• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

microsoft / botbuilder-js / 14082303413

26 Mar 2025 11:36AM UTC coverage: 84.47% (-0.05%) from 84.524%
14082303413

push

github

web-flow
Update elliptic, esbuild, and serialize-javascript (#4862)

8260 of 10940 branches covered (75.5%)

Branch coverage included in aggregate %.

20572 of 23193 relevant lines covered (88.7%)

4032.56 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

76.92
/libraries/botframework-connector/src/auth/tokenCredentials.ts
1
// Copyright (c) Microsoft Corporation. All rights reserved.
2
// Licensed under the MIT License. See License.txt in the project root for license information.
3

4
import {
1✔
5
    HttpHeaders,
6
    Constants,
7
    WebResourceLike,
8
    ServiceClientCredentials,
9
} from 'botbuilder-stdlib/lib/azureCoreHttpCompat';
10

11
/**
12
 * A credentials object that uses a token string and a authorzation scheme to authenticate.
13
 */
14
export class TokenCredentials implements ServiceClientCredentials {
1✔
15
    token: string;
16
    authorizationScheme: string = Constants.HeaderConstants.AUTHORIZATION_SCHEME;
67✔
17

18
    /**
19
     * Creates a new TokenCredentials object.
20
     *
21
     * @class
22
     * @param {string} token The token.
23
     * @param {string} [authorizationScheme] The authorization scheme.
24
     */
25
    constructor(token: string, authorizationScheme: string = Constants.HeaderConstants.AUTHORIZATION_SCHEME) {
67✔
26
        if (!token) {
67!
27
            throw new Error('token cannot be null or undefined.');
×
28
        }
29
        this.token = token;
67✔
30
        this.authorizationScheme = authorizationScheme;
67✔
31
    }
32

33
    /**
34
     * Signs a request with the Authentication header.
35
     *
36
     * @param {WebResourceLike} webResource The WebResourceLike to be signed.
37
     * @returns {Promise<WebResourceLike>} The signed request object.
38
     */
39
    signRequest(webResource: WebResourceLike): Promise<WebResourceLike> {
40
        if (!webResource.headers) webResource.headers = new HttpHeaders();
81!
41
        webResource.headers.set(Constants.HeaderConstants.AUTHORIZATION, `${this.authorizationScheme} ${this.token}`);
81✔
42
        return Promise.resolve(webResource);
81✔
43
    }
44
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc