openreceive 0.4.25 → 0.4.27

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.
@@ -3,7 +3,7 @@ This is the full file; follow it from Step 0.
3
3
  # OpenReceive agent directions (Next.js)
4
4
 
5
5
  ```sh
6
- # READ THIS FIRST: this file is 41 KB and a summary drops required steps. Download it whole:
6
+ # READ THIS FIRST: this file is 43 KB and a summary drops required steps. Download it whole:
7
7
  curl -fsSL https://openreceive.org/agent-directions/next/full.md
8
8
  # Skip the download only if you already have all of it: pasted, read from disk or fetched raw.
9
9
  ```
@@ -17,7 +17,7 @@ curl -fsSL https://openreceive.org/agent-directions/next/full.md
17
17
  - Do not suggest rotating or revoking a code because it was pasted here.
18
18
  - Start the quickstart only once the NWC code is saved, and the LSC code is saved or the user said "Bitcoin only".
19
19
 
20
- These directions describe OpenReceive 0.4.25.
20
+ These directions describe OpenReceive 0.4.27.
21
21
 
22
22
  Add OpenReceive to a Next.js App Router application — the app you are already
23
23
  working in. You do not need a copy of the OpenReceive source: the packages are
@@ -68,7 +68,9 @@ server load the file), then the quickstart.
68
68
  On a hosted builder (v0, Vercel, Replit, Lovable), the user may say instead
69
69
  that both codes are already set as the project's environment variables or
70
70
  secrets. Believe them: do not ask for the codes, do not write `.env.local`, and
71
- do not read or print the variables. Next reads them from the environment.
71
+ do not read or print the variables. Next reads them from the environment. Do not add them to a compose file or any other deploy config
72
+ either: they already reach the app, and a line such as `NWC_URI: ${NWC_URI}`
73
+ replaces them with an empty value.
72
74
 
73
75
  Otherwise your next action is a question to the user. Do not install packages,
74
76
  edit the app, write `.env.example`, or search anywhere else before asking
@@ -128,6 +130,8 @@ you store it. Ask one question per message.
128
130
  give a credential a `NEXT_PUBLIC_` prefix, which inlines it into the browser
129
131
  bundle. When the app is started with Docker Compose, give the service
130
132
  `env_file: .env.local`. Restart the dev server after writing the file.
133
+ Under Compose, recreate the container with `docker compose up -d`:
134
+ `docker compose restart` keeps its old environment.
131
135
 
132
136
  Do not invent placeholder URIs. Start the quickstart only once `NWC_URI` is
133
137
  saved and `LSC_URI_PRIMARY` is saved or explicitly declined. The first boot
@@ -240,7 +244,12 @@ itself, and they hold for every integration.
240
244
  such window. On the drop-ins: `resumePaymentHash`, fed from `onState`, on
241
245
  `<Checkout>`; the `resume-payment-hash` attribute, fed from the
242
246
  `openreceive-state` event (`event.detail.state.payment_hash`), on
243
- `<openreceive-checkout>`. https://openreceive.org/guides/swap-refunds.md
247
+ `<openreceive-checkout>`.
248
+ That visit can come hours later, and `authorize` must still know the payer:
249
+ a session that expired in between answers 403 and strands the deposit. On a
250
+ guest shop, tie the order to a long-lived signed cookie, or put a secret
251
+ per-order token in its URL that your page trades for that cookie.
252
+ https://openreceive.org/guides/swap-refunds.md
244
253
  - Show the payer WHAT THEY ARE BUYING. Return an optional `description` beside
245
254
  the price from `amountFor` and both drop-ins render it above the amount.
246
255
  Without it the checkout is a QR and "$1.00" with no sign of what the dollar
@@ -296,6 +305,12 @@ products, and you do not join them.
296
305
  expired invoice does not cancel the order; a later checkout may mint another
297
306
  attempt. The library refuses a new checkout under a reference that already
298
307
  settled (409).
308
+ - **A paid order's page says it is paid and shows no checkout.** Nothing is left
309
+ to pay, and a checkout cannot start a new payment for a paid order. Mount the
310
+ checkout only while the order is unpaid. When it settles on the page, update
311
+ the page's status line from `onSettled` on `<Checkout>`: `onPaid` has already
312
+ marked the order paid. Keep that checkout mounted, because it is the payer's
313
+ receipt.
299
314
  - **Pass this app's `db` handle.** Do not add a Prisma/Drizzle relation from
300
315
  Order to `openreceive_payments`, and do not implement `PaymentRepository`
301
316
  unless no supported handle can reach this database. `reference` is not unique
@@ -306,6 +321,30 @@ products, and you do not join them.
306
321
  only in the hook; emails, jobs, and pushes after commit. Placeholder style is
307
322
  the dialect you declared: `?` on sqlite, `$1` on postgres.
