@codingame/monaco-vscode-authentication-service-override 25.1.2 → 26.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.
Files changed (14) hide show
  1. package/package.json +2 -2
  2. package/vscode/src/vs/workbench/contrib/authentication/browser/actions/manageAccountPreferencesForExtensionAction.js +59 -52
  3. package/vscode/src/vs/workbench/contrib/authentication/browser/actions/manageAccountPreferencesForMcpServerAction.js +43 -43
  4. package/vscode/src/vs/workbench/contrib/authentication/browser/actions/manageAccountsAction.js +50 -26
  5. package/vscode/src/vs/workbench/contrib/authentication/browser/actions/manageDynamicAuthenticationProvidersAction.js +19 -19
  6. package/vscode/src/vs/workbench/contrib/authentication/browser/actions/manageTrustedExtensionsForAccountAction.js +41 -43
  7. package/vscode/src/vs/workbench/contrib/authentication/browser/actions/manageTrustedMcpServersForAccountAction.js +40 -40
  8. package/vscode/src/vs/workbench/contrib/authentication/browser/actions/signOutOfAccountAction.js +18 -12
  9. package/vscode/src/vs/workbench/contrib/authentication/browser/authentication.contribution.js +33 -27
  10. package/vscode/src/vs/workbench/services/authentication/browser/authenticationAccessService.js +22 -23
  11. package/vscode/src/vs/workbench/services/authentication/browser/authenticationExtensionsService.js +130 -78
  12. package/vscode/src/vs/workbench/services/authentication/browser/authenticationQueryService.js +97 -65
  13. package/vscode/src/vs/workbench/services/authentication/browser/authenticationUsageService.js +14 -17
  14. package/vscode/src/vs/workbench/services/authentication/browser/dynamicAuthenticationProviderStorageService.js +54 -27
@@ -6,7 +6,7 @@ import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
6
6
  import { MenuRegistry, MenuId } from '@codingame/monaco-vscode-api/vscode/vs/platform/actions/common/actions';
7
7
  import { CommandsRegistry } from '@codingame/monaco-vscode-api/vscode/vs/platform/commands/common/commands';
