mirror of
https://github.com/coder/code-server.git
synced 2026-05-09 05:47:26 +02:00
Merge commit 'be3e8236086165e5e45a5a10783823874b3f3ebd' as 'lib/vscode'
This commit is contained in:
21
lib/vscode/src/vs/platform/sign/browser/signService.ts
Normal file
21
lib/vscode/src/vs/platform/sign/browser/signService.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { ISignService } from 'vs/platform/sign/common/sign';
|
||||
|
||||
export class SignService implements ISignService {
|
||||
|
||||
declare readonly _serviceBrand: undefined;
|
||||
|
||||
private readonly _tkn: string | null;
|
||||
|
||||
constructor(token: string | undefined) {
|
||||
this._tkn = token || null;
|
||||
}
|
||||
|
||||
async sign(value: string): Promise<string> {
|
||||
return this._tkn || '';
|
||||
}
|
||||
}
|
||||
15
lib/vscode/src/vs/platform/sign/common/sign.ts
Normal file
15
lib/vscode/src/vs/platform/sign/common/sign.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
|
||||
export const SIGN_SERVICE_ID = 'signService';
|
||||
export const ISignService = createDecorator<ISignService>(SIGN_SERVICE_ID);
|
||||
|
||||
export interface ISignService {
|
||||
readonly _serviceBrand: undefined;
|
||||
|
||||
sign(value: string): Promise<string>;
|
||||
}
|
||||
35
lib/vscode/src/vs/platform/sign/node/signService.ts
Normal file
35
lib/vscode/src/vs/platform/sign/node/signService.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { ISignService } from 'vs/platform/sign/common/sign';
|
||||
|
||||
declare module vsda {
|
||||
// the signer is a native module that for historical reasons uses a lower case class name
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
export class signer {
|
||||
sign(arg: any): any;
|
||||
}
|
||||
}
|
||||
|
||||
export class SignService implements ISignService {
|
||||
declare readonly _serviceBrand: undefined;
|
||||
|
||||
private vsda(): Promise<typeof vsda> {
|
||||
return new Promise((resolve, reject) => require(['vsda'], resolve, reject));
|
||||
}
|
||||
|
||||
async sign(value: string): Promise<string> {
|
||||
try {
|
||||
const vsda = await this.vsda();
|
||||
const signer = new vsda.signer();
|
||||
if (signer) {
|
||||
return signer.sign(value);
|
||||
}
|
||||
} catch (e) {
|
||||
// ignore errors silently
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user