@agent-score/commerce 2.3.0 → 2.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 +6 -6
- package/dist/challenge/index.d.mts +9 -5
- package/dist/challenge/index.d.ts +9 -5
- package/dist/challenge/index.js +11 -4
- package/dist/challenge/index.js.map +1 -1
- package/dist/challenge/index.mjs +11 -4
- package/dist/challenge/index.mjs.map +1 -1
- package/dist/{checkout-ChyOi7aU.d.ts → checkout-McfNpZJf.d.ts} +80 -12
- package/dist/{checkout-Ceo1_rVJ.d.mts → checkout-o17dIxHi.d.mts} +80 -12
- package/dist/core.d.mts +27 -7
- package/dist/core.d.ts +27 -7
- package/dist/core.js +25 -11
- package/dist/core.js.map +1 -1
- package/dist/core.mjs +25 -11
- package/dist/core.mjs.map +1 -1
- package/dist/discovery/index.d.mts +26 -10
- package/dist/discovery/index.d.ts +26 -10
- package/dist/discovery/index.js +58 -10
- package/dist/discovery/index.js.map +1 -1
- package/dist/discovery/index.mjs +58 -10
- package/dist/discovery/index.mjs.map +1 -1
- package/dist/gate-CWP10xPQ.d.mts +339 -0
- package/dist/gate-CWP10xPQ.d.ts +339 -0
- package/dist/identity/express.d.mts +26 -1
- package/dist/identity/express.d.ts +26 -1
- package/dist/identity/express.js +599 -25
- package/dist/identity/express.js.map +1 -1
- package/dist/identity/express.mjs +595 -24
- package/dist/identity/express.mjs.map +1 -1
- package/dist/identity/fastify.d.mts +12 -2
- package/dist/identity/fastify.d.ts +12 -2
- package/dist/identity/fastify.js +607 -25
- package/dist/identity/fastify.js.map +1 -1
- package/dist/identity/fastify.mjs +603 -24
- package/dist/identity/fastify.mjs.map +1 -1
- package/dist/identity/hono.d.mts +26 -1
- package/dist/identity/hono.d.ts +26 -1
- package/dist/identity/hono.js +588 -25
- package/dist/identity/hono.js.map +1 -1
- package/dist/identity/hono.mjs +584 -24
- package/dist/identity/hono.mjs.map +1 -1
- package/dist/identity/nextjs.d.mts +3 -0
- package/dist/identity/nextjs.d.ts +3 -0
- package/dist/identity/nextjs.js +593 -25
- package/dist/identity/nextjs.js.map +1 -1
- package/dist/identity/nextjs.mjs +589 -24
- package/dist/identity/nextjs.mjs.map +1 -1
- package/dist/identity/policy.js.map +1 -1
- package/dist/identity/policy.mjs.map +1 -1
- package/dist/identity/web.d.mts +24 -1
- package/dist/identity/web.d.ts +24 -1
- package/dist/identity/web.js +593 -25
- package/dist/identity/web.js.map +1 -1
- package/dist/identity/web.mjs +589 -24
- package/dist/identity/web.mjs.map +1 -1
- package/dist/index.d.mts +129 -14
- package/dist/index.d.ts +129 -14
- package/dist/index.js +978 -99
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +956 -99
- package/dist/index.mjs.map +1 -1
- package/dist/{default_rails-DtR_E9N9.d.ts → network_kind-BIJM2peR.d.ts} +22 -8
- package/dist/{default_rails-K25PtWrL.d.mts → network_kind-C0EMkdzz.d.mts} +22 -8
- package/dist/payment/index.d.mts +16 -26
- package/dist/payment/index.d.ts +16 -26
- package/dist/payment/index.js +62 -57
- package/dist/payment/index.js.map +1 -1
- package/dist/payment/index.mjs +62 -57
- package/dist/payment/index.mjs.map +1 -1
- package/dist/{pricing-B3-aKxSz.d.ts → pricing-CytRwhC2.d.ts} +1 -1
- package/dist/{pricing-BReyZiqN.d.mts → pricing-KHDqMLd7.d.mts} +1 -1
- package/dist/{rail_spec-B1239jPp.d.mts → rail_spec-BFZmW9RN.d.mts} +3 -4
- package/dist/{rail_spec-B1239jPp.d.ts → rail_spec-BFZmW9RN.d.ts} +3 -4
- package/dist/stripe-multichain/index.d.mts +2 -9
- package/dist/stripe-multichain/index.d.ts +2 -9
- package/dist/stripe-multichain/index.js.map +1 -1
- package/dist/stripe-multichain/index.mjs.map +1 -1
- package/dist/{wwwauthenticate-D_FMnPgU.d.mts → wwwauthenticate-CVaGUMjU.d.mts} +8 -6
- package/dist/{wwwauthenticate-D_FMnPgU.d.ts → wwwauthenticate-CVaGUMjU.d.ts} +8 -6
- package/package.json +14 -13
|
@@ -131,7 +131,530 @@ function denialReasonToBody(reason) {
|
|
|
131
131
|
return body;
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
+
// src/aip/verify.ts
|
|
135
|
+
import { decodeJwt, decodeProtectedHeader, importJWK as importJWK2, jwtVerify } from "jose";
|
|
136
|
+
|
|
137
|
+
// src/aip/http-signature.ts
|
|
138
|
+
import { calculateJwkThumbprint, importJWK } from "jose";
|
|
139
|
+
var { subtle } = globalThis.crypto;
|
|
140
|
+
var b64ToBytes = (b64) => {
|
|
141
|
+
const bin = atob(b64);
|
|
142
|
+
const out = new Uint8Array(bin.length);
|
|
143
|
+
for (let i = 0; i < bin.length; i++) {
|
|
144
|
+
out[i] = bin.charCodeAt(i);
|
|
145
|
+
}
|
|
146
|
+
return out;
|
|
147
|
+
};
|
|
148
|
+
var AIP_COVERED_COMPONENTS = ["@method", "@authority", "@path", "agent-identity"];
|
|
149
|
+
var AIP_SIGNATURE_TAG = "agent-identity";
|
|
150
|
+
var DEFAULT_MAX_SKEW_SECONDS = 60;
|
|
151
|
+
var normalizeAuthority = (authority) => {
|
|
152
|
+
const lower = authority.trim().toLowerCase();
|
|
153
|
+
const colon = lower.lastIndexOf(":");
|
|
154
|
+
if (colon === -1) {
|
|
155
|
+
return lower;
|
|
156
|
+
}
|
|
157
|
+
if (lower.includes("]") && colon < lower.indexOf("]")) {
|
|
158
|
+
return lower;
|
|
159
|
+
}
|
|
160
|
+
const host = lower.slice(0, colon);
|
|
161
|
+
const port = lower.slice(colon + 1);
|
|
162
|
+
if (port === "80" || port === "443") {
|
|
163
|
+
return host;
|
|
164
|
+
}
|
|
165
|
+
return lower;
|
|
166
|
+
};
|
|
167
|
+
var componentValue = (name, input) => {
|
|
168
|
+
switch (name) {
|
|
169
|
+
case "@method":
|
|
170
|
+
return input.method.toUpperCase();
|
|
171
|
+
case "@authority":
|
|
172
|
+
return normalizeAuthority(input.authority);
|
|
173
|
+
case "@path":
|
|
174
|
+
return input.path;
|
|
175
|
+
case "agent-identity":
|
|
176
|
+
return input.agentIdentity.trim();
|
|
177
|
+
default:
|
|
178
|
+
return input.extra?.[name] ?? null;
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
var serializeComponentList = (components) => `(${components.map((c) => `"${c}"`).join(" ")})`;
|
|
182
|
+
var serializeParams = (p) => {
|
|
183
|
+
const parts = [];
|
|
184
|
+
if (p.created !== void 0) {
|
|
185
|
+
parts.push(`created=${p.created}`);
|
|
186
|
+
}
|
|
187
|
+
if (p.expires !== void 0) {
|
|
188
|
+
parts.push(`expires=${p.expires}`);
|
|
189
|
+
}
|
|
190
|
+
if (p.keyid !== void 0) {
|
|
191
|
+
parts.push(`keyid="${p.keyid}"`);
|
|
192
|
+
}
|
|
193
|
+
if (p.alg !== void 0) {
|
|
194
|
+
parts.push(`alg="${p.alg}"`);
|
|
195
|
+
}
|
|
196
|
+
if (p.tag !== void 0) {
|
|
197
|
+
parts.push(`tag="${p.tag}"`);
|
|
198
|
+
}
|
|
199
|
+
return parts.map((s) => `;${s}`).join("");
|
|
200
|
+
};
|
|
201
|
+
var buildSignatureBase = (params, input) => {
|
|
202
|
+
const lines = [];
|
|
203
|
+
for (const name of params.components) {
|
|
204
|
+
const value = componentValue(name, input);
|
|
205
|
+
if (value === null) {
|
|
206
|
+
throw new MissingComponentError(name);
|
|
207
|
+
}
|
|
208
|
+
lines.push(`"${name}": ${value}`);
|
|
209
|
+
}
|
|
210
|
+
const paramsValue = serializeComponentList(params.components) + serializeParams(params);
|
|
211
|
+
lines.push(`"@signature-params": ${paramsValue}`);
|
|
212
|
+
return lines.join("\n");
|
|
213
|
+
};
|
|
214
|
+
var MissingComponentError = class extends Error {
|
|
215
|
+
constructor(component) {
|
|
216
|
+
super(`signature base missing covered component: ${component}`);
|
|
217
|
+
this.component = component;
|
|
218
|
+
this.name = "MissingComponentError";
|
|
219
|
+
}
|
|
220
|
+
component;
|
|
221
|
+
};
|
|
222
|
+
var parseSignatureInput = (header, tag = AIP_SIGNATURE_TAG) => {
|
|
223
|
+
const members = splitDictionary(header);
|
|
224
|
+
if (members.length === 0) {
|
|
225
|
+
return null;
|
|
226
|
+
}
|
|
227
|
+
const parsed = members.map((m) => {
|
|
228
|
+
const params = parseInnerListMember(m.value);
|
|
229
|
+
return params ? { label: m.label, params } : null;
|
|
230
|
+
}).filter((x) => x !== null);
|
|
231
|
+
if (parsed.length === 0) {
|
|
232
|
+
return null;
|
|
233
|
+
}
|
|
234
|
+
const tagged = parsed.find((p) => p.params.tag === tag);
|
|
235
|
+
if (tagged) {
|
|
236
|
+
return tagged;
|
|
237
|
+
}
|
|
238
|
+
if (parsed.length === 1 && parsed[0].params.tag === void 0) {
|
|
239
|
+
return parsed[0];
|
|
240
|
+
}
|
|
241
|
+
return null;
|
|
242
|
+
};
|
|
243
|
+
var parseSignatureValue = (header, label) => {
|
|
244
|
+
const members = splitDictionary(header);
|
|
245
|
+
const member = members.find((m) => m.label === label);
|
|
246
|
+
if (!member) {
|
|
247
|
+
return null;
|
|
248
|
+
}
|
|
249
|
+
const v = member.value.trim();
|
|
250
|
+
if (!v.startsWith(":") || !v.endsWith(":") || v.length < 2) {
|
|
251
|
+
return null;
|
|
252
|
+
}
|
|
253
|
+
const b64 = v.slice(1, -1);
|
|
254
|
+
try {
|
|
255
|
+
return b64ToBytes(b64);
|
|
256
|
+
} catch {
|
|
257
|
+
return null;
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
var splitDictionary = (header) => {
|
|
261
|
+
const out = [];
|
|
262
|
+
let depth = 0;
|
|
263
|
+
let inBytes = false;
|
|
264
|
+
let inString = false;
|
|
265
|
+
let current = "";
|
|
266
|
+
for (let i = 0; i < header.length; i++) {
|
|
267
|
+
const ch = header[i];
|
|
268
|
+
if (inString) {
|
|
269
|
+
current += ch;
|
|
270
|
+
if (ch === '"' && header[i - 1] !== "\\") {
|
|
271
|
+
inString = false;
|
|
272
|
+
}
|
|
273
|
+
continue;
|
|
274
|
+
}
|
|
275
|
+
if (ch === '"') {
|
|
276
|
+
inString = true;
|
|
277
|
+
current += ch;
|
|
278
|
+
continue;
|
|
279
|
+
}
|
|
280
|
+
if (ch === ":") {
|
|
281
|
+
inBytes = !inBytes;
|
|
282
|
+
current += ch;
|
|
283
|
+
continue;
|
|
284
|
+
}
|
|
285
|
+
if (!inBytes && ch === "(") {
|
|
286
|
+
depth++;
|
|
287
|
+
current += ch;
|
|
288
|
+
continue;
|
|
289
|
+
}
|
|
290
|
+
if (!inBytes && ch === ")") {
|
|
291
|
+
depth = Math.max(0, depth - 1);
|
|
292
|
+
current += ch;
|
|
293
|
+
continue;
|
|
294
|
+
}
|
|
295
|
+
if (!inBytes && depth === 0 && ch === ",") {
|
|
296
|
+
pushMember(out, current);
|
|
297
|
+
current = "";
|
|
298
|
+
continue;
|
|
299
|
+
}
|
|
300
|
+
current += ch;
|
|
301
|
+
}
|
|
302
|
+
pushMember(out, current);
|
|
303
|
+
return out;
|
|
304
|
+
};
|
|
305
|
+
var pushMember = (out, raw) => {
|
|
306
|
+
const trimmed = raw.trim();
|
|
307
|
+
if (!trimmed) {
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
const eq = trimmed.indexOf("=");
|
|
311
|
+
if (eq === -1) {
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
const label = trimmed.slice(0, eq).trim();
|
|
315
|
+
const value = trimmed.slice(eq + 1).trim();
|
|
316
|
+
if (label) {
|
|
317
|
+
out.push({ label, value });
|
|
318
|
+
}
|
|
319
|
+
};
|
|
320
|
+
var parseInnerListMember = (value) => {
|
|
321
|
+
const open = value.indexOf("(");
|
|
322
|
+
const close = value.indexOf(")", open + 1);
|
|
323
|
+
if (open === -1 || close === -1) {
|
|
324
|
+
return null;
|
|
325
|
+
}
|
|
326
|
+
const listBody = value.slice(open + 1, close).trim();
|
|
327
|
+
const components = listBody.length === 0 ? [] : (listBody.match(/"[^"]*"/g) ?? []).map((s) => s.slice(1, -1));
|
|
328
|
+
const params = { components };
|
|
329
|
+
const paramStr = value.slice(close + 1);
|
|
330
|
+
const re = /;\s*([a-zA-Z][a-zA-Z0-9_-]*)\s*=\s*("(?:[^"\\]|\\.)*"|-?\d+)/g;
|
|
331
|
+
let match;
|
|
332
|
+
while ((match = re.exec(paramStr)) !== null) {
|
|
333
|
+
const key = match[1];
|
|
334
|
+
const raw = match[2];
|
|
335
|
+
const val = raw.startsWith('"') ? raw.slice(1, -1) : Number(raw);
|
|
336
|
+
if (key === "created") {
|
|
337
|
+
params.created = val;
|
|
338
|
+
} else if (key === "expires") {
|
|
339
|
+
params.expires = val;
|
|
340
|
+
} else if (key === "keyid") {
|
|
341
|
+
params.keyid = val;
|
|
342
|
+
} else if (key === "tag") {
|
|
343
|
+
params.tag = val;
|
|
344
|
+
} else if (key === "alg") {
|
|
345
|
+
params.alg = val;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
return params;
|
|
349
|
+
};
|
|
350
|
+
var verifyMessageSignature = async (input) => {
|
|
351
|
+
const selected = parseSignatureInput(input.signatureInput);
|
|
352
|
+
if (!selected) {
|
|
353
|
+
return { ok: false, reason: "no_aip_signature" };
|
|
354
|
+
}
|
|
355
|
+
const { label, params } = selected;
|
|
356
|
+
if (params.alg !== void 0 && !["ed25519", "eddsa"].includes(params.alg.toLowerCase())) {
|
|
357
|
+
return { ok: false, reason: "unsupported_alg" };
|
|
358
|
+
}
|
|
359
|
+
for (const required of AIP_COVERED_COMPONENTS) {
|
|
360
|
+
if (!params.components.includes(required)) {
|
|
361
|
+
return { ok: false, reason: "missing_covered_component" };
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
const now = input.now ?? Math.floor(Date.now() / 1e3);
|
|
365
|
+
const skew = input.maxSkewSeconds ?? DEFAULT_MAX_SKEW_SECONDS;
|
|
366
|
+
if (params.created !== void 0 && params.created > now + skew) {
|
|
367
|
+
return { ok: false, reason: "created_in_future" };
|
|
368
|
+
}
|
|
369
|
+
if (params.expires !== void 0 && params.expires < now - skew) {
|
|
370
|
+
return { ok: false, reason: "expired" };
|
|
371
|
+
}
|
|
372
|
+
if (!params.keyid) {
|
|
373
|
+
return { ok: false, reason: "missing_keyid" };
|
|
374
|
+
}
|
|
375
|
+
const cnf = input.cnfJwk;
|
|
376
|
+
if (cnf.kty !== "OKP" || cnf.crv !== "Ed25519" || typeof cnf.x !== "string" || cnf.x.length === 0) {
|
|
377
|
+
return { ok: false, reason: "unsupported_cnf_key" };
|
|
378
|
+
}
|
|
379
|
+
let thumbprint;
|
|
380
|
+
try {
|
|
381
|
+
thumbprint = await calculateJwkThumbprint(input.cnfJwk, "sha256");
|
|
382
|
+
} catch {
|
|
383
|
+
return { ok: false, reason: "unsupported_cnf_key" };
|
|
384
|
+
}
|
|
385
|
+
if (params.keyid !== thumbprint) {
|
|
386
|
+
return { ok: false, reason: "keyid_mismatch" };
|
|
387
|
+
}
|
|
388
|
+
const sig = parseSignatureValue(input.signature, label);
|
|
389
|
+
if (!sig) {
|
|
390
|
+
return { ok: false, reason: "malformed_signature" };
|
|
391
|
+
}
|
|
392
|
+
let base;
|
|
393
|
+
try {
|
|
394
|
+
base = buildSignatureBase(params, {
|
|
395
|
+
method: input.method,
|
|
396
|
+
authority: input.authority,
|
|
397
|
+
path: input.path,
|
|
398
|
+
agentIdentity: input.agentIdentity,
|
|
399
|
+
extra: input.extraComponents
|
|
400
|
+
});
|
|
401
|
+
} catch (err) {
|
|
402
|
+
if (err instanceof MissingComponentError) {
|
|
403
|
+
return { ok: false, reason: "missing_covered_component" };
|
|
404
|
+
}
|
|
405
|
+
throw err;
|
|
406
|
+
}
|
|
407
|
+
let valid;
|
|
408
|
+
try {
|
|
409
|
+
const key = await importJWK(input.cnfJwk, "EdDSA");
|
|
410
|
+
if (!(key instanceof CryptoKey)) {
|
|
411
|
+
return { ok: false, reason: "signature_invalid" };
|
|
412
|
+
}
|
|
413
|
+
valid = await subtle.verify(
|
|
414
|
+
{ name: "Ed25519" },
|
|
415
|
+
key,
|
|
416
|
+
sig,
|
|
417
|
+
new TextEncoder().encode(base)
|
|
418
|
+
);
|
|
419
|
+
} catch {
|
|
420
|
+
return { ok: false, reason: "signature_invalid" };
|
|
421
|
+
}
|
|
422
|
+
return valid ? { ok: true, params } : { ok: false, reason: "signature_invalid" };
|
|
423
|
+
};
|
|
424
|
+
|
|
425
|
+
// src/aip/types.ts
|
|
426
|
+
var isObject = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
427
|
+
var isNonEmptyString = (v) => typeof v === "string" && v.length > 0;
|
|
428
|
+
var isAitShape = (payload) => isObject(payload) && isObject(payload.cnf) && isObject(payload.agent);
|
|
429
|
+
var validateAitPayload = (payload) => {
|
|
430
|
+
if (!isObject(payload)) {
|
|
431
|
+
return { ok: false, reason: "not_an_object" };
|
|
432
|
+
}
|
|
433
|
+
if (!isNonEmptyString(payload.aip_version)) {
|
|
434
|
+
return { ok: false, reason: "missing_aip_version" };
|
|
435
|
+
}
|
|
436
|
+
if (!isNonEmptyString(payload.iss)) {
|
|
437
|
+
return { ok: false, reason: "missing_iss" };
|
|
438
|
+
}
|
|
439
|
+
if (!isNonEmptyString(payload.sub)) {
|
|
440
|
+
return { ok: false, reason: "missing_sub" };
|
|
441
|
+
}
|
|
442
|
+
if (typeof payload.iat !== "number") {
|
|
443
|
+
return { ok: false, reason: "missing_iat" };
|
|
444
|
+
}
|
|
445
|
+
if (typeof payload.exp !== "number") {
|
|
446
|
+
return { ok: false, reason: "missing_exp" };
|
|
447
|
+
}
|
|
448
|
+
if (!isObject(payload.cnf) || !isObject(payload.cnf.jwk)) {
|
|
449
|
+
return { ok: false, reason: "missing_cnf" };
|
|
450
|
+
}
|
|
451
|
+
if (!isObject(payload.agent) || !isNonEmptyString(payload.agent.provider)) {
|
|
452
|
+
return { ok: false, reason: "missing_agent_provider" };
|
|
453
|
+
}
|
|
454
|
+
if (payload.trust_level === "human_confirmed") {
|
|
455
|
+
const auth = payload.auth;
|
|
456
|
+
const amr = isObject(auth) ? auth.amr : void 0;
|
|
457
|
+
if (!Array.isArray(amr) || amr.length === 0) {
|
|
458
|
+
return { ok: false, reason: "human_confirmed_without_amr" };
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
return { ok: true, payload };
|
|
462
|
+
};
|
|
463
|
+
|
|
464
|
+
// src/aip/verify.ts
|
|
465
|
+
var verifyAit = async (ctx, opts) => {
|
|
466
|
+
if (ctx.agentIdentityHeaders.length === 0) {
|
|
467
|
+
return { ok: false, reason: "no_token" };
|
|
468
|
+
}
|
|
469
|
+
if (!ctx.signatureInput || !ctx.signature) {
|
|
470
|
+
return { ok: false, reason: "pop_signature_missing" };
|
|
471
|
+
}
|
|
472
|
+
let lastFailure = "malformed_token";
|
|
473
|
+
for (const raw of ctx.agentIdentityHeaders) {
|
|
474
|
+
const token = stripBearer(raw);
|
|
475
|
+
let header;
|
|
476
|
+
let payload;
|
|
477
|
+
try {
|
|
478
|
+
header = decodeProtectedHeader(token);
|
|
479
|
+
payload = decodeJwt(token);
|
|
480
|
+
} catch {
|
|
481
|
+
lastFailure = "malformed_token";
|
|
482
|
+
continue;
|
|
483
|
+
}
|
|
484
|
+
if (header.alg === void 0 || header.alg.toLowerCase() === "none") {
|
|
485
|
+
lastFailure = "malformed_token";
|
|
486
|
+
continue;
|
|
487
|
+
}
|
|
488
|
+
if (!isAitShape(payload)) {
|
|
489
|
+
lastFailure = "malformed_token";
|
|
490
|
+
continue;
|
|
491
|
+
}
|
|
492
|
+
const validated = validateAitPayload(payload);
|
|
493
|
+
if (!validated.ok) {
|
|
494
|
+
lastFailure = "invalid_claims";
|
|
495
|
+
continue;
|
|
496
|
+
}
|
|
497
|
+
const claims = validated.payload;
|
|
498
|
+
const keyLookup = await opts.jwks.getKey(claims.iss, header.kid);
|
|
499
|
+
if (!keyLookup.ok) {
|
|
500
|
+
lastFailure = keyLookup.reason === "untrusted_issuer" || keyLookup.reason === "insecure_issuer" ? "untrusted_issuer" : "key_unavailable";
|
|
501
|
+
continue;
|
|
502
|
+
}
|
|
503
|
+
const jwtClockTolerance = opts.maxSkewSeconds ?? 60;
|
|
504
|
+
try {
|
|
505
|
+
const idpKey = await importJWK2(keyLookup.key, normalizeAlg(header.alg));
|
|
506
|
+
await jwtVerify(token, idpKey, {
|
|
507
|
+
// Pin the signature algorithm allowlist (RFC 8725 §3.1) — also rejects `alg:none`. Without
|
|
508
|
+
// this, jose accepts whatever alg the resolved JWK supports, so a trusted IdP publishing a
|
|
509
|
+
// non-Ed25519 (e.g. RSA/EC) `use:sig` key would let an attacker present an RS256/ES256
|
|
510
|
+
// token that verifies. Matches the server-side allowlist in core/api aip-verify.
|
|
511
|
+
algorithms: AIT_SIGNING_ALGS,
|
|
512
|
+
clockTolerance: jwtClockTolerance,
|
|
513
|
+
currentDate: opts.now !== void 0 ? new Date(opts.now * 1e3) : void 0
|
|
514
|
+
});
|
|
515
|
+
} catch (err) {
|
|
516
|
+
lastFailure = isExpiry(err) ? "expired_token" : "idp_signature_invalid";
|
|
517
|
+
continue;
|
|
518
|
+
}
|
|
519
|
+
const nowSec = opts.now ?? Math.floor(Date.now() / 1e3);
|
|
520
|
+
if (claims.iat > nowSec + jwtClockTolerance) {
|
|
521
|
+
lastFailure = "expired_token";
|
|
522
|
+
continue;
|
|
523
|
+
}
|
|
524
|
+
const popResult = await verifyMessageSignature({
|
|
525
|
+
method: ctx.method,
|
|
526
|
+
authority: ctx.authority,
|
|
527
|
+
path: ctx.path,
|
|
528
|
+
agentIdentity: raw,
|
|
529
|
+
signatureInput: ctx.signatureInput,
|
|
530
|
+
signature: ctx.signature,
|
|
531
|
+
cnfJwk: claims.cnf.jwk,
|
|
532
|
+
now: opts.now,
|
|
533
|
+
maxSkewSeconds: opts.maxSkewSeconds
|
|
534
|
+
});
|
|
535
|
+
if (!popResult.ok) {
|
|
536
|
+
lastFailure = "pop_signature_invalid";
|
|
537
|
+
continue;
|
|
538
|
+
}
|
|
539
|
+
return { ok: true, ait: { payload: claims, iss: claims.iss, cnfJwk: claims.cnf.jwk, token } };
|
|
540
|
+
}
|
|
541
|
+
return { ok: false, reason: lastFailure };
|
|
542
|
+
};
|
|
543
|
+
var stripBearer = (value) => {
|
|
544
|
+
const trimmed = value.trim();
|
|
545
|
+
return /^bearer\s+/i.test(trimmed) ? trimmed.replace(/^bearer\s+/i, "") : trimmed;
|
|
546
|
+
};
|
|
547
|
+
var AIT_SIGNING_ALGS = ["EdDSA", "ES256"];
|
|
548
|
+
var normalizeAlg = (alg) => alg.toLowerCase() === "eddsa" ? "EdDSA" : alg;
|
|
549
|
+
var isExpiry = (err) => typeof err === "object" && err !== null && err.code === "ERR_JWT_EXPIRED";
|
|
550
|
+
|
|
551
|
+
// src/aip/request.ts
|
|
552
|
+
var readNodeHeader = (headers, name) => {
|
|
553
|
+
const v = headers[name] ?? headers[name.toLowerCase()];
|
|
554
|
+
if (v === void 0) {
|
|
555
|
+
return void 0;
|
|
556
|
+
}
|
|
557
|
+
return Array.isArray(v) ? v.join(", ") : v;
|
|
558
|
+
};
|
|
559
|
+
var hasAgentIdentityHeaderNode = (headers) => {
|
|
560
|
+
const raw = readNodeHeader(headers, "agent-identity");
|
|
561
|
+
return raw !== void 0 && raw.split(",").some((s) => s.trim().length > 0);
|
|
562
|
+
};
|
|
563
|
+
var buildVerifyContextFromParts = (parts) => {
|
|
564
|
+
const agentIdentityRaw = readNodeHeader(parts.headers, "agent-identity");
|
|
565
|
+
const agentIdentityHeaders = agentIdentityRaw ? agentIdentityRaw.split(",").map((s) => s.trim()).filter((s) => s.length > 0) : [];
|
|
566
|
+
const host = parts.authority ?? readNodeHeader(parts.headers, "host") ?? "";
|
|
567
|
+
let path;
|
|
568
|
+
try {
|
|
569
|
+
path = new URL(parts.url, host ? `http://${host}` : "http://localhost").pathname;
|
|
570
|
+
} catch {
|
|
571
|
+
const q = parts.url.indexOf("?");
|
|
572
|
+
path = q === -1 ? parts.url : parts.url.slice(0, q);
|
|
573
|
+
}
|
|
574
|
+
return {
|
|
575
|
+
method: parts.method,
|
|
576
|
+
authority: host,
|
|
577
|
+
path,
|
|
578
|
+
agentIdentityHeaders,
|
|
579
|
+
signatureInput: readNodeHeader(parts.headers, "signature-input") ?? null,
|
|
580
|
+
signature: readNodeHeader(parts.headers, "signature") ?? null
|
|
581
|
+
};
|
|
582
|
+
};
|
|
583
|
+
|
|
584
|
+
// src/aip/gate.ts
|
|
585
|
+
var verifyFromContext = async (ctx, opts) => {
|
|
586
|
+
const result = await verifyAit(ctx, { jwks: opts.jwks, now: opts.now, maxSkewSeconds: opts.maxSkewSeconds });
|
|
587
|
+
return result.ok ? { ok: true, ait: result.ait } : { ok: false, failure: result.reason };
|
|
588
|
+
};
|
|
589
|
+
var verifyAitParts = (parts, opts) => verifyFromContext(buildVerifyContextFromParts(parts), opts);
|
|
590
|
+
var aipErrorCode = (failure) => {
|
|
591
|
+
switch (failure) {
|
|
592
|
+
case "no_token":
|
|
593
|
+
case "pop_signature_missing":
|
|
594
|
+
return "agent_identity_required";
|
|
595
|
+
case "untrusted_issuer":
|
|
596
|
+
return "untrusted_issuer";
|
|
597
|
+
case "expired_token":
|
|
598
|
+
return "expired_token";
|
|
599
|
+
case "invalid_claims":
|
|
600
|
+
return "insufficient_claims";
|
|
601
|
+
case "key_unavailable":
|
|
602
|
+
return "idp_unavailable";
|
|
603
|
+
case "malformed_token":
|
|
604
|
+
case "idp_signature_invalid":
|
|
605
|
+
case "pop_signature_invalid":
|
|
606
|
+
return "invalid_signature";
|
|
607
|
+
default:
|
|
608
|
+
return "invalid_signature";
|
|
609
|
+
}
|
|
610
|
+
};
|
|
611
|
+
var aipErrorStatus = (failure) => {
|
|
612
|
+
switch (failure) {
|
|
613
|
+
case "key_unavailable":
|
|
614
|
+
return 503;
|
|
615
|
+
case "untrusted_issuer":
|
|
616
|
+
case "invalid_claims":
|
|
617
|
+
return 403;
|
|
618
|
+
default:
|
|
619
|
+
return 401;
|
|
620
|
+
}
|
|
621
|
+
};
|
|
622
|
+
var aipErrorDetail = (failure) => {
|
|
623
|
+
switch (failure) {
|
|
624
|
+
case "no_token":
|
|
625
|
+
return "No Agent-Identity token was presented.";
|
|
626
|
+
case "pop_signature_missing":
|
|
627
|
+
return "The request is missing the RFC 9421 HTTP Message Signature that proves possession of the token-bound key.";
|
|
628
|
+
case "untrusted_issuer":
|
|
629
|
+
return "The token's issuer is not in this service's trusted-issuer list.";
|
|
630
|
+
case "expired_token":
|
|
631
|
+
return "The Agent Identity Token has expired.";
|
|
632
|
+
case "invalid_claims":
|
|
633
|
+
return "The token is missing required claims for this endpoint.";
|
|
634
|
+
case "malformed_token":
|
|
635
|
+
return "The Agent-Identity header could not be parsed as an Agent Identity Token.";
|
|
636
|
+
case "idp_signature_invalid":
|
|
637
|
+
return "The identity provider's signature on the token failed verification.";
|
|
638
|
+
case "pop_signature_invalid":
|
|
639
|
+
return "The request signature did not match the key bound to the token.";
|
|
640
|
+
case "key_unavailable":
|
|
641
|
+
return "The identity provider's signing key could not be resolved.";
|
|
642
|
+
default:
|
|
643
|
+
return "Token verification failed.";
|
|
644
|
+
}
|
|
645
|
+
};
|
|
646
|
+
var buildAipErrorBody = (failure) => {
|
|
647
|
+
const code = aipErrorCode(failure);
|
|
648
|
+
return {
|
|
649
|
+
type: `urn:aip:error:${code}`,
|
|
650
|
+
title: code.replace(/_/g, " "),
|
|
651
|
+
status: aipErrorStatus(failure),
|
|
652
|
+
detail: aipErrorDetail(failure)
|
|
653
|
+
};
|
|
654
|
+
};
|
|
655
|
+
|
|
134
656
|
// src/core.ts
|
|
657
|
+
import { createHash } from "crypto";
|
|
135
658
|
import {
|
|
136
659
|
AgentScore,
|
|
137
660
|
InvalidCredentialError,
|
|
@@ -233,8 +756,9 @@ var INVALID_CREDENTIAL_INSTRUCTIONS = JSON.stringify({
|
|
|
233
756
|
],
|
|
234
757
|
user_message: "The operator_token is not recognized. Use a different stored token, or restart the verification session flow to mint a new one."
|
|
235
758
|
});
|
|
236
|
-
function buildAgentMemoryHint() {
|
|
759
|
+
function buildAgentMemoryHint(aipTrustedIssuers) {
|
|
237
760
|
const api = CANONICAL_AGENTSCORE_API;
|
|
761
|
+
const acceptsAip = aipTrustedIssuers !== void 0 && aipTrustedIssuers.length > 0;
|
|
238
762
|
return {
|
|
239
763
|
save_for_future_agentscore_gates: true,
|
|
240
764
|
pattern_summary: "AgentScore is a cross-merchant identity substrate for agent commerce. Any endpoint that returns 403 missing_identity / identity_verification_required or 402 challenges referencing AgentScore uses the same identity system. One KYC works across all AgentScore merchants \u2014 no re-verification per site. Save this pattern (and the endpoints below) to persistent memory so future AgentScore encounters skip the cold-start session flow.",
|
|
@@ -242,8 +766,12 @@ function buildAgentMemoryHint() {
|
|
|
242
766
|
identity_check_endpoint: `${api}/v1/credentials`,
|
|
243
767
|
identity_paths: {
|
|
244
768
|
wallet: "If paying from a crypto wallet you have used before on any AgentScore merchant, send `X-Wallet-Address: 0x...`. Shortest path; no token lifecycle to manage.",
|
|
245
|
-
operator_token: "For any rail (Stripe SPT, card, or a wallet you have not linked yet), send `X-Operator-Token: opc_...`. Reusable across merchants until the token expires."
|
|
769
|
+
operator_token: "For any rail (Stripe SPT, card, or a wallet you have not linked yet), send `X-Operator-Token: opc_...`. Reusable across merchants until the token expires.",
|
|
770
|
+
...acceptsAip && {
|
|
771
|
+
agent_identity: 'If you hold an AIP Agent Identity Token from a trusted issuer (see aip_trusted_issuers), present it: send the JWT in an `Agent-Identity` header plus an RFC 9421 HTTP Message Signature (Signature-Input + Signature over @method @authority @path agent-identity, tag="agent-identity") signed with the token-bound cnf key. The merchant verifies it and applies its policy \u2014 no separate AgentScore credential needed.'
|
|
772
|
+
}
|
|
246
773
|
},
|
|
774
|
+
...acceptsAip && { aip_trusted_issuers: aipTrustedIssuers },
|
|
247
775
|
bootstrap: "If you have neither a linked wallet nor a valid operator_token, follow the session/verify flow in the per-request `agent_instructions` block. This happens at most once per agent identity \u2014 after first verification, the operator_token and any subsequently used wallet are reusable everywhere.",
|
|
248
776
|
do_not_persist_in_memory: ["operator_token", "poll_secret"],
|
|
249
777
|
persist_in_credential_store: ["operator_token"]
|
|
@@ -265,11 +793,12 @@ function createAgentScoreCore(options) {
|
|
|
265
793
|
baseUrl: rawBaseUrl = "https://api.agentscore.sh",
|
|
266
794
|
chain: gateChain,
|
|
267
795
|
userAgent,
|
|
268
|
-
createSessionOnMissing
|
|
796
|
+
createSessionOnMissing,
|
|
797
|
+
aipTrustedIssuers
|
|
269
798
|
} = options;
|
|
270
799
|
const baseUrl = stripTrailingSlashes(rawBaseUrl);
|
|
271
|
-
const agentMemoryHint = buildAgentMemoryHint();
|
|
272
|
-
const defaultUa = `@agent-score/commerce@${"2.
|
|
800
|
+
const agentMemoryHint = buildAgentMemoryHint(aipTrustedIssuers);
|
|
801
|
+
const defaultUa = `@agent-score/commerce@${"2.5.0"}`;
|
|
273
802
|
const userAgentHeader = userAgent ? `${userAgent} (${defaultUa})` : defaultUa;
|
|
274
803
|
const sdk = new AgentScore({ apiKey, baseUrl, userAgent: userAgentHeader });
|
|
275
804
|
const sessionSdkCache = /* @__PURE__ */ new Map();
|
|
@@ -287,6 +816,7 @@ function createAgentScoreCore(options) {
|
|
|
287
816
|
return s;
|
|
288
817
|
}
|
|
289
818
|
const cache = new TTLCache(cacheSeconds * 1e3);
|
|
819
|
+
const lastSignerRaw = /* @__PURE__ */ new Map();
|
|
290
820
|
async function tryMintSessionDenial(ctx) {
|
|
291
821
|
if (!createSessionOnMissing) return void 0;
|
|
292
822
|
try {
|
|
@@ -344,13 +874,18 @@ function createAgentScoreCore(options) {
|
|
|
344
874
|
}
|
|
345
875
|
}
|
|
346
876
|
async function evaluate(identity, ctx, signer) {
|
|
347
|
-
if (!identity || !identity.address && !identity.operatorToken) {
|
|
877
|
+
if (!identity || !identity.address?.trim() && !identity.operatorToken?.trim() && !identity.aipToken?.trim()) {
|
|
348
878
|
if (failOpen) return { kind: "allow" };
|
|
349
879
|
const sessionReason = await tryMintSessionDenial(ctx);
|
|
350
880
|
if (sessionReason) return { kind: "deny", reason: sessionReason };
|
|
881
|
+
const acceptsAip = aipTrustedIssuers !== void 0 && aipTrustedIssuers.length > 0;
|
|
882
|
+
const aipStep = acceptsAip ? [
|
|
883
|
+
`If you hold an AIP Agent Identity Token from a trusted issuer (${aipTrustedIssuers.join(", ")}): present it \u2014 send the JWT in an Agent-Identity header plus an RFC 9421 HTTP Message Signature (Signature-Input + Signature over @method @authority @path agent-identity, tag="agent-identity") signed with the token-bound cnf key. This satisfies identity in one round trip without an AgentScore credential.`
|
|
884
|
+
] : [];
|
|
351
885
|
const missingIdentityInstructions = JSON.stringify({
|
|
352
886
|
action: "probe_identity_then_session",
|
|
353
887
|
steps: [
|
|
888
|
+
...aipStep,
|
|
354
889
|
"If you have a wallet AND this merchant accepts a wallet-signing rail (Tempo MPP or x402 \u2014 see openapi.json x-payment-info): send X-Wallet-Address and retry. If the wallet is already linked to an AgentScore operator (via prior SIWE claim or prior captureWallet), this passes in one round trip. If the wallet is unlinked or the account has no KYC, the 403 will include a verify_url \u2014 share it with the user to claim the wallet + complete KYC, then retry.",
|
|
355
890
|
"If step 1 is denied or you already have a stored operator_token (valid + not expired): send X-Operator-Token: opc_... and retry.",
|
|
356
891
|
"If neither applies: retry with NO identity header. Merchants that auto-create verification sessions (most AgentScore merchants do) return verify_url + session_id + poll_secret in the 403 body \u2014 share verify_url with the user, then poll poll_url every 5s with the X-Poll-Secret header until status=verified (the poll returns a one-time operator_token). If the retry returns the same bare 403, this merchant does not support self-service session bootstrapping \u2014 direct the user to https://agentscore.sh/sign-up to create an AgentScore identity and mint an operator_token from their dashboard (https://agentscore.sh/dashboard/verify). The user hands the opc_... to you, and you retry with X-Operator-Token."
|
|
@@ -366,7 +901,7 @@ function createAgentScoreCore(options) {
|
|
|
366
901
|
}
|
|
367
902
|
};
|
|
368
903
|
}
|
|
369
|
-
const cacheKey = identity.operatorToken?.toLowerCase() ?? (identity.address ? normalizeAddress(identity.address) : "");
|
|
904
|
+
const cacheKey = identity.aipToken ? `aip:${createHash("sha256").update(identity.aipToken).digest("hex")}` : identity.operatorToken?.toLowerCase() ?? (identity.address ? normalizeAddress(identity.address) : "");
|
|
370
905
|
const cached = cache.get(cacheKey);
|
|
371
906
|
if (cached) {
|
|
372
907
|
if (cached.allow) {
|
|
@@ -411,7 +946,7 @@ function createAgentScoreCore(options) {
|
|
|
411
946
|
// regardless of policy.require_sanctions_clear (which gates the separate NAME screen).
|
|
412
947
|
...signer && { signer: { address: signer.address, network: signer.network } }
|
|
413
948
|
};
|
|
414
|
-
const result = identity.address ? await sdk.assess(identity.address, { ...opts, operatorToken: identity.operatorToken }) : await sdk.assess(null, { ...opts, operatorToken: identity.operatorToken });
|
|
949
|
+
const result = identity.aipToken ? await sdk.assess(null, { ...opts, aipToken: identity.aipToken }) : identity.address ? await sdk.assess(identity.address, { ...opts, operatorToken: identity.operatorToken }) : await sdk.assess(null, { ...opts, operatorToken: identity.operatorToken });
|
|
415
950
|
data = result;
|
|
416
951
|
} catch (err) {
|
|
417
952
|
if (err instanceof PaymentRequiredError) {
|
|
@@ -482,6 +1017,9 @@ function createAgentScoreCore(options) {
|
|
|
482
1017
|
const decisionReasons = data.decision_reasons ?? [];
|
|
483
1018
|
const allow = decision === "allow" || decision == null;
|
|
484
1019
|
cache.set(cacheKey, { allow, decision: decision ?? void 0, reasons: decisionReasons, raw: data });
|
|
1020
|
+
if (identity.address !== void 0 && identity.operatorToken === void 0 && identity.aipToken === void 0 && (data.signer_match !== void 0 || data.signer_sanctions !== void 0)) {
|
|
1021
|
+
lastSignerRaw.set(normalizeAddress(identity.address), data);
|
|
1022
|
+
}
|
|
485
1023
|
if (allow) {
|
|
486
1024
|
const quota = data.quota;
|
|
487
1025
|
return {
|
|
@@ -546,9 +1084,7 @@ function createAgentScoreCore(options) {
|
|
|
546
1084
|
}
|
|
547
1085
|
function getSignerVerdict2(claimedAddress) {
|
|
548
1086
|
const claimedNorm = normalizeAddress(claimedAddress);
|
|
549
|
-
const
|
|
550
|
-
if (!cached) return void 0;
|
|
551
|
-
const raw = cached.raw;
|
|
1087
|
+
const raw = lastSignerRaw.get(claimedNorm) ?? cache.get(claimedNorm)?.raw;
|
|
552
1088
|
if (!raw) return void 0;
|
|
553
1089
|
const rawMatch = raw.signer_match;
|
|
554
1090
|
const rawSanctions = raw.signer_sanctions;
|
|
@@ -626,6 +1162,18 @@ async function extractSolanaSignerFromCredential(credential) {
|
|
|
626
1162
|
}
|
|
627
1163
|
}
|
|
628
1164
|
async function extractPaymentSigner(request, x402PaymentHeader) {
|
|
1165
|
+
if (x402PaymentHeader) {
|
|
1166
|
+
try {
|
|
1167
|
+
const decoded = atob(x402PaymentHeader);
|
|
1168
|
+
const parsed = JSON.parse(decoded);
|
|
1169
|
+
const from = parsed?.payload?.authorization?.from;
|
|
1170
|
+
if (typeof from === "string" && /^0x[0-9a-fA-F]{40}$/.test(from)) {
|
|
1171
|
+
return { address: from.toLowerCase(), network: "evm" };
|
|
1172
|
+
}
|
|
1173
|
+
} catch (err) {
|
|
1174
|
+
console.warn("[gate] x402 signer extraction failed:", err instanceof Error ? err.message : err);
|
|
1175
|
+
}
|
|
1176
|
+
}
|
|
629
1177
|
const authHeader = request.headers.get("authorization");
|
|
630
1178
|
if (authHeader) {
|
|
631
1179
|
try {
|
|
@@ -645,18 +1193,6 @@ async function extractPaymentSigner(request, x402PaymentHeader) {
|
|
|
645
1193
|
console.warn("[gate] MPP signer extraction failed:", err instanceof Error ? err.message : err);
|
|
646
1194
|
}
|
|
647
1195
|
}
|
|
648
|
-
if (x402PaymentHeader) {
|
|
649
|
-
try {
|
|
650
|
-
const decoded = atob(x402PaymentHeader);
|
|
651
|
-
const parsed = JSON.parse(decoded);
|
|
652
|
-
const from = parsed?.payload?.authorization?.from;
|
|
653
|
-
if (typeof from === "string" && /^0x[0-9a-fA-F]{40}$/.test(from)) {
|
|
654
|
-
return { address: from.toLowerCase(), network: "evm" };
|
|
655
|
-
}
|
|
656
|
-
} catch (err) {
|
|
657
|
-
console.warn("[gate] x402 signer extraction failed:", err instanceof Error ? err.message : err);
|
|
658
|
-
}
|
|
659
|
-
}
|
|
660
1196
|
return null;
|
|
661
1197
|
}
|
|
662
1198
|
async function extractPaymentSignerFromAuth(authHeader, x402PaymentHeader) {
|
|
@@ -769,14 +1305,57 @@ var conditionalAgentscoreGatePlugin = async (fastify, options) => {
|
|
|
769
1305
|
};
|
|
770
1306
|
conditionalAgentscoreGatePlugin[/* @__PURE__ */ Symbol.for("skip-override")] = true;
|
|
771
1307
|
var conditionalAgentscoreGate = conditionalAgentscoreGatePlugin;
|
|
1308
|
+
var AIT_STATE_KEY = "__agentscoreAit";
|
|
1309
|
+
function defaultAipOnDenied(_req, reply, body) {
|
|
1310
|
+
reply.code(body.status).header("content-type", "application/problem+json").send(body);
|
|
1311
|
+
}
|
|
1312
|
+
var aipGatePlugin = async (fastify, options) => {
|
|
1313
|
+
const { onDenied = defaultAipOnDenied, ...gateOpts } = options;
|
|
1314
|
+
fastify.addHook("preHandler", async (request, reply) => {
|
|
1315
|
+
const result = await verifyAitParts(
|
|
1316
|
+
{ method: request.method, url: request.url, headers: request.headers },
|
|
1317
|
+
gateOpts
|
|
1318
|
+
);
|
|
1319
|
+
if (!result.ok) {
|
|
1320
|
+
await onDenied(request, reply, buildAipErrorBody(result.failure));
|
|
1321
|
+
return;
|
|
1322
|
+
}
|
|
1323
|
+
request[AIT_STATE_KEY] = result.ait;
|
|
1324
|
+
});
|
|
1325
|
+
};
|
|
1326
|
+
aipGatePlugin[/* @__PURE__ */ Symbol.for("skip-override")] = true;
|
|
1327
|
+
var aipGate = aipGatePlugin;
|
|
1328
|
+
var conditionalAipGatePlugin = async (fastify, options) => {
|
|
1329
|
+
const { onDenied = defaultAipOnDenied, ...gateOpts } = options;
|
|
1330
|
+
fastify.addHook("preHandler", async (request, reply) => {
|
|
1331
|
+
if (!hasAgentIdentityHeaderNode(request.headers)) return;
|
|
1332
|
+
const result = await verifyAitParts(
|
|
1333
|
+
{ method: request.method, url: request.url, headers: request.headers },
|
|
1334
|
+
gateOpts
|
|
1335
|
+
);
|
|
1336
|
+
if (!result.ok) {
|
|
1337
|
+
await onDenied(request, reply, buildAipErrorBody(result.failure));
|
|
1338
|
+
return;
|
|
1339
|
+
}
|
|
1340
|
+
request[AIT_STATE_KEY] = result.ait;
|
|
1341
|
+
});
|
|
1342
|
+
};
|
|
1343
|
+
conditionalAipGatePlugin[/* @__PURE__ */ Symbol.for("skip-override")] = true;
|
|
1344
|
+
var conditionalAipGate = conditionalAipGatePlugin;
|
|
1345
|
+
function getVerifiedAit(request) {
|
|
1346
|
+
return request[AIT_STATE_KEY];
|
|
1347
|
+
}
|
|
772
1348
|
export {
|
|
773
1349
|
agentscoreGate,
|
|
1350
|
+
aipGate,
|
|
774
1351
|
captureWallet,
|
|
775
1352
|
conditionalAgentscoreGate,
|
|
1353
|
+
conditionalAipGate,
|
|
776
1354
|
fastify_default as default,
|
|
777
1355
|
getAgentScoreData,
|
|
778
1356
|
getGateDegradedState,
|
|
779
1357
|
getGateQuotaInfo,
|
|
780
|
-
getSignerVerdict
|
|
1358
|
+
getSignerVerdict,
|
|
1359
|
+
getVerifiedAit
|
|
781
1360
|
};
|
|
782
1361
|
//# sourceMappingURL=fastify.mjs.map
|