daftari 3.13.1 → 3.15.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 +31 -0
- package/dist/consolidate/index.d.ts.map +1 -1
- package/dist/consolidate/index.js +3 -12
- package/dist/consolidate/index.js.map +1 -1
- package/dist/distill/cli.d.ts.map +1 -1
- package/dist/distill/cli.js +2 -1
- package/dist/distill/cli.js.map +1 -1
- package/dist/distill/cost.d.ts +3 -3
- package/dist/distill/cost.d.ts.map +1 -1
- package/dist/distill/index.d.ts.map +1 -1
- package/dist/distill/index.js +3 -15
- package/dist/distill/index.js.map +1 -1
- 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/distill/state.d.ts +12 -0
- package/dist/distill/state.d.ts.map +1 -1
- package/dist/distill/state.js +16 -6
- package/dist/distill/state.js.map +1 -1
- package/dist/eval/index.d.ts.map +1 -1
- package/dist/eval/index.js +11 -16
- package/dist/eval/index.js.map +1 -1
- package/dist/eval/llm-openrouter.d.ts +4 -1
- package/dist/eval/llm-openrouter.d.ts.map +1 -1
- package/dist/eval/llm-openrouter.js +21 -5
- package/dist/eval/llm-openrouter.js.map +1 -1
- package/dist/eval/transport.d.ts +5 -0
- package/dist/eval/transport.d.ts.map +1 -0
- package/dist/eval/transport.js +27 -0
- package/dist/eval/transport.js.map +1 -0
- 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.d.ts.map +1 -1
- package/dist/sleep/index.js +6 -16
- package/dist/sleep/index.js.map +1 -1
- 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,204 @@
|
|
|
1
|
+
/*! @azure/msal-common v16.14.0 2026-08-28 */
|
|
2
|
+
'use strict';
|
|
3
|
+
import { createClientConfigurationError } from '../error/ClientConfigurationError.mjs';
|
|
4
|
+
import { StringUtils } from '../utils/StringUtils.mjs';
|
|
5
|
+
import { createClientAuthError } from '../error/ClientAuthError.mjs';
|
|
6
|
+
import { OIDC_DEFAULT_SCOPES, OFFLINE_ACCESS_SCOPE, OIDC_SCOPES } from '../utils/Constants.mjs';
|
|
7
|
+
import { emptyInputScopesError } from '../error/ClientConfigurationErrorCodes.mjs';
|
|
8
|
+
import { cannotAppendScopeSet, cannotRemoveEmptyScope, emptyInputScopeSet } from '../error/ClientAuthErrorCodes.mjs';
|
|
9
|
+
|
|
10
|
+
/*
|
|
11
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
12
|
+
* Licensed under the MIT License.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* The ScopeSet class creates a set of scopes. Scopes are case-insensitive, unique values, so the Set object in JS makes
|
|
16
|
+
* the most sense to implement for this class. All scopes are trimmed and converted to lower case strings in intersection and union functions
|
|
17
|
+
* to ensure uniqueness of strings.
|
|
18
|
+
*/
|
|
19
|
+
class ScopeSet {
|
|
20
|
+
constructor(inputScopes, correlationId) {
|
|
21
|
+
this.correlationId = correlationId;
|
|
22
|
+
// Filter empty string and null/undefined array items
|
|
23
|
+
const scopeArr = inputScopes
|
|
24
|
+
? StringUtils.trimArrayEntries([...inputScopes])
|
|
25
|
+
: [];
|
|
26
|
+
const filteredInput = scopeArr
|
|
27
|
+
? StringUtils.removeEmptyStringsFromArray(scopeArr)
|
|
28
|
+
: [];
|
|
29
|
+
// Check if scopes array has at least one member
|
|
30
|
+
if (!filteredInput || !filteredInput.length) {
|
|
31
|
+
throw createClientConfigurationError(emptyInputScopesError, correlationId);
|
|
32
|
+
}
|
|
33
|
+
this.scopes = new Set(); // Iterator in constructor not supported by IE11
|
|
34
|
+
filteredInput.forEach((scope) => this.scopes.add(scope));
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Factory method to create ScopeSet from space-delimited string
|
|
38
|
+
* @param inputScopeString
|
|
39
|
+
* @param appClientId
|
|
40
|
+
* @param scopesRequired
|
|
41
|
+
*/
|
|
42
|
+
static fromString(inputScopeString, correlationId) {
|
|
43
|
+
const scopeString = inputScopeString || "";
|
|
44
|
+
const inputScopes = scopeString.split(" ");
|
|
45
|
+
return new ScopeSet(inputScopes, correlationId);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Creates the set of scopes to search for in cache lookups
|
|
49
|
+
* @param inputScopeString
|
|
50
|
+
* @returns
|
|
51
|
+
*/
|
|
52
|
+
static createSearchScopes(inputScopeString, correlationId) {
|
|
53
|
+
// Handle empty scopes by using default OIDC scopes for cache lookup
|
|
54
|
+
const scopesToUse = inputScopeString && inputScopeString.length > 0
|
|
55
|
+
? inputScopeString
|
|
56
|
+
: [...OIDC_DEFAULT_SCOPES];
|
|
57
|
+
const scopeSet = new ScopeSet(scopesToUse, correlationId);
|
|
58
|
+
if (!scopeSet.containsOnlyOIDCScopes()) {
|
|
59
|
+
scopeSet.removeOIDCScopes();
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
scopeSet.removeScope(OFFLINE_ACCESS_SCOPE);
|
|
63
|
+
}
|
|
64
|
+
return scopeSet;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Check if a given scope is present in this set of scopes.
|
|
68
|
+
* @param scope
|
|
69
|
+
*/
|
|
70
|
+
containsScope(scope) {
|
|
71
|
+
const lowerCaseScopes = this.printScopesLowerCase().split(" ");
|
|
72
|
+
const lowerCaseScopesSet = new ScopeSet(lowerCaseScopes, this.correlationId);
|
|
73
|
+
// compare lowercase scopes
|
|
74
|
+
return scope
|
|
75
|
+
? lowerCaseScopesSet.scopes.has(scope.toLowerCase())
|
|
76
|
+
: false;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Check if a set of scopes is present in this set of scopes.
|
|
80
|
+
* @param scopeSet
|
|
81
|
+
*/
|
|
82
|
+
containsScopeSet(scopeSet) {
|
|
83
|
+
if (!scopeSet || scopeSet.scopes.size <= 0) {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
return (this.scopes.size >= scopeSet.scopes.size &&
|
|
87
|
+
scopeSet.asArray().every((scope) => this.containsScope(scope)));
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Check if set of scopes contains only the defaults
|
|
91
|
+
*/
|
|
92
|
+
containsOnlyOIDCScopes() {
|
|
93
|
+
let defaultScopeCount = 0;
|
|
94
|
+
OIDC_SCOPES.forEach((defaultScope) => {
|
|
95
|
+
if (this.containsScope(defaultScope)) {
|
|
96
|
+
defaultScopeCount += 1;
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
return this.scopes.size === defaultScopeCount;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Appends single scope if passed
|
|
103
|
+
* @param newScope
|
|
104
|
+
*/
|
|
105
|
+
appendScope(newScope) {
|
|
106
|
+
if (newScope) {
|
|
107
|
+
this.scopes.add(newScope.trim());
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Appends multiple scopes if passed
|
|
112
|
+
* @param newScopes
|
|
113
|
+
*/
|
|
114
|
+
appendScopes(newScopes) {
|
|
115
|
+
try {
|
|
116
|
+
newScopes.forEach((newScope) => this.appendScope(newScope));
|
|
117
|
+
}
|
|
118
|
+
catch (e) {
|
|
119
|
+
throw createClientAuthError(cannotAppendScopeSet, this.correlationId);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Removes element from set of scopes.
|
|
124
|
+
* @param scope
|
|
125
|
+
*/
|
|
126
|
+
removeScope(scope) {
|
|
127
|
+
if (!scope) {
|
|
128
|
+
throw createClientAuthError(cannotRemoveEmptyScope, this.correlationId);
|
|
129
|
+
}
|
|
130
|
+
this.scopes.delete(scope.trim());
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Removes default scopes from set of scopes
|
|
134
|
+
* Primarily used to prevent cache misses if the default scopes are not returned from the server
|
|
135
|
+
*/
|
|
136
|
+
removeOIDCScopes() {
|
|
137
|
+
OIDC_SCOPES.forEach((defaultScope) => {
|
|
138
|
+
this.scopes.delete(defaultScope);
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Combines an array of scopes with the current set of scopes.
|
|
143
|
+
* @param otherScopes
|
|
144
|
+
*/
|
|
145
|
+
unionScopeSets(otherScopes) {
|
|
146
|
+
if (!otherScopes) {
|
|
147
|
+
throw createClientAuthError(emptyInputScopeSet, this.correlationId);
|
|
148
|
+
}
|
|
149
|
+
const unionScopes = new Set(); // Iterator in constructor not supported in IE11
|
|
150
|
+
otherScopes.scopes.forEach((scope) => unionScopes.add(scope.toLowerCase()));
|
|
151
|
+
this.scopes.forEach((scope) => unionScopes.add(scope.toLowerCase()));
|
|
152
|
+
return unionScopes;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Check if scopes intersect between this set and another.
|
|
156
|
+
* @param otherScopes
|
|
157
|
+
*/
|
|
158
|
+
intersectingScopeSets(otherScopes) {
|
|
159
|
+
if (!otherScopes) {
|
|
160
|
+
throw createClientAuthError(emptyInputScopeSet, this.correlationId);
|
|
161
|
+
}
|
|
162
|
+
// Do not allow OIDC scopes to be the only intersecting scopes
|
|
163
|
+
if (!otherScopes.containsOnlyOIDCScopes()) {
|
|
164
|
+
otherScopes.removeOIDCScopes();
|
|
165
|
+
}
|
|
166
|
+
const unionScopes = this.unionScopeSets(otherScopes);
|
|
167
|
+
const sizeOtherScopes = otherScopes.getScopeCount();
|
|
168
|
+
const sizeThisScopes = this.getScopeCount();
|
|
169
|
+
const sizeUnionScopes = unionScopes.size;
|
|
170
|
+
return sizeUnionScopes < sizeThisScopes + sizeOtherScopes;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Returns size of set of scopes.
|
|
174
|
+
*/
|
|
175
|
+
getScopeCount() {
|
|
176
|
+
return this.scopes.size;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Returns the scopes as an array of string values
|
|
180
|
+
*/
|
|
181
|
+
asArray() {
|
|
182
|
+
const array = [];
|
|
183
|
+
this.scopes.forEach((val) => array.push(val));
|
|
184
|
+
return array;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Prints scopes into a space-delimited string
|
|
188
|
+
*/
|
|
189
|
+
printScopes() {
|
|
190
|
+
if (this.scopes) {
|
|
191
|
+
const scopeArr = this.asArray();
|
|
192
|
+
return scopeArr.join(" ");
|
|
193
|
+
}
|
|
194
|
+
return "";
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Prints scopes into a space-delimited lower-case string (used for caching)
|
|
198
|
+
*/
|
|
199
|
+
printScopesLowerCase() {
|
|
200
|
+
return this.printScopes().toLowerCase();
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export { ScopeSet };
|
|
@@ -0,0 +1,432 @@
|
|
|
1
|
+
/*! @azure/msal-common v16.14.0 2026-08-28 */
|
|
2
|
+
'use strict';
|
|
3
|
+
import { updateAccountTenantProfileData, buildTenantProfile } from '../account/AccountInfo.mjs';
|
|
4
|
+
import { extractTokenClaims, isKmsi } from '../account/AuthToken.mjs';
|
|
5
|
+
import { getTenantIdFromIdTokenClaims } from '../account/TokenClaims.mjs';
|
|
6
|
+
import { TokenCacheContext } from '../cache/persistence/TokenCacheContext.mjs';
|
|
7
|
+
import { generateHomeAccountId, getAccountInfo, createAccountEntity } from '../cache/utils/AccountEntityUtils.mjs';
|
|
8
|
+
import { createIdTokenEntity, createAccessTokenEntity, createRefreshTokenEntity, serializeAttributeTokens } from '../cache/utils/CacheHelpers.mjs';
|
|
9
|
+
import { PopTokenGenerator } from '../crypto/PopTokenGenerator.mjs';
|
|
10
|
+
import { DpopProofGenerator } from '../crypto/DpopProofGenerator.mjs';
|
|
11
|
+
import { DEFAULT_TOKEN_BINDING_KEY_MANAGER } from '../crypto/ITokenBindingKeyManager.mjs';
|
|
12
|
+
import { createClientAuthError } from '../error/ClientAuthError.mjs';
|
|
13
|
+
import { isInteractionRequiredError, InteractionRequiredAuthError } from '../error/InteractionRequiredAuthError.mjs';
|
|
14
|
+
import { ServerError } from '../error/ServerError.mjs';
|
|
15
|
+
import { ScopeSet } from '../request/ScopeSet.mjs';
|
|
16
|
+
import { NOT_AVAILABLE, HTTP_SERVER_ERROR_RANGE_START, HTTP_SERVER_ERROR_RANGE_END, HTTP_CLIENT_ERROR_RANGE_START, HTTP_CLIENT_ERROR_RANGE_END, AuthenticationScheme, THE_FAMILY_ID } from '../utils/Constants.mjs';
|
|
17
|
+
import { parseRequestState } from '../utils/ProtocolUtils.mjs';
|
|
18
|
+
import { toDateFromSeconds } from '../utils/TimeUtils.mjs';
|
|
19
|
+
import { nonceMismatch, dpopTokenTypeMismatch, invalidCacheEnvironment, keyIdMissing } from '../error/ClientAuthErrorCodes.mjs';
|
|
20
|
+
|
|
21
|
+
/*
|
|
22
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
23
|
+
* Licensed under the MIT License.
|
|
24
|
+
*/
|
|
25
|
+
/**
|
|
26
|
+
* Class that handles response parsing.
|
|
27
|
+
* @internal
|
|
28
|
+
*/
|
|
29
|
+
class ResponseHandler {
|
|
30
|
+
constructor(clientId, cacheStorage, cryptoObj, logger, performanceClient, serializableCache, persistencePlugin, tokenBindingKeyManager = DEFAULT_TOKEN_BINDING_KEY_MANAGER) {
|
|
31
|
+
this.clientId = clientId;
|
|
32
|
+
this.cacheStorage = cacheStorage;
|
|
33
|
+
this.cryptoObj = cryptoObj;
|
|
34
|
+
this.tokenBindingKeyManager = tokenBindingKeyManager;
|
|
35
|
+
this.logger = logger;
|
|
36
|
+
this.performanceClient = performanceClient;
|
|
37
|
+
this.serializableCache = serializableCache;
|
|
38
|
+
this.persistencePlugin = persistencePlugin;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Function which validates server authorization token response.
|
|
42
|
+
* @param serverResponse
|
|
43
|
+
* @param correlationId
|
|
44
|
+
* @param refreshAccessToken
|
|
45
|
+
*/
|
|
46
|
+
validateTokenResponse(serverResponse, correlationId, refreshAccessToken) {
|
|
47
|
+
// Check for error
|
|
48
|
+
if (serverResponse.error ||
|
|
49
|
+
serverResponse.error_description ||
|
|
50
|
+
serverResponse.suberror) {
|
|
51
|
+
const errString = `Error(s): ${serverResponse.error_codes || NOT_AVAILABLE} - Timestamp: ${serverResponse.timestamp || NOT_AVAILABLE} - Description: ${serverResponse.error_description || NOT_AVAILABLE} - Correlation ID: ${serverResponse.correlation_id || NOT_AVAILABLE} - Trace ID: ${serverResponse.trace_id || NOT_AVAILABLE}`;
|
|
52
|
+
const serverErrorNo = serverResponse.error_codes?.length
|
|
53
|
+
? serverResponse.error_codes[0]
|
|
54
|
+
: undefined;
|
|
55
|
+
const serverError = new ServerError(serverResponse.error || "", serverResponse.correlation_id || "", errString, serverResponse.suberror, serverErrorNo, serverResponse.status);
|
|
56
|
+
// check if 500 error
|
|
57
|
+
if (refreshAccessToken &&
|
|
58
|
+
serverResponse.status &&
|
|
59
|
+
serverResponse.status >=
|
|
60
|
+
HTTP_SERVER_ERROR_RANGE_START &&
|
|
61
|
+
serverResponse.status <= HTTP_SERVER_ERROR_RANGE_END) {
|
|
62
|
+
this.logger.warning(`16ks7j ${serverError}`, correlationId);
|
|
63
|
+
// don't throw an exception, but alert the user via a log that the token was unable to be refreshed
|
|
64
|
+
return;
|
|
65
|
+
// check if 400 error
|
|
66
|
+
}
|
|
67
|
+
else if (refreshAccessToken &&
|
|
68
|
+
serverResponse.status &&
|
|
69
|
+
serverResponse.status >=
|
|
70
|
+
HTTP_CLIENT_ERROR_RANGE_START &&
|
|
71
|
+
serverResponse.status <= HTTP_CLIENT_ERROR_RANGE_END) {
|
|
72
|
+
this.logger.warning(`0g61x3 ${serverError}`, correlationId);
|
|
73
|
+
// don't throw an exception, but alert the user via a log that the token was unable to be refreshed
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (isInteractionRequiredError(serverResponse.error, serverResponse.error_description, serverResponse.suberror)) {
|
|
77
|
+
throw new InteractionRequiredAuthError(serverResponse.error || "", serverResponse.correlation_id || "", serverResponse.error_description, serverResponse.suberror, serverResponse.timestamp || "", serverResponse.trace_id || "", serverResponse.claims || "", serverErrorNo);
|
|
78
|
+
}
|
|
79
|
+
throw serverError;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Returns a constructed token response based on given string. Also manages the cache updates and cleanups.
|
|
84
|
+
* @param serverTokenResponse
|
|
85
|
+
* @param authority
|
|
86
|
+
*/
|
|
87
|
+
async handleServerTokenResponse(serverTokenResponse, authority, reqTimestamp, request, apiId, authCodePayload, userAssertionHash, handlingRefreshTokenResponse, forceCacheRefreshTokenResponse, serverRequestId, additionalCacheKeyComponents) {
|
|
88
|
+
// create an idToken object (not entity)
|
|
89
|
+
let idTokenClaims;
|
|
90
|
+
if (serverTokenResponse.id_token) {
|
|
91
|
+
idTokenClaims = extractTokenClaims(serverTokenResponse.id_token || "", this.cryptoObj.base64Decode, request.correlationId);
|
|
92
|
+
// token nonce check (TODO: Add a warning if no nonce is given?)
|
|
93
|
+
if (authCodePayload && authCodePayload.nonce) {
|
|
94
|
+
if (idTokenClaims.nonce !== authCodePayload.nonce) {
|
|
95
|
+
throw createClientAuthError(nonceMismatch, request.correlationId);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
// generate homeAccountId
|
|
100
|
+
this.homeAccountIdentifier = generateHomeAccountId(serverTokenResponse.client_info || "", authority.authorityType, this.logger, this.cryptoObj, request.correlationId, idTokenClaims);
|
|
101
|
+
// save the response tokens
|
|
102
|
+
let requestStateObj;
|
|
103
|
+
if (!!authCodePayload && !!authCodePayload.state) {
|
|
104
|
+
requestStateObj = parseRequestState(this.cryptoObj.base64Decode, authCodePayload.state, request.correlationId);
|
|
105
|
+
}
|
|
106
|
+
// Add keyId from request to serverTokenResponse if defined
|
|
107
|
+
serverTokenResponse.key_id =
|
|
108
|
+
serverTokenResponse.key_id ||
|
|
109
|
+
request.dpopJkt ||
|
|
110
|
+
request.sshKid ||
|
|
111
|
+
undefined;
|
|
112
|
+
if (request.authenticationScheme === AuthenticationScheme.DPOP) {
|
|
113
|
+
if (serverTokenResponse.token_type?.toLowerCase() !==
|
|
114
|
+
AuthenticationScheme.DPOP.toLowerCase()) {
|
|
115
|
+
this.performanceClient?.addFields({
|
|
116
|
+
dpopTokenTypeMismatch: serverTokenResponse.token_type,
|
|
117
|
+
}, request.correlationId);
|
|
118
|
+
throw createClientAuthError(dpopTokenTypeMismatch, request.correlationId);
|
|
119
|
+
}
|
|
120
|
+
serverTokenResponse.token_type =
|
|
121
|
+
AuthenticationScheme.DPOP;
|
|
122
|
+
}
|
|
123
|
+
// Compute components once for entity storage (fallback if hash not provided by client)
|
|
124
|
+
const attributeTokenPartition = serializeAttributeTokens(request.attributeTokens);
|
|
125
|
+
const cacheKeyComponents = additionalCacheKeyComponents ??
|
|
126
|
+
(attributeTokenPartition
|
|
127
|
+
? {
|
|
128
|
+
attribute_tokens: attributeTokenPartition,
|
|
129
|
+
}
|
|
130
|
+
: undefined);
|
|
131
|
+
const cacheRecord = this.generateCacheRecord(serverTokenResponse, authority, reqTimestamp, request, idTokenClaims, userAssertionHash, authCodePayload, cacheKeyComponents);
|
|
132
|
+
let cacheContext;
|
|
133
|
+
try {
|
|
134
|
+
if (this.persistencePlugin && this.serializableCache) {
|
|
135
|
+
this.logger.verbose("0jbz5k", request.correlationId);
|
|
136
|
+
cacheContext = new TokenCacheContext(this.serializableCache, true);
|
|
137
|
+
await this.persistencePlugin.beforeCacheAccess(cacheContext);
|
|
138
|
+
}
|
|
139
|
+
/*
|
|
140
|
+
* When saving a refreshed tokens to the cache, it is expected that the account that was used is present in the cache.
|
|
141
|
+
* If not present, we should return null, as it's the case that another application called removeAccount in between
|
|
142
|
+
* the calls to getAllAccounts and acquireTokenSilent. We should not overwrite that removal, unless explicitly flagged by
|
|
143
|
+
* the developer, as in the case of refresh token flow used in ADAL Node to MSAL Node migration.
|
|
144
|
+
*/
|
|
145
|
+
if (handlingRefreshTokenResponse &&
|
|
146
|
+
!forceCacheRefreshTokenResponse &&
|
|
147
|
+
cacheRecord.account) {
|
|
148
|
+
const cachedAccounts = this.cacheStorage.getAllAccounts({
|
|
149
|
+
homeAccountId: cacheRecord.account.homeAccountId,
|
|
150
|
+
environment: cacheRecord.account.environment,
|
|
151
|
+
}, request.correlationId);
|
|
152
|
+
if (cachedAccounts.length < 1) {
|
|
153
|
+
this.logger.warning("1gmt66", request.correlationId);
|
|
154
|
+
this.performanceClient?.addFields({
|
|
155
|
+
acntLoggedOut: true,
|
|
156
|
+
}, request.correlationId);
|
|
157
|
+
return await ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, this.performanceClient, {
|
|
158
|
+
idTokenClaims,
|
|
159
|
+
requestState: requestStateObj,
|
|
160
|
+
requestId: serverRequestId,
|
|
161
|
+
tokenBindingKeyManager: this.tokenBindingKeyManager,
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
await this.cacheStorage.saveCacheRecord(cacheRecord, request.correlationId, isKmsi(idTokenClaims || {}), apiId, request.storeInCache);
|
|
166
|
+
}
|
|
167
|
+
finally {
|
|
168
|
+
if (this.persistencePlugin &&
|
|
169
|
+
this.serializableCache &&
|
|
170
|
+
cacheContext) {
|
|
171
|
+
this.logger.verbose("1bh17u", request.correlationId);
|
|
172
|
+
await this.persistencePlugin.afterCacheAccess(cacheContext);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, this.performanceClient, {
|
|
176
|
+
idTokenClaims,
|
|
177
|
+
requestState: requestStateObj,
|
|
178
|
+
serverTokenResponse,
|
|
179
|
+
requestId: serverRequestId,
|
|
180
|
+
tokenBindingKeyManager: this.tokenBindingKeyManager,
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Generates CacheRecord
|
|
185
|
+
* @param serverTokenResponse
|
|
186
|
+
* @param idTokenObj
|
|
187
|
+
* @param authority
|
|
188
|
+
*/
|
|
189
|
+
generateCacheRecord(serverTokenResponse, authority, reqTimestamp, request, idTokenClaims, userAssertionHash, authCodePayload, additionalCacheKeyComponents) {
|
|
190
|
+
const env = authority.getPreferredCache();
|
|
191
|
+
if (!env) {
|
|
192
|
+
throw createClientAuthError(invalidCacheEnvironment, request.correlationId);
|
|
193
|
+
}
|
|
194
|
+
const claimsTenantId = getTenantIdFromIdTokenClaims(idTokenClaims);
|
|
195
|
+
// IdToken: non AAD scenarios can have empty realm
|
|
196
|
+
let cachedIdToken;
|
|
197
|
+
let cachedAccount;
|
|
198
|
+
if (serverTokenResponse.id_token && !!idTokenClaims) {
|
|
199
|
+
cachedIdToken = createIdTokenEntity(this.homeAccountIdentifier, env, serverTokenResponse.id_token, this.clientId, claimsTenantId || "");
|
|
200
|
+
cachedAccount = buildAccountToCache(this.cacheStorage, authority, this.homeAccountIdentifier, this.cryptoObj.base64Decode, request.correlationId, idTokenClaims, serverTokenResponse.client_info, env, claimsTenantId, authCodePayload, undefined, // nativeAccountId
|
|
201
|
+
this.logger, this.performanceClient);
|
|
202
|
+
}
|
|
203
|
+
// AccessToken
|
|
204
|
+
let cachedAccessToken = null;
|
|
205
|
+
if (serverTokenResponse.access_token) {
|
|
206
|
+
// If scopes not returned in server response, use request scopes
|
|
207
|
+
const responseScopes = serverTokenResponse.scope
|
|
208
|
+
? ScopeSet.fromString(serverTokenResponse.scope, request.correlationId)
|
|
209
|
+
: new ScopeSet(request.scopes || [], request.correlationId);
|
|
210
|
+
/*
|
|
211
|
+
* Use timestamp calculated before request
|
|
212
|
+
* Server may return timestamps as strings, parse to numbers if so.
|
|
213
|
+
*/
|
|
214
|
+
const expiresIn = (typeof serverTokenResponse.expires_in === "string"
|
|
215
|
+
? parseInt(serverTokenResponse.expires_in, 10)
|
|
216
|
+
: serverTokenResponse.expires_in) || 0;
|
|
217
|
+
const extExpiresIn = (typeof serverTokenResponse.ext_expires_in === "string"
|
|
218
|
+
? parseInt(serverTokenResponse.ext_expires_in, 10)
|
|
219
|
+
: serverTokenResponse.ext_expires_in) || 0;
|
|
220
|
+
const refreshIn = (typeof serverTokenResponse.refresh_in === "string"
|
|
221
|
+
? parseInt(serverTokenResponse.refresh_in, 10)
|
|
222
|
+
: serverTokenResponse.refresh_in) || undefined;
|
|
223
|
+
const tokenExpirationSeconds = reqTimestamp + expiresIn;
|
|
224
|
+
const extendedTokenExpirationSeconds = tokenExpirationSeconds + extExpiresIn;
|
|
225
|
+
const refreshOnSeconds = refreshIn && refreshIn > 0
|
|
226
|
+
? reqTimestamp + refreshIn
|
|
227
|
+
: undefined;
|
|
228
|
+
// non AAD scenarios can have empty realm
|
|
229
|
+
cachedAccessToken = createAccessTokenEntity(this.homeAccountIdentifier, env, serverTokenResponse.access_token, this.clientId, claimsTenantId || authority.tenant || "", responseScopes.printScopes(), tokenExpirationSeconds, extendedTokenExpirationSeconds, this.cryptoObj.base64Decode, request.correlationId, refreshOnSeconds, serverTokenResponse.token_type, userAssertionHash, serverTokenResponse.key_id, additionalCacheKeyComponents);
|
|
230
|
+
// Set resource (to be used for MCP scenarios)
|
|
231
|
+
const resource = request.resource || null;
|
|
232
|
+
if (resource) {
|
|
233
|
+
cachedAccessToken.resource = resource;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
// refreshToken
|
|
237
|
+
let cachedRefreshToken = null;
|
|
238
|
+
if (serverTokenResponse.refresh_token) {
|
|
239
|
+
let rtExpiresOn;
|
|
240
|
+
if (serverTokenResponse.refresh_token_expires_in) {
|
|
241
|
+
const rtExpiresIn = typeof serverTokenResponse.refresh_token_expires_in ===
|
|
242
|
+
"string"
|
|
243
|
+
? parseInt(serverTokenResponse.refresh_token_expires_in, 10)
|
|
244
|
+
: serverTokenResponse.refresh_token_expires_in;
|
|
245
|
+
rtExpiresOn = reqTimestamp + rtExpiresIn;
|
|
246
|
+
this.performanceClient?.addFields({ ntwkRtExpiresOnSeconds: rtExpiresOn }, request.correlationId);
|
|
247
|
+
}
|
|
248
|
+
cachedRefreshToken = createRefreshTokenEntity(this.homeAccountIdentifier, env, serverTokenResponse.refresh_token, this.clientId, serverTokenResponse.foci, userAssertionHash, rtExpiresOn);
|
|
249
|
+
}
|
|
250
|
+
// appMetadata
|
|
251
|
+
let cachedAppMetadata = null;
|
|
252
|
+
if (serverTokenResponse.foci) {
|
|
253
|
+
cachedAppMetadata = {
|
|
254
|
+
clientId: this.clientId,
|
|
255
|
+
environment: env,
|
|
256
|
+
familyId: serverTokenResponse.foci,
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
return {
|
|
260
|
+
account: cachedAccount,
|
|
261
|
+
idToken: cachedIdToken,
|
|
262
|
+
accessToken: cachedAccessToken,
|
|
263
|
+
refreshToken: cachedRefreshToken,
|
|
264
|
+
appMetadata: cachedAppMetadata,
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Creates an @AuthenticationResult from @CacheRecord , @IdToken , and a boolean that states whether or not the result is from cache.
|
|
269
|
+
*
|
|
270
|
+
* Optionally takes a state string that is set as-is in the response.
|
|
271
|
+
*
|
|
272
|
+
* @param cacheRecord
|
|
273
|
+
* @param idTokenObj
|
|
274
|
+
* @param fromTokenCache
|
|
275
|
+
* @param stateString
|
|
276
|
+
*/
|
|
277
|
+
static async generateAuthenticationResult(cryptoObj, authority, cacheRecord, fromTokenCache, request, performanceClient, options = {}) {
|
|
278
|
+
const { idTokenClaims, requestState, serverTokenResponse, requestId, tokenBindingKeyManager = DEFAULT_TOKEN_BINDING_KEY_MANAGER, } = options;
|
|
279
|
+
let accessToken = "";
|
|
280
|
+
let responseScopes = [];
|
|
281
|
+
let expiresOn = null;
|
|
282
|
+
let extExpiresOn;
|
|
283
|
+
let refreshOn;
|
|
284
|
+
let familyId = "";
|
|
285
|
+
let dpopProof;
|
|
286
|
+
if (cacheRecord.accessToken) {
|
|
287
|
+
const accessTokenType = cacheRecord.accessToken.tokenType?.toLowerCase();
|
|
288
|
+
/*
|
|
289
|
+
* if the request object has `popKid` property, `signPopToken` will be set to false and
|
|
290
|
+
* the token will be returned unsigned
|
|
291
|
+
*/
|
|
292
|
+
if (cacheRecord.accessToken.tokenType ===
|
|
293
|
+
AuthenticationScheme.POP &&
|
|
294
|
+
!request.popKid) {
|
|
295
|
+
const popTokenGenerator = new PopTokenGenerator(cryptoObj, tokenBindingKeyManager, performanceClient);
|
|
296
|
+
const { secret, keyId } = cacheRecord.accessToken;
|
|
297
|
+
if (!keyId) {
|
|
298
|
+
throw createClientAuthError(keyIdMissing, request.correlationId);
|
|
299
|
+
}
|
|
300
|
+
accessToken = await popTokenGenerator.signPopToken(secret, keyId, request);
|
|
301
|
+
}
|
|
302
|
+
else {
|
|
303
|
+
accessToken = cacheRecord.accessToken.secret;
|
|
304
|
+
}
|
|
305
|
+
if (accessTokenType ===
|
|
306
|
+
AuthenticationScheme.DPOP.toLowerCase()) {
|
|
307
|
+
if (!cacheRecord.accessToken.keyId) {
|
|
308
|
+
throw createClientAuthError(keyIdMissing, request.correlationId);
|
|
309
|
+
}
|
|
310
|
+
const dpopProofGenerator = new DpopProofGenerator(cryptoObj, tokenBindingKeyManager);
|
|
311
|
+
dpopProof = await dpopProofGenerator.generateResourceProof({
|
|
312
|
+
htu: request.resourceRequestUri,
|
|
313
|
+
htm: request.resourceRequestMethod,
|
|
314
|
+
accessToken: cacheRecord.accessToken.secret,
|
|
315
|
+
}, cacheRecord.accessToken.keyId, request.correlationId);
|
|
316
|
+
}
|
|
317
|
+
responseScopes = ScopeSet.fromString(cacheRecord.accessToken.target, request.correlationId).asArray();
|
|
318
|
+
// Access token expiresOn cached in seconds, converting to Date for AuthenticationResult
|
|
319
|
+
expiresOn = toDateFromSeconds(cacheRecord.accessToken.expiresOn);
|
|
320
|
+
extExpiresOn = toDateFromSeconds(cacheRecord.accessToken.extendedExpiresOn);
|
|
321
|
+
if (cacheRecord.accessToken.refreshOn) {
|
|
322
|
+
refreshOn = toDateFromSeconds(cacheRecord.accessToken.refreshOn);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
if (cacheRecord.appMetadata) {
|
|
326
|
+
familyId =
|
|
327
|
+
cacheRecord.appMetadata.familyId === THE_FAMILY_ID
|
|
328
|
+
? THE_FAMILY_ID
|
|
329
|
+
: "";
|
|
330
|
+
}
|
|
331
|
+
const uid = idTokenClaims?.oid || idTokenClaims?.sub || "";
|
|
332
|
+
const tid = idTokenClaims?.tid || "";
|
|
333
|
+
/*
|
|
334
|
+
* Surface the sovereign enclave for telemetry. This runs for both freshly acquired
|
|
335
|
+
* and cache-served tokens because SilentFlowClient shares this method, so the field
|
|
336
|
+
* is present on silent requests that never hit the network.
|
|
337
|
+
*/
|
|
338
|
+
const regionSubScope = idTokenClaims?.tenant_region_sub_scope;
|
|
339
|
+
if (typeof regionSubScope === "string") {
|
|
340
|
+
performanceClient?.addFields({ regionSubScope }, request.correlationId);
|
|
341
|
+
}
|
|
342
|
+
// for hybrid + native bridge enablement, send back the native account Id
|
|
343
|
+
if (serverTokenResponse?.spa_accountid && !!cacheRecord.account) {
|
|
344
|
+
// Set on deprecated top-level for downgrade compat
|
|
345
|
+
cacheRecord.account.nativeAccountId =
|
|
346
|
+
serverTokenResponse?.spa_accountid;
|
|
347
|
+
// Set on the matching tenant profile (source of truth)
|
|
348
|
+
const targetTenantId = tid || cacheRecord.account.realm;
|
|
349
|
+
if (cacheRecord.account.tenantProfiles) {
|
|
350
|
+
const matchingProfile = cacheRecord.account.tenantProfiles.find((tp) => tp.tenantId === targetTenantId);
|
|
351
|
+
if (matchingProfile) {
|
|
352
|
+
matchingProfile.nativeAccountId =
|
|
353
|
+
serverTokenResponse.spa_accountid;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
const accountInfo = cacheRecord.account
|
|
358
|
+
? updateAccountTenantProfileData(getAccountInfo(cacheRecord.account), undefined, // tenantProfile optional
|
|
359
|
+
idTokenClaims, cacheRecord.idToken?.secret)
|
|
360
|
+
: null;
|
|
361
|
+
return {
|
|
362
|
+
authority: authority.canonicalAuthority,
|
|
363
|
+
uniqueId: uid,
|
|
364
|
+
tenantId: tid,
|
|
365
|
+
scopes: responseScopes,
|
|
366
|
+
account: accountInfo,
|
|
367
|
+
idToken: cacheRecord?.idToken?.secret || "",
|
|
368
|
+
idTokenClaims: idTokenClaims || {},
|
|
369
|
+
accessToken: accessToken,
|
|
370
|
+
dpopProof,
|
|
371
|
+
fromCache: fromTokenCache,
|
|
372
|
+
expiresOn: expiresOn,
|
|
373
|
+
extExpiresOn: extExpiresOn,
|
|
374
|
+
refreshOn: refreshOn,
|
|
375
|
+
correlationId: request.correlationId,
|
|
376
|
+
requestId: requestId || "",
|
|
377
|
+
familyId: familyId,
|
|
378
|
+
tokenType: cacheRecord.accessToken?.tokenType?.toLowerCase() ===
|
|
379
|
+
AuthenticationScheme.DPOP.toLowerCase()
|
|
380
|
+
? AuthenticationScheme.DPOP
|
|
381
|
+
: cacheRecord.accessToken?.tokenType || "",
|
|
382
|
+
state: requestState ? requestState.userRequestState : "",
|
|
383
|
+
cloudGraphHostName: cacheRecord.account?.cloudGraphHostName || "",
|
|
384
|
+
msGraphHost: cacheRecord.account?.msGraphHost || "",
|
|
385
|
+
code: serverTokenResponse?.spa_code,
|
|
386
|
+
fromPlatformBroker: false,
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
/** @internal */
|
|
391
|
+
function buildAccountToCache(cacheStorage, authority, homeAccountId, base64Decode, correlationId, idTokenClaims, clientInfo, environment, claimsTenantId, authCodePayload, nativeAccountId, logger, performanceClient) {
|
|
392
|
+
logger?.verbose("09jz0t", correlationId);
|
|
393
|
+
/*
|
|
394
|
+
* Check if base account is already cached. Filter by homeAccountId (identifies
|
|
395
|
+
* the user's home identity) and environment (identifies the cloud) — the two
|
|
396
|
+
* tenant-agnostic properties that uniquely locate a base AccountEntity.
|
|
397
|
+
*/
|
|
398
|
+
const accountEnvironment = environment || authority.getPreferredCache();
|
|
399
|
+
const matchedAccounts = cacheStorage.getAccountsFilteredBy({ homeAccountId, environment: accountEnvironment }, correlationId);
|
|
400
|
+
performanceClient?.addFields({ cacheMatchedAccounts: matchedAccounts.length }, correlationId);
|
|
401
|
+
if (matchedAccounts.length > 1) {
|
|
402
|
+
/*
|
|
403
|
+
* Base accounts are expected to be unique for a given homeAccountId in normal cache usage.
|
|
404
|
+
* If multiple matches exist, ignore the cache hit rather than arbitrarily choosing one.
|
|
405
|
+
*/
|
|
406
|
+
logger?.warning("0x7ad1", correlationId);
|
|
407
|
+
}
|
|
408
|
+
const cachedAccount = matchedAccounts.length === 1 ? matchedAccounts[0] : null;
|
|
409
|
+
const baseAccount = cachedAccount ||
|
|
410
|
+
createAccountEntity({
|
|
411
|
+
homeAccountId,
|
|
412
|
+
idTokenClaims,
|
|
413
|
+
clientInfo,
|
|
414
|
+
environment,
|
|
415
|
+
cloudGraphHostName: authCodePayload?.cloud_graph_host_name,
|
|
416
|
+
msGraphHost: authCodePayload?.msgraph_host,
|
|
417
|
+
nativeAccountId: nativeAccountId,
|
|
418
|
+
}, authority, correlationId, base64Decode);
|
|
419
|
+
const tenantProfiles = baseAccount.tenantProfiles || [];
|
|
420
|
+
const tenantId = claimsTenantId || baseAccount.realm;
|
|
421
|
+
if (tenantId &&
|
|
422
|
+
!tenantProfiles.find((tenantProfile) => {
|
|
423
|
+
return tenantProfile.tenantId === tenantId;
|
|
424
|
+
})) {
|
|
425
|
+
const newTenantProfile = buildTenantProfile(homeAccountId, baseAccount.localAccountId, tenantId, nativeAccountId, idTokenClaims);
|
|
426
|
+
tenantProfiles.push(newTenantProfile);
|
|
427
|
+
}
|
|
428
|
+
baseAccount.tenantProfiles = tenantProfiles;
|
|
429
|
+
return baseAccount;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
export { ResponseHandler, buildAccountToCache };
|