@waku/rln 0.1.6-acc9100.0 → 0.1.6-b0a2e39.0

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.
Files changed (69) hide show
  1. package/bundle/_virtual/utils.js +2 -2
  2. package/bundle/_virtual/utils2.js +2 -2
  3. package/bundle/index.js +1 -1
  4. package/bundle/node_modules/@chainsafe/bls-keystore/node_modules/@noble/hashes/_sha2.js +1 -1
  5. package/bundle/node_modules/@chainsafe/bls-keystore/node_modules/@noble/hashes/hmac.js +1 -1
  6. package/bundle/node_modules/@chainsafe/bls-keystore/node_modules/@noble/hashes/pbkdf2.js +1 -1
  7. package/bundle/node_modules/@chainsafe/bls-keystore/node_modules/@noble/hashes/scrypt.js +1 -1
  8. package/bundle/node_modules/@chainsafe/bls-keystore/node_modules/@noble/hashes/sha256.js +1 -1
  9. package/bundle/node_modules/@chainsafe/bls-keystore/node_modules/@noble/hashes/sha512.js +1 -1
  10. package/bundle/node_modules/@chainsafe/bls-keystore/node_modules/@noble/hashes/utils.js +1 -1
  11. package/bundle/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/random.js +1 -1
  12. package/bundle/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/utils.js +2 -2
  13. package/bundle/packages/core/dist/lib/connection_manager/connection_manager.js +1 -0
  14. package/bundle/packages/core/dist/lib/connection_manager/keep_alive_manager.js +1 -0
  15. package/bundle/packages/core/dist/lib/filter/filter.js +2 -0
  16. package/bundle/packages/core/dist/lib/light_push/light_push.js +12 -9
  17. package/bundle/packages/core/dist/lib/light_push/light_push_v3.js +30 -0
  18. package/bundle/packages/core/dist/lib/light_push/utils.js +18 -0
  19. package/bundle/packages/core/dist/lib/message/version_0.js +1 -0
  20. package/bundle/packages/core/dist/lib/metadata/metadata.js +2 -0
  21. package/bundle/packages/core/dist/lib/store/store.js +2 -0
  22. package/bundle/packages/interfaces/dist/light_push_v3.js +29 -0
  23. package/bundle/packages/interfaces/dist/protocols.js +10 -0
  24. package/bundle/packages/proto/dist/generated/light_push.js +3 -3
  25. package/bundle/packages/proto/dist/generated/light_push_v3.js +348 -0
  26. package/bundle/packages/rln/dist/codec.js +1 -0
  27. package/bundle/packages/rln/dist/contract/constants.js +1 -7
  28. package/bundle/packages/rln/dist/contract/rln_base_contract.js +7 -28
  29. package/bundle/packages/rln/dist/contract/rln_contract.js +1 -0
  30. package/bundle/packages/rln/dist/credentials_manager.js +15 -16
  31. package/bundle/packages/rln/dist/identity.js +8 -5
  32. package/bundle/packages/rln/dist/keystore/keystore.js +12 -15
  33. package/bundle/packages/rln/dist/message.js +2 -0
  34. package/bundle/packages/rln/dist/rln.js +2 -0
  35. package/bundle/packages/rln/dist/utils/bytes.js +16 -14
  36. package/bundle/packages/rln/dist/utils/epoch.js +1 -0
  37. package/bundle/packages/utils/dist/common/sharding/index.js +1 -0
  38. package/dist/.tsbuildinfo +1 -1
  39. package/dist/contract/constants.d.ts +0 -6
  40. package/dist/contract/constants.js +0 -6
  41. package/dist/contract/constants.js.map +1 -1
  42. package/dist/contract/rln_base_contract.d.ts +0 -6
  43. package/dist/contract/rln_base_contract.js +6 -28
  44. package/dist/contract/rln_base_contract.js.map +1 -1
  45. package/dist/contract/test-utils.d.ts +39 -0
  46. package/dist/contract/test-utils.js +118 -0
  47. package/dist/contract/test-utils.js.map +1 -0
  48. package/dist/credentials_manager.js +14 -16
  49. package/dist/credentials_manager.js.map +1 -1
  50. package/dist/identity.d.ts +2 -4
  51. package/dist/identity.js +6 -5
  52. package/dist/identity.js.map +1 -1
  53. package/dist/keystore/keystore.js +11 -15
  54. package/dist/keystore/keystore.js.map +1 -1
  55. package/dist/utils/bytes.d.ts +6 -2
  56. package/dist/utils/bytes.js +15 -13
  57. package/dist/utils/bytes.js.map +1 -1
  58. package/dist/utils/index.d.ts +1 -1
  59. package/dist/utils/index.js +1 -1
  60. package/dist/utils/index.js.map +1 -1
  61. package/package.json +1 -1
  62. package/src/contract/constants.ts +0 -9
  63. package/src/contract/rln_base_contract.ts +13 -41
  64. package/src/contract/test-utils.ts +179 -0
  65. package/src/credentials_manager.ts +21 -27
  66. package/src/identity.ts +7 -5
  67. package/src/keystore/keystore.ts +24 -28
  68. package/src/utils/bytes.ts +25 -21
  69. package/src/utils/index.ts +1 -1
