tensaku 0.3.0 → 0.3.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: e8c394724c7f5587635c17b0c4c6e3ff7c02351ac3d432554836ee35255179fe
4
- data.tar.gz: 3dcdeeb2b5cfc2fd56ed28e00dd399c9529ea04edd335ba5ce220f74459e6ca2
3
+ metadata.gz: bded651552ef924d61c4d8e952a3ba0f1024fb0709566d95ea868c8a6f653f42
4
+ data.tar.gz: 6d66695514f54b31b1f1c4c5e24bbf9ce211bf1154e632d1201c0888eee499bc
5
5
  SHA512:
6
- metadata.gz: 71966e3cb764655f9a128df10bf084327692668c80f5bfc6708e43d5ab41e8a4db7743b1ebe033a1df369242e9b2ff156c2718c90cd5951bc420586f527c38ea
7
- data.tar.gz: ebe3540b54a22d691b0a3fa9b9197f3ec76066fa078d80515078697871af8575835c4043b8345983ebd575e7218d783ffc28f30589ca289132bceebc0eae39f1
6
+ metadata.gz: 4c1177b6fee9b8793a5ac961edb849075a75baa4f46b40dfcdbe15eb494604bfe78358f50bf09594a88d1dc37337501590faa7b0da0a045b88fa4988c3f7af4a
7
+ data.tar.gz: 47214ef1ba2ccc6cc6279eaa55e07e1548e622a66850bbf23f2de5bd68c02d9fd075ca7e73d9bac8be222c53814bb6ca6decc63c319d76e117717e7c67cd3819
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.1 (2026-11-15)
4
+
5
+ - Tensaku works on a phone or another device paired with [Parcela](https://parcela.run) and reached
6
+ through Parcela's proxy. Parcela's proxy is the one proxy Tensaku trusts to forward another client:
7
+ a request from loopback whose `Parcela-Device-Secret` header equals the `PARCELA_PROXY_SECRET`
8
+ Parcela gives the server gets the overlay and the endpoints. The Host and Origin checks and the boot
9
+ token still apply. Any other request forwarded from another machine is still refused.
10
+ - An app that doesn't load Active Model boots in development again. Since 0.2.3 it failed with
11
+ `uninitialized constant ActiveModel`.
12
+
3
13
  ## 0.3.0 (2026-11-15)
4
14
 
5
15
  ### Notes
data/README.md CHANGED
@@ -54,6 +54,10 @@ Ask your agent to do your Tensaku notes, and it works through the open ones. Ask
54
54
 
55
55
  The agent marks a note `working`, asks a question back, declines it, or resolves it with a reply. Each change shows on the note's pin. A green pin means the change is ready for you to check.
56
56
 
57
+ ## Use it from a phone
58
+
59
+ Tensaku answers only requests from your computer, with one exception: a device paired with [Parcela](https://parcela.run) and reached through Parcela's proxy. Parcela gives the server a secret in `PARCELA_PROXY_SECRET`, removes any `Parcela-Device-Secret` header a client sends, and sets it to that secret only on a paired device's request. Tensaku trusts a request from loopback that carries the matching secret. The page's Host must still be a local name or one in `config.hosts`, and anything that reads source or writes still needs the boot token Tensaku puts in the page. No other proxy is trusted.
60
+
57
61
  ## Documentation
58
62
 
59
63
  The documentation site is [tensaku.lostcoords.com](https://tensaku.lostcoords.com). Its pages are Markdown files in `docs/app/views/pages/`.
@@ -202,7 +202,7 @@ module Tensaku
202
202
  end
203
203
 
204
204
  def script(request)
205
- raise Forbidden, "Tensaku only answers requests from this machine" unless Guard.loopback?(request)
205
+ raise Forbidden, "Tensaku only answers requests from this machine or a device paired with Parcela" unless Guard.local_client?(request)
206
206
 
207
207
  [ 200, { "content-type" => "text/javascript; charset=utf-8", "cache-control" => "no-cache" }, [ File.read(ASSET) ] ]
208
208
  end
data/lib/tensaku/guard.rb CHANGED
@@ -7,14 +7,23 @@ module Tensaku
7
7
  # "From this machine" means a loopback peer address, no proxy header naming another client, a Host
8
8
  # that is a local name (or one the app lists in config.hosts), and no Origin from another site. The
9
9
  # Host check stops DNS rebinding: a page on another domain that resolves to 127.0.0.1.
10
+ #
11
+ # One proxy is trusted to forward other clients: Parcela, for devices paired with it. Its proxy
12
+ # connects from loopback, strips client-sent Parcela-Device headers, and on a paired device's request
13
+ # sends Parcela-Device-Secret equal to the PARCELA_PROXY_SECRET it gave this process.
10
14
  module Guard
11
15
  LOOPBACK = [ IPAddr.new("127.0.0.0/8"), IPAddr.new("::1/128") ].freeze
12
16
  FORWARDED = %w[HTTP_X_FORWARDED_FOR HTTP_X_REAL_IP HTTP_FORWARDED HTTP_CLIENT_IP HTTP_TRUE_CLIENT_IP HTTP_CF_CONNECTING_IP].freeze
13
17
 
14
18
  module_function
15
19
 
16
- def loopback?(request)
17
- loopback_address?(request.get_header("REMOTE_ADDR")) && !forwarded_from_elsewhere?(request)
20
+ def local_client?(request)
21
+ loopback_address?(request.get_header("REMOTE_ADDR")) && (!forwarded_from_elsewhere?(request) || parcela_device?(request))
22
+ end
23
+
24
+ def parcela_device?(request)
25
+ secret = ENV["PARCELA_PROXY_SECRET"].to_s
26
+ !secret.empty? && secure_compare(request.get_header("HTTP_PARCELA_DEVICE_SECRET").to_s, secret)
18
27
  end
19
28
 
20
29
  # Whether the request came from this machine and from a page of this app, not another site.
@@ -34,7 +43,7 @@ module Tensaku
34
43
 
35
44
  # Every endpoint but the script adds the token on top of this.
36
45
  def check_local_client!(request)
37
- raise Forbidden, "Tensaku only answers requests from this machine" unless loopback?(request)
46
+ raise Forbidden, "Tensaku only answers requests from this machine or a device paired with Parcela" unless local_client?(request)
38
47
 
39
48
  origin = request.get_header("HTTP_ORIGIN")
40
49
  raise Forbidden, "Cross-origin requests are refused" if origin && !local_url?(origin)
@@ -45,7 +45,10 @@ module Tensaku
45
45
 
46
46
  config.after_initialize do
47
47
  I18n.backend.extend(Tensaku::I18nMarkers::Backend) unless I18n.backend.is_a?(Tensaku::I18nMarkers::Backend)
48
- [ ActiveModel::Type::ImmutableString, ActiveModel::Type::String ].each { it.prepend(Tensaku::I18nMarkers::ModelStrings) }
48
+ # An app without Active Model, such as one that loads only Action Controller, has no model strings.
49
+ if defined?(ActiveModel::Type::String)
50
+ [ ActiveModel::Type::ImmutableString, ActiveModel::Type::String ].each { it.prepend(Tensaku::I18nMarkers::ModelStrings) }
51
+ end
49
52
 
50
53
  if (warning = Tensaku::Caches.fragment_cache_warning)
51
54
  Rails.logger.warn("[Tensaku] #{warning}")
@@ -1,3 +1,3 @@
1
1
  module Tensaku
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tensaku
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Afonso