@codingame/monaco-vscode-authentication-service-override 7.1.0 → 8.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codingame/monaco-vscode-authentication-service-override",
3
- "version": "7.1.0",
3
+ "version": "8.0.0",
4
4
  "keywords": [],
5
5
  "author": {
6
6
  "name": "CodinGame",
@@ -26,6 +26,6 @@
26
26
  }
27
27
  },
28
28
  "dependencies": {
29
- "vscode": "npm:@codingame/monaco-vscode-api@7.1.0"
29
+ "vscode": "npm:@codingame/monaco-vscode-api@8.0.0"
30
30
  }
31
31
  }
@@ -1,6 +1,6 @@
1
1
  import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
2
2
  import { Disposable, MutableDisposable, dispose } from 'vscode/vscode/vs/base/common/lifecycle';
3
- import { localizeWithPath } from 'vscode/vscode/vs/nls';
3
+ import { localize } from 'vscode/vscode/vs/nls';
4
4
  import { MenuRegistry, MenuId } from 'vscode/vscode/vs/platform/actions/common/actions';
5
5
  import { CommandsRegistry } from 'vscode/vscode/vs/platform/commands/common/commands';
6
6
  import { IDialogService } from 'vscode/vscode/vs/platform/dialogs/common/dialogs.service';
@@ -16,7 +16,6 @@ import { IAuthenticationUsageService } from 'vscode/vscode/vs/workbench/services
16
16
  import { IAuthenticationService } from 'vscode/vscode/vs/workbench/services/authentication/common/authentication.service';
17
17
  import Severity$1 from 'vscode/vscode/vs/base/common/severity';
18
18
 
19
- const _moduleId = "vs/workbench/services/authentication/browser/authenticationExtensionsService";
20
19
  const SCOPESLIST_SEPARATOR = ' ';
21
20
  let AuthenticationExtensionsService = class AuthenticationExtensionsService extends Disposable {
22
21
  constructor(activityService, storageService, dialogService, quickInputService, _authenticationService, _authenticationUsageService, _authenticationAccessService) {
@@ -99,7 +98,7 @@ let AuthenticationExtensionsService = class AuthenticationExtensionsService exte
99
98
  numberOfRequests += ( (Object.keys(accessRequest))).length;
100
99
  });
101
100
  if (numberOfRequests > 0) {
102
- const badge = ( (new NumberBadge(numberOfRequests, () => ( localizeWithPath(_moduleId, 0, "Sign in requested")))));
101
+ const badge = ( (new NumberBadge(numberOfRequests, () => ( localize(1663, "Sign in requested")))));
103
102
  this._accountBadgeDisposable.value = this.activityService.showAccountsActivity({ badge });
104
103
  }
105
104
  }
@@ -134,9 +133,8 @@ let AuthenticationExtensionsService = class AuthenticationExtensionsService exte
134
133
  })(SessionPromptChoice || (SessionPromptChoice = {}))));
