@azure/msal-common 14.0.2 → 14.1.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/account/AccountInfo.d.ts +32 -32
- package/dist/account/AuthToken.d.ts +17 -20
- package/dist/account/AuthToken.d.ts.map +1 -1
- package/dist/account/AuthToken.mjs +61 -51
- package/dist/account/AuthToken.mjs.map +1 -1
- package/dist/account/CcsCredential.d.ts +9 -9
- package/dist/account/CcsCredential.mjs +8 -8
- package/dist/account/CcsCredential.mjs.map +1 -1
- package/dist/account/ClientCredentials.d.ts +14 -14
- package/dist/account/ClientInfo.d.ts +19 -19
- package/dist/account/ClientInfo.d.ts.map +1 -1
- package/dist/account/ClientInfo.mjs +39 -39
- package/dist/account/ClientInfo.mjs.map +1 -1
- package/dist/account/TokenClaims.d.ts +65 -65
- package/dist/authority/Authority.d.ts +235 -235
- package/dist/authority/Authority.d.ts.map +1 -1
- package/dist/authority/Authority.mjs +743 -765
- package/dist/authority/Authority.mjs.map +1 -1
- package/dist/authority/AuthorityFactory.d.ts +31 -31
- package/dist/authority/AuthorityFactory.d.ts.map +1 -1
- package/dist/authority/AuthorityFactory.mjs +52 -51
- package/dist/authority/AuthorityFactory.mjs.map +1 -1
- package/dist/authority/AuthorityMetadata.d.ts +623 -623
- package/dist/authority/AuthorityMetadata.mjs +884 -884
- package/dist/authority/AuthorityMetadata.mjs.map +1 -1
- package/dist/authority/AuthorityOptions.d.ts +21 -21
- package/dist/authority/AuthorityOptions.mjs +18 -18
- package/dist/authority/AuthorityOptions.mjs.map +1 -1
- package/dist/authority/AuthorityType.d.ts +10 -10
- package/dist/authority/AuthorityType.mjs +13 -13
- package/dist/authority/AuthorityType.mjs.map +1 -1
- package/dist/authority/AzureRegion.d.ts +1 -1
- package/dist/authority/AzureRegionConfiguration.d.ts +5 -5
- package/dist/authority/CloudDiscoveryMetadata.d.ts +5 -5
- package/dist/authority/CloudInstanceDiscoveryErrorResponse.d.ts +13 -13
- package/dist/authority/CloudInstanceDiscoveryErrorResponse.mjs +8 -8
- package/dist/authority/CloudInstanceDiscoveryErrorResponse.mjs.map +1 -1
- package/dist/authority/CloudInstanceDiscoveryResponse.d.ts +9 -9
- package/dist/authority/CloudInstanceDiscoveryResponse.mjs +8 -8
- package/dist/authority/CloudInstanceDiscoveryResponse.mjs.map +1 -1
- package/dist/authority/ImdsOptions.d.ts +5 -5
- package/dist/authority/OIDCOptions.d.ts +8 -8
- package/dist/authority/OpenIdConfigResponse.d.ts +11 -11
- package/dist/authority/OpenIdConfigResponse.mjs +10 -10
- package/dist/authority/OpenIdConfigResponse.mjs.map +1 -1
- package/dist/authority/ProtocolMode.d.ts +8 -8
- package/dist/authority/ProtocolMode.mjs +11 -11
- package/dist/authority/ProtocolMode.mjs.map +1 -1
- package/dist/authority/RegionDiscovery.d.ts +32 -30
- package/dist/authority/RegionDiscovery.d.ts.map +1 -1
- package/dist/authority/RegionDiscovery.mjs +107 -108
- package/dist/authority/RegionDiscovery.mjs.map +1 -1
- package/dist/authority/RegionDiscoveryMetadata.d.ts +6 -6
- package/dist/broker/nativeBroker/INativeBrokerPlugin.d.ts +15 -15
- package/dist/cache/CacheManager.d.ts +446 -446
- package/dist/cache/CacheManager.d.ts.map +1 -1
- package/dist/cache/CacheManager.mjs +1001 -1025
- package/dist/cache/CacheManager.mjs.map +1 -1
- package/dist/cache/entities/AccessTokenEntity.d.ts +56 -56
- package/dist/cache/entities/AccessTokenEntity.d.ts.map +1 -1
- package/dist/cache/entities/AccessTokenEntity.mjs +112 -114
- package/dist/cache/entities/AccessTokenEntity.mjs.map +1 -1
- package/dist/cache/entities/AccountEntity.d.ts +101 -101
- package/dist/cache/entities/AccountEntity.d.ts.map +1 -1
- package/dist/cache/entities/AccountEntity.mjs +222 -223
- package/dist/cache/entities/AccountEntity.mjs.map +1 -1
- package/dist/cache/entities/AppMetadataEntity.d.ts +39 -39
- package/dist/cache/entities/AppMetadataEntity.mjs +66 -66
- package/dist/cache/entities/AppMetadataEntity.mjs.map +1 -1
- package/dist/cache/entities/AuthorityMetadataEntity.d.ts +48 -48
- package/dist/cache/entities/AuthorityMetadataEntity.mjs +78 -78
- package/dist/cache/entities/AuthorityMetadataEntity.mjs.map +1 -1
- package/dist/cache/entities/CacheRecord.d.ts +14 -14
- package/dist/cache/entities/CacheRecord.mjs +14 -14
- package/dist/cache/entities/CacheRecord.mjs.map +1 -1
- package/dist/cache/entities/CredentialEntity.d.ts +88 -88
- package/dist/cache/entities/CredentialEntity.d.ts.map +1 -1
- package/dist/cache/entities/CredentialEntity.mjs +138 -137
- package/dist/cache/entities/CredentialEntity.mjs.map +1 -1
- package/dist/cache/entities/IdTokenEntity.d.ts +34 -34
- package/dist/cache/entities/IdTokenEntity.mjs +56 -56
- package/dist/cache/entities/IdTokenEntity.mjs.map +1 -1
- package/dist/cache/entities/RefreshTokenEntity.d.ts +36 -36
- package/dist/cache/entities/RefreshTokenEntity.mjs +59 -59
- package/dist/cache/entities/RefreshTokenEntity.mjs.map +1 -1
- package/dist/cache/entities/ServerTelemetryEntity.d.ts +12 -12
- package/dist/cache/entities/ServerTelemetryEntity.mjs +27 -27
- package/dist/cache/entities/ServerTelemetryEntity.mjs.map +1 -1
- package/dist/cache/entities/ThrottlingEntity.d.ts +13 -13
- package/dist/cache/entities/ThrottlingEntity.mjs +23 -23
- package/dist/cache/entities/ThrottlingEntity.mjs.map +1 -1
- package/dist/cache/interface/ICacheManager.d.ts +166 -166
- package/dist/cache/interface/ICachePlugin.d.ts +5 -5
- package/dist/cache/interface/ISerializableTokenCache.d.ts +4 -4
- package/dist/cache/persistence/TokenCacheContext.d.ts +23 -23
- package/dist/cache/persistence/TokenCacheContext.mjs +25 -25
- package/dist/cache/persistence/TokenCacheContext.mjs.map +1 -1
- package/dist/cache/utils/CacheTypes.d.ts +69 -69
- package/dist/client/AuthorizationCodeClient.d.ts +73 -73
- package/dist/client/AuthorizationCodeClient.d.ts.map +1 -1
- package/dist/client/AuthorizationCodeClient.mjs +412 -440
- package/dist/client/AuthorizationCodeClient.mjs.map +1 -1
- package/dist/client/BaseClient.d.ts +51 -51
- package/dist/client/BaseClient.d.ts.map +1 -1
- package/dist/client/BaseClient.mjs +101 -94
- package/dist/client/BaseClient.mjs.map +1 -1
- package/dist/client/RefreshTokenClient.d.ts +35 -35
- package/dist/client/RefreshTokenClient.d.ts.map +1 -1
- package/dist/client/RefreshTokenClient.mjs +185 -243
- package/dist/client/RefreshTokenClient.mjs.map +1 -1
- package/dist/client/SilentFlowClient.d.ts +26 -25
- package/dist/client/SilentFlowClient.d.ts.map +1 -1
- package/dist/client/SilentFlowClient.mjs +128 -104
- package/dist/client/SilentFlowClient.mjs.map +1 -1
- package/dist/config/AppTokenProvider.d.ts +38 -38
- package/dist/config/ClientConfiguration.d.ts +150 -150
- package/dist/config/ClientConfiguration.d.ts.map +1 -1
- package/dist/config/ClientConfiguration.mjs +99 -100
- package/dist/config/ClientConfiguration.mjs.map +1 -1
- package/dist/crypto/ICrypto.d.ts +62 -62
- package/dist/crypto/ICrypto.d.ts.map +1 -1
- package/dist/crypto/ICrypto.mjs +35 -43
- package/dist/crypto/ICrypto.mjs.map +1 -1
- package/dist/crypto/IGuidGenerator.d.ts +4 -4
- package/dist/crypto/JoseHeader.d.ts +22 -22
- package/dist/crypto/JoseHeader.d.ts.map +1 -1
- package/dist/crypto/JoseHeader.mjs +39 -38
- package/dist/crypto/JoseHeader.mjs.map +1 -1
- package/dist/crypto/PopTokenGenerator.d.ts +60 -59
- package/dist/crypto/PopTokenGenerator.d.ts.map +1 -1
- package/dist/crypto/PopTokenGenerator.mjs +83 -83
- package/dist/crypto/PopTokenGenerator.mjs.map +1 -1
- package/dist/crypto/SignedHttpRequest.d.ts +11 -11
- package/dist/error/AuthError.d.ts +44 -47
- package/dist/error/AuthError.d.ts.map +1 -1
- package/dist/error/AuthError.mjs +50 -52
- package/dist/error/AuthError.mjs.map +1 -1
- package/dist/error/AuthErrorCodes.d.ts +6 -0
- package/dist/error/AuthErrorCodes.d.ts.map +1 -0
- package/dist/error/AuthErrorCodes.mjs +14 -0
- package/dist/error/AuthErrorCodes.mjs.map +1 -0
- package/dist/error/ClientAuthError.d.ts +232 -412
- package/dist/error/ClientAuthError.d.ts.map +1 -1
- package/dist/error/ClientAuthError.mjs +248 -520
- package/dist/error/ClientAuthError.mjs.map +1 -1
- package/dist/error/ClientAuthErrorCodes.d.ts +44 -0
- package/dist/error/ClientAuthErrorCodes.d.ts.map +1 -0
- package/dist/error/ClientAuthErrorCodes.mjs +52 -0
- package/dist/error/ClientAuthErrorCodes.mjs.map +1 -0
- package/dist/error/ClientConfigurationError.d.ts +128 -222
- package/dist/error/ClientConfigurationError.d.ts.map +1 -1
- package/dist/error/ClientConfigurationError.mjs +140 -281
- package/dist/error/ClientConfigurationError.mjs.map +1 -1
- package/dist/error/ClientConfigurationErrorCodes.d.ts +23 -0
- package/dist/error/ClientConfigurationErrorCodes.d.ts.map +1 -0
- package/dist/error/ClientConfigurationErrorCodes.mjs +31 -0
- package/dist/error/ClientConfigurationErrorCodes.mjs.map +1 -0
- package/dist/error/InteractionRequiredAuthError.d.ts +57 -59
- package/dist/error/InteractionRequiredAuthError.d.ts.map +1 -1
- package/dist/error/InteractionRequiredAuthError.mjs +80 -79
- package/dist/error/InteractionRequiredAuthError.mjs.map +1 -1
- package/dist/error/InteractionRequiredAuthErrorCodes.d.ts +6 -0
- package/dist/error/InteractionRequiredAuthErrorCodes.d.ts.map +1 -0
- package/dist/error/InteractionRequiredAuthErrorCodes.mjs +16 -0
- package/dist/error/InteractionRequiredAuthErrorCodes.mjs.map +1 -0
- package/dist/error/JoseHeaderError.d.ts +15 -28
- package/dist/error/JoseHeaderError.d.ts.map +1 -1
- package/dist/error/JoseHeaderError.mjs +24 -40
- package/dist/error/JoseHeaderError.mjs.map +1 -1
- package/dist/error/JoseHeaderErrorCodes.d.ts +3 -0
- package/dist/error/JoseHeaderErrorCodes.d.ts.map +1 -0
- package/dist/error/JoseHeaderErrorCodes.mjs +11 -0
- package/dist/error/JoseHeaderErrorCodes.mjs.map +1 -0
- package/dist/error/ServerError.d.ts +7 -7
- package/dist/error/ServerError.mjs +14 -14
- package/dist/error/ServerError.mjs.map +1 -1
- package/dist/index.cjs +8727 -8978
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +96 -96
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +17 -7
- package/dist/index.mjs.map +1 -1
- package/dist/logger/Logger.d.ts +95 -95
- package/dist/logger/Logger.d.ts.map +1 -1
- package/dist/logger/Logger.mjs +188 -198
- package/dist/logger/Logger.mjs.map +1 -1
- package/dist/network/INetworkModule.d.ts +29 -29
- package/dist/network/INetworkModule.d.ts.map +1 -1
- package/dist/network/INetworkModule.mjs +14 -15
- package/dist/network/INetworkModule.mjs.map +1 -1
- package/dist/network/NetworkManager.d.ts +33 -33
- package/dist/network/NetworkManager.d.ts.map +1 -1
- package/dist/network/NetworkManager.mjs +36 -35
- package/dist/network/NetworkManager.mjs.map +1 -1
- package/dist/network/RequestThumbprint.d.ts +16 -16
- package/dist/network/ThrottlingUtils.d.ts +42 -42
- package/dist/network/ThrottlingUtils.mjs +95 -95
- package/dist/network/ThrottlingUtils.mjs.map +1 -1
- package/dist/packageMetadata.d.ts +2 -2
- package/dist/packageMetadata.mjs +4 -4
- package/dist/packageMetadata.mjs.map +1 -1
- package/dist/request/AuthenticationHeaderParser.d.ts +19 -19
- package/dist/request/AuthenticationHeaderParser.d.ts.map +1 -1
- package/dist/request/AuthenticationHeaderParser.mjs +58 -57
- package/dist/request/AuthenticationHeaderParser.mjs.map +1 -1
- package/dist/request/BaseAuthRequest.d.ts +40 -40
- package/dist/request/CommonAuthorizationCodeRequest.d.ts +27 -27
- package/dist/request/CommonAuthorizationUrlRequest.d.ts +50 -50
- package/dist/request/CommonClientCredentialRequest.d.ts +17 -17
- package/dist/request/CommonDeviceCodeRequest.d.ts +21 -21
- package/dist/request/CommonEndSessionRequest.d.ts +21 -21
- package/dist/request/CommonOnBehalfOfRequest.d.ts +13 -13
- package/dist/request/CommonRefreshTokenRequest.d.ts +19 -19
- package/dist/request/CommonSilentFlowRequest.d.ts +18 -18
- package/dist/request/CommonUsernamePasswordRequest.d.ts +17 -17
- package/dist/request/NativeRequest.d.ts +19 -19
- package/dist/request/NativeSignOutRequest.d.ts +5 -5
- package/dist/request/RequestParameterBuilder.d.ts +217 -217
- package/dist/request/RequestParameterBuilder.d.ts.map +1 -1
- package/dist/request/RequestParameterBuilder.mjs +383 -383
- package/dist/request/RequestParameterBuilder.mjs.map +1 -1
- package/dist/request/RequestValidator.d.ts +33 -33
- package/dist/request/RequestValidator.d.ts.map +1 -1
- package/dist/request/RequestValidator.mjs +83 -84
- package/dist/request/RequestValidator.mjs.map +1 -1
- package/dist/request/ScopeSet.d.ts +88 -88
- package/dist/request/ScopeSet.d.ts.map +1 -1
- package/dist/request/ScopeSet.mjs +201 -199
- package/dist/request/ScopeSet.mjs.map +1 -1
- package/dist/request/StoreInCache.d.ts +8 -8
- package/dist/response/AuthenticationResult.d.ts +41 -39
- package/dist/response/AuthenticationResult.d.ts.map +1 -1
- package/dist/response/AuthorizationCodePayload.d.ts +13 -13
- package/dist/response/DeviceCodeResponse.d.ts +25 -25
- package/dist/response/ExternalTokenResponse.d.ts +15 -15
- package/dist/response/IMDSBadResponse.d.ts +4 -4
- package/dist/response/ResponseHandler.d.ts +67 -66
- package/dist/response/ResponseHandler.d.ts.map +1 -1
- package/dist/response/ResponseHandler.mjs +316 -297
- package/dist/response/ResponseHandler.mjs.map +1 -1
- package/dist/response/ServerAuthorizationCodeResponse.d.ts +25 -25
- package/dist/response/ServerAuthorizationTokenResponse.d.ts +46 -44
- package/dist/response/ServerAuthorizationTokenResponse.d.ts.map +1 -1
- package/dist/telemetry/performance/IPerformanceClient.d.ts +51 -51
- package/dist/telemetry/performance/IPerformanceClient.d.ts.map +1 -1
- package/dist/telemetry/performance/IPerformanceMeasurement.d.ts +5 -5
- package/dist/telemetry/performance/PerformanceClient.d.ts +191 -191
- package/dist/telemetry/performance/PerformanceClient.d.ts.map +1 -1
- package/dist/telemetry/performance/PerformanceClient.mjs +409 -408
- package/dist/telemetry/performance/PerformanceClient.mjs.map +1 -1
- package/dist/telemetry/performance/PerformanceEvent.d.ts +433 -426
- package/dist/telemetry/performance/PerformanceEvent.d.ts.map +1 -1
- package/dist/telemetry/performance/PerformanceEvent.mjs +234 -226
- package/dist/telemetry/performance/PerformanceEvent.mjs.map +1 -1
- package/dist/telemetry/performance/StubPerformanceClient.d.ts +24 -24
- package/dist/telemetry/performance/StubPerformanceClient.d.ts.map +1 -1
- package/dist/telemetry/performance/StubPerformanceClient.mjs +77 -57
- package/dist/telemetry/performance/StubPerformanceClient.mjs.map +1 -1
- package/dist/telemetry/server/ServerTelemetryManager.d.ts +66 -66
- package/dist/telemetry/server/ServerTelemetryManager.d.ts.map +1 -1
- package/dist/telemetry/server/ServerTelemetryManager.mjs +197 -198
- package/dist/telemetry/server/ServerTelemetryManager.mjs.map +1 -1
- package/dist/telemetry/server/ServerTelemetryRequest.d.ts +8 -8
- package/dist/url/IUri.d.ts +12 -12
- package/dist/url/UrlString.d.ts +83 -83
- package/dist/url/UrlString.d.ts.map +1 -1
- package/dist/url/UrlString.mjs +283 -283
- package/dist/url/UrlString.mjs.map +1 -1
- package/dist/utils/Constants.d.ts +366 -353
- package/dist/utils/Constants.d.ts.map +1 -1
- package/dist/utils/Constants.mjs +377 -360
- package/dist/utils/Constants.mjs.map +1 -1
- package/dist/utils/FunctionWrappers.d.ts +28 -0
- package/dist/utils/FunctionWrappers.d.ts.map +1 -0
- package/dist/utils/FunctionWrappers.mjs +90 -0
- package/dist/utils/FunctionWrappers.mjs.map +1 -0
- package/dist/utils/MsalTypes.d.ts +6 -6
- package/dist/utils/ProtocolUtils.d.ts +42 -42
- package/dist/utils/ProtocolUtils.d.ts.map +1 -1
- package/dist/utils/ProtocolUtils.mjs +71 -73
- package/dist/utils/ProtocolUtils.mjs.map +1 -1
- package/dist/utils/StringUtils.d.ts +40 -53
- package/dist/utils/StringUtils.d.ts.map +1 -1
- package/dist/utils/StringUtils.mjs +95 -126
- package/dist/utils/StringUtils.mjs.map +1 -1
- package/dist/utils/TimeUtils.d.ts +27 -27
- package/dist/utils/TimeUtils.mjs +45 -45
- package/dist/utils/TimeUtils.mjs.map +1 -1
- package/package.json +6 -4
- package/src/account/AccountInfo.ts +44 -0
- package/src/account/AuthToken.ts +71 -0
- package/src/account/CcsCredential.ts +16 -0
- package/src/account/ClientCredentials.ts +20 -0
- package/src/account/ClientInfo.ts +67 -0
- package/src/account/TokenClaims.ts +70 -0
- package/src/authority/Authority.ts +1207 -0
- package/src/authority/AuthorityFactory.ts +118 -0
- package/src/authority/AuthorityMetadata.ts +953 -0
- package/src/authority/AuthorityOptions.ts +40 -0
- package/src/authority/AuthorityType.ts +15 -0
- package/src/authority/AzureRegion.ts +7 -0
- package/src/authority/AzureRegionConfiguration.ts +16 -0
- package/src/authority/CloudDiscoveryMetadata.ts +10 -0
- package/src/authority/CloudInstanceDiscoveryErrorResponse.ts +26 -0
- package/src/authority/CloudInstanceDiscoveryResponse.ts +21 -0
- package/src/authority/ImdsOptions.ts +10 -0
- package/src/authority/OIDCOptions.ts +14 -0
- package/src/authority/OpenIdConfigResponse.ts +24 -0
- package/src/authority/ProtocolMode.ts +13 -0
- package/src/authority/RegionDiscovery.ts +196 -0
- package/src/authority/RegionDiscoveryMetadata.ts +15 -0
- package/src/broker/nativeBroker/INativeBrokerPlugin.ts +29 -0
- package/src/cache/CacheManager.ts +1579 -0
- package/src/cache/entities/AccessTokenEntity.ts +167 -0
- package/src/cache/entities/AccountEntity.ts +314 -0
- package/src/cache/entities/AppMetadataEntity.ts +91 -0
- package/src/cache/entities/AuthorityMetadataEntity.ts +112 -0
- package/src/cache/entities/CacheRecord.ts +33 -0
- package/src/cache/entities/CredentialEntity.ts +220 -0
- package/src/cache/entities/IdTokenEntity.ts +74 -0
- package/src/cache/entities/RefreshTokenEntity.ts +78 -0
- package/src/cache/entities/ServerTelemetryEntity.ts +38 -0
- package/src/cache/entities/ThrottlingEntity.ts +36 -0
- package/src/cache/interface/ICacheManager.ts +218 -0
- package/src/cache/interface/ICachePlugin.ts +11 -0
- package/src/cache/interface/ISerializableTokenCache.ts +9 -0
- package/src/cache/persistence/TokenCacheContext.ts +39 -0
- package/src/cache/utils/CacheTypes.ts +93 -0
- package/src/client/AuthorizationCodeClient.ts +736 -0
- package/src/client/BaseClient.ts +208 -0
- package/src/client/RefreshTokenClient.ts +399 -0
- package/src/client/SilentFlowClient.ts +239 -0
- package/src/config/AppTokenProvider.ts +47 -0
- package/src/config/ClientConfiguration.ts +286 -0
- package/src/crypto/ICrypto.ts +112 -0
- package/src/crypto/IGuidGenerator.ts +9 -0
- package/src/crypto/JoseHeader.ts +58 -0
- package/src/crypto/PopTokenGenerator.ts +160 -0
- package/src/crypto/SignedHttpRequest.ts +16 -0
- package/src/error/AuthError.ts +83 -0
- package/src/error/AuthErrorCodes.ts +10 -0
- package/src/error/ClientAuthError.ts +333 -0
- package/src/error/ClientAuthErrorCodes.ts +51 -0
- package/src/error/ClientConfigurationError.ts +210 -0
- package/src/error/ClientConfigurationErrorCodes.ts +28 -0
- package/src/error/InteractionRequiredAuthError.ts +139 -0
- package/src/error/InteractionRequiredAuthErrorCodes.ts +13 -0
- package/src/error/JoseHeaderError.ts +32 -0
- package/src/error/JoseHeaderErrorCodes.ts +7 -0
- package/src/error/ServerError.ts +18 -0
- package/src/index.ts +226 -0
- package/src/logger/Logger.ts +272 -0
- package/src/network/INetworkModule.ts +60 -0
- package/src/network/NetworkManager.ts +76 -0
- package/src/network/RequestThumbprint.ts +22 -0
- package/src/network/ThrottlingUtils.ts +156 -0
- package/src/packageMetadata.ts +3 -0
- package/src/request/AuthenticationHeaderParser.ts +92 -0
- package/src/request/BaseAuthRequest.ts +46 -0
- package/src/request/CommonAuthorizationCodeRequest.ts +33 -0
- package/src/request/CommonAuthorizationUrlRequest.ts +56 -0
- package/src/request/CommonClientCredentialRequest.ts +23 -0
- package/src/request/CommonDeviceCodeRequest.ts +31 -0
- package/src/request/CommonEndSessionRequest.ts +27 -0
- package/src/request/CommonOnBehalfOfRequest.ts +19 -0
- package/src/request/CommonRefreshTokenRequest.ts +25 -0
- package/src/request/CommonSilentFlowRequest.ts +24 -0
- package/src/request/CommonUsernamePasswordRequest.ts +23 -0
- package/src/request/NativeRequest.ts +25 -0
- package/src/request/NativeSignOutRequest.ts +10 -0
- package/src/request/RequestParameterBuilder.ts +613 -0
- package/src/request/RequestValidator.ts +116 -0
- package/src/request/ScopeSet.ts +246 -0
- package/src/request/StoreInCache.ts +16 -0
- package/src/response/AuthenticationResult.ts +47 -0
- package/src/response/AuthorizationCodePayload.ts +18 -0
- package/src/response/DeviceCodeResponse.ts +31 -0
- package/src/response/ExternalTokenResponse.ts +24 -0
- package/src/response/IMDSBadResponse.ts +9 -0
- package/src/response/ResponseHandler.ts +634 -0
- package/src/response/ServerAuthorizationCodeResponse.ts +33 -0
- package/src/response/ServerAuthorizationTokenResponse.ts +54 -0
- package/src/telemetry/performance/IPerformanceClient.ts +71 -0
- package/src/telemetry/performance/IPerformanceMeasurement.ts +10 -0
- package/src/telemetry/performance/PerformanceClient.ts +636 -0
- package/src/telemetry/performance/PerformanceEvent.ts +542 -0
- package/src/telemetry/performance/StubPerformanceClient.ts +101 -0
- package/src/telemetry/server/ServerTelemetryManager.ts +274 -0
- package/src/telemetry/server/ServerTelemetryRequest.ts +13 -0
- package/src/url/IUri.ts +17 -0
- package/src/url/UrlString.ts +373 -0
- package/src/utils/Constants.ts +444 -0
- package/src/utils/FunctionWrappers.ts +105 -0
- package/src/utils/MsalTypes.ts +9 -0
- package/src/utils/ProtocolUtils.ts +120 -0
- package/src/utils/StringUtils.ts +106 -0
- package/src/utils/TimeUtils.ts +51 -0
- package/dist/account/DecodedAuthToken.d.ts +0 -9
- package/dist/account/DecodedAuthToken.d.ts.map +0 -1
|
@@ -0,0 +1,613 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
AADServerParamKeys,
|
|
8
|
+
Constants,
|
|
9
|
+
ResponseMode,
|
|
10
|
+
SSOTypes,
|
|
11
|
+
CLIENT_INFO,
|
|
12
|
+
AuthenticationScheme,
|
|
13
|
+
ClaimsRequestKeys,
|
|
14
|
+
PasswordGrantConstants,
|
|
15
|
+
OIDC_DEFAULT_SCOPES,
|
|
16
|
+
ThrottlingConstants,
|
|
17
|
+
HeaderNames,
|
|
18
|
+
} from "../utils/Constants";
|
|
19
|
+
import { ScopeSet } from "./ScopeSet";
|
|
20
|
+
import {
|
|
21
|
+
createClientConfigurationError,
|
|
22
|
+
ClientConfigurationErrorCodes,
|
|
23
|
+
} from "../error/ClientConfigurationError";
|
|
24
|
+
import { StringDict } from "../utils/MsalTypes";
|
|
25
|
+
import { RequestValidator } from "./RequestValidator";
|
|
26
|
+
import {
|
|
27
|
+
ApplicationTelemetry,
|
|
28
|
+
LibraryInfo,
|
|
29
|
+
} from "../config/ClientConfiguration";
|
|
30
|
+
import { ServerTelemetryManager } from "../telemetry/server/ServerTelemetryManager";
|
|
31
|
+
import { ClientInfo } from "../account/ClientInfo";
|
|
32
|
+
|
|
33
|
+
/** @internal */
|
|
34
|
+
export class RequestParameterBuilder {
|
|
35
|
+
private parameters: Map<string, string>;
|
|
36
|
+
|
|
37
|
+
constructor() {
|
|
38
|
+
this.parameters = new Map<string, string>();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* add response_type = code
|
|
43
|
+
*/
|
|
44
|
+
addResponseTypeCode(): void {
|
|
45
|
+
this.parameters.set(
|
|
46
|
+
AADServerParamKeys.RESPONSE_TYPE,
|
|
47
|
+
encodeURIComponent(Constants.CODE_RESPONSE_TYPE)
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* add response_type = token id_token
|
|
53
|
+
*/
|
|
54
|
+
addResponseTypeForTokenAndIdToken(): void {
|
|
55
|
+
this.parameters.set(
|
|
56
|
+
AADServerParamKeys.RESPONSE_TYPE,
|
|
57
|
+
encodeURIComponent(
|
|
58
|
+
`${Constants.TOKEN_RESPONSE_TYPE} ${Constants.ID_TOKEN_RESPONSE_TYPE}`
|
|
59
|
+
)
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* add response_mode. defaults to query.
|
|
65
|
+
* @param responseMode
|
|
66
|
+
*/
|
|
67
|
+
addResponseMode(responseMode?: ResponseMode): void {
|
|
68
|
+
this.parameters.set(
|
|
69
|
+
AADServerParamKeys.RESPONSE_MODE,
|
|
70
|
+
encodeURIComponent(responseMode ? responseMode : ResponseMode.QUERY)
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Add flag to indicate STS should attempt to use WAM if available
|
|
76
|
+
*/
|
|
77
|
+
addNativeBroker(): void {
|
|
78
|
+
this.parameters.set(
|
|
79
|
+
AADServerParamKeys.NATIVE_BROKER,
|
|
80
|
+
encodeURIComponent("1")
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* add scopes. set addOidcScopes to false to prevent default scopes in non-user scenarios
|
|
86
|
+
* @param scopeSet
|
|
87
|
+
* @param addOidcScopes
|
|
88
|
+
*/
|
|
89
|
+
addScopes(
|
|
90
|
+
scopes: string[],
|
|
91
|
+
addOidcScopes: boolean = true,
|
|
92
|
+
defaultScopes: Array<string> = OIDC_DEFAULT_SCOPES
|
|
93
|
+
): void {
|
|
94
|
+
// Always add openid to the scopes when adding OIDC scopes
|
|
95
|
+
if (
|
|
96
|
+
addOidcScopes &&
|
|
97
|
+
!defaultScopes.includes("openid") &&
|
|
98
|
+
!scopes.includes("openid")
|
|
99
|
+
) {
|
|
100
|
+
defaultScopes.push("openid");
|
|
101
|
+
}
|
|
102
|
+
const requestScopes = addOidcScopes
|
|
103
|
+
? [...(scopes || []), ...defaultScopes]
|
|
104
|
+
: scopes || [];
|
|
105
|
+
const scopeSet = new ScopeSet(requestScopes);
|
|
106
|
+
this.parameters.set(
|
|
107
|
+
AADServerParamKeys.SCOPE,
|
|
108
|
+
encodeURIComponent(scopeSet.printScopes())
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* add clientId
|
|
114
|
+
* @param clientId
|
|
115
|
+
*/
|
|
116
|
+
addClientId(clientId: string): void {
|
|
117
|
+
this.parameters.set(
|
|
118
|
+
AADServerParamKeys.CLIENT_ID,
|
|
119
|
+
encodeURIComponent(clientId)
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* add redirect_uri
|
|
125
|
+
* @param redirectUri
|
|
126
|
+
*/
|
|
127
|
+
addRedirectUri(redirectUri: string): void {
|
|
128
|
+
RequestValidator.validateRedirectUri(redirectUri);
|
|
129
|
+
this.parameters.set(
|
|
130
|
+
AADServerParamKeys.REDIRECT_URI,
|
|
131
|
+
encodeURIComponent(redirectUri)
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* add post logout redirectUri
|
|
137
|
+
* @param redirectUri
|
|
138
|
+
*/
|
|
139
|
+
addPostLogoutRedirectUri(redirectUri: string): void {
|
|
140
|
+
RequestValidator.validateRedirectUri(redirectUri);
|
|
141
|
+
this.parameters.set(
|
|
142
|
+
AADServerParamKeys.POST_LOGOUT_URI,
|
|
143
|
+
encodeURIComponent(redirectUri)
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* add id_token_hint to logout request
|
|
149
|
+
* @param idTokenHint
|
|
150
|
+
*/
|
|
151
|
+
addIdTokenHint(idTokenHint: string): void {
|
|
152
|
+
this.parameters.set(
|
|
153
|
+
AADServerParamKeys.ID_TOKEN_HINT,
|
|
154
|
+
encodeURIComponent(idTokenHint)
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* add domain_hint
|
|
160
|
+
* @param domainHint
|
|
161
|
+
*/
|
|
162
|
+
addDomainHint(domainHint: string): void {
|
|
163
|
+
this.parameters.set(
|
|
164
|
+
SSOTypes.DOMAIN_HINT,
|
|
165
|
+
encodeURIComponent(domainHint)
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* add login_hint
|
|
171
|
+
* @param loginHint
|
|
172
|
+
*/
|
|
173
|
+
addLoginHint(loginHint: string): void {
|
|
174
|
+
this.parameters.set(SSOTypes.LOGIN_HINT, encodeURIComponent(loginHint));
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Adds the CCS (Cache Credential Service) query parameter for login_hint
|
|
179
|
+
* @param loginHint
|
|
180
|
+
*/
|
|
181
|
+
addCcsUpn(loginHint: string): void {
|
|
182
|
+
this.parameters.set(
|
|
183
|
+
HeaderNames.CCS_HEADER,
|
|
184
|
+
encodeURIComponent(`UPN:${loginHint}`)
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Adds the CCS (Cache Credential Service) query parameter for account object
|
|
190
|
+
* @param loginHint
|
|
191
|
+
*/
|
|
192
|
+
addCcsOid(clientInfo: ClientInfo): void {
|
|
193
|
+
this.parameters.set(
|
|
194
|
+
HeaderNames.CCS_HEADER,
|
|
195
|
+
encodeURIComponent(`Oid:${clientInfo.uid}@${clientInfo.utid}`)
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* add sid
|
|
201
|
+
* @param sid
|
|
202
|
+
*/
|
|
203
|
+
addSid(sid: string): void {
|
|
204
|
+
this.parameters.set(SSOTypes.SID, encodeURIComponent(sid));
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* add claims
|
|
209
|
+
* @param claims
|
|
210
|
+
*/
|
|
211
|
+
addClaims(claims?: string, clientCapabilities?: Array<string>): void {
|
|
212
|
+
const mergedClaims = this.addClientCapabilitiesToClaims(
|
|
213
|
+
claims,
|
|
214
|
+
clientCapabilities
|
|
215
|
+
);
|
|
216
|
+
RequestValidator.validateClaims(mergedClaims);
|
|
217
|
+
this.parameters.set(
|
|
218
|
+
AADServerParamKeys.CLAIMS,
|
|
219
|
+
encodeURIComponent(mergedClaims)
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* add correlationId
|
|
225
|
+
* @param correlationId
|
|
226
|
+
*/
|
|
227
|
+
addCorrelationId(correlationId: string): void {
|
|
228
|
+
this.parameters.set(
|
|
229
|
+
AADServerParamKeys.CLIENT_REQUEST_ID,
|
|
230
|
+
encodeURIComponent(correlationId)
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* add library info query params
|
|
236
|
+
* @param libraryInfo
|
|
237
|
+
*/
|
|
238
|
+
addLibraryInfo(libraryInfo: LibraryInfo): void {
|
|
239
|
+
// Telemetry Info
|
|
240
|
+
this.parameters.set(AADServerParamKeys.X_CLIENT_SKU, libraryInfo.sku);
|
|
241
|
+
this.parameters.set(
|
|
242
|
+
AADServerParamKeys.X_CLIENT_VER,
|
|
243
|
+
libraryInfo.version
|
|
244
|
+
);
|
|
245
|
+
if (libraryInfo.os) {
|
|
246
|
+
this.parameters.set(AADServerParamKeys.X_CLIENT_OS, libraryInfo.os);
|
|
247
|
+
}
|
|
248
|
+
if (libraryInfo.cpu) {
|
|
249
|
+
this.parameters.set(
|
|
250
|
+
AADServerParamKeys.X_CLIENT_CPU,
|
|
251
|
+
libraryInfo.cpu
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Add client telemetry parameters
|
|
258
|
+
* @param appTelemetry
|
|
259
|
+
*/
|
|
260
|
+
addApplicationTelemetry(appTelemetry: ApplicationTelemetry): void {
|
|
261
|
+
if (appTelemetry?.appName) {
|
|
262
|
+
this.parameters.set(
|
|
263
|
+
AADServerParamKeys.X_APP_NAME,
|
|
264
|
+
appTelemetry.appName
|
|
265
|
+
);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
if (appTelemetry?.appVersion) {
|
|
269
|
+
this.parameters.set(
|
|
270
|
+
AADServerParamKeys.X_APP_VER,
|
|
271
|
+
appTelemetry.appVersion
|
|
272
|
+
);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* add prompt
|
|
278
|
+
* @param prompt
|
|
279
|
+
*/
|
|
280
|
+
addPrompt(prompt: string): void {
|
|
281
|
+
RequestValidator.validatePrompt(prompt);
|
|
282
|
+
this.parameters.set(
|
|
283
|
+
`${AADServerParamKeys.PROMPT}`,
|
|
284
|
+
encodeURIComponent(prompt)
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* add state
|
|
290
|
+
* @param state
|
|
291
|
+
*/
|
|
292
|
+
addState(state: string): void {
|
|
293
|
+
if (state) {
|
|
294
|
+
this.parameters.set(
|
|
295
|
+
AADServerParamKeys.STATE,
|
|
296
|
+
encodeURIComponent(state)
|
|
297
|
+
);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* add nonce
|
|
303
|
+
* @param nonce
|
|
304
|
+
*/
|
|
305
|
+
addNonce(nonce: string): void {
|
|
306
|
+
this.parameters.set(
|
|
307
|
+
AADServerParamKeys.NONCE,
|
|
308
|
+
encodeURIComponent(nonce)
|
|
309
|
+
);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* add code_challenge and code_challenge_method
|
|
314
|
+
* - throw if either of them are not passed
|
|
315
|
+
* @param codeChallenge
|
|
316
|
+
* @param codeChallengeMethod
|
|
317
|
+
*/
|
|
318
|
+
addCodeChallengeParams(
|
|
319
|
+
codeChallenge: string,
|
|
320
|
+
codeChallengeMethod: string
|
|
321
|
+
): void {
|
|
322
|
+
RequestValidator.validateCodeChallengeParams(
|
|
323
|
+
codeChallenge,
|
|
324
|
+
codeChallengeMethod
|
|
325
|
+
);
|
|
326
|
+
if (codeChallenge && codeChallengeMethod) {
|
|
327
|
+
this.parameters.set(
|
|
328
|
+
AADServerParamKeys.CODE_CHALLENGE,
|
|
329
|
+
encodeURIComponent(codeChallenge)
|
|
330
|
+
);
|
|
331
|
+
this.parameters.set(
|
|
332
|
+
AADServerParamKeys.CODE_CHALLENGE_METHOD,
|
|
333
|
+
encodeURIComponent(codeChallengeMethod)
|
|
334
|
+
);
|
|
335
|
+
} else {
|
|
336
|
+
throw createClientConfigurationError(
|
|
337
|
+
ClientConfigurationErrorCodes.pkceParamsMissing
|
|
338
|
+
);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* add the `authorization_code` passed by the user to exchange for a token
|
|
344
|
+
* @param code
|
|
345
|
+
*/
|
|
346
|
+
addAuthorizationCode(code: string): void {
|
|
347
|
+
this.parameters.set(AADServerParamKeys.CODE, encodeURIComponent(code));
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* add the `authorization_code` passed by the user to exchange for a token
|
|
352
|
+
* @param code
|
|
353
|
+
*/
|
|
354
|
+
addDeviceCode(code: string): void {
|
|
355
|
+
this.parameters.set(
|
|
356
|
+
AADServerParamKeys.DEVICE_CODE,
|
|
357
|
+
encodeURIComponent(code)
|
|
358
|
+
);
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* add the `refreshToken` passed by the user
|
|
363
|
+
* @param refreshToken
|
|
364
|
+
*/
|
|
365
|
+
addRefreshToken(refreshToken: string): void {
|
|
366
|
+
this.parameters.set(
|
|
367
|
+
AADServerParamKeys.REFRESH_TOKEN,
|
|
368
|
+
encodeURIComponent(refreshToken)
|
|
369
|
+
);
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* add the `code_verifier` passed by the user to exchange for a token
|
|
374
|
+
* @param codeVerifier
|
|
375
|
+
*/
|
|
376
|
+
addCodeVerifier(codeVerifier: string): void {
|
|
377
|
+
this.parameters.set(
|
|
378
|
+
AADServerParamKeys.CODE_VERIFIER,
|
|
379
|
+
encodeURIComponent(codeVerifier)
|
|
380
|
+
);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* add client_secret
|
|
385
|
+
* @param clientSecret
|
|
386
|
+
*/
|
|
387
|
+
addClientSecret(clientSecret: string): void {
|
|
388
|
+
this.parameters.set(
|
|
389
|
+
AADServerParamKeys.CLIENT_SECRET,
|
|
390
|
+
encodeURIComponent(clientSecret)
|
|
391
|
+
);
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* add clientAssertion for confidential client flows
|
|
396
|
+
* @param clientAssertion
|
|
397
|
+
*/
|
|
398
|
+
addClientAssertion(clientAssertion: string): void {
|
|
399
|
+
if (clientAssertion) {
|
|
400
|
+
this.parameters.set(
|
|
401
|
+
AADServerParamKeys.CLIENT_ASSERTION,
|
|
402
|
+
encodeURIComponent(clientAssertion)
|
|
403
|
+
);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* add clientAssertionType for confidential client flows
|
|
409
|
+
* @param clientAssertionType
|
|
410
|
+
*/
|
|
411
|
+
addClientAssertionType(clientAssertionType: string): void {
|
|
412
|
+
if (clientAssertionType) {
|
|
413
|
+
this.parameters.set(
|
|
414
|
+
AADServerParamKeys.CLIENT_ASSERTION_TYPE,
|
|
415
|
+
encodeURIComponent(clientAssertionType)
|
|
416
|
+
);
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* add OBO assertion for confidential client flows
|
|
422
|
+
* @param clientAssertion
|
|
423
|
+
*/
|
|
424
|
+
addOboAssertion(oboAssertion: string): void {
|
|
425
|
+
this.parameters.set(
|
|
426
|
+
AADServerParamKeys.OBO_ASSERTION,
|
|
427
|
+
encodeURIComponent(oboAssertion)
|
|
428
|
+
);
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* add grant type
|
|
433
|
+
* @param grantType
|
|
434
|
+
*/
|
|
435
|
+
addRequestTokenUse(tokenUse: string): void {
|
|
436
|
+
this.parameters.set(
|
|
437
|
+
AADServerParamKeys.REQUESTED_TOKEN_USE,
|
|
438
|
+
encodeURIComponent(tokenUse)
|
|
439
|
+
);
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
/**
|
|
443
|
+
* add grant type
|
|
444
|
+
* @param grantType
|
|
445
|
+
*/
|
|
446
|
+
addGrantType(grantType: string): void {
|
|
447
|
+
this.parameters.set(
|
|
448
|
+
AADServerParamKeys.GRANT_TYPE,
|
|
449
|
+
encodeURIComponent(grantType)
|
|
450
|
+
);
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
/**
|
|
454
|
+
* add client info
|
|
455
|
+
*
|
|
456
|
+
*/
|
|
457
|
+
addClientInfo(): void {
|
|
458
|
+
this.parameters.set(CLIENT_INFO, "1");
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* add extraQueryParams
|
|
463
|
+
* @param eQParams
|
|
464
|
+
*/
|
|
465
|
+
addExtraQueryParameters(eQParams: StringDict): void {
|
|
466
|
+
const sanitizedEQParams = RequestValidator.sanitizeEQParams(
|
|
467
|
+
eQParams,
|
|
468
|
+
this.parameters
|
|
469
|
+
);
|
|
470
|
+
Object.keys(sanitizedEQParams).forEach((key) => {
|
|
471
|
+
this.parameters.set(key, eQParams[key]);
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
addClientCapabilitiesToClaims(
|
|
476
|
+
claims?: string,
|
|
477
|
+
clientCapabilities?: Array<string>
|
|
478
|
+
): string {
|
|
479
|
+
let mergedClaims: object;
|
|
480
|
+
|
|
481
|
+
// Parse provided claims into JSON object or initialize empty object
|
|
482
|
+
if (!claims) {
|
|
483
|
+
mergedClaims = {};
|
|
484
|
+
} else {
|
|
485
|
+
try {
|
|
486
|
+
mergedClaims = JSON.parse(claims);
|
|
487
|
+
} catch (e) {
|
|
488
|
+
throw createClientConfigurationError(
|
|
489
|
+
ClientConfigurationErrorCodes.invalidClaims
|
|
490
|
+
);
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
if (clientCapabilities && clientCapabilities.length > 0) {
|
|
495
|
+
if (!mergedClaims.hasOwnProperty(ClaimsRequestKeys.ACCESS_TOKEN)) {
|
|
496
|
+
// Add access_token key to claims object
|
|
497
|
+
mergedClaims[ClaimsRequestKeys.ACCESS_TOKEN] = {};
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
// Add xms_cc claim with provided clientCapabilities to access_token key
|
|
501
|
+
mergedClaims[ClaimsRequestKeys.ACCESS_TOKEN][
|
|
502
|
+
ClaimsRequestKeys.XMS_CC
|
|
503
|
+
] = {
|
|
504
|
+
values: clientCapabilities,
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
return JSON.stringify(mergedClaims);
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
/**
|
|
512
|
+
* adds `username` for Password Grant flow
|
|
513
|
+
* @param username
|
|
514
|
+
*/
|
|
515
|
+
addUsername(username: string): void {
|
|
516
|
+
this.parameters.set(
|
|
517
|
+
PasswordGrantConstants.username,
|
|
518
|
+
encodeURIComponent(username)
|
|
519
|
+
);
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
/**
|
|
523
|
+
* adds `password` for Password Grant flow
|
|
524
|
+
* @param password
|
|
525
|
+
*/
|
|
526
|
+
addPassword(password: string): void {
|
|
527
|
+
this.parameters.set(
|
|
528
|
+
PasswordGrantConstants.password,
|
|
529
|
+
encodeURIComponent(password)
|
|
530
|
+
);
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
/**
|
|
534
|
+
* add pop_jwk to query params
|
|
535
|
+
* @param cnfString
|
|
536
|
+
*/
|
|
537
|
+
addPopToken(cnfString: string): void {
|
|
538
|
+
if (cnfString) {
|
|
539
|
+
this.parameters.set(
|
|
540
|
+
AADServerParamKeys.TOKEN_TYPE,
|
|
541
|
+
AuthenticationScheme.POP
|
|
542
|
+
);
|
|
543
|
+
this.parameters.set(
|
|
544
|
+
AADServerParamKeys.REQ_CNF,
|
|
545
|
+
encodeURIComponent(cnfString)
|
|
546
|
+
);
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
/**
|
|
551
|
+
* add SSH JWK and key ID to query params
|
|
552
|
+
*/
|
|
553
|
+
addSshJwk(sshJwkString: string): void {
|
|
554
|
+
if (sshJwkString) {
|
|
555
|
+
this.parameters.set(
|
|
556
|
+
AADServerParamKeys.TOKEN_TYPE,
|
|
557
|
+
AuthenticationScheme.SSH
|
|
558
|
+
);
|
|
559
|
+
this.parameters.set(
|
|
560
|
+
AADServerParamKeys.REQ_CNF,
|
|
561
|
+
encodeURIComponent(sshJwkString)
|
|
562
|
+
);
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
/**
|
|
567
|
+
* add server telemetry fields
|
|
568
|
+
* @param serverTelemetryManager
|
|
569
|
+
*/
|
|
570
|
+
addServerTelemetry(serverTelemetryManager: ServerTelemetryManager): void {
|
|
571
|
+
this.parameters.set(
|
|
572
|
+
AADServerParamKeys.X_CLIENT_CURR_TELEM,
|
|
573
|
+
serverTelemetryManager.generateCurrentRequestHeaderValue()
|
|
574
|
+
);
|
|
575
|
+
this.parameters.set(
|
|
576
|
+
AADServerParamKeys.X_CLIENT_LAST_TELEM,
|
|
577
|
+
serverTelemetryManager.generateLastRequestHeaderValue()
|
|
578
|
+
);
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
/**
|
|
582
|
+
* Adds parameter that indicates to the server that throttling is supported
|
|
583
|
+
*/
|
|
584
|
+
addThrottling(): void {
|
|
585
|
+
this.parameters.set(
|
|
586
|
+
AADServerParamKeys.X_MS_LIB_CAPABILITY,
|
|
587
|
+
ThrottlingConstants.X_MS_LIB_CAPABILITY_VALUE
|
|
588
|
+
);
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
/**
|
|
592
|
+
* Adds logout_hint parameter for "silent" logout which prevent server account picker
|
|
593
|
+
*/
|
|
594
|
+
addLogoutHint(logoutHint: string): void {
|
|
595
|
+
this.parameters.set(
|
|
596
|
+
AADServerParamKeys.LOGOUT_HINT,
|
|
597
|
+
encodeURIComponent(logoutHint)
|
|
598
|
+
);
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
/**
|
|
602
|
+
* Utility to create a URL from the params map
|
|
603
|
+
*/
|
|
604
|
+
createQueryString(): string {
|
|
605
|
+
const queryParameterArray: Array<string> = new Array<string>();
|
|
606
|
+
|
|
607
|
+
this.parameters.forEach((value, key) => {
|
|
608
|
+
queryParameterArray.push(`${key}=${value}`);
|
|
609
|
+
});
|
|
610
|
+
|
|
611
|
+
return queryParameterArray.join("&");
|
|
612
|
+
}
|
|
613
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
createClientConfigurationError,
|
|
8
|
+
ClientConfigurationErrorCodes,
|
|
9
|
+
} from "../error/ClientConfigurationError";
|
|
10
|
+
import { PromptValue, CodeChallengeMethodValues } from "../utils/Constants";
|
|
11
|
+
import { StringDict } from "../utils/MsalTypes";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Validates server consumable params from the "request" objects
|
|
15
|
+
*/
|
|
16
|
+
export class RequestValidator {
|
|
17
|
+
/**
|
|
18
|
+
* Utility to check if the `redirectUri` in the request is a non-null value
|
|
19
|
+
* @param redirectUri
|
|
20
|
+
*/
|
|
21
|
+
static validateRedirectUri(redirectUri: string): void {
|
|
22
|
+
if (!redirectUri) {
|
|
23
|
+
throw createClientConfigurationError(
|
|
24
|
+
ClientConfigurationErrorCodes.redirectUriEmpty
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Utility to validate prompt sent by the user in the request
|
|
31
|
+
* @param prompt
|
|
32
|
+
*/
|
|
33
|
+
static validatePrompt(prompt: string): void {
|
|
34
|
+
const promptValues = [];
|
|
35
|
+
|
|
36
|
+
for (const value in PromptValue) {
|
|
37
|
+
promptValues.push(PromptValue[value]);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (promptValues.indexOf(prompt) < 0) {
|
|
41
|
+
throw createClientConfigurationError(
|
|
42
|
+
ClientConfigurationErrorCodes.invalidPromptValue
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
static validateClaims(claims: string): void {
|
|
48
|
+
try {
|
|
49
|
+
JSON.parse(claims);
|
|
50
|
+
} catch (e) {
|
|
51
|
+
throw createClientConfigurationError(
|
|
52
|
+
ClientConfigurationErrorCodes.invalidClaims
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Utility to validate code_challenge and code_challenge_method
|
|
59
|
+
* @param codeChallenge
|
|
60
|
+
* @param codeChallengeMethod
|
|
61
|
+
*/
|
|
62
|
+
static validateCodeChallengeParams(
|
|
63
|
+
codeChallenge: string,
|
|
64
|
+
codeChallengeMethod: string
|
|
65
|
+
): void {
|
|
66
|
+
if (!codeChallenge || !codeChallengeMethod) {
|
|
67
|
+
throw createClientConfigurationError(
|
|
68
|
+
ClientConfigurationErrorCodes.pkceParamsMissing
|
|
69
|
+
);
|
|
70
|
+
} else {
|
|
71
|
+
this.validateCodeChallengeMethod(codeChallengeMethod);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Utility to validate code_challenge_method
|
|
77
|
+
* @param codeChallengeMethod
|
|
78
|
+
*/
|
|
79
|
+
static validateCodeChallengeMethod(codeChallengeMethod: string): void {
|
|
80
|
+
if (
|
|
81
|
+
[
|
|
82
|
+
CodeChallengeMethodValues.PLAIN,
|
|
83
|
+
CodeChallengeMethodValues.S256,
|
|
84
|
+
].indexOf(codeChallengeMethod) < 0
|
|
85
|
+
) {
|
|
86
|
+
throw createClientConfigurationError(
|
|
87
|
+
ClientConfigurationErrorCodes.invalidCodeChallengeMethod
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Removes unnecessary, duplicate, and empty string query parameters from extraQueryParameters
|
|
94
|
+
* @param request
|
|
95
|
+
*/
|
|
96
|
+
static sanitizeEQParams(
|
|
97
|
+
eQParams: StringDict,
|
|
98
|
+
queryParams: Map<string, string>
|
|
99
|
+
): StringDict {
|
|
100
|
+
if (!eQParams) {
|
|
101
|
+
return {};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Remove any query parameters already included in SSO params
|
|
105
|
+
queryParams.forEach((_value, key) => {
|
|
106
|
+
if (eQParams[key]) {
|
|
107
|
+
delete eQParams[key];
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
// remove empty string parameters
|
|
112
|
+
return Object.fromEntries(
|
|
113
|
+
Object.entries(eQParams).filter((kv) => kv[1] !== "")
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
}
|