@tillstack/secrets-node 0.1.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/dist/index.d.mts +15 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +36 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +28 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +62 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { SecretsClientOptions, SecretsClient, PullResult } from '@tillstack/secrets-core';
|
|
2
|
+
export * from '@tillstack/secrets-core';
|
|
3
|
+
|
|
4
|
+
/** Create a client from options or the environment (`TILLSECRETS_TOKEN`,
|
|
5
|
+
* optional `TILLSECRETS_URL`, optional `TILLSECRETS_ENV`). */
|
|
6
|
+
declare function createClient(opts?: Partial<SecretsClientOptions>): SecretsClient;
|
|
7
|
+
interface LoadOptions extends Partial<SecretsClientOptions> {
|
|
8
|
+
/** Overwrite keys already present in process.env (default false — existing
|
|
9
|
+
* wins, matching dotenv). */
|
|
10
|
+
override?: boolean;
|
|
11
|
+
}
|
|
12
|
+
/** Pull secrets and inject them into process.env. Returns the pulled map. */
|
|
13
|
+
declare function load(opts?: LoadOptions): Promise<PullResult>;
|
|
14
|
+
|
|
15
|
+
export { type LoadOptions, createClient, load };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { SecretsClientOptions, SecretsClient, PullResult } from '@tillstack/secrets-core';
|
|
2
|
+
export * from '@tillstack/secrets-core';
|
|
3
|
+
|
|
4
|
+
/** Create a client from options or the environment (`TILLSECRETS_TOKEN`,
|
|
5
|
+
* optional `TILLSECRETS_URL`, optional `TILLSECRETS_ENV`). */
|
|
6
|
+
declare function createClient(opts?: Partial<SecretsClientOptions>): SecretsClient;
|
|
7
|
+
interface LoadOptions extends Partial<SecretsClientOptions> {
|
|
8
|
+
/** Overwrite keys already present in process.env (default false — existing
|
|
9
|
+
* wins, matching dotenv). */
|
|
10
|
+
override?: boolean;
|
|
11
|
+
}
|
|
12
|
+
/** Pull secrets and inject them into process.env. Returns the pulled map. */
|
|
13
|
+
declare function load(opts?: LoadOptions): Promise<PullResult>;
|
|
14
|
+
|
|
15
|
+
export { type LoadOptions, createClient, load };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var secretsCore = require('@tillstack/secrets-core');
|
|
4
|
+
|
|
5
|
+
// src/index.ts
|
|
6
|
+
function createClient(opts) {
|
|
7
|
+
const token = opts?.token ?? process.env.TILLSECRETS_TOKEN;
|
|
8
|
+
if (!token) throw new Error("TillSecrets: no token \u2014 pass one or set TILLSECRETS_TOKEN");
|
|
9
|
+
const built = { token };
|
|
10
|
+
const url = opts?.url ?? process.env.TILLSECRETS_URL;
|
|
11
|
+
if (url) built.url = url;
|
|
12
|
+
const env = opts?.environmentId ?? process.env.TILLSECRETS_ENV;
|
|
13
|
+
if (env) built.environmentId = env;
|
|
14
|
+
if (opts?.timeoutMs !== void 0) built.timeoutMs = opts.timeoutMs;
|
|
15
|
+
if (opts?.fetch) built.fetch = opts.fetch;
|
|
16
|
+
return new secretsCore.SecretsClient(built);
|
|
17
|
+
}
|
|
18
|
+
async function load(opts = {}) {
|
|
19
|
+
const client = createClient(opts);
|
|
20
|
+
const result = await client.pull();
|
|
21
|
+
for (const [k, v] of Object.entries(result.secrets)) {
|
|
22
|
+
if (opts.override || process.env[k] === void 0) process.env[k] = v;
|
|
23
|
+
}
|
|
24
|
+
return result;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
exports.createClient = createClient;
|
|
28
|
+
exports.load = load;
|
|
29
|
+
Object.keys(secretsCore).forEach(function (k) {
|
|
30
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () { return secretsCore[k]; }
|
|
33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AAA,CAAI,CAAC,MAAM,MAAA,EAAW,OAAA,CAAQ,GAAA,CAAI,CAAC,CAAA,GAAI,CAAA;AAAA,EACtE;AACA,EAAA,OAAO,MAAA;AACT","file":"index.js","sourcesContent":["// @tillstack/secrets-node — TillSecrets client for Node.js.\n//\n// import { load } from '@tillstack/secrets-node'\n// await load() // reads TILLSECRETS_TOKEN, injects into process.env\n// // ... process.env.STRIPE_KEY is now populated\n//\n// or explicitly:\n// const client = createClient({ token })\n// const { secrets } = await client.pull()\n\nimport { SecretsClient, type SecretsClientOptions, type PullResult } from '@tillstack/secrets-core'\n\nexport * from '@tillstack/secrets-core'\n\n/** Create a client from options or the environment (`TILLSECRETS_TOKEN`,\n * optional `TILLSECRETS_URL`, optional `TILLSECRETS_ENV`). */\nexport function createClient(opts?: Partial<SecretsClientOptions>): SecretsClient {\n const token = opts?.token ?? process.env.TILLSECRETS_TOKEN\n if (!token) throw new Error('TillSecrets: no token — pass one or set TILLSECRETS_TOKEN')\n const built: SecretsClientOptions = { token }\n const url = opts?.url ?? process.env.TILLSECRETS_URL\n if (url) built.url = url\n const env = opts?.environmentId ?? process.env.TILLSECRETS_ENV\n if (env) built.environmentId = env\n if (opts?.timeoutMs !== undefined) built.timeoutMs = opts.timeoutMs\n if (opts?.fetch) built.fetch = opts.fetch\n return new SecretsClient(built)\n}\n\nexport interface LoadOptions extends Partial<SecretsClientOptions> {\n /** Overwrite keys already present in process.env (default false — existing\n * wins, matching dotenv). */\n override?: boolean\n}\n\n/** Pull secrets and inject them into process.env. Returns the pulled map. */\nexport async function load(opts: LoadOptions = {}): Promise<PullResult> {\n const client = createClient(opts)\n const result = await client.pull()\n for (const [k, v] of Object.entries(result.secrets)) {\n if (opts.override || process.env[k] === undefined) process.env[k] = v\n }\n return result\n}\n"]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { SecretsClient } from '@tillstack/secrets-core';
|
|
2
|
+
export * from '@tillstack/secrets-core';
|
|
3
|
+
|
|
4
|
+
// src/index.ts
|
|
5
|
+
function createClient(opts) {
|
|
6
|
+
const token = opts?.token ?? process.env.TILLSECRETS_TOKEN;
|
|
7
|
+
if (!token) throw new Error("TillSecrets: no token \u2014 pass one or set TILLSECRETS_TOKEN");
|
|
8
|
+
const built = { token };
|
|
9
|
+
const url = opts?.url ?? process.env.TILLSECRETS_URL;
|
|
10
|
+
if (url) built.url = url;
|
|
11
|
+
const env = opts?.environmentId ?? process.env.TILLSECRETS_ENV;
|
|
12
|
+
if (env) built.environmentId = env;
|
|
13
|
+
if (opts?.timeoutMs !== void 0) built.timeoutMs = opts.timeoutMs;
|
|
14
|
+
if (opts?.fetch) built.fetch = opts.fetch;
|
|
15
|
+
return new SecretsClient(built);
|
|
16
|
+
}
|
|
17
|
+
async function load(opts = {}) {
|
|
18
|
+
const client = createClient(opts);
|
|
19
|
+
const result = await client.pull();
|
|
20
|
+
for (const [k, v] of Object.entries(result.secrets)) {
|
|
21
|
+
if (opts.override || process.env[k] === void 0) process.env[k] = v;
|
|
22
|
+
}
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { createClient, load };
|
|
27
|
+
//# sourceMappingURL=index.mjs.map
|
|
28
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;AAgBO,SAAS,aAAa,IAAA,EAAqD;AAChF,EAAA,MAAM,KAAA,GAAQ,IAAA,EAAM,KAAA,IAAS,OAAA,CAAQ,GAAA,CAAI,iBAAA;AACzC,EAAA,IAAI,CAAC,KAAA,EAAO,MAAM,IAAI,MAAM,gEAA2D,CAAA;AACvF,EAAA,MAAM,KAAA,GAA8B,EAAE,KAAA,EAAM;AAC5C,EAAA,MAAM,GAAA,GAAM,IAAA,EAAM,GAAA,IAAO,OAAA,CAAQ,GAAA,CAAI,eAAA;AACrC,EAAA,IAAI,GAAA,QAAW,GAAA,GAAM,GAAA;AACrB,EAAA,MAAM,GAAA,GAAM,IAAA,EAAM,aAAA,IAAiB,OAAA,CAAQ,GAAA,CAAI,eAAA;AAC/C,EAAA,IAAI,GAAA,QAAW,aAAA,GAAgB,GAAA;AAC/B,EAAA,IAAI,IAAA,EAAM,SAAA,KAAc,MAAA,EAAW,KAAA,CAAM,YAAY,IAAA,CAAK,SAAA;AAC1D,EAAA,IAAI,IAAA,EAAM,KAAA,EAAO,KAAA,CAAM,KAAA,GAAQ,IAAA,CAAK,KAAA;AACpC,EAAA,OAAO,IAAI,cAAc,KAAK,CAAA;AAChC;AASA,eAAsB,IAAA,CAAK,IAAA,GAAoB,EAAC,EAAwB;AACtE,EAAA,MAAM,MAAA,GAAS,aAAa,IAAI,CAAA;AAChC,EAAA,MAAM,MAAA,GAAS,MAAM,MAAA,CAAO,IAAA,EAAK;AACjC,EAAA,KAAA,MAAW,CAAC,GAAG,CAAC,CAAA,IAAK,OAAO,OAAA,CAAQ,MAAA,CAAO,OAAO,CAAA,EAAG;AACnD,IAAA,IAAI,IAAA,CAAK,QAAA,IAAY,OAAA,CAAQ,GAAA,CAAI,CAAC,MAAM,MAAA,EAAW,OAAA,CAAQ,GAAA,CAAI,CAAC,CAAA,GAAI,CAAA;AAAA,EACtE;AACA,EAAA,OAAO,MAAA;AACT","file":"index.mjs","sourcesContent":["// @tillstack/secrets-node — TillSecrets client for Node.js.\n//\n// import { load } from '@tillstack/secrets-node'\n// await load() // reads TILLSECRETS_TOKEN, injects into process.env\n// // ... process.env.STRIPE_KEY is now populated\n//\n// or explicitly:\n// const client = createClient({ token })\n// const { secrets } = await client.pull()\n\nimport { SecretsClient, type SecretsClientOptions, type PullResult } from '@tillstack/secrets-core'\n\nexport * from '@tillstack/secrets-core'\n\n/** Create a client from options or the environment (`TILLSECRETS_TOKEN`,\n * optional `TILLSECRETS_URL`, optional `TILLSECRETS_ENV`). */\nexport function createClient(opts?: Partial<SecretsClientOptions>): SecretsClient {\n const token = opts?.token ?? process.env.TILLSECRETS_TOKEN\n if (!token) throw new Error('TillSecrets: no token — pass one or set TILLSECRETS_TOKEN')\n const built: SecretsClientOptions = { token }\n const url = opts?.url ?? process.env.TILLSECRETS_URL\n if (url) built.url = url\n const env = opts?.environmentId ?? process.env.TILLSECRETS_ENV\n if (env) built.environmentId = env\n if (opts?.timeoutMs !== undefined) built.timeoutMs = opts.timeoutMs\n if (opts?.fetch) built.fetch = opts.fetch\n return new SecretsClient(built)\n}\n\nexport interface LoadOptions extends Partial<SecretsClientOptions> {\n /** Overwrite keys already present in process.env (default false — existing\n * wins, matching dotenv). */\n override?: boolean\n}\n\n/** Pull secrets and inject them into process.env. Returns the pulled map. */\nexport async function load(opts: LoadOptions = {}): Promise<PullResult> {\n const client = createClient(opts)\n const result = await client.pull()\n for (const [k, v] of Object.entries(result.secrets)) {\n if (opts.override || process.env[k] === undefined) process.env[k] = v\n }\n return result\n}\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tillstack/secrets-node",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "TillSecrets client for Node.js — pull encrypted config at boot and inject it into process.env, with a drop-in dotenv-style API.",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.mjs",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": {
|
|
12
|
+
"types": "./dist/index.d.mts",
|
|
13
|
+
"default": "./dist/index.mjs"
|
|
14
|
+
},
|
|
15
|
+
"require": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"default": "./dist/index.js"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"./package.json": "./package.json"
|
|
21
|
+
},
|
|
22
|
+
"sideEffects": false,
|
|
23
|
+
"files": [
|
|
24
|
+
"dist"
|
|
25
|
+
],
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@tillstack/secrets-core": "^0.1.0"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@types/node": "^22.0.0",
|
|
31
|
+
"tsup": "^8.5.1",
|
|
32
|
+
"typescript": "^5.7.3"
|
|
33
|
+
},
|
|
34
|
+
"license": "UNLICENSED",
|
|
35
|
+
"repository": {
|
|
36
|
+
"type": "git",
|
|
37
|
+
"url": "git+https://github.com/tillafrica/tilldev.git",
|
|
38
|
+
"directory": "packages/secrets-node"
|
|
39
|
+
},
|
|
40
|
+
"homepage": "https://tilldev.dev",
|
|
41
|
+
"bugs": {
|
|
42
|
+
"url": "https://github.com/tillafrica/tilldev/issues"
|
|
43
|
+
},
|
|
44
|
+
"publishConfig": {
|
|
45
|
+
"access": "public"
|
|
46
|
+
},
|
|
47
|
+
"keywords": [
|
|
48
|
+
"tilldev",
|
|
49
|
+
"tillsecrets",
|
|
50
|
+
"secrets",
|
|
51
|
+
"config",
|
|
52
|
+
"env",
|
|
53
|
+
"dotenv",
|
|
54
|
+
"node"
|
|
55
|
+
],
|
|
56
|
+
"scripts": {
|
|
57
|
+
"build": "tsup",
|
|
58
|
+
"dev": "tsup --watch",
|
|
59
|
+
"typecheck": "tsc --noEmit",
|
|
60
|
+
"clean": "rm -rf dist"
|
|
61
|
+
}
|
|
62
|
+
}
|