@codingame/monaco-vscode-api 1.83.14 → 1.83.15
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/api.js +1 -1
- package/contributions.js +36 -0
- package/extensions.d.ts +83 -4
- package/extensions.js +9 -14
- package/lifecycle.js +4 -1
- package/localExtensionHost.js +207 -0
- package/missing-services.js +15 -3
- package/monaco-editor-treemending.patch +966 -955
- package/monaco.js +4 -36
- package/package.json +10 -6
- package/service-override/tools/editor.d.ts +6 -6
- package/services.d.ts +18 -18
- package/services.js +1 -0
- package/vscode/src/vs/base/common/errors.d.ts +1 -8
- package/vscode/src/vs/base/common/uri.d.ts +1 -7
- package/vscode/src/vs/platform/terminal/common/terminal.d.ts +2 -27
- package/vscode/src/vs/platform/userDataProfile/common/userDataProfile.d.ts +39 -1
- package/vscode/src/vs/platform/workspace/common/workspace.d.ts +1 -44
- package/vscode/src/vs/workbench/api/browser/statusBarExtensionPoint.js +160 -2
- package/vscode/src/vs/workbench/contrib/scm/browser/dirtydiffDecorator.js +564 -11
- package/vscode/src/vs/workbench/contrib/scm/common/scm.js +9 -1
- package/vscode/src/vs/workbench/contrib/search/browser/searchModel.js +1 -0
- package/vscode/src/vs/workbench/services/authentication/browser/authenticationService.js +594 -2
- package/vscode/src/vs/workbench/services/extensions/browser/extensionUrlHandler.js +307 -1
- package/vscode/src/vs/workbench/services/extensions/browser/webWorkerExtensionHost.d.ts +10 -0
- package/vscode/src/vs/workbench/services/extensions/common/extensionDescriptionRegistry.d.ts +2 -37
- package/vscode/src/vs/workbench/services/extensions/common/extensionHostProtocol.d.ts +2 -73
- package/vscode/src/vs/workbench/services/extensions/common/extensions.d.ts +1 -5
- package/vscode/src/vs/workbench/services/textfile/common/textfiles.js +6 -2
- package/vscode/src/vs/workbench/services/themes/common/iconExtensionPoint.js +174 -0
- package/vscode-dts/vscode.proposed.aiRelatedInformation.d.ts +49 -0
- package/vscode-dts/vscode.proposed.authGetSessions.d.ts +62 -0
- package/vscode-dts/vscode.proposed.authSession.d.ts +13 -0
- package/vscode-dts/vscode.proposed.canonicalUriProvider.d.ts +47 -0
- package/vscode-dts/vscode.proposed.chat.d.ts +25 -0
- package/vscode-dts/vscode.proposed.chatAgents.d.ts +39 -0
- package/vscode-dts/vscode.proposed.chatProvider.d.ts +38 -0
- package/vscode-dts/vscode.proposed.chatRequestAccess.d.ts +47 -0
- package/vscode-dts/vscode.proposed.chatSlashCommands.d.ts +47 -0
- package/vscode-dts/vscode.proposed.chatVariables.d.ts +35 -0
- package/vscode-dts/vscode.proposed.codiconDecoration.d.ts +48 -0
- package/vscode-dts/vscode.proposed.commentsDraftState.d.ts +18 -0
- package/vscode-dts/vscode.proposed.contribCommentEditorActionsMenu.d.ts +6 -0
- package/vscode-dts/vscode.proposed.contribCommentPeekContext.d.ts +10 -0
- package/vscode-dts/vscode.proposed.contribCommentThreadAdditionalMenu.d.ts +8 -0
- package/vscode-dts/vscode.proposed.contribEditSessions.d.ts +8 -0
- package/vscode-dts/vscode.proposed.contribEditorContentMenu.d.ts +6 -0
- package/vscode-dts/vscode.proposed.contribLabelFormatterWorkspaceTooltip.d.ts +6 -0
- package/vscode-dts/vscode.proposed.contribMenuBarHome.d.ts +6 -0
- package/vscode-dts/vscode.proposed.contribMergeEditorMenus.d.ts +6 -0
- package/vscode-dts/vscode.proposed.contribNotebookStaticPreloads.d.ts +6 -0
- package/vscode-dts/vscode.proposed.contribRemoteHelp.d.ts +6 -0
- package/vscode-dts/vscode.proposed.contribShareMenu.d.ts +7 -0
- package/vscode-dts/vscode.proposed.contribStatusBarItems.d.ts +8 -0
- package/vscode-dts/vscode.proposed.contribViewsRemote.d.ts +6 -0
- package/vscode-dts/vscode.proposed.contribViewsWelcome.d.ts +6 -0
- package/vscode-dts/vscode.proposed.customEditorMove.d.ts +29 -0
- package/vscode-dts/vscode.proposed.debugFocus.d.ts +74 -0
- package/vscode-dts/vscode.proposed.diffCommand.d.ts +38 -0
- package/vscode-dts/vscode.proposed.diffContentOptions.d.ts +16 -0
- package/vscode-dts/vscode.proposed.documentFiltersExclusive.d.ts +13 -0
- package/vscode-dts/vscode.proposed.documentPaste.d.ts +111 -0
- package/vscode-dts/vscode.proposed.dropMetadata.d.ts +60 -0
- package/vscode-dts/vscode.proposed.editSessionIdentityProvider.d.ts +71 -0
- package/vscode-dts/vscode.proposed.editorInsets.d.ts +22 -0
- package/vscode-dts/vscode.proposed.extensionRuntime.d.ts +24 -0
- package/vscode-dts/vscode.proposed.extensionsAny.d.ts +40 -0
- package/vscode-dts/vscode.proposed.externalUriOpener.d.ts +163 -0
- package/vscode-dts/vscode.proposed.fileComments.d.ts +85 -0
- package/vscode-dts/vscode.proposed.fileSearchProvider.d.ts +67 -0
- package/vscode-dts/vscode.proposed.findTextInFiles.d.ts +104 -0
- package/vscode-dts/vscode.proposed.fsChunks.d.ts +16 -0
- package/vscode-dts/vscode.proposed.handleIssueUri.d.ts +31 -0
- package/vscode-dts/vscode.proposed.idToken.d.ts +16 -0
- package/vscode-dts/vscode.proposed.inlineCompletionsAdditions.d.ts +71 -0
- package/vscode-dts/vscode.proposed.interactive.d.ts +227 -0
- package/vscode-dts/vscode.proposed.interactiveUserActions.d.ts +70 -0
- package/vscode-dts/vscode.proposed.interactiveWindow.d.ts +25 -0
- package/vscode-dts/vscode.proposed.ipc.d.ts +37 -0
- package/vscode-dts/vscode.proposed.mappedEditsProvider.d.ts +42 -0
- package/vscode-dts/vscode.proposed.notebookCellExecutionState.d.ts +52 -0
- package/vscode-dts/vscode.proposed.notebookControllerAffinityHidden.d.ts +17 -0
- package/vscode-dts/vscode.proposed.notebookDeprecated.d.ts +16 -0
- package/vscode-dts/vscode.proposed.notebookExecution.d.ts +39 -0
- package/vscode-dts/vscode.proposed.notebookKernelSource.d.ts +46 -0
- package/vscode-dts/vscode.proposed.notebookLiveShare.d.ts +21 -0
- package/vscode-dts/vscode.proposed.notebookMessaging.d.ts +68 -0
- package/vscode-dts/vscode.proposed.notebookMime.d.ts +33 -0
- package/vscode-dts/vscode.proposed.portsAttributes.d.ts +100 -0
- package/vscode-dts/vscode.proposed.profileContentHandlers.d.ts +19 -0
- package/vscode-dts/vscode.proposed.quickDiffProvider.d.ts +17 -0
- package/vscode-dts/vscode.proposed.quickPickItemTooltip.d.ts +16 -0
- package/vscode-dts/vscode.proposed.quickPickSortByLabel.d.ts +16 -0
- package/vscode-dts/vscode.proposed.readonlyMessage.d.ts +14 -0
- package/vscode-dts/vscode.proposed.resolvers.d.ts +371 -0
- package/vscode-dts/vscode.proposed.saveEditor.d.ts +35 -0
- package/vscode-dts/vscode.proposed.scmActionButton.d.ts +19 -0
- package/vscode-dts/vscode.proposed.scmHistoryProvider.d.ts +77 -0
- package/vscode-dts/vscode.proposed.scmSelectedProvider.d.ts +22 -0
- package/vscode-dts/vscode.proposed.scmTextDocument.d.ts +19 -0
- package/vscode-dts/vscode.proposed.scmValidation.d.ts +60 -0
- package/vscode-dts/vscode.proposed.shareProvider.d.ts +74 -0
- package/vscode-dts/vscode.proposed.showLocal.d.ts +19 -0
- package/vscode-dts/vscode.proposed.tabInputTextMerge.d.ts +25 -0
- package/vscode-dts/vscode.proposed.taskPresentationGroup.d.ts +16 -0
- package/vscode-dts/vscode.proposed.telemetry.d.ts +36 -0
- package/vscode-dts/vscode.proposed.terminalDataWriteEvent.d.ts +32 -0
- package/vscode-dts/vscode.proposed.terminalDimensions.d.ts +39 -0
- package/vscode-dts/vscode.proposed.terminalExecuteCommandEvent.d.ts +46 -0
- package/vscode-dts/vscode.proposed.terminalQuickFixProvider.d.ts +83 -0
- package/vscode-dts/vscode.proposed.terminalSelection.d.ts +16 -0
- package/vscode-dts/vscode.proposed.testCoverage.d.ts +198 -0
- package/vscode-dts/vscode.proposed.testMessageContextValue.d.ts +45 -0
- package/vscode-dts/vscode.proposed.testObserver.d.ts +184 -0
- package/vscode-dts/vscode.proposed.textSearchProvider.d.ts +281 -0
- package/vscode-dts/vscode.proposed.timeline.d.ts +163 -0
- package/vscode-dts/vscode.proposed.tokenInformation.d.ts +26 -0
- package/vscode-dts/vscode.proposed.treeViewActiveItem.d.ts +30 -0
- package/vscode-dts/vscode.proposed.treeViewMarkdownMessage.d.ts +28 -0
- package/vscode-dts/vscode.proposed.treeViewReveal.d.ts +13 -0
- package/vscode-dts/vscode.proposed.tunnelFactory.d.ts +44 -0
- package/vscode-dts/vscode.proposed.tunnels.d.ts +64 -0
- package/vscode-dts/vscode.proposed.windowActivity.d.ts +17 -0
- package/vscode-dts/vscode.proposed.workspaceTrust.d.ts +30 -0
- package/vscode/src/vs/base/common/ternarySearchTree.d.ts +0 -46
- package/vscode/src/vs/base/common/uriIpc.d.ts +0 -10
- package/vscode/src/vs/platform/workspace/common/editSessions.d.ts +0 -7
- package/vscode/src/vs/workbench/services/extensions/common/proxyIdentifier.d.ts +0 -44
- package/vscode/src/vs/workbench/services/search/common/search.d.ts +0 -52
- package/vscode.proposed.d.ts +0 -4787
|
@@ -1,10 +1,24 @@
|
|
|
1
|
+
import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
+
import { flatten } from 'monaco-editor/esm/vs/base/common/arrays.js';
|
|
3
|
+
import { Emitter } from 'monaco-editor/esm/vs/base/common/event.js';
|
|
4
|
+
import { Disposable, MutableDisposable, dispose } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
|
|
5
|
+
import { isFalsyOrWhitespace } from 'monaco-editor/esm/vs/base/common/strings.js';
|
|
1
6
|
import { isString } from 'monaco-editor/esm/vs/base/common/types.js';
|
|
2
7
|
import * as nls from 'monaco-editor/esm/vs/nls.js';
|
|
3
8
|
import { MenuRegistry, MenuId } from 'monaco-editor/esm/vs/platform/actions/common/actions.js';
|
|
4
9
|
import { CommandsRegistry } from 'monaco-editor/esm/vs/platform/commands/common/commands.js';
|
|
5
10
|
import { ContextKeyExpr } from 'monaco-editor/esm/vs/platform/contextkey/common/contextkey.js';
|
|
6
11
|
import '../../../../../../../override/vs/platform/dialogs/common/dialogs.js';
|
|
12
|
+
import { Severity } from 'monaco-editor/esm/vs/platform/notification/common/notification.js';
|
|
13
|
+
import { IProductService } from 'monaco-editor/esm/vs/platform/product/common/productService.js';
|
|
14
|
+
import { IQuickInputService } from 'monaco-editor/esm/vs/platform/quickinput/common/quickInput.js';
|
|
15
|
+
import { IStorageService } from 'monaco-editor/esm/vs/platform/storage/common/storage.js';
|
|
16
|
+
import { IActivityService, NumberBadge } from '../../activity/common/activity.js';
|
|
17
|
+
import { IAuthenticationService } from '../common/authentication.js';
|
|
7
18
|
import { IBrowserWorkbenchEnvironmentService } from '../../environment/browser/environmentService.js';
|
|
19
|
+
import { IExtensionService } from '../../extensions/common/extensions.js';
|
|
20
|
+
import { ExtensionsRegistry } from '../../extensions/common/extensionsRegistry.js';
|
|
21
|
+
import { IDialogService } from '../../../../platform/dialogs/common/dialogs.js';
|
|
8
22
|
function getAuthenticationProviderActivationEvent(id) { return `onAuthenticationRequest:${id}`; }
|
|
9
23
|
function readAccountUsages(storageService, providerId, accountName) {
|
|
10
24
|
const accountKey = `${providerId}-${accountName}-usages`;
|
|
@@ -72,11 +86,53 @@ function readAllowedExtensions(storageService, providerId, accountName) {
|
|
|
72
86
|
catch (err) { }
|
|
73
87
|
return trustedExtensions;
|
|
74
88
|
}
|
|
89
|
+
const SCOPESLIST_SEPARATOR = ' ';
|
|
75
90
|
CommandsRegistry.registerCommand('workbench.getCodeExchangeProxyEndpoints', function (accessor, _) {
|
|
76
91
|
const environmentService = accessor.get(IBrowserWorkbenchEnvironmentService);
|
|
77
92
|
return environmentService.options?.codeExchangeProxyEndpoints;
|
|
78
93
|
});
|
|
79
|
-
|
|
94
|
+
const authenticationDefinitionSchema = {
|
|
95
|
+
type: 'object',
|
|
96
|
+
additionalProperties: false,
|
|
97
|
+
properties: {
|
|
98
|
+
id: {
|
|
99
|
+
type: 'string',
|
|
100
|
+
description: ( nls.localizeWithPath(
|
|
101
|
+
'vs/workbench/services/authentication/browser/authenticationService',
|
|
102
|
+
'authentication.id',
|
|
103
|
+
'The id of the authentication provider.'
|
|
104
|
+
))
|
|
105
|
+
},
|
|
106
|
+
label: {
|
|
107
|
+
type: 'string',
|
|
108
|
+
description: ( nls.localizeWithPath(
|
|
109
|
+
'vs/workbench/services/authentication/browser/authenticationService',
|
|
110
|
+
'authentication.label',
|
|
111
|
+
'The human readable name of the authentication provider.'
|
|
112
|
+
)),
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
const authenticationExtPoint = ( ExtensionsRegistry.registerExtensionPoint({
|
|
117
|
+
extensionPoint: 'authentication',
|
|
118
|
+
jsonSchema: {
|
|
119
|
+
description: ( nls.localizeWithPath(
|
|
120
|
+
'vs/workbench/services/authentication/browser/authenticationService',
|
|
121
|
+
{ key: 'authenticationExtensionPoint', comment: [`'Contributes' means adds here`] },
|
|
122
|
+
'Contributes authentication'
|
|
123
|
+
)),
|
|
124
|
+
type: 'array',
|
|
125
|
+
items: authenticationDefinitionSchema
|
|
126
|
+
},
|
|
127
|
+
activationEventsGenerator: (authenticationProviders, result) => {
|
|
128
|
+
for (const authenticationProvider of authenticationProviders) {
|
|
129
|
+
if (authenticationProvider.id) {
|
|
130
|
+
result.push(`onAuthenticationRequest:${authenticationProvider.id}`);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}));
|
|
135
|
+
let placeholderMenuItem = MenuRegistry.appendMenuItem(MenuId.AccountsContext, {
|
|
80
136
|
command: {
|
|
81
137
|
id: 'noAuthenticationProviders',
|
|
82
138
|
title: ( nls.localizeWithPath(
|
|
@@ -87,4 +143,540 @@ MenuRegistry.appendMenuItem(MenuId.AccountsContext, {
|
|
|
87
143
|
precondition: ( ContextKeyExpr.false())
|
|
88
144
|
},
|
|
89
145
|
});
|
|
90
|
-
|
|
146
|
+
let AuthenticationService = class AuthenticationService extends Disposable {
|
|
147
|
+
constructor(activityService, extensionService, storageService, dialogService, quickInputService, productService) {
|
|
148
|
+
super();
|
|
149
|
+
this.activityService = activityService;
|
|
150
|
+
this.extensionService = extensionService;
|
|
151
|
+
this.storageService = storageService;
|
|
152
|
+
this.dialogService = dialogService;
|
|
153
|
+
this.quickInputService = quickInputService;
|
|
154
|
+
this.productService = productService;
|
|
155
|
+
this._signInRequestItems = ( new Map());
|
|
156
|
+
this._sessionAccessRequestItems = ( new Map());
|
|
157
|
+
this._accountBadgeDisposable = this._register(( new MutableDisposable()));
|
|
158
|
+
this._authenticationProviders = ( new Map());
|
|
159
|
+
this.declaredProviders = [];
|
|
160
|
+
this._onDidRegisterAuthenticationProvider = this._register(( new Emitter()));
|
|
161
|
+
this.onDidRegisterAuthenticationProvider = this._onDidRegisterAuthenticationProvider.event;
|
|
162
|
+
this._onDidUnregisterAuthenticationProvider = this._register(( new Emitter()));
|
|
163
|
+
this.onDidUnregisterAuthenticationProvider = this._onDidUnregisterAuthenticationProvider.event;
|
|
164
|
+
this._onDidChangeSessions = this._register(( new Emitter()));
|
|
165
|
+
this.onDidChangeSessions = this._onDidChangeSessions.event;
|
|
166
|
+
this._onDidChangeDeclaredProviders = this._register(( new Emitter()));
|
|
167
|
+
this.onDidChangeDeclaredProviders = this._onDidChangeDeclaredProviders.event;
|
|
168
|
+
authenticationExtPoint.setHandler((extensions, { added, removed }) => {
|
|
169
|
+
added.forEach(point => {
|
|
170
|
+
for (const provider of point.value) {
|
|
171
|
+
if (isFalsyOrWhitespace(provider.id)) {
|
|
172
|
+
point.collector.error(( nls.localizeWithPath(
|
|
173
|
+
'vs/workbench/services/authentication/browser/authenticationService',
|
|
174
|
+
'authentication.missingId',
|
|
175
|
+
'An authentication contribution must specify an id.'
|
|
176
|
+
)));
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
if (isFalsyOrWhitespace(provider.label)) {
|
|
180
|
+
point.collector.error(( nls.localizeWithPath(
|
|
181
|
+
'vs/workbench/services/authentication/browser/authenticationService',
|
|
182
|
+
'authentication.missingLabel',
|
|
183
|
+
'An authentication contribution must specify a label.'
|
|
184
|
+
)));
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
if (!( this.declaredProviders.some(p => p.id === provider.id))) {
|
|
188
|
+
this.declaredProviders.push(provider);
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
point.collector.error(( nls.localizeWithPath(
|
|
192
|
+
'vs/workbench/services/authentication/browser/authenticationService',
|
|
193
|
+
'authentication.idConflict',
|
|
194
|
+
"This authentication id '{0}' has already been registered",
|
|
195
|
+
provider.id
|
|
196
|
+
)));
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
const removedExtPoints = flatten(( removed.map(r => r.value)));
|
|
201
|
+
removedExtPoints.forEach(point => {
|
|
202
|
+
const index = this.declaredProviders.findIndex(provider => provider.id === point.id);
|
|
203
|
+
if (index > -1) {
|
|
204
|
+
this.declaredProviders.splice(index, 1);
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
this._onDidChangeDeclaredProviders.fire(this.declaredProviders);
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
getProviderIds() {
|
|
211
|
+
const providerIds = [];
|
|
212
|
+
this._authenticationProviders.forEach(provider => {
|
|
213
|
+
providerIds.push(provider.id);
|
|
214
|
+
});
|
|
215
|
+
return providerIds;
|
|
216
|
+
}
|
|
217
|
+
isAuthenticationProviderRegistered(id) {
|
|
218
|
+
return ( this._authenticationProviders.has(id));
|
|
219
|
+
}
|
|
220
|
+
registerAuthenticationProvider(id, authenticationProvider) {
|
|
221
|
+
this._authenticationProviders.set(id, authenticationProvider);
|
|
222
|
+
this._onDidRegisterAuthenticationProvider.fire({ id, label: authenticationProvider.label });
|
|
223
|
+
if (placeholderMenuItem) {
|
|
224
|
+
placeholderMenuItem.dispose();
|
|
225
|
+
placeholderMenuItem = undefined;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
unregisterAuthenticationProvider(id) {
|
|
229
|
+
const provider = this._authenticationProviders.get(id);
|
|
230
|
+
if (provider) {
|
|
231
|
+
provider.dispose();
|
|
232
|
+
this._authenticationProviders.delete(id);
|
|
233
|
+
this._onDidUnregisterAuthenticationProvider.fire({ id, label: provider.label });
|
|
234
|
+
const accessRequests = this._sessionAccessRequestItems.get(id) || {};
|
|
235
|
+
( Object.keys(accessRequests)).forEach(extensionId => {
|
|
236
|
+
this.removeAccessRequest(id, extensionId);
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
if (!this._authenticationProviders.size) {
|
|
240
|
+
placeholderMenuItem = MenuRegistry.appendMenuItem(MenuId.AccountsContext, {
|
|
241
|
+
command: {
|
|
242
|
+
id: 'noAuthenticationProviders',
|
|
243
|
+
title: ( nls.localizeWithPath(
|
|
244
|
+
'vs/workbench/services/authentication/browser/authenticationService',
|
|
245
|
+
'loading',
|
|
246
|
+
"Loading..."
|
|
247
|
+
)),
|
|
248
|
+
precondition: ( ContextKeyExpr.false())
|
|
249
|
+
},
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
async sessionsUpdate(id, event) {
|
|
254
|
+
const provider = this._authenticationProviders.get(id);
|
|
255
|
+
if (provider) {
|
|
256
|
+
this._onDidChangeSessions.fire({ providerId: id, label: provider.label, event: event });
|
|
257
|
+
if (event.added) {
|
|
258
|
+
await this.updateNewSessionRequests(provider, event.added);
|
|
259
|
+
}
|
|
260
|
+
if (event.removed) {
|
|
261
|
+
await this.updateAccessRequests(id, event.removed);
|
|
262
|
+
}
|
|
263
|
+
this.updateBadgeCount();
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
async updateNewSessionRequests(provider, addedSessions) {
|
|
267
|
+
const existingRequestsForProvider = this._signInRequestItems.get(provider.id);
|
|
268
|
+
if (!existingRequestsForProvider) {
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
( Object.keys(existingRequestsForProvider)).forEach(requestedScopes => {
|
|
272
|
+
if (( addedSessions.some(
|
|
273
|
+
session => session.scopes.slice().join(SCOPESLIST_SEPARATOR) === requestedScopes
|
|
274
|
+
))) {
|
|
275
|
+
const sessionRequest = existingRequestsForProvider[requestedScopes];
|
|
276
|
+
sessionRequest?.disposables.forEach(item => item.dispose());
|
|
277
|
+
delete existingRequestsForProvider[requestedScopes];
|
|
278
|
+
if (( Object.keys(existingRequestsForProvider)).length === 0) {
|
|
279
|
+
this._signInRequestItems.delete(provider.id);
|
|
280
|
+
}
|
|
281
|
+
else {
|
|
282
|
+
this._signInRequestItems.set(provider.id, existingRequestsForProvider);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
async updateAccessRequests(providerId, removedSessions) {
|
|
288
|
+
const providerRequests = this._sessionAccessRequestItems.get(providerId);
|
|
289
|
+
if (providerRequests) {
|
|
290
|
+
( Object.keys(providerRequests)).forEach(extensionId => {
|
|
291
|
+
removedSessions.forEach(removed => {
|
|
292
|
+
const indexOfSession = providerRequests[extensionId].possibleSessions.findIndex(session => session.id === removed.id);
|
|
293
|
+
if (indexOfSession) {
|
|
294
|
+
providerRequests[extensionId].possibleSessions.splice(indexOfSession, 1);
|
|
295
|
+
}
|
|
296
|
+
});
|
|
297
|
+
if (!providerRequests[extensionId].possibleSessions.length) {
|
|
298
|
+
this.removeAccessRequest(providerId, extensionId);
|
|
299
|
+
}
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
updateBadgeCount() {
|
|
304
|
+
this._accountBadgeDisposable.clear();
|
|
305
|
+
let numberOfRequests = 0;
|
|
306
|
+
this._signInRequestItems.forEach(providerRequests => {
|
|
307
|
+
( Object.keys(providerRequests)).forEach(request => {
|
|
308
|
+
numberOfRequests += providerRequests[request].requestingExtensionIds.length;
|
|
309
|
+
});
|
|
310
|
+
});
|
|
311
|
+
this._sessionAccessRequestItems.forEach(accessRequest => {
|
|
312
|
+
numberOfRequests += ( Object.keys(accessRequest)).length;
|
|
313
|
+
});
|
|
314
|
+
if (numberOfRequests > 0) {
|
|
315
|
+
const badge = ( new NumberBadge(numberOfRequests, () => ( nls.localizeWithPath(
|
|
316
|
+
'vs/workbench/services/authentication/browser/authenticationService',
|
|
317
|
+
'sign in',
|
|
318
|
+
"Sign in requested"
|
|
319
|
+
))));
|
|
320
|
+
this._accountBadgeDisposable.value = this.activityService.showAccountsActivity({ badge });
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
removeAccessRequest(providerId, extensionId) {
|
|
324
|
+
const providerRequests = this._sessionAccessRequestItems.get(providerId) || {};
|
|
325
|
+
if (providerRequests[extensionId]) {
|
|
326
|
+
dispose(providerRequests[extensionId].disposables);
|
|
327
|
+
delete providerRequests[extensionId];
|
|
328
|
+
this.updateBadgeCount();
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
isAccessAllowed(providerId, accountName, extensionId) {
|
|
332
|
+
const allowList = readAllowedExtensions(this.storageService, providerId, accountName);
|
|
333
|
+
const extensionData = allowList.find(extension => extension.id === extensionId);
|
|
334
|
+
if (extensionData) {
|
|
335
|
+
return extensionData.allowed !== undefined
|
|
336
|
+
? extensionData.allowed
|
|
337
|
+
: true;
|
|
338
|
+
}
|
|
339
|
+
if (this.productService.trustedExtensionAuthAccess?.includes(extensionId)) {
|
|
340
|
+
return true;
|
|
341
|
+
}
|
|
342
|
+
return undefined;
|
|
343
|
+
}
|
|
344
|
+
updateAllowedExtension(providerId, accountName, extensionId, extensionName, isAllowed) {
|
|
345
|
+
const allowList = readAllowedExtensions(this.storageService, providerId, accountName);
|
|
346
|
+
const index = allowList.findIndex(extension => extension.id === extensionId);
|
|
347
|
+
if (index === -1) {
|
|
348
|
+
allowList.push({ id: extensionId, name: extensionName, allowed: isAllowed });
|
|
349
|
+
}
|
|
350
|
+
else {
|
|
351
|
+
allowList[index].allowed = isAllowed;
|
|
352
|
+
}
|
|
353
|
+
this.storageService.store(`${providerId}-${accountName}`, JSON.stringify(allowList), -1 , 0 );
|
|
354
|
+
}
|
|
355
|
+
updateSessionPreference(providerId, extensionId, session) {
|
|
356
|
+
const key = `${extensionId}-${providerId}-${session.scopes.join(' ')}`;
|
|
357
|
+
this.storageService.store(key, session.id, 1 , 1 );
|
|
358
|
+
this.storageService.store(key, session.id, -1 , 1 );
|
|
359
|
+
}
|
|
360
|
+
getSessionPreference(providerId, extensionId, scopes) {
|
|
361
|
+
const key = `${extensionId}-${providerId}-${scopes.join(' ')}`;
|
|
362
|
+
return this.storageService.get(key, 1 ) ?? this.storageService.get(key, -1 );
|
|
363
|
+
}
|
|
364
|
+
removeSessionPreference(providerId, extensionId, scopes) {
|
|
365
|
+
const key = `${extensionId}-${providerId}-${scopes.join(' ')}`;
|
|
366
|
+
this.storageService.remove(key, 1 );
|
|
367
|
+
this.storageService.remove(key, -1 );
|
|
368
|
+
}
|
|
369
|
+
async showGetSessionPrompt(providerId, accountName, extensionId, extensionName) {
|
|
370
|
+
const providerName = this.getLabel(providerId);
|
|
371
|
+
let SessionPromptChoice;
|
|
372
|
+
( (function(SessionPromptChoice) {
|
|
373
|
+
SessionPromptChoice[SessionPromptChoice["Allow"] = 0] = "Allow";
|
|
374
|
+
SessionPromptChoice[SessionPromptChoice["Deny"] = 1] = "Deny";
|
|
375
|
+
SessionPromptChoice[SessionPromptChoice["Cancel"] = 2] = "Cancel";
|
|
376
|
+
})(SessionPromptChoice || (SessionPromptChoice = {})));
|
|
377
|
+
const { result } = await this.dialogService.prompt({
|
|
378
|
+
type: Severity.Info,
|
|
379
|
+
message: ( nls.localizeWithPath(
|
|
380
|
+
'vs/workbench/services/authentication/browser/authenticationService',
|
|
381
|
+
'confirmAuthenticationAccess',
|
|
382
|
+
"The extension '{0}' wants to access the {1} account '{2}'.",
|
|
383
|
+
extensionName,
|
|
384
|
+
providerName,
|
|
385
|
+
accountName
|
|
386
|
+
)),
|
|
387
|
+
buttons: [
|
|
388
|
+
{
|
|
389
|
+
label: ( nls.localizeWithPath(
|
|
390
|
+
'vs/workbench/services/authentication/browser/authenticationService',
|
|
391
|
+
{ key: 'allow', comment: ['&& denotes a mnemonic'] },
|
|
392
|
+
"&&Allow"
|
|
393
|
+
)),
|
|
394
|
+
run: () => SessionPromptChoice.Allow
|
|
395
|
+
},
|
|
396
|
+
{
|
|
397
|
+
label: ( nls.localizeWithPath(
|
|
398
|
+
'vs/workbench/services/authentication/browser/authenticationService',
|
|
399
|
+
{ key: 'deny', comment: ['&& denotes a mnemonic'] },
|
|
400
|
+
"&&Deny"
|
|
401
|
+
)),
|
|
402
|
+
run: () => SessionPromptChoice.Deny
|
|
403
|
+
}
|
|
404
|
+
],
|
|
405
|
+
cancelButton: {
|
|
406
|
+
run: () => SessionPromptChoice.Cancel
|
|
407
|
+
}
|
|
408
|
+
});
|
|
409
|
+
if (result !== SessionPromptChoice.Cancel) {
|
|
410
|
+
this.updateAllowedExtension(providerId, accountName, extensionId, extensionName, result === SessionPromptChoice.Allow);
|
|
411
|
+
this.removeAccessRequest(providerId, extensionId);
|
|
412
|
+
}
|
|
413
|
+
return result === SessionPromptChoice.Allow;
|
|
414
|
+
}
|
|
415
|
+
async selectSession(providerId, extensionId, extensionName, scopes, availableSessions) {
|
|
416
|
+
return ( new Promise((resolve, reject) => {
|
|
417
|
+
if (!availableSessions.length) {
|
|
418
|
+
reject('No available sessions');
|
|
419
|
+
}
|
|
420
|
+
const quickPick = this.quickInputService.createQuickPick();
|
|
421
|
+
quickPick.ignoreFocusOut = true;
|
|
422
|
+
const items = ( availableSessions.map(session => {
|
|
423
|
+
return {
|
|
424
|
+
label: session.account.label,
|
|
425
|
+
session: session
|
|
426
|
+
};
|
|
427
|
+
}));
|
|
428
|
+
items.push({
|
|
429
|
+
label: ( nls.localizeWithPath(
|
|
430
|
+
'vs/workbench/services/authentication/browser/authenticationService',
|
|
431
|
+
'useOtherAccount',
|
|
432
|
+
"Sign in to another account"
|
|
433
|
+
))
|
|
434
|
+
});
|
|
435
|
+
const providerName = this.getLabel(providerId);
|
|
436
|
+
quickPick.items = items;
|
|
437
|
+
quickPick.title = ( nls.localizeWithPath('vs/workbench/services/authentication/browser/authenticationService', {
|
|
438
|
+
key: 'selectAccount',
|
|
439
|
+
comment: ['The placeholder {0} is the name of an extension. {1} is the name of the type of account, such as Microsoft or GitHub.']
|
|
440
|
+
}, "The extension '{0}' wants to access a {1} account", extensionName, providerName));
|
|
441
|
+
quickPick.placeholder = ( nls.localizeWithPath(
|
|
442
|
+
'vs/workbench/services/authentication/browser/authenticationService',
|
|
443
|
+
'getSessionPlateholder',
|
|
444
|
+
"Select an account for '{0}' to use or Esc to cancel",
|
|
445
|
+
extensionName
|
|
446
|
+
));
|
|
447
|
+
quickPick.onDidAccept(async (_) => {
|
|
448
|
+
const session = quickPick.selectedItems[0].session ?? (await this.createSession(providerId, scopes));
|
|
449
|
+
const accountName = session.account.label;
|
|
450
|
+
this.updateAllowedExtension(providerId, accountName, extensionId, extensionName, true);
|
|
451
|
+
this.updateSessionPreference(providerId, extensionId, session);
|
|
452
|
+
this.removeAccessRequest(providerId, extensionId);
|
|
453
|
+
quickPick.dispose();
|
|
454
|
+
resolve(session);
|
|
455
|
+
});
|
|
456
|
+
quickPick.onDidHide(_ => {
|
|
457
|
+
if (!quickPick.selectedItems[0]) {
|
|
458
|
+
reject('User did not consent to account access');
|
|
459
|
+
}
|
|
460
|
+
quickPick.dispose();
|
|
461
|
+
});
|
|
462
|
+
quickPick.show();
|
|
463
|
+
}));
|
|
464
|
+
}
|
|
465
|
+
async completeSessionAccessRequest(providerId, extensionId, extensionName, scopes) {
|
|
466
|
+
const providerRequests = this._sessionAccessRequestItems.get(providerId) || {};
|
|
467
|
+
const existingRequest = providerRequests[extensionId];
|
|
468
|
+
if (!existingRequest) {
|
|
469
|
+
return;
|
|
470
|
+
}
|
|
471
|
+
const possibleSessions = existingRequest.possibleSessions;
|
|
472
|
+
const supportsMultipleAccounts = this.supportsMultipleAccounts(providerId);
|
|
473
|
+
let session;
|
|
474
|
+
if (supportsMultipleAccounts) {
|
|
475
|
+
try {
|
|
476
|
+
session = await this.selectSession(providerId, extensionId, extensionName, scopes, possibleSessions);
|
|
477
|
+
}
|
|
478
|
+
catch (_) {
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
else {
|
|
482
|
+
const approved = await this.showGetSessionPrompt(providerId, possibleSessions[0].account.label, extensionId, extensionName);
|
|
483
|
+
if (approved) {
|
|
484
|
+
session = possibleSessions[0];
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
if (session) {
|
|
488
|
+
addAccountUsage(this.storageService, providerId, session.account.label, extensionId, extensionName);
|
|
489
|
+
const providerName = this.getLabel(providerId);
|
|
490
|
+
this._onDidChangeSessions.fire({ providerId, label: providerName, event: { added: [], removed: [], changed: [session] } });
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
requestSessionAccess(providerId, extensionId, extensionName, scopes, possibleSessions) {
|
|
494
|
+
const providerRequests = this._sessionAccessRequestItems.get(providerId) || {};
|
|
495
|
+
const hasExistingRequest = providerRequests[extensionId];
|
|
496
|
+
if (hasExistingRequest) {
|
|
497
|
+
return;
|
|
498
|
+
}
|
|
499
|
+
const menuItem = MenuRegistry.appendMenuItem(MenuId.AccountsContext, {
|
|
500
|
+
group: '3_accessRequests',
|
|
501
|
+
command: {
|
|
502
|
+
id: `${providerId}${extensionId}Access`,
|
|
503
|
+
title: ( nls.localizeWithPath('vs/workbench/services/authentication/browser/authenticationService', {
|
|
504
|
+
key: 'accessRequest',
|
|
505
|
+
comment: [`The placeholder {0} will be replaced with an authentication provider''s label. {1} will be replaced with an extension name. (1) is to indicate that this menu item contributes to a badge count`]
|
|
506
|
+
}, "Grant access to {0} for {1}... (1)", this.getLabel(providerId), extensionName))
|
|
507
|
+
}
|
|
508
|
+
});
|
|
509
|
+
const accessCommand = CommandsRegistry.registerCommand({
|
|
510
|
+
id: `${providerId}${extensionId}Access`,
|
|
511
|
+
handler: async (accessor) => {
|
|
512
|
+
const authenticationService = accessor.get(IAuthenticationService);
|
|
513
|
+
authenticationService.completeSessionAccessRequest(providerId, extensionId, extensionName, scopes);
|
|
514
|
+
}
|
|
515
|
+
});
|
|
516
|
+
providerRequests[extensionId] = { possibleSessions, disposables: [menuItem, accessCommand] };
|
|
517
|
+
this._sessionAccessRequestItems.set(providerId, providerRequests);
|
|
518
|
+
this.updateBadgeCount();
|
|
519
|
+
}
|
|
520
|
+
async requestNewSession(providerId, scopes, extensionId, extensionName) {
|
|
521
|
+
let provider = this._authenticationProviders.get(providerId);
|
|
522
|
+
if (!provider) {
|
|
523
|
+
await ( new Promise((resolve, _) => {
|
|
524
|
+
const dispose = this.onDidRegisterAuthenticationProvider(e => {
|
|
525
|
+
if (e.id === providerId) {
|
|
526
|
+
provider = this._authenticationProviders.get(providerId);
|
|
527
|
+
dispose.dispose();
|
|
528
|
+
resolve();
|
|
529
|
+
}
|
|
530
|
+
});
|
|
531
|
+
}));
|
|
532
|
+
}
|
|
533
|
+
if (!provider) {
|
|
534
|
+
return;
|
|
535
|
+
}
|
|
536
|
+
const providerRequests = this._signInRequestItems.get(providerId);
|
|
537
|
+
const scopesList = scopes.join(SCOPESLIST_SEPARATOR);
|
|
538
|
+
const extensionHasExistingRequest = providerRequests
|
|
539
|
+
&& providerRequests[scopesList]
|
|
540
|
+
&& providerRequests[scopesList].requestingExtensionIds.includes(extensionId);
|
|
541
|
+
if (extensionHasExistingRequest) {
|
|
542
|
+
return;
|
|
543
|
+
}
|
|
544
|
+
const commandId = `${providerId}:${extensionId}:signIn${( Object.keys(providerRequests || [])).length}`;
|
|
545
|
+
const menuItem = MenuRegistry.appendMenuItem(MenuId.AccountsContext, {
|
|
546
|
+
group: '2_signInRequests',
|
|
547
|
+
command: {
|
|
548
|
+
id: commandId,
|
|
549
|
+
title: ( nls.localizeWithPath('vs/workbench/services/authentication/browser/authenticationService', {
|
|
550
|
+
key: 'signInRequest',
|
|
551
|
+
comment: [`The placeholder {0} will be replaced with an authentication provider's label. {1} will be replaced with an extension name. (1) is to indicate that this menu item contributes to a badge count.`]
|
|
552
|
+
}, "Sign in with {0} to use {1} (1)", provider.label, extensionName))
|
|
553
|
+
}
|
|
554
|
+
});
|
|
555
|
+
const signInCommand = CommandsRegistry.registerCommand({
|
|
556
|
+
id: commandId,
|
|
557
|
+
handler: async (accessor) => {
|
|
558
|
+
const authenticationService = accessor.get(IAuthenticationService);
|
|
559
|
+
const session = await authenticationService.createSession(providerId, scopes);
|
|
560
|
+
this.updateAllowedExtension(providerId, session.account.label, extensionId, extensionName, true);
|
|
561
|
+
this.updateSessionPreference(providerId, extensionId, session);
|
|
562
|
+
}
|
|
563
|
+
});
|
|
564
|
+
if (providerRequests) {
|
|
565
|
+
const existingRequest = providerRequests[scopesList] || { disposables: [], requestingExtensionIds: [] };
|
|
566
|
+
providerRequests[scopesList] = {
|
|
567
|
+
disposables: [...existingRequest.disposables, menuItem, signInCommand],
|
|
568
|
+
requestingExtensionIds: [...existingRequest.requestingExtensionIds, extensionId]
|
|
569
|
+
};
|
|
570
|
+
this._signInRequestItems.set(providerId, providerRequests);
|
|
571
|
+
}
|
|
572
|
+
else {
|
|
573
|
+
this._signInRequestItems.set(providerId, {
|
|
574
|
+
[scopesList]: {
|
|
575
|
+
disposables: [menuItem, signInCommand],
|
|
576
|
+
requestingExtensionIds: [extensionId]
|
|
577
|
+
}
|
|
578
|
+
});
|
|
579
|
+
}
|
|
580
|
+
this.updateBadgeCount();
|
|
581
|
+
}
|
|
582
|
+
getLabel(id) {
|
|
583
|
+
const authProvider = this._authenticationProviders.get(id);
|
|
584
|
+
if (authProvider) {
|
|
585
|
+
return authProvider.label;
|
|
586
|
+
}
|
|
587
|
+
else {
|
|
588
|
+
throw new Error(`No authentication provider '${id}' is currently registered.`);
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
supportsMultipleAccounts(id) {
|
|
592
|
+
const authProvider = this._authenticationProviders.get(id);
|
|
593
|
+
if (authProvider) {
|
|
594
|
+
return authProvider.supportsMultipleAccounts;
|
|
595
|
+
}
|
|
596
|
+
else {
|
|
597
|
+
throw new Error(`No authentication provider '${id}' is currently registered.`);
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
async tryActivateProvider(providerId, activateImmediate) {
|
|
601
|
+
await this.extensionService.activateByEvent(getAuthenticationProviderActivationEvent(providerId), activateImmediate ? 1 : 0 );
|
|
602
|
+
let provider = this._authenticationProviders.get(providerId);
|
|
603
|
+
if (provider) {
|
|
604
|
+
return provider;
|
|
605
|
+
}
|
|
606
|
+
const didRegister = ( new Promise((resolve, _) => {
|
|
607
|
+
this.onDidRegisterAuthenticationProvider(e => {
|
|
608
|
+
if (e.id === providerId) {
|
|
609
|
+
provider = this._authenticationProviders.get(providerId);
|
|
610
|
+
if (provider) {
|
|
611
|
+
resolve(provider);
|
|
612
|
+
}
|
|
613
|
+
else {
|
|
614
|
+
throw new Error(`No authentication provider '${providerId}' is currently registered.`);
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
});
|
|
618
|
+
}));
|
|
619
|
+
const didTimeout = ( new Promise((_, reject) => {
|
|
620
|
+
setTimeout(() => {
|
|
621
|
+
reject('Timed out waiting for authentication provider to register');
|
|
622
|
+
}, 5000);
|
|
623
|
+
}));
|
|
624
|
+
return Promise.race([didRegister, didTimeout]);
|
|
625
|
+
}
|
|
626
|
+
async getSessions(id, scopes, activateImmediate = false) {
|
|
627
|
+
const authProvider = this._authenticationProviders.get(id) || (await this.tryActivateProvider(id, activateImmediate));
|
|
628
|
+
if (authProvider) {
|
|
629
|
+
return await authProvider.getSessions(scopes);
|
|
630
|
+
}
|
|
631
|
+
else {
|
|
632
|
+
throw new Error(`No authentication provider '${id}' is currently registered.`);
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
async createSession(id, scopes, options) {
|
|
636
|
+
const authProvider = this._authenticationProviders.get(id) || (await this.tryActivateProvider(id, !!options?.activateImmediate));
|
|
637
|
+
if (authProvider) {
|
|
638
|
+
return await authProvider.createSession(scopes, {
|
|
639
|
+
sessionToRecreate: options?.sessionToRecreate
|
|
640
|
+
});
|
|
641
|
+
}
|
|
642
|
+
else {
|
|
643
|
+
throw new Error(`No authentication provider '${id}' is currently registered.`);
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
async removeSession(id, sessionId) {
|
|
647
|
+
const authProvider = this._authenticationProviders.get(id);
|
|
648
|
+
if (authProvider) {
|
|
649
|
+
return authProvider.removeSession(sessionId);
|
|
650
|
+
}
|
|
651
|
+
else {
|
|
652
|
+
throw new Error(`No authentication provider '${id}' is currently registered.`);
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
async manageTrustedExtensionsForAccount(id, accountName) {
|
|
656
|
+
const authProvider = this._authenticationProviders.get(id);
|
|
657
|
+
if (authProvider) {
|
|
658
|
+
return authProvider.manageTrustedExtensions(accountName);
|
|
659
|
+
}
|
|
660
|
+
else {
|
|
661
|
+
throw new Error(`No authentication provider '${id}' is currently registered.`);
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
async removeAccountSessions(id, accountName, sessions) {
|
|
665
|
+
const authProvider = this._authenticationProviders.get(id);
|
|
666
|
+
if (authProvider) {
|
|
667
|
+
return authProvider.removeAccountSessions(accountName, sessions);
|
|
668
|
+
}
|
|
669
|
+
else {
|
|
670
|
+
throw new Error(`No authentication provider '${id}' is currently registered.`);
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
};
|
|
674
|
+
AuthenticationService = ( __decorate([
|
|
675
|
+
( __param(0, IActivityService)),
|
|
676
|
+
( __param(1, IExtensionService)),
|
|
677
|
+
( __param(2, IStorageService)),
|
|
678
|
+
( __param(3, IDialogService)),
|
|
679
|
+
( __param(4, IQuickInputService)),
|
|
680
|
+
( __param(5, IProductService))
|
|
681
|
+
], AuthenticationService));
|
|
682
|
+
export { AuthenticationService, addAccountUsage, getAuthenticationProviderActivationEvent, getCurrentAuthenticationSessionInfo, readAccountUsages, readAllowedExtensions, removeAccountUsage };
|