@azure/msal-common 0.0.1-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/LICENSE +21 -0
- package/README.md +62 -0
- package/dist/_virtual/_tslib.js +90 -0
- package/dist/_virtual/_tslib.js.map +1 -0
- package/dist/account/AccountInfo.d.ts +30 -0
- package/dist/account/AccountInfo.d.ts.map +1 -0
- package/dist/account/AuthToken.d.ts +17 -0
- package/dist/account/AuthToken.d.ts.map +1 -0
- package/dist/account/AuthToken.js +43 -0
- package/dist/account/AuthToken.js.map +1 -0
- package/dist/account/CcsCredential.d.ts +9 -0
- package/dist/account/CcsCredential.d.ts.map +1 -0
- package/dist/account/CcsCredential.js +14 -0
- package/dist/account/CcsCredential.js.map +1 -0
- package/dist/account/ClientCredentials.d.ts +15 -0
- package/dist/account/ClientCredentials.d.ts.map +1 -0
- package/dist/account/ClientInfo.d.ts +20 -0
- package/dist/account/ClientInfo.d.ts.map +1 -0
- package/dist/account/ClientInfo.js +44 -0
- package/dist/account/ClientInfo.js.map +1 -0
- package/dist/account/DecodedAuthToken.d.ts +9 -0
- package/dist/account/DecodedAuthToken.d.ts.map +1 -0
- package/dist/account/TokenClaims.d.ts +60 -0
- package/dist/account/TokenClaims.d.ts.map +1 -0
- package/dist/authority/Authority.d.ts +200 -0
- package/dist/authority/Authority.d.ts.map +1 -0
- package/dist/authority/Authority.js +678 -0
- package/dist/authority/Authority.js.map +1 -0
- package/dist/authority/AuthorityFactory.d.ts +29 -0
- package/dist/authority/AuthorityFactory.d.ts.map +1 -0
- package/dist/authority/AuthorityFactory.js +69 -0
- package/dist/authority/AuthorityFactory.js.map +1 -0
- package/dist/authority/AuthorityMetadata.d.ts +623 -0
- package/dist/authority/AuthorityMetadata.d.ts.map +1 -0
- package/dist/authority/AuthorityMetadata.js +12 -0
- package/dist/authority/AuthorityMetadata.js.map +1 -0
- package/dist/authority/AuthorityOptions.d.ts +19 -0
- package/dist/authority/AuthorityOptions.d.ts.map +1 -0
- package/dist/authority/AuthorityOptions.js +24 -0
- package/dist/authority/AuthorityOptions.js.map +1 -0
- package/dist/authority/AuthorityType.d.ts +8 -0
- package/dist/authority/AuthorityType.d.ts.map +1 -0
- package/dist/authority/AuthorityType.js +17 -0
- package/dist/authority/AuthorityType.js.map +1 -0
- package/dist/authority/AzureRegion.d.ts +2 -0
- package/dist/authority/AzureRegion.d.ts.map +1 -0
- package/dist/authority/AzureRegionConfiguration.d.ts +6 -0
- package/dist/authority/AzureRegionConfiguration.d.ts.map +1 -0
- package/dist/authority/CloudDiscoveryMetadata.d.ts +6 -0
- package/dist/authority/CloudDiscoveryMetadata.d.ts.map +1 -0
- package/dist/authority/CloudInstanceDiscoveryResponse.d.ts +10 -0
- package/dist/authority/CloudInstanceDiscoveryResponse.d.ts.map +1 -0
- package/dist/authority/CloudInstanceDiscoveryResponse.js +13 -0
- package/dist/authority/CloudInstanceDiscoveryResponse.js.map +1 -0
- package/dist/authority/ImdsOptions.d.ts +7 -0
- package/dist/authority/ImdsOptions.d.ts.map +1 -0
- package/dist/authority/OpenIdConfigResponse.d.ts +12 -0
- package/dist/authority/OpenIdConfigResponse.d.ts.map +1 -0
- package/dist/authority/OpenIdConfigResponse.js +15 -0
- package/dist/authority/OpenIdConfigResponse.js.map +1 -0
- package/dist/authority/ProtocolMode.d.ts +8 -0
- package/dist/authority/ProtocolMode.d.ts.map +1 -0
- package/dist/authority/ProtocolMode.js +17 -0
- package/dist/authority/ProtocolMode.js.map +1 -0
- package/dist/authority/RegionDiscovery.d.ts +28 -0
- package/dist/authority/RegionDiscovery.d.ts.map +1 -0
- package/dist/authority/RegionDiscovery.js +127 -0
- package/dist/authority/RegionDiscovery.js.map +1 -0
- package/dist/authority/RegionDiscoveryMetadata.d.ts +7 -0
- package/dist/authority/RegionDiscoveryMetadata.d.ts.map +1 -0
- package/dist/cache/CacheManager.d.ts +393 -0
- package/dist/cache/CacheManager.d.ts.map +1 -0
- package/dist/cache/CacheManager.js +885 -0
- package/dist/cache/CacheManager.js.map +1 -0
- package/dist/cache/entities/AccessTokenEntity.d.ts +57 -0
- package/dist/cache/entities/AccessTokenEntity.d.ts.map +1 -0
- package/dist/cache/entities/AccessTokenEntity.js +124 -0
- package/dist/cache/entities/AccessTokenEntity.js.map +1 -0
- package/dist/cache/entities/AccountEntity.d.ts +100 -0
- package/dist/cache/entities/AccountEntity.d.ts.map +1 -0
- package/dist/cache/entities/AccountEntity.js +243 -0
- package/dist/cache/entities/AccountEntity.js.map +1 -0
- package/dist/cache/entities/AppMetadataEntity.d.ts +40 -0
- package/dist/cache/entities/AppMetadataEntity.d.ts.map +1 -0
- package/dist/cache/entities/AppMetadataEntity.js +74 -0
- package/dist/cache/entities/AppMetadataEntity.js.map +1 -0
- package/dist/cache/entities/AuthorityMetadataEntity.d.ts +48 -0
- package/dist/cache/entities/AuthorityMetadataEntity.d.ts.map +1 -0
- package/dist/cache/entities/AuthorityMetadataEntity.js +82 -0
- package/dist/cache/entities/AuthorityMetadataEntity.js.map +1 -0
- package/dist/cache/entities/CacheRecord.d.ts +14 -0
- package/dist/cache/entities/CacheRecord.d.ts.map +1 -0
- package/dist/cache/entities/CacheRecord.js +19 -0
- package/dist/cache/entities/CacheRecord.js.map +1 -0
- package/dist/cache/entities/CredentialEntity.d.ts +94 -0
- package/dist/cache/entities/CredentialEntity.d.ts.map +1 -0
- package/dist/cache/entities/CredentialEntity.js +164 -0
- package/dist/cache/entities/CredentialEntity.js.map +1 -0
- package/dist/cache/entities/IdTokenEntity.d.ts +35 -0
- package/dist/cache/entities/IdTokenEntity.d.ts.map +1 -0
- package/dist/cache/entities/IdTokenEntity.js +70 -0
- package/dist/cache/entities/IdTokenEntity.js.map +1 -0
- package/dist/cache/entities/RefreshTokenEntity.d.ts +37 -0
- package/dist/cache/entities/RefreshTokenEntity.d.ts.map +1 -0
- package/dist/cache/entities/RefreshTokenEntity.js +73 -0
- package/dist/cache/entities/RefreshTokenEntity.js.map +1 -0
- package/dist/cache/entities/ServerTelemetryEntity.d.ts +13 -0
- package/dist/cache/entities/ServerTelemetryEntity.d.ts.map +1 -0
- package/dist/cache/entities/ServerTelemetryEntity.js +35 -0
- package/dist/cache/entities/ServerTelemetryEntity.js.map +1 -0
- package/dist/cache/entities/ThrottlingEntity.d.ts +14 -0
- package/dist/cache/entities/ThrottlingEntity.d.ts.map +1 -0
- package/dist/cache/entities/ThrottlingEntity.js +32 -0
- package/dist/cache/entities/ThrottlingEntity.js.map +1 -0
- package/dist/cache/interface/ICacheManager.d.ts +157 -0
- package/dist/cache/interface/ICacheManager.d.ts.map +1 -0
- package/dist/cache/interface/ICachePlugin.d.ts +6 -0
- package/dist/cache/interface/ICachePlugin.d.ts.map +1 -0
- package/dist/cache/interface/ISerializableTokenCache.d.ts +5 -0
- package/dist/cache/interface/ISerializableTokenCache.d.ts.map +1 -0
- package/dist/cache/persistence/TokenCacheContext.d.ts +24 -0
- package/dist/cache/persistence/TokenCacheContext.d.ts.map +1 -0
- package/dist/cache/persistence/TokenCacheContext.js +39 -0
- package/dist/cache/persistence/TokenCacheContext.js.map +1 -0
- package/dist/cache/utils/CacheTypes.d.ts +60 -0
- package/dist/cache/utils/CacheTypes.d.ts.map +1 -0
- package/dist/client/AuthorizationCodeClient.d.ts +76 -0
- package/dist/client/AuthorizationCodeClient.d.ts.map +1 -0
- package/dist/client/AuthorizationCodeClient.js +468 -0
- package/dist/client/AuthorizationCodeClient.js.map +1 -0
- package/dist/client/BaseClient.d.ts +45 -0
- package/dist/client/BaseClient.d.ts.map +1 -0
- package/dist/client/BaseClient.js +103 -0
- package/dist/client/BaseClient.js.map +1 -0
- package/dist/client/ClientCredentialClient.d.ts +39 -0
- package/dist/client/ClientCredentialClient.d.ts.map +1 -0
- package/dist/client/ClientCredentialClient.js +202 -0
- package/dist/client/ClientCredentialClient.js.map +1 -0
- package/dist/client/DeviceCodeClient.d.ts +52 -0
- package/dist/client/DeviceCodeClient.d.ts.map +1 -0
- package/dist/client/DeviceCodeClient.js +232 -0
- package/dist/client/DeviceCodeClient.js.map +1 -0
- package/dist/client/OnBehalfOfClient.d.ts +51 -0
- package/dist/client/OnBehalfOfClient.d.ts.map +1 -0
- package/dist/client/OnBehalfOfClient.js +244 -0
- package/dist/client/OnBehalfOfClient.js.map +1 -0
- package/dist/client/RefreshTokenClient.d.ts +40 -0
- package/dist/client/RefreshTokenClient.d.ts.map +1 -0
- package/dist/client/RefreshTokenClient.js +255 -0
- package/dist/client/RefreshTokenClient.js.map +1 -0
- package/dist/client/SilentFlowClient.d.ts +25 -0
- package/dist/client/SilentFlowClient.d.ts.map +1 -0
- package/dist/client/SilentFlowClient.js +128 -0
- package/dist/client/SilentFlowClient.js.map +1 -0
- package/dist/client/UsernamePasswordClient.d.ts +29 -0
- package/dist/client/UsernamePasswordClient.d.ts.map +1 -0
- package/dist/client/UsernamePasswordClient.js +120 -0
- package/dist/client/UsernamePasswordClient.js.map +1 -0
- package/dist/config/AppTokenProvider.d.ts +39 -0
- package/dist/config/AppTokenProvider.d.ts.map +1 -0
- package/dist/config/ClientConfiguration.d.ts +135 -0
- package/dist/config/ClientConfiguration.d.ts.map +1 -0
- package/dist/config/ClientConfiguration.js +105 -0
- package/dist/config/ClientConfiguration.js.map +1 -0
- package/dist/crypto/ICrypto.d.ts +63 -0
- package/dist/crypto/ICrypto.d.ts.map +1 -0
- package/dist/crypto/ICrypto.js +80 -0
- package/dist/crypto/ICrypto.js.map +1 -0
- package/dist/crypto/IGuidGenerator.d.ts +5 -0
- package/dist/crypto/IGuidGenerator.d.ts.map +1 -0
- package/dist/crypto/JoseHeader.d.ts +22 -0
- package/dist/crypto/JoseHeader.d.ts.map +1 -0
- package/dist/crypto/JoseHeader.js +45 -0
- package/dist/crypto/JoseHeader.js.map +1 -0
- package/dist/crypto/PopTokenGenerator.d.ts +56 -0
- package/dist/crypto/PopTokenGenerator.d.ts.map +1 -0
- package/dist/crypto/PopTokenGenerator.js +107 -0
- package/dist/crypto/PopTokenGenerator.js.map +1 -0
- package/dist/crypto/SignedHttpRequest.d.ts +12 -0
- package/dist/crypto/SignedHttpRequest.d.ts.map +1 -0
- package/dist/error/AuthError.d.ts +48 -0
- package/dist/error/AuthError.d.ts.map +1 -0
- package/dist/error/AuthError.js +61 -0
- package/dist/error/AuthError.js.map +1 -0
- package/dist/error/ClientAuthError.d.ts +372 -0
- package/dist/error/ClientAuthError.d.ts.map +1 -0
- package/dist/error/ClientAuthError.js +477 -0
- package/dist/error/ClientAuthError.js.map +1 -0
- package/dist/error/ClientConfigurationError.d.ts +199 -0
- package/dist/error/ClientConfigurationError.d.ts.map +1 -0
- package/dist/error/ClientConfigurationError.js +260 -0
- package/dist/error/ClientConfigurationError.js.map +1 -0
- package/dist/error/InteractionRequiredAuthError.d.ts +42 -0
- package/dist/error/InteractionRequiredAuthError.d.ts.map +1 -0
- package/dist/error/InteractionRequiredAuthError.js +80 -0
- package/dist/error/InteractionRequiredAuthError.js.map +1 -0
- package/dist/error/JoseHeaderError.d.ts +29 -0
- package/dist/error/JoseHeaderError.d.ts.map +1 -0
- package/dist/error/JoseHeaderError.js +50 -0
- package/dist/error/JoseHeaderError.js.map +1 -0
- package/dist/error/ServerError.d.ts +8 -0
- package/dist/error/ServerError.d.ts.map +1 -0
- package/dist/error/ServerError.js +25 -0
- package/dist/error/ServerError.js.map +1 -0
- package/dist/index.cjs.js +8441 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +90 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +53 -0
- package/dist/index.js.map +1 -0
- package/dist/logger/Logger.d.ts +95 -0
- package/dist/logger/Logger.d.ts.map +1 -0
- package/dist/logger/Logger.js +185 -0
- package/dist/logger/Logger.js.map +1 -0
- package/dist/network/INetworkModule.d.ts +31 -0
- package/dist/network/INetworkModule.d.ts.map +1 -0
- package/dist/network/INetworkModule.js +21 -0
- package/dist/network/INetworkModule.js.map +1 -0
- package/dist/network/NetworkManager.d.ts +21 -0
- package/dist/network/NetworkManager.d.ts.map +1 -0
- package/dist/network/NetworkManager.js +56 -0
- package/dist/network/NetworkManager.js.map +1 -0
- package/dist/network/RequestThumbprint.d.ts +17 -0
- package/dist/network/RequestThumbprint.d.ts.map +1 -0
- package/dist/network/ThrottlingUtils.d.ts +42 -0
- package/dist/network/ThrottlingUtils.d.ts.map +1 -0
- package/dist/network/ThrottlingUtils.js +101 -0
- package/dist/network/ThrottlingUtils.js.map +1 -0
- package/dist/packageMetadata.d.ts +3 -0
- package/dist/packageMetadata.d.ts.map +1 -0
- package/dist/packageMetadata.js +8 -0
- package/dist/packageMetadata.js.map +1 -0
- package/dist/request/AuthenticationHeaderParser.d.ts +20 -0
- package/dist/request/AuthenticationHeaderParser.d.ts.map +1 -0
- package/dist/request/AuthenticationHeaderParser.js +64 -0
- package/dist/request/AuthenticationHeaderParser.js.map +1 -0
- package/dist/request/BaseAuthRequest.d.ts +34 -0
- package/dist/request/BaseAuthRequest.d.ts.map +1 -0
- package/dist/request/CommonAuthorizationCodeRequest.d.ts +28 -0
- package/dist/request/CommonAuthorizationCodeRequest.d.ts.map +1 -0
- package/dist/request/CommonAuthorizationUrlRequest.d.ts +51 -0
- package/dist/request/CommonAuthorizationUrlRequest.d.ts.map +1 -0
- package/dist/request/CommonClientCredentialRequest.d.ts +17 -0
- package/dist/request/CommonClientCredentialRequest.d.ts.map +1 -0
- package/dist/request/CommonDeviceCodeRequest.d.ts +19 -0
- package/dist/request/CommonDeviceCodeRequest.d.ts.map +1 -0
- package/dist/request/CommonEndSessionRequest.d.ts +21 -0
- package/dist/request/CommonEndSessionRequest.d.ts.map +1 -0
- package/dist/request/CommonOnBehalfOfRequest.d.ts +13 -0
- package/dist/request/CommonOnBehalfOfRequest.d.ts.map +1 -0
- package/dist/request/CommonRefreshTokenRequest.d.ts +21 -0
- package/dist/request/CommonRefreshTokenRequest.d.ts.map +1 -0
- package/dist/request/CommonSilentFlowRequest.d.ts +20 -0
- package/dist/request/CommonSilentFlowRequest.d.ts.map +1 -0
- package/dist/request/CommonUsernamePasswordRequest.d.ts +17 -0
- package/dist/request/CommonUsernamePasswordRequest.d.ts.map +1 -0
- package/dist/request/RequestParameterBuilder.d.ts +217 -0
- package/dist/request/RequestParameterBuilder.d.ts.map +1 -0
- package/dist/request/RequestParameterBuilder.js +387 -0
- package/dist/request/RequestParameterBuilder.js.map +1 -0
- package/dist/request/RequestValidator.d.ts +34 -0
- package/dist/request/RequestValidator.d.ts.map +1 -0
- package/dist/request/RequestValidator.js +92 -0
- package/dist/request/RequestValidator.js.map +1 -0
- package/dist/request/ScopeSet.d.ts +83 -0
- package/dist/request/ScopeSet.d.ts.map +1 -0
- package/dist/request/ScopeSet.js +192 -0
- package/dist/request/ScopeSet.js.map +1 -0
- package/dist/response/AuthenticationResult.d.ts +38 -0
- package/dist/response/AuthenticationResult.d.ts.map +1 -0
- package/dist/response/AuthorizationCodePayload.d.ts +14 -0
- package/dist/response/AuthorizationCodePayload.d.ts.map +1 -0
- package/dist/response/DeviceCodeResponse.d.ts +26 -0
- package/dist/response/DeviceCodeResponse.d.ts.map +1 -0
- package/dist/response/ExternalTokenResponse.d.ts +15 -0
- package/dist/response/ExternalTokenResponse.d.ts.map +1 -0
- package/dist/response/IMDSBadResponse.d.ts +5 -0
- package/dist/response/IMDSBadResponse.d.ts.map +1 -0
- package/dist/response/ResponseHandler.d.ts +71 -0
- package/dist/response/ResponseHandler.d.ts.map +1 -0
- package/dist/response/ResponseHandler.js +293 -0
- package/dist/response/ResponseHandler.js.map +1 -0
- package/dist/response/ServerAuthorizationCodeResponse.d.ts +22 -0
- package/dist/response/ServerAuthorizationCodeResponse.d.ts.map +1 -0
- package/dist/response/ServerAuthorizationTokenResponse.d.ts +43 -0
- package/dist/response/ServerAuthorizationTokenResponse.d.ts.map +1 -0
- package/dist/telemetry/performance/IPerformanceClient.d.ts +22 -0
- package/dist/telemetry/performance/IPerformanceClient.d.ts.map +1 -0
- package/dist/telemetry/performance/IPerformanceMeasurement.d.ts +6 -0
- package/dist/telemetry/performance/IPerformanceMeasurement.d.ts.map +1 -0
- package/dist/telemetry/performance/PerformanceClient.d.ts +125 -0
- package/dist/telemetry/performance/PerformanceClient.d.ts.map +1 -0
- package/dist/telemetry/performance/PerformanceClient.js +281 -0
- package/dist/telemetry/performance/PerformanceClient.js.map +1 -0
- package/dist/telemetry/performance/PerformanceEvent.d.ts +249 -0
- package/dist/telemetry/performance/PerformanceEvent.d.ts.map +1 -0
- package/dist/telemetry/performance/PerformanceEvent.js +121 -0
- package/dist/telemetry/performance/PerformanceEvent.js.map +1 -0
- package/dist/telemetry/performance/StubPerformanceClient.d.ts +13 -0
- package/dist/telemetry/performance/StubPerformanceClient.d.ts.map +1 -0
- package/dist/telemetry/performance/StubPerformanceClient.js +37 -0
- package/dist/telemetry/performance/StubPerformanceClient.js.map +1 -0
- package/dist/telemetry/server/ServerTelemetryManager.d.ts +67 -0
- package/dist/telemetry/server/ServerTelemetryManager.d.ts.map +1 -0
- package/dist/telemetry/server/ServerTelemetryManager.js +168 -0
- package/dist/telemetry/server/ServerTelemetryManager.js.map +1 -0
- package/dist/telemetry/server/ServerTelemetryRequest.d.ts +9 -0
- package/dist/telemetry/server/ServerTelemetryRequest.d.ts.map +1 -0
- package/dist/url/IUri.d.ts +13 -0
- package/dist/url/IUri.d.ts.map +1 -0
- package/dist/url/UrlString.d.ts +62 -0
- package/dist/url/UrlString.d.ts.map +1 -0
- package/dist/url/UrlString.js +208 -0
- package/dist/url/UrlString.js.map +1 -0
- package/dist/utils/Constants.d.ts +340 -0
- package/dist/utils/Constants.d.ts.map +1 -0
- package/dist/utils/Constants.js +381 -0
- package/dist/utils/Constants.js.map +1 -0
- package/dist/utils/MsalTypes.d.ts +7 -0
- package/dist/utils/MsalTypes.d.ts.map +1 -0
- package/dist/utils/ProtocolUtils.d.ts +43 -0
- package/dist/utils/ProtocolUtils.d.ts.map +1 -0
- package/dist/utils/ProtocolUtils.js +77 -0
- package/dist/utils/ProtocolUtils.js.map +1 -0
- package/dist/utils/StringUtils.d.ts +54 -0
- package/dist/utils/StringUtils.d.ts.map +1 -0
- package/dist/utils/StringUtils.js +129 -0
- package/dist/utils/StringUtils.js.map +1 -0
- package/dist/utils/TimeUtils.d.ts +28 -0
- package/dist/utils/TimeUtils.d.ts.map +1 -0
- package/dist/utils/TimeUtils.js +53 -0
- package/dist/utils/TimeUtils.js.map +1 -0
- package/package.json +76 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { StringDict } from "../utils/MsalTypes";
|
|
2
|
+
/**
|
|
3
|
+
* Validates server consumable params from the "request" objects
|
|
4
|
+
*/
|
|
5
|
+
export declare class RequestValidator {
|
|
6
|
+
/**
|
|
7
|
+
* Utility to check if the `redirectUri` in the request is a non-null value
|
|
8
|
+
* @param redirectUri
|
|
9
|
+
*/
|
|
10
|
+
static validateRedirectUri(redirectUri: string): void;
|
|
11
|
+
/**
|
|
12
|
+
* Utility to validate prompt sent by the user in the request
|
|
13
|
+
* @param prompt
|
|
14
|
+
*/
|
|
15
|
+
static validatePrompt(prompt: string): void;
|
|
16
|
+
static validateClaims(claims: string): void;
|
|
17
|
+
/**
|
|
18
|
+
* Utility to validate code_challenge and code_challenge_method
|
|
19
|
+
* @param codeChallenge
|
|
20
|
+
* @param codeChallengeMethod
|
|
21
|
+
*/
|
|
22
|
+
static validateCodeChallengeParams(codeChallenge: string, codeChallengeMethod: string): void;
|
|
23
|
+
/**
|
|
24
|
+
* Utility to validate code_challenge_method
|
|
25
|
+
* @param codeChallengeMethod
|
|
26
|
+
*/
|
|
27
|
+
static validateCodeChallengeMethod(codeChallengeMethod: string): void;
|
|
28
|
+
/**
|
|
29
|
+
* Removes unnecessary or duplicate query parameters from extraQueryParameters
|
|
30
|
+
* @param request
|
|
31
|
+
*/
|
|
32
|
+
static sanitizeEQParams(eQParams: StringDict, queryParams: Map<string, string>): StringDict;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=RequestValidator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RequestValidator.d.ts","sourceRoot":"","sources":["../../src/request/RequestValidator.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD;;GAEG;AACH,qBAAa,gBAAgB;IAEzB;;;OAGG;IACH,MAAM,CAAC,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAI,IAAI;IAMtD;;;OAGG;IACH,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,GAAI,IAAI;IAY5C,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,GAAI,IAAI;IAQ5C;;;;OAIG;IACH,MAAM,CAAC,2BAA2B,CAAC,aAAa,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,GAAI,IAAI;IAQ7F;;;OAGG;IACH,MAAM,CAAC,2BAA2B,CAAC,mBAAmB,EAAE,MAAM,GAAI,IAAI;IAWtE;;;OAGG;IACH,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAI,UAAU;CAc/F"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/*! @azure/msal-common v0.0.1-alpha.0 2022-08-02 */
|
|
2
|
+
'use strict';
|
|
3
|
+
import { StringUtils } from '../utils/StringUtils.js';
|
|
4
|
+
import { ClientConfigurationError } from '../error/ClientConfigurationError.js';
|
|
5
|
+
import { CodeChallengeMethodValues, PromptValue } from '../utils/Constants.js';
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
9
|
+
* Licensed under the MIT License.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Validates server consumable params from the "request" objects
|
|
13
|
+
*/
|
|
14
|
+
var RequestValidator = /** @class */ (function () {
|
|
15
|
+
function RequestValidator() {
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Utility to check if the `redirectUri` in the request is a non-null value
|
|
19
|
+
* @param redirectUri
|
|
20
|
+
*/
|
|
21
|
+
RequestValidator.validateRedirectUri = function (redirectUri) {
|
|
22
|
+
if (StringUtils.isEmpty(redirectUri)) {
|
|
23
|
+
throw ClientConfigurationError.createRedirectUriEmptyError();
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Utility to validate prompt sent by the user in the request
|
|
28
|
+
* @param prompt
|
|
29
|
+
*/
|
|
30
|
+
RequestValidator.validatePrompt = function (prompt) {
|
|
31
|
+
var promptValues = [];
|
|
32
|
+
for (var value in PromptValue) {
|
|
33
|
+
promptValues.push(PromptValue[value]);
|
|
34
|
+
}
|
|
35
|
+
if (promptValues.indexOf(prompt) < 0) {
|
|
36
|
+
throw ClientConfigurationError.createInvalidPromptError(prompt);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
RequestValidator.validateClaims = function (claims) {
|
|
40
|
+
try {
|
|
41
|
+
JSON.parse(claims);
|
|
42
|
+
}
|
|
43
|
+
catch (e) {
|
|
44
|
+
throw ClientConfigurationError.createInvalidClaimsRequestError();
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Utility to validate code_challenge and code_challenge_method
|
|
49
|
+
* @param codeChallenge
|
|
50
|
+
* @param codeChallengeMethod
|
|
51
|
+
*/
|
|
52
|
+
RequestValidator.validateCodeChallengeParams = function (codeChallenge, codeChallengeMethod) {
|
|
53
|
+
if (StringUtils.isEmpty(codeChallenge) || StringUtils.isEmpty(codeChallengeMethod)) {
|
|
54
|
+
throw ClientConfigurationError.createInvalidCodeChallengeParamsError();
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
this.validateCodeChallengeMethod(codeChallengeMethod);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Utility to validate code_challenge_method
|
|
62
|
+
* @param codeChallengeMethod
|
|
63
|
+
*/
|
|
64
|
+
RequestValidator.validateCodeChallengeMethod = function (codeChallengeMethod) {
|
|
65
|
+
if ([
|
|
66
|
+
CodeChallengeMethodValues.PLAIN,
|
|
67
|
+
CodeChallengeMethodValues.S256
|
|
68
|
+
].indexOf(codeChallengeMethod) < 0) {
|
|
69
|
+
throw ClientConfigurationError.createInvalidCodeChallengeMethodError();
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Removes unnecessary or duplicate query parameters from extraQueryParameters
|
|
74
|
+
* @param request
|
|
75
|
+
*/
|
|
76
|
+
RequestValidator.sanitizeEQParams = function (eQParams, queryParams) {
|
|
77
|
+
if (!eQParams) {
|
|
78
|
+
return {};
|
|
79
|
+
}
|
|
80
|
+
// Remove any query parameters already included in SSO params
|
|
81
|
+
queryParams.forEach(function (value, key) {
|
|
82
|
+
if (eQParams[key]) {
|
|
83
|
+
delete eQParams[key];
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
return eQParams;
|
|
87
|
+
};
|
|
88
|
+
return RequestValidator;
|
|
89
|
+
}());
|
|
90
|
+
|
|
91
|
+
export { RequestValidator };
|
|
92
|
+
//# sourceMappingURL=RequestValidator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RequestValidator.js","sources":["../../src/request/RequestValidator.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { StringUtils } from \"../utils/StringUtils\";\nimport { ClientConfigurationError } from \"../error/ClientConfigurationError\";\nimport { PromptValue, CodeChallengeMethodValues} from \"../utils/Constants\";\nimport { StringDict } from \"../utils/MsalTypes\";\n\n/**\n * Validates server consumable params from the \"request\" objects\n */\nexport class RequestValidator {\n\n /**\n * Utility to check if the `redirectUri` in the request is a non-null value\n * @param redirectUri\n */\n static validateRedirectUri(redirectUri: string) : void {\n if (StringUtils.isEmpty(redirectUri)) {\n throw ClientConfigurationError.createRedirectUriEmptyError();\n }\n }\n\n /**\n * Utility to validate prompt sent by the user in the request\n * @param prompt\n */\n static validatePrompt(prompt: string) : void {\n const promptValues = [];\n\n for (const value in PromptValue) {\n promptValues.push(PromptValue[value]);\n }\n\n if (promptValues.indexOf(prompt) < 0) {\n throw ClientConfigurationError.createInvalidPromptError(prompt);\n }\n }\n\n static validateClaims(claims: string) : void {\n try {\n JSON.parse(claims);\n } catch(e) {\n throw ClientConfigurationError.createInvalidClaimsRequestError();\n }\n }\n\n /**\n * Utility to validate code_challenge and code_challenge_method\n * @param codeChallenge\n * @param codeChallengeMethod\n */\n static validateCodeChallengeParams(codeChallenge: string, codeChallengeMethod: string) : void {\n if (StringUtils.isEmpty(codeChallenge) || StringUtils.isEmpty(codeChallengeMethod)) {\n throw ClientConfigurationError.createInvalidCodeChallengeParamsError();\n } else {\n this.validateCodeChallengeMethod(codeChallengeMethod);\n }\n }\n\n /**\n * Utility to validate code_challenge_method\n * @param codeChallengeMethod\n */\n static validateCodeChallengeMethod(codeChallengeMethod: string) : void {\n if (\n [\n CodeChallengeMethodValues.PLAIN,\n CodeChallengeMethodValues.S256\n ].indexOf(codeChallengeMethod) < 0\n ) {\n throw ClientConfigurationError.createInvalidCodeChallengeMethodError();\n }\n }\n\n /**\n * Removes unnecessary or duplicate query parameters from extraQueryParameters\n * @param request\n */\n static sanitizeEQParams(eQParams: StringDict, queryParams: Map<string, string>) : StringDict {\n if (!eQParams) {\n return {};\n }\n\n // Remove any query parameters already included in SSO params\n queryParams.forEach((value, key) => {\n if (eQParams[key]) {\n delete eQParams[key];\n }\n });\n\n return eQParams;\n }\n}\n"],"names":[],"mappings":";;;;;;AAAA;;;AAGG;AAOH;;AAEG;AACH,IAAA,gBAAA,kBAAA,YAAA;AAAA,IAAA,SAAA,gBAAA,GAAA;KAkFC;AAhFG;;;AAGG;IACI,gBAAmB,CAAA,mBAAA,GAA1B,UAA2B,WAAmB,EAAA;AAC1C,QAAA,IAAI,WAAW,CAAC,OAAO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,OAAO,CAAC,mBAAmB,CAAC,GAAG,CAAC,EACpC;AACE,YAAA,MAAM,wBAAwB,CAAC,qCAAqC,EAAE,CAAC;AAC1E,SAAA;KACJ,CAAA;AAED;;;AAGG;AACI,IAAA,gBAAA,CAAA,gBAAgB,GAAvB,UAAwB,QAAoB,EAAE,WAAgC,EAAA;QAC1E,IAAI,CAAC,QAAQ,EAAE;AACX,YAAA,OAAO,EAAE,CAAC;AACb,SAAA;;AAGD,QAAA,WAAW,CAAC,OAAO,CAAC,UAAC,KAAK,EAAE,GAAG,EAAA;AAC3B,YAAA,IAAI,QAAQ,CAAC,GAAG,CAAC,EAAE;AACf,gBAAA,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC;AACxB,aAAA;AACL,SAAC,CAAC,CAAC;AAEH,QAAA,OAAO,QAAQ,CAAC;KACnB,CAAA;IACL,OAAC,gBAAA,CAAA;AAAD,CAAC,EAAA;;;;"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The ScopeSet class creates a set of scopes. Scopes are case-insensitive, unique values, so the Set object in JS makes
|
|
3
|
+
* the most sense to implement for this class. All scopes are trimmed and converted to lower case strings in intersection and union functions
|
|
4
|
+
* to ensure uniqueness of strings.
|
|
5
|
+
*/
|
|
6
|
+
export declare class ScopeSet {
|
|
7
|
+
private scopes;
|
|
8
|
+
constructor(inputScopes: Array<string>);
|
|
9
|
+
/**
|
|
10
|
+
* Factory method to create ScopeSet from space-delimited string
|
|
11
|
+
* @param inputScopeString
|
|
12
|
+
* @param appClientId
|
|
13
|
+
* @param scopesRequired
|
|
14
|
+
*/
|
|
15
|
+
static fromString(inputScopeString: string): ScopeSet;
|
|
16
|
+
/**
|
|
17
|
+
* Used to validate the scopes input parameter requested by the developer.
|
|
18
|
+
* @param {Array<string>} inputScopes - Developer requested permissions. Not all scopes are guaranteed to be included in the access token returned.
|
|
19
|
+
* @param {boolean} scopesRequired - Boolean indicating whether the scopes array is required or not
|
|
20
|
+
*/
|
|
21
|
+
private validateInputScopes;
|
|
22
|
+
/**
|
|
23
|
+
* Check if a given scope is present in this set of scopes.
|
|
24
|
+
* @param scope
|
|
25
|
+
*/
|
|
26
|
+
containsScope(scope: string): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Check if a set of scopes is present in this set of scopes.
|
|
29
|
+
* @param scopeSet
|
|
30
|
+
*/
|
|
31
|
+
containsScopeSet(scopeSet: ScopeSet): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Check if set of scopes contains only the defaults
|
|
34
|
+
*/
|
|
35
|
+
containsOnlyOIDCScopes(): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Appends single scope if passed
|
|
38
|
+
* @param newScope
|
|
39
|
+
*/
|
|
40
|
+
appendScope(newScope: string): void;
|
|
41
|
+
/**
|
|
42
|
+
* Appends multiple scopes if passed
|
|
43
|
+
* @param newScopes
|
|
44
|
+
*/
|
|
45
|
+
appendScopes(newScopes: Array<string>): void;
|
|
46
|
+
/**
|
|
47
|
+
* Removes element from set of scopes.
|
|
48
|
+
* @param scope
|
|
49
|
+
*/
|
|
50
|
+
removeScope(scope: string): void;
|
|
51
|
+
/**
|
|
52
|
+
* Removes default scopes from set of scopes
|
|
53
|
+
* Primarily used to prevent cache misses if the default scopes are not returned from the server
|
|
54
|
+
*/
|
|
55
|
+
removeOIDCScopes(): void;
|
|
56
|
+
/**
|
|
57
|
+
* Combines an array of scopes with the current set of scopes.
|
|
58
|
+
* @param otherScopes
|
|
59
|
+
*/
|
|
60
|
+
unionScopeSets(otherScopes: ScopeSet): Set<string>;
|
|
61
|
+
/**
|
|
62
|
+
* Check if scopes intersect between this set and another.
|
|
63
|
+
* @param otherScopes
|
|
64
|
+
*/
|
|
65
|
+
intersectingScopeSets(otherScopes: ScopeSet): boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Returns size of set of scopes.
|
|
68
|
+
*/
|
|
69
|
+
getScopeCount(): number;
|
|
70
|
+
/**
|
|
71
|
+
* Returns the scopes as an array of string values
|
|
72
|
+
*/
|
|
73
|
+
asArray(): Array<string>;
|
|
74
|
+
/**
|
|
75
|
+
* Prints scopes into a space-delimited string
|
|
76
|
+
*/
|
|
77
|
+
printScopes(): string;
|
|
78
|
+
/**
|
|
79
|
+
* Prints scopes into a space-delimited lower-case string (used for caching)
|
|
80
|
+
*/
|
|
81
|
+
printScopesLowerCase(): string;
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=ScopeSet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScopeSet.d.ts","sourceRoot":"","sources":["../../src/request/ScopeSet.ts"],"names":[],"mappings":"AAUA;;;;GAIG;AACH,qBAAa,QAAQ;IAEjB,OAAO,CAAC,MAAM,CAAc;gBAEhB,WAAW,EAAE,KAAK,CAAC,MAAM,CAAC;IAYtC;;;;;OAKG;IACH,MAAM,CAAC,UAAU,CAAC,gBAAgB,EAAE,MAAM,GAAG,QAAQ;IAMrD;;;;OAIG;IACH,OAAO,CAAC,mBAAmB;IAO3B;;;OAGG;IACH,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAOrC;;;OAGG;IACH,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO;IAQ7C;;OAEG;IACH,sBAAsB,IAAI,OAAO;IAWjC;;;OAGG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAMnC;;;OAGG;IACH,YAAY,CAAC,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,IAAI;IAQ5C;;;OAGG;IACH,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAOhC;;;OAGG;IACH,gBAAgB,IAAI,IAAI;IAMxB;;;OAGG;IACH,cAAc,CAAC,WAAW,EAAE,QAAQ,GAAG,GAAG,CAAC,MAAM,CAAC;IAUlD;;;OAGG;IACH,qBAAqB,CAAC,WAAW,EAAE,QAAQ,GAAG,OAAO;IAgBrD;;OAEG;IACH,aAAa,IAAI,MAAM;IAIvB;;OAEG;IACH,OAAO,IAAI,KAAK,CAAC,MAAM,CAAC;IAMxB;;OAEG;IACH,WAAW,IAAI,MAAM;IAQrB;;OAEG;IACH,oBAAoB,IAAI,MAAM;CAGjC"}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/*! @azure/msal-common v0.0.1-alpha.0 2022-08-02 */
|
|
2
|
+
'use strict';
|
|
3
|
+
import { __spreadArrays } from '../_virtual/_tslib.js';
|
|
4
|
+
import { ClientConfigurationError } from '../error/ClientConfigurationError.js';
|
|
5
|
+
import { StringUtils } from '../utils/StringUtils.js';
|
|
6
|
+
import { ClientAuthError } from '../error/ClientAuthError.js';
|
|
7
|
+
import { OIDC_SCOPES, Constants } from '../utils/Constants.js';
|
|
8
|
+
|
|
9
|
+
/*
|
|
10
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
11
|
+
* Licensed under the MIT License.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* The ScopeSet class creates a set of scopes. Scopes are case-insensitive, unique values, so the Set object in JS makes
|
|
15
|
+
* the most sense to implement for this class. All scopes are trimmed and converted to lower case strings in intersection and union functions
|
|
16
|
+
* to ensure uniqueness of strings.
|
|
17
|
+
*/
|
|
18
|
+
var ScopeSet = /** @class */ (function () {
|
|
19
|
+
function ScopeSet(inputScopes) {
|
|
20
|
+
var _this = this;
|
|
21
|
+
// Filter empty string and null/undefined array items
|
|
22
|
+
var scopeArr = inputScopes ? StringUtils.trimArrayEntries(__spreadArrays(inputScopes)) : [];
|
|
23
|
+
var filteredInput = scopeArr ? StringUtils.removeEmptyStringsFromArray(scopeArr) : [];
|
|
24
|
+
// Validate and filter scopes (validate function throws if validation fails)
|
|
25
|
+
this.validateInputScopes(filteredInput);
|
|
26
|
+
this.scopes = new Set(); // Iterator in constructor not supported by IE11
|
|
27
|
+
filteredInput.forEach(function (scope) { return _this.scopes.add(scope); });
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Factory method to create ScopeSet from space-delimited string
|
|
31
|
+
* @param inputScopeString
|
|
32
|
+
* @param appClientId
|
|
33
|
+
* @param scopesRequired
|
|
34
|
+
*/
|
|
35
|
+
ScopeSet.fromString = function (inputScopeString) {
|
|
36
|
+
var scopeString = inputScopeString || Constants.EMPTY_STRING;
|
|
37
|
+
var inputScopes = scopeString.split(" ");
|
|
38
|
+
return new ScopeSet(inputScopes);
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Used to validate the scopes input parameter requested by the developer.
|
|
42
|
+
* @param {Array<string>} inputScopes - Developer requested permissions. Not all scopes are guaranteed to be included in the access token returned.
|
|
43
|
+
* @param {boolean} scopesRequired - Boolean indicating whether the scopes array is required or not
|
|
44
|
+
*/
|
|
45
|
+
ScopeSet.prototype.validateInputScopes = function (inputScopes) {
|
|
46
|
+
// Check if scopes are required but not given or is an empty array
|
|
47
|
+
if (!inputScopes || inputScopes.length < 1) {
|
|
48
|
+
throw ClientConfigurationError.createEmptyScopesArrayError();
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Check if a given scope is present in this set of scopes.
|
|
53
|
+
* @param scope
|
|
54
|
+
*/
|
|
55
|
+
ScopeSet.prototype.containsScope = function (scope) {
|
|
56
|
+
var lowerCaseScopes = this.printScopesLowerCase().split(" ");
|
|
57
|
+
var lowerCaseScopesSet = new ScopeSet(lowerCaseScopes);
|
|
58
|
+
// compare lowercase scopes
|
|
59
|
+
return !StringUtils.isEmpty(scope) ? lowerCaseScopesSet.scopes.has(scope.toLowerCase()) : false;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Check if a set of scopes is present in this set of scopes.
|
|
63
|
+
* @param scopeSet
|
|
64
|
+
*/
|
|
65
|
+
ScopeSet.prototype.containsScopeSet = function (scopeSet) {
|
|
66
|
+
var _this = this;
|
|
67
|
+
if (!scopeSet || scopeSet.scopes.size <= 0) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
return (this.scopes.size >= scopeSet.scopes.size && scopeSet.asArray().every(function (scope) { return _this.containsScope(scope); }));
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Check if set of scopes contains only the defaults
|
|
74
|
+
*/
|
|
75
|
+
ScopeSet.prototype.containsOnlyOIDCScopes = function () {
|
|
76
|
+
var _this = this;
|
|
77
|
+
var defaultScopeCount = 0;
|
|
78
|
+
OIDC_SCOPES.forEach(function (defaultScope) {
|
|
79
|
+
if (_this.containsScope(defaultScope)) {
|
|
80
|
+
defaultScopeCount += 1;
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
return this.scopes.size === defaultScopeCount;
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Appends single scope if passed
|
|
87
|
+
* @param newScope
|
|
88
|
+
*/
|
|
89
|
+
ScopeSet.prototype.appendScope = function (newScope) {
|
|
90
|
+
if (!StringUtils.isEmpty(newScope)) {
|
|
91
|
+
this.scopes.add(newScope.trim());
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Appends multiple scopes if passed
|
|
96
|
+
* @param newScopes
|
|
97
|
+
*/
|
|
98
|
+
ScopeSet.prototype.appendScopes = function (newScopes) {
|
|
99
|
+
var _this = this;
|
|
100
|
+
try {
|
|
101
|
+
newScopes.forEach(function (newScope) { return _this.appendScope(newScope); });
|
|
102
|
+
}
|
|
103
|
+
catch (e) {
|
|
104
|
+
throw ClientAuthError.createAppendScopeSetError(e);
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* Removes element from set of scopes.
|
|
109
|
+
* @param scope
|
|
110
|
+
*/
|
|
111
|
+
ScopeSet.prototype.removeScope = function (scope) {
|
|
112
|
+
if (StringUtils.isEmpty(scope)) {
|
|
113
|
+
throw ClientAuthError.createRemoveEmptyScopeFromSetError(scope);
|
|
114
|
+
}
|
|
115
|
+
this.scopes.delete(scope.trim());
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* Removes default scopes from set of scopes
|
|
119
|
+
* Primarily used to prevent cache misses if the default scopes are not returned from the server
|
|
120
|
+
*/
|
|
121
|
+
ScopeSet.prototype.removeOIDCScopes = function () {
|
|
122
|
+
var _this = this;
|
|
123
|
+
OIDC_SCOPES.forEach(function (defaultScope) {
|
|
124
|
+
_this.scopes.delete(defaultScope);
|
|
125
|
+
});
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* Combines an array of scopes with the current set of scopes.
|
|
129
|
+
* @param otherScopes
|
|
130
|
+
*/
|
|
131
|
+
ScopeSet.prototype.unionScopeSets = function (otherScopes) {
|
|
132
|
+
if (!otherScopes) {
|
|
133
|
+
throw ClientAuthError.createEmptyInputScopeSetError();
|
|
134
|
+
}
|
|
135
|
+
var unionScopes = new Set(); // Iterator in constructor not supported in IE11
|
|
136
|
+
otherScopes.scopes.forEach(function (scope) { return unionScopes.add(scope.toLowerCase()); });
|
|
137
|
+
this.scopes.forEach(function (scope) { return unionScopes.add(scope.toLowerCase()); });
|
|
138
|
+
return unionScopes;
|
|
139
|
+
};
|
|
140
|
+
/**
|
|
141
|
+
* Check if scopes intersect between this set and another.
|
|
142
|
+
* @param otherScopes
|
|
143
|
+
*/
|
|
144
|
+
ScopeSet.prototype.intersectingScopeSets = function (otherScopes) {
|
|
145
|
+
if (!otherScopes) {
|
|
146
|
+
throw ClientAuthError.createEmptyInputScopeSetError();
|
|
147
|
+
}
|
|
148
|
+
// Do not allow OIDC scopes to be the only intersecting scopes
|
|
149
|
+
if (!otherScopes.containsOnlyOIDCScopes()) {
|
|
150
|
+
otherScopes.removeOIDCScopes();
|
|
151
|
+
}
|
|
152
|
+
var unionScopes = this.unionScopeSets(otherScopes);
|
|
153
|
+
var sizeOtherScopes = otherScopes.getScopeCount();
|
|
154
|
+
var sizeThisScopes = this.getScopeCount();
|
|
155
|
+
var sizeUnionScopes = unionScopes.size;
|
|
156
|
+
return sizeUnionScopes < (sizeThisScopes + sizeOtherScopes);
|
|
157
|
+
};
|
|
158
|
+
/**
|
|
159
|
+
* Returns size of set of scopes.
|
|
160
|
+
*/
|
|
161
|
+
ScopeSet.prototype.getScopeCount = function () {
|
|
162
|
+
return this.scopes.size;
|
|
163
|
+
};
|
|
164
|
+
/**
|
|
165
|
+
* Returns the scopes as an array of string values
|
|
166
|
+
*/
|
|
167
|
+
ScopeSet.prototype.asArray = function () {
|
|
168
|
+
var array = [];
|
|
169
|
+
this.scopes.forEach(function (val) { return array.push(val); });
|
|
170
|
+
return array;
|
|
171
|
+
};
|
|
172
|
+
/**
|
|
173
|
+
* Prints scopes into a space-delimited string
|
|
174
|
+
*/
|
|
175
|
+
ScopeSet.prototype.printScopes = function () {
|
|
176
|
+
if (this.scopes) {
|
|
177
|
+
var scopeArr = this.asArray();
|
|
178
|
+
return scopeArr.join(" ");
|
|
179
|
+
}
|
|
180
|
+
return Constants.EMPTY_STRING;
|
|
181
|
+
};
|
|
182
|
+
/**
|
|
183
|
+
* Prints scopes into a space-delimited lower-case string (used for caching)
|
|
184
|
+
*/
|
|
185
|
+
ScopeSet.prototype.printScopesLowerCase = function () {
|
|
186
|
+
return this.printScopes().toLowerCase();
|
|
187
|
+
};
|
|
188
|
+
return ScopeSet;
|
|
189
|
+
}());
|
|
190
|
+
|
|
191
|
+
export { ScopeSet };
|
|
192
|
+
//# sourceMappingURL=ScopeSet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScopeSet.js","sources":["../../src/request/ScopeSet.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ClientConfigurationError } from \"../error/ClientConfigurationError\";\nimport { StringUtils } from \"../utils/StringUtils\";\nimport { ClientAuthError } from \"../error/ClientAuthError\";\nimport { Constants, OIDC_SCOPES } from \"../utils/Constants\";\n\n/**\n * The ScopeSet class creates a set of scopes. Scopes are case-insensitive, unique values, so the Set object in JS makes\n * the most sense to implement for this class. All scopes are trimmed and converted to lower case strings in intersection and union functions\n * to ensure uniqueness of strings.\n */\nexport class ScopeSet {\n // Scopes as a Set of strings\n private scopes: Set<string>;\n\n constructor(inputScopes: Array<string>) {\n // Filter empty string and null/undefined array items\n const scopeArr = inputScopes ? StringUtils.trimArrayEntries([...inputScopes]) : [];\n const filteredInput = scopeArr ? StringUtils.removeEmptyStringsFromArray(scopeArr) : [];\n\n // Validate and filter scopes (validate function throws if validation fails)\n this.validateInputScopes(filteredInput);\n\n this.scopes = new Set<string>(); // Iterator in constructor not supported by IE11\n filteredInput.forEach(scope => this.scopes.add(scope));\n }\n\n /**\n * Factory method to create ScopeSet from space-delimited string\n * @param inputScopeString\n * @param appClientId\n * @param scopesRequired\n */\n static fromString(inputScopeString: string): ScopeSet {\n const scopeString = inputScopeString || Constants.EMPTY_STRING;\n const inputScopes: Array<string> = scopeString.split(\" \");\n return new ScopeSet(inputScopes);\n }\n\n /**\n * Used to validate the scopes input parameter requested by the developer.\n * @param {Array<string>} inputScopes - Developer requested permissions. Not all scopes are guaranteed to be included in the access token returned.\n * @param {boolean} scopesRequired - Boolean indicating whether the scopes array is required or not\n */\n private validateInputScopes(inputScopes: Array<string>): void {\n // Check if scopes are required but not given or is an empty array\n if (!inputScopes || inputScopes.length < 1) {\n throw ClientConfigurationError.createEmptyScopesArrayError();\n }\n }\n\n /**\n * Check if a given scope is present in this set of scopes.\n * @param scope\n */\n containsScope(scope: string): boolean {\n const lowerCaseScopes = this.printScopesLowerCase().split(\" \");\n const lowerCaseScopesSet = new ScopeSet(lowerCaseScopes);\n // compare lowercase scopes\n return !StringUtils.isEmpty(scope) ? lowerCaseScopesSet.scopes.has(scope.toLowerCase()) : false;\n }\n\n /**\n * Check if a set of scopes is present in this set of scopes.\n * @param scopeSet\n */\n containsScopeSet(scopeSet: ScopeSet): boolean {\n if (!scopeSet || scopeSet.scopes.size <= 0) {\n return false;\n }\n\n return (this.scopes.size >= scopeSet.scopes.size && scopeSet.asArray().every(scope => this.containsScope(scope)));\n }\n\n /**\n * Check if set of scopes contains only the defaults\n */\n containsOnlyOIDCScopes(): boolean {\n let defaultScopeCount = 0;\n OIDC_SCOPES.forEach((defaultScope: string) => {\n if (this.containsScope(defaultScope)) {\n defaultScopeCount += 1;\n }\n });\n\n return this.scopes.size === defaultScopeCount;\n }\n\n /**\n * Appends single scope if passed\n * @param newScope\n */\n appendScope(newScope: string): void {\n if (!StringUtils.isEmpty(newScope)) {\n this.scopes.add(newScope.trim());\n }\n }\n\n /**\n * Appends multiple scopes if passed\n * @param newScopes\n */\n appendScopes(newScopes: Array<string>): void {\n try {\n newScopes.forEach(newScope => this.appendScope(newScope));\n } catch (e) {\n throw ClientAuthError.createAppendScopeSetError(e);\n }\n }\n\n /**\n * Removes element from set of scopes.\n * @param scope\n */\n removeScope(scope: string): void {\n if (StringUtils.isEmpty(scope)) {\n throw ClientAuthError.createRemoveEmptyScopeFromSetError(scope);\n }\n this.scopes.delete(scope.trim());\n }\n\n /**\n * Removes default scopes from set of scopes\n * Primarily used to prevent cache misses if the default scopes are not returned from the server\n */\n removeOIDCScopes(): void {\n OIDC_SCOPES.forEach((defaultScope: string) => {\n this.scopes.delete(defaultScope);\n });\n }\n\n /**\n * Combines an array of scopes with the current set of scopes.\n * @param otherScopes\n */\n unionScopeSets(otherScopes: ScopeSet): Set<string> {\n if (!otherScopes) {\n throw ClientAuthError.createEmptyInputScopeSetError();\n }\n const unionScopes = new Set<string>(); // Iterator in constructor not supported in IE11\n otherScopes.scopes.forEach(scope => unionScopes.add(scope.toLowerCase()));\n this.scopes.forEach(scope => unionScopes.add(scope.toLowerCase()));\n return unionScopes;\n }\n\n /**\n * Check if scopes intersect between this set and another.\n * @param otherScopes\n */\n intersectingScopeSets(otherScopes: ScopeSet): boolean {\n if (!otherScopes) {\n throw ClientAuthError.createEmptyInputScopeSetError();\n }\n \n // Do not allow OIDC scopes to be the only intersecting scopes\n if (!otherScopes.containsOnlyOIDCScopes()) {\n otherScopes.removeOIDCScopes();\n }\n const unionScopes = this.unionScopeSets(otherScopes);\n const sizeOtherScopes = otherScopes.getScopeCount();\n const sizeThisScopes = this.getScopeCount();\n const sizeUnionScopes = unionScopes.size;\n return sizeUnionScopes < (sizeThisScopes + sizeOtherScopes);\n }\n\n /**\n * Returns size of set of scopes.\n */\n getScopeCount(): number {\n return this.scopes.size;\n }\n\n /**\n * Returns the scopes as an array of string values\n */\n asArray(): Array<string> {\n const array: Array<string> = [];\n this.scopes.forEach(val => array.push(val));\n return array;\n }\n\n /**\n * Prints scopes into a space-delimited string\n */\n printScopes(): string {\n if (this.scopes) {\n const scopeArr = this.asArray();\n return scopeArr.join(\" \");\n }\n return Constants.EMPTY_STRING;\n }\n\n /**\n * Prints scopes into a space-delimited lower-case string (used for caching)\n */\n printScopesLowerCase(): string {\n return this.printScopes().toLowerCase();\n }\n}\n"],"names":[],"mappings":";;;;;;;;AAAA;;;AAGG;AAOH;;;;AAIG;AACH,IAAA,QAAA,kBAAA,YAAA;AAII,IAAA,SAAA,QAAA,CAAY,WAA0B,EAAA;QAAtC,IAUC,KAAA,GAAA,IAAA,CAAA;;AARG,QAAA,IAAM,QAAQ,GAAG,WAAW,GAAG,WAAW,CAAC,gBAAgB,CAAA,cAAA,CAAK,WAAW,CAAE,CAAA,GAAG,EAAE,CAAC;AACnF,QAAA,IAAM,aAAa,GAAG,QAAQ,GAAG,WAAW,CAAC,2BAA2B,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC;;AAGxF,QAAA,IAAI,CAAC,mBAAmB,CAAC,aAAa,CAAC,CAAC;QAExC,IAAI,CAAC,MAAM,GAAG,IAAI,GAAG,EAAU,CAAC;AAChC,QAAA,aAAa,CAAC,OAAO,CAAC,UAAA,KAAK,EAAA,EAAI,OAAA,KAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAtB,EAAsB,CAAC,CAAC;KAC1D;AAED;;;;;AAKG;IACI,QAAU,CAAA,UA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,EAAA;;;;"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { AccountInfo } from "../account/AccountInfo";
|
|
2
|
+
/**
|
|
3
|
+
* Result returned from the authority's token endpoint.
|
|
4
|
+
* - uniqueId - `oid` or `sub` claim from ID token
|
|
5
|
+
* - tenantId - `tid` claim from ID token
|
|
6
|
+
* - scopes - Scopes that are validated for the respective token
|
|
7
|
+
* - account - An account object representation of the currently signed-in user
|
|
8
|
+
* - idToken - Id token received as part of the response
|
|
9
|
+
* - idTokenClaims - MSAL-relevant ID token claims
|
|
10
|
+
* - accessToken - Access token or SSH certificate received as part of the response
|
|
11
|
+
* - fromCache - Boolean denoting whether token came from cache
|
|
12
|
+
* - expiresOn - Javascript Date object representing relative expiration of access token
|
|
13
|
+
* - extExpiresOn - Javascript Date object representing extended relative expiration of access token in case of server outage
|
|
14
|
+
* - state - Value passed in by user in request
|
|
15
|
+
* - familyId - Family ID identifier, usually only used for refresh tokens
|
|
16
|
+
*/
|
|
17
|
+
export declare type AuthenticationResult = {
|
|
18
|
+
authority: string;
|
|
19
|
+
uniqueId: string;
|
|
20
|
+
tenantId: string;
|
|
21
|
+
scopes: Array<string>;
|
|
22
|
+
account: AccountInfo | null;
|
|
23
|
+
idToken: string;
|
|
24
|
+
idTokenClaims: object;
|
|
25
|
+
accessToken: string;
|
|
26
|
+
fromCache: boolean;
|
|
27
|
+
expiresOn: Date | null;
|
|
28
|
+
tokenType: string;
|
|
29
|
+
correlationId: string;
|
|
30
|
+
extExpiresOn?: Date;
|
|
31
|
+
state?: string;
|
|
32
|
+
familyId?: string;
|
|
33
|
+
cloudGraphHostName?: string;
|
|
34
|
+
msGraphHost?: string;
|
|
35
|
+
code?: string;
|
|
36
|
+
fromNativeBroker?: boolean;
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=AuthenticationResult.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AuthenticationResult.d.ts","sourceRoot":"","sources":["../../src/response/AuthenticationResult.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD;;;;;;;;;;;;;;GAcG;AACH,oBAAY,oBAAoB,GAAG;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACtB,OAAO,EAAE,WAAW,GAAG,IAAI,CAAC;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,IAAI,GAAG,IAAI,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,IAAI,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC9B,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Response returned after processing the code response query string or fragment.
|
|
3
|
+
*/
|
|
4
|
+
export declare type AuthorizationCodePayload = {
|
|
5
|
+
code: string;
|
|
6
|
+
cloud_instance_name?: string;
|
|
7
|
+
cloud_instance_host_name?: string;
|
|
8
|
+
cloud_graph_host_name?: string;
|
|
9
|
+
msgraph_host?: string;
|
|
10
|
+
state?: string;
|
|
11
|
+
nonce?: string;
|
|
12
|
+
client_info?: string;
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=AuthorizationCodePayload.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AuthorizationCodePayload.d.ts","sourceRoot":"","sources":["../../src/response/AuthorizationCodePayload.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,oBAAY,wBAAwB,GAAG;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DeviceCode returned by the security token service device code endpoint containing information necessary for device code flow.
|
|
3
|
+
* - userCode: code which user needs to provide when authenticating at the verification URI
|
|
4
|
+
* - deviceCode: code which should be included in the request for the access token
|
|
5
|
+
* - verificationUri: URI where user can authenticate
|
|
6
|
+
* - expiresIn: expiration time of the device code in seconds
|
|
7
|
+
* - interval: interval at which the STS should be polled at
|
|
8
|
+
* - message: message which should be displayed to the user
|
|
9
|
+
*/
|
|
10
|
+
export declare type DeviceCodeResponse = {
|
|
11
|
+
userCode: string;
|
|
12
|
+
deviceCode: string;
|
|
13
|
+
verificationUri: string;
|
|
14
|
+
expiresIn: number;
|
|
15
|
+
interval: number;
|
|
16
|
+
message: string;
|
|
17
|
+
};
|
|
18
|
+
export declare type ServerDeviceCodeResponse = {
|
|
19
|
+
user_code: string;
|
|
20
|
+
device_code: string;
|
|
21
|
+
verification_uri: string;
|
|
22
|
+
expires_in: number;
|
|
23
|
+
interval: number;
|
|
24
|
+
message: string;
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=DeviceCodeResponse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DeviceCodeResponse.d.ts","sourceRoot":"","sources":["../../src/response/DeviceCodeResponse.ts"],"names":[],"mappings":"AAKA;;;;;;;;GAQG;AACH,oBAAY,kBAAkB,GAAG;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,oBAAY,wBAAwB,GAAG;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACnB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ServerAuthorizationTokenResponse } from "./ServerAuthorizationTokenResponse";
|
|
2
|
+
/**
|
|
3
|
+
* Response object used for loading external tokens to cache.
|
|
4
|
+
* - token_type: Indicates the token type value. The only type that Azure AD supports is Bearer.
|
|
5
|
+
* - scope: The scopes that the access_token is valid for.
|
|
6
|
+
* - expires_in: How long the access token is valid (in seconds).
|
|
7
|
+
* - id_token: A JSON Web Token (JWT). The app can decode the segments of this token to request information about the user who signed in.
|
|
8
|
+
* - access_token: The requested access token. The app can use this token to authenticate to the secured resource, such as a web API.
|
|
9
|
+
* - client_info: Client info object
|
|
10
|
+
*/
|
|
11
|
+
export declare type ExternalTokenResponse = Pick<ServerAuthorizationTokenResponse, "token_type" | "scope" | "expires_in" | "id_token"> & {
|
|
12
|
+
access_token?: string;
|
|
13
|
+
client_info?: string;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=ExternalTokenResponse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExternalTokenResponse.d.ts","sourceRoot":"","sources":["../../src/response/ExternalTokenResponse.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,gCAAgC,EAAE,MAAM,oCAAoC,CAAC;AAEtF;;;;;;;;GAQG;AACH,oBAAY,qBAAqB,GAAG,IAAI,CAAC,gCAAgC,EAAE,YAAY,GAAG,OAAO,GAAG,YAAY,GAAG,UAAU,CAAC,GAAG;IAC7H,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAA;CACvB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IMDSBadResponse.d.ts","sourceRoot":"","sources":["../../src/response/IMDSBadResponse.ts"],"names":[],"mappings":"AAKA,oBAAY,eAAe,GAAG;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,iBAAiB,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CACpC,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { ServerAuthorizationTokenResponse } from "./ServerAuthorizationTokenResponse";
|
|
2
|
+
import { ICrypto } from "../crypto/ICrypto";
|
|
3
|
+
import { ServerAuthorizationCodeResponse } from "./ServerAuthorizationCodeResponse";
|
|
4
|
+
import { Logger } from "../logger/Logger";
|
|
5
|
+
import { AuthToken } from "../account/AuthToken";
|
|
6
|
+
import { AuthenticationResult } from "./AuthenticationResult";
|
|
7
|
+
import { Authority } from "../authority/Authority";
|
|
8
|
+
import { CacheRecord } from "../cache/entities/CacheRecord";
|
|
9
|
+
import { CacheManager } from "../cache/CacheManager";
|
|
10
|
+
import { RequestStateObject } from "../utils/ProtocolUtils";
|
|
11
|
+
import { ICachePlugin } from "../cache/interface/ICachePlugin";
|
|
12
|
+
import { ISerializableTokenCache } from "../cache/interface/ISerializableTokenCache";
|
|
13
|
+
import { AuthorizationCodePayload } from "./AuthorizationCodePayload";
|
|
14
|
+
import { BaseAuthRequest } from "../request/BaseAuthRequest";
|
|
15
|
+
/**
|
|
16
|
+
* Class that handles response parsing.
|
|
17
|
+
*/
|
|
18
|
+
export declare class ResponseHandler {
|
|
19
|
+
private clientId;
|
|
20
|
+
private cacheStorage;
|
|
21
|
+
private cryptoObj;
|
|
22
|
+
private logger;
|
|
23
|
+
private homeAccountIdentifier;
|
|
24
|
+
private serializableCache;
|
|
25
|
+
private persistencePlugin;
|
|
26
|
+
constructor(clientId: string, cacheStorage: CacheManager, cryptoObj: ICrypto, logger: Logger, serializableCache: ISerializableTokenCache | null, persistencePlugin: ICachePlugin | null);
|
|
27
|
+
/**
|
|
28
|
+
* Function which validates server authorization code response.
|
|
29
|
+
* @param serverResponseHash
|
|
30
|
+
* @param cachedState
|
|
31
|
+
* @param cryptoObj
|
|
32
|
+
*/
|
|
33
|
+
validateServerAuthorizationCodeResponse(serverResponseHash: ServerAuthorizationCodeResponse, cachedState: string, cryptoObj: ICrypto): void;
|
|
34
|
+
/**
|
|
35
|
+
* Function which validates server authorization token response.
|
|
36
|
+
* @param serverResponse
|
|
37
|
+
*/
|
|
38
|
+
validateTokenResponse(serverResponse: ServerAuthorizationTokenResponse): void;
|
|
39
|
+
/**
|
|
40
|
+
* Returns a constructed token response based on given string. Also manages the cache updates and cleanups.
|
|
41
|
+
* @param serverTokenResponse
|
|
42
|
+
* @param authority
|
|
43
|
+
*/
|
|
44
|
+
handleServerTokenResponse(serverTokenResponse: ServerAuthorizationTokenResponse, authority: Authority, reqTimestamp: number, request: BaseAuthRequest, authCodePayload?: AuthorizationCodePayload, userAssertionHash?: string, handlingRefreshTokenResponse?: boolean, forceCacheRefreshTokenResponse?: boolean): Promise<AuthenticationResult>;
|
|
45
|
+
/**
|
|
46
|
+
* Generates CacheRecord
|
|
47
|
+
* @param serverTokenResponse
|
|
48
|
+
* @param idTokenObj
|
|
49
|
+
* @param authority
|
|
50
|
+
*/
|
|
51
|
+
private generateCacheRecord;
|
|
52
|
+
/**
|
|
53
|
+
* Generate Account
|
|
54
|
+
* @param serverTokenResponse
|
|
55
|
+
* @param idToken
|
|
56
|
+
* @param authority
|
|
57
|
+
*/
|
|
58
|
+
private generateAccountEntity;
|
|
59
|
+
/**
|
|
60
|
+
* Creates an @AuthenticationResult from @CacheRecord , @IdToken , and a boolean that states whether or not the result is from cache.
|
|
61
|
+
*
|
|
62
|
+
* Optionally takes a state string that is set as-is in the response.
|
|
63
|
+
*
|
|
64
|
+
* @param cacheRecord
|
|
65
|
+
* @param idTokenObj
|
|
66
|
+
* @param fromTokenCache
|
|
67
|
+
* @param stateString
|
|
68
|
+
*/
|
|
69
|
+
static generateAuthenticationResult(cryptoObj: ICrypto, authority: Authority, cacheRecord: CacheRecord, fromTokenCache: boolean, request: BaseAuthRequest, idTokenObj?: AuthToken, requestState?: RequestStateObject, code?: string): Promise<AuthenticationResult>;
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=ResponseHandler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResponseHandler.d.ts","sourceRoot":"","sources":["../../src/response/ResponseHandler.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,gCAAgC,EAAE,MAAM,oCAAoC,CAAC;AAEtF,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAG5C,OAAO,EAAE,+BAA+B,EAAE,MAAM,mCAAmC,CAAC;AACpF,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAMnD,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAiB,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAI3E,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAE/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,4CAA4C,CA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