@massalabs/gossip-sdk 0.0.1 → 0.0.2-dev.20260128111120
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/dist/api/messageProtocol/index.d.ts +19 -0
- package/dist/api/messageProtocol/index.js +26 -0
- package/dist/api/messageProtocol/mock.d.ts +12 -0
- package/{src/api/messageProtocol/mock.ts → dist/api/messageProtocol/mock.js} +2 -3
- package/dist/api/messageProtocol/rest.d.ts +22 -0
- package/dist/api/messageProtocol/rest.js +161 -0
- package/dist/api/messageProtocol/types.d.ts +61 -0
- package/dist/api/messageProtocol/types.js +6 -0
- package/dist/assets/generated/wasm/README.md +281 -0
- package/dist/assets/generated/wasm/gossip_wasm.d.ts +498 -0
- package/dist/assets/generated/wasm/gossip_wasm.js +1399 -0
- package/dist/assets/generated/wasm/gossip_wasm_bg.wasm +0 -0
- package/dist/assets/generated/wasm/gossip_wasm_bg.wasm.d.ts +68 -0
- package/dist/assets/generated/wasm/package.json +15 -0
- package/dist/config/protocol.d.ts +36 -0
- package/dist/config/protocol.js +77 -0
- package/dist/config/sdk.d.ts +82 -0
- package/dist/config/sdk.js +55 -0
- package/{src/contacts.ts → dist/contacts.d.ts} +10 -94
- package/dist/contacts.js +166 -0
- package/dist/core/SdkEventEmitter.d.ts +36 -0
- package/dist/core/SdkEventEmitter.js +59 -0
- package/dist/core/SdkPolling.d.ts +35 -0
- package/dist/core/SdkPolling.js +100 -0
- package/{src/core/index.ts → dist/core/index.d.ts} +0 -2
- package/dist/core/index.js +5 -0
- package/dist/crypto/bip39.d.ts +34 -0
- package/dist/crypto/bip39.js +62 -0
- package/dist/crypto/encryption.d.ts +37 -0
- package/dist/crypto/encryption.js +46 -0
- package/dist/db.d.ts +190 -0
- package/dist/db.js +311 -0
- package/dist/gossipSdk.d.ts +274 -0
- package/dist/gossipSdk.js +690 -0
- package/dist/index.d.ts +73 -0
- package/dist/index.js +77 -0
- package/dist/services/announcement.d.ts +43 -0
- package/dist/services/announcement.js +491 -0
- package/dist/services/auth.d.ts +37 -0
- package/dist/services/auth.js +76 -0
- package/dist/services/discussion.d.ts +63 -0
- package/dist/services/discussion.js +297 -0
- package/dist/services/message.d.ts +74 -0
- package/dist/services/message.js +826 -0
- package/dist/services/refresh.d.ts +41 -0
- package/dist/services/refresh.js +205 -0
- package/{src/sw.ts → dist/sw.d.ts} +1 -8
- package/dist/sw.js +10 -0
- package/dist/types/events.d.ts +80 -0
- package/dist/types/events.js +7 -0
- package/dist/types.d.ts +32 -0
- package/dist/types.js +7 -0
- package/dist/utils/base64.d.ts +10 -0
- package/dist/utils/base64.js +30 -0
- package/dist/utils/contacts.d.ts +42 -0
- package/dist/utils/contacts.js +113 -0
- package/dist/utils/discussions.d.ts +24 -0
- package/dist/utils/discussions.js +38 -0
- package/dist/utils/logs.d.ts +19 -0
- package/dist/utils/logs.js +89 -0
- package/dist/utils/messageSerialization.d.ts +64 -0
- package/dist/utils/messageSerialization.js +184 -0
- package/dist/utils/queue.d.ts +50 -0
- package/dist/utils/queue.js +110 -0
- package/dist/utils/type.d.ts +10 -0
- package/dist/utils/type.js +4 -0
- package/dist/utils/userId.d.ts +40 -0
- package/dist/utils/userId.js +90 -0
- package/dist/utils/validation.d.ts +50 -0
- package/dist/utils/validation.js +112 -0
- package/dist/utils.d.ts +30 -0
- package/{src/utils.ts → dist/utils.js} +9 -19
- package/dist/wasm/encryption.d.ts +56 -0
- package/{src/wasm/encryption.ts → dist/wasm/encryption.js} +22 -51
- package/dist/wasm/index.d.ts +10 -0
- package/{src/wasm/index.ts → dist/wasm/index.js} +1 -8
- package/dist/wasm/loader.d.ts +21 -0
- package/dist/wasm/loader.js +103 -0
- package/dist/wasm/session.d.ts +85 -0
- package/dist/wasm/session.js +226 -0
- package/dist/wasm/userKeys.d.ts +17 -0
- package/{src/wasm/userKeys.ts → dist/wasm/userKeys.js} +6 -13
- package/package.json +5 -1
- package/src/api/messageProtocol/index.ts +0 -53
- package/src/api/messageProtocol/rest.ts +0 -209
- package/src/api/messageProtocol/types.ts +0 -70
- package/src/config/protocol.ts +0 -97
- package/src/config/sdk.ts +0 -131
- package/src/core/SdkEventEmitter.ts +0 -91
- package/src/core/SdkPolling.ts +0 -134
- package/src/crypto/bip39.ts +0 -84
- package/src/crypto/encryption.ts +0 -77
- package/src/db.ts +0 -465
- package/src/gossipSdk.ts +0 -994
- package/src/index.ts +0 -211
- package/src/services/announcement.ts +0 -653
- package/src/services/auth.ts +0 -95
- package/src/services/discussion.ts +0 -380
- package/src/services/message.ts +0 -1055
- package/src/services/refresh.ts +0 -234
- package/src/types/events.ts +0 -108
- package/src/types.ts +0 -70
- package/src/utils/base64.ts +0 -39
- package/src/utils/contacts.ts +0 -161
- package/src/utils/discussions.ts +0 -55
- package/src/utils/logs.ts +0 -86
- package/src/utils/messageSerialization.ts +0 -257
- package/src/utils/queue.ts +0 -106
- package/src/utils/type.ts +0 -7
- package/src/utils/userId.ts +0 -114
- package/src/utils/validation.ts +0 -144
- package/src/wasm/loader.ts +0 -123
- package/src/wasm/session.ts +0 -276
- package/test/config/protocol.spec.ts +0 -31
- package/test/config/sdk.spec.ts +0 -163
- package/test/db/helpers.spec.ts +0 -142
- package/test/db/operations.spec.ts +0 -128
- package/test/db/states.spec.ts +0 -535
- package/test/integration/discussion-flow.spec.ts +0 -422
- package/test/integration/messaging-flow.spec.ts +0 -708
- package/test/integration/sdk-lifecycle.spec.ts +0 -325
- package/test/mocks/index.ts +0 -9
- package/test/mocks/mockMessageProtocol.ts +0 -100
- package/test/services/auth.spec.ts +0 -311
- package/test/services/discussion.spec.ts +0 -279
- package/test/services/message-deduplication.spec.ts +0 -299
- package/test/services/message-startup.spec.ts +0 -331
- package/test/services/message.spec.ts +0 -817
- package/test/services/refresh.spec.ts +0 -199
- package/test/services/session-status.spec.ts +0 -349
- package/test/session/wasm.spec.ts +0 -227
- package/test/setup.ts +0 -52
- package/test/utils/contacts.spec.ts +0 -156
- package/test/utils/discussions.spec.ts +0 -66
- package/test/utils/queue.spec.ts +0 -52
- package/test/utils/serialization.spec.ts +0 -120
- package/test/utils/userId.spec.ts +0 -120
- package/test/utils/validation.spec.ts +0 -223
- package/test/utils.ts +0 -212
- package/tsconfig.json +0 -26
- package/tsconfig.tsbuildinfo +0 -1
- package/vitest.config.ts +0 -28
|
@@ -0,0 +1,498 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export function start(): void;
|
|
4
|
+
/**
|
|
5
|
+
* Generates user keys from a passphrase using password-based key derivation.
|
|
6
|
+
*/
|
|
7
|
+
export function generate_user_keys(passphrase: string): UserKeys;
|
|
8
|
+
/**
|
|
9
|
+
* Encrypts data using AES-256-SIV authenticated encryption.
|
|
10
|
+
*
|
|
11
|
+
* # Parameters
|
|
12
|
+
*
|
|
13
|
+
* - `key`: The encryption key (64 bytes)
|
|
14
|
+
* - `nonce`: The nonce (16 bytes, should be unique per encryption)
|
|
15
|
+
* - `plaintext`: The data to encrypt
|
|
16
|
+
* - `aad`: Additional authenticated data (not encrypted, but authenticated)
|
|
17
|
+
*
|
|
18
|
+
* # Returns
|
|
19
|
+
*
|
|
20
|
+
* The ciphertext with authentication tag appended.
|
|
21
|
+
*
|
|
22
|
+
* # Security Notes
|
|
23
|
+
*
|
|
24
|
+
* - The nonce should be unique for each encryption operation
|
|
25
|
+
* - AES-SIV is nonce-misuse resistant: reusing nonces only leaks if plaintexts are identical
|
|
26
|
+
* - AAD is authenticated but not encrypted; it must be transmitted separately
|
|
27
|
+
* - The same AAD must be provided during decryption
|
|
28
|
+
*
|
|
29
|
+
* # Example
|
|
30
|
+
*
|
|
31
|
+
* ```javascript
|
|
32
|
+
* const key = EncryptionKey.generate();
|
|
33
|
+
* const nonce = Nonce.generate();
|
|
34
|
+
* const plaintext = new TextEncoder().encode("Secret message");
|
|
35
|
+
* const aad = new TextEncoder().encode("context info");
|
|
36
|
+
*
|
|
37
|
+
* const ciphertext = aead_encrypt(key, nonce, plaintext, aad);
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export function aead_encrypt(key: EncryptionKey, nonce: Nonce, plaintext: Uint8Array, aad: Uint8Array): Uint8Array;
|
|
41
|
+
/**
|
|
42
|
+
* Decrypts data using AES-256-SIV authenticated encryption.
|
|
43
|
+
*
|
|
44
|
+
* # Parameters
|
|
45
|
+
*
|
|
46
|
+
* - `key`: The encryption key (64 bytes, must match encryption key)
|
|
47
|
+
* - `nonce`: The nonce (16 bytes, must match encryption nonce)
|
|
48
|
+
* - `ciphertext`: The encrypted data with authentication tag
|
|
49
|
+
* - `aad`: Additional authenticated data (must match encryption AAD)
|
|
50
|
+
*
|
|
51
|
+
* # Returns
|
|
52
|
+
*
|
|
53
|
+
* The decrypted plaintext, or `null` if authentication fails.
|
|
54
|
+
*
|
|
55
|
+
* # Security Notes
|
|
56
|
+
*
|
|
57
|
+
* - Returns `null` if:
|
|
58
|
+
* - The ciphertext has been tampered with
|
|
59
|
+
* - The wrong key or nonce is used
|
|
60
|
+
* - The AAD doesn't match
|
|
61
|
+
* - Never ignore a decryption failure; it indicates tampering or corruption
|
|
62
|
+
*
|
|
63
|
+
* # Example
|
|
64
|
+
*
|
|
65
|
+
* ```javascript
|
|
66
|
+
* const plaintext = aead_decrypt(key, nonce, ciphertext, aad);
|
|
67
|
+
* if (plaintext) {
|
|
68
|
+
* console.log("Decrypted:", new TextDecoder().decode(plaintext));
|
|
69
|
+
* } else {
|
|
70
|
+
* console.error("Decryption failed - data may be corrupted or tampered");
|
|
71
|
+
* }
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
export function aead_decrypt(key: EncryptionKey, nonce: Nonce, ciphertext: Uint8Array, aad: Uint8Array): Uint8Array | undefined;
|
|
75
|
+
/**
|
|
76
|
+
* Session status indicating the state of a peer session.
|
|
77
|
+
*/
|
|
78
|
+
export enum SessionStatus {
|
|
79
|
+
Active = 0,
|
|
80
|
+
UnknownPeer = 1,
|
|
81
|
+
NoSession = 2,
|
|
82
|
+
PeerRequested = 3,
|
|
83
|
+
SelfRequested = 4,
|
|
84
|
+
Killed = 5,
|
|
85
|
+
Saturated = 6,
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Result from feeding an incoming announcement.
|
|
89
|
+
*/
|
|
90
|
+
export class AnnouncementResult {
|
|
91
|
+
private constructor();
|
|
92
|
+
free(): void;
|
|
93
|
+
[Symbol.dispose](): void;
|
|
94
|
+
/**
|
|
95
|
+
* Gets the announcer's public keys.
|
|
96
|
+
*/
|
|
97
|
+
readonly announcer_public_keys: UserPublicKeys;
|
|
98
|
+
/**
|
|
99
|
+
* Gets the announcement timestamp in milliseconds since Unix epoch.
|
|
100
|
+
*/
|
|
101
|
+
readonly timestamp: number;
|
|
102
|
+
/**
|
|
103
|
+
* Gets the user data embedded in the announcement.
|
|
104
|
+
*/
|
|
105
|
+
readonly user_data: Uint8Array;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Encryption key for AEAD operations (AES-256-SIV).
|
|
109
|
+
*
|
|
110
|
+
* AES-256-SIV uses a 64-byte (512-bit) key: two 256-bit keys for encryption and MAC.
|
|
111
|
+
*/
|
|
112
|
+
export class EncryptionKey {
|
|
113
|
+
private constructor();
|
|
114
|
+
free(): void;
|
|
115
|
+
[Symbol.dispose](): void;
|
|
116
|
+
/**
|
|
117
|
+
* Generates a new random encryption key (64 bytes).
|
|
118
|
+
*/
|
|
119
|
+
static generate(): EncryptionKey;
|
|
120
|
+
/**
|
|
121
|
+
* Generates a deterministic encryption key (64 bytes) from a seed and salt.
|
|
122
|
+
*
|
|
123
|
+
* Uses Argon2id via `crypto_password_kdf` to derive a 64-byte key suitable for
|
|
124
|
+
* AES-256-SIV (which requires 64 bytes: 2×256-bit keys).
|
|
125
|
+
*
|
|
126
|
+
* - `seed`: application-provided seed string (treat like a password)
|
|
127
|
+
* - `salt`: unique, random salt (minimum 8 bytes, recommended 16+ bytes)
|
|
128
|
+
*/
|
|
129
|
+
static from_seed(seed: string, salt: Uint8Array): EncryptionKey;
|
|
130
|
+
/**
|
|
131
|
+
* Creates an encryption key from raw bytes (must be 64 bytes).
|
|
132
|
+
*/
|
|
133
|
+
static from_bytes(bytes: Uint8Array): EncryptionKey;
|
|
134
|
+
/**
|
|
135
|
+
* Gets the raw bytes of the encryption key.
|
|
136
|
+
*/
|
|
137
|
+
to_bytes(): Uint8Array;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Nonce for AEAD operations (AES-256-SIV).
|
|
141
|
+
*
|
|
142
|
+
* AES-256-SIV uses a 16-byte (128-bit) nonce. The nonce should be unique
|
|
143
|
+
* per encryption for maximum security, though SIV mode is nonce-misuse resistant.
|
|
144
|
+
*/
|
|
145
|
+
export class Nonce {
|
|
146
|
+
private constructor();
|
|
147
|
+
free(): void;
|
|
148
|
+
[Symbol.dispose](): void;
|
|
149
|
+
/**
|
|
150
|
+
* Generates a new random nonce (16 bytes).
|
|
151
|
+
*/
|
|
152
|
+
static generate(): Nonce;
|
|
153
|
+
/**
|
|
154
|
+
* Creates a nonce from raw bytes (must be 16 bytes).
|
|
155
|
+
*/
|
|
156
|
+
static from_bytes(bytes: Uint8Array): Nonce;
|
|
157
|
+
/**
|
|
158
|
+
* Gets the raw bytes of the nonce.
|
|
159
|
+
*/
|
|
160
|
+
to_bytes(): Uint8Array;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Output from receiving a message.
|
|
164
|
+
*/
|
|
165
|
+
export class ReceiveMessageOutput {
|
|
166
|
+
private constructor();
|
|
167
|
+
free(): void;
|
|
168
|
+
[Symbol.dispose](): void;
|
|
169
|
+
/**
|
|
170
|
+
* Gets the received message contents.
|
|
171
|
+
*/
|
|
172
|
+
readonly message: Uint8Array;
|
|
173
|
+
/**
|
|
174
|
+
* Gets the message timestamp (milliseconds since Unix epoch).
|
|
175
|
+
*/
|
|
176
|
+
readonly timestamp: number;
|
|
177
|
+
/**
|
|
178
|
+
* Gets the list of newly acknowledged seekers.
|
|
179
|
+
*/
|
|
180
|
+
readonly acknowledged_seekers: Array<any>;
|
|
181
|
+
/**
|
|
182
|
+
* Gets the sender's user id (32 bytes).
|
|
183
|
+
*/
|
|
184
|
+
readonly user_id: Uint8Array;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Output from sending a message.
|
|
188
|
+
*/
|
|
189
|
+
export class SendMessageOutput {
|
|
190
|
+
private constructor();
|
|
191
|
+
free(): void;
|
|
192
|
+
[Symbol.dispose](): void;
|
|
193
|
+
/**
|
|
194
|
+
* Gets the seeker (identifier for message board lookup).
|
|
195
|
+
*/
|
|
196
|
+
readonly seeker: Uint8Array;
|
|
197
|
+
/**
|
|
198
|
+
* Gets the encrypted message data.
|
|
199
|
+
*/
|
|
200
|
+
readonly data: Uint8Array;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Session manager configuration for controlling session behavior.
|
|
204
|
+
*/
|
|
205
|
+
export class SessionConfig {
|
|
206
|
+
free(): void;
|
|
207
|
+
[Symbol.dispose](): void;
|
|
208
|
+
/**
|
|
209
|
+
* Creates a new session configuration with the given parameters.
|
|
210
|
+
*/
|
|
211
|
+
constructor(max_incoming_announcement_age_millis: number, max_incoming_announcement_future_millis: number, max_incoming_message_age_millis: number, max_incoming_message_future_millis: number, max_session_inactivity_millis: number, keep_alive_interval_millis: number, max_session_lag_length: bigint);
|
|
212
|
+
/**
|
|
213
|
+
* Creates a default configuration with sensible defaults:
|
|
214
|
+
* - Announcement age: 1 week
|
|
215
|
+
* - Announcement future: 1 minute
|
|
216
|
+
* - Message age: 1 week
|
|
217
|
+
* - Message future: 1 minute
|
|
218
|
+
* - Session inactivity: 1 week
|
|
219
|
+
* - Keep-alive interval: 1 day
|
|
220
|
+
* - Max lag: 10000 messages
|
|
221
|
+
*/
|
|
222
|
+
static new_default(): SessionConfig;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Session manager wrapper for WebAssembly.
|
|
226
|
+
*/
|
|
227
|
+
export class SessionManagerWrapper {
|
|
228
|
+
free(): void;
|
|
229
|
+
[Symbol.dispose](): void;
|
|
230
|
+
/**
|
|
231
|
+
* Creates a new session manager with the given configuration.
|
|
232
|
+
*/
|
|
233
|
+
constructor(config: SessionConfig);
|
|
234
|
+
/**
|
|
235
|
+
* Deserializes a session manager from an encrypted blob.
|
|
236
|
+
*/
|
|
237
|
+
static from_encrypted_blob(encrypted_blob: Uint8Array, key: EncryptionKey): SessionManagerWrapper;
|
|
238
|
+
/**
|
|
239
|
+
* Serializes and encrypts the session manager into a blob.
|
|
240
|
+
*/
|
|
241
|
+
to_encrypted_blob(key: EncryptionKey): Uint8Array;
|
|
242
|
+
/**
|
|
243
|
+
* Establishes an outgoing session with a peer.
|
|
244
|
+
*
|
|
245
|
+
* # Parameters
|
|
246
|
+
*
|
|
247
|
+
* - `peer_pk`: The peer's public keys
|
|
248
|
+
* - `our_pk`: Our public keys
|
|
249
|
+
* - `our_sk`: Our secret keys
|
|
250
|
+
* - `user_data`: Arbitrary user data to include in the announcement (can be empty)
|
|
251
|
+
*
|
|
252
|
+
* # Security Warning
|
|
253
|
+
*
|
|
254
|
+
* **The user_data in announcements has reduced security compared to regular messages:**
|
|
255
|
+
* - ✅ **Plausible deniability preserved**: The user_data is not cryptographically signed,
|
|
256
|
+
* so you can deny having sent specific user_data content (though you cannot deny the
|
|
257
|
+
* announcement itself).
|
|
258
|
+
* - ❌ **No post-compromise secrecy**: If your long-term keys are compromised in the
|
|
259
|
+
* future, past announcements (including their user_data) can be decrypted.
|
|
260
|
+
*
|
|
261
|
+
* **Recommendation**: Avoid including highly sensitive information in user_data. Use it for
|
|
262
|
+
* metadata like protocol version, public display names, or capability flags. Send truly
|
|
263
|
+
* sensitive data through regular messages after the session is established.
|
|
264
|
+
*
|
|
265
|
+
* # Returns
|
|
266
|
+
*
|
|
267
|
+
* The announcement bytes to publish to the blockchain.
|
|
268
|
+
*/
|
|
269
|
+
establish_outgoing_session(peer_pk: UserPublicKeys, our_pk: UserPublicKeys, our_sk: UserSecretKeys, user_data: Uint8Array): Uint8Array;
|
|
270
|
+
/**
|
|
271
|
+
* Feeds an incoming announcement from the blockchain.
|
|
272
|
+
*
|
|
273
|
+
* # Parameters
|
|
274
|
+
*
|
|
275
|
+
* - `announcement_bytes`: The raw announcement bytes received from the blockchain
|
|
276
|
+
* - `our_pk`: Our public keys
|
|
277
|
+
* - `our_sk`: Our secret keys
|
|
278
|
+
*
|
|
279
|
+
* # Returns
|
|
280
|
+
*
|
|
281
|
+
* If the announcement is valid, returns an `AnnouncementResult` containing:
|
|
282
|
+
* - The announcer's public keys
|
|
283
|
+
* - The timestamp when the announcement was created (milliseconds since Unix epoch)
|
|
284
|
+
* - The user data embedded in the announcement
|
|
285
|
+
*
|
|
286
|
+
* Returns `None` if the announcement is invalid or too old.
|
|
287
|
+
*
|
|
288
|
+
* # Security Warning
|
|
289
|
+
*
|
|
290
|
+
* **The user_data in announcements has reduced security compared to regular messages:**
|
|
291
|
+
* - ✅ **Plausible deniability preserved**: The user_data is not cryptographically signed,
|
|
292
|
+
* so the sender can deny having sent specific user_data content (though they cannot deny
|
|
293
|
+
* the announcement itself).
|
|
294
|
+
* - ❌ **No post-compromise secrecy**: If the sender's long-term keys are compromised
|
|
295
|
+
* in the future, all past announcements (including their user_data) can be decrypted.
|
|
296
|
+
*
|
|
297
|
+
* **Recommendation**: Treat user_data as having limited confidentiality. Use it for
|
|
298
|
+
* metadata that is not highly sensitive. Send truly sensitive information through regular
|
|
299
|
+
* messages after the session is established.
|
|
300
|
+
*/
|
|
301
|
+
feed_incoming_announcement(announcement_bytes: Uint8Array, our_pk: UserPublicKeys, our_sk: UserSecretKeys): AnnouncementResult | undefined;
|
|
302
|
+
/**
|
|
303
|
+
* Gets the list of message board seekers to monitor.
|
|
304
|
+
*/
|
|
305
|
+
get_message_board_read_keys(): Array<any>;
|
|
306
|
+
/**
|
|
307
|
+
* Sends a message to a peer.
|
|
308
|
+
*/
|
|
309
|
+
send_message(peer_id: Uint8Array, message_contents: Uint8Array): SendMessageOutput | undefined;
|
|
310
|
+
/**
|
|
311
|
+
* Processes an incoming message from the message board.
|
|
312
|
+
*/
|
|
313
|
+
feed_incoming_message_board_read(seeker: Uint8Array, ciphertext: Uint8Array, our_sk: UserSecretKeys): ReceiveMessageOutput | undefined;
|
|
314
|
+
/**
|
|
315
|
+
* Gets the list of all peer IDs.
|
|
316
|
+
*/
|
|
317
|
+
peer_list(): Array<any>;
|
|
318
|
+
/**
|
|
319
|
+
* Gets the session status for a peer.
|
|
320
|
+
*/
|
|
321
|
+
peer_session_status(peer_id: Uint8Array): SessionStatus;
|
|
322
|
+
/**
|
|
323
|
+
* Discards a peer and all associated session state.
|
|
324
|
+
*/
|
|
325
|
+
peer_discard(peer_id: Uint8Array): void;
|
|
326
|
+
/**
|
|
327
|
+
* Refreshes sessions and returns peer IDs that need keep-alive messages.
|
|
328
|
+
*/
|
|
329
|
+
refresh(): Array<any>;
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* User keypair containing both public and secret keys.
|
|
333
|
+
*/
|
|
334
|
+
export class UserKeys {
|
|
335
|
+
private constructor();
|
|
336
|
+
free(): void;
|
|
337
|
+
[Symbol.dispose](): void;
|
|
338
|
+
/**
|
|
339
|
+
* Gets the public keys.
|
|
340
|
+
*/
|
|
341
|
+
public_keys(): UserPublicKeys;
|
|
342
|
+
/**
|
|
343
|
+
* Gets the secret keys.
|
|
344
|
+
*/
|
|
345
|
+
secret_keys(): UserSecretKeys;
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* User public keys for authentication and encryption.
|
|
349
|
+
*/
|
|
350
|
+
export class UserPublicKeys {
|
|
351
|
+
private constructor();
|
|
352
|
+
free(): void;
|
|
353
|
+
[Symbol.dispose](): void;
|
|
354
|
+
/**
|
|
355
|
+
* Derives a unique user ID from the public keys.
|
|
356
|
+
*/
|
|
357
|
+
derive_id(): Uint8Array;
|
|
358
|
+
/**
|
|
359
|
+
* Serializes the public keys to bytes.
|
|
360
|
+
*/
|
|
361
|
+
to_bytes(): Uint8Array;
|
|
362
|
+
/**
|
|
363
|
+
* Deserializes public keys from bytes.
|
|
364
|
+
*/
|
|
365
|
+
static from_bytes(bytes: Uint8Array): UserPublicKeys;
|
|
366
|
+
/**
|
|
367
|
+
* Gets the DSA verification key bytes.
|
|
368
|
+
*/
|
|
369
|
+
readonly dsa_verification_key: Uint8Array;
|
|
370
|
+
/**
|
|
371
|
+
* Gets the KEM public key bytes.
|
|
372
|
+
*/
|
|
373
|
+
readonly kem_public_key: Uint8Array;
|
|
374
|
+
/**
|
|
375
|
+
* Gets the Massa public key bytes.
|
|
376
|
+
*/
|
|
377
|
+
readonly massa_public_key: Uint8Array;
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* User secret keys for signing and decryption.
|
|
381
|
+
*/
|
|
382
|
+
export class UserSecretKeys {
|
|
383
|
+
private constructor();
|
|
384
|
+
free(): void;
|
|
385
|
+
[Symbol.dispose](): void;
|
|
386
|
+
/**
|
|
387
|
+
* Serializes the secret keys to bytes for secure storage.
|
|
388
|
+
*/
|
|
389
|
+
to_bytes(): Uint8Array;
|
|
390
|
+
/**
|
|
391
|
+
* Deserializes secret keys from bytes.
|
|
392
|
+
*/
|
|
393
|
+
static from_bytes(bytes: Uint8Array): UserSecretKeys;
|
|
394
|
+
/**
|
|
395
|
+
* Gets the DSA signing key bytes.
|
|
396
|
+
*/
|
|
397
|
+
readonly dsa_signing_key: Uint8Array;
|
|
398
|
+
/**
|
|
399
|
+
* Gets the KEM secret key bytes.
|
|
400
|
+
*/
|
|
401
|
+
readonly kem_secret_key: Uint8Array;
|
|
402
|
+
/**
|
|
403
|
+
* Gets only the Massa secret key bytes
|
|
404
|
+
*/
|
|
405
|
+
readonly massa_secret_key: Uint8Array;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
409
|
+
|
|
410
|
+
export interface InitOutput {
|
|
411
|
+
readonly memory: WebAssembly.Memory;
|
|
412
|
+
readonly __wbg_sessionconfig_free: (a: number, b: number) => void;
|
|
413
|
+
readonly sessionconfig_new: (a: number, b: number, c: number, d: number, e: number, f: number, g: bigint) => number;
|
|
414
|
+
readonly sessionconfig_new_default: () => number;
|
|
415
|
+
readonly __wbg_userpublickeys_free: (a: number, b: number) => void;
|
|
416
|
+
readonly userpublickeys_derive_id: (a: number) => [number, number];
|
|
417
|
+
readonly userpublickeys_dsa_verification_key: (a: number) => [number, number];
|
|
418
|
+
readonly userpublickeys_kem_public_key: (a: number) => [number, number];
|
|
419
|
+
readonly userpublickeys_massa_public_key: (a: number) => [number, number];
|
|
420
|
+
readonly userpublickeys_to_bytes: (a: number) => [number, number, number, number];
|
|
421
|
+
readonly userpublickeys_from_bytes: (a: number, b: number) => [number, number, number];
|
|
422
|
+
readonly __wbg_usersecretkeys_free: (a: number, b: number) => void;
|
|
423
|
+
readonly usersecretkeys_to_bytes: (a: number) => [number, number, number, number];
|
|
424
|
+
readonly usersecretkeys_from_bytes: (a: number, b: number) => [number, number, number];
|
|
425
|
+
readonly usersecretkeys_dsa_signing_key: (a: number) => [number, number];
|
|
426
|
+
readonly usersecretkeys_kem_secret_key: (a: number) => [number, number];
|
|
427
|
+
readonly usersecretkeys_massa_secret_key: (a: number) => [number, number];
|
|
428
|
+
readonly __wbg_userkeys_free: (a: number, b: number) => void;
|
|
429
|
+
readonly userkeys_public_keys: (a: number) => [number, number, number];
|
|
430
|
+
readonly userkeys_secret_keys: (a: number) => [number, number, number];
|
|
431
|
+
readonly generate_user_keys: (a: number, b: number) => [number, number, number];
|
|
432
|
+
readonly __wbg_encryptionkey_free: (a: number, b: number) => void;
|
|
433
|
+
readonly encryptionkey_generate: () => number;
|
|
434
|
+
readonly encryptionkey_from_seed: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
435
|
+
readonly encryptionkey_from_bytes: (a: number, b: number) => [number, number, number];
|
|
436
|
+
readonly encryptionkey_to_bytes: (a: number) => [number, number];
|
|
437
|
+
readonly __wbg_nonce_free: (a: number, b: number) => void;
|
|
438
|
+
readonly nonce_generate: () => number;
|
|
439
|
+
readonly nonce_from_bytes: (a: number, b: number) => [number, number, number];
|
|
440
|
+
readonly nonce_to_bytes: (a: number) => [number, number];
|
|
441
|
+
readonly aead_encrypt: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
|
|
442
|
+
readonly aead_decrypt: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
|
|
443
|
+
readonly __wbg_sendmessageoutput_free: (a: number, b: number) => void;
|
|
444
|
+
readonly sendmessageoutput_seeker: (a: number) => [number, number];
|
|
445
|
+
readonly sendmessageoutput_data: (a: number) => [number, number];
|
|
446
|
+
readonly __wbg_receivemessageoutput_free: (a: number, b: number) => void;
|
|
447
|
+
readonly __wbg_announcementresult_free: (a: number, b: number) => void;
|
|
448
|
+
readonly announcementresult_announcer_public_keys: (a: number) => number;
|
|
449
|
+
readonly announcementresult_timestamp: (a: number) => number;
|
|
450
|
+
readonly announcementresult_user_data: (a: number) => [number, number];
|
|
451
|
+
readonly receivemessageoutput_message: (a: number) => [number, number];
|
|
452
|
+
readonly receivemessageoutput_timestamp: (a: number) => number;
|
|
453
|
+
readonly receivemessageoutput_acknowledged_seekers: (a: number) => any;
|
|
454
|
+
readonly receivemessageoutput_user_id: (a: number) => [number, number];
|
|
455
|
+
readonly __wbg_sessionmanagerwrapper_free: (a: number, b: number) => void;
|
|
456
|
+
readonly sessionmanagerwrapper_new: (a: number) => number;
|
|
457
|
+
readonly sessionmanagerwrapper_from_encrypted_blob: (a: number, b: number, c: number) => [number, number, number];
|
|
458
|
+
readonly sessionmanagerwrapper_to_encrypted_blob: (a: number, b: number) => [number, number, number, number];
|
|
459
|
+
readonly sessionmanagerwrapper_establish_outgoing_session: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
|
|
460
|
+
readonly sessionmanagerwrapper_feed_incoming_announcement: (a: number, b: number, c: number, d: number, e: number) => number;
|
|
461
|
+
readonly sessionmanagerwrapper_get_message_board_read_keys: (a: number) => any;
|
|
462
|
+
readonly sessionmanagerwrapper_send_message: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
|
|
463
|
+
readonly sessionmanagerwrapper_feed_incoming_message_board_read: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
|
|
464
|
+
readonly sessionmanagerwrapper_peer_list: (a: number) => any;
|
|
465
|
+
readonly sessionmanagerwrapper_peer_session_status: (a: number, b: number, c: number) => [number, number, number];
|
|
466
|
+
readonly sessionmanagerwrapper_peer_discard: (a: number, b: number, c: number) => [number, number];
|
|
467
|
+
readonly sessionmanagerwrapper_refresh: (a: number) => any;
|
|
468
|
+
readonly start: () => void;
|
|
469
|
+
readonly __wbindgen_exn_store: (a: number) => void;
|
|
470
|
+
readonly __externref_table_alloc: () => number;
|
|
471
|
+
readonly __wbindgen_export_2: WebAssembly.Table;
|
|
472
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
473
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
474
|
+
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
475
|
+
readonly __externref_table_dealloc: (a: number) => void;
|
|
476
|
+
readonly __wbindgen_start: () => void;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
480
|
+
/**
|
|
481
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
482
|
+
* a precompiled `WebAssembly.Module`.
|
|
483
|
+
*
|
|
484
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
485
|
+
*
|
|
486
|
+
* @returns {InitOutput}
|
|
487
|
+
*/
|
|
488
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
489
|
+
|
|
490
|
+
/**
|
|
491
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
492
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
493
|
+
*
|
|
494
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
495
|
+
*
|
|
496
|
+
* @returns {Promise<InitOutput>}
|
|
497
|
+
*/
|
|
498
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|