@microsoft/vscode-azext-azureauth 6.0.0-alpha.6 → 6.0.0-alpha.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/src/providers/AzureSubscriptionProviderBase.js +6 -2
- package/dist/cjs/src/providers/VSCodeAzureSubscriptionProvider.js +8 -0
- package/dist/cjs/src/utils/configuredAzureEnv.js +5 -5
- package/dist/esm/src/contracts/AzureSubscriptionProvider.d.ts +2 -2
- package/dist/esm/src/providers/AzureSubscriptionProviderBase.js +6 -2
- package/dist/esm/src/providers/VSCodeAzureSubscriptionProvider.js +8 -0
- package/dist/esm/src/utils/configuredAzureEnv.d.ts +1 -0
- package/dist/esm/src/utils/configuredAzureEnv.js +1 -1
- package/package.json +1 -1
|
@@ -51,7 +51,7 @@ const Limiter_1 = require("../utils/Limiter");
|
|
|
51
51
|
const NotSignedInError_1 = require("../utils/NotSignedInError");
|
|
52
52
|
const screen_1 = require("../utils/screen");
|
|
53
53
|
const tryGetTokenExpiration_1 = require("../utils/tryGetTokenExpiration");
|
|
54
|
-
const EventDebounce =
|
|
54
|
+
const EventDebounce = 2 * 1000; // 2 seconds minimum between `onRefreshSuggested` events
|
|
55
55
|
const EventSilenceTime = 5 * 1000; // 5 seconds after sign-in to silence `onRefreshSuggested` events
|
|
56
56
|
const TenantListConcurrency = 3; // We will try to list tenants for at most 3 accounts in parallel
|
|
57
57
|
const SubscriptionListConcurrency = 5; // We will try to list subscriptions for at most 5 account+tenants in parallel
|
|
@@ -94,7 +94,11 @@ class AzureSubscriptionProviderBase {
|
|
|
94
94
|
return this.refreshSuggestedEmitter.event(callback, thisArg, disposables);
|
|
95
95
|
}
|
|
96
96
|
fireRefreshSuggestedIfNeeded(evtArgs) {
|
|
97
|
-
|
|
97
|
+
// subscriptionFilterChange is an explicit user action and must never be suppressed,
|
|
98
|
+
// otherwise re-selecting a subscription shortly after unselecting one gets swallowed
|
|
99
|
+
// by the debounce/silence window that the first refresh triggered.
|
|
100
|
+
if (evtArgs.reason !== 'subscriptionFilterChange' &&
|
|
101
|
+
(this.suppressRefreshSuggestedEvents || Date.now() < this.lastRefreshSuggestedTime + EventDebounce)) {
|
|
98
102
|
// Suppress and/or debounce events to avoid flooding
|
|
99
103
|
return false;
|
|
100
104
|
}
|
|
@@ -40,6 +40,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
40
40
|
exports.VSCodeAzureSubscriptionProvider = void 0;
|
|
41
41
|
const vscode = __importStar(require("vscode"));
|
|
42
42
|
const AzureSubscriptionProviderRequestOptions_1 = require("../contracts/AzureSubscriptionProviderRequestOptions"); // eslint-disable-line @typescript-eslint/no-unused-vars -- It is used in the doc comments
|
|
43
|
+
const configuredAzureEnv_1 = require("../utils/configuredAzureEnv");
|
|
43
44
|
const dedupeSubscriptions_1 = require("../utils/dedupeSubscriptions");
|
|
44
45
|
const CaselessMap_1 = require("../utils/map/CaselessMap");
|
|
45
46
|
const TwoKeyCaselessMap_1 = require("../utils/map/TwoKeyCaselessMap");
|
|
@@ -71,6 +72,13 @@ class VSCodeAzureSubscriptionProvider extends AzureSubscriptionProviderBase_1.Az
|
|
|
71
72
|
if (e.affectsConfiguration(`${ConfigPrefix}.${SelectedSubscriptionsConfigKey}`)) {
|
|
72
73
|
this.fireRefreshSuggestedIfNeeded({ reason: 'subscriptionFilterChange' });
|
|
73
74
|
}
|
|
75
|
+
else if (e.affectsConfiguration(configuredAzureEnv_1.CustomCloudConfigurationSection)) {
|
|
76
|
+
this.accountCache.clear();
|
|
77
|
+
this.tenantCache.clear();
|
|
78
|
+
this.subscriptionCache.clear();
|
|
79
|
+
this.log('Cleared all caches due to cloud environment change');
|
|
80
|
+
this.fireRefreshSuggestedIfNeeded({ reason: 'cloudChange' });
|
|
81
|
+
}
|
|
74
82
|
});
|
|
75
83
|
return super.onRefreshSuggested(callback, thisArg, disposables);
|
|
76
84
|
}
|
|
@@ -37,14 +37,14 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
37
37
|
};
|
|
38
38
|
})();
|
|
39
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
-
exports.ExtendedEnvironment = void 0;
|
|
40
|
+
exports.ExtendedEnvironment = exports.CustomCloudConfigurationSection = void 0;
|
|
41
41
|
exports.getConfiguredAzureEnv = getConfiguredAzureEnv;
|
|
42
42
|
exports.setConfiguredAzureEnv = setConfiguredAzureEnv;
|
|
43
43
|
exports.getConfiguredAuthProviderId = getConfiguredAuthProviderId;
|
|
44
44
|
const azureEnv = __importStar(require("@azure/ms-rest-azure-env")); // This package is so small that it's not worth lazy loading
|
|
45
45
|
const vscode = __importStar(require("vscode"));
|
|
46
46
|
// These strings come from https://github.com/microsoft/vscode/blob/eac16e9b63a11885b538db3e0b533a02a2fb8143/extensions/microsoft-authentication/package.json#L40-L99
|
|
47
|
-
|
|
47
|
+
exports.CustomCloudConfigurationSection = 'microsoft-sovereign-cloud';
|
|
48
48
|
const CloudEnvironmentSettingName = 'environment';
|
|
49
49
|
const CustomEnvironmentSettingName = 'customEnvironment';
|
|
50
50
|
var CloudEnvironmentSettingValue;
|
|
@@ -70,7 +70,7 @@ exports.ExtendedEnvironment = ExtendedEnvironment;
|
|
|
70
70
|
* @returns The configured Azure environment from the settings in the built-in authentication provider extension
|
|
71
71
|
*/
|
|
72
72
|
function getConfiguredAzureEnv() {
|
|
73
|
-
const authProviderConfig = vscode.workspace.getConfiguration(CustomCloudConfigurationSection);
|
|
73
|
+
const authProviderConfig = vscode.workspace.getConfiguration(exports.CustomCloudConfigurationSection);
|
|
74
74
|
const environmentSettingValue = authProviderConfig.get(CloudEnvironmentSettingName);
|
|
75
75
|
if (environmentSettingValue === CloudEnvironmentSettingValue.ChinaCloud) {
|
|
76
76
|
return new ExtendedEnvironment(azureEnv.Environment.ChinaCloud, false);
|
|
@@ -83,7 +83,7 @@ function getConfiguredAzureEnv() {
|
|
|
83
83
|
if (customCloud) {
|
|
84
84
|
return new ExtendedEnvironment(customCloud, true);
|
|
85
85
|
}
|
|
86
|
-
throw new Error(vscode.l10n.t('The custom cloud choice is not configured. Please configure the setting `{0}.{1}`.', CustomCloudConfigurationSection, CustomEnvironmentSettingName));
|
|
86
|
+
throw new Error(vscode.l10n.t('The custom cloud choice is not configured. Please configure the setting `{0}.{1}`.', exports.CustomCloudConfigurationSection, CustomEnvironmentSettingName));
|
|
87
87
|
}
|
|
88
88
|
return new ExtendedEnvironment(azureEnv.Environment.AzureCloud, false);
|
|
89
89
|
}
|
|
@@ -96,7 +96,7 @@ function getConfiguredAzureEnv() {
|
|
|
96
96
|
* @param target (Optional) The configuration target to use, by default {@link vscode.ConfigurationTarget.Global}.
|
|
97
97
|
*/
|
|
98
98
|
async function setConfiguredAzureEnv(cloud, target = vscode.ConfigurationTarget.Global) {
|
|
99
|
-
const authProviderConfig = vscode.workspace.getConfiguration(CustomCloudConfigurationSection);
|
|
99
|
+
const authProviderConfig = vscode.workspace.getConfiguration(exports.CustomCloudConfigurationSection);
|
|
100
100
|
if (typeof cloud === 'undefined' || !cloud) {
|
|
101
101
|
// Use public cloud implicitly--set `environment` setting to `undefined`
|
|
102
102
|
await authProviderConfig.update(CloudEnvironmentSettingName, undefined, target);
|
|
@@ -10,7 +10,7 @@ export interface AzureSubscriptionProvider {
|
|
|
10
10
|
/**
|
|
11
11
|
* Fires when the list of available subscriptions may have changed, and a refresh is suggested.
|
|
12
12
|
* The callback will be given a {@link RefreshSuggestedEvent} with more information.
|
|
13
|
-
* @note This will be fired at most every
|
|
13
|
+
* @note This will be fired at most every 2 seconds, to avoid flooding. It is also suppressed
|
|
14
14
|
* during operations this provider is performing itself, such as during sign-in.
|
|
15
15
|
*/
|
|
16
16
|
onRefreshSuggested: vscode.Event<RefreshSuggestedEvent>;
|
|
@@ -108,5 +108,5 @@ export interface RefreshSuggestedEvent {
|
|
|
108
108
|
/**
|
|
109
109
|
* The reason a refresh was suggested.
|
|
110
110
|
*/
|
|
111
|
-
reason: 'sessionChange' | 'subscriptionFilterChange';
|
|
111
|
+
reason: 'sessionChange' | 'subscriptionFilterChange' | 'cloudChange';
|
|
112
112
|
}
|
|
@@ -15,7 +15,7 @@ import { Limiter } from '../utils/Limiter';
|
|
|
15
15
|
import { isNotSignedInError, NotSignedInError } from '../utils/NotSignedInError';
|
|
16
16
|
import { screen } from '../utils/screen';
|
|
17
17
|
import { tryGetTokenExpiration } from '../utils/tryGetTokenExpiration';
|
|
18
|
-
const EventDebounce =
|
|
18
|
+
const EventDebounce = 2 * 1000; // 2 seconds minimum between `onRefreshSuggested` events
|
|
19
19
|
const EventSilenceTime = 5 * 1000; // 5 seconds after sign-in to silence `onRefreshSuggested` events
|
|
20
20
|
const TenantListConcurrency = 3; // We will try to list tenants for at most 3 accounts in parallel
|
|
21
21
|
const SubscriptionListConcurrency = 5; // We will try to list subscriptions for at most 5 account+tenants in parallel
|
|
@@ -58,7 +58,11 @@ export class AzureSubscriptionProviderBase {
|
|
|
58
58
|
return this.refreshSuggestedEmitter.event(callback, thisArg, disposables);
|
|
59
59
|
}
|
|
60
60
|
fireRefreshSuggestedIfNeeded(evtArgs) {
|
|
61
|
-
|
|
61
|
+
// subscriptionFilterChange is an explicit user action and must never be suppressed,
|
|
62
|
+
// otherwise re-selecting a subscription shortly after unselecting one gets swallowed
|
|
63
|
+
// by the debounce/silence window that the first refresh triggered.
|
|
64
|
+
if (evtArgs.reason !== 'subscriptionFilterChange' &&
|
|
65
|
+
(this.suppressRefreshSuggestedEvents || Date.now() < this.lastRefreshSuggestedTime + EventDebounce)) {
|
|
62
66
|
// Suppress and/or debounce events to avoid flooding
|
|
63
67
|
return false;
|
|
64
68
|
}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
import * as vscode from 'vscode';
|
|
6
6
|
import { DefaultOptions, getCoalescenceKey } from '../contracts/AzureSubscriptionProviderRequestOptions'; // eslint-disable-line @typescript-eslint/no-unused-vars -- It is used in the doc comments
|
|
7
|
+
import { CustomCloudConfigurationSection } from '../utils/configuredAzureEnv';
|
|
7
8
|
import { dedupeSubscriptions } from '../utils/dedupeSubscriptions';
|
|
8
9
|
import { CaselessMap } from '../utils/map/CaselessMap';
|
|
9
10
|
import { TwoKeyCaselessMap } from '../utils/map/TwoKeyCaselessMap';
|
|
@@ -35,6 +36,13 @@ export class VSCodeAzureSubscriptionProvider extends AzureSubscriptionProviderBa
|
|
|
35
36
|
if (e.affectsConfiguration(`${ConfigPrefix}.${SelectedSubscriptionsConfigKey}`)) {
|
|
36
37
|
this.fireRefreshSuggestedIfNeeded({ reason: 'subscriptionFilterChange' });
|
|
37
38
|
}
|
|
39
|
+
else if (e.affectsConfiguration(CustomCloudConfigurationSection)) {
|
|
40
|
+
this.accountCache.clear();
|
|
41
|
+
this.tenantCache.clear();
|
|
42
|
+
this.subscriptionCache.clear();
|
|
43
|
+
this.log('Cleared all caches due to cloud environment change');
|
|
44
|
+
this.fireRefreshSuggestedIfNeeded({ reason: 'cloudChange' });
|
|
45
|
+
}
|
|
38
46
|
});
|
|
39
47
|
return super.onRefreshSuggested(callback, thisArg, disposables);
|
|
40
48
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as azureEnv from '@azure/ms-rest-azure-env';
|
|
2
2
|
import * as vscode from 'vscode';
|
|
3
|
+
export declare const CustomCloudConfigurationSection = "microsoft-sovereign-cloud";
|
|
3
4
|
export declare class ExtendedEnvironment extends azureEnv.Environment {
|
|
4
5
|
readonly isCustomCloud: boolean;
|
|
5
6
|
constructor(parameters: azureEnv.EnvironmentParameters, isCustomCloud: boolean);
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import * as azureEnv from '@azure/ms-rest-azure-env'; // This package is so small that it's not worth lazy loading
|
|
6
6
|
import * as vscode from 'vscode';
|
|
7
7
|
// These strings come from https://github.com/microsoft/vscode/blob/eac16e9b63a11885b538db3e0b533a02a2fb8143/extensions/microsoft-authentication/package.json#L40-L99
|
|
8
|
-
const CustomCloudConfigurationSection = 'microsoft-sovereign-cloud';
|
|
8
|
+
export const CustomCloudConfigurationSection = 'microsoft-sovereign-cloud';
|
|
9
9
|
const CloudEnvironmentSettingName = 'environment';
|
|
10
10
|
const CustomEnvironmentSettingName = 'customEnvironment';
|
|
11
11
|
var CloudEnvironmentSettingValue;
|
package/package.json
CHANGED