@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
package/dist/discovery/index.js
CHANGED
|
@@ -79,6 +79,45 @@ __export(discovery_exports, {
|
|
|
79
79
|
});
|
|
80
80
|
module.exports = __toCommonJS(discovery_exports);
|
|
81
81
|
|
|
82
|
+
// src/payment/amounts.ts
|
|
83
|
+
function usdToAtomic(usd, opts) {
|
|
84
|
+
const { decimals } = opts;
|
|
85
|
+
if (!Number.isInteger(decimals) || decimals < 0) {
|
|
86
|
+
throw new RangeError(`decimals must be a non-negative integer, got ${decimals}`);
|
|
87
|
+
}
|
|
88
|
+
if (typeof usd === "number") {
|
|
89
|
+
if (!Number.isFinite(usd)) {
|
|
90
|
+
throw new RangeError(`usd must be finite, got ${usd}`);
|
|
91
|
+
}
|
|
92
|
+
if (usd < 0) {
|
|
93
|
+
throw new RangeError(`usd must be non-negative, got ${usd}`);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
const s = (typeof usd === "number" ? usd.toString() : usd).trim();
|
|
97
|
+
if (s.startsWith("-")) {
|
|
98
|
+
throw new RangeError(`usd must be non-negative, got ${s}`);
|
|
99
|
+
}
|
|
100
|
+
if (s === "NaN" || s === "Infinity") {
|
|
101
|
+
throw new RangeError(`usd must be finite, got ${s}`);
|
|
102
|
+
}
|
|
103
|
+
const match = /^(\d*)(?:\.(\d*))?$/.exec(s);
|
|
104
|
+
if (!match || match[1] === "" && (match[2] === void 0 || match[2] === "")) {
|
|
105
|
+
throw new SyntaxError(`invalid usd value: ${JSON.stringify(usd)}`);
|
|
106
|
+
}
|
|
107
|
+
const intPart = match[1] || "0";
|
|
108
|
+
const fracPart = match[2] ?? "";
|
|
109
|
+
if (fracPart.length <= decimals) {
|
|
110
|
+
return BigInt(intPart + fracPart.padEnd(decimals, "0"));
|
|
111
|
+
}
|
|
112
|
+
const kept = fracPart.slice(0, decimals);
|
|
113
|
+
const roundDigit = fracPart[decimals];
|
|
114
|
+
let result = BigInt(intPart + kept);
|
|
115
|
+
if (roundDigit >= "5") {
|
|
116
|
+
result += 1n;
|
|
117
|
+
}
|
|
118
|
+
return result;
|
|
119
|
+
}
|
|
120
|
+
|
|
82
121
|
// src/payment/networks.ts
|
|
83
122
|
var networks = {
|
|
84
123
|
base: {
|
|
@@ -202,8 +241,7 @@ function buildPaymentRequestBlob({
|
|
|
202
241
|
const decimalsResolved = decimals ?? railDef?.decimals ?? 6;
|
|
203
242
|
const currencyResolved = currency ?? railDef?.currency ?? "usd";
|
|
204
243
|
const chainIdResolved = chainId ?? railDef?.chainId;
|
|
205
|
-
const
|
|
206
|
-
const amountRaw = BigInt(Math.round(amountNum * 10 ** decimalsResolved)).toString();
|
|
244
|
+
const amountRaw = usdToAtomic(amountUsd, { decimals: decimalsResolved }).toString();
|
|
207
245
|
const blob = { amount: amountRaw, currency: currencyResolved, decimals: decimalsResolved };
|
|
208
246
|
if (recipient) blob.recipient = recipient;
|
|
209
247
|
const methodDetails = {};
|
|
@@ -406,11 +444,13 @@ function buildWellKnownX402(input) {
|
|
|
406
444
|
// src/discovery/llms_txt.ts
|
|
407
445
|
function llmsTxtIdentitySection({
|
|
408
446
|
agentscore,
|
|
409
|
-
compliance
|
|
447
|
+
compliance,
|
|
448
|
+
aip
|
|
410
449
|
} = {}) {
|
|
411
450
|
if (!agentscore) {
|
|
412
451
|
return "";
|
|
413
452
|
}
|
|
453
|
+
const aipBullet = aip ? "\n- **`Agent-Identity: <JWT>` + RFC 9421 signature** \u2014 present an Agent Identity Token (AIP) from a trusted issuer (AgentScore is always trusted). Short-lived and bound to your key; sign the request (`Signature-Input` + `Signature` over `@method @authority @path agent-identity`, tag `agent-identity`) to prove possession. No long-lived token on the wire. Mint one with `agentscore-pay identity-mint` or let `agentscore-pay pay --identity aip` attach it automatically." : "";
|
|
414
454
|
const complianceNote = compliance ? `
|
|
415
455
|
|
|
416
456
|
Compliance: ${[
|
|
@@ -424,7 +464,7 @@ Compliance: ${[
|
|
|
424
464
|
AgentScore identity is reusable across every AgentScore-gated merchant \u2014 one KYC, no re-verification per site. Pick a header:
|
|
425
465
|
|
|
426
466
|
- **\`X-Wallet-Address: 0x...\` or base58** \u2014 works on signing rails (Tempo, x402, Solana MPP). The wallet you claim must sign the payment.
|
|
427
|
-
- **\`X-Operator-Token: opc_...\`** \u2014 works on every rail, including Stripe SPT. Reusable across AgentScore merchants until expiry
|
|
467
|
+
- **\`X-Operator-Token: opc_...\`** \u2014 works on every rail, including Stripe SPT. Reusable across AgentScore merchants until expiry.${aipBullet}
|
|
428
468
|
- **Neither** \u2014 you get a 403 with \`verify_url\`. Complete the session flow once and reuse the resulting \`opc_...\` everywhere.${complianceNote}`;
|
|
429
469
|
}
|
|
430
470
|
function llmsTxtPaymentSection(input) {
|
|
@@ -565,6 +605,12 @@ function agentscoreSecuritySchemes() {
|
|
|
565
605
|
name: "X-Wallet-Address",
|
|
566
606
|
description: "Wallet-path identity (0x... or base58). Only works on rails that carry a wallet signature (Tempo MPP, x402 EIP-3009, x402 SPL Token). The wallet you claim MUST sign the payment."
|
|
567
607
|
},
|
|
608
|
+
AgentIdentity: {
|
|
609
|
+
type: "apiKey",
|
|
610
|
+
in: "header",
|
|
611
|
+
name: "Agent-Identity",
|
|
612
|
+
description: "AIP Agent Identity Token path (a JWT from a trusted issuer; AgentScore is always trusted). Opt-in. The token is bound to the agent key via `cnf`; the request MUST also carry an RFC 9421 HTTP Message Signature (`Signature-Input` + `Signature` over `@method @authority @path agent-identity`, tag `agent-identity`) proving possession. A verified AIT is the sole identity and is evaluated against the merchant policy via its attested claims."
|
|
613
|
+
},
|
|
568
614
|
siwx: siwxSecurityScheme()
|
|
569
615
|
};
|
|
570
616
|
}
|
|
@@ -928,14 +974,16 @@ function identitySection(input) {
|
|
|
928
974
|
if (id.minAge) reqs.push(`age ${id.minAge}+`);
|
|
929
975
|
if (id.allowedJurisdictions?.length) reqs.push(`${id.allowedJurisdictions.join("/")} only`);
|
|
930
976
|
if (id.sanctionsClear) reqs.push("sanctions clear");
|
|
931
|
-
if (reqs.length === 0) return "";
|
|
977
|
+
if (reqs.length === 0 && !id.aip) return "";
|
|
932
978
|
const bootstrap = input.identityBootstrapUrl ? `
|
|
933
979
|
|
|
934
980
|
If you don't have a Passport, fetch \`${input.identityBootstrapUrl}\` and follow the onboarding there first. Bring back the \`opc_...\` operator token in \`X-Operator-Token\` on every gated request.` : "";
|
|
981
|
+
const reqLine = reqs.length ? `This merchant uses AgentScore identity. Required: ${reqs.join(", ")}.${bootstrap}` : `This merchant uses AgentScore identity.${bootstrap}`;
|
|
982
|
+
const aipNote = id.aip ? "\n\nThis merchant accepts AIP Agent Identity Tokens. If you hold an AIT from a trusted issuer (AgentScore is always trusted), present 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 \u2014 it satisfies identity in one round trip, no separate AgentScore credential needed. `agentscore-pay pay --identity aip` does this automatically." : "";
|
|
935
983
|
return [
|
|
936
984
|
"## Identity Prerequisite",
|
|
937
985
|
"",
|
|
938
|
-
|
|
986
|
+
`${reqLine}${aipNote}`,
|
|
939
987
|
"",
|
|
940
988
|
"Denial bodies carry an `agent_instructions` block describing the recovery action \u2014 read the `action` field and follow it. See the identity-bootstrap skill for the canonical denial-code \u2192 action table."
|
|
941
989
|
].join("\n");
|
|
@@ -1509,19 +1557,19 @@ function stableStringify(value) {
|
|
|
1509
1557
|
}
|
|
1510
1558
|
if (!Number.isInteger(value)) {
|
|
1511
1559
|
throw new Error(
|
|
1512
|
-
`UCP profile canonicalization rejects non-integer Number ${value}. Use a decimal string (e.g. "9.99") for monetary or fractional fields
|
|
1560
|
+
`UCP profile canonicalization rejects non-integer Number ${value}. Use a decimal string (e.g. "9.99") for monetary or fractional fields so the signed canonical bytes stay stable for any verifier.`
|
|
1513
1561
|
);
|
|
1514
1562
|
}
|
|
1515
1563
|
if (!Number.isSafeInteger(value)) {
|
|
1516
1564
|
throw new Error(
|
|
1517
|
-
`stableStringify: integer ${value} exceeds Number.MAX_SAFE_INTEGER. For values >2^53, use a decimal string to
|
|
1565
|
+
`stableStringify: integer ${value} exceeds Number.MAX_SAFE_INTEGER. For values >2^53, use a decimal string to keep the signed bytes stable across implementations.`
|
|
1518
1566
|
);
|
|
1519
1567
|
}
|
|
1520
1568
|
}
|
|
1521
1569
|
if (typeof value === "string") {
|
|
1522
1570
|
if (value.includes("\u2028") || value.includes("\u2029")) {
|
|
1523
1571
|
throw new Error(
|
|
1524
|
-
"stableStringify: strings containing U+2028 (LINE SEPARATOR) or U+2029 (PARAGRAPH SEPARATOR) are not allowed;
|
|
1572
|
+
"stableStringify: strings containing U+2028 (LINE SEPARATOR) or U+2029 (PARAGRAPH SEPARATOR) are not allowed; stable canonical bytes require neither be present (some JSON encoders escape them, others emit them raw)."
|
|
1525
1573
|
);
|
|
1526
1574
|
}
|
|
1527
1575
|
return JSON.stringify(value);
|
|
@@ -1541,7 +1589,7 @@ function stableStringify(value) {
|
|
|
1541
1589
|
for (const k of keys) {
|
|
1542
1590
|
if (k.includes("\u2028") || k.includes("\u2029")) {
|
|
1543
1591
|
throw new Error(
|
|
1544
|
-
"stableStringify: object keys containing U+2028 (LINE SEPARATOR) or U+2029 (PARAGRAPH SEPARATOR) are not allowed;
|
|
1592
|
+
"stableStringify: object keys containing U+2028 (LINE SEPARATOR) or U+2029 (PARAGRAPH SEPARATOR) are not allowed; stable canonical bytes require neither be present (some JSON encoders escape them, others emit them raw)."
|
|
1545
1593
|
);
|
|
1546
1594
|
}
|
|
1547
1595
|
}
|