@goodmeta/agent-verifier 0.2.0 → 0.5.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 +67 -26
- package/dist/ap2/chain.d.ts +43 -0
- package/dist/ap2/chain.d.ts.map +1 -0
- package/dist/ap2/chain.js +100 -0
- package/dist/ap2/chain.js.map +1 -0
- package/dist/ap2/chains.d.ts +68 -0
- package/dist/ap2/chains.d.ts.map +1 -0
- package/dist/ap2/chains.js +119 -0
- package/dist/ap2/chains.js.map +1 -0
- package/dist/ap2/constraints.d.ts +32 -0
- package/dist/ap2/constraints.d.ts.map +1 -0
- package/dist/ap2/constraints.js +222 -0
- package/dist/ap2/constraints.js.map +1 -0
- package/dist/ap2/hash.d.ts +23 -0
- package/dist/ap2/hash.d.ts.map +1 -0
- package/dist/ap2/hash.js +54 -0
- package/dist/ap2/hash.js.map +1 -0
- package/dist/ap2/index.d.ts +28 -0
- package/dist/ap2/index.d.ts.map +1 -0
- package/dist/ap2/index.js +35 -0
- package/dist/ap2/index.js.map +1 -0
- package/dist/ap2/jwk.d.ts +24 -0
- package/dist/ap2/jwk.d.ts.map +1 -0
- package/dist/ap2/jwk.js +29 -0
- package/dist/ap2/jwk.js.map +1 -0
- package/dist/ap2/kb-sd-jwt.d.ts +44 -0
- package/dist/ap2/kb-sd-jwt.d.ts.map +1 -0
- package/dist/ap2/kb-sd-jwt.js +97 -0
- package/dist/ap2/kb-sd-jwt.js.map +1 -0
- package/dist/ap2/keys.d.ts +41 -0
- package/dist/ap2/keys.d.ts.map +1 -0
- package/dist/ap2/keys.js +114 -0
- package/dist/ap2/keys.js.map +1 -0
- package/dist/ap2/max-flow.d.ts +26 -0
- package/dist/ap2/max-flow.d.ts.map +1 -0
- package/dist/ap2/max-flow.js +173 -0
- package/dist/ap2/max-flow.js.map +1 -0
- package/dist/ap2/parse.d.ts +35 -0
- package/dist/ap2/parse.d.ts.map +1 -0
- package/dist/ap2/parse.js +78 -0
- package/dist/ap2/parse.js.map +1 -0
- package/dist/ap2/sd-jwt.d.ts +83 -0
- package/dist/ap2/sd-jwt.d.ts.map +1 -0
- package/dist/ap2/sd-jwt.js +306 -0
- package/dist/ap2/sd-jwt.js.map +1 -0
- package/dist/ap2/types.d.ts +270 -0
- package/dist/ap2/types.d.ts.map +1 -0
- package/dist/ap2/types.js +141 -0
- package/dist/ap2/types.js.map +1 -0
- package/dist/client.d.ts +152 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +171 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +30 -0
- package/dist/index.js.map +1 -0
- package/dist/policy.d.ts +45 -0
- package/dist/policy.d.ts.map +1 -0
- package/dist/policy.js +88 -0
- package/dist/policy.js.map +1 -0
- package/dist/receipt-jwt.d.ts +30 -0
- package/dist/receipt-jwt.d.ts.map +1 -0
- package/dist/receipt-jwt.js +39 -0
- package/dist/receipt-jwt.js.map +1 -0
- package/dist/schema.d.ts +41 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +50 -0
- package/dist/schema.js.map +1 -0
- package/dist/types.d.ts +116 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +8 -0
- package/dist/types.js.map +1 -0
- package/dist/verify.d.ts +24 -0
- package/dist/verify.d.ts.map +1 -0
- package/dist/verify.js +69 -0
- package/dist/verify.js.map +1 -0
- package/package.json +14 -7
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Root SD-JWT verification + disclosure resolution.
|
|
3
|
+
*
|
|
4
|
+
* Signatures: verified by jose, ES256-pinned, key supplied out-of-band — never
|
|
5
|
+
* by a disclosure library, never resolving a header `jwk`/`jku`/`x5u`/`kid`.
|
|
6
|
+
*
|
|
7
|
+
* Disclosure resolution mirrors AP2's actual reference behavior, which is a
|
|
8
|
+
* hybrid of THREE layers (AP2's golden vectors are minted by the Python
|
|
9
|
+
* `sd_jwt` lib + AP2's own post-passes, so we mirror that exact stack, not the
|
|
10
|
+
* unrelated TS `@sd-jwt` lib):
|
|
11
|
+
*
|
|
12
|
+
* A. Standard RFC 9901 unpack — port of `sd_jwt` lib
|
|
13
|
+
* `SDJWTVerifier._unpack_disclosed_claims`: resolve `{"...": digest}` array
|
|
14
|
+
* elements ([salt, value]) and `_sd: [digest]` object members
|
|
15
|
+
* ([salt, name, value]) against the token's disclosures; strip `_sd` /
|
|
16
|
+
* `_sd_alg`; reject duplicate disclosure hashes, duplicate `_sd` digests,
|
|
17
|
+
* and duplicate disclosed keys. Only sha-256 (the lib rejects others).
|
|
18
|
+
* B. AP2 delegate-item resolution — port of `chain.py::_resolve_delegate_items`
|
|
19
|
+
* + `_inline_sd_claims`: walk a resolved `delegate_payload` array; for dict
|
|
20
|
+
* items, inline any remaining object-property `_sd` digests; decode any
|
|
21
|
+
* bare-string items into their dict value.
|
|
22
|
+
* C. CMWallet quirk — port of `kb_sd_jwt.py::_resolve_delegate_payload` +
|
|
23
|
+
* `_try_resolve_digest`: `delegate_payload` items that are bare digest
|
|
24
|
+
* STRINGS get replaced in place by the dict value of the matching
|
|
25
|
+
* disclosure (used by KB hops in P3).
|
|
26
|
+
*
|
|
27
|
+
* Validated byte-exact against `test/fixtures/ap2-vectors.json`
|
|
28
|
+
* (`expectedPayloads`), minted from AP2's own SDK.
|
|
29
|
+
*/
|
|
30
|
+
import { Buffer } from "node:buffer";
|
|
31
|
+
import { compactVerify } from "jose";
|
|
32
|
+
import { computeDisclosureDigest } from "./hash.js";
|
|
33
|
+
import { parseJwk } from "./jwk.js";
|
|
34
|
+
const SD_DIGESTS_KEY = "_sd";
|
|
35
|
+
const DIGEST_ALG_KEY = "_sd_alg";
|
|
36
|
+
const SD_LIST_PREFIX = "...";
|
|
37
|
+
const SUPPORTED_SD_ALG = "sha-256";
|
|
38
|
+
const ARRAY_DISCLOSURE_LEN = 2; // [salt, value]
|
|
39
|
+
const PROPERTY_DISCLOSURE_LEN = 3; // [salt, name, value]
|
|
40
|
+
function isPlainObject(value) {
|
|
41
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
42
|
+
}
|
|
43
|
+
function decodeDisclosure(disclosure) {
|
|
44
|
+
let decoded;
|
|
45
|
+
try {
|
|
46
|
+
decoded = JSON.parse(Buffer.from(disclosure, "base64url").toString("utf8"));
|
|
47
|
+
}
|
|
48
|
+
catch (e) {
|
|
49
|
+
throw new Error(`Cannot decode disclosure: ${e.message}`);
|
|
50
|
+
}
|
|
51
|
+
if (!Array.isArray(decoded)) {
|
|
52
|
+
throw new Error("Disclosure must decode to a JSON array");
|
|
53
|
+
}
|
|
54
|
+
return decoded;
|
|
55
|
+
}
|
|
56
|
+
// ── Layer A: standard RFC 9901 unpack (sd_jwt lib) ───────────────────────────
|
|
57
|
+
/**
|
|
58
|
+
* Map every disclosure to its decoded array, keyed by its digest. Mirrors
|
|
59
|
+
* `_create_hash_mappings`: a duplicate digest is an error.
|
|
60
|
+
*/
|
|
61
|
+
function buildDisclosureMap(disclosures, sdAlg) {
|
|
62
|
+
const map = new Map();
|
|
63
|
+
for (const d of disclosures) {
|
|
64
|
+
const digest = computeDisclosureDigest(d, sdAlg);
|
|
65
|
+
if (map.has(digest)) {
|
|
66
|
+
throw new Error(`Duplicate disclosure hash ${digest}`);
|
|
67
|
+
}
|
|
68
|
+
map.set(digest, decodeDisclosure(d));
|
|
69
|
+
}
|
|
70
|
+
return map;
|
|
71
|
+
}
|
|
72
|
+
/** `{"...": "<digest>"}` array-element form (RFC 9901 §4.2.4.1). */
|
|
73
|
+
function arrayElementDigest(el) {
|
|
74
|
+
if (!isPlainObject(el))
|
|
75
|
+
return null;
|
|
76
|
+
const keys = Object.keys(el);
|
|
77
|
+
if (keys.length === 1 && keys[0] === SD_LIST_PREFIX && typeof el[SD_LIST_PREFIX] === "string") {
|
|
78
|
+
return el[SD_LIST_PREFIX];
|
|
79
|
+
}
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Recursively replace disclosed digests with their values. Port of the
|
|
84
|
+
* `sd_jwt` lib `_unpack_disclosed_claims`. `dupCheck` tracks `_sd` digests
|
|
85
|
+
* across the whole payload so a reused digest is rejected.
|
|
86
|
+
*/
|
|
87
|
+
function unpack(claims, map, dupCheck) {
|
|
88
|
+
if (Array.isArray(claims)) {
|
|
89
|
+
const output = [];
|
|
90
|
+
for (const element of claims) {
|
|
91
|
+
const digest = arrayElementDigest(element);
|
|
92
|
+
if (digest !== null) {
|
|
93
|
+
const decoded = map.get(digest);
|
|
94
|
+
if (decoded !== undefined) {
|
|
95
|
+
if (decoded.length !== ARRAY_DISCLOSURE_LEN) {
|
|
96
|
+
throw new Error(`Array-element disclosure must be [salt, value], got length ${decoded.length}`);
|
|
97
|
+
}
|
|
98
|
+
output.push(unpack(decoded[1], map, dupCheck));
|
|
99
|
+
}
|
|
100
|
+
// undisclosed / decoy digest → element is omitted
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
output.push(unpack(element, map, dupCheck));
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return output;
|
|
107
|
+
}
|
|
108
|
+
if (isPlainObject(claims)) {
|
|
109
|
+
const preOutput = {};
|
|
110
|
+
for (const [k, v] of Object.entries(claims)) {
|
|
111
|
+
if (k !== SD_DIGESTS_KEY && k !== DIGEST_ALG_KEY) {
|
|
112
|
+
preOutput[k] = unpack(v, map, dupCheck);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
const sd = claims[SD_DIGESTS_KEY];
|
|
116
|
+
if (Array.isArray(sd)) {
|
|
117
|
+
for (const digest of sd) {
|
|
118
|
+
// Mirror the Python lib: every `_sd` entry is duplicate-tracked before
|
|
119
|
+
// the map lookup (even a non-string one), so a repeated digest is
|
|
120
|
+
// rejected regardless of type. Only string digests can match a real
|
|
121
|
+
// disclosure; others fall through (map.get returns undefined).
|
|
122
|
+
if (dupCheck.has(digest)) {
|
|
123
|
+
throw new Error(`Duplicate hash found in SD-JWT: ${String(digest)}`);
|
|
124
|
+
}
|
|
125
|
+
dupCheck.add(digest);
|
|
126
|
+
const decoded = typeof digest === "string" ? map.get(digest) : undefined;
|
|
127
|
+
if (decoded !== undefined) {
|
|
128
|
+
if (decoded.length !== PROPERTY_DISCLOSURE_LEN) {
|
|
129
|
+
throw new Error(`Object-property disclosure must be [salt, name, value], got length ${decoded.length}`);
|
|
130
|
+
}
|
|
131
|
+
const key = decoded[1];
|
|
132
|
+
if (key in preOutput) {
|
|
133
|
+
throw new Error(`Duplicate key found when unpacking disclosed claim: '${key}'`);
|
|
134
|
+
}
|
|
135
|
+
preOutput[key] = unpack(decoded[2], map, dupCheck);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return preOutput;
|
|
140
|
+
}
|
|
141
|
+
return claims;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Resolve all disclosures in an issuer-verified payload (Layer A). Mirrors
|
|
145
|
+
* `_extract_sd_claims`: rejects a non-sha-256 `_sd_alg` (the lib supports only
|
|
146
|
+
* sha-256), then unpacks.
|
|
147
|
+
*/
|
|
148
|
+
export function resolveDisclosures(payload, disclosures, sdAlg) {
|
|
149
|
+
if (sdAlg !== undefined && sdAlg !== SUPPORTED_SD_ALG) {
|
|
150
|
+
throw new Error(`Invalid hash algorithm: ${sdAlg} (only ${SUPPORTED_SD_ALG} supported)`);
|
|
151
|
+
}
|
|
152
|
+
const map = buildDisclosureMap(disclosures, sdAlg);
|
|
153
|
+
return unpack(payload, map, new Set());
|
|
154
|
+
}
|
|
155
|
+
// ── Layer C: CMWallet bare-digest-string resolution (kb_sd_jwt.py) ───────────
|
|
156
|
+
/** First disclosure whose digest equals `digest`, returned as its dict value. */
|
|
157
|
+
function tryResolveDigest(digest, disclosures, sdAlg) {
|
|
158
|
+
for (const disc of disclosures) {
|
|
159
|
+
if (computeDisclosureDigest(disc, sdAlg) !== digest)
|
|
160
|
+
continue;
|
|
161
|
+
let arr;
|
|
162
|
+
try {
|
|
163
|
+
arr = JSON.parse(Buffer.from(disc, "base64url").toString("utf8"));
|
|
164
|
+
}
|
|
165
|
+
catch {
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
if (!Array.isArray(arr))
|
|
169
|
+
continue;
|
|
170
|
+
const val = arr.length === ARRAY_DISCLOSURE_LEN ? arr[1] : arr.length === PROPERTY_DISCLOSURE_LEN ? arr[2] : null;
|
|
171
|
+
if (isPlainObject(val))
|
|
172
|
+
return val;
|
|
173
|
+
}
|
|
174
|
+
return null;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Resolve bare digest-string items inside `delegate_payload` in place. Port of
|
|
178
|
+
* `kb_sd_jwt.py::_resolve_delegate_payload`: dict items are left unchanged;
|
|
179
|
+
* string items are replaced by the matching disclosure's dict value (or kept
|
|
180
|
+
* as-is when no disclosure matches).
|
|
181
|
+
*/
|
|
182
|
+
export function resolveDelegatePayload(payload, token) {
|
|
183
|
+
const dp = payload["delegate_payload"];
|
|
184
|
+
if (!Array.isArray(dp) || token.disclosures.length === 0)
|
|
185
|
+
return;
|
|
186
|
+
payload["delegate_payload"] = dp.map((item) => {
|
|
187
|
+
if (isPlainObject(item))
|
|
188
|
+
return item;
|
|
189
|
+
if (typeof item === "string") {
|
|
190
|
+
const decoded = tryResolveDigest(item, token.disclosures, token.sdAlg);
|
|
191
|
+
return decoded ?? item;
|
|
192
|
+
}
|
|
193
|
+
return item;
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
// ── Layer B: AP2 delegate-item resolution (chain.py) ─────────────────────────
|
|
197
|
+
/** Inline object-property `_sd` digests into a delegate item in place. */
|
|
198
|
+
function inlineSdClaims(item, token) {
|
|
199
|
+
const sdDigests = item[SD_DIGESTS_KEY];
|
|
200
|
+
if (!Array.isArray(sdDigests) || sdDigests.length === 0 || token.disclosures.length === 0)
|
|
201
|
+
return;
|
|
202
|
+
for (const digest of sdDigests) {
|
|
203
|
+
for (const d of token.disclosures) {
|
|
204
|
+
if (computeDisclosureDigest(d, token.sdAlg) === digest) {
|
|
205
|
+
const decoded = decodeDisclosure(d);
|
|
206
|
+
if (decoded.length === PROPERTY_DISCLOSURE_LEN) {
|
|
207
|
+
item[decoded[1]] = decoded[2];
|
|
208
|
+
}
|
|
209
|
+
break;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
/** Decode a bare disclosure string into its dict value, if it has one. */
|
|
215
|
+
function decodeDisclosureDict(disclosure) {
|
|
216
|
+
let arr;
|
|
217
|
+
try {
|
|
218
|
+
arr = JSON.parse(Buffer.from(disclosure, "base64url").toString("utf8"));
|
|
219
|
+
}
|
|
220
|
+
catch {
|
|
221
|
+
return null;
|
|
222
|
+
}
|
|
223
|
+
if (!Array.isArray(arr))
|
|
224
|
+
return null;
|
|
225
|
+
const val = arr.length === PROPERTY_DISCLOSURE_LEN ? arr[2] : arr.length === ARRAY_DISCLOSURE_LEN ? arr[1] : null;
|
|
226
|
+
return isPlainObject(val) ? val : null;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Resolve the effective delegate items from a verified payload's
|
|
230
|
+
* `delegate_payload`. Port of `chain.py::_resolve_delegate_items`.
|
|
231
|
+
*/
|
|
232
|
+
export function resolveDelegateItems(delegatePayload, token) {
|
|
233
|
+
if (!Array.isArray(delegatePayload))
|
|
234
|
+
return [];
|
|
235
|
+
const items = [];
|
|
236
|
+
for (const item of delegatePayload) {
|
|
237
|
+
if (isPlainObject(item)) {
|
|
238
|
+
inlineSdClaims(item, token);
|
|
239
|
+
items.push(item);
|
|
240
|
+
}
|
|
241
|
+
else if (typeof item === "string") {
|
|
242
|
+
const decoded = decodeDisclosureDict(item);
|
|
243
|
+
if (decoded !== null)
|
|
244
|
+
items.push(decoded);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
return items;
|
|
248
|
+
}
|
|
249
|
+
/** Verify one ES256 compact JWS signature; throws on any failure. Key is supplied
|
|
250
|
+
* out-of-band — a header `jwk`/`jku`/`x5u`/`kid` is NEVER trusted to pick it. */
|
|
251
|
+
export async function verifyEs256(issuerJwt, key) {
|
|
252
|
+
await compactVerify(issuerJwt, key, { algorithms: ["ES256"] });
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Verify the root issuer JWT signature (ES256, pinned) and resolve its
|
|
256
|
+
* disclosures. `key` is the issuer's public key, supplied out-of-band (x5c/kid
|
|
257
|
+
* trust is resolved by the caller in P4).
|
|
258
|
+
*/
|
|
259
|
+
export async function verifyRootSdJwt(token, key) {
|
|
260
|
+
await verifyEs256(token.issuerJwt, key);
|
|
261
|
+
const verifiedPayload = resolveDisclosures(token.payload, token.disclosures, token.sdAlg);
|
|
262
|
+
const delegateItems = resolveDelegateItems(verifiedPayload["delegate_payload"], token);
|
|
263
|
+
return { token, verifiedPayload, delegateItems };
|
|
264
|
+
}
|
|
265
|
+
// ── cnf.jwk resolution (3-tier `_find_cnf`, + single-cnf hardening H3) ────────
|
|
266
|
+
function cnfDict(value) {
|
|
267
|
+
return isPlainObject(value) && isPlainObject(value["jwk"]) ? value : null;
|
|
268
|
+
}
|
|
269
|
+
function firstCnfInList(list) {
|
|
270
|
+
if (!Array.isArray(list))
|
|
271
|
+
return null;
|
|
272
|
+
for (const item of list) {
|
|
273
|
+
if (isPlainObject(item)) {
|
|
274
|
+
const c = cnfDict(item["cnf"]);
|
|
275
|
+
if (c)
|
|
276
|
+
return c;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
return null;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Resolve the `cnf.jwk` that the NEXT hop must be signed under. Port of AP2's
|
|
283
|
+
* `common.py::_find_cnf` (3-tier: delegate_items[*].cnf → verified
|
|
284
|
+
* delegate_payload[*].cnf → top-level cnf), returned as a strict EC-P256 JWK.
|
|
285
|
+
*
|
|
286
|
+
* Hardening H3 (stricter than AP2's first-match): reject if MORE THAN ONE
|
|
287
|
+
* delegate item carries a `cnf` — a disclosure-injected second `cnf` must not be
|
|
288
|
+
* able to silently win. (The signed-`_sd` binding refinement is pending a
|
|
289
|
+
* crafted ambiguous-cnf vector.)
|
|
290
|
+
*/
|
|
291
|
+
export function cnfJwk(resolved) {
|
|
292
|
+
const itemsWithCnf = resolved.delegateItems.filter((it) => cnfDict(it["cnf"]) !== null);
|
|
293
|
+
if (itemsWithCnf.length > 1) {
|
|
294
|
+
throw new Error("Ambiguous cnf: more than one delegate item carries a cnf claim");
|
|
295
|
+
}
|
|
296
|
+
const cnf = (itemsWithCnf[0] ? cnfDict(itemsWithCnf[0]["cnf"]) : null) ??
|
|
297
|
+
firstCnfInList(resolved.verifiedPayload["delegate_payload"]) ??
|
|
298
|
+
cnfDict(resolved.verifiedPayload["cnf"]);
|
|
299
|
+
if (!cnf)
|
|
300
|
+
throw new Error("Previous token missing cnf.jwk");
|
|
301
|
+
const jwk = parseJwk(cnf["jwk"]);
|
|
302
|
+
if (!jwk)
|
|
303
|
+
throw new Error("cnf.jwk is not a valid EC P-256 JWK");
|
|
304
|
+
return jwk;
|
|
305
|
+
}
|
|
306
|
+
//# sourceMappingURL=sd-jwt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sd-jwt.js","sourceRoot":"","sources":["../../src/ap2/sd-jwt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,aAAa,EAAuD,MAAM,MAAM,CAAC;AAE1F,OAAO,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAY,MAAM,UAAU,CAAC;AAK9C,MAAM,cAAc,GAAG,KAAK,CAAC;AAC7B,MAAM,cAAc,GAAG,SAAS,CAAC;AACjC,MAAM,cAAc,GAAG,KAAK,CAA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Ae,CAAC,KAAK,CAAC,CAAC,CAAC;IAC3C,IAAI,CAAC,GAAG;QAAE,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;IAC5D,MAAM,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;IACjC,IAAI,CAAC,GAAG;QAAE,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;IACjE,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed AP2 payment-mandate schemas (zod), mirroring AP2's generated models at
|
|
3
|
+
* commit e1ea56d (`generated/open_payment_mandate.py`, `payment_mandate.py`,
|
|
4
|
+
* `types/{amount,merchant,payment_instrument,pisp}.py`).
|
|
5
|
+
*
|
|
6
|
+
* `vct` is pinned to the EXACT version-suffixed literal (AUTH-1 / SPEC-16: a
|
|
7
|
+
* verifier MUST match the full `vct` string), so a wrong/loose `vct` fails to
|
|
8
|
+
* parse. Objects are non-strict (unknown keys stripped) to match pydantic's
|
|
9
|
+
* default `extra='ignore'` and tolerate `iat`/`exp`/`risk_data`/future fields.
|
|
10
|
+
* Constraints are kept loosely typed at the mandate level so an UNKNOWN
|
|
11
|
+
* constraint type does not crash parsing — it is surfaced as a violation during
|
|
12
|
+
* evaluation (AUTH-15: unknown constraints MUST fail evaluation), not silently
|
|
13
|
+
* dropped.
|
|
14
|
+
*/
|
|
15
|
+
import { z } from "zod";
|
|
16
|
+
export declare const AmountSchema: z.ZodObject<{
|
|
17
|
+
amount: z.ZodNumber;
|
|
18
|
+
currency: z.ZodString;
|
|
19
|
+
}, z.core.$strip>;
|
|
20
|
+
export declare const MerchantSchema: z.ZodObject<{
|
|
21
|
+
id: z.ZodString;
|
|
22
|
+
name: z.ZodString;
|
|
23
|
+
website: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
24
|
+
}, z.core.$strip>;
|
|
25
|
+
export declare const PaymentInstrumentSchema: z.ZodObject<{
|
|
26
|
+
id: z.ZodString;
|
|
27
|
+
type: z.ZodString;
|
|
28
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
29
|
+
}, z.core.$strip>;
|
|
30
|
+
export declare const PispSchema: z.ZodObject<{
|
|
31
|
+
legal_name: z.ZodString;
|
|
32
|
+
brand_name: z.ZodString;
|
|
33
|
+
domain_name: z.ZodString;
|
|
34
|
+
}, z.core.$strip>;
|
|
35
|
+
export type Amount = z.infer<typeof AmountSchema>;
|
|
36
|
+
export type Merchant = z.infer<typeof MerchantSchema>;
|
|
37
|
+
export type PaymentInstrument = z.infer<typeof PaymentInstrumentSchema>;
|
|
38
|
+
export type Pisp = z.infer<typeof PispSchema>;
|
|
39
|
+
export declare const AmountRangeSchema: z.ZodObject<{
|
|
40
|
+
type: z.ZodLiteral<"payment.amount_range">;
|
|
41
|
+
currency: z.ZodString;
|
|
42
|
+
max: z.ZodNumber;
|
|
43
|
+
min: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
44
|
+
}, z.core.$strip>;
|
|
45
|
+
export declare const BudgetSchema: z.ZodObject<{
|
|
46
|
+
type: z.ZodLiteral<"payment.budget">;
|
|
47
|
+
max: z.ZodNumber;
|
|
48
|
+
currency: z.ZodString;
|
|
49
|
+
}, z.core.$strip>;
|
|
50
|
+
export declare const AgentRecurrenceSchema: z.ZodObject<{
|
|
51
|
+
type: z.ZodLiteral<"payment.agent_recurrence">;
|
|
52
|
+
frequency: z.ZodString;
|
|
53
|
+
max_occurrences: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
54
|
+
}, z.core.$strip>;
|
|
55
|
+
export declare const AllowedPayeesSchema: z.ZodObject<{
|
|
56
|
+
type: z.ZodLiteral<"payment.allowed_payees">;
|
|
57
|
+
allowed: z.ZodArray<z.ZodObject<{
|
|
58
|
+
id: z.ZodString;
|
|
59
|
+
name: z.ZodString;
|
|
60
|
+
website: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
61
|
+
}, z.core.$strip>>;
|
|
62
|
+
}, z.core.$strip>;
|
|
63
|
+
export declare const AllowedPaymentInstrumentsSchema: z.ZodObject<{
|
|
64
|
+
type: z.ZodLiteral<"payment.allowed_payment_instruments">;
|
|
65
|
+
allowed: z.ZodArray<z.ZodObject<{
|
|
66
|
+
id: z.ZodString;
|
|
67
|
+
type: z.ZodString;
|
|
68
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
69
|
+
}, z.core.$strip>>;
|
|
70
|
+
}, z.core.$strip>;
|
|
71
|
+
export declare const AllowedPispsSchema: z.ZodObject<{
|
|
72
|
+
type: z.ZodLiteral<"payment.allowed_pisps">;
|
|
73
|
+
allowed: z.ZodArray<z.ZodObject<{
|
|
74
|
+
legal_name: z.ZodString;
|
|
75
|
+
brand_name: z.ZodString;
|
|
76
|
+
domain_name: z.ZodString;
|
|
77
|
+
}, z.core.$strip>>;
|
|
78
|
+
}, z.core.$strip>;
|
|
79
|
+
export declare const ExecutionDateSchema: z.ZodObject<{
|
|
80
|
+
type: z.ZodLiteral<"payment.execution_date">;
|
|
81
|
+
not_before: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
82
|
+
not_after: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
83
|
+
}, z.core.$strip>;
|
|
84
|
+
export declare const PaymentReferenceSchema: z.ZodObject<{
|
|
85
|
+
type: z.ZodLiteral<"payment.reference">;
|
|
86
|
+
conditional_transaction_id: z.ZodString;
|
|
87
|
+
}, z.core.$strip>;
|
|
88
|
+
/** Strongly-typed union of the known payment constraints (for the evaluator). */
|
|
89
|
+
export declare const KnownPaymentConstraintSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
90
|
+
type: z.ZodLiteral<"payment.amount_range">;
|
|
91
|
+
currency: z.ZodString;
|
|
92
|
+
max: z.ZodNumber;
|
|
93
|
+
min: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
94
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
95
|
+
type: z.ZodLiteral<"payment.budget">;
|
|
96
|
+
max: z.ZodNumber;
|
|
97
|
+
currency: z.ZodString;
|
|
98
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
99
|
+
type: z.ZodLiteral<"payment.agent_recurrence">;
|
|
100
|
+
frequency: z.ZodString;
|
|
101
|
+
max_occurrences: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
102
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
103
|
+
type: z.ZodLiteral<"payment.allowed_payees">;
|
|
104
|
+
allowed: z.ZodArray<z.ZodObject<{
|
|
105
|
+
id: z.ZodString;
|
|
106
|
+
name: z.ZodString;
|
|
107
|
+
website: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
108
|
+
}, z.core.$strip>>;
|
|
109
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
110
|
+
type: z.ZodLiteral<"payment.allowed_payment_instruments">;
|
|
111
|
+
allowed: z.ZodArray<z.ZodObject<{
|
|
112
|
+
id: z.ZodString;
|
|
113
|
+
type: z.ZodString;
|
|
114
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
115
|
+
}, z.core.$strip>>;
|
|
116
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
117
|
+
type: z.ZodLiteral<"payment.allowed_pisps">;
|
|
118
|
+
allowed: z.ZodArray<z.ZodObject<{
|
|
119
|
+
legal_name: z.ZodString;
|
|
120
|
+
brand_name: z.ZodString;
|
|
121
|
+
domain_name: z.ZodString;
|
|
122
|
+
}, z.core.$strip>>;
|
|
123
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
124
|
+
type: z.ZodLiteral<"payment.execution_date">;
|
|
125
|
+
not_before: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
126
|
+
not_after: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
127
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
128
|
+
type: z.ZodLiteral<"payment.reference">;
|
|
129
|
+
conditional_transaction_id: z.ZodString;
|
|
130
|
+
}, z.core.$strip>], "type">;
|
|
131
|
+
export type KnownPaymentConstraint = z.infer<typeof KnownPaymentConstraintSchema>;
|
|
132
|
+
export declare const OpenPaymentMandateSchema: z.ZodObject<{
|
|
133
|
+
vct: z.ZodLiteral<"mandate.payment.open.1">;
|
|
134
|
+
constraints: z.ZodArray<z.ZodObject<{
|
|
135
|
+
type: z.ZodString;
|
|
136
|
+
}, z.core.$loose>>;
|
|
137
|
+
cnf: z.ZodOptional<z.ZodUnknown>;
|
|
138
|
+
payee: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
139
|
+
id: z.ZodString;
|
|
140
|
+
name: z.ZodString;
|
|
141
|
+
website: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
142
|
+
}, z.core.$strip>>>;
|
|
143
|
+
payment_amount: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
144
|
+
amount: z.ZodNumber;
|
|
145
|
+
currency: z.ZodString;
|
|
146
|
+
}, z.core.$strip>>>;
|
|
147
|
+
payment_instrument: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
148
|
+
id: z.ZodString;
|
|
149
|
+
type: z.ZodString;
|
|
150
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
151
|
+
}, z.core.$strip>>>;
|
|
152
|
+
pisp: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
153
|
+
legal_name: z.ZodString;
|
|
154
|
+
brand_name: z.ZodString;
|
|
155
|
+
domain_name: z.ZodString;
|
|
156
|
+
}, z.core.$strip>>>;
|
|
157
|
+
execution_date: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
158
|
+
}, z.core.$strip>;
|
|
159
|
+
export declare const PaymentMandateSchema: z.ZodObject<{
|
|
160
|
+
vct: z.ZodLiteral<"mandate.payment.1">;
|
|
161
|
+
transaction_id: z.ZodString;
|
|
162
|
+
payee: z.ZodObject<{
|
|
163
|
+
id: z.ZodString;
|
|
164
|
+
name: z.ZodString;
|
|
165
|
+
website: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
166
|
+
}, z.core.$strip>;
|
|
167
|
+
pisp: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
168
|
+
legal_name: z.ZodString;
|
|
169
|
+
brand_name: z.ZodString;
|
|
170
|
+
domain_name: z.ZodString;
|
|
171
|
+
}, z.core.$strip>>>;
|
|
172
|
+
payment_amount: z.ZodObject<{
|
|
173
|
+
amount: z.ZodNumber;
|
|
174
|
+
currency: z.ZodString;
|
|
175
|
+
}, z.core.$strip>;
|
|
176
|
+
payment_instrument: z.ZodObject<{
|
|
177
|
+
id: z.ZodString;
|
|
178
|
+
type: z.ZodString;
|
|
179
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
180
|
+
}, z.core.$strip>;
|
|
181
|
+
execution_date: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
182
|
+
}, z.core.$strip>;
|
|
183
|
+
export type OpenPaymentMandate = z.infer<typeof OpenPaymentMandateSchema>;
|
|
184
|
+
export type PaymentMandate = z.infer<typeof PaymentMandateSchema>;
|
|
185
|
+
/** Aggregated usage context (port of `constraints.py::MandateContext`). */
|
|
186
|
+
export interface MandateContext {
|
|
187
|
+
total_amount: number;
|
|
188
|
+
total_uses: number;
|
|
189
|
+
last_used_date?: number | null;
|
|
190
|
+
}
|
|
191
|
+
export declare const AllowedMerchantsSchema: z.ZodObject<{
|
|
192
|
+
type: z.ZodLiteral<"checkout.allowed_merchants">;
|
|
193
|
+
allowed: z.ZodArray<z.ZodObject<{
|
|
194
|
+
id: z.ZodString;
|
|
195
|
+
name: z.ZodString;
|
|
196
|
+
website: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
197
|
+
}, z.core.$strip>>;
|
|
198
|
+
}, z.core.$strip>;
|
|
199
|
+
declare const LineItemRequirementsSchema: z.ZodObject<{
|
|
200
|
+
id: z.ZodString;
|
|
201
|
+
acceptable_items: z.ZodArray<z.ZodObject<{
|
|
202
|
+
id: z.ZodString;
|
|
203
|
+
title: z.ZodString;
|
|
204
|
+
}, z.core.$strip>>;
|
|
205
|
+
quantity: z.ZodNumber;
|
|
206
|
+
}, z.core.$strip>;
|
|
207
|
+
export declare const LineItemsSchema: z.ZodObject<{
|
|
208
|
+
type: z.ZodLiteral<"checkout.line_items">;
|
|
209
|
+
items: z.ZodArray<z.ZodObject<{
|
|
210
|
+
id: z.ZodString;
|
|
211
|
+
acceptable_items: z.ZodArray<z.ZodObject<{
|
|
212
|
+
id: z.ZodString;
|
|
213
|
+
title: z.ZodString;
|
|
214
|
+
}, z.core.$strip>>;
|
|
215
|
+
quantity: z.ZodNumber;
|
|
216
|
+
}, z.core.$strip>>;
|
|
217
|
+
}, z.core.$strip>;
|
|
218
|
+
export declare const KnownCheckoutConstraintSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
219
|
+
type: z.ZodLiteral<"checkout.allowed_merchants">;
|
|
220
|
+
allowed: z.ZodArray<z.ZodObject<{
|
|
221
|
+
id: z.ZodString;
|
|
222
|
+
name: z.ZodString;
|
|
223
|
+
website: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
224
|
+
}, z.core.$strip>>;
|
|
225
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
226
|
+
type: z.ZodLiteral<"checkout.line_items">;
|
|
227
|
+
items: z.ZodArray<z.ZodObject<{
|
|
228
|
+
id: z.ZodString;
|
|
229
|
+
acceptable_items: z.ZodArray<z.ZodObject<{
|
|
230
|
+
id: z.ZodString;
|
|
231
|
+
title: z.ZodString;
|
|
232
|
+
}, z.core.$strip>>;
|
|
233
|
+
quantity: z.ZodNumber;
|
|
234
|
+
}, z.core.$strip>>;
|
|
235
|
+
}, z.core.$strip>], "type">;
|
|
236
|
+
export type LineItemRequirement = z.infer<typeof LineItemRequirementsSchema>;
|
|
237
|
+
export declare const OpenCheckoutMandateSchema: z.ZodObject<{
|
|
238
|
+
vct: z.ZodLiteral<"mandate.checkout.open.1">;
|
|
239
|
+
constraints: z.ZodArray<z.ZodObject<{
|
|
240
|
+
type: z.ZodString;
|
|
241
|
+
}, z.core.$loose>>;
|
|
242
|
+
cnf: z.ZodOptional<z.ZodUnknown>;
|
|
243
|
+
}, z.core.$strip>;
|
|
244
|
+
export type OpenCheckoutMandate = z.infer<typeof OpenCheckoutMandateSchema>;
|
|
245
|
+
/** Closed checkout mandate (mirror `generated/checkout_mandate.py`). */
|
|
246
|
+
export declare const CheckoutMandateSchema: z.ZodObject<{
|
|
247
|
+
vct: z.ZodLiteral<"mandate.checkout.1">;
|
|
248
|
+
checkout_jwt: z.ZodString;
|
|
249
|
+
checkout_hash: z.ZodString;
|
|
250
|
+
}, z.core.$strip>;
|
|
251
|
+
export type CheckoutMandate = z.infer<typeof CheckoutMandateSchema>;
|
|
252
|
+
/** Minimal UCP Checkout — only the fields the constraint evaluators read
|
|
253
|
+
* (`merchant`, `line_items[].item.id`, `line_items[].quantity`). `extra='allow'`
|
|
254
|
+
* in AP2, so unknown keys pass through. */
|
|
255
|
+
export declare const CheckoutSchema: z.ZodObject<{
|
|
256
|
+
merchant: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
257
|
+
id: z.ZodString;
|
|
258
|
+
name: z.ZodString;
|
|
259
|
+
website: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
260
|
+
}, z.core.$strip>>>;
|
|
261
|
+
line_items: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
262
|
+
item: z.ZodObject<{
|
|
263
|
+
id: z.ZodString;
|
|
264
|
+
}, z.core.$loose>;
|
|
265
|
+
quantity: z.ZodNumber;
|
|
266
|
+
}, z.core.$loose>>>>;
|
|
267
|
+
}, z.core.$loose>;
|
|
268
|
+
export type Checkout = z.infer<typeof CheckoutSchema>;
|
|
269
|
+
export {};
|
|
270
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @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