@zanii/blackbox 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -1
- package/dist/a2a/index.d.ts +27 -0
- package/dist/a2a/index.js +104 -1
- package/dist/agents/index.d.ts +8 -0
- package/dist/analysis/accuracy.d.ts +24 -0
- package/dist/analysis/accuracy.js +45 -0
- package/dist/analysis/credential.d.ts +101 -0
- package/dist/analysis/credential.js +142 -0
- package/dist/analysis/faults.js +115 -0
- package/dist/analysis/grounding.d.ts +122 -0
- package/dist/analysis/grounding.js +445 -0
- package/dist/analysis/hallucination.d.ts +32 -0
- package/dist/analysis/hallucination.js +357 -0
- package/dist/analysis/index.d.ts +23 -0
- package/dist/analysis/index.js +93 -0
- package/dist/analysis/memory.d.ts +8 -0
- package/dist/analysis/memory.js +35 -8
- package/dist/analysis/reference.d.ts +49 -0
- package/dist/analysis/reference.js +164 -0
- package/dist/analysis/taxonomy.js +1 -0
- package/dist/approvals/index.d.ts +23 -0
- package/dist/approvals/index.js +48 -0
- package/dist/archive/parquet.d.ts +2 -0
- package/dist/archive/parquet.js +185 -0
- package/dist/badge/index.d.ts +16 -0
- package/dist/badge/index.js +48 -0
- package/dist/bom/index.js +20 -0
- package/dist/cli.js +114 -10
- package/dist/compliance/art12.js +36 -9
- package/dist/compliance/index.d.ts +36 -2
- package/dist/compliance/index.js +78 -11
- package/dist/compliance/zanii.d.ts +29 -0
- package/dist/compliance/zanii.js +84 -0
- package/dist/constitution/index.d.ts +57 -0
- package/dist/constitution/index.js +131 -0
- package/dist/cv/index.d.ts +39 -0
- package/dist/cv/index.js +108 -0
- package/dist/disclosure/index.d.ts +31 -0
- package/dist/disclosure/index.js +113 -0
- package/dist/encryption/index.d.ts +9 -0
- package/dist/encryption/index.js +31 -0
- package/dist/evidence/index.d.ts +60 -0
- package/dist/evidence/index.js +151 -0
- package/dist/federation/index.d.ts +35 -0
- package/dist/federation/index.js +102 -0
- package/dist/finance/index.d.ts +126 -0
- package/dist/finance/index.js +320 -0
- package/dist/fleet/index.js +9 -0
- package/dist/gov/index.d.ts +108 -0
- package/dist/gov/index.js +225 -0
- package/dist/health/index.d.ts +120 -0
- package/dist/health/index.js +233 -0
- package/dist/index.d.ts +28 -6
- package/dist/index.js +28 -6
- package/dist/memory/index.d.ts +36 -0
- package/dist/memory/index.js +85 -0
- package/dist/occurrence/index.d.ts +11 -0
- package/dist/occurrence/index.js +18 -0
- package/dist/otlp/index.js +28 -1
- package/dist/packs/index.js +44 -4
- package/dist/policy/delta.js +7 -1
- package/dist/policy/index.d.ts +23 -6
- package/dist/policy/index.js +151 -8
- package/dist/policy/zanii.d.ts +31 -0
- package/dist/policy/zanii.js +87 -0
- package/dist/pq/index.d.ts +23 -0
- package/dist/pq/index.js +104 -0
- package/dist/search/index.d.ts +23 -0
- package/dist/search/index.js +69 -0
- package/dist/session/index.d.ts +89 -1
- package/dist/session/index.js +143 -11
- package/dist/sla/index.d.ts +61 -0
- package/dist/sla/index.js +197 -0
- package/dist/succession/index.d.ts +50 -0
- package/dist/succession/index.js +123 -0
- package/dist/tokens/index.d.ts +6 -0
- package/dist/tokens/index.js +46 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/walls/index.d.ts +31 -0
- package/dist/walls/index.js +119 -0
- package/package.json +1 -1
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
// The court evidence pack (spec/investigations.md §7): why a court, or an expert it appoints, can
|
|
2
|
+
// rely on a record, and how to check it without trusting the operator. Arabic and English. Pure;
|
|
3
|
+
// mirrors sdks/python/src/zanii_blackbox/evidence.py; pinned by spec/vectors/evidence-pack.json.
|
|
4
|
+
import { hashLine } from "../verify/envelope.js";
|
|
5
|
+
const LEGAL_BASIS = {
|
|
6
|
+
en: "Under UAE Federal Decree-Law No. 46 of 2021 on Electronic Transactions and Trust Services, an electronic record and an electronic signature have legal effect and may be admitted as evidence. This pack lets a court, or an expert it appoints, check the record's integrity and origin independently, without relying on the operator. It maps the evidence; it is not legal advice.",
|
|
7
|
+
ar: "بموجب المرسوم بقانون اتحادي رقم 46 لسنة 2021 في شأن المعاملات الإلكترونية وخدمات الثقة، يكون للسجل الإلكتروني والتوقيع الإلكتروني أثر قانوني ويجوز قبولهما دليلًا. تتيح هذه الحزمة للمحكمة، أو لخبير تعيّنه، التحقق المستقل من سلامة السجل ومصدره دون الاعتماد على المشغّل. هي بيان للأدلة، وليست استشارة قانونية.",
|
|
8
|
+
};
|
|
9
|
+
const STEPS = [
|
|
10
|
+
{
|
|
11
|
+
en: "The hash chain: each event's hash covers its content and the previous event's hash (SHA-256 over RFC 8785 JSON). Recomputing them gives the last hash shown above.",
|
|
12
|
+
ar: "سلسلة التجزئة: تجزئة كل حدث تشمل محتواه وتجزئة الحدث السابق (SHA-256 على JSON وفق RFC 8785). إعادة حسابها تعطي آخر تجزئة المذكورة أعلاه.",
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
en: "The bodies: each body's SHA-256 matches the hash its event recorded. An erased body is gone, but its hash stays, so the chain still checks.",
|
|
16
|
+
ar: "المحتوى: تطابق تجزئة SHA-256 لكل محتوى التجزئةَ التي سجّلها حدثه. المحتوى الممحوّ لم يعد موجودًا، لكن تجزئته باقية، فتبقى السلسلة قابلة للتحقق.",
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
en: "The anchors: each ledger receipt commits to the session, its number of events and its last hash, and is signed by the gateway's DID under a delegation from its owner.",
|
|
20
|
+
ar: "التثبيت: كل إيصال في دفتر الأستاذ يلتزم بالجلسة وعدد أحداثها وآخر تجزئة لها، وموقّع بهوية البوابة (DID) بتفويض من مالكها.",
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
en: "The ledger: each receipt is in the ledger's Merkle log (an inclusion proof) under a signed tree head, and the log only ever grew.",
|
|
24
|
+
ar: "دفتر الأستاذ: كل إيصال مُدرَج في سجل ميركل الخاص بدفتر الأستاذ (إثبات إدراج) تحت رأس شجرة موقّع، والسجل لم يزد إلا نموًّا.",
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
en: "The gateway's own log, when present: the session's signed statement, its inclusion in the gateway's transparency log, the witnesses' cosignatures and the RFC 3161 time-stamp.",
|
|
28
|
+
ar: "سجل البوابة نفسها، إن وُجد: البيان الموقّع للجلسة، وإدراجه في سجل الشفافية للبوابة، وتواقيع الشهود المشتركة، والختم الزمني وفق RFC 3161.",
|
|
29
|
+
},
|
|
30
|
+
];
|
|
31
|
+
const REPRODUCE = [
|
|
32
|
+
"npx @zanii/blackbox verify bundle.json --proofs",
|
|
33
|
+
"pip install zanii-blackbox && blackbox verify bundle.json --proofs",
|
|
34
|
+
];
|
|
35
|
+
const parse = (line) => {
|
|
36
|
+
try {
|
|
37
|
+
return JSON.parse(line);
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
return {};
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
/** spec/investigations.md §7. */
|
|
44
|
+
export function evidencePack(bundle, report, opts) {
|
|
45
|
+
const lines = bundle.lines;
|
|
46
|
+
const first = lines.length ? parse(lines[0]) : {};
|
|
47
|
+
const last = lines.length ? parse(lines.at(-1)) : {};
|
|
48
|
+
const open = first.kind === "session.open" ? first : {};
|
|
49
|
+
const newest = bundle.anchors.at(-1);
|
|
50
|
+
const t = bundle.transparency;
|
|
51
|
+
const proofs = report.proofs === null || opts.proofs === "not_checked"
|
|
52
|
+
? "not_checked"
|
|
53
|
+
: report.proofs.every((p) => p.ok)
|
|
54
|
+
? "checked"
|
|
55
|
+
: "failed";
|
|
56
|
+
return {
|
|
57
|
+
v: 1,
|
|
58
|
+
kind: "blackbox-evidence-pack",
|
|
59
|
+
session_id: bundle.session.session_id,
|
|
60
|
+
label: typeof bundle.session.label === "string" ? bundle.session.label : null,
|
|
61
|
+
agent: open.meta?.agent ?? null,
|
|
62
|
+
anchored_by: bundle.anchored_by,
|
|
63
|
+
ledger_url: bundle.ledger_url,
|
|
64
|
+
record: {
|
|
65
|
+
events: lines.length,
|
|
66
|
+
head: lines.length ? hashLine(lines.at(-1)) : null,
|
|
67
|
+
first_at: typeof first.ts === "string" ? first.ts : null,
|
|
68
|
+
last_at: typeof last.ts === "string" ? last.ts : null,
|
|
69
|
+
closed: last.kind === "session.close",
|
|
70
|
+
},
|
|
71
|
+
anchors: {
|
|
72
|
+
count: bundle.anchors.length,
|
|
73
|
+
last: newest
|
|
74
|
+
? {
|
|
75
|
+
count: newest.count,
|
|
76
|
+
receipt_hash: newest.receipt_hash,
|
|
77
|
+
anchored_at: newest.anchored_at,
|
|
78
|
+
}
|
|
79
|
+
: null,
|
|
80
|
+
},
|
|
81
|
+
transparency: t
|
|
82
|
+
? {
|
|
83
|
+
statement: t.statement !== undefined,
|
|
84
|
+
receipt: t.receipt !== undefined,
|
|
85
|
+
checkpoint: t.checkpoint !== undefined,
|
|
86
|
+
timestamp: t.timestamp !== undefined,
|
|
87
|
+
}
|
|
88
|
+
: null,
|
|
89
|
+
verified: report.ok,
|
|
90
|
+
verification: {
|
|
91
|
+
chain: report.chain.ok ? "ok" : report.chain.code,
|
|
92
|
+
identity: report.identity.ok ? "ok" : "mismatch",
|
|
93
|
+
proofs,
|
|
94
|
+
},
|
|
95
|
+
legal_basis: LEGAL_BASIS,
|
|
96
|
+
steps: STEPS.map((s, i) => ({ n: i + 1, ...s })),
|
|
97
|
+
reproduce: REPRODUCE,
|
|
98
|
+
generated_at: opts.generated_at,
|
|
99
|
+
bundle_sha256: opts.bundle_sha256,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
// U+2067 … U+2069 isolate the Arabic paragraphs, so they read right to left in any viewer.
|
|
103
|
+
const rtl = (s) => `${s}`;
|
|
104
|
+
/** The Markdown copy (spec/investigations.md §7): `en`, `ar` or `both`. */
|
|
105
|
+
export function renderEvidencePack(pack, lang = "both") {
|
|
106
|
+
const show = (b) => lang === "en" ? b.en : lang === "ar" ? rtl(b.ar) : `${b.en}\n\n> ${rtl(b.ar)}`;
|
|
107
|
+
const label = (en, ar) => lang === "en" ? en : lang === "ar" ? rtl(ar) : `${en} / ${rtl(ar)}`;
|
|
108
|
+
const r = pack.record;
|
|
109
|
+
const verdict = pack.verified
|
|
110
|
+
? label("VERIFIED", "تم التحقق")
|
|
111
|
+
: label("FAILED VERIFICATION", "فشل التحقق");
|
|
112
|
+
const rows = [
|
|
113
|
+
[label("Session", "الجلسة"), `\`${pack.session_id}\``],
|
|
114
|
+
[label("Label", "التسمية"), pack.label ? pack.label.replaceAll("|", "\\|") : "—"],
|
|
115
|
+
[label("Events", "الأحداث"), String(r.events)],
|
|
116
|
+
[label("Last hash", "آخر تجزئة"), r.head ? `\`${r.head}\`` : "—"],
|
|
117
|
+
[label("Period", "المدة"), `${r.first_at ?? "—"} → ${r.last_at ?? "—"}`],
|
|
118
|
+
[label("Closed", "مغلقة"), r.closed ? label("yes", "نعم") : label("no", "لا")],
|
|
119
|
+
[label("Anchored by", "ثبّتها"), pack.anchored_by ? `\`${pack.anchored_by}\`` : "—"],
|
|
120
|
+
[label("Anchors", "التثبيتات"), String(pack.anchors.count)],
|
|
121
|
+
[label("Chain", "السلسلة"), pack.verification.chain],
|
|
122
|
+
[label("Identity", "الهوية"), pack.verification.identity],
|
|
123
|
+
[label("Ledger proofs", "إثباتات دفتر الأستاذ"), pack.verification.proofs],
|
|
124
|
+
[label("Bundle SHA-256", "تجزئة الحزمة"), `\`${pack.bundle_sha256}\``],
|
|
125
|
+
[label("Generated", "أُنشئت"), pack.generated_at],
|
|
126
|
+
];
|
|
127
|
+
return [
|
|
128
|
+
`# ${label("Evidence pack", "حزمة الأدلة")}`,
|
|
129
|
+
"",
|
|
130
|
+
`**${verdict}**`,
|
|
131
|
+
"",
|
|
132
|
+
`| | |`,
|
|
133
|
+
`|---|---|`,
|
|
134
|
+
...rows.map(([k, v]) => `| ${k} | ${v} |`),
|
|
135
|
+
"",
|
|
136
|
+
`## ${label("Legal basis", "الأساس القانوني")}`,
|
|
137
|
+
"",
|
|
138
|
+
show(pack.legal_basis),
|
|
139
|
+
"",
|
|
140
|
+
`## ${label("How to check it", "خطوات التحقق")}`,
|
|
141
|
+
"",
|
|
142
|
+
...pack.steps.map((s) => `${s.n}. ${show(s)}`),
|
|
143
|
+
"",
|
|
144
|
+
`## ${label("Reproduce offline", "إعادة التحقق دون اتصال")}`,
|
|
145
|
+
"",
|
|
146
|
+
"```sh",
|
|
147
|
+
...pack.reproduce,
|
|
148
|
+
"```",
|
|
149
|
+
"",
|
|
150
|
+
].join("\n");
|
|
151
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type SignedTreeHead } from "@zanii/core";
|
|
2
|
+
/** Zanii's witness co-signature over a signed tree head the caller has checked (signed, append-only). */
|
|
3
|
+
export declare function cosignLedgerSth(sth: SignedTreeHead, o: {
|
|
4
|
+
did: string;
|
|
5
|
+
privateKey: Uint8Array;
|
|
6
|
+
}): {
|
|
7
|
+
v: number;
|
|
8
|
+
witnessed_log_id: string;
|
|
9
|
+
cosignature: SignedTreeHead;
|
|
10
|
+
};
|
|
11
|
+
/** Zanii's check: a valid co-signature over the same (size, root) of a valid tree head. */
|
|
12
|
+
export declare function verifyLedgerCosignature(c: unknown, sth: SignedTreeHead): boolean;
|
|
13
|
+
/** Zanii's equivocation proof: one log key, one size, two roots. Throws unless it really is one. */
|
|
14
|
+
export declare function buildEquivocationProof(a: SignedTreeHead, b: SignedTreeHead): {
|
|
15
|
+
v: number;
|
|
16
|
+
type: string;
|
|
17
|
+
log_id: string;
|
|
18
|
+
size: number;
|
|
19
|
+
sths: SignedTreeHead[];
|
|
20
|
+
};
|
|
21
|
+
/** Re-checks a proof from scratch: both signatures, same log, same size, different roots. */
|
|
22
|
+
export declare function verifyEquivocationProof(proof: unknown): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Zanii's gossip comparison over views already fetched: views of other logs and bad signatures
|
|
25
|
+
* are set aside, and two valid views at one size with different roots are an equivocation proof.
|
|
26
|
+
*/
|
|
27
|
+
export declare function compareViews(logId: string, views: ReadonlyArray<{
|
|
28
|
+
source: string;
|
|
29
|
+
sth?: unknown;
|
|
30
|
+
error?: string;
|
|
31
|
+
}>): {
|
|
32
|
+
ok: boolean;
|
|
33
|
+
reasons: string[];
|
|
34
|
+
equivocation?: ReturnType<typeof buildEquivocationProof>;
|
|
35
|
+
};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
// Witnessing and federation (spec/anchoring.md §12): the gateway as an independent witness that
|
|
2
|
+
// co-signs the ledger's signed tree heads it checked, and gossip that turns a split view into an
|
|
3
|
+
// equivocation proof (@zanii/witness, @zanii/federation). Pure; mirrors
|
|
4
|
+
// sdks/python/src/zanii_blackbox/federation.py; pinned by spec/vectors/federation.json.
|
|
5
|
+
import { createSTH, verifySTH } from "@zanii/core";
|
|
6
|
+
const valid = (sth) => {
|
|
7
|
+
try {
|
|
8
|
+
return typeof sth === "object" && sth !== null && verifySTH(sth);
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
/** Zanii's witness co-signature over a signed tree head the caller has checked (signed, append-only). */
|
|
15
|
+
export function cosignLedgerSth(sth, o) {
|
|
16
|
+
if (!valid(sth))
|
|
17
|
+
throw new Error("refusing to co-sign: the signed tree head doesn't verify");
|
|
18
|
+
const cosignature = createSTH({ logId: o.did, size: sth.size, root: sth.root, ts: sth.ts }, o.privateKey);
|
|
19
|
+
return { v: 1, witnessed_log_id: sth.log_id, cosignature };
|
|
20
|
+
}
|
|
21
|
+
/** Zanii's check: a valid co-signature over the same (size, root) of a valid tree head. */
|
|
22
|
+
export function verifyLedgerCosignature(c, sth) {
|
|
23
|
+
const p = (c ?? {});
|
|
24
|
+
const cs = p.cosignature;
|
|
25
|
+
if (p.v !== 1 || !cs || typeof cs !== "object" || p.witnessed_log_id !== sth.log_id)
|
|
26
|
+
return false;
|
|
27
|
+
return valid(sth) && valid(cs) && cs.size === sth.size && cs.root === sth.root;
|
|
28
|
+
}
|
|
29
|
+
/** Zanii's equivocation proof: one log key, one size, two roots. Throws unless it really is one. */
|
|
30
|
+
export function buildEquivocationProof(a, b) {
|
|
31
|
+
if (a.log_id !== b.log_id)
|
|
32
|
+
throw new Error("not equivocation: different logs");
|
|
33
|
+
if (a.size !== b.size)
|
|
34
|
+
throw new Error("not equivocation: different tree sizes (could be honest growth)");
|
|
35
|
+
if (a.root === b.root)
|
|
36
|
+
throw new Error("not equivocation: same root — the views agree");
|
|
37
|
+
if (!valid(a) || !valid(b))
|
|
38
|
+
throw new Error("not equivocation: an STH signature is invalid (a forgery proves nothing)");
|
|
39
|
+
const [x, y] = a.root < b.root ? [a, b] : [b, a];
|
|
40
|
+
return { v: 1, type: "federation.equivocation", log_id: a.log_id, size: a.size, sths: [x, y] };
|
|
41
|
+
}
|
|
42
|
+
/** Re-checks a proof from scratch: both signatures, same log, same size, different roots. */
|
|
43
|
+
export function verifyEquivocationProof(proof) {
|
|
44
|
+
const p = (proof ?? {});
|
|
45
|
+
const sths = p.sths;
|
|
46
|
+
if (p.v !== 1 ||
|
|
47
|
+
p.type !== "federation.equivocation" ||
|
|
48
|
+
!Array.isArray(sths) ||
|
|
49
|
+
sths.length !== 2)
|
|
50
|
+
return false;
|
|
51
|
+
const [a, b] = sths;
|
|
52
|
+
if (!a || !b || typeof a !== "object" || typeof b !== "object")
|
|
53
|
+
return false;
|
|
54
|
+
return (a.log_id === p.log_id &&
|
|
55
|
+
b.log_id === p.log_id &&
|
|
56
|
+
a.size === p.size &&
|
|
57
|
+
b.size === p.size &&
|
|
58
|
+
a.root !== b.root &&
|
|
59
|
+
valid(a) &&
|
|
60
|
+
valid(b));
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Zanii's gossip comparison over views already fetched: views of other logs and bad signatures
|
|
64
|
+
* are set aside, and two valid views at one size with different roots are an equivocation proof.
|
|
65
|
+
*/
|
|
66
|
+
export function compareViews(logId, views) {
|
|
67
|
+
const reasons = [];
|
|
68
|
+
const bySize = new Map();
|
|
69
|
+
let usable = 0;
|
|
70
|
+
for (const v of views) {
|
|
71
|
+
const sth = v.sth;
|
|
72
|
+
if (sth === undefined || sth === null) {
|
|
73
|
+
reasons.push(`${v.source}: unreachable (${v.error})`);
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
if (typeof sth !== "object") {
|
|
77
|
+
reasons.push(`${v.source}: not a signed tree head`);
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
const s = sth;
|
|
81
|
+
if (s.log_id !== logId) {
|
|
82
|
+
reasons.push(`${v.source}: serves a different log (${String(s.log_id)})`);
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
if (!valid(s)) {
|
|
86
|
+
reasons.push(`${v.source}: the signature doesn't verify`);
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
usable++;
|
|
90
|
+
const seen = bySize.get(s.size);
|
|
91
|
+
if (seen && seen.sth.root !== s.root) {
|
|
92
|
+
const equivocation = buildEquivocationProof(seen.sth, s);
|
|
93
|
+
reasons.push(`split view: ${seen.source} and ${v.source} show different roots at size ${s.size}`);
|
|
94
|
+
return { ok: false, reasons, equivocation };
|
|
95
|
+
}
|
|
96
|
+
if (!seen)
|
|
97
|
+
bySize.set(s.size, { source: v.source, sth: s });
|
|
98
|
+
}
|
|
99
|
+
if (usable === 0)
|
|
100
|
+
reasons.push("no usable views");
|
|
101
|
+
return { ok: usable > 0, reasons };
|
|
102
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
type Obj = Record<string, unknown>;
|
|
2
|
+
/** Minor-unit precision: Zanii's table, plus the Gulf's currencies. */
|
|
3
|
+
export declare const CURRENCIES: Readonly<Record<string, number>>;
|
|
4
|
+
/** Zanii's exact parse: a decimal string to minor units (a string), never a float. */
|
|
5
|
+
export declare function parseMoney(amount: string | number, currency: string): {
|
|
6
|
+
currency: string;
|
|
7
|
+
minor: string;
|
|
8
|
+
display: string;
|
|
9
|
+
};
|
|
10
|
+
export declare const formatMoney: (minor: string | number | bigint, currency: string) => string;
|
|
11
|
+
/** Zanii's payment receipt payload. No settlement reference, no payment. */
|
|
12
|
+
export declare function buildPayment(input: {
|
|
13
|
+
rail: string;
|
|
14
|
+
reference: string;
|
|
15
|
+
amount: string | number;
|
|
16
|
+
currency: string;
|
|
17
|
+
from?: string;
|
|
18
|
+
to?: string;
|
|
19
|
+
memo?: string;
|
|
20
|
+
extra?: Obj;
|
|
21
|
+
}): {
|
|
22
|
+
target: string;
|
|
23
|
+
rail: string;
|
|
24
|
+
reference: string;
|
|
25
|
+
money: {
|
|
26
|
+
currency: string;
|
|
27
|
+
minor: string;
|
|
28
|
+
display: string;
|
|
29
|
+
};
|
|
30
|
+
from: string | null;
|
|
31
|
+
to: string | null;
|
|
32
|
+
memo: string | null;
|
|
33
|
+
extra: Obj | null;
|
|
34
|
+
};
|
|
35
|
+
/** Zanii's KYA screen, offline: the DID or its owner on a deny list is a hit. */
|
|
36
|
+
export declare function screenCounterparty(did: string, opts?: {
|
|
37
|
+
denyList?: readonly string[];
|
|
38
|
+
owner?: string;
|
|
39
|
+
}): {
|
|
40
|
+
did: string;
|
|
41
|
+
owner: string | null;
|
|
42
|
+
ok: boolean;
|
|
43
|
+
hits: {
|
|
44
|
+
source: string;
|
|
45
|
+
detail: string;
|
|
46
|
+
}[];
|
|
47
|
+
history: null;
|
|
48
|
+
};
|
|
49
|
+
/** Zanii's kya.screening payload for a screening result. */
|
|
50
|
+
export declare function screeningPayload(result: ReturnType<typeof screenCounterparty>, ts: string, screenedBy?: string | null): {
|
|
51
|
+
_zr_kind: string;
|
|
52
|
+
v: number;
|
|
53
|
+
did: string;
|
|
54
|
+
owner: string | null;
|
|
55
|
+
ok: boolean;
|
|
56
|
+
hits: {
|
|
57
|
+
source: string;
|
|
58
|
+
detail: string;
|
|
59
|
+
}[];
|
|
60
|
+
sources: string[];
|
|
61
|
+
screened_by: string | null;
|
|
62
|
+
ts: string;
|
|
63
|
+
};
|
|
64
|
+
export declare const FTA_WALL_ID = "fta-prepares-never-files";
|
|
65
|
+
/** Zanii's FTA payloads: a filing prepared (never filed), and its hand-off to a Tax Agent. */
|
|
66
|
+
export declare function ftaPayload(input: {
|
|
67
|
+
action: "prepared" | "handoff";
|
|
68
|
+
filingType: string;
|
|
69
|
+
period: string;
|
|
70
|
+
by: string;
|
|
71
|
+
toTaxAgent?: string;
|
|
72
|
+
filingRef?: string;
|
|
73
|
+
manifestHash?: string;
|
|
74
|
+
}): Obj;
|
|
75
|
+
/** Zanii's kyb.attestation: an owner DID signs which domain and legal entity it is. */
|
|
76
|
+
export declare function buildOwnerAttestation(input: {
|
|
77
|
+
did: string;
|
|
78
|
+
domain: string;
|
|
79
|
+
entity: {
|
|
80
|
+
name: string;
|
|
81
|
+
jurisdiction?: string;
|
|
82
|
+
registration?: string;
|
|
83
|
+
};
|
|
84
|
+
ts: string;
|
|
85
|
+
ownerPrivateKey: Uint8Array;
|
|
86
|
+
}): {
|
|
87
|
+
v: number;
|
|
88
|
+
type: string;
|
|
89
|
+
did: string;
|
|
90
|
+
domain: string;
|
|
91
|
+
entity: {
|
|
92
|
+
name: string;
|
|
93
|
+
jurisdiction?: string;
|
|
94
|
+
registration?: string;
|
|
95
|
+
};
|
|
96
|
+
ts: string;
|
|
97
|
+
sig: string;
|
|
98
|
+
};
|
|
99
|
+
export declare function verifyOwnerAttestation(a: unknown): boolean;
|
|
100
|
+
/** Zanii's two-way check: the owner signed it, and the domain's own doc lists that owner. */
|
|
101
|
+
export declare function verifyOwnerBinding(attestation: unknown, doc: unknown): {
|
|
102
|
+
ok: boolean;
|
|
103
|
+
reasons: string[];
|
|
104
|
+
entity: Obj | null;
|
|
105
|
+
};
|
|
106
|
+
export declare function financeFindings(lines: readonly string[], bodies: (hash: string) => Uint8Array | undefined, closing?: boolean): {
|
|
107
|
+
code: string;
|
|
108
|
+
source: string;
|
|
109
|
+
severity: "warning" | "advisory";
|
|
110
|
+
ref: Record<string, string | number>;
|
|
111
|
+
detail: string;
|
|
112
|
+
}[];
|
|
113
|
+
/** spec/finance.md §2: the session's payments, and exact totals per currency (minor units). */
|
|
114
|
+
export declare function paymentsOf(lines: readonly string[], bodies: (hash: string) => Uint8Array | undefined): {
|
|
115
|
+
payments: {
|
|
116
|
+
seq: number;
|
|
117
|
+
rail: unknown;
|
|
118
|
+
reference: unknown;
|
|
119
|
+
money: Obj;
|
|
120
|
+
to: unknown;
|
|
121
|
+
}[];
|
|
122
|
+
totals: {
|
|
123
|
+
[k: string]: string;
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
export {};
|