@simplito/privmx-webendpoint 2.5.1 → 2.6.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 (73) hide show
  1. package/Types.d.ts +98 -2
  2. package/Types.js +102 -15
  3. package/api/ConnectionNative.d.ts +18 -2
  4. package/api/ConnectionNative.js +26 -7
  5. package/api/EventApiNative.d.ts +4 -3
  6. package/api/EventApiNative.js +7 -4
  7. package/api/InboxApiNative.d.ts +4 -5
  8. package/api/InboxApiNative.js +6 -9
  9. package/api/KvdbApiNative.d.ts +5 -5
  10. package/api/KvdbApiNative.js +8 -8
  11. package/api/StoreApiNative.d.ts +6 -7
  12. package/api/StoreApiNative.js +6 -9
  13. package/api/ThreadApiNative.d.ts +4 -5
  14. package/api/ThreadApiNative.js +6 -9
  15. package/assets/driver-web-context.js +1 -1
  16. package/assets/e2ee-worker.js +1 -0
  17. package/assets/endpoint-wasm-module.js +2 -19
  18. package/assets/endpoint-wasm-module.wasm +0 -0
  19. package/assets/privmx-endpoint-web.js +2 -0
  20. package/bundle/privmx-endpoint-web.js +1 -1
  21. package/extra/PrivmxClient.d.ts +9 -2
  22. package/extra/PrivmxClient.js +15 -1
  23. package/extra/__mocks__/constants.d.ts +63 -0
  24. package/extra/__mocks__/constants.js +51 -0
  25. package/extra/__mocks__/mockContainerSubscriber.d.ts +8 -0
  26. package/extra/__mocks__/mockContainerSubscriber.js +26 -0
  27. package/extra/{__tests__/__mocks__ → __mocks__}/mockEventQueue.d.ts +1 -3
  28. package/extra/{__tests__/__mocks__ → __mocks__}/mockEventQueue.js +6 -8
  29. package/extra/{__tests__/__mocks__ → __mocks__}/utils.d.ts +1 -1
  30. package/extra/{__tests__/__mocks__ → __mocks__}/utils.js +4 -5
  31. package/extra/__tests__/eventsManager.test.js +38 -27
  32. package/extra/__tests__/inboxEventManager.js +79 -0
  33. package/extra/__tests__/storeEventManager.test.js +48 -28
  34. package/extra/__tests__/threadEventManager.test.js +49 -29
  35. package/extra/events.d.ts +4 -217
  36. package/extra/events.js +25 -213
  37. package/extra/files.d.ts +2 -2
  38. package/extra/files.js +2 -2
  39. package/extra/inbox.js +1 -2
  40. package/extra/index.d.ts +3 -3
  41. package/extra/index.js +9 -10
  42. package/extra/managers.d.ts +98 -0
  43. package/extra/managers.js +157 -0
  44. package/extra/subscriptions.d.ts +165 -0
  45. package/extra/subscriptions.js +51 -0
  46. package/extra/utils.js +4 -5
  47. package/index.d.ts +2 -2
  48. package/index.js +2 -1
  49. package/package.json +12 -13
  50. package/service/Connection.d.ts +21 -2
  51. package/service/Connection.js +27 -2
  52. package/service/CryptoApi.d.ts +1 -1
  53. package/service/CryptoApi.js +1 -1
  54. package/service/EventApi.d.ts +14 -9
  55. package/service/EventApi.js +35 -10
  56. package/service/InboxApi.d.ts +14 -13
  57. package/service/InboxApi.js +42 -17
  58. package/service/KvdbApi.d.ts +33 -25
  59. package/service/KvdbApi.js +65 -31
  60. package/service/StoreApi.d.ts +18 -15
  61. package/service/StoreApi.js +48 -20
  62. package/service/ThreadApi.d.ts +14 -13
  63. package/service/ThreadApi.js +44 -19
  64. package/service/index.d.ts +2 -1
  65. package/service/index.js +3 -1
  66. package/extra/__tests__/__mocks__/constants.d.ts +0 -36
  67. package/extra/__tests__/__mocks__/constants.js +0 -42
  68. package/extra/__tests__/__mocks__/mockContainerSubscriber.d.ts +0 -12
  69. package/extra/__tests__/__mocks__/mockContainerSubscriber.js +0 -25
  70. package/extra/__tests__/__mocks__/mockEventAPIs.d.ts +0 -30
  71. package/extra/__tests__/__mocks__/mockEventAPIs.js +0 -70
  72. package/extra/__tests__/inboxEventManager.test.js +0 -56
  73. /package/extra/__tests__/{inboxEventManager.test.d.ts → inboxEventManager.d.ts} +0 -0
