@simplito/privmx-webendpoint 2.2.9 → 2.5.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.
Files changed (55) hide show
  1. package/FinalizationHelper.d.ts +18 -0
  2. package/FinalizationHelper.js +49 -0
  3. package/Types.d.ts +178 -21
  4. package/Types.js +7 -0
  5. package/api/ApiStatic.d.ts +16 -0
  6. package/api/ApiStatic.js +26 -0
  7. package/api/ConnectionNative.d.ts +9 -3
  8. package/api/ConnectionNative.js +24 -0
  9. package/api/CryptoApiNative.d.ts +14 -0
  10. package/api/CryptoApiNative.js +30 -0
  11. package/api/EventApiNative.d.ts +20 -0
  12. package/api/EventApiNative.js +36 -0
  13. package/api/ExtKeyNative.d.ts +23 -0
  14. package/api/ExtKeyNative.js +66 -0
  15. package/api/KvdbApiNative.d.ts +33 -0
  16. package/api/KvdbApiNative.js +75 -0
  17. package/assets/driver-web-context.js +1 -1
  18. package/assets/endpoint-wasm-module.js +1 -1
  19. package/assets/endpoint-wasm-module.wasm +0 -0
  20. package/bundle/privmx-endpoint-web.js +1 -1
  21. package/extra/PrivmxClient.d.ts +139 -0
  22. package/extra/PrivmxClient.js +285 -0
  23. package/extra/PublicConnection.d.ts +70 -0
  24. package/extra/PublicConnection.js +118 -0
  25. package/extra/events.d.ts +2 -2
  26. package/extra/inbox.d.ts +3 -3
  27. package/extra/inbox.js +1 -1
  28. package/extra/index.d.ts +10 -8
  29. package/extra/index.js +6 -1
  30. package/index.d.ts +2 -2
  31. package/index.js +3 -1
  32. package/package.json +5 -1
  33. package/service/Connection.d.ts +29 -3
  34. package/service/Connection.js +31 -2
  35. package/service/CryptoApi.d.ts +48 -1
  36. package/service/CryptoApi.js +59 -1
  37. package/service/EndpointFactory.d.ts +24 -3
  38. package/service/EndpointFactory.js +56 -5
  39. package/service/EventApi.d.ts +40 -0
  40. package/service/EventApi.js +60 -0
  41. package/service/ExtKey.d.ts +103 -0
  42. package/service/ExtKey.js +167 -0
  43. package/service/InboxApi.d.ts +9 -9
  44. package/service/InboxApi.js +9 -9
  45. package/service/KvdbApi.d.ts +142 -0
  46. package/service/KvdbApi.js +208 -0
  47. package/service/StoreApi.d.ts +6 -6
  48. package/service/StoreApi.js +6 -6
  49. package/service/ThreadApi.d.ts +6 -6
  50. package/service/ThreadApi.js +6 -6
  51. package/service/UserVerifierInterface.d.ts +18 -0
  52. package/service/UserVerifierInterface.js +2 -0
  53. package/service/index.d.ts +3 -1
  54. package/service/index.js +5 -1
  55. package/assets/privmx-endpoint-web.js +0 -2
