@azure/identity 3.0.0-beta.1 → 3.0.1

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.

Potentially problematic release.


This version of @azure/identity might be problematic. Click here for more details.

Files changed (132) hide show
  1. package/README.md +1 -1
  2. package/dist/index.js +2469 -2424
  3. package/dist/index.js.map +1 -1
  4. package/dist-esm/src/client/identityClient.js +5 -9
  5. package/dist-esm/src/client/identityClient.js.map +1 -1
  6. package/dist-esm/src/constants.js +5 -1
  7. package/dist-esm/src/constants.js.map +1 -1
  8. package/dist-esm/src/credentials/authorizationCodeCredential.browser.js.map +1 -1
  9. package/dist-esm/src/credentials/authorizationCodeCredential.js +10 -3
  10. package/dist-esm/src/credentials/authorizationCodeCredential.js.map +1 -1
  11. package/dist-esm/src/credentials/authorizationCodeCredentialOptions.js +4 -0
  12. package/dist-esm/src/credentials/authorizationCodeCredentialOptions.js.map +1 -0
  13. package/dist-esm/src/credentials/azureApplicationCredential.browser.js.map +1 -1
  14. package/dist-esm/src/credentials/azureApplicationCredential.js +1 -1
  15. package/dist-esm/src/credentials/azureApplicationCredential.js.map +1 -1
  16. package/dist-esm/src/credentials/azureApplicationCredentialOptions.js +4 -0
  17. package/dist-esm/src/credentials/azureApplicationCredentialOptions.js.map +1 -0
  18. package/dist-esm/src/credentials/azureCliCredential.browser.js.map +1 -1
  19. package/dist-esm/src/credentials/azureCliCredential.js +6 -9
  20. package/dist-esm/src/credentials/azureCliCredential.js.map +1 -1
  21. package/dist-esm/src/credentials/azureCliCredentialOptions.js.map +1 -1
  22. package/dist-esm/src/credentials/azurePowerShellCredential.browser.js.map +1 -1
  23. package/dist-esm/src/credentials/azurePowerShellCredential.js +5 -8
  24. package/dist-esm/src/credentials/azurePowerShellCredential.js.map +1 -1
  25. package/dist-esm/src/credentials/azurePowerShellCredentialOptions.js.map +1 -1
  26. package/dist-esm/src/credentials/chainedTokenCredential.js +1 -1
  27. package/dist-esm/src/credentials/chainedTokenCredential.js.map +1 -1
  28. package/dist-esm/src/credentials/clientAssertionCredential.js +4 -1
  29. package/dist-esm/src/credentials/clientAssertionCredential.js.map +1 -1
  30. package/dist-esm/src/credentials/clientAssertionCredentialOptions.js +4 -0
  31. package/dist-esm/src/credentials/clientAssertionCredentialOptions.js.map +1 -0
  32. package/dist-esm/src/credentials/clientCertificateCredential.js +4 -0
  33. package/dist-esm/src/credentials/clientCertificateCredential.js.map +1 -1
  34. package/dist-esm/src/credentials/clientCertificateCredentialOptions.js.map +1 -1
  35. package/dist-esm/src/credentials/clientSecretCredential.browser.js +6 -3
  36. package/dist-esm/src/credentials/clientSecretCredential.browser.js.map +1 -1
  37. package/dist-esm/src/credentials/clientSecretCredential.js +6 -1
  38. package/dist-esm/src/credentials/clientSecretCredential.js.map +1 -1
  39. package/dist-esm/src/credentials/clientSecretCredentialOptions.js.map +1 -1
  40. package/dist-esm/src/credentials/defaultAzureCredential.browser.js.map +1 -1
  41. package/dist-esm/src/credentials/defaultAzureCredential.js +2 -2
  42. package/dist-esm/src/credentials/defaultAzureCredential.js.map +1 -1
  43. package/dist-esm/src/credentials/defaultAzureCredentialOptions.js +4 -0
  44. package/dist-esm/src/credentials/defaultAzureCredentialOptions.js.map +1 -0
  45. package/dist-esm/src/credentials/deviceCodeCredential.js +7 -2
  46. package/dist-esm/src/credentials/deviceCodeCredential.js.map +1 -1
  47. package/dist-esm/src/credentials/deviceCodeCredentialOptions.js.map +1 -1
  48. package/dist-esm/src/credentials/environmentCredential.browser.js.map +1 -1
  49. package/dist-esm/src/credentials/environmentCredential.js +18 -7
  50. package/dist-esm/src/credentials/environmentCredential.js.map +1 -1
  51. package/dist-esm/src/credentials/environmentCredentialOptions.js +4 -0
  52. package/dist-esm/src/credentials/environmentCredentialOptions.js.map +1 -0
  53. package/dist-esm/src/credentials/interactiveBrowserCredential.browser.js +9 -3
  54. package/dist-esm/src/credentials/interactiveBrowserCredential.browser.js.map +1 -1
  55. package/dist-esm/src/credentials/interactiveBrowserCredential.js +8 -3
  56. package/dist-esm/src/credentials/interactiveBrowserCredential.js.map +1 -1
  57. package/dist-esm/src/credentials/interactiveBrowserCredentialOptions.js.map +1 -1
  58. package/dist-esm/src/credentials/interactiveCredentialOptions.js.map +1 -1
  59. package/dist-esm/src/credentials/managedIdentityCredential/appServiceMsi2017.js +1 -8
  60. package/dist-esm/src/credentials/managedIdentityCredential/appServiceMsi2017.js.map +1 -1
  61. package/dist-esm/src/credentials/managedIdentityCredential/appServiceMsi2019.js +1 -8
  62. package/dist-esm/src/credentials/managedIdentityCredential/appServiceMsi2019.js.map +1 -1
  63. package/dist-esm/src/credentials/managedIdentityCredential/fabricMsi.js +1 -8
  64. package/dist-esm/src/credentials/managedIdentityCredential/fabricMsi.js.map +1 -1
  65. package/dist-esm/src/credentials/managedIdentityCredential/imdsMsi.js +31 -53
  66. package/dist-esm/src/credentials/managedIdentityCredential/imdsMsi.js.map +1 -1
  67. package/dist-esm/src/credentials/managedIdentityCredential/models.js.map +1 -1
  68. package/dist-esm/src/credentials/managedIdentityCredential/utils.js +23 -0
  69. package/dist-esm/src/credentials/managedIdentityCredential/utils.js.map +1 -1
  70. package/dist-esm/src/credentials/multiTenantTokenCredentialOptions.js +4 -0
  71. package/dist-esm/src/credentials/multiTenantTokenCredentialOptions.js.map +1 -0
  72. package/dist-esm/src/credentials/onBehalfOfCredential.js +7 -2
  73. package/dist-esm/src/credentials/onBehalfOfCredential.js.map +1 -1
  74. package/dist-esm/src/credentials/onBehalfOfCredentialOptions.js.map +1 -1
  75. package/dist-esm/src/credentials/usernamePasswordCredential.browser.js +8 -17
  76. package/dist-esm/src/credentials/usernamePasswordCredential.browser.js.map +1 -1
  77. package/dist-esm/src/credentials/usernamePasswordCredential.js +7 -2
  78. package/dist-esm/src/credentials/usernamePasswordCredential.js.map +1 -1
  79. package/dist-esm/src/credentials/usernamePasswordCredentialOptions.js.map +1 -1
  80. package/dist-esm/src/credentials/visualStudioCodeCredential.browser.js.map +1 -1
  81. package/dist-esm/src/credentials/visualStudioCodeCredential.js +9 -7
  82. package/dist-esm/src/credentials/visualStudioCodeCredential.js.map +1 -1
  83. package/dist-esm/src/credentials/visualStudioCodeCredentialOptions.js +4 -0
  84. package/dist-esm/src/credentials/visualStudioCodeCredentialOptions.js.map +1 -0
  85. package/dist-esm/src/index.js +4 -4
  86. package/dist-esm/src/index.js.map +1 -1
  87. package/dist-esm/src/msal/browserFlows/msalAuthCode.js +2 -2
  88. package/dist-esm/src/msal/browserFlows/msalAuthCode.js.map +1 -1
  89. package/dist-esm/src/msal/browserFlows/msalBrowserCommon.js +6 -4
  90. package/dist-esm/src/msal/browserFlows/msalBrowserCommon.js.map +1 -1
  91. package/dist-esm/src/msal/credentials.js.map +1 -1
  92. package/dist-esm/src/msal/flows.js.map +1 -1
  93. package/dist-esm/src/msal/nodeFlows/msalAuthorizationCode.js +1 -1
  94. package/dist-esm/src/msal/nodeFlows/msalAuthorizationCode.js.map +1 -1
  95. package/dist-esm/src/msal/nodeFlows/msalClientAssertion.js +1 -1
  96. package/dist-esm/src/msal/nodeFlows/msalClientAssertion.js.map +1 -1
  97. package/dist-esm/src/msal/nodeFlows/msalClientCertificate.js +3 -3
  98. package/dist-esm/src/msal/nodeFlows/msalClientCertificate.js.map +1 -1
  99. package/dist-esm/src/msal/nodeFlows/msalClientSecret.js.map +1 -1
  100. package/dist-esm/src/msal/nodeFlows/msalDeviceCode.js.map +1 -1
  101. package/dist-esm/src/msal/nodeFlows/msalNodeCommon.js +11 -10
  102. package/dist-esm/src/msal/nodeFlows/msalNodeCommon.js.map +1 -1
  103. package/dist-esm/src/msal/nodeFlows/msalOnBehalfOf.js +1 -1
  104. package/dist-esm/src/msal/nodeFlows/msalOnBehalfOf.js.map +1 -1
  105. package/dist-esm/src/msal/nodeFlows/msalOpenBrowser.js +5 -5
  106. package/dist-esm/src/msal/nodeFlows/msalOpenBrowser.js.map +1 -1
  107. package/dist-esm/src/msal/nodeFlows/msalUsernamePassword.js.map +1 -1
  108. package/dist-esm/src/msal/utils.js +4 -4
  109. package/dist-esm/src/msal/utils.js.map +1 -1
  110. package/dist-esm/src/plugins/provider.js.map +1 -1
  111. package/dist-esm/src/util/logging.js +4 -0
  112. package/dist-esm/src/util/logging.js.map +1 -1
  113. package/dist-esm/src/util/processMultiTenantRequest.browser.js +29 -0
  114. package/dist-esm/src/util/processMultiTenantRequest.browser.js.map +1 -0
  115. package/dist-esm/src/util/processMultiTenantRequest.js +32 -0
  116. package/dist-esm/src/util/processMultiTenantRequest.js.map +1 -0
  117. package/dist-esm/src/util/scopeUtils.js +7 -0
  118. package/dist-esm/src/util/scopeUtils.js.map +1 -1
  119. package/dist-esm/src/util/tenantIdUtils.js +44 -0
  120. package/dist-esm/src/util/tenantIdUtils.js.map +1 -0
  121. package/dist-esm/src/util/tracing.js +1 -1
  122. package/dist-esm/src/util/tracing.js.map +1 -1
  123. package/package.json +2 -2
  124. package/types/identity.d.ts +59 -15
  125. package/dist-esm/src/util/checkTenantId.js +0 -11
  126. package/dist-esm/src/util/checkTenantId.js.map +0 -1
  127. package/dist-esm/src/util/resolveTenantId.js +0 -18
  128. package/dist-esm/src/util/resolveTenantId.js.map +0 -1
  129. package/dist-esm/src/util/validateMultiTenant.browser.js +0 -22
  130. package/dist-esm/src/util/validateMultiTenant.browser.js.map +0 -1
  131. package/dist-esm/src/util/validateMultiTenant.js +0 -29
  132. package/dist-esm/src/util/validateMultiTenant.js.map +0 -1
