@waku/rln 0.1.6-b7e9b08.0 → 0.1.6-f7778a9.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 (71) hide show
  1. package/bundle/_virtual/utils.js +2 -2
  2. package/bundle/_virtual/utils2.js +2 -2
  3. package/bundle/index.js +2 -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/node_modules/@ethersproject/keccak256/lib.esm/index.js +1 -1
  14. package/bundle/node_modules/{@ethersproject/keccak256/node_modules/js-sha3 → js-sha3}/src/sha3.js +2 -2
  15. package/bundle/packages/core/dist/lib/connection_manager/connection_manager.js +0 -3
  16. package/bundle/packages/core/dist/lib/connection_manager/keep_alive_manager.js +3 -3
  17. package/bundle/packages/core/dist/lib/filter/filter.js +0 -3
  18. package/bundle/packages/core/dist/lib/light_push/light_push.js +0 -3
  19. package/bundle/packages/core/dist/lib/message/version_0.js +1 -4
  20. package/bundle/packages/core/dist/lib/metadata/metadata.js +0 -3
  21. package/bundle/packages/core/dist/lib/store/store.js +3 -3
  22. package/bundle/packages/rln/dist/codec.js +3 -3
  23. package/bundle/packages/rln/dist/contract/constants.js +8 -1
  24. package/bundle/packages/rln/dist/contract/rln_base_contract.js +138 -75
  25. package/bundle/packages/rln/dist/contract/rln_contract.js +3 -3
  26. package/bundle/packages/rln/dist/credentials_manager.js +15 -10
  27. package/bundle/packages/rln/dist/keystore/keystore.js +4 -4
  28. package/bundle/packages/rln/dist/message.js +11 -0
  29. package/bundle/packages/rln/dist/rln.js +3 -3
  30. package/bundle/packages/rln/dist/utils/epoch.js +3 -3
  31. package/bundle/packages/utils/dist/common/sharding/index.js +4 -4
  32. package/dist/.tsbuildinfo +1 -1
  33. package/dist/contract/constants.d.ts +6 -0
  34. package/dist/contract/constants.js +6 -0
  35. package/dist/contract/constants.js.map +1 -1
  36. package/dist/contract/index.d.ts +1 -0
  37. package/dist/contract/index.js +1 -0
  38. package/dist/contract/index.js.map +1 -1
  39. package/dist/contract/rln_base_contract.d.ts +37 -22
  40. package/dist/contract/rln_base_contract.js +135 -72
  41. package/dist/contract/rln_base_contract.js.map +1 -1
  42. package/dist/contract/types.d.ts +5 -0
  43. package/dist/contract/types.js.map +1 -1
  44. package/dist/credentials_manager.js +12 -7
  45. package/dist/credentials_manager.js.map +1 -1
  46. package/dist/index.d.ts +2 -1
  47. package/dist/index.js +1 -0
  48. package/dist/index.js.map +1 -1
  49. package/dist/keystore/keystore.js.map +1 -1
  50. package/dist/keystore/types.d.ts +2 -2
  51. package/dist/message.d.ts +5 -4
  52. package/dist/message.js +2 -0
  53. package/dist/message.js.map +1 -1
  54. package/package.json +1 -1
  55. package/src/contract/constants.ts +9 -0
  56. package/src/contract/index.ts +1 -0
  57. package/src/contract/rln_base_contract.ts +181 -103
  58. package/src/contract/types.ts +5 -0
  59. package/src/credentials_manager.ts +20 -7
  60. package/src/index.ts +3 -1
  61. package/src/keystore/keystore.ts +4 -2
  62. package/src/keystore/types.ts +2 -2
  63. package/src/message.ts +7 -4
  64. package/bundle/packages/utils/node_modules/@waku/interfaces/dist/connection_manager.js +0 -19
  65. package/bundle/packages/utils/node_modules/@waku/interfaces/dist/health_indicator.js +0 -12
  66. package/bundle/packages/utils/node_modules/@waku/interfaces/dist/protocols.js +0 -92
  67. /package/bundle/packages/{utils/node_modules/@waku/interfaces → interfaces}/dist/constants.js +0 -0
  68. /package/bundle/{node_modules → packages/rln/node_modules}/uuid/dist/esm-browser/native.js +0 -0
  69. /package/bundle/{node_modules → packages/rln/node_modules}/uuid/dist/esm-browser/rng.js +0 -0
  70. /package/bundle/{node_modules → packages/rln/node_modules}/uuid/dist/esm-browser/stringify.js +0 -0
  71. /package/bundle/{node_modules → packages/rln/node_modules}/uuid/dist/esm-browser/v4.js +0 -0
@@ -21,8 +21,8 @@ import { isCredentialValid, isKeystoreValid } from "./schema_validator.js";
21
21
  import type {
22
22
  Keccak256Hash,
23
23
  KeystoreEntity,
24
+ KeystoreMembershipInfo,
24
25
  MembershipHash,
25
- MembershipInfo,
26
26
  Password,
27
27
  Sha256Hash
28
28
  } from "./types.js";
