@geekmidas/cli 10.0.0-alpha.10 → 10.0.0-alpha.12

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.
Files changed (157) hide show
  1. package/README.md +13 -40
  2. package/dist/{CachedStateProvider-CqPdW7CB.cjs → CachedStateProvider-BEBl2wQT.cjs} +1 -1
  3. package/dist/{CachedStateProvider-CqPdW7CB.cjs.map → CachedStateProvider-BEBl2wQT.cjs.map} +1 -1
  4. package/dist/CachedStateProvider-C-8wtlto.mjs +3 -0
  5. package/dist/{CachedStateProvider-DTniehMP.mjs → CachedStateProvider-Co4n5Wvs.mjs} +1 -1
  6. package/dist/{CachedStateProvider-DTniehMP.mjs.map → CachedStateProvider-Co4n5Wvs.mjs.map} +1 -1
  7. package/dist/{CachedStateProvider-BLo7zv7S.cjs → CachedStateProvider-DqhGpzsm.cjs} +1 -1
  8. package/dist/{HostingerProvider-h3EbEp-Z.cjs → HostingerProvider-BOvsgATO.cjs} +1 -1
  9. package/dist/{HostingerProvider-h3EbEp-Z.cjs.map → HostingerProvider-BOvsgATO.cjs.map} +1 -1
  10. package/dist/{HostingerProvider-Cft7lEYr.mjs → HostingerProvider-BcyFRbqV.mjs} +1 -1
  11. package/dist/{HostingerProvider-Cft7lEYr.mjs.map → HostingerProvider-BcyFRbqV.mjs.map} +1 -1
  12. package/dist/{LocalStateProvider-Bn6tS-oL.mjs → LocalStateProvider-Bq-0C0sg.mjs} +1 -1
  13. package/dist/{LocalStateProvider-Bn6tS-oL.mjs.map → LocalStateProvider-Bq-0C0sg.mjs.map} +1 -1
  14. package/dist/{LocalStateProvider-Db9SEjyH.cjs → LocalStateProvider-yjXZXZDM.cjs} +1 -1
  15. package/dist/{LocalStateProvider-Db9SEjyH.cjs.map → LocalStateProvider-yjXZXZDM.cjs.map} +1 -1
  16. package/dist/{Route53Provider-RdpUDJQk.mjs → Route53Provider-C0xmer8U.mjs} +1 -1
  17. package/dist/{Route53Provider-RdpUDJQk.mjs.map → Route53Provider-C0xmer8U.mjs.map} +1 -1
  18. package/dist/{Route53Provider-di2fMM5N.cjs → Route53Provider-CH9XH7bz.cjs} +1 -1
  19. package/dist/{Route53Provider-di2fMM5N.cjs.map → Route53Provider-CH9XH7bz.cjs.map} +1 -1
  20. package/dist/{SSMStateProvider-DyX8s9HI.cjs → SSMStateProvider-CXtNgPfy.cjs} +1 -1
  21. package/dist/{SSMStateProvider-DyX8s9HI.cjs.map → SSMStateProvider-CXtNgPfy.cjs.map} +1 -1
  22. package/dist/{SSMStateProvider-BRt2py-A.mjs → SSMStateProvider-DOZifZfE.mjs} +1 -1
  23. package/dist/{SSMStateProvider-BRt2py-A.mjs.map → SSMStateProvider-DOZifZfE.mjs.map} +1 -1
  24. package/dist/{backup-provisioner-Bgj5Vi_L.mjs → backup-provisioner-DXXg6FIL.mjs} +1 -1
  25. package/dist/{backup-provisioner-Bgj5Vi_L.mjs.map → backup-provisioner-DXXg6FIL.mjs.map} +1 -1
  26. package/dist/{backup-provisioner-BrsHwYG0.cjs → backup-provisioner-cE2PuCTb.cjs} +1 -1
  27. package/dist/{backup-provisioner-BrsHwYG0.cjs.map → backup-provisioner-cE2PuCTb.cjs.map} +1 -1
  28. package/dist/{bundler-BY1OmV1e.cjs → bundler-BMekgx7a.cjs} +4 -19
  29. package/dist/bundler-BMekgx7a.cjs.map +1 -0
  30. package/dist/{bundler-Be8Zg4Wd.mjs → bundler-Bux2iF-v.mjs} +4 -19
  31. package/dist/bundler-Bux2iF-v.mjs.map +1 -0
  32. package/dist/{config-DVVph9yz.mjs → config-DTsVjKZD.mjs} +3 -3
  33. package/dist/{config-DVVph9yz.mjs.map → config-DTsVjKZD.mjs.map} +1 -1
  34. package/dist/{config-BZ1F0WuA.cjs → config-RYR9j6EF.cjs} +3 -3
  35. package/dist/{config-BZ1F0WuA.cjs.map → config-RYR9j6EF.cjs.map} +1 -1
  36. package/dist/config.cjs +3 -3
  37. package/dist/config.d.cts +2 -2
  38. package/dist/config.d.mts +2 -2
  39. package/dist/config.mjs +3 -3
  40. package/dist/{credentials-Xamqe_NJ.cjs → credentials-DQRvPz2S.cjs} +1166 -1078
  41. package/dist/credentials-DQRvPz2S.cjs.map +1 -0
  42. package/dist/{credentials-dP8vRVRv.mjs → credentials-jMJC63qs.mjs} +1145 -1069
  43. package/dist/credentials-jMJC63qs.mjs.map +1 -0
  44. package/dist/{discover-CAlFgYec.mjs → discover-BYHQwQqu.mjs} +15 -2
  45. package/dist/discover-BYHQwQqu.mjs.map +1 -0
  46. package/dist/{discover-DTmFeloL.cjs → discover-DmW9Bscc.cjs} +20 -1
  47. package/dist/discover-DmW9Bscc.cjs.map +1 -0
  48. package/dist/dokploy-api-5cK2InBm.cjs +3 -0
  49. package/dist/dokploy-api-D2Ny4Jrc.mjs +3 -0
  50. package/dist/{dokploy-api-aTFPz7_4.mjs → dokploy-api-pdaBryoY.mjs} +1 -1
  51. package/dist/{dokploy-api-aTFPz7_4.mjs.map → dokploy-api-pdaBryoY.mjs.map} +1 -1
  52. package/dist/{dokploy-api-BsVH0y_s.cjs → dokploy-api-zqKe9lHH.cjs} +1 -1
  53. package/dist/{dokploy-api-BsVH0y_s.cjs.map → dokploy-api-zqKe9lHH.cjs.map} +1 -1
  54. package/dist/{emit-CiZS_5Ub.mjs → emit-CIlvnDvV.mjs} +1 -1
  55. package/dist/{emit-CiZS_5Ub.mjs.map → emit-CIlvnDvV.mjs.map} +1 -1
  56. package/dist/{emit-CbcRolsa.cjs → emit-CUD1BWls.cjs} +1 -1
  57. package/dist/{emit-CbcRolsa.cjs.map → emit-CUD1BWls.cjs.map} +1 -1
  58. package/dist/{encryption-C6jaU0hE.cjs → encryption-D2pL3tHH.cjs} +1 -1
  59. package/dist/{encryption-C6jaU0hE.cjs.map → encryption-D2pL3tHH.cjs.map} +1 -1
  60. package/dist/encryption-YDsXXi6w.mjs +3 -0
  61. package/dist/{encryption-D-abyhZx.mjs → encryption-_4zwjOAR.mjs} +1 -1
  62. package/dist/{encryption-D-abyhZx.mjs.map → encryption-_4zwjOAR.mjs.map} +1 -1
  63. package/dist/{encryption-CHzzeR8a.cjs → encryption-sQ2Oxx0d.cjs} +1 -1
  64. package/dist/{fullstack-secrets-D1o9-G5l.mjs → fullstack-secrets-B6KBHf-g.mjs} +2 -2
  65. package/dist/{fullstack-secrets-D1o9-G5l.mjs.map → fullstack-secrets-B6KBHf-g.mjs.map} +1 -1
  66. package/dist/{fullstack-secrets-C-GGohke.cjs → fullstack-secrets-DL8v0y4D.cjs} +1 -13
  67. package/dist/{fullstack-secrets-C-GGohke.cjs.map → fullstack-secrets-DL8v0y4D.cjs.map} +1 -1
  68. package/dist/github-BThvbf2W.cjs +197 -0
  69. package/dist/github-BThvbf2W.cjs.map +1 -0
  70. package/dist/github-DpMZurEK.mjs +196 -0
  71. package/dist/github-DpMZurEK.mjs.map +1 -0
  72. package/dist/{index-CR5urhWX.d.cts → index-BzJ7QJ9c.d.mts} +2 -6
  73. package/dist/index-BzJ7QJ9c.d.mts.map +1 -0
  74. package/dist/{index-C6e-ULLx.d.mts → index-CfMjtdVC.d.cts} +2 -6
  75. package/dist/index-CfMjtdVC.d.cts.map +1 -0
  76. package/dist/index.cjs +474 -1381
  77. package/dist/index.cjs.map +1 -1
  78. package/dist/index.mjs +474 -1381
  79. package/dist/index.mjs.map +1 -1
  80. package/dist/keystore-C9rint2E.cjs +101 -0
  81. package/dist/keystore-C9rint2E.cjs.map +1 -0
  82. package/dist/keystore-TxeYM7an.mjs +83 -0
  83. package/dist/keystore-TxeYM7an.mjs.map +1 -0
  84. package/dist/{openapi-Xx0A7Wg0.mjs → openapi-Bs3-5q_r.mjs} +3 -3
  85. package/dist/{openapi-Xx0A7Wg0.mjs.map → openapi-Bs3-5q_r.mjs.map} +1 -1
  86. package/dist/{openapi-SjsgARie.cjs → openapi-DWLTsYLL.cjs} +3 -3
  87. package/dist/{openapi-SjsgARie.cjs.map → openapi-DWLTsYLL.cjs.map} +1 -1
  88. package/dist/openapi.cjs +4 -4
  89. package/dist/openapi.d.cts +1 -1
  90. package/dist/openapi.d.mts +1 -1
  91. package/dist/openapi.mjs +4 -4
  92. package/dist/reconcile/public.cjs +2 -2
  93. package/dist/reconcile/public.d.cts +1 -1
  94. package/dist/reconcile/public.d.mts +1 -1
  95. package/dist/reconcile/public.mjs +2 -2
  96. package/dist/{reconcile-CFs8C_1a.mjs → reconcile-BI0tWkwz.mjs} +2 -2
  97. package/dist/{reconcile-CFs8C_1a.mjs.map → reconcile-BI0tWkwz.mjs.map} +1 -1
  98. package/dist/{reconcile-D0pimNiy.cjs → reconcile-Bhw5fmKu.cjs} +2 -2
  99. package/dist/{reconcile-D0pimNiy.cjs.map → reconcile-Bhw5fmKu.cjs.map} +1 -1
  100. package/dist/setup-BmLoNrDX.mjs +12 -0
  101. package/dist/setup-BrR1_xGy.cjs +12 -0
  102. package/dist/{setup-hC6hI86f.cjs → setup-BsNR2LBG.cjs} +16 -22
  103. package/dist/setup-BsNR2LBG.cjs.map +1 -0
  104. package/dist/{setup-C8KOx8_8.mjs → setup-D5-JMknk.mjs} +16 -22
  105. package/dist/setup-D5-JMknk.mjs.map +1 -0
  106. package/dist/{storage-Bi24WfoW.mjs → storage-B020InPW.mjs} +4 -79
  107. package/dist/storage-B020InPW.mjs.map +1 -0
  108. package/dist/{storage-BJmzYxt8.cjs → storage-CSNplaJn.cjs} +4 -85
  109. package/dist/storage-CSNplaJn.cjs.map +1 -0
  110. package/dist/{storage-CYlGwWTj.mjs → storage-DGBzMLZa.mjs} +2 -1
  111. package/dist/{storage-BM9hGpgv.cjs → storage-DlVol_oj.cjs} +2 -1
  112. package/dist/{sync-SizaChmC.cjs → sync-0ILCb-1S.cjs} +2 -2
  113. package/dist/{sync-SizaChmC.cjs.map → sync-0ILCb-1S.cjs.map} +1 -1
  114. package/dist/{sync-CmEuNZsB.mjs → sync-CzHXiR9c.mjs} +2 -2
  115. package/dist/{sync-CmEuNZsB.mjs.map → sync-CzHXiR9c.mjs.map} +1 -1
  116. package/dist/sync-DYENfOt4.cjs +4 -0
  117. package/dist/{sync-hOqAWHR6.mjs → sync-HAau6h_R.mjs} +1 -1
  118. package/dist/{types-6pkp2RRj.d.mts → types-DVIx8I1N.d.mts} +4 -274
  119. package/dist/types-DVIx8I1N.d.mts.map +1 -0
  120. package/dist/{types-Y3fKQSAK.d.cts → types-PMP_qXRY.d.cts} +4 -274
  121. package/dist/types-PMP_qXRY.d.cts.map +1 -0
  122. package/dist/workspace/index.cjs +1 -1
  123. package/dist/workspace/index.d.cts +3 -3
  124. package/dist/workspace/index.d.mts +3 -3
  125. package/dist/workspace/index.mjs +1 -1
  126. package/dist/workspace-Cji6lE8E.cjs +10 -0
  127. package/dist/workspace-CkJAtRIX.mjs +9 -0
  128. package/dist/{workspace-zoqRbihZ.mjs → workspace-CtnZnWsa.mjs} +40 -72
  129. package/dist/workspace-CtnZnWsa.mjs.map +1 -0
  130. package/dist/{workspace-C6VJQVtG.cjs → workspace-DPV7FtAv.cjs} +45 -71
  131. package/dist/workspace-DPV7FtAv.cjs.map +1 -0
  132. package/package.json +11 -11
  133. package/dist/CachedStateProvider-BxoAm-B2.mjs +0 -3
  134. package/dist/bundler-BY1OmV1e.cjs.map +0 -1
  135. package/dist/bundler-Be8Zg4Wd.mjs.map +0 -1
  136. package/dist/credentials-Xamqe_NJ.cjs.map +0 -1
  137. package/dist/credentials-dP8vRVRv.mjs.map +0 -1
  138. package/dist/discover-CAlFgYec.mjs.map +0 -1
  139. package/dist/discover-DTmFeloL.cjs.map +0 -1
  140. package/dist/dokploy-api-BS2xnJLZ.mjs +0 -3
  141. package/dist/dokploy-api-BuxDRo3l.cjs +0 -3
  142. package/dist/encryption-CQUncu7v.mjs +0 -3
  143. package/dist/index-C6e-ULLx.d.mts.map +0 -1
  144. package/dist/index-CR5urhWX.d.cts.map +0 -1
  145. package/dist/setup-BA8ciTPU.mjs +0 -11
  146. package/dist/setup-BsZvZP6f.cjs +0 -11
  147. package/dist/setup-C8KOx8_8.mjs.map +0 -1
  148. package/dist/setup-hC6hI86f.cjs.map +0 -1
  149. package/dist/storage-BJmzYxt8.cjs.map +0 -1
  150. package/dist/storage-Bi24WfoW.mjs.map +0 -1
  151. package/dist/sync-D306yOWu.cjs +0 -4
  152. package/dist/types-6pkp2RRj.d.mts.map +0 -1
  153. package/dist/types-Y3fKQSAK.d.cts.map +0 -1
  154. package/dist/workspace-BzrG_2SI.mjs +0 -8
  155. package/dist/workspace-C6VJQVtG.cjs.map +0 -1
  156. package/dist/workspace-XXtNhqJl.cjs +0 -9
  157. 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,5 +1,5 @@
1
- import { ConstructGenerator, isPartitionedRoutes } from "./discover-CAlFgYec.mjs";
2
- import { loadWorkspaceConfig } from "./config-DVVph9yz.mjs";
1
+ import { ConstructGenerator, isPartitionedRoutes } from "./discover-BYHQwQqu.mjs";
2
+ import { loadWorkspaceConfig } from "./config-DTsVjKZD.mjs";
3
3
  import { dirname, join, relative, resolve } from "node:path";
4
4
  import { kebabCase } from "@geekmidas/manifest";
5
5
  import { mkdir, writeFile } from "node:fs/promises";
@@ -2018,4 +2018,4 @@ async function runOpenApiInSubprocess(appCwd, appName) {
2018
2018
 
2019
2019
  //#endregion
2020
2020
  export { EndpointGenerator, OPENAPI_OUTPUT_PATH, generateOpenApi, generateOpenApiFrom, normalizeRoutes, openApiPathFor, openapiCommand, resolveOpenApiConfig, runtimeFor };
2021
- //# sourceMappingURL=openapi-Xx0A7Wg0.mjs.map
2021
+ //# sourceMappingURL=openapi-Bs3-5q_r.mjs.map