@azure/msal-common 4.5.0 → 4.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +15 -0
- package/LICENSE +21 -21
- package/README.md +61 -61
- package/changelog.md +398 -390
- package/dist/_virtual/_tslib.js +1 -1
- package/dist/account/AuthToken.js +7 -7
- package/dist/account/AuthToken.js.map +1 -1
- package/dist/account/CcsCredential.js +1 -1
- package/dist/account/CcsCredential.js.map +1 -1
- package/dist/account/ClientInfo.js +10 -10
- package/dist/account/ClientInfo.js.map +1 -1
- package/dist/authority/Authority.js +53 -53
- package/dist/authority/Authority.js.map +1 -1
- package/dist/authority/AuthorityFactory.js +9 -9
- package/dist/authority/AuthorityFactory.js.map +1 -1
- package/dist/authority/AuthorityType.js +1 -1
- package/dist/authority/AuthorityType.js.map +1 -1
- package/dist/authority/CloudInstanceDiscoveryResponse.js +1 -1
- package/dist/authority/CloudInstanceDiscoveryResponse.js.map +1 -1
- package/dist/authority/OpenIdConfigResponse.js +1 -1
- package/dist/authority/OpenIdConfigResponse.js.map +1 -1
- package/dist/authority/ProtocolMode.js +1 -1
- package/dist/authority/ProtocolMode.js.map +1 -1
- package/dist/authority/RegionDiscovery.js +9 -9
- package/dist/authority/RegionDiscovery.js.map +1 -1
- package/dist/cache/CacheManager.js +47 -47
- package/dist/cache/CacheManager.js.map +1 -1
- package/dist/cache/entities/AccessTokenEntity.js +11 -11
- package/dist/cache/entities/AccessTokenEntity.js.map +1 -1
- package/dist/cache/entities/AccountEntity.js +14 -14
- package/dist/cache/entities/AccountEntity.js.map +1 -1
- package/dist/cache/entities/AppMetadataEntity.js +1 -1
- package/dist/cache/entities/AppMetadataEntity.js.map +1 -1
- package/dist/cache/entities/AuthorityMetadataEntity.js +5 -5
- package/dist/cache/entities/AuthorityMetadataEntity.js.map +1 -1
- package/dist/cache/entities/CacheRecord.js +1 -1
- package/dist/cache/entities/CacheRecord.js.map +1 -1
- package/dist/cache/entities/CredentialEntity.js +5 -5
- package/dist/cache/entities/CredentialEntity.js.map +1 -1
- package/dist/cache/entities/IdTokenEntity.js +3 -3
- package/dist/cache/entities/IdTokenEntity.js.map +1 -1
- package/dist/cache/entities/RefreshTokenEntity.js +3 -3
- package/dist/cache/entities/RefreshTokenEntity.js.map +1 -1
- package/dist/cache/entities/ServerTelemetryEntity.js +1 -1
- package/dist/cache/entities/ServerTelemetryEntity.js.map +1 -1
- package/dist/cache/entities/ThrottlingEntity.js +1 -1
- package/dist/cache/entities/ThrottlingEntity.js.map +1 -1
- package/dist/cache/persistence/TokenCacheContext.js +3 -3
- package/dist/cache/persistence/TokenCacheContext.js.map +1 -1
- package/dist/client/AuthorizationCodeClient.js +32 -32
- package/dist/client/AuthorizationCodeClient.js.map +1 -1
- package/dist/client/BaseClient.js +11 -11
- package/dist/client/BaseClient.js.map +1 -1
- package/dist/client/ClientCredentialClient.js +17 -17
- package/dist/client/ClientCredentialClient.js.map +1 -1
- package/dist/client/DeviceCodeClient.js +25 -25
- package/dist/client/DeviceCodeClient.js.map +1 -1
- package/dist/client/OnBehalfOfClient.js +19 -19
- package/dist/client/OnBehalfOfClient.js.map +1 -1
- package/dist/client/RefreshTokenClient.js +25 -25
- package/dist/client/RefreshTokenClient.js.map +1 -1
- package/dist/client/SilentFlowClient.js +27 -27
- package/dist/client/SilentFlowClient.js.map +1 -1
- package/dist/client/UsernamePasswordClient.js +11 -11
- package/dist/client/UsernamePasswordClient.js.map +1 -1
- package/dist/config/ClientConfiguration.js +6 -6
- package/dist/config/ClientConfiguration.js.map +1 -1
- package/dist/crypto/ICrypto.js +8 -8
- package/dist/crypto/ICrypto.js.map +1 -1
- package/dist/crypto/PopTokenGenerator.js +9 -9
- package/dist/crypto/PopTokenGenerator.js.map +1 -1
- package/dist/error/AuthError.js +3 -3
- package/dist/error/AuthError.js.map +1 -1
- package/dist/error/ClientAuthError.js +3 -3
- package/dist/error/ClientAuthError.js.map +1 -1
- package/dist/error/ClientConfigurationError.js +3 -3
- package/dist/error/ClientConfigurationError.js.map +1 -1
- package/dist/error/InteractionRequiredAuthError.js +3 -3
- package/dist/error/InteractionRequiredAuthError.js.map +1 -1
- package/dist/error/ServerError.js +3 -3
- package/dist/error/ServerError.js.map +1 -1
- package/dist/index.cjs.js +70 -29
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +29 -29
- package/dist/logger/Logger.js +7 -7
- package/dist/logger/Logger.js.map +1 -1
- package/dist/network/INetworkModule.js +4 -4
- package/dist/network/INetworkModule.js.map +1 -1
- package/dist/network/NetworkManager.js +8 -8
- package/dist/network/NetworkManager.js.map +1 -1
- package/dist/network/ThrottlingUtils.js +4 -4
- package/dist/network/ThrottlingUtils.js.map +1 -1
- package/dist/packageMetadata.d.ts +1 -1
- package/dist/packageMetadata.js +2 -2
- package/dist/packageMetadata.js.map +1 -1
- package/dist/request/RequestParameterBuilder.js +18 -18
- package/dist/request/RequestParameterBuilder.js.map +1 -1
- package/dist/request/RequestValidator.js +10 -10
- package/dist/request/RequestValidator.js.map +1 -1
- package/dist/request/ScopeSet.js +14 -14
- package/dist/request/ScopeSet.js.map +1 -1
- package/dist/response/ResponseHandler.js +61 -61
- package/dist/response/ResponseHandler.js.map +1 -1
- package/dist/telemetry/server/ServerTelemetryManager.js +13 -13
- package/dist/telemetry/server/ServerTelemetryManager.js.map +1 -1
- package/dist/url/UrlString.js +24 -24
- package/dist/url/UrlString.js.map +1 -1
- package/dist/utils/Constants.js +1 -1
- package/dist/utils/Constants.js.map +1 -1
- package/dist/utils/ProtocolUtils.js +13 -13
- package/dist/utils/ProtocolUtils.js.map +1 -1
- package/dist/utils/StringUtils.js +5 -5
- package/dist/utils/StringUtils.js.map +1 -1
- package/dist/utils/TimeUtils.js +1 -1
- package/dist/utils/TimeUtils.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
/*! @azure/msal-common v4.5.
|
|
1
|
+
/*! @azure/msal-common v4.5.1 2021-08-02 */
|
|
2
2
|
'use strict';
|
|
3
3
|
import { __extends, __awaiter, __generator } from '../_virtual/_tslib.js';
|
|
4
|
+
import { BaseClient } from './BaseClient.js';
|
|
5
|
+
import { ScopeSet } from '../request/ScopeSet.js';
|
|
6
|
+
import { AuthToken } from '../account/AuthToken.js';
|
|
7
|
+
import { TimeUtils } from '../utils/TimeUtils.js';
|
|
8
|
+
import { RefreshTokenClient } from './RefreshTokenClient.js';
|
|
9
|
+
import { ClientAuthError, ClientAuthErrorMessage } from '../error/ClientAuthError.js';
|
|
10
|
+
import { ClientConfigurationError } from '../error/ClientConfigurationError.js';
|
|
11
|
+
import { ResponseHandler } from '../response/ResponseHandler.js';
|
|
4
12
|
import { CacheOutcome, AuthenticationScheme } from '../utils/Constants.js';
|
|
5
|
-
import {
|
|
6
|
-
import { StringUtils as StringUtils$1 } from '../utils/StringUtils.js';
|
|
7
|
-
import { ClientConfigurationError as ClientConfigurationError$1 } from '../error/ClientConfigurationError.js';
|
|
8
|
-
import { ScopeSet as ScopeSet$1 } from '../request/ScopeSet.js';
|
|
9
|
-
import { AuthToken as AuthToken$1 } from '../account/AuthToken.js';
|
|
10
|
-
import { BaseClient as BaseClient$1 } from './BaseClient.js';
|
|
11
|
-
import { TimeUtils as TimeUtils$1 } from '../utils/TimeUtils.js';
|
|
12
|
-
import { ResponseHandler as ResponseHandler$1 } from '../response/ResponseHandler.js';
|
|
13
|
-
import { RefreshTokenClient as RefreshTokenClient$1 } from './RefreshTokenClient.js';
|
|
13
|
+
import { StringUtils } from '../utils/StringUtils.js';
|
|
14
14
|
|
|
15
15
|
/*
|
|
16
16
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -37,8 +37,8 @@ var SilentFlowClient = /** @class */ (function (_super) {
|
|
|
37
37
|
case 1: return [2 /*return*/, _a.sent()];
|
|
38
38
|
case 2:
|
|
39
39
|
e_1 = _a.sent();
|
|
40
|
-
if (e_1 instanceof ClientAuthError
|
|
41
|
-
refreshTokenClient = new RefreshTokenClient
|
|
40
|
+
if (e_1 instanceof ClientAuthError && e_1.errorCode === ClientAuthErrorMessage.tokenRefreshRequired.code) {
|
|
41
|
+
refreshTokenClient = new RefreshTokenClient(this.config);
|
|
42
42
|
return [2 /*return*/, refreshTokenClient.acquireTokenByRefreshToken(request)];
|
|
43
43
|
}
|
|
44
44
|
else {
|
|
@@ -62,40 +62,40 @@ var SilentFlowClient = /** @class */ (function (_super) {
|
|
|
62
62
|
case 0:
|
|
63
63
|
// Cannot renew token if no request object is given.
|
|
64
64
|
if (!request) {
|
|
65
|
-
throw ClientConfigurationError
|
|
65
|
+
throw ClientConfigurationError.createEmptyTokenRequestError();
|
|
66
66
|
}
|
|
67
67
|
// We currently do not support silent flow for account === null use cases; This will be revisited for confidential flow usecases
|
|
68
68
|
if (!request.account) {
|
|
69
|
-
throw ClientAuthError
|
|
69
|
+
throw ClientAuthError.createNoAccountInSilentRequestError();
|
|
70
70
|
}
|
|
71
|
-
requestScopes = new ScopeSet
|
|
71
|
+
requestScopes = new ScopeSet(request.scopes || []);
|
|
72
72
|
environment = request.authority || this.authority.getPreferredCache();
|
|
73
73
|
authScheme = request.authenticationScheme || AuthenticationScheme.BEARER;
|
|
74
74
|
cacheRecord = this.cacheManager.readCacheRecord(request.account, this.config.authOptions.clientId, requestScopes, environment, authScheme);
|
|
75
75
|
if (request.forceRefresh) {
|
|
76
76
|
// Must refresh due to present force_refresh flag.
|
|
77
77
|
(_a = this.serverTelemetryManager) === null || _a === void 0 ? void 0 : _a.setCacheOutcome(CacheOutcome.FORCE_REFRESH);
|
|
78
|
-
throw ClientAuthError
|
|
78
|
+
throw ClientAuthError.createRefreshRequiredError();
|
|
79
79
|
}
|
|
80
80
|
else if (!cacheRecord.accessToken) {
|
|
81
81
|
// Must refresh due to non-existent access_token.
|
|
82
82
|
(_b = this.serverTelemetryManager) === null || _b === void 0 ? void 0 : _b.setCacheOutcome(CacheOutcome.NO_CACHED_ACCESS_TOKEN);
|
|
83
|
-
throw ClientAuthError
|
|
83
|
+
throw ClientAuthError.createRefreshRequiredError();
|
|
84
84
|
}
|
|
85
|
-
else if (TimeUtils
|
|
86
|
-
TimeUtils
|
|
85
|
+
else if (TimeUtils.wasClockTurnedBack(cacheRecord.accessToken.cachedAt) ||
|
|
86
|
+
TimeUtils.isTokenExpired(cacheRecord.accessToken.expiresOn, this.config.systemOptions.tokenRenewalOffsetSeconds)) {
|
|
87
87
|
// Must refresh due to expired access_token.
|
|
88
88
|
(_c = this.serverTelemetryManager) === null || _c === void 0 ? void 0 : _c.setCacheOutcome(CacheOutcome.CACHED_ACCESS_TOKEN_EXPIRED);
|
|
89
|
-
throw ClientAuthError
|
|
89
|
+
throw ClientAuthError.createRefreshRequiredError();
|
|
90
90
|
}
|
|
91
|
-
else if (cacheRecord.accessToken.refreshOn && TimeUtils
|
|
91
|
+
else if (cacheRecord.accessToken.refreshOn && TimeUtils.isTokenExpired(cacheRecord.accessToken.refreshOn, 0)) {
|
|
92
92
|
// Must refresh due to the refresh_in value.
|
|
93
93
|
(_d = this.serverTelemetryManager) === null || _d === void 0 ? void 0 : _d.setCacheOutcome(CacheOutcome.REFRESH_CACHED_ACCESS_TOKEN);
|
|
94
|
-
throw ClientAuthError
|
|
94
|
+
throw ClientAuthError.createRefreshRequiredError();
|
|
95
95
|
}
|
|
96
|
-
else if (!StringUtils
|
|
96
|
+
else if (!StringUtils.isEmptyObj(request.claims)) {
|
|
97
97
|
// Must refresh due to request parameters.
|
|
98
|
-
throw ClientAuthError
|
|
98
|
+
throw ClientAuthError.createRefreshRequiredError();
|
|
99
99
|
}
|
|
100
100
|
if (this.config.serverTelemetryManager) {
|
|
101
101
|
this.config.serverTelemetryManager.incrementCacheHits();
|
|
@@ -117,16 +117,16 @@ var SilentFlowClient = /** @class */ (function (_super) {
|
|
|
117
117
|
switch (_a.label) {
|
|
118
118
|
case 0:
|
|
119
119
|
if (cacheRecord.idToken) {
|
|
120
|
-
idTokenObj = new AuthToken
|
|
120
|
+
idTokenObj = new AuthToken(cacheRecord.idToken.secret, this.config.cryptoInterface);
|
|
121
121
|
}
|
|
122
|
-
return [4 /*yield*/, ResponseHandler
|
|
122
|
+
return [4 /*yield*/, ResponseHandler.generateAuthenticationResult(this.cryptoUtils, this.authority, cacheRecord, true, request, idTokenObj)];
|
|
123
123
|
case 1: return [2 /*return*/, _a.sent()];
|
|
124
124
|
}
|
|
125
125
|
});
|
|
126
126
|
});
|
|
127
127
|
};
|
|
128
128
|
return SilentFlowClient;
|
|
129
|
-
}(BaseClient
|
|
129
|
+
}(BaseClient));
|
|
130
130
|
|
|
131
131
|
export { SilentFlowClient };
|
|
132
132
|
//# sourceMappingURL=SilentFlowClient.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SilentFlowClient.js","sources":["../../src/client/SilentFlowClient.ts"],"sourcesContent":["/*\
|
|
1
|
+
{"version":3,"file":"SilentFlowClient.js","sources":["../../src/client/SilentFlowClient.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { BaseClient } from \"./BaseClient\";\nimport { ClientConfiguration } from \"../config/ClientConfiguration\";\nimport { CommonSilentFlowRequest } from \"../request/CommonSilentFlowRequest\";\nimport { AuthenticationResult } from \"../response/AuthenticationResult\";\nimport { ScopeSet } from \"../request/ScopeSet\";\nimport { AuthToken } from \"../account/AuthToken\";\nimport { TimeUtils } from \"../utils/TimeUtils\";\nimport { RefreshTokenClient } from \"./RefreshTokenClient\";\nimport { ClientAuthError, ClientAuthErrorMessage } from \"../error/ClientAuthError\";\nimport { ClientConfigurationError } from \"../error/ClientConfigurationError\";\nimport { ResponseHandler } from \"../response/ResponseHandler\";\nimport { CacheRecord } from \"../cache/entities/CacheRecord\";\nimport { AuthenticationScheme, CacheOutcome } from \"../utils/Constants\";\nimport { StringUtils } from \"../utils/StringUtils\";\n\nexport class SilentFlowClient extends BaseClient {\n\n constructor(configuration: ClientConfiguration) {\n super(configuration);\n }\n\n /**\n * Retrieves a token from cache if it is still valid, or uses the cached refresh token to renew\n * the given token and returns the renewed token\n * @param request\n */\n async acquireToken(request: CommonSilentFlowRequest): Promise<AuthenticationResult> {\n try {\n return await this.acquireCachedToken(request);\n } catch (e) {\n if (e instanceof ClientAuthError && e.errorCode === ClientAuthErrorMessage.tokenRefreshRequired.code) {\n const refreshTokenClient = new RefreshTokenClient(this.config);\n return refreshTokenClient.acquireTokenByRefreshToken(request);\n } else {\n throw e;\n }\n }\n }\n\n /**\n * Retrieves token from cache or throws an error if it must be refreshed.\n * @param request\n */\n async acquireCachedToken(request: CommonSilentFlowRequest): Promise<AuthenticationResult> {\n // Cannot renew token if no request object is given.\n if (!request) {\n throw ClientConfigurationError.createEmptyTokenRequestError();\n }\n\n // We currently do not support silent flow for account === null use cases; This will be revisited for confidential flow usecases\n if (!request.account) {\n throw ClientAuthError.createNoAccountInSilentRequestError();\n }\n const requestScopes = new ScopeSet(request.scopes || []);\n const environment = request.authority || this.authority.getPreferredCache();\n const authScheme = request.authenticationScheme || AuthenticationScheme.BEARER;\n const cacheRecord = this.cacheManager.readCacheRecord(request.account, this.config.authOptions.clientId, requestScopes, environment, authScheme);\n \n if (request.forceRefresh) {\n // Must refresh due to present force_refresh flag.\n this.serverTelemetryManager?.setCacheOutcome(CacheOutcome.FORCE_REFRESH);\n throw ClientAuthError.createRefreshRequiredError();\n } else if (!cacheRecord.accessToken) {\n // Must refresh due to non-existent access_token.\n this.serverTelemetryManager?.setCacheOutcome(CacheOutcome.NO_CACHED_ACCESS_TOKEN);\n throw ClientAuthError.createRefreshRequiredError();\n } else if (\n TimeUtils.wasClockTurnedBack(cacheRecord.accessToken.cachedAt) ||\n TimeUtils.isTokenExpired(cacheRecord.accessToken.expiresOn, this.config.systemOptions.tokenRenewalOffsetSeconds)\n ) {\n // Must refresh due to expired access_token.\n this.serverTelemetryManager?.setCacheOutcome(CacheOutcome.CACHED_ACCESS_TOKEN_EXPIRED);\n throw ClientAuthError.createRefreshRequiredError();\n } else if (cacheRecord.accessToken.refreshOn && TimeUtils.isTokenExpired(cacheRecord.accessToken.refreshOn, 0)) {\n // Must refresh due to the refresh_in value.\n this.serverTelemetryManager?.setCacheOutcome(CacheOutcome.REFRESH_CACHED_ACCESS_TOKEN);\n throw ClientAuthError.createRefreshRequiredError();\n } else if (!StringUtils.isEmptyObj(request.claims)) {\n // Must refresh due to request parameters.\n throw ClientAuthError.createRefreshRequiredError();\n }\n\n if (this.config.serverTelemetryManager) {\n this.config.serverTelemetryManager.incrementCacheHits();\n }\n\n return await this.generateResultFromCacheRecord(cacheRecord, request);\n }\n\n /**\n * Helper function to build response object from the CacheRecord\n * @param cacheRecord\n */\n private async generateResultFromCacheRecord(cacheRecord: CacheRecord, request: CommonSilentFlowRequest): Promise<AuthenticationResult> {\n let idTokenObj: AuthToken | undefined;\n if (cacheRecord.idToken) {\n idTokenObj = new AuthToken(cacheRecord.idToken.secret, this.config.cryptoInterface);\n }\n return await ResponseHandler.generateAuthenticationResult(\n this.cryptoUtils,\n this.authority,\n cacheRecord,\n true,\n request,\n idTokenObj\n );\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA;;;;;IAoBsC,oCAAU;IAE5C,0BAAY,aAAkC;eAC1C,kBAAM,aAAa,CAAC;KACvB;;;;;;IAOK,uCAAY,GAAlB,UAAmB,OAAgC;;;;;;;wBAEpC,qBAAM,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,EAAA;4BAA7C,sBAAO,SAAsC,EAAC;;;wBAE9C,IAAI,GAAC,YAAY,eAAe,IAAI,GAAC,CAAC,SAAS,KAAK,sBAAsB,CAAC,oBAAoB,CAAC,IAAI,EAAE;4BAC5F,kBAAkB,GAAG,IAAI,kBAAkB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;4BAC/D,sBAAO,kBAAkB,CAAC,0BAA0B,CAAC,OAAO,CAAC,EAAC;yBACjE;6BAAM;4BACH,MAAM,GAAC,CAAC;y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
|
1
|
+
/*! @azure/msal-common v4.5.1 2021-08-02 */
|
|
2
2
|
'use strict';
|
|
3
3
|
import { __extends, __awaiter, __generator } from '../_virtual/_tslib.js';
|
|
4
|
+
import { BaseClient } from './BaseClient.js';
|
|
5
|
+
import { ResponseHandler } from '../response/ResponseHandler.js';
|
|
6
|
+
import { RequestParameterBuilder } from '../request/RequestParameterBuilder.js';
|
|
4
7
|
import { GrantType } from '../utils/Constants.js';
|
|
5
|
-
import { StringUtils
|
|
8
|
+
import { StringUtils } from '../utils/StringUtils.js';
|
|
9
|
+
import { TimeUtils } from '../utils/TimeUtils.js';
|
|
6
10
|
import { CcsCredentialType } from '../account/CcsCredential.js';
|
|
7
|
-
import { BaseClient as BaseClient$1 } from './BaseClient.js';
|
|
8
|
-
import { RequestParameterBuilder as RequestParameterBuilder$1 } from '../request/RequestParameterBuilder.js';
|
|
9
|
-
import { TimeUtils as TimeUtils$1 } from '../utils/TimeUtils.js';
|
|
10
|
-
import { ResponseHandler as ResponseHandler$1 } from '../response/ResponseHandler.js';
|
|
11
11
|
|
|
12
12
|
/*
|
|
13
13
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -34,11 +34,11 @@ var UsernamePasswordClient = /** @class */ (function (_super) {
|
|
|
34
34
|
switch (_a.label) {
|
|
35
35
|
case 0:
|
|
36
36
|
this.logger.info("in acquireToken call");
|
|
37
|
-
reqTimestamp = TimeUtils
|
|
37
|
+
reqTimestamp = TimeUtils.nowSeconds();
|
|
38
38
|
return [4 /*yield*/, this.executeTokenRequest(this.authority, request)];
|
|
39
39
|
case 1:
|
|
40
40
|
response = _a.sent();
|
|
41
|
-
responseHandler = new ResponseHandler
|
|
41
|
+
responseHandler = new ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, this.config.serializableCache, this.config.persistencePlugin);
|
|
42
42
|
// Validate response. This function throws a server error if an error is returned by the server.
|
|
43
43
|
responseHandler.validateTokenResponse(response.body);
|
|
44
44
|
tokenResponse = responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request);
|
|
@@ -75,7 +75,7 @@ var UsernamePasswordClient = /** @class */ (function (_super) {
|
|
|
75
75
|
* @param request
|
|
76
76
|
*/
|
|
77
77
|
UsernamePasswordClient.prototype.createTokenRequestBody = function (request) {
|
|
78
|
-
var parameterBuilder = new RequestParameterBuilder
|
|
78
|
+
var parameterBuilder = new RequestParameterBuilder();
|
|
79
79
|
parameterBuilder.addClientId(this.config.authOptions.clientId);
|
|
80
80
|
parameterBuilder.addUsername(request.username);
|
|
81
81
|
parameterBuilder.addPassword(request.password);
|
|
@@ -97,7 +97,7 @@ var UsernamePasswordClient = /** @class */ (function (_super) {
|
|
|
97
97
|
parameterBuilder.addClientAssertion(clientAssertion.assertion);
|
|
98
98
|
parameterBuilder.addClientAssertionType(clientAssertion.assertionType);
|
|
99
99
|
}
|
|
100
|
-
if (!StringUtils
|
|
100
|
+
if (!StringUtils.isEmptyObj(request.claims) || this.config.authOptions.clientCapabilities && this.config.authOptions.clientCapabilities.length > 0) {
|
|
101
101
|
parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);
|
|
102
102
|
}
|
|
103
103
|
if (this.config.systemOptions.preventCorsPreflight && request.username) {
|
|
@@ -106,7 +106,7 @@ var UsernamePasswordClient = /** @class */ (function (_super) {
|
|
|
106
106
|
return parameterBuilder.createQueryString();
|
|
107
107
|
};
|
|
108
108
|
return UsernamePasswordClient;
|
|
109
|
-
}(BaseClient
|
|
109
|
+
}(BaseClient));
|
|
110
110
|
|
|
111
111
|
export { UsernamePasswordClient };
|
|
112
112
|
//# sourceMappingURL=UsernamePasswordClient.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UsernamePasswordClient.js","sources":["../../src/client/UsernamePasswordClient.ts"],"sourcesContent":["/*\
|
|
1
|
+
{"version":3,"file":"UsernamePasswordClient.js","sources":["../../src/client/UsernamePasswordClient.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { BaseClient } from \"./BaseClient\";\nimport { ClientConfiguration } from \"../config/ClientConfiguration\";\nimport { CommonUsernamePasswordRequest } from \"../request/CommonUsernamePasswordRequest\";\nimport { AuthenticationResult } from \"../response/AuthenticationResult\";\nimport { ResponseHandler } from \"../response/ResponseHandler\";\nimport { Authority } from \"../authority/Authority\";\nimport { NetworkResponse } from \"../network/NetworkManager\";\nimport { ServerAuthorizationTokenResponse } from \"../response/ServerAuthorizationTokenResponse\";\nimport { RequestParameterBuilder } from \"../request/RequestParameterBuilder\";\nimport { GrantType } from \"../utils/Constants\";\nimport { StringUtils } from \"../utils/StringUtils\";\nimport { RequestThumbprint } from \"../network/RequestThumbprint\";\nimport { TimeUtils } from \"../utils/TimeUtils\";\nimport { CcsCredentialType } from \"../account/CcsCredential\";\n\n/**\n * Oauth2.0 Password grant client\n * Note: We are only supporting public clients for password grant and for purely testing purposes\n */\nexport class UsernamePasswordClient extends BaseClient {\n\n constructor(configuration: ClientConfiguration) {\n super(configuration);\n }\n\n /**\n * API to acquire a token by passing the username and password to the service in exchage of credentials\n * password_grant\n * @param request\n */\n async acquireToken(request: CommonUsernamePasswordRequest): Promise<AuthenticationResult | null> {\n this.logger.info(\"in acquireToken call\");\n\n const reqTimestamp = TimeUtils.nowSeconds();\n const response = await this.executeTokenRequest(this.authority, request);\n\n const responseHandler = new ResponseHandler(\n this.config.authOptions.clientId,\n this.cacheManager,\n this.cryptoUtils,\n this.logger,\n this.config.serializableCache,\n this.config.persistencePlugin\n );\n\n // Validate response. This function throws a server error if an error is returned by the server.\n responseHandler.validateTokenResponse(response.body);\n const tokenResponse = responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request);\n\n return tokenResponse;\n }\n\n /**\n * Executes POST request to token endpoint\n * @param authority\n * @param request\n */\n private async executeTokenRequest(authority: Authority, request: CommonUsernamePasswordRequest): Promise<NetworkResponse<ServerAuthorizationTokenResponse>> {\n const thumbprint: RequestThumbprint = {\n clientId: this.config.authOptions.clientId,\n authority: authority.canonicalAuthority,\n scopes: request.scopes\n };\n const requestBody = this.createTokenRequestBody(request);\n const headers: Record<string, string> = this.createTokenRequestHeaders({\n credential: request.username,\n type: CcsCredentialType.UPN\n });\n\n return this.executePostToTokenEndpoint(authority.tokenEndpoint, requestBody, headers, thumbprint);\n }\n\n /**\n * Generates a map for all the params to be sent to the service\n * @param request\n */\n private createTokenRequestBody(request: CommonUsernamePasswordRequest): string {\n const parameterBuilder = new RequestParameterBuilder();\n\n parameterBuilder.addClientId(this.config.authOptions.clientId);\n parameterBuilder.addUsername(request.username);\n parameterBuilder.addPassword(request.password);\n\n parameterBuilder.addScopes(request.scopes);\n\n parameterBuilder.addGrantType(GrantType.RESOURCE_OWNER_PASSWORD_GRANT);\n parameterBuilder.addClientInfo();\n\n parameterBuilder.addLibraryInfo(this.config.libraryInfo);\n\n parameterBuilder.addThrottling();\n\n if (this.serverTelemetryManager) {\n parameterBuilder.addServerTelemetry(this.serverTelemetryManager);\n }\n\n const correlationId = request.correlationId || this.config.cryptoInterface.createNewGuid();\n parameterBuilder.addCorrelationId(correlationId);\n\n if (this.config.clientCredentials.clientSecret) {\n parameterBuilder.addClientSecret(this.config.clientCredentials.clientSecret);\n }\n\n if (this.config.clientCredentials.clientAssertion) {\n const clientAssertion = this.config.clientCredentials.clientAssertion;\n parameterBuilder.addClientAssertion(clientAssertion.assertion);\n parameterBuilder.addClientAssertionType(clientAssertion.assertionType);\n }\n\n if (!StringUtils.isEmptyObj(request.claims) || this.config.authOptions.clientCapabilities && this.config.authOptions.clientCapabilities.length > 0) {\n parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);\n }\n\n if (this.config.systemOptions.preventCorsPreflight && request.username) {\n parameterBuilder.addCcsUpn(request.username);\n }\n\n return parameterBuilder.createQueryString();\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAAA;;;;AAoBA;;;;;IAI4C,0CAAU;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e,GAAG,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,eAAe,CAAC;YACtE,gBAAgB,CAAC,kBAAkB,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;YAC/D,gBAAgB,CAAC,sBAAsB,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC;SAC1E;QAED,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,kBAAkB,IAAI,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,kBAAkB,CAAC,MAAM,GAAG,CAAC,EAAE;YAChJ,gBAAgB,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAC;SAC1F;QAED,IAAI,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,oBAAoB,IAAI,OAAO,CAAC,QAAQ,EAAE;YACpE,gBAAgB,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;SAChD;QAED,OAAO,gBAAgB,CAAC,iBAAiB,EAAE,CAAC;KAC/C;IACL,6BAAC;AAAD,CApGA,CAA4C,UAAU;;;;"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
/*! @azure/msal-common v4.5.
|
|
1
|
+
/*! @azure/msal-common v4.5.1 2021-08-02 */
|
|
2
2
|
'use strict';
|
|
3
3
|
import { __assign, __awaiter, __generator } from '../_virtual/_tslib.js';
|
|
4
|
-
import { Constants as Constants$1 } from '../utils/Constants.js';
|
|
5
|
-
import { AuthError as AuthError$1 } from '../error/AuthError.js';
|
|
6
4
|
import { DEFAULT_CRYPTO_IMPLEMENTATION } from '../crypto/ICrypto.js';
|
|
5
|
+
import { AuthError } from '../error/AuthError.js';
|
|
7
6
|
import { LogLevel } from '../logger/Logger.js';
|
|
7
|
+
import { Constants } from '../utils/Constants.js';
|
|
8
8
|
import { version } from '../packageMetadata.js';
|
|
9
9
|
import { DefaultStorageClass } from '../cache/CacheManager.js';
|
|
10
10
|
|
|
@@ -32,7 +32,7 @@ var DEFAULT_NETWORK_IMPLEMENTATION = {
|
|
|
32
32
|
var notImplErr;
|
|
33
33
|
return __generator(this, function (_a) {
|
|
34
34
|
notImplErr = "Network interface - sendGetRequestAsync() has not been implemented";
|
|
35
|
-
throw AuthError
|
|
35
|
+
throw AuthError.createUnexpectedError(notImplErr);
|
|
36
36
|
});
|
|
37
37
|
});
|
|
38
38
|
},
|
|
@@ -41,13 +41,13 @@ var DEFAULT_NETWORK_IMPLEMENTATION = {
|
|
|
41
41
|
var notImplErr;
|
|
42
42
|
return __generator(this, function (_a) {
|
|
43
43
|
notImplErr = "Network interface - sendPostRequestAsync() has not been implemented";
|
|
44
|
-
throw AuthError
|
|
44
|
+
throw AuthError.createUnexpectedError(notImplErr);
|
|
45
45
|
});
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
49
|
var DEFAULT_LIBRARY_INFO = {
|
|
50
|
-
sku: Constants
|
|
50
|
+
sku: Constants.SKU,
|
|
51
51
|
version: version,
|
|
52
52
|
cpu: "",
|
|
53
53
|
os: ""
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClientConfiguration.js","sources":["../../src/config/ClientConfiguration.ts"],"sourcesContent":["/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { INetworkModule } from \"../network/INetworkModule\";\r\nimport { DEFAULT_CRYPTO_IMPLEMENTATION, ICrypto } from \"../crypto/ICrypto\";\r\nimport { AuthError } from \"../error/AuthError\";\r\nimport { ILoggerCallback, LogLevel } from \"../logger/Logger\";\r\nimport { Constants } from \"../utils/Constants\";\r\nimport { version } from \"../packageMetadata\";\r\nimport { Authority } from \"../authority/Authority\";\r\nimport { CacheManager, DefaultStorageClass } from \"../cache/CacheManager\";\r\nimport { ServerTelemetryManager } from \"../telemetry/server/ServerTelemetryManager\";\r\nimport { ICachePlugin } from \"../cache/interface/ICachePlugin\";\r\nimport { ISerializableTokenCache } from \"../cache/interface/ISerializableTokenCache\";\r\n\r\n// Token renewal offset default in seconds\r\nconst DEFAULT_TOKEN_RENEWAL_OFFSET_SEC = 300;\r\n\r\n/**\r\n * Use the configuration object to configure MSAL Modules and initialize the base interfaces for MSAL.\r\n *\r\n * This object allows you to configure important elements of MSAL functionality:\r\n * - authOptions - Authentication for application\r\n * - cryptoInterface - Implementation of crypto functions\r\n * - libraryInfo - Library metadata\r\n * - loggerOptions - Logging for application\r\n * - networkInterface - Network implementation\r\n * - storageInterface - Storage implementation\r\n * - systemOptions - Additional library options\r\n * - clientCredentials - Credentials options for confidential clients\r\n */\r\nexport type ClientConfiguration = {\r\n authOptions: AuthOptions,\r\n systemOptions?: SystemOptions,\r\n loggerOptions?: LoggerOptions,\r\n storageInterface?: CacheManager,\r\n networkInterface?: INetworkModule,\r\n cryptoInterface?: ICrypto,\r\n clientCredentials?: ClientCredentials,\r\n libraryInfo?: LibraryInfo\r\n serverTelemetryManager?: ServerTelemetryManager | null,\r\n persistencePlugin?: ICachePlugin | null,\r\n serializableCache?: ISerializableTokenCache | null\r\n};\r\n\r\nexport type CommonClientConfiguration = {\r\n authOptions: Required<AuthOptions>,\r\n systemOptions: Required<SystemOptions>,\r\n loggerOptions : Required<LoggerOptions>,\r\n storageInterface: CacheManager,\r\n networkInterface : INetworkModule,\r\n cryptoInterface : Required<ICrypto>,\r\n libraryInfo : LibraryInfo,\r\n serverTelemetryManager: ServerTelemetryManager | null,\r\n clientCredentials: ClientCredentials,\r\n persistencePlugin: ICachePlugin | null,\r\n serializableCache: ISerializableTokenCache | null\r\n};\r\n\r\n/**\r\n * Use this to configure the auth options in the ClientConfiguration object\r\n *\r\n * - clientId - Client ID of your app registered with our Application registration portal : https://portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/RegisteredAppsPreview in Microsoft Identity Platform\r\n * - authority - You can configure a specific authority, defaults to \" \" or \"https://login.microsoftonline.com/common\"\r\n * - knownAuthorities - An array of URIs that are known to be valid. Used in B2C scenarios.\r\n * - cloudDiscoveryMetadata - A string containing the cloud discovery response. Used in AAD scenarios.\r\n * - clientCapabilities - Array of capabilities which will be added to the claims.access_token.xms_cc request property on every network request.\r\n * - protocolMode - Enum that represents the protocol that msal follows. Used for configuring proper endpoints.\r\n */\r\nexport type AuthOptions = {\r\n clientId: string;\r\n authority: Authority;\r\n clientCapabilities?: Array<string>;\r\n};\r\n\r\n/**\r\n * Use this to configure token renewal info in the Configuration object\r\n *\r\n * - tokenRenewalOffsetSeconds - Sets the window of offset needed to renew the token before expiry\r\n */\r\nexport type SystemOptions = {\r\n tokenRenewalOffsetSeconds?: number;\r\n preventCorsPreflight?: boolean;\r\n};\r\n\r\n/**\r\n * Use this to configure the logging that MSAL does, by configuring logger options in the Configuration object\r\n *\r\n * - loggerCallback - Callback for logger\r\n * - piiLoggingEnabled - Sets whether pii logging is enabled\r\n * - logLevel - Sets the level at which logging happens\r\n * - correlationId - Sets the correlationId printed by the logger\r\n */\r\nexport type LoggerOptions = {\r\n loggerCallback?: ILoggerCallback,\r\n piiLoggingEnabled?: boolean,\r\n logLevel?: LogLevel,\r\n correlationId?: string\r\n};\r\n\r\n/**\r\n * Library-specific options\r\n */\r\nexport type LibraryInfo = {\r\n sku: string,\r\n version: string,\r\n cpu: string,\r\n os: string\r\n};\r\n\r\n/**\r\n * Credentials for confidential clients\r\n */\r\nexport type ClientCredentials = {\r\n clientSecret?: string,\r\n clientAssertion? : {\r\n assertion: string,\r\n assertionType: string\r\n };\r\n};\r\n\r\nexport const DEFAULT_SYSTEM_OPTIONS: Required<SystemOptions> = {\r\n tokenRenewalOffsetSeconds: DEFAULT_TOKEN_RENEWAL_OFFSET_SEC,\r\n preventCorsPreflight: false\r\n};\r\n\r\nconst DEFAULT_LOGGER_IMPLEMENTATION: Required<LoggerOptions> = {\r\n loggerCallback: () => {\r\n // allow users to not set loggerCallback\r\n },\r\n piiLoggingEnabled: false,\r\n logLevel: LogLevel.Info,\r\n correlationId: \"\"\r\n};\r\n\r\nconst DEFAULT_NETWORK_IMPLEMENTATION: INetworkModule = {\r\n async sendGetRequestAsync<T>(): Promise<T> {\r\n const notImplErr = \"Network interface - sendGetRequestAsync() has not been implemented\";\r\n throw AuthError.createUnexpectedError(notImplErr);\r\n },\r\n async sendPostRequestAsync<T>(): Promise<T> {\r\n const notImplErr = \"Network interface - sendPostRequestAsync() has not been implemented\";\r\n throw AuthError.createUnexpectedError(notImplErr);\r\n }\r\n};\r\n\r\nconst DEFAULT_LIBRARY_INFO: LibraryInfo = {\r\n sku: Constants.SKU,\r\n version: version,\r\n cpu: \"\",\r\n os: \"\"\r\n};\r\n\r\nconst DEFAULT_CLIENT_CREDENTIALS: ClientCredentials = {\r\n clientSecret: \"\",\r\n clientAssertion: undefined\r\n};\r\n\r\n/**\r\n * Function that sets the default options when not explicitly configured from app developer\r\n *\r\n * @param Configuration\r\n *\r\n * @returns Configuration\r\n */\r\nexport function buildClientConfiguration(\r\n {\r\n authOptions: userAuthOptions,\r\n systemOptions: userSystemOptions,\r\n loggerOptions: userLoggerOption,\r\n storageInterface: storageImplementation,\r\n networkInterface: networkImplementation,\r\n cryptoInterface: cryptoImplementation,\r\n clientCredentials: clientCredentials,\r\n libraryInfo: libraryInfo,\r\n serverTelemetryManager: serverTelemetryManager,\r\n persistencePlugin: persistencePlugin,\r\n serializableCache: serializableCache\r\n }: ClientConfiguration): CommonClientConfiguration {\r\n\r\n return {\r\n authOptions: buildAuthOptions(userAuthOptions),\r\n systemOptions: { ...DEFAULT_SYSTEM_OPTIONS, ...userSystemOptions },\r\n loggerOptions: { ...DEFAULT_LOGGER_IMPLEMENTATION, ...userLoggerOption },\r\n storageInterface: storageImplementation || new DefaultStorageClass(userAuthOptions.clientId, DEFAULT_CRYPTO_IMPLEMENTATION),\r\n networkInterface: networkImplementation || DEFAULT_NETWORK_IMPLEMENTATION,\r\n cryptoInterface: cryptoImplementation || DEFAULT_CRYPTO_IMPLEMENTATION,\r\n clientCredentials: clientCredentials || DEFAULT_CLIENT_CREDENTIALS,\r\n libraryInfo: { ...DEFAULT_LIBRARY_INFO, ...libraryInfo },\r\n serverTelemetryManager: serverTelemetryManager || null,\r\n persistencePlugin: persistencePlugin || null,\r\n serializableCache: serializableCache || null\r\n };\r\n}\r\n\r\n/**\r\n * Construct authoptions from the client and platform passed values\r\n * @param authOptions\r\n */\r\nfunction buildAuthOptions(authOptions: AuthOptions): Required<AuthOptions> {\r\n return {\r\n clientCapabilities: [],\r\n ...authOptions\r\n };\r\n}\r\n"],"names":["AuthError","Constants"],"mappings":";;;;;;;;;;AAAA;;;;AAiBA;AACA,IAAM,gCAAgC,GAAG,GAAG,CAAC;IAyGhC,sBAAsB,GAA4B;IAC3D,yBAAyB,EAAE,gCAAgC;IAC3D,oBAAoB,EAAE,KAAK;EAC7B;AAEF,IAAM,6BAA6B,GAA4B;IAC3D,cAAc,EAAE;;KAEf;IACD,iBAAiB,EAAE,KAAK;IACxB,QAAQ,EAAE,QAAQ,CAAC,IAAI;IACvB,aAAa,EAAE,EAAE;CACpB,CAAC;AAEF,IAAM,8BAA8B,GAAmB;IAC7C,mBAAmB,EAAzB;;;;gBACU,UAAU,GAAG,oEAAoE,CAAC;gBACxF,MAAMA,WAAS,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;;;KACrD;IACK,oBAAoB,EAA1B;;;;gBACU,UAAU,GAAG,qEAAqE,CAAC;gBACzF,MAAMA,WAAS,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;;;KACrD;CACJ,CAAC;AAEF,IAAM,oBAAoB,GAAgB;IACtC,GAAG,EAAEC,WAAS,CAAC,GAAG;IAClB,OAAO,EAAE,OAAO;IAChB,GAAG,EAAE,EAAE;IACP,EAAE,EAAE,EAAE;CACT,CAAC;AAEF,IAAM,0BAA0B,GAAsB;IAClD,YAAY,EAAE,EAAE;IAChB,eAAe,EAAE,SAAS;CAC7B,CAAC;AAEF;;;;;;;SAOgB,wBAAwB,CACpC,EAYsB;QAXlB,gCAA4B,EAC5B,oCAAgC,EAChC,mCAA+B,EAC/B,2CAAuC,EACvC,2CAAuC,EACvC,yCAAqC,EACrC,wCAAoC,EACpC,4BAAwB,EACxB,kDAA8C,EAC9C,wCAAoC,EACpC,wCAAoC;IAGxC,OAAO;QACH,WAAW,EAAE,gBAAgB,CAAC,eAAe,CAAC;QAC9C,aAAa,wBAAO,sBAAsB,GAAK,iBAAiB,CAAE;QAClE,aAAa,wBAAO,6BAA6B,GAAK,gBAAgB,CAAE;QACxE,gBAAgB,EAAE,qBAAqB,IAAI,IAAI,mBAAmB,CAAC,eAAe,CAAC,QAAQ,EAAE,6BAA6B,CAAC;QAC3H,gBAAgB,EAAE,qBAAqB,IAAI,8BAA8B;QACzE,eAAe,EAAE,oBAAoB,IAAI,6BAA6B;QACtE,iBAAiB,EAAE,iBAAiB,IAAI,0BAA0B;QAClE,WAAW,wBAAO,oBAAoB,GAAK,WAAW,CAAE;QACxD,sBAAsB,EAAE,sBAAsB,IAAI,IAAI;QACtD,iBAAiB,EAAE,iBAAiB,IAAI,IAAI;QAC5C,iBAAiB,EAAE,iBAAiB,IAAI,IAAI;KAC/C,CAAC;AACN,CAAC;AAED;;;;AAIA,SAAS,gBAAgB,CAAC,WAAwB;IAC9C,kBACI,kBAAkB,EAAE,EAAE,IACnB,WAAW,EAChB;AACN;;;;"}
|
|
1
|
+
{"version":3,"file":"ClientConfiguration.js","sources":["../../src/config/ClientConfiguration.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { INetworkModule } from \"../network/INetworkModule\";\nimport { DEFAULT_CRYPTO_IMPLEMENTATION, ICrypto } from \"../crypto/ICrypto\";\nimport { AuthError } from \"../error/AuthError\";\nimport { ILoggerCallback, LogLevel } from \"../logger/Logger\";\nimport { Constants } from \"../utils/Constants\";\nimport { version } from \"../packageMetadata\";\nimport { Authority } from \"../authority/Authority\";\nimport { CacheManager, DefaultStorageClass } from \"../cache/CacheManager\";\nimport { ServerTelemetryManager } from \"../telemetry/server/ServerTelemetryManager\";\nimport { ICachePlugin } from \"../cache/interface/ICachePlugin\";\nimport { ISerializableTokenCache } from \"../cache/interface/ISerializableTokenCache\";\n\n// Token renewal offset default in seconds\nconst DEFAULT_TOKEN_RENEWAL_OFFSET_SEC = 300;\n\n/**\n * Use the configuration object to configure MSAL Modules and initialize the base interfaces for MSAL.\n *\n * This object allows you to configure important elements of MSAL functionality:\n * - authOptions - Authentication for application\n * - cryptoInterface - Implementation of crypto functions\n * - libraryInfo - Library metadata\n * - loggerOptions - Logging for application\n * - networkInterface - Network implementation\n * - storageInterface - Storage implementation\n * - systemOptions - Additional library options\n * - clientCredentials - Credentials options for confidential clients\n */\nexport type ClientConfiguration = {\n authOptions: AuthOptions,\n systemOptions?: SystemOptions,\n loggerOptions?: LoggerOptions,\n storageInterface?: CacheManager,\n networkInterface?: INetworkModule,\n cryptoInterface?: ICrypto,\n clientCredentials?: ClientCredentials,\n libraryInfo?: LibraryInfo\n serverTelemetryManager?: ServerTelemetryManager | null,\n persistencePlugin?: ICachePlugin | null,\n serializableCache?: ISerializableTokenCache | null\n};\n\nexport type CommonClientConfiguration = {\n authOptions: Required<AuthOptions>,\n systemOptions: Required<SystemOptions>,\n loggerOptions : Required<LoggerOptions>,\n storageInterface: CacheManager,\n networkInterface : INetworkModule,\n cryptoInterface : Required<ICrypto>,\n libraryInfo : LibraryInfo,\n serverTelemetryManager: ServerTelemetryManager | null,\n clientCredentials: ClientCredentials,\n persistencePlugin: ICachePlugin | null,\n serializableCache: ISerializableTokenCache | null\n};\n\n/**\n * Use this to configure the auth options in the ClientConfiguration object\n *\n * - clientId - Client ID of your app registered with our Application registration portal : https://portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/RegisteredAppsPreview in Microsoft Identity Platform\n * - authority - You can configure a specific authority, defaults to \" \" or \"https://login.microsoftonline.com/common\"\n * - knownAuthorities - An array of URIs that are known to be valid. Used in B2C scenarios.\n * - cloudDiscoveryMetadata - A string containing the cloud discovery response. Used in AAD scenarios.\n * - clientCapabilities - Array of capabilities which will be added to the claims.access_token.xms_cc request property on every network request.\n * - protocolMode - Enum that represents the protocol that msal follows. Used for configuring proper endpoints.\n */\nexport type AuthOptions = {\n clientId: string;\n authority: Authority;\n clientCapabilities?: Array<string>;\n};\n\n/**\n * Use this to configure token renewal info in the Configuration object\n *\n * - tokenRenewalOffsetSeconds - Sets the window of offset needed to renew the token before expiry\n */\nexport type SystemOptions = {\n tokenRenewalOffsetSeconds?: number;\n preventCorsPreflight?: boolean;\n};\n\n/**\n * Use this to configure the logging that MSAL does, by configuring logger options in the Configuration object\n *\n * - loggerCallback - Callback for logger\n * - piiLoggingEnabled - Sets whether pii logging is enabled\n * - logLevel - Sets the level at which logging happens\n * - correlationId - Sets the correlationId printed by the logger\n */\nexport type LoggerOptions = {\n loggerCallback?: ILoggerCallback,\n piiLoggingEnabled?: boolean,\n logLevel?: LogLevel,\n correlationId?: string\n};\n\n/**\n * Library-specific options\n */\nexport type LibraryInfo = {\n sku: string,\n version: string,\n cpu: string,\n os: string\n};\n\n/**\n * Credentials for confidential clients\n */\nexport type ClientCredentials = {\n clientSecret?: string,\n clientAssertion? : {\n assertion: string,\n assertionType: string\n };\n};\n\nexport const DEFAULT_SYSTEM_OPTIONS: Required<SystemOptions> = {\n tokenRenewalOffsetSeconds: DEFAULT_TOKEN_RENEWAL_OFFSET_SEC,\n preventCorsPreflight: false\n};\n\nconst DEFAULT_LOGGER_IMPLEMENTATION: Required<LoggerOptions> = {\n loggerCallback: () => {\n // allow users to not set loggerCallback\n },\n piiLoggingEnabled: false,\n logLevel: LogLevel.Info,\n correlationId: \"\"\n};\n\nconst DEFAULT_NETWORK_IMPLEMENTATION: INetworkModule = {\n async sendGetRequestAsync<T>(): Promise<T> {\n const notImplErr = \"Network interface - sendGetRequestAsync() has not been implemented\";\n throw AuthError.createUnexpectedError(notImplErr);\n },\n async sendPostRequestAsync<T>(): Promise<T> {\n const notImplErr = \"Network interface - sendPostRequestAsync() has not been implemented\";\n throw AuthError.createUnexpectedError(notImplErr);\n }\n};\n\nconst DEFAULT_LIBRARY_INFO: LibraryInfo = {\n sku: Constants.SKU,\n version: version,\n cpu: \"\",\n os: \"\"\n};\n\nconst DEFAULT_CLIENT_CREDENTIALS: ClientCredentials = {\n clientSecret: \"\",\n clientAssertion: undefined\n};\n\n/**\n * Function that sets the default options when not explicitly configured from app developer\n *\n * @param Configuration\n *\n * @returns Configuration\n */\nexport function buildClientConfiguration(\n {\n authOptions: userAuthOptions,\n systemOptions: userSystemOptions,\n loggerOptions: userLoggerOption,\n storageInterface: storageImplementation,\n networkInterface: networkImplementation,\n cryptoInterface: cryptoImplementation,\n clientCredentials: clientCredentials,\n libraryInfo: libraryInfo,\n serverTelemetryManager: serverTelemetryManager,\n persistencePlugin: persistencePlugin,\n serializableCache: serializableCache\n }: ClientConfiguration): CommonClientConfiguration {\n\n return {\n authOptions: buildAuthOptions(userAuthOptions),\n systemOptions: { ...DEFAULT_SYSTEM_OPTIONS, ...userSystemOptions },\n loggerOptions: { ...DEFAULT_LOGGER_IMPLEMENTATION, ...userLoggerOption },\n storageInterface: storageImplementation || new DefaultStorageClass(userAuthOptions.clientId, DEFAULT_CRYPTO_IMPLEMENTATION),\n networkInterface: networkImplementation || DEFAULT_NETWORK_IMPLEMENTATION,\n cryptoInterface: cryptoImplementation || DEFAULT_CRYPTO_IMPLEMENTATION,\n clientCredentials: clientCredentials || DEFAULT_CLIENT_CREDENTIALS,\n libraryInfo: { ...DEFAULT_LIBRARY_INFO, ...libraryInfo },\n serverTelemetryManager: serverTelemetryManager || null,\n persistencePlugin: persistencePlugin || null,\n serializableCache: serializableCache || null\n };\n}\n\n/**\n * Construct authoptions from the client and platform passed values\n * @param authOptions\n */\nfunction buildAuthOptions(authOptions: AuthO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AC9C,aAAa,wBAAO,sBAAsB,GAAK,iBAAiB,CAAE;QAClE,aAAa,wBAAO,6BAA6B,GAAK,gBAAgB,CAAE;QACxE,gBAAgB,EAAE,qBAAqB,IAAI,IAAI,mBAAmB,CAAC,eAAe,CAAC,QAAQ,EAAE,6BAA6B,CAAC;QAC3H,gBAAgB,EAAE,qBAAqB,IAAI,8BAA8B;QACzE,eAAe,EAAE,oBAAoB,IAAI,6BAA6B;QACtE,iBAAiB,EAAE,iBAAiB,IAAI,0BAA0B;QAClE,WAAW,wBAAO,oBAAoB,GAAK,WAAW,CAAE;QACxD,sBAAsB,EAAE,sBAAsB,IAAI,IAAI;QACtD,iBAAiB,EAAE,iBAAiB,IAAI,IAAI;QAC5C,iBAAiB,EAAE,iBAAiB,IAAI,IAAI;KAC/C,CAAC;AACN,CAAC;AAED;;;;AAIA,SAAS,gBAAgB,CAAC,WAAwB;IAC9C,kBACI,kBAAkB,EAAE,EAAE,IACnB,WAAW,EAChB;AACN;;;;"}
|
package/dist/crypto/ICrypto.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/*! @azure/msal-common v4.5.
|
|
1
|
+
/*! @azure/msal-common v4.5.1 2021-08-02 */
|
|
2
2
|
'use strict';
|
|
3
3
|
import { __awaiter, __generator } from '../_virtual/_tslib.js';
|
|
4
|
-
import { AuthError
|
|
4
|
+
import { AuthError } from '../error/AuthError.js';
|
|
5
5
|
|
|
6
6
|
/*
|
|
7
7
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -10,22 +10,22 @@ import { AuthError as AuthError$1 } from '../error/AuthError.js';
|
|
|
10
10
|
var DEFAULT_CRYPTO_IMPLEMENTATION = {
|
|
11
11
|
createNewGuid: function () {
|
|
12
12
|
var notImplErr = "Crypto interface - createNewGuid() has not been implemented";
|
|
13
|
-
throw AuthError
|
|
13
|
+
throw AuthError.createUnexpectedError(notImplErr);
|
|
14
14
|
},
|
|
15
15
|
base64Decode: function () {
|
|
16
16
|
var notImplErr = "Crypto interface - base64Decode() has not been implemented";
|
|
17
|
-
throw AuthError
|
|
17
|
+
throw AuthError.createUnexpectedError(notImplErr);
|
|
18
18
|
},
|
|
19
19
|
base64Encode: function () {
|
|
20
20
|
var notImplErr = "Crypto interface - base64Encode() has not been implemented";
|
|
21
|
-
throw AuthError
|
|
21
|
+
throw AuthError.createUnexpectedError(notImplErr);
|
|
22
22
|
},
|
|
23
23
|
generatePkceCodes: function () {
|
|
24
24
|
return __awaiter(this, void 0, void 0, function () {
|
|
25
25
|
var notImplErr;
|
|
26
26
|
return __generator(this, function (_a) {
|
|
27
27
|
notImplErr = "Crypto interface - generatePkceCodes() has not been implemented";
|
|
28
|
-
throw AuthError
|
|
28
|
+
throw AuthError.createUnexpectedError(notImplErr);
|
|
29
29
|
});
|
|
30
30
|
});
|
|
31
31
|
},
|
|
@@ -34,7 +34,7 @@ var DEFAULT_CRYPTO_IMPLEMENTATION = {
|
|
|
34
34
|
var notImplErr;
|
|
35
35
|
return __generator(this, function (_a) {
|
|
36
36
|
notImplErr = "Crypto interface - getPublicKeyThumbprint() has not been implemented";
|
|
37
|
-
throw AuthError
|
|
37
|
+
throw AuthError.createUnexpectedError(notImplErr);
|
|
38
38
|
});
|
|
39
39
|
});
|
|
40
40
|
},
|
|
@@ -43,7 +43,7 @@ var DEFAULT_CRYPTO_IMPLEMENTATION = {
|
|
|
43
43
|
var notImplErr;
|
|
44
44
|
return __generator(this, function (_a) {
|
|
45
45
|
notImplErr = "Crypto interface - signJwt() has not been implemented";
|
|
46
|
-
throw AuthError
|
|
46
|
+
throw AuthError.createUnexpectedError(notImplErr);
|
|
47
47
|
});
|
|
48
48
|
});
|
|
49
49
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ICrypto.js","sources":["../../src/crypto/ICrypto.ts"],"sourcesContent":["/*\
|
|
1
|
+
{"version":3,"file":"ICrypto.js","sources":["../../src/crypto/ICrypto.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { AuthError } from \"../error/AuthError\";\nimport { BaseAuthRequest } from \"../request/BaseAuthRequest\";\nimport { SignedHttpRequest } from \"./SignedHttpRequest\";\n\n/**\n * The PkceCodes type describes the structure\n * of objects that contain PKCE code\n * challenge and verifier pairs\n */\nexport type PkceCodes = {\n verifier: string,\n challenge: string\n};\n\n/**\n * Interface for crypto functions used by library\n */\nexport interface ICrypto {\n /**\n * Creates a guid randomly.\n */\n createNewGuid(): string;\n /**\n * base64 Encode string\n * @param input \n */\n base64Encode(input: string): string;\n /**\n * base64 decode string\n * @param input \n */\n base64Decode(input: string): string;\n /**\n * Generate PKCE codes for OAuth. See RFC here: https://tools.ietf.org/html/rfc7636\n */\n generatePkceCodes(): Promise<PkceCodes>;\n /**\n * Generates an JWK RSA S256 Thumbprint\n * @param request\n */\n getPublicKeyThumbprint(request: BaseAuthRequest): Promise<string>;\n /** \n * Returns a signed proof-of-possession token with a given acces token that contains a cnf claim with the required kid.\n * @param accessToken \n */\n signJwt(payload: SignedHttpRequest, kid: string): Promise<string>;\n}\n\nexport const DEFAULT_CRYPTO_IMPLEMENTATION: ICrypto = {\n createNewGuid: (): string => {\n const notImplErr = \"Crypto interface - createNewGuid() has not been implemented\";\n throw AuthError.createUnexpectedError(notImplErr);\n },\n base64Decode: (): string => {\n const notImplErr = \"Crypto interface - base64Decode() has not been implemented\";\n throw AuthError.createUnexpectedError(notImplErr);\n },\n base64Encode: (): string => {\n const notImplErr = \"Crypto interface - base64Encode() has not been implemented\";\n throw AuthError.createUnexpectedError(notImplErr);\n },\n async generatePkceCodes(): Promise<PkceCodes> {\n const notImplErr = \"Crypto interface - generatePkceCodes() has not been implemented\";\n throw AuthError.createUnexpectedError(notImplErr);\n },\n async getPublicKeyThumbprint(): Promise<string> {\n const notImplErr = \"Crypto interface - getPublicKeyThumbprint() has not been implemented\";\n throw AuthError.createUnexpectedError(notImplErr);\n },\n async signJwt(): Promise<string> {\n const notImplErr = \"Crypto interface - signJwt() has not been implemented\";\n throw AuthError.createUnexpectedError(notImplErr);\n }\n};\n"],"names":[],"mappings":";;;;;AAAA;;;;IAqDa,6BAA6B,GAAY;IAClD,aAAa,EAAE;QACX,IAAM,UAAU,GAAG,6DAA6D,CAAC;QACjF,MAAM,SAAS,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;KACrD;IACD,YAAY,EAAE;QACV,IAAM,UAAU,GAAG,4DAA4D,CAAC;QAChF,MAAM,SAAS,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;KACrD;IACD,YAAY,EAAE;QACV,IAAM,UAAU,GAAG,4DAA4D,CAAC;QAChF,MAAM,SAAS,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;KACrD;IACK,iBAAiB,EAAvB;;;;gBACU,UAAU,GAAG,iEAAiE,CAAC;gBACrF,MAAM,SAAS,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;;;KACrD;IACK,sBAAsB,EAA5B;;;;gBACU,UAAU,GAAG,sEAAsE,CAAC;gBAC1F,MAAM,SAAS,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;;;KACrD;IACK,OAAO,EAAb;;;;gBACU,UAAU,GAAG,uDAAuD,CAAC;gBAC3E,MAAM,SAAS,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;;;KACrD;;;;;"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
/*! @azure/msal-common v4.5.
|
|
1
|
+
/*! @azure/msal-common v4.5.1 2021-08-02 */
|
|
2
2
|
'use strict';
|
|
3
3
|
import { __awaiter, __generator } from '../_virtual/_tslib.js';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
4
|
+
import { AuthToken } from '../account/AuthToken.js';
|
|
5
|
+
import { TimeUtils } from '../utils/TimeUtils.js';
|
|
6
|
+
import { UrlString } from '../url/UrlString.js';
|
|
7
|
+
import { ClientAuthError } from '../error/ClientAuthError.js';
|
|
8
8
|
|
|
9
9
|
/*
|
|
10
10
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -43,16 +43,16 @@ var PopTokenGenerator = /** @class */ (function () {
|
|
|
43
43
|
return __generator(this, function (_b) {
|
|
44
44
|
switch (_b.label) {
|
|
45
45
|
case 0:
|
|
46
|
-
tokenClaims = AuthToken
|
|
46
|
+
tokenClaims = AuthToken.extractTokenClaims(accessToken, this.cryptoUtils);
|
|
47
47
|
resourceRequestMethod = request.resourceRequestMethod, resourceRequestUri = request.resourceRequestUri, shrClaims = request.shrClaims;
|
|
48
|
-
resourceUrlString = (resourceRequestUri) ? new UrlString
|
|
48
|
+
resourceUrlString = (resourceRequestUri) ? new UrlString(resourceRequestUri) : undefined;
|
|
49
49
|
resourceUrlComponents = resourceUrlString === null || resourceUrlString === void 0 ? void 0 : resourceUrlString.getUrlComponents();
|
|
50
50
|
if (!((_a = tokenClaims === null || tokenClaims === void 0 ? void 0 : tokenClaims.cnf) === null || _a === void 0 ? void 0 : _a.kid)) {
|
|
51
|
-
throw ClientAuthError
|
|
51
|
+
throw ClientAuthError.createTokenClaimsRequiredError();
|
|
52
52
|
}
|
|
53
53
|
return [4 /*yield*/, this.cryptoUtils.signJwt({
|
|
54
54
|
at: accessToken,
|
|
55
|
-
ts: TimeUtils
|
|
55
|
+
ts: TimeUtils.nowSeconds(),
|
|
56
56
|
m: resourceRequestMethod === null || resourceRequestMethod === void 0 ? void 0 : resourceRequestMethod.toUpperCase(),
|
|
57
57
|
u: resourceUrlComponents === null || resourceUrlComponents === void 0 ? void 0 : resourceUrlComponents.HostNameAndPort,
|
|
58
58
|
nonce: this.cryptoUtils.createNewGuid(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PopTokenGenerator.js","sources":["../../src/crypto/PopTokenGenerator.ts"],"sourcesContent":["/*\
|
|
1
|
+
{"version":3,"file":"PopTokenGenerator.js","sources":["../../src/crypto/PopTokenGenerator.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ICrypto } from \"./ICrypto\";\nimport { AuthToken } from \"../account/AuthToken\";\nimport { TokenClaims } from \"../account/TokenClaims\";\nimport { TimeUtils } from \"../utils/TimeUtils\";\nimport { UrlString } from \"../url/UrlString\";\nimport { ClientAuthError } from \"../error/ClientAuthError\";\nimport { BaseAuthRequest } from \"../request/BaseAuthRequest\";\n\n/**\n * See eSTS docs for more info.\n * - A kid element, with the value containing an RFC 7638-compliant JWK thumbprint that is base64 encoded.\n * - xms_ksl element, representing the storage location of the key's secret component on the client device. One of two values:\n * - sw: software storage\n * - uhw: hardware storage\n */\ntype ReqCnf = {\n kid: string;\n xms_ksl: KeyLocation;\n};\n\nenum KeyLocation {\n SW = \"sw\",\n UHW = \"uhw\"\n}\n\nexport class PopTokenGenerator {\n\n private cryptoUtils: ICrypto;\n\n constructor(cryptoUtils: ICrypto) {\n this.cryptoUtils = cryptoUtils;\n }\n\n async generateCnf(request: BaseAuthRequest): Promise<string> {\n const kidThumbprint = await this.cryptoUtils.getPublicKeyThumbprint(request);\n const reqCnf: ReqCnf = {\n kid: kidThumbprint,\n xms_ksl: KeyLocation.SW\n };\n return this.cryptoUtils.base64Encode(JSON.stringify(reqCnf));\n }\n\n async signPopToken(accessToken: string, request: BaseAuthRequest): Promise<string> {\n const tokenClaims: TokenClaims | null = AuthToken.extractTokenClaims(accessToken, this.cryptoUtils);\n\n // Deconstruct request to extract SHR parameters\n const { resourceRequestMethod, resourceRequestUri, shrClaims } = request;\n\n const resourceUrlString = (resourceRequestUri) ? new UrlString(resourceRequestUri) : undefined;\n const resourceUrlComponents = resourceUrlString?.getUrlComponents();\n\n if (!tokenClaims?.cnf?.kid) {\n throw ClientAuthError.createTokenClaimsRequiredError();\n }\n\n return await this.cryptoUtils.signJwt({\n at: accessToken,\n ts: TimeUtils.nowSeconds(),\n m: resourceRequestMethod?.toUpperCase(),\n u: resourceUrlComponents?.HostNameAndPort,\n nonce: this.cryptoUtils.createNewGuid(),\n p: resourceUrlComponents?.AbsolutePath,\n q: (resourceUrlComponents?.QueryString) ? [[], resourceUrlComponents.QueryString] : undefined,\n client_claims: shrClaims || undefined\n }, tokenClaims.cnf.kid);\n }\n}\n"],"names":[],"mappings":";;;;;;;;AAAA;;;;AAyBA,IAAK,WAGJ;AAHD,WAAK,WAAW;IACZ,wBAAS,CAAA;IACT,0BAAW,CAAA;AACf,CAAC,EAHI,WAAW,KAAX,WAAW,QAGf;;IAMG,2BAAY,WAAoB;QAC5B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;KAClC;IAEK,uCAAW,GAAjB,UAAkB,OAAwB;;;;;4BAChB,qBAAM,IAAI,CAAC,WAAW,CAAC,sBAAsB,CAAC,OAAO,CAAC,EAAA;;wBAAtE,aAAa,GAAG,SAAsD;wBACtE,MAAM,GAAW;4BACnB,GAAG,EAAE,aAAa;4BAClB,OAAO,EAAE,WAAW,CAAC,EAAE;yBAC1B,CAAC;wBACF,sBAAO,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,EAAC;;;;KAChE;IAEK,wCAAY,GAAlB,UAAmB,WAAmB,EAAE,OAAwB;;;;;;;wBACtD,WAAW,GAAuB,SAAS,CAAC,kBAAkB,CAAC,WAAW,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;wBAG5F,qBAAqB,GAAoC,OAAO,sBAA3C,EAAE,kBAAkB,GAAgB,OAAO,mBAAvB,EAAE,SAAS,GAAK,OAAO,UAAZ,CAAa;wBAEnE,iBAAiB,GAAG,CAAC,kBAAkB,IAAI,IAAI,SAAS,CAAC,kBAAkB,CAAC,GAAG,SAAS,CAAC;wBACzF,qBAAqB,GAAG,iBAAiB,aAAjB,iBAAiB,uBAAjB,iBAAiB,CAAE,gBAAgB,EAAE,CAAC;wBAEpE,IAAI,QAAC,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,GAAG,0CAAE,GAAG,CAAA,EAAE;4BACxB,MAAM,eAAe,CAAC,8BAA8B,EAAE,CAAC;yBAC1D;wBAEM,qBAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC;gCAClC,EAAE,EAAE,WAAW;gCACf,EAAE,EAAE,SAAS,CAAC,UAAU,EAAE;gCAC1B,CAAC,EAAE,qBAAqB,aAArB,qBAAqB,uBAArB,qBAAqB,CAAE,WAAW,EAAE;gCACvC,CAAC,EAAE,qBAAqB,aAArB,qBAAqB,uBAArB,qBAAqB,CAAE,eAAe;gCACzC,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,aAAa,EAAE;gCACvC,CAAC,EAAE,qBAAqB,aAArB,qBAAqB,uBAArB,qBAAqB,CAAE,YAAY;gCACtC,CAAC,EAAE,CAAC,qBAAqB,aAArB,qBAAqB,uBAArB,qBAAqB,CAAE,WAAW,IAAI,CAAC,EAAE,EAAE,qBAAqB,CAAC,WAAW,CAAC,GAAG,SAAS;gCAC7F,aAAa,EAAE,SAAS,IAAI,SAAS;6BACxC,EAAE,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,EAAA;4BATvB,sBAAO,SASgB,EAAC;;;;KAC3B;IACL,wBAAC;AAAD,CAAC;;;;"}
|
package/dist/error/AuthError.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/*! @azure/msal-common v4.5.
|
|
1
|
+
/*! @azure/msal-common v4.5.1 2021-08-02 */
|
|
2
2
|
'use strict';
|
|
3
3
|
import { __extends } from '../_virtual/_tslib.js';
|
|
4
|
-
import { Constants
|
|
4
|
+
import { Constants } from '../utils/Constants.js';
|
|
5
5
|
|
|
6
6
|
/*
|
|
7
7
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -26,7 +26,7 @@ var AuthError = /** @class */ (function (_super) {
|
|
|
26
26
|
var errorString = errorMessage ? errorCode + ": " + errorMessage : errorCode;
|
|
27
27
|
_this = _super.call(this, errorString) || this;
|
|
28
28
|
Object.setPrototypeOf(_this, AuthError.prototype);
|
|
29
|
-
_this.errorCode = errorCode || Constants
|
|
29
|
+
_this.errorCode = errorCode || Constants.EMPTY_STRING;
|
|
30
30
|
_this.errorMessage = errorMessage || "";
|
|
31
31
|
_this.subError = suberror || "";
|
|
32
32
|
_this.name = "AuthError";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthError.js","sources":["../../src/error/AuthError.ts"],"sourcesContent":["/*\
|
|
1
|
+
{"version":3,"file":"AuthError.js","sources":["../../src/error/AuthError.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { Constants } from \"../utils/Constants\";\n\n/**\n * AuthErrorMessage class containing string constants used by error codes and messages.\n */\nexport const AuthErrorMessage = {\n unexpectedError: {\n code: \"unexpected_error\",\n desc: \"Unexpected error in authentication.\"\n }\n};\n\n/**\n * General error class thrown by the MSAL.js library.\n */\nexport class AuthError extends Error {\n\n /**\n * Short string denoting error\n */\n errorCode: string;\n\n /**\n * Detailed description of error\n */\n errorMessage: string;\n\n /**\n * Describes the subclass of an error\n */\n subError: string;\n\n constructor(errorCode?: string, errorMessage?: string, suberror?: string) {\n const errorString = errorMessage ? `${errorCode}: ${errorMessage}` : errorCode;\n super(errorString);\n Object.setPrototypeOf(this, AuthError.prototype);\n\n this.errorCode = errorCode || Constants.EMPTY_STRING;\n this.errorMessage = errorMessage || \"\";\n this.subError = suberror || \"\";\n this.name = \"AuthError\";\n }\n\n /**\n * Creates an error that is thrown when something unexpected happens in the library.\n * @param errDesc\n */\n static createUnexpectedError(errDesc: string): AuthError {\n return new AuthError(AuthErrorMessage.unexpectedError.code, `${AuthErrorMessage.unexpectedError.desc}: ${errDesc}`);\n }\n}\n"],"names":[],"mappings":";;;;;AAAA;;;;AAOA;;;IAGa,gBAAgB,GAAG;IAC5B,eAAe,EAAE;QACb,IAAI,EAAE,kBAAkB;QACxB,IAAI,EAAE,qCAAqC;KAC9C;EACH;AAEF;;;;IAG+B,6BAAK;IAiBhC,mBAAY,SAAkB,EAAE,YAAqB,EAAE,QAAiB;QAAxE,iBASC;QARG,IAAM,WAAW,GAAG,YAAY,GAAM,SAAS,UAAK,YAAc,GAAG,SAAS,CAAC;QAC/E,QAAA,kBAAM,WAAW,CAAC,SAAC;QACnB,MAAM,CAAC,cAAc,CAAC,KAAI,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;QAEjD,KAAI,CAAC,SAAS,GAAG,SAAS,IAAI,SAAS,CAAC,YAAY,CAAC;QACrD,KAAI,CAAC,YAAY,GAAG,YAAY,IAAI,EAAE,CAAC;QACvC,KAAI,CAAC,QAAQ,GAAG,QAAQ,IAAI,EAAE,CAAC;QAC/B,KAAI,CAAC,IAAI,GAAG,WAAW,CAAC;;KAC3B;;;;;IAMM,+BAAqB,GAA5B,UAA6B,OAAe;QACxC,OAAO,IAAI,SAAS,CAAC,gBAAgB,CAAC,eAAe,CAAC,IAAI,EAAK,gBAAgB,CAAC,eAAe,CAAC,IAAI,UAAK,OAAS,CAAC,CAAC;KACvH;IACL,gBAAC;AAAD,CAnCA,CAA+B,KAAK;;;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/*! @azure/msal-common v4.5.
|
|
1
|
+
/*! @azure/msal-common v4.5.1 2021-08-02 */
|
|
2
2
|
'use strict';
|
|
3
3
|
import { __extends } from '../_virtual/_tslib.js';
|
|
4
|
-
import { AuthError
|
|
4
|
+
import { AuthError } from './AuthError.js';
|
|
5
5
|
|
|
6
6
|
/*
|
|
7
7
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -450,7 +450,7 @@ var ClientAuthError = /** @class */ (function (_super) {
|
|
|
450
450
|
return new ClientAuthError(ClientAuthErrorMessage.noAuthorizationCodeFromServer.code, ClientAuthErrorMessage.noAuthorizationCodeFromServer.desc);
|
|
451
451
|
};
|
|
452
452
|
return ClientAuthError;
|
|
453
|
-
}(AuthError
|
|
453
|
+
}(AuthError));
|
|
454
454
|
|
|
455
455
|
export { ClientAuthError, ClientAuthErrorMessage };
|
|
456
456
|
//# sourceMappingURL=ClientAuthError.js.map
|