@genesis-tech/genesispay-seller 0.13.1 → 1.3.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.
Files changed (99) hide show
  1. package/CHANGELOG.md +206 -0
  2. package/README.md +670 -91
  3. package/dist/checkout-documents.d.ts +99 -0
  4. package/dist/checkout-documents.d.ts.map +1 -0
  5. package/dist/checkout-documents.js +155 -0
  6. package/dist/checkout-documents.js.map +1 -0
  7. package/dist/checkout-return.d.ts +41 -0
  8. package/dist/checkout-return.d.ts.map +1 -0
  9. package/dist/checkout-return.js +68 -0
  10. package/dist/checkout-return.js.map +1 -0
  11. package/dist/client.d.ts +318 -0
  12. package/dist/client.d.ts.map +1 -0
  13. package/dist/client.js +718 -0
  14. package/dist/client.js.map +1 -0
  15. package/dist/contract-mandates.d.ts +39 -0
  16. package/dist/contract-mandates.d.ts.map +1 -0
  17. package/dist/contract-mandates.js +98 -0
  18. package/dist/contract-mandates.js.map +1 -0
  19. package/dist/contract-usage.d.ts +29 -0
  20. package/dist/contract-usage.d.ts.map +1 -0
  21. package/dist/contract-usage.js +92 -0
  22. package/dist/contract-usage.js.map +1 -0
  23. package/dist/customers.d.ts +41 -0
  24. package/dist/customers.d.ts.map +1 -0
  25. package/dist/customers.js +76 -0
  26. package/dist/customers.js.map +1 -0
  27. package/dist/entitlements.d.ts +19 -0
  28. package/dist/entitlements.d.ts.map +1 -0
  29. package/dist/entitlements.js +30 -0
  30. package/dist/entitlements.js.map +1 -0
  31. package/dist/errors.d.ts +129 -0
  32. package/dist/errors.d.ts.map +1 -0
  33. package/dist/errors.js +273 -0
  34. package/dist/errors.js.map +1 -0
  35. package/dist/fulfillment-attempts.d.ts +29 -0
  36. package/dist/fulfillment-attempts.d.ts.map +1 -0
  37. package/dist/fulfillment-attempts.js +71 -0
  38. package/dist/fulfillment-attempts.js.map +1 -0
  39. package/dist/fulfillment.d.ts +152 -0
  40. package/dist/fulfillment.d.ts.map +1 -0
  41. package/dist/fulfillment.js +810 -0
  42. package/dist/fulfillment.js.map +1 -0
  43. package/dist/genesispay-settlement.d.ts +32 -0
  44. package/dist/genesispay-settlement.d.ts.map +1 -0
  45. package/dist/genesispay-settlement.js +500 -0
  46. package/dist/genesispay-settlement.js.map +1 -0
  47. package/dist/index.d.ts +22 -0
  48. package/dist/index.d.ts.map +1 -0
  49. package/dist/index.js +21 -0
  50. package/dist/index.js.map +1 -0
  51. package/dist/invoices.d.ts +111 -0
  52. package/dist/invoices.d.ts.map +1 -0
  53. package/dist/invoices.js +192 -0
  54. package/dist/invoices.js.map +1 -0
  55. package/dist/item-tax.d.ts +15 -0
  56. package/dist/item-tax.d.ts.map +1 -0
  57. package/dist/item-tax.js +19 -0
  58. package/dist/item-tax.js.map +1 -0
  59. package/dist/mandate-gate.d.ts +54 -0
  60. package/dist/mandate-gate.d.ts.map +1 -0
  61. package/dist/mandate-gate.js +183 -0
  62. package/dist/mandate-gate.js.map +1 -0
  63. package/dist/mandates.d.ts +189 -0
  64. package/dist/mandates.d.ts.map +1 -0
  65. package/dist/mandates.js +234 -0
  66. package/dist/mandates.js.map +1 -0
  67. package/dist/networks.d.ts +10 -0
  68. package/dist/networks.d.ts.map +1 -0
  69. package/dist/networks.js +23 -0
  70. package/dist/networks.js.map +1 -0
  71. package/dist/payment-gate.d.ts +98 -0
  72. package/dist/payment-gate.d.ts.map +1 -0
  73. package/dist/payment-gate.js +370 -0
  74. package/dist/payment-gate.js.map +1 -0
  75. package/dist/plans.d.ts +68 -0
  76. package/dist/plans.d.ts.map +1 -0
  77. package/dist/plans.js +127 -0
  78. package/dist/plans.js.map +1 -0
  79. package/dist/products.d.ts +170 -0
  80. package/dist/products.d.ts.map +1 -0
  81. package/dist/products.js +1317 -0
  82. package/dist/products.js.map +1 -0
  83. package/dist/resource.d.ts +47 -0
  84. package/dist/resource.d.ts.map +1 -0
  85. package/dist/resource.js +71 -0
  86. package/dist/resource.js.map +1 -0
  87. package/dist/strict-response.d.ts +21 -0
  88. package/dist/strict-response.d.ts.map +1 -0
  89. package/dist/strict-response.js +68 -0
  90. package/dist/strict-response.js.map +1 -0
  91. package/dist/usdc-amount.d.ts +7 -0
  92. package/dist/usdc-amount.d.ts.map +1 -0
  93. package/dist/usdc-amount.js +21 -0
  94. package/dist/usdc-amount.js.map +1 -0
  95. package/dist/webhooks.d.ts +352 -0
  96. package/dist/webhooks.d.ts.map +1 -0
  97. package/dist/webhooks.js +244 -0
  98. package/dist/webhooks.js.map +1 -0
  99. package/package.json +4 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,211 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.3.0 — purchase-bound settlement preparation