@@ -122,6 +122,8 @@ export declare class AuthorizationCodeCredential implements TokenCredential {
122
122
  private disableAutomaticAuthentication?;
123
123
  private authorizationCode;
124
124
  private redirectUri;
125
+ private tenantId?;
126
+ private additionallyAllowedTenantIds;
125
127
  /**
126
128
  * Creates an instance of AuthorizationCodeCredential with the details needed
127
129
  * to request an access token using an authentication that was obtained
@@ -144,7 +146,7 @@ export declare class AuthorizationCodeCredential implements TokenCredential {
144
146
  Must be the same URI that is configured for the App Registration.
145
147
  * @param options - Options for configuring the client which makes the access token request.
146
148
  */
147
- constructor(tenantId: string | "common", clientId: string, clientSecret: string, authorizationCode: string, redirectUri: string, options?: TokenCredentialOptions);
149
+ constructor(tenantId: string | "common", clientId: string, clientSecret: string, authorizationCode: string, redirectUri: string, options?: AuthorizationCodeCredentialOptions);
148
150
  /**
149
151
  * Creates an instance of AuthorizationCodeCredential with the details needed
150
152
  * to request an access token using an authentication that was obtained
@@ -166,7 +168,7 @@ export declare class AuthorizationCodeCredential implements TokenCredential {
166
168
  Must be the same URI that is configured for the App Registration.
167
169
  * @param options - Options for configuring the client which makes the access token request.
168
170
  */
169
- constructor(tenantId: string | "common", clientId: string, authorizationCode: string, redirectUri: string, options?: TokenCredentialOptions);
171
+ constructor(tenantId: string | "common", clientId: string, authorizationCode: string, redirectUri: string, options?: AuthorizationCodeCredentialOptions);
170
172
  /**
171
173
  * Authenticates with Azure Active Directory and returns an access token if successful.
172
174
  * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
@@ -178,6 +180,12 @@ export declare class AuthorizationCodeCredential implements TokenCredential {
178
180
  getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken>;
179
181
  }
180
182
 
183
+ /**
184
+ * Options for the {@link AuthorizationCodeCredential}
185
+ */
186
+ export declare interface AuthorizationCodeCredentialOptions extends MultiTenantTokenCredentialOptions {
187
+ }
188
+
181
189
  /**
182
190
  * A list of known Azure authority hosts
183
191
  */
@@ -208,6 +216,7 @@ export declare enum AzureAuthorityHosts {
208
216
  */
209
217
  export declare class AzureCliCredential implements TokenCredential {
210
218
  private tenantId?;
219
+ private additionallyAllowedTenantIds;
211
220
  /**
212
221
  * Creates an instance of the {@link AzureCliCredential}.
213
222
  *
@@ -231,7 +240,7 @@ export declare class AzureCliCredential implements TokenCredential {
231
240
  /**
232
241
  * Options for the {@link AzureCliCredential}
233
242
  */
234
- export declare interface AzureCliCredentialOptions extends TokenCredentialOptions {
243
+ export declare interface AzureCliCredentialOptions extends MultiTenantTokenCredentialOptions {
235
244
  /**
236
245
  * Allows specifying a tenant ID
237
246
  */
@@ -245,6 +254,7 @@ export declare interface AzureCliCredentialOptions extends TokenCredentialOption
245
254
  */
246
255
  export declare class AzurePowerShellCredential implements TokenCredential {
247
256
  private tenantId?;
257
+ private additionallyAllowedTenantIds;
248
258
  /**
249
259
  * Creates an instance of the {@link AzurePowerShellCredential}.
250
260
  *
@@ -275,7 +285,7 @@ export declare class AzurePowerShellCredential implements TokenCredential {
275
285
  /**
276
286
  * Options for the {@link AzurePowerShellCredential}
277
287
  */
278
- export declare interface AzurePowerShellCredentialOptions extends TokenCredentialOptions {
288
+ export declare interface AzurePowerShellCredentialOptions extends MultiTenantTokenCredentialOptions {
279
289
  /**
280
290
  * Allows specifying a tenant ID
281
291
  */
@@ -338,6 +348,7 @@ export declare class ChainedTokenCredential implements TokenCredential {
338
348
  export declare class ClientAssertionCredential implements TokenCredential {
339
349
  private msalFlow;
340
350
  private tenantId;
351
+ private additionallyAllowedTenantIds;
341
352
  private clientId;
342
353
  private options;
343
354
  /**
@@ -350,7 +361,7 @@ export declare class ClientAssertionCredential implements TokenCredential {
350
361
  * @param getAssertion - A function that retrieves the assertion for the credential to use.
351
362
  * @param options - Options for configuring the client which makes the authentication request.
352
363
  */
353
- constructor(tenantId: string, clientId: string, getAssertion: () => Promise<string>, options?: TokenCredentialOptions);
364
+ constructor(tenantId: string, clientId: string, getAssertion: () => Promise<string>, options?: ClientAssertionCredentialOptions);
354
365
  /**
355
366
  * Authenticates with Azure Active Directory and returns an access token if successful.
356
367
  * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
@@ -362,6 +373,12 @@ export declare class ClientAssertionCredential implements TokenCredential {
362
373
  getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken>;
363
374
  }
364
375
 
376
+ /**
377
+ * Options for the {@link ClientAssertionCredential}
378
+ */
379
+ export declare interface ClientAssertionCredentialOptions extends MultiTenantTokenCredentialOptions {
380
+ }
381
+
365
382
  /**
366
383
  * Enables authentication to Azure Active Directory using a PEM-encoded
367
384
  * certificate that is assigned to an App Registration. More information
@@ -371,6 +388,8 @@ export declare class ClientAssertionCredential implements TokenCredential {
371
388
  *
372
389
  */
373
390
  export declare class ClientCertificateCredential implements TokenCredential {
391
+ private tenantId;
392
+ private additionallyAllowedTenantIds;
374
393
  private msalFlow;
375
394
  /**
376
395
  * Creates an instance of the ClientCertificateCredential with the details
@@ -418,7 +437,7 @@ export declare class ClientCertificateCredential implements TokenCredential {
418
437
  /**
419
438
  * Optional parameters for the {@link ClientCertificateCredential} class.
420
439
  */
421
- export declare interface ClientCertificateCredentialOptions extends TokenCredentialOptions, CredentialPersistenceOptions {
440
+ export declare interface ClientCertificateCredentialOptions extends MultiTenantTokenCredentialOptions, CredentialPersistenceOptions {
422
441
  /**
423
442
  * Option to include x5c header for SubjectName and Issuer name authorization.
424
443
  * Set this option to send base64 encoded public certificate in the client assertion header as an x5c claim
@@ -468,6 +487,8 @@ export declare interface ClientCertificatePEMCertificatePath {
468
487
  *
469
488
  */
470
489
  export declare class ClientSecretCredential implements TokenCredential {
490
+ private tenantId;
491
+ private additionallyAllowedTenantIds;
471
492
  private msalFlow;
472
493
  /**
473
494
  * Creates an instance of the ClientSecretCredential with the details
@@ -494,7 +515,7 @@ export declare class ClientSecretCredential implements TokenCredential {
494
515
  /**
495
516
  * Optional parameters for the {@link ClientSecretCredential} class.
496
517
  */
497
- export declare interface ClientSecretCredentialOptions extends TokenCredentialOptions, CredentialPersistenceOptions {
518
+ export declare interface ClientSecretCredentialOptions extends MultiTenantTokenCredentialOptions, CredentialPersistenceOptions {
498
519
  }
499
520
 
500
521
  /**
@@ -627,7 +648,7 @@ export declare interface DefaultAzureCredentialClientIdOptions extends DefaultAz
627
648
  /**
628
649
  * Provides options to configure the {@link DefaultAzureCredential} class.
629
650
  */
630
- export declare interface DefaultAzureCredentialOptions extends TokenCredentialOptions {
651
+ export declare interface DefaultAzureCredentialOptions extends MultiTenantTokenCredentialOptions {
631
652
  /**
632
653
  * Optionally pass in a Tenant ID to be used as part of the credential.
633
654
  * By default it may use a generic tenant ID depending on the underlying credential.
@@ -676,6 +697,8 @@ export declare function deserializeAuthenticationRecord(serializedRecord: string
676
697
  * that the user can enter into https://microsoft.com/devicelogin.
677
698
  */
678
699
  export declare class DeviceCodeCredential implements TokenCredential {
700
+ private tenantId?;
701
+ private additionallyAllowedTenantIds;
679
702
  private msalFlow;
680
703
  private disableAutomaticAuthentication?;
681
704
  /**
@@ -787,6 +810,9 @@ export declare class EnvironmentCredential implements TokenCredential {
787
810
  * - `AZURE_TENANT_ID`: The Azure Active Directory tenant (directory) ID.
788
811
  * - `AZURE_CLIENT_ID`: The client (application) ID of an App Registration in the tenant.
789
812
  *
813
+ * If setting the AZURE_TENANT_ID, then you can also set the additionally allowed tenants
814
+ * - `AZURE_ADDITIONALLY_ALLOWED_TENANTS`: For multi-tenant applications, specifies additional tenants for which the credential may acquire tokens with a single semicolon delimited string. Use * to allow all tenants.
815
+ *
790
816
  * Environment variables used for client credential authentication:
791
817
  * - `AZURE_CLIENT_SECRET`: A client secret that was generated for the App Registration.
792
818
  * - `AZURE_CLIENT_CERTIFICATE_PATH`: The path to a PEM certificate to use during the authentication, instead of the client secret.
@@ -815,7 +841,7 @@ export declare class EnvironmentCredential implements TokenCredential {
815
841
  * Enables authentication to Azure Active Directory depending on the available environment variables.
816
842
  * Defines options for the EnvironmentCredential class.
817
843
  */
818
- export declare interface EnvironmentCredentialOptions extends TokenCredentialOptions {
844
+ export declare interface EnvironmentCredentialOptions extends MultiTenantTokenCredentialOptions {
819
845
  }
820
846
 
821
847
  /**
@@ -871,6 +897,8 @@ export declare type IdentityPlugin = (context: unknown) => void;
871
897
  * using the interactive login flow.
872
898
  */
873
899
  export declare class InteractiveBrowserCredential implements TokenCredential {
900
+ private tenantId?;
901
+ private additionallyAllowedTenantIds;
874
902
  private msalFlow;
875
903
  private disableAutomaticAuthentication?;
876
904
  /**
@@ -974,7 +1002,7 @@ export declare interface InteractiveBrowserCredentialNodeOptions extends Interac
974
1002
  /**
975
1003
  * Common constructor options for the Identity credentials that requires user interaction.
976
1004
  */
977
- export declare interface InteractiveCredentialOptions extends TokenCredentialOptions {
1005
+ export declare interface InteractiveCredentialOptions extends MultiTenantTokenCredentialOptions {
978
1006
  /**
979
1007
  * Result of a previous authentication that can be used to retrieve the cached credentials of each individual account.
980
1008
  * This is necessary to provide in case the application wants to work with more than one account per
@@ -1073,11 +1101,24 @@ export declare interface ManagedIdentityCredentialResourceIdOptions extends Toke
1073
1101
  resourceId: string;
1074
1102
  }
1075
1103
 
1104
+ /**
1105
+ * Options for multi-tenant applications which allows for additionally allowed tenants.
1106
+ */
1107
+ export declare interface MultiTenantTokenCredentialOptions extends TokenCredentialOptions {
1108
+ /**
1109
+ * For multi-tenant applications, specifies additional tenants for which the credential may acquire tokens.
1110
+ * Add the wildcard value "*" to allow the credential to acquire tokens for any tenant the application is installed.
1111
+ */
1112
+ additionallyAllowedTenants?: string[];
1113
+ }
1114
+
1076
1115
  /**
1077
1116
  * Enables authentication to Azure Active Directory using the [On Behalf Of flow](https://docs.microsoft.com/azure/active-directory/develop/v2-oauth2-on-behalf-of-flow).
1078
1117
  */
1079
1118
  export declare class OnBehalfOfCredential implements TokenCredential {
1080
1119
  private options;
1120
+ private tenantId;
1121
+ private additionallyAllowedTenantIds;
1081
1122
  private msalFlow;
1082
1123
  /**
1083
1124
  * Creates an instance of the {@link OnBehalfOfCredential} with the details
@@ -1100,7 +1141,7 @@ export declare class OnBehalfOfCredential implements TokenCredential {
1100
1141
  *
1101
1142
  * @param options - Optional parameters, generally common across credentials.
1102
1143
  */
1103
- constructor(options: OnBehalfOfCredentialCertificateOptions & TokenCredentialOptions & CredentialPersistenceOptions);
1144
+ constructor(options: OnBehalfOfCredentialCertificateOptions & MultiTenantTokenCredentialOptions & CredentialPersistenceOptions);
1104
1145
  /**
1105
1146
  * Creates an instance of the {@link OnBehalfOfCredential} with the details
1106
1147
  * needed to authenticate against Azure Active Directory with a client
@@ -1122,7 +1163,7 @@ export declare class OnBehalfOfCredential implements TokenCredential {
1122
1163
  *
1123
1164
  * @param options - Optional parameters, generally common across credentials.
1124
1165
  */
1125
- constructor(options: OnBehalfOfCredentialSecretOptions & TokenCredentialOptions & CredentialPersistenceOptions);
1166
+ constructor(options: OnBehalfOfCredentialSecretOptions & MultiTenantTokenCredentialOptions & CredentialPersistenceOptions);
1126
1167
  /**
1127
1168
  * Authenticates with Azure Active Directory and returns an access token if successful.
1128
1169
  * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
@@ -1163,7 +1204,7 @@ export declare interface OnBehalfOfCredentialCertificateOptions {
1163
1204
  /**
1164
1205
  * Optional parameters for the {@link OnBehalfOfCredential} class.
1165
1206
  */
1166
- export declare type OnBehalfOfCredentialOptions = (OnBehalfOfCredentialSecretOptions | OnBehalfOfCredentialCertificateOptions) & TokenCredentialOptions & CredentialPersistenceOptions;
1207
+ export declare type OnBehalfOfCredentialOptions = (OnBehalfOfCredentialSecretOptions | OnBehalfOfCredentialCertificateOptions) & MultiTenantTokenCredentialOptions & CredentialPersistenceOptions;
1167
1208
 
1168
1209
  /**
1169
1210
  * Defines the parameters to authenticate the {@link OnBehalfOfCredential} with a secret.
@@ -1284,6 +1325,8 @@ export declare function useIdentityPlugin(plugin: IdentityPlugin): void;
1284
1325
  * types can't be used.
1285
1326
  */
1286
1327
  export declare class UsernamePasswordCredential implements TokenCredential {
1328
+ private tenantId;
1329
+ private additionallyAllowedTenantIds;
1287
1330
  private msalFlow;
1288
1331
  /**
1289
1332
  * Creates an instance of the UsernamePasswordCredential with the details
@@ -1315,7 +1358,7 @@ export declare class UsernamePasswordCredential implements TokenCredential {
1315
1358
  /**
1316
1359
  * Defines options for the {@link UsernamePasswordCredential} class.
1317
1360
  */
1318
- export declare interface UsernamePasswordCredentialOptions extends TokenCredentialOptions, CredentialPersistenceOptions {
1361
+ export declare interface UsernamePasswordCredentialOptions extends MultiTenantTokenCredentialOptions, CredentialPersistenceOptions {
1319
1362
  }
1320
1363
 
1321
1364
  /**
@@ -1326,6 +1369,7 @@ export declare interface UsernamePasswordCredentialOptions extends TokenCredenti
1326
1369
  export declare class VisualStudioCodeCredential implements TokenCredential {
1327
1370
  private identityClient;
1328
1371
  private tenantId;
1372
+ private additionallyAllowedTenantIds;
1329
1373
  private cloudName;
1330
1374
  /**
1331
1375
  * Creates an instance of VisualStudioCodeCredential to use for automatically authenticating via VSCode.
@@ -1364,7 +1408,7 @@ export declare class VisualStudioCodeCredential implements TokenCredential {
1364
1408
  /**
1365
1409
  * Provides options to configure the Visual Studio Code credential.
1366
1410
  */
1367
- export declare interface VisualStudioCodeCredentialOptions extends TokenCredentialOptions {
1411
+ export declare interface VisualStudioCodeCredentialOptions extends MultiTenantTokenCredentialOptions {
1368
1412
  /**
1369
1413
  * Optionally pass in a Tenant ID to be used as part of the credential
1370
1414
  */
@@ -1,11 +0,0 @@
1
- // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT license.
3
- import { formatError } from "../util/logging";
4
- export function checkTenantId(logger, tenantId) {
5
- if (!tenantId.match(/^[0-9a-zA-Z-.:/]+$/)) {
6
- const error = new Error("Invalid tenant id provided. You can locate your tenant id by following the instructions listed here: https://docs.microsoft.com/partner-center/find-ids-and-domain-names.");
7
- logger.info(formatError("", error));
8
- throw error;
9
- }
10
- }
11
- //# sourceMappingURL=checkTenantId.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"checkTenantId.js","sourceRoot":"","sources":["../../../src/util/checkTenantId.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAoB,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEhE,MAAM,UAAU,aAAa,CAAC,MAAwB,EAAE,QAAgB;IACtE,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,oBAAoB,CAAC,EAAE;QACzC,MAAM,KAAK,GAAG,IAAI,KAAK,CACrB,2KAA2K,CAC5K,CAAC;QACF,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC;QACpC,MAAM,KAAK,CAAC;KACb;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { CredentialLogger, formatError } from \"../util/logging\";\n\nexport function checkTenantId(logger: CredentialLogger, tenantId: string): void {\n if (!tenantId.match(/^[0-9a-zA-Z-.:/]+$/)) {\n const error = new Error(\n \"Invalid tenant id provided. You can locate your tenant id by following the instructions listed here: https://docs.microsoft.com/partner-center/find-ids-and-domain-names.\"\n );\n logger.info(formatError(\"\", error));\n throw error;\n }\n}\n"]}
@@ -1,18 +0,0 @@
1
- // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT license.
3
- import { DeveloperSignOnClientId } from "../constants";
4
- import { checkTenantId } from "./checkTenantId";
5
- export function resolveTenantId(logger, tenantId, clientId) {
6
- if (tenantId) {
7
- checkTenantId(logger, tenantId);
8
- return tenantId;
9
- }
10
- if (!clientId) {
11
- clientId = DeveloperSignOnClientId;
12
- }
13
- if (clientId !== DeveloperSignOnClientId) {
14
- return "common";
15
- }
16
- return "organizations";
17
- }
18
- //# sourceMappingURL=resolveTenantId.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"resolveTenantId.js","sourceRoot":"","sources":["../../../src/util/resolveTenantId.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD,MAAM,UAAU,eAAe,CAC7B,MAAwB,EACxB,QAAiB,EACjB,QAAiB;IAEjB,IAAI,QAAQ,EAAE;QACZ,aAAa,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QAChC,OAAO,QAAQ,CAAC;KACjB;IACD,IAAI,CAAC,QAAQ,EAAE;QACb,QAAQ,GAAG,uBAAuB,CAAC;KACpC;IACD,IAAI,QAAQ,KAAK,uBAAuB,EAAE;QACxC,OAAO,QAAQ,CAAC;KACjB;IACD,OAAO,eAAe,CAAC;AACzB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { DeveloperSignOnClientId } from \"../constants\";\nimport { checkTenantId } from \"./checkTenantId\";\nimport { CredentialLogger } from \"./logging\";\n\nexport function resolveTenantId(\n logger: CredentialLogger,\n tenantId?: string,\n clientId?: string\n): string {\n if (tenantId) {\n checkTenantId(logger, tenantId);\n return tenantId;\n }\n if (!clientId) {\n clientId = DeveloperSignOnClientId;\n }\n if (clientId !== DeveloperSignOnClientId) {\n return \"common\";\n }\n return \"organizations\";\n}\n"]}
@@ -1,22 +0,0 @@
1
- // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT license.
3
- /**
4
- * @internal
5
- */
6
- export const multiTenantADFSErrorMessage = "A new tenant Id can't be assigned through the GetTokenOptions when a credential has been originally configured to use the tenant `adfs`.";
7
- /**
8
- * Of getToken contains a tenantId, this functions allows picking this tenantId as the appropriate for authentication,
9
- * unless multitenant authentication has been disabled through the AZURE_IDENTITY_DISABLE_MULTITENANTAUTH (on Node.js),
10
- * or unless the original tenant Id is `adfs`.
11
- * @internal
12
- */
13
- export function processMultiTenantRequest(tenantId, getTokenOptions) {
14
- if (!(getTokenOptions === null || getTokenOptions === void 0 ? void 0 : getTokenOptions.tenantId)) {
15
- return tenantId;
16
- }
17
- if (tenantId === "adfs") {
18
- throw new Error(multiTenantADFSErrorMessage);
19
- }
20
- return getTokenOptions === null || getTokenOptions === void 0 ? void 0 : getTokenOptions.tenantId;
21
- }
22
- //# sourceMappingURL=validateMultiTenant.browser.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"validateMultiTenant.browser.js","sourceRoot":"","sources":["../../../src/util/validateMultiTenant.browser.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC;;GAEG;AACH,MAAM,CAAC,MAAM,2BAA2B,GACtC,0IAA0I,CAAC;AAE7I;;;;;GAKG;AACH,MAAM,UAAU,yBAAyB,CACvC,QAAiB,EACjB,eAAiC;IAEjC,IAAI,CAAC,CAAA,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,QAAQ,CAAA,EAAE;QAC9B,OAAO,QAAQ,CAAC;KACjB;IACD,IAAI,QAAQ,KAAK,MAAM,EAAE;QACvB,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;KAC9C;IACD,OAAO,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,QAAQ,CAAC;AACnC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { GetTokenOptions } from \"@azure/core-auth\";\n\n/**\n * @internal\n */\nexport const multiTenantADFSErrorMessage =\n \"A new tenant Id can't be assigned through the GetTokenOptions when a credential has been originally configured to use the tenant `adfs`.\";\n\n/**\n * Of getToken contains a tenantId, this functions allows picking this tenantId as the appropriate for authentication,\n * unless multitenant authentication has been disabled through the AZURE_IDENTITY_DISABLE_MULTITENANTAUTH (on Node.js),\n * or unless the original tenant Id is `adfs`.\n * @internal\n */\nexport function processMultiTenantRequest(\n tenantId?: string,\n getTokenOptions?: GetTokenOptions\n): string | undefined {\n if (!getTokenOptions?.tenantId) {\n return tenantId;\n }\n if (tenantId === \"adfs\") {\n throw new Error(multiTenantADFSErrorMessage);\n }\n return getTokenOptions?.tenantId;\n}\n"]}
@@ -1,29 +0,0 @@
1
- // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT license.
3
- /**
4
- * @internal
5
- */
6
- export const multiTenantDisabledErrorMessage = "A getToken request was attempted with a tenant different than the tenant configured at the initialization of the credential, but multi-tenant authentication has been disabled by the environment variable AZURE_IDENTITY_DISABLE_MULTITENANTAUTH.";
7
- /**
8
- * @internal
9
- */
10
- export const multiTenantADFSErrorMessage = "A new tenant Id can't be assigned through the GetTokenOptions when a credential has been originally configured to use the tenant `adfs`.";
11
- /**
12
- * Of getToken contains a tenantId, this functions allows picking this tenantId as the appropriate for authentication,
13
- * unless multitenant authentication has been disabled through the AZURE_IDENTITY_DISABLE_MULTITENANTAUTH (on Node.js),
14
- * or unless the original tenant Id is `adfs`.
15
- * @internal
16
- */
17
- export function processMultiTenantRequest(tenantId, getTokenOptions) {
18
- if (!(getTokenOptions === null || getTokenOptions === void 0 ? void 0 : getTokenOptions.tenantId)) {
19
- return tenantId;
20
- }
21
- if (process.env.AZURE_IDENTITY_DISABLE_MULTITENANTAUTH) {
22
- throw new Error(multiTenantDisabledErrorMessage);
23
- }
24
- if (tenantId === "adfs") {
25
- throw new Error(multiTenantADFSErrorMessage);
26
- }
27
- return getTokenOptions === null || getTokenOptions === void 0 ? void 0 : getTokenOptions.tenantId;
28
- }
29
- //# sourceMappingURL=validateMultiTenant.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"validateMultiTenant.js","sourceRoot":"","sources":["../../../src/util/validateMultiTenant.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC;;GAEG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAC1C,oPAAoP,CAAC;AAEvP;;GAEG;AACH,MAAM,CAAC,MAAM,2BAA2B,GACtC,0IAA0I,CAAC;AAE7I;;;;;GAKG;AACH,MAAM,UAAU,yBAAyB,CACvC,QAAiB,EACjB,eAAiC;IAEjC,IAAI,CAAC,CAAA,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,QAAQ,CAAA,EAAE;QAC9B,OAAO,QAAQ,CAAC;KACjB;IACD,IAAI,OAAO,CAAC,GAAG,CAAC,sCAAsC,EAAE;QACtD,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;KAClD;IACD,IAAI,QAAQ,KAAK,MAAM,EAAE;QACvB,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;KAC9C;IACD,OAAO,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,QAAQ,CAAC;AACnC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { GetTokenOptions } from \"@azure/core-auth\";\n\n/**\n * @internal\n */\nexport const multiTenantDisabledErrorMessage =\n \"A getToken request was attempted with a tenant different than the tenant configured at the initialization of the credential, but multi-tenant authentication has been disabled by the environment variable AZURE_IDENTITY_DISABLE_MULTITENANTAUTH.\";\n\n/**\n * @internal\n */\nexport const multiTenantADFSErrorMessage =\n \"A new tenant Id can't be assigned through the GetTokenOptions when a credential has been originally configured to use the tenant `adfs`.\";\n\n/**\n * Of getToken contains a tenantId, this functions allows picking this tenantId as the appropriate for authentication,\n * unless multitenant authentication has been disabled through the AZURE_IDENTITY_DISABLE_MULTITENANTAUTH (on Node.js),\n * or unless the original tenant Id is `adfs`.\n * @internal\n */\nexport function processMultiTenantRequest(\n tenantId?: string,\n getTokenOptions?: GetTokenOptions\n): string | undefined {\n if (!getTokenOptions?.tenantId) {\n return tenantId;\n }\n if (process.env.AZURE_IDENTITY_DISABLE_MULTITENANTAUTH) {\n throw new Error(multiTenantDisabledErrorMessage);\n }\n if (tenantId === \"adfs\") {\n throw new Error(multiTenantADFSErrorMessage);\n }\n return getTokenOptions?.tenantId;\n}\n"]}