@@ -0,0 +1,165 @@
1
+ import { Types } from "..";
2
+ import { ThreadEventSelectorType, ThreadEventType } from "../Types";
3
+ import { GenericEvent } from "./managers";
4
+ export type ThreadCallbackPayload = {
5
+ [Types.ThreadEventType.THREAD_CREATE]: Types.Thread;
6
+ [Types.ThreadEventType.THREAD_UPDATE]: Types.Thread;
7
+ [Types.ThreadEventType.THREAD_DELETE]: {
8
+ threadId: string;
9
+ };
10
+ [Types.ThreadEventType.THREAD_STATS]: {
11
+ lastMsgDate: number;
12
+ messagesCount: number;
13
+ threadId: string;
14
+ };
15
+ [Types.ThreadEventType.MESSAGE_CREATE]: Types.Message;
16
+ [Types.ThreadEventType.MESSAGE_UPDATE]: Types.Message;
17
+ [Types.ThreadEventType.MESSAGE_DELETE]: {
18
+ threadId: string;
19
+ messageId: string;
20
+ };
21
+ [Types.ThreadEventType.COLLECTION_CHANGE]: Types.CollectionChangedEventData;
22
+ };
23
+ export type StoreCallbackPayload = {
24
+ [Types.StoreEventType.STORE_CREATE]: Types.Store;
25
+ [Types.StoreEventType.STORE_UPDATE]: Types.Store;
26
+ [Types.StoreEventType.STORE_DELETE]: {
27
+ storeId: string;
28
+ };
29
+ [Types.StoreEventType.STORE_STATS]: {
30
+ contextId: string;
31
+ storeId: string;
32
+ lastFileDate: number;
33
+ filesCount: number;
34
+ };
35
+ [Types.StoreEventType.FILE_CREATE]: Types.File;
36
+ [Types.StoreEventType.FILE_UPDATE]: Types.File;
37
+ [Types.StoreEventType.FILE_DELETE]: {
38
+ contextId: string;
39
+ storeId: string;
40
+ fileId: string;
41
+ };
42
+ [Types.StoreEventType.COLLECTION_CHANGE]: Types.CollectionChangedEventData;
43
+ };
44
+ export type InboxCallbackPayload = {
45
+ [Types.InboxEventType.INBOX_CREATE]: Types.Inbox;
46
+ [Types.InboxEventType.INBOX_UPDATE]: Types.Inbox;
47
+ [Types.InboxEventType.INBOX_DELETE]: {
48
+ inboxId: string;
49
+ };
50
+ [Types.InboxEventType.ENTRY_CREATE]: Types.InboxEntry;
51
+ [Types.InboxEventType.ENTRY_DELETE]: {
52
+ contextId: string;
53
+ inboxId: string;
54
+ entryId: string;
55
+ };
56
+ [Types.InboxEventType.COLLECTION_CHANGE]: Types.CollectionChangedEventData;
57
+ };
58
+ export type KvdbCallbackPayload = {
59
+ [Types.KvdbEventType.KVDB_STATS]: {
60
+ lastEntryDate: number;
61
+ entryCount: number;
62
+ kvdbId: string;
63
+ };
64
+ [Types.KvdbEventType.KVDB_CREATE]: Types.Kvdb;
65
+ [Types.KvdbEventType.KVDB_UPDATE]: Types.Kvdb;
66
+ [Types.KvdbEventType.KVDB_DELETE]: {
67
+ kvdbId: string;
68
+ };
69
+ [Types.KvdbEventType.ENTRY_UPDATE]: Types.KvdbEntry;
70
+ [Types.KvdbEventType.ENTRY_CREATE]: Types.KvdbEntry;
71
+ [Types.KvdbEventType.ENTRY_DELETE]: {
72
+ contextId: string;
73
+ kvdbId: string;
74
+ entryId: string;
75
+ };
76
+ [Types.KvdbEventType.COLLECTION_CHANGE]: Types.CollectionChangedEventData;
77
+ };
78
+ export type EventCallback = {
79
+ callback: (e: Types.Event) => void;
80
+ symbol: Symbol;
81
+ };
82
+ export interface Subscription<T, S> {
83
+ type: T;
84
+ selector: S;
85
+ id: string;
86
+ callbacks: EventCallback[];
87
+ }
88
+ export declare function createThreadSubscription<T extends Types.ThreadEventType, S extends Types.ThreadEventSelectorType>(s: {
89
+ type: T;
90
+ selector: S;
91
+ id: string;
92
+ callbacks: ((arg: GenericEvent<ThreadCallbackPayload[T]>) => void)[];
93
+ }): {
94
+ callbacks: EventCallback[];
95
+ type: T;
96
+ selector: S;
97
+ id: string;
98
+ };
99
+ export declare function createStoreSubscription<T extends Types.StoreEventType, S extends Types.StoreEventSelectorType>(s: {
100
+ type: T;
101
+ selector: S;
102
+ id: string;
103
+ callbacks: ((arg: GenericEvent<StoreCallbackPayload[T]>) => void)[];
104
+ }): {
105
+ callbacks: EventCallback[];
106
+ type: T;
107
+ selector: S;
108
+ id: string;
109
+ };
110
+ export declare function createKvdbSubscription<T extends Types.KvdbEventType, S extends Types.KvdbEventSelectorType>(s: {
111
+ type: T;
112
+ selector: S;
113
+ id: string;
114
+ callbacks: ((arg: GenericEvent<KvdbCallbackPayload[T]>) => void)[];
115
+ }): {
116
+ callbacks: EventCallback[];
117
+ type: T;
118
+ selector: S;
119
+ id: string;
120
+ };
121
+ export declare function createInboxSubscription<T extends Types.InboxEventType, S extends Types.InboxEventSelectorType>(s: {
122
+ type: T;
123
+ selector: S;
124
+ id: string;
125
+ callbacks: ((arg: GenericEvent<InboxCallbackPayload[T]>) => void)[];
126
+ }): {
127
+ callbacks: EventCallback[];
128
+ type: T;
129
+ selector: S;
130
+ id: string;
131
+ };
132
+ export declare enum ConnectionEventType {
133
+ LIB_DISCONNECTED = 0,
134
+ LIB_PLATFORM_DISCONNECTED = 1,
135
+ LIB_CONNECTED = 2
136
+ }
137
+ export declare function createConnectionSubscription(s: {
138
+ type: ConnectionEventType;
139
+ callbacks: ((arg: GenericEvent<undefined>) => void)[];
140
+ }): {
141
+ callbacks: EventCallback[];
142
+ type: ConnectionEventType;
143
+ };
144
+ export interface EventSubscriber<E, S> {
145
+ /**
146
+ * Subscribe for the Thread events on the given subscription query.
147
+ * @param {string[]} subscriptionQueries list of queries
148
+ */
149
+ subscribeFor(subscriptionQueries: string[]): Promise<string[]>;
150
+ /**
151
+ * Unsubscribes from events for the given subscriptionId.
152
+ */
153
+ unsubscribeFrom(subscriptionIds: string[]): Promise<void>;
154
+ /**
155
+ * Generate subscription Query for the Thread events.
156
+ * @param {EventType} eventType type of event which you listen for
157
+ * @param {EventSelectorType} selectorType scope on which you listen for events
158
+ * @param {string} selectorId ID of the selector
159
+ */
160
+ buildSubscriptionQuery(eventType: E, selectorType: S, selectorId: string): Promise<string>;
161
+ }
162
+ export type SubscriberForThreadsEvents = EventSubscriber<ThreadEventType, ThreadEventSelectorType>;
163
+ export type SubscriberForStoreEvents = EventSubscriber<Types.StoreEventType, Types.StoreEventSelectorType>;
164
+ export type SubscriberForInboxEvents = EventSubscriber<Types.InboxEventType, Types.InboxEventSelectorType>;
165
+ export type SubscriberForKvdbEvents = EventSubscriber<Types.KvdbEventType, Types.KvdbEventSelectorType>;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ConnectionEventType = void 0;
4
+ exports.createThreadSubscription = createThreadSubscription;
5
+ exports.createStoreSubscription = createStoreSubscription;
6
+ exports.createKvdbSubscription = createKvdbSubscription;
7
+ exports.createInboxSubscription = createInboxSubscription;
8
+ exports.createConnectionSubscription = createConnectionSubscription;
9
+ const __1 = require("..");
10
+ function toEventCallback(f) {
11
+ return {
12
+ callback: f,
13
+ symbol: Symbol()
14
+ };
15
+ }
16
+ function createThreadSubscription(s) {
17
+ return {
18
+ ...s,
19
+ callbacks: s.callbacks.map(toEventCallback)
20
+ };
21
+ }
22
+ function createStoreSubscription(s) {
23
+ return {
24
+ ...s,
25
+ callbacks: s.callbacks.map(toEventCallback)
26
+ };
27
+ }
28
+ function createKvdbSubscription(s) {
29
+ return {
30
+ ...s,
31
+ callbacks: s.callbacks.map(toEventCallback)
32
+ };
33
+ }
34
+ function createInboxSubscription(s) {
35
+ return {
36
+ ...s,
37
+ callbacks: s.callbacks.map(toEventCallback)
38
+ };
39
+ }
40
+ var ConnectionEventType;
41
+ (function (ConnectionEventType) {
42
+ ConnectionEventType[ConnectionEventType["LIB_DISCONNECTED"] = 0] = "LIB_DISCONNECTED";
43
+ ConnectionEventType[ConnectionEventType["LIB_PLATFORM_DISCONNECTED"] = 1] = "LIB_PLATFORM_DISCONNECTED";
44
+ ConnectionEventType[ConnectionEventType["LIB_CONNECTED"] = 2] = "LIB_CONNECTED";
45
+ })(ConnectionEventType || (exports.ConnectionEventType = ConnectionEventType = {}));
46
+ function createConnectionSubscription(s) {
47
+ return {
48
+ ...s,
49
+ callbacks: s.callbacks.map(toEventCallback)
50
+ };
51
+ }
package/extra/utils.js CHANGED
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.strToUint8 = exports.uint8ToStr = exports.deserializeObject = exports.serializeObject = void 0;
3
+ exports.serializeObject = serializeObject;
4
+ exports.deserializeObject = deserializeObject;
5
+ exports.uint8ToStr = uint8ToStr;
6
+ exports.strToUint8 = strToUint8;
4
7
  /**
5
8
  * Helper function to convert objects to Uint8Array
6
9
  * @param {Record<string, any>} object - The object to serialize
@@ -14,7 +17,6 @@ function serializeObject(object) {
14
17
  const parsed = JSON.stringify(object);
15
18
  return encoder.encode(parsed);
16
19
  }
17
- exports.serializeObject = serializeObject;
18
20
  /**
19
21
  * Helper function to convert Uint8Array to objects
20
22
  * @param {Uint8Array} data - The data to deserialize
@@ -41,7 +43,6 @@ function deserializeObject(data) {
41
43
  }
42
44
  }
43
45
  }
44
- exports.deserializeObject = deserializeObject;
45
46
  /**
46
47
  * Convert Uint8Array to a string
47
48
  * @param {Uint8Array} arr - The array to convert
@@ -53,7 +54,6 @@ function uint8ToStr(arr) {
53
54
  }
54
55
  return new TextDecoder().decode(arr);
55
56
  }
56
- exports.uint8ToStr = uint8ToStr;
57
57
  /**
58
58
  * Convert a string to Uint8Array
59
59
  * @param {string} text - The text to convert
@@ -65,4 +65,3 @@ function strToUint8(text) {
65
65
  }
66
66
  return new TextEncoder().encode(text);
67
67
  }
68
- exports.strToUint8 = strToUint8;
package/index.d.ts CHANGED
@@ -9,6 +9,6 @@ See the License for the specific language governing permissions and
9
9
  limitations under the License.
10
10
  */
