@joystick.js/node-canary 0.0.0-canary.355 → 0.0.0-canary.356

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 (455) hide show
  1. package/.build/getFilesToBuild.js +26 -0
  2. package/.build/getPlatformSafeFilePath.js +6 -0
  3. package/.build/getPlatformSafePath.js +6 -0
  4. package/.build/index.js +88 -0
  5. package/.build/isWindows.js +3 -0
  6. package/dist/action/class.js +1 -103
  7. package/dist/action/index.js +1 -8
  8. package/dist/app/accounts/default_user_output_fields.js +1 -0
  9. package/dist/app/accounts/delete_user.js +1 -0
  10. package/dist/app/accounts/generate_account_session.js +1 -0
  11. package/dist/app/accounts/generate_password_reset_token.js +1 -0
  12. package/dist/app/accounts/get_browser_safe_user.js +1 -0
  13. package/dist/app/accounts/has_login_token_expired.js +1 -0
  14. package/dist/app/accounts/index.js +1 -31
  15. package/dist/app/accounts/login.js +1 -65
  16. package/dist/app/accounts/recover_password.js +1 -0
  17. package/dist/app/accounts/reset_password.js +1 -0
  18. package/dist/app/accounts/roles/add.js +1 -7
  19. package/dist/app/accounts/roles/grant.js +1 -7
  20. package/dist/app/accounts/roles/index.js +1 -17
  21. package/dist/app/accounts/roles/list.js +1 -7
  22. package/dist/app/accounts/roles/remove.js +1 -7
  23. package/dist/app/accounts/roles/revoke.js +1 -7
  24. package/dist/app/accounts/roles/user_has_role.js +1 -0
  25. package/dist/app/accounts/send_email_verification.js +1 -0
  26. package/dist/app/accounts/set_account_cookie.js +1 -0
  27. package/dist/app/accounts/set_password.js +1 -0
  28. package/dist/app/accounts/signup.js +1 -140
  29. package/dist/app/accounts/unset_account_cookie.js +1 -0
  30. package/dist/app/accounts/verify_email.js +1 -0
  31. package/dist/app/api/accounts/authenticated.js +1 -0
  32. package/dist/app/api/accounts/login.js +1 -0
  33. package/dist/app/api/accounts/logout.js +1 -0
  34. package/dist/app/api/accounts/recover_password.js +1 -0
  35. package/dist/app/api/accounts/reset_password.js +1 -0
  36. package/dist/app/api/accounts/signup.js +1 -0
  37. package/dist/app/api/accounts/user.js +1 -0
  38. package/dist/app/api/accounts/verify_email.js +1 -0
  39. package/dist/app/api/format_api_error.js +1 -0
  40. package/dist/app/api/get.js +2 -0
  41. package/dist/app/api/get_api_context.js +1 -0
  42. package/dist/app/api/get_api_for_data_functions.js +1 -0
  43. package/dist/app/api/get_api_url_component.js +1 -0
  44. package/dist/app/api/get_output.js +1 -0
  45. package/dist/app/api/get_value_from_object.js +1 -0
  46. package/dist/app/api/handle_api_error.js +1 -0
  47. package/dist/app/api/input_validators.js +1 -0
  48. package/dist/app/api/is_array_path.js +1 -0
  49. package/dist/app/api/push/health.js +2 -0
  50. package/dist/app/api/register_getters.js +1 -0
  51. package/dist/app/api/register_setters.js +1 -0
  52. package/dist/app/api/sanitize_api_response.js +1 -0
  53. package/dist/app/api/set.js +2 -0
  54. package/dist/app/api/test/accounts/delete.js +1 -0
  55. package/dist/app/api/test/accounts/signup.js +1 -0
  56. package/dist/app/api/test/bootstrap.js +1 -0
  57. package/dist/app/api/test/process.js +1 -0
  58. package/dist/app/api/test/queues.js +1 -0
  59. package/dist/app/api/validate_input.js +1 -0
  60. package/dist/app/api/validate_session.js +1 -0
  61. package/dist/app/api/validate_type.js +1 -0
  62. package/dist/app/browser/hmr_client.js +1 -0
  63. package/dist/app/browser/process_polyfill.js +1 -0
  64. package/dist/app/cron_jobs/register.js +1 -0
  65. package/dist/app/databases/database_type_map.js +1 -0
  66. package/dist/app/databases/get_target_database_connection.js +1 -0
  67. package/dist/app/databases/mongodb/available_query_parameters.js +1 -0
  68. package/dist/app/databases/mongodb/build_connection_string.js +1 -0
  69. package/dist/app/databases/mongodb/build_query_parameters.js +1 -0
  70. package/dist/app/databases/mongodb/connect.js +6 -0
  71. package/dist/app/databases/mongodb/create_indexes.js +1 -0
  72. package/dist/app/databases/postgresql/accounts/create_accounts_metadata_table_columns.js +1 -0
  73. package/dist/app/databases/postgresql/connect.js +30 -0
  74. package/dist/app/databases/postgresql/create_indexes.js +1 -0
  75. package/dist/app/databases/postgresql/create_tables.js +1 -0
  76. package/dist/app/databases/postgresql/handle_cleanup_queues.js +5 -0
  77. package/dist/app/databases/queries/accounts.js +1 -0
  78. package/dist/app/databases/queries/map.js +1 -0
  79. package/dist/app/databases/queries/mongodb/accounts.js +1 -0
  80. package/dist/app/databases/queries/mongodb/queues.js +1 -0
  81. package/dist/app/databases/queries/mongodb/sessions.js +1 -0
  82. package/dist/app/databases/queries/postgresql/accounts.js +1 -0
  83. package/dist/app/databases/queries/postgresql/queues.js +123 -0
  84. package/dist/app/databases/queries/postgresql/sessions.js +14 -0
  85. package/dist/app/databases/queries/sessions.js +1 -0
  86. package/dist/app/databases/register_database.js +1 -0
  87. package/dist/app/databases/sql.js +1 -0
  88. package/dist/app/email/send.js +1 -0
  89. package/dist/app/email/validate_smtp_settings.js +1 -0
  90. package/dist/app/fixture/index.js +1 -0
  91. package/dist/app/generate_machine_id.js +1 -0
  92. package/dist/app/generate_process_id.js +1 -0
  93. package/dist/app/get_ssl_certificates.js +1 -0
  94. package/dist/app/handle_process_errors.js +1 -0
  95. package/dist/app/index.js +1 -805
  96. package/dist/app/middleware/account.js +1 -0
  97. package/dist/app/middleware/body_parser.js +1 -0
  98. package/dist/app/middleware/build_error.js +1 -0
  99. package/dist/app/middleware/built_in.js +1 -0
  100. package/dist/app/middleware/context.js +1 -0
  101. package/dist/app/middleware/cors.js +1 -22
  102. package/dist/app/middleware/csp.js +1 -48
  103. package/dist/app/middleware/generate_insecure_page.js +65 -0
  104. package/dist/app/middleware/generate_joystick_error_page.js +143 -0
  105. package/dist/app/middleware/hmr_client.js +1 -0
  106. package/dist/app/middleware/insecure.js +1 -10
  107. package/dist/app/middleware/process_browser_polyfill.js +1 -0
  108. package/dist/app/middleware/render/get_url.js +1 -0
  109. package/dist/app/middleware/render/index.js +1 -0
  110. package/dist/app/middleware/request_methods.js +1 -0
  111. package/dist/app/middleware/session.js +1 -24
  112. package/dist/app/queues/index.js +1 -164
  113. package/dist/app/register_app_options.js +1 -0
  114. package/dist/app/routes/register_route_from_function.js +1 -0
  115. package/dist/app/routes/register_route_from_object.js +1 -0
  116. package/dist/app/routes/supported_http_methods.js +1 -0
  117. package/dist/app/settings/load.js +1 -0
  118. package/dist/app/ssr/index.js +32 -0
  119. package/dist/app/ssr/set_base_attributes_in_html.js +1 -0
  120. package/dist/app/ssr/set_head_tags_in_html.js +1 -0
  121. package/dist/app/start_express.js +1 -0
  122. package/dist/app/start_node_as_cluster.js +1 -0
  123. package/dist/app/uploaders/local_upload_progress_middleware.js +1 -0
  124. package/dist/app/uploaders/register.js +1 -0
  125. package/dist/app/uploaders/run_upload.js +1 -0
  126. package/dist/app/uploaders/validate_options.js +1 -0
  127. package/dist/app/uploaders/validate_uploads.js +1 -0
  128. package/dist/app/websockets/emit_event.js +1 -0
  129. package/dist/app/websockets/index.js +1 -0
  130. package/dist/app/websockets/register.js +1 -0
  131. package/dist/index.js +4 -95
  132. package/dist/lib/camel_pascal_to_snake.js +1 -0
  133. package/dist/lib/constants.js +1 -17
  134. package/dist/lib/dynamic_import.js +1 -0
  135. package/dist/lib/escape_html.js +1 -0
  136. package/dist/lib/escape_key_value_pair.js +1 -0
  137. package/dist/lib/float_to_decimal_place.js +1 -0
  138. package/dist/lib/generate_id.js +1 -0
  139. package/dist/lib/get_browser_safe_request.js +1 -0
  140. package/dist/lib/get_joystick_build_path.js +1 -0
  141. package/dist/lib/get_origin.js +1 -0
  142. package/dist/lib/get_sanitized_context.js +1 -0
  143. package/dist/lib/get_translations.js +1 -0
  144. package/dist/lib/hash_string.js +1 -0
  145. package/dist/lib/is_valid_json.js +1 -0
  146. package/dist/lib/log.js +13 -49
  147. package/dist/lib/node_path_polyfills.js +1 -0
  148. package/dist/lib/parse_json.js +1 -0
  149. package/dist/lib/path_exists.js +1 -12
  150. package/dist/lib/rainbow_road.js +1 -0
  151. package/dist/lib/replace_backslashes_with_forward_slashes.js +1 -0
  152. package/dist/lib/replace_file_protocol.js +1 -0
  153. package/dist/lib/serialize_query_parameters.js +1 -0
  154. package/dist/lib/set_cookie.js +1 -0
  155. package/dist/lib/string_to_slug.js +1 -0
  156. package/dist/lib/timestamps.js +1 -47
  157. package/dist/lib/types.js +1 -0
  158. package/dist/lib/unset_cookie.js +1 -0
  159. package/dist/lib/wait.js +1 -8
  160. package/dist/test/track_function_call.js +1 -0
  161. package/increment_version.js +14 -0
  162. package/package.json +25 -43
  163. package/src/action/class.js +137 -0
  164. package/src/action/index.js +8 -0
  165. package/src/app/accounts/default_user_output_fields.js +10 -0
  166. package/src/app/accounts/delete_user.js +18 -0
  167. package/src/app/accounts/generate_account_session.js +11 -0
  168. package/src/app/accounts/generate_password_reset_token.js +16 -0
  169. package/src/app/accounts/get_browser_safe_user.js +29 -0
  170. package/src/app/accounts/has_login_token_expired.js +9 -0
  171. package/src/app/accounts/index.js +38 -0
  172. package/src/app/accounts/login.js +82 -0
  173. package/src/app/accounts/recover_password.js +58 -0
  174. package/src/app/accounts/reset_password.js +69 -0
  175. package/src/app/accounts/roles/add.js +7 -0
  176. package/src/app/accounts/roles/grant.js +7 -0
  177. package/src/app/accounts/roles/index.js +17 -0
  178. package/src/app/accounts/roles/list.js +7 -0
  179. package/src/app/accounts/roles/remove.js +7 -0
  180. package/src/app/accounts/roles/revoke.js +7 -0
  181. package/src/app/accounts/roles/user_has_role.js +7 -0
  182. package/src/app/accounts/send_email_verification.js +48 -0
  183. package/src/app/accounts/set_account_cookie.js +12 -0
  184. package/src/app/accounts/set_password.js +46 -0
  185. package/src/app/accounts/signup.js +158 -0
  186. package/src/app/accounts/unset_account_cookie.js +12 -0
  187. package/src/app/accounts/verify_email.js +32 -0
  188. package/src/app/api/accounts/authenticated.js +17 -0
  189. package/src/app/api/accounts/login.js +36 -0
  190. package/src/app/api/accounts/logout.js +20 -0
  191. package/src/app/api/accounts/recover_password.js +16 -0
  192. package/src/app/api/accounts/reset_password.js +24 -0
  193. package/src/app/api/accounts/signup.js +49 -0
  194. package/src/app/api/accounts/user.js +21 -0
  195. package/src/app/api/accounts/verify_email.js +11 -0
  196. package/src/app/api/format_api_error.js +10 -0
  197. package/src/app/api/get.js +119 -0
  198. package/src/app/api/get_api_context.js +27 -0
  199. package/src/app/api/get_api_for_data_functions.js +37 -0
  200. package/src/app/api/get_api_url_component.js +5 -0
  201. package/src/app/api/get_output.js +116 -0
  202. package/src/app/api/get_value_from_object.js +8 -0
  203. package/src/app/api/handle_api_error.js +31 -0
  204. package/src/app/api/input_validators.js +227 -0
  205. package/src/app/api/is_array_path.js +6 -0
  206. package/src/app/api/push/health.js +17 -0
  207. package/src/app/api/register_getters.js +53 -0
  208. package/src/app/api/register_setters.js +52 -0
  209. package/src/app/api/sanitize_api_response.js +35 -0
  210. package/src/app/api/set.js +119 -0
  211. package/src/app/api/test/accounts/delete.js +8 -0
  212. package/src/app/api/test/accounts/signup.js +47 -0
  213. package/src/app/api/test/bootstrap.js +36 -0
  214. package/src/app/api/test/process.js +7 -0
  215. package/src/app/api/test/queues.js +25 -0
  216. package/src/app/api/validate_input.js +132 -0
  217. package/src/app/api/validate_session.js +20 -0
  218. package/src/app/api/validate_type.js +24 -0
  219. package/src/app/browser/hmr_client.js +190 -0
  220. package/src/app/browser/process_polyfill.js +11 -0
  221. package/src/app/cron_jobs/register.js +29 -0
  222. package/src/app/databases/database_type_map.js +6 -0
  223. package/src/app/databases/get_target_database_connection.js +25 -0
  224. package/{dist/app/databases/mongodb/availableQueryParameters.js → src/app/databases/mongodb/available_query_parameters.js} +3 -4
  225. package/src/app/databases/mongodb/build_connection_string.js +30 -0
  226. package/src/app/databases/mongodb/build_query_parameters.js +17 -0
  227. package/src/app/databases/mongodb/connect.js +42 -0
  228. package/src/app/databases/mongodb/create_indexes.js +35 -0
  229. package/src/app/databases/postgresql/accounts/create_accounts_metadata_table_columns.js +18 -0
  230. package/{dist/app/databases/postgresql/index.js → src/app/databases/postgresql/connect.js} +53 -66
  231. package/src/app/databases/postgresql/create_indexes.js +51 -0
  232. package/src/app/databases/postgresql/create_tables.js +70 -0
  233. package/src/app/databases/postgresql/handle_cleanup_queues.js +36 -0
  234. package/src/app/databases/queries/accounts.js +17 -0
  235. package/src/app/databases/queries/map.js +21 -0
  236. package/src/app/databases/queries/mongodb/accounts.js +360 -0
  237. package/src/app/databases/queries/mongodb/queues.js +157 -0
  238. package/src/app/databases/queries/mongodb/sessions.js +22 -0
  239. package/src/app/databases/queries/postgresql/accounts.js +379 -0
  240. package/{dist/app/databases/postgresql/queries → src/app/databases/queries/postgresql}/queues.js +92 -63
  241. package/src/app/databases/queries/postgresql/sessions.js +37 -0
  242. package/src/app/databases/queries/sessions.js +17 -0
  243. package/src/app/databases/register_database.js +30 -0
  244. package/{dist/app/databases/generate_sql_from_object.js → src/app/databases/sql.js} +25 -22
  245. package/src/app/email/send.js +104 -0
  246. package/src/app/email/validate_smtp_settings.js +53 -0
  247. package/src/app/fixture/index.js +50 -0
  248. package/src/app/generate_machine_id.js +26 -0
  249. package/src/app/generate_process_id.js +30 -0
  250. package/src/app/get_ssl_certificates.js +23 -0
  251. package/src/app/handle_process_errors.js +101 -0
  252. package/src/app/index.js +248 -0
  253. package/src/app/middleware/account.js +28 -0
  254. package/src/app/middleware/body_parser.js +18 -0
  255. package/src/app/middleware/build_error.js +18 -0
  256. package/src/app/middleware/built_in.js +76 -0
  257. package/src/app/middleware/context.js +28 -0
  258. package/src/app/middleware/cors.js +23 -0
  259. package/src/app/middleware/csp.js +54 -0
  260. package/{dist/app/middleware/get_insecure_landing_page_html.js → src/app/middleware/generate_insecure_page.js} +7 -7
  261. package/{dist/lib/generateErrorPage.js → src/app/middleware/generate_joystick_error_page.js} +21 -21
  262. package/src/app/middleware/hmr_client.js +12 -0
  263. package/src/app/middleware/insecure.js +22 -0
  264. package/src/app/middleware/process_browser_polyfill.js +12 -0
  265. package/src/app/middleware/render/get_url.js +15 -0
  266. package/src/app/middleware/render/index.js +93 -0
  267. package/src/app/middleware/request_methods.js +21 -0
  268. package/src/app/middleware/session.js +31 -0
  269. package/src/app/queues/index.js +268 -0
  270. package/src/app/register_app_options.js +7 -0
  271. package/src/app/routes/register_route_from_function.js +10 -0
  272. package/src/app/routes/register_route_from_object.js +34 -0
  273. package/src/app/routes/supported_http_methods.js +9 -0
  274. package/src/app/settings/load.js +33 -0
  275. package/src/app/ssr/index.js +123 -0
  276. package/src/app/ssr/set_base_attributes_in_html.js +43 -0
  277. package/src/app/ssr/set_head_tags_in_html.js +104 -0
  278. package/src/app/start_express.js +50 -0
  279. package/{dist/app/cluster.js → src/app/start_node_as_cluster.js} +9 -5
  280. package/src/app/uploaders/local_upload_progress_middleware.js +24 -0
  281. package/src/app/uploaders/register.js +169 -0
  282. package/src/app/uploaders/run_upload.js +136 -0
  283. package/src/app/uploaders/validate_options.js +74 -0
  284. package/src/app/uploaders/validate_uploads.js +127 -0
  285. package/src/app/websockets/emit_event.js +14 -0
  286. package/src/app/websockets/index.js +16 -0
  287. package/src/app/websockets/register.js +175 -0
  288. package/src/index.js +77 -0
  289. package/{dist/lib/camelPascalToSnake.js → src/lib/camel_pascal_to_snake.js} +3 -4
  290. package/src/lib/constants.js +21 -0
  291. package/src/lib/dynamic_import.js +6 -0
  292. package/src/lib/escape_html.js +9 -0
  293. package/src/lib/escape_key_value_pair.js +15 -0
  294. package/src/lib/float_to_decimal_place.js +5 -0
  295. package/src/lib/generate_id.js +15 -0
  296. package/src/lib/get_browser_safe_request.js +17 -0
  297. package/src/lib/get_joystick_build_path.js +28 -0
  298. package/src/lib/get_origin.js +7 -0
  299. package/src/lib/get_sanitized_context.js +51 -0
  300. package/src/lib/get_translations.js +96 -0
  301. package/src/lib/hash_string.js +7 -0
  302. package/src/lib/is_valid_json.js +10 -0
  303. package/src/lib/log.js +42 -0
  304. package/src/lib/node_path_polyfills.js +18 -0
  305. package/src/lib/parse_json.js +9 -0
  306. package/src/lib/path_exists.js +11 -0
  307. package/src/lib/rainbow_road.js +7 -0
  308. package/src/lib/replace_backslashes_with_forward_slashes.js +8 -0
  309. package/src/lib/replace_file_protocol.js +8 -0
  310. package/src/lib/serialize_query_parameters.js +7 -0
  311. package/src/lib/set_cookie.js +16 -0
  312. package/src/lib/string_to_slug.js +14 -0
  313. package/src/lib/timestamps.js +48 -0
  314. package/src/lib/types.js +59 -0
  315. package/src/lib/unset_cookie.js +11 -0
  316. package/src/lib/wait.js +9 -0
  317. package/src/test/track_function_call.js +16 -0
  318. package/README.md +0 -8
  319. package/_package.json +0 -62
  320. package/canary.js +0 -12
  321. package/dist/api/get.js +0 -31
  322. package/dist/api/getOrigin.js +0 -6
  323. package/dist/api/index.js +0 -9
  324. package/dist/api/set.js +0 -31
  325. package/dist/app/accounts/createMetadataTableColumns.js +0 -12
  326. package/dist/app/accounts/defaultUserOutputFields.js +0 -9
  327. package/dist/app/accounts/deleteUser.js +0 -7
  328. package/dist/app/accounts/generateResetToken.js +0 -28
  329. package/dist/app/accounts/generateSession.js +0 -13
  330. package/dist/app/accounts/getBrowserSafeUser.js +0 -26
  331. package/dist/app/accounts/hasLoginTokenExpired.js +0 -17
  332. package/dist/app/accounts/hashString.js +0 -7
  333. package/dist/app/accounts/recoverPassword.js +0 -33
  334. package/dist/app/accounts/resetPassword.js +0 -79
  335. package/dist/app/accounts/roles/userHasRole.js +0 -7
  336. package/dist/app/accounts/runUserQuery.js +0 -15
  337. package/dist/app/accounts/sendEmailVerification.js +0 -65
  338. package/dist/app/accounts/setAuthenticationCookie.js +0 -11
  339. package/dist/app/accounts/setPassword.js +0 -45
  340. package/dist/app/accounts/unsetAuthenticationCookie.js +0 -11
  341. package/dist/app/accounts/verifyEmail.js +0 -49
  342. package/dist/app/databases/getTargetDatabase.js +0 -10
  343. package/dist/app/databases/getTargetDatabaseConnection.js +0 -19
  344. package/dist/app/databases/getTargetDatabaseProvider.js +0 -10
  345. package/dist/app/databases/mongodb/buildConnectionString.js +0 -22
  346. package/dist/app/databases/mongodb/buildQueryParameters.js +0 -14
  347. package/dist/app/databases/mongodb/createAccountsIndexes.js +0 -18
  348. package/dist/app/databases/mongodb/createSessionsIndexes.js +0 -10
  349. package/dist/app/databases/mongodb/index.js +0 -40
  350. package/dist/app/databases/mongodb/queries/accounts.js +0 -273
  351. package/dist/app/databases/mongodb/queries/queues.js +0 -138
  352. package/dist/app/databases/mongodb/queries/sessions.js +0 -21
  353. package/dist/app/databases/postgresql/addColumnToTable.js +0 -6
  354. package/dist/app/databases/postgresql/createAccountsIndexes.js +0 -21
  355. package/dist/app/databases/postgresql/createAccountsTables.js +0 -39
  356. package/dist/app/databases/postgresql/createDatabase.js +0 -0
  357. package/dist/app/databases/postgresql/createSessionsIndexes.js +0 -10
  358. package/dist/app/databases/postgresql/createSessionsTables.js +0 -14
  359. package/dist/app/databases/postgresql/handleCleanupQueues.js +0 -36
  360. package/dist/app/databases/postgresql/queries/accounts.js +0 -189
  361. package/dist/app/databases/postgresql/queries/sessions.js +0 -34
  362. package/dist/app/databases/queryMap.js +0 -21
  363. package/dist/app/databases/stringToSnakeCase.js +0 -6
  364. package/dist/app/databases/typesMap.js +0 -7
  365. package/dist/app/getAPIContext.js +0 -25
  366. package/dist/app/getAPIURLComponent.js +0 -6
  367. package/dist/app/getBrowserSafeRequest.js +0 -14
  368. package/dist/app/getOutput.js +0 -74
  369. package/dist/app/handleProcessErrors.js +0 -73
  370. package/dist/app/initExpress.js +0 -41
  371. package/dist/app/middleware/bodyParser.js +0 -16
  372. package/dist/app/middleware/getTranslations.js +0 -65
  373. package/dist/app/middleware/hmr/client.js +0 -117
  374. package/dist/app/middleware/index.js +0 -93
  375. package/dist/app/middleware/render.js +0 -155
  376. package/dist/app/middleware/requestMethods.js +0 -19
  377. package/dist/app/registerGetters.js +0 -44
  378. package/dist/app/registerSetters.js +0 -44
  379. package/dist/app/runGetter.js +0 -115
  380. package/dist/app/runSessionQuery.js +0 -15
  381. package/dist/app/runSetter.js +0 -115
  382. package/dist/app/runUploader.js +0 -143
  383. package/dist/app/sanitizeAPIResponse.js +0 -27
  384. package/dist/app/utils/process.js +0 -193
  385. package/dist/app/validateInstanceToken.js +0 -16
  386. package/dist/app/validateSession.js +0 -21
  387. package/dist/app/validateUploaderOptions.js +0 -53
  388. package/dist/app/validateUploads.js +0 -113
  389. package/dist/email/render.js +0 -50
  390. package/dist/email/send.js +0 -61
  391. package/dist/email/templates/base.css +0 -194
  392. package/dist/email/templates/base.html +0 -28
  393. package/dist/email/templates/reset-password.js +0 -13
  394. package/dist/email/validateSMTPSettings.js +0 -27
  395. package/dist/fixture/index.js +0 -40
  396. package/dist/lib/escapeHTML.js +0 -9
  397. package/dist/lib/escapeKeyValuePair.js +0 -13
  398. package/dist/lib/formatAPIError.js +0 -11
  399. package/dist/lib/formatErrorString.js +0 -8
  400. package/dist/lib/generateCookie.js +0 -14
  401. package/dist/lib/generateId.js +0 -13
  402. package/dist/lib/generateMachineId.js +0 -15
  403. package/dist/lib/getBuildPath.js +0 -10
  404. package/dist/lib/getErrorObject.js +0 -9
  405. package/dist/lib/getPlatformSafeFilePath.js +0 -8
  406. package/dist/lib/getPlatformSafePath.js +0 -8
  407. package/dist/lib/getSSLCertificates.js +0 -19
  408. package/dist/lib/importFile.js +0 -7
  409. package/dist/lib/isValidHTTPMethod.js +0 -7
  410. package/dist/lib/isValidJSONString.js +0 -11
  411. package/dist/lib/nodeUrlPolyfills.js +0 -14
  412. package/dist/lib/objectToSQLKeysString.js +0 -18
  413. package/dist/lib/objectToSQLValuesString.js +0 -16
  414. package/dist/lib/obscenedb/debounce.js +0 -12
  415. package/dist/lib/obscenedb/index.js +0 -61
  416. package/dist/lib/parseDatabasesFromEnvironment.js +0 -9
  417. package/dist/lib/rainbowRoad.js +0 -7
  418. package/dist/lib/readDirectory.js +0 -24
  419. package/dist/lib/replaceBackslashesWithForwardSlashes.js +0 -8
  420. package/dist/lib/replaceFileProtocol.js +0 -8
  421. package/dist/lib/replaceForwardSlashesWithBackslashes.js +0 -8
  422. package/dist/lib/serializeQueryParameters.js +0 -8
  423. package/dist/lib/serverAvailable.js +0 -0
  424. package/dist/lib/setCookie.js +0 -16
  425. package/dist/lib/supportedHTTPMethods.js +0 -4
  426. package/dist/lib/unsetCookie.js +0 -13
  427. package/dist/push/connectMongoDB.js +0 -21
  428. package/dist/push/logs/index.js +0 -52
  429. package/dist/settings/index.js +0 -5
  430. package/dist/settings/load.js +0 -28
  431. package/dist/ssr/compileCSS.js +0 -85
  432. package/dist/ssr/findComponentInTree.js +0 -29
  433. package/dist/ssr/formatCSS.js +0 -6
  434. package/dist/ssr/getAPIForDataFunctions.js +0 -35
  435. package/dist/ssr/getCSSFromTree.js +0 -33
  436. package/dist/ssr/getDataFromComponent.js +0 -15
  437. package/dist/ssr/index.js +0 -415
  438. package/dist/ssr/replaceWhenTags.js +0 -36
  439. package/dist/ssr/setHeadTagsInHTML.js +0 -84
  440. package/dist/test/index.js +0 -9
  441. package/dist/test/trackFunctionCall.js +0 -17
  442. package/dist/validation/index.js +0 -10
  443. package/dist/validation/inputWithSchema/index.js +0 -105
  444. package/dist/validation/lib/constants.js +0 -162
  445. package/dist/validation/lib/getValueFromObject.js +0 -12
  446. package/dist/validation/lib/getValueFromObject.test.js +0 -7
  447. package/dist/validation/lib/isArrayPath.js +0 -6
  448. package/dist/validation/lib/throwError.js +0 -6
  449. package/dist/validation/lib/typeValidators.js +0 -38
  450. package/dist/validation/lib/validateType.js +0 -33
  451. package/dist/validation/schema/index.js +0 -44
  452. package/dist/websockets/emitWebsocketEvent.js +0 -12
  453. package/dist/websockets/index.js +0 -16
  454. package/getSanitizedContext.js +0 -43
  455. package/notes +0 -1
