@agent-score/commerce 1.5.1 → 1.7.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 +27 -15
- package/dist/challenge/index.js.map +1 -1
- package/dist/challenge/index.mjs.map +1 -1
- package/dist/core.d.mts +36 -27
- package/dist/core.d.ts +36 -27
- 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/identity/express.d.mts +2 -2
- package/dist/identity/express.d.ts +2 -2
- package/dist/identity/express.js +1 -1
- package/dist/identity/express.js.map +1 -1
- package/dist/identity/express.mjs +1 -1
- package/dist/identity/express.mjs.map +1 -1
- package/dist/identity/fastify.d.mts +2 -2
- package/dist/identity/fastify.d.ts +2 -2
- package/dist/identity/fastify.js +1 -1
- package/dist/identity/fastify.js.map +1 -1
- package/dist/identity/fastify.mjs +1 -1
- package/dist/identity/fastify.mjs.map +1 -1
- package/dist/identity/hono.d.mts +2 -2
- package/dist/identity/hono.d.ts +2 -2
- package/dist/identity/hono.js +1 -1
- package/dist/identity/hono.js.map +1 -1
- package/dist/identity/hono.mjs +1 -1
- package/dist/identity/hono.mjs.map +1 -1
- package/dist/identity/nextjs.d.mts +2 -2
- package/dist/identity/nextjs.d.ts +2 -2
- package/dist/identity/nextjs.js +1 -1
- package/dist/identity/nextjs.js.map +1 -1
- package/dist/identity/nextjs.mjs +1 -1
- package/dist/identity/nextjs.mjs.map +1 -1
- package/dist/identity/policy.d.mts +3 -3
- package/dist/identity/policy.d.ts +3 -3
- package/dist/identity/policy.js +3 -3
- package/dist/identity/policy.js.map +1 -1
- package/dist/identity/policy.mjs +2 -2
- 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 +1 -1
- package/dist/identity/web.js.map +1 -1
- package/dist/identity/web.mjs +1 -1
- package/dist/identity/web.mjs.map +1 -1
- package/dist/index.d.mts +286 -130
- package/dist/index.d.ts +286 -130
- package/dist/index.js +130 -72
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +124 -69
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -32,11 +32,13 @@ var index_exports = {};
|
|
|
32
32
|
__export(index_exports, {
|
|
33
33
|
AGENTSCORE_UCP_CAPABILITY: () => AGENTSCORE_UCP_CAPABILITY,
|
|
34
34
|
FIXABLE_DENIAL_REASONS: () => FIXABLE_DENIAL_REASONS,
|
|
35
|
+
UCPSigningKey: () => UCPSigningKey,
|
|
35
36
|
UCPVerificationError: () => UCPVerificationError,
|
|
36
37
|
UCP_A2A_EXTENSION_URI: () => UCP_A2A_EXTENSION_URI,
|
|
37
38
|
buildA2AAgentCard: () => buildA2AAgentCard,
|
|
38
39
|
buildAgentMemoryHint: () => buildAgentMemoryHint,
|
|
39
40
|
buildContactSupportNextSteps: () => buildContactSupportNextSteps,
|
|
41
|
+
buildGateOptionsFromPolicy: () => buildGateOptionsFromPolicy,
|
|
40
42
|
buildJWKSResponse: () => buildJWKSResponse,
|
|
41
43
|
buildSignerMismatchBody: () => buildSignerMismatchBody,
|
|
42
44
|
buildUCPProfile: () => buildUCPProfile,
|
|
@@ -46,16 +48,17 @@ __export(index_exports, {
|
|
|
46
48
|
extractPaymentSignerAddress: () => extractPaymentSignerAddress,
|
|
47
49
|
generateUCPSigningKey: () => generateUCPSigningKey,
|
|
48
50
|
isFixableDenial: () => isFixableDenial,
|
|
49
|
-
|
|
51
|
+
mppPaymentHandler: () => mppPaymentHandler,
|
|
50
52
|
readX402PaymentHeader: () => readX402PaymentHeader,
|
|
51
53
|
runGateWithEnforcement: () => runGateWithEnforcement,
|
|
52
54
|
shippingCountryAllowed: () => shippingCountryAllowed,
|
|
53
55
|
shippingStateAllowed: () => shippingStateAllowed,
|
|
54
56
|
signUCPProfile: () => signUCPProfile,
|
|
57
|
+
stripeSptPaymentHandler: () => stripeSptPaymentHandler,
|
|
55
58
|
ucpA2AExtension: () => ucpA2AExtension,
|
|
56
|
-
ucpSigningKeyFromJWK: () => ucpSigningKeyFromJWK,
|
|
57
59
|
verificationAgentInstructions: () => verificationAgentInstructions,
|
|
58
|
-
verifyUCPProfile: () => verifyUCPProfile
|
|
60
|
+
verifyUCPProfile: () => verifyUCPProfile,
|
|
61
|
+
x402PaymentHandler: () => x402PaymentHandler
|
|
59
62
|
});
|
|
60
63
|
module.exports = __toCommonJS(index_exports);
|
|
61
64
|
|
|
@@ -384,73 +387,86 @@ function readX402PaymentHeader(request) {
|
|
|
384
387
|
}
|
|
385
388
|
|
|
386
389
|
// src/identity/a2a.ts
|
|
390
|
+
var PROTOCOL_VERSION = "1.0";
|
|
391
|
+
var DEFAULT_PROTOCOL_BINDING = "HTTP+JSON";
|
|
392
|
+
var DEFAULT_INPUT_MODE = "application/json";
|
|
393
|
+
var DEFAULT_OUTPUT_MODE = "application/json";
|
|
387
394
|
var UCP_A2A_EXTENSION_URI = "https://ucp.dev/2026-04-08/specification/reference";
|
|
388
|
-
function ucpA2AExtension(capabilities = {}) {
|
|
395
|
+
function ucpA2AExtension(capabilities = {}, options = {}) {
|
|
389
396
|
return {
|
|
390
397
|
uri: UCP_A2A_EXTENSION_URI,
|
|
398
|
+
description: "UCP support: this agent serves Universal Commerce Protocol bindings via the A2A transport.",
|
|
399
|
+
required: options.required ?? false,
|
|
391
400
|
params: { capabilities }
|
|
392
401
|
};
|
|
393
402
|
}
|
|
394
|
-
var PROTOCOL_VERSION = "1.0";
|
|
395
|
-
var CARD_VERSION = 1;
|
|
396
403
|
function buildA2AAgentCard(input) {
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
if (operatorId) {
|
|
402
|
-
const operatorVerification = input.data.operator_verification;
|
|
403
|
-
const accountVerification = input.data.account_verification;
|
|
404
|
-
identity = {
|
|
405
|
-
issuer,
|
|
406
|
-
operator_id: operatorId,
|
|
407
|
-
kyc_level: accountVerification?.kyc_level ?? operatorVerification?.level ?? "none",
|
|
408
|
-
sanctions_clear: accountVerification?.sanctions_clear === true,
|
|
409
|
-
age_bracket: accountVerification?.age_bracket ?? "unknown",
|
|
410
|
-
jurisdiction: accountVerification?.jurisdiction ?? "",
|
|
411
|
-
verified_at: accountVerification?.verified_at ?? operatorVerification?.verified_at ?? null,
|
|
412
|
-
verify_url: input.verifyUrl ?? input.data.verify_url ?? `${issuer}/verify`
|
|
413
|
-
};
|
|
414
|
-
}
|
|
404
|
+
if (!input.skills || input.skills.length === 0) {
|
|
405
|
+
throw new Error(
|
|
406
|
+
"buildA2AAgentCard: `skills` MUST be a non-empty list. Per spec \xA74.4.1 (proto field 12 [field_behavior=REQUIRED]), every Agent Card must declare at least one AgentSkill. Construct A2AAgentCard directly to bypass."
|
|
407
|
+
);
|
|
415
408
|
}
|
|
409
|
+
const capabilities = {};
|
|
410
|
+
if (input.streaming !== void 0) capabilities.streaming = input.streaming;
|
|
411
|
+
if (input.push_notifications !== void 0) capabilities.push_notifications = input.push_notifications;
|
|
412
|
+
if (input.extensions && input.extensions.length > 0) capabilities.extensions = input.extensions;
|
|
413
|
+
if (input.extended_agent_card !== void 0) capabilities.extended_agent_card = input.extended_agent_card;
|
|
414
|
+
const primaryInterface = {
|
|
415
|
+
url: input.url,
|
|
416
|
+
protocol_binding: input.protocol_binding ?? DEFAULT_PROTOCOL_BINDING,
|
|
417
|
+
protocol_version: input.a2a_protocol_version ?? PROTOCOL_VERSION
|
|
418
|
+
};
|
|
416
419
|
const card = {
|
|
417
|
-
protocol_version: PROTOCOL_VERSION,
|
|
418
|
-
card_version: CARD_VERSION,
|
|
419
420
|
name: input.name,
|
|
420
|
-
|
|
421
|
+
description: input.description,
|
|
422
|
+
supported_interfaces: [primaryInterface],
|
|
423
|
+
version: input.version ?? "1.0.0",
|
|
424
|
+
capabilities,
|
|
425
|
+
default_input_modes: input.default_input_modes ?? [DEFAULT_INPUT_MODE],
|
|
426
|
+
default_output_modes: input.default_output_modes ?? [DEFAULT_OUTPUT_MODE],
|
|
427
|
+
skills: input.skills
|
|
421
428
|
};
|
|
422
|
-
if (input.
|
|
423
|
-
if (input.
|
|
424
|
-
if (input.
|
|
425
|
-
if (input.
|
|
426
|
-
if (input.
|
|
429
|
+
if (input.provider !== void 0) card.provider = input.provider;
|
|
430
|
+
if (input.documentation_url !== void 0) card.documentation_url = input.documentation_url;
|
|
431
|
+
if (input.icon_url !== void 0) card.icon_url = input.icon_url;
|
|
432
|
+
if (input.signatures !== void 0 && input.signatures.length > 0) card.signatures = input.signatures;
|
|
433
|
+
if (input.security_schemes !== void 0) card.security_schemes = input.security_schemes;
|
|
434
|
+
if (input.security_requirements !== void 0) card.security_requirements = input.security_requirements;
|
|
435
|
+
if (input.extras) {
|
|
436
|
+
for (const [k, v] of Object.entries(input.extras)) {
|
|
437
|
+
card[k] = v;
|
|
438
|
+
}
|
|
439
|
+
}
|
|
427
440
|
return card;
|
|
428
441
|
}
|
|
429
442
|
|
|
430
443
|
// src/identity/ucp.ts
|
|
431
|
-
function
|
|
444
|
+
function ucpSigningKeyFromJWKImpl(jwk) {
|
|
432
445
|
if (!jwk || typeof jwk !== "object") {
|
|
433
|
-
throw new Error(`
|
|
446
|
+
throw new Error(`UCPSigningKey.fromJWK expected a non-null object; got ${typeof jwk}.`);
|
|
434
447
|
}
|
|
435
448
|
if (typeof jwk.kid !== "string" || !jwk.kid) {
|
|
436
|
-
throw new Error("
|
|
449
|
+
throw new Error("UCPSigningKey.fromJWK: JWK missing required field `kid` (or non-string).");
|
|
437
450
|
}
|
|
438
451
|
if (typeof jwk.kty !== "string" || !jwk.kty) {
|
|
439
|
-
throw new Error("
|
|
452
|
+
throw new Error("UCPSigningKey.fromJWK: JWK missing required field `kty` (or non-string).");
|
|
440
453
|
}
|
|
441
454
|
if (jwk.kty !== "OKP" && jwk.kty !== "EC" && jwk.kty !== "RSA") {
|
|
442
455
|
throw new Error(
|
|
443
|
-
`
|
|
456
|
+
`UCPSigningKey.fromJWK: kty=${JSON.stringify(jwk.kty)} is not a supported asymmetric key type (expected OKP, EC, or RSA). Symmetric \`oct\` keys are rejected because they cannot publicly verify a JWS in the trust-mode UCP flow.`
|
|
444
457
|
);
|
|
445
458
|
}
|
|
446
459
|
if ((jwk.kty === "EC" || jwk.kty === "OKP") && (typeof jwk.crv !== "string" || !jwk.crv)) {
|
|
447
|
-
throw new Error(`
|
|
460
|
+
throw new Error(`UCPSigningKey.fromJWK: kty=${jwk.kty} requires a non-empty \`crv\` field (e.g., "P-256" for EC, "Ed25519" for OKP).`);
|
|
448
461
|
}
|
|
449
462
|
return jwk;
|
|
450
463
|
}
|
|
464
|
+
var UCPSigningKey = {
|
|
465
|
+
fromJWK: ucpSigningKeyFromJWKImpl
|
|
466
|
+
};
|
|
451
467
|
var DEFAULT_VERSION = "2026-04-08";
|
|
452
468
|
var AGENTSCORE_CAPABILITY_NAME = "sh.agentscore.identity";
|
|
453
|
-
var AGENTSCORE_CAPABILITY_VERSION = "
|
|
469
|
+
var AGENTSCORE_CAPABILITY_VERSION = "2026-04-08";
|
|
454
470
|
var AGENTSCORE_DEFAULT_SPEC_URL = "https://agentscore.sh/specification/identity";
|
|
455
471
|
var AGENTSCORE_DEFAULT_SCHEMA_URL = "https://agentscore.sh/schemas/ucp/sh-agentscore-identity-v1.json";
|
|
456
472
|
var AGENTSCORE_EXTENDS = ["dev.ucp.shopping.checkout", "dev.ucp.shopping.cart"];
|
|
@@ -474,44 +490,47 @@ var RESERVED_UCP_FIELDS = /* @__PURE__ */ new Set([
|
|
|
474
490
|
"prototype"
|
|
475
491
|
]);
|
|
476
492
|
function buildUCPProfile(input) {
|
|
493
|
+
for (const [name, bindings] of Object.entries(input.services ?? {})) {
|
|
494
|
+
for (const binding of bindings) {
|
|
495
|
+
if ((binding.transport === "rest" || binding.transport === "mcp" || binding.transport === "a2a") && (binding.endpoint === void 0 || binding.endpoint === null || binding.endpoint === "")) {
|
|
496
|
+
throw new Error(
|
|
497
|
+
`buildUCPProfile: service "${name}" transport=${binding.transport} requires \`endpoint\`. Per UCP spec service.json business_schema, rest/mcp/a2a bindings MUST carry an endpoint URL.`
|
|
498
|
+
);
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
const paymentHandlers = {};
|
|
503
|
+
for (const [name, bindings] of Object.entries(input.payment_handlers ?? {})) {
|
|
504
|
+
paymentHandlers[name] = bindings.map((binding) => {
|
|
505
|
+
if (Array.isArray(binding.available_instruments) && binding.available_instruments.length === 0) {
|
|
506
|
+
const { available_instruments: _drop, ...rest } = binding;
|
|
507
|
+
return rest;
|
|
508
|
+
}
|
|
509
|
+
return binding;
|
|
510
|
+
});
|
|
511
|
+
}
|
|
477
512
|
const capabilities = {};
|
|
478
513
|
for (const [name, bindings] of Object.entries(input.capabilities ?? {})) {
|
|
479
514
|
capabilities[name] = [...bindings];
|
|
480
515
|
}
|
|
481
|
-
if (input.
|
|
482
|
-
const
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
verify_url: input.data.verify_url ?? null,
|
|
494
|
-
issuer: "https://agentscore.sh"
|
|
495
|
-
};
|
|
496
|
-
const agentscoreBinding = {
|
|
497
|
-
version: AGENTSCORE_CAPABILITY_VERSION,
|
|
498
|
-
spec: input.agentscore_spec_url ?? AGENTSCORE_DEFAULT_SPEC_URL,
|
|
499
|
-
schema: input.agentscore_schema_url ?? AGENTSCORE_DEFAULT_SCHEMA_URL,
|
|
500
|
-
extends: AGENTSCORE_EXTENDS,
|
|
501
|
-
// `claims` is our vendor extra on the binding; allowed per spec via the
|
|
502
|
-
// `[k: string]: unknown` index signature on UCPCapabilityBinding.
|
|
503
|
-
claims
|
|
504
|
-
};
|
|
505
|
-
const existing = capabilities[AGENTSCORE_CAPABILITY_NAME];
|
|
506
|
-
if (existing) existing.push(agentscoreBinding);
|
|
507
|
-
else capabilities[AGENTSCORE_CAPABILITY_NAME] = [agentscoreBinding];
|
|
508
|
-
}
|
|
516
|
+
if (input.agentscore_gate) {
|
|
517
|
+
const gateConfig = { ...input.agentscore_gate };
|
|
518
|
+
const agentscoreBinding = {
|
|
519
|
+
version: AGENTSCORE_CAPABILITY_VERSION,
|
|
520
|
+
spec: input.agentscore_spec_url ?? AGENTSCORE_DEFAULT_SPEC_URL,
|
|
521
|
+
schema: input.agentscore_schema_url ?? AGENTSCORE_DEFAULT_SCHEMA_URL,
|
|
522
|
+
extends: AGENTSCORE_EXTENDS
|
|
523
|
+
};
|
|
524
|
+
if (Object.keys(gateConfig).length > 0) agentscoreBinding.config = gateConfig;
|
|
525
|
+
const existing = capabilities[AGENTSCORE_CAPABILITY_NAME];
|
|
526
|
+
if (existing) existing.push(agentscoreBinding);
|
|
527
|
+
else capabilities[AGENTSCORE_CAPABILITY_NAME] = [agentscoreBinding];
|
|
509
528
|
}
|
|
510
529
|
const ucp = {
|
|
511
530
|
version: input.version ?? DEFAULT_VERSION,
|
|
512
531
|
services: input.services ?? {},
|
|
513
532
|
capabilities,
|
|
514
|
-
payment_handlers:
|
|
533
|
+
payment_handlers: paymentHandlers
|
|
515
534
|
};
|
|
516
535
|
if (input.name !== void 0) ucp.name = input.name;
|
|
517
536
|
if (input.supported_versions !== void 0) ucp.supported_versions = input.supported_versions;
|
|
@@ -538,6 +557,42 @@ function buildUCPProfile(input) {
|
|
|
538
557
|
return profile;
|
|
539
558
|
}
|
|
540
559
|
var AGENTSCORE_UCP_CAPABILITY = AGENTSCORE_CAPABILITY_NAME;
|
|
560
|
+
var HANDLER_VERSION = "2026-04-08";
|
|
561
|
+
var SPEC_BASE = "https://agentscore.sh/specification/payment-handlers";
|
|
562
|
+
var SCHEMA_BASE = "https://agentscore.sh/schemas/payment-handlers";
|
|
563
|
+
function mppPaymentHandler(input) {
|
|
564
|
+
return {
|
|
565
|
+
"sh.agentscore.payment.mpp": [{
|
|
566
|
+
id: "mpp",
|
|
567
|
+
version: HANDLER_VERSION,
|
|
568
|
+
spec: `${SPEC_BASE}/mpp`,
|
|
569
|
+
schema: `${SCHEMA_BASE}/mpp.json`,
|
|
570
|
+
config: { networks: input.networks }
|
|
571
|
+
}]
|
|
572
|
+
};
|
|
573
|
+
}
|
|
574
|
+
function x402PaymentHandler(input) {
|
|
575
|
+
return {
|
|
576
|
+
"sh.agentscore.payment.x402": [{
|
|
577
|
+
id: "x402",
|
|
578
|
+
version: HANDLER_VERSION,
|
|
579
|
+
spec: `${SPEC_BASE}/x402`,
|
|
580
|
+
schema: `${SCHEMA_BASE}/x402.json`,
|
|
581
|
+
config: { networks: input.networks }
|
|
582
|
+
}]
|
|
583
|
+
};
|
|
584
|
+
}
|
|
585
|
+
function stripeSptPaymentHandler(input) {
|
|
586
|
+
return {
|
|
587
|
+
"sh.agentscore.payment.stripe_spt": [{
|
|
588
|
+
id: "stripe-spt",
|
|
589
|
+
version: HANDLER_VERSION,
|
|
590
|
+
spec: `${SPEC_BASE}/stripe_spt`,
|
|
591
|
+
schema: `${SCHEMA_BASE}/stripe_spt.json`,
|
|
592
|
+
config: { rail: "stripe-spt", profile_id: input.profile_id }
|
|
593
|
+
}]
|
|
594
|
+
};
|
|
595
|
+
}
|
|
541
596
|
|
|
542
597
|
// src/identity/ucp-jwks.ts
|
|
543
598
|
var JOSE_INSTALL_HINT = "Install the optional peer dependency: `npm install jose@^6` (or `bun add jose`). Tested against jose v6.x.";
|
|
@@ -812,7 +867,7 @@ function buildJWKSResponse(keys) {
|
|
|
812
867
|
}
|
|
813
868
|
|
|
814
869
|
// src/identity/policy.ts
|
|
815
|
-
function
|
|
870
|
+
function buildGateOptionsFromPolicy(policy, base) {
|
|
816
871
|
if (!policy || !policy.enforcement) return null;
|
|
817
872
|
return {
|
|
818
873
|
apiKey: base.apiKey,
|
|
@@ -861,11 +916,13 @@ function shippingStateAllowed(state, country, policy) {
|
|
|
861
916
|
0 && (module.exports = {
|
|
862
917
|
AGENTSCORE_UCP_CAPABILITY,
|
|
863
918
|
FIXABLE_DENIAL_REASONS,
|
|
919
|
+
UCPSigningKey,
|
|
864
920
|
UCPVerificationError,
|
|
865
921
|
UCP_A2A_EXTENSION_URI,
|
|
866
922
|
buildA2AAgentCard,
|
|
867
923
|
buildAgentMemoryHint,
|
|
868
924
|
buildContactSupportNextSteps,
|
|
925
|
+
buildGateOptionsFromPolicy,
|
|
869
926
|
buildJWKSResponse,
|
|
870
927
|
buildSignerMismatchBody,
|
|
871
928
|
buildUCPProfile,
|
|
@@ -875,15 +932,16 @@ function shippingStateAllowed(state, country, policy) {
|
|
|
875
932
|
extractPaymentSignerAddress,
|
|
876
933
|
generateUCPSigningKey,
|
|
877
934
|
isFixableDenial,
|
|
878
|
-
|
|
935
|
+
mppPaymentHandler,
|
|
879
936
|
readX402PaymentHeader,
|
|
880
937
|
runGateWithEnforcement,
|
|
881
938
|
shippingCountryAllowed,
|
|
882
939
|
shippingStateAllowed,
|
|
883
940
|
signUCPProfile,
|
|
941
|
+
stripeSptPaymentHandler,
|
|
884
942
|
ucpA2AExtension,
|
|
885
|
-
ucpSigningKeyFromJWK,
|
|
886
943
|
verificationAgentInstructions,
|
|
887
|
-
verifyUCPProfile
|
|
944
|
+
verifyUCPProfile,
|
|
945
|
+
x402PaymentHandler
|
|
888
946
|
});
|
|
889
947
|
//# sourceMappingURL=index.js.map
|