ecash-lib 1.2.2-rc4 → 1.2.2-rc5

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
@@ -7,18 +7,9 @@ export interface Ecc {
7
7
  /** Sign a Schnorr signature. msg needs to be a 32-byte hash */
8
8
  schnorrSign(seckey: Uint8Array, msg: Uint8Array): Uint8Array;
9
9
  }
10
- /** Uninitialized Ecc impl that throws an error asking for initWasm */
11
- export declare class EccBeforeWasm implements Ecc {
12
- constructor();
13
- derivePubkey(_seckey: Uint8Array): Uint8Array;
14
- ecdsaSign(_seckey: Uint8Array, _msg: Uint8Array): Uint8Array;
15
- schnorrSign(_seckey: Uint8Array, _msg: Uint8Array): Uint8Array;
16
- }
17
10
  /** Ecc implementation using WebAssembly */
18
11
  export declare let Ecc: {
19
12
  new (): Ecc;
20
- } | {
21
- new (): EccBeforeWasm;
22
13
  };
23
14
  /** Dummy Ecc impl that always returns 0, useful for measuring tx size */
24
15
  export declare class EccDummy implements Ecc {
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,EAAE,GAAG,EAAE,UAAU,GAAG,UAAU,CAAC;CAChE;AAED,sEAAsE;AACtE,qBAAa,aAAc,YAAW,GAAG;;IAKrC,YAAY,CAAC,OAAO,EAAE,UAAU,GAAG,UAAU;IAI7C,SAAS,CAAC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,GAA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AU;CAGjE;AAED,wBAAgB,QAAQ,CAAC,GAAG,EAAE;IAAE,QAAQ,GAAG,CAAA;CAAE,QAS5C"}
package/dist/ecc.js CHANGED
@@ -3,23 +3,7 @@
3
3
  // Distributed under the MIT software license, see the accompanying
4
4
  // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.__setEcc = exports.EccDummy = exports.Ecc = exports.EccBeforeWasm = void 0;
7
- /** Uninitialized Ecc impl that throws an error asking for initWasm */
8
- class EccBeforeWasm {
9
- constructor() {
10
- throw new Error('Ecc is not initialized, initWasm() must be called');
11
- }
12
- derivePubkey(_seckey) {
13
- throw new Error('Ecc is not initialized, initWasm() must be called');
14
- }
15
- ecdsaSign(_seckey, _msg) {
16
- throw new Error('Ecc is not initialized, initWasm() must be called');
17
- }
18
- schnorrSign(_seckey, _msg) {
19
- throw new Error('Ecc is not initialized, initWasm() must be called');
20
- }
21
- }
22
- exports.EccBeforeWasm = EccBeforeWasm;
6
+ exports.__setEcc = exports.EccDummy = exports.Ecc = void 0;
23
7
  /** Dummy Ecc impl that always returns 0, useful for measuring tx size */
24
8
  class EccDummy {
25
9
  derivePubkey(_seckey) {
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,sEAAsE;AACtE,MAAa,aAAa;IACtB;QACI,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;IACzE,CAAC;IAED,YAAY,CAAC,OAAmB;QAC5B,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;IACzE,CAAC;IAED,SAAS,CAAC,OAAmB,EAAE,IAAgB;QAC3C,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;IACzE,CAAC;IAED,WAAW,CAAC,OAAmB,EAAE,IAAgB;QAC7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E;QACtB,QAAQ,EAAE;YACN,GAAG,CAAE,UAAkC,CAAC,QAAQ,IAAI,EAAE,CAAC;YACvD,GAAG,EAAE,GAAG;SACX;KAC0B,CAAC,CAAC;AACrC,CAAC;AATD,4BASC"}
package/global.d.ts CHANGED
@@ -3,11 +3,34 @@
3
3
  // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
4
 
5
5
  /**
6
- * Note this is duplicated in src/ecc.ts
7
- * We could not import it here as it leads to rel path errors in the
6
+ * global.d.ts
7
+ *
8
+ * Extend globalThis to include a new namespace, ecashlib
9
+ * We use this namespace to store lib functions that are only
10
+ * available after initWasm()
11
+ *
12
+ * We store all lib methods in ecashlib namespace to reduce chances of
13
+ * namespace collision in global this
14
+ *
15
+ * In general, dependency injection is a better practice, and this is what
16
+ * ecash-lib used until 1.2.2
17
+ *
18
+ * However dependency injection caused issues with libraries that used ecash-lib
19
+ * as a dependency, like ecash-agora. Methods that "should" have been available
20
+ * after initWasm() would not be available.
21
+ *
22
+ * Resolved by adding to globalThis (as responsibly as possible)
23
+ */
24
+
25
+ // BEGIN DUPLICATED CLASS DEFINITIONS
26
+
27
+ /**
28
+ * Note
29
+ * These definitions are duplicated in src/ecc.ts
30
+ * Could not import it here as it leads to rel path errors in the
8
31
  * published dependency when it is consumed by other apps
9
32
  */
10
- // BEGIN DUPLICATED CLASS DEFS
33
+
11
34
  /** Interface to abstract over Elliptic Curve Cryptography */
12
35
  export interface Ecc {
13
36
  /** Derive a public key from secret key. */
@@ -22,7 +45,7 @@ export interface Ecc {
22
45
 
23
46
  /** Ecc implementation using WebAssembly */
24
47
  export let Ecc: { new (): Ecc };
25
- // END DUPLICATED CLASS DEFS
48
+ // END DUPLICATED CLASS DEFINITIONS
26
49
 
27
50
  export interface EcashLibHashes {
28
51
  sha256: (data: Uint8Array) => Uint8Array;
@@ -30,7 +53,7 @@ export interface EcashLibHashes {
30
53
  shaRmd160: (data: Uint8Array) => Uint8Array;
31
54
  }
32
55
 
33
- // Extend global this to include hashes
56
+ // Extend global this to include HASHES and Ecc
34
57
  declare global {
35
58
  interface GlobalThis {
36
59
  ecashlib: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ecash-lib",
3
- "version": "1.2.2-rc4",
3
+ "version": "1.2.2-rc5",
4
4
  "description": "Library for eCash transaction building",
5
5
  "main": "./dist/indexNodeJs.js",
6
6
  "browser": "./dist/indexBrowser.js",