openreceive-rails 0.3.3 → 0.4.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 96a850e9b25d9797bff5f7b668b8e8bf26c891991058bf58ffd911c0abcdcbb4
4
- data.tar.gz: 33d4e8872eb37baf2d77f0f47b5224dafa4851f056e43ff0c047f9b3e05ab647
3
+ metadata.gz: d96bcbf6cbe2379c285d8fc0f61b59438d75c27af55465be700f0c18ea498dcb
4
+ data.tar.gz: 6e97b4d45559953ffca5380313692559579e322df6700f4d165970bced786023
5
5
  SHA512:
6
- metadata.gz: 2447535630f828c0185846df6f79b995ac0968c8a7a0e22ccf02104e3b9003333e3754476f65addb09823ae1678004639c8dfeb95e6f914f54c26fd610f575f0
7
- data.tar.gz: c01e0905acbd634606783b0b6fe05eb16002238f7987cb92ac48c97da788f49a82b42242e82ca60d19624d359a6841583bf7a9caab73f2f8902c44f0a567a70d
6
+ metadata.gz: 79214e11c2cd614f5eaac640a65180468d06218775d74415db20f9a3064e097db16575816f8da8acafc2bdd1402fe69019485476db6a44cf7ab336b2a4faa4ff
7
+ data.tar.gz: 78e9da4d3da20415f49683c6866b4ef44892b8be1bba3ea637e27080fb0474d64b462871fbce8fb0c40eb8059519f5e2653ff617ef1d9b8e23a70094c76be721
data/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.1 - 2026-09-02
4
+
5
+ Version lockstep with the 0.4.1 npm release. First version published from CI
6
+ through RubyGems Trusted Publishing (`.github/workflows/publish-gems.yml`)
7
+ instead of a maintainer's API key and OTP. No functional change in this gem.
8
+
9
+ ## 0.4.0 - 2026-09-02
10
+
11
+ Version lockstep with the 0.4.0 npm release. The generated initializer's
12
+ `config.authorize` comment now states the resource guarantee:
13
+ `context[:resource][:reference]` is always a validated non-empty String
14
+ (200 characters or fewer) by the time the lambda runs, and `payment_hash` is
15
+ nil except on `payment.check`, `swap.read`, and `swap.refund`. No functional
16
+ change.
17
+
3
18
  ## 0.3.3 - 2026-09-02
4
19
 
5
20
  ### A missing migration says so, with the fix
@@ -18,7 +18,9 @@ OpenReceive.configure do |config|
18
18
  # cookies, or headers from it, as in a controller
19
19
  # context[:resource] — { reference:, payment_hash: } copied from the
20
20
  # payer's JSON body. It names an order; it does not
21
- # prove this caller owns it.
21
+ # prove this caller owns it. reference is always a
22
+ # validated non-empty String (≤200 chars); payment_hash
23
+ # is nil except on payment.check / swap.read / swap.refund.
22
24
  # Return true to allow the request, false for a 403.
23
25
  #
24
26
  # The default below is a NAMED PLACEHOLDER, and the engine warns at boot for
@@ -5,6 +5,6 @@ module OpenReceive
5
5
  # top-level `::Rails` framework constant — engine code always references the framework as
6
6
  # `::Rails` to avoid shadowing.
7
7
  module Rails
8
- VERSION = "0.3.3"
8
+ VERSION = "0.4.1"
9
9
  end
10
10
  end
@@ -40,6 +40,7 @@ same diagnostics redacted, always exit 0 — safe to share.
40
40
  | Status | Meaning | Where to look |
41
41
  | --- | --- | --- |
42
42
  | 403 FORBIDDEN | Your own `authorize` hook denied it, or the request looked cross-site. Check the session/cookie actually reaches the checkout routes. https://openreceive.org/guides/authorization.md |
43
+ | Never 403s — any visitor can mint, poll, or refund for any reference | The opposite failure: on Rails the generated `config.authorize = OpenReceive::ALLOW_ALL_AUTHORIZE` placeholder is still installed (the engine warns at boot; `bin/rails openreceive:doctor` reports it). Replace it with the app's real ownership check. https://openreceive.org/guides/authorization.md |
43
44
  | 404 NOT_FOUND | `amountFor` returned `null` (unknown reference), or the `payment_hash` does not belong to that reference. |
