@azure/identity-vscode 1.0.1-alpha.20250228.2 → 1.0.1-alpha.20250303.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -4,15 +4,6 @@ This package provides a plugin to the Azure Identity library for JavaScript ([`@
4
4
 
5
5
  [Source code](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity-vscode) | [Samples](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity-vscode/samples-dev)
6
6
 
7
- ## Getting started
8
-
9
- ```javascript
10
- const { useIdentityPlugin } = require("@azure/identity");
11
- const { vsCodePlugin } = require("@azure/identity-vscode");
12
-
13
- useIdentityPlugin(vsCodePlugin);
14
- ```
15
-
16
7
  ### Prerequisites
17
8
 
18
9
  - An [Azure subscription](https://azure.microsoft.com/free/).
@@ -39,9 +30,9 @@ If this is your first time using `@azure/identity` or Microsoft Entra ID, we rec
39
30
 
40
31
  As of `@azure/identity` version 2.0.0, the Identity client library for JavaScript includes a plugin API. This package (`@azure/identity-vscode`) exports a plugin object that you must pass as an argument to the top-level `useIdentityPlugin` function from the `@azure/identity` package. Enable authentication through the "Azure Account" extension for Visual Studio Code as follows:
41
32
 
42
- ```javascript
43
- const { useIdentityPlugin } = require("@azure/identity");
44
- const { vsCodePlugin } = require("@azure/identity-vscode");
33
+ ```ts snippet:ReadmeSampleUsePlugin
34
+ import { useIdentityPlugin } from "@azure/identity";
35
+ import { vsCodePlugin } from "@azure/identity-vscode";
45
36
 
46
37
  useIdentityPlugin(vsCodePlugin);
47
38
  ```
@@ -58,51 +49,37 @@ After signing in, you may need to select a subscription (for example, if you hav
58
49
 
59
50
  Once the plugin is registered, you can use `VisualStudioCodeCredential` in a similar fashion to the other credential classes in `@azure/identity`:
60
51
 
61
- ```javascript
62
- const { useIdentityPlugin, VisualStudioCodeCredential } = require("@azure/identity");
63
- const { vsCodePlugin } = require("@azure/identity-vscode");
52
+ ```ts snippet:ReadmeSampleVisualStudioCodeCredential
53
+ import { useIdentityPlugin, VisualStudioCodeCredential } from "@azure/identity";
54
+ import { vsCodePlugin } from "@azure/identity-vscode";
64
55
 
65
56
  useIdentityPlugin(vsCodePlugin);
66
57
 
67
- async function main() {
68
- const credential = new VisualStudioCodeCredential();
69
-
70
- // The graph.microsoft.com scope is used as an example
71
- const scope = "https://graph.microsoft.com/.default";
58
+ const credential = new VisualStudioCodeCredential();
72
59
 
73
- // Print out part of the access token
74
- console.log((await credential.getToken(scope)).token.substr(0, 10), "...");
75
- }
60
+ // The graph.microsoft.com scope is used as an example
61
+ const scope = "https://graph.microsoft.com/.default";
76
62
 
77
- main().catch((error) => {
78
- console.error("An error occurred:", error);
79
- process.exit(1);
80
- });
63
+ // Print out part of the access token
64
+ console.log((await credential.getToken(scope)).token.substr(0, 10), "...");
81
65
  ```
82
66
 
83
67
  You can also use `DefaultAzureCredential`, which will attempt to authenticate using the "Azure Account" extension for Visual Studio Code if it's available:
84
68
 
85
- ```javascript
86
- const { useIdentityPlugin, DefaultAzureCredential } = require("@azure/identity");
87
- const { vsCodePlugin } = require("@azure/identity-vscode");
69
+ ```ts snippet:ReadmeSampleDefaultAzureCredential
70
+ import { useIdentityPlugin, DefaultAzureCredential } from "@azure/identity";
71
+ import { vsCodePlugin } from "@azure/identity-vscode";
88
72
 
89
73
  useIdentityPlugin(vsCodePlugin);
90
74
 
91
- async function main() {
92
- // With the plugin enabled above, `DefaultAzureCredential` will use
93
- // Visual Studio Code's "Azure Account" extension to authenticate if
94
- // it is available.
95
- const credential = new DefaultAzureCredential();
96
-
97
- // This will print a JWT access_token and its expiration timestamp
98
- // The graph.microsoft.com scope is used as an example
99
- console.log("Token:", await credential.getToken("https://graph.microsoft.com/.default"));
100
- }
101
-
102
- main().catch((error) => {
103
- console.error("An error occurred:", error);
104
- process.exit(1);
105
- });
75
+ // With the plugin enabled above, `DefaultAzureCredential` will use
76
+ // Visual Studio Code's "Azure Account" extension to authenticate if
77
+ // it is available.
78
+ const credential = new DefaultAzureCredential();
79
+
80
+ // This will print a JWT access_token and its expiration timestamp
81
+ // The graph.microsoft.com scope is used as an example
82
+ console.log("Token:", await credential.getToken("https://graph.microsoft.com/.default"));
106
83
  ```
107
84
 
108
85
  ## Troubleshooting
@@ -111,8 +88,8 @@ main().catch((error) => {
111
88
 
112
89
  Enabling logging may help uncover useful information about failures. In order to see a log of HTTP requests and responses, set the `AZURE_LOG_LEVEL` environment variable to `info`. Alternatively, logging can be enabled at runtime by calling `setLogLevel` in the `@azure/logger`:
113
90
 
114
- ```javascript
115
- const { setLogLevel } = require("@azure/logger");
91
+ ```ts snippet:SetLogLevel
92
+ import { setLogLevel } from "@azure/logger";
116
93
 
117
94
  setLogLevel("info");
118
95
  ```
@@ -16,15 +16,19 @@ import type { IdentityPlugin } from "@azure/identity";
16
16
  *
17
17
  * Example:
18
18
  *
19
- * ```javascript
19
+ * ```ts snippet:ReadmeSampleVisualStudioCodeCredential
20
20
  * import { useIdentityPlugin, VisualStudioCodeCredential } from "@azure/identity";
21
21
  * import { vsCodePlugin } from "@azure/identity-vscode";
22
22
  *
23
- * // Load the plugin
24
23
  * useIdentityPlugin(vsCodePlugin);
25
24
  *
26
- * // Now that the plugin is loaded, this credential may be used
27
25
  * const credential = new VisualStudioCodeCredential();
26
+ *
27
+ * // The graph.microsoft.com scope is used as an example
28
+ * const scope = "https://graph.microsoft.com/.default";
29
+ *
30
+ * // Print out part of the access token
31
+ * console.log((await credential.getToken(scope)).token.substr(0, 10), "...");
28
32
  * ```
29
33
  */
30
34
  export declare const vsCodePlugin: IdentityPlugin;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AA+BtD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,YAAY,EAAE,cAM1B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AA+BtD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,YAAY,EAAE,cAM1B,CAAC"}
@@ -19,15 +19,19 @@ const VSCodeServiceName = "VS Code Azure";
19
19
  *
20
20
  * Example:
21
21
  *
22
- * ```javascript
22
+ * ```ts snippet:ReadmeSampleVisualStudioCodeCredential
23
23
  * import { useIdentityPlugin, VisualStudioCodeCredential } from "@azure/identity";
24
24
  * import { vsCodePlugin } from "@azure/identity-vscode";
25
25
  *
26
- * // Load the plugin
27
26
  * useIdentityPlugin(vsCodePlugin);
28
27
  *
29
- * // Now that the plugin is loaded, this credential may be used
30
28
  * const credential = new VisualStudioCodeCredential();
29
+ *
30
+ * // The graph.microsoft.com scope is used as an example
31
+ * const scope = "https://graph.microsoft.com/.default";
32
+ *
33
+ * // Print out part of the access token
34
+ * console.log((await credential.getToken(scope)).token.substr(0, 10), "...");
31
35
  * ```
32
36
  */
33
37
  export const vsCodePlugin = (context) => {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,MAAM,iBAAiB,GAAG,eAAe,CAAC;AA4B1C;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,CAAC,MAAM,YAAY,GAAmB,CAAC,OAAO,EAAE,EAAE;IACtD,MAAM,EAAE,uBAAuB,EAAE,GAAG,OAA6B,CAAC;IAElE,uBAAuB,CAAC,yBAAyB,CAAC,GAAG,EAAE,CACrD,MAAM,CAAC,eAAe,CAAC,iBAAiB,CAAC,CAC1C,CAAC;AACJ,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { IdentityPlugin } from \"@azure/identity\";\nimport keytar from \"keytar\";\n\nconst VSCodeServiceName = \"VS Code Azure\";\n\n/**\n * A function that searches for credentials in the Visual Studio Code credential store.\n *\n * @returns an array of credentials (username and password)\n */\ntype VSCodeCredentialFinder = () => Promise<Array<{ account: string; password: string }>>;\n\n/**\n * Plugin context entries for controlling VisualStudioCodeCredential.\n */\ninterface 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 */\ninterface AzurePluginContext {\n vsCodeCredentialControl: VisualStudioCodeCredentialControl;\n}\n\n/**\n * A plugin that provides the dependencies of `VisualStudioCodeCredential`\n * and enables it within `@azure/identity`. The plugin API is compatible with\n * `@azure/identity` versions 2.0.0 and later. Load this plugin using the\n * `useIdentityPlugin` function, imported from `@azure/identity`.\n *\n * `VisualStudioCodeCredential` uses the authentication session from the \"Azure\n * Account\" extension in VS Code.\n *\n * To use this functionality, import `VisualStudioCodeCredential` or\n * `DefaultAzureCredential` from `@azure/identity`. If this plugin is not\n * enabled, then `VisualStudioCodeCredential` will throw a\n * `CredentialUnavailableError`, and `DefaultAzureCredential` will not be able\n * to use authentication through Visual Studio Code.\n *\n * Example:\n *\n * ```javascript\n * import { useIdentityPlugin, VisualStudioCodeCredential } from \"@azure/identity\";\n * import { vsCodePlugin } from \"@azure/identity-vscode\";\n *\n * // Load the plugin\n * useIdentityPlugin(vsCodePlugin);\n *\n * // Now that the plugin is loaded, this credential may be used\n * const credential = new VisualStudioCodeCredential();\n * ```\n */\nexport const vsCodePlugin: IdentityPlugin = (context) => {\n const { vsCodeCredentialControl } = context as AzurePluginContext;\n\n vsCodeCredentialControl.setVsCodeCredentialFinder(() =>\n keytar.findCredentials(VSCodeServiceName),\n );\n};\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,MAAM,iBAAiB,GAAG,eAAe,CAAC;AA4B1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,CAAC,MAAM,YAAY,GAAmB,CAAC,OAAO,EAAE,EAAE;IACtD,MAAM,EAAE,uBAAuB,EAAE,GAAG,OAA6B,CAAC;IAElE,uBAAuB,CAAC,yBAAyB,CAAC,GAAG,EAAE,CACrD,MAAM,CAAC,eAAe,CAAC,iBAAiB,CAAC,CAC1C,CAAC;AACJ,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { IdentityPlugin } from \"@azure/identity\";\nimport keytar from \"keytar\";\n\nconst VSCodeServiceName = \"VS Code Azure\";\n\n/**\n * A function that searches for credentials in the Visual Studio Code credential store.\n *\n * @returns an array of credentials (username and password)\n */\ntype VSCodeCredentialFinder = () => Promise<Array<{ account: string; password: string }>>;\n\n/**\n * Plugin context entries for controlling VisualStudioCodeCredential.\n */\ninterface 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 */\ninterface AzurePluginContext {\n vsCodeCredentialControl: VisualStudioCodeCredentialControl;\n}\n\n/**\n * A plugin that provides the dependencies of `VisualStudioCodeCredential`\n * and enables it within `@azure/identity`. The plugin API is compatible with\n * `@azure/identity` versions 2.0.0 and later. Load this plugin using the\n * `useIdentityPlugin` function, imported from `@azure/identity`.\n *\n * `VisualStudioCodeCredential` uses the authentication session from the \"Azure\n * Account\" extension in VS Code.\n *\n * To use this functionality, import `VisualStudioCodeCredential` or\n * `DefaultAzureCredential` from `@azure/identity`. If this plugin is not\n * enabled, then `VisualStudioCodeCredential` will throw a\n * `CredentialUnavailableError`, and `DefaultAzureCredential` will not be able\n * to use authentication through Visual Studio Code.\n *\n * Example:\n *\n * ```ts snippet:ReadmeSampleVisualStudioCodeCredential\n * import { useIdentityPlugin, VisualStudioCodeCredential } from \"@azure/identity\";\n * import { vsCodePlugin } from \"@azure/identity-vscode\";\n *\n * useIdentityPlugin(vsCodePlugin);\n *\n * const credential = new VisualStudioCodeCredential();\n *\n * // The graph.microsoft.com scope is used as an example\n * const scope = \"https://graph.microsoft.com/.default\";\n *\n * // Print out part of the access token\n * console.log((await credential.getToken(scope)).token.substr(0, 10), \"...\");\n * ```\n */\nexport const vsCodePlugin: IdentityPlugin = (context) => {\n const { vsCodeCredentialControl } = context as AzurePluginContext;\n\n vsCodeCredentialControl.setVsCodeCredentialFinder(() =>\n keytar.findCredentials(VSCodeServiceName),\n );\n};\n"]}
@@ -16,15 +16,19 @@ import type { IdentityPlugin } from "@azure/identity";
16
16
  *
17
17
  * Example:
18
18
  *
19
- * ```javascript
19
+ * ```ts snippet:ReadmeSampleVisualStudioCodeCredential
20
20
  * import { useIdentityPlugin, VisualStudioCodeCredential } from "@azure/identity";
21
21
  * import { vsCodePlugin } from "@azure/identity-vscode";
22
22
  *
23
- * // Load the plugin
24
23
  * useIdentityPlugin(vsCodePlugin);
25
24
  *
26
- * // Now that the plugin is loaded, this credential may be used
27
25
  * const credential = new VisualStudioCodeCredential();
26
+ *
27
+ * // The graph.microsoft.com scope is used as an example
28
+ * const scope = "https://graph.microsoft.com/.default";
29
+ *
30
+ * // Print out part of the access token
31
+ * console.log((await credential.getToken(scope)).token.substr(0, 10), "...");
28
32
  * ```
29
33
  */
30
34
  export declare const vsCodePlugin: IdentityPlugin;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AA+BtD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,YAAY,EAAE,cAM1B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AA+BtD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,YAAY,EAAE,cAM1B,CAAC"}
@@ -23,15 +23,19 @@ const VSCodeServiceName = "VS Code Azure";
23
23
  *
24
24
  * Example:
25
25
  *
26
- * ```javascript
26
+ * ```ts snippet:ReadmeSampleVisualStudioCodeCredential
27
27
  * import { useIdentityPlugin, VisualStudioCodeCredential } from "@azure/identity";
28
28
  * import { vsCodePlugin } from "@azure/identity-vscode";
29
29
  *
30
- * // Load the plugin
31
30
  * useIdentityPlugin(vsCodePlugin);
32
31
  *
33
- * // Now that the plugin is loaded, this credential may be used
34
32
  * const credential = new VisualStudioCodeCredential();
33
+ *
34
+ * // The graph.microsoft.com scope is used as an example
35
+ * const scope = "https://graph.microsoft.com/.default";
36
+ *
37
+ * // Print out part of the access token
38
+ * console.log((await credential.getToken(scope)).token.substr(0, 10), "...");
35
39
  * ```
36
40
  */
37
41
  const vsCodePlugin = (context) => {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;AAGlC,4DAA4B;AAE5B,MAAM,iBAAiB,GAAG,eAAe,CAAC;AA4B1C;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACI,MAAM,YAAY,GAAmB,CAAC,OAAO,EAAE,EAAE;IACtD,MAAM,EAAE,uBAAuB,EAAE,GAAG,OAA6B,CAAC;IAElE,uBAAuB,CAAC,yBAAyB,CAAC,GAAG,EAAE,CACrD,gBAAM,CAAC,eAAe,CAAC,iBAAiB,CAAC,CAC1C,CAAC;AACJ,CAAC,CAAC;AANW,QAAA,YAAY,gBAMvB","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { IdentityPlugin } from \"@azure/identity\";\nimport keytar from \"keytar\";\n\nconst VSCodeServiceName = \"VS Code Azure\";\n\n/**\n * A function that searches for credentials in the Visual Studio Code credential store.\n *\n * @returns an array of credentials (username and password)\n */\ntype VSCodeCredentialFinder = () => Promise<Array<{ account: string; password: string }>>;\n\n/**\n * Plugin context entries for controlling VisualStudioCodeCredential.\n */\ninterface 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 */\ninterface AzurePluginContext {\n vsCodeCredentialControl: VisualStudioCodeCredentialControl;\n}\n\n/**\n * A plugin that provides the dependencies of `VisualStudioCodeCredential`\n * and enables it within `@azure/identity`. The plugin API is compatible with\n * `@azure/identity` versions 2.0.0 and later. Load this plugin using the\n * `useIdentityPlugin` function, imported from `@azure/identity`.\n *\n * `VisualStudioCodeCredential` uses the authentication session from the \"Azure\n * Account\" extension in VS Code.\n *\n * To use this functionality, import `VisualStudioCodeCredential` or\n * `DefaultAzureCredential` from `@azure/identity`. If this plugin is not\n * enabled, then `VisualStudioCodeCredential` will throw a\n * `CredentialUnavailableError`, and `DefaultAzureCredential` will not be able\n * to use authentication through Visual Studio Code.\n *\n * Example:\n *\n * ```javascript\n * import { useIdentityPlugin, VisualStudioCodeCredential } from \"@azure/identity\";\n * import { vsCodePlugin } from \"@azure/identity-vscode\";\n *\n * // Load the plugin\n * useIdentityPlugin(vsCodePlugin);\n *\n * // Now that the plugin is loaded, this credential may be used\n * const credential = new VisualStudioCodeCredential();\n * ```\n */\nexport const vsCodePlugin: IdentityPlugin = (context) => {\n const { vsCodeCredentialControl } = context as AzurePluginContext;\n\n vsCodeCredentialControl.setVsCodeCredentialFinder(() =>\n keytar.findCredentials(VSCodeServiceName),\n );\n};\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;AAGlC,4DAA4B;AAE5B,MAAM,iBAAiB,GAAG,eAAe,CAAC;AA4B1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACI,MAAM,YAAY,GAAmB,CAAC,OAAO,EAAE,EAAE;IACtD,MAAM,EAAE,uBAAuB,EAAE,GAAG,OAA6B,CAAC;IAElE,uBAAuB,CAAC,yBAAyB,CAAC,GAAG,EAAE,CACrD,gBAAM,CAAC,eAAe,CAAC,iBAAiB,CAAC,CAC1C,CAAC;AACJ,CAAC,CAAC;AANW,QAAA,YAAY,gBAMvB","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { IdentityPlugin } from \"@azure/identity\";\nimport keytar from \"keytar\";\n\nconst VSCodeServiceName = \"VS Code Azure\";\n\n/**\n * A function that searches for credentials in the Visual Studio Code credential store.\n *\n * @returns an array of credentials (username and password)\n */\ntype VSCodeCredentialFinder = () => Promise<Array<{ account: string; password: string }>>;\n\n/**\n * Plugin context entries for controlling VisualStudioCodeCredential.\n */\ninterface 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 */\ninterface AzurePluginContext {\n vsCodeCredentialControl: VisualStudioCodeCredentialControl;\n}\n\n/**\n * A plugin that provides the dependencies of `VisualStudioCodeCredential`\n * and enables it within `@azure/identity`. The plugin API is compatible with\n * `@azure/identity` versions 2.0.0 and later. Load this plugin using the\n * `useIdentityPlugin` function, imported from `@azure/identity`.\n *\n * `VisualStudioCodeCredential` uses the authentication session from the \"Azure\n * Account\" extension in VS Code.\n *\n * To use this functionality, import `VisualStudioCodeCredential` or\n * `DefaultAzureCredential` from `@azure/identity`. If this plugin is not\n * enabled, then `VisualStudioCodeCredential` will throw a\n * `CredentialUnavailableError`, and `DefaultAzureCredential` will not be able\n * to use authentication through Visual Studio Code.\n *\n * Example:\n *\n * ```ts snippet:ReadmeSampleVisualStudioCodeCredential\n * import { useIdentityPlugin, VisualStudioCodeCredential } from \"@azure/identity\";\n * import { vsCodePlugin } from \"@azure/identity-vscode\";\n *\n * useIdentityPlugin(vsCodePlugin);\n *\n * const credential = new VisualStudioCodeCredential();\n *\n * // The graph.microsoft.com scope is used as an example\n * const scope = \"https://graph.microsoft.com/.default\";\n *\n * // Print out part of the access token\n * console.log((await credential.getToken(scope)).token.substr(0, 10), \"...\");\n * ```\n */\nexport const vsCodePlugin: IdentityPlugin = (context) => {\n const { vsCodeCredentialControl } = context as AzurePluginContext;\n\n vsCodeCredentialControl.setVsCodeCredentialFinder(() =>\n keytar.findCredentials(VSCodeServiceName),\n );\n};\n"]}
@@ -16,15 +16,19 @@ import type { IdentityPlugin } from "@azure/identity";
16
16
  *
17
17
  * Example:
18
18
  *
19
- * ```javascript
19
+ * ```ts snippet:ReadmeSampleVisualStudioCodeCredential
20
20
  * import { useIdentityPlugin, VisualStudioCodeCredential } from "@azure/identity";
21
21
  * import { vsCodePlugin } from "@azure/identity-vscode";
22
22
  *
23
- * // Load the plugin
24
23
  * useIdentityPlugin(vsCodePlugin);
25
24
  *
26
- * // Now that the plugin is loaded, this credential may be used
27
25
  * const credential = new VisualStudioCodeCredential();
26
+ *
27
+ * // The graph.microsoft.com scope is used as an example
28
+ * const scope = "https://graph.microsoft.com/.default";
29
+ *
30
+ * // Print out part of the access token
31
+ * console.log((await credential.getToken(scope)).token.substr(0, 10), "...");
28
32
  * ```
29
33
  */
30
34
  export declare const vsCodePlugin: IdentityPlugin;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AA+BtD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,YAAY,EAAE,cAM1B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AA+BtD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,YAAY,EAAE,cAM1B,CAAC"}
package/dist/esm/index.js CHANGED
@@ -19,15 +19,19 @@ const VSCodeServiceName = "VS Code Azure";
19
19
  *
20
20
  * Example:
21
21
  *
22
- * ```javascript
22
+ * ```ts snippet:ReadmeSampleVisualStudioCodeCredential
23
23
  * import { useIdentityPlugin, VisualStudioCodeCredential } from "@azure/identity";
24
24
  * import { vsCodePlugin } from "@azure/identity-vscode";
25
25
  *
26
- * // Load the plugin
27
26
  * useIdentityPlugin(vsCodePlugin);
28
27
  *
29
- * // Now that the plugin is loaded, this credential may be used
30
28
  * const credential = new VisualStudioCodeCredential();
29
+ *
30
+ * // The graph.microsoft.com scope is used as an example
31
+ * const scope = "https://graph.microsoft.com/.default";
32
+ *
33
+ * // Print out part of the access token
34
+ * console.log((await credential.getToken(scope)).token.substr(0, 10), "...");
31
35
  * ```
32
36
  */
33
37
  export const vsCodePlugin = (context) => {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,MAAM,iBAAiB,GAAG,eAAe,CAAC;AA4B1C;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,CAAC,MAAM,YAAY,GAAmB,CAAC,OAAO,EAAE,EAAE;IACtD,MAAM,EAAE,uBAAuB,EAAE,GAAG,OAA6B,CAAC;IAElE,uBAAuB,CAAC,yBAAyB,CAAC,GAAG,EAAE,CACrD,MAAM,CAAC,eAAe,CAAC,iBAAiB,CAAC,CAC1C,CAAC;AACJ,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { IdentityPlugin } from \"@azure/identity\";\nimport keytar from \"keytar\";\n\nconst VSCodeServiceName = \"VS Code Azure\";\n\n/**\n * A function that searches for credentials in the Visual Studio Code credential store.\n *\n * @returns an array of credentials (username and password)\n */\ntype VSCodeCredentialFinder = () => Promise<Array<{ account: string; password: string }>>;\n\n/**\n * Plugin context entries for controlling VisualStudioCodeCredential.\n */\ninterface 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 */\ninterface AzurePluginContext {\n vsCodeCredentialControl: VisualStudioCodeCredentialControl;\n}\n\n/**\n * A plugin that provides the dependencies of `VisualStudioCodeCredential`\n * and enables it within `@azure/identity`. The plugin API is compatible with\n * `@azure/identity` versions 2.0.0 and later. Load this plugin using the\n * `useIdentityPlugin` function, imported from `@azure/identity`.\n *\n * `VisualStudioCodeCredential` uses the authentication session from the \"Azure\n * Account\" extension in VS Code.\n *\n * To use this functionality, import `VisualStudioCodeCredential` or\n * `DefaultAzureCredential` from `@azure/identity`. If this plugin is not\n * enabled, then `VisualStudioCodeCredential` will throw a\n * `CredentialUnavailableError`, and `DefaultAzureCredential` will not be able\n * to use authentication through Visual Studio Code.\n *\n * Example:\n *\n * ```javascript\n * import { useIdentityPlugin, VisualStudioCodeCredential } from \"@azure/identity\";\n * import { vsCodePlugin } from \"@azure/identity-vscode\";\n *\n * // Load the plugin\n * useIdentityPlugin(vsCodePlugin);\n *\n * // Now that the plugin is loaded, this credential may be used\n * const credential = new VisualStudioCodeCredential();\n * ```\n */\nexport const vsCodePlugin: IdentityPlugin = (context) => {\n const { vsCodeCredentialControl } = context as AzurePluginContext;\n\n vsCodeCredentialControl.setVsCodeCredentialFinder(() =>\n keytar.findCredentials(VSCodeServiceName),\n );\n};\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,MAAM,iBAAiB,GAAG,eAAe,CAAC;AA4B1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,CAAC,MAAM,YAAY,GAAmB,CAAC,OAAO,EAAE,EAAE;IACtD,MAAM,EAAE,uBAAuB,EAAE,GAAG,OAA6B,CAAC;IAElE,uBAAuB,CAAC,yBAAyB,CAAC,GAAG,EAAE,CACrD,MAAM,CAAC,eAAe,CAAC,iBAAiB,CAAC,CAC1C,CAAC;AACJ,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { IdentityPlugin } from \"@azure/identity\";\nimport keytar from \"keytar\";\n\nconst VSCodeServiceName = \"VS Code Azure\";\n\n/**\n * A function that searches for credentials in the Visual Studio Code credential store.\n *\n * @returns an array of credentials (username and password)\n */\ntype VSCodeCredentialFinder = () => Promise<Array<{ account: string; password: string }>>;\n\n/**\n * Plugin context entries for controlling VisualStudioCodeCredential.\n */\ninterface 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 */\ninterface AzurePluginContext {\n vsCodeCredentialControl: VisualStudioCodeCredentialControl;\n}\n\n/**\n * A plugin that provides the dependencies of `VisualStudioCodeCredential`\n * and enables it within `@azure/identity`. The plugin API is compatible with\n * `@azure/identity` versions 2.0.0 and later. Load this plugin using the\n * `useIdentityPlugin` function, imported from `@azure/identity`.\n *\n * `VisualStudioCodeCredential` uses the authentication session from the \"Azure\n * Account\" extension in VS Code.\n *\n * To use this functionality, import `VisualStudioCodeCredential` or\n * `DefaultAzureCredential` from `@azure/identity`. If this plugin is not\n * enabled, then `VisualStudioCodeCredential` will throw a\n * `CredentialUnavailableError`, and `DefaultAzureCredential` will not be able\n * to use authentication through Visual Studio Code.\n *\n * Example:\n *\n * ```ts snippet:ReadmeSampleVisualStudioCodeCredential\n * import { useIdentityPlugin, VisualStudioCodeCredential } from \"@azure/identity\";\n * import { vsCodePlugin } from \"@azure/identity-vscode\";\n *\n * useIdentityPlugin(vsCodePlugin);\n *\n * const credential = new VisualStudioCodeCredential();\n *\n * // The graph.microsoft.com scope is used as an example\n * const scope = \"https://graph.microsoft.com/.default\";\n *\n * // Print out part of the access token\n * console.log((await credential.getToken(scope)).token.substr(0, 10), \"...\");\n * ```\n */\nexport const vsCodePlugin: IdentityPlugin = (context) => {\n const { vsCodeCredentialControl } = context as AzurePluginContext;\n\n vsCodeCredentialControl.setVsCodeCredentialFinder(() =>\n keytar.findCredentials(VSCodeServiceName),\n );\n};\n"]}
@@ -16,15 +16,19 @@ import type { IdentityPlugin } from "@azure/identity";
16
16
  *
17
17
  * Example:
18
18
  *
19
- * ```javascript
19
+ * ```ts snippet:ReadmeSampleVisualStudioCodeCredential
20
20
  * import { useIdentityPlugin, VisualStudioCodeCredential } from "@azure/identity";
21
21
  * import { vsCodePlugin } from "@azure/identity-vscode";
22
22
  *
23
- * // Load the plugin
24
23
  * useIdentityPlugin(vsCodePlugin);
25
24
  *
26
- * // Now that the plugin is loaded, this credential may be used
27
25
  * const credential = new VisualStudioCodeCredential();
26
+ *
27
+ * // The graph.microsoft.com scope is used as an example
28
+ * const scope = "https://graph.microsoft.com/.default";
29
+ *
30
+ * // Print out part of the access token
31
+ * console.log((await credential.getToken(scope)).token.substr(0, 10), "...");
28
32
  * ```
29
33
  */
30
34
  export declare const vsCodePlugin: IdentityPlugin;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AA+BtD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,YAAY,EAAE,cAM1B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AA+BtD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,YAAY,EAAE,cAM1B,CAAC"}
@@ -19,15 +19,19 @@ const VSCodeServiceName = "VS Code Azure";
19
19
  *
20
20
  * Example:
21
21
  *
22
- * ```javascript
22
+ * ```ts snippet:ReadmeSampleVisualStudioCodeCredential
23
23
  * import { useIdentityPlugin, VisualStudioCodeCredential } from "@azure/identity";
24
24
  * import { vsCodePlugin } from "@azure/identity-vscode";
25
25
  *
26
- * // Load the plugin
27
26
  * useIdentityPlugin(vsCodePlugin);
28
27
  *
29
- * // Now that the plugin is loaded, this credential may be used
30
28
  * const credential = new VisualStudioCodeCredential();
29
+ *
30
+ * // The graph.microsoft.com scope is used as an example
31
+ * const scope = "https://graph.microsoft.com/.default";
32
+ *
33
+ * // Print out part of the access token
34
+ * console.log((await credential.getToken(scope)).token.substr(0, 10), "...");
31
35
  * ```
32
36
  */
33
37
  export const vsCodePlugin = (context) => {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,MAAM,iBAAiB,GAAG,eAAe,CAAC;AA4B1C;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,CAAC,MAAM,YAAY,GAAmB,CAAC,OAAO,EAAE,EAAE;IACtD,MAAM,EAAE,uBAAuB,EAAE,GAAG,OAA6B,CAAC;IAElE,uBAAuB,CAAC,yBAAyB,CAAC,GAAG,EAAE,CACrD,MAAM,CAAC,eAAe,CAAC,iBAAiB,CAAC,CAC1C,CAAC;AACJ,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { IdentityPlugin } from \"@azure/identity\";\nimport keytar from \"keytar\";\n\nconst VSCodeServiceName = \"VS Code Azure\";\n\n/**\n * A function that searches for credentials in the Visual Studio Code credential store.\n *\n * @returns an array of credentials (username and password)\n */\ntype VSCodeCredentialFinder = () => Promise<Array<{ account: string; password: string }>>;\n\n/**\n * Plugin context entries for controlling VisualStudioCodeCredential.\n */\ninterface 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 */\ninterface AzurePluginContext {\n vsCodeCredentialControl: VisualStudioCodeCredentialControl;\n}\n\n/**\n * A plugin that provides the dependencies of `VisualStudioCodeCredential`\n * and enables it within `@azure/identity`. The plugin API is compatible with\n * `@azure/identity` versions 2.0.0 and later. Load this plugin using the\n * `useIdentityPlugin` function, imported from `@azure/identity`.\n *\n * `VisualStudioCodeCredential` uses the authentication session from the \"Azure\n * Account\" extension in VS Code.\n *\n * To use this functionality, import `VisualStudioCodeCredential` or\n * `DefaultAzureCredential` from `@azure/identity`. If this plugin is not\n * enabled, then `VisualStudioCodeCredential` will throw a\n * `CredentialUnavailableError`, and `DefaultAzureCredential` will not be able\n * to use authentication through Visual Studio Code.\n *\n * Example:\n *\n * ```javascript\n * import { useIdentityPlugin, VisualStudioCodeCredential } from \"@azure/identity\";\n * import { vsCodePlugin } from \"@azure/identity-vscode\";\n *\n * // Load the plugin\n * useIdentityPlugin(vsCodePlugin);\n *\n * // Now that the plugin is loaded, this credential may be used\n * const credential = new VisualStudioCodeCredential();\n * ```\n */\nexport const vsCodePlugin: IdentityPlugin = (context) => {\n const { vsCodeCredentialControl } = context as AzurePluginContext;\n\n vsCodeCredentialControl.setVsCodeCredentialFinder(() =>\n keytar.findCredentials(VSCodeServiceName),\n );\n};\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,MAAM,iBAAiB,GAAG,eAAe,CAAC;AA4B1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,CAAC,MAAM,YAAY,GAAmB,CAAC,OAAO,EAAE,EAAE;IACtD,MAAM,EAAE,uBAAuB,EAAE,GAAG,OAA6B,CAAC;IAElE,uBAAuB,CAAC,yBAAyB,CAAC,GAAG,EAAE,CACrD,MAAM,CAAC,eAAe,CAAC,iBAAiB,CAAC,CAC1C,CAAC;AACJ,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { IdentityPlugin } from \"@azure/identity\";\nimport keytar from \"keytar\";\n\nconst VSCodeServiceName = \"VS Code Azure\";\n\n/**\n * A function that searches for credentials in the Visual Studio Code credential store.\n *\n * @returns an array of credentials (username and password)\n */\ntype VSCodeCredentialFinder = () => Promise<Array<{ account: string; password: string }>>;\n\n/**\n * Plugin context entries for controlling VisualStudioCodeCredential.\n */\ninterface 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 */\ninterface AzurePluginContext {\n vsCodeCredentialControl: VisualStudioCodeCredentialControl;\n}\n\n/**\n * A plugin that provides the dependencies of `VisualStudioCodeCredential`\n * and enables it within `@azure/identity`. The plugin API is compatible with\n * `@azure/identity` versions 2.0.0 and later. Load this plugin using the\n * `useIdentityPlugin` function, imported from `@azure/identity`.\n *\n * `VisualStudioCodeCredential` uses the authentication session from the \"Azure\n * Account\" extension in VS Code.\n *\n * To use this functionality, import `VisualStudioCodeCredential` or\n * `DefaultAzureCredential` from `@azure/identity`. If this plugin is not\n * enabled, then `VisualStudioCodeCredential` will throw a\n * `CredentialUnavailableError`, and `DefaultAzureCredential` will not be able\n * to use authentication through Visual Studio Code.\n *\n * Example:\n *\n * ```ts snippet:ReadmeSampleVisualStudioCodeCredential\n * import { useIdentityPlugin, VisualStudioCodeCredential } from \"@azure/identity\";\n * import { vsCodePlugin } from \"@azure/identity-vscode\";\n *\n * useIdentityPlugin(vsCodePlugin);\n *\n * const credential = new VisualStudioCodeCredential();\n *\n * // The graph.microsoft.com scope is used as an example\n * const scope = \"https://graph.microsoft.com/.default\";\n *\n * // Print out part of the access token\n * console.log((await credential.getToken(scope)).token.substr(0, 10), \"...\");\n * ```\n */\nexport const vsCodePlugin: IdentityPlugin = (context) => {\n const { vsCodeCredentialControl } = context as AzurePluginContext;\n\n vsCodeCredentialControl.setVsCodeCredentialFinder(() =>\n keytar.findCredentials(VSCodeServiceName),\n );\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azure/identity-vscode",
3
- "version": "1.0.1-alpha.20250228.2",
3
+ "version": "1.0.1-alpha.20250303.2",
4
4
  "sdk-type": "client",
5
5
  "description": "Use the Azure Account extension for Visual Studio Code to authenticate with Azure Identity",
6
6
  "main": "./dist/commonjs/index.js",
@@ -27,7 +27,7 @@
27
27
  "unit-test": "npm run unit-test:node && npm run unit-test:browser",
28
28
  "unit-test:browser": "echo skipped",
29
29
  "unit-test:node": "echo skipped",
30
- "update-snippets": "echo skipped"
30
+ "update-snippets": "dev-tool run update-snippets"
31
31
  },
32
32
  "files": [
33
33
  "dist/",
@@ -66,16 +66,19 @@
66
66
  "@azure/core-client": "^1.7.0",
67
67
  "@azure/dev-tool": ">=1.0.0-alpha <1.0.0-alphb",
68
68
  "@azure/eslint-plugin-azure-sdk": ">=3.0.0-alpha <3.0.0-alphb",
69
+ "@azure/logger": "^1.1.4",
69
70
  "@types/node": "^18.0.0",
70
- "@vitest/coverage-istanbul": "^3.0.3",
71
+ "@vitest/browser": "^3.0.6",
72
+ "@vitest/coverage-istanbul": "^3.0.6",
71
73
  "dotenv": "^16.0.0",
72
74
  "eslint": "^9.9.0",
73
- "playwright": "^1.49.0",
75
+ "playwright": "^1.50.1",
74
76
  "typescript": "~5.7.2",
75
- "vitest": "^3.0.3"
77
+ "vitest": "^3.0.6"
76
78
  },
77
79
  "type": "module",
78
80
  "tshy": {
81
+ "project": "./tsconfig.src.json",
79
82
  "exports": {
80
83
  "./package.json": "./package.json",
81
84
  ".": "./src/index.ts"
@@ -88,8 +91,7 @@
88
91
  "browser",
89
92
  "react-native"
90
93
  ],
91
- "selfLink": false,
92
- "project": "./tsconfig.src.json"
94
+ "selfLink": false
93
95
  },
94
96
  "browser": "./dist/browser/index.js",
95
97
  "exports": {
@@ -112,5 +114,6 @@
112
114
  "default": "./dist/commonjs/index.js"
113
115
  }
114
116
  }
115
- }
117
+ },
118
+ "react-native": "./dist/react-native/index.js"
116
119
  }