@microsoft/vscode-azext-azureauth 2.1.0 → 2.4.0

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/CHANGELOG.md CHANGED
@@ -1,34 +1,34 @@
1
- # Change Log
2
-
3
- ## 1.4.0 - 2023-11-03
4
- * [#1619](https://github.com/microsoft/vscode-azuretools/pull/1619) Make `getSession` synchronous to fix an issue that broke app service deployments
5
-
6
- ## 1.3.0 - 2023-10-23
7
-
8
- * [#1610](https://github.com/microsoft/vscode-azuretools/pull/1610) Add `signInToTenant` command which facilitates signing in to a specific tenant.
9
- * [#1610](https://github.com/microsoft/vscode-azuretools/pull/1610) Add `getUnauthenticatedTenants` utility.
10
-
11
- ## 1.2.2 - 2023-10-19
12
-
13
- * [#1608](https://github.com/microsoft/vscode-azuretools/pull/1608) Fix appending `.default` to tenant id scope which caused sign in to fail
14
-
15
- ## 1.2.1 - 2023-09-26
16
-
17
- * [#1594](https://github.com/microsoft/vscode-azuretools/pull/1594) Fix getScopes always injecting the management scope, even if a scope for a different resource is specified
18
- * [#1597](https://github.com/microsoft/vscode-azuretools/pull/1597) Make `authentication.getSession` use scopes argument
19
-
20
- ## 1.1.3 - 2023-09-14
21
-
22
- * [#1585](https://github.com/microsoft/vscode-azuretools/pull/1585) Check if tenant is signed in before listing subscriptions
23
-
24
- ## 1.1.2 - 2023-07-26
25
-
26
- * [#1542](https://github.com/microsoft/vscode-azuretools/pull/1542) Fix Azure subscriptions are not returned in alphabetical order
27
-
28
- ## 1.1.1 - 2023-07-26
29
-
30
- * [#1540](https://github.com/microsoft/vscode-azuretools/pull/1540) Ignore .default if it is passed as a scope
31
-
32
- ## 1.0.0 - 2023-06-05
33
-
34
- Initial release
1
+ # Change Log
2
+
3
+ ## 1.4.0 - 2023-11-03
4
+ * [#1619](https://github.com/microsoft/vscode-azuretools/pull/1619) Make `getSession` synchronous to fix an issue that broke app service deployments
5
+
6
+ ## 1.3.0 - 2023-10-23
7
+
8
+ * [#1610](https://github.com/microsoft/vscode-azuretools/pull/1610) Add `signInToTenant` command which facilitates signing in to a specific tenant.
9
+ * [#1610](https://github.com/microsoft/vscode-azuretools/pull/1610) Add `getUnauthenticatedTenants` utility.
10
+
11
+ ## 1.2.2 - 2023-10-19
12
+
13
+ * [#1608](https://github.com/microsoft/vscode-azuretools/pull/1608) Fix appending `.default` to tenant id scope which caused sign in to fail
14
+
15
+ ## 1.2.1 - 2023-09-26
16
+
17
+ * [#1594](https://github.com/microsoft/vscode-azuretools/pull/1594) Fix getScopes always injecting the management scope, even if a scope for a different resource is specified
18
+ * [#1597](https://github.com/microsoft/vscode-azuretools/pull/1597) Make `authentication.getSession` use scopes argument
19
+
20
+ ## 1.1.3 - 2023-09-14
21
+
22
+ * [#1585](https://github.com/microsoft/vscode-azuretools/pull/1585) Check if tenant is signed in before listing subscriptions
23
+
24
+ ## 1.1.2 - 2023-07-26
25
+
26
+ * [#1542](https://github.com/microsoft/vscode-azuretools/pull/1542) Fix Azure subscriptions are not returned in alphabetical order
27
+
28
+ ## 1.1.1 - 2023-07-26
29
+
30
+ * [#1540](https://github.com/microsoft/vscode-azuretools/pull/1540) Ignore .default if it is passed as a scope
31
+
32
+ ## 1.0.0 - 2023-06-05
33
+
34
+ Initial release
package/LICENSE.md CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) Microsoft Corporation. All rights reserved.
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE
1
+ MIT License
2
+
3
+ Copyright (c) Microsoft Corporation. All rights reserved.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE
package/README.md CHANGED
@@ -1,111 +1,111 @@
1
- # VSCode Azure SDK for Node.js - Azure Auth
2
-
3
- [![Build Status](https://dev.azure.com/ms-azuretools/AzCode/_apis/build/status/vscode-azuretools)](https://dev.azure.com/ms-azuretools/AzCode/_build/latest?definitionId=17)
4
-
5
- This package provides a simple way to authenticate to Azure and receive Azure subscription information. It uses the [built-in Microsoft Authentication extension](https://github.com/microsoft/vscode/tree/main/extensions/microsoft-authentication) and does not rely on the [Azure Account extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.azure-account) in any way.
6
-
7
- ## Azure Subscription Provider
8
-
9
- The `AzureSubscriptionProvider` interface describes the functions of this package.
10
-
11
- ```typescript
12
- /**
13
- * An interface for obtaining Azure subscription information
14
- */
15
- export interface AzureSubscriptionProvider {
16
- /**
17
- * Gets a list of tenants available to the user.
18
- * Use {@link isSignedIn} to check if the user is signed in to a particular tenant.
19
- *
20
- * @returns A list of tenants.
21
- */
22
- getTenants(): Promise<TenantIdDescription[]>;
23
-
24
- /**
25
- * Gets a list of Azure subscriptions available to the user.
26
- *
27
- * @param filter - Whether to filter the list returned, according to the list returned
28
- * by `getTenantFilters()` and `getSubscriptionFilters()`. Optional, default true.
29
- *
30
- * @returns A list of Azure subscriptions.
31
- *
32
- * @throws A {@link NotSignedInError} If the user is not signed in to Azure.
33
- * Use {@link isSignedIn} and/or {@link signIn} before this method to ensure
34
- * the user is signed in.
35
- */
36
- getSubscriptions(filter: boolean): Promise<AzureSubscription[]>;
37
-
38
- /**
39
- * Checks to see if a user is signed in.
40
- *
41
- * @param tenantId (Optional) Provide to check if a user is signed in to a specific tenant.
42
- *
43
- * @returns True if the user is signed in, false otherwise.
44
- */
45
- isSignedIn(tenantId?: string): Promise<boolean>;
46
-
47
- /**
48
- * Asks the user to sign in or pick an account to use.
49
- *
50
- * @param tenantId (Optional) Provide to sign in to a specific tenant.
51
- *
52
- * @returns True if the user is signed in, false otherwise.
53
- */
54
- signIn(tenantId?: string): Promise<boolean>;
55
-
56
- /**
57
- * An event that is fired when the user signs in. Debounced to fire at most once every 5 seconds.
58
- */
59
- onDidSignIn: vscode.Event<void>;
60
-
61
- /**
62
- * Signs the user out
63
- *
64
- * @deprecated Not currently supported by VS Code auth providers
65
- *
66
- * @throws Throws an {@link Error} every time
67
- */
68
- signOut(): Promise<void>;
69
-
70
- /**
71
- * An event that is fired when the user signs out. Debounced to fire at most once every 5 seconds.
72
- */
73
- onDidSignOut: vscode.Event<void>;
74
- }
75
- ```
76
-
77
- If the caller calls `getSubscriptions()` when the user is not signed in, a `NotSignedInError` will be thrown. You can check to see if a caught error is an instance of this error with `isNotSignedInError()`.
78
-
79
- ## Azure Cloud Configuration
80
- Two methods are available for controlling the VSCode settings that determine what cloud is connected to when enumerating subscriptions.
81
-
82
- ```typescript
83
- /**
84
- * Gets the configured Azure environment.
85
- *
86
- * @returns The configured Azure environment from the `microsoft-sovereign-cloud.endpoint` setting.
87
- */
88
- export declare function getConfiguredAzureEnv(): azureEnv.Environment & {
89
- isCustomCloud: boolean;
90
- };
91
-
92
- /**
93
- * Sets the configured Azure cloud.
94
- *
95
- * @param cloud Use `'AzureCloud'` for public Azure cloud, `'AzureChinaCloud'` for Azure China, or `'AzureUSGovernment'` for Azure US Government.
96
- * These are the same values as the cloud names in `@azure/ms-rest-azure-env`. For a custom cloud, use an instance of the `@azure/ms-rest-azure-env` `EnvironmentParameters`.
97
- *
98
- * @param target (Optional) The configuration target to use, by default {@link vscode.ConfigurationTarget.Global}.
99
- */
100
- export declare function setConfiguredAzureEnv(cloud: string | azureEnv.EnvironmentParameters, target?: vscode.ConfigurationTarget): Promise<void>;
101
- ```
102
-
103
- ## Logs
104
-
105
- View the Microsoft Authentication extension logs by running the `Developer: Show Logs...` command from the VS Code command palette.
106
-
107
- Change the log level by running the `Developer: Set Log Level...` command from the VS Code command palette. Select `Microsoft Authentication` from the list of loggers and then select the desired log level.
108
-
109
- ## License
110
-
111
- [MIT](LICENSE.md)
1
+ # VSCode Azure SDK for Node.js - Azure Auth
2
+
3
+ [![Build Status](https://dev.azure.com/ms-azuretools/AzCode/_apis/build/status/vscode-azuretools)](https://dev.azure.com/ms-azuretools/AzCode/_build/latest?definitionId=17)
4
+
5
+ This package provides a simple way to authenticate to Azure and receive Azure subscription information. It uses the [built-in Microsoft Authentication extension](https://github.com/microsoft/vscode/tree/main/extensions/microsoft-authentication) and does not rely on the [Azure Account extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.azure-account) in any way.
6
+
7
+ ## Azure Subscription Provider
8
+
9
+ The `AzureSubscriptionProvider` interface describes the functions of this package.
10
+
11
+ ```typescript
12
+ /**
13
+ * An interface for obtaining Azure subscription information
14
+ */
15
+ export interface AzureSubscriptionProvider {
16
+ /**
17
+ * Gets a list of tenants available to the user.
18
+ * Use {@link isSignedIn} to check if the user is signed in to a particular tenant.
19
+ *
20
+ * @returns A list of tenants.
21
+ */
22
+ getTenants(): Promise<TenantIdDescription[]>;
23
+
24
+ /**
25
+ * Gets a list of Azure subscriptions available to the user.
26
+ *
27
+ * @param filter - Whether to filter the list returned, according to the list returned
28
+ * by `getTenantFilters()` and `getSubscriptionFilters()`. Optional, default true.
29
+ *
30
+ * @returns A list of Azure subscriptions.
31
+ *
32
+ * @throws A {@link NotSignedInError} If the user is not signed in to Azure.
33
+ * Use {@link isSignedIn} and/or {@link signIn} before this method to ensure
34
+ * the user is signed in.
35
+ */
36
+ getSubscriptions(filter: boolean): Promise<AzureSubscription[]>;
37
+
38
+ /**
39
+ * Checks to see if a user is signed in.
40
+ *
41
+ * @param tenantId (Optional) Provide to check if a user is signed in to a specific tenant.
42
+ *
43
+ * @returns True if the user is signed in, false otherwise.
44
+ */
45
+ isSignedIn(tenantId?: string): Promise<boolean>;
46
+
47
+ /**
48
+ * Asks the user to sign in or pick an account to use.
49
+ *
50
+ * @param tenantId (Optional) Provide to sign in to a specific tenant.
51
+ *
52
+ * @returns True if the user is signed in, false otherwise.
53
+ */
54
+ signIn(tenantId?: string): Promise<boolean>;
55
+
56
+ /**
57
+ * An event that is fired when the user signs in. Debounced to fire at most once every 5 seconds.
58
+ */
59
+ onDidSignIn: vscode.Event<void>;
60
+
61
+ /**
62
+ * Signs the user out
63
+ *
64
+ * @deprecated Not currently supported by VS Code auth providers
65
+ *
66
+ * @throws Throws an {@link Error} every time
67
+ */
68
+ signOut(): Promise<void>;
69
+
70
+ /**
71
+ * An event that is fired when the user signs out. Debounced to fire at most once every 5 seconds.
72
+ */
73
+ onDidSignOut: vscode.Event<void>;
74
+ }
75
+ ```
76
+
77
+ If the caller calls `getSubscriptions()` when the user is not signed in, a `NotSignedInError` will be thrown. You can check to see if a caught error is an instance of this error with `isNotSignedInError()`.
78
+
79
+ ## Azure Cloud Configuration
80
+ Two methods are available for controlling the VSCode settings that determine what cloud is connected to when enumerating subscriptions.
81
+
82
+ ```typescript
83
+ /**
84
+ * Gets the configured Azure environment.
85
+ *
86
+ * @returns The configured Azure environment from the `microsoft-sovereign-cloud.endpoint` setting.
87
+ */
88
+ export declare function getConfiguredAzureEnv(): azureEnv.Environment & {
89
+ isCustomCloud: boolean;
90
+ };
91
+
92
+ /**
93
+ * Sets the configured Azure cloud.
94
+ *
95
+ * @param cloud Use `'AzureCloud'` for public Azure cloud, `'AzureChinaCloud'` for Azure China, or `'AzureUSGovernment'` for Azure US Government.
96
+ * These are the same values as the cloud names in `@azure/ms-rest-azure-env`. For a custom cloud, use an instance of the `@azure/ms-rest-azure-env` `EnvironmentParameters`.
97
+ *
98
+ * @param target (Optional) The configuration target to use, by default {@link vscode.ConfigurationTarget.Global}.
99
+ */
100
+ export declare function setConfiguredAzureEnv(cloud: string | azureEnv.EnvironmentParameters, target?: vscode.ConfigurationTarget): Promise<void>;
101
+ ```
102
+
103
+ ## Logs
104
+
105
+ View the Microsoft Authentication extension logs by running the `Developer: Show Logs...` command from the VS Code command palette.
106
+
107
+ Change the log level by running the `Developer: Set Log Level...` command from the VS Code command palette. Select `Microsoft Authentication` from the list of loggers and then select the desired log level.
108
+
109
+ ## License
110
+
111
+ [MIT](LICENSE.md)
@@ -1,14 +1,14 @@
1
- import type * as vscode from 'vscode';
2
- /**
3
- * Represents a means of obtaining authentication data for an Azure subscription.
4
- */
5
- export interface AzureAuthentication {
6
- /**
7
- * Gets a VS Code authentication session for an Azure subscription.
8
- *
9
- * @param scopes - The scopes for which the authentication is needed.
10
- *
11
- * @returns A VS Code authentication session or undefined, if none could be obtained.
12
- */
13
- getSession(scopes?: string[]): vscode.ProviderResult<vscode.AuthenticationSession>;
14
- }
1
+ import type * as vscode from 'vscode';
2
+ /**
3
+ * Represents a means of obtaining authentication data for an Azure subscription.
4
+ */
5
+ export interface AzureAuthentication {
6
+ /**
7
+ * Gets a VS Code authentication session for an Azure subscription.
8
+ *
9
+ * @param scopes - The scopes for which the authentication is needed.
10
+ *
11
+ * @returns A VS Code authentication session or undefined, if none could be obtained.
12
+ */
13
+ getSession(scopes?: string[]): vscode.ProviderResult<vscode.AuthenticationSession>;
14
+ }
@@ -1,7 +1,7 @@
1
- "use strict";
2
- /*---------------------------------------------------------------------------------------------
3
- * Copyright (c) Microsoft Corporation. All rights reserved.
4
- * Licensed under the MIT License. See License.txt in the project root for license information.
5
- *--------------------------------------------------------------------------------------------*/
6
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Microsoft Corporation. All rights reserved.
4
+ * Licensed under the MIT License. See License.txt in the project root for license information.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
7
  //# sourceMappingURL=AzureAuthentication.js.map
@@ -0,0 +1,52 @@
1
+ import type { TenantIdDescription } from '@azure/arm-resources-subscriptions';
2
+ import { Event } from 'vscode';
3
+ import { AzureSubscription } from './AzureSubscription';
4
+ import { AzureSubscriptionProvider } from './AzureSubscriptionProvider';
5
+ export declare function createAzureDevOpsSubscriptionProviderFactory(): () => Promise<AzureDevOpsSubscriptionProvider>;
6
+ /**
7
+ * AzureSubscriptionProvider implemented to authenticate via federated DevOps service connection, using workflow identity federation
8
+ * To learn how to configure your DevOps environment to use this provider, refer to the README.md
9
+ * NOTE: This provider is only available when running in an Azure DevOps pipeline
10
+ * Reference: https://learn.microsoft.com/en-us/entra/workload-id/workload-identity-federation
11
+ */
12
+ export declare class AzureDevOpsSubscriptionProvider implements AzureSubscriptionProvider {
13
+ private _tokenCredential;
14
+ /**
15
+ * The resource ID of the Azure DevOps federated service connection,
16
+ * which can be found on the `resourceId` field of the URL at the address bar
17
+ * when viewing the service connection in the Azure DevOps portal
18
+ */
19
+ private _SERVICE_CONNECTION_ID;
20
+ /**
21
+ * The `Tenant ID` field of the service connection properties
22
+ */
23
+ private _DOMAIN;
24
+ /**
25
+ * The `Service Principal Id` field of the service connection properties
26
+ */
27
+ private _CLIENT_ID;
28
+ constructor();
29
+ getSubscriptions(_filter: boolean): Promise<AzureSubscription[]>;
30
+ isSignedIn(): Promise<boolean>;
31
+ signIn(): Promise<boolean>;
32
+ signOut(): Promise<void>;
33
+ getTenants(): Promise<TenantIdDescription[]>;
34
+ /**
35
+ * Gets the subscriptions for a given tenant.
36
+ *
37
+ * @param tenantId The tenant ID to get subscriptions for.
38
+ *
39
+ * @returns The list of subscriptions for the tenant.
40
+ */
41
+ private getSubscriptionsForTenant;
42
+ /**
43
+ * Gets a fully-configured subscription client for a given tenant ID
44
+ *
45
+ * @param tenantId (Optional) The tenant ID to get a client for
46
+ *
47
+ * @returns A client, the credential used by the client, and the authentication function
48
+ */
49
+ private getSubscriptionClient;
50
+ onDidSignIn: Event<void>;
51
+ onDidSignOut: Event<void>;
52
+ }