diff --git a/Dockerfile b/Dockerfile index 44aa36d..e5f70e5 100755 --- a/Dockerfile +++ b/Dockerfile @@ -1,62 +1,11 @@ # syntax=docker/dockerfile:1.4 -FROM rust:1.82-alpine AS wasm-builder -WORKDIR /build - -# Installation des dépendances nécessaires pour la compilation -RUN apk update && apk add --no-cache \ - git \ - openssh-client \ - curl \ - nodejs \ - npm \ - build-base \ - pkgconfig \ - clang \ - llvm \ - musl-dev \ - nginx - -# Installer wasm-bindgen CLI (0.2.92) et target wasm32 (Rust >=1.81) -RUN cargo install wasm-bindgen-cli --version 0.2.103 --locked && \ - rustup target add wasm32-unknown-unknown -ENV PATH="/usr/local/cargo/bin:${PATH}" - -# Configuration SSH basique -RUN mkdir -p /root/.ssh && \ - ssh-keyscan git.4nkweb.com >> /root/.ssh/known_hosts - -# On se place dans le bon répertoire parent -WORKDIR /build -# Copie du projet ihm_client -COPY . ihm_client/ - -# Clonage du sdk_client au même niveau que ihm_client en utilisant la clé SSH montée -RUN --mount=type=ssh git clone -b dev ssh://git@git.4nkweb.com/4nk/sdk_client.git - -# Build du WebAssembly (cargo) + wasm-bindgen -WORKDIR /build/sdk_client -# Harmoniser wasm-bindgen crate avec le CLI -RUN cargo update -p wasm-bindgen --precise 0.2.103 && \ - cargo update -p wasm-bindgen-macro --precise 0.2.103 && \ - cargo update -p wasm-bindgen-backend --precise 0.2.103 && \ - cargo update -p wasm-bindgen-macro-support --precise 0.2.103 && \ - cargo update -p js-sys --precise 0.3.80 && \ - cargo update -p web-sys --precise 0.3.80 && \ - cargo build --target wasm32-unknown-unknown --profile dev && \ - wasm-bindgen target/wasm32-unknown-unknown/debug/sdk_client.wasm \ - --out-dir /build/ihm_client/pkg \ - --typescript \ - --target bundler \ - --debug - FROM node:20-alpine WORKDIR /app # Installation des dépendances nécessaires RUN apk update && apk add --no-cache git nginx -# Copie des fichiers du projet -COPY --from=wasm-builder /build/ihm_client/pkg ./pkg +# Copie du projet (incluant pkg pré-compilé) COPY . . # Installation des dépendances Node.js diff --git a/pkg/README.md b/pkg/README.md new file mode 100644 index 0000000..73ee464 --- /dev/null +++ b/pkg/README.md @@ -0,0 +1,34 @@ +## sdk_client — bibliothèque cliente Silent Payments (WASM) + +Ce dépôt fournit une bibliothèque cliente visant l’intégration WebAssembly pour gérer appareil, portefeuille, processus et échanges chiffrés associés aux Silent Payments. Cette documentation renvoie vers `docs/` pour les spécifications détaillées, sans exemples exécutables. + +## 📋 Table des Matières + +- [📚 Documentation](#-documentation) +- [🧪 Tests](#-tests) +- [🛠️ Développement](#️-développement) +- [🚨 Dépannage](#-dépannage) + +## 📚 Documentation + +- [Architecture](docs/ARCHITECTURE.md) +- [Référence API](docs/API.md) +- [Configuration](docs/CONFIGURATION.md) +- [Tests](docs/TESTING.md) + +## 🧪 Tests + +- Tests natifs: `cargo test` +- Tests WASM (Windows): utiliser le script PowerShell `scripts/run-wasm-tests.ps1` (prérequis LLVM/Clang, voir `docs/TESTING.md`). + +## 🛠️ Développement + +La surface de code est centrée sur `src/` (Rust) avec export WASM. Les invariants sont décrits dans `docs/ARCHITECTURE.md` et `docs/API.md`. + +## 🚨 Dépannage + +Consulter `docs/TESTING.md` (section WASM Windows) pour les variables d’environnement et le runner wasm-bindgen. + +--- + +Documentation de référence: voir `docs/` pour la table des matières. diff --git a/pkg/package.json b/pkg/package.json new file mode 100644 index 0000000..04d749a --- /dev/null +++ b/pkg/package.json @@ -0,0 +1,11 @@ +{ + "name": "sdk_client", + "version": "0.1.3", + "files": [ + "sdk_client_bg.wasm", + "sdk_client.js", + "sdk_client.d.ts" + ], + "main": "sdk_client.js", + "types": "sdk_client.d.ts" +} \ No newline at end of file diff --git a/pkg/sdk_client.d.ts b/pkg/sdk_client.d.ts new file mode 100644 index 0000000..ce6a913 --- /dev/null +++ b/pkg/sdk_client.d.ts @@ -0,0 +1,248 @@ +/* tslint:disable */ +/* eslint-disable */ +export function setup(): void; +export function get_address(): string; +export function get_member(): Member; +export function restore_device(device: any): void; +export function create_device_from_sp_wallet(sp_wallet: string): string; +export function create_new_device(birthday: number, network_str: string): string; +export function scan_blocks(tip_height: number, blindbit_url: string): Promise; +export function is_paired(): boolean; +export function pair_device(process_id: string, sp_addresses: string[]): void; +export function unpair_device(): void; +export function dump_wallet(): string; +export function reset_shared_secrets(): void; +export function set_shared_secrets(secrets: string): void; +export function get_pairing_process_id(): string; +export function dump_device(): Device; +export function dump_neutered_device(): Device; +export function reset_device(): void; +export function get_txid(transaction: string): string; +export function get_prevouts(transaction: string): string[]; +export function get_opreturn(transaction: string): string; +export function process_commit_new_state(process: Process, state_id: string, new_tip: string): Process; +export function parse_new_tx(new_tx_msg: string, block_height: number, members_list: OutPointMemberMap): ApiReturn; +export function parse_cipher(cipher_msg: string, members_list: OutPointMemberMap, processes: OutPointProcessMap): ApiReturn; +export function get_outputs(): any; +export function get_available_amount(): bigint; +/** + * We send a transaction that pays at least one output to each address + * The goal can be to establish a shared_secret to be used as an encryption key for further communication + * or if the recipient is a relay it can be the init transaction for a new process + */ +export function create_transaction(addresses: string[], fee_rate: number): ApiReturn; +export function sign_transaction(partial_tx: TsUnsignedTransaction): ApiReturn; +export function create_new_process(private_data: Pcd, roles: Roles, public_data: Pcd, relay_address: string, fee_rate: number, members_list: OutPointMemberMap): ApiReturn; +export function update_process(process: Process, new_attributes: Pcd, roles: Roles, new_public_data: Pcd, members_list: OutPointMemberMap): ApiReturn; +export function request_data(process_id: string, state_ids_str: string[], roles: any, members_list: OutPointMemberMap): ApiReturn; +export function create_update_message(process: Process, state_id: string, members_list: OutPointMemberMap): ApiReturn; +export function validate_state(process: Process, state_id: string, members_list: OutPointMemberMap): ApiReturn; +export function refuse_state(process: Process, state_id: string, members_list: OutPointMemberMap): ApiReturn; +export function evaluate_state(process: Process, state_id: string, members_list: OutPointMemberMap): ApiReturn; +export function create_response_prd(process: Process, state_id: string, members_list: OutPointMemberMap): ApiReturn; +export function create_faucet_msg(): string; +export function get_storages(process_outpoint: string): string[]; +export function is_child_role(parent_roles: string, child_roles: string): void; +export function decrypt_data(key: Uint8Array, data: Uint8Array): Uint8Array; +export function encode_binary(data: any): Pcd; +export function encode_json(json_data: any): Pcd; +export function decode_value(value: Uint8Array): any; +export function hash_value(value: any, commited_in: string, label: string): string; +/** + * Generate a merkle proof for a specific attribute in a process state. + * + * This function creates a merkle proof that proves the existence of a specific attribute + * in a given state of a process. The proof can be used to verify that the attribute + * was indeed part of the state without revealing the entire state. + * + * # Arguments + * * `process_state` - The process state object as a JavaScript value + * * `attribute_name` - The name of the attribute to generate a proof for + * + * # Returns + * A MerkleProofResult object containing: + * * `proof` - The merkle proof as a hex string + * * `root` - The merkle root (state_id) as a hex string + * * `attribute` - The attribute name that was proven + * * `attribute_index` - The index of the attribute in the merkle tree + * * `total_leaves_count` - The total number of leaves in the merkle tree + * + * # Errors + * * "Failed to deserialize process state" - If the process state cannot be deserialized from JsValue + * * "Attribute not found in state" - If the attribute doesn't exist in the state + */ +export function get_merkle_proof(process_state: any, attribute_name: string): MerkleProofResult; +/** + * Validate a merkle proof for a specific attribute. + * + * This function verifies that a merkle proof is valid and proves the existence + * of a specific attribute in a given state. It checks that the proof correctly + * leads to the claimed root when combined with the attribute hash. + * + * # Arguments + * * `proof_result` - a JsValue expected to contain a MerkleProofResult with the proof and metadata + * * `hash` - The hash of the attribute data as a hex string (the leaf value) + * + * # Returns + * A boolean indicating whether the proof is valid + * + * # Errors + * * "serde_wasm_bindgen deserialization error" - If the proof is not a valid MerkleProofResult + * * "Invalid proof format" - If the proof cannot be parsed + * * "Invalid hash format" - If the hash is not a valid 32-byte hex string + * * "Invalid root format" - If the root is not a valid 32-byte hex string + */ +export function validate_merkle_proof(proof_result: any, hash: string): boolean; +export type DiffStatus = "None" | "Rejected" | "Validated"; + +export interface UserDiff { + process_id: string; + state_id: string; + value_commitment: string; + field: string; + roles: Roles; + description: string | null; + notify_user: boolean; + need_validation: boolean; + validation_status: DiffStatus; +} + +export interface UpdatedProcess { + process_id: OutPoint; + current_process: Process; + diffs: UserDiff[]; + encrypted_data: Record; + validated_state: number[] | null; +} + +export interface ApiReturn { + secrets: SecretsStore | null; + updated_process: UpdatedProcess | null; + new_tx_to_send: NewTxMessage | null; + ciphers_to_send: string[]; + commit_to_send: CommitMessage | null; + push_to_storage: string[]; + partial_tx: TsUnsignedTransaction | null; +} + +export interface encryptWithNewKeyResult { + cipher: string; + key: string; +} + +export interface MerkleProofResult { + proof: string; + root: string; + attribute: string; + attribute_index: number; + total_leaves_count: number; +} + +export interface Device { + sp_wallet: SpWallet; + pairing_process_commitment: OutPoint | null; + paired_member: Member; +} + +export interface SecretsStore { + shared_secrets: Record; + unconfirmed_secrets: AnkSharedSecretHash[]; +} + +/** + * A process is basically a succession of states + * The latest state MUST be an empty state with only the commited_in field set at the last unspent outpoint + * Commiting this last empty state in a transaction is called obliterating a process, basically terminating it + */ +export interface Process { + states: ProcessState[]; +} + +export interface ProcessState { + commited_in: OutPoint; + pcd_commitment: Record; + state_id: string; + keys: Record; + validation_tokens: Proof[]; + public_data: Pcd; + roles: Record; +} + +export type Roles = Record; + +export interface RoleDefinition { + members: OutPoint[]; + validation_rules: ValidationRule[]; + storages: string[]; +} + +export interface ValidationRule { + quorum: number; + fields: string[]; + min_sig_member: number; +} + +export type PcdCommitments = Record; + +export type Pcd = Record; + +export interface Member { + sp_addresses: string[]; +} + +export type TsUnsignedTransaction = SilentPaymentUnsignedTransaction; + +export type OutPointProcessMap = Record; + +export type OutPointMemberMap = Record; + +export interface Prd { + prd_type: PrdType; + process_id: OutPoint; + sender: OutPoint | null; + keys: Record; + pcd_commitments: PcdCommitments; + validation_tokens: Proof[]; + roles: Roles; + public_data: Pcd; + payload: string; + proof: Proof | null; +} + +export type PrdType = "None" | "Connect" | "Message" | "Update" | "List" | "Response" | "Confirm" | "TxProposal" | "Request"; + +export interface HandshakeMessage { + sp_address: string; + peers_list: OutPointMemberMap; + processes_list: OutPointProcessMap; + chain_tip: number; +} + +export interface NewTxMessage { + transaction: string; + tweak_data: string | null; + error: AnkError | null; +} + +export interface FaucetMessage { + sp_address: string; + commitment: string; + error: AnkError | null; +} + +/** + * Message sent to the server to commit some state in a transaction + * Client must first send a commit message with empty validation_tokens + * Relay will ignore a commit message for an update he\'s not aware of that also bears validation_tokens + */ +export interface CommitMessage { + process_id: OutPoint; + pcd_commitment: PcdCommitments; + roles: Roles; + public_data: Pcd; + validation_tokens: Proof[]; + error: AnkError | null; +} + +export type AnkFlag = "NewTx" | "Faucet" | "Cipher" | "Commit" | "Handshake" | "Sync" | "Unknown"; + diff --git a/pkg/sdk_client.js b/pkg/sdk_client.js new file mode 100644 index 0000000..9c7d6df --- /dev/null +++ b/pkg/sdk_client.js @@ -0,0 +1,1672 @@ + +let imports = {}; +imports['__wbindgen_placeholder__'] = module.exports; +let wasm; +const { TextEncoder, TextDecoder } = require(`util`); + +let WASM_VECTOR_LEN = 0; + +let cachedUint8ArrayMemory0 = null; + +function getUint8ArrayMemory0() { + if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) { + cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer); + } + return cachedUint8ArrayMemory0; +} + +let cachedTextEncoder = new TextEncoder('utf-8'); + +const encodeString = (typeof cachedTextEncoder.encodeInto === 'function' + ? function (arg, view) { + return cachedTextEncoder.encodeInto(arg, view); +} + : function (arg, view) { + const buf = cachedTextEncoder.encode(arg); + view.set(buf); + return { + read: arg.length, + written: buf.length + }; +}); + +function passStringToWasm0(arg, malloc, realloc) { + + if (typeof(arg) !== 'string') throw new Error(`expected a string argument, found ${typeof(arg)}`); + + 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 = encodeString(arg, view); + if (ret.read !== arg.length) throw new Error('failed to pass whole string'); + offset += ret.written; + ptr = realloc(ptr, len, offset, 1) >>> 0; + } + + WASM_VECTOR_LEN = offset; + return ptr; +} + +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 logError(f, args) { + try { + return f.apply(this, args); + } catch (e) { + let error = (function () { + try { + return e instanceof Error ? `${e.message}\n\nStack:\n${e.stack}` : e.toString(); + } catch(_) { + return ""; + } + }()); + console.error("wasm-bindgen: imported JS function that was not marked as `catch` threw an error:", error); + throw e; + } +} + +let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }); + +cachedTextDecoder.decode(); + +function getStringFromWasm0(ptr, len) { + ptr = ptr >>> 0; + return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len)); +} + +function addToExternrefTable0(obj) { + const idx = wasm.__externref_table_alloc(); + wasm.__wbindgen_export_4.set(idx, obj); + return idx; +} + +function handleError(f, args) { + try { + return f.apply(this, args); + } catch (e) { + const idx = addToExternrefTable0(e); + wasm.__wbindgen_exn_store(idx); + } +} + +function _assertBoolean(n) { + if (typeof(n) !== 'boolean') { + throw new Error(`expected a boolean argument, found ${typeof(n)}`); + } +} + +function _assertNum(n) { + if (typeof(n) !== 'number') throw new Error(`expected a number argument, found ${typeof(n)}`); +} + +function isLikeNone(x) { + return x === undefined || x === null; +} + +function _assertBigInt(n) { + if (typeof(n) !== 'bigint') throw new Error(`expected a bigint argument, found ${typeof(n)}`); +} + +const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined') + ? { register: () => {}, unregister: () => {} } + : new FinalizationRegistry(state => { + wasm.__wbindgen_export_5.get(state.dtor)(state.a, state.b) +}); + +function makeMutClosure(arg0, arg1, dtor, f) { + const state = { a: arg0, b: arg1, cnt: 1, dtor }; + 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 { + if (--state.cnt === 0) { + wasm.__wbindgen_export_5.get(state.dtor)(a, state.b); + CLOSURE_DTORS.unregister(state); + } else { + state.a = a; + } + } + }; + real.original = state; + CLOSURE_DTORS.register(real, state, state); + return real; +} + +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; +} + +module.exports.setup = function() { + wasm.setup(); +}; + +function takeFromExternrefTable0(idx) { + const value = wasm.__wbindgen_export_4.get(idx); + wasm.__externref_table_dealloc(idx); + return value; +} +/** + * @returns {string} + */ +module.exports.get_address = function() { + let deferred2_0; + let deferred2_1; + try { + const ret = wasm.get_address(); + var ptr1 = ret[0]; + var len1 = ret[1]; + if (ret[3]) { + ptr1 = 0; len1 = 0; + throw takeFromExternrefTable0(ret[2]); + } + deferred2_0 = ptr1; + deferred2_1 = len1; + return getStringFromWasm0(ptr1, len1); + } finally { + wasm.__wbindgen_free(deferred2_0, deferred2_1, 1); + } +}; + +/** + * @returns {Member} + */ +module.exports.get_member = function() { + const ret = wasm.get_member(); + if (ret[2]) { + throw takeFromExternrefTable0(ret[1]); + } + return takeFromExternrefTable0(ret[0]); +}; + +/** + * @param {any} device + */ +module.exports.restore_device = function(device) { + const ret = wasm.restore_device(device); + if (ret[1]) { + throw takeFromExternrefTable0(ret[0]); + } +}; + +/** + * @param {string} sp_wallet + * @returns {string} + */ +module.exports.create_device_from_sp_wallet = function(sp_wallet) { + let deferred3_0; + let deferred3_1; + try { + const ptr0 = passStringToWasm0(sp_wallet, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.create_device_from_sp_wallet(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); + } +}; + +/** + * @param {number} birthday + * @param {string} network_str + * @returns {string} + */ +module.exports.create_new_device = function(birthday, network_str) { + let deferred3_0; + let deferred3_1; + try { + _assertNum(birthday); + const ptr0 = passStringToWasm0(network_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.create_new_device(birthday, 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); + } +}; + +/** + * @param {number} tip_height + * @param {string} blindbit_url + * @returns {Promise} + */ +module.exports.scan_blocks = function(tip_height, blindbit_url) { + _assertNum(tip_height); + const ptr0 = passStringToWasm0(blindbit_url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.scan_blocks(tip_height, ptr0, len0); + return ret; +}; + +/** + * @returns {boolean} + */ +module.exports.is_paired = function() { + const ret = wasm.is_paired(); + if (ret[2]) { + throw takeFromExternrefTable0(ret[1]); + } + return ret[0] !== 0; +}; + +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; +} +/** + * @param {string} process_id + * @param {string[]} sp_addresses + */ +module.exports.pair_device = function(process_id, sp_addresses) { + const ptr0 = passStringToWasm0(process_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passArrayJsValueToWasm0(sp_addresses, wasm.__wbindgen_malloc); + const len1 = WASM_VECTOR_LEN; + const ret = wasm.pair_device(ptr0, len0, ptr1, len1); + if (ret[1]) { + throw takeFromExternrefTable0(ret[0]); + } +}; + +module.exports.unpair_device = function() { + const ret = wasm.unpair_device(); + if (ret[1]) { + throw takeFromExternrefTable0(ret[0]); + } +}; + +/** + * @returns {string} + */ +module.exports.dump_wallet = function() { + let deferred2_0; + let deferred2_1; + try { + const ret = wasm.dump_wallet(); + var ptr1 = ret[0]; + var len1 = ret[1]; + if (ret[3]) { + ptr1 = 0; len1 = 0; + throw takeFromExternrefTable0(ret[2]); + } + deferred2_0 = ptr1; + deferred2_1 = len1; + return getStringFromWasm0(ptr1, len1); + } finally { + wasm.__wbindgen_free(deferred2_0, deferred2_1, 1); + } +}; + +module.exports.reset_shared_secrets = function() { + const ret = wasm.reset_shared_secrets(); + if (ret[1]) { + throw takeFromExternrefTable0(ret[0]); + } +}; + +/** + * @param {string} secrets + */ +module.exports.set_shared_secrets = function(secrets) { + const ptr0 = passStringToWasm0(secrets, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.set_shared_secrets(ptr0, len0); + if (ret[1]) { + throw takeFromExternrefTable0(ret[0]); + } +}; + +/** + * @returns {string} + */ +module.exports.get_pairing_process_id = function() { + let deferred2_0; + let deferred2_1; + try { + const ret = wasm.get_pairing_process_id(); + var ptr1 = ret[0]; + var len1 = ret[1]; + if (ret[3]) { + ptr1 = 0; len1 = 0; + throw takeFromExternrefTable0(ret[2]); + } + deferred2_0 = ptr1; + deferred2_1 = len1; + return getStringFromWasm0(ptr1, len1); + } finally { + wasm.__wbindgen_free(deferred2_0, deferred2_1, 1); + } +}; + +/** + * @returns {Device} + */ +module.exports.dump_device = function() { + const ret = wasm.dump_device(); + if (ret[2]) { + throw takeFromExternrefTable0(ret[1]); + } + return takeFromExternrefTable0(ret[0]); +}; + +/** + * @returns {Device} + */ +module.exports.dump_neutered_device = function() { + const ret = wasm.dump_neutered_device(); + if (ret[2]) { + throw takeFromExternrefTable0(ret[1]); + } + return takeFromExternrefTable0(ret[0]); +}; + +module.exports.reset_device = function() { + const ret = wasm.reset_device(); + if (ret[1]) { + throw takeFromExternrefTable0(ret[0]); + } +}; + +/** + * @param {string} transaction + * @returns {string} + */ +module.exports.get_txid = function(transaction) { + let deferred3_0; + let deferred3_1; + try { + const ptr0 = passStringToWasm0(transaction, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.get_txid(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); + } +}; + +function getArrayJsValueFromWasm0(ptr, len) { + ptr = ptr >>> 0; + const mem = getDataViewMemory0(); + const result = []; + for (let i = ptr; i < ptr + 4 * len; i += 4) { + result.push(wasm.__wbindgen_export_4.get(mem.getUint32(i, true))); + } + wasm.__externref_drop_slice(ptr, len); + return result; +} +/** + * @param {string} transaction + * @returns {string[]} + */ +module.exports.get_prevouts = function(transaction) { + const ptr0 = passStringToWasm0(transaction, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.get_prevouts(ptr0, len0); + if (ret[3]) { + throw takeFromExternrefTable0(ret[2]); + } + var v2 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice(); + wasm.__wbindgen_free(ret[0], ret[1] * 4, 4); + return v2; +}; + +/** + * @param {string} transaction + * @returns {string} + */ +module.exports.get_opreturn = function(transaction) { + let deferred3_0; + let deferred3_1; + try { + const ptr0 = passStringToWasm0(transaction, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.get_opreturn(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); + } +}; + +/** + * @param {Process} process + * @param {string} state_id + * @param {string} new_tip + * @returns {Process} + */ +module.exports.process_commit_new_state = function(process, state_id, new_tip) { + const ptr0 = passStringToWasm0(state_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passStringToWasm0(new_tip, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + const ret = wasm.process_commit_new_state(process, ptr0, len0, ptr1, len1); + if (ret[2]) { + throw takeFromExternrefTable0(ret[1]); + } + return takeFromExternrefTable0(ret[0]); +}; + +/** + * @param {string} new_tx_msg + * @param {number} block_height + * @param {OutPointMemberMap} members_list + * @returns {ApiReturn} + */ +module.exports.parse_new_tx = function(new_tx_msg, block_height, members_list) { + const ptr0 = passStringToWasm0(new_tx_msg, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + _assertNum(block_height); + const ret = wasm.parse_new_tx(ptr0, len0, block_height, members_list); + if (ret[2]) { + throw takeFromExternrefTable0(ret[1]); + } + return takeFromExternrefTable0(ret[0]); +}; + +/** + * @param {string} cipher_msg + * @param {OutPointMemberMap} members_list + * @param {OutPointProcessMap} processes + * @returns {ApiReturn} + */ +module.exports.parse_cipher = function(cipher_msg, members_list, processes) { + const ptr0 = passStringToWasm0(cipher_msg, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.parse_cipher(ptr0, len0, members_list, processes); + if (ret[2]) { + throw takeFromExternrefTable0(ret[1]); + } + return takeFromExternrefTable0(ret[0]); +}; + +/** + * @returns {any} + */ +module.exports.get_outputs = function() { + const ret = wasm.get_outputs(); + if (ret[2]) { + throw takeFromExternrefTable0(ret[1]); + } + return takeFromExternrefTable0(ret[0]); +}; + +/** + * @returns {bigint} + */ +module.exports.get_available_amount = function() { + const ret = wasm.get_available_amount(); + if (ret[2]) { + throw takeFromExternrefTable0(ret[1]); + } + return BigInt.asUintN(64, ret[0]); +}; + +/** + * We send a transaction that pays at least one output to each address + * The goal can be to establish a shared_secret to be used as an encryption key for further communication + * or if the recipient is a relay it can be the init transaction for a new process + * @param {string[]} addresses + * @param {number} fee_rate + * @returns {ApiReturn} + */ +module.exports.create_transaction = function(addresses, fee_rate) { + const ptr0 = passArrayJsValueToWasm0(addresses, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + _assertNum(fee_rate); + const ret = wasm.create_transaction(ptr0, len0, fee_rate); + if (ret[2]) { + throw takeFromExternrefTable0(ret[1]); + } + return takeFromExternrefTable0(ret[0]); +}; + +/** + * @param {TsUnsignedTransaction} partial_tx + * @returns {ApiReturn} + */ +module.exports.sign_transaction = function(partial_tx) { + const ret = wasm.sign_transaction(partial_tx); + if (ret[2]) { + throw takeFromExternrefTable0(ret[1]); + } + return takeFromExternrefTable0(ret[0]); +}; + +/** + * @param {Pcd} private_data + * @param {Roles} roles + * @param {Pcd} public_data + * @param {string} relay_address + * @param {number} fee_rate + * @param {OutPointMemberMap} members_list + * @returns {ApiReturn} + */ +module.exports.create_new_process = function(private_data, roles, public_data, relay_address, fee_rate, members_list) { + const ptr0 = passStringToWasm0(relay_address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + _assertNum(fee_rate); + const ret = wasm.create_new_process(private_data, roles, public_data, ptr0, len0, fee_rate, members_list); + if (ret[2]) { + throw takeFromExternrefTable0(ret[1]); + } + return takeFromExternrefTable0(ret[0]); +}; + +/** + * @param {Process} process + * @param {Pcd} new_attributes + * @param {Roles} roles + * @param {Pcd} new_public_data + * @param {OutPointMemberMap} members_list + * @returns {ApiReturn} + */ +module.exports.update_process = function(process, new_attributes, roles, new_public_data, members_list) { + const ret = wasm.update_process(process, new_attributes, roles, new_public_data, members_list); + if (ret[2]) { + throw takeFromExternrefTable0(ret[1]); + } + return takeFromExternrefTable0(ret[0]); +}; + +/** + * @param {string} process_id + * @param {string[]} state_ids_str + * @param {any} roles + * @param {OutPointMemberMap} members_list + * @returns {ApiReturn} + */ +module.exports.request_data = function(process_id, state_ids_str, roles, members_list) { + const ptr0 = passStringToWasm0(process_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passArrayJsValueToWasm0(state_ids_str, wasm.__wbindgen_malloc); + const len1 = WASM_VECTOR_LEN; + const ret = wasm.request_data(ptr0, len0, ptr1, len1, roles, members_list); + if (ret[2]) { + throw takeFromExternrefTable0(ret[1]); + } + return takeFromExternrefTable0(ret[0]); +}; + +/** + * @param {Process} process + * @param {string} state_id + * @param {OutPointMemberMap} members_list + * @returns {ApiReturn} + */ +module.exports.create_update_message = function(process, state_id, members_list) { + const ptr0 = passStringToWasm0(state_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.create_update_message(process, ptr0, len0, members_list); + if (ret[2]) { + throw takeFromExternrefTable0(ret[1]); + } + return takeFromExternrefTable0(ret[0]); +}; + +/** + * @param {Process} process + * @param {string} state_id + * @param {OutPointMemberMap} members_list + * @returns {ApiReturn} + */ +module.exports.validate_state = function(process, state_id, members_list) { + const ptr0 = passStringToWasm0(state_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.validate_state(process, ptr0, len0, members_list); + if (ret[2]) { + throw takeFromExternrefTable0(ret[1]); + } + return takeFromExternrefTable0(ret[0]); +}; + +/** + * @param {Process} process + * @param {string} state_id + * @param {OutPointMemberMap} members_list + * @returns {ApiReturn} + */ +module.exports.refuse_state = function(process, state_id, members_list) { + const ptr0 = passStringToWasm0(state_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.refuse_state(process, ptr0, len0, members_list); + if (ret[2]) { + throw takeFromExternrefTable0(ret[1]); + } + return takeFromExternrefTable0(ret[0]); +}; + +/** + * @param {Process} process + * @param {string} state_id + * @param {OutPointMemberMap} members_list + * @returns {ApiReturn} + */ +module.exports.evaluate_state = function(process, state_id, members_list) { + const ptr0 = passStringToWasm0(state_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.evaluate_state(process, ptr0, len0, members_list); + if (ret[2]) { + throw takeFromExternrefTable0(ret[1]); + } + return takeFromExternrefTable0(ret[0]); +}; + +/** + * @param {Process} process + * @param {string} state_id + * @param {OutPointMemberMap} members_list + * @returns {ApiReturn} + */ +module.exports.create_response_prd = function(process, state_id, members_list) { + const ptr0 = passStringToWasm0(state_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.create_response_prd(process, ptr0, len0, members_list); + if (ret[2]) { + throw takeFromExternrefTable0(ret[1]); + } + return takeFromExternrefTable0(ret[0]); +}; + +/** + * @returns {string} + */ +module.exports.create_faucet_msg = function() { + let deferred2_0; + let deferred2_1; + try { + const ret = wasm.create_faucet_msg(); + var ptr1 = ret[0]; + var len1 = ret[1]; + if (ret[3]) { + ptr1 = 0; len1 = 0; + throw takeFromExternrefTable0(ret[2]); + } + deferred2_0 = ptr1; + deferred2_1 = len1; + return getStringFromWasm0(ptr1, len1); + } finally { + wasm.__wbindgen_free(deferred2_0, deferred2_1, 1); + } +}; + +/** + * @param {string} process_outpoint + * @returns {string[]} + */ +module.exports.get_storages = function(process_outpoint) { + const ptr0 = passStringToWasm0(process_outpoint, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.get_storages(ptr0, len0); + if (ret[3]) { + throw takeFromExternrefTable0(ret[2]); + } + var v2 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice(); + wasm.__wbindgen_free(ret[0], ret[1] * 4, 4); + return v2; +}; + +/** + * @param {string} parent_roles + * @param {string} child_roles + */ +module.exports.is_child_role = function(parent_roles, child_roles) { + const ptr0 = passStringToWasm0(parent_roles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passStringToWasm0(child_roles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + const ret = wasm.is_child_role(ptr0, len0, ptr1, len1); + if (ret[1]) { + throw takeFromExternrefTable0(ret[0]); + } +}; + +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 getArrayU8FromWasm0(ptr, len) { + ptr = ptr >>> 0; + return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len); +} +/** + * @param {Uint8Array} key + * @param {Uint8Array} data + * @returns {Uint8Array} + */ +module.exports.decrypt_data = function(key, data) { + const ptr0 = passArray8ToWasm0(key, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passArray8ToWasm0(data, wasm.__wbindgen_malloc); + const len1 = WASM_VECTOR_LEN; + const ret = wasm.decrypt_data(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; +}; + +/** + * @param {any} data + * @returns {Pcd} + */ +module.exports.encode_binary = function(data) { + const ret = wasm.encode_binary(data); + if (ret[2]) { + throw takeFromExternrefTable0(ret[1]); + } + return takeFromExternrefTable0(ret[0]); +}; + +/** + * @param {any} json_data + * @returns {Pcd} + */ +module.exports.encode_json = function(json_data) { + const ret = wasm.encode_json(json_data); + if (ret[2]) { + throw takeFromExternrefTable0(ret[1]); + } + return takeFromExternrefTable0(ret[0]); +}; + +/** + * @param {Uint8Array} value + * @returns {any} + */ +module.exports.decode_value = function(value) { + const ptr0 = passArray8ToWasm0(value, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.decode_value(ptr0, len0); + if (ret[2]) { + throw takeFromExternrefTable0(ret[1]); + } + return takeFromExternrefTable0(ret[0]); +}; + +/** + * @param {any} value + * @param {string} commited_in + * @param {string} label + * @returns {string} + */ +module.exports.hash_value = function(value, commited_in, label) { + let deferred4_0; + let deferred4_1; + try { + const ptr0 = passStringToWasm0(commited_in, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passStringToWasm0(label, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + const ret = wasm.hash_value(value, ptr0, len0, ptr1, len1); + var ptr3 = ret[0]; + var len3 = ret[1]; + if (ret[3]) { + ptr3 = 0; len3 = 0; + throw takeFromExternrefTable0(ret[2]); + } + deferred4_0 = ptr3; + deferred4_1 = len3; + return getStringFromWasm0(ptr3, len3); + } finally { + wasm.__wbindgen_free(deferred4_0, deferred4_1, 1); + } +}; + +/** + * Generate a merkle proof for a specific attribute in a process state. + * + * This function creates a merkle proof that proves the existence of a specific attribute + * in a given state of a process. The proof can be used to verify that the attribute + * was indeed part of the state without revealing the entire state. + * + * # Arguments + * * `process_state` - The process state object as a JavaScript value + * * `attribute_name` - The name of the attribute to generate a proof for + * + * # Returns + * A MerkleProofResult object containing: + * * `proof` - The merkle proof as a hex string + * * `root` - The merkle root (state_id) as a hex string + * * `attribute` - The attribute name that was proven + * * `attribute_index` - The index of the attribute in the merkle tree + * * `total_leaves_count` - The total number of leaves in the merkle tree + * + * # Errors + * * "Failed to deserialize process state" - If the process state cannot be deserialized from JsValue + * * "Attribute not found in state" - If the attribute doesn't exist in the state + * @param {any} process_state + * @param {string} attribute_name + * @returns {MerkleProofResult} + */ +module.exports.get_merkle_proof = function(process_state, attribute_name) { + const ptr0 = passStringToWasm0(attribute_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.get_merkle_proof(process_state, ptr0, len0); + if (ret[2]) { + throw takeFromExternrefTable0(ret[1]); + } + return takeFromExternrefTable0(ret[0]); +}; + +/** + * Validate a merkle proof for a specific attribute. + * + * This function verifies that a merkle proof is valid and proves the existence + * of a specific attribute in a given state. It checks that the proof correctly + * leads to the claimed root when combined with the attribute hash. + * + * # Arguments + * * `proof_result` - a JsValue expected to contain a MerkleProofResult with the proof and metadata + * * `hash` - The hash of the attribute data as a hex string (the leaf value) + * + * # Returns + * A boolean indicating whether the proof is valid + * + * # Errors + * * "serde_wasm_bindgen deserialization error" - If the proof is not a valid MerkleProofResult + * * "Invalid proof format" - If the proof cannot be parsed + * * "Invalid hash format" - If the hash is not a valid 32-byte hex string + * * "Invalid root format" - If the root is not a valid 32-byte hex string + * @param {any} proof_result + * @param {string} hash + * @returns {boolean} + */ +module.exports.validate_merkle_proof = function(proof_result, hash) { + const ptr0 = passStringToWasm0(hash, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.validate_merkle_proof(proof_result, ptr0, len0); + if (ret[2]) { + throw takeFromExternrefTable0(ret[1]); + } + return ret[0] !== 0; +}; + +function __wbg_adapter_52(arg0, arg1) { + _assertNum(arg0); + _assertNum(arg1); + wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h0dcb1618ebc342c1(arg0, arg1); +} + +function __wbg_adapter_55(arg0, arg1, arg2) { + _assertNum(arg0); + _assertNum(arg1); + wasm.closure667_externref_shim(arg0, arg1, arg2); +} + +function __wbg_adapter_227(arg0, arg1, arg2, arg3) { + _assertNum(arg0); + _assertNum(arg1); + wasm.closure1273_externref_shim(arg0, arg1, arg2, arg3); +} + +const __wbindgen_enum_RequestCredentials = ["omit", "same-origin", "include"]; + +const __wbindgen_enum_RequestMode = ["same-origin", "no-cors", "cors", "navigate"]; + +module.exports.__wbg_String_8f0eb39a4a4c2f66 = function() { return logError(function (arg0, arg1) { + const ret = String(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); +}, arguments) }; + +module.exports.__wbg_abort_410ec47a64ac6117 = function() { return logError(function (arg0, arg1) { + arg0.abort(arg1); +}, arguments) }; + +module.exports.__wbg_abort_775ef1d17fc65868 = function() { return logError(function (arg0) { + arg0.abort(); +}, arguments) }; + +module.exports.__wbg_append_8c7dd8d641a5f01b = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) { + arg0.append(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4)); +}, arguments) }; + +module.exports.__wbg_buffer_609cc3eee51ed158 = function() { return logError(function (arg0) { + const ret = arg0.buffer; + return ret; +}, arguments) }; + +module.exports.__wbg_call_672a4d21634d4a24 = function() { return handleError(function (arg0, arg1) { + const ret = arg0.call(arg1); + return ret; +}, arguments) }; + +module.exports.__wbg_call_7cccdd69e0791ae2 = function() { return handleError(function (arg0, arg1, arg2) { + const ret = arg0.call(arg1, arg2); + return ret; +}, arguments) }; + +module.exports.__wbg_clearTimeout_b1115618e821c3b2 = function() { return logError(function (arg0) { + const ret = clearTimeout(arg0); + return ret; +}, arguments) }; + +module.exports.__wbg_crypto_ed58b8e10a292839 = function() { return logError(function (arg0) { + const ret = arg0.crypto; + return ret; +}, arguments) }; + +module.exports.__wbg_debug_e17b51583ca6a632 = function() { return logError(function (arg0, arg1, arg2, arg3) { + console.debug(arg0, arg1, arg2, arg3); +}, arguments) }; + +module.exports.__wbg_done_769e5ede4b31c67b = function() { return logError(function (arg0) { + const ret = arg0.done; + _assertBoolean(ret); + return ret; +}, arguments) }; + +module.exports.__wbg_entries_3265d4158b33e5dc = function() { return logError(function (arg0) { + const ret = Object.entries(arg0); + return ret; +}, arguments) }; + +module.exports.__wbg_error_524f506f44df1645 = function() { return logError(function (arg0) { + console.error(arg0); +}, arguments) }; + +module.exports.__wbg_error_80de38b3f7cc3c3c = function() { return logError(function (arg0, arg1, arg2, arg3) { + console.error(arg0, arg1, arg2, arg3); +}, arguments) }; + +module.exports.__wbg_fetch_3afbdcc7ddbf16fe = function() { return logError(function (arg0) { + const ret = fetch(arg0); + return ret; +}, arguments) }; + +module.exports.__wbg_fetch_509096533071c657 = function() { return logError(function (arg0, arg1) { + const ret = arg0.fetch(arg1); + return ret; +}, arguments) }; + +module.exports.__wbg_getRandomValues_bcb4912f16000dc4 = function() { return handleError(function (arg0, arg1) { + arg0.getRandomValues(arg1); +}, arguments) }; + +module.exports.__wbg_get_67b2ba62fc30de12 = function() { return handleError(function (arg0, arg1) { + const ret = Reflect.get(arg0, arg1); + return ret; +}, arguments) }; + +module.exports.__wbg_get_b9b93047fe3cf45b = function() { return logError(function (arg0, arg1) { + const ret = arg0[arg1 >>> 0]; + return ret; +}, arguments) }; + +module.exports.__wbg_getwithrefkey_1dc361bd10053bfe = function() { return logError(function (arg0, arg1) { + const ret = arg0[arg1]; + return ret; +}, arguments) }; + +module.exports.__wbg_has_a5ea9117f258a0ec = function() { return handleError(function (arg0, arg1) { + const ret = Reflect.has(arg0, arg1); + _assertBoolean(ret); + return ret; +}, arguments) }; + +module.exports.__wbg_headers_9cb51cfd2ac780a4 = function() { return logError(function (arg0) { + const ret = arg0.headers; + return ret; +}, arguments) }; + +module.exports.__wbg_info_033d8b8a0838f1d3 = function() { return logError(function (arg0, arg1, arg2, arg3) { + console.info(arg0, arg1, arg2, arg3); +}, arguments) }; + +module.exports.__wbg_instanceof_ArrayBuffer_e14585432e3737fc = function() { return logError(function (arg0) { + let result; + try { + result = arg0 instanceof ArrayBuffer; + } catch (_) { + result = false; + } + const ret = result; + _assertBoolean(ret); + return ret; +}, arguments) }; + +module.exports.__wbg_instanceof_Map_f3469ce2244d2430 = function() { return logError(function (arg0) { + let result; + try { + result = arg0 instanceof Map; + } catch (_) { + result = false; + } + const ret = result; + _assertBoolean(ret); + return ret; +}, arguments) }; + +module.exports.__wbg_instanceof_Response_f2cc20d9f7dfd644 = function() { return logError(function (arg0) { + let result; + try { + result = arg0 instanceof Response; + } catch (_) { + result = false; + } + const ret = result; + _assertBoolean(ret); + return ret; +}, arguments) }; + +module.exports.__wbg_instanceof_Uint8Array_17156bcf118086a9 = function() { return logError(function (arg0) { + let result; + try { + result = arg0 instanceof Uint8Array; + } catch (_) { + result = false; + } + const ret = result; + _assertBoolean(ret); + return ret; +}, arguments) }; + +module.exports.__wbg_isArray_a1eab7e0d067391b = function() { return logError(function (arg0) { + const ret = Array.isArray(arg0); + _assertBoolean(ret); + return ret; +}, arguments) }; + +module.exports.__wbg_isSafeInteger_343e2beeeece1bb0 = function() { return logError(function (arg0) { + const ret = Number.isSafeInteger(arg0); + _assertBoolean(ret); + return ret; +}, arguments) }; + +module.exports.__wbg_iterator_9a24c88df860dc65 = function() { return logError(function () { + const ret = Symbol.iterator; + return ret; +}, arguments) }; + +module.exports.__wbg_length_a446193dc22c12f8 = function() { return logError(function (arg0) { + const ret = arg0.length; + _assertNum(ret); + return ret; +}, arguments) }; + +module.exports.__wbg_length_e2d2a49132c1b256 = function() { return logError(function (arg0) { + const ret = arg0.length; + _assertNum(ret); + return ret; +}, arguments) }; + +module.exports.__wbg_log_cad59bb680daec67 = function() { return logError(function (arg0, arg1, arg2, arg3) { + console.log(arg0, arg1, arg2, arg3); +}, arguments) }; + +module.exports.__wbg_msCrypto_0a36e2ec3a343d26 = function() { return logError(function (arg0) { + const ret = arg0.msCrypto; + return ret; +}, arguments) }; + +module.exports.__wbg_new_018dcc2d6c8c2f6a = function() { return handleError(function () { + const ret = new Headers(); + return ret; +}, arguments) }; + +module.exports.__wbg_new_23a2665fac83c611 = function() { return logError(function (arg0, arg1) { + try { + var state0 = {a: arg0, b: arg1}; + var cb0 = (arg0, arg1) => { + const a = state0.a; + state0.a = 0; + try { + return __wbg_adapter_227(a, state0.b, arg0, arg1); + } finally { + state0.a = a; + } + }; + const ret = new Promise(cb0); + return ret; + } finally { + state0.a = state0.b = 0; + } +}, arguments) }; + +module.exports.__wbg_new_405e22f390576ce2 = function() { return logError(function () { + const ret = new Object(); + return ret; +}, arguments) }; + +module.exports.__wbg_new_5e0be73521bc8c17 = function() { return logError(function () { + const ret = new Map(); + return ret; +}, arguments) }; + +module.exports.__wbg_new_78feb108b6472713 = function() { return logError(function () { + const ret = new Array(); + return ret; +}, arguments) }; + +module.exports.__wbg_new_a12002a7f91c75be = function() { return logError(function (arg0) { + const ret = new Uint8Array(arg0); + return ret; +}, arguments) }; + +module.exports.__wbg_new_e25e5aab09ff45db = function() { return handleError(function () { + const ret = new AbortController(); + return ret; +}, arguments) }; + +module.exports.__wbg_newnoargs_105ed471475aaf50 = function() { return logError(function (arg0, arg1) { + const ret = new Function(getStringFromWasm0(arg0, arg1)); + return ret; +}, arguments) }; + +module.exports.__wbg_newwithbyteoffsetandlength_d97e637ebe145a9a = function() { return logError(function (arg0, arg1, arg2) { + const ret = new Uint8Array(arg0, arg1 >>> 0, arg2 >>> 0); + return ret; +}, arguments) }; + +module.exports.__wbg_newwithlength_a381634e90c276d4 = function() { return logError(function (arg0) { + const ret = new Uint8Array(arg0 >>> 0); + return ret; +}, arguments) }; + +module.exports.__wbg_newwithstrandinit_06c535e0a867c635 = function() { return handleError(function (arg0, arg1, arg2) { + const ret = new Request(getStringFromWasm0(arg0, arg1), arg2); + return ret; +}, arguments) }; + +module.exports.__wbg_next_25feadfc0913fea9 = function() { return logError(function (arg0) { + const ret = arg0.next; + return ret; +}, arguments) }; + +module.exports.__wbg_next_6574e1a8a62d1055 = function() { return handleError(function (arg0) { + const ret = arg0.next(); + return ret; +}, arguments) }; + +module.exports.__wbg_node_02999533c4ea02e3 = function() { return logError(function (arg0) { + const ret = arg0.node; + return ret; +}, arguments) }; + +module.exports.__wbg_now_2c95c9de01293173 = function() { return logError(function (arg0) { + const ret = arg0.now(); + return ret; +}, arguments) }; + +module.exports.__wbg_parse_def2e24ef1252aff = function() { return handleError(function (arg0, arg1) { + const ret = JSON.parse(getStringFromWasm0(arg0, arg1)); + return ret; +}, arguments) }; + +module.exports.__wbg_performance_7a3ffd0b17f663ad = function() { return logError(function (arg0) { + const ret = arg0.performance; + return ret; +}, arguments) }; + +module.exports.__wbg_process_5c1d670bc53614b8 = function() { return logError(function (arg0) { + const ret = arg0.process; + return ret; +}, arguments) }; + +module.exports.__wbg_queueMicrotask_97d92b4fcc8a61c5 = function() { return logError(function (arg0) { + queueMicrotask(arg0); +}, arguments) }; + +module.exports.__wbg_queueMicrotask_d3219def82552485 = function() { return logError(function (arg0) { + const ret = arg0.queueMicrotask; + return ret; +}, arguments) }; + +module.exports.__wbg_randomFillSync_ab2cfe79ebbf2740 = function() { return handleError(function (arg0, arg1) { + arg0.randomFillSync(arg1); +}, arguments) }; + +module.exports.__wbg_require_79b1e9274cde3c87 = function() { return handleError(function () { + const ret = module.require; + return ret; +}, arguments) }; + +module.exports.__wbg_resolve_4851785c9c5f573d = function() { return logError(function (arg0) { + const ret = Promise.resolve(arg0); + return ret; +}, arguments) }; + +module.exports.__wbg_setTimeout_ca12ead8b48245e2 = function() { return logError(function (arg0, arg1) { + const ret = setTimeout(arg0, arg1); + return ret; +}, arguments) }; + +module.exports.__wbg_set_37837023f3d740e8 = function() { return logError(function (arg0, arg1, arg2) { + arg0[arg1 >>> 0] = arg2; +}, arguments) }; + +module.exports.__wbg_set_3f1d0b984ed272ed = function() { return logError(function (arg0, arg1, arg2) { + arg0[arg1] = arg2; +}, arguments) }; + +module.exports.__wbg_set_65595bdd868b3009 = function() { return logError(function (arg0, arg1, arg2) { + arg0.set(arg1, arg2 >>> 0); +}, arguments) }; + +module.exports.__wbg_set_8fc6bf8a5b1071d1 = function() { return logError(function (arg0, arg1, arg2) { + const ret = arg0.set(arg1, arg2); + return ret; +}, arguments) }; + +module.exports.__wbg_set_bb8cecf6a62b9f46 = function() { return handleError(function (arg0, arg1, arg2) { + const ret = Reflect.set(arg0, arg1, arg2); + _assertBoolean(ret); + return ret; +}, arguments) }; + +module.exports.__wbg_setbody_5923b78a95eedf29 = function() { return logError(function (arg0, arg1) { + arg0.body = arg1; +}, arguments) }; + +module.exports.__wbg_setcredentials_c3a22f1cd105a2c6 = function() { return logError(function (arg0, arg1) { + arg0.credentials = __wbindgen_enum_RequestCredentials[arg1]; +}, arguments) }; + +module.exports.__wbg_setheaders_834c0bdb6a8949ad = function() { return logError(function (arg0, arg1) { + arg0.headers = arg1; +}, arguments) }; + +module.exports.__wbg_setmethod_3c5280fe5d890842 = function() { return logError(function (arg0, arg1, arg2) { + arg0.method = getStringFromWasm0(arg1, arg2); +}, arguments) }; + +module.exports.__wbg_setmode_5dc300b865044b65 = function() { return logError(function (arg0, arg1) { + arg0.mode = __wbindgen_enum_RequestMode[arg1]; +}, arguments) }; + +module.exports.__wbg_setsignal_75b21ef3a81de905 = function() { return logError(function (arg0, arg1) { + arg0.signal = arg1; +}, arguments) }; + +module.exports.__wbg_signal_aaf9ad74119f20a4 = function() { return logError(function (arg0) { + const ret = arg0.signal; + return ret; +}, arguments) }; + +module.exports.__wbg_static_accessor_GLOBAL_88a902d13a557d07 = function() { return logError(function () { + const ret = typeof global === 'undefined' ? null : global; + return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); +}, arguments) }; + +module.exports.__wbg_static_accessor_GLOBAL_THIS_56578be7e9f832b0 = function() { return logError(function () { + const ret = typeof globalThis === 'undefined' ? null : globalThis; + return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); +}, arguments) }; + +module.exports.__wbg_static_accessor_SELF_37c5d418e4bf5819 = function() { return logError(function () { + const ret = typeof self === 'undefined' ? null : self; + return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); +}, arguments) }; + +module.exports.__wbg_static_accessor_WINDOW_5de37043a91a9c40 = function() { return logError(function () { + const ret = typeof window === 'undefined' ? null : window; + return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); +}, arguments) }; + +module.exports.__wbg_status_f6360336ca686bf0 = function() { return logError(function (arg0) { + const ret = arg0.status; + _assertNum(ret); + return ret; +}, arguments) }; + +module.exports.__wbg_stringify_f7ed6987935b4a24 = function() { return handleError(function (arg0) { + const ret = JSON.stringify(arg0); + return ret; +}, arguments) }; + +module.exports.__wbg_subarray_aa9065fa9dc5df96 = function() { return logError(function (arg0, arg1, arg2) { + const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0); + return ret; +}, arguments) }; + +module.exports.__wbg_text_7805bea50de2af49 = function() { return handleError(function (arg0) { + const ret = arg0.text(); + return ret; +}, arguments) }; + +module.exports.__wbg_then_44b73946d2fb3e7d = function() { return logError(function (arg0, arg1) { + const ret = arg0.then(arg1); + return ret; +}, arguments) }; + +module.exports.__wbg_then_48b406749878a531 = function() { return logError(function (arg0, arg1, arg2) { + const ret = arg0.then(arg1, arg2); + return ret; +}, arguments) }; + +module.exports.__wbg_url_ae10c34ca209681d = function() { return logError(function (arg0, arg1) { + const ret = arg1.url; + 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); +}, arguments) }; + +module.exports.__wbg_value_cd1ffa7b1ab794f1 = function() { return logError(function (arg0) { + const ret = arg0.value; + return ret; +}, arguments) }; + +module.exports.__wbg_versions_c71aa1626a93e0a1 = function() { return logError(function (arg0) { + const ret = arg0.versions; + return ret; +}, arguments) }; + +module.exports.__wbg_warn_aaf1f4664a035bd6 = function() { return logError(function (arg0, arg1, arg2, arg3) { + console.warn(arg0, arg1, arg2, arg3); +}, arguments) }; + +module.exports.__wbindgen_as_number = function(arg0) { + const ret = +arg0; + return ret; +}; + +module.exports.__wbindgen_bigint_from_i64 = function(arg0) { + const ret = arg0; + return ret; +}; + +module.exports.__wbindgen_bigint_from_u64 = function(arg0) { + const ret = BigInt.asUintN(64, arg0); + return ret; +}; + +module.exports.__wbindgen_bigint_get_as_i64 = function(arg0, arg1) { + const v = arg1; + const ret = typeof(v) === 'bigint' ? v : undefined; + if (!isLikeNone(ret)) { + _assertBigInt(ret); + } + getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true); + getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true); +}; + +module.exports.__wbindgen_boolean_get = function(arg0) { + const v = arg0; + const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2; + _assertNum(ret); + return ret; +}; + +module.exports.__wbindgen_cb_drop = function(arg0) { + const obj = arg0.original; + if (obj.cnt-- == 1) { + obj.a = 0; + return true; + } + const ret = false; + _assertBoolean(ret); + return ret; +}; + +module.exports.__wbindgen_closure_wrapper11341 = function() { return logError(function (arg0, arg1, arg2) { + const ret = makeMutClosure(arg0, arg1, 647, __wbg_adapter_52); + return ret; +}, arguments) }; + +module.exports.__wbindgen_closure_wrapper11582 = function() { return logError(function (arg0, arg1, arg2) { + const ret = makeMutClosure(arg0, arg1, 668, __wbg_adapter_55); + return ret; +}, arguments) }; + +module.exports.__wbindgen_debug_string = 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); +}; + +module.exports.__wbindgen_error_new = function(arg0, arg1) { + const ret = new Error(getStringFromWasm0(arg0, arg1)); + return ret; +}; + +module.exports.__wbindgen_in = function(arg0, arg1) { + const ret = arg0 in arg1; + _assertBoolean(ret); + return ret; +}; + +module.exports.__wbindgen_init_externref_table = function() { + const table = wasm.__wbindgen_export_4; + 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); + ; +}; + +module.exports.__wbindgen_is_bigint = function(arg0) { + const ret = typeof(arg0) === 'bigint'; + _assertBoolean(ret); + return ret; +}; + +module.exports.__wbindgen_is_function = function(arg0) { + const ret = typeof(arg0) === 'function'; + _assertBoolean(ret); + return ret; +}; + +module.exports.__wbindgen_is_object = function(arg0) { + const val = arg0; + const ret = typeof(val) === 'object' && val !== null; + _assertBoolean(ret); + return ret; +}; + +module.exports.__wbindgen_is_string = function(arg0) { + const ret = typeof(arg0) === 'string'; + _assertBoolean(ret); + return ret; +}; + +module.exports.__wbindgen_is_undefined = function(arg0) { + const ret = arg0 === undefined; + _assertBoolean(ret); + return ret; +}; + +module.exports.__wbindgen_jsval_eq = function(arg0, arg1) { + const ret = arg0 === arg1; + _assertBoolean(ret); + return ret; +}; + +module.exports.__wbindgen_jsval_loose_eq = function(arg0, arg1) { + const ret = arg0 == arg1; + _assertBoolean(ret); + return ret; +}; + +module.exports.__wbindgen_memory = function() { + const ret = wasm.memory; + return ret; +}; + +module.exports.__wbindgen_number_get = function(arg0, arg1) { + const obj = arg1; + const ret = typeof(obj) === 'number' ? obj : undefined; + if (!isLikeNone(ret)) { + _assertNum(ret); + } + getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true); + getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true); +}; + +module.exports.__wbindgen_number_new = function(arg0) { + const ret = arg0; + return ret; +}; + +module.exports.__wbindgen_string_get = 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); +}; + +module.exports.__wbindgen_string_new = function(arg0, arg1) { + const ret = getStringFromWasm0(arg0, arg1); + return ret; +}; + +module.exports.__wbindgen_throw = function(arg0, arg1) { + throw new Error(getStringFromWasm0(arg0, arg1)); +}; + +const path = require('path').join(__dirname, 'sdk_client_bg.wasm'); +const bytes = require('fs').readFileSync(path); + +const wasmModule = new WebAssembly.Module(bytes); +const wasmInstance = new WebAssembly.Instance(wasmModule, imports); +wasm = wasmInstance.exports; +module.exports.__wasm = wasm; + +wasm.__wbindgen_start(); + diff --git a/pkg/sdk_client_bg.wasm b/pkg/sdk_client_bg.wasm new file mode 100644 index 0000000..288c36e Binary files /dev/null and b/pkg/sdk_client_bg.wasm differ