@azure/msal-browser 3.3.0 → 3.5.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/app/IPublicClientApplication.mjs +1 -1
- package/dist/app/PublicClientApplication.d.ts.map +1 -1
- package/dist/app/PublicClientApplication.mjs +3 -4
- package/dist/app/PublicClientApplication.mjs.map +1 -1
- package/dist/app/PublicClientNext.d.ts.map +1 -1
- package/dist/app/PublicClientNext.mjs +4 -6
- package/dist/app/PublicClientNext.mjs.map +1 -1
- package/dist/broker/nativeBroker/NativeMessageHandler.mjs +1 -1
- package/dist/broker/nativeBroker/NativeStatusCodes.mjs +1 -1
- package/dist/cache/AsyncMemoryStorage.mjs +1 -1
- package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
- package/dist/cache/BrowserCacheManager.mjs +26 -26
- package/dist/cache/BrowserCacheManager.mjs.map +1 -1
- package/dist/cache/BrowserStorage.mjs +1 -1
- package/dist/cache/CryptoKeyStore.mjs +1 -1
- package/dist/cache/DatabaseStorage.mjs +1 -1
- package/dist/cache/MemoryStorage.mjs +1 -1
- package/dist/cache/TokenCache.d.ts.map +1 -1
- package/dist/cache/TokenCache.mjs +5 -5
- package/dist/cache/TokenCache.mjs.map +1 -1
- package/dist/config/Configuration.mjs +1 -1
- package/dist/controllers/ControllerFactory.d.ts +2 -8
- package/dist/controllers/ControllerFactory.d.ts.map +1 -1
- package/dist/controllers/ControllerFactory.mjs +21 -38
- package/dist/controllers/ControllerFactory.mjs.map +1 -1
- package/dist/controllers/IController.d.ts +1 -2
- package/dist/controllers/IController.d.ts.map +1 -1
- package/dist/controllers/NestedAppAuthController.mjs +1 -1
- package/dist/controllers/StandardController.d.ts +4 -4
- package/dist/controllers/StandardController.d.ts.map +1 -1
- package/dist/controllers/StandardController.mjs +50 -51
- package/dist/controllers/StandardController.mjs.map +1 -1
- package/dist/controllers/UnknownOperatingContextController.mjs +1 -1
- package/dist/crypto/BrowserCrypto.mjs +1 -1
- package/dist/crypto/CryptoOps.d.ts +2 -2
- package/dist/crypto/CryptoOps.d.ts.map +1 -1
- package/dist/crypto/CryptoOps.mjs +4 -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/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.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/interaction_client/BaseInteractionClient.d.ts +0 -1
- package/dist/interaction_client/BaseInteractionClient.d.ts.map +1 -1
- package/dist/interaction_client/BaseInteractionClient.mjs +2 -3
- package/dist/interaction_client/BaseInteractionClient.mjs.map +1 -1
- package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +1 -1
- package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
- package/dist/interaction_client/NativeInteractionClient.mjs +4 -4
- package/dist/interaction_client/NativeInteractionClient.mjs.map +1 -1
- package/dist/interaction_client/PopupClient.d.ts +1 -12
- package/dist/interaction_client/PopupClient.d.ts.map +1 -1
- package/dist/interaction_client/PopupClient.mjs +28 -111
- package/dist/interaction_client/PopupClient.mjs.map +1 -1
- package/dist/interaction_client/RedirectClient.d.ts +3 -3
- package/dist/interaction_client/RedirectClient.d.ts.map +1 -1
- package/dist/interaction_client/RedirectClient.mjs +59 -50
- package/dist/interaction_client/RedirectClient.mjs.map +1 -1
- package/dist/interaction_client/SilentAuthCodeClient.d.ts.map +1 -1
- package/dist/interaction_client/SilentAuthCodeClient.mjs +3 -5
- package/dist/interaction_client/SilentAuthCodeClient.mjs.map +1 -1
- package/dist/interaction_client/SilentCacheClient.mjs +1 -1
- package/dist/interaction_client/SilentIframeClient.d.ts.map +1 -1
- package/dist/interaction_client/SilentIframeClient.mjs +9 -23
- package/dist/interaction_client/SilentIframeClient.mjs.map +1 -1
- package/dist/interaction_client/SilentRefreshClient.d.ts.map +1 -1
- package/dist/interaction_client/SilentRefreshClient.mjs +2 -12
- package/dist/interaction_client/SilentRefreshClient.mjs.map +1 -1
- package/dist/interaction_client/StandardInteractionClient.d.ts +1 -6
- package/dist/interaction_client/StandardInteractionClient.d.ts.map +1 -1
- package/dist/interaction_client/StandardInteractionClient.mjs +2 -24
- package/dist/interaction_client/StandardInteractionClient.mjs.map +1 -1
- package/dist/interaction_handler/InteractionHandler.d.ts +6 -13
- package/dist/interaction_handler/InteractionHandler.d.ts.map +1 -1
- package/dist/interaction_handler/InteractionHandler.mjs +30 -61
- package/dist/interaction_handler/InteractionHandler.mjs.map +1 -1
- package/dist/interaction_handler/RedirectHandler.d.ts +14 -7
- package/dist/interaction_handler/RedirectHandler.d.ts.map +1 -1
- package/dist/interaction_handler/RedirectHandler.mjs +30 -15
- package/dist/interaction_handler/RedirectHandler.mjs.map +1 -1
- package/dist/interaction_handler/SilentHandler.d.ts +2 -2
- package/dist/interaction_handler/SilentHandler.d.ts.map +1 -1
- package/dist/interaction_handler/SilentHandler.mjs +13 -7
- package/dist/interaction_handler/SilentHandler.mjs.map +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/StandardOperatingContext.mjs +1 -1
- package/dist/operatingcontext/TeamsAppOperatingContext.mjs +1 -1
- package/dist/operatingcontext/UnknownOperatingContext.mjs +1 -1
- package/dist/packageMetadata.d.ts +1 -1
- package/dist/packageMetadata.mjs +2 -2
- package/dist/response/ResponseHandler.d.ts +8 -0
- package/dist/response/ResponseHandler.d.ts.map +1 -0
- package/dist/response/ResponseHandler.mjs +46 -0
- package/dist/response/ResponseHandler.mjs.map +1 -0
- 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.d.ts +7 -14
- package/dist/utils/BrowserProtocolUtils.d.ts.map +1 -1
- package/dist/utils/BrowserProtocolUtils.mjs +17 -30
- package/dist/utils/BrowserProtocolUtils.mjs.map +1 -1
- package/dist/utils/BrowserUtils.mjs +1 -1
- package/lib/msal-browser.cjs +18434 -61
- package/lib/msal-browser.cjs.map +1 -1
- package/lib/msal-browser.js +3037 -3733
- package/lib/msal-browser.js.map +1 -1
- package/lib/msal-browser.min.js +68 -66
- package/package.json +2 -2
- package/src/app/PublicClientApplication.ts +4 -3
- package/src/app/PublicClientNext.ts +7 -5
- package/src/cache/BrowserCacheManager.ts +29 -50
- package/src/cache/TokenCache.ts +5 -4
- package/src/controllers/ControllerFactory.ts +30 -49
- package/src/controllers/IController.ts +0 -6
- package/src/controllers/StandardController.ts +70 -85
- package/src/crypto/CryptoOps.ts +5 -3
- package/src/index.ts +1 -0
- package/src/interaction_client/BaseInteractionClient.ts +1 -2
- package/src/interaction_client/NativeInteractionClient.ts +4 -3
- package/src/interaction_client/PopupClient.ts +72 -196
- package/src/interaction_client/RedirectClient.ts +111 -100
- package/src/interaction_client/SilentAuthCodeClient.ts +1 -12
- package/src/interaction_client/SilentIframeClient.ts +17 -44
- package/src/interaction_client/SilentRefreshClient.ts +5 -19
- package/src/interaction_client/StandardInteractionClient.ts +2 -48
- package/src/interaction_handler/InteractionHandler.ts +39 -112
- package/src/interaction_handler/RedirectHandler.ts +52 -30
- package/src/interaction_handler/SilentHandler.ts +12 -5
- package/src/packageMetadata.ts +1 -1
- package/src/response/ResponseHandler.ts +73 -0
- package/src/utils/BrowserProtocolUtils.ts +17 -36
|
@@ -21,15 +21,13 @@ import {
|
|
|
21
21
|
PromptValue,
|
|
22
22
|
InProgressPerformanceEvent,
|
|
23
23
|
RequestThumbprint,
|
|
24
|
-
ServerError,
|
|
25
24
|
AccountEntity,
|
|
26
|
-
ServerResponseType,
|
|
27
|
-
UrlString,
|
|
28
25
|
invokeAsync,
|
|
29
26
|
createClientAuthError,
|
|
30
27
|
ClientAuthErrorCodes,
|
|
31
28
|
AccountFilter,
|
|
32
29
|
buildStaticAuthorityOptions,
|
|
30
|
+
InteractionRequiredAuthErrorCodes,
|
|
33
31
|
} from "@azure/msal-common";
|
|
34
32
|
import {
|
|
35
33
|
BrowserCacheManager,
|
|
@@ -336,16 +334,6 @@ export class StandardController implements IController {
|
|
|
336
334
|
// Block token acquisition before initialize has been called
|
|
337
335
|
BrowserUtils.blockAPICallsBeforeInitialize(this.initialized);
|
|
338
336
|
|
|
339
|
-
let foundServerResponse = hash;
|
|
340
|
-
|
|
341
|
-
if (
|
|
342
|
-
this.config.auth.OIDCOptions?.serverResponseType ===
|
|
343
|
-
ServerResponseType.QUERY
|
|
344
|
-
) {
|
|
345
|
-
const url = window.location.href;
|
|
346
|
-
foundServerResponse = UrlString.parseQueryServerResponse(url);
|
|
347
|
-
}
|
|
348
|
-
|
|
349
337
|
const loggedInAccounts = this.getAllAccounts();
|
|
350
338
|
if (this.isBrowserEnvironment) {
|
|
351
339
|
/**
|
|
@@ -353,8 +341,7 @@ export class StandardController implements IController {
|
|
|
353
341
|
* otherwise return the promise from the first invocation. Prevents race conditions when handleRedirectPromise is called
|
|
354
342
|
* several times concurrently.
|
|
355
343
|
*/
|
|
356
|
-
const redirectResponseKey =
|
|
357
|
-
foundServerResponse || Constants.EMPTY_STRING;
|
|
344
|
+
const redirectResponseKey = hash || "";
|
|
358
345
|
let response = this.redirectResponse.get(redirectResponseKey);
|
|
359
346
|
if (typeof response === "undefined") {
|
|
360
347
|
this.eventHandler.emitEvent(
|
|
@@ -376,7 +363,7 @@ export class StandardController implements IController {
|
|
|
376
363
|
this.nativeExtensionProvider
|
|
377
364
|
) &&
|
|
378
365
|
this.nativeExtensionProvider &&
|
|
379
|
-
!
|
|
366
|
+
!hash
|
|
380
367
|
) {
|
|
381
368
|
this.logger.trace(
|
|
382
369
|
"handleRedirectPromise - acquiring token from native platform"
|
|
@@ -408,9 +395,7 @@ export class StandardController implements IController {
|
|
|
408
395
|
const redirectClient =
|
|
409
396
|
this.createRedirectClient(correlationId);
|
|
410
397
|
redirectResponse =
|
|
411
|
-
redirectClient.handleRedirectPromise(
|
|
412
|
-
foundServerResponse
|
|
413
|
-
);
|
|
398
|
+
redirectClient.handleRedirectPromise(hash);
|
|
414
399
|
}
|
|
415
400
|
|
|
416
401
|
response = redirectResponse
|
|
@@ -533,7 +518,7 @@ export class StandardController implements IController {
|
|
|
533
518
|
this.nativeExtensionProvider,
|
|
534
519
|
this.getNativeAccountId(request),
|
|
535
520
|
this.nativeInternalStorage,
|
|
536
|
-
|
|
521
|
+
correlationId
|
|
537
522
|
);
|
|
538
523
|
result = nativeClient
|
|
539
524
|
.acquireTokenRedirect(request)
|
|
@@ -543,26 +528,22 @@ export class StandardController implements IController {
|
|
|
543
528
|
isFatalNativeAuthError(e)
|
|
544
529
|
) {
|
|
545
530
|
this.nativeExtensionProvider = undefined; // If extension gets uninstalled during session prevent future requests from continuing to attempt
|
|
546
|
-
const redirectClient =
|
|
547
|
-
|
|
548
|
-
);
|
|
531
|
+
const redirectClient =
|
|
532
|
+
this.createRedirectClient(correlationId);
|
|
549
533
|
return redirectClient.acquireToken(request);
|
|
550
534
|
} else if (e instanceof InteractionRequiredAuthError) {
|
|
551
535
|
this.logger.verbose(
|
|
552
536
|
"acquireTokenRedirect - Resolving interaction required error thrown by native broker by falling back to web flow"
|
|
553
537
|
);
|
|
554
|
-
const redirectClient =
|
|
555
|
-
|
|
556
|
-
);
|
|
538
|
+
const redirectClient =
|
|
539
|
+
this.createRedirectClient(correlationId);
|
|
557
540
|
return redirectClient.acquireToken(request);
|
|
558
541
|
}
|
|
559
542
|
this.getBrowserStorage().setInteractionInProgress(false);
|
|
560
543
|
throw e;
|
|
561
544
|
});
|
|
562
545
|
} else {
|
|
563
|
-
const redirectClient = this.createRedirectClient(
|
|
564
|
-
request.correlationId
|
|
565
|
-
);
|
|
546
|
+
const redirectClient = this.createRedirectClient(correlationId);
|
|
566
547
|
result = redirectClient.acquireToken(request);
|
|
567
548
|
}
|
|
568
549
|
|
|
@@ -632,7 +613,13 @@ export class StandardController implements IController {
|
|
|
632
613
|
let result: Promise<AuthenticationResult>;
|
|
633
614
|
|
|
634
615
|
if (this.canUseNative(request)) {
|
|
635
|
-
result = this.acquireTokenNative(
|
|
616
|
+
result = this.acquireTokenNative(
|
|
617
|
+
{
|
|
618
|
+
...request,
|
|
619
|
+
correlationId,
|
|
620
|
+
},
|
|
621
|
+
ApiId.acquireTokenPopup
|
|
622
|
+
)
|
|
636
623
|
.then((response) => {
|
|
637
624
|
this.getBrowserStorage().setInteractionInProgress(false);
|
|
638
625
|
atPopupMeasurement.end({
|
|
@@ -648,24 +635,22 @@ export class StandardController implements IController {
|
|
|
648
635
|
isFatalNativeAuthError(e)
|
|
649
636
|
) {
|
|
650
637
|
this.nativeExtensionProvider = undefined; // If extension gets uninstalled during session prevent future requests from continuing to attempt
|
|
651
|
-
const popupClient =
|
|
652
|
-
|
|
653
|
-
);
|
|
638
|
+
const popupClient =
|
|
639
|
+
this.createPopupClient(correlationId);
|
|
654
640
|
return popupClient.acquireToken(request);
|
|
655
641
|
} else if (e instanceof InteractionRequiredAuthError) {
|
|
656
642
|
this.logger.verbose(
|
|
657
643
|
"acquireTokenPopup - Resolving interaction required error thrown by native broker by falling back to web flow"
|
|
658
644
|
);
|
|
659
|
-
const popupClient =
|
|
660
|
-
|
|
661
|
-
);
|
|
645
|
+
const popupClient =
|
|
646
|
+
this.createPopupClient(correlationId);
|
|
662
647
|
return popupClient.acquireToken(request);
|
|
663
648
|
}
|
|
664
649
|
this.getBrowserStorage().setInteractionInProgress(false);
|
|
665
650
|
throw e;
|
|
666
651
|
});
|
|
667
652
|
} else {
|
|
668
|
-
const popupClient = this.createPopupClient(
|
|
653
|
+
const popupClient = this.createPopupClient(correlationId);
|
|
669
654
|
result = popupClient.acquireToken(request);
|
|
670
655
|
}
|
|
671
656
|
|
|
@@ -876,7 +861,7 @@ export class StandardController implements IController {
|
|
|
876
861
|
);
|
|
877
862
|
const atbcMeasurement = this.performanceClient.startMeasurement(
|
|
878
863
|
PerformanceEvents.AcquireTokenByCode,
|
|
879
|
-
|
|
864
|
+
correlationId
|
|
880
865
|
);
|
|
881
866
|
|
|
882
867
|
try {
|
|
@@ -934,7 +919,7 @@ export class StandardController implements IController {
|
|
|
934
919
|
} else {
|
|
935
920
|
this.logger.verbose(
|
|
936
921
|
"Existing acquireTokenByCode request found",
|
|
937
|
-
|
|
922
|
+
correlationId
|
|
938
923
|
);
|
|
939
924
|
atbcMeasurement.discard();
|
|
940
925
|
}
|
|
@@ -942,7 +927,10 @@ export class StandardController implements IController {
|
|
|
942
927
|
} else if (request.nativeAccountId) {
|
|
943
928
|
if (this.canUseNative(request, request.nativeAccountId)) {
|
|
944
929
|
return this.acquireTokenNative(
|
|
945
|
-
|
|
930
|
+
{
|
|
931
|
+
...request,
|
|
932
|
+
correlationId,
|
|
933
|
+
},
|
|
946
934
|
ApiId.acquireTokenByCode,
|
|
947
935
|
request.nativeAccountId
|
|
948
936
|
).catch((e: AuthError) => {
|
|
@@ -1047,13 +1035,13 @@ export class StandardController implements IController {
|
|
|
1047
1035
|
protected async acquireTokenFromCache(
|
|
1048
1036
|
silentCacheClient: SilentCacheClient,
|
|
1049
1037
|
commonRequest: CommonSilentFlowRequest,
|
|
1050
|
-
|
|
1038
|
+
cacheLookupPolicy: CacheLookupPolicy
|
|
1051
1039
|
): Promise<AuthenticationResult> {
|
|
1052
1040
|
this.performanceClient.addQueueMeasurement(
|
|
1053
1041
|
PerformanceEvents.AcquireTokenFromCache,
|
|
1054
1042
|
commonRequest.correlationId
|
|
1055
1043
|
);
|
|
1056
|
-
switch (
|
|
1044
|
+
switch (cacheLookupPolicy) {
|
|
1057
1045
|
case CacheLookupPolicy.Default:
|
|
1058
1046
|
case CacheLookupPolicy.AccessToken:
|
|
1059
1047
|
case CacheLookupPolicy.AccessTokenAndRefreshToken:
|
|
@@ -1074,18 +1062,18 @@ export class StandardController implements IController {
|
|
|
1074
1062
|
/**
|
|
1075
1063
|
* Attempt to acquire an access token via a refresh token
|
|
1076
1064
|
* @param commonRequest CommonSilentFlowRequest
|
|
1077
|
-
* @param
|
|
1065
|
+
* @param cacheLookupPolicy CacheLookupPolicy
|
|
1078
1066
|
* @returns A promise that, when resolved, returns the access token
|
|
1079
1067
|
*/
|
|
1080
1068
|
public async acquireTokenByRefreshToken(
|
|
1081
1069
|
commonRequest: CommonSilentFlowRequest,
|
|
1082
|
-
|
|
1070
|
+
cacheLookupPolicy: CacheLookupPolicy
|
|
1083
1071
|
): Promise<AuthenticationResult> {
|
|
1084
1072
|
this.performanceClient.addQueueMeasurement(
|
|
1085
1073
|
PerformanceEvents.AcquireTokenByRefreshToken,
|
|
1086
1074
|
commonRequest.correlationId
|
|
1087
1075
|
);
|
|
1088
|
-
switch (
|
|
1076
|
+
switch (cacheLookupPolicy) {
|
|
1089
1077
|
case CacheLookupPolicy.Default:
|
|
1090
1078
|
case CacheLookupPolicy.AccessTokenAndRefreshToken:
|
|
1091
1079
|
case CacheLookupPolicy.RefreshToken:
|
|
@@ -1911,6 +1899,7 @@ export class StandardController implements IController {
|
|
|
1911
1899
|
resourceRequestUri: request.resourceRequestUri,
|
|
1912
1900
|
shrClaims: request.shrClaims,
|
|
1913
1901
|
sshKid: request.sshKid,
|
|
1902
|
+
shrOptions: request.shrOptions,
|
|
1914
1903
|
};
|
|
1915
1904
|
const silentRequestKey = JSON.stringify(thumbprint);
|
|
1916
1905
|
|
|
@@ -2055,12 +2044,8 @@ export class StandardController implements IController {
|
|
|
2055
2044
|
request.correlationId
|
|
2056
2045
|
)(request, account);
|
|
2057
2046
|
|
|
2058
|
-
const
|
|
2059
|
-
|
|
2060
|
-
// set the request's CacheLookupPolicy to Default if it was not optionally passed in
|
|
2061
|
-
cacheLookupPolicy:
|
|
2062
|
-
request.cacheLookupPolicy || CacheLookupPolicy.Default,
|
|
2063
|
-
};
|
|
2047
|
+
const cacheLookupPolicy =
|
|
2048
|
+
request.cacheLookupPolicy || CacheLookupPolicy.Default;
|
|
2064
2049
|
|
|
2065
2050
|
result = invokeAsync(
|
|
2066
2051
|
this.acquireTokenFromCache.bind(this),
|
|
@@ -2068,10 +2053,10 @@ export class StandardController implements IController {
|
|
|
2068
2053
|
this.logger,
|
|
2069
2054
|
this.performanceClient,
|
|
2070
2055
|
silentRequest.correlationId
|
|
2071
|
-
)(silentCacheClient, silentRequest,
|
|
2056
|
+
)(silentCacheClient, silentRequest, cacheLookupPolicy).catch(
|
|
2072
2057
|
(cacheError: AuthError) => {
|
|
2073
2058
|
if (
|
|
2074
|
-
|
|
2059
|
+
request.cacheLookupPolicy ===
|
|
2075
2060
|
CacheLookupPolicy.AccessToken
|
|
2076
2061
|
) {
|
|
2077
2062
|
throw cacheError;
|
|
@@ -2091,42 +2076,42 @@ export class StandardController implements IController {
|
|
|
2091
2076
|
this.logger,
|
|
2092
2077
|
this.performanceClient,
|
|
2093
2078
|
silentRequest.correlationId
|
|
2094
|
-
)(silentRequest,
|
|
2079
|
+
)(silentRequest, cacheLookupPolicy).catch(
|
|
2095
2080
|
(refreshTokenError: AuthError) => {
|
|
2096
|
-
const
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2081
|
+
const isSilentlyResolvable =
|
|
2082
|
+
(!(
|
|
2083
|
+
refreshTokenError instanceof
|
|
2084
|
+
InteractionRequiredAuthError
|
|
2085
|
+
) &&
|
|
2086
|
+
(refreshTokenError.errorCode ===
|
|
2087
|
+
BrowserConstants.INVALID_GRANT_ERROR ||
|
|
2088
|
+
refreshTokenError.errorCode ===
|
|
2089
|
+
ClientAuthErrorCodes.tokenRefreshRequired)) ||
|
|
2102
2090
|
refreshTokenError.errorCode ===
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
CacheLookupPolicy.
|
|
2115
|
-
|
|
2091
|
+
InteractionRequiredAuthErrorCodes.noTokensFound;
|
|
2092
|
+
|
|
2093
|
+
const tryIframeRenewal =
|
|
2094
|
+
cacheLookupPolicy ===
|
|
2095
|
+
CacheLookupPolicy.Default ||
|
|
2096
|
+
cacheLookupPolicy === CacheLookupPolicy.Skip ||
|
|
2097
|
+
cacheLookupPolicy ===
|
|
2098
|
+
CacheLookupPolicy.RefreshTokenAndNetwork;
|
|
2099
|
+
|
|
2100
|
+
if (isSilentlyResolvable && tryIframeRenewal) {
|
|
2101
|
+
this.logger.verbose(
|
|
2102
|
+
"Refresh token expired/invalid or CacheLookupPolicy is set to Skip, attempting acquire token by iframe.",
|
|
2103
|
+
request.correlationId
|
|
2104
|
+
);
|
|
2105
|
+
return invokeAsync(
|
|
2106
|
+
this.acquireTokenBySilentIframe.bind(this),
|
|
2107
|
+
PerformanceEvents.AcquireTokenBySilentIframe,
|
|
2108
|
+
this.logger,
|
|
2109
|
+
this.performanceClient,
|
|
2110
|
+
silentRequest.correlationId
|
|
2111
|
+
)(silentRequest);
|
|
2112
|
+
} else {
|
|
2116
2113
|
throw refreshTokenError;
|
|
2117
2114
|
}
|
|
2118
|
-
|
|
2119
|
-
this.logger.verbose(
|
|
2120
|
-
"Refresh token expired/invalid or CacheLookupPolicy is set to Skip, attempting acquire token by iframe.",
|
|
2121
|
-
request.correlationId
|
|
2122
|
-
);
|
|
2123
|
-
return invokeAsync(
|
|
2124
|
-
this.acquireTokenBySilentIframe.bind(this),
|
|
2125
|
-
PerformanceEvents.AcquireTokenBySilentIframe,
|
|
2126
|
-
this.logger,
|
|
2127
|
-
this.performanceClient,
|
|
2128
|
-
silentRequest.correlationId
|
|
2129
|
-
)(silentRequest);
|
|
2130
2115
|
}
|
|
2131
2116
|
);
|
|
2132
2117
|
}
|
package/src/crypto/CryptoOps.ts
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
JoseHeader,
|
|
10
10
|
Logger,
|
|
11
11
|
PerformanceEvents,
|
|
12
|
+
ShrOptions,
|
|
12
13
|
SignedHttpRequest,
|
|
13
14
|
SignedHttpRequestParameters,
|
|
14
15
|
} from "@azure/msal-common";
|
|
@@ -161,6 +162,7 @@ export class CryptoOps implements ICrypto {
|
|
|
161
162
|
async signJwt(
|
|
162
163
|
payload: SignedHttpRequest,
|
|
163
164
|
kid: string,
|
|
165
|
+
shrOptions?: ShrOptions,
|
|
164
166
|
correlationId?: string
|
|
165
167
|
): Promise<string> {
|
|
166
168
|
const signJwtMeasurement = this.performanceClient?.startMeasurement(
|
|
@@ -180,15 +182,15 @@ export class CryptoOps implements ICrypto {
|
|
|
180
182
|
cachedKeyPair.publicKey
|
|
181
183
|
);
|
|
182
184
|
const publicKeyJwkString = getSortedObjectString(publicKeyJwk);
|
|
183
|
-
|
|
184
185
|
// Base64URL encode public key thumbprint with keyId only: BASE64URL({ kid: "FULL_PUBLIC_KEY_HASH" })
|
|
185
186
|
const encodedKeyIdThumbprint = urlEncode(JSON.stringify({ kid: kid }));
|
|
186
|
-
|
|
187
187
|
// Generate header
|
|
188
188
|
const shrHeader = JoseHeader.getShrHeaderString({
|
|
189
|
-
|
|
189
|
+
...shrOptions?.header,
|
|
190
190
|
alg: publicKeyJwk.alg,
|
|
191
|
+
kid: encodedKeyIdThumbprint,
|
|
191
192
|
});
|
|
193
|
+
|
|
192
194
|
const encodedShrHeader = urlEncode(shrHeader);
|
|
193
195
|
|
|
194
196
|
// Generate payload
|
package/src/index.ts
CHANGED
|
@@ -141,7 +141,7 @@ export abstract class BaseInteractionClient {
|
|
|
141
141
|
): Promise<BaseAuthRequest> {
|
|
142
142
|
this.performanceClient.addQueueMeasurement(
|
|
143
143
|
PerformanceEvents.InitializeBaseRequest,
|
|
144
|
-
|
|
144
|
+
this.correlationId
|
|
145
145
|
);
|
|
146
146
|
const authority = request.authority || this.config.auth.authority;
|
|
147
147
|
|
|
@@ -266,7 +266,6 @@ export abstract class BaseInteractionClient {
|
|
|
266
266
|
/**
|
|
267
267
|
* Used to get a discovered version of the default authority.
|
|
268
268
|
* @param requestAuthority
|
|
269
|
-
* @param requestCorrelationId
|
|
270
269
|
*/
|
|
271
270
|
protected async getDiscoveredAuthority(
|
|
272
271
|
requestAuthority?: string
|
|
@@ -33,6 +33,7 @@ import {
|
|
|
33
33
|
invokeAsync,
|
|
34
34
|
createAuthError,
|
|
35
35
|
AuthErrorCodes,
|
|
36
|
+
CacheHelpers,
|
|
36
37
|
} from "@azure/msal-common";
|
|
37
38
|
import { BaseInteractionClient } from "./BaseInteractionClient";
|
|
38
39
|
import { BrowserConfiguration } from "../config/Configuration";
|
|
@@ -656,7 +657,7 @@ export class NativeInteractionClient extends BaseInteractionClient {
|
|
|
656
657
|
reqTimestamp: number
|
|
657
658
|
): void {
|
|
658
659
|
const cachedIdToken: IdTokenEntity | null =
|
|
659
|
-
|
|
660
|
+
CacheHelpers.createIdTokenEntity(
|
|
660
661
|
homeAccountIdentifier,
|
|
661
662
|
request.authority,
|
|
662
663
|
response.id_token || "",
|
|
@@ -675,7 +676,7 @@ export class NativeInteractionClient extends BaseInteractionClient {
|
|
|
675
676
|
const responseScopes = this.generateScopes(response, request);
|
|
676
677
|
|
|
677
678
|
const cachedAccessToken: AccessTokenEntity | null =
|
|
678
|
-
|
|
679
|
+
CacheHelpers.createAccessTokenEntity(
|
|
679
680
|
homeAccountIdentifier,
|
|
680
681
|
request.authority,
|
|
681
682
|
responseAccessToken,
|
|
@@ -684,7 +685,7 @@ export class NativeInteractionClient extends BaseInteractionClient {
|
|
|
684
685
|
responseScopes.printScopes(),
|
|
685
686
|
tokenExpirationSeconds,
|
|
686
687
|
0,
|
|
687
|
-
|
|
688
|
+
base64Decode
|
|
688
689
|
);
|
|
689
690
|
|
|
690
691
|
const nativeCacheRecord = new CacheRecord(
|