@agent-score/commerce 1.8.1 → 2.0.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 (90) hide show
  1. package/README.md +73 -9
  2. package/dist/{_response-9yp6Fit2.d.mts → _response-BFYN3b6i.d.mts} +17 -19
  3. package/dist/{_response-CC6jNb8q.d.ts → _response-_iPD5AIj.d.ts} +17 -19
  4. package/dist/challenge/index.d.mts +106 -198
  5. package/dist/challenge/index.d.ts +106 -198
  6. package/dist/challenge/index.js +238 -111
  7. package/dist/challenge/index.js.map +1 -1
  8. package/dist/challenge/index.mjs +238 -111
  9. package/dist/challenge/index.mjs.map +1 -1
  10. package/dist/checkout-BoFwnVsj.d.ts +931 -0
  11. package/dist/checkout-DRbQ0Fsh.d.mts +931 -0
  12. package/dist/core.d.mts +2 -2
  13. package/dist/core.d.ts +2 -2
  14. package/dist/core.js +1 -1
  15. package/dist/core.js.map +1 -1
  16. package/dist/core.mjs +1 -1
  17. package/dist/core.mjs.map +1 -1
  18. package/dist/discovery/index.d.mts +453 -51
  19. package/dist/discovery/index.d.ts +453 -51
  20. package/dist/discovery/index.js +1092 -58
  21. package/dist/discovery/index.js.map +1 -1
  22. package/dist/discovery/index.mjs +1060 -57
  23. package/dist/discovery/index.mjs.map +1 -1
  24. package/dist/identity/express.d.mts +3 -3
  25. package/dist/identity/express.d.ts +3 -3
  26. package/dist/identity/express.js +30 -19
  27. package/dist/identity/express.js.map +1 -1
  28. package/dist/identity/express.mjs +30 -19
  29. package/dist/identity/express.mjs.map +1 -1
  30. package/dist/identity/fastify.d.mts +4 -4
  31. package/dist/identity/fastify.d.ts +4 -4
  32. package/dist/identity/fastify.js +30 -19
  33. package/dist/identity/fastify.js.map +1 -1
  34. package/dist/identity/fastify.mjs +30 -19
  35. package/dist/identity/fastify.mjs.map +1 -1
  36. package/dist/identity/hono.d.mts +3 -3
  37. package/dist/identity/hono.d.ts +3 -3
  38. package/dist/identity/hono.js +30 -19
  39. package/dist/identity/hono.js.map +1 -1
  40. package/dist/identity/hono.mjs +30 -19
  41. package/dist/identity/hono.mjs.map +1 -1
  42. package/dist/identity/nextjs.d.mts +6 -7
  43. package/dist/identity/nextjs.d.ts +6 -7
  44. package/dist/identity/nextjs.js +30 -19
  45. package/dist/identity/nextjs.js.map +1 -1
  46. package/dist/identity/nextjs.mjs +30 -19
  47. package/dist/identity/nextjs.mjs.map +1 -1
  48. package/dist/identity/policy.d.mts +41 -4
  49. package/dist/identity/policy.d.ts +41 -4
  50. package/dist/identity/policy.js +3662 -18
  51. package/dist/identity/policy.js.map +1 -1
  52. package/dist/identity/policy.mjs +3648 -3
  53. package/dist/identity/policy.mjs.map +1 -1
  54. package/dist/identity/web.d.mts +3 -3
  55. package/dist/identity/web.d.ts +3 -3
  56. package/dist/identity/web.js +30 -19
  57. package/dist/identity/web.js.map +1 -1
  58. package/dist/identity/web.mjs +30 -19
  59. package/dist/identity/web.mjs.map +1 -1
  60. package/dist/index.d.mts +72 -329
  61. package/dist/index.d.ts +72 -329
  62. package/dist/index.js +3651 -373
  63. package/dist/index.js.map +1 -1
  64. package/dist/index.mjs +3628 -361
  65. package/dist/index.mjs.map +1 -1
  66. package/dist/payment/index.d.mts +256 -265
  67. package/dist/payment/index.d.ts +256 -265
  68. package/dist/payment/index.js +586 -149
  69. package/dist/payment/index.js.map +1 -1
  70. package/dist/payment/index.mjs +573 -148
  71. package/dist/payment/index.mjs.map +1 -1
  72. package/dist/{agent_instructions-DiMSGkdm.d.mts → pricing-CQ9DIFaw.d.ts} +109 -56
  73. package/dist/{agent_instructions-DiMSGkdm.d.ts → pricing-CxzwyiO6.d.mts} +109 -56
  74. package/dist/rail_spec-XP0wKgJV.d.mts +132 -0
  75. package/dist/rail_spec-XP0wKgJV.d.ts +132 -0
  76. package/dist/{signer-CFVQsWjL.d.mts → signer-3FAit11j.d.mts} +27 -1
  77. package/dist/{signer-CFVQsWjL.d.ts → signer-3FAit11j.d.ts} +27 -1
  78. package/dist/solana-Cds87OTu.d.mts +67 -0
  79. package/dist/solana-Cds87OTu.d.ts +67 -0
  80. package/dist/stripe-multichain/index.d.mts +55 -66
  81. package/dist/stripe-multichain/index.d.ts +55 -66
  82. package/dist/stripe-multichain/index.js +68 -42
  83. package/dist/stripe-multichain/index.js.map +1 -1
  84. package/dist/stripe-multichain/index.mjs +68 -41
  85. package/dist/stripe-multichain/index.mjs.map +1 -1
  86. package/dist/{wwwauthenticate-CU1eNvMQ.d.mts → wwwauthenticate-D_FMnPgU.d.mts} +9 -10
  87. package/dist/{wwwauthenticate-CU1eNvMQ.d.ts → wwwauthenticate-D_FMnPgU.d.ts} +9 -10
  88. package/dist/x402_server-hgQzWQwB.d.mts +81 -0
  89. package/dist/x402_server-hgQzWQwB.d.ts +81 -0
  90. package/package.json +9 -7
