@azure/msal-common 5.0.0 → 6.0.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.
Files changed (169) hide show
  1. package/CHANGELOG.json +130 -0
  2. package/{changelog.md → CHANGELOG.md} +462 -413
  3. package/LICENSE +21 -21
  4. package/README.md +62 -61
  5. package/dist/_virtual/_tslib.js +1 -1
  6. package/dist/account/AuthToken.js +1 -1
  7. package/dist/account/AuthToken.js.map +1 -1
  8. package/dist/account/CcsCredential.js +1 -1
  9. package/dist/account/CcsCredential.js.map +1 -1
  10. package/dist/account/ClientInfo.js +1 -1
  11. package/dist/account/ClientInfo.js.map +1 -1
  12. package/dist/authority/Authority.d.ts.map +1 -1
  13. package/dist/authority/Authority.js +8 -2
  14. package/dist/authority/Authority.js.map +1 -1
  15. package/dist/authority/AuthorityFactory.js +1 -1
  16. package/dist/authority/AuthorityFactory.js.map +1 -1
  17. package/dist/authority/AuthorityType.js +1 -1
  18. package/dist/authority/AuthorityType.js.map +1 -1
  19. package/dist/authority/CloudInstanceDiscoveryResponse.js +1 -1
  20. package/dist/authority/CloudInstanceDiscoveryResponse.js.map +1 -1
  21. package/dist/authority/OpenIdConfigResponse.d.ts +1 -1
  22. package/dist/authority/OpenIdConfigResponse.d.ts.map +1 -1
  23. package/dist/authority/OpenIdConfigResponse.js +1 -2
  24. package/dist/authority/OpenIdConfigResponse.js.map +1 -1
  25. package/dist/authority/ProtocolMode.js +1 -1
  26. package/dist/authority/ProtocolMode.js.map +1 -1
  27. package/dist/authority/RegionDiscovery.js +1 -1
  28. package/dist/authority/RegionDiscovery.js.map +1 -1
  29. package/dist/cache/CacheManager.d.ts +15 -5
  30. package/dist/cache/CacheManager.d.ts.map +1 -1
  31. package/dist/cache/CacheManager.js +49 -18
  32. package/dist/cache/CacheManager.js.map +1 -1
  33. package/dist/cache/entities/AccessTokenEntity.d.ts +3 -1
  34. package/dist/cache/entities/AccessTokenEntity.d.ts.map +1 -1
  35. package/dist/cache/entities/AccessTokenEntity.js +23 -10
  36. package/dist/cache/entities/AccessTokenEntity.js.map +1 -1
  37. package/dist/cache/entities/AccountEntity.js +1 -1
  38. package/dist/cache/entities/AccountEntity.js.map +1 -1
  39. package/dist/cache/entities/AppMetadataEntity.js +1 -1
  40. package/dist/cache/entities/AppMetadataEntity.js.map +1 -1
  41. package/dist/cache/entities/AuthorityMetadataEntity.d.ts +1 -1
  42. package/dist/cache/entities/AuthorityMetadataEntity.d.ts.map +1 -1
  43. package/dist/cache/entities/AuthorityMetadataEntity.js +1 -2
  44. package/dist/cache/entities/AuthorityMetadataEntity.js.map +1 -1
  45. package/dist/cache/entities/CacheRecord.js +1 -1
  46. package/dist/cache/entities/CacheRecord.js.map +1 -1
  47. package/dist/cache/entities/CredentialEntity.d.ts +13 -2
  48. package/dist/cache/entities/CredentialEntity.d.ts.map +1 -1
  49. package/dist/cache/entities/CredentialEntity.js +25 -10
  50. package/dist/cache/entities/CredentialEntity.js.map +1 -1
  51. package/dist/cache/entities/IdTokenEntity.js +1 -1
  52. package/dist/cache/entities/IdTokenEntity.js.map +1 -1
  53. package/dist/cache/entities/RefreshTokenEntity.js +1 -1
  54. package/dist/cache/entities/RefreshTokenEntity.js.map +1 -1
  55. package/dist/cache/entities/ServerTelemetryEntity.js +1 -1
  56. package/dist/cache/entities/ServerTelemetryEntity.js.map +1 -1
  57. package/dist/cache/entities/ThrottlingEntity.js +1 -1
  58. package/dist/cache/entities/ThrottlingEntity.js.map +1 -1
  59. package/dist/cache/persistence/TokenCacheContext.js +1 -1
  60. package/dist/cache/persistence/TokenCacheContext.js.map +1 -1
  61. package/dist/cache/utils/CacheTypes.d.ts +2 -0
  62. package/dist/cache/utils/CacheTypes.d.ts.map +1 -1
  63. package/dist/client/AuthorizationCodeClient.d.ts +1 -0
  64. package/dist/client/AuthorizationCodeClient.d.ts.map +1 -1
  65. package/dist/client/AuthorizationCodeClient.js +46 -10
  66. package/dist/client/AuthorizationCodeClient.js.map +1 -1
  67. package/dist/client/BaseClient.js +1 -1
  68. package/dist/client/BaseClient.js.map +1 -1
  69. package/dist/client/ClientCredentialClient.d.ts.map +1 -1
  70. package/dist/client/ClientCredentialClient.js +4 -2
  71. package/dist/client/ClientCredentialClient.js.map +1 -1
  72. package/dist/client/DeviceCodeClient.d.ts.map +1 -1
  73. package/dist/client/DeviceCodeClient.js +7 -3
  74. package/dist/client/DeviceCodeClient.js.map +1 -1
  75. package/dist/client/OnBehalfOfClient.d.ts.map +1 -1
  76. package/dist/client/OnBehalfOfClient.js +4 -2
  77. package/dist/client/OnBehalfOfClient.js.map +1 -1
  78. package/dist/client/RefreshTokenClient.d.ts.map +1 -1
  79. package/dist/client/RefreshTokenClient.js +24 -11
  80. package/dist/client/RefreshTokenClient.js.map +1 -1
  81. package/dist/client/SilentFlowClient.d.ts.map +1 -1
  82. package/dist/client/SilentFlowClient.js +14 -18
  83. package/dist/client/SilentFlowClient.js.map +1 -1
  84. package/dist/client/UsernamePasswordClient.d.ts.map +1 -1
  85. package/dist/client/UsernamePasswordClient.js +4 -2
  86. package/dist/client/UsernamePasswordClient.js.map +1 -1
  87. package/dist/config/ClientConfiguration.js +1 -1
  88. package/dist/config/ClientConfiguration.js.map +1 -1
  89. package/dist/crypto/ICrypto.d.ts +6 -1
  90. package/dist/crypto/ICrypto.d.ts.map +1 -1
  91. package/dist/crypto/ICrypto.js +10 -1
  92. package/dist/crypto/ICrypto.js.map +1 -1
  93. package/dist/crypto/PopTokenGenerator.js +4 -4
  94. package/dist/crypto/PopTokenGenerator.js.map +1 -1
  95. package/dist/error/AuthError.js +1 -1
  96. package/dist/error/AuthError.js.map +1 -1
  97. package/dist/error/ClientAuthError.d.ts +8 -4
  98. package/dist/error/ClientAuthError.d.ts.map +1 -1
  99. package/dist/error/ClientAuthError.js +11 -7
  100. package/dist/error/ClientAuthError.js.map +1 -1
  101. package/dist/error/ClientConfigurationError.d.ts +29 -0
  102. package/dist/error/ClientConfigurationError.d.ts.map +1 -1
  103. package/dist/error/ClientConfigurationError.js +43 -3
  104. package/dist/error/ClientConfigurationError.js.map +1 -1
  105. package/dist/error/InteractionRequiredAuthError.d.ts +24 -5
  106. package/dist/error/InteractionRequiredAuthError.d.ts.map +1 -1
  107. package/dist/error/InteractionRequiredAuthError.js +30 -9
  108. package/dist/error/InteractionRequiredAuthError.js.map +1 -1
  109. package/dist/error/ServerError.js +1 -1
  110. package/dist/error/ServerError.js.map +1 -1
  111. package/dist/index.cjs.js +371 -101
  112. package/dist/index.cjs.js.map +1 -1
  113. package/dist/index.d.ts +3 -1
  114. package/dist/index.d.ts.map +1 -1
  115. package/dist/index.js +4 -2
  116. package/dist/index.js.map +1 -1
  117. package/dist/logger/Logger.js +1 -1
  118. package/dist/logger/Logger.js.map +1 -1
  119. package/dist/network/INetworkModule.js +1 -1
  120. package/dist/network/INetworkModule.js.map +1 -1
  121. package/dist/network/NetworkManager.js +1 -1
  122. package/dist/network/NetworkManager.js.map +1 -1
  123. package/dist/network/RequestThumbprint.d.ts +2 -0
  124. package/dist/network/RequestThumbprint.d.ts.map +1 -1
  125. package/dist/network/ThrottlingUtils.d.ts.map +1 -1
  126. package/dist/network/ThrottlingUtils.js +4 -2
  127. package/dist/network/ThrottlingUtils.js.map +1 -1
  128. package/dist/packageMetadata.d.ts +1 -1
  129. package/dist/packageMetadata.js +2 -2
  130. package/dist/packageMetadata.js.map +1 -1
  131. package/dist/request/AuthenticationHeaderParser.d.ts +20 -0
  132. package/dist/request/AuthenticationHeaderParser.d.ts.map +1 -0
  133. package/dist/request/AuthenticationHeaderParser.js +64 -0
  134. package/dist/request/AuthenticationHeaderParser.js.map +1 -0
  135. package/dist/request/BaseAuthRequest.d.ts +9 -1
  136. package/dist/request/BaseAuthRequest.d.ts.map +1 -1
  137. package/dist/request/CommonAuthorizationCodeRequest.d.ts +3 -0
  138. package/dist/request/CommonAuthorizationCodeRequest.d.ts.map +1 -1
  139. package/dist/request/RequestParameterBuilder.d.ts +4 -0
  140. package/dist/request/RequestParameterBuilder.d.ts.map +1 -1
  141. package/dist/request/RequestParameterBuilder.js +10 -1
  142. package/dist/request/RequestParameterBuilder.js.map +1 -1
  143. package/dist/request/RequestValidator.js +1 -1
  144. package/dist/request/RequestValidator.js.map +1 -1
  145. package/dist/request/ScopeSet.js +1 -1
  146. package/dist/request/ScopeSet.js.map +1 -1
  147. package/dist/response/AuthenticationResult.d.ts +2 -1
  148. package/dist/response/AuthenticationResult.d.ts.map +1 -1
  149. package/dist/response/ResponseHandler.d.ts +1 -1
  150. package/dist/response/ResponseHandler.d.ts.map +1 -1
  151. package/dist/response/ResponseHandler.js +11 -8
  152. package/dist/response/ResponseHandler.js.map +1 -1
  153. package/dist/response/ServerAuthorizationTokenResponse.d.ts +3 -0
  154. package/dist/response/ServerAuthorizationTokenResponse.d.ts.map +1 -1
  155. package/dist/telemetry/server/ServerTelemetryManager.js +1 -1
  156. package/dist/telemetry/server/ServerTelemetryManager.js.map +1 -1
  157. package/dist/url/UrlString.js +1 -1
  158. package/dist/url/UrlString.js.map +1 -1
  159. package/dist/utils/Constants.d.ts +7 -3
  160. package/dist/utils/Constants.d.ts.map +1 -1
  161. package/dist/utils/Constants.js +6 -2
  162. package/dist/utils/Constants.js.map +1 -1
  163. package/dist/utils/ProtocolUtils.js +1 -1
  164. package/dist/utils/ProtocolUtils.js.map +1 -1
  165. package/dist/utils/StringUtils.js +1 -1
  166. package/dist/utils/StringUtils.js.map +1 -1
  167. package/dist/utils/TimeUtils.js +1 -1
  168. package/dist/utils/TimeUtils.js.map +1 -1
  169. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- /*! @azure/msal-common v5.0.0 2021-09-08 */
1
+ /*! @azure/msal-common v6.0.0 2022-01-04 */
2
2
  'use strict';
3
3
  import { __extends, __awaiter, __generator } from '../_virtual/_tslib.js';
4
4
  import { BaseClient } from './BaseClient.js';
