@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.
Files changed (45) hide show
  1. package/FinalizationHelper.d.ts +18 -0
  2. package/FinalizationHelper.js +49 -0
  3. package/Types.d.ts +77 -21
  4. package/Types.js +3 -0
  5. package/api/ApiStatic.d.ts +16 -0
  6. package/api/ApiStatic.js +26 -0
  7. package/api/ConnectionNative.d.ts +7 -1
  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/assets/driver-web-context.js +1 -1
  16. package/assets/endpoint-wasm-module.js +1 -1
  17. package/assets/endpoint-wasm-module.wasm +0 -0
  18. package/bundle/privmx-endpoint-web.js +1 -1
  19. package/extra/PrivmxClient.d.ts +133 -0
  20. package/extra/PrivmxClient.js +271 -0
  21. package/extra/PublicConnection.d.ts +70 -0
  22. package/extra/PublicConnection.js +118 -0
  23. package/extra/events.d.ts +2 -2
  24. package/extra/inbox.d.ts +3 -3
  25. package/extra/inbox.js +1 -1
  26. package/extra/index.d.ts +10 -8
  27. package/extra/index.js +6 -1
  28. package/index.d.ts +2 -2
  29. package/index.js +2 -1
  30. package/package.json +5 -1
  31. package/service/Connection.d.ts +27 -1
  32. package/service/Connection.js +29 -0
  33. package/service/CryptoApi.d.ts +48 -1
  34. package/service/CryptoApi.js +59 -1
  35. package/service/EndpointFactory.d.ts +9 -0
  36. package/service/EndpointFactory.js +24 -0
  37. package/service/EventApi.d.ts +40 -0
  38. package/service/EventApi.js +60 -0
  39. package/service/ExtKey.d.ts +103 -0
  40. package/service/ExtKey.js +167 -0
  41. package/service/UserVerifierInterface.d.ts +18 -0
  42. package/service/UserVerifierInterface.js +2 -0
  43. package/service/index.d.ts +2 -1
  44. package/service/index.js +3 -1
  45. package/assets/privmx-endpoint-web.js +0 -2
