@simplito/privmx-webendpoint 2.1.1 → 2.2.1
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/Types.d.ts +407 -0
- package/Types.js +27 -0
- package/api/Api.d.ts +20 -0
- package/api/Api.js +48 -0
- package/api/BaseNative.d.ts +20 -0
- package/api/BaseNative.js +35 -0
- package/api/ConnectionNative.d.ts +24 -0
- package/api/ConnectionNative.js +51 -0
- package/api/CryptoApiNative.d.ts +25 -0
- package/api/CryptoApiNative.js +54 -0
- package/api/EventQueueNative.d.ts +20 -0
- package/api/EventQueueNative.js +37 -0
- package/api/IdGenerator.d.ts +14 -0
- package/api/IdGenerator.js +21 -0
- package/api/InboxApiNative.d.ts +38 -0
- package/api/InboxApiNative.js +90 -0
- package/api/StoreApiNative.d.ts +37 -0
- package/api/StoreApiNative.js +87 -0
- package/api/ThreadApiNative.d.ts +31 -0
- package/api/ThreadApiNative.js +69 -0
- package/assets/endpoint-wasm-module.js +20 -0
- package/{webAssets → assets}/endpoint-wasm-module.wasm +0 -0
- package/bundle/privmx-endpoint-web.js +2 -0
- package/bundle/privmx-endpoint-web.js.LICENSE.txt +10 -0
- package/bundle.d.ts +12 -0
- package/bundle.js +16 -0
- package/extra/__tests__/__mocks__/constants.d.ts +36 -0
- package/extra/__tests__/__mocks__/constants.js +42 -0
- package/extra/__tests__/__mocks__/mockContainerSubscriber.d.ts +12 -0
- package/extra/__tests__/__mocks__/mockContainerSubscriber.js +25 -0
- package/extra/__tests__/__mocks__/mockEventAPIs.d.ts +30 -0
- package/extra/__tests__/__mocks__/mockEventAPIs.js +70 -0
- package/extra/__tests__/__mocks__/mockEventQueue.d.ts +13 -0
- package/extra/__tests__/__mocks__/mockEventQueue.js +45 -0
- package/extra/__tests__/__mocks__/utils.d.ts +8 -0
- package/extra/__tests__/__mocks__/utils.js +21 -0
- package/extra/__tests__/eventsManager.test.d.ts +1 -0
- package/extra/__tests__/eventsManager.test.js +73 -0
- package/extra/__tests__/inboxEventManager.test.d.ts +1 -0
- package/extra/__tests__/inboxEventManager.test.js +56 -0
- package/extra/__tests__/storeEventManager.test.d.ts +1 -0
- package/extra/__tests__/storeEventManager.test.js +56 -0
- package/extra/__tests__/threadEventManager.test.d.ts +1 -0
- package/extra/__tests__/threadEventManager.test.js +60 -0
- package/extra/__tests__/utils.test.d.ts +1 -0
- package/extra/__tests__/utils.test.js +52 -0
- package/extra/events.d.ts +234 -0
- package/extra/events.js +270 -0
- package/extra/files.d.ts +120 -0
- package/extra/files.js +216 -0
- package/extra/generics.d.ts +19 -0
- package/extra/generics.js +2 -0
- package/extra/inbox.d.ts +38 -0
- package/extra/inbox.js +35 -0
- package/extra/index.d.ts +8 -0
- package/extra/index.js +23 -0
- package/extra/utils.d.ts +24 -0
- package/extra/utils.js +68 -0
- package/index.d.ts +14 -0
- package/index.js +25 -0
- package/package.json +45 -3
- package/service/BaseApi.d.ts +16 -0
- package/service/BaseApi.js +29 -0
- package/service/Connection.d.ts +45 -0
- package/service/Connection.js +57 -0
- package/service/CryptoApi.d.ts +83 -0
- package/service/CryptoApi.js +113 -0
- package/service/EndpointFactory.d.ts +89 -0
- package/service/EndpointFactory.js +173 -0
- package/service/EventQueue.d.ts +20 -0
- package/service/EventQueue.js +37 -0
- package/service/InboxApi.d.ts +183 -0
- package/service/InboxApi.js +262 -0
- package/service/StoreApi.d.ts +170 -0
- package/service/StoreApi.js +246 -0
- package/service/ThreadApi.d.ts +124 -0
- package/service/ThreadApi.js +186 -0
- package/service/index.d.ts +9 -0
- package/service/index.js +19 -0
- package/webAssets/endpoint-wasm-module.js +0 -20
- package/webAssets/privmx-endpoint-web.js +0 -2
- /package/{webAssets/LICENSE.md → LICENSE.md} +0 -0
- /package/{webAssets → assets}/driver-web-context.js +0 -0
- /package/{webAssets → assets}/endpoint-wasm-module.worker.js +0 -0
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
PrivMX Web Endpoint.
|
|
4
|
+
Copyright © 2024 Simplito sp. z o.o.
|
|
5
|
+
|
|
6
|
+
This file is part of the PrivMX Platform (https://privmx.dev).
|
|
7
|
+
This software is Licensed under the PrivMX Free License.
|
|
8
|
+
|
|
9
|
+
See the License for the specific language governing permissions and
|
|
10
|
+
limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.StoreApi = void 0;
|
|
14
|
+
const BaseApi_1 = require("./BaseApi");
|
|
15
|
+
class StoreApi extends BaseApi_1.BaseApi {
|
|
16
|
+
native;
|
|
17
|
+
constructor(native, ptr) {
|
|
18
|
+
super(ptr);
|
|
19
|
+
this.native = native;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Creates a new Store in given Context.
|
|
23
|
+
*
|
|
24
|
+
* @param {string} contextId ID of the Context to create the Store in
|
|
25
|
+
* @param {UserWithPubKey[]} users array of UserWithPubKey structs which indicates who will have access to the created Store
|
|
26
|
+
* @param {UserWithPubKey[]} managers array of UserWithPubKey structs which indicates who will have access (and management rights) to the
|
|
27
|
+
* created Store
|
|
28
|
+
* @param {Uint8Array} publicMeta public (unencrypted) metadata
|
|
29
|
+
* @param {Uint8Array} privateMeta private (encrypted) metadata
|
|
30
|
+
* @param {ContainerPolicy} policies Store's policies
|
|
31
|
+
* @returns {string} created Store ID
|
|
32
|
+
*/
|
|
33
|
+
async createStore(contextId, users, managers, publicMeta, privateMeta, policies) {
|
|
34
|
+
return this.native.createStore(this.servicePtr, [
|
|
35
|
+
contextId,
|
|
36
|
+
users,
|
|
37
|
+
managers,
|
|
38
|
+
publicMeta,
|
|
39
|
+
privateMeta,
|
|
40
|
+
policies
|
|
41
|
+
]);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Updates an existing Store.
|
|
45
|
+
*
|
|
46
|
+
* @param {string} storeId ID of the Store to update
|
|
47
|
+
* @param {UserWithPubKey[]} users array of UserWithPubKey structs which indicates who will have access to the created Store
|
|
48
|
+
* @param {UserWithPubKey[]} managers array of UserWithPubKey structs which indicates who will have access (and management rights) to the
|
|
49
|
+
* created Store
|
|
50
|
+
* @param {Uint8Array} publicMeta public (unencrypted) metadata
|
|
51
|
+
* @param {Uint8Array} privateMeta private (encrypted) metadata
|
|
52
|
+
* @param {number} version current version of the updated Store
|
|
53
|
+
* @param {boolean} force force update (without checking version)
|
|
54
|
+
* @param {boolean} forceGenerateNewKey force to regenerate a key for the Store
|
|
55
|
+
* @param {ContainerPolicy} policies Store's policies
|
|
56
|
+
*/
|
|
57
|
+
async updateStore(storeId, users, managers, publicMeta, privateMeta, version, force, forceGenerateNewKey, policies) {
|
|
58
|
+
return this.native.updateStore(this.servicePtr, [
|
|
59
|
+
storeId,
|
|
60
|
+
users,
|
|
61
|
+
managers,
|
|
62
|
+
publicMeta,
|
|
63
|
+
privateMeta,
|
|
64
|
+
version,
|
|
65
|
+
force,
|
|
66
|
+
forceGenerateNewKey,
|
|
67
|
+
policies
|
|
68
|
+
]);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Deletes a Store by given Store ID.
|
|
72
|
+
*
|
|
73
|
+
* @param {string} storeId ID of the Store to delete
|
|
74
|
+
*/
|
|
75
|
+
async deleteStore(storeId) {
|
|
76
|
+
return this.native.deleteStore(this.servicePtr, [storeId]);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Gets a single Store by given Store ID.
|
|
80
|
+
*
|
|
81
|
+
* @param {string} storeId ID of the Store to get
|
|
82
|
+
* @returns {Store} struct containing information about the Store
|
|
83
|
+
*/
|
|
84
|
+
async getStore(storeId) {
|
|
85
|
+
return this.native.getStore(this.servicePtr, [storeId]);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Gets a list of Stores in given Context.
|
|
89
|
+
*
|
|
90
|
+
* @param {string} contextId ID of the Context to get the Stores from
|
|
91
|
+
* @param {PagingQuery} pagingQuery struct with list query parameters
|
|
92
|
+
* @returns {PagingList<Store>} struct containing list of Stores
|
|
93
|
+
*/
|
|
94
|
+
async listStores(contextId, pagingQuery) {
|
|
95
|
+
return this.native.listStores(this.servicePtr, [contextId, pagingQuery]);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Creates a new file in a Store.
|
|
99
|
+
*
|
|
100
|
+
* @param {string} storeId ID of the Store to create the file in
|
|
101
|
+
* @param {Uint8Array} publicMeta public file metadata
|
|
102
|
+
* @param {Uint8Array} privateMeta private file metadata
|
|
103
|
+
* @param {number} size size of the file
|
|
104
|
+
* @returns {number} handle to write data
|
|
105
|
+
*/
|
|
106
|
+
async createFile(storeId, publicMeta, privateMeta, size) {
|
|
107
|
+
return this.native.createFile(this.servicePtr, [
|
|
108
|
+
storeId,
|
|
109
|
+
publicMeta,
|
|
110
|
+
privateMeta,
|
|
111
|
+
size,
|
|
112
|
+
]);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Update an existing file in a Store.
|
|
116
|
+
*
|
|
117
|
+
* @param {string} fileId ID of the file to update
|
|
118
|
+
* @param {Uint8Array} publicMeta public file metadata
|
|
119
|
+
* @param {Uint8Array} privateMeta private file metadata
|
|
120
|
+
* @param {number} size size of the file
|
|
121
|
+
* @returns {number} handle to write file data
|
|
122
|
+
*/
|
|
123
|
+
async updateFile(fileId, publicMeta, privateMeta, size) {
|
|
124
|
+
return this.native.updateFile(this.servicePtr, [
|
|
125
|
+
fileId,
|
|
126
|
+
publicMeta,
|
|
127
|
+
privateMeta,
|
|
128
|
+
size,
|
|
129
|
+
]);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Update metadata of an existing file in a Store.
|
|
133
|
+
*
|
|
134
|
+
* @param {string} fileId ID of the file to update
|
|
135
|
+
* @param {Uint8Array} publicMeta public file metadata
|
|
136
|
+
* @param {Uint8Array} privateMeta private file metadata
|
|
137
|
+
*/
|
|
138
|
+
async updateFileMeta(fileId, publicMeta, privateMeta) {
|
|
139
|
+
return this.native.updateFileMeta(this.servicePtr, [
|
|
140
|
+
fileId,
|
|
141
|
+
publicMeta,
|
|
142
|
+
privateMeta,
|
|
143
|
+
]);
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Writes a file data.
|
|
147
|
+
*
|
|
148
|
+
* @param {number} fileHandle handle to write file data
|
|
149
|
+
* @param {Uint8Array} dataChunk file data chunk
|
|
150
|
+
*/
|
|
151
|
+
async writeToFile(fileHandle, dataChunk) {
|
|
152
|
+
return this.native.writeToFile(this.servicePtr, [fileHandle, dataChunk]);
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Deletes a file by given ID.
|
|
156
|
+
*
|
|
157
|
+
* @param {string} fileId ID of the file to delete
|
|
158
|
+
*/
|
|
159
|
+
async deleteFile(fileId) {
|
|
160
|
+
return this.native.deleteFile(this.servicePtr, [fileId]);
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Gets a single file by the given file ID.
|
|
164
|
+
*
|
|
165
|
+
* @param {string} fileId ID of the file to get
|
|
166
|
+
* @returns {File} struct containing information about the file
|
|
167
|
+
*/
|
|
168
|
+
async getFile(fileId) {
|
|
169
|
+
return this.native.getFile(this.servicePtr, [fileId]);
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Gets a list of files in given Store.
|
|
173
|
+
*
|
|
174
|
+
* @param {string} storeId ID of the Store to get files from
|
|
175
|
+
* @param {PagingQuery} pagingQuery struct with list query parameters
|
|
176
|
+
* @returns {PagingList<File>} struct containing list of files
|
|
177
|
+
*/
|
|
178
|
+
async listFiles(storeId, pagingQuery) {
|
|
179
|
+
return this.native.listFiles(this.servicePtr, [storeId, pagingQuery]);
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Opens a file to read.
|
|
183
|
+
*
|
|
184
|
+
* @param {string} fileId ID of the file to read
|
|
185
|
+
* @returns {number} handle to read file data
|
|
186
|
+
*/
|
|
187
|
+
async openFile(fileId) {
|
|
188
|
+
return this.native.openFile(this.servicePtr, [fileId]);
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Reads file data.
|
|
192
|
+
* Single read call moves the files's cursor position by declared length or set it at the end of the file.
|
|
193
|
+
*
|
|
194
|
+
* @param {string} fileHandle handle to write file data
|
|
195
|
+
* @param {number} length size of data to read
|
|
196
|
+
* @returns {Uint8Array} array buffer with file data chunk
|
|
197
|
+
*/
|
|
198
|
+
async readFromFile(fileHandle, length) {
|
|
199
|
+
return this.native.readFromFile(this.servicePtr, [fileHandle, length]);
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Moves read cursor.
|
|
203
|
+
*
|
|
204
|
+
* @param {string} fileHandle handle to write file data
|
|
205
|
+
* @param {number} position new cursor position
|
|
206
|
+
*/
|
|
207
|
+
async seekInFile(fileHandle, position) {
|
|
208
|
+
return this.native.seekInFile(this.servicePtr, [fileHandle, position]);
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Closes the file handle.
|
|
212
|
+
*
|
|
213
|
+
* @param {string} fileHandle handle to read/write file data
|
|
214
|
+
* @returns {string} ID of closed file
|
|
215
|
+
*/
|
|
216
|
+
async closeFile(fileHandle) {
|
|
217
|
+
return this.native.closeFile(this.servicePtr, [fileHandle]);
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Subscribes for the Store module main events.
|
|
221
|
+
*/
|
|
222
|
+
async subscribeForStoreEvents() {
|
|
223
|
+
return this.native.subscribeForStoreEvents(this.servicePtr, []);
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Unsubscribes from the Store module main events.
|
|
227
|
+
*/
|
|
228
|
+
async unsubscribeFromStoreEvents() {
|
|
229
|
+
return this.native.unsubscribeFromStoreEvents(this.servicePtr, []);
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Subscribes for events in given Store.
|
|
233
|
+
* @param {string} storeId ID of the Store to subscribe
|
|
234
|
+
*/
|
|
235
|
+
async subscribeForFileEvents(storeId) {
|
|
236
|
+
return this.native.subscribeForFileEvents(this.servicePtr, [storeId]);
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Unsubscribes from events in given Store.
|
|
240
|
+
* @param {string} storeId ID of the Store to unsubscribe
|
|
241
|
+
*/
|
|
242
|
+
async unsubscribeFromFileEvents(storeId) {
|
|
243
|
+
return this.native.unsubscribeFromFileEvents(this.servicePtr, [storeId]);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
exports.StoreApi = StoreApi;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
PrivMX Web Endpoint.
|
|
3
|
+
Copyright © 2024 Simplito sp. z o.o.
|
|
4
|
+
|
|
5
|
+
This file is part of the PrivMX Platform (https://privmx.dev).
|
|
6
|
+
This software is Licensed under the PrivMX Free License.
|
|
7
|
+
|
|
8
|
+
See the License for the specific language governing permissions and
|
|
9
|
+
limitations under the License.
|
|
10
|
+
*/
|
|
11
|
+
import { BaseApi } from "./BaseApi";
|
|
12
|
+
import { ThreadApiNative } from "../api/ThreadApiNative";
|
|
13
|
+
import { PagingQuery, PagingList, UserWithPubKey, Thread, Message, ContainerPolicy } from "../Types";
|
|
14
|
+
export declare class ThreadApi extends BaseApi {
|
|
15
|
+
protected native: ThreadApiNative;
|
|
16
|
+
constructor(native: ThreadApiNative, ptr: number);
|
|
17
|
+
/**
|
|
18
|
+
* Creates a new Thread in given Context.
|
|
19
|
+
*
|
|
20
|
+
* @param {string} contextId ID of the Context to create the Thread in
|
|
21
|
+
* @param {UserWithPubKey[]} users array of UserWithPubKey structs which indicates who will have access to the created Thread
|
|
22
|
+
* @param {UserWithPubKey[]} managers array of UserWithPubKey structs which indicates who will have access (and management rights) to
|
|
23
|
+
* the created Thread
|
|
24
|
+
* @param {Uint8Array} publicMeta public (unencrypted) metadata
|
|
25
|
+
* @param {Uint8Array} privateMeta private (encrypted) metadata
|
|
26
|
+
* @param {ContainerPolicy} policies Thread's policies
|
|
27
|
+
* @returns {string} ID of the created Thread
|
|
28
|
+
*/
|
|
29
|
+
createThread(contextId: string, users: UserWithPubKey[], managers: UserWithPubKey[], publicMeta: Uint8Array, privateMeta: Uint8Array, policies?: ContainerPolicy): Promise<string>;
|
|
30
|
+
/**
|
|
31
|
+
* Updates an existing Thread.
|
|
32
|
+
*
|
|
33
|
+
* @param {string} threadId ID of the Thread to update
|
|
34
|
+
* @param {UserWithPubKey[]} users array of UserWithPubKey structs which indicates who will have access to the created Thread
|
|
35
|
+
* @param {UserWithPubKey[]} managers array of UserWithPubKey structs which indicates who will have access (and management rights) to
|
|
36
|
+
* the created Thread
|
|
37
|
+
* @param {Uint8Array} publicMeta public (unencrypted) metadata
|
|
38
|
+
* @param {Uint8Array} privateMeta private (encrypted) metadata
|
|
39
|
+
* @param {number} version current version of the updated Thread
|
|
40
|
+
* @param {boolean} force force update (without checking version)
|
|
41
|
+
* @param {boolean} forceGenerateNewKey force to regenerate a key for the Thread
|
|
42
|
+
* @param {ContainerPolicy} policies Thread's policies
|
|
43
|
+
*/
|
|
44
|
+
updateThread(threadId: string, users: UserWithPubKey[], managers: UserWithPubKey[], publicMeta: Uint8Array, privateMeta: Uint8Array, version: number, force: boolean, forceGenerateNewKey: boolean, policies?: ContainerPolicy): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* Deletes a Thread by given Thread ID.
|
|
47
|
+
*
|
|
48
|
+
* @param {string} threadId ID of the Thread to delete
|
|
49
|
+
*/
|
|
50
|
+
deleteThread(threadId: string): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Gets a Thread by given Thread ID.
|
|
53
|
+
*
|
|
54
|
+
* @param {string} threadId ID of Thread to get
|
|
55
|
+
* @returns {Thread} struct containing info about the Thread
|
|
56
|
+
*/
|
|
57
|
+
getThread(threadId: string): Promise<Thread>;
|
|
58
|
+
/**
|
|
59
|
+
* Gets a list of Threads in given Context.
|
|
60
|
+
*
|
|
61
|
+
* @param {string} contextId ID of the Context to get the Threads from
|
|
62
|
+
* @param {PagingQuery} pagingQuery struct with list query parameters
|
|
63
|
+
* @returns {PagingList<Thread>} struct containing a list of Threads
|
|
64
|
+
*/
|
|
65
|
+
listThreads(contextId: string, pagingQuery: PagingQuery): Promise<PagingList<Thread>>;
|
|
66
|
+
/**
|
|
67
|
+
* Gets a message by given message ID.
|
|
68
|
+
*
|
|
69
|
+
* @param {string} messageId ID of the message to get
|
|
70
|
+
* @returns {Message} struct containing the message
|
|
71
|
+
*/
|
|
72
|
+
getMessage(messageId: string): Promise<Message>;
|
|
73
|
+
/**
|
|
74
|
+
* Gets a list of messages from a Thread.
|
|
75
|
+
*
|
|
76
|
+
* @param {string} threadId ID of the Thread to list messages from
|
|
77
|
+
* @param {PagingQuery} pagingQuery struct with list query parameters
|
|
78
|
+
* @returns {PagingList<Message>} struct containing a list of messages
|
|
79
|
+
*/
|
|
80
|
+
listMessages(threadId: string, pagingQuery: PagingQuery): Promise<PagingList<Message>>;
|
|
81
|
+
/**
|
|
82
|
+
* Sends a message in a Thread.
|
|
83
|
+
*
|
|
84
|
+
* @param {string} threadId ID of the Thread to send message to
|
|
85
|
+
* @param {Uint8Array} publicMeta public message metadata
|
|
86
|
+
* @param {Uint8Array} privateMeta private message metadata
|
|
87
|
+
* @param {Uint8Array} data content of the message
|
|
88
|
+
* @returns {string} ID of the new message
|
|
89
|
+
*/
|
|
90
|
+
sendMessage(threadId: string, publicMeta: Uint8Array, privateMeta: Uint8Array, data: Uint8Array): Promise<string>;
|
|
91
|
+
/**
|
|
92
|
+
* Deletes a message by given message ID.
|
|
93
|
+
*
|
|
94
|
+
* @param {string} messageId ID of the message to delete
|
|
95
|
+
*/
|
|
96
|
+
deleteMessage(messageId: string): Promise<void>;
|
|
97
|
+
/**
|
|
98
|
+
* Update message in a Thread.
|
|
99
|
+
*
|
|
100
|
+
* @param {string} messageId ID of the message to update
|
|
101
|
+
* @param {Uint8Array} publicMeta public message metadata
|
|
102
|
+
* @param {Uint8Array} privateMeta private message metadata
|
|
103
|
+
* @param {Uint8Array} data content of the message
|
|
104
|
+
*/
|
|
105
|
+
updateMessage(messageId: string, publicMeta: Uint8Array, privateMeta: Uint8Array, data: Uint8Array): Promise<void>;
|
|
106
|
+
/**
|
|
107
|
+
* Subscribes for the Thread module main events.
|
|
108
|
+
*/
|
|
109
|
+
subscribeForThreadEvents(): Promise<void>;
|
|
110
|
+
/**
|
|
111
|
+
* Unsubscribes from the Thread module main events.
|
|
112
|
+
*/
|
|
113
|
+
unsubscribeFromThreadEvents(): Promise<void>;
|
|
114
|
+
/**
|
|
115
|
+
* Subscribes for events in given Thread.
|
|
116
|
+
* @param {string} threadId ID of the Thread to subscribe
|
|
117
|
+
*/
|
|
118
|
+
subscribeForMessageEvents(threadId: string): Promise<void>;
|
|
119
|
+
/**
|
|
120
|
+
* Unsubscribes from events in given Thread.
|
|
121
|
+
* @param {string} threadId ID of the Thread to unsubscribe
|
|
122
|
+
*/
|
|
123
|
+
unsubscribeFromMessageEvents(threadId: string): Promise<void>;
|
|
124
|
+
}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
PrivMX Web Endpoint.
|
|
4
|
+
Copyright © 2024 Simplito sp. z o.o.
|
|
5
|
+
|
|
6
|
+
This file is part of the PrivMX Platform (https://privmx.dev).
|
|
7
|
+
This software is Licensed under the PrivMX Free License.
|
|
8
|
+
|
|
9
|
+
See the License for the specific language governing permissions and
|
|
10
|
+
limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.ThreadApi = void 0;
|
|
14
|
+
const BaseApi_1 = require("./BaseApi");
|
|
15
|
+
class ThreadApi extends BaseApi_1.BaseApi {
|
|
16
|
+
native;
|
|
17
|
+
constructor(native, ptr) {
|
|
18
|
+
super(ptr);
|
|
19
|
+
this.native = native;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Creates a new Thread in given Context.
|
|
23
|
+
*
|
|
24
|
+
* @param {string} contextId ID of the Context to create the Thread in
|
|
25
|
+
* @param {UserWithPubKey[]} users array of UserWithPubKey structs which indicates who will have access to the created Thread
|
|
26
|
+
* @param {UserWithPubKey[]} managers array of UserWithPubKey structs which indicates who will have access (and management rights) to
|
|
27
|
+
* the created Thread
|
|
28
|
+
* @param {Uint8Array} publicMeta public (unencrypted) metadata
|
|
29
|
+
* @param {Uint8Array} privateMeta private (encrypted) metadata
|
|
30
|
+
* @param {ContainerPolicy} policies Thread's policies
|
|
31
|
+
* @returns {string} ID of the created Thread
|
|
32
|
+
*/
|
|
33
|
+
async createThread(contextId, users, managers, publicMeta, privateMeta, policies) {
|
|
34
|
+
return this.native.createThread(this.servicePtr, [
|
|
35
|
+
contextId,
|
|
36
|
+
users,
|
|
37
|
+
managers,
|
|
38
|
+
publicMeta,
|
|
39
|
+
privateMeta,
|
|
40
|
+
policies,
|
|
41
|
+
]);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Updates an existing Thread.
|
|
45
|
+
*
|
|
46
|
+
* @param {string} threadId ID of the Thread to update
|
|
47
|
+
* @param {UserWithPubKey[]} users array of UserWithPubKey structs which indicates who will have access to the created Thread
|
|
48
|
+
* @param {UserWithPubKey[]} managers array of UserWithPubKey structs which indicates who will have access (and management rights) to
|
|
49
|
+
* the created Thread
|
|
50
|
+
* @param {Uint8Array} publicMeta public (unencrypted) metadata
|
|
51
|
+
* @param {Uint8Array} privateMeta private (encrypted) metadata
|
|
52
|
+
* @param {number} version current version of the updated Thread
|
|
53
|
+
* @param {boolean} force force update (without checking version)
|
|
54
|
+
* @param {boolean} forceGenerateNewKey force to regenerate a key for the Thread
|
|
55
|
+
* @param {ContainerPolicy} policies Thread's policies
|
|
56
|
+
*/
|
|
57
|
+
async updateThread(threadId, users, managers, publicMeta, privateMeta, version, force, forceGenerateNewKey, policies) {
|
|
58
|
+
return this.native.updateThread(this.servicePtr, [
|
|
59
|
+
threadId,
|
|
60
|
+
users,
|
|
61
|
+
managers,
|
|
62
|
+
publicMeta,
|
|
63
|
+
privateMeta,
|
|
64
|
+
version,
|
|
65
|
+
force,
|
|
66
|
+
forceGenerateNewKey,
|
|
67
|
+
policies,
|
|
68
|
+
]);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Deletes a Thread by given Thread ID.
|
|
72
|
+
*
|
|
73
|
+
* @param {string} threadId ID of the Thread to delete
|
|
74
|
+
*/
|
|
75
|
+
async deleteThread(threadId) {
|
|
76
|
+
return this.native.deleteThread(this.servicePtr, [threadId]);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Gets a Thread by given Thread ID.
|
|
80
|
+
*
|
|
81
|
+
* @param {string} threadId ID of Thread to get
|
|
82
|
+
* @returns {Thread} struct containing info about the Thread
|
|
83
|
+
*/
|
|
84
|
+
async getThread(threadId) {
|
|
85
|
+
return this.native.getThread(this.servicePtr, [threadId]);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Gets a list of Threads in given Context.
|
|
89
|
+
*
|
|
90
|
+
* @param {string} contextId ID of the Context to get the Threads from
|
|
91
|
+
* @param {PagingQuery} pagingQuery struct with list query parameters
|
|
92
|
+
* @returns {PagingList<Thread>} struct containing a list of Threads
|
|
93
|
+
*/
|
|
94
|
+
async listThreads(contextId, pagingQuery) {
|
|
95
|
+
return this.native.listThreads(this.servicePtr, [contextId, pagingQuery]);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Gets a message by given message ID.
|
|
99
|
+
*
|
|
100
|
+
* @param {string} messageId ID of the message to get
|
|
101
|
+
* @returns {Message} struct containing the message
|
|
102
|
+
*/
|
|
103
|
+
async getMessage(messageId) {
|
|
104
|
+
return this.native.getMessage(this.servicePtr, [messageId]);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Gets a list of messages from a Thread.
|
|
108
|
+
*
|
|
109
|
+
* @param {string} threadId ID of the Thread to list messages from
|
|
110
|
+
* @param {PagingQuery} pagingQuery struct with list query parameters
|
|
111
|
+
* @returns {PagingList<Message>} struct containing a list of messages
|
|
112
|
+
*/
|
|
113
|
+
async listMessages(threadId, pagingQuery) {
|
|
114
|
+
return this.native.listMessages(this.servicePtr, [threadId, pagingQuery]);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Sends a message in a Thread.
|
|
118
|
+
*
|
|
119
|
+
* @param {string} threadId ID of the Thread to send message to
|
|
120
|
+
* @param {Uint8Array} publicMeta public message metadata
|
|
121
|
+
* @param {Uint8Array} privateMeta private message metadata
|
|
122
|
+
* @param {Uint8Array} data content of the message
|
|
123
|
+
* @returns {string} ID of the new message
|
|
124
|
+
*/
|
|
125
|
+
async sendMessage(threadId, publicMeta, privateMeta, data) {
|
|
126
|
+
return this.native.sendMessage(this.servicePtr, [
|
|
127
|
+
threadId,
|
|
128
|
+
publicMeta,
|
|
129
|
+
privateMeta,
|
|
130
|
+
data,
|
|
131
|
+
]);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Deletes a message by given message ID.
|
|
135
|
+
*
|
|
136
|
+
* @param {string} messageId ID of the message to delete
|
|
137
|
+
*/
|
|
138
|
+
async deleteMessage(messageId) {
|
|
139
|
+
return this.native.deleteMessage(this.servicePtr, [messageId]);
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Update message in a Thread.
|
|
143
|
+
*
|
|
144
|
+
* @param {string} messageId ID of the message to update
|
|
145
|
+
* @param {Uint8Array} publicMeta public message metadata
|
|
146
|
+
* @param {Uint8Array} privateMeta private message metadata
|
|
147
|
+
* @param {Uint8Array} data content of the message
|
|
148
|
+
*/
|
|
149
|
+
async updateMessage(messageId, publicMeta, privateMeta, data) {
|
|
150
|
+
return this.native.updateMessage(this.servicePtr, [
|
|
151
|
+
messageId,
|
|
152
|
+
publicMeta,
|
|
153
|
+
privateMeta,
|
|
154
|
+
data,
|
|
155
|
+
]);
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Subscribes for the Thread module main events.
|
|
159
|
+
*/
|
|
160
|
+
async subscribeForThreadEvents() {
|
|
161
|
+
return this.native.subscribeForThreadEvents(this.servicePtr, []);
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Unsubscribes from the Thread module main events.
|
|
165
|
+
*/
|
|
166
|
+
async unsubscribeFromThreadEvents() {
|
|
167
|
+
return this.native.unsubscribeFromThreadEvents(this.servicePtr, []);
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Subscribes for events in given Thread.
|
|
171
|
+
* @param {string} threadId ID of the Thread to subscribe
|
|
172
|
+
*/
|
|
173
|
+
async subscribeForMessageEvents(threadId) {
|
|
174
|
+
return this.native.subscribeForMessageEvents(this.servicePtr, [threadId]);
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Unsubscribes from events in given Thread.
|
|
178
|
+
* @param {string} threadId ID of the Thread to unsubscribe
|
|
179
|
+
*/
|
|
180
|
+
async unsubscribeFromMessageEvents(threadId) {
|
|
181
|
+
return this.native.unsubscribeFromMessageEvents(this.servicePtr, [
|
|
182
|
+
threadId,
|
|
183
|
+
]);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
exports.ThreadApi = ThreadApi;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { EndpointFactory } from "./EndpointFactory";
|
|
2
|
+
import { ThreadApi } from "./ThreadApi";
|
|
3
|
+
import { StoreApi } from "./StoreApi";
|
|
4
|
+
import { InboxApi } from "./InboxApi";
|
|
5
|
+
import { CryptoApi } from "./CryptoApi";
|
|
6
|
+
import { Connection } from "./Connection";
|
|
7
|
+
import { EventQueue } from "./EventQueue";
|
|
8
|
+
import { BaseApi } from "./BaseApi";
|
|
9
|
+
export { EndpointFactory, ThreadApi, StoreApi, InboxApi, CryptoApi, Connection, EventQueue, BaseApi };
|
package/service/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseApi = exports.EventQueue = exports.Connection = exports.CryptoApi = exports.InboxApi = exports.StoreApi = exports.ThreadApi = exports.EndpointFactory = void 0;
|
|
4
|
+
const EndpointFactory_1 = require("./EndpointFactory");
|
|
5
|
+
Object.defineProperty(exports, "EndpointFactory", { enumerable: true, get: function () { return EndpointFactory_1.EndpointFactory; } });
|
|
6
|
+
const ThreadApi_1 = require("./ThreadApi");
|
|
7
|
+
Object.defineProperty(exports, "ThreadApi", { enumerable: true, get: function () { return ThreadApi_1.ThreadApi; } });
|
|
8
|
+
const StoreApi_1 = require("./StoreApi");
|
|
9
|
+
Object.defineProperty(exports, "StoreApi", { enumerable: true, get: function () { return StoreApi_1.StoreApi; } });
|
|
10
|
+
const InboxApi_1 = require("./InboxApi");
|
|
11
|
+
Object.defineProperty(exports, "InboxApi", { enumerable: true, get: function () { return InboxApi_1.InboxApi; } });
|
|
12
|
+
const CryptoApi_1 = require("./CryptoApi");
|
|
13
|
+
Object.defineProperty(exports, "CryptoApi", { enumerable: true, get: function () { return CryptoApi_1.CryptoApi; } });
|
|
14
|
+
const Connection_1 = require("./Connection");
|
|
15
|
+
Object.defineProperty(exports, "Connection", { enumerable: true, get: function () { return Connection_1.Connection; } });
|
|
16
|
+
const EventQueue_1 = require("./EventQueue");
|
|
17
|
+
Object.defineProperty(exports, "EventQueue", { enumerable: true, get: function () { return EventQueue_1.EventQueue; } });
|
|
18
|
+
const BaseApi_1 = require("./BaseApi");
|
|
19
|
+
Object.defineProperty(exports, "BaseApi", { enumerable: true, get: function () { return BaseApi_1.BaseApi; } });
|