Skip to content

Commit 4179b72

Browse files
committed
Use crypto
1 parent daa6f97 commit 4179b72

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

spec/setupTests.ts

-4
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,8 @@ limitations under the License.
1515
*/
1616

1717
import DOMException from "domexception";
18-
import * as crypto from "crypto";
1918

2019
global.DOMException = DOMException as typeof global.DOMException;
21-
// Set node crypto into global.crypto
22-
// Needed in `CryptoApi#createRecoveryKeyFromPassphrase` and `crypto/crypto.ts`
23-
global.crypto = crypto.webcrypto as typeof global.crypto;
2420

2521
jest.mock("../src/http-api/utils", () => ({
2622
...jest.requireActual("../src/http-api/utils"),

src/rust-crypto/rust-crypto.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import { CrossSigningIdentity } from "./CrossSigningIdentity";
4646
import { secretStorageContainsCrossSigningKeys } from "./secret-storage";
4747
import { keyFromPassphrase } from "../crypto/key_passphrase";
4848
import { encodeRecoveryKey } from "../crypto/recoverykey";
49+
import { crypto } from "../crypto/crypto";
4950

5051
/**
5152
* An implementation of {@link CryptoBackend} using the Rust matrix-sdk-crypto.
@@ -426,7 +427,7 @@ export class RustCrypto implements CryptoBackend {
426427
} else {
427428
// Using the navigator crypto API to generate the private key
428429
privateKey = new Uint8Array(32);
429-
global.crypto.getRandomValues(privateKey);
430+
crypto.getRandomValues(privateKey);
430431
}
431432

432433
const encodedPrivateKey = encodeRecoveryKey(privateKey);

0 commit comments

Comments
 (0)