@azure/identity 4.8.1-alpha.20250410.1 → 4.9.1-alpha.20250416.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/constants.d.ts +1 -1
- package/dist/browser/constants.js +1 -1
- package/dist/browser/constants.js.map +1 -1
- package/dist/commonjs/constants.d.ts +1 -1
- package/dist/commonjs/constants.js +1 -1
- package/dist/commonjs/constants.js.map +1 -1
- package/dist/esm/constants.d.ts +1 -1
- package/dist/esm/constants.js +1 -1
- package/dist/esm/constants.js.map +1 -1
- package/dist/workerd/client/identityClient.d.ts +65 -0
- package/dist/workerd/client/identityClient.d.ts.map +1 -0
- package/dist/workerd/client/identityClient.js +248 -0
- package/dist/workerd/client/identityClient.js.map +1 -0
- package/dist/workerd/constants.d.ts +69 -0
- package/dist/workerd/constants.d.ts.map +1 -0
- package/dist/workerd/constants.js +75 -0
- package/dist/workerd/constants.js.map +1 -0
- package/dist/workerd/credentials/authorityValidationOptions.d.ts +16 -0
- package/dist/workerd/credentials/authorityValidationOptions.d.ts.map +1 -0
- package/dist/workerd/credentials/authorityValidationOptions.js +4 -0
- package/dist/workerd/credentials/authorityValidationOptions.js.map +1 -0
- package/dist/workerd/credentials/authorizationCodeCredential.d.ts +73 -0
- package/dist/workerd/credentials/authorizationCodeCredential.d.ts.map +1 -0
- package/dist/workerd/credentials/authorizationCodeCredential.js +60 -0
- package/dist/workerd/credentials/authorizationCodeCredential.js.map +1 -0
- package/dist/workerd/credentials/authorizationCodeCredentialOptions.d.ts +8 -0
- package/dist/workerd/credentials/authorizationCodeCredentialOptions.d.ts.map +1 -0
- package/dist/workerd/credentials/authorizationCodeCredentialOptions.js +4 -0
- package/dist/workerd/credentials/authorizationCodeCredentialOptions.js.map +1 -0
- package/dist/workerd/credentials/azureApplicationCredential.d.ts +24 -0
- package/dist/workerd/credentials/azureApplicationCredential.d.ts.map +1 -0
- package/dist/workerd/credentials/azureApplicationCredential.js +32 -0
- package/dist/workerd/credentials/azureApplicationCredential.js.map +1 -0
- package/dist/workerd/credentials/azureApplicationCredentialOptions.d.ts +13 -0
- package/dist/workerd/credentials/azureApplicationCredentialOptions.d.ts.map +1 -0
- package/dist/workerd/credentials/azureApplicationCredentialOptions.js +4 -0
- package/dist/workerd/credentials/azureApplicationCredentialOptions.js.map +1 -0
- package/dist/workerd/credentials/azureCliCredential.d.ts +64 -0
- package/dist/workerd/credentials/azureCliCredential.d.ts.map +1 -0
- package/dist/workerd/credentials/azureCliCredential.js +191 -0
- package/dist/workerd/credentials/azureCliCredential.js.map +1 -0
- package/dist/workerd/credentials/azureCliCredentialOptions.d.ts +20 -0
- package/dist/workerd/credentials/azureCliCredentialOptions.d.ts.map +1 -0
- package/dist/workerd/credentials/azureCliCredentialOptions.js +4 -0
- package/dist/workerd/credentials/azureCliCredentialOptions.js.map +1 -0
- package/dist/workerd/credentials/azureDeveloperCliCredential.d.ts +71 -0
- package/dist/workerd/credentials/azureDeveloperCliCredential.d.ts.map +1 -0
- package/dist/workerd/credentials/azureDeveloperCliCredential.js +173 -0
- package/dist/workerd/credentials/azureDeveloperCliCredential.js.map +1 -0
- package/dist/workerd/credentials/azureDeveloperCliCredentialOptions.d.ts +15 -0
- package/dist/workerd/credentials/azureDeveloperCliCredentialOptions.d.ts.map +1 -0
- package/dist/workerd/credentials/azureDeveloperCliCredentialOptions.js +4 -0
- package/dist/workerd/credentials/azureDeveloperCliCredentialOptions.js.map +1 -0
- package/dist/workerd/credentials/azurePipelinesCredential.d.ts +38 -0
- package/dist/workerd/credentials/azurePipelinesCredential.d.ts.map +1 -0
- package/dist/workerd/credentials/azurePipelinesCredential.js +141 -0
- package/dist/workerd/credentials/azurePipelinesCredential.js.map +1 -0
- package/dist/workerd/credentials/azurePipelinesCredentialOptions.d.ts +9 -0
- package/dist/workerd/credentials/azurePipelinesCredentialOptions.d.ts.map +1 -0
- package/dist/workerd/credentials/azurePipelinesCredentialOptions.js +4 -0
- package/dist/workerd/credentials/azurePipelinesCredentialOptions.js.map +1 -0
- package/dist/workerd/credentials/azurePowerShellCredential.d.ts +75 -0
- package/dist/workerd/credentials/azurePowerShellCredential.d.ts.map +1 -0
- package/dist/workerd/credentials/azurePowerShellCredential.js +229 -0
- package/dist/workerd/credentials/azurePowerShellCredential.js.map +1 -0
- package/dist/workerd/credentials/azurePowerShellCredentialOptions.d.ts +15 -0
- package/dist/workerd/credentials/azurePowerShellCredentialOptions.d.ts.map +1 -0
- package/dist/workerd/credentials/azurePowerShellCredentialOptions.js +4 -0
- package/dist/workerd/credentials/azurePowerShellCredentialOptions.js.map +1 -0
- package/dist/workerd/credentials/brokerAuthOptions.d.ts +13 -0
- package/dist/workerd/credentials/brokerAuthOptions.d.ts.map +1 -0
- package/dist/workerd/credentials/brokerAuthOptions.js +2 -0
- package/dist/workerd/credentials/brokerAuthOptions.js.map +1 -0
- package/dist/workerd/credentials/browserCustomizationOptions.d.ts +19 -0
- package/dist/workerd/credentials/browserCustomizationOptions.d.ts.map +1 -0
- package/dist/workerd/credentials/browserCustomizationOptions.js +4 -0
- package/dist/workerd/credentials/browserCustomizationOptions.js.map +1 -0
- package/dist/workerd/credentials/chainedTokenCredential.d.ts +51 -0
- package/dist/workerd/credentials/chainedTokenCredential.d.ts.map +1 -0
- package/dist/workerd/credentials/chainedTokenCredential.js +92 -0
- package/dist/workerd/credentials/chainedTokenCredential.js.map +1 -0
- package/dist/workerd/credentials/clientAssertionCredential.d.ts +33 -0
- package/dist/workerd/credentials/clientAssertionCredential.d.ts.map +1 -0
- package/dist/workerd/credentials/clientAssertionCredential.js +55 -0
- package/dist/workerd/credentials/clientAssertionCredential.js.map +1 -0
- package/dist/workerd/credentials/clientAssertionCredentialOptions.d.ts +9 -0
- package/dist/workerd/credentials/clientAssertionCredentialOptions.d.ts.map +1 -0
- package/dist/workerd/credentials/clientAssertionCredentialOptions.js +4 -0
- package/dist/workerd/credentials/clientAssertionCredentialOptions.js.map +1 -0
- package/dist/workerd/credentials/clientCertificateCredential.d.ts +72 -0
- package/dist/workerd/credentials/clientCertificateCredential.d.ts.map +1 -0
- package/dist/workerd/credentials/clientCertificateCredential.js +122 -0
- package/dist/workerd/credentials/clientCertificateCredential.js.map +1 -0
- package/dist/workerd/credentials/clientCertificateCredentialModels.d.ts +31 -0
- package/dist/workerd/credentials/clientCertificateCredentialModels.d.ts.map +1 -0
- package/dist/workerd/credentials/clientCertificateCredentialModels.js +4 -0
- package/dist/workerd/credentials/clientCertificateCredentialModels.js.map +1 -0
- package/dist/workerd/credentials/clientCertificateCredentialOptions.d.ts +14 -0
- package/dist/workerd/credentials/clientCertificateCredentialOptions.d.ts.map +1 -0
- package/dist/workerd/credentials/clientCertificateCredentialOptions.js +4 -0
- package/dist/workerd/credentials/clientCertificateCredentialOptions.js.map +1 -0
- package/dist/workerd/credentials/clientSecretCredential.d.ts +37 -0
- package/dist/workerd/credentials/clientSecretCredential.d.ts.map +1 -0
- package/dist/workerd/credentials/clientSecretCredential.js +60 -0
- package/dist/workerd/credentials/clientSecretCredential.js.map +1 -0
- package/dist/workerd/credentials/clientSecretCredentialOptions.d.ts +9 -0
- package/dist/workerd/credentials/clientSecretCredentialOptions.d.ts.map +1 -0
- package/dist/workerd/credentials/clientSecretCredentialOptions.js +4 -0
- package/dist/workerd/credentials/clientSecretCredentialOptions.js.map +1 -0
- package/dist/workerd/credentials/credentialPersistenceOptions.d.ts +30 -0
- package/dist/workerd/credentials/credentialPersistenceOptions.d.ts.map +1 -0
- package/dist/workerd/credentials/credentialPersistenceOptions.js +4 -0
- package/dist/workerd/credentials/credentialPersistenceOptions.js.map +1 -0
- package/dist/workerd/credentials/defaultAzureCredential.d.ts +65 -0
- package/dist/workerd/credentials/defaultAzureCredential.d.ts.map +1 -0
- package/dist/workerd/credentials/defaultAzureCredential.js +164 -0
- package/dist/workerd/credentials/defaultAzureCredential.js.map +1 -0
- package/dist/workerd/credentials/defaultAzureCredentialOptions.d.ts +49 -0
- package/dist/workerd/credentials/defaultAzureCredentialOptions.d.ts.map +1 -0
- package/dist/workerd/credentials/defaultAzureCredentialOptions.js +4 -0
- package/dist/workerd/credentials/defaultAzureCredentialOptions.js.map +1 -0
- package/dist/workerd/credentials/deviceCodeCredential.d.ts +67 -0
- package/dist/workerd/credentials/deviceCodeCredential.d.ts.map +1 -0
- package/dist/workerd/credentials/deviceCodeCredential.js +91 -0
- package/dist/workerd/credentials/deviceCodeCredential.js.map +1 -0
- package/dist/workerd/credentials/deviceCodeCredentialOptions.d.ts +53 -0
- package/dist/workerd/credentials/deviceCodeCredentialOptions.d.ts.map +1 -0
- package/dist/workerd/credentials/deviceCodeCredentialOptions.js +4 -0
- package/dist/workerd/credentials/deviceCodeCredentialOptions.js.map +1 -0
- package/dist/workerd/credentials/environmentCredential.d.ts +52 -0
- package/dist/workerd/credentials/environmentCredential.d.ts.map +1 -0
- package/dist/workerd/credentials/environmentCredential.js +130 -0
- package/dist/workerd/credentials/environmentCredential.js.map +1 -0
- package/dist/workerd/credentials/environmentCredentialOptions.d.ts +9 -0
- package/dist/workerd/credentials/environmentCredentialOptions.d.ts.map +1 -0
- package/dist/workerd/credentials/environmentCredentialOptions.js +4 -0
- package/dist/workerd/credentials/environmentCredentialOptions.js.map +1 -0
- package/dist/workerd/credentials/interactiveBrowserCredential.d.ts +56 -0
- package/dist/workerd/credentials/interactiveBrowserCredential.d.ts.map +1 -0
- package/dist/workerd/credentials/interactiveBrowserCredential.js +91 -0
- package/dist/workerd/credentials/interactiveBrowserCredential.js.map +1 -0
- package/dist/workerd/credentials/interactiveBrowserCredentialOptions.d.ts +77 -0
- package/dist/workerd/credentials/interactiveBrowserCredentialOptions.d.ts.map +1 -0
- package/dist/workerd/credentials/interactiveBrowserCredentialOptions.js +4 -0
- package/dist/workerd/credentials/interactiveBrowserCredentialOptions.js.map +1 -0
- package/dist/workerd/credentials/interactiveCredentialOptions.d.ts +25 -0
- package/dist/workerd/credentials/interactiveCredentialOptions.d.ts.map +1 -0
- package/dist/workerd/credentials/interactiveCredentialOptions.js +4 -0
- package/dist/workerd/credentials/interactiveCredentialOptions.js.map +1 -0
- package/dist/workerd/credentials/managedIdentityCredential/imdsMsi.d.ts +18 -0
- package/dist/workerd/credentials/managedIdentityCredential/imdsMsi.d.ts.map +1 -0
- package/dist/workerd/credentials/managedIdentityCredential/imdsMsi.js +99 -0
- package/dist/workerd/credentials/managedIdentityCredential/imdsMsi.js.map +1 -0
- package/dist/workerd/credentials/managedIdentityCredential/imdsRetryPolicy.d.ts +12 -0
- package/dist/workerd/credentials/managedIdentityCredential/imdsRetryPolicy.d.ts.map +1 -0
- package/dist/workerd/credentials/managedIdentityCredential/imdsRetryPolicy.js +33 -0
- package/dist/workerd/credentials/managedIdentityCredential/imdsRetryPolicy.js.map +1 -0
- package/dist/workerd/credentials/managedIdentityCredential/index.d.ts +61 -0
- package/dist/workerd/credentials/managedIdentityCredential/index.d.ts.map +1 -0
- package/dist/workerd/credentials/managedIdentityCredential/index.js +239 -0
- package/dist/workerd/credentials/managedIdentityCredential/index.js.map +1 -0
- package/dist/workerd/credentials/managedIdentityCredential/models.d.ts +24 -0
- package/dist/workerd/credentials/managedIdentityCredential/models.d.ts.map +1 -0
- package/dist/workerd/credentials/managedIdentityCredential/models.js +4 -0
- package/dist/workerd/credentials/managedIdentityCredential/models.js.map +1 -0
- package/dist/workerd/credentials/managedIdentityCredential/options.d.ts +37 -0
- package/dist/workerd/credentials/managedIdentityCredential/options.d.ts.map +1 -0
- package/dist/workerd/credentials/managedIdentityCredential/options.js +4 -0
- package/dist/workerd/credentials/managedIdentityCredential/options.js.map +1 -0
- package/dist/workerd/credentials/managedIdentityCredential/tokenExchangeMsi.d.ts +14 -0
- package/dist/workerd/credentials/managedIdentityCredential/tokenExchangeMsi.d.ts.map +1 -0
- package/dist/workerd/credentials/managedIdentityCredential/tokenExchangeMsi.js +32 -0
- package/dist/workerd/credentials/managedIdentityCredential/tokenExchangeMsi.js.map +1 -0
- package/dist/workerd/credentials/managedIdentityCredential/utils.d.ts +37 -0
- package/dist/workerd/credentials/managedIdentityCredential/utils.d.ts.map +1 -0
- package/dist/workerd/credentials/managedIdentityCredential/utils.js +81 -0
- package/dist/workerd/credentials/managedIdentityCredential/utils.js.map +1 -0
- package/dist/workerd/credentials/multiTenantTokenCredentialOptions.d.ts +12 -0
- package/dist/workerd/credentials/multiTenantTokenCredentialOptions.d.ts.map +1 -0
- package/dist/workerd/credentials/multiTenantTokenCredentialOptions.js +4 -0
- package/dist/workerd/credentials/multiTenantTokenCredentialOptions.js.map +1 -0
- package/dist/workerd/credentials/onBehalfOfCredential.d.ts +105 -0
- package/dist/workerd/credentials/onBehalfOfCredential.d.ts.map +1 -0
- package/dist/workerd/credentials/onBehalfOfCredential.js +112 -0
- package/dist/workerd/credentials/onBehalfOfCredential.js.map +1 -0
- package/dist/workerd/credentials/onBehalfOfCredentialOptions.d.ts +76 -0
- package/dist/workerd/credentials/onBehalfOfCredentialOptions.d.ts.map +1 -0
- package/dist/workerd/credentials/onBehalfOfCredentialOptions.js +4 -0
- package/dist/workerd/credentials/onBehalfOfCredentialOptions.js.map +1 -0
- package/dist/workerd/credentials/usernamePasswordCredential.d.ts +42 -0
- package/dist/workerd/credentials/usernamePasswordCredential.d.ts.map +1 -0
- package/dist/workerd/credentials/usernamePasswordCredential.js +68 -0
- package/dist/workerd/credentials/usernamePasswordCredential.js.map +1 -0
- package/dist/workerd/credentials/usernamePasswordCredentialOptions.d.ts +10 -0
- package/dist/workerd/credentials/usernamePasswordCredentialOptions.d.ts.map +1 -0
- package/dist/workerd/credentials/usernamePasswordCredentialOptions.js +4 -0
- package/dist/workerd/credentials/usernamePasswordCredentialOptions.js.map +1 -0
- package/dist/workerd/credentials/visualStudioCodeCredential.d.ts +66 -0
- package/dist/workerd/credentials/visualStudioCodeCredential.d.ts.map +1 -0
- package/dist/workerd/credentials/visualStudioCodeCredential.js +196 -0
- package/dist/workerd/credentials/visualStudioCodeCredential.js.map +1 -0
- package/dist/workerd/credentials/visualStudioCodeCredentialOptions.d.ts +16 -0
- package/dist/workerd/credentials/visualStudioCodeCredentialOptions.d.ts.map +1 -0
- package/dist/workerd/credentials/visualStudioCodeCredentialOptions.js +4 -0
- package/dist/workerd/credentials/visualStudioCodeCredentialOptions.js.map +1 -0
- package/dist/workerd/credentials/visualStudioCodeCredentialPlugin.d.ts +16 -0
- package/dist/workerd/credentials/visualStudioCodeCredentialPlugin.d.ts.map +1 -0
- package/dist/workerd/credentials/visualStudioCodeCredentialPlugin.js +4 -0
- package/dist/workerd/credentials/visualStudioCodeCredentialPlugin.js.map +1 -0
- package/dist/workerd/credentials/workloadIdentityCredential.d.ts +47 -0
- package/dist/workerd/credentials/workloadIdentityCredential.d.ts.map +1 -0
- package/dist/workerd/credentials/workloadIdentityCredential.js +114 -0
- package/dist/workerd/credentials/workloadIdentityCredential.js.map +1 -0
- package/dist/workerd/credentials/workloadIdentityCredentialOptions.d.ts +20 -0
- package/dist/workerd/credentials/workloadIdentityCredentialOptions.d.ts.map +1 -0
- package/dist/workerd/credentials/workloadIdentityCredentialOptions.js +4 -0
- package/dist/workerd/credentials/workloadIdentityCredentialOptions.js.map +1 -0
- package/dist/workerd/errors.d.ts +139 -0
- package/dist/workerd/errors.d.ts.map +1 -0
- package/dist/workerd/errors.js +123 -0
- package/dist/workerd/errors.js.map +1 -0
- package/dist/workerd/index.d.ts +61 -0
- package/dist/workerd/index.d.ts.map +1 -0
- package/dist/workerd/index.js +34 -0
- package/dist/workerd/index.js.map +1 -0
- package/dist/workerd/msal/browserFlows/msalBrowserCommon.d.ts +19 -0
- package/dist/workerd/msal/browserFlows/msalBrowserCommon.d.ts.map +1 -0
- package/dist/workerd/msal/browserFlows/msalBrowserCommon.js +291 -0
- package/dist/workerd/msal/browserFlows/msalBrowserCommon.js.map +1 -0
- package/dist/workerd/msal/browserFlows/msalBrowserOptions.d.ts +87 -0
- package/dist/workerd/msal/browserFlows/msalBrowserOptions.d.ts.map +1 -0
- package/dist/workerd/msal/browserFlows/msalBrowserOptions.js +4 -0
- package/dist/workerd/msal/browserFlows/msalBrowserOptions.js.map +1 -0
- package/dist/workerd/msal/credentials.d.ts +52 -0
- package/dist/workerd/msal/credentials.d.ts.map +1 -0
- package/dist/workerd/msal/credentials.js +4 -0
- package/dist/workerd/msal/credentials.js.map +1 -0
- package/dist/workerd/msal/msal.d.ts +3 -0
- package/dist/workerd/msal/msal.d.ts.map +1 -0
- package/dist/workerd/msal/msal.js +5 -0
- package/dist/workerd/msal/msal.js.map +1 -0
- package/dist/workerd/msal/nodeFlows/brokerOptions.d.ts +44 -0
- package/dist/workerd/msal/nodeFlows/brokerOptions.d.ts.map +1 -0
- package/dist/workerd/msal/nodeFlows/brokerOptions.js +2 -0
- package/dist/workerd/msal/nodeFlows/brokerOptions.js.map +1 -0
- package/dist/workerd/msal/nodeFlows/msalClient.d.ts +186 -0
- package/dist/workerd/msal/nodeFlows/msalClient.d.ts.map +1 -0
- package/dist/workerd/msal/nodeFlows/msalClient.js +469 -0
- package/dist/workerd/msal/nodeFlows/msalClient.js.map +1 -0
- package/dist/workerd/msal/nodeFlows/msalPlugins.d.ts +91 -0
- package/dist/workerd/msal/nodeFlows/msalPlugins.d.ts.map +1 -0
- package/dist/workerd/msal/nodeFlows/msalPlugins.js +87 -0
- package/dist/workerd/msal/nodeFlows/msalPlugins.js.map +1 -0
- package/dist/workerd/msal/nodeFlows/tokenCachePersistenceOptions.d.ts +24 -0
- package/dist/workerd/msal/nodeFlows/tokenCachePersistenceOptions.d.ts.map +1 -0
- package/dist/workerd/msal/nodeFlows/tokenCachePersistenceOptions.js +4 -0
- package/dist/workerd/msal/nodeFlows/tokenCachePersistenceOptions.js.map +1 -0
- package/dist/workerd/msal/types.d.ts +87 -0
- package/dist/workerd/msal/types.d.ts.map +1 -0
- package/dist/workerd/msal/types.js +4 -0
- package/dist/workerd/msal/types.js.map +1 -0
- package/dist/workerd/msal/utils.d.ts +95 -0
- package/dist/workerd/msal/utils.d.ts.map +1 -0
- package/dist/workerd/msal/utils.js +238 -0
- package/dist/workerd/msal/utils.js.map +1 -0
- package/dist/workerd/package.json +3 -0
- package/dist/workerd/plugins/consumer.d.ts +28 -0
- package/dist/workerd/plugins/consumer.d.ts.map +1 -0
- package/dist/workerd/plugins/consumer.js +43 -0
- package/dist/workerd/plugins/consumer.js.map +1 -0
- package/dist/workerd/plugins/provider.d.ts +36 -0
- package/dist/workerd/plugins/provider.d.ts.map +1 -0
- package/dist/workerd/plugins/provider.js +4 -0
- package/dist/workerd/plugins/provider.js.map +1 -0
- package/dist/workerd/regionalAuthority.d.ts +122 -0
- package/dist/workerd/regionalAuthority.d.ts.map +1 -0
- package/dist/workerd/regionalAuthority.js +140 -0
- package/dist/workerd/regionalAuthority.js.map +1 -0
- package/dist/workerd/tokenCredentialOptions.d.ts +28 -0
- package/dist/workerd/tokenCredentialOptions.d.ts.map +1 -0
- package/dist/workerd/tokenCredentialOptions.js +4 -0
- package/dist/workerd/tokenCredentialOptions.js.map +1 -0
- package/dist/workerd/tokenProvider.d.ts +39 -0
- package/dist/workerd/tokenProvider.d.ts.map +1 -0
- package/dist/workerd/tokenProvider.js +53 -0
- package/dist/workerd/tokenProvider.js.map +1 -0
- package/dist/workerd/util/authHostEnv-browser.d.mts +4 -0
- package/dist/workerd/util/authHostEnv-browser.d.mts.map +1 -0
- package/dist/workerd/util/authHostEnv-browser.mjs +7 -0
- package/dist/workerd/util/authHostEnv-browser.mjs.map +1 -0
- package/dist/workerd/util/identityTokenEndpoint.d.ts +2 -0
- package/dist/workerd/util/identityTokenEndpoint.d.ts.map +1 -0
- package/dist/workerd/util/identityTokenEndpoint.js +11 -0
- package/dist/workerd/util/identityTokenEndpoint.js.map +1 -0
- package/dist/workerd/util/logging.d.ts +70 -0
- package/dist/workerd/util/logging.d.ts.map +1 -0
- package/dist/workerd/util/logging.js +94 -0
- package/dist/workerd/util/logging.js.map +1 -0
- package/dist/workerd/util/processMultiTenantRequest.d.ts +10 -0
- package/dist/workerd/util/processMultiTenantRequest.d.ts.map +1 -0
- package/dist/workerd/util/processMultiTenantRequest.js +35 -0
- package/dist/workerd/util/processMultiTenantRequest.js.map +1 -0
- package/dist/workerd/util/processUtils.d.ts +13 -0
- package/dist/workerd/util/processUtils.d.ts.map +1 -0
- package/dist/workerd/util/processUtils.js +32 -0
- package/dist/workerd/util/processUtils.js.map +1 -0
- package/dist/workerd/util/scopeUtils.d.ts +17 -0
- package/dist/workerd/util/scopeUtils.d.ts.map +1 -0
- package/dist/workerd/util/scopeUtils.js +29 -0
- package/dist/workerd/util/scopeUtils.js.map +1 -0
- package/dist/workerd/util/subscriptionUtils.d.ts +6 -0
- package/dist/workerd/util/subscriptionUtils.d.ts.map +1 -0
- package/dist/workerd/util/subscriptionUtils.js +14 -0
- package/dist/workerd/util/subscriptionUtils.js.map +1 -0
- package/dist/workerd/util/tenantIdUtils.d.ts +15 -0
- package/dist/workerd/util/tenantIdUtils.d.ts.map +1 -0
- package/dist/workerd/util/tenantIdUtils.js +44 -0
- package/dist/workerd/util/tenantIdUtils.js.map +1 -0
- package/dist/workerd/util/tracing.d.ts +6 -0
- package/dist/workerd/util/tracing.d.ts.map +1 -0
- package/dist/workerd/util/tracing.js +14 -0
- package/dist/workerd/util/tracing.js.map +1 -0
- package/package.json +9 -3
@@ -0,0 +1,14 @@
|
|
1
|
+
import type { AccessToken, GetTokenOptions } from "@azure/core-auth";
|
2
|
+
import type { MSIConfiguration } from "./models.js";
|
3
|
+
/**
|
4
|
+
* Defines how to determine whether the token exchange MSI is available, and also how to retrieve a token from the token exchange MSI.
|
5
|
+
*
|
6
|
+
* Token exchange MSI (used by AKS) is the only MSI implementation handled entirely by Azure Identity.
|
7
|
+
* The rest have been migrated to MSAL.
|
8
|
+
*/
|
9
|
+
export declare const tokenExchangeMsi: {
|
10
|
+
name: string;
|
11
|
+
isAvailable(clientId?: string): Promise<boolean>;
|
12
|
+
getToken(configuration: MSIConfiguration, getTokenOptions?: GetTokenOptions): Promise<AccessToken | null>;
|
13
|
+
};
|
14
|
+
//# sourceMappingURL=tokenExchangeMsi.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"tokenExchangeMsi.d.ts","sourceRoot":"","sources":["../../../../src/credentials/managedIdentityCredential/tokenExchangeMsi.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAQpD;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB;;2BAEE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;4BAerC,gBAAgB,oBACd,eAAe,GAC/B,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;CAY/B,CAAC"}
|
@@ -0,0 +1,32 @@
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
2
|
+
// Licensed under the MIT License.
|
3
|
+
import { WorkloadIdentityCredential } from "../workloadIdentityCredential.js";
|
4
|
+
import { credentialLogger } from "../../util/logging.js";
|
5
|
+
const msiName = "ManagedIdentityCredential - Token Exchange";
|
6
|
+
const logger = credentialLogger(msiName);
|
7
|
+
/**
|
8
|
+
* Defines how to determine whether the token exchange MSI is available, and also how to retrieve a token from the token exchange MSI.
|
9
|
+
*
|
10
|
+
* Token exchange MSI (used by AKS) is the only MSI implementation handled entirely by Azure Identity.
|
11
|
+
* The rest have been migrated to MSAL.
|
12
|
+
*/
|
13
|
+
export const tokenExchangeMsi = {
|
14
|
+
name: "tokenExchangeMsi",
|
15
|
+
async isAvailable(clientId) {
|
16
|
+
const env = process.env;
|
17
|
+
const result = Boolean((clientId || env.AZURE_CLIENT_ID) &&
|
18
|
+
env.AZURE_TENANT_ID &&
|
19
|
+
process.env.AZURE_FEDERATED_TOKEN_FILE);
|
20
|
+
if (!result) {
|
21
|
+
logger.info(`${msiName}: Unavailable. The environment variables needed are: AZURE_CLIENT_ID (or the client ID sent through the parameters), AZURE_TENANT_ID and AZURE_FEDERATED_TOKEN_FILE`);
|
22
|
+
}
|
23
|
+
return result;
|
24
|
+
},
|
25
|
+
async getToken(configuration, getTokenOptions = {}) {
|
26
|
+
const { scopes, clientId } = configuration;
|
27
|
+
const identityClientTokenCredentialOptions = {};
|
28
|
+
const workloadIdentityCredential = new WorkloadIdentityCredential(Object.assign(Object.assign({ clientId, tenantId: process.env.AZURE_TENANT_ID, tokenFilePath: process.env.AZURE_FEDERATED_TOKEN_FILE }, identityClientTokenCredentialOptions), { disableInstanceDiscovery: true }));
|
29
|
+
return workloadIdentityCredential.getToken(scopes, getTokenOptions);
|
30
|
+
},
|
31
|
+
};
|
32
|
+
//# sourceMappingURL=tokenExchangeMsi.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"tokenExchangeMsi.js","sourceRoot":"","sources":["../../../../src/credentials/managedIdentityCredential/tokenExchangeMsi.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OAAO,EAAE,0BAA0B,EAAE,MAAM,kCAAkC,CAAC;AAC9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAGzD,MAAM,OAAO,GAAG,4CAA4C,CAAC;AAC7D,MAAM,MAAM,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;AAEzC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,IAAI,EAAE,kBAAkB;IACxB,KAAK,CAAC,WAAW,CAAC,QAAiB;QACjC,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;QACxB,MAAM,MAAM,GAAG,OAAO,CACpB,CAAC,QAAQ,IAAI,GAAG,CAAC,eAAe,CAAC;YAC/B,GAAG,CAAC,eAAe;YACnB,OAAO,CAAC,GAAG,CAAC,0BAA0B,CACzC,CAAC;QACF,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,CAAC,IAAI,CACT,GAAG,OAAO,qKAAqK,CAChL,CAAC;QACJ,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,KAAK,CAAC,QAAQ,CACZ,aAA+B,EAC/B,kBAAmC,EAAE;QAErC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,aAAa,CAAC;QAC3C,MAAM,oCAAoC,GAAG,EAAE,CAAC;QAChD,MAAM,0BAA0B,GAAG,IAAI,0BAA0B,CAAC,8BAChE,QAAQ,EACR,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,eAAe,EACrC,aAAa,EAAE,OAAO,CAAC,GAAG,CAAC,0BAA0B,IAClD,oCAAoC,KACvC,wBAAwB,EAAE,IAAI,GACM,CAAC,CAAC;QACxC,OAAO,0BAA0B,CAAC,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IACtE,CAAC;CACF,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AccessToken, GetTokenOptions } from \"@azure/core-auth\";\nimport type { MSIConfiguration } from \"./models.js\";\nimport { WorkloadIdentityCredential } from \"../workloadIdentityCredential.js\";\nimport { credentialLogger } from \"../../util/logging.js\";\nimport type { WorkloadIdentityCredentialOptions } from \"../workloadIdentityCredentialOptions.js\";\n\nconst msiName = \"ManagedIdentityCredential - Token Exchange\";\nconst logger = credentialLogger(msiName);\n\n/**\n * Defines how to determine whether the token exchange MSI is available, and also how to retrieve a token from the token exchange MSI.\n *\n * Token exchange MSI (used by AKS) is the only MSI implementation handled entirely by Azure Identity.\n * The rest have been migrated to MSAL.\n */\nexport const tokenExchangeMsi = {\n name: \"tokenExchangeMsi\",\n async isAvailable(clientId?: string): Promise<boolean> {\n const env = process.env;\n const result = Boolean(\n (clientId || env.AZURE_CLIENT_ID) &&\n env.AZURE_TENANT_ID &&\n process.env.AZURE_FEDERATED_TOKEN_FILE,\n );\n if (!result) {\n logger.info(\n `${msiName}: Unavailable. The environment variables needed are: AZURE_CLIENT_ID (or the client ID sent through the parameters), AZURE_TENANT_ID and AZURE_FEDERATED_TOKEN_FILE`,\n );\n }\n return result;\n },\n async getToken(\n configuration: MSIConfiguration,\n getTokenOptions: GetTokenOptions = {},\n ): Promise<AccessToken | null> {\n const { scopes, clientId } = configuration;\n const identityClientTokenCredentialOptions = {};\n const workloadIdentityCredential = new WorkloadIdentityCredential({\n clientId,\n tenantId: process.env.AZURE_TENANT_ID,\n tokenFilePath: process.env.AZURE_FEDERATED_TOKEN_FILE,\n ...identityClientTokenCredentialOptions,\n disableInstanceDiscovery: true,\n } as WorkloadIdentityCredentialOptions);\n return workloadIdentityCredential.getToken(scopes, getTokenOptions);\n },\n};\n"]}
|
@@ -0,0 +1,37 @@
|
|
1
|
+
/**
|
2
|
+
* Error message for Service Fabric Managed Identity environment.
|
3
|
+
*/
|
4
|
+
export declare const serviceFabricErrorMessage = "Specifying a `clientId` or `resourceId` is not supported by the Service Fabric managed identity environment. The managed identity configuration is determined by the Service Fabric cluster resource configuration. See https://aka.ms/servicefabricmi for more information";
|
5
|
+
/**
|
6
|
+
* Most MSIs send requests to the IMDS endpoint, or a similar endpoint.
|
7
|
+
* These are GET requests that require sending a `resource` parameter on the query.
|
8
|
+
* This resource can be derived from the scopes received through the getToken call, as long as only one scope is received.
|
9
|
+
* Multiple scopes assume that the resulting token will have access to multiple resources, which won't be the case.
|
10
|
+
*
|
11
|
+
* For that reason, when we encounter multiple scopes, we return undefined.
|
12
|
+
* It's up to the individual MSI implementations to throw the errors (which helps us provide less generic errors).
|
13
|
+
*/
|
14
|
+
export declare function mapScopesToResource(scopes: string | string[]): string | undefined;
|
15
|
+
/**
|
16
|
+
* Internal type roughly matching the raw responses of the authentication endpoints.
|
17
|
+
*
|
18
|
+
* @internal
|
19
|
+
*/
|
20
|
+
export interface TokenResponseParsedBody {
|
21
|
+
access_token?: string;
|
22
|
+
refresh_token?: string;
|
23
|
+
expires_in: number;
|
24
|
+
expires_on?: number | string;
|
25
|
+
refresh_on?: number | string;
|
26
|
+
}
|
27
|
+
/**
|
28
|
+
* Given a token response, return the expiration timestamp as the number of milliseconds from the Unix epoch.
|
29
|
+
* @param body - A parsed response body from the authentication endpoint.
|
30
|
+
*/
|
31
|
+
export declare function parseExpirationTimestamp(body: TokenResponseParsedBody): number;
|
32
|
+
/**
|
33
|
+
* Given a token response, return the expiration timestamp as the number of milliseconds from the Unix epoch.
|
34
|
+
* @param body - A parsed response body from the authentication endpoint.
|
35
|
+
*/
|
36
|
+
export declare function parseRefreshTimestamp(body: TokenResponseParsedBody): number | undefined;
|
37
|
+
//# sourceMappingURL=utils.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/credentials/managedIdentityCredential/utils.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,eAAO,MAAM,yBAAyB,gRACyO,CAAC;AAEhR;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,GAAG,SAAS,CAiBjF;AAED;;;;GAIG;AACH,MAAM,WAAW,uBAAuB;IACtC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC7B,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAC9B;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,uBAAuB,GAAG,MAAM,CAwB9E;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,uBAAuB,GAAG,MAAM,GAAG,SAAS,CAqBvF"}
|
@@ -0,0 +1,81 @@
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
2
|
+
// Licensed under the MIT License.
|
3
|
+
const DefaultScopeSuffix = "/.default";
|
4
|
+
/**
|
5
|
+
* Error message for Service Fabric Managed Identity environment.
|
6
|
+
*/
|
7
|
+
export const serviceFabricErrorMessage = "Specifying a `clientId` or `resourceId` is not supported by the Service Fabric managed identity environment. The managed identity configuration is determined by the Service Fabric cluster resource configuration. See https://aka.ms/servicefabricmi for more information";
|
8
|
+
/**
|
9
|
+
* Most MSIs send requests to the IMDS endpoint, or a similar endpoint.
|
10
|
+
* These are GET requests that require sending a `resource` parameter on the query.
|
11
|
+
* This resource can be derived from the scopes received through the getToken call, as long as only one scope is received.
|
12
|
+
* Multiple scopes assume that the resulting token will have access to multiple resources, which won't be the case.
|
13
|
+
*
|
14
|
+
* For that reason, when we encounter multiple scopes, we return undefined.
|
15
|
+
* It's up to the individual MSI implementations to throw the errors (which helps us provide less generic errors).
|
16
|
+
*/
|
17
|
+
export function mapScopesToResource(scopes) {
|
18
|
+
let scope = "";
|
19
|
+
if (Array.isArray(scopes)) {
|
20
|
+
if (scopes.length !== 1) {
|
21
|
+
return;
|
22
|
+
}
|
23
|
+
scope = scopes[0];
|
24
|
+
}
|
25
|
+
else if (typeof scopes === "string") {
|
26
|
+
scope = scopes;
|
27
|
+
}
|
28
|
+
if (!scope.endsWith(DefaultScopeSuffix)) {
|
29
|
+
return scope;
|
30
|
+
}
|
31
|
+
return scope.substr(0, scope.lastIndexOf(DefaultScopeSuffix));
|
32
|
+
}
|
33
|
+
/**
|
34
|
+
* Given a token response, return the expiration timestamp as the number of milliseconds from the Unix epoch.
|
35
|
+
* @param body - A parsed response body from the authentication endpoint.
|
36
|
+
*/
|
37
|
+
export function parseExpirationTimestamp(body) {
|
38
|
+
if (typeof body.expires_on === "number") {
|
39
|
+
return body.expires_on * 1000;
|
40
|
+
}
|
41
|
+
if (typeof body.expires_on === "string") {
|
42
|
+
const asNumber = +body.expires_on;
|
43
|
+
if (!isNaN(asNumber)) {
|
44
|
+
return asNumber * 1000;
|
45
|
+
}
|
46
|
+
const asDate = Date.parse(body.expires_on);
|
47
|
+
if (!isNaN(asDate)) {
|
48
|
+
return asDate;
|
49
|
+
}
|
50
|
+
}
|
51
|
+
if (typeof body.expires_in === "number") {
|
52
|
+
return Date.now() + body.expires_in * 1000;
|
53
|
+
}
|
54
|
+
throw new Error(`Failed to parse token expiration from body. expires_in="${body.expires_in}", expires_on="${body.expires_on}"`);
|
55
|
+
}
|
56
|
+
/**
|
57
|
+
* Given a token response, return the expiration timestamp as the number of milliseconds from the Unix epoch.
|
58
|
+
* @param body - A parsed response body from the authentication endpoint.
|
59
|
+
*/
|
60
|
+
export function parseRefreshTimestamp(body) {
|
61
|
+
if (body.refresh_on) {
|
62
|
+
if (typeof body.refresh_on === "number") {
|
63
|
+
return body.refresh_on * 1000;
|
64
|
+
}
|
65
|
+
if (typeof body.refresh_on === "string") {
|
66
|
+
const asNumber = +body.refresh_on;
|
67
|
+
if (!isNaN(asNumber)) {
|
68
|
+
return asNumber * 1000;
|
69
|
+
}
|
70
|
+
const asDate = Date.parse(body.refresh_on);
|
71
|
+
if (!isNaN(asDate)) {
|
72
|
+
return asDate;
|
73
|
+
}
|
74
|
+
}
|
75
|
+
throw new Error(`Failed to parse refresh_on from body. refresh_on="${body.refresh_on}"`);
|
76
|
+
}
|
77
|
+
else {
|
78
|
+
return undefined;
|
79
|
+
}
|
80
|
+
}
|
81
|
+
//# sourceMappingURL=utils.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/credentials/managedIdentityCredential/utils.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,MAAM,kBAAkB,GAAG,WAAW,CAAC;AAEvC;;GAEG;AACH,MAAM,CAAC,MAAM,yBAAyB,GACpC,6QAA6Q,CAAC;AAEhR;;;;;;;;GAQG;AACH,MAAM,UAAU,mBAAmB,CAAC,MAAyB;IAC3D,IAAI,KAAK,GAAG,EAAE,CAAC;IACf,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAC1B,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxB,OAAO;QACT,CAAC;QAED,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;SAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QACtC,KAAK,GAAG,MAAM,CAAC;IACjB,CAAC;IAED,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC;QACxC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAC,CAAC;AAChE,CAAC;AAeD;;;GAGG;AACH,MAAM,UAAU,wBAAwB,CAAC,IAA6B;IACpE,IAAI,OAAO,IAAI,CAAC,UAAU,KAAK,QAAQ,EAAE,CAAC;QACxC,OAAO,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;IAChC,CAAC;IAED,IAAI,OAAO,IAAI,CAAC,UAAU,KAAK,QAAQ,EAAE,CAAC;QACxC,MAAM,QAAQ,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC;QAClC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC;YACrB,OAAO,QAAQ,GAAG,IAAI,CAAC;QACzB,CAAC;QAED,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC3C,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;YACnB,OAAO,MAAM,CAAC;QAChB,CAAC;IACH,CAAC;IAED,IAAI,OAAO,IAAI,CAAC,UAAU,KAAK,QAAQ,EAAE,CAAC;QACxC,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;IAC7C,CAAC;IAED,MAAM,IAAI,KAAK,CACb,2DAA2D,IAAI,CAAC,UAAU,kBAAkB,IAAI,CAAC,UAAU,GAAG,CAC/G,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,qBAAqB,CAAC,IAA6B;IACjE,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;QACpB,IAAI,OAAO,IAAI,CAAC,UAAU,KAAK,QAAQ,EAAE,CAAC;YACxC,OAAO,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QAChC,CAAC;QAED,IAAI,OAAO,IAAI,CAAC,UAAU,KAAK,QAAQ,EAAE,CAAC;YACxC,MAAM,QAAQ,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC;YAClC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC;gBACrB,OAAO,QAAQ,GAAG,IAAI,CAAC;YACzB,CAAC;YAED,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YAC3C,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;gBACnB,OAAO,MAAM,CAAC;YAChB,CAAC;QACH,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,qDAAqD,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC;IAC3F,CAAC;SAAM,CAAC;QACN,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nconst DefaultScopeSuffix = \"/.default\";\n\n/**\n * Error message for Service Fabric Managed Identity environment.\n */\nexport const serviceFabricErrorMessage =\n \"Specifying a `clientId` or `resourceId` is not supported by the Service Fabric managed identity environment. The managed identity configuration is determined by the Service Fabric cluster resource configuration. See https://aka.ms/servicefabricmi for more information\";\n\n/**\n * Most MSIs send requests to the IMDS endpoint, or a similar endpoint.\n * These are GET requests that require sending a `resource` parameter on the query.\n * This resource can be derived from the scopes received through the getToken call, as long as only one scope is received.\n * Multiple scopes assume that the resulting token will have access to multiple resources, which won't be the case.\n *\n * For that reason, when we encounter multiple scopes, we return undefined.\n * It's up to the individual MSI implementations to throw the errors (which helps us provide less generic errors).\n */\nexport function mapScopesToResource(scopes: string | string[]): string | undefined {\n let scope = \"\";\n if (Array.isArray(scopes)) {\n if (scopes.length !== 1) {\n return;\n }\n\n scope = scopes[0];\n } else if (typeof scopes === \"string\") {\n scope = scopes;\n }\n\n if (!scope.endsWith(DefaultScopeSuffix)) {\n return scope;\n }\n\n return scope.substr(0, scope.lastIndexOf(DefaultScopeSuffix));\n}\n\n/**\n * Internal type roughly matching the raw responses of the authentication endpoints.\n *\n * @internal\n */\nexport interface TokenResponseParsedBody {\n access_token?: string;\n refresh_token?: string;\n expires_in: number;\n expires_on?: number | string;\n refresh_on?: number | string;\n}\n\n/**\n * Given a token response, return the expiration timestamp as the number of milliseconds from the Unix epoch.\n * @param body - A parsed response body from the authentication endpoint.\n */\nexport function parseExpirationTimestamp(body: TokenResponseParsedBody): number {\n if (typeof body.expires_on === \"number\") {\n return body.expires_on * 1000;\n }\n\n if (typeof body.expires_on === \"string\") {\n const asNumber = +body.expires_on;\n if (!isNaN(asNumber)) {\n return asNumber * 1000;\n }\n\n const asDate = Date.parse(body.expires_on);\n if (!isNaN(asDate)) {\n return asDate;\n }\n }\n\n if (typeof body.expires_in === \"number\") {\n return Date.now() + body.expires_in * 1000;\n }\n\n throw new Error(\n `Failed to parse token expiration from body. expires_in=\"${body.expires_in}\", expires_on=\"${body.expires_on}\"`,\n );\n}\n\n/**\n * Given a token response, return the expiration timestamp as the number of milliseconds from the Unix epoch.\n * @param body - A parsed response body from the authentication endpoint.\n */\nexport function parseRefreshTimestamp(body: TokenResponseParsedBody): number | undefined {\n if (body.refresh_on) {\n if (typeof body.refresh_on === \"number\") {\n return body.refresh_on * 1000;\n }\n\n if (typeof body.refresh_on === \"string\") {\n const asNumber = +body.refresh_on;\n if (!isNaN(asNumber)) {\n return asNumber * 1000;\n }\n\n const asDate = Date.parse(body.refresh_on);\n if (!isNaN(asDate)) {\n return asDate;\n }\n }\n throw new Error(`Failed to parse refresh_on from body. refresh_on=\"${body.refresh_on}\"`);\n } else {\n return undefined;\n }\n}\n"]}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import type { TokenCredentialOptions } from "../tokenCredentialOptions.js";
|
2
|
+
/**
|
3
|
+
* Options for multi-tenant applications which allows for additionally allowed tenants.
|
4
|
+
*/
|
5
|
+
export interface MultiTenantTokenCredentialOptions extends TokenCredentialOptions {
|
6
|
+
/**
|
7
|
+
* For multi-tenant applications, specifies additional tenants for which the credential may acquire tokens.
|
8
|
+
* Add the wildcard value "*" to allow the credential to acquire tokens for any tenant the application is installed.
|
9
|
+
*/
|
10
|
+
additionallyAllowedTenants?: string[];
|
11
|
+
}
|
12
|
+
//# sourceMappingURL=multiTenantTokenCredentialOptions.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"multiTenantTokenCredentialOptions.d.ts","sourceRoot":"","sources":["../../../src/credentials/multiTenantTokenCredentialOptions.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAE3E;;GAEG;AACH,MAAM,WAAW,iCAAkC,SAAQ,sBAAsB;IAC/E;;;OAGG;IACH,0BAA0B,CAAC,EAAE,MAAM,EAAE,CAAC;CACvC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"multiTenantTokenCredentialOptions.js","sourceRoot":"","sources":["../../../src/credentials/multiTenantTokenCredentialOptions.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { TokenCredentialOptions } from \"../tokenCredentialOptions.js\";\n\n/**\n * Options for multi-tenant applications which allows for additionally allowed tenants.\n */\nexport interface MultiTenantTokenCredentialOptions extends TokenCredentialOptions {\n /**\n * For multi-tenant applications, specifies additional tenants for which the credential may acquire tokens.\n * Add the wildcard value \"*\" to allow the credential to acquire tokens for any tenant the application is installed.\n */\n additionallyAllowedTenants?: string[];\n}\n"]}
|
@@ -0,0 +1,105 @@
|
|
1
|
+
import type { AccessToken, GetTokenOptions, TokenCredential } from "@azure/core-auth";
|
2
|
+
import type { OnBehalfOfCredentialAssertionOptions, OnBehalfOfCredentialCertificateOptions, OnBehalfOfCredentialSecretOptions } from "./onBehalfOfCredentialOptions.js";
|
3
|
+
import type { CredentialPersistenceOptions } from "./credentialPersistenceOptions.js";
|
4
|
+
import type { MultiTenantTokenCredentialOptions } from "./multiTenantTokenCredentialOptions.js";
|
5
|
+
/**
|
6
|
+
* Enables authentication to Microsoft Entra ID using the [On Behalf Of flow](https://learn.microsoft.com/entra/identity-platform/v2-oauth2-on-behalf-of-flow).
|
7
|
+
*/
|
8
|
+
export declare class OnBehalfOfCredential implements TokenCredential {
|
9
|
+
private tenantId;
|
10
|
+
private additionallyAllowedTenantIds;
|
11
|
+
private msalClient;
|
12
|
+
private sendCertificateChain?;
|
13
|
+
private certificatePath?;
|
14
|
+
private clientSecret?;
|
15
|
+
private userAssertionToken;
|
16
|
+
private clientAssertion?;
|
17
|
+
/**
|
18
|
+
* Creates an instance of the {@link OnBehalfOfCredential} with the details
|
19
|
+
* needed to authenticate against Microsoft Entra ID with path to a PEM certificate,
|
20
|
+
* and an user assertion.
|
21
|
+
*
|
22
|
+
* Example using the `KeyClient` from [\@azure/keyvault-keys](https://www.npmjs.com/package/\@azure/keyvault-keys):
|
23
|
+
*
|
24
|
+
* ```ts snippet:on_behalf_of_credential_pem_example
|
25
|
+
* import { OnBehalfOfCredential } from "@azure/identity";
|
26
|
+
* import { KeyClient } from "@azure/keyvault-keys";
|
27
|
+
*
|
28
|
+
* const tokenCredential = new OnBehalfOfCredential({
|
29
|
+
* tenantId: "tenant-id",
|
30
|
+
* clientId: "client-id",
|
31
|
+
* certificatePath: "/path/to/certificate.pem",
|
32
|
+
* userAssertionToken: "access-token",
|
33
|
+
* });
|
34
|
+
* const client = new KeyClient("vault-url", tokenCredential);
|
35
|
+
*
|
36
|
+
* await client.getKey("key-name");
|
37
|
+
* ```
|
38
|
+
*
|
39
|
+
* @param options - Optional parameters, generally common across credentials.
|
40
|
+
*/
|
41
|
+
constructor(options: OnBehalfOfCredentialCertificateOptions & MultiTenantTokenCredentialOptions & CredentialPersistenceOptions);
|
42
|
+
/**
|
43
|
+
* Creates an instance of the {@link OnBehalfOfCredential} with the details
|
44
|
+
* needed to authenticate against Microsoft Entra ID with a client
|
45
|
+
* secret and an user assertion.
|
46
|
+
*
|
47
|
+
* Example using the `KeyClient` from [\@azure/keyvault-keys](https://www.npmjs.com/package/\@azure/keyvault-keys):
|
48
|
+
*
|
49
|
+
* ```ts snippet:on_behalf_of_credential_secret_example
|
50
|
+
* import { OnBehalfOfCredential } from "@azure/identity";
|
51
|
+
* import { KeyClient } from "@azure/keyvault-keys";
|
52
|
+
*
|
53
|
+
* const tokenCredential = new OnBehalfOfCredential({
|
54
|
+
* tenantId: "tenant-id",
|
55
|
+
* clientId: "client-id",
|
56
|
+
* clientSecret: "client-secret",
|
57
|
+
* userAssertionToken: "access-token",
|
58
|
+
* });
|
59
|
+
* const client = new KeyClient("vault-url", tokenCredential);
|
60
|
+
*
|
61
|
+
* await client.getKey("key-name");
|
62
|
+
* ```
|
63
|
+
*
|
64
|
+
* @param options - Optional parameters, generally common across credentials.
|
65
|
+
*/
|
66
|
+
constructor(options: OnBehalfOfCredentialSecretOptions & MultiTenantTokenCredentialOptions & CredentialPersistenceOptions);
|
67
|
+
/**
|
68
|
+
* Creates an instance of the {@link OnBehalfOfCredential} with the details
|
69
|
+
* needed to authenticate against Microsoft Entra ID with a client `getAssertion`
|
70
|
+
* and an user assertion.
|
71
|
+
*
|
72
|
+
* Example using the `KeyClient` from [\@azure/keyvault-keys](https://www.npmjs.com/package/\@azure/keyvault-keys):
|
73
|
+
*
|
74
|
+
* ```ts snippet:on_behalf_of_credential_assertion_example
|
75
|
+
* import { OnBehalfOfCredential } from "@azure/identity";
|
76
|
+
* import { KeyClient } from "@azure/keyvault-keys";
|
77
|
+
*
|
78
|
+
* const tokenCredential = new OnBehalfOfCredential({
|
79
|
+
* tenantId: "tenant-id",
|
80
|
+
* clientId: "client-id",
|
81
|
+
* getAssertion: () => {
|
82
|
+
* return Promise.resolve("my-jwt");
|
83
|
+
* },
|
84
|
+
* userAssertionToken: "access-token",
|
85
|
+
* });
|
86
|
+
* const client = new KeyClient("vault-url", tokenCredential);
|
87
|
+
*
|
88
|
+
* await client.getKey("key-name");
|
89
|
+
* ```
|
90
|
+
*
|
91
|
+
* @param options - Optional parameters, generally common across credentials.
|
92
|
+
*/
|
93
|
+
constructor(options: OnBehalfOfCredentialAssertionOptions & MultiTenantTokenCredentialOptions & CredentialPersistenceOptions);
|
94
|
+
/**
|
95
|
+
* Authenticates with Microsoft Entra ID and returns an access token if successful.
|
96
|
+
* If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
97
|
+
*
|
98
|
+
* @param scopes - The list of scopes for which the token will have access.
|
99
|
+
* @param options - The options used to configure the underlying network requests.
|
100
|
+
*/
|
101
|
+
getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken>;
|
102
|
+
private buildClientCertificate;
|
103
|
+
private parseCertificate;
|
104
|
+
}
|
105
|
+
//# sourceMappingURL=onBehalfOfCredential.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"onBehalfOfCredential.d.ts","sourceRoot":"","sources":["../../../src/credentials/onBehalfOfCredential.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAGtF,OAAO,KAAK,EACV,oCAAoC,EACpC,sCAAsC,EAEtC,iCAAiC,EAClC,MAAM,kCAAkC,CAAC;AAS1C,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAC;AAEtF,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,wCAAwC,CAAC;AAShG;;GAEG;AACH,qBAAa,oBAAqB,YAAW,eAAe;IAC1D,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,4BAA4B,CAAW;IAC/C,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,oBAAoB,CAAC,CAAU;IACvC,OAAO,CAAC,eAAe,CAAC,CAAS;IACjC,OAAO,CAAC,YAAY,CAAC,CAAS;IAC9B,OAAO,CAAC,kBAAkB,CAAS;IACnC,OAAO,CAAC,eAAe,CAAC,CAAwB;IAEhD;;;;;;;;;;;;;;;;;;;;;;;OAuBG;gBAED,OAAO,EAAE,sCAAsC,GAC7C,iCAAiC,GACjC,4BAA4B;IAEhC;;;;;;;;;;;;;;;;;;;;;;;OAuBG;gBAED,OAAO,EAAE,iCAAiC,GACxC,iCAAiC,GACjC,4BAA4B;IAGhC;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;gBAED,OAAO,EAAE,oCAAoC,GAC3C,iCAAiC,GACjC,4BAA4B;IAuDhC;;;;;;OAMG;IACG,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,OAAO,GAAE,eAAoB,GAAG,OAAO,CAAC,WAAW,CAAC;YA0ChF,sBAAsB;YActB,gBAAgB;CAoC/B"}
|
@@ -0,0 +1,112 @@
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
2
|
+
// Licensed under the MIT License.
|
3
|
+
import { createMsalClient } from "../msal/nodeFlows/msalClient.js";
|
4
|
+
import { credentialLogger, formatError } from "../util/logging.js";
|
5
|
+
import { processMultiTenantRequest, resolveAdditionallyAllowedTenantIds, } from "../util/tenantIdUtils.js";
|
6
|
+
import { CredentialUnavailableError } from "../errors.js";
|
7
|
+
import { createHash } from "node:crypto";
|
8
|
+
import { ensureScopes } from "../util/scopeUtils.js";
|
9
|
+
import { readFile } from "node:fs/promises";
|
10
|
+
import { tracingClient } from "../util/tracing.js";
|
11
|
+
const credentialName = "OnBehalfOfCredential";
|
12
|
+
const logger = credentialLogger(credentialName);
|
13
|
+
/**
|
14
|
+
* Enables authentication to Microsoft Entra ID using the [On Behalf Of flow](https://learn.microsoft.com/entra/identity-platform/v2-oauth2-on-behalf-of-flow).
|
15
|
+
*/
|
16
|
+
export class OnBehalfOfCredential {
|
17
|
+
constructor(options) {
|
18
|
+
const { clientSecret } = options;
|
19
|
+
const { certificatePath, sendCertificateChain } = options;
|
20
|
+
const { getAssertion } = options;
|
21
|
+
const { tenantId, clientId, userAssertionToken, additionallyAllowedTenants: additionallyAllowedTenantIds, } = options;
|
22
|
+
if (!tenantId) {
|
23
|
+
throw new CredentialUnavailableError(`${credentialName}: tenantId is a required parameter. To troubleshoot, visit https://aka.ms/azsdk/js/identity/serviceprincipalauthentication/troubleshoot.`);
|
24
|
+
}
|
25
|
+
if (!clientId) {
|
26
|
+
throw new CredentialUnavailableError(`${credentialName}: clientId is a required parameter. To troubleshoot, visit https://aka.ms/azsdk/js/identity/serviceprincipalauthentication/troubleshoot.`);
|
27
|
+
}
|
28
|
+
if (!clientSecret && !certificatePath && !getAssertion) {
|
29
|
+
throw new CredentialUnavailableError(`${credentialName}: You must provide one of clientSecret, certificatePath, or a getAssertion callback but none were provided. To troubleshoot, visit https://aka.ms/azsdk/js/identity/serviceprincipalauthentication/troubleshoot.`);
|
30
|
+
}
|
31
|
+
if (!userAssertionToken) {
|
32
|
+
throw new CredentialUnavailableError(`${credentialName}: userAssertionToken is a required parameter. To troubleshoot, visit https://aka.ms/azsdk/js/identity/serviceprincipalauthentication/troubleshoot.`);
|
33
|
+
}
|
34
|
+
this.certificatePath = certificatePath;
|
35
|
+
this.clientSecret = clientSecret;
|
36
|
+
this.userAssertionToken = userAssertionToken;
|
37
|
+
this.sendCertificateChain = sendCertificateChain;
|
38
|
+
this.clientAssertion = getAssertion;
|
39
|
+
this.tenantId = tenantId;
|
40
|
+
this.additionallyAllowedTenantIds = resolveAdditionallyAllowedTenantIds(additionallyAllowedTenantIds);
|
41
|
+
this.msalClient = createMsalClient(clientId, this.tenantId, Object.assign(Object.assign({}, options), { logger, tokenCredentialOptions: options }));
|
42
|
+
}
|
43
|
+
/**
|
44
|
+
* Authenticates with Microsoft Entra ID and returns an access token if successful.
|
45
|
+
* If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
46
|
+
*
|
47
|
+
* @param scopes - The list of scopes for which the token will have access.
|
48
|
+
* @param options - The options used to configure the underlying network requests.
|
49
|
+
*/
|
50
|
+
async getToken(scopes, options = {}) {
|
51
|
+
return tracingClient.withSpan(`${credentialName}.getToken`, options, async (newOptions) => {
|
52
|
+
newOptions.tenantId = processMultiTenantRequest(this.tenantId, newOptions, this.additionallyAllowedTenantIds, logger);
|
53
|
+
const arrayScopes = ensureScopes(scopes);
|
54
|
+
if (this.certificatePath) {
|
55
|
+
const clientCertificate = await this.buildClientCertificate(this.certificatePath);
|
56
|
+
return this.msalClient.getTokenOnBehalfOf(arrayScopes, this.userAssertionToken, clientCertificate, newOptions);
|
57
|
+
}
|
58
|
+
else if (this.clientSecret) {
|
59
|
+
return this.msalClient.getTokenOnBehalfOf(arrayScopes, this.userAssertionToken, this.clientSecret, options);
|
60
|
+
}
|
61
|
+
else if (this.clientAssertion) {
|
62
|
+
return this.msalClient.getTokenOnBehalfOf(arrayScopes, this.userAssertionToken, this.clientAssertion, options);
|
63
|
+
}
|
64
|
+
else {
|
65
|
+
// this is an invalid scenario and is a bug, as the constructor should have thrown an error if neither clientSecret nor certificatePath nor clientAssertion were provided
|
66
|
+
throw new Error("Expected either clientSecret or certificatePath or clientAssertion to be defined.");
|
67
|
+
}
|
68
|
+
});
|
69
|
+
}
|
70
|
+
async buildClientCertificate(certificatePath) {
|
71
|
+
try {
|
72
|
+
const parts = await this.parseCertificate({ certificatePath }, this.sendCertificateChain);
|
73
|
+
return {
|
74
|
+
thumbprint: parts.thumbprint,
|
75
|
+
privateKey: parts.certificateContents,
|
76
|
+
x5c: parts.x5c,
|
77
|
+
};
|
78
|
+
}
|
79
|
+
catch (error) {
|
80
|
+
logger.info(formatError("", error));
|
81
|
+
throw error;
|
82
|
+
}
|
83
|
+
}
|
84
|
+
async parseCertificate(configuration, sendCertificateChain) {
|
85
|
+
const certificatePath = configuration.certificatePath;
|
86
|
+
const certificateContents = await readFile(certificatePath, "utf8");
|
87
|
+
const x5c = sendCertificateChain ? certificateContents : undefined;
|
88
|
+
const certificatePattern = /(-+BEGIN CERTIFICATE-+)(\n\r?|\r\n?)([A-Za-z0-9+/\n\r]+=*)(\n\r?|\r\n?)(-+END CERTIFICATE-+)/g;
|
89
|
+
const publicKeys = [];
|
90
|
+
// Match all possible certificates, in the order they are in the file. These will form the chain that is used for x5c
|
91
|
+
let match;
|
92
|
+
do {
|
93
|
+
match = certificatePattern.exec(certificateContents);
|
94
|
+
if (match) {
|
95
|
+
publicKeys.push(match[3]);
|
96
|
+
}
|
97
|
+
} while (match);
|
98
|
+
if (publicKeys.length === 0) {
|
99
|
+
throw new Error("The file at the specified path does not contain a PEM-encoded certificate.");
|
100
|
+
}
|
101
|
+
const thumbprint = createHash("sha1")
|
102
|
+
.update(Buffer.from(publicKeys[0], "base64"))
|
103
|
+
.digest("hex")
|
104
|
+
.toUpperCase();
|
105
|
+
return {
|
106
|
+
certificateContents,
|
107
|
+
thumbprint,
|
108
|
+
x5c,
|
109
|
+
};
|
110
|
+
}
|
111
|
+
}
|
112
|
+
//# sourceMappingURL=onBehalfOfCredential.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"onBehalfOfCredential.js","sourceRoot":"","sources":["../../../src/credentials/onBehalfOfCredential.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAOnE,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,EACL,yBAAyB,EACzB,mCAAmC,GACpC,MAAM,0BAA0B,CAAC;AAKlC,OAAO,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAE1D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,MAAM,cAAc,GAAG,sBAAsB,CAAC;AAC9C,MAAM,MAAM,GAAG,gBAAgB,CAAC,cAAc,CAAC,CAAC;AAEhD;;GAEG;AACH,MAAM,OAAO,oBAAoB;IAqG/B,YAAY,OAAoC;QAC9C,MAAM,EAAE,YAAY,EAAE,GAAG,OAA4C,CAAC;QACtE,MAAM,EAAE,eAAe,EAAE,oBAAoB,EAAE,GAC7C,OAAiD,CAAC;QACpD,MAAM,EAAE,YAAY,EAAE,GAAG,OAA+C,CAAC;QACzE,MAAM,EACJ,QAAQ,EACR,QAAQ,EACR,kBAAkB,EAClB,0BAA0B,EAAE,4BAA4B,GACzD,GAAG,OAAO,CAAC;QACZ,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,IAAI,0BAA0B,CAClC,GAAG,cAAc,0IAA0I,CAC5J,CAAC;QACJ,CAAC;QAED,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,IAAI,0BAA0B,CAClC,GAAG,cAAc,0IAA0I,CAC5J,CAAC;QACJ,CAAC;QAED,IAAI,CAAC,YAAY,IAAI,CAAC,eAAe,IAAI,CAAC,YAAY,EAAE,CAAC;YACvD,MAAM,IAAI,0BAA0B,CAClC,GAAG,cAAc,kNAAkN,CACpO,CAAC;QACJ,CAAC;QAED,IAAI,CAAC,kBAAkB,EAAE,CAAC;YACxB,MAAM,IAAI,0BAA0B,CAClC,GAAG,cAAc,oJAAoJ,CACtK,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAC;QAC7C,IAAI,CAAC,oBAAoB,GAAG,oBAAoB,CAAC;QACjD,IAAI,CAAC,eAAe,GAAG,YAAY,CAAC;QAEpC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,4BAA4B,GAAG,mCAAmC,CACrE,4BAA4B,CAC7B,CAAC;QAEF,IAAI,CAAC,UAAU,GAAG,gBAAgB,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,kCACrD,OAAO,KACV,MAAM,EACN,sBAAsB,EAAE,OAAO,IAC/B,CAAC;IACL,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,QAAQ,CAAC,MAAyB,EAAE,UAA2B,EAAE;QACrE,OAAO,aAAa,CAAC,QAAQ,CAAC,GAAG,cAAc,WAAW,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE;YACxF,UAAU,CAAC,QAAQ,GAAG,yBAAyB,CAC7C,IAAI,CAAC,QAAQ,EACb,UAAU,EACV,IAAI,CAAC,4BAA4B,EACjC,MAAM,CACP,CAAC;YAEF,MAAM,WAAW,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;YACzC,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;gBACzB,MAAM,iBAAiB,GAAG,MAAM,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;gBAElF,OAAO,IAAI,CAAC,UAAU,CAAC,kBAAkB,CACvC,WAAW,EACX,IAAI,CAAC,kBAAkB,EACvB,iBAAiB,EACjB,UAAU,CACX,CAAC;YACJ,CAAC;iBAAM,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;gBAC7B,OAAO,IAAI,CAAC,UAAU,CAAC,kBAAkB,CACvC,WAAW,EACX,IAAI,CAAC,kBAAkB,EACvB,IAAI,CAAC,YAAY,EACjB,OAAO,CACR,CAAC;YACJ,CAAC;iBAAM,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;gBAChC,OAAO,IAAI,CAAC,UAAU,CAAC,kBAAkB,CACvC,WAAW,EACX,IAAI,CAAC,kBAAkB,EACvB,IAAI,CAAC,eAAe,EACpB,OAAO,CACR,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,yKAAyK;gBACzK,MAAM,IAAI,KAAK,CACb,mFAAmF,CACpF,CAAC;YACJ,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAEO,KAAK,CAAC,sBAAsB,CAAC,eAAuB;QAC1D,IAAI,CAAC;YACH,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,EAAE,eAAe,EAAE,EAAE,IAAI,CAAC,oBAAoB,CAAC,CAAC;YAC1F,OAAO;gBACL,UAAU,EAAE,KAAK,CAAC,UAAU;gBAC5B,UAAU,EAAE,KAAK,CAAC,mBAAmB;gBACrC,GAAG,EAAE,KAAK,CAAC,GAAG;aACf,CAAC;QACJ,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC;YACpC,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,gBAAgB,CAC5B,aAAkD,EAClD,oBAA8B;QAE9B,MAAM,eAAe,GAAG,aAAa,CAAC,eAAe,CAAC;QACtD,MAAM,mBAAmB,GAAG,MAAM,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;QACpE,MAAM,GAAG,GAAG,oBAAoB,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,SAAS,CAAC;QAEnE,MAAM,kBAAkB,GACtB,+FAA+F,CAAC;QAClG,MAAM,UAAU,GAAa,EAAE,CAAC;QAEhC,qHAAqH;QACrH,IAAI,KAAK,CAAC;QACV,GAAG,CAAC;YACF,KAAK,GAAG,kBAAkB,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;YACrD,IAAI,KAAK,EAAE,CAAC;gBACV,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;YAC5B,CAAC;QACH,CAAC,QAAQ,KAAK,EAAE;QAEhB,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC5B,MAAM,IAAI,KAAK,CAAC,4EAA4E,CAAC,CAAC;QAChG,CAAC;QAED,MAAM,UAAU,GAAG,UAAU,CAAC,MAAM,CAAC;aAClC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;aAC5C,MAAM,CAAC,KAAK,CAAC;aACb,WAAW,EAAE,CAAC;QAEjB,OAAO;YACL,mBAAmB;YACnB,UAAU;YACV,GAAG;SACJ,CAAC;IACJ,CAAC;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.js\";\nimport { createMsalClient } from \"../msal/nodeFlows/msalClient.js\";\nimport type {\n OnBehalfOfCredentialAssertionOptions,\n OnBehalfOfCredentialCertificateOptions,\n OnBehalfOfCredentialOptions,\n OnBehalfOfCredentialSecretOptions,\n} from \"./onBehalfOfCredentialOptions.js\";\nimport { credentialLogger, formatError } from \"../util/logging.js\";\nimport {\n processMultiTenantRequest,\n resolveAdditionallyAllowedTenantIds,\n} from \"../util/tenantIdUtils.js\";\n\nimport type { CertificateParts } from \"../msal/types.js\";\nimport type { ClientCertificatePEMCertificatePath } from \"./clientCertificateCredentialModels.js\";\nimport type { CredentialPersistenceOptions } from \"./credentialPersistenceOptions.js\";\nimport { CredentialUnavailableError } from \"../errors.js\";\nimport type { MultiTenantTokenCredentialOptions } from \"./multiTenantTokenCredentialOptions.js\";\nimport { createHash } from \"node:crypto\";\nimport { ensureScopes } from \"../util/scopeUtils.js\";\nimport { readFile } from \"node:fs/promises\";\nimport { tracingClient } from \"../util/tracing.js\";\n\nconst credentialName = \"OnBehalfOfCredential\";\nconst logger = credentialLogger(credentialName);\n\n/**\n * Enables authentication to Microsoft Entra ID using the [On Behalf Of flow](https://learn.microsoft.com/entra/identity-platform/v2-oauth2-on-behalf-of-flow).\n */\nexport class OnBehalfOfCredential implements TokenCredential {\n private tenantId: string;\n private additionallyAllowedTenantIds: string[];\n private msalClient: MsalClient;\n private sendCertificateChain?: boolean;\n private certificatePath?: string;\n private clientSecret?: string;\n private userAssertionToken: string;\n private clientAssertion?: () => Promise<string>;\n\n /**\n * Creates an instance of the {@link OnBehalfOfCredential} with the details\n * needed to authenticate against Microsoft Entra ID with path to a PEM certificate,\n * and an user assertion.\n *\n * Example using the `KeyClient` from [\\@azure/keyvault-keys](https://www.npmjs.com/package/\\@azure/keyvault-keys):\n *\n * ```ts snippet:on_behalf_of_credential_pem_example\n * import { OnBehalfOfCredential } from \"@azure/identity\";\n * import { KeyClient } from \"@azure/keyvault-keys\";\n *\n * const tokenCredential = new OnBehalfOfCredential({\n * tenantId: \"tenant-id\",\n * clientId: \"client-id\",\n * certificatePath: \"/path/to/certificate.pem\",\n * userAssertionToken: \"access-token\",\n * });\n * const client = new KeyClient(\"vault-url\", tokenCredential);\n *\n * await client.getKey(\"key-name\");\n * ```\n *\n * @param options - Optional parameters, generally common across credentials.\n */\n constructor(\n options: OnBehalfOfCredentialCertificateOptions &\n MultiTenantTokenCredentialOptions &\n CredentialPersistenceOptions,\n );\n /**\n * Creates an instance of the {@link OnBehalfOfCredential} with the details\n * needed to authenticate against Microsoft Entra ID with a client\n * secret and an user assertion.\n *\n * Example using the `KeyClient` from [\\@azure/keyvault-keys](https://www.npmjs.com/package/\\@azure/keyvault-keys):\n *\n * ```ts snippet:on_behalf_of_credential_secret_example\n * import { OnBehalfOfCredential } from \"@azure/identity\";\n * import { KeyClient } from \"@azure/keyvault-keys\";\n *\n * const tokenCredential = new OnBehalfOfCredential({\n * tenantId: \"tenant-id\",\n * clientId: \"client-id\",\n * clientSecret: \"client-secret\",\n * userAssertionToken: \"access-token\",\n * });\n * const client = new KeyClient(\"vault-url\", tokenCredential);\n *\n * await client.getKey(\"key-name\");\n * ```\n *\n * @param options - Optional parameters, generally common across credentials.\n */\n constructor(\n options: OnBehalfOfCredentialSecretOptions &\n MultiTenantTokenCredentialOptions &\n CredentialPersistenceOptions,\n );\n\n /**\n * Creates an instance of the {@link OnBehalfOfCredential} with the details\n * needed to authenticate against Microsoft Entra ID with a client `getAssertion`\n * and an user assertion.\n *\n * Example using the `KeyClient` from [\\@azure/keyvault-keys](https://www.npmjs.com/package/\\@azure/keyvault-keys):\n *\n * ```ts snippet:on_behalf_of_credential_assertion_example\n * import { OnBehalfOfCredential } from \"@azure/identity\";\n * import { KeyClient } from \"@azure/keyvault-keys\";\n *\n * const tokenCredential = new OnBehalfOfCredential({\n * tenantId: \"tenant-id\",\n * clientId: \"client-id\",\n * getAssertion: () => {\n * return Promise.resolve(\"my-jwt\");\n * },\n * userAssertionToken: \"access-token\",\n * });\n * const client = new KeyClient(\"vault-url\", tokenCredential);\n *\n * await client.getKey(\"key-name\");\n * ```\n *\n * @param options - Optional parameters, generally common across credentials.\n */\n constructor(\n options: OnBehalfOfCredentialAssertionOptions &\n MultiTenantTokenCredentialOptions &\n CredentialPersistenceOptions,\n );\n\n constructor(options: OnBehalfOfCredentialOptions) {\n const { clientSecret } = options as OnBehalfOfCredentialSecretOptions;\n const { certificatePath, sendCertificateChain } =\n options as OnBehalfOfCredentialCertificateOptions;\n const { getAssertion } = options as OnBehalfOfCredentialAssertionOptions;\n const {\n tenantId,\n clientId,\n userAssertionToken,\n additionallyAllowedTenants: additionallyAllowedTenantIds,\n } = options;\n if (!tenantId) {\n throw new CredentialUnavailableError(\n `${credentialName}: 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 `${credentialName}: clientId is a required parameter. To troubleshoot, visit https://aka.ms/azsdk/js/identity/serviceprincipalauthentication/troubleshoot.`,\n );\n }\n\n if (!clientSecret && !certificatePath && !getAssertion) {\n throw new CredentialUnavailableError(\n `${credentialName}: You must provide one of clientSecret, certificatePath, or a getAssertion callback but none were provided. To troubleshoot, visit https://aka.ms/azsdk/js/identity/serviceprincipalauthentication/troubleshoot.`,\n );\n }\n\n if (!userAssertionToken) {\n throw new CredentialUnavailableError(\n `${credentialName}: userAssertionToken is a required parameter. To troubleshoot, visit https://aka.ms/azsdk/js/identity/serviceprincipalauthentication/troubleshoot.`,\n );\n }\n this.certificatePath = certificatePath;\n this.clientSecret = clientSecret;\n this.userAssertionToken = userAssertionToken;\n this.sendCertificateChain = sendCertificateChain;\n this.clientAssertion = getAssertion;\n\n this.tenantId = tenantId;\n this.additionallyAllowedTenantIds = resolveAdditionallyAllowedTenantIds(\n additionallyAllowedTenantIds,\n );\n\n this.msalClient = createMsalClient(clientId, this.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 the underlying network requests.\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 = ensureScopes(scopes);\n if (this.certificatePath) {\n const clientCertificate = await this.buildClientCertificate(this.certificatePath);\n\n return this.msalClient.getTokenOnBehalfOf(\n arrayScopes,\n this.userAssertionToken,\n clientCertificate,\n newOptions,\n );\n } else if (this.clientSecret) {\n return this.msalClient.getTokenOnBehalfOf(\n arrayScopes,\n this.userAssertionToken,\n this.clientSecret,\n options,\n );\n } else if (this.clientAssertion) {\n return this.msalClient.getTokenOnBehalfOf(\n arrayScopes,\n this.userAssertionToken,\n this.clientAssertion,\n options,\n );\n } else {\n // this is an invalid scenario and is a bug, as the constructor should have thrown an error if neither clientSecret nor certificatePath nor clientAssertion were provided\n throw new Error(\n \"Expected either clientSecret or certificatePath or clientAssertion to be defined.\",\n );\n }\n });\n }\n\n private async buildClientCertificate(certificatePath: string): Promise<CertificateParts> {\n try {\n const parts = await this.parseCertificate({ certificatePath }, this.sendCertificateChain);\n return {\n thumbprint: parts.thumbprint,\n privateKey: parts.certificateContents,\n x5c: parts.x5c,\n };\n } catch (error: any) {\n logger.info(formatError(\"\", error));\n throw error;\n }\n }\n\n private async parseCertificate(\n configuration: ClientCertificatePEMCertificatePath,\n sendCertificateChain?: boolean,\n ): Promise<Omit<CertificateParts, \"privateKey\"> & { certificateContents: string }> {\n const certificatePath = configuration.certificatePath;\n const certificateContents = 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}\n"]}
|
@@ -0,0 +1,76 @@
|
|
1
|
+
import type { AuthorityValidationOptions } from "./authorityValidationOptions.js";
|
2
|
+
import type { CredentialPersistenceOptions } from "./credentialPersistenceOptions.js";
|
3
|
+
import type { MultiTenantTokenCredentialOptions } from "./multiTenantTokenCredentialOptions.js";
|
4
|
+
/**
|
5
|
+
* Defines the parameters to authenticate the {@link OnBehalfOfCredential} with a secret.
|
6
|
+
*/
|
7
|
+
export interface OnBehalfOfCredentialSecretOptions {
|
8
|
+
/**
|
9
|
+
* The Microsoft Entra tenant (directory) ID.
|
10
|
+
*/
|
11
|
+
tenantId: string;
|
12
|
+
/**
|
13
|
+
* The client (application) ID of an App Registration in the tenant.
|
14
|
+
*/
|
15
|
+
clientId: string;
|
16
|
+
/**
|
17
|
+
* A client secret that was generated for the App Registration.
|
18
|
+
*/
|
19
|
+
clientSecret: string;
|
20
|
+
/**
|
21
|
+
* The user assertion for the On-Behalf-Of flow.
|
22
|
+
*/
|
23
|
+
userAssertionToken: string;
|
24
|
+
}
|
25
|
+
/**
|
26
|
+
* Defines the parameters to authenticate the {@link OnBehalfOfCredential} with a certificate.
|
27
|
+
*/
|
28
|
+
export interface OnBehalfOfCredentialCertificateOptions {
|
29
|
+
/**
|
30
|
+
* The Microsoft Entra tenant (directory) ID.
|
31
|
+
*/
|
32
|
+
tenantId: string;
|
33
|
+
/**
|
34
|
+
* The client (application) ID of an App Registration in the tenant.
|
35
|
+
*/
|
36
|
+
clientId: string;
|
37
|
+
/**
|
38
|
+
* The path to a PEM-encoded public/private key certificate on the filesystem.
|
39
|
+
*/
|
40
|
+
certificatePath: string;
|
41
|
+
/**
|
42
|
+
* The user assertion for the On-Behalf-Of flow.
|
43
|
+
*/
|
44
|
+
userAssertionToken: string;
|
45
|
+
/**
|
46
|
+
* Option to include x5c header for SubjectName and Issuer name authorization.
|
47
|
+
* Set this option to send base64 encoded public certificate in the client assertion header as an x5c claim
|
48
|
+
*/
|
49
|
+
sendCertificateChain?: boolean;
|
50
|
+
}
|
51
|
+
/**
|
52
|
+
* Defines the parameters to authenticate the {@link OnBehalfOfCredential} with an assertion.
|
53
|
+
*/
|
54
|
+
export interface OnBehalfOfCredentialAssertionOptions {
|
55
|
+
/**
|
56
|
+
* The Microsoft Entra tenant (directory) ID.
|
57
|
+
*/
|
58
|
+
tenantId: string;
|
59
|
+
/**
|
60
|
+
* The client (application) ID of an App Registration in the tenant.
|
61
|
+
*/
|
62
|
+
clientId: string;
|
63
|
+
/**
|
64
|
+
* A function that retrieves the client assertion for the credential to use
|
65
|
+
*/
|
66
|
+
getAssertion: () => Promise<string>;
|
67
|
+
/**
|
68
|
+
* The user assertion for the On-Behalf-Of flow.
|
69
|
+
*/
|
70
|
+
userAssertionToken: string;
|
71
|
+
}
|
72
|
+
/**
|
73
|
+
* Optional parameters for the {@link OnBehalfOfCredential} class.
|
74
|
+
*/
|
75
|
+
export type OnBehalfOfCredentialOptions = (OnBehalfOfCredentialSecretOptions | OnBehalfOfCredentialCertificateOptions | OnBehalfOfCredentialAssertionOptions) & MultiTenantTokenCredentialOptions & CredentialPersistenceOptions & AuthorityValidationOptions;
|
76
|
+
//# sourceMappingURL=onBehalfOfCredentialOptions.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"onBehalfOfCredentialOptions.d.ts","sourceRoot":"","sources":["../../../src/credentials/onBehalfOfCredentialOptions.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAClF,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAC;AACtF,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,wCAAwC,CAAC;AAEhG;;GAEG;AACH,MAAM,WAAW,iCAAiC;IAChD;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,sCAAsC;IACrD;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,eAAe,EAAE,MAAM,CAAC;IACxB;;OAEG;IACH,kBAAkB,EAAE,MAAM,CAAC;IAC3B;;;OAGG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,oCAAoC;IACnD;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,YAAY,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;IACpC;;OAEG;IACH,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AACD;;GAEG;AACH,MAAM,MAAM,2BAA2B,GAAG,CACtC,iCAAiC,GACjC,sCAAsC,GACtC,oCAAoC,CACvC,GACC,iCAAiC,GACjC,4BAA4B,GAC5B,0BAA0B,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"onBehalfOfCredentialOptions.js","sourceRoot":"","sources":["../../../src/credentials/onBehalfOfCredentialOptions.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AuthorityValidationOptions } from \"./authorityValidationOptions.js\";\nimport type { CredentialPersistenceOptions } from \"./credentialPersistenceOptions.js\";\nimport type { MultiTenantTokenCredentialOptions } from \"./multiTenantTokenCredentialOptions.js\";\n\n/**\n * Defines the parameters to authenticate the {@link OnBehalfOfCredential} with a secret.\n */\nexport interface OnBehalfOfCredentialSecretOptions {\n /**\n * The Microsoft Entra tenant (directory) ID.\n */\n tenantId: string;\n /**\n * The client (application) ID of an App Registration in the tenant.\n */\n clientId: string;\n /**\n * A client secret that was generated for the App Registration.\n */\n clientSecret: string;\n /**\n * The user assertion for the On-Behalf-Of flow.\n */\n userAssertionToken: string;\n}\n\n/**\n * Defines the parameters to authenticate the {@link OnBehalfOfCredential} with a certificate.\n */\nexport interface OnBehalfOfCredentialCertificateOptions {\n /**\n * The Microsoft Entra tenant (directory) ID.\n */\n tenantId: string;\n /**\n * The client (application) ID of an App Registration in the tenant.\n */\n clientId: string;\n /**\n * The path to a PEM-encoded public/private key certificate on the filesystem.\n */\n certificatePath: string;\n /**\n * The user assertion for the On-Behalf-Of flow.\n */\n userAssertionToken: string;\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}\n\n/**\n * Defines the parameters to authenticate the {@link OnBehalfOfCredential} with an assertion.\n */\nexport interface OnBehalfOfCredentialAssertionOptions {\n /**\n * The Microsoft Entra tenant (directory) ID.\n */\n tenantId: string;\n /**\n * The client (application) ID of an App Registration in the tenant.\n */\n clientId: string;\n /**\n * A function that retrieves the client assertion for the credential to use\n */\n getAssertion: () => Promise<string>;\n /**\n * The user assertion for the On-Behalf-Of flow.\n */\n userAssertionToken: string;\n}\n/**\n * Optional parameters for the {@link OnBehalfOfCredential} class.\n */\nexport type OnBehalfOfCredentialOptions = (\n | OnBehalfOfCredentialSecretOptions\n | OnBehalfOfCredentialCertificateOptions\n | OnBehalfOfCredentialAssertionOptions\n) &\n MultiTenantTokenCredentialOptions &\n CredentialPersistenceOptions &\n AuthorityValidationOptions;\n"]}
|
@@ -0,0 +1,42 @@
|
|
1
|
+
import type { AccessToken, GetTokenOptions, TokenCredential } from "@azure/core-auth";
|
2
|
+
import type { UsernamePasswordCredentialOptions } from "./usernamePasswordCredentialOptions.js";
|
3
|
+
/**
|
4
|
+
* Enables authentication to Microsoft Entra ID with a user's
|
5
|
+
* username and password. This credential requires a high degree of
|
6
|
+
* trust so you should only use it when other, more secure credential
|
7
|
+
* types can't be used.
|
8
|
+
* @deprecated UsernamePasswordCredential is deprecated. Use a more secure credential. See https://aka.ms/azsdk/identity/mfa for details.
|
9
|
+
*/
|
10
|
+
export declare class UsernamePasswordCredential implements TokenCredential {
|
11
|
+
private tenantId;
|
12
|
+
private additionallyAllowedTenantIds;
|
13
|
+
private msalClient;
|
14
|
+
private username;
|
15
|
+
private password;
|
16
|
+
/**
|
17
|
+
* Creates an instance of the UsernamePasswordCredential with the details
|
18
|
+
* needed to authenticate against Microsoft Entra ID with a username
|
19
|
+
* and password.
|
20
|
+
*
|
21
|
+
* @param tenantId - The Microsoft Entra tenant (directory).
|
22
|
+
* @param clientId - The client (application) ID of an App Registration in the tenant.
|
23
|
+
* @param username - The user account's e-mail address (user name).
|
24
|
+
* @param password - The user account's account password
|
25
|
+
* @param options - Options for configuring the client which makes the authentication request.
|
26
|
+
*/
|
27
|
+
constructor(tenantId: string, clientId: string, username: string, password: string, options?: UsernamePasswordCredentialOptions);
|
28
|
+
/**
|
29
|
+
* Authenticates with Microsoft Entra ID and returns an access token if successful.
|
30
|
+
* If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
31
|
+
*
|
32
|
+
* If the user provided the option `disableAutomaticAuthentication`,
|
33
|
+
* once the token can't be retrieved silently,
|
34
|
+
* this method won't attempt to request user interaction to retrieve the token.
|
35
|
+
*
|
36
|
+
* @param scopes - The list of scopes for which the token will have access.
|
37
|
+
* @param options - The options used to configure any requests this
|
38
|
+
* TokenCredential implementation might make.
|
39
|
+
*/
|
40
|
+
getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken>;
|
41
|
+
}
|
42
|
+
//# sourceMappingURL=usernamePasswordCredential.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"usernamePasswordCredential.d.ts","sourceRoot":"","sources":["../../../src/credentials/usernamePasswordCredential.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAStF,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,wCAAwC,CAAC;AAOhG;;;;;;GAMG;AACH,qBAAa,0BAA2B,YAAW,eAAe;IAChE,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,4BAA4B,CAAW;IAC/C,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,QAAQ,CAAS;IAEzB;;;;;;;;;;OAUG;gBAED,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,iCAAsC;IAwCjD;;;;;;;;;;;OAWG;IACG,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,OAAO,GAAE,eAAoB,GAAG,OAAO,CAAC,WAAW,CAAC;CAsB/F"}
|