@geekmidas/cli 10.0.0-alpha.10 → 10.0.0-alpha.11
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/{CachedStateProvider-CqPdW7CB.cjs → CachedStateProvider-BEBl2wQT.cjs} +1 -1
- package/dist/{CachedStateProvider-CqPdW7CB.cjs.map → CachedStateProvider-BEBl2wQT.cjs.map} +1 -1
- package/dist/CachedStateProvider-C-8wtlto.mjs +3 -0
- package/dist/{CachedStateProvider-DTniehMP.mjs → CachedStateProvider-Co4n5Wvs.mjs} +1 -1
- package/dist/{CachedStateProvider-DTniehMP.mjs.map → CachedStateProvider-Co4n5Wvs.mjs.map} +1 -1
- package/dist/{CachedStateProvider-BLo7zv7S.cjs → CachedStateProvider-DqhGpzsm.cjs} +1 -1
- package/dist/{HostingerProvider-h3EbEp-Z.cjs → HostingerProvider-BOvsgATO.cjs} +1 -1
- package/dist/{HostingerProvider-h3EbEp-Z.cjs.map → HostingerProvider-BOvsgATO.cjs.map} +1 -1
- package/dist/{HostingerProvider-Cft7lEYr.mjs → HostingerProvider-BcyFRbqV.mjs} +1 -1
- package/dist/{HostingerProvider-Cft7lEYr.mjs.map → HostingerProvider-BcyFRbqV.mjs.map} +1 -1
- package/dist/{LocalStateProvider-Bn6tS-oL.mjs → LocalStateProvider-Bq-0C0sg.mjs} +1 -1
- package/dist/{LocalStateProvider-Bn6tS-oL.mjs.map → LocalStateProvider-Bq-0C0sg.mjs.map} +1 -1
- package/dist/{LocalStateProvider-Db9SEjyH.cjs → LocalStateProvider-yjXZXZDM.cjs} +1 -1
- package/dist/{LocalStateProvider-Db9SEjyH.cjs.map → LocalStateProvider-yjXZXZDM.cjs.map} +1 -1
- package/dist/{Route53Provider-RdpUDJQk.mjs → Route53Provider-C0xmer8U.mjs} +1 -1
- package/dist/{Route53Provider-RdpUDJQk.mjs.map → Route53Provider-C0xmer8U.mjs.map} +1 -1
- package/dist/{Route53Provider-di2fMM5N.cjs → Route53Provider-CH9XH7bz.cjs} +1 -1
- package/dist/{Route53Provider-di2fMM5N.cjs.map → Route53Provider-CH9XH7bz.cjs.map} +1 -1
- package/dist/{SSMStateProvider-DyX8s9HI.cjs → SSMStateProvider-CXtNgPfy.cjs} +1 -1
- package/dist/{SSMStateProvider-DyX8s9HI.cjs.map → SSMStateProvider-CXtNgPfy.cjs.map} +1 -1
- package/dist/{SSMStateProvider-BRt2py-A.mjs → SSMStateProvider-DOZifZfE.mjs} +1 -1
- package/dist/{SSMStateProvider-BRt2py-A.mjs.map → SSMStateProvider-DOZifZfE.mjs.map} +1 -1
- package/dist/{backup-provisioner-Bgj5Vi_L.mjs → backup-provisioner-DXXg6FIL.mjs} +1 -1
- package/dist/{backup-provisioner-Bgj5Vi_L.mjs.map → backup-provisioner-DXXg6FIL.mjs.map} +1 -1
- package/dist/{backup-provisioner-BrsHwYG0.cjs → backup-provisioner-cE2PuCTb.cjs} +1 -1
- package/dist/{backup-provisioner-BrsHwYG0.cjs.map → backup-provisioner-cE2PuCTb.cjs.map} +1 -1
- package/dist/{bundler-BY1OmV1e.cjs → bundler-CaTGtiaO.cjs} +3 -3
- package/dist/{bundler-BY1OmV1e.cjs.map → bundler-CaTGtiaO.cjs.map} +1 -1
- package/dist/{bundler-Be8Zg4Wd.mjs → bundler-S3ek7ea-.mjs} +3 -3
- package/dist/{bundler-Be8Zg4Wd.mjs.map → bundler-S3ek7ea-.mjs.map} +1 -1
- package/dist/{config-DVVph9yz.mjs → config-B0L2tvvC.mjs} +2 -2
- package/dist/{config-DVVph9yz.mjs.map → config-B0L2tvvC.mjs.map} +1 -1
- package/dist/{config-BZ1F0WuA.cjs → config-HhDpJmLO.cjs} +2 -2
- package/dist/{config-BZ1F0WuA.cjs.map → config-HhDpJmLO.cjs.map} +1 -1
- package/dist/config.cjs +2 -2
- package/dist/config.d.mts +2 -2
- package/dist/config.mjs +2 -2
- package/dist/{credentials-Xamqe_NJ.cjs → credentials-B2Pyh3bJ.cjs} +5 -5
- package/dist/{credentials-Xamqe_NJ.cjs.map → credentials-B2Pyh3bJ.cjs.map} +1 -1
- package/dist/{credentials-dP8vRVRv.mjs → credentials-CZrys9C5.mjs} +5 -5
- package/dist/{credentials-dP8vRVRv.mjs.map → credentials-CZrys9C5.mjs.map} +1 -1
- package/dist/dokploy-api-5cK2InBm.cjs +3 -0
- package/dist/dokploy-api-D2Ny4Jrc.mjs +3 -0
- package/dist/{dokploy-api-aTFPz7_4.mjs → dokploy-api-pdaBryoY.mjs} +1 -1
- package/dist/{dokploy-api-aTFPz7_4.mjs.map → dokploy-api-pdaBryoY.mjs.map} +1 -1
- package/dist/{dokploy-api-BsVH0y_s.cjs → dokploy-api-zqKe9lHH.cjs} +1 -1
- package/dist/{dokploy-api-BsVH0y_s.cjs.map → dokploy-api-zqKe9lHH.cjs.map} +1 -1
- package/dist/{emit-CiZS_5Ub.mjs → emit-CIlvnDvV.mjs} +1 -1
- package/dist/{emit-CiZS_5Ub.mjs.map → emit-CIlvnDvV.mjs.map} +1 -1
- package/dist/{emit-CbcRolsa.cjs → emit-CUD1BWls.cjs} +1 -1
- package/dist/{emit-CbcRolsa.cjs.map → emit-CUD1BWls.cjs.map} +1 -1
- package/dist/{encryption-C6jaU0hE.cjs → encryption-D2pL3tHH.cjs} +1 -1
- package/dist/{encryption-C6jaU0hE.cjs.map → encryption-D2pL3tHH.cjs.map} +1 -1
- package/dist/encryption-YDsXXi6w.mjs +3 -0
- package/dist/{encryption-D-abyhZx.mjs → encryption-_4zwjOAR.mjs} +1 -1
- package/dist/{encryption-D-abyhZx.mjs.map → encryption-_4zwjOAR.mjs.map} +1 -1
- package/dist/{encryption-CHzzeR8a.cjs → encryption-sQ2Oxx0d.cjs} +1 -1
- package/dist/{fullstack-secrets-C-GGohke.cjs → fullstack-secrets-D6MyHhQP.cjs} +1 -1
- package/dist/{fullstack-secrets-C-GGohke.cjs.map → fullstack-secrets-D6MyHhQP.cjs.map} +1 -1
- package/dist/{fullstack-secrets-D1o9-G5l.mjs → fullstack-secrets-METaRLS1.mjs} +1 -1
- package/dist/{fullstack-secrets-D1o9-G5l.mjs.map → fullstack-secrets-METaRLS1.mjs.map} +1 -1
- package/dist/github-BrvaPkFf.cjs +197 -0
- package/dist/github-BrvaPkFf.cjs.map +1 -0
- package/dist/github-CrpsXSfV.mjs +196 -0
- package/dist/github-CrpsXSfV.mjs.map +1 -0
- package/dist/{index-C6e-ULLx.d.mts → index-Ayxg_DQY.d.mts} +2 -2
- package/dist/{index-C6e-ULLx.d.mts.map → index-Ayxg_DQY.d.mts.map} +1 -1
- package/dist/index.cjs +109 -63
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +108 -62
- package/dist/index.mjs.map +1 -1
- package/dist/keystore-C9rint2E.cjs +101 -0
- package/dist/keystore-C9rint2E.cjs.map +1 -0
- package/dist/keystore-TxeYM7an.mjs +83 -0
- package/dist/keystore-TxeYM7an.mjs.map +1 -0
- package/dist/{openapi-SjsgARie.cjs → openapi-DaKlTKxz.cjs} +2 -2
- package/dist/{openapi-SjsgARie.cjs.map → openapi-DaKlTKxz.cjs.map} +1 -1
- package/dist/{openapi-react-query-CmJ1xDbn.cjs → openapi-react-query-BKH334Ug.cjs} +1 -1
- package/dist/{openapi-react-query-CmJ1xDbn.cjs.map → openapi-react-query-BKH334Ug.cjs.map} +1 -1
- package/dist/{openapi-react-query-Byltvm_7.mjs → openapi-react-query-DoR5CmzQ.mjs} +1 -1
- package/dist/{openapi-react-query-Byltvm_7.mjs.map → openapi-react-query-DoR5CmzQ.mjs.map} +1 -1
- package/dist/openapi-react-query.cjs +1 -1
- package/dist/openapi-react-query.mjs +1 -1
- package/dist/{openapi-Xx0A7Wg0.mjs → openapi-y1d7Kalt.mjs} +2 -2
- package/dist/{openapi-Xx0A7Wg0.mjs.map → openapi-y1d7Kalt.mjs.map} +1 -1
- package/dist/openapi.cjs +3 -3
- package/dist/openapi.d.mts +1 -1
- package/dist/openapi.mjs +3 -3
- package/dist/reconcile/public.cjs +1 -1
- package/dist/reconcile/public.d.mts +1 -1
- package/dist/reconcile/public.mjs +1 -1
- package/dist/{reconcile-CFs8C_1a.mjs → reconcile-C13ERt1U.mjs} +2 -2
- package/dist/{reconcile-CFs8C_1a.mjs.map → reconcile-C13ERt1U.mjs.map} +1 -1
- package/dist/{reconcile-D0pimNiy.cjs → reconcile-CYMhFSYy.cjs} +2 -2
- package/dist/{reconcile-D0pimNiy.cjs.map → reconcile-CYMhFSYy.cjs.map} +1 -1
- package/dist/setup-BWgMs4gg.mjs +12 -0
- package/dist/{setup-hC6hI86f.cjs → setup-DOv92pIu.cjs} +6 -6
- package/dist/{setup-hC6hI86f.cjs.map → setup-DOv92pIu.cjs.map} +1 -1
- package/dist/{setup-C8KOx8_8.mjs → setup-DQo_h_yK.mjs} +6 -6
- package/dist/{setup-C8KOx8_8.mjs.map → setup-DQo_h_yK.mjs.map} +1 -1
- package/dist/setup-lCx_DcUo.cjs +12 -0
- package/dist/{storage-Bi24WfoW.mjs → storage-B020InPW.mjs} +4 -79
- package/dist/storage-B020InPW.mjs.map +1 -0
- package/dist/{storage-BJmzYxt8.cjs → storage-CSNplaJn.cjs} +4 -85
- package/dist/storage-CSNplaJn.cjs.map +1 -0
- package/dist/{storage-CYlGwWTj.mjs → storage-DGBzMLZa.mjs} +2 -1
- package/dist/{storage-BM9hGpgv.cjs → storage-DlVol_oj.cjs} +2 -1
- package/dist/{sync-SizaChmC.cjs → sync-0ILCb-1S.cjs} +2 -2
- package/dist/{sync-SizaChmC.cjs.map → sync-0ILCb-1S.cjs.map} +1 -1
- package/dist/{sync-CmEuNZsB.mjs → sync-CzHXiR9c.mjs} +2 -2
- package/dist/{sync-CmEuNZsB.mjs.map → sync-CzHXiR9c.mjs.map} +1 -1
- package/dist/sync-DYENfOt4.cjs +4 -0
- package/dist/{sync-hOqAWHR6.mjs → sync-HAau6h_R.mjs} +1 -1
- package/dist/{types-6pkp2RRj.d.mts → types-CL7jPFM2.d.mts} +1 -1
- package/dist/{types-6pkp2RRj.d.mts.map → types-CL7jPFM2.d.mts.map} +1 -1
- package/dist/workspace/index.cjs +1 -1
- package/dist/workspace/index.d.mts +2 -2
- package/dist/workspace/index.mjs +1 -1
- package/dist/{workspace-C6VJQVtG.cjs → workspace-C-a3G_U0.cjs} +30 -4
- package/dist/workspace-C-a3G_U0.cjs.map +1 -0
- package/dist/workspace-DQxxs7Jk.cjs +10 -0
- package/dist/{workspace-zoqRbihZ.mjs → workspace-DaEX7FEg.mjs} +25 -5
- package/dist/workspace-DaEX7FEg.mjs.map +1 -0
- package/dist/workspace-DbI580qS.mjs +9 -0
- package/package.json +11 -11
- package/dist/CachedStateProvider-BxoAm-B2.mjs +0 -3
- package/dist/dokploy-api-BS2xnJLZ.mjs +0 -3
- package/dist/dokploy-api-BuxDRo3l.cjs +0 -3
- package/dist/encryption-CQUncu7v.mjs +0 -3
- package/dist/setup-BA8ciTPU.mjs +0 -11
- package/dist/setup-BsZvZP6f.cjs +0 -11
- package/dist/storage-BJmzYxt8.cjs.map +0 -1
- package/dist/storage-Bi24WfoW.mjs.map +0 -1
- package/dist/sync-D306yOWu.cjs +0 -4
- package/dist/workspace-BzrG_2SI.mjs +0 -8
- package/dist/workspace-C6VJQVtG.cjs.map +0 -1
- package/dist/workspace-XXtNhqJl.cjs +0 -9
- package/dist/workspace-zoqRbihZ.mjs.map +0 -1
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
2
|
+
const node_fs = require_chunk.__toESM(require("node:fs"));
|
|
3
|
+
const node_path = require_chunk.__toESM(require("node:path"));
|
|
4
|
+
const node_fs_promises = require_chunk.__toESM(require("node:fs/promises"));
|
|
5
|
+
const node_os = require_chunk.__toESM(require("node:os"));
|
|
6
|
+
const node_crypto = require_chunk.__toESM(require("node:crypto"));
|
|
7
|
+
|
|
8
|
+
//#region src/secrets/keystore.ts
|
|
9
|
+
/** Key length for AES-256 encryption */
|
|
10
|
+
const KEY_LENGTH = 32;
|
|
11
|
+
/**
|
|
12
|
+
* Get the keystore directory for a project.
|
|
13
|
+
* Keys are stored at ~/.gkm/{project-name}/
|
|
14
|
+
*
|
|
15
|
+
* @param projectName - Name of the project (defaults to current directory name)
|
|
16
|
+
* @returns Path to the keystore directory
|
|
17
|
+
*/
|
|
18
|
+
function getKeystoreDir(projectName) {
|
|
19
|
+
const name = projectName ?? (0, node_path.basename)(process.cwd());
|
|
20
|
+
return (0, node_path.join)((0, node_os.homedir)(), ".gkm", name);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Get the path to a stage's encryption key.
|
|
24
|
+
*
|
|
25
|
+
* @param stage - Stage name (e.g., 'development', 'production')
|
|
26
|
+
* @param projectName - Name of the project (defaults to current directory name)
|
|
27
|
+
* @returns Path to the key file
|
|
28
|
+
*/
|
|
29
|
+
function getKeyPath(stage, projectName) {
|
|
30
|
+
return (0, node_path.join)(getKeystoreDir(projectName), `${stage}.key`);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Generate a new encryption key for a stage.
|
|
34
|
+
* The key is stored at ~/.gkm/{project-name}/{stage}.key with restricted permissions.
|
|
35
|
+
*
|
|
36
|
+
* @param stage - Stage name
|
|
37
|
+
* @param projectName - Project name (defaults to current directory name)
|
|
38
|
+
* @returns The generated key as a hex string
|
|
39
|
+
*/
|
|
40
|
+
async function generateKey(stage, projectName) {
|
|
41
|
+
const keyDir = getKeystoreDir(projectName);
|
|
42
|
+
const keyPath = getKeyPath(stage, projectName);
|
|
43
|
+
await (0, node_fs_promises.mkdir)(keyDir, {
|
|
44
|
+
recursive: true,
|
|
45
|
+
mode: 448
|
|
46
|
+
});
|
|
47
|
+
const key = (0, node_crypto.randomBytes)(KEY_LENGTH).toString("hex");
|
|
48
|
+
await (0, node_fs_promises.writeFile)(keyPath, key, {
|
|
49
|
+
mode: 384,
|
|
50
|
+
encoding: "utf-8"
|
|
51
|
+
});
|
|
52
|
+
await (0, node_fs_promises.chmod)(keyPath, 384);
|
|
53
|
+
return key;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Read an encryption key for a stage.
|
|
57
|
+
*
|
|
58
|
+
* @param stage - Stage name
|
|
59
|
+
* @param projectName - Project name (defaults to current directory name)
|
|
60
|
+
* @returns The key as a hex string, or null if not found
|
|
61
|
+
*/
|
|
62
|
+
async function readKey(stage, projectName) {
|
|
63
|
+
const keyPath = getKeyPath(stage, projectName);
|
|
64
|
+
if (!(0, node_fs.existsSync)(keyPath)) return null;
|
|
65
|
+
const key = await (0, node_fs_promises.readFile)(keyPath, "utf-8");
|
|
66
|
+
return key.trim();
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Get or create a key for a stage.
|
|
70
|
+
* If the key already exists, it is returned. Otherwise, a new key is generated.
|
|
71
|
+
*
|
|
72
|
+
* @param stage - Stage name
|
|
73
|
+
* @param projectName - Project name (defaults to current directory name)
|
|
74
|
+
* @returns The key as a hex string
|
|
75
|
+
*/
|
|
76
|
+
async function getOrCreateKey(stage, projectName) {
|
|
77
|
+
const existingKey = await readKey(stage, projectName);
|
|
78
|
+
if (existingKey) return existingKey;
|
|
79
|
+
return generateKey(stage, projectName);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
//#endregion
|
|
83
|
+
Object.defineProperty(exports, 'getKeyPath', {
|
|
84
|
+
enumerable: true,
|
|
85
|
+
get: function () {
|
|
86
|
+
return getKeyPath;
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
Object.defineProperty(exports, 'getOrCreateKey', {
|
|
90
|
+
enumerable: true,
|
|
91
|
+
get: function () {
|
|
92
|
+
return getOrCreateKey;
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
Object.defineProperty(exports, 'readKey', {
|
|
96
|
+
enumerable: true,
|
|
97
|
+
get: function () {
|
|
98
|
+
return readKey;
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
//# sourceMappingURL=keystore-C9rint2E.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keystore-C9rint2E.cjs","names":["projectName?: string","stage: string"],"sources":["../src/secrets/keystore.ts"],"sourcesContent":["import { randomBytes } from 'node:crypto';\nimport { existsSync } from 'node:fs';\nimport { chmod, mkdir, readFile, rm, writeFile } from 'node:fs/promises';\nimport { homedir } from 'node:os';\nimport { basename, join } from 'node:path';\n\n/** Key length for AES-256 encryption */\nconst KEY_LENGTH = 32; // 256 bits\n\n/**\n * Get the keystore directory for a project.\n * Keys are stored at ~/.gkm/{project-name}/\n *\n * @param projectName - Name of the project (defaults to current directory name)\n * @returns Path to the keystore directory\n */\nexport function getKeystoreDir(projectName?: string): string {\n\tconst name = projectName ?? basename(process.cwd());\n\treturn join(homedir(), '.gkm', name);\n}\n\n/**\n * Get the path to a stage's encryption key.\n *\n * @param stage - Stage name (e.g., 'development', 'production')\n * @param projectName - Name of the project (defaults to current directory name)\n * @returns Path to the key file\n */\nexport function getKeyPath(stage: string, projectName?: string): string {\n\treturn join(getKeystoreDir(projectName), `${stage}.key`);\n}\n\n/**\n * Check if a key exists for a stage.\n */\nexport function keyExists(stage: string, projectName?: string): boolean {\n\treturn existsSync(getKeyPath(stage, projectName));\n}\n\n/**\n * Generate a new encryption key for a stage.\n * The key is stored at ~/.gkm/{project-name}/{stage}.key with restricted permissions.\n *\n * @param stage - Stage name\n * @param projectName - Project name (defaults to current directory name)\n * @returns The generated key as a hex string\n */\nexport async function generateKey(\n\tstage: string,\n\tprojectName?: string,\n): Promise<string> {\n\tconst keyDir = getKeystoreDir(projectName);\n\tconst keyPath = getKeyPath(stage, projectName);\n\n\t// Ensure keystore directory exists with restricted permissions\n\tawait mkdir(keyDir, { recursive: true, mode: 0o700 });\n\n\t// Generate random key\n\tconst key = randomBytes(KEY_LENGTH).toString('hex');\n\n\t// Write key with restricted permissions (owner read/write only)\n\tawait writeFile(keyPath, key, { mode: 0o600, encoding: 'utf-8' });\n\n\t// Ensure permissions are set correctly (in case file existed)\n\tawait chmod(keyPath, 0o600);\n\n\treturn key;\n}\n\n/**\n * Read an encryption key for a stage.\n *\n * @param stage - Stage name\n * @param projectName - Project name (defaults to current directory name)\n * @returns The key as a hex string, or null if not found\n */\nexport async function readKey(\n\tstage: string,\n\tprojectName?: string,\n): Promise<string | null> {\n\tconst keyPath = getKeyPath(stage, projectName);\n\n\tif (!existsSync(keyPath)) {\n\t\treturn null;\n\t}\n\n\tconst key = await readFile(keyPath, 'utf-8');\n\treturn key.trim();\n}\n\n/**\n * Read an encryption key for a stage, throwing if not found.\n */\nexport async function requireKey(\n\tstage: string,\n\tprojectName?: string,\n): Promise<string> {\n\tconst key = await readKey(stage, projectName);\n\n\tif (!key) {\n\t\tconst name = projectName ?? basename(process.cwd());\n\t\tthrow new Error(\n\t\t\t`Encryption key not found for stage \"${stage}\" in project \"${name}\". ` +\n\t\t\t\t`Expected key at: ${getKeyPath(stage, projectName)}`,\n\t\t);\n\t}\n\n\treturn key;\n}\n\n/**\n * Delete a key for a stage.\n */\nexport async function deleteKey(\n\tstage: string,\n\tprojectName?: string,\n): Promise<void> {\n\tconst keyPath = getKeyPath(stage, projectName);\n\n\tif (existsSync(keyPath)) {\n\t\tawait rm(keyPath);\n\t}\n}\n\n/**\n * Get or create a key for a stage.\n * If the key already exists, it is returned. Otherwise, a new key is generated.\n *\n * @param stage - Stage name\n * @param projectName - Project name (defaults to current directory name)\n * @returns The key as a hex string\n */\nexport async function getOrCreateKey(\n\tstage: string,\n\tprojectName?: string,\n): Promise<string> {\n\tconst existingKey = await readKey(stage, projectName);\n\n\tif (existingKey) {\n\t\treturn existingKey;\n\t}\n\n\treturn generateKey(stage, projectName);\n}\n"],"mappings":";;;;;;;;;AAOA,MAAM,aAAa;;;;;;;;AASnB,SAAgB,eAAeA,aAA8B;CAC5D,MAAM,OAAO,eAAe,wBAAS,QAAQ,KAAK,CAAC;AACnD,QAAO,oBAAK,sBAAS,EAAE,QAAQ,KAAK;AACpC;;;;;;;;AASD,SAAgB,WAAWC,OAAeD,aAA8B;AACvE,QAAO,oBAAK,eAAe,YAAY,GAAG,EAAE,MAAM,MAAM;AACxD;;;;;;;;;AAiBD,eAAsB,YACrBC,OACAD,aACkB;CAClB,MAAM,SAAS,eAAe,YAAY;CAC1C,MAAM,UAAU,WAAW,OAAO,YAAY;AAG9C,OAAM,4BAAM,QAAQ;EAAE,WAAW;EAAM,MAAM;CAAO,EAAC;CAGrD,MAAM,MAAM,6BAAY,WAAW,CAAC,SAAS,MAAM;AAGnD,OAAM,gCAAU,SAAS,KAAK;EAAE,MAAM;EAAO,UAAU;CAAS,EAAC;AAGjE,OAAM,4BAAM,SAAS,IAAM;AAE3B,QAAO;AACP;;;;;;;;AASD,eAAsB,QACrBC,OACAD,aACyB;CACzB,MAAM,UAAU,WAAW,OAAO,YAAY;AAE9C,MAAK,wBAAW,QAAQ,CACvB,QAAO;CAGR,MAAM,MAAM,MAAM,+BAAS,SAAS,QAAQ;AAC5C,QAAO,IAAI,MAAM;AACjB;;;;;;;;;AA4CD,eAAsB,eACrBC,OACAD,aACkB;CAClB,MAAM,cAAc,MAAM,QAAQ,OAAO,YAAY;AAErD,KAAI,YACH,QAAO;AAGR,QAAO,YAAY,OAAO,YAAY;AACtC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { basename, join } from "node:path";
|
|
3
|
+
import { chmod, mkdir, readFile, writeFile } from "node:fs/promises";
|
|
4
|
+
import { homedir } from "node:os";
|
|
5
|
+
import { randomBytes } from "node:crypto";
|
|
6
|
+
|
|
7
|
+
//#region src/secrets/keystore.ts
|
|
8
|
+
/** Key length for AES-256 encryption */
|
|
9
|
+
const KEY_LENGTH = 32;
|
|
10
|
+
/**
|
|
11
|
+
* Get the keystore directory for a project.
|
|
12
|
+
* Keys are stored at ~/.gkm/{project-name}/
|
|
13
|
+
*
|
|
14
|
+
* @param projectName - Name of the project (defaults to current directory name)
|
|
15
|
+
* @returns Path to the keystore directory
|
|
16
|
+
*/
|
|
17
|
+
function getKeystoreDir(projectName) {
|
|
18
|
+
const name = projectName ?? basename(process.cwd());
|
|
19
|
+
return join(homedir(), ".gkm", name);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Get the path to a stage's encryption key.
|
|
23
|
+
*
|
|
24
|
+
* @param stage - Stage name (e.g., 'development', 'production')
|
|
25
|
+
* @param projectName - Name of the project (defaults to current directory name)
|
|
26
|
+
* @returns Path to the key file
|
|
27
|
+
*/
|
|
28
|
+
function getKeyPath(stage, projectName) {
|
|
29
|
+
return join(getKeystoreDir(projectName), `${stage}.key`);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Generate a new encryption key for a stage.
|
|
33
|
+
* The key is stored at ~/.gkm/{project-name}/{stage}.key with restricted permissions.
|
|
34
|
+
*
|
|
35
|
+
* @param stage - Stage name
|
|
36
|
+
* @param projectName - Project name (defaults to current directory name)
|
|
37
|
+
* @returns The generated key as a hex string
|
|
38
|
+
*/
|
|
39
|
+
async function generateKey(stage, projectName) {
|
|
40
|
+
const keyDir = getKeystoreDir(projectName);
|
|
41
|
+
const keyPath = getKeyPath(stage, projectName);
|
|
42
|
+
await mkdir(keyDir, {
|
|
43
|
+
recursive: true,
|
|
44
|
+
mode: 448
|
|
45
|
+
});
|
|
46
|
+
const key = randomBytes(KEY_LENGTH).toString("hex");
|
|
47
|
+
await writeFile(keyPath, key, {
|
|
48
|
+
mode: 384,
|
|
49
|
+
encoding: "utf-8"
|
|
50
|
+
});
|
|
51
|
+
await chmod(keyPath, 384);
|
|
52
|
+
return key;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Read an encryption key for a stage.
|
|
56
|
+
*
|
|
57
|
+
* @param stage - Stage name
|
|
58
|
+
* @param projectName - Project name (defaults to current directory name)
|
|
59
|
+
* @returns The key as a hex string, or null if not found
|
|
60
|
+
*/
|
|
61
|
+
async function readKey(stage, projectName) {
|
|
62
|
+
const keyPath = getKeyPath(stage, projectName);
|
|
63
|
+
if (!existsSync(keyPath)) return null;
|
|
64
|
+
const key = await readFile(keyPath, "utf-8");
|
|
65
|
+
return key.trim();
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Get or create a key for a stage.
|
|
69
|
+
* If the key already exists, it is returned. Otherwise, a new key is generated.
|
|
70
|
+
*
|
|
71
|
+
* @param stage - Stage name
|
|
72
|
+
* @param projectName - Project name (defaults to current directory name)
|
|
73
|
+
* @returns The key as a hex string
|
|
74
|
+
*/
|
|
75
|
+
async function getOrCreateKey(stage, projectName) {
|
|
76
|
+
const existingKey = await readKey(stage, projectName);
|
|
77
|
+
if (existingKey) return existingKey;
|
|
78
|
+
return generateKey(stage, projectName);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
//#endregion
|
|
82
|
+
export { getKeyPath, getOrCreateKey, readKey };
|
|
83
|
+
//# sourceMappingURL=keystore-TxeYM7an.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keystore-TxeYM7an.mjs","names":["projectName?: string","stage: string"],"sources":["../src/secrets/keystore.ts"],"sourcesContent":["import { randomBytes } from 'node:crypto';\nimport { existsSync } from 'node:fs';\nimport { chmod, mkdir, readFile, rm, writeFile } from 'node:fs/promises';\nimport { homedir } from 'node:os';\nimport { basename, join } from 'node:path';\n\n/** Key length for AES-256 encryption */\nconst KEY_LENGTH = 32; // 256 bits\n\n/**\n * Get the keystore directory for a project.\n * Keys are stored at ~/.gkm/{project-name}/\n *\n * @param projectName - Name of the project (defaults to current directory name)\n * @returns Path to the keystore directory\n */\nexport function getKeystoreDir(projectName?: string): string {\n\tconst name = projectName ?? basename(process.cwd());\n\treturn join(homedir(), '.gkm', name);\n}\n\n/**\n * Get the path to a stage's encryption key.\n *\n * @param stage - Stage name (e.g., 'development', 'production')\n * @param projectName - Name of the project (defaults to current directory name)\n * @returns Path to the key file\n */\nexport function getKeyPath(stage: string, projectName?: string): string {\n\treturn join(getKeystoreDir(projectName), `${stage}.key`);\n}\n\n/**\n * Check if a key exists for a stage.\n */\nexport function keyExists(stage: string, projectName?: string): boolean {\n\treturn existsSync(getKeyPath(stage, projectName));\n}\n\n/**\n * Generate a new encryption key for a stage.\n * The key is stored at ~/.gkm/{project-name}/{stage}.key with restricted permissions.\n *\n * @param stage - Stage name\n * @param projectName - Project name (defaults to current directory name)\n * @returns The generated key as a hex string\n */\nexport async function generateKey(\n\tstage: string,\n\tprojectName?: string,\n): Promise<string> {\n\tconst keyDir = getKeystoreDir(projectName);\n\tconst keyPath = getKeyPath(stage, projectName);\n\n\t// Ensure keystore directory exists with restricted permissions\n\tawait mkdir(keyDir, { recursive: true, mode: 0o700 });\n\n\t// Generate random key\n\tconst key = randomBytes(KEY_LENGTH).toString('hex');\n\n\t// Write key with restricted permissions (owner read/write only)\n\tawait writeFile(keyPath, key, { mode: 0o600, encoding: 'utf-8' });\n\n\t// Ensure permissions are set correctly (in case file existed)\n\tawait chmod(keyPath, 0o600);\n\n\treturn key;\n}\n\n/**\n * Read an encryption key for a stage.\n *\n * @param stage - Stage name\n * @param projectName - Project name (defaults to current directory name)\n * @returns The key as a hex string, or null if not found\n */\nexport async function readKey(\n\tstage: string,\n\tprojectName?: string,\n): Promise<string | null> {\n\tconst keyPath = getKeyPath(stage, projectName);\n\n\tif (!existsSync(keyPath)) {\n\t\treturn null;\n\t}\n\n\tconst key = await readFile(keyPath, 'utf-8');\n\treturn key.trim();\n}\n\n/**\n * Read an encryption key for a stage, throwing if not found.\n */\nexport async function requireKey(\n\tstage: string,\n\tprojectName?: string,\n): Promise<string> {\n\tconst key = await readKey(stage, projectName);\n\n\tif (!key) {\n\t\tconst name = projectName ?? basename(process.cwd());\n\t\tthrow new Error(\n\t\t\t`Encryption key not found for stage \"${stage}\" in project \"${name}\". ` +\n\t\t\t\t`Expected key at: ${getKeyPath(stage, projectName)}`,\n\t\t);\n\t}\n\n\treturn key;\n}\n\n/**\n * Delete a key for a stage.\n */\nexport async function deleteKey(\n\tstage: string,\n\tprojectName?: string,\n): Promise<void> {\n\tconst keyPath = getKeyPath(stage, projectName);\n\n\tif (existsSync(keyPath)) {\n\t\tawait rm(keyPath);\n\t}\n}\n\n/**\n * Get or create a key for a stage.\n * If the key already exists, it is returned. Otherwise, a new key is generated.\n *\n * @param stage - Stage name\n * @param projectName - Project name (defaults to current directory name)\n * @returns The key as a hex string\n */\nexport async function getOrCreateKey(\n\tstage: string,\n\tprojectName?: string,\n): Promise<string> {\n\tconst existingKey = await readKey(stage, projectName);\n\n\tif (existingKey) {\n\t\treturn existingKey;\n\t}\n\n\treturn generateKey(stage, projectName);\n}\n"],"mappings":";;;;;;;;AAOA,MAAM,aAAa;;;;;;;;AASnB,SAAgB,eAAeA,aAA8B;CAC5D,MAAM,OAAO,eAAe,SAAS,QAAQ,KAAK,CAAC;AACnD,QAAO,KAAK,SAAS,EAAE,QAAQ,KAAK;AACpC;;;;;;;;AASD,SAAgB,WAAWC,OAAeD,aAA8B;AACvE,QAAO,KAAK,eAAe,YAAY,GAAG,EAAE,MAAM,MAAM;AACxD;;;;;;;;;AAiBD,eAAsB,YACrBC,OACAD,aACkB;CAClB,MAAM,SAAS,eAAe,YAAY;CAC1C,MAAM,UAAU,WAAW,OAAO,YAAY;AAG9C,OAAM,MAAM,QAAQ;EAAE,WAAW;EAAM,MAAM;CAAO,EAAC;CAGrD,MAAM,MAAM,YAAY,WAAW,CAAC,SAAS,MAAM;AAGnD,OAAM,UAAU,SAAS,KAAK;EAAE,MAAM;EAAO,UAAU;CAAS,EAAC;AAGjE,OAAM,MAAM,SAAS,IAAM;AAE3B,QAAO;AACP;;;;;;;;AASD,eAAsB,QACrBC,OACAD,aACyB;CACzB,MAAM,UAAU,WAAW,OAAO,YAAY;AAE9C,MAAK,WAAW,QAAQ,CACvB,QAAO;CAGR,MAAM,MAAM,MAAM,SAAS,SAAS,QAAQ;AAC5C,QAAO,IAAI,MAAM;AACjB;;;;;;;;;AA4CD,eAAsB,eACrBC,OACAD,aACkB;CAClB,MAAM,cAAc,MAAM,QAAQ,OAAO,YAAY;AAErD,KAAI,YACH,QAAO;AAGR,QAAO,YAAY,OAAO,YAAY;AACtC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
2
2
|
const require_discover = require('./discover-DTmFeloL.cjs');
|
|
3
|
-
const require_config = require('./config-
|
|
3
|
+
const require_config = require('./config-HhDpJmLO.cjs');
|
|
4
4
|
const node_path = require_chunk.__toESM(require("node:path"));
|
|
5
5
|
const __geekmidas_manifest = require_chunk.__toESM(require("@geekmidas/manifest"));
|
|
6
6
|
const node_fs_promises = require_chunk.__toESM(require("node:fs/promises"));
|
|
@@ -2072,4 +2072,4 @@ Object.defineProperty(exports, 'runtimeFor', {
|
|
|
2072
2072
|
return runtimeFor;
|
|
2073
2073
|
}
|
|
2074
2074
|
});
|
|
2075
|
-
//# sourceMappingURL=openapi-
|
|
2075
|
+
//# sourceMappingURL=openapi-DaKlTKxz.cjs.map
|