File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -2,9 +2,9 @@ import { ec as EC } from "elliptic";
22
33const ec = new EC ( "secp256k1" ) ;
44// eslint-disable-next-line @typescript-eslint/no-explicit-any, n/no-unsupported-features/node-builtins
5- const browserCrypto = globalThis . crypto || ( globalThis as any ) . msCrypto || { } ;
5+ let browserCrypto = globalThis . crypto || ( globalThis as any ) . msCrypto || { } ;
66// eslint-disable-next-line @typescript-eslint/no-explicit-any
7- const subtle = browserCrypto . subtle || ( browserCrypto as any ) . webkitSubtle ;
7+ let subtle = browserCrypto . subtle || ( browserCrypto as any ) . webkitSubtle ;
88
99const EC_GROUP_ORDER = Buffer . from ( "fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141" , "hex" ) ;
1010const ZERO32 = Buffer . alloc ( 32 , 0 ) ;
@@ -16,6 +16,12 @@ export interface Ecies {
1616 mac : Buffer ;
1717}
1818
19+ export function injectCryptoLib ( cryptoLib : unknown ) {
20+ browserCrypto = cryptoLib ;
21+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
22+ subtle = browserCrypto . subtle || ( browserCrypto as any ) . webkitSubtle ;
23+ }
24+
1925function assert ( condition : boolean , message : string ) {
2026 if ( ! condition ) {
2127 throw new Error ( message || "Assertion failed" ) ;
You can’t perform that action at this time.
0 commit comments