vallkey 0.1.0 → 0.2.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 +4 -4
- data/README.md +13 -7
- data/lib/vallkey/patch.rb +20 -17
- data/lib/vallkey/version.rb +1 -1
- metadata +6 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 58237aacff3a14626297ec257d52fc8e403ef687a3b982314650dee3d5fca384
|
|
4
|
+
data.tar.gz: bc697f3b2153a60f54e97de40032aa4e4115bf7c87e206cc09c67b6f972212da
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a9472118b607a55f00afecfb68197fa0ef7e3b60085067d9d30713bcb5f777527e61f520de0fc42c0ee33ef3e4c45b560a11eb0cf04fa1182680bd91612e58c9
|
|
7
|
+
data.tar.gz: c0123dfbe198a67423622690bd7589e8723f33f59cf5a5cfd43e76e11353e3bd45a31f8bfd2bef860ca01ad88e5f6d4c5135d815bf9d1158565f9c22f81b8a3d
|
data/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+

|
|
2
|
+
|
|
1
3
|
# vallkey (Ruby)
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
Route ghost-key requests through [Vallkey](https://vallkey.com) using the supported HTTP clients below. Requests that carry a ghost key go to Vallkey, which swaps in the real key under your rules. Every other request is left alone.
|
|
4
6
|
|
|
5
7
|
```sh
|
|
6
8
|
gem install vallkey
|
|
@@ -9,10 +11,14 @@ RUBYOPT=-rvallkey/auto bundle exec rails server
|
|
|
9
11
|
|
|
10
12
|
Using `bundle exec`? Add `gem "vallkey"` to your Gemfile too: Bundler only loads the gems it lists.
|
|
11
13
|
|
|
12
|
-
Covers Net::HTTP,
|
|
14
|
+
Covers Net::HTTP, used by SDKs configured for this transport (Stripe, OpenAI, Anthropic, AWS, and Twilio, Octokit and Slack through Faraday).
|
|
15
|
+
|
|
16
|
+
| Setting | What it does |
|
|
17
|
+
| ----------------- | ------------------------------------------------------ |
|
|
18
|
+
| `VALLKEY_API` | The Vallkey server (default `https://api.vallkey.com`) |
|
|
19
|
+
| `VALLKEY_AUTO=0` | Turns it off |
|
|
20
|
+
| `VALLKEY_DEBUG=1` | Logs each request sent to Vallkey (never the key) |
|
|
21
|
+
|
|
22
|
+
## Compatibility and security
|
|
13
23
|
|
|
14
|
-
|
|
15
|
-
|---|---|
|
|
16
|
-
| `VALLKEY_API` | The Vallkey server (default `https://api.vallkey.com`) |
|
|
17
|
-
| `VALLKEY_AUTO=0` | Turns it off |
|
|
18
|
-
| `VALLKEY_DEBUG=1` | Logs each request sent to Vallkey (never the key) |
|
|
24
|
+
Read the [transport boundaries](https://github.com/vallkeyhq/developer-tools/blob/main/docs/compatibility.md) and [security policy](../SECURITY.md). Local transport tests do not certify every SDK version or cloud deployment. Use a dedicated key and verify requests from the actual application after deployment.
|
data/lib/vallkey/patch.rb
CHANGED
|
@@ -1,19 +1,6 @@
|
|
|
1
|
-
#
|
|
2
|
-
#
|
|
3
|
-
#
|
|
4
|
-
#
|
|
5
|
-
# Covers Net::HTTP, which carries almost every Ruby SDK: on its own (Stripe, OpenAI,
|
|
6
|
-
# Anthropic, AWS), and under Faraday, HTTParty and rest-client (Twilio, Octokit, Slack).
|
|
7
|
-
# Net::HTTP is patched once the app loads it, never loaded from here: under Bundler,
|
|
8
|
-
# loading it before the app could pick another version than the app's Gemfile.lock.
|
|
9
|
-
#
|
|
10
|
-
# Each request sent to Vallkey says in x-vallkey-host which address it was for, and in
|
|
11
|
-
# x-vallkey-hook what sent it: this hook, Ruby's version, the platform and VALLKEY_ENV, so
|
|
12
|
-
# the dashboard can show each place a key is used. Never app names or secrets.
|
|
13
|
-
#
|
|
14
|
-
# VALLKEY_API the Vallkey server (default https://api.vallkey.com)
|
|
15
|
-
# VALLKEY_DEBUG=1 logs each request sent to Vallkey (never the key)
|
|
16
|
-
# VALLKEY_ENV a name for this place (production, staging...), shown in the dashboard
|
|
1
|
+
# Redirect recognized ghost credentials in Net::HTTP requests.
|
|
2
|
+
# Install after Net::HTTP loads so Bundler retains control of its version.
|
|
3
|
+
# See README.md for configuration and transport boundaries.
|
|
17
4
|
module Vallkey
|
|
18
5
|
module Patch
|
|
19
6
|
GHOST = /gk_[a-z]{2,20}_[A-Za-z0-9_-]{22}_[A-Za-z0-9_-]{43}/.freeze
|
|
@@ -150,6 +137,7 @@ module Vallkey
|
|
|
150
137
|
def request(req, body = nil, &block)
|
|
151
138
|
moved = Vallkey::Patch.installed && Vallkey::Patch.redirect?(self, req, body)
|
|
152
139
|
unless moved
|
|
140
|
+
Vallkey::Patch.tag(self, req, body) if Vallkey::Patch.installed
|
|
153
141
|
if @vallkey_deferred
|
|
154
142
|
@vallkey_deferred = false
|
|
155
143
|
connect
|
|
@@ -182,6 +170,7 @@ module Vallkey
|
|
|
182
170
|
|
|
183
171
|
class << self
|
|
184
172
|
def redirect?(http, req, body)
|
|
173
|
+
return false if ENV["VALLKEY_AUTO"] == "0" # a .env file loaded after start can turn it off
|
|
185
174
|
t = target
|
|
186
175
|
return false if http.address == t.host && http.port == t.port
|
|
187
176
|
headers = []
|
|
@@ -190,11 +179,25 @@ module Vallkey
|
|
|
190
179
|
scheme = http.use_ssl? ? "https" : "http"
|
|
191
180
|
default = http.use_ssl? ? 443 : 80
|
|
192
181
|
from = http.port == default ? http.address : "#{http.address}:#{http.port}"
|
|
193
|
-
log("#{scheme}://#{from}
|
|
182
|
+
log("#{scheme}://#{from}", "#{t.scheme}://#{t.host_with_port}")
|
|
194
183
|
[t, from]
|
|
195
184
|
rescue StandardError
|
|
196
185
|
false # anything unusual goes out as it was
|
|
197
186
|
end
|
|
187
|
+
|
|
188
|
+
# Already addressed to Vallkey by an SDK's address setting: say which app it is, so
|
|
189
|
+
# one app is one place on the dashboard however each SDK reaches Vallkey.
|
|
190
|
+
def tag(http, req, body)
|
|
191
|
+
return if ENV["VALLKEY_AUTO"] == "0"
|
|
192
|
+
t = target
|
|
193
|
+
return unless http.address == t.host && http.port == t.port
|
|
194
|
+
return if req[WHO_HEADER]
|
|
195
|
+
headers = []
|
|
196
|
+
req.each_header { |name, value| headers << [name, value] }
|
|
197
|
+
req[WHO_HEADER] = who if ghost?(req.path, headers, body || req.body)
|
|
198
|
+
rescue StandardError
|
|
199
|
+
nil # anything unusual goes out as it was
|
|
200
|
+
end
|
|
198
201
|
end
|
|
199
202
|
end
|
|
200
203
|
end
|
data/lib/vallkey/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: vallkey
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Vallkey
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
10
|
+
date: 2026-10-27 00:00:00.000000000 Z
|
|
11
11
|
dependencies: []
|
|
12
12
|
description: Requests that carry a Vallkey ghost key go to Vallkey; nothing else is
|
|
13
13
|
touched. Turn it on with RUBYOPT=-rvallkey/auto.
|
|
@@ -26,6 +26,8 @@ licenses:
|
|
|
26
26
|
- MIT
|
|
27
27
|
metadata:
|
|
28
28
|
documentation_uri: https://vallkey.com/docs/
|
|
29
|
+
source_code_uri: https://github.com/vallkeyhq/developer-tools/tree/main/ruby
|
|
30
|
+
bug_tracker_uri: https://github.com/vallkeyhq/developer-tools/issues
|
|
29
31
|
rubygems_mfa_required: 'true'
|
|
30
32
|
rdoc_options: []
|
|
31
33
|
require_paths:
|
|
@@ -41,7 +43,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
41
43
|
- !ruby/object:Gem::Version
|
|
42
44
|
version: '0'
|
|
43
45
|
requirements: []
|
|
44
|
-
rubygems_version:
|
|
46
|
+
rubygems_version: 3.6.9
|
|
45
47
|
specification_version: 4
|
|
46
|
-
summary:
|
|
48
|
+
summary: Vallkey runtime integration for Net::HTTP.
|
|
47
49
|
test_files: []
|