@microsoft/vscode-azext-azureauth 4.0.2 → 4.1.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.
@@ -1,63 +1,82 @@
1
- import type * as vscode from 'vscode';
2
- import type { AzureSubscription } from './AzureSubscription';
3
- import type { AzureTenant } from './AzureTenant';
4
- /**
5
- * An interface for obtaining Azure subscription information
6
- */
7
- export interface AzureSubscriptionProvider {
8
- /**
9
- * Gets a list of tenants available to the user.
10
- * Use {@link isSignedIn} to check if the user is signed in to a particular tenant.
11
- *
12
- * @param account - Optionally pass in a specific account to get tenants for.
13
- *
14
- * @returns A list of tenants.
15
- */
16
- getTenants(account?: vscode.AuthenticationSessionAccountInformation): Promise<AzureTenant[]>;
17
- /**
18
- * Gets a list of Azure subscriptions available to the user.
19
- *
20
- * @param filter - Whether to filter the list returned, according to the list returned
21
- * by `getTenantFilters()` and `getSubscriptionFilters()`. Optional, default true.
22
- *
23
- * @returns A list of Azure subscriptions.
24
- *
25
- * @throws A {@link NotSignedInError} If the user is not signed in to Azure.
26
- * Use {@link isSignedIn} and/or {@link signIn} before this method to ensure
27
- * the user is signed in.
28
- */
29
- getSubscriptions(filter: boolean): Promise<AzureSubscription[]>;
30
- /**
31
- * Checks to see if a user is signed in.
32
- *
33
- * @param tenantId (Optional) Provide to check if a user is signed in to a specific tenant.
34
- *
35
- * @returns True if the user is signed in, false otherwise.
36
- */
37
- isSignedIn(tenantId?: string, account?: vscode.AuthenticationSessionAccountInformation): Promise<boolean>;
38
- /**
39
- * Asks the user to sign in or pick an account to use.
40
- *
41
- * @param tenantId (Optional) Provide to sign in to a specific tenant.
42
- * @param account (Optional) Provide to sign in to a specific account.
43
- *
44
- * @returns True if the user is signed in, false otherwise.
45
- */
46
- signIn(tenantId?: string, account?: vscode.AuthenticationSessionAccountInformation): Promise<boolean>;
47
- /**
48
- * An event that is fired when the user signs in. Debounced to fire at most once every 5 seconds.
49
- */
50
- onDidSignIn: vscode.Event<void>;
51
- /**
52
- * Signs the user out
53
- *
54
- * @deprecated Not currently supported by VS Code auth providers
55
- *
56
- * @throws Throws an {@link Error} every time
57
- */
58
- signOut(): Promise<void>;
59
- /**
60
- * An event that is fired when the user signs out. Debounced to fire at most once every 5 seconds.
61
- */
62
- onDidSignOut: vscode.Event<void>;
63
- }
1
+ import type * as vscode from 'vscode';
2
+ import type { AzureSubscription } from './AzureSubscription';
3
+ import type { AzureTenant } from './AzureTenant';
4
+ /**
5
+ * A filter for {@link AzureSubscriptionProvider.getSubscriptions}
6
+ */
7
+ export type GetSubscriptionsFilter = {
8
+ /**
9
+ * The account to get subscriptions for. If not provided, all accounts the extension
10
+ * currently has access to are used.
11
+ */
12
+ account?: vscode.AuthenticationSessionAccountInformation;
13
+ /**
14
+ * The tenant to get subscriptions for. If not provided, all tenants for each account
15
+ * are used.
16
+ */
17
+ tenantId?: string;
18
+ };
19
+ /**
20
+ * An interface for obtaining Azure subscription information
21
+ */
22
+ export interface AzureSubscriptionProvider {
23
+ /**
24
+ * Gets a list of tenants available to the user.
25
+ * Use {@link isSignedIn} to check if the user is signed in to a particular tenant.
26
+ *
27
+ * @param account - Optionally pass in a specific account to get tenants for.
28
+ *
29
+ * @returns A list of tenants.
30
+ */
31
+ getTenants(account?: vscode.AuthenticationSessionAccountInformation): Promise<AzureTenant[]>;
32
+ /**
33
+ * Gets a list of Azure subscriptions available to the user.
34
+ *
35
+ * @param filter - Whether to filter the list returned. When:
36
+ * - `true`: according to the list returned by `getTenantFilters()` and `getSubscriptionFilters()`.
37
+ * - `false`: return all subscriptions.
38
+ * - `GetSubscriptionsFilter`: according to the values in the filter.
39
+ *
40
+ * Optional, default true.
41
+ *
42
+ * @returns A list of Azure subscriptions.
43
+ *
44
+ * @throws A {@link NotSignedInError} If the user is not signed in to Azure.
45
+ * Use {@link isSignedIn} and/or {@link signIn} before this method to ensure
46
+ * the user is signed in.
47
+ */
48
+ getSubscriptions(filter: boolean | GetSubscriptionsFilter): Promise<AzureSubscription[]>;
49
+ /**
50
+ * Checks to see if a user is signed in.
51
+ *
52
+ * @param tenantId (Optional) Provide to check if a user is signed in to a specific tenant.
53
+ *
54
+ * @returns True if the user is signed in, false otherwise.
55
+ */
56
+ isSignedIn(tenantId?: string, account?: vscode.AuthenticationSessionAccountInformation): Promise<boolean>;
57
+ /**
58
+ * Asks the user to sign in or pick an account to use.
59
+ *
60
+ * @param tenantId (Optional) Provide to sign in to a specific tenant.
61
+ * @param account (Optional) Provide to sign in to a specific account.
62
+ *
63
+ * @returns True if the user is signed in, false otherwise.
64
+ */
65
+ signIn(tenantId?: string, account?: vscode.AuthenticationSessionAccountInformation): Promise<boolean>;
66
+ /**
67
+ * An event that is fired when the user signs in. Debounced to fire at most once every 5 seconds.
68
+ */
69
+ onDidSignIn: vscode.Event<void>;
70
+ /**
71
+ * Signs the user out
72
+ *
73
+ * @deprecated Not currently supported by VS Code auth providers
74
+ *
75
+ * @throws Throws an {@link Error} every time
76
+ */
77
+ signOut(): Promise<void>;
78
+ /**
79
+ * An event that is fired when the user signs out. Debounced to fire at most once every 5 seconds.
80
+ */
81
+ onDidSignOut: vscode.Event<void>;
82
+ }
@@ -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=AzureSubscriptionProvider.js.map
@@ -1,5 +1,5 @@
1
- import { TenantIdDescription } from "@azure/arm-resources-subscriptions";
2
- import * as vscode from 'vscode';
3
- export interface AzureTenant extends TenantIdDescription {
4
- account: vscode.AuthenticationSessionAccountInformation;
5
- }
1
+ import { TenantIdDescription } from "@azure/arm-resources-subscriptions";
2
+ import * as vscode from 'vscode';
3
+ export interface AzureTenant extends TenantIdDescription {
4
+ account: vscode.AuthenticationSessionAccountInformation;
5
+ }
@@ -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=AzureTenant.js.map
@@ -1,15 +1,15 @@
1
- /**
2
- * An error indicating the user is not signed in.
3
- */
4
- export declare class NotSignedInError extends Error {
5
- readonly isNotSignedInError = true;
6
- constructor();
7
- }
8
- /**
9
- * Tests if an object is a `NotSignedInError`. This should be used instead of `instanceof`.
10
- *
11
- * @param error The object to test
12
- *
13
- * @returns True if the object is a NotSignedInError, false otherwise
14
- */
15
- export declare function isNotSignedInError(error: unknown): error is NotSignedInError;
1
+ /**
2
+ * An error indicating the user is not signed in.
3
+ */
4
+ export declare class NotSignedInError extends Error {
5
+ readonly isNotSignedInError = true;
6
+ constructor();
7
+ }
8
+ /**
9
+ * Tests if an object is a `NotSignedInError`. This should be used instead of `instanceof`.
10
+ *
11
+ * @param error The object to test
12
+ *
13
+ * @returns True if the object is a NotSignedInError, false otherwise
14
+ */
15
+ export declare function isNotSignedInError(error: unknown): error is NotSignedInError;
@@ -1,30 +1,30 @@
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
- exports.isNotSignedInError = exports.NotSignedInError = void 0;
8
- const vscode = require("vscode");
9
- /**
10
- * An error indicating the user is not signed in.
11
- */
12
- class NotSignedInError extends Error {
13
- constructor() {
14
- super(vscode.l10n.t('You are not signed in to an Azure account. Please sign in.'));
15
- this.isNotSignedInError = true;
16
- }
17
- }
18
- exports.NotSignedInError = NotSignedInError;
19
- /**
20
- * Tests if an object is a `NotSignedInError`. This should be used instead of `instanceof`.
21
- *
22
- * @param error The object to test
23
- *
24
- * @returns True if the object is a NotSignedInError, false otherwise
25
- */
26
- function isNotSignedInError(error) {
27
- return !!error && typeof error === 'object' && error.isNotSignedInError === true;
28
- }
29
- exports.isNotSignedInError = isNotSignedInError;
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
+ exports.isNotSignedInError = exports.NotSignedInError = void 0;
8
+ const vscode = require("vscode");
9
+ /**
10
+ * An error indicating the user is not signed in.
11
+ */
12
+ class NotSignedInError extends Error {
13
+ constructor() {
14
+ super(vscode.l10n.t('You are not signed in to an Azure account. Please sign in.'));
15
+ this.isNotSignedInError = true;
16
+ }
17
+ }
18
+ exports.NotSignedInError = NotSignedInError;
19
+ /**
20
+ * Tests if an object is a `NotSignedInError`. This should be used instead of `instanceof`.
21
+ *
22
+ * @param error The object to test
23
+ *
24
+ * @returns True if the object is a NotSignedInError, false otherwise
25
+ */
26
+ function isNotSignedInError(error) {
27
+ return !!error && typeof error === 'object' && error.isNotSignedInError === true;
28
+ }
29
+ exports.isNotSignedInError = isNotSignedInError;
30
30
  //# sourceMappingURL=NotSignedInError.js.map