@@ -1,5 +1,5 @@
1
- export { F as FIXABLE_DENIAL_REASONS, b as buildContactSupportNextSteps, a as buildSignerMismatchBody, d as denialReasonStatus, c as denialReasonToBody, i as isFixableDenial, v as verificationAgentInstructions } from '../_response-9yp6Fit2.mjs';
2
- export { r as readX402PaymentHeader } from '../signer-CFVQsWjL.mjs';
1
+ export { F as FIXABLE_DENIAL_REASONS, b as buildContactSupportNextSteps, a as buildSignerMismatchBody, d as denialReasonStatus, c as denialReasonToBody, i as isFixableDenial, v as verificationAgentInstructions } from '../_response-BFYN3b6i.mjs';
2
+ export { r as readX402PaymentHeader } from '../signer-3FAit11j.mjs';
3
3
  import { AgentScoreCoreOptions, AgentIdentity, DenialReason, CreateSessionOnMissing, AssessResult, SignerVerdict, FailOpenInfraReason, GateQuotaInfo } from '../core.mjs';
4
4
 
5
5
  interface AgentScoreGateOptions extends Omit<AgentScoreCoreOptions, 'createSessionOnMissing'> {
@@ -91,4 +91,4 @@ declare function withAgentScoreGate<TCtx = unknown>(options: AgentScoreGateOptio
91
91
  quota?: GateQuotaInfo;
92
92
  }, ctx?: TCtx) => Response | Promise<Response>): (req: Request, ctx?: TCtx) => Promise<Response>;
93
93
 
