@azure/msal-browser 2.23.0 → 2.24.0-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/LICENSE +21 -21
- package/README.md +214 -214
- package/dist/_virtual/_tslib.js +1 -1
- package/dist/app/ClientApplication.d.ts +58 -1
- package/dist/app/ClientApplication.d.ts.map +1 -1
- package/dist/app/ClientApplication.js +290 -75
- package/dist/app/ClientApplication.js.map +1 -1
- package/dist/app/IPublicClientApplication.d.ts +1 -0
- package/dist/app/IPublicClientApplication.d.ts.map +1 -1
- package/dist/app/IPublicClientApplication.js +4 -1
- package/dist/app/IPublicClientApplication.js.map +1 -1
- package/dist/app/PublicClientApplication.d.ts.map +1 -1
- package/dist/app/PublicClientApplication.js +48 -42
- package/dist/app/PublicClientApplication.js.map +1 -1
- package/dist/broker/nativeBroker/NativeMessageHandler.d.ts +49 -0
- package/dist/broker/nativeBroker/NativeMessageHandler.d.ts.map +1 -0
- package/dist/broker/nativeBroker/NativeMessageHandler.js +246 -0
- package/dist/broker/nativeBroker/NativeMessageHandler.js.map +1 -0
- package/dist/broker/nativeBroker/NativeRequest.d.ts +43 -0
- package/dist/broker/nativeBroker/NativeRequest.d.ts.map +1 -0
- package/dist/broker/nativeBroker/NativeResponse.d.ts +24 -0
- package/dist/broker/nativeBroker/NativeResponse.d.ts.map +1 -0
- package/dist/cache/AsyncMemoryStorage.js +1 -1
- package/dist/cache/AsyncMemoryStorage.js.map +1 -1
- package/dist/cache/BrowserCacheManager.d.ts +11 -0
- package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
- package/dist/cache/BrowserCacheManager.js +44 -2
- package/dist/cache/BrowserCacheManager.js.map +1 -1
- package/dist/cache/BrowserStorage.js +1 -1
- package/dist/cache/BrowserStorage.js.map +1 -1
- package/dist/cache/DatabaseStorage.js +1 -1
- package/dist/cache/DatabaseStorage.js.map +1 -1
- package/dist/cache/MemoryStorage.js +1 -1
- package/dist/cache/MemoryStorage.js.map +1 -1
- package/dist/cache/TokenCache.js +1 -1
- package/dist/cache/TokenCache.js.map +1 -1
- package/dist/config/Configuration.d.ts +99 -38
- package/dist/config/Configuration.d.ts.map +1 -1
- package/dist/config/Configuration.js +4 -3
- package/dist/config/Configuration.js.map +1 -1
- package/dist/crypto/BrowserCrypto.js +1 -1
- package/dist/crypto/BrowserCrypto.js.map +1 -1
- package/dist/crypto/CryptoOps.js +1 -1
- package/dist/crypto/CryptoOps.js.map +1 -1
- package/dist/crypto/GuidGenerator.js +1 -1
- package/dist/crypto/GuidGenerator.js.map +1 -1
- package/dist/crypto/PkceGenerator.js +1 -1
- package/dist/crypto/PkceGenerator.js.map +1 -1
- package/dist/crypto/SignedHttpRequest.js +1 -1
- package/dist/crypto/SignedHttpRequest.js.map +1 -1
- package/dist/encode/Base64Decode.js +1 -1
- package/dist/encode/Base64Decode.js.map +1 -1
- package/dist/encode/Base64Encode.js +1 -1
- package/dist/encode/Base64Encode.js.map +1 -1
- package/dist/error/BrowserAuthError.d.ts +58 -0
- package/dist/error/BrowserAuthError.d.ts.map +1 -1
- package/dist/error/BrowserAuthError.js +73 -1
- package/dist/error/BrowserAuthError.js.map +1 -1
- package/dist/error/BrowserConfigurationAuthError.js +1 -1
- package/dist/error/BrowserConfigurationAuthError.js.map +1 -1
- package/dist/error/NativeAuthError.d.ts +46 -0
- package/dist/error/NativeAuthError.d.ts.map +1 -0
- package/dist/error/NativeAuthError.js +82 -0
- package/dist/error/NativeAuthError.js.map +1 -0
- package/dist/event/EventHandler.js +1 -1
- package/dist/event/EventHandler.js.map +1 -1
- package/dist/event/EventMessage.js +1 -1
- package/dist/event/EventMessage.js.map +1 -1
- package/dist/event/EventType.d.ts +2 -0
- package/dist/event/EventType.d.ts.map +1 -1
- package/dist/event/EventType.js +3 -1
- package/dist/event/EventType.js.map +1 -1
- package/dist/index.cjs.js +1633 -449
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/interaction_client/BaseInteractionClient.d.ts +12 -2
- package/dist/interaction_client/BaseInteractionClient.d.ts.map +1 -1
- package/dist/interaction_client/BaseInteractionClient.js +35 -3
- package/dist/interaction_client/BaseInteractionClient.js.map +1 -1
- package/dist/interaction_client/HybridSpaAuthorizationCodeClient.js +1 -1
- package/dist/interaction_client/HybridSpaAuthorizationCodeClient.js.map +1 -1
- package/dist/interaction_client/NativeInteractionClient.d.ts +57 -0
- package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -0
- package/dist/interaction_client/NativeInteractionClient.js +334 -0
- package/dist/interaction_client/NativeInteractionClient.js.map +1 -0
- package/dist/interaction_client/PopupClient.d.ts.map +1 -1
- package/dist/interaction_client/PopupClient.js +36 -7
- package/dist/interaction_client/PopupClient.js.map +1 -1
- package/dist/interaction_client/RedirectClient.d.ts.map +1 -1
- package/dist/interaction_client/RedirectClient.js +26 -8
- package/dist/interaction_client/RedirectClient.js.map +1 -1
- package/dist/interaction_client/SilentAuthCodeClient.d.ts +2 -1
- package/dist/interaction_client/SilentAuthCodeClient.d.ts.map +1 -1
- package/dist/interaction_client/SilentAuthCodeClient.js +3 -3
- package/dist/interaction_client/SilentAuthCodeClient.js.map +1 -1
- package/dist/interaction_client/SilentCacheClient.d.ts.map +1 -1
- package/dist/interaction_client/SilentCacheClient.js +2 -4
- package/dist/interaction_client/SilentCacheClient.js.map +1 -1
- package/dist/interaction_client/SilentIframeClient.d.ts +5 -3
- package/dist/interaction_client/SilentIframeClient.d.ts.map +1 -1
- package/dist/interaction_client/SilentIframeClient.js +38 -25
- package/dist/interaction_client/SilentIframeClient.js.map +1 -1
- package/dist/interaction_client/SilentRefreshClient.js +1 -1
- package/dist/interaction_client/SilentRefreshClient.js.map +1 -1
- package/dist/interaction_client/StandardInteractionClient.d.ts +2 -8
- package/dist/interaction_client/StandardInteractionClient.d.ts.map +1 -1
- package/dist/interaction_client/StandardInteractionClient.js +5 -9
- package/dist/interaction_client/StandardInteractionClient.js.map +1 -1
- package/dist/interaction_handler/InteractionHandler.d.ts.map +1 -1
- package/dist/interaction_handler/InteractionHandler.js +15 -4
- package/dist/interaction_handler/InteractionHandler.js.map +1 -1
- package/dist/interaction_handler/PopupHandler.js +1 -1
- package/dist/interaction_handler/PopupHandler.js.map +1 -1
- package/dist/interaction_handler/RedirectHandler.d.ts +1 -1
- package/dist/interaction_handler/RedirectHandler.d.ts.map +1 -1
- package/dist/interaction_handler/RedirectHandler.js +16 -9
- package/dist/interaction_handler/RedirectHandler.js.map +1 -1
- package/dist/interaction_handler/SilentHandler.js +1 -1
- package/dist/interaction_handler/SilentHandler.js.map +1 -1
- package/dist/navigation/NavigationClient.js +1 -1
- package/dist/navigation/NavigationClient.js.map +1 -1
- package/dist/network/FetchClient.js +1 -1
- package/dist/network/FetchClient.js.map +1 -1
- package/dist/network/XhrClient.js +1 -1
- package/dist/network/XhrClient.js.map +1 -1
- package/dist/packageMetadata.d.ts +1 -1
- package/dist/packageMetadata.d.ts.map +1 -1
- package/dist/packageMetadata.js +2 -2
- package/dist/packageMetadata.js.map +1 -1
- package/dist/request/AuthorizationCodeRequest.d.ts +2 -1
- package/dist/request/AuthorizationCodeRequest.d.ts.map +1 -1
- package/dist/request/AuthorizationUrlRequest.d.ts +1 -1
- package/dist/request/AuthorizationUrlRequest.d.ts.map +1 -1
- package/dist/request/PopupRequest.d.ts +1 -1
- package/dist/request/PopupRequest.d.ts.map +1 -1
- package/dist/request/RedirectRequest.d.ts +1 -1
- package/dist/request/RedirectRequest.d.ts.map +1 -1
- package/dist/request/SsoSilentRequest.d.ts +1 -1
- package/dist/request/SsoSilentRequest.d.ts.map +1 -1
- package/dist/telemetry/BrowserPerformanceClient.js +1 -1
- package/dist/telemetry/BrowserPerformanceClient.js.map +1 -1
- package/dist/telemetry/BrowserPerformanceMeasurement.js +1 -1
- package/dist/telemetry/BrowserPerformanceMeasurement.js.map +1 -1
- package/dist/utils/BrowserConstants.d.ts +12 -1
- package/dist/utils/BrowserConstants.d.ts.map +1 -1
- package/dist/utils/BrowserConstants.js +14 -2
- package/dist/utils/BrowserConstants.js.map +1 -1
- package/dist/utils/BrowserProtocolUtils.js +1 -1
- package/dist/utils/BrowserProtocolUtils.js.map +1 -1
- package/dist/utils/BrowserStringUtils.js +1 -1
- package/dist/utils/BrowserStringUtils.js.map +1 -1
- package/dist/utils/BrowserUtils.d.ts +6 -0
- package/dist/utils/BrowserUtils.d.ts.map +1 -1
- package/dist/utils/BrowserUtils.js +11 -1
- package/dist/utils/BrowserUtils.js.map +1 -1
- package/dist/utils/MathUtils.js +1 -1
- package/dist/utils/MathUtils.js.map +1 -1
- package/dist/utils/PopupUtils.js +1 -1
- package/dist/utils/PopupUtils.js.map +1 -1
- package/lib/msal-browser.js +1633 -449
- package/lib/msal-browser.js.map +1 -1
- package/lib/msal-browser.min.js +38 -38
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ICrypto, INetworkModule, Logger, AuthenticationResult, AccountInfo, BaseAuthRequest, ServerTelemetryManager, IPerformanceClient } from "@azure/msal-common";
|
|
1
|
+
import { ICrypto, INetworkModule, Logger, AuthenticationResult, AccountInfo, BaseAuthRequest, ServerTelemetryManager, Authority, IPerformanceClient } from "@azure/msal-common";
|
|
2
2
|
import { BrowserConfiguration } from "../config/Configuration";
|
|
3
3
|
import { BrowserCacheManager } from "../cache/BrowserCacheManager";
|
|
4
4
|
import { EventHandler } from "../event/EventHandler";
|
|
@@ -6,6 +6,8 @@ import { EndSessionRequest } from "../request/EndSessionRequest";
|
|
|
6
6
|
import { RedirectRequest } from "../request/RedirectRequest";
|
|
7
7
|
import { PopupRequest } from "../request/PopupRequest";
|
|
8
8
|
import { SsoSilentRequest } from "../request/SsoSilentRequest";
|
|
9
|
+
import { INavigationClient } from "../navigation/INavigationClient";
|
|
10
|
+
import { NativeMessageHandler } from "../broker/nativeBroker/NativeMessageHandler";
|
|
9
11
|
export declare abstract class BaseInteractionClient {
|
|
10
12
|
protected config: BrowserConfiguration;
|
|
11
13
|
protected browserStorage: BrowserCacheManager;
|
|
@@ -13,9 +15,11 @@ export declare abstract class BaseInteractionClient {
|
|
|
13
15
|
protected networkClient: INetworkModule;
|
|
14
16
|
protected logger: Logger;
|
|
15
17
|
protected eventHandler: EventHandler;
|
|
18
|
+
protected navigationClient: INavigationClient;
|
|
19
|
+
protected nativeMessageHandler: NativeMessageHandler | undefined;
|
|
16
20
|
protected correlationId: string;
|
|
17
21
|
protected performanceClient: IPerformanceClient;
|
|
18
|
-
constructor(config: BrowserConfiguration, storageImpl: BrowserCacheManager, browserCrypto: ICrypto, logger: Logger, eventHandler: EventHandler, performanceClient: IPerformanceClient, correlationId?: string);
|
|
22
|
+
constructor(config: BrowserConfiguration, storageImpl: BrowserCacheManager, browserCrypto: ICrypto, logger: Logger, eventHandler: EventHandler, navigationClient: INavigationClient, performanceClient: IPerformanceClient, nativeMessageHandler?: NativeMessageHandler, correlationId?: string);
|
|
19
23
|
abstract acquireToken(request: RedirectRequest | PopupRequest | SsoSilentRequest): Promise<AuthenticationResult | void>;
|
|
20
24
|
abstract logout(request: EndSessionRequest): Promise<void>;
|
|
21
25
|
protected clearCacheOnLogout(account?: AccountInfo | null): Promise<void>;
|
|
@@ -39,5 +43,11 @@ export declare abstract class BaseInteractionClient {
|
|
|
39
43
|
* @param forceRefresh
|
|
40
44
|
*/
|
|
41
45
|
protected initializeServerTelemetryManager(apiId: number, forceRefresh?: boolean): ServerTelemetryManager;
|
|
46
|
+
/**
|
|
47
|
+
* Used to get a discovered version of the default authority.
|
|
48
|
+
* @param requestAuthority
|
|
49
|
+
* @param requestCorrelationId
|
|
50
|
+
*/
|
|
51
|
+
protected getDiscoveredAuthority(requestAuthority?: string): Promise<Authority>;
|
|
42
52
|
}
|
|
43
53
|
//# sourceMappingURL=BaseInteractionClient.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseInteractionClient.d.ts","sourceRoot":"","sources":["../../src/interaction_client/BaseInteractionClient.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,oBAAoB,EAAE,WAAW,EAAiB,eAAe,EAAmC,sBAAsB,EAAiE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"BaseInteractionClient.d.ts","sourceRoot":"","sources":["../../src/interaction_client/BaseInteractionClient.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,oBAAoB,EAAE,WAAW,EAAiB,eAAe,EAAmC,sBAAsB,EAAiE,SAAS,EAAsC,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACnU,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAI/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,6CAA6C,CAAC;AAEnF,8BAAsB,qBAAqB;IAEvC,SAAS,CAAC,MAAM,EAAE,oBAAoB,CAAC;IACvC,SAAS,CAAC,cAAc,EAAE,mBAAmB,CAAC;IAC9C,SAAS,CAAC,aAAa,EAAE,OAAO,CAAC;IACjC,SAAS,CAAC,aAAa,EAAE,cAAc,CAAC;IACxC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,YAAY,EAAE,YAAY,CAAC;IACrC,SAAS,CAAC,gBAAgB,EAAE,iBAAiB,CAAC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ter, __generator, __spread, __assign } from '../_virtual/_tslib.js';
|
|
4
|
-
import { AccountEntity, AuthenticationScheme, ClientConfigurationError, StringUtils, UrlString, ServerTelemetryManager } from '@azure/msal-common';
|
|
4
|
+
import { AccountEntity, AuthenticationScheme, ClientConfigurationError, StringUtils, UrlString, ServerTelemetryManager, AuthorityFactory } from '@azure/msal-common';
|
|
5
5
|
import { version } from '../packageMetadata.js';
|
|
6
6
|
import { BrowserConstants } from '../utils/BrowserConstants.js';
|
|
7
7
|
import { BrowserUtils } from '../utils/BrowserUtils.js';
|
|
@@ -11,12 +11,14 @@ import { BrowserUtils } from '../utils/BrowserUtils.js';
|
|
|
11
11
|
* Licensed under the MIT License.
|
|
12
12
|
*/
|
|
13
13
|
var BaseInteractionClient = /** @class */ (function () {
|
|
14
|
-
function BaseInteractionClient(config, storageImpl, browserCrypto, logger, eventHandler, performanceClient, correlationId) {
|
|
14
|
+
function BaseInteractionClient(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, performanceClient, nativeMessageHandler, correlationId) {
|
|
15
15
|
this.config = config;
|
|
16
16
|
this.browserStorage = storageImpl;
|
|
17
17
|
this.browserCrypto = browserCrypto;
|
|
18
18
|
this.networkClient = this.config.system.networkClient;
|
|
19
19
|
this.eventHandler = eventHandler;
|
|
20
|
+
this.navigationClient = navigationClient;
|
|
21
|
+
this.nativeMessageHandler = nativeMessageHandler;
|
|
20
22
|
this.correlationId = correlationId || this.browserCrypto.createNewGuid();
|
|
21
23
|
this.logger = logger.clone(BrowserConstants.MSAL_SKU, version, this.correlationId);
|
|
22
24
|
this.performanceClient = performanceClient;
|
|
@@ -139,6 +141,36 @@ var BaseInteractionClient = /** @class */ (function () {
|
|
|
139
141
|
};
|
|
140
142
|
return new ServerTelemetryManager(telemetryPayload, this.browserStorage);
|
|
141
143
|
};
|
|
144
|
+
/**
|
|
145
|
+
* Used to get a discovered version of the default authority.
|
|
146
|
+
* @param requestAuthority
|
|
147
|
+
* @param requestCorrelationId
|
|
148
|
+
*/
|
|
149
|
+
BaseInteractionClient.prototype.getDiscoveredAuthority = function (requestAuthority) {
|
|
150
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
151
|
+
var authorityOptions;
|
|
152
|
+
return __generator(this, function (_a) {
|
|
153
|
+
switch (_a.label) {
|
|
154
|
+
case 0:
|
|
155
|
+
this.logger.verbose("getDiscoveredAuthority called");
|
|
156
|
+
authorityOptions = {
|
|
157
|
+
protocolMode: this.config.auth.protocolMode,
|
|
158
|
+
knownAuthorities: this.config.auth.knownAuthorities,
|
|
159
|
+
cloudDiscoveryMetadata: this.config.auth.cloudDiscoveryMetadata,
|
|
160
|
+
authorityMetadata: this.config.auth.authorityMetadata
|
|
161
|
+
};
|
|
162
|
+
if (!requestAuthority) return [3 /*break*/, 2];
|
|
163
|
+
this.logger.verbose("Creating discovered authority with request authority");
|
|
164
|
+
return [4 /*yield*/, AuthorityFactory.createDiscoveredInstance(requestAuthority, this.config.system.networkClient, this.browserStorage, authorityOptions)];
|
|
165
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
166
|
+
case 2:
|
|
167
|
+
this.logger.verbose("Creating discovered authority with configured authority");
|
|
168
|
+
return [4 /*yield*/, AuthorityFactory.createDiscoveredInstance(this.config.auth.authority, this.config.system.networkClient, this.browserStorage, authorityOptions)];
|
|
169
|
+
case 3: return [2 /*return*/, _a.sent()];
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
};
|
|
142
174
|
return BaseInteractionClient;
|
|
143
175
|
}());
|
|
144
176
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseInteractionClient.js","sources":["../../src/interaction_client/BaseInteractionClient.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ICrypto, INetworkModule, Logger, AuthenticationResult, AccountInfo, AccountEntity, BaseAuthRequest, AuthenticationScheme, UrlString, ServerTelemetryManager, ServerTelemetryRequest, ClientConfigurationError, StringUtils, IPerformanceClient } from \"@azure/msal-common\";\nimport { BrowserConfiguration } from \"../config/Configuration\";\nimport { BrowserCacheManager } from \"../cache/BrowserCacheManager\";\nimport { EventHandler } from \"../event/EventHandler\";\nimport { EndSessionRequest } from \"../request/EndSessionRequest\";\nimport { RedirectRequest } from \"../request/RedirectRequest\";\nimport { PopupRequest } from \"../request/PopupRequest\";\nimport { SsoSilentRequest } from \"../request/SsoSilentRequest\";\nimport { version } from \"../packageMetadata\";\nimport { BrowserConstants } from \"../utils/BrowserConstants\";\nimport { BrowserUtils } from \"../utils/BrowserUtils\";\n\nexport abstract class BaseInteractionClient {\n\n protected config: BrowserConfiguration;\n protected browserStorage: BrowserCacheManager;\n protected browserCrypto: ICrypto;\n protected networkClient: INetworkModule;\n protected logger: Logger;\n protected eventHandler: EventHandler;\n protected correlationId: string;\n protected performanceClient: IPerformanceClient;\n\n constructor(config: BrowserConfiguration, storageImpl: BrowserCacheManager, browserCrypto: ICrypto, logger: Logger, eventHandler: EventHandler, performanceClient: IPerformanceClient, correlationId?: string) {\n this.config = config;\n this.browserStorage = storageImpl;\n this.browserCrypto = browserCrypto;\n this.networkClient = this.config.system.networkClient;\n this.eventHandler = eventHandler;\n this.correlationId = correlationId || this.browserCrypto.createNewGuid();\n this.logger = logger.clone(BrowserConstants.MSAL_SKU, version, this.correlationId);\n this.performanceClient = performanceClient;\n }\n\n abstract acquireToken(request: RedirectRequest|PopupRequest|SsoSilentRequest): Promise<AuthenticationResult|void>;\n\n abstract logout(request: EndSessionRequest): Promise<void>;\n\n protected async clearCacheOnLogout(account?: AccountInfo| null): Promise<void> {\n if (account) {\n if (AccountEntity.accountInfoIsEqual(account, this.browserStorage.getActiveAccount(), false)) {\n this.logger.verbose(\"Setting active account to null\");\n this.browserStorage.setActiveAccount(null);\n }\n // Clear given account.\n try {\n await this.browserStorage.removeAccount(AccountEntity.generateAccountCacheKey(account));\n this.logger.verbose(\"Cleared cache items belonging to the account provided in the logout request.\");\n } catch (error) {\n this.logger.error(\"Account provided in logout request was not found. Local cache unchanged.\");\n }\n } else {\n try {\n this.logger.verbose(\"No account provided in logout request, clearing all cache items.\", this.correlationId);\n // Clear all accounts and tokens\n await this.browserStorage.clear();\n // Clear any stray keys from IndexedDB\n await this.browserCrypto.clearKeystore();\n } catch(e) {\n this.logger.error(\"Attempted to clear all MSAL cache items and failed. Local cache unchanged.\");\n }\n }\n }\n\n /**\n * Initializer function for all request APIs\n * @param request\n */\n protected async initializeBaseRequest(request: Partial<BaseAuthRequest>): Promise<BaseAuthRequest> {\n this.logger.verbose(\"Initializing BaseAuthRequest\");\n const authority = request.authority || this.config.auth.authority;\n\n const scopes = [...((request && request.scopes) || [])];\n\n const validatedRequest: BaseAuthRequest = {\n ...request,\n correlationId: this.correlationId,\n authority,\n scopes\n };\n\n // Set authenticationScheme to BEARER if not explicitly set in the request\n if (!validatedRequest.authenticationScheme) {\n validatedRequest.authenticationScheme = AuthenticationScheme.BEARER;\n this.logger.verbose(\"Authentication Scheme wasn't explicitly set in request, defaulting to \\\"Bearer\\\" request\");\n } else {\n if (validatedRequest.authenticationScheme === AuthenticationScheme.SSH) {\n if (!request.sshJwk) {\n throw ClientConfigurationError.createMissingSshJwkError();\n }\n if(!request.sshKid) {\n throw ClientConfigurationError.createMissingSshKidError();\n }\n }\n this.logger.verbose(`Authentication Scheme set to \"${validatedRequest.authenticationScheme}\" as configured in Auth request`);\n }\n\n // Set requested claims hash if claims were requested\n if (request.claims && !StringUtils.isEmpty(request.claims)) {\n validatedRequest.requestedClaimsHash = await this.browserCrypto.hashString(request.claims);\n } \n\n return validatedRequest;\n }\n\n /**\n *\n * Use to get the redirect uri configured in MSAL or null.\n * @param requestRedirectUri\n * @returns Redirect URL\n *\n */\n getRedirectUri(requestRedirectUri?: string): string {\n this.logger.verbose(\"getRedirectUri called\");\n const redirectUri = requestRedirectUri || this.config.auth.redirectUri || BrowserUtils.getCurrentUri();\n return UrlString.getAbsoluteUrl(redirectUri, BrowserUtils.getCurrentUri());\n }\n\n /**\n *\n * @param apiId\n * @param correlationId\n * @param forceRefresh\n */\n protected initializeServerTelemetryManager(apiId: number, forceRefresh?: boolean): ServerTelemetryManager {\n this.logger.verbose(\"initializeServerTelemetryManager called\");\n const telemetryPayload: ServerTelemetryRequest = {\n clientId: this.config.auth.clientId,\n correlationId: this.correlationId,\n apiId: apiId,\n forceRefresh: forceRefresh || false,\n wrapperSKU: this.browserStorage.getWrapperMetadata()[0],\n wrapperVer: this.browserStorage.getWrapperMetadata()[1]\n };\n\n return new ServerTelemetryManager(telemetryPayload, this.browserStorage);\n }\n}\n"],"names":[],"mappings":";;;;;;;;AAAA;;;;;IA4BI,+BAAY,MAA4B,EAAE,WAAgC,EAAE,aAAsB,EAAE,MAAc,EAAE,YAA0B,EAAE,iBAAqC,EAAE,aAAsB;QACzM,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,cAAc,GAAG,WAAW,CAAC;QAClC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC;QACtD,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,aAAa,GAAG,aAAa,IAAI,IAAI,CAAC,aAAa,CAAC,aAAa,EAAE,CAAC;QACzE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;QACnF,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;KAC9C;IAMe,kDAAkB,GAAlC,UAAmC,OAA2B;;;;;6BACtD,OAAO,EAAP,wBAAO;wBACP,IAAI,aAAa,CAAC,kBAAkB,CAAC,OAAO,EAAE,IAAI,CAAC,cAAc,CAAC,gBAAgB,EAAE,EAAE,KAAK,CAAC,EAAE;4BAC1F,IAAI,CAA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AI,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ;YACnC,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,KAAK,EAAE,KAAK;YACZ,YAAY,EAAE,YAAY,IAAI,KAAK;YACnC,UAAU,EAAE,IAAI,CAAC,cAAc,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAC;YACvD,UAAU,EAAE,IAAI,CAAC,cAAc,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAC;SAC1D,CAAC;QAEF,OAAO,IAAI,sBAAsB,CAAC,gBAAgB,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;KAC5E;IACL,4BAAC;AAAD,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"BaseInteractionClient.js","sources":["../../src/interaction_client/BaseInteractionClient.ts"],"sourcesContent":["/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { ICrypto, INetworkModule, Logger, AuthenticationResult, AccountInfo, AccountEntity, BaseAuthRequest, AuthenticationScheme, UrlString, ServerTelemetryManager, ServerTelemetryRequest, ClientConfigurationError, StringUtils, Authority, AuthorityOptions, AuthorityFactory, IPerformanceClient } from \"@azure/msal-common\";\r\nimport { BrowserConfiguration } from \"../config/Configuration\";\r\nimport { BrowserCacheManager } from \"../cache/BrowserCacheManager\";\r\nimport { EventHandler } from \"../event/EventHandler\";\r\nimport { EndSessionRequest } from \"../request/EndSessionRequest\";\r\nimport { RedirectRequest } from \"../request/RedirectRequest\";\r\nimport { PopupRequest } from \"../request/PopupRequest\";\r\nimport { SsoSilentRequest } from \"../request/SsoSilentRequest\";\r\nimport { version } from \"../packageMetadata\";\r\nimport { BrowserConstants } from \"../utils/BrowserConstants\";\r\nimport { BrowserUtils } from \"../utils/BrowserUtils\";\r\nimport { INavigationClient } from \"../navigation/INavigationClient\";\r\nimport { NativeMessageHandler } from \"../broker/nativeBroker/NativeMessageHandler\";\r\n\r\nexport abstract class BaseInteractionClient {\r\n\r\n protected config: BrowserConfiguration;\r\n protected browserStorage: BrowserCacheManager;\r\n protected browserCrypto: ICrypto;\r\n protected networkClient: INetworkModule;\r\n protected logger: Logger;\r\n protected eventHandler: EventHandler;\r\n protected navigationClient: INavigationClient;\r\n protected nativeMessageHandler: NativeMessageHandler | undefined;\r\n protected correlationId: string;\r\n protected performanceClient: IPerformanceClient;\r\n\r\n constructor(config: BrowserConfiguration, storageImpl: BrowserCacheManager, browserCrypto: ICrypto, logger: Logger, eventHandler: EventHandler, navigationClient: INavigationClient, performanceClient: IPerformanceClient, nativeMessageHandler?: NativeMessageHandler, correlationId?: string) {\r\n this.config = config;\r\n this.browserStorage = storageImpl;\r\n this.browserCrypto = browserCrypto;\r\n this.networkClient = this.config.system.networkClient;\r\n this.eventHandler = eventHandler;\r\n this.navigationClient = navigationClient;\r\n this.nativeMessageHandler = nativeMessageHandler;\r\n this.correlationId = correlationId || this.browserCrypto.createNewGuid();\r\n this.logger = logger.clone(BrowserConstants.MSAL_SKU, version, this.correlationId);\r\n this.performanceClient = performanceClient;\r\n }\r\n\r\n abstract acquireToken(request: RedirectRequest|PopupRequest|SsoSilentRequest): Promise<AuthenticationResult|void>;\r\n\r\n abstract logout(request: EndSessionRequest): Promise<void>;\r\n\r\n protected async clearCacheOnLogout(account?: AccountInfo| null): Promise<void> {\r\n if (account) {\r\n if (AccountEntity.accountInfoIsEqual(account, this.browserStorage.getActiveAccount(), false)) {\r\n this.logger.verbose(\"Setting active account to null\");\r\n this.browserStorage.setActiveAccount(null);\r\n }\r\n // Clear given account.\r\n try {\r\n await this.browserStorage.removeAccount(AccountEntity.generateAccountCacheKey(account));\r\n this.logger.verbose(\"Cleared cache items belonging to the account provided in the logout request.\");\r\n } catch (error) {\r\n this.logger.error(\"Account provided in logout request was not found. Local cache unchanged.\");\r\n }\r\n } else {\r\n try {\r\n this.logger.verbose(\"No account provided in logout request, clearing all cache items.\", this.correlationId);\r\n // Clear all accounts and tokens\r\n await this.browserStorage.clear();\r\n // Clear any stray keys from IndexedDB\r\n await this.browserCrypto.clearKeystore();\r\n } catch(e) {\r\n this.logger.error(\"Attempted to clear all MSAL cache items and failed. Local cache unchanged.\");\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Initializer function for all request APIs\r\n * @param request\r\n */\r\n protected async initializeBaseRequest(request: Partial<BaseAuthRequest>): Promise<BaseAuthRequest> {\r\n this.logger.verbose(\"Initializing BaseAuthRequest\");\r\n const authority = request.authority || this.config.auth.authority;\r\n\r\n const scopes = [...((request && request.scopes) || [])];\r\n\r\n const validatedRequest: BaseAuthRequest = {\r\n ...request,\r\n correlationId: this.correlationId,\r\n authority,\r\n scopes\r\n };\r\n\r\n // Set authenticationScheme to BEARER if not explicitly set in the request\r\n if (!validatedRequest.authenticationScheme) {\r\n validatedRequest.authenticationScheme = AuthenticationScheme.BEARER;\r\n this.logger.verbose(\"Authentication Scheme wasn't explicitly set in request, defaulting to \\\"Bearer\\\" request\");\r\n } else {\r\n if (validatedRequest.authenticationScheme === AuthenticationScheme.SSH) {\r\n if (!request.sshJwk) {\r\n throw ClientConfigurationError.createMissingSshJwkError();\r\n }\r\n if(!request.sshKid) {\r\n throw ClientConfigurationError.createMissingSshKidError();\r\n }\r\n }\r\n this.logger.verbose(`Authentication Scheme set to \"${validatedRequest.authenticationScheme}\" as configured in Auth request`);\r\n }\r\n\r\n // Set requested claims hash if claims were requested\r\n if (request.claims && !StringUtils.isEmpty(request.claims)) {\r\n validatedRequest.requestedClaimsHash = await this.browserCrypto.hashString(request.claims);\r\n }\r\n\r\n return validatedRequest;\r\n }\r\n\r\n /**\r\n *\r\n * Use to get the redirect uri configured in MSAL or null.\r\n * @param requestRedirectUri\r\n * @returns Redirect URL\r\n *\r\n */\r\n getRedirectUri(requestRedirectUri?: string): string {\r\n this.logger.verbose(\"getRedirectUri called\");\r\n const redirectUri = requestRedirectUri || this.config.auth.redirectUri || BrowserUtils.getCurrentUri();\r\n return UrlString.getAbsoluteUrl(redirectUri, BrowserUtils.getCurrentUri());\r\n }\r\n\r\n /**\r\n *\r\n * @param apiId\r\n * @param correlationId\r\n * @param forceRefresh\r\n */\r\n protected initializeServerTelemetryManager(apiId: number, forceRefresh?: boolean): ServerTelemetryManager {\r\n this.logger.verbose(\"initializeServerTelemetryManager called\");\r\n const telemetryPayload: ServerTelemetryRequest = {\r\n clientId: this.config.auth.clientId,\r\n correlationId: this.correlationId,\r\n apiId: apiId,\r\n forceRefresh: forceRefresh || false,\r\n wrapperSKU: this.browserStorage.getWrapperMetadata()[0],\r\n wrapperVer: this.browserStorage.getWrapperMetadata()[1]\r\n };\r\n\r\n return new ServerTelemetryManager(telemetryPayload, this.browserStorage);\r\n }\r\n\r\n /**\r\n * Used to get a discovered version of the default authority.\r\n * @param requestAuthority\r\n * @param requestCorrelationId\r\n */\r\n protected async getDiscoveredAuthority(requestAuthority?: string): Promise<Authority> {\r\n this.logger.verbose(\"getDiscoveredAuthority called\");\r\n const authorityOptions: AuthorityOptions = {\r\n protocolMode: this.config.auth.protocolMode,\r\n knownAuthorities: this.config.auth.knownAuthorities,\r\n cloudDiscoveryMetadata: this.config.auth.cloudDiscoveryMetadata,\r\n authorityMetadata: this.config.auth.authorityMetadata\r\n };\r\n\r\n if (requestAuthority) {\r\n this.logger.verbose(\"Creating discovered authority with request authority\");\r\n return await AuthorityFactory.createDiscoveredInstance(requestAuthority, this.config.system.networkClient, this.browserStorage, authorityOptions);\r\n }\r\n\r\n this.logger.verbose(\"Creating discovered authority with configured authority\");\r\n return await AuthorityFactory.createDiscoveredInstance(this.config.auth.authority, this.config.system.networkClient, this.browserStorage, authorityOptions);\r\n }\r\n}\r\n"],"names":[],"mappings":";;;;;;;;AAAA;;;;;IAgCI,+BAAY,MAA4B,EAAE,WAAgC,EAAE,aAAsB,EAAE,MAAc,EAAE,YAA0B,EAAE,gBAAmC,EAAE,iBAAqC,EAAE,oBAA2C,EAAE,aAAsB;QAC3R,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAA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+B,CAAC,CAAC;wBAC/C,gBAAgB,GAAqB;4BACvC,YAAY,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY;4BAC3C,gBAAgB,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAgB;4BACnD,sBAAsB,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,sBAAsB;4BAC/D,iBAAiB,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,iBAAiB;yBACxD,CAAC;6BAEE,gBAAgB,EAAhB,wBAAgB;wBAChB,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,sDAAsD,CAAC,CAAC;wBACrE,qBAAM,gBAAgB,CAAC,wBAAwB,CAAC,gBAAgB,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE,IAAI,CAAC,cAAc,EAAE,gBAAgB,CAAC,EAAA;4BAAjJ,sBAAO,SAA0I,EAAC;;wBAGtJ,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,yDAAyD,CAAC,CAAC;wBACxE,qBAAM,gBAAgB,CAAC,wBAAwB,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE,IAAI,CAAC,cAAc,EAAE,gBAAgB,CAAC,EAAA;4BAA3J,sBAAO,SAAoJ,EAAC;;;;KAC/J;IACL,4BAAC;AAAD,CAAC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HybridSpaAuthorizationCodeClient.js","sources":["../../src/interaction_client/HybridSpaAuthorizationCodeClient.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { AuthorizationCodeClient, ClientConfiguration } from \"@azure/msal-common\";\n\nexport class HybridSpaAuthorizationCodeClient extends AuthorizationCodeClient {\n constructor(config: ClientConfiguration) {\n super(config);\n this.includeRedirectUri = false;\n }\n}\n"],"names":[],"mappings":";;;;;AAAA;;;;;IAOsD,oDAAuB;IACzE,0CAAY,MAA2B;QAAvC,YACI,kBAAM,MAAM,CAAC,SAEhB;QADG,KAAI,CAAC,kBAAkB,GAAG,KAAK,CAAC;;KACnC;IACL,uCAAC;AAAD,CALA,CAAsD,uBAAuB;;;;"}
|
|
1
|
+
{"version":3,"file":"HybridSpaAuthorizationCodeClient.js","sources":["../../src/interaction_client/HybridSpaAuthorizationCodeClient.ts"],"sourcesContent":["/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { AuthorizationCodeClient, ClientConfiguration } from \"@azure/msal-common\";\r\n\r\nexport class HybridSpaAuthorizationCodeClient extends AuthorizationCodeClient {\r\n constructor(config: ClientConfiguration) {\r\n super(config);\r\n this.includeRedirectUri = false;\r\n }\r\n}\r\n"],"names":[],"mappings":";;;;;AAAA;;;;;IAOsD,oDAAuB;IACzE,0CAAY,MAA2B;QAAvC,YACI,kBAAM,MAAM,CAAC,SAEhB;QADG,KAAI,CAAC,kBAAkB,GAAG,KAAK,CAAC;;KACnC;IACL,uCAAC;AAAD,CALA,CAAsD,uBAAuB;;;;"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { AuthenticationResult, Logger, ICrypto, IPerformanceClient } from "@azure/msal-common";
|
|
2
|
+
import { BaseInteractionClient } from "./BaseInteractionClient";
|
|
3
|
+
import { BrowserConfiguration } from "../config/Configuration";
|
|
4
|
+
import { BrowserCacheManager } from "../cache/BrowserCacheManager";
|
|
5
|
+
import { EventHandler } from "../event/EventHandler";
|
|
6
|
+
import { PopupRequest } from "../request/PopupRequest";
|
|
7
|
+
import { SilentRequest } from "../request/SilentRequest";
|
|
8
|
+
import { SsoSilentRequest } from "../request/SsoSilentRequest";
|
|
9
|
+
import { NativeMessageHandler } from "../broker/nativeBroker/NativeMessageHandler";
|
|
10
|
+
import { ApiId } from "../utils/BrowserConstants";
|
|
11
|
+
import { NativeTokenRequest } from "../broker/nativeBroker/NativeRequest";
|
|
12
|
+
import { NativeResponse } from "../broker/nativeBroker/NativeResponse";
|
|
13
|
+
import { RedirectRequest } from "../request/RedirectRequest";
|
|
14
|
+
import { INavigationClient } from "../navigation/INavigationClient";
|
|
15
|
+
export declare class NativeInteractionClient extends BaseInteractionClient {
|
|
16
|
+
protected apiId: ApiId;
|
|
17
|
+
protected accountId: string;
|
|
18
|
+
protected nativeMessageHandler: NativeMessageHandler;
|
|
19
|
+
constructor(config: BrowserConfiguration, browserStorage: BrowserCacheManager, browserCrypto: ICrypto, logger: Logger, eventHandler: EventHandler, navigationClient: INavigationClient, apiId: ApiId, performanceClient: IPerformanceClient, provider: NativeMessageHandler, accountId: string, correlationId?: string);
|
|
20
|
+
/**
|
|
21
|
+
* Acquire token from native platform via browser extension
|
|
22
|
+
* @param request
|
|
23
|
+
*/
|
|
24
|
+
acquireToken(request: PopupRequest | SilentRequest | SsoSilentRequest): Promise<AuthenticationResult>;
|
|
25
|
+
/**
|
|
26
|
+
* Acquires a token from native platform then redirects to the redirectUri instead of returning the response
|
|
27
|
+
* @param request
|
|
28
|
+
*/
|
|
29
|
+
acquireTokenRedirect(request: RedirectRequest): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* If the previous page called native platform for a token using redirect APIs, send the same request again and return the response
|
|
32
|
+
*/
|
|
33
|
+
handleRedirectPromise(): Promise<AuthenticationResult | null>;
|
|
34
|
+
/**
|
|
35
|
+
* Logout from native platform via browser extension
|
|
36
|
+
* @param request
|
|
37
|
+
*/
|
|
38
|
+
logout(): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Transform response from native platform into AuthenticationResult object which will be returned to the end user
|
|
41
|
+
* @param response
|
|
42
|
+
* @param request
|
|
43
|
+
* @param reqTimestamp
|
|
44
|
+
*/
|
|
45
|
+
protected handleNativeResponse(response: NativeResponse, request: NativeTokenRequest, reqTimestamp: number): Promise<AuthenticationResult>;
|
|
46
|
+
/**
|
|
47
|
+
* Validates native platform response before processing
|
|
48
|
+
* @param response
|
|
49
|
+
*/
|
|
50
|
+
private validateNativeResponse;
|
|
51
|
+
/**
|
|
52
|
+
* Translates developer provided request object into NativeRequest object
|
|
53
|
+
* @param request
|
|
54
|
+
*/
|
|
55
|
+
protected initializeNativeRequest(request: PopupRequest | SsoSilentRequest): Promise<NativeTokenRequest>;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=NativeInteractionClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NativeInteractionClient.d.ts","sourceRoot":"","sources":["../../src/interaction_client/NativeInteractionClient.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,oBAAoB,EAAE,MAAM,EAAE,OAAO,EAA8L,kBAAkB,EAAqB,MAAM,oBAAoB,CAAC;AAC9S,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,6CAA6C,CAAC;AACnF,OAAO,EAAyB,KAAK,EAAsB,MAAM,2BAA2B,CAAC;AAC7F,OAAO,EAA8B,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AACtG,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAEvE,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAGpE,qBAAa,uBAAwB,S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, PerformanceEvents, AuthenticationScheme, PopTokenGenerator, AccountEntity, Constants, AuthorityType, ScopeSet, AuthToken, PromptValue, UrlString, OIDC_DEFAULT_SCOPES } from '@azure/msal-common';
|
|
5
|
+
import { BaseInteractionClient } from './BaseInteractionClient.js';
|
|
6
|
+
import { TemporaryCacheKeys, NativeExtensionMethod, ApiId } from '../utils/BrowserConstants.js';
|
|
7
|
+
import { NativeAuthError } from '../error/NativeAuthError.js';
|
|
8
|
+
import { BrowserAuthError } from '../error/BrowserAuthError.js';
|
|
9
|
+
|
|
10
|
+
/*
|
|
11
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
12
|
+
* Licensed under the MIT License.
|
|
13
|
+
*/
|
|
14
|
+
var NativeInteractionClient = /** @class */ (function (_super) {
|
|
15
|
+
__extends(NativeInteractionClient, _super);
|
|
16
|
+
function NativeInteractionClient(config, browserStorage, browserCrypto, logger, eventHandler, navigationClient, apiId, performanceClient, provider, accountId, correlationId) {
|
|
17
|
+
var _this = _super.call(this, config, browserStorage, browserCrypto, logger, eventHandler, navigationClient, performanceClient, provider, correlationId) || this;
|
|
18
|
+
_this.apiId = apiId;
|
|
19
|
+
_this.accountId = accountId;
|
|
20
|
+
_this.nativeMessageHandler = provider;
|
|
21
|
+
return _this;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Acquire token from native platform via browser extension
|
|
25
|
+
* @param request
|
|
26
|
+
*/
|
|
27
|
+
NativeInteractionClient.prototype.acquireToken = function (request) {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
29
|
+
var nativeATMeasurement, nativeRequest, messageBody, reqTimestamp, response, validatedResponse;
|
|
30
|
+
return __generator(this, function (_a) {
|
|
31
|
+
switch (_a.label) {
|
|
32
|
+
case 0:
|
|
33
|
+
this.logger.trace("NativeInteractionClient - acquireToken called.");
|
|
34
|
+
nativeATMeasurement = this.performanceClient.startMeasurement(PerformanceEvents.NativeInteractionClientAcquireToken, request.correlationId);
|
|
35
|
+
return [4 /*yield*/, this.initializeNativeRequest(request)];
|
|
36
|
+
case 1:
|
|
37
|
+
nativeRequest = _a.sent();
|
|
38
|
+
messageBody = {
|
|
39
|
+
method: NativeExtensionMethod.GetToken,
|
|
40
|
+
request: nativeRequest
|
|
41
|
+
};
|
|
42
|
+
reqTimestamp = TimeUtils.nowSeconds();
|
|
43
|
+
return [4 /*yield*/, this.nativeMessageHandler.sendMessage(messageBody)];
|
|
44
|
+
case 2:
|
|
45
|
+
response = _a.sent();
|
|
46
|
+
validatedResponse = this.validateNativeResponse(response);
|
|
47
|
+
return [2 /*return*/, this.handleNativeResponse(validatedResponse, nativeRequest, reqTimestamp)
|
|
48
|
+
.then(function (result) {
|
|
49
|
+
nativeATMeasurement.endMeasurement({
|
|
50
|
+
success: true,
|
|
51
|
+
isNativeBroker: true
|
|
52
|
+
});
|
|
53
|
+
return result;
|
|
54
|
+
})
|
|
55
|
+
.catch(function (error) {
|
|
56
|
+
nativeATMeasurement.endMeasurement({
|
|
57
|
+
success: false,
|
|
58
|
+
isNativeBroker: true
|
|
59
|
+
});
|
|
60
|
+
throw error;
|
|
61
|
+
})];
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Acquires a token from native platform then redirects to the redirectUri instead of returning the response
|
|
68
|
+
* @param request
|
|
69
|
+
*/
|
|
70
|
+
NativeInteractionClient.prototype.acquireTokenRedirect = function (request) {
|
|
71
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
72
|
+
var nativeRequest, messageBody, response, e_1, navigationOptions, redirectUri;
|
|
73
|
+
return __generator(this, function (_a) {
|
|
74
|
+
switch (_a.label) {
|
|
75
|
+
case 0:
|
|
76
|
+
this.logger.trace("NativeInteractionClient - acquireTokenRedirect called.");
|
|
77
|
+
return [4 /*yield*/, this.initializeNativeRequest(request)];
|
|
78
|
+
case 1:
|
|
79
|
+
nativeRequest = _a.sent();
|
|
80
|
+
messageBody = {
|
|
81
|
+
method: NativeExtensionMethod.GetToken,
|
|
82
|
+
request: nativeRequest
|
|
83
|
+
};
|
|
84
|
+
_a.label = 2;
|
|
85
|
+
case 2:
|
|
86
|
+
_a.trys.push([2, 4, , 5]);
|
|
87
|
+
return [4 /*yield*/, this.nativeMessageHandler.sendMessage(messageBody)];
|
|
88
|
+
case 3:
|
|
89
|
+
response = _a.sent();
|
|
90
|
+
this.validateNativeResponse(response);
|
|
91
|
+
return [3 /*break*/, 5];
|
|
92
|
+
case 4:
|
|
93
|
+
e_1 = _a.sent();
|
|
94
|
+
// Only throw fatal errors here to allow application to fallback to regular redirect. Otherwise proceed and the error will be thrown in handleRedirectPromise
|
|
95
|
+
if (e_1 instanceof NativeAuthError && e_1.isFatal()) {
|
|
96
|
+
throw e_1;
|
|
97
|
+
}
|
|
98
|
+
return [3 /*break*/, 5];
|
|
99
|
+
case 5:
|
|
100
|
+
this.browserStorage.setTemporaryCache(TemporaryCacheKeys.NATIVE_REQUEST, JSON.stringify(nativeRequest), true);
|
|
101
|
+
navigationOptions = {
|
|
102
|
+
apiId: ApiId.acquireTokenRedirect,
|
|
103
|
+
timeout: this.config.system.redirectNavigationTimeout,
|
|
104
|
+
noHistory: false
|
|
105
|
+
};
|
|
106
|
+
redirectUri = this.config.auth.navigateToLoginRequestUrl ? window.location.href : this.getRedirectUri(request.redirectUri);
|
|
107
|
+
return [4 /*yield*/, this.navigationClient.navigateExternal(redirectUri, navigationOptions)];
|
|
108
|
+
case 6:
|
|
109
|
+
_a.sent(); // Need to treat this as external to ensure handleRedirectPromise is run again
|
|
110
|
+
return [2 /*return*/];
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* If the previous page called native platform for a token using redirect APIs, send the same request again and return the response
|
|
117
|
+
*/
|
|
118
|
+
NativeInteractionClient.prototype.handleRedirectPromise = function () {
|
|
119
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
120
|
+
var cachedRequest, messageBody, reqTimestamp, response, result, e_2;
|
|
121
|
+
return __generator(this, function (_a) {
|
|
122
|
+
switch (_a.label) {
|
|
123
|
+
case 0:
|
|
124
|
+
this.logger.trace("NativeInteractionClient - handleRedirectPromise called.");
|
|
125
|
+
if (!this.browserStorage.isInteractionInProgress(true)) {
|
|
126
|
+
this.logger.info("handleRedirectPromise called but there is no interaction in progress, returning null.");
|
|
127
|
+
return [2 /*return*/, null];
|
|
128
|
+
}
|
|
129
|
+
cachedRequest = this.browserStorage.getCachedNativeRequest();
|
|
130
|
+
if (!cachedRequest) {
|
|
131
|
+
this.logger.verbose("NativeInteractionClient - handleRedirectPromise called but there is no cached request, returning null.");
|
|
132
|
+
return [2 /*return*/, null];
|
|
133
|
+
}
|
|
134
|
+
this.browserStorage.removeItem(this.browserStorage.generateCacheKey(TemporaryCacheKeys.NATIVE_REQUEST));
|
|
135
|
+
messageBody = {
|
|
136
|
+
method: NativeExtensionMethod.GetToken,
|
|
137
|
+
request: cachedRequest
|
|
138
|
+
};
|
|
139
|
+
reqTimestamp = TimeUtils.nowSeconds();
|
|
140
|
+
_a.label = 1;
|
|
141
|
+
case 1:
|
|
142
|
+
_a.trys.push([1, 3, , 4]);
|
|
143
|
+
this.logger.verbose("NativeInteractionClient - handleRedirectPromise sending message to native broker.");
|
|
144
|
+
return [4 /*yield*/, this.nativeMessageHandler.sendMessage(messageBody)];
|
|
145
|
+
case 2:
|
|
146
|
+
response = _a.sent();
|
|
147
|
+
this.validateNativeResponse(response);
|
|
148
|
+
result = this.handleNativeResponse(response, cachedRequest, reqTimestamp);
|
|
149
|
+
this.browserStorage.setInteractionInProgress(false);
|
|
150
|
+
return [2 /*return*/, result];
|
|
151
|
+
case 3:
|
|
152
|
+
e_2 = _a.sent();
|
|
153
|
+
this.browserStorage.setInteractionInProgress(false);
|
|
154
|
+
throw e_2;
|
|
155
|
+
case 4: return [2 /*return*/];
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
};
|
|
160
|
+
/**
|
|
161
|
+
* Logout from native platform via browser extension
|
|
162
|
+
* @param request
|
|
163
|
+
*/
|
|
164
|
+
NativeInteractionClient.prototype.logout = function () {
|
|
165
|
+
this.logger.trace("NativeInteractionClient - logout called.");
|
|
166
|
+
return Promise.reject("Logout not implemented yet");
|
|
167
|
+
};
|
|
168
|
+
/**
|
|
169
|
+
* Transform response from native platform into AuthenticationResult object which will be returned to the end user
|
|
170
|
+
* @param response
|
|
171
|
+
* @param request
|
|
172
|
+
* @param reqTimestamp
|
|
173
|
+
*/
|
|
174
|
+
NativeInteractionClient.prototype.handleNativeResponse = function (response, request, reqTimestamp) {
|
|
175
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
176
|
+
var idTokenObj, authority, authorityPreferredCache, homeAccountIdentifier, accountEntity, responseScopes, accountProperties, uid, tid, responseAccessToken, responseTokenType, _a, popTokenGenerator, shrParameters, result;
|
|
177
|
+
var _this = this;
|
|
178
|
+
return __generator(this, function (_b) {
|
|
179
|
+
switch (_b.label) {
|
|
180
|
+
case 0:
|
|
181
|
+
this.logger.trace("NativeInteractionClient - handleNativeResponse called.");
|
|
182
|
+
if (response.account.id !== request.accountId) {
|
|
183
|
+
// User switch in native broker prompt is not supported. All users must first sign in through web flow to ensure server state is in sync
|
|
184
|
+
throw NativeAuthError.createUserSwitchError();
|
|
185
|
+
}
|
|
186
|
+
idTokenObj = new AuthToken(response.id_token || Constants.EMPTY_STRING, this.browserCrypto);
|
|
187
|
+
return [4 /*yield*/, this.getDiscoveredAuthority(request.authority)];
|
|
188
|
+
case 1:
|
|
189
|
+
authority = _b.sent();
|
|
190
|
+
authorityPreferredCache = authority.getPreferredCache();
|
|
191
|
+
homeAccountIdentifier = AccountEntity.generateHomeAccountId(response.client_info || Constants.EMPTY_STRING, AuthorityType.Default, this.logger, this.browserCrypto, idTokenObj);
|
|
192
|
+
accountEntity = AccountEntity.createAccount(response.client_info, homeAccountIdentifier, idTokenObj, undefined, undefined, undefined, undefined, authorityPreferredCache, response.account.id);
|
|
193
|
+
this.browserStorage.setAccount(accountEntity);
|
|
194
|
+
responseScopes = response.scopes ? ScopeSet.fromString(response.scopes) : ScopeSet.fromString(request.scopes);
|
|
195
|
+
accountProperties = response.account.properties || {};
|
|
196
|
+
uid = accountProperties["UID"] || idTokenObj.claims.oid || idTokenObj.claims.sub || Constants.EMPTY_STRING;
|
|
197
|
+
tid = accountProperties["TenantId"] || idTokenObj.claims.tid || Constants.EMPTY_STRING;
|
|
198
|
+
responseTokenType = AuthenticationScheme.BEARER;
|
|
199
|
+
_a = request.token_type;
|
|
200
|
+
switch (_a) {
|
|
201
|
+
case AuthenticationScheme.POP: return [3 /*break*/, 2];
|
|
202
|
+
}
|
|
203
|
+
return [3 /*break*/, 4];
|
|
204
|
+
case 2:
|
|
205
|
+
// Set the token type to POP in the response
|
|
206
|
+
responseTokenType = AuthenticationScheme.POP;
|
|
207
|
+
// Check if native layer returned an SHR token
|
|
208
|
+
if (response.shr) {
|
|
209
|
+
this.logger.trace("handleNativeServerResponse: SHR is enabled in native layer");
|
|
210
|
+
responseAccessToken = response.shr;
|
|
211
|
+
return [3 /*break*/, 5];
|
|
212
|
+
}
|
|
213
|
+
popTokenGenerator = new PopTokenGenerator(this.browserCrypto);
|
|
214
|
+
shrParameters = {
|
|
215
|
+
resourceRequestMethod: request.resourceRequestMethod,
|
|
216
|
+
resourceRequestUri: request.resourceRequestUri,
|
|
217
|
+
shrClaims: request.shrClaims,
|
|
218
|
+
shrNonce: request.shrNonce
|
|
219
|
+
};
|
|
220
|
+
return [4 /*yield*/, popTokenGenerator.signPopToken(response.access_token, shrParameters)];
|
|
221
|
+
case 3:
|
|
222
|
+
responseAccessToken = _b.sent();
|
|
223
|
+
return [3 /*break*/, 5];
|
|
224
|
+
case 4:
|
|
225
|
+
{
|
|
226
|
+
responseAccessToken = response.access_token;
|
|
227
|
+
}
|
|
228
|
+
_b.label = 5;
|
|
229
|
+
case 5:
|
|
230
|
+
result = {
|
|
231
|
+
authority: authority.canonicalAuthority,
|
|
232
|
+
uniqueId: uid,
|
|
233
|
+
tenantId: tid,
|
|
234
|
+
scopes: responseScopes.asArray(),
|
|
235
|
+
account: accountEntity.getAccountInfo(),
|
|
236
|
+
idToken: response.id_token,
|
|
237
|
+
idTokenClaims: idTokenObj.claims,
|
|
238
|
+
accessToken: responseAccessToken,
|
|
239
|
+
fromCache: false,
|
|
240
|
+
expiresOn: new Date(Number(reqTimestamp + response.expires_in) * 1000),
|
|
241
|
+
tokenType: responseTokenType,
|
|
242
|
+
correlationId: this.correlationId,
|
|
243
|
+
state: response.state,
|
|
244
|
+
fromNativeBroker: true
|
|
245
|
+
};
|
|
246
|
+
// Remove any existing cached tokens for this account
|
|
247
|
+
this.browserStorage.removeAccountContext(accountEntity).catch(function (e) {
|
|
248
|
+
_this.logger.error("Error occurred while removing account context from browser storage. " + e);
|
|
249
|
+
});
|
|
250
|
+
return [2 /*return*/, result];
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
});
|
|
254
|
+
};
|
|
255
|
+
/**
|
|
256
|
+
* Validates native platform response before processing
|
|
257
|
+
* @param response
|
|
258
|
+
*/
|
|
259
|
+
NativeInteractionClient.prototype.validateNativeResponse = function (response) {
|
|
260
|
+
if (response.hasOwnProperty("access_token") &&
|
|
261
|
+
response.hasOwnProperty("id_token") &&
|
|
262
|
+
response.hasOwnProperty("client_info") &&
|
|
263
|
+
response.hasOwnProperty("account") &&
|
|
264
|
+
response.hasOwnProperty("scopes") &&
|
|
265
|
+
response.hasOwnProperty("expires_in")) {
|
|
266
|
+
return response;
|
|
267
|
+
}
|
|
268
|
+
else {
|
|
269
|
+
throw NativeAuthError.createUnexpectedError("Response missing expected properties.");
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
/**
|
|
273
|
+
* Translates developer provided request object into NativeRequest object
|
|
274
|
+
* @param request
|
|
275
|
+
*/
|
|
276
|
+
NativeInteractionClient.prototype.initializeNativeRequest = function (request) {
|
|
277
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
278
|
+
var authority, canonicalAuthority, scopes, scopeSet, instanceAware, validatedRequest, shrParameters, popTokenGenerator, cnf, _a;
|
|
279
|
+
return __generator(this, function (_b) {
|
|
280
|
+
switch (_b.label) {
|
|
281
|
+
case 0:
|
|
282
|
+
this.logger.trace("NativeInteractionClient - initializeNativeRequest called");
|
|
283
|
+
authority = request.authority || this.config.auth.authority;
|
|
284
|
+
canonicalAuthority = new UrlString(authority);
|
|
285
|
+
canonicalAuthority.validateAsUri();
|
|
286
|
+
scopes = request && request.scopes || [];
|
|
287
|
+
scopeSet = new ScopeSet(scopes);
|
|
288
|
+
scopeSet.appendScopes(OIDC_DEFAULT_SCOPES);
|
|
289
|
+
if (request.prompt) {
|
|
290
|
+
switch (request.prompt) {
|
|
291
|
+
case PromptValue.NONE:
|
|
292
|
+
case PromptValue.CONSENT:
|
|
293
|
+
this.logger.trace("initializeNativeRequest: prompt is compatible with native flow");
|
|
294
|
+
break;
|
|
295
|
+
default:
|
|
296
|
+
this.logger.trace("initializeNativeRequest: prompt = " + request.prompt + " is not compatible with native flow");
|
|
297
|
+
throw BrowserAuthError.createNativePromptParameterNotSupportedError();
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
instanceAware = !!(request.extraQueryParameters && request.extraQueryParameters.instance_aware);
|
|
301
|
+
validatedRequest = __assign(__assign({}, request), { accountId: this.accountId, clientId: this.config.auth.clientId, authority: canonicalAuthority.urlString, scopes: scopeSet.printScopes(), redirectUri: this.getRedirectUri(request.redirectUri), correlationId: this.correlationId, instance_aware: instanceAware, token_type: request.authenticationScheme, extraParameters: __assign(__assign({}, request.extraQueryParameters), request.tokenQueryParameters), extendedExpiryToken: false // Make this configurable?
|
|
302
|
+
});
|
|
303
|
+
if (!(request.authenticationScheme === AuthenticationScheme.POP)) return [3 /*break*/, 3];
|
|
304
|
+
shrParameters = {
|
|
305
|
+
resourceRequestUri: request.resourceRequestUri,
|
|
306
|
+
resourceRequestMethod: request.resourceRequestMethod,
|
|
307
|
+
shrClaims: request.shrClaims,
|
|
308
|
+
shrNonce: request.shrNonce
|
|
309
|
+
};
|
|
310
|
+
popTokenGenerator = new PopTokenGenerator(this.browserCrypto);
|
|
311
|
+
return [4 /*yield*/, popTokenGenerator.generateCnf(shrParameters)];
|
|
312
|
+
case 1:
|
|
313
|
+
cnf = _b.sent();
|
|
314
|
+
// to reduce the URL length, it is recommended to send the hash of the req_cnf instead of the whole string
|
|
315
|
+
_a = validatedRequest;
|
|
316
|
+
return [4 /*yield*/, popTokenGenerator.generateCnfHash(cnf)];
|
|
317
|
+
case 2:
|
|
318
|
+
// to reduce the URL length, it is recommended to send the hash of the req_cnf instead of the whole string
|
|
319
|
+
_a.req_cnf = _b.sent();
|
|
320
|
+
_b.label = 3;
|
|
321
|
+
case 3:
|
|
322
|
+
if (this.apiId === ApiId.ssoSilent || this.apiId === ApiId.acquireTokenSilent_silentFlow) {
|
|
323
|
+
validatedRequest.prompt = PromptValue.NONE;
|
|
324
|
+
}
|
|
325
|
+
return [2 /*return*/, validatedRequest];
|
|
326
|
+
}
|
|
327
|
+
});
|
|
328
|
+
});
|
|
329
|
+
};
|
|
330
|
+
return NativeInteractionClient;
|
|
331
|
+
}(BaseInteractionClient));
|
|
332
|
+
|
|
333
|
+
export { NativeInteractionClient };
|
|
334
|
+
//# sourceMappingURL=NativeInteractionClient.js.map
|