@mtndev/cli 2.0.0 → 2.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.
Files changed (264) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/cjs/__chunks/VH7oDXx4.cjs +28 -0
  3. package/cjs/commands/aws/ec2/allow-ip/handler.cjs +261 -12
  4. package/cjs/commands/aws/ec2/allow-ip/index.cjs +25 -55
  5. package/cjs/commands/aws/ec2/allow-ip/schema.cjs +33 -13
  6. package/cjs/commands/aws/ec2/allow-ip/utils.cjs +379 -39
  7. package/cjs/commands/aws/iam/admin-group.cjs +111 -15
  8. package/cjs/commands/aws/iam/break-glass/handler.cjs +127 -12
  9. package/cjs/commands/aws/iam/break-glass/index.cjs +7 -19
  10. package/cjs/commands/aws/iam/break-glass/schema.cjs +21 -12
  11. package/cjs/commands/aws/iam/check-admin/handler.cjs +89 -10
  12. package/cjs/commands/aws/iam/check-admin/index.cjs +7 -17
  13. package/cjs/commands/aws/iam/check-admin/schema.cjs +19 -12
  14. package/cjs/commands/aws/iam/policies/s3-restrictions-deny-non-s3-services.json +20 -0
  15. package/cjs/commands/aws/iam/policies/sts-federation.json +11 -0
  16. package/cjs/commands/aws/iam/policies/user-admins-deny-list.json +175 -0
  17. package/cjs/commands/aws/iam/policies/user-admins-deny-regions-list.json +41 -0
  18. package/cjs/commands/aws/iam/policies/user-admins-self-service-iam.json +56 -0
  19. package/cjs/commands/aws/iam/policies/user-admins-write-list.json +117 -0
  20. package/cjs/commands/aws/iam/remove-admin/handler.cjs +120 -11
  21. package/cjs/commands/aws/iam/remove-admin/index.cjs +7 -18
  22. package/cjs/commands/aws/iam/remove-admin/schema.cjs +22 -12
  23. package/cjs/commands/aws/iam/setup-acl/handler.cjs +227 -14
  24. package/cjs/commands/aws/iam/setup-acl/index.cjs +13 -33
  25. package/cjs/commands/aws/iam/setup-acl/schema.cjs +19 -7
  26. package/cjs/commands/aws/iam/setup-acl/utils.cjs +305 -20
  27. package/cjs/commands/aws/iam/users/handler.cjs +59 -12
  28. package/cjs/commands/aws/iam/users/index.cjs +18 -41
  29. package/cjs/commands/aws/iam/users/schema.cjs +17 -7
  30. package/cjs/commands/aws/iam/users/utils.cjs +454 -30
  31. package/cjs/commands/aws/index.cjs +223 -229
  32. package/cjs/commands/aws/route53/add-record/handler.cjs +264 -18
  33. package/cjs/commands/aws/route53/add-record/index.cjs +26 -57
  34. package/cjs/commands/aws/route53/add-record/schema.cjs +43 -11
  35. package/cjs/commands/aws/route53/add-record/utils.cjs +404 -37
  36. package/cjs/commands/aws/route53/remove-record/handler.cjs +114 -14
  37. package/cjs/commands/aws/route53/remove-record/index.cjs +5 -18
  38. package/cjs/commands/aws/route53/remove-record/schema.cjs +22 -8
  39. package/cjs/commands/aws/schema.cjs +19 -10
  40. package/cjs/commands/aws/ses/send-email/handler.cjs +73 -12
  41. package/cjs/commands/aws/ses/send-email/index.cjs +9 -23
  42. package/cjs/commands/aws/ses/send-email/schema.cjs +24 -7
  43. package/cjs/commands/aws/ses/send-email/utils.cjs +87 -11
  44. package/cjs/commands/aws/ses/smtp-password.cjs +72 -10
  45. package/cjs/commands/aws/utils/exec-aws.cjs +145 -16
  46. package/cjs/commands/aws/utils/resolve-policy-path.cjs +15 -6
  47. package/cjs/commands/aws/utils/resolve-profile.cjs +93 -11
  48. package/cjs/commands/aws/utils/tty.cjs +54 -10
  49. package/cjs/commands/db/create-readonly-user/handler.cjs +254 -11
  50. package/cjs/commands/db/create-readonly-user/index.cjs +18 -40
  51. package/cjs/commands/db/create-readonly-user/mysql.cjs +102 -9
  52. package/cjs/commands/db/create-readonly-user/postgres.cjs +209 -9
  53. package/cjs/commands/db/create-readonly-user/schema.cjs +39 -12
  54. package/cjs/commands/db/create-readonly-user/utils.cjs +160 -22
  55. package/cjs/commands/db/index.cjs +46 -44
  56. package/cjs/commands/doppler/handler.cjs +95 -11
  57. package/cjs/commands/doppler/index.cjs +33 -68
  58. package/cjs/commands/doppler/schema.cjs +130 -14
  59. package/cjs/commands/doppler/set-secret.cjs +378 -19
  60. package/cjs/commands/doppler/utils/exec.cjs +106 -12
  61. package/cjs/commands/doppler/utils.cjs +412 -34
  62. package/cjs/commands/icons/handler.cjs +82 -8
  63. package/cjs/commands/icons/index.cjs +15 -31
  64. package/cjs/commands/icons/schema.cjs +101 -13
  65. package/cjs/commands/icons/utils.cjs +131 -13
  66. package/cjs/commands/index.cjs +54 -161
  67. package/cjs/commands/schema.cjs +25 -8
  68. package/cjs/index.cjs +3 -4
  69. package/esm/commands/aws/ec2/allow-ip/handler.js +258 -12
  70. package/esm/commands/aws/ec2/allow-ip/index.js +4 -55
  71. package/esm/commands/aws/ec2/allow-ip/schema.js +29 -13
  72. package/esm/commands/aws/ec2/allow-ip/utils.js +363 -39
  73. package/esm/commands/aws/iam/admin-group.js +104 -15
  74. package/esm/commands/aws/iam/break-glass/handler.js +124 -12
  75. package/esm/commands/aws/iam/break-glass/index.js +4 -19
  76. package/esm/commands/aws/iam/break-glass/schema.js +19 -12
  77. package/esm/commands/aws/iam/check-admin/handler.js +86 -10
  78. package/esm/commands/aws/iam/check-admin/index.js +4 -17
  79. package/esm/commands/aws/iam/check-admin/schema.js +17 -12
  80. package/esm/commands/aws/iam/policies/s3-restrictions-deny-non-s3-services.json +20 -0
  81. package/esm/commands/aws/iam/policies/sts-federation.json +11 -0
  82. package/esm/commands/aws/iam/policies/user-admins-deny-list.json +175 -0
  83. package/esm/commands/aws/iam/policies/user-admins-deny-regions-list.json +41 -0
  84. package/esm/commands/aws/iam/policies/user-admins-self-service-iam.json +56 -0
  85. package/esm/commands/aws/iam/policies/user-admins-write-list.json +117 -0
  86. package/esm/commands/aws/iam/remove-admin/handler.js +117 -11
  87. package/esm/commands/aws/iam/remove-admin/index.js +4 -18
  88. package/esm/commands/aws/iam/remove-admin/schema.js +20 -12
  89. package/esm/commands/aws/iam/setup-acl/handler.js +224 -14
  90. package/esm/commands/aws/iam/setup-acl/index.js +4 -33
  91. package/esm/commands/aws/iam/setup-acl/schema.js +18 -7
  92. package/esm/commands/aws/iam/setup-acl/utils.js +298 -20
  93. package/esm/commands/aws/iam/users/handler.js +56 -12
  94. package/esm/commands/aws/iam/users/index.js +4 -41
  95. package/esm/commands/aws/iam/users/schema.js +16 -7
  96. package/esm/commands/aws/iam/users/utils.js +440 -30
  97. package/esm/commands/aws/index.js +142 -229
  98. package/esm/commands/aws/route53/add-record/handler.js +258 -18
  99. package/esm/commands/aws/route53/add-record/index.js +4 -57
  100. package/esm/commands/aws/route53/add-record/schema.js +40 -11
  101. package/esm/commands/aws/route53/add-record/utils.js +389 -37
  102. package/esm/commands/aws/route53/remove-record/handler.js +111 -14
  103. package/esm/commands/aws/route53/remove-record/index.js +3 -18
  104. package/esm/commands/aws/route53/remove-record/schema.js +21 -8
  105. package/esm/commands/aws/schema.js +16 -10
  106. package/esm/commands/aws/ses/send-email/handler.js +70 -12
  107. package/esm/commands/aws/ses/send-email/index.js +4 -23
  108. package/esm/commands/aws/ses/send-email/schema.js +23 -7
  109. package/esm/commands/aws/ses/send-email/utils.js +84 -11
  110. package/esm/commands/aws/ses/smtp-password.js +69 -10
  111. package/esm/commands/aws/utils/exec-aws.js +136 -15
  112. package/esm/commands/aws/utils/resolve-policy-path.js +14 -6
  113. package/esm/commands/aws/utils/resolve-profile.js +88 -11
  114. package/esm/commands/aws/utils/tty.js +51 -10
  115. package/esm/commands/db/create-readonly-user/handler.js +251 -11
  116. package/esm/commands/db/create-readonly-user/index.js +4 -40
  117. package/esm/commands/db/create-readonly-user/mysql.js +98 -9
  118. package/esm/commands/db/create-readonly-user/postgres.js +205 -9
  119. package/esm/commands/db/create-readonly-user/schema.js +35 -12
  120. package/esm/commands/db/create-readonly-user/utils.js +151 -22
  121. package/esm/commands/db/index.js +31 -44
  122. package/esm/commands/doppler/handler.js +92 -11
  123. package/esm/commands/doppler/index.js +6 -68
  124. package/esm/commands/doppler/schema.js +125 -15
  125. package/esm/commands/doppler/set-secret.js +370 -19
  126. package/esm/commands/doppler/utils/exec.js +100 -12
  127. package/esm/commands/doppler/utils.js +396 -34
  128. package/esm/commands/icons/handler.js +79 -8
  129. package/esm/commands/icons/index.js +4 -31
  130. package/esm/commands/icons/schema.js +97 -15
  131. package/esm/commands/icons/utils.js +125 -13
  132. package/esm/commands/index.js +47 -155
  133. package/esm/commands/schema.js +22 -7
  134. package/esm/index.js +3 -4
  135. package/package.json +5 -2
  136. package/vitest.config.ts +11 -0
  137. package/cjs/__chunks/2FSYDFUV.cjs +0 -146
  138. package/cjs/__chunks/3A5ZYU5M.cjs +0 -105
  139. package/cjs/__chunks/3BY5Y4W7.cjs +0 -1
  140. package/cjs/__chunks/3NOHGUCF.cjs +0 -9
  141. package/cjs/__chunks/3T2LXW7J.cjs +0 -387
  142. package/cjs/__chunks/4SFWHCB3.cjs +0 -133
  143. package/cjs/__chunks/4XT5JEAS.cjs +0 -1
  144. package/cjs/__chunks/AZEB4H4I.cjs +0 -208
  145. package/cjs/__chunks/B2KFW7T7.cjs +0 -1
  146. package/cjs/__chunks/B5ENMOCD.cjs +0 -288
  147. package/cjs/__chunks/B6XM5KSF.cjs +0 -338
  148. package/cjs/__chunks/BDU2UCE5.cjs +0 -1
  149. package/cjs/__chunks/BLMSMR5E.cjs +0 -46
  150. package/cjs/__chunks/CMUD7LLN.cjs +0 -47
  151. package/cjs/__chunks/DTQ2LB3I.cjs +0 -49
  152. package/cjs/__chunks/FM5MVRQF.cjs +0 -23
  153. package/cjs/__chunks/FRHST54J.cjs +0 -135
  154. package/cjs/__chunks/FU4VP2LN.cjs +0 -1
  155. package/cjs/__chunks/G5K4PVIL.cjs +0 -26
  156. package/cjs/__chunks/GU3R54MK.cjs +0 -127
  157. package/cjs/__chunks/GUL36IFZ.cjs +0 -61
  158. package/cjs/__chunks/GZMTNK5N.cjs +0 -1
  159. package/cjs/__chunks/H74JSDBU.cjs +0 -30
  160. package/cjs/__chunks/INFOPAHN.cjs +0 -117
  161. package/cjs/__chunks/J36P6UNE.cjs +0 -75
  162. package/cjs/__chunks/JB7T7PKQ.cjs +0 -538
  163. package/cjs/__chunks/JSL2JDMW.cjs +0 -1
  164. package/cjs/__chunks/K4QNHRTP.cjs +0 -163
  165. package/cjs/__chunks/KU76LC42.cjs +0 -192
  166. package/cjs/__chunks/LFDSHANP.cjs +0 -34
  167. package/cjs/__chunks/LHE24ECK.cjs +0 -192
  168. package/cjs/__chunks/LIKQ3SI4.cjs +0 -1
  169. package/cjs/__chunks/LXDF5QVZ.cjs +0 -313
  170. package/cjs/__chunks/LXOOJR2R.cjs +0 -74
  171. package/cjs/__chunks/N5MXFOQZ.cjs +0 -167
  172. package/cjs/__chunks/N7D56LPP.cjs +0 -25
  173. package/cjs/__chunks/NFXQNOQH.cjs +0 -393
  174. package/cjs/__chunks/NIMXXHJQ.cjs +0 -92
  175. package/cjs/__chunks/NLKJIUEX.cjs +0 -126
  176. package/cjs/__chunks/NT2XXAI6.cjs +0 -89
  177. package/cjs/__chunks/NWZGFHKH.cjs +0 -121
  178. package/cjs/__chunks/R3GUC7O7.cjs +0 -110
  179. package/cjs/__chunks/RPVAXPJ4.cjs +0 -1
  180. package/cjs/__chunks/S3LVCWPN.cjs +0 -23
  181. package/cjs/__chunks/SBBNW2BF.cjs +0 -249
  182. package/cjs/__chunks/T2A7TN4F.cjs +0 -81
  183. package/cjs/__chunks/TKNNDDIB.cjs +0 -97
  184. package/cjs/__chunks/TNSRDJPR.cjs +0 -1
  185. package/cjs/__chunks/UWHPE2GI.cjs +0 -20
  186. package/cjs/__chunks/W6K7BV74.cjs +0 -1
  187. package/cjs/__chunks/WBOQ6AUN.cjs +0 -320
  188. package/cjs/__chunks/WHGN5PZI.cjs +0 -299
  189. package/cjs/__chunks/WOYF2L6T.cjs +0 -11
  190. package/cjs/__chunks/X26XY2N6.cjs +0 -18
  191. package/cjs/__chunks/XMKOKRXZ.cjs +0 -16
  192. package/cjs/__chunks/XTJPQ3EX.cjs +0 -1
  193. package/cjs/__chunks/YRHFKTW2.cjs +0 -63
  194. package/cjs/__chunks/ZMDIOZPT.cjs +0 -22
  195. package/cjs/commands/aws/iam/policies/s3-restrictions-deny-non-s3-services.cjs +0 -28
  196. package/cjs/commands/aws/iam/policies/sts-federation.cjs +0 -19
  197. package/cjs/commands/aws/iam/policies/user-admins-deny-list.cjs +0 -183
  198. package/cjs/commands/aws/iam/policies/user-admins-deny-regions-list.cjs +0 -49
  199. package/cjs/commands/aws/iam/policies/user-admins-self-service-iam.cjs +0 -64
  200. package/cjs/commands/aws/iam/policies/user-admins-write-list.cjs +0 -125
  201. package/esm/__chunks/2FTTEFEK.js +0 -97
  202. package/esm/__chunks/33UYMUQD.js +0 -338
  203. package/esm/__chunks/3BKWTHLJ.js +0 -25
  204. package/esm/__chunks/3HE4BEJX.js +0 -105
  205. package/esm/__chunks/3QLI5BDL.js +0 -387
  206. package/esm/__chunks/5GIUAFXL.js +0 -89
  207. package/esm/__chunks/5ZBVGSOK.js +0 -0
  208. package/esm/__chunks/6G4PXXKF.js +0 -75
  209. package/esm/__chunks/73BJG53F.js +0 -11
  210. package/esm/__chunks/7VF4Q43Q.js +0 -0
  211. package/esm/__chunks/AEDEAYF5.js +0 -0
  212. package/esm/__chunks/AZCP3SFJ.js +0 -0
  213. package/esm/__chunks/B2DVQ2UL.js +0 -61
  214. package/esm/__chunks/CVQVHLW5.js +0 -0
  215. package/esm/__chunks/D62SPZXC.js +0 -0
  216. package/esm/__chunks/DLEJ25GZ.js +0 -121
  217. package/esm/__chunks/DMYFNF54.js +0 -192
  218. package/esm/__chunks/DNFTUMGD.js +0 -23
  219. package/esm/__chunks/DVKD6YSR.js +0 -49
  220. package/esm/__chunks/EMSH4P76.js +0 -20
  221. package/esm/__chunks/FFKFVMIE.js +0 -167
  222. package/esm/__chunks/FL7AILGH.js +0 -133
  223. package/esm/__chunks/FNXUONAV.js +0 -110
  224. package/esm/__chunks/G4NJHFFU.js +0 -320
  225. package/esm/__chunks/HJSXC6HP.js +0 -117
  226. package/esm/__chunks/IEOGAQYI.js +0 -46
  227. package/esm/__chunks/IZFGBYGE.js +0 -34
  228. package/esm/__chunks/J34UVKLA.js +0 -26
  229. package/esm/__chunks/JZPBBBIG.js +0 -74
  230. package/esm/__chunks/KWUJP5MG.js +0 -135
  231. package/esm/__chunks/M35URMT4.js +0 -313
  232. package/esm/__chunks/NF3M2L6C.js +0 -81
  233. package/esm/__chunks/O3CCA76Q.js +0 -22
  234. package/esm/__chunks/PNPPDYKC.js +0 -299
  235. package/esm/__chunks/QFXN4EHM.js +0 -393
  236. package/esm/__chunks/QKDDLIWD.js +0 -146
  237. package/esm/__chunks/QSE66AKY.js +0 -208
  238. package/esm/__chunks/QUF7PS4R.js +0 -18
  239. package/esm/__chunks/S7IJPJ4R.js +0 -126
  240. package/esm/__chunks/SD3E3EPH.js +0 -163
  241. package/esm/__chunks/SJXQJ7RS.js +0 -92
  242. package/esm/__chunks/SNCKIAOR.js +0 -0
  243. package/esm/__chunks/T3TTUHTW.js +0 -30
  244. package/esm/__chunks/TIOVE6HR.js +0 -0
  245. package/esm/__chunks/TXKMEIDQ.js +0 -0
  246. package/esm/__chunks/U7HAE2RF.js +0 -288
  247. package/esm/__chunks/UXWY7BYE.js +0 -63
  248. package/esm/__chunks/VKAKISRG.js +0 -192
  249. package/esm/__chunks/WD2YR6I7.js +0 -0
  250. package/esm/__chunks/WOZFZKFY.js +0 -0
  251. package/esm/__chunks/XI7GZDE2.js +0 -0
  252. package/esm/__chunks/XOUWDB3T.js +0 -249
  253. package/esm/__chunks/XQN2TA4S.js +0 -23
  254. package/esm/__chunks/XXK32TIM.js +0 -16
  255. package/esm/__chunks/YGWTVPZE.js +0 -538
  256. package/esm/__chunks/YRG7PT33.js +0 -127
  257. package/esm/__chunks/ZHKVJO2U.js +0 -47
  258. package/esm/__chunks/ZO55YUSY.js +0 -9
  259. package/esm/commands/aws/iam/policies/s3-restrictions-deny-non-s3-services.js +0 -28
  260. package/esm/commands/aws/iam/policies/sts-federation.js +0 -19
  261. package/esm/commands/aws/iam/policies/user-admins-deny-list.js +0 -183
  262. package/esm/commands/aws/iam/policies/user-admins-deny-regions-list.js +0 -49
  263. package/esm/commands/aws/iam/policies/user-admins-self-service-iam.js +0 -64
  264. package/esm/commands/aws/iam/policies/user-admins-write-list.js +0 -125
