seekrit-sdk 0.6.0 → 0.8.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 +3 -4
- data/lib/seekrit/client.rb +3 -3
- data/lib/seekrit/crypto.rb +36 -4
- data/lib/seekrit/post_quantum.rb +29 -0
- data/lib/seekrit/resolve.wasm +0 -0
- data/lib/seekrit/version.rb +1 -1
- data/testdata/ml-kem-1024.json +80 -0
- data/testdata/vectors.json +173 -1
- metadata +27 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f523104d2f075aeb346e5cdadc7e8b6cc1330770a2eb98b04f0a03b027e24690
|
|
4
|
+
data.tar.gz: e23c513743140892cffdfff07a55c49cd54a59cc26c31fc48a3f6f789857cb9f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bd398f92565b7ea9840fcaddcf31fadb4878a635c168402e4540e5bb57be6398df61cd727a884326eb6b54803d379d9cd2dd9a354da92b97e290f342ad565ce1
|
|
7
|
+
data.tar.gz: b0674a8572ddc23daf0cc42dcd714275393d83e1d7e16809142f139f66aa01f5bd069df5bcf81ee7730624b083e88b694d3e666b22282525899af17f85b4277a
|
data/README.md
CHANGED
|
@@ -21,8 +21,7 @@ Or in a Gemfile:
|
|
|
21
21
|
gem "seekrit-sdk"
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
-
Requires Ruby 3.0+.
|
|
25
|
-
library (`openssl`, `net/http`, `json`).
|
|
24
|
+
Requires Ruby 3.0+. Wasmtime unwraps upgraded environment keys in process. Ruby's OpenSSL library decrypts the secret values in every environment.
|
|
26
25
|
|
|
27
26
|
## Usage
|
|
28
27
|
|
|
@@ -100,7 +99,7 @@ client = Seekrit::Client.new(interpolate: false) # get the stored text instead
|
|
|
100
99
|
|
|
101
100
|
`GET /v1/resolve` returns ciphertext plus a data-encryption key wrapped to your
|
|
102
101
|
token's public key. This SDK recovers the token's private key, unwraps the DEK
|
|
103
|
-
(
|
|
102
|
+
(ML-KEM-1024 HPKE for upgraded environments, P-256 for legacy layers), and decrypts each secret
|
|
104
103
|
(AES-256-GCM, AAD-bound to `environmentId/NAME`) — the exact scheme used by the
|
|
105
104
|
CLI, `seekrit run`, and every other seekrit client. See
|
|
106
105
|
[seekrit.dev/docs](https://seekrit.dev/docs/concepts/encryption).
|
|
@@ -112,7 +111,7 @@ MIT
|
|
|
112
111
|
## Service token v2
|
|
113
112
|
|
|
114
113
|
Keep one `SEEKRIT_TOKEN`: `skt_<id>_v2.<auth-secret>.<private-key>`.
|
|
115
|
-
The client sends only `skt_<id>_v2.<auth-secret>` to the API and uses the private
|
|
114
|
+
An upgraded v3 bundle adds a local ML-KEM-1024 seed to the same `SEEKRIT_TOKEN`. A single resolve can combine upgraded and legacy layers. The client sends only `skt_<id>_v2.<auth-secret>` to the API and uses the private
|
|
116
115
|
key locally to decrypt. Legacy tokens are rejected before any API request;
|
|
117
116
|
upgrade clients and replace legacy tokens through the dashboard. A stolen
|
|
118
117
|
HTTP credential cannot decrypt environment payloads, but stealing the full
|
data/lib/seekrit/client.rb
CHANGED
|
@@ -62,9 +62,9 @@ module Seekrit
|
|
|
62
62
|
|
|
63
63
|
def fetch
|
|
64
64
|
uri = URI("#{@api_url}/v1/resolve")
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
params = @with.sort.map { |group, env| ["with", "#{group}:#{env}"] }
|
|
66
|
+
params << ["grants", "ml-kem-1024"] if @key.upgraded?
|
|
67
|
+
uri.query = URI.encode_www_form(params) unless params.empty?
|
|
68
68
|
|
|
69
69
|
request = Net::HTTP::Get.new(uri)
|
|
70
70
|
request["authorization"] = "Bearer #{@token}"
|
data/lib/seekrit/crypto.rb
CHANGED
|
@@ -23,9 +23,14 @@ module Seekrit
|
|
|
23
23
|
# Only the first two underscores are separators; the key segment may contain "_".
|
|
24
24
|
TOKEN_RE = /\A(skt_[0-9A-Za-z]+)_(?:v2\.[A-Za-z0-9_-]{43}\.)?([A-Za-z0-9_-]+)\z/.freeze
|
|
25
25
|
|
|
26
|
+
UPGRADED = /\A(skt_[0-9A-Za-z]+)_v3\.([A-Za-z0-9_-]{43})\.([A-Za-z0-9_-]+)\.([A-Za-z0-9_-]{85}[AQgw])\z/.freeze
|
|
27
|
+
|
|
26
28
|
module_function
|
|
27
29
|
|
|
28
30
|
def service_token_auth(token)
|
|
31
|
+
upgraded = UPGRADED.match(token)
|
|
32
|
+
return "#{upgraded[1]}_v2.#{upgraded[2]}" if upgraded
|
|
33
|
+
|
|
29
34
|
match = /\A(skt_[0-9A-Za-z]+_v2\.[A-Za-z0-9_-]{43})(?:\.[A-Za-z0-9_-]+)?\z/.match(token)
|
|
30
35
|
raise CryptoError, "a v2 service token is required for API access; replace legacy tokens in the dashboard" unless match
|
|
31
36
|
|
|
@@ -88,12 +93,31 @@ module Seekrit
|
|
|
88
93
|
class TokenKey
|
|
89
94
|
attr_reader :token_id
|
|
90
95
|
|
|
91
|
-
def initialize(token_id, ec_key)
|
|
96
|
+
def initialize(token_id, ec_key, seed = nil)
|
|
97
|
+
@seed = seed
|
|
92
98
|
@token_id = token_id
|
|
93
99
|
@ec_key = ec_key
|
|
94
100
|
end
|
|
95
101
|
|
|
102
|
+
def upgraded?
|
|
103
|
+
!@seed.nil?
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def inspect
|
|
107
|
+
"#<Seekrit::TokenKey #{@token_id}>"
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def unwrap_grants(org_id, grants)
|
|
111
|
+
return [] if grants.empty?
|
|
112
|
+
raise CryptoError, "an upgraded service token is required for this grant" unless upgraded?
|
|
113
|
+
|
|
114
|
+
require_relative "post_quantum"
|
|
115
|
+
PostQuantum.unwrap_grants(@token_id, @seed, org_id, grants)
|
|
116
|
+
end
|
|
117
|
+
|
|
96
118
|
def self.parse(token)
|
|
119
|
+
upgraded = Crypto::UPGRADED.match(token)
|
|
120
|
+
token = "#{upgraded[1]}_v2.#{upgraded[2]}.#{upgraded[3]}" if upgraded
|
|
97
121
|
match = Crypto::TOKEN_RE.match(token)
|
|
98
122
|
raise CryptoError, "not a valid seekrit service token" unless match
|
|
99
123
|
|
|
@@ -110,7 +134,7 @@ module Seekrit
|
|
|
110
134
|
raise CryptoError, "service token private key is corrupted"
|
|
111
135
|
end
|
|
112
136
|
end
|
|
113
|
-
new(match[1], ec_key)
|
|
137
|
+
new(match[1], ec_key, upgraded && upgraded[4])
|
|
114
138
|
end
|
|
115
139
|
|
|
116
140
|
# Recover a 32-byte environment DEK from a wd1. blob.
|
|
@@ -158,9 +182,17 @@ module Seekrit
|
|
|
158
182
|
# reference sees whichever layer won the name). Pass interpolate: false to
|
|
159
183
|
# get the stored text instead.
|
|
160
184
|
def materialize(resolve_response, key, interpolate: true)
|
|
185
|
+
layers = resolve_response.fetch("layers")
|
|
186
|
+
grants = layers.reject { |layer| layer.fetch("keyGeneration", "legacy") == "legacy" }
|
|
187
|
+
upgraded_keys = key.unwrap_grants(resolve_response.dig("scope", "orgId"), grants).each
|
|
161
188
|
merged = {}
|
|
162
|
-
|
|
163
|
-
dek =
|
|
189
|
+
layers.each do |layer|
|
|
190
|
+
dek = if layer.fetch("keyGeneration", "legacy") == "legacy"
|
|
191
|
+
raise CryptoError, "invalid legacy grant recipient" unless layer["recipient"].nil?
|
|
192
|
+
key.unwrap_dek(layer["wrappedDek"])
|
|
193
|
+
else
|
|
194
|
+
upgraded_keys.next
|
|
195
|
+
end
|
|
164
196
|
env_id = layer["environmentId"]
|
|
165
197
|
layer["secrets"].each do |secret|
|
|
166
198
|
merged[secret["name"]] = decrypt_secret(dek, secret["ciphertext"], secret_aad(env_id, secret["name"]))
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "json"
|
|
4
|
+
require "wasmtime"
|
|
5
|
+
|
|
6
|
+
module Seekrit
|
|
7
|
+
# Compile the bundled reader once. Every call gets private memory and no host imports.
|
|
8
|
+
module PostQuantum
|
|
9
|
+
ENGINE = Wasmtime::Engine.new
|
|
10
|
+
READER = Wasmtime::Module.from_file(ENGINE, File.join(__dir__, "resolve.wasm"))
|
|
11
|
+
|
|
12
|
+
def self.unwrap_grants(token_id, seed, org_id, layers)
|
|
13
|
+
grants = layers.map { |layer| layer.slice("environmentId", "keyGeneration", "recipient", "wrappedDek") }
|
|
14
|
+
payload = JSON.generate(tokenId: token_id, seed: seed, orgId: org_id, grants: grants)
|
|
15
|
+
instance = Wasmtime::Instance.new(Wasmtime::Store.new(ENGINE), READER, [])
|
|
16
|
+
memory = instance.export("memory").to_memory
|
|
17
|
+
memory.write(instance.invoke("seekrit_prepare", payload.bytesize), payload)
|
|
18
|
+
length = instance.invoke("seekrit_unwrap_grants")
|
|
19
|
+
raise CryptoError, "environment grant authentication failed" unless length == grants.size * 32
|
|
20
|
+
|
|
21
|
+
ptr = instance.invoke("seekrit_output")
|
|
22
|
+
keys = Array.new(grants.size) { |index| memory.read(ptr + index * 32, 32) }
|
|
23
|
+
instance.invoke("seekrit_prepare", 0)
|
|
24
|
+
keys
|
|
25
|
+
rescue Wasmtime::Error
|
|
26
|
+
raise CryptoError, "could not unwrap environment keys"
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
Binary file
|
data/lib/seekrit/version.rb
CHANGED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
{
|
|
2
|
+
"token": "skt_6EYgmoh8LuiPPAbM0SaVtc_v3.bh8OFkiEBdTJM4MBX75AMCPsR2Arp1i32sg8Ej0Vw7o.MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgra6e_i8D2dIWlz-43EVbrHz-g698-kxY22MCp95L7VGhRANCAATA4nkyQKLq4hD5YvzXLtNtKAK_g-H4LF260zk0bInSWMbDfx0vTTtOg0tRWoDYWbuIN0vb1YMZ5z13xH5aBsDx.k3G9BIApWaEN4VzuVIsMJoa_lWTcXx0Yl7tMoK_-TsEXdE1yKPYqys3D6uXh8qYNFBUaWbMIRpOHWL9qSXOAog",
|
|
3
|
+
"resolve": {
|
|
4
|
+
"scope": {
|
|
5
|
+
"orgId": "org_test",
|
|
6
|
+
"orgSlug": "acme",
|
|
7
|
+
"appId": "app_test",
|
|
8
|
+
"appSlug": "web",
|
|
9
|
+
"envId": "env_testbranch",
|
|
10
|
+
"envSlug": "preview"
|
|
11
|
+
},
|
|
12
|
+
"layers": [
|
|
13
|
+
{
|
|
14
|
+
"source": "group",
|
|
15
|
+
"environmentId": "env_grouptest0000000001",
|
|
16
|
+
"slug": "production",
|
|
17
|
+
"groupSlug": "shared",
|
|
18
|
+
"wrappedDek": "wd1.BGAAVA2nxO1UzcRZA_7ubZ9nLAGSf_Fc_6y07AHlv4N_q8dhQ0z4dwMHqUUaKPkkSnH8rnWkjnitlKHRmuIvoz8.dJ0ALJ9Wejh6nYiKM3adOA.VFgZWwqtT_ly6gP4.RIcWNi6id_QO9NtmCU4iFUEX9U9fUlqn2UNgmkgunpU_eVnKgMf6q8ui1PxcEBiw",
|
|
19
|
+
"secrets": [
|
|
20
|
+
{
|
|
21
|
+
"name": "SHARED",
|
|
22
|
+
"ciphertext": "sc1.oIjnQEJskdJ_nweV.MGETgRWPDkwhHm9e_jp567-b19Fn8DJohrU"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"name": "DATABASE_URL",
|
|
26
|
+
"ciphertext": "sc1.Fo69NaVLlUDFtGsk.tr8o0e7mMSB7DWkfZuv0eLOsNq7Fm-3dd2zOiPSXSHiwXbg"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"name": "UNICODE",
|
|
30
|
+
"ciphertext": "sc1.hu_o1qPHzmeJrT0q.5jIWUj9fTvGXjyeSyhtOMdvlWRenXqNy9F2uYg3XVgui0CYmdA"
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"source": "app",
|
|
36
|
+
"environmentId": "env_apptest0000000000001",
|
|
37
|
+
"slug": "production",
|
|
38
|
+
"keyGeneration": "32859618-8349-47ad-b9d5-57a175189d68",
|
|
39
|
+
"recipient": {
|
|
40
|
+
"principalType": "service_token",
|
|
41
|
+
"principalId": "skt_6EYgmoh8LuiPPAbM0SaVtc"
|
|
42
|
+
},
|
|
43
|
+
"wrappedDek": "wd3.eyeLAxBctpXxJV5qeoQ77_dsofVdEOuK8BoOcoAj_DyULMGYWjNlxXYo4fvYJBDOt6yYiI8ilwqoaPjnKAzKivBoUWB3nc9WS6skY8DQS4rnKcLb_wlIRx7tAo5bh0GWcxM6IhynAcG45JvhKsLaBK58M08us9WoU-sOYS07VE3grpxrrGAmg5DD9jifItcEzWzO2mViEfEiTG5WHXZs7EcV4Ll4DuQ-phzcuJOjeCcS7eOhVFlJNFeI2J70k5TmrNJl4QuvL4Kvit7mhiV7vHPW-ZXR07mreg3pB6hAM7ikSo_VKi7Q4hhYuo9d7yQLKCL9vZRkQFMEnrvY8uibIxQ-JMBH376fvVF_N1nCwAy8Sz6ykUSY0BWsv4DZexm8cIm_1Le-dPli2JaXcc_ZXF0Q_vsDRCihgzgNKZ3Lr16H_n1BA0pUTKSGTrwmQL167UpLRkIm0UFSC4wX4Lq1a1CWrJW9RKN2vJPl1gk-MD_lBhTxw31vuT9H2JMEg_ZB2hiVrHTo8H9Kb1ttvtoclka4BRPjUvX59SN0RB7PUiLVudrxBROoUDP6IGBVMTvfyECJHBgOQoxooyuVmiz_vCt88EmyGr8mhpl3CTr-2ytYaGOF3Z03B8Y0IoxqFHGlqaQduW-JwGLw7nrlxHofA5w6gasvhPz2smLaZ_HEuYeiqXxRS195-UHuagb4ZXzubu8Uym4OoTgA_RNMDwlvi6-HMaaspTMzMJXIzx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37tT1CYpvd7oiTxZehRBqOM9lMN_gETTIdwsen5rb9E1595L3ZHypsli7U32lZjJRag9uMK03tQaL7MsMSpxqWb9ASTWXjQPdHHiAWG-gFgs0CxaoZ5epk4wRyX0HRE4N04ALhAexXfsgpLZoSX7gKTGErq0UY3nx_AQBfcUCLbdGLLdb0z3BCeI1FkqVDv_9f3Vfx9_24WBQ1cOkp1fKMgGNnwQpaVz40Ny7XLKjxsYTGcRjq0NZUmlt0pa8wA6qLsGhsMOs.WvI55qbAENTtweAFiObhI2-itbmErz2-TaHfn46uwHBxJusqUQPTA36fbuY6ZSH_",
|
|
44
|
+
"secrets": [
|
|
45
|
+
{
|
|
46
|
+
"name": "SHARED",
|
|
47
|
+
"ciphertext": "sc1.rYbCkwnBZyWl_NV5.5sD3--Ju_7lC7f7XyOWohyIn9_n7DRdlDoI47xKw"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"name": "RESULT",
|
|
51
|
+
"ciphertext": "sc1.fAgTVBxzg3C69sLJ.jbmDH56ptN9i3aIJn1DW7YMZNTiBTv_oYks3n-beNJXMUppHie_2d5Q"
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"source": "branch",
|
|
57
|
+
"environmentId": "env_testbranch",
|
|
58
|
+
"slug": "preview",
|
|
59
|
+
"keyGeneration": "f9802590-23ef-4ef5-b438-a25a6c7bda6b",
|
|
60
|
+
"recipient": {
|
|
61
|
+
"principalType": "service_token",
|
|
62
|
+
"principalId": "skt_6EYgmoh8LuiPPAbM0SaVtc"
|
|
63
|
+
},
|
|
64
|
+
"wrappedDek": "wd3.ae4BaD_DpGP5iLSiX9UJOKduZYM6alQnctWIIGNyctqNo8TljasCTqEblimuHbKzx9H0qKsDD7Qk-iuaNDNpQG73dLedfXplVm705GcldTfv9eOgcbIP9Tk8NyGwdLxw4Jcfzy9Qh2qh7b_pkPCJRjqtsRPJRpwgMNnlGQ3_ZAtAhvEpIzeZS1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
|
|
72
|
+
]
|
|
73
|
+
},
|
|
74
|
+
"cache": {
|
|
75
|
+
"apiUrl": "https://interop.seekrit.invalid",
|
|
76
|
+
"key": "0ef1575c4401202b2bdcbc854fb42aacf289c923c2848831ff678e0650ba2dcd",
|
|
77
|
+
"tokenFingerprint": "a888a8da75d997f572dfb0c7032de1d1a4028b4a873869ea4751b4162bfcf29b",
|
|
78
|
+
"snapshotKey": "a5308029d1cd124fa039cf1b51ec7f40865f6312b550b6e82bed4670e1241ac4"
|
|
79
|
+
}
|
|
80
|
+
}
|
data/testdata/vectors.json
CHANGED
|
@@ -239,7 +239,7 @@
|
|
|
239
239
|
]
|
|
240
240
|
},
|
|
241
241
|
"substitution": {
|
|
242
|
-
"note": "Placeholder substitution over plaintext alone — no crypto involved. Every implementation of the engine (apps/proxy/src/substitute.rs and the fetch/httpx shims in the language SDKs) runs these, so the rules can never drift apart. The lookup each harness must install: a name in `denied` returns Denied, otherwise a name present in `values` returns that Value, otherwise Unknown. A case has either `expected` + `names`, or `error`.",
|
|
242
|
+
"note": "Placeholder substitution over plaintext alone — no crypto involved. Every implementation of the engine (apps/proxy/src/substitute.rs and the fetch/httpx shims in the language SDKs) runs these, so the rules can never drift apart. The lookup each harness must install: a name in `denied` returns Denied, otherwise a name present in `values` returns that Value, otherwise Unknown. A case has either `expected` + `names`, or `error`. A case with `header` is the value of that request header and runs through the header entry point (substitute_header / substituteHeader): an `Authorization` or `Proxy-Authorization` value (name compared case-insensitively) of the form `Basic <credentials>` — scheme case-insensitive, then one or more spaces, then canonical padded RFC 4648 base64 (standard alphabet, zero padding bits) that decodes to UTF-8 — has the decoded text substituted with the same lookup and re-encoded, keeping the scheme and spacing as sent. Any other value, including a Basic credential that fails one of those checks, is substituted as text exactly as a case without `header`.",
|
|
243
243
|
"cases": [
|
|
244
244
|
{
|
|
245
245
|
"name": "substitutes a placeholder and reports the name",
|
|
@@ -429,6 +429,178 @@
|
|
|
429
429
|
"names": [
|
|
430
430
|
"EMPTY"
|
|
431
431
|
]
|
|
432
|
+
},
|
|
433
|
+
{
|
|
434
|
+
"name": "a placeholder inside a Basic credential is decoded, substituted, and re-encoded",
|
|
435
|
+
"header": "authorization",
|
|
436
|
+
"input": "Basic eC1hY2Nlc3MtdG9rZW46e3tzZWVrcml0OkdJVEhVQl9UT0tFTn19",
|
|
437
|
+
"values": {
|
|
438
|
+
"GITHUB_TOKEN": "ghp_live"
|
|
439
|
+
},
|
|
440
|
+
"denied": [],
|
|
441
|
+
"expected": "Basic eC1hY2Nlc3MtdG9rZW46Z2hwX2xpdmU=",
|
|
442
|
+
"names": [
|
|
443
|
+
"GITHUB_TOKEN"
|
|
444
|
+
]
|
|
445
|
+
},
|
|
446
|
+
{
|
|
447
|
+
"name": "Proxy-Authorization carries a Basic credential too, re-encoded as UTF-8",
|
|
448
|
+
"header": "proxy-authorization",
|
|
449
|
+
"input": "Basic YWdlbnQ6e3tzZWVrcml0OlBST1hZX1BBU1NXT1JEfX0=",
|
|
450
|
+
"values": {
|
|
451
|
+
"PROXY_PASSWORD": "hünter2"
|
|
452
|
+
},
|
|
453
|
+
"denied": [],
|
|
454
|
+
"expected": "Basic YWdlbnQ6aMO8bnRlcjI=",
|
|
455
|
+
"names": [
|
|
456
|
+
"PROXY_PASSWORD"
|
|
457
|
+
]
|
|
458
|
+
},
|
|
459
|
+
{
|
|
460
|
+
"name": "the header name and the Basic scheme match case-insensitively",
|
|
461
|
+
"header": "Authorization",
|
|
462
|
+
"input": "bAsIc e3tzZWVrcml0OkdJVEhVQl9UT0tFTn19Ongtb2F1dGgtYmFzaWM=",
|
|
463
|
+
"values": {
|
|
464
|
+
"GITHUB_TOKEN": "ghp_live"
|
|
465
|
+
},
|
|
466
|
+
"denied": [],
|
|
467
|
+
"expected": "bAsIc Z2hwX2xpdmU6eC1vYXV0aC1iYXNpYw==",
|
|
468
|
+
"names": [
|
|
469
|
+
"GITHUB_TOKEN"
|
|
470
|
+
]
|
|
471
|
+
},
|
|
472
|
+
{
|
|
473
|
+
"name": "every placeholder in a Basic credential is injected, and the spaces after the scheme are kept",
|
|
474
|
+
"header": "authorization",
|
|
475
|
+
"input": "Basic e3tzZWVrcml0OkdIX1VTRVJ9fTp7e3NlZWtyaXQ6R0lUSFVCX1RPS0VOfX0=",
|
|
476
|
+
"values": {
|
|
477
|
+
"GH_USER": "octocat",
|
|
478
|
+
"GITHUB_TOKEN": "ghp_live"
|
|
479
|
+
},
|
|
480
|
+
"denied": [],
|
|
481
|
+
"expected": "Basic b2N0b2NhdDpnaHBfbGl2ZQ==",
|
|
482
|
+
"names": [
|
|
483
|
+
"GH_USER",
|
|
484
|
+
"GITHUB_TOKEN"
|
|
485
|
+
]
|
|
486
|
+
},
|
|
487
|
+
{
|
|
488
|
+
"name": "a denied name inside a Basic credential aborts the pass",
|
|
489
|
+
"header": "authorization",
|
|
490
|
+
"input": "Basic eC1hY2Nlc3MtdG9rZW46e3tzZWVrcml0OlNPTUVfT1RIRVJ9fQ==",
|
|
491
|
+
"values": {
|
|
492
|
+
"GITHUB_TOKEN": "ghp_live"
|
|
493
|
+
},
|
|
494
|
+
"denied": [
|
|
495
|
+
"SOME_OTHER"
|
|
496
|
+
],
|
|
497
|
+
"error": {
|
|
498
|
+
"code": "denied",
|
|
499
|
+
"name": "SOME_OTHER"
|
|
500
|
+
}
|
|
501
|
+
},
|
|
502
|
+
{
|
|
503
|
+
"name": "an unresolved name inside a Basic credential aborts the pass",
|
|
504
|
+
"header": "authorization",
|
|
505
|
+
"input": "Basic eC1hY2Nlc3MtdG9rZW46e3tzZWVrcml0Ok1JU1NJTkd9fQ==",
|
|
506
|
+
"values": {
|
|
507
|
+
"GITHUB_TOKEN": "ghp_live"
|
|
508
|
+
},
|
|
509
|
+
"denied": [],
|
|
510
|
+
"error": {
|
|
511
|
+
"code": "unresolved",
|
|
512
|
+
"name": "MISSING"
|
|
513
|
+
}
|
|
514
|
+
},
|
|
515
|
+
{
|
|
516
|
+
"name": "a Basic credential with no placeholder passes through byte-identical",
|
|
517
|
+
"header": "authorization",
|
|
518
|
+
"input": "Basic dXNlcjpwYXNz",
|
|
519
|
+
"values": {
|
|
520
|
+
"GITHUB_TOKEN": "ghp_live"
|
|
521
|
+
},
|
|
522
|
+
"denied": [],
|
|
523
|
+
"expected": "Basic dXNlcjpwYXNz",
|
|
524
|
+
"names": []
|
|
525
|
+
},
|
|
526
|
+
{
|
|
527
|
+
"name": "a placeholder standing in for the whole Basic credential is substituted as text",
|
|
528
|
+
"header": "authorization",
|
|
529
|
+
"input": "Basic {{seekrit:GITHUB_BASIC}}",
|
|
530
|
+
"values": {
|
|
531
|
+
"GITHUB_BASIC": "eC1hY2Nlc3MtdG9rZW46Z2hwX2xpdmU="
|
|
532
|
+
},
|
|
533
|
+
"denied": [],
|
|
534
|
+
"expected": "Basic eC1hY2Nlc3MtdG9rZW46Z2hwX2xpdmU=",
|
|
535
|
+
"names": [
|
|
536
|
+
"GITHUB_BASIC"
|
|
537
|
+
]
|
|
538
|
+
},
|
|
539
|
+
{
|
|
540
|
+
"name": "a scheme other than Basic is not decoded",
|
|
541
|
+
"header": "authorization",
|
|
542
|
+
"input": "Bearer e3tzZWVrcml0OkdJVEhVQl9UT0tFTn19",
|
|
543
|
+
"values": {
|
|
544
|
+
"GITHUB_TOKEN": "ghp_live"
|
|
545
|
+
},
|
|
546
|
+
"denied": [],
|
|
547
|
+
"expected": "Bearer e3tzZWVrcml0OkdJVEhVQl9UT0tFTn19",
|
|
548
|
+
"names": []
|
|
549
|
+
},
|
|
550
|
+
{
|
|
551
|
+
"name": "a Basic credential in any other header is not decoded",
|
|
552
|
+
"header": "x-upstream-authorization",
|
|
553
|
+
"input": "Basic eC1hY2Nlc3MtdG9rZW46e3tzZWVrcml0OkdJVEhVQl9UT0tFTn19",
|
|
554
|
+
"values": {
|
|
555
|
+
"GITHUB_TOKEN": "ghp_live"
|
|
556
|
+
},
|
|
557
|
+
"denied": [],
|
|
558
|
+
"expected": "Basic eC1hY2Nlc3MtdG9rZW46e3tzZWVrcml0OkdJVEhVQl9UT0tFTn19",
|
|
559
|
+
"names": []
|
|
560
|
+
},
|
|
561
|
+
{
|
|
562
|
+
"name": "unpadded base64 is not decoded",
|
|
563
|
+
"header": "authorization",
|
|
564
|
+
"input": "Basic eDp7e3NlZWtyaXQ6R0lUSFVCX1RPS0VOfX0",
|
|
565
|
+
"values": {
|
|
566
|
+
"GITHUB_TOKEN": "ghp_live"
|
|
567
|
+
},
|
|
568
|
+
"denied": [],
|
|
569
|
+
"expected": "Basic eDp7e3NlZWtyaXQ6R0lUSFVCX1RPS0VOfX0",
|
|
570
|
+
"names": []
|
|
571
|
+
},
|
|
572
|
+
{
|
|
573
|
+
"name": "base64 with non-zero padding bits is not decoded",
|
|
574
|
+
"header": "authorization",
|
|
575
|
+
"input": "Basic eDp7e3NlZWtyaXQ6R0lUSFVCX1RPS0VOfX1=",
|
|
576
|
+
"values": {
|
|
577
|
+
"GITHUB_TOKEN": "ghp_live"
|
|
578
|
+
},
|
|
579
|
+
"denied": [],
|
|
580
|
+
"expected": "Basic eDp7e3NlZWtyaXQ6R0lUSFVCX1RPS0VOfX1=",
|
|
581
|
+
"names": []
|
|
582
|
+
},
|
|
583
|
+
{
|
|
584
|
+
"name": "the base64url alphabet is not decoded",
|
|
585
|
+
"header": "authorization",
|
|
586
|
+
"input": "Basic Y2l-Ont7c2Vla3JpdDpHSVRIVUJfVE9LRU59fQ==",
|
|
587
|
+
"values": {
|
|
588
|
+
"GITHUB_TOKEN": "ghp_live"
|
|
589
|
+
},
|
|
590
|
+
"denied": [],
|
|
591
|
+
"expected": "Basic Y2l-Ont7c2Vla3JpdDpHSVRIVUJfVE9LRU59fQ==",
|
|
592
|
+
"names": []
|
|
593
|
+
},
|
|
594
|
+
{
|
|
595
|
+
"name": "a Basic credential that does not decode to UTF-8 is not decoded",
|
|
596
|
+
"header": "authorization",
|
|
597
|
+
"input": "Basic /zp7e3NlZWtyaXQ6R0lUSFVCX1RPS0VOfX0=",
|
|
598
|
+
"values": {
|
|
599
|
+
"GITHUB_TOKEN": "ghp_live"
|
|
600
|
+
},
|
|
601
|
+
"denied": [],
|
|
602
|
+
"expected": "Basic /zp7e3NlZWtyaXQ6R0lUSFVCX1RPS0VOfX0=",
|
|
603
|
+
"names": []
|
|
432
604
|
}
|
|
433
605
|
]
|
|
434
606
|
}
|
metadata
CHANGED
|
@@ -1,20 +1,40 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: seekrit-sdk
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.8.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- seekrit
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
12
|
-
dependencies:
|
|
11
|
+
date: 2026-12-05 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: wasmtime
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '14'
|
|
20
|
+
- - "<"
|
|
21
|
+
- !ruby/object:Gem::Version
|
|
22
|
+
version: '51'
|
|
23
|
+
type: :runtime
|
|
24
|
+
prerelease: false
|
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
26
|
+
requirements:
|
|
27
|
+
- - ">="
|
|
28
|
+
- !ruby/object:Gem::Version
|
|
29
|
+
version: '14'
|
|
30
|
+
- - "<"
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '51'
|
|
13
33
|
description: |
|
|
14
34
|
Read-path SDK for seekrit, the zero-knowledge secrets manager. Authenticate
|
|
15
35
|
with a service token, resolve your environment, and get decrypted secrets —
|
|
16
36
|
the API only ever returns ciphertext; decryption happens in your process.
|
|
17
|
-
|
|
37
|
+
Upgraded tokens use the bundled WebAssembly reader in-process. Optional Rails
|
|
18
38
|
integration included. Require as "seekrit" or "seekrit/sdk"; the module is
|
|
19
39
|
Seekrit.
|
|
20
40
|
email:
|
|
@@ -29,9 +49,12 @@ files:
|
|
|
29
49
|
- lib/seekrit/crypto.rb
|
|
30
50
|
- lib/seekrit/errors.rb
|
|
31
51
|
- lib/seekrit/interpolate.rb
|
|
52
|
+
- lib/seekrit/post_quantum.rb
|
|
32
53
|
- lib/seekrit/railtie.rb
|
|
54
|
+
- lib/seekrit/resolve.wasm
|
|
33
55
|
- lib/seekrit/sdk.rb
|
|
34
56
|
- lib/seekrit/version.rb
|
|
57
|
+
- testdata/ml-kem-1024.json
|
|
35
58
|
- testdata/vectors.json
|
|
36
59
|
homepage: https://seekrit.dev
|
|
37
60
|
licenses:
|