@agent-score/commerce 2.4.0 → 2.6.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.
Files changed (80) hide show
  1. package/README.md +19 -17
  2. package/dist/challenge/index.d.mts +31 -3
  3. package/dist/challenge/index.d.ts +31 -3
  4. package/dist/challenge/index.js +25 -9
  5. package/dist/challenge/index.js.map +1 -1
  6. package/dist/challenge/index.mjs +25 -9
  7. package/dist/challenge/index.mjs.map +1 -1
  8. package/dist/{checkout-B-MIzYzW.d.ts → checkout-C4RD7M0Z.d.ts} +117 -13
  9. package/dist/{checkout-Bn7ZKIBD.d.mts → checkout-CzB9f_jf.d.mts} +117 -13
  10. package/dist/core.d.mts +40 -7
  11. package/dist/core.d.ts +40 -7
  12. package/dist/core.js +52 -27
  13. package/dist/core.js.map +1 -1
  14. package/dist/core.mjs +52 -27
  15. package/dist/core.mjs.map +1 -1
  16. package/dist/discovery/index.d.mts +33 -3
  17. package/dist/discovery/index.d.ts +33 -3
  18. package/dist/discovery/index.js +50 -16
  19. package/dist/discovery/index.js.map +1 -1
  20. package/dist/discovery/index.mjs +49 -16
  21. package/dist/discovery/index.mjs.map +1 -1
  22. package/dist/gate-D2RP6bZg.d.ts +307 -0
  23. package/dist/gate-GCXy4FHI.d.mts +307 -0
  24. package/dist/identity/express.d.mts +28 -1
  25. package/dist/identity/express.d.ts +28 -1
  26. package/dist/identity/express.js +714 -31
  27. package/dist/identity/express.js.map +1 -1
  28. package/dist/identity/express.mjs +710 -30
  29. package/dist/identity/express.mjs.map +1 -1
  30. package/dist/identity/fastify.d.mts +14 -2
  31. package/dist/identity/fastify.d.ts +14 -2
  32. package/dist/identity/fastify.js +727 -31
  33. package/dist/identity/fastify.js.map +1 -1
  34. package/dist/identity/fastify.mjs +723 -30
  35. package/dist/identity/fastify.mjs.map +1 -1
  36. package/dist/identity/hono.d.mts +28 -1
  37. package/dist/identity/hono.d.ts +28 -1
  38. package/dist/identity/hono.js +696 -33
  39. package/dist/identity/hono.js.map +1 -1
  40. package/dist/identity/hono.mjs +692 -32
  41. package/dist/identity/hono.mjs.map +1 -1
  42. package/dist/identity/nextjs.d.mts +5 -0
  43. package/dist/identity/nextjs.d.ts +5 -0
  44. package/dist/identity/nextjs.js +695 -30
  45. package/dist/identity/nextjs.js.map +1 -1
  46. package/dist/identity/nextjs.mjs +691 -29
  47. package/dist/identity/nextjs.mjs.map +1 -1
  48. package/dist/identity/policy.d.mts +21 -2
  49. package/dist/identity/policy.d.ts +21 -2
  50. package/dist/identity/policy.js +22 -1
  51. package/dist/identity/policy.js.map +1 -1
  52. package/dist/identity/policy.mjs +21 -1
  53. package/dist/identity/policy.mjs.map +1 -1
  54. package/dist/identity/web.d.mts +26 -1
  55. package/dist/identity/web.d.ts +26 -1
  56. package/dist/identity/web.js +695 -30
  57. package/dist/identity/web.js.map +1 -1
  58. package/dist/identity/web.mjs +691 -29
  59. package/dist/identity/web.mjs.map +1 -1
  60. package/dist/index.d.mts +165 -4
  61. package/dist/index.d.ts +165 -4
  62. package/dist/index.js +3103 -534
  63. package/dist/index.js.map +1 -1
  64. package/dist/index.mjs +3086 -545
  65. package/dist/index.mjs.map +1 -1
  66. package/dist/payment/index.d.mts +1 -1
  67. package/dist/payment/index.d.ts +1 -1
  68. package/dist/payment/index.js +10 -2
  69. package/dist/payment/index.js.map +1 -1
  70. package/dist/payment/index.mjs +10 -2
  71. package/dist/payment/index.mjs.map +1 -1
  72. package/dist/stripe-multichain/index.js +1614 -266
  73. package/dist/stripe-multichain/index.js.map +1 -1
  74. package/dist/stripe-multichain/index.mjs +1614 -266
  75. package/dist/stripe-multichain/index.mjs.map +1 -1
  76. package/dist/types-D1slMt0H.d.mts +137 -0
  77. package/dist/types-D1slMt0H.d.ts +137 -0
  78. package/dist/{wwwauthenticate-CVaGUMjU.d.mts → wwwauthenticate-Dgm-_af9.d.mts} +11 -1
  79. package/dist/{wwwauthenticate-CVaGUMjU.d.ts → wwwauthenticate-Dgm-_af9.d.ts} +11 -1
  80. package/package.json +26 -21