@@ -0,0 +1,18 @@
1
+ interface NativeObjInfo {
2
+ ptr: number;
3
+ onFree: () => Promise<void>;
4
+ }
5
+ export declare class FinalizationHelper {
6
+ private wasmLib;
7
+ private static instance;
8
+ private static wasmLib;
9
+ static init(wasmLib: any): void;
10
+ static getInstance(): FinalizationHelper;
11
+ private finalizationRegistry;
12
+ private finalizationQueue;
13
+ private scheduler;
14
+ private constructor();
15
+ private scheduleCleanup;
16
+ register(target: WeakKey, info: NativeObjInfo): void;
17
+ }
18
+ export {};
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FinalizationHelper = void 0;
4
+ const ApiStatic_1 = require("./api/ApiStatic");
5
+ class FinalizationHelper {
6
+ wasmLib;
7
+ static instance;
8
+ static wasmLib;
9
+ static init(wasmLib) {
10
+ FinalizationHelper.wasmLib = wasmLib;
11
+ }
12
+ static getInstance() {
13
+ if (!FinalizationHelper.wasmLib) {
14
+ throw new Error("Initialize first with the WASM Library object");
15
+ }
16
+ if (!this.instance) {
17
+ this.instance = new FinalizationHelper(FinalizationHelper.wasmLib);
18
+ }
19
+ return this.instance;
20
+ }
21
+ finalizationRegistry;
22
+ finalizationQueue = [];
23
+ scheduler = null;
24
+ constructor(wasmLib) {
25
+ this.wasmLib = wasmLib;
26
+ this.finalizationRegistry = new FinalizationRegistry(onCleanup => {
27
+ const api = ApiStatic_1.ApiStatic.getInstance();
28
+ this.finalizationQueue.push(onCleanup.onFree);
29
+ this.scheduleCleanup();
30
+ });
31
+ }
32
+ scheduleCleanup() {
33
+ if (this.scheduler) {
34
+ return;
35
+ }
36
+ this.scheduler = setTimeout(async () => {
37
+ for (const freeCall of this.finalizationQueue) {
38
+ await freeCall();
39
+ }
40
+ this.finalizationQueue = [];
41
+ clearTimeout(this.scheduler);
42
+ this.scheduler = null;
43
+ }, 1000);
44
+ }
45
+ register(target, info) {
46
+ this.finalizationRegistry.register(target, info, target);
47
+ }
48
+ }
49
+ exports.FinalizationHelper = FinalizationHelper;
package/Types.d.ts CHANGED
@@ -8,6 +8,7 @@ This software is Licensed under the PrivMX Free License.
8
8
  See the License for the specific language governing permissions and
9
9
  limitations under the License.
10
10
  */
11
+ import { ExtKey } from "./service/ExtKey";
11
12
  export type SortOrder = "desc" | "asc";
12
13
  /**
13
14
  * Holds Event details
@@ -32,15 +33,18 @@ export interface Event {
32
33
  *
33
34
  * @param {number} skip number of elements to skip from result
34
35
  * @param {number} limit limit of elements to return for query
35
- * @param {SortOrder} sortOrder Order of elements in result. Use "asc" for ascending, "desc" for descening.
36
+ * @param {SortOrder} sortOrder Order of elements in result. Use "asc" for ascending, "desc" for descending.
36
37
  * @param {string} [lastId] id of the element from which query results should start
37
- *
38
+ * @param {string} [sortBy] field name to sort elements by
39
+ * @param {string} [queryAsJson] extra query parameters in serialized JSON
38
40
  */
39
41
  export interface PagingQuery {
40
42
  skip: number;
41
43
  limit: number;
42
44
  sortOrder: SortOrder;
43
45
  lastId?: string;
46
+ sortBy?: string;
47
+ queryAsJson?: string;
44
48
  }
45
49
  /**
46
50
  * Contains results of listing methods
@@ -81,6 +85,19 @@ export interface UserWithPubKey {
81
85
  userId: string;
82
86
  pubKey: string;
83
87
  }
88
+ /**
89
+ * Contains Information about user
90
+ *
91
+ * @type {UserInfo}
92
+ *
93
+ * @param {UserWithPubKey} user User publicKey and userId
94
+ * @param {boolean} isActive is user connected to the Bridge
95
+ *
96
+ */
97
+ export interface UserInfo {
98
+ user: UserWithPubKey;
99
+ isActive: boolean;
100
+ }
84
101
  /**
85
102
  * Holds all available information about a Thread.
86
103
  *
@@ -96,11 +113,11 @@ export interface UserWithPubKey {
96
113
  * @param {string[]} managers list of users (their IDs) with management rights
97
114
  * @param {number} version version number (changes on updates)
98
115
  * @param {number} lastMsgDate timestamp of last posted message
99
- * @param {Uint8Array} publicMeta Thread's public meta data
100
- * @param {Uint8Array} privateMeta Thread's private mata data
116
+ * @param {Uint8Array} publicMeta Thread's public metadata
117
+ * @param {Uint8Array} privateMeta Thread's private metadata
101
118
  * @param {ContainerPolicy} policy Thread's policies
102
119
  * @param {number} messagesCount total number of messages in the Thread
103
- * @param {number} statusCode status code of retrival and decryption of the Thread
120
+ * @param {number} statusCode status code of retrieval and decryption of the Thread
104
121
  *
105
122
  */