@@ -310,7 +310,9 @@ export class Keystore {
310
310
 
311
311
  // follows nwaku implementation
312
312
  // https://github.com/waku-org/nwaku/blob/f05528d4be3d3c876a8b07f9bb7dfaae8aa8ec6e/waku/waku_keystore/protocol_types.nim#L111
313
- private static computeMembershipHash(info: MembershipInfo): MembershipHash {
313
+ private static computeMembershipHash(
314
+ info: KeystoreMembershipInfo
315
+ ): MembershipHash {
314
316
  return bytesToHex(
315
317
  sha256(utf8ToBytes(`${info.chainId}${info.address}${info.treeIndex}`))
316
318
  ).toUpperCase();
@@ -7,7 +7,7 @@ export type Password = string | Uint8Array;
7
7
 
8
8
  // see reference
9
9
  // https://github.com/waku-org/nwaku/blob/f05528d4be3d3c876a8b07f9bb7dfaae8aa8ec6e/waku/waku_keystore/protocol_types.nim#L111
10
- export type MembershipInfo = {
10
+ export type KeystoreMembershipInfo = {
11
11
  chainId: string;
12
12
  address: string;
13
13
  treeIndex: number;
@@ -16,7 +16,7 @@ export type MembershipInfo = {
16
16
 
17
17
  export type KeystoreEntity = {
18
18
  identity: IdentityCredential;
19
- membership: MembershipInfo;
19
+ membership: KeystoreMembershipInfo;
20
20
  };
21
21
 
22
22
  export type DecryptedCredentials = KeystoreEntity;
package/src/message.ts CHANGED
@@ -1,7 +1,9 @@
1
+ import { message } from "@waku/core";
1
2
  import type {
2
3
  IDecodedMessage,
3
4
  IMessage,
4
- IRateLimitProof
5
+ IRateLimitProof,
6
+ IRlnMessage
5
7
  } from "@waku/interfaces";
6
8
  import * as utils from "@waku/utils/bytes";
7
9
 
@@ -13,12 +15,13 @@ export function toRLNSignal(contentTopic: string, msg: IMessage): Uint8Array {
13
15
  return new Uint8Array([...(msg.payload ?? []), ...contentTopicBytes]);
14
16
  }
15
17
 
16
- export class RlnMessage<T extends IDecodedMessage> implements IDecodedMessage {
18
+ export class RlnMessage<T extends IDecodedMessage> implements IRlnMessage {
17
19
  public pubsubTopic = "";
20
+ public version = message.version_0.Version;
18
21
 
19
22
  public constructor(
20
- public rlnInstance: RLNInstance,
21
- public msg: T,
23
+ private rlnInstance: RLNInstance,
24
+ private msg: T,
22
25
  public rateLimitProof: IRateLimitProof | undefined
23
26
  ) {}
24
27
 
@@ -1,19 +0,0 @@
1
- var Tags;
2
- (function (Tags) {
3
- Tags["BOOTSTRAP"] = "bootstrap";
4
- Tags["PEER_EXCHANGE"] = "peer-exchange";
5
- Tags["LOCAL"] = "local-peer-cache";
6
- })(Tags || (Tags = {}));
7
- var EPeersByDiscoveryEvents;
8
- (function (EPeersByDiscoveryEvents) {
9
- EPeersByDiscoveryEvents["PEER_DISCOVERY_BOOTSTRAP"] = "peer:discovery:bootstrap";
10
- EPeersByDiscoveryEvents["PEER_DISCOVERY_PEER_EXCHANGE"] = "peer:discovery:peer-exchange";
11
- EPeersByDiscoveryEvents["PEER_CONNECT_BOOTSTRAP"] = "peer:connected:bootstrap";
12
- EPeersByDiscoveryEvents["PEER_CONNECT_PEER_EXCHANGE"] = "peer:connected:peer-exchange";
13
- })(EPeersByDiscoveryEvents || (EPeersByDiscoveryEvents = {}));
14
- var EConnectionStateEvents;
15
- (function (EConnectionStateEvents) {
16
- EConnectionStateEvents["CONNECTION_STATUS"] = "waku:connection";
17
- })(EConnectionStateEvents || (EConnectionStateEvents = {}));
18
-
19
- export { EConnectionStateEvents, EPeersByDiscoveryEvents, Tags };
@@ -1,12 +0,0 @@
1
- var HealthStatusChangeEvents;
2
- (function (HealthStatusChangeEvents) {
3
- HealthStatusChangeEvents["StatusChange"] = "health:change";
4
- })(HealthStatusChangeEvents || (HealthStatusChangeEvents = {}));
5
- var HealthStatus;
6
- (function (HealthStatus) {
7
- HealthStatus["Unhealthy"] = "Unhealthy";
8
- HealthStatus["MinimallyHealthy"] = "MinimallyHealthy";
9
- HealthStatus["SufficientlyHealthy"] = "SufficientlyHealthy";
10
- })(HealthStatus || (HealthStatus = {}));
11
-
12
- export { HealthStatus, HealthStatusChangeEvents };
@@ -1,92 +0,0 @@
1
- var Protocols;
2
- (function (Protocols) {
3
- Protocols["Relay"] = "relay";
4
- Protocols["Store"] = "store";
5
- Protocols["LightPush"] = "lightpush";
6
- Protocols["Filter"] = "filter";
7
- })(Protocols || (Protocols = {}));
8
- var ProtocolError;
9
- (function (ProtocolError) {
10
- //
11
- // GENERAL ERRORS SECTION
12
- //
13
- /**
14
- * Could not determine the origin of the fault. Best to check connectivity and try again
15
- * */
16
- ProtocolError["GENERIC_FAIL"] = "Generic error";
17
- /**
18
- * The remote peer rejected the message. Information provided by the remote peer
19
- * is logged. Review message validity, or mitigation for `NO_PEER_AVAILABLE`
20
- * or `DECODE_FAILED` can be used.
21
- */
22
- ProtocolError["REMOTE_PEER_REJECTED"] = "Remote peer rejected";
23
- /**
24
- * Failure to protobuf decode the message. May be due to a remote peer issue,
25
- * ensuring that messages are sent via several peer enable mitigation of this error.
26
- */
27
- ProtocolError["DECODE_FAILED"] = "Failed to decode";
28
- /**
29
- * Failure to find a peer with suitable protocols. This may due to a connection issue.
30
- * Mitigation can be: retrying after a given time period, display connectivity issue
31
- * to user or listening for `peer:connected:bootstrap` or `peer:connected:peer-exchange`
32
- * on the connection manager before retrying.
33
- */
34
- ProtocolError["NO_PEER_AVAILABLE"] = "No peer available";
35
- /**
36
- * Failure to find a stream to the peer. This may be because the connection with the peer is not still alive.
37
- * Mitigation can be: retrying after a given time period, or mitigation for `NO_PEER_AVAILABLE` can be used.
38
- */
39
- ProtocolError["NO_STREAM_AVAILABLE"] = "No stream available";
40
- /**
41
- * The remote peer did not behave as expected. Mitigation for `NO_PEER_AVAILABLE`
42
- * or `DECODE_FAILED` can be used.
43
- */
44
- ProtocolError["NO_RESPONSE"] = "No response received";
45
- //
46
- // SEND ERRORS SECTION
47
- //
48
- /**
49
- * Failure to protobuf encode the message. This is not recoverable and needs
50
- * further investigation.
51
- */
52
- ProtocolError["ENCODE_FAILED"] = "Failed to encode";
53
- /**
54
- * The message payload is empty, making the message invalid. Ensure that a non-empty
55
- * payload is set on the outgoing message.
56
- */
57
- ProtocolError["EMPTY_PAYLOAD"] = "Payload is empty";
58
- /**
59
- * The message size is above the maximum message size allowed on the Waku Network.
60
- * Compressing the message or using an alternative strategy for large messages is recommended.
61
- */
62
- ProtocolError["SIZE_TOO_BIG"] = "Size is too big";
63
- /**
64
- * The PubsubTopic passed to the send function is not configured on the Waku node.
65
- * Please ensure that the PubsubTopic is used when initializing the Waku node.
66
- */
67
- ProtocolError["TOPIC_NOT_CONFIGURED"] = "Topic not configured";
68
- /**
69
- * Fails when
70
- */
71
- ProtocolError["STREAM_ABORTED"] = "Stream aborted";
72
- /**
73
- * General proof generation error message.
74
- * nwaku: https://github.com/waku-org/nwaku/blob/c3cb06ac6c03f0f382d3941ea53b330f6a8dd127/waku/waku_rln_relay/group_manager/group_manager_base.nim#L201C19-L201C42
75
- */
76
- ProtocolError["RLN_PROOF_GENERATION"] = "Proof generation failed";
77
- //
78
- // RECEIVE ERRORS SECTION
79
- //
80
- /**
81
- * The pubsub topic configured on the decoder does not match the pubsub topic setup on the protocol.
82
- * Ensure that the pubsub topic used for decoder creation is the same as the one used for protocol.
83
- */
84
- ProtocolError["TOPIC_DECODER_MISMATCH"] = "Topic decoder mismatch";
85
- /**
86
- * The topics passed in the decoders do not match each other, or don't exist at all.
87
- * Ensure that all the pubsub topics used in the decoders are valid and match each other.
88
- */
89
- ProtocolError["INVALID_DECODER_TOPICS"] = "Invalid decoder topics";
90
- })(ProtocolError || (ProtocolError = {}));
91
-
92
- export { ProtocolError, Protocols };