11
11
  import { EndpointFactory } from "./service/EndpointFactory";
12
- import { EventQueue, StoreApi, ThreadApi, InboxApi, KvdbApi, Connection, CryptoApi, BaseApi, ExtKey } from "./service";
12
+ import { EventQueue, StoreApi, ThreadApi, InboxApi, KvdbApi, Connection, CryptoApi, BaseApi, ExtKey, EventApi } from "./service";
13
13
  import * as Types from "./Types";
14
- export { EndpointFactory as Endpoint, Types, EventQueue, StoreApi, ThreadApi, InboxApi, KvdbApi, CryptoApi, Connection, BaseApi, ExtKey };
14
+ export { EndpointFactory as Endpoint, Types, EventQueue, StoreApi, ThreadApi, InboxApi, KvdbApi, CryptoApi, Connection, BaseApi, ExtKey, EventApi };
package/index.js CHANGED
@@ -10,7 +10,7 @@ See the License for the specific language governing permissions and
10
10
  limitations under the License.
11
11
  */
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.ExtKey = exports.BaseApi = exports.Connection = exports.CryptoApi = exports.KvdbApi = exports.InboxApi = exports.ThreadApi = exports.StoreApi = exports.EventQueue = exports.Types = exports.Endpoint = void 0;
13
+ exports.EventApi = exports.ExtKey = exports.BaseApi = exports.Connection = exports.CryptoApi = exports.KvdbApi = exports.InboxApi = exports.ThreadApi = exports.StoreApi = exports.EventQueue = exports.Types = exports.Endpoint = void 0;
14
14
  const EndpointFactory_1 = require("./service/EndpointFactory");