106
123
  export interface Thread {
@@ -126,11 +143,11 @@ export interface Thread {
126
143
  * @type {Message}
127
144
  *
128
145
  * @param {ServerMessageInfo} info message's information created by server
129
- * @param {Uint8Array} publicMeta message's public meta data
130
- * @param {Uint8Array} privateMeta message's private mata data
146
+ * @param {Uint8Array} publicMeta message's public metadata
147
+ * @param {Uint8Array} privateMeta message's private metadata
131
148
  * @param {Uint8Array} data message's data
132
149
  * @param {string} authorPubKey public key of an author of the message
133
- * @param {number} statusCode status code of retrival and decryption of the message
150
+ * @param {number} statusCode status code of retrieval and decryption of the message
134
151
  *
135
152
  */
136
153
  export interface Message {
@@ -173,11 +190,11 @@ export interface ServerMessageInfo {
173
190
  * @param {string[]} users list of users (their IDs) with access to the Store
174
191
  * @param {string[]} managers list of users (their IDs) with management rights
175
192
  * @param {number} version version number (changes on updates)
176
- * @param {Uint8Array} publicMeta Store's public meta data
177
- * @param {Uint8Array} privateMeta Store's private mata data
193
+ * @param {Uint8Array} publicMeta Store's public metadata
194
+ * @param {Uint8Array} privateMeta Store's private metadata
178
195
  * @param {ContainerPolicy} policy Store's policies
179
196
  * @param {number} filesCount total number of files in the Store
180
- * @param {number} statusCode status code of retrival and decryption of the Store
197
+ * @param {number} statusCode status code of retrieval and decryption of the Store
181
198
  *
182
199
  */
183
200
  export interface Store {
@@ -203,11 +220,11 @@ export interface Store {
203
220
  * @type {File}
204
221
  *
205
222
  * @param {ServerFileInfo} info file's information created by server
206
- * @param {Uint8Array} publicMeta file's public meta data
207
- * @param {Uint8Array} privateMeta file's private mata data
223
+ * @param {Uint8Array} publicMeta file's public metadata
224
+ * @param {Uint8Array} privateMeta file's private metadata
208
225
  * @param {number} size file's size
209
226
  * @param {string} authorPubKey public key of an author of the file
210
- * @param {number} tatusCode status code of retrival and decryption of the file
227
+ * @param {number} tatusCode status code of retrieval and decryption of the file
211
228
  *
212
229
  */
213
230
  export interface File {
@@ -249,11 +266,11 @@ export interface ServerFileInfo {
249
266
  * @param {string[]} users list of users (their IDs) with access to the Inbox
250
267
  * @param {string[]} managers list of users (their IDs) with management rights
251
268
  * @param {number} version version number (changes on updates)
252
- * @param {Uint8Array} publicMeta Inbox' public meta data
253
- * @param {Uint8Array} privateMeta Inbox' private mata data
269
+ * @param {Uint8Array} publicMeta Inbox' public metadata
270
+ * @param {Uint8Array} privateMeta Inbox' private metadata
254
271
  * @param {FilesConfig} filesConfig Inbox' files configuration
255
272
  * @param {ContainerWithoutItemPolicy} policy Inbox' policies
256
- * @param {number} statusCode status code of retrival and decryption of the Inbox
273
+ * @param {number} statusCode status code of retrieval and decryption of the Inbox
257
274
  *
258
275
  */
259
276
  export interface Inbox {
@@ -279,7 +296,7 @@ export interface Inbox {
279
296
  *
280
297
  * @param {string} inboxId ID of the Inbox
281
298
  * @param {number} version version of the Inbox
282
- * @param {Uint8Array} publicMeta Inbox' public meta data
299
+ * @param {Uint8Array} publicMeta Inbox' public metadata
283
300
  *
284
301
  */
285
302
  export interface InboxPublicView {
@@ -298,7 +315,7 @@ export interface InboxPublicView {
298
315
  * @param {File[]} files list of files attached to the entry
299
316
  * @param {string} authorPubKey public key of the author of an entry
300
317
  * @param {number} createDate Inbox entry creation timestamp
301
- * @param {number} statusCode status code of retrival and decryption of the Inbox entry
318
+ * @param {number} statusCode status code of retrieval and decryption of the Inbox entry
302
319
  */
303
320
  export interface InboxEntry {
304
321
  entryId: string;
@@ -314,8 +331,8 @@ export interface InboxEntry {
314
331
  *
315
332
  * @type {FilesConfig}
316
333
  *
317
- * @param {int64_t} minCount minimum numer of files required when sending inbox entry
318
- * @param {int64_t} maxCount maximum numer of files allowed when sending inbox entry
334
+ * @param {int64_t} minCount minimum number of files required when sending inbox entry
335
+ * @param {int64_t} maxCount maximum number of files allowed when sending inbox entry
319
336
  * @param {int64_t} maxFileSize maximum file size allowed when sending inbox entry
320
337
  * @param {int64_t} maxWholeUploadSize maximum size of all files in total allowed when sending inbox entry
321
338
  *
@@ -326,6 +343,93 @@ export interface FilesConfig {
326
343
  maxFileSize: number;
327
344
  maxWholeUploadSize: number;
328
345
  }
346
+ /**
347
+ * Holds all available information about a KVDB.
348
+ *
349
+ * @type {Kvdb}
350
+ *
351
+ * @param {string} contextId ID of the Context
352
+ * @param {string} kvdbId ID ot the KVDB
353
+ * @param {number} createDate KVDB creation timestamp
354
+ * @param {string} author ID of the user who created the KVDB
355
+ * @param {number} lastModificationDate KVDB last modification timestamp
356
+ * @param {string} lastModifier ID of the user who last modified the KVDB
357
+ * @param {string[]} users list of users (their IDs) with access to the KVDB
358
+ * @param {string[]} managers list of users (their IDs) with management rights
359
+ * @param {number} version version number (changes on updates)
360
+ * @param {number} lastMsgDate timestamp of last posted message
361
+ * @param {Uint8Array} publicMeta KVDB's public meta data
362
+ * @param {Uint8Array} privateMeta KVDB's private mata data
363
+ * @param {ContainerPolicy} policy KVDB's policies
364
+ * @param {number} entries total number of messages in the KVDB
365
+ * @param {number} statusCode status code of retrival and decryption of the KVDB
366
+ * @param {number} schemaVersion Version of the KVDB data structure and how it is encoded/encrypted
367
+ */
368
+ export interface Kvdb {
369
+ contextId: string;
370
+ kvdbId: string;
371
+ createDate: number;
372
+ creator: string;
373
+ lastModificationDate: number;
374
+ lastModifier: string;
375
+ users: string[];
376
+ managers: string[];
377
+ version: number;
378
+ lastMsgDate: number;
379
+ publicMeta: Uint8Array;
380
+ privateMeta: Uint8Array;
381
+ policy: ContainerPolicy;
382
+ entries: number;
383
+ statusCode: number;
384
+ schemaVersion: number;
385
+ }
386
+ /**
387
+ * Holds information about the KvdbEntry.
388
+ *
389
+ * @type {KvdbEntry}
390
+ *
391
+ * @param {ServerKvdbEntryInfo} info KVDB entry's information created by server
392
+ * @param {Uint8Array} publicMeta KVDB entry's public meta data
393
+ * @param {Uint8Array} privateMeta KVDB entry's private mata data
394
+ * @param {Uint8Array} data KVDB entry's data
395
+ * @param {string} authorPubKey public key of an author of the KVDB entry
396
+ * @param {number} version version of the KVDB entry
397
+ * @param {number} statusCode status code of retrival and decryption of the KVDB entry
398
+ * @param {number} schemaVersion Version of the KVDB entry data structure and how it is encoded/encrypted
399
+ */
400
+ export interface KvdbEntry {
401
+ info: ServerKvdbEntryInfo;
402
+ publicMeta: Uint8Array;
403
+ privateMeta: Uint8Array;
404
+ data: Uint8Array;
405
+ authorPubKey: string;
406
+ version: number;
407
+ statusCode: number;
408
+ schemaVersion: number;
409
+ }
410
+ /**
411
+ * Holds message's information created by server
412
+ *
413
+ * @type {ServerKvdbEntryInfo}
414
+ *
415
+ * @param {string} kvdbId ID of the kvdb
416
+ * @param {string} key KVDB entry's key
417
+ * @param {number} createDate entry creation timestamp
418
+ * @param {string} author ID of the user who created the entry
419
+ *
420
+ */
421
+ export interface ServerKvdbEntryInfo {
422
+ kvdbId: string;
423
+ key: string;
424
+ createDate: number;
425
+ author: string;
426
+ }
427
+ /**
428
+ * Holds information about the entries deletion result.
429
+ *
430
+ * @type {DeleteEntriesResult}
431
+ */
432
+ export type DeleteEntriesResult = Map<string, boolean>;
329
433
  /**
330
434
  * Holds Container policies settings
331
435
  *
@@ -405,3 +509,56 @@ export interface Error {
405
509
  description: string;
406
510
  full: string;
407
511
  }
512
+ /**
513
+ * @param {string} mnemonic BIP-39 mnemonic
514
+ * @param {ExtKey} extKey Ecc Key
515
+ * @param {Uint8Array} entropy BIP-39 entropy
516
+ */
517
+ export interface BIP39 {
518
+ mnemonic: string;
519
+ entropy: Uint8Array;
520
+ extKey: ExtKey;
521
+ }
522
+ /**
523
+ *
524
+ * @type {VerificationRequest}
525
+ *
526
+ * @param {string} contextId Id of the Context
527
+ * @param {string} senderId Id of the sender
528
+ * @param {string} senderPubKey Public key of the sender
529
+ * @param {number} date The data creation date
530
+ * @param {BridgeIdentity} bridgeIdentity Bridge Identity
531
+ */
532
+ export interface VerificationRequest {
533
+ contextId: string;
534
+ senderId: string;
535
+ senderPubKey: string;
536
+ date: number;
537
+ bridgeIdentity?: BridgeIdentity;
538
+ }
539
+ /**
540
+ * Bridge server identification details.
541
+ *
542
+ * @type {BridgeIdentity}
543
+ *
544
+ * @param {string} url Bridge URL
545
+ * @param {string} pubKey Bridge public Key
546
+ * @param {string} instanceId Bridge instance Id given by PKI
547
+ */
548
+ export interface BridgeIdentity {
549
+ url: string;
550
+ pubKey?: string;
551
+ instanceId?: string;
552
+ }
553
+ /**
554
+ * PKI Verification options
555
+ *
556
+ * @type {PKIVerificationOptions}
557
+ *
558
+ * @param {string} [bridgePubKey] Bridge public key
559
+ * @param {string} [bridgeInstanceId] Bridge instance Id given by PKI
560
+ */
561
+ export interface PKIVerificationOptions {
562
+ bridgePubKey?: string;
563
+ bridgeInstanceId?: string;
564
+ }
package/Types.js CHANGED
@@ -25,3 +25,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
25
25
  ;
26
26
  ;
27
27
  ;
28
+ ;
29
+ ;
30
+ ;
31
+ ;
32
+ ;
33
+ ;
34
+ ;
@@ -0,0 +1,16 @@
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 { Api } from "./Api";
12
+ export declare class ApiStatic {
13
+ private static instance;
14
+ static init(api: Api): void;
15
+ static getInstance(): Api;
16
+ }
@@ -0,0 +1,26 @@
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.ApiStatic = void 0;
14
+ class ApiStatic {
15
+ static instance;
16
+ static init(api) {
17
+ this.instance = api;
18
+ }
19
+ static getInstance() {
20
+ if (!this.instance) {
21
+ throw new Error("API Static not initialized");
22
+ }
23
+ return this.instance;
24
+ }
25
+ }
26
+ exports.ApiStatic = ApiStatic;
@@ -8,17 +8,23 @@ This software is Licensed under the PrivMX Free License.
8
8
  See the License for the specific language governing permissions and
9
9
  limitations under the License.
10
10
  */
11
- import { PagingQuery, PagingList, Context } from "../Types";
11
+ import { UserVerifierInterface } from "../service/UserVerifierInterface";
12
+ import { PagingQuery, PagingList, Context, UserInfo, PKIVerificationOptions } from "../Types";
12
13
  import { BaseNative } from "./BaseNative";
13
14
  export declare class ConnectionNative extends BaseNative {
14
15
  protected lastConnectionId: number;
16
+ protected userVerifierPtr: number;
15
17
  protected newApi(_connectionPtr: number): Promise<number>;
16
18
  deleteApi(ptr: number): Promise<void>;
17
19
  newConnection(): Promise<number>;
18
20
  deleteConnection(ptr: number): Promise<void>;
19
- connect(ptr: number, args: [string, string, string]): Promise<void>;
20
- connectPublic(ptr: number, args: [string, string]): Promise<void>;
21
+ connect(ptr: number, args: [string, string, string, PKIVerificationOptions]): Promise<void>;
22
+ connectPublic(ptr: number, args: [string, string, PKIVerificationOptions]): Promise<void>;
21
23
  getConnectionId(ptr: number, args: []): Promise<number>;
22
24
  listContexts(ptr: number, args: [PagingQuery]): Promise<PagingList<Context>>;
25
+ getContextUsers(ptr: number, args: [string]): Promise<UserInfo[]>;
23
26
  disconnect(ptr: number, args: []): Promise<void>;
27
+ setUserVerifier(_ptr: number, args: [number, UserVerifierInterface]): Promise<void>;
28
+ protected newUserVerifierInterface(connectionPtr: number): Promise<number>;
29
+ protected deleteUserVerifierInterface(ptr: number): Promise<void>;
24
30
  }
@@ -14,6 +14,7 @@ exports.ConnectionNative = void 0;
14
14
  const BaseNative_1 = require("./BaseNative");
15
15
  class ConnectionNative extends BaseNative_1.BaseNative {
16
16
  lastConnectionId = -1;
17
+ userVerifierPtr = -1;
17
18
  async newApi(_connectionPtr) {
18
19
  throw new Error("Use the newConnection() - specialized version of method instead.");
19
20
  }
@@ -44,8 +45,31 @@ class ConnectionNative extends BaseNative_1.BaseNative {
44
45
  async listContexts(ptr, args) {
45
46
  return this.runAsync((taskId) => this.api.lib.Connection_listContexts(taskId, ptr, args));
46
47
  }
48
+ async getContextUsers(ptr, args) {
49
+ return this.runAsync((taskId) => this.api.lib.Connection_getContextUsers(taskId, ptr, args));
50
+ }
47
51
  async disconnect(ptr, args) {
48
52
  await this.runAsync((taskId) => this.api.lib.Connection_disconnect(taskId, ptr, args));
49
53
  }
54
+ async setUserVerifier(_ptr, args) {
55
+ if (this.userVerifierPtr > -1) {
56
+ await this.deleteUserVerifierInterface(this.userVerifierPtr);
57
+ this.userVerifierPtr = -1;
58
+ }
59
+ const [connectionPtr, verifierInterface] = args;
60
+ window.userVierifier_verify = async (request) => {
61
+ if (verifierInterface && typeof verifierInterface.verify === "function") {
62
+ return verifierInterface.verify(request);
63
+ }
64
+ throw new Error("Call on UserVerifierInterface with missing implementation");
65
+ };
66
+ this.userVerifierPtr = await this.runAsync((taskId) => this.api.lib.Connection_newUserVerifierInterface(taskId, connectionPtr));
67
+ }
68
+ async newUserVerifierInterface(connectionPtr) {
69
+ return this.runAsync((taskId) => this.api.lib.Connection_newUserVerifierInterface(taskId, connectionPtr));
70
+ }
71
+ async deleteUserVerifierInterface(ptr) {
72
+ await this.runAsync((taskId) => this.api.lib.Connection_deleteUserVerifierInterface(taskId, ptr));
73
+ }
50
74
  }
51
75
  exports.ConnectionNative = ConnectionNative;
@@ -8,7 +8,14 @@ This software is Licensed under the PrivMX Free License.
8
8
  See the License for the specific language governing permissions and
9
9
  limitations under the License.
10
10
  */
11
+ import { BIP39 } from "../Types";
11
12
  import { BaseNative } from "./BaseNative";
13
+ import { ExtKeyNativePtr } from "./ExtKeyNative";
14
+ export interface BIP39Native {
15
+ mnemonic: string;
16
+ extKey: ExtKeyNativePtr;
17
+ entropy: Uint8Array;
18
+ }
12
19
  export declare class CryptoApiNative extends BaseNative {
13
20
  newApi(): Promise<number>;
14
21
  deleteApi(ptr: number): Promise<void>;
@@ -23,4 +30,11 @@ export declare class CryptoApiNative extends BaseNative {
23
30
  encryptDataSymmetric(ptr: number, args: [Uint8Array, Uint8Array]): Promise<Uint8Array>;
24
31
  decryptDataSymmetric(ptr: number, args: [Uint8Array, Uint8Array]): Promise<Uint8Array>;
25
32
  convertPEMKeytoWIFKey(ptr: number, args: [string]): Promise<string>;
33
+ generateBip39(ptr: number, args: [number, string]): Promise<BIP39>;
34
+ fromMnemonic(ptr: number, args: [string, string]): Promise<BIP39>;
35
+ fromEntropy(ptr: number, args: [Uint8Array, string]): Promise<BIP39>;
36
+ entropyToMnemonic(ptr: number, args: [Uint8Array]): Promise<string>;
37
+ mnemonicToEntropy(ptr: number, args: [string]): Promise<Uint8Array>;
38
+ mnemonicToSeed(ptr: number, args: [string, string]): Promise<Uint8Array>;
39
+ private convertBIP;
26
40
  }
@@ -11,7 +11,9 @@ limitations under the License.
11
11
  */
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  exports.CryptoApiNative = void 0;
14
+ const ExtKey_1 = require("../service/ExtKey");
14
15
  const BaseNative_1 = require("./BaseNative");
16
+ ;
15
17
  class CryptoApiNative extends BaseNative_1.BaseNative {
16
18
  async newApi() {
17
19
  return this.runAsync((taskId) => this.api.lib.CryptoApi_newCryptoApi(taskId));
@@ -53,5 +55,33 @@ class CryptoApiNative extends BaseNative_1.BaseNative {
53
55
  async convertPEMKeytoWIFKey(ptr, args) {
54
56
  return this.runAsync((taskId) => this.api.lib.CryptoApi_convertPEMKeytoWIFKey(taskId, ptr, args));
55
57
  }
58
+ async generateBip39(ptr, args) {
59
+ const bipNative = await this.runAsync((taskId) => this.api.lib.CryptoApi_generateBip39(taskId, ptr, args));
60
+ return this.convertBIP(bipNative);
61
+ }
62
+ async fromMnemonic(ptr, args) {
63
+ const bipNative = await this.runAsync((taskId) => this.api.lib.CryptoApi_fromMnemonic(taskId, ptr, args));
64
+ return this.convertBIP(bipNative);
65
+ }
66
+ async fromEntropy(ptr, args) {
67
+ const bipNative = await this.runAsync((taskId) => this.api.lib.CryptoApi_fromEntropy(taskId, ptr, args));
68
+ return this.convertBIP(bipNative);
69
+ }
70
+ async entropyToMnemonic(ptr, args) {
71
+ return this.runAsync((taskId) => this.api.lib.CryptoApi_entropyToMnemonic(taskId, ptr, args));
72
+ }
73
+ async mnemonicToEntropy(ptr, args) {
74
+ return this.runAsync((taskId) => this.api.lib.CryptoApi_mnemonicToEntropy(taskId, ptr, args));
75
+ }
76
+ async mnemonicToSeed(ptr, args) {
77
+ return this.runAsync((taskId) => this.api.lib.CryptoApi_mnemonicToSeed(taskId, ptr, args));
78
+ }
79
+ convertBIP(bipNative) {
80
+ return {
81
+ mnemonic: bipNative.mnemonic,
82
+ entropy: bipNative.entropy,
83
+ extKey: ExtKey_1.ExtKey.fromPtr(bipNative.extKey)
84
+ };
85
+ }
56
86
  }
57
87
  exports.CryptoApiNative = CryptoApiNative;
@@ -0,0 +1,20 @@
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 { UserWithPubKey } from "../Types";
12
+ import { BaseNative } from "./BaseNative";
13
+ export declare class EventApiNative extends BaseNative {
14
+ newApi(connectionPtr: number): Promise<number>;
15
+ deleteApi(ptr: number): Promise<void>;
16
+ create(ptr: number, args: []): Promise<void>;
17
+ emitEvent(ptr: number, args: [string, string, Uint8Array, UserWithPubKey[]]): Promise<void>;
18
+ subscribeForCustomEvents(ptr: number, args: [string, string]): Promise<void>;
19
+ unsubscribeFromCustomEvents(ptr: number, args: [string, string]): Promise<void>;
20
+ }
@@ -0,0 +1,36 @@
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.EventApiNative = void 0;
14
+ const BaseNative_1 = require("./BaseNative");
15
+ class EventApiNative extends BaseNative_1.BaseNative {
16
+ async newApi(connectionPtr) {
17
+ return this.runAsync((taskId) => this.api.lib.EventApi_newEventApi(taskId, connectionPtr));
18
+ }
19
+ async deleteApi(ptr) {
20
+ await this.runAsync((taskId) => this.api.lib.EventApi_deleteEventApi(taskId, ptr));
21
+ this.deleteApiRef();
22
+ }
23
+ async create(ptr, args) {
24
+ return this.runAsync((taskId) => this.api.lib.EventApi_create(taskId, ptr, args));
25
+ }
26
+ async emitEvent(ptr, args) {
27
+ return this.runAsync((taskId) => this.api.lib.EventApi_emitEvent(taskId, ptr, args));
28
+ }
29
+ async subscribeForCustomEvents(ptr, args) {
30
+ return this.runAsync((taskId) => this.api.lib.EventApi_subscribeForCustomEvents(taskId, ptr, args));
31
+ }
32
+ async unsubscribeFromCustomEvents(ptr, args) {
33
+ return this.runAsync((taskId) => this.api.lib.EventApi_unsubscribeFromCustomEvents(taskId, ptr, args));
34
+ }
35
+ }
36
+ exports.EventApiNative = EventApiNative;
@@ -0,0 +1,23 @@
1
+ import { BaseNative } from "./BaseNative";
2
+ export type ExtKeyNativePtr = number & {
3
+ __extKeyNativePtr: never;
4
+ };
5
+ export declare class ExtKeyNative extends BaseNative {
6
+ protected newApi(): Promise<number>;
7
+ deleteApi(ptr: number): Promise<void>;
8
+ deleteExtKey(ptr: number): Promise<void>;
9
+ static fromSeed(args: [Uint8Array]): Promise<ExtKeyNativePtr>;
10
+ static fromBase58(args: [string]): Promise<ExtKeyNativePtr>;
11
+ static generateRandom(args: []): Promise<ExtKeyNativePtr>;
12
+ derive(ptr: number, args: [number]): Promise<ExtKeyNativePtr>;
13
+ deriveHardened(ptr: number, args: [number]): Promise<ExtKeyNativePtr>;
14
+ getPrivatePartAsBase58(ptr: number, args: []): Promise<string>;
15
+ getPublicPartAsBase58(ptr: number, args: []): Promise<string>;
16
+ getPrivateKey(ptr: number, args: []): Promise<string>;
17
+ getPublicKey(ptr: number, args: []): Promise<string>;
18
+ getPrivateEncKey(ptr: number, args: []): Promise<Uint8Array>;
19
+ getPublicKeyAsBase58Address(ptr: number, args: []): Promise<string>;
20
+ getChainCode(ptr: number, args: []): Promise<Uint8Array>;
21
+ verifyCompactSignatureWithHash(ptr: number, args: [Uint8Array, Uint8Array]): Promise<boolean>;
22
+ isPrivate(ptr: number, args: []): Promise<boolean>;
23
+ }