@microsoft/vscode-azext-azureauth 1.0.0 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
- export * from './AzureAuthentication';
2
- export * from './AzureSubscription';
3
- export * from './AzureSubscriptionProvider';
4
- export * from './NotSignedInError';
5
- export * from './utils/configuredAzureEnv';
6
- export * from './VSCodeAzureSubscriptionProvider';
1
+ export * from './AzureAuthentication';
2
+ export * from './AzureSubscription';
3
+ export * from './AzureSubscriptionProvider';
4
+ export * from './NotSignedInError';
5
+ export * from './utils/configuredAzureEnv';
6
+ export * from './VSCodeAzureSubscriptionProvider';
package/out/src/index.js CHANGED
@@ -1,27 +1,27 @@
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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
- if (k2 === undefined) k2 = k;
8
- var desc = Object.getOwnPropertyDescriptor(m, k);
9
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10
- desc = { enumerable: true, get: function() { return m[k]; } };
11
- }
12
- Object.defineProperty(o, k2, desc);
13
- }) : (function(o, m, k, k2) {
14
- if (k2 === undefined) k2 = k;
15
- o[k2] = m[k];
16
- }));
17
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
18
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
19
- };
20
- Object.defineProperty(exports, "__esModule", { value: true });
21
- __exportStar(require("./AzureAuthentication"), exports);
22
- __exportStar(require("./AzureSubscription"), exports);
23
- __exportStar(require("./AzureSubscriptionProvider"), exports);
24
- __exportStar(require("./NotSignedInError"), exports);
25
- __exportStar(require("./utils/configuredAzureEnv"), exports);
26
- __exportStar(require("./VSCodeAzureSubscriptionProvider"), exports);
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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
+ if (k2 === undefined) k2 = k;
8
+ var desc = Object.getOwnPropertyDescriptor(m, k);
9
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10
+ desc = { enumerable: true, get: function() { return m[k]; } };
11
+ }
12
+ Object.defineProperty(o, k2, desc);
13
+ }) : (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ o[k2] = m[k];
16
+ }));
17
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
18
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
19
+ };
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ __exportStar(require("./AzureAuthentication"), exports);
22
+ __exportStar(require("./AzureSubscription"), exports);
23
+ __exportStar(require("./AzureSubscriptionProvider"), exports);
24
+ __exportStar(require("./NotSignedInError"), exports);
25
+ __exportStar(require("./utils/configuredAzureEnv"), exports);
26
+ __exportStar(require("./VSCodeAzureSubscriptionProvider"), exports);
27
27
  //# sourceMappingURL=index.js.map
