@azure/msal-browser 3.4.0 → 3.5.1-beta.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 +51 -51
- package/dist/app/IPublicClientApplication.mjs +102 -102
- package/dist/app/PublicClientApplication.d.ts +268 -268
- package/dist/app/PublicClientApplication.mjs +333 -333
- package/dist/app/PublicClientNext.d.ts +273 -273
- package/dist/app/PublicClientNext.mjs +351 -351
- package/dist/broker/nativeBroker/NativeMessageHandler.d.ts +62 -62
- package/dist/broker/nativeBroker/NativeMessageHandler.mjs +254 -254
- package/dist/broker/nativeBroker/NativeRequest.d.ts +44 -44
- package/dist/broker/nativeBroker/NativeResponse.d.ts +48 -48
- package/dist/broker/nativeBroker/NativeStatusCodes.d.ts +7 -7
- package/dist/broker/nativeBroker/NativeStatusCodes.mjs +11 -11
- package/dist/cache/AsyncMemoryStorage.d.ts +51 -51
- package/dist/cache/AsyncMemoryStorage.mjs +132 -132
- package/dist/cache/BrowserCacheManager.d.ts +383 -383
- package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
- package/dist/cache/BrowserCacheManager.mjs +1264 -1264
- package/dist/cache/BrowserCacheManager.mjs.map +1 -1
- package/dist/cache/BrowserStorage.d.ts +11 -11
- package/dist/cache/BrowserStorage.mjs +32 -32
- package/dist/cache/CryptoKeyStore.d.ts +18 -18
- package/dist/cache/CryptoKeyStore.mjs +40 -40
- package/dist/cache/DatabaseStorage.d.ts +56 -56
- package/dist/cache/DatabaseStorage.mjs +190 -190
- package/dist/cache/IAsyncMemoryStorage.d.ts +27 -27
- package/dist/cache/ITokenCache.d.ts +11 -11
- package/dist/cache/IWindowStorage.d.ts +27 -27
- package/dist/cache/MemoryStorage.d.ts +11 -11
- package/dist/cache/MemoryStorage.mjs +31 -31
- package/dist/cache/TokenCache.d.ts +77 -77
- package/dist/cache/TokenCache.mjs +224 -224
- package/dist/config/Configuration.d.ts +206 -206
- package/dist/config/Configuration.mjs +128 -128
- package/dist/controllers/ControllerFactory.d.ts +4 -4
- package/dist/controllers/ControllerFactory.mjs +29 -29
- package/dist/controllers/IController.d.ts +61 -61
- package/dist/controllers/NestedAppAuthController.d.ts +95 -95
- package/dist/controllers/NestedAppAuthController.d.ts.map +1 -1
- package/dist/controllers/NestedAppAuthController.mjs +335 -333
- package/dist/controllers/NestedAppAuthController.mjs.map +1 -1
- package/dist/controllers/StandardController.d.ts +407 -407
- package/dist/controllers/StandardController.d.ts.map +1 -1
- package/dist/controllers/StandardController.mjs +1294 -1291
- package/dist/controllers/StandardController.mjs.map +1 -1
- package/dist/controllers/UnknownOperatingContextController.d.ts +87 -87
- package/dist/controllers/UnknownOperatingContextController.mjs +264 -264
- package/dist/crypto/BrowserCrypto.d.ts +44 -44
- package/dist/crypto/BrowserCrypto.mjs +93 -93
- package/dist/crypto/CryptoOps.d.ts +63 -63
- package/dist/crypto/CryptoOps.d.ts.map +1 -1
- package/dist/crypto/CryptoOps.mjs +145 -144
- package/dist/crypto/CryptoOps.mjs.map +1 -1
- package/dist/crypto/PkceGenerator.d.ts +8 -8
- package/dist/crypto/PkceGenerator.mjs +54 -54
- package/dist/crypto/SignedHttpRequest.d.ts +30 -30
- package/dist/crypto/SignedHttpRequest.mjs +39 -39
- package/dist/encode/Base64Decode.d.ts +9 -9
- package/dist/encode/Base64Decode.mjs +36 -36
- package/dist/encode/Base64Encode.d.ts +19 -19
- package/dist/encode/Base64Encode.mjs +43 -43
- package/dist/error/BrowserAuthError.d.ts +250 -250
- package/dist/error/BrowserAuthError.mjs +258 -258
- package/dist/error/BrowserAuthErrorCodes.d.ts +45 -45
- package/dist/error/BrowserAuthErrorCodes.mjs +49 -49
- package/dist/error/BrowserConfigurationAuthError.d.ts +33 -33
- package/dist/error/BrowserConfigurationAuthError.mjs +40 -40
- package/dist/error/BrowserConfigurationAuthErrorCodes.d.ts +3 -3
- package/dist/error/BrowserConfigurationAuthErrorCodes.mjs +7 -7
- package/dist/error/NativeAuthError.d.ts +29 -29
- package/dist/error/NativeAuthError.mjs +60 -60
- package/dist/error/NativeAuthErrorCodes.d.ts +2 -2
- package/dist/error/NativeAuthErrorCodes.mjs +6 -6
- package/dist/error/NestedAppAuthError.d.ts +14 -14
- package/dist/error/NestedAppAuthError.mjs +23 -23
- package/dist/event/EventHandler.d.ts +41 -41
- package/dist/event/EventHandler.mjs +119 -119
- package/dist/event/EventMessage.d.ts +25 -25
- package/dist/event/EventMessage.mjs +68 -68
- package/dist/event/EventType.d.ts +28 -28
- package/dist/event/EventType.mjs +31 -31
- package/dist/index.d.ts +39 -39
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/interaction_client/BaseInteractionClient.d.ts +54 -55
- package/dist/interaction_client/BaseInteractionClient.d.ts.map +1 -1
- package/dist/interaction_client/BaseInteractionClient.mjs +152 -153
- package/dist/interaction_client/BaseInteractionClient.mjs.map +1 -1
- package/dist/interaction_client/HybridSpaAuthorizationCodeClient.d.ts +4 -4
- package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +10 -10
- package/dist/interaction_client/NativeInteractionClient.d.ts +140 -140
- package/dist/interaction_client/NativeInteractionClient.mjs +548 -548
- package/dist/interaction_client/PopupClient.d.ts +105 -115
- package/dist/interaction_client/PopupClient.d.ts.map +1 -1
- package/dist/interaction_client/PopupClient.mjs +435 -505
- package/dist/interaction_client/PopupClient.mjs.map +1 -1
- package/dist/interaction_client/RedirectClient.d.ts +49 -49
- package/dist/interaction_client/RedirectClient.d.ts.map +1 -1
- package/dist/interaction_client/RedirectClient.mjs +314 -297
- package/dist/interaction_client/RedirectClient.mjs.map +1 -1
- package/dist/interaction_client/SilentAuthCodeClient.d.ts +23 -23
- package/dist/interaction_client/SilentAuthCodeClient.mjs +57 -57
- package/dist/interaction_client/SilentCacheClient.d.ts +24 -24
- package/dist/interaction_client/SilentCacheClient.mjs +61 -61
- package/dist/interaction_client/SilentIframeClient.d.ts +32 -32
- package/dist/interaction_client/SilentIframeClient.d.ts.map +1 -1
- package/dist/interaction_client/SilentIframeClient.mjs +99 -108
- package/dist/interaction_client/SilentIframeClient.mjs.map +1 -1
- package/dist/interaction_client/SilentRefreshClient.d.ts +20 -20
- package/dist/interaction_client/SilentRefreshClient.mjs +43 -43
- package/dist/interaction_client/StandardInteractionClient.d.ts +54 -59
- package/dist/interaction_client/StandardInteractionClient.d.ts.map +1 -1
- package/dist/interaction_client/StandardInteractionClient.mjs +222 -244
- package/dist/interaction_client/StandardInteractionClient.mjs.map +1 -1
- package/dist/interaction_handler/InteractionHandler.d.ts +33 -33
- package/dist/interaction_handler/InteractionHandler.d.ts.map +1 -1
- package/dist/interaction_handler/InteractionHandler.mjs +94 -98
- package/dist/interaction_handler/InteractionHandler.mjs.map +1 -1
- package/dist/interaction_handler/RedirectHandler.d.ts +32 -32
- package/dist/interaction_handler/RedirectHandler.d.ts.map +1 -1
- package/dist/interaction_handler/RedirectHandler.mjs +135 -139
- package/dist/interaction_handler/RedirectHandler.mjs.map +1 -1
- package/dist/interaction_handler/SilentHandler.d.ts +13 -13
- package/dist/interaction_handler/SilentHandler.d.ts.map +1 -1
- package/dist/interaction_handler/SilentHandler.mjs +134 -128
- package/dist/interaction_handler/SilentHandler.mjs.map +1 -1
- package/dist/naa/AccountInfo.d.ts +11 -12
- package/dist/naa/AccountInfo.d.ts.map +1 -1
- package/dist/naa/AccountRequests.d.ts +9 -9
- package/dist/naa/AuthBridge.d.ts +5 -5
- package/dist/naa/BridgeCapabilities.d.ts +3 -3
- package/dist/naa/BridgeError.d.ts +9 -9
- package/dist/naa/BridgeError.d.ts.map +1 -1
- package/dist/naa/BridgeError.mjs +7 -7
- package/dist/naa/BridgeError.mjs.map +1 -1
- package/dist/naa/BridgeProxy.d.ts +72 -71
- package/dist/naa/BridgeProxy.d.ts.map +1 -1
- package/dist/naa/BridgeProxy.mjs +152 -149
- package/dist/naa/BridgeProxy.mjs.map +1 -1
- package/dist/naa/BridgeRequest.d.ts +6 -6
- package/dist/naa/BridgeRequestEnvelope.d.ts +13 -13
- package/dist/naa/BridgeResponseEnvelope.d.ts +10 -10
- package/dist/naa/BridgeStatusCode.d.ts +10 -10
- package/dist/naa/BridgeStatusCode.mjs +15 -15
- package/dist/naa/IBridgeProxy.d.ts +12 -10
- package/dist/naa/IBridgeProxy.d.ts.map +1 -1
- package/dist/naa/InitializeBridgeResponse.d.ts +6 -6
- package/dist/naa/InitializeBridgeResponse.d.ts.map +1 -1
- package/dist/naa/TokenRequest.d.ts +19 -21
- package/dist/naa/TokenRequest.d.ts.map +1 -1
- package/dist/naa/TokenResponse.d.ts +15 -16
- package/dist/naa/TokenResponse.d.ts.map +1 -1
- package/dist/naa/mapping/NestedAppAuthAdapter.d.ts +23 -25
- package/dist/naa/mapping/NestedAppAuthAdapter.d.ts.map +1 -1
- package/dist/naa/mapping/NestedAppAuthAdapter.mjs +142 -170
- package/dist/naa/mapping/NestedAppAuthAdapter.mjs.map +1 -1
- package/dist/navigation/INavigationClient.d.ts +16 -16
- package/dist/navigation/NavigationClient.d.ts +22 -22
- package/dist/navigation/NavigationClient.mjs +40 -40
- package/dist/navigation/NavigationOptions.d.ts +12 -12
- package/dist/network/FetchClient.d.ts +26 -26
- package/dist/network/FetchClient.mjs +99 -99
- package/dist/operatingcontext/BaseOperatingContext.d.ts +40 -40
- package/dist/operatingcontext/BaseOperatingContext.mjs +44 -44
- package/dist/operatingcontext/StandardOperatingContext.d.ts +25 -25
- package/dist/operatingcontext/StandardOperatingContext.mjs +43 -43
- package/dist/operatingcontext/TeamsAppOperatingContext.d.ts +32 -32
- package/dist/operatingcontext/TeamsAppOperatingContext.d.ts.map +1 -1
- package/dist/operatingcontext/TeamsAppOperatingContext.mjs +85 -82
- package/dist/operatingcontext/TeamsAppOperatingContext.mjs.map +1 -1
- package/dist/operatingcontext/UnknownOperatingContext.d.ts +25 -25
- package/dist/operatingcontext/UnknownOperatingContext.mjs +42 -42
- package/dist/packageMetadata.d.ts +2 -2
- package/dist/packageMetadata.mjs +4 -4
- package/dist/request/AuthorizationCodeRequest.d.ts +8 -8
- package/dist/request/AuthorizationUrlRequest.d.ts +8 -8
- package/dist/request/ClearCacheRequest.d.ts +10 -10
- package/dist/request/EndSessionPopupRequest.d.ts +18 -18
- package/dist/request/EndSessionRequest.d.ts +15 -15
- package/dist/request/PopupRequest.d.ts +34 -34
- package/dist/request/PopupWindowAttributes.d.ts +15 -15
- package/dist/request/RedirectRequest.d.ts +35 -35
- package/dist/request/SilentRequest.d.ts +32 -32
- package/dist/request/SsoSilentRequest.d.ts +29 -29
- package/dist/response/AuthenticationResult.d.ts +4 -4
- package/dist/response/ResponseHandler.d.ts +8 -0
- package/dist/response/ResponseHandler.d.ts.map +1 -0
- package/dist/response/ResponseHandler.mjs +46 -0
- package/dist/response/ResponseHandler.mjs.map +1 -0
- package/dist/telemetry/BrowserPerformanceClient.d.ts +36 -36
- package/dist/telemetry/BrowserPerformanceClient.mjs +125 -125
- package/dist/telemetry/BrowserPerformanceMeasurement.d.ts +21 -21
- package/dist/telemetry/BrowserPerformanceMeasurement.mjs +92 -92
- package/dist/utils/BrowserConstants.d.ts +176 -176
- package/dist/utils/BrowserConstants.mjs +204 -204
- package/dist/utils/BrowserProtocolUtils.d.ts +11 -18
- package/dist/utils/BrowserProtocolUtils.d.ts.map +1 -1
- package/dist/utils/BrowserProtocolUtils.mjs +23 -36
- package/dist/utils/BrowserProtocolUtils.mjs.map +1 -1
- package/dist/utils/BrowserUtils.d.ts +56 -56
- package/dist/utils/BrowserUtils.mjs +125 -125
- package/lib/msal-browser.cjs +17926 -18062
- package/lib/msal-browser.cjs.map +1 -1
- package/lib/msal-browser.js +17926 -18062
- package/lib/msal-browser.js.map +1 -1
- package/lib/msal-browser.min.js +66 -65
- package/package.json +102 -102
- package/src/cache/BrowserCacheManager.ts +7 -10
- package/src/controllers/NestedAppAuthController.ts +8 -3
- package/src/controllers/StandardController.ts +31 -40
- package/src/crypto/CryptoOps.ts +5 -3
- package/src/index.ts +1 -0
- package/src/interaction_client/BaseInteractionClient.ts +1 -2
- package/src/interaction_client/PopupClient.ts +34 -137
- package/src/interaction_client/RedirectClient.ts +71 -55
- package/src/interaction_client/SilentIframeClient.ts +16 -27
- package/src/interaction_client/StandardInteractionClient.ts +2 -48
- package/src/interaction_handler/InteractionHandler.ts +5 -8
- package/src/interaction_handler/RedirectHandler.ts +4 -8
- package/src/interaction_handler/SilentHandler.ts +12 -5
- package/src/naa/AccountInfo.ts +3 -4
- package/src/naa/BridgeError.ts +4 -4
- package/src/naa/BridgeProxy.ts +6 -2
- package/src/naa/IBridgeProxy.ts +2 -0
- package/src/naa/InitializeBridgeResponse.ts +1 -1
- package/src/naa/TokenRequest.ts +0 -2
- package/src/naa/TokenResponse.ts +1 -2
- package/src/naa/mapping/NestedAppAuthAdapter.ts +72 -80
- package/src/operatingcontext/TeamsAppOperatingContext.ts +4 -1
- package/src/packageMetadata.ts +1 -1
- package/src/response/ResponseHandler.ts +73 -0
- package/src/utils/BrowserProtocolUtils.ts +17 -36
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
CcsCredential,
|
|
15
15
|
invokeAsync,
|
|
16
16
|
PerformanceEvents,
|
|
17
|
+
ServerAuthorizationCodeResponse,
|
|
17
18
|
} from "@azure/msal-common";
|
|
18
19
|
import {
|
|
19
20
|
createBrowserAuthError,
|
|
@@ -141,17 +142,12 @@ export class RedirectHandler {
|
|
|
141
142
|
* Handle authorization code response in the window.
|
|
142
143
|
* @param hash
|
|
143
144
|
*/
|
|
144
|
-
async
|
|
145
|
-
|
|
145
|
+
async handleCodeResponse(
|
|
146
|
+
response: ServerAuthorizationCodeResponse,
|
|
146
147
|
state: string
|
|
147
148
|
): Promise<AuthenticationResult> {
|
|
148
149
|
this.logger.verbose("RedirectHandler.handleCodeResponse called");
|
|
149
150
|
|
|
150
|
-
// Check that location hash isn't empty.
|
|
151
|
-
if (!locationHash) {
|
|
152
|
-
throw createBrowserAuthError(BrowserAuthErrorCodes.hashEmptyError);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
151
|
// Interaction is completed - remove interaction status.
|
|
156
152
|
this.browserStorage.setInteractionInProgress(false);
|
|
157
153
|
|
|
@@ -168,7 +164,7 @@ export class RedirectHandler {
|
|
|
168
164
|
let authCodeResponse;
|
|
169
165
|
try {
|
|
170
166
|
authCodeResponse = this.authModule.handleFragmentResponse(
|
|
171
|
-
|
|
167
|
+
response,
|
|
172
168
|
requestState
|
|
173
169
|
);
|
|
174
170
|
} catch (e) {
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
PerformanceEvents,
|
|
10
10
|
invokeAsync,
|
|
11
11
|
invoke,
|
|
12
|
+
ServerResponseType,
|
|
12
13
|
} from "@azure/msal-common";
|
|
13
14
|
import {
|
|
14
15
|
createBrowserAuthError,
|
|
@@ -67,7 +68,8 @@ export async function monitorIframeForHash(
|
|
|
67
68
|
pollIntervalMilliseconds: number,
|
|
68
69
|
performanceClient: IPerformanceClient,
|
|
69
70
|
logger: Logger,
|
|
70
|
-
correlationId: string
|
|
71
|
+
correlationId: string,
|
|
72
|
+
responseType: ServerResponseType
|
|
71
73
|
): Promise<string> {
|
|
72
74
|
performanceClient.addQueueMeasurement(
|
|
73
75
|
PerformanceEvents.SilentHandlerMonitorIframeForHash,
|
|
@@ -110,12 +112,17 @@ export async function monitorIframeForHash(
|
|
|
110
112
|
return;
|
|
111
113
|
}
|
|
112
114
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
115
|
+
let responseString = "";
|
|
116
|
+
if (contentWindow) {
|
|
117
|
+
if (responseType === ServerResponseType.QUERY) {
|
|
118
|
+
responseString = contentWindow.location.search;
|
|
119
|
+
} else {
|
|
120
|
+
responseString = contentWindow.location.hash;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
116
123
|
window.clearTimeout(timeoutId);
|
|
117
124
|
window.clearInterval(intervalId);
|
|
118
|
-
resolve(
|
|
125
|
+
resolve(responseString);
|
|
119
126
|
}, pollIntervalMilliseconds);
|
|
120
127
|
}).finally(() => {
|
|
121
128
|
invoke(
|
package/src/naa/AccountInfo.ts
CHANGED
|
@@ -4,14 +4,13 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
export type AccountInfo = {
|
|
7
|
-
homeAccountId
|
|
7
|
+
homeAccountId?: string;
|
|
8
8
|
environment: string;
|
|
9
|
-
tenantId
|
|
9
|
+
tenantId?: string;
|
|
10
10
|
username: string;
|
|
11
|
-
localAccountId
|
|
11
|
+
localAccountId?: string;
|
|
12
12
|
name?: string;
|
|
13
13
|
idToken?: string; // idTokenClaims can be parsed from idToken in MSAL.js
|
|
14
14
|
platformBrokerId?: string; // Used by WAM previous called nativeAccountId
|
|
15
15
|
idTokenClaims?: object;
|
|
16
|
-
client_info?: string;
|
|
17
16
|
};
|
package/src/naa/BridgeError.ts
CHANGED
|
@@ -7,10 +7,10 @@ import { BridgeStatusCode } from "./BridgeStatusCode";
|
|
|
7
7
|
|
|
8
8
|
export type BridgeError = {
|
|
9
9
|
status: BridgeStatusCode;
|
|
10
|
-
code
|
|
11
|
-
subError
|
|
12
|
-
description
|
|
13
|
-
properties
|
|
10
|
+
code?: string; // auth_flow_last_error such as invalid_grant
|
|
11
|
+
subError?: string; // server_suberror_code such as consent_required
|
|
12
|
+
description?: string;
|
|
13
|
+
properties?: object; // additional telemetry info
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
export function isBridgeError(error: unknown): error is BridgeError {
|
package/src/naa/BridgeProxy.ts
CHANGED
|
@@ -36,7 +36,7 @@ export class BridgeProxy implements IBridgeProxy {
|
|
|
36
36
|
static crypto: Crypto;
|
|
37
37
|
sdkName: string;
|
|
38
38
|
sdkVersion: string;
|
|
39
|
-
capabilities
|
|
39
|
+
capabilities?: BridgeCapabilities;
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
42
|
* initializeNestedAppAuthBridge - Initializes the bridge to the host app
|
|
@@ -162,6 +162,10 @@ export class BridgeProxy implements IBridgeProxy {
|
|
|
162
162
|
return this.sendRequest<AccountInfo>("GetActiveAccount", undefined);
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
+
public getHostCapabilities(): BridgeCapabilities | null {
|
|
166
|
+
return this.capabilities ?? null;
|
|
167
|
+
}
|
|
168
|
+
|
|
165
169
|
/**
|
|
166
170
|
* A method used to send a request to the bridge
|
|
167
171
|
* @param request A token request
|
|
@@ -206,7 +210,7 @@ export class BridgeProxy implements IBridgeProxy {
|
|
|
206
210
|
private constructor(
|
|
207
211
|
sdkName: string,
|
|
208
212
|
sdkVersion: string,
|
|
209
|
-
capabilities
|
|
213
|
+
capabilities?: BridgeCapabilities
|
|
210
214
|
) {
|
|
211
215
|
this.sdkName = sdkName;
|
|
212
216
|
this.sdkVersion = sdkVersion;
|
package/src/naa/IBridgeProxy.ts
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
AccountByLocalIdRequest,
|
|
10
10
|
AccountByUsernameRequest,
|
|
11
11
|
} from "./AccountRequests";
|
|
12
|
+
import { BridgeCapabilities } from "./BridgeCapabilities";
|
|
12
13
|
import { TokenRequest } from "./TokenRequest";
|
|
13
14
|
import { TokenResponse } from "./TokenResponse";
|
|
14
15
|
|
|
@@ -22,4 +23,5 @@ export interface IBridgeProxy {
|
|
|
22
23
|
| AccountByUsernameRequest
|
|
23
24
|
): Promise<AccountInfo>;
|
|
24
25
|
getActiveAccount(): Promise<AccountInfo>;
|
|
26
|
+
getHostCapabilities(): BridgeCapabilities | null;
|
|
25
27
|
}
|
package/src/naa/TokenRequest.ts
CHANGED
|
@@ -9,7 +9,6 @@ export type TokenRequest = {
|
|
|
9
9
|
authority?: string;
|
|
10
10
|
scope: string;
|
|
11
11
|
correlationId: string;
|
|
12
|
-
prompt?: string; // Prompt used to identify interactive request
|
|
13
12
|
nonce?: string;
|
|
14
13
|
claims?: string;
|
|
15
14
|
state?: string;
|
|
@@ -18,7 +17,6 @@ export type TokenRequest = {
|
|
|
18
17
|
authenticationScheme?: string;
|
|
19
18
|
shrClaims?: string;
|
|
20
19
|
shrNonce?: string;
|
|
21
|
-
clientCapabilities?: string[]; // CP1 for CAE support
|
|
22
20
|
resourceRequestMethod?: string;
|
|
23
21
|
resourceRequestUri?: string;
|
|
24
22
|
extendedExpiryToken?: boolean;
|
package/src/naa/TokenResponse.ts
CHANGED
|
@@ -8,14 +8,13 @@ import { AccountInfo } from "./AccountInfo";
|
|
|
8
8
|
export type TokenResponse = {
|
|
9
9
|
access_token: string;
|
|
10
10
|
account: AccountInfo;
|
|
11
|
-
client_info: string;
|
|
12
11
|
expires_in: number;
|
|
13
12
|
id_token: string;
|
|
14
13
|
properties: TokenResponseProperties | null;
|
|
15
14
|
scope: string;
|
|
16
|
-
state: string;
|
|
17
15
|
shr?: string; // token binding enabled at native layer it is the access token, not the signing keys
|
|
18
16
|
extendedLifetimeToken?: boolean;
|
|
17
|
+
authority?: string;
|
|
19
18
|
};
|
|
20
19
|
|
|
21
20
|
export type TokenResponseProperties = {
|
|
@@ -15,16 +15,18 @@ import {
|
|
|
15
15
|
ClientConfigurationError,
|
|
16
16
|
InteractionRequiredAuthError,
|
|
17
17
|
ServerError,
|
|
18
|
-
TimeUtils,
|
|
19
18
|
ICrypto,
|
|
20
19
|
Logger,
|
|
21
20
|
AuthToken,
|
|
22
21
|
TokenClaims,
|
|
23
22
|
ClientAuthErrorCodes,
|
|
23
|
+
AuthenticationScheme,
|
|
24
|
+
RequestParameterBuilder,
|
|
25
|
+
StringUtils,
|
|
26
|
+
createClientAuthError,
|
|
24
27
|
} from "@azure/msal-common";
|
|
25
28
|
import { isBridgeError } from "../BridgeError";
|
|
26
29
|
import { BridgeStatusCode } from "../BridgeStatusCode";
|
|
27
|
-
import { SilentRequest } from "../../request/SilentRequest";
|
|
28
30
|
import { AuthenticationResult } from "../../response/AuthenticationResult";
|
|
29
31
|
import {} from "../../error/BrowserAuthErrorCodes";
|
|
30
32
|
|
|
@@ -46,41 +48,6 @@ export class NestedAppAuthAdapter {
|
|
|
46
48
|
this.logger = logger;
|
|
47
49
|
}
|
|
48
50
|
|
|
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
51
|
public toNaaTokenRequest(
|
|
85
52
|
request: PopupRequest | RedirectRequest
|
|
86
53
|
): TokenRequest {
|
|
@@ -93,6 +60,11 @@ export class NestedAppAuthAdapter {
|
|
|
93
60
|
);
|
|
94
61
|
}
|
|
95
62
|
|
|
63
|
+
const requestBuilder = new RequestParameterBuilder();
|
|
64
|
+
const claims = requestBuilder.addClientCapabilitiesToClaims(
|
|
65
|
+
request.claims,
|
|
66
|
+
this.clientCapabilities
|
|
67
|
+
);
|
|
96
68
|
const tokenRequest: TokenRequest = {
|
|
97
69
|
userObjectId: request.account?.homeAccountId,
|
|
98
70
|
clientId: this.clientId,
|
|
@@ -101,16 +73,12 @@ export class NestedAppAuthAdapter {
|
|
|
101
73
|
correlationId:
|
|
102
74
|
request.correlationId !== undefined
|
|
103
75
|
? request.correlationId
|
|
104
|
-
:
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
state: request.state !== undefined ? request.state : "",
|
|
76
|
+
: this.crypto.createNewGuid(),
|
|
77
|
+
nonce: request.nonce,
|
|
78
|
+
claims: !StringUtils.isEmptyObj(claims) ? claims : undefined,
|
|
79
|
+
state: request.state,
|
|
109
80
|
authenticationScheme:
|
|
110
|
-
request.authenticationScheme
|
|
111
|
-
? request.authenticationScheme
|
|
112
|
-
: "",
|
|
113
|
-
clientCapabilities: undefined,
|
|
81
|
+
request.authenticationScheme || AuthenticationScheme.BEARER,
|
|
114
82
|
extraParameters: extraParams,
|
|
115
83
|
};
|
|
116
84
|
|
|
@@ -119,36 +87,41 @@ export class NestedAppAuthAdapter {
|
|
|
119
87
|
|
|
120
88
|
public fromNaaTokenResponse(
|
|
121
89
|
request: TokenRequest,
|
|
122
|
-
response: TokenResponse
|
|
90
|
+
response: TokenResponse,
|
|
91
|
+
reqTimestamp: number
|
|
123
92
|
): AuthenticationResult {
|
|
93
|
+
if (!response.id_token || !response.access_token) {
|
|
94
|
+
throw createClientAuthError(ClientAuthErrorCodes.nullOrEmptyToken);
|
|
95
|
+
}
|
|
96
|
+
|
|
124
97
|
const expiresOn = new Date(
|
|
125
|
-
|
|
98
|
+
(reqTimestamp + (response.expires_in || 0)) * 1000
|
|
99
|
+
);
|
|
100
|
+
const idTokenClaims = AuthToken.extractTokenClaims(
|
|
101
|
+
response.id_token,
|
|
102
|
+
this.crypto.base64Decode
|
|
103
|
+
);
|
|
104
|
+
const account = this.fromNaaAccountInfo(
|
|
105
|
+
response.account,
|
|
106
|
+
idTokenClaims
|
|
126
107
|
);
|
|
127
|
-
|
|
128
|
-
const account = this.fromNaaAccountInfo(response.account);
|
|
129
108
|
|
|
130
109
|
const authenticationResult: AuthenticationResult = {
|
|
131
|
-
authority: response.account.environment,
|
|
132
|
-
uniqueId:
|
|
133
|
-
tenantId:
|
|
110
|
+
authority: response.authority || account.environment,
|
|
111
|
+
uniqueId: account.localAccountId,
|
|
112
|
+
tenantId: account.tenantId,
|
|
134
113
|
scopes: response.scope.split(" "),
|
|
135
|
-
account
|
|
114
|
+
account,
|
|
136
115
|
idToken: response.id_token !== undefined ? response.id_token : "",
|
|
137
|
-
idTokenClaims
|
|
138
|
-
account.idTokenClaims !== undefined
|
|
139
|
-
? account.idTokenClaims
|
|
140
|
-
: {},
|
|
116
|
+
idTokenClaims,
|
|
141
117
|
accessToken: response.access_token,
|
|
142
118
|
fromCache: true,
|
|
143
119
|
expiresOn: expiresOn,
|
|
144
120
|
tokenType:
|
|
145
|
-
request.authenticationScheme
|
|
146
|
-
? request.authenticationScheme
|
|
147
|
-
: "Bearer",
|
|
121
|
+
request.authenticationScheme || AuthenticationScheme.BEARER,
|
|
148
122
|
correlationId: request.correlationId,
|
|
149
|
-
requestId: "",
|
|
150
123
|
extExpiresOn: expiresOn,
|
|
151
|
-
state:
|
|
124
|
+
state: request.state,
|
|
152
125
|
};
|
|
153
126
|
|
|
154
127
|
return authenticationResult;
|
|
@@ -176,26 +149,41 @@ export class NestedAppAuthAdapter {
|
|
|
176
149
|
* authorityType?: string;
|
|
177
150
|
* };
|
|
178
151
|
*/
|
|
179
|
-
public fromNaaAccountInfo(
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
152
|
+
public fromNaaAccountInfo(
|
|
153
|
+
fromAccount: NaaAccountInfo,
|
|
154
|
+
idTokenClaims?: TokenClaims
|
|
155
|
+
): MsalAccountInfo {
|
|
156
|
+
const effectiveIdTokenClaims =
|
|
157
|
+
idTokenClaims || (fromAccount.idTokenClaims as TokenClaims);
|
|
158
|
+
|
|
159
|
+
const localAccountId =
|
|
160
|
+
fromAccount.localAccountId ||
|
|
161
|
+
effectiveIdTokenClaims?.oid ||
|
|
162
|
+
effectiveIdTokenClaims?.sub ||
|
|
163
|
+
"";
|
|
164
|
+
|
|
165
|
+
const tenantId =
|
|
166
|
+
fromAccount.tenantId || effectiveIdTokenClaims?.tid || "";
|
|
167
|
+
|
|
168
|
+
const homeAccountId =
|
|
169
|
+
fromAccount.homeAccountId || `${localAccountId}.${tenantId}`;
|
|
170
|
+
|
|
171
|
+
const username =
|
|
172
|
+
fromAccount.username ||
|
|
173
|
+
effectiveIdTokenClaims?.preferred_username ||
|
|
174
|
+
"";
|
|
175
|
+
|
|
176
|
+
const name = fromAccount.name || effectiveIdTokenClaims?.name;
|
|
189
177
|
|
|
190
178
|
const account: MsalAccountInfo = {
|
|
191
|
-
homeAccountId
|
|
179
|
+
homeAccountId,
|
|
192
180
|
environment: fromAccount.environment,
|
|
193
|
-
tenantId
|
|
194
|
-
username
|
|
195
|
-
localAccountId
|
|
196
|
-
name
|
|
181
|
+
tenantId,
|
|
182
|
+
username,
|
|
183
|
+
localAccountId,
|
|
184
|
+
name,
|
|
197
185
|
idToken: fromAccount.idToken,
|
|
198
|
-
idTokenClaims:
|
|
186
|
+
idTokenClaims: effectiveIdTokenClaims,
|
|
199
187
|
};
|
|
200
188
|
|
|
201
189
|
return account;
|
|
@@ -233,7 +221,11 @@ export class NestedAppAuthAdapter {
|
|
|
233
221
|
ClientAuthErrorCodes.nestedAppAuthBridgeDisabled
|
|
234
222
|
);
|
|
235
223
|
case BridgeStatusCode.NESTED_APP_AUTH_UNAVAILABLE:
|
|
236
|
-
return new ClientAuthError(
|
|
224
|
+
return new ClientAuthError(
|
|
225
|
+
error.code ||
|
|
226
|
+
ClientAuthErrorCodes.nestedAppAuthBridgeDisabled,
|
|
227
|
+
error.description
|
|
228
|
+
);
|
|
237
229
|
case BridgeStatusCode.TRANSIENT_ERROR:
|
|
238
230
|
case BridgeStatusCode.PERSISTENT_ERROR:
|
|
239
231
|
return new ServerError(error.code, error.description);
|
|
@@ -70,7 +70,10 @@ export class TeamsAppOperatingContext extends BaseOperatingContext {
|
|
|
70
70
|
* this.activeAccount = await bridgeProxy.getActiveAccount();
|
|
71
71
|
*/
|
|
72
72
|
try {
|
|
73
|
-
|
|
73
|
+
if (bridgeProxy.getHostCapabilities()?.queryAccount) {
|
|
74
|
+
this.activeAccount =
|
|
75
|
+
await bridgeProxy.getActiveAccount();
|
|
76
|
+
}
|
|
74
77
|
} catch (e) {
|
|
75
78
|
this.activeAccount = undefined;
|
|
76
79
|
}
|
package/src/packageMetadata.ts
CHANGED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
ICrypto,
|
|
8
|
+
Logger,
|
|
9
|
+
ServerAuthorizationCodeResponse,
|
|
10
|
+
UrlUtils,
|
|
11
|
+
} from "@azure/msal-common";
|
|
12
|
+
import {
|
|
13
|
+
BrowserAuthErrorCodes,
|
|
14
|
+
createBrowserAuthError,
|
|
15
|
+
} from "../error/BrowserAuthError";
|
|
16
|
+
import { extractBrowserRequestState } from "../utils/BrowserProtocolUtils";
|
|
17
|
+
import { InteractionType } from "../utils/BrowserConstants";
|
|
18
|
+
|
|
19
|
+
export function deserializeResponse(
|
|
20
|
+
responseString: string,
|
|
21
|
+
responseLocation: string,
|
|
22
|
+
logger: Logger
|
|
23
|
+
): ServerAuthorizationCodeResponse {
|
|
24
|
+
// Deserialize hash fragment response parameters.
|
|
25
|
+
const serverParams = UrlUtils.getDeserializedResponse(responseString);
|
|
26
|
+
if (!serverParams) {
|
|
27
|
+
if (!UrlUtils.stripLeadingHashOrQuery(responseString)) {
|
|
28
|
+
// Hash or Query string is empty
|
|
29
|
+
logger.error(
|
|
30
|
+
`The request has returned to the redirectUri but a ${responseLocation} is not present. It's likely that the ${responseLocation} has been removed or the page has been redirected by code running on the redirectUri page.`
|
|
31
|
+
);
|
|
32
|
+
throw createBrowserAuthError(BrowserAuthErrorCodes.hashEmptyError);
|
|
33
|
+
} else {
|
|
34
|
+
logger.error(
|
|
35
|
+
`A ${responseLocation} is present in the iframe but it does not contain known properties. It's likely that the ${responseLocation} has been replaced by code running on the redirectUri page.`
|
|
36
|
+
);
|
|
37
|
+
logger.errorPii(
|
|
38
|
+
`The ${responseLocation} detected is: ${responseString}`
|
|
39
|
+
);
|
|
40
|
+
throw createBrowserAuthError(
|
|
41
|
+
BrowserAuthErrorCodes.hashDoesNotContainKnownProperties
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return serverParams;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Returns the interaction type that the response object belongs to
|
|
50
|
+
*/
|
|
51
|
+
export function validateInteractionType(
|
|
52
|
+
response: ServerAuthorizationCodeResponse,
|
|
53
|
+
browserCrypto: ICrypto,
|
|
54
|
+
interactionType: InteractionType
|
|
55
|
+
): void {
|
|
56
|
+
if (!response.state) {
|
|
57
|
+
throw createBrowserAuthError(BrowserAuthErrorCodes.noStateInHash);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const platformStateObj = extractBrowserRequestState(
|
|
61
|
+
browserCrypto,
|
|
62
|
+
response.state
|
|
63
|
+
);
|
|
64
|
+
if (!platformStateObj) {
|
|
65
|
+
throw createBrowserAuthError(BrowserAuthErrorCodes.unableToParseState);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (platformStateObj.interactionType !== interactionType) {
|
|
69
|
+
throw createBrowserAuthError(
|
|
70
|
+
BrowserAuthErrorCodes.stateInteractionTypeMismatch
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -8,8 +8,6 @@ import {
|
|
|
8
8
|
ICrypto,
|
|
9
9
|
RequestStateObject,
|
|
10
10
|
ProtocolUtils,
|
|
11
|
-
ServerAuthorizationCodeResponse,
|
|
12
|
-
UrlString,
|
|
13
11
|
createClientAuthError,
|
|
14
12
|
ClientAuthErrorCodes,
|
|
15
13
|
} from "@azure/msal-common";
|
|
@@ -18,41 +16,24 @@ export type BrowserStateObject = {
|
|
|
18
16
|
interactionType: InteractionType;
|
|
19
17
|
};
|
|
20
18
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
)
|
|
31
|
-
|
|
32
|
-
return null;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
try {
|
|
36
|
-
const requestStateObj: RequestStateObject =
|
|
37
|
-
ProtocolUtils.parseRequestState(browserCrypto, state);
|
|
38
|
-
return requestStateObj.libraryState.meta as BrowserStateObject;
|
|
39
|
-
} catch (e) {
|
|
40
|
-
throw createClientAuthError(ClientAuthErrorCodes.invalidState);
|
|
41
|
-
}
|
|
19
|
+
/**
|
|
20
|
+
* Extracts the BrowserStateObject from the state string.
|
|
21
|
+
* @param browserCrypto
|
|
22
|
+
* @param state
|
|
23
|
+
*/
|
|
24
|
+
export function extractBrowserRequestState(
|
|
25
|
+
browserCrypto: ICrypto,
|
|
26
|
+
state: string
|
|
27
|
+
): BrowserStateObject | null {
|
|
28
|
+
if (!state) {
|
|
29
|
+
return null;
|
|
42
30
|
}
|
|
43
31
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
): ServerAuthorizationCodeResponse {
|
|
51
|
-
if (!locationHash) {
|
|
52
|
-
return {};
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const hashUrlString = new UrlString(locationHash);
|
|
56
|
-
return UrlString.getDeserializedHash(hashUrlString.getHash());
|
|
32
|
+
try {
|
|
33
|
+
const requestStateObj: RequestStateObject =
|
|
34
|
+
ProtocolUtils.parseRequestState(browserCrypto, state);
|
|
35
|
+
return requestStateObj.libraryState.meta as BrowserStateObject;
|
|
36
|
+
} catch (e) {
|
|
37
|
+
throw createClientAuthError(ClientAuthErrorCodes.invalidState);
|
|
57
38
|
}
|
|
58
39
|
}
|