@@ -279,6 +279,7 @@ function buildAgentInstructions({
279
279
  }
280
280
 
281
281
  // src/core.ts
282
+ import { createHash } from "crypto";
282
283
  import {
283
284
  AgentScore,
284
285
  InvalidCredentialError,
@@ -318,7 +319,7 @@ var IDENTITY_VERIFICATION_REQUIRED_FALLBACK_INSTRUCTIONS = JSON.stringify({
318
319
  var API_ERROR_INSTRUCTIONS = JSON.stringify({
319
320
  action: "retry_with_backoff",
320
321
  steps: [
321
- "Verification is temporarily unavailable. Retry the request after 5\u201330 seconds with exponential backoff.",
322
+ "Verification is temporarily unavailable. Retry the request after 5-30 seconds with exponential backoff.",
322
323
  "This is NOT a compliance denial \u2014 the user does not need to re-verify their identity. Send the same identity headers (X-Wallet-Address or X-Operator-Token) on retry.",
323
324
  "If the request continues to fail after 3+ retries (~60 seconds total), surface the error to the user with the merchant's support contact."
324
325
  ],
@@ -344,7 +345,7 @@ var TOKEN_EXPIRED_FALLBACK_INSTRUCTIONS = JSON.stringify({
344
345
  });
345
346
 
346
347
  // src/core.ts
347
- var CANONICAL_AGENTSCORE_API = "https://api.agentscore.sh";
348
+ var CANONICAL_AGENTSCORE_API = "https://api.agentscore.com";
348
349
  var WALLET_SIGNER_MISMATCH_INSTRUCTIONS = JSON.stringify({
349
350
  action: "resign_or_switch_to_operator_token",
350
351
  steps: [
@@ -370,17 +371,22 @@ var INVALID_CREDENTIAL_INSTRUCTIONS = JSON.stringify({
370
371
  ],
371
372
  user_message: "The operator_token is not recognized. Use a different stored token, or restart the verification session flow to mint a new one."
372
373
  });
373
- function buildAgentMemoryHint() {
374
+ function buildAgentMemoryHint(aipTrustedIssuers) {
374
375
  const api = CANONICAL_AGENTSCORE_API;
376
+ const acceptsAip = aipTrustedIssuers !== void 0 && aipTrustedIssuers.length > 0;
375
377
  return {
376
378
  save_for_future_agentscore_gates: true,
377
379
  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.",
378
- quickstart: "https://docs.agentscore.sh/guides/agent-identity",
380
+ quickstart: "https://docs.agentscore.com/guides/agent-identity",
379
381
  identity_check_endpoint: `${api}/v1/credentials`,
380
382
  identity_paths: {
381
383
  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.",
382
- 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."
384
+ 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.",
385
+ ...acceptsAip && {
386
+ 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.'
387
+ }
383
388
  },
389
+ ...acceptsAip && { aip_trusted_issuers: aipTrustedIssuers },
384
390
  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.",
385
391
  do_not_persist_in_memory: ["operator_token", "poll_secret"],
386
392
  persist_in_credential_store: ["operator_token"]
@@ -389,10 +395,11 @@ function buildAgentMemoryHint() {
389
395
 
390
396
  // src/challenge/agent_memory.ts
391
397
  function firstEncounterAgentMemory({
392
- firstEncounter
398
+ firstEncounter,
399
+ aipTrustedIssuers
393
400
  }) {
394
401
  if (!firstEncounter) return void 0;
395
- return buildAgentMemoryHint();
402
+ return buildAgentMemoryHint(aipTrustedIssuers);
396
403
  }
397
404
 
398
405
  // src/challenge/body.ts
@@ -418,6 +425,7 @@ function build402Body({
418
425
  if (x402) {
419
426
  body.x402Version = x402.version ?? 2;
420
427
  body.accepts = x402.accepts;
428
+ if (x402.resource !== void 0) body.resource = x402.resource;
421
429
  if (x402.extensions !== void 0 && Object.keys(x402.extensions).length > 0) {
422
430
  body.extensions = x402.extensions;
423
431
  }
@@ -479,9 +487,17 @@ function normalizeHeadersToLowercase(headers) {
479
487
  function paymentRequiredHeader({
480
488
  x402Version,
481
489
  accepts,
482
- resource
490
+ resource,
491
+ extensions
483
492
  }) {
484
- return Buffer.from(JSON.stringify({ x402Version, accepts, ...resource ? { resource } : {} })).toString("base64");
493
+ return Buffer.from(
494
+ JSON.stringify({
495
+ x402Version,
496
+ accepts,
497
+ ...resource ? { resource } : {},
498
+ ...extensions && Object.keys(extensions).length > 0 ? { extensions } : {}
499
+ })
500
+ ).toString("base64");
485
501
  }
486
502
 
487
503
  // src/challenge/respond_402.ts