You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-25 05:23:13 +03:00
Remove node-specific crypto bits, use Node 16's WebCrypto (#2762)
This commit is contained in:
committed by
GitHub
parent
6af3b114e1
commit
30570bcce6
15
src/utils.ts
15
src/utils.ts
@@ -23,7 +23,6 @@ limitations under the License.
|
||||
import unhomoglyph from "unhomoglyph";
|
||||
import promiseRetry from "p-retry";
|
||||
|
||||
import type * as NodeCrypto from "crypto";
|
||||
import { MatrixEvent } from "./models/event";
|
||||
import { M_TIMESTAMP } from "./@types/location";
|
||||
import { ReceiptType } from "./@types/read_receipts";
|
||||
@@ -453,20 +452,6 @@ export function simpleRetryOperation<T>(promiseFn: (attempt: number) => Promise<
|
||||
});
|
||||
}
|
||||
|
||||
// We need to be able to access the Node.js crypto library from within the
|
||||
// Matrix SDK without needing to `require("crypto")`, which will fail in
|
||||
// browsers. So `index.ts` will call `setCrypto` to store it, and when we need
|
||||
// it, we can call `getCrypto`.
|
||||
let crypto: typeof NodeCrypto;
|
||||
|
||||
export function setCrypto(c: typeof NodeCrypto) {
|
||||
crypto = c;
|
||||
}
|
||||
|
||||
export function getCrypto(): typeof NodeCrypto {
|
||||
return crypto;
|
||||
}
|
||||
|
||||
// String averaging inspired by https://stackoverflow.com/a/2510816
|
||||
// Dev note: We make the alphabet a string because it's easier to write syntactically
|
||||
// than arrays. Thankfully, strings implement the useful parts of the Array interface
|
||||
|
||||
Reference in New Issue
Block a user