@@ -0,0 +1,60 @@
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.EventApi = void 0;
14
+ const BaseApi_1 = require("./BaseApi");
15
+ class EventApi extends BaseApi_1.BaseApi {
16
+ native;
17
+ constructor(native, ptr) {
18
+ super(ptr);
19
+ this.native = native;
20
+ }
21
+ // /**
22
+ // * Creates an instance of 'EventApi'.
23
+ // *
24
+ // * @param connection instance of 'Connection'
25
+ // *
26
+ // * @return EventApi object
27
+ // */
28
+ // static EventApi create(core::Connection& connection);
29
+ // EventApi() = default;
30
+ /**
31
+ * Emits the custom event on the given Context and channel.
32
+ *
33
+ * @param {string} contextId ID of the Context
34
+ * @param {string} channelName name of the Channel
35
+ * @param {Uint8Array} eventData event's data
36
+ * @param {UserWithPubKey[]} users list of UserWithPubKey objects which defines the recipients of the event
37
+ */
38
+ async emitEvent(contextId, channelName, eventData, users) {
39
+ return this.native.emitEvent(this.servicePtr, [contextId, channelName, eventData, users]);
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, channelName) {
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, channelName) {
57
+ return this.native.unsubscribeFromCustomEvents(this.servicePtr, [contextId, channelName]);
58
+ }
59
+ }
60
+ exports.EventApi = EventApi;
@@ -0,0 +1,103 @@
1
+ import { ExtKeyNativePtr } from "../api/ExtKeyNative";
2
+ import { BaseApi } from "./BaseApi";
3
+ export declare class ExtKey extends BaseApi {
4
+ private native;
5
+ ptr: ExtKeyNativePtr;
6
+ private static freeExtKey;
7
+ /**
8
+ * Creates ExtKey from given seed.
9
+ * @param {Uint8Array} seed the seed used to generate Key
10
+ * @returns {ExtKey} object
11
+ */
12
+ static fromSeed(seed: Uint8Array): Promise<ExtKey>;
13
+ /**
14
+ * Decodes ExtKey from Base58 format.
15
+ *
16
+ * @param {string} base58 the ExtKey in Base58
17
+ * @returns {ExtKey} object
18
+ */
19
+ static fromBase58(base58: string): Promise<ExtKey>;
20
+ /**
21
+ * Generates a new ExtKey.
22
+ *
23
+ * @returns {ExtKey} object
24
+ */
25
+ static generateRandom(): Promise<ExtKey>;
26
+ /**
27
+ * //doc-gen:ignore
28
+ */
29
+ private constructor();
30
+ static fromPtr(ptr: ExtKeyNativePtr): ExtKey;
31
+ /**
32
+ * Generates child ExtKey from a current ExtKey using BIP32.
33
+ *
34
+ * @param {number} index number from 0 to 2^31-1
35
+
36
+ * @returns {ExtKey} object
37
+ */
38
+ derive(index: number): Promise<ExtKey>;
39
+ /**
40
+ * Generates hardened child ExtKey from a current ExtKey using BIP32.
41
+ *
42
+ * @param {number} index number from 0 to 2^31-1
43
+
44
+ * @returns {ExtKey} object
45
+ */
46
+ deriveHardened(index: number): Promise<ExtKey>;
47
+ /**
48
+ * Converts ExtKey to Base58 string.
49
+ *
50
+ * @returns {string} ExtKey in Base58 format
51
+ */
52
+ getPrivatePartAsBase58(): Promise<string>;
53
+ /**
54
+ * Converts the public part of ExtKey to Base58 string.
55
+ *
56
+ * @returns {string} ExtKey in Base58 format
57
+ */
58
+ getPublicPartAsBase58(): Promise<string>;
59
+ /**
60
+ * Extracts ECC PrivateKey.
61
+ *
62
+ * @returns {string} ECC key in WIF format
63
+ */
64
+ getPrivateKey(): Promise<string>;
65
+ /**
66
+ * Extracts ECC PublicKey.
67
+ *
68
+ * @returns {string} ECC key in BASE58DER format
69
+ */
70
+ getPublicKey(): Promise<string>;
71
+ /**
72
+ * Extracts raw ECC PrivateKey.
73
+ *
74
+ * @returns {Uint8Array} ECC PrivateKey
75
+ */
76
+ getPrivateEncKey(): Promise<Uint8Array>;
77
+ /**
78
+ * Extracts ECC PublicKey Address.
79
+ *
80
+ * @returns {string} ECC Address in BASE58 format
81
+ */
82
+ getPublicKeyAsBase58Address(): Promise<string>;
83
+ /**
84
+ * Gets the chain code of Extended Key.
85
+ *
86
+ * @returns {Uint8Array} Raw chain code
87
+ */
88
+ getChainCode(): Promise<Uint8Array>;
89
+ /**
90
+ * Validates a signature of a message.
91
+ *
92
+ * @param {Uint8Array} message data used on validation
93
+ * @param {Uint8Array} signature signature of data to verify
94
+ * @returns {boolean} message validation result
95
+ */
96
+ verifyCompactSignatureWithHash(message: Uint8Array, signature: Uint8Array): Promise<boolean>;
97
+ /**
98
+ * Checks if ExtKey is Private.
99
+ *
100
+ * @returns {boolean} true if ExtKey is private
101
+ */
102
+ isPrivate(): Promise<boolean>;
103
+ }
@@ -0,0 +1,167 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ExtKey = void 0;
4
+ const ApiStatic_1 = require("../api/ApiStatic");
5
+ const ExtKeyNative_1 = require("../api/ExtKeyNative");
6
+ const FinalizationHelper_1 = require("../FinalizationHelper");
7
+ const BaseApi_1 = require("./BaseApi");
8
+ class ExtKey extends BaseApi_1.BaseApi {
9
+ native;
10
+ ptr;
11
+ static async freeExtKey(ptr) {
12
+ const nativeApi = new ExtKeyNative_1.ExtKeyNative(ApiStatic_1.ApiStatic.getInstance());
13
+ await nativeApi.deleteExtKey(ptr);
14
+ }
15
+ /**
16
+ * Creates ExtKey from given seed.
17
+ * @param {Uint8Array} seed the seed used to generate Key
18
+ * @returns {ExtKey} object
19
+ */
20
+ static async fromSeed(seed) {
21
+ const ptr = await ExtKeyNative_1.ExtKeyNative.fromSeed([seed]);
22
+ const native = new ExtKeyNative_1.ExtKeyNative(ApiStatic_1.ApiStatic.getInstance());
23
+ const extKey = new ExtKey(native, ptr);
24
+ const fh = FinalizationHelper_1.FinalizationHelper.getInstance();
25
+ fh.register(extKey, { ptr: ptr, onFree: () => this.freeExtKey(ptr) });
26
+ return extKey;
27
+ }
28
+ /**
29
+ * Decodes ExtKey from Base58 format.
30
+ *
31
+ * @param {string} base58 the ExtKey in Base58
32
+ * @returns {ExtKey} object
33
+ */
34
+ static async fromBase58(base58) {
35
+ const ptr = await ExtKeyNative_1.ExtKeyNative.fromBase58([base58]);
36
+ const native = new ExtKeyNative_1.ExtKeyNative(ApiStatic_1.ApiStatic.getInstance());
37
+ const extKey = new ExtKey(native, ptr);
38
+ const fh = FinalizationHelper_1.FinalizationHelper.getInstance();
39
+ fh.register(extKey, { ptr: ptr, onFree: () => this.freeExtKey(ptr) });
40
+ return extKey;
41
+ }
42
+ /**
43
+ * Generates a new ExtKey.
44
+ *
45
+ * @returns {ExtKey} object
46
+ */
47
+ static async generateRandom() {
48
+ const ptr = await ExtKeyNative_1.ExtKeyNative.generateRandom([]);
49
+ const native = new ExtKeyNative_1.ExtKeyNative(ApiStatic_1.ApiStatic.getInstance());
50
+ const extKey = new ExtKey(native, ptr);
51
+ const fh = FinalizationHelper_1.FinalizationHelper.getInstance();
52
+ fh.register(extKey, { ptr: ptr, onFree: () => this.freeExtKey(ptr) });
53
+ return extKey;
54
+ }
55
+ /**
56
+ * //doc-gen:ignore
57
+ */
58
+ constructor(native, ptr) {
59
+ super(ptr);
60
+ this.native = native;
61
+ this.ptr = ptr;
62
+ }
63
+ static fromPtr(ptr) {
64
+ const native = new ExtKeyNative_1.ExtKeyNative(ApiStatic_1.ApiStatic.getInstance());
65
+ return new ExtKey(native, ptr);
66
+ }
67
+ /**
68
+ * Generates child ExtKey from a current ExtKey using BIP32.
69
+ *
70
+ * @param {number} index number from 0 to 2^31-1
71
+
72
+ * @returns {ExtKey} object
73
+ */
74
+ async derive(index) {
75
+ const ptr = await this.native.derive(this.servicePtr, [index]);
76
+ const extKey = new ExtKey(this.native, ptr);
77
+ const fh = FinalizationHelper_1.FinalizationHelper.getInstance();
78
+ fh.register(extKey, { ptr: ptr, onFree: () => ExtKey.freeExtKey(ptr) });
79
+ return extKey;
80
+ }
81
+ /**
82
+ * Generates hardened child ExtKey from a current ExtKey using BIP32.
83
+ *
84
+ * @param {number} index number from 0 to 2^31-1
85
+
86
+ * @returns {ExtKey} object
87
+ */
88
+ async deriveHardened(index) {
89
+ const extKeyPtr = await this.native.deriveHardened(this.servicePtr, [index]);
90
+ return new ExtKey(this.native, extKeyPtr);
91
+ }
92
+ /**
93
+ * Converts ExtKey to Base58 string.
94
+ *
95
+ * @returns {string} ExtKey in Base58 format
96
+ */
97
+ async getPrivatePartAsBase58() {
98
+ return this.native.getPrivatePartAsBase58(this.servicePtr, []);
99
+ }
100
+ /**
101
+ * Converts the public part of ExtKey to Base58 string.
102
+ *
103
+ * @returns {string} ExtKey in Base58 format
104
+ */
105
+ async getPublicPartAsBase58() {
106
+ return this.native.getPublicPartAsBase58(this.servicePtr, []);
107
+ }
108
+ /**
109
+ * Extracts ECC PrivateKey.
110
+ *
111
+ * @returns {string} ECC key in WIF format
112
+ */
113
+ async getPrivateKey() {
114
+ return this.native.getPrivateKey(this.servicePtr, []);
115
+ }
116
+ /**
117
+ * Extracts ECC PublicKey.
118
+ *
119
+ * @returns {string} ECC key in BASE58DER format
120
+ */
121
+ async getPublicKey() {
122
+ return this.native.getPublicKey(this.servicePtr, []);
123
+ }
124
+ /**
125
+ * Extracts raw ECC PrivateKey.
126
+ *
127
+ * @returns {Uint8Array} ECC PrivateKey
128
+ */
129
+ async getPrivateEncKey() {
130
+ return this.native.getPrivateEncKey(this.servicePtr, []);
131
+ }
132
+ /**
133
+ * Extracts ECC PublicKey Address.
134
+ *
135
+ * @returns {string} ECC Address in BASE58 format
136
+ */
137
+ async getPublicKeyAsBase58Address() {
138
+ return this.native.getPublicKeyAsBase58Address(this.servicePtr, []);
139
+ }
140
+ /**
141
+ * Gets the chain code of Extended Key.
142
+ *
143
+ * @returns {Uint8Array} Raw chain code
144
+ */
145
+ async getChainCode() {
146
+ return this.native.getChainCode(this.servicePtr, []);
147
+ }
148
+ /**
149
+ * Validates a signature of a message.
150
+ *
151
+ * @param {Uint8Array} message data used on validation
152
+ * @param {Uint8Array} signature signature of data to verify
153
+ * @returns {boolean} message validation result
154
+ */
155
+ async verifyCompactSignatureWithHash(message, signature) {
156
+ return this.native.verifyCompactSignatureWithHash(this.servicePtr, [message, signature]);
157
+ }
158
+ /**
159
+ * Checks if ExtKey is Private.
160
+ *
161
+ * @returns {boolean} true if ExtKey is private
162
+ */
163
+ async isPrivate() {
164
+ return this.native.isPrivate(this.servicePtr, []);
165
+ }
166
+ }
167
+ exports.ExtKey = ExtKey;
@@ -0,0 +1,18 @@
1
+ import { VerificationRequest } from "../Types";
2
+ /**
3
+ * An interface consisting of a single verify() method, which - when implemented - should perform verification of the provided data using an external service verification
4
+ * should be done using an external service such as an application server or a PKI server.
5
+ *
6
+ * @type {UserVerifierInterface}
7
+ *
8
+ */
9
+ export interface UserVerifierInterface {
10
+ /**
11
+ * Verifies whether the specified users are valid.
12
+ * Checks if each user belonged to the Context and if this is their key in `date` and return `true` or `false` otherwise.
13
+ *
14
+ * @param request List of user data to verification
15
+ * @returns List of verification results whose items correspond to the items in the input list
16
+ */
17
+ verify(request: VerificationRequest[]): Promise<boolean[]>;
18
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -6,4 +6,5 @@ import { CryptoApi } from "./CryptoApi";
6
6
  import { Connection } from "./Connection";
7
7
  import { EventQueue } from "./EventQueue";
8
8
  import { BaseApi } from "./BaseApi";
9
- export { EndpointFactory, ThreadApi, StoreApi, InboxApi, CryptoApi, Connection, EventQueue, BaseApi };
9
+ import { ExtKey } from "./ExtKey";
10
+ export { EndpointFactory, ThreadApi, StoreApi, InboxApi, CryptoApi, Connection, EventQueue, BaseApi, ExtKey };
package/service/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
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;
3
+ exports.ExtKey = exports.BaseApi = exports.EventQueue = exports.Connection = exports.CryptoApi = exports.InboxApi = exports.StoreApi = exports.ThreadApi = exports.EndpointFactory = void 0;
4
4
  const EndpointFactory_1 = require("./EndpointFactory");
5
5
  Object.defineProperty(exports, "EndpointFactory", { enumerable: true, get: function () { return EndpointFactory_1.EndpointFactory; } });
6
6
  const ThreadApi_1 = require("./ThreadApi");
@@ -17,3 +17,5 @@ const EventQueue_1 = require("./EventQueue");
17
17
  Object.defineProperty(exports, "EventQueue", { enumerable: true, get: function () { return EventQueue_1.EventQueue; } });
18
18
  const BaseApi_1 = require("./BaseApi");
19
19
  Object.defineProperty(exports, "BaseApi", { enumerable: true, get: function () { return BaseApi_1.BaseApi; } });
20
+ const ExtKey_1 = require("./ExtKey");
21
+ Object.defineProperty(exports, "ExtKey", { enumerable: true, get: function () { return ExtKey_1.ExtKey; } });
@@ -1,2 +0,0 @@
1
- /*! For license information please see privmx-endpoint-web.js.LICENSE.txt */
2
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["privmx-webendpoint"]=t():e.PrivmxWebEndpoint=t()}(self,(()=>(()=>{"use strict";var e={667:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Api=void 0;const s=i(785);t.Api=class{lib;promises;taskIdGenerator;constructor(e){this.lib=e,this.taskIdGenerator=new s.IdGenerator,this.promises=new Map,this.setResultsCallback()}async runAsync(e){return new Promise(((t,i)=>{const s=this.generateId();this.promises.set(s,{resolve:t,reject:i}),e(s)}))}resolveResult(e){1==e.status?this.promises.get(e.taskId).resolve(e.result):this.promises.get(e.taskId).reject(e.error),this.promises.delete(e.taskId)}generateId(){return this.taskIdGenerator.generateId()}setResultsCallback(){this.lib.setResultsCallback((e=>this.resolveResult(e)))}}},361:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BaseNative=void 0,t.BaseNative=class{_api;constructor(e){this._api=e}get api(){if(!this._api)throw new Error("This API instance is no longer valid because the connection associated with it has been closed.");return this._api}deleteApiRef(){this._api=null}async runAsync(e){if(!this.api)throw new Error("This API instance is no longer valid because the connection associated with it has been closed.");return this.api.runAsync(e)}}},140:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ConnectionNative=void 0;const s=i(361);class n extends s.BaseNative{lastConnectionId=-1;async newApi(e){throw new Error("Use the newConnection() - specialized version of method instead.")}async deleteApi(e){await this.runAsync((t=>this.api.lib.Connection_deleteConnection(t,e))),this.deleteApiRef()}async newConnection(){return this.runAsync((e=>this.api.lib.Connection_newConnection(e)))}async deleteConnection(e){await this.runAsync((t=>this.api.lib.Connection_deleteConnection(t,e))),this.deleteApiRef()}async connect(e,t){await this.runAsync((i=>this.api.lib.Connection_connect(i,e,t))),await this.getConnectionId(e,[])}async connectPublic(e,t){return this.runAsync((i=>this.api.lib.Connection_connectPublic(i,e,t)))}async getConnectionId(e,t){return this.lastConnectionId<0&&(this.lastConnectionId=await this.runAsync((i=>this.api.lib.Connection_getConnectionId(i,e,t)))),this.lastConnectionId}async listContexts(e,t){return this.runAsync((i=>this.api.lib.Connection_listContexts(i,e,t)))}async disconnect(e,t){await this.runAsync((i=>this.api.lib.Connection_disconnect(i,e,t)))}}t.ConnectionNative=n},711:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CryptoApiNative=void 0;const s=i(361);class n extends s.BaseNative{async newApi(){return this.runAsync((e=>this.api.lib.CryptoApi_newCryptoApi(e)))}async deleteApi(e){await this.runAsync((t=>this.api.lib.CryptoApi_deleteCryptoApi(t,e))),this.deleteApiRef()}async create(e,t){return this.runAsync((i=>this.api.lib.CryptoApi_create(i,e,t)))}async signData(e,t){return this.runAsync((i=>this.api.lib.CryptoApi_signData(i,e,t)))}async generatePrivateKey(e,t){return this.runAsync((i=>this.api.lib.CryptoApi_generatePrivateKey(i,e,t)))}async derivePrivateKey(e,t){return this.runAsync((i=>this.api.lib.CryptoApi_derivePrivateKey(i,e,t)))}async derivePrivateKey2(e,t){return this.runAsync((i=>this.api.lib.CryptoApi_derivePrivateKey2(i,e,t)))}async derivePublicKey(e,t){return this.runAsync((i=>this.api.lib.CryptoApi_derivePublicKey(i,e,t)))}async generateKeySymmetric(e,t){return this.runAsync((i=>this.api.lib.CryptoApi_generateKeySymmetric(i,e,t)))}async encryptDataSymmetric(e,t){return this.runAsync((i=>this.api.lib.CryptoApi_encryptDataSymmetric(i,e,t)))}async decryptDataSymmetric(e,t){return this.runAsync((i=>this.api.lib.CryptoApi_decryptDataSymmetric(i,e,t)))}async convertPEMKeytoWIFKey(e,t){return this.runAsync((i=>this.api.lib.CryptoApi_convertPEMKeytoWIFKey(i,e,t)))}}t.CryptoApiNative=n},467:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.EventQueueNative=void 0;const s=i(361);class n extends s.BaseNative{async newApi(e){throw new Error("Use the newEventQueue() - specialized version of method instead.")}async deleteApi(e){await this.runAsync((t=>this.api.lib.EventQueue_deleteEventQueue(t,e))),this.deleteApiRef()}async newEventQueue(){return this.runAsync((e=>this.api.lib.EventQueue_newEventQueue(e)))}async deleteEventQueue(e){await this.runAsync((t=>this.api.lib.EventQueue_deleteEventQueue(t,e))),this.deleteApiRef()}async waitEvent(e,t){return this.runAsync((i=>this.api.lib.EventQueue_waitEvent(i,e,t)))}async emitBreakEvent(e,t){return this.runAsync((i=>this.api.lib.EventQueue_emitBreakEvent(i,e,t)))}}t.EventQueueNative=n},785:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.IdGenerator=void 0,t.IdGenerator=class{_id=0;generateId(){return this._id++,this._id}}},252:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.InboxApiNative=void 0;const s=i(361);class n extends s.BaseNative{async newApi(e,t,i){return this.runAsync((s=>this.api.lib.InboxApi_newInboxApi(s,e,t,i)))}async deleteApi(e){await this.runAsync((t=>this.api.lib.InboxApi_deleteInboxApi(t,e))),this.deleteApiRef()}async create(e,t){return this.runAsync((i=>this.api.lib.InboxApi_create(i,e,t)))}async createInbox(e,t){return this.runAsync((i=>this.api.lib.InboxApi_createInbox(i,e,t)))}async updateInbox(e,t){return this.runAsync((i=>this.api.lib.InboxApi_updateInbox(i,e,t)))}async getInbox(e,t){return this.runAsync((i=>this.api.lib.InboxApi_getInbox(i,e,t)))}async listInboxes(e,t){return this.runAsync((i=>this.api.lib.InboxApi_listInboxes(i,e,t)))}async getInboxPublicView(e,t){return this.runAsync((i=>this.api.lib.InboxApi_getInboxPublicView(i,e,t)))}async deleteInbox(e,t){return this.runAsync((i=>this.api.lib.InboxApi_deleteInbox(i,e,t)))}async prepareEntry(e,t){return this.runAsync((i=>this.api.lib.InboxApi_prepareEntry(i,e,t)))}async sendEntry(e,t){return this.runAsync((i=>this.api.lib.InboxApi_sendEntry(i,e,t)))}async readEntry(e,t){return this.runAsync((i=>this.api.lib.InboxApi_readEntry(i,e,t)))}async deleteEntry(e,t){return this.runAsync((i=>this.api.lib.InboxApi_deleteEntry(i,e,t)))}async listEntries(e,t){return this.runAsync((i=>this.api.lib.InboxApi_listEntries(i,e,t)))}async createFileHandle(e,t){return this.runAsync((i=>this.api.lib.InboxApi_createFileHandle(i,e,t)))}async writeToFile(e,t){return this.runAsync((i=>this.api.lib.InboxApi_writeToFile(i,e,t)))}async openFile(e,t){return this.runAsync((i=>this.api.lib.InboxApi_openFile(i,e,t)))}async readFromFile(e,t){return this.runAsync((i=>this.api.lib.InboxApi_readFromFile(i,e,t)))}async seekInFile(e,t){return this.runAsync((i=>this.api.lib.InboxApi_seekInFile(i,e,t)))}async closeFile(e,t){return this.runAsync((i=>this.api.lib.InboxApi_closeFile(i,e,t)))}async subscribeForInboxEvents(e,t){return this.runAsync((i=>this.api.lib.InboxApi_subscribeForInboxEvents(i,e,t)))}async unsubscribeFromInboxEvents(e,t){return this.runAsync((i=>this.api.lib.InboxApi_unsubscribeFromInboxEvents(i,e,t)))}async subscribeForEntryEvents(e,t){return this.runAsync((i=>this.api.lib.InboxApi_subscribeForEntryEvents(i,e,t)))}async unsubscribeFromEntryEvents(e,t){return this.runAsync((i=>this.api.lib.InboxApi_unsubscribeFromEntryEvents(i,e,t)))}}t.InboxApiNative=n},243:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.StoreApiNative=void 0;const s=i(361);class n extends s.BaseNative{async newApi(e){return this.runAsync((t=>this.api.lib.StoreApi_newStoreApi(t,e)))}async deleteApi(e){await this.runAsync((t=>this.api.lib.StoreApi_deleteStoreApi(t,e))),this.deleteApiRef()}async create(e,t){return this.runAsync((i=>this.api.lib.StoreApi_create(i,e,t)))}async createStore(e,t){return this.runAsync((i=>this.api.lib.StoreApi_createStore(i,e,t)))}async updateStore(e,t){return this.runAsync((i=>this.api.lib.StoreApi_updateStore(i,e,t)))}async deleteStore(e,t){return this.runAsync((i=>this.api.lib.StoreApi_deleteStore(i,e,t)))}async getStore(e,t){return this.runAsync((i=>this.api.lib.StoreApi_getStore(i,e,t)))}async listStores(e,t){return this.runAsync((i=>this.api.lib.StoreApi_listStores(i,e,t)))}async createFile(e,t){return this.runAsync((i=>this.api.lib.StoreApi_createFile(i,e,t)))}async updateFile(e,t){return this.runAsync((i=>this.api.lib.StoreApi_updateFile(i,e,t)))}async updateFileMeta(e,t){return this.runAsync((i=>this.api.lib.StoreApi_updateFileMeta(i,e,t)))}async writeToFile(e,t){return this.runAsync((i=>this.api.lib.StoreApi_writeToFile(i,e,t)))}async deleteFile(e,t){return this.runAsync((i=>this.api.lib.StoreApi_deleteFile(i,e,t)))}async getFile(e,t){return this.runAsync((i=>this.api.lib.StoreApi_getFile(i,e,t)))}async listFiles(e,t){return this.runAsync((i=>this.api.lib.StoreApi_listFiles(i,e,t)))}async openFile(e,t){return this.runAsync((i=>this.api.lib.StoreApi_openFile(i,e,t)))}async readFromFile(e,t){return this.runAsync((i=>this.api.lib.StoreApi_readFromFile(i,e,t)))}async seekInFile(e,t){return this.runAsync((i=>this.api.lib.StoreApi_seekInFile(i,e,t)))}async closeFile(e,t){return this.runAsync((i=>this.api.lib.StoreApi_closeFile(i,e,t)))}async subscribeForStoreEvents(e,t){return this.runAsync((i=>this.api.lib.StoreApi_subscribeForStoreEvents(i,e,t)))}async unsubscribeFromStoreEvents(e,t){return this.runAsync((i=>this.api.lib.StoreApi_unsubscribeFromStoreEvents(i,e,t)))}async subscribeForFileEvents(e,t){return this.runAsync((i=>this.api.lib.StoreApi_subscribeForFileEvents(i,e,t)))}async unsubscribeFromFileEvents(e,t){return this.runAsync((i=>this.api.lib.StoreApi_unsubscribeFromFileEvents(i,e,t)))}}t.StoreApiNative=n},272:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ThreadApiNative=void 0;const s=i(361);class n extends s.BaseNative{async newApi(e){return this.runAsync((t=>this.api.lib.ThreadApi_newThreadApi(t,e)))}async deleteApi(e){await this.runAsync((t=>this.api.lib.ThreadApi_deleteThreadApi(t,e))),this.deleteApiRef()}async create(e,t){return this.runAsync((i=>this.api.lib.ThreadApi_create(i,e,t)))}async createThread(e,t){return this.runAsync((i=>this.api.lib.ThreadApi_createThread(i,e,t)))}async updateThread(e,t){return this.runAsync((i=>this.api.lib.ThreadApi_updateThread(i,e,t)))}async deleteThread(e,t){return this.runAsync((i=>this.api.lib.ThreadApi_deleteThread(i,e,t)))}async getThread(e,t){return this.runAsync((i=>this.api.lib.ThreadApi_getThread(i,e,t)))}async listThreads(e,t){return this.runAsync((i=>this.api.lib.ThreadApi_listThreads(i,e,t)))}async getMessage(e,t){return this.runAsync((i=>this.api.lib.ThreadApi_getMessage(i,e,t)))}async listMessages(e,t){return this.runAsync((i=>this.api.lib.ThreadApi_listMessages(i,e,t)))}async sendMessage(e,t){return this.runAsync((i=>this.api.lib.ThreadApi_sendMessage(i,e,t)))}async deleteMessage(e,t){return this.runAsync((i=>this.api.lib.ThreadApi_deleteMessage(i,e,t)))}async updateMessage(e,t){return this.runAsync((i=>this.api.lib.ThreadApi_updateMessage(i,e,t)))}async subscribeForThreadEvents(e,t){return this.runAsync((i=>this.api.lib.ThreadApi_subscribeForThreadEvents(i,e,t)))}async unsubscribeFromThreadEvents(e,t){return this.runAsync((i=>this.api.lib.ThreadApi_unsubscribeFromThreadEvents(i,e,t)))}async subscribeForMessageEvents(e,t){return this.runAsync((i=>this.api.lib.ThreadApi_subscribeForMessageEvents(i,e,t)))}async unsubscribeFromMessageEvents(e,t){return this.runAsync((i=>this.api.lib.ThreadApi_unsubscribeFromMessageEvents(i,e,t)))}}t.ThreadApiNative=n},647:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BaseApi=void 0,t.BaseApi=class{_servicePtr;constructor(e){this._servicePtr=e}get servicePtr(){if(this._servicePtr<0)throw new Error("This API instance is no longer valid because the connection associated with it has been closed.");return this._servicePtr}destroyRefs(){this._servicePtr=-1}}},262:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Connection=void 0;const s=i(647);class n extends s.BaseApi{native;apisRefs={};nativeApisDeps={};constructor(e,t){super(t),this.native=e}async getConnectionId(){return this.native.getConnectionId(this.servicePtr,[])}async listContexts(e){return this.native.listContexts(this.servicePtr,[e])}async disconnect(){await this.native.disconnect(this.servicePtr,[]),await this.freeApis(),await this.native.deleteConnection(this.servicePtr)}async freeApis(){for(const e in this.apisRefs)this.nativeApisDeps[e]&&await this.nativeApisDeps[e].deleteApi(this.apisRefs[e]._apiServicePtr)}}t.Connection=n},11:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CryptoApi=void 0;const s=i(647);class n extends s.BaseApi{native;constructor(e,t){super(t),this.native=e}async signData(e,t){return this.native.signData(this.servicePtr,[e,t])}async generatePrivateKey(e){return this.native.generatePrivateKey(this.servicePtr,[e])}async derivePrivateKey(e,t){return this.native.derivePrivateKey(this.servicePtr,[e,t])}async derivePrivateKey2(e,t){return this.native.derivePrivateKey2(this.servicePtr,[e,t])}async derivePublicKey(e){return this.native.derivePublicKey(this.servicePtr,[e])}async generateKeySymmetric(){return this.native.generateKeySymmetric(this.servicePtr,[])}async encryptDataSymmetric(e,t){return this.native.encryptDataSymmetric(this.servicePtr,[e,t])}async decryptDataSymmetric(e,t){return this.native.decryptDataSymmetric(this.servicePtr,[e,t])}async convertPEMKeytoWIFKey(e){return this.native.convertPEMKeytoWIFKey(this.servicePtr,[e])}}t.CryptoApi=n},181:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.EndpointFactory=void 0;const s=i(667),n=i(140),r=i(711),a=i(467),c=i(252),o=i(243),u=i(272),h=i(262),p=i(11),y=i(297),l=i(134),v=i(985),d=i(148);class b{static api;static eventQueueInstance;static async setup(e){const t=e||document.currentScript.src.split("/").slice(0,-1).join("/"),i=["driver-web-context.js","endpoint-wasm-module.js"];for(const e of i)await this.loadScript(t+"/"+e);const s=await endpointWasmModule();b.init(s)}static async loadScript(e){return new Promise((t=>{const i=document.getElementsByTagName("head")[0],s=document.createElement("script");s.type="text/javascript",s.src=e,s.onload=()=>{t()},i.appendChild(s)}))}static init(e){this.api=new s.Api(e)}static async getEventQueue(){if(!this.eventQueueInstance){const e=new a.EventQueueNative(this.api),t=await e.newEventQueue();this.eventQueueInstance=new y.EventQueue(e,t)}return this.eventQueueInstance}static async connect(e,t,i){const s=new n.ConnectionNative(this.api),r=await s.newConnection();return await s.connect(r,[e,t,i]),new h.Connection(s,r)}static async connectPublic(e,t){const i=new n.ConnectionNative(this.api),s=await i.newConnection();return await i.connectPublic(s,[e,t]),new h.Connection(i,s)}static async createThreadApi(e){if("threads"in e.apisRefs)throw new Error("ThreadApi already registered for given connection.");const t=new u.ThreadApiNative(this.api),i=await t.newApi(e.servicePtr);return await t.create(i,[]),e.apisRefs.threads={_apiServicePtr:i},e.nativeApisDeps.threads=t,new d.ThreadApi(t,i)}static async createStoreApi(e){if("stores"in e.apisRefs)throw new Error("StoreApi already registered for given connection.");const t=new o.StoreApiNative(this.api),i=await t.newApi(e.servicePtr);return e.apisRefs.stores={_apiServicePtr:i},e.nativeApisDeps.stores=t,await t.create(i,[]),new v.StoreApi(t,i)}static async createInboxApi(e,t,i){if("inboxes"in e.apisRefs)throw new Error("InboxApi already registered for given connection.");const s=new c.InboxApiNative(this.api),n=await s.newApi(e.servicePtr,t.servicePtr,i.servicePtr);return e.apisRefs.inboxes={_apiServicePtr:n},e.nativeApisDeps.inboxes=s,await s.create(n,[]),new l.InboxApi(s,n)}static async createCryptoApi(){const e=new r.CryptoApiNative(this.api),t=await e.newApi();return await e.create(t,[]),new p.CryptoApi(e,t)}}t.EndpointFactory=b},297:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.EventQueue=void 0;const s=i(647);class n extends s.BaseApi{native;isPending=!1;constructor(e,t){super(t),this.native=e}async waitEvent(){if(this.isPending)throw"WaitEvent() is already in a pending state waiting for new events";try{return await this.native.waitEvent(this.servicePtr,[])}finally{this.isPending=!1}}async emitBreakEvent(){return this.native.emitBreakEvent(this.servicePtr,[])}}t.EventQueue=n},134:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.InboxApi=void 0;const s=i(647);class n extends s.BaseApi{native;constructor(e,t){super(t),this.native=e}async createInbox(e,t,i,s,n,r,a){return this.native.createInbox(this.servicePtr,[e,t,i,s,n,r,a])}async updateInbox(e,t,i,s,n,r,a,c,o,u){return this.native.updateInbox(this.servicePtr,[e,t,i,s,n,r,a,c,o,u])}async getInbox(e){return this.native.getInbox(this.servicePtr,[e])}async listInboxes(e,t){return this.native.listInboxes(this.servicePtr,[e,t])}async getInboxPublicView(e){return this.native.getInboxPublicView(this.servicePtr,[e])}async deleteInbox(e){return this.native.deleteInbox(this.servicePtr,[e])}async prepareEntry(e,t,i,s){return this.native.prepareEntry(this.servicePtr,[e,t,i,s])}async sendEntry(e){return this.native.sendEntry(this.servicePtr,[e])}async readEntry(e){return this.native.readEntry(this.servicePtr,[e])}async listEntries(e,t){return this.native.listEntries(this.servicePtr,[e,t])}async deleteEntry(e){return this.native.deleteEntry(this.servicePtr,[e])}async createFileHandle(e,t,i){return this.native.createFileHandle(this.servicePtr,[e,t,i])}async writeToFile(e,t,i){return this.native.writeToFile(this.servicePtr,[e,t,i])}async openFile(e){return this.native.openFile(this.servicePtr,[e])}async readFromFile(e,t){return this.native.readFromFile(this.servicePtr,[e,t])}async seekInFile(e,t){return this.native.seekInFile(this.servicePtr,[e,t])}async closeFile(e){return this.native.closeFile(this.servicePtr,[e])}async subscribeForInboxEvents(){return this.native.subscribeForInboxEvents(this.servicePtr,[])}async unsubscribeFromInboxEvents(){return this.native.unsubscribeFromInboxEvents(this.servicePtr,[])}async subscribeForEntryEvents(e){return this.native.subscribeForEntryEvents(this.servicePtr,[e])}async unsubscribeFromEntryEvents(e){return this.native.unsubscribeFromEntryEvents(this.servicePtr,[e])}}t.InboxApi=n},985:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.StoreApi=void 0;const s=i(647);class n extends s.BaseApi{native;constructor(e,t){super(t),this.native=e}async createStore(e,t,i,s,n,r){return this.native.createStore(this.servicePtr,[e,t,i,s,n,r])}async updateStore(e,t,i,s,n,r,a,c,o){return this.native.updateStore(this.servicePtr,[e,t,i,s,n,r,a,c,o])}async deleteStore(e){return this.native.deleteStore(this.servicePtr,[e])}async getStore(e){return this.native.getStore(this.servicePtr,[e])}async listStores(e,t){return this.native.listStores(this.servicePtr,[e,t])}async createFile(e,t,i,s){return this.native.createFile(this.servicePtr,[e,t,i,s])}async updateFile(e,t,i,s){return this.native.updateFile(this.servicePtr,[e,t,i,s])}async updateFileMeta(e,t,i){return this.native.updateFileMeta(this.servicePtr,[e,t,i])}async writeToFile(e,t){return this.native.writeToFile(this.servicePtr,[e,t])}async deleteFile(e){return this.native.deleteFile(this.servicePtr,[e])}async getFile(e){return this.native.getFile(this.servicePtr,[e])}async listFiles(e,t){return this.native.listFiles(this.servicePtr,[e,t])}async openFile(e){return this.native.openFile(this.servicePtr,[e])}async readFromFile(e,t){return this.native.readFromFile(this.servicePtr,[e,t])}async seekInFile(e,t){return this.native.seekInFile(this.servicePtr,[e,t])}async closeFile(e){return this.native.closeFile(this.servicePtr,[e])}async subscribeForStoreEvents(){return this.native.subscribeForStoreEvents(this.servicePtr,[])}async unsubscribeFromStoreEvents(){return this.native.unsubscribeFromStoreEvents(this.servicePtr,[])}async subscribeForFileEvents(e){return this.native.subscribeForFileEvents(this.servicePtr,[e])}async unsubscribeFromFileEvents(e){return this.native.unsubscribeFromFileEvents(this.servicePtr,[e])}}t.StoreApi=n},148:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ThreadApi=void 0;const s=i(647);class n extends s.BaseApi{native;constructor(e,t){super(t),this.native=e}async createThread(e,t,i,s,n,r){return this.native.createThread(this.servicePtr,[e,t,i,s,n,r])}async updateThread(e,t,i,s,n,r,a,c,o){return this.native.updateThread(this.servicePtr,[e,t,i,s,n,r,a,c,o])}async deleteThread(e){return this.native.deleteThread(this.servicePtr,[e])}async getThread(e){return this.native.getThread(this.servicePtr,[e])}async listThreads(e,t){return this.native.listThreads(this.servicePtr,[e,t])}async getMessage(e){return this.native.getMessage(this.servicePtr,[e])}async listMessages(e,t){return this.native.listMessages(this.servicePtr,[e,t])}async sendMessage(e,t,i,s){return this.native.sendMessage(this.servicePtr,[e,t,i,s])}async deleteMessage(e){return this.native.deleteMessage(this.servicePtr,[e])}async updateMessage(e,t,i,s){return this.native.updateMessage(this.servicePtr,[e,t,i,s])}async subscribeForThreadEvents(){return this.native.subscribeForThreadEvents(this.servicePtr,[])}async unsubscribeFromThreadEvents(){return this.native.unsubscribeFromThreadEvents(this.servicePtr,[])}async subscribeForMessageEvents(e){return this.native.subscribeForMessageEvents(this.servicePtr,[e])}async unsubscribeFromMessageEvents(e){return this.native.unsubscribeFromMessageEvents(this.servicePtr,[e])}}t.ThreadApi=n}},t={};function i(s){var n=t[s];if(void 0!==n)return n.exports;var r=t[s]={exports:{}};return e[s](r,r.exports,i),r.exports}var s={};return(()=>{var e=s;Object.defineProperty(e,"__esModule",{value:!0}),e.Endpoint=void 0;const t=i(181);Object.defineProperty(e,"Endpoint",{enumerable:!0,get:function(){return t.EndpointFactory}})})(),s})()));