@waku/interfaces 0.0.11 → 0.0.13

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/CHANGELOG.md CHANGED
@@ -5,6 +5,21 @@ All notable changes to this project will be documented in this file.
5
5
  The file is maintained by [Release Please](https://github.com/googleapis/release-please) based on [Conventional Commits](https://www.conventionalcommits.org) specification,
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.0.13](https://github.com/waku-org/js-waku/compare/interfaces-v0.0.12...interfaces-v0.0.13) (2023-05-18)
9
+
10
+
11
+ ### Features
12
+
13
+ * Add 1MB restriction to LightPush and Relay ([#1351](https://github.com/waku-org/js-waku/issues/1351)) ([72f97d4](https://github.com/waku-org/js-waku/commit/72f97d4545512f92936b1a9b50fa0b53f8603f9d))
14
+ * Expose `meta` on `IDecodedMessage` ([5724bb2](https://github.com/waku-org/js-waku/commit/5724bb2b21367e4e397acbc5530b3a2bf315194e))
15
+
16
+ ## [0.0.12](https://github.com/waku-org/js-waku/compare/interfaces-v0.0.11...interfaces-v0.0.12) (2023-05-09)
17
+
18
+
19
+ ### Features
20
+
21
+ * ToSubscriptionIterator impl for IReceiver ([#1307](https://github.com/waku-org/js-waku/issues/1307)) ([7daa9d0](https://github.com/waku-org/js-waku/commit/7daa9d05bf44b33296b56df214f5d5901887a129))
22
+
8
23
  ## [0.0.11](https://github.com/waku-org/js-waku/compare/interfaces-v0.0.10...interfaces-v0.0.11) (2023-04-03)
9
24
 
10
25
 
package/dist/index.d.ts CHANGED
@@ -10,3 +10,4 @@ export * from "./waku.js";
10
10
  export * from "./connection_manager.js";
11
11
  export * from "./sender.js";
12
12
  export * from "./receiver.js";
13
+ export * from "./misc.js";
package/dist/index.js CHANGED
@@ -10,4 +10,5 @@ export * from "./waku.js";
10
10
  export * from "./connection_manager.js";
11
11
  export * from "./sender.js";
12
12
  export * from "./receiver.js";
13
+ export * from "./misc.js";
13
14
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,yBAAyB,CAAC;AACxC,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,yBAAyB,CAAC;AACxC,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC"}
package/dist/message.d.ts CHANGED
@@ -61,6 +61,7 @@ export interface IDecodedMessage {
61
61
  timestamp: Date | undefined;
62
62
  rateLimitProof: IRateLimitProof | undefined;
63
63
  ephemeral: boolean | undefined;
64
+ meta: Uint8Array | undefined;
64
65
  }
65
66
  export interface IDecoder<T extends IDecodedMessage> {
66
67
  contentTopic: string;
package/dist/misc.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ import type { IDecodedMessage } from "./message.js";
2
+ export interface IAsyncIterator<T extends IDecodedMessage> {
3
+ iterator: AsyncIterator<T>;
4
+ stop: Unsubscribe;
5
+ }
6
+ export type Unsubscribe = () => void | Promise<void>;
7
+ export type PubSubTopic = string;
8
+ export type ContentTopic = string;
package/dist/misc.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=misc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"misc.js","sourceRoot":"","sources":["../src/misc.ts"],"names":[],"mappings":""}
@@ -53,6 +53,14 @@ export type ProtocolOptions = {
53
53
  peerId?: PeerId;
54
54
  };
55
55
  export type Callback<T extends IDecodedMessage> = (msg: T) => void | Promise<void>;
56
+ export declare enum SendError {
57
+ GENERIC_FAIL = "Generic error",
58
+ ENCODE_FAILED = "Failed to encode",
59
+ DECODE_FAILED = "Failed to decode",
60
+ SIZE_TOO_BIG = "Size is too big",
61
+ NO_RPC_RESPONSE = "No RPC response"
62
+ }
56
63
  export interface SendResult {
64
+ error?: SendError;
57
65
  recipients: PeerId[];
58
66
  }
package/dist/protocols.js CHANGED
@@ -5,4 +5,12 @@ export var Protocols;
5
5
  Protocols["LightPush"] = "lightpush";
6
6
  Protocols["Filter"] = "filter";
7
7
  })(Protocols || (Protocols = {}));
8
+ export var SendError;
9
+ (function (SendError) {
10
+ SendError["GENERIC_FAIL"] = "Generic error";
11
+ SendError["ENCODE_FAILED"] = "Failed to encode";
12
+ SendError["DECODE_FAILED"] = "Failed to decode";
13
+ SendError["SIZE_TOO_BIG"] = "Size is too big";
14
+ SendError["NO_RPC_RESPONSE"] = "No RPC response";
15
+ })(SendError || (SendError = {}));
8
16
  //# sourceMappingURL=protocols.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"protocols.js","sourceRoot":"","sources":["../src/protocols.ts"],"names":[],"mappings":"AAMA,MAAM,CAAN,IAAY,SAKX;AALD,WAAY,SAAS;IACnB,4BAAe,CAAA;IACf,4BAAe,CAAA;IACf,oCAAuB,CAAA;IACvB,8BAAiB,CAAA;AACnB,CAAC,EALW,SAAS,KAAT,SAAS,QAKpB"}
1
+ {"version":3,"file":"protocols.js","sourceRoot":"","sources":["../src/protocols.ts"],"names":[],"mappings":"AAMA,MAAM,CAAN,IAAY,SAKX;AALD,WAAY,SAAS;IACnB,4BAAe,CAAA;IACf,4BAAe,CAAA;IACf,oCAAuB,CAAA;IACvB,8BAAiB,CAAA;AACnB,CAAC,EALW,SAAS,KAAT,SAAS,QAKpB;AAqDD,MAAM,CAAN,IAAY,SAMX;AAND,WAAY,SAAS;IACnB,2CAA8B,CAAA;IAC9B,+CAAkC,CAAA;IAClC,+CAAkC,CAAA;IAClC,6CAAgC,CAAA;IAChC,gDAAmC,CAAA;AACrC,CAAC,EANW,SAAS,KAAT,SAAS,QAMpB"}
@@ -1,11 +1,9 @@
1
1
  import type { IDecodedMessage, IDecoder } from "./message.js";
2
+ import type { ContentTopic, IAsyncIterator, PubSubTopic, Unsubscribe } from "./misc.js";
2
3
  import type { Callback, ProtocolOptions } from "./protocols.js";
3
- type Unsubscribe = () => void | Promise<void>;
4
- type PubSubTopic = string;
5
- type ContentTopic = string;
6
4
  export type ActiveSubscriptions = Map<PubSubTopic, ContentTopic[]>;
7
5
  export interface IReceiver {
6
+ toSubscriptionIterator: <T extends IDecodedMessage>(decoders: IDecoder<T> | IDecoder<T>[], opts?: ProtocolOptions) => Promise<IAsyncIterator<T>>;
8
7
  subscribe: <T extends IDecodedMessage>(decoders: IDecoder<T> | IDecoder<T>[], callback: Callback<T>, opts?: ProtocolOptions) => Unsubscribe | Promise<Unsubscribe>;
9
8
  getActiveSubscriptions: () => ActiveSubscriptions;
10
9
  }
11
- export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@waku/interfaces",
3
- "version": "0.0.11",
3
+ "version": "0.0.13",
4
4
  "description": "Definition of Waku interfaces",
5
5
  "types": "./dist/index.d.ts",
6
6
  "module": "./dist/index.js",
@@ -35,11 +35,9 @@
35
35
  "build": "run-s build:**",
36
36
  "build:esm": "tsc",
37
37
  "fix": "run-s fix:*",
38
- "fix:prettier": "prettier . --write",
39
38
  "fix:lint": "eslint src --fix",
40
39
  "check": "run-s check:*",
41
40
  "check:lint": "eslint src",
42
- "check:prettier": "prettier . --list-different",
43
41
  "check:spelling": "cspell \"{README.md,src/**/*.ts}\"",
44
42
  "check:tsc": "tsc -p tsconfig.dev.json",
45
43
  "prepublish": "npm run build",
@@ -68,8 +66,8 @@
68
66
  "eslint-plugin-import": "^2.27.5",
69
67
  "eslint-plugin-prettier": "^4.2.1",
70
68
  "npm-run-all": "^4.1.5",
71
- "prettier": "^2.8.4",
72
- "typescript": "^4.9.5"
69
+ "prettier": "^2.8.8",
70
+ "typescript": "^5.0.4"
73
71
  },
74
72
  "typedoc": {
75
73
  "entryPoint": "./src/index.ts"
package/src/index.ts CHANGED
@@ -10,3 +10,4 @@ export * from "./waku.js";
10
10
  export * from "./connection_manager.js";
11
11
  export * from "./sender.js";
12
12
  export * from "./receiver.js";
13
+ export * from "./misc.js";
package/src/message.ts CHANGED
@@ -65,6 +65,7 @@ export interface IDecodedMessage {
65
65
  timestamp: Date | undefined;
66
66
  rateLimitProof: IRateLimitProof | undefined;
67
67
  ephemeral: boolean | undefined;
68
+ meta: Uint8Array | undefined;
68
69
  }
69
70
 
70
71
  export interface IDecoder<T extends IDecodedMessage> {
package/src/misc.ts ADDED
@@ -0,0 +1,11 @@
1
+ import type { IDecodedMessage } from "./message.js";
2
+
3
+ export interface IAsyncIterator<T extends IDecodedMessage> {
4
+ iterator: AsyncIterator<T>;
5
+ stop: Unsubscribe;
6
+ }
7
+
8
+ export type Unsubscribe = () => void | Promise<void>;
9
+
10
+ export type PubSubTopic = string;
11
+ export type ContentTopic = string;
package/src/protocols.ts CHANGED
@@ -62,6 +62,15 @@ export type Callback<T extends IDecodedMessage> = (
62
62
  msg: T
63
63
  ) => void | Promise<void>;
64
64
 
65
+ export enum SendError {
66
+ GENERIC_FAIL = "Generic error",
67
+ ENCODE_FAILED = "Failed to encode",
68
+ DECODE_FAILED = "Failed to decode",
69
+ SIZE_TOO_BIG = "Size is too big",
70
+ NO_RPC_RESPONSE = "No RPC response",
71
+ }
72
+
65
73
  export interface SendResult {
74
+ error?: SendError;
66
75
  recipients: PeerId[];
67
76
  }
package/src/receiver.ts CHANGED
@@ -1,13 +1,19 @@
1
1
  import type { IDecodedMessage, IDecoder } from "./message.js";
2
+ import type {
3
+ ContentTopic,
4
+ IAsyncIterator,
5
+ PubSubTopic,
6
+ Unsubscribe,
7
+ } from "./misc.js";
2
8
  import type { Callback, ProtocolOptions } from "./protocols.js";
3
9
 
4
- type Unsubscribe = () => void | Promise<void>;
5
- type PubSubTopic = string;
6
- type ContentTopic = string;
7
-
8
10
  export type ActiveSubscriptions = Map<PubSubTopic, ContentTopic[]>;
9
11
 
10
12
  export interface IReceiver {
13
+ toSubscriptionIterator: <T extends IDecodedMessage>(
14
+ decoders: IDecoder<T> | IDecoder<T>[],
15
+ opts?: ProtocolOptions
16
+ ) => Promise<IAsyncIterator<T>>;
11
17
  subscribe: <T extends IDecodedMessage>(
12
18
  decoders: IDecoder<T> | IDecoder<T>[],
13
19
  callback: Callback<T>,