@microsoft/vscode-azext-azureauth 5.0.0 → 5.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/cjs/src/AzureDevOpsSubscriptionProvider.js +2 -3
  3. package/dist/cjs/src/VSCodeAzureSubscriptionProvider.js +100 -47
  4. package/dist/cjs/src/index.js +1 -0
  5. package/dist/cjs/src/utils/getUnauthenticatedTenants.js +4 -2
  6. package/dist/cjs/src/utils/isGetSubscriptionsFilter.js +27 -0
  7. package/dist/esm/src/AzureDevOpsSubscriptionProvider.d.ts +6 -6
  8. package/dist/esm/src/AzureDevOpsSubscriptionProvider.js +2 -3
  9. package/dist/esm/src/AzureSubscription.d.ts +2 -2
  10. package/dist/esm/src/AzureTenant.d.ts +2 -2
  11. package/dist/esm/src/VSCodeAzureSubscriptionProvider.d.ts +13 -14
  12. package/dist/esm/src/VSCodeAzureSubscriptionProvider.js +100 -47
  13. package/dist/esm/src/index.d.ts +1 -46
  14. package/dist/esm/src/index.js +1 -0
  15. package/dist/esm/src/utils/getUnauthenticatedTenants.d.ts +4 -1
  16. package/dist/esm/src/utils/getUnauthenticatedTenants.js +4 -2
  17. package/dist/esm/src/utils/isGetSubscriptionsFilter.d.ts +14 -0
  18. package/dist/esm/src/utils/isGetSubscriptionsFilter.js +23 -0
  19. package/package.json +3 -3
  20. package/dist/cjs/src/AzureAuthentication.d.ts +0 -21
  21. package/dist/cjs/src/AzureDevOpsSubscriptionProvider.d.ts +0 -68
  22. package/dist/cjs/src/AzureSubscription.d.ts +0 -49
  23. package/dist/cjs/src/AzureSubscriptionProvider.d.ts +0 -82
  24. package/dist/cjs/src/AzureTenant.d.ts +0 -5
  25. package/dist/cjs/src/NotSignedInError.d.ts +0 -15
  26. package/dist/cjs/src/VSCodeAzureSubscriptionProvider.d.ts +0 -117
  27. package/dist/cjs/src/getSessionFromVSCode.d.ts +0 -13
  28. package/dist/cjs/src/index.d.ts +0 -56
  29. package/dist/cjs/src/signInToTenant.d.ts +0 -6
  30. package/dist/cjs/src/utils/configuredAzureEnv.d.ts +0 -24
  31. package/dist/cjs/src/utils/getUnauthenticatedTenants.d.ts +0 -6
  32. package/dist/cjs/src/utils/isAuthenticationWwwAuthenticateRequest.d.ts +0 -2
@@ -3,54 +3,9 @@ export * from './AzureDevOpsSubscriptionProvider';
3
3
  export * from './AzureSubscription';
4
4
  export * from './AzureSubscriptionProvider';
5
5
  export * from './AzureTenant';
6
+ export * from './getSessionFromVSCode';
6
7
  export * from './NotSignedInError';
7
8
  export * from './signInToTenant';
8
9
  export * from './utils/configuredAzureEnv';
9
10
  export * from './utils/getUnauthenticatedTenants';
10
11
  export * from './VSCodeAzureSubscriptionProvider';