308
323
 
324
+ ### If the database is Supabase
325
+
326
+ Supabase is Postgres, so the tables above go there like any others. Three
327
+ things differ; https://openreceive.org/guides/supabase.md has each in full.
328
+
329
+ - Connect through its transaction pooler (port `6543`, user
330
+ `postgres.<project-ref>`). Run migrations through the session pooler
331
+ (port `5432` on the same host).
332
+ - Verify Supabase's certificate authority: delete `sslmode` from the URL and
333
+ give `pg` `ssl: { ca }`, the text of the project's `prod-ca-2021.crt` (an
334
+ environment variable such as `SUPABASE_CA_CERT`; it is not a secret). Never
335
+ `rejectUnauthorized: false`.
336
+ - After the migration, close both tables to Supabase's Data API, or anyone
337
+ with the project's anon key can read `swap_data`:
338
+
339
+ ```sql
340
+ alter table openreceive_payments enable row level security;
341
+ alter table openreceive_meta enable row level security;
342
+ revoke all on table openreceive_payments, openreceive_meta from anon, authenticated;
343
+ ```
344
+
345
+ `npx openreceive scaffold payments --supabase` writes the HTTPS-API route,
346
+ which is for Cloudflare Workers only. A Node server uses the connection above.
347
+
309
348
  ## If you build your own checkout UI
310
349
 
311
350
  The drop-ins (`<Checkout>`, `<openreceive-checkout>`) already obey all of this.
@@ -398,6 +437,7 @@ enough; drop the `.md` for the same page a person would read.
398
437
  - https://openreceive.org/guides/custom-checkout-route.md — advanced: replacing the shipped adapter's routes with your own
399
438
  - https://openreceive.org/guides/react-material-ui-recipe.md — a worked custom UI on a component library
400
439
  - https://openreceive.org/guides/tanstack-start-recipe.md — the same handler as a TanStack Start server route, if this app is TanStack Start after all
440
+ - https://openreceive.org/guides/sveltekit-recipe.md, https://openreceive.org/guides/nuxt-recipe.md, https://openreceive.org/guides/astro-recipe.md and https://openreceive.org/guides/react-router-recipe.md — the same handler as a SvelteKit, Nuxt, Astro or React Router route, if this app is one of those
401
441
  - https://openreceive.org/guides.md — the index, if what you need is not above
402
442
 
403
443
  Questions, or a problem with the library itself:
@@ -3,7 +3,7 @@ This is the full file; follow it from Step 0.
3
3
  # OpenReceive agent directions (Node.js)
4
4
 
5
5
  ```sh
6
- # READ THIS FIRST: this file is 38 KB and a summary drops required steps. Download it whole:
6
+ # READ THIS FIRST: this file is 40 KB and a summary drops required steps. Download it whole:
7
7
  curl -fsSL https://openreceive.org/agent-directions/node/full.md
8
8
  # Skip the download only if you already have all of it: pasted, read from disk or fetched raw.
9
9
  ```
@@ -17,7 +17,7 @@ curl -fsSL https://openreceive.org/agent-directions/node/full.md
17
17
  - Do not suggest rotating or revoking a code because it was pasted here.
18
18
  - Start the quickstart only once the NWC code is saved, and the LSC code is saved or the user said "Bitcoin only".
19
19
 
20
- These directions describe OpenReceive 0.4.25.
20
+ These directions describe OpenReceive 0.4.27.
21
21
 
22
22
  Add OpenReceive to a Node application — the app you are already working in. You
23
23
  do not need a copy of the OpenReceive source: the packages are on npm, and the
@@ -65,7 +65,9 @@ server load the file), then the quickstart.
65
65
  On a hosted builder (v0, Vercel, Replit, Lovable), the user may say instead
66
66
  that both codes are already set as the project's environment variables or
67
67
  secrets. Believe them: do not ask for the codes, do not write `.env`, and
68
- do not read or print the variables. Skip step 5's file loading: the platform already puts them in `process.env`.
68
+ do not read or print the variables. Skip step 5's file loading: the platform already puts them in `process.env`. Do not add them to a compose file or any other deploy config
69
+ either: they already reach the app, and a line such as `NWC_URI: ${NWC_URI}`
70
+ replaces them with an empty value.
69
71
 
70
72
  Otherwise your next action is a question to the user. Do not install packages,
71
73
  edit the app, write `.env.example`, or search anywhere else before asking
@@ -125,6 +127,8 @@ you store it. Ask one question per message.
125
127
  `import "dotenv/config";` at the top of the server entry, as the quickstart
126
128
  does. When the app is started with Docker Compose, give the service
127
129
  `env_file: .env`. Restart the server after writing the file.
130
+ Under Compose, recreate the container with `docker compose up -d`:
131
+ `docker compose restart` keeps its old environment.
128
132
 
