phirepass-channel 0.1.89

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/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "phirepass-channel",
3
+ "type": "module",
4
+ "version": "0.1.89",
5
+ "license": "SEE LICENSE IN ../LICENCE",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/dimitrmo/phirepass-rs"
9
+ },
10
+ "files": [
11
+ "phirepass-channel_bg.wasm",
12
+ "phirepass-channel.js",
13
+ "phirepass-channel.d.ts"
14
+ ],
15
+ "main": "phirepass-channel.js",
16
+ "types": "phirepass-channel.d.ts",
17
+ "sideEffects": [
18
+ "./snippets/*"
19
+ ]
20
+ }
@@ -0,0 +1,100 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ export class Channel {
5
+ free(): void;
6
+ [Symbol.dispose](): void;
7
+ connect(): void;
8
+ disconnect(): void;
9
+ is_open(): boolean;
10
+ constructor(endpoint: string);
11
+ on_connection_close(cb?: Function | null): void;
12
+ on_connection_error(cb?: Function | null): void;
13
+ on_connection_message(cb?: Function | null): void;
14
+ on_connection_open(cb?: Function | null): void;
15
+ on_protocol_message(cb?: Function | null): void;
16
+ open_sftp_tunnel(node_id: string, username?: string | null, password?: string | null, msg_id?: number | null): void;
17
+ open_ssh_tunnel(node_id: string, username?: string | null, password?: string | null, msg_id?: number | null): void;
18
+ send_sftp_delete(node_id: string, sid: number, path: string, filename: string, msg_id?: number | null): void;
19
+ send_sftp_download_chunk(node_id: string, sid: number, download_id: number, chunk_index: number, msg_id?: number | null): void;
20
+ send_sftp_download_start(node_id: string, sid: number, path: string, filename: string, msg_id?: number | null): void;
21
+ send_sftp_list_data(node_id: string, sid: number, path: string, msg_id?: number | null): void;
22
+ send_sftp_upload_chunk(node_id: string, sid: number, upload_id: number, chunk_index: number, chunk_size: number, data: Uint8Array, msg_id?: number | null): void;
23
+ send_sftp_upload_start(node_id: string, sid: number, filename: string, remote_path: string, total_chunks: number, total_size: bigint, msg_id?: number | null): void;
24
+ send_ssh_terminal_resize(node_id: string, sid: number, cols: number, rows: number): void;
25
+ send_ssh_tunnel_data(node_id: string, sid: number, data: string): void;
26
+ start_heartbeat(interval_as_millis: number): void;
27
+ stop_heartbeat(): void;
28
+ }
29
+
30
+ export enum ErrorType {
31
+ Generic = 0,
32
+ RequiredUsername = 100,
33
+ RequiresPassword = 110,
34
+ }
35
+
36
+ export enum Protocol {
37
+ SSH = 0,
38
+ SFTP = 1,
39
+ }
40
+
41
+ export function version(): string;
42
+
43
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
44
+
45
+ export interface InitOutput {
46
+ readonly memory: WebAssembly.Memory;
47
+ readonly __wbg_channel_free: (a: number, b: number) => void;
48
+ readonly channel_connect: (a: number) => void;
49
+ readonly channel_disconnect: (a: number) => void;
50
+ readonly channel_is_open: (a: number) => number;
51
+ readonly channel_new: (a: number, b: number) => number;
52
+ readonly channel_on_connection_close: (a: number, b: number) => void;
53
+ readonly channel_on_connection_error: (a: number, b: number) => void;
54
+ readonly channel_on_connection_message: (a: number, b: number) => void;
55
+ readonly channel_on_connection_open: (a: number, b: number) => void;
56
+ readonly channel_on_protocol_message: (a: number, b: number) => void;
57
+ readonly channel_open_sftp_tunnel: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
58
+ readonly channel_open_ssh_tunnel: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
59
+ readonly channel_send_sftp_delete: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
60
+ readonly channel_send_sftp_download_chunk: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
61
+ readonly channel_send_sftp_download_start: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
62
+ readonly channel_send_sftp_list_data: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
63
+ readonly channel_send_sftp_upload_chunk: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => void;
64
+ readonly channel_send_sftp_upload_start: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: bigint, k: number) => void;
65
+ readonly channel_send_ssh_terminal_resize: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
66
+ readonly channel_send_ssh_tunnel_data: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
67
+ readonly channel_start_heartbeat: (a: number, b: number) => void;
68
+ readonly channel_stop_heartbeat: (a: number) => void;
69
+ readonly version: (a: number) => void;
70
+ readonly __wasm_bindgen_func_elem_37: (a: number, b: number) => void;
71
+ readonly __wasm_bindgen_func_elem_38: (a: number, b: number, c: number) => void;
72
+ readonly __wasm_bindgen_func_elem_41: (a: number, b: number) => void;
73
+ readonly __wbindgen_export: (a: number, b: number) => number;
74
+ readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
75
+ readonly __wbindgen_export3: (a: number) => void;
76
+ readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
77
+ readonly __wbindgen_export4: (a: number, b: number, c: number) => void;
78
+ }
79
+
80
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
81
+
82
+ /**
83
+ * Instantiates the given `module`, which can either be bytes or
84
+ * a precompiled `WebAssembly.Module`.
85
+ *
86
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
87
+ *
88
+ * @returns {InitOutput}
89
+ */
90
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
91
+
92
+ /**
93
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
94
+ * for everything else, calls `WebAssembly.instantiate` directly.
95
+ *
96
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
97
+ *
98
+ * @returns {Promise<InitOutput>}
99
+ */
100
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
@@ -0,0 +1,781 @@
1
+ /* @ts-self-types="./phirepass-channel.d.ts" */
2
+
3
+ export class Channel {
4
+ __destroy_into_raw() {
5
+ const ptr = this.__wbg_ptr;
6
+ this.__wbg_ptr = 0;
7
+ ChannelFinalization.unregister(this);
8
+ return ptr;
9
+ }
10
+ free() {
11
+ const ptr = this.__destroy_into_raw();
12
+ wasm.__wbg_channel_free(ptr, 0);
13
+ }
14
+ connect() {
15
+ wasm.channel_connect(this.__wbg_ptr);
16
+ }
17
+ disconnect() {
18
+ wasm.channel_disconnect(this.__wbg_ptr);
19
+ }
20
+ /**
21
+ * @returns {boolean}
22
+ */
23
+ is_open() {
24
+ const ret = wasm.channel_is_open(this.__wbg_ptr);
25
+ return ret !== 0;
26
+ }
27
+ /**
28
+ * @param {string} endpoint
29
+ */
30
+ constructor(endpoint) {
31
+ const ptr0 = passStringToWasm0(endpoint, wasm.__wbindgen_export, wasm.__wbindgen_export2);
32
+ const len0 = WASM_VECTOR_LEN;
33
+ const ret = wasm.channel_new(ptr0, len0);
34
+ this.__wbg_ptr = ret >>> 0;
35
+ ChannelFinalization.register(this, this.__wbg_ptr, this);
36
+ return this;
37
+ }
38
+ /**
39
+ * @param {Function | null} [cb]
40
+ */
41
+ on_connection_close(cb) {
42
+ wasm.channel_on_connection_close(this.__wbg_ptr, isLikeNone(cb) ? 0 : addHeapObject(cb));
43
+ }
44
+ /**
45
+ * @param {Function | null} [cb]
46
+ */
47
+ on_connection_error(cb) {
48
+ wasm.channel_on_connection_error(this.__wbg_ptr, isLikeNone(cb) ? 0 : addHeapObject(cb));
49
+ }
50
+ /**
51
+ * @param {Function | null} [cb]
52
+ */
53
+ on_connection_message(cb) {
54
+ wasm.channel_on_connection_message(this.__wbg_ptr, isLikeNone(cb) ? 0 : addHeapObject(cb));
55
+ }
56
+ /**
57
+ * @param {Function | null} [cb]
58
+ */
59
+ on_connection_open(cb) {
60
+ wasm.channel_on_connection_open(this.__wbg_ptr, isLikeNone(cb) ? 0 : addHeapObject(cb));
61
+ }
62
+ /**
63
+ * @param {Function | null} [cb]
64
+ */
65
+ on_protocol_message(cb) {
66
+ wasm.channel_on_protocol_message(this.__wbg_ptr, isLikeNone(cb) ? 0 : addHeapObject(cb));
67
+ }
68
+ /**
69
+ * @param {string} node_id
70
+ * @param {string | null} [username]
71
+ * @param {string | null} [password]
72
+ * @param {number | null} [msg_id]
73
+ */
74
+ open_sftp_tunnel(node_id, username, password, msg_id) {
75
+ const ptr0 = passStringToWasm0(node_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
76
+ const len0 = WASM_VECTOR_LEN;
77
+ var ptr1 = isLikeNone(username) ? 0 : passStringToWasm0(username, wasm.__wbindgen_export, wasm.__wbindgen_export2);
78
+ var len1 = WASM_VECTOR_LEN;
79
+ var ptr2 = isLikeNone(password) ? 0 : passStringToWasm0(password, wasm.__wbindgen_export, wasm.__wbindgen_export2);
80
+ var len2 = WASM_VECTOR_LEN;
81
+ wasm.channel_open_sftp_tunnel(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2, isLikeNone(msg_id) ? 0x100000001 : (msg_id) >>> 0);
82
+ }
83
+ /**
84
+ * @param {string} node_id
85
+ * @param {string | null} [username]
86
+ * @param {string | null} [password]
87
+ * @param {number | null} [msg_id]
88
+ */
89
+ open_ssh_tunnel(node_id, username, password, msg_id) {
90
+ const ptr0 = passStringToWasm0(node_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
91
+ const len0 = WASM_VECTOR_LEN;
92
+ var ptr1 = isLikeNone(username) ? 0 : passStringToWasm0(username, wasm.__wbindgen_export, wasm.__wbindgen_export2);
93
+ var len1 = WASM_VECTOR_LEN;
94
+ var ptr2 = isLikeNone(password) ? 0 : passStringToWasm0(password, wasm.__wbindgen_export, wasm.__wbindgen_export2);
95
+ var len2 = WASM_VECTOR_LEN;
96
+ wasm.channel_open_ssh_tunnel(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2, isLikeNone(msg_id) ? 0x100000001 : (msg_id) >>> 0);
97
+ }
98
+ /**
99
+ * @param {string} node_id
100
+ * @param {number} sid
101
+ * @param {string} path
102
+ * @param {string} filename
103
+ * @param {number | null} [msg_id]
104
+ */
105
+ send_sftp_delete(node_id, sid, path, filename, msg_id) {
106
+ const ptr0 = passStringToWasm0(node_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
107
+ const len0 = WASM_VECTOR_LEN;
108
+ const ptr1 = passStringToWasm0(path, wasm.__wbindgen_export, wasm.__wbindgen_export2);
109
+ const len1 = WASM_VECTOR_LEN;
110
+ const ptr2 = passStringToWasm0(filename, wasm.__wbindgen_export, wasm.__wbindgen_export2);
111
+ const len2 = WASM_VECTOR_LEN;
112
+ wasm.channel_send_sftp_delete(this.__wbg_ptr, ptr0, len0, sid, ptr1, len1, ptr2, len2, isLikeNone(msg_id) ? 0x100000001 : (msg_id) >>> 0);
113
+ }
114
+ /**
115
+ * @param {string} node_id
116
+ * @param {number} sid
117
+ * @param {number} download_id
118
+ * @param {number} chunk_index
119
+ * @param {number | null} [msg_id]
120
+ */
121
+ send_sftp_download_chunk(node_id, sid, download_id, chunk_index, msg_id) {
122
+ const ptr0 = passStringToWasm0(node_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
123
+ const len0 = WASM_VECTOR_LEN;
124
+ wasm.channel_send_sftp_download_chunk(this.__wbg_ptr, ptr0, len0, sid, download_id, chunk_index, isLikeNone(msg_id) ? 0x100000001 : (msg_id) >>> 0);
125
+ }
126
+ /**
127
+ * @param {string} node_id
128
+ * @param {number} sid
129
+ * @param {string} path
130
+ * @param {string} filename
131
+ * @param {number | null} [msg_id]
132
+ */
133
+ send_sftp_download_start(node_id, sid, path, filename, msg_id) {
134
+ const ptr0 = passStringToWasm0(node_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
135
+ const len0 = WASM_VECTOR_LEN;
136
+ const ptr1 = passStringToWasm0(path, wasm.__wbindgen_export, wasm.__wbindgen_export2);
137
+ const len1 = WASM_VECTOR_LEN;
138
+ const ptr2 = passStringToWasm0(filename, wasm.__wbindgen_export, wasm.__wbindgen_export2);
139
+ const len2 = WASM_VECTOR_LEN;
140
+ wasm.channel_send_sftp_download_start(this.__wbg_ptr, ptr0, len0, sid, ptr1, len1, ptr2, len2, isLikeNone(msg_id) ? 0x100000001 : (msg_id) >>> 0);
141
+ }
142
+ /**
143
+ * @param {string} node_id
144
+ * @param {number} sid
145
+ * @param {string} path
146
+ * @param {number | null} [msg_id]
147
+ */
148
+ send_sftp_list_data(node_id, sid, path, msg_id) {
149
+ const ptr0 = passStringToWasm0(node_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
150
+ const len0 = WASM_VECTOR_LEN;
151
+ const ptr1 = passStringToWasm0(path, wasm.__wbindgen_export, wasm.__wbindgen_export2);
152
+ const len1 = WASM_VECTOR_LEN;
153
+ wasm.channel_send_sftp_list_data(this.__wbg_ptr, ptr0, len0, sid, ptr1, len1, isLikeNone(msg_id) ? 0x100000001 : (msg_id) >>> 0);
154
+ }
155
+ /**
156
+ * @param {string} node_id
157
+ * @param {number} sid
158
+ * @param {number} upload_id
159
+ * @param {number} chunk_index
160
+ * @param {number} chunk_size
161
+ * @param {Uint8Array} data
162
+ * @param {number | null} [msg_id]
163
+ */
164
+ send_sftp_upload_chunk(node_id, sid, upload_id, chunk_index, chunk_size, data, msg_id) {
165
+ const ptr0 = passStringToWasm0(node_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
166
+ const len0 = WASM_VECTOR_LEN;
167
+ const ptr1 = passArray8ToWasm0(data, wasm.__wbindgen_export);
168
+ const len1 = WASM_VECTOR_LEN;
169
+ wasm.channel_send_sftp_upload_chunk(this.__wbg_ptr, ptr0, len0, sid, upload_id, chunk_index, chunk_size, ptr1, len1, isLikeNone(msg_id) ? 0x100000001 : (msg_id) >>> 0);
170
+ }
171
+ /**
172
+ * @param {string} node_id
173
+ * @param {number} sid
174
+ * @param {string} filename
175
+ * @param {string} remote_path
176
+ * @param {number} total_chunks
177
+ * @param {bigint} total_size
178
+ * @param {number | null} [msg_id]
179
+ */
180
+ send_sftp_upload_start(node_id, sid, filename, remote_path, total_chunks, total_size, msg_id) {
181
+ const ptr0 = passStringToWasm0(node_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
182
+ const len0 = WASM_VECTOR_LEN;
183
+ const ptr1 = passStringToWasm0(filename, wasm.__wbindgen_export, wasm.__wbindgen_export2);
184
+ const len1 = WASM_VECTOR_LEN;
185
+ const ptr2 = passStringToWasm0(remote_path, wasm.__wbindgen_export, wasm.__wbindgen_export2);
186
+ const len2 = WASM_VECTOR_LEN;
187
+ wasm.channel_send_sftp_upload_start(this.__wbg_ptr, ptr0, len0, sid, ptr1, len1, ptr2, len2, total_chunks, total_size, isLikeNone(msg_id) ? 0x100000001 : (msg_id) >>> 0);
188
+ }
189
+ /**
190
+ * @param {string} node_id
191
+ * @param {number} sid
192
+ * @param {number} cols
193
+ * @param {number} rows
194
+ */
195
+ send_ssh_terminal_resize(node_id, sid, cols, rows) {
196
+ const ptr0 = passStringToWasm0(node_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
197
+ const len0 = WASM_VECTOR_LEN;
198
+ wasm.channel_send_ssh_terminal_resize(this.__wbg_ptr, ptr0, len0, sid, cols, rows);
199
+ }
200
+ /**
201
+ * @param {string} node_id
202
+ * @param {number} sid
203
+ * @param {string} data
204
+ */
205
+ send_ssh_tunnel_data(node_id, sid, data) {
206
+ const ptr0 = passStringToWasm0(node_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
207
+ const len0 = WASM_VECTOR_LEN;
208
+ const ptr1 = passStringToWasm0(data, wasm.__wbindgen_export, wasm.__wbindgen_export2);
209
+ const len1 = WASM_VECTOR_LEN;
210
+ wasm.channel_send_ssh_tunnel_data(this.__wbg_ptr, ptr0, len0, sid, ptr1, len1);
211
+ }
212
+ /**
213
+ * @param {number} interval_as_millis
214
+ */
215
+ start_heartbeat(interval_as_millis) {
216
+ wasm.channel_start_heartbeat(this.__wbg_ptr, interval_as_millis);
217
+ }
218
+ stop_heartbeat() {
219
+ wasm.channel_stop_heartbeat(this.__wbg_ptr);
220
+ }
221
+ }
222
+ if (Symbol.dispose) Channel.prototype[Symbol.dispose] = Channel.prototype.free;
223
+
224
+ /**
225
+ * @enum {0 | 100 | 110}
226
+ */
227
+ export const ErrorType = Object.freeze({
228
+ Generic: 0, "0": "Generic",
229
+ RequiredUsername: 100, "100": "RequiredUsername",
230
+ RequiresPassword: 110, "110": "RequiresPassword",
231
+ });
232
+
233
+ /**
234
+ * @enum {0 | 1}
235
+ */
236
+ export const Protocol = Object.freeze({
237
+ SSH: 0, "0": "SSH",
238
+ SFTP: 1, "1": "SFTP",
239
+ });
240
+
241
+ /**
242
+ * @returns {string}
243
+ */
244
+ export function version() {
245
+ let deferred1_0;
246
+ let deferred1_1;
247
+ try {
248
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
249
+ wasm.version(retptr);
250
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
251
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
252
+ deferred1_0 = r0;
253
+ deferred1_1 = r1;
254
+ return getStringFromWasm0(r0, r1);
255
+ } finally {
256
+ wasm.__wbindgen_add_to_stack_pointer(16);
257
+ wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
258
+ }
259
+ }
260
+
261
+ function __wbg_get_imports() {
262
+ const import0 = {
263
+ __proto__: null,
264
+ __wbg_Error_8c4e43fe74559d73: function(arg0, arg1) {
265
+ const ret = Error(getStringFromWasm0(arg0, arg1));
266
+ return addHeapObject(ret);
267
+ },
268
+ __wbg_String_8f0eb39a4a4c2f66: function(arg0, arg1) {
269
+ const ret = String(getObject(arg1));
270
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
271
+ const len1 = WASM_VECTOR_LEN;
272
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
273
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
274
+ },
275
+ __wbg___wbindgen_debug_string_0bc8482c6e3508ae: function(arg0, arg1) {
276
+ const ret = debugString(getObject(arg1));
277
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
278
+ const len1 = WASM_VECTOR_LEN;
279
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
280
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
281
+ },
282
+ __wbg___wbindgen_string_get_72fb696202c56729: function(arg0, arg1) {
283
+ const obj = getObject(arg1);
284
+ const ret = typeof(obj) === 'string' ? obj : undefined;
285
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
286
+ var len1 = WASM_VECTOR_LEN;
287
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
288
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
289
+ },
290
+ __wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
291
+ throw new Error(getStringFromWasm0(arg0, arg1));
292
+ },
293
+ __wbg__wbg_cb_unref_d9b87ff7982e3b21: function(arg0) {
294
+ getObject(arg0)._wbg_cb_unref();
295
+ },
296
+ __wbg_call_389efe28435a9388: function() { return handleError(function (arg0, arg1) {
297
+ const ret = getObject(arg0).call(getObject(arg1));
298
+ return addHeapObject(ret);
299
+ }, arguments); },
300
+ __wbg_call_4708e0c13bdc8e95: function() { return handleError(function (arg0, arg1, arg2) {
301
+ const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
302
+ return addHeapObject(ret);
303
+ }, arguments); },
304
+ __wbg_clearInterval_dd1e598f425db353: function(arg0) {
305
+ const ret = clearInterval(takeObject(arg0));
306
+ return addHeapObject(ret);
307
+ },
308
+ __wbg_close_1d08eaf57ed325c0: function() { return handleError(function (arg0) {
309
+ getObject(arg0).close();
310
+ }, arguments); },
311
+ __wbg_data_5330da50312d0bc1: function(arg0) {
312
+ const ret = getObject(arg0).data;
313
+ return addHeapObject(ret);
314
+ },
315
+ __wbg_from_bddd64e7d5ff6941: function(arg0) {
316
+ const ret = Array.from(getObject(arg0));
317
+ return addHeapObject(ret);
318
+ },
319
+ __wbg_instanceof_ArrayBuffer_c367199e2fa2aa04: function(arg0) {
320
+ let result;
321
+ try {
322
+ result = getObject(arg0) instanceof ArrayBuffer;
323
+ } catch (_) {
324
+ result = false;
325
+ }
326
+ const ret = result;
327
+ return ret;
328
+ },
329
+ __wbg_length_32ed9a279acd054c: function(arg0) {
330
+ const ret = getObject(arg0).length;
331
+ return ret;
332
+ },
333
+ __wbg_new_057993d5b5e07835: function() { return handleError(function (arg0, arg1) {
334
+ const ret = new WebSocket(getStringFromWasm0(arg0, arg1));
335
+ return addHeapObject(ret);
336
+ }, arguments); },
337
+ __wbg_new_361308b2356cecd0: function() {
338
+ const ret = new Object();
339
+ return addHeapObject(ret);
340
+ },
341
+ __wbg_new_3eb36ae241fe6f44: function() {
342
+ const ret = new Array();
343
+ return addHeapObject(ret);
344
+ },
345
+ __wbg_new_dd2b680c8bf6ae29: function(arg0) {
346
+ const ret = new Uint8Array(getObject(arg0));
347
+ return addHeapObject(ret);
348
+ },
349
+ __wbg_prototypesetcall_bdcdcc5842e4d77d: function(arg0, arg1, arg2) {
350
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
351
+ },
352
+ __wbg_readyState_1bb73ec7b8a54656: function(arg0) {
353
+ const ret = getObject(arg0).readyState;
354
+ return ret;
355
+ },
356
+ __wbg_send_542f95dea2df7994: function() { return handleError(function (arg0, arg1, arg2) {
357
+ getObject(arg0).send(getArrayU8FromWasm0(arg1, arg2));
358
+ }, arguments); },
359
+ __wbg_setInterval_ed3b5e3c3ebb8a6d: function() { return handleError(function (arg0, arg1) {
360
+ const ret = setInterval(getObject(arg0), arg1);
361
+ return addHeapObject(ret);
362
+ }, arguments); },
363
+ __wbg_set_3f1d0b984ed272ed: function(arg0, arg1, arg2) {
364
+ getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
365
+ },
366
+ __wbg_set_binaryType_5bbf62e9f705dc1a: function(arg0, arg1) {
367
+ getObject(arg0).binaryType = __wbindgen_enum_BinaryType[arg1];
368
+ },
369
+ __wbg_set_f43e577aea94465b: function(arg0, arg1, arg2) {
370
+ getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
371
+ },
372
+ __wbg_set_onclose_d382f3e2c2b850eb: function(arg0, arg1) {
373
+ getObject(arg0).onclose = getObject(arg1);
374
+ },
375
+ __wbg_set_onerror_377f18bf4569bf85: function(arg0, arg1) {
376
+ getObject(arg0).onerror = getObject(arg1);
377
+ },
378
+ __wbg_set_onmessage_2114aa5f4f53051e: function(arg0, arg1) {
379
+ getObject(arg0).onmessage = getObject(arg1);
380
+ },
381
+ __wbg_set_onopen_b7b52d519d6c0f11: function(arg0, arg1) {
382
+ getObject(arg0).onopen = getObject(arg1);
383
+ },
384
+ __wbg_warn_cb75581ea3b29671: function(arg0, arg1) {
385
+ console.warn(getStringFromWasm0(arg0, arg1));
386
+ },
387
+ __wbindgen_cast_0000000000000001: function(arg0, arg1) {
388
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 1, function: Function { arguments: [NamedExternref("CloseEvent")], shim_idx: 2, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
389
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_37, __wasm_bindgen_func_elem_38);
390
+ return addHeapObject(ret);
391
+ },
392
+ __wbindgen_cast_0000000000000002: function(arg0, arg1) {
393
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 1, function: Function { arguments: [NamedExternref("ErrorEvent")], shim_idx: 2, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
394
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_37, __wasm_bindgen_func_elem_38);
395
+ return addHeapObject(ret);
396
+ },
397
+ __wbindgen_cast_0000000000000003: function(arg0, arg1) {
398
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 1, function: Function { arguments: [NamedExternref("MessageEvent")], shim_idx: 2, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
399
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_37, __wasm_bindgen_func_elem_38);
400
+ return addHeapObject(ret);
401
+ },
402
+ __wbindgen_cast_0000000000000004: function(arg0, arg1) {
403
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 1, function: Function { arguments: [], shim_idx: 5, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
404
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_37, __wasm_bindgen_func_elem_41);
405
+ return addHeapObject(ret);
406
+ },
407
+ __wbindgen_cast_0000000000000005: function(arg0) {
408
+ // Cast intrinsic for `F64 -> Externref`.
409
+ const ret = arg0;
410
+ return addHeapObject(ret);
411
+ },
412
+ __wbindgen_cast_0000000000000006: function(arg0, arg1) {
413
+ // Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
414
+ const ret = getArrayU8FromWasm0(arg0, arg1);
415
+ return addHeapObject(ret);
416
+ },
417
+ __wbindgen_cast_0000000000000007: function(arg0, arg1) {
418
+ // Cast intrinsic for `Ref(String) -> Externref`.
419
+ const ret = getStringFromWasm0(arg0, arg1);
420
+ return addHeapObject(ret);
421
+ },
422
+ __wbindgen_cast_0000000000000008: function(arg0) {
423
+ // Cast intrinsic for `U64 -> Externref`.
424
+ const ret = BigInt.asUintN(64, arg0);
425
+ return addHeapObject(ret);
426
+ },
427
+ __wbindgen_object_clone_ref: function(arg0) {
428
+ const ret = getObject(arg0);
429
+ return addHeapObject(ret);
430
+ },
431
+ __wbindgen_object_drop_ref: function(arg0) {
432
+ takeObject(arg0);
433
+ },
434
+ };
435
+ return {
436
+ __proto__: null,
437
+ "./phirepass-channel_bg.js": import0,
438
+ };
439
+ }
440
+
441
+ function __wasm_bindgen_func_elem_41(arg0, arg1) {
442
+ wasm.__wasm_bindgen_func_elem_41(arg0, arg1);
443
+ }
444
+
445
+ function __wasm_bindgen_func_elem_38(arg0, arg1, arg2) {
446
+ wasm.__wasm_bindgen_func_elem_38(arg0, arg1, addHeapObject(arg2));
447
+ }
448
+
449
+
450
+ const __wbindgen_enum_BinaryType = ["blob", "arraybuffer"];
451
+ const ChannelFinalization = (typeof FinalizationRegistry === 'undefined')
452
+ ? { register: () => {}, unregister: () => {} }
453
+ : new FinalizationRegistry(ptr => wasm.__wbg_channel_free(ptr >>> 0, 1));
454
+
455
+ function addHeapObject(obj) {
456
+ if (heap_next === heap.length) heap.push(heap.length + 1);
457
+ const idx = heap_next;
458
+ heap_next = heap[idx];
459
+
460
+ heap[idx] = obj;
461
+ return idx;
462
+ }
463
+
464
+ const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
465
+ ? { register: () => {}, unregister: () => {} }
466
+ : new FinalizationRegistry(state => state.dtor(state.a, state.b));
467
+
468
+ function debugString(val) {
469
+ // primitive types
470
+ const type = typeof val;
471
+ if (type == 'number' || type == 'boolean' || val == null) {
472
+ return `${val}`;
473
+ }
474
+ if (type == 'string') {
475
+ return `"${val}"`;
476
+ }
477
+ if (type == 'symbol') {
478
+ const description = val.description;
479
+ if (description == null) {
480
+ return 'Symbol';
481
+ } else {
482
+ return `Symbol(${description})`;
483
+ }
484
+ }
485
+ if (type == 'function') {
486
+ const name = val.name;
487
+ if (typeof name == 'string' && name.length > 0) {
488
+ return `Function(${name})`;
489
+ } else {
490
+ return 'Function';
491
+ }
492
+ }
493
+ // objects
494
+ if (Array.isArray(val)) {
495
+ const length = val.length;
496
+ let debug = '[';
497
+ if (length > 0) {
498
+ debug += debugString(val[0]);
499
+ }
500
+ for(let i = 1; i < length; i++) {
501
+ debug += ', ' + debugString(val[i]);
502
+ }
503
+ debug += ']';
504
+ return debug;
505
+ }
506
+ // Test for built-in
507
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
508
+ let className;
509
+ if (builtInMatches && builtInMatches.length > 1) {
510
+ className = builtInMatches[1];
511
+ } else {
512
+ // Failed to match the standard '[object ClassName]'
513
+ return toString.call(val);
514
+ }
515
+ if (className == 'Object') {
516
+ // we're a user defined class or Object
517
+ // JSON.stringify avoids problems with cycles, and is generally much
518
+ // easier than looping through ownProperties of `val`.
519
+ try {
520
+ return 'Object(' + JSON.stringify(val) + ')';
521
+ } catch (_) {
522
+ return 'Object';
523
+ }
524
+ }
525
+ // errors
526
+ if (val instanceof Error) {
527
+ return `${val.name}: ${val.message}\n${val.stack}`;
528
+ }
529
+ // TODO we could test for more things here, like `Set`s and `Map`s.
530
+ return className;
531
+ }
532
+
533
+ function dropObject(idx) {
534
+ if (idx < 132) return;
535
+ heap[idx] = heap_next;
536
+ heap_next = idx;
537
+ }
538
+
539
+ function getArrayU8FromWasm0(ptr, len) {
540
+ ptr = ptr >>> 0;
541
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
542
+ }
543
+
544
+ let cachedDataViewMemory0 = null;
545
+ function getDataViewMemory0() {
546
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
547
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
548
+ }
549
+ return cachedDataViewMemory0;
550
+ }
551
+
552
+ function getStringFromWasm0(ptr, len) {
553
+ ptr = ptr >>> 0;
554
+ return decodeText(ptr, len);
555
+ }
556
+
557
+ let cachedUint8ArrayMemory0 = null;
558
+ function getUint8ArrayMemory0() {
559
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
560
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
561
+ }
562
+ return cachedUint8ArrayMemory0;
563
+ }
564
+
565
+ function getObject(idx) { return heap[idx]; }
566
+
567
+ function handleError(f, args) {
568
+ try {
569
+ return f.apply(this, args);
570
+ } catch (e) {
571
+ wasm.__wbindgen_export3(addHeapObject(e));
572
+ }
573
+ }
574
+
575
+ let heap = new Array(128).fill(undefined);
576
+ heap.push(undefined, null, true, false);
577
+
578
+ let heap_next = heap.length;
579
+
580
+ function isLikeNone(x) {
581
+ return x === undefined || x === null;
582
+ }
583
+
584
+ function makeMutClosure(arg0, arg1, dtor, f) {
585
+ const state = { a: arg0, b: arg1, cnt: 1, dtor };
586
+ const real = (...args) => {
587
+
588
+ // First up with a closure we increment the internal reference
589
+ // count. This ensures that the Rust closure environment won't
590
+ // be deallocated while we're invoking it.
591
+ state.cnt++;
592
+ const a = state.a;
593
+ state.a = 0;
594
+ try {
595
+ return f(a, state.b, ...args);
596
+ } finally {
597
+ state.a = a;
598
+ real._wbg_cb_unref();
599
+ }
600
+ };
601
+ real._wbg_cb_unref = () => {
602
+ if (--state.cnt === 0) {
603
+ state.dtor(state.a, state.b);
604
+ state.a = 0;
605
+ CLOSURE_DTORS.unregister(state);
606
+ }
607
+ };
608
+ CLOSURE_DTORS.register(real, state, state);
609
+ return real;
610
+ }
611
+
612
+ function passArray8ToWasm0(arg, malloc) {
613
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
614
+ getUint8ArrayMemory0().set(arg, ptr / 1);
615
+ WASM_VECTOR_LEN = arg.length;
616
+ return ptr;
617
+ }
618
+
619
+ function passStringToWasm0(arg, malloc, realloc) {
620
+ if (realloc === undefined) {
621
+ const buf = cachedTextEncoder.encode(arg);
622
+ const ptr = malloc(buf.length, 1) >>> 0;
623
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
624
+ WASM_VECTOR_LEN = buf.length;
625
+ return ptr;
626
+ }
627
+
628
+ let len = arg.length;
629
+ let ptr = malloc(len, 1) >>> 0;
630
+
631
+ const mem = getUint8ArrayMemory0();
632
+
633
+ let offset = 0;
634
+
635
+ for (; offset < len; offset++) {
636
+ const code = arg.charCodeAt(offset);
637
+ if (code > 0x7F) break;
638
+ mem[ptr + offset] = code;
639
+ }
640
+ if (offset !== len) {
641
+ if (offset !== 0) {
642
+ arg = arg.slice(offset);
643
+ }
644
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
645
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
646
+ const ret = cachedTextEncoder.encodeInto(arg, view);
647
+
648
+ offset += ret.written;
649
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
650
+ }
651
+
652
+ WASM_VECTOR_LEN = offset;
653
+ return ptr;
654
+ }
655
+
656
+ function takeObject(idx) {
657
+ const ret = getObject(idx);
658
+ dropObject(idx);
659
+ return ret;
660
+ }
661
+
662
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
663
+ cachedTextDecoder.decode();
664
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
665
+ let numBytesDecoded = 0;
666
+ function decodeText(ptr, len) {
667
+ numBytesDecoded += len;
668
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
669
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
670
+ cachedTextDecoder.decode();
671
+ numBytesDecoded = len;
672
+ }
673
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
674
+ }
675
+
676
+ const cachedTextEncoder = new TextEncoder();
677
+
678
+ if (!('encodeInto' in cachedTextEncoder)) {
679
+ cachedTextEncoder.encodeInto = function (arg, view) {
680
+ const buf = cachedTextEncoder.encode(arg);
681
+ view.set(buf);
682
+ return {
683
+ read: arg.length,
684
+ written: buf.length
685
+ };
686
+ };
687
+ }
688
+
689
+ let WASM_VECTOR_LEN = 0;
690
+
691
+ let wasmModule, wasm;
692
+ function __wbg_finalize_init(instance, module) {
693
+ wasm = instance.exports;
694
+ wasmModule = module;
695
+ cachedDataViewMemory0 = null;
696
+ cachedUint8ArrayMemory0 = null;
697
+ return wasm;
698
+ }
699
+
700
+ async function __wbg_load(module, imports) {
701
+ if (typeof Response === 'function' && module instanceof Response) {
702
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
703
+ try {
704
+ return await WebAssembly.instantiateStreaming(module, imports);
705
+ } catch (e) {
706
+ const validResponse = module.ok && expectedResponseType(module.type);
707
+
708
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
709
+ console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
710
+
711
+ } else { throw e; }
712
+ }
713
+ }
714
+
715
+ const bytes = await module.arrayBuffer();
716
+ return await WebAssembly.instantiate(bytes, imports);
717
+ } else {
718
+ const instance = await WebAssembly.instantiate(module, imports);
719
+
720
+ if (instance instanceof WebAssembly.Instance) {
721
+ return { instance, module };
722
+ } else {
723
+ return instance;
724
+ }
725
+ }
726
+
727
+ function expectedResponseType(type) {
728
+ switch (type) {
729
+ case 'basic': case 'cors': case 'default': return true;
730
+ }
731
+ return false;
732
+ }
733
+ }
734
+
735
+ function initSync(module) {
736
+ if (wasm !== undefined) return wasm;
737
+
738
+
739
+ if (module !== undefined) {
740
+ if (Object.getPrototypeOf(module) === Object.prototype) {
741
+ ({module} = module)
742
+ } else {
743
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
744
+ }
745
+ }
746
+
747
+ const imports = __wbg_get_imports();
748
+ if (!(module instanceof WebAssembly.Module)) {
749
+ module = new WebAssembly.Module(module);
750
+ }
751
+ const instance = new WebAssembly.Instance(module, imports);
752
+ return __wbg_finalize_init(instance, module);
753
+ }
754
+
755
+ async function __wbg_init(module_or_path) {
756
+ if (wasm !== undefined) return wasm;
757
+
758
+
759
+ if (module_or_path !== undefined) {
760
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
761
+ ({module_or_path} = module_or_path)
762
+ } else {
763
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
764
+ }
765
+ }
766
+
767
+ if (module_or_path === undefined) {
768
+ module_or_path = new URL('phirepass-channel_bg.wasm', import.meta.url);
769
+ }
770
+ const imports = __wbg_get_imports();
771
+
772
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
773
+ module_or_path = fetch(module_or_path);
774
+ }
775
+
776
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
777
+
778
+ return __wbg_finalize_init(instance, module);
779
+ }
780
+
781
+ export { initSync, __wbg_init as default };
Binary file