@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
package/dist/_virtual/_tslib.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
|
-
import { ClientAuthError
|
|
4
|
-
import { StringUtils
|
|
3
|
+
import { ClientAuthError } from '../error/ClientAuthError.js';
|
|
4
|
+
import { StringUtils } from '../utils/StringUtils.js';
|
|
5
5
|
|
|
6
6
|
/*
|
|
7
7
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -12,8 +12,8 @@ import { StringUtils as StringUtils$1 } from '../utils/StringUtils.js';
|
|
|
12
12
|
*/
|
|
13
13
|
var AuthToken = /** @class */ (function () {
|
|
14
14
|
function AuthToken(rawToken, crypto) {
|
|
15
|
-
if (StringUtils
|
|
16
|
-
throw ClientAuthError
|
|
15
|
+
if (StringUtils.isEmpty(rawToken)) {
|
|
16
|
+
throw ClientAuthError.createTokenNullOrEmptyError(rawToken);
|
|
17
17
|
}
|
|
18
18
|
this.rawToken = rawToken;
|
|
19
19
|
this.claims = AuthToken.extractTokenClaims(rawToken, crypto);
|
|
@@ -24,7 +24,7 @@ var AuthToken = /** @class */ (function () {
|
|
|
24
24
|
* @param encodedToken
|
|
25
25
|
*/
|
|
26
26
|
AuthToken.extractTokenClaims = function (encodedToken, crypto) {
|
|
27
|
-
var decodedToken = StringUtils
|
|
27
|
+
var decodedToken = StringUtils.decodeAuthToken(encodedToken);
|
|
28
28
|
// token will be decoded to get the username
|
|
29
29
|
try {
|
|
30
30
|
var base64TokenPayload = decodedToken.JWSPayload;
|
|
@@ -33,7 +33,7 @@ var AuthToken = /** @class */ (function () {
|
|
|
33
33
|
return JSON.parse(base64Decoded);
|
|
34
34
|
}
|
|
35
35
|
catch (err) {
|
|
36
|
-
throw ClientAuthError
|
|
36
|
+
throw ClientAuthError.createTokenParsingError(err);
|
|
37
37
|
}
|
|
38
38
|
};
|
|
39
39
|
return AuthToken;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthToken.js","sources":["../../src/account/AuthToken.ts"],"sourcesContent":["/*\
|
|
1
|
+
{"version":3,"file":"AuthToken.js","sources":["../../src/account/AuthToken.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TokenClaims } from \"./TokenClaims\";\nimport { DecodedAuthToken } from \"./DecodedAuthToken\";\nimport { ClientAuthError } from \"../error/ClientAuthError\";\nimport { StringUtils } from \"../utils/StringUtils\";\nimport { ICrypto } from \"../crypto/ICrypto\";\n\n/**\n * JWT Token representation class. Parses token string and generates claims object.\n */\nexport class AuthToken {\n\n // Raw Token string\n rawToken: string;\n // Claims inside token\n claims: TokenClaims;\n constructor(rawToken: string, crypto: ICrypto) {\n if (StringUtils.isEmpty(rawToken)) {\n throw ClientAuthError.createTokenNullOrEmptyError(rawToken);\n }\n\n this.rawToken = rawToken;\n this.claims = AuthToken.extractTokenClaims(rawToken, crypto);\n }\n\n /**\n * Extract token by decoding the rawToken\n *\n * @param encodedToken\n */\n static extractTokenClaims(encodedToken: string, crypto: ICrypto): TokenClaims {\n\n const decodedToken: DecodedAuthToken = StringUtils.decodeAuthToken(encodedToken);\n\n // token will be decoded to get the username\n try {\n const base64TokenPayload = decodedToken.JWSPayload;\n\n // base64Decode() should throw an error if there is an issue\n const base64Decoded = crypto.base64Decode(base64TokenPayload);\n return JSON.parse(base64Decoded) as TokenClaims;\n } catch (err) {\n throw ClientAuthError.createTokenParsingError(err);\n }\n }\n}\n"],"names":[],"mappings":";;;;;AAAA;;;;AAWA;;;;IASI,mBAAY,QAAgB,EAAE,MAAe;QACzC,IAAI,WAAW,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;YAC/B,MAAM,eAAe,CAAC,2BAA2B,CAAC,QAAQ,CAAC,CAAC;SAC/D;QAED,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC,kBAAkB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;KAChE;;;;;;IAOM,4BAAkB,GAAzB,UAA0B,YAAoB,EAAE,MAAe;QAE3D,IAAM,YAAY,GAAqB,WAAW,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;;QAGjF,IAAI;YACA,IAAM,kBAAkB,GAAG,YAAY,CAAC,UAAU,CAAC;;YAGnD,IAAM,aAAa,GAAG,MAAM,CAAC,YAAY,CAAC,kBAAkB,CAAC,CAAC;YAC9D,OAAO,IAAI,CAAC,KAAK,CAAC,aAAa,CAAgB,CAAC;SACnD;QAAC,OAAO,GAAG,EAAE;YACV,MAAM,eAAe,CAAC,uBAAuB,CAAC,GAAG,CAAC,CAAC;SACtD;KACJ;IACL,gBAAC;AAAD,CAAC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CcsCredential.js","sources":["../../src/account/CcsCredential.ts"],"sourcesContent":["/*\
|
|
1
|
+
{"version":3,"file":"CcsCredential.js","sources":["../../src/account/CcsCredential.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport type CcsCredential = {\n credential: string,\n type: CcsCredentialType\n};\n\nexport enum CcsCredentialType {\n HOME_ACCOUNT_ID = \"home_account_id\",\n UPN = \"UPN\"\n}\n"],"names":[],"mappings":";;AAAA;;;;IAUY;AAAZ,WAAY,iBAAiB;IACzB,wDAAmC,CAAA;IACnC,gCAAW,CAAA;AACf,CAAC,EAHW,iBAAiB,KAAjB,iBAAiB;;;;"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/*! @azure/msal-common v4.5.
|
|
1
|
+
/*! @azure/msal-common v4.5.1 2021-08-02 */
|
|
2
2
|
'use strict';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import { ClientAuthError } from '../error/ClientAuthError.js';
|
|
4
|
+
import { StringUtils } from '../utils/StringUtils.js';
|
|
5
|
+
import { Constants, Separators } from '../utils/Constants.js';
|
|
6
6
|
|
|
7
7
|
/*
|
|
8
8
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -14,15 +14,15 @@ import { StringUtils as StringUtils$1 } from '../utils/StringUtils.js';
|
|
|
14
14
|
* @param crypto
|
|
15
15
|
*/
|
|
16
16
|
function buildClientInfo(rawClientInfo, crypto) {
|
|
17
|
-
if (StringUtils
|
|
18
|
-
throw ClientAuthError
|
|
17
|
+
if (StringUtils.isEmpty(rawClientInfo)) {
|
|
18
|
+
throw ClientAuthError.createClientInfoEmptyError();
|
|
19
19
|
}
|
|
20
20
|
try {
|
|
21
21
|
var decodedClientInfo = crypto.base64Decode(rawClientInfo);
|
|
22
22
|
return JSON.parse(decodedClientInfo);
|
|
23
23
|
}
|
|
24
24
|
catch (e) {
|
|
25
|
-
throw ClientAuthError
|
|
25
|
+
throw ClientAuthError.createClientInfoDecodingError(e);
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
@@ -30,13 +30,13 @@ function buildClientInfo(rawClientInfo, crypto) {
|
|
|
30
30
|
* @param homeAccountId
|
|
31
31
|
*/
|
|
32
32
|
function buildClientInfoFromHomeAccountId(homeAccountId) {
|
|
33
|
-
if (StringUtils
|
|
34
|
-
throw ClientAuthError
|
|
33
|
+
if (StringUtils.isEmpty(homeAccountId)) {
|
|
34
|
+
throw ClientAuthError.createClientInfoDecodingError("Home account ID was empty.");
|
|
35
35
|
}
|
|
36
36
|
var clientInfoParts = homeAccountId.split(Separators.CLIENT_INFO_SEPARATOR, 2);
|
|
37
37
|
return {
|
|
38
38
|
uid: clientInfoParts[0],
|
|
39
|
-
utid: clientInfoParts.length < 2 ? Constants
|
|
39
|
+
utid: clientInfoParts.length < 2 ? Constants.EMPTY_STRING : clientInfoParts[1]
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
42
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClientInfo.js","sources":["../../src/account/ClientInfo.ts"],"sourcesContent":["/*\
|
|
1
|
+
{"version":3,"file":"ClientInfo.js","sources":["../../src/account/ClientInfo.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ClientAuthError } from \"../error/ClientAuthError\";\nimport { StringUtils } from \"../utils/StringUtils\";\nimport { ICrypto } from \"../crypto/ICrypto\";\nimport { Separators, Constants } from \"../utils/Constants\";\n\n/**\n * Client info object which consists of two IDs. Need to add more info here.\n */\nexport type ClientInfo = {\n uid: string,\n utid: string\n};\n\n/**\n * Function to build a client info object from server clientInfo string\n * @param rawClientInfo\n * @param crypto\n */\nexport function buildClientInfo(rawClientInfo: string, crypto: ICrypto): ClientInfo {\n if (StringUtils.isEmpty(rawClientInfo)) {\n throw ClientAuthError.createClientInfoEmptyError();\n }\n\n try {\n const decodedClientInfo: string = crypto.base64Decode(rawClientInfo);\n return JSON.parse(decodedClientInfo) as ClientInfo;\n } catch (e) {\n throw ClientAuthError.createClientInfoDecodingError(e);\n }\n}\n\n/**\n * Function to build a client info object from cached homeAccountId string\n * @param homeAccountId \n */\nexport function buildClientInfoFromHomeAccountId(homeAccountId: string): ClientInfo {\n if (StringUtils.isEmpty(homeAccountId)) {\n throw ClientAuthError.createClientInfoDecodingError(\"Home account ID was empty.\");\n }\n const clientInfoParts: string[] = homeAccountId.split(Separators.CLIENT_INFO_SEPARATOR, 2);\n return {\n uid: clientInfoParts[0],\n utid: clientInfoParts.length < 2 ? Constants.EMPTY_STRING : clientInfoParts[1]\n };\n}\n"],"names":[],"mappings":";;;;;;AAAA;;;;AAkBA;;;;;SAKgB,eAAe,CAAC,aAAqB,EAAE,MAAe;IAClE,IAAI,WAAW,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE;QACpC,MAAM,eAAe,CAAC,0BAA0B,EAAE,CAAC;KACtD;IAED,IAAI;QACA,IAAM,iBAAiB,GAAW,MAAM,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;QACrE,OAAO,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAe,CAAC;KACtD;IAAC,OAAO,CAAC,EAAE;QACR,MAAM,eAAe,CAAC,6BAA6B,CAAC,CAAC,CAAC,CAAC;KAC1D;AACL,CAAC;AAED;;;;SAIgB,gCAAgC,CAAC,aAAqB;IAClE,IAAI,WAAW,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE;QACpC,MAAM,eAAe,CAAC,6BAA6B,CAAC,4BAA4B,CAAC,CAAC;KACrF;IACD,IAAM,eAAe,GAAa,aAAa,CAAC,KAAK,CAAC,UAAU,CAAC,qBAAqB,EAAE,CAAC,CAAC,CAAC;IAC3F,OAAO;QACH,GAAG,EAAE,eAAe,CAAC,CAAC,CAAC;QACvB,IAAI,EAAE,eAAe,CAAC,MAAM,GAAG,CAAC,GAAG,SAAS,CAAC,YAAY,GAAG,eAAe,CAAC,CAAC,CAAC;KACjF,CAAC;AACN;;;;"}
|
|
@@ -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 { __awaiter, __generator, __assign } from '../_virtual/_tslib.js';
|
|
4
|
-
import {
|
|
5
|
-
import { ClientAuthError as ClientAuthError$1 } from '../error/ClientAuthError.js';
|
|
6
|
-
import { ClientConfigurationError as ClientConfigurationError$1 } from '../error/ClientConfigurationError.js';
|
|
7
|
-
import { AuthorityType as AuthorityType$1 } from './AuthorityType.js';
|
|
8
|
-
import { UrlString as UrlString$1 } from '../url/UrlString.js';
|
|
4
|
+
import { AuthorityType } from './AuthorityType.js';
|
|
9
5
|
import { isOpenIdConfigResponse } from './OpenIdConfigResponse.js';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
6
|
+
import { UrlString } from '../url/UrlString.js';
|
|
7
|
+
import { ClientAuthError } from '../error/ClientAuthError.js';
|
|
8
|
+
import { Constants, AuthorityMetadataSource, RegionDiscoveryOutcomes } from '../utils/Constants.js';
|
|
9
|
+
import { ClientConfigurationError } from '../error/ClientConfigurationError.js';
|
|
10
|
+
import { ProtocolMode } from './ProtocolMode.js';
|
|
11
|
+
import { AuthorityMetadataEntity } from '../cache/entities/AuthorityMetadataEntity.js';
|
|
12
12
|
import { isCloudInstanceDiscoveryResponse } from './CloudInstanceDiscoveryResponse.js';
|
|
13
|
-
import { RegionDiscovery
|
|
13
|
+
import { RegionDiscovery } from './RegionDiscovery.js';
|
|
14
14
|
|
|
15
15
|
/*
|
|
16
16
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -27,19 +27,19 @@ var Authority = /** @class */ (function () {
|
|
|
27
27
|
this.networkInterface = networkInterface;
|
|
28
28
|
this.cacheManager = cacheManager;
|
|
29
29
|
this.authorityOptions = authorityOptions;
|
|
30
|
-
this.regionDiscovery = new RegionDiscovery
|
|
30
|
+
this.regionDiscovery = new RegionDiscovery(networkInterface);
|
|
31
31
|
this.regionDiscoveryMetadata = { region_used: undefined, region_source: undefined, region_outcome: undefined };
|
|
32
32
|
}
|
|
33
33
|
Object.defineProperty(Authority.prototype, "authorityType", {
|
|
34
34
|
// See above for AuthorityType
|
|
35
35
|
get: function () {
|
|
36
36
|
var pathSegments = this.canonicalAuthorityUrlComponents.PathSegments;
|
|
37
|
-
if (pathSegments.length && pathSegments[0].toLowerCase() === Constants
|
|
38
|
-
return AuthorityType
|
|
37
|
+
if (pathSegments.length && pathSegments[0].toLowerCase() === Constants.ADFS) {
|
|
38
|
+
return AuthorityType.Adfs;
|
|
39
39
|
}
|
|
40
|
-
return AuthorityType
|
|
40
|
+
return AuthorityType.Default;
|
|
41
41
|
},
|
|
42
|
-
enumerable:
|
|
42
|
+
enumerable: false,
|
|
43
43
|
configurable: true
|
|
44
44
|
});
|
|
45
45
|
Object.defineProperty(Authority.prototype, "protocolMode", {
|
|
@@ -49,7 +49,7 @@ var Authority = /** @class */ (function () {
|
|
|
49
49
|
get: function () {
|
|
50
50
|
return this.authorityOptions.protocolMode;
|
|
51
51
|
},
|
|
52
|
-
enumerable:
|
|
52
|
+
enumerable: false,
|
|
53
53
|
configurable: true
|
|
54
54
|
});
|
|
55
55
|
Object.defineProperty(Authority.prototype, "options", {
|
|
@@ -59,7 +59,7 @@ var Authority = /** @class */ (function () {
|
|
|
59
59
|
get: function () {
|
|
60
60
|
return this.authorityOptions;
|
|
61
61
|
},
|
|
62
|
-
enumerable:
|
|
62
|
+
enumerable: false,
|
|
63
63
|
configurable: true
|
|
64
64
|
});
|
|
65
65
|
Object.defineProperty(Authority.prototype, "canonicalAuthority", {
|
|
@@ -73,11 +73,11 @@ var Authority = /** @class */ (function () {
|
|
|
73
73
|
* Sets canonical authority.
|
|
74
74
|
*/
|
|
75
75
|
set: function (url) {
|
|
76
|
-
this._canonicalAuthority = new UrlString
|
|
76
|
+
this._canonicalAuthority = new UrlString(url);
|
|
77
77
|
this._canonicalAuthority.validateAsUri();
|
|
78
78
|
this._canonicalAuthorityUrlComponents = null;
|
|
79
79
|
},
|
|
80
|
-
enumerable:
|
|
80
|
+
enumerable: false,
|
|
81
81
|
configurable: true
|
|
82
82
|
});
|
|
83
83
|
Object.defineProperty(Authority.prototype, "canonicalAuthorityUrlComponents", {
|
|
@@ -90,7 +90,7 @@ var Authority = /** @class */ (function () {
|
|
|
90
90
|
}
|
|
91
91
|
return this._canonicalAuthorityUrlComponents;
|
|
92
92
|
},
|
|
93
|
-
enumerable:
|
|
93
|
+
enumerable: false,
|
|
94
94
|
configurable: true
|
|
95
95
|
});
|
|
96
96
|
Object.defineProperty(Authority.prototype, "hostnameAndPort", {
|
|
@@ -100,7 +100,7 @@ var Authority = /** @class */ (function () {
|
|
|
100
100
|
get: function () {
|
|
101
101
|
return this.canonicalAuthorityUrlComponents.HostNameAndPort.toLowerCase();
|
|
102
102
|
},
|
|
103
|
-
enumerable:
|
|
103
|
+
enumerable: false,
|
|
104
104
|
configurable: true
|
|
105
105
|
});
|
|
106
106
|
Object.defineProperty(Authority.prototype, "tenant", {
|
|
@@ -110,7 +110,7 @@ var Authority = /** @class */ (function () {
|
|
|
110
110
|
get: function () {
|
|
111
111
|
return this.canonicalAuthorityUrlComponents.PathSegments[0];
|
|
112
112
|
},
|
|
113
|
-
enumerable:
|
|
113
|
+
enumerable: false,
|
|
114
114
|
configurable: true
|
|
115
115
|
});
|
|
116
116
|
Object.defineProperty(Authority.prototype, "authorizationEndpoint", {
|
|
@@ -123,10 +123,10 @@ var Authority = /** @class */ (function () {
|
|
|
123
123
|
return this.replaceTenant(endpoint);
|
|
124
124
|
}
|
|
125
125
|
else {
|
|
126
|
-
throw ClientAuthError
|
|
126
|
+
throw ClientAuthError.createEndpointDiscoveryIncompleteError("Discovery incomplete.");
|
|
127
127
|
}
|
|
128
128
|
},
|
|
129
|
-
enumerable:
|
|
129
|
+
enumerable: false,
|
|
130
130
|
configurable: true
|
|
131
131
|
});
|
|
132
132
|
Object.defineProperty(Authority.prototype, "tokenEndpoint", {
|
|
@@ -139,10 +139,10 @@ var Authority = /** @class */ (function () {
|
|
|
139
139
|
return this.replaceTenant(endpoint);
|
|
140
140
|
}
|
|
141
141
|
else {
|
|
142
|
-
throw ClientAuthError
|
|
142
|
+
throw ClientAuthError.createEndpointDiscoveryIncompleteError("Discovery incomplete.");
|
|
143
143
|
}
|
|
144
144
|
},
|
|
145
|
-
enumerable:
|
|
145
|
+
enumerable: false,
|
|
146
146
|
configurable: true
|
|
147
147
|
});
|
|
148
148
|
Object.defineProperty(Authority.prototype, "deviceCodeEndpoint", {
|
|
@@ -152,10 +152,10 @@ var Authority = /** @class */ (function () {
|
|
|
152
152
|
return this.replaceTenant(endpoint);
|
|
153
153
|
}
|
|
154
154
|
else {
|
|
155
|
-
throw ClientAuthError
|
|
155
|
+
throw ClientAuthError.createEndpointDiscoveryIncompleteError("Discovery incomplete.");
|
|
156
156
|
}
|
|
157
157
|
},
|
|
158
|
-
enumerable:
|
|
158
|
+
enumerable: false,
|
|
159
159
|
configurable: true
|
|
160
160
|
});
|
|
161
161
|
Object.defineProperty(Authority.prototype, "endSessionEndpoint", {
|
|
@@ -168,10 +168,10 @@ var Authority = /** @class */ (function () {
|
|
|
168
168
|
return this.replaceTenant(endpoint);
|
|
169
169
|
}
|
|
170
170
|
else {
|
|
171
|
-
throw ClientAuthError
|
|
171
|
+
throw ClientAuthError.createEndpointDiscoveryIncompleteError("Discovery incomplete.");
|
|
172
172
|
}
|
|
173
173
|
},
|
|
174
|
-
enumerable:
|
|
174
|
+
enumerable: false,
|
|
175
175
|
configurable: true
|
|
176
176
|
});
|
|
177
177
|
Object.defineProperty(Authority.prototype, "selfSignedJwtAudience", {
|
|
@@ -184,10 +184,10 @@ var Authority = /** @class */ (function () {
|
|
|
184
184
|
return this.replaceTenant(endpoint);
|
|
185
185
|
}
|
|
186
186
|
else {
|
|
187
|
-
throw ClientAuthError
|
|
187
|
+
throw ClientAuthError.createEndpointDiscoveryIncompleteError("Discovery incomplete.");
|
|
188
188
|
}
|
|
189
189
|
},
|
|
190
|
-
enumerable:
|
|
190
|
+
enumerable: false,
|
|
191
191
|
configurable: true
|
|
192
192
|
});
|
|
193
193
|
/**
|
|
@@ -203,7 +203,7 @@ var Authority = /** @class */ (function () {
|
|
|
203
203
|
*/
|
|
204
204
|
Authority.prototype.replacePath = function (urlString) {
|
|
205
205
|
var endpoint = urlString;
|
|
206
|
-
var cachedAuthorityUrl = new UrlString
|
|
206
|
+
var cachedAuthorityUrl = new UrlString(this.metadata.canonical_authority);
|
|
207
207
|
var cachedAuthorityParts = cachedAuthorityUrl.getUrlComponents().PathSegments;
|
|
208
208
|
var currentAuthorityParts = this.canonicalAuthorityUrlComponents.PathSegments;
|
|
209
209
|
currentAuthorityParts.forEach(function (currentPart, index) {
|
|
@@ -219,12 +219,12 @@ var Authority = /** @class */ (function () {
|
|
|
219
219
|
* The default open id configuration endpoint for any canonical authority.
|
|
220
220
|
*/
|
|
221
221
|
get: function () {
|
|
222
|
-
if (this.authorityType === AuthorityType
|
|
222
|
+
if (this.authorityType === AuthorityType.Adfs || this.protocolMode === ProtocolMode.OIDC) {
|
|
223
223
|
return this.canonicalAuthority + ".well-known/openid-configuration";
|
|
224
224
|
}
|
|
225
225
|
return this.canonicalAuthority + "v2.0/.well-known/openid-configuration";
|
|
226
226
|
},
|
|
227
|
-
enumerable:
|
|
227
|
+
enumerable: false,
|
|
228
228
|
configurable: true
|
|
229
229
|
});
|
|
230
230
|
/**
|
|
@@ -245,7 +245,7 @@ var Authority = /** @class */ (function () {
|
|
|
245
245
|
case 0:
|
|
246
246
|
metadataEntity = this.cacheManager.getAuthorityMetadataByAlias(this.hostnameAndPort);
|
|
247
247
|
if (!metadataEntity) {
|
|
248
|
-
metadataEntity = new AuthorityMetadataEntity
|
|
248
|
+
metadataEntity = new AuthorityMetadataEntity();
|
|
249
249
|
metadataEntity.updateCanonicalAuthority(this.canonicalAuthority);
|
|
250
250
|
}
|
|
251
251
|
return [4 /*yield*/, this.updateCloudDiscoveryMetadata(metadataEntity)];
|
|
@@ -296,10 +296,10 @@ var Authority = /** @class */ (function () {
|
|
|
296
296
|
return [4 /*yield*/, this.regionDiscovery.detectRegion(this.authorityOptions.azureRegionConfiguration.environmentRegion, this.regionDiscoveryMetadata)];
|
|
297
297
|
case 2:
|
|
298
298
|
autodetectedRegionName = _b.sent();
|
|
299
|
-
azureRegion = this.authorityOptions.azureRegionConfiguration.azureRegion === Constants
|
|
299
|
+
azureRegion = this.authorityOptions.azureRegionConfiguration.azureRegion === Constants.AZURE_REGION_AUTO_DISCOVER_FLAG
|
|
300
300
|
? autodetectedRegionName
|
|
301
301
|
: this.authorityOptions.azureRegionConfiguration.azureRegion;
|
|
302
|
-
if (this.authorityOptions.azureRegionConfiguration.azureRegion === Constants
|
|
302
|
+
if (this.authorityOptions.azureRegionConfiguration.azureRegion === Constants.AZURE_REGION_AUTO_DISCOVER_FLAG) {
|
|
303
303
|
this.regionDiscoveryMetadata.region_outcome = autodetectedRegionName ?
|
|
304
304
|
RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_SUCCESSFUL :
|
|
305
305
|
RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_FAILED;
|
|
@@ -322,7 +322,7 @@ var Authority = /** @class */ (function () {
|
|
|
322
322
|
case 3:
|
|
323
323
|
metadataEntity.updateEndpointMetadata(metadata, true);
|
|
324
324
|
return [2 /*return*/, AuthorityMetadataSource.NETWORK];
|
|
325
|
-
case 4: throw ClientAuthError
|
|
325
|
+
case 4: throw ClientAuthError.createUnableToGetOpenidConfigError(this.defaultOpenIdConfigurationEndpoint);
|
|
326
326
|
}
|
|
327
327
|
});
|
|
328
328
|
});
|
|
@@ -333,7 +333,7 @@ var Authority = /** @class */ (function () {
|
|
|
333
333
|
* @param metadataEntity
|
|
334
334
|
*/
|
|
335
335
|
Authority.prototype.isAuthoritySameType = function (metadataEntity) {
|
|
336
|
-
var cachedAuthorityUrl = new UrlString
|
|
336
|
+
var cachedAuthorityUrl = new UrlString(metadataEntity.canonical_authority);
|
|
337
337
|
var cachedParts = cachedAuthorityUrl.getUrlComponents().PathSegments;
|
|
338
338
|
return cachedParts.length === this.canonicalAuthorityUrlComponents.PathSegments.length;
|
|
339
339
|
};
|
|
@@ -346,7 +346,7 @@ var Authority = /** @class */ (function () {
|
|
|
346
346
|
return JSON.parse(this.authorityOptions.authorityMetadata);
|
|
347
347
|
}
|
|
348
348
|
catch (e) {
|
|
349
|
-
throw ClientConfigurationError
|
|
349
|
+
throw ClientConfigurationError.createInvalidAuthorityMetadataError();
|
|
350
350
|
}
|
|
351
351
|
}
|
|
352
352
|
return null;
|
|
@@ -356,7 +356,7 @@ var Authority = /** @class */ (function () {
|
|
|
356
356
|
*/
|
|
357
357
|
Authority.prototype.getEndpointMetadataFromNetwork = function () {
|
|
358
358
|
return __awaiter(this, void 0, void 0, function () {
|
|
359
|
-
var response
|
|
359
|
+
var response;
|
|
360
360
|
return __generator(this, function (_a) {
|
|
361
361
|
switch (_a.label) {
|
|
362
362
|
case 0:
|
|
@@ -366,7 +366,7 @@ var Authority = /** @class */ (function () {
|
|
|
366
366
|
response = _a.sent();
|
|
367
367
|
return [2 /*return*/, isOpenIdConfigResponse(response.body) ? response.body : null];
|
|
368
368
|
case 2:
|
|
369
|
-
|
|
369
|
+
_a.sent();
|
|
370
370
|
return [2 /*return*/, null];
|
|
371
371
|
case 3: return [2 /*return*/];
|
|
372
372
|
}
|
|
@@ -403,7 +403,7 @@ var Authority = /** @class */ (function () {
|
|
|
403
403
|
}
|
|
404
404
|
else {
|
|
405
405
|
// Metadata could not be obtained from config, cache or network
|
|
406
|
-
throw ClientConfigurationError
|
|
406
|
+
throw ClientConfigurationError.createUntrustedAuthorityError();
|
|
407
407
|
}
|
|
408
408
|
}
|
|
409
409
|
});
|
|
@@ -423,7 +423,7 @@ var Authority = /** @class */ (function () {
|
|
|
423
423
|
}
|
|
424
424
|
}
|
|
425
425
|
catch (e) {
|
|
426
|
-
throw ClientConfigurationError
|
|
426
|
+
throw ClientConfigurationError.createInvalidCloudDiscoveryMetadataError();
|
|
427
427
|
}
|
|
428
428
|
}
|
|
429
429
|
// If cloudDiscoveryMetadata is empty or does not contain the host, check knownAuthorities
|
|
@@ -438,11 +438,11 @@ var Authority = /** @class */ (function () {
|
|
|
438
438
|
*/
|
|
439
439
|
Authority.prototype.getCloudDiscoveryMetadataFromNetwork = function () {
|
|
440
440
|
return __awaiter(this, void 0, void 0, function () {
|
|
441
|
-
var instanceDiscoveryEndpoint, match, response, metadata
|
|
441
|
+
var instanceDiscoveryEndpoint, match, response, metadata;
|
|
442
442
|
return __generator(this, function (_a) {
|
|
443
443
|
switch (_a.label) {
|
|
444
444
|
case 0:
|
|
445
|
-
instanceDiscoveryEndpoint = "" + Constants
|
|
445
|
+
instanceDiscoveryEndpoint = "" + Constants.AAD_INSTANCE_DISCOVERY_ENDPT + this.canonicalAuthority + "oauth2/v2.0/authorize";
|
|
446
446
|
match = null;
|
|
447
447
|
_a.label = 1;
|
|
448
448
|
case 1:
|
|
@@ -458,7 +458,7 @@ var Authority = /** @class */ (function () {
|
|
|
458
458
|
match = Authority.getCloudDiscoveryMetadataFromNetworkResponse(metadata, this.hostnameAndPort);
|
|
459
459
|
return [3 /*break*/, 4];
|
|
460
460
|
case 3:
|
|
461
|
-
|
|
461
|
+
_a.sent();
|
|
462
462
|
return [2 /*return*/, null];
|
|
463
463
|
case 4:
|
|
464
464
|
if (!match) {
|
|
@@ -476,7 +476,7 @@ var Authority = /** @class */ (function () {
|
|
|
476
476
|
Authority.prototype.isInKnownAuthorities = function () {
|
|
477
477
|
var _this = this;
|
|
478
478
|
var matches = this.authorityOptions.knownAuthorities.filter(function (authority) {
|
|
479
|
-
return UrlString
|
|
479
|
+
return UrlString.getDomainFromUrl(authority).toLowerCase() === _this.hostnameAndPort;
|
|
480
480
|
});
|
|
481
481
|
return matches.length > 0;
|
|
482
482
|
};
|
|
@@ -513,7 +513,7 @@ var Authority = /** @class */ (function () {
|
|
|
513
513
|
return this.metadata.preferred_cache;
|
|
514
514
|
}
|
|
515
515
|
else {
|
|
516
|
-
throw ClientAuthError
|
|
516
|
+
throw ClientAuthError.createEndpointDiscoveryIncompleteError("Discovery incomplete.");
|
|
517
517
|
}
|
|
518
518
|
};
|
|
519
519
|
/**
|
|
@@ -530,7 +530,7 @@ var Authority = /** @class */ (function () {
|
|
|
530
530
|
* @returns bool
|
|
531
531
|
*/
|
|
532
532
|
Authority.isPublicCloudAuthority = function (host) {
|
|
533
|
-
return Constants
|
|
533
|
+
return Constants.KNOWN_PUBLIC_CLOUDS.indexOf(host) >= 0;
|
|
534
534
|
};
|
|
535
535
|
/**
|
|
536
536
|
* Rebuild the authority string with the region
|
|
@@ -540,15 +540,15 @@ var Authority = /** @class */ (function () {
|
|
|
540
540
|
*/
|
|
541
541
|
Authority.buildRegionalAuthorityString = function (host, region, queryString) {
|
|
542
542
|
// Create and validate a Url string object with the initial authority string
|
|
543
|
-
var authorityUrlInstance = new UrlString
|
|
543
|
+
var authorityUrlInstance = new UrlString(host);
|
|
544
544
|
authorityUrlInstance.validateAsUri();
|
|
545
545
|
var authorityUrlParts = authorityUrlInstance.getUrlComponents();
|
|
546
546
|
var hostNameAndPort = region + "." + authorityUrlParts.HostNameAndPort;
|
|
547
547
|
if (this.isPublicCloudAuthority(authorityUrlParts.HostNameAndPort)) {
|
|
548
|
-
hostNameAndPort = region + "." + Constants
|
|
548
|
+
hostNameAndPort = region + "." + Constants.REGIONAL_AUTH_PUBLIC_CLOUD_SUFFIX;
|
|
549
549
|
}
|
|
550
550
|
// Include the query string portion of the url
|
|
551
|
-
var url = UrlString
|
|
551
|
+
var url = UrlString.constructAuthorityUriFromObject(__assign(__assign({}, authorityUrlInstance.getUrlComponents()), { HostNameAndPort: hostNameAndPort })).urlString;
|
|
552
552
|
// Add the query string if a query string was provided
|
|
553
553
|
if (queryString)
|
|
554
554
|
return url + "?" + queryString;
|