@azure/msal-browser 4.0.0-alpha.0 → 4.0.2
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/app/IPublicClientApplication.mjs +1 -1
- package/dist/app/PublicClientApplication.d.ts.map +1 -1
- package/dist/app/PublicClientApplication.mjs +4 -2
- package/dist/app/PublicClientApplication.mjs.map +1 -1
- package/dist/app/PublicClientNext.mjs +1 -1
- package/dist/broker/nativeBroker/NativeMessageHandler.d.ts +1 -1
- package/dist/broker/nativeBroker/NativeMessageHandler.d.ts.map +1 -1
- package/dist/broker/nativeBroker/NativeMessageHandler.mjs +8 -8
- package/dist/broker/nativeBroker/NativeMessageHandler.mjs.map +1 -1
- package/dist/broker/nativeBroker/NativeResponse.d.ts +1 -1
- package/dist/broker/nativeBroker/NativeStatusCodes.mjs +1 -1
- package/dist/cache/AccountManager.mjs +1 -1
- package/dist/cache/AsyncMemoryStorage.mjs +1 -1
- package/dist/cache/BrowserCacheManager.d.ts +10 -15
- package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
- package/dist/cache/BrowserCacheManager.mjs +42 -43
- package/dist/cache/BrowserCacheManager.mjs.map +1 -1
- package/dist/cache/CacheHelpers.mjs +1 -1
- package/dist/cache/CookieStorage.mjs +1 -1
- package/dist/cache/CookieStorage.mjs.map +1 -1
- package/dist/cache/DatabaseStorage.mjs +1 -1
- package/dist/cache/IWindowStorage.d.ts +2 -2
- package/dist/cache/IWindowStorage.d.ts.map +1 -1
- package/dist/cache/LocalStorage.d.ts +7 -3
- package/dist/cache/LocalStorage.d.ts.map +1 -1
- package/dist/cache/LocalStorage.mjs +48 -34
- package/dist/cache/LocalStorage.mjs.map +1 -1
- package/dist/cache/MemoryStorage.mjs +1 -1
- package/dist/cache/SessionStorage.mjs +1 -1
- package/dist/cache/TokenCache.d.ts.map +1 -1
- package/dist/cache/TokenCache.mjs +15 -14
- package/dist/cache/TokenCache.mjs.map +1 -1
- package/dist/config/Configuration.d.ts +2 -2
- package/dist/config/Configuration.d.ts.map +1 -1
- package/dist/config/Configuration.mjs +5 -5
- package/dist/config/Configuration.mjs.map +1 -1
- package/dist/controllers/ControllerFactory.mjs +1 -1
- package/dist/controllers/NestedAppAuthController.d.ts +6 -3
- package/dist/controllers/NestedAppAuthController.d.ts.map +1 -1
- package/dist/controllers/NestedAppAuthController.mjs +34 -18
- package/dist/controllers/NestedAppAuthController.mjs.map +1 -1
- package/dist/controllers/StandardController.d.ts +2 -2
- package/dist/controllers/StandardController.d.ts.map +1 -1
- package/dist/controllers/StandardController.mjs +27 -23
- package/dist/controllers/StandardController.mjs.map +1 -1
- package/dist/controllers/UnknownOperatingContextController.d.ts +2 -2
- package/dist/controllers/UnknownOperatingContextController.d.ts.map +1 -1
- package/dist/controllers/UnknownOperatingContextController.mjs +3 -3
- package/dist/controllers/UnknownOperatingContextController.mjs.map +1 -1
- package/dist/crypto/BrowserCrypto.d.ts +1 -1
- package/dist/crypto/BrowserCrypto.d.ts.map +1 -1
- package/dist/crypto/BrowserCrypto.mjs +3 -3
- package/dist/crypto/BrowserCrypto.mjs.map +1 -1
- package/dist/crypto/CryptoOps.d.ts +1 -1
- package/dist/crypto/CryptoOps.d.ts.map +1 -1
- package/dist/crypto/CryptoOps.mjs +3 -3
- package/dist/crypto/CryptoOps.mjs.map +1 -1
- package/dist/crypto/PkceGenerator.mjs +1 -1
- package/dist/crypto/SignedHttpRequest.mjs +1 -1
- package/dist/encode/Base64Decode.mjs +1 -1
- package/dist/encode/Base64Encode.mjs +1 -1
- package/dist/error/BrowserAuthError.mjs +1 -1
- package/dist/error/BrowserAuthErrorCodes.mjs +1 -1
- package/dist/error/BrowserConfigurationAuthError.mjs +1 -1
- package/dist/error/BrowserConfigurationAuthErrorCodes.mjs +1 -1
- package/dist/error/NativeAuthError.mjs +1 -1
- package/dist/error/NativeAuthError.mjs.map +1 -1
- package/dist/error/NativeAuthErrorCodes.mjs +1 -1
- package/dist/error/NestedAppAuthError.mjs +1 -1
- package/dist/event/EventHandler.mjs +1 -1
- package/dist/event/EventMessage.mjs +1 -1
- package/dist/event/EventType.mjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/interaction_client/BaseInteractionClient.mjs +1 -1
- package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +1 -1
- package/dist/interaction_client/NativeInteractionClient.d.ts +2 -3
- package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
- package/dist/interaction_client/NativeInteractionClient.mjs +11 -9
- package/dist/interaction_client/NativeInteractionClient.mjs.map +1 -1
- package/dist/interaction_client/PopupClient.d.ts.map +1 -1
- package/dist/interaction_client/PopupClient.mjs +4 -4
- package/dist/interaction_client/PopupClient.mjs.map +1 -1
- package/dist/interaction_client/RedirectClient.mjs +2 -2
- package/dist/interaction_client/RedirectClient.mjs.map +1 -1
- package/dist/interaction_client/SilentAuthCodeClient.mjs +1 -1
- package/dist/interaction_client/SilentCacheClient.mjs +1 -1
- package/dist/interaction_client/SilentIframeClient.mjs +2 -2
- package/dist/interaction_client/SilentIframeClient.mjs.map +1 -1
- package/dist/interaction_client/SilentRefreshClient.mjs +1 -1
- package/dist/interaction_client/StandardInteractionClient.mjs +1 -1
- package/dist/interaction_handler/InteractionHandler.mjs +1 -1
- package/dist/interaction_handler/RedirectHandler.mjs +1 -1
- package/dist/interaction_handler/SilentHandler.mjs +1 -1
- package/dist/naa/BridgeError.mjs +1 -1
- package/dist/naa/BridgeProxy.mjs +1 -1
- package/dist/naa/BridgeStatusCode.mjs +1 -1
- package/dist/naa/mapping/NestedAppAuthAdapter.mjs +1 -1
- package/dist/navigation/NavigationClient.mjs +1 -1
- package/dist/network/FetchClient.mjs +1 -1
- package/dist/operatingcontext/BaseOperatingContext.mjs +1 -1
- package/dist/operatingcontext/NestedAppOperatingContext.mjs +1 -1
- package/dist/operatingcontext/StandardOperatingContext.mjs +1 -1
- package/dist/operatingcontext/UnknownOperatingContext.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/AuthorizationUrlRequest.d.ts +1 -1
- package/dist/request/AuthorizationUrlRequest.d.ts.map +1 -1
- package/dist/request/PopupRequest.d.ts +1 -1
- package/dist/request/PopupRequest.d.ts.map +1 -1
- package/dist/request/RedirectRequest.d.ts +1 -1
- package/dist/request/RedirectRequest.d.ts.map +1 -1
- package/dist/request/RequestHelpers.mjs +1 -1
- package/dist/request/SsoSilentRequest.d.ts +1 -1
- package/dist/request/SsoSilentRequest.d.ts.map +1 -1
- package/dist/response/ResponseHandler.mjs +1 -1
- package/dist/telemetry/BrowserPerformanceClient.mjs +1 -1
- package/dist/telemetry/BrowserPerformanceMeasurement.mjs +1 -1
- package/dist/utils/BrowserConstants.mjs +1 -1
- package/dist/utils/BrowserProtocolUtils.mjs +1 -1
- package/dist/utils/BrowserUtils.d.ts.map +1 -1
- package/dist/utils/BrowserUtils.mjs +4 -2
- package/dist/utils/BrowserUtils.mjs.map +1 -1
- package/lib/msal-browser.cjs +298 -249
- package/lib/msal-browser.cjs.map +1 -1
- package/lib/msal-browser.js +298 -249
- package/lib/msal-browser.js.map +1 -1
- package/lib/msal-browser.min.js +63 -63
- package/lib/types/app/PublicClientApplication.d.ts.map +1 -1
- package/lib/types/broker/nativeBroker/NativeMessageHandler.d.ts +1 -1
- package/lib/types/broker/nativeBroker/NativeMessageHandler.d.ts.map +1 -1
- package/lib/types/broker/nativeBroker/NativeResponse.d.ts +1 -1
- package/lib/types/cache/BrowserCacheManager.d.ts +10 -15
- package/lib/types/cache/BrowserCacheManager.d.ts.map +1 -1
- package/lib/types/cache/IWindowStorage.d.ts +2 -2
- package/lib/types/cache/IWindowStorage.d.ts.map +1 -1
- package/lib/types/cache/LocalStorage.d.ts +7 -3
- package/lib/types/cache/LocalStorage.d.ts.map +1 -1
- package/lib/types/cache/TokenCache.d.ts.map +1 -1
- package/lib/types/config/Configuration.d.ts +2 -2
- package/lib/types/config/Configuration.d.ts.map +1 -1
- package/lib/types/controllers/NestedAppAuthController.d.ts +6 -3
- package/lib/types/controllers/NestedAppAuthController.d.ts.map +1 -1
- package/lib/types/controllers/StandardController.d.ts +2 -2
- package/lib/types/controllers/StandardController.d.ts.map +1 -1
- package/lib/types/controllers/UnknownOperatingContextController.d.ts +2 -2
- package/lib/types/controllers/UnknownOperatingContextController.d.ts.map +1 -1
- package/lib/types/crypto/BrowserCrypto.d.ts +1 -1
- package/lib/types/crypto/BrowserCrypto.d.ts.map +1 -1
- package/lib/types/crypto/CryptoOps.d.ts +1 -1
- package/lib/types/crypto/CryptoOps.d.ts.map +1 -1
- package/lib/types/interaction_client/NativeInteractionClient.d.ts +2 -3
- package/lib/types/interaction_client/NativeInteractionClient.d.ts.map +1 -1
- package/lib/types/interaction_client/PopupClient.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/AuthorizationUrlRequest.d.ts +1 -1
- package/lib/types/request/AuthorizationUrlRequest.d.ts.map +1 -1
- package/lib/types/request/PopupRequest.d.ts +1 -1
- package/lib/types/request/PopupRequest.d.ts.map +1 -1
- package/lib/types/request/RedirectRequest.d.ts +1 -1
- package/lib/types/request/RedirectRequest.d.ts.map +1 -1
- package/lib/types/request/SsoSilentRequest.d.ts +1 -1
- package/lib/types/request/SsoSilentRequest.d.ts.map +1 -1
- package/lib/types/utils/BrowserUtils.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/app/PublicClientApplication.ts +6 -1
- package/src/broker/nativeBroker/NativeMessageHandler.ts +7 -7
- package/src/broker/nativeBroker/NativeResponse.ts +1 -1
- package/src/cache/BrowserCacheManager.ts +88 -57
- package/src/cache/IWindowStorage.ts +2 -2
- package/src/cache/LocalStorage.ts +142 -43
- package/src/cache/TokenCache.ts +28 -11
- package/src/config/Configuration.ts +6 -6
- package/src/controllers/NestedAppAuthController.ts +51 -23
- package/src/controllers/StandardController.ts +41 -24
- package/src/controllers/UnknownOperatingContextController.ts +6 -5
- package/src/crypto/BrowserCrypto.ts +4 -2
- package/src/crypto/CryptoOps.ts +8 -2
- package/src/interaction_client/NativeInteractionClient.ts +16 -16
- package/src/interaction_client/PopupClient.ts +9 -8
- package/src/interaction_client/RedirectClient.ts +1 -1
- package/src/interaction_client/SilentIframeClient.ts +1 -1
- package/src/packageMetadata.ts +1 -1
- package/src/request/AuthorizationUrlRequest.ts +1 -1
- package/src/request/PopupRequest.ts +1 -1
- package/src/request/RedirectRequest.ts +1 -1
- package/src/request/SsoSilentRequest.ts +1 -1
- package/src/utils/BrowserUtils.ts +3 -1
package/src/cache/TokenCache.ts
CHANGED
|
@@ -86,6 +86,9 @@ export class TokenCache implements ITokenCache {
|
|
|
86
86
|
);
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
+
const correlationId =
|
|
90
|
+
request.correlationId || BrowserCrypto.createNewGuid();
|
|
91
|
+
|
|
89
92
|
const idTokenClaims = response.id_token
|
|
90
93
|
? AuthToken.extractTokenClaims(response.id_token, base64Decode)
|
|
91
94
|
: undefined;
|
|
@@ -115,6 +118,7 @@ export class TokenCache implements ITokenCache {
|
|
|
115
118
|
const cacheRecordAccount: AccountEntity = await this.loadAccount(
|
|
116
119
|
request,
|
|
117
120
|
options.clientInfo || response.client_info || "",
|
|
121
|
+
correlationId,
|
|
118
122
|
idTokenClaims,
|
|
119
123
|
authority
|
|
120
124
|
);
|
|
@@ -123,7 +127,8 @@ export class TokenCache implements ITokenCache {
|
|
|
123
127
|
response,
|
|
124
128
|
cacheRecordAccount.homeAccountId,
|
|
125
129
|
cacheRecordAccount.environment,
|
|
126
|
-
cacheRecordAccount.realm
|
|
130
|
+
cacheRecordAccount.realm,
|
|
131
|
+
correlationId
|
|
127
132
|
);
|
|
128
133
|
|
|
129
134
|
const accessToken = await this.loadAccessToken(
|
|
@@ -132,13 +137,15 @@ export class TokenCache implements ITokenCache {
|
|
|
132
137
|
cacheRecordAccount.homeAccountId,
|
|
133
138
|
cacheRecordAccount.environment,
|
|
134
139
|
cacheRecordAccount.realm,
|
|
135
|
-
options
|
|
140
|
+
options,
|
|
141
|
+
correlationId
|
|
136
142
|
);
|
|
137
143
|
|
|
138
144
|
const refreshToken = await this.loadRefreshToken(
|
|
139
145
|
response,
|
|
140
146
|
cacheRecordAccount.homeAccountId,
|
|
141
|
-
cacheRecordAccount.environment
|
|
147
|
+
cacheRecordAccount.environment,
|
|
148
|
+
correlationId
|
|
142
149
|
);
|
|
143
150
|
|
|
144
151
|
return this.generateAuthenticationResult(
|
|
@@ -166,6 +173,7 @@ export class TokenCache implements ITokenCache {
|
|
|
166
173
|
private async loadAccount(
|
|
167
174
|
request: SilentRequest,
|
|
168
175
|
clientInfo: string,
|
|
176
|
+
correlationId: string,
|
|
169
177
|
idTokenClaims?: TokenClaims,
|
|
170
178
|
authority?: Authority
|
|
171
179
|
): Promise<AccountEntity> {
|
|
@@ -175,7 +183,7 @@ export class TokenCache implements ITokenCache {
|
|
|
175
183
|
const accountEntity = AccountEntity.createFromAccountInfo(
|
|
176
184
|
request.account
|
|
177
185
|
);
|
|
178
|
-
await this.storage.setAccount(accountEntity);
|
|
186
|
+
await this.storage.setAccount(accountEntity, correlationId);
|
|
179
187
|
return accountEntity;
|
|
180
188
|
} else if (!authority || (!clientInfo && !idTokenClaims)) {
|
|
181
189
|
this.logger.error(
|
|
@@ -210,7 +218,7 @@ export class TokenCache implements ITokenCache {
|
|
|
210
218
|
this.logger
|
|
211
219
|
);
|
|
212
220
|
|
|
213
|
-
await this.storage.setAccount(cachedAccount);
|
|
221
|
+
await this.storage.setAccount(cachedAccount, correlationId);
|
|
214
222
|
return cachedAccount;
|
|
215
223
|
}
|
|
216
224
|
|
|
@@ -226,7 +234,8 @@ export class TokenCache implements ITokenCache {
|
|
|
226
234
|
response: ExternalTokenResponse,
|
|
227
235
|
homeAccountId: string,
|
|
228
236
|
environment: string,
|
|
229
|
-
tenantId: string
|
|
237
|
+
tenantId: string,
|
|
238
|
+
correlationId: string
|
|
230
239
|
): Promise<IdTokenEntity | null> {
|
|
231
240
|
if (!response.id_token) {
|
|
232
241
|
this.logger.verbose("TokenCache - no id token found in response");
|
|
@@ -242,7 +251,7 @@ export class TokenCache implements ITokenCache {
|
|
|
242
251
|
tenantId
|
|
243
252
|
);
|
|
244
253
|
|
|
245
|
-
await this.storage.setIdTokenCredential(idTokenEntity);
|
|
254
|
+
await this.storage.setIdTokenCredential(idTokenEntity, correlationId);
|
|
246
255
|
return idTokenEntity;
|
|
247
256
|
}
|
|
248
257
|
|
|
@@ -261,7 +270,8 @@ export class TokenCache implements ITokenCache {
|
|
|
261
270
|
homeAccountId: string,
|
|
262
271
|
environment: string,
|
|
263
272
|
tenantId: string,
|
|
264
|
-
options: LoadTokenOptions
|
|
273
|
+
options: LoadTokenOptions,
|
|
274
|
+
correlationId: string
|
|
265
275
|
): Promise<AccessTokenEntity | null> {
|
|
266
276
|
if (!response.access_token) {
|
|
267
277
|
this.logger.verbose(
|
|
@@ -309,7 +319,10 @@ export class TokenCache implements ITokenCache {
|
|
|
309
319
|
base64Decode
|
|
310
320
|
);
|
|
311
321
|
|
|
312
|
-
await this.storage.setAccessTokenCredential(
|
|
322
|
+
await this.storage.setAccessTokenCredential(
|
|
323
|
+
accessTokenEntity,
|
|
324
|
+
correlationId
|
|
325
|
+
);
|
|
313
326
|
return accessTokenEntity;
|
|
314
327
|
}
|
|
315
328
|
|
|
@@ -324,7 +337,8 @@ export class TokenCache implements ITokenCache {
|
|
|
324
337
|
private async loadRefreshToken(
|
|
325
338
|
response: ExternalTokenResponse,
|
|
326
339
|
homeAccountId: string,
|
|
327
|
-
environment: string
|
|
340
|
+
environment: string,
|
|
341
|
+
correlationId: string
|
|
328
342
|
): Promise<RefreshTokenEntity | null> {
|
|
329
343
|
if (!response.refresh_token) {
|
|
330
344
|
this.logger.verbose(
|
|
@@ -344,7 +358,10 @@ export class TokenCache implements ITokenCache {
|
|
|
344
358
|
response.refresh_token_expires_in
|
|
345
359
|
);
|
|
346
360
|
|
|
347
|
-
await this.storage.setRefreshTokenCredential(
|
|
361
|
+
await this.storage.setRefreshTokenCredential(
|
|
362
|
+
refreshTokenEntity,
|
|
363
|
+
correlationId
|
|
364
|
+
);
|
|
348
365
|
return refreshTokenEntity;
|
|
349
366
|
}
|
|
350
367
|
|
|
@@ -192,9 +192,9 @@ export type BrowserSystemOptions = SystemOptions & {
|
|
|
192
192
|
*/
|
|
193
193
|
allowRedirectInIframe?: boolean;
|
|
194
194
|
/**
|
|
195
|
-
* Flag to enable native broker support (e.g. acquiring tokens from WAM on Windows)
|
|
195
|
+
* Flag to enable native broker support (e.g. acquiring tokens from WAM on Windows, MacBroker on Mac)
|
|
196
196
|
*/
|
|
197
|
-
|
|
197
|
+
allowPlatformBroker?: boolean;
|
|
198
198
|
/**
|
|
199
199
|
* Sets the timeout for waiting for the native broker handshake to resolve
|
|
200
200
|
*/
|
|
@@ -340,7 +340,7 @@ export function buildConfiguration(
|
|
|
340
340
|
redirectNavigationTimeout: DEFAULT_REDIRECT_TIMEOUT_MS,
|
|
341
341
|
asyncPopups: false,
|
|
342
342
|
allowRedirectInIframe: false,
|
|
343
|
-
|
|
343
|
+
allowPlatformBroker: false,
|
|
344
344
|
nativeBrokerHandshakeTimeout:
|
|
345
345
|
userInputSystem?.nativeBrokerHandshakeTimeout ||
|
|
346
346
|
DEFAULT_NATIVE_BROKER_HANDSHAKE_TIMEOUT_MS,
|
|
@@ -376,14 +376,14 @@ export function buildConfiguration(
|
|
|
376
376
|
);
|
|
377
377
|
}
|
|
378
378
|
|
|
379
|
-
// Throw an error if user has set
|
|
379
|
+
// Throw an error if user has set allowPlatformBroker to true without being in AAD protocol mode
|
|
380
380
|
if (
|
|
381
381
|
userInputAuth?.protocolMode &&
|
|
382
382
|
userInputAuth.protocolMode !== ProtocolMode.AAD &&
|
|
383
|
-
providedSystemOptions?.
|
|
383
|
+
providedSystemOptions?.allowPlatformBroker
|
|
384
384
|
) {
|
|
385
385
|
throw createClientConfigurationError(
|
|
386
|
-
ClientConfigurationErrorCodes.
|
|
386
|
+
ClientConfigurationErrorCodes.cannotAllowPlatformBroker
|
|
387
387
|
);
|
|
388
388
|
}
|
|
389
389
|
|
|
@@ -53,6 +53,9 @@ import {
|
|
|
53
53
|
} from "../cache/BrowserCacheManager.js";
|
|
54
54
|
import { ClearCacheRequest } from "../request/ClearCacheRequest.js";
|
|
55
55
|
import * as AccountManager from "../cache/AccountManager.js";
|
|
56
|
+
import { AccountContext } from "../naa/BridgeAccountContext.js";
|
|
57
|
+
import { InitializeApplicationRequest } from "../request/InitializeApplicationRequest.js";
|
|
58
|
+
import { createNewGuid } from "../crypto/BrowserCrypto.js";
|
|
56
59
|
|
|
57
60
|
export class NestedAppAuthController implements IController {
|
|
58
61
|
// OperatingContext
|
|
@@ -82,6 +85,9 @@ export class NestedAppAuthController implements IController {
|
|
|
82
85
|
// NestedAppAuthAdapter
|
|
83
86
|
protected readonly nestedAppAuthAdapter: NestedAppAuthAdapter;
|
|
84
87
|
|
|
88
|
+
// currentAccount for NAA apps
|
|
89
|
+
protected currentAccountContext: AccountContext | null;
|
|
90
|
+
|
|
85
91
|
constructor(operatingContext: NestedAppOperatingContext) {
|
|
86
92
|
this.operatingContext = operatingContext;
|
|
87
93
|
const proxy = this.operatingContext.getBridgeProxy();
|
|
@@ -102,7 +108,7 @@ export class NestedAppAuthController implements IController {
|
|
|
102
108
|
|
|
103
109
|
// Initialize the crypto class.
|
|
104
110
|
this.browserCrypto = operatingContext.isBrowserEnvironment()
|
|
105
|
-
? new CryptoOps(this.logger, this.performanceClient)
|
|
111
|
+
? new CryptoOps(this.logger, this.performanceClient, true)
|
|
106
112
|
: DEFAULT_CRYPTO_IMPLEMENTATION;
|
|
107
113
|
|
|
108
114
|
// Initialize the browser storage class.
|
|
@@ -112,11 +118,13 @@ export class NestedAppAuthController implements IController {
|
|
|
112
118
|
this.config.cache,
|
|
113
119
|
this.browserCrypto,
|
|
114
120
|
this.logger,
|
|
121
|
+
this.performanceClient,
|
|
115
122
|
buildStaticAuthorityOptions(this.config.auth)
|
|
116
123
|
)
|
|
117
124
|
: DEFAULT_BROWSER_CACHE_MANAGER(
|
|
118
125
|
this.config.auth.clientId,
|
|
119
|
-
this.logger
|
|
126
|
+
this.logger,
|
|
127
|
+
this.performanceClient
|
|
120
128
|
);
|
|
121
129
|
|
|
122
130
|
this.eventHandler = new EventHandler(this.logger);
|
|
@@ -130,15 +138,7 @@ export class NestedAppAuthController implements IController {
|
|
|
130
138
|
|
|
131
139
|
// Set the active account if available
|
|
132
140
|
const accountContext = this.bridgeProxy.getAccountContext();
|
|
133
|
-
|
|
134
|
-
const cachedAccount = AccountManager.getAccount(
|
|
135
|
-
accountContext,
|
|
136
|
-
this.logger,
|
|
137
|
-
this.browserStorage
|
|
138
|
-
);
|
|
139
|
-
|
|
140
|
-
AccountManager.setActiveAccount(cachedAccount, this.browserStorage);
|
|
141
|
-
}
|
|
141
|
+
this.currentAccountContext = accountContext ? accountContext : null;
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
/**
|
|
@@ -157,8 +157,9 @@ export class NestedAppAuthController implements IController {
|
|
|
157
157
|
* Specific implementation of initialize function for NestedAppAuthController
|
|
158
158
|
* @returns
|
|
159
159
|
*/
|
|
160
|
-
async initialize(): Promise<void> {
|
|
161
|
-
|
|
160
|
+
async initialize(request?: InitializeApplicationRequest): Promise<void> {
|
|
161
|
+
const initCorrelationId = request?.correlationId || createNewGuid();
|
|
162
|
+
await this.browserStorage.initialize(initCorrelationId);
|
|
162
163
|
return Promise.resolve();
|
|
163
164
|
}
|
|
164
165
|
|
|
@@ -224,7 +225,13 @@ export class NestedAppAuthController implements IController {
|
|
|
224
225
|
// cache the tokens in the response
|
|
225
226
|
await this.hydrateCache(result, request);
|
|
226
227
|
|
|
227
|
-
|
|
228
|
+
// cache the account context in memory after successful token fetch
|
|
229
|
+
this.currentAccountContext = {
|
|
230
|
+
homeAccountId: result.account.homeAccountId,
|
|
231
|
+
environment: result.account.environment,
|
|
232
|
+
tenantId: result.account.tenantId,
|
|
233
|
+
};
|
|
234
|
+
|
|
228
235
|
this.eventHandler.emitEvent(
|
|
229
236
|
EventType.ACQUIRE_TOKEN_SUCCESS,
|
|
230
237
|
InteractionType.Popup,
|
|
@@ -318,7 +325,13 @@ export class NestedAppAuthController implements IController {
|
|
|
318
325
|
// cache the tokens in the response
|
|
319
326
|
await this.hydrateCache(result, request);
|
|
320
327
|
|
|
321
|
-
|
|
328
|
+
// cache the account context in memory after successful token fetch
|
|
329
|
+
this.currentAccountContext = {
|
|
330
|
+
homeAccountId: result.account.homeAccountId,
|
|
331
|
+
environment: result.account.environment,
|
|
332
|
+
tenantId: result.account.tenantId,
|
|
333
|
+
};
|
|
334
|
+
|
|
322
335
|
this.eventHandler.emitEvent(
|
|
323
336
|
EventType.ACQUIRE_TOKEN_SUCCESS,
|
|
324
337
|
InteractionType.Silent,
|
|
@@ -376,8 +389,20 @@ export class NestedAppAuthController implements IController {
|
|
|
376
389
|
return null;
|
|
377
390
|
}
|
|
378
391
|
|
|
392
|
+
// if the request has forceRefresh, we cannot look up in the cache
|
|
393
|
+
if (request.forceRefresh) {
|
|
394
|
+
this.logger.verbose(
|
|
395
|
+
"forceRefresh is set to true, skipping cache lookup"
|
|
396
|
+
);
|
|
397
|
+
return null;
|
|
398
|
+
}
|
|
399
|
+
|
|
379
400
|
// respect cache lookup policy
|
|
380
401
|
let result: AuthenticationResult | null = null;
|
|
402
|
+
if (!request.cacheLookupPolicy) {
|
|
403
|
+
request.cacheLookupPolicy = CacheLookupPolicy.Default;
|
|
404
|
+
}
|
|
405
|
+
|
|
381
406
|
switch (request.cacheLookupPolicy) {
|
|
382
407
|
case CacheLookupPolicy.Default:
|
|
383
408
|
case CacheLookupPolicy.AccessToken:
|
|
@@ -428,16 +453,16 @@ export class NestedAppAuthController implements IController {
|
|
|
428
453
|
private async acquireTokenFromCacheInternal(
|
|
429
454
|
request: SilentRequest
|
|
430
455
|
): Promise<AuthenticationResult | null> {
|
|
431
|
-
|
|
432
|
-
|
|
456
|
+
// always prioritize the account context from the bridge
|
|
457
|
+
const accountContext =
|
|
458
|
+
this.bridgeProxy.getAccountContext() || this.currentAccountContext;
|
|
459
|
+
let currentAccount: AccountInfo | null = null;
|
|
433
460
|
if (accountContext) {
|
|
434
|
-
|
|
461
|
+
currentAccount = AccountManager.getAccount(
|
|
435
462
|
accountContext,
|
|
436
463
|
this.logger,
|
|
437
464
|
this.browserStorage
|
|
438
465
|
);
|
|
439
|
-
// always prioritize for hub account context, the reqirement of `request.account` will be removed soon
|
|
440
|
-
currentAccount = hubAccount || request.account;
|
|
441
466
|
}
|
|
442
467
|
|
|
443
468
|
// fall back to brokering if no cached account is found
|
|
@@ -568,7 +593,7 @@ export class NestedAppAuthController implements IController {
|
|
|
568
593
|
| "responseMode"
|
|
569
594
|
| "codeChallenge"
|
|
570
595
|
| "codeChallengeMethod"
|
|
571
|
-
| "
|
|
596
|
+
| "platformBroker"
|
|
572
597
|
>
|
|
573
598
|
>
|
|
574
599
|
| PopupRequest,
|
|
@@ -761,7 +786,7 @@ export class NestedAppAuthController implements IController {
|
|
|
761
786
|
| "responseMode"
|
|
762
787
|
| "codeChallenge"
|
|
763
788
|
| "codeChallengeMethod"
|
|
764
|
-
| "
|
|
789
|
+
| "platformBroker"
|
|
765
790
|
>
|
|
766
791
|
>
|
|
767
792
|
): Promise<AuthenticationResult> {
|
|
@@ -842,7 +867,10 @@ export class NestedAppAuthController implements IController {
|
|
|
842
867
|
result.cloudGraphHostName,
|
|
843
868
|
result.msGraphHost
|
|
844
869
|
);
|
|
845
|
-
await this.browserStorage.setAccount(
|
|
870
|
+
await this.browserStorage.setAccount(
|
|
871
|
+
accountEntity,
|
|
872
|
+
result.correlationId
|
|
873
|
+
);
|
|
846
874
|
return this.browserStorage.hydrateCache(result, request);
|
|
847
875
|
}
|
|
848
876
|
}
|
|
@@ -242,12 +242,13 @@ export class StandardController implements IController {
|
|
|
242
242
|
this.config.cache,
|
|
243
243
|
this.browserCrypto,
|
|
244
244
|
this.logger,
|
|
245
|
-
|
|
246
|
-
this.
|
|
245
|
+
this.performanceClient,
|
|
246
|
+
buildStaticAuthorityOptions(this.config.auth)
|
|
247
247
|
)
|
|
248
248
|
: DEFAULT_BROWSER_CACHE_MANAGER(
|
|
249
249
|
this.config.auth.clientId,
|
|
250
|
-
this.logger
|
|
250
|
+
this.logger,
|
|
251
|
+
this.performanceClient
|
|
251
252
|
);
|
|
252
253
|
|
|
253
254
|
// initialize in memory storage for native flows
|
|
@@ -264,7 +265,6 @@ export class StandardController implements IController {
|
|
|
264
265
|
nativeCacheOptions,
|
|
265
266
|
this.browserCrypto,
|
|
266
267
|
this.logger,
|
|
267
|
-
undefined,
|
|
268
268
|
this.performanceClient
|
|
269
269
|
);
|
|
270
270
|
|
|
@@ -331,18 +331,24 @@ export class StandardController implements IController {
|
|
|
331
331
|
return;
|
|
332
332
|
}
|
|
333
333
|
|
|
334
|
-
await this.browserStorage.initialize();
|
|
335
|
-
|
|
336
334
|
const initCorrelationId =
|
|
337
335
|
request?.correlationId || this.getRequestCorrelationId();
|
|
338
|
-
const
|
|
336
|
+
const allowPlatformBroker = this.config.system.allowPlatformBroker;
|
|
339
337
|
const initMeasurement = this.performanceClient.startMeasurement(
|
|
340
338
|
PerformanceEvents.InitializeClientApplication,
|
|
341
339
|
initCorrelationId
|
|
342
340
|
);
|
|
343
341
|
this.eventHandler.emitEvent(EventType.INITIALIZE_START);
|
|
344
342
|
|
|
345
|
-
|
|
343
|
+
await invokeAsync(
|
|
344
|
+
this.browserStorage.initialize.bind(this.browserStorage),
|
|
345
|
+
PerformanceEvents.InitializeCache,
|
|
346
|
+
this.logger,
|
|
347
|
+
this.performanceClient,
|
|
348
|
+
initCorrelationId
|
|
349
|
+
)(initCorrelationId);
|
|
350
|
+
|
|
351
|
+
if (allowPlatformBroker) {
|
|
346
352
|
try {
|
|
347
353
|
this.nativeExtensionProvider =
|
|
348
354
|
await NativeMessageHandler.createProvider(
|
|
@@ -373,7 +379,10 @@ export class StandardController implements IController {
|
|
|
373
379
|
|
|
374
380
|
this.initialized = true;
|
|
375
381
|
this.eventHandler.emitEvent(EventType.INITIALIZE_END);
|
|
376
|
-
initMeasurement.end({
|
|
382
|
+
initMeasurement.end({
|
|
383
|
+
allowPlatformBroker: allowPlatformBroker,
|
|
384
|
+
success: true,
|
|
385
|
+
});
|
|
377
386
|
}
|
|
378
387
|
|
|
379
388
|
// #region Redirect Flow
|
|
@@ -433,7 +442,7 @@ export class StandardController implements IController {
|
|
|
433
442
|
this.browserStorage.getCachedNativeRequest();
|
|
434
443
|
const useNative =
|
|
435
444
|
request &&
|
|
436
|
-
NativeMessageHandler.
|
|
445
|
+
NativeMessageHandler.isPlatformBrokerAvailable(
|
|
437
446
|
this.config,
|
|
438
447
|
this.logger,
|
|
439
448
|
this.nativeExtensionProvider
|
|
@@ -656,7 +665,10 @@ export class StandardController implements IController {
|
|
|
656
665
|
|
|
657
666
|
let result: Promise<void>;
|
|
658
667
|
|
|
659
|
-
if (
|
|
668
|
+
if (
|
|
669
|
+
this.nativeExtensionProvider &&
|
|
670
|
+
this.canUsePlatformBroker(request)
|
|
671
|
+
) {
|
|
660
672
|
const nativeClient = new NativeInteractionClient(
|
|
661
673
|
this.config,
|
|
662
674
|
this.browserStorage,
|
|
@@ -770,7 +782,7 @@ export class StandardController implements IController {
|
|
|
770
782
|
|
|
771
783
|
let result: Promise<AuthenticationResult>;
|
|
772
784
|
|
|
773
|
-
if (this.
|
|
785
|
+
if (this.canUsePlatformBroker(request)) {
|
|
774
786
|
result = this.acquireTokenNative(
|
|
775
787
|
{
|
|
776
788
|
...request,
|
|
@@ -939,7 +951,7 @@ export class StandardController implements IController {
|
|
|
939
951
|
|
|
940
952
|
let result: Promise<AuthenticationResult>;
|
|
941
953
|
|
|
942
|
-
if (this.
|
|
954
|
+
if (this.canUsePlatformBroker(validRequest)) {
|
|
943
955
|
result = this.acquireTokenNative(
|
|
944
956
|
validRequest,
|
|
945
957
|
ApiId.ssoSilent
|
|
@@ -1087,7 +1099,9 @@ export class StandardController implements IController {
|
|
|
1087
1099
|
}
|
|
1088
1100
|
return await response;
|
|
1089
1101
|
} else if (request.nativeAccountId) {
|
|
1090
|
-
if (
|
|
1102
|
+
if (
|
|
1103
|
+
this.canUsePlatformBroker(request, request.nativeAccountId)
|
|
1104
|
+
) {
|
|
1091
1105
|
const result = await this.acquireTokenNative(
|
|
1092
1106
|
{
|
|
1093
1107
|
...request,
|
|
@@ -1474,7 +1488,10 @@ export class StandardController implements IController {
|
|
|
1474
1488
|
result.cloudGraphHostName,
|
|
1475
1489
|
result.msGraphHost
|
|
1476
1490
|
);
|
|
1477
|
-
await this.browserStorage.setAccount(
|
|
1491
|
+
await this.browserStorage.setAccount(
|
|
1492
|
+
accountEntity,
|
|
1493
|
+
result.correlationId
|
|
1494
|
+
);
|
|
1478
1495
|
|
|
1479
1496
|
if (result.fromNativeBroker) {
|
|
1480
1497
|
this.logger.verbose(
|
|
@@ -1524,16 +1541,16 @@ export class StandardController implements IController {
|
|
|
1524
1541
|
}
|
|
1525
1542
|
|
|
1526
1543
|
/**
|
|
1527
|
-
* Returns boolean indicating if this request can use the
|
|
1544
|
+
* Returns boolean indicating if this request can use the platform broker
|
|
1528
1545
|
* @param request
|
|
1529
1546
|
*/
|
|
1530
|
-
public
|
|
1547
|
+
public canUsePlatformBroker(
|
|
1531
1548
|
request: RedirectRequest | PopupRequest | SsoSilentRequest,
|
|
1532
1549
|
accountId?: string
|
|
1533
1550
|
): boolean {
|
|
1534
|
-
this.logger.trace("
|
|
1551
|
+
this.logger.trace("canUsePlatformBroker called");
|
|
1535
1552
|
if (
|
|
1536
|
-
!NativeMessageHandler.
|
|
1553
|
+
!NativeMessageHandler.isPlatformBrokerAvailable(
|
|
1537
1554
|
this.config,
|
|
1538
1555
|
this.logger,
|
|
1539
1556
|
this.nativeExtensionProvider,
|
|
@@ -1541,7 +1558,7 @@ export class StandardController implements IController {
|
|
|
1541
1558
|
)
|
|
1542
1559
|
) {
|
|
1543
1560
|
this.logger.trace(
|
|
1544
|
-
"
|
|
1561
|
+
"canUsePlatformBroker: isPlatformBrokerAvailable returned false, returning false"
|
|
1545
1562
|
);
|
|
1546
1563
|
return false;
|
|
1547
1564
|
}
|
|
@@ -1552,12 +1569,12 @@ export class StandardController implements IController {
|
|
|
1552
1569
|
case PromptValue.CONSENT:
|
|
1553
1570
|
case PromptValue.LOGIN:
|
|
1554
1571
|
this.logger.trace(
|
|
1555
|
-
"
|
|
1572
|
+
"canUsePlatformBroker: prompt is compatible with platform broker flow"
|
|
1556
1573
|
);
|
|
1557
1574
|
break;
|
|
1558
1575
|
default:
|
|
1559
1576
|
this.logger.trace(
|
|
1560
|
-
`
|
|
1577
|
+
`canUsePlatformBroker: prompt = ${request.prompt} is not compatible with platform broker flow, returning false`
|
|
1561
1578
|
);
|
|
1562
1579
|
return false;
|
|
1563
1580
|
}
|
|
@@ -1565,7 +1582,7 @@ export class StandardController implements IController {
|
|
|
1565
1582
|
|
|
1566
1583
|
if (!accountId && !this.getNativeAccountId(request)) {
|
|
1567
1584
|
this.logger.trace(
|
|
1568
|
-
"
|
|
1585
|
+
"canUsePlatformBroker: nativeAccountId is not available, returning false"
|
|
1569
1586
|
);
|
|
1570
1587
|
return false;
|
|
1571
1588
|
}
|
|
@@ -2254,7 +2271,7 @@ export class StandardController implements IController {
|
|
|
2254
2271
|
cacheLookupPolicy: CacheLookupPolicy
|
|
2255
2272
|
): Promise<AuthenticationResult> {
|
|
2256
2273
|
if (
|
|
2257
|
-
NativeMessageHandler.
|
|
2274
|
+
NativeMessageHandler.isPlatformBrokerAvailable(
|
|
2258
2275
|
this.config,
|
|
2259
2276
|
this.logger,
|
|
2260
2277
|
this.nativeExtensionProvider,
|
|
@@ -105,12 +105,13 @@ export class UnknownOperatingContextController implements IController {
|
|
|
105
105
|
this.config.cache,
|
|
106
106
|
this.browserCrypto,
|
|
107
107
|
this.logger,
|
|
108
|
-
|
|
109
|
-
|
|
108
|
+
this.performanceClient,
|
|
109
|
+
undefined
|
|
110
110
|
)
|
|
111
111
|
: DEFAULT_BROWSER_CACHE_MANAGER(
|
|
112
112
|
this.config.auth.clientId,
|
|
113
|
-
this.logger
|
|
113
|
+
this.logger,
|
|
114
|
+
this.performanceClient
|
|
114
115
|
);
|
|
115
116
|
}
|
|
116
117
|
getBrowserStorage(): BrowserCacheManager {
|
|
@@ -180,7 +181,7 @@ export class UnknownOperatingContextController implements IController {
|
|
|
180
181
|
| "codeChallenge"
|
|
181
182
|
| "codeChallengeMethod"
|
|
182
183
|
| "requestedClaimsHash"
|
|
183
|
-
| "
|
|
184
|
+
| "platformBroker"
|
|
184
185
|
>
|
|
185
186
|
>,
|
|
186
187
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
@@ -287,7 +288,7 @@ export class UnknownOperatingContextController implements IController {
|
|
|
287
288
|
| "codeChallenge"
|
|
288
289
|
| "codeChallengeMethod"
|
|
289
290
|
| "requestedClaimsHash"
|
|
290
|
-
| "
|
|
291
|
+
| "platformBroker"
|
|
291
292
|
>
|
|
292
293
|
>
|
|
293
294
|
): Promise<AuthenticationResult> {
|
|
@@ -58,7 +58,9 @@ const keygenAlgorithmOptions: RsaHashedKeyGenParams = {
|
|
|
58
58
|
/**
|
|
59
59
|
* Check whether browser crypto is available.
|
|
60
60
|
*/
|
|
61
|
-
export function validateCryptoAvailable(
|
|
61
|
+
export function validateCryptoAvailable(
|
|
62
|
+
skipValidateSubtleCrypto: boolean
|
|
63
|
+
): void {
|
|
62
64
|
if (!window) {
|
|
63
65
|
throw createBrowserAuthError(
|
|
64
66
|
BrowserAuthErrorCodes.nonBrowserEnvironment
|
|
@@ -67,7 +69,7 @@ export function validateCryptoAvailable(): void {
|
|
|
67
69
|
if (!window.crypto) {
|
|
68
70
|
throw createBrowserAuthError(BrowserAuthErrorCodes.cryptoNonExistent);
|
|
69
71
|
}
|
|
70
|
-
if (!window.crypto.subtle) {
|
|
72
|
+
if (!skipValidateSubtleCrypto && !window.crypto.subtle) {
|
|
71
73
|
throw createBrowserAuthError(
|
|
72
74
|
BrowserAuthErrorCodes.cryptoNonExistent,
|
|
73
75
|
SUBTLE_SUBERROR
|
package/src/crypto/CryptoOps.ts
CHANGED
|
@@ -50,10 +50,16 @@ export class CryptoOps implements ICrypto {
|
|
|
50
50
|
private static EXTRACTABLE: boolean = true;
|
|
51
51
|
private cache: AsyncMemoryStorage<CachedKeyPair>;
|
|
52
52
|
|
|
53
|
-
constructor(
|
|
53
|
+
constructor(
|
|
54
|
+
logger: Logger,
|
|
55
|
+
performanceClient?: IPerformanceClient,
|
|
56
|
+
skipValidateSubtleCrypto?: boolean
|
|
57
|
+
) {
|
|
54
58
|
this.logger = logger;
|
|
55
59
|
// Browser crypto needs to be validated first before any other classes can be set.
|
|
56
|
-
BrowserCrypto.validateCryptoAvailable(
|
|
60
|
+
BrowserCrypto.validateCryptoAvailable(
|
|
61
|
+
skipValidateSubtleCrypto ?? false
|
|
62
|
+
);
|
|
57
63
|
this.cache = new AsyncMemoryStorage<CachedKeyPair>(this.logger);
|
|
58
64
|
this.performanceClient = performanceClient;
|
|
59
65
|
}
|