@openreceive/http 0.2.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/LICENSE +21 -0
- package/README.md +57 -0
- package/dist/adapter-surface-BtXnvW2q.d.ts +722 -0
- package/dist/adapter-surface.d.ts +3 -0
- package/dist/adapter-surface.js +20 -0
- package/dist/chunk-5S24YV7E.js +2228 -0
- package/dist/index.d.ts +411 -0
- package/dist/index.js +74 -0
- package/package.json +59 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 OpenReceive contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# @openreceive/http
|
|
2
|
+
|
|
3
|
+
Framework-neutral receive-checkout handler. Its normal form requires `service`,
|
|
4
|
+
`authorize`, and the `host` integration. Create bodies never accept payer
|
|
5
|
+
amounts; the host's `amountFor` hook is the only price authority, and the
|
|
6
|
+
commit hook appends a payment-attempt row before the invoice is returned.
|
|
7
|
+
|
|
8
|
+
This package is ESM-only and requires Node >= 22.
|
|
9
|
+
|
|
10
|
+
`createHost({ db, amountFor, onPaid })` builds that
|
|
11
|
+
host integration on the library-owned payment repository inside the host
|
|
12
|
+
application's existing database (pg, node:sqlite, better-sqlite3, or a custom
|
|
13
|
+
adapter). The library owns attempt selection, per-reference commit locking,
|
|
14
|
+
write-once settlement with first-attempt-only fulfillment, and the
|
|
15
|
+
`pending → settled | expired | failed | attention` reconciliation state
|
|
16
|
+
machine (`attention` reads as `pending` on the wire; operators see it only in
|
|
17
|
+
`openreceive_payments.status`). `onPaid` is the settlement hook in both modes: with `db` it receives
|
|
18
|
+
`PaymentSettlement` (`reference` plus a `query` that runs inside the
|
|
19
|
+
settlement transaction); with a custom repository it receives the raw
|
|
20
|
+
`SettlementEvent` (`paymentHash`, `paidAt`, `details`). Settlement
|
|
21
|
+
piggybacks on mounted routes by default through the durable `openreceive_meta`
|
|
22
|
+
gate (`opportunisticReconcile: false` disables, `{ minIntervalSeconds }`
|
|
23
|
+
tunes); `startNotificationWorker` is the optional
|
|
24
|
+
listen-plus-reconcile worker process. A custom `PaymentRepository`
|
|
25
|
+
via the `payments` option is the advanced escape hatch.
|
|
26
|
+
|
|
27
|
+
It reuses one live attempt per rail, permits new attempts after expiry, and
|
|
28
|
+
verifies the `payment_hash` selector belongs to the authorized order. Committed
|
|
29
|
+
retries use the stored safe checkout snapshot. `swapData` is never serialized
|
|
30
|
+
into an HTTP response. OpenReceive never requires a separate database or Redis.
|
|
31
|
+
|
|
32
|
+
This is the home of the full host-integration surface. The framework adapters
|
|
33
|
+
(`@openreceive/express`, `@openreceive/fastify`, `@openreceive/next`) re-export
|
|
34
|
+
only a curated slice — the handler/stack factories, error surface, notification
|
|
35
|
+
worker, and their options/context/hook types — so anything deeper imports from
|
|
36
|
+
here (`npm run check:public-api` pins both surfaces):
|
|
37
|
+
|
|
38
|
+
- Handler and stack: `createHttpHandler`, `createStack`,
|
|
39
|
+
their options types, and `mapHostRouteError` / `HttpError` /
|
|
40
|
+
`HostError`.
|
|
41
|
+
- Host integration: `createHost`, the SQL repository
|
|
42
|
+
(`createSqlPayments`, `paymentsSchemaSql`), the
|
|
43
|
+
`PaymentRepository` contract types, and the settlement hook
|
|
44
|
+
contexts above.
|
|
45
|
+
- Reconciliation: `maybeReconcilePayments` (the durable gate pass),
|
|
46
|
+
`reconcileHostPayments`, `startReconciler`, and the shared
|
|
47
|
+
constants (`OPENRECEIVE_ATTEMPT_EXPIRY_GRACE_SECONDS`,
|
|
48
|
+
`OPENRECEIVE_RECONCILE_BATCH_SIZE`, scan bounds).
|
|
49
|
+
- Rate limiting: `createIpRateLimit`, `resolveClientIp`, and
|
|
50
|
+
`IpRateLimitConfig` behind the handler's `rateLimiting` /
|
|
51
|
+
`rateLimitHook` options.
|
|
52
|
+
- Generated wire types: the snake_case `Wire*` request/response body
|
|
53
|
+
types (`WireCheckout`, `WireCreateCheckoutRequest`,
|
|
54
|
+
`WirePaymentCheck`, `WireError`, …), generated from the
|
|
55
|
+
OpenAPI contract. The adapters re-export these too.
|
|
56
|
+
|
|
57
|
+
See the root README, the storage guide, and the OpenAPI contract.
|