Use non-subtle crypto in libsignal-protocol

This commit is contained in:
Fedor Indutny 2021-03-23 17:50:02 -07:00 committed by GitHub
parent 9e9d1c8e84
commit 919259c960
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 120 additions and 13 deletions

View file

@ -5,9 +5,13 @@ import pProps from 'p-props';
import { chunk } from 'lodash';
export function typedArrayToArrayBuffer(typedArray: Uint8Array): ArrayBuffer {
const { buffer, byteOffset, byteLength } = typedArray;
return buffer.slice(byteOffset, byteLength + byteOffset) as typeof typedArray;
const ab = new ArrayBuffer(typedArray.length);
// Create a new Uint8Array backed by the ArrayBuffer and copy all values from
// the `typedArray` into it by calling `.set()` method. Note that raw
// ArrayBuffer doesn't offer this API, because it is supposed to be used with
// concrete data view (i.e. Uint8Array, Float64Array, and so on.)
new Uint8Array(ab).set(typedArray, 0);
return ab;
}
export function arrayBufferToBase64(arrayBuffer: ArrayBuffer): string {