mirror of
https://github.com/Microsoft/vscode
synced 2024-09-13 21:55:38 +00:00
add some docs for workaround for #114227
This commit is contained in:
parent
a07327a430
commit
b9c6730480
|
@ -10,7 +10,14 @@ export async function sha1Hex(str: string): Promise<string> {
|
|||
|
||||
// Prefer to use browser's crypto module
|
||||
if (globalThis?.crypto?.subtle) {
|
||||
const hash = await globalThis.crypto.subtle.digest({ name: 'sha-1' }, VSBuffer.fromString(str, { dontUseNodeBuffer: true }).buffer);
|
||||
|
||||
// Careful to use `dontUseNodeBuffer` when passing the
|
||||
// buffer to the browser `crypto` API. Users reported
|
||||
// native crashes in certain cases that we could trace
|
||||
// back to passing node.js `Buffer` around
|
||||
// (https://github.com/microsoft/vscode/issues/114227)
|
||||
const buffer = VSBuffer.fromString(str, { dontUseNodeBuffer: true }).buffer;
|
||||
const hash = await globalThis.crypto.subtle.digest({ name: 'sha-1' }, buffer);
|
||||
|
||||
return toHexString(hash);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue