@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.mjs
CHANGED
|
@@ -330,73 +330,86 @@ function readX402PaymentHeader(request) {
|
|
|
330
330
|
}
|
|
331
331
|
|
|
332
332
|
// src/identity/a2a.ts
|
|
333
|
+
var PROTOCOL_VERSION = "1.0";
|
|
334
|
+
var DEFAULT_PROTOCOL_BINDING = "HTTP+JSON";
|
|
335
|
+
var DEFAULT_INPUT_MODE = "application/json";
|
|
336
|
+
var DEFAULT_OUTPUT_MODE = "application/json";
|
|
333
337
|
var UCP_A2A_EXTENSION_URI = "https://ucp.dev/2026-04-08/specification/reference";
|
|
334
|
-
function ucpA2AExtension(capabilities = {}) {
|
|
338
|
+
function ucpA2AExtension(capabilities = {}, options = {}) {
|
|
335
339
|
return {
|
|
336
340
|
uri: UCP_A2A_EXTENSION_URI,
|
|
341
|
+
description: "UCP support: this agent serves Universal Commerce Protocol bindings via the A2A transport.",
|
|
342
|
+
required: options.required ?? false,
|
|
337
343
|
params: { capabilities }
|
|
338
344
|
};
|
|
339
345
|
}
|
|
340
|
-
var PROTOCOL_VERSION = "1.0";
|
|
341
|
-
var CARD_VERSION = 1;
|
|
342
346
|
function buildA2AAgentCard(input) {
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
if (operatorId) {
|
|
348
|
-
const operatorVerification = input.data.operator_verification;
|
|
349
|
-
const accountVerification = input.data.account_verification;
|
|
350
|
-
identity = {
|
|
351
|
-
issuer,
|
|
352
|
-
operator_id: operatorId,
|
|
353
|
-
kyc_level: accountVerification?.kyc_level ?? operatorVerification?.level ?? "none",
|
|
354
|
-
sanctions_clear: accountVerification?.sanctions_clear === true,
|
|
355
|
-
age_bracket: accountVerification?.age_bracket ?? "unknown",
|
|
356
|
-
jurisdiction: accountVerification?.jurisdiction ?? "",
|
|
357
|
-
verified_at: accountVerification?.verified_at ?? operatorVerification?.verified_at ?? null,
|
|
358
|
-
verify_url: input.verifyUrl ?? input.data.verify_url ?? `${issuer}/verify`
|
|
359
|
-
};
|
|
360
|
-
}
|
|
347
|
+
if (!input.skills || input.skills.length === 0) {
|
|
348
|
+
throw new Error(
|
|
349
|
+
"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."
|
|
350
|
+
);
|
|
361
351
|
}
|
|
352
|
+
const capabilities = {};
|
|
353
|
+
if (input.streaming !== void 0) capabilities.streaming = input.streaming;
|
|
354
|
+
if (input.push_notifications !== void 0) capabilities.push_notifications = input.push_notifications;
|
|
355
|
+
if (input.extensions && input.extensions.length > 0) capabilities.extensions = input.extensions;
|
|
356
|
+
if (input.extended_agent_card !== void 0) capabilities.extended_agent_card = input.extended_agent_card;
|
|
357
|
+
const primaryInterface = {
|
|
358
|
+
url: input.url,
|
|
359
|
+
protocol_binding: input.protocol_binding ?? DEFAULT_PROTOCOL_BINDING,
|
|
360
|
+
protocol_version: input.a2a_protocol_version ?? PROTOCOL_VERSION
|
|
361
|
+
};
|
|
362
362
|
const card = {
|
|
363
|
-
protocol_version: PROTOCOL_VERSION,
|
|
364
|
-
card_version: CARD_VERSION,
|
|
365
363
|
name: input.name,
|
|
366
|
-
|
|
364
|
+
description: input.description,
|
|
365
|
+
supported_interfaces: [primaryInterface],
|
|
366
|
+
version: input.version ?? "1.0.0",
|
|
367
|
+
capabilities,
|
|
368
|
+
default_input_modes: input.default_input_modes ?? [DEFAULT_INPUT_MODE],
|
|
369
|
+
default_output_modes: input.default_output_modes ?? [DEFAULT_OUTPUT_MODE],
|
|
370
|
+
skills: input.skills
|
|
367
371
|
};
|
|
368
|
-
if (input.
|
|
369
|
-
if (input.
|
|
370
|
-
if (input.
|
|
371
|
-
if (input.
|
|
372
|
-
if (input.
|
|
372
|
+
if (input.provider !== void 0) card.provider = input.provider;
|
|
373
|
+
if (input.documentation_url !== void 0) card.documentation_url = input.documentation_url;
|
|
374
|
+
if (input.icon_url !== void 0) card.icon_url = input.icon_url;
|
|
375
|
+
if (input.signatures !== void 0 && input.signatures.length > 0) card.signatures = input.signatures;
|
|
376
|
+
if (input.security_schemes !== void 0) card.security_schemes = input.security_schemes;
|
|
377
|
+
if (input.security_requirements !== void 0) card.security_requirements = input.security_requirements;
|
|
378
|
+
if (input.extras) {
|
|
379
|
+
for (const [k, v] of Object.entries(input.extras)) {
|
|
380
|
+
card[k] = v;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
373
383
|
return card;
|
|
374
384
|
}
|
|
375
385
|
|
|
376
386
|
// src/identity/ucp.ts
|
|
377
|
-
function
|
|
387
|
+
function ucpSigningKeyFromJWKImpl(jwk) {
|
|
378
388
|
if (!jwk || typeof jwk !== "object") {
|
|
379
|
-
throw new Error(`
|
|
389
|
+
throw new Error(`UCPSigningKey.fromJWK expected a non-null object; got ${typeof jwk}.`);
|
|
380
390
|
}
|
|
381
391
|
if (typeof jwk.kid !== "string" || !jwk.kid) {
|
|
382
|
-
throw new Error("
|
|
392
|
+
throw new Error("UCPSigningKey.fromJWK: JWK missing required field `kid` (or non-string).");
|
|
383
393
|
}
|
|
384
394
|
if (typeof jwk.kty !== "string" || !jwk.kty) {
|
|
385
|
-
throw new Error("
|
|
395
|
+
throw new Error("UCPSigningKey.fromJWK: JWK missing required field `kty` (or non-string).");
|
|
386
396
|
}
|
|
387
397
|
if (jwk.kty !== "OKP" && jwk.kty !== "EC" && jwk.kty !== "RSA") {
|
|
388
398
|
throw new Error(
|
|
389
|
-
`
|
|
399
|
+
`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.`
|
|
390
400
|
);
|
|
391
401
|
}
|
|
392
402
|
if ((jwk.kty === "EC" || jwk.kty === "OKP") && (typeof jwk.crv !== "string" || !jwk.crv)) {
|
|
393
|
-
throw new Error(`
|
|
403
|
+
throw new Error(`UCPSigningKey.fromJWK: kty=${jwk.kty} requires a non-empty \`crv\` field (e.g., "P-256" for EC, "Ed25519" for OKP).`);
|
|
394
404
|
}
|
|
395
405
|
return jwk;
|
|
396
406
|
}
|
|
407
|
+
var UCPSigningKey = {
|
|
408
|
+
fromJWK: ucpSigningKeyFromJWKImpl
|
|
409
|
+
};
|
|
397
410
|
var DEFAULT_VERSION = "2026-04-08";
|
|
398
411
|
var AGENTSCORE_CAPABILITY_NAME = "sh.agentscore.identity";
|
|
399
|
-
var AGENTSCORE_CAPABILITY_VERSION = "
|
|
412
|
+
var AGENTSCORE_CAPABILITY_VERSION = "2026-04-08";
|
|
400
413
|
var AGENTSCORE_DEFAULT_SPEC_URL = "https://agentscore.sh/specification/identity";
|
|
401
414
|
var AGENTSCORE_DEFAULT_SCHEMA_URL = "https://agentscore.sh/schemas/ucp/sh-agentscore-identity-v1.json";
|
|
402
415
|
var AGENTSCORE_EXTENDS = ["dev.ucp.shopping.checkout", "dev.ucp.shopping.cart"];
|
|
@@ -420,44 +433,47 @@ var RESERVED_UCP_FIELDS = /* @__PURE__ */ new Set([
|
|
|
420
433
|
"prototype"
|
|
421
434
|
]);
|
|
422
435
|
function buildUCPProfile(input) {
|
|
436
|
+
for (const [name, bindings] of Object.entries(input.services ?? {})) {
|
|
437
|
+
for (const binding of bindings) {
|
|
438
|
+
if ((binding.transport === "rest" || binding.transport === "mcp" || binding.transport === "a2a") && (binding.endpoint === void 0 || binding.endpoint === null || binding.endpoint === "")) {
|
|
439
|
+
throw new Error(
|
|
440
|
+
`buildUCPProfile: service "${name}" transport=${binding.transport} requires \`endpoint\`. Per UCP spec service.json business_schema, rest/mcp/a2a bindings MUST carry an endpoint URL.`
|
|
441
|
+
);
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
const paymentHandlers = {};
|
|
446
|
+
for (const [name, bindings] of Object.entries(input.payment_handlers ?? {})) {
|
|
447
|
+
paymentHandlers[name] = bindings.map((binding) => {
|
|
448
|
+
if (Array.isArray(binding.available_instruments) && binding.available_instruments.length === 0) {
|
|
449
|
+
const { available_instruments: _drop, ...rest } = binding;
|
|
450
|
+
return rest;
|
|
451
|
+
}
|
|
452
|
+
return binding;
|
|
453
|
+
});
|
|
454
|
+
}
|
|
423
455
|
const capabilities = {};
|
|
424
456
|
for (const [name, bindings] of Object.entries(input.capabilities ?? {})) {
|
|
425
457
|
capabilities[name] = [...bindings];
|
|
426
458
|
}
|
|
427
|
-
if (input.
|
|
428
|
-
const
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
verify_url: input.data.verify_url ?? null,
|
|
440
|
-
issuer: "https://agentscore.sh"
|
|
441
|
-
};
|
|
442
|
-
const agentscoreBinding = {
|
|
443
|
-
version: AGENTSCORE_CAPABILITY_VERSION,
|
|
444
|
-
spec: input.agentscore_spec_url ?? AGENTSCORE_DEFAULT_SPEC_URL,
|
|
445
|
-
schema: input.agentscore_schema_url ?? AGENTSCORE_DEFAULT_SCHEMA_URL,
|
|
446
|
-
extends: AGENTSCORE_EXTENDS,
|
|
447
|
-
// `claims` is our vendor extra on the binding; allowed per spec via the
|
|
448
|
-
// `[k: string]: unknown` index signature on UCPCapabilityBinding.
|
|
449
|
-
claims
|
|
450
|
-
};
|
|
451
|
-
const existing = capabilities[AGENTSCORE_CAPABILITY_NAME];
|
|
452
|
-
if (existing) existing.push(agentscoreBinding);
|
|
453
|
-
else capabilities[AGENTSCORE_CAPABILITY_NAME] = [agentscoreBinding];
|
|
454
|
-
}
|
|
459
|
+
if (input.agentscore_gate) {
|
|
460
|
+
const gateConfig = { ...input.agentscore_gate };
|
|
461
|
+
const agentscoreBinding = {
|
|
462
|
+
version: AGENTSCORE_CAPABILITY_VERSION,
|
|
463
|
+
spec: input.agentscore_spec_url ?? AGENTSCORE_DEFAULT_SPEC_URL,
|
|
464
|
+
schema: input.agentscore_schema_url ?? AGENTSCORE_DEFAULT_SCHEMA_URL,
|
|
465
|
+
extends: AGENTSCORE_EXTENDS
|
|
466
|
+
};
|
|
467
|
+
if (Object.keys(gateConfig).length > 0) agentscoreBinding.config = gateConfig;
|
|
468
|
+
const existing = capabilities[AGENTSCORE_CAPABILITY_NAME];
|
|
469
|
+
if (existing) existing.push(agentscoreBinding);
|
|
470
|
+
else capabilities[AGENTSCORE_CAPABILITY_NAME] = [agentscoreBinding];
|
|
455
471
|
}
|
|
456
472
|
const ucp = {
|
|
457
473
|
version: input.version ?? DEFAULT_VERSION,
|
|
458
474
|
services: input.services ?? {},
|
|
459
475
|
capabilities,
|
|
460
|
-
payment_handlers:
|
|
476
|
+
payment_handlers: paymentHandlers
|
|
461
477
|
};
|
|
462
478
|
if (input.name !== void 0) ucp.name = input.name;
|
|
463
479
|
if (input.supported_versions !== void 0) ucp.supported_versions = input.supported_versions;
|
|
@@ -484,6 +500,42 @@ function buildUCPProfile(input) {
|
|
|
484
500
|
return profile;
|
|
485
501
|
}
|
|
486
502
|
var AGENTSCORE_UCP_CAPABILITY = AGENTSCORE_CAPABILITY_NAME;
|
|
503
|
+
var HANDLER_VERSION = "2026-04-08";
|
|
504
|
+
var SPEC_BASE = "https://agentscore.sh/specification/payment-handlers";
|
|
505
|
+
var SCHEMA_BASE = "https://agentscore.sh/schemas/payment-handlers";
|
|
506
|
+
function mppPaymentHandler(input) {
|
|
507
|
+
return {
|
|
508
|
+
"sh.agentscore.payment.mpp": [{
|
|
509
|
+
id: "mpp",
|
|
510
|
+
version: HANDLER_VERSION,
|
|
511
|
+
spec: `${SPEC_BASE}/mpp`,
|
|
512
|
+
schema: `${SCHEMA_BASE}/mpp.json`,
|
|
513
|
+
config: { networks: input.networks }
|
|
514
|
+
}]
|
|
515
|
+
};
|
|
516
|
+
}
|
|
517
|
+
function x402PaymentHandler(input) {
|
|
518
|
+
return {
|
|
519
|
+
"sh.agentscore.payment.x402": [{
|
|
520
|
+
id: "x402",
|
|
521
|
+
version: HANDLER_VERSION,
|
|
522
|
+
spec: `${SPEC_BASE}/x402`,
|
|
523
|
+
schema: `${SCHEMA_BASE}/x402.json`,
|
|
524
|
+
config: { networks: input.networks }
|
|
525
|
+
}]
|
|
526
|
+
};
|
|
527
|
+
}
|
|
528
|
+
function stripeSptPaymentHandler(input) {
|
|
529
|
+
return {
|
|
530
|
+
"sh.agentscore.payment.stripe_spt": [{
|
|
531
|
+
id: "stripe-spt",
|
|
532
|
+
version: HANDLER_VERSION,
|
|
533
|
+
spec: `${SPEC_BASE}/stripe_spt`,
|
|
534
|
+
schema: `${SCHEMA_BASE}/stripe_spt.json`,
|
|
535
|
+
config: { rail: "stripe-spt", profile_id: input.profile_id }
|
|
536
|
+
}]
|
|
537
|
+
};
|
|
538
|
+
}
|
|
487
539
|
|
|
488
540
|
// src/identity/ucp-jwks.ts
|
|
489
541
|
var JOSE_INSTALL_HINT = "Install the optional peer dependency: `npm install jose@^6` (or `bun add jose`). Tested against jose v6.x.";
|
|
@@ -758,7 +810,7 @@ function buildJWKSResponse(keys) {
|
|
|
758
810
|
}
|
|
759
811
|
|
|
760
812
|
// src/identity/policy.ts
|
|
761
|
-
function
|
|
813
|
+
function buildGateOptionsFromPolicy(policy, base) {
|
|
762
814
|
if (!policy || !policy.enforcement) return null;
|
|
763
815
|
return {
|
|
764
816
|
apiKey: base.apiKey,
|
|
@@ -806,11 +858,13 @@ function shippingStateAllowed(state, country, policy) {
|
|
|
806
858
|
export {
|
|
807
859
|
AGENTSCORE_UCP_CAPABILITY,
|
|
808
860
|
FIXABLE_DENIAL_REASONS,
|
|
861
|
+
UCPSigningKey,
|
|
809
862
|
UCPVerificationError,
|
|
810
863
|
UCP_A2A_EXTENSION_URI,
|
|
811
864
|
buildA2AAgentCard,
|
|
812
865
|
buildAgentMemoryHint,
|
|
813
866
|
buildContactSupportNextSteps,
|
|
867
|
+
buildGateOptionsFromPolicy,
|
|
814
868
|
buildJWKSResponse,
|
|
815
869
|
buildSignerMismatchBody,
|
|
816
870
|
buildUCPProfile,
|
|
@@ -820,15 +874,16 @@ export {
|
|
|
820
874
|
extractPaymentSignerAddress,
|
|
821
875
|
generateUCPSigningKey,
|
|
822
876
|
isFixableDenial,
|
|
823
|
-
|
|
877
|
+
mppPaymentHandler,
|
|
824
878
|
readX402PaymentHeader,
|
|
825
879
|
runGateWithEnforcement,
|
|
826
880
|
shippingCountryAllowed,
|
|
827
881
|
shippingStateAllowed,
|
|
828
882
|
signUCPProfile,
|
|
883
|
+
stripeSptPaymentHandler,
|
|
829
884
|
ucpA2AExtension,
|
|
830
|
-
ucpSigningKeyFromJWK,
|
|
831
885
|
verificationAgentInstructions,
|
|
832
|
-
verifyUCPProfile
|
|
886
|
+
verifyUCPProfile,
|
|
887
|
+
x402PaymentHandler
|
|
833
888
|
};
|
|
834
889
|
//# sourceMappingURL=index.mjs.map
|