|
| 1 | +diff --git a/src/vs/platform/sign/browser/signService.ts b/src/vs/platform/sign/browser/signService.ts |
| 2 | +index ec1e11b..8303040 100644 |
| 3 | +--- a/src/vs/platform/sign/browser/signService.ts |
| 4 | ++++ b/src/vs/platform/sign/browser/signService.ts |
| 5 | +@@ -5,6 +5,2 @@ |
| 6 | + |
| 7 | +-import { importAMDNodeModule, resolveAmdNodeModulePath } from '../../../amdX.js'; |
| 8 | +-import { WindowIntervalTimer } from '../../../base/browser/dom.js'; |
| 9 | +-import { mainWindow } from '../../../base/browser/window.js'; |
| 10 | +-import { memoize } from '../../../base/common/decorators.js'; |
| 11 | + import { IProductService } from '../../product/common/productService.js'; |
| 12 | +@@ -13,30 +9,4 @@ import { ISignService } from '../common/sign.js'; |
| 13 | + |
| 14 | +-declare module vsdaWeb { |
| 15 | +- export function sign(salted_message: string): string; |
| 16 | +- |
| 17 | +- // eslint-disable-next-line @typescript-eslint/naming-convention |
| 18 | +- export class validator { |
| 19 | +- free(): void; |
| 20 | +- constructor(); |
| 21 | +- createNewMessage(original: string): string; |
| 22 | +- validate(signed_message: string): 'ok' | 'error'; |
| 23 | +- } |
| 24 | +- |
| 25 | +- export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module; |
| 26 | +- export function init(module_or_path?: InitInput | Promise<InitInput>): Promise<unknown>; |
| 27 | +-} |
| 28 | +- |
| 29 | +-// Initialized if/when vsda is loaded |
| 30 | +-declare const vsda_web: { |
| 31 | +- default: typeof vsdaWeb.init; |
| 32 | +- sign: typeof vsdaWeb.sign; |
| 33 | +- validator: typeof vsdaWeb.validator; |
| 34 | +-}; |
| 35 | +- |
| 36 | +-const KEY_SIZE = 32; |
| 37 | +-const IV_SIZE = 16; |
| 38 | +-const STEP_SIZE = KEY_SIZE + IV_SIZE; |
| 39 | +- |
| 40 | + export class SignService extends AbstractSignService implements ISignService { |
| 41 | +- constructor(@IProductService private readonly productService: IProductService) { |
| 42 | ++ constructor(@IProductService _productService: IProductService) { |
| 43 | + super(); |
| 44 | +@@ -44,53 +14,7 @@ export class SignService extends AbstractSignService implements ISignService { |
| 45 | + protected override getValidator(): Promise<IVsdaValidator> { |
| 46 | +- return this.vsda().then(vsda => { |
| 47 | +- const v = new vsda.validator(); |
| 48 | +- return { |
| 49 | +- createNewMessage: arg => v.createNewMessage(arg), |
| 50 | +- validate: arg => v.validate(arg), |
| 51 | +- dispose: () => v.free(), |
| 52 | +- }; |
| 53 | +- }); |
| 54 | +- } |
| 55 | +- |
| 56 | +- protected override signValue(arg: string): Promise<string> { |
| 57 | +- return this.vsda().then(vsda => vsda.sign(arg)); |
| 58 | +- } |
| 59 | +- |
| 60 | +- @memoize |
| 61 | +- private async vsda(): Promise<typeof vsda_web> { |
| 62 | +- const checkInterval = new WindowIntervalTimer(); |
| 63 | +- let [wasm] = await Promise.all([ |
| 64 | +- this.getWasmBytes(), |
| 65 | +- new Promise<void>((resolve, reject) => { |
| 66 | +- importAMDNodeModule('vsda', 'rust/web/vsda.js').then(() => resolve(), reject); |
| 67 | +- |
| 68 | +- // todo@connor4312: there seems to be a bug(?) in vscode-loader with |
| 69 | +- // require() not resolving in web once the script loads, so check manually |
| 70 | +- checkInterval.cancelAndSet(() => { |
| 71 | +- if (typeof vsda_web !== 'undefined') { |
| 72 | +- resolve(); |
| 73 | +- } |
| 74 | +- }, 50, mainWindow); |
| 75 | +- }).finally(() => checkInterval.dispose()), |
| 76 | +- ]); |
| 77 | +- |
| 78 | +- const keyBytes = new TextEncoder().encode(this.productService.serverLicense?.join('\n') || ''); |
| 79 | +- for (let i = 0; i + STEP_SIZE < keyBytes.length; i += STEP_SIZE) { |
| 80 | +- const key = await crypto.subtle.importKey('raw', keyBytes.slice(i + IV_SIZE, i + IV_SIZE + KEY_SIZE), { name: 'AES-CBC' }, false, ['decrypt']); |
| 81 | +- wasm = await crypto.subtle.decrypt({ name: 'AES-CBC', iv: keyBytes.slice(i, i + IV_SIZE) }, key, wasm); |
| 82 | +- } |
| 83 | +- |
| 84 | +- await vsda_web.default(wasm); |
| 85 | +- |
| 86 | +- return vsda_web; |
| 87 | ++ throw new Error('error loading vsda'); |
| 88 | + } |
| 89 | + |
| 90 | +- private async getWasmBytes(): Promise<ArrayBuffer> { |
| 91 | +- const url = resolveAmdNodeModulePath('vsda', 'rust/web/vsda_bg.wasm'); |
| 92 | +- const response = await fetch(url); |
| 93 | +- if (!response.ok) { |
| 94 | +- throw new Error('error loading vsda'); |
| 95 | +- } |
| 96 | +- |
| 97 | +- return response.arrayBuffer(); |
| 98 | ++ protected override signValue(_arg: string): Promise<string> { |
| 99 | ++ throw new Error('error loading vsda'); |
| 100 | + } |
| 101 | +diff --git a/src/vs/server/node/remoteExtensionHostAgentServer.ts b/src/vs/server/node/remoteExtensionHostAgentServer.ts |
| 102 | +index e7949d3..2a553cc 100644 |
| 103 | +--- a/src/vs/server/node/remoteExtensionHostAgentServer.ts |
| 104 | ++++ b/src/vs/server/node/remoteExtensionHostAgentServer.ts |
| 105 | +@@ -8,3 +8,2 @@ import type * as http from 'http'; |
| 106 | + import * as net from 'net'; |
| 107 | +-import { createRequire } from 'node:module'; |
| 108 | + import { performance } from 'perf_hooks'; |
| 109 | +@@ -41,3 +40,2 @@ import { setupServerServices, SocketServer } from './serverServices.js'; |
| 110 | + import { CacheControl, serveError, serveFile, WebClientServer } from './webClientServer.js'; |
| 111 | +-const require = createRequire(import.meta.url); |
| 112 | + |
| 113 | +@@ -734,14 +732,3 @@ export async function createServer(address: string | net.AddressInfo | null, arg |
| 114 | + |
| 115 | +- const vsdaMod = instantiationService.invokeFunction((accessor) => { |
| 116 | +- const logService = accessor.get(ILogService); |
| 117 | +- const hasVSDA = fs.existsSync(join(FileAccess.asFileUri('').fsPath, '../node_modules/vsda')); |
| 118 | +- if (hasVSDA) { |
| 119 | +- try { |
| 120 | +- return require('vsda'); |
| 121 | +- } catch (err) { |
| 122 | +- logService.error(err); |
| 123 | +- } |
| 124 | +- } |
| 125 | +- return null; |
| 126 | +- }); |
| 127 | ++ const vsdaMod = instantiationService.invokeFunction(() => null); |
| 128 | + |
0 commit comments