@azure/msal-browser 3.14.0 → 3.16.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 +17 -0
- package/dist/app/PublicClientApplication.d.ts.map +1 -1
- package/dist/app/PublicClientApplication.mjs +37 -9
- package/dist/app/PublicClientApplication.mjs.map +1 -1
- package/dist/app/PublicClientNext.d.ts +3 -0
- package/dist/app/PublicClientNext.d.ts.map +1 -1
- package/dist/app/PublicClientNext.mjs +4 -1
- 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/AccountManager.d.ts +49 -0
- package/dist/cache/AccountManager.d.ts.map +1 -0
- package/dist/cache/AccountManager.mjs +131 -0
- package/dist/cache/AccountManager.mjs.map +1 -0
- package/dist/cache/AsyncMemoryStorage.mjs +1 -1
- package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
- package/dist/cache/BrowserCacheManager.mjs +9 -2
- package/dist/cache/BrowserCacheManager.mjs.map +1 -1
- package/dist/cache/BrowserStorage.mjs +1 -1
- package/dist/cache/DatabaseStorage.mjs +1 -1
- package/dist/cache/MemoryStorage.mjs +1 -1
- package/dist/cache/TokenCache.mjs +1 -1
- package/dist/config/Configuration.d.ts +3 -1
- package/dist/config/Configuration.d.ts.map +1 -1
- package/dist/config/Configuration.mjs +1 -1
- package/dist/config/Configuration.mjs.map +1 -1
- package/dist/controllers/ControllerFactory.d.ts.map +1 -1
- package/dist/controllers/ControllerFactory.mjs +10 -11
- package/dist/controllers/ControllerFactory.mjs.map +1 -1
- package/dist/controllers/NestedAppAuthController.d.ts +118 -10
- package/dist/controllers/NestedAppAuthController.d.ts.map +1 -1
- package/dist/controllers/NestedAppAuthController.mjs +227 -83
- package/dist/controllers/NestedAppAuthController.mjs.map +1 -1
- package/dist/controllers/StandardController.d.ts.map +1 -1
- package/dist/controllers/StandardController.mjs +85 -118
- 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.mjs +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.mjs +1 -1
- package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +1 -1
- package/dist/interaction_client/NativeInteractionClient.d.ts +4 -3
- package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
- package/dist/interaction_client/NativeInteractionClient.mjs +5 -3
- 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.mjs +1 -1
- package/dist/interaction_client/SilentIframeClient.mjs +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/BridgeAccountContext.d.ts +13 -0
- package/dist/naa/BridgeAccountContext.d.ts.map +1 -0
- package/dist/naa/BridgeCapabilities.d.ts +1 -1
- package/dist/naa/BridgeCapabilities.d.ts.map +1 -1
- package/dist/naa/BridgeError.mjs +1 -1
- package/dist/naa/BridgeProxy.d.ts +3 -2
- package/dist/naa/BridgeProxy.d.ts.map +1 -1
- package/dist/naa/BridgeProxy.mjs +9 -7
- package/dist/naa/BridgeProxy.mjs.map +1 -1
- package/dist/naa/BridgeRequestEnvelope.d.ts +1 -1
- package/dist/naa/BridgeRequestEnvelope.d.ts.map +1 -1
- package/dist/naa/BridgeStatusCode.mjs +1 -1
- package/dist/naa/IBridgeProxy.d.ts +2 -2
- package/dist/naa/IBridgeProxy.d.ts.map +1 -1
- package/dist/naa/InitContext.d.ts +2 -0
- package/dist/naa/InitContext.d.ts.map +1 -1
- package/dist/naa/mapping/NestedAppAuthAdapter.d.ts +12 -2
- package/dist/naa/mapping/NestedAppAuthAdapter.d.ts.map +1 -1
- package/dist/naa/mapping/NestedAppAuthAdapter.mjs +43 -6
- 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/{TeamsAppOperatingContext.d.ts → NestedAppOperatingContext.d.ts} +8 -6
- package/dist/operatingcontext/NestedAppOperatingContext.d.ts.map +1 -0
- package/dist/operatingcontext/{TeamsAppOperatingContext.mjs → NestedAppOperatingContext.mjs} +17 -30
- package/dist/operatingcontext/NestedAppOperatingContext.mjs.map +1 -0
- package/dist/operatingcontext/StandardOperatingContext.d.ts.map +1 -1
- package/dist/operatingcontext/StandardOperatingContext.mjs +1 -1
- package/dist/operatingcontext/StandardOperatingContext.mjs.map +1 -1
- package/dist/operatingcontext/UnknownOperatingContext.d.ts +5 -5
- package/dist/operatingcontext/UnknownOperatingContext.d.ts.map +1 -1
- package/dist/operatingcontext/UnknownOperatingContext.mjs +8 -8
- package/dist/operatingcontext/UnknownOperatingContext.mjs.map +1 -1
- package/dist/packageMetadata.d.ts +1 -1
- package/dist/packageMetadata.mjs +2 -2
- package/dist/request/RequestHelpers.mjs +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.mjs +1 -1
- package/lib/msal-browser.cjs +12412 -12117
- package/lib/msal-browser.cjs.map +1 -1
- package/lib/msal-browser.js +12412 -12117
- package/lib/msal-browser.js.map +1 -1
- package/lib/msal-browser.min.js +69 -69
- package/package.json +6 -4
- package/src/app/PublicClientApplication.ts +43 -8
- package/src/app/PublicClientNext.ts +3 -0
- package/src/cache/AccountManager.ts +184 -0
- package/src/cache/BrowserCacheManager.ts +11 -2
- package/src/config/Configuration.ts +3 -1
- package/src/controllers/ControllerFactory.ts +9 -11
- package/src/controllers/NestedAppAuthController.ts +375 -82
- package/src/controllers/StandardController.ts +138 -170
- package/src/index.ts +5 -1
- package/src/interaction_client/NativeInteractionClient.ts +8 -2
- package/src/naa/BridgeAccountContext.ts +17 -0
- package/src/naa/BridgeCapabilities.ts +2 -1
- package/src/naa/BridgeProxy.ts +11 -6
- package/src/naa/BridgeRequestEnvelope.ts +1 -6
- package/src/naa/IBridgeProxy.ts +2 -2
- package/src/naa/InitContext.ts +2 -0
- package/src/naa/mapping/NestedAppAuthAdapter.ts +68 -2
- package/src/operatingcontext/{TeamsAppOperatingContext.ts → NestedAppOperatingContext.ts} +15 -29
- package/src/operatingcontext/StandardOperatingContext.ts +1 -0
- package/src/operatingcontext/UnknownOperatingContext.ts +8 -7
- package/src/packageMetadata.ts +1 -1
- package/dist/operatingcontext/TeamsAppOperatingContext.d.ts.map +0 -1
- package/dist/operatingcontext/TeamsAppOperatingContext.mjs.map +0 -1
|
@@ -33,6 +33,7 @@ import {
|
|
|
33
33
|
BrowserCacheManager,
|
|
34
34
|
DEFAULT_BROWSER_CACHE_MANAGER,
|
|
35
35
|
} from "../cache/BrowserCacheManager";
|
|
36
|
+
import * as AccountManager from "../cache/AccountManager";
|
|
36
37
|
import { BrowserConfiguration, CacheOptions } from "../config/Configuration";
|
|
37
38
|
import {
|
|
38
39
|
InteractionType,
|
|
@@ -100,6 +101,18 @@ function getAccountType(
|
|
|
100
101
|
return "AAD";
|
|
101
102
|
}
|
|
102
103
|
|
|
104
|
+
function preflightCheck(
|
|
105
|
+
initialized: boolean,
|
|
106
|
+
performanceEvent: InProgressPerformanceEvent
|
|
107
|
+
) {
|
|
108
|
+
try {
|
|
109
|
+
BrowserUtils.preflightCheck(initialized);
|
|
110
|
+
} catch (e) {
|
|
111
|
+
performanceEvent.end({ success: false }, e);
|
|
112
|
+
throw e;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
103
116
|
export class StandardController implements IController {
|
|
104
117
|
// OperatingContext
|
|
105
118
|
protected readonly operatingContext: StandardOperatingContext;
|
|
@@ -409,7 +422,7 @@ export class StandardController implements IController {
|
|
|
409
422
|
true
|
|
410
423
|
) || "";
|
|
411
424
|
const rootMeasurement = this.performanceClient.startMeasurement(
|
|
412
|
-
|
|
425
|
+
PerformanceEvents.AcquireTokenRedirect,
|
|
413
426
|
correlationId
|
|
414
427
|
);
|
|
415
428
|
this.eventHandler.emitEvent(
|
|
@@ -554,88 +567,114 @@ export class StandardController implements IController {
|
|
|
554
567
|
// Preflight request
|
|
555
568
|
const correlationId = this.getRequestCorrelationId(request);
|
|
556
569
|
this.logger.verbose("acquireTokenRedirect called", correlationId);
|
|
557
|
-
|
|
558
|
-
this.
|
|
570
|
+
|
|
571
|
+
const atrMeasurement = this.performanceClient.startMeasurement(
|
|
572
|
+
PerformanceEvents.AcquireTokenPreRedirect,
|
|
573
|
+
correlationId
|
|
574
|
+
);
|
|
575
|
+
atrMeasurement.add({
|
|
576
|
+
accountType: getAccountType(request.account),
|
|
577
|
+
scenarioId: request.scenarioId,
|
|
578
|
+
});
|
|
579
|
+
|
|
580
|
+
const onRedirectNavigateCb = request.onRedirectNavigate;
|
|
581
|
+
request.onRedirectNavigate = (url: string) => {
|
|
582
|
+
const navigate =
|
|
583
|
+
typeof onRedirectNavigateCb === "function"
|
|
584
|
+
? onRedirectNavigateCb(url)
|
|
585
|
+
: undefined;
|
|
586
|
+
if (navigate !== false) {
|
|
587
|
+
atrMeasurement.end({ success: true });
|
|
588
|
+
} else {
|
|
589
|
+
atrMeasurement.discard();
|
|
590
|
+
}
|
|
591
|
+
return navigate;
|
|
592
|
+
};
|
|
559
593
|
|
|
560
594
|
// If logged in, emit acquire token events
|
|
561
595
|
const isLoggedIn = this.getAllAccounts().length > 0;
|
|
562
|
-
|
|
563
|
-
this.
|
|
564
|
-
|
|
565
|
-
InteractionType.Redirect,
|
|
566
|
-
request
|
|
567
|
-
);
|
|
568
|
-
} else {
|
|
569
|
-
this.eventHandler.emitEvent(
|
|
570
|
-
EventType.LOGIN_START,
|
|
571
|
-
InteractionType.Redirect,
|
|
572
|
-
request
|
|
573
|
-
);
|
|
574
|
-
}
|
|
596
|
+
try {
|
|
597
|
+
BrowserUtils.redirectPreflightCheck(this.initialized, this.config);
|
|
598
|
+
this.browserStorage.setInteractionInProgress(true);
|
|
575
599
|
|
|
576
|
-
|
|
600
|
+
if (isLoggedIn) {
|
|
601
|
+
this.eventHandler.emitEvent(
|
|
602
|
+
EventType.ACQUIRE_TOKEN_START,
|
|
603
|
+
InteractionType.Redirect,
|
|
604
|
+
request
|
|
605
|
+
);
|
|
606
|
+
} else {
|
|
607
|
+
this.eventHandler.emitEvent(
|
|
608
|
+
EventType.LOGIN_START,
|
|
609
|
+
InteractionType.Redirect,
|
|
610
|
+
request
|
|
611
|
+
);
|
|
612
|
+
}
|
|
577
613
|
|
|
578
|
-
|
|
579
|
-
const nativeClient = new NativeInteractionClient(
|
|
580
|
-
this.config,
|
|
581
|
-
this.browserStorage,
|
|
582
|
-
this.browserCrypto,
|
|
583
|
-
this.logger,
|
|
584
|
-
this.eventHandler,
|
|
585
|
-
this.navigationClient,
|
|
586
|
-
ApiId.acquireTokenRedirect,
|
|
587
|
-
this.performanceClient,
|
|
588
|
-
this.nativeExtensionProvider,
|
|
589
|
-
this.getNativeAccountId(request),
|
|
590
|
-
this.nativeInternalStorage,
|
|
591
|
-
correlationId
|
|
592
|
-
);
|
|
593
|
-
result = nativeClient
|
|
594
|
-
.acquireTokenRedirect(request)
|
|
595
|
-
.catch((e: AuthError) => {
|
|
596
|
-
if (
|
|
597
|
-
e instanceof NativeAuthError &&
|
|
598
|
-
isFatalNativeAuthError(e)
|
|
599
|
-
) {
|
|
600
|
-
this.nativeExtensionProvider = undefined; // If extension gets uninstalled during session prevent future requests from continuing to attempt
|
|
601
|
-
const redirectClient =
|
|
602
|
-
this.createRedirectClient(correlationId);
|
|
603
|
-
return redirectClient.acquireToken(request);
|
|
604
|
-
} else if (e instanceof InteractionRequiredAuthError) {
|
|
605
|
-
this.logger.verbose(
|
|
606
|
-
"acquireTokenRedirect - Resolving interaction required error thrown by native broker by falling back to web flow"
|
|
607
|
-
);
|
|
608
|
-
const redirectClient =
|
|
609
|
-
this.createRedirectClient(correlationId);
|
|
610
|
-
return redirectClient.acquireToken(request);
|
|
611
|
-
}
|
|
612
|
-
this.browserStorage.setInteractionInProgress(false);
|
|
613
|
-
throw e;
|
|
614
|
-
});
|
|
615
|
-
} else {
|
|
616
|
-
const redirectClient = this.createRedirectClient(correlationId);
|
|
617
|
-
result = redirectClient.acquireToken(request);
|
|
618
|
-
}
|
|
614
|
+
let result: Promise<void>;
|
|
619
615
|
|
|
620
|
-
|
|
621
|
-
|
|
616
|
+
if (this.nativeExtensionProvider && this.canUseNative(request)) {
|
|
617
|
+
const nativeClient = new NativeInteractionClient(
|
|
618
|
+
this.config,
|
|
619
|
+
this.browserStorage,
|
|
620
|
+
this.browserCrypto,
|
|
621
|
+
this.logger,
|
|
622
|
+
this.eventHandler,
|
|
623
|
+
this.navigationClient,
|
|
624
|
+
ApiId.acquireTokenRedirect,
|
|
625
|
+
this.performanceClient,
|
|
626
|
+
this.nativeExtensionProvider,
|
|
627
|
+
this.getNativeAccountId(request),
|
|
628
|
+
this.nativeInternalStorage,
|
|
629
|
+
correlationId
|
|
630
|
+
);
|
|
631
|
+
result = nativeClient
|
|
632
|
+
.acquireTokenRedirect(request, atrMeasurement)
|
|
633
|
+
.catch((e: AuthError) => {
|
|
634
|
+
if (
|
|
635
|
+
e instanceof NativeAuthError &&
|
|
636
|
+
isFatalNativeAuthError(e)
|
|
637
|
+
) {
|
|
638
|
+
this.nativeExtensionProvider = undefined; // If extension gets uninstalled during session prevent future requests from continuing to attempt
|
|
639
|
+
const redirectClient =
|
|
640
|
+
this.createRedirectClient(correlationId);
|
|
641
|
+
return redirectClient.acquireToken(request);
|
|
642
|
+
} else if (e instanceof InteractionRequiredAuthError) {
|
|
643
|
+
this.logger.verbose(
|
|
644
|
+
"acquireTokenRedirect - Resolving interaction required error thrown by native broker by falling back to web flow"
|
|
645
|
+
);
|
|
646
|
+
const redirectClient =
|
|
647
|
+
this.createRedirectClient(correlationId);
|
|
648
|
+
return redirectClient.acquireToken(request);
|
|
649
|
+
}
|
|
650
|
+
this.browserStorage.setInteractionInProgress(false);
|
|
651
|
+
throw e;
|
|
652
|
+
});
|
|
653
|
+
} else {
|
|
654
|
+
const redirectClient = this.createRedirectClient(correlationId);
|
|
655
|
+
result = redirectClient.acquireToken(request);
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
return await result;
|
|
659
|
+
} catch (e) {
|
|
660
|
+
atrMeasurement.end({ success: false }, e);
|
|
622
661
|
if (isLoggedIn) {
|
|
623
662
|
this.eventHandler.emitEvent(
|
|
624
663
|
EventType.ACQUIRE_TOKEN_FAILURE,
|
|
625
664
|
InteractionType.Redirect,
|
|
626
665
|
null,
|
|
627
|
-
e
|
|
666
|
+
e as EventError
|
|
628
667
|
);
|
|
629
668
|
} else {
|
|
630
669
|
this.eventHandler.emitEvent(
|
|
631
670
|
EventType.LOGIN_FAILURE,
|
|
632
671
|
InteractionType.Redirect,
|
|
633
672
|
null,
|
|
634
|
-
e
|
|
673
|
+
e as EventError
|
|
635
674
|
);
|
|
636
675
|
}
|
|
637
676
|
throw e;
|
|
638
|
-
}
|
|
677
|
+
}
|
|
639
678
|
}
|
|
640
679
|
|
|
641
680
|
// #endregion
|
|
@@ -663,7 +702,7 @@ export class StandardController implements IController {
|
|
|
663
702
|
|
|
664
703
|
try {
|
|
665
704
|
this.logger.verbose("acquireTokenPopup called", correlationId);
|
|
666
|
-
|
|
705
|
+
preflightCheck(this.initialized, atPopupMeasurement);
|
|
667
706
|
this.browserStorage.setInteractionInProgress(true);
|
|
668
707
|
} catch (e) {
|
|
669
708
|
// Since this function is syncronous we need to reject
|
|
@@ -833,18 +872,18 @@ export class StandardController implements IController {
|
|
|
833
872
|
prompt: request.prompt,
|
|
834
873
|
correlationId: correlationId,
|
|
835
874
|
};
|
|
836
|
-
BrowserUtils.preflightCheck(this.initialized);
|
|
837
875
|
this.ssoSilentMeasurement = this.performanceClient.startMeasurement(
|
|
838
876
|
PerformanceEvents.SsoSilent,
|
|
839
877
|
correlationId
|
|
840
878
|
);
|
|
841
|
-
this.ssoSilentMeasurement?.increment({
|
|
842
|
-
visibilityChangeCount: 0,
|
|
843
|
-
});
|
|
844
879
|
this.ssoSilentMeasurement?.add({
|
|
845
880
|
scenarioId: request.scenarioId,
|
|
846
881
|
accountType: getAccountType(request.account),
|
|
847
882
|
});
|
|
883
|
+
preflightCheck(this.initialized, this.ssoSilentMeasurement);
|
|
884
|
+
this.ssoSilentMeasurement?.increment({
|
|
885
|
+
visibilityChangeCount: 0,
|
|
886
|
+
});
|
|
848
887
|
|
|
849
888
|
document.addEventListener(
|
|
850
889
|
"visibilitychange",
|
|
@@ -936,16 +975,16 @@ export class StandardController implements IController {
|
|
|
936
975
|
): Promise<AuthenticationResult> {
|
|
937
976
|
const correlationId = this.getRequestCorrelationId(request);
|
|
938
977
|
this.logger.trace("acquireTokenByCode called", correlationId);
|
|
939
|
-
|
|
978
|
+
const atbcMeasurement = this.performanceClient.startMeasurement(
|
|
979
|
+
PerformanceEvents.AcquireTokenByCode,
|
|
980
|
+
correlationId
|
|
981
|
+
);
|
|
982
|
+
preflightCheck(this.initialized, atbcMeasurement);
|
|
940
983
|
this.eventHandler.emitEvent(
|
|
941
984
|
EventType.ACQUIRE_TOKEN_BY_CODE_START,
|
|
942
985
|
InteractionType.Silent,
|
|
943
986
|
request
|
|
944
987
|
);
|
|
945
|
-
const atbcMeasurement = this.performanceClient.startMeasurement(
|
|
946
|
-
PerformanceEvents.AcquireTokenByCode,
|
|
947
|
-
correlationId
|
|
948
|
-
);
|
|
949
988
|
atbcMeasurement.add({ scenarioId: request.scenarioId });
|
|
950
989
|
|
|
951
990
|
try {
|
|
@@ -1287,10 +1326,12 @@ export class StandardController implements IController {
|
|
|
1287
1326
|
* @returns Array of AccountInfo objects in cache
|
|
1288
1327
|
*/
|
|
1289
1328
|
getAllAccounts(accountFilter?: AccountFilter): AccountInfo[] {
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1329
|
+
return AccountManager.getAllAccounts(
|
|
1330
|
+
this.logger,
|
|
1331
|
+
this.browserStorage,
|
|
1332
|
+
this.isBrowserEnvironment,
|
|
1333
|
+
accountFilter
|
|
1334
|
+
);
|
|
1294
1335
|
}
|
|
1295
1336
|
|
|
1296
1337
|
/**
|
|
@@ -1299,26 +1340,11 @@ export class StandardController implements IController {
|
|
|
1299
1340
|
* @returns The first account found in the cache matching the provided filter or null if no account could be found.
|
|
1300
1341
|
*/
|
|
1301
1342
|
getAccount(accountFilter: AccountFilter): AccountInfo | null {
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
this.logger
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
const account: AccountInfo | null =
|
|
1309
|
-
this.browserStorage.getAccountInfoFilteredBy(accountFilter);
|
|
1310
|
-
|
|
1311
|
-
if (account) {
|
|
1312
|
-
this.logger.verbose(
|
|
1313
|
-
"getAccount: Account matching provided filter found, returning"
|
|
1314
|
-
);
|
|
1315
|
-
return account;
|
|
1316
|
-
} else {
|
|
1317
|
-
this.logger.verbose(
|
|
1318
|
-
"getAccount: No matching account found, returning null"
|
|
1319
|
-
);
|
|
1320
|
-
return null;
|
|
1321
|
-
}
|
|
1343
|
+
return AccountManager.getAccount(
|
|
1344
|
+
accountFilter,
|
|
1345
|
+
this.logger,
|
|
1346
|
+
this.browserStorage
|
|
1347
|
+
);
|
|
1322
1348
|
}
|
|
1323
1349
|
|
|
1324
1350
|
/**
|
|
@@ -1330,29 +1356,11 @@ export class StandardController implements IController {
|
|
|
1330
1356
|
* @returns The account object stored in MSAL
|
|
1331
1357
|
*/
|
|
1332
1358
|
getAccountByUsername(username: string): AccountInfo | null {
|
|
1333
|
-
|
|
1334
|
-
if (!username) {
|
|
1335
|
-
this.logger.warning("getAccountByUsername: No username provided");
|
|
1336
|
-
return null;
|
|
1337
|
-
}
|
|
1338
|
-
|
|
1339
|
-
const account = this.browserStorage.getAccountInfoFilteredBy({
|
|
1359
|
+
return AccountManager.getAccountByUsername(
|
|
1340
1360
|
username,
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
"getAccountByUsername: Account matching username found, returning"
|
|
1345
|
-
);
|
|
1346
|
-
this.logger.verbosePii(
|
|
1347
|
-
`getAccountByUsername: Returning signed-in accounts matching username: ${username}`
|
|
1348
|
-
);
|
|
1349
|
-
return account;
|
|
1350
|
-
} else {
|
|
1351
|
-
this.logger.verbose(
|
|
1352
|
-
"getAccountByUsername: No matching account found, returning null"
|
|
1353
|
-
);
|
|
1354
|
-
return null;
|
|
1355
|
-
}
|
|
1361
|
+
this.logger,
|
|
1362
|
+
this.browserStorage
|
|
1363
|
+
);
|
|
1356
1364
|
}
|
|
1357
1365
|
|
|
1358
1366
|
/**
|
|
@@ -1363,31 +1371,11 @@ export class StandardController implements IController {
|
|
|
1363
1371
|
* @returns The account object stored in MSAL
|
|
1364
1372
|
*/
|
|
1365
1373
|
getAccountByHomeId(homeAccountId: string): AccountInfo | null {
|
|
1366
|
-
|
|
1367
|
-
if (!homeAccountId) {
|
|
1368
|
-
this.logger.warning(
|
|
1369
|
-
"getAccountByHomeId: No homeAccountId provided"
|
|
1370
|
-
);
|
|
1371
|
-
return null;
|
|
1372
|
-
}
|
|
1373
|
-
|
|
1374
|
-
const account = this.browserStorage.getAccountInfoFilteredBy({
|
|
1374
|
+
return AccountManager.getAccountByHomeId(
|
|
1375
1375
|
homeAccountId,
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
"getAccountByHomeId: Account matching homeAccountId found, returning"
|
|
1380
|
-
);
|
|
1381
|
-
this.logger.verbosePii(
|
|
1382
|
-
`getAccountByHomeId: Returning signed-in accounts matching homeAccountId: ${homeAccountId}`
|
|
1383
|
-
);
|
|
1384
|
-
return account;
|
|
1385
|
-
} else {
|
|
1386
|
-
this.logger.verbose(
|
|
1387
|
-
"getAccountByHomeId: No matching account found, returning null"
|
|
1388
|
-
);
|
|
1389
|
-
return null;
|
|
1390
|
-
}
|
|
1376
|
+
this.logger,
|
|
1377
|
+
this.browserStorage
|
|
1378
|
+
);
|
|
1391
1379
|
}
|
|
1392
1380
|
|
|
1393
1381
|
/**
|
|
@@ -1398,31 +1386,11 @@ export class StandardController implements IController {
|
|
|
1398
1386
|
* @returns The account object stored in MSAL
|
|
1399
1387
|
*/
|
|
1400
1388
|
getAccountByLocalId(localAccountId: string): AccountInfo | null {
|
|
1401
|
-
|
|
1402
|
-
if (!localAccountId) {
|
|
1403
|
-
this.logger.warning(
|
|
1404
|
-
"getAccountByLocalId: No localAccountId provided"
|
|
1405
|
-
);
|
|
1406
|
-
return null;
|
|
1407
|
-
}
|
|
1408
|
-
|
|
1409
|
-
const account = this.browserStorage.getAccountInfoFilteredBy({
|
|
1389
|
+
return AccountManager.getAccountByLocalId(
|
|
1410
1390
|
localAccountId,
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
"getAccountByLocalId: Account matching localAccountId found, returning"
|
|
1415
|
-
);
|
|
1416
|
-
this.logger.verbosePii(
|
|
1417
|
-
`getAccountByLocalId: Returning signed-in accounts matching localAccountId: ${localAccountId}`
|
|
1418
|
-
);
|
|
1419
|
-
return account;
|
|
1420
|
-
} else {
|
|
1421
|
-
this.logger.verbose(
|
|
1422
|
-
"getAccountByLocalId: No matching account found, returning null"
|
|
1423
|
-
);
|
|
1424
|
-
return null;
|
|
1425
|
-
}
|
|
1391
|
+
this.logger,
|
|
1392
|
+
this.browserStorage
|
|
1393
|
+
);
|
|
1426
1394
|
}
|
|
1427
1395
|
|
|
1428
1396
|
/**
|
|
@@ -1430,14 +1398,14 @@ export class StandardController implements IController {
|
|
|
1430
1398
|
* @param account
|
|
1431
1399
|
*/
|
|
1432
1400
|
setActiveAccount(account: AccountInfo | null): void {
|
|
1433
|
-
|
|
1401
|
+
AccountManager.setActiveAccount(account, this.browserStorage);
|
|
1434
1402
|
}
|
|
1435
1403
|
|
|
1436
1404
|
/**
|
|
1437
1405
|
* Gets the currently active account
|
|
1438
1406
|
*/
|
|
1439
1407
|
getActiveAccount(): AccountInfo | null {
|
|
1440
|
-
return this.browserStorage
|
|
1408
|
+
return AccountManager.getActiveAccount(this.browserStorage);
|
|
1441
1409
|
}
|
|
1442
1410
|
|
|
1443
1411
|
// #endregion
|
|
@@ -1898,7 +1866,7 @@ export class StandardController implements IController {
|
|
|
1898
1866
|
scenarioId: request.scenarioId,
|
|
1899
1867
|
});
|
|
1900
1868
|
|
|
1901
|
-
|
|
1869
|
+
preflightCheck(this.initialized, atsMeasurement);
|
|
1902
1870
|
this.logger.verbose("acquireTokenSilent called", correlationId);
|
|
1903
1871
|
|
|
1904
1872
|
const account = request.account || this.getActiveAccount();
|
package/src/index.ts
CHANGED
|
@@ -11,7 +11,11 @@
|
|
|
11
11
|
import * as BrowserUtils from "./utils/BrowserUtils";
|
|
12
12
|
export { BrowserUtils };
|
|
13
13
|
|
|
14
|
-
export {
|
|
14
|
+
export {
|
|
15
|
+
PublicClientApplication,
|
|
16
|
+
createNestablePublicClientApplication,
|
|
17
|
+
createStandardPublicClientApplication,
|
|
18
|
+
} from "./app/PublicClientApplication";
|
|
15
19
|
export { PublicClientNext } from "./app/PublicClientNext";
|
|
16
20
|
export { IController } from "./controllers/IController";
|
|
17
21
|
export {
|
|
@@ -36,6 +36,7 @@ import {
|
|
|
36
36
|
updateAccountTenantProfileData,
|
|
37
37
|
CacheHelpers,
|
|
38
38
|
buildAccountToCache,
|
|
39
|
+
InProgressPerformanceEvent,
|
|
39
40
|
} from "@azure/msal-common";
|
|
40
41
|
import { BaseInteractionClient } from "./BaseInteractionClient";
|
|
41
42
|
import { BrowserConfiguration } from "../config/Configuration";
|
|
@@ -276,9 +277,13 @@ export class NativeInteractionClient extends BaseInteractionClient {
|
|
|
276
277
|
|
|
277
278
|
/**
|
|
278
279
|
* Acquires a token from native platform then redirects to the redirectUri instead of returning the response
|
|
279
|
-
* @param request
|
|
280
|
+
* @param {RedirectRequest} request
|
|
281
|
+
* @param {InProgressPerformanceEvent} rootMeasurement
|
|
280
282
|
*/
|
|
281
|
-
async acquireTokenRedirect(
|
|
283
|
+
async acquireTokenRedirect(
|
|
284
|
+
request: RedirectRequest,
|
|
285
|
+
rootMeasurement: InProgressPerformanceEvent
|
|
286
|
+
): Promise<void> {
|
|
282
287
|
this.logger.trace(
|
|
283
288
|
"NativeInteractionClient - acquireTokenRedirect called."
|
|
284
289
|
);
|
|
@@ -313,6 +318,7 @@ export class NativeInteractionClient extends BaseInteractionClient {
|
|
|
313
318
|
const redirectUri = this.config.auth.navigateToLoginRequestUrl
|
|
314
319
|
? window.location.href
|
|
315
320
|
: this.getRedirectUri(request.redirectUri);
|
|
321
|
+
rootMeasurement.end({ success: true });
|
|
316
322
|
await this.navigationClient.navigateExternal(
|
|
317
323
|
redirectUri,
|
|
318
324
|
navigationOptions
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* AccountContext is used to pass account information when the bridge is initialized
|
|
8
|
+
*
|
|
9
|
+
* NAA (MetaOS) apps are created and destroyed for the same session multiple times.
|
|
10
|
+
* `AccountContext` helps in booting up the cached account when the bridge
|
|
11
|
+
* is recreated for a new NAA instance in the same auth session.
|
|
12
|
+
*/
|
|
13
|
+
export interface AccountContext {
|
|
14
|
+
homeAccountId: string;
|
|
15
|
+
environment: string;
|
|
16
|
+
tenantId: string;
|
|
17
|
+
}
|
package/src/naa/BridgeProxy.ts
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { AccountInfo } from "./AccountInfo";
|
|
7
6
|
import { AuthBridge, AuthBridgeResponse } from "./AuthBridge";
|
|
8
7
|
import { AuthResult } from "./AuthResult";
|
|
9
8
|
import { BridgeCapabilities } from "./BridgeCapabilities";
|
|
9
|
+
import { AccountContext } from "./BridgeAccountContext";
|
|
10
10
|
import { BridgeError } from "./BridgeError";
|
|
11
11
|
import { BridgeRequest } from "./BridgeRequest";
|
|
12
12
|
import { BridgeRequestEnvelope, BridgeMethods } from "./BridgeRequestEnvelope";
|
|
@@ -33,6 +33,7 @@ export class BridgeProxy implements IBridgeProxy {
|
|
|
33
33
|
sdkName: string;
|
|
34
34
|
sdkVersion: string;
|
|
35
35
|
capabilities?: BridgeCapabilities;
|
|
36
|
+
accountContext?: AccountContext;
|
|
36
37
|
|
|
37
38
|
/**
|
|
38
39
|
* initializeNestedAppAuthBridge - Initializes the bridge to the host app
|
|
@@ -80,6 +81,7 @@ export class BridgeProxy implements IBridgeProxy {
|
|
|
80
81
|
messageType: "NestedAppAuthRequest",
|
|
81
82
|
method: "GetInitContext",
|
|
82
83
|
requestId: BrowserCrypto.createNewGuid(),
|
|
84
|
+
sendTime: Date.now(),
|
|
83
85
|
};
|
|
84
86
|
const request: BridgeRequest = {
|
|
85
87
|
requestId: message.requestId,
|
|
@@ -134,15 +136,14 @@ export class BridgeProxy implements IBridgeProxy {
|
|
|
134
136
|
};
|
|
135
137
|
}
|
|
136
138
|
|
|
137
|
-
public async getActiveAccount(): Promise<AccountInfo> {
|
|
138
|
-
const result = await this.sendRequest("GetActiveAccount");
|
|
139
|
-
return BridgeProxy.validateBridgeResultOrThrow(result.account);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
139
|
public getHostCapabilities(): BridgeCapabilities | null {
|
|
143
140
|
return this.capabilities ?? null;
|
|
144
141
|
}
|
|
145
142
|
|
|
143
|
+
public getAccountContext(): AccountContext | null {
|
|
144
|
+
return this.accountContext ? this.accountContext : null;
|
|
145
|
+
}
|
|
146
|
+
|
|
146
147
|
/**
|
|
147
148
|
* A method used to send a request to the bridge
|
|
148
149
|
* @param request A token request
|
|
@@ -156,6 +157,7 @@ export class BridgeProxy implements IBridgeProxy {
|
|
|
156
157
|
messageType: "NestedAppAuthRequest",
|
|
157
158
|
method: method,
|
|
158
159
|
requestId: BrowserCrypto.createNewGuid(),
|
|
160
|
+
sendTime: Date.now(),
|
|
159
161
|
...requestParams,
|
|
160
162
|
};
|
|
161
163
|
|
|
@@ -194,10 +196,12 @@ export class BridgeProxy implements IBridgeProxy {
|
|
|
194
196
|
private constructor(
|
|
195
197
|
sdkName: string,
|
|
196
198
|
sdkVersion: string,
|
|
199
|
+
accountContext?: AccountContext,
|
|
197
200
|
capabilities?: BridgeCapabilities
|
|
198
201
|
) {
|
|
199
202
|
this.sdkName = sdkName;
|
|
200
203
|
this.sdkVersion = sdkVersion;
|
|
204
|
+
this.accountContext = accountContext;
|
|
201
205
|
this.capabilities = capabilities;
|
|
202
206
|
}
|
|
203
207
|
|
|
@@ -210,6 +214,7 @@ export class BridgeProxy implements IBridgeProxy {
|
|
|
210
214
|
return new BridgeProxy(
|
|
211
215
|
response.sdkName,
|
|
212
216
|
response.sdkVersion,
|
|
217
|
+
response.accountContext,
|
|
213
218
|
response.capabilities
|
|
214
219
|
);
|
|
215
220
|
}
|
|
@@ -5,12 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import { TokenRequest } from "./TokenRequest";
|
|
7
7
|
|
|
8
|
-
export type BridgeMethods =
|
|
9
|
-
| "GetToken"
|
|
10
|
-
| "GetActiveAccount"
|
|
11
|
-
| "GetAllAccounts"
|
|
12
|
-
| "GetInitContext"
|
|
13
|
-
| "GetTokenPopup";
|
|
8
|
+
export type BridgeMethods = "GetToken" | "GetInitContext" | "GetTokenPopup";
|
|
14
9
|
|
|
15
10
|
export type BridgeRequestEnvelope = {
|
|
16
11
|
messageType: "NestedAppAuthRequest";
|
package/src/naa/IBridgeProxy.ts
CHANGED
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { AccountInfo } from "./AccountInfo";
|
|
7
6
|
import { AuthResult } from "./AuthResult";
|
|
7
|
+
import { AccountContext } from "./BridgeAccountContext";
|
|
8
8
|
import { BridgeCapabilities } from "./BridgeCapabilities";
|
|
9
9
|
import { TokenRequest } from "./TokenRequest";
|
|
10
10
|
|
|
11
11
|
export interface IBridgeProxy {
|
|
12
12
|
getTokenInteractive(request: TokenRequest): Promise<AuthResult>;
|
|
13
13
|
getTokenSilent(request: TokenRequest): Promise<AuthResult>;
|
|
14
|
-
getActiveAccount(): Promise<AccountInfo>;
|
|
15
14
|
getHostCapabilities(): BridgeCapabilities | null;
|
|
15
|
+
getAccountContext(): AccountContext | null;
|
|
16
16
|
}
|
package/src/naa/InitContext.ts
CHANGED
|
@@ -4,9 +4,11 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { BridgeCapabilities } from "./BridgeCapabilities";
|
|
7
|
+
import { AccountContext } from "./BridgeAccountContext";
|
|
7
8
|
|
|
8
9
|
export interface InitContext {
|
|
9
10
|
capabilities?: BridgeCapabilities;
|
|
10
11
|
sdkName: string;
|
|
11
12
|
sdkVersion: string;
|
|
13
|
+
accountContext?: AccountContext;
|
|
12
14
|
}
|