Files
boc/aamos-ledger/ui/js/api.js
T
Bernt bae705aa97 ARCHITECTURE: NFC roadmap, edge AI, audit logging
- Add NFC ePassport roadmap (ICAO 9303, eIDAS)
- Add TensorFlow.js edge face detection (BlazeFace)
- Add structured audit logger (GDPR-compliant)
- Risk scoring support

Part of KYC Apple Native UX v1.1.0
2026-06-29 16:24:48 +00:00

42 lines
1.6 KiB
JavaScript

// ═══════════════════════════════════════════════════════════════════════════
// LandveX Finance — API Client
// ═══════════════════════════════════════════════════════════════════════════
export class API {
constructor(opts = {}) {
this.baseUrl = opts.baseUrl || '/api/ledger';
this.tenant = opts.tenant || 'landvex';
this.getToken = opts.getToken || (() => localStorage.getItem('lv_token'));
}
async request(method, path, body = null) {
const url = this.baseUrl + path;
const headers = {
'Content-Type': 'application/json',
'x-tenant-id': this.tenant,
};
const token = this.getToken();
if (token) headers['Authorization'] = `Bearer ${token}`;
const opts = { method, headers };
if (body) opts.body = JSON.stringify(body);
const res = await fetch(url, opts);
if (!res.ok) {
const err = new Error(`HTTP ${res.status}`);
err.status = res.status;
try { err.data = await res.json(); } catch {}
throw err;
}
return res.json();
}
get(path) { return this.request('GET', path); }
post(path, body) { return this.request('POST', path, body); }
put(path, body) { return this.request('PUT', path, body); }
delete(path) { return this.request('DELETE', path); }
}