@codingame/monaco-vscode-authentication-service-override 18.3.1 → 19.0.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.
- package/index.js +5 -1
- package/package.json +5 -4
- package/vscode/src/vs/workbench/contrib/authentication/browser/actions/manageAccountPreferencesForExtensionAction.d.ts +6 -0
- package/vscode/src/vs/workbench/contrib/authentication/browser/actions/manageAccountPreferencesForExtensionAction.js +171 -0
- package/vscode/src/vs/workbench/contrib/authentication/browser/actions/manageAccountPreferencesForMcpServerAction.d.ts +6 -0
- package/vscode/src/vs/workbench/contrib/authentication/browser/actions/manageAccountPreferencesForMcpServerAction.js +171 -0
- package/vscode/src/vs/workbench/contrib/authentication/browser/actions/manageDynamicAuthenticationProvidersAction.d.ts +7 -0
- package/vscode/src/vs/workbench/contrib/authentication/browser/actions/manageDynamicAuthenticationProvidersAction.js +76 -0
- package/vscode/src/vs/workbench/contrib/authentication/browser/actions/manageTrustedExtensionsForAccountAction.d.ts +9 -0
- package/vscode/src/vs/workbench/contrib/authentication/browser/actions/manageTrustedExtensionsForAccountAction.js +177 -0
- package/vscode/src/vs/workbench/contrib/authentication/browser/actions/manageTrustedMcpServersForAccountAction.d.ts +9 -0
- package/vscode/src/vs/workbench/contrib/authentication/browser/actions/manageTrustedMcpServersForAccountAction.js +171 -0
- package/vscode/src/vs/workbench/contrib/authentication/browser/actions/signOutOfAccountAction.d.ts +9 -0
- package/vscode/src/vs/workbench/contrib/authentication/browser/actions/signOutOfAccountAction.js +52 -0
- package/vscode/src/vs/workbench/contrib/authentication/browser/authentication.contribution.d.ts +1 -0
- package/vscode/src/vs/workbench/contrib/authentication/browser/authentication.contribution.js +140 -0
- package/vscode/src/vs/workbench/services/authentication/browser/authenticationAccessService.js +39 -6
- package/vscode/src/vs/workbench/services/authentication/browser/authenticationExtensionsService.js +9 -9
- package/vscode/src/vs/workbench/services/authentication/browser/authenticationQueryService.d.ts +39 -0
- package/vscode/src/vs/workbench/services/authentication/browser/authenticationQueryService.js +613 -0
- package/vscode/src/vs/workbench/services/authentication/browser/authenticationUsageService.d.ts +1 -0
- package/vscode/src/vs/workbench/services/authentication/browser/authenticationUsageService.js +7 -2
package/index.js
CHANGED
|
@@ -10,6 +10,9 @@ import { IAuthenticationAccessService } from '@codingame/monaco-vscode-api/vscod
|
|
|
10
10
|
import { IAuthenticationUsageService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/authentication/browser/authenticationUsageService.service';
|
|
11
11
|
import { IDynamicAuthenticationProviderStorageService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/authentication/common/dynamicAuthenticationProviderStorage.service';
|
|
12
12
|
import { DynamicAuthenticationProviderStorageService } from './vscode/src/vs/workbench/services/authentication/browser/dynamicAuthenticationProviderStorageService.js';
|
|
13
|
+
import { IAuthenticationQueryService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/authentication/common/authenticationQuery.service';
|
|
14
|
+
import { AuthenticationQueryService } from './vscode/src/vs/workbench/services/authentication/browser/authenticationQueryService.js';
|
|
15
|
+
import './vscode/src/vs/workbench/contrib/authentication/browser/authentication.contribution.js';
|
|
13
16
|
|
|
14
17
|
function getServiceOverride() {
|
|
15
18
|
return {
|
|
@@ -17,7 +20,8 @@ function getServiceOverride() {
|
|
|
17
20
|
[IAuthenticationAccessService.toString()]: new SyncDescriptor(AuthenticationAccessService, [], true),
|
|
18
21
|
[IAuthenticationExtensionsService.toString()]: new SyncDescriptor(AuthenticationExtensionsService, [], true),
|
|
19
22
|
[IAuthenticationUsageService.toString()]: new SyncDescriptor(AuthenticationUsageService, [], true),
|
|
20
|
-
[IDynamicAuthenticationProviderStorageService.toString()]: new SyncDescriptor(DynamicAuthenticationProviderStorageService, [], true)
|
|
23
|
+
[IDynamicAuthenticationProviderStorageService.toString()]: new SyncDescriptor(DynamicAuthenticationProviderStorageService, [], true),
|
|
24
|
+
[IAuthenticationQueryService.toString()]: new SyncDescriptor(AuthenticationQueryService, [], true)
|
|
21
25
|
};
|
|
22
26
|
}
|
|
23
27
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codingame/monaco-vscode-authentication-service-override",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "19.0.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "VSCode public API plugged on the monaco editor - authentication service-override",
|
|
6
6
|
"keywords": [],
|
|
@@ -15,9 +15,10 @@
|
|
|
15
15
|
},
|
|
16
16
|
"type": "module",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@codingame/monaco-vscode-
|
|
19
|
-
"@codingame/monaco-vscode-
|
|
20
|
-
"@codingame/monaco-vscode-
|
|
18
|
+
"@codingame/monaco-vscode-34a0ffd3-b9f5-5699-b43b-38af5732f38a-common": "19.0.0",
|
|
19
|
+
"@codingame/monaco-vscode-937ecbdf-94c7-5b16-aefa-ad78ae557a93-common": "19.0.0",
|
|
20
|
+
"@codingame/monaco-vscode-api": "19.0.0",
|
|
21
|
+
"@codingame/monaco-vscode-f22e7e55-aee8-5b52-a6bc-950efd9f5890-common": "19.0.0"
|
|
21
22
|
},
|
|
22
23
|
"main": "index.js",
|
|
23
24
|
"module": "index.js",
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Action2 } from "@codingame/monaco-vscode-api/vscode/vs/platform/actions/common/actions";
|
|
2
|
+
import { ServicesAccessor } from "@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation";
|
|
3
|
+
export declare class ManageAccountPreferencesForExtensionAction extends Action2 {
|
|
4
|
+
constructor();
|
|
5
|
+
run(accessor: ServicesAccessor, extensionId?: string, providerId?: string): Promise<void>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
|
|
2
|
+
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
|
+
import { Event } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
|
|
4
|
+
import { DisposableStore } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
5
|
+
import { localize2, localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
|
|
6
|
+
import { Action2 } from '@codingame/monaco-vscode-api/vscode/vs/platform/actions/common/actions';
|
|
7
|
+
import { IDialogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/dialogs/common/dialogs.service';
|
|
8
|
+
import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
|
|
9
|
+
import { ILogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service';
|
|
10
|
+
import { IQuickInputService } from '@codingame/monaco-vscode-api/vscode/vs/platform/quickinput/common/quickInput.service';
|
|
11
|
+
import { IAuthenticationService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/authentication/common/authentication.service';
|
|
12
|
+
import { IAuthenticationQueryService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/authentication/common/authenticationQuery.service';
|
|
13
|
+
import { IExtensionService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensions/common/extensions.service';
|
|
14
|
+
|
|
15
|
+
class ManageAccountPreferencesForExtensionAction extends Action2 {
|
|
16
|
+
constructor() {
|
|
17
|
+
super({
|
|
18
|
+
id: '_manageAccountPreferencesForExtension',
|
|
19
|
+
title: ( localize2(4280, "Manage Extension Account Preferences")),
|
|
20
|
+
category: ( localize2(4281, "Accounts")),
|
|
21
|
+
f1: false
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
run(accessor, extensionId, providerId) {
|
|
25
|
+
return accessor.get(IInstantiationService).createInstance(ManageAccountPreferenceForExtensionActionImpl).run(extensionId, providerId);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
let ManageAccountPreferenceForExtensionActionImpl = class ManageAccountPreferenceForExtensionActionImpl {
|
|
29
|
+
constructor(_authenticationService, _quickInputService, _dialogService, _authenticationQueryService, _extensionService, _logService) {
|
|
30
|
+
this._authenticationService = _authenticationService;
|
|
31
|
+
this._quickInputService = _quickInputService;
|
|
32
|
+
this._dialogService = _dialogService;
|
|
33
|
+
this._authenticationQueryService = _authenticationQueryService;
|
|
34
|
+
this._extensionService = _extensionService;
|
|
35
|
+
this._logService = _logService;
|
|
36
|
+
}
|
|
37
|
+
async run(extensionId, providerId) {
|
|
38
|
+
if (!extensionId) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const extension = await this._extensionService.getExtension(extensionId);
|
|
42
|
+
if (!extension) {
|
|
43
|
+
throw ( new Error(`No extension with id ${extensionId}`));
|
|
44
|
+
}
|
|
45
|
+
if (!providerId) {
|
|
46
|
+
const extensionQuery = this._authenticationQueryService.extension(extensionId);
|
|
47
|
+
const providersWithAccess = await extensionQuery.getProvidersWithAccess();
|
|
48
|
+
if (!providersWithAccess.length) {
|
|
49
|
+
await this._dialogService.info(( localize(4282, "This extension has not used any accounts yet.")));
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
providerId = providersWithAccess[0];
|
|
53
|
+
if (providersWithAccess.length > 1) {
|
|
54
|
+
const result = await this._quickInputService.pick(( providersWithAccess.map(providerId => ({
|
|
55
|
+
label: this._authenticationService.getProvider(providerId).label,
|
|
56
|
+
id: providerId,
|
|
57
|
+
}))), {
|
|
58
|
+
placeHolder: ( localize(
|
|
59
|
+
4283,
|
|
60
|
+
"Select an authentication provider to manage account preferences for"
|
|
61
|
+
)),
|
|
62
|
+
title: ( localize(4284, "Manage Extension Account Preferences"))
|
|
63
|
+
});
|
|
64
|
+
if (!result) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
providerId = result.id;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const accounts = await this._authenticationService.getAccounts(providerId);
|
|
71
|
+
const currentAccountNamePreference = this._authenticationQueryService.provider(providerId).extension(extensionId).getPreferredAccount();
|
|
72
|
+
const items = this._getItems(accounts, providerId, currentAccountNamePreference);
|
|
73
|
+
const provider = this._authenticationService.getProvider(providerId);
|
|
74
|
+
if (provider.supportsMultipleAccounts) {
|
|
75
|
+
const lastUsedScopes = accounts
|
|
76
|
+
.flatMap(account => this._authenticationQueryService.provider(providerId).account(account.label).extension(extensionId).getUsage())
|
|
77
|
+
.sort((a, b) => b.lastUsed - a.lastUsed)[0]?.scopes;
|
|
78
|
+
if (lastUsedScopes) {
|
|
79
|
+
items.push({ type: 'separator' });
|
|
80
|
+
items.push({
|
|
81
|
+
providerId,
|
|
82
|
+
scopes: lastUsedScopes,
|
|
83
|
+
label: ( localize(4285, "Use a new account...")),
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
const disposables = ( new DisposableStore());
|
|
88
|
+
const picker = this._createQuickPick(disposables, extensionId, extension.displayName ?? extension.name, provider.label);
|
|
89
|
+
if (items.length === 0) {
|
|
90
|
+
disposables.add(this._handleNoAccounts(picker));
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
picker.items = items;
|
|
94
|
+
picker.show();
|
|
95
|
+
}
|
|
96
|
+
_createQuickPick(disposableStore, extensionId, extensionLabel, providerLabel) {
|
|
97
|
+
const picker = disposableStore.add(this._quickInputService.createQuickPick({ useSeparators: true }));
|
|
98
|
+
disposableStore.add(picker.onDidHide(() => {
|
|
99
|
+
disposableStore.dispose();
|
|
100
|
+
}));
|
|
101
|
+
picker.placeholder = ( localize(
|
|
102
|
+
4286,
|
|
103
|
+
"Manage '{0}' account preferences for {1}...",
|
|
104
|
+
extensionLabel,
|
|
105
|
+
providerLabel
|
|
106
|
+
));
|
|
107
|
+
picker.title = ( localize(4287, "'{0}' Account Preferences For This Workspace", extensionLabel));
|
|
108
|
+
picker.sortByLabel = false;
|
|
109
|
+
disposableStore.add(picker.onDidAccept(async () => {
|
|
110
|
+
picker.hide();
|
|
111
|
+
await this._accept(extensionId, picker.selectedItems);
|
|
112
|
+
}));
|
|
113
|
+
return picker;
|
|
114
|
+
}
|
|
115
|
+
_getItems(accounts, providerId, currentAccountNamePreference) {
|
|
116
|
+
return (accounts.map(a => currentAccountNamePreference === a.label
|
|
117
|
+
? {
|
|
118
|
+
label: a.label,
|
|
119
|
+
account: a,
|
|
120
|
+
providerId,
|
|
121
|
+
description: ( localize(4288, "Current account")),
|
|
122
|
+
picked: true
|
|
123
|
+
}
|
|
124
|
+
: {
|
|
125
|
+
label: a.label,
|
|
126
|
+
account: a,
|
|
127
|
+
providerId,
|
|
128
|
+
}));
|
|
129
|
+
}
|
|
130
|
+
_handleNoAccounts(picker) {
|
|
131
|
+
picker.validationMessage = ( localize(4289, "No accounts are currently used by this extension."));
|
|
132
|
+
picker.buttons = [this._quickInputService.backButton];
|
|
133
|
+
picker.show();
|
|
134
|
+
return Event.filter(picker.onDidTriggerButton, (e) => e === this._quickInputService.backButton)(() => this.run());
|
|
135
|
+
}
|
|
136
|
+
async _accept(extensionId, selectedItems) {
|
|
137
|
+
for (const item of selectedItems) {
|
|
138
|
+
let account;
|
|
139
|
+
if (!item.account) {
|
|
140
|
+
try {
|
|
141
|
+
const session = await this._authenticationService.createSession(item.providerId, [...item.scopes]);
|
|
142
|
+
account = session.account;
|
|
143
|
+
}
|
|
144
|
+
catch (e) {
|
|
145
|
+
this._logService.error(e);
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
account = item.account;
|
|
151
|
+
}
|
|
152
|
+
const providerId = item.providerId;
|
|
153
|
+
const extensionQuery = this._authenticationQueryService.provider(providerId).extension(extensionId);
|
|
154
|
+
const currentAccountName = extensionQuery.getPreferredAccount();
|
|
155
|
+
if (currentAccountName === account.label) {
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
extensionQuery.setPreferredAccount(account);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
ManageAccountPreferenceForExtensionActionImpl = ( __decorate([
|
|
163
|
+
( __param(0, IAuthenticationService)),
|
|
164
|
+
( __param(1, IQuickInputService)),
|
|
165
|
+
( __param(2, IDialogService)),
|
|
166
|
+
( __param(3, IAuthenticationQueryService)),
|
|
167
|
+
( __param(4, IExtensionService)),
|
|
168
|
+
( __param(5, ILogService))
|
|
169
|
+
], ManageAccountPreferenceForExtensionActionImpl));
|
|
170
|
+
|
|
171
|
+
export { ManageAccountPreferencesForExtensionAction };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Action2 } from "@codingame/monaco-vscode-api/vscode/vs/platform/actions/common/actions";
|
|
2
|
+
import { ServicesAccessor } from "@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation";
|
|
3
|
+
export declare class ManageAccountPreferencesForMcpServerAction extends Action2 {
|
|
4
|
+
constructor();
|
|
5
|
+
run(accessor: ServicesAccessor, mcpServerId?: string, providerId?: string): Promise<void>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
|
|
2
|
+
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
|
+
import { Event } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
|
|
4
|
+
import { DisposableStore } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
5
|
+
import { localize2, localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
|
|
6
|
+
import { Action2 } from '@codingame/monaco-vscode-api/vscode/vs/platform/actions/common/actions';
|
|
7
|
+
import { IDialogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/dialogs/common/dialogs.service';
|
|
8
|
+
import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
|
|
9
|
+
import { ILogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service';
|
|
10
|
+
import { IQuickInputService } from '@codingame/monaco-vscode-api/vscode/vs/platform/quickinput/common/quickInput.service';
|
|
11
|
+
import { IAuthenticationService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/authentication/common/authentication.service';
|
|
12
|
+
import { IAuthenticationQueryService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/authentication/common/authenticationQuery.service';
|
|
13
|
+
import { IMcpService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/mcp/common/mcpTypes.service';
|
|
14
|
+
|
|
15
|
+
class ManageAccountPreferencesForMcpServerAction extends Action2 {
|
|
16
|
+
constructor() {
|
|
17
|
+
super({
|
|
18
|
+
id: '_manageAccountPreferencesForMcpServer',
|
|
19
|
+
title: ( localize2(4290, "Manage MCP Server Account Preferences")),
|
|
20
|
+
category: ( localize2(4291, "Accounts")),
|
|
21
|
+
f1: false
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
run(accessor, mcpServerId, providerId) {
|
|
25
|
+
return accessor.get(IInstantiationService).createInstance(ManageAccountPreferenceForMcpServerActionImpl).run(mcpServerId, providerId);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
let ManageAccountPreferenceForMcpServerActionImpl = class ManageAccountPreferenceForMcpServerActionImpl {
|
|
29
|
+
constructor(_authenticationService, _quickInputService, _dialogService, _authenticationQueryService, _mcpService, _logService) {
|
|
30
|
+
this._authenticationService = _authenticationService;
|
|
31
|
+
this._quickInputService = _quickInputService;
|
|
32
|
+
this._dialogService = _dialogService;
|
|
33
|
+
this._authenticationQueryService = _authenticationQueryService;
|
|
34
|
+
this._mcpService = _mcpService;
|
|
35
|
+
this._logService = _logService;
|
|
36
|
+
}
|
|
37
|
+
async run(mcpServerId, providerId) {
|
|
38
|
+
if (!mcpServerId) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const mcpServer = this._mcpService.servers.get().find(s => s.definition.id === mcpServerId);
|
|
42
|
+
if (!mcpServer) {
|
|
43
|
+
throw ( new Error(`No MCP server with id ${mcpServerId}`));
|
|
44
|
+
}
|
|
45
|
+
if (!providerId) {
|
|
46
|
+
const mcpServerQuery = this._authenticationQueryService.mcpServer(mcpServerId);
|
|
47
|
+
const providersWithAccess = await mcpServerQuery.getProvidersWithAccess();
|
|
48
|
+
if (!providersWithAccess.length) {
|
|
49
|
+
await this._dialogService.info(( localize(4292, "This MCP server has not used any accounts yet.")));
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
providerId = providersWithAccess[0];
|
|
53
|
+
if (providersWithAccess.length > 1) {
|
|
54
|
+
const result = await this._quickInputService.pick(( providersWithAccess.map(providerId => ({
|
|
55
|
+
label: this._authenticationService.getProvider(providerId).label,
|
|
56
|
+
id: providerId,
|
|
57
|
+
}))), {
|
|
58
|
+
placeHolder: ( localize(
|
|
59
|
+
4293,
|
|
60
|
+
"Select an authentication provider to manage account preferences for"
|
|
61
|
+
)),
|
|
62
|
+
title: ( localize(4294, "Manage MCP Server Account Preferences"))
|
|
63
|
+
});
|
|
64
|
+
if (!result) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
providerId = result.id;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const accounts = await this._authenticationService.getAccounts(providerId);
|
|
71
|
+
const currentAccountNamePreference = this._authenticationQueryService.provider(providerId).mcpServer(mcpServerId).getPreferredAccount();
|
|
72
|
+
const items = this._getItems(accounts, providerId, currentAccountNamePreference);
|
|
73
|
+
const provider = this._authenticationService.getProvider(providerId);
|
|
74
|
+
if (provider.supportsMultipleAccounts) {
|
|
75
|
+
const lastUsedScopes = accounts
|
|
76
|
+
.flatMap(account => this._authenticationQueryService.provider(providerId).account(account.label).mcpServer(mcpServerId).getUsage())
|
|
77
|
+
.sort((a, b) => b.lastUsed - a.lastUsed)[0]?.scopes;
|
|
78
|
+
if (lastUsedScopes) {
|
|
79
|
+
items.push({ type: 'separator' });
|
|
80
|
+
items.push({
|
|
81
|
+
providerId: providerId,
|
|
82
|
+
scopes: lastUsedScopes,
|
|
83
|
+
label: ( localize(4295, "Use a new account...")),
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
const disposables = ( new DisposableStore());
|
|
88
|
+
const picker = this._createQuickPick(disposables, mcpServerId, mcpServer.definition.label, provider.label);
|
|
89
|
+
if (items.length === 0) {
|
|
90
|
+
disposables.add(this._handleNoAccounts(picker));
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
picker.items = items;
|
|
94
|
+
picker.show();
|
|
95
|
+
}
|
|
96
|
+
_createQuickPick(disposableStore, mcpServerId, mcpServerLabel, providerLabel) {
|
|
97
|
+
const picker = disposableStore.add(this._quickInputService.createQuickPick({ useSeparators: true }));
|
|
98
|
+
disposableStore.add(picker.onDidHide(() => {
|
|
99
|
+
disposableStore.dispose();
|
|
100
|
+
}));
|
|
101
|
+
picker.placeholder = ( localize(
|
|
102
|
+
4296,
|
|
103
|
+
"Manage '{0}' account preferences for {1}...",
|
|
104
|
+
mcpServerLabel,
|
|
105
|
+
providerLabel
|
|
106
|
+
));
|
|
107
|
+
picker.title = ( localize(4297, "'{0}' Account Preferences For This Workspace", mcpServerLabel));
|
|
108
|
+
picker.sortByLabel = false;
|
|
109
|
+
disposableStore.add(picker.onDidAccept(async () => {
|
|
110
|
+
picker.hide();
|
|
111
|
+
await this._accept(mcpServerId, picker.selectedItems);
|
|
112
|
+
}));
|
|
113
|
+
return picker;
|
|
114
|
+
}
|
|
115
|
+
_getItems(accounts, providerId, currentAccountNamePreference) {
|
|
116
|
+
return (accounts.map(a => currentAccountNamePreference === a.label
|
|
117
|
+
? {
|
|
118
|
+
label: a.label,
|
|
119
|
+
account: a,
|
|
120
|
+
providerId,
|
|
121
|
+
description: ( localize(4298, "Current account")),
|
|
122
|
+
picked: true
|
|
123
|
+
}
|
|
124
|
+
: {
|
|
125
|
+
label: a.label,
|
|
126
|
+
account: a,
|
|
127
|
+
providerId,
|
|
128
|
+
}));
|
|
129
|
+
}
|
|
130
|
+
_handleNoAccounts(picker) {
|
|
131
|
+
picker.validationMessage = ( localize(4299, "No accounts are currently used by this MCP server."));
|
|
132
|
+
picker.buttons = [this._quickInputService.backButton];
|
|
133
|
+
picker.show();
|
|
134
|
+
return Event.filter(picker.onDidTriggerButton, (e) => e === this._quickInputService.backButton)(() => this.run());
|
|
135
|
+
}
|
|
136
|
+
async _accept(mcpServerId, selectedItems) {
|
|
137
|
+
for (const item of selectedItems) {
|
|
138
|
+
let account;
|
|
139
|
+
if (!item.account) {
|
|
140
|
+
try {
|
|
141
|
+
const session = await this._authenticationService.createSession(item.providerId, [...item.scopes]);
|
|
142
|
+
account = session.account;
|
|
143
|
+
}
|
|
144
|
+
catch (e) {
|
|
145
|
+
this._logService.error(e);
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
account = item.account;
|
|
151
|
+
}
|
|
152
|
+
const providerId = item.providerId;
|
|
153
|
+
const mcpQuery = this._authenticationQueryService.provider(providerId).mcpServer(mcpServerId);
|
|
154
|
+
const currentAccountName = mcpQuery.getPreferredAccount();
|
|
155
|
+
if (currentAccountName === account.label) {
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
mcpQuery.setPreferredAccount(account);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
ManageAccountPreferenceForMcpServerActionImpl = ( __decorate([
|
|
163
|
+
( __param(0, IAuthenticationService)),
|
|
164
|
+
( __param(1, IQuickInputService)),
|
|
165
|
+
( __param(2, IDialogService)),
|
|
166
|
+
( __param(3, IAuthenticationQueryService)),
|
|
167
|
+
( __param(4, IMcpService)),
|
|
168
|
+
( __param(5, ILogService))
|
|
169
|
+
], ManageAccountPreferenceForMcpServerActionImpl));
|
|
170
|
+
|
|
171
|
+
export { ManageAccountPreferencesForMcpServerAction };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Action2 } from "@codingame/monaco-vscode-api/vscode/vs/platform/actions/common/actions";
|
|
2
|
+
import { ServicesAccessor } from "@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation";
|
|
3
|
+
export declare class RemoveDynamicAuthenticationProvidersAction extends Action2 {
|
|
4
|
+
static readonly ID = "workbench.action.removeDynamicAuthenticationProviders";
|
|
5
|
+
constructor();
|
|
6
|
+
run(accessor: ServicesAccessor): Promise<void>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
|
|
2
|
+
import { localize2, localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
|
|
3
|
+
import { Action2 } from '@codingame/monaco-vscode-api/vscode/vs/platform/actions/common/actions';
|
|
4
|
+
import { IQuickInputService } from '@codingame/monaco-vscode-api/vscode/vs/platform/quickinput/common/quickInput.service';
|
|
5
|
+
import { IDynamicAuthenticationProviderStorageService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/authentication/common/dynamicAuthenticationProviderStorage.service';
|
|
6
|
+
import { IAuthenticationService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/authentication/common/authentication.service';
|
|
7
|
+
import { IDialogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/dialogs/common/dialogs.service';
|
|
8
|
+
|
|
9
|
+
class RemoveDynamicAuthenticationProvidersAction extends Action2 {
|
|
10
|
+
static { this.ID = 'workbench.action.removeDynamicAuthenticationProviders'; }
|
|
11
|
+
constructor() {
|
|
12
|
+
super({
|
|
13
|
+
id: RemoveDynamicAuthenticationProvidersAction.ID,
|
|
14
|
+
title: ( localize2(4300, 'Remove Dynamic Authentication Providers')),
|
|
15
|
+
category: ( localize2(4301, 'Authentication')),
|
|
16
|
+
f1: true
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
async run(accessor) {
|
|
20
|
+
const quickInputService = accessor.get(IQuickInputService);
|
|
21
|
+
const dynamicAuthStorageService = accessor.get(IDynamicAuthenticationProviderStorageService);
|
|
22
|
+
const authenticationService = accessor.get(IAuthenticationService);
|
|
23
|
+
const dialogService = accessor.get(IDialogService);
|
|
24
|
+
const interactedProviders = dynamicAuthStorageService.getInteractedProviders();
|
|
25
|
+
if (interactedProviders.length === 0) {
|
|
26
|
+
await dialogService.info(( localize(4302, 'No dynamic authentication providers')), ( localize(4303, 'No dynamic authentication providers have been used yet.')));
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const items = ( interactedProviders.map(provider => ({
|
|
30
|
+
label: provider.label,
|
|
31
|
+
description: ( localize(4304, 'Client ID: {0}', provider.clientId)),
|
|
32
|
+
provider
|
|
33
|
+
})));
|
|
34
|
+
const selected = await quickInputService.pick(items, {
|
|
35
|
+
placeHolder: ( localize(4305, 'Select a dynamic authentication provider to remove')),
|
|
36
|
+
canPickMany: true
|
|
37
|
+
});
|
|
38
|
+
if (!selected || selected.length === 0) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const providerNames = ( selected.map(item => item.provider.label)).join(', ');
|
|
42
|
+
const message = selected.length === 1
|
|
43
|
+
? ( localize(
|
|
44
|
+
4306,
|
|
45
|
+
'Are you sure you want to remove the dynamic authentication provider "{0}"?',
|
|
46
|
+
providerNames
|
|
47
|
+
))
|
|
48
|
+
: ( localize(
|
|
49
|
+
4307,
|
|
50
|
+
'Are you sure you want to remove {0} dynamic authentication providers: {1}?',
|
|
51
|
+
selected.length,
|
|
52
|
+
providerNames
|
|
53
|
+
));
|
|
54
|
+
const result = await dialogService.confirm({
|
|
55
|
+
message,
|
|
56
|
+
detail: ( localize(
|
|
57
|
+
4308,
|
|
58
|
+
'This will remove all stored authentication data for the selected provider(s). You will need to re-authenticate if you use these providers again.'
|
|
59
|
+
)),
|
|
60
|
+
primaryButton: ( localize(4309, 'Remove')),
|
|
61
|
+
type: 'warning'
|
|
62
|
+
});
|
|
63
|
+
if (!result.confirmed) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
for (const item of selected) {
|
|
67
|
+
const providerId = item.provider.providerId;
|
|
68
|
+
if (authenticationService.isAuthenticationProviderRegistered(providerId)) {
|
|
69
|
+
authenticationService.unregisterAuthenticationProvider(providerId);
|
|
70
|
+
}
|
|
71
|
+
await dynamicAuthStorageService.removeDynamicProvider(providerId);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export { RemoveDynamicAuthenticationProvidersAction };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Action2 } from "@codingame/monaco-vscode-api/vscode/vs/platform/actions/common/actions";
|
|
2
|
+
import { ServicesAccessor } from "@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation";
|
|
3
|
+
export declare class ManageTrustedExtensionsForAccountAction extends Action2 {
|
|
4
|
+
constructor();
|
|
5
|
+
run(accessor: ServicesAccessor, options?: {
|
|
6
|
+
providerId: string;
|
|
7
|
+
accountLabel: string;
|
|
8
|
+
}): Promise<void>;
|
|
9
|
+
}
|