@azure/identity-cache-persistence 1.1.2-alpha.20241112.1 → 1.1.2-alpha.20241114.2

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 (151) hide show
  1. package/dist/index.js.map +1 -1
  2. package/dist-esm/src/index.js.map +1 -0
  3. package/dist-esm/src/platforms.js.map +1 -0
  4. package/dist-esm/src/provider.js.map +1 -0
  5. package/package.json +3 -4
  6. package/dist-esm/identity/src/client/identityClient.js +0 -257
  7. package/dist-esm/identity/src/client/identityClient.js.map +0 -1
  8. package/dist-esm/identity/src/constants.js +0 -70
  9. package/dist-esm/identity/src/constants.js.map +0 -1
  10. package/dist-esm/identity/src/credentials/authorityValidationOptions.js +0 -4
  11. package/dist-esm/identity/src/credentials/authorityValidationOptions.js.map +0 -1
  12. package/dist-esm/identity/src/credentials/authorizationCodeCredential.js +0 -63
  13. package/dist-esm/identity/src/credentials/authorizationCodeCredential.js.map +0 -1
  14. package/dist-esm/identity/src/credentials/authorizationCodeCredentialOptions.js +0 -4
  15. package/dist-esm/identity/src/credentials/authorizationCodeCredentialOptions.js.map +0 -1
  16. package/dist-esm/identity/src/credentials/azureCliCredential.js +0 -194
  17. package/dist-esm/identity/src/credentials/azureCliCredential.js.map +0 -1
  18. package/dist-esm/identity/src/credentials/azureCliCredentialOptions.js +0 -4
  19. package/dist-esm/identity/src/credentials/azureCliCredentialOptions.js.map +0 -1
  20. package/dist-esm/identity/src/credentials/azureDeveloperCliCredential.js +0 -176
  21. package/dist-esm/identity/src/credentials/azureDeveloperCliCredential.js.map +0 -1
  22. package/dist-esm/identity/src/credentials/azureDeveloperCliCredentialOptions.js +0 -4
  23. package/dist-esm/identity/src/credentials/azureDeveloperCliCredentialOptions.js.map +0 -1
  24. package/dist-esm/identity/src/credentials/azurePipelinesCredential.js +0 -146
  25. package/dist-esm/identity/src/credentials/azurePipelinesCredential.js.map +0 -1
  26. package/dist-esm/identity/src/credentials/azurePipelinesCredentialOptions.js +0 -4
  27. package/dist-esm/identity/src/credentials/azurePipelinesCredentialOptions.js.map +0 -1
  28. package/dist-esm/identity/src/credentials/azurePowerShellCredential.js +0 -238
  29. package/dist-esm/identity/src/credentials/azurePowerShellCredential.js.map +0 -1
  30. package/dist-esm/identity/src/credentials/azurePowerShellCredentialOptions.js +0 -4
  31. package/dist-esm/identity/src/credentials/azurePowerShellCredentialOptions.js.map +0 -1
  32. package/dist-esm/identity/src/credentials/brokerAuthOptions.js +0 -2
  33. package/dist-esm/identity/src/credentials/brokerAuthOptions.js.map +0 -1
  34. package/dist-esm/identity/src/credentials/browserCustomizationOptions.js +0 -4
  35. package/dist-esm/identity/src/credentials/browserCustomizationOptions.js.map +0 -1
  36. package/dist-esm/identity/src/credentials/chainedTokenCredential.js +0 -95
  37. package/dist-esm/identity/src/credentials/chainedTokenCredential.js.map +0 -1
  38. package/dist-esm/identity/src/credentials/clientAssertionCredential.js +0 -58
  39. package/dist-esm/identity/src/credentials/clientAssertionCredential.js.map +0 -1
  40. package/dist-esm/identity/src/credentials/clientAssertionCredentialOptions.js +0 -4
  41. package/dist-esm/identity/src/credentials/clientAssertionCredentialOptions.js.map +0 -1
  42. package/dist-esm/identity/src/credentials/clientCertificateCredential.js +0 -126
  43. package/dist-esm/identity/src/credentials/clientCertificateCredential.js.map +0 -1
  44. package/dist-esm/identity/src/credentials/clientCertificateCredentialOptions.js +0 -4
  45. package/dist-esm/identity/src/credentials/clientCertificateCredentialOptions.js.map +0 -1
  46. package/dist-esm/identity/src/credentials/clientSecretCredential.js +0 -63
  47. package/dist-esm/identity/src/credentials/clientSecretCredential.js.map +0 -1
  48. package/dist-esm/identity/src/credentials/clientSecretCredentialOptions.js +0 -4
  49. package/dist-esm/identity/src/credentials/clientSecretCredentialOptions.js.map +0 -1
  50. package/dist-esm/identity/src/credentials/credentialPersistenceOptions.js +0 -4
  51. package/dist-esm/identity/src/credentials/credentialPersistenceOptions.js.map +0 -1
  52. package/dist-esm/identity/src/credentials/defaultAzureCredential.js +0 -164
  53. package/dist-esm/identity/src/credentials/defaultAzureCredential.js.map +0 -1
  54. package/dist-esm/identity/src/credentials/defaultAzureCredentialOptions.js +0 -4
  55. package/dist-esm/identity/src/credentials/defaultAzureCredentialOptions.js.map +0 -1
  56. package/dist-esm/identity/src/credentials/deviceCodeCredential.js +0 -96
  57. package/dist-esm/identity/src/credentials/deviceCodeCredential.js.map +0 -1
  58. package/dist-esm/identity/src/credentials/deviceCodeCredentialOptions.js +0 -4
  59. package/dist-esm/identity/src/credentials/deviceCodeCredentialOptions.js.map +0 -1
  60. package/dist-esm/identity/src/credentials/environmentCredential.js +0 -133
  61. package/dist-esm/identity/src/credentials/environmentCredential.js.map +0 -1
  62. package/dist-esm/identity/src/credentials/environmentCredentialOptions.js +0 -4
  63. package/dist-esm/identity/src/credentials/environmentCredentialOptions.js.map +0 -1
  64. package/dist-esm/identity/src/credentials/interactiveBrowserCredential.js +0 -96
  65. package/dist-esm/identity/src/credentials/interactiveBrowserCredential.js.map +0 -1
  66. package/dist-esm/identity/src/credentials/interactiveBrowserCredentialOptions.js +0 -4
  67. package/dist-esm/identity/src/credentials/interactiveBrowserCredentialOptions.js.map +0 -1
  68. package/dist-esm/identity/src/credentials/interactiveCredentialOptions.js +0 -4
  69. package/dist-esm/identity/src/credentials/interactiveCredentialOptions.js.map +0 -1
  70. package/dist-esm/identity/src/credentials/managedIdentityCredential/imdsMsi.js +0 -125
  71. package/dist-esm/identity/src/credentials/managedIdentityCredential/imdsMsi.js.map +0 -1
  72. package/dist-esm/identity/src/credentials/managedIdentityCredential/imdsRetryPolicy.js +0 -33
  73. package/dist-esm/identity/src/credentials/managedIdentityCredential/imdsRetryPolicy.js.map +0 -1
  74. package/dist-esm/identity/src/credentials/managedIdentityCredential/index.js +0 -220
  75. package/dist-esm/identity/src/credentials/managedIdentityCredential/index.js.map +0 -1
  76. package/dist-esm/identity/src/credentials/managedIdentityCredential/models.js +0 -4
  77. package/dist-esm/identity/src/credentials/managedIdentityCredential/models.js.map +0 -1
  78. package/dist-esm/identity/src/credentials/managedIdentityCredential/tokenExchangeMsi.js +0 -37
  79. package/dist-esm/identity/src/credentials/managedIdentityCredential/tokenExchangeMsi.js.map +0 -1
  80. package/dist-esm/identity/src/credentials/managedIdentityCredential/utils.js +0 -77
  81. package/dist-esm/identity/src/credentials/managedIdentityCredential/utils.js.map +0 -1
  82. package/dist-esm/identity/src/credentials/multiTenantTokenCredentialOptions.js +0 -4
  83. package/dist-esm/identity/src/credentials/multiTenantTokenCredentialOptions.js.map +0 -1
  84. package/dist-esm/identity/src/credentials/onBehalfOfCredential.js +0 -119
  85. package/dist-esm/identity/src/credentials/onBehalfOfCredential.js.map +0 -1
  86. package/dist-esm/identity/src/credentials/onBehalfOfCredentialOptions.js +0 -4
  87. package/dist-esm/identity/src/credentials/onBehalfOfCredentialOptions.js.map +0 -1
  88. package/dist-esm/identity/src/credentials/usernamePasswordCredential.js +0 -70
  89. package/dist-esm/identity/src/credentials/usernamePasswordCredential.js.map +0 -1
  90. package/dist-esm/identity/src/credentials/usernamePasswordCredentialOptions.js +0 -4
  91. package/dist-esm/identity/src/credentials/usernamePasswordCredentialOptions.js.map +0 -1
  92. package/dist-esm/identity/src/credentials/visualStudioCodeCredential.js +0 -195
  93. package/dist-esm/identity/src/credentials/visualStudioCodeCredential.js.map +0 -1
  94. package/dist-esm/identity/src/credentials/visualStudioCodeCredentialOptions.js +0 -4
  95. package/dist-esm/identity/src/credentials/visualStudioCodeCredentialOptions.js.map +0 -1
  96. package/dist-esm/identity/src/credentials/visualStudioCodeCredentialPlugin.js +0 -4
  97. package/dist-esm/identity/src/credentials/visualStudioCodeCredentialPlugin.js.map +0 -1
  98. package/dist-esm/identity/src/credentials/workloadIdentityCredential.js +0 -119
  99. package/dist-esm/identity/src/credentials/workloadIdentityCredential.js.map +0 -1
  100. package/dist-esm/identity/src/credentials/workloadIdentityCredentialOptions.js +0 -4
  101. package/dist-esm/identity/src/credentials/workloadIdentityCredentialOptions.js.map +0 -1
  102. package/dist-esm/identity/src/errors.js +0 -123
  103. package/dist-esm/identity/src/errors.js.map +0 -1
  104. package/dist-esm/identity/src/index.js +0 -34
  105. package/dist-esm/identity/src/index.js.map +0 -1
  106. package/dist-esm/identity/src/msal/msal.js +0 -5
  107. package/dist-esm/identity/src/msal/msal.js.map +0 -1
  108. package/dist-esm/identity/src/msal/nodeFlows/brokerOptions.js +0 -2
  109. package/dist-esm/identity/src/msal/nodeFlows/brokerOptions.js.map +0 -1
  110. package/dist-esm/identity/src/msal/nodeFlows/msalClient.js +0 -511
  111. package/dist-esm/identity/src/msal/nodeFlows/msalClient.js.map +0 -1
  112. package/dist-esm/identity/src/msal/nodeFlows/msalPlugins.js +0 -87
  113. package/dist-esm/identity/src/msal/nodeFlows/msalPlugins.js.map +0 -1
  114. package/dist-esm/identity/src/msal/nodeFlows/tokenCachePersistenceOptions.js +0 -4
  115. package/dist-esm/identity/src/msal/nodeFlows/tokenCachePersistenceOptions.js.map +0 -1
  116. package/dist-esm/identity/src/msal/types.js +0 -4
  117. package/dist-esm/identity/src/msal/types.js.map +0 -1
  118. package/dist-esm/identity/src/msal/utils.js +0 -232
  119. package/dist-esm/identity/src/msal/utils.js.map +0 -1
  120. package/dist-esm/identity/src/plugins/consumer.js +0 -43
  121. package/dist-esm/identity/src/plugins/consumer.js.map +0 -1
  122. package/dist-esm/identity/src/plugins/provider.js +0 -4
  123. package/dist-esm/identity/src/plugins/provider.js.map +0 -1
  124. package/dist-esm/identity/src/regionalAuthority.js +0 -140
  125. package/dist-esm/identity/src/regionalAuthority.js.map +0 -1
  126. package/dist-esm/identity/src/tokenCredentialOptions.js +0 -4
  127. package/dist-esm/identity/src/tokenCredentialOptions.js.map +0 -1
  128. package/dist-esm/identity/src/tokenProvider.js +0 -55
  129. package/dist-esm/identity/src/tokenProvider.js.map +0 -1
  130. package/dist-esm/identity/src/util/identityTokenEndpoint.js +0 -11
  131. package/dist-esm/identity/src/util/identityTokenEndpoint.js.map +0 -1
  132. package/dist-esm/identity/src/util/logging.js +0 -94
  133. package/dist-esm/identity/src/util/logging.js.map +0 -1
  134. package/dist-esm/identity/src/util/processMultiTenantRequest.js +0 -35
  135. package/dist-esm/identity/src/util/processMultiTenantRequest.js.map +0 -1
  136. package/dist-esm/identity/src/util/processUtils.js +0 -32
  137. package/dist-esm/identity/src/util/processUtils.js.map +0 -1
  138. package/dist-esm/identity/src/util/scopeUtils.js +0 -29
  139. package/dist-esm/identity/src/util/scopeUtils.js.map +0 -1
  140. package/dist-esm/identity/src/util/subscriptionUtils.js +0 -14
  141. package/dist-esm/identity/src/util/subscriptionUtils.js.map +0 -1
  142. package/dist-esm/identity/src/util/tenantIdUtils.js +0 -44
  143. package/dist-esm/identity/src/util/tenantIdUtils.js.map +0 -1
  144. package/dist-esm/identity/src/util/tracing.js +0 -14
  145. package/dist-esm/identity/src/util/tracing.js.map +0 -1
  146. package/dist-esm/identity-cache-persistence/src/index.js.map +0 -1
  147. package/dist-esm/identity-cache-persistence/src/platforms.js.map +0 -1
  148. package/dist-esm/identity-cache-persistence/src/provider.js.map +0 -1
  149. /package/dist-esm/{identity-cache-persistence/src → src}/index.js +0 -0
  150. /package/dist-esm/{identity-cache-persistence/src → src}/platforms.js +0 -0
  151. /package/dist-esm/{identity-cache-persistence/src → src}/provider.js +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"file":"clientCertificateCredential.js","sourceRoot":"","sources":["../../../../../identity/src/credentials/clientCertificateCredential.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAIlC,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AACtD,OAAO,EACL,yBAAyB,EACzB,mCAAmC,GACpC,MAAM,uBAAuB,CAAC;AAI/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,QAAQ,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AAmB;YACnB,UAAU;YACV,GAAG;SACJ,CAAC;IACJ,CAAC;CAAA","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AccessToken, GetTokenOptions, TokenCredential } from \"@azure/core-auth\";\nimport type { MsalClient } from \"../msal/nodeFlows/msalClient\";\nimport { createMsalClient } from \"../msal/nodeFlows/msalClient\";\nimport { createHash, createPrivateKey } from \"crypto\";\nimport {\n processMultiTenantRequest,\n resolveAdditionallyAllowedTenantIds,\n} from \"../util/tenantIdUtils\";\n\nimport type { CertificateParts } from \"../msal/types\";\nimport type { ClientCertificateCredentialOptions } from \"./clientCertificateCredentialOptions\";\nimport { credentialLogger } from \"../util/logging\";\nimport { readFile } from \"fs/promises\";\nimport { tracingClient } from \"../util/tracing\";\n\nconst credentialName = \"ClientCertificateCredential\";\nconst logger = credentialLogger(credentialName);\n\n/**\n * Required configuration options for the {@link ClientCertificateCredential}, with the string contents of a PEM certificate\n */\nexport interface ClientCertificatePEMCertificate {\n /**\n * The PEM-encoded public/private key certificate on the filesystem.\n */\n certificate: string;\n\n /**\n * The password for the certificate file.\n */\n certificatePassword?: string;\n}\n/**\n * Required configuration options for the {@link ClientCertificateCredential}, with the path to a PEM certificate.\n */\nexport interface ClientCertificatePEMCertificatePath {\n /**\n * The path to the PEM-encoded public/private key certificate on the filesystem.\n */\n certificatePath: string;\n\n /**\n * The password for the certificate file.\n */\n certificatePassword?: string;\n}\n/**\n * Required configuration options for the {@link ClientCertificateCredential}, with either the string contents of a PEM certificate, or the path to a PEM certificate.\n */\nexport type ClientCertificateCredentialPEMConfiguration =\n | ClientCertificatePEMCertificate\n | ClientCertificatePEMCertificatePath;\n\n/**\n * Enables authentication to Microsoft Entra ID using a PEM-encoded\n * certificate that is assigned to an App Registration. More information\n * on how to configure certificate authentication can be found here:\n *\n * https://learn.microsoft.com/en-us/azure/active-directory/develop/active-directory-certificate-credentials#register-your-certificate-with-azure-ad\n *\n */\nexport class ClientCertificateCredential implements TokenCredential {\n private tenantId: string;\n private additionallyAllowedTenantIds: string[];\n private certificateConfiguration: ClientCertificateCredentialPEMConfiguration;\n private sendCertificateChain?: boolean;\n private msalClient: MsalClient;\n\n /**\n * Creates an instance of the ClientCertificateCredential with the details\n * needed to authenticate against Microsoft Entra ID with a certificate.\n *\n * @param tenantId - The Microsoft Entra tenant (directory) ID.\n * @param clientId - The client (application) ID of an App Registration in the tenant.\n * @param certificatePath - The path to a PEM-encoded public/private key certificate on the filesystem.\n * @param options - Options for configuring the client which makes the authentication request.\n */\n constructor(\n tenantId: string,\n clientId: string,\n certificatePath: string,\n options?: ClientCertificateCredentialOptions,\n );\n /**\n * Creates an instance of the ClientCertificateCredential with the details\n * needed to authenticate against Microsoft Entra ID with a certificate.\n *\n * @param tenantId - The Microsoft Entra tenant (directory) ID.\n * @param clientId - The client (application) ID of an App Registration in the tenant.\n * @param configuration - Other parameters required, including the path of the certificate on the filesystem.\n * If the type is ignored, we will throw the value of the path to a PEM certificate.\n * @param options - Options for configuring the client which makes the authentication request.\n */\n constructor(\n tenantId: string,\n clientId: string,\n configuration: ClientCertificatePEMCertificatePath,\n options?: ClientCertificateCredentialOptions,\n );\n /**\n * Creates an instance of the ClientCertificateCredential with the details\n * needed to authenticate against Microsoft Entra ID with a certificate.\n *\n * @param tenantId - The Microsoft Entra tenant (directory) ID.\n * @param clientId - The client (application) ID of an App Registration in the tenant.\n * @param configuration - Other parameters required, including the PEM-encoded certificate as a string.\n * If the type is ignored, we will throw the value of the PEM-encoded certificate.\n * @param options - Options for configuring the client which makes the authentication request.\n */\n constructor(\n tenantId: string,\n clientId: string,\n configuration: ClientCertificatePEMCertificate,\n options?: ClientCertificateCredentialOptions,\n );\n constructor(\n tenantId: string,\n clientId: string,\n certificatePathOrConfiguration: string | ClientCertificateCredentialPEMConfiguration,\n options: ClientCertificateCredentialOptions = {},\n ) {\n if (!tenantId || !clientId) {\n throw new Error(`${credentialName}: tenantId and clientId are required parameters.`);\n }\n\n this.tenantId = tenantId;\n this.additionallyAllowedTenantIds = resolveAdditionallyAllowedTenantIds(\n options?.additionallyAllowedTenants,\n );\n\n this.sendCertificateChain = options.sendCertificateChain;\n\n this.certificateConfiguration = {\n ...(typeof certificatePathOrConfiguration === \"string\"\n ? {\n certificatePath: certificatePathOrConfiguration,\n }\n : certificatePathOrConfiguration),\n };\n const certificate: string | undefined = (\n this.certificateConfiguration as ClientCertificatePEMCertificate\n ).certificate;\n const certificatePath: string | undefined = (\n this.certificateConfiguration as ClientCertificatePEMCertificatePath\n ).certificatePath;\n if (!this.certificateConfiguration || !(certificate || certificatePath)) {\n throw new Error(\n `${credentialName}: Provide either a PEM certificate in string form, or the path to that certificate in the filesystem. To troubleshoot, visit https://aka.ms/azsdk/js/identity/serviceprincipalauthentication/troubleshoot.`,\n );\n }\n if (certificate && certificatePath) {\n throw new Error(\n `${credentialName}: To avoid unexpected behaviors, providing both the contents of a PEM certificate and the path to a PEM certificate is forbidden. To troubleshoot, visit https://aka.ms/azsdk/js/identity/serviceprincipalauthentication/troubleshoot.`,\n );\n }\n this.msalClient = createMsalClient(clientId, tenantId, {\n ...options,\n logger,\n tokenCredentialOptions: options,\n });\n }\n\n /**\n * Authenticates with Microsoft Entra ID and returns an access token if successful.\n * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.\n *\n * @param scopes - The list of scopes for which the token will have access.\n * @param options - The options used to configure any requests this\n * TokenCredential implementation might make.\n */\n async getToken(scopes: string | string[], options: GetTokenOptions = {}): Promise<AccessToken> {\n return tracingClient.withSpan(`${credentialName}.getToken`, options, async (newOptions) => {\n newOptions.tenantId = processMultiTenantRequest(\n this.tenantId,\n newOptions,\n this.additionallyAllowedTenantIds,\n logger,\n );\n\n const arrayScopes = Array.isArray(scopes) ? scopes : [scopes];\n const certificate = await this.buildClientCertificate();\n return this.msalClient.getTokenByClientCertificate(arrayScopes, certificate, newOptions);\n });\n }\n\n private async buildClientCertificate(): Promise<CertificateParts> {\n const parts = await parseCertificate(\n this.certificateConfiguration,\n this.sendCertificateChain ?? false,\n );\n\n let privateKey: string;\n if (this.certificateConfiguration.certificatePassword !== undefined) {\n privateKey = createPrivateKey({\n key: parts.certificateContents,\n passphrase: this.certificateConfiguration.certificatePassword,\n format: \"pem\",\n })\n .export({\n format: \"pem\",\n type: \"pkcs8\",\n })\n .toString();\n } else {\n privateKey = parts.certificateContents;\n }\n\n return {\n thumbprint: parts.thumbprint,\n privateKey,\n x5c: parts.x5c,\n };\n }\n}\n\n/**\n * Parses a certificate into its relevant parts\n *\n * @param certificateConfiguration - The certificate contents or path to the certificate\n * @param sendCertificateChain - true if the entire certificate chain should be sent for SNI, false otherwise\n * @returns The parsed certificate parts and the certificate contents\n */\nexport async function parseCertificate(\n certificateConfiguration: ClientCertificateCredentialPEMConfiguration,\n sendCertificateChain: boolean,\n): Promise<Omit<CertificateParts, \"privateKey\"> & { certificateContents: string }> {\n const certificate: string | undefined = (\n certificateConfiguration as ClientCertificatePEMCertificate\n ).certificate;\n const certificatePath: string | undefined = (\n certificateConfiguration as ClientCertificatePEMCertificatePath\n ).certificatePath;\n const certificateContents = certificate || (await readFile(certificatePath!, \"utf8\"));\n const x5c = sendCertificateChain ? certificateContents : undefined;\n\n const certificatePattern =\n /(-+BEGIN CERTIFICATE-+)(\\n\\r?|\\r\\n?)([A-Za-z0-9+/\\n\\r]+=*)(\\n\\r?|\\r\\n?)(-+END CERTIFICATE-+)/g;\n const publicKeys: string[] = [];\n\n // Match all possible certificates, in the order they are in the file. These will form the chain that is used for x5c\n let match;\n do {\n match = certificatePattern.exec(certificateContents);\n if (match) {\n publicKeys.push(match[3]);\n }\n } while (match);\n\n if (publicKeys.length === 0) {\n throw new Error(\"The file at the specified path does not contain a PEM-encoded certificate.\");\n }\n\n const thumbprint = createHash(\"sha1\")\n .update(Buffer.from(publicKeys[0], \"base64\"))\n .digest(\"hex\")\n .toUpperCase();\n\n return {\n certificateContents,\n thumbprint,\n x5c,\n };\n}\n"]}
