UNPKG

@arcjet/redact-wasm

Version:

Arcjet sensitive information redaction detection engine

35 lines (32 loc) 1.26 kB
import { instantiate } from './wasm/arcjet_analyze_bindings_redact.component.js'; import componentCoreWasm from './wasm/arcjet_analyze_bindings_redact.component.core.wasm'; import componentCore2Wasm from './wasm/arcjet_analyze_bindings_redact.component.core2.wasm'; import componentCore3Wasm from './wasm/arcjet_analyze_bindings_redact.component.core3.wasm'; async function moduleFromPath(path) { if (path === "arcjet_analyze_bindings_redact.component.core.wasm") { return componentCoreWasm; } if (path === "arcjet_analyze_bindings_redact.component.core2.wasm") { return componentCore2Wasm; } if (path === "arcjet_analyze_bindings_redact.component.core3.wasm") { return componentCore3Wasm; } throw new Error(`Unknown path: ${path}`); } async function initializeWasm(detect, replace) { const coreImports = { "arcjet:redact/custom-redact": { detectSensitiveInfo: detect, redactSensitiveInfo: replace, }, }; try { // Await the instantiation to catch the failure return await instantiate(moduleFromPath, coreImports); } catch { console.debug("WebAssembly is not supported in this runtime"); } } export { initializeWasm };