11
- declare module 'vscode' {
12
- /**
13
- * Represents parameters for creating a session based on a WWW-Authenticate header value.
14
- * This is used when an API returns a 401 with a WWW-Authenticate header indicating
15
- * that additional authentication is required. The details of which will be passed down
16
- * to the authentication provider to create a session.
17
- *
18
- * @note The authorization provider must support handling challenges and specifically
19
- * the challenges in this WWW-Authenticate value.
20
- * @note For more information on WWW-Authenticate please see https://developer.mozilla.org/docs/Web/HTTP/Reference/Headers/WWW-Authenticate
21
- */
22
- interface AuthenticationWwwAuthenticateRequest {
23
- /**
24
- * The raw WWW-Authenticate header value that triggered this challenge.
25
- * This will be parsed by the authentication provider to extract the necessary
26
- * challenge information.
27
- */
28
- readonly wwwAuthenticate: string;
29
- /**
30
- * The fallback scopes to use if no scopes are found in the WWW-Authenticate header.
31
- */
32
- readonly fallbackScopes?: readonly string[];
33
- }
34
- /**
35
- * Namespace for authentication.
36
- */
37
- namespace authentication {
38
- /**
39
- * Get an authentication session matching the desired scopes or request. Rejects if a provider with providerId is not
40
- * registered, or if the user does not consent to sharing authentication information with the extension. If there
41
- * are multiple sessions with the same scopes, the user will be shown a quickpick to select which account they would like to use.
42
- *
43
- * Built-in auth providers include:
44
- * * 'github' - For GitHub.com
45
- * * 'microsoft' For both personal & organizational Microsoft accounts
46
- * * (less common) 'github-enterprise' - for alternative GitHub hostings, GHE.com, GitHub Enterprise Server
47
- * * (less common) 'microsoft-sovereign-cloud' - for alternative Microsoft clouds
48
- *
49
- * @param providerId The id of the provider to use
50
- * @param scopeListOrRequest A scope list of permissions requested or a WWW-Authenticate request. These are dependent on the authentication provider.
51
- * @param options The {@link AuthenticationGetSessionOptions} to use
52
- * @returns A thenable that resolves to an authentication session or undefined if a silent flow was used and no session was found
53
- */
54
- function getSession(providerId: string, scopeListOrRequest: ReadonlyArray<string> | AuthenticationWwwAuthenticateRequest, options?: AuthenticationGetSessionOptions): Thenable<AuthenticationSession | undefined>;
55
- }
56
- }
@@ -7,6 +7,7 @@ export * from './AzureDevOpsSubscriptionProvider';
7
7
  export * from './AzureSubscription';
8
8
  export * from './AzureSubscriptionProvider';
9
9
  export * from './AzureTenant';
10
+ export * from './getSessionFromVSCode';
10
11
  export * from './NotSignedInError';
11
12
  export * from './signInToTenant';
12
13
  export * from './utils/configuredAzureEnv';
@@ -1,6 +1,9 @@
1
+ import type * as vscode from "vscode";
1
2
  import type { AzureSubscriptionProvider } from "../AzureSubscriptionProvider";
2
3
  import type { AzureTenant } from "../AzureTenant";
3
4
  /**
5
+ * @param subscriptionProvider The {@link AzureSubscriptionProvider} to use
6
+ * @param account (Optional) The account to get unauthenticated tenants for
4
7
  * @returns list of tenants that VS Code doesn't have sessions for
5
8
  */
6
- export declare function getUnauthenticatedTenants(subscriptionProvider: AzureSubscriptionProvider): Promise<AzureTenant[]>;
9
+ export declare function getUnauthenticatedTenants(subscriptionProvider: AzureSubscriptionProvider, account?: vscode.AuthenticationSessionAccountInformation): Promise<AzureTenant[]>;
@@ -3,10 +3,12 @@
3
3
  * Licensed under the MIT License. See License.txt in the project root for license information.
4
4
  *--------------------------------------------------------------------------------------------*/
5
5
  /**
6
+ * @param subscriptionProvider The {@link AzureSubscriptionProvider} to use
7
+ * @param account (Optional) The account to get unauthenticated tenants for
6
8
  * @returns list of tenants that VS Code doesn't have sessions for
7
9
  */
