1 |
|
2 |
|
3 | import { HttpHeaders } from "../httpHeaders";
|
4 | import { Constants } from "../util/constants";
|
5 | var HeaderConstants = Constants.HeaderConstants;
|
6 | var DEFAULT_AUTHORIZATION_SCHEME = "Bearer";
|
7 |
|
8 |
|
9 |
|
10 | var TokenCredentials = (function () {
|
11 | |
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 | function TokenCredentials(token, authorizationScheme) {
|
19 | if (authorizationScheme === void 0) { authorizationScheme = DEFAULT_AUTHORIZATION_SCHEME; }
|
20 | this.authorizationScheme = DEFAULT_AUTHORIZATION_SCHEME;
|
21 | if (!token) {
|
22 | throw new Error("token cannot be null or undefined.");
|
23 | }
|
24 | this.token = token;
|
25 | this.authorizationScheme = authorizationScheme;
|
26 | }
|
27 | |
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 | TokenCredentials.prototype.signRequest = function (webResource) {
|
34 | if (!webResource.headers)
|
35 | webResource.headers = new HttpHeaders();
|
36 | webResource.headers.set(HeaderConstants.AUTHORIZATION, this.authorizationScheme + " " + this.token);
|
37 | return Promise.resolve(webResource);
|
38 | };
|
39 | return TokenCredentials;
|
40 | }());
|
41 | export { TokenCredentials };
|
42 |
|
\ | No newline at end of file |