@microsoft/vscode-azext-azureauth 2.3.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.
@@ -0,0 +1,249 @@
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
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
7
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
8
+ return new (P || (P = Promise))(function (resolve, reject) {
9
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
10
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
11
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
12
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
13
+ });
14
+ };
15
+ var __asyncValues = (this && this.__asyncValues) || function (o) {
16
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
17
+ var m = o[Symbol.asyncIterator], i;
18
+ return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
19
+ function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
20
+ function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
21
+ };
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ exports.AzureDevOpsSubscriptionProvider = exports.createAzureDevOpsSubscriptionProviderFactory = void 0;
24
+ const vscode_1 = require("vscode");
25
+ const configuredAzureEnv_1 = require("./utils/configuredAzureEnv");
26
+ let azureDevOpsSubscriptionProvider;
27
+ function createAzureDevOpsSubscriptionProviderFactory() {
28
+ return () => __awaiter(this, void 0, void 0, function* () {
29
+ azureDevOpsSubscriptionProvider !== null && azureDevOpsSubscriptionProvider !== void 0 ? azureDevOpsSubscriptionProvider : (azureDevOpsSubscriptionProvider = new AzureDevOpsSubscriptionProvider());
30
+ return azureDevOpsSubscriptionProvider;
31
+ });
32
+ }
33
+ exports.createAzureDevOpsSubscriptionProviderFactory = createAzureDevOpsSubscriptionProviderFactory;
34
+ /**
35
+ * AzureSubscriptionProvider implemented to authenticate via federated DevOps service connection, using workflow identity federation
36
+ * To learn how to configure your DevOps environment to use this provider, refer to the README.md
37
+ * NOTE: This provider is only available when running in an Azure DevOps pipeline
38
+ * Reference: https://learn.microsoft.com/en-us/entra/workload-id/workload-identity-federation
39
+ */
40
+ class AzureDevOpsSubscriptionProvider {
41
+ constructor() {
42
+ this.onDidSignIn = () => { return new vscode_1.Disposable(() => { }); };
43
+ this.onDidSignOut = () => { return new vscode_1.Disposable(() => { }); };
44
+ const SERVICE_CONNECTION_ID = process.env.AzCodeServiceConnectionID;
45
+ const DOMAIN = process.env.AzCodeServiceConnectionDomain;
46
+ const CLIENT_ID = process.env.AzCodeServiceConnectionClientID;
47
+ if (!SERVICE_CONNECTION_ID || !DOMAIN || !CLIENT_ID) {
48
+ throw new Error(`Azure DevOps federated service connection is not configured\n
49
+ process.env.AzCodeServiceConnectionID: ${SERVICE_CONNECTION_ID ? "✅" : "❌"}\n
50
+ process.env.AzCodeServiceConnectionDomain: ${DOMAIN ? "✅" : "❌"}\n
51
+ process.env.AzCodeServiceConnectionClientID: ${CLIENT_ID ? "✅" : "❌"}\n
52
+ `);
53
+ }
54
+ this._SERVICE_CONNECTION_ID = SERVICE_CONNECTION_ID;
55
+ this._DOMAIN = DOMAIN;
56
+ this._CLIENT_ID = CLIENT_ID;
57
+ }
58
+ getSubscriptions(_filter) {
59
+ return __awaiter(this, void 0, void 0, function* () {
60
+ // ignore the filter setting because not every consumer of this provider will use the Resources extension
61
+ const results = [];
62
+ for (const tenant of yield this.getTenants()) {
63
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
64
+ const tenantId = tenant.tenantId;
65
+ results.push(...yield this.getSubscriptionsForTenant(tenantId));
66
+ }
67
+ const sortSubscriptions = (subscriptions) => subscriptions.sort((a, b) => a.name.localeCompare(b.name));
68
+ return sortSubscriptions(results);
69
+ });
70
+ }
71
+ isSignedIn() {
72
+ return __awaiter(this, void 0, void 0, function* () {
73
+ return !!this._tokenCredential;
74
+ });
75
+ }
76
+ signIn() {
77
+ return __awaiter(this, void 0, void 0, function* () {
78
+ this._tokenCredential = yield getTokenCredential(this._SERVICE_CONNECTION_ID, this._DOMAIN, this._CLIENT_ID);
79
+ return !!this._tokenCredential;
80
+ });
81
+ }
82
+ signOut() {
83
+ return __awaiter(this, void 0, void 0, function* () {
84
+ this._tokenCredential = undefined;
85
+ });
86
+ }
87
+ getTenants() {
88
+ var _a;
89
+ return __awaiter(this, void 0, void 0, function* () {
90
+ return [{
91
+ tenantId: (_a = this._tokenCredential) === null || _a === void 0 ? void 0 : _a.tenantId,
92
+ }];
93
+ });
94
+ }
95
+ /**
96
+ * Gets the subscriptions for a given tenant.
97
+ *
98
+ * @param tenantId The tenant ID to get subscriptions for.
99
+ *
100
+ * @returns The list of subscriptions for the tenant.
101
+ */
102
+ getSubscriptionsForTenant(tenantId) {
103
+ var _a, e_1, _b, _c;
104
+ return __awaiter(this, void 0, void 0, function* () {
105
+ const { client, credential, authentication } = yield this.getSubscriptionClient(tenantId);
106
+ const environment = (0, configuredAzureEnv_1.getConfiguredAzureEnv)();
107
+ const subscriptions = [];
108
+ try {
109
+ for (var _d = true, _e = __asyncValues(client.subscriptions.list()), _f; _f = yield _e.next(), _a = _f.done, !_a;) {
110
+ _c = _f.value;
111
+ _d = false;
112
+ try {
113
+ const subscription = _c;
114
+ subscriptions.push({
115
+ authentication,
116
+ environment: environment,
117
+ credential: credential,
118
+ isCustomCloud: environment.isCustomCloud,
119
+ /* eslint-disable @typescript-eslint/no-non-null-assertion */
120
+ name: subscription.displayName,
121
+ subscriptionId: subscription.subscriptionId,
122
+ /* eslint-enable @typescript-eslint/no-non-null-assertion */
123
+ tenantId,
124
+ });
125
+ }
126
+ finally {
127
+ _d = true;
128
+ }
129
+ }
130
+ }
131
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
132
+ finally {
133
+ try {
134
+ if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
135
+ }
136
+ finally { if (e_1) throw e_1.error; }
137
+ }
138
+ return subscriptions;
139
+ });
140
+ }
141
+ /**
142
+ * Gets a fully-configured subscription client for a given tenant ID
143
+ *
144
+ * @param tenantId (Optional) The tenant ID to get a client for
145
+ *
146
+ * @returns A client, the credential used by the client, and the authentication function
147
+ */
148
+ getSubscriptionClient(_tenantId, scopes) {
149
+ var _a, _b;
150
+ return __awaiter(this, void 0, void 0, function* () {
151
+ const armSubs = yield Promise.resolve().then(() => require('@azure/arm-resources-subscriptions'));
152
+ if (!this._tokenCredential) {
153
+ throw new Error('Not signed in');
154
+ }
155
+ const accessToken = ((_b = (yield ((_a = this._tokenCredential) === null || _a === void 0 ? void 0 : _a.getToken("https://management.azure.com/.default")))) === null || _b === void 0 ? void 0 : _b.token) || '';
156
+ return {
157
+ client: new armSubs.SubscriptionClient(this._tokenCredential),
158
+ credential: this._tokenCredential,
159
+ authentication: {
160
+ getSession: (_scopes) => {
161
+ var _a, _b, _c, _d;
162
+ return {
163
+ accessToken,
164
+ id: ((_a = this._tokenCredential) === null || _a === void 0 ? void 0 : _a.tenantId) || '',
165
+ account: {
166
+ id: ((_b = this._tokenCredential) === null || _b === void 0 ? void 0 : _b.tenantId) || '',
167
+ label: ((_c = this._tokenCredential) === null || _c === void 0 ? void 0 : _c.tenantId) || '',
168
+ },
169
+ tenantId: ((_d = this._tokenCredential) === null || _d === void 0 ? void 0 : _d.tenantId) || '',
170
+ scopes: scopes || [],
171
+ };
172
+ }
173
+ }
174
+ };
175
+ });
176
+ }
177
+ }
178
+ exports.AzureDevOpsSubscriptionProvider = AzureDevOpsSubscriptionProvider;
179
+ /*
180
+ * @param serviceConnectionId The resource ID of the Azure DevOps federated service connection,
181
+ * which can be found on the `resourceId` field of the URL at the address bar when viewing the service connection in the Azure DevOps portal
182
+ * @param domain The `Tenant ID` field of the service connection properties
183
+ * @param clientId The `Service Principal Id` field of the service connection properties
184
+ */
185
+ function getTokenCredential(serviceConnectionId, domain, clientId) {
186
+ return __awaiter(this, void 0, void 0, function* () {
187
+ if (!process.env.AGENT_BUILDDIRECTORY) {
188
+ // Assume that AGENT_BUILDDIRECTORY is set if running in an Azure DevOps pipeline.
189
+ // So when not running in an Azure DevOps pipeline, throw an error since we cannot use the DevOps federated service connection credential.
190
+ throw new Error(`Cannot create DevOps federated service connection credential outside of an Azure DevOps pipeline.`);
191
+ }
192
+ else {
193
+ console.log(`Creating DevOps federated service connection credential for service connection..`);
194
+ // Pre-defined DevOps variable reference: https://learn.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops
195
+ const systemAccessToken = process.env.SYSTEM_ACCESSTOKEN;
196
+ const teamFoundationCollectionUri = process.env.SYSTEM_TEAMFOUNDATIONCOLLECTIONURI;
197
+ const teamProjectId = process.env.SYSTEM_TEAMPROJECTID;
198
+ const planId = process.env.SYSTEM_PLANID;
199
+ const jobId = process.env.SYSTEM_JOBID;
200
+ if (!systemAccessToken || !teamFoundationCollectionUri || !teamProjectId || !planId || !jobId) {
201
+ throw new Error(`Azure DevOps environment variables are not set.\n
202
+ process.env.SYSTEM_ACCESSTOKEN: ${process.env.SYSTEM_ACCESSTOKEN ? "✅" : "❌"}\n
203
+ process.env.SYSTEM_TEAMFOUNDATIONCOLLECTIONURI: ${process.env.SYSTEM_TEAMFOUNDATIONCOLLECTIONURI ? "✅" : "❌"}\n
204
+ process.env.SYSTEM_TEAMPROJECTID: ${process.env.SYSTEM_TEAMPROJECTID ? "✅" : "❌"}\n
205
+ process.env.SYSTEM_PLANID: ${process.env.SYSTEM_PLANID ? "✅" : "❌"}\n
206
+ process.env.SYSTEM_JOBID: ${process.env.SYSTEM_JOBID ? "✅" : "❌"}\n
207
+ REMEMBER: process.env.SYSTEM_ACCESSTOKEN must be explicitly mapped!\n
208
+ https://learn.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&tabs=yaml#systemaccesstoken
209
+ `);
210
+ }
211
+ const oidcRequestUrl = `${teamFoundationCollectionUri}${teamProjectId}/_apis/distributedtask/hubs/build/plans/${planId}/jobs/${jobId}/oidctoken?api-version=7.1-preview.1&serviceConnectionId=${serviceConnectionId}`;
212
+ const { ClientAssertionCredential } = yield Promise.resolve().then(() => require("@azure/identity"));
213
+ return new ClientAssertionCredential(domain, clientId, () => __awaiter(this, void 0, void 0, function* () { return yield requestOidcToken(oidcRequestUrl, systemAccessToken); }));
214
+ }
215
+ });
216
+ }
217
+ /**
218
+ * API reference: https://learn.microsoft.com/en-us/rest/api/azure/devops/distributedtask/oidctoken/create
219
+ */
220
+ function requestOidcToken(oidcRequestUrl, systemAccessToken) {
221
+ var _a;
222
+ return __awaiter(this, void 0, void 0, function* () {
223
+ const { ServiceClient } = yield Promise.resolve().then(() => require('@azure/core-client'));
224
+ const { createHttpHeaders, createPipelineRequest } = yield Promise.resolve().then(() => require('@azure/core-rest-pipeline'));
225
+ const genericClient = new ServiceClient();
226
+ const request = createPipelineRequest({
227
+ url: oidcRequestUrl,
228
+ method: "POST",
229
+ headers: createHttpHeaders({
230
+ "Content-Type": "application/json",
231
+ "Authorization": `Bearer ${systemAccessToken}`
232
+ })
233
+ });
234
+ const response = yield genericClient.sendRequest(request);
235
+ const body = ((_a = response.bodyAsText) === null || _a === void 0 ? void 0 : _a.toString()) || "";
236
+ if (response.status !== 200) {
237
+ throw new Error(`Failed to get OIDC token:\n
238
+ Response status: ${response.status}\n
239
+ Response body: ${body}\n
240
+ Response headers: ${JSON.stringify(response.headers.toJSON())}
241
+ `);
242
+ }
243
+ else {
244
+ console.log(`Successfully got OIDC token with status ${response.status}`);
245
+ }
246
+ return JSON.parse(body).oidcToken;
247
+ });
248
+ }
249
+ //# sourceMappingURL=AzureDevOpsSubscriptionProvider.js.map
@@ -1,44 +1,44 @@
1
- import type { TokenCredential } from '@azure/core-auth';
2
- import type { Environment } from '@azure/ms-rest-azure-env';
3
- import type { AzureAuthentication } from './AzureAuthentication';
4
- /**
5
- * A type representing an Azure subscription ID, not including the tenant ID.
6
- */
7
- export type SubscriptionId = string;
8
- /**
9
- * A type representing an Azure tenant ID.
10
- */
11
- export type TenantId = string;
12
- /**
13
- * Represents an Azure subscription.
14
- */
15
- export interface AzureSubscription {
16
- /**
17
- * Access to the authentication session associated with this subscription.
18
- */
19
- readonly authentication: AzureAuthentication;
20
- /**
21
- * The Azure environment to which this subscription belongs.
22
- */
23
- readonly environment: Environment;
24
- /**
25
- * Whether this subscription belongs to a custom cloud.
26
- */
27
- readonly isCustomCloud: boolean;
28
- /**
29
- * The display name of this subscription.
30
- */
31
- readonly name: string;
32
- /**
33
- * The ID of this subscription.
34
- */
35
- readonly subscriptionId: SubscriptionId;
36
- /**
37
- * The ID of the tenant to which this subscription belongs.
38
- */
39
- readonly tenantId: TenantId;
40
- /**
41
- * The credential for authentication to this subscription. Compatible with Azure track 2 SDKs.
42
- */
43
- readonly credential: TokenCredential;
44
- }
1
+ import type { TokenCredential } from '@azure/core-auth';
2
+ import type { Environment } from '@azure/ms-rest-azure-env';
3
+ import type { AzureAuthentication } from './AzureAuthentication';
4
+ /**
5
+ * A type representing an Azure subscription ID, not including the tenant ID.
6
+ */
7
+ export type SubscriptionId = string;
8
+ /**
9
+ * A type representing an Azure tenant ID.
10
+ */
11
+ export type TenantId = string;
12
+ /**
13
+ * Represents an Azure subscription.
14
+ */
15
+ export interface AzureSubscription {
16
+ /**
17
+ * Access to the authentication session associated with this subscription.
18
+ */
19
+ readonly authentication: AzureAuthentication;
20
+ /**
21
+ * The Azure environment to which this subscription belongs.
22
+ */
23
+ readonly environment: Environment;
24
+ /**
25
+ * Whether this subscription belongs to a custom cloud.
26
+ */
27
+ readonly isCustomCloud: boolean;
28
+ /**
29
+ * The display name of this subscription.
30
+ */
31
+ readonly name: string;
32
+ /**
33
+ * The ID of this subscription.
34
+ */
35
+ readonly subscriptionId: SubscriptionId;
36
+ /**
37
+ * The ID of the tenant to which this subscription belongs.
38
+ */
39
+ readonly tenantId: TenantId;
40
+ /**
41
+ * The credential for authentication to this subscription. Compatible with Azure track 2 SDKs.
42
+ */
43
+ readonly credential: TokenCredential;
44
+ }
@@ -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=AzureSubscription.js.map
@@ -1,60 +1,60 @@
1
- import type * as vscode from 'vscode';
2
- import type { AzureSubscription } from './AzureSubscription';
3
- import type { TenantIdDescription } from '@azure/arm-resources-subscriptions';
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
- * @returns A list of tenants.
13
- */
14
- getTenants(): Promise<TenantIdDescription[]>;
15
- /**
16
- * Gets a list of Azure subscriptions available to the user.
17
- *
18
- * @param filter - Whether to filter the list returned, according to the list returned
19
- * by `getTenantFilters()` and `getSubscriptionFilters()`. Optional, default true.
20
- *
21
- * @returns A list of Azure subscriptions.
22
- *
23
- * @throws A {@link NotSignedInError} If the user is not signed in to Azure.
24
- * Use {@link isSignedIn} and/or {@link signIn} before this method to ensure
25
- * the user is signed in.
26
- */
27
- getSubscriptions(filter: boolean): Promise<AzureSubscription[]>;
28
- /**
29
- * Checks to see if a user is signed in.
30
- *
31
- * @param tenantId (Optional) Provide to check if a user is signed in to a specific tenant.
32
- *
33
- * @returns True if the user is signed in, false otherwise.
34
- */
35
- isSignedIn(tenantId?: string): Promise<boolean>;
36
- /**
37
- * Asks the user to sign in or pick an account to use.
38
- *
39
- * @param tenantId (Optional) Provide to sign in to a specific tenant.
40
- *
41
- * @returns True if the user is signed in, false otherwise.
42
- */
43
- signIn(tenantId?: string): Promise<boolean>;
44
- /**
45
- * An event that is fired when the user signs in. Debounced to fire at most once every 5 seconds.
46
- */
47
- onDidSignIn: vscode.Event<void>;
48
- /**
49
- * Signs the user out
50
- *
51
- * @deprecated Not currently supported by VS Code auth providers
52
- *
53
- * @throws Throws an {@link Error} every time
54
- */
55
- signOut(): Promise<void>;
56
- /**
57
- * An event that is fired when the user signs out. Debounced to fire at most once every 5 seconds.
58
- */
59
- onDidSignOut: vscode.Event<void>;
60
- }
1
+ import type * as vscode from 'vscode';
2
+ import type { AzureSubscription } from './AzureSubscription';
3
+ import type { TenantIdDescription } from '@azure/arm-resources-subscriptions';
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
+ * @returns A list of tenants.
13
+ */
14
+ getTenants(): Promise<TenantIdDescription[]>;
15
+ /**
16
+ * Gets a list of Azure subscriptions available to the user.
17
+ *
18
+ * @param filter - Whether to filter the list returned, according to the list returned
19
+ * by `getTenantFilters()` and `getSubscriptionFilters()`. Optional, default true.
20
+ *
21
+ * @returns A list of Azure subscriptions.
22
+ *
23
+ * @throws A {@link NotSignedInError} If the user is not signed in to Azure.
24
+ * Use {@link isSignedIn} and/or {@link signIn} before this method to ensure
25
+ * the user is signed in.
26
+ */
27
+ getSubscriptions(filter: boolean): Promise<AzureSubscription[]>;
28
+ /**
29
+ * Checks to see if a user is signed in.
30
+ *
31
+ * @param tenantId (Optional) Provide to check if a user is signed in to a specific tenant.
32
+ *
33
+ * @returns True if the user is signed in, false otherwise.
34
+ */
35
+ isSignedIn(tenantId?: string): Promise<boolean>;
36
+ /**
37
+ * Asks the user to sign in or pick an account to use.
38
+ *
39
+ * @param tenantId (Optional) Provide to sign in to a specific tenant.
40
+ *
41
+ * @returns True if the user is signed in, false otherwise.
42
+ */
43
+ signIn(tenantId?: string): Promise<boolean>;
44
+ /**
45
+ * An event that is fired when the user signs in. Debounced to fire at most once every 5 seconds.
46
+ */
47
+ onDidSignIn: vscode.Event<void>;
48
+ /**
49
+ * Signs the user out
50
+ *
51
+ * @deprecated Not currently supported by VS Code auth providers
52
+ *
53
+ * @throws Throws an {@link Error} every time
54
+ */
55
+ signOut(): Promise<void>;
56
+ /**
57
+ * An event that is fired when the user signs out. Debounced to fire at most once every 5 seconds.
58
+ */
59
+ onDidSignOut: vscode.Event<void>;
60
+ }
@@ -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,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