1399 lines
47 KiB
JavaScript
1399 lines
47 KiB
JavaScript
let wasm;
|
|
|
|
function addToExternrefTable0(obj) {
|
|
const idx = wasm.__externref_table_alloc();
|
|
wasm.__wbindgen_export_2.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);
|
|
}
|
|
}
|
|
|
|
const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
|
|
|
|
if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
|
|
|
|
let cachedUint8ArrayMemory0 = null;
|
|
|
|
function getUint8ArrayMemory0() {
|
|
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
}
|
|
return cachedUint8ArrayMemory0;
|
|
}
|
|
|
|
function getStringFromWasm0(ptr, len) {
|
|
ptr = ptr >>> 0;
|
|
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
}
|
|
|
|
function isLikeNone(x) {
|
|
return x === undefined || x === null;
|
|
}
|
|
|
|
function getArrayU8FromWasm0(ptr, len) {
|
|
ptr = ptr >>> 0;
|
|
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
}
|
|
|
|
let WASM_VECTOR_LEN = 0;
|
|
|
|
const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
|
|
|
|
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 (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);
|
|
|
|
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;
|
|
}
|
|
|
|
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;
|
|
}
|
|
/**
|
|
* Create and unlock a new keyspace with the given name and password
|
|
* @param {string} keyspace
|
|
* @param {string} password
|
|
* @returns {Promise<void>}
|
|
*/
|
|
export function create_keyspace(keyspace, password) {
|
|
const ptr0 = passStringToWasm0(keyspace, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
const len0 = WASM_VECTOR_LEN;
|
|
const ptr1 = passStringToWasm0(password, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
const len1 = WASM_VECTOR_LEN;
|
|
const ret = wasm.create_keyspace(ptr0, len0, ptr1, len1);
|
|
return ret;
|
|
}
|
|
|
|
/**
|
|
* Initialize session with keyspace and password
|
|
* @param {string} keyspace
|
|
* @param {string} password
|
|
* @returns {Promise<void>}
|
|
*/
|
|
export function init_session(keyspace, password) {
|
|
const ptr0 = passStringToWasm0(keyspace, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
const len0 = WASM_VECTOR_LEN;
|
|
const ptr1 = passStringToWasm0(password, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
const len1 = WASM_VECTOR_LEN;
|
|
const ret = wasm.init_session(ptr0, len0, ptr1, len1);
|
|
return ret;
|
|
}
|
|
|
|
/**
|
|
* Lock the session (zeroize password and session)
|
|
*/
|
|
export function lock_session() {
|
|
wasm.lock_session();
|
|
}
|
|
|
|
function takeFromExternrefTable0(idx) {
|
|
const value = wasm.__wbindgen_export_2.get(idx);
|
|
wasm.__externref_table_dealloc(idx);
|
|
return value;
|
|
}
|
|
/**
|
|
* Get metadata of the currently selected keypair
|
|
* @returns {any}
|
|
*/
|
|
export function current_keypair_metadata() {
|
|
const ret = wasm.current_keypair_metadata();
|
|
if (ret[2]) {
|
|
throw takeFromExternrefTable0(ret[1]);
|
|
}
|
|
return takeFromExternrefTable0(ret[0]);
|
|
}
|
|
|
|
/**
|
|
* Get public key of the currently selected keypair as Uint8Array
|
|
* @returns {any}
|
|
*/
|
|
export function current_keypair_public_key() {
|
|
const ret = wasm.current_keypair_public_key();
|
|
if (ret[2]) {
|
|
throw takeFromExternrefTable0(ret[1]);
|
|
}
|
|
return takeFromExternrefTable0(ret[0]);
|
|
}
|
|
|
|
/**
|
|
* Returns true if a keyspace is currently unlocked
|
|
* @returns {boolean}
|
|
*/
|
|
export function is_unlocked() {
|
|
const ret = wasm.is_unlocked();
|
|
return ret !== 0;
|
|
}
|
|
|
|
/**
|
|
* Get the default public key for a workspace (keyspace)
|
|
* This returns the public key of the first keypair in the keyspace
|
|
* @param {string} workspace_id
|
|
* @returns {Promise<any>}
|
|
*/
|
|
export function get_workspace_default_public_key(workspace_id) {
|
|
const ptr0 = passStringToWasm0(workspace_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
const len0 = WASM_VECTOR_LEN;
|
|
const ret = wasm.get_workspace_default_public_key(ptr0, len0);
|
|
return ret;
|
|
}
|
|
|
|
/**
|
|
* Get the current unlocked public key as hex string
|
|
* @returns {string}
|
|
*/
|
|
export function get_current_unlocked_public_key() {
|
|
let deferred2_0;
|
|
let deferred2_1;
|
|
try {
|
|
const ret = wasm.get_current_unlocked_public_key();
|
|
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);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Get all keypairs from the current session
|
|
* Returns an array of keypair objects with id, type, and metadata
|
|
* Select keypair for the session
|
|
* @param {string} key_id
|
|
*/
|
|
export function select_keypair(key_id) {
|
|
const ptr0 = passStringToWasm0(key_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
const len0 = WASM_VECTOR_LEN;
|
|
const ret = wasm.select_keypair(ptr0, len0);
|
|
if (ret[1]) {
|
|
throw takeFromExternrefTable0(ret[0]);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* List keypairs in the current session's keyspace
|
|
* @returns {Promise<any>}
|
|
*/
|
|
export function list_keypairs() {
|
|
const ret = wasm.list_keypairs();
|
|
return ret;
|
|
}
|
|
|
|
/**
|
|
* Add a keypair to the current keyspace
|
|
* @param {string | null} [key_type]
|
|
* @param {string | null} [metadata]
|
|
* @returns {Promise<any>}
|
|
*/
|
|
export function add_keypair(key_type, metadata) {
|
|
var ptr0 = isLikeNone(key_type) ? 0 : passStringToWasm0(key_type, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
var len0 = WASM_VECTOR_LEN;
|
|
var ptr1 = isLikeNone(metadata) ? 0 : passStringToWasm0(metadata, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
var len1 = WASM_VECTOR_LEN;
|
|
const ret = wasm.add_keypair(ptr0, len0, ptr1, len1);
|
|
return ret;
|
|
}
|
|
|
|
function passArray8ToWasm0(arg, malloc) {
|
|
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
WASM_VECTOR_LEN = arg.length;
|
|
return ptr;
|
|
}
|
|
/**
|
|
* Sign message with current session (requires selected keypair)
|
|
* @param {Uint8Array} message
|
|
* @returns {Promise<any>}
|
|
*/
|
|
export function sign(message) {
|
|
const ptr0 = passArray8ToWasm0(message, wasm.__wbindgen_malloc);
|
|
const len0 = WASM_VECTOR_LEN;
|
|
const ret = wasm.sign(ptr0, len0);
|
|
return ret;
|
|
}
|
|
|
|
/**
|
|
* Get the current keyspace name
|
|
* @returns {string}
|
|
*/
|
|
export function get_current_keyspace_name() {
|
|
let deferred2_0;
|
|
let deferred2_1;
|
|
try {
|
|
const ret = wasm.get_current_keyspace_name();
|
|
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);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Sign message with default keypair (first keypair in keyspace) without changing session state
|
|
* @param {Uint8Array} message
|
|
* @returns {Promise<any>}
|
|
*/
|
|
export function sign_with_default_keypair(message) {
|
|
const ptr0 = passArray8ToWasm0(message, wasm.__wbindgen_malloc);
|
|
const len0 = WASM_VECTOR_LEN;
|
|
const ret = wasm.sign_with_default_keypair(ptr0, len0);
|
|
return ret;
|
|
}
|
|
|
|
/**
|
|
* Verify a signature with the current session's selected keypair
|
|
* @param {Uint8Array} message
|
|
* @param {string} signature
|
|
* @returns {Promise<any>}
|
|
*/
|
|
export function verify(message, signature) {
|
|
const ptr0 = passArray8ToWasm0(message, wasm.__wbindgen_malloc);
|
|
const len0 = WASM_VECTOR_LEN;
|
|
const ptr1 = passStringToWasm0(signature, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
const len1 = WASM_VECTOR_LEN;
|
|
const ret = wasm.verify(ptr0, len0, ptr1, len1);
|
|
return ret;
|
|
}
|
|
|
|
/**
|
|
* Encrypt data using the current session's keyspace symmetric cipher
|
|
* @param {Uint8Array} data
|
|
* @returns {Promise<any>}
|
|
*/
|
|
export function encrypt_data(data) {
|
|
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
const len0 = WASM_VECTOR_LEN;
|
|
const ret = wasm.encrypt_data(ptr0, len0);
|
|
return ret;
|
|
}
|
|
|
|
/**
|
|
* Decrypt data using the current session's keyspace symmetric cipher
|
|
* @param {Uint8Array} encrypted
|
|
* @returns {Promise<any>}
|
|
*/
|
|
export function decrypt_data(encrypted) {
|
|
const ptr0 = passArray8ToWasm0(encrypted, wasm.__wbindgen_malloc);
|
|
const len0 = WASM_VECTOR_LEN;
|
|
const ret = wasm.decrypt_data(ptr0, len0);
|
|
return ret;
|
|
}
|
|
|
|
/**
|
|
* Initialize the scripting environment (must be called before run_rhai)
|
|
*/
|
|
export function init_rhai_env() {
|
|
wasm.init_rhai_env();
|
|
}
|
|
|
|
/**
|
|
* Securely run a Rhai script in the extension context (must be called only after user approval)
|
|
* @param {string} script
|
|
* @returns {any}
|
|
*/
|
|
export function run_rhai(script) {
|
|
const ptr0 = passStringToWasm0(script, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
const len0 = WASM_VECTOR_LEN;
|
|
const ret = wasm.run_rhai(ptr0, len0);
|
|
if (ret[2]) {
|
|
throw takeFromExternrefTable0(ret[1]);
|
|
}
|
|
return takeFromExternrefTable0(ret[0]);
|
|
}
|
|
|
|
function __wbg_adapter_34(arg0, arg1, arg2) {
|
|
wasm.closure174_externref_shim(arg0, arg1, arg2);
|
|
}
|
|
|
|
function __wbg_adapter_39(arg0, arg1) {
|
|
wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__ha4436a3f79fb1a0f(arg0, arg1);
|
|
}
|
|
|
|
function __wbg_adapter_44(arg0, arg1, arg2) {
|
|
wasm.closure237_externref_shim(arg0, arg1, arg2);
|
|
}
|
|
|
|
function __wbg_adapter_49(arg0, arg1) {
|
|
wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hf148c54a4a246cea(arg0, arg1);
|
|
}
|
|
|
|
function __wbg_adapter_52(arg0, arg1, arg2) {
|
|
wasm.closure308_externref_shim(arg0, arg1, arg2);
|
|
}
|
|
|
|
function __wbg_adapter_55(arg0, arg1, arg2) {
|
|
wasm.closure392_externref_shim(arg0, arg1, arg2);
|
|
}
|
|
|
|
function __wbg_adapter_207(arg0, arg1, arg2, arg3) {
|
|
wasm.closure2046_externref_shim(arg0, arg1, arg2, arg3);
|
|
}
|
|
|
|
const __wbindgen_enum_BinaryType = ["blob", "arraybuffer"];
|
|
|
|
const __wbindgen_enum_IdbTransactionMode = ["readonly", "readwrite", "versionchange", "readwriteflush", "cleanup"];
|
|
|
|
const SigSocketConnectionFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
? { register: () => {}, unregister: () => {} }
|
|
: new FinalizationRegistry(ptr => wasm.__wbg_sigsocketconnection_free(ptr >>> 0, 1));
|
|
/**
|
|
* WASM-bindgen wrapper for SigSocket client
|
|
*
|
|
* This provides a clean JavaScript API for the browser extension to:
|
|
* - Connect to SigSocket servers
|
|
* - Send responses to sign requests
|
|
* - Manage connection state
|
|
*/
|
|
export class SigSocketConnection {
|
|
|
|
__destroy_into_raw() {
|
|
const ptr = this.__wbg_ptr;
|
|
this.__wbg_ptr = 0;
|
|
SigSocketConnectionFinalization.unregister(this);
|
|
return ptr;
|
|
}
|
|
|
|
free() {
|
|
const ptr = this.__destroy_into_raw();
|
|
wasm.__wbg_sigsocketconnection_free(ptr, 0);
|
|
}
|
|
/**
|
|
* Create a new SigSocket connection
|
|
*/
|
|
constructor() {
|
|
const ret = wasm.sigsocketconnection_new();
|
|
this.__wbg_ptr = ret >>> 0;
|
|
SigSocketConnectionFinalization.register(this, this.__wbg_ptr, this);
|
|
return this;
|
|
}
|
|
/**
|
|
* Connect to a SigSocket server
|
|
*
|
|
* # Arguments
|
|
* * `server_url` - WebSocket server URL (e.g., "ws://localhost:8080/ws")
|
|
* * `public_key_hex` - Client's public key as hex string
|
|
*
|
|
* # Returns
|
|
* * `Ok(())` - Successfully connected
|
|
* * `Err(error)` - Connection failed
|
|
* @param {string} server_url
|
|
* @param {string} public_key_hex
|
|
* @returns {Promise<void>}
|
|
*/
|
|
connect(server_url, public_key_hex) {
|
|
const ptr0 = passStringToWasm0(server_url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
const len0 = WASM_VECTOR_LEN;
|
|
const ptr1 = passStringToWasm0(public_key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
const len1 = WASM_VECTOR_LEN;
|
|
const ret = wasm.sigsocketconnection_connect(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
return ret;
|
|
}
|
|
/**
|
|
* Send a response to a sign request
|
|
*
|
|
* This should be called by the extension after the user has approved
|
|
* a sign request and the message has been signed.
|
|
*
|
|
* # Arguments
|
|
* * `request_id` - ID of the original request
|
|
* * `message_base64` - Original message (base64-encoded)
|
|
* * `signature_hex` - Signature as hex string
|
|
*
|
|
* # Returns
|
|
* * `Ok(())` - Response sent successfully
|
|
* * `Err(error)` - Failed to send response
|
|
* @param {string} request_id
|
|
* @param {string} message_base64
|
|
* @param {string} signature_hex
|
|
* @returns {Promise<void>}
|
|
*/
|
|
send_response(request_id, message_base64, signature_hex) {
|
|
const ptr0 = passStringToWasm0(request_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
const len0 = WASM_VECTOR_LEN;
|
|
const ptr1 = passStringToWasm0(message_base64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
const len1 = WASM_VECTOR_LEN;
|
|
const ptr2 = passStringToWasm0(signature_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
const len2 = WASM_VECTOR_LEN;
|
|
const ret = wasm.sigsocketconnection_send_response(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
return ret;
|
|
}
|
|
/**
|
|
* Send a rejection for a sign request
|
|
*
|
|
* This should be called when the user rejects a sign request.
|
|
*
|
|
* # Arguments
|
|
* * `request_id` - ID of the request to reject
|
|
* * `reason` - Reason for rejection (optional)
|
|
*
|
|
* # Returns
|
|
* * `Ok(())` - Rejection sent successfully
|
|
* * `Err(error)` - Failed to send rejection
|
|
* @param {string} request_id
|
|
* @param {string} reason
|
|
* @returns {Promise<void>}
|
|
*/
|
|
send_rejection(request_id, reason) {
|
|
const ptr0 = passStringToWasm0(request_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
const len0 = WASM_VECTOR_LEN;
|
|
const ptr1 = passStringToWasm0(reason, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
const len1 = WASM_VECTOR_LEN;
|
|
const ret = wasm.sigsocketconnection_send_rejection(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
return ret;
|
|
}
|
|
/**
|
|
* Disconnect from the SigSocket server
|
|
*/
|
|
disconnect() {
|
|
wasm.sigsocketconnection_disconnect(this.__wbg_ptr);
|
|
}
|
|
/**
|
|
* Check if connected to the server
|
|
* @returns {boolean}
|
|
*/
|
|
is_connected() {
|
|
const ret = wasm.sigsocketconnection_is_connected(this.__wbg_ptr);
|
|
return ret !== 0;
|
|
}
|
|
}
|
|
|
|
const SigSocketManagerFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
? { register: () => {}, unregister: () => {} }
|
|
: new FinalizationRegistry(ptr => wasm.__wbg_sigsocketmanager_free(ptr >>> 0, 1));
|
|
/**
|
|
* SigSocket manager for high-level operations
|
|
*/
|
|
export class SigSocketManager {
|
|
|
|
__destroy_into_raw() {
|
|
const ptr = this.__wbg_ptr;
|
|
this.__wbg_ptr = 0;
|
|
SigSocketManagerFinalization.unregister(this);
|
|
return ptr;
|
|
}
|
|
|
|
free() {
|
|
const ptr = this.__destroy_into_raw();
|
|
wasm.__wbg_sigsocketmanager_free(ptr, 0);
|
|
}
|
|
/**
|
|
* Connect to SigSocket server with smart connection management
|
|
*
|
|
* This handles all connection logic:
|
|
* - Reuses existing connection if same workspace
|
|
* - Switches connection if different workspace
|
|
* - Creates new connection if none exists
|
|
*
|
|
* # Arguments
|
|
* * `workspace` - The workspace name to connect with
|
|
* * `server_url` - The SigSocket server URL (e.g., "ws://localhost:8080/ws")
|
|
* * `event_callback` - JavaScript function to call when events occur
|
|
*
|
|
* # Returns
|
|
* * `Ok(connection_info)` - JSON string with connection details
|
|
* * `Err(error)` - If connection failed or workspace is invalid
|
|
* @param {string} workspace
|
|
* @param {string} server_url
|
|
* @param {Function} event_callback
|
|
* @returns {Promise<string>}
|
|
*/
|
|
static connect_workspace_with_events(workspace, server_url, event_callback) {
|
|
const ptr0 = passStringToWasm0(workspace, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
const len0 = WASM_VECTOR_LEN;
|
|
const ptr1 = passStringToWasm0(server_url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
const len1 = WASM_VECTOR_LEN;
|
|
const ret = wasm.sigsocketmanager_connect_workspace_with_events(ptr0, len0, ptr1, len1, event_callback);
|
|
return ret;
|
|
}
|
|
/**
|
|
* Connect to SigSocket server with a specific workspace (backward compatibility)
|
|
*
|
|
* This is a simpler version that doesn't set up event callbacks.
|
|
* Use connect_workspace_with_events for full functionality.
|
|
*
|
|
* # Arguments
|
|
* * `workspace` - The workspace name to connect with
|
|
* * `server_url` - The SigSocket server URL (e.g., "ws://localhost:8080/ws")
|
|
*
|
|
* # Returns
|
|
* * `Ok(connection_info)` - JSON string with connection details
|
|
* * `Err(error)` - If connection failed or workspace is invalid
|
|
* @param {string} workspace
|
|
* @param {string} server_url
|
|
* @returns {Promise<string>}
|
|
*/
|
|
static connect_workspace(workspace, server_url) {
|
|
const ptr0 = passStringToWasm0(workspace, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
const len0 = WASM_VECTOR_LEN;
|
|
const ptr1 = passStringToWasm0(server_url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
const len1 = WASM_VECTOR_LEN;
|
|
const ret = wasm.sigsocketmanager_connect_workspace(ptr0, len0, ptr1, len1);
|
|
return ret;
|
|
}
|
|
/**
|
|
* Disconnect from SigSocket server
|
|
*
|
|
* # Returns
|
|
* * `Ok(())` - Successfully disconnected
|
|
* * `Err(error)` - If disconnect failed
|
|
* @returns {Promise<void>}
|
|
*/
|
|
static disconnect() {
|
|
const ret = wasm.sigsocketmanager_disconnect();
|
|
return ret;
|
|
}
|
|
/**
|
|
* Check if we can approve a specific sign request
|
|
*
|
|
* This validates that:
|
|
* 1. The request exists
|
|
* 2. The vault session is unlocked
|
|
* 3. The current workspace matches the request's target
|
|
*
|
|
* # Arguments
|
|
* * `request_id` - The ID of the request to validate
|
|
*
|
|
* # Returns
|
|
* * `Ok(true)` - Request can be approved
|
|
* * `Ok(false)` - Request cannot be approved
|
|
* * `Err(error)` - Validation error
|
|
* @param {string} request_id
|
|
* @returns {Promise<boolean>}
|
|
*/
|
|
static can_approve_request(request_id) {
|
|
const ptr0 = passStringToWasm0(request_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
const len0 = WASM_VECTOR_LEN;
|
|
const ret = wasm.sigsocketmanager_can_approve_request(ptr0, len0);
|
|
return ret;
|
|
}
|
|
/**
|
|
* Approve a sign request and send the signature to the server
|
|
*
|
|
* This performs the complete approval flow:
|
|
* 1. Validates the request can be approved
|
|
* 2. Signs the message using the vault
|
|
* 3. Sends the signature to the SigSocket server
|
|
* 4. Removes the request from pending list
|
|
*
|
|
* # Arguments
|
|
* * `request_id` - The ID of the request to approve
|
|
*
|
|
* # Returns
|
|
* * `Ok(signature)` - Base64-encoded signature that was sent
|
|
* * `Err(error)` - If approval failed
|
|
* @param {string} request_id
|
|
* @returns {Promise<string>}
|
|
*/
|
|
static approve_request(request_id) {
|
|
const ptr0 = passStringToWasm0(request_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
const len0 = WASM_VECTOR_LEN;
|
|
const ret = wasm.sigsocketmanager_approve_request(ptr0, len0);
|
|
return ret;
|
|
}
|
|
/**
|
|
* Reject a sign request
|
|
*
|
|
* # Arguments
|
|
* * `request_id` - The ID of the request to reject
|
|
* * `reason` - The reason for rejection
|
|
*
|
|
* # Returns
|
|
* * `Ok(())` - Request rejected successfully
|
|
* * `Err(error)` - If rejection failed
|
|
* @param {string} request_id
|
|
* @param {string} reason
|
|
* @returns {Promise<void>}
|
|
*/
|
|
static reject_request(request_id, reason) {
|
|
const ptr0 = passStringToWasm0(request_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
const len0 = WASM_VECTOR_LEN;
|
|
const ptr1 = passStringToWasm0(reason, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
const len1 = WASM_VECTOR_LEN;
|
|
const ret = wasm.sigsocketmanager_reject_request(ptr0, len0, ptr1, len1);
|
|
return ret;
|
|
}
|
|
/**
|
|
* Get pending requests filtered by current workspace
|
|
*
|
|
* This returns only the requests that the current vault session can handle,
|
|
* based on the unlocked workspace and its public key.
|
|
*
|
|
* # Returns
|
|
* * `Ok(requests_json)` - JSON array of filtered requests
|
|
* * `Err(error)` - If filtering failed
|
|
* @returns {Promise<string>}
|
|
*/
|
|
static get_filtered_requests() {
|
|
const ret = wasm.sigsocketmanager_get_filtered_requests();
|
|
return ret;
|
|
}
|
|
/**
|
|
* Add a pending sign request (called when request arrives from server)
|
|
*
|
|
* # Arguments
|
|
* * `request_json` - JSON string containing the sign request
|
|
*
|
|
* # Returns
|
|
* * `Ok(())` - Request added successfully
|
|
* * `Err(error)` - If adding failed
|
|
* @param {string} request_json
|
|
*/
|
|
static add_pending_request(request_json) {
|
|
const ptr0 = passStringToWasm0(request_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
const len0 = WASM_VECTOR_LEN;
|
|
const ret = wasm.sigsocketmanager_add_pending_request(ptr0, len0);
|
|
if (ret[1]) {
|
|
throw takeFromExternrefTable0(ret[0]);
|
|
}
|
|
}
|
|
/**
|
|
* Get connection status
|
|
*
|
|
* # Returns
|
|
* * `Ok(status_json)` - JSON object with connection status
|
|
* * `Err(error)` - If getting status failed
|
|
* @returns {string}
|
|
*/
|
|
static get_connection_status() {
|
|
let deferred2_0;
|
|
let deferred2_1;
|
|
try {
|
|
const ret = wasm.sigsocketmanager_get_connection_status();
|
|
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);
|
|
}
|
|
}
|
|
/**
|
|
* Clear all pending requests
|
|
*
|
|
* # Returns
|
|
* * `Ok(())` - Requests cleared successfully
|
|
*/
|
|
static clear_pending_requests() {
|
|
const ret = wasm.sigsocketmanager_clear_pending_requests();
|
|
if (ret[1]) {
|
|
throw takeFromExternrefTable0(ret[0]);
|
|
}
|
|
}
|
|
}
|
|
|
|
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) {
|
|
if (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 __wbg_get_imports() {
|
|
const imports = {};
|
|
imports.wbg = {};
|
|
imports.wbg.__wbg_buffer_609cc3eee51ed158 = function(arg0) {
|
|
const ret = arg0.buffer;
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg_call_672a4d21634d4a24 = function() { return handleError(function (arg0, arg1) {
|
|
const ret = arg0.call(arg1);
|
|
return ret;
|
|
}, arguments) };
|
|
imports.wbg.__wbg_call_7cccdd69e0791ae2 = function() { return handleError(function (arg0, arg1, arg2) {
|
|
const ret = arg0.call(arg1, arg2);
|
|
return ret;
|
|
}, arguments) };
|
|
imports.wbg.__wbg_close_2893b7d056a0627d = function() { return handleError(function (arg0) {
|
|
arg0.close();
|
|
}, arguments) };
|
|
imports.wbg.__wbg_createObjectStore_d2f9e1016f4d81b9 = function() { return handleError(function (arg0, arg1, arg2, arg3) {
|
|
const ret = arg0.createObjectStore(getStringFromWasm0(arg1, arg2), arg3);
|
|
return ret;
|
|
}, arguments) };
|
|
imports.wbg.__wbg_crypto_574e78ad8b13b65f = function(arg0) {
|
|
const ret = arg0.crypto;
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg_data_432d9c3df2630942 = function(arg0) {
|
|
const ret = arg0.data;
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg_error_524f506f44df1645 = function(arg0) {
|
|
console.error(arg0);
|
|
};
|
|
imports.wbg.__wbg_error_ff4ddaabdfc5dbb3 = function() { return handleError(function (arg0) {
|
|
const ret = arg0.error;
|
|
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
}, arguments) };
|
|
imports.wbg.__wbg_getRandomValues_3c9c0d586e575a16 = function() { return handleError(function (arg0, arg1) {
|
|
globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
|
|
}, arguments) };
|
|
imports.wbg.__wbg_getRandomValues_b8f5dbd5f3995a9e = function() { return handleError(function (arg0, arg1) {
|
|
arg0.getRandomValues(arg1);
|
|
}, arguments) };
|
|
imports.wbg.__wbg_getTime_46267b1c24877e30 = function(arg0) {
|
|
const ret = arg0.getTime();
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg_get_4f73335ab78445db = function(arg0, arg1, arg2) {
|
|
const ret = arg1[arg2 >>> 0];
|
|
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);
|
|
};
|
|
imports.wbg.__wbg_get_67b2ba62fc30de12 = function() { return handleError(function (arg0, arg1) {
|
|
const ret = Reflect.get(arg0, arg1);
|
|
return ret;
|
|
}, arguments) };
|
|
imports.wbg.__wbg_get_8da03f81f6a1111e = function() { return handleError(function (arg0, arg1) {
|
|
const ret = arg0.get(arg1);
|
|
return ret;
|
|
}, arguments) };
|
|
imports.wbg.__wbg_instanceof_IdbDatabase_a3ef009ca00059f9 = function(arg0) {
|
|
let result;
|
|
try {
|
|
result = arg0 instanceof IDBDatabase;
|
|
} catch (_) {
|
|
result = false;
|
|
}
|
|
const ret = result;
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg_instanceof_IdbFactory_12eaba3366f4302f = function(arg0) {
|
|
let result;
|
|
try {
|
|
result = arg0 instanceof IDBFactory;
|
|
} catch (_) {
|
|
result = false;
|
|
}
|
|
const ret = result;
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg_instanceof_IdbOpenDbRequest_a3416e156c9db893 = function(arg0) {
|
|
let result;
|
|
try {
|
|
result = arg0 instanceof IDBOpenDBRequest;
|
|
} catch (_) {
|
|
result = false;
|
|
}
|
|
const ret = result;
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg_instanceof_IdbRequest_4813c3f207666aa4 = function(arg0) {
|
|
let result;
|
|
try {
|
|
result = arg0 instanceof IDBRequest;
|
|
} catch (_) {
|
|
result = false;
|
|
}
|
|
const ret = result;
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg_instanceof_Window_def73ea0955fc569 = function(arg0) {
|
|
let result;
|
|
try {
|
|
result = arg0 instanceof Window;
|
|
} catch (_) {
|
|
result = false;
|
|
}
|
|
const ret = result;
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg_length_52b6c4580c5ec934 = function(arg0) {
|
|
const ret = arg0.length;
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg_log_c222819a41e063d3 = function(arg0) {
|
|
console.log(arg0);
|
|
};
|
|
imports.wbg.__wbg_msCrypto_a61aeb35a24c1329 = function(arg0) {
|
|
const ret = arg0.msCrypto;
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg_new0_f788a2397c7ca929 = function() {
|
|
const ret = new Date();
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg_new_23a2665fac83c611 = 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_207(a, state0.b, arg0, arg1);
|
|
} finally {
|
|
state0.a = a;
|
|
}
|
|
};
|
|
const ret = new Promise(cb0);
|
|
return ret;
|
|
} finally {
|
|
state0.a = state0.b = 0;
|
|
}
|
|
};
|
|
imports.wbg.__wbg_new_405e22f390576ce2 = function() {
|
|
const ret = new Object();
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg_new_78feb108b6472713 = function() {
|
|
const ret = new Array();
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg_new_92c54fc74574ef55 = function() { return handleError(function (arg0, arg1) {
|
|
const ret = new WebSocket(getStringFromWasm0(arg0, arg1));
|
|
return ret;
|
|
}, arguments) };
|
|
imports.wbg.__wbg_new_a12002a7f91c75be = function(arg0) {
|
|
const ret = new Uint8Array(arg0);
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg_newnoargs_105ed471475aaf50 = function(arg0, arg1) {
|
|
const ret = new Function(getStringFromWasm0(arg0, arg1));
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg_newwithbyteoffsetandlength_d97e637ebe145a9a = function(arg0, arg1, arg2) {
|
|
const ret = new Uint8Array(arg0, arg1 >>> 0, arg2 >>> 0);
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg_newwithlength_a381634e90c276d4 = function(arg0) {
|
|
const ret = new Uint8Array(arg0 >>> 0);
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg_node_905d3e251edff8a2 = function(arg0) {
|
|
const ret = arg0.node;
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg_now_d18023d54d4e5500 = function(arg0) {
|
|
const ret = arg0.now();
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg_objectStoreNames_9bb1ab04a7012aaf = function(arg0) {
|
|
const ret = arg0.objectStoreNames;
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg_objectStore_21878d46d25b64b6 = function() { return handleError(function (arg0, arg1, arg2) {
|
|
const ret = arg0.objectStore(getStringFromWasm0(arg1, arg2));
|
|
return ret;
|
|
}, arguments) };
|
|
imports.wbg.__wbg_onConnectionStateChanged_b0dc098522afadba = function(arg0) {
|
|
onConnectionStateChanged(arg0 !== 0);
|
|
};
|
|
imports.wbg.__wbg_onSignRequestReceived_93232ba7a0919705 = function(arg0, arg1, arg2, arg3) {
|
|
onSignRequestReceived(getStringFromWasm0(arg0, arg1), getStringFromWasm0(arg2, arg3));
|
|
};
|
|
imports.wbg.__wbg_open_88b1390d99a7c691 = function() { return handleError(function (arg0, arg1, arg2) {
|
|
const ret = arg0.open(getStringFromWasm0(arg1, arg2));
|
|
return ret;
|
|
}, arguments) };
|
|
imports.wbg.__wbg_open_e0c0b2993eb596e1 = function() { return handleError(function (arg0, arg1, arg2, arg3) {
|
|
const ret = arg0.open(getStringFromWasm0(arg1, arg2), arg3 >>> 0);
|
|
return ret;
|
|
}, arguments) };
|
|
imports.wbg.__wbg_process_dc0fbacc7c1c06f7 = function(arg0) {
|
|
const ret = arg0.process;
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg_push_737cfc8c1432c2c6 = function(arg0, arg1) {
|
|
const ret = arg0.push(arg1);
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg_put_066faa31a6a88f5b = function() { return handleError(function (arg0, arg1, arg2) {
|
|
const ret = arg0.put(arg1, arg2);
|
|
return ret;
|
|
}, arguments) };
|
|
imports.wbg.__wbg_put_9ef5363941008835 = function() { return handleError(function (arg0, arg1) {
|
|
const ret = arg0.put(arg1);
|
|
return ret;
|
|
}, arguments) };
|
|
imports.wbg.__wbg_queueMicrotask_97d92b4fcc8a61c5 = function(arg0) {
|
|
queueMicrotask(arg0);
|
|
};
|
|
imports.wbg.__wbg_queueMicrotask_d3219def82552485 = function(arg0) {
|
|
const ret = arg0.queueMicrotask;
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg_randomFillSync_ac0988aba3254290 = function() { return handleError(function (arg0, arg1) {
|
|
arg0.randomFillSync(arg1);
|
|
}, arguments) };
|
|
imports.wbg.__wbg_readyState_7ef6e63c349899ed = function(arg0) {
|
|
const ret = arg0.readyState;
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg_require_60cc747a6bc5215a = function() { return handleError(function () {
|
|
const ret = module.require;
|
|
return ret;
|
|
}, arguments) };
|
|
imports.wbg.__wbg_resolve_4851785c9c5f573d = function(arg0) {
|
|
const ret = Promise.resolve(arg0);
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg_result_f29afabdf2c05826 = function() { return handleError(function (arg0) {
|
|
const ret = arg0.result;
|
|
return ret;
|
|
}, arguments) };
|
|
imports.wbg.__wbg_send_0293179ba074ffb4 = function() { return handleError(function (arg0, arg1, arg2) {
|
|
arg0.send(getStringFromWasm0(arg1, arg2));
|
|
}, arguments) };
|
|
imports.wbg.__wbg_setTimeout_f2fe5af8e3debeb3 = function() { return handleError(function (arg0, arg1, arg2) {
|
|
const ret = arg0.setTimeout(arg1, arg2);
|
|
return ret;
|
|
}, arguments) };
|
|
imports.wbg.__wbg_set_65595bdd868b3009 = function(arg0, arg1, arg2) {
|
|
arg0.set(arg1, arg2 >>> 0);
|
|
};
|
|
imports.wbg.__wbg_set_bb8cecf6a62b9f46 = function() { return handleError(function (arg0, arg1, arg2) {
|
|
const ret = Reflect.set(arg0, arg1, arg2);
|
|
return ret;
|
|
}, arguments) };
|
|
imports.wbg.__wbg_setbinaryType_92fa1ffd873b327c = function(arg0, arg1) {
|
|
arg0.binaryType = __wbindgen_enum_BinaryType[arg1];
|
|
};
|
|
imports.wbg.__wbg_setonclose_14fc475a49d488fc = function(arg0, arg1) {
|
|
arg0.onclose = arg1;
|
|
};
|
|
imports.wbg.__wbg_setonerror_8639efe354b947cd = function(arg0, arg1) {
|
|
arg0.onerror = arg1;
|
|
};
|
|
imports.wbg.__wbg_setonerror_d7e3056cc6e56085 = function(arg0, arg1) {
|
|
arg0.onerror = arg1;
|
|
};
|
|
imports.wbg.__wbg_setonmessage_6eccab530a8fb4c7 = function(arg0, arg1) {
|
|
arg0.onmessage = arg1;
|
|
};
|
|
imports.wbg.__wbg_setonopen_2da654e1f39745d5 = function(arg0, arg1) {
|
|
arg0.onopen = arg1;
|
|
};
|
|
imports.wbg.__wbg_setonsuccess_afa464ee777a396d = function(arg0, arg1) {
|
|
arg0.onsuccess = arg1;
|
|
};
|
|
imports.wbg.__wbg_setonupgradeneeded_fcf7ce4f2eb0cb5f = function(arg0, arg1) {
|
|
arg0.onupgradeneeded = arg1;
|
|
};
|
|
imports.wbg.__wbg_static_accessor_GLOBAL_88a902d13a557d07 = function() {
|
|
const ret = typeof global === 'undefined' ? null : global;
|
|
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
};
|
|
imports.wbg.__wbg_static_accessor_GLOBAL_THIS_56578be7e9f832b0 = function() {
|
|
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
|
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
};
|
|
imports.wbg.__wbg_static_accessor_SELF_37c5d418e4bf5819 = function() {
|
|
const ret = typeof self === 'undefined' ? null : self;
|
|
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
};
|
|
imports.wbg.__wbg_static_accessor_WINDOW_5de37043a91a9c40 = function() {
|
|
const ret = typeof window === 'undefined' ? null : window;
|
|
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
};
|
|
imports.wbg.__wbg_subarray_aa9065fa9dc5df96 = function(arg0, arg1, arg2) {
|
|
const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg_target_0a62d9d79a2a1ede = function(arg0) {
|
|
const ret = arg0.target;
|
|
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
};
|
|
imports.wbg.__wbg_then_44b73946d2fb3e7d = function(arg0, arg1) {
|
|
const ret = arg0.then(arg1);
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg_then_48b406749878a531 = function(arg0, arg1, arg2) {
|
|
const ret = arg0.then(arg1, arg2);
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg_transaction_d6d07c3c9963c49e = function() { return handleError(function (arg0, arg1, arg2) {
|
|
const ret = arg0.transaction(arg1, __wbindgen_enum_IdbTransactionMode[arg2]);
|
|
return ret;
|
|
}, arguments) };
|
|
imports.wbg.__wbg_versions_c01dfd4722a88165 = function(arg0) {
|
|
const ret = arg0.versions;
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbg_warn_4ca3906c248c47c4 = function(arg0) {
|
|
console.warn(arg0);
|
|
};
|
|
imports.wbg.__wbindgen_cb_drop = function(arg0) {
|
|
const obj = arg0.original;
|
|
if (obj.cnt-- == 1) {
|
|
obj.a = 0;
|
|
return true;
|
|
}
|
|
const ret = false;
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbindgen_closure_wrapper1015 = function(arg0, arg1, arg2) {
|
|
const ret = makeMutClosure(arg0, arg1, 309, __wbg_adapter_52);
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbindgen_closure_wrapper1320 = function(arg0, arg1, arg2) {
|
|
const ret = makeMutClosure(arg0, arg1, 393, __wbg_adapter_55);
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbindgen_closure_wrapper423 = function(arg0, arg1, arg2) {
|
|
const ret = makeMutClosure(arg0, arg1, 172, __wbg_adapter_34);
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbindgen_closure_wrapper424 = function(arg0, arg1, arg2) {
|
|
const ret = makeMutClosure(arg0, arg1, 172, __wbg_adapter_34);
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbindgen_closure_wrapper425 = function(arg0, arg1, arg2) {
|
|
const ret = makeMutClosure(arg0, arg1, 172, __wbg_adapter_39);
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbindgen_closure_wrapper428 = function(arg0, arg1, arg2) {
|
|
const ret = makeMutClosure(arg0, arg1, 172, __wbg_adapter_34);
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbindgen_closure_wrapper766 = function(arg0, arg1, arg2) {
|
|
const ret = makeMutClosure(arg0, arg1, 238, __wbg_adapter_44);
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbindgen_closure_wrapper767 = function(arg0, arg1, arg2) {
|
|
const ret = makeMutClosure(arg0, arg1, 238, __wbg_adapter_44);
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbindgen_closure_wrapper770 = function(arg0, arg1, arg2) {
|
|
const ret = makeMutClosure(arg0, arg1, 238, __wbg_adapter_49);
|
|
return ret;
|
|
};
|
|
imports.wbg.__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);
|
|
};
|
|
imports.wbg.__wbindgen_init_externref_table = function() {
|
|
const table = wasm.__wbindgen_export_2;
|
|
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);
|
|
;
|
|
};
|
|
imports.wbg.__wbindgen_is_function = function(arg0) {
|
|
const ret = typeof(arg0) === 'function';
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbindgen_is_null = function(arg0) {
|
|
const ret = arg0 === null;
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbindgen_is_object = function(arg0) {
|
|
const val = arg0;
|
|
const ret = typeof(val) === 'object' && val !== null;
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbindgen_is_string = function(arg0) {
|
|
const ret = typeof(arg0) === 'string';
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbindgen_is_undefined = function(arg0) {
|
|
const ret = arg0 === undefined;
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbindgen_json_parse = function(arg0, arg1) {
|
|
const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbindgen_json_serialize = function(arg0, arg1) {
|
|
const obj = arg1;
|
|
const ret = JSON.stringify(obj === undefined ? null : obj);
|
|
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);
|
|
};
|
|
imports.wbg.__wbindgen_memory = function() {
|
|
const ret = wasm.memory;
|
|
return ret;
|
|
};
|
|
imports.wbg.__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);
|
|
};
|
|
imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
|
|
const ret = getStringFromWasm0(arg0, arg1);
|
|
return ret;
|
|
};
|
|
imports.wbg.__wbindgen_throw = function(arg0, arg1) {
|
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
};
|
|
|
|
return imports;
|
|
}
|
|
|
|
function __wbg_init_memory(imports, memory) {
|
|
|
|
}
|
|
|
|
function __wbg_finalize_init(instance, module) {
|
|
wasm = instance.exports;
|
|
__wbg_init.__wbindgen_wasm_module = module;
|
|
cachedDataViewMemory0 = null;
|
|
cachedUint8ArrayMemory0 = null;
|
|
|
|
|
|
wasm.__wbindgen_start();
|
|
return wasm;
|
|
}
|
|
|
|
function initSync(module) {
|
|
if (wasm !== undefined) return wasm;
|
|
|
|
|
|
if (typeof 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();
|
|
|
|
__wbg_init_memory(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 (typeof 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 (typeof module_or_path === 'undefined') {
|
|
module_or_path = new URL('wasm_app_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);
|
|
}
|
|
|
|
__wbg_init_memory(imports);
|
|
|
|
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
|
|
return __wbg_finalize_init(instance, module);
|
|
}
|
|
|
|
export { initSync };
|
|
export default __wbg_init;
|