@devlab.group/agent-commerce 1.4.0 → 1.5.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.
@@ -0,0 +1,50 @@
1
+ /**
2
+ * The one MPP profile this rail targets.
3
+ *
4
+ * MPP combines a core HTTP authentication layer, an intent, a method and
5
+ * optional extensions. These constants identify the selected combination and
6
+ * the exact specification revision.
7
+ *
8
+ * Importing this metadata does not load `mppx`.
9
+ */
10
+ /** Upstream specification repository the pinned drafts were read from */
11
+ declare const MPP_SPEC_REPOSITORY = "https://github.com/tempoxyz/mpp-specs";
12
+ /**
13
+ * Upstream commit the pinned drafts were read at.
14
+ *
15
+ * A draft's content can change without its `-00` name changing, so the name
16
+ * alone does not identify a document; the commit does.
17
+ */
18
+ declare const MPP_SPEC_COMMIT = "806fdb8b8c92cda5c84b8660558921b6bbeef7e0";
19
+ /** The core HTTP authentication draft, the `charge` intent, and its EVM method */
20
+ declare const MPP_SPEC_DRAFTS: {
21
+ readonly core: "draft-httpauth-payment-00";
22
+ readonly intent: "draft-payment-intent-charge-00";
23
+ readonly method: "draft-evm-charge-00";
24
+ };
25
+ /** Exact `mppx` release the rail is pinned to */
26
+ declare const MPPX_VERSION = "0.10.1";
27
+ /**
28
+ * The pinned profile.
29
+ *
30
+ * `intent`, `method` and `credentialType` copy MPP wire identifiers from
31
+ * `mppx` so this module has no peer import; tests detect drift. `assetSymbol`
32
+ * is the pricing currency an MPP resource must use. EVM charge requests carry a
33
+ * numeric `chainId` and token address instead.
34
+ */
35
+ declare const MPP_PROFILE: {
36
+ readonly intent: "charge";
37
+ readonly method: "evm";
38
+ readonly credentialType: "authorization";
39
+ readonly assetSymbol: "USDC";
40
+ readonly assetDecimals: 6;
41
+ };
42
+ /** Supported CAIP-2 networks; gateway config applies the x402 mainnet guardrails */
43
+ declare const MPP_NETWORKS: readonly ["eip155:84532", "eip155:8453"];
44
+ type MppNetwork = (typeof MPP_NETWORKS)[number];
45
+ /**
46
+ * Compact descriptor value naming the core draft, intent and method
47
+ */
48
+ declare const MPP_SUPPORTED_SPEC: string;
49
+
50
+ export { type MppNetwork as M, MPPX_VERSION as a, MPP_PROFILE as b, MPP_SPEC_COMMIT as c, MPP_SPEC_DRAFTS as d, MPP_SPEC_REPOSITORY as e, MPP_SUPPORTED_SPEC as f };
package/dist/index.d.ts CHANGED
@@ -1,11 +1,12 @@
1
1
  import { f as Ap2AuthorizationConfig } from './types-CJtwLu1c.js';
2
- import { I as IsoTimestamp, D as DecimalAmount, P as PaymentMethodName, a as CommerceResource, b as PaymentSubmission, B as BackendHandler, A as AdapterDescriptor, c as AdapterHealth, R as ResourceRegistry, d as PaymentProvider, L as Logger, C as Clock, e as IdGenerator } from './runtime-CKq3d_3K.js';
3
- export { f as AuthorizationMethodName, g as BackendMethod, h as DEFAULT_BACKEND_TIMEOUT_MS, J as JsonSchema, N as NOOP_LOGGER, i as PROTOCOL_NAMES, j as PaymentChallenge, k as PaymentContext, l as PaymentRequirement, m as PaymentResult, n as PaymentSettlementContext, o as PaymentVerificationContext, p as Pricing, q as ProtocolName, s as systemClock } from './runtime-CKq3d_3K.js';
2
+ import { I as IsoTimestamp, D as DecimalAmount, P as PaymentMethodName, a as CommerceResource, b as PaymentSubmission, B as BackendHandler, A as AdapterDescriptor, c as AdapterHealth, R as ResourceRegistry, d as PaymentProvider, L as Logger, C as Clock, e as IdGenerator } from './runtime-DC5XQ9Cc.js';
3
+ export { f as AuthorizationMethodName, g as BackendMethod, h as DEFAULT_BACKEND_TIMEOUT_MS, J as JsonSchema, N as NOOP_LOGGER, i as PAYMENT_METHOD_NAMES, j as PROTOCOL_NAMES, k as PaymentChallenge, l as PaymentContext, m as PaymentRequirement, n as PaymentResult, o as PaymentSettlementContext, p as PaymentVerificationContext, q as Pricing, r as ProtocolName, s as systemClock } from './runtime-DC5XQ9Cc.js';
4
+ import { M as MppNetwork } from './constants-6mypC60h.js';
4
5
  import { X as X402FacilitatorConfig } from './guardrails-Dmwi63KB.js';
