ecash-lib 1.2.2-rc14 → 1.2.2-rc16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ecc.d.ts +18 -3
- package/dist/ecc.d.ts.map +1 -1
- package/dist/ecc.js +27 -56
- package/dist/ecc.js.map +1 -1
- package/package.json +1 -1
package/dist/ecc.d.ts
CHANGED
|
@@ -13,9 +13,24 @@ export declare class EccDummy implements Ecc {
|
|
|
13
13
|
ecdsaSign(_seckey: Uint8Array, _msg: Uint8Array): Uint8Array;
|
|
14
14
|
schnorrSign(_seckey: Uint8Array, _msg: Uint8Array): Uint8Array;
|
|
15
15
|
}
|
|
16
|
-
/**
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
/**
|
|
17
|
+
* We define Ecc as a proxy
|
|
18
|
+
* This is done to solve a specific problem
|
|
19
|
+
* If we have this kind of app structure:
|
|
20
|
+
* - AppOne has ecash-lib as a dependency
|
|
21
|
+
* - AppTwo has ecash-lib as a dependency
|
|
22
|
+
* - AppOne has AppTwo as a dependency
|
|
23
|
+
*
|
|
24
|
+
* So, we expect AppOne to use AppTwo methods that need initWasm()
|
|
25
|
+
* However, if we initWasm() in AppOne, these methods are not available in AppTwo
|
|
26
|
+
*
|
|
27
|
+
* We can get them into the globalThis with initWasm, but we still need Ecc to dynamically
|
|
28
|
+
* check the globalThis and realize it is there --- to preserve lib syntax
|
|
29
|
+
*
|
|
30
|
+
* In this way, users can still call "new Ecc()"
|
|
31
|
+
*
|
|
32
|
+
* With just globalThis, users must call "new (globalThis as unknown as GlobalThis).ecashlib.Ecc()"
|
|
33
|
+
*/
|
|
19
34
|
export declare const Ecc: {
|
|
20
35
|
new (): {
|
|
21
36
|
derivePubkey(_seckey: Uint8Array): Uint8Array;
|
package/dist/ecc.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ecc.d.ts","sourceRoot":"","sources":["../src/ecc.ts"],"names":[],"mapp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AAO,MAAM,GAAG;;8BAQc,UAAU,GAAG,UAAU;2BAI1B,UAAU,QAAQ,UAAU,GAAG,UAAU;6BAIvC,UAAU,QAAQ,UAAU,GAAG,UAAU;;CAcrE,CAAC;AAEF,wBAAgB,QAAQ,CAAC,GAAG,EAAE;IAAE,QAAQ,GAAG,CAAA;CAAE,QAO5C"}
|
package/dist/ecc.js
CHANGED
|
@@ -34,59 +34,38 @@ class EccUninitialized {
|
|
|
34
34
|
throw new Error('Ecc not initialized. Call initWasm first.');
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
/**
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
)
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
},
|
|
62
|
-
} as Partial<typeof globalThis>);
|
|
63
|
-
console.log(
|
|
64
|
-
`ecashlib in globalThis AFTER injection`,
|
|
65
|
-
'ecashlib' in globalThis,
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
// Update Ecc now that we know it is available in globalThis
|
|
69
|
-
console.log(`Updating Ecc in __setEcc`);
|
|
70
|
-
console.log(`Ecc before update`, Ecc);
|
|
71
|
-
// Re-assign
|
|
72
|
-
// But if we call initWasm() in parent lib, it does not reassign in the child lib
|
|
73
|
-
// So we need to "get it right" without any re-assigning
|
|
74
|
-
Ecc = (globalThis as unknown as GlobalThis).ecashlib.Ecc;
|
|
75
|
-
console.log(`Ecc after update`, Ecc);
|
|
76
|
-
}
|
|
77
|
-
*/
|
|
78
|
-
/** Ecc implementation using WebAssembly */
|
|
79
|
-
/** Ecc implementation using WebAssembly */
|
|
80
|
-
// Define Ecc as a getter function
|
|
81
|
-
exports.Ecc = new Proxy(class {
|
|
37
|
+
/**
|
|
38
|
+
* We define Ecc as a proxy
|
|
39
|
+
* This is done to solve a specific problem
|
|
40
|
+
* If we have this kind of app structure:
|
|
41
|
+
* - AppOne has ecash-lib as a dependency
|
|
42
|
+
* - AppTwo has ecash-lib as a dependency
|
|
43
|
+
* - AppOne has AppTwo as a dependency
|
|
44
|
+
*
|
|
45
|
+
* So, we expect AppOne to use AppTwo methods that need initWasm()
|
|
46
|
+
* However, if we initWasm() in AppOne, these methods are not available in AppTwo
|
|
47
|
+
*
|
|
48
|
+
* We can get them into the globalThis with initWasm, but we still need Ecc to dynamically
|
|
49
|
+
* check the globalThis and realize it is there --- to preserve lib syntax
|
|
50
|
+
*
|
|
51
|
+
* In this way, users can still call "new Ecc()"
|
|
52
|
+
*
|
|
53
|
+
* With just globalThis, users must call "new (globalThis as unknown as GlobalThis).ecashlib.Ecc()"
|
|
54
|
+
*/
|
|
55
|
+
exports.Ecc = new Proxy(class EccProxy {
|
|
56
|
+
constructor() {
|
|
57
|
+
if (!exports.Ecc.prototype.derivePubkey) {
|
|
58
|
+
throw new Error('Ecc not initialized. Call initWasm first.');
|
|
59
|
+
}
|
|
60
|
+
}
|
|
82
61
|
derivePubkey(_seckey) {
|
|
83
|
-
|
|
62
|
+
throw new Error('Ecc not initialized. Call initWasm first.');
|
|
84
63
|
}
|
|
85
64
|
ecdsaSign(_seckey, _msg) {
|
|
86
|
-
|
|
65
|
+
throw new Error('Ecc not initialized. Call initWasm first.');
|
|
87
66
|
}
|
|
88
67
|
schnorrSign(_seckey, _msg) {
|
|
89
|
-
|
|
68
|
+
throw new Error('Ecc not initialized. Call initWasm first.');
|
|
90
69
|
}
|
|
91
70
|
}, {
|
|
92
71
|
construct: () => {
|
|
@@ -98,20 +77,12 @@ exports.Ecc = new Proxy(class {
|
|
|
98
77
|
},
|
|
99
78
|
});
|
|
100
79
|
function __setEcc(ecc) {
|
|
101
|
-
console.log(`Ecc before update`, exports.Ecc);
|
|
102
|
-
console.log(`ecashlib in globalThis BEFORE injection`, 'ecashlib' in globalThis);
|
|
103
80
|
Object.assign(globalThis, {
|
|
104
81
|
ecashlib: {
|
|
105
82
|
...(globalThis.ecashlib || {}),
|
|
106
83
|
Ecc: ecc,
|
|
107
84
|
},
|
|
108
85
|
});
|
|
109
|
-
console.log(`ecashlib in globalThis AFTER injection`, 'ecashlib' in globalThis);
|
|
110
|
-
// Update Ecc now that we know it is available in globalThis
|
|
111
|
-
//console.log(`Updating Ecc in __setEcc`);
|
|
112
|
-
//console.log(`Ecc before update`, Ecc);
|
|
113
|
-
//Ecc = ecc; // This will use the setter defined above
|
|
114
|
-
console.log(`Ecc after update`, exports.Ecc);
|
|
115
86
|
}
|
|
116
87
|
exports.__setEcc = __setEcc;
|
|
117
88
|
//# sourceMappingURL=ecc.js.map
|
package/dist/ecc.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ecc.js","sourceRoot":"","sources":["../src/ecc.ts"],"names":[],"mappings":";AAAA,4CAA4C;AAC5C,mEAAmE;AACnE,sEAAsE;;;AActE,yEAAyE;AACzE,MAAa,QAAQ;IACjB,YAAY,CAAC,OAAmB;QAC5B,OAAO,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC;IAC9B,CAAC;IAED,SAAS,CAAC,OAAmB,EAAE,IAAgB;QAC3C,OAAO,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC;IAC9B,CAAC;IAED,WAAW,CAAC,OAAmB,EAAE,IAAgB;QAC7C,OAAO,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC;IAC9B,CAAC;CACJ;AAZD,4BAYC;AAED,qCAAqC;AACrC,MAAM,gBAAgB;IAClB;QACI,IAAI,CAAC,WAAG,CAAC,SAAS,CAAC,YAAY,EAAE,CAAC;YAC9B,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;QACjE,CAAC;IACL,CAAC;IAED,YAAY,CAAC,OAAmB;QAC5B,MAAM,IA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