@azure/msal-browser 3.1.0 → 3.3.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.d.ts.map +1 -1
- package/dist/app/IPublicClientApplication.mjs +20 -19
- package/dist/app/IPublicClientApplication.mjs.map +1 -1
- package/dist/app/PublicClientApplication.d.ts +14 -6
- package/dist/app/PublicClientApplication.d.ts.map +1 -1
- package/dist/app/PublicClientApplication.mjs +18 -8
- package/dist/app/PublicClientApplication.mjs.map +1 -1
- package/dist/app/PublicClientNext.d.ts +274 -0
- package/dist/app/PublicClientNext.d.ts.map +1 -0
- package/dist/app/PublicClientNext.mjs +362 -0
- package/dist/app/PublicClientNext.mjs.map +1 -0
- package/dist/broker/nativeBroker/NativeMessageHandler.d.ts +3 -4
- package/dist/broker/nativeBroker/NativeMessageHandler.d.ts.map +1 -1
- package/dist/broker/nativeBroker/NativeMessageHandler.mjs +13 -13
- package/dist/broker/nativeBroker/NativeMessageHandler.mjs.map +1 -1
- package/dist/broker/nativeBroker/NativeStatusCodes.d.ts +8 -0
- package/dist/broker/nativeBroker/NativeStatusCodes.d.ts.map +1 -0
- package/dist/broker/nativeBroker/NativeStatusCodes.mjs +16 -0
- package/dist/broker/nativeBroker/NativeStatusCodes.mjs.map +1 -0
- package/dist/cache/AsyncMemoryStorage.mjs +1 -1
- package/dist/cache/BrowserCacheManager.d.ts +4 -15
- package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
- package/dist/cache/BrowserCacheManager.mjs +13 -69
- package/dist/cache/BrowserCacheManager.mjs.map +1 -1
- package/dist/cache/BrowserStorage.d.ts.map +1 -1
- package/dist/cache/BrowserStorage.mjs +7 -9
- package/dist/cache/BrowserStorage.mjs.map +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.mjs +1 -1
- package/dist/config/Configuration.d.ts +4 -0
- package/dist/config/Configuration.d.ts.map +1 -1
- package/dist/config/Configuration.mjs +8 -7
- package/dist/config/Configuration.mjs.map +1 -1
- package/dist/controllers/ControllerFactory.d.ts +2 -1
- package/dist/controllers/ControllerFactory.d.ts.map +1 -1
- package/dist/controllers/ControllerFactory.mjs +26 -19
- package/dist/controllers/ControllerFactory.mjs.map +1 -1
- package/dist/controllers/IController.d.ts +3 -2
- package/dist/controllers/IController.d.ts.map +1 -1
- package/dist/controllers/NestedAppAuthController.d.ts +96 -0
- package/dist/controllers/NestedAppAuthController.d.ts.map +1 -0
- package/dist/controllers/NestedAppAuthController.mjs +345 -0
- package/dist/controllers/NestedAppAuthController.mjs.map +1 -0
- package/dist/controllers/StandardController.d.ts +11 -6
- package/dist/controllers/StandardController.d.ts.map +1 -1
- package/dist/controllers/StandardController.mjs +67 -45
- package/dist/controllers/StandardController.mjs.map +1 -1
- package/dist/controllers/UnknownOperatingContextController.d.ts +88 -0
- package/dist/controllers/UnknownOperatingContextController.d.ts.map +1 -0
- package/dist/controllers/UnknownOperatingContextController.mjs +275 -0
- package/dist/controllers/UnknownOperatingContextController.mjs.map +1 -0
- package/dist/crypto/BrowserCrypto.d.ts +44 -49
- package/dist/crypto/BrowserCrypto.d.ts.map +1 -1
- package/dist/crypto/BrowserCrypto.mjs +77 -77
- package/dist/crypto/BrowserCrypto.mjs.map +1 -1
- package/dist/crypto/CryptoOps.d.ts +1 -7
- package/dist/crypto/CryptoOps.d.ts.map +1 -1
- package/dist/crypto/CryptoOps.mjs +18 -23
- package/dist/crypto/CryptoOps.mjs.map +1 -1
- package/dist/crypto/PkceGenerator.d.ts +6 -21
- package/dist/crypto/PkceGenerator.d.ts.map +1 -1
- package/dist/crypto/PkceGenerator.mjs +45 -46
- package/dist/crypto/PkceGenerator.mjs.map +1 -1
- package/dist/crypto/SignedHttpRequest.mjs +1 -1
- package/dist/encode/Base64Decode.d.ts.map +1 -1
- package/dist/encode/Base64Decode.mjs +18 -2
- package/dist/encode/Base64Decode.mjs.map +1 -1
- package/dist/encode/Base64Encode.mjs +1 -1
- package/dist/error/BrowserAuthError.d.ts +10 -1
- package/dist/error/BrowserAuthError.d.ts.map +1 -1
- package/dist/error/BrowserAuthError.mjs +12 -3
- package/dist/error/BrowserAuthError.mjs.map +1 -1
- package/dist/error/BrowserAuthErrorCodes.d.ts +1 -0
- package/dist/error/BrowserAuthErrorCodes.d.ts.map +1 -1
- package/dist/error/BrowserAuthErrorCodes.mjs +3 -2
- package/dist/error/BrowserAuthErrorCodes.mjs.map +1 -1
- package/dist/error/BrowserConfigurationAuthError.d.ts +9 -46
- package/dist/error/BrowserConfigurationAuthError.d.ts.map +1 -1
- package/dist/error/BrowserConfigurationAuthError.mjs +20 -73
- package/dist/error/BrowserConfigurationAuthError.mjs.map +1 -1
- package/dist/error/BrowserConfigurationAuthErrorCodes.d.ts +4 -0
- package/dist/error/BrowserConfigurationAuthErrorCodes.d.ts.map +1 -0
- package/dist/error/BrowserConfigurationAuthErrorCodes.mjs +12 -0
- package/dist/error/BrowserConfigurationAuthErrorCodes.mjs.map +1 -0
- package/dist/error/NativeAuthError.d.ts +17 -45
- package/dist/error/NativeAuthError.d.ts.map +1 -1
- package/dist/error/NativeAuthError.mjs +47 -78
- package/dist/error/NativeAuthError.mjs.map +1 -1
- package/dist/error/NativeAuthErrorCodes.d.ts +3 -0
- package/dist/error/NativeAuthErrorCodes.d.ts.map +1 -0
- package/dist/error/NativeAuthErrorCodes.mjs +11 -0
- package/dist/error/NativeAuthErrorCodes.mjs.map +1 -0
- package/dist/error/NestedAppAuthError.d.ts +15 -0
- package/dist/error/NestedAppAuthError.d.ts.map +1 -0
- package/dist/error/NestedAppAuthError.mjs +30 -0
- package/dist/error/NestedAppAuthError.mjs.map +1 -0
- package/dist/event/EventHandler.d.ts.map +1 -1
- package/dist/event/EventHandler.mjs +3 -2
- package/dist/event/EventHandler.mjs.map +1 -1
- package/dist/event/EventMessage.mjs +1 -1
- package/dist/event/EventType.mjs +1 -1
- package/dist/index.d.ts +5 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +7 -3
- package/dist/index.mjs.map +1 -1
- package/dist/interaction_client/BaseInteractionClient.d.ts.map +1 -1
- package/dist/interaction_client/BaseInteractionClient.mjs +10 -11
- 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 +26 -13
- 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 +5 -4
- package/dist/interaction_client/PopupClient.mjs.map +1 -1
- package/dist/interaction_client/RedirectClient.mjs +7 -7
- package/dist/interaction_client/SilentAuthCodeClient.d.ts.map +1 -1
- package/dist/interaction_client/SilentAuthCodeClient.mjs +7 -10
- package/dist/interaction_client/SilentAuthCodeClient.mjs.map +1 -1
- package/dist/interaction_client/SilentCacheClient.d.ts.map +1 -1
- package/dist/interaction_client/SilentCacheClient.mjs +11 -18
- 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 +27 -13
- 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 +8 -18
- 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 +16 -37
- package/dist/interaction_client/StandardInteractionClient.mjs.map +1 -1
- package/dist/interaction_handler/InteractionHandler.d.ts.map +1 -1
- package/dist/interaction_handler/InteractionHandler.mjs +6 -9
- package/dist/interaction_handler/InteractionHandler.mjs.map +1 -1
- package/dist/interaction_handler/RedirectHandler.d.ts.map +1 -1
- package/dist/interaction_handler/RedirectHandler.mjs +3 -3
- package/dist/interaction_handler/RedirectHandler.mjs.map +1 -1
- package/dist/interaction_handler/SilentHandler.d.ts +13 -47
- package/dist/interaction_handler/SilentHandler.d.ts.map +1 -1
- package/dist/interaction_handler/SilentHandler.mjs +120 -156
- package/dist/interaction_handler/SilentHandler.mjs.map +1 -1
- package/dist/naa/AccountInfo.d.ts +13 -0
- package/dist/naa/AccountInfo.d.ts.map +1 -0
- package/dist/naa/AccountRequests.d.ts +10 -0
- package/dist/naa/AccountRequests.d.ts.map +1 -0
- package/dist/naa/AuthBridge.d.ts +6 -0
- package/dist/naa/AuthBridge.d.ts.map +1 -0
- package/dist/naa/BridgeCapabilities.d.ts +4 -0
- package/dist/naa/BridgeCapabilities.d.ts.map +1 -0
- package/dist/naa/BridgeError.d.ts +10 -0
- package/dist/naa/BridgeError.d.ts.map +1 -0
- package/dist/naa/BridgeError.mjs +12 -0
- package/dist/naa/BridgeError.mjs.map +1 -0
- package/dist/naa/BridgeProxy.d.ts +72 -0
- package/dist/naa/BridgeProxy.d.ts.map +1 -0
- package/dist/naa/BridgeProxy.mjs +154 -0
- package/dist/naa/BridgeProxy.mjs.map +1 -0
- package/dist/naa/BridgeRequest.d.ts +7 -0
- package/dist/naa/BridgeRequest.d.ts.map +1 -0
- package/dist/naa/BridgeRequestEnvelope.d.ts +14 -0
- package/dist/naa/BridgeRequestEnvelope.d.ts.map +1 -0
- package/dist/naa/BridgeResponseEnvelope.d.ts +11 -0
- package/dist/naa/BridgeResponseEnvelope.d.ts.map +1 -0
- package/dist/naa/BridgeStatusCode.d.ts +11 -0
- package/dist/naa/BridgeStatusCode.d.ts.map +1 -0
- package/dist/naa/BridgeStatusCode.mjs +20 -0
- package/dist/naa/BridgeStatusCode.mjs.map +1 -0
- package/dist/naa/IBridgeProxy.d.ts +11 -0
- package/dist/naa/IBridgeProxy.d.ts.map +1 -0
- package/dist/naa/InitializeBridgeResponse.d.ts +7 -0
- package/dist/naa/InitializeBridgeResponse.d.ts.map +1 -0
- package/dist/naa/TokenRequest.d.ts +22 -0
- package/dist/naa/TokenRequest.d.ts.map +1 -0
- package/dist/naa/TokenResponse.d.ts +17 -0
- package/dist/naa/TokenResponse.d.ts.map +1 -0
- package/dist/naa/mapping/NestedAppAuthAdapter.d.ts +26 -0
- package/dist/naa/mapping/NestedAppAuthAdapter.d.ts.map +1 -0
- package/dist/naa/mapping/NestedAppAuthAdapter.mjs +178 -0
- package/dist/naa/mapping/NestedAppAuthAdapter.mjs.map +1 -0
- 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.d.ts +7 -0
- package/dist/operatingcontext/TeamsAppOperatingContext.d.ts.map +1 -1
- package/dist/operatingcontext/TeamsAppOperatingContext.mjs +45 -4
- package/dist/operatingcontext/TeamsAppOperatingContext.mjs.map +1 -1
- package/dist/operatingcontext/UnknownOperatingContext.d.ts +26 -0
- package/dist/operatingcontext/UnknownOperatingContext.d.ts.map +1 -0
- package/dist/operatingcontext/UnknownOperatingContext.mjs +49 -0
- package/dist/operatingcontext/UnknownOperatingContext.mjs.map +1 -0
- package/dist/packageMetadata.d.ts +1 -1
- package/dist/packageMetadata.mjs +2 -2
- 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.map +1 -1
- package/dist/utils/BrowserProtocolUtils.mjs +3 -3
- package/dist/utils/BrowserProtocolUtils.mjs.map +1 -1
- package/dist/utils/BrowserUtils.d.ts +54 -53
- package/dist/utils/BrowserUtils.d.ts.map +1 -1
- package/dist/utils/BrowserUtils.mjs +114 -102
- package/dist/utils/BrowserUtils.mjs.map +1 -1
- package/lib/msal-browser.cjs +61 -18042
- package/lib/msal-browser.cjs.map +1 -1
- package/lib/msal-browser.js +13593 -12505
- package/lib/msal-browser.js.map +1 -1
- package/lib/msal-browser.min.js +66 -65
- package/package.json +2 -2
- package/src/app/IPublicClientApplication.ts +55 -18
- package/src/app/PublicClientApplication.ts +19 -7
- package/src/app/PublicClientNext.ts +442 -0
- package/src/broker/nativeBroker/NativeMessageHandler.ts +12 -15
- package/src/broker/nativeBroker/NativeStatusCodes.ts +13 -0
- package/src/cache/BrowserCacheManager.ts +29 -103
- package/src/cache/BrowserStorage.ts +9 -11
- package/src/config/Configuration.ts +21 -8
- package/src/controllers/ControllerFactory.ts +36 -25
- package/src/controllers/IController.ts +4 -1
- package/src/controllers/NestedAppAuthController.ts +525 -0
- package/src/controllers/StandardController.ts +163 -98
- package/src/controllers/UnknownOperatingContextController.ts +383 -0
- package/src/crypto/BrowserCrypto.ts +119 -103
- package/src/crypto/CryptoOps.ts +18 -27
- package/src/crypto/PkceGenerator.ts +93 -54
- package/src/encode/Base64Decode.ts +21 -1
- package/src/error/BrowserAuthError.ts +13 -1
- package/src/error/BrowserAuthErrorCodes.ts +1 -0
- package/src/error/BrowserConfigurationAuthError.ts +33 -102
- package/src/error/BrowserConfigurationAuthErrorCodes.ts +9 -0
- package/src/error/NativeAuthError.ts +73 -101
- package/src/error/NativeAuthErrorCodes.ts +7 -0
- package/src/error/NestedAppAuthError.ts +32 -0
- package/src/event/EventHandler.ts +2 -1
- package/src/index.ts +8 -10
- package/src/interaction_client/BaseInteractionClient.ts +14 -8
- package/src/interaction_client/NativeInteractionClient.ts +48 -14
- package/src/interaction_client/PopupClient.ts +2 -1
- package/src/interaction_client/RedirectClient.ts +1 -1
- package/src/interaction_client/SilentAuthCodeClient.ts +22 -19
- package/src/interaction_client/SilentCacheClient.ts +28 -28
- package/src/interaction_client/SilentIframeClient.ts +54 -18
- package/src/interaction_client/SilentRefreshClient.ts +26 -28
- package/src/interaction_client/StandardInteractionClient.ts +37 -68
- package/src/interaction_handler/InteractionHandler.ts +20 -15
- package/src/interaction_handler/RedirectHandler.ts +6 -2
- package/src/interaction_handler/SilentHandler.ts +177 -230
- package/src/naa/AccountInfo.ts +17 -0
- package/src/naa/AccountRequests.ts +16 -0
- package/src/naa/AuthBridge.ts +16 -0
- package/src/naa/BridgeCapabilities.ts +8 -0
- package/src/naa/BridgeError.ts +18 -0
- package/src/naa/BridgeProxy.ts +230 -0
- package/src/naa/BridgeRequest.ts +12 -0
- package/src/naa/BridgeRequestEnvelope.ts +46 -0
- package/src/naa/BridgeResponseEnvelope.ts +21 -0
- package/src/naa/BridgeStatusCode.ts +15 -0
- package/src/naa/IBridgeProxy.ts +25 -0
- package/src/naa/InitializeBridgeResponse.ts +12 -0
- package/src/naa/TokenRequest.ts +26 -0
- package/src/naa/TokenResponse.ts +61 -0
- package/src/naa/mapping/NestedAppAuthAdapter.ts +252 -0
- package/src/operatingcontext/TeamsAppOperatingContext.ts +43 -3
- package/src/operatingcontext/UnknownOperatingContext.ts +48 -0
- package/src/packageMetadata.ts +1 -1
- package/src/utils/BrowserProtocolUtils.ts +3 -2
- package/src/utils/BrowserUtils.ts +133 -125
- package/dist/crypto/ISubtleCrypto.d.ts +0 -10
- package/dist/crypto/ISubtleCrypto.d.ts.map +0 -1
- package/dist/crypto/ModernBrowserCrypto.d.ts +0 -10
- package/dist/crypto/ModernBrowserCrypto.d.ts.map +0 -1
- package/dist/crypto/ModernBrowserCrypto.mjs +0 -31
- package/dist/crypto/ModernBrowserCrypto.mjs.map +0 -1
- package/dist/utils/BrowserStringUtils.d.ts +0 -22
- package/dist/utils/BrowserStringUtils.d.ts.map +0 -1
- package/dist/utils/BrowserStringUtils.mjs +0 -144
- package/dist/utils/BrowserStringUtils.mjs.map +0 -1
- package/src/crypto/ISubtleCrypto.ts +0 -30
- package/src/crypto/ModernBrowserCrypto.ts +0 -69
- package/src/utils/BrowserStringUtils.ts +0 -143
|
@@ -3,12 +3,21 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
AuthError,
|
|
8
|
+
InteractionRequiredAuthError,
|
|
9
|
+
InteractionRequiredAuthErrorCodes,
|
|
10
|
+
createInteractionRequiredAuthError,
|
|
11
|
+
} from "@azure/msal-common";
|
|
7
12
|
import {
|
|
8
13
|
createBrowserAuthError,
|
|
9
14
|
BrowserAuthErrorCodes,
|
|
10
15
|
} from "./BrowserAuthError";
|
|
11
16
|
|
|
17
|
+
import * as NativeAuthErrorCodes from "./NativeAuthErrorCodes";
|
|
18
|
+
import * as NativeStatusCodes from "../broker/nativeBroker/NativeStatusCodes";
|
|
19
|
+
export { NativeAuthErrorCodes };
|
|
20
|
+
|
|
12
21
|
export type OSError = {
|
|
13
22
|
error?: number;
|
|
14
23
|
protocol_error?: string;
|
|
@@ -19,123 +28,86 @@ export type OSError = {
|
|
|
19
28
|
|
|
20
29
|
const INVALID_METHOD_ERROR = -2147186943;
|
|
21
30
|
|
|
22
|
-
export const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
NO_NETWORK: "NO_NETWORK",
|
|
26
|
-
TRANSIENT_ERROR: "TRANSIENT_ERROR",
|
|
27
|
-
PERSISTENT_ERROR: "PERSISTENT_ERROR",
|
|
28
|
-
DISABLED: "DISABLED",
|
|
29
|
-
ACCOUNT_UNAVAILABLE: "ACCOUNT_UNAVAILABLE",
|
|
30
|
-
} as const;
|
|
31
|
-
export type NativeStatusCode =
|
|
32
|
-
(typeof NativeStatusCode)[keyof typeof NativeStatusCode];
|
|
33
|
-
|
|
34
|
-
export const NativeAuthErrorMessage = {
|
|
35
|
-
extensionError: {
|
|
36
|
-
code: "ContentError",
|
|
37
|
-
},
|
|
38
|
-
userSwitch: {
|
|
39
|
-
code: "user_switch",
|
|
40
|
-
desc: "User attempted to switch accounts in the native broker, which is not allowed. All new accounts must sign-in through the standard web flow first, please try again.",
|
|
41
|
-
},
|
|
42
|
-
tokensNotFoundInCache: {
|
|
43
|
-
code: "tokens_not_found_in_internal_memory_cache",
|
|
44
|
-
desc: "Tokens not cached in MSAL JS internal memory, please make the WAM request",
|
|
45
|
-
},
|
|
31
|
+
export const NativeAuthErrorMessages = {
|
|
32
|
+
[NativeAuthErrorCodes.userSwitch]:
|
|
33
|
+
"User attempted to switch accounts in the native broker, which is not allowed. All new accounts must sign-in through the standard web flow first, please try again.",
|
|
46
34
|
};
|
|
47
35
|
|
|
48
36
|
export class NativeAuthError extends AuthError {
|
|
49
37
|
ext: OSError | undefined;
|
|
50
38
|
|
|
51
|
-
constructor(errorCode: string, description
|
|
39
|
+
constructor(errorCode: string, description?: string, ext?: OSError) {
|
|
52
40
|
super(errorCode, description);
|
|
53
41
|
|
|
54
42
|
Object.setPrototypeOf(this, NativeAuthError.prototype);
|
|
55
43
|
this.name = "NativeAuthError";
|
|
56
44
|
this.ext = ext;
|
|
57
45
|
}
|
|
46
|
+
}
|
|
58
47
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
if (
|
|
73
|
-
this.ext &&
|
|
74
|
-
this.ext.error &&
|
|
75
|
-
this.ext.error === INVALID_METHOD_ERROR
|
|
76
|
-
) {
|
|
77
|
-
return true;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
switch (this.errorCode) {
|
|
81
|
-
case NativeAuthErrorMessage.extensionError.code:
|
|
82
|
-
return true;
|
|
83
|
-
default:
|
|
84
|
-
return false;
|
|
85
|
-
}
|
|
48
|
+
/**
|
|
49
|
+
* These errors should result in a fallback to the 'standard' browser based auth flow.
|
|
50
|
+
*/
|
|
51
|
+
export function isFatalNativeAuthError(error: NativeAuthError): boolean {
|
|
52
|
+
if (
|
|
53
|
+
error.ext &&
|
|
54
|
+
error.ext.status &&
|
|
55
|
+
(error.ext.status === NativeStatusCodes.PERSISTENT_ERROR ||
|
|
56
|
+
error.ext.status === NativeStatusCodes.DISABLED)
|
|
57
|
+
) {
|
|
58
|
+
return true;
|
|
86
59
|
}
|
|
87
60
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
*/
|
|
95
|
-
static createError(
|
|
96
|
-
code: string,
|
|
97
|
-
description: string,
|
|
98
|
-
ext?: OSError
|
|
99
|
-
): AuthError {
|
|
100
|
-
if (ext && ext.status) {
|
|
101
|
-
switch (ext.status) {
|
|
102
|
-
case NativeStatusCode.ACCOUNT_UNAVAILABLE:
|
|
103
|
-
return InteractionRequiredAuthError.createNativeAccountUnavailableError();
|
|
104
|
-
case NativeStatusCode.USER_INTERACTION_REQUIRED:
|
|
105
|
-
return new InteractionRequiredAuthError(code, description);
|
|
106
|
-
case NativeStatusCode.USER_CANCEL:
|
|
107
|
-
return createBrowserAuthError(
|
|
108
|
-
BrowserAuthErrorCodes.userCancelled
|
|
109
|
-
);
|
|
110
|
-
case NativeStatusCode.NO_NETWORK:
|
|
111
|
-
return createBrowserAuthError(
|
|
112
|
-
BrowserAuthErrorCodes.noNetworkConnectivity
|
|
113
|
-
);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
return new NativeAuthError(code, description, ext);
|
|
61
|
+
if (
|
|
62
|
+
error.ext &&
|
|
63
|
+
error.ext.error &&
|
|
64
|
+
error.ext.error === INVALID_METHOD_ERROR
|
|
65
|
+
) {
|
|
66
|
+
return true;
|
|
118
67
|
}
|
|
119
68
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
return new NativeAuthError(
|
|
126
|
-
NativeAuthErrorMessage.userSwitch.code,
|
|
127
|
-
NativeAuthErrorMessage.userSwitch.desc
|
|
128
|
-
);
|
|
69
|
+
switch (error.errorCode) {
|
|
70
|
+
case NativeAuthErrorCodes.contentError:
|
|
71
|
+
return true;
|
|
72
|
+
default:
|
|
73
|
+
return false;
|
|
129
74
|
}
|
|
75
|
+
}
|
|
130
76
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
77
|
+
/**
|
|
78
|
+
* Create the appropriate error object based on the WAM status code.
|
|
79
|
+
* @param code
|
|
80
|
+
* @param description
|
|
81
|
+
* @param ext
|
|
82
|
+
* @returns
|
|
83
|
+
*/
|
|
84
|
+
export function createNativeAuthError(
|
|
85
|
+
code: string,
|
|
86
|
+
description?: string,
|
|
87
|
+
ext?: OSError
|
|
88
|
+
): AuthError {
|
|
89
|
+
if (ext && ext.status) {
|
|
90
|
+
switch (ext.status) {
|
|
91
|
+
case NativeStatusCodes.ACCOUNT_UNAVAILABLE:
|
|
92
|
+
return createInteractionRequiredAuthError(
|
|
93
|
+
InteractionRequiredAuthErrorCodes.nativeAccountUnavailable
|
|
94
|
+
);
|
|
95
|
+
case NativeStatusCodes.USER_INTERACTION_REQUIRED:
|
|
96
|
+
return new InteractionRequiredAuthError(code, description);
|
|
97
|
+
case NativeStatusCodes.USER_CANCEL:
|
|
98
|
+
return createBrowserAuthError(
|
|
99
|
+
BrowserAuthErrorCodes.userCancelled
|
|
100
|
+
);
|
|
101
|
+
case NativeStatusCodes.NO_NETWORK:
|
|
102
|
+
return createBrowserAuthError(
|
|
103
|
+
BrowserAuthErrorCodes.noNetworkConnectivity
|
|
104
|
+
);
|
|
105
|
+
}
|
|
140
106
|
}
|
|
107
|
+
|
|
108
|
+
return new NativeAuthError(
|
|
109
|
+
code,
|
|
110
|
+
NativeAuthErrorMessages[code] || description,
|
|
111
|
+
ext
|
|
112
|
+
);
|
|
141
113
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { AuthError } from "@azure/msal-common";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* NestedAppAuthErrorMessage class containing string constants used by error codes and messages.
|
|
10
|
+
*/
|
|
11
|
+
export const NestedAppAuthErrorMessage = {
|
|
12
|
+
unsupportedMethod: {
|
|
13
|
+
code: "unsupported_method",
|
|
14
|
+
desc: "The PKCE code challenge and verifier could not be generated.",
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export class NestedAppAuthError extends AuthError {
|
|
19
|
+
constructor(errorCode: string, errorMessage?: string) {
|
|
20
|
+
super(errorCode, errorMessage);
|
|
21
|
+
|
|
22
|
+
Object.setPrototypeOf(this, NestedAppAuthError.prototype);
|
|
23
|
+
this.name = "NestedAppAuthError";
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public static createUnsupportedError(): NestedAppAuthError {
|
|
27
|
+
return new NestedAppAuthError(
|
|
28
|
+
NestedAppAuthErrorMessage.unsupportedMethod.code,
|
|
29
|
+
NestedAppAuthErrorMessage.unsupportedMethod.desc
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
EventPayload,
|
|
18
18
|
} from "./EventMessage";
|
|
19
19
|
import { EventType } from "./EventType";
|
|
20
|
+
import { createNewGuid } from "../crypto/BrowserCrypto";
|
|
20
21
|
|
|
21
22
|
export class EventHandler {
|
|
22
23
|
// Callback for subscribing to events
|
|
@@ -40,7 +41,7 @@ export class EventHandler {
|
|
|
40
41
|
*/
|
|
41
42
|
addEventCallback(callback: EventCallbackFunction): string | null {
|
|
42
43
|
if (typeof window !== "undefined") {
|
|
43
|
-
const callbackId =
|
|
44
|
+
const callbackId = createNewGuid();
|
|
44
45
|
this.eventCallbacks.set(callbackId, callback);
|
|
45
46
|
this.logger.verbose(
|
|
46
47
|
`Event callback registered with id: ${callbackId}`
|
package/src/index.ts
CHANGED
|
@@ -8,12 +8,11 @@
|
|
|
8
8
|
* @module @azure/msal-browser
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
* Breaking changes to these APIs will be shipped under a minor version, instead of a major version.
|
|
14
|
-
*/
|
|
11
|
+
import * as BrowserUtils from "./utils/BrowserUtils";
|
|
12
|
+
export { BrowserUtils };
|
|
15
13
|
|
|
16
14
|
export { PublicClientApplication } from "./app/PublicClientApplication";
|
|
15
|
+
export { PublicClientNext } from "./app/PublicClientNext";
|
|
17
16
|
export { IController } from "./controllers/IController";
|
|
18
17
|
export {
|
|
19
18
|
Configuration,
|
|
@@ -32,12 +31,6 @@ export {
|
|
|
32
31
|
ApiId,
|
|
33
32
|
CacheLookupPolicy,
|
|
34
33
|
} from "./utils/BrowserConstants";
|
|
35
|
-
export { BrowserUtils } from "./utils/BrowserUtils";
|
|
36
|
-
|
|
37
|
-
/*
|
|
38
|
-
* export { IController} from "./controllers/IController";
|
|
39
|
-
* export { StandardController } from "./controllers/StandardController";
|
|
40
|
-
*/
|
|
41
34
|
|
|
42
35
|
// Browser Errors
|
|
43
36
|
export {
|
|
@@ -47,6 +40,7 @@ export {
|
|
|
47
40
|
} from "./error/BrowserAuthError";
|
|
48
41
|
export {
|
|
49
42
|
BrowserConfigurationAuthError,
|
|
43
|
+
BrowserConfigurationAuthErrorCodes,
|
|
50
44
|
BrowserConfigurationAuthErrorMessage,
|
|
51
45
|
} from "./error/BrowserConfigurationAuthError";
|
|
52
46
|
|
|
@@ -112,12 +106,16 @@ export {
|
|
|
112
106
|
IdTokenClaims,
|
|
113
107
|
// Error
|
|
114
108
|
AuthError,
|
|
109
|
+
AuthErrorCodes,
|
|
115
110
|
AuthErrorMessage,
|
|
116
111
|
ClientAuthError,
|
|
112
|
+
ClientAuthErrorCodes,
|
|
117
113
|
ClientAuthErrorMessage,
|
|
118
114
|
ClientConfigurationError,
|
|
115
|
+
ClientConfigurationErrorCodes,
|
|
119
116
|
ClientConfigurationErrorMessage,
|
|
120
117
|
InteractionRequiredAuthError,
|
|
118
|
+
InteractionRequiredAuthErrorCodes,
|
|
121
119
|
InteractionRequiredAuthErrorMessage,
|
|
122
120
|
ServerError,
|
|
123
121
|
// Network
|
|
@@ -14,7 +14,8 @@ import {
|
|
|
14
14
|
UrlString,
|
|
15
15
|
ServerTelemetryManager,
|
|
16
16
|
ServerTelemetryRequest,
|
|
17
|
-
|
|
17
|
+
createClientConfigurationError,
|
|
18
|
+
ClientConfigurationErrorCodes,
|
|
18
19
|
Authority,
|
|
19
20
|
AuthorityOptions,
|
|
20
21
|
AuthorityFactory,
|
|
@@ -31,11 +32,12 @@ import { PopupRequest } from "../request/PopupRequest";
|
|
|
31
32
|
import { SsoSilentRequest } from "../request/SsoSilentRequest";
|
|
32
33
|
import { version } from "../packageMetadata";
|
|
33
34
|
import { BrowserConstants } from "../utils/BrowserConstants";
|
|
34
|
-
import
|
|
35
|
+
import * as BrowserUtils from "../utils/BrowserUtils";
|
|
35
36
|
import { INavigationClient } from "../navigation/INavigationClient";
|
|
36
37
|
import { NativeMessageHandler } from "../broker/nativeBroker/NativeMessageHandler";
|
|
37
38
|
import { AuthenticationResult } from "../response/AuthenticationResult";
|
|
38
39
|
import { ClearCacheRequest } from "../request/ClearCacheRequest";
|
|
40
|
+
import { createNewGuid } from "../crypto/BrowserCrypto";
|
|
39
41
|
|
|
40
42
|
export abstract class BaseInteractionClient {
|
|
41
43
|
protected config: BrowserConfiguration;
|
|
@@ -67,8 +69,7 @@ export abstract class BaseInteractionClient {
|
|
|
67
69
|
this.eventHandler = eventHandler;
|
|
68
70
|
this.navigationClient = navigationClient;
|
|
69
71
|
this.nativeMessageHandler = nativeMessageHandler;
|
|
70
|
-
this.correlationId =
|
|
71
|
-
correlationId || this.browserCrypto.createNewGuid();
|
|
72
|
+
this.correlationId = correlationId || createNewGuid();
|
|
72
73
|
this.logger = logger.clone(
|
|
73
74
|
BrowserConstants.MSAL_SKU,
|
|
74
75
|
version,
|
|
@@ -142,7 +143,6 @@ export abstract class BaseInteractionClient {
|
|
|
142
143
|
PerformanceEvents.InitializeBaseRequest,
|
|
143
144
|
request.correlationId
|
|
144
145
|
);
|
|
145
|
-
this.logger.verbose("Initializing BaseAuthRequest");
|
|
146
146
|
const authority = request.authority || this.config.auth.authority;
|
|
147
147
|
|
|
148
148
|
if (account) {
|
|
@@ -170,10 +170,14 @@ export abstract class BaseInteractionClient {
|
|
|
170
170
|
AuthenticationScheme.SSH
|
|
171
171
|
) {
|
|
172
172
|
if (!request.sshJwk) {
|
|
173
|
-
throw
|
|
173
|
+
throw createClientConfigurationError(
|
|
174
|
+
ClientConfigurationErrorCodes.missingSshJwk
|
|
175
|
+
);
|
|
174
176
|
}
|
|
175
177
|
if (!request.sshKid) {
|
|
176
|
-
throw
|
|
178
|
+
throw createClientConfigurationError(
|
|
179
|
+
ClientConfigurationErrorCodes.missingSshKid
|
|
180
|
+
);
|
|
177
181
|
}
|
|
178
182
|
}
|
|
179
183
|
this.logger.verbose(
|
|
@@ -227,7 +231,9 @@ export abstract class BaseInteractionClient {
|
|
|
227
231
|
);
|
|
228
232
|
|
|
229
233
|
if (!discoveredAuthority.isAlias(account.environment)) {
|
|
230
|
-
throw
|
|
234
|
+
throw createClientConfigurationError(
|
|
235
|
+
ClientConfigurationErrorCodes.authorityMismatch
|
|
236
|
+
);
|
|
231
237
|
}
|
|
232
238
|
}
|
|
233
239
|
|
|
@@ -22,13 +22,17 @@ import {
|
|
|
22
22
|
PerformanceEvents,
|
|
23
23
|
IdTokenEntity,
|
|
24
24
|
AccessTokenEntity,
|
|
25
|
-
ClientAuthError,
|
|
26
25
|
AuthError,
|
|
27
26
|
CommonSilentFlowRequest,
|
|
28
27
|
AccountInfo,
|
|
29
28
|
CacheRecord,
|
|
30
29
|
AADServerParamKeys,
|
|
31
30
|
TokenClaims,
|
|
31
|
+
createClientAuthError,
|
|
32
|
+
ClientAuthErrorCodes,
|
|
33
|
+
invokeAsync,
|
|
34
|
+
createAuthError,
|
|
35
|
+
AuthErrorCodes,
|
|
32
36
|
} from "@azure/msal-common";
|
|
33
37
|
import { BaseInteractionClient } from "./BaseInteractionClient";
|
|
34
38
|
import { BrowserConfiguration } from "../config/Configuration";
|
|
@@ -49,7 +53,12 @@ import {
|
|
|
49
53
|
NativeTokenRequest,
|
|
50
54
|
} from "../broker/nativeBroker/NativeRequest";
|
|
51
55
|
import { MATS, NativeResponse } from "../broker/nativeBroker/NativeResponse";
|
|
52
|
-
import {
|
|
56
|
+
import {
|
|
57
|
+
NativeAuthError,
|
|
58
|
+
NativeAuthErrorCodes,
|
|
59
|
+
createNativeAuthError,
|
|
60
|
+
isFatalNativeAuthError,
|
|
61
|
+
} from "../error/NativeAuthError";
|
|
53
62
|
import { RedirectRequest } from "../request/RedirectRequest";
|
|
54
63
|
import { NavigationOptions } from "../navigation/NavigationOptions";
|
|
55
64
|
import { INavigationClient } from "../navigation/INavigationClient";
|
|
@@ -122,6 +131,10 @@ export class NativeInteractionClient extends BaseInteractionClient {
|
|
|
122
131
|
async acquireToken(
|
|
123
132
|
request: PopupRequest | SilentRequest | SsoSilentRequest
|
|
124
133
|
): Promise<AuthenticationResult> {
|
|
134
|
+
this.performanceClient.addQueueMeasurement(
|
|
135
|
+
PerformanceEvents.NativeInteractionClientAcquireToken,
|
|
136
|
+
request.correlationId
|
|
137
|
+
);
|
|
125
138
|
this.logger.trace("NativeInteractionClient - acquireToken called.");
|
|
126
139
|
|
|
127
140
|
// start the perf measurement
|
|
@@ -222,14 +235,15 @@ export class NativeInteractionClient extends BaseInteractionClient {
|
|
|
222
235
|
this.logger.warning(
|
|
223
236
|
"NativeInteractionClient:acquireTokensFromCache - No nativeAccountId provided"
|
|
224
237
|
);
|
|
225
|
-
throw
|
|
238
|
+
throw createClientAuthError(ClientAuthErrorCodes.noAccountFound);
|
|
226
239
|
}
|
|
227
240
|
// fetch the account from browser cache
|
|
228
|
-
const account = this.browserStorage.
|
|
241
|
+
const account = this.browserStorage.getBaseAccountInfo({
|
|
229
242
|
nativeAccountId,
|
|
230
243
|
});
|
|
244
|
+
|
|
231
245
|
if (!account) {
|
|
232
|
-
throw
|
|
246
|
+
throw createClientAuthError(ClientAuthErrorCodes.noAccountFound);
|
|
233
247
|
}
|
|
234
248
|
|
|
235
249
|
// leverage silent flow for cached tokens retrieval
|
|
@@ -241,9 +255,15 @@ export class NativeInteractionClient extends BaseInteractionClient {
|
|
|
241
255
|
const result = await this.silentCacheClient.acquireToken(
|
|
242
256
|
silentRequest
|
|
243
257
|
);
|
|
258
|
+
|
|
259
|
+
const fullAccount = {
|
|
260
|
+
...account,
|
|
261
|
+
idTokenClaims: result?.idTokenClaims as TokenClaims,
|
|
262
|
+
};
|
|
263
|
+
|
|
244
264
|
return {
|
|
245
265
|
...result,
|
|
246
|
-
account,
|
|
266
|
+
account: fullAccount,
|
|
247
267
|
};
|
|
248
268
|
} catch (e) {
|
|
249
269
|
throw e;
|
|
@@ -271,7 +291,7 @@ export class NativeInteractionClient extends BaseInteractionClient {
|
|
|
271
291
|
this.validateNativeResponse(response);
|
|
272
292
|
} catch (e) {
|
|
273
293
|
// Only throw fatal errors here to allow application to fallback to regular redirect. Otherwise proceed and the error will be thrown in handleRedirectPromise
|
|
274
|
-
if (e instanceof NativeAuthError && e
|
|
294
|
+
if (e instanceof NativeAuthError && isFatalNativeAuthError(e)) {
|
|
275
295
|
throw e;
|
|
276
296
|
}
|
|
277
297
|
}
|
|
@@ -384,7 +404,7 @@ export class NativeInteractionClient extends BaseInteractionClient {
|
|
|
384
404
|
|
|
385
405
|
if (response.account.id !== request.accountId) {
|
|
386
406
|
// User switch in native broker prompt is not supported. All users must first sign in through web flow to ensure server state is in sync
|
|
387
|
-
throw
|
|
407
|
+
throw createNativeAuthError(NativeAuthErrorCodes.userSwitch);
|
|
388
408
|
}
|
|
389
409
|
|
|
390
410
|
// Get the preferred_cache domain for the given authority
|
|
@@ -510,7 +530,7 @@ export class NativeInteractionClient extends BaseInteractionClient {
|
|
|
510
530
|
* PopTokenGenerator to query the full key for signing
|
|
511
531
|
*/
|
|
512
532
|
if (!request.keyId) {
|
|
513
|
-
throw
|
|
533
|
+
throw createClientAuthError(ClientAuthErrorCodes.keyIdMissing);
|
|
514
534
|
}
|
|
515
535
|
return await popTokenGenerator.signPopToken(
|
|
516
536
|
response.access_token,
|
|
@@ -559,6 +579,15 @@ export class NativeInteractionClient extends BaseInteractionClient {
|
|
|
559
579
|
idTokenClaims.tid ||
|
|
560
580
|
Constants.EMPTY_STRING;
|
|
561
581
|
|
|
582
|
+
const fullAccountEntity: AccountEntity = idTokenClaims
|
|
583
|
+
? Object.assign(new AccountEntity(), {
|
|
584
|
+
...accountEntity,
|
|
585
|
+
idTokenClaims: idTokenClaims,
|
|
586
|
+
})
|
|
587
|
+
: accountEntity;
|
|
588
|
+
|
|
589
|
+
const accountInfo = fullAccountEntity.getAccountInfo();
|
|
590
|
+
|
|
562
591
|
// generate PoP token as needed
|
|
563
592
|
const responseAccessToken = await this.generatePopAccessToken(
|
|
564
593
|
response,
|
|
@@ -574,7 +603,7 @@ export class NativeInteractionClient extends BaseInteractionClient {
|
|
|
574
603
|
uniqueId: uid,
|
|
575
604
|
tenantId: tid,
|
|
576
605
|
scopes: responseScopes.asArray(),
|
|
577
|
-
account:
|
|
606
|
+
account: accountInfo,
|
|
578
607
|
idToken: response.id_token,
|
|
579
608
|
idTokenClaims: idTokenClaims,
|
|
580
609
|
accessToken: responseAccessToken,
|
|
@@ -719,7 +748,8 @@ export class NativeInteractionClient extends BaseInteractionClient {
|
|
|
719
748
|
) {
|
|
720
749
|
return response as NativeResponse;
|
|
721
750
|
} else {
|
|
722
|
-
throw
|
|
751
|
+
throw createAuthError(
|
|
752
|
+
AuthErrorCodes.unexpectedError,
|
|
723
753
|
"Response missing expected properties."
|
|
724
754
|
);
|
|
725
755
|
}
|
|
@@ -859,9 +889,13 @@ export class NativeInteractionClient extends BaseInteractionClient {
|
|
|
859
889
|
};
|
|
860
890
|
|
|
861
891
|
const popTokenGenerator = new PopTokenGenerator(this.browserCrypto);
|
|
862
|
-
const reqCnfData = await
|
|
863
|
-
|
|
864
|
-
|
|
892
|
+
const reqCnfData = await invokeAsync(
|
|
893
|
+
popTokenGenerator.generateCnf.bind(popTokenGenerator),
|
|
894
|
+
PerformanceEvents.PopTokenGenerateCnf,
|
|
895
|
+
this.logger,
|
|
896
|
+
this.performanceClient,
|
|
897
|
+
this.correlationId
|
|
898
|
+
)(shrParameters, this.logger);
|
|
865
899
|
|
|
866
900
|
// to reduce the URL length, it is recommended to send the hash of the req_cnf instead of the whole string
|
|
867
901
|
validatedRequest.reqCnf = reqCnfData.reqCnfHash;
|
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
} from "../utils/BrowserConstants";
|
|
31
31
|
import { EndSessionPopupRequest } from "../request/EndSessionPopupRequest";
|
|
32
32
|
import { NavigationOptions } from "../navigation/NavigationOptions";
|
|
33
|
-
import
|
|
33
|
+
import * as BrowserUtils from "../utils/BrowserUtils";
|
|
34
34
|
import { PopupRequest } from "../request/PopupRequest";
|
|
35
35
|
import { NativeInteractionClient } from "./NativeInteractionClient";
|
|
36
36
|
import { NativeMessageHandler } from "../broker/nativeBroker/NativeMessageHandler";
|
|
@@ -211,6 +211,7 @@ export class PopupClient extends StandardInteractionClient {
|
|
|
211
211
|
request,
|
|
212
212
|
InteractionType.Popup
|
|
213
213
|
);
|
|
214
|
+
BrowserUtils.preconnect(validRequest.authority);
|
|
214
215
|
this.browserStorage.updateCacheEntries(
|
|
215
216
|
validRequest.state,
|
|
216
217
|
validRequest.nonce,
|
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
TemporaryCacheKeys,
|
|
27
27
|
} from "../utils/BrowserConstants";
|
|
28
28
|
import { RedirectHandler } from "../interaction_handler/RedirectHandler";
|
|
29
|
-
import
|
|
29
|
+
import * as BrowserUtils from "../utils/BrowserUtils";
|
|
30
30
|
import { EndSessionRequest } from "../request/EndSessionRequest";
|
|
31
31
|
import { EventType } from "../event/EventType";
|
|
32
32
|
import { NavigationOptions } from "../navigation/NavigationOptions";
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
Constants,
|
|
12
12
|
IPerformanceClient,
|
|
13
13
|
PerformanceEvents,
|
|
14
|
+
invokeAsync,
|
|
14
15
|
} from "@azure/msal-common";
|
|
15
16
|
import { StandardInteractionClient } from "./StandardInteractionClient";
|
|
16
17
|
import { AuthorizationUrlRequest } from "../request/AuthorizationUrlRequest";
|
|
@@ -23,11 +24,11 @@ import {
|
|
|
23
24
|
BrowserAuthErrorCodes,
|
|
24
25
|
} from "../error/BrowserAuthError";
|
|
25
26
|
import { InteractionType, ApiId } from "../utils/BrowserConstants";
|
|
26
|
-
import { SilentHandler } from "../interaction_handler/SilentHandler";
|
|
27
27
|
import { AuthorizationCodeRequest } from "../request/AuthorizationCodeRequest";
|
|
28
28
|
import { HybridSpaAuthorizationCodeClient } from "./HybridSpaAuthorizationCodeClient";
|
|
29
29
|
import { NativeMessageHandler } from "../broker/nativeBroker/NativeMessageHandler";
|
|
30
30
|
import { AuthenticationResult } from "../response/AuthenticationResult";
|
|
31
|
+
import { InteractionHandler } from "../interaction_handler/InteractionHandler";
|
|
31
32
|
|
|
32
33
|
export class SilentAuthCodeClient extends StandardInteractionClient {
|
|
33
34
|
private apiId: ApiId;
|
|
@@ -65,8 +66,6 @@ export class SilentAuthCodeClient extends StandardInteractionClient {
|
|
|
65
66
|
async acquireToken(
|
|
66
67
|
request: AuthorizationCodeRequest
|
|
67
68
|
): Promise<AuthenticationResult> {
|
|
68
|
-
this.logger.trace("SilentAuthCodeClient.acquireToken called");
|
|
69
|
-
|
|
70
69
|
// Auth code payload is required
|
|
71
70
|
if (!request.code) {
|
|
72
71
|
throw createBrowserAuthError(
|
|
@@ -75,15 +74,13 @@ export class SilentAuthCodeClient extends StandardInteractionClient {
|
|
|
75
74
|
}
|
|
76
75
|
|
|
77
76
|
// Create silent request
|
|
78
|
-
|
|
77
|
+
const silentRequest: AuthorizationUrlRequest = await invokeAsync(
|
|
78
|
+
this.initializeAuthorizationRequest.bind(this),
|
|
79
79
|
PerformanceEvents.StandardInteractionClientInitializeAuthorizationRequest,
|
|
80
|
+
this.logger,
|
|
81
|
+
this.performanceClient,
|
|
80
82
|
request.correlationId
|
|
81
|
-
);
|
|
82
|
-
const silentRequest: AuthorizationUrlRequest =
|
|
83
|
-
await this.initializeAuthorizationRequest(
|
|
84
|
-
request,
|
|
85
|
-
InteractionType.Silent
|
|
86
|
-
);
|
|
83
|
+
)(request, InteractionType.Silent);
|
|
87
84
|
this.browserStorage.updateCacheEntries(
|
|
88
85
|
silentRequest.state,
|
|
89
86
|
silentRequest.nonce,
|
|
@@ -104,30 +101,36 @@ export class SilentAuthCodeClient extends StandardInteractionClient {
|
|
|
104
101
|
};
|
|
105
102
|
|
|
106
103
|
// Initialize the client
|
|
107
|
-
|
|
104
|
+
const clientConfig = await invokeAsync(
|
|
105
|
+
this.getClientConfiguration.bind(this),
|
|
108
106
|
PerformanceEvents.StandardInteractionClientGetClientConfiguration,
|
|
107
|
+
this.logger,
|
|
108
|
+
this.performanceClient,
|
|
109
109
|
request.correlationId
|
|
110
|
-
);
|
|
111
|
-
const clientConfig = await this.getClientConfiguration(
|
|
112
|
-
serverTelemetryManager,
|
|
113
|
-
silentRequest.authority
|
|
114
|
-
);
|
|
110
|
+
)(serverTelemetryManager, silentRequest.authority);
|
|
115
111
|
const authClient: HybridSpaAuthorizationCodeClient =
|
|
116
112
|
new HybridSpaAuthorizationCodeClient(clientConfig);
|
|
117
113
|
this.logger.verbose("Auth code client created");
|
|
118
114
|
|
|
119
115
|
// Create silent handler
|
|
120
|
-
const
|
|
116
|
+
const interactionHandler = new InteractionHandler(
|
|
121
117
|
authClient,
|
|
122
118
|
this.browserStorage,
|
|
123
119
|
authCodeRequest,
|
|
124
120
|
this.logger,
|
|
125
|
-
this.config.system,
|
|
126
121
|
this.performanceClient
|
|
127
122
|
);
|
|
128
123
|
|
|
129
124
|
// Handle auth code parameters from request
|
|
130
|
-
return
|
|
125
|
+
return invokeAsync(
|
|
126
|
+
interactionHandler.handleCodeResponseFromServer.bind(
|
|
127
|
+
interactionHandler
|
|
128
|
+
),
|
|
129
|
+
PerformanceEvents.HandleCodeResponseFromServer,
|
|
130
|
+
this.logger,
|
|
131
|
+
this.performanceClient,
|
|
132
|
+
request.correlationId
|
|
133
|
+
)(
|
|
131
134
|
{
|
|
132
135
|
code: request.code,
|
|
133
136
|
msgraph_host: request.msGraphHost,
|