ping-openmls-sdk 0.1.1 → 0.2.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.
@@ -0,0 +1,259 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ export class PingClient {
5
+ private constructor();
6
+ free(): void;
7
+ [Symbol.dispose](): void;
8
+ /**
9
+ * Add members ([CR-2]). `entries` is an array of `{ deviceId: Uint8Array,
10
+ * keyPackage: Uint8Array }`. Bundling the device_id with the KeyPackage lets us
11
+ * persist a per-conversation device→leaf map for [`revokeDevice`].
12
+ */
13
+ addMembers(conv_id: Uint8Array, entries: any, now_ms: number): Promise<void>;
14
+ /**
15
+ * Build a `LinkingTicket` ([CR-13] populates `catchup_snapshot` from `last_app_events`).
16
+ *
17
+ * `last_app_events` is an array of `{ conversationId: Uint8Array, appEventBytes:
18
+ * Uint8Array }`. Pass `[]` to suppress catchup data.
19
+ */
20
+ buildLinkingTicket(new_device_id: Uint8Array, new_device_kp: Uint8Array, last_app_events: any, now_ms: number): Promise<any>;
21
+ consumeLinkingTicket(ticket: any, now_ms: number): Promise<void>;
22
+ createConversation(name: string | null | undefined, now_ms: number): Promise<Uint8Array>;
23
+ deviceId(): Uint8Array;
24
+ /**
25
+ * Export a derived secret from a conversation's MLS exporter ([CR-8]).
26
+ *
27
+ * The core wraps the bytes in `Zeroizing<Vec<u8>>`; once they cross the WASM/JS
28
+ * boundary they live in a regular JS `Uint8Array` and JS GC controls the lifetime.
29
+ * Callers in JS MUST treat the buffer as a secret — never log, persist only
30
+ * encrypted, and clear the typed array when done (`u8.fill(0)`).
31
+ */
32
+ exportConversationSecret(conv_id: Uint8Array, label: string, context: Uint8Array, length: number): Uint8Array;
33
+ /**
34
+ * [CR-7] Export the MLS state snapshot for one conversation.
35
+ */
36
+ exportConversationStateSnapshot(conv_id: Uint8Array, now_ms: number): Uint8Array;
37
+ freshKeyPackage(): Uint8Array;
38
+ /**
39
+ * Generate a fresh identity. Returns the export bytes — store them under the user's account.
40
+ */
41
+ static generateIdentity(): Uint8Array;
42
+ /**
43
+ * [CR-7] Import an MLS state snapshot produced by another device of the same
44
+ * user identity. Returns the conversation id the snapshot describes.
45
+ */
46
+ importStateSnapshot(snapshot_bytes: Uint8Array, now_ms: number): Promise<Uint8Array>;
47
+ /**
48
+ * Initialise the client. Pass an exported identity (use `generateIdentity()` for a fresh one).
49
+ */
50
+ static init(identity_export: Uint8Array, device_label: string, storage: JsStorage, transport: JsTransport, now_ms: number): Promise<PingClient>;
51
+ joinConversation(welcome: any, now_ms: number): Promise<Uint8Array>;
52
+ listConversations(): any;
53
+ onMessage(cb: Function): void;
54
+ processEnvelope(env: any, now_ms: number): Promise<any>;
55
+ removeMembers(conv_id: Uint8Array, leaves: Uint32Array, now_ms: number): Promise<void>;
56
+ /**
57
+ * Revoke a device ([CR-2]). Returns an array of Commit envelopes — one per
58
+ * conversation the device was a locally-known leaf in. Each envelope has already
59
+ * been handed to the transport; the host's hand-back is for any additional
60
+ * receipt-of-revocation handling.
61
+ */
62
+ revokeDevice(device_id: Uint8Array, now_ms: number): Promise<any>;
63
+ send(conv_id: Uint8Array, plaintext: Uint8Array, now_ms: number): Promise<any>;
64
+ syncConversations(now_ms: number): Promise<any>;
65
+ userId(): Uint8Array;
66
+ }
67
+
68
+ /**
69
+ * Runtime test harness support instantiated in JS.
70
+ *
71
+ * The node.js entry script instantiates a `Context` here which is used to
72
+ * drive test execution.
73
+ */
74
+ export class WasmBindgenTestContext {
75
+ free(): void;
76
+ [Symbol.dispose](): void;
77
+ /**
78
+ * Handle filter argument.
79
+ */
80
+ filtered_count(filtered: number): void;
81
+ /**
82
+ * Handle `--include-ignored` flag.
83
+ */
84
+ include_ignored(include_ignored: boolean): void;
85
+ /**
86
+ * Creates a new context ready to run tests.
87
+ *
88
+ * A `Context` is the main structure through which test execution is
89
+ * coordinated, and this will collect output and results for all executed
90
+ * tests.
91
+ */
92
+ constructor(is_bench: boolean);
93
+ /**
94
+ * Executes a list of tests, returning a promise representing their
95
+ * eventual completion.
96
+ *
97
+ * This is the main entry point for executing tests. All the tests passed
98
+ * in are the JS `Function` object that was plucked off the
99
+ * `WebAssembly.Instance` exports list.
100
+ *
101
+ * The promise returned resolves to either `true` if all tests passed or
102
+ * `false` if at least one test failed.
103
+ */
104
+ run(tests: any[]): Promise<any>;
105
+ }
106
+
107
+ /**
108
+ * Used to read benchmark data, and then the runner stores it on the local disk.
109
+ */
110
+ export function __wbgbench_dump(): Uint8Array | undefined;
111
+
112
+ /**
113
+ * Used to write previous benchmark data before the benchmark, for later comparison.
114
+ */
115
+ export function __wbgbench_import(baseline: Uint8Array): void;
116
+
117
+ /**
118
+ * Handler for `console.debug` invocations. See above.
119
+ */
120
+ export function __wbgtest_console_debug(args: Array<any>): void;
121
+
122
+ /**
123
+ * Handler for `console.error` invocations. See above.
124
+ */
125
+ export function __wbgtest_console_error(args: Array<any>): void;
126
+
127
+ /**
128
+ * Handler for `console.info` invocations. See above.
129
+ */
130
+ export function __wbgtest_console_info(args: Array<any>): void;
131
+
132
+ /**
133
+ * Handler for `console.log` invocations.
134
+ *
135
+ * If a test is currently running it takes the `args` array and stringifies
136
+ * it and appends it to the current output of the test. Otherwise it passes
137
+ * the arguments to the original `console.log` function, psased as
138
+ * `original`.
139
+ */
140
+ export function __wbgtest_console_log(args: Array<any>): void;
141
+
142
+ /**
143
+ * Handler for `console.warn` invocations. See above.
144
+ */
145
+ export function __wbgtest_console_warn(args: Array<any>): void;
146
+
147
+ export function __wbgtest_cov_dump(): Uint8Array | undefined;
148
+
149
+ /**
150
+ * Path to use for coverage data.
151
+ */
152
+ export function __wbgtest_coverage_path(env: string | null | undefined, pid: number, temp_dir: string, module_signature: bigint): string;
153
+
154
+ export function __wbgtest_module_signature(): bigint | undefined;
155
+
156
+ export function _start(): void;
157
+
158
+ /**
159
+ * HPKE-open a sealed `LinkingTicket` ([CR-3]). Pure function — usable without an
160
+ * initialized `PingClient`, which is exactly the situation the receiving device is in
161
+ * (pre-bootstrap; no identity yet).
162
+ *
163
+ * `new_device_priv` must be 32 bytes (X25519 private key). Errors are returned with a
164
+ * generic message — the new device shouldn't get to discriminate "wrong key" from
165
+ * "tampered ciphertext".
166
+ * [CR-13] Decode a `LinkingTicket.catchup_snapshot` blob. Pure function; no client
167
+ * required. The new device calls this after `consumeLinkingTicket` to populate its
168
+ * initial UI.
169
+ */
170
+ export function decodeCatchupSnapshot(snapshot_bytes: Uint8Array): any;
171
+
172
+ export function openLinkingTicket(sealed: Uint8Array, new_device_priv: Uint8Array): any;
173
+
174
+ /**
175
+ * HPKE-seal a `LinkingTicket` ([CR-3]). Pure function — does not need an initialized
176
+ * `PingClient`, so it's exported at module scope and the JS facade can call it from an
177
+ * ephemeral worker (no full client init needed on the sender side).
178
+ *
179
+ * `new_device_pub` must be 32 bytes. Returns CBOR-encoded sealed bytes.
180
+ */
181
+ export function sealLinkingTicket(ticket: any, new_device_pub: Uint8Array): Uint8Array;
182
+
183
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
184
+
185
+ export interface InitOutput {
186
+ readonly memory: WebAssembly.Memory;
187
+ readonly __wbg_pingclient_free: (a: number, b: number) => void;
188
+ readonly decodeCatchupSnapshot: (a: number, b: number, c: number) => void;
189
+ readonly openLinkingTicket: (a: number, b: number, c: number, d: number, e: number) => void;
190
+ readonly pingclient_addMembers: (a: number, b: number, c: number, d: number, e: number) => number;
191
+ readonly pingclient_buildLinkingTicket: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => number;
192
+ readonly pingclient_consumeLinkingTicket: (a: number, b: number, c: number) => number;
193
+ readonly pingclient_createConversation: (a: number, b: number, c: number, d: number) => number;
194
+ readonly pingclient_deviceId: (a: number, b: number) => void;
195
+ readonly pingclient_exportConversationSecret: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
196
+ readonly pingclient_exportConversationStateSnapshot: (a: number, b: number, c: number, d: number, e: number) => void;
197
+ readonly pingclient_freshKeyPackage: (a: number, b: number) => void;
198
+ readonly pingclient_generateIdentity: (a: number) => void;
199
+ readonly pingclient_importStateSnapshot: (a: number, b: number, c: number, d: number) => number;
200
+ readonly pingclient_init: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => number;
201
+ readonly pingclient_joinConversation: (a: number, b: number, c: number) => number;
202
+ readonly pingclient_listConversations: (a: number, b: number) => void;
203
+ readonly pingclient_onMessage: (a: number, b: number) => void;
204
+ readonly pingclient_processEnvelope: (a: number, b: number, c: number) => number;
205
+ readonly pingclient_removeMembers: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
206
+ readonly pingclient_revokeDevice: (a: number, b: number, c: number, d: number) => number;
207
+ readonly pingclient_send: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
208
+ readonly pingclient_syncConversations: (a: number, b: number) => number;
209
+ readonly pingclient_userId: (a: number, b: number) => void;
210
+ readonly sealLinkingTicket: (a: number, b: number, c: number, d: number) => void;
211
+ readonly _start: () => void;
212
+ readonly __wbg_wasmbindgentestcontext_free: (a: number, b: number) => void;
213
+ readonly __wbgbench_dump: (a: number) => void;
214
+ readonly __wbgbench_import: (a: number, b: number) => void;
215
+ readonly __wbgtest_console_debug: (a: number) => void;
216
+ readonly __wbgtest_console_error: (a: number) => void;
217
+ readonly __wbgtest_console_info: (a: number) => void;
218
+ readonly __wbgtest_console_log: (a: number) => void;
219
+ readonly __wbgtest_console_warn: (a: number) => void;
220
+ readonly __wbgtest_cov_dump: (a: number) => void;
221
+ readonly __wbgtest_coverage_path: (a: number, b: number, c: number, d: number, e: number, f: number, g: bigint) => void;
222
+ readonly __wbgtest_module_signature: (a: number) => void;
223
+ readonly wasmbindgentestcontext_filtered_count: (a: number, b: number) => void;
224
+ readonly wasmbindgentestcontext_include_ignored: (a: number, b: number) => void;
225
+ readonly wasmbindgentestcontext_new: (a: number) => number;
226
+ readonly wasmbindgentestcontext_run: (a: number, b: number, c: number) => number;
227
+ readonly __wasm_bindgen_func_elem_2609: (a: number, b: number, c: number, d: number, e: number) => void;
228
+ readonly __wasm_bindgen_func_elem_2599: (a: number, b: number, c: number, d: number) => void;
229
+ readonly __wasm_bindgen_func_elem_2608: (a: number, b: number, c: number, d: number) => void;
230
+ readonly __wbindgen_export: (a: number, b: number) => number;
231
+ readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
232
+ readonly __wbindgen_export3: (a: number) => void;
233
+ readonly __wbindgen_export4: (a: number, b: number, c: number) => void;
234
+ readonly __wbindgen_export5: (a: number, b: number) => void;
235
+ readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
236
+ readonly __wbindgen_start: () => void;
237
+ }
238
+
239
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
240
+
241
+ /**
242
+ * Instantiates the given `module`, which can either be bytes or
243
+ * a precompiled `WebAssembly.Module`.
244
+ *
245
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
246
+ *
247
+ * @returns {InitOutput}
248
+ */
249
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
250
+
251
+ /**
252
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
253
+ * for everything else, calls `WebAssembly.instantiate` directly.
254
+ *
255
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
256
+ *
257
+ * @returns {Promise<InitOutput>}
258
+ */
259
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;