@codingame/monaco-vscode-authentication-service-override 17.2.0 → 18.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +4 -1
- package/package.json +4 -4
- package/vscode/src/vs/workbench/services/authentication/browser/authenticationExtensionsService.js +10 -10
- package/vscode/src/vs/workbench/services/authentication/browser/dynamicAuthenticationProviderStorageService.d.ts +31 -0
- package/vscode/src/vs/workbench/services/authentication/browser/dynamicAuthenticationProviderStorageService.js +136 -0
package/index.js
CHANGED
|
@@ -8,13 +8,16 @@ import { AuthenticationUsageService } from './vscode/src/vs/workbench/services/a
|
|
|
8
8
|
import { AuthenticationExtensionsService } from './vscode/src/vs/workbench/services/authentication/browser/authenticationExtensionsService.js';
|
|
9
9
|
import { IAuthenticationAccessService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/authentication/browser/authenticationAccessService.service';
|
|
10
10
|
import { IAuthenticationUsageService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/authentication/browser/authenticationUsageService.service';
|
|
11
|
+
import { IDynamicAuthenticationProviderStorageService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/authentication/common/dynamicAuthenticationProviderStorage.service';
|
|
12
|
+
import { DynamicAuthenticationProviderStorageService } from './vscode/src/vs/workbench/services/authentication/browser/dynamicAuthenticationProviderStorageService.js';
|
|
11
13
|
|
|
12
14
|
function getServiceOverride() {
|
|
13
15
|
return {
|
|
14
16
|
[IAuthenticationService.toString()]: new SyncDescriptor(AuthenticationService, [], true),
|
|
15
17
|
[IAuthenticationAccessService.toString()]: new SyncDescriptor(AuthenticationAccessService, [], true),
|
|
16
18
|
[IAuthenticationExtensionsService.toString()]: new SyncDescriptor(AuthenticationExtensionsService, [], true),
|
|
17
|
-
[IAuthenticationUsageService.toString()]: new SyncDescriptor(AuthenticationUsageService, [], true)
|
|
19
|
+
[IAuthenticationUsageService.toString()]: new SyncDescriptor(AuthenticationUsageService, [], true),
|
|
20
|
+
[IDynamicAuthenticationProviderStorageService.toString()]: new SyncDescriptor(DynamicAuthenticationProviderStorageService, [], true)
|
|
18
21
|
};
|
|
19
22
|
}
|
|
20
23
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codingame/monaco-vscode-authentication-service-override",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "18.0.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "VSCode public API plugged on the monaco editor - authentication service-override",
|
|
6
6
|
"keywords": [],
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
},
|
|
16
16
|
"type": "module",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@codingame/monaco-vscode-
|
|
19
|
-
"@codingame/monaco-vscode-api": "
|
|
20
|
-
"@codingame/monaco-vscode-f22e7e55-aee8-5b52-a6bc-950efd9f5890-common": "
|
|
18
|
+
"@codingame/monaco-vscode-937ecbdf-94c7-5b16-aefa-ad78ae557a93-common": "18.0.0",
|
|
19
|
+
"@codingame/monaco-vscode-api": "18.0.0",
|
|
20
|
+
"@codingame/monaco-vscode-f22e7e55-aee8-5b52-a6bc-950efd9f5890-common": "18.0.0"
|
|
21
21
|
},
|
|
22
22
|
"main": "index.js",
|
|
23
23
|
"module": "index.js",
|
package/vscode/src/vs/workbench/services/authentication/browser/authenticationExtensionsService.js
CHANGED
|
@@ -10,7 +10,7 @@ import '@codingame/monaco-vscode-api/vscode/vs/platform/notification/common/noti
|
|
|
10
10
|
import { IQuickInputService } from '@codingame/monaco-vscode-api/vscode/vs/platform/quickinput/common/quickInput.service';
|
|
11
11
|
import { StorageScope, StorageTarget } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage';
|
|
12
12
|
import { IStorageService } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage.service';
|
|
13
|
-
import { NumberBadge } from '@codingame/monaco-vscode-
|
|
13
|
+
import { NumberBadge } from '@codingame/monaco-vscode-937ecbdf-94c7-5b16-aefa-ad78ae557a93-common/vscode/vs/workbench/services/activity/common/activity';
|
|
14
14
|
import { IActivityService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/activity/common/activity.service';
|
|
15
15
|
import { IAuthenticationAccessService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/authentication/browser/authenticationAccessService.service';
|
|
16
16
|
import { IAuthenticationUsageService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/authentication/browser/authenticationUsageService.service';
|
|
@@ -112,7 +112,7 @@ let AuthenticationExtensionsService = class AuthenticationExtensionsService exte
|
|
|
112
112
|
numberOfRequests += ( Object.keys(accessRequest)).length;
|
|
113
113
|
});
|
|
114
114
|
if (numberOfRequests > 0) {
|
|
115
|
-
const badge = ( new NumberBadge(numberOfRequests, () => ( localize(
|
|
115
|
+
const badge = ( new NumberBadge(numberOfRequests, () => ( localize(12304, "Sign in requested"))));
|
|
116
116
|
this._accountBadgeDisposable.value = this.activityService.showAccountsActivity({ badge });
|
|
117
117
|
}
|
|
118
118
|
}
|
|
@@ -179,7 +179,7 @@ let AuthenticationExtensionsService = class AuthenticationExtensionsService exte
|
|
|
179
179
|
const { result } = await this.dialogService.prompt({
|
|
180
180
|
type: Severity.Info,
|
|
181
181
|
message: ( localize(
|
|
182
|
-
|
|
182
|
+
12305,
|
|
183
183
|
"The extension '{0}' wants to access the {1} account '{2}'.",
|
|
184
184
|
extensionName,
|
|
185
185
|
provider.label,
|
|
@@ -187,11 +187,11 @@ let AuthenticationExtensionsService = class AuthenticationExtensionsService exte
|
|
|
187
187
|
)),
|
|
188
188
|
buttons: [
|
|
189
189
|
{
|
|
190
|
-
label: ( localize(
|
|
190
|
+
label: ( localize(12306, "&&Allow")),
|
|
191
191
|
run: () => SessionPromptChoice.Allow
|
|
192
192
|
},
|
|
193
193
|
{
|
|
194
|
-
label: ( localize(
|
|
194
|
+
label: ( localize(12307, "&&Deny")),
|
|
195
195
|
run: () => SessionPromptChoice.Deny
|
|
196
196
|
}
|
|
197
197
|
],
|
|
@@ -227,16 +227,16 @@ let AuthenticationExtensionsService = class AuthenticationExtensionsService exte
|
|
|
227
227
|
items.push({ label: account.label, account });
|
|
228
228
|
}
|
|
229
229
|
});
|
|
230
|
-
items.push({ label: ( localize(
|
|
230
|
+
items.push({ label: ( localize(12308, "Sign in to another account")) });
|
|
231
231
|
quickPick.items = items;
|
|
232
232
|
quickPick.title = ( localize(
|
|
233
|
-
|
|
233
|
+
12309,
|
|
234
234
|
"The extension '{0}' wants to access a {1} account",
|
|
235
235
|
extensionName,
|
|
236
236
|
this._authenticationService.getProvider(providerId).label
|
|
237
237
|
));
|
|
238
238
|
quickPick.placeholder = ( localize(
|
|
239
|
-
|
|
239
|
+
12310,
|
|
240
240
|
"Select an account for '{0}' to use or Esc to cancel",
|
|
241
241
|
extensionName
|
|
242
242
|
));
|
|
@@ -308,7 +308,7 @@ let AuthenticationExtensionsService = class AuthenticationExtensionsService exte
|
|
|
308
308
|
group: '3_accessRequests',
|
|
309
309
|
command: {
|
|
310
310
|
id: `${providerId}${extensionId}Access`,
|
|
311
|
-
title: ( localize(
|
|
311
|
+
title: ( localize(12311, "Grant access to {0} for {1}... (1)", provider.label, extensionName))
|
|
312
312
|
}
|
|
313
313
|
}));
|
|
314
314
|
const accessCommand = CommandsRegistry.registerCommand({
|
|
@@ -352,7 +352,7 @@ let AuthenticationExtensionsService = class AuthenticationExtensionsService exte
|
|
|
352
352
|
group: '2_signInRequests',
|
|
353
353
|
command: {
|
|
354
354
|
id: commandId,
|
|
355
|
-
title: ( localize(
|
|
355
|
+
title: ( localize(12312, "Sign in with {0} to use {1} (1)", provider.label, extensionName))
|
|
356
356
|
}
|
|
357
357
|
}));
|
|
358
358
|
const signInCommand = CommandsRegistry.registerCommand({
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { IStorageService } from "@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage.service";
|
|
2
|
+
import { DynamicAuthenticationProviderInfo, DynamicAuthenticationProviderTokensChangeEvent } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/authentication/common/dynamicAuthenticationProviderStorage";
|
|
3
|
+
import { IDynamicAuthenticationProviderStorageService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/authentication/common/dynamicAuthenticationProviderStorage.service";
|
|
4
|
+
import { ISecretStorageService } from "@codingame/monaco-vscode-api/vscode/vs/platform/secrets/common/secrets.service";
|
|
5
|
+
import { IAuthorizationTokenResponse } from "@codingame/monaco-vscode-api/vscode/vs/base/common/oauth";
|
|
6
|
+
import { ILogService } from "@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service";
|
|
7
|
+
import { Event } from "@codingame/monaco-vscode-api/vscode/vs/base/common/event";
|
|
8
|
+
import { Disposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
|
|
9
|
+
export declare class DynamicAuthenticationProviderStorageService extends Disposable implements IDynamicAuthenticationProviderStorageService {
|
|
10
|
+
private readonly storageService;
|
|
11
|
+
private readonly secretStorageService;
|
|
12
|
+
private readonly logService;
|
|
13
|
+
readonly _serviceBrand: undefined;
|
|
14
|
+
private static readonly PROVIDERS_STORAGE_KEY;
|
|
15
|
+
private readonly _onDidChangeTokens;
|
|
16
|
+
readonly onDidChangeTokens: Event<DynamicAuthenticationProviderTokensChangeEvent>;
|
|
17
|
+
constructor(storageService: IStorageService, secretStorageService: ISecretStorageService, logService: ILogService);
|
|
18
|
+
getClientId(providerId: string): string | undefined;
|
|
19
|
+
storeClientId(providerId: string, authorizationServer: string, clientId: string, label?: string): void;
|
|
20
|
+
private _trackProvider;
|
|
21
|
+
private _getStoredProviders;
|
|
22
|
+
private _storeProviders;
|
|
23
|
+
getInteractedProviders(): ReadonlyArray<DynamicAuthenticationProviderInfo>;
|
|
24
|
+
removeDynamicProvider(providerId: string): Promise<void>;
|
|
25
|
+
getSessionsForDynamicAuthProvider(authProviderId: string, clientId: string): Promise<(IAuthorizationTokenResponse & {
|
|
26
|
+
created_at: number;
|
|
27
|
+
})[] | undefined>;
|
|
28
|
+
setSessionsForDynamicAuthProvider(authProviderId: string, clientId: string, sessions: (IAuthorizationTokenResponse & {
|
|
29
|
+
created_at: number;
|
|
30
|
+
})[]): Promise<void>;
|
|
31
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
|
|
2
|
+
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
|
+
import { StorageScope, StorageTarget } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage';
|
|
4
|
+
import { IStorageService } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage.service';
|
|
5
|
+
import '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/extensions';
|
|
6
|
+
import '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
|
|
7
|
+
import { ISecretStorageService } from '@codingame/monaco-vscode-api/vscode/vs/platform/secrets/common/secrets.service';
|
|
8
|
+
import { isAuthorizationTokenResponse } from '@codingame/monaco-vscode-api/vscode/vs/base/common/oauth';
|
|
9
|
+
import { ILogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service';
|
|
10
|
+
import { Emitter } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
|
|
11
|
+
import { Disposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
12
|
+
import { Queue } from '@codingame/monaco-vscode-api/vscode/vs/base/common/async';
|
|
13
|
+
|
|
14
|
+
var DynamicAuthenticationProviderStorageService_1;
|
|
15
|
+
let DynamicAuthenticationProviderStorageService = class DynamicAuthenticationProviderStorageService extends Disposable {
|
|
16
|
+
static { DynamicAuthenticationProviderStorageService_1 = this; }
|
|
17
|
+
static { this.PROVIDERS_STORAGE_KEY = 'dynamicAuthProviders'; }
|
|
18
|
+
constructor(storageService, secretStorageService, logService) {
|
|
19
|
+
super();
|
|
20
|
+
this.storageService = storageService;
|
|
21
|
+
this.secretStorageService = secretStorageService;
|
|
22
|
+
this.logService = logService;
|
|
23
|
+
this._onDidChangeTokens = this._register(( new Emitter()));
|
|
24
|
+
this.onDidChangeTokens = this._onDidChangeTokens.event;
|
|
25
|
+
const queue = ( new Queue());
|
|
26
|
+
this._register(this.secretStorageService.onDidChangeSecret(async (key) => {
|
|
27
|
+
let payload;
|
|
28
|
+
try {
|
|
29
|
+
payload = JSON.parse(key);
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
}
|
|
33
|
+
if (payload?.isDynamicAuthProvider) {
|
|
34
|
+
void queue.queue(async () => {
|
|
35
|
+
const tokens = await this.getSessionsForDynamicAuthProvider(payload.authProviderId, payload.clientId);
|
|
36
|
+
this._onDidChangeTokens.fire({
|
|
37
|
+
authProviderId: payload.authProviderId,
|
|
38
|
+
clientId: payload.clientId,
|
|
39
|
+
tokens
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}));
|
|
44
|
+
}
|
|
45
|
+
getClientId(providerId) {
|
|
46
|
+
const providers = this._getStoredProviders();
|
|
47
|
+
const provider = providers.find(p => p.providerId === providerId);
|
|
48
|
+
return provider?.clientId;
|
|
49
|
+
}
|
|
50
|
+
storeClientId(providerId, authorizationServer, clientId, label) {
|
|
51
|
+
this._trackProvider(providerId, authorizationServer, clientId, label);
|
|
52
|
+
}
|
|
53
|
+
_trackProvider(providerId, authorizationServer, clientId, label) {
|
|
54
|
+
const providers = this._getStoredProviders();
|
|
55
|
+
const existingProviderIndex = providers.findIndex(p => p.providerId === providerId);
|
|
56
|
+
if (existingProviderIndex === -1) {
|
|
57
|
+
const newProvider = {
|
|
58
|
+
providerId,
|
|
59
|
+
label: label || providerId,
|
|
60
|
+
authorizationServer,
|
|
61
|
+
clientId
|
|
62
|
+
};
|
|
63
|
+
providers.push(newProvider);
|
|
64
|
+
this._storeProviders(providers);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
const existingProvider = providers[existingProviderIndex];
|
|
68
|
+
const updatedProvider = {
|
|
69
|
+
providerId,
|
|
70
|
+
label: label || existingProvider.label,
|
|
71
|
+
authorizationServer,
|
|
72
|
+
clientId
|
|
73
|
+
};
|
|
74
|
+
providers[existingProviderIndex] = updatedProvider;
|
|
75
|
+
this._storeProviders(providers);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
_getStoredProviders() {
|
|
79
|
+
const stored = this.storageService.get(DynamicAuthenticationProviderStorageService_1.PROVIDERS_STORAGE_KEY, StorageScope.APPLICATION, '[]');
|
|
80
|
+
try {
|
|
81
|
+
const providerInfos = JSON.parse(stored);
|
|
82
|
+
for (const providerInfo of providerInfos) {
|
|
83
|
+
if (!providerInfo.authorizationServer) {
|
|
84
|
+
providerInfo.authorizationServer = providerInfo.issuer;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return providerInfos;
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
return [];
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
_storeProviders(providers) {
|
|
94
|
+
this.storageService.store(DynamicAuthenticationProviderStorageService_1.PROVIDERS_STORAGE_KEY, JSON.stringify(providers), StorageScope.APPLICATION, StorageTarget.MACHINE);
|
|
95
|
+
}
|
|
96
|
+
getInteractedProviders() {
|
|
97
|
+
return this._getStoredProviders();
|
|
98
|
+
}
|
|
99
|
+
async removeDynamicProvider(providerId) {
|
|
100
|
+
const providers = this._getStoredProviders();
|
|
101
|
+
const providerInfo = providers.find(p => p.providerId === providerId);
|
|
102
|
+
const filteredProviders = providers.filter(p => p.providerId !== providerId);
|
|
103
|
+
this._storeProviders(filteredProviders);
|
|
104
|
+
if (providerInfo) {
|
|
105
|
+
const secretKey = JSON.stringify({ isDynamicAuthProvider: true, authProviderId: providerId, clientId: providerInfo.clientId });
|
|
106
|
+
await this.secretStorageService.delete(secretKey);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
async getSessionsForDynamicAuthProvider(authProviderId, clientId) {
|
|
110
|
+
const key = JSON.stringify({ isDynamicAuthProvider: true, authProviderId, clientId });
|
|
111
|
+
const value = await this.secretStorageService.get(key);
|
|
112
|
+
if (value) {
|
|
113
|
+
const parsed = JSON.parse(value);
|
|
114
|
+
if (!Array.isArray(parsed) || !parsed.every((t) => typeof t.created_at === 'number' && isAuthorizationTokenResponse(t))) {
|
|
115
|
+
this.logService.error(`Invalid session data for ${authProviderId} (${clientId}) in secret storage:`, parsed);
|
|
116
|
+
await this.secretStorageService.delete(key);
|
|
117
|
+
return undefined;
|
|
118
|
+
}
|
|
119
|
+
return parsed;
|
|
120
|
+
}
|
|
121
|
+
return undefined;
|
|
122
|
+
}
|
|
123
|
+
async setSessionsForDynamicAuthProvider(authProviderId, clientId, sessions) {
|
|
124
|
+
const key = JSON.stringify({ isDynamicAuthProvider: true, authProviderId, clientId });
|
|
125
|
+
const value = JSON.stringify(sessions);
|
|
126
|
+
await this.secretStorageService.set(key, value);
|
|
127
|
+
this.logService.trace(`Set session data for ${authProviderId} (${clientId}) in secret storage:`, sessions);
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
DynamicAuthenticationProviderStorageService = DynamicAuthenticationProviderStorageService_1 = ( __decorate([
|
|
131
|
+
( __param(0, IStorageService)),
|
|
132
|
+
( __param(1, ISecretStorageService)),
|
|
133
|
+
( __param(2, ILogService))
|
|
134
|
+
], DynamicAuthenticationProviderStorageService));
|
|
135
|
+
|
|
136
|
+
export { DynamicAuthenticationProviderStorageService };
|