@@ -158,10 +158,12 @@ var OnBehalfOfClient = /** @class */ (function (_super) {
158
158
  clientId: this.config.authOptions.clientId,
159
159
  authority: request.authority,
160
160
  scopes: request.scopes,
161
+ claims: request.claims,
161
162
  authenticationScheme: request.authenticationScheme,
162
163
  resourceRequestMethod: request.resourceRequestMethod,
163
164
  resourceRequestUri: request.resourceRequestUri,
164
- shrClaims: request.shrClaims
165
+ shrClaims: request.shrClaims,
166
+ sshKid: request.sshKid
165
167
  };
166
168
  reqTimestamp = TimeUtils.nowSeconds();
167
169
  return [4 /*yield*/, this.executePostToTokenEndpoint(authority.tokenEndpoint, requestBody, headers, thumbprint)];
@@ -1 +1 @@
1
- {"version":3,"file":"OnBehalfOfClient.js","sources":["../../src/client/OnBehalfOfClient.ts"],"sourcesContent":["/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { ClientConfiguration } from \"../config/ClientConfiguration\";\r\nimport { BaseClient } from \"./BaseClient\";\r\nimport { Authority } from \"../authority/Authority\";\r\nimport { RequestParameterBuilder } from \"../request/RequestParameterBuilder\";\r\nimport { ScopeSet } from \"../request/ScopeSet\";\r\nimport { GrantType, AADServerParamKeys , CredentialType, Constants, CacheOutcome } from \"../utils/Constants\";\r\nimport { ResponseHandler } from \"../response/ResponseHandler\";\r\nimport { AuthenticationResult } from \"../response/AuthenticationResult\";\r\nimport { CommonOnBehalfOfRequest } from \"../request/CommonOnBehalfOfRequest\";\r\nimport { TimeUtils } from \"../utils/TimeUtils\";\r\nimport { CredentialFilter, CredentialCache } from \"../cache/utils/CacheTypes\";\r\nimport { AccessTokenEntity } from \"../cache/entities/AccessTokenEntity\";\r\nimport { IdTokenEntity } from \"../cache/entities/IdTokenEntity\";\r\nimport { AccountEntity } from \"../cache/entities/AccountEntity\";\r\nimport { AuthToken } from \"../account/AuthToken\";\r\nimport { ClientAuthError } from \"../error/ClientAuthError\";\r\nimport { RequestThumbprint } from \"../network/RequestThumbprint\";\r\nimport { AccountInfo } from \"../account/AccountInfo\";\r\n\r\n/**\r\n * On-Behalf-Of client\r\n */\r\nexport class OnBehalfOfClient extends BaseClient {\r\n\r\n private scopeSet: ScopeSet;\r\n\r\n constructor(configuration: ClientConfiguration) {\r\n super(configuration);\r\n }\r\n\r\n /**\r\n * Public API to acquire tokens with on behalf of flow\r\n * @param request\r\n */\r\n public async acquireToken(request: CommonOnBehalfOfRequest): Promise<AuthenticationResult | null> {\r\n this.scopeSet = new ScopeSet(request.scopes || []);\r\n\r\n if (request.skipCache) {\r\n return await this.executeTokenRequest(request, this.authority);\r\n }\r\n\r\n const cachedAuthenticationResult = await this.getCachedAuthenticationResult(request);\r\n if (cachedAuthenticationResult) {\r\n return cachedAuthenticationResult;\r\n } else {\r\n return await this.executeTokenRequest(request, this.authority);\r\n }\r\n }\r\n\r\n /**\r\n * look up cache for tokens\r\n * @param request\r\n */\r\n private async getCachedAuthenticationResult(request: CommonOnBehalfOfRequest): Promise<AuthenticationResult | null> {\r\n const cachedAccessToken = this.readAccessTokenFromCache();\r\n if (!cachedAccessToken ||\r\n TimeUtils.isTokenExpired(cachedAccessToken.expiresOn, this.config.systemOptions.tokenRenewalOffsetSeconds)) {\r\n\r\n // Update the server telemetry outcome\r\n this.serverTelemetryManager?.setCacheOutcome(!cachedAccessToken ? CacheOutcome.CACHED_ACCESS_TOKEN_EXPIRED : CacheOutcome.NO_CACHED_ACCESS_TOKEN);\r\n\r\n return null;\r\n }\r\n\r\n const cachedIdToken = this.readIdTokenFromCache(request);\r\n let idTokenObject: AuthToken | undefined;\r\n let cachedAccount: AccountEntity | null = null;\r\n if (cachedIdToken) {\r\n idTokenObject = new AuthToken(cachedIdToken.secret, this.config.cryptoInterface);\r\n const localAccountId = idTokenObject.claims.oid ? idTokenObject.claims.oid : idTokenObject.claims.sub;\r\n const accountInfo: AccountInfo = {\r\n homeAccountId: cachedIdToken.homeAccountId,\r\n environment: cachedIdToken.environment,\r\n tenantId: cachedIdToken.realm,\r\n username: Constants.EMPTY_STRING,\r\n localAccountId: localAccountId || \"\"\r\n };\r\n\r\n cachedAccount = this.readAccountFromCache(accountInfo);\r\n }\r\n\r\n return await ResponseHandler.generateAuthenticationResult(\r\n this.cryptoUtils,\r\n this.authority,\r\n {\r\n account: cachedAccount,\r\n accessToken: cachedAccessToken,\r\n idToken: cachedIdToken,\r\n refreshToken: null,\r\n appMetadata: null\r\n },\r\n true,\r\n request,\r\n idTokenObject);\r\n }\r\n\r\n /**\r\n * read access token from cache TODO: CacheManager API should be used here\r\n * @param request\r\n */\r\n private readAccessTokenFromCache(): AccessTokenEntity | null {\r\n const accessTokenFilter: CredentialFilter = {\r\n environment: this.authority.canonicalAuthorityUrlComponents.HostNameAndPort,\r\n credentialType: CredentialType.ACCESS_TOKEN,\r\n clientId: this.config.authOptions.clientId,\r\n realm: this.authority.tenant,\r\n target: this.scopeSet.printScopesLowerCase(),\r\n };\r\n\r\n const credentialCache: CredentialCache = this.cacheManager.getCredentialsFilteredBy(accessTokenFilter);\r\n const accessTokens = Object.keys(credentialCache.accessTokens).map(key => credentialCache.accessTokens[key]);\r\n\r\n const numAccessTokens = accessTokens.length;\r\n if (numAccessTokens < 1) {\r\n return null;\r\n } else if (numAccessTokens > 1) {\r\n throw ClientAuthError.createMultipleMatchingTokensInCacheError();\r\n }\r\n return accessTokens[0] as AccessTokenEntity;\r\n }\r\n\r\n /**\r\n * read idtoken from cache TODO: CacheManager API should be used here instead\r\n * @param request\r\n */\r\n private readIdTokenFromCache(request: CommonOnBehalfOfRequest): IdTokenEntity | null {\r\n const idTokenFilter: CredentialFilter = {\r\n environment: this.authority.canonicalAuthorityUrlComponents.HostNameAndPort,\r\n credentialType: CredentialType.ID_TOKEN,\r\n clientId: this.config.authOptions.clientId,\r\n realm: this.authority.tenant,\r\n oboAssertion: request.oboAssertion\r\n };\r\n\r\n const credentialCache: CredentialCache = this.cacheManager.getCredentialsFilteredBy(idTokenFilter);\r\n const idTokens = Object.keys(credentialCache.idTokens).map(key => credentialCache.idTokens[key]);\r\n // When acquiring a token on behalf of an application, there might not be an id token in the cache\r\n if (idTokens.length < 1) {\r\n return null;\r\n }\r\n return idTokens[0] as IdTokenEntity;\r\n }\r\n\r\n /**\r\n * read account from cache, TODO: CacheManager API should be used here instead\r\n * @param account\r\n */\r\n private readAccountFromCache(account: AccountInfo): AccountEntity | null {\r\n return this.cacheManager.readAccountFromCache(account);\r\n }\r\n\r\n /**\r\n * Make a network call to the server requesting credentials\r\n * @param request\r\n * @param authority\r\n */\r\n private async executeTokenRequest(request: CommonOnBehalfOfRequest, authority: Authority)\r\n : Promise<AuthenticationResult | null> {\r\n\r\n const requestBody = this.createTokenRequestBody(request);\r\n const headers: Record<string, string> = this.createTokenRequestHeaders();\r\n const thumbprint: RequestThumbprint = {\r\n clientId: this.config.authOptions.clientId,\r\n authority: request.authority,\r\n scopes: request.scopes,\r\n authenticationScheme: request.authenticationScheme,\r\n resourceRequestMethod: request.resourceRequestMethod,\r\n resourceRequestUri: request.resourceRequestUri,\r\n shrClaims: request.shrClaims\r\n };\r\n\r\n const reqTimestamp = TimeUtils.nowSeconds();\r\n const response = await this.executePostToTokenEndpoint(authority.tokenEndpoint, requestBody, headers, thumbprint);\r\n\r\n const responseHandler = new ResponseHandler(\r\n this.config.authOptions.clientId,\r\n this.cacheManager,\r\n this.cryptoUtils,\r\n this.logger,\r\n this.config.serializableCache,\r\n this.config.persistencePlugin\r\n );\r\n\r\n responseHandler.validateTokenResponse(response.body);\r\n const tokenResponse = await responseHandler.handleServerTokenResponse(\r\n response.body,\r\n this.authority,\r\n reqTimestamp,\r\n request\r\n );\r\n\r\n return tokenResponse;\r\n }\r\n\r\n /**\r\n * generate a server request in accepable format\r\n * @param request\r\n */\r\n private createTokenRequestBody(request: CommonOnBehalfOfRequest): string {\r\n const parameterBuilder = new RequestParameterBuilder();\r\n\r\n parameterBuilder.addClientId(this.config.authOptions.clientId);\r\n\r\n parameterBuilder.addScopes(request.scopes);\r\n\r\n parameterBuilder.addGrantType(GrantType.JWT_BEARER);\r\n\r\n parameterBuilder.addClientInfo();\r\n\r\n parameterBuilder.addLibraryInfo(this.config.libraryInfo);\r\n\r\n parameterBuilder.addThrottling();\r\n \r\n if (this.serverTelemetryManager) {\r\n parameterBuilder.addServerTelemetry(this.serverTelemetryManager);\r\n }\r\n\r\n const correlationId = request.correlationId || this.config.cryptoInterface.createNewGuid();\r\n parameterBuilder.addCorrelationId(correlationId);\r\n\r\n parameterBuilder.addRequestTokenUse(AADServerParamKeys.ON_BEHALF_OF);\r\n\r\n parameterBuilder.addOboAssertion(request.oboAssertion);\r\n\r\n if (this.config.clientCredentials.clientSecret) {\r\n parameterBuilder.addClientSecret(this.config.clientCredentials.clientSecret);\r\n }\r\n\r\n if (this.config.clientCredentials.clientAssertion) {\r\n const clientAssertion = this.config.clientCredentials.clientAssertion;\r\n parameterBuilder.addClientAssertion(clientAssertion.assertion);\r\n parameterBuilder.addClientAssertionType(clientAssertion.assertionType);\r\n }\r\n\r\n return parameterBuilder.createQueryString();\r\n }\r\n}\r\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,EAAjB,wBAAiB;wBACV,qBAAM,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,EAAA;4BAA9D,sBAAO,SAAuD,EAAC;4BAGhC,qBAAM,IAAI,CAAC,6BAA6B,CAAC,OAAO,CAAC,EAAA;;wBAA9E,0BAA0B,GAAG,SAAiD;6BAChF,0BAA0B,EAA1B,wBAA0B;wBAC1B,sBAAO,0BAA0B,EAAC;4BAE3B,qBAAM,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,EAAA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eAAe,CAAC,aAAa,EAAE,CAAC;QAC3F,gBAAgB,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC;QAEjD,gBAAgB,CAAC,kBAAkB,CAAC,kBAAkB,CAAC,YAAY,CAAC,CAAC;QAErE,gBAAgB,CAAC,eAAe,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QAEvD,IAAI,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,YAAY,EAAE;YAC5C,gBAAgB,CAAC,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,YAAY,CAAC,CAAC;SAChF;QAED,IAAI,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,eAAe,EAAE;YAC/C,IAAM,eAAe,GAAG,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,eAAe,CAAC;YACtE,gBAAgB,CAAC,kBAAkB,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;YAC/D,gBAAgB,CAAC,sBAAsB,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC;SAC1E;QAED,OAAO,gBAAgB,CAAC,iBAAiB,EAAE,CAAC;KAC/C;IACL,uBAAC;AAAD,CAtNA,CAAsC,UAAU;;;;"}
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,CAAC,SAAS,EAAjB,wBAAiB;wBACV,qBAAM,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,EAAA;4BAA9D,sBAAO,SAAuD,EAAC;4BAGhC,qBAAM,IAAI,CAAC,6BAA6B,CAAC,OAAO,CAAC,EAAA;;wBAA9E,0BAA0B,GAAG,SAAiD;6BAChF,0BAA0B,EAA1B,wBAA0B;wBAC1B,sBAAO,0BAA0B,EAAC;4BAE3B,qBAAM,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,EAAA;4BAA9D,sBAAO,SAAuD,EAAC;;;;KAEtE;;;;;IAMa,wDAA6B,GAA3C,UAA4C,OAAgC;;;;;;;wBAClE,iBAAiB,GAAG,IAAI,CAAC,wBAAwB,EAAE,CAAC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AAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAoCxG;;;OAGG;YACW,kCAAkC;IAsBhD;;;;OAIG;YACW,mBAAmB;IAoBjC;;;OAGG;IACH,OAAO,CAAC,0BAA0B;IAUlC;;;OAGG;YACW,sBAAsB;CA8DvC"}
1
+ {"version":3,"file":"RefreshTokenClient.d.ts","sourceRoot":"","sources":["../../src/client/RefreshTokenClient.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AAMjF,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAKxE,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAU7E;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,UAAU;gBAElC,aAAa,EAAE,mBAAmB;IAIjC,YAAY,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAyB5F;;;OAGG;IACU,0BAA0B,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAoCxG;;;OAGG;YACW,kCAAkC;IAsBhD;;;;OAIG;YACW,mBAAmB;IAsBjC;;;OAGG;IACH,OAAO,CAAC,0BAA0B;IAUlC;;;OAGG;YACW,sBAAsB;CAoEvC"}
@@ -1,4 +1,4 @@
1
- /*! @azure/msal-common v5.0.0 2021-09-08 */
1
+ /*! @azure/msal-common v6.0.0 2022-01-04 */
2
2
  'use strict';
3
3
  import { __extends, __awaiter, __generator, __assign } from '../_virtual/_tslib.js';
4
4
  import { BaseClient } from './BaseClient.js';
@@ -8,12 +8,13 @@ import { ResponseHandler } from '../response/ResponseHandler.js';
8
8
  import { PopTokenGenerator } from '../crypto/PopTokenGenerator.js';
9
9
  import { StringUtils } from '../utils/StringUtils.js';
10
10
  import { ClientConfigurationError } from '../error/ClientConfigurationError.js';
11
- import { ClientAuthError, ClientAuthErrorMessage } from '../error/ClientAuthError.js';
11
+ import { ClientAuthError } from '../error/ClientAuthError.js';
12
12
  import { ServerError } from '../error/ServerError.js';
13
13
  import { TimeUtils } from '../utils/TimeUtils.js';
14
14
  import { UrlString } from '../url/UrlString.js';
15
15
  import { CcsCredentialType } from '../account/CcsCredential.js';
16
16
  import { buildClientInfoFromHomeAccountId } from '../account/ClientInfo.js';
17
+ import { InteractionRequiredAuthError, InteractionRequiredAuthErrorMessage } from '../error/InteractionRequiredAuthError.js';
17
18
 
18
19
  /*
19
20
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -67,7 +68,7 @@ var RefreshTokenClient = /** @class */ (function (_super) {
67
68
  return [2 /*return*/, this.acquireTokenWithCachedRefreshToken(request, true)];
68
69
  }
69
70
  catch (e) {
70
- noFamilyRTInCache = e instanceof ClientAuthError && e.errorCode === ClientAuthErrorMessage.noTokensFoundError.code;
71
+ noFamilyRTInCache = e instanceof InteractionRequiredAuthError && e.errorCode === InteractionRequiredAuthErrorMessage.noTokensFoundError.code;
71
72
  clientMismatchErrorWithFamilyRT = e instanceof ServerError && e.errorCode === Errors.INVALID_GRANT_ERROR && e.subError === Errors.CLIENT_MISMATCH_ERROR;
72
73
  // if family Refresh Token (FRT) cache acquisition fails or if client_mismatch error is seen with FRT, reattempt with application Refresh Token (ART)
73
74
  if (noFamilyRTInCache || clientMismatchErrorWithFamilyRT) {
@@ -95,7 +96,7 @@ var RefreshTokenClient = /** @class */ (function (_super) {
95
96
  refreshToken = this.cacheManager.readRefreshTokenFromCache(this.config.authOptions.clientId, request.account, foci);
96
97
  // no refresh Token
97
98
  if (!refreshToken) {
98
- throw ClientAuthError.createNoTokensFoundError();
99
+ throw InteractionRequiredAuthError.createNoTokensFoundError();
99
100
  }
100
101
  refreshTokenRequest = __assign(__assign({}, request), { refreshToken: refreshToken.secret, authenticationScheme: request.authenticationScheme || AuthenticationScheme.BEARER, ccsCredential: {
101
102
  credential: request.account.homeAccountId,
@@ -124,10 +125,12 @@ var RefreshTokenClient = /** @class */ (function (_super) {
124
125
  clientId: this.config.authOptions.clientId,
125
126
  authority: authority.canonicalAuthority,
126
127
  scopes: request.scopes,
128
+ claims: request.claims,
127
129
  authenticationScheme: request.authenticationScheme,
128
130
  resourceRequestMethod: request.resourceRequestMethod,
129
131
  resourceRequestUri: request.resourceRequestUri,
130
- shrClaims: request.shrClaims
132
+ shrClaims: request.shrClaims,
133
+ sshKid: request.sshKid
131
134
  };
132
135
  endpoint = UrlString.appendQueryString(authority.tokenEndpoint, queryParameters);
133
136
  return [2 /*return*/, this.executePostToTokenEndpoint(endpoint, requestBody, headers, thumbprint)];
@@ -152,9 +155,9 @@ var RefreshTokenClient = /** @class */ (function (_super) {
152
155
  */
153
156
  RefreshTokenClient.prototype.createTokenRequestBody = function (request) {
154
157
  return __awaiter(this, void 0, void 0, function () {
155
- var parameterBuilder, correlationId, clientAssertion, popTokenGenerator, _a, _b, clientInfo;
156
- return __generator(this, function (_c) {
157
- switch (_c.label) {
158
+ var parameterBuilder, correlationId, clientAssertion, popTokenGenerator, cnfString, clientInfo;
159
+ return __generator(this, function (_a) {
160
+ switch (_a.label) {
158
161
  case 0:
159
162
  parameterBuilder = new RequestParameterBuilder();
160
163
  parameterBuilder.addClientId(this.config.authOptions.clientId);
@@ -179,12 +182,22 @@ var RefreshTokenClient = /** @class */ (function (_super) {
179
182
  }
180
183
  if (!(request.authenticationScheme === AuthenticationScheme.POP)) return [3 /*break*/, 2];
181
184
  popTokenGenerator = new PopTokenGenerator(this.cryptoUtils);
182
- _b = (_a = parameterBuilder).addPopToken;
183
185
  return [4 /*yield*/, popTokenGenerator.generateCnf(request)];
184
186
  case 1:
185
- _b.apply(_a, [_c.sent()]);
186
- _c.label = 2;
187
+ cnfString = _a.sent();
188
+ parameterBuilder.addPopToken(cnfString);
189
+ return [3 /*break*/, 3];
187
190
  case 2:
191
+ if (request.authenticationScheme === AuthenticationScheme.SSH) {
192
+ if (request.sshJwk) {
193
+ parameterBuilder.addSshJwk(request.sshJwk);
194
+ }
195
+ else {
196
+ throw ClientConfigurationError.createMissingSshJwkError();
197
+ }
198
+ }
199
+ _a.label = 3;
200
+ case 3:
188
201
  if (!StringUtils.isEmptyObj(request.claims) || this.config.authOptions.clientCapabilities && this.config.authOptions.clientCapabilities.length > 0) {
189
202
  parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);
190
203
  }
@@ -1 +1 @@
1
- {"version":3,"file":"RefreshTokenClient.js","sources":["../../src/client/RefreshTokenClient.ts"],"sourcesContent":["/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { ClientConfiguration } from \"../config/ClientConfiguration\";\r\nimport { BaseClient } from \"./BaseClient\";\r\nimport { CommonRefreshTokenRequest } from \"../request/CommonRefreshTokenRequest\";\r\nimport { Authority } from \"../authority/Authority\";\r\nimport { ServerAuthorizationTokenResponse } from \"../response/ServerAuthorizationTokenResponse\";\r\nimport { RequestParameterBuilder } from \"../request/RequestParameterBuilder\";\r\nimport { GrantType, AuthenticationScheme, Errors } from \"../utils/Constants\";\r\nimport { ResponseHandler } from \"../response/ResponseHandler\";\r\nimport { AuthenticationResult } from \"../response/AuthenticationResult\";\r\nimport { PopTokenGenerator } from \"../crypto/PopTokenGenerator\";\r\nimport { StringUtils } from \"../utils/StringUtils\";\r\nimport { RequestThumbprint } from \"../network/RequestThumbprint\";\r\nimport { NetworkResponse } from \"../network/NetworkManager\";\r\nimport { CommonSilentFlowRequest } from \"../request/CommonSilentFlowRequest\";\r\nimport { ClientConfigurationError } from \"../error/ClientConfigurationError\";\r\nimport { ClientAuthError, ClientAuthErrorMessage } from \"../error/ClientAuthError\";\r\nimport { ServerError } from \"../error/ServerError\";\r\nimport { TimeUtils } from \"../utils/TimeUtils\";\r\nimport { UrlString } from \"../url/UrlString\";\r\nimport { CcsCredentialType } from \"../account/CcsCredential\";\r\nimport { buildClientInfoFromHomeAccountId } from \"../account/ClientInfo\";\r\n\r\n/**\r\n * OAuth2.0 refresh token client\r\n */\r\nexport class RefreshTokenClient extends BaseClient {\r\n\r\n constructor(configuration: ClientConfiguration) {\r\n super(configuration);\r\n }\r\n\r\n public async acquireToken(request: CommonRefreshTokenRequest): Promise<AuthenticationResult>{\r\n const reqTimestamp = TimeUtils.nowSeconds();\r\n const response = await this.executeTokenRequest(request, this.authority);\r\n\r\n const responseHandler = new ResponseHandler(\r\n this.config.authOptions.clientId,\r\n this.cacheManager,\r\n this.cryptoUtils,\r\n this.logger,\r\n this.config.serializableCache,\r\n this.config.persistencePlugin\r\n );\r\n\r\n responseHandler.validateTokenResponse(response.body);\r\n return responseHandler.handleServerTokenResponse(\r\n response.body,\r\n this.authority,\r\n reqTimestamp,\r\n request,\r\n undefined,\r\n undefined,\r\n true\r\n );\r\n }\r\n\r\n /**\r\n * Gets cached refresh token and attaches to request, then calls acquireToken API\r\n * @param request\r\n */\r\n public async acquireTokenByRefreshToken(request: CommonSilentFlowRequest): Promise<AuthenticationResult> {\r\n // Cannot renew token if no request object is given.\r\n if (!request) {\r\n throw ClientConfigurationError.createEmptyTokenRequestError();\r\n }\r\n\r\n // We currently do not support silent flow for account === null use cases; This will be revisited for confidential flow usecases\r\n if (!request.account) {\r\n throw ClientAuthError.createNoAccountInSilentRequestError();\r\n }\r\n\r\n // try checking if FOCI is enabled for the given application\r\n const isFOCI = this.cacheManager.isAppMetadataFOCI(request.account.environment, this.config.authOptions.clientId);\r\n\r\n // if the app is part of the family, retrive a Family refresh token if present and make a refreshTokenRequest\r\n if (isFOCI) {\r\n try {\r\n return this.acquireTokenWithCachedRefreshToken(request, true);\r\n } catch (e) {\r\n const noFamilyRTInCache = e instanceof ClientAuthError && e.errorCode === ClientAuthErrorMessage.noTokensFoundError.code;\r\n const clientMismatchErrorWithFamilyRT = e instanceof ServerError && e.errorCode === Errors.INVALID_GRANT_ERROR && e.subError === Errors.CLIENT_MISMATCH_ERROR;\r\n\r\n // if family Refresh Token (FRT) cache acquisition fails or if client_mismatch error is seen with FRT, reattempt with application Refresh Token (ART)\r\n if (noFamilyRTInCache || clientMismatchErrorWithFamilyRT) {\r\n return this.acquireTokenWithCachedRefreshToken(request, false);\r\n // throw in all other cases\r\n } else {\r\n throw e;\r\n }\r\n }\r\n }\r\n\r\n // fall back to application refresh token acquisition\r\n return this.acquireTokenWithCachedRefreshToken(request, false);\r\n }\r\n\r\n /**\r\n * makes a network call to acquire tokens by exchanging RefreshToken available in userCache; throws if refresh token is not cached\r\n * @param request\r\n */\r\n private async acquireTokenWithCachedRefreshToken(request: CommonSilentFlowRequest, foci: boolean) {\r\n // fetches family RT or application RT based on FOCI value\r\n const refreshToken = this.cacheManager.readRefreshTokenFromCache(this.config.authOptions.clientId, request.account, foci);\r\n\r\n // no refresh Token\r\n if (!refreshToken) {\r\n throw ClientAuthError.createNoTokensFoundError();\r\n }\r\n\r\n const refreshTokenRequest: CommonRefreshTokenRequest = {\r\n ...request,\r\n refreshToken: refreshToken.secret,\r\n authenticationScheme: request.authenticationScheme || AuthenticationScheme.BEARER,\r\n ccsCredential: {\r\n credential: request.account.homeAccountId,\r\n type: CcsCredentialType.HOME_ACCOUNT_ID\r\n }\r\n };\r\n\r\n return this.acquireToken(refreshTokenRequest);\r\n }\r\n\r\n /**\r\n * Constructs the network message and makes a NW call to the underlying secure token service\r\n * @param request\r\n * @param authority\r\n */\r\n private async executeTokenRequest(request: CommonRefreshTokenRequest, authority: Authority)\r\n : Promise<NetworkResponse<ServerAuthorizationTokenResponse>> {\r\n\r\n const requestBody = await this.createTokenRequestBody(request);\r\n const queryParameters = this.createTokenQueryParameters(request);\r\n const headers: Record<string, string> = this.createTokenRequestHeaders(request.ccsCredential);\r\n const thumbprint: RequestThumbprint = {\r\n clientId: this.config.authOptions.clientId,\r\n authority: authority.canonicalAuthority,\r\n scopes: request.scopes,\r\n authenticationScheme: request.authenticationScheme,\r\n resourceRequestMethod: request.resourceRequestMethod,\r\n resourceRequestUri: request.resourceRequestUri,\r\n shrClaims: request.shrClaims\r\n };\r\n\r\n const endpoint = UrlString.appendQueryString(authority.tokenEndpoint, queryParameters);\r\n return this.executePostToTokenEndpoint(endpoint, requestBody, headers, thumbprint);\r\n }\r\n\r\n /**\r\n * Creates query string for the /token request\r\n * @param request \r\n */\r\n private createTokenQueryParameters(request: CommonRefreshTokenRequest): string {\r\n const parameterBuilder = new RequestParameterBuilder();\r\n\r\n if (request.tokenQueryParameters) {\r\n parameterBuilder.addExtraQueryParameters(request.tokenQueryParameters);\r\n }\r\n\r\n return parameterBuilder.createQueryString();\r\n }\r\n\r\n /**\r\n * Helper function to create the token request body\r\n * @param request\r\n */\r\n private async createTokenRequestBody(request: CommonRefreshTokenRequest): Promise<string> {\r\n const parameterBuilder = new RequestParameterBuilder();\r\n\r\n parameterBuilder.addClientId(this.config.authOptions.clientId);\r\n\r\n parameterBuilder.addScopes(request.scopes);\r\n\r\n parameterBuilder.addGrantType(GrantType.REFRESH_TOKEN_GRANT);\r\n\r\n parameterBuilder.addClientInfo();\r\n\r\n parameterBuilder.addLibraryInfo(this.config.libraryInfo);\r\n\r\n parameterBuilder.addThrottling();\r\n \r\n if (this.serverTelemetryManager) {\r\n parameterBuilder.addServerTelemetry(this.serverTelemetryManager);\r\n }\r\n\r\n const correlationId = request.correlationId || this.config.cryptoInterface.createNewGuid();\r\n parameterBuilder.addCorrelationId(correlationId);\r\n\r\n parameterBuilder.addRefreshToken(request.refreshToken);\r\n\r\n if (this.config.clientCredentials.clientSecret) {\r\n parameterBuilder.addClientSecret(this.config.clientCredentials.clientSecret);\r\n }\r\n\r\n if (this.config.clientCredentials.clientAssertion) {\r\n const clientAssertion = this.config.clientCredentials.clientAssertion;\r\n parameterBuilder.addClientAssertion(clientAssertion.assertion);\r\n parameterBuilder.addClientAssertionType(clientAssertion.assertionType);\r\n }\r\n\r\n if (request.authenticationScheme === AuthenticationScheme.POP) {\r\n const popTokenGenerator = new PopTokenGenerator(this.cryptoUtils);\r\n\r\n parameterBuilder.addPopToken(await popTokenGenerator.generateCnf(request));\r\n }\r\n\r\n if (!StringUtils.isEmptyObj(request.claims) || this.config.authOptions.clientCapabilities && this.config.authOptions.clientCapabilities.length > 0) {\r\n parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);\r\n }\r\n\r\n if (this.config.systemOptions.preventCorsPreflight && request.ccsCredential) {\r\n switch (request.ccsCredential.type) {\r\n case CcsCredentialType.HOME_ACCOUNT_ID:\r\n try {\r\n const clientInfo = buildClientInfoFromHomeAccountId(request.ccsCredential.credential);\r\n parameterBuilder.addCcsOid(clientInfo);\r\n } catch (e) {\r\n this.logger.verbose(\"Could not parse home account ID for CCS Header: \" + e);\r\n }\r\n break;\r\n case CcsCredentialType.UPN:\r\n parameterBuilder.addCcsUpn(request.ccsCredential.credential);\r\n break;\r\n }\r\n }\r\n\r\n return parameterBuilder.createQueryString();\r\n }\r\n}\r\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA;;;;AA2BA;;;;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,CAA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AC,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,CA1MA,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\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,IAAI,CAAC,CAAC;wBACrD,sBAAO,eAAe,CAAC,yBAAyB,CAC5C,QAAQ,CAAC,IAAI,EACb,IAAI,CAA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AGG;IACG,kBAAkB,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IA8CzF;;;OAGG;YACW,6BAA6B;CAc9C"}
1
+ {"version":3,"file":"SilentFlowClient.d.ts","sourceRoot":"","sources":["../../src/client/SilentFlowClient.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAUxE,qBAAa,gBAAiB,SAAQ,UAAU;gBAEhC,aAAa,EAAE,mBAAmB;IAI9C;;;;OAIG;IACG,YAAY,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAanF;;;OAGG;IACG,kBAAkB,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAiDzF;;;OAGG;YACW,6BAA6B;CAc9C"}
@@ -1,16 +1,14 @@
1
- /*! @azure/msal-common v5.0.0 2021-09-08 */
1
+ /*! @azure/msal-common v6.0.0 2022-01-04 */
2
2
  'use strict';
3
3
  import { __extends, __awaiter, __generator } from '../_virtual/_tslib.js';
4
4
  import { BaseClient } from './BaseClient.js';
5
- import { ScopeSet } from '../request/ScopeSet.js';
6
5
  import { AuthToken } from '../account/AuthToken.js';
7
6
  import { TimeUtils } from '../utils/TimeUtils.js';
8
7
  import { RefreshTokenClient } from './RefreshTokenClient.js';
9
8
  import { ClientAuthError, ClientAuthErrorMessage } from '../error/ClientAuthError.js';
10
9
  import { ClientConfigurationError } from '../error/ClientConfigurationError.js';
11
10
  import { ResponseHandler } from '../response/ResponseHandler.js';
12
- import { CacheOutcome, AuthenticationScheme } from '../utils/Constants.js';
13
- import { StringUtils } from '../utils/StringUtils.js';
11
+ import { CacheOutcome } from '../utils/Constants.js';
14
12
 
15
13
  /*
16
14
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -56,7 +54,7 @@ var SilentFlowClient = /** @class */ (function (_super) {
56
54
  SilentFlowClient.prototype.acquireCachedToken = function (request) {
57
55
  var _a, _b, _c, _d;
58
56
  return __awaiter(this, void 0, void 0, function () {
59
- var requestScopes, environment, authScheme, cacheRecord;
57
+ var environment, cacheRecord;
60
58
  return __generator(this, function (_e) {
61
59
  switch (_e.label) {
62
60
  case 0:
@@ -64,37 +62,35 @@ var SilentFlowClient = /** @class */ (function (_super) {
64
62
  if (!request) {
65
63
  throw ClientConfigurationError.createEmptyTokenRequestError();
66
64
  }
67
- // We currently do not support silent flow for account === null use cases; This will be revisited for confidential flow usecases
68
- if (!request.account) {
69
- throw ClientAuthError.createNoAccountInSilentRequestError();
70
- }
71
- requestScopes = new ScopeSet(request.scopes || []);
72
- environment = request.authority || this.authority.getPreferredCache();
73
- authScheme = request.authenticationScheme || AuthenticationScheme.BEARER;
74
- cacheRecord = this.cacheManager.readCacheRecord(request.account, this.config.authOptions.clientId, requestScopes, environment, authScheme);
75
65
  if (request.forceRefresh) {
76
66
  // Must refresh due to present force_refresh flag.
77
67
  (_a = this.serverTelemetryManager) === null || _a === void 0 ? void 0 : _a.setCacheOutcome(CacheOutcome.FORCE_REFRESH);
68
+ this.logger.info("SilentFlowClient:acquireCachedToken - Skipping cache because forceRefresh is true.");
78
69
  throw ClientAuthError.createRefreshRequiredError();
79
70
  }
80
- else if (!cacheRecord.accessToken) {
71
+ // We currently do not support silent flow for account === null use cases; This will be revisited for confidential flow usecases
72
+ if (!request.account) {
73
+ throw ClientAuthError.createNoAccountInSilentRequestError();
74
+ }
75
+ environment = request.authority || this.authority.getPreferredCache();
76
+ cacheRecord = this.cacheManager.readCacheRecord(request.account, this.config.authOptions.clientId, request, environment);
77
+ if (!cacheRecord.accessToken) {
81
78
  // Must refresh due to non-existent access_token.
82
79
  (_b = this.serverTelemetryManager) === null || _b === void 0 ? void 0 : _b.setCacheOutcome(CacheOutcome.NO_CACHED_ACCESS_TOKEN);
80
+ this.logger.info("SilentFlowClient:acquireCachedToken - No access token found in cache for the given properties.");
83
81
  throw ClientAuthError.createRefreshRequiredError();
84
82
  }
85
83
  else if (TimeUtils.wasClockTurnedBack(cacheRecord.accessToken.cachedAt) ||
86
84
  TimeUtils.isTokenExpired(cacheRecord.accessToken.expiresOn, this.config.systemOptions.tokenRenewalOffsetSeconds)) {
87
85
  // Must refresh due to expired access_token.
88
86
  (_c = this.serverTelemetryManager) === null || _c === void 0 ? void 0 : _c.setCacheOutcome(CacheOutcome.CACHED_ACCESS_TOKEN_EXPIRED);
87
+ this.logger.info("SilentFlowClient:acquireCachedToken - Cached access token is expired or will expire within " + this.config.systemOptions.tokenRenewalOffsetSeconds + " seconds.");
89
88
  throw ClientAuthError.createRefreshRequiredError();
90
89
  }
91
90
  else if (cacheRecord.accessToken.refreshOn && TimeUtils.isTokenExpired(cacheRecord.accessToken.refreshOn, 0)) {
92
91
  // Must refresh due to the refresh_in value.
93
92
  (_d = this.serverTelemetryManager) === null || _d === void 0 ? void 0 : _d.setCacheOutcome(CacheOutcome.REFRESH_CACHED_ACCESS_TOKEN);
94
- throw ClientAuthError.createRefreshRequiredError();
95
- }
96
- else if (!StringUtils.isEmptyObj(request.claims)) {
97
- // Must refresh due to request parameters.
93
+ this.logger.info("SilentFlowClient:acquireCachedToken - Cached access token's refreshOn property has been exceeded'.");
98
94
  throw ClientAuthError.createRefreshRequiredError();
99
95
  }
100
96
  if (this.config.serverTelemetryManager) {
@@ -1 +1 @@
1
- {"version":3,"file":"SilentFlowClient.js","sources":["../../src/client/SilentFlowClient.ts"],"sourcesContent":["/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { BaseClient } from \"./BaseClient\";\r\nimport { ClientConfiguration } from \"../config/ClientConfiguration\";\r\nimport { CommonSilentFlowRequest } from \"../request/CommonSilentFlowRequest\";\r\nimport { AuthenticationResult } from \"../response/AuthenticationResult\";\r\nimport { ScopeSet } from \"../request/ScopeSet\";\r\nimport { AuthToken } from \"../account/AuthToken\";\r\nimport { TimeUtils } from \"../utils/TimeUtils\";\r\nimport { RefreshTokenClient } from \"./RefreshTokenClient\";\r\nimport { ClientAuthError, ClientAuthErrorMessage } from \"../error/ClientAuthError\";\r\nimport { ClientConfigurationError } from \"../error/ClientConfigurationError\";\r\nimport { ResponseHandler } from \"../response/ResponseHandler\";\r\nimport { CacheRecord } from \"../cache/entities/CacheRecord\";\r\nimport { AuthenticationScheme, CacheOutcome } from \"../utils/Constants\";\r\nimport { StringUtils } from \"../utils/StringUtils\";\r\n\r\nexport class SilentFlowClient extends BaseClient {\r\n\r\n constructor(configuration: ClientConfiguration) {\r\n super(configuration);\r\n }\r\n\r\n /**\r\n * Retrieves a token from cache if it is still valid, or uses the cached refresh token to renew\r\n * the given token and returns the renewed token\r\n * @param request\r\n */\r\n async acquireToken(request: CommonSilentFlowRequest): Promise<AuthenticationResult> {\r\n try {\r\n return await this.acquireCachedToken(request);\r\n } catch (e) {\r\n if (e instanceof ClientAuthError && e.errorCode === ClientAuthErrorMessage.tokenRefreshRequired.code) {\r\n const refreshTokenClient = new RefreshTokenClient(this.config);\r\n return refreshTokenClient.acquireTokenByRefreshToken(request);\r\n } else {\r\n throw e;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Retrieves token from cache or throws an error if it must be refreshed.\r\n * @param request\r\n */\r\n async acquireCachedToken(request: CommonSilentFlowRequest): Promise<AuthenticationResult> {\r\n // Cannot renew token if no request object is given.\r\n if (!request) {\r\n throw ClientConfigurationError.createEmptyTokenRequestError();\r\n }\r\n\r\n // We currently do not support silent flow for account === null use cases; This will be revisited for confidential flow usecases\r\n if (!request.account) {\r\n throw ClientAuthError.createNoAccountInSilentRequestError();\r\n }\r\n const requestScopes = new ScopeSet(request.scopes || []);\r\n const environment = request.authority || this.authority.getPreferredCache();\r\n const authScheme = request.authenticationScheme || AuthenticationScheme.BEARER;\r\n const cacheRecord = this.cacheManager.readCacheRecord(request.account, this.config.authOptions.clientId, requestScopes, environment, authScheme);\r\n \r\n if (request.forceRefresh) {\r\n // Must refresh due to present force_refresh flag.\r\n this.serverTelemetryManager?.setCacheOutcome(CacheOutcome.FORCE_REFRESH);\r\n throw ClientAuthError.createRefreshRequiredError();\r\n } else if (!cacheRecord.accessToken) {\r\n // Must refresh due to non-existent access_token.\r\n this.serverTelemetryManager?.setCacheOutcome(CacheOutcome.NO_CACHED_ACCESS_TOKEN);\r\n throw ClientAuthError.createRefreshRequiredError();\r\n } else if (\r\n TimeUtils.wasClockTurnedBack(cacheRecord.accessToken.cachedAt) ||\r\n TimeUtils.isTokenExpired(cacheRecord.accessToken.expiresOn, this.config.systemOptions.tokenRenewalOffsetSeconds)\r\n ) {\r\n // Must refresh due to expired access_token.\r\n this.serverTelemetryManager?.setCacheOutcome(CacheOutcome.CACHED_ACCESS_TOKEN_EXPIRED);\r\n throw ClientAuthError.createRefreshRequiredError();\r\n } else if (cacheRecord.accessToken.refreshOn && TimeUtils.isTokenExpired(cacheRecord.accessToken.refreshOn, 0)) {\r\n // Must refresh due to the refresh_in value.\r\n this.serverTelemetryManager?.setCacheOutcome(CacheOutcome.REFRESH_CACHED_ACCESS_TOKEN);\r\n throw ClientAuthError.createRefreshRequiredError();\r\n } else if (!StringUtils.isEmptyObj(request.claims)) {\r\n // Must refresh due to request parameters.\r\n throw ClientAuthError.createRefreshRequiredError();\r\n }\r\n\r\n if (this.config.serverTelemetryManager) {\r\n this.config.serverTelemetryManager.incrementCacheHits();\r\n }\r\n\r\n return await this.generateResultFromCacheRecord(cacheRecord, request);\r\n }\r\n\r\n /**\r\n * Helper function to build response object from the CacheRecord\r\n * @param cacheRecord\r\n */\r\n private async generateResultFromCacheRecord(cacheRecord: CacheRecord, request: CommonSilentFlowRequest): Promise<AuthenticationResult> {\r\n let idTokenObj: AuthToken | undefined;\r\n if (cacheRecord.idToken) {\r\n idTokenObj = new AuthToken(cacheRecord.idToken.secret, this.config.cryptoInterface);\r\n }\r\n return await ResponseHandler.generateAuthenticationResult(\r\n this.cryptoUtils,\r\n this.authority,\r\n cacheRecord,\r\n true,\r\n request,\r\n idTokenObj\r\n );\r\n }\r\n}\r\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA;;;;;IAoBsC,oCAAU;IAE5C,0BAAY,aAAkC;eAC1C,kBAAM,aAAa,CAAC;KACvB;;;;;;IAOK,uCAAY,GAAlB,UAAmB,OAAgC;;;;;;;wBAEpC,qBAAM,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,EAAA;4BAA7C,sBAAO,SAAsC,EAAC;;;wBAE9C,IAAI,GAAC,YAAY,eAAe,IAAI,GAAC,CAAC,SAAS,KAAK,sBAAsB,CAAC,oBAAoB,CAAC,IAAI,EAAE;4BAC5F,kBAAkB,GAAG,IAAI,kBAAkB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;4BAC/D,sBAAO,kBAAkB,CAAC,0BAA0B,CAAC,OAAO,CAAC,EAAC;yBACjE;6BAAM;4BACH,MAAM,GAAC,CAAC;yBACX;;;;;KAER;;;;;IAMK,6CAAkB,GAAxB,UAAyB,OAAgC;;;;;;;;wBAErD,IAAI,CAAC,OAAO,EAAE;4BACV,MAAM,wBAAwB,CAAC,4BAA4B,EAAE,CAAC;yBACjE;;wBAGD,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;4BAClB,MAAM,eAAe,CAAC,mCAAmC,EAAE,CAAC;yBAC/D;wBACK,aAAa,GAAG,IAAI,QAAQ,CAAC,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC;wBACnD,WAAW,GAAG,OAAO,CAAC,SAAS,IAAI,IAAI,CAAC,SAAS,CAAC,iBAAiB,EAAE,CAAC;wBACtE,UAAU,GAAG,OAAO,CAAC,oBAAoB,IAAI,oBAAoB,CAAC,MAAM,CAAC;wBACzE,WAAW,GAAG,IAAI,CA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AAI,CAAC,MAAM,CAAC,sBAAsB,EAAE;4BACpC,IAAI,CAAC,MAAM,CAAC,sBAAsB,CAAC,kBAAkB,EAAE,CAAC;yBAC3D;wBAEM,qBAAM,IAAI,CAAC,6BAA6B,CAAC,WAAW,EAAE,OAAO,CAAC,EAAA;4BAArE,sBAAO,SAA8D,EAAC;;;;KACzE;;;;;IAMa,wDAA6B,GAA3C,UAA4C,WAAwB,EAAE,OAAgC;;;;;;wBAElG,IAAI,WAAW,CAAC,OAAO,EAAE;4BACrB,UAAU,GAAG,IAAI,SAAS,CAAC,WAAW,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;yBACvF;wBACM,qBAAM,eAAe,CAAC,4BAA4B,CACrD,IAAI,CAAC,WAAW,EAChB,IAAI,CAAC,SAAS,EACd,WAAW,EACX,IAAI,EACJ,OAAO,EACP,UAAU,CACb,EAAA;4BAPD,sBAAO,SAON,EAAC;;;;KACL;IACL,uBAAC;AAAD,CA5FA,CAAsC,UAAU;;;;"}
1
+ {"version":3,"file":"SilentFlowClient.js","sources":["../../src/client/SilentFlowClient.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { BaseClient } from \"./BaseClient\";\nimport { ClientConfiguration } from \"../config/ClientConfiguration\";\nimport { CommonSilentFlowRequest } from \"../request/CommonSilentFlowRequest\";\nimport { AuthenticationResult } from \"../response/AuthenticationResult\";\nimport { AuthToken } from \"../account/AuthToken\";\nimport { TimeUtils } from \"../utils/TimeUtils\";\nimport { RefreshTokenClient } from \"./RefreshTokenClient\";\nimport { ClientAuthError, ClientAuthErrorMessage } from \"../error/ClientAuthError\";\nimport { ClientConfigurationError } from \"../error/ClientConfigurationError\";\nimport { ResponseHandler } from \"../response/ResponseHandler\";\nimport { CacheRecord } from \"../cache/entities/CacheRecord\";\nimport { CacheOutcome } from \"../utils/Constants\";\n\nexport class SilentFlowClient extends BaseClient {\n\n constructor(configuration: ClientConfiguration) {\n super(configuration);\n }\n\n /**\n * Retrieves a token from cache if it is still valid, or uses the cached refresh token to renew\n * the given token and returns the renewed token\n * @param request\n */\n async acquireToken(request: CommonSilentFlowRequest): Promise<AuthenticationResult> {\n try {\n return await this.acquireCachedToken(request);\n } catch (e) {\n if (e instanceof ClientAuthError && e.errorCode === ClientAuthErrorMessage.tokenRefreshRequired.code) {\n const refreshTokenClient = new RefreshTokenClient(this.config);\n return refreshTokenClient.acquireTokenByRefreshToken(request);\n } else {\n throw e;\n }\n }\n }\n\n /**\n * Retrieves token from cache or throws an error if it must be refreshed.\n * @param request\n */\n async acquireCachedToken(request: CommonSilentFlowRequest): Promise<AuthenticationResult> {\n // Cannot renew token if no request object is given.\n if (!request) {\n throw ClientConfigurationError.createEmptyTokenRequestError();\n }\n\n if (request.forceRefresh) {\n // Must refresh due to present force_refresh flag.\n this.serverTelemetryManager?.setCacheOutcome(CacheOutcome.FORCE_REFRESH);\n this.logger.info(\"SilentFlowClient:acquireCachedToken - Skipping cache because forceRefresh is true.\");\n throw ClientAuthError.createRefreshRequiredError();\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 const environment = request.authority || this.authority.getPreferredCache();\n\n const cacheRecord = this.cacheManager.readCacheRecord(request.account, this.config.authOptions.clientId, request, environment);\n \n if (!cacheRecord.accessToken) {\n // Must refresh due to non-existent access_token.\n this.serverTelemetryManager?.setCacheOutcome(CacheOutcome.NO_CACHED_ACCESS_TOKEN);\n this.logger.info(\"SilentFlowClient:acquireCachedToken - No access token found in cache for the given properties.\");\n throw ClientAuthError.createRefreshRequiredError();\n } else if (\n TimeUtils.wasClockTurnedBack(cacheRecord.accessToken.cachedAt) ||\n TimeUtils.isTokenExpired(cacheRecord.accessToken.expiresOn, this.config.systemOptions.tokenRenewalOffsetSeconds)\n ) {\n // Must refresh due to expired access_token.\n this.serverTelemetryManager?.setCacheOutcome(CacheOutcome.CACHED_ACCESS_TOKEN_EXPIRED);\n this.logger.info(`SilentFlowClient:acquireCachedToken - Cached access token is expired or will expire within ${this.config.systemOptions.tokenRenewalOffsetSeconds} seconds.`);\n throw ClientAuthError.createRefreshRequiredError();\n } else if (cacheRecord.accessToken.refreshOn && TimeUtils.isTokenExpired(cacheRecord.accessToken.refreshOn, 0)) {\n // Must refresh due to the refresh_in value.\n this.serverTelemetryManager?.setCacheOutcome(CacheOutcome.REFRESH_CACHED_ACCESS_TOKEN);\n this.logger.info(\"SilentFlowClient:acquireCachedToken - Cached access token's refreshOn property has been exceeded'.\");\n throw ClientAuthError.createRefreshRequiredError();\n }\n\n if (this.config.serverTelemetryManager) {\n this.config.serverTelemetryManager.incrementCacheHits();\n }\n\n return await this.generateResultFromCacheRecord(cacheRecord, request);\n }\n\n /**\n * Helper function to build response object from the CacheRecord\n * @param cacheRecord\n */\n private async generateResultFromCacheRecord(cacheRecord: CacheRecord, request: CommonSilentFlowRequest): Promise<AuthenticationResult> {\n let idTokenObj: AuthToken | undefined;\n if (cacheRecord.idToken) {\n idTokenObj = new AuthToken(cacheRecord.idToken.secret, this.config.cryptoInterface);\n }\n return await ResponseHandler.generateAuthenticationResult(\n this.cryptoUtils,\n this.authority,\n cacheRecord,\n true,\n request,\n idTokenObj\n );\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;IAkBsC,oCAAU;IAE5C,0BAAY,aAAkC;eAC1C,kBAAM,aAAa,CAAC;KACvB;;;;;;IAOK,uCAAY,GAAlB,UAAmB,OAAgC;;;;;;;wBAEpC,qBAAM,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,EAAA;4BAA7C,sBAAO,SAAsC,EAAC;;;wBAE9C,IAAI,GAAC,YAAY,eAAe,IAAI,GAAC,CAAC,SAAS,KAAK,sBAAsB,CAAC,oBAAoB,CAAC,IAAI,EAAE;4BAC5F,kBAAkB,GAAG,IAAI,kB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,UAAU,CACb,EAAA;4BAPD,sBAAO,SAON,EAAC;;;;KACL;IACL,uBAAC;AAAD,CA/FA,CAAsC,UAAU;;;;"}
@@ -1 +1 @@
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;IAmBjC;;;OAGG;IACH,OAAO,CAAC,sBAAsB;CA2CjC"}
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;CA2CjC"}
@@ -1,4 +1,4 @@
1
- /*! @azure/msal-common v5.0.0 2021-09-08 */
1
+ /*! @azure/msal-common v6.0.0 2022-01-04 */
2
2
  'use strict';
3
3
  import { __extends, __awaiter, __generator } from '../_virtual/_tslib.js';
4
4
  import { BaseClient } from './BaseClient.js';
@@ -60,10 +60,12 @@ var UsernamePasswordClient = /** @class */ (function (_super) {
60
60
  clientId: this.config.authOptions.clientId,
61
61
  authority: authority.canonicalAuthority,
62
62
  scopes: request.scopes,
63
+ claims: request.claims,
63
64
  authenticationScheme: request.authenticationScheme,
64
65
  resourceRequestMethod: request.resourceRequestMethod,
65
66
  resourceRequestUri: request.resourceRequestUri,
66
- shrClaims: request.shrClaims
67
+ shrClaims: request.shrClaims,
68
+ sshKid: request.sshKid
67
69
  };
68
70
  requestBody = this.createTokenRequestBody(request);
69
71
  headers = this.createTokenRequestHeaders({
@@ -1 +1 @@
1
- {"version":3,"file":"UsernamePasswordClient.js","sources":["../../src/client/UsernamePasswordClient.ts"],"sourcesContent":["/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { BaseClient } from \"./BaseClient\";\r\nimport { ClientConfiguration } from \"../config/ClientConfiguration\";\r\nimport { CommonUsernamePasswordRequest } from \"../request/CommonUsernamePasswordRequest\";\r\nimport { AuthenticationResult } from \"../response/AuthenticationResult\";\r\nimport { ResponseHandler } from \"../response/ResponseHandler\";\r\nimport { Authority } from \"../authority/Authority\";\r\nimport { NetworkResponse } from \"../network/NetworkManager\";\r\nimport { ServerAuthorizationTokenResponse } from \"../response/ServerAuthorizationTokenResponse\";\r\nimport { RequestParameterBuilder } from \"../request/RequestParameterBuilder\";\r\nimport { GrantType } from \"../utils/Constants\";\r\nimport { StringUtils } from \"../utils/StringUtils\";\r\nimport { RequestThumbprint } from \"../network/RequestThumbprint\";\r\nimport { TimeUtils } from \"../utils/TimeUtils\";\r\nimport { CcsCredentialType } from \"../account/CcsCredential\";\r\n\r\n/**\r\n * Oauth2.0 Password grant client\r\n * Note: We are only supporting public clients for password grant and for purely testing purposes\r\n */\r\nexport class UsernamePasswordClient extends BaseClient {\r\n\r\n constructor(configuration: ClientConfiguration) {\r\n super(configuration);\r\n }\r\n\r\n /**\r\n * API to acquire a token by passing the username and password to the service in exchage of credentials\r\n * password_grant\r\n * @param request\r\n */\r\n async acquireToken(request: CommonUsernamePasswordRequest): Promise<AuthenticationResult | null> {\r\n this.logger.info(\"in acquireToken call\");\r\n\r\n const reqTimestamp = TimeUtils.nowSeconds();\r\n const response = await this.executeTokenRequest(this.authority, request);\r\n\r\n const responseHandler = new ResponseHandler(\r\n this.config.authOptions.clientId,\r\n this.cacheManager,\r\n this.cryptoUtils,\r\n this.logger,\r\n this.config.serializableCache,\r\n this.config.persistencePlugin\r\n );\r\n\r\n // Validate response. This function throws a server error if an error is returned by the server.\r\n responseHandler.validateTokenResponse(response.body);\r\n const tokenResponse = responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request);\r\n\r\n return tokenResponse;\r\n }\r\n\r\n /**\r\n * Executes POST request to token endpoint\r\n * @param authority\r\n * @param request\r\n */\r\n private async executeTokenRequest(authority: Authority, request: CommonUsernamePasswordRequest): Promise<NetworkResponse<ServerAuthorizationTokenResponse>> {\r\n const thumbprint: RequestThumbprint = {\r\n clientId: this.config.authOptions.clientId,\r\n authority: authority.canonicalAuthority,\r\n scopes: request.scopes,\r\n authenticationScheme: request.authenticationScheme,\r\n resourceRequestMethod: request.resourceRequestMethod,\r\n resourceRequestUri: request.resourceRequestUri,\r\n shrClaims: request.shrClaims\r\n };\r\n const requestBody = this.createTokenRequestBody(request);\r\n const headers: Record<string, string> = this.createTokenRequestHeaders({\r\n credential: request.username,\r\n type: CcsCredentialType.UPN\r\n });\r\n\r\n return this.executePostToTokenEndpoint(authority.tokenEndpoint, requestBody, headers, thumbprint);\r\n }\r\n\r\n /**\r\n * Generates a map for all the params to be sent to the service\r\n * @param request\r\n */\r\n private createTokenRequestBody(request: CommonUsernamePasswordRequest): string {\r\n const parameterBuilder = new RequestParameterBuilder();\r\n\r\n parameterBuilder.addClientId(this.config.authOptions.clientId);\r\n parameterBuilder.addUsername(request.username);\r\n parameterBuilder.addPassword(request.password);\r\n\r\n parameterBuilder.addScopes(request.scopes);\r\n\r\n parameterBuilder.addGrantType(GrantType.RESOURCE_OWNER_PASSWORD_GRANT);\r\n parameterBuilder.addClientInfo();\r\n\r\n parameterBuilder.addLibraryInfo(this.config.libraryInfo);\r\n\r\n parameterBuilder.addThrottling();\r\n\r\n if (this.serverTelemetryManager) {\r\n parameterBuilder.addServerTelemetry(this.serverTelemetryManager);\r\n }\r\n\r\n const correlationId = request.correlationId || this.config.cryptoInterface.createNewGuid();\r\n parameterBuilder.addCorrelationId(correlationId);\r\n\r\n if (this.config.clientCredentials.clientSecret) {\r\n parameterBuilder.addClientSecret(this.config.clientCredentials.clientSecret);\r\n }\r\n\r\n if (this.config.clientCredentials.clientAssertion) {\r\n const clientAssertion = this.config.clientCredentials.clientAssertion;\r\n parameterBuilder.addClientAssertion(clientAssertion.assertion);\r\n parameterBuilder.addClientAssertionType(clientAssertion.assertionType);\r\n }\r\n\r\n if (!StringUtils.isEmptyObj(request.claims) || this.config.authOptions.clientCapabilities && this.config.authOptions.clientCapabilities.length > 0) {\r\n parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);\r\n }\r\n\r\n if (this.config.systemOptions.preventCorsPreflight && request.username) {\r\n parameterBuilder.addCcsUpn(request.username);\r\n }\r\n\r\n return parameterBuilder.createQueryString();\r\n }\r\n}\r\n"],"names":[],"mappings":";;;;;;;;;;;AAAA;;;;AAoBA;;;;;IAI4C,0CAAU;IAElD,gCAAY,aAAkC;eAC1C,kBAAM,aAAa,CAAC;KACvB;;;;;;IAOK,6CAAY,GAAlB,UAAmB,OAAsC;;;;;;wBACrD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;wBAEnC,YAAY,GAAG,SAA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AAM,CAAC,iBAAiB,CAAC,eAAe,CAAC;YACtE,gBAAgB,CAAC,kBAAkB,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;YAC/D,gBAAgB,CAAC,sBAAsB,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC;SAC1E;QAED,IAAI,CAAC,WAAW,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,gBAAgB,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAC;SAC1F;QAED,IAAI,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,oBAAoB,IAAI,OAAO,CAAC,QAAQ,EAAE;YACpE,gBAAgB,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;SAChD;QAED,OAAO,gBAAgB,CAAC,iBAAiB,EAAE,CAAC;KAC/C;IACL,6BAAC;AAAD,CAxGA,CAA4C,UAAU;;;;"}
1
+ {"version":3,"file":"UsernamePasswordClient.js","sources":["../../src/client/UsernamePasswordClient.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { BaseClient } from \"./BaseClient\";\nimport { ClientConfiguration } from \"../config/ClientConfiguration\";\nimport { CommonUsernamePasswordRequest } from \"../request/CommonUsernamePasswordRequest\";\nimport { AuthenticationResult } from \"../response/AuthenticationResult\";\nimport { ResponseHandler } from \"../response/ResponseHandler\";\nimport { Authority } from \"../authority/Authority\";\nimport { NetworkResponse } from \"../network/NetworkManager\";\nimport { ServerAuthorizationTokenResponse } from \"../response/ServerAuthorizationTokenResponse\";\nimport { RequestParameterBuilder } from \"../request/RequestParameterBuilder\";\nimport { GrantType } from \"../utils/Constants\";\nimport { StringUtils } from \"../utils/StringUtils\";\nimport { RequestThumbprint } from \"../network/RequestThumbprint\";\nimport { TimeUtils } from \"../utils/TimeUtils\";\nimport { CcsCredentialType } from \"../account/CcsCredential\";\n\n/**\n * Oauth2.0 Password grant client\n * Note: We are only supporting public clients for password grant and for purely testing purposes\n */\nexport class UsernamePasswordClient extends BaseClient {\n\n constructor(configuration: ClientConfiguration) {\n super(configuration);\n }\n\n /**\n * API to acquire a token by passing the username and password to the service in exchage of credentials\n * password_grant\n * @param request\n */\n async acquireToken(request: CommonUsernamePasswordRequest): Promise<AuthenticationResult | null> {\n this.logger.info(\"in acquireToken call\");\n\n const reqTimestamp = TimeUtils.nowSeconds();\n const response = await this.executeTokenRequest(this.authority, request);\n\n const responseHandler = new ResponseHandler(\n this.config.authOptions.clientId,\n this.cacheManager,\n this.cryptoUtils,\n this.logger,\n this.config.serializableCache,\n this.config.persistencePlugin\n );\n\n // Validate response. This function throws a server error if an error is returned by the server.\n responseHandler.validateTokenResponse(response.body);\n const tokenResponse = responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request);\n\n return tokenResponse;\n }\n\n /**\n * Executes POST request to token endpoint\n * @param authority\n * @param request\n */\n private async executeTokenRequest(authority: Authority, request: CommonUsernamePasswordRequest): Promise<NetworkResponse<ServerAuthorizationTokenResponse>> {\n const thumbprint: RequestThumbprint = {\n clientId: this.config.authOptions.clientId,\n authority: authority.canonicalAuthority,\n scopes: request.scopes,\n claims: request.claims,\n authenticationScheme: request.authenticationScheme,\n resourceRequestMethod: request.resourceRequestMethod,\n resourceRequestUri: request.resourceRequestUri,\n shrClaims: request.shrClaims,\n sshKid: request.sshKid\n };\n const requestBody = this.createTokenRequestBody(request);\n const headers: Record<string, string> = this.createTokenRequestHeaders({\n credential: request.username,\n type: CcsCredentialType.UPN\n });\n\n return this.executePostToTokenEndpoint(authority.tokenEndpoint, requestBody, headers, thumbprint);\n }\n\n /**\n * Generates a map for all the params to be sent to the service\n * @param request\n */\n private createTokenRequestBody(request: CommonUsernamePasswordRequest): string {\n const parameterBuilder = new RequestParameterBuilder();\n\n parameterBuilder.addClientId(this.config.authOptions.clientId);\n parameterBuilder.addUsername(request.username);\n parameterBuilder.addPassword(request.password);\n\n parameterBuilder.addScopes(request.scopes);\n\n parameterBuilder.addGrantType(GrantType.RESOURCE_OWNER_PASSWORD_GRANT);\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 if (this.config.clientCredentials.clientSecret) {\n parameterBuilder.addClientSecret(this.config.clientCredentials.clientSecret);\n }\n\n if (this.config.clientCredentials.clientAssertion) {\n const clientAssertion = this.config.clientCredentials.clientAssertion;\n parameterBuilder.addClientAssertion(clientAssertion.assertion);\n parameterBuilder.addClientAssertionType(clientAssertion.assertionType);\n }\n\n if (!StringUtils.isEmptyObj(request.claims) || this.config.authOptions.clientCapabilities && this.config.authOptions.clientCapabilities.length > 0) {\n parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);\n }\n\n if (this.config.systemOptions.preventCorsPreflight && request.username) {\n parameterBuilder.addCcsUpn(request.username);\n }\n\n return parameterBuilder.createQueryString();\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAAA;;;;AAoBA;;;;;IAI4C,0CAAU;IAElD,gCAAY,aAAkC;eAC1C,kBAAM,aAAa,CAAC;KACvB;;;;;;IAOK,6CAAY,GAAlB,UAAmB,OAAsC;;;;;;wBACrD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;wBAEnC,YAAY,GAAG,SAAS,CAAC,UAAU,EAAE,CAAC;wBAC3B,qBAAM,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,SAA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,iBAAiB,CAAC,eAAe,CAAC;YACtE,gBAAgB,CAAC,kBAAkB,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;YAC/D,gBAAgB,CAAC,sBAAsB,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC;SAC1E;QAED,IAAI,CAAC,WAAW,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,gBAAgB,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAC;SAC1F;QAED,IAAI,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,oBAAoB,IAAI,OAAO,CAAC,QAAQ,EAAE;YACpE,gBAAgB,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;SAChD;QAED,OAAO,gBAAgB,CAAC,iBAAiB,EAAE,CAAC;KAC/C;IACL,6BAAC;AAAD,CA1GA,CAA4C,UAAU;;;;"}
@@ -1,4 +1,4 @@
1
- /*! @azure/msal-common v5.0.0 2021-09-08 */
1
+ /*! @azure/msal-common v6.0.0 2022-01-04 */
2
2
  'use strict';
3
3
  import { __assign, __awaiter, __generator } from '../_virtual/_tslib.js';
4
4
  import { DEFAULT_CRYPTO_IMPLEMENTATION } from '../crypto/ICrypto.js';
@@ -1 +1 @@
1
- {"version":3,"file":"ClientConfiguration.js","sources":["../../src/config/ClientConfiguration.ts"],"sourcesContent":["/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { INetworkModule } from \"../network/INetworkModule\";\r\nimport { DEFAULT_CRYPTO_IMPLEMENTATION, ICrypto } from \"../crypto/ICrypto\";\r\nimport { AuthError } from \"../error/AuthError\";\r\nimport { ILoggerCallback, LogLevel } from \"../logger/Logger\";\r\nimport { Constants } from \"../utils/Constants\";\r\nimport { version } from \"../packageMetadata\";\r\nimport { Authority } from \"../authority/Authority\";\r\nimport { CacheManager, DefaultStorageClass } from \"../cache/CacheManager\";\r\nimport { ServerTelemetryManager } from \"../telemetry/server/ServerTelemetryManager\";\r\nimport { ICachePlugin } from \"../cache/interface/ICachePlugin\";\r\nimport { ISerializableTokenCache } from \"../cache/interface/ISerializableTokenCache\";\r\n\r\n// Token renewal offset default in seconds\r\nconst DEFAULT_TOKEN_RENEWAL_OFFSET_SEC = 300;\r\n\r\n/**\r\n * Use the configuration object to configure MSAL Modules and initialize the base interfaces for MSAL.\r\n *\r\n * This object allows you to configure important elements of MSAL functionality:\r\n * - authOptions - Authentication for application\r\n * - cryptoInterface - Implementation of crypto functions\r\n * - libraryInfo - Library metadata\r\n * - loggerOptions - Logging for application\r\n * - networkInterface - Network implementation\r\n * - storageInterface - Storage implementation\r\n * - systemOptions - Additional library options\r\n * - clientCredentials - Credentials options for confidential clients\r\n */\r\nexport type ClientConfiguration = {\r\n authOptions: AuthOptions,\r\n systemOptions?: SystemOptions,\r\n loggerOptions?: LoggerOptions,\r\n storageInterface?: CacheManager,\r\n networkInterface?: INetworkModule,\r\n cryptoInterface?: ICrypto,\r\n clientCredentials?: ClientCredentials,\r\n libraryInfo?: LibraryInfo\r\n serverTelemetryManager?: ServerTelemetryManager | null,\r\n persistencePlugin?: ICachePlugin | null,\r\n serializableCache?: ISerializableTokenCache | null\r\n};\r\n\r\nexport type CommonClientConfiguration = {\r\n authOptions: Required<AuthOptions>,\r\n systemOptions: Required<SystemOptions>,\r\n loggerOptions : Required<LoggerOptions>,\r\n storageInterface: CacheManager,\r\n networkInterface : INetworkModule,\r\n cryptoInterface : Required<ICrypto>,\r\n libraryInfo : LibraryInfo,\r\n serverTelemetryManager: ServerTelemetryManager | null,\r\n clientCredentials: ClientCredentials,\r\n persistencePlugin: ICachePlugin | null,\r\n serializableCache: ISerializableTokenCache | null\r\n};\r\n\r\n/**\r\n * Use this to configure the auth options in the ClientConfiguration object\r\n *\r\n * - clientId - Client ID of your app registered with our Application registration portal : https://portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/RegisteredAppsPreview in Microsoft Identity Platform\r\n * - authority - You can configure a specific authority, defaults to \" \" or \"https://login.microsoftonline.com/common\"\r\n * - knownAuthorities - An array of URIs that are known to be valid. Used in B2C scenarios.\r\n * - cloudDiscoveryMetadata - A string containing the cloud discovery response. Used in AAD scenarios.\r\n * - clientCapabilities - Array of capabilities which will be added to the claims.access_token.xms_cc request property on every network request.\r\n * - protocolMode - Enum that represents the protocol that msal follows. Used for configuring proper endpoints.\r\n */\r\nexport type AuthOptions = {\r\n clientId: string;\r\n authority: Authority;\r\n clientCapabilities?: Array<string>;\r\n};\r\n\r\n/**\r\n * Use this to configure token renewal info in the Configuration object\r\n *\r\n * - tokenRenewalOffsetSeconds - Sets the window of offset needed to renew the token before expiry\r\n */\r\nexport type SystemOptions = {\r\n tokenRenewalOffsetSeconds?: number;\r\n preventCorsPreflight?: boolean;\r\n};\r\n\r\n/**\r\n * Use this to configure the logging that MSAL does, by configuring logger options in the Configuration object\r\n *\r\n * - loggerCallback - Callback for logger\r\n * - piiLoggingEnabled - Sets whether pii logging is enabled\r\n * - logLevel - Sets the level at which logging happens\r\n * - correlationId - Sets the correlationId printed by the logger\r\n */\r\nexport type LoggerOptions = {\r\n loggerCallback?: ILoggerCallback,\r\n piiLoggingEnabled?: boolean,\r\n logLevel?: LogLevel,\r\n correlationId?: string\r\n};\r\n\r\n/**\r\n * Library-specific options\r\n */\r\nexport type LibraryInfo = {\r\n sku: string,\r\n version: string,\r\n cpu: string,\r\n os: string\r\n};\r\n\r\n/**\r\n * Credentials for confidential clients\r\n */\r\nexport type ClientCredentials = {\r\n clientSecret?: string,\r\n clientAssertion? : {\r\n assertion: string,\r\n assertionType: string\r\n };\r\n};\r\n\r\nexport const DEFAULT_SYSTEM_OPTIONS: Required<SystemOptions> = {\r\n tokenRenewalOffsetSeconds: DEFAULT_TOKEN_RENEWAL_OFFSET_SEC,\r\n preventCorsPreflight: false\r\n};\r\n\r\nconst DEFAULT_LOGGER_IMPLEMENTATION: Required<LoggerOptions> = {\r\n loggerCallback: () => {\r\n // allow users to not set loggerCallback\r\n },\r\n piiLoggingEnabled: false,\r\n logLevel: LogLevel.Info,\r\n correlationId: \"\"\r\n};\r\n\r\nconst DEFAULT_NETWORK_IMPLEMENTATION: INetworkModule = {\r\n async sendGetRequestAsync<T>(): Promise<T> {\r\n const notImplErr = \"Network interface - sendGetRequestAsync() has not been implemented\";\r\n throw AuthError.createUnexpectedError(notImplErr);\r\n },\r\n async sendPostRequestAsync<T>(): Promise<T> {\r\n const notImplErr = \"Network interface - sendPostRequestAsync() has not been implemented\";\r\n throw AuthError.createUnexpectedError(notImplErr);\r\n }\r\n};\r\n\r\nconst DEFAULT_LIBRARY_INFO: LibraryInfo = {\r\n sku: Constants.SKU,\r\n version: version,\r\n cpu: \"\",\r\n os: \"\"\r\n};\r\n\r\nconst DEFAULT_CLIENT_CREDENTIALS: ClientCredentials = {\r\n clientSecret: \"\",\r\n clientAssertion: undefined\r\n};\r\n\r\n/**\r\n * Function that sets the default options when not explicitly configured from app developer\r\n *\r\n * @param Configuration\r\n *\r\n * @returns Configuration\r\n */\r\nexport function buildClientConfiguration(\r\n {\r\n authOptions: userAuthOptions,\r\n systemOptions: userSystemOptions,\r\n loggerOptions: userLoggerOption,\r\n storageInterface: storageImplementation,\r\n networkInterface: networkImplementation,\r\n cryptoInterface: cryptoImplementation,\r\n clientCredentials: clientCredentials,\r\n libraryInfo: libraryInfo,\r\n serverTelemetryManager: serverTelemetryManager,\r\n persistencePlugin: persistencePlugin,\r\n serializableCache: serializableCache\r\n }: ClientConfiguration): CommonClientConfiguration {\r\n \r\n const loggerOptions = { ...DEFAULT_LOGGER_IMPLEMENTATION, ...userLoggerOption };\r\n \r\n return {\r\n authOptions: buildAuthOptions(userAuthOptions),\r\n systemOptions: { ...DEFAULT_SYSTEM_OPTIONS, ...userSystemOptions },\r\n loggerOptions: loggerOptions,\r\n storageInterface: storageImplementation || new DefaultStorageClass(userAuthOptions.clientId, DEFAULT_CRYPTO_IMPLEMENTATION),\r\n networkInterface: networkImplementation || DEFAULT_NETWORK_IMPLEMENTATION,\r\n cryptoInterface: cryptoImplementation || DEFAULT_CRYPTO_IMPLEMENTATION,\r\n clientCredentials: clientCredentials || DEFAULT_CLIENT_CREDENTIALS,\r\n libraryInfo: { ...DEFAULT_LIBRARY_INFO, ...libraryInfo },\r\n serverTelemetryManager: serverTelemetryManager || null,\r\n persistencePlugin: persistencePlugin || null,\r\n serializableCache: serializableCache || null\r\n };\r\n}\r\n\r\n/**\r\n * Construct authoptions from the client and platform passed values\r\n * @param authOptions\r\n */\r\nfunction buildAuthOptions(authOptions: AuthOptions): Required<AuthOptions> {\r\n return {\r\n clientCapabilities: [],\r\n ...authOptions\r\n };\r\n}\r\n"],"names":[],"mappings":";;;;;;;;;;AAAA;;;;AAiBA;AACA,IAAM,gCAAgC,GAAG,GAAG,CAAC;IAyGhC,sBAAsB,GAA4B;IAC3D,yBAAyB,EAAE,gCAAgC;IAC3D,oBAAoB,EAAE,KAAK;EAC7B;AAEF,IAAM,6BAA6B,GAA4B;IAC3D,cAAc,EAAE;;KAEf;IACD,iBAAiB,EAAE,KAAK;IACxB,QAAQ,EAAE,QAAQ,CAAC,IAAI;IACvB,aAAa,EAAE,EAAE;CACpB,CAAC;AAEF,IAAM,8BAA8B,GAAmB;IAC7C,mBAAmB,EAAzB;;;;gBACU,UAAU,GAAG,oEAAoE,CAAC;gBACxF,MAAM,SAAS,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;;;KACrD;IACK,oBAAoB,EAA1B;;;;gBACU,UAAU,GAAG,qEAAqE,CAAC;gBACzF,MAAM,SAAS,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;;;KACrD;CACJ,CAAC;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version":3,"file":"ClientConfiguration.js","sources":["../../src/config/ClientConfiguration.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { INetworkModule } from \"../network/INetworkModule\";\nimport { DEFAULT_CRYPTO_IMPLEMENTATION, ICrypto } from \"../crypto/ICrypto\";\nimport { AuthError } from \"../error/AuthError\";\nimport { ILoggerCallback, LogLevel } from \"../logger/Logger\";\nimport { Constants } from \"../utils/Constants\";\nimport { version } from \"../packageMetadata\";\nimport { Authority } from \"../authority/Authority\";\nimport { CacheManager, DefaultStorageClass } from \"../cache/CacheManager\";\nimport { ServerTelemetryManager } from \"../telemetry/server/ServerTelemetryManager\";\nimport { ICachePlugin } from \"../cache/interface/ICachePlugin\";\nimport { ISerializableTokenCache } from \"../cache/interface/ISerializableTokenCache\";\n\n// Token renewal offset default in seconds\nconst DEFAULT_TOKEN_RENEWAL_OFFSET_SEC = 300;\n\n/**\n * Use the configuration object to configure MSAL Modules and initialize the base interfaces for MSAL.\n *\n * This object allows you to configure important elements of MSAL functionality:\n * - authOptions - Authentication for application\n * - cryptoInterface - Implementation of crypto functions\n * - libraryInfo - Library metadata\n * - loggerOptions - Logging for application\n * - networkInterface - Network implementation\n * - storageInterface - Storage implementation\n * - systemOptions - Additional library options\n * - clientCredentials - Credentials options for confidential clients\n */\nexport type ClientConfiguration = {\n authOptions: AuthOptions,\n systemOptions?: SystemOptions,\n loggerOptions?: LoggerOptions,\n storageInterface?: CacheManager,\n networkInterface?: INetworkModule,\n cryptoInterface?: ICrypto,\n clientCredentials?: ClientCredentials,\n libraryInfo?: LibraryInfo\n serverTelemetryManager?: ServerTelemetryManager | null,\n persistencePlugin?: ICachePlugin | null,\n serializableCache?: ISerializableTokenCache | null\n};\n\nexport type CommonClientConfiguration = {\n authOptions: Required<AuthOptions>,\n systemOptions: Required<SystemOptions>,\n loggerOptions : Required<LoggerOptions>,\n storageInterface: CacheManager,\n networkInterface : INetworkModule,\n cryptoInterface : Required<ICrypto>,\n libraryInfo : LibraryInfo,\n serverTelemetryManager: ServerTelemetryManager | null,\n clientCredentials: ClientCredentials,\n persistencePlugin: ICachePlugin | null,\n serializableCache: ISerializableTokenCache | null\n};\n\n/**\n * Use this to configure the auth options in the ClientConfiguration object\n *\n * - clientId - Client ID of your app registered with our Application registration portal : https://portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/RegisteredAppsPreview in Microsoft Identity Platform\n * - authority - You can configure a specific authority, defaults to \" \" or \"https://login.microsoftonline.com/common\"\n * - knownAuthorities - An array of URIs that are known to be valid. Used in B2C scenarios.\n * - cloudDiscoveryMetadata - A string containing the cloud discovery response. Used in AAD scenarios.\n * - clientCapabilities - Array of capabilities which will be added to the claims.access_token.xms_cc request property on every network request.\n * - protocolMode - Enum that represents the protocol that msal follows. Used for configuring proper endpoints.\n */\nexport type AuthOptions = {\n clientId: string;\n authority: Authority;\n clientCapabilities?: Array<string>;\n};\n\n/**\n * Use this to configure token renewal info in the Configuration object\n *\n * - tokenRenewalOffsetSeconds - Sets the window of offset needed to renew the token before expiry\n */\nexport type SystemOptions = {\n tokenRenewalOffsetSeconds?: number;\n preventCorsPreflight?: boolean;\n};\n\n/**\n * Use this to configure the logging that MSAL does, by configuring logger options in the Configuration object\n *\n * - loggerCallback - Callback for logger\n * - piiLoggingEnabled - Sets whether pii logging is enabled\n * - logLevel - Sets the level at which logging happens\n * - correlationId - Sets the correlationId printed by the logger\n */\nexport type LoggerOptions = {\n loggerCallback?: ILoggerCallback,\n piiLoggingEnabled?: boolean,\n logLevel?: LogLevel,\n correlationId?: string\n};\n\n/**\n * Library-specific options\n */\nexport type LibraryInfo = {\n sku: string,\n version: string,\n cpu: string,\n os: string\n};\n\n/**\n * Credentials for confidential clients\n */\nexport type ClientCredentials = {\n clientSecret?: string,\n clientAssertion? : {\n assertion: string,\n assertionType: string\n };\n};\n\nexport const DEFAULT_SYSTEM_OPTIONS: Required<SystemOptions> = {\n tokenRenewalOffsetSeconds: DEFAULT_TOKEN_RENEWAL_OFFSET_SEC,\n preventCorsPreflight: false\n};\n\nconst DEFAULT_LOGGER_IMPLEMENTATION: Required<LoggerOptions> = {\n loggerCallback: () => {\n // allow users to not set loggerCallback\n },\n piiLoggingEnabled: false,\n logLevel: LogLevel.Info,\n correlationId: \"\"\n};\n\nconst DEFAULT_NETWORK_IMPLEMENTATION: INetworkModule = {\n async sendGetRequestAsync<T>(): Promise<T> {\n const notImplErr = \"Network interface - sendGetRequestAsync() has not been implemented\";\n throw AuthError.createUnexpectedError(notImplErr);\n },\n async sendPostRequestAsync<T>(): Promise<T> {\n const notImplErr = \"Network interface - sendPostRequestAsync() has not been implemented\";\n throw AuthError.createUnexpectedError(notImplErr);\n }\n};\n\nconst DEFAULT_LIBRARY_INFO: LibraryInfo = {\n sku: Constants.SKU,\n version: version,\n cpu: \"\",\n os: \"\"\n};\n\nconst DEFAULT_CLIENT_CREDENTIALS: ClientCredentials = {\n clientSecret: \"\",\n clientAssertion: undefined\n};\n\n/**\n * Function that sets the default options when not explicitly configured from app developer\n *\n * @param Configuration\n *\n * @returns Configuration\n */\nexport function buildClientConfiguration(\n {\n authOptions: userAuthOptions,\n systemOptions: userSystemOptions,\n loggerOptions: userLoggerOption,\n storageInterface: storageImplementation,\n networkInterface: networkImplementation,\n cryptoInterface: cryptoImplementation,\n clientCredentials: clientCredentials,\n libraryInfo: libraryInfo,\n serverTelemetryManager: serverTelemetryManager,\n persistencePlugin: persistencePlugin,\n serializableCache: serializableCache\n }: ClientConfiguration): CommonClientConfiguration {\n \n const loggerOptions = { ...DEFAULT_LOGGER_IMPLEMENTATION, ...userLoggerOption };\n \n return {\n authOptions: buildAuthOptions(userAuthOptions),\n systemOptions: { ...DEFAULT_SYSTEM_OPTIONS, ...userSystemOptions },\n loggerOptions: loggerOptions,\n storageInterface: storageImplementation || new DefaultStorageClass(userAuthOptions.clientId, DEFAULT_CRYPTO_IMPLEMENTATION),\n networkInterface: networkImplementation || DEFAULT_NETWORK_IMPLEMENTATION,\n cryptoInterface: cryptoImplementation || DEFAULT_CRYPTO_IMPLEMENTATION,\n clientCredentials: clientCredentials || DEFAULT_CLIENT_CREDENTIALS,\n libraryInfo: { ...DEFAULT_LIBRARY_INFO, ...libraryInfo },\n serverTelemetryManager: serverTelemetryManager || null,\n persistencePlugin: persistencePlugin || null,\n serializableCache: serializableCache || null\n };\n}\n\n/**\n * Construct authoptions from the client and platform passed values\n * @param authOptions\n */\nfunction buildAuthOptions(authOptions: AuthOptions): Required<AuthOptions> {\n return {\n clientCapabilities: [],\n ...authOptions\n };\n}\n"],"names":[],"mappings":";;;;;;;;;;AAAA;;;;AAiBA;AACA,IAAM,gCAAgC,GAAG,GAAG,CAAC;IAyGhC,sBAAsB,GAA4B;IAC3D,yBAAyB,EAAE,gCAAgC;IAC3D,oBAAoB,EAAE,KAAK;EAC7B;AAEF,IAAM,6BAA6B,GAA4B;IAC3D,cAAc,EAAE;;KAEf;IACD,iBAAiB,EAAE,KAAK;IACxB,QAAQ,EAAE,QAAQ,CAAC,IAAI;IACvB,aAAa,EAAE,EAAE;CACpB,CAAC;AAEF,IAAM,8BAA8B,GAAmB;IAC7C,mBAAmB,EAAzB;;;;gBACU,UAAU,GAAG,oEAAoE,CAAC;gBACxF,MAAM,SAAS,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;;;KACrD;IACK,oBAAoB,EAA1B;;;;gBACU,UAAU,GAAG,qEAAqE,CAAC;gBACzF,MAAM,SAAS,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;;;KACrD;CACJ,CAAC;AAEF,IAAM,oBAAoB,GAAgB;IACtC,GAAG,EAAE,SAAS,CAAC,GAAG;IAClB,OAAO,EAAE,OAAO;IAChB,GAAG,EAAE,EAAE;IACP,EAAE,EAAE,EAAE;CACT,CAAC;AAEF,IAAM,0BAA0B,GAAsB;IAClD,YAAY,EAAE,EAAE;IAChB,eAAe,EAAE,SAAS;CAC7B,CAAC;AAEF;;;;;;;SAOgB,wBAAwB,CACpC,EAYsB;QAXL,eAAe,iBAAA,EACb,iBAAiB,mBAAA,EACjB,gBAAgB,mBAAA,EACb,qBAAqB,sBAAA,EACrB,qBAAqB,sBAAA,EACtB,oBAAoB,qBAAA,EAClB,iBAAiB,uBAAA,EACvB,WAAW,iBAAA,EACA,sBAAsB,4BAAA,EAC3B,iBAAiB,uBAAA,EACjB,iBAAiB,uBAAA;IAGxC,IAAM,aAAa,yBAAQ,6BAA6B,GAAK,gBAAgB,CAAE,CAAC;IAEhF,OAAO;QACH,WAAW,EAAE,gBAAgB,CAAC,eAAe,CAAC;QAC9C,aAAa,wBAAO,sBAAsB,GAAK,iBAAiB,CAAE;QAClE,aAAa,EAAE,aAAa;QAC5B,gBAAgB,EAAE,qBAAqB,IAAI,IAAI,mBAAmB,CAAC,eAAe,CAAC,QAAQ,EAAE,6BAA6B,CAAC;QAC3H,gBAAgB,EAAE,qBAAqB,IAAI,8BAA8B;QACzE,eAAe,EAAE,oBAAoB,IAAI,6BAA6B;QACtE,iBAAiB,EAAE,iBAAiB,IAAI,0BAA0B;QAClE,WAAW,wBAAO,oBAAoB,GAAK,WAAW,CAAE;QACxD,sBAAsB,EAAE,sBAAsB,IAAI,IAAI;QACtD,iBAAiB,EAAE,iBAAiB,IAAI,IAAI;QAC5C,iBAAiB,EAAE,iBAAiB,IAAI,IAAI;KAC/C,CAAC;AACN,CAAC;AAED;;;;AAIA,SAAS,gBAAgB,CAAC,WAAwB;IAC9C,kBACI,kBAAkB,EAAE,EAAE,IACnB,WAAW,EAChB;AACN;;;;"}
@@ -9,7 +9,7 @@ export declare type PkceCodes = {
9
9
  verifier: string;
10
10
  challenge: string;
11
11
  };
12
- export declare type SignedHttpRequestParameters = Pick<BaseAuthRequest, "resourceRequestMethod" | "resourceRequestUri" | "shrClaims">;
12
+ export declare type SignedHttpRequestParameters = Pick<BaseAuthRequest, "resourceRequestMethod" | "resourceRequestUri" | "shrClaims" | "shrNonce">;
13
13
  /**
14
14
  * Interface for crypto functions used by library
15
15
  */
@@ -51,6 +51,11 @@ export interface ICrypto {
51
51
  * @param accessToken
52
52
  */
53
53
  signJwt(payload: SignedHttpRequest, kid: string): Promise<string>;
54
+ /**
55
+ * Returns the SHA-256 hash of an input string
56
+ * @param plainText
57
+ */
58
+ hashString(plainText: string): Promise<string>;
54
59
  }
55
60
  export declare const DEFAULT_CRYPTO_IMPLEMENTATION: ICrypto;
56
61
  //# sourceMappingURL=ICrypto.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ICrypto.d.ts","sourceRoot":"","sources":["../../src/crypto/ICrypto.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD;;;;GAIG;AACH,oBAAY,SAAS,GAAG;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAA;CACpB,CAAC;AAEF,oBAAY,2BAA2B,GAAG,IAAI,CAAC,eAAe,EAAE,uBAAuB,GAAG,oBAAoB,GAAG,WAAW,CAAC,CAAC;AAE9H;;GAEG;AACH,MAAM,WAAW,OAAO;IACpB;;OAEG;IACH,aAAa,IAAI,MAAM,CAAC;IACxB;;;OAGG;IACH,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACpC;;;OAGG;IACH,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACpC;;OAEG;IACH,iBAAiB,IAAI,OAAO,CAAC,SAAS,CAAC,CAAC;IACxC;;;OAGG;IACH,sBAAsB,CAAC,OAAO,EAAE,2BAA2B,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC9E;;;OAGG;IACH,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACrD;;OAEG;IACH,aAAa,IAAI,OAAO,CAAC,OAAO,CAAC,C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,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAClD;AAED,eAAO,MAAM,6BAA6B,EAAE,OAqC3C,CAAC"}
@@ -1,4 +1,4 @@
1
- /*! @azure/msal-common v5.0.0 2021-09-08 */
1
+ /*! @azure/msal-common v6.0.0 2022-01-04 */
2
2
  'use strict';
3
3
  import { __awaiter, __generator } from '../_virtual/_tslib.js';
4
4
  import { AuthError } from '../error/AuthError.js';
@@ -64,6 +64,15 @@ var DEFAULT_CRYPTO_IMPLEMENTATION = {
64
64
  throw AuthError.createUnexpectedError(notImplErr);
65
65
  });
66
66
  });
67
+ },
68
+ hashString: function () {
69
+ return __awaiter(this, void 0, void 0, function () {
70
+ var notImplErr;
71
+ return __generator(this, function (_a) {
72
+ notImplErr = "Crypto interface - hashString() has not been implemented";
73
+ throw AuthError.createUnexpectedError(notImplErr);
74
+ });
75
+ });
67
76
  }
68
77
  };
69
78