@azure/msal-browser 3.9.0 → 3.11.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.mjs +1 -1
- package/dist/app/PublicClientNext.mjs +1 -1
- package/dist/broker/nativeBroker/NativeMessageHandler.mjs +1 -1
- package/dist/broker/nativeBroker/NativeStatusCodes.mjs +1 -1
- package/dist/cache/AsyncMemoryStorage.d.ts +2 -3
- package/dist/cache/AsyncMemoryStorage.d.ts.map +1 -1
- package/dist/cache/AsyncMemoryStorage.mjs +4 -5
- package/dist/cache/AsyncMemoryStorage.mjs.map +1 -1
- package/dist/cache/BrowserCacheManager.d.ts +8 -27
- package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
- package/dist/cache/BrowserCacheManager.mjs +48 -75
- package/dist/cache/BrowserCacheManager.mjs.map +1 -1
- package/dist/cache/BrowserStorage.mjs +1 -1
- package/dist/cache/DatabaseStorage.d.ts +1 -1
- package/dist/cache/DatabaseStorage.d.ts.map +1 -1
- package/dist/cache/DatabaseStorage.mjs +14 -4
- package/dist/cache/DatabaseStorage.mjs.map +1 -1
- package/dist/cache/{IAsyncMemoryStorage.d.ts → IAsyncStorage.d.ts} +1 -1
- package/dist/cache/IAsyncStorage.d.ts.map +1 -0
- package/dist/cache/MemoryStorage.mjs +1 -1
- package/dist/cache/TokenCache.mjs +1 -1
- package/dist/config/Configuration.mjs +1 -1
- package/dist/controllers/ControllerFactory.mjs +1 -1
- package/dist/controllers/IController.d.ts +1 -3
- package/dist/controllers/IController.d.ts.map +1 -1
- package/dist/controllers/NestedAppAuthController.d.ts +2 -3
- package/dist/controllers/NestedAppAuthController.d.ts.map +1 -1
- package/dist/controllers/NestedAppAuthController.mjs +21 -19
- package/dist/controllers/NestedAppAuthController.mjs.map +1 -1
- package/dist/controllers/StandardController.d.ts +5 -23
- package/dist/controllers/StandardController.d.ts.map +1 -1
- package/dist/controllers/StandardController.mjs +47 -127
- package/dist/controllers/StandardController.mjs.map +1 -1
- package/dist/controllers/UnknownOperatingContextController.d.ts +1 -2
- package/dist/controllers/UnknownOperatingContextController.d.ts.map +1 -1
- package/dist/controllers/UnknownOperatingContextController.mjs +28 -36
- package/dist/controllers/UnknownOperatingContextController.mjs.map +1 -1
- package/dist/crypto/BrowserCrypto.d.ts +5 -0
- package/dist/crypto/BrowserCrypto.d.ts.map +1 -1
- package/dist/crypto/BrowserCrypto.mjs +12 -2
- package/dist/crypto/BrowserCrypto.mjs.map +1 -1
- package/dist/crypto/CryptoOps.d.ts.map +1 -1
- package/dist/crypto/CryptoOps.mjs +28 -12
- 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 +1 -6
- package/dist/interaction_client/BaseInteractionClient.d.ts.map +1 -1
- package/dist/interaction_client/BaseInteractionClient.mjs +2 -43
- 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 +18 -6
- package/dist/interaction_client/NativeInteractionClient.mjs.map +1 -1
- package/dist/interaction_client/PopupClient.mjs +1 -1
- package/dist/interaction_client/RedirectClient.mjs +1 -1
- package/dist/interaction_client/SilentAuthCodeClient.mjs +1 -1
- package/dist/interaction_client/SilentCacheClient.d.ts +1 -9
- package/dist/interaction_client/SilentCacheClient.d.ts.map +1 -1
- package/dist/interaction_client/SilentCacheClient.mjs +3 -22
- package/dist/interaction_client/SilentCacheClient.mjs.map +1 -1
- package/dist/interaction_client/SilentIframeClient.d.ts.map +1 -1
- package/dist/interaction_client/SilentIframeClient.mjs +14 -11
- 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 +3 -2
- package/dist/interaction_client/SilentRefreshClient.mjs.map +1 -1
- package/dist/interaction_client/StandardInteractionClient.d.ts.map +1 -1
- package/dist/interaction_client/StandardInteractionClient.mjs +3 -2
- package/dist/interaction_client/StandardInteractionClient.mjs.map +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.d.ts +3 -1
- package/dist/naa/mapping/NestedAppAuthAdapter.d.ts.map +1 -1
- package/dist/naa/mapping/NestedAppAuthAdapter.mjs +4 -3
- package/dist/naa/mapping/NestedAppAuthAdapter.mjs.map +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.d.ts.map +1 -1
- package/dist/packageMetadata.mjs +2 -2
- package/dist/request/RequestHelpers.d.ts +14 -0
- package/dist/request/RequestHelpers.d.ts.map +1 -0
- package/dist/request/RequestHelpers.mjs +61 -0
- package/dist/request/RequestHelpers.mjs.map +1 -0
- package/dist/response/ResponseHandler.mjs +1 -1
- package/dist/telemetry/BrowserPerformanceClient.d.ts +1 -1
- package/dist/telemetry/BrowserPerformanceClient.d.ts.map +1 -1
- package/dist/telemetry/BrowserPerformanceClient.mjs +7 -6
- package/dist/telemetry/BrowserPerformanceClient.mjs.map +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 +19 -3
- package/dist/utils/BrowserUtils.d.ts.map +1 -1
- package/dist/utils/BrowserUtils.mjs +45 -10
- package/dist/utils/BrowserUtils.mjs.map +1 -1
- package/lib/msal-browser.cjs +1116 -808
- package/lib/msal-browser.cjs.map +1 -1
- package/lib/msal-browser.js +1116 -808
- package/lib/msal-browser.js.map +1 -1
- package/lib/msal-browser.min.js +66 -66
- package/package.json +2 -2
- package/src/cache/AsyncMemoryStorage.ts +4 -6
- package/src/cache/BrowserCacheManager.ts +54 -90
- package/src/cache/DatabaseStorage.ts +14 -4
- package/src/controllers/IController.ts +1 -7
- package/src/controllers/NestedAppAuthController.ts +38 -23
- package/src/controllers/StandardController.ts +107 -179
- package/src/controllers/UnknownOperatingContextController.ts +28 -37
- package/src/crypto/BrowserCrypto.ts +11 -0
- package/src/crypto/CryptoOps.ts +31 -13
- package/src/index.ts +2 -0
- package/src/interaction_client/BaseInteractionClient.ts +0 -66
- package/src/interaction_client/NativeInteractionClient.ts +28 -9
- package/src/interaction_client/SilentCacheClient.ts +11 -51
- package/src/interaction_client/SilentIframeClient.ts +15 -16
- package/src/interaction_client/SilentRefreshClient.ts +3 -2
- package/src/interaction_client/StandardInteractionClient.ts +8 -2
- package/src/naa/mapping/NestedAppAuthAdapter.ts +10 -2
- package/src/packageMetadata.ts +1 -1
- package/src/request/RequestHelpers.ts +112 -0
- package/src/telemetry/BrowserPerformanceClient.ts +20 -10
- package/src/utils/BrowserUtils.ts +59 -15
- package/dist/cache/CryptoKeyStore.d.ts +0 -19
- package/dist/cache/CryptoKeyStore.d.ts.map +0 -1
- package/dist/cache/CryptoKeyStore.mjs +0 -47
- package/dist/cache/CryptoKeyStore.mjs.map +0 -1
- package/dist/cache/IAsyncMemoryStorage.d.ts.map +0 -1
- package/src/cache/CryptoKeyStore.ts +0 -63
- /package/src/cache/{IAsyncMemoryStorage.ts → IAsyncStorage.ts} +0 -0
|
@@ -52,10 +52,6 @@ import { SsoSilentRequest } from "../request/SsoSilentRequest";
|
|
|
52
52
|
import { EventCallbackFunction, EventError } from "../event/EventMessage";
|
|
53
53
|
import { EventType } from "../event/EventType";
|
|
54
54
|
import { EndSessionRequest } from "../request/EndSessionRequest";
|
|
55
|
-
import {
|
|
56
|
-
BrowserConfigurationAuthErrorCodes,
|
|
57
|
-
createBrowserConfigurationAuthError,
|
|
58
|
-
} from "../error/BrowserConfigurationAuthError";
|
|
59
55
|
import { EndSessionPopupRequest } from "../request/EndSessionPopupRequest";
|
|
60
56
|
import { INavigationClient } from "../navigation/INavigationClient";
|
|
61
57
|
import { EventHandler } from "../event/EventHandler";
|
|
@@ -86,6 +82,7 @@ import { IController } from "./IController";
|
|
|
86
82
|
import { AuthenticationResult } from "../response/AuthenticationResult";
|
|
87
83
|
import { ClearCacheRequest } from "../request/ClearCacheRequest";
|
|
88
84
|
import { createNewGuid } from "../crypto/BrowserCrypto";
|
|
85
|
+
import { initializeSilentRequest } from "../request/RequestHelpers";
|
|
89
86
|
|
|
90
87
|
export class StandardController implements IController {
|
|
91
88
|
// OperatingContext
|
|
@@ -143,7 +140,6 @@ export class StandardController implements IController {
|
|
|
143
140
|
string,
|
|
144
141
|
Promise<AuthenticationResult>
|
|
145
142
|
>;
|
|
146
|
-
private atsAsyncMeasurement?: InProgressPerformanceEvent = undefined;
|
|
147
143
|
|
|
148
144
|
private ssoSilentMeasurement?: InProgressPerformanceEvent;
|
|
149
145
|
private acquireTokenByCodeAsyncMeasurement?: InProgressPerformanceEvent;
|
|
@@ -257,14 +253,15 @@ export class StandardController implements IController {
|
|
|
257
253
|
return controller;
|
|
258
254
|
}
|
|
259
255
|
|
|
260
|
-
private trackPageVisibility(): void {
|
|
261
|
-
if (!
|
|
256
|
+
private trackPageVisibility(correlationId?: string): void {
|
|
257
|
+
if (!correlationId) {
|
|
262
258
|
return;
|
|
263
259
|
}
|
|
264
260
|
this.logger.info("Perf: Visibility change detected");
|
|
265
|
-
this.
|
|
266
|
-
visibilityChangeCount: 1,
|
|
267
|
-
|
|
261
|
+
this.performanceClient.incrementFields(
|
|
262
|
+
{ visibilityChangeCount: 1 },
|
|
263
|
+
correlationId
|
|
264
|
+
);
|
|
268
265
|
}
|
|
269
266
|
|
|
270
267
|
/**
|
|
@@ -483,17 +480,13 @@ export class StandardController implements IController {
|
|
|
483
480
|
EventType.HANDLE_REDIRECT_END,
|
|
484
481
|
InteractionType.Redirect
|
|
485
482
|
);
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
errorCode: eventError.errorCode,
|
|
490
|
-
subErrorCode: eventError.subError,
|
|
491
|
-
});
|
|
492
|
-
} else {
|
|
493
|
-
rootMeasurement.end({
|
|
483
|
+
|
|
484
|
+
rootMeasurement.end(
|
|
485
|
+
{
|
|
494
486
|
success: false,
|
|
495
|
-
}
|
|
496
|
-
|
|
487
|
+
},
|
|
488
|
+
eventError
|
|
489
|
+
);
|
|
497
490
|
|
|
498
491
|
throw e;
|
|
499
492
|
});
|
|
@@ -525,7 +518,8 @@ export class StandardController implements IController {
|
|
|
525
518
|
// Preflight request
|
|
526
519
|
const correlationId = this.getRequestCorrelationId(request);
|
|
527
520
|
this.logger.verbose("acquireTokenRedirect called", correlationId);
|
|
528
|
-
|
|
521
|
+
BrowserUtils.redirectPreflightCheck(this.initialized, this.config);
|
|
522
|
+
this.browserStorage.setInteractionInProgress(true);
|
|
529
523
|
|
|
530
524
|
// If logged in, emit acquire token events
|
|
531
525
|
const isLoggedIn = this.getAllAccounts().length > 0;
|
|
@@ -579,7 +573,7 @@ export class StandardController implements IController {
|
|
|
579
573
|
this.createRedirectClient(correlationId);
|
|
580
574
|
return redirectClient.acquireToken(request);
|
|
581
575
|
}
|
|
582
|
-
this.
|
|
576
|
+
this.browserStorage.setInteractionInProgress(false);
|
|
583
577
|
throw e;
|
|
584
578
|
});
|
|
585
579
|
} else {
|
|
@@ -628,7 +622,8 @@ export class StandardController implements IController {
|
|
|
628
622
|
|
|
629
623
|
try {
|
|
630
624
|
this.logger.verbose("acquireTokenPopup called", correlationId);
|
|
631
|
-
|
|
625
|
+
BrowserUtils.preflightCheck(this.initialized);
|
|
626
|
+
this.browserStorage.setInteractionInProgress(true);
|
|
632
627
|
} catch (e) {
|
|
633
628
|
// Since this function is syncronous we need to reject
|
|
634
629
|
return Promise.reject(e);
|
|
@@ -661,7 +656,7 @@ export class StandardController implements IController {
|
|
|
661
656
|
ApiId.acquireTokenPopup
|
|
662
657
|
)
|
|
663
658
|
.then((response) => {
|
|
664
|
-
this.
|
|
659
|
+
this.browserStorage.setInteractionInProgress(false);
|
|
665
660
|
atPopupMeasurement.end({
|
|
666
661
|
success: true,
|
|
667
662
|
isNativeBroker: true,
|
|
@@ -686,7 +681,7 @@ export class StandardController implements IController {
|
|
|
686
681
|
this.createPopupClient(correlationId);
|
|
687
682
|
return popupClient.acquireToken(request);
|
|
688
683
|
}
|
|
689
|
-
this.
|
|
684
|
+
this.browserStorage.setInteractionInProgress(false);
|
|
690
685
|
throw e;
|
|
691
686
|
});
|
|
692
687
|
} else {
|
|
@@ -725,7 +720,7 @@ export class StandardController implements IController {
|
|
|
725
720
|
});
|
|
726
721
|
return result;
|
|
727
722
|
})
|
|
728
|
-
.catch((e:
|
|
723
|
+
.catch((e: Error) => {
|
|
729
724
|
if (loggedInAccounts.length > 0) {
|
|
730
725
|
this.eventHandler.emitEvent(
|
|
731
726
|
EventType.ACQUIRE_TOKEN_FAILURE,
|
|
@@ -742,11 +737,13 @@ export class StandardController implements IController {
|
|
|
742
737
|
);
|
|
743
738
|
}
|
|
744
739
|
|
|
745
|
-
atPopupMeasurement.end(
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
740
|
+
atPopupMeasurement.end(
|
|
741
|
+
{
|
|
742
|
+
success: false,
|
|
743
|
+
},
|
|
744
|
+
e
|
|
745
|
+
);
|
|
746
|
+
|
|
750
747
|
// Since this function is syncronous we need to reject
|
|
751
748
|
return Promise.reject(e);
|
|
752
749
|
});
|
|
@@ -795,7 +792,7 @@ export class StandardController implements IController {
|
|
|
795
792
|
prompt: request.prompt,
|
|
796
793
|
correlationId: correlationId,
|
|
797
794
|
};
|
|
798
|
-
|
|
795
|
+
BrowserUtils.preflightCheck(this.initialized);
|
|
799
796
|
this.ssoSilentMeasurement = this.performanceClient.startMeasurement(
|
|
800
797
|
PerformanceEvents.SsoSilent,
|
|
801
798
|
correlationId
|
|
@@ -856,18 +853,19 @@ export class StandardController implements IController {
|
|
|
856
853
|
});
|
|
857
854
|
return response;
|
|
858
855
|
})
|
|
859
|
-
.catch((e:
|
|
856
|
+
.catch((e: Error) => {
|
|
860
857
|
this.eventHandler.emitEvent(
|
|
861
858
|
EventType.SSO_SILENT_FAILURE,
|
|
862
859
|
InteractionType.Silent,
|
|
863
860
|
null,
|
|
864
861
|
e
|
|
865
862
|
);
|
|
866
|
-
this.ssoSilentMeasurement?.end(
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
863
|
+
this.ssoSilentMeasurement?.end(
|
|
864
|
+
{
|
|
865
|
+
success: false,
|
|
866
|
+
},
|
|
867
|
+
e
|
|
868
|
+
);
|
|
871
869
|
throw e;
|
|
872
870
|
})
|
|
873
871
|
.finally(() => {
|
|
@@ -892,8 +890,8 @@ export class StandardController implements IController {
|
|
|
892
890
|
request: AuthorizationCodeRequest
|
|
893
891
|
): Promise<AuthenticationResult> {
|
|
894
892
|
const correlationId = this.getRequestCorrelationId(request);
|
|
895
|
-
this.preflightBrowserEnvironmentCheck(InteractionType.Silent);
|
|
896
893
|
this.logger.trace("acquireTokenByCode called", correlationId);
|
|
894
|
+
BrowserUtils.preflightCheck(this.initialized);
|
|
897
895
|
this.eventHandler.emitEvent(
|
|
898
896
|
EventType.ACQUIRE_TOKEN_BY_CODE_START,
|
|
899
897
|
InteractionType.Silent,
|
|
@@ -940,7 +938,7 @@ export class StandardController implements IController {
|
|
|
940
938
|
});
|
|
941
939
|
return result;
|
|
942
940
|
})
|
|
943
|
-
.catch((error:
|
|
941
|
+
.catch((error: Error) => {
|
|
944
942
|
this.hybridAuthCodeResponses.delete(hybridAuthCode);
|
|
945
943
|
this.eventHandler.emitEvent(
|
|
946
944
|
EventType.ACQUIRE_TOKEN_BY_CODE_FAILURE,
|
|
@@ -948,11 +946,12 @@ export class StandardController implements IController {
|
|
|
948
946
|
null,
|
|
949
947
|
error
|
|
950
948
|
);
|
|
951
|
-
atbcMeasurement.end(
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
949
|
+
atbcMeasurement.end(
|
|
950
|
+
{
|
|
951
|
+
success: false,
|
|
952
|
+
},
|
|
953
|
+
error
|
|
954
|
+
);
|
|
956
955
|
throw error;
|
|
957
956
|
});
|
|
958
957
|
this.hybridAuthCodeResponses.set(hybridAuthCode, response);
|
|
@@ -1000,12 +999,12 @@ export class StandardController implements IController {
|
|
|
1000
999
|
null,
|
|
1001
1000
|
e as EventError
|
|
1002
1001
|
);
|
|
1003
|
-
atbcMeasurement.end(
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1002
|
+
atbcMeasurement.end(
|
|
1003
|
+
{
|
|
1004
|
+
success: false,
|
|
1005
|
+
},
|
|
1006
|
+
e
|
|
1007
|
+
);
|
|
1009
1008
|
throw e;
|
|
1010
1009
|
}
|
|
1011
1010
|
}
|
|
@@ -1048,12 +1047,13 @@ export class StandardController implements IController {
|
|
|
1048
1047
|
});
|
|
1049
1048
|
return response;
|
|
1050
1049
|
})
|
|
1051
|
-
.catch((tokenRenewalError:
|
|
1052
|
-
this.acquireTokenByCodeAsyncMeasurement?.end(
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1050
|
+
.catch((tokenRenewalError: Error) => {
|
|
1051
|
+
this.acquireTokenByCodeAsyncMeasurement?.end(
|
|
1052
|
+
{
|
|
1053
|
+
success: false,
|
|
1054
|
+
},
|
|
1055
|
+
tokenRenewalError
|
|
1056
|
+
);
|
|
1057
1057
|
throw tokenRenewalError;
|
|
1058
1058
|
})
|
|
1059
1059
|
.finally(() => {
|
|
@@ -1073,7 +1073,6 @@ export class StandardController implements IController {
|
|
|
1073
1073
|
* @returns A promise that, when resolved, returns the access token
|
|
1074
1074
|
*/
|
|
1075
1075
|
protected async acquireTokenFromCache(
|
|
1076
|
-
silentCacheClient: SilentCacheClient,
|
|
1077
1076
|
commonRequest: CommonSilentFlowRequest,
|
|
1078
1077
|
cacheLookupPolicy: CacheLookupPolicy
|
|
1079
1078
|
): Promise<AuthenticationResult> {
|
|
@@ -1085,6 +1084,9 @@ export class StandardController implements IController {
|
|
|
1085
1084
|
case CacheLookupPolicy.Default:
|
|
1086
1085
|
case CacheLookupPolicy.AccessToken:
|
|
1087
1086
|
case CacheLookupPolicy.AccessTokenAndRefreshToken:
|
|
1087
|
+
const silentCacheClient = this.createSilentCacheClient(
|
|
1088
|
+
commonRequest.correlationId
|
|
1089
|
+
);
|
|
1088
1090
|
return invokeAsync(
|
|
1089
1091
|
silentCacheClient.acquireToken.bind(silentCacheClient),
|
|
1090
1092
|
PerformanceEvents.SilentCacheClientAcquireToken,
|
|
@@ -1190,7 +1192,8 @@ export class StandardController implements IController {
|
|
|
1190
1192
|
*/
|
|
1191
1193
|
async logoutRedirect(logoutRequest?: EndSessionRequest): Promise<void> {
|
|
1192
1194
|
const correlationId = this.getRequestCorrelationId(logoutRequest);
|
|
1193
|
-
|
|
1195
|
+
BrowserUtils.redirectPreflightCheck(this.initialized, this.config);
|
|
1196
|
+
this.browserStorage.setInteractionInProgress(true);
|
|
1194
1197
|
|
|
1195
1198
|
const redirectClient = this.createRedirectClient(correlationId);
|
|
1196
1199
|
return redirectClient.logout(logoutRequest);
|
|
@@ -1203,7 +1206,9 @@ export class StandardController implements IController {
|
|
|
1203
1206
|
logoutPopup(logoutRequest?: EndSessionPopupRequest): Promise<void> {
|
|
1204
1207
|
try {
|
|
1205
1208
|
const correlationId = this.getRequestCorrelationId(logoutRequest);
|
|
1206
|
-
|
|
1209
|
+
BrowserUtils.preflightCheck(this.initialized);
|
|
1210
|
+
this.browserStorage.setInteractionInProgress(true);
|
|
1211
|
+
|
|
1207
1212
|
const popupClient = this.createPopupClient(correlationId);
|
|
1208
1213
|
return popupClient.logout(logoutRequest);
|
|
1209
1214
|
} catch (e) {
|
|
@@ -1424,77 +1429,6 @@ export class StandardController implements IController {
|
|
|
1424
1429
|
|
|
1425
1430
|
// #region Helpers
|
|
1426
1431
|
|
|
1427
|
-
/**
|
|
1428
|
-
* Helper to validate app environment before making an auth request
|
|
1429
|
-
*
|
|
1430
|
-
* @protected
|
|
1431
|
-
* @param {InteractionType} interactionType What kind of interaction is being used
|
|
1432
|
-
* @param {boolean} [isAppEmbedded=false] Whether to set interaction in progress temp cache flag
|
|
1433
|
-
*/
|
|
1434
|
-
public preflightBrowserEnvironmentCheck(
|
|
1435
|
-
interactionType: InteractionType,
|
|
1436
|
-
isAppEmbedded: boolean = false
|
|
1437
|
-
): void {
|
|
1438
|
-
this.logger.verbose("preflightBrowserEnvironmentCheck started");
|
|
1439
|
-
// Block request if not in browser environment
|
|
1440
|
-
BrowserUtils.blockNonBrowserEnvironment(this.isBrowserEnvironment);
|
|
1441
|
-
|
|
1442
|
-
// Block redirects if in an iframe
|
|
1443
|
-
BrowserUtils.blockRedirectInIframe(
|
|
1444
|
-
interactionType,
|
|
1445
|
-
this.config.system.allowRedirectInIframe
|
|
1446
|
-
);
|
|
1447
|
-
|
|
1448
|
-
// Block auth requests inside a hidden iframe
|
|
1449
|
-
BrowserUtils.blockReloadInHiddenIframes();
|
|
1450
|
-
|
|
1451
|
-
// Block redirectUri opened in a popup from calling MSAL APIs
|
|
1452
|
-
BrowserUtils.blockAcquireTokenInPopups();
|
|
1453
|
-
|
|
1454
|
-
// Block token acquisition before initialize has been called
|
|
1455
|
-
BrowserUtils.blockAPICallsBeforeInitialize(this.initialized);
|
|
1456
|
-
|
|
1457
|
-
// Block redirects if memory storage is enabled but storeAuthStateInCookie is not
|
|
1458
|
-
if (
|
|
1459
|
-
interactionType === InteractionType.Redirect &&
|
|
1460
|
-
this.config.cache.cacheLocation ===
|
|
1461
|
-
BrowserCacheLocation.MemoryStorage &&
|
|
1462
|
-
!this.config.cache.storeAuthStateInCookie
|
|
1463
|
-
) {
|
|
1464
|
-
throw createBrowserConfigurationAuthError(
|
|
1465
|
-
BrowserConfigurationAuthErrorCodes.inMemRedirectUnavailable
|
|
1466
|
-
);
|
|
1467
|
-
}
|
|
1468
|
-
|
|
1469
|
-
if (
|
|
1470
|
-
interactionType === InteractionType.Redirect ||
|
|
1471
|
-
interactionType === InteractionType.Popup
|
|
1472
|
-
) {
|
|
1473
|
-
this.preflightInteractiveRequest(!isAppEmbedded);
|
|
1474
|
-
}
|
|
1475
|
-
}
|
|
1476
|
-
|
|
1477
|
-
/**
|
|
1478
|
-
* Preflight check for interactive requests
|
|
1479
|
-
*
|
|
1480
|
-
* @protected
|
|
1481
|
-
* @param {boolean} setInteractionInProgress Whether to set interaction in progress temp cache flag
|
|
1482
|
-
*/
|
|
1483
|
-
protected preflightInteractiveRequest(
|
|
1484
|
-
setInteractionInProgress: boolean
|
|
1485
|
-
): void {
|
|
1486
|
-
this.logger.verbose(
|
|
1487
|
-
"preflightInteractiveRequest called, validating app environment"
|
|
1488
|
-
);
|
|
1489
|
-
// block the reload if it occurred inside a hidden iframe
|
|
1490
|
-
BrowserUtils.blockReloadInHiddenIframes();
|
|
1491
|
-
|
|
1492
|
-
// Set interaction in progress temporary cache or throw if alread set.
|
|
1493
|
-
if (setInteractionInProgress) {
|
|
1494
|
-
this.getBrowserStorage().setInteractionInProgress(true);
|
|
1495
|
-
}
|
|
1496
|
-
}
|
|
1497
|
-
|
|
1498
1432
|
/**
|
|
1499
1433
|
* Acquire a token from native device (e.g. WAM)
|
|
1500
1434
|
* @param request
|
|
@@ -1820,13 +1754,6 @@ export class StandardController implements IController {
|
|
|
1820
1754
|
return this.performanceClient;
|
|
1821
1755
|
}
|
|
1822
1756
|
|
|
1823
|
-
/**
|
|
1824
|
-
* Returns the browser storage
|
|
1825
|
-
*/
|
|
1826
|
-
public getBrowserStorage(): BrowserCacheManager {
|
|
1827
|
-
return this.browserStorage;
|
|
1828
|
-
}
|
|
1829
|
-
|
|
1830
1757
|
/**
|
|
1831
1758
|
* Returns the browser env indicator
|
|
1832
1759
|
*/
|
|
@@ -1920,7 +1847,7 @@ export class StandardController implements IController {
|
|
|
1920
1847
|
cacheLookupPolicy: request.cacheLookupPolicy,
|
|
1921
1848
|
});
|
|
1922
1849
|
|
|
1923
|
-
|
|
1850
|
+
BrowserUtils.preflightCheck(this.initialized);
|
|
1924
1851
|
this.logger.verbose("acquireTokenSilent called", correlationId);
|
|
1925
1852
|
|
|
1926
1853
|
const account = request.account || this.getActiveAccount();
|
|
@@ -1979,13 +1906,14 @@ export class StandardController implements IController {
|
|
|
1979
1906
|
});
|
|
1980
1907
|
return result;
|
|
1981
1908
|
})
|
|
1982
|
-
.catch((error:
|
|
1909
|
+
.catch((error: Error) => {
|
|
1983
1910
|
this.activeSilentTokenRequests.delete(silentRequestKey);
|
|
1984
|
-
atsMeasurement.end(
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1911
|
+
atsMeasurement.end(
|
|
1912
|
+
{
|
|
1913
|
+
success: false,
|
|
1914
|
+
},
|
|
1915
|
+
error
|
|
1916
|
+
);
|
|
1989
1917
|
throw error;
|
|
1990
1918
|
});
|
|
1991
1919
|
this.activeSilentTokenRequests.set(silentRequestKey, response);
|
|
@@ -2014,7 +1942,7 @@ export class StandardController implements IController {
|
|
|
2014
1942
|
* @returns {Promise.<AuthenticationResult>} - a promise that is fulfilled when this function has completed, or rejected if an error was raised. Returns the {@link AuthResponse}
|
|
2015
1943
|
*/
|
|
2016
1944
|
protected async acquireTokenSilentAsync(
|
|
2017
|
-
request: SilentRequest,
|
|
1945
|
+
request: SilentRequest & { correlationId: string },
|
|
2018
1946
|
account: AccountInfo
|
|
2019
1947
|
): Promise<AuthenticationResult> {
|
|
2020
1948
|
this.performanceClient.addQueueMeasurement(
|
|
@@ -2027,14 +1955,17 @@ export class StandardController implements IController {
|
|
|
2027
1955
|
InteractionType.Silent,
|
|
2028
1956
|
request
|
|
2029
1957
|
);
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
1958
|
+
|
|
1959
|
+
if (request.correlationId) {
|
|
1960
|
+
this.performanceClient.incrementFields(
|
|
1961
|
+
{ visibilityChangeCount: 0 },
|
|
1962
|
+
request.correlationId
|
|
1963
|
+
);
|
|
1964
|
+
}
|
|
1965
|
+
|
|
1966
|
+
document.addEventListener("visibilitychange", () =>
|
|
1967
|
+
this.trackPageVisibility(request.correlationId)
|
|
2033
1968
|
);
|
|
2034
|
-
this.atsAsyncMeasurement?.increment({
|
|
2035
|
-
visibilityChangeCount: 0,
|
|
2036
|
-
});
|
|
2037
|
-
document.addEventListener("visibilitychange", this.trackPageVisibility);
|
|
2038
1969
|
let result: Promise<AuthenticationResult>;
|
|
2039
1970
|
if (
|
|
2040
1971
|
NativeMessageHandler.isNativeAvailable(
|
|
@@ -2076,19 +2007,19 @@ export class StandardController implements IController {
|
|
|
2076
2007
|
"acquireTokenSilent - attempting to acquire token from web flow"
|
|
2077
2008
|
);
|
|
2078
2009
|
|
|
2079
|
-
const silentCacheClient = this.createSilentCacheClient(
|
|
2080
|
-
request.correlationId
|
|
2081
|
-
);
|
|
2082
|
-
|
|
2083
2010
|
const silentRequest = await invokeAsync(
|
|
2084
|
-
|
|
2085
|
-
silentCacheClient
|
|
2086
|
-
),
|
|
2011
|
+
initializeSilentRequest,
|
|
2087
2012
|
PerformanceEvents.InitializeSilentRequest,
|
|
2088
2013
|
this.logger,
|
|
2089
2014
|
this.performanceClient,
|
|
2090
2015
|
request.correlationId
|
|
2091
|
-
)(
|
|
2016
|
+
)(
|
|
2017
|
+
request,
|
|
2018
|
+
account,
|
|
2019
|
+
this.config,
|
|
2020
|
+
this.performanceClient,
|
|
2021
|
+
this.logger
|
|
2022
|
+
);
|
|
2092
2023
|
|
|
2093
2024
|
const cacheLookupPolicy =
|
|
2094
2025
|
request.cacheLookupPolicy || CacheLookupPolicy.Default;
|
|
@@ -2099,7 +2030,7 @@ export class StandardController implements IController {
|
|
|
2099
2030
|
this.logger,
|
|
2100
2031
|
this.performanceClient,
|
|
2101
2032
|
silentRequest.correlationId
|
|
2102
|
-
)(
|
|
2033
|
+
)(silentRequest, cacheLookupPolicy).catch(
|
|
2103
2034
|
(cacheError: AuthError) => {
|
|
2104
2035
|
if (
|
|
2105
2036
|
request.cacheLookupPolicy ===
|
|
@@ -2108,8 +2039,6 @@ export class StandardController implements IController {
|
|
|
2108
2039
|
throw cacheError;
|
|
2109
2040
|
}
|
|
2110
2041
|
|
|
2111
|
-
// block the reload if it occurred inside a hidden iframe
|
|
2112
|
-
BrowserUtils.blockReloadInHiddenIframes();
|
|
2113
2042
|
this.eventHandler.emitEvent(
|
|
2114
2043
|
EventType.ACQUIRE_TOKEN_NETWORK_START,
|
|
2115
2044
|
InteractionType.Silent,
|
|
@@ -2160,32 +2089,31 @@ export class StandardController implements IController {
|
|
|
2160
2089
|
InteractionType.Silent,
|
|
2161
2090
|
response
|
|
2162
2091
|
);
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2092
|
+
if (request.correlationId) {
|
|
2093
|
+
this.performanceClient.addFields(
|
|
2094
|
+
{
|
|
2095
|
+
fromCache: response.fromCache,
|
|
2096
|
+
isNativeBroker: response.fromNativeBroker,
|
|
2097
|
+
requestId: response.requestId,
|
|
2098
|
+
},
|
|
2099
|
+
request.correlationId
|
|
2100
|
+
);
|
|
2101
|
+
}
|
|
2102
|
+
|
|
2169
2103
|
return response;
|
|
2170
2104
|
})
|
|
2171
|
-
.catch((tokenRenewalError:
|
|
2105
|
+
.catch((tokenRenewalError: Error) => {
|
|
2172
2106
|
this.eventHandler.emitEvent(
|
|
2173
2107
|
EventType.ACQUIRE_TOKEN_FAILURE,
|
|
2174
2108
|
InteractionType.Silent,
|
|
2175
2109
|
null,
|
|
2176
2110
|
tokenRenewalError
|
|
2177
2111
|
);
|
|
2178
|
-
this.atsAsyncMeasurement?.end({
|
|
2179
|
-
errorCode: tokenRenewalError.errorCode,
|
|
2180
|
-
subErrorCode: tokenRenewalError.subError,
|
|
2181
|
-
success: false,
|
|
2182
|
-
});
|
|
2183
2112
|
throw tokenRenewalError;
|
|
2184
2113
|
})
|
|
2185
2114
|
.finally(() => {
|
|
2186
|
-
document.removeEventListener(
|
|
2187
|
-
|
|
2188
|
-
this.trackPageVisibility
|
|
2115
|
+
document.removeEventListener("visibilitychange", () =>
|
|
2116
|
+
this.trackPageVisibility(request.correlationId)
|
|
2189
2117
|
);
|
|
2190
2118
|
});
|
|
2191
2119
|
}
|