8
8
  import { IDialogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/dialogs/common/dialogs.service';
9
- import '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/extensions';
9
+ import { registerSingleton, InstantiationType } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/extensions';
10
10
  import '@codingame/monaco-vscode-api/vscode/vs/platform/notification/common/notification';
11
11
  import { IQuickInputService } from '@codingame/monaco-vscode-api/vscode/vs/platform/quickinput/common/quickInput.service';
12
12
  import { StorageScope, StorageTarget } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage';
@@ -16,15 +16,24 @@ import { IActivityService } from '@codingame/monaco-vscode-api/vscode/vs/workben
16
16
  import { IAuthenticationAccessService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/authentication/browser/authenticationAccessService.service';
17
17
  import { IAuthenticationUsageService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/authentication/browser/authenticationUsageService.service';
18
18
  import { isAuthenticationWwwAuthenticateRequest } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/authentication/common/authentication';
19
- import { IAuthenticationService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/authentication/common/authentication.service';
19
+ import { IAuthenticationService, IAuthenticationExtensionsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/authentication/common/authentication.service';
20
20
  import { Emitter } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
21
21
  import { IProductService } from '@codingame/monaco-vscode-api/vscode/vs/platform/product/common/productService.service';
22
22
  import { ExtensionIdentifier } from '@codingame/monaco-vscode-api/vscode/vs/platform/extensions/common/extensions';
23
23
  import Severity from '@codingame/monaco-vscode-api/vscode/vs/base/common/severity';
24
24
 
25
- const SCOPESLIST_SEPARATOR = ' ';
25
+ const SCOPESLIST_SEPARATOR = " ";
26
26
  let AuthenticationExtensionsService = class AuthenticationExtensionsService extends Disposable {
27
- constructor(activityService, storageService, dialogService, quickInputService, _productService, _authenticationService, _authenticationUsageService, _authenticationAccessService) {
27
+ constructor(
28
+ activityService,
29
+ storageService,
30
+ dialogService,
31
+ quickInputService,
32
+ _productService,
33
+ _authenticationService,
34
+ _authenticationUsageService,
35
+ _authenticationAccessService
36
+ ) {
28
37
  super();
29
38
  this.activityService = activityService;
30
39
  this.storageService = storageService;
@@ -41,7 +50,7 @@ let AuthenticationExtensionsService = class AuthenticationExtensionsService exte
41
50
  this.onDidChangeAccountPreference = this._onDidAccountPreferenceChange.event;
42
51
  this._inheritAuthAccountPreferenceParentToChildren = this._productService.inheritAuthAccountPreference || {};
43
52
  this._inheritAuthAccountPreferenceChildToParent = Object.entries(this._inheritAuthAccountPreferenceParentToChildren).reduce((acc, [parent, children]) => {
44
- children.forEach((child) => {
53
+ children.forEach(child => {
45
54
  acc[child] = parent;
46
55
  });
47
56
  return acc;
@@ -77,8 +86,7 @@ let AuthenticationExtensionsService = class AuthenticationExtensionsService exte
77
86
  delete existingRequestsForProvider[requestedScopes];
78
87
  if (( Object.keys(existingRequestsForProvider)).length === 0) {
79
88
  this._signInRequestItems.delete(providerId);
80
- }
81
- else {
89
+ } else {
82
90
  this._signInRequestItems.set(providerId, existingRequestsForProvider);
83
91
  }
84
92
  this.updateBadgeCount();
@@ -113,8 +121,10 @@ let AuthenticationExtensionsService = class AuthenticationExtensionsService exte
113
121
  numberOfRequests += ( Object.keys(accessRequest)).length;
114
122
  });
115
123
  if (numberOfRequests > 0) {
116
- const badge = ( new NumberBadge(numberOfRequests, () => ( localize(13716, "Sign in requested"))));
117
- this._accountBadgeDisposable.value = this.activityService.showAccountsActivity({ badge });
124
+ const badge = ( new NumberBadge(numberOfRequests, () => ( localize(14098, "Sign in requested"))));
125
+ this._accountBadgeDisposable.value = this.activityService.showAccountsActivity({
126
+ badge
127
+ });
118
128
  }
119
129
  }
120
130
  removeAccessRequest(providerId, extensionId) {
@@ -133,16 +143,25 @@ let AuthenticationExtensionsService = class AuthenticationExtensionsService exte
133
143
  this.storageService.store(key, account.label, StorageScope.APPLICATION, StorageTarget.MACHINE);
134
144
  const childrenExtensions = this._inheritAuthAccountPreferenceParentToChildren[parentExtensionId];
135
145
  const extensionIds = childrenExtensions ? [parentExtensionId, ...childrenExtensions] : [parentExtensionId];
136
- this._onDidAccountPreferenceChange.fire({ extensionIds, providerId });
146
+ this._onDidAccountPreferenceChange.fire({
147
+ extensionIds,
148
+ providerId
149
+ });
137
150
  }
138
151
  getAccountPreference(extensionId, providerId) {
139
152
  const realExtensionId = ExtensionIdentifier.toKey(extensionId);
140
- const key = this._getKey(this._inheritAuthAccountPreferenceChildToParent[realExtensionId] ?? realExtensionId, providerId);
153
+ const key = this._getKey(
154
+ this._inheritAuthAccountPreferenceChildToParent[realExtensionId] ?? realExtensionId,
155
+ providerId
156
+ );
141
157
  return this.storageService.get(key, StorageScope.WORKSPACE) ?? this.storageService.get(key, StorageScope.APPLICATION);
142
158
  }
143
159
  removeAccountPreference(extensionId, providerId) {
144
160
  const realExtensionId = ExtensionIdentifier.toKey(extensionId);
145
- const key = this._getKey(this._inheritAuthAccountPreferenceChildToParent[realExtensionId] ?? realExtensionId, providerId);
161
+ const key = this._getKey(
162
+ this._inheritAuthAccountPreferenceChildToParent[realExtensionId] ?? realExtensionId,
163
+ providerId
164
+ );
146
165
  this.storageService.remove(key, StorageScope.WORKSPACE);
147
166
  this.storageService.remove(key, StorageScope.APPLICATION);
148
167
  }
@@ -172,52 +191,60 @@ let AuthenticationExtensionsService = class AuthenticationExtensionsService exte
172
191
  }
173
192
  async showGetSessionPrompt(provider, accountName, extensionId, extensionName) {
174
193
  let SessionPromptChoice;
175
- (function (SessionPromptChoice) {
194
+ (function(SessionPromptChoice) {
176
195
  SessionPromptChoice[SessionPromptChoice["Allow"] = 0] = "Allow";
177
196
  SessionPromptChoice[SessionPromptChoice["Deny"] = 1] = "Deny";
178
197
  SessionPromptChoice[SessionPromptChoice["Cancel"] = 2] = "Cancel";
179
198
  })(SessionPromptChoice || (SessionPromptChoice = {}));
180
- const { result } = await this.dialogService.prompt({
199
+ const {
200
+ result
201
+ } = await this.dialogService.prompt({
181
202
  type: Severity.Info,
182
203
  message: ( localize(
183
- 13717,
204
+ 14099,
184
205
  "The extension '{0}' wants to access the {1} account '{2}'.",
185
206
  extensionName,
186
207
  provider.label,
187
208
  accountName
188
209
  )),
189
- buttons: [
190
- {
191
- label: ( localize(13718, "&&Allow")),
192
- run: () => SessionPromptChoice.Allow
193
- },
194
- {
195
- label: ( localize(13719, "&&Deny")),
196
- run: () => SessionPromptChoice.Deny
197
- }
198
- ],
210
+ buttons: [{
211
+ label: ( localize(14100, "&&Allow")),
212
+ run: () => SessionPromptChoice.Allow
213
+ }, {
214
+ label: ( localize(14101, "&&Deny")),
215
+ run: () => SessionPromptChoice.Deny
216
+ }],
199
217
  cancelButton: {
200
218
  run: () => SessionPromptChoice.Cancel
201
219
  }
202
220
  });
203
221
  if (result !== SessionPromptChoice.Cancel) {
204
- this._authenticationAccessService.updateAllowedExtensions(provider.id, accountName, [{ id: extensionId, name: extensionName, allowed: result === SessionPromptChoice.Allow }]);
222
+ this._authenticationAccessService.updateAllowedExtensions(provider.id, accountName, [{
223
+ id: extensionId,
224
+ name: extensionName,
225
+ allowed: result === SessionPromptChoice.Allow
226
+ }]);
205
227
  this.removeAccessRequest(provider.id, extensionId);
206
228
  }
207
229
  return result === SessionPromptChoice.Allow;
208
230
  }
209
- async selectSession(providerId, extensionId, extensionName, scopeListOrRequest, availableSessions) {
231
+ async selectSession(
232
+ providerId,
233
+ extensionId,
234
+ extensionName,
235
+ scopeListOrRequest,
236
+ availableSessions
237
+ ) {
210
238
  const allAccounts = await this._authenticationService.getAccounts(providerId);
211
239
  if (!allAccounts.length) {
212
- throw ( new Error('No accounts available'));
240
+ throw ( new Error("No accounts available"));
213
241
  }
214
242
  const disposables = ( new DisposableStore());
215
243
  const quickPick = disposables.add(this.quickInputService.createQuickPick());
216
244
  quickPick.ignoreFocusOut = true;
217
245
  const accountsWithSessions = ( new Set());
218
- const items = ( availableSessions
219
- .filter(session => !( accountsWithSessions.has(session.account.label)) && accountsWithSessions.add(session.account.label))
220
- .map(session => {
246
+ const items = (
247
+ availableSessions.filter(session => !( accountsWithSessions.has(session.account.label)) && accountsWithSessions.add(session.account.label)).map(session => {
221
248
  return {
222
249
  label: session.account.label,
223
250
  session: session
@@ -225,45 +252,55 @@ let AuthenticationExtensionsService = class AuthenticationExtensionsService exte
225
252
  }));
226
253
  allAccounts.forEach(account => {
227
254
  if (!( accountsWithSessions.has(account.label))) {
228
- items.push({ label: account.label, account });
255
+ items.push({
256
+ label: account.label,
257
+ account
258
+ });
229
259
  }
230
260
  });
231
- items.push({ label: ( localize(13720, "Sign in to another account")) });
261
+ items.push({
262
+ label: ( localize(14102, "Sign in to another account"))
263
+ });
232
264
  quickPick.items = items;
233
265
  quickPick.title = ( localize(
234
- 13721,
266
+ 14103,
235
267
  "The extension '{0}' wants to access a {1} account",
236
268
  extensionName,
237
269
  this._authenticationService.getProvider(providerId).label
238
270
  ));
239
271
  quickPick.placeholder = ( localize(
240
- 13722,
272
+ 14104,
241
273
  "Select an account for '{0}' to use or Esc to cancel",
242
274
  extensionName
243
275
  ));
244
276
  return await ( new Promise((resolve, reject) => {
245
- disposables.add(quickPick.onDidAccept(async (_) => {
277
+ disposables.add(quickPick.onDidAccept(async _ => {
246
278
  quickPick.dispose();
247
279
  let session = quickPick.selectedItems[0].session;
248
280
  if (!session) {
249
281
  const account = quickPick.selectedItems[0].account;
250
282
  try {
251
- session = await this._authenticationService.createSession(providerId, scopeListOrRequest, { account });
252
- }
253
- catch (e) {
283
+ session = await this._authenticationService.createSession(providerId, scopeListOrRequest, {
284
+ account
285
+ });
286
+ } catch (e) {
254
287
  reject(e);
255
288
  return;
256
289
  }
257
290
  }
258
291
  const accountName = session.account.label;
259
- this._authenticationAccessService.updateAllowedExtensions(providerId, accountName, [{ id: extensionId, name: extensionName, allowed: true }]);
292
+ this._authenticationAccessService.updateAllowedExtensions(providerId, accountName, [{
293
+ id: extensionId,
294
+ name: extensionName,
295
+ allowed: true
296
+ }]);
260
297
  this._updateAccountAndSessionPreferences(providerId, extensionId, session);
261
298
  this.removeAccessRequest(providerId, extensionId);
262
299
  resolve(session);
263
300
  }));
264
301
  disposables.add(quickPick.onDidHide(_ => {
265
302
  if (!quickPick.selectedItems[0]) {
266
- reject('User did not consent to account access');
303
+ reject("User did not consent to account access");
267
304
  }
268
305
  disposables.dispose();
269
306
  }));
@@ -283,22 +320,37 @@ let AuthenticationExtensionsService = class AuthenticationExtensionsService exte
283
320
  let session;
284
321
  if (provider.supportsMultipleAccounts) {
285
322
  try {
286
- session = await this.selectSession(provider.id, extensionId, extensionName, scopeListOrRequest, possibleSessions);
287
- }
288
- catch (_) {
289
- }
290
- }
291
- else {
323
+ session = await this.selectSession(
324
+ provider.id,
325
+ extensionId,
326
+ extensionName,
327
+ scopeListOrRequest,
328
+ possibleSessions
329
+ );
330
+ } catch (_) {}
331
+ } else {
292
332
  const approved = await this.showGetSessionPrompt(provider, possibleSessions[0].account.label, extensionId, extensionName);
293
333
  if (approved) {
294
334
  session = possibleSessions[0];
295
335
  }
296
336
  }
297
337
  if (session) {
298
- this._authenticationUsageService.addAccountUsage(provider.id, session.account.label, session.scopes, extensionId, extensionName);
338
+ this._authenticationUsageService.addAccountUsage(
339
+ provider.id,
340
+ session.account.label,
341
+ session.scopes,
342
+ extensionId,
343
+ extensionName
344
+ );
299
345
  }
300
346
  }
301
- requestSessionAccess(providerId, extensionId, extensionName, scopeListOrRequest, possibleSessions) {
347
+ requestSessionAccess(
348
+ providerId,
349
+ extensionId,
350
+ extensionName,
351
+ scopeListOrRequest,
352
+ possibleSessions
353
+ ) {
302
354
  const providerRequests = this._sessionAccessRequestItems.get(providerId) || {};
303
355
  const hasExistingRequest = providerRequests[extensionId];
304
356
  if (hasExistingRequest) {
@@ -306,19 +358,22 @@ let AuthenticationExtensionsService = class AuthenticationExtensionsService exte
306
358
  }
307
359
  const provider = this._authenticationService.getProvider(providerId);
308
360
  const menuItem = ( MenuRegistry.appendMenuItem(MenuId.AccountsContext, {
309
- group: '3_accessRequests',
361
+ group: "3_accessRequests",
310
362
  command: {
311
363
  id: `${providerId}${extensionId}Access`,
312
- title: ( localize(13723, "Grant access to {0} for {1}... (1)", provider.label, extensionName))
364
+ title: ( localize(14105, "Grant access to {0} for {1}... (1)", provider.label, extensionName))
313
365
  }
314
366
  }));
315
367
  const accessCommand = CommandsRegistry.registerCommand({
316
368
  id: `${providerId}${extensionId}Access`,
317
- handler: async (accessor) => {
369
+ handler: async accessor => {
318
370
  this.completeSessionAccessRequest(provider, extensionId, extensionName, scopeListOrRequest);
319
371
  }
320
372
  });
321
- providerRequests[extensionId] = { possibleSessions, disposables: [menuItem, accessCommand] };
373
+ providerRequests[extensionId] = {
374
+ possibleSessions,
375
+ disposables: [menuItem, accessCommand]
376
+ };
322
377
  this._sessionAccessRequestItems.set(providerId, providerRequests);
323
378
  this.updateBadgeCount();
324
379
  }
@@ -336,46 +391,47 @@ let AuthenticationExtensionsService = class AuthenticationExtensionsService exte
336
391
  let provider;
337
392
  try {
338
393
  provider = this._authenticationService.getProvider(providerId);
339
- }
340
- catch (_e) {
394
+ } catch (_e) {
341
395
  return;
342
396
  }
343
397
  const providerRequests = this._signInRequestItems.get(providerId);
344
- const signInRequestKey = isAuthenticationWwwAuthenticateRequest(scopeListOrRequest)
345
- ? `${scopeListOrRequest.wwwAuthenticate}:${scopeListOrRequest.fallbackScopes?.join(SCOPESLIST_SEPARATOR) ?? ''}`
346
- : `${scopeListOrRequest.join(SCOPESLIST_SEPARATOR)}`;
347
- const extensionHasExistingRequest = providerRequests
348
- && providerRequests[signInRequestKey]
349
- && providerRequests[signInRequestKey].requestingExtensionIds.includes(extensionId);
398
+ const signInRequestKey = isAuthenticationWwwAuthenticateRequest(scopeListOrRequest) ? `${scopeListOrRequest.wwwAuthenticate}:${scopeListOrRequest.fallbackScopes?.join(SCOPESLIST_SEPARATOR) ?? ""}` : `${scopeListOrRequest.join(SCOPESLIST_SEPARATOR)}`;
399
+ const extensionHasExistingRequest = providerRequests && providerRequests[signInRequestKey] && providerRequests[signInRequestKey].requestingExtensionIds.includes(extensionId);
350
400
  if (extensionHasExistingRequest) {
351
401
  return;
352
402
  }
353
403
  const commandId = `${providerId}:${extensionId}:signIn${( Object.keys(providerRequests || [])).length}`;
354
404
  const menuItem = ( MenuRegistry.appendMenuItem(MenuId.AccountsContext, {
355
- group: '2_signInRequests',
405
+ group: "2_signInRequests",
356
406
  command: {
357
407
  id: commandId,
358
- title: ( localize(13724, "Sign in with {0} to use {1} (1)", provider.label, extensionName))
408
+ title: ( localize(14106, "Sign in with {0} to use {1} (1)", provider.label, extensionName))
359
409
  }
360
410
  }));
361
411
  const signInCommand = CommandsRegistry.registerCommand({
362
412
  id: commandId,
363
- handler: async (accessor) => {
413
+ handler: async accessor => {
364
414
  const authenticationService = accessor.get(IAuthenticationService);
365
415
  const session = await authenticationService.createSession(providerId, scopeListOrRequest);
366
- this._authenticationAccessService.updateAllowedExtensions(providerId, session.account.label, [{ id: extensionId, name: extensionName, allowed: true }]);
416
+ this._authenticationAccessService.updateAllowedExtensions(providerId, session.account.label, [{
417
+ id: extensionId,
418
+ name: extensionName,
419
+ allowed: true
420
+ }]);
367
421
  this._updateAccountAndSessionPreferences(providerId, extensionId, session);
368
422
  }
369
423
  });
370
424
  if (providerRequests) {
371
- const existingRequest = providerRequests[signInRequestKey] || { disposables: [], requestingExtensionIds: [] };
425
+ const existingRequest = providerRequests[signInRequestKey] || {
426
+ disposables: [],
427
+ requestingExtensionIds: []
428
+ };
372
429
  providerRequests[signInRequestKey] = {
373
430
  disposables: [...existingRequest.disposables, menuItem, signInCommand],
374
431
  requestingExtensionIds: [...existingRequest.requestingExtensionIds, extensionId]
375
432
  };
376
433
  this._signInRequestItems.set(providerId, providerRequests);
377
- }
378
- else {
434
+ } else {
379
435
  this._signInRequestItems.set(providerId, {
380
436
  [signInRequestKey]: {
381
437
  disposables: [menuItem, signInCommand],
@@ -386,15 +442,11 @@ let AuthenticationExtensionsService = class AuthenticationExtensionsService exte
386
442
  this.updateBadgeCount();
387
443
  }
388
444
  };
389
- AuthenticationExtensionsService = ( __decorate([
390
- ( __param(0, IActivityService)),
391
- ( __param(1, IStorageService)),
392
- ( __param(2, IDialogService)),
393
- ( __param(3, IQuickInputService)),
394
- ( __param(4, IProductService)),
395
- ( __param(5, IAuthenticationService)),
396
- ( __param(6, IAuthenticationUsageService)),
397
- ( __param(7, IAuthenticationAccessService))
398
- ], AuthenticationExtensionsService));
445
+ AuthenticationExtensionsService = ( __decorate([( __param(0, IActivityService)), ( __param(1, IStorageService)), ( __param(2, IDialogService)), ( __param(3, IQuickInputService)), ( __param(4, IProductService)), ( __param(5, IAuthenticationService)), ( __param(6, IAuthenticationUsageService)), ( __param(7, IAuthenticationAccessService))], AuthenticationExtensionsService));
446
+ ( registerSingleton(
447
+ IAuthenticationExtensionsService,
448
+ AuthenticationExtensionsService,
449
+ InstantiationType.Delayed
450
+ ));
399
451
 
400
452
  export { AuthenticationExtensionsService };