@simplito/privmx-webendpoint 2.2.9 → 2.3.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.
- package/FinalizationHelper.d.ts +18 -0
- package/FinalizationHelper.js +49 -0
- package/Types.d.ts +77 -21
- package/Types.js +3 -0
- package/api/ApiStatic.d.ts +16 -0
- package/api/ApiStatic.js +26 -0
- package/api/ConnectionNative.d.ts +7 -1
- package/api/ConnectionNative.js +24 -0
- package/api/CryptoApiNative.d.ts +14 -0
- package/api/CryptoApiNative.js +30 -0
- package/api/EventApiNative.d.ts +20 -0
- package/api/EventApiNative.js +36 -0
- package/api/ExtKeyNative.d.ts +23 -0
- package/api/ExtKeyNative.js +66 -0
- package/assets/driver-web-context.js +1 -1
- package/assets/endpoint-wasm-module.js +1 -1
- package/assets/endpoint-wasm-module.wasm +0 -0
- package/bundle/privmx-endpoint-web.js +1 -1
- package/extra/PrivmxClient.d.ts +133 -0
- package/extra/PrivmxClient.js +271 -0
- package/extra/PublicConnection.d.ts +70 -0
- package/extra/PublicConnection.js +118 -0
- package/extra/events.d.ts +2 -2
- package/extra/inbox.d.ts +3 -3
- package/extra/inbox.js +1 -1
- package/extra/index.d.ts +10 -8
- package/extra/index.js +6 -1
- package/index.d.ts +2 -2
- package/index.js +2 -1
- package/package.json +5 -1
- package/service/Connection.d.ts +27 -1
- package/service/Connection.js +29 -0
- package/service/CryptoApi.d.ts +48 -1
- package/service/CryptoApi.js +59 -1
- package/service/EndpointFactory.d.ts +9 -0
- package/service/EndpointFactory.js +24 -0
- package/service/EventApi.d.ts +40 -0
- package/service/EventApi.js +60 -0
- package/service/ExtKey.d.ts +103 -0
- package/service/ExtKey.js +167 -0
- package/service/UserVerifierInterface.d.ts +18 -0
- package/service/UserVerifierInterface.js +2 -0
- package/service/index.d.ts +2 -1
- package/service/index.js +3 -1
- 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,16 @@ 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
|
|
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} [queryAsJson] extra query parameters in serialized JSON
|
|
38
39
|
*/
|
|
39
40
|
export interface PagingQuery {
|
|
40
41
|
skip: number;
|
|
41
42
|
limit: number;
|
|
42
43
|
sortOrder: SortOrder;
|
|
43
44
|
lastId?: string;
|
|
45
|
+
queryAsJson?: string;
|
|
44
46
|
}
|
|
45
47
|
/**
|
|
46
48
|
* Contains results of listing methods
|
|
@@ -81,6 +83,19 @@ export interface UserWithPubKey {
|
|
|
81
83
|
userId: string;
|
|
82
84
|
pubKey: string;
|
|
83
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* Contains Information about user
|
|
88
|
+
*
|
|
89
|
+
* @type {UserInfo}
|
|
90
|
+
*
|
|
91
|
+
* @param {UserWithPubKey} user User publicKey and userId
|
|
92
|
+
* @param {boolean} isActive is user connected to the Bridge
|
|
93
|
+
*
|
|
94
|
+
*/
|
|
95
|
+
export interface UserInfo {
|
|
96
|
+
user: UserWithPubKey;
|
|
97
|
+
isActive: boolean;
|
|
98
|
+
}
|
|
84
99
|
/**
|
|
85
100
|
* Holds all available information about a Thread.
|
|
86
101
|
*
|
|
@@ -96,11 +111,11 @@ export interface UserWithPubKey {
|
|
|
96
111
|
* @param {string[]} managers list of users (their IDs) with management rights
|
|
97
112
|
* @param {number} version version number (changes on updates)
|
|
98
113
|
* @param {number} lastMsgDate timestamp of last posted message
|
|
99
|
-
* @param {Uint8Array} publicMeta Thread's public
|
|
100
|
-
* @param {Uint8Array} privateMeta Thread's private
|
|
114
|
+
* @param {Uint8Array} publicMeta Thread's public metadata
|
|
115
|
+
* @param {Uint8Array} privateMeta Thread's private metadata
|
|
101
116
|
* @param {ContainerPolicy} policy Thread's policies
|
|
102
117
|
* @param {number} messagesCount total number of messages in the Thread
|
|
103
|
-
* @param {number} statusCode status code of
|
|
118
|
+
* @param {number} statusCode status code of retrieval and decryption of the Thread
|
|
104
119
|
*
|
|
105
120
|
*/
|
|
106
121
|
export interface Thread {
|
|
@@ -126,11 +141,11 @@ export interface Thread {
|
|
|
126
141
|
* @type {Message}
|
|
127
142
|
*
|
|
128
143
|
* @param {ServerMessageInfo} info message's information created by server
|
|
129
|
-
* @param {Uint8Array} publicMeta message's public
|
|
130
|
-
* @param {Uint8Array} privateMeta message's private
|
|
144
|
+
* @param {Uint8Array} publicMeta message's public metadata
|
|
145
|
+
* @param {Uint8Array} privateMeta message's private metadata
|
|
131
146
|
* @param {Uint8Array} data message's data
|
|
132
147
|
* @param {string} authorPubKey public key of an author of the message
|
|
133
|
-
* @param {number} statusCode status code of
|
|
148
|
+
* @param {number} statusCode status code of retrieval and decryption of the message
|
|
134
149
|
*
|
|
135
150
|
*/
|
|
136
151
|
export interface Message {
|
|
@@ -173,11 +188,11 @@ export interface ServerMessageInfo {
|
|
|
173
188
|
* @param {string[]} users list of users (their IDs) with access to the Store
|
|
174
189
|
* @param {string[]} managers list of users (their IDs) with management rights
|
|
175
190
|
* @param {number} version version number (changes on updates)
|
|
176
|
-
* @param {Uint8Array} publicMeta Store's public
|
|
177
|
-
* @param {Uint8Array} privateMeta Store's private
|
|
191
|
+
* @param {Uint8Array} publicMeta Store's public metadata
|
|
192
|
+
* @param {Uint8Array} privateMeta Store's private metadata
|
|
178
193
|
* @param {ContainerPolicy} policy Store's policies
|
|
179
194
|
* @param {number} filesCount total number of files in the Store
|
|
180
|
-
* @param {number} statusCode status code of
|
|
195
|
+
* @param {number} statusCode status code of retrieval and decryption of the Store
|
|
181
196
|
*
|
|
182
197
|
*/
|
|
183
198
|
export interface Store {
|
|
@@ -203,11 +218,11 @@ export interface Store {
|
|
|
203
218
|
* @type {File}
|
|
204
219
|
*
|
|
205
220
|
* @param {ServerFileInfo} info file's information created by server
|
|
206
|
-
* @param {Uint8Array} publicMeta file's public
|
|
207
|
-
* @param {Uint8Array} privateMeta file's private
|
|
221
|
+
* @param {Uint8Array} publicMeta file's public metadata
|
|
222
|
+
* @param {Uint8Array} privateMeta file's private metadata
|
|
208
223
|
* @param {number} size file's size
|
|
209
224
|
* @param {string} authorPubKey public key of an author of the file
|
|
210
|
-
* @param {number} tatusCode status code of
|
|
225
|
+
* @param {number} tatusCode status code of retrieval and decryption of the file
|
|
211
226
|
*
|
|
212
227
|
*/
|
|
213
228
|
export interface File {
|
|
@@ -249,11 +264,11 @@ export interface ServerFileInfo {
|
|
|
249
264
|
* @param {string[]} users list of users (their IDs) with access to the Inbox
|
|
250
265
|
* @param {string[]} managers list of users (their IDs) with management rights
|
|
251
266
|
* @param {number} version version number (changes on updates)
|
|
252
|
-
* @param {Uint8Array} publicMeta Inbox' public
|
|
253
|
-
* @param {Uint8Array} privateMeta Inbox' private
|
|
267
|
+
* @param {Uint8Array} publicMeta Inbox' public metadata
|
|
268
|
+
* @param {Uint8Array} privateMeta Inbox' private metadata
|
|
254
269
|
* @param {FilesConfig} filesConfig Inbox' files configuration
|
|
255
270
|
* @param {ContainerWithoutItemPolicy} policy Inbox' policies
|
|
256
|
-
* @param {number} statusCode status code of
|
|
271
|
+
* @param {number} statusCode status code of retrieval and decryption of the Inbox
|
|
257
272
|
*
|
|
258
273
|
*/
|
|
259
274
|
export interface Inbox {
|
|
@@ -279,7 +294,7 @@ export interface Inbox {
|
|
|
279
294
|
*
|
|
280
295
|
* @param {string} inboxId ID of the Inbox
|
|
281
296
|
* @param {number} version version of the Inbox
|
|
282
|
-
* @param {Uint8Array} publicMeta Inbox' public
|
|
297
|
+
* @param {Uint8Array} publicMeta Inbox' public metadata
|
|
283
298
|
*
|
|
284
299
|
*/
|
|
285
300
|
export interface InboxPublicView {
|
|
@@ -298,7 +313,7 @@ export interface InboxPublicView {
|
|
|
298
313
|
* @param {File[]} files list of files attached to the entry
|
|
299
314
|
* @param {string} authorPubKey public key of the author of an entry
|
|
300
315
|
* @param {number} createDate Inbox entry creation timestamp
|
|
301
|
-
* @param {number} statusCode status code of
|
|
316
|
+
* @param {number} statusCode status code of retrieval and decryption of the Inbox entry
|
|
302
317
|
*/
|
|
303
318
|
export interface InboxEntry {
|
|
304
319
|
entryId: string;
|
|
@@ -314,8 +329,8 @@ export interface InboxEntry {
|
|
|
314
329
|
*
|
|
315
330
|
* @type {FilesConfig}
|
|
316
331
|
*
|
|
317
|
-
* @param {int64_t} minCount minimum
|
|
318
|
-
* @param {int64_t} maxCount maximum
|
|
332
|
+
* @param {int64_t} minCount minimum number of files required when sending inbox entry
|
|
333
|
+
* @param {int64_t} maxCount maximum number of files allowed when sending inbox entry
|
|
319
334
|
* @param {int64_t} maxFileSize maximum file size allowed when sending inbox entry
|
|
320
335
|
* @param {int64_t} maxWholeUploadSize maximum size of all files in total allowed when sending inbox entry
|
|
321
336
|
*
|
|
@@ -405,3 +420,44 @@ export interface Error {
|
|
|
405
420
|
description: string;
|
|
406
421
|
full: string;
|
|
407
422
|
}
|
|
423
|
+
/**
|
|
424
|
+
* @param {string} mnemonic BIP-39 mnemonic
|
|
425
|
+
* @param {ExtKey} extKey Ecc Key
|
|
426
|
+
* @param {Uint8Array} entropy BIP-39 entropy
|
|
427
|
+
*/
|
|
428
|
+
export interface BIP39 {
|
|
429
|
+
mnemonic: string;
|
|
430
|
+
entropy: Uint8Array;
|
|
431
|
+
extKey: ExtKey;
|
|
432
|
+
}
|
|
433
|
+
/**
|
|
434
|
+
*
|
|
435
|
+
* @type {VerificationRequest}
|
|
436
|
+
*
|
|
437
|
+
* @param {string} contextId Id of the Context
|
|
438
|
+
* @param {string} senderId Id of the sender
|
|
439
|
+
* @param {string} senderPubKey Public key of the sender
|
|
440
|
+
* @param {number} date The data creation date
|
|
441
|
+
* @param {BridgeIdentity} bridgeIdentity Bridge Identity
|
|
442
|
+
*/
|
|
443
|
+
export interface VerificationRequest {
|
|
444
|
+
contextId: string;
|
|
445
|
+
senderId: string;
|
|
446
|
+
senderPubKey: string;
|
|
447
|
+
date: number;
|
|
448
|
+
bridgeIdentity?: BridgeIdentity;
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* Bridge server identification details.
|
|
452
|
+
*
|
|
453
|
+
* @type {BridgeIdentity}
|
|
454
|
+
*
|
|
455
|
+
* @param {string} url Bridge URL
|
|
456
|
+
* @param {string} pubKey Bridge public Key
|
|
457
|
+
* @param {string} instanceId Bridge instance Id given by PKI
|
|
458
|
+
*/
|
|
459
|
+
export interface BridgeIdentity {
|
|
460
|
+
url: string;
|
|
461
|
+
pubKey?: string;
|
|
462
|
+
instanceId?: string;
|
|
463
|
+
}
|
package/Types.js
CHANGED
|
@@ -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
|
+
}
|
package/api/ApiStatic.js
ADDED
|
@@ -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,10 +8,12 @@ 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 {
|
|
11
|
+
import { UserVerifierInterface } from "../service/UserVerifierInterface";
|
|
12
|
+
import { PagingQuery, PagingList, Context, UserInfo } 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>;
|
|
@@ -20,5 +22,9 @@ export declare class ConnectionNative extends BaseNative {
|
|
|
20
22
|
connectPublic(ptr: number, args: [string, string]): 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
|
}
|
package/api/ConnectionNative.js
CHANGED
|
@@ -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;
|
package/api/CryptoApiNative.d.ts
CHANGED
|
@@ -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
|
}
|
package/api/CryptoApiNative.js
CHANGED
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExtKeyNative = void 0;
|
|
4
|
+
const ApiStatic_1 = require("./ApiStatic");
|
|
5
|
+
const BaseNative_1 = require("./BaseNative");
|
|
6
|
+
class ExtKeyNative extends BaseNative_1.BaseNative {
|
|
7
|
+
async newApi() {
|
|
8
|
+
throw new Error("Use the specialized version of method instead.");
|
|
9
|
+
}
|
|
10
|
+
async deleteApi(ptr) {
|
|
11
|
+
return this.runAsync((taskId) => this.api.lib.ExtKey_deleteExtKey(taskId, ptr));
|
|
12
|
+
}
|
|
13
|
+
async deleteExtKey(ptr) {
|
|
14
|
+
return this.runAsync((taskId) => this.api.lib.ExtKey_deleteExtKey(taskId, ptr));
|
|
15
|
+
}
|
|
16
|
+
static async fromSeed(args) {
|
|
17
|
+
const api = ApiStatic_1.ApiStatic.getInstance();
|
|
18
|
+
return api.runAsync((taskId) => api.lib.ExtKey_fromSeed(taskId, args));
|
|
19
|
+
}
|
|
20
|
+
static async fromBase58(args) {
|
|
21
|
+
// base58: string
|
|
22
|
+
const api = ApiStatic_1.ApiStatic.getInstance();
|
|
23
|
+
return api.runAsync((taskId) => api.lib.ExtKey_fromBase58(taskId, args));
|
|
24
|
+
}
|
|
25
|
+
static async generateRandom(args) {
|
|
26
|
+
const api = ApiStatic_1.ApiStatic.getInstance();
|
|
27
|
+
return api.runAsync((taskId) => api.lib.ExtKey_generateRandom(taskId, args));
|
|
28
|
+
}
|
|
29
|
+
async derive(ptr, args) {
|
|
30
|
+
// index: number
|
|
31
|
+
return this.runAsync((taskId) => this.api.lib.ExtKey_derive(taskId, ptr, args));
|
|
32
|
+
}
|
|
33
|
+
async deriveHardened(ptr, args) {
|
|
34
|
+
// index: number
|
|
35
|
+
return this.runAsync((taskId) => this.api.lib.ExtKey_deriveHardened(taskId, ptr, args));
|
|
36
|
+
}
|
|
37
|
+
getPrivatePartAsBase58(ptr, args) {
|
|
38
|
+
return this.runAsync((taskId) => this.api.lib.ExtKey_getPrivatePartAsBase58(taskId, ptr, args));
|
|
39
|
+
}
|
|
40
|
+
getPublicPartAsBase58(ptr, args) {
|
|
41
|
+
return this.runAsync((taskId) => this.api.lib.ExtKey_getPublicPartAsBase58(taskId, ptr, args));
|
|
42
|
+
}
|
|
43
|
+
getPrivateKey(ptr, args) {
|
|
44
|
+
return this.runAsync((taskId) => this.api.lib.ExtKey_getPrivateKey(taskId, ptr, args));
|
|
45
|
+
}
|
|
46
|
+
getPublicKey(ptr, args) {
|
|
47
|
+
return this.runAsync((taskId) => this.api.lib.ExtKey_getPublicKey(taskId, ptr, args));
|
|
48
|
+
}
|
|
49
|
+
getPrivateEncKey(ptr, args) {
|
|
50
|
+
return this.runAsync((taskId) => this.api.lib.ExtKey_getPrivateEncKey(taskId, ptr, args));
|
|
51
|
+
}
|
|
52
|
+
getPublicKeyAsBase58Address(ptr, args) {
|
|
53
|
+
return this.runAsync((taskId) => this.api.lib.ExtKey_getPublicKeyAsBase58Address(taskId, ptr, args));
|
|
54
|
+
}
|
|
55
|
+
getChainCode(ptr, args) {
|
|
56
|
+
return this.runAsync((taskId) => this.api.lib.ExtKey_getChainCode(taskId, ptr, args));
|
|
57
|
+
}
|
|
58
|
+
verifyCompactSignatureWithHash(ptr, args) {
|
|
59
|
+
// message: Uint8Array, signature: Uint8Array
|
|
60
|
+
return this.runAsync((taskId) => this.api.lib.ExtKey_verifyCompactSignatureWithHash(taskId, ptr, args));
|
|
61
|
+
}
|
|
62
|
+
isPrivate(ptr, args) {
|
|
63
|
+
return this.runAsync((taskId) => this.api.lib.ExtKey_isPrivate(taskId, ptr, args));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.ExtKeyNative = ExtKeyNative;
|