terminalwire 0.1.2 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/terminalwire/client/entitlement.rb +67 -31
- data/lib/terminalwire/client.rb +6 -3
- data/lib/terminalwire/thor.rb +4 -0
- data/lib/terminalwire/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1961141ea3c3667bbff1f44be8f95ce247128f9c41fe7c98b0f96bb4b1c5099e
|
4
|
+
data.tar.gz: e206f7d31c8632a5e25a9d8e2d5e4eb974927450c463abb7f474887d07b7c1a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 765fb306bb7c354511db2c0e6be9641c91d9207bbf2a97bcc6a0e67b039ab785061be38b0acc4ebea8a9784e43b3f211acefe9cda3200ed16dce1d14b95ce3f8
|
7
|
+
data.tar.gz: 3d2ebd1e83bdc9bd6fa742b2ebc496fc871ead16bf43a487c47d236ac18a863494542c0fcb5cbea6bf9c3f366fbffe5c374a49c054b96463d134912329c243a4
|
@@ -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,16 +73,19 @@ 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|
|
80
|
-
endpoint = Async::HTTP::Endpoint.parse(
|
80
|
+
endpoint = Async::HTTP::Endpoint.parse(
|
81
|
+
url,
|
82
|
+
alpn_protocols: Async::HTTP::Protocol::HTTP11.names
|
83
|
+
)
|
81
84
|
|
82
85
|
Async::WebSocket::Client.connect(endpoint) do |adapter|
|
83
86
|
transport = Terminalwire::Transport::WebSocket.new(adapter)
|
84
87
|
adapter = Terminalwire::Adapter.new(transport)
|
85
|
-
entitlement
|
88
|
+
entitlement ||= Entitlement.from_url(url)
|
86
89
|
Terminalwire::Client::Handler.new(adapter, arguments:, entitlement:).connect
|
87
90
|
end
|
88
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.4
|
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
|
@@ -192,7 +192,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
192
192
|
- !ruby/object:Gem::Version
|
193
193
|
version: '0'
|
194
194
|
requirements: []
|
195
|
-
rubygems_version: 3.5.
|
195
|
+
rubygems_version: 3.5.3
|
196
196
|
signing_key:
|
197
197
|
specification_version: 4
|
198
198
|
summary: Ship a CLI for your web app. No API required.
|