studio-engine 0.144.1 → 0.145.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c43f1f30b1b77ed84d5f243c25d5210b01008ecbb43a96dc5c55a8ccf08b53d7
4
- data.tar.gz: 71623f99204ce7afb7c6381186d632045764fd385fb08fe1af08c1eaea1a8fbc
3
+ metadata.gz: fcd5103975b372a755ab0a9c62d8915e9854271354a51b1549056080ef6c8046
4
+ data.tar.gz: d154629954b9c7ea8d3355a2f6a34d36edbfa5924226bee9e96e54c748222ef4
5
5
  SHA512:
6
- metadata.gz: 671142acad89b5deee37b401108764b0d516cdfffb1a30ff0763ca7b0220780b8008f61d2846397daf63a728e25f19fff0e3af23fba725032b357ce837a2b330
7
- data.tar.gz: 43e6e425adc3e096d4215f2d8099148ba6ebd63f2fbba9f0f5f17b3784ba4d2b38bd177dc3a8ed6ad2b6daaeec0e226e43ad424f590d90f826a301c49a56e664
6
+ metadata.gz: ce022131694e41f489478bc09f57b9c7921f517af7107349d75ac0f42f7ebb115f0acf7834ab9b2553e7f93dce003d7a3397c4409f9a313d7bf9f19a293b5e92
7
+ data.tar.gz: 7e5436be99e866b904422765adc5d1c4a43c210c0b18f51389cfcfab2a0addf7d78567f2bf1d424850316f14570e0b2e24fcc4e334e6c54954f56afe4040101c
data/CHANGELOG.md CHANGED
@@ -4,6 +4,12 @@ The format is [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). This pro
4
4
 
5
5
  ## Unreleased
6
6
 
7
+ ## 0.145.0 — 2026-11-28
8
+
9
+ ### Added
10
+
11
+ - **`GET /_studio/local_review.json` answers the minted magic link as data.** The same single-use mint as the redirect, returned as `{ url, expires_at }`, so the task board's Magic Link card can show the link it minted. Only an origin in `Studio.local_review_board_origins` (default `https://mcritchie.studio`) or a loopback origin gets a CORS grant to read it; the endpoint stays non-production and loopback-only. Consumers need do nothing.
12
+
7
13
  ## 0.144.1 — 2026-11-27
8
14
 
9
15
  ### Fixed
@@ -49,6 +49,8 @@ module Studio
49
49
  # spelling of a rule that already has one owner — and a mutation run
50
50
  # confirmed it guards nothing the store does not already guard.
51
51
  token = issue_magic_link(email, params[:return_to])
52
+ return render_minted_json(token) if request.format.json?
53
+
52
54
  redirect_to magic_link_url_for(token), allow_other_host: false
53
55
  end
54
56
 
@@ -56,6 +58,41 @@ module Studio
56
58
 
57
59
  MISSING_EMAIL = "Add ?email=<your address> to mint a local review link."
58
60
 
61
+ # GET /_studio/local_review.json — the SAME mint, answered as data instead of
62
+ # a redirect, so the task board's Magic Link card can SHOW the link it minted
63
+ # (the operator asked to see the token, not only to be sent through it).
64
+ #
65
+ # The board is another origin (the production hub, or another desk's port),
66
+ # so its page can read this answer only through CORS. The allow-list is
67
+ # Studio.local_review_board_origins plus any loopback origin; every other
68
+ # origin gets no Access-Control-Allow-Origin, so a stranger's page that
69
+ # fires this GET mints a row it can never read. The floor above still holds:
70
+ # never in production, loopback requests only.
71
+ #
72
+ # Access-Control-Allow-Private-Network answers Chrome's local-network check
73
+ # for a public page reading a loopback server.
74
+ def render_minted_json(token)
75
+ origin = request.headers["Origin"].to_s
76
+ if board_origin_allowed?(origin)
77
+ response.set_header("Access-Control-Allow-Origin", origin)
78
+ response.set_header("Access-Control-Allow-Private-Network", "true")
79
+ end
80
+ response.set_header("Vary", "Origin")
81
+ response.set_header("Cache-Control", "no-store")
82
+ link = Studio::Link.find_by(token: token)
83
+ render json: { url: magic_link_url_for(token), expires_at: link&.expires_at&.utc&.iso8601 }
84
+ end
85
+
86
+ def board_origin_allowed?(origin)
87
+ return false if origin.empty?
88
+ return true if Array(Studio.local_review_board_origins).include?(origin)
89
+
90
+ uri = URI.parse(origin)
91
+ %w[http https].include?(uri.scheme) && Studio::LOOPBACK_ORIGIN_HOSTS.include?(uri.host)
92
+ rescue URI::InvalidURIError
93
+ false
94
+ end
95
+
59
96
  # WHO to sign in, in priority order:
60
97
  #
61
98
  # 1. `?email=` — an explicit caller still wins.
@@ -1,3 +1,3 @@
1
1
  module Studio
2
- VERSION = "0.144.1"
2
+ VERSION = "0.145.0"
3
3
  end
data/lib/studio.rb CHANGED
@@ -1565,6 +1565,15 @@ module Studio
1565
1565
  # whose operator is not the first seeded account at that role.
1566
1566
  mattr_accessor :local_review_email, default: nil
1567
1567
 
1568
+ # The ORIGINS whose pages may READ a local-review mint answered as JSON
1569
+ # (GET /_studio/local_review.json): the task board's Magic Link card mints
1570
+ # from the operator's local server and shows the link it got back. Any loopback
1571
+ # origin is allowed besides these (LOOPBACK_ORIGIN_HOSTS: a board on another
1572
+ # desk's port). Every other origin gets no CORS header, so its page cannot read
1573
+ # the token. The endpoint's floor is unchanged: non-production, loopback only.
1574
+ mattr_accessor :local_review_board_origins, default: [ "https://mcritchie.studio" ]
1575
+ LOOPBACK_ORIGIN_HOSTS = %w[localhost 127.0.0.1 [::1] ::1].freeze
1576
+
1568
1577
  # Theme role colors (7 roles)
1569
1578
  mattr_accessor :theme_primary, default: "#8E82FE"
1570
1579
  mattr_accessor :theme_dark, default: "#1A1535"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: studio-engine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.144.1
4
+ version: 0.145.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex McRitchie