@@ -17,13 +17,18 @@ export function concatenate(...input: Uint8Array[]): Uint8Array {
17
17
  return result;
18
18
  }
19
19
 
20
- export function switchEndianness(bytes: Uint8Array): Uint8Array {
21
- return new Uint8Array(bytes.reverse());
22
- }
23
-
24
- export function buildBigIntFromUint8ArrayBE(bytes: Uint8Array): bigint {
25
- // Interpret bytes as big-endian
26
- return bytes.reduce((acc, byte) => (acc << 8n) + BigInt(byte), 0n);
20
+ // Adapted from https://github.com/feross/buffer
21
+ function checkInt(
22
+ buf: Uint8Array,
23
+ value: number,
24
+ offset: number,
25
+ ext: number,
26
+ max: number,
27
+ min: number
28
+ ): void {
29
+ if (value > max || value < min)
30
+ throw new RangeError('"value" argument is out of bounds');
31
+ if (offset + ext > buf.length) throw new RangeError("Index out of range");
27
32
  }
28
33
 
29
34
  export function writeUIntLE(
@@ -51,6 +56,19 @@ export function writeUIntLE(
51
56
  return buf;
52
57
  }
53
58
 
59
+ /**
60
+ * Transforms Uint8Array into BigInt
61
+ * @param array: Uint8Array
62
+ * @returns BigInt
63
+ */
64
+ export function buildBigIntFromUint8Array(
65
+ array: Uint8Array,
66
+ byteOffset: number = 0
67
+ ): bigint {
68
+ const dataView = new DataView(array.buffer);
69
+ return dataView.getBigUint64(byteOffset, true);
70
+ }
71
+
54
72
  /**
55
73
  * Fills with zeros to set length
56
74
  * @param array little endian Uint8Array
@@ -64,17 +82,3 @@ export function zeroPadLE(array: Uint8Array, length: number): Uint8Array {
64
82
  }
65
83
  return result;
66
84
  }
67
-
68
- // Adapted from https://github.com/feross/buffer
69
- function checkInt(
70
- buf: Uint8Array,
71
- value: number,
72
- offset: number,
73
- ext: number,
74
- max: number,
75
- min: number
76
- ): void {
77
- if (value > max || value < min)
78
- throw new RangeError('"value" argument is out of bounds');
79
- if (offset + ext > buf.length) throw new RangeError("Index out of range");
80
- }
@@ -2,7 +2,7 @@ export { extractMetaMaskSigner } from "./metamask.js";
2
2
  export {
3
3
  concatenate,
4
4
  writeUIntLE,
5
- switchEndianness,
5
+ buildBigIntFromUint8Array,
6
6
  zeroPadLE
7
7
  } from "./bytes.js";
8
8
  export { sha256, poseidonHash } from "./hash.js";