@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,121 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }// src/commands/db/create-readonly-user/utils.js
2
- var _crypto = require('crypto');
3
- function generatePassword(params = {}) {
4
- const { length = 24 } = params;
5
- const alphabet = "ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz23456789!@#$%^&*";
6
- const bytes = _crypto.randomBytes.call(void 0, length);
7
- let result = "";
8
- for (let i = 0; i < length; i += 1) {
9
- const byte = _nullishCoalesce(bytes[i], () => ( 0));
10
- result += alphabet[byte % alphabet.length];
11
- }
12
- return result;
13
- }
14
- function detectEngineFromUrl(url) {
15
- const trimmed = url.trim().toLowerCase();
16
- if (trimmed.startsWith("postgres://") || trimmed.startsWith("postgresql://")) {
17
- return "postgres";
18
- }
19
- if (trimmed.startsWith("mysql://") || trimmed.startsWith("mysql2://")) {
20
- return "mysql";
21
- }
22
- return null;
23
- }
24
- function resolveAdminUrl(params) {
25
- const { url, engine } = params;
26
- if (url) {
27
- return url;
28
- }
29
- if (engine === "mysql") {
30
- return _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(process.env.MYSQL_URL, () => ( process.env.DATABASE_URL)), () => ( process.env.MYSQL_DATABASE_URL)), () => ( null));
31
- }
32
- if (engine === "postgres") {
33
- return _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(process.env.DATABASE_URL, () => ( process.env.POSTGRES_URL)), () => ( process.env.POSTGRESQL_URL)), () => ( null));
34
- }
35
- return _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(process.env.DATABASE_URL, () => ( process.env.POSTGRES_URL)), () => ( process.env.POSTGRESQL_URL)), () => ( process.env.MYSQL_URL)), () => ( process.env.MYSQL_DATABASE_URL)), () => ( null));
36
- }
37
- function resolveSsl(params) {
38
- const { host, sslOption } = params;
39
- if (sslOption === true) {
40
- return { rejectUnauthorized: false };
41
- }
42
- if (sslOption === false) {
43
- return false;
44
- }
45
- const local = host === "localhost" || host === "127.0.0.1" || host === "::1" || host === "0.0.0.0";
46
- if (local) {
47
- return false;
48
- }
49
- return { rejectUnauthorized: false };
50
- }
51
- function parseConnectionUrl(params) {
52
- const { url, engine: engineOption, sslOption } = params;
53
- const engine = _nullishCoalesce(engineOption, () => ( detectEngineFromUrl(url)));
54
- if (!engine) {
55
- throw new Error(
56
- `Could not detect engine from URL. Pass --engine postgres|mysql. URL starts with: ${url.slice(0, 24)}\u2026`
57
- );
58
- }
59
- let parsed;
60
- try {
61
- parsed = new URL(url);
62
- } catch (e) {
63
- throw new Error(`Invalid connection URL: ${url}`);
64
- }
65
- const defaultPort = engine === "postgres" ? 5432 : 3306;
66
- const port = parsed.port ? Number.parseInt(parsed.port, 10) : defaultPort;
67
- const database = decodeURIComponent(parsed.pathname.replace(/^\//, "")) || (engine === "postgres" ? "postgres" : "");
68
- const host = parsed.hostname || "localhost";
69
- const user = decodeURIComponent(parsed.username || "");
70
- const password = decodeURIComponent(parsed.password || "");
71
- if (!user) {
72
- throw new Error("Connection URL is missing a username");
73
- }
74
- return {
75
- engine,
76
- host,
77
- port: Number.isFinite(port) ? port : defaultPort,
78
- user,
79
- password,
80
- database,
81
- ssl: resolveSsl({ host, sslOption }),
82
- url
83
- };
84
- }
85
- function buildReadonlyUrl(params) {
86
- const { engine, host, port, username, password, database } = params;
87
- const scheme = engine === "postgres" ? "postgresql" : "mysql";
88
- const auth = `${encodeURIComponent(username)}:${encodeURIComponent(password)}`;
89
- const dbPath = database ? `/${encodeURIComponent(database)}` : "/";
90
- return `${scheme}://${auth}@${host}:${port}${dbPath}`;
91
- }
92
- function quoteIdent(params) {
93
- const { engine, name } = params;
94
- if (engine === "postgres") {
95
- return `"${name.replace(/"/g, '""')}"`;
96
- }
97
- return `\`${name.replace(/`/g, "``")}\``;
98
- }
99
- function quoteLiteral(value) {
100
- return `'${value.replace(/'/g, "''")}'`;
101
- }
102
- function isSystemDatabase(params) {
103
- const { engine, name } = params;
104
- const lower = name.toLowerCase();
105
- if (engine === "postgres") {
106
- return lower === "template0" || lower === "template1" || lower === "rdsadmin" || lower === "cloudsqladmin";
107
- }
108
- return lower === "information_schema" || lower === "performance_schema" || lower === "mysql" || lower === "sys" || lower === "innodb" || lower === "#mysql50#lost+found";
109
- }
110
-
111
-
112
-
113
-
114
-
115
-
116
-
117
-
118
-
119
-
120
-
121
- exports.generatePassword = generatePassword; exports.detectEngineFromUrl = detectEngineFromUrl; exports.resolveAdminUrl = resolveAdminUrl; exports.resolveSsl = resolveSsl; exports.parseConnectionUrl = parseConnectionUrl; exports.buildReadonlyUrl = buildReadonlyUrl; exports.quoteIdent = quoteIdent; exports.quoteLiteral = quoteLiteral; exports.isSystemDatabase = isSystemDatabase;
@@ -1,110 +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; }// src/commands/aws/utils/exec-aws.js
2
- var _child_process = require('child_process');
3
- var _chalk = require('chalk'); var _chalk2 = _interopRequireDefault(_chalk);
4
- var AwsCliError = class extends Error {
5
- /**
6
- * @param {string} message
7
- * @param {string | null} [code]
8
- */
9
- constructor(message, code = null) {
10
- super(message);
11
- this.name = "AwsCliError";
12
- this.code = code;
13
- }
14
- };
15
- function parseAwsErrorCode(stderr) {
16
- const match = /\(([A-Za-z.]+)\)/.exec(stderr);
17
- return _nullishCoalesce(_optionalChain([match, 'optionalAccess', _ => _[1]]), () => ( null));
18
- }
19
- function requireCommands(commands) {
20
- const missing = commands.filter((command) => {
21
- const result = _child_process.spawnSync.call(void 0, "which", [command], { stdio: "pipe" });
22
- return result.status !== 0;
23
- });
24
- if (missing.length > 0) {
25
- throw new Error(
26
- `Required command(s) not found on PATH: ${missing.join(", ")}`
27
- );
28
- }
29
- }
30
- function runAws(params) {
31
- const {
32
- profile,
33
- region,
34
- args,
35
- expectJson = true,
36
- verbose = false,
37
- env
38
- } = params;
39
- const finalArgs = [];
40
- if (profile) finalArgs.push("--profile", profile);
41
- if (region) finalArgs.push("--region", region);
42
- finalArgs.push("--no-cli-pager", ...args);
43
- if (expectJson) finalArgs.push("--output", "json");
44
- return spawnAws("aws", finalArgs, { expectJson, verbose, env });
45
- }
46
- function runAwsVault(params) {
47
- const {
48
- profile,
49
- args,
50
- duration = "15m",
51
- expectJson = true,
52
- verbose = false
53
- } = params;
54
- const awsArgs = ["--no-cli-pager", ...args];
55
- if (expectJson) awsArgs.push("--output", "json");
56
- const finalArgs = [
57
- "exec",
58
- profile,
59
- "--duration",
60
- duration,
61
- "--",
62
- "aws",
63
- ...awsArgs
64
- ];
65
- return spawnAws("aws-vault", finalArgs, { expectJson, verbose });
66
- }
67
- function spawnAws(command, args, options) {
68
- const { expectJson, verbose, env } = options;
69
- if (verbose) {
70
- console.log(_chalk2.default.gray(` Executing: ${command} ${args.join(" ")}`));
71
- }
72
- const result = _child_process.spawnSync.call(void 0, command, args, {
73
- encoding: "utf-8",
74
- env: env ? { ...process.env, ...env } : process.env
75
- });
76
- if (result.error) {
77
- throw new AwsCliError(result.error.message);
78
- }
79
- if (result.status !== 0) {
80
- const stderr = (result.stderr || result.stdout || "").trim();
81
- const message = stderr || `Command failed: ${command} ${args.join(" ")}`;
82
- throw new AwsCliError(message, parseAwsErrorCode(stderr));
83
- }
84
- const stdout = (_nullishCoalesce(result.stdout, () => ( ""))).trim();
85
- if (!expectJson) {
86
- return stdout;
87
- }
88
- if (!stdout) {
89
- return {};
90
- }
91
- return JSON.parse(stdout);
92
- }
93
- function getCallerIdentity(params) {
94
- const { profile, region, verbose } = params;
95
- return runAws({
96
- profile,
97
- region,
98
- args: ["sts", "get-caller-identity"],
99
- verbose
100
- });
101
- }
102
-
103
-
104
-
105
-
106
-
107
-
108
-
109
-
110
- exports.AwsCliError = AwsCliError; exports.parseAwsErrorCode = parseAwsErrorCode; exports.requireCommands = requireCommands; exports.runAws = runAws; exports.runAwsVault = runAwsVault; exports.getCallerIdentity = getCallerIdentity;
@@ -1 +0,0 @@
1
- "use strict";
@@ -1,23 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
-
3
-
4
- var _WOYF2L6Tcjs = require('./WOYF2L6T.cjs');
5
-
6
- // src/commands/aws/iam/remove-admin/schema.js
7
- var _zod = require('zod');
8
- var removeAdminOptionsSchema = _zod.z.object({
9
- profile: _WOYF2L6Tcjs.profileField,
10
- all: _zod.z.boolean().optional().default(false).describe(
11
- "Scan every aws-vault profile (default only when --profile and AWS_PROFILE are unset)"
12
- ),
13
- user: _zod.z.array(_zod.z.string()).optional().default([]).describe(
14
- "Only remove these user(s); repeatable. Default: every user in the group"
15
- ),
16
- yes: _zod.z.boolean().optional().default(false).describe("Skip the per-profile confirmation prompt"),
17
- dryRun: _zod.z.boolean().optional().default(false).describe("Preview removals without changing anything"),
18
- verbose: _WOYF2L6Tcjs.verboseField
19
- });
20
-
21
-
22
-
23
- exports.removeAdminOptionsSchema = removeAdminOptionsSchema;
@@ -1,249 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
2
-
3
- var _R3GUC7O7cjs = require('./R3GUC7O7.cjs');
4
-
5
-
6
- var _3NOHGUCFcjs = require('./3NOHGUCF.cjs');
7
-
8
- // src/commands/aws/iam/setup-acl/utils.js
9
- var ACL_GROUPS = [
10
- "acl-admin-do-not-use",
11
- "acl-iam-full-access",
12
- "acl-power-users",
13
- "acl-read-only",
14
- "acl-s3-restrictions"
15
- ];
16
- var CUSTOM_POLICIES = [
17
- { name: "UserAdminsWriteList", fileName: "user-admins-write-list.json" },
18
- { name: "UserAdminsDenyList", fileName: "user-admins-deny-list.json" },
19
- {
20
- name: "UserAdminsSelfServiceIAM",
21
- fileName: "user-admins-self-service-iam.json"
22
- },
23
- {
24
- name: "UserAdminsDenyRegionsList",
25
- fileName: "user-admins-deny-regions-list.json"
26
- },
27
- { name: "sts-federation", fileName: "sts-federation.json" },
28
- {
29
- name: "S3RestrictionsDenyNonS3Services",
30
- fileName: "s3-restrictions-deny-non-s3-services.json"
31
- }
32
- ];
33
- function ensureGroup(params) {
34
- const { name, profile, verbose } = params;
35
- let exists = true;
36
- try {
37
- _R3GUC7O7cjs.runAws.call(void 0, {
38
- profile,
39
- args: ["iam", "get-group", "--group-name", name],
40
- verbose
41
- });
42
- } catch (e) {
43
- exists = false;
44
- }
45
- if (exists) {
46
- console.log(` Group exists: ${name}`);
47
- return;
48
- }
49
- console.log(` Create group: ${name}`);
50
- _R3GUC7O7cjs.runAws.call(void 0, {
51
- profile,
52
- args: ["iam", "create-group", "--group-name", name, "--path", "/"],
53
- expectJson: false,
54
- verbose
55
- });
56
- }
57
- function publishPolicy(params) {
58
- const { name, fileName, accountId, profile, verbose } = params;
59
- const arn = `arn:aws:iam::${accountId}:policy/${name}`;
60
- const file = _3NOHGUCFcjs.resolvePolicyPath.call(void 0, fileName);
61
- let exists = true;
62
- try {
63
- _R3GUC7O7cjs.runAws.call(void 0, {
64
- profile,
65
- args: ["iam", "get-policy", "--policy-arn", arn],
66
- verbose
67
- });
68
- } catch (e2) {
69
- exists = false;
70
- }
71
- if (!exists) {
72
- console.log(` Create policy: ${name}`);
73
- _R3GUC7O7cjs.runAws.call(void 0, {
74
- profile,
75
- args: [
76
- "iam",
77
- "create-policy",
78
- "--policy-name",
79
- name,
80
- "--policy-document",
81
- `file://${file}`,
82
- "--description",
83
- `ACL: ${name}`
84
- ],
85
- expectJson: false,
86
- verbose
87
- });
88
- return;
89
- }
90
- const nonDefaultCount = Number.parseInt(
91
- _R3GUC7O7cjs.runAws.call(void 0, {
92
- profile,
93
- args: [
94
- "iam",
95
- "list-policy-versions",
96
- "--policy-arn",
97
- arn,
98
- "--query",
99
- "length(Versions[?IsDefaultVersion==`false`])",
100
- "--output",
101
- "text"
102
- ],
103
- expectJson: false,
104
- verbose
105
- }),
106
- 10
107
- ) || 0;
108
- if (nonDefaultCount >= 4) {
109
- const oldest = _R3GUC7O7cjs.runAws.call(void 0, {
110
- profile,
111
- args: [
112
- "iam",
113
- "list-policy-versions",
114
- "--policy-arn",
115
- arn,
116
- "--query",
117
- "Versions[?IsDefaultVersion==`false`] | sort_by(@, &CreateDate)[0].VersionId",
118
- "--output",
119
- "text"
120
- ],
121
- expectJson: false,
122
- verbose
123
- });
124
- console.log(` Prune oldest version of ${name}: ${oldest}`);
125
- _R3GUC7O7cjs.runAws.call(void 0, {
126
- profile,
127
- args: [
128
- "iam",
129
- "delete-policy-version",
130
- "--policy-arn",
131
- arn,
132
- "--version-id",
133
- oldest
134
- ],
135
- expectJson: false,
136
- verbose
137
- });
138
- }
139
- console.log(` Update policy: ${name}`);
140
- _R3GUC7O7cjs.runAws.call(void 0, {
141
- profile,
142
- args: [
143
- "iam",
144
- "create-policy-version",
145
- "--policy-arn",
146
- arn,
147
- "--policy-document",
148
- `file://${file}`,
149
- "--set-as-default"
150
- ],
151
- expectJson: false,
152
- verbose
153
- });
154
- }
155
- function isPolicyAttached(params) {
156
- const { group, arn, profile, verbose } = params;
157
- const out = _R3GUC7O7cjs.runAws.call(void 0, {
158
- profile,
159
- args: [
160
- "iam",
161
- "list-attached-group-policies",
162
- "--group-name",
163
- group,
164
- "--query",
165
- `AttachedPolicies[?PolicyArn=='${arn}'].PolicyArn`,
166
- "--output",
167
- "text"
168
- ],
169
- expectJson: false,
170
- verbose
171
- });
172
- return Boolean(out);
173
- }
174
- function attach(params) {
175
- const { group, arn, profile, verbose } = params;
176
- const policyName = _nullishCoalesce(arn.split("/").pop(), () => ( arn));
177
- if (isPolicyAttached({ group, arn, profile, verbose })) {
178
- console.log(` [${group}] already attached: ${policyName}`);
179
- return;
180
- }
181
- console.log(` [${group}] attach: ${policyName}`);
182
- _R3GUC7O7cjs.runAws.call(void 0, {
183
- profile,
184
- args: [
185
- "iam",
186
- "attach-group-policy",
187
- "--group-name",
188
- group,
189
- "--policy-arn",
190
- arn
191
- ],
192
- expectJson: false,
193
- verbose
194
- });
195
- }
196
- function detach(params) {
197
- const { group, arn, profile, verbose } = params;
198
- const policyName = _nullishCoalesce(arn.split("/").pop(), () => ( arn));
199
- if (!isPolicyAttached({ group, arn, profile, verbose })) {
200
- return;
201
- }
202
- console.log(` [${group}] detach legacy: ${policyName}`);
203
- _R3GUC7O7cjs.runAws.call(void 0, {
204
- profile,
205
- args: [
206
- "iam",
207
- "detach-group-policy",
208
- "--group-name",
209
- group,
210
- "--policy-arn",
211
- arn
212
- ],
213
- expectJson: false,
214
- verbose
215
- });
216
- }
217
- function printFinalState(params) {
218
- const { profile, verbose } = params;
219
- for (const group of ACL_GROUPS) {
220
- console.log("");
221
- console.log(`=== ${group} ===`);
222
- const table = _R3GUC7O7cjs.runAws.call(void 0, {
223
- profile,
224
- args: [
225
- "iam",
226
- "list-attached-group-policies",
227
- "--group-name",
228
- group,
229
- "--query",
230
- "AttachedPolicies[].PolicyName",
231
- "--output",
232
- "table"
233
- ],
234
- expectJson: false,
235
- verbose
236
- });
237
- console.log(table);
238
- }
239
- }
240
-
241
-
242
-
243
-
244
-
245
-
246
-
247
-
248
-
249
- exports.ACL_GROUPS = ACL_GROUPS; exports.CUSTOM_POLICIES = CUSTOM_POLICIES; exports.ensureGroup = ensureGroup; exports.publishPolicy = publishPolicy; exports.attach = attach; exports.detach = detach; exports.printFinalState = printFinalState;
@@ -1,81 +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(); } }
2
-
3
-
4
- var _R3GUC7O7cjs = require('./R3GUC7O7.cjs');
5
-
6
- // src/commands/aws/iam/admin-group.js
7
- var _child_process = require('child_process');
8
- var _chalk = require('chalk'); var _chalk2 = _interopRequireDefault(_chalk);
9
- var ADMIN_GROUP_NAME = "acl-admin-do-not-use";
10
- var VAULT_DURATION = _nullishCoalesce(process.env.AWS_VAULT_DURATION, () => ( "15m"));
11
- function listVaultProfiles() {
12
- const result = _child_process.spawnSync.call(void 0, "aws-vault", ["list", "--credentials"], {
13
- encoding: "utf-8"
14
- });
15
- if (result.status !== 0) {
16
- return [];
17
- }
18
- return (_nullishCoalesce(result.stdout, () => ( ""))).split("\n").map((line) => line.trim()).filter((line) => line.length > 0);
19
- }
20
- function resolveAdminScanProfiles({ profile, all = false }) {
21
- const targetProfile = _nullishCoalesce(profile, () => ( process.env.AWS_PROFILE));
22
- if (!all && targetProfile) {
23
- return [targetProfile];
24
- }
25
- const profiles = listVaultProfiles();
26
- if (profiles.length === 0) {
27
- throw new Error("No aws-vault profiles with credentials found.");
28
- }
29
- return profiles;
30
- }
31
- function groupUserNames(group) {
32
- return (_nullishCoalesce(group.Users, () => ( []))).map((user) => user.UserName);
33
- }
34
- function resolveProfileScan(params) {
35
- const { profile, verbose = false } = params;
36
- const idArgs = ["sts", "get-caller-identity"];
37
- const groupArgs = ["iam", "get-group", "--group-name", ADMIN_GROUP_NAME];
38
- const directRun = (args, options = {}) => _R3GUC7O7cjs.runAws.call(void 0, { profile, args, expectJson: _nullishCoalesce(options.expectJson, () => ( true)), verbose });
39
- const vaultRun = (args, options = {}) => _R3GUC7O7cjs.runAwsVault.call(void 0, {
40
- profile,
41
- args,
42
- duration: VAULT_DURATION,
43
- expectJson: _nullishCoalesce(options.expectJson, () => ( true)),
44
- verbose
45
- });
46
- try {
47
- const identity = directRun(idArgs);
48
- const group = directRun(groupArgs);
49
- return {
50
- accountId: identity.Account,
51
- arn: identity.Arn,
52
- users: groupUserNames(group),
53
- run: directRun
54
- };
55
- } catch (directError) {
56
- try {
57
- const identity = vaultRun(idArgs);
58
- const group = vaultRun(groupArgs);
59
- return {
60
- accountId: identity.Account,
61
- arn: identity.Arn,
62
- users: groupUserNames(group),
63
- run: vaultRun
64
- };
65
- } catch (e) {
66
- if (verbose) {
67
- const reason = directError instanceof Error ? _nullishCoalesce(directError.message.split("\n")[0], () => ( "")) : String(directError);
68
- console.log(_chalk2.default.dim(`skip ${profile} \u2014 ${reason}`));
69
- }
70
- return null;
71
- }
72
- }
73
- }
74
-
75
-
76
-
77
-
78
-
79
-
80
-
81
- exports.ADMIN_GROUP_NAME = ADMIN_GROUP_NAME; exports.listVaultProfiles = listVaultProfiles; exports.resolveAdminScanProfiles = resolveAdminScanProfiles; exports.groupUserNames = groupUserNames; exports.resolveProfileScan = resolveProfileScan;
@@ -1,97 +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
-
5
- var _YRHFKTW2cjs = require('./YRHFKTW2.cjs');
6
-
7
-
8
- var _NT2XXAI6cjs = require('./NT2XXAI6.cjs');
9
-
10
-
11
- var _N7D56LPPcjs = require('./N7D56LPP.cjs');
12
-
13
- // src/commands/aws/ses/send-email/handler.js
14
- var _chalk = require('chalk'); var _chalk2 = _interopRequireDefault(_chalk);
15
- var _zod = require('zod');
16
- async function sendEmailCommand(options) {
17
- try {
18
- const parsed = _N7D56LPPcjs.sendEmailOptionsSchema.parse(options);
19
- const {
20
- to,
21
- from,
22
- subject,
23
- transport,
24
- region,
25
- profile: profileOption,
26
- accessKeyId,
27
- dryRun,
28
- verbose
29
- } = parsed;
30
- const body = _nullishCoalesce(parsed.body, () => ( _YRHFKTW2cjs.defaultBody.call(void 0, )));
31
- const profile = transport === "api" ? await _NT2XXAI6cjs.resolveProfile.call(void 0, { profile: profileOption }) : profileOption;
32
- console.log(_chalk2.default.blue("\n\u{1F4E7} SES send-email"));
33
- console.log(_chalk2.default.gray(` transport: ${transport}`));
34
- console.log(_chalk2.default.gray(` region: ${region}`));
35
- console.log(_chalk2.default.gray(` from: ${from}`));
36
- console.log(_chalk2.default.gray(` to: ${to}`));
37
- console.log(_chalk2.default.gray(` subject: ${subject}`));
38
- if (verbose) {
39
- console.log(_chalk2.default.gray(` body: ${body}`));
40
- }
41
- if (dryRun) {
42
- console.log(_chalk2.default.yellow("\n[dry-run] No email sent."));
43
- return;
44
- }
45
- const messageId = transport === "api" ? await _YRHFKTW2cjs.sendViaApi.call(void 0, { to, from, subject, body, region, profile }) : await _YRHFKTW2cjs.sendViaSmtp.call(void 0, { to, from, subject, body, region, accessKeyId });
46
- console.log(
47
- _chalk2.default.green(
48
- `
49
- \u2705 Email sent${messageId ? ` (messageId: ${messageId})` : ""}.`
50
- )
51
- );
52
- } catch (error) {
53
- if (error instanceof _zod.ZodError) {
54
- console.error(_chalk2.default.red("\n\u274C Invalid command options:"));
55
- error.errors.forEach((err) => {
56
- console.error(_chalk2.default.red(` ${err.path.join(".")}: ${err.message}`));
57
- });
58
- process.exit(1);
59
- }
60
- const verbose = (
61
- /** @type {any} */
62
- _optionalChain([options, 'optionalAccess', _ => _.verbose]) || false
63
- );
64
- console.error(_chalk2.default.red("\n\u274C send-email failed:"));
65
- if (error instanceof Error) {
66
- console.error(_chalk2.default.red(` ${error.message}`));
67
- if (verbose && error.stack) {
68
- console.error(_chalk2.default.gray("\nStack trace:"));
69
- console.error(_chalk2.default.gray(error.stack));
70
- }
71
- } else {
72
- console.error(_chalk2.default.red(` ${String(error)}`));
73
- }
74
- console.error(_chalk2.default.yellow("\n\u{1F4A1} Troubleshooting tips:"));
75
- console.error(
76
- _chalk2.default.yellow(" \u2022 The sender address must be verified in SES")
77
- );
78
- console.error(
79
- _chalk2.default.yellow(
80
- " \u2022 New SES accounts are sandboxed \u2014 recipients must also be verified"
81
- )
82
- );
83
- console.error(
84
- _chalk2.default.yellow(
85
- " \u2022 For smtp transport, set SES_SMTP_USER and SES_SMTP_PASSWORD"
86
- )
87
- );
88
- console.error(
89
- _chalk2.default.yellow(" \u2022 Use --verbose for detailed error information\n")
90
- );
91
- process.exit(1);
92
- }
93
- }
94
-
95
-
96
-
97
- exports.sendEmailCommand = sendEmailCommand;
@@ -1 +0,0 @@
1
- "use strict";