@agent-score/commerce 1.8.0 → 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.
- package/README.md +73 -9
- package/dist/{_response-BMt2y4Or.d.mts → _response-BFYN3b6i.d.mts} +19 -22
- package/dist/{_response-DyJ3mWI3.d.ts → _response-_iPD5AIj.d.ts} +19 -22
- package/dist/challenge/index.d.mts +106 -198
- package/dist/challenge/index.d.ts +106 -198
- package/dist/challenge/index.js +238 -111
- package/dist/challenge/index.js.map +1 -1
- package/dist/challenge/index.mjs +238 -111
- package/dist/challenge/index.mjs.map +1 -1
- package/dist/checkout-BoFwnVsj.d.ts +931 -0
- package/dist/checkout-DRbQ0Fsh.d.mts +931 -0
- package/dist/core.d.mts +2 -2
- package/dist/core.d.ts +2 -2
- package/dist/core.js +1 -1
- package/dist/core.js.map +1 -1
- package/dist/core.mjs +1 -1
- package/dist/core.mjs.map +1 -1
- package/dist/discovery/index.d.mts +453 -51
- package/dist/discovery/index.d.ts +453 -51
- package/dist/discovery/index.js +1092 -58
- package/dist/discovery/index.js.map +1 -1
- package/dist/discovery/index.mjs +1060 -57
- package/dist/discovery/index.mjs.map +1 -1
- package/dist/identity/express.d.mts +3 -3
- package/dist/identity/express.d.ts +3 -3
- package/dist/identity/express.js +30 -19
- package/dist/identity/express.js.map +1 -1
- package/dist/identity/express.mjs +30 -19
- package/dist/identity/express.mjs.map +1 -1
- package/dist/identity/fastify.d.mts +4 -4
- package/dist/identity/fastify.d.ts +4 -4
- package/dist/identity/fastify.js +30 -19
- package/dist/identity/fastify.js.map +1 -1
- package/dist/identity/fastify.mjs +30 -19
- package/dist/identity/fastify.mjs.map +1 -1
- package/dist/identity/hono.d.mts +3 -3
- package/dist/identity/hono.d.ts +3 -3
- package/dist/identity/hono.js +30 -19
- package/dist/identity/hono.js.map +1 -1
- package/dist/identity/hono.mjs +30 -19
- package/dist/identity/hono.mjs.map +1 -1
- package/dist/identity/nextjs.d.mts +6 -7
- package/dist/identity/nextjs.d.ts +6 -7
- package/dist/identity/nextjs.js +30 -19
- package/dist/identity/nextjs.js.map +1 -1
- package/dist/identity/nextjs.mjs +30 -19
- package/dist/identity/nextjs.mjs.map +1 -1
- package/dist/identity/policy.d.mts +41 -4
- package/dist/identity/policy.d.ts +41 -4
- package/dist/identity/policy.js +3662 -18
- package/dist/identity/policy.js.map +1 -1
- package/dist/identity/policy.mjs +3648 -3
- package/dist/identity/policy.mjs.map +1 -1
- package/dist/identity/web.d.mts +3 -3
- package/dist/identity/web.d.ts +3 -3
- package/dist/identity/web.js +30 -19
- package/dist/identity/web.js.map +1 -1
- package/dist/identity/web.mjs +30 -19
- package/dist/identity/web.mjs.map +1 -1
- package/dist/index.d.mts +72 -329
- package/dist/index.d.ts +72 -329
- package/dist/index.js +3651 -373
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3628 -361
- package/dist/index.mjs.map +1 -1
- package/dist/payment/index.d.mts +257 -266
- package/dist/payment/index.d.ts +257 -266
- package/dist/payment/index.js +586 -149
- package/dist/payment/index.js.map +1 -1
- package/dist/payment/index.mjs +573 -148
- package/dist/payment/index.mjs.map +1 -1
- package/dist/{agent_instructions-DiMSGkdm.d.mts → pricing-CQ9DIFaw.d.ts} +109 -56
- package/dist/{agent_instructions-DiMSGkdm.d.ts → pricing-CxzwyiO6.d.mts} +109 -56
- package/dist/rail_spec-XP0wKgJV.d.mts +132 -0
- package/dist/rail_spec-XP0wKgJV.d.ts +132 -0
- package/dist/{signer-CFVQsWjL.d.mts → signer-3FAit11j.d.mts} +27 -1
- package/dist/{signer-CFVQsWjL.d.ts → signer-3FAit11j.d.ts} +27 -1
- package/dist/solana-Cds87OTu.d.mts +67 -0
- package/dist/solana-Cds87OTu.d.ts +67 -0
- package/dist/stripe-multichain/index.d.mts +56 -67
- package/dist/stripe-multichain/index.d.ts +56 -67
- package/dist/stripe-multichain/index.js +68 -42
- package/dist/stripe-multichain/index.js.map +1 -1
- package/dist/stripe-multichain/index.mjs +68 -41
- package/dist/stripe-multichain/index.mjs.map +1 -1
- package/dist/{wwwauthenticate-CU1eNvMQ.d.mts → wwwauthenticate-D_FMnPgU.d.mts} +9 -10
- package/dist/{wwwauthenticate-CU1eNvMQ.d.ts → wwwauthenticate-D_FMnPgU.d.ts} +9 -10
- package/dist/x402_server-hgQzWQwB.d.mts +81 -0
- package/dist/x402_server-hgQzWQwB.d.ts +81 -0
- package/package.json +13 -9
package/dist/identity/nextjs.js
CHANGED
|
@@ -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(
|
|
52
|
-
|
|
51
|
+
function buildSignerMismatchBody({
|
|
52
|
+
result,
|
|
53
|
+
userMessage,
|
|
54
|
+
learnMoreUrl
|
|
55
|
+
}) {
|
|
53
56
|
if (result.kind === "pass") return null;
|
|
54
|
-
const
|
|
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
|
|
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:
|
|
71
|
-
learn_more_url:
|
|
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:
|
|
83
|
-
learn_more_url:
|
|
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
|
|
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(
|
|
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 ${
|
|
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
|
-
|
|
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:
|
|
105
|
-
steps:
|
|
106
|
-
poll_interval_seconds:
|
|
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:
|
|
110
|
-
...
|
|
111
|
-
...
|
|
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@${"
|
|
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();
|