5
- import { a as AuthorizationRequirement, b as AuthorizationSubmission, A as AuthorizationProvider } from './authorization-CPDcpJVa.js';
6
- export { c as AuthorizationFinalizeContext, d as AuthorizationRecord, e as AuthorizationVerification, f as AuthorizationVerificationContext } from './authorization-CPDcpJVa.js';
7
- import { D as DeliveredOutcome, P as PaymentRequiredOutcome, C as CommerceEvent, a as PaymentAttempt, b as CommerceReceipt, E as ExecutionPipeline, c as ProtocolAdapter, H as HttpProtocolAdapter, A as AdapterHttpRoute, d as ProtocolAdapterContext } from './protocol-adapter-CaMZj6Wm.js';
8
- export { e as COMMERCE_EVENT_TYPES, f as CanonicalRequest, g as CommerceEventType, h as EventSink, i as ExecutionOutcome, j as isHttpProtocolAdapter } from './protocol-adapter-CaMZj6Wm.js';
6
+ import { a as AuthorizationRequirement, b as AuthorizationSubmission, A as AuthorizationProvider } from './authorization-DA7mjy_O.js';
7
+ export { c as AuthorizationFinalizeContext, d as AuthorizationRecord, e as AuthorizationVerification, f as AuthorizationVerificationContext } from './authorization-DA7mjy_O.js';
8
+ import { D as DeliveredOutcome, P as PaymentRequiredOutcome, C as CommerceEvent, a as PaymentAttempt, b as CommerceReceipt, E as ExecutionPipeline, c as ProtocolAdapter, H as HttpProtocolAdapter, A as AdapterHttpRoute, d as ProtocolAdapterContext } from './protocol-adapter-APRjs1E2.js';
9
+ export { e as COMMERCE_EVENT_TYPES, f as CanonicalRequest, g as CommerceEventType, h as EventSink, i as ExecutionOutcome, j as isHttpProtocolAdapter } from './protocol-adapter-APRjs1E2.js';
9
10
  import { FastifyInstance } from 'fastify';
10
11
  import { IncomingMessage, ServerResponse } from 'node:http';
11
12
 
@@ -278,11 +279,10 @@ declare function parseAuthorizationHeader(raw: string | readonly string[] | unde
278
279
  * (MCP tool arguments, A2A message data). HTTP carries both in headers and
279
280
  * uses the two parse helpers directly.
280
281
  *
281
- * The payment method comes from the resource's own declaration. This is not
282
- * the place that decides which rail a resource uses, so a proof for a
283
- * resource with no configured rail is dropped rather than forwarded under an
284
- * invented method. The pipeline then treats the request as unpaid and decides
285
- * on its own terms.
282
+ * A payment proof is labelled with the resource's first method. `createGateway`
283
+ * puts provider-backed methods first so the label matches pipeline selection;
284
+ * custom registries must preserve that ordering. Without a method, the proof is
285
+ * dropped and the pipeline receives an unpaid request.
286
286
  */
287
287
  declare function extractReservedInputFields(rawInput: Record<string, unknown>, resource: CommerceResource | undefined, requestId?: string): {
288
288
  input: Record<string, unknown>;
@@ -303,6 +303,16 @@ interface BackendRequest {
303
303
  readonly resourceId: string;
304
304
  /** Validated resource input. */
305
305
  readonly input: unknown;
306
+ /**
307
+ * Names the *operation*, so the merchant can recognise a repeat of it.
308
+ *
309
+ * Not `requestId`, which is fresh per call and would make every retry look
310
+ * like new work. An adapter sets this only when it can derive a value that
311
+ * survives a client retry, a reconnect and a gateway restart; the HTTP
312
+ * executor forwards it as the `Idempotency-Key` request header. Absent
313
+ * means the protocol has no such notion, and the merchant sees no header.
314
+ */
315
+ readonly idempotencyKey?: string;
306
316
  }
307
317
  interface BackendResponse {
308
318
  readonly status: number;
@@ -536,6 +546,21 @@ interface GatewayConfig {
536
546
  readonly allowMainnet?: boolean;
537
547
  readonly allowUnauthenticatedFacilitator?: boolean;
538
548
  };
549
+ readonly mpp?: {
550
+ readonly enabled: boolean;
551
+ readonly network: MppNetwork;
552
+ readonly rpcUrl: string;
553
+ readonly asset: string;
554
+ readonly assetName: string;
555
+ readonly assetVersion: string;
556
+ readonly recipient: string;
557
+ readonly realm: string;
558
+ readonly challengeSecret: string;
559
+ readonly challengeTtlSeconds?: number;
560
+ readonly facilitator: X402FacilitatorConfig;
561
+ readonly allowMainnet?: boolean;
562
+ readonly allowUnauthenticatedFacilitator?: boolean;
563
+ };
539
564
  };
540
565
  /**
541
566
  * Absent when no `authorization:` block is configured, which is how every
@@ -630,8 +655,14 @@ declare class AcpProtocolAdapter implements HttpProtocolAdapter {
630
655
  private readonly token;
631
656
  private readonly operations;
632
657
  private readonly idempotencyOptions;
633
- /** Derived once: the token is fixed, and only its digest may be persisted. */
634
- private readonly identityHash;
658
+ /**
659
+ * What an idempotency claim is scoped to, from `context.publicBaseUrl`.
660
+ *
661
+ * Not readonly because, unlike the token, it is known only once the adapter
662
+ * starts. Worth that: scoping by the credential meant a rotation freed
663
+ * every outstanding claim.
664
+ */
665
+ private deployment;
635
666
  private readonly discoveryMetadata;
636
667
  private idempotency;
637
668
  private resources;