@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,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 { StringUtils } from '../utils/StringUtils.js';
|
|
4
|
+
import { ClientConfigurationError } from '../error/ClientConfigurationError.js';
|
|
3
5
|
import { CodeChallengeMethodValues, PromptValue } from '../utils/Constants.js';
|
|
4
|
-
import { StringUtils as StringUtils$1 } from '../utils/StringUtils.js';
|
|
5
|
-
import { ClientConfigurationError as ClientConfigurationError$1 } from '../error/ClientConfigurationError.js';
|
|
6
6
|
|
|
7
7
|
/*
|
|
8
8
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -19,8 +19,8 @@ var RequestValidator = /** @class */ (function () {
|
|
|
19
19
|
* @param redirectUri
|
|
20
20
|
*/
|
|
21
21
|
RequestValidator.validateRedirectUri = function (redirectUri) {
|
|
22
|
-
if (StringUtils
|
|
23
|
-
throw ClientConfigurationError
|
|
22
|
+
if (StringUtils.isEmpty(redirectUri)) {
|
|
23
|
+
throw ClientConfigurationError.createRedirectUriEmptyError();
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
26
|
/**
|
|
@@ -33,7 +33,7 @@ var RequestValidator = /** @class */ (function () {
|
|
|
33
33
|
promptValues.push(PromptValue[value]);
|
|
34
34
|
}
|
|
35
35
|
if (promptValues.indexOf(prompt) < 0) {
|
|
36
|
-
throw ClientConfigurationError
|
|
36
|
+
throw ClientConfigurationError.createInvalidPromptError(prompt);
|
|
37
37
|
}
|
|
38
38
|
};
|
|
39
39
|
RequestValidator.validateClaims = function (claims) {
|
|
@@ -41,7 +41,7 @@ var RequestValidator = /** @class */ (function () {
|
|
|
41
41
|
JSON.parse(claims);
|
|
42
42
|
}
|
|
43
43
|
catch (e) {
|
|
44
|
-
throw ClientConfigurationError
|
|
44
|
+
throw ClientConfigurationError.createInvalidClaimsRequestError();
|
|
45
45
|
}
|
|
46
46
|
};
|
|
47
47
|
/**
|
|
@@ -50,8 +50,8 @@ var RequestValidator = /** @class */ (function () {
|
|
|
50
50
|
* @param codeChallengeMethod
|
|
51
51
|
*/
|
|
52
52
|
RequestValidator.validateCodeChallengeParams = function (codeChallenge, codeChallengeMethod) {
|
|
53
|
-
if (StringUtils
|
|
54
|
-
throw ClientConfigurationError
|
|
53
|
+
if (StringUtils.isEmpty(codeChallenge) || StringUtils.isEmpty(codeChallengeMethod)) {
|
|
54
|
+
throw ClientConfigurationError.createInvalidCodeChallengeParamsError();
|
|
55
55
|
}
|
|
56
56
|
else {
|
|
57
57
|
this.validateCodeChallengeMethod(codeChallengeMethod);
|
|
@@ -66,7 +66,7 @@ var RequestValidator = /** @class */ (function () {
|
|
|
66
66
|
CodeChallengeMethodValues.PLAIN,
|
|
67
67
|
CodeChallengeMethodValues.S256
|
|
68
68
|
].indexOf(codeChallengeMethod) < 0) {
|
|
69
|
-
throw ClientConfigurationError
|
|
69
|
+
throw ClientConfigurationError.createInvalidCodeChallengeMethodError();
|
|
70
70
|
}
|
|
71
71
|
};
|
|
72
72
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RequestValidator.js","sources":["../../src/request/RequestValidator.ts"],"sourcesContent":["/*\
|
|
1
|
+
{"version":3,"file":"RequestValidator.js","sources":["../../src/request/RequestValidator.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { StringUtils } from \"../utils/StringUtils\";\nimport { ClientConfigurationError } from \"../error/ClientConfigurationError\";\nimport { PromptValue, CodeChallengeMethodValues} from \"../utils/Constants\";\nimport { StringDict } from \"../utils/MsalTypes\";\n\n/**\n * Validates server consumable params from the \"request\" objects\n */\nexport class RequestValidator {\n\n /**\n * Utility to check if the `redirectUri` in the request is a non-null value\n * @param redirectUri\n */\n static validateRedirectUri(redirectUri: string) : void {\n if (StringUtils.isEmpty(redirectUri)) {\n throw ClientConfigurationError.createRedirectUriEmptyError();\n }\n }\n\n /**\n * Utility to validate prompt sent by the user in the request\n * @param prompt\n */\n static validatePrompt(prompt: string) : void {\n const promptValues = [];\n\n for (const value in PromptValue) {\n promptValues.push(PromptValue[value]);\n }\n\n if (promptValues.indexOf(prompt) < 0) {\n throw ClientConfigurationError.createInvalidPromptError(prompt);\n }\n }\n\n static validateClaims(claims: string) : void {\n try {\n JSON.parse(claims);\n } catch(e) {\n throw ClientConfigurationError.createInvalidClaimsRequestError();\n }\n }\n\n /**\n * Utility to validate code_challenge and code_challenge_method\n * @param codeChallenge\n * @param codeChallengeMethod\n */\n static validateCodeChallengeParams(codeChallenge: string, codeChallengeMethod: string) : void {\n if (StringUtils.isEmpty(codeChallenge) || StringUtils.isEmpty(codeChallengeMethod)) {\n throw ClientConfigurationError.createInvalidCodeChallengeParamsError();\n } else {\n this.validateCodeChallengeMethod(codeChallengeMethod);\n }\n }\n\n /**\n * Utility to validate code_challenge_method\n * @param codeChallengeMethod\n */\n static validateCodeChallengeMethod(codeChallengeMethod: string) : void {\n if (\n [\n CodeChallengeMethodValues.PLAIN,\n CodeChallengeMethodValues.S256\n ].indexOf(codeChallengeMethod) < 0\n ) {\n throw ClientConfigurationError.createInvalidCodeChallengeMethodError();\n }\n }\n\n /**\n * Removes unnecessary or duplicate query parameters from extraQueryParameters\n * @param request\n */\n static sanitizeEQParams(eQParams: StringDict, queryParams: Map<string, string>) : StringDict {\n if (!eQParams) {\n return {};\n }\n\n // Remove any query parameters already included in SSO params\n queryParams.forEach((value, key) => {\n if (eQParams[key]) {\n delete eQParams[key];\n }\n });\n\n return eQParams;\n }\n}\n"],"names":[],"mappings":";;;;;;AAAA;;;;AAUA;;;;IAGA;KAkFC;;;;;IA5EU,oCAAmB,GAA1B,UAA2B,WAAmB;QAC1C,IAAI,WAAW,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE;YAClC,MAAM,wBAAwB,CAAC,2BAA2B,EAAE,CAAC;SAChE;KACJ;;;;;IAMM,+BAAc,GAArB,UAAsB,MAAc;QAChC,IAAM,YAAY,GAAG,EAAE,CAAC;QAExB,KAAK,IAAM,KAAK,IAAI,WAAW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C;;;;"}
|
package/dist/request/ScopeSet.js
CHANGED
|
@@ -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 { __spreadArrays } from '../_virtual/_tslib.js';
|
|
4
|
+
import { ClientConfigurationError } from '../error/ClientConfigurationError.js';
|
|
5
|
+
import { StringUtils } from '../utils/StringUtils.js';
|
|
6
|
+
import { ClientAuthError } from '../error/ClientAuthError.js';
|
|
4
7
|
import { OIDC_SCOPES } from '../utils/Constants.js';
|
|
5
|
-
import { ClientAuthError as ClientAuthError$1 } from '../error/ClientAuthError.js';
|
|
6
|
-
import { StringUtils as StringUtils$1 } from '../utils/StringUtils.js';
|
|
7
|
-
import { ClientConfigurationError as ClientConfigurationError$1 } from '../error/ClientConfigurationError.js';
|
|
8
8
|
|
|
9
9
|
/*
|
|
10
10
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -19,8 +19,8 @@ var ScopeSet = /** @class */ (function () {
|
|
|
19
19
|
function ScopeSet(inputScopes) {
|
|
20
20
|
var _this = this;
|
|
21
21
|
// Filter empty string and null/undefined array items
|
|
22
|
-
var scopeArr = inputScopes ? StringUtils
|
|
23
|
-
var filteredInput = scopeArr ? StringUtils
|
|
22
|
+
var scopeArr = inputScopes ? StringUtils.trimArrayEntries(__spreadArrays(inputScopes)) : [];
|
|
23
|
+
var filteredInput = scopeArr ? StringUtils.removeEmptyStringsFromArray(scopeArr) : [];
|
|
24
24
|
// Validate and filter scopes (validate function throws if validation fails)
|
|
25
25
|
this.validateInputScopes(filteredInput);
|
|
26
26
|
this.scopes = new Set(); // Iterator in constructor not supported by IE11
|
|
@@ -45,7 +45,7 @@ var ScopeSet = /** @class */ (function () {
|
|
|
45
45
|
ScopeSet.prototype.validateInputScopes = function (inputScopes) {
|
|
46
46
|
// Check if scopes are required but not given or is an empty array
|
|
47
47
|
if (!inputScopes || inputScopes.length < 1) {
|
|
48
|
-
throw ClientConfigurationError
|
|
48
|
+
throw ClientConfigurationError.createEmptyScopesArrayError();
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
51
|
/**
|
|
@@ -56,7 +56,7 @@ var ScopeSet = /** @class */ (function () {
|
|
|
56
56
|
var lowerCaseScopes = this.printScopesLowerCase().split(" ");
|
|
57
57
|
var lowerCaseScopesSet = new ScopeSet(lowerCaseScopes);
|
|
58
58
|
// compare lowercase scopes
|
|
59
|
-
return !StringUtils
|
|
59
|
+
return !StringUtils.isEmpty(scope) ? lowerCaseScopesSet.scopes.has(scope.toLowerCase()) : false;
|
|
60
60
|
};
|
|
61
61
|
/**
|
|
62
62
|
* Check if a set of scopes is present in this set of scopes.
|
|
@@ -87,7 +87,7 @@ var ScopeSet = /** @class */ (function () {
|
|
|
87
87
|
* @param newScope
|
|
88
88
|
*/
|
|
89
89
|
ScopeSet.prototype.appendScope = function (newScope) {
|
|
90
|
-
if (!StringUtils
|
|
90
|
+
if (!StringUtils.isEmpty(newScope)) {
|
|
91
91
|
this.scopes.add(newScope.trim());
|
|
92
92
|
}
|
|
93
93
|
};
|
|
@@ -101,7 +101,7 @@ var ScopeSet = /** @class */ (function () {
|
|
|
101
101
|
newScopes.forEach(function (newScope) { return _this.appendScope(newScope); });
|
|
102
102
|
}
|
|
103
103
|
catch (e) {
|
|
104
|
-
throw ClientAuthError
|
|
104
|
+
throw ClientAuthError.createAppendScopeSetError(e);
|
|
105
105
|
}
|
|
106
106
|
};
|
|
107
107
|
/**
|
|
@@ -109,8 +109,8 @@ var ScopeSet = /** @class */ (function () {
|
|
|
109
109
|
* @param scope
|
|
110
110
|
*/
|
|
111
111
|
ScopeSet.prototype.removeScope = function (scope) {
|
|
112
|
-
if (StringUtils
|
|
113
|
-
throw ClientAuthError
|
|
112
|
+
if (StringUtils.isEmpty(scope)) {
|
|
113
|
+
throw ClientAuthError.createRemoveEmptyScopeFromSetError(scope);
|
|
114
114
|
}
|
|
115
115
|
this.scopes.delete(scope.trim());
|
|
116
116
|
};
|
|
@@ -130,7 +130,7 @@ var ScopeSet = /** @class */ (function () {
|
|
|
130
130
|
*/
|
|
131
131
|
ScopeSet.prototype.unionScopeSets = function (otherScopes) {
|
|
132
132
|
if (!otherScopes) {
|
|
133
|
-
throw ClientAuthError
|
|
133
|
+
throw ClientAuthError.createEmptyInputScopeSetError();
|
|
134
134
|
}
|
|
135
135
|
var unionScopes = new Set(); // Iterator in constructor not supported in IE11
|
|
136
136
|
otherScopes.scopes.forEach(function (scope) { return unionScopes.add(scope.toLowerCase()); });
|
|
@@ -143,7 +143,7 @@ var ScopeSet = /** @class */ (function () {
|
|
|
143
143
|
*/
|
|
144
144
|
ScopeSet.prototype.intersectingScopeSets = function (otherScopes) {
|
|
145
145
|
if (!otherScopes) {
|
|
146
|
-
throw ClientAuthError
|
|
146
|
+
throw ClientAuthError.createEmptyInputScopeSetError();
|
|
147
147
|
}
|
|
148
148
|
// Do not allow OIDC scopes to be the only intersecting scopes
|
|
149
149
|
if (!otherScopes.containsOnlyOIDCScopes()) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScopeSet.js","sources":["../../src/request/ScopeSet.ts"],"sourcesContent":["/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { ClientConfigurationError } from \"../error/ClientConfigurationError\";\r\nimport { StringUtils } from \"../utils/StringUtils\";\r\nimport { ClientAuthError } from \"../error/ClientAuthError\";\r\nimport { OIDC_SCOPES } from \"../utils/Constants\";\r\n\r\n/**\r\n * The ScopeSet class creates a set of scopes. Scopes are case-insensitive, unique values, so the Set object in JS makes\r\n * the most sense to implement for this class. All scopes are trimmed and converted to lower case strings in intersection and union functions\r\n * to ensure uniqueness of strings.\r\n */\r\nexport class ScopeSet {\r\n // Scopes as a Set of strings\r\n private scopes: Set<string>;\r\n\r\n constructor(inputScopes: Array<string>) {\r\n // Filter empty string and null/undefined array items\r\n const scopeArr = inputScopes ? StringUtils.trimArrayEntries([...inputScopes]) : [];\r\n const filteredInput = scopeArr ? StringUtils.removeEmptyStringsFromArray(scopeArr) : [];\r\n\r\n // Validate and filter scopes (validate function throws if validation fails)\r\n this.validateInputScopes(filteredInput);\r\n\r\n this.scopes = new Set<string>(); // Iterator in constructor not supported by IE11\r\n filteredInput.forEach(scope => this.scopes.add(scope));\r\n }\r\n\r\n /**\r\n * Factory method to create ScopeSet from space-delimited string\r\n * @param inputScopeString\r\n * @param appClientId\r\n * @param scopesRequired\r\n */\r\n static fromString(inputScopeString: string): ScopeSet {\r\n const scopeString = inputScopeString || \"\";\r\n const inputScopes: Array<string> = scopeString.split(\" \");\r\n return new ScopeSet(inputScopes);\r\n }\r\n\r\n /**\r\n * Used to validate the scopes input parameter requested by the developer.\r\n * @param {Array<string>} inputScopes - Developer requested permissions. Not all scopes are guaranteed to be included in the access token returned.\r\n * @param {boolean} scopesRequired - Boolean indicating whether the scopes array is required or not\r\n */\r\n private validateInputScopes(inputScopes: Array<string>): void {\r\n // Check if scopes are required but not given or is an empty array\r\n if (!inputScopes || inputScopes.length < 1) {\r\n throw ClientConfigurationError.createEmptyScopesArrayError();\r\n }\r\n }\r\n\r\n /**\r\n * Check if a given scope is present in this set of scopes.\r\n * @param scope\r\n */\r\n containsScope(scope: string): boolean {\r\n const lowerCaseScopes = this.printScopesLowerCase().split(\" \");\r\n const lowerCaseScopesSet = new ScopeSet(lowerCaseScopes);\r\n // compare lowercase scopes\r\n return !StringUtils.isEmpty(scope) ? lowerCaseScopesSet.scopes.has(scope.toLowerCase()) : false;\r\n }\r\n\r\n /**\r\n * Check if a set of scopes is present in this set of scopes.\r\n * @param scopeSet\r\n */\r\n containsScopeSet(scopeSet: ScopeSet): boolean {\r\n if (!scopeSet || scopeSet.scopes.size <= 0) {\r\n return false;\r\n }\r\n\r\n return (this.scopes.size >= scopeSet.scopes.size && scopeSet.asArray().every(scope => this.containsScope(scope)));\r\n }\r\n\r\n /**\r\n * Check if set of scopes contains only the defaults\r\n */\r\n containsOnlyOIDCScopes(): boolean {\r\n let defaultScopeCount = 0;\r\n OIDC_SCOPES.forEach((defaultScope: string) => {\r\n if (this.containsScope(defaultScope)) {\r\n defaultScopeCount += 1;\r\n }\r\n });\r\n\r\n return this.scopes.size === defaultScopeCount;\r\n }\r\n\r\n /**\r\n * Appends single scope if passed\r\n * @param newScope\r\n */\r\n appendScope(newScope: string): void {\r\n if (!StringUtils.isEmpty(newScope)) {\r\n this.scopes.add(newScope.trim());\r\n }\r\n }\r\n\r\n /**\r\n * Appends multiple scopes if passed\r\n * @param newScopes\r\n */\r\n appendScopes(newScopes: Array<string>): void {\r\n try {\r\n newScopes.forEach(newScope => this.appendScope(newScope));\r\n } catch (e) {\r\n throw ClientAuthError.createAppendScopeSetError(e);\r\n }\r\n }\r\n\r\n /**\r\n * Removes element from set of scopes.\r\n * @param scope\r\n */\r\n removeScope(scope: string): void {\r\n if (StringUtils.isEmpty(scope)) {\r\n throw ClientAuthError.createRemoveEmptyScopeFromSetError(scope);\r\n }\r\n this.scopes.delete(scope.trim());\r\n }\r\n\r\n /**\r\n * Removes default scopes from set of scopes\r\n * Primarily used to prevent cache misses if the default scopes are not returned from the server\r\n */\r\n removeOIDCScopes(): void {\r\n OIDC_SCOPES.forEach((defaultScope: string) => {\r\n this.scopes.delete(defaultScope);\r\n });\r\n }\r\n\r\n /**\r\n * Combines an array of scopes with the current set of scopes.\r\n * @param otherScopes\r\n */\r\n unionScopeSets(otherScopes: ScopeSet): Set<string> {\r\n if (!otherScopes) {\r\n throw ClientAuthError.createEmptyInputScopeSetError();\r\n }\r\n const unionScopes = new Set<string>(); // Iterator in constructor not supported in IE11\r\n otherScopes.scopes.forEach(scope => unionScopes.add(scope.toLowerCase()));\r\n this.scopes.forEach(scope => unionScopes.add(scope.toLowerCase()));\r\n return unionScopes;\r\n }\r\n\r\n /**\r\n * Check if scopes intersect between this set and another.\r\n * @param otherScopes\r\n */\r\n intersectingScopeSets(otherScopes: ScopeSet): boolean {\r\n if (!otherScopes) {\r\n throw ClientAuthError.createEmptyInputScopeSetError();\r\n }\r\n \r\n // Do not allow OIDC scopes to be the only intersecting scopes\r\n if (!otherScopes.containsOnlyOIDCScopes()) {\r\n otherScopes.removeOIDCScopes();\r\n }\r\n const unionScopes = this.unionScopeSets(otherScopes);\r\n const sizeOtherScopes = otherScopes.getScopeCount();\r\n const sizeThisScopes = this.getScopeCount();\r\n const sizeUnionScopes = unionScopes.size;\r\n return sizeUnionScopes < (sizeThisScopes + sizeOtherScopes);\r\n }\r\n\r\n /**\r\n * Returns size of set of scopes.\r\n */\r\n getScopeCount(): number {\r\n return this.scopes.size;\r\n }\r\n\r\n /**\r\n * Returns the scopes as an array of string values\r\n */\r\n asArray(): Array<string> {\r\n const array: Array<string> = [];\r\n this.scopes.forEach(val => array.push(val));\r\n return array;\r\n }\r\n\r\n /**\r\n * Prints scopes into a space-delimited string\r\n */\r\n printScopes(): string {\r\n if (this.scopes) {\r\n const scopeArr = this.asArray();\r\n return scopeArr.join(\" \");\r\n }\r\n return \"\";\r\n }\r\n\r\n /**\r\n * Prints scopes into a space-delimited lower-case string (used for caching)\r\n */\r\n printScopesLowerCase(): string {\r\n return this.printScopes().toLowerCase();\r\n }\r\n}\r\n"],"names":["StringUtils","ClientConfigurationError","ClientAuthError"],"mappings":";;;;;;;;AAAA;;;;AAUA;;;;;;IASI,kBAAY,WAA0B;QAAtC,iBAUC;;QARG,IAAM,QAAQ,GAAG,WAAW,GAAGA,aAAW,CAAC,gBAAgB,gBAAK,WAAW,EAAE,GAAG,EAAE,CAAC;QACnF,IAAM,aAAa,GAAG,QAAQ,GAAGA,aAAW,CAAC,2BAA2B,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC;;QAGxF,IAAI,CAAC,mBAAmB,CAAC,aAAa,CAAC,CAAC;QAExC,IAAI,CAAC,MAAM,GAAG,IAAI,GAAG,EAAU,CAAC;QAChC,aAAa,CAAC,OAAO,C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AAE;YACb,IAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;YAChC,OAAO,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SAC7B;QACD,OAAO,EAAE,CAAC;KACb;;;;IAKD,uCAAoB,GAApB;QACI,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,WAAW,EAAE,CAAC;KAC3C;IACL,eAAC;AAAD,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"ScopeSet.js","sources":["../../src/request/ScopeSet.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ClientConfigurationError } from \"../error/ClientConfigurationError\";\nimport { StringUtils } from \"../utils/StringUtils\";\nimport { ClientAuthError } from \"../error/ClientAuthError\";\nimport { OIDC_SCOPES } from \"../utils/Constants\";\n\n/**\n * The ScopeSet class creates a set of scopes. Scopes are case-insensitive, unique values, so the Set object in JS makes\n * the most sense to implement for this class. All scopes are trimmed and converted to lower case strings in intersection and union functions\n * to ensure uniqueness of strings.\n */\nexport class ScopeSet {\n // Scopes as a Set of strings\n private scopes: Set<string>;\n\n constructor(inputScopes: Array<string>) {\n // Filter empty string and null/undefined array items\n const scopeArr = inputScopes ? StringUtils.trimArrayEntries([...inputScopes]) : [];\n const filteredInput = scopeArr ? StringUtils.removeEmptyStringsFromArray(scopeArr) : [];\n\n // Validate and filter scopes (validate function throws if validation fails)\n this.validateInputScopes(filteredInput);\n\n this.scopes = new Set<string>(); // Iterator in constructor not supported by IE11\n filteredInput.forEach(scope => this.scopes.add(scope));\n }\n\n /**\n * Factory method to create ScopeSet from space-delimited string\n * @param inputScopeString\n * @param appClientId\n * @param scopesRequired\n */\n static fromString(inputScopeString: string): ScopeSet {\n const scopeString = inputScopeString || \"\";\n const inputScopes: Array<string> = scopeString.split(\" \");\n return new ScopeSet(inputScopes);\n }\n\n /**\n * Used to validate the scopes input parameter requested by the developer.\n * @param {Array<string>} inputScopes - Developer requested permissions. Not all scopes are guaranteed to be included in the access token returned.\n * @param {boolean} scopesRequired - Boolean indicating whether the scopes array is required or not\n */\n private validateInputScopes(inputScopes: Array<string>): void {\n // Check if scopes are required but not given or is an empty array\n if (!inputScopes || inputScopes.length < 1) {\n throw ClientConfigurationError.createEmptyScopesArrayError();\n }\n }\n\n /**\n * Check if a given scope is present in this set of scopes.\n * @param scope\n */\n containsScope(scope: string): boolean {\n const lowerCaseScopes = this.printScopesLowerCase().split(\" \");\n const lowerCaseScopesSet = new ScopeSet(lowerCaseScopes);\n // compare lowercase scopes\n return !StringUtils.isEmpty(scope) ? lowerCaseScopesSet.scopes.has(scope.toLowerCase()) : false;\n }\n\n /**\n * Check if a set of scopes is present in this set of scopes.\n * @param scopeSet\n */\n containsScopeSet(scopeSet: ScopeSet): boolean {\n if (!scopeSet || scopeSet.scopes.size <= 0) {\n return false;\n }\n\n return (this.scopes.size >= scopeSet.scopes.size && scopeSet.asArray().every(scope => this.containsScope(scope)));\n }\n\n /**\n * Check if set of scopes contains only the defaults\n */\n containsOnlyOIDCScopes(): boolean {\n let defaultScopeCount = 0;\n OIDC_SCOPES.forEach((defaultScope: string) => {\n if (this.containsScope(defaultScope)) {\n defaultScopeCount += 1;\n }\n });\n\n return this.scopes.size === defaultScopeCount;\n }\n\n /**\n * Appends single scope if passed\n * @param newScope\n */\n appendScope(newScope: string): void {\n if (!StringUtils.isEmpty(newScope)) {\n this.scopes.add(newScope.trim());\n }\n }\n\n /**\n * Appends multiple scopes if passed\n * @param newScopes\n */\n appendScopes(newScopes: Array<string>): void {\n try {\n newScopes.forEach(newScope => this.appendScope(newScope));\n } catch (e) {\n throw ClientAuthError.createAppendScopeSetError(e);\n }\n }\n\n /**\n * Removes element from set of scopes.\n * @param scope\n */\n removeScope(scope: string): void {\n if (StringUtils.isEmpty(scope)) {\n throw ClientAuthError.createRemoveEmptyScopeFromSetError(scope);\n }\n this.scopes.delete(scope.trim());\n }\n\n /**\n * Removes default scopes from set of scopes\n * Primarily used to prevent cache misses if the default scopes are not returned from the server\n */\n removeOIDCScopes(): void {\n OIDC_SCOPES.forEach((defaultScope: string) => {\n this.scopes.delete(defaultScope);\n });\n }\n\n /**\n * Combines an array of scopes with the current set of scopes.\n * @param otherScopes\n */\n unionScopeSets(otherScopes: ScopeSet): Set<string> {\n if (!otherScopes) {\n throw ClientAuthError.createEmptyInputScopeSetError();\n }\n const unionScopes = new Set<string>(); // Iterator in constructor not supported in IE11\n otherScopes.scopes.forEach(scope => unionScopes.add(scope.toLowerCase()));\n this.scopes.forEach(scope => unionScopes.add(scope.toLowerCase()));\n return unionScopes;\n }\n\n /**\n * Check if scopes intersect between this set and another.\n * @param otherScopes\n */\n intersectingScopeSets(otherScopes: ScopeSet): boolean {\n if (!otherScopes) {\n throw ClientAuthError.createEmptyInputScopeSetError();\n }\n \n // Do not allow OIDC scopes to be the only intersecting scopes\n if (!otherScopes.containsOnlyOIDCScopes()) {\n otherScopes.removeOIDCScopes();\n }\n const unionScopes = this.unionScopeSets(otherScopes);\n const sizeOtherScopes = otherScopes.getScopeCount();\n const sizeThisScopes = this.getScopeCount();\n const sizeUnionScopes = unionScopes.size;\n return sizeUnionScopes < (sizeThisScopes + sizeOtherScopes);\n }\n\n /**\n * Returns size of set of scopes.\n */\n getScopeCount(): number {\n return this.scopes.size;\n }\n\n /**\n * Returns the scopes as an array of string values\n */\n asArray(): Array<string> {\n const array: Array<string> = [];\n this.scopes.forEach(val => array.push(val));\n return array;\n }\n\n /**\n * Prints scopes into a space-delimited string\n */\n printScopes(): string {\n if (this.scopes) {\n const scopeArr = this.asArray();\n return scopeArr.join(\" \");\n }\n return \"\";\n }\n\n /**\n * Prints scopes into a space-delimited lower-case string (used for caching)\n */\n printScopesLowerCase(): string {\n return this.printScopes().toLowerCase();\n }\n}\n"],"names":[],"mappings":";;;;;;;;AAAA;;;;AAUA;;;;;;IASI,kBAAY,WAA0B;QAAtC,iBAUC;;QARG,IAAM,QAAQ,GAAG,WAAW,GA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I,CAAC;KAC3B;;;;IAKD,0BAAO,GAAP;QACI,IAAM,KAAK,GAAkB,EAAE,CAAC;QAChC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,UAAA,GAAG,IAAI,OAAA,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,GAAA,CAAC,CAAC;QAC5C,OAAO,KAAK,CAAC;KAChB;;;;IAKD,8BAAW,GAAX;QACI,IAAI,IAAI,CAAC,MAAM,EAAE;YACb,IAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;YAChC,OAAO,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SAC7B;QACD,OAAO,EAAE,CAAC;KACb;;;;IAKD,uCAAoB,GAApB;QACI,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,WAAW,EAAE,CAAC;KAC3C;IACL,eAAC;AAAD,CAAC;;;;"}
|
|
@@ -1,24 +1,24 @@
|
|
|
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 { Constants as Constants$1, AuthenticationScheme, THE_FAMILY_ID } from '../utils/Constants.js';
|
|
5
|
-
import { ClientAuthError as ClientAuthError$1 } from '../error/ClientAuthError.js';
|
|
6
|
-
import { StringUtils as StringUtils$1 } from '../utils/StringUtils.js';
|
|
7
|
-
import { ScopeSet as ScopeSet$1 } from '../request/ScopeSet.js';
|
|
8
4
|
import { buildClientInfo } from '../account/ClientInfo.js';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
5
|
+
import { ClientAuthError } from '../error/ClientAuthError.js';
|
|
6
|
+
import { StringUtils } from '../utils/StringUtils.js';
|
|
7
|
+
import { ServerError } from '../error/ServerError.js';
|
|
8
|
+
import { AuthToken } from '../account/AuthToken.js';
|
|
9
|
+
import { ScopeSet } from '../request/ScopeSet.js';
|
|
10
|
+
import { AccountEntity } from '../cache/entities/AccountEntity.js';
|
|
11
|
+
import { AuthorityType } from '../authority/AuthorityType.js';
|
|
12
|
+
import { IdTokenEntity } from '../cache/entities/IdTokenEntity.js';
|
|
13
|
+
import { AccessTokenEntity } from '../cache/entities/AccessTokenEntity.js';
|
|
14
|
+
import { RefreshTokenEntity } from '../cache/entities/RefreshTokenEntity.js';
|
|
15
|
+
import { InteractionRequiredAuthError } from '../error/InteractionRequiredAuthError.js';
|
|
16
|
+
import { CacheRecord } from '../cache/entities/CacheRecord.js';
|
|
17
|
+
import { ProtocolUtils } from '../utils/ProtocolUtils.js';
|
|
18
|
+
import { Constants, AuthenticationScheme, THE_FAMILY_ID } from '../utils/Constants.js';
|
|
19
|
+
import { PopTokenGenerator } from '../crypto/PopTokenGenerator.js';
|
|
20
|
+
import { AppMetadataEntity } from '../cache/entities/AppMetadataEntity.js';
|
|
21
|
+
import { TokenCacheContext } from '../cache/persistence/TokenCacheContext.js';
|
|
22
22
|
|
|
23
23
|
/*
|
|
24
24
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -44,17 +44,17 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
44
44
|
*/
|
|
45
45
|
ResponseHandler.prototype.validateServerAuthorizationCodeResponse = function (serverResponseHash, cachedState, cryptoObj) {
|
|
46
46
|
if (!serverResponseHash.state || !cachedState) {
|
|
47
|
-
throw !serverResponseHash.state ? ClientAuthError
|
|
47
|
+
throw !serverResponseHash.state ? ClientAuthError.createStateNotFoundError("Server State") : ClientAuthError.createStateNotFoundError("Cached State");
|
|
48
48
|
}
|
|
49
49
|
if (decodeURIComponent(serverResponseHash.state) !== decodeURIComponent(cachedState)) {
|
|
50
|
-
throw ClientAuthError
|
|
50
|
+
throw ClientAuthError.createStateMismatchError();
|
|
51
51
|
}
|
|
52
52
|
// Check for error
|
|
53
53
|
if (serverResponseHash.error || serverResponseHash.error_description || serverResponseHash.suberror) {
|
|
54
|
-
if (InteractionRequiredAuthError
|
|
55
|
-
throw new InteractionRequiredAuthError
|
|
54
|
+
if (InteractionRequiredAuthError.isInteractionRequiredError(serverResponseHash.error, serverResponseHash.error_description, serverResponseHash.suberror)) {
|
|
55
|
+
throw new InteractionRequiredAuthError(serverResponseHash.error || Constants.EMPTY_STRING, serverResponseHash.error_description, serverResponseHash.suberror);
|
|
56
56
|
}
|
|
57
|
-
throw new ServerError
|
|
57
|
+
throw new ServerError(serverResponseHash.error || Constants.EMPTY_STRING, serverResponseHash.error_description, serverResponseHash.suberror);
|
|
58
58
|
}
|
|
59
59
|
if (serverResponseHash.client_info) {
|
|
60
60
|
buildClientInfo(serverResponseHash.client_info, cryptoObj);
|
|
@@ -67,11 +67,11 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
67
67
|
ResponseHandler.prototype.validateTokenResponse = function (serverResponse) {
|
|
68
68
|
// Check for error
|
|
69
69
|
if (serverResponse.error || serverResponse.error_description || serverResponse.suberror) {
|
|
70
|
-
if (InteractionRequiredAuthError
|
|
71
|
-
throw new InteractionRequiredAuthError
|
|
70
|
+
if (InteractionRequiredAuthError.isInteractionRequiredError(serverResponse.error, serverResponse.error_description, serverResponse.suberror)) {
|
|
71
|
+
throw new InteractionRequiredAuthError(serverResponse.error, serverResponse.error_description, serverResponse.suberror);
|
|
72
72
|
}
|
|
73
73
|
var errString = serverResponse.error_codes + " - [" + serverResponse.timestamp + "]: " + serverResponse.error_description + " - Correlation ID: " + serverResponse.correlation_id + " - Trace ID: " + serverResponse.trace_id;
|
|
74
|
-
throw new ServerError
|
|
74
|
+
throw new ServerError(serverResponse.error, errString, serverResponse.suberror);
|
|
75
75
|
}
|
|
76
76
|
};
|
|
77
77
|
/**
|
|
@@ -86,18 +86,18 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
86
86
|
switch (_a.label) {
|
|
87
87
|
case 0:
|
|
88
88
|
if (serverTokenResponse.id_token) {
|
|
89
|
-
idTokenObj = new AuthToken
|
|
89
|
+
idTokenObj = new AuthToken(serverTokenResponse.id_token || Constants.EMPTY_STRING, this.cryptoObj);
|
|
90
90
|
// token nonce check (TODO: Add a warning if no nonce is given?)
|
|
91
|
-
if (authCodePayload && !StringUtils
|
|
91
|
+
if (authCodePayload && !StringUtils.isEmpty(authCodePayload.nonce)) {
|
|
92
92
|
if (idTokenObj.claims.nonce !== authCodePayload.nonce) {
|
|
93
|
-
throw ClientAuthError
|
|
93
|
+
throw ClientAuthError.createNonceMismatchError();
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
// generate homeAccountId
|
|
98
|
-
this.homeAccountIdentifier = AccountEntity
|
|
98
|
+
this.homeAccountIdentifier = AccountEntity.generateHomeAccountId(serverTokenResponse.client_info || Constants.EMPTY_STRING, authority.authorityType, this.logger, this.cryptoObj, idTokenObj);
|
|
99
99
|
if (!!authCodePayload && !!authCodePayload.state) {
|
|
100
|
-
requestStateObj = ProtocolUtils
|
|
100
|
+
requestStateObj = ProtocolUtils.parseRequestState(this.cryptoObj, authCodePayload.state);
|
|
101
101
|
}
|
|
102
102
|
cacheRecord = this.generateCacheRecord(serverTokenResponse, authority, reqTimestamp, idTokenObj, request.scopes, oboAssertion, authCodePayload);
|
|
103
103
|
_a.label = 1;
|
|
@@ -105,7 +105,7 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
105
105
|
_a.trys.push([1, , 4, 7]);
|
|
106
106
|
if (!(this.persistencePlugin && this.serializableCache)) return [3 /*break*/, 3];
|
|
107
107
|
this.logger.verbose("Persistence enabled, calling beforeCacheAccess");
|
|
108
|
-
cacheContext = new TokenCacheContext
|
|
108
|
+
cacheContext = new TokenCacheContext(this.serializableCache, true);
|
|
109
109
|
return [4 /*yield*/, this.persistencePlugin.beforeCacheAccess(cacheContext)];
|
|
110
110
|
case 2:
|
|
111
111
|
_a.sent();
|
|
@@ -147,21 +147,21 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
147
147
|
*/
|
|
148
148
|
ResponseHandler.prototype.generateCacheRecord = function (serverTokenResponse, authority, reqTimestamp, idTokenObj, requestScopes, oboAssertion, authCodePayload) {
|
|
149
149
|
var env = authority.getPreferredCache();
|
|
150
|
-
if (StringUtils
|
|
151
|
-
throw ClientAuthError
|
|
150
|
+
if (StringUtils.isEmpty(env)) {
|
|
151
|
+
throw ClientAuthError.createInvalidCacheEnvironmentError();
|
|
152
152
|
}
|
|
153
153
|
// IdToken: non AAD scenarios can have empty realm
|
|
154
154
|
var cachedIdToken;
|
|
155
155
|
var cachedAccount;
|
|
156
|
-
if (!StringUtils
|
|
157
|
-
cachedIdToken = IdTokenEntity
|
|
156
|
+
if (!StringUtils.isEmpty(serverTokenResponse.id_token) && !!idTokenObj) {
|
|
157
|
+
cachedIdToken = IdTokenEntity.createIdTokenEntity(this.homeAccountIdentifier, env, serverTokenResponse.id_token || Constants.EMPTY_STRING, this.clientId, idTokenObj.claims.tid || Constants.EMPTY_STRING, oboAssertion);
|
|
158
158
|
cachedAccount = this.generateAccountEntity(serverTokenResponse, idTokenObj, authority, oboAssertion, authCodePayload);
|
|
159
159
|
}
|
|
160
160
|
// AccessToken
|
|
161
161
|
var cachedAccessToken = null;
|
|
162
|
-
if (!StringUtils
|
|
162
|
+
if (!StringUtils.isEmpty(serverTokenResponse.access_token)) {
|
|
163
163
|
// If scopes not returned in server response, use request scopes
|
|
164
|
-
var responseScopes = serverTokenResponse.scope ? ScopeSet
|
|
164
|
+
var responseScopes = serverTokenResponse.scope ? ScopeSet.fromString(serverTokenResponse.scope) : new ScopeSet(requestScopes || []);
|
|
165
165
|
/*
|
|
166
166
|
* Use timestamp calculated before request
|
|
167
167
|
* Server may return timestamps as strings, parse to numbers if so.
|
|
@@ -173,19 +173,19 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
173
173
|
var extendedTokenExpirationSeconds = tokenExpirationSeconds + extExpiresIn;
|
|
174
174
|
var refreshOnSeconds = refreshIn && refreshIn > 0 ? reqTimestamp + refreshIn : undefined;
|
|
175
175
|
// non AAD scenarios can have empty realm
|
|
176
|
-
cachedAccessToken = AccessTokenEntity
|
|
176
|
+
cachedAccessToken = AccessTokenEntity.createAccessTokenEntity(this.homeAccountIdentifier, env, serverTokenResponse.access_token || Constants.EMPTY_STRING, this.clientId, idTokenObj ? idTokenObj.claims.tid || Constants.EMPTY_STRING : authority.tenant, responseScopes.printScopes(), tokenExpirationSeconds, extendedTokenExpirationSeconds, this.cryptoObj, refreshOnSeconds, serverTokenResponse.token_type, oboAssertion);
|
|
177
177
|
}
|
|
178
178
|
// refreshToken
|
|
179
179
|
var cachedRefreshToken = null;
|
|
180
|
-
if (!StringUtils
|
|
181
|
-
cachedRefreshToken = RefreshTokenEntity
|
|
180
|
+
if (!StringUtils.isEmpty(serverTokenResponse.refresh_token)) {
|
|
181
|
+
cachedRefreshToken = RefreshTokenEntity.createRefreshTokenEntity(this.homeAccountIdentifier, env, serverTokenResponse.refresh_token || Constants.EMPTY_STRING, this.clientId, serverTokenResponse.foci, oboAssertion);
|
|
182
182
|
}
|
|
183
183
|
// appMetadata
|
|
184
184
|
var cachedAppMetadata = null;
|
|
185
|
-
if (!StringUtils
|
|
186
|
-
cachedAppMetadata = AppMetadataEntity
|
|
185
|
+
if (!StringUtils.isEmpty(serverTokenResponse.foci)) {
|
|
186
|
+
cachedAppMetadata = AppMetadataEntity.createAppMetadataEntity(this.clientId, env, serverTokenResponse.foci);
|
|
187
187
|
}
|
|
188
|
-
return new CacheRecord
|
|
188
|
+
return new CacheRecord(cachedAccount, cachedIdToken, cachedAccessToken, cachedRefreshToken, cachedAppMetadata);
|
|
189
189
|
};
|
|
190
190
|
/**
|
|
191
191
|
* Generate Account
|
|
@@ -198,17 +198,17 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
198
198
|
var cloudGraphHostName = authCodePayload ? authCodePayload.cloud_graph_host_name : "";
|
|
199
199
|
var msGraphhost = authCodePayload ? authCodePayload.msgraph_host : "";
|
|
200
200
|
// ADFS does not require client_info in the response
|
|
201
|
-
if (authorityType === AuthorityType
|
|
201
|
+
if (authorityType === AuthorityType.Adfs) {
|
|
202
202
|
this.logger.verbose("Authority type is ADFS, creating ADFS account");
|
|
203
|
-
return AccountEntity
|
|
203
|
+
return AccountEntity.createGenericAccount(authority, this.homeAccountIdentifier, idToken, oboAssertion, cloudGraphHostName, msGraphhost);
|
|
204
204
|
}
|
|
205
205
|
// This fallback applies to B2C as well as they fall under an AAD account type.
|
|
206
|
-
if (StringUtils
|
|
207
|
-
throw ClientAuthError
|
|
206
|
+
if (StringUtils.isEmpty(serverTokenResponse.client_info) && authority.protocolMode === "AAD") {
|
|
207
|
+
throw ClientAuthError.createClientInfoEmptyError();
|
|
208
208
|
}
|
|
209
209
|
return serverTokenResponse.client_info ?
|
|
210
|
-
AccountEntity
|
|
211
|
-
AccountEntity
|
|
210
|
+
AccountEntity.createAccount(serverTokenResponse.client_info, this.homeAccountIdentifier, authority, idToken, oboAssertion, cloudGraphHostName, msGraphhost) :
|
|
211
|
+
AccountEntity.createGenericAccount(authority, this.homeAccountIdentifier, idToken, oboAssertion, cloudGraphHostName, msGraphhost);
|
|
212
212
|
};
|
|
213
213
|
/**
|
|
214
214
|
* Creates an @AuthenticationResult from @CacheRecord , @IdToken , and a boolean that states whether or not the result is from cache.
|
|
@@ -230,10 +230,10 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
230
230
|
accessToken = "";
|
|
231
231
|
responseScopes = [];
|
|
232
232
|
expiresOn = null;
|
|
233
|
-
familyId = Constants
|
|
233
|
+
familyId = Constants.EMPTY_STRING;
|
|
234
234
|
if (!cacheRecord.accessToken) return [3 /*break*/, 4];
|
|
235
235
|
if (!(cacheRecord.accessToken.tokenType === AuthenticationScheme.POP)) return [3 /*break*/, 2];
|
|
236
|
-
popTokenGenerator = new PopTokenGenerator
|
|
236
|
+
popTokenGenerator = new PopTokenGenerator(cryptoObj);
|
|
237
237
|
return [4 /*yield*/, popTokenGenerator.signPopToken(cacheRecord.accessToken.secret, request)];
|
|
238
238
|
case 1:
|
|
239
239
|
accessToken = _d.sent();
|
|
@@ -242,33 +242,33 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
242
242
|
accessToken = cacheRecord.accessToken.secret;
|
|
243
243
|
_d.label = 3;
|
|
244
244
|
case 3:
|
|
245
|
-
responseScopes = ScopeSet
|
|
245
|
+
responseScopes = ScopeSet.fromString(cacheRecord.accessToken.target).asArray();
|
|
246
246
|
expiresOn = new Date(Number(cacheRecord.accessToken.expiresOn) * 1000);
|
|
247
247
|
extExpiresOn = new Date(Number(cacheRecord.accessToken.extendedExpiresOn) * 1000);
|
|
248
248
|
_d.label = 4;
|
|
249
249
|
case 4:
|
|
250
250
|
if (cacheRecord.appMetadata) {
|
|
251
|
-
familyId = cacheRecord.appMetadata.familyId === THE_FAMILY_ID ? THE_FAMILY_ID : Constants
|
|
251
|
+
familyId = cacheRecord.appMetadata.familyId === THE_FAMILY_ID ? THE_FAMILY_ID : Constants.EMPTY_STRING;
|
|
252
252
|
}
|
|
253
|
-
uid = (idTokenObj === null || idTokenObj === void 0 ? void 0 : idTokenObj.claims.oid) || (idTokenObj === null || idTokenObj === void 0 ? void 0 : idTokenObj.claims.sub) || Constants
|
|
254
|
-
tid = (idTokenObj === null || idTokenObj === void 0 ? void 0 : idTokenObj.claims.tid) || Constants
|
|
253
|
+
uid = (idTokenObj === null || idTokenObj === void 0 ? void 0 : idTokenObj.claims.oid) || (idTokenObj === null || idTokenObj === void 0 ? void 0 : idTokenObj.claims.sub) || Constants.EMPTY_STRING;
|
|
254
|
+
tid = (idTokenObj === null || idTokenObj === void 0 ? void 0 : idTokenObj.claims.tid) || Constants.EMPTY_STRING;
|
|
255
255
|
return [2 /*return*/, {
|
|
256
256
|
authority: authority.canonicalAuthority,
|
|
257
257
|
uniqueId: uid,
|
|
258
258
|
tenantId: tid,
|
|
259
259
|
scopes: responseScopes,
|
|
260
260
|
account: cacheRecord.account ? cacheRecord.account.getAccountInfo() : null,
|
|
261
|
-
idToken: idTokenObj ? idTokenObj.rawToken : Constants
|
|
261
|
+
idToken: idTokenObj ? idTokenObj.rawToken : Constants.EMPTY_STRING,
|
|
262
262
|
idTokenClaims: idTokenObj ? idTokenObj.claims : {},
|
|
263
263
|
accessToken: accessToken,
|
|
264
264
|
fromCache: fromTokenCache,
|
|
265
265
|
expiresOn: expiresOn,
|
|
266
266
|
extExpiresOn: extExpiresOn,
|
|
267
267
|
familyId: familyId,
|
|
268
|
-
tokenType: ((_a = cacheRecord.accessToken) === null || _a === void 0 ? void 0 : _a.tokenType) || Constants
|
|
269
|
-
state: requestState ? requestState.userRequestState : Constants
|
|
270
|
-
cloudGraphHostName: ((_b = cacheRecord.account) === null || _b === void 0 ? void 0 : _b.cloudGraphHostName) || Constants
|
|
271
|
-
msGraphHost: ((_c = cacheRecord.account) === null || _c === void 0 ? void 0 : _c.msGraphHost) || Constants
|
|
268
|
+
tokenType: ((_a = cacheRecord.accessToken) === null || _a === void 0 ? void 0 : _a.tokenType) || Constants.EMPTY_STRING,
|
|
269
|
+
state: requestState ? requestState.userRequestState : Constants.EMPTY_STRING,
|
|
270
|
+
cloudGraphHostName: ((_b = cacheRecord.account) === null || _b === void 0 ? void 0 : _b.cloudGraphHostName) || Constants.EMPTY_STRING,
|
|
271
|
+
msGraphHost: ((_c = cacheRecord.account) === null || _c === void 0 ? void 0 : _c.msGraphHost) || Constants.EMPTY_STRING
|
|
272
272
|
}];
|
|
273
273
|
}
|
|
274
274
|
});
|