@azure/msal-browser 3.2.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.mjs +1 -1
- package/dist/app/PublicClientApplication.mjs +2 -2
- 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.mjs +1 -1
- package/dist/broker/nativeBroker/NativeStatusCodes.mjs +1 -1
- package/dist/cache/AsyncMemoryStorage.mjs +1 -1
- package/dist/cache/BrowserCacheManager.d.ts +2 -13
- package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
- package/dist/cache/BrowserCacheManager.mjs +7 -64
- package/dist/cache/BrowserCacheManager.mjs.map +1 -1
- package/dist/cache/BrowserStorage.mjs +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 +2 -1
- 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/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.map +1 -1
- package/dist/controllers/StandardController.mjs +16 -13
- 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.map +1 -1
- package/dist/crypto/BrowserCrypto.mjs +3 -3
- package/dist/crypto/BrowserCrypto.mjs.map +1 -1
- package/dist/crypto/CryptoOps.d.ts.map +1 -1
- package/dist/crypto/CryptoOps.mjs +8 -5
- package/dist/crypto/CryptoOps.mjs.map +1 -1
- package/dist/crypto/PkceGenerator.mjs +1 -1
- package/dist/crypto/SignedHttpRequest.mjs +1 -1
- package/dist/encode/Base64Decode.mjs +1 -1
- package/dist/encode/Base64Encode.mjs +1 -1
- package/dist/error/BrowserAuthError.mjs +1 -1
- package/dist/error/BrowserAuthErrorCodes.mjs +1 -1
- package/dist/error/BrowserConfigurationAuthError.mjs +1 -1
- package/dist/error/BrowserConfigurationAuthErrorCodes.mjs +1 -1
- package/dist/error/NativeAuthError.mjs +1 -1
- package/dist/error/NativeAuthErrorCodes.mjs +1 -1
- package/dist/error/NestedAppAuthError.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.mjs +1 -1
- package/dist/event/EventMessage.mjs +1 -1
- package/dist/event/EventType.mjs +1 -1
- package/dist/index.d.ts +3 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +4 -2
- package/dist/index.mjs.map +1 -1
- package/dist/interaction_client/BaseInteractionClient.mjs +4 -4
- package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +1 -1
- package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
- package/dist/interaction_client/NativeInteractionClient.mjs +15 -4
- 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 +4 -4
- 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 +4 -3
- 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.mjs +1 -1
- package/dist/interaction_client/StandardInteractionClient.mjs +5 -5
- package/dist/interaction_handler/InteractionHandler.mjs +1 -1
- package/dist/interaction_handler/RedirectHandler.mjs +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 -155
- 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.mjs +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 -17728
- package/lib/msal-browser.cjs.map +1 -1
- package/lib/msal-browser.js +14625 -13223
- package/lib/msal-browser.js.map +1 -1
- package/lib/msal-browser.min.js +66 -68
- package/package.json +2 -2
- package/src/app/PublicClientApplication.ts +1 -1
- package/src/app/PublicClientNext.ts +442 -0
- package/src/cache/BrowserCacheManager.ts +11 -100
- package/src/config/Configuration.ts +5 -0
- package/src/controllers/ControllerFactory.ts +36 -25
- package/src/controllers/NestedAppAuthController.ts +525 -0
- package/src/controllers/StandardController.ts +8 -6
- package/src/controllers/UnknownOperatingContextController.ts +383 -0
- package/src/crypto/BrowserCrypto.ts +2 -2
- package/src/crypto/CryptoOps.ts +8 -5
- package/src/error/NestedAppAuthError.ts +32 -0
- package/src/index.ts +3 -10
- package/src/interaction_client/BaseInteractionClient.ts +1 -1
- package/src/interaction_client/NativeInteractionClient.ts +19 -3
- package/src/interaction_client/PopupClient.ts +2 -1
- package/src/interaction_client/RedirectClient.ts +1 -1
- package/src/interaction_client/SilentAuthCodeClient.ts +5 -4
- package/src/interaction_client/SilentCacheClient.ts +11 -3
- package/src/interaction_client/SilentIframeClient.ts +53 -17
- package/src/interaction_client/StandardInteractionClient.ts +1 -1
- package/src/interaction_handler/SilentHandler.ts +177 -233
- 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/BrowserUtils.ts +133 -125
- 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/utils/BrowserStringUtils.ts +0 -143
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"type": "git",
|
|
11
11
|
"url": "https://github.com/AzureAD/microsoft-authentication-library-for-js.git"
|
|
12
12
|
},
|
|
13
|
-
"version": "3.
|
|
13
|
+
"version": "3.3.0",
|
|
14
14
|
"description": "Microsoft Authentication Library for js",
|
|
15
15
|
"keywords": [
|
|
16
16
|
"implicit",
|
|
@@ -100,6 +100,6 @@
|
|
|
100
100
|
"typescript": "^4.9.5"
|
|
101
101
|
},
|
|
102
102
|
"dependencies": {
|
|
103
|
-
"@azure/msal-common": "14.
|
|
103
|
+
"@azure/msal-common": "14.2.0"
|
|
104
104
|
}
|
|
105
105
|
}
|
|
@@ -39,7 +39,7 @@ export class PublicClientApplication implements IPublicClientApplication {
|
|
|
39
39
|
configuration: Configuration
|
|
40
40
|
): Promise<IPublicClientApplication> {
|
|
41
41
|
const factory = new ControllerFactory(configuration);
|
|
42
|
-
const controller = await factory.
|
|
42
|
+
const controller = await factory.createV3Controller();
|
|
43
43
|
const pca = new PublicClientApplication(configuration, controller);
|
|
44
44
|
|
|
45
45
|
return pca;
|
|
@@ -0,0 +1,442 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { ITokenCache } from "../cache/ITokenCache";
|
|
7
|
+
import { INavigationClient } from "../navigation/INavigationClient";
|
|
8
|
+
import { AuthorizationCodeRequest } from "../request/AuthorizationCodeRequest";
|
|
9
|
+
import { PopupRequest } from "../request/PopupRequest";
|
|
10
|
+
import { RedirectRequest } from "../request/RedirectRequest";
|
|
11
|
+
import { SilentRequest } from "../request/SilentRequest";
|
|
12
|
+
import { WrapperSKU } from "../utils/BrowserConstants";
|
|
13
|
+
import { IPublicClientApplication } from "./IPublicClientApplication";
|
|
14
|
+
import { IController } from "../controllers/IController";
|
|
15
|
+
import {
|
|
16
|
+
PerformanceCallbackFunction,
|
|
17
|
+
AccountInfo,
|
|
18
|
+
AccountFilter,
|
|
19
|
+
Logger,
|
|
20
|
+
} from "@azure/msal-common";
|
|
21
|
+
import { EndSessionRequest } from "../request/EndSessionRequest";
|
|
22
|
+
import { SsoSilentRequest } from "../request/SsoSilentRequest";
|
|
23
|
+
import { ControllerFactory } from "../controllers/ControllerFactory";
|
|
24
|
+
import { BrowserConfiguration, Configuration } from "../config/Configuration";
|
|
25
|
+
import { EventCallbackFunction } from "../event/EventMessage";
|
|
26
|
+
import { ClearCacheRequest } from "../request/ClearCacheRequest";
|
|
27
|
+
import { AuthenticationResult } from "../response/AuthenticationResult";
|
|
28
|
+
import { UnknownOperatingContextController } from "../controllers/UnknownOperatingContextController";
|
|
29
|
+
import { UnknownOperatingContext } from "../operatingcontext/UnknownOperatingContext";
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* PublicClientNext is an early look at the planned implementation of PublicClientApplication in the next major version of MSAL.js.
|
|
33
|
+
* It contains support for multiple API implementations based on the runtime environment that it is running in.
|
|
34
|
+
*
|
|
35
|
+
* The goals of these changes are to provide a clean separation of behavior between different operating contexts (Nested App Auth, Platform Brokers, Plain old Browser, etc.)
|
|
36
|
+
* while still providing a consistent API surface for developers.
|
|
37
|
+
*
|
|
38
|
+
*/
|
|
39
|
+
export class PublicClientNext implements IPublicClientApplication {
|
|
40
|
+
/*
|
|
41
|
+
* Definite assignment assertion used below
|
|
42
|
+
* https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-7.html#definite-assignment-assertions
|
|
43
|
+
*/
|
|
44
|
+
protected controller!: IController;
|
|
45
|
+
protected configuration: Configuration;
|
|
46
|
+
|
|
47
|
+
public static async createPublicClientApplication(
|
|
48
|
+
configuration: Configuration
|
|
49
|
+
): Promise<IPublicClientApplication> {
|
|
50
|
+
const factory = new ControllerFactory(configuration);
|
|
51
|
+
const controller = await factory.createController();
|
|
52
|
+
let pca;
|
|
53
|
+
if (controller !== null) {
|
|
54
|
+
pca = new PublicClientNext(configuration, controller);
|
|
55
|
+
} else {
|
|
56
|
+
pca = new PublicClientNext(configuration);
|
|
57
|
+
}
|
|
58
|
+
return pca;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @constructor
|
|
63
|
+
* Constructor for the PublicClientNext used to instantiate the PublicClientNext object
|
|
64
|
+
*
|
|
65
|
+
* Important attributes in the Configuration object for auth are:
|
|
66
|
+
* - clientID: the application ID of your application. You can obtain one by registering your application with our Application registration portal : https://portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/RegisteredAppsPreview
|
|
67
|
+
* - authority: the authority URL for your application.
|
|
68
|
+
* - redirect_uri: the uri of your application registered in the portal.
|
|
69
|
+
*
|
|
70
|
+
* In Azure AD, authority is a URL indicating the Azure active directory that MSAL uses to obtain tokens.
|
|
71
|
+
* It is of the form https://login.microsoftonline.com/{Enter_the_Tenant_Info_Here}
|
|
72
|
+
* If your application supports Accounts in one organizational directory, replace "Enter_the_Tenant_Info_Here" value with the Tenant Id or Tenant name (for example, contoso.microsoft.com).
|
|
73
|
+
* If your application supports Accounts in any organizational directory, replace "Enter_the_Tenant_Info_Here" value with organizations.
|
|
74
|
+
* If your application supports Accounts in any organizational directory and personal Microsoft accounts, replace "Enter_the_Tenant_Info_Here" value with common.
|
|
75
|
+
* To restrict support to Personal Microsoft accounts only, replace "Enter_the_Tenant_Info_Here" value with consumers.
|
|
76
|
+
*
|
|
77
|
+
* In Azure B2C, authority is of the form https://{instance}/tfp/{tenant}/{policyName}/
|
|
78
|
+
* Full B2C functionality will be available in this library in future versions.
|
|
79
|
+
*
|
|
80
|
+
* @param configuration Object for the MSAL PublicClientApplication instance
|
|
81
|
+
* @param IController Optional parameter to explictly set the controller. (Will be removed when we remove public constructor)
|
|
82
|
+
*/
|
|
83
|
+
private constructor(
|
|
84
|
+
configuration: Configuration,
|
|
85
|
+
controller?: IController
|
|
86
|
+
) {
|
|
87
|
+
this.configuration = configuration;
|
|
88
|
+
if (controller) {
|
|
89
|
+
this.controller = controller;
|
|
90
|
+
} else {
|
|
91
|
+
const operatingContext = new UnknownOperatingContext(configuration);
|
|
92
|
+
this.controller = new UnknownOperatingContextController(
|
|
93
|
+
operatingContext
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Initializer function to perform async startup tasks such as connecting to WAM extension
|
|
100
|
+
*/
|
|
101
|
+
async initialize(): Promise<void> {
|
|
102
|
+
if (this.controller instanceof UnknownOperatingContextController) {
|
|
103
|
+
const factory = new ControllerFactory(this.configuration);
|
|
104
|
+
const result = await factory.createController();
|
|
105
|
+
if (result !== null) {
|
|
106
|
+
this.controller = result;
|
|
107
|
+
}
|
|
108
|
+
return this.controller.initialize();
|
|
109
|
+
}
|
|
110
|
+
return Promise.resolve();
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Use when you want to obtain an access_token for your API via opening a popup window in the user's browser
|
|
115
|
+
*
|
|
116
|
+
* @param request
|
|
117
|
+
*
|
|
118
|
+
* @returns A promise that is fulfilled when this function has completed, or rejected if an error was raised.
|
|
119
|
+
*/
|
|
120
|
+
async acquireTokenPopup(
|
|
121
|
+
request: PopupRequest
|
|
122
|
+
): Promise<AuthenticationResult> {
|
|
123
|
+
return this.controller.acquireTokenPopup(request);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Use when you want to obtain an access_token for your API by redirecting the user's browser window to the authorization endpoint. This function redirects
|
|
128
|
+
* the page, so any code that follows this function will not execute.
|
|
129
|
+
*
|
|
130
|
+
* IMPORTANT: It is NOT recommended to have code that is dependent on the resolution of the Promise. This function will navigate away from the current
|
|
131
|
+
* browser window. It currently returns a Promise in order to reflect the asynchronous nature of the code running in this function.
|
|
132
|
+
*
|
|
133
|
+
* @param request
|
|
134
|
+
*/
|
|
135
|
+
acquireTokenRedirect(request: RedirectRequest): Promise<void> {
|
|
136
|
+
return this.controller.acquireTokenRedirect(request);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Silently acquire an access token for a given set of scopes. Returns currently processing promise if parallel requests are made.
|
|
141
|
+
*
|
|
142
|
+
* @param {@link (SilentRequest:type)}
|
|
143
|
+
* @returns {Promise.<AuthenticationResult>} - a promise that is fulfilled when this function has completed, or rejected if an error was raised. Returns the {@link AuthenticationResult} object
|
|
144
|
+
*/
|
|
145
|
+
acquireTokenSilent(
|
|
146
|
+
silentRequest: SilentRequest
|
|
147
|
+
): Promise<AuthenticationResult> {
|
|
148
|
+
return this.controller.acquireTokenSilent(silentRequest);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* This function redeems an authorization code (passed as code) from the eSTS token endpoint.
|
|
153
|
+
* This authorization code should be acquired server-side using a confidential client to acquire a spa_code.
|
|
154
|
+
* This API is not indended for normal authorization code acquisition and redemption.
|
|
155
|
+
*
|
|
156
|
+
* Redemption of this authorization code will not require PKCE, as it was acquired by a confidential client.
|
|
157
|
+
*
|
|
158
|
+
* @param request {@link AuthorizationCodeRequest}
|
|
159
|
+
* @returns A promise that is fulfilled when this function has completed, or rejected if an error was raised.
|
|
160
|
+
*/
|
|
161
|
+
acquireTokenByCode(
|
|
162
|
+
request: AuthorizationCodeRequest
|
|
163
|
+
): Promise<AuthenticationResult> {
|
|
164
|
+
return this.controller.acquireTokenByCode(request);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Adds event callbacks to array
|
|
169
|
+
* @param callback
|
|
170
|
+
*/
|
|
171
|
+
addEventCallback(callback: EventCallbackFunction): string | null {
|
|
172
|
+
return this.controller.addEventCallback(callback);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Removes callback with provided id from callback array
|
|
177
|
+
* @param callbackId
|
|
178
|
+
*/
|
|
179
|
+
removeEventCallback(callbackId: string): void {
|
|
180
|
+
return this.controller.removeEventCallback(callbackId);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Registers a callback to receive performance events.
|
|
185
|
+
*
|
|
186
|
+
* @param {PerformanceCallbackFunction} callback
|
|
187
|
+
* @returns {string}
|
|
188
|
+
*/
|
|
189
|
+
addPerformanceCallback(callback: PerformanceCallbackFunction): string {
|
|
190
|
+
return this.controller.addPerformanceCallback(callback);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Removes a callback registered with addPerformanceCallback.
|
|
195
|
+
*
|
|
196
|
+
* @param {string} callbackId
|
|
197
|
+
* @returns {boolean}
|
|
198
|
+
*/
|
|
199
|
+
removePerformanceCallback(callbackId: string): boolean {
|
|
200
|
+
return this.controller.removePerformanceCallback(callbackId);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Adds event listener that emits an event when a user account is added or removed from localstorage in a different browser tab or window
|
|
205
|
+
*/
|
|
206
|
+
enableAccountStorageEvents(): void {
|
|
207
|
+
this.controller.enableAccountStorageEvents();
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Removes event listener that emits an event when a user account is added or removed from localstorage in a different browser tab or window
|
|
212
|
+
*/
|
|
213
|
+
disableAccountStorageEvents(): void {
|
|
214
|
+
this.controller.disableAccountStorageEvents();
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Returns the first account found in the cache that matches the account filter passed in.
|
|
219
|
+
* @param accountFilter
|
|
220
|
+
* @returns The first account found in the cache matching the provided filter or null if no account could be found.
|
|
221
|
+
*/
|
|
222
|
+
getAccount(accountFilter: AccountFilter): AccountInfo | null {
|
|
223
|
+
return this.controller.getAccount(accountFilter);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Returns the signed in account matching homeAccountId.
|
|
228
|
+
* (the account object is created at the time of successful login)
|
|
229
|
+
* or null when no matching account is found
|
|
230
|
+
* @param homeAccountId
|
|
231
|
+
* @returns The account object stored in MSAL
|
|
232
|
+
* @deprecated - Use getAccount instead
|
|
233
|
+
*/
|
|
234
|
+
getAccountByHomeId(homeAccountId: string): AccountInfo | null {
|
|
235
|
+
return this.controller.getAccountByHomeId(homeAccountId);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Returns the signed in account matching localAccountId.
|
|
240
|
+
* (the account object is created at the time of successful login)
|
|
241
|
+
* or null when no matching account is found
|
|
242
|
+
* @param localAccountId
|
|
243
|
+
* @returns The account object stored in MSAL
|
|
244
|
+
* @deprecated - Use getAccount instead
|
|
245
|
+
*/
|
|
246
|
+
getAccountByLocalId(localId: string): AccountInfo | null {
|
|
247
|
+
return this.controller.getAccountByLocalId(localId);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Returns the signed in account matching username.
|
|
252
|
+
* (the account object is created at the time of successful login)
|
|
253
|
+
* or null when no matching account is found.
|
|
254
|
+
* This API is provided for convenience but getAccountById should be used for best reliability
|
|
255
|
+
* @param userName
|
|
256
|
+
* @returns The account object stored in MSAL
|
|
257
|
+
* @deprecated - Use getAccount instead
|
|
258
|
+
*/
|
|
259
|
+
getAccountByUsername(userName: string): AccountInfo | null {
|
|
260
|
+
return this.controller.getAccountByUsername(userName);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Returns all the accounts in the cache that match the optional filter. If no filter is provided, all accounts are returned.
|
|
265
|
+
* @param accountFilter - (Optional) filter to narrow down the accounts returned
|
|
266
|
+
* @returns Array of AccountInfo objects in cache
|
|
267
|
+
*/
|
|
268
|
+
getAllAccounts(accountFilter?: AccountFilter): AccountInfo[] {
|
|
269
|
+
return this.controller.getAllAccounts(accountFilter);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Event handler function which allows users to fire events after the PublicClientApplication object
|
|
274
|
+
* has loaded during redirect flows. This should be invoked on all page loads involved in redirect
|
|
275
|
+
* auth flows.
|
|
276
|
+
* @param hash Hash to process. Defaults to the current value of window.location.hash. Only needs to be provided explicitly if the response to be handled is not contained in the current value.
|
|
277
|
+
* @returns Token response or null. If the return value is null, then no auth redirect was detected.
|
|
278
|
+
*/
|
|
279
|
+
handleRedirectPromise(
|
|
280
|
+
hash?: string | undefined
|
|
281
|
+
): Promise<AuthenticationResult | null> {
|
|
282
|
+
return this.controller.handleRedirectPromise(hash);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Use when initiating the login process via opening a popup window in the user's browser
|
|
287
|
+
*
|
|
288
|
+
* @param request
|
|
289
|
+
*
|
|
290
|
+
* @returns A promise that is fulfilled when this function has completed, or rejected if an error was raised.
|
|
291
|
+
*/
|
|
292
|
+
loginPopup(
|
|
293
|
+
request?: PopupRequest | undefined
|
|
294
|
+
): Promise<AuthenticationResult> {
|
|
295
|
+
return this.controller.loginPopup(request);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Use when initiating the login process by redirecting the user's browser to the authorization endpoint. This function redirects the page, so
|
|
300
|
+
* any code that follows this function will not execute.
|
|
301
|
+
*
|
|
302
|
+
* IMPORTANT: It is NOT recommended to have code that is dependent on the resolution of the Promise. This function will navigate away from the current
|
|
303
|
+
* browser window. It currently returns a Promise in order to reflect the asynchronous nature of the code running in this function.
|
|
304
|
+
*
|
|
305
|
+
* @param request
|
|
306
|
+
*/
|
|
307
|
+
loginRedirect(request?: RedirectRequest | undefined): Promise<void> {
|
|
308
|
+
return this.controller.loginRedirect(request);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Deprecated logout function. Use logoutRedirect or logoutPopup instead
|
|
313
|
+
* @param logoutRequest
|
|
314
|
+
* @deprecated
|
|
315
|
+
*/
|
|
316
|
+
logout(logoutRequest?: EndSessionRequest): Promise<void> {
|
|
317
|
+
return this.controller.logout(logoutRequest);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Use to log out the current user, and redirect the user to the postLogoutRedirectUri.
|
|
322
|
+
* Default behaviour is to redirect the user to `window.location.href`.
|
|
323
|
+
* @param logoutRequest
|
|
324
|
+
*/
|
|
325
|
+
logoutRedirect(logoutRequest?: EndSessionRequest): Promise<void> {
|
|
326
|
+
return this.controller.logoutRedirect(logoutRequest);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Clears local cache for the current user then opens a popup window prompting the user to sign-out of the server
|
|
331
|
+
* @param logoutRequest
|
|
332
|
+
*/
|
|
333
|
+
logoutPopup(logoutRequest?: EndSessionRequest): Promise<void> {
|
|
334
|
+
return this.controller.logoutPopup(logoutRequest);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* This function uses a hidden iframe to fetch an authorization code from the eSTS. There are cases where this may not work:
|
|
339
|
+
* - Any browser using a form of Intelligent Tracking Prevention
|
|
340
|
+
* - If there is not an established session with the service
|
|
341
|
+
*
|
|
342
|
+
* In these cases, the request must be done inside a popup or full frame redirect.
|
|
343
|
+
*
|
|
344
|
+
* For the cases where interaction is required, you cannot send a request with prompt=none.
|
|
345
|
+
*
|
|
346
|
+
* If your refresh token has expired, you can use this function to fetch a new set of tokens silently as long as
|
|
347
|
+
* you session on the server still exists.
|
|
348
|
+
* @param request {@link SsoSilentRequest}
|
|
349
|
+
*
|
|
350
|
+
* @returns A promise that is fulfilled when this function has completed, or rejected if an error was raised.
|
|
351
|
+
*/
|
|
352
|
+
ssoSilent(request: SsoSilentRequest): Promise<AuthenticationResult> {
|
|
353
|
+
return this.controller.ssoSilent(request);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* Gets the token cache for the application.
|
|
358
|
+
*/
|
|
359
|
+
getTokenCache(): ITokenCache {
|
|
360
|
+
return this.controller.getTokenCache();
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* Returns the logger instance
|
|
365
|
+
*/
|
|
366
|
+
getLogger(): Logger {
|
|
367
|
+
return this.controller.getLogger();
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* Replaces the default logger set in configurations with new Logger with new configurations
|
|
372
|
+
* @param logger Logger instance
|
|
373
|
+
*/
|
|
374
|
+
setLogger(logger: Logger): void {
|
|
375
|
+
this.controller.setLogger(logger);
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* Sets the account to use as the active account. If no account is passed to the acquireToken APIs, then MSAL will use this active account.
|
|
380
|
+
* @param account
|
|
381
|
+
*/
|
|
382
|
+
setActiveAccount(account: AccountInfo | null): void {
|
|
383
|
+
this.controller.setActiveAccount(account);
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* Gets the currently active account
|
|
388
|
+
*/
|
|
389
|
+
getActiveAccount(): AccountInfo | null {
|
|
390
|
+
return this.controller.getActiveAccount();
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* Called by wrapper libraries (Angular & React) to set SKU and Version passed down to telemetry, logger, etc.
|
|
395
|
+
* @param sku
|
|
396
|
+
* @param version
|
|
397
|
+
*/
|
|
398
|
+
initializeWrapperLibrary(sku: WrapperSKU, version: string): void {
|
|
399
|
+
return this.controller.initializeWrapperLibrary(sku, version);
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* Sets navigation client
|
|
404
|
+
* @param navigationClient
|
|
405
|
+
*/
|
|
406
|
+
setNavigationClient(navigationClient: INavigationClient): void {
|
|
407
|
+
this.controller.setNavigationClient(navigationClient);
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* Returns the configuration object
|
|
412
|
+
* @internal
|
|
413
|
+
*/
|
|
414
|
+
getConfiguration(): BrowserConfiguration {
|
|
415
|
+
return this.controller.getConfiguration();
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* Hydrates cache with the tokens and account in the AuthenticationResult object
|
|
420
|
+
* @param result
|
|
421
|
+
* @param request - The request object that was used to obtain the AuthenticationResult
|
|
422
|
+
* @returns
|
|
423
|
+
*/
|
|
424
|
+
async hydrateCache(
|
|
425
|
+
result: AuthenticationResult,
|
|
426
|
+
request:
|
|
427
|
+
| SilentRequest
|
|
428
|
+
| SsoSilentRequest
|
|
429
|
+
| RedirectRequest
|
|
430
|
+
| PopupRequest
|
|
431
|
+
): Promise<void> {
|
|
432
|
+
return this.controller.hydrateCache(result, request);
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
/**
|
|
436
|
+
* Clears tokens and account from the browser cache.
|
|
437
|
+
* @param logoutRequest
|
|
438
|
+
*/
|
|
439
|
+
clearCache(logoutRequest?: ClearCacheRequest): Promise<void> {
|
|
440
|
+
return this.controller.clearCache(logoutRequest);
|
|
441
|
+
}
|
|
442
|
+
}
|
|
@@ -35,6 +35,7 @@ import {
|
|
|
35
35
|
ClientAuthErrorCodes,
|
|
36
36
|
PerformanceEvents,
|
|
37
37
|
IPerformanceClient,
|
|
38
|
+
StaticAuthorityOptions,
|
|
38
39
|
} from "@azure/msal-common";
|
|
39
40
|
import { CacheOptions } from "../config/Configuration";
|
|
40
41
|
import {
|
|
@@ -85,9 +86,10 @@ export class BrowserCacheManager extends CacheManager {
|
|
|
85
86
|
clientId: string,
|
|
86
87
|
cacheConfig: Required<CacheOptions>,
|
|
87
88
|
cryptoImpl: ICrypto,
|
|
88
|
-
logger: Logger
|
|
89
|
+
logger: Logger,
|
|
90
|
+
staticAuthorityOptions?: StaticAuthorityOptions
|
|
89
91
|
) {
|
|
90
|
-
super(clientId, cryptoImpl, logger);
|
|
92
|
+
super(clientId, cryptoImpl, logger, staticAuthorityOptions);
|
|
91
93
|
this.cacheConfig = cacheConfig;
|
|
92
94
|
this.logger = logger;
|
|
93
95
|
this.internalStorage = new MemoryStorage();
|
|
@@ -1028,10 +1030,9 @@ export class BrowserCacheManager extends CacheManager {
|
|
|
1028
1030
|
);
|
|
1029
1031
|
return null;
|
|
1030
1032
|
}
|
|
1031
|
-
const activeAccount =
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
})[0] || null;
|
|
1033
|
+
const activeAccount = this.getAccountInfoFilteredBy({
|
|
1034
|
+
localAccountId: activeAccountValueLocal,
|
|
1035
|
+
});
|
|
1035
1036
|
if (activeAccount) {
|
|
1036
1037
|
this.logger.trace(
|
|
1037
1038
|
"BrowserCacheManager.getActiveAccount: Legacy active account cache schema found"
|
|
@@ -1051,12 +1052,10 @@ export class BrowserCacheManager extends CacheManager {
|
|
|
1051
1052
|
this.logger.trace(
|
|
1052
1053
|
"BrowserCacheManager.getActiveAccount: Active account filters schema found"
|
|
1053
1054
|
);
|
|
1054
|
-
return (
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
})[0] || null
|
|
1059
|
-
);
|
|
1055
|
+
return this.getAccountInfoFilteredBy({
|
|
1056
|
+
homeAccountId: activeAccountValueObj.homeAccountId,
|
|
1057
|
+
localAccountId: activeAccountValueObj.localAccountId,
|
|
1058
|
+
});
|
|
1060
1059
|
}
|
|
1061
1060
|
this.logger.trace(
|
|
1062
1061
|
"BrowserCacheManager.getActiveAccount: No active account found"
|
|
@@ -1098,94 +1097,6 @@ export class BrowserCacheManager extends CacheManager {
|
|
|
1098
1097
|
}
|
|
1099
1098
|
}
|
|
1100
1099
|
|
|
1101
|
-
/**
|
|
1102
|
-
* Gets a list of accounts that match all of the filters provided
|
|
1103
|
-
* @param account
|
|
1104
|
-
*/
|
|
1105
|
-
getAccountInfoByFilter(
|
|
1106
|
-
accountFilter: Partial<Omit<AccountInfo, "idTokenClaims" | "name">>
|
|
1107
|
-
): AccountInfo[] {
|
|
1108
|
-
const allAccounts = this.getAllAccounts();
|
|
1109
|
-
this.logger.trace(
|
|
1110
|
-
`BrowserCacheManager.getAccountInfoByFilter: total ${allAccounts.length} accounts found`
|
|
1111
|
-
);
|
|
1112
|
-
|
|
1113
|
-
return allAccounts.filter((accountObj) => {
|
|
1114
|
-
if (
|
|
1115
|
-
accountFilter.username &&
|
|
1116
|
-
accountFilter.username.toLowerCase() !==
|
|
1117
|
-
accountObj.username.toLowerCase()
|
|
1118
|
-
) {
|
|
1119
|
-
return false;
|
|
1120
|
-
}
|
|
1121
|
-
|
|
1122
|
-
if (
|
|
1123
|
-
accountFilter.homeAccountId &&
|
|
1124
|
-
accountFilter.homeAccountId !== accountObj.homeAccountId
|
|
1125
|
-
) {
|
|
1126
|
-
return false;
|
|
1127
|
-
}
|
|
1128
|
-
|
|
1129
|
-
if (
|
|
1130
|
-
accountFilter.localAccountId &&
|
|
1131
|
-
accountFilter.localAccountId !== accountObj.localAccountId
|
|
1132
|
-
) {
|
|
1133
|
-
return false;
|
|
1134
|
-
}
|
|
1135
|
-
|
|
1136
|
-
if (
|
|
1137
|
-
accountFilter.tenantId &&
|
|
1138
|
-
accountFilter.tenantId !== accountObj.tenantId
|
|
1139
|
-
) {
|
|
1140
|
-
return false;
|
|
1141
|
-
}
|
|
1142
|
-
|
|
1143
|
-
if (
|
|
1144
|
-
accountFilter.environment &&
|
|
1145
|
-
accountFilter.environment !== accountObj.environment
|
|
1146
|
-
) {
|
|
1147
|
-
return false;
|
|
1148
|
-
}
|
|
1149
|
-
|
|
1150
|
-
return true;
|
|
1151
|
-
});
|
|
1152
|
-
}
|
|
1153
|
-
|
|
1154
|
-
/**
|
|
1155
|
-
* Checks the cache for accounts matching loginHint or SID
|
|
1156
|
-
* @param loginHint
|
|
1157
|
-
* @param sid
|
|
1158
|
-
*/
|
|
1159
|
-
getAccountInfoByHints(
|
|
1160
|
-
loginHint?: string,
|
|
1161
|
-
sid?: string
|
|
1162
|
-
): AccountInfo | null {
|
|
1163
|
-
const matchingAccounts = this.getAllAccounts().filter((accountInfo) => {
|
|
1164
|
-
if (sid) {
|
|
1165
|
-
const accountSid =
|
|
1166
|
-
accountInfo.idTokenClaims &&
|
|
1167
|
-
accountInfo.idTokenClaims["sid"];
|
|
1168
|
-
return sid === accountSid;
|
|
1169
|
-
}
|
|
1170
|
-
|
|
1171
|
-
if (loginHint) {
|
|
1172
|
-
return loginHint === accountInfo.username;
|
|
1173
|
-
}
|
|
1174
|
-
|
|
1175
|
-
return false;
|
|
1176
|
-
});
|
|
1177
|
-
|
|
1178
|
-
if (matchingAccounts.length === 1) {
|
|
1179
|
-
return matchingAccounts[0];
|
|
1180
|
-
} else if (matchingAccounts.length > 1) {
|
|
1181
|
-
throw createClientAuthError(
|
|
1182
|
-
ClientAuthErrorCodes.multipleMatchingAccounts
|
|
1183
|
-
);
|
|
1184
|
-
}
|
|
1185
|
-
|
|
1186
|
-
return null;
|
|
1187
|
-
}
|
|
1188
|
-
|
|
1189
1100
|
/**
|
|
1190
1101
|
* fetch throttling entity from the platform cache
|
|
1191
1102
|
* @param throttlingCacheKey
|
|
@@ -93,6 +93,10 @@ export type BrowserAuthOptions = {
|
|
|
93
93
|
* Flag of whether to use the local metadata cache
|
|
94
94
|
*/
|
|
95
95
|
skipAuthorityMetadataCache?: boolean;
|
|
96
|
+
/**
|
|
97
|
+
* App supports nested app auth or not; defaults to false
|
|
98
|
+
*/
|
|
99
|
+
supportsNestedAppAuth?: boolean;
|
|
96
100
|
};
|
|
97
101
|
|
|
98
102
|
/** @internal */
|
|
@@ -273,6 +277,7 @@ export function buildConfiguration(
|
|
|
273
277
|
tenant: Constants.EMPTY_STRING,
|
|
274
278
|
},
|
|
275
279
|
skipAuthorityMetadataCache: false,
|
|
280
|
+
supportsNestedAppAuth: false,
|
|
276
281
|
};
|
|
277
282
|
|
|
278
283
|
// Default cache options for browser
|