mirror of
https://github.com/selfxyz/self.git
synced 2026-04-05 03:00:53 -04:00
* Clean up root license wording * Simplify SPDX header * simplify license and rename BSL to BUSL * fix merge issues * fix missing method --------- Co-authored-by: Justin Hernandez <transphorm@gmail.com>
28 lines
870 B
TypeScript
28 lines
870 B
TypeScript
// SPDX-License-Identifier: BUSL-1.1; Copyright (c) 2025 Social Connect Labs, Inc.; Licensed under BUSL-1.1 (see LICENSE); Apache-2.0 from 2029-06-11
|
|
|
|
// https://docs.ethers.org/v6/cookbook/react-native/
|
|
import { ethers } from 'ethers';
|
|
import crypto from 'react-native-quick-crypto';
|
|
|
|
ethers.randomBytes.register(length => {
|
|
return new Uint8Array(crypto.randomBytes(length));
|
|
});
|
|
|
|
ethers.computeHmac.register((algo, key, data) => {
|
|
return crypto.createHmac(algo, key).update(data).digest();
|
|
});
|
|
|
|
ethers.pbkdf2.register((passwd, salt, iter, keylen, algo) => {
|
|
return crypto.pbkdf2Sync(passwd, salt, iter, keylen, algo);
|
|
});
|
|
|
|
ethers.sha256.register(data => {
|
|
// @ts-expect-error
|
|
return crypto.createHash('sha256').update(data).digest();
|
|
});
|
|
|
|
ethers.sha512.register(data => {
|
|
// @ts-expect-error
|
|
return crypto.createHash('sha512').update(data).digest();
|
|
});
|