@azure/identity 2.0.0-beta.2 → 2.0.0-beta.6

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 (157) hide show
  1. package/CHANGELOG.md +127 -8
  2. package/README.md +88 -45
  3. package/dist/index.js +2237 -1675
  4. package/dist/index.js.map +1 -1
  5. package/dist-esm/src/client/errors.js +1 -1
  6. package/dist-esm/src/client/errors.js.map +1 -1
  7. package/dist-esm/src/client/identityClient.js +146 -132
  8. package/dist-esm/src/client/identityClient.js.map +1 -1
  9. package/dist-esm/src/constants.js +1 -1
  10. package/dist-esm/src/constants.js.map +1 -1
  11. package/dist-esm/src/credentials/applicationCredential.browser.js +29 -0
  12. package/dist-esm/src/credentials/applicationCredential.browser.js.map +1 -0
  13. package/dist-esm/src/credentials/applicationCredential.js +34 -0
  14. package/dist-esm/src/credentials/applicationCredential.js.map +1 -0
  15. package/dist-esm/src/credentials/authorizationCodeCredential.browser.js.map +1 -1
  16. package/dist-esm/src/credentials/authorizationCodeCredential.js +13 -76
  17. package/dist-esm/src/credentials/authorizationCodeCredential.js.map +1 -1
  18. package/dist-esm/src/credentials/azureCliCredential.browser.js.map +1 -1
  19. package/dist-esm/src/credentials/azureCliCredential.js +104 -81
  20. package/dist-esm/src/credentials/azureCliCredential.js.map +1 -1
  21. package/dist-esm/src/credentials/azureCliCredentialOptions.js +4 -0
  22. package/dist-esm/src/credentials/azureCliCredentialOptions.js.map +1 -0
  23. package/dist-esm/src/credentials/azurePowerShellCredential.browser.js +20 -0
  24. package/dist-esm/src/credentials/azurePowerShellCredential.browser.js.map +1 -0
  25. package/dist-esm/src/credentials/azurePowerShellCredential.js +173 -0
  26. package/dist-esm/src/credentials/azurePowerShellCredential.js.map +1 -0
  27. package/dist-esm/src/credentials/azurePowerShellCredentialOptions.js +4 -0
  28. package/dist-esm/src/credentials/azurePowerShellCredentialOptions.js.map +1 -0
  29. package/dist-esm/src/credentials/chainedTokenCredential.js +37 -34
  30. package/dist-esm/src/credentials/chainedTokenCredential.js.map +1 -1
  31. package/dist-esm/src/credentials/clientCertificateCredential.browser.js.map +1 -1
  32. package/dist-esm/src/credentials/clientCertificateCredential.js +9 -11
  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 +87 -0
  36. package/dist-esm/src/credentials/clientSecretCredential.browser.js.map +1 -0
  37. package/dist-esm/src/credentials/clientSecretCredential.js +9 -11
  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/credentialPersistenceOptions.js +4 -0
  41. package/dist-esm/src/credentials/credentialPersistenceOptions.js.map +1 -0
  42. package/dist-esm/src/credentials/defaultAzureCredential.browser.js +1 -1
  43. package/dist-esm/src/credentials/defaultAzureCredential.browser.js.map +1 -1
  44. package/dist-esm/src/credentials/defaultAzureCredential.js +38 -19
  45. package/dist-esm/src/credentials/defaultAzureCredential.js.map +1 -1
  46. package/dist-esm/src/credentials/deviceCodeCredential.browser.js.map +1 -1
  47. package/dist-esm/src/credentials/deviceCodeCredential.js +13 -22
  48. package/dist-esm/src/credentials/deviceCodeCredential.js.map +1 -1
  49. package/dist-esm/src/credentials/deviceCodeCredentialOptions.js.map +1 -1
  50. package/dist-esm/src/credentials/environmentCredential.browser.js.map +1 -1
  51. package/dist-esm/src/credentials/environmentCredential.js +47 -30
  52. package/dist-esm/src/credentials/environmentCredential.js.map +1 -1
  53. package/dist-esm/src/credentials/interactiveBrowserCredential.browser.js +14 -23
  54. package/dist-esm/src/credentials/interactiveBrowserCredential.browser.js.map +1 -1
  55. package/dist-esm/src/credentials/interactiveBrowserCredential.js +20 -26
  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 +36 -18
  60. package/dist-esm/src/credentials/managedIdentityCredential/appServiceMsi2017.js.map +1 -1
  61. package/dist-esm/src/credentials/managedIdentityCredential/arcMsi.js +61 -42
  62. package/dist-esm/src/credentials/managedIdentityCredential/arcMsi.js.map +1 -1
  63. package/dist-esm/src/credentials/managedIdentityCredential/cloudShellMsi.js +33 -18
  64. package/dist-esm/src/credentials/managedIdentityCredential/cloudShellMsi.js.map +1 -1
  65. package/dist-esm/src/credentials/managedIdentityCredential/constants.js +2 -1
  66. package/dist-esm/src/credentials/managedIdentityCredential/constants.js.map +1 -1
  67. package/dist-esm/src/credentials/managedIdentityCredential/fabricMsi.js +42 -23
  68. package/dist-esm/src/credentials/managedIdentityCredential/fabricMsi.js.map +1 -1
  69. package/dist-esm/src/credentials/managedIdentityCredential/imdsMsi.js +108 -73
  70. package/dist-esm/src/credentials/managedIdentityCredential/imdsMsi.js.map +1 -1
  71. package/dist-esm/src/credentials/managedIdentityCredential/index.browser.js +3 -6
  72. package/dist-esm/src/credentials/managedIdentityCredential/index.browser.js.map +1 -1
  73. package/dist-esm/src/credentials/managedIdentityCredential/index.js +119 -124
  74. package/dist-esm/src/credentials/managedIdentityCredential/index.js.map +1 -1
  75. package/dist-esm/src/credentials/managedIdentityCredential/models.js.map +1 -1
  76. package/dist-esm/src/credentials/managedIdentityCredential/tokenExchangeMsi.js +82 -0
  77. package/dist-esm/src/credentials/managedIdentityCredential/tokenExchangeMsi.js.map +1 -0
  78. package/dist-esm/src/credentials/managedIdentityCredential/utils.js +14 -8
  79. package/dist-esm/src/credentials/managedIdentityCredential/utils.js.map +1 -1
  80. package/dist-esm/src/credentials/onBehalfOfCredential.browser.js +17 -0
  81. package/dist-esm/src/credentials/onBehalfOfCredential.browser.js.map +1 -0
  82. package/dist-esm/src/credentials/onBehalfOfCredential.js +62 -0
  83. package/dist-esm/src/credentials/onBehalfOfCredential.js.map +1 -0
  84. package/dist-esm/src/credentials/onBehalfOfCredentialOptions.js +4 -0
  85. package/dist-esm/src/credentials/onBehalfOfCredentialOptions.js.map +1 -0
  86. package/dist-esm/src/credentials/usernamePasswordCredential.browser.js +87 -0
  87. package/dist-esm/src/credentials/usernamePasswordCredential.browser.js.map +1 -0
  88. package/dist-esm/src/credentials/usernamePasswordCredential.js +9 -33
  89. package/dist-esm/src/credentials/usernamePasswordCredential.js.map +1 -1
  90. package/dist-esm/src/credentials/usernamePasswordCredentialOptions.js.map +1 -1
  91. package/dist-esm/src/credentials/visualStudioCodeCredential.browser.js +5 -0
  92. package/dist-esm/src/credentials/visualStudioCodeCredential.browser.js.map +1 -1
  93. package/dist-esm/src/credentials/visualStudioCodeCredential.js +70 -68
  94. package/dist-esm/src/credentials/visualStudioCodeCredential.js.map +1 -1
  95. package/dist-esm/src/credentials/visualStudioCodeCredentialPlugin.js +4 -0
  96. package/dist-esm/src/credentials/visualStudioCodeCredentialPlugin.js.map +1 -0
  97. package/dist-esm/src/index.js +6 -1
  98. package/dist-esm/src/index.js.map +1 -1
  99. package/dist-esm/src/msal/browserFlows/browserCommon.js +30 -29
  100. package/dist-esm/src/msal/browserFlows/browserCommon.js.map +1 -1
  101. package/dist-esm/src/msal/browserFlows/msalAuthCode.js +103 -113
  102. package/dist-esm/src/msal/browserFlows/msalAuthCode.js.map +1 -1
  103. package/dist-esm/src/msal/credentials.js.map +1 -1
  104. package/dist-esm/src/msal/errors.js +1 -2
  105. package/dist-esm/src/msal/errors.js.map +1 -1
  106. package/dist-esm/src/msal/flows.js.map +1 -1
  107. package/dist-esm/src/msal/nodeFlows/msalAuthorizationCode.js +41 -0
  108. package/dist-esm/src/msal/nodeFlows/msalAuthorizationCode.js.map +1 -0
  109. package/dist-esm/src/msal/nodeFlows/msalClientCertificate.js +64 -46
  110. package/dist-esm/src/msal/nodeFlows/msalClientCertificate.js.map +1 -1
  111. package/dist-esm/src/msal/nodeFlows/msalClientSecret.js +15 -16
  112. package/dist-esm/src/msal/nodeFlows/msalClientSecret.js.map +1 -1
  113. package/dist-esm/src/msal/nodeFlows/msalDeviceCode.js +20 -22
  114. package/dist-esm/src/msal/nodeFlows/msalDeviceCode.js.map +1 -1
  115. package/dist-esm/src/msal/nodeFlows/msalOnBehalfOf.js +56 -0
  116. package/dist-esm/src/msal/nodeFlows/msalOnBehalfOf.js.map +1 -0
  117. package/dist-esm/src/msal/nodeFlows/msalOpenBrowser.js +43 -32
  118. package/dist-esm/src/msal/nodeFlows/msalOpenBrowser.js.map +1 -1
  119. package/dist-esm/src/msal/nodeFlows/msalUsernamePassword.js +15 -17
  120. package/dist-esm/src/msal/nodeFlows/msalUsernamePassword.js.map +1 -1
  121. package/dist-esm/src/msal/nodeFlows/nodeCommon.js +133 -110
  122. package/dist-esm/src/msal/nodeFlows/nodeCommon.js.map +1 -1
  123. package/dist-esm/src/msal/nodeFlows/tokenCachePersistenceOptions.js +4 -0
  124. package/dist-esm/src/msal/nodeFlows/tokenCachePersistenceOptions.js.map +1 -0
  125. package/dist-esm/src/msal/utils.js +31 -22
  126. package/dist-esm/src/msal/utils.js.map +1 -1
  127. package/dist-esm/src/plugins/consumer.browser.js +7 -0
  128. package/dist-esm/src/plugins/consumer.browser.js.map +1 -0
  129. package/dist-esm/src/plugins/consumer.js +44 -0
  130. package/dist-esm/src/plugins/consumer.js.map +1 -0
  131. package/dist-esm/src/{tokenCache/types.js → plugins/provider.js} +1 -1
  132. package/dist-esm/src/plugins/provider.js.map +1 -0
  133. package/dist-esm/src/regionalAuthority.js +115 -0
  134. package/dist-esm/src/regionalAuthority.js.map +1 -0
  135. package/dist-esm/src/util/logging.js +1 -1
  136. package/dist-esm/src/util/logging.js.map +1 -1
  137. package/dist-esm/src/util/processUtils.js +32 -0
  138. package/dist-esm/src/util/processUtils.js.map +1 -0
  139. package/dist-esm/src/util/scopeUtils.js +22 -0
  140. package/dist-esm/src/util/scopeUtils.js.map +1 -0
  141. package/dist-esm/src/util/tracing.js +23 -26
  142. package/dist-esm/src/util/tracing.js.map +1 -1
  143. package/dist-esm/src/util/validateMultiTenant.js +24 -0
  144. package/dist-esm/src/util/validateMultiTenant.js.map +1 -0
  145. package/package.json +43 -41
  146. package/types/identity.d.ts +500 -131
  147. package/dist-esm/src/tokenCache/TokenCachePersistence.browser.js +0 -23
  148. package/dist-esm/src/tokenCache/TokenCachePersistence.browser.js.map +0 -1
  149. package/dist-esm/src/tokenCache/TokenCachePersistence.js +0 -51
  150. package/dist-esm/src/tokenCache/TokenCachePersistence.js.map +0 -1
  151. package/dist-esm/src/tokenCache/nodeVersion.js +0 -10
  152. package/dist-esm/src/tokenCache/nodeVersion.js.map +0 -1
  153. package/dist-esm/src/tokenCache/persistencePlatforms.js +0 -150
  154. package/dist-esm/src/tokenCache/persistencePlatforms.js.map +0 -1
  155. package/dist-esm/src/tokenCache/types.js.map +0 -1
  156. package/dist-esm/src/util/authHostEnv.js +0 -13
  157. package/dist-esm/src/util/authHostEnv.js.map +0 -1
