@azure/msal-common 6.1.0 → 6.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/_tslib.js +1 -1
- package/dist/account/AccountInfo.d.ts +6 -1
- package/dist/account/AccountInfo.d.ts.map +1 -1
- package/dist/account/AuthToken.js +1 -1
- package/dist/account/CcsCredential.js +1 -1
- package/dist/account/ClientInfo.js +1 -1
- package/dist/account/TokenClaims.d.ts +29 -0
- package/dist/account/TokenClaims.d.ts.map +1 -1
- package/dist/authority/Authority.js +1 -1
- package/dist/authority/AuthorityFactory.js +1 -1
- package/dist/authority/AuthorityOptions.d.ts +1 -0
- package/dist/authority/AuthorityOptions.d.ts.map +1 -1
- package/dist/authority/AuthorityOptions.js +3 -1
- package/dist/authority/AuthorityOptions.js.map +1 -1
- package/dist/authority/AuthorityType.js +1 -1
- package/dist/authority/CloudInstanceDiscoveryResponse.js +1 -1
- package/dist/authority/OpenIdConfigResponse.js +1 -1
- package/dist/authority/ProtocolMode.js +1 -1
- package/dist/authority/RegionDiscovery.js +1 -1
- package/dist/cache/CacheManager.d.ts +1 -1
- package/dist/cache/CacheManager.js +3 -3
- package/dist/cache/CacheManager.js.map +1 -1
- package/dist/cache/entities/AccessTokenEntity.js +1 -1
- package/dist/cache/entities/AccountEntity.d.ts +3 -1
- package/dist/cache/entities/AccountEntity.d.ts.map +1 -1
- package/dist/cache/entities/AccountEntity.js +16 -12
- package/dist/cache/entities/AccountEntity.js.map +1 -1
- package/dist/cache/entities/AppMetadataEntity.js +1 -1
- package/dist/cache/entities/AuthorityMetadataEntity.js +1 -1
- package/dist/cache/entities/CacheRecord.js +1 -1
- package/dist/cache/entities/CredentialEntity.js +5 -5
- package/dist/cache/entities/CredentialEntity.js.map +1 -1
- package/dist/cache/entities/IdTokenEntity.js +1 -1
- package/dist/cache/entities/RefreshTokenEntity.js +1 -1
- package/dist/cache/entities/ServerTelemetryEntity.js +1 -1
- package/dist/cache/entities/ThrottlingEntity.js +1 -1
- package/dist/cache/persistence/TokenCacheContext.js +1 -1
- package/dist/client/AuthorizationCodeClient.d.ts.map +1 -1
- package/dist/client/AuthorizationCodeClient.js +119 -93
- package/dist/client/AuthorizationCodeClient.js.map +1 -1
- package/dist/client/BaseClient.js +1 -1
- package/dist/client/ClientCredentialClient.d.ts.map +1 -1
- package/dist/client/ClientCredentialClient.js +4 -3
- package/dist/client/ClientCredentialClient.js.map +1 -1
- package/dist/client/DeviceCodeClient.d.ts.map +1 -1
- package/dist/client/DeviceCodeClient.js +2 -1
- package/dist/client/DeviceCodeClient.js.map +1 -1
- package/dist/client/OnBehalfOfClient.js +3 -2
- package/dist/client/OnBehalfOfClient.js.map +1 -1
- package/dist/client/RefreshTokenClient.js +2 -1
- package/dist/client/RefreshTokenClient.js.map +1 -1
- package/dist/client/SilentFlowClient.js +1 -1
- package/dist/client/UsernamePasswordClient.d.ts.map +1 -1
- package/dist/client/UsernamePasswordClient.js +3 -1
- package/dist/client/UsernamePasswordClient.js.map +1 -1
- package/dist/config/ClientConfiguration.d.ts +16 -1
- package/dist/config/ClientConfiguration.d.ts.map +1 -1
- package/dist/config/ClientConfiguration.js +14 -7
- package/dist/config/ClientConfiguration.js.map +1 -1
- package/dist/crypto/ICrypto.d.ts +4 -2
- package/dist/crypto/ICrypto.d.ts.map +1 -1
- package/dist/crypto/ICrypto.js +1 -1
- package/dist/crypto/ICrypto.js.map +1 -1
- package/dist/crypto/IGuidGenerator.d.ts +5 -0
- package/dist/crypto/IGuidGenerator.d.ts.map +1 -0
- package/dist/crypto/PopTokenGenerator.d.ts +30 -0
- package/dist/crypto/PopTokenGenerator.d.ts.map +1 -1
- package/dist/crypto/PopTokenGenerator.js +38 -2
- package/dist/crypto/PopTokenGenerator.js.map +1 -1
- package/dist/error/AuthError.js +3 -3
- package/dist/error/AuthError.js.map +1 -1
- package/dist/error/ClientAuthError.js +1 -1
- package/dist/error/ClientConfigurationError.js +1 -1
- package/dist/error/InteractionRequiredAuthError.js +1 -1
- package/dist/error/ServerError.js +1 -1
- package/dist/index.cjs.js +659 -148
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/logger/Logger.js +13 -13
- package/dist/logger/Logger.js.map +1 -1
- package/dist/network/INetworkModule.js +1 -1
- package/dist/network/NetworkManager.js +1 -1
- package/dist/network/ThrottlingUtils.js +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.js +3 -3
- package/dist/request/AuthenticationHeaderParser.js.map +1 -1
- package/dist/request/CommonAuthorizationUrlRequest.d.ts +1 -0
- package/dist/request/CommonAuthorizationUrlRequest.d.ts.map +1 -1
- package/dist/request/RequestParameterBuilder.d.ts +14 -1
- package/dist/request/RequestParameterBuilder.d.ts.map +1 -1
- package/dist/request/RequestParameterBuilder.js +31 -3
- package/dist/request/RequestParameterBuilder.js.map +1 -1
- package/dist/request/RequestValidator.js +1 -1
- package/dist/request/ScopeSet.js +4 -4
- package/dist/request/ScopeSet.js.map +1 -1
- package/dist/response/AuthenticationResult.d.ts +1 -0
- package/dist/response/AuthenticationResult.d.ts.map +1 -1
- package/dist/response/ResponseHandler.d.ts.map +1 -1
- package/dist/response/ResponseHandler.js +6 -5
- package/dist/response/ResponseHandler.js.map +1 -1
- package/dist/response/ServerAuthorizationCodeResponse.d.ts +1 -0
- package/dist/response/ServerAuthorizationCodeResponse.d.ts.map +1 -1
- 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 +275 -0
- package/dist/telemetry/performance/PerformanceClient.js.map +1 -0
- package/dist/telemetry/performance/PerformanceEvent.d.ts +203 -0
- package/dist/telemetry/performance/PerformanceEvent.d.ts.map +1 -0
- package/dist/telemetry/performance/PerformanceEvent.js +100 -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.js +4 -4
- package/dist/telemetry/server/ServerTelemetryManager.js.map +1 -1
- package/dist/url/UrlString.js +2 -2
- package/dist/url/UrlString.js.map +1 -1
- package/dist/utils/Constants.d.ts +5 -0
- package/dist/utils/Constants.d.ts.map +1 -1
- package/dist/utils/Constants.js +7 -2
- package/dist/utils/Constants.js.map +1 -1
- package/dist/utils/ProtocolUtils.js +3 -3
- package/dist/utils/ProtocolUtils.js.map +1 -1
- package/dist/utils/StringUtils.js +1 -1
- package/dist/utils/TimeUtils.js +1 -1
- package/package.json +2 -4
- package/CHANGELOG.json +0 -1319
- package/CHANGELOG.md +0 -504
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthorizationCodeClient.js","sources":["../../src/client/AuthorizationCodeClient.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { BaseClient } from \"./BaseClient\";\nimport { CommonAuthorizationUrlRequest } from \"../request/CommonAuthorizationUrlRequest\";\nimport { CommonAuthorizationCodeRequest } from \"../request/CommonAuthorizationCodeRequest\";\nimport { Authority } from \"../authority/Authority\";\nimport { RequestParameterBuilder } from \"../request/RequestParameterBuilder\";\nimport { GrantType, AuthenticationScheme, PromptValue, Separators, AADServerParamKeys } from \"../utils/Constants\";\nimport { ClientConfiguration } from \"../config/ClientConfiguration\";\nimport { ServerAuthorizationTokenResponse } from \"../response/ServerAuthorizationTokenResponse\";\nimport { NetworkResponse } from \"../network/NetworkManager\";\nimport { ResponseHandler } from \"../response/ResponseHandler\";\nimport { AuthenticationResult } from \"../response/AuthenticationResult\";\nimport { StringUtils } from \"../utils/StringUtils\";\nimport { ClientAuthError } from \"../error/ClientAuthError\";\nimport { UrlString } from \"../url/UrlString\";\nimport { ServerAuthorizationCodeResponse } from \"../response/ServerAuthorizationCodeResponse\";\nimport { CommonEndSessionRequest } from \"../request/CommonEndSessionRequest\";\nimport { PopTokenGenerator } from \"../crypto/PopTokenGenerator\";\nimport { RequestThumbprint } from \"../network/RequestThumbprint\";\nimport { AuthorizationCodePayload } from \"../response/AuthorizationCodePayload\";\nimport { TimeUtils } from \"../utils/TimeUtils\";\nimport { TokenClaims } from \"../account/TokenClaims\";\nimport { AccountInfo } from \"../account/AccountInfo\";\nimport { buildClientInfoFromHomeAccountId, buildClientInfo } from \"../account/ClientInfo\";\nimport { CcsCredentialType, CcsCredential } from \"../account/CcsCredential\";\nimport { ClientConfigurationError } from \"../error/ClientConfigurationError\";\nimport { RequestValidator } from \"../request/RequestValidator\";\n\n/**\n * Oauth2.0 Authorization Code client\n */\nexport class AuthorizationCodeClient extends BaseClient {\n // Flag to indicate if client is for hybrid spa auth code redemption\n protected includeRedirectUri: boolean = true;\n\n constructor(configuration: ClientConfiguration) {\n super(configuration);\n }\n\n /**\n * Creates the URL of the authorization request letting the user input credentials and consent to the\n * application. The URL target the /authorize endpoint of the authority configured in the\n * application object.\n *\n * Once the user inputs their credentials and consents, the authority will send a response to the redirect URI\n * sent in the request and should contain an authorization code, which can then be used to acquire tokens via\n * acquireToken(AuthorizationCodeRequest)\n * @param request\n */\n async getAuthCodeUrl(request: CommonAuthorizationUrlRequest): Promise<string> {\n const queryString = this.createAuthCodeUrlQueryString(request);\n\n return UrlString.appendQueryString(this.authority.authorizationEndpoint, queryString);\n }\n\n /**\n * API to acquire a token in exchange of 'authorization_code` acquired by the user in the first leg of the\n * authorization_code_grant\n * @param request\n */\n async acquireToken(request: CommonAuthorizationCodeRequest, authCodePayload?: AuthorizationCodePayload): Promise<AuthenticationResult> {\n this.logger.info(\"in acquireToken call\");\n if (!request || StringUtils.isEmpty(request.code)) {\n throw ClientAuthError.createTokenRequestCannotBeMadeError();\n }\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 return await responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request, authCodePayload);\n }\n\n /**\n * Handles the hash fragment response from public client code request. Returns a code response used by\n * the client to exchange for a token in acquireToken.\n * @param hashFragment\n */\n handleFragmentResponse(hashFragment: string, cachedState: string): AuthorizationCodePayload {\n // Handle responses.\n const responseHandler = new ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, null, null);\n\n // Deserialize hash fragment response parameters.\n const hashUrlString = new UrlString(hashFragment);\n // Deserialize hash fragment response parameters.\n const serverParams: ServerAuthorizationCodeResponse = UrlString.getDeserializedHash(hashUrlString.getHash());\n\n // Get code response\n responseHandler.validateServerAuthorizationCodeResponse(serverParams, cachedState, this.cryptoUtils);\n\n // throw when there is no auth code in the response\n if (!serverParams.code) {\n throw ClientAuthError.createNoAuthCodeInServerResponseError();\n }\n return {\n ...serverParams,\n // Code param is optional in ServerAuthorizationCodeResponse but required in AuthorizationCodePaylod\n code: serverParams.code\n };\n }\n\n /**\n * Used to log out the current user, and redirect the user to the postLogoutRedirectUri.\n * Default behaviour is to redirect the user to `window.location.href`.\n * @param authorityUri\n */\n getLogoutUri(logoutRequest: CommonEndSessionRequest): string {\n // Throw error if logoutRequest is null/undefined\n if (!logoutRequest) {\n throw ClientConfigurationError.createEmptyLogoutRequestError();\n }\n const queryString = this.createLogoutUrlQueryString(logoutRequest);\n\n // Construct logout URI.\n return UrlString.appendQueryString(this.authority.endSessionEndpoint, queryString);\n }\n\n /**\n * Executes POST request to token endpoint\n * @param authority\n * @param request\n */\n private async executeTokenRequest(authority: Authority, request: CommonAuthorizationCodeRequest): 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\n const requestBody = await this.createTokenRequestBody(request);\n const queryParameters = this.createTokenQueryParameters(request);\n let ccsCredential: CcsCredential | undefined = undefined;\n if (request.clientInfo) {\n try {\n const clientInfo = buildClientInfo(request.clientInfo, this.cryptoUtils);\n ccsCredential = {\n credential: `${clientInfo.uid}${Separators.CLIENT_INFO_SEPARATOR}${clientInfo.utid}`,\n type: CcsCredentialType.HOME_ACCOUNT_ID\n };\n } catch (e) {\n this.logger.verbose(\"Could not parse client info for CCS Header: \" + e);\n }\n }\n const headers: Record<string, string> = this.createTokenRequestHeaders(ccsCredential || request.ccsCredential);\n const endpoint = StringUtils.isEmpty(queryParameters) ? authority.tokenEndpoint : `${authority.tokenEndpoint}?${queryParameters}`;\n\n return this.executePostToTokenEndpoint(endpoint, requestBody, headers, thumbprint);\n }\n\n /**\n * Creates query string for the /token request\n * @param request \n */\n private createTokenQueryParameters(request: CommonAuthorizationCodeRequest): string {\n const parameterBuilder = new RequestParameterBuilder();\n\n if (request.tokenQueryParameters) {\n parameterBuilder.addExtraQueryParameters(request.tokenQueryParameters);\n }\n\n return parameterBuilder.createQueryString();\n }\n\n /**\n * Generates a map for all the params to be sent to the service\n * @param request\n */\n private async createTokenRequestBody(request: CommonAuthorizationCodeRequest): Promise<string> {\n const parameterBuilder = new RequestParameterBuilder();\n\n parameterBuilder.addClientId(this.config.authOptions.clientId);\n\n /*\n * For hybrid spa flow, there will be a code but no verifier\n * In this scenario, don't include redirect uri as auth code will not be bound to redirect URI\n */\n if (!this.includeRedirectUri) {\n // Just validate\n RequestValidator.validateRedirectUri(request.redirectUri);\n } else {\n // Validate and include redirect uri\n parameterBuilder.addRedirectUri(request.redirectUri);\n }\n\n // Add scope array, parameter builder will add default scopes and dedupe\n parameterBuilder.addScopes(request.scopes);\n\n // add code: user set, not validated\n parameterBuilder.addAuthorizationCode(request.code);\n\n // Add library metadata\n parameterBuilder.addLibraryInfo(this.config.libraryInfo);\n\n parameterBuilder.addThrottling();\n \n if (this.serverTelemetryManager) {\n parameterBuilder.addServerTelemetry(this.serverTelemetryManager);\n }\n\n // add code_verifier if passed\n if (request.codeVerifier) {\n parameterBuilder.addCodeVerifier(request.codeVerifier);\n }\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 parameterBuilder.addGrantType(GrantType.AUTHORIZATION_CODE_GRANT);\n parameterBuilder.addClientInfo();\n\n if (request.authenticationScheme === AuthenticationScheme.POP) {\n const popTokenGenerator = new PopTokenGenerator(this.cryptoUtils);\n const cnfString = await popTokenGenerator.generateCnf(request);\n parameterBuilder.addPopToken(cnfString);\n } else if (request.authenticationScheme === AuthenticationScheme.SSH) {\n if(request.sshJwk) {\n parameterBuilder.addSshJwk(request.sshJwk);\n } else {\n throw ClientConfigurationError.createMissingSshJwkError();\n }\n }\n\n const correlationId = request.correlationId || this.config.cryptoInterface.createNewGuid();\n parameterBuilder.addCorrelationId(correlationId);\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 let ccsCred: CcsCredential | undefined = undefined;\n if (request.clientInfo) {\n try {\n const clientInfo = buildClientInfo(request.clientInfo, this.cryptoUtils);\n ccsCred = {\n credential: `${clientInfo.uid}${Separators.CLIENT_INFO_SEPARATOR}${clientInfo.utid}`,\n type: CcsCredentialType.HOME_ACCOUNT_ID\n };\n } catch (e) {\n this.logger.verbose(\"Could not parse client info for CCS Header: \" + e);\n }\n } else {\n ccsCred = request.ccsCredential;\n }\n\n // Adds these as parameters in the request instead of headers to prevent CORS preflight request\n if (this.config.systemOptions.preventCorsPreflight && ccsCred) {\n switch (ccsCred.type) {\n case CcsCredentialType.HOME_ACCOUNT_ID:\n try {\n const clientInfo = buildClientInfoFromHomeAccountId(ccsCred.credential);\n parameterBuilder.addCcsOid(clientInfo);\n } catch (e) {\n this.logger.verbose(\"Could not parse home account ID for CCS Header: \" + e);\n }\n break;\n case CcsCredentialType.UPN:\n parameterBuilder.addCcsUpn(ccsCred.credential);\n break;\n }\n }\n\n if (request.tokenBodyParameters) {\n parameterBuilder.addExtraQueryParameters(request.tokenBodyParameters);\n }\n\n // Add hybrid spa parameters if not already provided\n if (request.enableSpaAuthorizationCode && (!request.tokenBodyParameters || !request.tokenBodyParameters[AADServerParamKeys.RETURN_SPA_CODE])) {\n parameterBuilder.addExtraQueryParameters({\n [AADServerParamKeys.RETURN_SPA_CODE]: \"1\"\n });\n }\n \n return parameterBuilder.createQueryString();\n }\n\n /**\n * This API validates the `AuthorizationCodeUrlRequest` and creates a URL\n * @param request\n */\n private createAuthCodeUrlQueryString(request: CommonAuthorizationUrlRequest): string {\n const parameterBuilder = new RequestParameterBuilder();\n\n parameterBuilder.addClientId(this.config.authOptions.clientId);\n\n const requestScopes = [...request.scopes || [], ...request.extraScopesToConsent || []];\n parameterBuilder.addScopes(requestScopes);\n\n // validate the redirectUri (to be a non null value)\n parameterBuilder.addRedirectUri(request.redirectUri);\n\n // generate the correlationId if not set by the user and add\n const correlationId = request.correlationId || this.config.cryptoInterface.createNewGuid();\n parameterBuilder.addCorrelationId(correlationId);\n\n // add response_mode. If not passed in it defaults to query.\n parameterBuilder.addResponseMode(request.responseMode);\n\n // add response_type = code\n parameterBuilder.addResponseTypeCode();\n\n // add library info parameters\n parameterBuilder.addLibraryInfo(this.config.libraryInfo);\n\n // add client_info=1\n parameterBuilder.addClientInfo();\n\n if (request.codeChallenge && request.codeChallengeMethod) {\n parameterBuilder.addCodeChallengeParams(request.codeChallenge, request.codeChallengeMethod);\n }\n\n if (request.prompt) {\n parameterBuilder.addPrompt(request.prompt);\n }\n\n if (request.domainHint) {\n parameterBuilder.addDomainHint(request.domainHint);\n }\n\n // Add sid or loginHint with preference for sid -> loginHint -> username of AccountInfo object\n if (request.prompt !== PromptValue.SELECT_ACCOUNT) {\n // AAD will throw if prompt=select_account is passed with an account hint\n if (request.sid && request.prompt === PromptValue.NONE) {\n // SessionID is only used in silent calls\n this.logger.verbose(\"createAuthCodeUrlQueryString: Prompt is none, adding sid from request\");\n parameterBuilder.addSid(request.sid);\n } else if (request.account) {\n const accountSid = this.extractAccountSid(request.account);\n // If account and loginHint are provided, we will check account first for sid before adding loginHint\n if (accountSid && request.prompt === PromptValue.NONE) {\n // SessionId is only used in silent calls\n this.logger.verbose(\"createAuthCodeUrlQueryString: Prompt is none, adding sid from account\");\n parameterBuilder.addSid(accountSid);\n try {\n const clientInfo = buildClientInfoFromHomeAccountId(request.account.homeAccountId);\n parameterBuilder.addCcsOid(clientInfo);\n } catch (e) {\n this.logger.verbose(\"Could not parse home account ID for CCS Header: \" + e);\n }\n } else if (request.loginHint) {\n this.logger.verbose(\"createAuthCodeUrlQueryString: Adding login_hint from request\");\n parameterBuilder.addLoginHint(request.loginHint);\n parameterBuilder.addCcsUpn(request.loginHint);\n } else if (request.account.username) {\n // Fallback to account username if provided\n this.logger.verbose(\"createAuthCodeUrlQueryString: Adding login_hint from account\");\n parameterBuilder.addLoginHint(request.account.username);\n try {\n const clientInfo = buildClientInfoFromHomeAccountId(request.account.homeAccountId);\n parameterBuilder.addCcsOid(clientInfo);\n } catch (e) {\n this.logger.verbose(\"Could not parse home account ID for CCS Header: \" + e);\n }\n }\n } else if (request.loginHint) {\n this.logger.verbose(\"createAuthCodeUrlQueryString: No account, adding login_hint from request\");\n parameterBuilder.addLoginHint(request.loginHint);\n parameterBuilder.addCcsUpn(request.loginHint);\n }\n } else {\n this.logger.verbose(\"createAuthCodeUrlQueryString: Prompt is select_account, ignoring account hints\");\n }\n\n if (request.nonce) {\n parameterBuilder.addNonce(request.nonce);\n }\n\n if (request.state) {\n parameterBuilder.addState(request.state);\n }\n\n if (!StringUtils.isEmpty(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 (request.extraQueryParameters) {\n parameterBuilder.addExtraQueryParameters(request.extraQueryParameters);\n }\n\n return parameterBuilder.createQueryString();\n }\n\n /**\n * This API validates the `EndSessionRequest` and creates a URL\n * @param request\n */\n private createLogoutUrlQueryString(request: CommonEndSessionRequest): string {\n const parameterBuilder = new RequestParameterBuilder();\n\n if (request.postLogoutRedirectUri) {\n parameterBuilder.addPostLogoutRedirectUri(request.postLogoutRedirectUri);\n }\n\n if (request.correlationId) {\n parameterBuilder.addCorrelationId(request.correlationId);\n }\n\n if (request.idTokenHint) {\n parameterBuilder.addIdTokenHint(request.idTokenHint);\n }\n \n if(request.state) {\n parameterBuilder.addState(request.state);\n }\n\n if (request.logoutHint) {\n parameterBuilder.addLogoutHint(request.logoutHint);\n }\n\n if (request.extraQueryParameters) {\n parameterBuilder.addExtraQueryParameters(request.extraQueryParameters);\n }\n\n return parameterBuilder.createQueryString();\n }\n\n /**\n * Helper to get sid from account. Returns null if idTokenClaims are not present or sid is not present.\n * @param account \n */\n private extractAccountSid(account: AccountInfo): string | null {\n if (account.idTokenClaims) {\n const tokenClaims = account.idTokenClaims as TokenClaims;\n return tokenClaims.sid || null;\n }\n return null;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA;;;;AAgCA;;;;IAG6C,2CAAU;IAInD,iCAAY,aAAkC;QAA9C,YACI,kBAAM,aAAa,CAAC,SACvB;;QAJS,wBAAkB,GAAY,IAAI,CAAC;;KAI5C;;;;;;;;;;;IAYK,gDAAc,GAApB,UAAqB,OAAsC;;;;gBACjD,WAAW,GAAG,IAAI,CAAC,4BAA4B,CAAC,OAAO,CAAC,CAAC;gBAE/D,sBAAO,SAAS,CAAC,iBAAiB,CAAC,IAAI,CAAC,SAAS,CAAC,qBAAqB,EAAE,WAAW,CAAC,EAAC;;;KACzF;;;;;;IAOK,8CAAY,GAAlB,UAAmB,OAAuC,EAAE,eAA0C;;;;;;wBAClG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;wBACzC,IAAI,CAAC,OAAO,IAAI,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;4BAC/C,MAAM,eAAe,CAAC,mCAAmC,EAAE,CAAC;yBAC/D;wBAEK,YAAY,GAAG,SAAS,CAAC,UAAU,EAAE,CAAC;wBAC3B,qBAAM,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,EAAA;;wBAAlE,QAAQ,GAAG,SAAuD;wBAElE,eAAe,GAAG,IAAI,eAAe,CACvC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,QAAQ,EAChC,IAAI,CAAC,YAAY,EACjB,IAAI,CAAC,WAAW,EAChB,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,MAAM,CAAC,iBAAiB,EAC7B,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAChC,CAAC;;wBAGF,eAAe,CAAC,qBA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IAAI,OAAO,CAAC,oBAAoB,EAAE;YAC9B,gBAAgB,CAAC,uBAAuB,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC;SAC1E;QAED,OAAO,gBAAgB,CAAC,iBAAiB,EAAE,CAAC;KAC/C;;;;;IAMO,mDAAiB,GAAzB,UAA0B,OAAoB;QAC1C,IAAI,OAAO,CAAC,aAAa,EAAE;YACvB,IAAM,WAAW,GAAG,OAAO,CAAC,aAA4B,CAAC;YACzD,OAAO,WAAW,CAAC,GAAG,IAAI,IAAI,CAAC;SAClC;QACD,OAAO,IAAI,CAAC;KACf;IACL,8BAAC;AAAD,CAlaA,CAA6C,UAAU;;;;"}
|
|
1
|
+
{"version":3,"file":"AuthorizationCodeClient.js","sources":["../../src/client/AuthorizationCodeClient.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { BaseClient } from \"./BaseClient\";\nimport { CommonAuthorizationUrlRequest } from \"../request/CommonAuthorizationUrlRequest\";\nimport { CommonAuthorizationCodeRequest } from \"../request/CommonAuthorizationCodeRequest\";\nimport { Authority } from \"../authority/Authority\";\nimport { RequestParameterBuilder } from \"../request/RequestParameterBuilder\";\nimport { GrantType, AuthenticationScheme, PromptValue, Separators, AADServerParamKeys } from \"../utils/Constants\";\nimport { ClientConfiguration } from \"../config/ClientConfiguration\";\nimport { ServerAuthorizationTokenResponse } from \"../response/ServerAuthorizationTokenResponse\";\nimport { NetworkResponse } from \"../network/NetworkManager\";\nimport { ResponseHandler } from \"../response/ResponseHandler\";\nimport { AuthenticationResult } from \"../response/AuthenticationResult\";\nimport { StringUtils } from \"../utils/StringUtils\";\nimport { ClientAuthError } from \"../error/ClientAuthError\";\nimport { UrlString } from \"../url/UrlString\";\nimport { ServerAuthorizationCodeResponse } from \"../response/ServerAuthorizationCodeResponse\";\nimport { CommonEndSessionRequest } from \"../request/CommonEndSessionRequest\";\nimport { PopTokenGenerator } from \"../crypto/PopTokenGenerator\";\nimport { RequestThumbprint } from \"../network/RequestThumbprint\";\nimport { AuthorizationCodePayload } from \"../response/AuthorizationCodePayload\";\nimport { TimeUtils } from \"../utils/TimeUtils\";\nimport { TokenClaims } from \"../account/TokenClaims\";\nimport { AccountInfo } from \"../account/AccountInfo\";\nimport { buildClientInfoFromHomeAccountId, buildClientInfo } from \"../account/ClientInfo\";\nimport { CcsCredentialType, CcsCredential } from \"../account/CcsCredential\";\nimport { ClientConfigurationError } from \"../error/ClientConfigurationError\";\nimport { RequestValidator } from \"../request/RequestValidator\";\n\n/**\n * Oauth2.0 Authorization Code client\n */\nexport class AuthorizationCodeClient extends BaseClient {\n // Flag to indicate if client is for hybrid spa auth code redemption\n protected includeRedirectUri: boolean = true;\n\n constructor(configuration: ClientConfiguration) {\n super(configuration);\n }\n\n /**\n * Creates the URL of the authorization request letting the user input credentials and consent to the\n * application. The URL target the /authorize endpoint of the authority configured in the\n * application object.\n *\n * Once the user inputs their credentials and consents, the authority will send a response to the redirect URI\n * sent in the request and should contain an authorization code, which can then be used to acquire tokens via\n * acquireToken(AuthorizationCodeRequest)\n * @param request\n */\n async getAuthCodeUrl(request: CommonAuthorizationUrlRequest): Promise<string> {\n const queryString = await this.createAuthCodeUrlQueryString(request);\n\n return UrlString.appendQueryString(this.authority.authorizationEndpoint, queryString);\n }\n\n /**\n * API to acquire a token in exchange of 'authorization_code` acquired by the user in the first leg of the\n * authorization_code_grant\n * @param request\n */\n async acquireToken(request: CommonAuthorizationCodeRequest, authCodePayload?: AuthorizationCodePayload): Promise<AuthenticationResult> {\n this.logger.info(\"in acquireToken call\");\n if (!request || StringUtils.isEmpty(request.code)) {\n throw ClientAuthError.createTokenRequestCannotBeMadeError();\n }\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 return await responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request, authCodePayload);\n }\n\n /**\n * Handles the hash fragment response from public client code request. Returns a code response used by\n * the client to exchange for a token in acquireToken.\n * @param hashFragment\n */\n handleFragmentResponse(hashFragment: string, cachedState: string): AuthorizationCodePayload {\n // Handle responses.\n const responseHandler = new ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, null, null);\n\n // Deserialize hash fragment response parameters.\n const hashUrlString = new UrlString(hashFragment);\n // Deserialize hash fragment response parameters.\n const serverParams: ServerAuthorizationCodeResponse = UrlString.getDeserializedHash(hashUrlString.getHash());\n\n // Get code response\n responseHandler.validateServerAuthorizationCodeResponse(serverParams, cachedState, this.cryptoUtils);\n\n // throw when there is no auth code in the response\n if (!serverParams.code) {\n throw ClientAuthError.createNoAuthCodeInServerResponseError();\n }\n return {\n ...serverParams,\n // Code param is optional in ServerAuthorizationCodeResponse but required in AuthorizationCodePaylod\n code: serverParams.code\n };\n }\n\n /**\n * Used to log out the current user, and redirect the user to the postLogoutRedirectUri.\n * Default behaviour is to redirect the user to `window.location.href`.\n * @param authorityUri\n */\n getLogoutUri(logoutRequest: CommonEndSessionRequest): string {\n // Throw error if logoutRequest is null/undefined\n if (!logoutRequest) {\n throw ClientConfigurationError.createEmptyLogoutRequestError();\n }\n const queryString = this.createLogoutUrlQueryString(logoutRequest);\n\n // Construct logout URI.\n return UrlString.appendQueryString(this.authority.endSessionEndpoint, queryString);\n }\n\n /**\n * Executes POST request to token endpoint\n * @param authority\n * @param request\n */\n private async executeTokenRequest(authority: Authority, request: CommonAuthorizationCodeRequest): 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\n const requestBody = await this.createTokenRequestBody(request);\n const queryParameters = this.createTokenQueryParameters(request);\n let ccsCredential: CcsCredential | undefined = undefined;\n if (request.clientInfo) {\n try {\n const clientInfo = buildClientInfo(request.clientInfo, this.cryptoUtils);\n ccsCredential = {\n credential: `${clientInfo.uid}${Separators.CLIENT_INFO_SEPARATOR}${clientInfo.utid}`,\n type: CcsCredentialType.HOME_ACCOUNT_ID\n };\n } catch (e) {\n this.logger.verbose(\"Could not parse client info for CCS Header: \" + e);\n }\n }\n const headers: Record<string, string> = this.createTokenRequestHeaders(ccsCredential || request.ccsCredential);\n const endpoint = StringUtils.isEmpty(queryParameters) ? authority.tokenEndpoint : `${authority.tokenEndpoint}?${queryParameters}`;\n\n return this.executePostToTokenEndpoint(endpoint, requestBody, headers, thumbprint);\n }\n\n /**\n * Creates query string for the /token request\n * @param request\n */\n private createTokenQueryParameters(request: CommonAuthorizationCodeRequest): string {\n const parameterBuilder = new RequestParameterBuilder();\n\n if (request.tokenQueryParameters) {\n parameterBuilder.addExtraQueryParameters(request.tokenQueryParameters);\n }\n\n return parameterBuilder.createQueryString();\n }\n\n /**\n * Generates a map for all the params to be sent to the service\n * @param request\n */\n private async createTokenRequestBody(request: CommonAuthorizationCodeRequest): Promise<string> {\n const parameterBuilder = new RequestParameterBuilder();\n\n parameterBuilder.addClientId(this.config.authOptions.clientId);\n\n /*\n * For hybrid spa flow, there will be a code but no verifier\n * In this scenario, don't include redirect uri as auth code will not be bound to redirect URI\n */\n if (!this.includeRedirectUri) {\n // Just validate\n RequestValidator.validateRedirectUri(request.redirectUri);\n } else {\n // Validate and include redirect uri\n parameterBuilder.addRedirectUri(request.redirectUri);\n }\n\n // Add scope array, parameter builder will add default scopes and dedupe\n parameterBuilder.addScopes(request.scopes);\n\n // add code: user set, not validated\n parameterBuilder.addAuthorizationCode(request.code);\n\n // Add library metadata\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 // add code_verifier if passed\n if (request.codeVerifier) {\n parameterBuilder.addCodeVerifier(request.codeVerifier);\n }\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 parameterBuilder.addGrantType(GrantType.AUTHORIZATION_CODE_GRANT);\n parameterBuilder.addClientInfo();\n\n if (request.authenticationScheme === AuthenticationScheme.POP) {\n const popTokenGenerator = new PopTokenGenerator(this.cryptoUtils);\n const cnfString = await popTokenGenerator.generateCnf(request);\n parameterBuilder.addPopToken(cnfString);\n } else if (request.authenticationScheme === AuthenticationScheme.SSH) {\n if(request.sshJwk) {\n parameterBuilder.addSshJwk(request.sshJwk);\n } else {\n throw ClientConfigurationError.createMissingSshJwkError();\n }\n }\n\n const correlationId = request.correlationId || this.config.cryptoInterface.createNewGuid();\n parameterBuilder.addCorrelationId(correlationId);\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 let ccsCred: CcsCredential | undefined = undefined;\n if (request.clientInfo) {\n try {\n const clientInfo = buildClientInfo(request.clientInfo, this.cryptoUtils);\n ccsCred = {\n credential: `${clientInfo.uid}${Separators.CLIENT_INFO_SEPARATOR}${clientInfo.utid}`,\n type: CcsCredentialType.HOME_ACCOUNT_ID\n };\n } catch (e) {\n this.logger.verbose(\"Could not parse client info for CCS Header: \" + e);\n }\n } else {\n ccsCred = request.ccsCredential;\n }\n\n // Adds these as parameters in the request instead of headers to prevent CORS preflight request\n if (this.config.systemOptions.preventCorsPreflight && ccsCred) {\n switch (ccsCred.type) {\n case CcsCredentialType.HOME_ACCOUNT_ID:\n try {\n const clientInfo = buildClientInfoFromHomeAccountId(ccsCred.credential);\n parameterBuilder.addCcsOid(clientInfo);\n } catch (e) {\n this.logger.verbose(\"Could not parse home account ID for CCS Header: \" + e);\n }\n break;\n case CcsCredentialType.UPN:\n parameterBuilder.addCcsUpn(ccsCred.credential);\n break;\n }\n }\n\n if (request.tokenBodyParameters) {\n parameterBuilder.addExtraQueryParameters(request.tokenBodyParameters);\n }\n\n // Add hybrid spa parameters if not already provided\n if (request.enableSpaAuthorizationCode && (!request.tokenBodyParameters || !request.tokenBodyParameters[AADServerParamKeys.RETURN_SPA_CODE])) {\n parameterBuilder.addExtraQueryParameters({\n [AADServerParamKeys.RETURN_SPA_CODE]: \"1\"\n });\n }\n\n return parameterBuilder.createQueryString();\n }\n\n /**\n * This API validates the `AuthorizationCodeUrlRequest` and creates a URL\n * @param request\n */\n private async createAuthCodeUrlQueryString(request: CommonAuthorizationUrlRequest): Promise<string> {\n const parameterBuilder = new RequestParameterBuilder();\n\n parameterBuilder.addClientId(this.config.authOptions.clientId);\n\n const requestScopes = [...request.scopes || [], ...request.extraScopesToConsent || []];\n parameterBuilder.addScopes(requestScopes);\n\n // validate the redirectUri (to be a non null value)\n parameterBuilder.addRedirectUri(request.redirectUri);\n\n // generate the correlationId if not set by the user and add\n const correlationId = request.correlationId || this.config.cryptoInterface.createNewGuid();\n parameterBuilder.addCorrelationId(correlationId);\n\n // add response_mode. If not passed in it defaults to query.\n parameterBuilder.addResponseMode(request.responseMode);\n\n // add response_type = code\n parameterBuilder.addResponseTypeCode();\n\n // add library info parameters\n parameterBuilder.addLibraryInfo(this.config.libraryInfo);\n parameterBuilder.addApplicationTelemetry(this.config.telemetry.application);\n\n // add client_info=1\n parameterBuilder.addClientInfo();\n\n if (request.codeChallenge && request.codeChallengeMethod) {\n parameterBuilder.addCodeChallengeParams(request.codeChallenge, request.codeChallengeMethod);\n }\n\n if (request.prompt) {\n parameterBuilder.addPrompt(request.prompt);\n }\n\n if (request.domainHint) {\n parameterBuilder.addDomainHint(request.domainHint);\n }\n\n // Add sid or loginHint with preference for sid -> loginHint -> username of AccountInfo object\n if (request.prompt !== PromptValue.SELECT_ACCOUNT) {\n // AAD will throw if prompt=select_account is passed with an account hint\n if (request.sid && request.prompt === PromptValue.NONE) {\n // SessionID is only used in silent calls\n this.logger.verbose(\"createAuthCodeUrlQueryString: Prompt is none, adding sid from request\");\n parameterBuilder.addSid(request.sid);\n } else if (request.account) {\n const accountSid = this.extractAccountSid(request.account);\n // If account and loginHint are provided, we will check account first for sid before adding loginHint\n if (accountSid && request.prompt === PromptValue.NONE) {\n // SessionId is only used in silent calls\n this.logger.verbose(\"createAuthCodeUrlQueryString: Prompt is none, adding sid from account\");\n parameterBuilder.addSid(accountSid);\n try {\n const clientInfo = buildClientInfoFromHomeAccountId(request.account.homeAccountId);\n parameterBuilder.addCcsOid(clientInfo);\n } catch (e) {\n this.logger.verbose(\"Could not parse home account ID for CCS Header: \" + e);\n }\n } else if (request.loginHint) {\n this.logger.verbose(\"createAuthCodeUrlQueryString: Adding login_hint from request\");\n parameterBuilder.addLoginHint(request.loginHint);\n parameterBuilder.addCcsUpn(request.loginHint);\n } else if (request.account.username) {\n // Fallback to account username if provided\n this.logger.verbose(\"createAuthCodeUrlQueryString: Adding login_hint from account\");\n parameterBuilder.addLoginHint(request.account.username);\n try {\n const clientInfo = buildClientInfoFromHomeAccountId(request.account.homeAccountId);\n parameterBuilder.addCcsOid(clientInfo);\n } catch (e) {\n this.logger.verbose(\"Could not parse home account ID for CCS Header: \" + e);\n }\n }\n } else if (request.loginHint) {\n this.logger.verbose(\"createAuthCodeUrlQueryString: No account, adding login_hint from request\");\n parameterBuilder.addLoginHint(request.loginHint);\n parameterBuilder.addCcsUpn(request.loginHint);\n }\n } else {\n this.logger.verbose(\"createAuthCodeUrlQueryString: Prompt is select_account, ignoring account hints\");\n }\n\n if (request.nonce) {\n parameterBuilder.addNonce(request.nonce);\n }\n\n if (request.state) {\n parameterBuilder.addState(request.state);\n }\n\n if (!StringUtils.isEmpty(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 (request.extraQueryParameters) {\n parameterBuilder.addExtraQueryParameters(request.extraQueryParameters);\n }\n\n if (request.nativeBroker) {\n // signal ests that this is a WAM call\n parameterBuilder.addNativeBroker();\n\n // pass the req_cnf for POP\n if (request.authenticationScheme === AuthenticationScheme.POP) {\n const popTokenGenerator = new PopTokenGenerator(this.cryptoUtils);\n const cnf = await popTokenGenerator.generateCnf(request);\n\n // to reduce the URL length, it is recommended to send the hash of the req_cnf instead of the whole string\n const cnfHash = await popTokenGenerator.generateCnfHash(cnf);\n parameterBuilder.addPopToken(cnfHash);\n }\n }\n\n return parameterBuilder.createQueryString();\n }\n\n /**\n * This API validates the `EndSessionRequest` and creates a URL\n * @param request\n */\n private createLogoutUrlQueryString(request: CommonEndSessionRequest): string {\n const parameterBuilder = new RequestParameterBuilder();\n\n if (request.postLogoutRedirectUri) {\n parameterBuilder.addPostLogoutRedirectUri(request.postLogoutRedirectUri);\n }\n\n if (request.correlationId) {\n parameterBuilder.addCorrelationId(request.correlationId);\n }\n\n if (request.idTokenHint) {\n parameterBuilder.addIdTokenHint(request.idTokenHint);\n }\n\n if(request.state) {\n parameterBuilder.addState(request.state);\n }\n\n if (request.logoutHint) {\n parameterBuilder.addLogoutHint(request.logoutHint);\n }\n\n if (request.extraQueryParameters) {\n parameterBuilder.addExtraQueryParameters(request.extraQueryParameters);\n }\n\n return parameterBuilder.createQueryString();\n }\n\n /**\n * Helper to get sid from account. Returns null if idTokenClaims are not present or sid is not present.\n * @param account\n */\n private extractAccountSid(account: AccountInfo): string | null {\n if (account.idTokenClaims) {\n const tokenClaims = account.idTokenClaims as TokenClaims;\n return tokenClaims.sid || null;\n }\n return null;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA;;;;AAgCA;;;;IAG6C,2CAAU;IAInD,iCAAY,aAAkC;QAA9C,YACI,kBAAM,aAAa,CAAC,SACvB;;QAJS,wBAAkB,GAAY,IAAI,CAAC;;KAI5C;;;;;;;;;;;IAYK,gDAAc,GAApB,UAAqB,OAAsC;;;;;4BACnC,qBAAM,IAAI,CAAC,4BAA4B,CAAC,OAAO,CAAC,EAAA;;wBAA9D,WAAW,GAAG,SAAgD;wBAEpE,sBAAO,SAAS,CAAC,iBAAiB,CAAC,IAAI,CAAC,SAAS,CAAC,qBAAqB,EAAE,WAAW,CAAC,EAAC;;;;KACzF;;;;;;IAOK,8CAAY,GAAlB,UAAmB,OAAuC,EAAE,eAA0C;;;;;;wBAClG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;wBACzC,IAAI,CAAC,OAAO,IAAI,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;4BAC/C,MAAM,eAAe,CAAC,mCAAmC,EAAE,CAAC;yBAC/D;wBAEK,YAAY,GAAG,SAAS,CAAC,UAAU,EAAE,CAAC;wBAC3B,qBAAM,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,EAAA;;wBAAlE,QAAQ,GAAG,SAAuD;wBAElE,eAAe,GAAG,IAAI,eAAe,CACvC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,QAAQ,EAChC,IAAI,CAAC,YAAY,EACjB,IAAI,CAAC,WAAW,EAChB,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,MAAM,CAAC,iBAAiB,EAC7B,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAChC,CAAC;;wBAGF,eAAe,CAAC,qBAAqB,CAAC,QAAQ,CAAC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;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAM1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AACxE,OAAO,EAAE,6BAA6B,EAAE,MAAM,0CAA0C,CAAC;AAQzF;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,UAAU;IAElD,OAAO,CAAC,QAAQ,CAAW;gBAEf,aAAa,EAAE,mBAAmB;IAI9C;;;OAGG;IACU,YAAY,CAAC,OAAO,EAAE,6BAA6B,GAAG,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;IAgBvG;;OAEG;YACW,6BAA6B;IA6B3C;;;OAGG;IACH,OAAO,CAAC,wBAAwB;IAmBhC;;;;OAIG;YACW,mBAAmB;IAwCjC;;;OAGG;IACH,OAAO,CAAC,sBAAsB;
|
|
1
|
+
{"version":3,"file":"ClientCredentialClient.d.ts","sourceRoot":"","sources":["../../src/client/ClientCredentialClient.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAM1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AACxE,OAAO,EAAE,6BAA6B,EAAE,MAAM,0CAA0C,CAAC;AAQzF;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,UAAU;IAElD,OAAO,CAAC,QAAQ,CAAW;gBAEf,aAAa,EAAE,mBAAmB;IAI9C;;;OAGG;IACU,YAAY,CAAC,OAAO,EAAE,6BAA6B,GAAG,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;IAgBvG;;OAEG;YACW,6BAA6B;IA6B3C;;;OAGG;IACH,OAAO,CAAC,wBAAwB;IAmBhC;;;;OAIG;YACW,mBAAmB;IAwCjC;;;OAGG;IACH,OAAO,CAAC,sBAAsB;CAqCjC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
/*! @azure/msal-common v6.
|
|
1
|
+
/*! @azure/msal-common v6.3.0 2022-05-02 */
|
|
2
2
|
'use strict';
|
|
3
3
|
import { __extends, __awaiter, __generator } from '../_virtual/_tslib.js';
|
|
4
4
|
import { BaseClient } from './BaseClient.js';
|
|
5
5
|
import { RequestParameterBuilder } from '../request/RequestParameterBuilder.js';
|
|
6
6
|
import { ScopeSet } from '../request/ScopeSet.js';
|
|
7
|
-
import { CredentialType, GrantType, CacheOutcome } from '../utils/Constants.js';
|
|
7
|
+
import { Constants, CredentialType, GrantType, CacheOutcome } from '../utils/Constants.js';
|
|
8
8
|
import { ResponseHandler } from '../response/ResponseHandler.js';
|
|
9
9
|
import { TimeUtils } from '../utils/TimeUtils.js';
|
|
10
10
|
import { StringUtils } from '../utils/StringUtils.js';
|
|
@@ -84,7 +84,7 @@ var ClientCredentialClient = /** @class */ (function (_super) {
|
|
|
84
84
|
*/
|
|
85
85
|
ClientCredentialClient.prototype.readAccessTokenFromCache = function () {
|
|
86
86
|
var accessTokenFilter = {
|
|
87
|
-
homeAccountId:
|
|
87
|
+
homeAccountId: Constants.EMPTY_STRING,
|
|
88
88
|
environment: this.authority.canonicalAuthorityUrlComponents.HostNameAndPort,
|
|
89
89
|
credentialType: CredentialType.ACCESS_TOKEN,
|
|
90
90
|
clientId: this.config.authOptions.clientId,
|
|
@@ -149,6 +149,7 @@ var ClientCredentialClient = /** @class */ (function (_super) {
|
|
|
149
149
|
parameterBuilder.addScopes(request.scopes, false);
|
|
150
150
|
parameterBuilder.addGrantType(GrantType.CLIENT_CREDENTIALS_GRANT);
|
|
151
151
|
parameterBuilder.addLibraryInfo(this.config.libraryInfo);
|
|
152
|
+
parameterBuilder.addApplicationTelemetry(this.config.telemetry.application);
|
|
152
153
|
parameterBuilder.addThrottling();
|
|
153
154
|
if (this.serverTelemetryManager) {
|
|
154
155
|
parameterBuilder.addServerTelemetry(this.serverTelemetryManager);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClientCredentialClient.js","sources":["../../src/client/ClientCredentialClient.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ClientConfiguration } from \"../config/ClientConfiguration\";\nimport { BaseClient } from \"./BaseClient\";\nimport { Authority } from \"../authority/Authority\";\nimport { RequestParameterBuilder } from \"../request/RequestParameterBuilder\";\nimport { ScopeSet } from \"../request/ScopeSet\";\nimport { GrantType , CredentialType, CacheOutcome } from \"../utils/Constants\";\nimport { ResponseHandler } from \"../response/ResponseHandler\";\nimport { AuthenticationResult } from \"../response/AuthenticationResult\";\nimport { CommonClientCredentialRequest } from \"../request/CommonClientCredentialRequest\";\nimport { CredentialFilter, CredentialCache } from \"../cache/utils/CacheTypes\";\nimport { AccessTokenEntity } from \"../cache/entities/AccessTokenEntity\";\nimport { TimeUtils } from \"../utils/TimeUtils\";\nimport { StringUtils } from \"../utils/StringUtils\";\nimport { RequestThumbprint } from \"../network/RequestThumbprint\";\nimport { ClientAuthError } from \"../error/ClientAuthError\";\n\n/**\n * OAuth2.0 client credential grant\n */\nexport class ClientCredentialClient extends BaseClient {\n\n private scopeSet: ScopeSet;\n\n constructor(configuration: ClientConfiguration) {\n super(configuration);\n }\n\n /**\n * Public API to acquire a token with ClientCredential Flow for Confidential clients\n * @param request\n */\n public async acquireToken(request: CommonClientCredentialRequest): Promise<AuthenticationResult | null> {\n\n this.scopeSet = new ScopeSet(request.scopes || []);\n\n if (request.skipCache) {\n return await this.executeTokenRequest(request, this.authority);\n }\n\n const cachedAuthenticationResult = await this.getCachedAuthenticationResult(request);\n if (cachedAuthenticationResult) {\n return cachedAuthenticationResult;\n } else {\n return await this.executeTokenRequest(request, this.authority);\n }\n }\n\n /**\n * looks up cache if the tokens are cached already\n */\n private async getCachedAuthenticationResult(request: CommonClientCredentialRequest): Promise<AuthenticationResult | null> {\n \n const cachedAccessToken = this.readAccessTokenFromCache();\n\n if (!cachedAccessToken) {\n this.serverTelemetryManager?.setCacheOutcome(CacheOutcome.NO_CACHED_ACCESS_TOKEN);\n return null;\n }\n\n if (TimeUtils.isTokenExpired(cachedAccessToken.expiresOn, this.config.systemOptions.tokenRenewalOffsetSeconds)) {\n this.serverTelemetryManager?.setCacheOutcome(CacheOutcome.CACHED_ACCESS_TOKEN_EXPIRED);\n return null;\n }\n\n return await ResponseHandler.generateAuthenticationResult(\n this.cryptoUtils,\n this.authority,\n {\n account: null,\n idToken: null,\n accessToken: cachedAccessToken,\n refreshToken: null,\n appMetadata: null\n },\n true,\n request\n );\n }\n\n /**\n * Reads access token from the cache\n * TODO: Move this call to cacheManager instead\n */\n private readAccessTokenFromCache(): AccessTokenEntity | null {\n const accessTokenFilter: CredentialFilter = {\n homeAccountId: \"\",\n environment: this.authority.canonicalAuthorityUrlComponents.HostNameAndPort,\n credentialType: CredentialType.ACCESS_TOKEN,\n clientId: this.config.authOptions.clientId,\n realm: this.authority.tenant,\n target: this.scopeSet.printScopesLowerCase()\n };\n const credentialCache: CredentialCache = this.cacheManager.getCredentialsFilteredBy(accessTokenFilter);\n const accessTokens = Object.keys(credentialCache.accessTokens).map(key => credentialCache.accessTokens[key]);\n if (accessTokens.length < 1) {\n return null;\n } else if (accessTokens.length > 1) {\n throw ClientAuthError.createMultipleMatchingTokensInCacheError();\n }\n return accessTokens[0] as AccessTokenEntity;\n }\n\n /**\n * Makes a network call to request the token from the service\n * @param request\n * @param authority\n */\n private async executeTokenRequest(request: CommonClientCredentialRequest, authority: Authority)\n : Promise<AuthenticationResult | null> {\n\n const requestBody = this.createTokenRequestBody(request);\n const headers: Record<string, string> = this.createTokenRequestHeaders();\n const thumbprint: RequestThumbprint = {\n clientId: this.config.authOptions.clientId,\n authority: request.authority,\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\n const reqTimestamp = TimeUtils.nowSeconds();\n const response = await this.executePostToTokenEndpoint(authority.tokenEndpoint, requestBody, headers, thumbprint);\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 responseHandler.validateTokenResponse(response.body);\n const tokenResponse = await responseHandler.handleServerTokenResponse(\n response.body,\n this.authority,\n reqTimestamp,\n request\n );\n\n return tokenResponse;\n }\n\n /**\n * generate the request to the server in the acceptable format\n * @param request\n */\n private createTokenRequestBody(request: CommonClientCredentialRequest): string {\n const parameterBuilder = new RequestParameterBuilder();\n\n parameterBuilder.addClientId(this.config.authOptions.clientId);\n\n parameterBuilder.addScopes(request.scopes, false);\n\n parameterBuilder.addGrantType(GrantType.CLIENT_CREDENTIALS_GRANT);\n\n parameterBuilder.addLibraryInfo(this.config.libraryInfo);\n\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 return parameterBuilder.createQueryString();\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;AAqBA;;;;IAG4C,0CAAU;IAIlD,gCAAY,aAAkC;eAC1C,kBAAM,aAAa,CAAC;KACvB;;;;;IAMY,6CAAY,GAAzB,UAA0B,OAAsC;;;;;;wBAE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D,CAxKA,CAA4C,UAAU;;;;"}
|
|
1
|
+
{"version":3,"file":"ClientCredentialClient.js","sources":["../../src/client/ClientCredentialClient.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ClientConfiguration } from \"../config/ClientConfiguration\";\nimport { BaseClient } from \"./BaseClient\";\nimport { Authority } from \"../authority/Authority\";\nimport { RequestParameterBuilder } from \"../request/RequestParameterBuilder\";\nimport { ScopeSet } from \"../request/ScopeSet\";\nimport { GrantType , CredentialType, CacheOutcome, Constants } from \"../utils/Constants\";\nimport { ResponseHandler } from \"../response/ResponseHandler\";\nimport { AuthenticationResult } from \"../response/AuthenticationResult\";\nimport { CommonClientCredentialRequest } from \"../request/CommonClientCredentialRequest\";\nimport { CredentialFilter, CredentialCache } from \"../cache/utils/CacheTypes\";\nimport { AccessTokenEntity } from \"../cache/entities/AccessTokenEntity\";\nimport { TimeUtils } from \"../utils/TimeUtils\";\nimport { StringUtils } from \"../utils/StringUtils\";\nimport { RequestThumbprint } from \"../network/RequestThumbprint\";\nimport { ClientAuthError } from \"../error/ClientAuthError\";\n\n/**\n * OAuth2.0 client credential grant\n */\nexport class ClientCredentialClient extends BaseClient {\n\n private scopeSet: ScopeSet;\n\n constructor(configuration: ClientConfiguration) {\n super(configuration);\n }\n\n /**\n * Public API to acquire a token with ClientCredential Flow for Confidential clients\n * @param request\n */\n public async acquireToken(request: CommonClientCredentialRequest): Promise<AuthenticationResult | null> {\n\n this.scopeSet = new ScopeSet(request.scopes || []);\n\n if (request.skipCache) {\n return await this.executeTokenRequest(request, this.authority);\n }\n\n const cachedAuthenticationResult = await this.getCachedAuthenticationResult(request);\n if (cachedAuthenticationResult) {\n return cachedAuthenticationResult;\n } else {\n return await this.executeTokenRequest(request, this.authority);\n }\n }\n\n /**\n * looks up cache if the tokens are cached already\n */\n private async getCachedAuthenticationResult(request: CommonClientCredentialRequest): Promise<AuthenticationResult | null> {\n \n const cachedAccessToken = this.readAccessTokenFromCache();\n\n if (!cachedAccessToken) {\n this.serverTelemetryManager?.setCacheOutcome(CacheOutcome.NO_CACHED_ACCESS_TOKEN);\n return null;\n }\n\n if (TimeUtils.isTokenExpired(cachedAccessToken.expiresOn, this.config.systemOptions.tokenRenewalOffsetSeconds)) {\n this.serverTelemetryManager?.setCacheOutcome(CacheOutcome.CACHED_ACCESS_TOKEN_EXPIRED);\n return null;\n }\n\n return await ResponseHandler.generateAuthenticationResult(\n this.cryptoUtils,\n this.authority,\n {\n account: null,\n idToken: null,\n accessToken: cachedAccessToken,\n refreshToken: null,\n appMetadata: null\n },\n true,\n request\n );\n }\n\n /**\n * Reads access token from the cache\n * TODO: Move this call to cacheManager instead\n */\n private readAccessTokenFromCache(): AccessTokenEntity | null {\n const accessTokenFilter: CredentialFilter = {\n homeAccountId: Constants.EMPTY_STRING,\n environment: this.authority.canonicalAuthorityUrlComponents.HostNameAndPort,\n credentialType: CredentialType.ACCESS_TOKEN,\n clientId: this.config.authOptions.clientId,\n realm: this.authority.tenant,\n target: this.scopeSet.printScopesLowerCase()\n };\n const credentialCache: CredentialCache = this.cacheManager.getCredentialsFilteredBy(accessTokenFilter);\n const accessTokens = Object.keys(credentialCache.accessTokens).map(key => credentialCache.accessTokens[key]);\n if (accessTokens.length < 1) {\n return null;\n } else if (accessTokens.length > 1) {\n throw ClientAuthError.createMultipleMatchingTokensInCacheError();\n }\n return accessTokens[0] as AccessTokenEntity;\n }\n\n /**\n * Makes a network call to request the token from the service\n * @param request\n * @param authority\n */\n private async executeTokenRequest(request: CommonClientCredentialRequest, authority: Authority)\n : Promise<AuthenticationResult | null> {\n\n const requestBody = this.createTokenRequestBody(request);\n const headers: Record<string, string> = this.createTokenRequestHeaders();\n const thumbprint: RequestThumbprint = {\n clientId: this.config.authOptions.clientId,\n authority: request.authority,\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\n const reqTimestamp = TimeUtils.nowSeconds();\n const response = await this.executePostToTokenEndpoint(authority.tokenEndpoint, requestBody, headers, thumbprint);\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 responseHandler.validateTokenResponse(response.body);\n const tokenResponse = await responseHandler.handleServerTokenResponse(\n response.body,\n this.authority,\n reqTimestamp,\n request\n );\n\n return tokenResponse;\n }\n\n /**\n * generate the request to the server in the acceptable format\n * @param request\n */\n private createTokenRequestBody(request: CommonClientCredentialRequest): string {\n const parameterBuilder = new RequestParameterBuilder();\n\n parameterBuilder.addClientId(this.config.authOptions.clientId);\n\n parameterBuilder.addScopes(request.scopes, false);\n\n parameterBuilder.addGrantType(GrantType.CLIENT_CREDENTIALS_GRANT);\n\n parameterBuilder.addLibraryInfo(this.config.libraryInfo);\n parameterBuilder.addApplicationTelemetry(this.config.telemetry.application);\n\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 return parameterBuilder.createQueryString();\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;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C,kBAAkB,CAAC,MAAM,GAAG,CAAC,EAAE;YAChJ,gBAAgB,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAC;SAC1F;QAED,OAAO,gBAAgB,CAAC,iBAAiB,EAAE,CAAC;KAC/C;IACL,6BAAC;AAAD,CAzKA,CAA4C,UAAU;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeviceCodeClient.d.ts","sourceRoot":"","sources":["../../src/client/DeviceCodeClient.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAI7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAIpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAIxE;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,UAAU;gBAEhC,aAAa,EAAE,mBAAmB;IAI9C;;;;OAIG;IACU,YAAY,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;IA2BjG;;;OAGG;YACW,aAAa;IAkB3B;;;;;OAKG;YACW,sCAAsC;IAkCpD;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAczB;;;;OAIG;IACH,OAAO,CAAC,eAAe;IAqBvB;;;;;OAKG;YACW,0BAA0B;IAoDxC;;;;OAIG;IACH,OAAO,CAAC,sBAAsB;
|
|
1
|
+
{"version":3,"file":"DeviceCodeClient.d.ts","sourceRoot":"","sources":["../../src/client/DeviceCodeClient.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAI7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAIpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAIxE;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,UAAU;gBAEhC,aAAa,EAAE,mBAAmB;IAI9C;;;;OAIG;IACU,YAAY,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;IA2BjG;;;OAGG;YACW,aAAa;IAkB3B;;;;;OAKG;YACW,sCAAsC;IAkCpD;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAczB;;;;OAIG;IACH,OAAO,CAAC,eAAe;IAqBvB;;;;;OAKG;YACW,0BAA0B;IAoDxC;;;;OAIG;IACH,OAAO,CAAC,sBAAsB;CAwBjC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @azure/msal-common v6.
|
|
1
|
+
/*! @azure/msal-common v6.3.0 2022-05-02 */
|
|
2
2
|
'use strict';
|
|
3
3
|
import { __extends, __awaiter, __generator } from '../_virtual/_tslib.js';
|
|
4
4
|
import { BaseClient } from './BaseClient.js';
|
|
@@ -209,6 +209,7 @@ var DeviceCodeClient = /** @class */ (function (_super) {
|
|
|
209
209
|
requestParameters.addCorrelationId(correlationId);
|
|
210
210
|
requestParameters.addClientInfo();
|
|
211
211
|
requestParameters.addLibraryInfo(this.config.libraryInfo);
|
|
212
|
+
requestParameters.addApplicationTelemetry(this.config.telemetry.application);
|
|
212
213
|
requestParameters.addThrottling();
|
|
213
214
|
if (this.serverTelemetryManager) {
|
|
214
215
|
requestParameters.addServerTelemetry(this.serverTelemetryManager);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeviceCodeClient.js","sources":["../../src/client/DeviceCodeClient.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { DeviceCodeResponse, ServerDeviceCodeResponse } from \"../response/DeviceCodeResponse\";\nimport { BaseClient } from \"./BaseClient\";\nimport { CommonDeviceCodeRequest } from \"../request/CommonDeviceCodeRequest\";\nimport { ClientAuthError } from \"../error/ClientAuthError\";\nimport { RequestParameterBuilder } from \"../request/RequestParameterBuilder\";\nimport { Constants, GrantType } from \"../utils/Constants\";\nimport { ClientConfiguration } from \"../config/ClientConfiguration\";\nimport { TimeUtils } from \"../utils/TimeUtils\";\nimport { ServerAuthorizationTokenResponse } from \"../response/ServerAuthorizationTokenResponse\";\nimport { ResponseHandler } from \"../response/ResponseHandler\";\nimport { AuthenticationResult } from \"../response/AuthenticationResult\";\nimport { StringUtils } from \"../utils/StringUtils\";\nimport { RequestThumbprint } from \"../network/RequestThumbprint\";\n\n/**\n * OAuth2.0 Device code client\n */\nexport class DeviceCodeClient extends BaseClient {\n\n constructor(configuration: ClientConfiguration) {\n super(configuration);\n }\n\n /**\n * Gets device code from device code endpoint, calls back to with device code response, and\n * polls token endpoint to exchange device code for tokens\n * @param request\n */\n public async acquireToken(request: CommonDeviceCodeRequest): Promise<AuthenticationResult | null> {\n const deviceCodeResponse: DeviceCodeResponse = await this.getDeviceCode(request);\n request.deviceCodeCallback(deviceCodeResponse);\n const reqTimestamp = TimeUtils.nowSeconds();\n const response: ServerAuthorizationTokenResponse = await this.acquireTokenWithDeviceCode(\n request,\n deviceCodeResponse);\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);\n return await responseHandler.handleServerTokenResponse(\n response,\n this.authority,\n reqTimestamp,\n request\n );\n }\n\n /**\n * Creates device code request and executes http GET\n * @param request\n */\n private async getDeviceCode(request: CommonDeviceCodeRequest): Promise<DeviceCodeResponse> {\n const queryString = this.createQueryString(request);\n const headers = this.createTokenRequestHeaders();\n const thumbprint: RequestThumbprint = {\n clientId: this.config.authOptions.clientId,\n authority: request.authority,\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\n return this.executePostRequestToDeviceCodeEndpoint(this.authority.deviceCodeEndpoint, queryString, headers, thumbprint);\n }\n\n /**\n * Executes POST request to device code endpoint\n * @param deviceCodeEndpoint\n * @param queryString\n * @param headers\n */\n private async executePostRequestToDeviceCodeEndpoint(\n deviceCodeEndpoint: string,\n queryString: string,\n headers: Record<string, string>,\n thumbprint: RequestThumbprint): Promise<DeviceCodeResponse> {\n\n const {\n body: {\n user_code: userCode,\n device_code: deviceCode,\n verification_uri: verificationUri,\n expires_in: expiresIn,\n interval,\n message\n }\n } = await this.networkManager.sendPostRequest<ServerDeviceCodeResponse>(\n thumbprint,\n deviceCodeEndpoint,\n {\n body: queryString,\n headers: headers,\n proxyUrl: this.config.systemOptions.proxyUrl\n });\n\n return {\n userCode,\n deviceCode,\n verificationUri,\n expiresIn,\n interval,\n message\n };\n }\n\n /**\n * Create device code endpoint query parameters and returns string\n */\n private createQueryString(request: CommonDeviceCodeRequest): string {\n\n const parameterBuilder: RequestParameterBuilder = new RequestParameterBuilder();\n\n parameterBuilder.addScopes(request.scopes);\n parameterBuilder.addClientId(this.config.authOptions.clientId);\n\n if (!StringUtils.isEmpty(request.claims) || this.config.authOptions.clientCapabilities && this.config.authOptions.clientCapabilities.length > 0) {\n parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);\n }\n\n return parameterBuilder.createQueryString();\n }\n\n /**\n * Breaks the polling with specific conditions.\n * @param request CommonDeviceCodeRequest\n * @param deviceCodeResponse DeviceCodeResponse\n */\n private continuePolling(\n deviceCodeExpirationTime: number,\n userSpecifiedTimeout?: number,\n userSpecifiedCancelFlag?: boolean,\n ): boolean {\n if (userSpecifiedCancelFlag) {\n this.logger.error(\"Token request cancelled by setting DeviceCodeRequest.cancel = true\");\n throw ClientAuthError.createDeviceCodeCancelledError();\n } else if (userSpecifiedTimeout && userSpecifiedTimeout < deviceCodeExpirationTime && TimeUtils.nowSeconds() > userSpecifiedTimeout) {\n this.logger.error(`User defined timeout for device code polling reached. The timeout was set for ${userSpecifiedTimeout}`);\n throw ClientAuthError.createUserTimeoutReachedError();\n } else if (TimeUtils.nowSeconds() > deviceCodeExpirationTime) {\n if (userSpecifiedTimeout) {\n this.logger.verbose(`User specified timeout ignored as the device code has expired before the timeout elapsed. The user specified timeout was set for ${userSpecifiedTimeout}`);\n }\n this.logger.error(`Device code expired. Expiration time of device code was ${deviceCodeExpirationTime}`);\n throw ClientAuthError.createDeviceCodeExpiredError();\n }\n return true;\n }\n\n /**\n * Creates token request with device code response and polls token endpoint at interval set by the device code\n * response\n * @param request\n * @param deviceCodeResponse\n */\n private async acquireTokenWithDeviceCode(\n request: CommonDeviceCodeRequest,\n deviceCodeResponse: DeviceCodeResponse): Promise<ServerAuthorizationTokenResponse> {\n\n const requestBody = this.createTokenRequestBody(request, deviceCodeResponse);\n const headers: Record<string, string> = this.createTokenRequestHeaders();\n\n const userSpecifiedTimeout = request.timeout ? TimeUtils.nowSeconds() + request.timeout : undefined;\n const deviceCodeExpirationTime = TimeUtils.nowSeconds() + deviceCodeResponse.expiresIn;\n const pollingIntervalMilli = deviceCodeResponse.interval * 1000;\n\n /*\n * Poll token endpoint while (device code is not expired AND operation has not been cancelled by\n * setting CancellationToken.cancel = true). POST request is sent at interval set by pollingIntervalMilli\n */\n while (this.continuePolling(deviceCodeExpirationTime, userSpecifiedTimeout, request.cancel)) {\n const thumbprint: RequestThumbprint = {\n clientId: this.config.authOptions.clientId,\n authority: request.authority,\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 response = await this.executePostToTokenEndpoint(\n this.authority.tokenEndpoint,\n requestBody,\n headers,\n thumbprint);\n\n if (response.body && response.body.error === Constants.AUTHORIZATION_PENDING) {\n // user authorization is pending. Sleep for polling interval and try again\n this.logger.info(response.body.error_description || \"Authorization pending. Continue polling.\");\n \n await TimeUtils.delay(pollingIntervalMilli);\n } else {\n this.logger.verbose(\"Authorization completed successfully. Polling stopped.\");\n return response.body;\n }\n }\n\n /*\n * The above code should've thrown by this point, but to satisfy TypeScript,\n * and in the rare case the conditionals in continuePolling() may not catch everything...\n */\n this.logger.error(\"Polling stopped for unknown reasons.\");\n throw ClientAuthError.createDeviceCodeUnknownError();\n }\n\n /**\n * Creates query parameters and converts to string.\n * @param request\n * @param deviceCodeResponse\n */\n private createTokenRequestBody(request: CommonDeviceCodeRequest, deviceCodeResponse: DeviceCodeResponse): string {\n\n const requestParameters: RequestParameterBuilder = new RequestParameterBuilder();\n\n requestParameters.addScopes(request.scopes);\n requestParameters.addClientId(this.config.authOptions.clientId);\n requestParameters.addGrantType(GrantType.DEVICE_CODE_GRANT);\n requestParameters.addDeviceCode(deviceCodeResponse.deviceCode);\n const correlationId = request.correlationId || this.config.cryptoInterface.createNewGuid();\n requestParameters.addCorrelationId(correlationId);\n requestParameters.addClientInfo();\n requestParameters.addLibraryInfo(this.config.libraryInfo);\n requestParameters.addThrottling();\n \n if (this.serverTelemetryManager) {\n requestParameters.addServerTelemetry(this.serverTelemetryManager);\n }\n\n if (!StringUtils.isEmptyObj(request.claims) || this.config.authOptions.clientCapabilities && this.config.authOptions.clientCapabilities.length > 0) {\n requestParameters.addClaims(request.claims, this.config.authOptions.clientCapabilities);\n }\n return requestParameters.createQueryString();\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAAA;;;;AAmBA;;;;IAGsC,oCAAU;IAE5C,0BAAY,aAAkC;eAC1C,kBAAM,aAAa,CAAC;KACvB;;;;;;IAOY,uCAAY,GAAzB,UAA0B,OAAgC;;;;;4BACP,qBAAM,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,EAAA;;wBAA1E,kBAAkB,GA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AsC,UAAU;;;;"}
|
|
1
|
+
{"version":3,"file":"DeviceCodeClient.js","sources":["../../src/client/DeviceCodeClient.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { DeviceCodeResponse, ServerDeviceCodeResponse } from \"../response/DeviceCodeResponse\";\nimport { BaseClient } from \"./BaseClient\";\nimport { CommonDeviceCodeRequest } from \"../request/CommonDeviceCodeRequest\";\nimport { ClientAuthError } from \"../error/ClientAuthError\";\nimport { RequestParameterBuilder } from \"../request/RequestParameterBuilder\";\nimport { Constants, GrantType } from \"../utils/Constants\";\nimport { ClientConfiguration } from \"../config/ClientConfiguration\";\nimport { TimeUtils } from \"../utils/TimeUtils\";\nimport { ServerAuthorizationTokenResponse } from \"../response/ServerAuthorizationTokenResponse\";\nimport { ResponseHandler } from \"../response/ResponseHandler\";\nimport { AuthenticationResult } from \"../response/AuthenticationResult\";\nimport { StringUtils } from \"../utils/StringUtils\";\nimport { RequestThumbprint } from \"../network/RequestThumbprint\";\n\n/**\n * OAuth2.0 Device code client\n */\nexport class DeviceCodeClient extends BaseClient {\n\n constructor(configuration: ClientConfiguration) {\n super(configuration);\n }\n\n /**\n * Gets device code from device code endpoint, calls back to with device code response, and\n * polls token endpoint to exchange device code for tokens\n * @param request\n */\n public async acquireToken(request: CommonDeviceCodeRequest): Promise<AuthenticationResult | null> {\n const deviceCodeResponse: DeviceCodeResponse = await this.getDeviceCode(request);\n request.deviceCodeCallback(deviceCodeResponse);\n const reqTimestamp = TimeUtils.nowSeconds();\n const response: ServerAuthorizationTokenResponse = await this.acquireTokenWithDeviceCode(\n request,\n deviceCodeResponse);\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);\n return await responseHandler.handleServerTokenResponse(\n response,\n this.authority,\n reqTimestamp,\n request\n );\n }\n\n /**\n * Creates device code request and executes http GET\n * @param request\n */\n private async getDeviceCode(request: CommonDeviceCodeRequest): Promise<DeviceCodeResponse> {\n const queryString = this.createQueryString(request);\n const headers = this.createTokenRequestHeaders();\n const thumbprint: RequestThumbprint = {\n clientId: this.config.authOptions.clientId,\n authority: request.authority,\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\n return this.executePostRequestToDeviceCodeEndpoint(this.authority.deviceCodeEndpoint, queryString, headers, thumbprint);\n }\n\n /**\n * Executes POST request to device code endpoint\n * @param deviceCodeEndpoint\n * @param queryString\n * @param headers\n */\n private async executePostRequestToDeviceCodeEndpoint(\n deviceCodeEndpoint: string,\n queryString: string,\n headers: Record<string, string>,\n thumbprint: RequestThumbprint): Promise<DeviceCodeResponse> {\n\n const {\n body: {\n user_code: userCode,\n device_code: deviceCode,\n verification_uri: verificationUri,\n expires_in: expiresIn,\n interval,\n message\n }\n } = await this.networkManager.sendPostRequest<ServerDeviceCodeResponse>(\n thumbprint,\n deviceCodeEndpoint,\n {\n body: queryString,\n headers: headers,\n proxyUrl: this.config.systemOptions.proxyUrl\n });\n\n return {\n userCode,\n deviceCode,\n verificationUri,\n expiresIn,\n interval,\n message\n };\n }\n\n /**\n * Create device code endpoint query parameters and returns string\n */\n private createQueryString(request: CommonDeviceCodeRequest): string {\n\n const parameterBuilder: RequestParameterBuilder = new RequestParameterBuilder();\n\n parameterBuilder.addScopes(request.scopes);\n parameterBuilder.addClientId(this.config.authOptions.clientId);\n\n if (!StringUtils.isEmpty(request.claims) || this.config.authOptions.clientCapabilities && this.config.authOptions.clientCapabilities.length > 0) {\n parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);\n }\n\n return parameterBuilder.createQueryString();\n }\n\n /**\n * Breaks the polling with specific conditions.\n * @param request CommonDeviceCodeRequest\n * @param deviceCodeResponse DeviceCodeResponse\n */\n private continuePolling(\n deviceCodeExpirationTime: number,\n userSpecifiedTimeout?: number,\n userSpecifiedCancelFlag?: boolean,\n ): boolean {\n if (userSpecifiedCancelFlag) {\n this.logger.error(\"Token request cancelled by setting DeviceCodeRequest.cancel = true\");\n throw ClientAuthError.createDeviceCodeCancelledError();\n } else if (userSpecifiedTimeout && userSpecifiedTimeout < deviceCodeExpirationTime && TimeUtils.nowSeconds() > userSpecifiedTimeout) {\n this.logger.error(`User defined timeout for device code polling reached. The timeout was set for ${userSpecifiedTimeout}`);\n throw ClientAuthError.createUserTimeoutReachedError();\n } else if (TimeUtils.nowSeconds() > deviceCodeExpirationTime) {\n if (userSpecifiedTimeout) {\n this.logger.verbose(`User specified timeout ignored as the device code has expired before the timeout elapsed. The user specified timeout was set for ${userSpecifiedTimeout}`);\n }\n this.logger.error(`Device code expired. Expiration time of device code was ${deviceCodeExpirationTime}`);\n throw ClientAuthError.createDeviceCodeExpiredError();\n }\n return true;\n }\n\n /**\n * Creates token request with device code response and polls token endpoint at interval set by the device code\n * response\n * @param request\n * @param deviceCodeResponse\n */\n private async acquireTokenWithDeviceCode(\n request: CommonDeviceCodeRequest,\n deviceCodeResponse: DeviceCodeResponse): Promise<ServerAuthorizationTokenResponse> {\n\n const requestBody = this.createTokenRequestBody(request, deviceCodeResponse);\n const headers: Record<string, string> = this.createTokenRequestHeaders();\n\n const userSpecifiedTimeout = request.timeout ? TimeUtils.nowSeconds() + request.timeout : undefined;\n const deviceCodeExpirationTime = TimeUtils.nowSeconds() + deviceCodeResponse.expiresIn;\n const pollingIntervalMilli = deviceCodeResponse.interval * 1000;\n\n /*\n * Poll token endpoint while (device code is not expired AND operation has not been cancelled by\n * setting CancellationToken.cancel = true). POST request is sent at interval set by pollingIntervalMilli\n */\n while (this.continuePolling(deviceCodeExpirationTime, userSpecifiedTimeout, request.cancel)) {\n const thumbprint: RequestThumbprint = {\n clientId: this.config.authOptions.clientId,\n authority: request.authority,\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 response = await this.executePostToTokenEndpoint(\n this.authority.tokenEndpoint,\n requestBody,\n headers,\n thumbprint);\n\n if (response.body && response.body.error === Constants.AUTHORIZATION_PENDING) {\n // user authorization is pending. Sleep for polling interval and try again\n this.logger.info(response.body.error_description || \"Authorization pending. Continue polling.\");\n \n await TimeUtils.delay(pollingIntervalMilli);\n } else {\n this.logger.verbose(\"Authorization completed successfully. Polling stopped.\");\n return response.body;\n }\n }\n\n /*\n * The above code should've thrown by this point, but to satisfy TypeScript,\n * and in the rare case the conditionals in continuePolling() may not catch everything...\n */\n this.logger.error(\"Polling stopped for unknown reasons.\");\n throw ClientAuthError.createDeviceCodeUnknownError();\n }\n\n /**\n * Creates query parameters and converts to string.\n * @param request\n * @param deviceCodeResponse\n */\n private createTokenRequestBody(request: CommonDeviceCodeRequest, deviceCodeResponse: DeviceCodeResponse): string {\n\n const requestParameters: RequestParameterBuilder = new RequestParameterBuilder();\n\n requestParameters.addScopes(request.scopes);\n requestParameters.addClientId(this.config.authOptions.clientId);\n requestParameters.addGrantType(GrantType.DEVICE_CODE_GRANT);\n requestParameters.addDeviceCode(deviceCodeResponse.deviceCode);\n const correlationId = request.correlationId || this.config.cryptoInterface.createNewGuid();\n requestParameters.addCorrelationId(correlationId);\n requestParameters.addClientInfo();\n requestParameters.addLibraryInfo(this.config.libraryInfo);\n requestParameters.addApplicationTelemetry(this.config.telemetry.application);\n requestParameters.addThrottling();\n \n if (this.serverTelemetryManager) {\n requestParameters.addServerTelemetry(this.serverTelemetryManager);\n }\n\n if (!StringUtils.isEmptyObj(request.claims) || this.config.authOptions.clientCapabilities && this.config.authOptions.clientCapabilities.length > 0) {\n requestParameters.addClaims(request.claims, this.config.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W,CAAC,UAAU,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,kBAAkB,IAAI,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,kBAAkB,CAAC,MAAM,GAAG,CAAC,EAAE;YAChJ,iBAAiB,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAC;SAC3F;QACD,OAAO,iBAAiB,CAAC,iBAAiB,EAAE,CAAC;KAChD;IACL,uBAAC;AAAD,CAtOA,CAAsC,UAAU;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @azure/msal-common v6.
|
|
1
|
+
/*! @azure/msal-common v6.3.0 2022-05-02 */
|
|
2
2
|
'use strict';
|
|
3
3
|
import { __extends, __awaiter, __generator } from '../_virtual/_tslib.js';
|
|
4
4
|
import { BaseClient } from './BaseClient.js';
|
|
@@ -75,7 +75,7 @@ var OnBehalfOfClient = /** @class */ (function (_super) {
|
|
|
75
75
|
environment: cachedIdToken.environment,
|
|
76
76
|
tenantId: cachedIdToken.realm,
|
|
77
77
|
username: Constants.EMPTY_STRING,
|
|
78
|
-
localAccountId: localAccountId ||
|
|
78
|
+
localAccountId: localAccountId || Constants.EMPTY_STRING
|
|
79
79
|
};
|
|
80
80
|
cachedAccount = this.readAccountFromCache(accountInfo);
|
|
81
81
|
}
|
|
@@ -190,6 +190,7 @@ var OnBehalfOfClient = /** @class */ (function (_super) {
|
|
|
190
190
|
parameterBuilder.addGrantType(GrantType.JWT_BEARER);
|
|
191
191
|
parameterBuilder.addClientInfo();
|
|
192
192
|
parameterBuilder.addLibraryInfo(this.config.libraryInfo);
|
|
193
|
+
parameterBuilder.addApplicationTelemetry(this.config.telemetry.application);
|
|
193
194
|
parameterBuilder.addThrottling();
|
|
194
195
|
if (this.serverTelemetryManager) {
|
|
195
196
|
parameterBuilder.addServerTelemetry(this.serverTelemetryManager);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OnBehalfOfClient.js","sources":["../../src/client/OnBehalfOfClient.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ClientConfiguration } from \"../config/ClientConfiguration\";\nimport { BaseClient } from \"./BaseClient\";\nimport { Authority } from \"../authority/Authority\";\nimport { RequestParameterBuilder } from \"../request/RequestParameterBuilder\";\nimport { ScopeSet } from \"../request/ScopeSet\";\nimport { GrantType, AADServerParamKeys , CredentialType, Constants, CacheOutcome } from \"../utils/Constants\";\nimport { ResponseHandler } from \"../response/ResponseHandler\";\nimport { AuthenticationResult } from \"../response/AuthenticationResult\";\nimport { CommonOnBehalfOfRequest } from \"../request/CommonOnBehalfOfRequest\";\nimport { TimeUtils } from \"../utils/TimeUtils\";\nimport { CredentialFilter, CredentialCache } from \"../cache/utils/CacheTypes\";\nimport { AccessTokenEntity } from \"../cache/entities/AccessTokenEntity\";\nimport { IdTokenEntity } from \"../cache/entities/IdTokenEntity\";\nimport { AccountEntity } from \"../cache/entities/AccountEntity\";\nimport { AuthToken } from \"../account/AuthToken\";\nimport { ClientAuthError } from \"../error/ClientAuthError\";\nimport { RequestThumbprint } from \"../network/RequestThumbprint\";\nimport { AccountInfo } from \"../account/AccountInfo\";\n\n/**\n * On-Behalf-Of client\n */\nexport class OnBehalfOfClient extends BaseClient {\n\n private scopeSet: ScopeSet;\n\n constructor(configuration: ClientConfiguration) {\n super(configuration);\n }\n\n /**\n * Public API to acquire tokens with on behalf of flow\n * @param request\n */\n public async acquireToken(request: CommonOnBehalfOfRequest): Promise<AuthenticationResult | null> {\n this.scopeSet = new ScopeSet(request.scopes || []);\n\n if (request.skipCache) {\n return await this.executeTokenRequest(request, this.authority);\n }\n\n const cachedAuthenticationResult = await this.getCachedAuthenticationResult(request);\n if (cachedAuthenticationResult) {\n return cachedAuthenticationResult;\n } else {\n return await this.executeTokenRequest(request, this.authority);\n }\n }\n\n /**\n * look up cache for tokens\n * @param request\n */\n private async getCachedAuthenticationResult(request: CommonOnBehalfOfRequest): Promise<AuthenticationResult | null> {\n const cachedAccessToken = this.readAccessTokenFromCache();\n if (!cachedAccessToken ||\n TimeUtils.isTokenExpired(cachedAccessToken.expiresOn, this.config.systemOptions.tokenRenewalOffsetSeconds)) {\n\n // Update the server telemetry outcome\n this.serverTelemetryManager?.setCacheOutcome(!cachedAccessToken ? CacheOutcome.CACHED_ACCESS_TOKEN_EXPIRED : CacheOutcome.NO_CACHED_ACCESS_TOKEN);\n\n return null;\n }\n\n const cachedIdToken = this.readIdTokenFromCache(request);\n let idTokenObject: AuthToken | undefined;\n let cachedAccount: AccountEntity | null = null;\n if (cachedIdToken) {\n idTokenObject = new AuthToken(cachedIdToken.secret, this.config.cryptoInterface);\n const localAccountId = idTokenObject.claims.oid ? idTokenObject.claims.oid : idTokenObject.claims.sub;\n const accountInfo: AccountInfo = {\n homeAccountId: cachedIdToken.homeAccountId,\n environment: cachedIdToken.environment,\n tenantId: cachedIdToken.realm,\n username: Constants.EMPTY_STRING,\n localAccountId: localAccountId || \"\"\n };\n\n cachedAccount = this.readAccountFromCache(accountInfo);\n }\n\n return await ResponseHandler.generateAuthenticationResult(\n this.cryptoUtils,\n this.authority,\n {\n account: cachedAccount,\n accessToken: cachedAccessToken,\n idToken: cachedIdToken,\n refreshToken: null,\n appMetadata: null\n },\n true,\n request,\n idTokenObject);\n }\n\n /**\n * read access token from cache TODO: CacheManager API should be used here\n * @param request\n */\n private readAccessTokenFromCache(): AccessTokenEntity | null {\n const accessTokenFilter: CredentialFilter = {\n environment: this.authority.canonicalAuthorityUrlComponents.HostNameAndPort,\n credentialType: CredentialType.ACCESS_TOKEN,\n clientId: this.config.authOptions.clientId,\n realm: this.authority.tenant,\n target: this.scopeSet.printScopesLowerCase(),\n };\n\n const credentialCache: CredentialCache = this.cacheManager.getCredentialsFilteredBy(accessTokenFilter);\n const accessTokens = Object.keys(credentialCache.accessTokens).map(key => credentialCache.accessTokens[key]);\n\n const numAccessTokens = accessTokens.length;\n if (numAccessTokens < 1) {\n return null;\n } else if (numAccessTokens > 1) {\n throw ClientAuthError.createMultipleMatchingTokensInCacheError();\n }\n return accessTokens[0] as AccessTokenEntity;\n }\n\n /**\n * read idtoken from cache TODO: CacheManager API should be used here instead\n * @param request\n */\n private readIdTokenFromCache(request: CommonOnBehalfOfRequest): IdTokenEntity | null {\n const idTokenFilter: CredentialFilter = {\n environment: this.authority.canonicalAuthorityUrlComponents.HostNameAndPort,\n credentialType: CredentialType.ID_TOKEN,\n clientId: this.config.authOptions.clientId,\n realm: this.authority.tenant,\n oboAssertion: request.oboAssertion\n };\n\n const credentialCache: CredentialCache = this.cacheManager.getCredentialsFilteredBy(idTokenFilter);\n const idTokens = Object.keys(credentialCache.idTokens).map(key => credentialCache.idTokens[key]);\n // When acquiring a token on behalf of an application, there might not be an id token in the cache\n if (idTokens.length < 1) {\n return null;\n }\n return idTokens[0] as IdTokenEntity;\n }\n\n /**\n * read account from cache, TODO: CacheManager API should be used here instead\n * @param account\n */\n private readAccountFromCache(account: AccountInfo): AccountEntity | null {\n return this.cacheManager.readAccountFromCache(account);\n }\n\n /**\n * Make a network call to the server requesting credentials\n * @param request\n * @param authority\n */\n private async executeTokenRequest(request: CommonOnBehalfOfRequest, authority: Authority)\n : Promise<AuthenticationResult | null> {\n\n const requestBody = this.createTokenRequestBody(request);\n const headers: Record<string, string> = this.createTokenRequestHeaders();\n const thumbprint: RequestThumbprint = {\n clientId: this.config.authOptions.clientId,\n authority: request.authority,\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\n const reqTimestamp = TimeUtils.nowSeconds();\n const response = await this.executePostToTokenEndpoint(authority.tokenEndpoint, requestBody, headers, thumbprint);\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 responseHandler.validateTokenResponse(response.body);\n const tokenResponse = await responseHandler.handleServerTokenResponse(\n response.body,\n this.authority,\n reqTimestamp,\n request\n );\n\n return tokenResponse;\n }\n\n /**\n * generate a server request in accepable format\n * @param request\n */\n private createTokenRequestBody(request: CommonOnBehalfOfRequest): string {\n const parameterBuilder = new RequestParameterBuilder();\n\n parameterBuilder.addClientId(this.config.authOptions.clientId);\n\n parameterBuilder.addScopes(request.scopes);\n\n parameterBuilder.addGrantType(GrantType.JWT_BEARER);\n\n parameterBuilder.addClientInfo();\n\n parameterBuilder.addLibraryInfo(this.config.libraryInfo);\n\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 parameterBuilder.addRequestTokenUse(AADServerParamKeys.ON_BEHALF_OF);\n\n parameterBuilder.addOboAssertion(request.oboAssertion);\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 return parameterBuilder.createQueryString();\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;AAwBA;;;;IAGsC,oCAAU;IAI5C,0BAAY,aAAkC;eAC1C,kBAAM,aAAa,CAAC;KACvB;;;;;IAMY,uCAAY,GAAzB,UAA0B,OAAgC;;;;;;wBACtD,IAAI,CAAC,QAAQ,GAAG,IAAI,QAAQ,CAAC,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC;6BAE/C,OAAO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fClient.js","sources":["../../src/client/OnBehalfOfClient.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ClientConfiguration } from \"../config/ClientConfiguration\";\nimport { BaseClient } from \"./BaseClient\";\nimport { Authority } from \"../authority/Authority\";\nimport { RequestParameterBuilder } from \"../request/RequestParameterBuilder\";\nimport { ScopeSet } from \"../request/ScopeSet\";\nimport { GrantType, AADServerParamKeys , CredentialType, Constants, CacheOutcome } from \"../utils/Constants\";\nimport { ResponseHandler } from \"../response/ResponseHandler\";\nimport { AuthenticationResult } from \"../response/AuthenticationResult\";\nimport { CommonOnBehalfOfRequest } from \"../request/CommonOnBehalfOfRequest\";\nimport { TimeUtils } from \"../utils/TimeUtils\";\nimport { CredentialFilter, CredentialCache } from \"../cache/utils/CacheTypes\";\nimport { AccessTokenEntity } from \"../cache/entities/AccessTokenEntity\";\nimport { IdTokenEntity } from \"../cache/entities/IdTokenEntity\";\nimport { AccountEntity } from \"../cache/entities/AccountEntity\";\nimport { AuthToken } from \"../account/AuthToken\";\nimport { ClientAuthError } from \"../error/ClientAuthError\";\nimport { RequestThumbprint } from \"../network/RequestThumbprint\";\nimport { AccountInfo } from \"../account/AccountInfo\";\n\n/**\n * On-Behalf-Of client\n */\nexport class OnBehalfOfClient extends BaseClient {\n\n private scopeSet: ScopeSet;\n\n constructor(configuration: ClientConfiguration) {\n super(configuration);\n }\n\n /**\n * Public API to acquire tokens with on behalf of flow\n * @param request\n */\n public async acquireToken(request: CommonOnBehalfOfRequest): Promise<AuthenticationResult | null> {\n this.scopeSet = new ScopeSet(request.scopes || []);\n\n if (request.skipCache) {\n return await this.executeTokenRequest(request, this.authority);\n }\n\n const cachedAuthenticationResult = await this.getCachedAuthenticationResult(request);\n if (cachedAuthenticationResult) {\n return cachedAuthenticationResult;\n } else {\n return await this.executeTokenRequest(request, this.authority);\n }\n }\n\n /**\n * look up cache for tokens\n * @param request\n */\n private async getCachedAuthenticationResult(request: CommonOnBehalfOfRequest): Promise<AuthenticationResult | null> {\n const cachedAccessToken = this.readAccessTokenFromCache();\n if (!cachedAccessToken ||\n TimeUtils.isTokenExpired(cachedAccessToken.expiresOn, this.config.systemOptions.tokenRenewalOffsetSeconds)) {\n\n // Update the server telemetry outcome\n this.serverTelemetryManager?.setCacheOutcome(!cachedAccessToken ? CacheOutcome.CACHED_ACCESS_TOKEN_EXPIRED : CacheOutcome.NO_CACHED_ACCESS_TOKEN);\n\n return null;\n }\n\n const cachedIdToken = this.readIdTokenFromCache(request);\n let idTokenObject: AuthToken | undefined;\n let cachedAccount: AccountEntity | null = null;\n if (cachedIdToken) {\n idTokenObject = new AuthToken(cachedIdToken.secret, this.config.cryptoInterface);\n const localAccountId = idTokenObject.claims.oid ? idTokenObject.claims.oid : idTokenObject.claims.sub;\n const accountInfo: AccountInfo = {\n homeAccountId: cachedIdToken.homeAccountId,\n environment: cachedIdToken.environment,\n tenantId: cachedIdToken.realm,\n username: Constants.EMPTY_STRING,\n localAccountId: localAccountId || Constants.EMPTY_STRING\n };\n\n cachedAccount = this.readAccountFromCache(accountInfo);\n }\n\n return await ResponseHandler.generateAuthenticationResult(\n this.cryptoUtils,\n this.authority,\n {\n account: cachedAccount,\n accessToken: cachedAccessToken,\n idToken: cachedIdToken,\n refreshToken: null,\n appMetadata: null\n },\n true,\n request,\n idTokenObject);\n }\n\n /**\n * read access token from cache TODO: CacheManager API should be used here\n * @param request\n */\n private readAccessTokenFromCache(): AccessTokenEntity | null {\n const accessTokenFilter: CredentialFilter = {\n environment: this.authority.canonicalAuthorityUrlComponents.HostNameAndPort,\n credentialType: CredentialType.ACCESS_TOKEN,\n clientId: this.config.authOptions.clientId,\n realm: this.authority.tenant,\n target: this.scopeSet.printScopesLowerCase(),\n };\n\n const credentialCache: CredentialCache = this.cacheManager.getCredentialsFilteredBy(accessTokenFilter);\n const accessTokens = Object.keys(credentialCache.accessTokens).map(key => credentialCache.accessTokens[key]);\n\n const numAccessTokens = accessTokens.length;\n if (numAccessTokens < 1) {\n return null;\n } else if (numAccessTokens > 1) {\n throw ClientAuthError.createMultipleMatchingTokensInCacheError();\n }\n return accessTokens[0] as AccessTokenEntity;\n }\n\n /**\n * read idtoken from cache TODO: CacheManager API should be used here instead\n * @param request\n */\n private readIdTokenFromCache(request: CommonOnBehalfOfRequest): IdTokenEntity | null {\n const idTokenFilter: CredentialFilter = {\n environment: this.authority.canonicalAuthorityUrlComponents.HostNameAndPort,\n credentialType: CredentialType.ID_TOKEN,\n clientId: this.config.authOptions.clientId,\n realm: this.authority.tenant,\n oboAssertion: request.oboAssertion\n };\n\n const credentialCache: CredentialCache = this.cacheManager.getCredentialsFilteredBy(idTokenFilter);\n const idTokens = Object.keys(credentialCache.idTokens).map(key => credentialCache.idTokens[key]);\n // When acquiring a token on behalf of an application, there might not be an id token in the cache\n if (idTokens.length < 1) {\n return null;\n }\n return idTokens[0] as IdTokenEntity;\n }\n\n /**\n * read account from cache, TODO: CacheManager API should be used here instead\n * @param account\n */\n private readAccountFromCache(account: AccountInfo): AccountEntity | null {\n return this.cacheManager.readAccountFromCache(account);\n }\n\n /**\n * Make a network call to the server requesting credentials\n * @param request\n * @param authority\n */\n private async executeTokenRequest(request: CommonOnBehalfOfRequest, authority: Authority)\n : Promise<AuthenticationResult | null> {\n\n const requestBody = this.createTokenRequestBody(request);\n const headers: Record<string, string> = this.createTokenRequestHeaders();\n const thumbprint: RequestThumbprint = {\n clientId: this.config.authOptions.clientId,\n authority: request.authority,\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\n const reqTimestamp = TimeUtils.nowSeconds();\n const response = await this.executePostToTokenEndpoint(authority.tokenEndpoint, requestBody, headers, thumbprint);\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 responseHandler.validateTokenResponse(response.body);\n const tokenResponse = await responseHandler.handleServerTokenResponse(\n response.body,\n this.authority,\n reqTimestamp,\n request\n );\n\n return tokenResponse;\n }\n\n /**\n * generate a server request in accepable format\n * @param request\n */\n private createTokenRequestBody(request: CommonOnBehalfOfRequest): string {\n const parameterBuilder = new RequestParameterBuilder();\n\n parameterBuilder.addClientId(this.config.authOptions.clientId);\n\n parameterBuilder.addScopes(request.scopes);\n\n parameterBuilder.addGrantType(GrantType.JWT_BEARER);\n\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 parameterBuilder.addRequestTokenUse(AADServerParamKeys.ON_BEHALF_OF);\n\n parameterBuilder.addOboAssertion(request.oboAssertion);\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 return parameterBuilder.createQueryString();\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;AAwBA;;;;IAGsC,oCAAU;IAI5C,0BAAY,aAAkC;eAC1C,kBAAM,aAAa,CAAC;KACvB;;;;;IAMY,uCAAY,GAAzB,UAA0B,OAAgC;;;;;;wBACtD,IAAI,CAAC,QAAQ,GAAG,IAAI,QAAQ,CAAC,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC;6BAE/C,OAAO,CAAC,SAAS,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AC;KAC/C;IACL,uBAAC;AAAD,CAxNA,CAAsC,UAAU;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @azure/msal-common v6.
|
|
1
|
+
/*! @azure/msal-common v6.3.0 2022-05-02 */
|
|
2
2
|
'use strict';
|
|
3
3
|
import { __extends, __awaiter, __generator, __assign } from '../_virtual/_tslib.js';
|
|
4
4
|
import { BaseClient } from './BaseClient.js';
|
|
@@ -165,6 +165,7 @@ var RefreshTokenClient = /** @class */ (function (_super) {
|
|
|
165
165
|
parameterBuilder.addGrantType(GrantType.REFRESH_TOKEN_GRANT);
|
|
166
166
|
parameterBuilder.addClientInfo();
|
|
167
167
|
parameterBuilder.addLibraryInfo(this.config.libraryInfo);
|
|
168
|
+
parameterBuilder.addApplicationTelemetry(this.config.telemetry.application);
|
|
168
169
|
parameterBuilder.addThrottling();
|
|
169
170
|
if (this.serverTelemetryManager) {
|
|
170
171
|
parameterBuilder.addServerTelemetry(this.serverTelemetryManager);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RefreshTokenClient.js","sources":["../../src/client/RefreshTokenClient.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ClientConfiguration } from \"../config/ClientConfiguration\";\nimport { BaseClient } from \"./BaseClient\";\nimport { CommonRefreshTokenRequest } from \"../request/CommonRefreshTokenRequest\";\nimport { Authority } from \"../authority/Authority\";\nimport { ServerAuthorizationTokenResponse } from \"../response/ServerAuthorizationTokenResponse\";\nimport { RequestParameterBuilder } from \"../request/RequestParameterBuilder\";\nimport { GrantType, AuthenticationScheme, Errors } from \"../utils/Constants\";\nimport { ResponseHandler } from \"../response/ResponseHandler\";\nimport { AuthenticationResult } from \"../response/AuthenticationResult\";\nimport { PopTokenGenerator } from \"../crypto/PopTokenGenerator\";\nimport { StringUtils } from \"../utils/StringUtils\";\nimport { RequestThumbprint } from \"../network/RequestThumbprint\";\nimport { NetworkResponse } from \"../network/NetworkManager\";\nimport { CommonSilentFlowRequest } from \"../request/CommonSilentFlowRequest\";\nimport { ClientConfigurationError } from \"../error/ClientConfigurationError\";\nimport { ClientAuthError } from \"../error/ClientAuthError\";\nimport { ServerError } from \"../error/ServerError\";\nimport { TimeUtils } from \"../utils/TimeUtils\";\nimport { UrlString } from \"../url/UrlString\";\nimport { CcsCredentialType } from \"../account/CcsCredential\";\nimport { buildClientInfoFromHomeAccountId } from \"../account/ClientInfo\";\nimport { InteractionRequiredAuthError, InteractionRequiredAuthErrorMessage } from \"../error/InteractionRequiredAuthError\";\n\n/**\n * OAuth2.0 refresh token client\n */\nexport class RefreshTokenClient extends BaseClient {\n\n constructor(configuration: ClientConfiguration) {\n super(configuration);\n }\n\n public async acquireToken(request: CommonRefreshTokenRequest): Promise<AuthenticationResult>{\n const reqTimestamp = TimeUtils.nowSeconds();\n const response = await this.executeTokenRequest(request, this.authority);\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 responseHandler.validateTokenResponse(response.body);\n return responseHandler.handleServerTokenResponse(\n response.body,\n this.authority,\n reqTimestamp,\n request,\n undefined,\n undefined,\n true\n );\n }\n\n /**\n * Gets cached refresh token and attaches to request, then calls acquireToken API\n * @param request\n */\n public async acquireTokenByRefreshToken(request: CommonSilentFlowRequest): Promise<AuthenticationResult> {\n // Cannot renew token if no request object is given.\n if (!request) {\n throw ClientConfigurationError.createEmptyTokenRequestError();\n }\n\n // We currently do not support silent flow for account === null use cases; This will be revisited for confidential flow usecases\n if (!request.account) {\n throw ClientAuthError.createNoAccountInSilentRequestError();\n }\n\n // try checking if FOCI is enabled for the given application\n const isFOCI = this.cacheManager.isAppMetadataFOCI(request.account.environment, this.config.authOptions.clientId);\n\n // if the app is part of the family, retrive a Family refresh token if present and make a refreshTokenRequest\n if (isFOCI) {\n try {\n return this.acquireTokenWithCachedRefreshToken(request, true);\n } catch (e) {\n const noFamilyRTInCache = e instanceof InteractionRequiredAuthError && e.errorCode === InteractionRequiredAuthErrorMessage.noTokensFoundError.code;\n const clientMismatchErrorWithFamilyRT = e instanceof ServerError && e.errorCode === Errors.INVALID_GRANT_ERROR && e.subError === Errors.CLIENT_MISMATCH_ERROR;\n\n // if family Refresh Token (FRT) cache acquisition fails or if client_mismatch error is seen with FRT, reattempt with application Refresh Token (ART)\n if (noFamilyRTInCache || clientMismatchErrorWithFamilyRT) {\n return this.acquireTokenWithCachedRefreshToken(request, false);\n // throw in all other cases\n } else {\n throw e;\n }\n }\n }\n\n // fall back to application refresh token acquisition\n return this.acquireTokenWithCachedRefreshToken(request, false);\n }\n\n /**\n * makes a network call to acquire tokens by exchanging RefreshToken available in userCache; throws if refresh token is not cached\n * @param request\n */\n private async acquireTokenWithCachedRefreshToken(request: CommonSilentFlowRequest, foci: boolean) {\n // fetches family RT or application RT based on FOCI value\n const refreshToken = this.cacheManager.readRefreshTokenFromCache(this.config.authOptions.clientId, request.account, foci);\n\n // no refresh Token\n if (!refreshToken) {\n throw InteractionRequiredAuthError.createNoTokensFoundError();\n }\n\n const refreshTokenRequest: CommonRefreshTokenRequest = {\n ...request,\n refreshToken: refreshToken.secret,\n authenticationScheme: request.authenticationScheme || AuthenticationScheme.BEARER,\n ccsCredential: {\n credential: request.account.homeAccountId,\n type: CcsCredentialType.HOME_ACCOUNT_ID\n }\n };\n\n return this.acquireToken(refreshTokenRequest);\n }\n\n /**\n * Constructs the network message and makes a NW call to the underlying secure token service\n * @param request\n * @param authority\n */\n private async executeTokenRequest(request: CommonRefreshTokenRequest, authority: Authority)\n : Promise<NetworkResponse<ServerAuthorizationTokenResponse>> {\n\n const requestBody = await this.createTokenRequestBody(request);\n const queryParameters = this.createTokenQueryParameters(request);\n const headers: Record<string, string> = this.createTokenRequestHeaders(request.ccsCredential);\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\n const endpoint = UrlString.appendQueryString(authority.tokenEndpoint, queryParameters);\n return this.executePostToTokenEndpoint(endpoint, requestBody, headers, thumbprint);\n }\n\n /**\n * Creates query string for the /token request\n * @param request \n */\n private createTokenQueryParameters(request: CommonRefreshTokenRequest): string {\n const parameterBuilder = new RequestParameterBuilder();\n\n if (request.tokenQueryParameters) {\n parameterBuilder.addExtraQueryParameters(request.tokenQueryParameters);\n }\n\n return parameterBuilder.createQueryString();\n }\n\n /**\n * Helper function to create the token request body\n * @param request\n */\n private async createTokenRequestBody(request: CommonRefreshTokenRequest): Promise<string> {\n const parameterBuilder = new RequestParameterBuilder();\n\n parameterBuilder.addClientId(this.config.authOptions.clientId);\n\n parameterBuilder.addScopes(request.scopes);\n\n parameterBuilder.addGrantType(GrantType.REFRESH_TOKEN_GRANT);\n\n parameterBuilder.addClientInfo();\n\n parameterBuilder.addLibraryInfo(this.config.libraryInfo);\n\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 parameterBuilder.addRefreshToken(request.refreshToken);\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 (request.authenticationScheme === AuthenticationScheme.POP) {\n const popTokenGenerator = new PopTokenGenerator(this.cryptoUtils);\n const cnfString = await popTokenGenerator.generateCnf(request);\n parameterBuilder.addPopToken(cnfString);\n } else if (request.authenticationScheme === AuthenticationScheme.SSH) {\n if(request.sshJwk) {\n parameterBuilder.addSshJwk(request.sshJwk);\n } else {\n throw ClientConfigurationError.createMissingSshJwkError();\n }\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.ccsCredential) {\n switch (request.ccsCredential.type) {\n case CcsCredentialType.HOME_ACCOUNT_ID:\n try {\n const clientInfo = buildClientInfoFromHomeAccountId(request.ccsCredential.credential);\n parameterBuilder.addCcsOid(clientInfo);\n } catch (e) {\n this.logger.verbose(\"Could not parse home account ID for CCS Header: \" + e);\n }\n break;\n case CcsCredentialType.UPN:\n parameterBuilder.addCcsUpn(request.ccsCredential.credential);\n break;\n }\n }\n\n return parameterBuilder.createQueryString();\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;AA4BA;;;;IAGwC,sCAAU;IAE9C,4BAAY,aAAkC;eAC1C,kBAAM,aAAa,CAAC;KACvB;IAEY,yCAAY,GAAzB,UAA0B,OAAkC;;;;;;wBAClD,YAAY,GAAG,SAAS,CAAC,UAAU,EAAE,CAAC;wBAC3B,qBAAM,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,EAAA;;wBAAlE,QAAQ,GAAG,SAAuD;wBAElE,eAAe,GAAG,IAAI,eAAe,CACvC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,QAAQ,EAChC,IAAI,CAAC,YAAY,EACjB,IAAI,CAAC,WAAW,EAChB,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,MAAM,CAAC,iBAAiB,EAC7B,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAChC,CAAC;wBAEF,eAAe,CAAC,qBAAqB,CAAC,QAAQ,CAAC,I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CAAC,WAAW,CAAC,kBAAkB,CAAC,MAAM,GAAG,CAAC,EAAE;4BAChJ,gBAAgB,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAC;yBAC1F;wBAED,IAAI,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,oBAAoB,IAAI,OAAO,CAAC,aAAa,EAAE;4BACzE,QAAQ,OAAO,CAAC,aAAa,CAAC,IAAI;gCAC9B,KAAK,iBAAiB,CAAC,eAAe;oCAClC,IAAI;wCACM,UAAU,GAAG,gCAAgC,CAAC,OAAO,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;wCACtF,gBAAgB,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;qCAC1C;oCAAC,OAAO,CAAC,EAAE;wCACR,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,kDAAkD,GAAG,CAAC,CAAC,CAAC;qCAC/E;oCACD,MAAM;gCACV,KAAK,iBAAiB,CAAC,GAAG;oCACtB,gBAAgB,CAAC,SAAS,CAAC,OAAO,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;oCAC7D,MAAM;6BACb;yBACJ;wBAED,sBAAO,gBAAgB,CAAC,iBAAiB,EAAE,EAAC;;;;KAC/C;IACL,yBAAC;AAAD,CAlNA,CAAwC,UAAU;;;;"}
|
|
1
|
+
{"version":3,"file":"RefreshTokenClient.js","sources":["../../src/client/RefreshTokenClient.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ClientConfiguration } from \"../config/ClientConfiguration\";\nimport { BaseClient } from \"./BaseClient\";\nimport { CommonRefreshTokenRequest } from \"../request/CommonRefreshTokenRequest\";\nimport { Authority } from \"../authority/Authority\";\nimport { ServerAuthorizationTokenResponse } from \"../response/ServerAuthorizationTokenResponse\";\nimport { RequestParameterBuilder } from \"../request/RequestParameterBuilder\";\nimport { GrantType, AuthenticationScheme, Errors } from \"../utils/Constants\";\nimport { ResponseHandler } from \"../response/ResponseHandler\";\nimport { AuthenticationResult } from \"../response/AuthenticationResult\";\nimport { PopTokenGenerator } from \"../crypto/PopTokenGenerator\";\nimport { StringUtils } from \"../utils/StringUtils\";\nimport { RequestThumbprint } from \"../network/RequestThumbprint\";\nimport { NetworkResponse } from \"../network/NetworkManager\";\nimport { CommonSilentFlowRequest } from \"../request/CommonSilentFlowRequest\";\nimport { ClientConfigurationError } from \"../error/ClientConfigurationError\";\nimport { ClientAuthError } from \"../error/ClientAuthError\";\nimport { ServerError } from \"../error/ServerError\";\nimport { TimeUtils } from \"../utils/TimeUtils\";\nimport { UrlString } from \"../url/UrlString\";\nimport { CcsCredentialType } from \"../account/CcsCredential\";\nimport { buildClientInfoFromHomeAccountId } from \"../account/ClientInfo\";\nimport { InteractionRequiredAuthError, InteractionRequiredAuthErrorMessage } from \"../error/InteractionRequiredAuthError\";\n\n/**\n * OAuth2.0 refresh token client\n */\nexport class RefreshTokenClient extends BaseClient {\n\n constructor(configuration: ClientConfiguration) {\n super(configuration);\n }\n\n public async acquireToken(request: CommonRefreshTokenRequest): Promise<AuthenticationResult>{\n const reqTimestamp = TimeUtils.nowSeconds();\n const response = await this.executeTokenRequest(request, this.authority);\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 responseHandler.validateTokenResponse(response.body);\n return responseHandler.handleServerTokenResponse(\n response.body,\n this.authority,\n reqTimestamp,\n request,\n undefined,\n undefined,\n true\n );\n }\n\n /**\n * Gets cached refresh token and attaches to request, then calls acquireToken API\n * @param request\n */\n public async acquireTokenByRefreshToken(request: CommonSilentFlowRequest): Promise<AuthenticationResult> {\n // Cannot renew token if no request object is given.\n if (!request) {\n throw ClientConfigurationError.createEmptyTokenRequestError();\n }\n\n // We currently do not support silent flow for account === null use cases; This will be revisited for confidential flow usecases\n if (!request.account) {\n throw ClientAuthError.createNoAccountInSilentRequestError();\n }\n\n // try checking if FOCI is enabled for the given application\n const isFOCI = this.cacheManager.isAppMetadataFOCI(request.account.environment, this.config.authOptions.clientId);\n\n // if the app is part of the family, retrive a Family refresh token if present and make a refreshTokenRequest\n if (isFOCI) {\n try {\n return this.acquireTokenWithCachedRefreshToken(request, true);\n } catch (e) {\n const noFamilyRTInCache = e instanceof InteractionRequiredAuthError && e.errorCode === InteractionRequiredAuthErrorMessage.noTokensFoundError.code;\n const clientMismatchErrorWithFamilyRT = e instanceof ServerError && e.errorCode === Errors.INVALID_GRANT_ERROR && e.subError === Errors.CLIENT_MISMATCH_ERROR;\n\n // if family Refresh Token (FRT) cache acquisition fails or if client_mismatch error is seen with FRT, reattempt with application Refresh Token (ART)\n if (noFamilyRTInCache || clientMismatchErrorWithFamilyRT) {\n return this.acquireTokenWithCachedRefreshToken(request, false);\n // throw in all other cases\n } else {\n throw e;\n }\n }\n }\n\n // fall back to application refresh token acquisition\n return this.acquireTokenWithCachedRefreshToken(request, false);\n }\n\n /**\n * makes a network call to acquire tokens by exchanging RefreshToken available in userCache; throws if refresh token is not cached\n * @param request\n */\n private async acquireTokenWithCachedRefreshToken(request: CommonSilentFlowRequest, foci: boolean) {\n // fetches family RT or application RT based on FOCI value\n const refreshToken = this.cacheManager.readRefreshTokenFromCache(this.config.authOptions.clientId, request.account, foci);\n\n // no refresh Token\n if (!refreshToken) {\n throw InteractionRequiredAuthError.createNoTokensFoundError();\n }\n\n const refreshTokenRequest: CommonRefreshTokenRequest = {\n ...request,\n refreshToken: refreshToken.secret,\n authenticationScheme: request.authenticationScheme || AuthenticationScheme.BEARER,\n ccsCredential: {\n credential: request.account.homeAccountId,\n type: CcsCredentialType.HOME_ACCOUNT_ID\n }\n };\n\n return this.acquireToken(refreshTokenRequest);\n }\n\n /**\n * Constructs the network message and makes a NW call to the underlying secure token service\n * @param request\n * @param authority\n */\n private async executeTokenRequest(request: CommonRefreshTokenRequest, authority: Authority)\n : Promise<NetworkResponse<ServerAuthorizationTokenResponse>> {\n\n const requestBody = await this.createTokenRequestBody(request);\n const queryParameters = this.createTokenQueryParameters(request);\n const headers: Record<string, string> = this.createTokenRequestHeaders(request.ccsCredential);\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\n const endpoint = UrlString.appendQueryString(authority.tokenEndpoint, queryParameters);\n return this.executePostToTokenEndpoint(endpoint, requestBody, headers, thumbprint);\n }\n\n /**\n * Creates query string for the /token request\n * @param request \n */\n private createTokenQueryParameters(request: CommonRefreshTokenRequest): string {\n const parameterBuilder = new RequestParameterBuilder();\n\n if (request.tokenQueryParameters) {\n parameterBuilder.addExtraQueryParameters(request.tokenQueryParameters);\n }\n\n return parameterBuilder.createQueryString();\n }\n\n /**\n * Helper function to create the token request body\n * @param request\n */\n private async createTokenRequestBody(request: CommonRefreshTokenRequest): Promise<string> {\n const parameterBuilder = new RequestParameterBuilder();\n\n parameterBuilder.addClientId(this.config.authOptions.clientId);\n\n parameterBuilder.addScopes(request.scopes);\n\n parameterBuilder.addGrantType(GrantType.REFRESH_TOKEN_GRANT);\n\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 parameterBuilder.addRefreshToken(request.refreshToken);\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 (request.authenticationScheme === AuthenticationScheme.POP) {\n const popTokenGenerator = new PopTokenGenerator(this.cryptoUtils);\n const cnfString = await popTokenGenerator.generateCnf(request);\n parameterBuilder.addPopToken(cnfString);\n } else if (request.authenticationScheme === AuthenticationScheme.SSH) {\n if(request.sshJwk) {\n parameterBuilder.addSshJwk(request.sshJwk);\n } else {\n throw ClientConfigurationError.createMissingSshJwkError();\n }\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.ccsCredential) {\n switch (request.ccsCredential.type) {\n case CcsCredentialType.HOME_ACCOUNT_ID:\n try {\n const clientInfo = buildClientInfoFromHomeAccountId(request.ccsCredential.credential);\n parameterBuilder.addCcsOid(clientInfo);\n } catch (e) {\n this.logger.verbose(\"Could not parse home account ID for CCS Header: \" + e);\n }\n break;\n case CcsCredentialType.UPN:\n parameterBuilder.addCcsUpn(request.ccsCredential.credential);\n break;\n }\n }\n\n return parameterBuilder.createQueryString();\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;AA4BA;;;;IAGwC,sCAAU;IAE9C,4BAAY,aAAkC;eAC1C,kBAAM,aAAa,CAAC;KACvB;IAEY,yCAAY,GAAzB,UAA0B,OAAkC;;;;;;wBAClD,YAAY,GAAG,SAAS,CAAC,UAAU,EAAE,CAAC;wBAC3B,qBAAM,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,EAAA;;wBAAlE,QAAQ,GAAG,SAAuD;wBAElE,eAAe,GAAG,IAAI,eAAe,CACvC,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{"version":3,"file":"UsernamePasswordClient.d.ts","sourceRoot":"","sources":["../../src/client/UsernamePasswordClient.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,6BAA6B,EAAE,MAAM,0CAA0C,CAAC;AACzF,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAYxE;;;GAGG;AACH,qBAAa,sBAAuB,SAAQ,UAAU;gBAEtC,aAAa,EAAE,mBAAmB;IAI9C;;;;OAIG;IACG,YAAY,CAAC,OAAO,EAAE,6BAA6B,GAAG,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;IAsBhG;;;;OAIG;YACW,mBAAmB;IAqBjC;;;OAGG;IACH,OAAO,CAAC,sBAAsB;
|
|
1
|
+
{"version":3,"file":"UsernamePasswordClient.d.ts","sourceRoot":"","sources":["../../src/client/UsernamePasswordClient.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,6BAA6B,EAAE,MAAM,0CAA0C,CAAC;AACzF,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAYxE;;;GAGG;AACH,qBAAa,sBAAuB,SAAQ,UAAU;gBAEtC,aAAa,EAAE,mBAAmB;IAI9C;;;;OAIG;IACG,YAAY,CAAC,OAAO,EAAE,6BAA6B,GAAG,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;IAsBhG;;;;OAIG;YACW,mBAAmB;IAqBjC;;;OAGG;IACH,OAAO,CAAC,sBAAsB;CA6CjC"}
|