@azure/msal-common 6.1.0 → 6.3.0
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/dist/_virtual/_tslib.js +1 -1
- package/dist/account/AccountInfo.d.ts +6 -1
- package/dist/account/AccountInfo.d.ts.map +1 -1
- package/dist/account/AuthToken.js +1 -1
- package/dist/account/CcsCredential.js +1 -1
- package/dist/account/ClientInfo.js +1 -1
- package/dist/account/TokenClaims.d.ts +29 -0
- package/dist/account/TokenClaims.d.ts.map +1 -1
- package/dist/authority/Authority.js +1 -1
- package/dist/authority/AuthorityFactory.js +1 -1
- package/dist/authority/AuthorityOptions.d.ts +1 -0
- package/dist/authority/AuthorityOptions.d.ts.map +1 -1
- package/dist/authority/AuthorityOptions.js +3 -1
- package/dist/authority/AuthorityOptions.js.map +1 -1
- package/dist/authority/AuthorityType.js +1 -1
- package/dist/authority/CloudInstanceDiscoveryResponse.js +1 -1
- package/dist/authority/OpenIdConfigResponse.js +1 -1
- package/dist/authority/ProtocolMode.js +1 -1
- package/dist/authority/RegionDiscovery.js +1 -1
- package/dist/cache/CacheManager.d.ts +1 -1
- package/dist/cache/CacheManager.js +3 -3
- package/dist/cache/CacheManager.js.map +1 -1
- package/dist/cache/entities/AccessTokenEntity.js +1 -1
- package/dist/cache/entities/AccountEntity.d.ts +3 -1
- package/dist/cache/entities/AccountEntity.d.ts.map +1 -1
- package/dist/cache/entities/AccountEntity.js +16 -12
- package/dist/cache/entities/AccountEntity.js.map +1 -1
- package/dist/cache/entities/AppMetadataEntity.js +1 -1
- package/dist/cache/entities/AuthorityMetadataEntity.js +1 -1
- package/dist/cache/entities/CacheRecord.js +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 +1 -1
- package/dist/cache/entities/RefreshTokenEntity.js +1 -1
- package/dist/cache/entities/ServerTelemetryEntity.js +1 -1
- package/dist/cache/entities/ThrottlingEntity.js +1 -1
- package/dist/cache/persistence/TokenCacheContext.js +1 -1
- package/dist/client/AuthorizationCodeClient.d.ts.map +1 -1
- package/dist/client/AuthorizationCodeClient.js +119 -93
- package/dist/client/AuthorizationCodeClient.js.map +1 -1
- package/dist/client/BaseClient.js +1 -1
- package/dist/client/ClientCredentialClient.d.ts.map +1 -1
- package/dist/client/ClientCredentialClient.js +4 -3
- package/dist/client/ClientCredentialClient.js.map +1 -1
- package/dist/client/DeviceCodeClient.d.ts.map +1 -1
- package/dist/client/DeviceCodeClient.js +2 -1
- package/dist/client/DeviceCodeClient.js.map +1 -1
- package/dist/client/OnBehalfOfClient.js +3 -2
- package/dist/client/OnBehalfOfClient.js.map +1 -1
- package/dist/client/RefreshTokenClient.js +2 -1
- package/dist/client/RefreshTokenClient.js.map +1 -1
- package/dist/client/SilentFlowClient.js +1 -1
- package/dist/client/UsernamePasswordClient.d.ts.map +1 -1
- package/dist/client/UsernamePasswordClient.js +3 -1
- package/dist/client/UsernamePasswordClient.js.map +1 -1
- package/dist/config/ClientConfiguration.d.ts +16 -1
- package/dist/config/ClientConfiguration.d.ts.map +1 -1
- package/dist/config/ClientConfiguration.js +14 -7
- package/dist/config/ClientConfiguration.js.map +1 -1
- package/dist/crypto/ICrypto.d.ts +4 -2
- package/dist/crypto/ICrypto.d.ts.map +1 -1
- package/dist/crypto/ICrypto.js +1 -1
- package/dist/crypto/ICrypto.js.map +1 -1
- package/dist/crypto/IGuidGenerator.d.ts +5 -0
- package/dist/crypto/IGuidGenerator.d.ts.map +1 -0
- package/dist/crypto/PopTokenGenerator.d.ts +30 -0
- package/dist/crypto/PopTokenGenerator.d.ts.map +1 -1
- package/dist/crypto/PopTokenGenerator.js +38 -2
- 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 +1 -1
- package/dist/error/ClientConfigurationError.js +1 -1
- package/dist/error/InteractionRequiredAuthError.js +1 -1
- package/dist/error/ServerError.js +1 -1
- package/dist/index.cjs.js +659 -148
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/logger/Logger.js +13 -13
- package/dist/logger/Logger.js.map +1 -1
- package/dist/network/INetworkModule.js +1 -1
- package/dist/network/NetworkManager.js +1 -1
- package/dist/network/ThrottlingUtils.js +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/AuthenticationHeaderParser.js +3 -3
- package/dist/request/AuthenticationHeaderParser.js.map +1 -1
- package/dist/request/CommonAuthorizationUrlRequest.d.ts +1 -0
- package/dist/request/CommonAuthorizationUrlRequest.d.ts.map +1 -1
- package/dist/request/RequestParameterBuilder.d.ts +14 -1
- package/dist/request/RequestParameterBuilder.d.ts.map +1 -1
- package/dist/request/RequestParameterBuilder.js +31 -3
- package/dist/request/RequestParameterBuilder.js.map +1 -1
- package/dist/request/RequestValidator.js +1 -1
- package/dist/request/ScopeSet.js +4 -4
- package/dist/request/ScopeSet.js.map +1 -1
- package/dist/response/AuthenticationResult.d.ts +1 -0
- package/dist/response/AuthenticationResult.d.ts.map +1 -1
- package/dist/response/ResponseHandler.d.ts.map +1 -1
- package/dist/response/ResponseHandler.js +6 -5
- package/dist/response/ResponseHandler.js.map +1 -1
- package/dist/response/ServerAuthorizationCodeResponse.d.ts +1 -0
- package/dist/response/ServerAuthorizationCodeResponse.d.ts.map +1 -1
- package/dist/telemetry/performance/IPerformanceClient.d.ts +22 -0
- package/dist/telemetry/performance/IPerformanceClient.d.ts.map +1 -0
- package/dist/telemetry/performance/IPerformanceMeasurement.d.ts +6 -0
- package/dist/telemetry/performance/IPerformanceMeasurement.d.ts.map +1 -0
- package/dist/telemetry/performance/PerformanceClient.d.ts +125 -0
- package/dist/telemetry/performance/PerformanceClient.d.ts.map +1 -0
- package/dist/telemetry/performance/PerformanceClient.js +275 -0
- package/dist/telemetry/performance/PerformanceClient.js.map +1 -0
- package/dist/telemetry/performance/PerformanceEvent.d.ts +203 -0
- package/dist/telemetry/performance/PerformanceEvent.d.ts.map +1 -0
- package/dist/telemetry/performance/PerformanceEvent.js +100 -0
- package/dist/telemetry/performance/PerformanceEvent.js.map +1 -0
- package/dist/telemetry/performance/StubPerformanceClient.d.ts +13 -0
- package/dist/telemetry/performance/StubPerformanceClient.d.ts.map +1 -0
- package/dist/telemetry/performance/StubPerformanceClient.js +37 -0
- package/dist/telemetry/performance/StubPerformanceClient.js.map +1 -0
- package/dist/telemetry/server/ServerTelemetryManager.js +4 -4
- package/dist/telemetry/server/ServerTelemetryManager.js.map +1 -1
- package/dist/url/UrlString.js +2 -2
- package/dist/url/UrlString.js.map +1 -1
- package/dist/utils/Constants.d.ts +5 -0
- package/dist/utils/Constants.d.ts.map +1 -1
- package/dist/utils/Constants.js +7 -2
- package/dist/utils/Constants.js.map +1 -1
- package/dist/utils/ProtocolUtils.js +3 -3
- package/dist/utils/ProtocolUtils.js.map +1 -1
- package/dist/utils/StringUtils.js +1 -1
- package/dist/utils/TimeUtils.js +1 -1
- package/package.json +2 -4
- package/CHANGELOG.json +0 -1319
- package/CHANGELOG.md +0 -504
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @azure/msal-common v6.
|
|
1
|
+
/*! @azure/msal-common v6.3.0 2022-05-02 */
|
|
2
2
|
'use strict';
|
|
3
3
|
import { Separators, CacheAccountType, CacheType, Constants } from '../../utils/Constants.js';
|
|
4
4
|
import { buildClientInfo } from '../../account/ClientInfo.js';
|
|
@@ -31,6 +31,7 @@ import { AuthorityType } from '../../authority/AuthorityType.js';
|
|
|
31
31
|
* lastModificationApp:
|
|
32
32
|
* oboAssertion: access token passed in as part of OBO request
|
|
33
33
|
* idTokenClaims: Object containing claims parsed from ID token
|
|
34
|
+
* nativeAccountId: Account identifier on the native device
|
|
34
35
|
* }
|
|
35
36
|
*/
|
|
36
37
|
var AccountEntity = /** @class */ (function () {
|
|
@@ -84,7 +85,8 @@ var AccountEntity = /** @class */ (function () {
|
|
|
84
85
|
username: this.username,
|
|
85
86
|
localAccountId: this.localAccountId,
|
|
86
87
|
name: this.name,
|
|
87
|
-
idTokenClaims: this.idTokenClaims
|
|
88
|
+
idTokenClaims: this.idTokenClaims,
|
|
89
|
+
nativeAccountId: this.nativeAccountId
|
|
88
90
|
};
|
|
89
91
|
};
|
|
90
92
|
/**
|
|
@@ -94,8 +96,8 @@ var AccountEntity = /** @class */ (function () {
|
|
|
94
96
|
AccountEntity.generateAccountCacheKey = function (accountInterface) {
|
|
95
97
|
var accountKey = [
|
|
96
98
|
accountInterface.homeAccountId,
|
|
97
|
-
accountInterface.environment ||
|
|
98
|
-
accountInterface.tenantId ||
|
|
99
|
+
accountInterface.environment || Constants.EMPTY_STRING,
|
|
100
|
+
accountInterface.tenantId || Constants.EMPTY_STRING,
|
|
99
101
|
];
|
|
100
102
|
return accountKey.join(Separators.CACHE_KEY_SEPARATOR).toLowerCase();
|
|
101
103
|
};
|
|
@@ -106,29 +108,30 @@ var AccountEntity = /** @class */ (function () {
|
|
|
106
108
|
* @param idToken
|
|
107
109
|
* @param policy
|
|
108
110
|
*/
|
|
109
|
-
AccountEntity.createAccount = function (clientInfo, homeAccountId, idToken, authority, oboAssertion, cloudGraphHostName, msGraphHost, environment) {
|
|
111
|
+
AccountEntity.createAccount = function (clientInfo, homeAccountId, idToken, authority, oboAssertion, cloudGraphHostName, msGraphHost, environment, nativeAccountId) {
|
|
110
112
|
var _a, _b, _c, _d, _e, _f;
|
|
111
113
|
var account = new AccountEntity();
|
|
112
114
|
account.authorityType = CacheAccountType.MSSTS_ACCOUNT_TYPE;
|
|
113
115
|
account.clientInfo = clientInfo;
|
|
114
116
|
account.homeAccountId = homeAccountId;
|
|
117
|
+
account.nativeAccountId = nativeAccountId;
|
|
115
118
|
var env = environment || (authority && authority.getPreferredCache());
|
|
116
119
|
if (!env) {
|
|
117
120
|
throw ClientAuthError.createInvalidCacheEnvironmentError();
|
|
118
121
|
}
|
|
119
122
|
account.environment = env;
|
|
120
123
|
// non AAD scenarios can have empty realm
|
|
121
|
-
account.realm = ((_a = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _a === void 0 ? void 0 : _a.tid) ||
|
|
124
|
+
account.realm = ((_a = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _a === void 0 ? void 0 : _a.tid) || Constants.EMPTY_STRING;
|
|
122
125
|
account.oboAssertion = oboAssertion;
|
|
123
126
|
if (idToken) {
|
|
124
127
|
account.idTokenClaims = idToken.claims;
|
|
125
128
|
// How do you account for MSA CID here?
|
|
126
|
-
account.localAccountId = ((_b = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _b === void 0 ? void 0 : _b.oid) || ((_c = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _c === void 0 ? void 0 : _c.sub) ||
|
|
129
|
+
account.localAccountId = ((_b = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _b === void 0 ? void 0 : _b.oid) || ((_c = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _c === void 0 ? void 0 : _c.sub) || Constants.EMPTY_STRING;
|
|
127
130
|
/*
|
|
128
131
|
* In B2C scenarios the emails claim is used instead of preferred_username and it is an array. In most cases it will contain a single email.
|
|
129
132
|
* This field should not be relied upon if a custom policy is configured to return more than 1 email.
|
|
130
133
|
*/
|
|
131
|
-
account.username = ((_d = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _d === void 0 ? void 0 : _d.preferred_username) || (((_e = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _e === void 0 ? void 0 : _e.emails) ? idToken.claims.emails[0] :
|
|
134
|
+
account.username = ((_d = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _d === void 0 ? void 0 : _d.preferred_username) || (((_e = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _e === void 0 ? void 0 : _e.emails) ? idToken.claims.emails[0] : Constants.EMPTY_STRING);
|
|
132
135
|
account.name = (_f = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _f === void 0 ? void 0 : _f.name;
|
|
133
136
|
}
|
|
134
137
|
account.cloudGraphHostName = cloudGraphHostName;
|
|
@@ -146,7 +149,7 @@ var AccountEntity = /** @class */ (function () {
|
|
|
146
149
|
account.authorityType = (authority && authority.authorityType === AuthorityType.Adfs) ? CacheAccountType.ADFS_ACCOUNT_TYPE : CacheAccountType.GENERIC_ACCOUNT_TYPE;
|
|
147
150
|
account.homeAccountId = homeAccountId;
|
|
148
151
|
// non AAD scenarios can have empty realm
|
|
149
|
-
account.realm =
|
|
152
|
+
account.realm = Constants.EMPTY_STRING;
|
|
150
153
|
account.oboAssertion = oboAssertion;
|
|
151
154
|
var env = environment || authority && authority.getPreferredCache();
|
|
152
155
|
if (!env) {
|
|
@@ -154,10 +157,10 @@ var AccountEntity = /** @class */ (function () {
|
|
|
154
157
|
}
|
|
155
158
|
if (idToken) {
|
|
156
159
|
// How do you account for MSA CID here?
|
|
157
|
-
account.localAccountId = ((_a = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _a === void 0 ? void 0 : _a.oid) || ((_b = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _b === void 0 ? void 0 : _b.sub) ||
|
|
160
|
+
account.localAccountId = ((_a = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _a === void 0 ? void 0 : _a.oid) || ((_b = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _b === void 0 ? void 0 : _b.sub) || Constants.EMPTY_STRING;
|
|
158
161
|
// upn claim for most ADFS scenarios
|
|
159
|
-
account.username = ((_c = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _c === void 0 ? void 0 : _c.upn) ||
|
|
160
|
-
account.name = ((_d = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _d === void 0 ? void 0 : _d.name) ||
|
|
162
|
+
account.username = ((_c = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _c === void 0 ? void 0 : _c.upn) || Constants.EMPTY_STRING;
|
|
163
|
+
account.name = ((_d = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _d === void 0 ? void 0 : _d.name) || Constants.EMPTY_STRING;
|
|
161
164
|
account.idTokenClaims = idToken === null || idToken === void 0 ? void 0 : idToken.claims;
|
|
162
165
|
}
|
|
163
166
|
account.environment = env;
|
|
@@ -233,6 +236,7 @@ var AccountEntity = /** @class */ (function () {
|
|
|
233
236
|
(accountA.username === accountB.username) &&
|
|
234
237
|
(accountA.tenantId === accountB.tenantId) &&
|
|
235
238
|
(accountA.environment === accountB.environment) &&
|
|
239
|
+
(accountA.nativeAccountId === accountB.nativeAccountId) &&
|
|
236
240
|
claimsMatch;
|
|
237
241
|
};
|
|
238
242
|
return AccountEntity;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccountEntity.js","sources":["../../../src/cache/entities/AccountEntity.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n Separators,\n CacheAccountType,\n CacheType,\n Constants,\n} from \"../../utils/Constants\";\nimport { Authority } from \"../../authority/Authority\";\nimport { AuthToken } from \"../../account/AuthToken\";\nimport { ICrypto } from \"../../crypto/ICrypto\";\nimport { buildClientInfo } from \"../../account/ClientInfo\";\nimport { StringUtils } from \"../../utils/StringUtils\";\nimport { AccountInfo } from \"../../account/AccountInfo\";\nimport { ClientAuthError } from \"../../error/ClientAuthError\";\nimport { AuthorityType } from \"../../authority/AuthorityType\";\nimport { Logger } from \"../../logger/Logger\";\nimport { TokenClaims } from \"../../account/TokenClaims\";\n\n/**\n * Type that defines required and optional parameters for an Account field (based on universal cache schema implemented by all MSALs).\n *\n * Key : Value Schema\n *\n * Key: <home_account_id>-<environment>-<realm*>\n *\n * Value Schema:\n * {\n * homeAccountId: home account identifier for the auth scheme,\n * environment: entity that issued the token, represented as a full host\n * realm: Full tenant or organizational identifier that the account belongs to\n * localAccountId: Original tenant-specific accountID, usually used for legacy cases\n * username: primary username that represents the user, usually corresponds to preferred_username in the v2 endpt\n * authorityType: Accounts authority type as a string\n * name: Full name for the account, including given name and family name,\n * clientInfo: Full base64 encoded client info received from ESTS\n * lastModificationTime: last time this entity was modified in the cache\n * lastModificationApp:\n * oboAssertion: access token passed in as part of OBO request\n * idTokenClaims: Object containing claims parsed from ID token\n * }\n */\nexport class AccountEntity {\n homeAccountId: string;\n environment: string;\n realm: string;\n localAccountId: string;\n username: string;\n authorityType: string;\n name?: string;\n clientInfo?: string;\n lastModificationTime?: string;\n lastModificationApp?: string;\n oboAssertion?: string;\n cloudGraphHostName?: string;\n msGraphHost?: string; \n idTokenClaims?: TokenClaims;\n\n /**\n * Generate Account Id key component as per the schema: <home_account_id>-<environment>\n */\n generateAccountId(): string {\n const accountId: Array<string> = [this.homeAccountId, this.environment];\n return accountId.join(Separators.CACHE_KEY_SEPARATOR).toLowerCase();\n }\n\n /**\n * Generate Account Cache Key as per the schema: <home_account_id>-<environment>-<realm*>\n */\n generateAccountKey(): string {\n return AccountEntity.generateAccountCacheKey({\n homeAccountId: this.homeAccountId,\n environment: this.environment,\n tenantId: this.realm,\n username: this.username,\n localAccountId: this.localAccountId\n });\n }\n\n /**\n * returns the type of the cache (in this case account)\n */\n generateType(): number {\n switch (this.authorityType) {\n case CacheAccountType.ADFS_ACCOUNT_TYPE:\n return CacheType.ADFS;\n case CacheAccountType.MSAV1_ACCOUNT_TYPE:\n return CacheType.MSA;\n case CacheAccountType.MSSTS_ACCOUNT_TYPE:\n return CacheType.MSSTS;\n case CacheAccountType.GENERIC_ACCOUNT_TYPE:\n return CacheType.GENERIC;\n default: {\n throw ClientAuthError.createUnexpectedAccountTypeError();\n }\n }\n }\n\n /**\n * Returns the AccountInfo interface for this account.\n */\n getAccountInfo(): AccountInfo {\n return {\n homeAccountId: this.homeAccountId,\n environment: this.environment,\n tenantId: this.realm,\n username: this.username,\n localAccountId: this.localAccountId,\n name: this.name,\n idTokenClaims: this.idTokenClaims\n };\n }\n\n /**\n * Generates account key from interface\n * @param accountInterface\n */\n static generateAccountCacheKey(accountInterface: AccountInfo): string {\n const accountKey = [\n accountInterface.homeAccountId,\n accountInterface.environment || \"\",\n accountInterface.tenantId || \"\",\n ];\n\n return accountKey.join(Separators.CACHE_KEY_SEPARATOR).toLowerCase();\n }\n\n /**\n * Build Account cache from IdToken, clientInfo and authority/policy. Associated with AAD.\n * @param clientInfo\n * @param authority\n * @param idToken\n * @param policy\n */\n static createAccount(\n clientInfo: string,\n homeAccountId: string,\n idToken: AuthToken,\n authority?: Authority,\n oboAssertion?: string,\n cloudGraphHostName?: string,\n msGraphHost?: string,\n environment?: string\n ): AccountEntity {\n const account: AccountEntity = new AccountEntity();\n\n account.authorityType = CacheAccountType.MSSTS_ACCOUNT_TYPE;\n account.clientInfo = clientInfo;\n account.homeAccountId = homeAccountId;\n\n const env = environment || (authority && authority.getPreferredCache());\n\n if (!env) {\n throw ClientAuthError.createInvalidCacheEnvironmentError();\n }\n\n account.environment = env;\n // non AAD scenarios can have empty realm\n account.realm = idToken?.claims?.tid || \"\";\n account.oboAssertion = oboAssertion;\n \n if (idToken) {\n account.idTokenClaims = idToken.claims;\n\n // How do you account for MSA CID here?\n account.localAccountId = idToken?.claims?.oid || idToken?.claims?.sub || \"\";\n\n /*\n * In B2C scenarios the emails claim is used instead of preferred_username and it is an array. In most cases it will contain a single email.\n * This field should not be relied upon if a custom policy is configured to return more than 1 email.\n */\n account.username = idToken?.claims?.preferred_username || (idToken?.claims?.emails? idToken.claims.emails[0]: \"\");\n account.name = idToken?.claims?.name;\n }\n\n account.cloudGraphHostName = cloudGraphHostName;\n account.msGraphHost = msGraphHost;\n\n return account;\n }\n\n /**\n * Builds non-AAD/ADFS account.\n * @param authority\n * @param idToken\n */\n static createGenericAccount(\n homeAccountId: string,\n idToken: AuthToken,\n authority?: Authority,\n oboAssertion?: string,\n cloudGraphHostName?: string,\n msGraphHost?: string,\n environment?: string\n ): AccountEntity {\n const account: AccountEntity = new AccountEntity();\n\n account.authorityType = (authority && authority.authorityType === AuthorityType.Adfs) ? CacheAccountType.ADFS_ACCOUNT_TYPE : CacheAccountType.GENERIC_ACCOUNT_TYPE;\n account.homeAccountId = homeAccountId;\n // non AAD scenarios can have empty realm\n account.realm = \"\";\n account.oboAssertion = oboAssertion;\n\n const env = environment || authority && authority.getPreferredCache();\n\n if (!env) {\n throw ClientAuthError.createInvalidCacheEnvironmentError();\n }\n\n if (idToken) {\n // How do you account for MSA CID here?\n account.localAccountId = idToken?.claims?.oid || idToken?.claims?.sub || \"\";\n // upn claim for most ADFS scenarios\n account.username = idToken?.claims?.upn || \"\";\n account.name = idToken?.claims?.name || \"\";\n account.idTokenClaims = idToken?.claims;\n }\n\n account.environment = env;\n\n account.cloudGraphHostName = cloudGraphHostName;\n account.msGraphHost = msGraphHost;\n\n /*\n * add uniqueName to claims\n * account.name = idToken.claims.uniqueName;\n */\n\n return account;\n }\n\n /**\n * Generate HomeAccountId from server response\n * @param serverClientInfo\n * @param authType\n */\n static generateHomeAccountId(serverClientInfo: string, authType: AuthorityType, logger: Logger, cryptoObj: ICrypto, idToken?: AuthToken): string {\n\n const accountId = idToken?.claims?.sub ? idToken.claims.sub : Constants.EMPTY_STRING;\n\n // since ADFS does not have tid and does not set client_info\n if (authType === AuthorityType.Adfs) {\n return accountId;\n }\n\n // for cases where there is clientInfo\n if (serverClientInfo) {\n try {\n const clientInfo = buildClientInfo(serverClientInfo, cryptoObj);\n if (!StringUtils.isEmpty(clientInfo.uid) && !StringUtils.isEmpty(clientInfo.utid)) {\n return `${clientInfo.uid}${Separators.CLIENT_INFO_SEPARATOR}${clientInfo.utid}`;\n }\n } catch (e) {}\n }\n\n // default to \"sub\" claim\n logger.verbose(\"No client info in response\");\n return accountId;\n }\n\n /**\n * Validates an entity: checks for all expected params\n * @param entity\n */\n static isAccountEntity(entity: object): boolean {\n\n if (!entity) {\n return false;\n }\n\n return (\n entity.hasOwnProperty(\"homeAccountId\") &&\n entity.hasOwnProperty(\"environment\") &&\n entity.hasOwnProperty(\"realm\") &&\n entity.hasOwnProperty(\"localAccountId\") &&\n entity.hasOwnProperty(\"username\") &&\n entity.hasOwnProperty(\"authorityType\")\n );\n }\n\n /**\n * Helper function to determine whether 2 accountInfo objects represent the same account\n * @param accountA \n * @param accountB \n * @param compareClaims - If set to true idTokenClaims will also be compared to determine account equality\n */\n static accountInfoIsEqual(accountA: AccountInfo | null, accountB: AccountInfo | null, compareClaims?: boolean): boolean {\n if (!accountA || !accountB) {\n return false;\n }\n\n let claimsMatch = true; // default to true so as to not fail comparison below if compareClaims: false\n if (compareClaims) {\n const accountAClaims = (accountA.idTokenClaims || {}) as TokenClaims;\n const accountBClaims = (accountB.idTokenClaims || {}) as TokenClaims;\n\n // issued at timestamp and nonce are expected to change each time a new id token is acquired\n claimsMatch = (accountAClaims.iat === accountBClaims.iat) &&\n (accountAClaims.nonce === accountBClaims.nonce);\n }\n\n return (accountA.homeAccountId === accountB.homeAccountId) && \n (accountA.localAccountId === accountB.localAccountId) &&\n (accountA.username === accountB.username) &&\n (accountA.tenantId === accountB.tenantId) &&\n (accountA.environment === accountB.environment) &&\n claimsMatch;\n }\n}\n"],"names":[],"mappings":";;;;;;;;AAAA;;;;AAsBA;;;;;;;;;;;;;;;;;;;;;;;;IAuBA;KA0QC;;;;IAvPG,yCAAiB,GAAjB;QACI,IAAM,SAAS,GAAkB,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QACxE,OAAO,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,CAAC,WAAW,EAAE,CAAC;KACvE;;;;IAKD,0CAAkB,GAAlB;QACI,OAAO,aAAa,CAAC,uBAAuB,CAAC;YACzC,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,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C9B,MAAM,CAAC,cAAc,CAAC,gBAAgB,CAAC;YACvC,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC;YACjC,MAAM,CAAC,cAAc,CAAC,eAAe,CAAC,EACxC;KACL;;;;;;;IAQM,gCAAkB,GAAzB,UAA0B,QAA4B,EAAE,QAA4B,EAAE,aAAuB;QACzG,IAAI,CAAC,QAAQ,IAAI,CAAC,QAAQ,EAAE;YACxB,OAAO,KAAK,CAAC;SAChB;QAED,IAAI,WAAW,GAAG,IAAI,CAAC;QACvB,IAAI,aAAa,EAAE;YACf,IAAM,cAAc,IAAI,QAAQ,CAAC,aAAa,IAAI,EAAE,CAAgB,CAAC;YACrE,IAAM,cAAc,IAAI,QAAQ,CAAC,aAAa,IAAI,EAAE,CAAgB,CAAC;;YAGrE,WAAW,GAAG,CAAC,cAAc,CAAC,GAAG,KAAK,cAAc,CAAC,GAAG;iBACvD,cAAc,CAAC,KAAK,KAAK,cAAc,CAAC,KAAK,CAAC,CAAC;SACnD;QAED,OAAO,CAAC,QAAQ,CAAC,aAAa,KAAK,QAAQ,CAAC,aAAa;aACpD,QAAQ,CAAC,cAAc,KAAK,QAAQ,CAAC,cAAc,CAAC;aACpD,QAAQ,CAAC,QAAQ,KAAK,QAAQ,CAAC,QAAQ,CAAC;aACxC,QAAQ,CAAC,QAAQ,KAAK,QAAQ,CAAC,QAAQ,CAAC;aACxC,QAAQ,CAAC,WAAW,KAAK,QAAQ,CAAC,WAAW,CAAC;YAC/C,WAAW,CAAC;KACnB;IACL,oBAAC;AAAD,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"AccountEntity.js","sources":["../../../src/cache/entities/AccountEntity.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n Separators,\n CacheAccountType,\n CacheType,\n Constants,\n} from \"../../utils/Constants\";\nimport { Authority } from \"../../authority/Authority\";\nimport { AuthToken } from \"../../account/AuthToken\";\nimport { ICrypto } from \"../../crypto/ICrypto\";\nimport { buildClientInfo } from \"../../account/ClientInfo\";\nimport { StringUtils } from \"../../utils/StringUtils\";\nimport { AccountInfo } from \"../../account/AccountInfo\";\nimport { ClientAuthError } from \"../../error/ClientAuthError\";\nimport { AuthorityType } from \"../../authority/AuthorityType\";\nimport { Logger } from \"../../logger/Logger\";\nimport { TokenClaims } from \"../../account/TokenClaims\";\n\n/**\n * Type that defines required and optional parameters for an Account field (based on universal cache schema implemented by all MSALs).\n *\n * Key : Value Schema\n *\n * Key: <home_account_id>-<environment>-<realm*>\n *\n * Value Schema:\n * {\n * homeAccountId: home account identifier for the auth scheme,\n * environment: entity that issued the token, represented as a full host\n * realm: Full tenant or organizational identifier that the account belongs to\n * localAccountId: Original tenant-specific accountID, usually used for legacy cases\n * username: primary username that represents the user, usually corresponds to preferred_username in the v2 endpt\n * authorityType: Accounts authority type as a string\n * name: Full name for the account, including given name and family name,\n * clientInfo: Full base64 encoded client info received from ESTS\n * lastModificationTime: last time this entity was modified in the cache\n * lastModificationApp:\n * oboAssertion: access token passed in as part of OBO request\n * idTokenClaims: Object containing claims parsed from ID token\n * nativeAccountId: Account identifier on the native device\n * }\n */\nexport class AccountEntity {\n homeAccountId: string;\n environment: string;\n realm: string;\n localAccountId: string;\n username: string;\n authorityType: string;\n name?: string;\n clientInfo?: string;\n lastModificationTime?: string;\n lastModificationApp?: string;\n oboAssertion?: string;\n cloudGraphHostName?: string;\n msGraphHost?: string; \n idTokenClaims?: TokenClaims;\n nativeAccountId?: string;\n\n /**\n * Generate Account Id key component as per the schema: <home_account_id>-<environment>\n */\n generateAccountId(): string {\n const accountId: Array<string> = [this.homeAccountId, this.environment];\n return accountId.join(Separators.CACHE_KEY_SEPARATOR).toLowerCase();\n }\n\n /**\n * Generate Account Cache Key as per the schema: <home_account_id>-<environment>-<realm*>\n */\n generateAccountKey(): string {\n return AccountEntity.generateAccountCacheKey({\n homeAccountId: this.homeAccountId,\n environment: this.environment,\n tenantId: this.realm,\n username: this.username,\n localAccountId: this.localAccountId\n });\n }\n\n /**\n * returns the type of the cache (in this case account)\n */\n generateType(): number {\n switch (this.authorityType) {\n case CacheAccountType.ADFS_ACCOUNT_TYPE:\n return CacheType.ADFS;\n case CacheAccountType.MSAV1_ACCOUNT_TYPE:\n return CacheType.MSA;\n case CacheAccountType.MSSTS_ACCOUNT_TYPE:\n return CacheType.MSSTS;\n case CacheAccountType.GENERIC_ACCOUNT_TYPE:\n return CacheType.GENERIC;\n default: {\n throw ClientAuthError.createUnexpectedAccountTypeError();\n }\n }\n }\n\n /**\n * Returns the AccountInfo interface for this account.\n */\n getAccountInfo(): AccountInfo {\n return {\n homeAccountId: this.homeAccountId,\n environment: this.environment,\n tenantId: this.realm,\n username: this.username,\n localAccountId: this.localAccountId,\n name: this.name,\n idTokenClaims: this.idTokenClaims,\n nativeAccountId: this.nativeAccountId\n };\n }\n\n /**\n * Generates account key from interface\n * @param accountInterface\n */\n static generateAccountCacheKey(accountInterface: AccountInfo): string {\n const accountKey = [\n accountInterface.homeAccountId,\n accountInterface.environment || Constants.EMPTY_STRING,\n accountInterface.tenantId || Constants.EMPTY_STRING,\n ];\n\n return accountKey.join(Separators.CACHE_KEY_SEPARATOR).toLowerCase();\n }\n\n /**\n * Build Account cache from IdToken, clientInfo and authority/policy. Associated with AAD.\n * @param clientInfo\n * @param authority\n * @param idToken\n * @param policy\n */\n static createAccount(\n clientInfo: string,\n homeAccountId: string,\n idToken: AuthToken,\n authority?: Authority,\n oboAssertion?: string,\n cloudGraphHostName?: string,\n msGraphHost?: string,\n environment?: string,\n nativeAccountId?: string\n ): AccountEntity {\n const account: AccountEntity = new AccountEntity();\n\n account.authorityType = CacheAccountType.MSSTS_ACCOUNT_TYPE;\n account.clientInfo = clientInfo;\n account.homeAccountId = homeAccountId;\n account.nativeAccountId = nativeAccountId;\n\n const env = environment || (authority && authority.getPreferredCache());\n\n if (!env) {\n throw ClientAuthError.createInvalidCacheEnvironmentError();\n }\n\n account.environment = env;\n // non AAD scenarios can have empty realm\n account.realm = idToken?.claims?.tid || Constants.EMPTY_STRING;\n account.oboAssertion = oboAssertion;\n \n if (idToken) {\n account.idTokenClaims = idToken.claims;\n\n // How do you account for MSA CID here?\n account.localAccountId = idToken?.claims?.oid || idToken?.claims?.sub || Constants.EMPTY_STRING;\n\n /*\n * In B2C scenarios the emails claim is used instead of preferred_username and it is an array. In most cases it will contain a single email.\n * This field should not be relied upon if a custom policy is configured to return more than 1 email.\n */\n account.username = idToken?.claims?.preferred_username || (idToken?.claims?.emails? idToken.claims.emails[0]: Constants.EMPTY_STRING);\n account.name = idToken?.claims?.name;\n }\n\n account.cloudGraphHostName = cloudGraphHostName;\n account.msGraphHost = msGraphHost;\n\n return account;\n }\n\n /**\n * Builds non-AAD/ADFS account.\n * @param authority\n * @param idToken\n */\n static createGenericAccount(\n homeAccountId: string,\n idToken: AuthToken,\n authority?: Authority,\n oboAssertion?: string,\n cloudGraphHostName?: string,\n msGraphHost?: string,\n environment?: string\n ): AccountEntity {\n const account: AccountEntity = new AccountEntity();\n\n account.authorityType = (authority && authority.authorityType === AuthorityType.Adfs) ? CacheAccountType.ADFS_ACCOUNT_TYPE : CacheAccountType.GENERIC_ACCOUNT_TYPE;\n account.homeAccountId = homeAccountId;\n // non AAD scenarios can have empty realm\n account.realm = Constants.EMPTY_STRING;\n account.oboAssertion = oboAssertion;\n\n const env = environment || authority && authority.getPreferredCache();\n\n if (!env) {\n throw ClientAuthError.createInvalidCacheEnvironmentError();\n }\n\n if (idToken) {\n // How do you account for MSA CID here?\n account.localAccountId = idToken?.claims?.oid || idToken?.claims?.sub || Constants.EMPTY_STRING;\n // upn claim for most ADFS scenarios\n account.username = idToken?.claims?.upn || Constants.EMPTY_STRING;\n account.name = idToken?.claims?.name || Constants.EMPTY_STRING;\n account.idTokenClaims = idToken?.claims;\n }\n\n account.environment = env;\n\n account.cloudGraphHostName = cloudGraphHostName;\n account.msGraphHost = msGraphHost;\n\n /*\n * add uniqueName to claims\n * account.name = idToken.claims.uniqueName;\n */\n\n return account;\n }\n\n /**\n * Generate HomeAccountId from server response\n * @param serverClientInfo\n * @param authType\n */\n static generateHomeAccountId(serverClientInfo: string, authType: AuthorityType, logger: Logger, cryptoObj: ICrypto, idToken?: AuthToken): string {\n\n const accountId = idToken?.claims?.sub ? idToken.claims.sub : Constants.EMPTY_STRING;\n\n // since ADFS does not have tid and does not set client_info\n if (authType === AuthorityType.Adfs) {\n return accountId;\n }\n\n // for cases where there is clientInfo\n if (serverClientInfo) {\n try {\n const clientInfo = buildClientInfo(serverClientInfo, cryptoObj);\n if (!StringUtils.isEmpty(clientInfo.uid) && !StringUtils.isEmpty(clientInfo.utid)) {\n return `${clientInfo.uid}${Separators.CLIENT_INFO_SEPARATOR}${clientInfo.utid}`;\n }\n } catch (e) {}\n }\n\n // default to \"sub\" claim\n logger.verbose(\"No client info in response\");\n return accountId;\n }\n\n /**\n * Validates an entity: checks for all expected params\n * @param entity\n */\n static isAccountEntity(entity: object): boolean {\n\n if (!entity) {\n return false;\n }\n\n return (\n entity.hasOwnProperty(\"homeAccountId\") &&\n entity.hasOwnProperty(\"environment\") &&\n entity.hasOwnProperty(\"realm\") &&\n entity.hasOwnProperty(\"localAccountId\") &&\n entity.hasOwnProperty(\"username\") &&\n entity.hasOwnProperty(\"authorityType\")\n );\n }\n\n /**\n * Helper function to determine whether 2 accountInfo objects represent the same account\n * @param accountA \n * @param accountB \n * @param compareClaims - If set to true idTokenClaims will also be compared to determine account equality\n */\n static accountInfoIsEqual(accountA: AccountInfo | null, accountB: AccountInfo | null, compareClaims?: boolean): boolean {\n if (!accountA || !accountB) {\n return false;\n }\n\n let claimsMatch = true; // default to true so as to not fail comparison below if compareClaims: false\n if (compareClaims) {\n const accountAClaims = (accountA.idTokenClaims || {}) as TokenClaims;\n const accountBClaims = (accountB.idTokenClaims || {}) as TokenClaims;\n\n // issued at timestamp and nonce are expected to change each time a new id token is acquired\n claimsMatch = (accountAClaims.iat === accountBClaims.iat) &&\n (accountAClaims.nonce === accountBClaims.nonce);\n }\n\n return (accountA.homeAccountId === accountB.homeAccountId) && \n (accountA.localAccountId === accountB.localAccountId) &&\n (accountA.username === accountB.username) &&\n (accountA.tenantId === accountB.tenantId) &&\n (accountA.environment === accountB.environment) &&\n (accountA.nativeAccountId === accountB.nativeAccountId) &&\n claimsMatch;\n }\n}\n"],"names":[],"mappings":";;;;;;;;AAAA;;;;AAsBA;;;;;;;;;;;;;;;;;;;;;;;;;IAwBA;KA+QC;;;;IA3PG,yCAAiB,GAAjB;QACI,IAAM,SAAS,GAAkB,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QACxE,OAAO,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,CAAC,WAAW,EAAE,CAAC;KACvE;;;;IAKD,0CAAkB,GAAlB;QACI,OAAO,aAAa,CAAC,uBAAuB,CAAC;YACzC,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,QAAQ,EAAE,IAAI,CAAC,KAAK;YACpB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,cAAc,EAAE,IAAI,CAAC,cAAc;SACtC,CAAC,CAAC;KACN;;;;IAKD,oCAAY,GAAZ;QACI,QAAQ,IAAI,CAAC,aAAa;YACtB,KAAK,gBAAgB,CAAC,iBAAiB;gBACnC,OAAO,SAAS,CAAC,IAAI,CAAC;YAC1B,KAAK,gBAAgB,CAAC,kBAAkB;gBACpC,OAAO,SAAS,CAAC,GAAG,CAAC;YACzB,KAAK,gBAAgB,CAAC,kBAAkB;gBACpC,OAAO,SAAS,CAAC,KAAK,CAAC;YAC3B,KAAK,gBAAgB,CAAC,oBAAoB;gBACtC,OAAO,SAAS,CAAC,OAAO,CAAC;YAC7B,SAAS;gBACL,MAAM,eAAe,CAAC,gCAAgC,EAAE,CAAC;aAC5D;SACJ;KACJ;;;;IAKD,sCAAc,GAAd;Q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YACrE,IAAM,cAAc,IAAI,QAAQ,CAAC,aAAa,IAAI,EAAE,CAAgB,CAAC;;YAGrE,WAAW,GAAG,CAAC,cAAc,CAAC,GAAG,KAAK,cAAc,CAAC,GAAG;iBACvD,cAAc,CAAC,KAAK,KAAK,cAAc,CAAC,KAAK,CAAC,CAAC;SACnD;QAED,OAAO,CAAC,QAAQ,CAAC,aAAa,KAAK,QAAQ,CAAC,aAAa;aACpD,QAAQ,CAAC,cAAc,KAAK,QAAQ,CAAC,cAAc,CAAC;aACpD,QAAQ,CAAC,QAAQ,KAAK,QAAQ,CAAC,QAAQ,CAAC;aACxC,QAAQ,CAAC,QAAQ,KAAK,QAAQ,CAAC,QAAQ,CAAC;aACxC,QAAQ,CAAC,WAAW,KAAK,QAAQ,CAAC,WAAW,CAAC;aAC9C,QAAQ,CAAC,eAAe,KAAK,QAAQ,CAAC,eAAe,CAAC;YACvD,WAAW,CAAC;KACnB;IACL,oBAAC;AAAD,CAAC;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @azure/msal-common v6.
|
|
1
|
+
/*! @azure/msal-common v6.3.0 2022-05-02 */
|
|
2
2
|
'use strict';
|
|
3
3
|
import { CredentialType, CacheType, Constants, Separators, AuthenticationScheme } from '../../utils/Constants.js';
|
|
4
4
|
import { ClientAuthError } from '../../error/ClientAuthError.js';
|
|
@@ -131,7 +131,7 @@ var CredentialEntity = /** @class */ (function () {
|
|
|
131
131
|
var credentialId = [
|
|
132
132
|
credentialType,
|
|
133
133
|
clientOrFamilyId,
|
|
134
|
-
realm ||
|
|
134
|
+
realm || Constants.EMPTY_STRING,
|
|
135
135
|
];
|
|
136
136
|
return credentialId.join(Separators.CACHE_KEY_SEPARATOR).toLowerCase();
|
|
137
137
|
};
|
|
@@ -139,13 +139,13 @@ var CredentialEntity = /** @class */ (function () {
|
|
|
139
139
|
* Generate target key component as per schema: <target>
|
|
140
140
|
*/
|
|
141
141
|
CredentialEntity.generateTargetForCacheKey = function (scopes) {
|
|
142
|
-
return (scopes ||
|
|
142
|
+
return (scopes || Constants.EMPTY_STRING).toLowerCase();
|
|
143
143
|
};
|
|
144
144
|
/**
|
|
145
145
|
* Generate requested claims key component as per schema: <requestedClaims>
|
|
146
146
|
*/
|
|
147
147
|
CredentialEntity.generateClaimsHashForCacheKey = function (requestedClaimsHash) {
|
|
148
|
-
return (requestedClaimsHash ||
|
|
148
|
+
return (requestedClaimsHash || Constants.EMPTY_STRING).toLowerCase();
|
|
149
149
|
};
|
|
150
150
|
/**
|
|
151
151
|
* Generate scheme key componenet as per schema: <scheme>
|
|
@@ -155,7 +155,7 @@ var CredentialEntity = /** @class */ (function () {
|
|
|
155
155
|
* PoP Tokens and SSH certs include scheme in cache key
|
|
156
156
|
* Cast to lowercase to handle "bearer" from ADFS
|
|
157
157
|
*/
|
|
158
|
-
return (tokenType && tokenType.toLowerCase() !== AuthenticationScheme.BEARER.toLowerCase()) ? tokenType.toLowerCase() :
|
|
158
|
+
return (tokenType && tokenType.toLowerCase() !== AuthenticationScheme.BEARER.toLowerCase()) ? tokenType.toLowerCase() : Constants.EMPTY_STRING;
|
|
159
159
|
};
|
|
160
160
|
return CredentialEntity;
|
|
161
161
|
}());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CredentialEntity.js","sources":["../../../src/cache/entities/CredentialEntity.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { Separators, CredentialType, CacheType, Constants, AuthenticationScheme } from \"../../utils/Constants\";\nimport { ClientAuthError } from \"../../error/ClientAuthError\";\n\n/**\n * Base type for credentials to be stored in the cache: eg: ACCESS_TOKEN, ID_TOKEN etc\n *\n * Key:Value Schema:\n *\n * Key: <home_account_id*>-<environment>-<credential_type>-<client_id>-<realm*>-<target*>-<requestedClaims*>-<scheme*>\n *\n * Value Schema:\n * {\n * homeAccountId: home account identifier for the auth scheme,\n * environment: entity that issued the token, represented as a full host\n * credentialType: Type of credential as a string, can be one of the following: RefreshToken, AccessToken, IdToken, Password, Cookie, Certificate, Other\n * clientId: client ID of the application\n * secret: Actual credential as a string\n * familyId: Family ID identifier, usually only used for refresh tokens\n * realm: Full tenant or organizational identifier that the account belongs to\n * target: Permissions that are included in the token, or for refresh tokens, the resource identifier.\n * oboAssertion: access token passed in as part of OBO request\n * tokenType: Matches the authentication scheme for which the token was issued (i.e. Bearer or pop)\n * requestedClaimsHash: Matches the SHA 256 hash of the claims object included in the token request\n * }\n */\nexport class CredentialEntity {\n homeAccountId: string;\n environment: string;\n credentialType: CredentialType;\n clientId: string;\n secret: string;\n familyId?: string;\n realm?: string;\n target?: string;\n oboAssertion?: string;\n tokenType?: AuthenticationScheme;\n keyId?: string;\n requestedClaimsHash?: string;\n\n /**\n * Generate Account Id key component as per the schema: <home_account_id>-<environment>\n */\n generateAccountId(): string {\n return CredentialEntity.generateAccountIdForCacheKey(this.homeAccountId, this.environment);\n }\n\n /**\n * Generate Credential Id key component as per the schema: <credential_type>-<client_id>-<realm>\n */\n generateCredentialId(): string {\n return CredentialEntity.generateCredentialIdForCacheKey(\n this.credentialType,\n this.clientId,\n this.realm,\n this.familyId\n );\n }\n\n /**\n * Generate target key component as per schema: <target>\n */\n generateTarget(): string {\n return CredentialEntity.generateTargetForCacheKey(this.target);\n }\n\n /**\n * generates credential key\n */\n generateCredentialKey(): string {\n return CredentialEntity.generateCredentialCacheKey(\n this.homeAccountId,\n this.environment,\n this.credentialType,\n this.clientId,\n this.realm,\n this.target,\n this.familyId,\n this.tokenType,\n this.requestedClaimsHash\n );\n }\n\n /**\n * returns the type of the cache (in this case credential)\n */\n generateType(): number {\n switch (this.credentialType) {\n case CredentialType.ID_TOKEN:\n return CacheType.ID_TOKEN;\n case CredentialType.ACCESS_TOKEN:\n case CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME:\n return CacheType.ACCESS_TOKEN;\n case CredentialType.REFRESH_TOKEN:\n return CacheType.REFRESH_TOKEN;\n default: {\n throw ClientAuthError.createUnexpectedCredentialTypeError();\n }\n }\n }\n\n /**\n * helper function to return `CredentialType`\n * @param key\n */\n static getCredentialType(key: string): string {\n // First keyword search will match all \"AccessToken\" and \"AccessToken_With_AuthScheme\" credentials\n if (key.indexOf(CredentialType.ACCESS_TOKEN.toLowerCase()) !== -1) {\n // Perform second search to differentiate between \"AccessToken\" and \"AccessToken_With_AuthScheme\" credential types\n if (key.indexOf(CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME.toLowerCase()) !== -1) {\n return CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME;\n }\n return CredentialType.ACCESS_TOKEN;\n } else if (key.indexOf(CredentialType.ID_TOKEN.toLowerCase()) !== -1) {\n return CredentialType.ID_TOKEN;\n } else if (key.indexOf(CredentialType.REFRESH_TOKEN.toLowerCase()) !== -1) {\n return CredentialType.REFRESH_TOKEN;\n }\n\n return Constants.NOT_DEFINED;\n }\n\n /**\n * generates credential key\n * <home_account_id*>-\\<environment>-<credential_type>-<client_id>-<realm\\*>-<target\\*>-<scheme\\*>\n */\n static generateCredentialCacheKey(\n homeAccountId: string,\n environment: string,\n credentialType: CredentialType,\n clientId: string,\n realm?: string,\n target?: string,\n familyId?: string,\n tokenType?: AuthenticationScheme,\n requestedClaimsHash?: string\n ): string {\n const credentialKey = [\n this.generateAccountIdForCacheKey(homeAccountId, environment),\n this.generateCredentialIdForCacheKey(credentialType, clientId, realm, familyId),\n this.generateTargetForCacheKey(target),\n this.generateClaimsHashForCacheKey(requestedClaimsHash),\n this.generateSchemeForCacheKey(tokenType)\n ];\n\n return credentialKey.join(Separators.CACHE_KEY_SEPARATOR).toLowerCase();\n }\n\n /**\n * generates Account Id for keys\n * @param homeAccountId\n * @param environment\n */\n private static generateAccountIdForCacheKey(\n homeAccountId: string,\n environment: string\n ): string {\n const accountId: Array<string> = [homeAccountId, environment];\n return accountId.join(Separators.CACHE_KEY_SEPARATOR).toLowerCase();\n }\n\n /**\n * Generates Credential Id for keys\n * @param credentialType\n * @param realm\n * @param clientId\n * @param familyId\n */\n private static generateCredentialIdForCacheKey(\n credentialType: CredentialType,\n clientId: string,\n realm?: string,\n familyId?: string\n ): string {\n const clientOrFamilyId =\n credentialType === CredentialType.REFRESH_TOKEN\n ? familyId || clientId\n : clientId;\n const credentialId: Array<string> = [\n credentialType,\n clientOrFamilyId,\n realm || \"\",\n ];\n\n return credentialId.join(Separators.CACHE_KEY_SEPARATOR).toLowerCase();\n }\n\n /**\n * Generate target key component as per schema: <target>\n */\n private static generateTargetForCacheKey(scopes?: string): string {\n return (scopes || \"\").toLowerCase();\n }\n\n /**\n * Generate requested claims key component as per schema: <requestedClaims>\n */\n private static generateClaimsHashForCacheKey(requestedClaimsHash?: string): string {\n return(requestedClaimsHash || \"\").toLowerCase();\n }\n\n /**\n * Generate scheme key componenet as per schema: <scheme>\n */\n private static generateSchemeForCacheKey(tokenType?: string): string {\n /*\n * PoP Tokens and SSH certs include scheme in cache key\n * Cast to lowercase to handle \"bearer\" from ADFS\n */\n return (tokenType && tokenType.toLowerCase() !== AuthenticationScheme.BEARER.toLowerCase()) ? tokenType.toLowerCase() : \"\";\n }\n}\n"],"names":[],"mappings":";;;;;AAAA;;;;AAQA;;;;;;;;;;;;;;;;;;;;;;;IAsBA;KAyLC;;;;IAxKG,4CAAiB,GAAjB;QACI,OAAO,gBAAgB,CAAC,4BAA4B,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;KAC9F;;;;IAKD,+CAAoB,GAApB;QACI,OAAO,gBAAgB,CAAC,+BAA+B,CACnD,IAAI,CAAC,cAAc,EACnB,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,KAAK,EACV,IAAI,CAAC,QAAQ,CAChB,CAAC;KACL;;;;IAKD,yCAAc,GAAd;QACI,OAAO,gBAAgB,CAAC,yBAAyB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;KAClE;;;;IAKD,gDAAqB,GAArB;QACI,OA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MAAe;QACpD,OAAO,CAAC,MAAM,IAAI,EAAE,EAAE,WAAW,EAAE,CAAC;KACvC;;;;IAKc,8CAA6B,GAA5C,UAA6C,mBAA4B;QACrE,OAAM,CAAC,mBAAmB,IAAI,EAAE,EAAE,WAAW,EAAE,CAAC;KACnD;;;;IAKc,0CAAyB,GAAxC,UAAyC,SAAkB;;;;;QAKvD,OAAO,CAAC,SAAS,IAAI,SAAS,CAAC,WAAW,EAAE,KAAK,oBAAoB,CAAC,MAAM,CAAC,WAAW,EAAE,IAAI,SAAS,CAAC,WAAW,EAAE,GAAG,EAAE,CAAC;KAC9H;IACL,uBAAC;AAAD,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"CredentialEntity.js","sources":["../../../src/cache/entities/CredentialEntity.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { Separators, CredentialType, CacheType, Constants, AuthenticationScheme } from \"../../utils/Constants\";\nimport { ClientAuthError } from \"../../error/ClientAuthError\";\n\n/**\n * Base type for credentials to be stored in the cache: eg: ACCESS_TOKEN, ID_TOKEN etc\n *\n * Key:Value Schema:\n *\n * Key: <home_account_id*>-<environment>-<credential_type>-<client_id>-<realm*>-<target*>-<requestedClaims*>-<scheme*>\n *\n * Value Schema:\n * {\n * homeAccountId: home account identifier for the auth scheme,\n * environment: entity that issued the token, represented as a full host\n * credentialType: Type of credential as a string, can be one of the following: RefreshToken, AccessToken, IdToken, Password, Cookie, Certificate, Other\n * clientId: client ID of the application\n * secret: Actual credential as a string\n * familyId: Family ID identifier, usually only used for refresh tokens\n * realm: Full tenant or organizational identifier that the account belongs to\n * target: Permissions that are included in the token, or for refresh tokens, the resource identifier.\n * oboAssertion: access token passed in as part of OBO request\n * tokenType: Matches the authentication scheme for which the token was issued (i.e. Bearer or pop)\n * requestedClaimsHash: Matches the SHA 256 hash of the claims object included in the token request\n * }\n */\nexport class CredentialEntity {\n homeAccountId: string;\n environment: string;\n credentialType: CredentialType;\n clientId: string;\n secret: string;\n familyId?: string;\n realm?: string;\n target?: string;\n oboAssertion?: string;\n tokenType?: AuthenticationScheme;\n keyId?: string;\n requestedClaimsHash?: string;\n\n /**\n * Generate Account Id key component as per the schema: <home_account_id>-<environment>\n */\n generateAccountId(): string {\n return CredentialEntity.generateAccountIdForCacheKey(this.homeAccountId, this.environment);\n }\n\n /**\n * Generate Credential Id key component as per the schema: <credential_type>-<client_id>-<realm>\n */\n generateCredentialId(): string {\n return CredentialEntity.generateCredentialIdForCacheKey(\n this.credentialType,\n this.clientId,\n this.realm,\n this.familyId\n );\n }\n\n /**\n * Generate target key component as per schema: <target>\n */\n generateTarget(): string {\n return CredentialEntity.generateTargetForCacheKey(this.target);\n }\n\n /**\n * generates credential key\n */\n generateCredentialKey(): string {\n return CredentialEntity.generateCredentialCacheKey(\n this.homeAccountId,\n this.environment,\n this.credentialType,\n this.clientId,\n this.realm,\n this.target,\n this.familyId,\n this.tokenType,\n this.requestedClaimsHash\n );\n }\n\n /**\n * returns the type of the cache (in this case credential)\n */\n generateType(): number {\n switch (this.credentialType) {\n case CredentialType.ID_TOKEN:\n return CacheType.ID_TOKEN;\n case CredentialType.ACCESS_TOKEN:\n case CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME:\n return CacheType.ACCESS_TOKEN;\n case CredentialType.REFRESH_TOKEN:\n return CacheType.REFRESH_TOKEN;\n default: {\n throw ClientAuthError.createUnexpectedCredentialTypeError();\n }\n }\n }\n\n /**\n * helper function to return `CredentialType`\n * @param key\n */\n static getCredentialType(key: string): string {\n // First keyword search will match all \"AccessToken\" and \"AccessToken_With_AuthScheme\" credentials\n if (key.indexOf(CredentialType.ACCESS_TOKEN.toLowerCase()) !== -1) {\n // Perform second search to differentiate between \"AccessToken\" and \"AccessToken_With_AuthScheme\" credential types\n if (key.indexOf(CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME.toLowerCase()) !== -1) {\n return CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME;\n }\n return CredentialType.ACCESS_TOKEN;\n } else if (key.indexOf(CredentialType.ID_TOKEN.toLowerCase()) !== -1) {\n return CredentialType.ID_TOKEN;\n } else if (key.indexOf(CredentialType.REFRESH_TOKEN.toLowerCase()) !== -1) {\n return CredentialType.REFRESH_TOKEN;\n }\n\n return Constants.NOT_DEFINED;\n }\n\n /**\n * generates credential key\n * <home_account_id*>-\\<environment>-<credential_type>-<client_id>-<realm\\*>-<target\\*>-<scheme\\*>\n */\n static generateCredentialCacheKey(\n homeAccountId: string,\n environment: string,\n credentialType: CredentialType,\n clientId: string,\n realm?: string,\n target?: string,\n familyId?: string,\n tokenType?: AuthenticationScheme,\n requestedClaimsHash?: string\n ): string {\n const credentialKey = [\n this.generateAccountIdForCacheKey(homeAccountId, environment),\n this.generateCredentialIdForCacheKey(credentialType, clientId, realm, familyId),\n this.generateTargetForCacheKey(target),\n this.generateClaimsHashForCacheKey(requestedClaimsHash),\n this.generateSchemeForCacheKey(tokenType)\n ];\n\n return credentialKey.join(Separators.CACHE_KEY_SEPARATOR).toLowerCase();\n }\n\n /**\n * generates Account Id for keys\n * @param homeAccountId\n * @param environment\n */\n private static generateAccountIdForCacheKey(\n homeAccountId: string,\n environment: string\n ): string {\n const accountId: Array<string> = [homeAccountId, environment];\n return accountId.join(Separators.CACHE_KEY_SEPARATOR).toLowerCase();\n }\n\n /**\n * Generates Credential Id for keys\n * @param credentialType\n * @param realm\n * @param clientId\n * @param familyId\n */\n private static generateCredentialIdForCacheKey(\n credentialType: CredentialType,\n clientId: string,\n realm?: string,\n familyId?: string\n ): string {\n const clientOrFamilyId =\n credentialType === CredentialType.REFRESH_TOKEN\n ? familyId || clientId\n : clientId;\n const credentialId: Array<string> = [\n credentialType,\n clientOrFamilyId,\n realm || Constants.EMPTY_STRING,\n ];\n\n return credentialId.join(Separators.CACHE_KEY_SEPARATOR).toLowerCase();\n }\n\n /**\n * Generate target key component as per schema: <target>\n */\n private static generateTargetForCacheKey(scopes?: string): string {\n return (scopes || Constants.EMPTY_STRING).toLowerCase();\n }\n\n /**\n * Generate requested claims key component as per schema: <requestedClaims>\n */\n private static generateClaimsHashForCacheKey(requestedClaimsHash?: string): string {\n return(requestedClaimsHash || Constants.EMPTY_STRING).toLowerCase();\n }\n\n /**\n * Generate scheme key componenet as per schema: <scheme>\n */\n private static generateSchemeForCacheKey(tokenType?: string): string {\n /*\n * PoP Tokens and SSH certs include scheme in cache key\n * Cast to lowercase to handle \"bearer\" from ADFS\n */\n return (tokenType && tokenType.toLowerCase() !== AuthenticationScheme.BEARER.toLowerCase()) ? tokenType.toLowerCase() : Constants.EMPTY_STRING;\n }\n}\n"],"names":[],"mappings":";;;;;AAAA;;;;AAQA;;;;;;;;;;;;;;;;;;;;;;;IAsBA;KAyLC;;;;IAxKG,4CAAiB,GAAjB;QACI,OAAO,gBAAgB,CAAC,4BAA4B,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;KAC9F;;;;IAKD,+CAAoB,GAApB;QACI,OAAO,gBAAgB,CAAC,+BAA+B,CACnD,IAAI,CAAC,cAAc,EACnB,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,KAAK,EACV,IAAI,CAAC,QAAQ,CAChB,CAAC;KACL;;;;IAKD,yCAAc,GAAd;QACI,OAAO,gBAAgB,CAAC,yBAAyB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;KAClE;;;;IAKD,gDAAqB,GAArB;QACI,OAAO,gBAAgB,CAAC,0BAA0B,CAC9C,IAAI,CAAC,aAAa,EAClB,IAAI,CAAC,WAAW,EAChB,IAAI,CAAC,cAAc,EACnB,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,KAAK,EACV,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,mBAAmB,CAC3B,CAAC;KACL;;;;IAKD,uCAAY,GAAZ;QACI,QAAQ,IAAI,CAAC,cAA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@@
|
|
|
1
|
-
/*! @azure/msal-common v6.
|
|
1
|
+
/*! @azure/msal-common v6.3.0 2022-05-02 */
|
|
2
2
|
'use strict';
|
|
3
3
|
import { __extends, __awaiter, __generator, __assign, __spreadArrays } from '../_virtual/_tslib.js';
|
|
4
4
|
import { BaseClient } from './BaseClient.js';
|
|
5
5
|
import { RequestParameterBuilder } from '../request/RequestParameterBuilder.js';
|
|
6
|
-
import {
|
|
6
|
+
import { Separators, AADServerParamKeys, AuthenticationScheme, GrantType, PromptValue } from '../utils/Constants.js';
|
|
7
7
|
import { ResponseHandler } from '../response/ResponseHandler.js';
|
|
8
8
|
import { StringUtils } from '../utils/StringUtils.js';
|
|
9
9
|
import { ClientAuthError } from '../error/ClientAuthError.js';
|
|
10
10
|
import { UrlString } from '../url/UrlString.js';
|
|
11
11
|
import { PopTokenGenerator } from '../crypto/PopTokenGenerator.js';
|
|
12
12
|
import { TimeUtils } from '../utils/TimeUtils.js';
|
|
13
|
-
import {
|
|
13
|
+
import { buildClientInfo, buildClientInfoFromHomeAccountId } from '../account/ClientInfo.js';
|
|
14
14
|
import { CcsCredentialType } from '../account/CcsCredential.js';
|
|
15
15
|
import { ClientConfigurationError } from '../error/ClientConfigurationError.js';
|
|
16
16
|
import { RequestValidator } from '../request/RequestValidator.js';
|
|
@@ -44,8 +44,12 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
44
44
|
return __awaiter(this, void 0, void 0, function () {
|
|
45
45
|
var queryString;
|
|
46
46
|
return __generator(this, function (_a) {
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
switch (_a.label) {
|
|
48
|
+
case 0: return [4 /*yield*/, this.createAuthCodeUrlQueryString(request)];
|
|
49
|
+
case 1:
|
|
50
|
+
queryString = _a.sent();
|
|
51
|
+
return [2 /*return*/, UrlString.appendQueryString(this.authority.authorizationEndpoint, queryString)];
|
|
52
|
+
}
|
|
49
53
|
});
|
|
50
54
|
});
|
|
51
55
|
};
|
|
@@ -201,6 +205,7 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
201
205
|
parameterBuilder.addAuthorizationCode(request.code);
|
|
202
206
|
// Add library metadata
|
|
203
207
|
parameterBuilder.addLibraryInfo(this.config.libraryInfo);
|
|
208
|
+
parameterBuilder.addApplicationTelemetry(this.config.telemetry.application);
|
|
204
209
|
parameterBuilder.addThrottling();
|
|
205
210
|
if (this.serverTelemetryManager) {
|
|
206
211
|
parameterBuilder.addServerTelemetry(this.serverTelemetryManager);
|
|
@@ -294,95 +299,116 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
294
299
|
* @param request
|
|
295
300
|
*/
|
|
296
301
|
AuthorizationCodeClient.prototype.createAuthCodeUrlQueryString = function (request) {
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
302
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
303
|
+
var parameterBuilder, requestScopes, correlationId, accountSid, clientInfo, clientInfo, popTokenGenerator, cnf, cnfHash;
|
|
304
|
+
return __generator(this, function (_a) {
|
|
305
|
+
switch (_a.label) {
|
|
306
|
+
case 0:
|
|
307
|
+
parameterBuilder = new RequestParameterBuilder();
|
|
308
|
+
parameterBuilder.addClientId(this.config.authOptions.clientId);
|
|
309
|
+
requestScopes = __spreadArrays(request.scopes || [], request.extraScopesToConsent || []);
|
|
310
|
+
parameterBuilder.addScopes(requestScopes);
|
|
311
|
+
// validate the redirectUri (to be a non null value)
|
|
312
|
+
parameterBuilder.addRedirectUri(request.redirectUri);
|
|
313
|
+
correlationId = request.correlationId || this.config.cryptoInterface.createNewGuid();
|
|
314
|
+
parameterBuilder.addCorrelationId(correlationId);
|
|
315
|
+
// add response_mode. If not passed in it defaults to query.
|
|
316
|
+
parameterBuilder.addResponseMode(request.responseMode);
|
|
317
|
+
// add response_type = code
|
|
318
|
+
parameterBuilder.addResponseTypeCode();
|
|
319
|
+
// add library info parameters
|
|
320
|
+
parameterBuilder.addLibraryInfo(this.config.libraryInfo);
|
|
321
|
+
parameterBuilder.addApplicationTelemetry(this.config.telemetry.application);
|
|
322
|
+
// add client_info=1
|
|
323
|
+
parameterBuilder.addClientInfo();
|
|
324
|
+
if (request.codeChallenge && request.codeChallengeMethod) {
|
|
325
|
+
parameterBuilder.addCodeChallengeParams(request.codeChallenge, request.codeChallengeMethod);
|
|
326
|
+
}
|
|
327
|
+
if (request.prompt) {
|
|
328
|
+
parameterBuilder.addPrompt(request.prompt);
|
|
329
|
+
}
|
|
330
|
+
if (request.domainHint) {
|
|
331
|
+
parameterBuilder.addDomainHint(request.domainHint);
|
|
332
|
+
}
|
|
333
|
+
// Add sid or loginHint with preference for sid -> loginHint -> username of AccountInfo object
|
|
334
|
+
if (request.prompt !== PromptValue.SELECT_ACCOUNT) {
|
|
335
|
+
// AAD will throw if prompt=select_account is passed with an account hint
|
|
336
|
+
if (request.sid && request.prompt === PromptValue.NONE) {
|
|
337
|
+
// SessionID is only used in silent calls
|
|
338
|
+
this.logger.verbose("createAuthCodeUrlQueryString: Prompt is none, adding sid from request");
|
|
339
|
+
parameterBuilder.addSid(request.sid);
|
|
340
|
+
}
|
|
341
|
+
else if (request.account) {
|
|
342
|
+
accountSid = this.extractAccountSid(request.account);
|
|
343
|
+
// If account and loginHint are provided, we will check account first for sid before adding loginHint
|
|
344
|
+
if (accountSid && request.prompt === PromptValue.NONE) {
|
|
345
|
+
// SessionId is only used in silent calls
|
|
346
|
+
this.logger.verbose("createAuthCodeUrlQueryString: Prompt is none, adding sid from account");
|
|
347
|
+
parameterBuilder.addSid(accountSid);
|
|
348
|
+
try {
|
|
349
|
+
clientInfo = buildClientInfoFromHomeAccountId(request.account.homeAccountId);
|
|
350
|
+
parameterBuilder.addCcsOid(clientInfo);
|
|
351
|
+
}
|
|
352
|
+
catch (e) {
|
|
353
|
+
this.logger.verbose("Could not parse home account ID for CCS Header: " + e);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
else if (request.loginHint) {
|
|
357
|
+
this.logger.verbose("createAuthCodeUrlQueryString: Adding login_hint from request");
|
|
358
|
+
parameterBuilder.addLoginHint(request.loginHint);
|
|
359
|
+
parameterBuilder.addCcsUpn(request.loginHint);
|
|
360
|
+
}
|
|
361
|
+
else if (request.account.username) {
|
|
362
|
+
// Fallback to account username if provided
|
|
363
|
+
this.logger.verbose("createAuthCodeUrlQueryString: Adding login_hint from account");
|
|
364
|
+
parameterBuilder.addLoginHint(request.account.username);
|
|
365
|
+
try {
|
|
366
|
+
clientInfo = buildClientInfoFromHomeAccountId(request.account.homeAccountId);
|
|
367
|
+
parameterBuilder.addCcsOid(clientInfo);
|
|
368
|
+
}
|
|
369
|
+
catch (e) {
|
|
370
|
+
this.logger.verbose("Could not parse home account ID for CCS Header: " + e);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
else if (request.loginHint) {
|
|
375
|
+
this.logger.verbose("createAuthCodeUrlQueryString: No account, adding login_hint from request");
|
|
376
|
+
parameterBuilder.addLoginHint(request.loginHint);
|
|
377
|
+
parameterBuilder.addCcsUpn(request.loginHint);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
else {
|
|
381
|
+
this.logger.verbose("createAuthCodeUrlQueryString: Prompt is select_account, ignoring account hints");
|
|
382
|
+
}
|
|
383
|
+
if (request.nonce) {
|
|
384
|
+
parameterBuilder.addNonce(request.nonce);
|
|
385
|
+
}
|
|
386
|
+
if (request.state) {
|
|
387
|
+
parameterBuilder.addState(request.state);
|
|
388
|
+
}
|
|
389
|
+
if (!StringUtils.isEmpty(request.claims) || this.config.authOptions.clientCapabilities && this.config.authOptions.clientCapabilities.length > 0) {
|
|
390
|
+
parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);
|
|
391
|
+
}
|
|
392
|
+
if (request.extraQueryParameters) {
|
|
393
|
+
parameterBuilder.addExtraQueryParameters(request.extraQueryParameters);
|
|
394
|
+
}
|
|
395
|
+
if (!request.nativeBroker) return [3 /*break*/, 3];
|
|
396
|
+
// signal ests that this is a WAM call
|
|
397
|
+
parameterBuilder.addNativeBroker();
|
|
398
|
+
if (!(request.authenticationScheme === AuthenticationScheme.POP)) return [3 /*break*/, 3];
|
|
399
|
+
popTokenGenerator = new PopTokenGenerator(this.cryptoUtils);
|
|
400
|
+
return [4 /*yield*/, popTokenGenerator.generateCnf(request)];
|
|
401
|
+
case 1:
|
|
402
|
+
cnf = _a.sent();
|
|
403
|
+
return [4 /*yield*/, popTokenGenerator.generateCnfHash(cnf)];
|
|
404
|
+
case 2:
|
|
405
|
+
cnfHash = _a.sent();
|
|
406
|
+
parameterBuilder.addPopToken(cnfHash);
|
|
407
|
+
_a.label = 3;
|
|
408
|
+
case 3: return [2 /*return*/, parameterBuilder.createQueryString()];
|
|
362
409
|
}
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
this.logger.verbose("createAuthCodeUrlQueryString: No account, adding login_hint from request");
|
|
366
|
-
parameterBuilder.addLoginHint(request.loginHint);
|
|
367
|
-
parameterBuilder.addCcsUpn(request.loginHint);
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
else {
|
|
371
|
-
this.logger.verbose("createAuthCodeUrlQueryString: Prompt is select_account, ignoring account hints");
|
|
372
|
-
}
|
|
373
|
-
if (request.nonce) {
|
|
374
|
-
parameterBuilder.addNonce(request.nonce);
|
|
375
|
-
}
|
|
376
|
-
if (request.state) {
|
|
377
|
-
parameterBuilder.addState(request.state);
|
|
378
|
-
}
|
|
379
|
-
if (!StringUtils.isEmpty(request.claims) || this.config.authOptions.clientCapabilities && this.config.authOptions.clientCapabilities.length > 0) {
|
|
380
|
-
parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);
|
|
381
|
-
}
|
|
382
|
-
if (request.extraQueryParameters) {
|
|
383
|
-
parameterBuilder.addExtraQueryParameters(request.extraQueryParameters);
|
|
384
|
-
}
|
|
385
|
-
return parameterBuilder.createQueryString();
|
|
410
|
+
});
|
|
411
|
+
});
|
|
386
412
|
};
|
|
387
413
|
/**
|
|
388
414
|
* This API validates the `EndSessionRequest` and creates a URL
|