@codingame/monaco-vscode-authentication-service-override 11.1.2 → 12.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.d.ts +2 -1
- package/index.js +21 -1
- package/package.json +16 -7
- package/vscode/src/vs/workbench/services/authentication/browser/authenticationAccessService.d.ts +21 -0
- package/vscode/src/vs/workbench/services/authentication/browser/authenticationAccessService.js +7 -4
- package/vscode/src/vs/workbench/services/authentication/browser/authenticationExtensionsService.d.ts +51 -0
- package/vscode/src/vs/workbench/services/authentication/browser/authenticationExtensionsService.js +70 -63
- package/vscode/src/vs/workbench/services/authentication/browser/authenticationUsageService.d.ts +27 -0
- package/vscode/src/vs/workbench/services/authentication/browser/authenticationUsageService.js +7 -4
- package/authentication.js +0 -19
package/index.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { type IEditorOverrideServices } from "vscode/vscode/vs/editor/standalone/browser/standaloneServices";
|
|
2
|
+
export default function getServiceOverride(): IEditorOverrideServices;
|
package/index.js
CHANGED
|
@@ -1 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
import 'vscode/vscode/vs/editor/standalone/browser/standaloneServices';
|
|
3
|
+
import { SyncDescriptor } from 'vscode/vscode/vs/platform/instantiation/common/descriptors';
|
|
4
|
+
import { IAuthenticationService, IAuthenticationExtensionsService } from 'vscode/vscode/vs/workbench/services/authentication/common/authentication.service';
|
|
5
|
+
import { AuthenticationService } from '@codingame/monaco-vscode-3607c442-ae7a-594b-b840-038378c24fef-common/vscode/vs/workbench/services/authentication/browser/authenticationService';
|
|
6
|
+
import { AuthenticationAccessService } from './vscode/src/vs/workbench/services/authentication/browser/authenticationAccessService.js';
|
|
7
|
+
import { AuthenticationUsageService } from './vscode/src/vs/workbench/services/authentication/browser/authenticationUsageService.js';
|
|
8
|
+
import { AuthenticationExtensionsService } from './vscode/src/vs/workbench/services/authentication/browser/authenticationExtensionsService.js';
|
|
9
|
+
import { IAuthenticationAccessService } from 'vscode/vscode/vs/workbench/services/authentication/browser/authenticationAccessService.service';
|
|
10
|
+
import { IAuthenticationUsageService } from 'vscode/vscode/vs/workbench/services/authentication/browser/authenticationUsageService.service';
|
|
11
|
+
|
|
12
|
+
function getServiceOverride() {
|
|
13
|
+
return {
|
|
14
|
+
[IAuthenticationService.toString()]: new SyncDescriptor(AuthenticationService, [], true),
|
|
15
|
+
[IAuthenticationAccessService.toString()]: new SyncDescriptor(AuthenticationAccessService, [], true),
|
|
16
|
+
[IAuthenticationExtensionsService.toString()]: new SyncDescriptor(AuthenticationExtensionsService, [], true),
|
|
17
|
+
[IAuthenticationUsageService.toString()]: new SyncDescriptor(AuthenticationUsageService, [], true)
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { getServiceOverride as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codingame/monaco-vscode-authentication-service-override",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "12.0.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "VSCode public API plugged on the monaco editor - authentication service-override",
|
|
4
6
|
"keywords": [],
|
|
5
7
|
"author": {
|
|
6
8
|
"name": "CodinGame",
|
|
@@ -12,8 +14,13 @@
|
|
|
12
14
|
"url": "git+ssh://git@github.com/CodinGame/monaco-vscode-api.git"
|
|
13
15
|
},
|
|
14
16
|
"type": "module",
|
|
15
|
-
"
|
|
16
|
-
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@codingame/monaco-vscode-3607c442-ae7a-594b-b840-038378c24fef-common": "12.0.0",
|
|
19
|
+
"@codingame/monaco-vscode-a7c9ae3c-16d2-5d17-86b2-981be7094566-common": "12.0.0",
|
|
20
|
+
"vscode": "npm:@codingame/monaco-vscode-api@12.0.0"
|
|
21
|
+
},
|
|
22
|
+
"peerDependencies": {},
|
|
23
|
+
"peerDependenciesMeta": {},
|
|
17
24
|
"main": "index.js",
|
|
18
25
|
"module": "index.js",
|
|
19
26
|
"types": "index.d.ts",
|
|
@@ -22,10 +29,12 @@
|
|
|
22
29
|
"default": "./index.js"
|
|
23
30
|
},
|
|
24
31
|
"./vscode/*": {
|
|
25
|
-
"default": "./vscode/src/*.js"
|
|
32
|
+
"default": "./vscode/src/*.js",
|
|
33
|
+
"types": "./vscode/src/*.d.ts"
|
|
34
|
+
},
|
|
35
|
+
"./*": {
|
|
36
|
+
"default": "./*.js",
|
|
37
|
+
"types": "./*.d.ts"
|
|
26
38
|
}
|
|
27
|
-
},
|
|
28
|
-
"dependencies": {
|
|
29
|
-
"vscode": "npm:@codingame/monaco-vscode-api@11.1.2"
|
|
30
39
|
}
|
|
31
40
|
}
|
package/vscode/src/vs/workbench/services/authentication/browser/authenticationAccessService.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Event } from "vscode/vscode/vs/base/common/event";
|
|
2
|
+
import { Disposable } from "vscode/vscode/vs/base/common/lifecycle";
|
|
3
|
+
import { IProductService } from "vscode/vscode/vs/platform/product/common/productService.service";
|
|
4
|
+
import { IStorageService } from "vscode/vscode/vs/platform/storage/common/storage.service";
|
|
5
|
+
import { AllowedExtension } from "vscode/vscode/vs/workbench/services/authentication/common/authentication";
|
|
6
|
+
import { IAuthenticationAccessService } from "vscode/vscode/vs/workbench/services/authentication/browser/authenticationAccessService.service";
|
|
7
|
+
export declare class AuthenticationAccessService extends Disposable implements IAuthenticationAccessService {
|
|
8
|
+
private readonly _storageService;
|
|
9
|
+
private readonly _productService;
|
|
10
|
+
_serviceBrand: undefined;
|
|
11
|
+
private _onDidChangeExtensionSessionAccess;
|
|
12
|
+
readonly onDidChangeExtensionSessionAccess: Event<{
|
|
13
|
+
providerId: string;
|
|
14
|
+
accountName: string;
|
|
15
|
+
}>;
|
|
16
|
+
constructor(_storageService: IStorageService, _productService: IProductService);
|
|
17
|
+
isAccessAllowed(providerId: string, accountName: string, extensionId: string): boolean | undefined;
|
|
18
|
+
readAllowedExtensions(providerId: string, accountName: string): AllowedExtension[];
|
|
19
|
+
updateAllowedExtensions(providerId: string, accountName: string, extensions: AllowedExtension[]): void;
|
|
20
|
+
removeAllowedExtensions(providerId: string, accountName: string): void;
|
|
21
|
+
}
|
package/vscode/src/vs/workbench/services/authentication/browser/authenticationAccessService.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
import { __decorate, __param } from 'vscode/external/tslib/tslib.es6';
|
|
2
3
|
import { Emitter } from 'vscode/vscode/vs/base/common/event';
|
|
3
4
|
import { Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
5
|
+
import 'vscode/vscode/vs/platform/instantiation/common/extensions';
|
|
4
6
|
import { IProductService } from 'vscode/vscode/vs/platform/product/common/productService.service';
|
|
7
|
+
import { StorageScope, StorageTarget } from 'vscode/vscode/vs/platform/storage/common/storage';
|
|
5
8
|
import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage.service';
|
|
6
9
|
import 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
7
10
|
|
|
@@ -35,7 +38,7 @@ let AuthenticationAccessService = class AuthenticationAccessService extends Disp
|
|
|
35
38
|
readAllowedExtensions(providerId, accountName) {
|
|
36
39
|
let trustedExtensions = [];
|
|
37
40
|
try {
|
|
38
|
-
const trustedExtensionSrc = this._storageService.get(`${providerId}-${accountName}`,
|
|
41
|
+
const trustedExtensionSrc = this._storageService.get(`${providerId}-${accountName}`, StorageScope.APPLICATION);
|
|
39
42
|
if (trustedExtensionSrc) {
|
|
40
43
|
trustedExtensions = JSON.parse(trustedExtensionSrc);
|
|
41
44
|
}
|
|
@@ -54,11 +57,11 @@ let AuthenticationAccessService = class AuthenticationAccessService extends Disp
|
|
|
54
57
|
allowList[index].allowed = extension.allowed;
|
|
55
58
|
}
|
|
56
59
|
}
|
|
57
|
-
this._storageService.store(`${providerId}-${accountName}`, JSON.stringify(allowList),
|
|
60
|
+
this._storageService.store(`${providerId}-${accountName}`, JSON.stringify(allowList), StorageScope.APPLICATION, StorageTarget.USER);
|
|
58
61
|
this._onDidChangeExtensionSessionAccess.fire({ providerId, accountName });
|
|
59
62
|
}
|
|
60
63
|
removeAllowedExtensions(providerId, accountName) {
|
|
61
|
-
this._storageService.remove(`${providerId}-${accountName}`,
|
|
64
|
+
this._storageService.remove(`${providerId}-${accountName}`, StorageScope.APPLICATION);
|
|
62
65
|
this._onDidChangeExtensionSessionAccess.fire({ providerId, accountName });
|
|
63
66
|
}
|
|
64
67
|
};
|
package/vscode/src/vs/workbench/services/authentication/browser/authenticationExtensionsService.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Disposable } from "vscode/vscode/vs/base/common/lifecycle";
|
|
2
|
+
import { IDialogService } from "vscode/vscode/vs/platform/dialogs/common/dialogs.service";
|
|
3
|
+
import { IQuickInputService } from "vscode/vscode/vs/platform/quickinput/common/quickInput.service";
|
|
4
|
+
import { IStorageService } from "vscode/vscode/vs/platform/storage/common/storage.service";
|
|
5
|
+
import { IActivityService } from "vscode/vscode/vs/workbench/services/activity/common/activity.service";
|
|
6
|
+
import { IAuthenticationAccessService } from "vscode/vscode/vs/workbench/services/authentication/browser/authenticationAccessService.service";
|
|
7
|
+
import { IAuthenticationUsageService } from "vscode/vscode/vs/workbench/services/authentication/browser/authenticationUsageService.service";
|
|
8
|
+
import { AuthenticationSession, AuthenticationSessionAccount } from "vscode/vscode/vs/workbench/services/authentication/common/authentication";
|
|
9
|
+
import { IAuthenticationExtensionsService } from "vscode/vscode/vs/workbench/services/authentication/common/authentication.service";
|
|
10
|
+
import { IAuthenticationService } from "vscode/vscode/vs/workbench/services/authentication/common/authentication.service";
|
|
11
|
+
import { IProductService } from "vscode/vscode/vs/platform/product/common/productService.service";
|
|
12
|
+
export declare class AuthenticationExtensionsService extends Disposable implements IAuthenticationExtensionsService {
|
|
13
|
+
private readonly activityService;
|
|
14
|
+
private readonly storageService;
|
|
15
|
+
private readonly dialogService;
|
|
16
|
+
private readonly quickInputService;
|
|
17
|
+
private readonly _productService;
|
|
18
|
+
private readonly _authenticationService;
|
|
19
|
+
private readonly _authenticationUsageService;
|
|
20
|
+
private readonly _authenticationAccessService;
|
|
21
|
+
readonly _serviceBrand: undefined;
|
|
22
|
+
private _signInRequestItems;
|
|
23
|
+
private _sessionAccessRequestItems;
|
|
24
|
+
private readonly _accountBadgeDisposable;
|
|
25
|
+
private _onDidAccountPreferenceChange;
|
|
26
|
+
readonly onDidChangeAccountPreference: import("vscode/vscode/vs/base/common/event").Event<{
|
|
27
|
+
providerId: string;
|
|
28
|
+
extensionIds: string[];
|
|
29
|
+
}>;
|
|
30
|
+
private _inheritAuthAccountPreferenceParentToChildren;
|
|
31
|
+
private _inheritAuthAccountPreferenceChildToParent;
|
|
32
|
+
constructor(activityService: IActivityService, storageService: IStorageService, dialogService: IDialogService, quickInputService: IQuickInputService, _productService: IProductService, _authenticationService: IAuthenticationService, _authenticationUsageService: IAuthenticationUsageService, _authenticationAccessService: IAuthenticationAccessService);
|
|
33
|
+
private registerListeners;
|
|
34
|
+
private updateNewSessionRequests;
|
|
35
|
+
private updateAccessRequests;
|
|
36
|
+
private updateBadgeCount;
|
|
37
|
+
private removeAccessRequest;
|
|
38
|
+
updateAccountPreference(extensionId: string, providerId: string, account: AuthenticationSessionAccount): void;
|
|
39
|
+
getAccountPreference(extensionId: string, providerId: string): string | undefined;
|
|
40
|
+
removeAccountPreference(extensionId: string, providerId: string): void;
|
|
41
|
+
private _getKey;
|
|
42
|
+
updateSessionPreference(providerId: string, extensionId: string, session: AuthenticationSession): void;
|
|
43
|
+
getSessionPreference(providerId: string, extensionId: string, scopes: string[]): string | undefined;
|
|
44
|
+
removeSessionPreference(providerId: string, extensionId: string, scopes: string[]): void;
|
|
45
|
+
private _updateAccountAndSessionPreferences;
|
|
46
|
+
private showGetSessionPrompt;
|
|
47
|
+
selectSession(providerId: string, extensionId: string, extensionName: string, scopes: string[], availableSessions: AuthenticationSession[]): Promise<AuthenticationSession>;
|
|
48
|
+
private completeSessionAccessRequest;
|
|
49
|
+
requestSessionAccess(providerId: string, extensionId: string, extensionName: string, scopes: string[], possibleSessions: AuthenticationSession[]): void;
|
|
50
|
+
requestNewSession(providerId: string, scopes: string[], extensionId: string, extensionName: string): Promise<void>;
|
|
51
|
+
}
|
package/vscode/src/vs/workbench/services/authentication/browser/authenticationExtensionsService.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
import { __decorate, __param } from 'vscode/external/tslib/tslib.es6';
|
|
2
3
|
import { Disposable, MutableDisposable, dispose, DisposableStore } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
3
4
|
import { localize } from 'vscode/vscode/vs/nls';
|
|
4
5
|
import { MenuRegistry, MenuId } from 'vscode/vscode/vs/platform/actions/common/actions';
|
|
5
6
|
import { CommandsRegistry } from 'vscode/vscode/vs/platform/commands/common/commands';
|
|
6
7
|
import { IDialogService } from 'vscode/vscode/vs/platform/dialogs/common/dialogs.service';
|
|
8
|
+
import 'vscode/vscode/vs/platform/instantiation/common/extensions';
|
|
7
9
|
import 'vscode/vscode/vs/platform/notification/common/notification';
|
|
8
10
|
import { IQuickInputService } from 'vscode/vscode/vs/platform/quickinput/common/quickInput.service';
|
|
11
|
+
import { StorageScope, StorageTarget } from 'vscode/vscode/vs/platform/storage/common/storage';
|
|
9
12
|
import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage.service';
|
|
10
|
-
import { NumberBadge } from 'vscode/vscode/vs/workbench/services/activity/common/activity';
|
|
13
|
+
import { NumberBadge } from '@codingame/monaco-vscode-a7c9ae3c-16d2-5d17-86b2-981be7094566-common/vscode/vs/workbench/services/activity/common/activity';
|
|
11
14
|
import { IActivityService } from 'vscode/vscode/vs/workbench/services/activity/common/activity.service';
|
|
12
15
|
import { IAuthenticationAccessService } from 'vscode/vscode/vs/workbench/services/authentication/browser/authenticationAccessService.service';
|
|
13
16
|
import { IAuthenticationUsageService } from 'vscode/vscode/vs/workbench/services/authentication/browser/authenticationUsageService.service';
|
|
@@ -15,7 +18,7 @@ import { IAuthenticationService } from 'vscode/vscode/vs/workbench/services/auth
|
|
|
15
18
|
import { Emitter } from 'vscode/vscode/vs/base/common/event';
|
|
16
19
|
import { IProductService } from 'vscode/vscode/vs/platform/product/common/productService.service';
|
|
17
20
|
import { ExtensionIdentifier } from 'vscode/vscode/vs/platform/extensions/common/extensions';
|
|
18
|
-
import Severity
|
|
21
|
+
import Severity from 'vscode/vscode/vs/base/common/severity';
|
|
19
22
|
|
|
20
23
|
const SCOPESLIST_SEPARATOR = ' ';
|
|
21
24
|
let AuthenticationExtensionsService = class AuthenticationExtensionsService extends Disposable {
|
|
@@ -29,10 +32,10 @@ let AuthenticationExtensionsService = class AuthenticationExtensionsService exte
|
|
|
29
32
|
this._authenticationService = _authenticationService;
|
|
30
33
|
this._authenticationUsageService = _authenticationUsageService;
|
|
31
34
|
this._authenticationAccessService = _authenticationAccessService;
|
|
32
|
-
this._signInRequestItems = (
|
|
33
|
-
this._sessionAccessRequestItems = (
|
|
34
|
-
this._accountBadgeDisposable = this._register((
|
|
35
|
-
this._onDidAccountPreferenceChange = this._register((
|
|
35
|
+
this._signInRequestItems = ( new Map());
|
|
36
|
+
this._sessionAccessRequestItems = ( new Map());
|
|
37
|
+
this._accountBadgeDisposable = this._register(( new MutableDisposable()));
|
|
38
|
+
this._onDidAccountPreferenceChange = this._register(( new Emitter()));
|
|
36
39
|
this.onDidChangeAccountPreference = this._onDidAccountPreferenceChange.event;
|
|
37
40
|
this._inheritAuthAccountPreferenceParentToChildren = this._productService.inheritAuthAccountPreference || {};
|
|
38
41
|
this._inheritAuthAccountPreferenceChildToParent = Object.entries(this._inheritAuthAccountPreferenceParentToChildren).reduce((acc, [parent, children]) => {
|
|
@@ -55,7 +58,7 @@ let AuthenticationExtensionsService = class AuthenticationExtensionsService exte
|
|
|
55
58
|
}));
|
|
56
59
|
this._register(this._authenticationService.onDidUnregisterAuthenticationProvider(e => {
|
|
57
60
|
const accessRequests = this._sessionAccessRequestItems.get(e.id) || {};
|
|
58
|
-
(
|
|
61
|
+
( Object.keys(accessRequests)).forEach(extensionId => {
|
|
59
62
|
this.removeAccessRequest(e.id, extensionId);
|
|
60
63
|
});
|
|
61
64
|
}));
|
|
@@ -65,14 +68,14 @@ let AuthenticationExtensionsService = class AuthenticationExtensionsService exte
|
|
|
65
68
|
if (!existingRequestsForProvider) {
|
|
66
69
|
return;
|
|
67
70
|
}
|
|
68
|
-
(
|
|
69
|
-
if ((
|
|
71
|
+
( Object.keys(existingRequestsForProvider)).forEach(requestedScopes => {
|
|
72
|
+
if (( addedSessions.some(
|
|
70
73
|
session => session.scopes.slice().join(SCOPESLIST_SEPARATOR) === requestedScopes
|
|
71
|
-
)))
|
|
74
|
+
))) {
|
|
72
75
|
const sessionRequest = existingRequestsForProvider[requestedScopes];
|
|
73
76
|
sessionRequest?.disposables.forEach(item => item.dispose());
|
|
74
77
|
delete existingRequestsForProvider[requestedScopes];
|
|
75
|
-
if ((
|
|
78
|
+
if (( Object.keys(existingRequestsForProvider)).length === 0) {
|
|
76
79
|
this._signInRequestItems.delete(providerId);
|
|
77
80
|
}
|
|
78
81
|
else {
|
|
@@ -84,7 +87,7 @@ let AuthenticationExtensionsService = class AuthenticationExtensionsService exte
|
|
|
84
87
|
async updateAccessRequests(providerId, removedSessions) {
|
|
85
88
|
const providerRequests = this._sessionAccessRequestItems.get(providerId);
|
|
86
89
|
if (providerRequests) {
|
|
87
|
-
(
|
|
90
|
+
( Object.keys(providerRequests)).forEach(extensionId => {
|
|
88
91
|
removedSessions.forEach(removed => {
|
|
89
92
|
const indexOfSession = providerRequests[extensionId].possibleSessions.findIndex(session => session.id === removed.id);
|
|
90
93
|
if (indexOfSession) {
|
|
@@ -101,15 +104,15 @@ let AuthenticationExtensionsService = class AuthenticationExtensionsService exte
|
|
|
101
104
|
this._accountBadgeDisposable.clear();
|
|
102
105
|
let numberOfRequests = 0;
|
|
103
106
|
this._signInRequestItems.forEach(providerRequests => {
|
|
104
|
-
(
|
|
107
|
+
( Object.keys(providerRequests)).forEach(request => {
|
|
105
108
|
numberOfRequests += providerRequests[request].requestingExtensionIds.length;
|
|
106
109
|
});
|
|
107
110
|
});
|
|
108
111
|
this._sessionAccessRequestItems.forEach(accessRequest => {
|
|
109
|
-
numberOfRequests += (
|
|
112
|
+
numberOfRequests += ( Object.keys(accessRequest)).length;
|
|
110
113
|
});
|
|
111
114
|
if (numberOfRequests > 0) {
|
|
112
|
-
const badge = (
|
|
115
|
+
const badge = ( new NumberBadge(numberOfRequests, () => ( localize(11244, "Sign in requested"))));
|
|
113
116
|
this._accountBadgeDisposable.value = this.activityService.showAccountsActivity({ badge });
|
|
114
117
|
}
|
|
115
118
|
}
|
|
@@ -125,8 +128,8 @@ let AuthenticationExtensionsService = class AuthenticationExtensionsService exte
|
|
|
125
128
|
const realExtensionId = ExtensionIdentifier.toKey(extensionId);
|
|
126
129
|
const parentExtensionId = this._inheritAuthAccountPreferenceChildToParent[realExtensionId] ?? realExtensionId;
|
|
127
130
|
const key = this._getKey(parentExtensionId, providerId);
|
|
128
|
-
this.storageService.store(key, account.label,
|
|
129
|
-
this.storageService.store(key, account.label,
|
|
131
|
+
this.storageService.store(key, account.label, StorageScope.WORKSPACE, StorageTarget.MACHINE);
|
|
132
|
+
this.storageService.store(key, account.label, StorageScope.APPLICATION, StorageTarget.MACHINE);
|
|
130
133
|
const childrenExtensions = this._inheritAuthAccountPreferenceParentToChildren[parentExtensionId];
|
|
131
134
|
const extensionIds = childrenExtensions ? [parentExtensionId, ...childrenExtensions] : [parentExtensionId];
|
|
132
135
|
this._onDidAccountPreferenceChange.fire({ extensionIds, providerId });
|
|
@@ -134,13 +137,13 @@ let AuthenticationExtensionsService = class AuthenticationExtensionsService exte
|
|
|
134
137
|
getAccountPreference(extensionId, providerId) {
|
|
135
138
|
const realExtensionId = ExtensionIdentifier.toKey(extensionId);
|
|
136
139
|
const key = this._getKey(this._inheritAuthAccountPreferenceChildToParent[realExtensionId] ?? realExtensionId, providerId);
|
|
137
|
-
return this.storageService.get(key,
|
|
140
|
+
return this.storageService.get(key, StorageScope.WORKSPACE) ?? this.storageService.get(key, StorageScope.APPLICATION);
|
|
138
141
|
}
|
|
139
142
|
removeAccountPreference(extensionId, providerId) {
|
|
140
143
|
const realExtensionId = ExtensionIdentifier.toKey(extensionId);
|
|
141
144
|
const key = this._getKey(this._inheritAuthAccountPreferenceChildToParent[realExtensionId] ?? realExtensionId, providerId);
|
|
142
|
-
this.storageService.remove(key,
|
|
143
|
-
this.storageService.remove(key,
|
|
145
|
+
this.storageService.remove(key, StorageScope.WORKSPACE);
|
|
146
|
+
this.storageService.remove(key, StorageScope.APPLICATION);
|
|
144
147
|
}
|
|
145
148
|
_getKey(extensionId, providerId) {
|
|
146
149
|
return `${extensionId}-${providerId}`;
|
|
@@ -148,19 +151,19 @@ let AuthenticationExtensionsService = class AuthenticationExtensionsService exte
|
|
|
148
151
|
updateSessionPreference(providerId, extensionId, session) {
|
|
149
152
|
const realExtensionId = ExtensionIdentifier.toKey(extensionId);
|
|
150
153
|
const key = `${realExtensionId}-${providerId}-${session.scopes.join(SCOPESLIST_SEPARATOR)}`;
|
|
151
|
-
this.storageService.store(key, session.id,
|
|
152
|
-
this.storageService.store(key, session.id,
|
|
154
|
+
this.storageService.store(key, session.id, StorageScope.WORKSPACE, StorageTarget.MACHINE);
|
|
155
|
+
this.storageService.store(key, session.id, StorageScope.APPLICATION, StorageTarget.MACHINE);
|
|
153
156
|
}
|
|
154
157
|
getSessionPreference(providerId, extensionId, scopes) {
|
|
155
158
|
const realExtensionId = ExtensionIdentifier.toKey(extensionId);
|
|
156
159
|
const key = `${realExtensionId}-${providerId}-${scopes.join(SCOPESLIST_SEPARATOR)}`;
|
|
157
|
-
return this.storageService.get(key,
|
|
160
|
+
return this.storageService.get(key, StorageScope.WORKSPACE) ?? this.storageService.get(key, StorageScope.APPLICATION);
|
|
158
161
|
}
|
|
159
162
|
removeSessionPreference(providerId, extensionId, scopes) {
|
|
160
163
|
const realExtensionId = ExtensionIdentifier.toKey(extensionId);
|
|
161
164
|
const key = `${realExtensionId}-${providerId}-${scopes.join(SCOPESLIST_SEPARATOR)}`;
|
|
162
|
-
this.storageService.remove(key,
|
|
163
|
-
this.storageService.remove(key,
|
|
165
|
+
this.storageService.remove(key, StorageScope.WORKSPACE);
|
|
166
|
+
this.storageService.remove(key, StorageScope.APPLICATION);
|
|
164
167
|
}
|
|
165
168
|
_updateAccountAndSessionPreferences(providerId, extensionId, session) {
|
|
166
169
|
this.updateAccountPreference(extensionId, providerId, session.account);
|
|
@@ -168,15 +171,15 @@ let AuthenticationExtensionsService = class AuthenticationExtensionsService exte
|
|
|
168
171
|
}
|
|
169
172
|
async showGetSessionPrompt(provider, accountName, extensionId, extensionName) {
|
|
170
173
|
let SessionPromptChoice;
|
|
171
|
-
( (
|
|
174
|
+
(function (SessionPromptChoice) {
|
|
172
175
|
SessionPromptChoice[SessionPromptChoice["Allow"] = 0] = "Allow";
|
|
173
176
|
SessionPromptChoice[SessionPromptChoice["Deny"] = 1] = "Deny";
|
|
174
177
|
SessionPromptChoice[SessionPromptChoice["Cancel"] = 2] = "Cancel";
|
|
175
|
-
})(SessionPromptChoice || (SessionPromptChoice = {}))
|
|
178
|
+
})(SessionPromptChoice || (SessionPromptChoice = {}));
|
|
176
179
|
const { result } = await this.dialogService.prompt({
|
|
177
|
-
type: Severity
|
|
180
|
+
type: Severity.Info,
|
|
178
181
|
message: ( localize(
|
|
179
|
-
|
|
182
|
+
11245,
|
|
180
183
|
"The extension '{0}' wants to access the {1} account '{2}'.",
|
|
181
184
|
extensionName,
|
|
182
185
|
provider.label,
|
|
@@ -184,11 +187,11 @@ let AuthenticationExtensionsService = class AuthenticationExtensionsService exte
|
|
|
184
187
|
)),
|
|
185
188
|
buttons: [
|
|
186
189
|
{
|
|
187
|
-
label: ( localize(
|
|
190
|
+
label: ( localize(11246, "&&Allow")),
|
|
188
191
|
run: () => SessionPromptChoice.Allow
|
|
189
192
|
},
|
|
190
193
|
{
|
|
191
|
-
label: ( localize(
|
|
194
|
+
label: ( localize(11247, "&&Deny")),
|
|
192
195
|
run: () => SessionPromptChoice.Deny
|
|
193
196
|
}
|
|
194
197
|
],
|
|
@@ -205,35 +208,39 @@ let AuthenticationExtensionsService = class AuthenticationExtensionsService exte
|
|
|
205
208
|
async selectSession(providerId, extensionId, extensionName, scopes, availableSessions) {
|
|
206
209
|
const allAccounts = await this._authenticationService.getAccounts(providerId);
|
|
207
210
|
if (!allAccounts.length) {
|
|
208
|
-
throw (
|
|
211
|
+
throw ( new Error('No accounts available'));
|
|
209
212
|
}
|
|
210
|
-
const disposables = (
|
|
213
|
+
const disposables = ( new DisposableStore());
|
|
211
214
|
const quickPick = disposables.add(this.quickInputService.createQuickPick());
|
|
212
215
|
quickPick.ignoreFocusOut = true;
|
|
213
|
-
const accountsWithSessions = (
|
|
214
|
-
const items = (
|
|
215
|
-
.filter(session => !(
|
|
216
|
+
const accountsWithSessions = ( new Set());
|
|
217
|
+
const items = ( availableSessions
|
|
218
|
+
.filter(session => !( accountsWithSessions.has(session.account.label)) && accountsWithSessions.add(session.account.label))
|
|
216
219
|
.map(session => {
|
|
217
220
|
return {
|
|
218
221
|
label: session.account.label,
|
|
219
222
|
session: session
|
|
220
223
|
};
|
|
221
|
-
}))
|
|
224
|
+
}));
|
|
222
225
|
allAccounts.forEach(account => {
|
|
223
|
-
if (!(
|
|
226
|
+
if (!( accountsWithSessions.has(account.label))) {
|
|
224
227
|
items.push({ label: account.label, account });
|
|
225
228
|
}
|
|
226
229
|
});
|
|
227
|
-
items.push({ label: ( localize(
|
|
230
|
+
items.push({ label: ( localize(11248, "Sign in to another account")) });
|
|
228
231
|
quickPick.items = items;
|
|
229
232
|
quickPick.title = ( localize(
|
|
230
|
-
|
|
233
|
+
11249,
|
|
231
234
|
"The extension '{0}' wants to access a {1} account",
|
|
232
235
|
extensionName,
|
|
233
236
|
this._authenticationService.getProvider(providerId).label
|
|
234
237
|
));
|
|
235
|
-
quickPick.placeholder = ( localize(
|
|
236
|
-
|
|
238
|
+
quickPick.placeholder = ( localize(
|
|
239
|
+
11250,
|
|
240
|
+
"Select an account for '{0}' to use or Esc to cancel",
|
|
241
|
+
extensionName
|
|
242
|
+
));
|
|
243
|
+
return await ( new Promise((resolve, reject) => {
|
|
237
244
|
disposables.add(quickPick.onDidAccept(async (_) => {
|
|
238
245
|
quickPick.dispose();
|
|
239
246
|
let session = quickPick.selectedItems[0].session;
|
|
@@ -260,7 +267,7 @@ let AuthenticationExtensionsService = class AuthenticationExtensionsService exte
|
|
|
260
267
|
disposables.dispose();
|
|
261
268
|
}));
|
|
262
269
|
quickPick.show();
|
|
263
|
-
}))
|
|
270
|
+
}));
|
|
264
271
|
}
|
|
265
272
|
async completeSessionAccessRequest(provider, extensionId, extensionName, scopes) {
|
|
266
273
|
const providerRequests = this._sessionAccessRequestItems.get(provider.id) || {};
|
|
@@ -297,13 +304,13 @@ let AuthenticationExtensionsService = class AuthenticationExtensionsService exte
|
|
|
297
304
|
return;
|
|
298
305
|
}
|
|
299
306
|
const provider = this._authenticationService.getProvider(providerId);
|
|
300
|
-
const menuItem = (
|
|
307
|
+
const menuItem = ( MenuRegistry.appendMenuItem(MenuId.AccountsContext, {
|
|
301
308
|
group: '3_accessRequests',
|
|
302
309
|
command: {
|
|
303
310
|
id: `${providerId}${extensionId}Access`,
|
|
304
|
-
title: ( localize(
|
|
311
|
+
title: ( localize(11251, "Grant access to {0} for {1}... (1)", provider.label, extensionName))
|
|
305
312
|
}
|
|
306
|
-
}))
|
|
313
|
+
}));
|
|
307
314
|
const accessCommand = CommandsRegistry.registerCommand({
|
|
308
315
|
id: `${providerId}${extensionId}Access`,
|
|
309
316
|
handler: async (accessor) => {
|
|
@@ -316,14 +323,14 @@ let AuthenticationExtensionsService = class AuthenticationExtensionsService exte
|
|
|
316
323
|
}
|
|
317
324
|
async requestNewSession(providerId, scopes, extensionId, extensionName) {
|
|
318
325
|
if (!this._authenticationService.isAuthenticationProviderRegistered(providerId)) {
|
|
319
|
-
await (
|
|
326
|
+
await ( new Promise((resolve, _) => {
|
|
320
327
|
const dispose = this._authenticationService.onDidRegisterAuthenticationProvider(e => {
|
|
321
328
|
if (e.id === providerId) {
|
|
322
329
|
dispose.dispose();
|
|
323
330
|
resolve();
|
|
324
331
|
}
|
|
325
332
|
});
|
|
326
|
-
}))
|
|
333
|
+
}));
|
|
327
334
|
}
|
|
328
335
|
let provider;
|
|
329
336
|
try {
|
|
@@ -340,14 +347,14 @@ let AuthenticationExtensionsService = class AuthenticationExtensionsService exte
|
|
|
340
347
|
if (extensionHasExistingRequest) {
|
|
341
348
|
return;
|
|
342
349
|
}
|
|
343
|
-
const commandId = `${providerId}:${extensionId}:signIn${(
|
|
344
|
-
const menuItem = (
|
|
350
|
+
const commandId = `${providerId}:${extensionId}:signIn${( Object.keys(providerRequests || [])).length}`;
|
|
351
|
+
const menuItem = ( MenuRegistry.appendMenuItem(MenuId.AccountsContext, {
|
|
345
352
|
group: '2_signInRequests',
|
|
346
353
|
command: {
|
|
347
354
|
id: commandId,
|
|
348
|
-
title: ( localize(
|
|
355
|
+
title: ( localize(11252, "Sign in with {0} to use {1} (1)", provider.label, extensionName))
|
|
349
356
|
}
|
|
350
|
-
}))
|
|
357
|
+
}));
|
|
351
358
|
const signInCommand = CommandsRegistry.registerCommand({
|
|
352
359
|
id: commandId,
|
|
353
360
|
handler: async (accessor) => {
|
|
@@ -376,15 +383,15 @@ let AuthenticationExtensionsService = class AuthenticationExtensionsService exte
|
|
|
376
383
|
this.updateBadgeCount();
|
|
377
384
|
}
|
|
378
385
|
};
|
|
379
|
-
AuthenticationExtensionsService = (
|
|
380
|
-
(
|
|
381
|
-
(
|
|
382
|
-
(
|
|
383
|
-
(
|
|
384
|
-
(
|
|
385
|
-
(
|
|
386
|
-
(
|
|
387
|
-
(
|
|
388
|
-
], AuthenticationExtensionsService))
|
|
386
|
+
AuthenticationExtensionsService = ( __decorate([
|
|
387
|
+
( __param(0, IActivityService)),
|
|
388
|
+
( __param(1, IStorageService)),
|
|
389
|
+
( __param(2, IDialogService)),
|
|
390
|
+
( __param(3, IQuickInputService)),
|
|
391
|
+
( __param(4, IProductService)),
|
|
392
|
+
( __param(5, IAuthenticationService)),
|
|
393
|
+
( __param(6, IAuthenticationUsageService)),
|
|
394
|
+
( __param(7, IAuthenticationAccessService))
|
|
395
|
+
], AuthenticationExtensionsService));
|
|
389
396
|
|
|
390
397
|
export { AuthenticationExtensionsService };
|
package/vscode/src/vs/workbench/services/authentication/browser/authenticationUsageService.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Disposable } from "vscode/vscode/vs/base/common/lifecycle";
|
|
2
|
+
import { ILogService } from "vscode/vscode/vs/platform/log/common/log.service";
|
|
3
|
+
import { IProductService } from "vscode/vscode/vs/platform/product/common/productService.service";
|
|
4
|
+
import { IStorageService } from "vscode/vscode/vs/platform/storage/common/storage.service";
|
|
5
|
+
import { IAuthenticationService } from "vscode/vscode/vs/workbench/services/authentication/common/authentication.service";
|
|
6
|
+
import { IAuthenticationUsageService } from "vscode/vscode/vs/workbench/services/authentication/browser/authenticationUsageService.service";
|
|
7
|
+
export interface IAccountUsage {
|
|
8
|
+
extensionId: string;
|
|
9
|
+
extensionName: string;
|
|
10
|
+
lastUsed: number;
|
|
11
|
+
scopes?: string[];
|
|
12
|
+
}
|
|
13
|
+
export declare class AuthenticationUsageService extends Disposable implements IAuthenticationUsageService {
|
|
14
|
+
private readonly _storageService;
|
|
15
|
+
private readonly _authenticationService;
|
|
16
|
+
private readonly _logService;
|
|
17
|
+
_serviceBrand: undefined;
|
|
18
|
+
private _queue;
|
|
19
|
+
private _extensionsUsingAuth;
|
|
20
|
+
constructor(_storageService: IStorageService, _authenticationService: IAuthenticationService, _logService: ILogService, productService: IProductService);
|
|
21
|
+
initializeExtensionUsageCache(): Promise<void>;
|
|
22
|
+
extensionUsesAuth(extensionId: string): Promise<boolean>;
|
|
23
|
+
readAccountUsages(providerId: string, accountName: string): IAccountUsage[];
|
|
24
|
+
removeAccountUsage(providerId: string, accountName: string): void;
|
|
25
|
+
addAccountUsage(providerId: string, accountName: string, scopes: string[], extensionId: string, extensionName: string): void;
|
|
26
|
+
private _addExtensionsToCache;
|
|
27
|
+
}
|
package/vscode/src/vs/workbench/services/authentication/browser/authenticationUsageService.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
import { __decorate, __param } from 'vscode/external/tslib/tslib.es6';
|
|
2
3
|
import { Queue } from 'vscode/vscode/vs/base/common/async';
|
|
3
4
|
import { Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
5
|
+
import 'vscode/vscode/vs/platform/instantiation/common/extensions';
|
|
4
6
|
import { ILogService } from 'vscode/vscode/vs/platform/log/common/log.service';
|
|
5
7
|
import { IProductService } from 'vscode/vscode/vs/platform/product/common/productService.service';
|
|
8
|
+
import { StorageScope, StorageTarget } from 'vscode/vscode/vs/platform/storage/common/storage';
|
|
6
9
|
import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage.service';
|
|
7
10
|
import { IAuthenticationService } from 'vscode/vscode/vs/workbench/services/authentication/common/authentication.service';
|
|
8
11
|
import 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
@@ -39,7 +42,7 @@ let AuthenticationUsageService = class AuthenticationUsageService extends Dispos
|
|
|
39
42
|
}
|
|
40
43
|
readAccountUsages(providerId, accountName) {
|
|
41
44
|
const accountKey = `${providerId}-${accountName}-usages`;
|
|
42
|
-
const storedUsages = this._storageService.get(accountKey,
|
|
45
|
+
const storedUsages = this._storageService.get(accountKey, StorageScope.APPLICATION);
|
|
43
46
|
let usages = [];
|
|
44
47
|
if (storedUsages) {
|
|
45
48
|
try {
|
|
@@ -52,7 +55,7 @@ let AuthenticationUsageService = class AuthenticationUsageService extends Dispos
|
|
|
52
55
|
}
|
|
53
56
|
removeAccountUsage(providerId, accountName) {
|
|
54
57
|
const accountKey = `${providerId}-${accountName}-usages`;
|
|
55
|
-
this._storageService.remove(accountKey,
|
|
58
|
+
this._storageService.remove(accountKey, StorageScope.APPLICATION);
|
|
56
59
|
}
|
|
57
60
|
addAccountUsage(providerId, accountName, scopes, extensionId, extensionName) {
|
|
58
61
|
const accountKey = `${providerId}-${accountName}-usages`;
|
|
@@ -74,7 +77,7 @@ let AuthenticationUsageService = class AuthenticationUsageService extends Dispos
|
|
|
74
77
|
lastUsed: Date.now()
|
|
75
78
|
});
|
|
76
79
|
}
|
|
77
|
-
this._storageService.store(accountKey, JSON.stringify(usages),
|
|
80
|
+
this._storageService.store(accountKey, JSON.stringify(usages), StorageScope.APPLICATION, StorageTarget.MACHINE);
|
|
78
81
|
this._extensionsUsingAuth.add(extensionId);
|
|
79
82
|
}
|
|
80
83
|
async _addExtensionsToCache(providerId) {
|
package/authentication.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { SyncDescriptor } from 'vscode/vscode/vs/platform/instantiation/common/descriptors';
|
|
2
|
-
import { IAuthenticationService, IAuthenticationExtensionsService } from 'vscode/vscode/vs/workbench/services/authentication/common/authentication.service';
|
|
3
|
-
import { AuthenticationService } from 'vscode/vscode/vs/workbench/services/authentication/browser/authenticationService';
|
|
4
|
-
import { AuthenticationAccessService } from './vscode/src/vs/workbench/services/authentication/browser/authenticationAccessService.js';
|
|
5
|
-
import { AuthenticationUsageService } from './vscode/src/vs/workbench/services/authentication/browser/authenticationUsageService.js';
|
|
6
|
-
import { AuthenticationExtensionsService } from './vscode/src/vs/workbench/services/authentication/browser/authenticationExtensionsService.js';
|
|
7
|
-
import { IAuthenticationAccessService } from 'vscode/vscode/vs/workbench/services/authentication/browser/authenticationAccessService.service';
|
|
8
|
-
import { IAuthenticationUsageService } from 'vscode/vscode/vs/workbench/services/authentication/browser/authenticationUsageService.service';
|
|
9
|
-
|
|
10
|
-
function getServiceOverride() {
|
|
11
|
-
return {
|
|
12
|
-
[( IAuthenticationService.toString())]: new SyncDescriptor(AuthenticationService, [], true),
|
|
13
|
-
[( IAuthenticationAccessService.toString())]: new SyncDescriptor(AuthenticationAccessService, [], true),
|
|
14
|
-
[( IAuthenticationExtensionsService.toString())]: new SyncDescriptor(AuthenticationExtensionsService, [], true),
|
|
15
|
-
[( IAuthenticationUsageService.toString())]: new SyncDescriptor(AuthenticationUsageService, [], true)
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export { getServiceOverride as default };
|