@@ -1,113 +1,117 @@
1
- import * as vscode from 'vscode';
2
- import { AzureSubscription, SubscriptionId, TenantId } from './AzureSubscription';
3
- import { AzureSubscriptionProvider } from './AzureSubscriptionProvider';
4
- import { AzureTenant } from './AzureTenant';
5
- /**
6
- * A class for obtaining Azure subscription information using VSCode's built-in authentication
7
- * provider.
8
- */
9
- export declare class VSCodeAzureSubscriptionProvider extends vscode.Disposable implements AzureSubscriptionProvider {
10
- private readonly logger?;
11
- private readonly onDidSignInEmitter;
12
- private lastSignInEventFired;
13
- private suppressSignInEvents;
14
- private readonly onDidSignOutEmitter;
15
- private lastSignOutEventFired;
16
- constructor(logger?: vscode.LogOutputChannel | undefined);
17
- /**
18
- * Gets a list of tenants available to the user.
19
- * Use {@link isSignedIn} to check if the user is signed in to a particular tenant.
20
- *
21
- * @param account (Optional) A specific account to get tenants for. If not provided, all accounts will be used.
22
- *
23
- * @returns A list of tenants.
24
- */
25
- getTenants(account?: vscode.AuthenticationSessionAccountInformation): Promise<AzureTenant[]>;
26
- /**
27
- * Gets a list of Azure subscriptions available to the user.
28
- *
29
- * @param filter - Whether to filter the list returned, according to the list returned
30
- * by `getTenantFilters()` and `getSubscriptionFilters()`. Optional, default true.
31
- *
32
- * @returns A list of Azure subscriptions. The list is sorted by subscription name.
33
- * The list can contain duplicate subscriptions if they come from different accounts.
34
- *
35
- * @throws A {@link NotSignedInError} If the user is not signed in to Azure.
36
- * Use {@link isSignedIn} and/or {@link signIn} before this method to ensure
37
- * the user is signed in.
38
- */
39
- getSubscriptions(filter?: boolean): Promise<AzureSubscription[]>;
40
- /**
41
- * Checks to see if a user is signed in.
42
- *
43
- * @param tenantId (Optional) Provide to check if a user is signed in to a specific tenant.
44
- * @param account (Optional) Provide to check if a user is signed in to a specific account.
45
- *
46
- * @returns True if the user is signed in, false otherwise.
47
- *
48
- * If no tenant or account is provided, then
49
- * checks all accounts for a session.
50
- */
51
- isSignedIn(tenantId?: string, account?: vscode.AuthenticationSessionAccountInformation): Promise<boolean>;
52
- /**
53
- * Asks the user to sign in or pick an account to use.
54
- *
55
- * @param tenantId (Optional) Provide to sign in to a specific tenant.
56
- * @param account (Optional) Provide to sign in to a specific account.
57
- *
58
- * @returns True if the user is signed in, false otherwise.
59
- */
60
- signIn(tenantId?: string, account?: vscode.AuthenticationSessionAccountInformation): Promise<boolean>;
61
- /**
62
- * An event that is fired when the user signs in. Debounced to fire at most once every 5 seconds.
63
- */
64
- readonly onDidSignIn: vscode.Event<void>;
65
- /**
66
- * Signs the user out
67
- *
68
- * @deprecated Not currently supported by VS Code auth providers
69
- */
70
- signOut(): Promise<void>;
71
- /**
72
- * An event that is fired when the user signs out. Debounced to fire at most once every 5 seconds.
73
- */
74
- readonly onDidSignOut: vscode.Event<void>;
75
- /**
76
- * Gets the tenant filters that are configured in `azureResourceGroups.selectedSubscriptions`. To
77
- * override the settings with a custom filter, implement a child class with `getSubscriptionFilters()`
78
- * and/or `getTenantFilters()` overridden.
79
- *
80
- * If no values are returned by `getTenantFilters()`, then all tenants will be scanned for subscriptions.
81
- *
82
- * @returns A list of tenant IDs that are configured in `azureResourceGroups.selectedSubscriptions`.
83
- */
84
- protected getTenantFilters(): Promise<TenantId[]>;
85
- /**
86
- * Gets the subscription filters that are configured in `azureResourceGroups.selectedSubscriptions`. To
87
- * override the settings with a custom filter, implement a child class with `getSubscriptionFilters()`
88
- * and/or `getTenantFilters()` overridden.
89
- *
90
- * If no values are returned by `getSubscriptionFilters()`, then all subscriptions will be returned.
91
- *
92
- * @returns A list of subscription IDs that are configured in `azureResourceGroups.selectedSubscriptions`.
93
- */
94
- protected getSubscriptionFilters(): Promise<SubscriptionId[]>;
95
- /**
96
- * Gets the subscriptions for a given tenant.
97
- *
98
- * @param tenantId The tenant ID to get subscriptions for.
99
- * @param account The account to get the subscriptions for.
100
- *
101
- * @returns The list of subscriptions for the tenant.
102
- */
103
- private getSubscriptionsForTenant;
104
- /**
105
- * Gets a fully-configured subscription client for a given tenant ID
106
- *
107
- * @param tenantId (Optional) The tenant ID to get a client for
108
- * @param account The account that you would like to get the session for
109
- *
110
- * @returns A client, the credential used by the client, and the authentication function
111
- */
112
- private getSubscriptionClient;
113
- }
1
+ import * as vscode from 'vscode';
2
+ import { AzureSubscription, SubscriptionId, TenantId } from './AzureSubscription';
3
+ import { AzureSubscriptionProvider, GetSubscriptionsFilter } from './AzureSubscriptionProvider';
4
+ import { AzureTenant } from './AzureTenant';
5
+ /**
6
+ * A class for obtaining Azure subscription information using VSCode's built-in authentication
7
+ * provider.
8
+ */
9
+ export declare class VSCodeAzureSubscriptionProvider extends vscode.Disposable implements AzureSubscriptionProvider {
10
+ private readonly logger?;
11
+ private readonly onDidSignInEmitter;
12
+ private lastSignInEventFired;
13
+ private suppressSignInEvents;
14
+ private readonly onDidSignOutEmitter;
15
+ private lastSignOutEventFired;
16
+ constructor(logger?: vscode.LogOutputChannel | undefined);
17
+ /**
18
+ * Gets a list of tenants available to the user.
19
+ * Use {@link isSignedIn} to check if the user is signed in to a particular tenant.
20
+ *
21
+ * @param account (Optional) A specific account to get tenants for. If not provided, all accounts will be used.
22
+ *
23
+ * @returns A list of tenants.
24
+ */
25
+ getTenants(account?: vscode.AuthenticationSessionAccountInformation): Promise<AzureTenant[]>;
26
+ /**
27
+ * Gets a list of Azure subscriptions available to the user.
28
+ *
29
+ * @param filter - Whether to filter the list returned. When:
30
+ * - `true`: according to the list returned by `getTenantFilters()` and `getSubscriptionFilters()`.
31
+ * - `false`: return all subscriptions.
32
+ * - `GetSubscriptionsFilter`: according to the values in the filter.
33
+ *
34
+ * Optional, default true.
35
+ *
36
+ * @returns A list of Azure subscriptions. The list is sorted by subscription name.
37
+ * The list can contain duplicate subscriptions if they come from different accounts.
38
+ *
39
+ * @throws A {@link NotSignedInError} If the user is not signed in to Azure.
40
+ * Use {@link isSignedIn} and/or {@link signIn} before this method to ensure
41
+ * the user is signed in.
42
+ */
43
+ getSubscriptions(filter?: boolean | GetSubscriptionsFilter): Promise<AzureSubscription[]>;
44
+ /**
45
+ * Checks to see if a user is signed in.
46
+ *
47
+ * @param tenantId (Optional) Provide to check if a user is signed in to a specific tenant.
48
+ * @param account (Optional) Provide to check if a user is signed in to a specific account.
49
+ *
50
+ * @returns True if the user is signed in, false otherwise.
51
+ *
52
+ * If no tenant or account is provided, then
53
+ * checks all accounts for a session.
54
+ */
55
+ isSignedIn(tenantId?: string, account?: vscode.AuthenticationSessionAccountInformation): Promise<boolean>;
56
+ /**
57
+ * Asks the user to sign in or pick an account to use.
58
+ *
59
+ * @param tenantId (Optional) Provide to sign in to a specific tenant.
60
+ * @param account (Optional) Provide to sign in to a specific account.
61
+ *
62
+ * @returns True if the user is signed in, false otherwise.
63
+ */
64
+ signIn(tenantId?: string, account?: vscode.AuthenticationSessionAccountInformation): Promise<boolean>;
65
+ /**
66
+ * An event that is fired when the user signs in. Debounced to fire at most once every 5 seconds.
67
+ */
68
+ readonly onDidSignIn: vscode.Event<void>;
69
+ /**
70
+ * Signs the user out
71
+ *
72
+ * @deprecated Not currently supported by VS Code auth providers
73
+ */
74
+ signOut(): Promise<void>;
75
+ /**
76
+ * An event that is fired when the user signs out. Debounced to fire at most once every 5 seconds.
77
+ */
78
+ readonly onDidSignOut: vscode.Event<void>;
79
+ /**
80
+ * Gets the tenant filters that are configured in `azureResourceGroups.selectedSubscriptions`. To
81
+ * override the settings with a custom filter, implement a child class with `getSubscriptionFilters()`
82
+ * and/or `getTenantFilters()` overridden.
83
+ *
84
+ * If no values are returned by `getTenantFilters()`, then all tenants will be scanned for subscriptions.
85
+ *
86
+ * @returns A list of tenant IDs that are configured in `azureResourceGroups.selectedSubscriptions`.
87
+ */
88
+ protected getTenantFilters(): Promise<TenantId[]>;
89
+ /**
90
+ * Gets the subscription filters that are configured in `azureResourceGroups.selectedSubscriptions`. To
91
+ * override the settings with a custom filter, implement a child class with `getSubscriptionFilters()`
92
+ * and/or `getTenantFilters()` overridden.
93
+ *
94
+ * If no values are returned by `getSubscriptionFilters()`, then all subscriptions will be returned.
95
+ *
96
+ * @returns A list of subscription IDs that are configured in `azureResourceGroups.selectedSubscriptions`.
97
+ */
98
+ protected getSubscriptionFilters(): Promise<SubscriptionId[]>;
99
+ /**
100
+ * Gets the subscriptions for a given tenant.
101
+ *
102
+ * @param tenantId The tenant ID to get subscriptions for.
103
+ * @param account The account to get the subscriptions for.
104
+ *
105
+ * @returns The list of subscriptions for the tenant.
106
+ */
107
+ private getSubscriptionsForTenant;
108
+ /**
109
+ * Gets a fully-configured subscription client for a given tenant ID
110
+ *
111
+ * @param tenantId (Optional) The tenant ID to get a client for
112
+ * @param account The account that you would like to get the session for
113
+ *
114
+ * @returns A client, the credential used by the client, and the authentication function
115
+ */
116
+ private getSubscriptionClient;
117
+ }