@@ -1,313 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
-
3
-
4
- var _3A5ZYU5Mcjs = require('./3A5ZYU5M.cjs');
5
-
6
-
7
-
8
- var _K4QNHRTPcjs = require('./K4QNHRTP.cjs');
9
-
10
-
11
-
12
-
13
-
14
- var _H74JSDBUcjs = require('./H74JSDBU.cjs');
15
-
16
-
17
-
18
-
19
-
20
-
21
- var _NWZGFHKHcjs = require('./NWZGFHKH.cjs');
22
-
23
-
24
-
25
-
26
- var _CMUD7LLNcjs = require('./CMUD7LLN.cjs');
27
-
28
- // src/commands/db/create-readonly-user/handler.js
29
- var _chalk = require('chalk'); var _chalk2 = _interopRequireDefault(_chalk);
30
- var _zod = require('zod');
31
- async function resolveEngine(engineOption, url) {
32
- if (engineOption) {
33
- return engineOption;
34
- }
35
- if (url) {
36
- const detected = _NWZGFHKHcjs.detectEngineFromUrl.call(void 0, url);
37
- if (detected) {
38
- return detected;
39
- }
40
- }
41
- const index = await _CMUD7LLNcjs.promptChoice.call(void 0, {
42
- message: "Choose a database engine:",
43
- options: ["postgres", "mysql"]
44
- });
45
- const chosen = _H74JSDBUcjs.ENGINES[index];
46
- if (!chosen) {
47
- throw new Error("No engine selected");
48
- }
49
- return chosen;
50
- }
51
- async function resolveUrl(params) {
52
- const { urlOption, engine } = params;
53
- const fromEnv = _NWZGFHKHcjs.resolveAdminUrl.call(void 0, { url: urlOption, engine });
54
- if (fromEnv) {
55
- return fromEnv;
56
- }
57
- const example = engine === "postgres" ? "postgresql://admin:pass@host:5432/postgres" : "mysql://admin:pass@host:3306/";
58
- const raw = await _CMUD7LLNcjs.prompt.call(void 0, ` Admin connection URL (e.g. ${example}): `);
59
- if (!raw) {
60
- throw new Error(
61
- "Admin connection URL is required (pass --url or set DATABASE_URL)"
62
- );
63
- }
64
- return raw;
65
- }
66
- async function resolveScope(params) {
67
- const { databaseOption, databases } = params;
68
- if (databaseOption) {
69
- const normalized = databaseOption.trim().toLowerCase();
70
- if (normalized === "all" || normalized === "*") {
71
- return { mode: "all", databases };
72
- }
73
- if (!databases.includes(databaseOption)) {
74
- throw new Error(
75
- `Database "${databaseOption}" not found. Available: ${databases.join(", ") || "(none)"}`
76
- );
77
- }
78
- return { mode: "one", databases: [databaseOption] };
79
- }
80
- if (databases.length === 0) {
81
- throw new Error("No user databases found to grant access on.");
82
- }
83
- const options = [
84
- ...databases.map((name) => name),
85
- `all (${databases.length} databases)`
86
- ];
87
- const index = await _CMUD7LLNcjs.promptChoice.call(void 0, {
88
- message: "Grant read-only on which database?",
89
- options
90
- });
91
- if (index === options.length - 1) {
92
- return { mode: "all", databases };
93
- }
94
- const chosen = databases[index];
95
- if (!chosen) {
96
- throw new Error("No database selected");
97
- }
98
- return { mode: "one", databases: [chosen] };
99
- }
100
- async function resolveUsername(usernameOption) {
101
- if (usernameOption) {
102
- return usernameOption;
103
- }
104
- const raw = await _CMUD7LLNcjs.prompt.call(void 0,
105
- ` Read-only username [default: ${_H74JSDBUcjs.DEFAULT_READONLY_USERNAME}]: `
106
- );
107
- const username = raw || _H74JSDBUcjs.DEFAULT_READONLY_USERNAME;
108
- if (!/^[A-Za-z0-9_]+$/.test(username)) {
109
- throw new Error(
110
- "Username must contain only letters, numbers, and underscores"
111
- );
112
- }
113
- return username;
114
- }
115
- async function resolvePassword(passwordOption) {
116
- if (passwordOption) {
117
- return { password: passwordOption, generated: false };
118
- }
119
- const generate = await _CMUD7LLNcjs.promptYesNo.call(void 0, {
120
- message: " Generate a random password?",
121
- defaultYes: true
122
- });
123
- if (generate) {
124
- return { password: _NWZGFHKHcjs.generatePassword.call(void 0, ), generated: true };
125
- }
126
- const password = await _CMUD7LLNcjs.prompt.call(void 0, " Password: ");
127
- if (!password) {
128
- throw new Error("Password is required");
129
- }
130
- return { password, generated: false };
131
- }
132
- function redactUrl(url) {
133
- try {
134
- const parsed = new URL(url);
135
- if (parsed.password) {
136
- parsed.password = "***";
137
- }
138
- return parsed.toString();
139
- } catch (e) {
140
- return url;
141
- }
142
- }
143
- async function createReadonlyUserCommand(options) {
144
- try {
145
- const {
146
- engine: engineOption,
147
- url: urlOption,
148
- database: databaseOption,
149
- username: usernameOption,
150
- password: passwordOption,
151
- hostPattern: hostPatternOption,
152
- ssl: sslOption,
153
- yes,
154
- dryRun,
155
- verbose
156
- } = _H74JSDBUcjs.createReadonlyUserOptionsSchema.parse(options);
157
- console.log(_chalk2.default.blue("\nCreate read-only database user"));
158
- console.log("");
159
- const urlForDetect = _NWZGFHKHcjs.resolveAdminUrl.call(void 0, {
160
- url: urlOption,
161
- engine: engineOption
162
- });
163
- const engine = await resolveEngine(engineOption, urlForDetect);
164
- console.log(`Engine: ${engine}`);
165
- const url = await resolveUrl({ urlOption, engine });
166
- const config = _NWZGFHKHcjs.parseConnectionUrl.call(void 0, {
167
- url,
168
- engine,
169
- sslOption
170
- });
171
- console.log(
172
- `Admin: ${config.user}@${config.host}:${config.port}` + (config.database ? `/${config.database}` : "")
173
- );
174
- console.log("");
175
- const listed = engine === "postgres" ? await _K4QNHRTPcjs.listPostgresDatabases.call(void 0, config) : await _3A5ZYU5Mcjs.listMysqlDatabases.call(void 0, config);
176
- if (verbose) {
177
- console.log(`Found databases: ${listed.join(", ") || "(none)"}`);
178
- console.log("");
179
- }
180
- const scope = await resolveScope({
181
- databaseOption,
182
- databases: listed
183
- });
184
- console.log(
185
- scope.mode === "all" ? `Scope: all (${scope.databases.length} databases)` : `Scope: ${scope.databases[0]}`
186
- );
187
- console.log("");
188
- const username = await resolveUsername(usernameOption);
189
- const { password, generated } = await resolvePassword(passwordOption);
190
- const hostPattern = _nullishCoalesce(hostPatternOption, () => ( _H74JSDBUcjs.DEFAULT_MYSQL_HOST_PATTERN));
191
- console.log("");
192
- console.log("Plan:");
193
- console.log(` User: ${username}`);
194
- console.log(
195
- ` Password: ${generated ? "(generated)" : "(provided)"}${dryRun ? " [dry-run]" : ""}`
196
- );
197
- if (engine === "mysql") {
198
- console.log(` Host: ${hostPattern}`);
199
- }
200
- console.log(
201
- scope.mode === "all" ? ` Grants: SELECT on ALL databases (${scope.databases.length})` : ` Grants: SELECT on ${scope.databases[0]}`
202
- );
203
- if (scope.mode === "all" && engine === "postgres") {
204
- console.log(
205
- _chalk2.default.yellow(
206
- " Note: Databases created later will NOT get these grants automatically \u2014 re-run this command."
207
- )
208
- );
209
- }
210
- console.log("");
211
- if (!yes && !dryRun) {
212
- const confirmed = await _CMUD7LLNcjs.promptYesNo.call(void 0, {
213
- message: "Apply these changes?",
214
- defaultYes: false
215
- });
216
- if (!confirmed) {
217
- console.log("Aborted.");
218
- return;
219
- }
220
- console.log("");
221
- }
222
- const result = engine === "postgres" ? await _K4QNHRTPcjs.applyPostgresReadonly.call(void 0, {
223
- config,
224
- username,
225
- password,
226
- databases: scope.databases,
227
- dryRun,
228
- verbose
229
- }) : await _3A5ZYU5Mcjs.applyMysqlReadonly.call(void 0, {
230
- config,
231
- username,
232
- password,
233
- databases: scope.mode === "all" ? "all" : scope.databases,
234
- hostPattern,
235
- dryRun,
236
- verbose
237
- });
238
- if (dryRun) {
239
- console.log(_chalk2.default.cyan("Dry run \u2014 SQL that would run:"));
240
- for (const statement of result.statements) {
241
- console.log(` ${statement}`);
242
- }
243
- console.log("");
244
- console.log(_chalk2.default.cyan("No changes made."));
245
- return;
246
- }
247
- console.log(
248
- _chalk2.default.green(
249
- result.created ? `Created user "${username}" and granted read-only access.` : `Updated user "${username}" password and refreshed read-only grants.`
250
- )
251
- );
252
- console.log("");
253
- const sampleDb = scope.mode === "one" ? _nullishCoalesce(scope.databases[0], () => ( "")) : _nullishCoalesce(scope.databases[0], () => ( ""));
254
- const readonlyUrl = _NWZGFHKHcjs.buildReadonlyUrl.call(void 0, {
255
- engine,
256
- host: config.host,
257
- port: config.port,
258
- username,
259
- password,
260
- database: sampleDb
261
- });
262
- console.log("Connection (secret shown once \u2014 copy now):");
263
- console.log(
264
- "\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"
265
- );
266
- console.log(readonlyUrl);
267
- if (scope.mode === "all") {
268
- console.log("");
269
- console.log(
270
- _chalk2.default.gray(
271
- ` (URL uses database "${sampleDb}" as an example; user can connect to any granted database.)`
272
- )
273
- );
274
- }
275
- console.log(
276
- "\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"
277
- );
278
- console.log("");
279
- console.log(_chalk2.default.gray(`Admin URL used: ${redactUrl(url)}`));
280
- } catch (error) {
281
- if (error instanceof _zod.ZodError) {
282
- console.error(_chalk2.default.red("\n\u274C Invalid command options:"));
283
- error.errors.forEach((err) => {
284
- console.error(_chalk2.default.red(` ${err.path.join(".")}: ${err.message}`));
285
- });
286
- process.exit(1);
287
- }
288
- const verbose = (
289
- /** @type {any} */
290
- _optionalChain([options, 'optionalAccess', _ => _.verbose]) || false
291
- );
292
- console.error(_chalk2.default.red("\n\u274C create-readonly-user failed:"));
293
- if (error instanceof Error) {
294
- console.error(_chalk2.default.red(` ${error.message}`));
295
- if (verbose && error.stack) {
296
- console.error(_chalk2.default.gray("\nStack trace:"));
297
- console.error(_chalk2.default.gray(error.stack));
298
- }
299
- } else {
300
- console.error(_chalk2.default.red(` ${String(error)}`));
301
- }
302
- console.error(
303
- _chalk2.default.yellow(
304
- "\n\u{1F4A1} Pass --url or set DATABASE_URL. Use --verbose for details.\n"
305
- )
306
- );
307
- process.exit(1);
308
- }
309
- }
310
-
311
-
312
-
313
- exports.createReadonlyUserCommand = createReadonlyUserCommand;
@@ -1,74 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
-
3
- var _XMKOKRXZcjs = require('./XMKOKRXZ.cjs');
4
-
5
-
6
- var _3T2LXW7Jcjs = require('./3T2LXW7J.cjs');
7
-
8
-
9
-
10
- var _R3GUC7O7cjs = require('./R3GUC7O7.cjs');
11
-
12
-
13
- var _NT2XXAI6cjs = require('./NT2XXAI6.cjs');
14
-
15
- // src/commands/aws/iam/users/handler.js
16
- var _chalk = require('chalk'); var _chalk2 = _interopRequireDefault(_chalk);
17
- var _zod = require('zod');
18
- async function usersCommand(options) {
19
- try {
20
- const {
21
- accountName,
22
- profile: profileOption,
23
- verbose
24
- } = _XMKOKRXZcjs.usersOptionsSchema.parse(options);
25
- _R3GUC7O7cjs.requireCommands.call(void 0, ["aws"]);
26
- const profile = await _NT2XXAI6cjs.resolveProfile.call(void 0, { profile: profileOption });
27
- console.log(_chalk2.default.blue("\nAWS IAM user management"));
28
- console.log("");
29
- console.log("Caller:");
30
- const identity = _R3GUC7O7cjs.getCallerIdentity.call(void 0, { profile, verbose });
31
- console.log(` Account: ${identity.Account}`);
32
- console.log(` Arn: ${identity.Arn}`);
33
- console.log("");
34
- await _3T2LXW7Jcjs.createUsersInteractive.call(void 0, {
35
- accountName,
36
- profile,
37
- identity,
38
- verbose
39
- });
40
- console.log("Done.");
41
- } catch (error) {
42
- if (error instanceof _zod.ZodError) {
43
- console.error(_chalk2.default.red("\n\u274C Invalid command options:"));
44
- error.errors.forEach((err) => {
45
- console.error(_chalk2.default.red(` ${err.path.join(".")}: ${err.message}`));
46
- });
47
- process.exit(1);
48
- }
49
- const verbose = (
50
- /** @type {any} */
51
- _optionalChain([options, 'optionalAccess', _ => _.verbose]) || false
52
- );
53
- console.error(_chalk2.default.red("\n\u274C iam users failed:"));
54
- if (error instanceof Error) {
55
- console.error(_chalk2.default.red(` ${error.message}`));
56
- if (verbose && error.stack) {
57
- console.error(_chalk2.default.gray("\nStack trace:"));
58
- console.error(_chalk2.default.gray(error.stack));
59
- }
60
- } else {
61
- console.error(_chalk2.default.red(` ${String(error)}`));
62
- }
63
- console.error(
64
- _chalk2.default.yellow(
65
- "\n\u{1F4A1} Requires the AWS CLI and a profile with IAM write access.\n"
66
- )
67
- );
68
- process.exit(1);
69
- }
70
- }
71
-
72
-
73
-
74
- exports.usersCommand = usersCommand;
@@ -1,167 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
-
3
- var _S3LVCWPNcjs = require('./S3LVCWPN.cjs');
4
-
5
-
6
-
7
-
8
- var _T2A7TN4Fcjs = require('./T2A7TN4F.cjs');
9
-
10
-
11
- var _R3GUC7O7cjs = require('./R3GUC7O7.cjs');
12
-
13
-
14
- var _CMUD7LLNcjs = require('./CMUD7LLN.cjs');
15
-
16
- // src/commands/aws/iam/remove-admin/handler.js
17
- var _chalk = require('chalk'); var _chalk2 = _interopRequireDefault(_chalk);
18
- var _zod = require('zod');
19
- async function removeAdminCommand(options) {
20
- try {
21
- const { profile, all, user, yes, dryRun, verbose } = _S3LVCWPNcjs.removeAdminOptionsSchema.parse(options);
22
- _R3GUC7O7cjs.requireCommands.call(void 0, ["aws"]);
23
- const userFilter = new Set(user);
24
- const needsVault = all || !(_nullishCoalesce(profile, () => ( process.env.AWS_PROFILE)));
25
- if (needsVault) {
26
- _R3GUC7O7cjs.requireCommands.call(void 0, ["aws-vault"]);
27
- }
28
- let profiles;
29
- try {
30
- profiles = _T2A7TN4Fcjs.resolveAdminScanProfiles.call(void 0, { profile, all });
31
- } catch (resolveError) {
32
- if (resolveError instanceof Error && resolveError.message === "No aws-vault profiles with credentials found.") {
33
- console.error(_chalk2.default.red(resolveError.message));
34
- process.exit(1);
35
- }
36
- throw resolveError;
37
- }
38
- console.log(
39
- _chalk2.default.blue(
40
- `
41
- ==> Removing break-glass access (${_T2A7TN4Fcjs.ADMIN_GROUP_NAME}) across ${profiles.length} profile(s)
42
- `
43
- )
44
- );
45
- if (dryRun) {
46
- console.log(_chalk2.default.yellow("[dry-run] No changes will be made.\n"));
47
- }
48
- let removed = 0;
49
- let cleaned = 0;
50
- let skipped = 0;
51
- for (const candidate of profiles) {
52
- const scan = _T2A7TN4Fcjs.resolveProfileScan.call(void 0, { profile: candidate, verbose });
53
- if (!scan) {
54
- skipped += 1;
55
- continue;
56
- }
57
- if (scan.users.length === 0) {
58
- if (verbose) {
59
- console.log(
60
- _chalk2.default.green(`OK ${candidate} (${scan.accountId}) \u2014 0 users`)
61
- );
62
- }
63
- cleaned += 1;
64
- continue;
65
- }
66
- const targets = userFilter.size > 0 ? scan.users.filter((name) => userFilter.has(name)) : scan.users;
67
- if (targets.length === 0) {
68
- console.log(
69
- _chalk2.default.dim(
70
- `-- ${candidate} (${scan.accountId}) \u2014 has users but none match --user`
71
- )
72
- );
73
- skipped += 1;
74
- continue;
75
- }
76
- console.log(
77
- _chalk2.default.red(
78
- `FOUND ${candidate} (${scan.accountId}) \u2014 ${targets.length} user(s): ${targets.join(", ")}`
79
- )
80
- );
81
- if (dryRun) {
82
- for (const name of targets) {
83
- console.log(
84
- _chalk2.default.yellow(
85
- ` [dry-run] would remove ${name} from ${_T2A7TN4Fcjs.ADMIN_GROUP_NAME}`
86
- )
87
- );
88
- }
89
- continue;
90
- }
91
- let confirmed = yes;
92
- if (!confirmed) {
93
- confirmed = await _CMUD7LLNcjs.promptYesNo.call(void 0, {
94
- message: ` Remove ${targets.length} user(s) from ${_T2A7TN4Fcjs.ADMIN_GROUP_NAME} in ${candidate}?`,
95
- defaultYes: false
96
- });
97
- }
98
- if (!confirmed) {
99
- console.log(_chalk2.default.dim(" skipped (not confirmed)"));
100
- skipped += 1;
101
- continue;
102
- }
103
- for (const name of targets) {
104
- try {
105
- scan.run(
106
- [
107
- "iam",
108
- "remove-user-from-group",
109
- "--group-name",
110
- _T2A7TN4Fcjs.ADMIN_GROUP_NAME,
111
- "--user-name",
112
- name
113
- ],
114
- { expectJson: false }
115
- );
116
- console.log(_chalk2.default.green(` removed ${name}`));
117
- removed += 1;
118
- } catch (removeError) {
119
- const reason = removeError instanceof Error ? _nullishCoalesce(removeError.message.split("\n")[0], () => ( "")) : String(removeError);
120
- console.log(_chalk2.default.red(` failed to remove ${name}: ${reason}`));
121
- }
122
- }
123
- }
124
- console.log(_chalk2.default.blue("\n==> Summary"));
125
- console.log(` Profiles scanned: ${profiles.length}`);
126
- console.log(` Users removed: ${removed}`);
127
- console.log(` Already clean: ${cleaned}`);
128
- console.log(` Skipped: ${skipped}`);
129
- if (dryRun) {
130
- console.log(
131
- _chalk2.default.yellow("\n[dry-run] Re-run without --dry-run to apply changes.")
132
- );
133
- }
134
- } catch (error) {
135
- if (error instanceof _zod.ZodError) {
136
- console.error(_chalk2.default.red("\n\u274C Invalid command options:"));
137
- error.errors.forEach((err) => {
138
- console.error(_chalk2.default.red(` ${err.path.join(".")}: ${err.message}`));
139
- });
140
- process.exit(1);
141
- }
142
- const verbose = (
143
- /** @type {any} */
144
- _optionalChain([options, 'optionalAccess', _ => _.verbose]) || false
145
- );
146
- console.error(_chalk2.default.red("\n\u274C remove-admin failed:"));
147
- if (error instanceof Error) {
148
- console.error(_chalk2.default.red(` ${error.message}`));
149
- if (verbose && error.stack) {
150
- console.error(_chalk2.default.gray("\nStack trace:"));
151
- console.error(_chalk2.default.gray(error.stack));
152
- }
153
- } else {
154
- console.error(_chalk2.default.red(` ${String(error)}`));
155
- }
156
- console.error(
157
- _chalk2.default.yellow(
158
- "\n\u{1F4A1} Requires the AWS CLI (and aws-vault when scanning multiple profiles) and iam:RemoveUserFromGroup.\n"
159
- )
160
- );
161
- process.exit(1);
162
- }
163
- }
164
-
165
-
166
-
167
- exports.removeAdminCommand = removeAdminCommand;
@@ -1,25 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
-
3
-
4
- var _WOYF2L6Tcjs = require('./WOYF2L6T.cjs');
5
-
6
- // src/commands/aws/ses/send-email/schema.js
7
- var _zod = require('zod');
8
- var sendEmailOptionsSchema = _zod.z.object({
9
- to: _zod.z.string({ required_error: "--to <address> is required" }).describe("Recipient email address"),
10
- from: _zod.z.string({ required_error: "--from <address> is required" }).describe("Verified SES sender email address"),
11
- subject: _zod.z.string().optional().default("MTN CLI test email").describe("Email subject line"),
12
- body: _zod.z.string().optional().describe("Email body (defaults to a timestamp and random token)"),
13
- transport: _zod.z.enum(["api", "smtp"]).optional().default("api").describe("Send via the SES API (default) or SES SMTP"),
14
- region: _zod.z.string().optional().default("us-east-1").describe("AWS region for the SES endpoint"),
15
- profile: _WOYF2L6Tcjs.profileField,
16
- accessKeyId: _zod.z.string().optional().describe(
17
- "IAM access key ID used as the SMTP username (smtp transport only)"
18
- ),
19
- dryRun: _zod.z.boolean().optional().default(false).describe("Print the email payload without sending"),
20
- verbose: _WOYF2L6Tcjs.verboseField
21
- });
22
-
23
-
24
-
25
- exports.sendEmailOptionsSchema = sendEmailOptionsSchema;