terminalwire 0.1.3 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/terminalwire +2 -0
- data/lib/terminalwire/client/entitlement.rb +67 -31
- data/lib/terminalwire/client.rb +2 -2
- data/lib/terminalwire/thor.rb +4 -0
- data/lib/terminalwire/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 75925c367154b311709c4fbf293db71d7ba656261f6da2fe7b3da985e1aa8d4f
|
4
|
+
data.tar.gz: e6516a019131634d16b3742453528a2a90decfaeef4e276af8546d60bae1174d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b072aad864cecc96c70a4381e880b778bdd0178490a2bd81f9ae7805eea5f29fb9e4b913fb17973a26d99a177be3f1a46fae038a4f89af66af60c4e7be01548
|
7
|
+
data.tar.gz: f2e34e0ec2c7217b751d7cd4abf83f0a2c0bcb0cec3590d5bb8de4e3a1145e1be9c0b30d7a116108c6f4837bdf45e7c5161466b74e43ef552e0b44660ee8d622
|
data/exe/terminalwire
ADDED
@@ -1,5 +1,5 @@
|
|
1
1
|
module Terminalwire::Client
|
2
|
-
|
2
|
+
module Entitlement
|
3
3
|
class Paths
|
4
4
|
include Enumerable
|
5
5
|
|
@@ -55,53 +55,89 @@ module Terminalwire::Client
|
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
|
-
|
58
|
+
class Policy
|
59
|
+
attr_reader :paths, :authority, :schemes
|
59
60
|
|
60
|
-
|
61
|
-
@authority = authority
|
62
|
-
@paths = Paths.new
|
61
|
+
ROOT_PATH = "~/.terminalwire".freeze
|
63
62
|
|
64
|
-
|
65
|
-
|
66
|
-
|
63
|
+
def initialize(authority:)
|
64
|
+
@authority = authority
|
65
|
+
@paths = Paths.new
|
67
66
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
@schemes.permit "https"
|
72
|
-
end
|
67
|
+
# Permit the domain directory. This is necessary for basic operation of the client.
|
68
|
+
@paths.permit storage_path
|
69
|
+
@paths.permit storage_pattern
|
73
70
|
|
74
|
-
|
75
|
-
|
76
|
-
|
71
|
+
@schemes = Schemes.new
|
72
|
+
# Permit http & https by default.
|
73
|
+
@schemes.permit "http"
|
74
|
+
@schemes.permit "https"
|
75
|
+
end
|
77
76
|
|
78
|
-
|
79
|
-
|
80
|
-
|
77
|
+
def root_path
|
78
|
+
Pathname.new(ROOT_PATH)
|
79
|
+
end
|
80
|
+
|
81
|
+
def authority_path
|
82
|
+
root_path.join("authorities/#{authority}")
|
83
|
+
end
|
84
|
+
|
85
|
+
def storage_path
|
86
|
+
authority_path.join("storage")
|
87
|
+
end
|
81
88
|
|
82
|
-
|
83
|
-
|
89
|
+
def storage_pattern
|
90
|
+
storage_path.join("**/*")
|
91
|
+
end
|
92
|
+
|
93
|
+
def serialize
|
94
|
+
{
|
95
|
+
authority: @authority,
|
96
|
+
schemes: @schemes.serialize,
|
97
|
+
paths: @paths.serialize,
|
98
|
+
storage_path: storage_path.to_s,
|
99
|
+
}
|
100
|
+
end
|
84
101
|
end
|
85
102
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
103
|
+
class RootPolicy < Policy
|
104
|
+
HOST = "terminalwire.com".freeze
|
105
|
+
|
106
|
+
def initialize(*, **, &)
|
107
|
+
# Make damn sure the authority is set to Terminalwire.
|
108
|
+
super(*, authority: HOST, **, &)
|
109
|
+
|
110
|
+
# Now setup special permitted paths.
|
111
|
+
@paths.permit root_path
|
112
|
+
@paths.permit root_pattern
|
113
|
+
end
|
114
|
+
|
115
|
+
# Grant access to the `~/.terminalwire/**/*` path so users can install
|
116
|
+
# terminalwire apps via `terminalwire install svbtle`, etc.
|
117
|
+
def root_pattern
|
118
|
+
root_path.join("**/*")
|
119
|
+
end
|
93
120
|
end
|
94
121
|
|
95
122
|
def self.from_url(url)
|
123
|
+
url = URI(url)
|
124
|
+
|
125
|
+
case url.host
|
126
|
+
when RootPolicy::HOST
|
127
|
+
RootPolicy.new
|
128
|
+
else
|
129
|
+
Policy.new authority: url_authority(url)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
def self.url_authority(url)
|
96
134
|
# I had to lift this from URI::HTTP because `ws://` doesn't
|
97
135
|
# have an authority method.
|
98
|
-
|
136
|
+
if url.port == url.default_port
|
99
137
|
url.host
|
100
138
|
else
|
101
139
|
"#{url.host}:#{url.port}"
|
102
140
|
end
|
103
|
-
|
104
|
-
new authority:
|
105
141
|
end
|
106
142
|
end
|
107
143
|
end
|
data/lib/terminalwire/client.rb
CHANGED
@@ -73,7 +73,7 @@ module Terminalwire
|
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
76
|
-
def self.websocket(url:, arguments: ARGV)
|
76
|
+
def self.websocket(url:, arguments: ARGV, entitlement: nil)
|
77
77
|
url = URI(url)
|
78
78
|
|
79
79
|
Async do |task|
|
@@ -85,7 +85,7 @@ module Terminalwire
|
|
85
85
|
Async::WebSocket::Client.connect(endpoint) do |adapter|
|
86
86
|
transport = Terminalwire::Transport::WebSocket.new(adapter)
|
87
87
|
adapter = Terminalwire::Adapter.new(transport)
|
88
|
-
entitlement
|
88
|
+
entitlement ||= Entitlement.from_url(url)
|
89
89
|
Terminalwire::Client::Handler.new(adapter, arguments:, entitlement:).connect
|
90
90
|
end
|
91
91
|
end
|
data/lib/terminalwire/thor.rb
CHANGED
data/lib/terminalwire/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: terminalwire
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brad Gessler
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-09-
|
11
|
+
date: 2024-09-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: async-websocket
|
@@ -140,6 +140,7 @@ description: Stream command-line apps from your server without a web API
|
|
140
140
|
email:
|
141
141
|
- brad@terminalwire.com
|
142
142
|
executables:
|
143
|
+
- terminalwire
|
143
144
|
- terminalwire-exec
|
144
145
|
extensions: []
|
145
146
|
extra_rdoc_files: []
|
@@ -151,6 +152,7 @@ files:
|
|
151
152
|
- README.md
|
152
153
|
- Rakefile
|
153
154
|
- examples/exec/localrails
|
155
|
+
- exe/terminalwire
|
154
156
|
- exe/terminalwire-exec
|
155
157
|
- lib/generators/terminalwire/install/USAGE
|
156
158
|
- lib/generators/terminalwire/install/install_generator.rb
|
@@ -192,7 +194,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
192
194
|
- !ruby/object:Gem::Version
|
193
195
|
version: '0'
|
194
196
|
requirements: []
|
195
|
-
rubygems_version: 3.5.
|
197
|
+
rubygems_version: 3.5.3
|
196
198
|
signing_key:
|
197
199
|
specification_version: 4
|
198
200
|
summary: Ship a CLI for your web app. No API required.
|