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 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
- /** Ecc implementation using WebAssembly */
17
- /** Ecc implementation using WebAssembly */
18
- /** Ecc implementation using WebAssembly */
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":[],"mappings":"AAIA,6DAA6D;AAC7D,MAAM,WAAW,GAAG;IAChB,2CAA2C;IAC3C,YAAY,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAAC;IAE7C,8DAA8D;IAC9D,SAAS,CAAC,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,UAAU,GAAG,UAAU,CAAC;IAE3D,+DAA+D;IAC/D,WAAW,CAAC,MAAM,EAAE,UAAU,E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AO,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
- /** Ecc implementation using WebAssembly */
38
- //export let Ecc: { new (): Ecc };
39
- // note this doesn't work bc we can't build ecash-lib without it throwing an undefined error
40
- // otherwise it would probably work
41
- //export const Ecc = (globalThis as unknown as GlobalThis).ecashlib.Ecc;
42
- // This won't work because it gets assigned when it runs
43
- // TODO next step is to re-explore grok's getter setter solution
44
- /* Uncomment these to get back to the failure you understand
45
- export let Ecc = (() => {
46
- return 'ecashlib' in globalThis &&
47
- 'Ecc' in (globalThis as unknown as GlobalThis).ecashlib
48
- ? (globalThis as unknown as GlobalThis).ecashlib.Ecc
49
- : EccUninitialized;
50
- })();
51
-
52
- export function __setEcc(ecc: { new (): Ecc }) {
53
- console.log(
54
- `ecashlib in globalThis BEFORE injection`,
55
- 'ecashlib' in globalThis,
56
- );
57
- Object.assign(globalThis, {
58
- ecashlib: {
59
- ...((globalThis as Record<string, any>).ecashlib || {}),
60
- Ecc: ecc,
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
- return new Uint8Array(33);
62
+ throw new Error('Ecc not initialized. Call initWasm first.');
84
63
  }
85
64
  ecdsaSign(_seckey, _msg) {
86
- return new Uint8Array(73);
65
+ throw new Error('Ecc not initialized. Call initWasm first.');
87
66
  }
88
67
  schnorrSign(_seckey, _msg) {
89
- return new Uint8Array(64);
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,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;IACjE,CAAC;IAED,SAAS,CAAC,OAAmB,EAAE,IAAgB;QAC3C,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;IACjE,CAAC;IAED,WAAW,CAAC,OAAmB,EAAE,IAAgB;QAC7C,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;IACjE,CAAC;CACJ;AAED,2CAA2C;AAC3C,kCAAkC;AAElC,4FAA4F;AAC5F,mCAAmC;AAC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OAAmB;QAC5B,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;IACjE,CAAC;IAED,SAAS,CAAC,OAAmB,EAAE,IAAgB;QAC3C,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;IACjE,CAAC;IAED,WAAW,CAAC,OAAmB,EAAE,IAAgB;QAC7C,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;IACjE,CAAC;CACJ,EACD;IACI,SAAS,EAAE,GAAG,EAAE;QACZ,MAAM,UAAU,GACZ,UAAU,IAAI,UAAU;YACxB,KAAK,IAAK,UAAoC,CAAC,QAAQ;YACnD,CAAC,CAAE,UAAoC,CAAC,QAAQ,CAAC,GAAG;YACpD,CAAC,CAAC,gBAAgB,CAAC;QAC3B,OAAO,IAAI,UAAU,EAAE,CAAC;IAC5B,CAAC;CACJ,CACJ,CAAC;AAEF,SAAgB,QAAQ,CAAC,GAAoB;IACzC,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE;QACtB,QAAQ,EAAE;YACN,GAAG,CAAE,UAAkC,CAAC,QAAQ,IAAI,EAAE,CAAC;YACvD,GAAG,EAAE,GAAG;SACX;KAC0B,CAAC,CAAC;AACrC,CAAC;AAPD,4BAOC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ecash-lib",
3
- "version": "1.2.2-rc14",
3
+ "version": "1.2.2-rc16",
4
4
  "description": "Library for eCash transaction building",
5
5
  "main": "./dist/indexNodeJs.js",
6
6
  "browser": "./dist/indexBrowser.js",