@codingame/monaco-vscode-api 1.82.2 → 1.82.3
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/README.md +2 -0
- package/missing-services.js +17 -0
- package/monaco-editor-treemending.patch +551 -551
- package/package.json +1 -1
- package/service-override/quickaccess.js +1 -1
- package/service-override/tools/editor.d.ts +1 -1
- package/service-override/views.js +10 -0
- package/service-override/workspaceTrust.d.ts +5 -0
- package/service-override/workspaceTrust.js +13 -0
- package/services.d.ts +3 -0
- package/services.js +3 -0
- package/vscode/src/vs/base/common/htmlContent.d.ts +23 -2
- package/vscode/src/vs/platform/extensionManagement/common/extensionManagementUtil.js +16 -1
- package/vscode/src/vs/platform/opener/browser/link.d.ts +8 -0
- package/vscode/src/vs/platform/workspace/common/workspaceTrust.d.ts +34 -1
- package/vscode/src/vs/workbench/browser/parts/banner/bannerPart.js +228 -0
- package/vscode/src/vs/workbench/browser/parts/banner/media/bannerpart.css.js +4 -0
- package/vscode/src/vs/workbench/browser/parts/panel/panelActions.js +21 -0
- package/vscode/src/vs/workbench/browser/parts/titlebar/commandCenterControl.js +134 -0
- package/vscode/src/vs/workbench/browser/parts/titlebar/media/titlebarpart.css.js +4 -0
- package/vscode/src/vs/workbench/browser/parts/titlebar/titlebarPart.js +365 -0
- package/vscode/src/vs/workbench/browser/parts/titlebar/windowTitle.js +216 -0
- package/vscode/src/vs/workbench/common/contextkeys.js +2 -1
- package/vscode/src/vs/workbench/common/theme.js +6 -6
- package/vscode/src/vs/workbench/contrib/extensions/common/extensions.js +2 -1
- package/vscode/src/vs/workbench/contrib/preferences/browser/preferences.contribution.js +108 -4
- package/vscode/src/vs/workbench/contrib/workspace/browser/media/workspaceTrustEditor.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/workspace/browser/workspace.contribution.js +842 -0
- package/vscode/src/vs/workbench/contrib/workspace/browser/workspaceTrustEditor.js +1047 -0
- package/vscode/src/vs/workbench/contrib/workspace/common/workspace.js +14 -0
- package/vscode/src/vs/workbench/services/banner/browser/bannerService.d.ts +25 -0
- package/vscode/src/vs/workbench/services/banner/browser/bannerService.js +3 -0
- package/vscode/src/vs/workbench/services/title/common/titleService.d.ts +31 -0
- package/vscode/src/vs/workbench/services/title/common/titleService.js +3 -0
- package/vscode/src/vs/workbench/services/userDataProfile/common/userDataProfile.js +3 -1
- package/vscode/src/vs/workbench/services/workspaces/browser/workspaceTrustEditorInput.js +27 -0
- package/vscode/src/vs/workbench/services/workspaces/common/workspaceTrust.js +649 -1
|
@@ -1,2 +1,650 @@
|
|
|
1
|
+
import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
+
import { Emitter, Event } from 'monaco-editor/esm/vs/base/common/event.js';
|
|
3
|
+
import { Disposable, DisposableStore, toDisposable } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
|
|
4
|
+
import { LinkedList } from 'monaco-editor/esm/vs/base/common/linkedList.js';
|
|
5
|
+
import { Schemas } from 'monaco-editor/esm/vs/base/common/network.js';
|
|
6
|
+
import { URI } from 'monaco-editor/esm/vs/base/common/uri.js';
|
|
7
|
+
import { IConfigurationService } from 'monaco-editor/esm/vs/platform/configuration/common/configuration.js';
|
|
8
|
+
import { IRemoteAuthorityResolverService } from '../../../../platform/remote/common/remoteAuthorityResolver.js';
|
|
9
|
+
import { getRemoteAuthority } from 'monaco-editor/esm/vs/platform/remote/common/remoteHosts.js';
|
|
10
|
+
import { isVirtualResource } from '../../../../platform/workspace/common/virtualWorkspace.js';
|
|
11
|
+
import { IStorageService } from 'monaco-editor/esm/vs/platform/storage/common/storage.js';
|
|
12
|
+
import { isSavedWorkspace, isTemporaryWorkspace, toWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier, IWorkspaceContextService } from 'monaco-editor/esm/vs/platform/workspace/common/workspace.js';
|
|
13
|
+
import { IWorkspaceTrustEnablementService, IWorkspaceTrustManagementService } from 'monaco-editor/esm/vs/platform/workspace/common/workspaceTrust.js';
|
|
14
|
+
import { Memento } from '../../../common/memento.js';
|
|
15
|
+
import { IWorkbenchEnvironmentService } from '../../environment/common/environmentService.js';
|
|
16
|
+
import { IUriIdentityService } from 'monaco-editor/esm/vs/platform/uriIdentity/common/uriIdentity.js';
|
|
17
|
+
import { isEqualAuthority } from 'monaco-editor/esm/vs/base/common/resources.js';
|
|
18
|
+
import { isWeb } from 'monaco-editor/esm/vs/base/common/platform.js';
|
|
19
|
+
import { IFileService } from 'monaco-editor/esm/vs/platform/files/common/files.js';
|
|
20
|
+
const WORKSPACE_TRUST_ENABLED = 'security.workspace.trust.enabled';
|
|
21
|
+
const WORKSPACE_TRUST_STARTUP_PROMPT = 'security.workspace.trust.startupPrompt';
|
|
22
|
+
const WORKSPACE_TRUST_BANNER = 'security.workspace.trust.banner';
|
|
23
|
+
const WORKSPACE_TRUST_UNTRUSTED_FILES = 'security.workspace.trust.untrustedFiles';
|
|
24
|
+
const WORKSPACE_TRUST_EMPTY_WINDOW = 'security.workspace.trust.emptyWindow';
|
|
1
25
|
const WORKSPACE_TRUST_EXTENSION_SUPPORT = 'extensions.supportUntrustedWorkspaces';
|
|
2
|
-
|
|
26
|
+
const WORKSPACE_TRUST_STORAGE_KEY = 'content.trust.model.key';
|
|
27
|
+
class CanonicalWorkspace {
|
|
28
|
+
constructor(originalWorkspace, canonicalFolderUris, canonicalConfiguration) {
|
|
29
|
+
this.originalWorkspace = originalWorkspace;
|
|
30
|
+
this.canonicalFolderUris = canonicalFolderUris;
|
|
31
|
+
this.canonicalConfiguration = canonicalConfiguration;
|
|
32
|
+
}
|
|
33
|
+
get folders() {
|
|
34
|
+
return ( this.originalWorkspace.folders.map((folder, index) => {
|
|
35
|
+
return {
|
|
36
|
+
index: folder.index,
|
|
37
|
+
name: folder.name,
|
|
38
|
+
toResource: folder.toResource,
|
|
39
|
+
uri: this.canonicalFolderUris[index]
|
|
40
|
+
};
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
get transient() {
|
|
44
|
+
return this.originalWorkspace.transient;
|
|
45
|
+
}
|
|
46
|
+
get configuration() {
|
|
47
|
+
return this.canonicalConfiguration ?? this.originalWorkspace.configuration;
|
|
48
|
+
}
|
|
49
|
+
get id() {
|
|
50
|
+
return this.originalWorkspace.id;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
let WorkspaceTrustEnablementService = class WorkspaceTrustEnablementService extends Disposable {
|
|
54
|
+
constructor(configurationService, environmentService) {
|
|
55
|
+
super();
|
|
56
|
+
this.configurationService = configurationService;
|
|
57
|
+
this.environmentService = environmentService;
|
|
58
|
+
}
|
|
59
|
+
isWorkspaceTrustEnabled() {
|
|
60
|
+
if (this.environmentService.disableWorkspaceTrust) {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
return !!this.configurationService.getValue(WORKSPACE_TRUST_ENABLED);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
WorkspaceTrustEnablementService = ( __decorate([
|
|
67
|
+
( __param(0, IConfigurationService)),
|
|
68
|
+
( __param(1, IWorkbenchEnvironmentService))
|
|
69
|
+
], WorkspaceTrustEnablementService));
|
|
70
|
+
let WorkspaceTrustManagementService = class WorkspaceTrustManagementService extends Disposable {
|
|
71
|
+
constructor(configurationService, remoteAuthorityResolverService, storageService, uriIdentityService, environmentService, workspaceService, workspaceTrustEnablementService, fileService) {
|
|
72
|
+
super();
|
|
73
|
+
this.configurationService = configurationService;
|
|
74
|
+
this.remoteAuthorityResolverService = remoteAuthorityResolverService;
|
|
75
|
+
this.storageService = storageService;
|
|
76
|
+
this.uriIdentityService = uriIdentityService;
|
|
77
|
+
this.environmentService = environmentService;
|
|
78
|
+
this.workspaceService = workspaceService;
|
|
79
|
+
this.workspaceTrustEnablementService = workspaceTrustEnablementService;
|
|
80
|
+
this.fileService = fileService;
|
|
81
|
+
this.storageKey = WORKSPACE_TRUST_STORAGE_KEY;
|
|
82
|
+
this._onDidChangeTrust = this._register(( new Emitter()));
|
|
83
|
+
this.onDidChangeTrust = this._onDidChangeTrust.event;
|
|
84
|
+
this._onDidChangeTrustedFolders = this._register(( new Emitter()));
|
|
85
|
+
this.onDidChangeTrustedFolders = this._onDidChangeTrustedFolders.event;
|
|
86
|
+
this._canonicalStartupFiles = [];
|
|
87
|
+
this._canonicalUrisResolved = false;
|
|
88
|
+
this._canonicalWorkspace = this.workspaceService.getWorkspace();
|
|
89
|
+
this._workspaceResolvedPromise = ( new Promise((resolve) => {
|
|
90
|
+
this._workspaceResolvedPromiseResolve = resolve;
|
|
91
|
+
}));
|
|
92
|
+
this._workspaceTrustInitializedPromise = ( new Promise((resolve) => {
|
|
93
|
+
this._workspaceTrustInitializedPromiseResolve = resolve;
|
|
94
|
+
}));
|
|
95
|
+
this._storedTrustState = ( new WorkspaceTrustMemento(isWeb && this.isEmptyWorkspace() ? undefined : this.storageService));
|
|
96
|
+
this._trustTransitionManager = this._register(( new WorkspaceTrustTransitionManager()));
|
|
97
|
+
this._trustStateInfo = this.loadTrustInfo();
|
|
98
|
+
this._isTrusted = this.calculateWorkspaceTrust();
|
|
99
|
+
this.initializeWorkspaceTrust();
|
|
100
|
+
this.registerListeners();
|
|
101
|
+
}
|
|
102
|
+
initializeWorkspaceTrust() {
|
|
103
|
+
this.resolveCanonicalUris()
|
|
104
|
+
.then(async () => {
|
|
105
|
+
this._canonicalUrisResolved = true;
|
|
106
|
+
await this.updateWorkspaceTrust();
|
|
107
|
+
})
|
|
108
|
+
.finally(() => {
|
|
109
|
+
this._workspaceResolvedPromiseResolve();
|
|
110
|
+
if (!this.environmentService.remoteAuthority) {
|
|
111
|
+
this._workspaceTrustInitializedPromiseResolve();
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
if (this.environmentService.remoteAuthority) {
|
|
115
|
+
this.remoteAuthorityResolverService.resolveAuthority(this.environmentService.remoteAuthority)
|
|
116
|
+
.then(async (result) => {
|
|
117
|
+
this._remoteAuthority = result;
|
|
118
|
+
await this.fileService.activateProvider(Schemas.vscodeRemote);
|
|
119
|
+
await this.updateWorkspaceTrust();
|
|
120
|
+
})
|
|
121
|
+
.finally(() => {
|
|
122
|
+
this._workspaceTrustInitializedPromiseResolve();
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
if (this.isEmptyWorkspace()) {
|
|
126
|
+
this._workspaceTrustInitializedPromise.then(() => {
|
|
127
|
+
if (this._storedTrustState.isEmptyWorkspaceTrusted === undefined) {
|
|
128
|
+
this._storedTrustState.isEmptyWorkspaceTrusted = this.isWorkspaceTrusted();
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
registerListeners() {
|
|
134
|
+
this._register(this.workspaceService.onDidChangeWorkspaceFolders(async () => await this.updateWorkspaceTrust()));
|
|
135
|
+
this._register(this.storageService.onDidChangeValue(-1 , this.storageKey, this._register(( new DisposableStore())))(async () => {
|
|
136
|
+
if (JSON.stringify(this._trustStateInfo) !== JSON.stringify(this.loadTrustInfo())) {
|
|
137
|
+
this._trustStateInfo = this.loadTrustInfo();
|
|
138
|
+
this._onDidChangeTrustedFolders.fire();
|
|
139
|
+
await this.updateWorkspaceTrust();
|
|
140
|
+
}
|
|
141
|
+
}));
|
|
142
|
+
}
|
|
143
|
+
async getCanonicalUri(uri) {
|
|
144
|
+
let canonicalUri = uri;
|
|
145
|
+
if (this.environmentService.remoteAuthority && uri.scheme === Schemas.vscodeRemote) {
|
|
146
|
+
canonicalUri = await this.remoteAuthorityResolverService.getCanonicalURI(uri);
|
|
147
|
+
}
|
|
148
|
+
else if (uri.scheme === 'vscode-vfs') {
|
|
149
|
+
const index = uri.authority.indexOf('+');
|
|
150
|
+
if (index !== -1) {
|
|
151
|
+
canonicalUri = uri.with({ authority: uri.authority.substr(0, index) });
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return canonicalUri.with({ query: null, fragment: null });
|
|
155
|
+
}
|
|
156
|
+
async resolveCanonicalUris() {
|
|
157
|
+
const filesToOpen = [];
|
|
158
|
+
if (this.environmentService.filesToOpenOrCreate) {
|
|
159
|
+
filesToOpen.push(...this.environmentService.filesToOpenOrCreate);
|
|
160
|
+
}
|
|
161
|
+
if (this.environmentService.filesToDiff) {
|
|
162
|
+
filesToOpen.push(...this.environmentService.filesToDiff);
|
|
163
|
+
}
|
|
164
|
+
if (this.environmentService.filesToMerge) {
|
|
165
|
+
filesToOpen.push(...this.environmentService.filesToMerge);
|
|
166
|
+
}
|
|
167
|
+
if (filesToOpen.length) {
|
|
168
|
+
const filesToOpenOrCreateUris = ( filesToOpen.filter(f => !!f.fileUri).map(f => f.fileUri));
|
|
169
|
+
const canonicalFilesToOpen = await Promise.all(( filesToOpenOrCreateUris.map(uri => this.getCanonicalUri(uri))));
|
|
170
|
+
this._canonicalStartupFiles.push(...canonicalFilesToOpen.filter(uri => this._canonicalStartupFiles.every(u => !this.uriIdentityService.extUri.isEqual(uri, u))));
|
|
171
|
+
}
|
|
172
|
+
const workspaceUris = ( this.workspaceService.getWorkspace().folders.map(f => f.uri));
|
|
173
|
+
const canonicalWorkspaceFolders = await Promise.all(( workspaceUris.map(uri => this.getCanonicalUri(uri))));
|
|
174
|
+
let canonicalWorkspaceConfiguration = this.workspaceService.getWorkspace().configuration;
|
|
175
|
+
if (canonicalWorkspaceConfiguration && isSavedWorkspace(canonicalWorkspaceConfiguration, this.environmentService)) {
|
|
176
|
+
canonicalWorkspaceConfiguration = await this.getCanonicalUri(canonicalWorkspaceConfiguration);
|
|
177
|
+
}
|
|
178
|
+
this._canonicalWorkspace = ( new CanonicalWorkspace(
|
|
179
|
+
this.workspaceService.getWorkspace(),
|
|
180
|
+
canonicalWorkspaceFolders,
|
|
181
|
+
canonicalWorkspaceConfiguration
|
|
182
|
+
));
|
|
183
|
+
}
|
|
184
|
+
loadTrustInfo() {
|
|
185
|
+
const infoAsString = this.storageService.get(this.storageKey, -1 );
|
|
186
|
+
let result;
|
|
187
|
+
try {
|
|
188
|
+
if (infoAsString) {
|
|
189
|
+
result = JSON.parse(infoAsString);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
catch { }
|
|
193
|
+
if (!result) {
|
|
194
|
+
result = {
|
|
195
|
+
uriTrustInfo: []
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
if (!result.uriTrustInfo) {
|
|
199
|
+
result.uriTrustInfo = [];
|
|
200
|
+
}
|
|
201
|
+
result.uriTrustInfo = ( result.uriTrustInfo.map(info => { return { uri: URI.revive(info.uri), trusted: info.trusted }; }));
|
|
202
|
+
result.uriTrustInfo = result.uriTrustInfo.filter(info => info.trusted);
|
|
203
|
+
return result;
|
|
204
|
+
}
|
|
205
|
+
async saveTrustInfo() {
|
|
206
|
+
this.storageService.store(this.storageKey, JSON.stringify(this._trustStateInfo), -1 , 1 );
|
|
207
|
+
this._onDidChangeTrustedFolders.fire();
|
|
208
|
+
await this.updateWorkspaceTrust();
|
|
209
|
+
}
|
|
210
|
+
getWorkspaceUris() {
|
|
211
|
+
const workspaceUris = ( this._canonicalWorkspace.folders.map(f => f.uri));
|
|
212
|
+
const workspaceConfiguration = this._canonicalWorkspace.configuration;
|
|
213
|
+
if (workspaceConfiguration && isSavedWorkspace(workspaceConfiguration, this.environmentService)) {
|
|
214
|
+
workspaceUris.push(workspaceConfiguration);
|
|
215
|
+
}
|
|
216
|
+
return workspaceUris;
|
|
217
|
+
}
|
|
218
|
+
calculateWorkspaceTrust() {
|
|
219
|
+
if (!this.workspaceTrustEnablementService.isWorkspaceTrustEnabled()) {
|
|
220
|
+
return true;
|
|
221
|
+
}
|
|
222
|
+
if (!this._canonicalUrisResolved) {
|
|
223
|
+
return false;
|
|
224
|
+
}
|
|
225
|
+
if (this.environmentService.remoteAuthority && this._remoteAuthority?.options?.isTrusted) {
|
|
226
|
+
return this._remoteAuthority.options.isTrusted;
|
|
227
|
+
}
|
|
228
|
+
if (this.isEmptyWorkspace()) {
|
|
229
|
+
if (this._storedTrustState.isEmptyWorkspaceTrusted !== undefined) {
|
|
230
|
+
return this._storedTrustState.isEmptyWorkspaceTrusted;
|
|
231
|
+
}
|
|
232
|
+
if (this._canonicalStartupFiles.length) {
|
|
233
|
+
return this.getUrisTrust(this._canonicalStartupFiles);
|
|
234
|
+
}
|
|
235
|
+
return !!this.configurationService.getValue(WORKSPACE_TRUST_EMPTY_WINDOW);
|
|
236
|
+
}
|
|
237
|
+
return this.getUrisTrust(this.getWorkspaceUris());
|
|
238
|
+
}
|
|
239
|
+
async updateWorkspaceTrust(trusted) {
|
|
240
|
+
if (!this.workspaceTrustEnablementService.isWorkspaceTrustEnabled()) {
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
if (trusted === undefined) {
|
|
244
|
+
await this.resolveCanonicalUris();
|
|
245
|
+
trusted = this.calculateWorkspaceTrust();
|
|
246
|
+
}
|
|
247
|
+
if (this.isWorkspaceTrusted() === trusted) {
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
this.isTrusted = trusted;
|
|
251
|
+
await this._trustTransitionManager.participate(trusted);
|
|
252
|
+
this._onDidChangeTrust.fire(trusted);
|
|
253
|
+
}
|
|
254
|
+
getUrisTrust(uris) {
|
|
255
|
+
let state = true;
|
|
256
|
+
for (const uri of uris) {
|
|
257
|
+
const { trusted } = this.doGetUriTrustInfo(uri);
|
|
258
|
+
if (!trusted) {
|
|
259
|
+
state = trusted;
|
|
260
|
+
return state;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
return state;
|
|
264
|
+
}
|
|
265
|
+
doGetUriTrustInfo(uri) {
|
|
266
|
+
if (!this.workspaceTrustEnablementService.isWorkspaceTrustEnabled()) {
|
|
267
|
+
return { trusted: true, uri };
|
|
268
|
+
}
|
|
269
|
+
if (this.isTrustedVirtualResource(uri)) {
|
|
270
|
+
return { trusted: true, uri };
|
|
271
|
+
}
|
|
272
|
+
if (this.isTrustedByRemote(uri)) {
|
|
273
|
+
return { trusted: true, uri };
|
|
274
|
+
}
|
|
275
|
+
let resultState = false;
|
|
276
|
+
let maxLength = -1;
|
|
277
|
+
let resultUri = uri;
|
|
278
|
+
for (const trustInfo of this._trustStateInfo.uriTrustInfo) {
|
|
279
|
+
if (this.uriIdentityService.extUri.isEqualOrParent(uri, trustInfo.uri)) {
|
|
280
|
+
const fsPath = trustInfo.uri.fsPath;
|
|
281
|
+
if (fsPath.length > maxLength) {
|
|
282
|
+
maxLength = fsPath.length;
|
|
283
|
+
resultState = trustInfo.trusted;
|
|
284
|
+
resultUri = trustInfo.uri;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
return { trusted: resultState, uri: resultUri };
|
|
289
|
+
}
|
|
290
|
+
async doSetUrisTrust(uris, trusted) {
|
|
291
|
+
let changed = false;
|
|
292
|
+
for (const uri of uris) {
|
|
293
|
+
if (trusted) {
|
|
294
|
+
if (this.isTrustedVirtualResource(uri)) {
|
|
295
|
+
continue;
|
|
296
|
+
}
|
|
297
|
+
if (this.isTrustedByRemote(uri)) {
|
|
298
|
+
continue;
|
|
299
|
+
}
|
|
300
|
+
const foundItem = this._trustStateInfo.uriTrustInfo.find(trustInfo => this.uriIdentityService.extUri.isEqual(trustInfo.uri, uri));
|
|
301
|
+
if (!foundItem) {
|
|
302
|
+
this._trustStateInfo.uriTrustInfo.push({ uri, trusted: true });
|
|
303
|
+
changed = true;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
else {
|
|
307
|
+
const previousLength = this._trustStateInfo.uriTrustInfo.length;
|
|
308
|
+
this._trustStateInfo.uriTrustInfo = this._trustStateInfo.uriTrustInfo.filter(trustInfo => !this.uriIdentityService.extUri.isEqual(trustInfo.uri, uri));
|
|
309
|
+
if (previousLength !== this._trustStateInfo.uriTrustInfo.length) {
|
|
310
|
+
changed = true;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
if (changed) {
|
|
315
|
+
await this.saveTrustInfo();
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
isEmptyWorkspace() {
|
|
319
|
+
if (this.workspaceService.getWorkbenchState() === 1 ) {
|
|
320
|
+
return true;
|
|
321
|
+
}
|
|
322
|
+
const workspace = this.workspaceService.getWorkspace();
|
|
323
|
+
if (workspace) {
|
|
324
|
+
return isTemporaryWorkspace(this.workspaceService.getWorkspace()) && workspace.folders.length === 0;
|
|
325
|
+
}
|
|
326
|
+
return false;
|
|
327
|
+
}
|
|
328
|
+
isTrustedVirtualResource(uri) {
|
|
329
|
+
return isVirtualResource(uri) && uri.scheme !== 'vscode-vfs';
|
|
330
|
+
}
|
|
331
|
+
isTrustedByRemote(uri) {
|
|
332
|
+
if (!this.environmentService.remoteAuthority) {
|
|
333
|
+
return false;
|
|
334
|
+
}
|
|
335
|
+
if (!this._remoteAuthority) {
|
|
336
|
+
return false;
|
|
337
|
+
}
|
|
338
|
+
return (isEqualAuthority(getRemoteAuthority(uri), this._remoteAuthority.authority.authority)) && !!this._remoteAuthority.options?.isTrusted;
|
|
339
|
+
}
|
|
340
|
+
set isTrusted(value) {
|
|
341
|
+
this._isTrusted = value;
|
|
342
|
+
if (!value) {
|
|
343
|
+
this._storedTrustState.acceptsOutOfWorkspaceFiles = false;
|
|
344
|
+
}
|
|
345
|
+
if (this.isEmptyWorkspace()) {
|
|
346
|
+
this._storedTrustState.isEmptyWorkspaceTrusted = value;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
get workspaceResolved() {
|
|
350
|
+
return this._workspaceResolvedPromise;
|
|
351
|
+
}
|
|
352
|
+
get workspaceTrustInitialized() {
|
|
353
|
+
return this._workspaceTrustInitializedPromise;
|
|
354
|
+
}
|
|
355
|
+
get acceptsOutOfWorkspaceFiles() {
|
|
356
|
+
return this._storedTrustState.acceptsOutOfWorkspaceFiles;
|
|
357
|
+
}
|
|
358
|
+
set acceptsOutOfWorkspaceFiles(value) {
|
|
359
|
+
this._storedTrustState.acceptsOutOfWorkspaceFiles = value;
|
|
360
|
+
}
|
|
361
|
+
isWorkspaceTrusted() {
|
|
362
|
+
return this._isTrusted;
|
|
363
|
+
}
|
|
364
|
+
isWorkspaceTrustForced() {
|
|
365
|
+
if (this.environmentService.remoteAuthority && this._remoteAuthority && this._remoteAuthority.options?.isTrusted !== undefined) {
|
|
366
|
+
return true;
|
|
367
|
+
}
|
|
368
|
+
const workspaceUris = this.getWorkspaceUris().filter(uri => !this.isTrustedVirtualResource(uri));
|
|
369
|
+
if (workspaceUris.length === 0) {
|
|
370
|
+
return true;
|
|
371
|
+
}
|
|
372
|
+
return false;
|
|
373
|
+
}
|
|
374
|
+
canSetParentFolderTrust() {
|
|
375
|
+
const workspaceIdentifier = toWorkspaceIdentifier(this._canonicalWorkspace);
|
|
376
|
+
if (!isSingleFolderWorkspaceIdentifier(workspaceIdentifier)) {
|
|
377
|
+
return false;
|
|
378
|
+
}
|
|
379
|
+
if (workspaceIdentifier.uri.scheme !== Schemas.file && workspaceIdentifier.uri.scheme !== Schemas.vscodeRemote) {
|
|
380
|
+
return false;
|
|
381
|
+
}
|
|
382
|
+
const parentFolder = this.uriIdentityService.extUri.dirname(workspaceIdentifier.uri);
|
|
383
|
+
if (this.uriIdentityService.extUri.isEqual(workspaceIdentifier.uri, parentFolder)) {
|
|
384
|
+
return false;
|
|
385
|
+
}
|
|
386
|
+
return true;
|
|
387
|
+
}
|
|
388
|
+
async setParentFolderTrust(trusted) {
|
|
389
|
+
if (this.canSetParentFolderTrust()) {
|
|
390
|
+
const workspaceUri = toWorkspaceIdentifier(this._canonicalWorkspace).uri;
|
|
391
|
+
const parentFolder = this.uriIdentityService.extUri.dirname(workspaceUri);
|
|
392
|
+
await this.setUrisTrust([parentFolder], trusted);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
canSetWorkspaceTrust() {
|
|
396
|
+
if (this.environmentService.remoteAuthority && (!this._remoteAuthority || this._remoteAuthority.options?.isTrusted !== undefined)) {
|
|
397
|
+
return false;
|
|
398
|
+
}
|
|
399
|
+
if (this.isEmptyWorkspace()) {
|
|
400
|
+
return true;
|
|
401
|
+
}
|
|
402
|
+
const workspaceUris = this.getWorkspaceUris().filter(uri => !this.isTrustedVirtualResource(uri));
|
|
403
|
+
if (workspaceUris.length === 0) {
|
|
404
|
+
return false;
|
|
405
|
+
}
|
|
406
|
+
if (!this.isWorkspaceTrusted()) {
|
|
407
|
+
return true;
|
|
408
|
+
}
|
|
409
|
+
const workspaceIdentifier = toWorkspaceIdentifier(this._canonicalWorkspace);
|
|
410
|
+
if (!isSingleFolderWorkspaceIdentifier(workspaceIdentifier)) {
|
|
411
|
+
return false;
|
|
412
|
+
}
|
|
413
|
+
if (workspaceIdentifier.uri.scheme !== Schemas.file && workspaceIdentifier.uri.scheme !== 'vscode-vfs') {
|
|
414
|
+
return false;
|
|
415
|
+
}
|
|
416
|
+
const trustInfo = this.doGetUriTrustInfo(workspaceIdentifier.uri);
|
|
417
|
+
if (!trustInfo.trusted || !this.uriIdentityService.extUri.isEqual(workspaceIdentifier.uri, trustInfo.uri)) {
|
|
418
|
+
return false;
|
|
419
|
+
}
|
|
420
|
+
if (this.canSetParentFolderTrust()) {
|
|
421
|
+
const parentFolder = this.uriIdentityService.extUri.dirname(workspaceIdentifier.uri);
|
|
422
|
+
const parentPathTrustInfo = this.doGetUriTrustInfo(parentFolder);
|
|
423
|
+
if (parentPathTrustInfo.trusted) {
|
|
424
|
+
return false;
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
return true;
|
|
428
|
+
}
|
|
429
|
+
async setWorkspaceTrust(trusted) {
|
|
430
|
+
if (this.isEmptyWorkspace()) {
|
|
431
|
+
await this.updateWorkspaceTrust(trusted);
|
|
432
|
+
return;
|
|
433
|
+
}
|
|
434
|
+
const workspaceFolders = this.getWorkspaceUris();
|
|
435
|
+
await this.setUrisTrust(workspaceFolders, trusted);
|
|
436
|
+
}
|
|
437
|
+
async getUriTrustInfo(uri) {
|
|
438
|
+
if (!this.workspaceTrustEnablementService.isWorkspaceTrustEnabled()) {
|
|
439
|
+
return { trusted: true, uri };
|
|
440
|
+
}
|
|
441
|
+
if (this.isTrustedByRemote(uri)) {
|
|
442
|
+
return { trusted: true, uri };
|
|
443
|
+
}
|
|
444
|
+
return this.doGetUriTrustInfo(await this.getCanonicalUri(uri));
|
|
445
|
+
}
|
|
446
|
+
async setUrisTrust(uris, trusted) {
|
|
447
|
+
this.doSetUrisTrust(await Promise.all(( uris.map(uri => this.getCanonicalUri(uri)))), trusted);
|
|
448
|
+
}
|
|
449
|
+
getTrustedUris() {
|
|
450
|
+
return ( this._trustStateInfo.uriTrustInfo.map(info => info.uri));
|
|
451
|
+
}
|
|
452
|
+
async setTrustedUris(uris) {
|
|
453
|
+
this._trustStateInfo.uriTrustInfo = [];
|
|
454
|
+
for (const uri of uris) {
|
|
455
|
+
const canonicalUri = await this.getCanonicalUri(uri);
|
|
456
|
+
const cleanUri = this.uriIdentityService.extUri.removeTrailingPathSeparator(canonicalUri);
|
|
457
|
+
let added = false;
|
|
458
|
+
for (const addedUri of this._trustStateInfo.uriTrustInfo) {
|
|
459
|
+
if (this.uriIdentityService.extUri.isEqual(addedUri.uri, cleanUri)) {
|
|
460
|
+
added = true;
|
|
461
|
+
break;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
if (added) {
|
|
465
|
+
continue;
|
|
466
|
+
}
|
|
467
|
+
this._trustStateInfo.uriTrustInfo.push({
|
|
468
|
+
trusted: true,
|
|
469
|
+
uri: cleanUri
|
|
470
|
+
});
|
|
471
|
+
}
|
|
472
|
+
await this.saveTrustInfo();
|
|
473
|
+
}
|
|
474
|
+
addWorkspaceTrustTransitionParticipant(participant) {
|
|
475
|
+
return this._trustTransitionManager.addWorkspaceTrustTransitionParticipant(participant);
|
|
476
|
+
}
|
|
477
|
+
};
|
|
478
|
+
WorkspaceTrustManagementService = ( __decorate([
|
|
479
|
+
( __param(0, IConfigurationService)),
|
|
480
|
+
( __param(1, IRemoteAuthorityResolverService)),
|
|
481
|
+
( __param(2, IStorageService)),
|
|
482
|
+
( __param(3, IUriIdentityService)),
|
|
483
|
+
( __param(4, IWorkbenchEnvironmentService)),
|
|
484
|
+
( __param(5, IWorkspaceContextService)),
|
|
485
|
+
( __param(6, IWorkspaceTrustEnablementService)),
|
|
486
|
+
( __param(7, IFileService))
|
|
487
|
+
], WorkspaceTrustManagementService));
|
|
488
|
+
let WorkspaceTrustRequestService = class WorkspaceTrustRequestService extends Disposable {
|
|
489
|
+
constructor(configurationService, workspaceTrustManagementService) {
|
|
490
|
+
super();
|
|
491
|
+
this.configurationService = configurationService;
|
|
492
|
+
this.workspaceTrustManagementService = workspaceTrustManagementService;
|
|
493
|
+
this._onDidInitiateOpenFilesTrustRequest = this._register(( new Emitter()));
|
|
494
|
+
this.onDidInitiateOpenFilesTrustRequest = this._onDidInitiateOpenFilesTrustRequest.event;
|
|
495
|
+
this._onDidInitiateWorkspaceTrustRequest = this._register(( new Emitter()));
|
|
496
|
+
this.onDidInitiateWorkspaceTrustRequest = this._onDidInitiateWorkspaceTrustRequest.event;
|
|
497
|
+
this._onDidInitiateWorkspaceTrustRequestOnStartup = this._register(( new Emitter()));
|
|
498
|
+
this.onDidInitiateWorkspaceTrustRequestOnStartup = this._onDidInitiateWorkspaceTrustRequestOnStartup.event;
|
|
499
|
+
}
|
|
500
|
+
get untrustedFilesSetting() {
|
|
501
|
+
return this.configurationService.getValue(WORKSPACE_TRUST_UNTRUSTED_FILES);
|
|
502
|
+
}
|
|
503
|
+
set untrustedFilesSetting(value) {
|
|
504
|
+
this.configurationService.updateValue(WORKSPACE_TRUST_UNTRUSTED_FILES, value);
|
|
505
|
+
}
|
|
506
|
+
async completeOpenFilesTrustRequest(result, saveResponse) {
|
|
507
|
+
if (!this._openFilesTrustRequestResolver) {
|
|
508
|
+
return;
|
|
509
|
+
}
|
|
510
|
+
if (result === 1 ) {
|
|
511
|
+
this.workspaceTrustManagementService.acceptsOutOfWorkspaceFiles = true;
|
|
512
|
+
}
|
|
513
|
+
if (saveResponse) {
|
|
514
|
+
if (result === 1 ) {
|
|
515
|
+
this.untrustedFilesSetting = 'open';
|
|
516
|
+
}
|
|
517
|
+
if (result === 2 ) {
|
|
518
|
+
this.untrustedFilesSetting = 'newWindow';
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
this._openFilesTrustRequestResolver(result);
|
|
522
|
+
this._openFilesTrustRequestResolver = undefined;
|
|
523
|
+
this._openFilesTrustRequestPromise = undefined;
|
|
524
|
+
}
|
|
525
|
+
async requestOpenFilesTrust(uris) {
|
|
526
|
+
if (!this.workspaceTrustManagementService.isWorkspaceTrusted()) {
|
|
527
|
+
return 1 ;
|
|
528
|
+
}
|
|
529
|
+
const openFilesTrustInfo = await Promise.all(( uris.map(uri => this.workspaceTrustManagementService.getUriTrustInfo(uri))));
|
|
530
|
+
if (( openFilesTrustInfo.map(info => info.trusted)).every(trusted => trusted)) {
|
|
531
|
+
return 1 ;
|
|
532
|
+
}
|
|
533
|
+
if (this.untrustedFilesSetting !== 'prompt') {
|
|
534
|
+
if (this.untrustedFilesSetting === 'newWindow') {
|
|
535
|
+
return 2 ;
|
|
536
|
+
}
|
|
537
|
+
if (this.untrustedFilesSetting === 'open') {
|
|
538
|
+
return 1 ;
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
if (this.workspaceTrustManagementService.acceptsOutOfWorkspaceFiles) {
|
|
542
|
+
return 1 ;
|
|
543
|
+
}
|
|
544
|
+
if (!this._openFilesTrustRequestPromise) {
|
|
545
|
+
this._openFilesTrustRequestPromise = ( new Promise(resolve => {
|
|
546
|
+
this._openFilesTrustRequestResolver = resolve;
|
|
547
|
+
}));
|
|
548
|
+
}
|
|
549
|
+
else {
|
|
550
|
+
return this._openFilesTrustRequestPromise;
|
|
551
|
+
}
|
|
552
|
+
this._onDidInitiateOpenFilesTrustRequest.fire();
|
|
553
|
+
return this._openFilesTrustRequestPromise;
|
|
554
|
+
}
|
|
555
|
+
resolveWorkspaceTrustRequest(trusted) {
|
|
556
|
+
if (this._workspaceTrustRequestResolver) {
|
|
557
|
+
this._workspaceTrustRequestResolver(trusted ?? this.workspaceTrustManagementService.isWorkspaceTrusted());
|
|
558
|
+
this._workspaceTrustRequestResolver = undefined;
|
|
559
|
+
this._workspaceTrustRequestPromise = undefined;
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
cancelWorkspaceTrustRequest() {
|
|
563
|
+
if (this._workspaceTrustRequestResolver) {
|
|
564
|
+
this._workspaceTrustRequestResolver(undefined);
|
|
565
|
+
this._workspaceTrustRequestResolver = undefined;
|
|
566
|
+
this._workspaceTrustRequestPromise = undefined;
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
async completeWorkspaceTrustRequest(trusted) {
|
|
570
|
+
if (trusted === undefined || trusted === this.workspaceTrustManagementService.isWorkspaceTrusted()) {
|
|
571
|
+
this.resolveWorkspaceTrustRequest(trusted);
|
|
572
|
+
return;
|
|
573
|
+
}
|
|
574
|
+
Event.once(this.workspaceTrustManagementService.onDidChangeTrust)(trusted => this.resolveWorkspaceTrustRequest(trusted));
|
|
575
|
+
await this.workspaceTrustManagementService.setWorkspaceTrust(trusted);
|
|
576
|
+
}
|
|
577
|
+
async requestWorkspaceTrust(options) {
|
|
578
|
+
if (this.workspaceTrustManagementService.isWorkspaceTrusted()) {
|
|
579
|
+
return this.workspaceTrustManagementService.isWorkspaceTrusted();
|
|
580
|
+
}
|
|
581
|
+
if (!this._workspaceTrustRequestPromise) {
|
|
582
|
+
this._workspaceTrustRequestPromise = ( new Promise(resolve => {
|
|
583
|
+
this._workspaceTrustRequestResolver = resolve;
|
|
584
|
+
}));
|
|
585
|
+
}
|
|
586
|
+
else {
|
|
587
|
+
return this._workspaceTrustRequestPromise;
|
|
588
|
+
}
|
|
589
|
+
this._onDidInitiateWorkspaceTrustRequest.fire(options);
|
|
590
|
+
return this._workspaceTrustRequestPromise;
|
|
591
|
+
}
|
|
592
|
+
requestWorkspaceTrustOnStartup() {
|
|
593
|
+
if (!this._workspaceTrustRequestPromise) {
|
|
594
|
+
this._workspaceTrustRequestPromise = ( new Promise(resolve => {
|
|
595
|
+
this._workspaceTrustRequestResolver = resolve;
|
|
596
|
+
}));
|
|
597
|
+
}
|
|
598
|
+
this._onDidInitiateWorkspaceTrustRequestOnStartup.fire();
|
|
599
|
+
}
|
|
600
|
+
};
|
|
601
|
+
WorkspaceTrustRequestService = ( __decorate([
|
|
602
|
+
( __param(0, IConfigurationService)),
|
|
603
|
+
( __param(1, IWorkspaceTrustManagementService))
|
|
604
|
+
], WorkspaceTrustRequestService));
|
|
605
|
+
class WorkspaceTrustTransitionManager extends Disposable {
|
|
606
|
+
constructor() {
|
|
607
|
+
super(...arguments);
|
|
608
|
+
this.participants = ( new LinkedList());
|
|
609
|
+
}
|
|
610
|
+
addWorkspaceTrustTransitionParticipant(participant) {
|
|
611
|
+
const remove = this.participants.push(participant);
|
|
612
|
+
return toDisposable(() => remove());
|
|
613
|
+
}
|
|
614
|
+
async participate(trusted) {
|
|
615
|
+
for (const participant of this.participants) {
|
|
616
|
+
await participant.participate(trusted);
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
dispose() {
|
|
620
|
+
this.participants.clear();
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
class WorkspaceTrustMemento {
|
|
624
|
+
constructor(storageService) {
|
|
625
|
+
this._acceptsOutOfWorkspaceFilesKey = 'acceptsOutOfWorkspaceFiles';
|
|
626
|
+
this._isEmptyWorkspaceTrustedKey = 'isEmptyWorkspaceTrusted';
|
|
627
|
+
if (storageService) {
|
|
628
|
+
this._memento = ( new Memento('workspaceTrust', storageService));
|
|
629
|
+
this._mementoObject = this._memento.getMemento(1 , 1 );
|
|
630
|
+
}
|
|
631
|
+
else {
|
|
632
|
+
this._mementoObject = {};
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
get acceptsOutOfWorkspaceFiles() {
|
|
636
|
+
return this._mementoObject[this._acceptsOutOfWorkspaceFilesKey] ?? false;
|
|
637
|
+
}
|
|
638
|
+
set acceptsOutOfWorkspaceFiles(value) {
|
|
639
|
+
this._mementoObject[this._acceptsOutOfWorkspaceFilesKey] = value;
|
|
640
|
+
this._memento?.saveMemento();
|
|
641
|
+
}
|
|
642
|
+
get isEmptyWorkspaceTrusted() {
|
|
643
|
+
return this._mementoObject[this._isEmptyWorkspaceTrustedKey];
|
|
644
|
+
}
|
|
645
|
+
set isEmptyWorkspaceTrusted(value) {
|
|
646
|
+
this._mementoObject[this._isEmptyWorkspaceTrustedKey] = value;
|
|
647
|
+
this._memento?.saveMemento();
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
export { CanonicalWorkspace, WORKSPACE_TRUST_BANNER, WORKSPACE_TRUST_EMPTY_WINDOW, WORKSPACE_TRUST_ENABLED, WORKSPACE_TRUST_EXTENSION_SUPPORT, WORKSPACE_TRUST_STARTUP_PROMPT, WORKSPACE_TRUST_STORAGE_KEY, WORKSPACE_TRUST_UNTRUSTED_FILES, WorkspaceTrustEnablementService, WorkspaceTrustManagementService, WorkspaceTrustRequestService };
|