44
45
  | 409 CONFLICT | **Normal state, not a bug**: the reference already settled, or an unpaid checkout for that method is already live. Show it as order state; never retry-loop. |
45
46
  | 503 retryable | The host hook failed while persisting the attempt (instructions withheld), or the wallet is unavailable. Read the server log for the underlying error. |
@@ -1,6 +1,6 @@
1
1
  # OpenReceive agent directions (Node.js)
2
2
 
3
- These directions describe OpenReceive 0.3.3.
3
+ These directions describe OpenReceive 0.4.1.
4
4
 
5
5
  Add OpenReceive to a Node application — the app you are already working in. You
6
6
  do not need a copy of the OpenReceive source: the packages are on npm, and the
@@ -374,6 +374,8 @@ const openreceive = openReceiveExpress({
374
374
  : null;
375
375
  },
376
376
  // Your own access check: may this caller do this action to this reference?
377
+ // `resource.reference` is your own order id, sent back by the payer's
378
+ // browser — a claim, not proof — already validated as a non-empty string.
377
379
  authorize: async ({ action, request, resource }) =>
378
380
  orders.viewerMay(
379
381
  await sessions.currentUser(request),
@@ -451,11 +453,13 @@ so a white card never lands on a dark page. The checkout is styled by CSS
451
453
  variables under `data-theme`; [Frontend checkout](https://openreceive.org/guides/frontend-checkout.md) has
452
454
  the knobs.
453
455
 
454
- Outside Vite/Rollup (esbuild, webpack, a plain script tag) the packaged
455
- payment-method icons cannot resolve their own URLs the drop-in needs this
456
- exactly as a custom UI does. Serve the two packages' `dist/assets` trees and
457
- pass the base as `assetBaseUrl="/openreceive-assets"`
458
- ([Provider registry](https://openreceive.org/guides/provider-registry.md#assets-are-files-your-host-serves)).
456
+ The payment-method icons are compiled into `@openreceive/browser` and need
457
+ nothing from your bundler. The wallet logos and pay tutorials are files in
458
+ `@openreceive/provider-data`, and outside Vite/Rollup (esbuild, webpack, a
459
+ plain script tag) they cannot resolve their own URLs — the drop-in needs this
460
+ exactly as a custom UI does. Serve that package's `dist/assets` tree and pass
461
+ the base as `assetBaseUrl="/openreceive-assets"`
462
+ ([Provider registry](https://openreceive.org/guides/provider-registry.md#assets)).
459
463
 
460
464
  That is the whole loop: your server owns the price and the order, the payer gets
461
465
  an invoice, and `onPaid` runs once inside the settlement transaction.
@@ -1,6 +1,6 @@
1
1
  # OpenReceive agent directions (Rails)
2
2
 
3
- These directions describe OpenReceive 0.3.3.
3
+ These directions describe OpenReceive 0.4.1.
4
4
 
5
5
  Add OpenReceive to a Rails application — the app you are already working in. You
6
6
  do not need a copy of the OpenReceive source: the gem is on RubyGems, the
@@ -106,7 +106,9 @@ itself, and they hold for every integration.
106
106
  reject payer-supplied amounts.
107
107
  - `config.authorize` runs on every request, and the `resource` it receives is a
108
108
  CLAIM the payer made, not proof. Read the framework session; never trust a
109
- body field.
109
+ body field. The generator installs `OpenReceive::ALLOW_ALL_AUTHORIZE`, a
110
+ placeholder that allows everything (the engine warns at boot while it is
111
+ set) — replace it with this app's real ownership check, same as `on_paid`.
110
112
  - `config.on_paid` must be idempotent. It runs once per `reference` — your order
111
113
  id, one per thing you fulfill, created before checkout, kept across retries,
112
114
  never reused. A fresh id per page load lets one order be paid twice.
@@ -409,7 +411,9 @@ OpenReceive.configure do |config|
409
411
  # cookies, or headers from it, as in a controller
410
412
  # context[:resource] — { reference:, payment_hash: } copied from the
411
413
  # payer's JSON body. It names an order; it does not
412
- # prove this caller owns it.
414
+ # prove this caller owns it. reference is always a
415
+ # validated non-empty String (≤200 chars); payment_hash
416
+ # is nil except on payment.check / swap.read / swap.refund.
413
417
  # Return true to allow, false for a 403. Here: only the signed-in customer
414
418
  # who placed the order may act on it.
415
419
  config.authorize = lambda do |context|
@@ -455,7 +459,12 @@ The generated initializer ships
455
459
  the settlement and fulfills nothing. Replace it with your real fulfillment (as
456
460
  above); the engine warns every time your application boots while the
457
461
  placeholder is still configured, because orders would otherwise be recorded as settled without ever
458
- being fulfilled.
462
+ being fulfilled. The same applies to
463
+ `config.authorize = OpenReceive::ALLOW_ALL_AUTHORIZE`, the generated
464
+ allow-all placeholder: it treats possession of the reference as
465
+ authorization, which is safe only while references are unguessable, and the
466
+ engine warns at boot until you replace it with your own ownership check (as
467
+ above). Replace both, not just `on_paid`.
459
468
 
460
469
  The amount always comes from your own order record; payer-supplied amounts are
461
470
  rejected. Advanced hooks (`resolve_checkout`, `on_checkout_created`) remain as
@@ -510,13 +519,13 @@ Bundling with esbuild (jsbundling-rails)? Two things:
510
519
  <%= javascript_include_tag "application", type: "module" %>
511
520
  ```
512
521
 
513
- 2. Serve the payment-method icons. They are files shipped in
514
- `@openreceive/browser` and `@openreceive/provider-data` not in
515
- `@openreceive/elements` and only Vite-style bundlers resolve them from
516
- the import. Merge both packages' `dist/assets` trees into
517
- `public/openreceive-assets/assets/` and set
522
+ 2. Serve the provider images. The payment-method icons are compiled into
523
+ `@openreceive/browser` and need nothing, but the wallet logos and pay
524
+ tutorials are files shipped in `@openreceive/provider-data`, and only
525
+ Vite-style bundlers resolve them from the import. Copy that package's
526
+ `dist/assets` tree to `public/openreceive-assets/assets/` and set
518
527
  `asset-base-url="/openreceive-assets"` on the element
519
- ([Provider registry](https://openreceive.org/guides/provider-registry.md#assets-are-files-your-host-serves)).
528
+ ([Provider registry](https://openreceive.org/guides/provider-registry.md#assets)).
520
529
 
521
530
  The element creates the checkout for `reference`, then renders and polls
522
531
  itself. React/Vue/Svelte/Angular apps use the matching wrapper package
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openreceive-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - OpenReceive
@@ -15,28 +15,28 @@ dependencies:
15
15
  requirements:
16
16
  - - '='
17
17
  - !ruby/object:Gem::Version
18
- version: 0.3.3
18
+ version: 0.4.1
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - '='
24
24
  - !ruby/object:Gem::Version
25
- version: 0.3.3
25
+ version: 0.4.1
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: openreceive-server
28
28
  requirement: !ruby/object:Gem::Requirement
29
29
  requirements:
30
30
  - - '='
31
31
  - !ruby/object:Gem::Version
32
- version: 0.3.3
32
+ version: 0.4.1
33
33
  type: :runtime
34
34
  prerelease: false
35
35
  version_requirements: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - '='
38
38
  - !ruby/object:Gem::Version
39
- version: 0.3.3
39
+ version: 0.4.1
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: rails
42
42
  requirement: !ruby/object:Gem::Requirement
@@ -153,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
153
153
  - !ruby/object:Gem::Version
154
154
  version: '0'
155
155
  requirements: []
156
- rubygems_version: 3.6.8
156
+ rubygems_version: 3.6.9
157
157
  specification_version: 4
158
158
  summary: OpenReceive mountable Rails engine with engine-owned payment attempts in
159
159
  the host database.