@mccaskie-labs/workbench-config 0.0.0-stage → 0.1.1
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/CHANGELOG.md +11 -0
- package/README.md +33 -2
- package/capabilities/ai.json +69 -0
- package/capabilities/config.json +56 -0
- package/capabilities/config.md +23 -0
- package/capabilities/gateway.json +75 -0
- package/capabilities/schema.json +414 -0
- package/dist/capabilities.gen.d.ts +403 -0
- package/dist/capabilities.gen.js +554 -0
- package/dist/capability-schema.d.ts +193 -0
- package/dist/capability-schema.js +217 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +34 -0
- package/dist/define-config.d.ts +21 -0
- package/dist/define-config.js +57 -0
- package/dist/dev-vars.d.ts +10 -0
- package/dist/dev-vars.js +23 -0
- package/dist/env.d.ts +8 -0
- package/dist/env.js +16 -0
- package/dist/errors.d.ts +17 -0
- package/dist/errors.js +26 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +7 -0
- package/dist/secrets.d.ts +19 -0
- package/dist/secrets.js +44 -0
- package/package.json +48 -4
package/dist/secrets.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { missing } from "./errors.js";
|
|
2
|
+
/**
|
|
3
|
+
* Reads a Secrets Store binding (a secret shared between Workers). Throws if
|
|
4
|
+
* the value is empty. `name` is only used to name the binding in the error.
|
|
5
|
+
*/
|
|
6
|
+
export async function sharedSecret(binding, name = "Secrets Store binding") {
|
|
7
|
+
if (!binding || typeof binding.get !== "function")
|
|
8
|
+
throw missing(name, "no Secrets Store binding");
|
|
9
|
+
let value;
|
|
10
|
+
try {
|
|
11
|
+
value = await binding.get();
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
// The binding's own error can say why; it can't hold the value, which was never read.
|
|
15
|
+
throw missing(name, "the Secrets Store could not return it");
|
|
16
|
+
}
|
|
17
|
+
if (typeof value !== "string" || value === "")
|
|
18
|
+
throw missing(name);
|
|
19
|
+
return value;
|
|
20
|
+
}
|
|
21
|
+
/** Reads a Worker secret or variable by name. Throws, naming it, if it is missing or empty. */
|
|
22
|
+
export function workerSecret(env, name) {
|
|
23
|
+
const value = env[name];
|
|
24
|
+
if (typeof value !== "string" || value === "")
|
|
25
|
+
throw missing(name);
|
|
26
|
+
return value;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Replaces a secret for logs. Always `[redacted]`, whatever the value: no
|
|
30
|
+
* prefix, suffix or length is kept, so a log line can never carry part of it.
|
|
31
|
+
* `redactAll` does the same for every occurrence inside a longer string.
|
|
32
|
+
*/
|
|
33
|
+
export function redact(_value) {
|
|
34
|
+
return "[redacted]";
|
|
35
|
+
}
|
|
36
|
+
/** Replaces every occurrence of each secret in `text` with `[redacted]`. Empty secrets are ignored. */
|
|
37
|
+
export function redactAll(text, secrets) {
|
|
38
|
+
let out = text;
|
|
39
|
+
for (const secret of secrets) {
|
|
40
|
+
if (typeof secret === "string" && secret !== "")
|
|
41
|
+
out = out.split(secret).join("[redacted]");
|
|
42
|
+
}
|
|
43
|
+
return out;
|
|
44
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,50 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mccaskie-labs/workbench-config",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Workbench app configuration: WORKBENCH_ENV, typed variables that fail by name, secrets that are never printed, and the capabilities manifest.",
|
|
5
|
+
"license": "UNLICENSED",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/mccaskie-labs/workbench.git",
|
|
10
|
+
"directory": "packages/config"
|
|
11
|
+
},
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": ">=24"
|
|
14
|
+
},
|
|
15
|
+
"sideEffects": false,
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"default": "./dist/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./capabilities/*.json": "./capabilities/*.json",
|
|
22
|
+
"./package.json": "./package.json"
|
|
23
|
+
},
|
|
24
|
+
"bin": {
|
|
25
|
+
"workbench-config": "./dist/cli.js"
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist",
|
|
29
|
+
"capabilities",
|
|
30
|
+
"README.md",
|
|
31
|
+
"CHANGELOG.md"
|
|
32
|
+
],
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"access": "public"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"typecheck": "tsc -p tsconfig.json --noEmit && tsc -p test/tsconfig.json",
|
|
38
|
+
"test": "vitest run",
|
|
39
|
+
"build": "node scripts/build.mjs",
|
|
40
|
+
"prepack": "node scripts/build.mjs"
|
|
41
|
+
},
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"zod": "^4.1.0"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@types/node": "24.19.2",
|
|
47
|
+
"vitest": "^5.1.0",
|
|
48
|
+
"zod": "4.6.7"
|
|
49
|
+
}
|
|
50
|
+
}
|