daftari 3.13.1 → 3.14.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/CHANGELOG.md +16 -0
- package/dist/distill/propose.d.ts.map +1 -1
- package/dist/distill/propose.js +10 -3
- package/dist/distill/propose.js.map +1 -1
- package/dist/extract/index.d.ts +16 -0
- package/dist/extract/index.d.ts.map +1 -0
- package/dist/extract/index.js +95 -0
- package/dist/extract/index.js.map +1 -0
- package/dist/extract/normalize.d.ts +7 -0
- package/dist/extract/normalize.d.ts.map +1 -0
- package/dist/extract/normalize.js +52 -0
- package/dist/extract/normalize.js.map +1 -0
- package/dist/extract/office.d.ts +63 -0
- package/dist/extract/office.d.ts.map +1 -0
- package/dist/extract/office.js +763 -0
- package/dist/extract/office.js.map +1 -0
- package/dist/extract/pdf.d.ts +16 -0
- package/dist/extract/pdf.d.ts.map +1 -0
- package/dist/extract/pdf.js +196 -0
- package/dist/extract/pdf.js.map +1 -0
- package/dist/extract/types.d.ts +55 -0
- package/dist/extract/types.d.ts.map +1 -0
- package/dist/extract/types.js +47 -0
- package/dist/extract/types.js.map +1 -0
- package/dist/extract/worker.d.ts +2 -0
- package/dist/extract/worker.d.ts.map +1 -0
- package/dist/extract/worker.js +57 -0
- package/dist/extract/worker.js.map +1 -0
- package/dist/integrations/engine.d.ts +174 -3
- package/dist/integrations/engine.d.ts.map +1 -1
- package/dist/integrations/engine.js +184 -16
- package/dist/integrations/engine.js.map +1 -1
- package/dist/integrations/google.d.ts +2 -1
- package/dist/integrations/google.d.ts.map +1 -1
- package/dist/integrations/google.js +12 -117
- package/dist/integrations/google.js.map +1 -1
- package/dist/integrations/http-json.d.ts +27 -0
- package/dist/integrations/http-json.d.ts.map +1 -0
- package/dist/integrations/http-json.js +148 -0
- package/dist/integrations/http-json.js.map +1 -0
- package/dist/integrations/microsoft.d.ts +22 -0
- package/dist/integrations/microsoft.d.ts.map +1 -0
- package/dist/integrations/microsoft.js +1780 -0
- package/dist/integrations/microsoft.js.map +1 -0
- package/dist/integrations/microsoft.ui.d.ts +18 -0
- package/dist/integrations/microsoft.ui.d.ts.map +1 -0
- package/dist/integrations/microsoft.ui.js +131 -0
- package/dist/integrations/microsoft.ui.js.map +1 -0
- package/dist/integrations/oauth.d.ts.map +1 -1
- package/dist/integrations/oauth.js +10 -2
- package/dist/integrations/oauth.js.map +1 -1
- package/dist/integrations/queue.d.ts +1 -1
- package/dist/integrations/queue.d.ts.map +1 -1
- package/dist/integrations/queue.js +23 -1
- package/dist/integrations/queue.js.map +1 -1
- package/dist/integrations/routes.d.ts +26 -0
- package/dist/integrations/routes.d.ts.map +1 -1
- package/dist/integrations/routes.js +502 -8
- package/dist/integrations/routes.js.map +1 -1
- package/dist/integrations/runtime.d.ts +14 -2
- package/dist/integrations/runtime.d.ts.map +1 -1
- package/dist/integrations/runtime.js +39 -7
- package/dist/integrations/runtime.js.map +1 -1
- package/dist/integrations/state.d.ts +1 -1
- package/dist/integrations/state.d.ts.map +1 -1
- package/dist/integrations/state.js +48 -8
- package/dist/integrations/state.js.map +1 -1
- package/dist/integrations/types.d.ts +54 -3
- package/dist/integrations/types.d.ts.map +1 -1
- package/dist/integrations/types.js +21 -1
- package/dist/integrations/types.js.map +1 -1
- package/dist/search/watcher.d.ts.map +1 -1
- package/dist/search/watcher.js +3 -22
- package/dist/search/watcher.js.map +1 -1
- package/dist/serve/index.d.ts.map +1 -1
- package/dist/serve/index.js +7 -0
- package/dist/serve/index.js.map +1 -1
- package/dist/sleep/index.js +2 -2
- package/dist/sleep/report.js +1 -1
- package/dist/sleep/report.js.map +1 -1
- package/dist/sleep/tension-scan.d.ts.map +1 -1
- package/dist/sleep/tension-scan.js +0 -0
- package/dist/sleep/tension-scan.js.map +1 -1
- package/dist/storage/local.d.ts +1 -0
- package/dist/storage/local.d.ts.map +1 -1
- package/dist/storage/local.js +8 -1
- package/dist/storage/local.js.map +1 -1
- package/dist/utils/config.d.ts +8 -1
- package/dist/utils/config.d.ts.map +1 -1
- package/dist/utils/config.js +143 -19
- package/dist/utils/config.js.map +1 -1
- package/dist/view/pages.d.ts.map +1 -1
- package/dist/view/pages.js +11 -0
- package/dist/view/pages.js.map +1 -1
- package/dist/view/render.d.ts.map +1 -1
- package/dist/view/render.js +37 -2
- package/dist/view/render.js.map +1 -1
- package/package.json +8 -3
- package/src/integrations/microsoft/assets/VENDORING.md +109 -0
- package/src/integrations/microsoft/assets/glue.js +244 -0
- package/src/integrations/microsoft/assets/picker-serializer.js +99 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/app/IPublicClientApplication.mjs +91 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/app/PublicClientApplication.mjs +355 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/broker/nativeBroker/NativeStatusCodes.mjs +15 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/broker/nativeBroker/PlatformAuthDOMHandler.mjs +153 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/broker/nativeBroker/PlatformAuthExtensionHandler.mjs +271 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/broker/nativeBroker/PlatformAuthProvider.mjs +95 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/cache/AccountManager.mjs +49 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/cache/AsyncMemoryStorage.mjs +144 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/cache/BrowserCacheManager.mjs +1465 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/cache/CacheHelpers.mjs +45 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/cache/CacheKeys.mjs +32 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/cache/CookieStorage.mjs +94 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/cache/DatabaseStorage.mjs +208 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/cache/EncryptedData.mjs +13 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/cache/LocalStorage.mjs +319 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/cache/MemoryStorage.mjs +48 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/cache/SessionStorage.mjs +46 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/cache/TokenCache.mjs +220 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/config/Configuration.mjs +138 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/controllers/NestedAppAuthController.mjs +483 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/controllers/StandardController.mjs +1532 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/crypto/BrowserCrypto.mjs +354 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/crypto/CryptoOps.mjs +146 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/crypto/PkceGenerator.mjs +63 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/crypto/SignedHttpRequest.mjs +50 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/crypto/TokenBindingKeyManager.mjs +156 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/encode/Base64Decode.mjs +43 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/encode/Base64Encode.mjs +47 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/error/BrowserAuthError.mjs +26 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/error/BrowserAuthErrorCodes.mjs +65 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/error/BrowserConfigurationAuthError.mjs +24 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/error/BrowserConfigurationAuthErrorCodes.mjs +11 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/error/NativeAuthError.mjs +79 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/error/NativeAuthErrorCodes.mjs +12 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/error/NestedAppAuthError.mjs +25 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/event/EventHandler.mjs +110 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/event/EventMessage.mjs +60 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/event/EventType.mjs +30 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/index.mjs +48 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/interaction_client/BaseInteractionClient.mjs +150 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/interaction_client/HybridSpaAuthorizationCodeClient.mjs +16 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/interaction_client/PlatformAuthInteractionClient.mjs +734 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/interaction_client/PopupClient.mjs +528 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/interaction_client/RedirectClient.mjs +464 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/interaction_client/SilentAuthCodeClient.mjs +85 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/interaction_client/SilentCacheClient.mjs +58 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/interaction_client/SilentIframeClient.mjs +255 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/interaction_client/SilentRefreshClient.mjs +77 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/interaction_client/StandardInteractionClient.mjs +217 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/interaction_handler/InteractionHandler.mjs +95 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/interaction_handler/SilentHandler.mjs +71 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/naa/BridgeError.mjs +11 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/naa/BridgeProxy.mjs +152 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/naa/BridgeStatusCode.mjs +18 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/naa/mapping/NestedAppAuthAdapter.mjs +239 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/navigation/NavigationClient.mjs +47 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/network/FetchClient.mjs +153 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/operatingcontext/BaseOperatingContext.mjs +112 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/operatingcontext/NestedAppOperatingContext.mjs +79 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/operatingcontext/StandardOperatingContext.mjs +50 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/packageMetadata.mjs +7 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/popup_relay/constants.mjs +20 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/popup_relay/relayClient.mjs +113 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/protocol/Authorize.mjs +326 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/request/RequestHelpers.mjs +143 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/response/ResponseHandler.mjs +45 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/telemetry/BrowserPerformanceClient.mjs +126 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/telemetry/BrowserPerformanceEvents.mjs +133 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/telemetry/BrowserPerformanceMeasurement.mjs +96 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/telemetry/BrowserRootPerformanceEvents.mjs +53 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/utils/BrowserConstants.mjs +220 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/utils/BrowserProtocolUtils.mjs +27 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/utils/BrowserUtils.mjs +364 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/utils/Helpers.mjs +19 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/utils/MsalFrameStatsUtils.mjs +38 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/webBrokerBridge/PendingRequestRegistry.mjs +63 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/webBrokerBridge/WebBrokerBridgeError.mjs +38 -0
- package/src/integrations/microsoft/assets/vendor/msal-browser/webBrokerBridge/WebBrokerBridgeErrorMap.mjs +57 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/account/AccountInfo.mjs +91 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/account/AuthToken.mjs +70 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/account/CcsCredential.mjs +12 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/account/ClientInfo.mjs +43 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/account/TokenClaims.mjs +24 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/authority/Authority.mjs +988 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/authority/AuthorityFactory.mjs +41 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/authority/AuthorityMetadata.mjs +158 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/authority/AuthorityOptions.mjs +20 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/authority/AuthorityType.mjs +16 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/authority/CloudInstanceDiscoveryErrorResponse.mjs +12 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/authority/CloudInstanceDiscoveryResponse.mjs +12 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/authority/OpenIdConfigResponse.mjs +14 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/authority/ProtocolMode.mjs +26 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/authority/RegionDiscovery.mjs +116 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/cache/CacheManager.mjs +1202 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/cache/persistence/TokenCacheContext.mjs +29 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/cache/utils/AccountEntityUtils.mjs +222 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/cache/utils/CacheHelpers.mjs +294 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/client/AuthorizationCodeClient.mjs +289 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/client/RefreshTokenClient.mjs +262 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/client/SilentFlowClient.mjs +142 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/config/ClientConfiguration.mjs +111 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/constants/AADServerParamKeys.mjs +74 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/crypto/DpopProofGenerator.mjs +152 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/crypto/ICrypto.mjs +52 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/crypto/ITokenBindingKeyManager.mjs +27 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/crypto/JoseHeader.mjs +72 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/crypto/PopTokenGenerator.mjs +109 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/error/AuthError.mjs +31 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/error/AuthErrorCodes.mjs +13 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/error/CacheError.mjs +44 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/error/CacheErrorCodes.mjs +10 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/error/ClientAuthError.mjs +26 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/error/ClientAuthErrorCodes.mjs +46 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/error/ClientConfigurationError.mjs +23 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/error/ClientConfigurationErrorCodes.mjs +38 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/error/InteractionRequiredAuthError.mjs +73 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/error/InteractionRequiredAuthErrorCodes.mjs +53 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/error/JoseHeaderError.mjs +24 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/error/JoseHeaderErrorCodes.mjs +12 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/error/NetworkError.mjs +34 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/error/PlatformBrokerError.mjs +48 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/error/ServerError.mjs +22 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/index-browser.mjs +79 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/logger/Logger.mjs +291 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/network/INetworkModule.mjs +20 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/network/RequestThumbprint.mjs +27 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/network/ThrottlingUtils.mjs +91 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/packageMetadata.mjs +7 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/protocol/Authorize.mjs +239 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/protocol/Token.mjs +148 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/request/AuthenticationHeaderParser.mjs +63 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/request/BaseAuthRequest.mjs +37 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/request/RequestParameterBuilder.mjs +529 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/request/ScopeSet.mjs +204 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/response/ResponseHandler.mjs +432 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/telemetry/performance/PerformanceClient.mjs +557 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/telemetry/performance/PerformanceEvent.mjs +68 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/telemetry/performance/PerformanceEvents.mjs +73 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/telemetry/performance/StubPerformanceClient.mjs +61 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/telemetry/server/ServerTelemetryManager.mjs +297 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/url/UrlString.mjs +164 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/utils/ClientAssertionUtils.mjs +21 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/utils/Constants.mjs +304 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/utils/FunctionWrappers.mjs +95 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/utils/ObjectUtils.mjs +27 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/utils/ProtocolUtils.mjs +76 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/utils/StringUtils.mjs +82 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/utils/TimeUtils.mjs +75 -0
- package/src/integrations/microsoft/assets/vendor/msal-common/utils/UrlUtils.mjs +128 -0
|
@@ -0,0 +1,734 @@
|
|
|
1
|
+
/*! @azure/msal-browser v5.20.0 2026-08-28 */
|
|
2
|
+
'use strict';
|
|
3
|
+
import { ServerTelemetryManager, AADServerParamKeys, TimeUtils, AuthError, ScopeSet, createClientAuthError, ClientAuthErrorCodes, AuthToken, updateAccountTenantProfileData, UrlString, buildAccountToCache, AccountEntityUtils, AuthorityType, Constants, PopTokenGenerator, CacheHelpers, RequestParameterBuilder, invokeAsync, PerformanceEvents } from '../../msal-common/index-browser.mjs';
|
|
4
|
+
import { base64Decode } from '../encode/Base64Decode.mjs';
|
|
5
|
+
import { createBrowserAuthError } from '../error/BrowserAuthError.mjs';
|
|
6
|
+
import { NativeAuthError, isFatalNativeAuthError, createNativeAuthError } from '../error/NativeAuthError.mjs';
|
|
7
|
+
import { version } from '../packageMetadata.mjs';
|
|
8
|
+
import { NativeInteractionClientAcquireToken } from '../telemetry/BrowserPerformanceEvents.mjs';
|
|
9
|
+
import { BrowserConstants, CacheLookupPolicy, TemporaryCacheKeys, ApiId, PlatformAuthConstants } from '../utils/BrowserConstants.mjs';
|
|
10
|
+
import { getCurrentUri } from '../utils/BrowserUtils.mjs';
|
|
11
|
+
import { BaseInteractionClient, initializeServerTelemetryManager, getRedirectUri, getDiscoveredAuthority } from './BaseInteractionClient.mjs';
|
|
12
|
+
import { SilentCacheClient } from './SilentCacheClient.mjs';
|
|
13
|
+
import { invalidPopTokenRequest, nativePromptNotSupported } from '../error/BrowserAuthErrorCodes.mjs';
|
|
14
|
+
import { userSwitch } from '../error/NativeAuthErrorCodes.mjs';
|
|
15
|
+
|
|
16
|
+
/*
|
|
17
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
18
|
+
* Licensed under the MIT License.
|
|
19
|
+
*/
|
|
20
|
+
class PlatformAuthInteractionClient extends BaseInteractionClient {
|
|
21
|
+
constructor(config, browserStorage, browserCrypto, logger, eventHandler, navigationClient, apiId, performanceClient, provider, accountId, nativeStorageImpl, correlationId, tokenBindingKeyManager) {
|
|
22
|
+
super(config, browserStorage, browserCrypto, logger, eventHandler, navigationClient, performanceClient, correlationId, provider, tokenBindingKeyManager);
|
|
23
|
+
this.apiId = apiId;
|
|
24
|
+
this.accountId = accountId;
|
|
25
|
+
this.platformAuthProvider = provider;
|
|
26
|
+
this.nativeStorageManager = nativeStorageImpl;
|
|
27
|
+
this.silentCacheClient = new SilentCacheClient(config, this.nativeStorageManager, browserCrypto, logger, eventHandler, navigationClient, performanceClient, correlationId, provider, this.tokenBindingKeyManager);
|
|
28
|
+
const extensionName = this.platformAuthProvider.getExtensionName();
|
|
29
|
+
this.skus = ServerTelemetryManager.makeExtraSkuString({
|
|
30
|
+
libraryName: BrowserConstants.MSAL_SKU,
|
|
31
|
+
libraryVersion: version,
|
|
32
|
+
extensionName: extensionName,
|
|
33
|
+
extensionVersion: this.platformAuthProvider.getExtensionVersion(),
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Adds SKUs to request extra query parameters
|
|
38
|
+
* @param request {PlatformAuthRequest}
|
|
39
|
+
* @private
|
|
40
|
+
*/
|
|
41
|
+
addRequestSKUs(request) {
|
|
42
|
+
request.extraParameters = {
|
|
43
|
+
...request.extraParameters,
|
|
44
|
+
[AADServerParamKeys.X_CLIENT_EXTRA_SKU]: this.skus,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Acquire token from native platform via browser extension
|
|
49
|
+
* @param request
|
|
50
|
+
*/
|
|
51
|
+
async acquireToken(request, cacheLookupPolicy) {
|
|
52
|
+
this.logger.trace("03qeos", this.correlationId);
|
|
53
|
+
// start the perf measurement
|
|
54
|
+
const nativeATMeasurement = this.performanceClient.startMeasurement(NativeInteractionClientAcquireToken, this.correlationId);
|
|
55
|
+
const reqTimestamp = TimeUtils.nowSeconds();
|
|
56
|
+
const serverTelemetryManager = initializeServerTelemetryManager(this.apiId, this.config.auth.clientId, this.correlationId, this.browserStorage, this.logger, undefined, this.config.system.serverTelemetryEnabled);
|
|
57
|
+
// initialize native request (statically builds the request; does not contact the broker)
|
|
58
|
+
let nativeRequest;
|
|
59
|
+
try {
|
|
60
|
+
nativeRequest = await this.initializePlatformRequest(request);
|
|
61
|
+
}
|
|
62
|
+
catch (e) {
|
|
63
|
+
/*
|
|
64
|
+
* Request initialization (e.g. PoP token generation or authority
|
|
65
|
+
* resolution) failed before the broker was contacted, so end the
|
|
66
|
+
* measurement here to avoid an orphaned sub-measurement.
|
|
67
|
+
* Broker was never engaged, so this was not a native broker outcome.
|
|
68
|
+
*/
|
|
69
|
+
nativeATMeasurement.add({
|
|
70
|
+
isNativeBroker: false,
|
|
71
|
+
});
|
|
72
|
+
nativeATMeasurement.end({
|
|
73
|
+
success: false,
|
|
74
|
+
}, e);
|
|
75
|
+
throw e;
|
|
76
|
+
}
|
|
77
|
+
// check if the tokens can be retrieved from internal cache
|
|
78
|
+
try {
|
|
79
|
+
const result = await this.acquireTokensFromCache(this.accountId, nativeRequest);
|
|
80
|
+
// Served from the native internal cache; token did not come directly from the broker
|
|
81
|
+
nativeATMeasurement.add({
|
|
82
|
+
isNativeBroker: false,
|
|
83
|
+
});
|
|
84
|
+
nativeATMeasurement.end({
|
|
85
|
+
success: true,
|
|
86
|
+
fromCache: true,
|
|
87
|
+
});
|
|
88
|
+
return result;
|
|
89
|
+
}
|
|
90
|
+
catch (e) {
|
|
91
|
+
if (cacheLookupPolicy === CacheLookupPolicy.AccessToken) {
|
|
92
|
+
this.logger.info("0eitbc", this.correlationId);
|
|
93
|
+
nativeATMeasurement.add({
|
|
94
|
+
isNativeBroker: false,
|
|
95
|
+
});
|
|
96
|
+
nativeATMeasurement.end({
|
|
97
|
+
success: false,
|
|
98
|
+
});
|
|
99
|
+
throw e;
|
|
100
|
+
}
|
|
101
|
+
// continue with a native call for any and all errors
|
|
102
|
+
this.logger.info("0957j1", this.correlationId);
|
|
103
|
+
}
|
|
104
|
+
// dispatch the request to the broker
|
|
105
|
+
try {
|
|
106
|
+
const validatedResponse = await this.platformAuthProvider.sendMessage(nativeRequest);
|
|
107
|
+
const result = await this.handleNativeResponse(validatedResponse, nativeRequest, reqTimestamp, request.storeInCache);
|
|
108
|
+
nativeATMeasurement.end({
|
|
109
|
+
success: true,
|
|
110
|
+
requestId: result.requestId,
|
|
111
|
+
});
|
|
112
|
+
serverTelemetryManager.clearNativeBrokerErrorCode();
|
|
113
|
+
return result;
|
|
114
|
+
}
|
|
115
|
+
catch (e) {
|
|
116
|
+
if (e instanceof NativeAuthError) {
|
|
117
|
+
serverTelemetryManager.setNativeBrokerErrorCode(e.errorCode);
|
|
118
|
+
}
|
|
119
|
+
nativeATMeasurement.end({
|
|
120
|
+
success: false,
|
|
121
|
+
}, e);
|
|
122
|
+
this.setBrokerErrorTelemetry(e);
|
|
123
|
+
throw e;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Records platform-broker error telemetry on the root event for the current
|
|
128
|
+
* correlationId. `isNativeBroker` is set optimistically to true because the
|
|
129
|
+
* broker was engaged; when the caller subsequently falls back to a web flow
|
|
130
|
+
* that succeeds, the root success measurement overrides it to false via
|
|
131
|
+
* `result.fromPlatformBroker`. Terminal broker errors (no fallback) retain
|
|
132
|
+
* true. `brokerErrorName`/`brokerErrorCode` are recorded when the error is an `AuthError`.
|
|
133
|
+
* @param error error thrown by the broker interaction
|
|
134
|
+
*/
|
|
135
|
+
setBrokerErrorTelemetry(error) {
|
|
136
|
+
if (error instanceof AuthError) {
|
|
137
|
+
this.performanceClient.addFields({
|
|
138
|
+
isNativeBroker: true,
|
|
139
|
+
brokerErrorName: error.name,
|
|
140
|
+
brokerErrorCode: error.errorCode,
|
|
141
|
+
}, this.correlationId);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Creates silent flow request
|
|
146
|
+
* @param request
|
|
147
|
+
* @param cachedAccount
|
|
148
|
+
* @returns CommonSilentFlowRequest
|
|
149
|
+
*/
|
|
150
|
+
createSilentCacheRequest(request, cachedAccount) {
|
|
151
|
+
const silentRequest = {
|
|
152
|
+
authority: request.authority,
|
|
153
|
+
correlationId: this.correlationId,
|
|
154
|
+
scopes: ScopeSet.fromString(request.scope, this.correlationId).asArray(),
|
|
155
|
+
account: cachedAccount,
|
|
156
|
+
forceRefresh: false,
|
|
157
|
+
};
|
|
158
|
+
// Preserve FMI partition semantics for silent cache filtering.
|
|
159
|
+
if (request.attributeTokens) {
|
|
160
|
+
silentRequest.attributeTokens = request.attributeTokens.split(" ");
|
|
161
|
+
}
|
|
162
|
+
return silentRequest;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Fetches the tokens from the cache if un-expired
|
|
166
|
+
* @param nativeAccountId
|
|
167
|
+
* @param request
|
|
168
|
+
* @returns authenticationResult
|
|
169
|
+
*/
|
|
170
|
+
async acquireTokensFromCache(nativeAccountId, request) {
|
|
171
|
+
if (!nativeAccountId) {
|
|
172
|
+
this.logger.warning("1ndf3e", this.correlationId);
|
|
173
|
+
throw createClientAuthError(ClientAuthErrorCodes.noAccountFound, this.correlationId);
|
|
174
|
+
}
|
|
175
|
+
// fetch the account from browser cache
|
|
176
|
+
const account = this.browserStorage.getBaseAccountInfo({
|
|
177
|
+
nativeAccountId,
|
|
178
|
+
}, this.correlationId);
|
|
179
|
+
if (!account) {
|
|
180
|
+
throw createClientAuthError(ClientAuthErrorCodes.noAccountFound, this.correlationId);
|
|
181
|
+
}
|
|
182
|
+
// leverage silent flow for cached tokens retrieval
|
|
183
|
+
try {
|
|
184
|
+
const silentRequest = this.createSilentCacheRequest(request, account);
|
|
185
|
+
const result = await this.silentCacheClient.acquireToken(silentRequest);
|
|
186
|
+
const idToken = this.browserStorage.getIdToken(account, this.correlationId, this.browserStorage.getTokenKeys(), account.tenantId);
|
|
187
|
+
const idTokenClaims = AuthToken.extractTokenClaims(idToken?.secret || "", base64Decode, this.correlationId);
|
|
188
|
+
const fullAccount = updateAccountTenantProfileData(account, undefined, // tenantProfile optional
|
|
189
|
+
idTokenClaims, idToken?.secret);
|
|
190
|
+
return {
|
|
191
|
+
...result,
|
|
192
|
+
idToken: idToken?.secret || "",
|
|
193
|
+
idTokenClaims: idTokenClaims,
|
|
194
|
+
account: fullAccount,
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
catch (e) {
|
|
198
|
+
throw e;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Acquires a token from native platform then redirects to the redirectUri instead of returning the response
|
|
203
|
+
* @param {RedirectRequest} request
|
|
204
|
+
* @param {InProgressPerformanceEvent} rootMeasurement
|
|
205
|
+
* @param {HandleRedirectPromiseOptions} options
|
|
206
|
+
*/
|
|
207
|
+
async acquireTokenRedirect(request, rootMeasurement, options) {
|
|
208
|
+
this.logger.trace("0luikq", this.correlationId);
|
|
209
|
+
const nativeRequest = await this.initializePlatformRequest(request);
|
|
210
|
+
const navigateToLoginRequestUrl = options?.navigateToLoginRequestUrl ?? true;
|
|
211
|
+
try {
|
|
212
|
+
await this.platformAuthProvider.sendMessage(nativeRequest);
|
|
213
|
+
}
|
|
214
|
+
catch (e) {
|
|
215
|
+
// Only throw fatal errors here to allow application to fallback to regular redirect. Otherwise proceed and the error will be thrown in handleRedirectPromise
|
|
216
|
+
if (e instanceof NativeAuthError) {
|
|
217
|
+
const serverTelemetryManager = initializeServerTelemetryManager(this.apiId, this.config.auth.clientId, this.correlationId, this.browserStorage, this.logger, undefined, this.config.system.serverTelemetryEnabled);
|
|
218
|
+
serverTelemetryManager.setNativeBrokerErrorCode(e.errorCode);
|
|
219
|
+
if (isFatalNativeAuthError(e)) {
|
|
220
|
+
/*
|
|
221
|
+
* Fatal error on redirect initiate always falls back to a
|
|
222
|
+
* regular web redirect, so this request did not complete
|
|
223
|
+
* natively. Token telemetry for the eventual outcome lands
|
|
224
|
+
* in handleRedirectPromise (phase 2).
|
|
225
|
+
*/
|
|
226
|
+
this.setBrokerErrorTelemetry(e);
|
|
227
|
+
throw e;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
this.browserStorage.setTemporaryCache(TemporaryCacheKeys.NATIVE_REQUEST, JSON.stringify({
|
|
232
|
+
...nativeRequest,
|
|
233
|
+
storeInCache: request.storeInCache,
|
|
234
|
+
}), true);
|
|
235
|
+
const navigationOptions = {
|
|
236
|
+
apiId: ApiId.acquireTokenRedirect,
|
|
237
|
+
timeout: this.config.system.redirectNavigationTimeout,
|
|
238
|
+
noHistory: false,
|
|
239
|
+
};
|
|
240
|
+
const redirectUri = navigateToLoginRequestUrl
|
|
241
|
+
? UrlString.getAbsoluteUrl(request.redirectStartPage || window.location.href, getCurrentUri(), this.correlationId)
|
|
242
|
+
: getRedirectUri(request.redirectUri, this.config.auth.redirectUri, this.logger, this.correlationId);
|
|
243
|
+
rootMeasurement.end({ success: true });
|
|
244
|
+
await this.navigationClient.navigateExternal(redirectUri, navigationOptions); // Need to treat this as external to ensure handleRedirectPromise is run again
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* If the previous page called native platform for a token using redirect APIs, send the same request again and return the response
|
|
248
|
+
* @param performanceClient {IPerformanceClient?}
|
|
249
|
+
* @param correlationId {string?} correlation identifier
|
|
250
|
+
*/
|
|
251
|
+
async handleRedirectPromise() {
|
|
252
|
+
this.logger.trace("1c5lhw", this.correlationId);
|
|
253
|
+
if (!this.browserStorage.isInteractionInProgress(true)) {
|
|
254
|
+
this.logger.info("0le6uv", this.correlationId);
|
|
255
|
+
return null;
|
|
256
|
+
}
|
|
257
|
+
// remove prompt from the request to prevent WAM from prompting twice
|
|
258
|
+
const cachedRequest = this.browserStorage.getCachedNativeRequest();
|
|
259
|
+
if (!cachedRequest) {
|
|
260
|
+
this.logger.verbose("0a6zjb", this.correlationId);
|
|
261
|
+
this.performanceClient?.addFields({ errorCode: "no_cached_request" }, this.correlationId);
|
|
262
|
+
return null;
|
|
263
|
+
}
|
|
264
|
+
/*
|
|
265
|
+
* storeInCache is a client-side cache directive persisted alongside the cached
|
|
266
|
+
* request (not a broker-contract parameter), so extract it here before resending.
|
|
267
|
+
*/
|
|
268
|
+
const { prompt, storeInCache, ...request } = cachedRequest;
|
|
269
|
+
if (prompt) {
|
|
270
|
+
this.logger.verbose("0ac34v", this.correlationId);
|
|
271
|
+
}
|
|
272
|
+
this.browserStorage.removeItem(this.browserStorage.generateCacheKey(TemporaryCacheKeys.NATIVE_REQUEST));
|
|
273
|
+
const reqTimestamp = TimeUtils.nowSeconds();
|
|
274
|
+
try {
|
|
275
|
+
this.logger.verbose("003x5a", this.correlationId);
|
|
276
|
+
const response = await this.platformAuthProvider.sendMessage(request);
|
|
277
|
+
const authResult = await this.handleNativeResponse(response, request, reqTimestamp, storeInCache);
|
|
278
|
+
const serverTelemetryManager = initializeServerTelemetryManager(this.apiId, this.config.auth.clientId, this.correlationId, this.browserStorage, this.logger, undefined, this.config.system.serverTelemetryEnabled);
|
|
279
|
+
serverTelemetryManager.clearNativeBrokerErrorCode();
|
|
280
|
+
return authResult;
|
|
281
|
+
}
|
|
282
|
+
catch (e) {
|
|
283
|
+
this.setBrokerErrorTelemetry(e);
|
|
284
|
+
throw e;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Logout from native platform via browser extension
|
|
289
|
+
* @param request
|
|
290
|
+
*/
|
|
291
|
+
logout() {
|
|
292
|
+
this.logger.trace("0u2sjm", this.correlationId);
|
|
293
|
+
return Promise.reject("Logout not implemented yet");
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Transform response from native platform into AuthenticationResult object which will be returned to the end user
|
|
297
|
+
* @param response
|
|
298
|
+
* @param request
|
|
299
|
+
* @param reqTimestamp
|
|
300
|
+
*/
|
|
301
|
+
async handleNativeResponse(response, request, reqTimestamp, storeInCache) {
|
|
302
|
+
this.logger.trace("1bojln", this.correlationId);
|
|
303
|
+
// generate identifiers
|
|
304
|
+
const idTokenClaims = AuthToken.extractTokenClaims(response.id_token, base64Decode, this.correlationId);
|
|
305
|
+
const homeAccountIdentifier = this.createHomeAccountIdentifier(response, idTokenClaims);
|
|
306
|
+
const cachedhomeAccountId = this.browserStorage.getAccountInfoFilteredBy({
|
|
307
|
+
nativeAccountId: request.accountId,
|
|
308
|
+
}, this.correlationId)?.homeAccountId;
|
|
309
|
+
// add exception for double brokering, please note this is temporary and will be fortified in future
|
|
310
|
+
if (request.extraParameters?.child_client_id &&
|
|
311
|
+
response.account.id !== request.accountId) {
|
|
312
|
+
this.logger.info("1ub1in", this.correlationId);
|
|
313
|
+
}
|
|
314
|
+
else if (homeAccountIdentifier !== cachedhomeAccountId &&
|
|
315
|
+
response.account.id !== request.accountId) {
|
|
316
|
+
// 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
|
|
317
|
+
throw createNativeAuthError(userSwitch, this.correlationId);
|
|
318
|
+
}
|
|
319
|
+
// Get the preferred_cache domain for the given authority
|
|
320
|
+
const authority = await getDiscoveredAuthority(this.config, this.correlationId, this.performanceClient, this.browserStorage, this.logger, request.authority);
|
|
321
|
+
const baseAccount = buildAccountToCache(this.browserStorage, authority, homeAccountIdentifier, base64Decode, this.correlationId, idTokenClaims, response.client_info, authority.getPreferredCache(), // environment
|
|
322
|
+
idTokenClaims.tid, undefined, // auth code payload
|
|
323
|
+
response.account.id, this.logger, this.performanceClient);
|
|
324
|
+
// Ensure expires_in is in number format
|
|
325
|
+
response.expires_in = Number(response.expires_in);
|
|
326
|
+
// generate authenticationResult
|
|
327
|
+
const result = await this.generateAuthenticationResult(response, request, idTokenClaims, baseAccount, authority.canonicalAuthority, reqTimestamp);
|
|
328
|
+
// cache accounts and tokens in the appropriate storage
|
|
329
|
+
await this.cacheAccount(baseAccount, AuthToken.isKmsi(idTokenClaims));
|
|
330
|
+
await this.cacheNativeTokens(response, request, homeAccountIdentifier, idTokenClaims, result.tenantId, reqTimestamp, authority.getPreferredCache(), // environment
|
|
331
|
+
storeInCache);
|
|
332
|
+
return result;
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* creates an homeAccountIdentifier for the account
|
|
336
|
+
* @param response
|
|
337
|
+
* @param idTokenObj
|
|
338
|
+
* @returns
|
|
339
|
+
*/
|
|
340
|
+
createHomeAccountIdentifier(response, idTokenClaims) {
|
|
341
|
+
// Save account in browser storage
|
|
342
|
+
const homeAccountIdentifier = AccountEntityUtils.generateHomeAccountId(response.client_info || "", AuthorityType.Default, this.logger, this.browserCrypto, this.correlationId, idTokenClaims);
|
|
343
|
+
return homeAccountIdentifier;
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Helper to generate scopes
|
|
347
|
+
* @param response
|
|
348
|
+
* @param request
|
|
349
|
+
* @returns
|
|
350
|
+
*/
|
|
351
|
+
generateScopes(requestScopes, responseScopes) {
|
|
352
|
+
return responseScopes
|
|
353
|
+
? ScopeSet.fromString(responseScopes, this.correlationId)
|
|
354
|
+
: ScopeSet.fromString(requestScopes, this.correlationId);
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* If PoP token is requesred, records the PoP token if returned from the WAM, else generates one in the browser
|
|
358
|
+
* @param request
|
|
359
|
+
* @param response
|
|
360
|
+
*/
|
|
361
|
+
async generatePopAccessToken(response, request) {
|
|
362
|
+
if (request.tokenType === Constants.AuthenticationScheme.POP &&
|
|
363
|
+
request.signPopToken) {
|
|
364
|
+
/**
|
|
365
|
+
* This code prioritizes SHR returned from the native layer. In case of error/SHR not calculated from WAM and the AT
|
|
366
|
+
* is still received, SHR is calculated locally
|
|
367
|
+
*/
|
|
368
|
+
// Check if native layer returned an SHR token
|
|
369
|
+
if (response.shr) {
|
|
370
|
+
this.logger.trace("0coqhu", this.correlationId);
|
|
371
|
+
return response.shr;
|
|
372
|
+
}
|
|
373
|
+
// Generate SHR in msal js if WAM does not compute it when POP is enabled
|
|
374
|
+
const popTokenGenerator = new PopTokenGenerator(this.browserCrypto, this.tokenBindingKeyManager, this.performanceClient);
|
|
375
|
+
const shrParameters = {
|
|
376
|
+
resourceRequestMethod: request.resourceRequestMethod,
|
|
377
|
+
resourceRequestUri: request.resourceRequestUri,
|
|
378
|
+
shrClaims: request.shrClaims,
|
|
379
|
+
shrNonce: request.shrNonce,
|
|
380
|
+
correlationId: this.correlationId,
|
|
381
|
+
};
|
|
382
|
+
/**
|
|
383
|
+
* KeyID must be present in the native request from when the PoP key was generated in order for
|
|
384
|
+
* PopTokenGenerator to query the full key for signing
|
|
385
|
+
*/
|
|
386
|
+
if (!request.keyId) {
|
|
387
|
+
throw createClientAuthError(ClientAuthErrorCodes.keyIdMissing, this.correlationId);
|
|
388
|
+
}
|
|
389
|
+
return popTokenGenerator.signPopToken(response.access_token, request.keyId, shrParameters);
|
|
390
|
+
}
|
|
391
|
+
else {
|
|
392
|
+
return response.access_token;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Generates authentication result
|
|
397
|
+
* @param response
|
|
398
|
+
* @param request
|
|
399
|
+
* @param idTokenObj
|
|
400
|
+
* @param accountEntity
|
|
401
|
+
* @param authority
|
|
402
|
+
* @param reqTimestamp
|
|
403
|
+
* @returns
|
|
404
|
+
*/
|
|
405
|
+
async generateAuthenticationResult(response, request, idTokenClaims, accountEntity, authority, reqTimestamp) {
|
|
406
|
+
// Add Native Broker fields to Telemetry
|
|
407
|
+
const mats = this.addTelemetryFromNativeResponse(response.properties.MATS);
|
|
408
|
+
// If scopes not returned in server response, use request scopes
|
|
409
|
+
const responseScopes = this.generateScopes(request.scope, response.scope);
|
|
410
|
+
const accountProperties = response.account.properties || {};
|
|
411
|
+
const uid = accountProperties["UID"] ||
|
|
412
|
+
idTokenClaims.oid ||
|
|
413
|
+
idTokenClaims.sub ||
|
|
414
|
+
"";
|
|
415
|
+
const tid = accountProperties["TenantId"] || idTokenClaims.tid || "";
|
|
416
|
+
const accountInfo = updateAccountTenantProfileData(AccountEntityUtils.getAccountInfo(accountEntity), undefined, // tenantProfile optional
|
|
417
|
+
idTokenClaims, response.id_token);
|
|
418
|
+
/**
|
|
419
|
+
* In pairwise broker flows, this check prevents the broker's native account id
|
|
420
|
+
* from being returned over the embedded app's account id.
|
|
421
|
+
*/
|
|
422
|
+
if (accountInfo.nativeAccountId !== response.account.id) {
|
|
423
|
+
accountInfo.nativeAccountId = response.account.id;
|
|
424
|
+
// Also update the matching tenant profile (source of truth)
|
|
425
|
+
const targetTenantId = tid || accountInfo.tenantId;
|
|
426
|
+
const tenantProfile = accountInfo.tenantProfiles?.get(targetTenantId);
|
|
427
|
+
if (tenantProfile) {
|
|
428
|
+
tenantProfile.nativeAccountId = response.account.id;
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
// generate PoP token as needed
|
|
432
|
+
const responseAccessToken = await this.generatePopAccessToken(response, request);
|
|
433
|
+
const tokenType = request.tokenType === Constants.AuthenticationScheme.POP
|
|
434
|
+
? Constants.AuthenticationScheme.POP
|
|
435
|
+
: Constants.AuthenticationScheme.BEARER;
|
|
436
|
+
const result = {
|
|
437
|
+
authority: authority,
|
|
438
|
+
uniqueId: uid,
|
|
439
|
+
tenantId: tid,
|
|
440
|
+
scopes: responseScopes.asArray(),
|
|
441
|
+
account: accountInfo,
|
|
442
|
+
idToken: response.id_token,
|
|
443
|
+
idTokenClaims: idTokenClaims,
|
|
444
|
+
accessToken: responseAccessToken,
|
|
445
|
+
fromCache: mats ? this.isResponseFromCache(mats) : false,
|
|
446
|
+
// Request timestamp and NativeResponse expires_in are in seconds, converting to Date for AuthenticationResult
|
|
447
|
+
expiresOn: TimeUtils.toDateFromSeconds(reqTimestamp + response.expires_in),
|
|
448
|
+
tokenType: tokenType,
|
|
449
|
+
correlationId: this.correlationId,
|
|
450
|
+
state: response.state,
|
|
451
|
+
fromPlatformBroker: true,
|
|
452
|
+
...(request.extraParameters?.resource && {
|
|
453
|
+
resource: request.extraParameters.resource,
|
|
454
|
+
}),
|
|
455
|
+
};
|
|
456
|
+
return result;
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* cache the account entity in browser storage
|
|
460
|
+
* @param accountEntity
|
|
461
|
+
*/
|
|
462
|
+
async cacheAccount(accountEntity, kmsi) {
|
|
463
|
+
// Store the account info and hence `nativeAccountId` in browser cache
|
|
464
|
+
await this.browserStorage.setAccount(accountEntity, this.correlationId, kmsi, this.apiId);
|
|
465
|
+
// Remove any existing cached tokens for this account in browser storage
|
|
466
|
+
this.browserStorage.removeAccountContext(AccountEntityUtils.getAccountInfo(accountEntity), this.correlationId);
|
|
467
|
+
}
|
|
468
|
+
/**
|
|
469
|
+
* Stores the access_token and id_token in inmemory storage
|
|
470
|
+
* @param response
|
|
471
|
+
* @param request
|
|
472
|
+
* @param homeAccountIdentifier
|
|
473
|
+
* @param idTokenObj
|
|
474
|
+
* @param responseAccessToken
|
|
475
|
+
* @param tenantId
|
|
476
|
+
* @param reqTimestamp
|
|
477
|
+
*/
|
|
478
|
+
async cacheNativeTokens(response, request, homeAccountIdentifier, idTokenClaims, tenantId, reqTimestamp, environment, storeInCache) {
|
|
479
|
+
const cachedIdToken = CacheHelpers.createIdTokenEntity(homeAccountIdentifier, environment, response.id_token || "", request.clientId, idTokenClaims.tid || "");
|
|
480
|
+
// cache accessToken in inmemory storage
|
|
481
|
+
const expiresIn = request.tokenType === Constants.AuthenticationScheme.POP
|
|
482
|
+
? Constants.SHR_NONCE_VALIDITY
|
|
483
|
+
: (typeof response.expires_in === "string"
|
|
484
|
+
? parseInt(response.expires_in, 10)
|
|
485
|
+
: response.expires_in) || 0;
|
|
486
|
+
const tokenExpirationSeconds = reqTimestamp + expiresIn;
|
|
487
|
+
const responseScopes = this.generateScopes(response.scope, request.scope);
|
|
488
|
+
const additionalCacheKeyComponents = request.attributeTokens
|
|
489
|
+
? {
|
|
490
|
+
attribute_tokens: request.attributeTokens,
|
|
491
|
+
}
|
|
492
|
+
: undefined;
|
|
493
|
+
const cachedAccessToken = CacheHelpers.createAccessTokenEntity(homeAccountIdentifier, environment, response.access_token, request.clientId, idTokenClaims.tid || tenantId, responseScopes.printScopes(), tokenExpirationSeconds, 0, base64Decode, request.correlationId, undefined, request.tokenType, undefined, request.keyId, additionalCacheKeyComponents);
|
|
494
|
+
// save idtoken credential in configured browser storage
|
|
495
|
+
if (!!cachedIdToken && storeInCache?.idToken !== false) {
|
|
496
|
+
await this.browserStorage.setIdTokenCredential(cachedIdToken, this.correlationId, AuthToken.isKmsi(idTokenClaims));
|
|
497
|
+
}
|
|
498
|
+
// save access token credential in memory storage
|
|
499
|
+
const nativeCacheRecord = {
|
|
500
|
+
accessToken: cachedAccessToken,
|
|
501
|
+
};
|
|
502
|
+
return this.nativeStorageManager.saveCacheRecord(nativeCacheRecord, this.correlationId, AuthToken.isKmsi(idTokenClaims), this.apiId, storeInCache);
|
|
503
|
+
}
|
|
504
|
+
getExpiresInValue(tokenType, expiresIn) {
|
|
505
|
+
return tokenType === Constants.AuthenticationScheme.POP
|
|
506
|
+
? Constants.SHR_NONCE_VALIDITY
|
|
507
|
+
: (typeof expiresIn === "string"
|
|
508
|
+
? parseInt(expiresIn, 10)
|
|
509
|
+
: expiresIn) || 0;
|
|
510
|
+
}
|
|
511
|
+
addTelemetryFromNativeResponse(matsResponse) {
|
|
512
|
+
const mats = this.getMATSFromResponse(matsResponse);
|
|
513
|
+
if (!mats) {
|
|
514
|
+
return null;
|
|
515
|
+
}
|
|
516
|
+
this.performanceClient.addFields({
|
|
517
|
+
extensionId: this.platformAuthProvider.getExtensionId(),
|
|
518
|
+
extensionVersion: this.platformAuthProvider.getExtensionVersion(),
|
|
519
|
+
matsBrokerVersion: mats.broker_version,
|
|
520
|
+
matsAccountJoinOnStart: mats.account_join_on_start,
|
|
521
|
+
matsAccountJoinOnEnd: mats.account_join_on_end,
|
|
522
|
+
matsDeviceJoin: mats.device_join,
|
|
523
|
+
matsPromptBehavior: mats.prompt_behavior,
|
|
524
|
+
matsApiErrorCode: mats.api_error_code,
|
|
525
|
+
matsUiVisible: mats.ui_visible,
|
|
526
|
+
matsSilentCode: mats.silent_code,
|
|
527
|
+
matsSilentBiSubCode: mats.silent_bi_sub_code,
|
|
528
|
+
matsSilentMessage: mats.silent_message,
|
|
529
|
+
matsSilentStatus: mats.silent_status,
|
|
530
|
+
matsHttpStatus: mats.http_status,
|
|
531
|
+
matsHttpEventCount: mats.http_event_count,
|
|
532
|
+
}, this.correlationId);
|
|
533
|
+
return mats;
|
|
534
|
+
}
|
|
535
|
+
/**
|
|
536
|
+
* Gets MATS telemetry from native response
|
|
537
|
+
* @param response
|
|
538
|
+
* @returns
|
|
539
|
+
*/
|
|
540
|
+
getMATSFromResponse(matsResponse) {
|
|
541
|
+
if (matsResponse) {
|
|
542
|
+
try {
|
|
543
|
+
return JSON.parse(matsResponse);
|
|
544
|
+
}
|
|
545
|
+
catch (e) {
|
|
546
|
+
this.logger.error("0b3l57", this.correlationId);
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
return null;
|
|
550
|
+
}
|
|
551
|
+
/**
|
|
552
|
+
* Returns whether or not response came from native cache
|
|
553
|
+
* @param response
|
|
554
|
+
* @returns
|
|
555
|
+
*/
|
|
556
|
+
isResponseFromCache(mats) {
|
|
557
|
+
if (typeof mats.is_cached === "undefined") {
|
|
558
|
+
this.logger.verbose("1okqev", this.correlationId);
|
|
559
|
+
return false;
|
|
560
|
+
}
|
|
561
|
+
return !!mats.is_cached;
|
|
562
|
+
}
|
|
563
|
+
/**
|
|
564
|
+
* Translates developer provided request object into NativeRequest object
|
|
565
|
+
* @param request
|
|
566
|
+
*/
|
|
567
|
+
async initializePlatformRequest(request) {
|
|
568
|
+
this.logger.trace("1xdm2a", this.correlationId);
|
|
569
|
+
const canonicalAuthority = await this.getCanonicalAuthority(request);
|
|
570
|
+
// ignore config claims if skipBrokerClaims is set to true and this is a brokered authentication flow
|
|
571
|
+
const configClaims = request.skipBrokerClaims && !!request.embeddedClientId
|
|
572
|
+
? undefined
|
|
573
|
+
: this.config.auth.clientCapabilities;
|
|
574
|
+
/*
|
|
575
|
+
* scopes are expected to be received by the native broker as "scope" and will be added to the request below. Other properties that should be dropped from the request to the native broker can be included in the object destructuring here.
|
|
576
|
+
* attributeTokens is destructured out because PlatformAuthRequest represents it as a pre-serialized string, not the caller-provided Array<string>.
|
|
577
|
+
*/
|
|
578
|
+
const { scopes, claims } = request;
|
|
579
|
+
const scopeSet = new ScopeSet(scopes || [], this.correlationId);
|
|
580
|
+
scopeSet.appendScopes(Constants.OIDC_DEFAULT_SCOPES);
|
|
581
|
+
const mergedClaims = RequestParameterBuilder.buildMergedClaims(claims, configClaims?.length ? configClaims : undefined);
|
|
582
|
+
const hasAttributeTokens = !!request.attributeTokens?.length;
|
|
583
|
+
this.performanceClient?.addFields({
|
|
584
|
+
hasAttributeTokens,
|
|
585
|
+
}, this.correlationId);
|
|
586
|
+
const validatedRequest = {
|
|
587
|
+
claims: mergedClaims,
|
|
588
|
+
accountId: this.accountId,
|
|
589
|
+
clientId: this.config.auth.clientId,
|
|
590
|
+
authority: canonicalAuthority.urlString,
|
|
591
|
+
scope: scopeSet.printScopes(),
|
|
592
|
+
redirectUri: getRedirectUri(request.redirectUri, this.config.auth.redirectUri, this.logger, this.correlationId),
|
|
593
|
+
prompt: this.getPrompt(request.prompt),
|
|
594
|
+
correlationId: this.correlationId,
|
|
595
|
+
isSts: false,
|
|
596
|
+
tokenType: request.authenticationScheme,
|
|
597
|
+
windowTitleSubstring: document.title,
|
|
598
|
+
nonce: request.nonce,
|
|
599
|
+
state: request.state,
|
|
600
|
+
loginHint: request.loginHint,
|
|
601
|
+
extraParameters: {
|
|
602
|
+
...request.extraParameters,
|
|
603
|
+
...(request.resource && { resource: request.resource }), // resource is set for MCP scenarios
|
|
604
|
+
},
|
|
605
|
+
extendedExpiryToken: false,
|
|
606
|
+
keyId: request.popKid,
|
|
607
|
+
resourceRequestMethod: request.resourceRequestMethod,
|
|
608
|
+
resourceRequestUri: request.resourceRequestUri,
|
|
609
|
+
shrClaims: request.shrClaims,
|
|
610
|
+
shrNonce: request.shrNonce,
|
|
611
|
+
};
|
|
612
|
+
if (hasAttributeTokens) {
|
|
613
|
+
validatedRequest.attributeTokens =
|
|
614
|
+
CacheHelpers.serializeAttributeTokens(request.attributeTokens);
|
|
615
|
+
}
|
|
616
|
+
// Check for PoP token requests: signPopToken should only be set to true if popKid is not set
|
|
617
|
+
if (validatedRequest.signPopToken && !!request.popKid) {
|
|
618
|
+
throw createBrowserAuthError(invalidPopTokenRequest, this.correlationId);
|
|
619
|
+
}
|
|
620
|
+
this.handleExtraBrokerParams(validatedRequest, request.embeddedClientId);
|
|
621
|
+
validatedRequest.extraParameters =
|
|
622
|
+
validatedRequest.extraParameters || {};
|
|
623
|
+
validatedRequest.extraParameters.telemetry =
|
|
624
|
+
PlatformAuthConstants.MATS_TELEMETRY;
|
|
625
|
+
if (request.authenticationScheme === Constants.AuthenticationScheme.POP) {
|
|
626
|
+
// add POP request type
|
|
627
|
+
const shrParameters = {
|
|
628
|
+
resourceRequestUri: request.resourceRequestUri,
|
|
629
|
+
resourceRequestMethod: request.resourceRequestMethod,
|
|
630
|
+
shrClaims: request.shrClaims,
|
|
631
|
+
shrNonce: request.shrNonce,
|
|
632
|
+
correlationId: this.correlationId,
|
|
633
|
+
};
|
|
634
|
+
const popTokenGenerator = new PopTokenGenerator(this.browserCrypto, this.tokenBindingKeyManager, this.performanceClient);
|
|
635
|
+
// generate reqCnf if not provided in the request
|
|
636
|
+
let reqCnfData;
|
|
637
|
+
if (!validatedRequest.keyId) {
|
|
638
|
+
const generatedReqCnfData = await invokeAsync(popTokenGenerator.generateCnf.bind(popTokenGenerator), PerformanceEvents.PopTokenGenerateCnf, this.logger, this.performanceClient, this.correlationId)(shrParameters, this.logger);
|
|
639
|
+
reqCnfData = generatedReqCnfData.reqCnfString;
|
|
640
|
+
validatedRequest.keyId = generatedReqCnfData.kid;
|
|
641
|
+
validatedRequest.signPopToken = true;
|
|
642
|
+
}
|
|
643
|
+
else {
|
|
644
|
+
reqCnfData = this.browserCrypto.base64UrlEncode(JSON.stringify({ kid: validatedRequest.keyId }));
|
|
645
|
+
validatedRequest.signPopToken = false;
|
|
646
|
+
}
|
|
647
|
+
// SPAs require whole string to be passed to broker
|
|
648
|
+
validatedRequest.reqCnf = reqCnfData;
|
|
649
|
+
}
|
|
650
|
+
this.addRequestSKUs(validatedRequest);
|
|
651
|
+
return validatedRequest;
|
|
652
|
+
}
|
|
653
|
+
async getCanonicalAuthority(request) {
|
|
654
|
+
const requestAuthority = request.authority || this.config.auth.authority;
|
|
655
|
+
const { azureCloudOptions, account } = request;
|
|
656
|
+
if (account) {
|
|
657
|
+
// validate authority
|
|
658
|
+
await getDiscoveredAuthority(this.config, this.correlationId, this.performanceClient, this.browserStorage, this.logger, requestAuthority, azureCloudOptions, undefined, // requestExtraQueryParameters
|
|
659
|
+
account);
|
|
660
|
+
}
|
|
661
|
+
const canonicalAuthority = new UrlString(requestAuthority, this.correlationId);
|
|
662
|
+
canonicalAuthority.validateAsUri();
|
|
663
|
+
return canonicalAuthority;
|
|
664
|
+
}
|
|
665
|
+
getPrompt(prompt) {
|
|
666
|
+
// If request is silent, prompt is always none
|
|
667
|
+
switch (this.apiId) {
|
|
668
|
+
case ApiId.ssoSilent:
|
|
669
|
+
case ApiId.acquireTokenSilent_silentFlow:
|
|
670
|
+
this.logger.trace("12n1y2", this.correlationId);
|
|
671
|
+
return Constants.PromptValue.NONE;
|
|
672
|
+
}
|
|
673
|
+
// Prompt not provided, request may proceed and native broker decides if it needs to prompt
|
|
674
|
+
if (!prompt) {
|
|
675
|
+
this.logger.trace("0uid1p", this.correlationId);
|
|
676
|
+
return undefined;
|
|
677
|
+
}
|
|
678
|
+
// If request is interactive, check if prompt provided is allowed to go directly to native broker
|
|
679
|
+
switch (prompt) {
|
|
680
|
+
case Constants.PromptValue.NONE:
|
|
681
|
+
case Constants.PromptValue.CONSENT:
|
|
682
|
+
case Constants.PromptValue.LOGIN:
|
|
683
|
+
this.logger.trace("0i0hco", this.correlationId);
|
|
684
|
+
return prompt;
|
|
685
|
+
default:
|
|
686
|
+
this.logger.trace(`0w3tpw ${prompt}`, this.correlationId);
|
|
687
|
+
throw createBrowserAuthError(nativePromptNotSupported, this.correlationId);
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
/**
|
|
691
|
+
* Handles extra broker request parameters
|
|
692
|
+
* @param request {PlatformAuthRequest}
|
|
693
|
+
* @private
|
|
694
|
+
*/
|
|
695
|
+
handleExtraBrokerParams(request, embeddedClientId) {
|
|
696
|
+
const hasExtraBrokerParams = request.extraParameters &&
|
|
697
|
+
request.extraParameters.hasOwnProperty(AADServerParamKeys.BROKER_CLIENT_ID) &&
|
|
698
|
+
request.extraParameters.hasOwnProperty(AADServerParamKeys.BROKER_REDIRECT_URI) &&
|
|
699
|
+
request.extraParameters.hasOwnProperty(AADServerParamKeys.CLIENT_ID);
|
|
700
|
+
if (!embeddedClientId && !hasExtraBrokerParams) {
|
|
701
|
+
return;
|
|
702
|
+
}
|
|
703
|
+
let child_client_id = "";
|
|
704
|
+
const child_redirect_uri = request.redirectUri;
|
|
705
|
+
if (embeddedClientId) {
|
|
706
|
+
request.redirectUri = this.config.auth.redirectUri;
|
|
707
|
+
child_client_id = embeddedClientId;
|
|
708
|
+
}
|
|
709
|
+
else if (request.extraParameters) {
|
|
710
|
+
request.redirectUri =
|
|
711
|
+
request.extraParameters[AADServerParamKeys.BROKER_REDIRECT_URI];
|
|
712
|
+
child_client_id =
|
|
713
|
+
request.extraParameters[AADServerParamKeys.CLIENT_ID];
|
|
714
|
+
}
|
|
715
|
+
const {
|
|
716
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
717
|
+
[AADServerParamKeys.BROKER_CLIENT_ID]: _brkClientId,
|
|
718
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
719
|
+
[AADServerParamKeys.BROKER_REDIRECT_URI]: _brkRedirectUri,
|
|
720
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
721
|
+
[AADServerParamKeys.CLIENT_ID]: _clientId, ...remainingExtraParameters } = request.extraParameters || {};
|
|
722
|
+
request.extraParameters = {
|
|
723
|
+
...remainingExtraParameters,
|
|
724
|
+
child_client_id,
|
|
725
|
+
child_redirect_uri,
|
|
726
|
+
};
|
|
727
|
+
this.performanceClient?.addFields({
|
|
728
|
+
embeddedClientId: child_client_id,
|
|
729
|
+
embeddedRedirectUri: child_redirect_uri,
|
|
730
|
+
}, this.correlationId);
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
export { PlatformAuthInteractionClient };
|