@@ -0,0 +1,44 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+ import { msalNodeFlowCacheControl } from "../msal/nodeFlows/nodeCommon";
4
+ import { vsCodeCredentialControl } from "../credentials/visualStudioCodeCredential";
5
+ /**
6
+ * The context passed to an Identity plugin. This contains objects that
7
+ * plugins can use to set backend implementations.
8
+ * @internal
9
+ */
10
+ const pluginContext = {
11
+ cachePluginControl: msalNodeFlowCacheControl,
12
+ vsCodeCredentialControl: vsCodeCredentialControl
13
+ };
14
+ /**
15
+ * Extend Azure Identity with additional functionality. Pass a plugin from
16
+ * a plugin package, such as:
17
+ *
18
+ * - `@azure/identity-cache-persistence`: provides persistent token caching
19
+ * - `@azure/identity-vscode`: provides the dependencies of
20
+ * `VisualStudioCodeCredential` and enables it
21
+ *
22
+ * Example:
23
+ *
24
+ * ```javascript
25
+ * import { cachePersistencePlugin } from "@azure/identity-cache-persistence";
26
+ *
27
+ * import { useIdentityPlugin, DefaultAzureCredential } from "@azure/identity";
28
+ * useIdentityPlugin(cachePersistencePlugin);
29
+ *
30
+ * // The plugin has the capability to extend `DefaultAzureCredential` and to
31
+ * // add middleware to the underlying credentials, such as persistence.
32
+ * const credential = new DefaultAzureCredential({
33
+ * tokenCachePersistenceOptions: {
34
+ * enabled: true
35
+ * }
36
+ * });
37
+ * ```
38
+ *
39
+ * @param plugin - the plugin to register
40
+ */
41
+ export function useIdentityPlugin(plugin) {
42
+ plugin(pluginContext);
43
+ }
44
+ //# sourceMappingURL=consumer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consumer.js","sourceRoot":"","sources":["../../../src/plugins/consumer.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EAAE,uBAAuB,EAAE,MAAM,2CAA2C,CAAC;AAEpF;;;;GAIG;AACH,MAAM,aAAa,GAAuB;IACxC,kBAAkB,EAAE,wBAAwB;IAC5C,uBAAuB,EAAE,uBAAuB;CACjD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAsB;IACtD,MAAM,CAAC,aAAa,CAAC,CAAC;AACxB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { AzurePluginContext, IdentityPlugin } from \"./provider\";\nimport { msalNodeFlowCacheControl } from \"../msal/nodeFlows/nodeCommon\";\nimport { vsCodeCredentialControl } from \"../credentials/visualStudioCodeCredential\";\n\n/**\n * The context passed to an Identity plugin. This contains objects that\n * plugins can use to set backend implementations.\n * @internal\n */\nconst pluginContext: AzurePluginContext = {\n cachePluginControl: msalNodeFlowCacheControl,\n vsCodeCredentialControl: vsCodeCredentialControl\n};\n\n/**\n * Extend Azure Identity with additional functionality. Pass a plugin from\n * a plugin package, such as:\n *\n * - `@azure/identity-cache-persistence`: provides persistent token caching\n * - `@azure/identity-vscode`: provides the dependencies of\n * `VisualStudioCodeCredential` and enables it\n *\n * Example:\n *\n * ```javascript\n * import { cachePersistencePlugin } from \"@azure/identity-cache-persistence\";\n *\n * import { useIdentityPlugin, DefaultAzureCredential } from \"@azure/identity\";\n * useIdentityPlugin(cachePersistencePlugin);\n *\n * // The plugin has the capability to extend `DefaultAzureCredential` and to\n * // add middleware to the underlying credentials, such as persistence.\n * const credential = new DefaultAzureCredential({\n * tokenCachePersistenceOptions: {\n * enabled: true\n * }\n * });\n * ```\n *\n * @param plugin - the plugin to register\n */\nexport function useIdentityPlugin(plugin: IdentityPlugin): void {\n plugin(pluginContext);\n}\n"]}
@@ -1,4 +1,4 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
2
  // Licensed under the MIT license.
3
3
  export {};