8
- export async function getUnauthenticatedTenants(subscriptionProvider) {
9
- const tenants = await subscriptionProvider.getTenants();
10
+ export async function getUnauthenticatedTenants(subscriptionProvider, account) {
11
+ const tenants = await subscriptionProvider.getTenants(account);
10
12
  const unauthenticatedTenants = [];
11
13
  for await (const tenant of tenants) {
12
14
  if (!await subscriptionProvider.isSignedIn(tenant.tenantId, tenant.account)) {
@@ -0,0 +1,14 @@
1
+ import type * as vscode from 'vscode';
2
+ import type { GetSubscriptionsFilter } from '../AzureSubscriptionProvider';
3
+ /**
4
+ * Check if an object is a {@link GetSubscriptionsFilter} with a tenantId.
5
+ */
6
+ export declare function isGetSubscriptionsTenantFilter(obj: unknown): obj is GetSubscriptionsFilter & {
7
+ tenantId: string;
8
+ };
9
+ /**
10
+ * Check if an object is a {@link GetSubscriptionsFilter} with an account.
11
+ */
12
+ export declare function isGetSubscriptionsAccountFilter(obj: unknown): obj is GetSubscriptionsFilter & {
13
+ account: vscode.AuthenticationSessionAccountInformation;
14
+ };
@@ -0,0 +1,23 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License. See License.md in the project root for license information.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ /**
6
+ * Check if an object is a {@link GetSubscriptionsFilter} with a tenantId.
7
+ */
8
+ export function isGetSubscriptionsTenantFilter(obj) {
9
+ if (typeof obj === 'object' && !!obj && 'tenantId' in obj && typeof obj.tenantId === 'string' && !!obj.tenantId) {
10
+ return true;
11
+ }
12
+ return false;
13
+ }
14
+ /**
15
+ * Check if an object is a {@link GetSubscriptionsFilter} with an account.
16
+ */
17
+ export function isGetSubscriptionsAccountFilter(obj) {
18
+ if (typeof obj === 'object' && !!obj && 'account' in obj && typeof obj.account === 'object' && !!obj.account) {
19
+ return true;
20
+ }
21
+ return false;
22
+ }
23
+ //# sourceMappingURL=isGetSubscriptionsFilter.js.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@microsoft/vscode-azext-azureauth",
3
3
  "author": "Microsoft Corporation",
4
- "version": "5.0.0",
4
+ "version": "5.1.1",
5
5
  "description": "Azure authentication helpers for Visual Studio Code",
6
6
  "tags": [
7
7
  "azure",
@@ -26,7 +26,7 @@
26
26
  "scripts": {
27
27
  "build": "npm run build:esm && npm run build:cjs",
28
28
  "build:esm": "tsc -p ./",
29
- "build:cjs": "tsc -p ./ --outDir ./dist/cjs --module nodenext --moduleResolution nodenext",
29
+ "build:cjs": "tsc -p ./ --outDir ./dist/cjs --module nodenext --moduleResolution nodenext --declaration false",
30
30
  "lint": "eslint --ext .ts .",
31
31
  "lint-fix": "eslint --ext .ts . --fix",
32
32
  "test": "node ./dist/cjs/test/runTest.js",
@@ -42,7 +42,7 @@
42
42
  "@types/glob": "^8.1.0",
43
43
  "@types/mocha": "^7.0.2",
44
44
  "@types/node": "^18.18.7",
45
- "@types/vscode": "1.104.0",
45
+ "@types/vscode": "1.105.0",
46
46
  "@typescript-eslint/eslint-plugin": "^5.53.0",
47
47
  "@vscode/test-electron": "^2.3.8",
48
48
  "eslint": "^8.34.0",
@@ -1,21 +0,0 @@
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
- * Always uses the default scope, `https://management.azure.com/.default/` and respects `microsoft-sovereign-cloud.environment` setting.
9
- *
10
- * @returns A VS Code authentication session or undefined, if none could be obtained.
11
- */
12
- getSession(): vscode.ProviderResult<vscode.AuthenticationSession>;
13
- /**
14
- * Gets a VS Code authentication session for an Azure subscription.
15
- *
16
- * @param scopeListOrRequest - The scopes or request for which the authentication is needed.
17
- *
18
- * @returns A VS Code authentication session or undefined, if none could be obtained.
19
- */
20
- getSessionWithScopes(scopeListOrRequest: string[] | vscode.AuthenticationWwwAuthenticateRequest): vscode.ProviderResult<vscode.AuthenticationSession>;
21
- }
@@ -1,68 +0,0 @@
1
- import { Event } from 'vscode';
2
- import { AzureSubscription } from './AzureSubscription';
3
- import { AzureSubscriptionProvider, GetSubscriptionsFilter } from './AzureSubscriptionProvider';
4
- import { AzureTenant } from './AzureTenant';
5
- export interface AzureDevOpsSubscriptionProviderInitializer {
6
- /**
7
- * The resource ID of the Azure DevOps federated service connection,
8
- * which can be found on the `resourceId` field of the URL at the address bar
9
- * when viewing the service connection in the Azure DevOps portal
10
- */
11
- serviceConnectionId: string;
12
- /**
13
- * The `Tenant ID` field of the service connection properties
14
- */
15
- domain: string;
16
- /**
17
- * The `Service Principal Id` field of the service connection properties
18
- */
19
- clientId: string;
20
- }
21
- export declare function createAzureDevOpsSubscriptionProviderFactory(initializer: AzureDevOpsSubscriptionProviderInitializer): () => Promise<AzureDevOpsSubscriptionProvider>;
22
- /**
23
- * AzureSubscriptionProvider implemented to authenticate via federated DevOps service connection, using workflow identity federation
24
- * To learn how to configure your DevOps environment to use this provider, refer to the README.md
25
- * NOTE: This provider is only available when running in an Azure DevOps pipeline
26
- * Reference: https://learn.microsoft.com/en-us/entra/workload-id/workload-identity-federation
27
- */
28
- export declare class AzureDevOpsSubscriptionProvider implements AzureSubscriptionProvider {
29
- private _tokenCredential;
30
- /**
31
- * The resource ID of the Azure DevOps federated service connection,
32
- * which can be found on the `resourceId` field of the URL at the address bar
33
- * when viewing the service connection in the Azure DevOps portal
34
- */
35
- private _SERVICE_CONNECTION_ID;
36
- /**
37
- * The `Tenant ID` field of the service connection properties
38
- */
39
- private _DOMAIN;
40
- /**
41
- * The `Service Principal Id` field of the service connection properties
42
- */
43
- private _CLIENT_ID;
44
- constructor({ serviceConnectionId, domain, clientId }: AzureDevOpsSubscriptionProviderInitializer);
45
- getSubscriptions(_filter: boolean | GetSubscriptionsFilter): Promise<AzureSubscription[]>;
46
- isSignedIn(): Promise<boolean>;
47
- signIn(): Promise<boolean>;
48
- signOut(): Promise<void>;
49
- getTenants(): Promise<AzureTenant[]>;
50
- /**
51
- * Gets the subscriptions for a given tenant.
52
- *
53
- * @param tenantId The tenant ID to get subscriptions for.
54
- *
55
- * @returns The list of subscriptions for the tenant.
56
- */
57
- private getSubscriptionsForTenant;
58
- /**
59
- * Gets a fully-configured subscription client for a given tenant ID
60
- *
61
- * @param tenantId (Optional) The tenant ID to get a client for
62
- *
63
- * @returns A client, the credential used by the client, and the authentication function
64
- */
65
- private getSubscriptionClient;
66
- onDidSignIn: Event<void>;
67
- onDidSignOut: Event<void>;
68
- }
@@ -1,49 +0,0 @@
1
- import type { TokenCredential } from '@azure/core-auth';
2
- import type { Environment } from '@azure/ms-rest-azure-env';
3
- import * as vscode from "vscode";
4
- import { AzureAuthentication } from './AzureAuthentication';
5
- /**
6
- * A type representing an Azure subscription ID, not including the tenant ID.
7
- */
8
- export type SubscriptionId = string;
9
- /**
10
- * A type representing an Azure tenant ID.
11
- */
12
- export type TenantId = string;
13
- /**
14
- * Represents an Azure subscription.
15
- */
16
- export interface AzureSubscription {
17
- /**
18
- * Access to the authentication session associated with this subscription.
19
- */
20
- readonly authentication: AzureAuthentication;
21
- /**
22
- * The Azure environment to which this subscription belongs.
23
- */
24
- readonly environment: Environment;
25
- /**
26
- * Whether this subscription belongs to a custom cloud.
27
- */
28
- readonly isCustomCloud: boolean;
29
- /**
30
- * The display name of this subscription.
31
- */
32
- readonly name: string;
33
- /**
34
- * The ID of this subscription.
35
- */
36
- readonly subscriptionId: SubscriptionId;
37
- /**
38
- * The ID of the tenant to which this subscription belongs.
39
- */
40
- readonly tenantId: TenantId;
41
- /**
42
- * The credential for authentication to this subscription. Compatible with Azure track 2 SDKs.
43
- */
44
- readonly credential: TokenCredential;
45
- /**
46
- * The account associated with this subscription.
47
- */
48
- readonly account: vscode.AuthenticationSessionAccountInformation;
49
- }
@@ -1,82 +0,0 @@
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,5 +0,0 @@
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,15 +0,0 @@
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,117 +0,0 @@
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
- }
@@ -1,13 +0,0 @@
1
- import * as vscode from "vscode";
2
- /**
3
- * Wraps {@link vscode.authentication.getSession} and handles:
4
- * * Passing the configured auth provider id
5
- * * Getting the list of scopes, adding the tenant id to the scope list if needed
6
- *
7
- * @param scopeOrListOrRequest - top-level resource scopes (e.g. http://management.azure.com, http://storage.azure.com) or .default scopes. All resources/scopes will be normalized to the `.default` scope for each resource.
8
- * Use `vscode.AuthenticationWwwAuthenticateRequest` if you need to pass in a challenge (WWW-Authenticate header). Note: Use of `vscode.AuthenticationWwwAuthenticateRequest` requires VS Code 1.105.0 or newer.
9
- * @param tenantId - (Optional) The tenant ID, will be added to the scopes
10
- * @param options - see {@link vscode.AuthenticationGetSessionOptions}
11
- * @returns An authentication session if available, or undefined if there are no sessions
12
- */
13
- export declare function getSessionFromVSCode(scopeOrListOrRequest?: string | string[] | vscode.AuthenticationWwwAuthenticateRequest, tenantId?: string, options?: vscode.AuthenticationGetSessionOptions): Promise<vscode.AuthenticationSession | undefined>;
@@ -1,56 +0,0 @@
1
- export * from './AzureAuthentication';
2
- export * from './AzureDevOpsSubscriptionProvider';
3
- export * from './AzureSubscription';
4
- export * from './AzureSubscriptionProvider';
5
- export * from './AzureTenant';
6
- export * from './NotSignedInError';
7
- export * from './signInToTenant';
8
- export * from './utils/configuredAzureEnv';
9
- export * from './utils/getUnauthenticatedTenants';
10
- export * from './VSCodeAzureSubscriptionProvider';
11
- declare module 'vscode' {
12
- /**
13
- * Represents parameters for creating a session based on a WWW-Authenticate header value.
14
- * This is used when an API returns a 401 with a WWW-Authenticate header indicating
15
- * that additional authentication is required. The details of which will be passed down
16
- * to the authentication provider to create a session.
17
- *
18
- * @note The authorization provider must support handling challenges and specifically
19
- * the challenges in this WWW-Authenticate value.
20
- * @note For more information on WWW-Authenticate please see https://developer.mozilla.org/docs/Web/HTTP/Reference/Headers/WWW-Authenticate
21
- */
22
- interface AuthenticationWwwAuthenticateRequest {
23
- /**
24
- * The raw WWW-Authenticate header value that triggered this challenge.
25
- * This will be parsed by the authentication provider to extract the necessary
26
- * challenge information.
27
- */
28
- readonly wwwAuthenticate: string;
29
- /**
30
- * The fallback scopes to use if no scopes are found in the WWW-Authenticate header.
31
- */
32
- readonly fallbackScopes?: readonly string[];
33
- }
34
- /**
35
- * Namespace for authentication.
36
- */
37
- namespace authentication {
38
- /**
39
- * Get an authentication session matching the desired scopes or request. Rejects if a provider with providerId is not
40
- * registered, or if the user does not consent to sharing authentication information with the extension. If there
41
- * are multiple sessions with the same scopes, the user will be shown a quickpick to select which account they would like to use.
42
- *
43
- * Built-in auth providers include:
44
- * * 'github' - For GitHub.com
45
- * * 'microsoft' For both personal & organizational Microsoft accounts
46
- * * (less common) 'github-enterprise' - for alternative GitHub hostings, GHE.com, GitHub Enterprise Server
47
- * * (less common) 'microsoft-sovereign-cloud' - for alternative Microsoft clouds
48
- *
49
- * @param providerId The id of the provider to use
50
- * @param scopeListOrRequest A scope list of permissions requested or a WWW-Authenticate request. These are dependent on the authentication provider.
51
- * @param options The {@link AuthenticationGetSessionOptions} to use
52
- * @returns A thenable that resolves to an authentication session or undefined if a silent flow was used and no session was found
53
- */
54
- function getSession(providerId: string, scopeListOrRequest: ReadonlyArray<string> | AuthenticationWwwAuthenticateRequest, options?: AuthenticationGetSessionOptions): Thenable<AuthenticationSession | undefined>;
55
- }
56
- }
@@ -1,6 +0,0 @@
1
- import type { AzureSubscriptionProvider } from "./AzureSubscriptionProvider";
2
- /**
3
- * Prompts user to select from a list of unauthenticated tenants.
4
- * Once selected, requests a new session from VS Code specifially for this tenant.
5
- */
6
- export declare function signInToTenant(subscriptionProvider: AzureSubscriptionProvider): Promise<void>;
@@ -1,24 +0,0 @@
1
- import * as azureEnv from '@azure/ms-rest-azure-env';
2
- import * as vscode from 'vscode';
3
- /**
4
- * Gets the configured Azure environment.
5
- *
6
- * @returns The configured Azure environment from the settings in the built-in authentication provider extension
7
- */
8
- export declare function getConfiguredAzureEnv(): azureEnv.Environment & {
9
- isCustomCloud: boolean;
10
- };
11
- /**
12
- * Sets the configured Azure cloud.
13
- *
14
- * @param cloud Use `'AzureCloud'` or `undefined` for public Azure cloud, `'ChinaCloud'` for Azure China, or `'USGovernment'` for Azure US Government.
15
- * 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` {@link azureEnv.EnvironmentParameters}.
16
- *
17
- * @param target (Optional) The configuration target to use, by default {@link vscode.ConfigurationTarget.Global}.
18
- */
19
- export declare function setConfiguredAzureEnv(cloud: 'AzureCloud' | 'ChinaCloud' | 'USGovernment' | undefined | azureEnv.EnvironmentParameters, target?: vscode.ConfigurationTarget): Promise<void>;
20
- /**
21
- * Gets the ID of the authentication provider configured to be used
22
- * @returns The provider ID to use, either `'microsoft'` or `'microsoft-sovereign-cloud'`
23
- */
24
- export declare function getConfiguredAuthProviderId(): string;
@@ -1,6 +0,0 @@
1
- import type { AzureSubscriptionProvider } from "../AzureSubscriptionProvider";
2
- import type { AzureTenant } from "../AzureTenant";
3
- /**
4
- * @returns list of tenants that VS Code doesn't have sessions for
5
- */
6
- export declare function getUnauthenticatedTenants(subscriptionProvider: AzureSubscriptionProvider): Promise<AzureTenant[]>;
@@ -1,2 +0,0 @@
1
- import type * as vscode from "vscode";
2
- export declare function isAuthenticationWwwAuthenticateRequest(obj: unknown): obj is vscode.AuthenticationWwwAuthenticateRequest;