15
15
  Object.defineProperty(exports, "Endpoint", { enumerable: true, get: function () { return EndpointFactory_1.EndpointFactory; } });
16
16
  const service_1 = require("./service");
@@ -23,5 +23,6 @@ Object.defineProperty(exports, "Connection", { enumerable: true, get: function (
23
23
  Object.defineProperty(exports, "CryptoApi", { enumerable: true, get: function () { return service_1.CryptoApi; } });
24
24
  Object.defineProperty(exports, "BaseApi", { enumerable: true, get: function () { return service_1.BaseApi; } });
25
25
  Object.defineProperty(exports, "ExtKey", { enumerable: true, get: function () { return service_1.ExtKey; } });
26
+ Object.defineProperty(exports, "EventApi", { enumerable: true, get: function () { return service_1.EventApi; } });
26
27
  const Types = require("./Types");
27
28
  exports.Types = Types;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simplito/privmx-webendpoint",
3
- "version": "2.5.1",
3
+ "version": "2.6.0",
4
4
  "description": "PrivMX Web Endpoint library",
5
5
  "author": "Simplito",
6
6
  "license": "PrivMX Free License",
@@ -37,7 +37,7 @@
37
37
  "./extra": "./extra/index.js"
38
38
  },
39
39
  "scripts": {
40
- "test": "echo \"Error: no test specified\" && exit 1",
40
+ "test": "jest",
41
41
  "compile": "tsc",
42
42
  "build": "npm run clean && npm run build:bundle && npm run build:mjs && npm run build:fixup",
43
43
  "clean": "rm -rf ./dist",
@@ -50,31 +50,30 @@
50
50
  "node": ">=4"
51
51
  },
52
52
  "devDependencies": {
53
+ "@babel/core": "^7.26.0",
54
+ "@babel/preset-env": "^7.26.0",
55
+ "@types/jest": "^29.5.14",
53
56
  "@types/node": "^20.9.0",
54
57
  "@types/webpack": "^5.28.5",
55
58
  "assert": "^2.1.0",
59
+ "babel-jest": "^29.7.0",
56
60
  "buffer": "^6.0.3",
57
61
  "crypto-browserify": "^3.12.0",
62
+ "jest": "^29.7.0",
63
+ "prettier": "^3.4.2",
58
64
  "process": "^0.11.10",
59
65
  "stream-browserify": "^3.0.0",
66
+ "ts-jest": "^29.2.5",
60
67
  "ts-loader": "^9.5.1",
61
68
  "ts-node": "^10.9.1",
62
69
  "tslib": "^2.6.2",
63
- "typescript": "^5.2.2",
70
+ "typescript": "5.8",
64
71
  "vm-browserify": "^1.1.2",
65
72
  "webpack": "^5.89.0",
66
73
  "webpack-cli": "^5.1.4",
67
- "webpack-dev-server": "^4.15.1",
68
- "@babel/core": "^7.26.0",
69
- "@babel/preset-env": "^7.26.0",
70
- "@types/jest": "^29.5.14",
71
- "babel-jest": "^29.7.0",
72
- "jest": "^29.7.0",
73
- "prettier": "^3.4.2",
74
- "ts-jest": "^29.2.5"
74
+ "webpack-dev-server": "^4.15.1"
75
75
  },
76
76
  "dependencies": {
77
- "elliptic": "^6.6.1"
77
+ "elliptic": "^6.6.1"
78
78
  }
79
79
  }
80
-
@@ -10,7 +10,7 @@ limitations under the License.
10
10
  */
11
11
  import { BaseApi } from "./BaseApi";
12
12
  import { ConnectionNative } from "../api/ConnectionNative";
13
- import { PagingQuery, PagingList, Context, UserInfo } from "../Types";
13
+ import { PagingQuery, PagingList, Context, UserInfo, ConnectionEventType, ConnectionEventSelectorType } from "../Types";
14
14
  import { BaseNative } from "../api/BaseNative";
15
15
  import { UserVerifierInterface } from "./UserVerifierInterface";
16
16
  export declare class Connection extends BaseApi {
@@ -50,7 +50,26 @@ export declare class Connection extends BaseApi {
50
50
  *
51
51
  * @returns a list of the UserInfo objects
52
52
  */
53
- getContextUsers(contextId: string): Promise<UserInfo[]>;
53
+ listContextUsers(contextId: string, pagingQuery: PagingQuery): Promise<PagingList<UserInfo>>;
54
+ /**
55
+ * Subscribe for the Context events on the given subscription query.
56
+ *
57
+ * @param {string[]} subscriptionQueries list of queries
58
+ * @return list of subscriptionIds in matching order to subscriptionQueries
59
+ */
60
+ subscribeFor(subscriptionQueries: string[]): Promise<string[]>;
61
+ /**
62
+ * Unsubscribe from events for the given subscriptionId.
63
+ * @param {string[]} subscriptionIds list of subscriptionId
64
+ */
65
+ unsubscribeFrom(subscriptionIds: string[]): Promise<void>;
66
+ /**
67
+ * Generate subscription Query for the Context events.
68
+ * @param {EventType} eventType type of event which you listen for
69
+ * @param {EventSelectorType} selectorType scope on which you listen for events
70
+ * @param {string} selectorId ID of the selector
71
+ */
72
+ buildSubscriptionQuery(eventType: ConnectionEventType, selectorType: ConnectionEventSelectorType, selectorId: string): Promise<string>;
54
73
  /**
55
74
  * Disconnects from the Platform backend.
56
75
  *
@@ -50,8 +50,33 @@ class Connection extends BaseApi_1.BaseApi {
50
50
  *
51
51
  * @returns a list of the UserInfo objects
52
52
  */
53
- async getContextUsers(contextId) {
54
- return this.native.getContextUsers(this.servicePtr, [contextId]);
53
+ async listContextUsers(contextId, pagingQuery) {
54
+ return this.native.listContextUsers(this.servicePtr, [contextId, pagingQuery]);
55
+ }
56
+ /**
57
+ * Subscribe for the Context events on the given subscription query.
58
+ *
59
+ * @param {string[]} subscriptionQueries list of queries
60
+ * @return list of subscriptionIds in matching order to subscriptionQueries
61
+ */
62
+ async subscribeFor(subscriptionQueries) {
63
+ return this.native.subscribeFor(this.servicePtr, [subscriptionQueries]);
64
+ }
65
+ /**
66
+ * Unsubscribe from events for the given subscriptionId.
67
+ * @param {string[]} subscriptionIds list of subscriptionId
68
+ */
69
+ async unsubscribeFrom(subscriptionIds) {
70
+ return this.native.unsubscribeFrom(this.servicePtr, [subscriptionIds]);
71
+ }
72
+ /**
73
+ * Generate subscription Query for the Context events.
74
+ * @param {EventType} eventType type of event which you listen for
75
+ * @param {EventSelectorType} selectorType scope on which you listen for events
76
+ * @param {string} selectorId ID of the selector
77
+ */
78
+ async buildSubscriptionQuery(eventType, selectorType, selectorId) {
79
+ return this.native.buildSubscriptionQuery(this.servicePtr, [eventType, selectorType, selectorId]);
55
80
  }
56
81
  /**
57
82
  * Disconnects from the Platform backend.
@@ -101,7 +101,7 @@ export declare class CryptoApi extends BaseApi {
101
101
  /**
102
102
  * Generates ECC key using BIP-39 mnemonic.
103
103
  *
104
- * @param {string} mnemonic the BIP-39 entropy used to generate the Key
104
+ * @param {string} mnemonic the BIP-39 mnemonic used to generate the Key
105
105
  * @param {string} password the password used to generate the Key
106
106
  * @return BIP39_t object containing ECC Key and associated with it BIP-39 mnemonic and entropy
107
107
  */
@@ -133,7 +133,7 @@ class CryptoApi extends BaseApi_1.BaseApi {
133
133
  /**
134
134
  * Generates ECC key using BIP-39 mnemonic.
135
135
  *
136
- * @param {string} mnemonic the BIP-39 entropy used to generate the Key
136
+ * @param {string} mnemonic the BIP-39 mnemonic used to generate the Key
137
137
  * @param {string} password the password used to generate the Key
138
138
  * @return BIP39_t object containing ECC Key and associated with it BIP-39 mnemonic and entropy
139
139
  */
@@ -10,7 +10,7 @@ limitations under the License.
10
10
  */
11
11
  import { BaseApi } from "./BaseApi";
12
12
  import { EventApiNative } from "../api/EventApiNative";
13
- import { UserWithPubKey } from "../Types";
13
+ import { EventsEventSelectorType, UserWithPubKey } from "../Types";
14
14
  export declare class EventApi extends BaseApi {
15
15
  private native;
16
16
  constructor(native: EventApiNative, ptr: number);
@@ -24,17 +24,22 @@ export declare class EventApi extends BaseApi {
24
24
  */
25
25
  emitEvent(contextId: string, channelName: string, eventData: Uint8Array, users: UserWithPubKey[]): Promise<void>;
26
26
  /**
27
- * Subscribe for the custom events on the given channel.
27
+ * Subscribe for the custom events on the given subscription query.
28
28
  *
29
- * @param {string} contextId ID of the Context
30
- * @param {string} channelName name of the Channel
29
+ * @param {string[]} subscriptionQueries list of queries
30
+ * @return list of subscriptionIds in maching order to subscriptionQueries
31
31
  */
32
- subscribeForCustomEvents(contextId: string, channelName: string): Promise<void>;
32
+ subscribeFor(subscriptionQueries: string[]): Promise<string[]>;
33
33
  /**
34
- * Unsubscribe from the custom events on the given channel.
35
- *
36
- * @param {string} contextId ID of the Context
34
+ * Unsubscribe from events for the given subscriptionId.
35
+ * @param {string[]} subscriptionIds list of subscriptionId
36
+ */
37
+ unsubscribeFrom(subscriptionIds: string[]): Promise<void>;
38
+ /**
39
+ * Generate subscription Query for the custom events.
37
40
  * @param {string} channelName name of the Channel
41
+ * @param {EventSelectorType} selectorType scope on which you listen for events
42
+ * @param {string} selectorId ID of the selector
38
43
  */
39
- unsubscribeFromCustomEvents(contextId: string, channelName: string): Promise<void>;
44
+ buildSubscriptionQuery(channelName: string, selectorType: EventsEventSelectorType, selectorId: string): Promise<string>;
40
45
  }
@@ -38,23 +38,48 @@ class EventApi extends BaseApi_1.BaseApi {
38
38
  async emitEvent(contextId, channelName, eventData, users) {
39
39
  return this.native.emitEvent(this.servicePtr, [contextId, channelName, eventData, users]);
40
40
  }
41
+ // /**
42
+ // * Subscribe for the custom events on the given channel.
43
+ // *
44
+ // * @param {string} contextId ID of the Context
45
+ // * @param {string} channelName name of the Channel
46
+ // */
47
+ // async subscribeForCustomEvents(contextId: string, channelName: string) {
48
+ // return this.native.subscribeForCustomEvents(this.servicePtr, [contextId, channelName]);
49
+ // }
50
+ // /**
51
+ // * Unsubscribe from the custom events on the given channel.
52
+ // *
53
+ // * @param {string} contextId ID of the Context
54
+ // * @param {string} channelName name of the Channel
55
+ // */
56
+ // async unsubscribeFromCustomEvents(contextId: string, channelName: string) {
57
+ // return this.native.unsubscribeFromCustomEvents(this.servicePtr, [contextId, channelName]);
58
+ // }
41
59
  /**
42
- * Subscribe for the custom events on the given channel.
60
+ * Subscribe for the custom events on the given subscription query.
43
61
  *
44
- * @param {string} contextId ID of the Context
45
- * @param {string} channelName name of the Channel
62
+ * @param {string[]} subscriptionQueries list of queries
63
+ * @return list of subscriptionIds in maching order to subscriptionQueries
46
64
  */
47
- async subscribeForCustomEvents(contextId, channelName) {
48
- return this.native.subscribeForCustomEvents(this.servicePtr, [contextId, channelName]);
65
+ async subscribeFor(subscriptionQueries) {
66
+ return this.native.subscribeFor(this.servicePtr, [subscriptionQueries]);
49
67
  }
50
68
  /**
51
- * Unsubscribe from the custom events on the given channel.
52
- *
53
- * @param {string} contextId ID of the Context
69
+ * Unsubscribe from events for the given subscriptionId.
70
+ * @param {string[]} subscriptionIds list of subscriptionId
71
+ */
72
+ async unsubscribeFrom(subscriptionIds) {
73
+ return this.native.unsubscribeFrom(this.servicePtr, [subscriptionIds]);
74
+ }
75
+ /**
76
+ * Generate subscription Query for the custom events.
54
77
  * @param {string} channelName name of the Channel
78
+ * @param {EventSelectorType} selectorType scope on which you listen for events
79
+ * @param {string} selectorId ID of the selector
55
80
  */
56
- async unsubscribeFromCustomEvents(contextId, channelName) {
57
- return this.native.unsubscribeFromCustomEvents(this.servicePtr, [contextId, channelName]);
81
+ async buildSubscriptionQuery(channelName, selectorType, selectorId) {
82
+ return this.native.buildSubscriptionQuery(this.servicePtr, [channelName, selectorType, selectorId]);
58
83
  }
59
84
  }
60
85
  exports.EventApi = EventApi;
@@ -10,7 +10,7 @@ limitations under the License.
10
10
  */
11
11
  import { BaseApi } from "./BaseApi";
12
12
  import { InboxApiNative } from "../api/InboxApiNative";
13
- import { PagingQuery, PagingList, UserWithPubKey, Inbox, InboxPublicView, InboxEntry, FilesConfig, ContainerWithoutItemPolicy } from "../Types";
13
+ import { PagingQuery, PagingList, UserWithPubKey, Inbox, InboxPublicView, InboxEntry, FilesConfig, ContainerWithoutItemPolicy, InboxEventType, InboxEventSelectorType } from "../Types";
14
14
  export declare class InboxApi extends BaseApi {
15
15
  private native;
16
16
  constructor(native: InboxApiNative, ptr: number);
@@ -163,21 +163,22 @@ export declare class InboxApi extends BaseApi {
163
163
  */
164
164
  closeFile(fileHandle: number): Promise<string>;
165
165
  /**
166
- * Subscribes for the Inbox module main events.
167
- */
168
- subscribeForInboxEvents(): Promise<void>;
169
- /**
170
- * Unsubscribes from the Inbox module main events.
166
+ * Subscribe for the Inbox events on the given subscription query.
167
+ *
168
+ * @param {string[]} subscriptionQueries list of queries
169
+ * @return list of subscriptionIds in maching order to subscriptionQueries
171
170
  */
172
- unsubscribeFromInboxEvents(): Promise<void>;
171
+ subscribeFor(subscriptionQueries: string[]): Promise<string[]>;
173
172
  /**
174
- * Subscribes for events in given Inbox.
175
- * @param {string} inboxId ID of the Inbox to subscribe
173
+ * Unsubscribe from events for the given subscriptionId.
174
+ * @param {string[]} subscriptionIds list of subscriptionId
176
175
  */
177
- subscribeForEntryEvents(inboxId: string): Promise<void>;
176
+ unsubscribeFrom(subscriptionIds: string[]): Promise<void>;
178
177
  /**
179
- * Unsubscribes from events in given Inbox.
180
- * @param {string} inboxId ID of the Inbox to unsubscribe
178
+ * Generate subscription Query for the Inbox events.
179
+ * @param {EventType} eventType type of event which you listen for
180
+ * @param {EventSelectorType} selectorType scope on which you listen for events
181
+ * @param {string} selectorId ID of the selector
181
182
  */
182
- unsubscribeFromEntryEvents(inboxId: string): Promise<void>;
183
+ buildSubscriptionQuery(eventType: InboxEventType, selectorType: InboxEventSelectorType, selectorId: string): Promise<string>;
183
184
  }
@@ -232,31 +232,56 @@ class InboxApi extends BaseApi_1.BaseApi {
232
232
  async closeFile(fileHandle) {
233
233
  return this.native.closeFile(this.servicePtr, [fileHandle]);
234
234
  }
235
+ // /**
236
+ // * Subscribes for the Inbox module main events.
237
+ // */
238
+ // async subscribeForInboxEvents(): Promise<void> {
239
+ // return this.native.subscribeForInboxEvents(this.servicePtr, []);
240
+ // }
241
+ // /**
242
+ // * Unsubscribes from the Inbox module main events.
243
+ // */
244
+ // async unsubscribeFromInboxEvents(): Promise<void> {
245
+ // return this.native.unsubscribeFromInboxEvents(this.servicePtr, []);
246
+ // }
247
+ // /**
248
+ // * Subscribes for events in given Inbox.
249
+ // * @param {string} inboxId ID of the Inbox to subscribe
250
+ // */
251
+ // async subscribeForEntryEvents(inboxId: string): Promise<void> {
252
+ // return this.native.subscribeForEntryEvents(this.servicePtr, [inboxId]);
253
+ // }
254
+ // /**
255
+ // * Unsubscribes from events in given Inbox.
256
+ // * @param {string} inboxId ID of the Inbox to unsubscribe
257
+ // */
258
+ // async unsubscribeFromEntryEvents(inboxId: string): Promise<void> {
259
+ // return this.native.unsubscribeFromEntryEvents(this.servicePtr, [inboxId]);
260
+ // }
235
261
  /**
236
- * Subscribes for the Inbox module main events.
237
- */
238
- async subscribeForInboxEvents() {
239
- return this.native.subscribeForInboxEvents(this.servicePtr, []);
240
- }
241
- /**
242
- * Unsubscribes from the Inbox module main events.
262
+ * Subscribe for the Inbox events on the given subscription query.
263
+ *
264
+ * @param {string[]} subscriptionQueries list of queries
265
+ * @return list of subscriptionIds in maching order to subscriptionQueries
243
266
  */
244
- async unsubscribeFromInboxEvents() {
245
- return this.native.unsubscribeFromInboxEvents(this.servicePtr, []);
267
+ async subscribeFor(subscriptionQueries) {
268
+ return this.native.subscribeFor(this.servicePtr, [subscriptionQueries]);
246
269
  }
247
270
  /**
248
- * Subscribes for events in given Inbox.
249
- * @param {string} inboxId ID of the Inbox to subscribe
271
+ * Unsubscribe from events for the given subscriptionId.
272
+ * @param {string[]} subscriptionIds list of subscriptionId
250
273
  */
251
- async subscribeForEntryEvents(inboxId) {
252
- return this.native.subscribeForEntryEvents(this.servicePtr, [inboxId]);
274
+ async unsubscribeFrom(subscriptionIds) {
275
+ return this.native.unsubscribeFrom(this.servicePtr, [subscriptionIds]);
253
276
  }
254
277
  /**
255
- * Unsubscribes from events in given Inbox.
256
- * @param {string} inboxId ID of the Inbox to unsubscribe
278
+ * Generate subscription Query for the Inbox events.
279
+ * @param {EventType} eventType type of event which you listen for
280
+ * @param {EventSelectorType} selectorType scope on which you listen for events
281
+ * @param {string} selectorId ID of the selector
257
282
  */
258
- async unsubscribeFromEntryEvents(inboxId) {
259
- return this.native.unsubscribeFromEntryEvents(this.servicePtr, [inboxId]);
283
+ async buildSubscriptionQuery(eventType, selectorType, selectorId) {
284
+ return this.native.buildSubscriptionQuery(this.servicePtr, [eventType, selectorType, selectorId]);
260
285
  }
261
286
  }
262
287
  exports.InboxApi = InboxApi;