@@ -1,24 +1,24 @@
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 `microsoft-sovereign-cloud.endpoint` setting.
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'` for public Azure cloud, `'AzureChinaCloud'` for Azure China, or `'AzureUSGovernment'` 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` `EnvironmentParameters`.
16
- *
17
- * @param target (Optional) The configuration target to use, by default {@link vscode.ConfigurationTarget.Global}.
18
- */
19
- export declare function setConfiguredAzureEnv(cloud: string | 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
+ 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,90 +1,95 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.getConfiguredAuthProviderId = exports.setConfiguredAzureEnv = exports.getConfiguredAzureEnv = void 0;
17
- const azureEnv = require("@azure/ms-rest-azure-env"); // This package is so small that it's not worth lazy loading
18
- const vscode = require("vscode");
19
- const AzureCloudName = azureEnv.Environment.AzureCloud.name;
20
- const AzureChinaCloudName = azureEnv.Environment.ChinaCloud.name;
21
- const AzureUSGovernmentCloudName = azureEnv.Environment.USGovernment.name;
22
- const CloudNameToEndpointSettingValue = {};
23
- CloudNameToEndpointSettingValue[AzureCloudName] = undefined;
24
- CloudNameToEndpointSettingValue[AzureChinaCloudName] = 'Azure China';
25
- CloudNameToEndpointSettingValue[AzureUSGovernmentCloudName] = 'Azure US Government';
26
- /**
27
- * Gets the configured Azure environment.
28
- *
29
- * @returns The configured Azure environment from the `microsoft-sovereign-cloud.endpoint` setting.
30
- */
31
- function getConfiguredAzureEnv() {
32
- var _a;
33
- const authProviderConfig = vscode.workspace.getConfiguration('microsoft-sovereign-cloud');
34
- const endpointSettingValue = (_a = authProviderConfig.get('endpoint')) === null || _a === void 0 ? void 0 : _a.toLowerCase();
35
- // The endpoint setting will accept either the environment name (either 'Azure China' or 'Azure US Government'),
36
- // or an endpoint URL. Since the user could configure the same environment either way, we need to check both.
37
- // We'll also throw to lowercase just to maximize the chance of success.
38
- /* eslint-disable @typescript-eslint/no-non-null-assertion */
39
- if (endpointSettingValue === CloudNameToEndpointSettingValue[AzureChinaCloudName].toLowerCase() || endpointSettingValue === azureEnv.Environment.ChinaCloud.activeDirectoryEndpointUrl.toLowerCase()) {
40
- return Object.assign(Object.assign({}, azureEnv.Environment.get(azureEnv.Environment.ChinaCloud.name)), { isCustomCloud: false });
41
- }
42
- else if (endpointSettingValue === CloudNameToEndpointSettingValue[AzureUSGovernmentCloudName].toLowerCase() || endpointSettingValue === azureEnv.Environment.USGovernment.activeDirectoryEndpointUrl.toLowerCase()) {
43
- return Object.assign(Object.assign({}, azureEnv.Environment.get(azureEnv.Environment.USGovernment.name)), { isCustomCloud: false });
44
- }
45
- else if (endpointSettingValue) {
46
- const rgConfig = vscode.workspace.getConfiguration('azureResourceGroups');
47
- const customCloud = rgConfig.get('customCloud'); // TODO: final setting name
48
- if (customCloud) {
49
- return Object.assign(Object.assign({}, new azureEnv.Environment(customCloud)), { isCustomCloud: true });
50
- }
51
- throw new Error(vscode.l10n.t('The custom cloud choice is not configured. Please configure the setting `azureResourceGroups.customCloud`.')); // TODO: final setting name
52
- }
53
- /* eslint-enable @typescript-eslint/no-non-null-assertion */
54
- return Object.assign(Object.assign({}, azureEnv.Environment.get(azureEnv.Environment.AzureCloud.name)), { isCustomCloud: false });
55
- }
56
- exports.getConfiguredAzureEnv = getConfiguredAzureEnv;
57
- /**
58
- * Sets the configured Azure cloud.
59
- *
60
- * @param cloud Use `'AzureCloud'` for public Azure cloud, `'AzureChinaCloud'` for Azure China, or `'AzureUSGovernment'` for Azure US Government.
61
- * 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`.
62
- *
63
- * @param target (Optional) The configuration target to use, by default {@link vscode.ConfigurationTarget.Global}.
64
- */
65
- function setConfiguredAzureEnv(cloud, target = vscode.ConfigurationTarget.Global) {
66
- return __awaiter(this, void 0, void 0, function* () {
67
- const authProviderConfig = vscode.workspace.getConfiguration('microsoft-sovereign-cloud');
68
- if (typeof cloud === 'string' && cloud in CloudNameToEndpointSettingValue) {
69
- yield authProviderConfig.update('endpoint', CloudNameToEndpointSettingValue[cloud], target);
70
- }
71
- else if (typeof cloud === 'object' && 'activeDirectoryEndpointUrl' in cloud) {
72
- yield authProviderConfig.update('endpoint', cloud.activeDirectoryEndpointUrl, target);
73
- const rgConfig = vscode.workspace.getConfiguration('azureResourceGroups');
74
- yield rgConfig.update('customCloud', cloud, target); // TODO: final setting name
75
- }
76
- else {
77
- throw new Error(`Invalid cloud value: ${JSON.stringify(cloud)}`);
78
- }
79
- });
80
- }
81
- exports.setConfiguredAzureEnv = setConfiguredAzureEnv;
82
- /**
83
- * Gets the ID of the authentication provider configured to be used
84
- * @returns The provider ID to use, either `'microsoft'` or `'microsoft-sovereign-cloud'`
85
- */
86
- function getConfiguredAuthProviderId() {
87
- return getConfiguredAzureEnv().name === AzureCloudName ? 'microsoft' : 'microsoft-sovereign-cloud';
88
- }
89
- exports.getConfiguredAuthProviderId = getConfiguredAuthProviderId;
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
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.getConfiguredAuthProviderId = exports.setConfiguredAzureEnv = exports.getConfiguredAzureEnv = void 0;
17
+ const azureEnv = require("@azure/ms-rest-azure-env"); // This package is so small that it's not worth lazy loading
18
+ const vscode = require("vscode");
19
+ // These strings come from https://github.com/microsoft/vscode/blob/eac16e9b63a11885b538db3e0b533a02a2fb8143/extensions/microsoft-authentication/package.json#L40-L99
20
+ const CustomCloudConfigurationSection = 'microsoft-sovereign-cloud';
21
+ const CloudEnvironmentSettingName = 'environment';
22
+ const CustomEnvironmentSettingName = 'customEnvironment';
23
+ var CloudEnvironmentSettingValue;
24
+ (function (CloudEnvironmentSettingValue) {
25
+ CloudEnvironmentSettingValue["ChinaCloud"] = "ChinaCloud";
26
+ CloudEnvironmentSettingValue["USGovernment"] = "USGovernment";
27
+ CloudEnvironmentSettingValue["Custom"] = "custom";
28
+ })(CloudEnvironmentSettingValue || (CloudEnvironmentSettingValue = {}));
29
+ /**
30
+ * Gets the configured Azure environment.
31
+ *
32
+ * @returns The configured Azure environment from the settings in the built-in authentication provider extension
33
+ */
34
+ function getConfiguredAzureEnv() {
35
+ const authProviderConfig = vscode.workspace.getConfiguration(CustomCloudConfigurationSection);
36
+ const environmentSettingValue = authProviderConfig.get(CloudEnvironmentSettingName);
37
+ if (environmentSettingValue === CloudEnvironmentSettingValue.ChinaCloud) {
38
+ return Object.assign(Object.assign({}, azureEnv.Environment.get(azureEnv.Environment.ChinaCloud.name)), { isCustomCloud: false });
39
+ }
40
+ else if (environmentSettingValue === CloudEnvironmentSettingValue.USGovernment) {
41
+ return Object.assign(Object.assign({}, azureEnv.Environment.get(azureEnv.Environment.USGovernment.name)), { isCustomCloud: false });
42
+ }
43
+ else if (environmentSettingValue === CloudEnvironmentSettingValue.Custom) {
44
+ const customCloud = authProviderConfig.get(CustomEnvironmentSettingName);
45
+ if (customCloud) {
46
+ return Object.assign(Object.assign({}, new azureEnv.Environment(customCloud)), { isCustomCloud: true });
47
+ }
48
+ throw new Error(vscode.l10n.t('The custom cloud choice is not configured. Please configure the setting `{0}.{1}`.', CustomCloudConfigurationSection, CustomEnvironmentSettingName));
49
+ }
50
+ return Object.assign(Object.assign({}, azureEnv.Environment.get(azureEnv.Environment.AzureCloud.name)), { isCustomCloud: false });
51
+ }
52
+ exports.getConfiguredAzureEnv = getConfiguredAzureEnv;
53
+ /**
54
+ * Sets the configured Azure cloud.
55
+ *
56
+ * @param cloud Use `'AzureCloud'` or `undefined` for public Azure cloud, `'ChinaCloud'` for Azure China, or `'USGovernment'` for Azure US Government.
57
+ * 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}.
58
+ *
59
+ * @param target (Optional) The configuration target to use, by default {@link vscode.ConfigurationTarget.Global}.
60
+ */
61
+ function setConfiguredAzureEnv(cloud, target = vscode.ConfigurationTarget.Global) {
62
+ return __awaiter(this, void 0, void 0, function* () {
63
+ const authProviderConfig = vscode.workspace.getConfiguration(CustomCloudConfigurationSection);
64
+ if (typeof cloud === 'undefined' || !cloud) {
65
+ // Use public cloud implicitly--set `environment` setting to `undefined`
66
+ yield authProviderConfig.update(CloudEnvironmentSettingName, undefined, target);
67
+ }
68
+ else if (typeof cloud === 'string' && cloud === 'AzureCloud') {
69
+ // Use public cloud explicitly--set `environment` setting to `undefined`
70
+ yield authProviderConfig.update(CloudEnvironmentSettingName, undefined, target);
71
+ }
72
+ else if (typeof cloud === 'string') {
73
+ // Use a sovereign cloud--set the `environment` setting to the specified value
74
+ yield authProviderConfig.update(CloudEnvironmentSettingName, cloud, target);
75
+ }
76
+ else if (typeof cloud === 'object') {
77
+ // use a custom cloud--set the `environment` setting to `custom` and the `customEnvironment` setting to the specified value
78
+ yield authProviderConfig.update(CloudEnvironmentSettingName, CloudEnvironmentSettingValue.Custom, target);
79
+ yield authProviderConfig.update(CustomEnvironmentSettingName, cloud, target);
80
+ }
81
+ else {
82
+ throw new Error(`Invalid cloud value: ${JSON.stringify(cloud)}`);
83
+ }
84
+ });
85
+ }
86
+ exports.setConfiguredAzureEnv = setConfiguredAzureEnv;
87
+ /**
88
+ * Gets the ID of the authentication provider configured to be used
89
+ * @returns The provider ID to use, either `'microsoft'` or `'microsoft-sovereign-cloud'`
90
+ */
91
+ function getConfiguredAuthProviderId() {
92
+ return getConfiguredAzureEnv().name === azureEnv.Environment.AzureCloud.name ? 'microsoft' : 'microsoft-sovereign-cloud';
93
+ }
94
+ exports.getConfiguredAuthProviderId = getConfiguredAuthProviderId;
90
95
  //# sourceMappingURL=configuredAzureEnv.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": "1.0.0",
4
+ "version": "1.1.2",
5
5
  "description": "Azure authentication helpers for Visual Studio Code",
6
6
  "tags": [
7
7
  "azure",