@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.
- package/package.json +2 -2
- package/vscode/src/vs/workbench/contrib/authentication/browser/actions/manageAccountPreferencesForExtensionAction.js +59 -52
- package/vscode/src/vs/workbench/contrib/authentication/browser/actions/manageAccountPreferencesForMcpServerAction.js +43 -43
- package/vscode/src/vs/workbench/contrib/authentication/browser/actions/manageAccountsAction.js +50 -26
- package/vscode/src/vs/workbench/contrib/authentication/browser/actions/manageDynamicAuthenticationProvidersAction.js +19 -19
- package/vscode/src/vs/workbench/contrib/authentication/browser/actions/manageTrustedExtensionsForAccountAction.js +41 -43
- package/vscode/src/vs/workbench/contrib/authentication/browser/actions/manageTrustedMcpServersForAccountAction.js +40 -40
- package/vscode/src/vs/workbench/contrib/authentication/browser/actions/signOutOfAccountAction.js +18 -12
- package/vscode/src/vs/workbench/contrib/authentication/browser/authentication.contribution.js +33 -27
- package/vscode/src/vs/workbench/services/authentication/browser/authenticationAccessService.js +22 -23
- package/vscode/src/vs/workbench/services/authentication/browser/authenticationExtensionsService.js +130 -78
- package/vscode/src/vs/workbench/services/authentication/browser/authenticationQueryService.js +97 -65
- package/vscode/src/vs/workbench/services/authentication/browser/authenticationUsageService.js +14 -17
- package/vscode/src/vs/workbench/services/authentication/browser/dynamicAuthenticationProviderStorageService.js +54 -27
package/vscode/src/vs/workbench/services/authentication/browser/authenticationQueryService.js
CHANGED
|
@@ -30,16 +30,18 @@ class AccountExtensionQuery extends BaseQuery {
|
|
|
30
30
|
return this.queryService.authenticationAccessService.isAccessAllowed(this.providerId, this.accountName, this.extensionId);
|
|
31
31
|
}
|
|
32
32
|
setAccessAllowed(allowed, extensionName) {
|
|
33
|
-
this.queryService.authenticationAccessService.updateAllowedExtensions(this.providerId, this.accountName, [{
|
|
33
|
+
this.queryService.authenticationAccessService.updateAllowedExtensions(this.providerId, this.accountName, [{
|
|
34
|
+
id: this.extensionId,
|
|
35
|
+
name: extensionName || this.extensionId,
|
|
36
|
+
allowed
|
|
37
|
+
}]);
|
|
34
38
|
}
|
|
35
39
|
addUsage(scopes, extensionName) {
|
|
36
40
|
this.queryService.authenticationUsageService.addAccountUsage(this.providerId, this.accountName, scopes, this.extensionId, extensionName);
|
|
37
41
|
}
|
|
38
42
|
getUsage() {
|
|
39
43
|
const allUsages = this.queryService.authenticationUsageService.readAccountUsages(this.providerId, this.accountName);
|
|
40
|
-
return ( allUsages
|
|
41
|
-
.filter(usage => usage.extensionId === ExtensionIdentifier.toKey(this.extensionId))
|
|
42
|
-
.map(usage => ({
|
|
44
|
+
return ( allUsages.filter(usage => usage.extensionId === ExtensionIdentifier.toKey(this.extensionId)).map(usage => ({
|
|
43
45
|
extensionId: usage.extensionId,
|
|
44
46
|
extensionName: usage.extensionName,
|
|
45
47
|
scopes: usage.scopes || [],
|
|
@@ -51,11 +53,20 @@ class AccountExtensionQuery extends BaseQuery {
|
|
|
51
53
|
const filteredUsages = allUsages.filter(usage => usage.extensionId !== this.extensionId);
|
|
52
54
|
this.queryService.authenticationUsageService.removeAccountUsage(this.providerId, this.accountName);
|
|
53
55
|
for (const usage of filteredUsages) {
|
|
54
|
-
this.queryService.authenticationUsageService.addAccountUsage(
|
|
56
|
+
this.queryService.authenticationUsageService.addAccountUsage(
|
|
57
|
+
this.providerId,
|
|
58
|
+
this.accountName,
|
|
59
|
+
usage.scopes || [],
|
|
60
|
+
usage.extensionId,
|
|
61
|
+
usage.extensionName
|
|
62
|
+
);
|
|
55
63
|
}
|
|
56
64
|
}
|
|
57
65
|
setAsPreferred() {
|
|
58
|
-
this.queryService.authenticationExtensionsService.updateAccountPreference(this.extensionId, this.providerId, {
|
|
66
|
+
this.queryService.authenticationExtensionsService.updateAccountPreference(this.extensionId, this.providerId, {
|
|
67
|
+
label: this.accountName,
|
|
68
|
+
id: this.accountName
|
|
69
|
+
});
|
|
59
70
|
}
|
|
60
71
|
isPreferred() {
|
|
61
72
|
const preferredAccount = this.queryService.authenticationExtensionsService.getAccountPreference(this.extensionId, this.providerId);
|
|
@@ -77,16 +88,18 @@ class AccountMcpServerQuery extends BaseQuery {
|
|
|
77
88
|
return this.queryService.authenticationMcpAccessService.isAccessAllowed(this.providerId, this.accountName, this.mcpServerId);
|
|
78
89
|
}
|
|
79
90
|
setAccessAllowed(allowed, mcpServerName) {
|
|
80
|
-
this.queryService.authenticationMcpAccessService.updateAllowedMcpServers(this.providerId, this.accountName, [{
|
|
91
|
+
this.queryService.authenticationMcpAccessService.updateAllowedMcpServers(this.providerId, this.accountName, [{
|
|
92
|
+
id: this.mcpServerId,
|
|
93
|
+
name: mcpServerName || this.mcpServerId,
|
|
94
|
+
allowed
|
|
95
|
+
}]);
|
|
81
96
|
}
|
|
82
97
|
addUsage(scopes, mcpServerName) {
|
|
83
98
|
this.queryService.authenticationMcpUsageService.addAccountUsage(this.providerId, this.accountName, scopes, this.mcpServerId, mcpServerName);
|
|
84
99
|
}
|
|
85
100
|
getUsage() {
|
|
86
101
|
const allUsages = this.queryService.authenticationMcpUsageService.readAccountUsages(this.providerId, this.accountName);
|
|
87
|
-
return ( allUsages
|
|
88
|
-
.filter(usage => usage.mcpServerId === this.mcpServerId)
|
|
89
|
-
.map(usage => ({
|
|
102
|
+
return ( allUsages.filter(usage => usage.mcpServerId === this.mcpServerId).map(usage => ({
|
|
90
103
|
mcpServerId: usage.mcpServerId,
|
|
91
104
|
mcpServerName: usage.mcpServerName,
|
|
92
105
|
scopes: usage.scopes || [],
|
|
@@ -98,11 +111,20 @@ class AccountMcpServerQuery extends BaseQuery {
|
|
|
98
111
|
const filteredUsages = allUsages.filter(usage => usage.mcpServerId !== this.mcpServerId);
|
|
99
112
|
this.queryService.authenticationMcpUsageService.removeAccountUsage(this.providerId, this.accountName);
|
|
100
113
|
for (const usage of filteredUsages) {
|
|
101
|
-
this.queryService.authenticationMcpUsageService.addAccountUsage(
|
|
114
|
+
this.queryService.authenticationMcpUsageService.addAccountUsage(
|
|
115
|
+
this.providerId,
|
|
116
|
+
this.accountName,
|
|
117
|
+
usage.scopes || [],
|
|
118
|
+
usage.mcpServerId,
|
|
119
|
+
usage.mcpServerName
|
|
120
|
+
);
|
|
102
121
|
}
|
|
103
122
|
}
|
|
104
123
|
setAsPreferred() {
|
|
105
|
-
this.queryService.authenticationMcpService.updateAccountPreference(this.mcpServerId, this.providerId, {
|
|
124
|
+
this.queryService.authenticationMcpService.updateAccountPreference(this.mcpServerId, this.providerId, {
|
|
125
|
+
label: this.accountName,
|
|
126
|
+
id: this.accountName
|
|
127
|
+
});
|
|
106
128
|
}
|
|
107
129
|
isPreferred() {
|
|
108
130
|
const preferredAccount = this.queryService.authenticationMcpService.getAccountPreference(this.mcpServerId, this.providerId);
|
|
@@ -122,9 +144,7 @@ class AccountExtensionsQuery extends BaseQuery {
|
|
|
122
144
|
getAllowedExtensions() {
|
|
123
145
|
const allowedExtensions = this.queryService.authenticationAccessService.readAllowedExtensions(this.providerId, this.accountName);
|
|
124
146
|
const usages = this.queryService.authenticationUsageService.readAccountUsages(this.providerId, this.accountName);
|
|
125
|
-
return ( allowedExtensions
|
|
126
|
-
.filter(ext => ext.allowed !== false)
|
|
127
|
-
.map(ext => {
|
|
147
|
+
return ( allowedExtensions.filter(ext => ext.allowed !== false).map(ext => {
|
|
128
148
|
const extensionUsages = usages.filter(usage => usage.extensionId === ext.id);
|
|
129
149
|
const lastUsed = extensionUsages.length > 0 ? Math.max(...( extensionUsages.map(u => u.lastUsed))) : undefined;
|
|
130
150
|
const extensionQuery = ( new AccountExtensionQuery(this.providerId, this.accountName, ext.id, this.queryService));
|
|
@@ -139,11 +159,19 @@ class AccountExtensionsQuery extends BaseQuery {
|
|
|
139
159
|
}));
|
|
140
160
|
}
|
|
141
161
|
allowAccess(extensionIds) {
|
|
142
|
-
const extensionsToAllow = ( extensionIds.map(id => ({
|
|
162
|
+
const extensionsToAllow = ( extensionIds.map(id => ({
|
|
163
|
+
id,
|
|
164
|
+
name: id,
|
|
165
|
+
allowed: true
|
|
166
|
+
})));
|
|
143
167
|
this.queryService.authenticationAccessService.updateAllowedExtensions(this.providerId, this.accountName, extensionsToAllow);
|
|
144
168
|
}
|
|
145
169
|
removeAccess(extensionIds) {
|
|
146
|
-
const extensionsToRemove = ( extensionIds.map(id => ({
|
|
170
|
+
const extensionsToRemove = ( extensionIds.map(id => ({
|
|
171
|
+
id,
|
|
172
|
+
name: id,
|
|
173
|
+
allowed: false
|
|
174
|
+
})));
|
|
147
175
|
this.queryService.authenticationAccessService.updateAllowedExtensions(this.providerId, this.accountName, extensionsToRemove);
|
|
148
176
|
}
|
|
149
177
|
forEach(callback) {
|
|
@@ -164,15 +192,22 @@ class AccountMcpServersQuery extends BaseQuery {
|
|
|
164
192
|
this.accountName = accountName;
|
|
165
193
|
}
|
|
166
194
|
getAllowedMcpServers() {
|
|
167
|
-
return this.queryService.authenticationMcpAccessService.readAllowedMcpServers(this.providerId, this.accountName)
|
|
168
|
-
.filter(server => server.allowed !== false);
|
|
195
|
+
return this.queryService.authenticationMcpAccessService.readAllowedMcpServers(this.providerId, this.accountName).filter(server => server.allowed !== false);
|
|
169
196
|
}
|
|
170
197
|
allowAccess(mcpServerIds) {
|
|
171
|
-
const mcpServersToAllow = ( mcpServerIds.map(id => ({
|
|
198
|
+
const mcpServersToAllow = ( mcpServerIds.map(id => ({
|
|
199
|
+
id,
|
|
200
|
+
name: id,
|
|
201
|
+
allowed: true
|
|
202
|
+
})));
|
|
172
203
|
this.queryService.authenticationMcpAccessService.updateAllowedMcpServers(this.providerId, this.accountName, mcpServersToAllow);
|
|
173
204
|
}
|
|
174
205
|
removeAccess(mcpServerIds) {
|
|
175
|
-
const mcpServersToRemove = ( mcpServerIds.map(id => ({
|
|
206
|
+
const mcpServersToRemove = ( mcpServerIds.map(id => ({
|
|
207
|
+
id,
|
|
208
|
+
name: id,
|
|
209
|
+
allowed: false
|
|
210
|
+
})));
|
|
176
211
|
this.queryService.authenticationMcpAccessService.updateAllowedMcpServers(this.providerId, this.accountName, mcpServersToRemove);
|
|
177
212
|
}
|
|
178
213
|
forEach(callback) {
|
|
@@ -247,11 +282,11 @@ class AccountEntitiesQuery extends BaseQuery {
|
|
|
247
282
|
forEach(callback) {
|
|
248
283
|
const extensionsQuery = ( new AccountExtensionsQuery(this.providerId, this.accountName, this.queryService));
|
|
249
284
|
extensionsQuery.forEach(extensionQuery => {
|
|
250
|
-
callback(extensionQuery.extensionId,
|
|
285
|
+
callback(extensionQuery.extensionId, "extension");
|
|
251
286
|
});
|
|
252
287
|
const mcpServersQuery = ( new AccountMcpServersQuery(this.providerId, this.accountName, this.queryService));
|
|
253
288
|
mcpServersQuery.forEach(mcpServerQuery => {
|
|
254
|
-
callback(mcpServerQuery.mcpServerId,
|
|
289
|
+
callback(mcpServerQuery.mcpServerId, "mcpServer");
|
|
255
290
|
});
|
|
256
291
|
}
|
|
257
292
|
}
|
|
@@ -318,8 +353,7 @@ class ProviderMcpServerQuery extends BaseQuery {
|
|
|
318
353
|
}
|
|
319
354
|
}
|
|
320
355
|
return lastUsedAccount;
|
|
321
|
-
}
|
|
322
|
-
catch {
|
|
356
|
+
} catch {
|
|
323
357
|
return undefined;
|
|
324
358
|
}
|
|
325
359
|
}
|
|
@@ -343,8 +377,7 @@ class ProviderMcpServerQuery extends BaseQuery {
|
|
|
343
377
|
}
|
|
344
378
|
}
|
|
345
379
|
return usedAccounts;
|
|
346
|
-
}
|
|
347
|
-
catch {
|
|
380
|
+
} catch {
|
|
348
381
|
return [];
|
|
349
382
|
}
|
|
350
383
|
}
|
|
@@ -381,17 +414,17 @@ class ProviderQuery extends BaseQuery {
|
|
|
381
414
|
}
|
|
382
415
|
}
|
|
383
416
|
}
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
417
|
+
} catch {}
|
|
418
|
+
return {
|
|
419
|
+
extensions,
|
|
420
|
+
mcpServers
|
|
421
|
+
};
|
|
388
422
|
}
|
|
389
423
|
async getAccountNames() {
|
|
390
424
|
try {
|
|
391
425
|
const accounts = await this.queryService.authenticationService.getAccounts(this.providerId);
|
|
392
426
|
return ( accounts.map(account => account.label));
|
|
393
|
-
}
|
|
394
|
-
catch {
|
|
427
|
+
} catch {
|
|
395
428
|
return [];
|
|
396
429
|
}
|
|
397
430
|
}
|
|
@@ -409,15 +442,21 @@ class ProviderQuery extends BaseQuery {
|
|
|
409
442
|
const usageCount = allUsages.length;
|
|
410
443
|
const lastUsed = Math.max(...( allUsages.map(u => u.lastUsed)), 0);
|
|
411
444
|
if (usageCount > 0) {
|
|
412
|
-
recentActivity.push({
|
|
445
|
+
recentActivity.push({
|
|
446
|
+
accountName: account.label,
|
|
447
|
+
lastUsed,
|
|
448
|
+
usageCount
|
|
449
|
+
});
|
|
413
450
|
}
|
|
414
451
|
}
|
|
415
452
|
recentActivity.sort((a, b) => b.lastUsed - a.lastUsed);
|
|
416
453
|
totalSessions = recentActivity.reduce((sum, activity) => sum + activity.usageCount, 0);
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
454
|
+
} catch {}
|
|
455
|
+
return {
|
|
456
|
+
totalSessions,
|
|
457
|
+
totalAccounts,
|
|
458
|
+
recentActivity
|
|
459
|
+
};
|
|
421
460
|
}
|
|
422
461
|
async forEachAccount(callback) {
|
|
423
462
|
try {
|
|
@@ -426,9 +465,7 @@ class ProviderQuery extends BaseQuery {
|
|
|
426
465
|
const accountQuery = ( new AccountQuery(this.providerId, account.label, this.queryService));
|
|
427
466
|
callback(accountQuery);
|
|
428
467
|
}
|
|
429
|
-
}
|
|
430
|
-
catch {
|
|
431
|
-
}
|
|
468
|
+
} catch {}
|
|
432
469
|
}
|
|
433
470
|
}
|
|
434
471
|
class ExtensionQuery {
|
|
@@ -452,9 +489,7 @@ class ExtensionQuery {
|
|
|
452
489
|
if (hasAccess) {
|
|
453
490
|
providersWithAccess.push(providerId);
|
|
454
491
|
}
|
|
455
|
-
}
|
|
456
|
-
catch {
|
|
457
|
-
}
|
|
492
|
+
} catch {}
|
|
458
493
|
}
|
|
459
494
|
return providersWithAccess;
|
|
460
495
|
}
|
|
@@ -497,9 +532,7 @@ class McpServerQuery {
|
|
|
497
532
|
if (hasAccess) {
|
|
498
533
|
providersWithAccess.push(providerId);
|
|
499
534
|
}
|
|
500
|
-
}
|
|
501
|
-
catch {
|
|
502
|
-
}
|
|
535
|
+
} catch {}
|
|
503
536
|
}
|
|
504
537
|
return providersWithAccess;
|
|
505
538
|
}
|
|
@@ -522,7 +555,16 @@ class McpServerQuery {
|
|
|
522
555
|
}
|
|
523
556
|
}
|
|
524
557
|
let AuthenticationQueryService = class AuthenticationQueryService extends Disposable {
|
|
525
|
-
constructor(
|
|
558
|
+
constructor(
|
|
559
|
+
authenticationService,
|
|
560
|
+
authenticationUsageService,
|
|
561
|
+
authenticationMcpUsageService,
|
|
562
|
+
authenticationAccessService,
|
|
563
|
+
authenticationMcpAccessService,
|
|
564
|
+
authenticationExtensionsService,
|
|
565
|
+
authenticationMcpService,
|
|
566
|
+
logService
|
|
567
|
+
) {
|
|
526
568
|
super();
|
|
527
569
|
this.authenticationService = authenticationService;
|
|
528
570
|
this.authenticationUsageService = authenticationUsageService;
|
|
@@ -539,14 +581,14 @@ let AuthenticationQueryService = class AuthenticationQueryService extends Dispos
|
|
|
539
581
|
this._register(this.authenticationExtensionsService.onDidChangeAccountPreference(e => {
|
|
540
582
|
this._onDidChangePreferences.fire({
|
|
541
583
|
providerId: e.providerId,
|
|
542
|
-
entityType:
|
|
584
|
+
entityType: "extension",
|
|
543
585
|
entityIds: e.extensionIds
|
|
544
586
|
});
|
|
545
587
|
}));
|
|
546
588
|
this._register(this.authenticationMcpService.onDidChangeAccountPreference(e => {
|
|
547
589
|
this._onDidChangePreferences.fire({
|
|
548
590
|
providerId: e.providerId,
|
|
549
|
-
entityType:
|
|
591
|
+
entityType: "mcpServer",
|
|
550
592
|
entityIds: e.mcpServerIds
|
|
551
593
|
});
|
|
552
594
|
}));
|
|
@@ -578,8 +620,8 @@ let AuthenticationQueryService = class AuthenticationQueryService extends Dispos
|
|
|
578
620
|
});
|
|
579
621
|
}
|
|
580
622
|
async clearAllData(confirmation, includeInternal = true) {
|
|
581
|
-
if (confirmation !==
|
|
582
|
-
throw ( new Error(
|
|
623
|
+
if (confirmation !== "CLEAR_ALL_AUTH_DATA") {
|
|
624
|
+
throw ( new Error("Must provide confirmation string to clear all authentication data"));
|
|
583
625
|
}
|
|
584
626
|
const providerIds = this.getProviderIds(includeInternal);
|
|
585
627
|
for (const providerId of providerIds) {
|
|
@@ -591,23 +633,13 @@ let AuthenticationQueryService = class AuthenticationQueryService extends Dispos
|
|
|
591
633
|
this.authenticationMcpAccessService.removeAllowedMcpServers(providerId, account.label);
|
|
592
634
|
this.authenticationMcpUsageService.removeAccountUsage(providerId, account.label);
|
|
593
635
|
}
|
|
594
|
-
}
|
|
595
|
-
catch (error) {
|
|
636
|
+
} catch (error) {
|
|
596
637
|
this.logService.error(`Error clearing data for provider ${providerId}:`, error);
|
|
597
638
|
}
|
|
598
639
|
}
|
|
599
|
-
this.logService.info(
|
|
640
|
+
this.logService.info("All authentication data cleared");
|
|
600
641
|
}
|
|
601
642
|
};
|
|
602
|
-
AuthenticationQueryService = ( __decorate([
|
|
603
|
-
( __param(0, IAuthenticationService)),
|
|
604
|
-
( __param(1, IAuthenticationUsageService)),
|
|
605
|
-
( __param(2, IAuthenticationMcpUsageService)),
|
|
606
|
-
( __param(3, IAuthenticationAccessService)),
|
|
607
|
-
( __param(4, IAuthenticationMcpAccessService)),
|
|
608
|
-
( __param(5, IAuthenticationExtensionsService)),
|
|
609
|
-
( __param(6, IAuthenticationMcpService)),
|
|
610
|
-
( __param(7, ILogService))
|
|
611
|
-
], AuthenticationQueryService));
|
|
643
|
+
AuthenticationQueryService = ( __decorate([( __param(0, IAuthenticationService)), ( __param(1, IAuthenticationUsageService)), ( __param(2, IAuthenticationMcpUsageService)), ( __param(3, IAuthenticationAccessService)), ( __param(4, IAuthenticationMcpAccessService)), ( __param(5, IAuthenticationExtensionsService)), ( __param(6, IAuthenticationMcpService)), ( __param(7, ILogService))], AuthenticationQueryService));
|
|
612
644
|
|
|
613
645
|
export { AuthenticationQueryService };
|
package/vscode/src/vs/workbench/services/authentication/browser/authenticationUsageService.js
CHANGED
|
@@ -25,15 +25,16 @@ let AuthenticationUsageService = class AuthenticationUsageService extends Dispos
|
|
|
25
25
|
for (const extensionId of trustedExtensionAuthAccess) {
|
|
26
26
|
this._extensionsUsingAuth.add(extensionId);
|
|
27
27
|
}
|
|
28
|
-
}
|
|
29
|
-
else if (trustedExtensionAuthAccess) {
|
|
28
|
+
} else if (trustedExtensionAuthAccess) {
|
|
30
29
|
for (const extensions of ( Object.values(trustedExtensionAuthAccess))) {
|
|
31
30
|
for (const extensionId of extensions) {
|
|
32
31
|
this._extensionsUsingAuth.add(extensionId);
|
|
33
32
|
}
|
|
34
33
|
}
|
|
35
34
|
}
|
|
36
|
-
this._register(this._authenticationService.onDidRegisterAuthenticationProvider(
|
|
35
|
+
this._register(this._authenticationService.onDidRegisterAuthenticationProvider(
|
|
36
|
+
provider => this._queue.queue(() => this._addExtensionsToCache(provider.id))
|
|
37
|
+
));
|
|
37
38
|
}
|
|
38
39
|
async initializeExtensionUsageCache() {
|
|
39
40
|
await this._queue.queue(() => Promise.all(( this._authenticationService.getProviderIds().map(providerId => this._addExtensionsToCache(providerId)))));
|
|
@@ -49,9 +50,7 @@ let AuthenticationUsageService = class AuthenticationUsageService extends Dispos
|
|
|
49
50
|
if (storedUsages) {
|
|
50
51
|
try {
|
|
51
52
|
usages = JSON.parse(storedUsages);
|
|
52
|
-
}
|
|
53
|
-
catch (e) {
|
|
54
|
-
}
|
|
53
|
+
} catch (e) {}
|
|
55
54
|
}
|
|
56
55
|
return usages;
|
|
57
56
|
}
|
|
@@ -70,8 +69,7 @@ let AuthenticationUsageService = class AuthenticationUsageService extends Dispos
|
|
|
70
69
|
scopes,
|
|
71
70
|
lastUsed: Date.now()
|
|
72
71
|
});
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
72
|
+
} else {
|
|
75
73
|
usages.push({
|
|
76
74
|
extensionId,
|
|
77
75
|
extensionName,
|
|
@@ -79,7 +77,12 @@ let AuthenticationUsageService = class AuthenticationUsageService extends Dispos
|
|
|
79
77
|
lastUsed: Date.now()
|
|
80
78
|
});
|
|
81
79
|
}
|
|
82
|
-
this._storageService.store(
|
|
80
|
+
this._storageService.store(
|
|
81
|
+
accountKey,
|
|
82
|
+
JSON.stringify(usages),
|
|
83
|
+
StorageScope.APPLICATION,
|
|
84
|
+
StorageTarget.MACHINE
|
|
85
|
+
);
|
|
83
86
|
this._extensionsUsingAuth.add(extensionId);
|
|
84
87
|
}
|
|
85
88
|
async _addExtensionsToCache(providerId) {
|
|
@@ -94,17 +97,11 @@ let AuthenticationUsageService = class AuthenticationUsageService extends Dispos
|
|
|
94
97
|
this._extensionsUsingAuth.add(u.extensionId);
|
|
95
98
|
}
|
|
96
99
|
}
|
|
97
|
-
}
|
|
98
|
-
catch (e) {
|
|
100
|
+
} catch (e) {
|
|
99
101
|
this._logService.error(e);
|
|
100
102
|
}
|
|
101
103
|
}
|
|
102
104
|
};
|
|
103
|
-
AuthenticationUsageService = ( __decorate([
|
|
104
|
-
( __param(0, IStorageService)),
|
|
105
|
-
( __param(1, IAuthenticationService)),
|
|
106
|
-
( __param(2, ILogService)),
|
|
107
|
-
( __param(3, IProductService))
|
|
108
|
-
], AuthenticationUsageService));
|
|
105
|
+
AuthenticationUsageService = ( __decorate([( __param(0, IStorageService)), ( __param(1, IAuthenticationService)), ( __param(2, ILogService)), ( __param(3, IProductService))], AuthenticationUsageService));
|
|
109
106
|
|
|
110
107
|
export { AuthenticationUsageService };
|
|
@@ -13,8 +13,12 @@ import { Queue } from '@codingame/monaco-vscode-api/vscode/vs/base/common/async'
|
|
|
13
13
|
|
|
14
14
|
var DynamicAuthenticationProviderStorageService_1;
|
|
15
15
|
let DynamicAuthenticationProviderStorageService = class DynamicAuthenticationProviderStorageService extends Disposable {
|
|
16
|
-
static {
|
|
17
|
-
|
|
16
|
+
static {
|
|
17
|
+
DynamicAuthenticationProviderStorageService_1 = this;
|
|
18
|
+
}
|
|
19
|
+
static {
|
|
20
|
+
this.PROVIDERS_STORAGE_KEY = "dynamicAuthProviders";
|
|
21
|
+
}
|
|
18
22
|
constructor(storageService, secretStorageService, logService) {
|
|
19
23
|
super();
|
|
20
24
|
this.storageService = storageService;
|
|
@@ -23,13 +27,11 @@ let DynamicAuthenticationProviderStorageService = class DynamicAuthenticationPro
|
|
|
23
27
|
this._onDidChangeTokens = this._register(( new Emitter()));
|
|
24
28
|
this.onDidChangeTokens = this._onDidChangeTokens.event;
|
|
25
29
|
const queue = ( new Queue());
|
|
26
|
-
this._register(this.secretStorageService.onDidChangeSecret(async
|
|
30
|
+
this._register(this.secretStorageService.onDidChangeSecret(async key => {
|
|
27
31
|
let payload;
|
|
28
32
|
try {
|
|
29
33
|
payload = JSON.parse(key);
|
|
30
|
-
}
|
|
31
|
-
catch (error) {
|
|
32
|
-
}
|
|
34
|
+
} catch (error) {}
|
|
33
35
|
if (payload?.isDynamicAuthProvider) {
|
|
34
36
|
void queue.queue(async () => {
|
|
35
37
|
const tokens = await this.getSessionsForDynamicAuthProvider(payload.authProviderId, payload.clientId);
|
|
@@ -51,14 +53,15 @@ let DynamicAuthenticationProviderStorageService = class DynamicAuthenticationPro
|
|
|
51
53
|
if (credentials && (credentials.clientId || credentials.clientSecret)) {
|
|
52
54
|
return credentials;
|
|
53
55
|
}
|
|
54
|
-
}
|
|
55
|
-
catch {
|
|
56
|
+
} catch {
|
|
56
57
|
await this.secretStorageService.delete(key);
|
|
57
58
|
}
|
|
58
59
|
}
|
|
59
60
|
const providers = this._getStoredProviders();
|
|
60
61
|
const provider = providers.find(p => p.providerId === providerId);
|
|
61
|
-
return provider?.clientId ? {
|
|
62
|
+
return provider?.clientId ? {
|
|
63
|
+
clientId: provider.clientId
|
|
64
|
+
} : undefined;
|
|
62
65
|
}
|
|
63
66
|
getClientId(providerId) {
|
|
64
67
|
const providers = this._getStoredProviders();
|
|
@@ -68,7 +71,10 @@ let DynamicAuthenticationProviderStorageService = class DynamicAuthenticationPro
|
|
|
68
71
|
async storeClientRegistration(providerId, authorizationServer, clientId, clientSecret, label) {
|
|
69
72
|
this._trackProvider(providerId, authorizationServer, clientId, label);
|
|
70
73
|
const key = `dynamicAuthProvider:clientRegistration:${providerId}`;
|
|
71
|
-
const credentials = {
|
|
74
|
+
const credentials = {
|
|
75
|
+
clientId,
|
|
76
|
+
clientSecret
|
|
77
|
+
};
|
|
72
78
|
await this.secretStorageService.set(key, JSON.stringify(credentials));
|
|
73
79
|
}
|
|
74
80
|
_trackProvider(providerId, authorizationServer, clientId, label) {
|
|
@@ -83,8 +89,7 @@ let DynamicAuthenticationProviderStorageService = class DynamicAuthenticationPro
|
|
|
83
89
|
};
|
|
84
90
|
providers.push(newProvider);
|
|
85
91
|
this._storeProviders(providers);
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
92
|
+
} else {
|
|
88
93
|
const existingProvider = providers[existingProviderIndex];
|
|
89
94
|
const updatedProvider = {
|
|
90
95
|
providerId,
|
|
@@ -97,7 +102,11 @@ let DynamicAuthenticationProviderStorageService = class DynamicAuthenticationPro
|
|
|
97
102
|
}
|
|
98
103
|
}
|
|
99
104
|
_getStoredProviders() {
|
|
100
|
-
const stored = this.storageService.get(
|
|
105
|
+
const stored = this.storageService.get(
|
|
106
|
+
DynamicAuthenticationProviderStorageService_1.PROVIDERS_STORAGE_KEY,
|
|
107
|
+
StorageScope.APPLICATION,
|
|
108
|
+
"[]"
|
|
109
|
+
);
|
|
101
110
|
try {
|
|
102
111
|
const providerInfos = JSON.parse(stored);
|
|
103
112
|
for (const providerInfo of providerInfos) {
|
|
@@ -106,13 +115,17 @@ let DynamicAuthenticationProviderStorageService = class DynamicAuthenticationPro
|
|
|
106
115
|
}
|
|
107
116
|
}
|
|
108
117
|
return providerInfos;
|
|
109
|
-
}
|
|
110
|
-
catch {
|
|
118
|
+
} catch {
|
|
111
119
|
return [];
|
|
112
120
|
}
|
|
113
121
|
}
|
|
114
122
|
_storeProviders(providers) {
|
|
115
|
-
this.storageService.store(
|
|
123
|
+
this.storageService.store(
|
|
124
|
+
DynamicAuthenticationProviderStorageService_1.PROVIDERS_STORAGE_KEY,
|
|
125
|
+
JSON.stringify(providers),
|
|
126
|
+
StorageScope.APPLICATION,
|
|
127
|
+
StorageTarget.MACHINE
|
|
128
|
+
);
|
|
116
129
|
}
|
|
117
130
|
getInteractedProviders() {
|
|
118
131
|
return this._getStoredProviders();
|
|
@@ -123,19 +136,30 @@ let DynamicAuthenticationProviderStorageService = class DynamicAuthenticationPro
|
|
|
123
136
|
const filteredProviders = providers.filter(p => p.providerId !== providerId);
|
|
124
137
|
this._storeProviders(filteredProviders);
|
|
125
138
|
if (providerInfo) {
|
|
126
|
-
const secretKey = JSON.stringify({
|
|
139
|
+
const secretKey = JSON.stringify({
|
|
140
|
+
isDynamicAuthProvider: true,
|
|
141
|
+
authProviderId: providerId,
|
|
142
|
+
clientId: providerInfo.clientId
|
|
143
|
+
});
|
|
127
144
|
await this.secretStorageService.delete(secretKey);
|
|
128
145
|
}
|
|
129
146
|
const credentialsKey = `dynamicAuthProvider:clientRegistration:${providerId}`;
|
|
130
147
|
await this.secretStorageService.delete(credentialsKey);
|
|
131
148
|
}
|
|
132
149
|
async getSessionsForDynamicAuthProvider(authProviderId, clientId) {
|
|
133
|
-
const key = JSON.stringify({
|
|
150
|
+
const key = JSON.stringify({
|
|
151
|
+
isDynamicAuthProvider: true,
|
|
152
|
+
authProviderId,
|
|
153
|
+
clientId
|
|
154
|
+
});
|
|
134
155
|
const value = await this.secretStorageService.get(key);
|
|
135
156
|
if (value) {
|
|
136
157
|
const parsed = JSON.parse(value);
|
|
137
|
-
if (!Array.isArray(parsed) || !parsed.every(
|
|
138
|
-
this.logService.error(
|
|
158
|
+
if (!Array.isArray(parsed) || !parsed.every(t => typeof t.created_at === "number" && isAuthorizationTokenResponse(t))) {
|
|
159
|
+
this.logService.error(
|
|
160
|
+
`Invalid session data for ${authProviderId} (${clientId}) in secret storage:`,
|
|
161
|
+
parsed
|
|
162
|
+
);
|
|
139
163
|
await this.secretStorageService.delete(key);
|
|
140
164
|
return undefined;
|
|
141
165
|
}
|
|
@@ -144,16 +168,19 @@ let DynamicAuthenticationProviderStorageService = class DynamicAuthenticationPro
|
|
|
144
168
|
return undefined;
|
|
145
169
|
}
|
|
146
170
|
async setSessionsForDynamicAuthProvider(authProviderId, clientId, sessions) {
|
|
147
|
-
const key = JSON.stringify({
|
|
171
|
+
const key = JSON.stringify({
|
|
172
|
+
isDynamicAuthProvider: true,
|
|
173
|
+
authProviderId,
|
|
174
|
+
clientId
|
|
175
|
+
});
|
|
148
176
|
const value = JSON.stringify(sessions);
|
|
149
177
|
await this.secretStorageService.set(key, value);
|
|
150
|
-
this.logService.trace(
|
|
178
|
+
this.logService.trace(
|
|
179
|
+
`Set session data for ${authProviderId} (${clientId}) in secret storage:`,
|
|
180
|
+
sessions
|
|
181
|
+
);
|
|
151
182
|
}
|
|
152
183
|
};
|
|
153
|
-
DynamicAuthenticationProviderStorageService = DynamicAuthenticationProviderStorageService_1 = ( __decorate([
|
|
154
|
-
( __param(0, IStorageService)),
|
|
155
|
-
( __param(1, ISecretStorageService)),
|
|
156
|
-
( __param(2, ILogService))
|
|
157
|
-
], DynamicAuthenticationProviderStorageService));
|
|
184
|
+
DynamicAuthenticationProviderStorageService = DynamicAuthenticationProviderStorageService_1 = ( __decorate([( __param(0, IStorageService)), ( __param(1, ISecretStorageService)), ( __param(2, ILogService))], DynamicAuthenticationProviderStorageService));
|
|
158
185
|
|
|
159
186
|
export { DynamicAuthenticationProviderStorageService };
|