@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
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { TokenRequest } from "../TokenRequest";
|
|
7
|
+
import { AccountInfo as NaaAccountInfo } from "../AccountInfo";
|
|
8
|
+
import { RedirectRequest } from "../../request/RedirectRequest";
|
|
9
|
+
import { PopupRequest } from "../../request/PopupRequest";
|
|
10
|
+
import { TokenResponse } from "../TokenResponse";
|
|
11
|
+
import {
|
|
12
|
+
AccountInfo as MsalAccountInfo,
|
|
13
|
+
AuthError,
|
|
14
|
+
ClientAuthError,
|
|
15
|
+
ClientConfigurationError,
|
|
16
|
+
InteractionRequiredAuthError,
|
|
17
|
+
ServerError,
|
|
18
|
+
TimeUtils,
|
|
19
|
+
ICrypto,
|
|
20
|
+
Logger,
|
|
21
|
+
AuthToken,
|
|
22
|
+
TokenClaims,
|
|
23
|
+
ClientAuthErrorCodes,
|
|
24
|
+
} from "@azure/msal-common";
|
|
25
|
+
import { isBridgeError } from "../BridgeError";
|
|
26
|
+
import { BridgeStatusCode } from "../BridgeStatusCode";
|
|
27
|
+
import { SilentRequest } from "../../request/SilentRequest";
|
|
28
|
+
import { AuthenticationResult } from "../../response/AuthenticationResult";
|
|
29
|
+
import {} from "../../error/BrowserAuthErrorCodes";
|
|
30
|
+
|
|
31
|
+
export class NestedAppAuthAdapter {
|
|
32
|
+
protected crypto: ICrypto;
|
|
33
|
+
protected logger: Logger;
|
|
34
|
+
protected clientId: string;
|
|
35
|
+
protected clientCapabilities: string[];
|
|
36
|
+
|
|
37
|
+
constructor(
|
|
38
|
+
clientId: string,
|
|
39
|
+
clientCapabilities: string[],
|
|
40
|
+
crypto: ICrypto,
|
|
41
|
+
logger: Logger
|
|
42
|
+
) {
|
|
43
|
+
this.clientId = clientId;
|
|
44
|
+
this.clientCapabilities = clientCapabilities;
|
|
45
|
+
this.crypto = crypto;
|
|
46
|
+
this.logger = logger;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
public toNaaSilentTokenRequest(request: SilentRequest): TokenRequest {
|
|
50
|
+
let extraParams: Map<string, string>;
|
|
51
|
+
if (request.extraQueryParameters === undefined) {
|
|
52
|
+
extraParams = new Map<string, string>();
|
|
53
|
+
} else {
|
|
54
|
+
extraParams = new Map<string, string>(
|
|
55
|
+
Object.entries(request.extraQueryParameters)
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Need to get information about the client to populate request correctly
|
|
60
|
+
* For example: client id, client capabilities
|
|
61
|
+
*/
|
|
62
|
+
const tokenRequest: TokenRequest = {
|
|
63
|
+
userObjectId: request.account?.homeAccountId,
|
|
64
|
+
clientId: this.clientId,
|
|
65
|
+
authority: request.authority,
|
|
66
|
+
scope: request.scopes.join(" "),
|
|
67
|
+
correlationId:
|
|
68
|
+
request.correlationId !== undefined
|
|
69
|
+
? request.correlationId
|
|
70
|
+
: this.crypto.createNewGuid(),
|
|
71
|
+
prompt: request.prompt !== undefined ? request.prompt : "",
|
|
72
|
+
claims: request.claims !== undefined ? request.claims : "",
|
|
73
|
+
authenticationScheme:
|
|
74
|
+
request.authenticationScheme !== undefined
|
|
75
|
+
? request.authenticationScheme
|
|
76
|
+
: "",
|
|
77
|
+
clientCapabilities: this.clientCapabilities,
|
|
78
|
+
extraParameters: extraParams,
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
return tokenRequest;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
public toNaaTokenRequest(
|
|
85
|
+
request: PopupRequest | RedirectRequest
|
|
86
|
+
): TokenRequest {
|
|
87
|
+
let extraParams: Map<string, string>;
|
|
88
|
+
if (request.extraQueryParameters === undefined) {
|
|
89
|
+
extraParams = new Map<string, string>();
|
|
90
|
+
} else {
|
|
91
|
+
extraParams = new Map<string, string>(
|
|
92
|
+
Object.entries(request.extraQueryParameters)
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const tokenRequest: TokenRequest = {
|
|
97
|
+
userObjectId: request.account?.homeAccountId,
|
|
98
|
+
clientId: this.clientId,
|
|
99
|
+
authority: request.authority,
|
|
100
|
+
scope: request.scopes.join(" "),
|
|
101
|
+
correlationId:
|
|
102
|
+
request.correlationId !== undefined
|
|
103
|
+
? request.correlationId
|
|
104
|
+
: "",
|
|
105
|
+
prompt: request.prompt !== undefined ? request.prompt : "",
|
|
106
|
+
nonce: request.nonce !== undefined ? request.nonce : "",
|
|
107
|
+
claims: request.claims !== undefined ? request.claims : "",
|
|
108
|
+
state: request.state !== undefined ? request.state : "",
|
|
109
|
+
authenticationScheme:
|
|
110
|
+
request.authenticationScheme !== undefined
|
|
111
|
+
? request.authenticationScheme
|
|
112
|
+
: "",
|
|
113
|
+
clientCapabilities: undefined,
|
|
114
|
+
extraParameters: extraParams,
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
return tokenRequest;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
public fromNaaTokenResponse(
|
|
121
|
+
request: TokenRequest,
|
|
122
|
+
response: TokenResponse
|
|
123
|
+
): AuthenticationResult {
|
|
124
|
+
const expiresOn = new Date(
|
|
125
|
+
TimeUtils.nowSeconds() + (response.expires_in || 0) * 1000
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
const account = this.fromNaaAccountInfo(response.account);
|
|
129
|
+
|
|
130
|
+
const authenticationResult: AuthenticationResult = {
|
|
131
|
+
authority: response.account.environment,
|
|
132
|
+
uniqueId: response.account.homeAccountId,
|
|
133
|
+
tenantId: response.account.tenantId,
|
|
134
|
+
scopes: response.scope.split(" "),
|
|
135
|
+
account: this.fromNaaAccountInfo(response.account),
|
|
136
|
+
idToken: response.id_token !== undefined ? response.id_token : "",
|
|
137
|
+
idTokenClaims:
|
|
138
|
+
account.idTokenClaims !== undefined
|
|
139
|
+
? account.idTokenClaims
|
|
140
|
+
: {},
|
|
141
|
+
accessToken: response.access_token,
|
|
142
|
+
fromCache: true,
|
|
143
|
+
expiresOn: expiresOn,
|
|
144
|
+
tokenType:
|
|
145
|
+
request.authenticationScheme !== undefined
|
|
146
|
+
? request.authenticationScheme
|
|
147
|
+
: "Bearer",
|
|
148
|
+
correlationId: request.correlationId,
|
|
149
|
+
requestId: "",
|
|
150
|
+
extExpiresOn: expiresOn,
|
|
151
|
+
state: response.state,
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
return authenticationResult;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/*
|
|
158
|
+
* export type AccountInfo = {
|
|
159
|
+
* homeAccountId: string;
|
|
160
|
+
* environment: string;
|
|
161
|
+
* tenantId: string;
|
|
162
|
+
* username: string;
|
|
163
|
+
* localAccountId: string;
|
|
164
|
+
* name?: string;
|
|
165
|
+
* idToken?: string;
|
|
166
|
+
* idTokenClaims?: TokenClaims & {
|
|
167
|
+
* [key: string]:
|
|
168
|
+
* | string
|
|
169
|
+
* | number
|
|
170
|
+
* | string[]
|
|
171
|
+
* | object
|
|
172
|
+
* | undefined
|
|
173
|
+
* | unknown;
|
|
174
|
+
* };
|
|
175
|
+
* nativeAccountId?: string;
|
|
176
|
+
* authorityType?: string;
|
|
177
|
+
* };
|
|
178
|
+
*/
|
|
179
|
+
public fromNaaAccountInfo(fromAccount: NaaAccountInfo): MsalAccountInfo {
|
|
180
|
+
let tokenClaims: TokenClaims | undefined;
|
|
181
|
+
if (fromAccount.idToken !== undefined) {
|
|
182
|
+
tokenClaims = AuthToken.extractTokenClaims(
|
|
183
|
+
fromAccount.idToken,
|
|
184
|
+
this.crypto.base64Decode
|
|
185
|
+
);
|
|
186
|
+
} else {
|
|
187
|
+
tokenClaims = undefined;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const account: MsalAccountInfo = {
|
|
191
|
+
homeAccountId: fromAccount.homeAccountId,
|
|
192
|
+
environment: fromAccount.environment,
|
|
193
|
+
tenantId: fromAccount.tenantId,
|
|
194
|
+
username: fromAccount.username,
|
|
195
|
+
localAccountId: fromAccount.localAccountId,
|
|
196
|
+
name: fromAccount.name,
|
|
197
|
+
idToken: fromAccount.idToken,
|
|
198
|
+
idTokenClaims: tokenClaims,
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
return account;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
*
|
|
206
|
+
* @param error BridgeError
|
|
207
|
+
* @returns AuthError, ClientAuthError, ClientConfigurationError, ServerError, InteractionRequiredError
|
|
208
|
+
*/
|
|
209
|
+
public fromBridgeError(
|
|
210
|
+
error: unknown
|
|
211
|
+
):
|
|
212
|
+
| AuthError
|
|
213
|
+
| ClientAuthError
|
|
214
|
+
| ClientConfigurationError
|
|
215
|
+
| ServerError
|
|
216
|
+
| InteractionRequiredAuthError {
|
|
217
|
+
if (isBridgeError(error)) {
|
|
218
|
+
switch (error.status) {
|
|
219
|
+
case BridgeStatusCode.USER_CANCEL:
|
|
220
|
+
return new ClientAuthError(
|
|
221
|
+
ClientAuthErrorCodes.userCanceled
|
|
222
|
+
);
|
|
223
|
+
case BridgeStatusCode.NO_NETWORK:
|
|
224
|
+
return new ClientAuthError(
|
|
225
|
+
ClientAuthErrorCodes.noNetworkConnectivity
|
|
226
|
+
);
|
|
227
|
+
case BridgeStatusCode.ACCOUNT_UNAVAILABLE:
|
|
228
|
+
return new ClientAuthError(
|
|
229
|
+
ClientAuthErrorCodes.noAccountFound
|
|
230
|
+
);
|
|
231
|
+
case BridgeStatusCode.DISABLED:
|
|
232
|
+
return new ClientAuthError(
|
|
233
|
+
ClientAuthErrorCodes.nestedAppAuthBridgeDisabled
|
|
234
|
+
);
|
|
235
|
+
case BridgeStatusCode.NESTED_APP_AUTH_UNAVAILABLE:
|
|
236
|
+
return new ClientAuthError(error.code, error.description);
|
|
237
|
+
case BridgeStatusCode.TRANSIENT_ERROR:
|
|
238
|
+
case BridgeStatusCode.PERSISTENT_ERROR:
|
|
239
|
+
return new ServerError(error.code, error.description);
|
|
240
|
+
case BridgeStatusCode.USER_INTERACTION_REQUIRED:
|
|
241
|
+
return new InteractionRequiredAuthError(
|
|
242
|
+
error.code,
|
|
243
|
+
error.description
|
|
244
|
+
);
|
|
245
|
+
default:
|
|
246
|
+
return new AuthError(error.code, error.description);
|
|
247
|
+
}
|
|
248
|
+
} else {
|
|
249
|
+
return new AuthError("unknown_error", "An unknown error occurred");
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
@@ -4,8 +4,14 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { BaseOperatingContext } from "./BaseOperatingContext";
|
|
7
|
+
import { IBridgeProxy } from "../naa/IBridgeProxy";
|
|
8
|
+
import { BridgeProxy } from "../naa/BridgeProxy";
|
|
9
|
+
import { AccountInfo } from "../naa/AccountInfo";
|
|
7
10
|
|
|
8
11
|
export class TeamsAppOperatingContext extends BaseOperatingContext {
|
|
12
|
+
protected bridgeProxy: IBridgeProxy | undefined = undefined;
|
|
13
|
+
protected activeAccount: AccountInfo | undefined = undefined;
|
|
14
|
+
|
|
9
15
|
/*
|
|
10
16
|
* TODO: Once we have determine the bundling code return here to specify the name of the bundle
|
|
11
17
|
* containing the implementation for this operating context
|
|
@@ -33,6 +39,18 @@ export class TeamsAppOperatingContext extends BaseOperatingContext {
|
|
|
33
39
|
return TeamsAppOperatingContext.ID;
|
|
34
40
|
}
|
|
35
41
|
|
|
42
|
+
getBridgeProxy(): IBridgeProxy | undefined {
|
|
43
|
+
return this.bridgeProxy;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
getActiveAccount(): AccountInfo | undefined {
|
|
47
|
+
return this.activeAccount;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
setActiveAccount(account: AccountInfo): void {
|
|
51
|
+
this.activeAccount = account;
|
|
52
|
+
}
|
|
53
|
+
|
|
36
54
|
/**
|
|
37
55
|
* Checks whether the operating context is available.
|
|
38
56
|
* Confirms that the code is running a browser rather. This is required.
|
|
@@ -40,9 +58,31 @@ export class TeamsAppOperatingContext extends BaseOperatingContext {
|
|
|
40
58
|
*/
|
|
41
59
|
async initialize(): Promise<boolean> {
|
|
42
60
|
/*
|
|
43
|
-
* TODO: Add implementation to check for presence of inject
|
|
44
|
-
*
|
|
61
|
+
* TODO: Add implementation to check for presence of inject Nested App Auth Bridge JavaScript interface
|
|
62
|
+
*
|
|
45
63
|
*/
|
|
46
|
-
|
|
64
|
+
try {
|
|
65
|
+
if (typeof window !== "undefined") {
|
|
66
|
+
const bridgeProxy: IBridgeProxy = await BridgeProxy.create();
|
|
67
|
+
/*
|
|
68
|
+
* Because we want single sign on we need to attempt to
|
|
69
|
+
* grab the active account as part of initialization
|
|
70
|
+
* this.activeAccount = await bridgeProxy.getActiveAccount();
|
|
71
|
+
*/
|
|
72
|
+
try {
|
|
73
|
+
this.activeAccount = await bridgeProxy.getActiveAccount();
|
|
74
|
+
} catch (e) {
|
|
75
|
+
this.activeAccount = undefined;
|
|
76
|
+
}
|
|
77
|
+
this.bridgeProxy = bridgeProxy;
|
|
78
|
+
this.available = bridgeProxy !== undefined;
|
|
79
|
+
} else {
|
|
80
|
+
this.available = false;
|
|
81
|
+
}
|
|
82
|
+
} catch (e) {
|
|
83
|
+
this.available = false;
|
|
84
|
+
} finally {
|
|
85
|
+
return this.available;
|
|
86
|
+
}
|
|
47
87
|
}
|
|
48
88
|
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { BaseOperatingContext } from "./BaseOperatingContext";
|
|
7
|
+
|
|
8
|
+
export class UnknownOperatingContext extends BaseOperatingContext {
|
|
9
|
+
/*
|
|
10
|
+
* TODO: Once we have determine the bundling code return here to specify the name of the bundle
|
|
11
|
+
* containing the implementation for this operating context
|
|
12
|
+
*/
|
|
13
|
+
static readonly MODULE_NAME: string = "";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Unique identifier for the operating context
|
|
17
|
+
*/
|
|
18
|
+
static readonly ID: string = "UnknownOperatingContext";
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Return the module name. Intended for use with import() to enable dynamic import
|
|
22
|
+
* of the implementation associated with this operating context
|
|
23
|
+
* @returns
|
|
24
|
+
*/
|
|
25
|
+
getModuleName(): string {
|
|
26
|
+
return UnknownOperatingContext.MODULE_NAME;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Returns the unique identifier for this operating context
|
|
30
|
+
* @returns string
|
|
31
|
+
*/
|
|
32
|
+
getId(): string {
|
|
33
|
+
return UnknownOperatingContext.ID;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Checks whether the operating context is available.
|
|
38
|
+
* Confirms that the code is running a browser rather. This is required.
|
|
39
|
+
* @returns Promise<boolean> indicating whether this operating context is currently available.
|
|
40
|
+
*/
|
|
41
|
+
async initialize(): Promise<boolean> {
|
|
42
|
+
/**
|
|
43
|
+
* This operating context is in use when we have not checked for what the operating context is.
|
|
44
|
+
* The context is unknown until we check it.
|
|
45
|
+
*/
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
}
|
package/src/packageMetadata.ts
CHANGED
|
@@ -5,12 +5,13 @@
|
|
|
5
5
|
|
|
6
6
|
import { InteractionType } from "./BrowserConstants";
|
|
7
7
|
import {
|
|
8
|
-
ClientAuthError,
|
|
9
8
|
ICrypto,
|
|
10
9
|
RequestStateObject,
|
|
11
10
|
ProtocolUtils,
|
|
12
11
|
ServerAuthorizationCodeResponse,
|
|
13
12
|
UrlString,
|
|
13
|
+
createClientAuthError,
|
|
14
|
+
ClientAuthErrorCodes,
|
|
14
15
|
} from "@azure/msal-common";
|
|
15
16
|
|
|
16
17
|
export type BrowserStateObject = {
|
|
@@ -36,7 +37,7 @@ export class BrowserProtocolUtils {
|
|
|
36
37
|
ProtocolUtils.parseRequestState(browserCrypto, state);
|
|
37
38
|
return requestStateObj.libraryState.meta as BrowserStateObject;
|
|
38
39
|
} catch (e) {
|
|
39
|
-
throw
|
|
40
|
+
throw createClientAuthError(ClientAuthErrorCodes.invalidState);
|
|
40
41
|
}
|
|
41
42
|
}
|
|
42
43
|
|