135
134
  const { result } = await this.dialogService.prompt({
136
135
  type: Severity$1.Info,
137
- message: ( localizeWithPath(
138
- _moduleId,
139
- 1,
136
+ message: ( localize(
137
+ 1664,
140
138
  "The extension '{0}' wants to access the {1} account '{2}'.",
141
139
  extensionName,
142
140
  provider.label,
@@ -144,11 +142,11 @@ let AuthenticationExtensionsService = class AuthenticationExtensionsService exte
144
142
  )),
145
143
  buttons: [
146
144
  {
147
- label: ( localizeWithPath(_moduleId, 2, "&&Allow")),
145
+ label: ( localize(1665, "&&Allow")),
148
146
  run: () => SessionPromptChoice.Allow
149
147
  },
150
148
  {
151
- label: ( localizeWithPath(_moduleId, 3, "&&Deny")),
149
+ label: ( localize(1666, "&&Deny")),
152
150
  run: () => SessionPromptChoice.Deny
153
151
  }
154
152
  ],
@@ -163,64 +161,61 @@ let AuthenticationExtensionsService = class AuthenticationExtensionsService exte
163
161
  return result === SessionPromptChoice.Allow;
164
162
  }
165
163
  async selectSession(providerId, extensionId, extensionName, scopes, availableSessions) {
166
- return (
167
- (new Promise((resolve, reject) => {
168
- if (!availableSessions.length) {
169
- reject('No available sessions');
170
- return;
171
- }
172
- const quickPick = this.quickInputService.createQuickPick();
173
- quickPick.ignoreFocusOut = true;
174
- const items = ( (availableSessions.map(session => {
175
- return {
176
- label: session.account.label,
177
- session: session
178
- };
179
- })));
180
- items.push({
181
- label: ( localizeWithPath(_moduleId, 4, "Sign in to another account"))
182
- });
183
- quickPick.items = items;
184
- quickPick.title = ( localizeWithPath(
185
- _moduleId,
186
- 5,
187
- "The extension '{0}' wants to access a {1} account",
188
- extensionName,
189
- this._authenticationService.getProvider(providerId).label
190
- ));
191
- quickPick.placeholder = ( localizeWithPath(
192
- _moduleId,
193
- 6,
194
- "Select an account for '{0}' to use or Esc to cancel",
195
- extensionName
196
- ));
197
- quickPick.onDidAccept(async (_) => {
198
- quickPick.dispose();
199
- let session = quickPick.selectedItems[0].session;
200
- if (!session) {
201
- try {
202
- session = await this._authenticationService.createSession(providerId, scopes);
203
- }
204
- catch (e) {
205
- reject(e);
206
- return;
207
- }
164
+ const allAccounts = await this._authenticationService.getAccounts(providerId);
165
+ if (!allAccounts.length) {
166
+ throw ( (new Error('No accounts available')));
167
+ }
168
+ const quickPick = this.quickInputService.createQuickPick();
169
+ quickPick.ignoreFocusOut = true;
170
+ const items = ( (availableSessions.map(session => {
171
+ return {
172
+ label: session.account.label,
173
+ session: session
174
+ };
175
+ })));
176
+ const accountsWithSessions = ( (new Set( (availableSessions.map(session => session.account.label)))));
177
+ allAccounts.forEach(account => {
178
+ if (!( (accountsWithSessions.has(account.label)))) {
179
+ items.push({ label: account.label, account });
180
+ }
181
+ });
182
+ items.push({ label: ( localize(1667, "Sign in to another account")) });
183
+ quickPick.items = items;
184
+ quickPick.title = ( localize(
185
+ 1668,
186
+ "The extension '{0}' wants to access a {1} account",
187
+ extensionName,
188
+ this._authenticationService.getProvider(providerId).label
189
+ ));
190
+ quickPick.placeholder = ( localize(1669, "Select an account for '{0}' to use or Esc to cancel", extensionName));
191
+ return await ( (new Promise((resolve, reject) => {
192
+ quickPick.onDidAccept(async (_) => {
193
+ quickPick.dispose();
194
+ let session = quickPick.selectedItems[0].session;
195
+ if (!session) {
196
+ const account = quickPick.selectedItems[0].account;
197
+ try {
198
+ session = await this._authenticationService.createSession(providerId, scopes, { account });
208
199
  }
209
- const accountName = session.account.label;
210
- this._authenticationAccessService.updateAllowedExtensions(providerId, accountName, [{ id: extensionId, name: extensionName, allowed: true }]);
211
- this.updateSessionPreference(providerId, extensionId, session);
212
- this.removeAccessRequest(providerId, extensionId);
213
- resolve(session);
214
- });
215
- quickPick.onDidHide(_ => {
216
- quickPick.dispose();
217
- if (!quickPick.selectedItems[0]) {
218
- reject('User did not consent to account access');
200
+ catch (e) {
201
+ reject(e);
202
+ return;
219
203
  }
220
- });
221
- quickPick.show();
222
- }))
223
- );
204
+ }
205
+ const accountName = session.account.label;
206
+ this._authenticationAccessService.updateAllowedExtensions(providerId, accountName, [{ id: extensionId, name: extensionName, allowed: true }]);
207
+ this.updateSessionPreference(providerId, extensionId, session);
208
+ this.removeAccessRequest(providerId, extensionId);
209
+ resolve(session);
210
+ });
211
+ quickPick.onDidHide(_ => {
212
+ quickPick.dispose();
213
+ if (!quickPick.selectedItems[0]) {
214
+ reject('User did not consent to account access');
215
+ }
216
+ });
217
+ quickPick.show();
218
+ })));
224
219
  }
225
220
  async completeSessionAccessRequest(provider, extensionId, extensionName, scopes) {
226
221
  const providerRequests = this._sessionAccessRequestItems.get(provider.id) || {};
@@ -261,13 +256,7 @@ let AuthenticationExtensionsService = class AuthenticationExtensionsService exte
261
256
  group: '3_accessRequests',
262
257
  command: {
263
258
  id: `${providerId}${extensionId}Access`,
264
- title: ( localizeWithPath(
265
- _moduleId,
266
- 7,
267
- "Grant access to {0} for {1}... (1)",
268
- provider.label,
269
- extensionName
270
- ))
259
+ title: ( localize(1670, "Grant access to {0} for {1}... (1)", provider.label, extensionName))
271
260
  }
272
261
  })));
273
262
  const accessCommand = CommandsRegistry.registerCommand({
@@ -311,13 +300,7 @@ let AuthenticationExtensionsService = class AuthenticationExtensionsService exte
311
300
  group: '2_signInRequests',
312
301
  command: {
313
302
  id: commandId,
314
- title: ( localizeWithPath(
315
- _moduleId,
316
- 8,
317
- "Sign in with {0} to use {1} (1)",
318
- provider.label,
319
- extensionName
320
- ))
303
+ title: ( localize(1671, "Sign in with {0} to use {1} (1)", provider.label, extensionName))
321
304
  }
322
305
  })));
323
306
  const signInCommand = CommandsRegistry.registerCommand({