@azure/msal-common 14.15.0 → 15.0.0-alpha.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/account/AccountInfo.mjs +1 -1
- package/dist/account/AuthToken.mjs +1 -1
- package/dist/account/CcsCredential.mjs +1 -1
- package/dist/account/ClientInfo.mjs +1 -1
- package/dist/account/TokenClaims.mjs +1 -1
- package/dist/authority/Authority.mjs +1 -1
- package/dist/authority/AuthorityFactory.mjs +1 -1
- package/dist/authority/AuthorityMetadata.mjs +1 -1
- package/dist/authority/AuthorityOptions.mjs +1 -1
- package/dist/authority/AuthorityType.mjs +1 -1
- package/dist/authority/CloudInstanceDiscoveryErrorResponse.mjs +1 -1
- package/dist/authority/CloudInstanceDiscoveryResponse.mjs +1 -1
- package/dist/authority/OpenIdConfigResponse.mjs +1 -1
- package/dist/authority/ProtocolMode.mjs +1 -1
- package/dist/authority/RegionDiscovery.mjs +1 -1
- package/dist/broker/nativeBroker/INativeBrokerPlugin.d.ts +1 -0
- package/dist/broker/nativeBroker/INativeBrokerPlugin.d.ts.map +1 -1
- package/dist/cache/CacheManager.d.ts +8 -37
- package/dist/cache/CacheManager.d.ts.map +1 -1
- package/dist/cache/CacheManager.mjs +10 -77
- package/dist/cache/CacheManager.mjs.map +1 -1
- package/dist/cache/entities/AccountEntity.mjs +1 -1
- package/dist/cache/interface/ICacheManager.d.ts +4 -4
- package/dist/cache/interface/ICacheManager.d.ts.map +1 -1
- package/dist/cache/persistence/TokenCacheContext.mjs +1 -1
- package/dist/cache/utils/CacheHelpers.mjs +1 -1
- package/dist/client/AuthorizationCodeClient.d.ts.map +1 -1
- package/dist/client/AuthorizationCodeClient.mjs +24 -13
- package/dist/client/AuthorizationCodeClient.mjs.map +1 -1
- package/dist/client/BaseClient.d.ts +10 -3
- package/dist/client/BaseClient.d.ts.map +1 -1
- package/dist/client/BaseClient.mjs +62 -10
- package/dist/client/BaseClient.mjs.map +1 -1
- package/dist/client/RefreshTokenClient.d.ts.map +1 -1
- package/dist/client/RefreshTokenClient.mjs +10 -4
- package/dist/client/RefreshTokenClient.mjs.map +1 -1
- package/dist/client/SilentFlowClient.mjs +1 -1
- package/dist/config/ClientConfiguration.d.ts +2 -0
- package/dist/config/ClientConfiguration.d.ts.map +1 -1
- package/dist/config/ClientConfiguration.mjs +1 -1
- package/dist/config/ClientConfiguration.mjs.map +1 -1
- package/dist/constants/AADServerParamKeys.d.ts +2 -0
- package/dist/constants/AADServerParamKeys.d.ts.map +1 -1
- package/dist/constants/AADServerParamKeys.mjs +5 -3
- package/dist/constants/AADServerParamKeys.mjs.map +1 -1
- package/dist/crypto/ICrypto.mjs +1 -1
- package/dist/crypto/JoseHeader.mjs +1 -1
- package/dist/crypto/PopTokenGenerator.mjs +1 -1
- package/dist/error/AuthError.mjs +1 -1
- package/dist/error/AuthErrorCodes.mjs +1 -1
- package/dist/error/CacheError.mjs +1 -1
- package/dist/error/CacheErrorCodes.mjs +1 -1
- package/dist/error/ClientAuthError.mjs +1 -1
- package/dist/error/ClientAuthErrorCodes.mjs +1 -1
- package/dist/error/ClientConfigurationError.mjs +1 -1
- package/dist/error/ClientConfigurationErrorCodes.mjs +1 -1
- package/dist/error/InteractionRequiredAuthError.mjs +1 -1
- package/dist/error/InteractionRequiredAuthErrorCodes.mjs +1 -1
- package/dist/error/JoseHeaderError.mjs +1 -1
- package/dist/error/JoseHeaderErrorCodes.mjs +1 -1
- package/dist/error/NetworkError.d.ts +19 -0
- package/dist/error/NetworkError.d.ts.map +1 -0
- package/dist/error/NetworkError.mjs +34 -0
- package/dist/error/NetworkError.mjs.map +1 -0
- package/dist/error/ServerError.mjs +1 -1
- package/dist/exports-common.d.ts +2 -1
- package/dist/exports-common.d.ts.map +1 -1
- package/dist/index-browser.mjs +2 -2
- package/dist/index-node.mjs +2 -2
- package/dist/index.mjs +2 -2
- package/dist/logger/Logger.mjs +1 -1
- package/dist/network/INetworkModule.d.ts +1 -1
- package/dist/network/INetworkModule.d.ts.map +1 -1
- package/dist/network/INetworkModule.mjs +1 -1
- package/dist/network/NetworkResponse.d.ts +6 -0
- package/dist/network/NetworkResponse.d.ts.map +1 -0
- package/dist/network/ThrottlingUtils.d.ts +1 -1
- package/dist/network/ThrottlingUtils.d.ts.map +1 -1
- package/dist/network/ThrottlingUtils.mjs +1 -1
- package/dist/packageMetadata.d.ts +1 -1
- package/dist/packageMetadata.d.ts.map +1 -1
- package/dist/packageMetadata.mjs +2 -2
- package/dist/request/AuthenticationHeaderParser.mjs +1 -1
- package/dist/request/BaseAuthRequest.d.ts +2 -0
- package/dist/request/BaseAuthRequest.d.ts.map +1 -1
- package/dist/request/RequestParameterBuilder.d.ts +8 -1
- package/dist/request/RequestParameterBuilder.d.ts.map +1 -1
- package/dist/request/RequestParameterBuilder.mjs +26 -3
- package/dist/request/RequestParameterBuilder.mjs.map +1 -1
- package/dist/request/RequestValidator.mjs +1 -1
- package/dist/request/ScopeSet.mjs +1 -1
- package/dist/response/ResponseHandler.mjs +3 -3
- package/dist/response/ResponseHandler.mjs.map +1 -1
- package/dist/telemetry/performance/PerformanceClient.d.ts.map +1 -1
- package/dist/telemetry/performance/PerformanceClient.mjs +29 -10
- package/dist/telemetry/performance/PerformanceClient.mjs.map +1 -1
- package/dist/telemetry/performance/PerformanceEvent.d.ts +9 -0
- package/dist/telemetry/performance/PerformanceEvent.d.ts.map +1 -1
- package/dist/telemetry/performance/PerformanceEvent.mjs +6 -1
- package/dist/telemetry/performance/PerformanceEvent.mjs.map +1 -1
- package/dist/telemetry/performance/StubPerformanceClient.mjs +1 -1
- package/dist/telemetry/server/ServerTelemetryManager.mjs +1 -1
- package/dist/url/UrlString.mjs +1 -1
- package/dist/utils/ClientAssertionUtils.mjs +1 -1
- package/dist/utils/Constants.d.ts +1 -6
- package/dist/utils/Constants.d.ts.map +1 -1
- package/dist/utils/Constants.mjs +2 -7
- package/dist/utils/Constants.mjs.map +1 -1
- package/dist/utils/FunctionWrappers.mjs +1 -1
- package/dist/utils/ProtocolUtils.mjs +1 -1
- package/dist/utils/StringUtils.mjs +1 -1
- package/dist/utils/TimeUtils.mjs +1 -1
- package/dist/utils/UrlUtils.mjs +1 -1
- package/lib/index-browser.cjs +33 -13
- package/lib/index-browser.cjs.map +1 -1
- package/lib/{index-node-aee3f7b6.js → index-node-DDJMpU-A.js} +278 -260
- package/lib/index-node-DDJMpU-A.js.map +1 -0
- package/lib/index-node.cjs +5 -4
- package/lib/index-node.cjs.map +1 -1
- package/lib/index.cjs +5 -4
- package/lib/index.cjs.map +1 -1
- package/lib/types/broker/nativeBroker/INativeBrokerPlugin.d.ts +1 -0
- package/lib/types/broker/nativeBroker/INativeBrokerPlugin.d.ts.map +1 -1
- package/lib/types/cache/CacheManager.d.ts +8 -37
- package/lib/types/cache/CacheManager.d.ts.map +1 -1
- package/lib/types/cache/interface/ICacheManager.d.ts +4 -4
- package/lib/types/cache/interface/ICacheManager.d.ts.map +1 -1
- package/lib/types/client/AuthorizationCodeClient.d.ts.map +1 -1
- package/lib/types/client/BaseClient.d.ts +10 -3
- package/lib/types/client/BaseClient.d.ts.map +1 -1
- package/lib/types/client/RefreshTokenClient.d.ts.map +1 -1
- package/lib/types/config/ClientConfiguration.d.ts +2 -0
- package/lib/types/config/ClientConfiguration.d.ts.map +1 -1
- package/lib/types/constants/AADServerParamKeys.d.ts +2 -0
- package/lib/types/constants/AADServerParamKeys.d.ts.map +1 -1
- package/lib/types/error/NetworkError.d.ts +19 -0
- package/lib/types/error/NetworkError.d.ts.map +1 -0
- package/lib/types/exports-common.d.ts +2 -1
- package/lib/types/exports-common.d.ts.map +1 -1
- package/lib/types/network/INetworkModule.d.ts +1 -1
- package/lib/types/network/INetworkModule.d.ts.map +1 -1
- package/lib/types/network/NetworkResponse.d.ts +6 -0
- package/lib/types/network/NetworkResponse.d.ts.map +1 -0
- package/lib/types/network/ThrottlingUtils.d.ts +1 -1
- package/lib/types/network/ThrottlingUtils.d.ts.map +1 -1
- package/lib/types/packageMetadata.d.ts +1 -1
- package/lib/types/packageMetadata.d.ts.map +1 -1
- package/lib/types/request/BaseAuthRequest.d.ts +2 -0
- package/lib/types/request/BaseAuthRequest.d.ts.map +1 -1
- package/lib/types/request/RequestParameterBuilder.d.ts +8 -1
- package/lib/types/request/RequestParameterBuilder.d.ts.map +1 -1
- package/lib/types/telemetry/performance/PerformanceClient.d.ts.map +1 -1
- package/lib/types/telemetry/performance/PerformanceEvent.d.ts +9 -0
- package/lib/types/telemetry/performance/PerformanceEvent.d.ts.map +1 -1
- package/lib/types/utils/Constants.d.ts +1 -6
- package/lib/types/utils/Constants.d.ts.map +1 -1
- package/package.json +2 -4
- package/src/authority/RegionDiscovery.ts +1 -1
- package/src/cache/CacheManager.ts +16 -130
- package/src/cache/interface/ICacheManager.ts +4 -4
- package/src/client/AuthorizationCodeClient.ts +37 -16
- package/src/client/BaseClient.ts +104 -22
- package/src/client/RefreshTokenClient.ts +14 -5
- package/src/config/ClientConfiguration.ts +2 -0
- package/src/constants/AADServerParamKeys.ts +2 -0
- package/src/error/NetworkError.ts +44 -0
- package/src/exports-common.ts +2 -5
- package/src/network/INetworkModule.ts +1 -1
- package/src/network/NetworkResponse.ts +10 -0
- package/src/network/ThrottlingUtils.ts +1 -1
- package/src/packageMetadata.ts +1 -1
- package/src/request/BaseAuthRequest.ts +2 -0
- package/src/request/RequestParameterBuilder.ts +51 -1
- package/src/response/ResponseHandler.ts +2 -2
- package/src/telemetry/performance/PerformanceClient.ts +42 -12
- package/src/telemetry/performance/PerformanceEvent.ts +15 -0
- package/src/utils/Constants.ts +1 -6
- package/dist/network/NetworkManager.d.ts +0 -34
- package/dist/network/NetworkManager.d.ts.map +0 -1
- package/dist/network/NetworkManager.mjs +0 -44
- package/dist/network/NetworkManager.mjs.map +0 -1
- package/lib/index-node-aee3f7b6.js.map +0 -1
- package/lib/types/network/NetworkManager.d.ts +0 -34
- package/lib/types/network/NetworkManager.d.ts.map +0 -1
- package/src/network/NetworkManager.ts +0 -76
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Constants.d.ts","sourceRoot":"","sources":["../../../src/utils/Constants.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2DrB,CAAC;AAEF,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;CAmBb,CAAC;AACX,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,OAAO,UAAU,CAAC,CAAC;AAEtE,eAAO,MAAM,mBAAmB,UAI/B,CAAC;AAEF,eAAO,MAAM,WAAW,UAAkD,CAAC;AAE3E;;GAEG;AACH,eAAO,MAAM,WAAW
|
|
1
|
+
{"version":3,"file":"Constants.d.ts","sourceRoot":"","sources":["../../../src/utils/Constants.ts"],"names":[],"mappings":"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"}
|
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"type": "git",
|
|
11
11
|
"url": "https://github.com/AzureAD/microsoft-authentication-library-for-js.git"
|
|
12
12
|
},
|
|
13
|
-
"version": "
|
|
13
|
+
"version": "15.0.0-alpha.0",
|
|
14
14
|
"description": "Microsoft Authentication Library for js",
|
|
15
15
|
"keywords": [
|
|
16
16
|
"implicit",
|
|
@@ -107,17 +107,15 @@
|
|
|
107
107
|
"@types/jest": "^29.5.0",
|
|
108
108
|
"@types/lodash": "^4.14.182",
|
|
109
109
|
"@types/node": "^20.3.1",
|
|
110
|
-
"@types/sinon": "^7.5.0",
|
|
111
110
|
"eslint-config-msal": "file:../../shared-configs/eslint-config-msal",
|
|
112
111
|
"jest": "^29.5.0",
|
|
113
112
|
"lodash": "^4.17.21",
|
|
114
113
|
"msal-test-utils": "file:../../shared-test-utils",
|
|
115
114
|
"prettier": "2.8.7",
|
|
116
115
|
"rimraf": "^3.0.2",
|
|
117
|
-
"rollup": "^
|
|
116
|
+
"rollup": "^4.22.4",
|
|
118
117
|
"rollup-msal": "file:../../shared-configs/rollup-msal",
|
|
119
118
|
"shx": "^0.3.2",
|
|
120
|
-
"sinon": "^7.5.0",
|
|
121
119
|
"ts-jest": "^29.1.0",
|
|
122
120
|
"ts-jest-resolver": "^2.0.1",
|
|
123
121
|
"ts-node": "^10.9.1",
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { INetworkModule } from "../network/INetworkModule.js";
|
|
7
|
-
import { NetworkResponse } from "../network/
|
|
7
|
+
import { NetworkResponse } from "../network/NetworkResponse.js";
|
|
8
8
|
import { IMDSBadResponse } from "../response/IMDSBadResponse.js";
|
|
9
9
|
import {
|
|
10
10
|
Constants,
|
|
@@ -36,7 +36,6 @@ import {
|
|
|
36
36
|
import {
|
|
37
37
|
AccountInfo,
|
|
38
38
|
TenantProfile,
|
|
39
|
-
tenantIdMatchesHomeTenant,
|
|
40
39
|
updateAccountTenantProfileData,
|
|
41
40
|
} from "../account/AccountInfo.js";
|
|
42
41
|
import { AppMetadataEntity } from "./entities/AppMetadataEntity.js";
|
|
@@ -87,21 +86,11 @@ export abstract class CacheManager implements ICacheManager {
|
|
|
87
86
|
logger?: Logger
|
|
88
87
|
): AccountEntity | null;
|
|
89
88
|
|
|
90
|
-
/**
|
|
91
|
-
* Returns deserialized account if found in the cache, otherwiser returns null
|
|
92
|
-
*/
|
|
93
|
-
abstract getCachedAccountEntity(accountKey: string): AccountEntity | null;
|
|
94
|
-
|
|
95
89
|
/**
|
|
96
90
|
* set account entity in the platform cache
|
|
97
91
|
* @param account
|
|
98
92
|
*/
|
|
99
|
-
abstract setAccount(account: AccountEntity): void
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* remove account entity from the platform cache if it's outdated
|
|
103
|
-
*/
|
|
104
|
-
abstract removeOutdatedAccount(accountKey: string): void;
|
|
93
|
+
abstract setAccount(account: AccountEntity): Promise<void>;
|
|
105
94
|
|
|
106
95
|
/**
|
|
107
96
|
* fetch the idToken entity from the platform cache
|
|
@@ -113,7 +102,7 @@ export abstract class CacheManager implements ICacheManager {
|
|
|
113
102
|
* set idToken entity to the platform cache
|
|
114
103
|
* @param idToken
|
|
115
104
|
*/
|
|
116
|
-
abstract setIdTokenCredential(idToken: IdTokenEntity): void
|
|
105
|
+
abstract setIdTokenCredential(idToken: IdTokenEntity): Promise<void>;
|
|
117
106
|
|
|
118
107
|
/**
|
|
119
108
|
* fetch the idToken entity from the platform cache
|
|
@@ -127,7 +116,9 @@ export abstract class CacheManager implements ICacheManager {
|
|
|
127
116
|
* set idToken entity to the platform cache
|
|
128
117
|
* @param accessToken
|
|
129
118
|
*/
|
|
130
|
-
abstract setAccessTokenCredential(
|
|
119
|
+
abstract setAccessTokenCredential(
|
|
120
|
+
accessToken: AccessTokenEntity
|
|
121
|
+
): Promise<void>;
|
|
131
122
|
|
|
132
123
|
/**
|
|
133
124
|
* fetch the idToken entity from the platform cache
|
|
@@ -141,7 +132,9 @@ export abstract class CacheManager implements ICacheManager {
|
|
|
141
132
|
* set idToken entity to the platform cache
|
|
142
133
|
* @param refreshToken
|
|
143
134
|
*/
|
|
144
|
-
abstract setRefreshTokenCredential(
|
|
135
|
+
abstract setRefreshTokenCredential(
|
|
136
|
+
refreshToken: RefreshTokenEntity
|
|
137
|
+
): Promise<void>;
|
|
145
138
|
|
|
146
139
|
/**
|
|
147
140
|
* fetch appMetadata entity from the platform cache
|
|
@@ -233,19 +226,6 @@ export abstract class CacheManager implements ICacheManager {
|
|
|
233
226
|
*/
|
|
234
227
|
abstract getTokenKeys(): TokenKeys;
|
|
235
228
|
|
|
236
|
-
/**
|
|
237
|
-
* Function which clears cache.
|
|
238
|
-
*/
|
|
239
|
-
abstract clear(): Promise<void>;
|
|
240
|
-
|
|
241
|
-
/**
|
|
242
|
-
* Function which updates an outdated credential cache key
|
|
243
|
-
*/
|
|
244
|
-
abstract updateCredentialCacheKey(
|
|
245
|
-
currentCacheKey: string,
|
|
246
|
-
credential: ValidCredentialType
|
|
247
|
-
): string;
|
|
248
|
-
|
|
249
229
|
/**
|
|
250
230
|
* Returns all the accounts in the cache that match the optional filter. If no filter is provided, all accounts are returned.
|
|
251
231
|
* @param accountFilter - (Optional) filter to narrow down the accounts returned
|
|
@@ -509,11 +489,11 @@ export abstract class CacheManager implements ICacheManager {
|
|
|
509
489
|
|
|
510
490
|
try {
|
|
511
491
|
if (!!cacheRecord.account) {
|
|
512
|
-
this.setAccount(cacheRecord.account);
|
|
492
|
+
await this.setAccount(cacheRecord.account);
|
|
513
493
|
}
|
|
514
494
|
|
|
515
495
|
if (!!cacheRecord.idToken && storeInCache?.idToken !== false) {
|
|
516
|
-
this.setIdTokenCredential(cacheRecord.idToken);
|
|
496
|
+
await this.setIdTokenCredential(cacheRecord.idToken);
|
|
517
497
|
}
|
|
518
498
|
|
|
519
499
|
if (
|
|
@@ -527,7 +507,7 @@ export abstract class CacheManager implements ICacheManager {
|
|
|
527
507
|
!!cacheRecord.refreshToken &&
|
|
528
508
|
storeInCache?.refreshToken !== false
|
|
529
509
|
) {
|
|
530
|
-
this.setRefreshTokenCredential(cacheRecord.refreshToken);
|
|
510
|
+
await this.setRefreshTokenCredential(cacheRecord.refreshToken);
|
|
531
511
|
}
|
|
532
512
|
|
|
533
513
|
if (!!cacheRecord.appMetadata) {
|
|
@@ -607,7 +587,7 @@ export abstract class CacheManager implements ICacheManager {
|
|
|
607
587
|
}
|
|
608
588
|
});
|
|
609
589
|
await Promise.all(removedAccessTokens);
|
|
610
|
-
this.setAccessTokenCredential(credential);
|
|
590
|
+
await this.setAccessTokenCredential(credential);
|
|
611
591
|
}
|
|
612
592
|
|
|
613
593
|
/**
|
|
@@ -1011,88 +991,6 @@ export abstract class CacheManager implements ICacheManager {
|
|
|
1011
991
|
await Promise.all(removedCredentials);
|
|
1012
992
|
}
|
|
1013
993
|
|
|
1014
|
-
/**
|
|
1015
|
-
* Migrates a single-tenant account and all it's associated alternate cross-tenant account objects in the
|
|
1016
|
-
* cache into a condensed multi-tenant account object with tenant profiles.
|
|
1017
|
-
* @param accountKey
|
|
1018
|
-
* @param accountEntity
|
|
1019
|
-
* @param logger
|
|
1020
|
-
* @returns
|
|
1021
|
-
*/
|
|
1022
|
-
protected updateOutdatedCachedAccount(
|
|
1023
|
-
accountKey: string,
|
|
1024
|
-
accountEntity: AccountEntity | null,
|
|
1025
|
-
logger?: Logger
|
|
1026
|
-
): AccountEntity | null {
|
|
1027
|
-
// Only update if account entity is defined and has no tenantProfiles object (is outdated)
|
|
1028
|
-
if (accountEntity && accountEntity.isSingleTenant()) {
|
|
1029
|
-
this.commonLogger?.verbose(
|
|
1030
|
-
"updateOutdatedCachedAccount: Found a single-tenant (outdated) account entity in the cache, migrating to multi-tenant account entity"
|
|
1031
|
-
);
|
|
1032
|
-
|
|
1033
|
-
// Get keys of all accounts belonging to user
|
|
1034
|
-
const matchingAccountKeys = this.getAccountKeys().filter(
|
|
1035
|
-
(key: string) => {
|
|
1036
|
-
return key.startsWith(accountEntity.homeAccountId);
|
|
1037
|
-
}
|
|
1038
|
-
);
|
|
1039
|
-
|
|
1040
|
-
// Get all account entities belonging to user
|
|
1041
|
-
const accountsToMerge: AccountEntity[] = [];
|
|
1042
|
-
matchingAccountKeys.forEach((key: string) => {
|
|
1043
|
-
const account = this.getCachedAccountEntity(key);
|
|
1044
|
-
if (account) {
|
|
1045
|
-
accountsToMerge.push(account);
|
|
1046
|
-
}
|
|
1047
|
-
});
|
|
1048
|
-
|
|
1049
|
-
// Set base account to home account if available, any account if not
|
|
1050
|
-
const baseAccount =
|
|
1051
|
-
accountsToMerge.find((account) => {
|
|
1052
|
-
return tenantIdMatchesHomeTenant(
|
|
1053
|
-
account.realm,
|
|
1054
|
-
account.homeAccountId
|
|
1055
|
-
);
|
|
1056
|
-
}) || accountsToMerge[0];
|
|
1057
|
-
|
|
1058
|
-
// Populate tenant profiles built from each account entity belonging to the user
|
|
1059
|
-
baseAccount.tenantProfiles = accountsToMerge.map(
|
|
1060
|
-
(account: AccountEntity) => {
|
|
1061
|
-
return {
|
|
1062
|
-
tenantId: account.realm,
|
|
1063
|
-
localAccountId: account.localAccountId,
|
|
1064
|
-
name: account.name,
|
|
1065
|
-
isHomeTenant: tenantIdMatchesHomeTenant(
|
|
1066
|
-
account.realm,
|
|
1067
|
-
account.homeAccountId
|
|
1068
|
-
),
|
|
1069
|
-
};
|
|
1070
|
-
}
|
|
1071
|
-
);
|
|
1072
|
-
|
|
1073
|
-
const updatedAccount = CacheManager.toObject(new AccountEntity(), {
|
|
1074
|
-
...baseAccount,
|
|
1075
|
-
});
|
|
1076
|
-
|
|
1077
|
-
const newAccountKey = updatedAccount.generateAccountKey();
|
|
1078
|
-
|
|
1079
|
-
// Clear cache of legacy account objects that have been collpsed into tenant profiles
|
|
1080
|
-
matchingAccountKeys.forEach((key: string) => {
|
|
1081
|
-
if (key !== newAccountKey) {
|
|
1082
|
-
this.removeOutdatedAccount(accountKey);
|
|
1083
|
-
}
|
|
1084
|
-
});
|
|
1085
|
-
|
|
1086
|
-
// Cache updated account object
|
|
1087
|
-
this.setAccount(updatedAccount);
|
|
1088
|
-
logger?.verbose("Updated an outdated account entity in the cache");
|
|
1089
|
-
return updatedAccount;
|
|
1090
|
-
}
|
|
1091
|
-
|
|
1092
|
-
// No update is necessary
|
|
1093
|
-
return accountEntity;
|
|
1094
|
-
}
|
|
1095
|
-
|
|
1096
994
|
/**
|
|
1097
995
|
* returns a boolean if the given credential is removed
|
|
1098
996
|
* @param credential
|
|
@@ -1939,28 +1837,25 @@ export abstract class CacheManager implements ICacheManager {
|
|
|
1939
1837
|
|
|
1940
1838
|
/** @internal */
|
|
1941
1839
|
export class DefaultStorageClass extends CacheManager {
|
|
1942
|
-
setAccount(): void {
|
|
1840
|
+
async setAccount(): Promise<void> {
|
|
1943
1841
|
throw createClientAuthError(ClientAuthErrorCodes.methodNotImplemented);
|
|
1944
1842
|
}
|
|
1945
1843
|
getAccount(): AccountEntity {
|
|
1946
1844
|
throw createClientAuthError(ClientAuthErrorCodes.methodNotImplemented);
|
|
1947
1845
|
}
|
|
1948
|
-
|
|
1949
|
-
throw createClientAuthError(ClientAuthErrorCodes.methodNotImplemented);
|
|
1950
|
-
}
|
|
1951
|
-
setIdTokenCredential(): void {
|
|
1846
|
+
async setIdTokenCredential(): Promise<void> {
|
|
1952
1847
|
throw createClientAuthError(ClientAuthErrorCodes.methodNotImplemented);
|
|
1953
1848
|
}
|
|
1954
1849
|
getIdTokenCredential(): IdTokenEntity {
|
|
1955
1850
|
throw createClientAuthError(ClientAuthErrorCodes.methodNotImplemented);
|
|
1956
1851
|
}
|
|
1957
|
-
setAccessTokenCredential(): void {
|
|
1852
|
+
async setAccessTokenCredential(): Promise<void> {
|
|
1958
1853
|
throw createClientAuthError(ClientAuthErrorCodes.methodNotImplemented);
|
|
1959
1854
|
}
|
|
1960
1855
|
getAccessTokenCredential(): AccessTokenEntity {
|
|
1961
1856
|
throw createClientAuthError(ClientAuthErrorCodes.methodNotImplemented);
|
|
1962
1857
|
}
|
|
1963
|
-
setRefreshTokenCredential(): void {
|
|
1858
|
+
async setRefreshTokenCredential(): Promise<void> {
|
|
1964
1859
|
throw createClientAuthError(ClientAuthErrorCodes.methodNotImplemented);
|
|
1965
1860
|
}
|
|
1966
1861
|
getRefreshTokenCredential(): RefreshTokenEntity {
|
|
@@ -2005,13 +1900,4 @@ export class DefaultStorageClass extends CacheManager {
|
|
|
2005
1900
|
getTokenKeys(): TokenKeys {
|
|
2006
1901
|
throw createClientAuthError(ClientAuthErrorCodes.methodNotImplemented);
|
|
2007
1902
|
}
|
|
2008
|
-
async clear(): Promise<void> {
|
|
2009
|
-
throw createClientAuthError(ClientAuthErrorCodes.methodNotImplemented);
|
|
2010
|
-
}
|
|
2011
|
-
updateCredentialCacheKey(): string {
|
|
2012
|
-
throw createClientAuthError(ClientAuthErrorCodes.methodNotImplemented);
|
|
2013
|
-
}
|
|
2014
|
-
removeOutdatedAccount(): void {
|
|
2015
|
-
throw createClientAuthError(ClientAuthErrorCodes.methodNotImplemented);
|
|
2016
|
-
}
|
|
2017
1903
|
}
|
|
@@ -27,7 +27,7 @@ export interface ICacheManager {
|
|
|
27
27
|
* set account entity in the platform cache
|
|
28
28
|
* @param account
|
|
29
29
|
*/
|
|
30
|
-
setAccount(account: AccountEntity): void
|
|
30
|
+
setAccount(account: AccountEntity): Promise<void>;
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* Returns true if the given key matches our account key schema. Also matches homeAccountId and/or tenantId if provided
|
|
@@ -52,7 +52,7 @@ export interface ICacheManager {
|
|
|
52
52
|
* set idToken entity to the platform cache
|
|
53
53
|
* @param idToken
|
|
54
54
|
*/
|
|
55
|
-
setIdTokenCredential(idToken: IdTokenEntity): void
|
|
55
|
+
setIdTokenCredential(idToken: IdTokenEntity): Promise<void>;
|
|
56
56
|
|
|
57
57
|
/**
|
|
58
58
|
* fetch the idToken entity from the platform cache
|
|
@@ -64,7 +64,7 @@ export interface ICacheManager {
|
|
|
64
64
|
* set idToken entity to the platform cache
|
|
65
65
|
* @param accessToken
|
|
66
66
|
*/
|
|
67
|
-
setAccessTokenCredential(accessToken: AccessTokenEntity): void
|
|
67
|
+
setAccessTokenCredential(accessToken: AccessTokenEntity): Promise<void>;
|
|
68
68
|
|
|
69
69
|
/**
|
|
70
70
|
* fetch the idToken entity from the platform cache
|
|
@@ -78,7 +78,7 @@ export interface ICacheManager {
|
|
|
78
78
|
* set idToken entity to the platform cache
|
|
79
79
|
* @param refreshToken
|
|
80
80
|
*/
|
|
81
|
-
setRefreshTokenCredential(refreshToken: RefreshTokenEntity): void
|
|
81
|
+
setRefreshTokenCredential(refreshToken: RefreshTokenEntity): Promise<void>;
|
|
82
82
|
|
|
83
83
|
/**
|
|
84
84
|
* fetch appMetadata entity from the platform cache
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
isOidcProtocolMode,
|
|
22
22
|
} from "../config/ClientConfiguration.js";
|
|
23
23
|
import { ServerAuthorizationTokenResponse } from "../response/ServerAuthorizationTokenResponse.js";
|
|
24
|
-
import { NetworkResponse } from "../network/
|
|
24
|
+
import { NetworkResponse } from "../network/NetworkResponse.js";
|
|
25
25
|
import { ResponseHandler } from "../response/ResponseHandler.js";
|
|
26
26
|
import { AuthenticationResult } from "../response/AuthenticationResult.js";
|
|
27
27
|
import { StringUtils } from "../utils/StringUtils.js";
|
|
@@ -314,10 +314,14 @@ export class AuthorizationCodeClient extends BaseClient {
|
|
|
314
314
|
request.correlationId
|
|
315
315
|
);
|
|
316
316
|
|
|
317
|
-
const parameterBuilder = new RequestParameterBuilder(
|
|
317
|
+
const parameterBuilder = new RequestParameterBuilder(
|
|
318
|
+
request.correlationId,
|
|
319
|
+
this.performanceClient
|
|
320
|
+
);
|
|
318
321
|
|
|
319
322
|
parameterBuilder.addClientId(
|
|
320
|
-
request.
|
|
323
|
+
request.embeddedClientId ||
|
|
324
|
+
request.tokenBodyParameters?.[AADServerParamKeys.CLIENT_ID] ||
|
|
321
325
|
this.config.authOptions.clientId
|
|
322
326
|
);
|
|
323
327
|
|
|
@@ -416,11 +420,6 @@ export class AuthorizationCodeClient extends BaseClient {
|
|
|
416
420
|
}
|
|
417
421
|
}
|
|
418
422
|
|
|
419
|
-
const correlationId =
|
|
420
|
-
request.correlationId ||
|
|
421
|
-
this.config.cryptoInterface.createNewGuid();
|
|
422
|
-
parameterBuilder.addCorrelationId(correlationId);
|
|
423
|
-
|
|
424
423
|
if (
|
|
425
424
|
!StringUtils.isEmptyObj(request.claims) ||
|
|
426
425
|
(this.config.authOptions.clientCapabilities &&
|
|
@@ -474,6 +473,13 @@ export class AuthorizationCodeClient extends BaseClient {
|
|
|
474
473
|
}
|
|
475
474
|
}
|
|
476
475
|
|
|
476
|
+
if (request.embeddedClientId) {
|
|
477
|
+
parameterBuilder.addBrokerParameters({
|
|
478
|
+
brokerClientId: this.config.authOptions.clientId,
|
|
479
|
+
brokerRedirectUri: this.config.authOptions.redirectUri,
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
|
|
477
483
|
if (request.tokenBodyParameters) {
|
|
478
484
|
parameterBuilder.addExtraQueryParameters(
|
|
479
485
|
request.tokenBodyParameters
|
|
@@ -503,15 +509,24 @@ export class AuthorizationCodeClient extends BaseClient {
|
|
|
503
509
|
private async createAuthCodeUrlQueryString(
|
|
504
510
|
request: CommonAuthorizationUrlRequest
|
|
505
511
|
): Promise<string> {
|
|
512
|
+
// generate the correlationId if not set by the user and add
|
|
513
|
+
const correlationId =
|
|
514
|
+
request.correlationId ||
|
|
515
|
+
this.config.cryptoInterface.createNewGuid();
|
|
516
|
+
|
|
506
517
|
this.performanceClient?.addQueueMeasurement(
|
|
507
518
|
PerformanceEvents.AuthClientCreateQueryString,
|
|
508
|
-
|
|
519
|
+
correlationId
|
|
509
520
|
);
|
|
510
521
|
|
|
511
|
-
const parameterBuilder = new RequestParameterBuilder(
|
|
522
|
+
const parameterBuilder = new RequestParameterBuilder(
|
|
523
|
+
correlationId,
|
|
524
|
+
this.performanceClient
|
|
525
|
+
);
|
|
512
526
|
|
|
513
527
|
parameterBuilder.addClientId(
|
|
514
|
-
request.
|
|
528
|
+
request.embeddedClientId ||
|
|
529
|
+
request.extraQueryParameters?.[AADServerParamKeys.CLIENT_ID] ||
|
|
515
530
|
this.config.authOptions.clientId
|
|
516
531
|
);
|
|
517
532
|
|
|
@@ -524,10 +539,6 @@ export class AuthorizationCodeClient extends BaseClient {
|
|
|
524
539
|
// validate the redirectUri (to be a non null value)
|
|
525
540
|
parameterBuilder.addRedirectUri(request.redirectUri);
|
|
526
541
|
|
|
527
|
-
// generate the correlationId if not set by the user and add
|
|
528
|
-
const correlationId =
|
|
529
|
-
request.correlationId ||
|
|
530
|
-
this.config.cryptoInterface.createNewGuid();
|
|
531
542
|
parameterBuilder.addCorrelationId(correlationId);
|
|
532
543
|
|
|
533
544
|
// add response_mode. If not passed in it defaults to query.
|
|
@@ -674,6 +685,13 @@ export class AuthorizationCodeClient extends BaseClient {
|
|
|
674
685
|
);
|
|
675
686
|
}
|
|
676
687
|
|
|
688
|
+
if (request.embeddedClientId) {
|
|
689
|
+
parameterBuilder.addBrokerParameters({
|
|
690
|
+
brokerClientId: this.config.authOptions.clientId,
|
|
691
|
+
brokerRedirectUri: this.config.authOptions.redirectUri,
|
|
692
|
+
});
|
|
693
|
+
}
|
|
694
|
+
|
|
677
695
|
this.addExtraQueryParams(request, parameterBuilder);
|
|
678
696
|
|
|
679
697
|
if (request.nativeBroker) {
|
|
@@ -714,7 +732,10 @@ export class AuthorizationCodeClient extends BaseClient {
|
|
|
714
732
|
private createLogoutUrlQueryString(
|
|
715
733
|
request: CommonEndSessionRequest
|
|
716
734
|
): string {
|
|
717
|
-
const parameterBuilder = new RequestParameterBuilder(
|
|
735
|
+
const parameterBuilder = new RequestParameterBuilder(
|
|
736
|
+
request.correlationId,
|
|
737
|
+
this.performanceClient
|
|
738
|
+
);
|
|
718
739
|
|
|
719
740
|
if (request.postLogoutRedirectUri) {
|
|
720
741
|
parameterBuilder.addPostLogoutRedirectUri(
|
package/src/client/BaseClient.ts
CHANGED
|
@@ -8,8 +8,11 @@ import {
|
|
|
8
8
|
buildClientConfiguration,
|
|
9
9
|
CommonClientConfiguration,
|
|
10
10
|
} from "../config/ClientConfiguration.js";
|
|
11
|
-
import {
|
|
12
|
-
|
|
11
|
+
import {
|
|
12
|
+
INetworkModule,
|
|
13
|
+
NetworkRequestOptions,
|
|
14
|
+
} from "../network/INetworkModule.js";
|
|
15
|
+
import { NetworkResponse } from "../network/NetworkResponse.js";
|
|
13
16
|
import { ICrypto } from "../crypto/ICrypto.js";
|
|
14
17
|
import { Authority } from "../authority/Authority.js";
|
|
15
18
|
import { Logger } from "../logger/Logger.js";
|
|
@@ -26,6 +29,14 @@ import { RequestParameterBuilder } from "../request/RequestParameterBuilder.js";
|
|
|
26
29
|
import { BaseAuthRequest } from "../request/BaseAuthRequest.js";
|
|
27
30
|
import { createDiscoveredInstance } from "../authority/AuthorityFactory.js";
|
|
28
31
|
import { PerformanceEvents } from "../telemetry/performance/PerformanceEvent.js";
|
|
32
|
+
import { ThrottlingUtils } from "../network/ThrottlingUtils.js";
|
|
33
|
+
import { AuthError } from "../error/AuthError.js";
|
|
34
|
+
import {
|
|
35
|
+
ClientAuthErrorCodes,
|
|
36
|
+
createClientAuthError,
|
|
37
|
+
} from "../error/ClientAuthError.js";
|
|
38
|
+
import { NetworkError } from "../error/NetworkError.js";
|
|
39
|
+
import { invokeAsync } from "../utils/FunctionWrappers.js";
|
|
29
40
|
|
|
30
41
|
/**
|
|
31
42
|
* Base application class which will construct requests to send to and handle responses from the Microsoft STS using the authorization code flow.
|
|
@@ -50,9 +61,6 @@ export abstract class BaseClient {
|
|
|
50
61
|
// Server Telemetry Manager
|
|
51
62
|
protected serverTelemetryManager: ServerTelemetryManager | null;
|
|
52
63
|
|
|
53
|
-
// Network Manager
|
|
54
|
-
protected networkManager: NetworkManager;
|
|
55
|
-
|
|
56
64
|
// Default authority object
|
|
57
65
|
public authority: Authority;
|
|
58
66
|
|
|
@@ -78,12 +86,6 @@ export abstract class BaseClient {
|
|
|
78
86
|
// Set the network interface
|
|
79
87
|
this.networkClient = this.config.networkInterface;
|
|
80
88
|
|
|
81
|
-
// Set the NetworkManager
|
|
82
|
-
this.networkManager = new NetworkManager(
|
|
83
|
-
this.networkClient,
|
|
84
|
-
this.cacheManager
|
|
85
|
-
);
|
|
86
|
-
|
|
87
89
|
// Set TelemetryManager
|
|
88
90
|
this.serverTelemetryManager = this.config.serverTelemetryManager;
|
|
89
91
|
|
|
@@ -152,19 +154,12 @@ export abstract class BaseClient {
|
|
|
152
154
|
}
|
|
153
155
|
|
|
154
156
|
const response =
|
|
155
|
-
await this.
|
|
157
|
+
await this.sendPostRequest<ServerAuthorizationTokenResponse>(
|
|
156
158
|
thumbprint,
|
|
157
159
|
tokenEndpoint,
|
|
158
|
-
{ body: queryString, headers: headers }
|
|
160
|
+
{ body: queryString, headers: headers },
|
|
161
|
+
correlationId
|
|
159
162
|
);
|
|
160
|
-
this.performanceClient?.addFields(
|
|
161
|
-
{
|
|
162
|
-
refreshTokenSize: response.body.refresh_token?.length || 0,
|
|
163
|
-
httpVerToken:
|
|
164
|
-
response.headers?.[HeaderNames.X_MS_HTTP_VERSION] || "",
|
|
165
|
-
},
|
|
166
|
-
correlationId
|
|
167
|
-
);
|
|
168
163
|
|
|
169
164
|
if (
|
|
170
165
|
this.config.serverTelemetryManager &&
|
|
@@ -178,6 +173,81 @@ export abstract class BaseClient {
|
|
|
178
173
|
return response;
|
|
179
174
|
}
|
|
180
175
|
|
|
176
|
+
/**
|
|
177
|
+
* Wraps sendPostRequestAsync with necessary preflight and postflight logic
|
|
178
|
+
* @param thumbprint - Request thumbprint for throttling
|
|
179
|
+
* @param tokenEndpoint - Endpoint to make the POST to
|
|
180
|
+
* @param options - Body and Headers to include on the POST request
|
|
181
|
+
* @param correlationId - CorrelationId for telemetry
|
|
182
|
+
*/
|
|
183
|
+
async sendPostRequest<T extends ServerAuthorizationTokenResponse>(
|
|
184
|
+
thumbprint: RequestThumbprint,
|
|
185
|
+
tokenEndpoint: string,
|
|
186
|
+
options: NetworkRequestOptions,
|
|
187
|
+
correlationId: string
|
|
188
|
+
): Promise<NetworkResponse<T>> {
|
|
189
|
+
ThrottlingUtils.preProcess(this.cacheManager, thumbprint);
|
|
190
|
+
|
|
191
|
+
let response;
|
|
192
|
+
try {
|
|
193
|
+
response = await invokeAsync(
|
|
194
|
+
this.networkClient.sendPostRequestAsync.bind(
|
|
195
|
+
this.networkClient
|
|
196
|
+
)<T>,
|
|
197
|
+
PerformanceEvents.NetworkClientSendPostRequestAsync,
|
|
198
|
+
this.logger,
|
|
199
|
+
this.performanceClient,
|
|
200
|
+
correlationId
|
|
201
|
+
)(tokenEndpoint, options);
|
|
202
|
+
const responseHeaders = response.headers || {};
|
|
203
|
+
this.performanceClient?.addFields(
|
|
204
|
+
{
|
|
205
|
+
refreshTokenSize: response.body.refresh_token?.length || 0,
|
|
206
|
+
httpVerToken:
|
|
207
|
+
responseHeaders[HeaderNames.X_MS_HTTP_VERSION] || "",
|
|
208
|
+
requestId:
|
|
209
|
+
responseHeaders[HeaderNames.X_MS_REQUEST_ID] || "",
|
|
210
|
+
},
|
|
211
|
+
correlationId
|
|
212
|
+
);
|
|
213
|
+
} catch (e) {
|
|
214
|
+
if (e instanceof NetworkError) {
|
|
215
|
+
const responseHeaders = e.responseHeaders;
|
|
216
|
+
if (responseHeaders) {
|
|
217
|
+
this.performanceClient?.addFields(
|
|
218
|
+
{
|
|
219
|
+
httpVerToken:
|
|
220
|
+
responseHeaders[
|
|
221
|
+
HeaderNames.X_MS_HTTP_VERSION
|
|
222
|
+
] || "",
|
|
223
|
+
requestId:
|
|
224
|
+
responseHeaders[HeaderNames.X_MS_REQUEST_ID] ||
|
|
225
|
+
"",
|
|
226
|
+
contentTypeHeader:
|
|
227
|
+
responseHeaders[HeaderNames.CONTENT_TYPE] ||
|
|
228
|
+
undefined,
|
|
229
|
+
contentLengthHeader:
|
|
230
|
+
responseHeaders[HeaderNames.CONTENT_LENGTH] ||
|
|
231
|
+
undefined,
|
|
232
|
+
httpStatus: e.httpStatus,
|
|
233
|
+
},
|
|
234
|
+
correlationId
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
throw e.error;
|
|
238
|
+
}
|
|
239
|
+
if (e instanceof AuthError) {
|
|
240
|
+
throw e;
|
|
241
|
+
} else {
|
|
242
|
+
throw createClientAuthError(ClientAuthErrorCodes.networkError);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
ThrottlingUtils.postProcess(this.cacheManager, thumbprint, response);
|
|
247
|
+
|
|
248
|
+
return response;
|
|
249
|
+
}
|
|
250
|
+
|
|
181
251
|
/**
|
|
182
252
|
* Updates the authority object of the client. Endpoint discovery must be completed.
|
|
183
253
|
* @param updatedAuthority
|
|
@@ -208,7 +278,17 @@ export abstract class BaseClient {
|
|
|
208
278
|
* @param request
|
|
209
279
|
*/
|
|
210
280
|
createTokenQueryParameters(request: BaseAuthRequest): string {
|
|
211
|
-
const parameterBuilder = new RequestParameterBuilder(
|
|
281
|
+
const parameterBuilder = new RequestParameterBuilder(
|
|
282
|
+
request.correlationId,
|
|
283
|
+
this.performanceClient
|
|
284
|
+
);
|
|
285
|
+
|
|
286
|
+
if (request.embeddedClientId) {
|
|
287
|
+
parameterBuilder.addBrokerParameters({
|
|
288
|
+
brokerClientId: this.config.authOptions.clientId,
|
|
289
|
+
brokerRedirectUri: this.config.authOptions.redirectUri,
|
|
290
|
+
});
|
|
291
|
+
}
|
|
212
292
|
|
|
213
293
|
if (request.tokenQueryParameters) {
|
|
214
294
|
parameterBuilder.addExtraQueryParameters(
|
|
@@ -216,6 +296,8 @@ export abstract class BaseClient {
|
|
|
216
296
|
);
|
|
217
297
|
}
|
|
218
298
|
|
|
299
|
+
parameterBuilder.addCorrelationId(request.correlationId);
|
|
300
|
+
|
|
219
301
|
return parameterBuilder.createQueryString();
|
|
220
302
|
}
|
|
221
303
|
}
|
|
@@ -24,7 +24,7 @@ import { AuthenticationResult } from "../response/AuthenticationResult.js";
|
|
|
24
24
|
import { PopTokenGenerator } from "../crypto/PopTokenGenerator.js";
|
|
25
25
|
import { StringUtils } from "../utils/StringUtils.js";
|
|
26
26
|
import { RequestThumbprint } from "../network/RequestThumbprint.js";
|
|
27
|
-
import { NetworkResponse } from "../network/
|
|
27
|
+
import { NetworkResponse } from "../network/NetworkResponse.js";
|
|
28
28
|
import { CommonSilentFlowRequest } from "../request/CommonSilentFlowRequest.js";
|
|
29
29
|
import {
|
|
30
30
|
createClientConfigurationError,
|
|
@@ -345,10 +345,14 @@ export class RefreshTokenClient extends BaseClient {
|
|
|
345
345
|
);
|
|
346
346
|
|
|
347
347
|
const correlationId = request.correlationId;
|
|
348
|
-
const parameterBuilder = new RequestParameterBuilder(
|
|
348
|
+
const parameterBuilder = new RequestParameterBuilder(
|
|
349
|
+
correlationId,
|
|
350
|
+
this.performanceClient
|
|
351
|
+
);
|
|
349
352
|
|
|
350
353
|
parameterBuilder.addClientId(
|
|
351
|
-
request.
|
|
354
|
+
request.embeddedClientId ||
|
|
355
|
+
request.tokenBodyParameters?.[AADServerParamKeys.CLIENT_ID] ||
|
|
352
356
|
this.config.authOptions.clientId
|
|
353
357
|
);
|
|
354
358
|
|
|
@@ -376,8 +380,6 @@ export class RefreshTokenClient extends BaseClient {
|
|
|
376
380
|
parameterBuilder.addServerTelemetry(this.serverTelemetryManager);
|
|
377
381
|
}
|
|
378
382
|
|
|
379
|
-
parameterBuilder.addCorrelationId(correlationId);
|
|
380
|
-
|
|
381
383
|
parameterBuilder.addRefreshToken(request.refreshToken);
|
|
382
384
|
|
|
383
385
|
if (this.config.clientCredentials.clientSecret) {
|
|
@@ -472,6 +474,13 @@ export class RefreshTokenClient extends BaseClient {
|
|
|
472
474
|
}
|
|
473
475
|
}
|
|
474
476
|
|
|
477
|
+
if (request.embeddedClientId) {
|
|
478
|
+
parameterBuilder.addBrokerParameters({
|
|
479
|
+
brokerClientId: this.config.authOptions.clientId,
|
|
480
|
+
brokerRedirectUri: this.config.authOptions.redirectUri,
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
|
|
475
484
|
if (request.tokenBodyParameters) {
|
|
476
485
|
parameterBuilder.addExtraQueryParameters(
|
|
477
486
|
request.tokenBodyParameters
|