feature/1-self-sovereign-passports-for-user-identity #2
1 changed files with 11 additions and 7 deletions
|
|
@ -1,7 +1,6 @@
|
||||||
import type { UserProfile, SPFPassport } from './auth/types';
|
'use client';
|
||||||
|
|
||||||
// Import the generated WASM module types
|
import type { UserProfile, SPFPassport } from './auth/types';
|
||||||
// import type * as WasmModule from '../wasm/pkg/sharenet_passport_wasm';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* WASM module interface with proper TypeScript typing
|
* WASM module interface with proper TypeScript typing
|
||||||
|
|
@ -54,12 +53,17 @@ export class PassportWASMLoader {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Dynamically import the WASM bindings - they handle the WASM initialization
|
// Dynamically import the WASM bindings
|
||||||
|
// With bundler target, the module is automatically initialized on import
|
||||||
|
// but we need to ensure the WASM memory is ready before calling functions
|
||||||
const wasmModule = await import('./wasm-pkg/sharenet_passport_wasm');
|
const wasmModule = await import('./wasm-pkg/sharenet_passport_wasm');
|
||||||
|
|
||||||
// Initialize the WASM module using the default export
|
// Test that the WASM module is properly initialized by checking if
|
||||||
// With bundler target, this automatically handles the WASM loading
|
// the wasm memory is accessible through a simple property access
|
||||||
await wasmModule.default();
|
// This ensures the WASM module is fully loaded before we use it
|
||||||
|
if (!wasmModule || typeof wasmModule.parse_spf_file !== 'function') {
|
||||||
|
throw new Error('WASM module exports not properly loaded');
|
||||||
|
}
|
||||||
|
|
||||||
// Create wrapper functions with proper typing
|
// Create wrapper functions with proper typing
|
||||||
const wasmWrapper: PassportWASM = {
|
const wasmWrapper: PassportWASM = {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue