UNPKG

@arcjet/redact-wasm

Version:

Arcjet sensitive information redaction detection engine

38 lines (35 loc) 1.41 kB
import { instantiate } from './wasm/arcjet_analyze_bindings_redact.component.js'; import { wasm } from './_virtual/arcjet_analyze_bindings_redact.component.core.js'; import { wasm as wasm$1 } from './_virtual/arcjet_analyze_bindings_redact.component.core2.js'; import { wasm as wasm$2 } from './_virtual/arcjet_analyze_bindings_redact.component.core3.js'; const componentCoreWasmPromise = wasm(); const componentCore2WasmPromise = wasm$1(); const componentCore3WasmPromise = wasm$2(); async function moduleFromPath(path) { if (path === "arcjet_analyze_bindings_redact.component.core.wasm") { return componentCoreWasmPromise; } if (path === "arcjet_analyze_bindings_redact.component.core2.wasm") { return componentCore2WasmPromise; } if (path === "arcjet_analyze_bindings_redact.component.core3.wasm") { return componentCore3WasmPromise; } 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 };