4
- //# sourceMappingURL=types.js.map
4
+ //# sourceMappingURL=provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.js","sourceRoot":"","sources":["../../../src/plugins/provider.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { VSCodeCredentialFinder } from \"../credentials/visualStudioCodeCredentialPlugin\";\nimport { TokenCachePersistenceOptions } from \"../msal/nodeFlows/tokenCachePersistenceOptions\";\n\n/**\n * The type of an Azure Identity plugin, a function accepting a plugin\n * context.\n */\nexport type IdentityPlugin = (context: unknown) => void;\n\n/**\n * Plugin context entries for controlling cache plugins.\n */\nexport interface CachePluginControl {\n setPersistence(\n persistenceFactory: (\n options?: TokenCachePersistenceOptions\n ) => Promise<import(\"@azure/msal-common\").ICachePlugin>\n ): void;\n}\n\n/**\n * Plugin context entries for controlling VisualStudioCodeCredential.\n */\nexport interface VisualStudioCodeCredentialControl {\n setVsCodeCredentialFinder(finder: VSCodeCredentialFinder): void;\n}\n\n/**\n * Context options passed to a plugin during initialization.\n *\n * Plugin authors are responsible for casting their plugin context values\n * to this type.\n *\n * @internal\n */\nexport interface AzurePluginContext {\n cachePluginControl: CachePluginControl;\n vsCodeCredentialControl: VisualStudioCodeCredentialControl;\n}\n"]}
@@ -0,0 +1,115 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+ /**
4
+ * Helps specify a regional authority, or "AutoDiscoverRegion" to auto-detect the region.
5
+ */
6
+ export var RegionalAuthority;
7
+ (function (RegionalAuthority) {
8
+ /** Instructs MSAL to attempt to discover the region */
9
+ RegionalAuthority["AutoDiscoverRegion"] = "AutoDiscoverRegion";
10
+ /** Uses the {@link RegionalAuthority} for the Azure 'westus' region. */
11
+ RegionalAuthority["USWest"] = "westus";
12
+ /** Uses the {@link RegionalAuthority} for the Azure 'westus2' region. */
13
+ RegionalAuthority["USWest2"] = "westus2";
14
+ /** Uses the {@link RegionalAuthority} for the Azure 'centralus' region. */
15
+ RegionalAuthority["USCentral"] = "centralus";
16
+ /** Uses the {@link RegionalAuthority} for the Azure 'eastus' region. */
17
+ RegionalAuthority["USEast"] = "eastus";
18
+ /** Uses the {@link RegionalAuthority} for the Azure 'eastus2' region. */
19
+ RegionalAuthority["USEast2"] = "eastus2";
20
+ /** Uses the {@link RegionalAuthority} for the Azure 'northcentralus' region. */
21
+ RegionalAuthority["USNorthCentral"] = "northcentralus";
22
+ /** Uses the {@link RegionalAuthority} for the Azure 'southcentralus' region. */
23
+ RegionalAuthority["USSouthCentral"] = "southcentralus";
24
+ /** Uses the {@link RegionalAuthority} for the Azure 'westcentralus' region. */
25
+ RegionalAuthority["USWestCentral"] = "westcentralus";
26
+ /** Uses the {@link RegionalAuthority} for the Azure 'canadacentral' region. */
27
+ RegionalAuthority["CanadaCentral"] = "canadacentral";
28
+ /** Uses the {@link RegionalAuthority} for the Azure 'canadaeast' region. */
29
+ RegionalAuthority["CanadaEast"] = "canadaeast";
30
+ /** Uses the {@link RegionalAuthority} for the Azure 'brazilsouth' region. */
31
+ RegionalAuthority["BrazilSouth"] = "brazilsouth";
32
+ /** Uses the {@link RegionalAuthority} for the Azure 'northeurope' region. */
33
+ RegionalAuthority["EuropeNorth"] = "northeurope";
34
+ /** Uses the {@link RegionalAuthority} for the Azure 'westeurope' region. */
35
+ RegionalAuthority["EuropeWest"] = "westeurope";
36
+ /** Uses the {@link RegionalAuthority} for the Azure 'uksouth' region. */
37
+ RegionalAuthority["UKSouth"] = "uksouth";
38
+ /** Uses the {@link RegionalAuthority} for the Azure 'ukwest' region. */
39
+ RegionalAuthority["UKWest"] = "ukwest";
40
+ /** Uses the {@link RegionalAuthority} for the Azure 'francecentral' region. */
41
+ RegionalAuthority["FranceCentral"] = "francecentral";
42
+ /** Uses the {@link RegionalAuthority} for the Azure 'francesouth' region. */
43
+ RegionalAuthority["FranceSouth"] = "francesouth";
44
+ /** Uses the {@link RegionalAuthority} for the Azure 'switzerlandnorth' region. */
45
+ RegionalAuthority["SwitzerlandNorth"] = "switzerlandnorth";
46
+ /** Uses the {@link RegionalAuthority} for the Azure 'switzerlandwest' region. */
47
+ RegionalAuthority["SwitzerlandWest"] = "switzerlandwest";
48
+ /** Uses the {@link RegionalAuthority} for the Azure 'germanynorth' region. */
49
+ RegionalAuthority["GermanyNorth"] = "germanynorth";
50
+ /** Uses the {@link RegionalAuthority} for the Azure 'germanywestcentral' region. */
51
+ RegionalAuthority["GermanyWestCentral"] = "germanywestcentral";
52
+ /** Uses the {@link RegionalAuthority} for the Azure 'norwaywest' region. */
53
+ RegionalAuthority["NorwayWest"] = "norwaywest";
54
+ /** Uses the {@link RegionalAuthority} for the Azure 'norwayeast' region. */
55
+ RegionalAuthority["NorwayEast"] = "norwayeast";
56
+ /** Uses the {@link RegionalAuthority} for the Azure 'eastasia' region. */
57
+ RegionalAuthority["AsiaEast"] = "eastasia";
58
+ /** Uses the {@link RegionalAuthority} for the Azure 'southeastasia' region. */
59
+ RegionalAuthority["AsiaSouthEast"] = "southeastasia";
60
+ /** Uses the {@link RegionalAuthority} for the Azure 'japaneast' region. */
61
+ RegionalAuthority["JapanEast"] = "japaneast";
62
+ /** Uses the {@link RegionalAuthority} for the Azure 'japanwest' region. */
63
+ RegionalAuthority["JapanWest"] = "japanwest";
64
+ /** Uses the {@link RegionalAuthority} for the Azure 'australiaeast' region. */
65
+ RegionalAuthority["AustraliaEast"] = "australiaeast";
66
+ /** Uses the {@link RegionalAuthority} for the Azure 'australiasoutheast' region. */
67
+ RegionalAuthority["AustraliaSouthEast"] = "australiasoutheast";
68
+ /** Uses the {@link RegionalAuthority} for the Azure 'australiacentral' region. */
69
+ RegionalAuthority["AustraliaCentral"] = "australiacentral";
70
+ /** Uses the {@link RegionalAuthority} for the Azure 'australiacentral2' region. */
71
+ RegionalAuthority["AustraliaCentral2"] = "australiacentral2";
72
+ /** Uses the {@link RegionalAuthority} for the Azure 'centralindia' region. */
73
+ RegionalAuthority["IndiaCentral"] = "centralindia";
74
+ /** Uses the {@link RegionalAuthority} for the Azure 'southindia' region. */
75
+ RegionalAuthority["IndiaSouth"] = "southindia";
76
+ /** Uses the {@link RegionalAuthority} for the Azure 'westindia' region. */
77
+ RegionalAuthority["IndiaWest"] = "westindia";
78
+ /** Uses the {@link RegionalAuthority} for the Azure 'koreasouth' region. */
79
+ RegionalAuthority["KoreaSouth"] = "koreasouth";
80
+ /** Uses the {@link RegionalAuthority} for the Azure 'koreacentral' region. */
81
+ RegionalAuthority["KoreaCentral"] = "koreacentral";
82
+ /** Uses the {@link RegionalAuthority} for the Azure 'uaecentral' region. */
83
+ RegionalAuthority["UAECentral"] = "uaecentral";
84
+ /** Uses the {@link RegionalAuthority} for the Azure 'uaenorth' region. */
85
+ RegionalAuthority["UAENorth"] = "uaenorth";
86
+ /** Uses the {@link RegionalAuthority} for the Azure 'southafricanorth' region. */
87
+ RegionalAuthority["SouthAfricaNorth"] = "southafricanorth";
88
+ /** Uses the {@link RegionalAuthority} for the Azure 'southafricawest' region. */
89
+ RegionalAuthority["SouthAfricaWest"] = "southafricawest";
90
+ /** Uses the {@link RegionalAuthority} for the Azure 'chinanorth' region. */
91
+ RegionalAuthority["ChinaNorth"] = "chinanorth";
92
+ /** Uses the {@link RegionalAuthority} for the Azure 'chinaeast' region. */
93
+ RegionalAuthority["ChinaEast"] = "chinaeast";
94
+ /** Uses the {@link RegionalAuthority} for the Azure 'chinanorth2' region. */
95
+ RegionalAuthority["ChinaNorth2"] = "chinanorth2";
96
+ /** Uses the {@link RegionalAuthority} for the Azure 'chinaeast2' region. */
97
+ RegionalAuthority["ChinaEast2"] = "chinaeast2";
98
+ /** Uses the {@link RegionalAuthority} for the Azure 'germanycentral' region. */
99
+ RegionalAuthority["GermanyCentral"] = "germanycentral";
100
+ /** Uses the {@link RegionalAuthority} for the Azure 'germanynortheast' region. */
101
+ RegionalAuthority["GermanyNorthEast"] = "germanynortheast";
102
+ /** Uses the {@link RegionalAuthority} for the Azure 'usgovvirginia' region. */
103
+ RegionalAuthority["GovernmentUSVirginia"] = "usgovvirginia";
104
+ /** Uses the {@link RegionalAuthority} for the Azure 'usgoviowa' region. */
105
+ RegionalAuthority["GovernmentUSIowa"] = "usgoviowa";
106
+ /** Uses the {@link RegionalAuthority} for the Azure 'usgovarizona' region. */
107
+ RegionalAuthority["GovernmentUSArizona"] = "usgovarizona";
108
+ /** Uses the {@link RegionalAuthority} for the Azure 'usgovtexas' region. */
109
+ RegionalAuthority["GovernmentUSTexas"] = "usgovtexas";
110
+ /** Uses the {@link RegionalAuthority} for the Azure 'usdodeast' region. */
111
+ RegionalAuthority["GovernmentUSDodEast"] = "usdodeast";
112
+ /** Uses the {@link RegionalAuthority} for the Azure 'usdodcentral' region. */
113
+ RegionalAuthority["GovernmentUSDodCentral"] = "usdodcentral";
114
+ })(RegionalAuthority || (RegionalAuthority = {}));
115
+ //# sourceMappingURL=regionalAuthority.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"regionalAuthority.js","sourceRoot":"","sources":["../../src/regionalAuthority.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;GAEG;AACH,MAAM,CAAN,IAAY,iBA2GX;AA3GD,WAAY,iBAAiB;IAC3B,uDAAuD;IACvD,8DAAyC,CAAA;IACzC,wEAAwE;IACxE,sCAAiB,CAAA;IACjB,yEAAyE;IACzE,wCAAmB,CAAA;IACnB,2EAA2E;IAC3E,4CAAuB,CAAA;IACvB,wEAAwE;IACxE,sCAAiB,CAAA;IACjB,yEAAyE;IACzE,wCAAmB,CAAA;IACnB,gFAAgF;IAChF,sDAAiC,CAAA;IACjC,gFAAgF;IAChF,sDAAiC,CAAA;IACjC,+EAA+E;IAC/E,oDAA+B,CAAA;IAC/B,+EAA+E;IAC/E,oDAA+B,CAAA;IAC/B,4EAA4E;IAC5E,8CAAyB,CAAA;IACzB,6EAA6E;IAC7E,gDAA2B,CAAA;IAC3B,6EAA6E;IAC7E,gDAA2B,CAAA;IAC3B,4EAA4E;IAC5E,8CAAyB,CAAA;IACzB,yEAAyE;IACzE,wCAAmB,CAAA;IACnB,wEAAwE;IACxE,sCAAiB,CAAA;IACjB,+EAA+E;IAC/E,oDAA+B,CAAA;IAC/B,6EAA6E;IAC7E,gDAA2B,CAAA;IAC3B,kFAAkF;IAClF,0DAAqC,CAAA;IACrC,iFAAiF;IACjF,wDAAmC,CAAA;IACnC,8EAA8E;IAC9E,kDAA6B,CAAA;IAC7B,oFAAoF;IACpF,8DAAyC,CAAA;IACzC,4EAA4E;IAC5E,8CAAyB,CAAA;IACzB,4EAA4E;IAC5E,8CAAyB,CAAA;IACzB,0EAA0E;IAC1E,0CAAqB,CAAA;IACrB,+EAA+E;IAC/E,oDAA+B,CAAA;IAC/B,2EAA2E;IAC3E,4CAAuB,CAAA;IACvB,2EAA2E;IAC3E,4CAAuB,CAAA;IACvB,+EAA+E;IAC/E,oDAA+B,CAAA;IAC/B,oFAAoF;IACpF,8DAAyC,CAAA;IACzC,kFAAkF;IAClF,0DAAqC,CAAA;IACrC,mFAAmF;IACnF,4DAAuC,CAAA;IACvC,8EAA8E;IAC9E,kDAA6B,CAAA;IAC7B,4EAA4E;IAC5E,8CAAyB,CAAA;IACzB,2EAA2E;IAC3E,4CAAuB,CAAA;IACvB,4EAA4E;IAC5E,8CAAyB,CAAA;IACzB,8EAA8E;IAC9E,kDAA6B,CAAA;IAC7B,4EAA4E;IAC5E,8CAAyB,CAAA;IACzB,0EAA0E;IAC1E,0CAAqB,CAAA;IACrB,kFAAkF;IAClF,0DAAqC,CAAA;IACrC,iFAAiF;IACjF,wDAAmC,CAAA;IACnC,4EAA4E;IAC5E,8CAAyB,CAAA;IACzB,2EAA2E;IAC3E,4CAAuB,CAAA;IACvB,6EAA6E;IAC7E,gDAA2B,CAAA;IAC3B,4EAA4E;IAC5E,8CAAyB,CAAA;IACzB,gFAAgF;IAChF,sDAAiC,CAAA;IACjC,kFAAkF;IAClF,0DAAqC,CAAA;IACrC,+EAA+E;IAC/E,2DAAsC,CAAA;IACtC,2EAA2E;IAC3E,mDAA8B,CAAA;IAC9B,8EAA8E;IAC9E,yDAAoC,CAAA;IACpC,4EAA4E;IAC5E,qDAAgC,CAAA;IAChC,2EAA2E;IAC3E,sDAAiC,CAAA;IACjC,8EAA8E;IAC9E,4DAAuC,CAAA;AACzC,CAAC,EA3GW,iBAAiB,KAAjB,iBAAiB,QA2G5B","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * Helps specify a regional authority, or \"AutoDiscoverRegion\" to auto-detect the region.\n */\nexport enum RegionalAuthority {\n /** Instructs MSAL to attempt to discover the region */\n AutoDiscoverRegion = \"AutoDiscoverRegion\",\n /** Uses the {@link RegionalAuthority} for the Azure 'westus' region. */\n USWest = \"westus\",\n /** Uses the {@link RegionalAuthority} for the Azure 'westus2' region. */\n USWest2 = \"westus2\",\n /** Uses the {@link RegionalAuthority} for the Azure 'centralus' region. */\n USCentral = \"centralus\",\n /** Uses the {@link RegionalAuthority} for the Azure 'eastus' region. */\n USEast = \"eastus\",\n /** Uses the {@link RegionalAuthority} for the Azure 'eastus2' region. */\n USEast2 = \"eastus2\",\n /** Uses the {@link RegionalAuthority} for the Azure 'northcentralus' region. */\n USNorthCentral = \"northcentralus\",\n /** Uses the {@link RegionalAuthority} for the Azure 'southcentralus' region. */\n USSouthCentral = \"southcentralus\",\n /** Uses the {@link RegionalAuthority} for the Azure 'westcentralus' region. */\n USWestCentral = \"westcentralus\",\n /** Uses the {@link RegionalAuthority} for the Azure 'canadacentral' region. */\n CanadaCentral = \"canadacentral\",\n /** Uses the {@link RegionalAuthority} for the Azure 'canadaeast' region. */\n CanadaEast = \"canadaeast\",\n /** Uses the {@link RegionalAuthority} for the Azure 'brazilsouth' region. */\n BrazilSouth = \"brazilsouth\",\n /** Uses the {@link RegionalAuthority} for the Azure 'northeurope' region. */\n EuropeNorth = \"northeurope\",\n /** Uses the {@link RegionalAuthority} for the Azure 'westeurope' region. */\n EuropeWest = \"westeurope\",\n /** Uses the {@link RegionalAuthority} for the Azure 'uksouth' region. */\n UKSouth = \"uksouth\",\n /** Uses the {@link RegionalAuthority} for the Azure 'ukwest' region. */\n UKWest = \"ukwest\",\n /** Uses the {@link RegionalAuthority} for the Azure 'francecentral' region. */\n FranceCentral = \"francecentral\",\n /** Uses the {@link RegionalAuthority} for the Azure 'francesouth' region. */\n FranceSouth = \"francesouth\",\n /** Uses the {@link RegionalAuthority} for the Azure 'switzerlandnorth' region. */\n SwitzerlandNorth = \"switzerlandnorth\",\n /** Uses the {@link RegionalAuthority} for the Azure 'switzerlandwest' region. */\n SwitzerlandWest = \"switzerlandwest\",\n /** Uses the {@link RegionalAuthority} for the Azure 'germanynorth' region. */\n GermanyNorth = \"germanynorth\",\n /** Uses the {@link RegionalAuthority} for the Azure 'germanywestcentral' region. */\n GermanyWestCentral = \"germanywestcentral\",\n /** Uses the {@link RegionalAuthority} for the Azure 'norwaywest' region. */\n NorwayWest = \"norwaywest\",\n /** Uses the {@link RegionalAuthority} for the Azure 'norwayeast' region. */\n NorwayEast = \"norwayeast\",\n /** Uses the {@link RegionalAuthority} for the Azure 'eastasia' region. */\n AsiaEast = \"eastasia\",\n /** Uses the {@link RegionalAuthority} for the Azure 'southeastasia' region. */\n AsiaSouthEast = \"southeastasia\",\n /** Uses the {@link RegionalAuthority} for the Azure 'japaneast' region. */\n JapanEast = \"japaneast\",\n /** Uses the {@link RegionalAuthority} for the Azure 'japanwest' region. */\n JapanWest = \"japanwest\",\n /** Uses the {@link RegionalAuthority} for the Azure 'australiaeast' region. */\n AustraliaEast = \"australiaeast\",\n /** Uses the {@link RegionalAuthority} for the Azure 'australiasoutheast' region. */\n AustraliaSouthEast = \"australiasoutheast\",\n /** Uses the {@link RegionalAuthority} for the Azure 'australiacentral' region. */\n AustraliaCentral = \"australiacentral\",\n /** Uses the {@link RegionalAuthority} for the Azure 'australiacentral2' region. */\n AustraliaCentral2 = \"australiacentral2\",\n /** Uses the {@link RegionalAuthority} for the Azure 'centralindia' region. */\n IndiaCentral = \"centralindia\",\n /** Uses the {@link RegionalAuthority} for the Azure 'southindia' region. */\n IndiaSouth = \"southindia\",\n /** Uses the {@link RegionalAuthority} for the Azure 'westindia' region. */\n IndiaWest = \"westindia\",\n /** Uses the {@link RegionalAuthority} for the Azure 'koreasouth' region. */\n KoreaSouth = \"koreasouth\",\n /** Uses the {@link RegionalAuthority} for the Azure 'koreacentral' region. */\n KoreaCentral = \"koreacentral\",\n /** Uses the {@link RegionalAuthority} for the Azure 'uaecentral' region. */\n UAECentral = \"uaecentral\",\n /** Uses the {@link RegionalAuthority} for the Azure 'uaenorth' region. */\n UAENorth = \"uaenorth\",\n /** Uses the {@link RegionalAuthority} for the Azure 'southafricanorth' region. */\n SouthAfricaNorth = \"southafricanorth\",\n /** Uses the {@link RegionalAuthority} for the Azure 'southafricawest' region. */\n SouthAfricaWest = \"southafricawest\",\n /** Uses the {@link RegionalAuthority} for the Azure 'chinanorth' region. */\n ChinaNorth = \"chinanorth\",\n /** Uses the {@link RegionalAuthority} for the Azure 'chinaeast' region. */\n ChinaEast = \"chinaeast\",\n /** Uses the {@link RegionalAuthority} for the Azure 'chinanorth2' region. */\n ChinaNorth2 = \"chinanorth2\",\n /** Uses the {@link RegionalAuthority} for the Azure 'chinaeast2' region. */\n ChinaEast2 = \"chinaeast2\",\n /** Uses the {@link RegionalAuthority} for the Azure 'germanycentral' region. */\n GermanyCentral = \"germanycentral\",\n /** Uses the {@link RegionalAuthority} for the Azure 'germanynortheast' region. */\n GermanyNorthEast = \"germanynortheast\",\n /** Uses the {@link RegionalAuthority} for the Azure 'usgovvirginia' region. */\n GovernmentUSVirginia = \"usgovvirginia\",\n /** Uses the {@link RegionalAuthority} for the Azure 'usgoviowa' region. */\n GovernmentUSIowa = \"usgoviowa\",\n /** Uses the {@link RegionalAuthority} for the Azure 'usgovarizona' region. */\n GovernmentUSArizona = \"usgovarizona\",\n /** Uses the {@link RegionalAuthority} for the Azure 'usgovtexas' region. */\n GovernmentUSTexas = \"usgovtexas\",\n /** Uses the {@link RegionalAuthority} for the Azure 'usdodeast' region. */\n GovernmentUSDodEast = \"usdodeast\",\n /** Uses the {@link RegionalAuthority} for the Azure 'usdodcentral' region. */\n GovernmentUSDodCentral = \"usdodcentral\"\n}\n"]}
@@ -77,6 +77,6 @@ export function credentialLoggerInstance(title, parent, log = logger) {
77
77
  */
78
78
  export function credentialLogger(title, log = logger) {
79
79
  const credLogger = credentialLoggerInstance(title, undefined, log);
80
- return Object.assign(Object.assign({}, credLogger), { getToken: credentialLoggerInstance("=> getToken()", credLogger, log) });
80
+ return Object.assign(Object.assign({}, credLogger), { parent: log, getToken: credentialLoggerInstance("=> getToken()", credLogger, log) });
81
81
  }
82
82
  //# sourceMappingURL=logging.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"logging.js","sourceRoot":"","sources":["../../../src/util/logging.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,kBAAkB,EAAe,MAAM,eAAe,CAAC;AAEhE;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,kBAAkB,CAAC,UAAU,CAAC,CAAC;AAOrD;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,gBAA0B;IACvD,OAAO,gBAAgB,CAAC,MAAM,CAC5B,CAAC,GAA2B,EAAE,WAAmB,EAAE,EAAE;QACnD,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE;YAC5B,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;SAChC;aAAM;YACL,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;SAC/B;QACD,OAAO,GAAG,CAAC;IACb,CAAC,EACD,EAAE,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,CAC9B,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,cAAsB,EAAE,gBAA0B;IAC3E,MAAM,EAAE,QAAQ,EAAE,GAAG,cAAc,CAAC,gBAAgB,CAAC,CAAC;IACtD,MAAM,CAAC,IAAI,CACT,GAAG,cAAc,kDAAkD,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACzF,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,KAAwB;IACpD,OAAO,oBAAoB,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC;AAChF,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,KAAoC,EAAE,KAAqB;IACrF,IAAI,OAAO,GAAG,QAAQ,CAAC;IACvB,IAAI,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,MAAM,EAAE;QACjB,OAAO,IAAI,YAAY,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC;KAC3E;IACD,OAAO,GAAG,OAAO,mBAAmB,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,GAAG,CAAC;AAC3F,CAAC;AAkBD;;;;;;;GAOG;AACH,MAAM,UAAU,wBAAwB,CACtC,KAAa,EACb,MAAiC,EACjC,MAAmB,MAAM;IAEzB,MAAM,SAAS,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,SAAS,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;IAElE,SAAS,IAAI,CAAC,OAAe;QAC3B,GAAG,CAAC,IAAI,CAAC,GAAG,SAAS,KAAK,EAAE,OAAO,CAAC,CAAC;IACvC,CAAC;IAED,OAAO;QACL,KAAK;QACL,SAAS;QACT,IAAI;KACL,CAAC;AACJ,CAAC;AAUD;;;;;;;;;GASG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAa,EAAE,MAAmB,MAAM;IACvE,MAAM,UAAU,GAAG,wBAAwB,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,CAAC,CAAC;IACnE,uCACK,UAAU,KACb,QAAQ,EAAE,wBAAwB,CAAC,eAAe,EAAE,UAAU,EAAE,GAAG,CAAC,IACpE;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { createClientLogger, AzureLogger } from \"@azure/logger\";\n\n/**\n * The AzureLogger used for all clients within the identity package\n */\nexport const logger = createClientLogger(\"identity\");\n\ninterface EnvironmentAccumulator {\n missing: string[];\n assigned: string[];\n}\n\n/**\n * Separates a list of environment variable names into a plain object with two arrays: an array of missing environment variables and another array with assigned environment variables.\n * @param supportedEnvVars - List of environment variable names\n */\nexport function processEnvVars(supportedEnvVars: string[]): EnvironmentAccumulator {\n return supportedEnvVars.reduce(\n (acc: EnvironmentAccumulator, envVariable: string) => {\n if (process.env[envVariable]) {\n acc.assigned.push(envVariable);\n } else {\n acc.missing.push(envVariable);\n }\n return acc;\n },\n { missing: [], assigned: [] }\n );\n}\n\n/**\n * Based on a given list of environment variable names,\n * logs the environment variables currently assigned during the usage of a credential that goes by the given name.\n * @param credentialName - Name of the credential in use\n * @param supportedEnvVars - List of environment variables supported by that credential\n */\nexport function logEnvVars(credentialName: string, supportedEnvVars: string[]): void {\n const { assigned } = processEnvVars(supportedEnvVars);\n logger.info(\n `${credentialName} => Found the following environment variables: ${assigned.join(\", \")}`\n );\n}\n\n/**\n * Formatting the success event on the credentials\n */\nexport function formatSuccess(scope: string | string[]): string {\n return `SUCCESS. Scopes: ${Array.isArray(scope) ? scope.join(\", \") : scope}.`;\n}\n\n/**\n * Formatting the success event on the credentials\n */\nexport function formatError(scope: string | string[] | undefined, error: Error | string): string {\n let message = \"ERROR.\";\n if (scope?.length) {\n message += ` Scopes: ${Array.isArray(scope) ? scope.join(\", \") : scope}.`;\n }\n return `${message} Error message: ${typeof error === \"string\" ? error : error.message}.`;\n}\n\n/**\n * A CredentialLoggerInstance is a logger properly formatted to work in a credential's constructor, and its methods.\n */\nexport interface CredentialLoggerInstance {\n title: string;\n fullTitle: string;\n info(message: string): void;\n /**\n * The logging functions for warning and error are intentionally left out, since we want the identity logging to be at the info level.\n * Otherwise, they would look like:\n *\n * warning(message: string): void;\n * error(err: Error): void;\n */\n}\n\n/**\n * Generates a CredentialLoggerInstance.\n *\n * It logs with the format:\n *\n * `[title] => [message]`\n *\n */\nexport function credentialLoggerInstance(\n title: string,\n parent?: CredentialLoggerInstance,\n log: AzureLogger = logger\n): CredentialLoggerInstance {\n const fullTitle = parent ? `${parent.fullTitle} ${title}` : title;\n\n function info(message: string): void {\n log.info(`${fullTitle} =>`, message);\n }\n\n return {\n title,\n fullTitle,\n info\n };\n}\n\n/**\n * A CredentialLogger is a logger declared at the credential's constructor, and used at any point in the credential.\n * It has all the properties of a CredentialLoggerInstance, plus other logger instances, one per method.\n */\nexport interface CredentialLogger extends CredentialLoggerInstance {\n getToken: CredentialLoggerInstance;\n}\n\n/**\n * Generates a CredentialLogger, which is a logger declared at the credential's constructor, and used at any point in the credential.\n * It has all the properties of a CredentialLoggerInstance, plus other logger instances, one per method.\n *\n * It logs with the format:\n *\n * `[title] => [message]`\n * `[title] => getToken() => [message]`\n *\n */\nexport function credentialLogger(title: string, log: AzureLogger = logger): CredentialLogger {\n const credLogger = credentialLoggerInstance(title, undefined, log);\n return {\n ...credLogger,\n getToken: credentialLoggerInstance(\"=> getToken()\", credLogger, log)\n };\n}\n"]}
1
+ {"version":3,"file":"logging.js","sourceRoot":"","sources":["../../../src/util/logging.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,kBAAkB,EAAe,MAAM,eAAe,CAAC;AAEhE;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,kBAAkB,CAAC,UAAU,CAAC,CAAC;AAOrD;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,gBAA0B;IACvD,OAAO,gBAAgB,CAAC,MAAM,CAC5B,CAAC,GAA2B,EAAE,WAAmB,EAAE,EAAE;QACnD,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE;YAC5B,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;SAChC;aAAM;YACL,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;SAC/B;QACD,OAAO,GAAG,CAAC;IACb,CAAC,EACD,EAAE,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,CAC9B,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,cAAsB,EAAE,gBAA0B;IAC3E,MAAM,EAAE,QAAQ,EAAE,GAAG,cAAc,CAAC,gBAAgB,CAAC,CAAC;IACtD,MAAM,CAAC,IAAI,CACT,GAAG,cAAc,kDAAkD,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACzF,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,KAAwB;IACpD,OAAO,oBAAoB,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC;AAChF,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,KAAoC,EAAE,KAAqB;IACrF,IAAI,OAAO,GAAG,QAAQ,CAAC;IACvB,IAAI,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,MAAM,EAAE;QACjB,OAAO,IAAI,YAAY,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC;KAC3E;IACD,OAAO,GAAG,OAAO,mBAAmB,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,GAAG,CAAC;AAC3F,CAAC;AAkBD;;;;;;;GAOG;AACH,MAAM,UAAU,wBAAwB,CACtC,KAAa,EACb,MAAiC,EACjC,MAAmB,MAAM;IAEzB,MAAM,SAAS,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,SAAS,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;IAElE,SAAS,IAAI,CAAC,OAAe;QAC3B,GAAG,CAAC,IAAI,CAAC,GAAG,SAAS,KAAK,EAAE,OAAO,CAAC,CAAC;IACvC,CAAC;IAED,OAAO;QACL,KAAK;QACL,SAAS;QACT,IAAI;KACL,CAAC;AACJ,CAAC;AAWD;;;;;;;;;GASG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAa,EAAE,MAAmB,MAAM;IACvE,MAAM,UAAU,GAAG,wBAAwB,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,CAAC,CAAC;IACnE,uCACK,UAAU,KACb,MAAM,EAAE,GAAG,EACX,QAAQ,EAAE,wBAAwB,CAAC,eAAe,EAAE,UAAU,EAAE,GAAG,CAAC,IACpE;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { createClientLogger, AzureLogger } from \"@azure/logger\";\n\n/**\n * The AzureLogger used for all clients within the identity package\n */\nexport const logger = createClientLogger(\"identity\");\n\ninterface EnvironmentAccumulator {\n missing: string[];\n assigned: string[];\n}\n\n/**\n * Separates a list of environment variable names into a plain object with two arrays: an array of missing environment variables and another array with assigned environment variables.\n * @param supportedEnvVars - List of environment variable names\n */\nexport function processEnvVars(supportedEnvVars: string[]): EnvironmentAccumulator {\n return supportedEnvVars.reduce(\n (acc: EnvironmentAccumulator, envVariable: string) => {\n if (process.env[envVariable]) {\n acc.assigned.push(envVariable);\n } else {\n acc.missing.push(envVariable);\n }\n return acc;\n },\n { missing: [], assigned: [] }\n );\n}\n\n/**\n * Based on a given list of environment variable names,\n * logs the environment variables currently assigned during the usage of a credential that goes by the given name.\n * @param credentialName - Name of the credential in use\n * @param supportedEnvVars - List of environment variables supported by that credential\n */\nexport function logEnvVars(credentialName: string, supportedEnvVars: string[]): void {\n const { assigned } = processEnvVars(supportedEnvVars);\n logger.info(\n `${credentialName} => Found the following environment variables: ${assigned.join(\", \")}`\n );\n}\n\n/**\n * Formatting the success event on the credentials\n */\nexport function formatSuccess(scope: string | string[]): string {\n return `SUCCESS. Scopes: ${Array.isArray(scope) ? scope.join(\", \") : scope}.`;\n}\n\n/**\n * Formatting the success event on the credentials\n */\nexport function formatError(scope: string | string[] | undefined, error: Error | string): string {\n let message = \"ERROR.\";\n if (scope?.length) {\n message += ` Scopes: ${Array.isArray(scope) ? scope.join(\", \") : scope}.`;\n }\n return `${message} Error message: ${typeof error === \"string\" ? error : error.message}.`;\n}\n\n/**\n * A CredentialLoggerInstance is a logger properly formatted to work in a credential's constructor, and its methods.\n */\nexport interface CredentialLoggerInstance {\n title: string;\n fullTitle: string;\n info(message: string): void;\n /**\n * The logging functions for warning and error are intentionally left out, since we want the identity logging to be at the info level.\n * Otherwise, they would look like:\n *\n * warning(message: string): void;\n * error(err: Error): void;\n */\n}\n\n/**\n * Generates a CredentialLoggerInstance.\n *\n * It logs with the format:\n *\n * `[title] => [message]`\n *\n */\nexport function credentialLoggerInstance(\n title: string,\n parent?: CredentialLoggerInstance,\n log: AzureLogger = logger\n): CredentialLoggerInstance {\n const fullTitle = parent ? `${parent.fullTitle} ${title}` : title;\n\n function info(message: string): void {\n log.info(`${fullTitle} =>`, message);\n }\n\n return {\n title,\n fullTitle,\n info\n };\n}\n\n/**\n * A CredentialLogger is a logger declared at the credential's constructor, and used at any point in the credential.\n * It has all the properties of a CredentialLoggerInstance, plus other logger instances, one per method.\n */\nexport interface CredentialLogger extends CredentialLoggerInstance {\n parent: AzureLogger;\n getToken: CredentialLoggerInstance;\n}\n\n/**\n * Generates a CredentialLogger, which is a logger declared at the credential's constructor, and used at any point in the credential.\n * It has all the properties of a CredentialLoggerInstance, plus other logger instances, one per method.\n *\n * It logs with the format:\n *\n * `[title] => [message]`\n * `[title] => getToken() => [message]`\n *\n */\nexport function credentialLogger(title: string, log: AzureLogger = logger): CredentialLogger {\n const credLogger = credentialLoggerInstance(title, undefined, log);\n return {\n ...credLogger,\n parent: log,\n getToken: credentialLoggerInstance(\"=> getToken()\", credLogger, log)\n };\n}\n"]}
@@ -0,0 +1,32 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+ import * as childProcess from "child_process";
4
+ /**
5
+ * Easy to mock childProcess utils.
6
+ * @internal
7
+ */
8
+ export const processUtils = {
9
+ /**
10
+ * Promisifying childProcess.execFile
11
+ * @internal
12
+ */
13
+ execFile(file, params, options) {
14
+ return new Promise((resolve, reject) => {
15
+ childProcess.execFile(file, params, options, (error, stdout, stderr) => {
16
+ if (Buffer.isBuffer(stdout)) {
17
+ stdout = stdout.toString("utf8");
18
+ }
19
+ if (Buffer.isBuffer(stderr)) {
20
+ stderr = stderr.toString("utf8");
21
+ }
22
+ if (stderr || error) {
23
+ reject(stderr ? new Error(stderr) : error);
24
+ }
25
+ else {
26
+ resolve(stdout);
27
+ }
28
+ });
29
+ });
30
+ }
31
+ };
32
+ //# sourceMappingURL=processUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"processUtils.js","sourceRoot":"","sources":["../../../src/util/processUtils.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,KAAK,YAAY,MAAM,eAAe,CAAC;AAE9C;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B;;;OAGG;IACH,QAAQ,CACN,IAAY,EACZ,MAAgB,EAChB,OAAwD;QAExD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,YAAY,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE;gBACrE,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;oBAC3B,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;iBAClC;gBACD,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;oBAC3B,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;iBAClC;gBACD,IAAI,MAAM,IAAI,KAAK,EAAE;oBACnB,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;iBAC5C;qBAAM;oBACL,OAAO,CAAC,MAAM,CAAC,CAAC;iBACjB;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport * as childProcess from \"child_process\";\n\n/**\n * Easy to mock childProcess utils.\n * @internal\n */\nexport const processUtils = {\n /**\n * Promisifying childProcess.execFile\n * @internal\n */\n execFile(\n file: string,\n params: string[],\n options?: childProcess.ExecFileOptionsWithStringEncoding\n ): Promise<string | Buffer> {\n return new Promise((resolve, reject) => {\n childProcess.execFile(file, params, options, (error, stdout, stderr) => {\n if (Buffer.isBuffer(stdout)) {\n stdout = stdout.toString(\"utf8\");\n }\n if (Buffer.isBuffer(stderr)) {\n stderr = stderr.toString(\"utf8\");\n }\n if (stderr || error) {\n reject(stderr ? new Error(stderr) : error);\n } else {\n resolve(stdout);\n }\n });\n });\n }\n};\n"]}
@@ -0,0 +1,22 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+ import { formatError } from "./logging";
4
+ /**
5
+ * Throws if the received scope is not valid.
6
+ * @internal
7
+ */
8
+ export function ensureValidScope(scope, logger) {
9
+ if (!scope.match(/^[0-9a-zA-Z-.:/]+$/)) {
10
+ const error = new Error("Invalid scope was specified by the user or calling client");
11
+ logger.getToken.info(formatError(scope, error));
12
+ throw error;
13
+ }
14
+ }
15
+ /**
16
+ * Returns the resource out of a scope.
17
+ * @internal
18
+ */
19
+ export function getScopeResource(scope) {
20
+ return scope.replace(/\/.default$/, "");
21
+ }
22
+ //# sourceMappingURL=scopeUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scopeUtils.js","sourceRoot":"","sources":["../../../src/util/scopeUtils.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAoB,WAAW,EAAE,MAAM,WAAW,CAAC;AAE1D;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAa,EAAE,MAAwB;IACtE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,oBAAoB,CAAC,EAAE;QACtC,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAC;QACrF,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;QAChD,MAAM,KAAK,CAAC;KACb;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAa;IAC5C,OAAO,KAAK,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;AAC1C,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { CredentialLogger, formatError } from \"./logging\";\n\n/**\n * Throws if the received scope is not valid.\n * @internal\n */\nexport function ensureValidScope(scope: string, logger: CredentialLogger): void {\n if (!scope.match(/^[0-9a-zA-Z-.:/]+$/)) {\n const error = new Error(\"Invalid scope was specified by the user or calling client\");\n logger.getToken.info(formatError(scope, error));\n throw error;\n }\n}\n\n/**\n * Returns the resource out of a scope.\n * @internal\n */\nexport function getScopeResource(scope: string): string {\n return scope.replace(/\\/.default$/, \"\");\n}\n"]}
@@ -1,6 +1,5 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
2
  // Licensed under the MIT license.
3
- import { __awaiter } from "tslib";
4
3
  import { createSpanFunction, SpanStatusCode } from "@azure/core-tracing";
5
4
  /**
6
5
  * Creates a span using the global tracer.
@@ -15,34 +14,32 @@ export const createSpan = createSpanFunction({
15
14
  * Traces an operation and properly handles reporting start, end and errors for a given span
16
15
  *
17
16
  * @param operationName - Name of a method in the TClient type
18
- * @param options - An options class, typically derived from \@azure/core-http/RequestOptionsBase
17
+ * @param options - An options class, typically derived from \@azure/core-rest-pipeline/RequestOptionsBase
19
18
  * @param fn - The function to call with an options class that properly propagates the span context
20
19
  *
21
20
  * @internal
22
21
  */
23
- export function trace(operationName, options, fn, createSpanFn = createSpan) {
24
- return __awaiter(this, void 0, void 0, function* () {
25
- const { updatedOptions, span } = createSpanFn(operationName, options);
26
- try {
27
- // NOTE: we really do need to await on this function here so we can handle any exceptions thrown and properly
28
- // close the span.
29
- const result = yield fn(updatedOptions, span);
30
- // otel 0.16+ needs this or else the code ends up being set as UNSET
31
- span.setStatus({
32
- code: SpanStatusCode.OK
33
- });
34
- return result;
35
- }
36
- catch (err) {
37
- span.setStatus({
38
- code: SpanStatusCode.ERROR,
39
- message: err.message
40
- });
41
- throw err;
42
- }
43
- finally {
44
- span.end();
45
- }
46
- });
22
+ export async function trace(operationName, options, fn, createSpanFn = createSpan) {
23
+ const { updatedOptions, span } = createSpanFn(operationName, options);
24
+ try {
25
+ // NOTE: we really do need to await on this function here so we can handle any exceptions thrown and properly
26
+ // close the span.
27
+ const result = await fn(updatedOptions, span);
28
+ // otel 0.16+ needs this or else the code ends up being set as UNSET
29
+ span.setStatus({
30
+ code: SpanStatusCode.OK
31
+ });
32
+ return result;
33
+ }
34
+ catch (err) {
35
+ span.setStatus({
36
+ code: SpanStatusCode.ERROR,
37
+ message: err.message
38
+ });
39
+ throw err;
40
+ }
41
+ finally {
42
+ span.end();
43
+ }
47
44
  }
48
45
  //# sourceMappingURL=tracing.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tracing.js","sourceRoot":"","sources":["../../../src/util/tracing.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAGlC,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAQ,MAAM,qBAAqB,CAAC;AAE/E;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,kBAAkB,CAAC;IAC3C,aAAa,EAAE,gBAAgB;IAC/B,SAAS,EAAE,eAAe;CAC3B,CAAC,CAAC;AAEH;;;;;;;;;GASG;AACH,MAAM,UAAgB,KAAK,CACzB,aAAqB,EACrB,OAAyB,EACzB,EAA+D,EAC/D,YAAY,GAAG,UAAU;;QAEzB,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,GAAG,YAAY,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;QAEtE,IAAI;YACF,6GAA6G;YAC7G,kBAAkB;YAClB,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC;YAE9C,oEAAoE;YACpE,IAAI,CAAC,SAAS,CAAC;gBACb,IAAI,EAAE,cAAc,CAAC,EAAE;aACxB,CAAC,CAAC;YACH,OAAO,MAAM,CAAC;SACf;QAAC,OAAO,GAAG,EAAE;YACZ,IAAI,CAAC,SAAS,CAAC;gBACb,IAAI,EAAE,cAAc,CAAC,KAAK;gBAC1B,OAAO,EAAE,GAAG,CAAC,OAAO;aACrB,CAAC,CAAC;YACH,MAAM,GAAG,CAAC;SACX;gBAAS;YACR,IAAI,CAAC,GAAG,EAAE,CAAC;SACZ;IACH,CAAC;CAAA","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { OperationOptions } from \"@azure/core-http\";\nimport { createSpanFunction, SpanStatusCode, Span } from \"@azure/core-tracing\";\n\n/**\n * Creates a span using the global tracer.\n * @internal\n */\nexport const createSpan = createSpanFunction({\n packagePrefix: \"Azure.Identity\",\n namespace: \"Microsoft.AAD\"\n});\n\n/**\n * From: https://github.com/Azure/azure-sdk-for-js/blob/46139daa3317a0d12e8b55b02b9d9cdf1b2e762a/sdk/appconfiguration/app-configuration/src/internal/tracingHelpers.ts\n * Traces an operation and properly handles reporting start, end and errors for a given span\n *\n * @param operationName - Name of a method in the TClient type\n * @param options - An options class, typically derived from \\@azure/core-http/RequestOptionsBase\n * @param fn - The function to call with an options class that properly propagates the span context\n *\n * @internal\n */\nexport async function trace<ReturnT>(\n operationName: string,\n options: OperationOptions,\n fn: (options: OperationOptions, span: Span) => Promise<ReturnT>,\n createSpanFn = createSpan\n): Promise<ReturnT> {\n const { updatedOptions, span } = createSpanFn(operationName, options);\n\n try {\n // NOTE: we really do need to await on this function here so we can handle any exceptions thrown and properly\n // close the span.\n const result = await fn(updatedOptions, span);\n\n // otel 0.16+ needs this or else the code ends up being set as UNSET\n span.setStatus({\n code: SpanStatusCode.OK\n });\n return result;\n } catch (err) {\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: err.message\n });\n throw err;\n } finally {\n span.end();\n }\n}\n"]}
1
+ {"version":3,"file":"tracing.js","sourceRoot":"","sources":["../../../src/util/tracing.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAQ,MAAM,qBAAqB,CAAC;AAG/E;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,kBAAkB,CAAC;IAC3C,aAAa,EAAE,gBAAgB;IAC/B,SAAS,EAAE,eAAe;CAC3B,CAAC,CAAC;AAEH;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,KAAK,CACzB,aAAqB,EACrB,OAAyB,EACzB,EAA+D,EAC/D,YAAY,GAAG,UAAU;IAEzB,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,GAAG,YAAY,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;IAEtE,IAAI;QACF,6GAA6G;QAC7G,kBAAkB;QAClB,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC;QAE9C,oEAAoE;QACpE,IAAI,CAAC,SAAS,CAAC;YACb,IAAI,EAAE,cAAc,CAAC,EAAE;SACxB,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;KACf;IAAC,OAAO,GAAG,EAAE;QACZ,IAAI,CAAC,SAAS,CAAC;YACb,IAAI,EAAE,cAAc,CAAC,KAAK;YAC1B,OAAO,EAAE,GAAG,CAAC,OAAO;SACrB,CAAC,CAAC;QACH,MAAM,GAAG,CAAC;KACX;YAAS;QACR,IAAI,CAAC,GAAG,EAAE,CAAC;KACZ;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { createSpanFunction, SpanStatusCode, Span } from \"@azure/core-tracing\";\nimport { OperationOptions } from \"@azure/core-client\";\n\n/**\n * Creates a span using the global tracer.\n * @internal\n */\nexport const createSpan = createSpanFunction({\n packagePrefix: \"Azure.Identity\",\n namespace: \"Microsoft.AAD\"\n});\n\n/**\n * From: https://github.com/Azure/azure-sdk-for-js/blob/46139daa3317a0d12e8b55b02b9d9cdf1b2e762a/sdk/appconfiguration/app-configuration/src/internal/tracingHelpers.ts\n * Traces an operation and properly handles reporting start, end and errors for a given span\n *\n * @param operationName - Name of a method in the TClient type\n * @param options - An options class, typically derived from \\@azure/core-rest-pipeline/RequestOptionsBase\n * @param fn - The function to call with an options class that properly propagates the span context\n *\n * @internal\n */\nexport async function trace<ReturnT>(\n operationName: string,\n options: OperationOptions,\n fn: (options: OperationOptions, span: Span) => Promise<ReturnT>,\n createSpanFn = createSpan\n): Promise<ReturnT> {\n const { updatedOptions, span } = createSpanFn(operationName, options);\n\n try {\n // NOTE: we really do need to await on this function here so we can handle any exceptions thrown and properly\n // close the span.\n const result = await fn(updatedOptions, span);\n\n // otel 0.16+ needs this or else the code ends up being set as UNSET\n span.setStatus({\n code: SpanStatusCode.OK\n });\n return result;\n } catch (err) {\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: err.message\n });\n throw err;\n } finally {\n span.end();\n }\n}\n"]}
@@ -0,0 +1,24 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+ /**
4
+ * @internal
5
+ */
6
+ export const multiTenantErrorMessage = "A getToken request was attempted with a tenant different than the tenant configured at the initialization of the credential, but multi-tenant authentication was not enabled in this credential instance.";
7
+ /**
8
+ * Verifies whether locally assigned tenants are equal to tenants received through getToken.
9
+ * Returns the appropriate tenant.
10
+ * @internal
11
+ */
12
+ export function processMultiTenantRequest(tenantId, allowMultiTenantAuthentication, getTokenOptions) {
13
+ if (!allowMultiTenantAuthentication &&
14
+ (getTokenOptions === null || getTokenOptions === void 0 ? void 0 : getTokenOptions.tenantId) &&
15
+ tenantId &&
16
+ getTokenOptions.tenantId !== tenantId) {
17
+ throw new Error(multiTenantErrorMessage);
18
+ }
19
+ if (allowMultiTenantAuthentication && (getTokenOptions === null || getTokenOptions === void 0 ? void 0 : getTokenOptions.tenantId)) {
20
+ return getTokenOptions.tenantId;
21
+ }
22
+ return tenantId;
23
+ }
24
+ //# sourceMappingURL=validateMultiTenant.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validateMultiTenant.js","sourceRoot":"","sources":["../../../src/util/validateMultiTenant.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAClC,2MAA2M,CAAC;AAE9M;;;;GAIG;AACH,MAAM,UAAU,yBAAyB,CACvC,QAAiB,EACjB,8BAAwC,EACxC,eAAiC;IAEjC,IACE,CAAC,8BAA8B;SAC/B,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,QAAQ,CAAA;QACzB,QAAQ;QACR,eAAe,CAAC,QAAQ,KAAK,QAAQ,EACrC;QACA,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;KAC1C;IACD,IAAI,8BAA8B,KAAI,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,QAAQ,CAAA,EAAE;QAC/D,OAAO,eAAe,CAAC,QAAQ,CAAC;KACjC;IACD,OAAO,QAAQ,CAAC;AAClB,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 multiTenantErrorMessage =\n \"A getToken request was attempted with a tenant different than the tenant configured at the initialization of the credential, but multi-tenant authentication was not enabled in this credential instance.\";\n\n/**\n * Verifies whether locally assigned tenants are equal to tenants received through getToken.\n * Returns the appropriate tenant.\n * @internal\n */\nexport function processMultiTenantRequest(\n tenantId?: string,\n allowMultiTenantAuthentication?: boolean,\n getTokenOptions?: GetTokenOptions\n): string | undefined {\n if (\n !allowMultiTenantAuthentication &&\n getTokenOptions?.tenantId &&\n tenantId &&\n getTokenOptions.tenantId !== tenantId\n ) {\n throw new Error(multiTenantErrorMessage);\n }\n if (allowMultiTenantAuthentication && getTokenOptions?.tenantId) {\n return getTokenOptions.tenantId;\n }\n return tenantId;\n}\n"]}
package/package.json CHANGED
@@ -1,35 +1,40 @@
1
1
  {
2
2
  "name": "@azure/identity",
3
3
  "sdk-type": "client",
4
- "version": "2.0.0-beta.2",
4
+ "version": "2.0.0-beta.6",
5
5
  "description": "Provides credential implementations for Azure SDK libraries that can authenticate with Azure Active Directory",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist-esm/src/index.js",
8
8
  "types": "./types/identity.d.ts",
9
9
  "browser": {
10
+ "os": false,
11
+ "process": false,
10
12
  "./dist-esm/src/credentials/azureCliCredential.js": "./dist-esm/src/credentials/azureCliCredential.browser.js",
11
13
  "./dist-esm/src/credentials/environmentCredential.js": "./dist-esm/src/credentials/environmentCredential.browser.js",
12
14
  "./dist-esm/src/credentials/managedIdentityCredential/index.js": "./dist-esm/src/credentials/managedIdentityCredential/index.browser.js",
13
15
  "./dist-esm/src/credentials/clientCertificateCredential.js": "./dist-esm/src/credentials/clientCertificateCredential.browser.js",
16
+ "./dist-esm/src/credentials/clientSecretCredential.js": "./dist-esm/src/credentials/clientSecretCredential.browser.js",
14
17
  "./dist-esm/src/credentials/deviceCodeCredential.js": "./dist-esm/src/credentials/deviceCodeCredential.browser.js",
15
18
  "./dist-esm/src/credentials/defaultAzureCredential.js": "./dist-esm/src/credentials/defaultAzureCredential.browser.js",
16
19
  "./dist-esm/src/credentials/authorizationCodeCredential.js": "./dist-esm/src/credentials/authorizationCodeCredential.browser.js",
17
20
  "./dist-esm/src/credentials/interactiveBrowserCredential.js": "./dist-esm/src/credentials/interactiveBrowserCredential.browser.js",
18
21
  "./dist-esm/src/credentials/visualStudioCodeCredential.js": "./dist-esm/src/credentials/visualStudioCodeCredential.browser.js",
22
+ "./dist-esm/src/credentials/usernamePasswordCredential.js": "./dist-esm/src/credentials/usernamePasswordCredential.browser.js",
23
+ "./dist-esm/src/credentials/azurePowerShellCredential.js": "./dist-esm/src/credentials/azurePowerShellCredential.browser.js",
24
+ "./dist-esm/src/credentials/applicationCredential.js": "./dist-esm/src/credentials/applicationCredential.browser.js",
25
+ "./dist-esm/src/credentials/onBehalfOfCredential.js": "./dist-esm/src/credentials/onBehalfOfCredential.browser.js",
19
26
  "./dist-esm/src/util/authHostEnv.js": "./dist-esm/src/util/authHostEnv.browser.js",
20
- "./dist-esm/src/tokenCache/TokenCachePersistence.js": "./dist-esm/src/tokenCache/TokenCachePersistence.browser.js"
27
+ "./dist-esm/src/tokenCache/TokenCachePersistence.js": "./dist-esm/src/tokenCache/TokenCachePersistence.browser.js",
28
+ "./dist-esm/src/plugins/consumer.js": "./dist-esm/src/plugins/consumer.browser.js",
29
+ "./dist-esm/test/httpRequests.js": "./dist-esm/test/httpRequests.browser.js"
21
30
  },
22
31
  "scripts": {
23
32
  "audit": "node ../../../common/scripts/rush-audit.js && rimraf node_modules package-lock.json && npm i --package-lock-only 2>&1 && npm audit",
24
- "build:browser": "tsc -p . && cross-env ONLY_BROWSER=true rollup -c 2>&1",
25
- "build:node": "tsc -p . && cross-env ONLY_NODE=true rollup -c 2>&1",
26
33
  "build:samples": "echo skipped",
27
- "build:test:browser": "tsc -p . && cross-env ONLY_BROWSER=true rollup -c rollup.test.config.js 2>&1",
28
- "build:test:node": "tsc -p . && cross-env ONLY_NODE=true rollup -c rollup.test.config.js 2>&1",
29
- "build:test": "tsc -p . && rollup -c rollup.test.config.js 2>&1",
30
- "build": "npm run extract-api && tsc -p . && rollup -c 2>&1",
34
+ "build:test": "tsc -p . && rollup -c 2>&1",
35
+ "build": "npm run clean && npm run extract-api && tsc -p . && rollup -c 2>&1",
31
36
  "check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\" \"samples/**/*.{js,json}\"",
32
- "clean": "rimraf dist dist-esm dist-browser test-dist test-browser typings *.tgz *.log",
37
+ "clean": "rimraf dist dist-* types *.tgz *.log",
33
38
  "execute:samples": "echo skipped",
34
39
  "extract-api": "tsc -p . && api-extractor run --local",
35
40
  "format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\" \"samples/**/*.{js,json}\"",
@@ -39,12 +44,12 @@
39
44
  "lint:fix": "eslint package.json api-extractor.json src test --ext .ts --fix --fix-type [problem,suggestion]",
40
45
  "lint": "eslint package.json api-extractor.json src test --ext .ts",
41
46
  "pack": "npm pack 2>&1",
42
- "prebuild": "npm run clean",
43
47
  "test:browser": "npm run clean && npm run build:test && npm run unit-test:browser && npm run integration-test:browser",
44
48
  "test:node": "npm run clean && npm run build:test && npm run unit-test:node && npm run integration-test:node",
45
49
  "test": "npm run clean && npm run build:test && npm run unit-test && npm run integration-test",
46
- "unit-test:browser": "echo skipped",
47
- "unit-test:node": "mocha --require source-map-support/register --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 180000 --full-trace \"test-dist/**/*.js\"",
50
+ "unit-test:browser": "karma start --single-run",
51
+ "unit-test:node": "mocha -r esm -r ts-node/register --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 300000 --full-trace --exclude \"test/**/browser/**/*.spec.ts\" \"test/**/*.spec.ts\"",
52
+ "unit-test:node:no-timeouts": "mocha -r esm -r ts-node/register --reporter ../../../common/tools/mocha-multi-reporter.js --no-timeouts --full-trace --exclude \"test/**/browser/**/*.spec.ts\" \"test/**/*.spec.ts\"",
48
53
  "unit-test": "npm run unit-test:node && npm run unit-test:browser",
49
54
  "docs": "typedoc --excludePrivate --excludeNotExported --excludeExternals --stripInternal --mode file --out ./dist/docs ./src"
50
55
  },
@@ -55,8 +60,16 @@
55
60
  "README.md",
56
61
  "LICENSE"
57
62
  ],
63
+ "//metadata": {
64
+ "constantPaths": [
65
+ {
66
+ "path": "src/client/identityClient.ts",
67
+ "prefix": "packageDetails"
68
+ }
69
+ ]
70
+ },
58
71
  "engines": {
59
- "node": ">=8.0.0"
72
+ "node": ">=12.0.0"
60
73
  },
61
74
  "repository": "github:Azure/azure-sdk-for-js",
62
75
  "keywords": [
@@ -66,7 +79,7 @@
66
79
  "authentication",
67
80
  "credential",
68
81
  "certificate",
69
- "managed service identity",
82
+ "managed identity",
70
83
  "client secret",
71
84
  "access token"
72
85
  ],
@@ -75,46 +88,39 @@
75
88
  "bugs": {
76
89
  "url": "https://github.com/Azure/azure-sdk-for-js/issues"
77
90
  },
78
- "engine": {
79
- "node": ">=8.0.0"
80
- },
81
- "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/identity/identity/README.md",
91
+ "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity/README.md",
82
92
  "sideEffects": false,
83
93
  "dependencies": {
84
- "@azure/core-http": "^1.2.0",
85
- "@azure/core-tracing": "1.0.0-preview.11",
94
+ "@azure/core-util": "^1.0.0-beta.1",
95
+ "@azure/core-tracing": "1.0.0-preview.13",
96
+ "@azure/core-auth": "^1.3.0",
97
+ "@azure/core-client": "^1.0.0",
98
+ "@azure/core-rest-pipeline": "^1.1.0",
86
99
  "@azure/logger": "^1.0.0",
87
100
  "@azure/abort-controller": "^1.0.0",
88
- "@azure/msal-common": "~4.0.1",
89
- "@azure/msal-node": "^1.0.0",
90
- "@azure/msal-browser": "2.9.0",
101
+ "@azure/msal-common": "^4.5.1",
102
+ "@azure/msal-node": "^1.3.0",
103
+ "@azure/msal-browser": "^2.16.0",
91
104
  "@types/stoppable": "^1.1.0",
92
105
  "events": "^3.0.0",
93
106
  "jws": "^4.0.0",
94
107
  "open": "^7.0.0",
95
- "qs": "^6.7.0",
96
108
  "stoppable": "^1.1.0",
97
- "tslib": "^2.0.0",
109
+ "tslib": "^2.2.0",
98
110
  "uuid": "^8.3.0"
99
111
  },
100
- "optionalDependencies": {
101
- "keytar": "^7.3.0"
102
- },
103
112
  "devDependencies": {
104
113
  "@azure/eslint-plugin-azure-sdk": "^3.0.0",
105
114
  "@azure/dev-tool": "^1.0.0",
106
- "@azure/test-utils-recorder": "^1.0.0",
115
+ "@azure/test-utils": "^1.0.0",
116
+ "@azure-tools/test-recorder": "^1.0.0",
107
117
  "@microsoft/api-extractor": "7.7.11",
108
- "@rollup/plugin-commonjs": "11.0.2",
109
- "@rollup/plugin-json": "^4.0.0",
110
- "@rollup/plugin-multi-entry": "^3.0.0",
111
- "@rollup/plugin-node-resolve": "^8.0.0",
112
- "@rollup/plugin-replace": "^2.2.0",
113
118
  "@types/jws": "^3.2.2",
114
119
  "@types/mocha": "^7.0.2",
115
- "@types/node": "^8.0.0",
116
- "@types/qs": "^6.5.3",
120
+ "@types/node": "^12.0.0",
117
121
  "@types/uuid": "^8.0.0",
122
+ "@types/chai": "^4.1.6",
123
+ "chai": "^4.2.0",
118
124
  "assert": "^1.4.1",
119
125
  "cross-env": "^7.0.2",
120
126
  "dotenv": "^8.2.0",
@@ -131,17 +137,13 @@
131
137
  "mocha": "^7.1.1",
132
138
  "mocha-junit-reporter": "^1.18.0",
133
139
  "prettier": "^1.16.4",
134
- "puppeteer": "^3.3.0",
140
+ "puppeteer": "^10.2.0",
135
141
  "rimraf": "^3.0.0",
136
142
  "rollup": "^1.16.3",
137
- "rollup-plugin-sourcemaps": "^0.4.2",
138
- "rollup-plugin-terser": "^5.1.1",
139
- "rollup-plugin-visualizer": "^4.0.4",
140
143
  "typescript": "~4.2.0",
141
144
  "util": "^0.12.1",
142
145
  "sinon": "^9.0.2",
143
146
  "@types/sinon": "^9.0.4",
144
- "mock-fs": "^4.10.4",
145
147
  "typedoc": "0.15.2"
146
148
  }
147
149
  }