@voxgig/sdkgen 4.6.0 → 4.7.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.
- package/bin/voxgig-sdkgen +1 -1
- package/dist/cmp/Feature.js +5 -0
- package/dist/cmp/Feature.js.map +1 -1
- package/dist/cmp/TestControl.d.ts +4 -0
- package/dist/cmp/TestControl.js +51 -0
- package/dist/cmp/TestControl.js.map +1 -0
- package/dist/helpers/featureSource.d.ts +3 -1
- package/dist/helpers/featureSource.js +105 -0
- package/dist/helpers/featureSource.js.map +1 -1
- package/dist/sdkgen.d.ts +3 -2
- package/dist/sdkgen.js +9 -4
- package/dist/sdkgen.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utility.d.ts +2 -1
- package/dist/utility.js +52 -0
- package/dist/utility.js.map +1 -1
- package/model/sdkgen.aon +58 -0
- package/package.json +1 -1
- package/project/.sdk/model/feature/secrets.aon +82 -0
- package/project/.sdk/src/cmp/cpp/Main_cpp.ts +2 -1
- package/project/.sdk/src/cmp/cpp/Test_cpp.ts +5 -1
- package/project/.sdk/src/cmp/csharp/Main_csharp.ts +2 -1
- package/project/.sdk/src/cmp/csharp/TestDirect_csharp.ts +30 -6
- package/project/.sdk/src/cmp/csharp/TestEntity_csharp.ts +29 -5
- package/project/.sdk/src/cmp/csharp/Test_csharp.ts +5 -1
- package/project/.sdk/src/cmp/dart/Main_dart.ts +2 -1
- package/project/.sdk/src/cmp/dart/TestDirect_dart.ts +23 -6
- package/project/.sdk/src/cmp/dart/TestEntity_dart.ts +28 -7
- package/project/.sdk/src/cmp/dart/Test_dart.ts +5 -1
- package/project/.sdk/src/cmp/go/Main_go.ts +2 -1
- package/project/.sdk/src/cmp/go/Test_go.ts +5 -1
- package/project/.sdk/src/cmp/java/Main_java.ts +2 -1
- package/project/.sdk/src/cmp/java/Test_java.ts +5 -1
- package/project/.sdk/src/cmp/js/Main_js.ts +2 -1
- package/project/.sdk/src/cmp/js/TestDirect_js.ts +30 -5
- package/project/.sdk/src/cmp/js/TestEntity_js.ts +35 -5
- package/project/.sdk/src/cmp/js/Test_js.ts +5 -1
- package/project/.sdk/src/cmp/js/fragment/Direct.test.fragment.js +7 -1
- package/project/.sdk/src/cmp/js/fragment/Entity.test.fragment.js +7 -1
- package/project/.sdk/src/cmp/kotlin/Main_kotlin.ts +2 -1
- package/project/.sdk/src/cmp/kotlin/Test_kotlin.ts +5 -1
- package/project/.sdk/src/cmp/lua/Main_lua.ts +2 -1
- package/project/.sdk/src/cmp/lua/TestDirect_lua.ts +28 -4
- package/project/.sdk/src/cmp/lua/TestEntity_lua.ts +24 -4
- package/project/.sdk/src/cmp/lua/Test_lua.ts +5 -1
- package/project/.sdk/src/cmp/ocaml/Gitignore_ocaml.ts +1 -0
- package/project/.sdk/src/cmp/perl/Main_perl.ts +2 -1
- package/project/.sdk/src/cmp/perl/TestDirect_perl.ts +25 -4
- package/project/.sdk/src/cmp/perl/TestEntity_perl.ts +24 -4
- package/project/.sdk/src/cmp/perl/Test_perl.ts +5 -1
- package/project/.sdk/src/cmp/perl/utility_perl.ts +10 -0
- package/project/.sdk/src/cmp/php/Main_php.ts +2 -1
- package/project/.sdk/src/cmp/php/TestDirect_php.ts +24 -5
- package/project/.sdk/src/cmp/php/TestEntity_php.ts +28 -4
- package/project/.sdk/src/cmp/php/Test_php.ts +5 -1
- package/project/.sdk/src/cmp/py/Main_py.ts +2 -1
- package/project/.sdk/src/cmp/py/Test_py.ts +5 -1
- package/project/.sdk/src/cmp/rb/Main_rb.ts +2 -1
- package/project/.sdk/src/cmp/rb/TestDirect_rb.ts +24 -5
- package/project/.sdk/src/cmp/rb/TestEntity_rb.ts +24 -4
- package/project/.sdk/src/cmp/rb/Test_rb.ts +5 -1
- package/project/.sdk/src/cmp/rb/utility_rb.ts +3 -1
- package/project/.sdk/src/cmp/rust/Main_rust.ts +2 -1
- package/project/.sdk/src/cmp/rust/TestDirect_rust.ts +31 -4
- package/project/.sdk/src/cmp/rust/TestEntity_rust.ts +37 -4
- package/project/.sdk/src/cmp/rust/Test_rust.ts +5 -1
- package/project/.sdk/src/cmp/scala/Main_scala.ts +2 -1
- package/project/.sdk/src/cmp/scala/Test_scala.ts +5 -1
- package/project/.sdk/src/cmp/ts/Config_ts.ts +50 -8
- package/project/.sdk/src/cmp/ts/Main_ts.ts +10 -2
- package/project/.sdk/src/cmp/ts/TestDirect_ts.ts +10 -3
- package/project/.sdk/src/cmp/ts/TestEntity_ts.ts +11 -3
- package/project/.sdk/src/cmp/ts/Test_ts.ts +5 -1
- package/project/.sdk/tm/csharp/test/Runner.cs +45 -0
- package/project/.sdk/tm/dart/test/utility.dart +39 -0
- package/project/.sdk/tm/js/test/sdk-test-control.json +19 -0
- package/project/.sdk/tm/js/test/utility.js +91 -1
- package/project/.sdk/tm/lua/test/runner.lua +40 -0
- package/project/.sdk/tm/ocaml/test/harness.ml +14 -4
- package/project/.sdk/tm/perl/t/runner.pm +30 -0
- package/project/.sdk/tm/php/test/Runner.php +36 -0
- package/project/.sdk/tm/rb/test/runner.rb +25 -0
- package/project/.sdk/tm/rust/tests/common/mod.rs +32 -0
- package/project/.sdk/tm/rust/utility/make_options.rs +1 -1
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/Sekreto.ts +8 -2
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/Sigv4.ts +29 -5
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/index.ts +30 -21
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/provider/Registry.ts +90 -0
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/provider/addr.ts +48 -0
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/provider/aws.ts +219 -0
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/provider/azuresecrets.ts +144 -0
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/provider/boru.ts +113 -0
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/provider/doppler.ts +77 -0
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/provider/dotenv.ts +51 -0
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/provider/env.ts +31 -0
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/provider/file.ts +54 -0
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/provider/gcpsecrets.ts +118 -0
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/provider/hashicorp.ts +159 -0
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/provider/http.ts +66 -0
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/provider/infisical.ts +107 -0
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/provider/memory.ts +33 -0
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/provider/onepassword.ts +120 -0
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/provider/support.ts +176 -0
- package/project/.sdk/tm/ts/test/vendor/omni/Runner.ts +15 -13
- package/project/.sdk/tm/ts/test/vendor/omni/Util.ts +25 -19
- package/project/.sdk/tm/ts/test/vendor/omni/compat.ts +1 -1
- package/project/.sdk/tm/ts/test/vendor/omni/index.ts +1 -1
- package/project/.sdk/tm/zig/core/utility.zig +1 -1
- package/project/sdkgen-package.json +1 -1
- package/src/cmp/Feature.ts +5 -0
- package/src/cmp/TestControl.ts +64 -0
- package/src/helpers/featureSource.ts +130 -0
- package/src/sdkgen.ts +7 -0
- package/src/utility.ts +61 -0
- package/project/.sdk/tm/ts/src/feature/secrets/sekreto/Providers.ts +0 -1221
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
// VENDORED: @voxgig/sekreto 0.1.2 (typescript/src/provider/hashicorp.ts)
|
|
2
|
+
// Source: https://github.com/voxgig/sekreto @ 65009cb5758850db767785ab666e71895f86086b
|
|
3
|
+
// License: MIT (c) voxgig - see repository LICENSE. Do not edit: resync from upstream.
|
|
4
|
+
/* Copyright (c) 2025 Voxgig Ltd, MIT License */
|
|
5
|
+
|
|
6
|
+
import { ProviderSpec, Provider, SekretoError, checkname, nodemod, vaultref } from './support'
|
|
7
|
+
import { checkaddr } from './addr'
|
|
8
|
+
import { fetchjson } from './http'
|
|
9
|
+
|
|
10
|
+
export function hashicorpprovider(
|
|
11
|
+
addr: string,
|
|
12
|
+
token: string,
|
|
13
|
+
options?: {
|
|
14
|
+
mount?: string
|
|
15
|
+
kv?: number
|
|
16
|
+
vaultnamespace?: string
|
|
17
|
+
auth?: ProviderSpec['auth']
|
|
18
|
+
},
|
|
19
|
+
): Provider {
|
|
20
|
+
const opts = options || {}
|
|
21
|
+
const usemount = opts.mount || 'secret'
|
|
22
|
+
const kv = opts.kv || 2
|
|
23
|
+
|
|
24
|
+
// A version typo like kv: 3 must not quietly behave as v2 and turn
|
|
25
|
+
// its 404s into misses; there is nothing safe to assume it meant.
|
|
26
|
+
if (1 !== kv && 2 !== kv) {
|
|
27
|
+
throw new SekretoError('sekreto: hashicorp: unsupported kv version: ' + String(kv))
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// The working token: a configured token is kept forever, a logged-in
|
|
31
|
+
// token is renewed shortly before its lease runs out - a long-running
|
|
32
|
+
// process must not keep presenting a token the vault already expired.
|
|
33
|
+
let livetoken: string | undefined = '' === token ? undefined : token
|
|
34
|
+
let renewat = Infinity
|
|
35
|
+
|
|
36
|
+
const baseheaders = (): Record<string, string> => {
|
|
37
|
+
const headers: Record<string, string> = {}
|
|
38
|
+
if (opts.vaultnamespace) {
|
|
39
|
+
headers['X-Vault-Namespace'] = opts.vaultnamespace
|
|
40
|
+
}
|
|
41
|
+
return headers
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const login = async (): Promise<string> => {
|
|
45
|
+
const auth = opts.auth
|
|
46
|
+
if (!auth) {
|
|
47
|
+
throw new SekretoError('sekreto: hashicorp: no token and no auth method')
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const mount = auth.mount || auth.method
|
|
51
|
+
const url = addr.replace(/\/$/, '') + '/v1/auth/' + mount + '/login'
|
|
52
|
+
|
|
53
|
+
let body: any
|
|
54
|
+
if ('kubernetes' === auth.method) {
|
|
55
|
+
let jwt = auth.jwt
|
|
56
|
+
if (undefined === jwt) {
|
|
57
|
+
const file = auth.jwtfile || '/var/run/secrets/kubernetes.io/serviceaccount/token'
|
|
58
|
+
try {
|
|
59
|
+
const { readFileSync } = nodemod<typeof import('node:fs')>('node:fs')
|
|
60
|
+
jwt = readFileSync(file, 'utf8').trim()
|
|
61
|
+
} catch (err: any) {
|
|
62
|
+
throw new SekretoError('sekreto: hashicorp: cannot read jwt file ' + file)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
body = { role: auth.role || '', jwt }
|
|
66
|
+
} else if ('approle' === auth.method) {
|
|
67
|
+
body = { role_id: auth.roleid || '', secret_id: auth.secretid || '' }
|
|
68
|
+
} else {
|
|
69
|
+
throw new SekretoError('sekreto: hashicorp: unknown auth method: ' + String(auth.method))
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const res = await fetchjson('POST', url, baseheaders(), JSON.stringify(body))
|
|
73
|
+
|
|
74
|
+
const got = res.body && res.body.auth && res.body.auth.client_token
|
|
75
|
+
if (200 !== res.status || !got) {
|
|
76
|
+
throw new SekretoError('sekreto: hashicorp login failed: ' + res.status + ': ' + url)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const lease = Number(res.body.auth.lease_duration)
|
|
80
|
+
renewat = 0 < lease ? Date.now() + Math.max(lease - 60, 1) * 1000 : Infinity
|
|
81
|
+
|
|
82
|
+
return String(got)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return {
|
|
86
|
+
lookup: async (name: string) => {
|
|
87
|
+
checkaddr(addr)
|
|
88
|
+
|
|
89
|
+
if (undefined === livetoken || Date.now() >= renewat) {
|
|
90
|
+
livetoken = await login()
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const ref = vaultref(name)
|
|
94
|
+
const base = addr.replace(/\/$/, '') + '/v1/' + usemount
|
|
95
|
+
const url = 1 === kv ? base + '/' + ref.path : base + '/data/' + ref.path
|
|
96
|
+
|
|
97
|
+
const headers = baseheaders()
|
|
98
|
+
headers['X-Vault-Token'] = livetoken
|
|
99
|
+
|
|
100
|
+
const res = await fetchjson('GET', url, headers)
|
|
101
|
+
|
|
102
|
+
if (404 === res.status) {
|
|
103
|
+
return undefined
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (200 !== res.status) {
|
|
107
|
+
throw new SekretoError('sekreto: hashicorp error: ' + res.status + ': ' + url)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const data =
|
|
111
|
+
1 === kv ? res.body && res.body.data : res.body && res.body.data && res.body.data.data
|
|
112
|
+
|
|
113
|
+
const value = data ? data[ref.field] : undefined
|
|
114
|
+
return undefined === value || null === value ? undefined : String(value)
|
|
115
|
+
},
|
|
116
|
+
describe: () => 'hashicorp:' + addr + '/' + usemount,
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** A boru vault (https://github.com/boru-lang/boru).
|
|
121
|
+
*
|
|
122
|
+
* Two ways in, both boru's own.
|
|
123
|
+
*
|
|
124
|
+
* With no `addr`, the CLI: `boru vault get --reveal <alias>` prints the
|
|
125
|
+
* secret on stdout and nothing else. The passphrase is read by boru
|
|
126
|
+
* itself from `BORU_VAULT_PASSPHRASE`; sekreto never accepts it as
|
|
127
|
+
* config and never puts it on a command line, where it would show up in
|
|
128
|
+
* the process table.
|
|
129
|
+
*
|
|
130
|
+
* With an `addr`, boru's wire protocol: `boru vault serve` publishes a
|
|
131
|
+
* read-only, HashiCorp-shaped provision API (boru's
|
|
132
|
+
* design/VAULT-WIRE-PROTOCOL.0.md), authenticated by a capability token
|
|
133
|
+
* from `boru vault grant`. A sekreto name is already a valid boru
|
|
134
|
+
* alias, and boru aliases keep their dots, so `api.token` is the single
|
|
135
|
+
* path segment `api.token` - not the `api`/`token` split a HashiCorp KV
|
|
136
|
+
* gets. The value is the `value` field. A 404 is a miss; anything else
|
|
137
|
+
* the server refuses (a revoked capability, a sealed vault) is an
|
|
138
|
+
* error.
|
|
139
|
+
*
|
|
140
|
+
* boru's `vault proxy` and `vault mcp` remain out of bounds: they are a
|
|
141
|
+
* credential *broker*, built precisely so the caller never receives the
|
|
142
|
+
* credential. `vault serve` is the provision endpoint, built to hand
|
|
143
|
+
* the value back - that is the one sekreto uses. */
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
// Registering at import is what makes this module's presence the only
|
|
147
|
+
// thing that decides whether the kind exists in a build.
|
|
148
|
+
import { register } from './Registry'
|
|
149
|
+
|
|
150
|
+
register({
|
|
151
|
+
name: 'hashicorp',
|
|
152
|
+
needs: ['fetch', 'fs'],
|
|
153
|
+
define: (spec: ProviderSpec) => hashicorpprovider(spec.addr || '', spec.token || '', {
|
|
154
|
+
mount: spec.mount,
|
|
155
|
+
kv: spec.kv,
|
|
156
|
+
vaultnamespace: spec.vaultnamespace,
|
|
157
|
+
auth: spec.auth,
|
|
158
|
+
}),
|
|
159
|
+
})
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// VENDORED: @voxgig/sekreto 0.1.2 (typescript/src/provider/http.ts)
|
|
2
|
+
// Source: https://github.com/voxgig/sekreto @ 65009cb5758850db767785ab666e71895f86086b
|
|
3
|
+
// License: MIT (c) voxgig - see repository LICENSE. Do not edit: resync from upstream.
|
|
4
|
+
/* Copyright (c) 2025 Voxgig Ltd, MIT License */
|
|
5
|
+
|
|
6
|
+
import { SekretoError } from './support'
|
|
7
|
+
import { checkaddr } from './addr'
|
|
8
|
+
|
|
9
|
+
// Moved here with fetchjson, its only consumer.
|
|
10
|
+
const HTTP_TIMEOUT_MS = 10000
|
|
11
|
+
|
|
12
|
+
export async function fetchjson(
|
|
13
|
+
method: string,
|
|
14
|
+
url: string,
|
|
15
|
+
headers: Record<string, string>,
|
|
16
|
+
body?: string,
|
|
17
|
+
): Promise<{ status: number; body: any }> {
|
|
18
|
+
let res: Response
|
|
19
|
+
try {
|
|
20
|
+
res = await fetch(url, {
|
|
21
|
+
method,
|
|
22
|
+
headers,
|
|
23
|
+
body,
|
|
24
|
+
// A vault API never legitimately redirects, and a followed redirect
|
|
25
|
+
// carries X-Vault-Token to the redirect's host (and can downgrade
|
|
26
|
+
// https to http), which checkaddr - it only validates the configured
|
|
27
|
+
// address - cannot see. Refuse to follow one.
|
|
28
|
+
redirect: 'error',
|
|
29
|
+
// Bound the wait so an accepted-but-silent endpoint cannot hang the
|
|
30
|
+
// caller (and the app's startup) forever.
|
|
31
|
+
signal: AbortSignal.timeout(HTTP_TIMEOUT_MS),
|
|
32
|
+
})
|
|
33
|
+
} catch (err: any) {
|
|
34
|
+
throw new SekretoError('sekreto: cannot reach ' + url.split('?')[0] + ': ' + err.message)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
let parsed: any = undefined
|
|
38
|
+
try {
|
|
39
|
+
parsed = await res.json()
|
|
40
|
+
} catch (err: any) {
|
|
41
|
+
// A success status promised JSON; a body that does not parse means
|
|
42
|
+
// the store could not answer coherently, and treating it as a miss
|
|
43
|
+
// would fall through to a weaker store. Error statuses may carry
|
|
44
|
+
// any body - they are decided on status alone.
|
|
45
|
+
if (200 === res.status) {
|
|
46
|
+
throw new SekretoError('sekreto: malformed response from ' + url.split('?')[0])
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return { status: res.status, body: parsed }
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** HashiCorp Vault.
|
|
54
|
+
*
|
|
55
|
+
* KV v2 (the default): `api.token` reads `{addr}/v1/{mount}/data/api`
|
|
56
|
+
* and takes the `token` field of `data.data`. KV v1 (`kv: 1`) reads
|
|
57
|
+
* `{addr}/v1/{mount}/api` and takes the field of `data`. A 404 means
|
|
58
|
+
* "not here" - a miss - so a vault can sit in a chain with fallbacks.
|
|
59
|
+
*
|
|
60
|
+
* A Vault Enterprise namespace rides the X-Vault-Namespace header, on
|
|
61
|
+
* logins as well as reads.
|
|
62
|
+
*
|
|
63
|
+
* Instead of being handed a token, the provider can log in: Kubernetes
|
|
64
|
+
* auth (the pod's service-account JWT, from its conventional path) or
|
|
65
|
+
* AppRole. A failed login is an error, never a miss - it means this
|
|
66
|
+
* store could not answer at all. */
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
// VENDORED: @voxgig/sekreto 0.1.2 (typescript/src/provider/infisical.ts)
|
|
2
|
+
// Source: https://github.com/voxgig/sekreto @ 65009cb5758850db767785ab666e71895f86086b
|
|
3
|
+
// License: MIT (c) voxgig - see repository LICENSE. Do not edit: resync from upstream.
|
|
4
|
+
/* Copyright (c) 2025 Voxgig Ltd, MIT License */
|
|
5
|
+
|
|
6
|
+
import { ProviderSpec, Provider, SekretoError, envkey } from './support'
|
|
7
|
+
import { checkaddr } from './addr'
|
|
8
|
+
import { fetchjson } from './http'
|
|
9
|
+
|
|
10
|
+
export function infisicalprovider(options?: {
|
|
11
|
+
addr?: string
|
|
12
|
+
token?: string
|
|
13
|
+
clientid?: string
|
|
14
|
+
clientsecret?: string
|
|
15
|
+
project?: string
|
|
16
|
+
environment?: string
|
|
17
|
+
path?: string
|
|
18
|
+
}): Provider {
|
|
19
|
+
const opts = options || {}
|
|
20
|
+
|
|
21
|
+
// A configured token is kept forever; a universal-auth token carries
|
|
22
|
+
// expiresIn and is renewed shortly before it runs out.
|
|
23
|
+
let livetoken: string | undefined
|
|
24
|
+
let renewat = Infinity
|
|
25
|
+
|
|
26
|
+
const login = async (addr: string): Promise<string> => {
|
|
27
|
+
if (opts.token) {
|
|
28
|
+
return opts.token
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (!opts.clientid || !opts.clientsecret) {
|
|
32
|
+
throw new SekretoError('sekreto: infisical: no token and no client credentials')
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const res = await fetchjson(
|
|
36
|
+
'POST',
|
|
37
|
+
addr + '/api/v1/auth/universal-auth/login',
|
|
38
|
+
{ 'content-type': 'application/json' },
|
|
39
|
+
JSON.stringify({ clientId: opts.clientid, clientSecret: opts.clientsecret }),
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
const got = res.body && res.body.accessToken
|
|
43
|
+
if (200 !== res.status || !got) {
|
|
44
|
+
throw new SekretoError('sekreto: infisical login failed: ' + res.status)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const expires = Number(res.body.expiresIn)
|
|
48
|
+
renewat = 0 < expires ? Date.now() + Math.max(expires - 60, 1) * 1000 : Infinity
|
|
49
|
+
|
|
50
|
+
return String(got)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return {
|
|
54
|
+
lookup: async (name: string) => {
|
|
55
|
+
const addr = (opts.addr || 'https://app.infisical.com').replace(/\/$/, '')
|
|
56
|
+
checkaddr(addr)
|
|
57
|
+
|
|
58
|
+
const project = opts.project || ''
|
|
59
|
+
const environment = opts.environment || ''
|
|
60
|
+
if ('' === project || '' === environment) {
|
|
61
|
+
throw new SekretoError('sekreto: infisical: no project/environment')
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (undefined === livetoken || Date.now() >= renewat) {
|
|
65
|
+
livetoken = await login(addr)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const url =
|
|
69
|
+
addr +
|
|
70
|
+
'/api/v3/secrets/raw/' +
|
|
71
|
+
envkey(name) +
|
|
72
|
+
'?workspaceId=' +
|
|
73
|
+
encodeURIComponent(project) +
|
|
74
|
+
'&environment=' +
|
|
75
|
+
encodeURIComponent(environment) +
|
|
76
|
+
'&secretPath=' +
|
|
77
|
+
encodeURIComponent(opts.path || '/')
|
|
78
|
+
|
|
79
|
+
const res = await fetchjson('GET', url, { authorization: 'Bearer ' + livetoken })
|
|
80
|
+
|
|
81
|
+
if (404 === res.status) {
|
|
82
|
+
return undefined
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (200 !== res.status) {
|
|
86
|
+
throw new SekretoError('sekreto: infisical error: ' + res.status)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const value = res.body && res.body.secret && res.body.secret.secretValue
|
|
90
|
+
return undefined === value || null === value ? undefined : String(value)
|
|
91
|
+
},
|
|
92
|
+
describe: () => 'infisical:' + (opts.project || '') + '/' + (opts.environment || ''),
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** Build a provider from its declarative form. */
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
// Registering at import is what makes this module's presence the only
|
|
100
|
+
// thing that decides whether the kind exists in a build.
|
|
101
|
+
import { register } from './Registry'
|
|
102
|
+
|
|
103
|
+
register({
|
|
104
|
+
name: 'infisical',
|
|
105
|
+
needs: ['fetch'],
|
|
106
|
+
define: (spec: ProviderSpec) => infisicalprovider(spec),
|
|
107
|
+
})
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// VENDORED: @voxgig/sekreto 0.1.2 (typescript/src/provider/memory.ts)
|
|
2
|
+
// Source: https://github.com/voxgig/sekreto @ 65009cb5758850db767785ab666e71895f86086b
|
|
3
|
+
// License: MIT (c) voxgig - see repository LICENSE. Do not edit: resync from upstream.
|
|
4
|
+
/* Copyright (c) 2025 Voxgig Ltd, MIT License */
|
|
5
|
+
|
|
6
|
+
import { ProviderSpec, Provider, envkey } from './support'
|
|
7
|
+
|
|
8
|
+
export function memoryprovider(values: Record<string, string>, prefix?: string): Provider {
|
|
9
|
+
return {
|
|
10
|
+
lookup: (name: string) => values[envkey(name, prefix)],
|
|
11
|
+
describe: () => 'memory' + (prefix ? ':' + prefix : ''),
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** A directory of one-secret-per-file entries, keyed like the
|
|
16
|
+
* environment: `api.token` reads `<dir>/API_TOKEN`.
|
|
17
|
+
*
|
|
18
|
+
* This is the shape of a mounted Kubernetes Secret, a Docker or Swarm
|
|
19
|
+
* secret, and a systemd credentials directory, so those all work with no
|
|
20
|
+
* further configuration. One trailing newline is stripped - tools that
|
|
21
|
+
* write these files disagree about it, and a newline is never part of a
|
|
22
|
+
* secret on purpose. */
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
// Registering at import is what makes this module's presence the only
|
|
26
|
+
// thing that decides whether the kind exists in a build.
|
|
27
|
+
import { register } from './Registry'
|
|
28
|
+
|
|
29
|
+
register({
|
|
30
|
+
name: 'memory',
|
|
31
|
+
needs: [],
|
|
32
|
+
define: (spec: ProviderSpec) => memoryprovider(spec.values || {}, spec.prefix),
|
|
33
|
+
})
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
// VENDORED: @voxgig/sekreto 0.1.2 (typescript/src/provider/onepassword.ts)
|
|
2
|
+
// Source: https://github.com/voxgig/sekreto @ 65009cb5758850db767785ab666e71895f86086b
|
|
3
|
+
// License: MIT (c) voxgig - see repository LICENSE. Do not edit: resync from upstream.
|
|
4
|
+
/* Copyright (c) 2025 Voxgig Ltd, MIT License */
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
ProviderSpec, Provider, SekretoError, checkname, vaultref,
|
|
8
|
+
} from './support'
|
|
9
|
+
import { checkaddr } from './addr'
|
|
10
|
+
import { fetchjson } from './http'
|
|
11
|
+
|
|
12
|
+
export function onepasswordprovider(options?: {
|
|
13
|
+
addr?: string
|
|
14
|
+
token?: string
|
|
15
|
+
vault?: string
|
|
16
|
+
}): Provider {
|
|
17
|
+
const opts = options || {}
|
|
18
|
+
|
|
19
|
+
let vaultid: string | undefined
|
|
20
|
+
|
|
21
|
+
const auth = (): Record<string, string> => ({
|
|
22
|
+
authorization: 'Bearer ' + (opts.token || ''),
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
const resolvevault = async (addr: string): Promise<string> => {
|
|
26
|
+
const want = opts.vault || ''
|
|
27
|
+
if ('' === want) {
|
|
28
|
+
throw new SekretoError('sekreto: onepassword: no vault')
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const res = await fetchjson('GET', addr + '/v1/vaults', auth())
|
|
32
|
+
|
|
33
|
+
if (200 !== res.status || !Array.isArray(res.body)) {
|
|
34
|
+
throw new SekretoError('sekreto: onepassword error: ' + res.status + ': listing vaults')
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
for (const entry of res.body) {
|
|
38
|
+
if (entry && (want === entry.id || want === entry.name)) {
|
|
39
|
+
return String(entry.id)
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
throw new SekretoError('sekreto: onepassword: no vault named ' + want)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return {
|
|
47
|
+
lookup: async (name: string) => {
|
|
48
|
+
checkname(name)
|
|
49
|
+
|
|
50
|
+
const addr = (opts.addr || '').replace(/\/$/, '')
|
|
51
|
+
if ('' === addr) {
|
|
52
|
+
throw new SekretoError('sekreto: onepassword: no addr')
|
|
53
|
+
}
|
|
54
|
+
checkaddr(addr)
|
|
55
|
+
|
|
56
|
+
if (undefined === vaultid) {
|
|
57
|
+
vaultid = await resolvevault(addr)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const filter = encodeURIComponent('title eq "' + name + '"')
|
|
61
|
+
const found = await fetchjson(
|
|
62
|
+
'GET',
|
|
63
|
+
addr + '/v1/vaults/' + vaultid + '/items?filter=' + filter,
|
|
64
|
+
auth(),
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
if (200 !== found.status || !Array.isArray(found.body)) {
|
|
68
|
+
throw new SekretoError('sekreto: onepassword error: ' + found.status + ': finding ' + name)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (0 === found.body.length) {
|
|
72
|
+
return undefined
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const item = await fetchjson(
|
|
76
|
+
'GET',
|
|
77
|
+
addr + '/v1/vaults/' + vaultid + '/items/' + found.body[0].id,
|
|
78
|
+
auth(),
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
if (200 !== item.status) {
|
|
82
|
+
throw new SekretoError('sekreto: onepassword error: ' + item.status + ': reading ' + name)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const fields = (item.body && item.body.fields) || []
|
|
86
|
+
|
|
87
|
+
for (const field of fields) {
|
|
88
|
+
if (field && 'PASSWORD' === field.purpose) {
|
|
89
|
+
return undefined === field.value || null === field.value ? undefined : String(field.value)
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
for (const field of fields) {
|
|
93
|
+
if (field && 'value' === field.label) {
|
|
94
|
+
return undefined === field.value || null === field.value ? undefined : String(field.value)
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return undefined
|
|
99
|
+
},
|
|
100
|
+
describe: () => 'onepassword:' + (opts.vault || ''),
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** Doppler.
|
|
105
|
+
*
|
|
106
|
+
* The whole config is downloaded once - Doppler's own bulk endpoint -
|
|
107
|
+
* and answered from memory, like a remote .env: `api.token` is the
|
|
108
|
+
* `API_TOKEN` entry. A service token is config-scoped, so project and
|
|
109
|
+
* config are only needed with broader tokens. */
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
// Registering at import is what makes this module's presence the only
|
|
113
|
+
// thing that decides whether the kind exists in a build.
|
|
114
|
+
import { register } from './Registry'
|
|
115
|
+
|
|
116
|
+
register({
|
|
117
|
+
name: 'onepassword',
|
|
118
|
+
needs: ['fetch'],
|
|
119
|
+
define: (spec: ProviderSpec) => onepasswordprovider(spec),
|
|
120
|
+
})
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
// VENDORED: @voxgig/sekreto 0.1.2 (typescript/src/provider/support.ts)
|
|
2
|
+
// Source: https://github.com/voxgig/sekreto @ 65009cb5758850db767785ab666e71895f86086b
|
|
3
|
+
// License: MIT (c) voxgig - see repository LICENSE. Do not edit: resync from upstream.
|
|
4
|
+
// The providers a Sekreto chains together.
|
|
5
|
+
//
|
|
6
|
+
// A provider answers one question: "do you have this secret?" It returns
|
|
7
|
+
// the value, or undefined to mean "ask the next one". Nothing else about
|
|
8
|
+
// a provider is visible to the caller - which is the point: an app reads
|
|
9
|
+
// `api.token` and never learns whether it came from the environment, a
|
|
10
|
+
// .env file, HashiCorp Vault, AWS, GCP, Azure or a boru vault.
|
|
11
|
+
//
|
|
12
|
+
// Two failure shapes, and they are never interchangeable. A store that
|
|
13
|
+
// does not hold the secret is a MISS (undefined) - the chain carries on.
|
|
14
|
+
// A store that could not answer - bad credentials, unreachable host,
|
|
15
|
+
// missing configuration - is an ERROR: falling through there would
|
|
16
|
+
// quietly reach for a weaker store.
|
|
17
|
+
|
|
18
|
+
import {
|
|
19
|
+
SekretoError,
|
|
20
|
+
awsparam,
|
|
21
|
+
checkname,
|
|
22
|
+
envkey,
|
|
23
|
+
flatname,
|
|
24
|
+
parsedotenv,
|
|
25
|
+
vaultref,
|
|
26
|
+
} from '../Sekreto'
|
|
27
|
+
|
|
28
|
+
// NODE BUILTINS, LOADED ON FIRST USE.
|
|
29
|
+
//
|
|
30
|
+
// These were top-level imports, which made them a side effect of importing
|
|
31
|
+
// sekreto AT ALL: `child_process`, `fs` and `path` entered the module graph
|
|
32
|
+
// for a caller who only ever used a `memory` or `env` provider, and any
|
|
33
|
+
// runtime lacking them failed at import time rather than at the point of
|
|
34
|
+
// use. Sekreto.ts imports makeprovider from this module, so the chain
|
|
35
|
+
// reached everything.
|
|
36
|
+
//
|
|
37
|
+
// A plain require(), not `await import()`: dotenvprovider, fileprovider and
|
|
38
|
+
// boruprovider all have SYNCHRONOUS lookups, and making them async to
|
|
39
|
+
// accommodate a dynamic import would change observable behaviour for anyone
|
|
40
|
+
// calling a provider directly. The package is CommonJS ("type":
|
|
41
|
+
// "commonjs"), so require is available and synchronous.
|
|
42
|
+
//
|
|
43
|
+
// What this buys and what it does not: the builtins are no longer evaluated
|
|
44
|
+
// at import time, so importing sekreto is safe in a runtime that lacks them
|
|
45
|
+
// and a bundler can drop an unreachable provider along with its edge. It is
|
|
46
|
+
// NOT by itself a complete browser story — a bundler still resolves a
|
|
47
|
+
// require it can see statically, so a browser build wants conditional
|
|
48
|
+
// exports ("browser" field) as well. That is a packaging change, tracked
|
|
49
|
+
// separately.
|
|
50
|
+
const nodemods: Record<string, any> = {}
|
|
51
|
+
|
|
52
|
+
function nodemod<T = any>(name: string): T {
|
|
53
|
+
let mod = nodemods[name]
|
|
54
|
+
|
|
55
|
+
if (undefined === mod) {
|
|
56
|
+
try {
|
|
57
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
58
|
+
mod = nodemods[name] = require(name)
|
|
59
|
+
} catch (err: any) {
|
|
60
|
+
throw new SekretoError(
|
|
61
|
+
'sekreto: this provider needs ' +
|
|
62
|
+
name +
|
|
63
|
+
', which this runtime does not provide: ' +
|
|
64
|
+
err.message,
|
|
65
|
+
)
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return mod as T
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export type Provider = {
|
|
73
|
+
/** The value, or undefined if this provider does not have it. */
|
|
74
|
+
lookup: (name: string) => Promise<string | undefined> | string | undefined
|
|
75
|
+
/** A short description, shown by `Sekreto.sources()`. */
|
|
76
|
+
describe: () => string
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** The declarative form of a provider, as used in config and in the
|
|
80
|
+
* shared spec. */
|
|
81
|
+
export type ProviderSpec = {
|
|
82
|
+
kind:
|
|
83
|
+
| 'env'
|
|
84
|
+
| 'dotenv'
|
|
85
|
+
| 'memory'
|
|
86
|
+
| 'file'
|
|
87
|
+
| 'hashicorp'
|
|
88
|
+
| 'boru'
|
|
89
|
+
| 'awssecrets'
|
|
90
|
+
| 'awsparams'
|
|
91
|
+
| 'gcpsecrets'
|
|
92
|
+
| 'azuresecrets'
|
|
93
|
+
| 'onepassword'
|
|
94
|
+
| 'doppler'
|
|
95
|
+
| 'infisical'
|
|
96
|
+
/** The store name `Sekreto.getfrom` addresses. Defaults to `kind`. */
|
|
97
|
+
name?: string
|
|
98
|
+
prefix?: string
|
|
99
|
+
/** dotenv: the file to read. */
|
|
100
|
+
file?: string
|
|
101
|
+
/** memory: literal values, keyed like environment variables. */
|
|
102
|
+
values?: Record<string, string>
|
|
103
|
+
/** file: the directory of one-secret-per-file entries. */
|
|
104
|
+
dir?: string
|
|
105
|
+
/** hashicorp / boru (wire) / gcp / 1password / doppler / infisical:
|
|
106
|
+
* the base URL. */
|
|
107
|
+
addr?: string
|
|
108
|
+
/** hashicorp / boru (wire) / gcp / azure / 1password / doppler /
|
|
109
|
+
* infisical: the access token. */
|
|
110
|
+
token?: string
|
|
111
|
+
/** hashicorp / boru (wire): the KV mount (default `secret`). */
|
|
112
|
+
mount?: string
|
|
113
|
+
/** hashicorp: KV engine version, 1 or 2 (default 2). */
|
|
114
|
+
kv?: number
|
|
115
|
+
/** hashicorp: Vault Enterprise namespace (X-Vault-Namespace). */
|
|
116
|
+
vaultnamespace?: string
|
|
117
|
+
/** hashicorp: log in for a token instead of being handed one. */
|
|
118
|
+
auth?: {
|
|
119
|
+
method: 'kubernetes' | 'approle'
|
|
120
|
+
/** The auth mount, defaulting to the method name. */
|
|
121
|
+
mount?: string
|
|
122
|
+
/** kubernetes: the Vault role to log in as. */
|
|
123
|
+
role?: string
|
|
124
|
+
/** kubernetes: the service-account JWT itself (tests). */
|
|
125
|
+
jwt?: string
|
|
126
|
+
/** kubernetes: where the JWT lives; the conventional pod path by
|
|
127
|
+
* default. */
|
|
128
|
+
jwtfile?: string
|
|
129
|
+
/** approle: the role and secret ids. */
|
|
130
|
+
roleid?: string
|
|
131
|
+
secretid?: string
|
|
132
|
+
}
|
|
133
|
+
/** boru: the executable to run (default `boru`). */
|
|
134
|
+
command?: string
|
|
135
|
+
/** boru: the namespace qualifying the alias. */
|
|
136
|
+
namespace?: string
|
|
137
|
+
/** boru: the vault home, passed as BORU_HOME. */
|
|
138
|
+
home?: string
|
|
139
|
+
/** aws: region and credentials; the standard AWS_* environment
|
|
140
|
+
* variables fill whichever are not given. */
|
|
141
|
+
region?: string
|
|
142
|
+
keyid?: string
|
|
143
|
+
secret?: string
|
|
144
|
+
session?: string
|
|
145
|
+
/** gcp / doppler / infisical: the project (GCP project id, Doppler
|
|
146
|
+
* project slug, Infisical workspace id). */
|
|
147
|
+
project?: string
|
|
148
|
+
/** azure: the Key Vault name or full URL. 1password: the vault name
|
|
149
|
+
* or id. */
|
|
150
|
+
vault?: string
|
|
151
|
+
/** azure: client-credential login. infisical: universal-auth login
|
|
152
|
+
* (tenant is Azure-only). */
|
|
153
|
+
tenant?: string
|
|
154
|
+
clientid?: string
|
|
155
|
+
clientsecret?: string
|
|
156
|
+
/** azure: where to log in / where IMDS answers. gcp: where the
|
|
157
|
+
* metadata server answers. Overridable for tests and for clouds with
|
|
158
|
+
* nonstandard endpoints. */
|
|
159
|
+
loginaddr?: string
|
|
160
|
+
imdsaddr?: string
|
|
161
|
+
metadataaddr?: string
|
|
162
|
+
/** azure: the Key Vault API version (default 7.4). */
|
|
163
|
+
apiversion?: string
|
|
164
|
+
/** doppler: the config slug (with `project`). */
|
|
165
|
+
config?: string
|
|
166
|
+
/** infisical: the environment slug and secret path. */
|
|
167
|
+
environment?: string
|
|
168
|
+
path?: string
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/** Environment variables: `api.token` from `API_TOKEN`. */
|
|
172
|
+
|
|
173
|
+
export {
|
|
174
|
+
SekretoError, awsparam, checkname, envkey, flatname, parsedotenv, vaultref,
|
|
175
|
+
}
|
|
176
|
+
export { nodemod }
|