94
- export { type AgentScoreGateOptions, type GuardResult, createAgentScoreGate, withAgentScoreGate };
94
+ export { type GuardResult, createAgentScoreGate, withAgentScoreGate };
@@ -1,5 +1,5 @@
1
- export { F as FIXABLE_DENIAL_REASONS, b as buildContactSupportNextSteps, a as buildSignerMismatchBody, d as denialReasonStatus, c as denialReasonToBody, i as isFixableDenial, v as verificationAgentInstructions } from '../_response-CC6jNb8q.js';
2
- export { r as readX402PaymentHeader } from '../signer-CFVQsWjL.js';
1
+ export { F as FIXABLE_DENIAL_REASONS, b as buildContactSupportNextSteps, a as buildSignerMismatchBody, d as denialReasonStatus, c as denialReasonToBody, i as isFixableDenial, v as verificationAgentInstructions } from '../_response-_iPD5AIj.js';
2
+ export { r as readX402PaymentHeader } from '../signer-3FAit11j.js';
3
3
  import { AgentScoreCoreOptions, AgentIdentity, DenialReason, CreateSessionOnMissing, AssessResult, SignerVerdict, FailOpenInfraReason, GateQuotaInfo } from '../core.js';
4
4
 
5
5
  interface AgentScoreGateOptions extends Omit<AgentScoreCoreOptions, 'createSessionOnMissing'> {
@@ -91,4 +91,4 @@ declare function withAgentScoreGate<TCtx = unknown>(options: AgentScoreGateOptio
91
91
  quota?: GateQuotaInfo;
92
92
  }, ctx?: TCtx) => Response | Promise<Response>): (req: Request, ctx?: TCtx) => Promise<Response>;
93
93
 
94
- export { type AgentScoreGateOptions, type GuardResult, createAgentScoreGate, withAgentScoreGate };
94
+ export { type GuardResult, createAgentScoreGate, withAgentScoreGate };
@@ -48,13 +48,16 @@ function denialReasonStatus(reason) {
48
48
  if (reason.code === "api_error") return 503;
49
49
  return 403;
50
50
  }
