@azure/msal-common 4.5.0 → 5.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +178 -0
- package/{changelog.md → CHANGELOG.md} +446 -390
- package/LICENSE +21 -21
- package/README.md +62 -61
- package/dist/_virtual/_tslib.js +1 -1
- package/dist/account/AuthToken.js +7 -7
- package/dist/account/AuthToken.js.map +1 -1
- package/dist/account/CcsCredential.js +1 -1
- package/dist/account/CcsCredential.js.map +1 -1
- package/dist/account/ClientInfo.js +10 -10
- package/dist/account/ClientInfo.js.map +1 -1
- package/dist/account/TokenClaims.d.ts +5 -0
- package/dist/account/TokenClaims.d.ts.map +1 -1
- package/dist/authority/Authority.d.ts.map +1 -1
- package/dist/authority/Authority.js +60 -54
- package/dist/authority/Authority.js.map +1 -1
- package/dist/authority/AuthorityFactory.js +9 -9
- package/dist/authority/AuthorityFactory.js.map +1 -1
- package/dist/authority/AuthorityType.js +1 -1
- package/dist/authority/AuthorityType.js.map +1 -1
- package/dist/authority/CloudInstanceDiscoveryResponse.js +1 -1
- package/dist/authority/CloudInstanceDiscoveryResponse.js.map +1 -1
- package/dist/authority/OpenIdConfigResponse.d.ts +1 -1
- package/dist/authority/OpenIdConfigResponse.d.ts.map +1 -1
- package/dist/authority/OpenIdConfigResponse.js +1 -2
- package/dist/authority/OpenIdConfigResponse.js.map +1 -1
- package/dist/authority/ProtocolMode.js +1 -1
- package/dist/authority/ProtocolMode.js.map +1 -1
- package/dist/authority/RegionDiscovery.js +9 -9
- package/dist/authority/RegionDiscovery.js.map +1 -1
- package/dist/cache/CacheManager.d.ts +23 -9
- package/dist/cache/CacheManager.d.ts.map +1 -1
- package/dist/cache/CacheManager.js +244 -114
- package/dist/cache/CacheManager.js.map +1 -1
- package/dist/cache/entities/AccessTokenEntity.d.ts +3 -2
- package/dist/cache/entities/AccessTokenEntity.d.ts.map +1 -1
- package/dist/cache/entities/AccessTokenEntity.js +23 -17
- package/dist/cache/entities/AccessTokenEntity.js.map +1 -1
- package/dist/cache/entities/AccountEntity.d.ts +2 -2
- package/dist/cache/entities/AccountEntity.d.ts.map +1 -1
- package/dist/cache/entities/AccountEntity.js +18 -18
- package/dist/cache/entities/AccountEntity.js.map +1 -1
- package/dist/cache/entities/AppMetadataEntity.js +1 -1
- package/dist/cache/entities/AppMetadataEntity.js.map +1 -1
- package/dist/cache/entities/AuthorityMetadataEntity.d.ts +1 -1
- package/dist/cache/entities/AuthorityMetadataEntity.d.ts.map +1 -1
- package/dist/cache/entities/AuthorityMetadataEntity.js +5 -6
- package/dist/cache/entities/AuthorityMetadataEntity.js.map +1 -1
- package/dist/cache/entities/CacheRecord.js +1 -1
- package/dist/cache/entities/CacheRecord.js.map +1 -1
- package/dist/cache/entities/CredentialEntity.d.ts +7 -3
- package/dist/cache/entities/CredentialEntity.d.ts.map +1 -1
- package/dist/cache/entities/CredentialEntity.js +16 -9
- package/dist/cache/entities/CredentialEntity.js.map +1 -1
- package/dist/cache/entities/IdTokenEntity.js +3 -3
- package/dist/cache/entities/IdTokenEntity.js.map +1 -1
- package/dist/cache/entities/RefreshTokenEntity.js +3 -3
- package/dist/cache/entities/RefreshTokenEntity.js.map +1 -1
- package/dist/cache/entities/ServerTelemetryEntity.js +1 -1
- package/dist/cache/entities/ServerTelemetryEntity.js.map +1 -1
- package/dist/cache/entities/ThrottlingEntity.js +1 -1
- package/dist/cache/entities/ThrottlingEntity.js.map +1 -1
- package/dist/cache/interface/ICacheManager.d.ts +5 -5
- package/dist/cache/interface/ICacheManager.d.ts.map +1 -1
- package/dist/cache/persistence/TokenCacheContext.js +3 -3
- package/dist/cache/persistence/TokenCacheContext.js.map +1 -1
- package/dist/cache/utils/CacheTypes.d.ts +4 -1
- package/dist/cache/utils/CacheTypes.d.ts.map +1 -1
- package/dist/client/AuthorizationCodeClient.d.ts +1 -1
- package/dist/client/AuthorizationCodeClient.d.ts.map +1 -1
- package/dist/client/AuthorizationCodeClient.js +56 -43
- package/dist/client/AuthorizationCodeClient.js.map +1 -1
- package/dist/client/BaseClient.js +11 -11
- package/dist/client/BaseClient.js.map +1 -1
- package/dist/client/ClientCredentialClient.d.ts.map +1 -1
- package/dist/client/ClientCredentialClient.js +24 -18
- package/dist/client/ClientCredentialClient.js.map +1 -1
- package/dist/client/DeviceCodeClient.d.ts.map +1 -1
- package/dist/client/DeviceCodeClient.js +39 -27
- package/dist/client/DeviceCodeClient.js.map +1 -1
- package/dist/client/OnBehalfOfClient.d.ts.map +1 -1
- package/dist/client/OnBehalfOfClient.js +26 -20
- package/dist/client/OnBehalfOfClient.js.map +1 -1
- package/dist/client/RefreshTokenClient.d.ts.map +1 -1
- package/dist/client/RefreshTokenClient.js +49 -32
- package/dist/client/RefreshTokenClient.js.map +1 -1
- package/dist/client/SilentFlowClient.d.ts.map +1 -1
- package/dist/client/SilentFlowClient.js +40 -35
- package/dist/client/SilentFlowClient.js.map +1 -1
- package/dist/client/UsernamePasswordClient.d.ts.map +1 -1
- package/dist/client/UsernamePasswordClient.js +18 -12
- package/dist/client/UsernamePasswordClient.js.map +1 -1
- package/dist/config/ClientConfiguration.d.ts.map +1 -1
- package/dist/config/ClientConfiguration.js +8 -7
- package/dist/config/ClientConfiguration.js.map +1 -1
- package/dist/crypto/ICrypto.d.ts +11 -1
- package/dist/crypto/ICrypto.d.ts.map +1 -1
- package/dist/crypto/ICrypto.js +26 -8
- package/dist/crypto/ICrypto.js.map +1 -1
- package/dist/crypto/PopTokenGenerator.d.ts +21 -4
- package/dist/crypto/PopTokenGenerator.d.ts.map +1 -1
- package/dist/crypto/PopTokenGenerator.js +42 -31
- package/dist/crypto/PopTokenGenerator.js.map +1 -1
- package/dist/error/AuthError.d.ts +5 -0
- package/dist/error/AuthError.d.ts.map +1 -1
- package/dist/error/AuthError.js +6 -3
- package/dist/error/AuthError.js.map +1 -1
- package/dist/error/ClientAuthError.d.ts +13 -4
- package/dist/error/ClientAuthError.d.ts.map +1 -1
- package/dist/error/ClientAuthError.js +20 -9
- package/dist/error/ClientAuthError.js.map +1 -1
- package/dist/error/ClientConfigurationError.d.ts +29 -0
- package/dist/error/ClientConfigurationError.d.ts.map +1 -1
- package/dist/error/ClientConfigurationError.js +45 -5
- package/dist/error/ClientConfigurationError.js.map +1 -1
- package/dist/error/InteractionRequiredAuthError.d.ts +24 -5
- package/dist/error/InteractionRequiredAuthError.d.ts.map +1 -1
- package/dist/error/InteractionRequiredAuthError.js +30 -9
- package/dist/error/InteractionRequiredAuthError.js.map +1 -1
- package/dist/error/ServerError.js +3 -3
- package/dist/error/ServerError.js.map +1 -1
- package/dist/index.cjs.js +675 -244
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +7 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +33 -29
- package/dist/index.js.map +1 -1
- package/dist/logger/Logger.d.ts.map +1 -1
- package/dist/logger/Logger.js +11 -9
- package/dist/logger/Logger.js.map +1 -1
- package/dist/network/INetworkModule.js +4 -4
- package/dist/network/INetworkModule.js.map +1 -1
- package/dist/network/NetworkManager.js +8 -8
- package/dist/network/NetworkManager.js.map +1 -1
- package/dist/network/RequestThumbprint.d.ts +7 -0
- package/dist/network/RequestThumbprint.d.ts.map +1 -1
- package/dist/network/ThrottlingUtils.d.ts +2 -1
- package/dist/network/ThrottlingUtils.d.ts.map +1 -1
- package/dist/network/ThrottlingUtils.js +14 -8
- package/dist/network/ThrottlingUtils.js.map +1 -1
- package/dist/packageMetadata.d.ts +1 -1
- package/dist/packageMetadata.js +2 -2
- package/dist/packageMetadata.js.map +1 -1
- 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 +7 -1
- package/dist/request/BaseAuthRequest.d.ts.map +1 -1
- package/dist/request/CommonEndSessionRequest.d.ts +4 -0
- package/dist/request/CommonEndSessionRequest.d.ts.map +1 -1
- package/dist/request/RequestParameterBuilder.d.ts +4 -0
- package/dist/request/RequestParameterBuilder.d.ts.map +1 -1
- package/dist/request/RequestParameterBuilder.js +27 -18
- package/dist/request/RequestParameterBuilder.js.map +1 -1
- package/dist/request/RequestValidator.js +10 -10
- package/dist/request/RequestValidator.js.map +1 -1
- package/dist/request/ScopeSet.js +14 -14
- package/dist/request/ScopeSet.js.map +1 -1
- package/dist/response/AuthenticationResult.d.ts +2 -1
- package/dist/response/AuthenticationResult.d.ts.map +1 -1
- package/dist/response/ExternalTokenResponse.d.ts +15 -0
- package/dist/response/ExternalTokenResponse.d.ts.map +1 -0
- package/dist/response/ResponseHandler.d.ts.map +1 -1
- package/dist/response/ResponseHandler.js +74 -69
- package/dist/response/ResponseHandler.js.map +1 -1
- package/dist/response/ServerAuthorizationTokenResponse.d.ts +5 -2
- package/dist/response/ServerAuthorizationTokenResponse.d.ts.map +1 -1
- package/dist/telemetry/server/ServerTelemetryManager.js +13 -13
- package/dist/telemetry/server/ServerTelemetryManager.js.map +1 -1
- package/dist/url/UrlString.d.ts +0 -6
- package/dist/url/UrlString.d.ts.map +1 -1
- package/dist/url/UrlString.js +25 -40
- package/dist/url/UrlString.js.map +1 -1
- package/dist/utils/Constants.d.ts +5 -2
- package/dist/utils/Constants.d.ts.map +1 -1
- package/dist/utils/Constants.js +5 -2
- package/dist/utils/Constants.js.map +1 -1
- package/dist/utils/ProtocolUtils.js +13 -13
- package/dist/utils/ProtocolUtils.js.map +1 -1
- package/dist/utils/StringUtils.d.ts.map +1 -1
- package/dist/utils/StringUtils.js +15 -14
- package/dist/utils/StringUtils.js.map +1 -1
- package/dist/utils/TimeUtils.js +1 -1
- package/dist/utils/TimeUtils.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
/*! @azure/msal-common
|
|
1
|
+
/*! @azure/msal-common v5.1.0 2021-11-02 */
|
|
2
2
|
'use strict';
|
|
3
3
|
import { __assign, __awaiter, __generator } from '../_virtual/_tslib.js';
|
|
4
|
-
import { Constants as Constants$1 } from '../utils/Constants.js';
|
|
5
|
-
import { AuthError as AuthError$1 } from '../error/AuthError.js';
|
|
6
4
|
import { DEFAULT_CRYPTO_IMPLEMENTATION } from '../crypto/ICrypto.js';
|
|
5
|
+
import { AuthError } from '../error/AuthError.js';
|
|
7
6
|
import { LogLevel } from '../logger/Logger.js';
|
|
7
|
+
import { Constants } from '../utils/Constants.js';
|
|
8
8
|
import { version } from '../packageMetadata.js';
|
|
9
9
|
import { DefaultStorageClass } from '../cache/CacheManager.js';
|
|
10
10
|
|
|
@@ -32,7 +32,7 @@ var DEFAULT_NETWORK_IMPLEMENTATION = {
|
|
|
32
32
|
var notImplErr;
|
|
33
33
|
return __generator(this, function (_a) {
|
|
34
34
|
notImplErr = "Network interface - sendGetRequestAsync() has not been implemented";
|
|
35
|
-
throw AuthError
|
|
35
|
+
throw AuthError.createUnexpectedError(notImplErr);
|
|
36
36
|
});
|
|
37
37
|
});
|
|
38
38
|
},
|
|
@@ -41,13 +41,13 @@ var DEFAULT_NETWORK_IMPLEMENTATION = {
|
|
|
41
41
|
var notImplErr;
|
|
42
42
|
return __generator(this, function (_a) {
|
|
43
43
|
notImplErr = "Network interface - sendPostRequestAsync() has not been implemented";
|
|
44
|
-
throw AuthError
|
|
44
|
+
throw AuthError.createUnexpectedError(notImplErr);
|
|
45
45
|
});
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
49
|
var DEFAULT_LIBRARY_INFO = {
|
|
50
|
-
sku: Constants
|
|
50
|
+
sku: Constants.SKU,
|
|
51
51
|
version: version,
|
|
52
52
|
cpu: "",
|
|
53
53
|
os: ""
|
|
@@ -65,10 +65,11 @@ var DEFAULT_CLIENT_CREDENTIALS = {
|
|
|
65
65
|
*/
|
|
66
66
|
function buildClientConfiguration(_a) {
|
|
67
67
|
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, serverTelemetryManager = _a.serverTelemetryManager, persistencePlugin = _a.persistencePlugin, serializableCache = _a.serializableCache;
|
|
68
|
+
var loggerOptions = __assign(__assign({}, DEFAULT_LOGGER_IMPLEMENTATION), userLoggerOption);
|
|
68
69
|
return {
|
|
69
70
|
authOptions: buildAuthOptions(userAuthOptions),
|
|
70
71
|
systemOptions: __assign(__assign({}, DEFAULT_SYSTEM_OPTIONS), userSystemOptions),
|
|
71
|
-
loggerOptions:
|
|
72
|
+
loggerOptions: loggerOptions,
|
|
72
73
|
storageInterface: storageImplementation || new DefaultStorageClass(userAuthOptions.clientId, DEFAULT_CRYPTO_IMPLEMENTATION),
|
|
73
74
|
networkInterface: networkImplementation || DEFAULT_NETWORK_IMPLEMENTATION,
|
|
74
75
|
cryptoInterface: cryptoImplementation || DEFAULT_CRYPTO_IMPLEMENTATION,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClientConfiguration.js","sources":["../../src/config/ClientConfiguration.ts"],"sourcesContent":["/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { INetworkModule } from \"../network/INetworkModule\";\r\nimport { DEFAULT_CRYPTO_IMPLEMENTATION, ICrypto } from \"../crypto/ICrypto\";\r\nimport { AuthError } from \"../error/AuthError\";\r\nimport { ILoggerCallback, LogLevel } from \"../logger/Logger\";\r\nimport { Constants } from \"../utils/Constants\";\r\nimport { version } from \"../packageMetadata\";\r\nimport { Authority } from \"../authority/Authority\";\r\nimport { CacheManager, DefaultStorageClass } from \"../cache/CacheManager\";\r\nimport { ServerTelemetryManager } from \"../telemetry/server/ServerTelemetryManager\";\r\nimport { ICachePlugin } from \"../cache/interface/ICachePlugin\";\r\nimport { ISerializableTokenCache } from \"../cache/interface/ISerializableTokenCache\";\r\n\r\n// Token renewal offset default in seconds\r\nconst DEFAULT_TOKEN_RENEWAL_OFFSET_SEC = 300;\r\n\r\n/**\r\n * Use the configuration object to configure MSAL Modules and initialize the base interfaces for MSAL.\r\n *\r\n * This object allows you to configure important elements of MSAL functionality:\r\n * - authOptions - Authentication for application\r\n * - cryptoInterface - Implementation of crypto functions\r\n * - libraryInfo - Library metadata\r\n * - loggerOptions - Logging for application\r\n * - networkInterface - Network implementation\r\n * - storageInterface - Storage implementation\r\n * - systemOptions - Additional library options\r\n * - clientCredentials - Credentials options for confidential clients\r\n */\r\nexport type ClientConfiguration = {\r\n authOptions: AuthOptions,\r\n systemOptions?: SystemOptions,\r\n loggerOptions?: LoggerOptions,\r\n storageInterface?: CacheManager,\r\n networkInterface?: INetworkModule,\r\n cryptoInterface?: ICrypto,\r\n clientCredentials?: ClientCredentials,\r\n libraryInfo?: LibraryInfo\r\n serverTelemetryManager?: ServerTelemetryManager | null,\r\n persistencePlugin?: ICachePlugin | null,\r\n serializableCache?: ISerializableTokenCache | null\r\n};\r\n\r\nexport type CommonClientConfiguration = {\r\n authOptions: Required<AuthOptions>,\r\n systemOptions: Required<SystemOptions>,\r\n loggerOptions : Required<LoggerOptions>,\r\n storageInterface: CacheManager,\r\n networkInterface : INetworkModule,\r\n cryptoInterface : Required<ICrypto>,\r\n libraryInfo : LibraryInfo,\r\n serverTelemetryManager: ServerTelemetryManager | null,\r\n clientCredentials: ClientCredentials,\r\n persistencePlugin: ICachePlugin | null,\r\n serializableCache: ISerializableTokenCache | null\r\n};\r\n\r\n/**\r\n * Use this to configure the auth options in the ClientConfiguration object\r\n *\r\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\r\n * - authority - You can configure a specific authority, defaults to \" \" or \"https://login.microsoftonline.com/common\"\r\n * - knownAuthorities - An array of URIs that are known to be valid. Used in B2C scenarios.\r\n * - cloudDiscoveryMetadata - A string containing the cloud discovery response. Used in AAD scenarios.\r\n * - clientCapabilities - Array of capabilities which will be added to the claims.access_token.xms_cc request property on every network request.\r\n * - protocolMode - Enum that represents the protocol that msal follows. Used for configuring proper endpoints.\r\n */\r\nexport type AuthOptions = {\r\n clientId: string;\r\n authority: Authority;\r\n clientCapabilities?: Array<string>;\r\n};\r\n\r\n/**\r\n * Use this to configure token renewal info in the Configuration object\r\n *\r\n * - tokenRenewalOffsetSeconds - Sets the window of offset needed to renew the token before expiry\r\n */\r\nexport type SystemOptions = {\r\n tokenRenewalOffsetSeconds?: number;\r\n preventCorsPreflight?: boolean;\r\n};\r\n\r\n/**\r\n * Use this to configure the logging that MSAL does, by configuring logger options in the Configuration object\r\n *\r\n * - loggerCallback - Callback for logger\r\n * - piiLoggingEnabled - Sets whether pii logging is enabled\r\n * - logLevel - Sets the level at which logging happens\r\n * - correlationId - Sets the correlationId printed by the logger\r\n */\r\nexport type LoggerOptions = {\r\n loggerCallback?: ILoggerCallback,\r\n piiLoggingEnabled?: boolean,\r\n logLevel?: LogLevel,\r\n correlationId?: string\r\n};\r\n\r\n/**\r\n * Library-specific options\r\n */\r\nexport type LibraryInfo = {\r\n sku: string,\r\n version: string,\r\n cpu: string,\r\n os: string\r\n};\r\n\r\n/**\r\n * Credentials for confidential clients\r\n */\r\nexport type ClientCredentials = {\r\n clientSecret?: string,\r\n clientAssertion? : {\r\n assertion: string,\r\n assertionType: string\r\n };\r\n};\r\n\r\nexport const DEFAULT_SYSTEM_OPTIONS: Required<SystemOptions> = {\r\n tokenRenewalOffsetSeconds: DEFAULT_TOKEN_RENEWAL_OFFSET_SEC,\r\n preventCorsPreflight: false\r\n};\r\n\r\nconst DEFAULT_LOGGER_IMPLEMENTATION: Required<LoggerOptions> = {\r\n loggerCallback: () => {\r\n // allow users to not set loggerCallback\r\n },\r\n piiLoggingEnabled: false,\r\n logLevel: LogLevel.Info,\r\n correlationId: \"\"\r\n};\r\n\r\nconst DEFAULT_NETWORK_IMPLEMENTATION: INetworkModule = {\r\n async sendGetRequestAsync<T>(): Promise<T> {\r\n const notImplErr = \"Network interface - sendGetRequestAsync() has not been implemented\";\r\n throw AuthError.createUnexpectedError(notImplErr);\r\n },\r\n async sendPostRequestAsync<T>(): Promise<T> {\r\n const notImplErr = \"Network interface - sendPostRequestAsync() has not been implemented\";\r\n throw AuthError.createUnexpectedError(notImplErr);\r\n }\r\n};\r\n\r\nconst DEFAULT_LIBRARY_INFO: LibraryInfo = {\r\n sku: Constants.SKU,\r\n version: version,\r\n cpu: \"\",\r\n os: \"\"\r\n};\r\n\r\nconst DEFAULT_CLIENT_CREDENTIALS: ClientCredentials = {\r\n clientSecret: \"\",\r\n clientAssertion: undefined\r\n};\r\n\r\n/**\r\n * Function that sets the default options when not explicitly configured from app developer\r\n *\r\n * @param Configuration\r\n *\r\n * @returns Configuration\r\n */\r\nexport function buildClientConfiguration(\r\n {\r\n authOptions: userAuthOptions,\r\n systemOptions: userSystemOptions,\r\n loggerOptions: userLoggerOption,\r\n storageInterface: storageImplementation,\r\n networkInterface: networkImplementation,\r\n cryptoInterface: cryptoImplementation,\r\n clientCredentials: clientCredentials,\r\n libraryInfo: libraryInfo,\r\n serverTelemetryManager: serverTelemetryManager,\r\n persistencePlugin: persistencePlugin,\r\n serializableCache: serializableCache\r\n }: ClientConfiguration): CommonClientConfiguration {\r\n\r\n return {\r\n authOptions: buildAuthOptions(userAuthOptions),\r\n systemOptions: { ...DEFAULT_SYSTEM_OPTIONS, ...userSystemOptions },\r\n loggerOptions: { ...DEFAULT_LOGGER_IMPLEMENTATION, ...userLoggerOption },\r\n storageInterface: storageImplementation || new DefaultStorageClass(userAuthOptions.clientId, DEFAULT_CRYPTO_IMPLEMENTATION),\r\n networkInterface: networkImplementation || DEFAULT_NETWORK_IMPLEMENTATION,\r\n cryptoInterface: cryptoImplementation || DEFAULT_CRYPTO_IMPLEMENTATION,\r\n clientCredentials: clientCredentials || DEFAULT_CLIENT_CREDENTIALS,\r\n libraryInfo: { ...DEFAULT_LIBRARY_INFO, ...libraryInfo },\r\n serverTelemetryManager: serverTelemetryManager || null,\r\n persistencePlugin: persistencePlugin || null,\r\n serializableCache: serializableCache || null\r\n };\r\n}\r\n\r\n/**\r\n * Construct authoptions from the client and platform passed values\r\n * @param authOptions\r\n */\r\nfunction buildAuthOptions(authOptions: AuthOptions): Required<AuthOptions> {\r\n return {\r\n clientCapabilities: [],\r\n ...authOptions\r\n };\r\n}\r\n"],"names":["AuthError","Constants"],"mappings":";;;;;;;;;;AAAA;;;;AAiBA;AACA,IAAM,gCAAgC,GAAG,GAAG,CAAC;IAyGhC,sBAAsB,GAA4B;IAC3D,yBAAyB,EAAE,gCAAgC;IAC3D,oBAAoB,EAAE,KAAK;EAC7B;AAEF,IAAM,6BAA6B,GAA4B;IAC3D,cAAc,EAAE;;KAEf;IACD,iBAAiB,EAAE,KAAK;IACxB,QAAQ,EAAE,QAAQ,CAAC,IAAI;IACvB,aAAa,EAAE,EAAE;CACpB,CAAC;AAEF,IAAM,8BAA8B,GAAmB;IAC7C,mBAAmB,EAAzB;;;;gBACU,UAAU,GAAG,oEAAoE,CAAC;gBACxF,MAAMA,WAAS,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;;;KACrD;IACK,oBAAoB,EAA1B;;;;gBACU,UAAU,GAAG,qEAAqE,CAAC;gBACzF,MAAMA,WAAS,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;;;KACrD;CACJ,CAAC;AAEF,IAAM,oBAAoB,GAAgB;IACtC,GAAG,EAAEC,WAAS,CAAC,GAAG;IAClB,OAAO,EAAE,OAAO;IAChB,GAAG,EAAE,EAAE;IACP,EAAE,EAAE,EAAE;CACT,CAAC;AAEF,IAAM,0BAA0B,GAAsB;IAClD,YAAY,EAAE,EAAE;IAChB,eAAe,EAAE,SAAS;CAC7B,CAAC;AAEF;;;;;;;SAOgB,wBAAwB,CACpC,EAYsB;QAXlB,gCAA4B,EAC5B,oCAAgC,EAChC,mCAA+B,EAC/B,2CAAuC,EACvC,2CAAuC,EACvC,yCAAqC,EACrC,wCAAoC,EACpC,4BAAwB,EACxB,kDAA8C,EAC9C,wCAAoC,EACpC,wCAAoC;IAGxC,OAAO;QACH,WAAW,EAAE,gBAAgB,CAAC,eAAe,CAAC;QAC9C,aAAa,wBAAO,sBAAsB,GAAK,iBAAiB,CAAE;QAClE,aAAa,wBAAO,6BAA6B,GAAK,gBAAgB,CAAE;QACxE,gBAAgB,EAAE,qBAAqB,IAAI,IAAI,mBAAmB,CAAC,eAAe,CAAC,QAAQ,EAAE,6BAA6B,CAAC;QAC3H,gBAAgB,EAAE,qBAAqB,IAAI,8BAA8B;QACzE,eAAe,EAAE,oBAAoB,IAAI,6BAA6B;QACtE,iBAAiB,EAAE,iBAAiB,IAAI,0BAA0B;QAClE,WAAW,wBAAO,oBAAoB,GAAK,WAAW,CAAE;QACxD,sBAAsB,EAAE,sBAAsB,IAAI,IAAI;QACtD,iBAAiB,EAAE,iBAAiB,IAAI,IAAI;QAC5C,iBAAiB,EAAE,iBAAiB,IAAI,IAAI;KAC/C,CAAC;AACN,CAAC;AAED;;;;AAIA,SAAS,gBAAgB,CAAC,WAAwB;IAC9C,kBACI,kBAAkB,EAAE,EAAE,IACnB,WAAW,EAChB;AACN;;;;"}
|
|
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 { CacheManager, DefaultStorageClass } from \"../cache/CacheManager\";\nimport { ServerTelemetryManager } from \"../telemetry/server/ServerTelemetryManager\";\nimport { ICachePlugin } from \"../cache/interface/ICachePlugin\";\nimport { ISerializableTokenCache } from \"../cache/interface/ISerializableTokenCache\";\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 * - 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 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 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 */\nexport type AuthOptions = {\n clientId: string;\n authority: Authority;\n clientCapabilities?: Array<string>;\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};\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 * Credentials for confidential clients\n */\nexport type ClientCredentials = {\n clientSecret?: string,\n clientAssertion? : {\n assertion: string,\n assertionType: string\n };\n};\n\nexport const DEFAULT_SYSTEM_OPTIONS: Required<SystemOptions> = {\n tokenRenewalOffsetSeconds: DEFAULT_TOKEN_RENEWAL_OFFSET_SEC,\n preventCorsPreflight: false\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: \"\"\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: \"\",\n os: \"\"\n};\n\nconst DEFAULT_CLIENT_CREDENTIALS: ClientCredentials = {\n clientSecret: \"\",\n clientAssertion: undefined\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 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 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 ...authOptions\n };\n}\n"],"names":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QAC9C,aAAa,wBAAO,sBAAsB,GAAK,iBAAiB,CAAE;QAClE,aAAa,EAAE,aAAa;QAC5B,gBAAgB,EAAE,qBAAqB,IAAI,IAAI,mBAAmB,CAAC,eAAe,CAAC,QAAQ,EAAE,6BAA6B,CAAC;QAC3H,gBAAgB,EAAE,qBAAqB,IAAI,8BAA8B;QACzE,eAAe,EAAE,oBAAoB,IAAI,6BAA6B;QACtE,iBAAiB,EAAE,iBAAiB,IAAI,0BAA0B;QAClE,WAAW,wBAAO,oBAAoB,GAAK,WAAW,CAAE;QACxD,sBAAsB,EAAE,sBAAsB,IAAI,IAAI;QACtD,iBAAiB,EAAE,iBAAiB,IAAI,IAAI;QAC5C,iBAAiB,EAAE,iBAAiB,IAAI,IAAI;KAC/C,CAAC;AACN,CAAC;AAED;;;;AAIA,SAAS,gBAAgB,CAAC,WAAwB;IAC9C,kBACI,kBAAkB,EAAE,EAAE,IACnB,WAAW,EAChB;AACN;;;;"}
|
package/dist/crypto/ICrypto.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export declare type PkceCodes = {
|
|
|
9
9
|
verifier: string;
|
|
10
10
|
challenge: string;
|
|
11
11
|
};
|
|
12
|
+
export declare type SignedHttpRequestParameters = Pick<BaseAuthRequest, "resourceRequestMethod" | "resourceRequestUri" | "shrClaims" | "shrNonce">;
|
|
12
13
|
/**
|
|
13
14
|
* Interface for crypto functions used by library
|
|
14
15
|
*/
|
|
@@ -35,7 +36,16 @@ export interface ICrypto {
|
|
|
35
36
|
* Generates an JWK RSA S256 Thumbprint
|
|
36
37
|
* @param request
|
|
37
38
|
*/
|
|
38
|
-
getPublicKeyThumbprint(request:
|
|
39
|
+
getPublicKeyThumbprint(request: SignedHttpRequestParameters): Promise<string>;
|
|
40
|
+
/**
|
|
41
|
+
* Removes cryptographic keypair from key store matching the keyId passed in
|
|
42
|
+
* @param kid
|
|
43
|
+
*/
|
|
44
|
+
removeTokenBindingKey(kid: string): Promise<boolean>;
|
|
45
|
+
/**
|
|
46
|
+
* Removes all cryptographic keys from IndexedDB storage
|
|
47
|
+
*/
|
|
48
|
+
clearKeystore(): Promise<boolean>;
|
|
39
49
|
/**
|
|
40
50
|
* Returns a signed proof-of-possession token with a given acces token that contains a cnf claim with the required kid.
|
|
41
51
|
* @param accessToken
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ICrypto.d.ts","sourceRoot":"","sources":["../../src/crypto/ICrypto.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD;;;;GAIG;AACH,oBAAY,SAAS,GAAG;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAA;CACpB,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,OAAO;IACpB;;OAEG;IACH,aAAa,IAAI,MAAM,CAAC;IACxB;;;OAGG;IACH,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACpC;;;OAGG;IACH,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACpC;;OAEG;IACH,iBAAiB,IAAI,OAAO,CAAC,SAAS,CAAC,CAAC;IACxC;;;OAGG;IACH,sBAAsB,CAAC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"ICrypto.d.ts","sourceRoot":"","sources":["../../src/crypto/ICrypto.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD;;;;GAIG;AACH,oBAAY,SAAS,GAAG;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAA;CACpB,CAAC;AAEF,oBAAY,2BAA2B,GAAG,IAAI,CAAC,eAAe,EAAE,uBAAuB,GAAG,oBAAoB,GAAG,WAAW,GAAG,UAAU,CAAC,CAAC;AAE3I;;GAEG;AACH,MAAM,WAAW,OAAO;IACpB;;OAEG;IACH,aAAa,IAAI,MAAM,CAAC;IACxB;;;OAGG;IACH,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACpC;;;OAGG;IACH,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACpC;;OAEG;IACH,iBAAiB,IAAI,OAAO,CAAC,SAAS,CAAC,CAAC;IACxC;;;OAGG;IACH,sBAAsB,CAAC,OAAO,EAAE,2BAA2B,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC9E;;;OAGG;IACH,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACrD;;OAEG;IACH,aAAa,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAClC;;;OAGG;IACH,OAAO,CAAC,OAAO,EAAE,iBAAiB,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACrE;AAED,eAAO,MAAM,6BAA6B,EAAE,OAiC3C,CAAC"}
|
package/dist/crypto/ICrypto.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/*! @azure/msal-common
|
|
1
|
+
/*! @azure/msal-common v5.1.0 2021-11-02 */
|
|
2
2
|
'use strict';
|
|
3
3
|
import { __awaiter, __generator } from '../_virtual/_tslib.js';
|
|
4
|
-
import { AuthError
|
|
4
|
+
import { AuthError } from '../error/AuthError.js';
|
|
5
5
|
|
|
6
6
|
/*
|
|
7
7
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -10,22 +10,22 @@ import { AuthError as AuthError$1 } from '../error/AuthError.js';
|
|
|
10
10
|
var DEFAULT_CRYPTO_IMPLEMENTATION = {
|
|
11
11
|
createNewGuid: function () {
|
|
12
12
|
var notImplErr = "Crypto interface - createNewGuid() has not been implemented";
|
|
13
|
-
throw AuthError
|
|
13
|
+
throw AuthError.createUnexpectedError(notImplErr);
|
|
14
14
|
},
|
|
15
15
|
base64Decode: function () {
|
|
16
16
|
var notImplErr = "Crypto interface - base64Decode() has not been implemented";
|
|
17
|
-
throw AuthError
|
|
17
|
+
throw AuthError.createUnexpectedError(notImplErr);
|
|
18
18
|
},
|
|
19
19
|
base64Encode: function () {
|
|
20
20
|
var notImplErr = "Crypto interface - base64Encode() has not been implemented";
|
|
21
|
-
throw AuthError
|
|
21
|
+
throw AuthError.createUnexpectedError(notImplErr);
|
|
22
22
|
},
|
|
23
23
|
generatePkceCodes: function () {
|
|
24
24
|
return __awaiter(this, void 0, void 0, function () {
|
|
25
25
|
var notImplErr;
|
|
26
26
|
return __generator(this, function (_a) {
|
|
27
27
|
notImplErr = "Crypto interface - generatePkceCodes() has not been implemented";
|
|
28
|
-
throw AuthError
|
|
28
|
+
throw AuthError.createUnexpectedError(notImplErr);
|
|
29
29
|
});
|
|
30
30
|
});
|
|
31
31
|
},
|
|
@@ -34,7 +34,25 @@ var DEFAULT_CRYPTO_IMPLEMENTATION = {
|
|
|
34
34
|
var notImplErr;
|
|
35
35
|
return __generator(this, function (_a) {
|
|
36
36
|
notImplErr = "Crypto interface - getPublicKeyThumbprint() has not been implemented";
|
|
37
|
-
throw AuthError
|
|
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);
|
|
38
56
|
});
|
|
39
57
|
});
|
|
40
58
|
},
|
|
@@ -43,7 +61,7 @@ var DEFAULT_CRYPTO_IMPLEMENTATION = {
|
|
|
43
61
|
var notImplErr;
|
|
44
62
|
return __generator(this, function (_a) {
|
|
45
63
|
notImplErr = "Crypto interface - signJwt() has not been implemented";
|
|
46
|
-
throw AuthError
|
|
64
|
+
throw AuthError.createUnexpectedError(notImplErr);
|
|
47
65
|
});
|
|
48
66
|
});
|
|
49
67
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ICrypto.js","sources":["../../src/crypto/ICrypto.ts"],"sourcesContent":["/*\
|
|
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\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): 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};\n"],"names":[],"mappings":";;;;;AAAA;;;;IAgEa,6BAA6B,GAAY;IAClD,aAAa,EAAE;QACX,IAAM,UAAU,GAAG,6DAA6D,CAAC;QACjF,MAAM,SAAS,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;KACrD;IACD,YAAY,EAAE;QACV,IAAM,UAAU,GAAG,4DAA4D,CAAC;QAChF,MAAM,SAAS,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;KACrD;IACD,YAAY,EAAE;QACV,IAAM,UAAU,GAAG,4DAA4D,CAAC;QAChF,MAAM,SAAS,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;KACrD;IACK,iBAAiB,EAAvB;;;;gBACU,UAAU,GAAG,iEAAiE,CAAC;gBACrF,MAAM,SAAS,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;;;KACrD;IACK,sBAAsB,EAA5B;;;;gBACU,UAAU,GAAG,sEAAsE,CAAC;gBAC1F,MAAM,SAAS,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;;;KACrD;IACK,qBAAqB,EAA3B;;;;gBACU,UAAU,GAAG,qEAAqE,CAAC;gBACzF,MAAM,SAAS,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;;;KACrD;IACK,aAAa,EAAnB;;;;gBACU,UAAU,GAAG,6DAA6D,CAAC;gBACjF,MAAM,SAAS,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;;;KACrD;IACK,OAAO,EAAb;;;;gBACU,UAAU,GAAG,uDAAuD,CAAC;gBAC3E,MAAM,SAAS,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;;;KACrD;;;;;"}
|
|
@@ -1,9 +1,26 @@
|
|
|
1
|
-
import { ICrypto } from "./ICrypto";
|
|
2
|
-
|
|
1
|
+
import { ICrypto, SignedHttpRequestParameters } from "./ICrypto";
|
|
2
|
+
/**
|
|
3
|
+
* See eSTS docs for more info.
|
|
4
|
+
* - A kid element, with the value containing an RFC 7638-compliant JWK thumbprint that is base64 encoded.
|
|
5
|
+
* - xms_ksl element, representing the storage location of the key's secret component on the client device. One of two values:
|
|
6
|
+
* - sw: software storage
|
|
7
|
+
* - uhw: hardware storage
|
|
8
|
+
*/
|
|
9
|
+
declare type ReqCnf = {
|
|
10
|
+
kid: string;
|
|
11
|
+
xms_ksl: KeyLocation;
|
|
12
|
+
};
|
|
13
|
+
declare enum KeyLocation {
|
|
14
|
+
SW = "sw",
|
|
15
|
+
UHW = "uhw"
|
|
16
|
+
}
|
|
3
17
|
export declare class PopTokenGenerator {
|
|
4
18
|
private cryptoUtils;
|
|
5
19
|
constructor(cryptoUtils: ICrypto);
|
|
6
|
-
generateCnf(request:
|
|
7
|
-
|
|
20
|
+
generateCnf(request: SignedHttpRequestParameters): Promise<string>;
|
|
21
|
+
generateKid(request: SignedHttpRequestParameters): Promise<ReqCnf>;
|
|
22
|
+
signPopToken(accessToken: string, request: SignedHttpRequestParameters): Promise<string>;
|
|
23
|
+
signPayload(payload: string, kid: string, request: SignedHttpRequestParameters, claims?: object): Promise<string>;
|
|
8
24
|
}
|
|
25
|
+
export {};
|
|
9
26
|
//# sourceMappingURL=PopTokenGenerator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PopTokenGenerator.d.ts","sourceRoot":"","sources":["../../src/crypto/PopTokenGenerator.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"PopTokenGenerator.d.ts","sourceRoot":"","sources":["../../src/crypto/PopTokenGenerator.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAE,2BAA2B,EAAE,MAAM,WAAW,CAAC;AAOjE;;;;;;GAMG;AACH,aAAK,MAAM,GAAG;IACV,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,WAAW,CAAC;CACxB,CAAC;AAEF,aAAK,WAAW;IACZ,EAAE,OAAO;IACT,GAAG,QAAQ;CACd;AAED,qBAAa,iBAAiB;IAE1B,OAAO,CAAC,WAAW,CAAU;gBAEjB,WAAW,EAAE,OAAO;IAI1B,WAAW,CAAC,OAAO,EAAE,2BAA2B,GAAG,OAAO,CAAC,MAAM,CAAC;IAKlE,WAAW,CAAC,OAAO,EAAE,2BAA2B,GAAG,OAAO,CAAC,MAAM,CAAC;IASlE,YAAY,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,2BAA2B,GAAG,OAAO,CAAC,MAAM,CAAC;IASxF,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,2BAA2B,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAmB1H"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
/*! @azure/msal-common
|
|
1
|
+
/*! @azure/msal-common v5.1.0 2021-11-02 */
|
|
2
2
|
'use strict';
|
|
3
|
-
import { __awaiter, __generator } from '../_virtual/_tslib.js';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
3
|
+
import { __awaiter, __generator, __assign } from '../_virtual/_tslib.js';
|
|
4
|
+
import { AuthToken } from '../account/AuthToken.js';
|
|
5
|
+
import { TimeUtils } from '../utils/TimeUtils.js';
|
|
6
|
+
import { UrlString } from '../url/UrlString.js';
|
|
7
|
+
import { ClientAuthError } from '../error/ClientAuthError.js';
|
|
8
8
|
|
|
9
9
|
/*
|
|
10
10
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -21,17 +21,29 @@ var PopTokenGenerator = /** @class */ (function () {
|
|
|
21
21
|
}
|
|
22
22
|
PopTokenGenerator.prototype.generateCnf = function (request) {
|
|
23
23
|
return __awaiter(this, void 0, void 0, function () {
|
|
24
|
-
var
|
|
24
|
+
var reqCnf;
|
|
25
|
+
return __generator(this, function (_a) {
|
|
26
|
+
switch (_a.label) {
|
|
27
|
+
case 0: return [4 /*yield*/, this.generateKid(request)];
|
|
28
|
+
case 1:
|
|
29
|
+
reqCnf = _a.sent();
|
|
30
|
+
return [2 /*return*/, this.cryptoUtils.base64Encode(JSON.stringify(reqCnf))];
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
PopTokenGenerator.prototype.generateKid = function (request) {
|
|
36
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
37
|
+
var kidThumbprint;
|
|
25
38
|
return __generator(this, function (_a) {
|
|
26
39
|
switch (_a.label) {
|
|
27
40
|
case 0: return [4 /*yield*/, this.cryptoUtils.getPublicKeyThumbprint(request)];
|
|
28
41
|
case 1:
|
|
29
42
|
kidThumbprint = _a.sent();
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return [2 /*return*/, this.cryptoUtils.base64Encode(JSON.stringify(reqCnf))];
|
|
43
|
+
return [2 /*return*/, {
|
|
44
|
+
kid: kidThumbprint,
|
|
45
|
+
xms_ksl: KeyLocation.SW
|
|
46
|
+
}];
|
|
35
47
|
}
|
|
36
48
|
});
|
|
37
49
|
});
|
|
@@ -39,28 +51,27 @@ var PopTokenGenerator = /** @class */ (function () {
|
|
|
39
51
|
PopTokenGenerator.prototype.signPopToken = function (accessToken, request) {
|
|
40
52
|
var _a;
|
|
41
53
|
return __awaiter(this, void 0, void 0, function () {
|
|
42
|
-
var tokenClaims
|
|
54
|
+
var tokenClaims;
|
|
43
55
|
return __generator(this, function (_b) {
|
|
44
|
-
|
|
56
|
+
tokenClaims = AuthToken.extractTokenClaims(accessToken, this.cryptoUtils);
|
|
57
|
+
if (!((_a = tokenClaims === null || tokenClaims === void 0 ? void 0 : tokenClaims.cnf) === null || _a === void 0 ? void 0 : _a.kid)) {
|
|
58
|
+
throw ClientAuthError.createTokenClaimsRequiredError();
|
|
59
|
+
}
|
|
60
|
+
return [2 /*return*/, this.signPayload(accessToken, tokenClaims.cnf.kid, request)];
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
PopTokenGenerator.prototype.signPayload = function (payload, kid, request, claims) {
|
|
65
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
66
|
+
var resourceRequestMethod, resourceRequestUri, shrClaims, shrNonce, resourceUrlString, resourceUrlComponents;
|
|
67
|
+
return __generator(this, function (_a) {
|
|
68
|
+
switch (_a.label) {
|
|
45
69
|
case 0:
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
resourceUrlString = (resourceRequestUri) ? new UrlString$1(resourceRequestUri) : undefined;
|
|
70
|
+
resourceRequestMethod = request.resourceRequestMethod, resourceRequestUri = request.resourceRequestUri, shrClaims = request.shrClaims, shrNonce = request.shrNonce;
|
|
71
|
+
resourceUrlString = (resourceRequestUri) ? new UrlString(resourceRequestUri) : undefined;
|
|
49
72
|
resourceUrlComponents = resourceUrlString === null || resourceUrlString === void 0 ? void 0 : resourceUrlString.getUrlComponents();
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
return [4 /*yield*/, this.cryptoUtils.signJwt({
|
|
54
|
-
at: accessToken,
|
|
55
|
-
ts: TimeUtils$1.nowSeconds(),
|
|
56
|
-
m: resourceRequestMethod === null || resourceRequestMethod === void 0 ? void 0 : resourceRequestMethod.toUpperCase(),
|
|
57
|
-
u: resourceUrlComponents === null || resourceUrlComponents === void 0 ? void 0 : resourceUrlComponents.HostNameAndPort,
|
|
58
|
-
nonce: this.cryptoUtils.createNewGuid(),
|
|
59
|
-
p: resourceUrlComponents === null || resourceUrlComponents === void 0 ? void 0 : resourceUrlComponents.AbsolutePath,
|
|
60
|
-
q: (resourceUrlComponents === null || resourceUrlComponents === void 0 ? void 0 : resourceUrlComponents.QueryString) ? [[], resourceUrlComponents.QueryString] : undefined,
|
|
61
|
-
client_claims: shrClaims || undefined
|
|
62
|
-
}, tokenClaims.cnf.kid)];
|
|
63
|
-
case 1: return [2 /*return*/, _b.sent()];
|
|
73
|
+
return [4 /*yield*/, this.cryptoUtils.signJwt(__assign({ at: payload, ts: TimeUtils.nowSeconds(), m: resourceRequestMethod === null || resourceRequestMethod === void 0 ? void 0 : resourceRequestMethod.toUpperCase(), u: resourceUrlComponents === null || resourceUrlComponents === void 0 ? void 0 : resourceUrlComponents.HostNameAndPort, nonce: shrNonce || this.cryptoUtils.createNewGuid(), p: resourceUrlComponents === null || resourceUrlComponents === void 0 ? void 0 : resourceUrlComponents.AbsolutePath, q: (resourceUrlComponents === null || resourceUrlComponents === void 0 ? void 0 : resourceUrlComponents.QueryString) ? [[], resourceUrlComponents.QueryString] : undefined, client_claims: shrClaims || undefined }, claims), kid)];
|
|
74
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
64
75
|
}
|
|
65
76
|
});
|
|
66
77
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PopTokenGenerator.js","sources":["../../src/crypto/PopTokenGenerator.ts"],"sourcesContent":["/*\
|
|
1
|
+
{"version":3,"file":"PopTokenGenerator.js","sources":["../../src/crypto/PopTokenGenerator.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ICrypto, SignedHttpRequestParameters } from \"./ICrypto\";\nimport { AuthToken } from \"../account/AuthToken\";\nimport { TokenClaims } from \"../account/TokenClaims\";\nimport { TimeUtils } from \"../utils/TimeUtils\";\nimport { UrlString } from \"../url/UrlString\";\nimport { ClientAuthError } from \"../error/ClientAuthError\";\n\n/**\n * See eSTS docs for more info.\n * - A kid element, with the value containing an RFC 7638-compliant JWK thumbprint that is base64 encoded.\n * - xms_ksl element, representing the storage location of the key's secret component on the client device. One of two values:\n * - sw: software storage\n * - uhw: hardware storage\n */\ntype ReqCnf = {\n kid: string;\n xms_ksl: KeyLocation;\n};\n\nenum KeyLocation {\n SW = \"sw\",\n UHW = \"uhw\"\n}\n\nexport class PopTokenGenerator {\n\n private cryptoUtils: ICrypto;\n\n constructor(cryptoUtils: ICrypto) {\n this.cryptoUtils = cryptoUtils;\n }\n\n async generateCnf(request: SignedHttpRequestParameters): Promise<string> {\n const reqCnf = await this.generateKid(request);\n return this.cryptoUtils.base64Encode(JSON.stringify(reqCnf));\n }\n\n async generateKid(request: SignedHttpRequestParameters): Promise<ReqCnf> {\n const kidThumbprint = await this.cryptoUtils.getPublicKeyThumbprint(request);\n\n return {\n kid: kidThumbprint,\n xms_ksl: KeyLocation.SW\n };\n }\n\n async signPopToken(accessToken: string, request: SignedHttpRequestParameters): Promise<string> {\n const tokenClaims: TokenClaims | null = AuthToken.extractTokenClaims(accessToken, this.cryptoUtils);\n if (!tokenClaims?.cnf?.kid) {\n throw ClientAuthError.createTokenClaimsRequiredError();\n }\n \n return this.signPayload(accessToken, tokenClaims.cnf.kid, request);\n }\n\n async signPayload(payload: string, kid: string, request: SignedHttpRequestParameters, claims?: object): Promise<string> {\n // Deconstruct request to extract SHR parameters\n const { resourceRequestMethod, resourceRequestUri, shrClaims, shrNonce } = request;\n\n const resourceUrlString = (resourceRequestUri) ? new UrlString(resourceRequestUri) : undefined;\n const resourceUrlComponents = resourceUrlString?.getUrlComponents();\n\n return await this.cryptoUtils.signJwt({\n at: payload,\n ts: TimeUtils.nowSeconds(),\n m: resourceRequestMethod?.toUpperCase(),\n u: resourceUrlComponents?.HostNameAndPort,\n nonce: shrNonce || this.cryptoUtils.createNewGuid(),\n p: resourceUrlComponents?.AbsolutePath,\n q: (resourceUrlComponents?.QueryString) ? [[], resourceUrlComponents.QueryString] : undefined,\n client_claims: shrClaims || undefined,\n ...claims\n }, kid);\n }\n}\n"],"names":[],"mappings":";;;;;;;;AAAA;;;;AAwBA,IAAK,WAGJ;AAHD,WAAK,WAAW;IACZ,wBAAS,CAAA;IACT,0BAAW,CAAA;AACf,CAAC,EAHI,WAAW,KAAX,WAAW,QAGf;;IAMG,2BAAY,WAAoB;QAC5B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;KAClC;IAEK,uCAAW,GAAjB,UAAkB,OAAoC;;;;;4BACnC,qBAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,EAAA;;wBAAxC,MAAM,GAAG,SAA+B;wBAC9C,sBAAO,IAAI,CAAC,WAAW,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,CAAC,EAAE,qBAAqB,aAArB,qBAAqB,uBAArB,qBAAqB,CAAE,WAAW,IACrC,CAAC,EAAE,qBAAqB,aAArB,qBAAqB,uBAArB,qBAAqB,CAAE,eAAe,EACzC,KAAK,EAAE,QAAQ,IAAI,IAAI,CAAC,WAAW,CAAC,aAAa,EAAE,EACnD,CAAC,EAAE,qBAAqB,aAArB,qBAAqB,uBAArB,qBAAqB,CAAE,YAAY,EACtC,CAAC,EAAE,CAAC,qBAAqB,aAArB,qBAAqB,uBAArB,qBAAqB,CAAE,WAAW,IAAI,CAAC,EAAE,EAAE,qBAAqB,CAAC,WAAW,CAAC,GAAG,SAAS,EAC7F,aAAa,EAAE,SAAS,IAAI,SAAS,IAClC,MAAM,GACV,GAAG,CAAC,EAAA;4BAVP,sBAAO,SAUA,EAAC;;;;KACX;IACL,wBAAC;AAAD,CAAC;;;;"}
|
|
@@ -23,7 +23,12 @@ export declare class AuthError extends Error {
|
|
|
23
23
|
* Describes the subclass of an error
|
|
24
24
|
*/
|
|
25
25
|
subError: string;
|
|
26
|
+
/**
|
|
27
|
+
* CorrelationId associated with the error
|
|
28
|
+
*/
|
|
29
|
+
correlationId: string;
|
|
26
30
|
constructor(errorCode?: string, errorMessage?: string, suberror?: string);
|
|
31
|
+
setCorrelationId(correlationId: string): void;
|
|
27
32
|
/**
|
|
28
33
|
* Creates an error that is thrown when something unexpected happens in the library.
|
|
29
34
|
* @param errDesc
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthError.d.ts","sourceRoot":"","sources":["../../src/error/AuthError.ts"],"names":[],"mappings":"AAOA;;GAEG;AACH,eAAO,MAAM,gBAAgB;;;;;CAK5B,CAAC;AAEF;;GAEG;AACH,qBAAa,SAAU,SAAQ,KAAK;IAEhC;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"AuthError.d.ts","sourceRoot":"","sources":["../../src/error/AuthError.ts"],"names":[],"mappings":"AAOA;;GAEG;AACH,eAAO,MAAM,gBAAgB;;;;;CAK5B,CAAC;AAEF;;GAEG;AACH,qBAAa,SAAU,SAAQ,KAAK;IAEhC;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;gBAEV,SAAS,CAAC,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM;IAWxE,gBAAgB,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI;IAI7C;;;OAGG;IACH,MAAM,CAAC,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS;CAG3D"}
|
package/dist/error/AuthError.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/*! @azure/msal-common
|
|
1
|
+
/*! @azure/msal-common v5.1.0 2021-11-02 */
|
|
2
2
|
'use strict';
|
|
3
3
|
import { __extends } from '../_virtual/_tslib.js';
|
|
4
|
-
import { Constants
|
|
4
|
+
import { Constants } from '../utils/Constants.js';
|
|
5
5
|
|
|
6
6
|
/*
|
|
7
7
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -26,12 +26,15 @@ var AuthError = /** @class */ (function (_super) {
|
|
|
26
26
|
var errorString = errorMessage ? errorCode + ": " + errorMessage : errorCode;
|
|
27
27
|
_this = _super.call(this, errorString) || this;
|
|
28
28
|
Object.setPrototypeOf(_this, AuthError.prototype);
|
|
29
|
-
_this.errorCode = errorCode || Constants
|
|
29
|
+
_this.errorCode = errorCode || Constants.EMPTY_STRING;
|
|
30
30
|
_this.errorMessage = errorMessage || "";
|
|
31
31
|
_this.subError = suberror || "";
|
|
32
32
|
_this.name = "AuthError";
|
|
33
33
|
return _this;
|
|
34
34
|
}
|
|
35
|
+
AuthError.prototype.setCorrelationId = function (correlationId) {
|
|
36
|
+
this.correlationId = correlationId;
|
|
37
|
+
};
|
|
35
38
|
/**
|
|
36
39
|
* Creates an error that is thrown when something unexpected happens in the library.
|
|
37
40
|
* @param errDesc
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthError.js","sources":["../../src/error/AuthError.ts"],"sourcesContent":["/*\
|
|
1
|
+
{"version":3,"file":"AuthError.js","sources":["../../src/error/AuthError.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { Constants } from \"../utils/Constants\";\n\n/**\n * AuthErrorMessage class containing string constants used by error codes and messages.\n */\nexport const AuthErrorMessage = {\n unexpectedError: {\n code: \"unexpected_error\",\n desc: \"Unexpected error in authentication.\"\n }\n};\n\n/**\n * General error class thrown by the MSAL.js library.\n */\nexport class AuthError extends Error {\n\n /**\n * Short string denoting error\n */\n errorCode: string;\n\n /**\n * Detailed description of error\n */\n errorMessage: string;\n\n /**\n * Describes the subclass of an error\n */\n subError: string;\n\n /**\n * CorrelationId associated with the error\n */\n correlationId: string;\n\n constructor(errorCode?: string, errorMessage?: string, suberror?: string) {\n const errorString = errorMessage ? `${errorCode}: ${errorMessage}` : errorCode;\n super(errorString);\n Object.setPrototypeOf(this, AuthError.prototype);\n\n this.errorCode = errorCode || Constants.EMPTY_STRING;\n this.errorMessage = errorMessage || \"\";\n this.subError = suberror || \"\";\n this.name = \"AuthError\";\n }\n\n setCorrelationId(correlationId: string): void {\n this.correlationId = correlationId;\n }\n\n /**\n * Creates an error that is thrown when something unexpected happens in the library.\n * @param errDesc\n */\n static createUnexpectedError(errDesc: string): AuthError {\n return new AuthError(AuthErrorMessage.unexpectedError.code, `${AuthErrorMessage.unexpectedError.desc}: ${errDesc}`);\n }\n}\n"],"names":[],"mappings":";;;;;AAAA;;;;AAOA;;;IAGa,gBAAgB,GAAG;IAC5B,eAAe,EAAE;QACb,IAAI,EAAE,kBAAkB;QACxB,IAAI,EAAE,qCAAqC;KAC9C;EACH;AAEF;;;;IAG+B,6BAAK;IAsBhC,mBAAY,SAAkB,EAAE,YAAqB,EAAE,QAAiB;QAAxE,iBASC;QARG,IAAM,WAAW,GAAG,YAAY,GAAM,SAAS,UAAK,YAAc,GAAG,SAAS,CAAC;QAC/E,QAAA,kBAAM,WAAW,CAAC,SAAC;QACnB,MAAM,CAAC,cAAc,CAAC,KAAI,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;QAEjD,KAAI,CAAC,SAAS,GAAG,SAAS,IAAI,SAAS,CAAC,YAAY,CAAC;QACrD,KAAI,CAAC,YAAY,GAAG,YAAY,IAAI,EAAE,CAAC;QACvC,KAAI,CAAC,QAAQ,GAAG,QAAQ,IAAI,EAAE,CAAC;QAC/B,KAAI,CAAC,IAAI,GAAG,WAAW,CAAC;;KAC3B;IAED,oCAAgB,GAAhB,UAAiB,aAAqB;QAClC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;KACtC;;;;;IAMM,+BAAqB,GAA5B,UAA6B,OAAe;QACxC,OAAO,IAAI,SAAS,CAAC,gBAAgB,CAAC,eAAe,CAAC,IAAI,EAAK,gBAAgB,CAAC,eAAe,CAAC,IAAI,UAAK,OAAS,CAAC,CAAC;KACvH;IACL,gBAAC;AAAD,CA5CA,CAA+B,KAAK;;;;"}
|
|
@@ -175,6 +175,14 @@ export declare const ClientAuthErrorMessage: {
|
|
|
175
175
|
code: string;
|
|
176
176
|
desc: string;
|
|
177
177
|
};
|
|
178
|
+
bindingKeyNotRemovedError: {
|
|
179
|
+
code: string;
|
|
180
|
+
desc: string;
|
|
181
|
+
};
|
|
182
|
+
logoutNotSupported: {
|
|
183
|
+
code: string;
|
|
184
|
+
desc: string;
|
|
185
|
+
};
|
|
178
186
|
};
|
|
179
187
|
/**
|
|
180
188
|
* Error thrown when there is an error in the client code running on the browser.
|
|
@@ -241,10 +249,6 @@ export declare class ClientAuthError extends AuthError {
|
|
|
241
249
|
* @param missingNonce
|
|
242
250
|
*/
|
|
243
251
|
static createNonceNotFoundError(missingNonce: string): ClientAuthError;
|
|
244
|
-
/**
|
|
245
|
-
* Creates an error thrown when the authorization code required for a token request is null or empty.
|
|
246
|
-
*/
|
|
247
|
-
static createNoTokensFoundError(): ClientAuthError;
|
|
248
252
|
/**
|
|
249
253
|
* Throws error when multiple tokens are in cache.
|
|
250
254
|
*/
|
|
@@ -351,5 +355,10 @@ export declare class ClientAuthError extends AuthError {
|
|
|
351
355
|
* Throws error when the authorization code is missing from the server response
|
|
352
356
|
*/
|
|
353
357
|
static createNoAuthCodeInServerResponseError(): ClientAuthError;
|
|
358
|
+
static createBindingKeyNotRemovedError(): ClientAuthError;
|
|
359
|
+
/**
|
|
360
|
+
* Thrown when logout is attempted for an authority that doesnt have an end_session_endpoint
|
|
361
|
+
*/
|
|
362
|
+
static createLogoutNotSupportedError(): ClientAuthError;
|
|
354
363
|
}
|
|
355
364
|
//# sourceMappingURL=ClientAuthError.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClientAuthError.d.ts","sourceRoot":"","sources":["../../src/error/ClientAuthError.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC;;GAEG;AACH,eAAO,MAAM,sBAAsB
|
|
1
|
+
{"version":3,"file":"ClientAuthError.d.ts","sourceRoot":"","sources":["../../src/error/ClientAuthError.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC;;GAEG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;IAOvD,MAAM,CAAC,8BAA8B,IAAI,eAAe;IAIxD;;OAEG;IACH,MAAM,CAAC,qCAAqC,IAAI,eAAe;IAI/D,MAAM,CAAC,+BAA+B,IAAI,eAAe;IAIzD;;OAEG;IACH,MAAM,CAAC,6BAA6B,IAAI,eAAe;CAG1D"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/*! @azure/msal-common
|
|
1
|
+
/*! @azure/msal-common v5.1.0 2021-11-02 */
|
|
2
2
|
'use strict';
|
|
3
3
|
import { __extends } from '../_virtual/_tslib.js';
|
|
4
|
-
import { AuthError
|
|
4
|
+
import { AuthError } from './AuthError.js';
|
|
5
5
|
|
|
6
6
|
/*
|
|
7
7
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -183,6 +183,14 @@ var ClientAuthErrorMessage = {
|
|
|
183
183
|
accessTokenEntityNullError: {
|
|
184
184
|
code: "access_token_entity_null",
|
|
185
185
|
desc: "Access token entity is null, please check logs and cache to ensure a valid access token is present."
|
|
186
|
+
},
|
|
187
|
+
bindingKeyNotRemovedError: {
|
|
188
|
+
code: "binding_key_not_removed",
|
|
189
|
+
desc: "Could not remove the credential's binding key from storage."
|
|
190
|
+
},
|
|
191
|
+
logoutNotSupported: {
|
|
192
|
+
code: "end_session_endpoint_not_supported",
|
|
193
|
+
desc: "Provided authority does not support logout."
|
|
186
194
|
}
|
|
187
195
|
};
|
|
188
196
|
/**
|
|
@@ -282,12 +290,6 @@ var ClientAuthError = /** @class */ (function (_super) {
|
|
|
282
290
|
ClientAuthError.createNonceNotFoundError = function (missingNonce) {
|
|
283
291
|
return new ClientAuthError(ClientAuthErrorMessage.nonceNotFoundError.code, ClientAuthErrorMessage.nonceNotFoundError.desc + ": " + missingNonce);
|
|
284
292
|
};
|
|
285
|
-
/**
|
|
286
|
-
* Creates an error thrown when the authorization code required for a token request is null or empty.
|
|
287
|
-
*/
|
|
288
|
-
ClientAuthError.createNoTokensFoundError = function () {
|
|
289
|
-
return new ClientAuthError(ClientAuthErrorMessage.noTokensFoundError.code, ClientAuthErrorMessage.noTokensFoundError.desc);
|
|
290
|
-
};
|
|
291
293
|
/**
|
|
292
294
|
* Throws error when multiple tokens are in cache.
|
|
293
295
|
*/
|
|
@@ -449,8 +451,17 @@ var ClientAuthError = /** @class */ (function (_super) {
|
|
|
449
451
|
ClientAuthError.createNoAuthCodeInServerResponseError = function () {
|
|
450
452
|
return new ClientAuthError(ClientAuthErrorMessage.noAuthorizationCodeFromServer.code, ClientAuthErrorMessage.noAuthorizationCodeFromServer.desc);
|
|
451
453
|
};
|
|
454
|
+
ClientAuthError.createBindingKeyNotRemovedError = function () {
|
|
455
|
+
return new ClientAuthError(ClientAuthErrorMessage.bindingKeyNotRemovedError.code, ClientAuthErrorMessage.bindingKeyNotRemovedError.desc);
|
|
456
|
+
};
|
|
457
|
+
/**
|
|
458
|
+
* Thrown when logout is attempted for an authority that doesnt have an end_session_endpoint
|
|
459
|
+
*/
|
|
460
|
+
ClientAuthError.createLogoutNotSupportedError = function () {
|
|
461
|
+
return new ClientAuthError(ClientAuthErrorMessage.logoutNotSupported.code, ClientAuthErrorMessage.logoutNotSupported.desc);
|
|
462
|
+
};
|
|
452
463
|
return ClientAuthError;
|
|
453
|
-
}(AuthError
|
|
464
|
+
}(AuthError));
|
|
454
465
|
|
|
455
466
|
export { ClientAuthError, ClientAuthErrorMessage };
|
|
456
467
|
//# sourceMappingURL=ClientAuthError.js.map
|