Docs / Client API · apps/web/src/lib/arkivzk-client.ts
Client API
Every screen of the web app talks to the Kalypso SDK through one browser-side module:
apps/web/src/lib/arkivzk-client.ts. The UI imports nothing else from the library, so this file
is the whole contract between the frontend and @arkivzk/sdk / the app's API routes.
All functions are async, run in the browser, and throw on failure. The UI shows the
error's message to the user as-is, so messages should be human readable.
Encrypts on device, commits, splits the key 2-of-3, uploads the optional file to Swarm, writes the record entity. onStep(s) is called with short human strings; the UI shows them as a live log.
listRecords()
Vault, Prove, Shred
Records known to this device. The UI shows status badges and "expires in X" from expiresAtMs.
getRecord(entityKey)
Vault → view
Reassembles the key and decrypts. If file is present the UI offers a download (and an inline preview for images).
The Vault form sends schemaId: "medical.v1" with values = { age: number, country: string, bloodGroup: string }
and retentionSeconds of 300 (5 minute demo), 1, 7, 30 or 180 days.
Generates the proof (takes seconds; the UI shows a live timer plus onStep messages) and publishes a proof entity. The UI builds the share link /verify/<proofEntityKey>.
Claims sent by the UI:
range: { field, min?, max? } (at least one bound, numbers only)
equality: { field, equals } (number if the input parses as a number, otherwise string)
For records with pendingShred: keys are gone, but the delete + receipt didn't publish. Same onStep semantics as shredRecords.
shredRecords(entityKeys, onStep)
onStep receives the full current step list each time (not a delta); the UI re-renders it as-is. Suggested steps: guardian 1 destroyed, guardian 2 destroyed, device share destroyed, Arkiv delete tx, receipt entity. Resolves with the receipt; the UI links /receipt/<receiptKey> and offers the receipt as a JSON erasure certificate download.
Reads the proof + record commitment from Arkiv and verifies. checks renders as a pass/fail checklist. recordStatus === "shredded" is shown as revoked even if the math checks out, with a link to receiptKey.
getReceipt(receiptKey)
/receipt/[key]
Reads a ShredReceipt and checks each guardian signature (valid). Shows keySharesRemainingAtMost.
erasureCertificate(receiptKey)
receipt card
Downloaded as JSON by "Download erasure certificate".
listArchive()
/archive
Raw calldata snapshots captured by the archive indexer.
tryDecryptArchived(txHash)
/archive
Tries to decrypt a snapshot with everything an archive node has. log lines are printed in a terminal view.
The site is served with Cross-Origin-Opener-Policy: same-origin and
Cross-Origin-Embedder-Policy: require-corp so the multithreaded WASM prover can use
SharedArrayBuffer. Any cross-origin resource the client loads (WASM, workers, scripts) must be
same-origin or send Cross-Origin-Resource-Policy / CORS headers.