update exports
Some checks are pending
Sharenet Passport CI / test-native (push) Waiting to run
Sharenet Passport CI / test-wasm-headless (push) Waiting to run
Sharenet Passport CI / test-wasm-webdriver (push) Waiting to run
Sharenet Passport CI / build-wasm (push) Waiting to run
Sharenet Passport CI / lint (push) Waiting to run

This commit is contained in:
Continuist 2025-10-29 23:06:41 -04:00
parent 8a39f36875
commit 181adee26c
5 changed files with 973 additions and 10 deletions

View file

@ -6,20 +6,14 @@
use wasm_bindgen::prelude::*; use wasm_bindgen::prelude::*;
use crate::application::use_cases::{ use crate::application::use_cases::{
CreatePassportUseCase,
ImportFromRecoveryUseCase,
ExportPassportUseCase,
SignCardUseCase, SignCardUseCase,
CreateUserProfileUseCase,
UpdateUserProfileUseCase,
DeleteUserProfileUseCase
}; };
use crate::infrastructure::{ use crate::infrastructure::{
Bip39MnemonicGenerator, Bip39MnemonicGenerator,
Ed25519KeyDeriver, Ed25519KeyDeriver,
XChaCha20FileEncryptor, XChaCha20FileEncryptor,
}; };
use crate::domain::entities::{Passport, UserIdentity, UserPreferences, PassportFile, RecoveryPhrase, UserProfile, Seed}; use crate::domain::entities::{Passport, UserIdentity, UserPreferences, PassportFile, RecoveryPhrase, UserProfile};
use crate::domain::traits::{MnemonicGenerator, KeyDeriver, FileEncryptor}; use crate::domain::traits::{MnemonicGenerator, KeyDeriver, FileEncryptor};
/// Create a new passport with the given universe ID and password /// Create a new passport with the given universe ID and password
@ -29,7 +23,7 @@ use crate::domain::traits::{MnemonicGenerator, KeyDeriver, FileEncryptor};
#[wasm_bindgen] #[wasm_bindgen]
pub fn create_passport( pub fn create_passport(
univ_id: String, univ_id: String,
password: String, _password: String,
) -> Result<JsValue, JsValue> { ) -> Result<JsValue, JsValue> {
// For WASM, we need to create a passport in memory without file operations // For WASM, we need to create a passport in memory without file operations
// This is a simplified version that creates the passport structure directly // This is a simplified version that creates the passport structure directly
@ -71,7 +65,7 @@ pub fn create_passport(
pub fn import_from_recovery( pub fn import_from_recovery(
univ_id: String, univ_id: String,
recovery_words: Vec<String>, recovery_words: Vec<String>,
password: String, _password: String,
) -> Result<JsValue, JsValue> { ) -> Result<JsValue, JsValue> {
let generator = Bip39MnemonicGenerator; let generator = Bip39MnemonicGenerator;
let key_deriver = Ed25519KeyDeriver; let key_deriver = Ed25519KeyDeriver;
@ -120,7 +114,7 @@ pub fn import_from_encrypted_data(
// Decrypt the passport file using the password // Decrypt the passport file using the password
let encryptor = XChaCha20FileEncryptor; let encryptor = XChaCha20FileEncryptor;
let (seed, public_key, private_key, user_profiles) = encryptor.decrypt( let (seed, public_key, private_key, _user_profiles) = encryptor.decrypt(
&passport_file, &passport_file,
&password, &password,
).map_err(|e| JsValue::from_str(&format!("Failed to decrypt passport: {}", e)))?; ).map_err(|e| JsValue::from_str(&format!("Failed to decrypt passport: {}", e)))?;

113
pkg/sharenet_passport.d.ts vendored Normal file
View file

@ -0,0 +1,113 @@
/* tslint:disable */
/* eslint-disable */
/**
* Create a new passport with the given universe ID and password
*
* Returns a JSON string containing both the passport and recovery phrase
* This function works entirely in memory and doesn't write to any storage.
*/
export function create_passport(univ_id: string, _password: string): any;
/**
* Import a passport from recovery phrase
* Returns the imported passport as JSON
*/
export function import_from_recovery(univ_id: string, recovery_words: string[], _password: string): any;
/**
* Load a passport from encrypted data (ArrayBuffer/Blob)
* This accepts encrypted passport data as bytes and returns the decrypted passport
*/
export function import_from_encrypted_data(encrypted_data: Uint8Array, password: string): any;
/**
* Export a passport to encrypted data (ArrayBuffer/Blob)
* This returns encrypted passport data as bytes that can be downloaded or stored
*/
export function export_to_encrypted_data(passport_json: any, password: string): Uint8Array;
/**
* Sign a message with the passport's private key
*/
export function sign_message(passport_json: any, message: string): Uint8Array;
/**
* Generate a new recovery phrase
*/
export function generate_recovery_phrase(): any;
/**
* Validate a recovery phrase
*/
export function validate_recovery_phrase(recovery_words: string[]): boolean;
/**
* Create a new user profile for a passport
* Returns the updated passport as JSON
*/
export function create_user_profile(passport_json: any, hub_did: string | null | undefined, identity_json: any, preferences_json: any): any;
/**
* Update an existing user profile
* Returns the updated passport as JSON
*/
export function update_user_profile(passport_json: any, profile_id: string, identity_json: any, preferences_json: any): any;
/**
* Delete a user profile
* Returns the updated passport as JSON
*/
export function delete_user_profile(passport_json: any, profile_id: string): any;
/**
* Change passport password
* Returns the updated passport as JSON
*/
export function change_passport_password(_passport_json: any, _old_password: string, _new_password: string): any;
/**
* Get passport metadata from encrypted data
* This can extract public metadata without full decryption
*/
export function get_passport_metadata(encrypted_data: Uint8Array): any;
/**
* Validate passport file integrity from encrypted data
*/
export function validate_passport_file(encrypted_data: Uint8Array): boolean;
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
export interface InitOutput {
readonly memory: WebAssembly.Memory;
readonly create_passport: (a: number, b: number, c: number, d: number) => [number, number, number];
readonly import_from_recovery: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
readonly import_from_encrypted_data: (a: number, b: number, c: number, d: number) => [number, number, number];
readonly export_to_encrypted_data: (a: any, b: number, c: number) => [number, number, number, number];
readonly sign_message: (a: any, b: number, c: number) => [number, number, number, number];
readonly generate_recovery_phrase: () => [number, number, number];
readonly validate_recovery_phrase: (a: number, b: number) => [number, number, number];
readonly create_user_profile: (a: any, b: number, c: number, d: any, e: any) => [number, number, number];
readonly update_user_profile: (a: any, b: number, c: number, d: any, e: any) => [number, number, number];
readonly delete_user_profile: (a: any, b: number, c: number) => [number, number, number];
readonly change_passport_password: (a: any, b: number, c: number, d: number, e: number) => [number, number, number];
readonly get_passport_metadata: (a: number, b: number) => [number, number, number];
readonly validate_passport_file: (a: number, b: number) => [number, number, number];
readonly __wbindgen_malloc: (a: number, b: number) => number;
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
readonly __wbindgen_exn_store: (a: number) => void;
readonly __externref_table_alloc: () => number;
readonly __wbindgen_externrefs: WebAssembly.Table;
readonly __externref_table_dealloc: (a: number) => void;
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
readonly __wbindgen_start: () => void;
}
export type SyncInitInput = BufferSource | WebAssembly.Module;
/**
* Instantiates the given `module`, which can either be bytes or
* a precompiled `WebAssembly.Module`.
*
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
*
* @returns {InitOutput}
*/
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
/**
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
* for everything else, calls `WebAssembly.instantiate` directly.
*
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
*
* @returns {Promise<InitOutput>}
*/
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;

832
pkg/sharenet_passport.js Normal file
View file

@ -0,0 +1,832 @@
let wasm;
let cachedUint8ArrayMemory0 = null;
function getUint8ArrayMemory0() {
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
}
return cachedUint8ArrayMemory0;
}
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
cachedTextDecoder.decode();
const MAX_SAFARI_DECODE_BYTES = 2146435072;
let numBytesDecoded = 0;
function decodeText(ptr, len) {
numBytesDecoded += len;
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
cachedTextDecoder.decode();
numBytesDecoded = len;
}
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
}
function getStringFromWasm0(ptr, len) {
ptr = ptr >>> 0;
return decodeText(ptr, len);
}
let WASM_VECTOR_LEN = 0;
const cachedTextEncoder = new TextEncoder();
if (!('encodeInto' in cachedTextEncoder)) {
cachedTextEncoder.encodeInto = function (arg, view) {
const buf = cachedTextEncoder.encode(arg);
view.set(buf);
return {
read: arg.length,
written: buf.length
};
}
}
function passStringToWasm0(arg, malloc, realloc) {
if (realloc === undefined) {
const buf = cachedTextEncoder.encode(arg);
const ptr = malloc(buf.length, 1) >>> 0;
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
WASM_VECTOR_LEN = buf.length;
return ptr;
}
let len = arg.length;
let ptr = malloc(len, 1) >>> 0;
const mem = getUint8ArrayMemory0();
let offset = 0;
for (; offset < len; offset++) {
const code = arg.charCodeAt(offset);
if (code > 0x7F) break;
mem[ptr + offset] = code;
}
if (offset !== len) {
if (offset !== 0) {
arg = arg.slice(offset);
}
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
const ret = cachedTextEncoder.encodeInto(arg, view);
offset += ret.written;
ptr = realloc(ptr, len, offset, 1) >>> 0;
}
WASM_VECTOR_LEN = offset;
return ptr;
}
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 isLikeNone(x) {
return x === undefined || x === null;
}
function debugString(val) {
// primitive types
const type = typeof val;
if (type == 'number' || type == 'boolean' || val == null) {
return `${val}`;
}
if (type == 'string') {
return `"${val}"`;
}
if (type == 'symbol') {
const description = val.description;
if (description == null) {
return 'Symbol';
} else {
return `Symbol(${description})`;
}
}
if (type == 'function') {
const name = val.name;
if (typeof name == 'string' && name.length > 0) {
return `Function(${name})`;
} else {
return 'Function';
}
}
// objects
if (Array.isArray(val)) {
const length = val.length;
let debug = '[';
if (length > 0) {
debug += debugString(val[0]);
}
for(let i = 1; i < length; i++) {
debug += ', ' + debugString(val[i]);
}
debug += ']';
return debug;
}
// Test for built-in
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
let className;
if (builtInMatches && builtInMatches.length > 1) {
className = builtInMatches[1];
} else {
// Failed to match the standard '[object ClassName]'
return toString.call(val);
}
if (className == 'Object') {
// we're a user defined class or Object
// JSON.stringify avoids problems with cycles, and is generally much
// easier than looping through ownProperties of `val`.
try {
return 'Object(' + JSON.stringify(val) + ')';
} catch (_) {
return 'Object';
}
}
// errors
if (val instanceof Error) {
return `${val.name}: ${val.message}\n${val.stack}`;
}
// TODO we could test for more things here, like `Set`s and `Map`s.
return className;
}
function addToExternrefTable0(obj) {
const idx = wasm.__externref_table_alloc();
wasm.__wbindgen_externrefs.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 getArrayU8FromWasm0(ptr, len) {
ptr = ptr >>> 0;
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
}
function takeFromExternrefTable0(idx) {
const value = wasm.__wbindgen_externrefs.get(idx);
wasm.__externref_table_dealloc(idx);
return value;
}
/**
* Create a new passport with the given universe ID and password
*
* Returns a JSON string containing both the passport and recovery phrase
* This function works entirely in memory and doesn't write to any storage.
* @param {string} univ_id
* @param {string} _password
* @returns {any}
*/
export function create_passport(univ_id, _password) {
const ptr0 = passStringToWasm0(univ_id, 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_passport(ptr0, len0, ptr1, len1);
if (ret[2]) {
throw takeFromExternrefTable0(ret[1]);
}
return takeFromExternrefTable0(ret[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;
}
/**
* Import a passport from recovery phrase
* Returns the imported passport as JSON
* @param {string} univ_id
* @param {string[]} recovery_words
* @param {string} _password
* @returns {any}
*/
export function import_from_recovery(univ_id, recovery_words, _password) {
const ptr0 = passStringToWasm0(univ_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const len0 = WASM_VECTOR_LEN;
const ptr1 = passArrayJsValueToWasm0(recovery_words, wasm.__wbindgen_malloc);
const len1 = WASM_VECTOR_LEN;
const ptr2 = passStringToWasm0(_password, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const len2 = WASM_VECTOR_LEN;
const ret = wasm.import_from_recovery(ptr0, len0, ptr1, len1, ptr2, len2);
if (ret[2]) {
throw takeFromExternrefTable0(ret[1]);
}
return 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;
}
/**
* Load a passport from encrypted data (ArrayBuffer/Blob)
* This accepts encrypted passport data as bytes and returns the decrypted passport
* @param {Uint8Array} encrypted_data
* @param {string} password
* @returns {any}
*/
export function import_from_encrypted_data(encrypted_data, password) {
const ptr0 = passArray8ToWasm0(encrypted_data, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
const ptr1 = passStringToWasm0(password, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const len1 = WASM_VECTOR_LEN;
const ret = wasm.import_from_encrypted_data(ptr0, len0, ptr1, len1);
if (ret[2]) {
throw takeFromExternrefTable0(ret[1]);
}
return takeFromExternrefTable0(ret[0]);
}
/**
* Export a passport to encrypted data (ArrayBuffer/Blob)
* This returns encrypted passport data as bytes that can be downloaded or stored
* @param {any} passport_json
* @param {string} password
* @returns {Uint8Array}
*/
export function export_to_encrypted_data(passport_json, password) {
const ptr0 = passStringToWasm0(password, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const len0 = WASM_VECTOR_LEN;
const ret = wasm.export_to_encrypted_data(passport_json, ptr0, len0);
if (ret[3]) {
throw takeFromExternrefTable0(ret[2]);
}
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
return v2;
}
/**
* Sign a message with the passport's private key
* @param {any} passport_json
* @param {string} message
* @returns {Uint8Array}
*/
export function sign_message(passport_json, message) {
const ptr0 = passStringToWasm0(message, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const len0 = WASM_VECTOR_LEN;
const ret = wasm.sign_message(passport_json, ptr0, len0);
if (ret[3]) {
throw takeFromExternrefTable0(ret[2]);
}
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
return v2;
}
/**
* Generate a new recovery phrase
* @returns {any}
*/
export function generate_recovery_phrase() {
const ret = wasm.generate_recovery_phrase();
if (ret[2]) {
throw takeFromExternrefTable0(ret[1]);
}
return takeFromExternrefTable0(ret[0]);
}
/**
* Validate a recovery phrase
* @param {string[]} recovery_words
* @returns {boolean}
*/
export function validate_recovery_phrase(recovery_words) {
const ptr0 = passArrayJsValueToWasm0(recovery_words, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
const ret = wasm.validate_recovery_phrase(ptr0, len0);
if (ret[2]) {
throw takeFromExternrefTable0(ret[1]);
}
return ret[0] !== 0;
}
/**
* Create a new user profile for a passport
* Returns the updated passport as JSON
* @param {any} passport_json
* @param {string | null | undefined} hub_did
* @param {any} identity_json
* @param {any} preferences_json
* @returns {any}
*/
export function create_user_profile(passport_json, hub_did, identity_json, preferences_json) {
var ptr0 = isLikeNone(hub_did) ? 0 : passStringToWasm0(hub_did, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
var len0 = WASM_VECTOR_LEN;
const ret = wasm.create_user_profile(passport_json, ptr0, len0, identity_json, preferences_json);
if (ret[2]) {
throw takeFromExternrefTable0(ret[1]);
}
return takeFromExternrefTable0(ret[0]);
}
/**
* Update an existing user profile
* Returns the updated passport as JSON
* @param {any} passport_json
* @param {string} profile_id
* @param {any} identity_json
* @param {any} preferences_json
* @returns {any}
*/
export function update_user_profile(passport_json, profile_id, identity_json, preferences_json) {
const ptr0 = passStringToWasm0(profile_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const len0 = WASM_VECTOR_LEN;
const ret = wasm.update_user_profile(passport_json, ptr0, len0, identity_json, preferences_json);
if (ret[2]) {
throw takeFromExternrefTable0(ret[1]);
}
return takeFromExternrefTable0(ret[0]);
}
/**
* Delete a user profile
* Returns the updated passport as JSON
* @param {any} passport_json
* @param {string} profile_id
* @returns {any}
*/
export function delete_user_profile(passport_json, profile_id) {
const ptr0 = passStringToWasm0(profile_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const len0 = WASM_VECTOR_LEN;
const ret = wasm.delete_user_profile(passport_json, ptr0, len0);
if (ret[2]) {
throw takeFromExternrefTable0(ret[1]);
}
return takeFromExternrefTable0(ret[0]);
}
/**
* Change passport password
* Returns the updated passport as JSON
* @param {any} _passport_json
* @param {string} _old_password
* @param {string} _new_password
* @returns {any}
*/
export function change_passport_password(_passport_json, _old_password, _new_password) {
const ptr0 = passStringToWasm0(_old_password, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const len0 = WASM_VECTOR_LEN;
const ptr1 = passStringToWasm0(_new_password, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const len1 = WASM_VECTOR_LEN;
const ret = wasm.change_passport_password(_passport_json, ptr0, len0, ptr1, len1);
if (ret[2]) {
throw takeFromExternrefTable0(ret[1]);
}
return takeFromExternrefTable0(ret[0]);
}
/**
* Get passport metadata from encrypted data
* This can extract public metadata without full decryption
* @param {Uint8Array} encrypted_data
* @returns {any}
*/
export function get_passport_metadata(encrypted_data) {
const ptr0 = passArray8ToWasm0(encrypted_data, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
const ret = wasm.get_passport_metadata(ptr0, len0);
if (ret[2]) {
throw takeFromExternrefTable0(ret[1]);
}
return takeFromExternrefTable0(ret[0]);
}
/**
* Validate passport file integrity from encrypted data
* @param {Uint8Array} encrypted_data
* @returns {boolean}
*/
export function validate_passport_file(encrypted_data) {
const ptr0 = passArray8ToWasm0(encrypted_data, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
const ret = wasm.validate_passport_file(ptr0, len0);
if (ret[2]) {
throw takeFromExternrefTable0(ret[1]);
}
return ret[0] !== 0;
}
const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
async function __wbg_load(module, imports) {
if (typeof Response === 'function' && module instanceof Response) {
if (typeof WebAssembly.instantiateStreaming === 'function') {
try {
return await WebAssembly.instantiateStreaming(module, imports);
} catch (e) {
const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
} else {
throw e;
}
}
}
const bytes = await module.arrayBuffer();
return await WebAssembly.instantiate(bytes, imports);
} else {
const instance = await WebAssembly.instantiate(module, imports);
if (instance instanceof WebAssembly.Instance) {
return { instance, module };
} else {
return instance;
}
}
}
function __wbg_get_imports() {
const imports = {};
imports.wbg = {};
imports.wbg.__wbg_Error_e83987f665cf5504 = function(arg0, arg1) {
const ret = Error(getStringFromWasm0(arg0, arg1));
return ret;
};
imports.wbg.__wbg_Number_bb48ca12f395cd08 = function(arg0) {
const ret = Number(arg0);
return ret;
};
imports.wbg.__wbg_String_8f0eb39a4a4c2f66 = 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);
};
imports.wbg.__wbg___wbindgen_bigint_get_as_i64_f3ebc5a755000afd = function(arg0, arg1) {
const v = arg1;
const ret = typeof(v) === 'bigint' ? v : undefined;
getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
};
imports.wbg.__wbg___wbindgen_boolean_get_6d5a1ee65bab5f68 = function(arg0) {
const v = arg0;
const ret = typeof(v) === 'boolean' ? v : undefined;
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
};
imports.wbg.__wbg___wbindgen_debug_string_df47ffb5e35e6763 = 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.__wbg___wbindgen_in_bb933bd9e1b3bc0f = function(arg0, arg1) {
const ret = arg0 in arg1;
return ret;
};
imports.wbg.__wbg___wbindgen_is_bigint_cb320707dcd35f0b = function(arg0) {
const ret = typeof(arg0) === 'bigint';
return ret;
};
imports.wbg.__wbg___wbindgen_is_function_ee8a6c5833c90377 = function(arg0) {
const ret = typeof(arg0) === 'function';
return ret;
};
imports.wbg.__wbg___wbindgen_is_object_c818261d21f283a4 = function(arg0) {
const val = arg0;
const ret = typeof(val) === 'object' && val !== null;
return ret;
};
imports.wbg.__wbg___wbindgen_is_string_fbb76cb2940daafd = function(arg0) {
const ret = typeof(arg0) === 'string';
return ret;
};
imports.wbg.__wbg___wbindgen_is_undefined_2d472862bd29a478 = function(arg0) {
const ret = arg0 === undefined;
return ret;
};
imports.wbg.__wbg___wbindgen_jsval_eq_6b13ab83478b1c50 = function(arg0, arg1) {
const ret = arg0 === arg1;
return ret;
};
imports.wbg.__wbg___wbindgen_jsval_loose_eq_b664b38a2f582147 = function(arg0, arg1) {
const ret = arg0 == arg1;
return ret;
};
imports.wbg.__wbg___wbindgen_number_get_a20bf9b85341449d = function(arg0, arg1) {
const obj = arg1;
const ret = typeof(obj) === 'number' ? obj : undefined;
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
};
imports.wbg.__wbg___wbindgen_string_get_e4f06c90489ad01b = 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.__wbg___wbindgen_throw_b855445ff6a94295 = function(arg0, arg1) {
throw new Error(getStringFromWasm0(arg0, arg1));
};
imports.wbg.__wbg_call_525440f72fbfc0ea = function() { return handleError(function (arg0, arg1, arg2) {
const ret = arg0.call(arg1, arg2);
return ret;
}, arguments) };
imports.wbg.__wbg_call_e762c39fa8ea36bf = function() { return handleError(function (arg0, arg1) {
const ret = arg0.call(arg1);
return ret;
}, arguments) };
imports.wbg.__wbg_crypto_574e78ad8b13b65f = function(arg0) {
const ret = arg0.crypto;
return ret;
};
imports.wbg.__wbg_done_2042aa2670fb1db1 = function(arg0) {
const ret = arg0.done;
return ret;
};
imports.wbg.__wbg_getRandomValues_38a1ff1ea09f6cc7 = 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_get_7bed016f185add81 = function(arg0, arg1) {
const ret = arg0[arg1 >>> 0];
return ret;
};
imports.wbg.__wbg_get_efcb449f58ec27c2 = function() { return handleError(function (arg0, arg1) {
const ret = Reflect.get(arg0, arg1);
return ret;
}, arguments) };
imports.wbg.__wbg_get_with_ref_key_1dc361bd10053bfe = function(arg0, arg1) {
const ret = arg0[arg1];
return ret;
};
imports.wbg.__wbg_instanceof_ArrayBuffer_70beb1189ca63b38 = function(arg0) {
let result;
try {
result = arg0 instanceof ArrayBuffer;
} catch (_) {
result = false;
}
const ret = result;
return ret;
};
imports.wbg.__wbg_instanceof_Uint8Array_20c8e73002f7af98 = function(arg0) {
let result;
try {
result = arg0 instanceof Uint8Array;
} catch (_) {
result = false;
}
const ret = result;
return ret;
};
imports.wbg.__wbg_isArray_96e0af9891d0945d = function(arg0) {
const ret = Array.isArray(arg0);
return ret;
};
imports.wbg.__wbg_isSafeInteger_d216eda7911dde36 = function(arg0) {
const ret = Number.isSafeInteger(arg0);
return ret;
};
imports.wbg.__wbg_iterator_e5822695327a3c39 = function() {
const ret = Symbol.iterator;
return ret;
};
imports.wbg.__wbg_length_69bca3cb64fc8748 = function(arg0) {
const ret = arg0.length;
return ret;
};
imports.wbg.__wbg_length_cdd215e10d9dd507 = function(arg0) {
const ret = arg0.length;
return ret;
};
imports.wbg.__wbg_msCrypto_a61aeb35a24c1329 = function(arg0) {
const ret = arg0.msCrypto;
return ret;
};
imports.wbg.__wbg_new_1acc0b6eea89d040 = function() {
const ret = new Object();
return ret;
};
imports.wbg.__wbg_new_5a79be3ab53b8aa5 = function(arg0) {
const ret = new Uint8Array(arg0);
return ret;
};
imports.wbg.__wbg_new_68651c719dcda04e = function() {
const ret = new Map();
return ret;
};
imports.wbg.__wbg_new_e17d9f43105b08be = function() {
const ret = new Array();
return ret;
};
imports.wbg.__wbg_new_no_args_ee98eee5275000a4 = function(arg0, arg1) {
const ret = new Function(getStringFromWasm0(arg0, arg1));
return ret;
};
imports.wbg.__wbg_new_with_length_01aa0dc35aa13543 = function(arg0) {
const ret = new Uint8Array(arg0 >>> 0);
return ret;
};
imports.wbg.__wbg_next_020810e0ae8ebcb0 = function() { return handleError(function (arg0) {
const ret = arg0.next();
return ret;
}, arguments) };
imports.wbg.__wbg_next_2c826fe5dfec6b6a = function(arg0) {
const ret = arg0.next;
return ret;
};
imports.wbg.__wbg_node_905d3e251edff8a2 = function(arg0) {
const ret = arg0.node;
return ret;
};
imports.wbg.__wbg_now_793306c526e2e3b6 = function() {
const ret = Date.now();
return ret;
};
imports.wbg.__wbg_now_98430d19d580dbab = function() { return handleError(function () {
const ret = Date.now();
return ret;
}, arguments) };
imports.wbg.__wbg_process_dc0fbacc7c1c06f7 = function(arg0) {
const ret = arg0.process;
return ret;
};
imports.wbg.__wbg_prototypesetcall_2a6620b6922694b2 = function(arg0, arg1, arg2) {
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
};
imports.wbg.__wbg_randomFillSync_ac0988aba3254290 = function() { return handleError(function (arg0, arg1) {
arg0.randomFillSync(arg1);
}, arguments) };
imports.wbg.__wbg_require_60cc747a6bc5215a = function() { return handleError(function () {
const ret = module.require;
return ret;
}, arguments) };
imports.wbg.__wbg_set_3f1d0b984ed272ed = function(arg0, arg1, arg2) {
arg0[arg1] = arg2;
};
imports.wbg.__wbg_set_907fb406c34a251d = function(arg0, arg1, arg2) {
const ret = arg0.set(arg1, arg2);
return ret;
};
imports.wbg.__wbg_set_c213c871859d6500 = function(arg0, arg1, arg2) {
arg0[arg1 >>> 0] = arg2;
};
imports.wbg.__wbg_static_accessor_GLOBAL_89e1d9ac6a1b250e = function() {
const ret = typeof global === 'undefined' ? null : global;
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
};
imports.wbg.__wbg_static_accessor_GLOBAL_THIS_8b530f326a9e48ac = function() {
const ret = typeof globalThis === 'undefined' ? null : globalThis;
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
};
imports.wbg.__wbg_static_accessor_SELF_6fdf4b64710cc91b = function() {
const ret = typeof self === 'undefined' ? null : self;
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
};
imports.wbg.__wbg_static_accessor_WINDOW_b45bfc5a37f6cfa2 = function() {
const ret = typeof window === 'undefined' ? null : window;
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
};
imports.wbg.__wbg_subarray_480600f3d6a9f26c = function(arg0, arg1, arg2) {
const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
return ret;
};
imports.wbg.__wbg_value_692627309814bb8c = function(arg0) {
const ret = arg0.value;
return ret;
};
imports.wbg.__wbg_versions_c01dfd4722a88165 = function(arg0) {
const ret = arg0.versions;
return ret;
};
imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
// Cast intrinsic for `Ref(String) -> Externref`.
const ret = getStringFromWasm0(arg0, arg1);
return ret;
};
imports.wbg.__wbindgen_cast_4625c577ab2ec9ee = function(arg0) {
// Cast intrinsic for `U64 -> Externref`.
const ret = BigInt.asUintN(64, arg0);
return ret;
};
imports.wbg.__wbindgen_cast_9ae0607507abb057 = function(arg0) {
// Cast intrinsic for `I64 -> Externref`.
const ret = arg0;
return ret;
};
imports.wbg.__wbindgen_cast_cb9088102bce6b30 = function(arg0, arg1) {
// Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
const ret = getArrayU8FromWasm0(arg0, arg1);
return ret;
};
imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
// Cast intrinsic for `F64 -> Externref`.
const ret = arg0;
return ret;
};
imports.wbg.__wbindgen_init_externref_table = function() {
const table = wasm.__wbindgen_externrefs;
const offset = table.grow(4);
table.set(0, undefined);
table.set(offset + 0, undefined);
table.set(offset + 1, null);
table.set(offset + 2, true);
table.set(offset + 3, false);
;
};
return imports;
}
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();
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('sharenet_passport_bg.wasm', import.meta.url);
}
const imports = __wbg_get_imports();
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
module_or_path = fetch(module_or_path);
}
const { instance, module } = await __wbg_load(await module_or_path, imports);
return __wbg_finalize_init(instance, module);
}
export { initSync };
export default __wbg_init;

Binary file not shown.

24
pkg/sharenet_passport_bg.wasm.d.ts vendored Normal file
View file

@ -0,0 +1,24 @@
/* tslint:disable */
/* eslint-disable */
export const memory: WebAssembly.Memory;
export const create_passport: (a: number, b: number, c: number, d: number) => [number, number, number];
export const import_from_recovery: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
export const import_from_encrypted_data: (a: number, b: number, c: number, d: number) => [number, number, number];
export const export_to_encrypted_data: (a: any, b: number, c: number) => [number, number, number, number];
export const sign_message: (a: any, b: number, c: number) => [number, number, number, number];
export const generate_recovery_phrase: () => [number, number, number];
export const validate_recovery_phrase: (a: number, b: number) => [number, number, number];
export const create_user_profile: (a: any, b: number, c: number, d: any, e: any) => [number, number, number];
export const update_user_profile: (a: any, b: number, c: number, d: any, e: any) => [number, number, number];
export const delete_user_profile: (a: any, b: number, c: number) => [number, number, number];
export const change_passport_password: (a: any, b: number, c: number, d: number, e: number) => [number, number, number];
export const get_passport_metadata: (a: number, b: number) => [number, number, number];
export const validate_passport_file: (a: number, b: number) => [number, number, number];
export const __wbindgen_malloc: (a: number, b: number) => number;
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
export const __wbindgen_exn_store: (a: number) => void;
export const __externref_table_alloc: () => number;
export const __wbindgen_externrefs: WebAssembly.Table;
export const __externref_table_dealloc: (a: number) => void;
export const __wbindgen_free: (a: number, b: number, c: number) => void;
export const __wbindgen_start: () => void;