51
- function buildSignerMismatchBody(input) {
52
- const { result } = input;
51
+ function buildSignerMismatchBody({
52
+ result,
53
+ userMessage,
54
+ learnMoreUrl
55
+ }) {
53
56
  if (result.kind === "pass") return null;
54
- const learnMoreUrl = input.learnMoreUrl ?? "https://docs.agentscore.sh/guides/agent-identity";
57
+ const learnMoreUrlResolved = learnMoreUrl ?? "https://docs.agentscore.sh/guides/agent-identity";
55
58
  if (result.kind === "wallet_signer_mismatch") {
56
59
  const linkedWallets = result.linkedWallets ?? [];
57
- const userMessage = input.userMessage ?? (linkedWallets.length > 0 ? `Sign the payment with one of the wallets linked to this operator: ${linkedWallets.join(", ")}. Then retry.` : "Sign the payment with the same wallet you claimed via X-Wallet-Address, or switch to X-Operator-Token for rail-independent identity.");
60
+ const userMessageResolved = userMessage ?? (linkedWallets.length > 0 ? `Sign the payment with one of the wallets linked to this operator: ${linkedWallets.join(", ")}. Then retry.` : "Sign the payment with the same wallet you claimed via X-Wallet-Address, or switch to X-Operator-Token for rail-independent identity.");
58
61
  return {
59
62
  error: {
60
63
  code: "wallet_signer_mismatch",
@@ -67,8 +70,8 @@ function buildSignerMismatchBody(input) {
67
70
  linked_wallets: linkedWallets,
68
71
  next_steps: {
69
72
  action: "regenerate_payment_from_linked_wallet",
70
- user_message: userMessage,
71
- learn_more_url: learnMoreUrl
73
+ user_message: userMessageResolved,
74
+ learn_more_url: learnMoreUrlResolved
72
75
  }
73
76
  };
74
77
  }
@@ -79,8 +82,8 @@ function buildSignerMismatchBody(input) {
79
82
  },
80
83
  next_steps: {
81
84
  action: "switch_to_operator_token",
82
- user_message: input.userMessage ?? "Drop the X-Wallet-Address header and retry with X-Operator-Token (works on every payment rail).",
83
- learn_more_url: learnMoreUrl
85
+ user_message: userMessage ?? "Drop the X-Wallet-Address header and retry with X-Operator-Token (works on every payment rail).",
86
+ learn_more_url: learnMoreUrlResolved
84
87
  }
85
88
  };
86
89
  }
@@ -88,27 +91,35 @@ function buildContactSupportNextSteps(supportEmail, message) {
88
91
  return {
89
92
  action: "contact_support",
90
93
  support_email: supportEmail,
91
- user_message: message ?? `If you believe this denial is in error, contact support at ${supportEmail} with your order details.`
94
+ user_message: message ?? `If you believe this denial is in error, contact support at ${supportEmail} with the details of your request.`
92
95
  };
93
96
  }
94
- function verificationAgentInstructions(input = {}) {
97
+ function verificationAgentInstructions({
98
+ userAction,
99
+ retryStep,
100
+ extraSteps,
101
+ pollIntervalSeconds = 5,
102
+ timeoutSeconds = 3600,
103
+ orderTtl,
104
+ extra
105
+ } = {}) {
95
106
  const baseSteps = [
96
107
  "Present the verify_url directly to the user \u2014 it is a complete, ready-to-open URL with the session token already embedded (e.g. https://agentscore.sh/verify?session=sess_...). Do NOT modify or construct the URL yourself.",
97
- `Immediately begin polling poll_url every ${input.pollIntervalSeconds ?? 5} seconds with header X-Poll-Secret set to poll_secret. The user will complete verification in their browser while you poll in the background.`,
108
+ `Immediately begin polling poll_url every ${pollIntervalSeconds} seconds with header X-Poll-Secret set to poll_secret. The user will complete verification in their browser while you poll in the background.`,
98
109
  "The user visits the URL, signs in, completes identity verification (photo ID + selfie via Stripe Identity), and closes the tab. They do NOT need to copy or paste anything back to you.",
99
110
  'When your poll returns status "verified", extract operator_token from the response. This is a one-time value \u2014 save it immediately. Subsequent polls return status "consumed" without the token.',
100
- input.retryStep ?? "Retry the original merchant request with header X-Operator-Token set to the operator_token value."
111
+ retryStep ?? "Retry the original merchant request with header X-Operator-Token set to the operator_token value."
101
112
  ];
102
113
  return {
103
114
  action: "poll_for_credential",
104
- user_action: input.userAction ?? "The user must visit verify_url to complete identity verification before this request can proceed",
105
- steps: input.extraSteps ? [...baseSteps, ...input.extraSteps] : baseSteps,
106
- poll_interval_seconds: input.pollIntervalSeconds ?? 5,
115
+ user_action: userAction ?? "The user must visit verify_url to complete identity verification before this request can proceed",
116
+ steps: extraSteps ? [...baseSteps, ...extraSteps] : baseSteps,
117
+ poll_interval_seconds: pollIntervalSeconds,
107
118
  poll_secret_header: "X-Poll-Secret",
108
119
  retry_token_header: "X-Operator-Token",
109
- timeout_seconds: input.timeoutSeconds ?? 3600,
110
- ...input.orderTtl ? { order_ttl: input.orderTtl } : {},
111
- ...input.extra ?? {}
120
+ timeout_seconds: timeoutSeconds,
121
+ ...orderTtl ? { order_ttl: orderTtl } : {},
122
+ ...extra ?? {}
112
123
  };
113
124
  }
114
125
 
@@ -360,7 +371,7 @@ function createAgentScoreCore(options) {
360
371
  } = options;
361
372
  const baseUrl = stripTrailingSlashes(rawBaseUrl);
362
373
  const agentMemoryHint = buildAgentMemoryHint();
363
- const defaultUa = `@agent-score/commerce@${"1.8.1"}`;
374
+ const defaultUa = `@agent-score/commerce@${"2.0.0"}`;
364
375
  const userAgentHeader = userAgent ? `${userAgent} (${defaultUa})` : defaultUa;
365
376
  const sdk = new import_sdk.AgentScore({ apiKey, baseUrl, userAgent: userAgentHeader });
366
377
  const sessionSdkCache = /* @__PURE__ */ new Map();