4
+
5
+ Additive; requires protocol `^0.5.0`.
6
+
7
+ - Product gates (`products.gate(...).protect`) and the generic
8
+ `createPaymentGate(...).wrap` accept settlement-preparation parameters from
9
+ `GENESISPAY-Settlement-Prepare-Params` when `GENESISPAY-Settlement-Prepare: 1`
10
+ is present. The request body is then the purchase body, so a route may parse
11
+ and validate it before calling the gate (ADR-0083).
12
+ - In that mode a product gate recomputes the canonical method, resource URL and
13
+ request fingerprint and requires them to equal the expected gate intent. A
14
+ mismatch answers `422 { code: "contract_mismatch", mismatches }` and nothing
15
+ is forwarded to GenesisPay; a present but malformed params header answers
16
+ `422 { code: "invalid_request" }` and is never replaced by the body.
17
+ - The generic gate binds no request fingerprint; in header mode it treats the
18
+ body as opaque purchase content and never reads it.
19
+ - Without the params header both gates behave exactly as in 1.2.1: the body
20
+ carries the plan parameters (GET resources, hosted links, older engines).
21
+ - The `prepare` action sent to GenesisPay is unchanged.
22
+ - Document the beta lock on new mandate authority. A locked deployment answers
23
+ HTTP `409` `mandate_authority_locked_for_beta` (no `Retry-After`) for
24
+ `mandates.create`, the `contract_mandate_v1` proposal/activation helpers,
25
+ `mandates.proposeContractUsage` and `plans.create`.
26
+ `mandates.submitContractUsage`, revocation, reads and the x402 payment gate
27
+ are unaffected. Documentation only; no SDK source change and no publication.
28
+
29
+ ## 1.2.1 — settlement ambiguity and terminal polling fixes
30
+
31
+ - Preserve a payer-supplied transaction hash when a custom settlement verifier
32
+ throws, returning a non-success reconciliation response instead of losing the
33
+ locator.
34
+ - Map asynchronously polled `failed` and `expired` product settlements to HTTP
35
+ 409 and 410. Terminal status never looks like successful resource delivery,
36
+ never runs the protected handler, and never forwards `PAYMENT-RESPONSE`.
37
+ - Require synchronous facilitator success to carry a full transaction hash,
38
+ exact network, exact integer minor amount, exact known payer and both explicit
39
+ authorization/settlement verification flags before the paid handler runs.
40
+ - Document the already-exported experimental `contract_mandate_v1` helpers:
41
+ `mandates.createContractSubscription`, `createContractPerUse`,
42
+ `proposeContractUsage`, `submitContractUsage`, and `getContractUsage`, plus
43
+ their result/input types. They independently rebuild typed data and fail
44
+ closed on inconsistent authority. Their presence does not enable backend
45
+ admission or grant Mainnet clearance.
46
+
47
+ ## 1.2.0 — hosted checkout documents and asynchronous settlement
48
+
49
+ Built on the strict 1.1.0 SDK and protocol 0.4 contract; no npm publication is
50
+ part of this change. Strict creation still requires an idempotency key and
51
+ versioned responses, and only `fulfillment.verify()` grants payment authority.
52
+
53
+ ### Added
54
+
55
+ - The facilitator settlement adapter accepts versioned HTTP 202 queue
56
+ acceptance, polls the same-origin seller-key status URL, and reports success
57
+ only after GenesisPay verifies the seller transfer and returns its real hash.
58
+ - Strict product gates poll seller-scoped settlement status after 202 and retry
59
+ the gate request only after seller confirmation. `queued` and `submitted`
60
+ never authorize resource delivery; failed, expired, malformed and timed-out
61
+ status remains fail-closed.
62
+ - `settlementPollTimeoutMs` configures the facilitator adapter's bounded poll
63
+ window (120 seconds by default). Legacy synchronous 200 settlement remains
64
+ compatible.
65
+
66
+ - Plan-aware x402 gates advertise a preparation handshake, proxy exact
67
+ pre-sign authority through the GenesisPay facilitator, and submit the returned
68
+ plan id with settlement. Signed-first clients receive an upgrade refusal
69
+ before broadcast; current on-chain transfers are unchanged (MR-1011).
70
+
71
+ - **`genesispay.checkoutDocuments.list()`** lists the seller's immutable formal
72
+ invoices and enhanced receipts created after confirmed, non-simulated hosted
73
+ human checkout payments.
74
+ - **`genesispay.checkoutDocuments.get(publicId)`** retrieves one document; the
75
+ authenticated API also exposes `GET /api/v1/checkout-documents/:publicId/pdf`.
76
+ - Products and checkout requests expose explicit inclusive `taxConfig`; product
77
+ updates and `checkout.updateTax()` use `expectedTaxConfig` conflict detection.
78
+ - New manual invoices use inclusive per-line tax and produce an invoice/receipt
79
+ pair after real payment. Existing finalized documents stay immutable.
80
+
81
+ ### Safety
82
+
83
+ - Checkout documents are read-only snapshots, not the manual
84
+ `genesispay.invoices.*` lifecycle. A missing `invoiceNumber` means an honest
85
+ enhanced receipt rather than a guessed or incomplete formal invoice.
86
+ - New standalone checkout requests are single-use; repeat purchases use products.
87
+ Legacy generic reusable links close after payment, preserving their history.
88
+
89
+ ## 1.1.0 — durable fulfillment notifications (release candidate)
90
+
91
+ - Add typed `payment.fulfilled` notifications with strict envelope/evidence shape
92
+ checks after raw-body HMAC verification. Wire amounts remain strings;
93
+ authenticated `fulfillment.verify` is still required for economic authority.
94
+ - Add `fulfillment.listAttempts` with scoped, versioned keyset discovery for
95
+ missing-notification recovery. Historical candidates never authorize fulfillment.
96
+ - Document stable source event IDs, nine-send retry cycles, explicit replay and
97
+ attempt/intent-keyed atomic credit handling across webhook and reconciliation.
98
+
99
+ ## 1.0.0 — strict fulfilment authority
100
+
101
+ Breaking authority contract. Existing tolerant checkout, product, entitlement,
102
+ and webhook views remain available for display, correlation, and migration, but
103
+ they are not proof that a seller may fulfil an order.
104
+
105
+ ### Added
106
+
107
+ - `genesispay.fulfillment.verify({ locator, expected })`, the only public SDK
108
+ path that returns strict payment authority. It always retrieves evidence from
109
+ the seller-authenticated GenesisPay API; no public method accepts a
110
+ caller-created evidence object.
111
+ - Exact `ExpectedProductContract`, `ExpectedPaymentLinkContract`,
112
+ `FulfillmentLocator`, `FulfillmentVerification`, and `VerifiedPayment` types.
113
+ Money is `bigint` minor units in application code and bounded canonical
114
+ decimal strings on the wire.
115
+ - Explicit `GENESISPAY-Version: 2026-08-26` negotiation plus matching
116
+ `GENESISPAY-Request-Id` and version metadata on successful and negative
117
+ results.
118
+ - Typed `GenesisPayContractMismatchError`,
119
+ `GenesisPayAmbiguousLocatorError`, `GenesisPayEvidenceError`, and
120
+ `GenesisPayVersionError`. Every SDK error now exposes nullable `requestId` and
121
+ `apiVersion` properties; they are null only when no versioned response exists.
122
+ - `products.assertContract(expected)` and idempotent
123
+ `products.createCheckout({ expected, ... }, { idempotencyKey })`. The latter
124
+ returns an explicit `product_checkout_link` with `linkId`, never an ambiguous
125
+ checkout `id`.
126
+ - `createGateRequestFingerprint(request)` and the breaking
127
+ `products.gate(id).protect(request, expected, handler)` signature. A product
128
+ handler now receives only strictly verified payment/product fields.
129
+
130
+ ### Safety
131
+
132
+ - Strict fee validation distinguishes a supported 100%-of-gross record-only
133
+ quote from an authorized deduction: the former preserves the full seller
134
+ payment; the latter must leave a positive seller amount. Quotes above gross
135
+ fail closed in both backend and SDK.
136
+ - The configured `expectedPayTo` pin also guards strict product contract checks,
137
+ checkout creation and gate protection, authenticated checkout retrieval, and
138
+ strict fulfillment verification. Missing/conflicting retrieved destinations
139
+ fail closed; a caller's expected contract cannot override the pin. Historical
140
+ reconciliation after wallet rotation uses a client pinned to the original
141
+ order destination. Clients without a pin retain their existing behavior.
142
+ - Strict `checkout.create` errors preserve request/version correlation from
143
+ response headers or body while retaining validation, rate-limit and other
144
+ typed HTTP errors, including interrupted or non-JSON error responses.
145
+ - MR-102/MR-103: mode, Base network, chain, asset, token address, and six-decimal
146
+ scale are cross-validated against the SDK's audited USDC/EURC deployment
147
+ registry before a result can be verified.
148
+ - MR-202: locator identity, exact gross amount, frozen destination, product/SKU,
149
+ and complete delivery or gate intent must match the expected immutable
150
+ contract. Contract mismatches throw and include the mismatched field paths.
151
+ - MR-804: verified evidence requires the literal `simulated: false` and the
152
+ supported authority provenance version. Historical evidence without that
153
+ provenance fails closed instead of inheriting a default.
154
+ - Known missing/null/wrong-typed fields, noncanonical or oversized money,
155
+ settlement arithmetic contradictions, unsafe/noncanonical URLs, unknown
156
+ payment channels, and unsupported versions fail closed. Unknown additive
157
+ fields remain forward compatible.
158
+ - Direct `checkout.create` now requires `{ idempotencyKey }` and sends both
159
+ `Idempotency-Key` and the strict API version. There is no idempotency-free
160
+ money-creation overload in 1.0.
161
+ - A product gate never defaults asset/chain or fabricates `simulated: false`.
162
+ Its initial challenge sends the complete validated expected contract for an
163
+ atomic pre-attempt comparison against the exact frozen payable link. Evidence
164
+ failure after settlement returns a `503` recovery response that preserves
165
+ a matching `PAYMENT-RESPONSE` and carries the attempt ID when one is known; permanent
166
+ inconsistencies are explicitly `retryable: false`.
167
+ - Signed gate recovery cross-checks attempt IDs in the request URL, payment
168
+ payload, settlement body, and settlement header. A post-commit transport loss
169
+ returns a retryable recovery response using that locator; a settlement that
170
+ names a different attempt than the signed one never reaches verification or
171
+ the paid handler and drops that other attempt's receipt. Both this case and
172
+ body/header contradictions report an unknown, retryable outcome.
173
+ - Interrupted verification response streams remain transient, while completed
174
+ malformed evidence stays permanent. Missing strict settlement metadata or a
175
+ negative `not_found`/`not_confirmed` verification never claims confirmation.
176
+ - Strict backend creation and gate calls reject a seller key whose mode does
177
+ not match the payment chain before exposing or settling that payment,
178
+ including product checkout idempotent replay.
179
+ - Confirmed gate retries can recover after their original authorization expires,
180
+ with signature and on-chain replay verification and no repeat broadcast/fee.
181
+ Failed/expired attempts remain terminal, including on archived links.
182
+ - Verified network contracts no longer expose the mutable shared asset registry.
183
+ URL-delivery examples use entitlement verification to honor revocation/expiry.
184
+ - Successful entitlement lookups must report a valid entitlement; payer-authorized
185
+ fees must leave a positive seller amount. Contradictory evidence is rejected.
186
+ - Conflicting recovery identities discard unrelated receipts on 503, other 5xx
187
+ and contradictory 2xx responses, while retaining the signed attempt locator.
188
+ - Frozen fee terms and the amount actually collected are deliberately separate:
189
+ a non-collecting payment may have nonzero configured fee terms with a zero
190
+ settled fee.
191
+
192
+ ### Migration
193
+
194
+ Use webhook, browser-return, link, or entitlement identifiers only as locators.
195
+ Pass an immutable expected contract to `fulfillment.verify`, fulfil only on
196
+ `verified: true`, and alert on typed mismatch/evidence/version errors using their
197
+ request ID. Pin this major exactly until the matching strict backend is deployed.
198
+
199
+ ## 0.13.2 — clean recovery package
200
+
201
+ No API or runtime behaviour change from `0.13.0`. This immutable patch release
202
+ replaces two unusable artifacts: `0.13.0` included stale legacy build output and
203
+ `0.13.1` omitted compiled `dist` entirely. Both versions are deprecated.
204
+
205
+ The release pipeline now clean/force-builds TypeScript project references,
206
+ repeats the forced build during `prepack`, and rejects a pack manifest that is
207
+ missing compiled exports or contains legacy artifact filenames.
208
+
3
209
  ## 0.13.0 — checkout return parameters and fulfilment DX
4
210
 
5
211
  Additive. Exports the return-parameter constants and a hint parser, and adds