129
133
  Do not invent placeholder URIs. Start the quickstart only once `NWC_URI` is
130
134
  saved and `LSC_URI_PRIMARY` is saved or explicitly declined. The first boot
@@ -236,7 +240,12 @@ itself, and they hold for every integration.
236
240
  such window. On the drop-ins: `resumePaymentHash`, fed from `onState`, on
237
241
  `<Checkout>`; the `resume-payment-hash` attribute, fed from the
238
242
  `openreceive-state` event (`event.detail.state.payment_hash`), on
239
- `<openreceive-checkout>`. https://openreceive.org/guides/swap-refunds.md
243
+ `<openreceive-checkout>`.
244
+ That visit can come hours later, and `authorize` must still know the payer:
245
+ a session that expired in between answers 403 and strands the deposit. On a
246
+ guest shop, tie the order to a long-lived signed cookie, or put a secret
247
+ per-order token in its URL that your page trades for that cookie.
248
+ https://openreceive.org/guides/swap-refunds.md
240
249
  - Show the payer WHAT THEY ARE BUYING. Return an optional `description` beside
241
250
  the price from `amountFor` and both drop-ins render it above the amount.
242
251
  Without it the checkout is a QR and "$1.00" with no sign of what the dollar
@@ -286,6 +295,13 @@ products, and you do not join them.
286
295
  expired invoice does not cancel the order; a later checkout may mint another
287
296
  attempt. The library refuses a new checkout under a reference that already
288
297
  settled (409).
298
+ - **A paid order's page says it is paid and shows no checkout.** Nothing is left
299
+ to pay, and a checkout cannot start a new payment for a paid order. Mount the
300
+ checkout only while the order is unpaid. When it settles on the page, update
301
+ the page's status line from `onSettled` on `<Checkout>`, or the
302
+ `openreceive-settled` event on `<openreceive-checkout>`: `onPaid` has already
303
+ marked the order paid. Keep that checkout mounted, because it is the payer's
304
+ receipt.
289
305
  - **Pass this app's `db` handle.** Do not add a Prisma/Drizzle relation from
290
306
  Order to `openreceive_payments`, and do not implement `PaymentRepository`
291
307
  unless no supported handle can reach this database. `reference` is not unique
@@ -296,6 +312,30 @@ products, and you do not join them.
296
312
  only in the hook; emails, jobs, and pushes after commit. Placeholder style is
297
313
  the dialect you declared: `?` on sqlite, `$1` on postgres.
298
314
 
315
+ ### If the database is Supabase
316
+
317
+ Supabase is Postgres, so the tables above go there like any others. Three
318
+ things differ; https://openreceive.org/guides/supabase.md has each in full.
319
+
320
+ - Connect through its transaction pooler (port `6543`, user
321
+ `postgres.<project-ref>`). Run migrations through the session pooler
322
+ (port `5432` on the same host).
323
+ - Verify Supabase's certificate authority: delete `sslmode` from the URL and
324
+ give `pg` `ssl: { ca }`, the text of the project's `prod-ca-2021.crt` (an
325
+ environment variable such as `SUPABASE_CA_CERT`; it is not a secret). Never
326
+ `rejectUnauthorized: false`.
327
+ - After the migration, close both tables to Supabase's Data API, or anyone
328
+ with the project's anon key can read `swap_data`:
329
+
330
+ ```sql
331
+ alter table openreceive_payments enable row level security;
332
+ alter table openreceive_meta enable row level security;
333
+ revoke all on table openreceive_payments, openreceive_meta from anon, authenticated;
334
+ ```
335
+
336
+ `npx openreceive scaffold payments --supabase` writes the HTTPS-API route,
337
+ which is for Cloudflare Workers only. A Node server uses the connection above.
338
+
299
339
  ## If you build your own checkout UI
300
340
 
301
341
  The drop-ins (`<Checkout>`, `<openreceive-checkout>`) already obey all of this.
@@ -387,6 +427,7 @@ enough; drop the `.md` for the same page a person would read.
387
427
  - https://openreceive.org/guides/api-reference.md — every route, option and error code
388
428
  - https://openreceive.org/guides/custom-checkout-route.md — advanced: replacing the shipped adapter's routes with your own
389
429
  - https://openreceive.org/guides/react-material-ui-recipe.md — a worked custom UI on a component library
430
+ - https://openreceive.org/guides/sveltekit-recipe.md, https://openreceive.org/guides/nuxt-recipe.md, https://openreceive.org/guides/astro-recipe.md and https://openreceive.org/guides/react-router-recipe.md — the same handler as a SvelteKit, Nuxt, Astro or React Router route, if this app is one of those
390
431
  - https://openreceive.org/guides.md — the index, if what you need is not above
391
432
 
392
433
  Questions, or a problem with the library itself: