@agent-score/commerce 1.8.1 → 2.0.1
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-9yp6Fit2.d.mts → _response-BFYN3b6i.d.mts} +17 -19
- package/dist/{_response-CC6jNb8q.d.ts → _response-_iPD5AIj.d.ts} +17 -19
- 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-B1JuEcbx.d.ts +939 -0
- package/dist/checkout-BN5i1Fi7.d.mts +939 -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 +23307 -18
- package/dist/identity/policy.js.map +1 -1
- package/dist/identity/policy.mjs +23313 -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 +23301 -378
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23294 -362
- package/dist/index.mjs.map +1 -1
- package/dist/payment/index.d.mts +297 -265
- package/dist/payment/index.d.ts +297 -265
- package/dist/payment/index.js +605 -149
- package/dist/payment/index.js.map +1 -1
- package/dist/payment/index.mjs +590 -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 +55 -66
- package/dist/stripe-multichain/index.d.ts +55 -66
- 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 +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-
|
|
2
|
-
export { r as readX402PaymentHeader } from '../signer-
|
|
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, FailOpenInfraReason, GateQuotaInfo, SignerVerdict } from '../core.mjs';
|
|
4
4
|
import { Request, Response, NextFunction } from 'express';
|
|
5
5
|
|
|
@@ -56,4 +56,4 @@ declare function captureWallet(req: Request, options: {
|
|
|
56
56
|
*/
|
|
57
57
|
declare function getSignerVerdict(req: Request): SignerVerdict | undefined;
|
|
58
58
|
|
|
59
|
-
export {
|
|
59
|
+
export { agentscoreGate, captureWallet, getAgentScoreData, getGateDegradedState, getGateQuotaInfo, getSignerVerdict };
|
|
@@ -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-
|
|
2
|
-
export { r as readX402PaymentHeader } from '../signer-
|
|
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, FailOpenInfraReason, GateQuotaInfo, SignerVerdict } from '../core.js';
|
|
4
4
|
import { Request, Response, NextFunction } from 'express';
|
|
5
5
|
|
|
@@ -56,4 +56,4 @@ declare function captureWallet(req: Request, options: {
|
|
|
56
56
|
*/
|
|
57
57
|
declare function getSignerVerdict(req: Request): SignerVerdict | undefined;
|
|
58
58
|
|
|
59
|
-
export {
|
|
59
|
+
export { agentscoreGate, captureWallet, getAgentScoreData, getGateDegradedState, getGateQuotaInfo, getSignerVerdict };
|
package/dist/identity/express.js
CHANGED
|
@@ -52,13 +52,16 @@ function denialReasonStatus(reason) {
|
|
|
52
52
|
if (reason.code === "api_error") return 503;
|
|
53
53
|
return 403;
|
|
54
54
|
}
|
|
55
|
-
function buildSignerMismatchBody(
|
|
56
|
-
|
|
55
|
+
function buildSignerMismatchBody({
|
|
56
|
+
result,
|
|
57
|
+
userMessage,
|
|
58
|
+
learnMoreUrl
|
|
59
|
+
}) {
|
|
57
60
|
if (result.kind === "pass") return null;
|
|
58
|
-
const
|
|
61
|
+
const learnMoreUrlResolved = learnMoreUrl ?? "https://docs.agentscore.sh/guides/agent-identity";
|
|
59
62
|
if (result.kind === "wallet_signer_mismatch") {
|
|
60
63
|
const linkedWallets = result.linkedWallets ?? [];
|
|
61
|
-
const
|
|
64
|
+
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.");
|
|
62
65
|
return {
|
|
63
66
|
error: {
|
|
64
67
|
code: "wallet_signer_mismatch",
|
|
@@ -71,8 +74,8 @@ function buildSignerMismatchBody(input) {
|
|
|
71
74
|
linked_wallets: linkedWallets,
|
|
72
75
|
next_steps: {
|
|
73
76
|
action: "regenerate_payment_from_linked_wallet",
|
|
74
|
-
user_message:
|
|
75
|
-
learn_more_url:
|
|
77
|
+
user_message: userMessageResolved,
|
|
78
|
+
learn_more_url: learnMoreUrlResolved
|
|
76
79
|
}
|
|
77
80
|
};
|
|
78
81
|
}
|
|
@@ -83,8 +86,8 @@ function buildSignerMismatchBody(input) {
|
|
|
83
86
|
},
|
|
84
87
|
next_steps: {
|
|
85
88
|
action: "switch_to_operator_token",
|
|
86
|
-
user_message:
|
|
87
|
-
learn_more_url:
|
|
89
|
+
user_message: userMessage ?? "Drop the X-Wallet-Address header and retry with X-Operator-Token (works on every payment rail).",
|
|
90
|
+
learn_more_url: learnMoreUrlResolved
|
|
88
91
|
}
|
|
89
92
|
};
|
|
90
93
|
}
|
|
@@ -92,27 +95,35 @@ function buildContactSupportNextSteps(supportEmail, message) {
|
|
|
92
95
|
return {
|
|
93
96
|
action: "contact_support",
|
|
94
97
|
support_email: supportEmail,
|
|
95
|
-
user_message: message ?? `If you believe this denial is in error, contact support at ${supportEmail} with your
|
|
98
|
+
user_message: message ?? `If you believe this denial is in error, contact support at ${supportEmail} with the details of your request.`
|
|
96
99
|
};
|
|
97
100
|
}
|
|
98
|
-
function verificationAgentInstructions(
|
|
101
|
+
function verificationAgentInstructions({
|
|
102
|
+
userAction,
|
|
103
|
+
retryStep,
|
|
104
|
+
extraSteps,
|
|
105
|
+
pollIntervalSeconds = 5,
|
|
106
|
+
timeoutSeconds = 3600,
|
|
107
|
+
orderTtl,
|
|
108
|
+
extra
|
|
109
|
+
} = {}) {
|
|
99
110
|
const baseSteps = [
|
|
100
111
|
"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.",
|
|
101
|
-
`Immediately begin polling poll_url every ${
|
|
112
|
+
`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.`,
|
|
102
113
|
"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.",
|
|
103
114
|
'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.',
|
|
104
|
-
|
|
115
|
+
retryStep ?? "Retry the original merchant request with header X-Operator-Token set to the operator_token value."
|
|
105
116
|
];
|
|
106
117
|
return {
|
|
107
118
|
action: "poll_for_credential",
|
|
108
|
-
user_action:
|
|
109
|
-
steps:
|
|
110
|
-
poll_interval_seconds:
|
|
119
|
+
user_action: userAction ?? "The user must visit verify_url to complete identity verification before this request can proceed",
|
|
120
|
+
steps: extraSteps ? [...baseSteps, ...extraSteps] : baseSteps,
|
|
121
|
+
poll_interval_seconds: pollIntervalSeconds,
|
|
111
122
|
poll_secret_header: "X-Poll-Secret",
|
|
112
123
|
retry_token_header: "X-Operator-Token",
|
|
113
|
-
timeout_seconds:
|
|
114
|
-
...
|
|
115
|
-
...
|
|
124
|
+
timeout_seconds: timeoutSeconds,
|
|
125
|
+
...orderTtl ? { order_ttl: orderTtl } : {},
|
|
126
|
+
...extra ?? {}
|
|
116
127
|
};
|
|
117
128
|
}
|
|
118
129
|
|
|
@@ -364,7 +375,7 @@ function createAgentScoreCore(options) {
|
|
|
364
375
|
} = options;
|
|
365
376
|
const baseUrl = stripTrailingSlashes(rawBaseUrl);
|
|
366
377
|
const agentMemoryHint = buildAgentMemoryHint();
|
|
367
|
-
const defaultUa = `@agent-score/commerce@${"
|
|
378
|
+
const defaultUa = `@agent-score/commerce@${"2.0.1"}`;
|
|
368
379
|
const userAgentHeader = userAgent ? `${userAgent} (${defaultUa})` : defaultUa;
|
|
369
380
|
const sdk = new import_sdk.AgentScore({ apiKey, baseUrl, userAgent: userAgentHeader });
|
|
370
381
|
const sessionSdkCache = /* @__PURE__ */ new Map();
|