@@ -0,0 +1,26 @@
1
+ import fs from "fs";
2
+ import { join } from "path";
3
+
4
+ function rreaddirSync(directory, allFiles = []) {
5
+ const files = fs.readdirSync(directory).map((file) => join(directory, file));
6
+ allFiles.push(...files);
7
+ files.forEach((f) => {
8
+ fs.statSync(f).isDirectory() && rreaddirSync(f, allFiles);
9
+ });
10
+ return allFiles;
11
+ }
12
+
13
+ export default () => {
14
+ const files = rreaddirSync("./src");
15
+
16
+ const filteredFiles = files.filter((path) => {
17
+ return (
18
+ !fs.lstatSync(path).isDirectory() &&
19
+ !["node_modules", ".DS_Store", "src/tests"].some((excludedPath) => {
20
+ return path.includes(excludedPath);
21
+ })
22
+ );
23
+ });
24
+
25
+ return filteredFiles;
26
+ };
@@ -0,0 +1,6 @@
1
+ import isWindows from './isWindows.js';
2
+
3
+ export default (path = '') => {
4
+ // NOTE: This is why serial killers exist.
5
+ return isWindows ? path.replace(/[a-zA-Z]:\\\\/gi, '') : path;
6
+ };
@@ -0,0 +1,6 @@
1
+ import isWindows from './isWindows.js';
2
+
3
+ export default (path = '') => {
4
+ // NOTE: This is why serial killers exist.
5
+ return isWindows ? path.replace('/', '\\') : path;
6
+ };
@@ -0,0 +1,88 @@
1
+ import fs from "fs";
2
+ import child_process from 'child_process';
3
+ import path from "path";
4
+ import esbuild from "esbuild";
5
+ import getFilesToBuild from "./getFilesToBuild.js";
6
+
7
+ const checkIfBrowserFile = (path = "") => {
8
+ const browserPaths = [
9
+ "app/browser/process_polyfill.js",
10
+ "app/browser/hmr_client.js"
11
+ ];
12
+
13
+ return browserPaths.some((browserPath) => {
14
+ return path.includes(browserPath);
15
+ });
16
+ };
17
+
18
+ const buildFile = (fileToBuild) => {
19
+ const [_, file] = fileToBuild.split('src/');
20
+ const isBrowserFile = checkIfBrowserFile(file);
21
+
22
+ return esbuild
23
+ .build({
24
+ entryPoints: [`src/${file}`],
25
+ bundle: isBrowserFile,
26
+ outfile: `./dist/${file}`,
27
+ platform: isBrowserFile ? "browser" : "node",
28
+ format: "esm",
29
+ minify: true,
30
+ plugins: [],
31
+ })
32
+ .catch((error) => {
33
+ console.log(error);
34
+ });
35
+ };
36
+
37
+ const buildFiles = (filesToBuild = []) => {
38
+ return Promise.all(filesToBuild.map((file) => buildFile(file.path)));
39
+ };
40
+
41
+ const copyFiles = (filesToCopy = []) => {
42
+ filesToCopy.forEach((fileToCopy) => {
43
+ const [_, file] = fileToCopy.path.split("src/");
44
+ fs.mkdir(`./dist/${path.dirname(file)}`, { recursive: true }, (error) => {
45
+ if (error) {
46
+ console.warn(error);
47
+ }
48
+ fs.writeFileSync(`./dist/${file}`, fs.readFileSync(`src/${file}`));
49
+ });
50
+ });
51
+ };
52
+
53
+ const filesToBuild = getFilesToBuild();
54
+
55
+ const isNotJavaScript = (path = "") => {
56
+ const extension = path.split('.').pop();
57
+ return extension && !extension.match(/\js$/);
58
+ };
59
+
60
+ const files = filesToBuild.map((path) => {
61
+ let target = "esm";
62
+
63
+ const platformSafePath = path;
64
+
65
+ const copyPaths = [
66
+ "email/templates/base.html",
67
+ ];
68
+
69
+ const isCopyPath = isNotJavaScript(platformSafePath) || copyPaths.some((copyPath) => {
70
+ return path.includes(copyPath);
71
+ });
72
+
73
+ if (isCopyPath) {
74
+ target = "copy";
75
+ }
76
+
77
+ return {
78
+ path: platformSafePath,
79
+ target,
80
+ };
81
+ });
82
+
83
+ if (fs.existsSync('dist')) {
84
+ child_process.execSync('rm -rf ./dist');
85
+ }
86
+
87
+ copyFiles(files.filter(({ target }) => target === "copy"));
88
+ buildFiles(files.filter(({ target }) => target !== "copy"));
@@ -0,0 +1,3 @@
1
+ import os from 'os';
2
+
3
+ export default os.platform() === "win32";
@@ -1,103 +1 @@
1
- import formatAPIError from "../lib/formatAPIError";
2
- import validate from "../validation";
3
- import trackFunctionCall from "../test/trackFunctionCall.js";
4
- class Action {
5
- constructor(input = {}) {
6
- this.name = input?.name;
7
- this.config = input?.config;
8
- this.options = input?.options;
9
- this.steps = this._serializeSteps();
10
- this._serializeSteps = this._serializeSteps.bind(this);
11
- this._logError = this._logError.bind(this);
12
- this.run = this.run.bind(this);
13
- }
14
- _serializeSteps() {
15
- return Object.entries(this?.config?.steps || {})?.reduce((serializedSteps = {}, [stepName = "", stepOptions = {}]) => {
16
- serializedSteps[stepName] = async (...args) => {
17
- try {
18
- trackFunctionCall(`node.actions.${this?.name}.steps.${stepName}`, [
19
- ...args,
20
- this
21
- ]);
22
- const result = await stepOptions?.run(...args, this);
23
- if (typeof stepOptions?.onSuccess === "function") {
24
- stepOptions.onSuccess(result, this);
25
- trackFunctionCall(`node.actions.${this?.name}.steps.${stepName}.onSuccess`, [
26
- result,
27
- this
28
- ]);
29
- }
30
- return result;
31
- } catch (exception) {
32
- if (this.options?.logErrors) {
33
- this._logError(stepName, exception);
34
- }
35
- if (typeof stepOptions?.onError === "function") {
36
- stepOptions.onError(exception, this);
37
- trackFunctionCall(`node.actions.${this?.name}.steps.${stepName}.onError`, [
38
- exception,
39
- this
40
- ]);
41
- }
42
- }
43
- };
44
- return serializedSteps;
45
- }, {});
46
- }
47
- _logError(location = null, exception = null) {
48
- let path = "";
49
- if (this.name && !location) {
50
- path += `${this.name}`;
51
- }
52
- if (this.name && location) {
53
- path += `${this.name}.${location}`;
54
- }
55
- console.log({ path, exception });
56
- }
57
- run(input = {}) {
58
- return new Promise(async (resolve, reject) => {
59
- try {
60
- this.abort = (error) => {
61
- trackFunctionCall(`node.actions.${this?.name}.abort`, [
62
- error
63
- ]);
64
- reject(error);
65
- throw error;
66
- };
67
- if (Object.keys(this?.config?.input || {})?.length > 0) {
68
- const validationErrors = await validate.inputWithSchema(input, this?.config?.input);
69
- if (validationErrors?.length > 0) {
70
- for (let i = 0; i < validationErrors?.length; i += 1) {
71
- const error = validationErrors[i];
72
- if (this?.options?.logErrors) {
73
- console.log(`[${this.name}.validation] ${error}`);
74
- }
75
- }
76
- const formattedValidationErrors = validationErrors?.map((validationError) => {
77
- return validationError?.substring(0, validationError.length - 1);
78
- }).join(", ");
79
- return reject(new Error(formattedValidationErrors));
80
- }
81
- }
82
- trackFunctionCall(`node.actions.${this.name}.run`, [
83
- input || {},
84
- this.steps,
85
- this
86
- ]);
87
- const result = await this.config?.run(input || {}, this?.steps, this);
88
- return resolve(result);
89
- } catch (exception) {
90
- if (this.options?.logErrors) {
91
- this._logError(null, exception);
92
- }
93
- reject(exception);
94
- }
95
- }).catch((error) => {
96
- return Promise.reject(formatAPIError(error, error?.location || this.name));
97
- });
98
- }
99
- }
100
- var class_default = Action;
101
- export {
102
- class_default as default
103
- };
1
+ import l from"../app/api/format_api_error.js";import e from"../test/track_function_call.js";import h from"../lib/types.js";import u from"../app/api/validate_input.js";class f{constructor(i={}){this.name=i?.name,this.config=i?.config,this.options=i?.options,this.steps=this._serialize_steps(),this._serialize_steps=this._serialize_steps.bind(this),this._log_error=this._log_error.bind(this),this.run=this.run.bind(this)}_serialize_steps(){return Object.entries(this?.config?.steps||{})?.reduce((i={},[r="",s={}])=>(i[r]=async(...o)=>{try{e(`node.actions.${this?.name}.steps.${r}`,[...o,this]);const t=await s?.run(...o,this);return(h.is_function(s?.onSuccess)||h.is_function(s?.on_success))&&((s.onSuccess||s.on_success)(t,this),e(`node.actions.${this?.name}.steps.${r}.on_success`,[t,this])),t}catch(t){(this.options?.logErrors||this.options?.log_errors)&&this._log_error(r,t),(h.is_function(s.onError)||h.is_function(s.on_error))&&((s.onError||s.on_error)(t,this),e(`node.actions.${this?.name}.steps.${r}.on_error`,[t,this]))}},i),{})}_log_error(i=null,r=null){let s="";this.name&&!i&&(s+=`${this.name}`),this.name&&i&&(s+=`${this.name}.${i}`),console.log({path:s,exception:r})}run(i={}){return new Promise(async(r,s)=>{try{if(this.abort=t=>{throw e(`node.actions.${this?.name}.abort`,[t]),s(t),t},Object.keys(this?.config?.input||{})?.length>0){const t=await u(i,this?.config?.input);if(t?.length>0){for(let n=0;n<t?.length;n+=1){const a=t[n];(this?.options?.logErrors||this?.options?.log_errors)&&console.log(`[${this.name}.validation] ${a}`)}const c=t?.map(n=>n?.substring(0,n.length-1)).join(", ");return s(new Error(c))}}e(`node.actions.${this.name}.run`,[i||{},this.steps,this]);const o=await this.config?.run(i||{},this?.steps,this);return r(o)}catch(o){(this.options?.logErrors||this?.options?.log_errors)&&this._log_error(null,o),s(o)}}).catch(r=>Promise.reject(l(r,r?.location||this.name)))}}var b=f;export{b as default};
@@ -1,8 +1 @@
1
- import Action from "./class";
2
- var action_default = (name = "", config = {}, options = {}) => {
3
- const action = new Action({ name, config, options });
4
- return action.run;
5
- };
6
- export {
7
- action_default as default
8
- };
1
+ import c from"./class.js";const i=(n="",t={},o={})=>new c({name:n,config:t,options:o}).run;var r=i;export{r as default};
@@ -0,0 +1 @@
1
+ const e=["_id","emailAddress","user_id","email_address"];var d=e;export{d as default};
@@ -0,0 +1 @@
1
+ import o from"../databases/queries/accounts.js";import s from"../../lib/types.js";const t=async(e={})=>{await o("delete_user",{user_id:e?.user_id}),(s.is_function(process.joystick?.app_options?.accounts?.events?.onDeleteUser)||s.is_function(process.joystick?.app_options?.accounts?.events?.on_delete_user))&&(process.joystick?.app_options?.accounts?.events?.onDeleteUser||process.joystick?.app_options?.accounts?.events?.on_delete_user)(e?.user_id)};var p=t;export{p as default};
@@ -0,0 +1 @@
1
+ import t from"../../lib/generate_id.js";var r=()=>{const e=new Date;return e.setDate(e.getDate()+30),{token:t(64),token_expires_at:e}};export{r as default};
@@ -0,0 +1 @@
1
+ import r from"../../lib/generate_id.js";import o from"../databases/queries/accounts.js";const n=(t="",e="")=>o("add_password_reset_token",{email_address:t,token:e}),s=async(t="")=>{const e=r(32);return await n(t,e),e};var d=s;export{d as default};
@@ -0,0 +1 @@
1
+ import n from"../../lib/types.js";const u=(s=null)=>{if(!s||!n.is_object(s))return null;const t=["password","passwordResetTokens","sessions","oauth","verifyEmailTokens"];return Object.entries(s||{}).filter(([e])=>!t.includes(e)).reduce((e,[r,o])=>(e[r]||(e[r]=o),e),{})};var f=u;export{f as default};
@@ -0,0 +1 @@
1
+ const r=(t,n=null,e=null)=>!n||!e?!0:new Date(e)<=new Date;var l=r;export{l as default};
@@ -1,31 +1 @@
1
- import _setAuthenticationCookie from "./setAuthenticationCookie.js";
2
- import _unsetAuthenticationCookie from "./unsetAuthenticationCookie.js";
3
- import defaultUserOutputFields from "./defaultUserOutputFields";
4
- import deleteUser from "./deleteUser.js";
5
- import getBrowserSafeUser from "./getBrowserSafeUser";
6
- import login from "./login";
7
- import recoverPassword from "./recoverPassword";
8
- import resetPassword from "./resetPassword";
9
- import roles from "./roles";
10
- import sendEmailVerification from "./sendEmailVerification";
11
- import setPassword from "./setPassword";
12
- import signup from "./signup";
13
- import verifyEmail from "./verifyEmail.js";
14
- var accounts_default = {
15
- _setAuthenticationCookie,
16
- _unsetAuthenticationCookie,
17
- defaultUserOutputFields,
18
- deleteUser,
19
- getBrowserSafeUser,
20
- login,
21
- recoverPassword,
22
- resetPassword,
23
- roles,
24
- sendEmailVerification,
25
- setPassword,
26
- signup,
27
- verifyEmail
28
- };
29
- export {
30
- accounts_default as default
31
- };
1
+ import f from"./set_account_cookie.js";import a from"./unset_account_cookie.js";import p from"./default_user_output_fields.js";import r from"./delete_user.js";import o from"./get_browser_safe_user.js";import _ from"./login.js";import e from"./recover_password.js";import t from"./reset_password.js";import c from"./roles/index.js";import s from"./send_email_verification.js";import i from"./set_password.js";import d from"./signup.js";import m from"./verify_email.js";const u={_set_account_cookie:f,_unset_account_cookie:a,default_user_output_fields:p,deleteUser:r,delete_user:r,getBrowserSafeUser:o,get_browser_safe_user:o,login:_,recoverPassword:e,recover_password:e,resetPassword:t,reset_password:t,roles:c,sendEmailVerification:s,send_email_verification:s,setPassword:i,set_password:i,signup:d,verifyEmail:m,verify_email:m};var S=u;export{S as default};
@@ -1,65 +1 @@
1
- import bcrypt from "bcrypt";
2
- import formatErrorString from "../../lib/formatErrorString";
3
- import runUserQuery from "./runUserQuery";
4
- import generateSession from "./generateSession";
5
- import getOutput from "../getOutput";
6
- const addSessionToUser = (userId = null, session = null) => {
7
- try {
8
- return runUserQuery("addSession", { userId, session });
9
- } catch (error) {
10
- throw new Error(formatErrorString("login.addSessionToUser", error));
11
- }
12
- };
13
- const deleteOldSessions = (userId = null) => {
14
- try {
15
- return runUserQuery("deleteOldSessions", { userId });
16
- } catch (error) {
17
- throw new Error(formatErrorString("login.deleteOldSessions", error));
18
- }
19
- };
20
- const checkIfValidPassword = (passwordFromLogin = null, passwordHashFromUser = null) => {
21
- try {
22
- return bcrypt.compareSync(passwordFromLogin, passwordHashFromUser);
23
- } catch (error) {
24
- throw new Error(formatErrorString("login.checkIfValidPassword", error));
25
- }
26
- };
27
- const login = async (options, { resolve, reject }) => {
28
- try {
29
- const user = await runUserQuery("user", {
30
- emailAddress: options.emailAddress,
31
- username: options.username
32
- });
33
- if (!user) {
34
- throw new Error(`A user with the ${options.emailAddress ? "email address" : "username"} ${options.emailAddress || options.username} could not be found.`);
35
- }
36
- const isValidPassword = checkIfValidPassword(options.password, user.password);
37
- if (!isValidPassword) {
38
- return reject("Incorrect password.");
39
- }
40
- await deleteOldSessions(user?._id || user?.user_id);
41
- const session = await generateSession();
42
- await addSessionToUser(user?._id || user?.user_id, session);
43
- const { password, sessions, ...restOfUser } = user;
44
- if (typeof process.joystick?._app?.options?.accounts?.onLogin === "function") {
45
- process.joystick?._app?.options?.accounts?.onLogin({
46
- ...session,
47
- user
48
- });
49
- }
50
- return resolve({
51
- ...session,
52
- user: getOutput({
53
- ...restOfUser
54
- }, options?.output)
55
- });
56
- } catch (error) {
57
- reject(new Error(formatErrorString("login", error)));
58
- }
59
- };
60
- var login_default = (options) => new Promise((resolve, reject) => {
61
- login(options, { resolve, reject });
62
- });
63
- export {
64
- login_default as default
65
- };
1
+ import i from"bcrypt";import t from"../databases/queries/accounts.js";import c from"./generate_account_session.js";import d from"../api/get_output.js";import n from"../../lib/types.js";const u=(s=null,e=null)=>t("add_session",{user_id:s,session:e}),_=(s=null)=>t("get_existing_session",{user_id:s}),p=(s=null)=>t("delete_old_sessions",{user_id:s}),l=(s=null,e=null)=>i.compareSync(s,e),m=async(s={})=>{const e=await t("user",{email_address:s.email_address||s.emailAddress,username:s.username});if(!e)throw new Error(`A user with the ${s.email_address||s.emailAddress?"email address":"username"} ${s.email_address||s.emailAddress||s.username} could not be found.`);if(!l(s.password,e.password))throw new Error("Incorrect password.");const o=e?._id||e?.user_id;await p(o);let r=await _(o);r||(r=c(),await u(o,r));const{password:f,sessions:y,...a}=e;return(n.is_function(process.joystick?.app_options?.accounts?.events?.onLogin)||n.is_function(process.joystick?.app_options?.accounts?.events?.on_login))&&(process.joystick?.app_options?.accounts?.events?.onLogin||process.joystick?.app_options?.accounts?.events?.on_login)({...r,user:e}),{...r,user:d({...a},s?.output)}};var x=m;export{x as default};
@@ -0,0 +1 @@
1
+ import a from"../databases/queries/accounts.js";import n from"./generate_password_reset_token.js";import i from"../settings/load.js";import d from"../email/send.js";import r from"../../lib/types.js";const c=i(),m=(e="")=>a("get_password_reset_token",{user_id:e}),l=(e="")=>a("user",{email_address:e}),u=async(e={})=>{const s=await l(e?.email_address||e?.emailAddress);if(!s)throw new Error(`A user with the email address ${e?.email_address||e?.emailAddress} could not be found.`);const o=await m(s?._id||s?.user_id)||await n(e.email_address||e.emailAddress),t=`${process.env.ROOT_URL||`http://localhost:${process.env.PORT}`}/reset-password/${o}`;return process.env.NODE_ENV==="development"&&console.log(`Reset Password URL: ${t}`),(r.is_function(process.joystick?.app_options?.accounts?.events?.onRecoverPassword)||r.is_function(process.joystick?.app_options?.accounts?.events?.on_recover_password))&&(process.joystick?.app_options?.accounts?.events?.onRecoverPassword||process.joystick?.app_options?.accounts?.events?.on_recover_password)(e?.email_address||e?.emailAddress),await d({to:e.email_address||e?.emailAddress,from:c?.config?.email?.from,subject:"Reset Your Password",template:"reset_password",props:{email_address:e.email_address||e?.emailAddress,url:t}}),!0};var y=u;export{y as default};
@@ -0,0 +1 @@
1
+ import o from"../databases/queries/accounts.js";import _ from"./generate_account_session.js";import a from"../api/get_output.js";import i from"../../lib/hash_string.js";import n from"../../lib/types.js";const u=(s=null,e=null)=>o("remove_reset_token",{user_id:s,token:e}),c=(s=null,e=null)=>o("add_session",{user_id:s,session:e}),p=async(s="",e="")=>{const t=i(e);return await o("set_new_password",{user_id:s,hashed_password:t}),t},d=(s="")=>o("reset_user_sessions",{user_id:s}),w=(s="")=>o("user_with_reset_token",{"passwordResetTokens.token":s}),k=async(s={})=>{const e=await w(s.token);if(!e)throw new Error("Invalid password reset token.");await d(e?._id||e?.user_id),await p(e?._id||e?.user_id,s.password);const t=await u(e?._id||e?.user_id,s.token),r=_();return await c(t?._id||t?.user_id,r),(n.is_function(process.joystick?.app_options?.accounts?.events?.onResetPassword)||n.is_function(process.joystick?.app_options?.accounts?.events?.on_reset_password))&&(process.joystick?.app_options?.accounts?.events?.onResetPassword||process.joystick?.app_options?.accounts?.events?.on_reset_password)({user:t,...r}),{user:a(t,s?.output),...r}};var v=k;export{v as default};
@@ -1,7 +1 @@
1
- import runUserQuery from "../runUserQuery";
2
- var add_default = (role = "") => {
3
- return runUserQuery("addRole", { role });
4
- };
5
- export {
6
- add_default as default
7
- };
1
+ import o from"../../databases/queries/accounts.js";const t=(r="")=>o("add_role",{role:r});var e=t;export{e as default};
@@ -1,7 +1 @@
1
- import runUserQuery from "../runUserQuery";
2
- var grant_default = (userId = "", role = "") => {
3
- return runUserQuery("grantRole", { userId, role });
4
- };
5
- export {
6
- grant_default as default
7
- };
1
+ import o from"../../databases/queries/accounts.js";const e=(r="",t="")=>o("grant_role",{user_id:r,role:t});var a=e;export{a as default};
@@ -1,17 +1 @@
1
- import add from "./add";
2
- import remove from "./remove";
3
- import list from "./list";
4
- import grant from "./grant";
5
- import revoke from "./revoke";
6
- import userHasRole from "./userHasRole";
7
- var roles_default = {
8
- add,
9
- remove,
10
- list,
11
- grant,
12
- revoke,
13
- userHasRole
14
- };
15
- export {
16
- roles_default as default
17
- };
1
+ import o from"./add.js";import m from"./remove.js";import e from"./list.js";import t from"./grant.js";import f from"./revoke.js";import r from"./user_has_role.js";var u={add:o,remove:m,list:e,grant:t,revoke:f,userHasRole:r,user_has_role:r};export{u as default};
@@ -1,7 +1 @@
1
- import runUserQuery from "../runUserQuery";
2
- var list_default = (role = "") => {
3
- return runUserQuery("listRoles");
4
- };
5
- export {
6
- list_default as default
7
- };
1
+ import t from"../../databases/queries/accounts.js";const r=()=>t("list_roles");var e=r;export{e as default};
@@ -1,7 +1 @@
1
- import runUserQuery from "../runUserQuery";
2
- var remove_default = (role = "") => {
3
- return runUserQuery("removeRole", { role });
4
- };
5
- export {
6
- remove_default as default
7
- };
1
+ import r from"../../databases/queries/accounts.js";const o=(e="")=>r("remove_role",{role:e});var m=o;export{m as default};
@@ -1,7 +1 @@
1
- import runUserQuery from "../runUserQuery";
2
- var revoke_default = (userId = "", role = "") => {
3
- return runUserQuery("revokeRole", { userId, role });
4
- };
5
- export {
6
- revoke_default as default
7
- };
1
+ import o from"../../databases/queries/accounts.js";const t=(e="",r="")=>o("revoke_role",{user_id:e,role:r});var c=t;export{c as default};
@@ -0,0 +1 @@
1
+ import o from"../../databases/queries/accounts.js";const s=(r="",e="")=>o("user_has_role",{user_id:r,role:e});var u=s;export{u as default};
@@ -0,0 +1 @@
1
+ import r from"../databases/queries/accounts.js";import o from"../settings/load.js";import a from"../email/send.js";const n=(e="",i="")=>{const t=o();return a({to:e,from:t?.config?.email?.from,subject:t?.config?.email?.verify?.subject||"Verify your email address",template:t?.config?.email?.verify?.template||"verify_email",props:{emailAddress:e,email_address:e,url:process.env.NODE_ENV==="development"?`http://localhost:${process.env.PORT}/api/_accounts/verify_email?token=${i}`:`${process.env.ROOT_URL}/api/_accounts/verify_email?token=${i}`}})},s=(e="")=>r("create_email_verification_token",{user_id:e}),c=(e="")=>r("user",{_id:e}),m=async(e="")=>{const i=await c(e);if(!i?.emailVerified&&!i?.emailVerifiedAt){const t=await s(i?._id||i?.user_id);await n(i?.emailAddress,t)}return!0};var u=m;export{u as default};
@@ -0,0 +1 @@
1
+ import _ from"../../lib/set_cookie.js";const k=(o=null,e=null)=>!o||!e?null:(_(o,"joystick_login_token",e.token,e.token_expires_at),_(o,"joystick_login_token_expires_at",e.token_expires_at,e.token_expires_at),o);var t=k;export{t as default};
@@ -0,0 +1 @@
1
+ import e from"../databases/queries/accounts.js";import n from"../../lib/hash_string.js";import t from"../../lib/types.js";const i=(s=null)=>e("reset_user_sessions",{user_id:s}),a=async(s="",r="")=>{const o=n(r);return await e("set_new_password",{user_id:s,hashed_password:o}),o},u=(s="")=>e("user",{_id:s}),c=async(s={})=>{if(!s?.user_id||!s?.password)throw new Error("Must provider a user_id and password to set.");const r=await u(s?.user_id);if(!r)throw new Error("Invalid user_id.");return await a(r?._id||r?.user_id,s?.password),await i(r?._id||r?.user_id),(t.is_function(process.joystick?.app_options?.accounts?.events?.onSetPassword)||t.is_function(process.joystick?.app_options?.accounts?.events?.on_set_password))&&(process.joystick?.app_options?.accounts?.events?.onSetPassword||process.joystick?.app_options?.accounts?.events?.on_set_password)(s?.user_id),!0};var w=c;export{w as default};
@@ -1,140 +1 @@
1
- import hashString from "./hashString";
2
- import generateSession from "./generateSession";
3
- import formatErrorString from "../../lib/formatErrorString";
4
- import runUserQuery from "./runUserQuery";
5
- import { isObject } from "../../validation/lib/typeValidators";
6
- import getOutput from "../getOutput";
7
- import typesMap from "../databases/typesMap";
8
- import getTargetDatabaseProvider from "../databases/getTargetDatabaseProvider.js";
9
- import stringToSnakeCase from "../databases/stringToSnakeCase.js";
10
- import createMetadataTableColumns from "./createMetadataTableColumns.js";
11
- import roles from "./roles/index.js";
12
- const addSessionToUser = (userId = null, session = null) => {
13
- try {
14
- return runUserQuery("addSession", { userId, session });
15
- } catch (error) {
16
- throw new Error(formatErrorString("signup.addSessionToUser", error));
17
- }
18
- };
19
- const getUserByUserId = (userId = "") => {
20
- try {
21
- return runUserQuery("user", { _id: userId });
22
- } catch (exception) {
23
- throw new Error(formatErrorString("signup.getUserByUserId", exception));
24
- }
25
- };
26
- const insertUserInDatabase = async (user = {}) => {
27
- try {
28
- return runUserQuery("createUser", user);
29
- } catch (exception) {
30
- throw new Error(formatErrorString("signup.insertUserInDatabase", exception));
31
- }
32
- };
33
- const sqlizeMetadata = (metadata = {}) => {
34
- try {
35
- return Object.entries(metadata || {}).reduce((sqlized = {}, [key, value]) => {
36
- sqlized[stringToSnakeCase(key)] = value;
37
- return sqlized;
38
- }, {});
39
- } catch (exception) {
40
- throw new Error(`[actionName.sqlizeMetadata] ${exception.message}`);
41
- }
42
- };
43
- const getUserToCreate = async (options = {}) => {
44
- try {
45
- const usersDatabase = getTargetDatabaseProvider("users");
46
- const usersDatabaseType = typesMap[usersDatabase];
47
- let user = {
48
- password: await hashString(options.password)
49
- };
50
- if (options?.emailAddress) {
51
- user.emailAddress = options?.emailAddress;
52
- }
53
- if (options?.username) {
54
- user.username = options?.username;
55
- }
56
- if (options?.metadata && isObject(options.metadata) && usersDatabaseType === "sql") {
57
- const sqlizedMetadata = sqlizeMetadata(options.metadata);
58
- await createMetadataTableColumns(usersDatabase, sqlizedMetadata);
59
- const metadata = { ...options?.metadata || {} };
60
- if (metadata?.roles) {
61
- delete metadata.roles;
62
- }
63
- user = {
64
- ...sqlizeMetadata(metadata),
65
- ...user
66
- };
67
- }
68
- if (options?.metadata && isObject(options.metadata) && usersDatabaseType === "nosql") {
69
- let metadata = { ...options?.metadata || {} };
70
- if (metadata?.roles) {
71
- delete metadata.roles;
72
- }
73
- user = {
74
- ...metadata || {},
75
- ...user
76
- };
77
- }
78
- return user;
79
- } catch (exception) {
80
- throw new Error(formatErrorString("signup.getUserToCreate", exception));
81
- }
82
- };
83
- const getExistingUser = (emailAddress = "", username = "") => {
84
- try {
85
- return runUserQuery("existingUser", { emailAddress, username });
86
- } catch (exception) {
87
- throw new Error(formatErrorString("signup.getExistingUser", exception));
88
- }
89
- };
90
- const signup = async (options, { resolve, reject }) => {
91
- try {
92
- if (!options.emailAddress) {
93
- return reject("Email address is required.");
94
- }
95
- if (!options.password) {
96
- return reject("Password is required.");
97
- }
98
- const existingUser = await getExistingUser(options.emailAddress, options.metadata?.username);
99
- if (existingUser && process.env.NODE_ENV !== "test") {
100
- throw new Error(`A user with the ${existingUser.existingUsername ? "username" : "email address"} ${existingUser.existingUsername || existingUser.existingEmailAddress} already exists.`);
101
- }
102
- let userToCreate;
103
- let userId = existingUser?._id || existingUser?.user_id;
104
- if (!existingUser) {
105
- userToCreate = await getUserToCreate(options);
106
- userId = await insertUserInDatabase(userToCreate);
107
- }
108
- const user = await getUserByUserId(userId);
109
- const session = generateSession();
110
- if (user?._id || user?.user_id) {
111
- await addSessionToUser(user?._id || user?.user_id, session);
112
- }
113
- if (options?.metadata?.roles?.length > 0 && process.env.NODE_ENV === "test") {
114
- for (let i = 0; i < options?.metadata?.roles?.length; i += 1) {
115
- const role = options?.metadata?.roles[i];
116
- roles.grant(user?._id || user?.user_id, role);
117
- }
118
- }
119
- if (typeof process.joystick?._app?.options?.accounts?.onSignup === "function") {
120
- process.joystick?._app?.options?.accounts?.onSignup({
121
- ...session,
122
- userId,
123
- user
124
- });
125
- }
126
- return resolve({
127
- ...session,
128
- userId,
129
- user: getOutput(user, options?.output)
130
- });
131
- } catch (exception) {
132
- reject(new Error(formatErrorString("signup", exception)));
133
- }
134
- };
135
- var signup_default = (options) => new Promise((resolve, reject) => {
136
- signup(options, { resolve, reject });
137
- });
138
- export {
139
- signup_default as default
140
- };
1
+ import i from"../databases/queries/accounts.js";import m from"../../lib/camel_pascal_to_snake.js";import u from"../databases/postgresql/accounts/create_accounts_metadata_table_columns.js";import l from"../databases/database_type_map.js";import f from"./generate_account_session.js";import w from"../api/get_output.js";import p from"../databases/get_target_database_connection.js";import y from"../../lib/hash_string.js";import g from"./roles/index.js";import n from"../../lib/types.js";const b=(e=null,s=null)=>i("add_session",{user_id:e,session:s}),h=(e="")=>i("user",{_id:e}),x=async(e={})=>i("create_user",e),_=(e={})=>Object.entries(e||{}).reduce((s={},[r,a])=>(s[m(r)]=a,s),{}),E=async(e={})=>{const s=p("users"),r=l[s?.provider];let a={password:y(e.password)};if(e?.email_address&&(a.emailAddress=e?.email_address||e.emailAddress),e?.username&&(a.username=e?.username),e?.metadata&&n.is_object(e.metadata)&&r==="sql"){const t=_(e.metadata);await u(s,t);const d={...e?.metadata||{}};d?.roles&&delete d.roles,a={..._(d),...a}}if(e?.metadata&&n.is_object(e.metadata)&&r==="nosql"){let t={...e?.metadata||{}};t?.roles&&delete t.roles,a={...t||{},...a}}return a},j=(e="",s="")=>i("existing_user",{email_address:e,username:s}),v=async e=>{if(!e.email_address&&!e.emailAddress)throw new Error("Email address is required.");if(!e.password)throw new Error("Password is required.");const s=await j(e.email_address||e.emailAddress,e.metadata?.username);if(s&&process.env.NODE_ENV!=="test")throw new Error(`A user with the ${s.exisitng_username?"username":"email address"} ${s.exisitng_username||s.existing_email_address} already exists.`);let r,a=s?._id||s?.user_id;s||(r=await E(e),a=await x(r));const t=await h(a),d=f();if(a&&await b(a,d),e?.metadata?.roles?.length>0&&process.env.NODE_ENV==="test")for(let o=0;o<e?.metadata?.roles?.length;o+=1){const c=e?.metadata?.roles[o];g.grant(t?._id||t?.user_id,c)}return(n.is_function(process.joystick?.app_options?.accounts?.events?.onSignup)||n.is_function(process.joystick?.app_options?.accounts?.events?.on_signup))&&(process.joystick?.app_options?.accounts?.events?.onSignup||process.joystick?.app_options?.accounts?.events?.on_signup)({...d,user_id:a,userId:a,user:t}),{...d,userId:a,user_id:a,user:w(t,e?.output)}};var z=v;export{z as default};
@@ -0,0 +1 @@
1
+ import t from"../../lib/unset_cookie.js";const n=(o=null)=>o?(t("joystick_login_token",o),t("joystick_login_token_expires_at",o),o):null;var i=n;export{i as default};
@@ -0,0 +1 @@
1
+ import o from"../databases/queries/accounts.js";const r=(t="",e="")=>o("mark_email_verified_at",{user_id:t,token:e}),i=(t="")=>o("user_with_verify_email_token",{token:t}),n=async(t={})=>{const e=await i(t?.token);if(!e)throw new Error("A user with this token could not be found.");return await r(e?._id||e?.user_id,t?.token),typeof process.joystick?.app_options?.accounts?.events?.onVerifyEmail=="function"&&process.joystick?.app_options?.accounts?.events?.onVerifyEmail(e?.emailAddress||e?.email_address),!0};var a=n;export{a as default};
@@ -0,0 +1 @@
1
+ import n from"../../accounts/has_login_token_expired.js";const s=(t={},o={})=>{const e=n(o,t?.cookies?.joystick_login_token,t?.cookies?.joystick_login_token_expires_at),i=e?401:200;return o.status(i).send(JSON.stringify({status:i,authenticated:!e}))};var a=s;export{a as default};
@@ -0,0 +1 @@
1
+ import n from"../../accounts/index.js";import a from"../../accounts/default_user_output_fields.js";import i from"../handle_api_error.js";const r=async(t={},e={})=>{try{const o=await n.login({email_address:t?.body?.emailAddress||t?.body?.email_address,username:t?.body?.username,password:t?.body?.password,output:t?.body?.output||a});!process.env.NODE_ENV!=="test"&&n._set_account_cookie(e,{token:o?.token,token_expires_at:o?.token_expires_at});const s={...o?.user||{}};process.env.NODE_ENV==="test"&&(s.joystick_token=o?.token,s.joystick_login_token_expires_at=o?.token_expires_at),e.status(200).send(JSON.stringify(s))}catch(o){i("accounts.login",o,e)}};var p=r;export{p as default};
@@ -0,0 +1 @@
1
+ import n from"../../accounts/index.js";import t from"../../../lib/types.js";const c=(s={},o={})=>{n._unset_account_cookie(o),(t.is_function(process?.joystick?.app_options?.accounts?.events?.onLogout)||t.is_function(process?.joystick?.app_options?.accounts?.events?.on_logout))&&(process?.joystick?.app_options?.accounts?.events?.onLogout||process?.joystick?.app_options?.accounts?.events?.on_logout)(s?.context?.user),o.status(200).send(JSON.stringify({}))};var i=c;export{i as default};
@@ -0,0 +1 @@
1
+ import o from"../../accounts/index.js";import e from"../handle_api_error.js";const d=async(r={},s={})=>{try{await o.recover_password({email_address:r?.body?.emailAddress||r?.body?.email_address}),s.status(200).send(JSON.stringify({}))}catch(a){e("accounts.recover_password",a,s)}};var i=d;export{i as default};
@@ -0,0 +1 @@
1
+ import e from"../../accounts/index.js";import r from"../../accounts/default_user_output_fields.js";import a from"../handle_api_error.js";const n=async(o={},s={})=>{try{const t=await e.reset_password({token:o?.body?.token,password:o?.body?.password,output:o?.body?.output||r});e._set_account_cookie(s,{token:t?.token,token_expires_at:t?.token_expires_at}),s.status(200).send(JSON.stringify(t?.user||{}))}catch(t){a("accounts.reset_password",t,s)}};var d=n;export{d as default};