xfina-wasm
v0.7.0
Published
Fast, privacy-first parser for Indian financial statements (ReBIT/AA standard)
Readme
Xfina (WASM Bindings)
Xfina is a blazingly fast WebAssembly (WASM) library for parsing Indian financial statements (Bank Accounts, Credit Cards, Mutual Funds) and international brokers (IBKR).
It runs 100% in the browser or Node.js, extracting structured data from raw PDFs, Excel files, and CSVs into ReBIT-compliant JSON objects without ever sending sensitive financial data to a server.
Installation
npm install xfina-wasmQuick Start (Browser / Vite)
import init, { parse, detect, formats, version } from "xfina-wasm";
await init();
// Hand over the bytes; the format is worked out from the content.
const result = parse(fileBytes, {
filename: file.name, // used as an ordering hint, never as proof
password: null, // required for encrypted PDFs
modifiedTimestamp: 1750000000, // last-resort statement date
as: null, // pin a format id to skip detection
schema: "xfina", // or "rebit"
});
if (result.error) {
// Failures arrive in the envelope rather than as a thrown value, so a
// caller branches on `kind` instead of matching on message text.
if (result.error.kind === "password_required") {
promptForPassword(result.error.filename_hint); // e.g. "mf-cams"
}
} else {
result.format; // "ba-hdfc"
result.category; // "bank_account"
result.institution; // "HDFC Bank"
result.detection; // how it was identified, plus the file's own metadata
result.validation; // the two-level validation report
result.data; // the account, in the requested schema
}The four functions
| Function | Purpose |
|---|---|
| parse(bytes, options) | Identify and parse a statement. Returns the envelope, or { error }. |
| detect(bytes, options) | Identify a statement without parsing it. |
| formats() | Every format this build knows, with id, category, institution, containers and enabled. Build your UI from this rather than a hardcoded list. |
| version() | The version of the parsers actually running. |
Error kinds: password_required, incorrect_password, unrecognized_format,
invalid_format, parse_error, unsupported, format_not_enabled, io.
