diff --git a/.gitignore b/.gitignore index f74d910..fae72c5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,18 +1,3 @@ **target/ *.pem *.key -example-usage/dev-cert/ - -# The root Cargo.lock and the example-usage workspace lockfile are committed: -# the workspace ships binaries (example-usage/*) and a committed lockfile keeps -# their builds reproducible. Workspace members do not own a lockfile (the root -# one governs them); ignore any stray per-member lockfiles so they are not -# committed by accident. -/client/Cargo.lock -/codec/Cargo.lock -/common/Cargo.lock -/crypto/Cargo.lock -/host/Cargo.lock -/transport/Cargo.lock -/type-map/Cargo.lock -/wasm/Cargo.lock diff --git a/client/Cargo.lock b/client/Cargo.lock new file mode 100644 index 0000000..72dff85 --- /dev/null +++ b/client/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "client" +version = "0.1.0" diff --git a/codec/Cargo.lock b/codec/Cargo.lock new file mode 100644 index 0000000..e987889 --- /dev/null +++ b/codec/Cargo.lock @@ -0,0 +1,91 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "cfg-if" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" + +[[package]] +name = "chacha20" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f8d983286843e49675a4b7a2d174efe136dc93a18d69130dd18198a6c167601" +dependencies = [ + "cfg-if", + "cpufeatures", + "rand_core", +] + +[[package]] +name = "cpufeatures" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b2a41393f66f16b0823bb79094d54ac5fbd34ab292ddafb9a0456ac9f87d201" +dependencies = [ + "libc", +] + +[[package]] +name = "getrandom" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099" +dependencies = [ + "cfg-if", + "libc", + "r-efi", + "rand_core", +] + +[[package]] +name = "libc" +version = "0.2.186" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66" + +[[package]] +name = "mtp-codec" +version = "0.1.0" +dependencies = [ + "base64", + "byteorder", + "rand", +] + +[[package]] +name = "r-efi" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" + +[[package]] +name = "rand" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2e8e8bcc7961af1fdac401278c6a831614941f6164ee3bf4ce61b7edb162207" +dependencies = [ + "chacha20", + "getrandom", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69" diff --git a/common/Cargo.lock b/common/Cargo.lock new file mode 100644 index 0000000..cf2d91b --- /dev/null +++ b/common/Cargo.lock @@ -0,0 +1,16 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "common" +version = "0.1.0" +quinn = { version = "0.11.9", default-features = false, features = [ + "rustls-aws-lc-rs", + "rustls", +] } +wtransport = { version = "0.7.1", default-features = false, features = [ + "aws-lc-rs", + "quinn", + "self-signed", +] } diff --git a/crypto/Cargo.lock b/crypto/Cargo.lock new file mode 100644 index 0000000..c708c11 --- /dev/null +++ b/crypto/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "crypto" +version = "0.1.0" diff --git a/host/Cargo.lock b/host/Cargo.lock new file mode 100644 index 0000000..aa19d17 --- /dev/null +++ b/host/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "host" +version = "0.1.0" diff --git a/transport/Cargo.lock b/transport/Cargo.lock new file mode 100644 index 0000000..fb10a6a --- /dev/null +++ b/transport/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "transport" +version = "0.1.0" diff --git a/type-map/Cargo.lock b/type-map/Cargo.lock new file mode 100644 index 0000000..c301538 --- /dev/null +++ b/type-map/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "type-map" +version = "0.1.0" diff --git a/wasm/pkg/mtp_wasm.d.ts b/wasm/pkg/mtp_wasm.d.ts new file mode 100644 index 0000000..4e3f9d0 --- /dev/null +++ b/wasm/pkg/mtp_wasm.d.ts @@ -0,0 +1,282 @@ +/* tslint:disable */ +/* eslint-disable */ + +export class ConnectionConfig { + free(): void; + [Symbol.dispose](): void; + constructor(url: string); + client_id: bigint; + set server_certificate_hashes(value: string[]); + readonly url: string; +} + +export enum ConnectionState { + Disconnected = 0, + Connecting = 1, + Connected = 2, + Failed = 3, +} + +export class WasmChaCha20Poly1305 { + free(): void; + [Symbol.dispose](): void; + /** + * Decrypt `nonce || ciphertext` with `aad`. + */ + decrypt(ciphertext: Uint8Array, aad: Uint8Array): Uint8Array; + /** + * Encrypt `plaintext` with `aad`. + * Returns `nonce || ciphertext`. + */ + encrypt(plaintext: Uint8Array, aad: Uint8Array): Uint8Array; + /** + * Create a new cipher with a 32-byte key. + */ + constructor(key: Uint8Array); +} + +export class WasmClient { + free(): void; + [Symbol.dispose](): void; + /** + * Authenticated login with an existing client ID. + * Exchanges Identification + signatures and verifies the host response. + * + * - `host_public_key_bytes`: serialized PublicKeyBundle from the server + * - `keyring_bytes`: serialized Keyring of this client (must match `client_id`) + * - `client_id`: previously assigned client ID + * + * Returns the confirmed (same) client ID on success. + */ + auth_connect(config: ConnectionConfig, host_public_key_bytes: Uint8Array, keyring_bytes: Uint8Array, client_id: bigint): Promise; + /** + * Authenticated registration with a fresh keyring. + * The server assigns a new client ID. + * + * - `host_public_key_bytes`: serialized PublicKeyBundle from the server + * - `keyring_bytes`: serialized Keyring (must include ed25519 secret key) + * + * Returns the newly assigned client ID. + */ + auth_register(config: ConnectionConfig, host_public_key_bytes: Uint8Array, keyring_bytes: Uint8Array): Promise; + /** + * Unauthenticated connect (sends basic Identification, enables receive loop). + */ + connect(config: ConnectionConfig): Promise; + disconnect(): void; + static is_supported(): boolean; + constructor(on_state_change: Function, on_message: Function, on_error: Function); + send(frame: Uint8Array): Promise; + readonly state: number; +} + +export class WasmEd25519Signer { + free(): void; + [Symbol.dispose](): void; + /** + * Load a signer from its 32-byte secret key. + */ + constructor(secret_key: Uint8Array); + /** + * Sign `message` and return the signature bytes. + */ + sign(message: Uint8Array): Uint8Array; + /** + * Verify `signature` against `message`. + */ + verify(message: Uint8Array, signature: Uint8Array): void; +} + +export class WasmKeyring { + private constructor(); + free(): void; + [Symbol.dispose](): void; + /** + * Deserialise a keyring from bytes. + */ + static from_bytes(bytes: Uint8Array): WasmKeyring; + /** + * Return the public half of this keyring as a bundle. + */ + public_key_bundle(): WasmPublicKeyBundle; + /** + * Serialise the keyring to bytes. + */ + to_bytes(): Uint8Array; +} + +export class WasmPublicKeyBundle { + private constructor(); + free(): void; + [Symbol.dispose](): void; + static from_bytes(bytes: Uint8Array): WasmPublicKeyBundle; + to_bytes(): Uint8Array; + readonly kem_public_key: Uint8Array; + readonly sig_cl_public_key: Uint8Array; + readonly sig_pq_public_key: Uint8Array; +} + +/** + * Build a demo Ping frame with encrypted and signed containers + * (mirrors the Rust client example but uses only reserved data types). + */ +export function build_demo_message(client_id: bigint, keyring_bytes: Uint8Array, host_bundle_bytes: Uint8Array): Uint8Array; + +/** + * Build a simple Ping frame with description, timestamp, and optional data. + */ +export function build_ping_frame(client_id: bigint, description: string, timestamp: bigint, data: Uint8Array): Uint8Array; + +/** + * Build a request frame with the given communication type name, request ID, and JSON data. + * + * - `comm_type`: communication type name (e.g. "get_model", "rank_models") or PascalCase + * - `id`: request ID for response correlation + * - `json_data`: JSON-stringified request payload + */ +export function build_request_frame(comm_type: string, id: number, json_data: string): Uint8Array; + +/** + * Generate a fresh Ed25519 keypair. + * + * Returns `{ signer: WasmEd25519Signer, secretKey: Uint8Array, publicKey: Uint8Array }`. + */ +export function ed25519_generate(): any; + +/** + * Standalone Ed25519 signature verification. + */ +export function ed25519_verify(public_key: Uint8Array, message: Uint8Array, signature: Uint8Array): void; + +/** + * Parse any MTP frame into the human-readable CommunicationValue display form. + */ +export function format_frame(frame: Uint8Array): string; + +/** + * Build a [`Keyring`] containing only an Ed25519 keypair (no KEM, no ML-DSA). + * + * Takes the Ed25519 secret key and public key, each 32 bytes. + * Returns the serialised keyring bytes, suitable for passing to `WasmClient.auth_register`. + */ +export function keyring_from_ed25519(secret_key: Uint8Array, public_key: Uint8Array): Uint8Array; + +export function main(): void; + +/** + * Parse an auth response frame into a JS object. + */ +export function parse_auth_response(response: Uint8Array): any; + +/** + * Parse a response frame into a JSON string containing `_id`, `_type`, and data fields. + */ +export function parse_response_frame(frame: Uint8Array): string; + +/** + * Derive a 32-byte encryption key from `ikm` with `salt` and `context`. + */ +export function wasm_derive_encryption_key(ikm: Uint8Array, salt: Uint8Array, context: Uint8Array): Uint8Array; + +/** + * HKDF-expand: derive `len` bytes from `ikm` with `salt` and `info`. + */ +export function wasm_hkdf_expand(ikm: Uint8Array, salt: Uint8Array, info: Uint8Array, len: number): Uint8Array; + +/** + * SHA-256 digest. + */ +export function wasm_sha256(data: Uint8Array): Uint8Array; + +/** + * Double SHA-256 (SHA-256 applied twice). + */ +export function wasm_sha256_double(data: Uint8Array): Uint8Array; + +export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module; + +export interface InitOutput { + readonly memory: WebAssembly.Memory; + readonly __wbg_wasmchacha20poly1305_free: (a: number, b: number) => void; + readonly __wbg_wasmed25519signer_free: (a: number, b: number) => void; + readonly __wbg_wasmkeyring_free: (a: number, b: number) => void; + readonly __wbg_wasmpublickeybundle_free: (a: number, b: number) => void; + readonly ed25519_generate: () => [number, number, number]; + readonly ed25519_verify: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number]; + readonly keyring_from_ed25519: (a: number, b: number, c: number, d: number) => [number, number, number, number]; + readonly wasm_derive_encryption_key: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number]; + readonly wasm_hkdf_expand: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number, number, number]; + readonly wasm_sha256: (a: number, b: number) => [number, number]; + readonly wasm_sha256_double: (a: number, b: number) => [number, number]; + readonly wasmchacha20poly1305_decrypt: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number]; + readonly wasmchacha20poly1305_encrypt: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number]; + readonly wasmchacha20poly1305_new: (a: number, b: number) => [number, number, number]; + readonly wasmed25519signer_new: (a: number, b: number) => [number, number, number]; + readonly wasmed25519signer_sign: (a: number, b: number, c: number) => [number, number, number, number]; + readonly wasmed25519signer_verify: (a: number, b: number, c: number, d: number, e: number) => [number, number]; + readonly wasmkeyring_from_bytes: (a: number, b: number) => [number, number, number]; + readonly wasmkeyring_public_key_bundle: (a: number) => number; + readonly wasmkeyring_to_bytes: (a: number) => [number, number]; + readonly wasmpublickeybundle_from_bytes: (a: number, b: number) => [number, number, number]; + readonly wasmpublickeybundle_kem_public_key: (a: number) => [number, number]; + readonly wasmpublickeybundle_sig_cl_public_key: (a: number) => [number, number]; + readonly wasmpublickeybundle_sig_pq_public_key: (a: number) => [number, number]; + readonly wasmpublickeybundle_to_bytes: (a: number) => [number, number]; + readonly build_demo_message: (a: bigint, b: number, c: number, d: number, e: number) => [number, number, number, number]; + readonly build_ping_frame: (a: bigint, b: number, c: number, d: bigint, e: number, f: number) => [number, number, number, number]; + readonly build_request_frame: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number]; + readonly format_frame: (a: number, b: number) => [number, number, number, number]; + readonly parse_auth_response: (a: number, b: number) => [number, number, number]; + readonly parse_response_frame: (a: number, b: number) => [number, number, number, number]; + readonly main: () => void; + readonly __wbg_connectionconfig_free: (a: number, b: number) => void; + readonly __wbg_wasmclient_free: (a: number, b: number) => void; + readonly connectionconfig_client_id: (a: number) => bigint; + readonly connectionconfig_new: (a: number, b: number) => number; + readonly connectionconfig_set_client_id: (a: number, b: bigint) => void; + readonly connectionconfig_set_server_certificate_hashes: (a: number, b: number, c: number) => void; + readonly connectionconfig_url: (a: number) => [number, number]; + readonly wasmclient_auth_connect: (a: number, b: number, c: number, d: number, e: number, f: number, g: bigint) => any; + readonly wasmclient_auth_register: (a: number, b: number, c: number, d: number, e: number, f: number) => any; + readonly wasmclient_connect: (a: number, b: number) => any; + readonly wasmclient_disconnect: (a: number) => void; + readonly wasmclient_is_supported: () => number; + readonly wasmclient_new: (a: any, b: any, c: any) => number; + readonly wasmclient_send: (a: number, b: number, c: number) => any; + readonly wasmclient_state: (a: number) => number; + readonly wasm_bindgen__convert__closures_____invoke__h6588d25cdde23584: (a: number, b: number, c: any) => [number, number]; + readonly wasm_bindgen__convert__closures_____invoke__h5c81efa430e34369: (a: number, b: number, c: any) => [number, number]; + readonly wasm_bindgen__convert__closures_____invoke__h5c81efa430e34369_2: (a: number, b: number, c: any) => [number, number]; + readonly wasm_bindgen__convert__closures_____invoke__h4bf2427f775cf424: (a: number, b: number, c: any, d: any) => void; + readonly __wbindgen_malloc: (a: number, b: number) => number; + readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number; + readonly __wbindgen_exn_store: (a: number) => void; + readonly __externref_table_alloc: () => number; + readonly __wbindgen_externrefs: WebAssembly.Table; + readonly __wbindgen_free: (a: number, b: number, c: number) => void; + readonly __wbindgen_destroy_closure: (a: number, b: number) => void; + readonly __externref_table_dealloc: (a: number) => void; + readonly __wbindgen_start: () => void; +} + +export type SyncInitInput = BufferSource | WebAssembly.Module; + +/** + * Instantiates the given `module`, which can either be bytes or + * a precompiled `WebAssembly.Module`. + * + * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated. + * + * @returns {InitOutput} + */ +export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput; + +/** + * If `module_or_path` is {RequestInfo} or {URL}, makes a request and + * for everything else, calls `WebAssembly.instantiate` directly. + * + * @param {{ module_or_path: InitInput | Promise }} module_or_path - Passing `InitInput` directly is deprecated. + * + * @returns {Promise} + */ +export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise } | InitInput | Promise): Promise; diff --git a/wasm/pkg/mtp_wasm.js b/wasm/pkg/mtp_wasm.js new file mode 100644 index 0000000..bbe86a2 --- /dev/null +++ b/wasm/pkg/mtp_wasm.js @@ -0,0 +1,1412 @@ +/* @ts-self-types="./mtp_wasm.d.ts" */ + +export class ConnectionConfig { + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + ConnectionConfigFinalization.unregister(this); + return ptr; + } + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_connectionconfig_free(ptr, 0); + } + /** + * @returns {bigint} + */ + get client_id() { + const ret = wasm.connectionconfig_client_id(this.__wbg_ptr); + return BigInt.asUintN(64, ret); + } + /** + * @param {string} url + */ + constructor(url) { + const ptr0 = passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.connectionconfig_new(ptr0, len0); + this.__wbg_ptr = ret; + ConnectionConfigFinalization.register(this, this.__wbg_ptr, this); + return this; + } + /** + * @param {bigint} id + */ + set client_id(id) { + wasm.connectionconfig_set_client_id(this.__wbg_ptr, id); + } + /** + * @param {string[]} hashes + */ + set server_certificate_hashes(hashes) { + const ptr0 = passArrayJsValueToWasm0(hashes, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + wasm.connectionconfig_set_server_certificate_hashes(this.__wbg_ptr, ptr0, len0); + } + /** + * @returns {string} + */ + get url() { + let deferred1_0; + let deferred1_1; + try { + const ret = wasm.connectionconfig_url(this.__wbg_ptr); + deferred1_0 = ret[0]; + deferred1_1 = ret[1]; + return getStringFromWasm0(ret[0], ret[1]); + } finally { + wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); + } + } +} +if (Symbol.dispose) ConnectionConfig.prototype[Symbol.dispose] = ConnectionConfig.prototype.free; + +/** + * @enum {0 | 1 | 2 | 3} + */ +export const ConnectionState = Object.freeze({ + Disconnected: 0, "0": "Disconnected", + Connecting: 1, "1": "Connecting", + Connected: 2, "2": "Connected", + Failed: 3, "3": "Failed", +}); + +export class WasmChaCha20Poly1305 { + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + WasmChaCha20Poly1305Finalization.unregister(this); + return ptr; + } + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_wasmchacha20poly1305_free(ptr, 0); + } + /** + * Decrypt `nonce || ciphertext` with `aad`. + * @param {Uint8Array} ciphertext + * @param {Uint8Array} aad + * @returns {Uint8Array} + */ + decrypt(ciphertext, aad) { + const ptr0 = passArray8ToWasm0(ciphertext, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passArray8ToWasm0(aad, wasm.__wbindgen_malloc); + const len1 = WASM_VECTOR_LEN; + const ret = wasm.wasmchacha20poly1305_decrypt(this.__wbg_ptr, ptr0, len0, ptr1, len1); + if (ret[3]) { + throw takeFromExternrefTable0(ret[2]); + } + var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); + wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); + return v3; + } + /** + * Encrypt `plaintext` with `aad`. + * Returns `nonce || ciphertext`. + * @param {Uint8Array} plaintext + * @param {Uint8Array} aad + * @returns {Uint8Array} + */ + encrypt(plaintext, aad) { + const ptr0 = passArray8ToWasm0(plaintext, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passArray8ToWasm0(aad, wasm.__wbindgen_malloc); + const len1 = WASM_VECTOR_LEN; + const ret = wasm.wasmchacha20poly1305_encrypt(this.__wbg_ptr, ptr0, len0, ptr1, len1); + if (ret[3]) { + throw takeFromExternrefTable0(ret[2]); + } + var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); + wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); + return v3; + } + /** + * Create a new cipher with a 32-byte key. + * @param {Uint8Array} key + */ + constructor(key) { + const ptr0 = passArray8ToWasm0(key, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.wasmchacha20poly1305_new(ptr0, len0); + if (ret[2]) { + throw takeFromExternrefTable0(ret[1]); + } + this.__wbg_ptr = ret[0]; + WasmChaCha20Poly1305Finalization.register(this, this.__wbg_ptr, this); + return this; + } +} +if (Symbol.dispose) WasmChaCha20Poly1305.prototype[Symbol.dispose] = WasmChaCha20Poly1305.prototype.free; + +export class WasmClient { + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + WasmClientFinalization.unregister(this); + return ptr; + } + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_wasmclient_free(ptr, 0); + } + /** + * Authenticated login with an existing client ID. + * Exchanges Identification + signatures and verifies the host response. + * + * - `host_public_key_bytes`: serialized PublicKeyBundle from the server + * - `keyring_bytes`: serialized Keyring of this client (must match `client_id`) + * - `client_id`: previously assigned client ID + * + * Returns the confirmed (same) client ID on success. + * @param {ConnectionConfig} config + * @param {Uint8Array} host_public_key_bytes + * @param {Uint8Array} keyring_bytes + * @param {bigint} client_id + * @returns {Promise} + */ + auth_connect(config, host_public_key_bytes, keyring_bytes, client_id) { + _assertClass(config, ConnectionConfig); + const ptr0 = passArray8ToWasm0(host_public_key_bytes, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passArray8ToWasm0(keyring_bytes, wasm.__wbindgen_malloc); + const len1 = WASM_VECTOR_LEN; + const ret = wasm.wasmclient_auth_connect(this.__wbg_ptr, config.__wbg_ptr, ptr0, len0, ptr1, len1, client_id); + return ret; + } + /** + * Authenticated registration with a fresh keyring. + * The server assigns a new client ID. + * + * - `host_public_key_bytes`: serialized PublicKeyBundle from the server + * - `keyring_bytes`: serialized Keyring (must include ed25519 secret key) + * + * Returns the newly assigned client ID. + * @param {ConnectionConfig} config + * @param {Uint8Array} host_public_key_bytes + * @param {Uint8Array} keyring_bytes + * @returns {Promise} + */ + auth_register(config, host_public_key_bytes, keyring_bytes) { + _assertClass(config, ConnectionConfig); + const ptr0 = passArray8ToWasm0(host_public_key_bytes, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passArray8ToWasm0(keyring_bytes, wasm.__wbindgen_malloc); + const len1 = WASM_VECTOR_LEN; + const ret = wasm.wasmclient_auth_register(this.__wbg_ptr, config.__wbg_ptr, ptr0, len0, ptr1, len1); + return ret; + } + /** + * Unauthenticated connect (sends basic Identification, enables receive loop). + * @param {ConnectionConfig} config + * @returns {Promise} + */ + connect(config) { + _assertClass(config, ConnectionConfig); + const ret = wasm.wasmclient_connect(this.__wbg_ptr, config.__wbg_ptr); + return ret; + } + disconnect() { + wasm.wasmclient_disconnect(this.__wbg_ptr); + } + /** + * @returns {boolean} + */ + static is_supported() { + const ret = wasm.wasmclient_is_supported(); + return ret !== 0; + } + /** + * @param {Function} on_state_change + * @param {Function} on_message + * @param {Function} on_error + */ + constructor(on_state_change, on_message, on_error) { + const ret = wasm.wasmclient_new(on_state_change, on_message, on_error); + this.__wbg_ptr = ret; + WasmClientFinalization.register(this, this.__wbg_ptr, this); + return this; + } + /** + * @param {Uint8Array} frame + * @returns {Promise} + */ + send(frame) { + const ptr0 = passArray8ToWasm0(frame, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.wasmclient_send(this.__wbg_ptr, ptr0, len0); + return ret; + } + /** + * @returns {number} + */ + get state() { + const ret = wasm.wasmclient_state(this.__wbg_ptr); + return ret; + } +} +if (Symbol.dispose) WasmClient.prototype[Symbol.dispose] = WasmClient.prototype.free; + +export class WasmEd25519Signer { + static __wrap(ptr) { + const obj = Object.create(WasmEd25519Signer.prototype); + obj.__wbg_ptr = ptr; + WasmEd25519SignerFinalization.register(obj, obj.__wbg_ptr, obj); + return obj; + } + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + WasmEd25519SignerFinalization.unregister(this); + return ptr; + } + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_wasmed25519signer_free(ptr, 0); + } + /** + * Load a signer from its 32-byte secret key. + * @param {Uint8Array} secret_key + */ + constructor(secret_key) { + const ptr0 = passArray8ToWasm0(secret_key, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.wasmed25519signer_new(ptr0, len0); + if (ret[2]) { + throw takeFromExternrefTable0(ret[1]); + } + this.__wbg_ptr = ret[0]; + WasmEd25519SignerFinalization.register(this, this.__wbg_ptr, this); + return this; + } + /** + * Sign `message` and return the signature bytes. + * @param {Uint8Array} message + * @returns {Uint8Array} + */ + sign(message) { + const ptr0 = passArray8ToWasm0(message, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.wasmed25519signer_sign(this.__wbg_ptr, ptr0, len0); + if (ret[3]) { + throw takeFromExternrefTable0(ret[2]); + } + var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); + wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); + return v2; + } + /** + * Verify `signature` against `message`. + * @param {Uint8Array} message + * @param {Uint8Array} signature + */ + verify(message, signature) { + const ptr0 = passArray8ToWasm0(message, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc); + const len1 = WASM_VECTOR_LEN; + const ret = wasm.wasmed25519signer_verify(this.__wbg_ptr, ptr0, len0, ptr1, len1); + if (ret[1]) { + throw takeFromExternrefTable0(ret[0]); + } + } +} +if (Symbol.dispose) WasmEd25519Signer.prototype[Symbol.dispose] = WasmEd25519Signer.prototype.free; + +export class WasmKeyring { + static __wrap(ptr) { + const obj = Object.create(WasmKeyring.prototype); + obj.__wbg_ptr = ptr; + WasmKeyringFinalization.register(obj, obj.__wbg_ptr, obj); + return obj; + } + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + WasmKeyringFinalization.unregister(this); + return ptr; + } + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_wasmkeyring_free(ptr, 0); + } + /** + * Deserialise a keyring from bytes. + * @param {Uint8Array} bytes + * @returns {WasmKeyring} + */ + static from_bytes(bytes) { + const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.wasmkeyring_from_bytes(ptr0, len0); + if (ret[2]) { + throw takeFromExternrefTable0(ret[1]); + } + return WasmKeyring.__wrap(ret[0]); + } + /** + * Return the public half of this keyring as a bundle. + * @returns {WasmPublicKeyBundle} + */ + public_key_bundle() { + const ret = wasm.wasmkeyring_public_key_bundle(this.__wbg_ptr); + return WasmPublicKeyBundle.__wrap(ret); + } + /** + * Serialise the keyring to bytes. + * @returns {Uint8Array} + */ + to_bytes() { + const ret = wasm.wasmkeyring_to_bytes(this.__wbg_ptr); + var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); + wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); + return v1; + } +} +if (Symbol.dispose) WasmKeyring.prototype[Symbol.dispose] = WasmKeyring.prototype.free; + +export class WasmPublicKeyBundle { + static __wrap(ptr) { + const obj = Object.create(WasmPublicKeyBundle.prototype); + obj.__wbg_ptr = ptr; + WasmPublicKeyBundleFinalization.register(obj, obj.__wbg_ptr, obj); + return obj; + } + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + WasmPublicKeyBundleFinalization.unregister(this); + return ptr; + } + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_wasmpublickeybundle_free(ptr, 0); + } + /** + * @param {Uint8Array} bytes + * @returns {WasmPublicKeyBundle} + */ + static from_bytes(bytes) { + const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.wasmpublickeybundle_from_bytes(ptr0, len0); + if (ret[2]) { + throw takeFromExternrefTable0(ret[1]); + } + return WasmPublicKeyBundle.__wrap(ret[0]); + } + /** + * @returns {Uint8Array} + */ + get kem_public_key() { + const ret = wasm.wasmpublickeybundle_kem_public_key(this.__wbg_ptr); + var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); + wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); + return v1; + } + /** + * @returns {Uint8Array} + */ + get sig_cl_public_key() { + const ret = wasm.wasmpublickeybundle_sig_cl_public_key(this.__wbg_ptr); + var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); + wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); + return v1; + } + /** + * @returns {Uint8Array} + */ + get sig_pq_public_key() { + const ret = wasm.wasmpublickeybundle_sig_pq_public_key(this.__wbg_ptr); + var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); + wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); + return v1; + } + /** + * @returns {Uint8Array} + */ + to_bytes() { + const ret = wasm.wasmpublickeybundle_to_bytes(this.__wbg_ptr); + var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); + wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); + return v1; + } +} +if (Symbol.dispose) WasmPublicKeyBundle.prototype[Symbol.dispose] = WasmPublicKeyBundle.prototype.free; + +/** + * Build a demo Ping frame with encrypted and signed containers + * (mirrors the Rust client example but uses only reserved data types). + * @param {bigint} client_id + * @param {Uint8Array} keyring_bytes + * @param {Uint8Array} host_bundle_bytes + * @returns {Uint8Array} + */ +export function build_demo_message(client_id, keyring_bytes, host_bundle_bytes) { + const ptr0 = passArray8ToWasm0(keyring_bytes, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passArray8ToWasm0(host_bundle_bytes, wasm.__wbindgen_malloc); + const len1 = WASM_VECTOR_LEN; + const ret = wasm.build_demo_message(client_id, ptr0, len0, ptr1, len1); + if (ret[3]) { + throw takeFromExternrefTable0(ret[2]); + } + var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); + wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); + return v3; +} + +/** + * Build a simple Ping frame with description, timestamp, and optional data. + * @param {bigint} client_id + * @param {string} description + * @param {bigint} timestamp + * @param {Uint8Array} data + * @returns {Uint8Array} + */ +export function build_ping_frame(client_id, description, timestamp, data) { + const ptr0 = passStringToWasm0(description, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passArray8ToWasm0(data, wasm.__wbindgen_malloc); + const len1 = WASM_VECTOR_LEN; + const ret = wasm.build_ping_frame(client_id, ptr0, len0, timestamp, ptr1, len1); + if (ret[3]) { + throw takeFromExternrefTable0(ret[2]); + } + var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); + wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); + return v3; +} + +/** + * Build a request frame with the given communication type name, request ID, and JSON data. + * + * - `comm_type`: communication type name (e.g. "get_model", "rank_models") or PascalCase + * - `id`: request ID for response correlation + * - `json_data`: JSON-stringified request payload + * @param {string} comm_type + * @param {number} id + * @param {string} json_data + * @returns {Uint8Array} + */ +export function build_request_frame(comm_type, id, json_data) { + const ptr0 = passStringToWasm0(comm_type, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passStringToWasm0(json_data, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + const ret = wasm.build_request_frame(ptr0, len0, id, ptr1, len1); + if (ret[3]) { + throw takeFromExternrefTable0(ret[2]); + } + var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); + wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); + return v3; +} + +/** + * Generate a fresh Ed25519 keypair. + * + * Returns `{ signer: WasmEd25519Signer, secretKey: Uint8Array, publicKey: Uint8Array }`. + * @returns {any} + */ +export function ed25519_generate() { + const ret = wasm.ed25519_generate(); + if (ret[2]) { + throw takeFromExternrefTable0(ret[1]); + } + return takeFromExternrefTable0(ret[0]); +} + +/** + * Standalone Ed25519 signature verification. + * @param {Uint8Array} public_key + * @param {Uint8Array} message + * @param {Uint8Array} signature + */ +export function ed25519_verify(public_key, message, signature) { + const ptr0 = passArray8ToWasm0(public_key, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passArray8ToWasm0(message, wasm.__wbindgen_malloc); + const len1 = WASM_VECTOR_LEN; + const ptr2 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc); + const len2 = WASM_VECTOR_LEN; + const ret = wasm.ed25519_verify(ptr0, len0, ptr1, len1, ptr2, len2); + if (ret[1]) { + throw takeFromExternrefTable0(ret[0]); + } +} + +/** + * Parse any MTP frame into the human-readable CommunicationValue display form. + * @param {Uint8Array} frame + * @returns {string} + */ +export function format_frame(frame) { + let deferred3_0; + let deferred3_1; + try { + const ptr0 = passArray8ToWasm0(frame, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.format_frame(ptr0, len0); + var ptr2 = ret[0]; + var len2 = ret[1]; + if (ret[3]) { + ptr2 = 0; len2 = 0; + throw takeFromExternrefTable0(ret[2]); + } + deferred3_0 = ptr2; + deferred3_1 = len2; + return getStringFromWasm0(ptr2, len2); + } finally { + wasm.__wbindgen_free(deferred3_0, deferred3_1, 1); + } +} + +/** + * Build a [`Keyring`] containing only an Ed25519 keypair (no KEM, no ML-DSA). + * + * Takes the Ed25519 secret key and public key, each 32 bytes. + * Returns the serialised keyring bytes, suitable for passing to `WasmClient.auth_register`. + * @param {Uint8Array} secret_key + * @param {Uint8Array} public_key + * @returns {Uint8Array} + */ +export function keyring_from_ed25519(secret_key, public_key) { + const ptr0 = passArray8ToWasm0(secret_key, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passArray8ToWasm0(public_key, wasm.__wbindgen_malloc); + const len1 = WASM_VECTOR_LEN; + const ret = wasm.keyring_from_ed25519(ptr0, len0, ptr1, len1); + if (ret[3]) { + throw takeFromExternrefTable0(ret[2]); + } + var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); + wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); + return v3; +} + +export function main() { + wasm.main(); +} + +/** + * Parse an auth response frame into a JS object. + * @param {Uint8Array} response + * @returns {any} + */ +export function parse_auth_response(response) { + const ptr0 = passArray8ToWasm0(response, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.parse_auth_response(ptr0, len0); + if (ret[2]) { + throw takeFromExternrefTable0(ret[1]); + } + return takeFromExternrefTable0(ret[0]); +} + +/** + * Parse a response frame into a JSON string containing `_id`, `_type`, and data fields. + * @param {Uint8Array} frame + * @returns {string} + */ +export function parse_response_frame(frame) { + let deferred3_0; + let deferred3_1; + try { + const ptr0 = passArray8ToWasm0(frame, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.parse_response_frame(ptr0, len0); + var ptr2 = ret[0]; + var len2 = ret[1]; + if (ret[3]) { + ptr2 = 0; len2 = 0; + throw takeFromExternrefTable0(ret[2]); + } + deferred3_0 = ptr2; + deferred3_1 = len2; + return getStringFromWasm0(ptr2, len2); + } finally { + wasm.__wbindgen_free(deferred3_0, deferred3_1, 1); + } +} + +/** + * Derive a 32-byte encryption key from `ikm` with `salt` and `context`. + * @param {Uint8Array} ikm + * @param {Uint8Array} salt + * @param {Uint8Array} context + * @returns {Uint8Array} + */ +export function wasm_derive_encryption_key(ikm, salt, context) { + const ptr0 = passArray8ToWasm0(ikm, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passArray8ToWasm0(salt, wasm.__wbindgen_malloc); + const len1 = WASM_VECTOR_LEN; + const ptr2 = passArray8ToWasm0(context, wasm.__wbindgen_malloc); + const len2 = WASM_VECTOR_LEN; + const ret = wasm.wasm_derive_encryption_key(ptr0, len0, ptr1, len1, ptr2, len2); + if (ret[3]) { + throw takeFromExternrefTable0(ret[2]); + } + var v4 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); + wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); + return v4; +} + +/** + * HKDF-expand: derive `len` bytes from `ikm` with `salt` and `info`. + * @param {Uint8Array} ikm + * @param {Uint8Array} salt + * @param {Uint8Array} info + * @param {number} len + * @returns {Uint8Array} + */ +export function wasm_hkdf_expand(ikm, salt, info, len) { + const ptr0 = passArray8ToWasm0(ikm, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passArray8ToWasm0(salt, wasm.__wbindgen_malloc); + const len1 = WASM_VECTOR_LEN; + const ptr2 = passArray8ToWasm0(info, wasm.__wbindgen_malloc); + const len2 = WASM_VECTOR_LEN; + const ret = wasm.wasm_hkdf_expand(ptr0, len0, ptr1, len1, ptr2, len2, len); + if (ret[3]) { + throw takeFromExternrefTable0(ret[2]); + } + var v4 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); + wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); + return v4; +} + +/** + * SHA-256 digest. + * @param {Uint8Array} data + * @returns {Uint8Array} + */ +export function wasm_sha256(data) { + const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.wasm_sha256(ptr0, len0); + var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); + wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); + return v2; +} + +/** + * Double SHA-256 (SHA-256 applied twice). + * @param {Uint8Array} data + * @returns {Uint8Array} + */ +export function wasm_sha256_double(data) { + const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.wasm_sha256_double(ptr0, len0); + var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); + wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); + return v2; +} +function __wbg_get_imports() { + const import0 = { + __proto__: null, + __wbg___wbindgen_boolean_get_fa956cfa2d1bd751: function(arg0) { + const v = arg0; + const ret = typeof(v) === 'boolean' ? v : undefined; + return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0; + }, + __wbg___wbindgen_debug_string_c25d447a39f5578f: function(arg0, arg1) { + const ret = debugString(arg1); + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); + getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); + }, + __wbg___wbindgen_is_function_1ff95bcc5517c252: function(arg0) { + const ret = typeof(arg0) === 'function'; + return ret; + }, + __wbg___wbindgen_is_null_ea9085d691f535d3: function(arg0) { + const ret = arg0 === null; + return ret; + }, + __wbg___wbindgen_is_object_a27215656b807791: function(arg0) { + const val = arg0; + const ret = typeof(val) === 'object' && val !== null; + return ret; + }, + __wbg___wbindgen_is_string_ea5e6cc2e4141dfe: function(arg0) { + const ret = typeof(arg0) === 'string'; + return ret; + }, + __wbg___wbindgen_is_undefined_c05833b95a3cf397: function(arg0) { + const ret = arg0 === undefined; + return ret; + }, + __wbg___wbindgen_string_get_b0ca35b86a603356: function(arg0, arg1) { + const obj = arg1; + const ret = typeof(obj) === 'string' ? obj : undefined; + var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); + getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); + }, + __wbg___wbindgen_throw_344f42d3211c4765: function(arg0, arg1) { + throw new Error(getStringFromWasm0(arg0, arg1)); + }, + __wbg__wbg_cb_unref_fffb441def202758: function(arg0) { + arg0._wbg_cb_unref(); + }, + __wbg_call_8a2dd23819f8a60a: function() { return handleError(function (arg0, arg1) { + const ret = arg0.call(arg1); + return ret; + }, arguments); }, + __wbg_call_a6e5c5dce5018821: function() { return handleError(function (arg0, arg1, arg2) { + const ret = arg0.call(arg1, arg2); + return ret; + }, arguments); }, + __wbg_close_23b01d38b065688a: function(arg0, arg1) { + arg0.close(arg1); + }, + __wbg_createUnidirectionalStream_9ff0e4127f40ed0d: function(arg0) { + const ret = arg0.createUnidirectionalStream(); + return ret; + }, + __wbg_crypto_38df2bab126b63dc: function(arg0) { + const ret = arg0.crypto; + return ret; + }, + __wbg_entries_015dc610cd81ede0: function(arg0) { + const ret = Object.entries(arg0); + return ret; + }, + __wbg_error_a6fa202b58aa1cd3: function(arg0, arg1) { + let deferred0_0; + let deferred0_1; + try { + deferred0_0 = arg0; + deferred0_1 = arg1; + console.error(getStringFromWasm0(arg0, arg1)); + } finally { + wasm.__wbindgen_free(deferred0_0, deferred0_1, 1); + } + }, + __wbg_getRandomValues_c44a50d8cfdaebeb: function() { return handleError(function (arg0, arg1) { + arg0.getRandomValues(arg1); + }, arguments); }, + __wbg_getRandomValues_cc7f052a444bb2ce: function() { return handleError(function (arg0, arg1) { + globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1)); + }, arguments); }, + __wbg_get_507a50627bffa49b: function(arg0, arg1) { + const ret = arg0[arg1 >>> 0]; + return ret; + }, + __wbg_get_78f252d074a84d0b: function() { return handleError(function (arg0, arg1) { + const ret = Reflect.get(arg0, arg1); + return ret; + }, arguments); }, + __wbg_has_8374cf06984d8bfc: function() { return handleError(function (arg0, arg1) { + const ret = Reflect.has(arg0, arg1); + return ret; + }, arguments); }, + __wbg_incomingUnidirectionalStreams_505a67efefd669d3: function(arg0) { + const ret = arg0.incomingUnidirectionalStreams; + return ret; + }, + __wbg_isArray_0677c962b281d01a: function(arg0) { + const ret = Array.isArray(arg0); + return ret; + }, + __wbg_length_1f0964f4a5e2c6d8: function(arg0) { + const ret = arg0.length; + return ret; + }, + __wbg_length_370319915dc99107: function(arg0) { + const ret = arg0.length; + return ret; + }, + __wbg_log_d267660666346fb3: function(arg0) { + console.log(arg0); + }, + __wbg_msCrypto_bd5a034af96bcba6: function(arg0) { + const ret = arg0.msCrypto; + return ret; + }, + __wbg_new_227d7c05414eb861: function() { + const ret = new Error(); + return ret; + }, + __wbg_new_a2778e1fb014b494: function() { return handleError(function (arg0, arg1) { + const ret = new WebTransport(getStringFromWasm0(arg0, arg1)); + return ret; + }, arguments); }, + __wbg_new_cd45aabdf6073e84: function(arg0) { + const ret = new Uint8Array(arg0); + return ret; + }, + __wbg_new_da52cf8fe3429cb2: function() { + const ret = new Object(); + return ret; + }, + __wbg_new_from_slice_77cdfb7977362f3c: function(arg0, arg1) { + const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1)); + return ret; + }, + __wbg_new_typed_1824d93f294193e5: function(arg0, arg1) { + try { + var state0 = {a: arg0, b: arg1}; + var cb0 = (arg0, arg1) => { + const a = state0.a; + state0.a = 0; + try { + return wasm_bindgen__convert__closures_____invoke__h4bf2427f775cf424(a, state0.b, arg0, arg1); + } finally { + state0.a = a; + } + }; + const ret = new Promise(cb0); + return ret; + } finally { + state0.a = 0; + } + }, + __wbg_new_with_length_e6785c33c8e4cce8: function(arg0) { + const ret = new Uint8Array(arg0 >>> 0); + return ret; + }, + __wbg_new_with_options_5b1cc213336d0b4c: function() { return handleError(function (arg0, arg1, arg2) { + const ret = new WebTransport(getStringFromWasm0(arg0, arg1), arg2); + return ret; + }, arguments); }, + __wbg_node_84ea875411254db1: function(arg0) { + const ret = arg0.node; + return ret; + }, + __wbg_now_86c0d4ba3fa605b8: function() { + const ret = Date.now(); + return ret; + }, + __wbg_parse_1c0d8a8656d7e016: function() { return handleError(function (arg0, arg1) { + const ret = JSON.parse(getStringFromWasm0(arg0, arg1)); + return ret; + }, arguments); }, + __wbg_process_44c7a14e11e9f69e: function(arg0) { + const ret = arg0.process; + return ret; + }, + __wbg_prototypesetcall_4770620bbe4688a0: function(arg0, arg1, arg2) { + Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2); + }, + __wbg_queueMicrotask_0ab5b2d2393e99b9: function(arg0) { + const ret = arg0.queueMicrotask; + return ret; + }, + __wbg_queueMicrotask_6a09b7bc46549209: function(arg0) { + queueMicrotask(arg0); + }, + __wbg_randomFillSync_6c25eac9869eb53c: function() { return handleError(function (arg0, arg1) { + arg0.randomFillSync(arg1); + }, arguments); }, + __wbg_ready_e4dad560377c42e6: function(arg0) { + const ret = arg0.ready; + return ret; + }, + __wbg_require_b4edbdcf3e2a1ef0: function() { return handleError(function () { + const ret = module.require; + return ret; + }, arguments); }, + __wbg_resolve_2191a4dfe481c25b: function(arg0) { + const ret = Promise.resolve(arg0); + return ret; + }, + __wbg_set_8535240470bf2500: function() { return handleError(function (arg0, arg1, arg2) { + const ret = Reflect.set(arg0, arg1, arg2); + return ret; + }, arguments); }, + __wbg_set_algorithm_4884633ae550b091: function(arg0, arg1, arg2) { + arg0.algorithm = getStringFromWasm0(arg1, arg2); + }, + __wbg_set_server_certificate_hashes_c6f10c7638672baf: function(arg0, arg1, arg2) { + arg0.serverCertificateHashes = getArrayJsValueViewFromWasm0(arg1, arg2); + }, + __wbg_set_value_u8_array_38f1c892603c4916: function(arg0, arg1) { + arg0.value = arg1; + }, + __wbg_stack_3b0d974bbf31e44f: function(arg0, arg1) { + const ret = arg1.stack; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); + getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); + }, + __wbg_static_accessor_GLOBAL_4ef717fb391d88b7: function() { + const ret = typeof global === 'undefined' ? null : global; + return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); + }, + __wbg_static_accessor_GLOBAL_THIS_8d1badc68b5a74f4: function() { + const ret = typeof globalThis === 'undefined' ? null : globalThis; + return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); + }, + __wbg_static_accessor_SELF_146583524fe1469b: function() { + const ret = typeof self === 'undefined' ? null : self; + return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); + }, + __wbg_static_accessor_WINDOW_f2829a2234d7819e: function() { + const ret = typeof window === 'undefined' ? null : window; + return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); + }, + __wbg_stringify_b54333f60f1e4dad: function() { return handleError(function (arg0) { + const ret = JSON.stringify(arg0); + return ret; + }, arguments); }, + __wbg_subarray_3ed232c8a6baee09: function(arg0, arg1, arg2) { + const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0); + return ret; + }, + __wbg_then_16d107c451e9905d: function(arg0, arg1, arg2) { + const ret = arg0.then(arg1, arg2); + return ret; + }, + __wbg_then_6ec10ae38b3e92f7: function(arg0, arg1) { + const ret = arg0.then(arg1); + return ret; + }, + __wbg_versions_276b2795b1c6a219: function(arg0) { + const ret = arg0.versions; + return ret; + }, + __wbg_wasmed25519signer_new: function(arg0) { + const ret = WasmEd25519Signer.__wrap(arg0); + return ret; + }, + __wbindgen_cast_0000000000000001: function(arg0, arg1) { + // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 137, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`. + const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h6588d25cdde23584); + return ret; + }, + __wbindgen_cast_0000000000000002: function(arg0, arg1) { + // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("WebTransportSendStream")], shim_idx: 63, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`. + const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h5c81efa430e34369); + return ret; + }, + __wbindgen_cast_0000000000000003: function(arg0, arg1) { + // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("undefined")], shim_idx: 63, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`. + const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h5c81efa430e34369_2); + return ret; + }, + __wbindgen_cast_0000000000000004: function(arg0) { + // Cast intrinsic for `F64 -> Externref`. + const ret = arg0; + return ret; + }, + __wbindgen_cast_0000000000000005: function(arg0, arg1) { + // Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`. + const ret = getArrayU8FromWasm0(arg0, arg1); + return ret; + }, + __wbindgen_cast_0000000000000006: function(arg0, arg1) { + // Cast intrinsic for `Ref(String) -> Externref`. + const ret = getStringFromWasm0(arg0, arg1); + return ret; + }, + __wbindgen_cast_0000000000000007: function(arg0) { + // Cast intrinsic for `U64 -> Externref`. + const ret = BigInt.asUintN(64, arg0); + return ret; + }, + __wbindgen_init_externref_table: function() { + const table = wasm.__wbindgen_externrefs; + const offset = table.grow(4); + table.set(0, undefined); + table.set(offset + 0, undefined); + table.set(offset + 1, null); + table.set(offset + 2, true); + table.set(offset + 3, false); + }, + }; + return { + __proto__: null, + "./mtp_wasm_bg.js": import0, + }; +} + +function wasm_bindgen__convert__closures_____invoke__h6588d25cdde23584(arg0, arg1, arg2) { + const ret = wasm.wasm_bindgen__convert__closures_____invoke__h6588d25cdde23584(arg0, arg1, arg2); + if (ret[1]) { + throw takeFromExternrefTable0(ret[0]); + } +} + +function wasm_bindgen__convert__closures_____invoke__h5c81efa430e34369(arg0, arg1, arg2) { + const ret = wasm.wasm_bindgen__convert__closures_____invoke__h5c81efa430e34369(arg0, arg1, arg2); + if (ret[1]) { + throw takeFromExternrefTable0(ret[0]); + } +} + +function wasm_bindgen__convert__closures_____invoke__h5c81efa430e34369_2(arg0, arg1, arg2) { + const ret = wasm.wasm_bindgen__convert__closures_____invoke__h5c81efa430e34369_2(arg0, arg1, arg2); + if (ret[1]) { + throw takeFromExternrefTable0(ret[0]); + } +} + +function wasm_bindgen__convert__closures_____invoke__h4bf2427f775cf424(arg0, arg1, arg2, arg3) { + wasm.wasm_bindgen__convert__closures_____invoke__h4bf2427f775cf424(arg0, arg1, arg2, arg3); +} + +const ConnectionConfigFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(ptr => wasm.__wbg_connectionconfig_free(ptr, 1)); +const WasmChaCha20Poly1305Finalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(ptr => wasm.__wbg_wasmchacha20poly1305_free(ptr, 1)); +const WasmClientFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(ptr => wasm.__wbg_wasmclient_free(ptr, 1)); +const WasmEd25519SignerFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(ptr => wasm.__wbg_wasmed25519signer_free(ptr, 1)); +const WasmKeyringFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(ptr => wasm.__wbg_wasmkeyring_free(ptr, 1)); +const WasmPublicKeyBundleFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(ptr => wasm.__wbg_wasmpublickeybundle_free(ptr, 1)); + +function addToExternrefTable0(obj) { + const idx = wasm.__externref_table_alloc(); + wasm.__wbindgen_externrefs.set(idx, obj); + return idx; +} + +function _assertClass(instance, klass) { + if (!(instance instanceof klass)) { + throw new Error(`expected instance of ${klass.name}`); + } +} + +const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(state => wasm.__wbindgen_destroy_closure(state.a, state.b)); + +function debugString(val) { + // primitive types + const type = typeof val; + if (type == 'number' || type == 'boolean' || val == null) { + return `${val}`; + } + if (type == 'string') { + return `"${val}"`; + } + if (type == 'symbol') { + const description = val.description; + if (description == null) { + return 'Symbol'; + } else { + return `Symbol(${description})`; + } + } + if (type == 'function') { + const name = val.name; + if (typeof name == 'string' && name.length > 0) { + return `Function(${name})`; + } else { + return 'Function'; + } + } + // objects + if (Array.isArray(val)) { + const length = val.length; + let debug = '['; + if (length > 0) { + debug += debugString(val[0]); + } + for(let i = 1; i < length; i++) { + debug += ', ' + debugString(val[i]); + } + debug += ']'; + return debug; + } + // Test for built-in + const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val)); + let className; + if (builtInMatches && builtInMatches.length > 1) { + className = builtInMatches[1]; + } else { + // Failed to match the standard '[object ClassName]' + return toString.call(val); + } + if (className == 'Object') { + // we're a user defined class or Object + // JSON.stringify avoids problems with cycles, and is generally much + // easier than looping through ownProperties of `val`. + try { + return 'Object(' + JSON.stringify(val) + ')'; + } catch (_) { + return 'Object'; + } + } + // errors + if (val instanceof Error) { + return `${val.name}: ${val.message}\n${val.stack}`; + } + // TODO we could test for more things here, like `Set`s and `Map`s. + return className; +} + +function getArrayJsValueViewFromWasm0(ptr, len) { + ptr = ptr >>> 0; + const mem = getDataViewMemory0(); + const result = []; + for (let i = ptr; i < ptr + 4 * len; i += 4) { + result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true))); + } + return result; +} + +function getArrayU8FromWasm0(ptr, len) { + ptr = ptr >>> 0; + return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len); +} + +let cachedDataViewMemory0 = null; +function getDataViewMemory0() { + if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) { + cachedDataViewMemory0 = new DataView(wasm.memory.buffer); + } + return cachedDataViewMemory0; +} + +function getStringFromWasm0(ptr, len) { + return decodeText(ptr >>> 0, len); +} + +let cachedUint8ArrayMemory0 = null; +function getUint8ArrayMemory0() { + if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) { + cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer); + } + return cachedUint8ArrayMemory0; +} + +function handleError(f, args) { + try { + return f.apply(this, args); + } catch (e) { + const idx = addToExternrefTable0(e); + wasm.__wbindgen_exn_store(idx); + } +} + +function isLikeNone(x) { + return x === undefined || x === null; +} + +function makeMutClosure(arg0, arg1, f) { + const state = { a: arg0, b: arg1, cnt: 1 }; + const real = (...args) => { + + // First up with a closure we increment the internal reference + // count. This ensures that the Rust closure environment won't + // be deallocated while we're invoking it. + state.cnt++; + const a = state.a; + state.a = 0; + try { + return f(a, state.b, ...args); + } finally { + state.a = a; + real._wbg_cb_unref(); + } + }; + real._wbg_cb_unref = () => { + if (--state.cnt === 0) { + wasm.__wbindgen_destroy_closure(state.a, state.b); + state.a = 0; + CLOSURE_DTORS.unregister(state); + } + }; + CLOSURE_DTORS.register(real, state, state); + return real; +} + +function passArray8ToWasm0(arg, malloc) { + const ptr = malloc(arg.length * 1, 1) >>> 0; + getUint8ArrayMemory0().set(arg, ptr / 1); + WASM_VECTOR_LEN = arg.length; + return ptr; +} + +function passArrayJsValueToWasm0(array, malloc) { + const ptr = malloc(array.length * 4, 4) >>> 0; + for (let i = 0; i < array.length; i++) { + const add = addToExternrefTable0(array[i]); + getDataViewMemory0().setUint32(ptr + 4 * i, add, true); + } + WASM_VECTOR_LEN = array.length; + return ptr; +} + +function passStringToWasm0(arg, malloc, realloc) { + if (realloc === undefined) { + const buf = cachedTextEncoder.encode(arg); + const ptr = malloc(buf.length, 1) >>> 0; + getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf); + WASM_VECTOR_LEN = buf.length; + return ptr; + } + + let len = arg.length; + let ptr = malloc(len, 1) >>> 0; + + const mem = getUint8ArrayMemory0(); + + let offset = 0; + + for (; offset < len; offset++) { + const code = arg.charCodeAt(offset); + if (code > 0x7F) break; + mem[ptr + offset] = code; + } + if (offset !== len) { + if (offset !== 0) { + arg = arg.slice(offset); + } + ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0; + const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len); + const ret = cachedTextEncoder.encodeInto(arg, view); + + offset += ret.written; + ptr = realloc(ptr, len, offset, 1) >>> 0; + } + + WASM_VECTOR_LEN = offset; + return ptr; +} + +function takeFromExternrefTable0(idx) { + const value = wasm.__wbindgen_externrefs.get(idx); + wasm.__externref_table_dealloc(idx); + return value; +} + +let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }); +cachedTextDecoder.decode(); +const MAX_SAFARI_DECODE_BYTES = 2146435072; +let numBytesDecoded = 0; +function decodeText(ptr, len) { + numBytesDecoded += len; + if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) { + cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }); + cachedTextDecoder.decode(); + numBytesDecoded = len; + } + return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len)); +} + +const cachedTextEncoder = new TextEncoder(); + +if (!('encodeInto' in cachedTextEncoder)) { + cachedTextEncoder.encodeInto = function (arg, view) { + const buf = cachedTextEncoder.encode(arg); + view.set(buf); + return { + read: arg.length, + written: buf.length + }; + }; +} + +let WASM_VECTOR_LEN = 0; + +let wasmModule, wasmInstance, wasm; +function __wbg_finalize_init(instance, module) { + wasmInstance = instance; + wasm = instance.exports; + wasmModule = module; + cachedDataViewMemory0 = null; + cachedUint8ArrayMemory0 = null; + wasm.__wbindgen_start(); + return wasm; +} + +async function __wbg_load(module, imports) { + if (typeof Response === 'function' && module instanceof Response) { + if (typeof WebAssembly.instantiateStreaming === 'function') { + try { + return await WebAssembly.instantiateStreaming(module, imports); + } catch (e) { + const validResponse = module.ok && expectedResponseType(module.type); + + if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') { + 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); + + } else { throw e; } + } + } + + const bytes = await module.arrayBuffer(); + return await WebAssembly.instantiate(bytes, imports); + } else { + const instance = await WebAssembly.instantiate(module, imports); + + if (instance instanceof WebAssembly.Instance) { + return { instance, module }; + } else { + return instance; + } + } + + function expectedResponseType(type) { + switch (type) { + case 'basic': case 'cors': case 'default': return true; + } + return false; + } +} + +function initSync(module) { + if (wasm !== undefined) return wasm; + + + if (module !== undefined) { + if (Object.getPrototypeOf(module) === Object.prototype) { + ({module} = module) + } else { + console.warn('using deprecated parameters for `initSync()`; pass a single object instead') + } + } + + const imports = __wbg_get_imports(); + if (!(module instanceof WebAssembly.Module)) { + module = new WebAssembly.Module(module); + } + const instance = new WebAssembly.Instance(module, imports); + return __wbg_finalize_init(instance, module); +} + +async function __wbg_init(module_or_path) { + if (wasm !== undefined) return wasm; + + + if (module_or_path !== undefined) { + if (Object.getPrototypeOf(module_or_path) === Object.prototype) { + ({module_or_path} = module_or_path) + } else { + console.warn('using deprecated parameters for the initialization function; pass a single object instead') + } + } + + if (module_or_path === undefined) { + module_or_path = new URL('mtp_wasm_bg.wasm', import.meta.url); + } + const imports = __wbg_get_imports(); + + if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) { + module_or_path = fetch(module_or_path); + } + + const { instance, module } = await __wbg_load(await module_or_path, imports); + + return __wbg_finalize_init(instance, module); +} + +export { initSync, __wbg_init as default }; diff --git a/wasm/pkg/mtp_wasm_bg.wasm b/wasm/pkg/mtp_wasm_bg.wasm new file mode 100644 index 0000000..9a6b28c Binary files /dev/null and b/wasm/pkg/mtp_wasm_bg.wasm differ diff --git a/wasm/pkg/mtp_wasm_bg.wasm.d.ts b/wasm/pkg/mtp_wasm_bg.wasm.d.ts new file mode 100644 index 0000000..82b833e --- /dev/null +++ b/wasm/pkg/mtp_wasm_bg.wasm.d.ts @@ -0,0 +1,63 @@ +/* tslint:disable */ +/* eslint-disable */ +export const memory: WebAssembly.Memory; +export const __wbg_wasmchacha20poly1305_free: (a: number, b: number) => void; +export const __wbg_wasmed25519signer_free: (a: number, b: number) => void; +export const __wbg_wasmkeyring_free: (a: number, b: number) => void; +export const __wbg_wasmpublickeybundle_free: (a: number, b: number) => void; +export const ed25519_generate: () => [number, number, number]; +export const ed25519_verify: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number]; +export const keyring_from_ed25519: (a: number, b: number, c: number, d: number) => [number, number, number, number]; +export const wasm_derive_encryption_key: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number]; +export const wasm_hkdf_expand: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number, number, number]; +export const wasm_sha256: (a: number, b: number) => [number, number]; +export const wasm_sha256_double: (a: number, b: number) => [number, number]; +export const wasmchacha20poly1305_decrypt: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number]; +export const wasmchacha20poly1305_encrypt: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number]; +export const wasmchacha20poly1305_new: (a: number, b: number) => [number, number, number]; +export const wasmed25519signer_new: (a: number, b: number) => [number, number, number]; +export const wasmed25519signer_sign: (a: number, b: number, c: number) => [number, number, number, number]; +export const wasmed25519signer_verify: (a: number, b: number, c: number, d: number, e: number) => [number, number]; +export const wasmkeyring_from_bytes: (a: number, b: number) => [number, number, number]; +export const wasmkeyring_public_key_bundle: (a: number) => number; +export const wasmkeyring_to_bytes: (a: number) => [number, number]; +export const wasmpublickeybundle_from_bytes: (a: number, b: number) => [number, number, number]; +export const wasmpublickeybundle_kem_public_key: (a: number) => [number, number]; +export const wasmpublickeybundle_sig_cl_public_key: (a: number) => [number, number]; +export const wasmpublickeybundle_sig_pq_public_key: (a: number) => [number, number]; +export const wasmpublickeybundle_to_bytes: (a: number) => [number, number]; +export const build_demo_message: (a: bigint, b: number, c: number, d: number, e: number) => [number, number, number, number]; +export const build_ping_frame: (a: bigint, b: number, c: number, d: bigint, e: number, f: number) => [number, number, number, number]; +export const build_request_frame: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number]; +export const format_frame: (a: number, b: number) => [number, number, number, number]; +export const parse_auth_response: (a: number, b: number) => [number, number, number]; +export const parse_response_frame: (a: number, b: number) => [number, number, number, number]; +export const main: () => void; +export const __wbg_connectionconfig_free: (a: number, b: number) => void; +export const __wbg_wasmclient_free: (a: number, b: number) => void; +export const connectionconfig_client_id: (a: number) => bigint; +export const connectionconfig_new: (a: number, b: number) => number; +export const connectionconfig_set_client_id: (a: number, b: bigint) => void; +export const connectionconfig_set_server_certificate_hashes: (a: number, b: number, c: number) => void; +export const connectionconfig_url: (a: number) => [number, number]; +export const wasmclient_auth_connect: (a: number, b: number, c: number, d: number, e: number, f: number, g: bigint) => any; +export const wasmclient_auth_register: (a: number, b: number, c: number, d: number, e: number, f: number) => any; +export const wasmclient_connect: (a: number, b: number) => any; +export const wasmclient_disconnect: (a: number) => void; +export const wasmclient_is_supported: () => number; +export const wasmclient_new: (a: any, b: any, c: any) => number; +export const wasmclient_send: (a: number, b: number, c: number) => any; +export const wasmclient_state: (a: number) => number; +export const wasm_bindgen__convert__closures_____invoke__h6588d25cdde23584: (a: number, b: number, c: any) => [number, number]; +export const wasm_bindgen__convert__closures_____invoke__h5c81efa430e34369: (a: number, b: number, c: any) => [number, number]; +export const wasm_bindgen__convert__closures_____invoke__h5c81efa430e34369_2: (a: number, b: number, c: any) => [number, number]; +export const wasm_bindgen__convert__closures_____invoke__h4bf2427f775cf424: (a: number, b: number, c: any, d: any) => void; +export const __wbindgen_malloc: (a: number, b: number) => number; +export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number; +export const __wbindgen_exn_store: (a: number) => void; +export const __externref_table_alloc: () => number; +export const __wbindgen_externrefs: WebAssembly.Table; +export const __wbindgen_free: (a: number, b: number, c: number) => void; +export const __wbindgen_destroy_closure: (a: number, b: number) => void; +export const __externref_table_dealloc: (a: number) => void; +export const __wbindgen_start: () => void; diff --git a/wasm/pkg/package.json b/wasm/pkg/package.json new file mode 100644 index 0000000..632853f --- /dev/null +++ b/wasm/pkg/package.json @@ -0,0 +1,15 @@ +{ + "name": "mtp-wasm", + "type": "module", + "version": "0.1.0", + "files": [ + "mtp_wasm_bg.wasm", + "mtp_wasm.js", + "mtp_wasm.d.ts" + ], + "main": "mtp_wasm.js", + "types": "mtp_wasm.d.ts", + "sideEffects": [ + "./snippets/*" + ] +}