@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,120 @@
|
|
|
1
|
+
/*! @azure/msal-common v0.0.1-alpha.0 2022-08-02 */
|
|
2
|
+
'use strict';
|
|
3
|
+
import { __extends, __awaiter, __generator } from '../_virtual/_tslib.js';
|
|
4
|
+
import { BaseClient } from './BaseClient.js';
|
|
5
|
+
import { ResponseHandler } from '../response/ResponseHandler.js';
|
|
6
|
+
import { RequestParameterBuilder } from '../request/RequestParameterBuilder.js';
|
|
7
|
+
import { GrantType } from '../utils/Constants.js';
|
|
8
|
+
import { StringUtils } from '../utils/StringUtils.js';
|
|
9
|
+
import { TimeUtils } from '../utils/TimeUtils.js';
|
|
10
|
+
import { CcsCredentialType } from '../account/CcsCredential.js';
|
|
11
|
+
|
|
12
|
+
/*
|
|
13
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
14
|
+
* Licensed under the MIT License.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Oauth2.0 Password grant client
|
|
18
|
+
* Note: We are only supporting public clients for password grant and for purely testing purposes
|
|
19
|
+
*/
|
|
20
|
+
var UsernamePasswordClient = /** @class */ (function (_super) {
|
|
21
|
+
__extends(UsernamePasswordClient, _super);
|
|
22
|
+
function UsernamePasswordClient(configuration) {
|
|
23
|
+
return _super.call(this, configuration) || this;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* API to acquire a token by passing the username and password to the service in exchage of credentials
|
|
27
|
+
* password_grant
|
|
28
|
+
* @param request
|
|
29
|
+
*/
|
|
30
|
+
UsernamePasswordClient.prototype.acquireToken = function (request) {
|
|
31
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
32
|
+
var reqTimestamp, response, responseHandler, tokenResponse;
|
|
33
|
+
return __generator(this, function (_a) {
|
|
34
|
+
switch (_a.label) {
|
|
35
|
+
case 0:
|
|
36
|
+
this.logger.info("in acquireToken call");
|
|
37
|
+
reqTimestamp = TimeUtils.nowSeconds();
|
|
38
|
+
return [4 /*yield*/, this.executeTokenRequest(this.authority, request)];
|
|
39
|
+
case 1:
|
|
40
|
+
response = _a.sent();
|
|
41
|
+
responseHandler = new ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, this.config.serializableCache, this.config.persistencePlugin);
|
|
42
|
+
// Validate response. This function throws a server error if an error is returned by the server.
|
|
43
|
+
responseHandler.validateTokenResponse(response.body);
|
|
44
|
+
tokenResponse = responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request);
|
|
45
|
+
return [2 /*return*/, tokenResponse];
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Executes POST request to token endpoint
|
|
52
|
+
* @param authority
|
|
53
|
+
* @param request
|
|
54
|
+
*/
|
|
55
|
+
UsernamePasswordClient.prototype.executeTokenRequest = function (authority, request) {
|
|
56
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
57
|
+
var thumbprint, requestBody, headers;
|
|
58
|
+
return __generator(this, function (_a) {
|
|
59
|
+
thumbprint = {
|
|
60
|
+
clientId: this.config.authOptions.clientId,
|
|
61
|
+
authority: authority.canonicalAuthority,
|
|
62
|
+
scopes: request.scopes,
|
|
63
|
+
claims: request.claims,
|
|
64
|
+
authenticationScheme: request.authenticationScheme,
|
|
65
|
+
resourceRequestMethod: request.resourceRequestMethod,
|
|
66
|
+
resourceRequestUri: request.resourceRequestUri,
|
|
67
|
+
shrClaims: request.shrClaims,
|
|
68
|
+
sshKid: request.sshKid
|
|
69
|
+
};
|
|
70
|
+
requestBody = this.createTokenRequestBody(request);
|
|
71
|
+
headers = this.createTokenRequestHeaders({
|
|
72
|
+
credential: request.username,
|
|
73
|
+
type: CcsCredentialType.UPN
|
|
74
|
+
});
|
|
75
|
+
return [2 /*return*/, this.executePostToTokenEndpoint(authority.tokenEndpoint, requestBody, headers, thumbprint)];
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Generates a map for all the params to be sent to the service
|
|
81
|
+
* @param request
|
|
82
|
+
*/
|
|
83
|
+
UsernamePasswordClient.prototype.createTokenRequestBody = function (request) {
|
|
84
|
+
var parameterBuilder = new RequestParameterBuilder();
|
|
85
|
+
parameterBuilder.addClientId(this.config.authOptions.clientId);
|
|
86
|
+
parameterBuilder.addUsername(request.username);
|
|
87
|
+
parameterBuilder.addPassword(request.password);
|
|
88
|
+
parameterBuilder.addScopes(request.scopes);
|
|
89
|
+
parameterBuilder.addResponseTypeForTokenAndIdToken();
|
|
90
|
+
parameterBuilder.addGrantType(GrantType.RESOURCE_OWNER_PASSWORD_GRANT);
|
|
91
|
+
parameterBuilder.addClientInfo();
|
|
92
|
+
parameterBuilder.addLibraryInfo(this.config.libraryInfo);
|
|
93
|
+
parameterBuilder.addApplicationTelemetry(this.config.telemetry.application);
|
|
94
|
+
parameterBuilder.addThrottling();
|
|
95
|
+
if (this.serverTelemetryManager) {
|
|
96
|
+
parameterBuilder.addServerTelemetry(this.serverTelemetryManager);
|
|
97
|
+
}
|
|
98
|
+
var correlationId = request.correlationId || this.config.cryptoInterface.createNewGuid();
|
|
99
|
+
parameterBuilder.addCorrelationId(correlationId);
|
|
100
|
+
if (this.config.clientCredentials.clientSecret) {
|
|
101
|
+
parameterBuilder.addClientSecret(this.config.clientCredentials.clientSecret);
|
|
102
|
+
}
|
|
103
|
+
if (this.config.clientCredentials.clientAssertion) {
|
|
104
|
+
var clientAssertion = this.config.clientCredentials.clientAssertion;
|
|
105
|
+
parameterBuilder.addClientAssertion(clientAssertion.assertion);
|
|
106
|
+
parameterBuilder.addClientAssertionType(clientAssertion.assertionType);
|
|
107
|
+
}
|
|
108
|
+
if (!StringUtils.isEmptyObj(request.claims) || this.config.authOptions.clientCapabilities && this.config.authOptions.clientCapabilities.length > 0) {
|
|
109
|
+
parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);
|
|
110
|
+
}
|
|
111
|
+
if (this.config.systemOptions.preventCorsPreflight && request.username) {
|
|
112
|
+
parameterBuilder.addCcsUpn(request.username);
|
|
113
|
+
}
|
|
114
|
+
return parameterBuilder.createQueryString();
|
|
115
|
+
};
|
|
116
|
+
return UsernamePasswordClient;
|
|
117
|
+
}(BaseClient));
|
|
118
|
+
|
|
119
|
+
export { UsernamePasswordClient };
|
|
120
|
+
//# sourceMappingURL=UsernamePasswordClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UsernamePasswordClient.js","sources":["../../src/client/UsernamePasswordClient.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { BaseClient } from \"./BaseClient\";\nimport { ClientConfiguration } from \"../config/ClientConfiguration\";\nimport { CommonUsernamePasswordRequest } from \"../request/CommonUsernamePasswordRequest\";\nimport { AuthenticationResult } from \"../response/AuthenticationResult\";\nimport { ResponseHandler } from \"../response/ResponseHandler\";\nimport { Authority } from \"../authority/Authority\";\nimport { NetworkResponse } from \"../network/NetworkManager\";\nimport { ServerAuthorizationTokenResponse } from \"../response/ServerAuthorizationTokenResponse\";\nimport { RequestParameterBuilder } from \"../request/RequestParameterBuilder\";\nimport { GrantType } from \"../utils/Constants\";\nimport { StringUtils } from \"../utils/StringUtils\";\nimport { RequestThumbprint } from \"../network/RequestThumbprint\";\nimport { TimeUtils } from \"../utils/TimeUtils\";\nimport { CcsCredentialType } from \"../account/CcsCredential\";\n\n/**\n * Oauth2.0 Password grant client\n * Note: We are only supporting public clients for password grant and for purely testing purposes\n */\nexport class UsernamePasswordClient extends BaseClient {\n\n constructor(configuration: ClientConfiguration) {\n super(configuration);\n }\n\n /**\n * API to acquire a token by passing the username and password to the service in exchage of credentials\n * password_grant\n * @param request\n */\n async acquireToken(request: CommonUsernamePasswordRequest): Promise<AuthenticationResult | null> {\n this.logger.info(\"in acquireToken call\");\n\n const reqTimestamp = TimeUtils.nowSeconds();\n const response = await this.executeTokenRequest(this.authority, request);\n\n const responseHandler = new ResponseHandler(\n this.config.authOptions.clientId,\n this.cacheManager,\n this.cryptoUtils,\n this.logger,\n this.config.serializableCache,\n this.config.persistencePlugin\n );\n\n // Validate response. This function throws a server error if an error is returned by the server.\n responseHandler.validateTokenResponse(response.body);\n const tokenResponse = responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request);\n\n return tokenResponse;\n }\n\n /**\n * Executes POST request to token endpoint\n * @param authority\n * @param request\n */\n private async executeTokenRequest(authority: Authority, request: CommonUsernamePasswordRequest): Promise<NetworkResponse<ServerAuthorizationTokenResponse>> {\n const thumbprint: RequestThumbprint = {\n clientId: this.config.authOptions.clientId,\n authority: authority.canonicalAuthority,\n scopes: request.scopes,\n claims: request.claims,\n authenticationScheme: request.authenticationScheme,\n resourceRequestMethod: request.resourceRequestMethod,\n resourceRequestUri: request.resourceRequestUri,\n shrClaims: request.shrClaims,\n sshKid: request.sshKid\n };\n const requestBody = this.createTokenRequestBody(request);\n const headers: Record<string, string> = this.createTokenRequestHeaders({\n credential: request.username,\n type: CcsCredentialType.UPN\n });\n\n return this.executePostToTokenEndpoint(authority.tokenEndpoint, requestBody, headers, thumbprint);\n }\n\n /**\n * Generates a map for all the params to be sent to the service\n * @param request\n */\n private createTokenRequestBody(request: CommonUsernamePasswordRequest): string {\n const parameterBuilder = new RequestParameterBuilder();\n\n parameterBuilder.addClientId(this.config.authOptions.clientId);\n parameterBuilder.addUsername(request.username);\n parameterBuilder.addPassword(request.password);\n\n parameterBuilder.addScopes(request.scopes);\n\n parameterBuilder.addResponseTypeForTokenAndIdToken();\n\n parameterBuilder.addGrantType(GrantType.RESOURCE_OWNER_PASSWORD_GRANT);\n parameterBuilder.addClientInfo();\n\n parameterBuilder.addLibraryInfo(this.config.libraryInfo);\n parameterBuilder.addApplicationTelemetry(this.config.telemetry.application);\n parameterBuilder.addThrottling();\n\n if (this.serverTelemetryManager) {\n parameterBuilder.addServerTelemetry(this.serverTelemetryManager);\n }\n\n const correlationId = request.correlationId || this.config.cryptoInterface.createNewGuid();\n parameterBuilder.addCorrelationId(correlationId);\n\n if (this.config.clientCredentials.clientSecret) {\n parameterBuilder.addClientSecret(this.config.clientCredentials.clientSecret);\n }\n\n if (this.config.clientCredentials.clientAssertion) {\n const clientAssertion = this.config.clientCredentials.clientAssertion;\n parameterBuilder.addClientAssertion(clientAssertion.assertion);\n parameterBuilder.addClientAssertionType(clientAssertion.assertionType);\n }\n\n if (!StringUtils.isEmptyObj(request.claims) || this.config.authOptions.clientCapabilities && this.config.authOptions.clientCapabilities.length > 0) {\n parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);\n }\n\n if (this.config.systemOptions.preventCorsPreflight && request.username) {\n parameterBuilder.addCcsUpn(request.username);\n }\n\n return parameterBuilder.createQueryString();\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAAA;;;AAGG;AAiBH;;;AAGG;AACH,IAAA,sBAAA,kBAAA,UAAA,MAAA,EAAA;IAA4C,SAAU,CAAA,sBAAA,EAAA,MAAA,CAAA,CAAA;AAElD,IAAA,SAAA,sBAAA,CAAY,aAAkC,EAAA;AAC1C,QAAA,OAAA,MAAA,CAAA,IAAA,CAAA,IAAA,EAAM,aAAa,CAAC,IAAA,IAAA,CAAA;KACvB;AAED;;;;AAIG;IACG,sBAAY,CAAA,SAAA,CAAA,YAAA,GAAlB,UAAmB,OAAsC,EAAA;;;;;;AACrD,wBAAA,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;AAEnC,wBAAA,YAAY,GAAG,SAAS,CAA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A;AAED,QAAA,OAAO,gBAAgB,CAAC,iBAAiB,EAAE,CAAC;KAC/C,CAAA;IACL,OAAC,sBAAA,CAAA;AAAD,CA5GA,CAA4C,UAAU,CA4GrD;;;;"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extensibility interface, which allows the app developer to return a token, based on the passed-in parameters, instead of fetching tokens from
|
|
3
|
+
* the Identity Provider (AAD).
|
|
4
|
+
* Developers need to construct and return an AppTokenProviderResult object back to MSAL. MSAL will cache the token response
|
|
5
|
+
* in the same way it would do if the result were comming from AAD.
|
|
6
|
+
* This extensibility point is only defined for the client_credential flow, i.e. acquireTokenByClientCredential and
|
|
7
|
+
* meant for Azure SDK to enhance Managed Identity support.
|
|
8
|
+
*/
|
|
9
|
+
export interface IAppTokenProvider {
|
|
10
|
+
(appTokenProviderParameters: AppTokenProviderParameters): Promise<AppTokenProviderResult>;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Input object for the IAppTokenProvider extensiblity. MSAL will create this object, which can be used
|
|
14
|
+
* to help create an AppTokenProviderResult.
|
|
15
|
+
*
|
|
16
|
+
* - correlationId - the correlation Id associated with the request
|
|
17
|
+
* - tenantId - the tenant Id for which the token must be provided
|
|
18
|
+
* - scopes - the scopes for which the token must be provided
|
|
19
|
+
* - claims - any extra claims that the token must satisfy
|
|
20
|
+
*/
|
|
21
|
+
export declare type AppTokenProviderParameters = {
|
|
22
|
+
readonly correlationId?: string;
|
|
23
|
+
readonly tenantId: string;
|
|
24
|
+
readonly scopes: Array<string>;
|
|
25
|
+
readonly claims?: string;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Output object for IAppTokenProvider extensiblity.
|
|
29
|
+
*
|
|
30
|
+
* - accessToken - the actual access token, typically in JWT format, that satisfies the request data AppTokenProviderParameters
|
|
31
|
+
* - expiresInSeconds - how long the tokens has before expiry, in seconds. Similar to the "expires_in" field in an AAD token response.
|
|
32
|
+
* - refreshInSeconds - how long the token has before it should be proactively refreshed. Similar to the "refresh_in" field in an AAD token response.
|
|
33
|
+
*/
|
|
34
|
+
export declare type AppTokenProviderResult = {
|
|
35
|
+
accessToken: string;
|
|
36
|
+
expiresInSeconds: number;
|
|
37
|
+
refreshInSeconds?: number;
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=AppTokenProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AppTokenProvider.d.ts","sourceRoot":"","sources":["../../src/config/AppTokenProvider.ts"],"names":[],"mappings":"AAKA;;;;;;;GAOG;AACH,MAAM,WAAW,iBAAiB;IAC9B,CAAC,0BAA0B,EAAE,0BAA0B,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;CAC7F;AAED;;;;;;;;GAQG;AACH,oBAAY,0BAA0B,GAAG;IACrC,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC/B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF;;;;;;GAMG;AACH,oBAAY,sBAAsB,GAAG;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAC"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { INetworkModule } from "../network/INetworkModule";
|
|
2
|
+
import { ICrypto } from "../crypto/ICrypto";
|
|
3
|
+
import { ILoggerCallback, LogLevel } from "../logger/Logger";
|
|
4
|
+
import { Authority } from "../authority/Authority";
|
|
5
|
+
import { AzureCloudInstance } from "../authority/AuthorityOptions";
|
|
6
|
+
import { CacheManager } from "../cache/CacheManager";
|
|
7
|
+
import { ServerTelemetryManager } from "../telemetry/server/ServerTelemetryManager";
|
|
8
|
+
import { ICachePlugin } from "../cache/interface/ICachePlugin";
|
|
9
|
+
import { ISerializableTokenCache } from "../cache/interface/ISerializableTokenCache";
|
|
10
|
+
import { ClientCredentials } from "../account/ClientCredentials";
|
|
11
|
+
/**
|
|
12
|
+
* Use the configuration object to configure MSAL Modules and initialize the base interfaces for MSAL.
|
|
13
|
+
*
|
|
14
|
+
* This object allows you to configure important elements of MSAL functionality:
|
|
15
|
+
* - authOptions - Authentication for application
|
|
16
|
+
* - cryptoInterface - Implementation of crypto functions
|
|
17
|
+
* - libraryInfo - Library metadata
|
|
18
|
+
* - telemetry - Telemetry options and data
|
|
19
|
+
* - loggerOptions - Logging for application
|
|
20
|
+
* - networkInterface - Network implementation
|
|
21
|
+
* - storageInterface - Storage implementation
|
|
22
|
+
* - systemOptions - Additional library options
|
|
23
|
+
* - clientCredentials - Credentials options for confidential clients
|
|
24
|
+
*/
|
|
25
|
+
export declare type ClientConfiguration = {
|
|
26
|
+
authOptions: AuthOptions;
|
|
27
|
+
systemOptions?: SystemOptions;
|
|
28
|
+
loggerOptions?: LoggerOptions;
|
|
29
|
+
storageInterface?: CacheManager;
|
|
30
|
+
networkInterface?: INetworkModule;
|
|
31
|
+
cryptoInterface?: ICrypto;
|
|
32
|
+
clientCredentials?: ClientCredentials;
|
|
33
|
+
libraryInfo?: LibraryInfo;
|
|
34
|
+
telemetry?: TelemetryOptions;
|
|
35
|
+
serverTelemetryManager?: ServerTelemetryManager | null;
|
|
36
|
+
persistencePlugin?: ICachePlugin | null;
|
|
37
|
+
serializableCache?: ISerializableTokenCache | null;
|
|
38
|
+
};
|
|
39
|
+
export declare type CommonClientConfiguration = {
|
|
40
|
+
authOptions: Required<AuthOptions>;
|
|
41
|
+
systemOptions: Required<SystemOptions>;
|
|
42
|
+
loggerOptions: Required<LoggerOptions>;
|
|
43
|
+
storageInterface: CacheManager;
|
|
44
|
+
networkInterface: INetworkModule;
|
|
45
|
+
cryptoInterface: Required<ICrypto>;
|
|
46
|
+
libraryInfo: LibraryInfo;
|
|
47
|
+
telemetry: Required<TelemetryOptions>;
|
|
48
|
+
serverTelemetryManager: ServerTelemetryManager | null;
|
|
49
|
+
clientCredentials: ClientCredentials;
|
|
50
|
+
persistencePlugin: ICachePlugin | null;
|
|
51
|
+
serializableCache: ISerializableTokenCache | null;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Use this to configure the auth options in the ClientConfiguration object
|
|
55
|
+
*
|
|
56
|
+
* - clientId - Client ID of your app registered with our Application registration portal : https://portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/RegisteredAppsPreview in Microsoft Identity Platform
|
|
57
|
+
* - authority - You can configure a specific authority, defaults to " " or "https://login.microsoftonline.com/common"
|
|
58
|
+
* - knownAuthorities - An array of URIs that are known to be valid. Used in B2C scenarios.
|
|
59
|
+
* - cloudDiscoveryMetadata - A string containing the cloud discovery response. Used in AAD scenarios.
|
|
60
|
+
* - clientCapabilities - Array of capabilities which will be added to the claims.access_token.xms_cc request property on every network request.
|
|
61
|
+
* - protocolMode - Enum that represents the protocol that msal follows. Used for configuring proper endpoints.
|
|
62
|
+
* - skipAuthorityMetadataCache - A flag to choose whether to use or not use the local metadata cache during authority initialization. Defaults to false.
|
|
63
|
+
*/
|
|
64
|
+
export declare type AuthOptions = {
|
|
65
|
+
clientId: string;
|
|
66
|
+
authority: Authority;
|
|
67
|
+
clientCapabilities?: Array<string>;
|
|
68
|
+
azureCloudOptions?: AzureCloudOptions;
|
|
69
|
+
skipAuthorityMetadataCache?: boolean;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Use this to configure token renewal info in the Configuration object
|
|
73
|
+
*
|
|
74
|
+
* - tokenRenewalOffsetSeconds - Sets the window of offset needed to renew the token before expiry
|
|
75
|
+
*/
|
|
76
|
+
export declare type SystemOptions = {
|
|
77
|
+
tokenRenewalOffsetSeconds?: number;
|
|
78
|
+
preventCorsPreflight?: boolean;
|
|
79
|
+
proxyUrl?: string;
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Use this to configure the logging that MSAL does, by configuring logger options in the Configuration object
|
|
83
|
+
*
|
|
84
|
+
* - loggerCallback - Callback for logger
|
|
85
|
+
* - piiLoggingEnabled - Sets whether pii logging is enabled
|
|
86
|
+
* - logLevel - Sets the level at which logging happens
|
|
87
|
+
* - correlationId - Sets the correlationId printed by the logger
|
|
88
|
+
*/
|
|
89
|
+
export declare type LoggerOptions = {
|
|
90
|
+
loggerCallback?: ILoggerCallback;
|
|
91
|
+
piiLoggingEnabled?: boolean;
|
|
92
|
+
logLevel?: LogLevel;
|
|
93
|
+
correlationId?: string;
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Library-specific options
|
|
97
|
+
*/
|
|
98
|
+
export declare type LibraryInfo = {
|
|
99
|
+
sku: string;
|
|
100
|
+
version: string;
|
|
101
|
+
cpu: string;
|
|
102
|
+
os: string;
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* AzureCloudInstance specific options
|
|
106
|
+
*
|
|
107
|
+
* - azureCloudInstance - string enum providing short notation for soverign and public cloud authorities
|
|
108
|
+
* - tenant - provision to provide the tenant info
|
|
109
|
+
*/
|
|
110
|
+
export declare type AzureCloudOptions = {
|
|
111
|
+
azureCloudInstance: AzureCloudInstance;
|
|
112
|
+
tenant?: string;
|
|
113
|
+
};
|
|
114
|
+
export declare type TelemetryOptions = {
|
|
115
|
+
application: ApplicationTelemetry;
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* Telemetry information sent on request
|
|
119
|
+
* - appName: Unique string name of an application
|
|
120
|
+
* - appVersion: Version of the application using MSAL
|
|
121
|
+
*/
|
|
122
|
+
export declare type ApplicationTelemetry = {
|
|
123
|
+
appName: string;
|
|
124
|
+
appVersion: string;
|
|
125
|
+
};
|
|
126
|
+
export declare const DEFAULT_SYSTEM_OPTIONS: Required<SystemOptions>;
|
|
127
|
+
/**
|
|
128
|
+
* Function that sets the default options when not explicitly configured from app developer
|
|
129
|
+
*
|
|
130
|
+
* @param Configuration
|
|
131
|
+
*
|
|
132
|
+
* @returns Configuration
|
|
133
|
+
*/
|
|
134
|
+
export declare function buildClientConfiguration({ authOptions: userAuthOptions, systemOptions: userSystemOptions, loggerOptions: userLoggerOption, storageInterface: storageImplementation, networkInterface: networkImplementation, cryptoInterface: cryptoImplementation, clientCredentials: clientCredentials, libraryInfo: libraryInfo, telemetry: telemetry, serverTelemetryManager: serverTelemetryManager, persistencePlugin: persistencePlugin, serializableCache: serializableCache, }: ClientConfiguration): CommonClientConfiguration;
|
|
135
|
+
//# sourceMappingURL=ClientConfiguration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClientConfiguration.d.ts","sourceRoot":"","sources":["../../src/config/ClientConfiguration.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAiC,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE3E,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG7D,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,YAAY,EAAuB,MAAM,uBAAuB,CAAC;AAC1E,OAAO,EAAE,sBAAsB,EAAE,MAAM,4CAA4C,CAAC;AACpF,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,4CAA4C,CAAC;AACrF,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAKjE;;;;;;;;;;;;;GAaG;AACH,oBAAY,mBAAmB,GAAG;IAC9B,WAAW,EAAE,WAAW,CAAC;IACzB,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,g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AE,iBAAiB,EACpC,iBAAiB,EAAE,iBAAiB,GACvC,EAAE,mBAAmB,GAAG,yBAAyB,CAkBrD"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/*! @azure/msal-common v0.0.1-alpha.0 2022-08-02 */
|
|
2
|
+
'use strict';
|
|
3
|
+
import { __assign, __awaiter, __generator } from '../_virtual/_tslib.js';
|
|
4
|
+
import { DEFAULT_CRYPTO_IMPLEMENTATION } from '../crypto/ICrypto.js';
|
|
5
|
+
import { AuthError } from '../error/AuthError.js';
|
|
6
|
+
import { LogLevel } from '../logger/Logger.js';
|
|
7
|
+
import { Constants } from '../utils/Constants.js';
|
|
8
|
+
import { version } from '../packageMetadata.js';
|
|
9
|
+
import { AzureCloudInstance } from '../authority/AuthorityOptions.js';
|
|
10
|
+
import { DefaultStorageClass } from '../cache/CacheManager.js';
|
|
11
|
+
|
|
12
|
+
/*
|
|
13
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
14
|
+
* Licensed under the MIT License.
|
|
15
|
+
*/
|
|
16
|
+
// Token renewal offset default in seconds
|
|
17
|
+
var DEFAULT_TOKEN_RENEWAL_OFFSET_SEC = 300;
|
|
18
|
+
var DEFAULT_SYSTEM_OPTIONS = {
|
|
19
|
+
tokenRenewalOffsetSeconds: DEFAULT_TOKEN_RENEWAL_OFFSET_SEC,
|
|
20
|
+
preventCorsPreflight: false,
|
|
21
|
+
proxyUrl: Constants.EMPTY_STRING
|
|
22
|
+
};
|
|
23
|
+
var DEFAULT_LOGGER_IMPLEMENTATION = {
|
|
24
|
+
loggerCallback: function () {
|
|
25
|
+
// allow users to not set loggerCallback
|
|
26
|
+
},
|
|
27
|
+
piiLoggingEnabled: false,
|
|
28
|
+
logLevel: LogLevel.Info,
|
|
29
|
+
correlationId: Constants.EMPTY_STRING
|
|
30
|
+
};
|
|
31
|
+
var DEFAULT_NETWORK_IMPLEMENTATION = {
|
|
32
|
+
sendGetRequestAsync: function () {
|
|
33
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
34
|
+
var notImplErr;
|
|
35
|
+
return __generator(this, function (_a) {
|
|
36
|
+
notImplErr = "Network interface - sendGetRequestAsync() has not been implemented";
|
|
37
|
+
throw AuthError.createUnexpectedError(notImplErr);
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
},
|
|
41
|
+
sendPostRequestAsync: function () {
|
|
42
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
43
|
+
var notImplErr;
|
|
44
|
+
return __generator(this, function (_a) {
|
|
45
|
+
notImplErr = "Network interface - sendPostRequestAsync() has not been implemented";
|
|
46
|
+
throw AuthError.createUnexpectedError(notImplErr);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
var DEFAULT_LIBRARY_INFO = {
|
|
52
|
+
sku: Constants.SKU,
|
|
53
|
+
version: version,
|
|
54
|
+
cpu: Constants.EMPTY_STRING,
|
|
55
|
+
os: Constants.EMPTY_STRING
|
|
56
|
+
};
|
|
57
|
+
var DEFAULT_CLIENT_CREDENTIALS = {
|
|
58
|
+
clientSecret: Constants.EMPTY_STRING,
|
|
59
|
+
clientAssertion: undefined
|
|
60
|
+
};
|
|
61
|
+
var DEFAULT_AZURE_CLOUD_OPTIONS = {
|
|
62
|
+
azureCloudInstance: AzureCloudInstance.None,
|
|
63
|
+
tenant: "" + Constants.DEFAULT_COMMON_TENANT
|
|
64
|
+
};
|
|
65
|
+
var DEFAULT_TELEMETRY_OPTIONS = {
|
|
66
|
+
application: {
|
|
67
|
+
appName: "",
|
|
68
|
+
appVersion: ""
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Function that sets the default options when not explicitly configured from app developer
|
|
73
|
+
*
|
|
74
|
+
* @param Configuration
|
|
75
|
+
*
|
|
76
|
+
* @returns Configuration
|
|
77
|
+
*/
|
|
78
|
+
function buildClientConfiguration(_a) {
|
|
79
|
+
var userAuthOptions = _a.authOptions, userSystemOptions = _a.systemOptions, userLoggerOption = _a.loggerOptions, storageImplementation = _a.storageInterface, networkImplementation = _a.networkInterface, cryptoImplementation = _a.cryptoInterface, clientCredentials = _a.clientCredentials, libraryInfo = _a.libraryInfo, telemetry = _a.telemetry, serverTelemetryManager = _a.serverTelemetryManager, persistencePlugin = _a.persistencePlugin, serializableCache = _a.serializableCache;
|
|
80
|
+
var loggerOptions = __assign(__assign({}, DEFAULT_LOGGER_IMPLEMENTATION), userLoggerOption);
|
|
81
|
+
return {
|
|
82
|
+
authOptions: buildAuthOptions(userAuthOptions),
|
|
83
|
+
systemOptions: __assign(__assign({}, DEFAULT_SYSTEM_OPTIONS), userSystemOptions),
|
|
84
|
+
loggerOptions: loggerOptions,
|
|
85
|
+
storageInterface: storageImplementation || new DefaultStorageClass(userAuthOptions.clientId, DEFAULT_CRYPTO_IMPLEMENTATION),
|
|
86
|
+
networkInterface: networkImplementation || DEFAULT_NETWORK_IMPLEMENTATION,
|
|
87
|
+
cryptoInterface: cryptoImplementation || DEFAULT_CRYPTO_IMPLEMENTATION,
|
|
88
|
+
clientCredentials: clientCredentials || DEFAULT_CLIENT_CREDENTIALS,
|
|
89
|
+
libraryInfo: __assign(__assign({}, DEFAULT_LIBRARY_INFO), libraryInfo),
|
|
90
|
+
telemetry: __assign(__assign({}, DEFAULT_TELEMETRY_OPTIONS), telemetry),
|
|
91
|
+
serverTelemetryManager: serverTelemetryManager || null,
|
|
92
|
+
persistencePlugin: persistencePlugin || null,
|
|
93
|
+
serializableCache: serializableCache || null,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Construct authoptions from the client and platform passed values
|
|
98
|
+
* @param authOptions
|
|
99
|
+
*/
|
|
100
|
+
function buildAuthOptions(authOptions) {
|
|
101
|
+
return __assign({ clientCapabilities: [], azureCloudOptions: DEFAULT_AZURE_CLOUD_OPTIONS, skipAuthorityMetadataCache: false }, authOptions);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export { DEFAULT_SYSTEM_OPTIONS, buildClientConfiguration };
|
|
105
|
+
//# sourceMappingURL=ClientConfiguration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClientConfiguration.js","sources":["../../src/config/ClientConfiguration.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { INetworkModule } from \"../network/INetworkModule\";\nimport { DEFAULT_CRYPTO_IMPLEMENTATION, ICrypto } from \"../crypto/ICrypto\";\nimport { AuthError } from \"../error/AuthError\";\nimport { ILoggerCallback, LogLevel } from \"../logger/Logger\";\nimport { Constants } from \"../utils/Constants\";\nimport { version } from \"../packageMetadata\";\nimport { Authority } from \"../authority/Authority\";\nimport { AzureCloudInstance } from \"../authority/AuthorityOptions\";\nimport { CacheManager, DefaultStorageClass } from \"../cache/CacheManager\";\nimport { ServerTelemetryManager } from \"../telemetry/server/ServerTelemetryManager\";\nimport { ICachePlugin } from \"../cache/interface/ICachePlugin\";\nimport { ISerializableTokenCache } from \"../cache/interface/ISerializableTokenCache\";\nimport { ClientCredentials } from \"../account/ClientCredentials\";\n\n// Token renewal offset default in seconds\nconst DEFAULT_TOKEN_RENEWAL_OFFSET_SEC = 300;\n\n/**\n * Use the configuration object to configure MSAL Modules and initialize the base interfaces for MSAL.\n *\n * This object allows you to configure important elements of MSAL functionality:\n * - authOptions - Authentication for application\n * - cryptoInterface - Implementation of crypto functions\n * - libraryInfo - Library metadata\n * - telemetry - Telemetry options and data\n * - loggerOptions - Logging for application\n * - networkInterface - Network implementation\n * - storageInterface - Storage implementation\n * - systemOptions - Additional library options\n * - clientCredentials - Credentials options for confidential clients\n */\nexport type ClientConfiguration = {\n authOptions: AuthOptions,\n systemOptions?: SystemOptions,\n loggerOptions?: LoggerOptions,\n storageInterface?: CacheManager,\n networkInterface?: INetworkModule,\n cryptoInterface?: ICrypto,\n clientCredentials?: ClientCredentials,\n libraryInfo?: LibraryInfo\n telemetry?: TelemetryOptions,\n serverTelemetryManager?: ServerTelemetryManager | null,\n persistencePlugin?: ICachePlugin | null,\n serializableCache?: ISerializableTokenCache | null, \n};\n\nexport type CommonClientConfiguration = {\n authOptions: Required<AuthOptions>,\n systemOptions: Required<SystemOptions>,\n loggerOptions : Required<LoggerOptions>,\n storageInterface: CacheManager,\n networkInterface : INetworkModule,\n cryptoInterface : Required<ICrypto>,\n libraryInfo : LibraryInfo,\n telemetry: Required<TelemetryOptions>,\n serverTelemetryManager: ServerTelemetryManager | null,\n clientCredentials: ClientCredentials,\n persistencePlugin: ICachePlugin | null,\n serializableCache: ISerializableTokenCache | null, \n};\n\n/**\n * Use this to configure the auth options in the ClientConfiguration object\n *\n * - clientId - Client ID of your app registered with our Application registration portal : https://portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/RegisteredAppsPreview in Microsoft Identity Platform\n * - authority - You can configure a specific authority, defaults to \" \" or \"https://login.microsoftonline.com/common\"\n * - knownAuthorities - An array of URIs that are known to be valid. Used in B2C scenarios.\n * - cloudDiscoveryMetadata - A string containing the cloud discovery response. Used in AAD scenarios.\n * - clientCapabilities - Array of capabilities which will be added to the claims.access_token.xms_cc request property on every network request.\n * - protocolMode - Enum that represents the protocol that msal follows. Used for configuring proper endpoints.\n * - skipAuthorityMetadataCache - A flag to choose whether to use or not use the local metadata cache during authority initialization. Defaults to false.\n */\nexport type AuthOptions = {\n clientId: string;\n authority: Authority;\n clientCapabilities?: Array<string>;\n azureCloudOptions?: AzureCloudOptions;\n skipAuthorityMetadataCache?: boolean;\n};\n\n/**\n * Use this to configure token renewal info in the Configuration object\n *\n * - tokenRenewalOffsetSeconds - Sets the window of offset needed to renew the token before expiry\n */\nexport type SystemOptions = {\n tokenRenewalOffsetSeconds?: number;\n preventCorsPreflight?: boolean;\n proxyUrl?: string;\n};\n\n/**\n * Use this to configure the logging that MSAL does, by configuring logger options in the Configuration object\n *\n * - loggerCallback - Callback for logger\n * - piiLoggingEnabled - Sets whether pii logging is enabled\n * - logLevel - Sets the level at which logging happens\n * - correlationId - Sets the correlationId printed by the logger\n */\nexport type LoggerOptions = {\n loggerCallback?: ILoggerCallback,\n piiLoggingEnabled?: boolean,\n logLevel?: LogLevel,\n correlationId?: string\n};\n\n/**\n * Library-specific options\n */\nexport type LibraryInfo = {\n sku: string,\n version: string,\n cpu: string,\n os: string\n};\n\n/**\n * AzureCloudInstance specific options\n *\n * - azureCloudInstance - string enum providing short notation for soverign and public cloud authorities\n * - tenant - provision to provide the tenant info\n */\nexport type AzureCloudOptions = {\n azureCloudInstance: AzureCloudInstance;\n tenant?: string,\n};\n\nexport type TelemetryOptions = {\n application: ApplicationTelemetry;\n};\n\n/**\n * Telemetry information sent on request\n * - appName: Unique string name of an application\n * - appVersion: Version of the application using MSAL\n */\nexport type ApplicationTelemetry = {\n appName: string;\n appVersion: string;\n};\n\nexport const DEFAULT_SYSTEM_OPTIONS: Required<SystemOptions> = {\n tokenRenewalOffsetSeconds: DEFAULT_TOKEN_RENEWAL_OFFSET_SEC,\n preventCorsPreflight: false,\n proxyUrl: Constants.EMPTY_STRING\n};\n\nconst DEFAULT_LOGGER_IMPLEMENTATION: Required<LoggerOptions> = {\n loggerCallback: () => {\n // allow users to not set loggerCallback\n },\n piiLoggingEnabled: false,\n logLevel: LogLevel.Info,\n correlationId: Constants.EMPTY_STRING\n};\n\nconst DEFAULT_NETWORK_IMPLEMENTATION: INetworkModule = {\n async sendGetRequestAsync<T>(): Promise<T> {\n const notImplErr = \"Network interface - sendGetRequestAsync() has not been implemented\";\n throw AuthError.createUnexpectedError(notImplErr);\n },\n async sendPostRequestAsync<T>(): Promise<T> {\n const notImplErr = \"Network interface - sendPostRequestAsync() has not been implemented\";\n throw AuthError.createUnexpectedError(notImplErr);\n }\n};\n\nconst DEFAULT_LIBRARY_INFO: LibraryInfo = {\n sku: Constants.SKU,\n version: version,\n cpu: Constants.EMPTY_STRING,\n os: Constants.EMPTY_STRING\n};\n\nconst DEFAULT_CLIENT_CREDENTIALS: ClientCredentials = {\n clientSecret: Constants.EMPTY_STRING,\n clientAssertion: undefined\n};\n\nconst DEFAULT_AZURE_CLOUD_OPTIONS: AzureCloudOptions = {\n azureCloudInstance: AzureCloudInstance.None,\n tenant: `${Constants.DEFAULT_COMMON_TENANT}`\n};\n\nconst DEFAULT_TELEMETRY_OPTIONS: Required<TelemetryOptions> = {\n application: {\n appName: \"\",\n appVersion: \"\"\n }\n};\n\n/**\n * Function that sets the default options when not explicitly configured from app developer\n *\n * @param Configuration\n *\n * @returns Configuration\n */\nexport function buildClientConfiguration(\n {\n authOptions: userAuthOptions,\n systemOptions: userSystemOptions,\n loggerOptions: userLoggerOption,\n storageInterface: storageImplementation,\n networkInterface: networkImplementation,\n cryptoInterface: cryptoImplementation,\n clientCredentials: clientCredentials,\n libraryInfo: libraryInfo,\n telemetry: telemetry,\n serverTelemetryManager: serverTelemetryManager,\n persistencePlugin: persistencePlugin,\n serializableCache: serializableCache, \n }: ClientConfiguration): CommonClientConfiguration {\n\n const loggerOptions = { ...DEFAULT_LOGGER_IMPLEMENTATION, ...userLoggerOption };\n\n return {\n authOptions: buildAuthOptions(userAuthOptions),\n systemOptions: { ...DEFAULT_SYSTEM_OPTIONS, ...userSystemOptions },\n loggerOptions: loggerOptions,\n storageInterface: storageImplementation || new DefaultStorageClass(userAuthOptions.clientId, DEFAULT_CRYPTO_IMPLEMENTATION),\n networkInterface: networkImplementation || DEFAULT_NETWORK_IMPLEMENTATION,\n cryptoInterface: cryptoImplementation || DEFAULT_CRYPTO_IMPLEMENTATION,\n clientCredentials: clientCredentials || DEFAULT_CLIENT_CREDENTIALS,\n libraryInfo: { ...DEFAULT_LIBRARY_INFO, ...libraryInfo },\n telemetry: { ...DEFAULT_TELEMETRY_OPTIONS, ...telemetry },\n serverTelemetryManager: serverTelemetryManager || null,\n persistencePlugin: persistencePlugin || null,\n serializableCache: serializableCache || null, \n };\n}\n\n/**\n * Construct authoptions from the client and platform passed values\n * @param authOptions\n */\nfunction buildAuthOptions(authOptions: AuthOptions): Required<AuthOptions> {\n return {\n clientCapabilities: [],\n azureCloudOptions: DEFAULT_AZURE_CLOUD_OPTIONS,\n skipAuthorityMetadataCache: false,\n ...authOptions\n };\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAAA;;;AAGG;AAgBH;AACA,IAAM,gCAAgC,GAAG,GAAG,CAAC;AA8HhC,IAAA,sBAAsB,GAA4B;AAC3D,IAAA,yBAAyB,EAAE,gCAAgC;AAC3D,IAAA,oBAAoB,EAAE,KAAK;IAC3B,QAAQ,EAAE,SAAS,CAAC,YAAY;EAClC;AAEF,IAAM,6BAA6B,GAA4B;AAC3D,IAAA,cAAc,EAAE,YAAA;;KAEf;AACD,IAAA,iBAAiB,EAAE,KAAK;IACxB,QAAQ,EAAE,QAAQ,CAAC,IAAI;IACvB,aAAa,EAAE,SAAS,CAAC,YAAY;CACxC,CAAC;AAEF,IAAM,8BAA8B,GAAmB;AAC7C,IAAA,mBAAmB,EAAzB,YAAA;;;;gBACU,UAAU,GAAG,oEAAoE,CAAC;AACxF,gBAAA,MAAM,SAAS,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;;;AACrD,KAAA;AACK,IAAA,oBAAoB,EAA1B,YAAA;;;;gBACU,UAAU,GAAG,qEAAqE,CAAC;AACzF,gBAAA,MAAM,SAAS,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;;;AACrD,KAAA;CACJ,CAAC;AAEF,IAAM,oBAAoB,GAAgB;IACtC,GAAG,EAAE,SAAS,CAAC,GAAG;AAClB,IAAA,OAAO,EAAE,OAAO;IAChB,GAAG,EAAE,SAAS,CAAC,YAAY;IAC3B,EAAE,EAAE,SAAS,CAAC,YAAY;CAC7B,CAAC;AAEF,IAAM,0BAA0B,GAAsB;IAClD,YAAY,EAAE,SAAS,CAAC,YAAY;AACpC,IAAA,eAAe,EAAE,SAAS;CAC7B,CAAC;AAEF,IAAM,2BAA2B,GAAsB;IACnD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6B;QACtE,iBAAiB,EAAE,iBAAiB,IAAI,0BAA0B;AAClE,QAAA,WAAW,EAAO,QAAA,CAAA,QAAA,CAAA,EAAA,EAAA,oBAAoB,CAAK,EAAA,WAAW,CAAE;AACxD,QAAA,SAAS,EAAO,QAAA,CAAA,QAAA,CAAA,EAAA,EAAA,yBAAyB,CAAK,EAAA,SAAS,CAAE;QACzD,sBAAsB,EAAE,sBAAsB,IAAI,IAAI;QACtD,iBAAiB,EAAE,iBAAiB,IAAI,IAAI;QAC5C,iBAAiB,EAAE,iBAAiB,IAAI,IAAI;KAC/C,CAAC;AACN,CAAC;AAED;;;AAGG;AACH,SAAS,gBAAgB,CAAC,WAAwB,EAAA;AAC9C,IAAA,OAAA,QAAA,CAAA,EACI,kBAAkB,EAAE,EAAE,EACtB,iBAAiB,EAAE,2BAA2B,EAC9C,0BAA0B,EAAE,KAAK,EAAA,EAC9B,WAAW,CAChB,CAAA;AACN;;;;"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { BaseAuthRequest } from "../request/BaseAuthRequest";
|
|
2
|
+
import { SignedHttpRequest } from "./SignedHttpRequest";
|
|
3
|
+
/**
|
|
4
|
+
* The PkceCodes type describes the structure
|
|
5
|
+
* of objects that contain PKCE code
|
|
6
|
+
* challenge and verifier pairs
|
|
7
|
+
*/
|
|
8
|
+
export declare type PkceCodes = {
|
|
9
|
+
verifier: string;
|
|
10
|
+
challenge: string;
|
|
11
|
+
};
|
|
12
|
+
export declare type SignedHttpRequestParameters = Pick<BaseAuthRequest, "resourceRequestMethod" | "resourceRequestUri" | "shrClaims" | "shrNonce"> & {
|
|
13
|
+
correlationId?: string;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Interface for crypto functions used by library
|
|
17
|
+
*/
|
|
18
|
+
export interface ICrypto {
|
|
19
|
+
/**
|
|
20
|
+
* Creates a guid randomly.
|
|
21
|
+
*/
|
|
22
|
+
createNewGuid(): string;
|
|
23
|
+
/**
|
|
24
|
+
* base64 Encode string
|
|
25
|
+
* @param input
|
|
26
|
+
*/
|
|
27
|
+
base64Encode(input: string): string;
|
|
28
|
+
/**
|
|
29
|
+
* base64 decode string
|
|
30
|
+
* @param input
|
|
31
|
+
*/
|
|
32
|
+
base64Decode(input: string): string;
|
|
33
|
+
/**
|
|
34
|
+
* Generate PKCE codes for OAuth. See RFC here: https://tools.ietf.org/html/rfc7636
|
|
35
|
+
*/
|
|
36
|
+
generatePkceCodes(): Promise<PkceCodes>;
|
|
37
|
+
/**
|
|
38
|
+
* Generates an JWK RSA S256 Thumbprint
|
|
39
|
+
* @param request
|
|
40
|
+
*/
|
|
41
|
+
getPublicKeyThumbprint(request: SignedHttpRequestParameters): Promise<string>;
|
|
42
|
+
/**
|
|
43
|
+
* Removes cryptographic keypair from key store matching the keyId passed in
|
|
44
|
+
* @param kid
|
|
45
|
+
*/
|
|
46
|
+
removeTokenBindingKey(kid: string): Promise<boolean>;
|
|
47
|
+
/**
|
|
48
|
+
* Removes all cryptographic keys from IndexedDB storage
|
|
49
|
+
*/
|
|
50
|
+
clearKeystore(): Promise<boolean>;
|
|
51
|
+
/**
|
|
52
|
+
* Returns a signed proof-of-possession token with a given acces token that contains a cnf claim with the required kid.
|
|
53
|
+
* @param accessToken
|
|
54
|
+
*/
|
|
55
|
+
signJwt(payload: SignedHttpRequest, kid: string, correlationId?: string): Promise<string>;
|
|
56
|
+
/**
|
|
57
|
+
* Returns the SHA-256 hash of an input string
|
|
58
|
+
* @param plainText
|
|
59
|
+
*/
|
|
60
|
+
hashString(plainText: string): Promise<string>;
|
|
61
|
+
}
|
|
62
|
+
export declare const DEFAULT_CRYPTO_IMPLEMENTATION: ICrypto;
|
|
63
|
+
//# sourceMappingURL=ICrypto.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ICrypto.d.ts","sourceRoot":"","sources":["../../src/crypto/ICrypto.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,eAAe,EAAE,MAAM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use strict';
|
|
3
|
+
import { __awaiter, __generator } from '../_virtual/_tslib.js';
|
|
4
|
+
import { AuthError } from '../error/AuthError.js';
|
|
5
|
+
|
|
6
|
+
/*
|
|
7
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
8
|
+
* Licensed under the MIT License.
|
|
9
|
+
*/
|
|
10
|
+
var DEFAULT_CRYPTO_IMPLEMENTATION = {
|
|
11
|
+
createNewGuid: function () {
|
|
12
|
+
var notImplErr = "Crypto interface - createNewGuid() has not been implemented";
|
|
13
|
+
throw AuthError.createUnexpectedError(notImplErr);
|
|
14
|
+
},
|
|
15
|
+
base64Decode: function () {
|
|
16
|
+
var notImplErr = "Crypto interface - base64Decode() has not been implemented";
|
|
17
|
+
throw AuthError.createUnexpectedError(notImplErr);
|
|
18
|
+
},
|
|
19
|
+
base64Encode: function () {
|
|
20
|
+
var notImplErr = "Crypto interface - base64Encode() has not been implemented";
|
|
21
|
+
throw AuthError.createUnexpectedError(notImplErr);
|
|
22
|
+
},
|
|
23
|
+
generatePkceCodes: function () {
|
|
24
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
25
|
+
var notImplErr;
|
|
26
|
+
return __generator(this, function (_a) {
|
|
27
|
+
notImplErr = "Crypto interface - generatePkceCodes() has not been implemented";
|
|
28
|
+
throw AuthError.createUnexpectedError(notImplErr);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
getPublicKeyThumbprint: function () {
|
|
33
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
34
|
+
var notImplErr;
|
|
35
|
+
return __generator(this, function (_a) {
|
|
36
|
+
notImplErr = "Crypto interface - getPublicKeyThumbprint() has not been implemented";
|
|
37
|
+
throw AuthError.createUnexpectedError(notImplErr);
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
},
|
|
41
|
+
removeTokenBindingKey: function () {
|
|
42
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
43
|
+
var notImplErr;
|
|
44
|
+
return __generator(this, function (_a) {
|
|
45
|
+
notImplErr = "Crypto interface - removeTokenBindingKey() has not been implemented";
|
|
46
|
+
throw AuthError.createUnexpectedError(notImplErr);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
},
|
|
50
|
+
clearKeystore: function () {
|
|
51
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
52
|
+
var notImplErr;
|
|
53
|
+
return __generator(this, function (_a) {
|
|
54
|
+
notImplErr = "Crypto interface - clearKeystore() has not been implemented";
|
|
55
|
+
throw AuthError.createUnexpectedError(notImplErr);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
},
|
|
59
|
+
signJwt: function () {
|
|
60
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
61
|
+
var notImplErr;
|
|
62
|
+
return __generator(this, function (_a) {
|
|
63
|
+
notImplErr = "Crypto interface - signJwt() has not been implemented";
|
|
64
|
+
throw AuthError.createUnexpectedError(notImplErr);
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
},
|
|
68
|
+
hashString: function () {
|
|
69
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
70
|
+
var notImplErr;
|
|
71
|
+
return __generator(this, function (_a) {
|
|
72
|
+
notImplErr = "Crypto interface - hashString() has not been implemented";
|
|
73
|
+
throw AuthError.createUnexpectedError(notImplErr);
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export { DEFAULT_CRYPTO_IMPLEMENTATION };
|
|
80
|
+
//# sourceMappingURL=ICrypto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ICrypto.js","sources":["../../src/crypto/ICrypto.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { AuthError } from \"../error/AuthError\";\nimport { BaseAuthRequest } from \"../request/BaseAuthRequest\";\nimport { SignedHttpRequest } from \"./SignedHttpRequest\";\n\n/**\n * The PkceCodes type describes the structure\n * of objects that contain PKCE code\n * challenge and verifier pairs\n */\nexport type PkceCodes = {\n verifier: string,\n challenge: string\n};\n\nexport type SignedHttpRequestParameters = Pick<BaseAuthRequest, \"resourceRequestMethod\" | \"resourceRequestUri\" | \"shrClaims\" | \"shrNonce\" > & {\n correlationId?: string\n};\n\n/**\n * Interface for crypto functions used by library\n */\nexport interface ICrypto {\n /**\n * Creates a guid randomly.\n */\n createNewGuid(): string;\n /**\n * base64 Encode string\n * @param input \n */\n base64Encode(input: string): string;\n /**\n * base64 decode string\n * @param input \n */\n base64Decode(input: string): string;\n /**\n * Generate PKCE codes for OAuth. See RFC here: https://tools.ietf.org/html/rfc7636\n */\n generatePkceCodes(): Promise<PkceCodes>;\n /**\n * Generates an JWK RSA S256 Thumbprint\n * @param request\n */\n getPublicKeyThumbprint(request: SignedHttpRequestParameters): Promise<string>;\n /**\n * Removes cryptographic keypair from key store matching the keyId passed in\n * @param kid \n */\n removeTokenBindingKey(kid: string): Promise<boolean>;\n /**\n * Removes all cryptographic keys from IndexedDB storage\n */\n clearKeystore(): Promise<boolean>;\n /** \n * Returns a signed proof-of-possession token with a given acces token that contains a cnf claim with the required kid.\n * @param accessToken \n */\n signJwt(payload: SignedHttpRequest, kid: string, correlationId?: string): Promise<string>;\n /**\n * Returns the SHA-256 hash of an input string\n * @param plainText\n */\n hashString(plainText: string): Promise<string>;\n}\n\nexport const DEFAULT_CRYPTO_IMPLEMENTATION: ICrypto = {\n createNewGuid: (): string => {\n const notImplErr = \"Crypto interface - createNewGuid() has not been implemented\";\n throw AuthError.createUnexpectedError(notImplErr);\n },\n base64Decode: (): string => {\n const notImplErr = \"Crypto interface - base64Decode() has not been implemented\";\n throw AuthError.createUnexpectedError(notImplErr);\n },\n base64Encode: (): string => {\n const notImplErr = \"Crypto interface - base64Encode() has not been implemented\";\n throw AuthError.createUnexpectedError(notImplErr);\n },\n async generatePkceCodes(): Promise<PkceCodes> {\n const notImplErr = \"Crypto interface - generatePkceCodes() has not been implemented\";\n throw AuthError.createUnexpectedError(notImplErr);\n },\n async getPublicKeyThumbprint(): Promise<string> {\n const notImplErr = \"Crypto interface - getPublicKeyThumbprint() has not been implemented\";\n throw AuthError.createUnexpectedError(notImplErr);\n },\n async removeTokenBindingKey(): Promise<boolean> {\n const notImplErr = \"Crypto interface - removeTokenBindingKey() has not been implemented\";\n throw AuthError.createUnexpectedError(notImplErr);\n },\n async clearKeystore(): Promise<boolean> {\n const notImplErr = \"Crypto interface - clearKeystore() has not been implemented\";\n throw AuthError.createUnexpectedError(notImplErr);\n },\n async signJwt(): Promise<string> {\n const notImplErr = \"Crypto interface - signJwt() has not been implemented\";\n throw AuthError.createUnexpectedError(notImplErr);\n },\n async hashString(): Promise<string> {\n const notImplErr = \"Crypto interface - hashString() has not been implemented\";\n throw AuthError.createUnexpectedError(notImplErr);\n }\n};\n"],"names":[],"mappings":";;;;;AAAA;;;AAGG;AAoEU,IAAA,6BAA6B,GAAY;AAClD,IAAA,aAAa,EAAE,YAAA;QACX,IAAM,UAAU,GAAG,6DAA6D,CAAC;AACjF,QAAA,MAAM,SAAS,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;KACrD;AACD,IAAA,YAAY,EAAE,YAAA;QACV,IAAM,UAAU,GAAG,4DAA4D,CAAC;AAChF,QAAA,MAAM,SAAS,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;KACrD;AACD,IAAA,YAAY,EAAE,YAAA;QACV,IAAM,UAAU,GAAG,4DAA4D,CAAC;AAChF,QAAA,MAAM,SAAS,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;KACrD;AACK,IAAA,iBAAiB,EAAvB,YAAA;;;;gBACU,UAAU,GAAG,iEAAiE,CAAC;AACrF,gBAAA,MAAM,SAAS,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;;;AACrD,KAAA;AACK,IAAA,sBAAsB,EAA5B,YAAA;;;;gBACU,UAAU,GAAG,sEAAsE,CA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