demo-marketplace — "Brocante"
A second-hand marketplace where publishing a listing requires a verified identity. Node 18+, node:http
only, TypeScript SDK through a file dependency ("@maclustr/identity": "file:../../sdk/typescript").
bash
./setup.sh # builds the SDK if needed, npm install, provisions application + key + webhook, writes .env.local
npm start # http://localhost:8881| Where | What |
|---|---|
server.mjs → publishGate() |
the server-side gate (local record + live check, fail closed) |
server.mjs → POST /api/identity/session |
session creation with the secret key; only url is returned |
server.mjs → POST /webhooks/identity |
raw body, constructEvent, deduplication on event.id |
server.mjs → sessionEnded() |
verification.cancelled / .expired: the pending session is forgotten, a record still under review for it is closed, the user can start again |
server.mjs → storeVerification() |
the four stored fields, protection against late or replayed events |
public/app.js |
openVerification({ mode: "modal" }) from the browser SDK; no key |
public/index.html |
the badge and what it does and does not certify |
Environment: PORT, MLID_BASE_URL, MLID_SECRET_KEY, MLID_WEBHOOK_SECRET, DEMO_STATE_FILE
(default data/state.json), MLID_TIMEOUT_MS, MLID_MAX_RETRIES.
Demo shortcuts that must not be copied: the login is an unsigned cookie, the database is a JSON file, and
/api/debug/events exposes the webhook log for the end-to-end script.