@kitsy/cnos 0.0.1 → 1.0.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/README.md +3 -1
- package/dist/chunk-44JOQPSN.js +109 -0
- package/dist/chunk-ASZ7I3JJ.js +35 -0
- package/dist/chunk-CGTFH4QQ.js +49 -0
- package/dist/chunk-GGYIRIGU.js +83 -0
- package/dist/chunk-H65FPTDM.js +23 -0
- package/dist/chunk-K2T4R5WH.js +1565 -0
- package/dist/chunk-KG6OZX5C.js +202 -0
- package/dist/envNaming-BrOk5ndZ.d.cts +8 -0
- package/dist/envNaming-DCaNdnrF.d.ts +8 -0
- package/dist/index.cjs +1942 -28
- package/dist/index.d.cts +7 -3
- package/dist/index.d.ts +7 -3
- package/dist/index.js +112 -23
- package/dist/internal.cjs +288 -0
- package/dist/internal.d.cts +20 -0
- package/dist/internal.d.ts +20 -0
- package/dist/internal.js +18 -0
- package/dist/plugin/basic-schema.cjs +214 -3
- package/dist/plugin/basic-schema.d.cts +5 -6
- package/dist/plugin/basic-schema.d.ts +5 -6
- package/dist/plugin/basic-schema.js +7 -2
- package/dist/plugin/cli-args.cjs +132 -3
- package/dist/plugin/cli-args.d.cts +12 -1
- package/dist/plugin/cli-args.d.ts +12 -1
- package/dist/plugin/cli-args.js +11 -2
- package/dist/plugin/dotenv.cjs +212 -3
- package/dist/plugin/dotenv.d.cts +8 -1
- package/dist/plugin/dotenv.d.ts +8 -1
- package/dist/plugin/dotenv.js +11 -2
- package/dist/plugin/env-export.cjs +222 -3
- package/dist/plugin/env-export.d.cts +7 -1
- package/dist/plugin/env-export.d.ts +7 -1
- package/dist/plugin/env-export.js +14 -2
- package/dist/plugin/filesystem.cjs +320 -3
- package/dist/plugin/filesystem.d.cts +17 -1
- package/dist/plugin/filesystem.d.ts +17 -1
- package/dist/plugin/filesystem.js +17 -2
- package/dist/plugin/process-env.cjs +126 -3
- package/dist/plugin/process-env.d.cts +7 -1
- package/dist/plugin/process-env.d.ts +7 -1
- package/dist/plugin/process-env.js +9 -2
- package/dist/plugin-BVNEHj19.d.cts +309 -0
- package/dist/plugin-BVNEHj19.d.ts +309 -0
- package/dist/toPublicEnv-Dd152fFy.d.cts +7 -0
- package/dist/toPublicEnv-Gwz3xTK0.d.ts +7 -0
- package/package.json +15 -16
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import { CnosCreateOptions, CnosRuntime, CnosPlugin } from '
|
|
2
|
-
export {
|
|
1
|
+
import { R as ResolvedGraph, D as DumpPlanOptions, a as DumpPlan, b as DumpOptions, c as DumpResult, C as CnosCreateOptions, d as CnosRuntime, e as CnosPlugin } from './plugin-BVNEHj19.cjs';
|
|
2
|
+
export { f as ConfigEntry, I as InspectResult, L as LoaderPlugin, g as LogicalKey, M as ManifestFile, N as NormalizedManifest, T as ToEnvOptions, h as ToPublicEnvOptions } from './plugin-BVNEHj19.cjs';
|
|
3
|
+
export { t as toEnv, a as toPublicEnv } from './toPublicEnv-Dd152fFy.cjs';
|
|
4
|
+
|
|
5
|
+
declare function planDump(graph: ResolvedGraph, options?: DumpPlanOptions): DumpPlan;
|
|
6
|
+
declare function writeDump(graph: ResolvedGraph, options: DumpOptions): Promise<DumpResult>;
|
|
3
7
|
|
|
4
8
|
declare function createCnos(options?: CnosCreateOptions): Promise<CnosRuntime>;
|
|
5
9
|
|
|
6
10
|
declare function defaultPlugins(): CnosPlugin[];
|
|
7
11
|
|
|
8
|
-
export { createCnos, defaultPlugins };
|
|
12
|
+
export { CnosCreateOptions, CnosPlugin, CnosRuntime, DumpOptions, DumpPlan, DumpPlanOptions, DumpResult, createCnos, defaultPlugins, planDump, writeDump };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import { CnosCreateOptions, CnosRuntime, CnosPlugin } from '
|
|
2
|
-
export {
|
|
1
|
+
import { R as ResolvedGraph, D as DumpPlanOptions, a as DumpPlan, b as DumpOptions, c as DumpResult, C as CnosCreateOptions, d as CnosRuntime, e as CnosPlugin } from './plugin-BVNEHj19.js';
|
|
2
|
+
export { f as ConfigEntry, I as InspectResult, L as LoaderPlugin, g as LogicalKey, M as ManifestFile, N as NormalizedManifest, T as ToEnvOptions, h as ToPublicEnvOptions } from './plugin-BVNEHj19.js';
|
|
3
|
+
export { t as toEnv, a as toPublicEnv } from './toPublicEnv-Gwz3xTK0.js';
|
|
4
|
+
|
|
5
|
+
declare function planDump(graph: ResolvedGraph, options?: DumpPlanOptions): DumpPlan;
|
|
6
|
+
declare function writeDump(graph: ResolvedGraph, options: DumpOptions): Promise<DumpResult>;
|
|
3
7
|
|
|
4
8
|
declare function createCnos(options?: CnosCreateOptions): Promise<CnosRuntime>;
|
|
5
9
|
|
|
6
10
|
declare function defaultPlugins(): CnosPlugin[];
|
|
7
11
|
|
|
8
|
-
export { createCnos, defaultPlugins };
|
|
12
|
+
export { CnosCreateOptions, CnosPlugin, CnosRuntime, DumpOptions, DumpPlan, DumpPlanOptions, DumpResult, createCnos, defaultPlugins, planDump, writeDump };
|
package/dist/index.js
CHANGED
|
@@ -1,22 +1,118 @@
|
|
|
1
|
-
// src/createCnos.ts
|
|
2
1
|
import {
|
|
3
|
-
|
|
4
|
-
} from "
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
createBasicSchemaPlugin
|
|
3
|
+
} from "./chunk-H65FPTDM.js";
|
|
4
|
+
import {
|
|
5
|
+
createCliArgsPlugin
|
|
6
|
+
} from "./chunk-GGYIRIGU.js";
|
|
7
|
+
import {
|
|
8
|
+
createDotenvPlugin
|
|
9
|
+
} from "./chunk-44JOQPSN.js";
|
|
11
10
|
import {
|
|
12
11
|
createEnvExportPlugin,
|
|
13
12
|
createPublicEnvExportPlugin
|
|
14
|
-
} from "
|
|
13
|
+
} from "./chunk-ASZ7I3JJ.js";
|
|
15
14
|
import {
|
|
16
15
|
createFilesystemSecretsPlugin,
|
|
17
16
|
createFilesystemValuesPlugin
|
|
18
|
-
} from "
|
|
19
|
-
import {
|
|
17
|
+
} from "./chunk-KG6OZX5C.js";
|
|
18
|
+
import {
|
|
19
|
+
createProcessEnvPlugin
|
|
20
|
+
} from "./chunk-CGTFH4QQ.js";
|
|
21
|
+
import {
|
|
22
|
+
createCnos,
|
|
23
|
+
createProvenanceInspector,
|
|
24
|
+
planDump,
|
|
25
|
+
toEnv,
|
|
26
|
+
toPublicEnv,
|
|
27
|
+
writeDump
|
|
28
|
+
} from "./chunk-K2T4R5WH.js";
|
|
29
|
+
|
|
30
|
+
// package.json
|
|
31
|
+
var package_default = {
|
|
32
|
+
name: "@kitsy/cnos",
|
|
33
|
+
version: "1.0.1",
|
|
34
|
+
description: "Batteries-included CNOS runtime package wired with the official plugins.",
|
|
35
|
+
type: "module",
|
|
36
|
+
main: "./dist/index.cjs",
|
|
37
|
+
module: "./dist/index.js",
|
|
38
|
+
types: "./dist/index.d.ts",
|
|
39
|
+
exports: {
|
|
40
|
+
".": {
|
|
41
|
+
types: "./dist/index.d.ts",
|
|
42
|
+
import: "./dist/index.js",
|
|
43
|
+
require: "./dist/index.cjs"
|
|
44
|
+
},
|
|
45
|
+
"./internal": {
|
|
46
|
+
types: "./dist/internal.d.ts",
|
|
47
|
+
import: "./dist/internal.js",
|
|
48
|
+
require: "./dist/internal.cjs"
|
|
49
|
+
},
|
|
50
|
+
"./plugins/filesystem": {
|
|
51
|
+
types: "./dist/plugin/filesystem.d.ts",
|
|
52
|
+
import: "./dist/plugin/filesystem.js",
|
|
53
|
+
require: "./dist/plugin/filesystem.cjs"
|
|
54
|
+
},
|
|
55
|
+
"./plugins/dotenv": {
|
|
56
|
+
types: "./dist/plugin/dotenv.d.ts",
|
|
57
|
+
import: "./dist/plugin/dotenv.js",
|
|
58
|
+
require: "./dist/plugin/dotenv.cjs"
|
|
59
|
+
},
|
|
60
|
+
"./plugins/process-env": {
|
|
61
|
+
types: "./dist/plugin/process-env.d.ts",
|
|
62
|
+
import: "./dist/plugin/process-env.js",
|
|
63
|
+
require: "./dist/plugin/process-env.cjs"
|
|
64
|
+
},
|
|
65
|
+
"./plugins/cli-args": {
|
|
66
|
+
types: "./dist/plugin/cli-args.d.ts",
|
|
67
|
+
import: "./dist/plugin/cli-args.js",
|
|
68
|
+
require: "./dist/plugin/cli-args.cjs"
|
|
69
|
+
},
|
|
70
|
+
"./plugins/basic-schema": {
|
|
71
|
+
types: "./dist/plugin/basic-schema.d.ts",
|
|
72
|
+
import: "./dist/plugin/basic-schema.js",
|
|
73
|
+
require: "./dist/plugin/basic-schema.cjs"
|
|
74
|
+
},
|
|
75
|
+
"./plugins/env-export": {
|
|
76
|
+
types: "./dist/plugin/env-export.d.ts",
|
|
77
|
+
import: "./dist/plugin/env-export.js",
|
|
78
|
+
require: "./dist/plugin/env-export.cjs"
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
files: [
|
|
82
|
+
"dist"
|
|
83
|
+
],
|
|
84
|
+
license: "MIT",
|
|
85
|
+
repository: {
|
|
86
|
+
type: "git",
|
|
87
|
+
url: "https://github.com/kitsyai/cnos.git",
|
|
88
|
+
directory: "packages/cnos"
|
|
89
|
+
},
|
|
90
|
+
homepage: "https://github.com/kitsyai/cnos/tree/main/packages/cnos",
|
|
91
|
+
bugs: {
|
|
92
|
+
url: "https://github.com/kitsyai/cnos/issues"
|
|
93
|
+
},
|
|
94
|
+
keywords: [
|
|
95
|
+
"cnos",
|
|
96
|
+
"config",
|
|
97
|
+
"runtime"
|
|
98
|
+
],
|
|
99
|
+
publishConfig: {
|
|
100
|
+
access: "public"
|
|
101
|
+
},
|
|
102
|
+
dependencies: {
|
|
103
|
+
yaml: "^2.8.3"
|
|
104
|
+
},
|
|
105
|
+
scripts: {
|
|
106
|
+
build: "tsup --config tsup.config.ts",
|
|
107
|
+
clean: "rimraf dist",
|
|
108
|
+
dev: "tsup --config tsup.config.ts --watch",
|
|
109
|
+
lint: "eslint src test",
|
|
110
|
+
test: "vitest run",
|
|
111
|
+
typecheck: "tsc -p tsconfig.json --noEmit"
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
// src/defaultPlugins.ts
|
|
20
116
|
function defaultPlugins() {
|
|
21
117
|
return [
|
|
22
118
|
createFilesystemValuesPlugin(),
|
|
@@ -32,22 +128,15 @@ function defaultPlugins() {
|
|
|
32
128
|
}
|
|
33
129
|
|
|
34
130
|
// src/createCnos.ts
|
|
35
|
-
async function
|
|
36
|
-
return
|
|
131
|
+
async function createCnos2(options = {}) {
|
|
132
|
+
return createCnos({
|
|
37
133
|
...options,
|
|
134
|
+
cnosVersion: package_default.version,
|
|
38
135
|
plugins: [...defaultPlugins(), ...options.plugins ?? []]
|
|
39
136
|
});
|
|
40
137
|
}
|
|
41
|
-
|
|
42
|
-
// src/index.ts
|
|
43
|
-
import {
|
|
44
|
-
planDump,
|
|
45
|
-
toEnv,
|
|
46
|
-
toPublicEnv,
|
|
47
|
-
writeDump
|
|
48
|
-
} from "@kitsy/cnos-core";
|
|
49
138
|
export {
|
|
50
|
-
createCnos,
|
|
139
|
+
createCnos2 as createCnos,
|
|
51
140
|
defaultPlugins,
|
|
52
141
|
planDump,
|
|
53
142
|
toEnv,
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/internal.ts
|
|
31
|
+
var internal_exports = {};
|
|
32
|
+
__export(internal_exports, {
|
|
33
|
+
flattenObject: () => flattenObject,
|
|
34
|
+
parseYaml: () => parseYaml,
|
|
35
|
+
resolveConfigDocumentPath: () => resolveConfigDocumentPath,
|
|
36
|
+
resolveSecretStoreRoot: () => resolveSecretStoreRoot,
|
|
37
|
+
stringifyYaml: () => stringifyYaml,
|
|
38
|
+
validateRuntime: () => validateRuntime,
|
|
39
|
+
writeLocalSecret: () => writeLocalSecret
|
|
40
|
+
});
|
|
41
|
+
module.exports = __toCommonJS(internal_exports);
|
|
42
|
+
|
|
43
|
+
// ../core/src/manifest/loadManifest.ts
|
|
44
|
+
var import_promises2 = require("fs/promises");
|
|
45
|
+
var import_node_path2 = __toESM(require("path"), 1);
|
|
46
|
+
|
|
47
|
+
// ../core/src/utils/path.ts
|
|
48
|
+
var import_promises = require("fs/promises");
|
|
49
|
+
var import_node_os = __toESM(require("os"), 1);
|
|
50
|
+
var import_node_path = __toESM(require("path"), 1);
|
|
51
|
+
function expandHomePath(targetPath) {
|
|
52
|
+
if (targetPath === "~") {
|
|
53
|
+
return import_node_os.default.homedir();
|
|
54
|
+
}
|
|
55
|
+
if (targetPath.startsWith("~/") || targetPath.startsWith("~\\")) {
|
|
56
|
+
return import_node_path.default.join(import_node_os.default.homedir(), targetPath.slice(2));
|
|
57
|
+
}
|
|
58
|
+
return targetPath;
|
|
59
|
+
}
|
|
60
|
+
function resolveNamespaceDirectory(workspaceRoot, namespace, profile) {
|
|
61
|
+
const rootFolder = namespace === "value" ? "values" : "secrets";
|
|
62
|
+
if (profile && profile !== "base") {
|
|
63
|
+
return import_node_path.default.resolve(workspaceRoot, "profiles", profile, rootFolder);
|
|
64
|
+
}
|
|
65
|
+
return import_node_path.default.resolve(workspaceRoot, rootFolder);
|
|
66
|
+
}
|
|
67
|
+
function resolveConfigDocumentPath(workspaceRoot, namespace, configPath, profile) {
|
|
68
|
+
const namespaceRoot = resolveNamespaceDirectory(workspaceRoot, namespace, profile);
|
|
69
|
+
const fileName = `${configPath.split(".").shift() ?? "app"}.yml`;
|
|
70
|
+
return import_node_path.default.resolve(namespaceRoot, fileName);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// ../core/src/utils/yaml.ts
|
|
74
|
+
var import_yaml = require("yaml");
|
|
75
|
+
function parseYaml(source) {
|
|
76
|
+
return (0, import_yaml.parse)(source);
|
|
77
|
+
}
|
|
78
|
+
function stringifyYaml(value) {
|
|
79
|
+
return (0, import_yaml.stringify)(value);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// ../core/src/manifest/loadWorkspaceFile.ts
|
|
83
|
+
var import_promises3 = require("fs/promises");
|
|
84
|
+
var import_node_path3 = __toESM(require("path"), 1);
|
|
85
|
+
|
|
86
|
+
// ../core/src/profiles/expandProfileChain.ts
|
|
87
|
+
var import_promises4 = require("fs/promises");
|
|
88
|
+
var import_node_path4 = __toESM(require("path"), 1);
|
|
89
|
+
|
|
90
|
+
// ../core/src/workspaces/resolveWorkspaceContext.ts
|
|
91
|
+
var import_promises5 = require("fs/promises");
|
|
92
|
+
var import_node_path5 = __toESM(require("path"), 1);
|
|
93
|
+
|
|
94
|
+
// ../core/src/utils/envNaming.ts
|
|
95
|
+
function normalizeMappingConfig(config = {}) {
|
|
96
|
+
return {
|
|
97
|
+
convention: config.convention,
|
|
98
|
+
explicit: config.explicit ?? {}
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
function toScreamingSnakeSegment(segment) {
|
|
102
|
+
return segment.replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/[^A-Za-z0-9]+/g, "_").replace(/_+/g, "_").replace(/^_+|_+$/g, "").toUpperCase();
|
|
103
|
+
}
|
|
104
|
+
function toScreamingSnake(path8) {
|
|
105
|
+
return path8.split(".").map((segment) => toScreamingSnakeSegment(segment)).filter(Boolean).join("_");
|
|
106
|
+
}
|
|
107
|
+
function logicalKeyToEnvVar(key, config = {}) {
|
|
108
|
+
const normalized = normalizeMappingConfig(config);
|
|
109
|
+
const explicitEntry = Object.entries(normalized.explicit).find(([, logicalKey]) => logicalKey === key);
|
|
110
|
+
if (explicitEntry) {
|
|
111
|
+
return explicitEntry[0];
|
|
112
|
+
}
|
|
113
|
+
if (normalized.convention !== "SCREAMING_SNAKE") {
|
|
114
|
+
return void 0;
|
|
115
|
+
}
|
|
116
|
+
if (key.startsWith("value.")) {
|
|
117
|
+
return toScreamingSnake(key.slice("value.".length));
|
|
118
|
+
}
|
|
119
|
+
if (key.startsWith("secret.")) {
|
|
120
|
+
return `SECRET_${toScreamingSnake(key.slice("secret.".length))}`;
|
|
121
|
+
}
|
|
122
|
+
return void 0;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// ../core/src/runtime/dump.ts
|
|
126
|
+
var import_promises6 = require("fs/promises");
|
|
127
|
+
var import_node_path6 = __toESM(require("path"), 1);
|
|
128
|
+
|
|
129
|
+
// ../core/src/utils/flatten.ts
|
|
130
|
+
function flattenObject(value, prefix = "") {
|
|
131
|
+
return Object.entries(value).reduce((accumulator, [key, nestedValue]) => {
|
|
132
|
+
const nextKey = prefix ? `${prefix}.${key}` : key;
|
|
133
|
+
if (nestedValue && typeof nestedValue === "object" && !Array.isArray(nestedValue)) {
|
|
134
|
+
Object.assign(accumulator, flattenObject(nestedValue, nextKey));
|
|
135
|
+
return accumulator;
|
|
136
|
+
}
|
|
137
|
+
accumulator[nextKey] = nestedValue;
|
|
138
|
+
return accumulator;
|
|
139
|
+
}, {});
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// ../core/src/utils/secretStore.ts
|
|
143
|
+
var import_node_crypto = require("crypto");
|
|
144
|
+
var import_promises7 = require("fs/promises");
|
|
145
|
+
var import_node_path7 = __toESM(require("path"), 1);
|
|
146
|
+
function resolveSecretStoreRoot(processEnv = process.env) {
|
|
147
|
+
return import_node_path7.default.resolve(expandHomePath(processEnv.CNOS_SECRET_HOME ?? "~/.cnos/secrets"));
|
|
148
|
+
}
|
|
149
|
+
function resolveSecretStoreFile(storeRoot, ref) {
|
|
150
|
+
return import_node_path7.default.join(storeRoot, "store", ...ref.split("/")).concat(".json");
|
|
151
|
+
}
|
|
152
|
+
function deriveKey(passphrase, salt) {
|
|
153
|
+
return (0, import_node_crypto.scryptSync)(passphrase, salt, 32);
|
|
154
|
+
}
|
|
155
|
+
function encryptDocument(value, passphrase) {
|
|
156
|
+
const salt = (0, import_node_crypto.randomBytes)(16);
|
|
157
|
+
const iv = (0, import_node_crypto.randomBytes)(12);
|
|
158
|
+
const key = deriveKey(passphrase, salt);
|
|
159
|
+
const cipher = (0, import_node_crypto.createCipheriv)("aes-256-gcm", key, iv);
|
|
160
|
+
const ciphertext = Buffer.concat([cipher.update(value, "utf8"), cipher.final()]);
|
|
161
|
+
const tag = cipher.getAuthTag();
|
|
162
|
+
return {
|
|
163
|
+
version: 1,
|
|
164
|
+
algorithm: "aes-256-gcm",
|
|
165
|
+
salt: salt.toString("base64"),
|
|
166
|
+
iv: iv.toString("base64"),
|
|
167
|
+
tag: tag.toString("base64"),
|
|
168
|
+
ciphertext: ciphertext.toString("base64")
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
async function writeLocalSecret(storeRoot, ref, value, passphrase) {
|
|
172
|
+
const filePath = resolveSecretStoreFile(storeRoot, ref);
|
|
173
|
+
await (0, import_promises7.mkdir)(import_node_path7.default.dirname(filePath), { recursive: true });
|
|
174
|
+
await (0, import_promises7.writeFile)(filePath, JSON.stringify(encryptDocument(value, passphrase), null, 2), "utf8");
|
|
175
|
+
return filePath;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// ../core/src/validation/envMapping.ts
|
|
179
|
+
function fallbackLogicalKeyToEnvVar(key) {
|
|
180
|
+
return key.replace(/^(value|secret)\./, "").replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/[^A-Za-z0-9]+/g, "_").replace(/_+/g, "_").replace(/^_+|_+$/g, "").toUpperCase();
|
|
181
|
+
}
|
|
182
|
+
function validateEnvMappingCollisions(manifest, graph) {
|
|
183
|
+
const candidates = /* @__PURE__ */ new Set([
|
|
184
|
+
...Object.values(manifest.envMapping.explicit),
|
|
185
|
+
...manifest.public.promote,
|
|
186
|
+
...Object.keys(manifest.schema),
|
|
187
|
+
...graph ? Array.from(graph.entries.keys()) : []
|
|
188
|
+
]);
|
|
189
|
+
const collisions = /* @__PURE__ */ new Map();
|
|
190
|
+
for (const key of candidates) {
|
|
191
|
+
if (key.startsWith("meta.")) {
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
const envVar = logicalKeyToEnvVar(key, manifest.envMapping) ?? (key.startsWith("value.") || key.startsWith("secret.") ? fallbackLogicalKeyToEnvVar(key) : void 0);
|
|
195
|
+
if (!envVar) {
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
const keys = collisions.get(envVar) ?? [];
|
|
199
|
+
keys.push(key);
|
|
200
|
+
collisions.set(envVar, keys);
|
|
201
|
+
}
|
|
202
|
+
return Array.from(collisions.entries()).filter(([, keys]) => new Set(keys).size > 1).map(([envVar, keys]) => ({
|
|
203
|
+
code: "env-mapping.collision",
|
|
204
|
+
message: `Multiple logical keys map to env var ${envVar}: ${Array.from(new Set(keys)).join(", ")}`
|
|
205
|
+
}));
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// ../core/src/validation/publicSafety.ts
|
|
209
|
+
function validatePublicSafety(manifest) {
|
|
210
|
+
return manifest.public.promote.filter((key) => !key.startsWith("value.")).map((key) => ({
|
|
211
|
+
code: "public.invalid-promotion",
|
|
212
|
+
key,
|
|
213
|
+
message: `public.promote may only include value.* keys: ${key}`
|
|
214
|
+
}));
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// ../core/src/validation/workspaceSafety.ts
|
|
218
|
+
function validateWorkspaceSafety(manifest, graph) {
|
|
219
|
+
const issues = [];
|
|
220
|
+
const localRoot = graph.workspace.workspaceRoots.find(
|
|
221
|
+
(entry) => entry.scope === "local" && entry.workspaceId === graph.workspace.workspaceId
|
|
222
|
+
);
|
|
223
|
+
if (!localRoot) {
|
|
224
|
+
issues.push({
|
|
225
|
+
code: "workspace.missing-local-root",
|
|
226
|
+
message: `Missing local workspace root for ${graph.workspace.workspaceId}`
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
if (manifest.workspaces.global.allowWrite && !manifest.workspaces.global.enabled) {
|
|
230
|
+
issues.push({
|
|
231
|
+
code: "workspace.global-write-policy",
|
|
232
|
+
message: "workspaces.global.allowWrite requires workspaces.global.enabled: true"
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
return issues;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// ../core/src/validation/validateRuntime.ts
|
|
239
|
+
async function validateRuntime(runtime) {
|
|
240
|
+
const validatorPlugins = runtime.plugins.filter(
|
|
241
|
+
(plugin) => plugin.kind === "validator"
|
|
242
|
+
);
|
|
243
|
+
const pluginResults = await Promise.all(
|
|
244
|
+
validatorPlugins.map(
|
|
245
|
+
(plugin) => plugin.validate(runtime.graph, {
|
|
246
|
+
manifest: runtime.manifest,
|
|
247
|
+
schema: runtime.manifest.schema
|
|
248
|
+
})
|
|
249
|
+
)
|
|
250
|
+
);
|
|
251
|
+
const builtInResults = [
|
|
252
|
+
{
|
|
253
|
+
pluginId: "public-safety",
|
|
254
|
+
valid: true,
|
|
255
|
+
issues: validatePublicSafety(runtime.manifest)
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
pluginId: "env-mapping",
|
|
259
|
+
valid: true,
|
|
260
|
+
issues: validateEnvMappingCollisions(runtime.manifest, runtime.graph)
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
pluginId: "workspace-safety",
|
|
264
|
+
valid: true,
|
|
265
|
+
issues: validateWorkspaceSafety(runtime.manifest, runtime.graph)
|
|
266
|
+
}
|
|
267
|
+
].map((result) => ({
|
|
268
|
+
...result,
|
|
269
|
+
valid: result.issues.length === 0
|
|
270
|
+
}));
|
|
271
|
+
const results = [...pluginResults, ...builtInResults];
|
|
272
|
+
const issues = results.flatMap((result) => result.issues);
|
|
273
|
+
return {
|
|
274
|
+
valid: issues.length === 0,
|
|
275
|
+
issues,
|
|
276
|
+
results
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
280
|
+
0 && (module.exports = {
|
|
281
|
+
flattenObject,
|
|
282
|
+
parseYaml,
|
|
283
|
+
resolveConfigDocumentPath,
|
|
284
|
+
resolveSecretStoreRoot,
|
|
285
|
+
stringifyYaml,
|
|
286
|
+
validateRuntime,
|
|
287
|
+
writeLocalSecret
|
|
288
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { d as CnosRuntime, V as ValidationSummary } from './plugin-BVNEHj19.cjs';
|
|
2
|
+
export { i as ValidationIssue, W as WorkspaceFile } from './plugin-BVNEHj19.cjs';
|
|
3
|
+
|
|
4
|
+
declare function flattenObject(value: Record<string, unknown>, prefix?: string): Record<string, unknown>;
|
|
5
|
+
|
|
6
|
+
declare function resolveConfigDocumentPath(workspaceRoot: string, namespace: 'value' | 'secret', configPath: string, profile?: string): string;
|
|
7
|
+
|
|
8
|
+
interface SecretReference {
|
|
9
|
+
provider: string;
|
|
10
|
+
ref: string;
|
|
11
|
+
}
|
|
12
|
+
declare function resolveSecretStoreRoot(processEnv?: Record<string, string | undefined>): string;
|
|
13
|
+
declare function writeLocalSecret(storeRoot: string, ref: string, value: string, passphrase: string): Promise<string>;
|
|
14
|
+
|
|
15
|
+
declare function parseYaml<T>(source: string): T;
|
|
16
|
+
declare function stringifyYaml(value: unknown): string;
|
|
17
|
+
|
|
18
|
+
declare function validateRuntime(runtime: CnosRuntime): Promise<ValidationSummary>;
|
|
19
|
+
|
|
20
|
+
export { type SecretReference, ValidationSummary, flattenObject, parseYaml, resolveConfigDocumentPath, resolveSecretStoreRoot, stringifyYaml, validateRuntime, writeLocalSecret };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { d as CnosRuntime, V as ValidationSummary } from './plugin-BVNEHj19.js';
|
|
2
|
+
export { i as ValidationIssue, W as WorkspaceFile } from './plugin-BVNEHj19.js';
|
|
3
|
+
|
|
4
|
+
declare function flattenObject(value: Record<string, unknown>, prefix?: string): Record<string, unknown>;
|
|
5
|
+
|
|
6
|
+
declare function resolveConfigDocumentPath(workspaceRoot: string, namespace: 'value' | 'secret', configPath: string, profile?: string): string;
|
|
7
|
+
|
|
8
|
+
interface SecretReference {
|
|
9
|
+
provider: string;
|
|
10
|
+
ref: string;
|
|
11
|
+
}
|
|
12
|
+
declare function resolveSecretStoreRoot(processEnv?: Record<string, string | undefined>): string;
|
|
13
|
+
declare function writeLocalSecret(storeRoot: string, ref: string, value: string, passphrase: string): Promise<string>;
|
|
14
|
+
|
|
15
|
+
declare function parseYaml<T>(source: string): T;
|
|
16
|
+
declare function stringifyYaml(value: unknown): string;
|
|
17
|
+
|
|
18
|
+
declare function validateRuntime(runtime: CnosRuntime): Promise<ValidationSummary>;
|
|
19
|
+
|
|
20
|
+
export { type SecretReference, ValidationSummary, flattenObject, parseYaml, resolveConfigDocumentPath, resolveSecretStoreRoot, stringifyYaml, validateRuntime, writeLocalSecret };
|
package/dist/internal.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {
|
|
2
|
+
flattenObject,
|
|
3
|
+
parseYaml,
|
|
4
|
+
resolveConfigDocumentPath,
|
|
5
|
+
resolveSecretStoreRoot,
|
|
6
|
+
stringifyYaml,
|
|
7
|
+
validateRuntime,
|
|
8
|
+
writeLocalSecret
|
|
9
|
+
} from "./chunk-K2T4R5WH.js";
|
|
10
|
+
export {
|
|
11
|
+
flattenObject,
|
|
12
|
+
parseYaml,
|
|
13
|
+
resolveConfigDocumentPath,
|
|
14
|
+
resolveSecretStoreRoot,
|
|
15
|
+
stringifyYaml,
|
|
16
|
+
validateRuntime,
|
|
17
|
+
writeLocalSecret
|
|
18
|
+
};
|