@@ -1,4 +0,0 @@
1
- // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT License.
3
- export {};
4
- //# sourceMappingURL=clientCertificateCredentialOptions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"clientCertificateCredentialOptions.js","sourceRoot":"","sources":["../../../../../identity/src/credentials/clientCertificateCredentialOptions.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AuthorityValidationOptions } from \"./authorityValidationOptions\";\nimport type { CredentialPersistenceOptions } from \"./credentialPersistenceOptions\";\nimport type { MultiTenantTokenCredentialOptions } from \"./multiTenantTokenCredentialOptions\";\n\n/**\n * Optional parameters for the {@link ClientCertificateCredential} class.\n */\nexport interface ClientCertificateCredentialOptions\n extends MultiTenantTokenCredentialOptions,\n CredentialPersistenceOptions,\n AuthorityValidationOptions {\n /**\n * Option to include x5c header for SubjectName and Issuer name authorization.\n * Set this option to send base64 encoded public certificate in the client assertion header as an x5c claim\n */\n sendCertificateChain?: boolean;\n // TODO: Export again once we're ready to release this feature.\n // /**\n // * Specifies a regional authority. Please refer to the {@link RegionalAuthority} type for the accepted values.\n // * If {@link RegionalAuthority.AutoDiscoverRegion} is specified, we will try to discover the regional authority endpoint.\n // * If the property is not specified, the credential uses the global authority endpoint.\n // */\n // regionalAuthority?: string;\n}\n"]}
@@ -1,63 +0,0 @@
1
- // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT License.
3
- import { __awaiter } from "tslib";
4
- import { createMsalClient } from "../msal/nodeFlows/msalClient";
5
- import { processMultiTenantRequest, resolveAdditionallyAllowedTenantIds, } from "../util/tenantIdUtils";
6
- import { CredentialUnavailableError } from "../errors";
7
- import { credentialLogger } from "../util/logging";
8
- import { ensureScopes } from "../util/scopeUtils";
9
- import { tracingClient } from "../util/tracing";
10
- const logger = credentialLogger("ClientSecretCredential");
11
- /**
12
- * Enables authentication to Microsoft Entra ID using a client secret
13
- * that was generated for an App Registration. More information on how
14
- * to configure a client secret can be found here:
15
- *
16
- * https://learn.microsoft.com/entra/identity-platform/quickstart-configure-app-access-web-apis#add-credentials-to-your-web-application
17
- *
18
- */
19
- export class ClientSecretCredential {
20
- /**
21
- * Creates an instance of the ClientSecretCredential with the details
22
- * needed to authenticate against Microsoft Entra ID with a client
23
- * secret.
24
- *
25
- * @param tenantId - The Microsoft Entra tenant (directory) ID.
26
- * @param clientId - The client (application) ID of an App Registration in the tenant.
27
- * @param clientSecret - A client secret that was generated for the App Registration.
28
- * @param options - Options for configuring the client which makes the authentication request.
29
- */
30
- constructor(tenantId, clientId, clientSecret, options = {}) {
31
- if (!tenantId) {
32
- throw new CredentialUnavailableError("ClientSecretCredential: tenantId is a required parameter. To troubleshoot, visit https://aka.ms/azsdk/js/identity/serviceprincipalauthentication/troubleshoot.");
33
- }
34
- if (!clientId) {
35
- throw new CredentialUnavailableError("ClientSecretCredential: clientId is a required parameter. To troubleshoot, visit https://aka.ms/azsdk/js/identity/serviceprincipalauthentication/troubleshoot.");
36
- }
37
- if (!clientSecret) {
38
- throw new CredentialUnavailableError("ClientSecretCredential: clientSecret is a required parameter. To troubleshoot, visit https://aka.ms/azsdk/js/identity/serviceprincipalauthentication/troubleshoot.");
39
- }
40
- this.clientSecret = clientSecret;
41
- this.tenantId = tenantId;
42
- this.additionallyAllowedTenantIds = resolveAdditionallyAllowedTenantIds(options === null || options === void 0 ? void 0 : options.additionallyAllowedTenants);
43
- this.msalClient = createMsalClient(clientId, tenantId, Object.assign(Object.assign({}, options), { logger, tokenCredentialOptions: options }));
44
- }
45
- /**
46
- * Authenticates with Microsoft Entra ID and returns an access token if successful.
47
- * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
48
- *
49
- * @param scopes - The list of scopes for which the token will have access.
50
- * @param options - The options used to configure any requests this
51
- * TokenCredential implementation might make.
52
- */
53
- getToken(scopes_1) {
54
- return __awaiter(this, arguments, void 0, function* (scopes, options = {}) {
55
- return tracingClient.withSpan(`${this.constructor.name}.getToken`, options, (newOptions) => __awaiter(this, void 0, void 0, function* () {
56
- newOptions.tenantId = processMultiTenantRequest(this.tenantId, newOptions, this.additionallyAllowedTenantIds, logger);
57
- const arrayScopes = ensureScopes(scopes);
58
- return this.msalClient.getTokenByClientSecret(arrayScopes, this.clientSecret, newOptions);
59
- }));
60
- });
61
- }
62
- }
63
- //# sourceMappingURL=clientSecretCredential.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"clientSecretCredential.js","sourceRoot":"","sources":["../../../../../identity/src/credentials/clientSecretCredential.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAIlC,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EACL,yBAAyB,EACzB,mCAAmC,GACpC,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAAE,0BAA0B,EAAE,MAAM,WAAW,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,MAAM,MAAM,GAAG,gBAAgB,CAAC,wBAAwB,CAAC,CAAC;AAE1D;;;;;;;GAOG;AACH,MAAM,OAAO,sBAAsB;IAMjC;;;;;;;;;OASG;IACH,YACE,QAAgB,EAChB,QAAgB,EAChB,YAAoB,EACpB,UAAyC,EAAE;QAE3C,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,IAAI,0BAA0B,CAClC,gKAAgK,CACjK,CAAC;QACJ,CAAC;QAED,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,IAAI,0BAA0B,CAClC,gKAAgK,CACjK,CAAC;QACJ,CAAC;QAED,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB,MAAM,IAAI,0BAA0B,CAClC,oKAAoK,CACrK,CAAC;QACJ,CAAC;QAED,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,4BAA4B,GAAG,mCAAmC,CACrE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,0BAA0B,CACpC,CAAC;QAEF,IAAI,CAAC,UAAU,GAAG,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,kCAChD,OAAO,KACV,MAAM,EACN,sBAAsB,EAAE,OAAO,IAC/B,CAAC;IACL,CAAC;IAED;;;;;;;OAOG;IACG,QAAQ;6DAAC,MAAyB,EAAE,UAA2B,EAAE;YACrE,OAAO,aAAa,CAAC,QAAQ,CAC3B,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,WAAW,EACnC,OAAO,EACP,CAAO,UAAU,EAAE,EAAE;gBACnB,UAAU,CAAC,QAAQ,GAAG,yBAAyB,CAC7C,IAAI,CAAC,QAAQ,EACb,UAAU,EACV,IAAI,CAAC,4BAA4B,EACjC,MAAM,CACP,CAAC;gBAEF,MAAM,WAAW,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;gBACzC,OAAO,IAAI,CAAC,UAAU,CAAC,sBAAsB,CAAC,WAAW,EAAE,IAAI,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;YAC5F,CAAC,CAAA,CACF,CAAC;QACJ,CAAC;KAAA;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AccessToken, GetTokenOptions, TokenCredential } from \"@azure/core-auth\";\nimport type { MsalClient } from \"../msal/nodeFlows/msalClient\";\nimport { createMsalClient } from \"../msal/nodeFlows/msalClient\";\nimport {\n processMultiTenantRequest,\n resolveAdditionallyAllowedTenantIds,\n} from \"../util/tenantIdUtils\";\n\nimport type { ClientSecretCredentialOptions } from \"./clientSecretCredentialOptions\";\nimport { CredentialUnavailableError } from \"../errors\";\nimport { credentialLogger } from \"../util/logging\";\nimport { ensureScopes } from \"../util/scopeUtils\";\nimport { tracingClient } from \"../util/tracing\";\n\nconst logger = credentialLogger(\"ClientSecretCredential\");\n\n/**\n * Enables authentication to Microsoft Entra ID using a client secret\n * that was generated for an App Registration. More information on how\n * to configure a client secret can be found here:\n *\n * https://learn.microsoft.com/entra/identity-platform/quickstart-configure-app-access-web-apis#add-credentials-to-your-web-application\n *\n */\nexport class ClientSecretCredential implements TokenCredential {\n private tenantId: string;\n private additionallyAllowedTenantIds: string[];\n private msalClient: MsalClient;\n private clientSecret: string;\n\n /**\n * Creates an instance of the ClientSecretCredential with the details\n * needed to authenticate against Microsoft Entra ID with a client\n * secret.\n *\n * @param tenantId - The Microsoft Entra tenant (directory) ID.\n * @param clientId - The client (application) ID of an App Registration in the tenant.\n * @param clientSecret - A client secret that was generated for the App Registration.\n * @param options - Options for configuring the client which makes the authentication request.\n */\n constructor(\n tenantId: string,\n clientId: string,\n clientSecret: string,\n options: ClientSecretCredentialOptions = {},\n ) {\n if (!tenantId) {\n throw new CredentialUnavailableError(\n \"ClientSecretCredential: tenantId is a required parameter. To troubleshoot, visit https://aka.ms/azsdk/js/identity/serviceprincipalauthentication/troubleshoot.\",\n );\n }\n\n if (!clientId) {\n throw new CredentialUnavailableError(\n \"ClientSecretCredential: clientId is a required parameter. To troubleshoot, visit https://aka.ms/azsdk/js/identity/serviceprincipalauthentication/troubleshoot.\",\n );\n }\n\n if (!clientSecret) {\n throw new CredentialUnavailableError(\n \"ClientSecretCredential: clientSecret is a required parameter. To troubleshoot, visit https://aka.ms/azsdk/js/identity/serviceprincipalauthentication/troubleshoot.\",\n );\n }\n\n this.clientSecret = clientSecret;\n this.tenantId = tenantId;\n this.additionallyAllowedTenantIds = resolveAdditionallyAllowedTenantIds(\n options?.additionallyAllowedTenants,\n );\n\n this.msalClient = createMsalClient(clientId, tenantId, {\n ...options,\n logger,\n tokenCredentialOptions: options,\n });\n }\n\n /**\n * Authenticates with Microsoft Entra ID and returns an access token if successful.\n * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.\n *\n * @param scopes - The list of scopes for which the token will have access.\n * @param options - The options used to configure any requests this\n * TokenCredential implementation might make.\n */\n async getToken(scopes: string | string[], options: GetTokenOptions = {}): Promise<AccessToken> {\n return tracingClient.withSpan(\n `${this.constructor.name}.getToken`,\n options,\n async (newOptions) => {\n newOptions.tenantId = processMultiTenantRequest(\n this.tenantId,\n newOptions,\n this.additionallyAllowedTenantIds,\n logger,\n );\n\n const arrayScopes = ensureScopes(scopes);\n return this.msalClient.getTokenByClientSecret(arrayScopes, this.clientSecret, newOptions);\n },\n );\n }\n}\n"]}
@@ -1,4 +0,0 @@
1
- // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT License.
3
- export {};
4
- //# sourceMappingURL=clientSecretCredentialOptions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"clientSecretCredentialOptions.js","sourceRoot":"","sources":["../../../../../identity/src/credentials/clientSecretCredentialOptions.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AuthorityValidationOptions } from \"./authorityValidationOptions\";\nimport type { CredentialPersistenceOptions } from \"./credentialPersistenceOptions\";\nimport type { MultiTenantTokenCredentialOptions } from \"./multiTenantTokenCredentialOptions\";\n\n/**\n * Optional parameters for the {@link ClientSecretCredential} class.\n */\nexport interface ClientSecretCredentialOptions\n extends MultiTenantTokenCredentialOptions,\n CredentialPersistenceOptions,\n AuthorityValidationOptions {\n // TODO: Export again once we're ready to release this feature.\n // /**\n // * Specifies a regional authority. Please refer to the {@link RegionalAuthority} type for the accepted values.\n // * If {@link RegionalAuthority.AutoDiscoverRegion} is specified, we will try to discover the regional authority endpoint.\n // * If the property is not specified, the credential uses the global authority endpoint.\n // */\n // regionalAuthority?: string;\n}\n"]}
@@ -1,4 +0,0 @@
1
- // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT License.
3
- export {};
4
- //# sourceMappingURL=credentialPersistenceOptions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"credentialPersistenceOptions.js","sourceRoot":"","sources":["../../../../../identity/src/credentials/credentialPersistenceOptions.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { TokenCachePersistenceOptions } from \"../msal/nodeFlows/tokenCachePersistenceOptions\";\n\n/**\n * Shared configuration options for credentials that support persistent token\n * caching.\n */\nexport interface CredentialPersistenceOptions {\n /**\n * Options to provide to the persistence layer (if one is available) when\n * storing credentials.\n *\n * You must first register a persistence provider plugin. See the\n * `@azure/identity-cache-persistence` package on NPM.\n *\n * Example:\n *\n * ```ts snippet:credential_persistence_options_example\n * import { useIdentityPlugin, DeviceCodeCredential } from \"@azure/identity\";\n *\n * useIdentityPlugin(cachePersistencePlugin);\n * const credential = new DeviceCodeCredential({\n * tokenCachePersistenceOptions: {\n * enabled: true,\n * },\n * });\n * ```\n */\n\n tokenCachePersistenceOptions?: TokenCachePersistenceOptions;\n}\n"]}
@@ -1,164 +0,0 @@
1
- // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT License.
3
- import { ManagedIdentityCredential } from "./managedIdentityCredential";
4
- import { AzureCliCredential } from "./azureCliCredential";
5
- import { AzureDeveloperCliCredential } from "./azureDeveloperCliCredential";
6
- import { AzurePowerShellCredential } from "./azurePowerShellCredential";
7
- import { ChainedTokenCredential } from "./chainedTokenCredential";
8
- import { EnvironmentCredential } from "./environmentCredential";
9
- import { WorkloadIdentityCredential } from "./workloadIdentityCredential";
10
- import { credentialLogger } from "../util/logging";
11
- const logger = credentialLogger("DefaultAzureCredential");
12
- /**
13
- * Creates a {@link ManagedIdentityCredential} from the provided options.
14
- * @param options - Options to configure the credential.
15
- *
16
- * @internal
17
- */
18
- export function createDefaultManagedIdentityCredential(options = {}) {
19
- var _a, _b, _c, _d;
20
- (_a = options.retryOptions) !== null && _a !== void 0 ? _a : (options.retryOptions = {
21
- maxRetries: 5,
22
- retryDelayInMs: 800,
23
- });
24
- const managedIdentityClientId = (_b = options === null || options === void 0 ? void 0 : options.managedIdentityClientId) !== null && _b !== void 0 ? _b : process.env.AZURE_CLIENT_ID;
25
- const workloadIdentityClientId = (_c = options === null || options === void 0 ? void 0 : options.workloadIdentityClientId) !== null && _c !== void 0 ? _c : managedIdentityClientId;
26
- const managedResourceId = options === null || options === void 0 ? void 0 : options.managedIdentityResourceId;
27
- const workloadFile = process.env.AZURE_FEDERATED_TOKEN_FILE;
28
- const tenantId = (_d = options === null || options === void 0 ? void 0 : options.tenantId) !== null && _d !== void 0 ? _d : process.env.AZURE_TENANT_ID;
29
- if (managedResourceId) {
30
- const managedIdentityResourceIdOptions = Object.assign(Object.assign({}, options), { resourceId: managedResourceId });
31
- return new ManagedIdentityCredential(managedIdentityResourceIdOptions);
32
- }
33
- if (workloadFile && workloadIdentityClientId) {
34
- const workloadIdentityCredentialOptions = Object.assign(Object.assign({}, options), { tenantId: tenantId });
35
- return new ManagedIdentityCredential(workloadIdentityClientId, workloadIdentityCredentialOptions);
36
- }
37
- if (managedIdentityClientId) {
38
- const managedIdentityClientOptions = Object.assign(Object.assign({}, options), { clientId: managedIdentityClientId });
39
- return new ManagedIdentityCredential(managedIdentityClientOptions);
40
- }
41
- // We may be able to return a UnavailableCredential here, but that may be a breaking change
42
- return new ManagedIdentityCredential(options);
43
- }
44
- /**
45
- * Creates a {@link WorkloadIdentityCredential} from the provided options.
46
- * @param options - Options to configure the credential.
47
- *
48
- * @internal
49
- */
50
- function createDefaultWorkloadIdentityCredential(options) {
51
- var _a, _b, _c;
52
- const managedIdentityClientId = (_a = options === null || options === void 0 ? void 0 : options.managedIdentityClientId) !== null && _a !== void 0 ? _a : process.env.AZURE_CLIENT_ID;
53
- const workloadIdentityClientId = (_b = options === null || options === void 0 ? void 0 : options.workloadIdentityClientId) !== null && _b !== void 0 ? _b : managedIdentityClientId;
54
- const workloadFile = process.env.AZURE_FEDERATED_TOKEN_FILE;
55
- const tenantId = (_c = options === null || options === void 0 ? void 0 : options.tenantId) !== null && _c !== void 0 ? _c : process.env.AZURE_TENANT_ID;
56
- if (workloadFile && workloadIdentityClientId) {
57
- const workloadIdentityCredentialOptions = Object.assign(Object.assign({}, options), { tenantId, clientId: workloadIdentityClientId, tokenFilePath: workloadFile });
58
- return new WorkloadIdentityCredential(workloadIdentityCredentialOptions);
59
- }
60
- if (tenantId) {
61
- const workloadIdentityClientTenantOptions = Object.assign(Object.assign({}, options), { tenantId });
62
- return new WorkloadIdentityCredential(workloadIdentityClientTenantOptions);
63
- }
64
- // We may be able to return a UnavailableCredential here, but that may be a breaking change
65
- return new WorkloadIdentityCredential(options);
66
- }
67
- /**
68
- * Creates a {@link AzureDeveloperCliCredential} from the provided options.
69
- * @param options - Options to configure the credential.
70
- *
71
- * @internal
72
- */
73
- function createDefaultAzureDeveloperCliCredential(options = {}) {
74
- const processTimeoutInMs = options.processTimeoutInMs;
75
- return new AzureDeveloperCliCredential(Object.assign({ processTimeoutInMs }, options));
76
- }
77
- /**
78
- * Creates a {@link AzureCliCredential} from the provided options.
79
- * @param options - Options to configure the credential.
80
- *
81
- * @internal
82
- */
83
- function createDefaultAzureCliCredential(options = {}) {
84
- const processTimeoutInMs = options.processTimeoutInMs;
85
- return new AzureCliCredential(Object.assign({ processTimeoutInMs }, options));
86
- }
87
- /**
88
- * Creates a {@link AzurePowerShellCredential} from the provided options.
89
- * @param options - Options to configure the credential.
90
- *
91
- * @internal
92
- */
93
- function createDefaultAzurePowershellCredential(options = {}) {
94
- const processTimeoutInMs = options.processTimeoutInMs;
95
- return new AzurePowerShellCredential(Object.assign({ processTimeoutInMs }, options));
96
- }
97
- /**
98
- * Creates an {@link EnvironmentCredential} from the provided options.
99
- * @param options - Options to configure the credential.
100
- *
101
- * @internal
102
- */
103
- export function createEnvironmentCredential(options = {}) {
104
- return new EnvironmentCredential(options);
105
- }
106
- /**
107
- * A no-op credential that logs the reason it was skipped if getToken is called.
108
- * @internal
109
- */
110
- export class UnavailableDefaultCredential {
111
- constructor(credentialName, message) {
112
- this.credentialName = credentialName;
113
- this.credentialUnavailableErrorMessage = message;
114
- }
115
- getToken() {
116
- logger.getToken.info(`Skipping ${this.credentialName}, reason: ${this.credentialUnavailableErrorMessage}`);
117
- return Promise.resolve(null);
118
- }
119
- }
120
- /**
121
- * Provides a default {@link ChainedTokenCredential} configuration that works for most
122
- * applications that use Azure SDK client libraries. For more information, see
123
- * [DefaultAzureCredential overview](https://aka.ms/azsdk/js/identity/credential-chains#use-defaultazurecredential-for-flexibility).
124
- *
125
- * The following credential types will be tried, in order:
126
- *
127
- * - {@link EnvironmentCredential}
128
- * - {@link WorkloadIdentityCredential}
129
- * - {@link ManagedIdentityCredential}
130
- * - {@link AzureCliCredential}
131
- * - {@link AzurePowerShellCredential}
132
- * - {@link AzureDeveloperCliCredential}
133
- *
134
- * Consult the documentation of these credential types for more information
135
- * on how they attempt authentication.
136
- */
137
- export class DefaultAzureCredential extends ChainedTokenCredential {
138
- constructor(options) {
139
- const credentialFunctions = [
140
- createEnvironmentCredential,
141
- createDefaultWorkloadIdentityCredential,
142
- createDefaultManagedIdentityCredential,
143
- createDefaultAzureCliCredential,
144
- createDefaultAzurePowershellCredential,
145
- createDefaultAzureDeveloperCliCredential,
146
- ];
147
- // DefaultCredential constructors should not throw, instead throwing on getToken() which is handled by ChainedTokenCredential.
148
- // When adding new credentials to the default chain, consider:
149
- // 1. Making the constructor parameters required and explicit
150
- // 2. Validating any required parameters in the factory function
151
- // 3. Returning a UnavailableDefaultCredential from the factory function if a credential is unavailable for any reason
152
- const credentials = credentialFunctions.map((createCredentialFn) => {
153
- try {
154
- return createCredentialFn(options);
155
- }
156
- catch (err) {
157
- logger.warning(`Skipped ${createCredentialFn.name} because of an error creating the credential: ${err}`);
158
- return new UnavailableDefaultCredential(createCredentialFn.name, err.message);
159
- }
160
- });
161
- super(...credentials);
162
- }
163
- }
164
- //# sourceMappingURL=defaultAzureCredential.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"defaultAzureCredential.js","sourceRoot":"","sources":["../../../../../identity/src/credentials/defaultAzureCredential.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAWlC,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAExE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAE1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD,MAAM,MAAM,GAAG,gBAAgB,CAAC,wBAAwB,CAAC,CAAC;AAE1D;;;;;GAKG;AACH,MAAM,UAAU,sCAAsC,CACpD,UAG4C,EAAE;;IAE9C,MAAA,OAAO,CAAC,YAAY,oCAApB,OAAO,CAAC,YAAY,GAAK;QACvB,UAAU,EAAE,CAAC;QACb,cAAc,EAAE,GAAG;KACpB,EAAC;IACF,MAAM,uBAAuB,GAC3B,MAAC,OAAiD,aAAjD,OAAO,uBAAP,OAAO,CAA4C,uBAAuB,mCAC3E,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC;IAC9B,MAAM,wBAAwB,GAC5B,MAAC,OAAiD,aAAjD,OAAO,uBAAP,OAAO,CAA4C,wBAAwB,mCAC5E,uBAAuB,CAAC;IAC1B,MAAM,iBAAiB,GAAI,OAAmD,aAAnD,OAAO,uBAAP,OAAO,CAC9B,yBAAyB,CAAC;IAC9B,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC;IAC5D,MAAM,QAAQ,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OAAO,CAAC;IACnD,CAAC;IAED,QAAQ;QACN,MAAM,CAAC,QAAQ,CAAC,IAAI,CAClB,YAAY,IAAI,CAAC,cAAc,aAAa,IAAI,CAAC,iCAAiC,EAAE,CACrF,CAAC;QACF,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;CACF;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAO,sBAAuB,SAAQ,sBAAsB;IAsBhE,YAAY,OAAuC;QACjD,MAAM,mBAAmB,GAAG;YAC1B,2BAA2B;YAC3B,uCAAuC;YACvC,sCAAsC;YACtC,+BAA+B;YAC/B,sCAAsC;YACtC,wCAAwC;SACzC,CAAC;QAEF,8HAA8H;QAE9H,8DAA8D;QAC9D,6DAA6D;QAC7D,gEAAgE;QAChE,sHAAsH;QACtH,MAAM,WAAW,GAAsB,mBAAmB,CAAC,GAAG,CAAC,CAAC,kBAAkB,EAAE,EAAE;YACpF,IAAI,CAAC;gBACH,OAAO,kBAAkB,CAAC,OAAO,CAAC,CAAC;YACrC,CAAC;YAAC,OAAO,GAAQ,EAAE,CAAC;gBAClB,MAAM,CAAC,OAAO,CACZ,WAAW,kBAAkB,CAAC,IAAI,iDAAiD,GAAG,EAAE,CACzF,CAAC;gBACF,OAAO,IAAI,4BAA4B,CAAC,kBAAkB,CAAC,IAAI,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;YAChF,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,KAAK,CAAC,GAAG,WAAW,CAAC,CAAC;IACxB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n DefaultAzureCredentialClientIdOptions,\n DefaultAzureCredentialOptions,\n DefaultAzureCredentialResourceIdOptions,\n} from \"./defaultAzureCredentialOptions\";\nimport type {\n ManagedIdentityCredentialClientIdOptions,\n ManagedIdentityCredentialResourceIdOptions,\n} from \"./managedIdentityCredential\";\nimport { ManagedIdentityCredential } from \"./managedIdentityCredential\";\n\nimport { AzureCliCredential } from \"./azureCliCredential\";\nimport { AzureDeveloperCliCredential } from \"./azureDeveloperCliCredential\";\nimport { AzurePowerShellCredential } from \"./azurePowerShellCredential\";\nimport { ChainedTokenCredential } from \"./chainedTokenCredential\";\nimport { EnvironmentCredential } from \"./environmentCredential\";\nimport type { TokenCredential } from \"@azure/core-auth\";\nimport { WorkloadIdentityCredential } from \"./workloadIdentityCredential\";\nimport type { WorkloadIdentityCredentialOptions } from \"./workloadIdentityCredentialOptions\";\nimport { credentialLogger } from \"../util/logging\";\n\nconst logger = credentialLogger(\"DefaultAzureCredential\");\n\n/**\n * Creates a {@link ManagedIdentityCredential} from the provided options.\n * @param options - Options to configure the credential.\n *\n * @internal\n */\nexport function createDefaultManagedIdentityCredential(\n options:\n | DefaultAzureCredentialOptions\n | DefaultAzureCredentialResourceIdOptions\n | DefaultAzureCredentialClientIdOptions = {},\n): TokenCredential {\n options.retryOptions ??= {\n maxRetries: 5,\n retryDelayInMs: 800,\n };\n const managedIdentityClientId =\n (options as DefaultAzureCredentialClientIdOptions)?.managedIdentityClientId ??\n process.env.AZURE_CLIENT_ID;\n const workloadIdentityClientId =\n (options as DefaultAzureCredentialClientIdOptions)?.workloadIdentityClientId ??\n managedIdentityClientId;\n const managedResourceId = (options as DefaultAzureCredentialResourceIdOptions)\n ?.managedIdentityResourceId;\n const workloadFile = process.env.AZURE_FEDERATED_TOKEN_FILE;\n const tenantId = options?.tenantId ?? process.env.AZURE_TENANT_ID;\n if (managedResourceId) {\n const managedIdentityResourceIdOptions: ManagedIdentityCredentialResourceIdOptions = {\n ...options,\n resourceId: managedResourceId,\n };\n return new ManagedIdentityCredential(managedIdentityResourceIdOptions);\n }\n\n if (workloadFile && workloadIdentityClientId) {\n const workloadIdentityCredentialOptions: DefaultAzureCredentialOptions = {\n ...options,\n tenantId: tenantId,\n };\n\n return new ManagedIdentityCredential(\n workloadIdentityClientId,\n workloadIdentityCredentialOptions,\n );\n }\n\n if (managedIdentityClientId) {\n const managedIdentityClientOptions: ManagedIdentityCredentialClientIdOptions = {\n ...options,\n clientId: managedIdentityClientId,\n };\n\n return new ManagedIdentityCredential(managedIdentityClientOptions);\n }\n\n // We may be able to return a UnavailableCredential here, but that may be a breaking change\n return new ManagedIdentityCredential(options);\n}\n\n/**\n * Creates a {@link WorkloadIdentityCredential} from the provided options.\n * @param options - Options to configure the credential.\n *\n * @internal\n */\nfunction createDefaultWorkloadIdentityCredential(\n options?: DefaultAzureCredentialOptions | DefaultAzureCredentialClientIdOptions,\n): TokenCredential {\n const managedIdentityClientId =\n (options as DefaultAzureCredentialClientIdOptions)?.managedIdentityClientId ??\n process.env.AZURE_CLIENT_ID;\n const workloadIdentityClientId =\n (options as DefaultAzureCredentialClientIdOptions)?.workloadIdentityClientId ??\n managedIdentityClientId;\n const workloadFile = process.env.AZURE_FEDERATED_TOKEN_FILE;\n const tenantId = options?.tenantId ?? process.env.AZURE_TENANT_ID;\n if (workloadFile && workloadIdentityClientId) {\n const workloadIdentityCredentialOptions: WorkloadIdentityCredentialOptions = {\n ...options,\n tenantId,\n clientId: workloadIdentityClientId,\n tokenFilePath: workloadFile,\n };\n return new WorkloadIdentityCredential(workloadIdentityCredentialOptions);\n }\n if (tenantId) {\n const workloadIdentityClientTenantOptions: WorkloadIdentityCredentialOptions = {\n ...options,\n tenantId,\n };\n return new WorkloadIdentityCredential(workloadIdentityClientTenantOptions);\n }\n\n // We may be able to return a UnavailableCredential here, but that may be a breaking change\n return new WorkloadIdentityCredential(options);\n}\n\n/**\n * Creates a {@link AzureDeveloperCliCredential} from the provided options.\n * @param options - Options to configure the credential.\n *\n * @internal\n */\nfunction createDefaultAzureDeveloperCliCredential(\n options: DefaultAzureCredentialOptions = {},\n): TokenCredential {\n const processTimeoutInMs = options.processTimeoutInMs;\n return new AzureDeveloperCliCredential({ processTimeoutInMs, ...options });\n}\n\n/**\n * Creates a {@link AzureCliCredential} from the provided options.\n * @param options - Options to configure the credential.\n *\n * @internal\n */\nfunction createDefaultAzureCliCredential(\n options: DefaultAzureCredentialOptions = {},\n): TokenCredential {\n const processTimeoutInMs = options.processTimeoutInMs;\n return new AzureCliCredential({ processTimeoutInMs, ...options });\n}\n\n/**\n * Creates a {@link AzurePowerShellCredential} from the provided options.\n * @param options - Options to configure the credential.\n *\n * @internal\n */\nfunction createDefaultAzurePowershellCredential(\n options: DefaultAzureCredentialOptions = {},\n): TokenCredential {\n const processTimeoutInMs = options.processTimeoutInMs;\n return new AzurePowerShellCredential({ processTimeoutInMs, ...options });\n}\n\n/**\n * Creates an {@link EnvironmentCredential} from the provided options.\n * @param options - Options to configure the credential.\n *\n * @internal\n */\nexport function createEnvironmentCredential(\n options: DefaultAzureCredentialOptions = {},\n): TokenCredential {\n return new EnvironmentCredential(options);\n}\n\n/**\n * A no-op credential that logs the reason it was skipped if getToken is called.\n * @internal\n */\nexport class UnavailableDefaultCredential implements TokenCredential {\n credentialUnavailableErrorMessage: string;\n credentialName: string;\n\n constructor(credentialName: string, message: string) {\n this.credentialName = credentialName;\n this.credentialUnavailableErrorMessage = message;\n }\n\n getToken(): Promise<null> {\n logger.getToken.info(\n `Skipping ${this.credentialName}, reason: ${this.credentialUnavailableErrorMessage}`,\n );\n return Promise.resolve(null);\n }\n}\n\n/**\n * Provides a default {@link ChainedTokenCredential} configuration that works for most\n * applications that use Azure SDK client libraries. For more information, see\n * [DefaultAzureCredential overview](https://aka.ms/azsdk/js/identity/credential-chains#use-defaultazurecredential-for-flexibility).\n *\n * The following credential types will be tried, in order:\n *\n * - {@link EnvironmentCredential}\n * - {@link WorkloadIdentityCredential}\n * - {@link ManagedIdentityCredential}\n * - {@link AzureCliCredential}\n * - {@link AzurePowerShellCredential}\n * - {@link AzureDeveloperCliCredential}\n *\n * Consult the documentation of these credential types for more information\n * on how they attempt authentication.\n */\nexport class DefaultAzureCredential extends ChainedTokenCredential {\n /**\n * Creates an instance of the DefaultAzureCredential class with {@link DefaultAzureCredentialClientIdOptions}.\n *\n * @param options - Optional parameters. See {@link DefaultAzureCredentialClientIdOptions}.\n */\n constructor(options?: DefaultAzureCredentialClientIdOptions);\n\n /**\n * Creates an instance of the DefaultAzureCredential class with {@link DefaultAzureCredentialResourceIdOptions}.\n *\n * @param options - Optional parameters. See {@link DefaultAzureCredentialResourceIdOptions}.\n */\n constructor(options?: DefaultAzureCredentialResourceIdOptions);\n\n /**\n * Creates an instance of the DefaultAzureCredential class with {@link DefaultAzureCredentialOptions}.\n *\n * @param options - Optional parameters. See {@link DefaultAzureCredentialOptions}.\n */\n constructor(options?: DefaultAzureCredentialOptions);\n\n constructor(options?: DefaultAzureCredentialOptions) {\n const credentialFunctions = [\n createEnvironmentCredential,\n createDefaultWorkloadIdentityCredential,\n createDefaultManagedIdentityCredential,\n createDefaultAzureCliCredential,\n createDefaultAzurePowershellCredential,\n createDefaultAzureDeveloperCliCredential,\n ];\n\n // DefaultCredential constructors should not throw, instead throwing on getToken() which is handled by ChainedTokenCredential.\n\n // When adding new credentials to the default chain, consider:\n // 1. Making the constructor parameters required and explicit\n // 2. Validating any required parameters in the factory function\n // 3. Returning a UnavailableDefaultCredential from the factory function if a credential is unavailable for any reason\n const credentials: TokenCredential[] = credentialFunctions.map((createCredentialFn) => {\n try {\n return createCredentialFn(options);\n } catch (err: any) {\n logger.warning(\n `Skipped ${createCredentialFn.name} because of an error creating the credential: ${err}`,\n );\n return new UnavailableDefaultCredential(createCredentialFn.name, err.message);\n }\n });\n\n super(...credentials);\n }\n}\n"]}
@@ -1,4 +0,0 @@
1
- // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT License.
3
- export {};
4
- //# sourceMappingURL=defaultAzureCredentialOptions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"defaultAzureCredentialOptions.js","sourceRoot":"","sources":["../../../../../identity/src/credentials/defaultAzureCredentialOptions.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AuthorityValidationOptions } from \"./authorityValidationOptions\";\nimport type { MultiTenantTokenCredentialOptions } from \"./multiTenantTokenCredentialOptions\";\n\n/**\n * Provides options to configure the {@link DefaultAzureCredential} class.\n * This variation supports `managedIdentityClientId` and not `managedIdentityResourceId`, since only one of both is supported.\n */\nexport interface DefaultAzureCredentialClientIdOptions extends DefaultAzureCredentialOptions {\n /**\n * Optionally pass in a user assigned client ID to be used by the {@link ManagedIdentityCredential}.\n * This client ID can also be passed through to the {@link ManagedIdentityCredential} through the environment variable: AZURE_CLIENT_ID.\n */\n managedIdentityClientId?: string;\n /**\n * Optionally pass in a user assigned client ID to be used by the {@link WorkloadIdentityCredential}.\n * This client ID can also be passed through to the {@link WorkloadIdentityCredential} through the environment variable: AZURE_CLIENT_ID.\n */\n workloadIdentityClientId?: string;\n}\n\n/**\n * Provides options to configure the {@link DefaultAzureCredential} class.\n * This variation supports `managedIdentityResourceId` and not `managedIdentityClientId`, since only one of both is supported.\n */\nexport interface DefaultAzureCredentialResourceIdOptions extends DefaultAzureCredentialOptions {\n /**\n * Optionally pass in a resource ID to be used by the {@link ManagedIdentityCredential}.\n * In scenarios such as when user assigned identities are created using an ARM template,\n * where the resource Id of the identity is known but the client Id can't be known ahead of time,\n * this parameter allows programs to use these user assigned identities\n * without having to first determine the client Id of the created identity.\n */\n managedIdentityResourceId: string;\n}\n\n/**\n * Provides options to configure the {@link DefaultAzureCredential} class.\n */\nexport interface DefaultAzureCredentialOptions\n extends MultiTenantTokenCredentialOptions,\n AuthorityValidationOptions {\n /**\n * Optionally pass in a Tenant ID to be used as part of the credential.\n * By default it may use a generic tenant ID depending on the underlying credential.\n */\n tenantId?: string;\n\n /**\n * Timeout configurable for making token requests for developer credentials, namely, {@link AzurePowershellCredential},\n * {@link AzureDeveloperCliCredential} and {@link AzureCliCredential}.\n * Process timeout for credentials should be provided in milliseconds.\n */\n processTimeoutInMs?: number;\n}\n"]}
@@ -1,96 +0,0 @@
1
- // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT License.
3
- import { __awaiter } from "tslib";
4
- import { processMultiTenantRequest, resolveAdditionallyAllowedTenantIds, resolveTenantId, } from "../util/tenantIdUtils";
5
- import { credentialLogger } from "../util/logging";
6
- import { ensureScopes } from "../util/scopeUtils";
7
- import { tracingClient } from "../util/tracing";
8
- import { createMsalClient } from "../msal/nodeFlows/msalClient";
9
- import { DeveloperSignOnClientId } from "../constants";
10
- const logger = credentialLogger("DeviceCodeCredential");
11
- /**
12
- * Method that logs the user code from the DeviceCodeCredential.
13
- * @param deviceCodeInfo - The device code.
14
- */
15
- export function defaultDeviceCodePromptCallback(deviceCodeInfo) {
16
- console.log(deviceCodeInfo.message);
17
- }
18
- /**
19
- * Enables authentication to Microsoft Entra ID using a device code
20
- * that the user can enter into https://microsoft.com/devicelogin.
21
- */
22
- export class DeviceCodeCredential {
23
- /**
24
- * Creates an instance of DeviceCodeCredential with the details needed
25
- * to initiate the device code authorization flow with Microsoft Entra ID.
26
- *
27
- * A message will be logged, giving users a code that they can use to authenticate once they go to https://microsoft.com/devicelogin
28
- *
29
- * Developers can configure how this message is shown by passing a custom `userPromptCallback`:
30
- *
31
- * ```ts snippet:device_code_credential_example
32
- * import { DeviceCodeCredential } from "@azure/identity";
33
- *
34
- * const credential = new DeviceCodeCredential({
35
- * tenantId: process.env.AZURE_TENANT_ID,
36
- * clientId: process.env.AZURE_CLIENT_ID,
37
- * userPromptCallback: (info) => {
38
- * console.log("CUSTOMIZED PROMPT CALLBACK", info.message);
39
- * },
40
- * });
41
- * ```
42
- *
43
- * @param options - Options for configuring the client which makes the authentication requests.
44
- */
45
- constructor(options) {
46
- var _a, _b;
47
- this.tenantId = options === null || options === void 0 ? void 0 : options.tenantId;
48
- this.additionallyAllowedTenantIds = resolveAdditionallyAllowedTenantIds(options === null || options === void 0 ? void 0 : options.additionallyAllowedTenants);
49
- const clientId = (_a = options === null || options === void 0 ? void 0 : options.clientId) !== null && _a !== void 0 ? _a : DeveloperSignOnClientId;
50
- const tenantId = resolveTenantId(logger, options === null || options === void 0 ? void 0 : options.tenantId, clientId);
51
- this.userPromptCallback = (_b = options === null || options === void 0 ? void 0 : options.userPromptCallback) !== null && _b !== void 0 ? _b : defaultDeviceCodePromptCallback;
52
- this.msalClient = createMsalClient(clientId, tenantId, Object.assign(Object.assign({}, options), { logger, tokenCredentialOptions: options || {} }));
53
- this.disableAutomaticAuthentication = options === null || options === void 0 ? void 0 : options.disableAutomaticAuthentication;
54
- }
55
- /**
56
- * Authenticates with Microsoft Entra ID and returns an access token if successful.
57
- * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
58
- *
59
- * If the user provided the option `disableAutomaticAuthentication`,
60
- * once the token can't be retrieved silently,
61
- * this method won't attempt to request user interaction to retrieve the token.
62
- *
63
- * @param scopes - The list of scopes for which the token will have access.
64
- * @param options - The options used to configure any requests this
65
- * TokenCredential implementation might make.
66
- */
67
- getToken(scopes_1) {
68
- return __awaiter(this, arguments, void 0, function* (scopes, options = {}) {
69
- return tracingClient.withSpan(`${this.constructor.name}.getToken`, options, (newOptions) => __awaiter(this, void 0, void 0, function* () {
70
- newOptions.tenantId = processMultiTenantRequest(this.tenantId, newOptions, this.additionallyAllowedTenantIds, logger);
71
- const arrayScopes = ensureScopes(scopes);
72
- return this.msalClient.getTokenByDeviceCode(arrayScopes, this.userPromptCallback, Object.assign(Object.assign({}, newOptions), { disableAutomaticAuthentication: this.disableAutomaticAuthentication }));
73
- }));
74
- });
75
- }
76
- /**
77
- * Authenticates with Microsoft Entra ID and returns an access token if successful.
78
- * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
79
- *
80
- * If the token can't be retrieved silently, this method will always generate a challenge for the user.
81
- *
82
- * @param scopes - The list of scopes for which the token will have access.
83
- * @param options - The options used to configure any requests this
84
- * TokenCredential implementation might make.
85
- */
86
- authenticate(scopes_1) {
87
- return __awaiter(this, arguments, void 0, function* (scopes, options = {}) {
88
- return tracingClient.withSpan(`${this.constructor.name}.authenticate`, options, (newOptions) => __awaiter(this, void 0, void 0, function* () {
89
- const arrayScopes = Array.isArray(scopes) ? scopes : [scopes];
90
- yield this.msalClient.getTokenByDeviceCode(arrayScopes, this.userPromptCallback, Object.assign(Object.assign({}, newOptions), { disableAutomaticAuthentication: false }));
91
- return this.msalClient.getActiveAccount();
92
- }));
93
- });
94
- }
95
- }
96
- //# sourceMappingURL=deviceCodeCredential.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"deviceCodeCredential.js","sourceRoot":"","sources":["../../../../../identity/src/credentials/deviceCodeCredential.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAGlC,OAAO,EACL,yBAAyB,EACzB,mCAAmC,EACnC,eAAe,GAChB,MAAM,uBAAuB,CAAC;AAO/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAEvD,MAAM,MAAM,GAAG,gBAAgB,CAAC,sBAAsB,CAAC,CAAC;AAExD;;;GAGG;AACH,MAAM,UAAU,+BAA+B,CAAC,cAA8B;IAC5E,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;AACtC,CAAC;AAED;;;GAGG;AACH,MAAM,OAAO,oBAAoB;IAO/B;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,YAAY,OAAqC;;QAC/C,IAAI,CAAC,QAAQ,GAAG,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,QAAQ,CAAC;QAClC,IAAI,CAAC,4BAA4B,GAAG,mCAAmC,CACrE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,0BAA0B,CACpC,CAA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AG,IAAI,CAAC,WAAW,CAAC,IAAI,eAAe,EACvC,OAAO,EACP,CAAO,UAAU,EAAE,EAAE;gBACnB,MAAM,WAAW,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;gBAC9D,MAAM,IAAI,CAAC,UAAU,CAAC,oBAAoB,CAAC,WAAW,EAAE,IAAI,CAAC,kBAAkB,kCAC1E,UAAU,KACb,8BAA8B,EAAE,KAAK,IACrC,CAAC;gBACH,OAAO,IAAI,CAAC,UAAU,CAAC,gBAAgB,EAAE,CAAC;YAC5C,CAAC,CAAA,CACF,CAAC;QACJ,CAAC;KAAA;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AccessToken, GetTokenOptions, TokenCredential } from \"@azure/core-auth\";\nimport {\n processMultiTenantRequest,\n resolveAdditionallyAllowedTenantIds,\n resolveTenantId,\n} from \"../util/tenantIdUtils\";\nimport type {\n DeviceCodeCredentialOptions,\n DeviceCodeInfo,\n DeviceCodePromptCallback,\n} from \"./deviceCodeCredentialOptions\";\nimport type { AuthenticationRecord } from \"../msal/types\";\nimport { credentialLogger } from \"../util/logging\";\nimport { ensureScopes } from \"../util/scopeUtils\";\nimport { tracingClient } from \"../util/tracing\";\nimport type { MsalClient } from \"../msal/nodeFlows/msalClient\";\nimport { createMsalClient } from \"../msal/nodeFlows/msalClient\";\nimport { DeveloperSignOnClientId } from \"../constants\";\n\nconst logger = credentialLogger(\"DeviceCodeCredential\");\n\n/**\n * Method that logs the user code from the DeviceCodeCredential.\n * @param deviceCodeInfo - The device code.\n */\nexport function defaultDeviceCodePromptCallback(deviceCodeInfo: DeviceCodeInfo): void {\n console.log(deviceCodeInfo.message);\n}\n\n/**\n * Enables authentication to Microsoft Entra ID using a device code\n * that the user can enter into https://microsoft.com/devicelogin.\n */\nexport class DeviceCodeCredential implements TokenCredential {\n private tenantId?: string;\n private additionallyAllowedTenantIds: string[];\n private disableAutomaticAuthentication?: boolean;\n private msalClient: MsalClient;\n private userPromptCallback: DeviceCodePromptCallback;\n\n /**\n * Creates an instance of DeviceCodeCredential with the details needed\n * to initiate the device code authorization flow with Microsoft Entra ID.\n *\n * A message will be logged, giving users a code that they can use to authenticate once they go to https://microsoft.com/devicelogin\n *\n * Developers can configure how this message is shown by passing a custom `userPromptCallback`:\n *\n * ```ts snippet:device_code_credential_example\n * import { DeviceCodeCredential } from \"@azure/identity\";\n *\n * const credential = new DeviceCodeCredential({\n * tenantId: process.env.AZURE_TENANT_ID,\n * clientId: process.env.AZURE_CLIENT_ID,\n * userPromptCallback: (info) => {\n * console.log(\"CUSTOMIZED PROMPT CALLBACK\", info.message);\n * },\n * });\n * ```\n *\n * @param options - Options for configuring the client which makes the authentication requests.\n */\n constructor(options?: DeviceCodeCredentialOptions) {\n this.tenantId = options?.tenantId;\n this.additionallyAllowedTenantIds = resolveAdditionallyAllowedTenantIds(\n options?.additionallyAllowedTenants,\n );\n const clientId = options?.clientId ?? DeveloperSignOnClientId;\n const tenantId = resolveTenantId(logger, options?.tenantId, clientId);\n this.userPromptCallback = options?.userPromptCallback ?? defaultDeviceCodePromptCallback;\n this.msalClient = createMsalClient(clientId, tenantId, {\n ...options,\n logger,\n tokenCredentialOptions: options || {},\n });\n this.disableAutomaticAuthentication = options?.disableAutomaticAuthentication;\n }\n\n /**\n * Authenticates with Microsoft Entra ID and returns an access token if successful.\n * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.\n *\n * If the user provided the option `disableAutomaticAuthentication`,\n * once the token can't be retrieved silently,\n * this method won't attempt to request user interaction to retrieve the token.\n *\n * @param scopes - The list of scopes for which the token will have access.\n * @param options - The options used to configure any requests this\n * TokenCredential implementation might make.\n */\n async getToken(scopes: string | string[], options: GetTokenOptions = {}): Promise<AccessToken> {\n return tracingClient.withSpan(\n `${this.constructor.name}.getToken`,\n options,\n async (newOptions) => {\n newOptions.tenantId = processMultiTenantRequest(\n this.tenantId,\n newOptions,\n this.additionallyAllowedTenantIds,\n logger,\n );\n\n const arrayScopes = ensureScopes(scopes);\n return this.msalClient.getTokenByDeviceCode(arrayScopes, this.userPromptCallback, {\n ...newOptions,\n disableAutomaticAuthentication: this.disableAutomaticAuthentication,\n });\n },\n );\n }\n\n /**\n * Authenticates with Microsoft Entra ID and returns an access token if successful.\n * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.\n *\n * If the token can't be retrieved silently, this method will always generate a challenge for the user.\n *\n * @param scopes - The list of scopes for which the token will have access.\n * @param options - The options used to configure any requests this\n * TokenCredential implementation might make.\n */\n async authenticate(\n scopes: string | string[],\n options: GetTokenOptions = {},\n ): Promise<AuthenticationRecord | undefined> {\n return tracingClient.withSpan(\n `${this.constructor.name}.authenticate`,\n options,\n async (newOptions) => {\n const arrayScopes = Array.isArray(scopes) ? scopes : [scopes];\n await this.msalClient.getTokenByDeviceCode(arrayScopes, this.userPromptCallback, {\n ...newOptions,\n disableAutomaticAuthentication: false, // this method should always allow user interaction\n });\n return this.msalClient.getActiveAccount();\n },\n );\n }\n}\n"]}
@@ -1,4 +0,0 @@
1
- // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT License.
3
- export {};
4
- //# sourceMappingURL=deviceCodeCredentialOptions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"deviceCodeCredentialOptions.js","sourceRoot":"","sources":["../../../../../identity/src/credentials/deviceCodeCredentialOptions.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { CredentialPersistenceOptions } from \"./credentialPersistenceOptions\";\nimport type { InteractiveCredentialOptions } from \"./interactiveCredentialOptions\";\n\n/**\n * Provides the user code and verification URI where the code must be\n * entered. Also provides a message to display to the user which\n * contains an instruction with these details.\n */\nexport interface DeviceCodeInfo {\n /**\n * The device code that the user must enter into the verification page.\n */\n userCode: string;\n\n /**\n * The verification URI to which the user must navigate to enter the device\n * code.\n */\n verificationUri: string;\n\n /**\n * A message that may be shown to the user to instruct them on how to enter\n * the device code in the page specified by the verification URI.\n */\n message: string;\n}\n\n/**\n * Defines the signature of a callback which will be passed to\n * DeviceCodeCredential for the purpose of displaying authentication\n * details to the user.\n */\nexport type DeviceCodePromptCallback = (deviceCodeInfo: DeviceCodeInfo) => void;\n\n/**\n * Defines options for the InteractiveBrowserCredential class for Node.js.\n */\nexport interface DeviceCodeCredentialOptions\n extends InteractiveCredentialOptions,\n CredentialPersistenceOptions {\n /**\n * The Microsoft Entra tenant (directory) ID.\n */\n tenantId?: string;\n /**\n * Client ID of the Microsoft Entra application that users will sign into.\n * It is recommended that developers register their applications and assign appropriate roles.\n * For more information, visit https://aka.ms/identity/AppRegistrationAndRoleAssignment.\n * If not specified, users will authenticate to an Azure development application,\n * which is not recommended for production scenarios.\n */\n clientId?: string;\n /**\n * A callback function that will be invoked to show {@link DeviceCodeInfo} to the user.\n * If left unassigned, we will automatically log the device code information\n * and the authentication instructions in the console.\n */\n userPromptCallback?: DeviceCodePromptCallback;\n}\n"]}