@hubble-ventures/infisicml 1.2.1 → 2.0.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/CHANGELOG.md +66 -1
- package/README.md +94 -94
- package/dist/aliases.d.ts +11 -5
- package/dist/aliases.d.ts.map +1 -1
- package/dist/aliases.js +20 -12
- package/dist/aliases.js.map +1 -1
- package/dist/ci-skip.d.ts +32 -15
- package/dist/ci-skip.d.ts.map +1 -1
- package/dist/ci-skip.js +48 -39
- package/dist/ci-skip.js.map +1 -1
- package/dist/commands/export-gha.d.ts +16 -0
- package/dist/commands/export-gha.d.ts.map +1 -1
- package/dist/commands/export-gha.js +48 -39
- package/dist/commands/export-gha.js.map +1 -1
- package/dist/commands/list.d.ts.map +1 -1
- package/dist/commands/list.js +17 -25
- package/dist/commands/list.js.map +1 -1
- package/dist/commands/paths.d.ts.map +1 -1
- package/dist/commands/paths.js +11 -10
- package/dist/commands/paths.js.map +1 -1
- package/dist/commands/run.d.ts.map +1 -1
- package/dist/commands/run.js +6 -3
- package/dist/commands/run.js.map +1 -1
- package/dist/commands/validate.d.ts.map +1 -1
- package/dist/commands/validate.js +1 -11
- package/dist/commands/validate.js.map +1 -1
- package/dist/github-env.js +1 -1
- package/dist/github-env.js.map +1 -1
- package/dist/include.d.ts +6 -43
- package/dist/include.d.ts.map +1 -1
- package/dist/include.js +11 -67
- package/dist/include.js.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/dist/manifest.d.ts +14 -35
- package/dist/manifest.d.ts.map +1 -1
- package/dist/manifest.js +26 -85
- package/dist/manifest.js.map +1 -1
- package/dist/pull.d.ts.map +1 -1
- package/dist/pull.js +11 -16
- package/dist/pull.js.map +1 -1
- package/dist/tree.d.ts +49 -0
- package/dist/tree.d.ts.map +1 -0
- package/dist/tree.js +190 -0
- package/dist/tree.js.map +1 -0
- package/package.json +4 -2
- package/schema/secrets.schema.json +49 -43
package/dist/include.js
CHANGED
|
@@ -1,82 +1,26 @@
|
|
|
1
|
-
import { resolveAliases } from "./aliases.js";
|
|
2
1
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* (so the source value exists to materialize the target). Phantom entries — an
|
|
9
|
-
* alias target that isn't a real vault key — simply miss on fetch, which is
|
|
10
|
-
* harmless: the post-fetch {@link selectEmittedSecrets} still validates the
|
|
11
|
-
* emitted set against `include`, so a genuinely-missing key fails there exactly
|
|
12
|
-
* as in folder mode.
|
|
2
|
+
* A declared key (a tree `raw` entry or `aliased` source) that no folder
|
|
3
|
+
* produced is treated like a missing required key: fail, unless it's listed in
|
|
4
|
+
* the environment's `optionalKeys`, in which case it's downgraded to a
|
|
5
|
+
* `::notice::`. Enforced identically in `pull` and `export-gha` so the two
|
|
6
|
+
* surfaces stay consistent.
|
|
13
7
|
*/
|
|
14
|
-
export function
|
|
15
|
-
const aliases = resolveAliases(manifest);
|
|
16
|
-
const keys = new Set();
|
|
17
|
-
for (const name of include) {
|
|
18
|
-
keys.add(name);
|
|
19
|
-
for (const { source, targets } of aliases) {
|
|
20
|
-
if (targets.includes(name))
|
|
21
|
-
keys.add(source);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
return [...keys];
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Filter a materialized secret map down to the `include` allowlist.
|
|
28
|
-
*
|
|
29
|
-
* Runs *after* {@link applyAliases}, so it filters the final set of names: an
|
|
30
|
-
* alias whose source isn't listed still emits its target, and a canonical key
|
|
31
|
-
* not listed is dropped even when its alias target is kept.
|
|
32
|
-
*
|
|
33
|
-
* When `include` is `undefined` this is a pass-through (emit all keys) — the
|
|
34
|
-
* backward-compatible default. Returns a new object; the input is not mutated.
|
|
35
|
-
*/
|
|
36
|
-
export function applyInclude(merged, include) {
|
|
37
|
-
if (include === undefined) {
|
|
38
|
-
return { filtered: { ...merged }, unknown: [] };
|
|
39
|
-
}
|
|
40
|
-
const allow = new Set(include);
|
|
41
|
-
const filtered = {};
|
|
42
|
-
for (const [key, value] of Object.entries(merged)) {
|
|
43
|
-
if (allow.has(key))
|
|
44
|
-
filtered[key] = value;
|
|
45
|
-
}
|
|
46
|
-
const unknown = include.filter((name) => !(name in merged));
|
|
47
|
-
return { filtered, unknown };
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* An `include` name that no folder produced is treated like a missing required
|
|
51
|
-
* key: fail, unless it's listed in the environment's `optionalKeys`, in which
|
|
52
|
-
* case it's downgraded to a `::notice::`. Enforced identically in `pull` and
|
|
53
|
-
* `export-gha` so the two surfaces stay consistent.
|
|
54
|
-
*/
|
|
55
|
-
export function enforceIncludeKnown(unknown, optionalKeys) {
|
|
8
|
+
export function enforceKnownKeys(unknown, optionalKeys) {
|
|
56
9
|
const optional = new Set(optionalKeys);
|
|
57
10
|
const missing = [];
|
|
58
|
-
|
|
11
|
+
// Dedupe: the same key name can be declared-and-absent in more than one
|
|
12
|
+
// folder, which would otherwise notice/report it twice.
|
|
13
|
+
for (const name of new Set(unknown)) {
|
|
59
14
|
if (optional.has(name)) {
|
|
60
|
-
console.log(`::notice::
|
|
15
|
+
console.log(`::notice::declared key ${name} not produced by its folder (optional for this environment)`);
|
|
61
16
|
}
|
|
62
17
|
else {
|
|
63
18
|
missing.push(name);
|
|
64
19
|
}
|
|
65
20
|
}
|
|
66
21
|
if (missing.length > 0) {
|
|
67
|
-
throw new Error(`
|
|
22
|
+
throw new Error(`tree declares key(s) not produced by any pulled folder: ${missing.join(", ")}. ` +
|
|
68
23
|
"Fix the name, add the folder, or list the key in environments.<slug>.optionalKeys to allow absence.");
|
|
69
24
|
}
|
|
70
25
|
}
|
|
71
|
-
/**
|
|
72
|
-
* Shared allowlist step for both emit surfaces: filter the aliased map to the
|
|
73
|
-
* (already-resolved) `include` and enforce the unknown-key policy. Callers
|
|
74
|
-
* resolve `include` once — with {@link resolveInclude} — so the value they use
|
|
75
|
-
* for headers/logging is the same one that governs the filter.
|
|
76
|
-
*/
|
|
77
|
-
export function selectEmittedSecrets(aliased, include, optionalKeys) {
|
|
78
|
-
const { filtered, unknown } = applyInclude(aliased, include);
|
|
79
|
-
enforceIncludeKnown(unknown, optionalKeys);
|
|
80
|
-
return filtered;
|
|
81
|
-
}
|
|
82
26
|
//# sourceMappingURL=include.js.map
|
package/dist/include.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"include.js","sourceRoot":"","sources":["../src/include.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"include.js","sourceRoot":"","sources":["../src/include.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAC9B,OAAiB,EACjB,YAAsB;IAEtB,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,YAAY,CAAC,CAAC;IACvC,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,wEAAwE;IACxE,wDAAwD;IACxD,KAAK,MAAM,IAAI,IAAI,IAAI,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;QACpC,IAAI,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACvB,OAAO,CAAC,GAAG,CACT,0BAA0B,IAAI,6DAA6D,CAC5F,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACrB,CAAC;IACH,CAAC;IACD,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CACb,2DAA2D,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI;YAC/E,qGAAqG,CACxG,CAAC;IACJ,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
export { applyAliases, type ResolvedAlias, resolveAliases, } from "./aliases.js";
|
|
2
|
-
export {
|
|
2
|
+
export { fetchCompiledFolders, type FolderSecrets, isCi, keysForCiStub, materializeSecrets, mergeFolderSecrets, shouldSkipInfisicalPull, } from "./ci-skip.js";
|
|
3
3
|
export { type AdvertiseKeysHook, defineConfig, type DiscoveryConfig, type InfisicmlConfig, loadConfig, type ResolvedConfig, } from "./config.js";
|
|
4
4
|
export { parseDotenv, serializeDotenv } from "./dotenv.js";
|
|
5
5
|
export { normalizeEnvSlug } from "./env-slug.js";
|
|
6
6
|
export { appendPlainToGithubEnv, appendSecretsToGithubEnv, appendSecretToGithubEnv, } from "./github-env.js";
|
|
7
7
|
export { type AdvertiseInput, keysForScope, runAdvertiseKeysHooks, } from "./hooks.js";
|
|
8
|
-
export {
|
|
9
|
-
export { loadManifestJson, normalizeFolderPath,
|
|
8
|
+
export { enforceKnownKeys } from "./include.js";
|
|
9
|
+
export { loadManifestJson, normalizeFolderPath, resolveCompiledFolders, resolveFetchMode, resolveSecretsOutputPath, type SecretsManifest, secretsManifestSchema, } from "./manifest.js";
|
|
10
10
|
export { logMissingOptionalKeys, resolveOptionalKeys, } from "./optional-keys.js";
|
|
11
11
|
export { commandExists, LocalProvider } from "./providers/local.js";
|
|
12
12
|
export { RemoteProvider } from "./providers/remote.js";
|
|
13
13
|
export type { SecretsProvider } from "./providers/types.js";
|
|
14
14
|
export { type PullResult, pullManifest, writeInjectedSecretsStub, } from "./pull.js";
|
|
15
15
|
export { discoverManifests, type PackageManifest } from "./registry.js";
|
|
16
|
+
export { type CompiledFolder, type CompiledKey, compileTree, type FolderArray, type FolderEntry, type SecretsTree, treeSchema, } from "./tree.js";
|
|
16
17
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,KAAK,aAAa,EAClB,cAAc,GACf,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,oBAAoB,EACpB,IAAI,EACJ,aAAa,EACb,kBAAkB,EAClB,uBAAuB,GACxB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,KAAK,iBAAiB,EACtB,YAAY,EACZ,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,UAAU,EACV,KAAK,cAAc,GACpB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EACL,sBAAsB,EACtB,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,KAAK,cAAc,EACnB,YAAY,EACZ,qBAAqB,GACtB,MAAM,YAAY,CAAC;AACpB,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,KAAK,aAAa,EAClB,cAAc,GACf,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,oBAAoB,EACpB,KAAK,aAAa,EAClB,IAAI,EACJ,aAAa,EACb,kBAAkB,EAClB,kBAAkB,EAClB,uBAAuB,GACxB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,KAAK,iBAAiB,EACtB,YAAY,EACZ,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,UAAU,EACV,KAAK,cAAc,GACpB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EACL,sBAAsB,EACtB,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,KAAK,cAAc,EACnB,YAAY,EACZ,qBAAqB,GACtB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,sBAAsB,EACtB,gBAAgB,EAChB,wBAAwB,EACxB,KAAK,eAAe,EACpB,qBAAqB,GACtB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,YAAY,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EACL,KAAK,UAAU,EACf,YAAY,EACZ,wBAAwB,GACzB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,iBAAiB,EAAE,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC;AACxE,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,WAAW,EACX,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,UAAU,GACX,MAAM,WAAW,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
export { applyAliases, resolveAliases, } from "./aliases.js";
|
|
2
|
-
export {
|
|
2
|
+
export { fetchCompiledFolders, isCi, keysForCiStub, materializeSecrets, mergeFolderSecrets, shouldSkipInfisicalPull, } from "./ci-skip.js";
|
|
3
3
|
export { defineConfig, loadConfig, } from "./config.js";
|
|
4
4
|
export { parseDotenv, serializeDotenv } from "./dotenv.js";
|
|
5
5
|
export { normalizeEnvSlug } from "./env-slug.js";
|
|
6
6
|
export { appendPlainToGithubEnv, appendSecretsToGithubEnv, appendSecretToGithubEnv, } from "./github-env.js";
|
|
7
7
|
export { keysForScope, runAdvertiseKeysHooks, } from "./hooks.js";
|
|
8
|
-
export {
|
|
9
|
-
export { loadManifestJson, normalizeFolderPath,
|
|
8
|
+
export { enforceKnownKeys } from "./include.js";
|
|
9
|
+
export { loadManifestJson, normalizeFolderPath, resolveCompiledFolders, resolveFetchMode, resolveSecretsOutputPath, secretsManifestSchema, } from "./manifest.js";
|
|
10
10
|
export { logMissingOptionalKeys, resolveOptionalKeys, } from "./optional-keys.js";
|
|
11
11
|
export { commandExists, LocalProvider } from "./providers/local.js";
|
|
12
12
|
export { RemoteProvider } from "./providers/remote.js";
|
|
13
13
|
export { pullManifest, writeInjectedSecretsStub, } from "./pull.js";
|
|
14
14
|
export { discoverManifests } from "./registry.js";
|
|
15
|
+
export { compileTree, treeSchema, } from "./tree.js";
|
|
15
16
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAEZ,cAAc,GACf,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,oBAAoB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAEZ,cAAc,GACf,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,oBAAoB,EAEpB,IAAI,EACJ,aAAa,EACb,kBAAkB,EAClB,kBAAkB,EAClB,uBAAuB,GACxB,MAAM,cAAc,CAAC;AACtB,OAAO,EAEL,YAAY,EAGZ,UAAU,GAEX,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EACL,sBAAsB,EACtB,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAEL,YAAY,EACZ,qBAAqB,GACtB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,sBAAsB,EACtB,gBAAgB,EAChB,wBAAwB,EAExB,qBAAqB,GACtB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,EAEL,YAAY,EACZ,wBAAwB,GACzB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,iBAAiB,EAAwB,MAAM,eAAe,CAAC;AACxE,OAAO,EAGL,WAAW,EAIX,UAAU,GACX,MAAM,WAAW,CAAC"}
|
package/dist/manifest.d.ts
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { type CompiledFolder } from "./tree.js";
|
|
2
3
|
export declare const secretsManifestSchema: z.ZodObject<{
|
|
3
4
|
$schema: z.ZodOptional<z.ZodString>;
|
|
4
|
-
|
|
5
|
+
secrets: z.ZodType<import("./tree.js").SecretsTree, z.ZodTypeDef, import("./tree.js").SecretsTree>;
|
|
5
6
|
profiles: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
6
|
-
|
|
7
|
-
include: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
7
|
+
secrets: z.ZodType<import("./tree.js").SecretsTree, z.ZodTypeDef, import("./tree.js").SecretsTree>;
|
|
8
8
|
fetch: z.ZodOptional<z.ZodEnum<["folder", "keys"]>>;
|
|
9
9
|
}, "strip", z.ZodTypeAny, {
|
|
10
|
-
|
|
11
|
-
include?: string[] | undefined;
|
|
10
|
+
secrets: import("./tree.js").SecretsTree;
|
|
12
11
|
fetch?: "keys" | "folder" | undefined;
|
|
13
12
|
}, {
|
|
14
|
-
|
|
15
|
-
include?: string[] | undefined;
|
|
13
|
+
secrets: import("./tree.js").SecretsTree;
|
|
16
14
|
fetch?: "keys" | "folder" | undefined;
|
|
17
15
|
}>>>;
|
|
18
16
|
ci: z.ZodOptional<z.ZodObject<{
|
|
@@ -26,8 +24,6 @@ export declare const secretsManifestSchema: z.ZodObject<{
|
|
|
26
24
|
stubInCi?: boolean | undefined;
|
|
27
25
|
}>>;
|
|
28
26
|
output: z.ZodOptional<z.ZodString>;
|
|
29
|
-
aliases: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>>;
|
|
30
|
-
include: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
31
27
|
fetch: z.ZodOptional<z.ZodEnum<["folder", "keys"]>>;
|
|
32
28
|
environments: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
33
29
|
optionalKeys: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
@@ -37,13 +33,11 @@ export declare const secretsManifestSchema: z.ZodObject<{
|
|
|
37
33
|
optionalKeys?: string[] | undefined;
|
|
38
34
|
}>>>;
|
|
39
35
|
}, "strip", z.ZodTypeAny, {
|
|
40
|
-
|
|
36
|
+
secrets: import("./tree.js").SecretsTree;
|
|
41
37
|
$schema?: string | undefined;
|
|
42
|
-
include?: string[] | undefined;
|
|
43
38
|
fetch?: "keys" | "folder" | undefined;
|
|
44
39
|
profiles?: Record<string, {
|
|
45
|
-
|
|
46
|
-
include?: string[] | undefined;
|
|
40
|
+
secrets: import("./tree.js").SecretsTree;
|
|
47
41
|
fetch?: "keys" | "folder" | undefined;
|
|
48
42
|
}> | undefined;
|
|
49
43
|
ci?: {
|
|
@@ -51,18 +45,15 @@ export declare const secretsManifestSchema: z.ZodObject<{
|
|
|
51
45
|
stubInCi?: boolean | undefined;
|
|
52
46
|
} | undefined;
|
|
53
47
|
output?: string | undefined;
|
|
54
|
-
aliases?: Record<string, string | string[]> | undefined;
|
|
55
48
|
environments?: Record<string, {
|
|
56
49
|
optionalKeys?: string[] | undefined;
|
|
57
50
|
}> | undefined;
|
|
58
51
|
}, {
|
|
59
|
-
|
|
52
|
+
secrets: import("./tree.js").SecretsTree;
|
|
60
53
|
$schema?: string | undefined;
|
|
61
|
-
include?: string[] | undefined;
|
|
62
54
|
fetch?: "keys" | "folder" | undefined;
|
|
63
55
|
profiles?: Record<string, {
|
|
64
|
-
|
|
65
|
-
include?: string[] | undefined;
|
|
56
|
+
secrets: import("./tree.js").SecretsTree;
|
|
66
57
|
fetch?: "keys" | "folder" | undefined;
|
|
67
58
|
}> | undefined;
|
|
68
59
|
ci?: {
|
|
@@ -70,36 +61,24 @@ export declare const secretsManifestSchema: z.ZodObject<{
|
|
|
70
61
|
stubInCi?: boolean | undefined;
|
|
71
62
|
} | undefined;
|
|
72
63
|
output?: string | undefined;
|
|
73
|
-
aliases?: Record<string, string | string[]> | undefined;
|
|
74
64
|
environments?: Record<string, {
|
|
75
65
|
optionalKeys?: string[] | undefined;
|
|
76
66
|
}> | undefined;
|
|
77
67
|
}>;
|
|
78
68
|
export type SecretsManifest = z.infer<typeof secretsManifestSchema>;
|
|
79
69
|
export declare function loadManifestJson(raw: unknown): SecretsManifest;
|
|
80
|
-
/** Profile paths replace default paths when a profile is set. */
|
|
81
|
-
export declare function resolvePaths(manifest: SecretsManifest, profile?: string): string[];
|
|
82
70
|
/**
|
|
83
|
-
*
|
|
84
|
-
* `
|
|
85
|
-
*
|
|
71
|
+
* Compile the effective folder tree into an ordered {@link CompiledFolder} list.
|
|
72
|
+
* A profile's `tree` replaces the root `tree` when a profile is set (same
|
|
73
|
+
* replace-not-merge as v1 `paths`). Throws on an unknown profile name.
|
|
86
74
|
*/
|
|
87
|
-
export declare function
|
|
75
|
+
export declare function resolveCompiledFolders(manifest: SecretsManifest, profile?: string): CompiledFolder[];
|
|
88
76
|
/**
|
|
89
77
|
* Resolve the effective fetch mode. A profile's `fetch` replaces the root
|
|
90
78
|
* `fetch` when the profile defines it; otherwise the root `fetch` applies.
|
|
91
|
-
* Defaults to `"folder"` (whole-folder read + local
|
|
79
|
+
* Defaults to `"folder"` (whole-folder read + local select) when unset.
|
|
92
80
|
*/
|
|
93
81
|
export declare function resolveFetchMode(manifest: SecretsManifest, profile?: string): "folder" | "keys";
|
|
94
|
-
/**
|
|
95
|
-
* Cross-field rule: `fetch: "keys"` requires an `include` allowlist, because
|
|
96
|
-
* key mode fetches exactly the keys `include` names. The check spans the root
|
|
97
|
-
* and every profile (a profile's `fetch`/`include` each replace the root's), so
|
|
98
|
-
* every runnable combination is covered. Returns human-readable issue strings
|
|
99
|
-
* (empty when consistent) for `validate` to surface. Zod can't express this —
|
|
100
|
-
* the requirement depends on the resolved profile.
|
|
101
|
-
*/
|
|
102
|
-
export declare function checkFetchIncludeConsistency(manifest: SecretsManifest): string[];
|
|
103
82
|
export declare function normalizeFolderPath(folder: string): string;
|
|
104
83
|
export declare function resolveSecretsOutputPath(manifestDir: string, outputName: string): string;
|
|
105
84
|
//# sourceMappingURL=manifest.d.ts.map
|
package/dist/manifest.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,KAAK,cAAc,EAGpB,MAAM,WAAW,CAAC;AASnB,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyChC,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,GAAG,eAAe,CAE9D;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,eAAe,EACzB,OAAO,CAAC,EAAE,MAAM,GACf,cAAc,EAAE,CASlB;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,eAAe,EACzB,OAAO,CAAC,EAAE,MAAM,GACf,QAAQ,GAAG,MAAM,CAMnB;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAE1D;AAED,wBAAgB,wBAAwB,CACtC,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,GACjB,MAAM,CAiBR"}
|
package/dist/manifest.js
CHANGED
|
@@ -1,39 +1,25 @@
|
|
|
1
1
|
import { resolve, sep } from "node:path";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
|
|
4
|
-
const pathsSchema = z
|
|
5
|
-
.array(z.string().regex(pathPattern))
|
|
6
|
-
.min(1, "paths must be a non-empty array");
|
|
7
|
-
const envVarNamePattern = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
8
|
-
const aliasSourceSchema = z
|
|
9
|
-
.string()
|
|
10
|
-
.regex(envVarNamePattern, "alias source must be a valid env var name");
|
|
11
|
-
const aliasTargetSchema = z
|
|
12
|
-
.string()
|
|
13
|
-
.regex(envVarNamePattern, "alias target must be a valid env var name");
|
|
14
|
-
// Key-level allowlist. When present, only these env var names are emitted from
|
|
15
|
-
// whatever the folders yielded (after aliases). `.min(1)` because an empty
|
|
16
|
-
// allowlist is almost certainly a mistake — omit the field to emit every key.
|
|
17
|
-
const includeSchema = z
|
|
18
|
-
.array(z.string().regex(envVarNamePattern, "include entry must be a valid env var name"))
|
|
19
|
-
.min(1, "include must be a non-empty array");
|
|
3
|
+
import { compileTree, treeSchema, } from "./tree.js";
|
|
20
4
|
// How secrets are read from the vault. `folder` (default) fetches whole folders
|
|
21
|
-
// and
|
|
22
|
-
// so the vault never transmits the rest — wire-level least
|
|
23
|
-
//
|
|
24
|
-
//
|
|
5
|
+
// and selects the declared keys locally. `keys` fetches only the exact keys the
|
|
6
|
+
// tree declares, so the vault never transmits the rest — wire-level least
|
|
7
|
+
// privilege. Because the tree always names every key, `keys` needs no separate
|
|
8
|
+
// allowlist (unlike v1, where it required `include`).
|
|
25
9
|
const fetchModeSchema = z.enum(["folder", "keys"]);
|
|
26
10
|
export const secretsManifestSchema = z.object({
|
|
27
11
|
$schema: z.string().optional(),
|
|
28
|
-
|
|
12
|
+
// The folder tree: an array of `{ folder: [ ...contents ] }` objects naming
|
|
13
|
+
// which Infisical folders to pull and, per folder, exactly which keys to emit
|
|
14
|
+
// (bare strings) and how to alias them (`{ SOURCE: "TARGET" }`). Subfolders
|
|
15
|
+
// nest as `{ name: [ ... ] }`. See tree.ts for the entry grammar.
|
|
16
|
+
secrets: treeSchema,
|
|
29
17
|
profiles: z
|
|
30
18
|
.record(z.string(), z.object({
|
|
31
|
-
|
|
32
|
-
//
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
// Overrides the root `fetch` for this profile when set (same
|
|
36
|
-
// replace-not-merge as `paths` / `include`).
|
|
19
|
+
// Replaces the root `secrets` for this profile when running with
|
|
20
|
+
// --profile (same replace-not-merge as v1 `paths`).
|
|
21
|
+
secrets: treeSchema,
|
|
22
|
+
// Overrides the root `fetch` for this profile when set.
|
|
37
23
|
fetch: fetchModeSchema.optional(),
|
|
38
24
|
}))
|
|
39
25
|
.optional(),
|
|
@@ -47,23 +33,9 @@ export const secretsManifestSchema = z.object({
|
|
|
47
33
|
.string()
|
|
48
34
|
.regex(/^[^/\\]+$/)
|
|
49
35
|
.optional(),
|
|
50
|
-
//
|
|
51
|
-
//
|
|
52
|
-
//
|
|
53
|
-
// convention-prefixed name — Vite reads VITE_*, Next reads NEXT_PUBLIC_*.
|
|
54
|
-
// Declaring the mapping here means every consumer (CI export-gha, local pull)
|
|
55
|
-
// emits the right name instead of each workflow re-deriving it.
|
|
56
|
-
aliases: z
|
|
57
|
-
.record(aliasSourceSchema, z.union([aliasTargetSchema, z.array(aliasTargetSchema).min(1)]))
|
|
58
|
-
.optional(),
|
|
59
|
-
// Emit only these keys from whatever the folders yielded (default-deny key
|
|
60
|
-
// selection). Applied after `aliases`, to the final set of names — so a client
|
|
61
|
-
// can pull a shared vendor folder but emit only its public key. Absent = emit
|
|
62
|
-
// all (backward compatible). A per-profile `include` replaces this one.
|
|
63
|
-
include: includeSchema.optional(),
|
|
64
|
-
// Read strategy: `folder` (default) pulls whole folders and filters locally;
|
|
65
|
-
// `keys` pulls only the keys `include` resolves to (least privilege at the
|
|
66
|
-
// wire). A per-profile `fetch` replaces this one.
|
|
36
|
+
// Read strategy: `folder` (default) pulls whole folders and selects the
|
|
37
|
+
// declared keys locally; `keys` pulls only the declared keys (least privilege
|
|
38
|
+
// at the wire). A per-profile `fetch` replaces this one.
|
|
67
39
|
fetch: fetchModeSchema.optional(),
|
|
68
40
|
environments: z
|
|
69
41
|
.record(z.string(), z.object({
|
|
@@ -74,34 +46,25 @@ export const secretsManifestSchema = z.object({
|
|
|
74
46
|
export function loadManifestJson(raw) {
|
|
75
47
|
return secretsManifestSchema.parse(raw);
|
|
76
48
|
}
|
|
77
|
-
/**
|
|
78
|
-
|
|
49
|
+
/**
|
|
50
|
+
* Compile the effective folder tree into an ordered {@link CompiledFolder} list.
|
|
51
|
+
* A profile's `tree` replaces the root `tree` when a profile is set (same
|
|
52
|
+
* replace-not-merge as v1 `paths`). Throws on an unknown profile name.
|
|
53
|
+
*/
|
|
54
|
+
export function resolveCompiledFolders(manifest, profile) {
|
|
79
55
|
if (profile) {
|
|
80
56
|
const profileConfig = manifest.profiles?.[profile];
|
|
81
57
|
if (!profileConfig) {
|
|
82
58
|
throw new Error(`Unknown profile '${profile}' in secrets.json`);
|
|
83
59
|
}
|
|
84
|
-
return profileConfig.
|
|
60
|
+
return compileTree(profileConfig.secrets);
|
|
85
61
|
}
|
|
86
|
-
return manifest.
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Resolve the effective key allowlist. A profile's `include` replaces the root
|
|
90
|
-
* `include` when the profile defines it; otherwise the root `include` applies.
|
|
91
|
-
* Returns `undefined` when no allowlist is in effect (emit all keys).
|
|
92
|
-
*/
|
|
93
|
-
export function resolveInclude(manifest, profile) {
|
|
94
|
-
if (profile) {
|
|
95
|
-
const profileInclude = manifest.profiles?.[profile]?.include;
|
|
96
|
-
if (profileInclude !== undefined)
|
|
97
|
-
return profileInclude;
|
|
98
|
-
}
|
|
99
|
-
return manifest.include;
|
|
62
|
+
return compileTree(manifest.secrets);
|
|
100
63
|
}
|
|
101
64
|
/**
|
|
102
65
|
* Resolve the effective fetch mode. A profile's `fetch` replaces the root
|
|
103
66
|
* `fetch` when the profile defines it; otherwise the root `fetch` applies.
|
|
104
|
-
* Defaults to `"folder"` (whole-folder read + local
|
|
67
|
+
* Defaults to `"folder"` (whole-folder read + local select) when unset.
|
|
105
68
|
*/
|
|
106
69
|
export function resolveFetchMode(manifest, profile) {
|
|
107
70
|
if (profile) {
|
|
@@ -111,28 +74,6 @@ export function resolveFetchMode(manifest, profile) {
|
|
|
111
74
|
}
|
|
112
75
|
return manifest.fetch ?? "folder";
|
|
113
76
|
}
|
|
114
|
-
/**
|
|
115
|
-
* Cross-field rule: `fetch: "keys"` requires an `include` allowlist, because
|
|
116
|
-
* key mode fetches exactly the keys `include` names. The check spans the root
|
|
117
|
-
* and every profile (a profile's `fetch`/`include` each replace the root's), so
|
|
118
|
-
* every runnable combination is covered. Returns human-readable issue strings
|
|
119
|
-
* (empty when consistent) for `validate` to surface. Zod can't express this —
|
|
120
|
-
* the requirement depends on the resolved profile.
|
|
121
|
-
*/
|
|
122
|
-
export function checkFetchIncludeConsistency(manifest) {
|
|
123
|
-
const issues = [];
|
|
124
|
-
const check = (profile, label) => {
|
|
125
|
-
if (resolveFetchMode(manifest, profile) === "keys" &&
|
|
126
|
-
resolveInclude(manifest, profile) === undefined) {
|
|
127
|
-
issues.push(`fetch: "keys" requires an include allowlist (${label})`);
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
check(undefined, "root");
|
|
131
|
-
for (const name of Object.keys(manifest.profiles ?? {})) {
|
|
132
|
-
check(name, `profile "${name}"`);
|
|
133
|
-
}
|
|
134
|
-
return issues;
|
|
135
|
-
}
|
|
136
77
|
export function normalizeFolderPath(folder) {
|
|
137
78
|
return `/${folder.replace(/^\/+/, "")}`;
|
|
138
79
|
}
|
package/dist/manifest.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest.js","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"manifest.js","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAEL,WAAW,EACX,UAAU,GACX,MAAM,WAAW,CAAC;AAEnB,gFAAgF;AAChF,gFAAgF;AAChF,0EAA0E;AAC1E,+EAA+E;AAC/E,sDAAsD;AACtD,MAAM,eAAe,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;AAEnD,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5C,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC9B,4EAA4E;IAC5E,8EAA8E;IAC9E,4EAA4E;IAC5E,kEAAkE;IAClE,OAAO,EAAE,UAAU;IACnB,QAAQ,EAAE,CAAC;SACR,MAAM,CACL,CAAC,CAAC,MAAM,EAAE,EACV,CAAC,CAAC,MAAM,CAAC;QACP,iEAAiE;QACj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ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pull.d.ts","sourceRoot":"","sources":["../src/pull.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAErD,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,SAAS,CAAC;AAE9C,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,EAAE,eAAe,CAAC;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,eAAe,CAAC;CAC3B,CAAC;AAEF,wBAAgB,wBAAwB,CACtC,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,eAAe,EACzB,IAAI,EAAE,MAAM,EAAE,GACb,IAAI,CAgBN;AAED,wBAAsB,YAAY,CAChC,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,UAAU,CAAC,CAgErB"}
|
package/dist/pull.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { existsSync, writeFileSync } from "node:fs";
|
|
2
2
|
import { relative } from "node:path";
|
|
3
|
-
import {
|
|
4
|
-
import { fetchManifestSecrets, keysForCiStub, shouldSkipInfisicalPull, } from "./ci-skip.js";
|
|
3
|
+
import { fetchCompiledFolders, keysForCiStub, materializeSecrets, shouldSkipInfisicalPull, } from "./ci-skip.js";
|
|
5
4
|
import { serializeDotenv } from "./dotenv.js";
|
|
6
|
-
import {
|
|
7
|
-
import { normalizeFolderPath, resolveFetchMode, resolveInclude, resolvePaths, resolveSecretsOutputPath, } from "./manifest.js";
|
|
5
|
+
import { normalizeFolderPath, resolveCompiledFolders, resolveFetchMode, resolveSecretsOutputPath, } from "./manifest.js";
|
|
8
6
|
import { resolveOptionalKeys } from "./optional-keys.js";
|
|
9
7
|
export function writeInjectedSecretsStub(outputPath, manifest, keys) {
|
|
10
8
|
const fromEnv = {};
|
|
@@ -37,25 +35,22 @@ export async function pullManifest(options) {
|
|
|
37
35
|
console.log(`⏭️ ${manifest.id}: skipped Infisical pull (injected env → ${rel})`);
|
|
38
36
|
return "skipped";
|
|
39
37
|
}
|
|
40
|
-
const
|
|
38
|
+
const folders = resolveCompiledFolders(manifest.config, profile);
|
|
41
39
|
const fetchMode = resolveFetchMode(manifest.config, profile);
|
|
42
|
-
|
|
43
|
-
//
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
//
|
|
48
|
-
//
|
|
49
|
-
// explicitly — otherwise the first secret gets glued onto the "# Generated"
|
|
50
|
-
// line.
|
|
40
|
+
// Per-folder fetch → per-folder alias + missing-key enforcement → merge, so a
|
|
41
|
+
// key declared in two folders keeps each folder's value/provenance.
|
|
42
|
+
const folderSecrets = await fetchCompiledFolders(provider, envName, folders, fetchMode);
|
|
43
|
+
const merged = materializeSecrets(folderSecrets, resolveOptionalKeys(manifest.config, envName));
|
|
44
|
+
// filter(Boolean) drops the optional Profile line when absent. It would also
|
|
45
|
+
// drop a trailing "" sentinel, so append the trailing newline explicitly —
|
|
46
|
+
// otherwise the first secret gets glued onto the "# Generated" line.
|
|
51
47
|
const header = `${[
|
|
52
48
|
"# Pulled from Infisical — do not edit. Refresh: infisicml pull",
|
|
53
49
|
`# Package: ${manifest.id}`,
|
|
54
50
|
`# Environment: ${envName}`,
|
|
55
51
|
profile ? `# Profile: ${profile}` : "",
|
|
56
|
-
`# Paths: ${
|
|
52
|
+
`# Paths: ${folders.map((f) => normalizeFolderPath(f.path)).join(", ")}`,
|
|
57
53
|
fetchMode === "keys" ? "# Fetch: keys (per-key least-privilege read)" : "",
|
|
58
|
-
include ? `# Include: ${include.join(", ")}` : "",
|
|
59
54
|
`# Generated: ${new Date().toISOString()}`,
|
|
60
55
|
]
|
|
61
56
|
.filter(Boolean)
|
package/dist/pull.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pull.js","sourceRoot":"","sources":["../src/pull.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,
|
|
1
|
+
{"version":3,"file":"pull.js","sourceRoot":"","sources":["../src/pull.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EACL,oBAAoB,EACpB,aAAa,EACb,kBAAkB,EAClB,uBAAuB,GACxB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,gBAAgB,EAChB,wBAAwB,GACzB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAgBzD,MAAM,UAAU,wBAAwB,CACtC,UAAkB,EAClB,QAAyB,EACzB,IAAc;IAEd,MAAM,OAAO,GAA2B,EAAE,CAAC;IAC3C,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC/B,IAAI,KAAK;YAAE,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IAClC,CAAC;IAED,MAAM,MAAM,GAAG;QACb,sEAAsE;QACtE,cAAc,QAAQ,CAAC,EAAE,EAAE;QAC3B,sDAAsD;QACtD,gBAAgB,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE;QAC1C,EAAE;KACH,CAAC,IAAI,CAAC,IAAI,CAA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;IAC9E,oEAAoE;IACpE,MAAM,aAAa,GAAG,MAAM,oBAAoB,CAC9C,QAAQ,EACR,OAAO,EACP,OAAO,EACP,SAAS,CACV,CAAC;IACF,MAAM,MAAM,GAAG,kBAAkB,CAC/B,aAAa,EACb,mBAAmB,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,CAC9C,CAAC;IAEF,6EAA6E;IAC7E,2EAA2E;IAC3E,qEAAqE;IACrE,MAAM,MAAM,GAAG,GAAG;QAChB,gEAAgE;QAChE,cAAc,QAAQ,CAAC,EAAE,EAAE;QAC3B,kBAAkB,OAAO,EAAE;QAC3B,OAAO,CAAC,CAAC,CAAC,cAAc,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE;QACtC,YAAY,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,mBAAmB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;QACxE,SAAS,KAAK,MAAM,CAAC,CAAC,CAAC,8CAA8C,CAAC,CAAC,CAAC,EAAE;QAC1E,gBAAgB,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE;KAC3C;SACE,MAAM,CAAC,OAAO,CAAC;SACf,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;IAElB,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC;IAC5D,OAAO,CAAC,GAAG,CACT,KAAK,QAAQ,CAAC,EAAE,WAAW,GAAG,KAAK,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,QAAQ,CACtE,CAAC;IACF,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
package/dist/tree.d.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* One entry in a folder's contents array. Either:
|
|
4
|
+
* - a **string** — a plain key emitted as-is, or
|
|
5
|
+
* - an **object** whose entries are, per key, discriminated by value type:
|
|
6
|
+
* - `SOURCE: "TARGET"` (string value) — an alias (the canonical vault key
|
|
7
|
+
* `SOURCE` is emitted and copied to `TARGET`). Multiple targets? Repeat the
|
|
8
|
+
* entry, one target each.
|
|
9
|
+
* - `name: [ ... ]` (array value) — a subfolder (its own contents array).
|
|
10
|
+
*/
|
|
11
|
+
export type FolderEntry = string | {
|
|
12
|
+
[key: string]: string | FolderArray;
|
|
13
|
+
};
|
|
14
|
+
/** A folder's contents: a non-empty array of {@link FolderEntry}. */
|
|
15
|
+
export type FolderArray = FolderEntry[];
|
|
16
|
+
/**
|
|
17
|
+
* The manifest's `secrets`: a non-empty array of single-folder objects
|
|
18
|
+
* (`{ folderName: contentsArray }`) — the top level of the tree.
|
|
19
|
+
*/
|
|
20
|
+
export type SecretsTree = Array<{
|
|
21
|
+
[folder: string]: FolderArray;
|
|
22
|
+
}>;
|
|
23
|
+
/** A single emitted key resolved from a folder (canonical name + aliases). */
|
|
24
|
+
export type CompiledKey = {
|
|
25
|
+
key: string;
|
|
26
|
+
aliases: string[];
|
|
27
|
+
};
|
|
28
|
+
/** A folder path plus the exact keys to emit from it (provenance-aware). */
|
|
29
|
+
export type CompiledFolder = {
|
|
30
|
+
path: string;
|
|
31
|
+
keys: CompiledKey[];
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Schema for the manifest's `secrets`: a non-empty array of folder objects, each
|
|
35
|
+
* validated recursively. Cast to the precise {@link SecretsTree} type — the base
|
|
36
|
+
* `z.array` infers `unknown[]`, but every element is structurally a folder
|
|
37
|
+
* object once {@link validateFolderObject} passes.
|
|
38
|
+
*/
|
|
39
|
+
export declare const treeSchema: z.ZodType<SecretsTree>;
|
|
40
|
+
/**
|
|
41
|
+
* Flatten a validated tree into an ordered list of {@link CompiledFolder}.
|
|
42
|
+
* String entries carry no aliases; each `SOURCE: "TARGET"` entry carries its
|
|
43
|
+
* single target (repeat the entry for several targets). A folder's own keys are
|
|
44
|
+
* emitted before recursing into its subfolders, so declaration order is
|
|
45
|
+
* preserved (last folder wins on a genuine cross-folder name collision at merge
|
|
46
|
+
* time).
|
|
47
|
+
*/
|
|
48
|
+
export declare function compileTree(secrets: SecretsTree): CompiledFolder[];
|
|
49
|
+
//# sourceMappingURL=tree.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["../src/tree.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAWxB;;;;;;;;GAQG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,WAAW,CAAA;CAAE,CAAC;AAE3E,qEAAqE;AACrE,MAAM,MAAM,WAAW,GAAG,WAAW,EAAE,CAAC;AAExC;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,KAAK,CAAC;IAAE,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,CAAA;CAAE,CAAC,CAAC;AAEnE,8EAA8E;AAC9E,MAAM,MAAM,WAAW,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AAE7D,4EAA4E;AAC5E,MAAM,MAAM,cAAc,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,WAAW,EAAE,CAAA;CAAE,CAAC;AAkJnE;;;;;GAKG;AACH,eAAO,MAAM,UAAU,EAUJ,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;AAE1C;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,WAAW,GAAG,cAAc,EAAE,CAQlE"}
|