@joystick.js/node-canary 0.0.0-canary.42 → 0.0.0-canary.420
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.build/getFilesToBuild.js +26 -0
- package/.build/getPlatformSafeFilePath.js +6 -0
- package/.build/getPlatformSafePath.js +6 -0
- package/.build/index.js +88 -0
- package/.build/isWindows.js +3 -0
- package/dist/action/class.js +1 -82
- package/dist/action/index.js +1 -8
- package/dist/app/accounts/default_user_output_fields.js +1 -0
- package/dist/app/accounts/delete_user.js +1 -0
- package/dist/app/accounts/generate_account_session.js +1 -0
- package/dist/app/accounts/generate_password_reset_token.js +1 -0
- package/dist/app/accounts/get_browser_safe_user.js +1 -0
- package/dist/app/accounts/has_login_token_expired.js +1 -0
- package/dist/app/accounts/index.js +1 -29
- package/dist/app/accounts/login.js +1 -59
- package/dist/app/accounts/recover_password.js +1 -0
- package/dist/app/accounts/reset_password.js +1 -0
- package/dist/app/accounts/roles/add.js +1 -7
- package/dist/app/accounts/roles/grant.js +1 -7
- package/dist/app/accounts/roles/index.js +1 -17
- package/dist/app/accounts/roles/list.js +1 -7
- package/dist/app/accounts/roles/remove.js +1 -7
- package/dist/app/accounts/roles/revoke.js +1 -7
- package/dist/app/accounts/roles/user_has_role.js +1 -0
- package/dist/app/accounts/send_email_verification.js +1 -0
- package/dist/app/accounts/set_account_cookie.js +1 -0
- package/dist/app/accounts/set_password.js +1 -0
- package/dist/app/accounts/signup.js +1 -97
- package/dist/app/accounts/unset_account_cookie.js +1 -0
- package/dist/app/accounts/verify_email.js +1 -0
- package/dist/app/api/accounts/authenticated.js +1 -0
- package/dist/app/api/accounts/login.js +1 -0
- package/dist/app/api/accounts/logout.js +1 -0
- package/dist/app/api/accounts/recover_password.js +1 -0
- package/dist/app/api/accounts/reset_password.js +1 -0
- package/dist/app/api/accounts/signup.js +1 -0
- package/dist/app/api/accounts/user.js +1 -0
- package/dist/app/api/accounts/verify_email.js +1 -0
- package/dist/app/api/format_api_error.js +1 -0
- package/dist/app/api/get.js +2 -0
- package/dist/app/api/get_api_context.js +1 -0
- package/dist/app/api/get_api_for_data_functions.js +1 -0
- package/dist/app/api/get_api_url_component.js +1 -0
- package/dist/app/api/get_output.js +1 -0
- package/dist/app/api/get_value_from_object.js +1 -0
- package/dist/app/api/handle_api_error.js +1 -0
- package/dist/app/api/input_validators.js +1 -0
- package/dist/app/api/is_array_path.js +1 -0
- package/dist/app/api/push/health.js +2 -0
- package/dist/app/api/register_getters.js +1 -0
- package/dist/app/api/register_setters.js +1 -0
- package/dist/app/api/sanitize_api_response.js +1 -0
- package/dist/app/api/set.js +2 -0
- package/dist/app/api/test/accounts/delete.js +1 -0
- package/dist/app/api/test/accounts/signup.js +1 -0
- package/dist/app/api/test/bootstrap.js +1 -0
- package/dist/app/api/test/process.js +1 -0
- package/dist/app/api/test/queues.js +1 -0
- package/dist/app/api/validate_input.js +1 -0
- package/dist/app/api/validate_session.js +1 -0
- package/dist/app/api/validate_type.js +1 -0
- package/dist/app/browser/hmr_client.js +1 -0
- package/dist/app/browser/process_polyfill.js +1 -0
- package/dist/app/cron_jobs/register.js +1 -0
- package/dist/app/databases/database_type_map.js +1 -0
- package/dist/app/databases/get_target_database_connection.js +1 -0
- package/dist/app/databases/mongodb/available_query_parameters.js +1 -0
- package/dist/app/databases/mongodb/build_connection_string.js +1 -0
- package/dist/app/databases/mongodb/build_query_parameters.js +1 -0
- package/dist/app/databases/mongodb/connect.js +6 -0
- package/dist/app/databases/mongodb/create_indexes.js +1 -0
- package/dist/app/databases/postgresql/accounts/create_accounts_metadata_table_columns.js +1 -0
- package/dist/app/databases/postgresql/connect.js +30 -0
- package/dist/app/databases/postgresql/create_indexes.js +1 -0
- package/dist/app/databases/postgresql/create_tables.js +1 -0
- package/dist/app/databases/postgresql/handle_cleanup_queues.js +5 -0
- package/dist/app/databases/postgresql/handle_cleanup_sessions.js +1 -0
- package/dist/app/databases/queries/accounts.js +1 -0
- package/dist/app/databases/queries/map.js +1 -0
- package/dist/app/databases/queries/mongodb/accounts.js +1 -0
- package/dist/app/databases/queries/mongodb/queues.js +1 -0
- package/dist/app/databases/queries/mongodb/sessions.js +1 -0
- package/dist/app/databases/queries/postgresql/accounts.js +1 -0
- package/dist/app/databases/queries/postgresql/queues.js +123 -0
- package/dist/app/databases/queries/postgresql/sessions.js +14 -0
- package/dist/app/databases/queries/sessions.js +1 -0
- package/dist/app/databases/register_database.js +1 -0
- package/dist/app/databases/sql.js +1 -0
- package/dist/app/email/send.js +1 -0
- package/dist/app/email/validate_smtp_settings.js +1 -0
- package/dist/app/fixture/index.js +1 -0
- package/dist/app/generate_machine_id.js +1 -0
- package/dist/app/generate_process_id.js +1 -0
- package/dist/app/get_ssl_certificates.js +1 -0
- package/dist/app/handle_process_errors.js +1 -0
- package/dist/app/index.js +1 -654
- package/dist/app/middleware/account.js +1 -0
- package/dist/app/middleware/body_parser.js +1 -0
- package/dist/app/middleware/build_error.js +1 -0
- package/dist/app/middleware/built_in.js +1 -0
- package/dist/app/middleware/context.js +1 -0
- package/dist/app/middleware/cors.js +1 -22
- package/dist/app/middleware/csp.js +1 -48
- package/dist/app/middleware/generate_insecure_page.js +65 -0
- package/dist/app/middleware/generate_joystick_error_page.js +147 -0
- package/dist/app/middleware/hmr_client.js +1 -0
- package/dist/app/middleware/insecure.js +1 -11
- package/dist/app/middleware/process_browser_polyfill.js +1 -0
- package/dist/app/middleware/render/get_url.js +1 -0
- package/dist/app/middleware/render/index.js +1 -0
- package/dist/app/middleware/request_methods.js +1 -0
- package/dist/app/middleware/session.js +1 -24
- package/dist/app/push_logs.js +1 -0
- package/dist/app/queues/index.js +1 -119
- package/dist/app/register_app_options.js +1 -0
- package/dist/app/routes/register_route_from_function.js +1 -0
- package/dist/app/routes/register_route_from_object.js +1 -0
- package/dist/app/routes/supported_http_methods.js +1 -0
- package/dist/app/settings/load.js +1 -0
- package/dist/app/ssr/index.js +32 -0
- package/dist/app/ssr/set_base_attributes_in_html.js +1 -0
- package/dist/app/ssr/set_head_tags_in_html.js +1 -0
- package/dist/app/start_express.js +1 -0
- package/dist/app/start_node_as_cluster.js +1 -0
- package/dist/app/uploaders/local_upload_progress_middleware.js +1 -0
- package/dist/app/uploaders/register.js +1 -0
- package/dist/app/uploaders/run_upload.js +1 -0
- package/dist/app/uploaders/validate_options.js +1 -0
- package/dist/app/uploaders/validate_uploads.js +1 -0
- package/dist/app/websockets/emit_event.js +1 -0
- package/dist/app/websockets/index.js +1 -0
- package/dist/app/websockets/register.js +1 -0
- package/dist/index.js +4 -76
- package/dist/lib/camel_pascal_to_snake.js +1 -0
- package/dist/lib/constants.js +1 -13
- package/dist/lib/dynamic_import.js +1 -0
- package/dist/lib/escape_html.js +1 -0
- package/dist/lib/escape_key_value_pair.js +1 -0
- package/dist/lib/float_to_decimal_place.js +1 -0
- package/dist/lib/generate_id.js +1 -0
- package/dist/lib/get_browser_safe_request.js +1 -0
- package/dist/lib/get_joystick_build_path.js +1 -0
- package/dist/lib/get_origin.js +1 -0
- package/dist/lib/get_sanitized_context.js +1 -0
- package/dist/lib/get_translations.js +1 -0
- package/dist/lib/hash_string.js +1 -0
- package/dist/lib/is_valid_json.js +1 -0
- package/dist/lib/log.js +13 -52
- package/dist/lib/node_path_polyfills.js +1 -0
- package/dist/lib/parse_json.js +1 -0
- package/dist/lib/path_exists.js +1 -0
- package/dist/lib/rainbow_road.js +1 -0
- package/dist/lib/replace_backslashes_with_forward_slashes.js +1 -0
- package/dist/lib/replace_file_protocol.js +1 -0
- package/dist/lib/serialize_query_parameters.js +1 -0
- package/dist/lib/set_cookie.js +1 -0
- package/dist/lib/string_to_slug.js +1 -0
- package/dist/lib/timestamps.js +1 -0
- package/dist/lib/types.js +1 -0
- package/dist/lib/unset_cookie.js +1 -0
- package/dist/lib/wait.js +1 -0
- package/dist/test/track_function_call.js +1 -0
- package/increment_version.js +3 -0
- package/package.json +27 -44
- package/src/action/class.js +137 -0
- package/src/action/index.js +8 -0
- package/src/app/accounts/default_user_output_fields.js +10 -0
- package/src/app/accounts/delete_user.js +18 -0
- package/src/app/accounts/generate_account_session.js +11 -0
- package/src/app/accounts/generate_password_reset_token.js +16 -0
- package/src/app/accounts/get_browser_safe_user.js +29 -0
- package/src/app/accounts/has_login_token_expired.js +9 -0
- package/src/app/accounts/index.js +38 -0
- package/src/app/accounts/login.js +82 -0
- package/src/app/accounts/recover_password.js +58 -0
- package/src/app/accounts/reset_password.js +69 -0
- package/src/app/accounts/roles/add.js +7 -0
- package/src/app/accounts/roles/grant.js +7 -0
- package/src/app/accounts/roles/index.js +18 -0
- package/src/app/accounts/roles/list.js +7 -0
- package/src/app/accounts/roles/remove.js +7 -0
- package/src/app/accounts/roles/revoke.js +7 -0
- package/src/app/accounts/roles/user_has_role.js +7 -0
- package/src/app/accounts/send_email_verification.js +48 -0
- package/src/app/accounts/set_account_cookie.js +12 -0
- package/src/app/accounts/set_password.js +46 -0
- package/src/app/accounts/signup.js +158 -0
- package/src/app/accounts/unset_account_cookie.js +12 -0
- package/src/app/accounts/verify_email.js +32 -0
- package/src/app/api/accounts/authenticated.js +17 -0
- package/src/app/api/accounts/login.js +36 -0
- package/src/app/api/accounts/logout.js +20 -0
- package/src/app/api/accounts/recover_password.js +16 -0
- package/src/app/api/accounts/reset_password.js +24 -0
- package/src/app/api/accounts/signup.js +49 -0
- package/src/app/api/accounts/user.js +21 -0
- package/src/app/api/accounts/verify_email.js +11 -0
- package/src/app/api/format_api_error.js +10 -0
- package/src/app/api/get.js +119 -0
- package/src/app/api/get_api_context.js +27 -0
- package/src/app/api/get_api_for_data_functions.js +37 -0
- package/src/app/api/get_api_url_component.js +5 -0
- package/src/app/api/get_output.js +116 -0
- package/src/app/api/get_value_from_object.js +8 -0
- package/src/app/api/handle_api_error.js +28 -0
- package/src/app/api/input_validators.js +227 -0
- package/src/app/api/is_array_path.js +6 -0
- package/src/app/api/push/health.js +17 -0
- package/src/app/api/register_getters.js +57 -0
- package/src/app/api/register_setters.js +55 -0
- package/src/app/api/sanitize_api_response.js +35 -0
- package/src/app/api/set.js +119 -0
- package/src/app/api/test/accounts/delete.js +8 -0
- package/src/app/api/test/accounts/signup.js +50 -0
- package/src/app/api/test/bootstrap.js +36 -0
- package/src/app/api/test/process.js +7 -0
- package/src/app/api/test/queues.js +25 -0
- package/src/app/api/validate_input.js +132 -0
- package/src/app/api/validate_session.js +20 -0
- package/src/app/api/validate_type.js +24 -0
- package/src/app/browser/hmr_client.js +196 -0
- package/src/app/browser/process_polyfill.js +11 -0
- package/src/app/cron_jobs/register.js +29 -0
- package/src/app/databases/database_type_map.js +6 -0
- package/src/app/databases/get_target_database_connection.js +25 -0
- package/{dist/app/databases/mongodb/availableQueryParameters.js → src/app/databases/mongodb/available_query_parameters.js} +3 -4
- package/src/app/databases/mongodb/build_connection_string.js +30 -0
- package/src/app/databases/mongodb/build_query_parameters.js +17 -0
- package/src/app/databases/mongodb/connect.js +42 -0
- package/src/app/databases/mongodb/create_indexes.js +35 -0
- package/src/app/databases/postgresql/accounts/create_accounts_metadata_table_columns.js +18 -0
- package/src/app/databases/postgresql/connect.js +128 -0
- package/src/app/databases/postgresql/create_indexes.js +58 -0
- package/src/app/databases/postgresql/create_tables.js +70 -0
- package/src/app/databases/postgresql/handle_cleanup_queues.js +36 -0
- package/src/app/databases/postgresql/handle_cleanup_sessions.js +5 -0
- package/src/app/databases/queries/accounts.js +17 -0
- package/src/app/databases/queries/map.js +21 -0
- package/src/app/databases/queries/mongodb/accounts.js +360 -0
- package/src/app/databases/queries/mongodb/queues.js +157 -0
- package/src/app/databases/queries/mongodb/sessions.js +22 -0
- package/src/app/databases/queries/postgresql/accounts.js +379 -0
- package/src/app/databases/queries/postgresql/queues.js +288 -0
- package/src/app/databases/queries/postgresql/sessions.js +37 -0
- package/src/app/databases/queries/sessions.js +17 -0
- package/src/app/databases/register_database.js +30 -0
- package/src/app/databases/sql.js +63 -0
- package/src/app/email/send.js +108 -0
- package/src/app/email/validate_smtp_settings.js +53 -0
- package/src/app/fixture/index.js +50 -0
- package/src/app/generate_machine_id.js +26 -0
- package/src/app/generate_process_id.js +30 -0
- package/src/app/get_ssl_certificates.js +23 -0
- package/src/app/handle_process_errors.js +101 -0
- package/src/app/index.js +248 -0
- package/src/app/middleware/account.js +28 -0
- package/src/app/middleware/body_parser.js +18 -0
- package/src/app/middleware/build_error.js +18 -0
- package/src/app/middleware/built_in.js +76 -0
- package/src/app/middleware/context.js +34 -0
- package/src/app/middleware/cors.js +23 -0
- package/src/app/middleware/csp.js +54 -0
- package/src/app/middleware/generate_insecure_page.js +71 -0
- package/{dist/lib/generateErrorPage.js → src/app/middleware/generate_joystick_error_page.js} +25 -21
- package/src/app/middleware/hmr_client.js +12 -0
- package/src/app/middleware/insecure.js +22 -0
- package/src/app/middleware/process_browser_polyfill.js +12 -0
- package/src/app/middleware/render/get_url.js +15 -0
- package/src/app/middleware/render/index.js +93 -0
- package/src/app/middleware/request_methods.js +21 -0
- package/src/app/middleware/session.js +31 -0
- package/src/app/push_logs.js +36 -0
- package/src/app/queues/index.js +268 -0
- package/src/app/register_app_options.js +7 -0
- package/src/app/routes/register_route_from_function.js +10 -0
- package/src/app/routes/register_route_from_object.js +34 -0
- package/src/app/routes/supported_http_methods.js +9 -0
- package/src/app/settings/load.js +33 -0
- package/src/app/ssr/index.js +131 -0
- package/src/app/ssr/set_base_attributes_in_html.js +43 -0
- package/src/app/ssr/set_head_tags_in_html.js +104 -0
- package/src/app/start_express.js +50 -0
- package/src/app/start_node_as_cluster.js +30 -0
- package/src/app/uploaders/local_upload_progress_middleware.js +24 -0
- package/src/app/uploaders/register.js +169 -0
- package/src/app/uploaders/run_upload.js +136 -0
- package/src/app/uploaders/validate_options.js +74 -0
- package/src/app/uploaders/validate_uploads.js +127 -0
- package/src/app/websockets/emit_event.js +14 -0
- package/src/app/websockets/index.js +16 -0
- package/src/app/websockets/register.js +175 -0
- package/src/index.js +82 -0
- package/{dist/lib/camelPascalToSnake.js → src/lib/camel_pascal_to_snake.js} +3 -4
- package/src/lib/constants.js +21 -0
- package/src/lib/dynamic_import.js +6 -0
- package/src/lib/escape_html.js +9 -0
- package/src/lib/escape_key_value_pair.js +15 -0
- package/src/lib/float_to_decimal_place.js +5 -0
- package/src/lib/generate_id.js +15 -0
- package/src/lib/get_browser_safe_request.js +17 -0
- package/src/lib/get_joystick_build_path.js +28 -0
- package/src/lib/get_origin.js +7 -0
- package/src/lib/get_sanitized_context.js +51 -0
- package/src/lib/get_translations.js +102 -0
- package/src/lib/hash_string.js +7 -0
- package/src/lib/is_valid_json.js +10 -0
- package/src/lib/log.js +42 -0
- package/src/lib/node_path_polyfills.js +18 -0
- package/src/lib/parse_json.js +9 -0
- package/src/lib/path_exists.js +11 -0
- package/src/lib/rainbow_road.js +7 -0
- package/src/lib/replace_backslashes_with_forward_slashes.js +8 -0
- package/src/lib/replace_file_protocol.js +8 -0
- package/src/lib/serialize_query_parameters.js +7 -0
- package/src/lib/set_cookie.js +16 -0
- package/src/lib/string_to_slug.js +14 -0
- package/src/lib/timestamps.js +48 -0
- package/src/lib/types.js +59 -0
- package/src/lib/unset_cookie.js +11 -0
- package/src/lib/wait.js +9 -0
- package/src/test/track_function_call.js +16 -0
- package/README.md +0 -8
- package/_package.json +0 -63
- package/canary.js +0 -12
- package/dist/api/get.js +0 -29
- package/dist/api/getOrigin.js +0 -6
- package/dist/api/index.js +0 -9
- package/dist/api/set.js +0 -29
- package/dist/app/accounts/defaultUserOutputFields.js +0 -9
- package/dist/app/accounts/generateResetToken.js +0 -28
- package/dist/app/accounts/generateSession.js +0 -15
- package/dist/app/accounts/getBrowserSafeUser.js +0 -24
- package/dist/app/accounts/hasLoginTokenExpired.js +0 -18
- package/dist/app/accounts/hashString.js +0 -7
- package/dist/app/accounts/recoverPassword.js +0 -30
- package/dist/app/accounts/resetPassword.js +0 -73
- package/dist/app/accounts/roles/index.test.js +0 -123
- package/dist/app/accounts/roles/userHasRole.js +0 -7
- package/dist/app/accounts/runUserQuery.js +0 -15
- package/dist/app/accounts/sendEmailVerification.js +0 -65
- package/dist/app/accounts/setAuthenticationCookie.js +0 -11
- package/dist/app/accounts/setPassword.js +0 -45
- package/dist/app/accounts/unsetAuthenticationCookie.js +0 -11
- package/dist/app/accounts/verifyEmail.js +0 -46
- package/dist/app/databases/getTargetDatabase.js +0 -10
- package/dist/app/databases/getTargetDatabaseConnection.js +0 -19
- package/dist/app/databases/getTargetDatabaseProvider.js +0 -10
- package/dist/app/databases/mongodb/buildConnectionString.js +0 -22
- package/dist/app/databases/mongodb/buildQueryParameters.js +0 -14
- package/dist/app/databases/mongodb/index.js +0 -40
- package/dist/app/databases/mongodb/queries/accounts.js +0 -266
- package/dist/app/databases/mongodb/queries/queues.js +0 -111
- package/dist/app/databases/postgresql/addColumnToTable.js +0 -6
- package/dist/app/databases/postgresql/createAccountsIndexes.js +0 -21
- package/dist/app/databases/postgresql/createAccountsTables.js +0 -39
- package/dist/app/databases/postgresql/createDatabase.js +0 -0
- package/dist/app/databases/postgresql/index.js +0 -55
- package/dist/app/databases/postgresql/queries/accounts.js +0 -186
- package/dist/app/databases/postgresql/queries/queues.js +0 -211
- package/dist/app/databases/queryMap.js +0 -17
- package/dist/app/databases/typesMap.js +0 -7
- package/dist/app/getAPIContext.js +0 -25
- package/dist/app/getAPIURLComponent.js +0 -6
- package/dist/app/getBrowserSafeRequest.js +0 -14
- package/dist/app/getOutput.js +0 -74
- package/dist/app/handleProcessErrors.js +0 -73
- package/dist/app/index.test.js +0 -575
- package/dist/app/initExpress.js +0 -41
- package/dist/app/middleware/bodyParser.js +0 -16
- package/dist/app/middleware/hmr/client.js +0 -113
- package/dist/app/middleware/index.js +0 -89
- package/dist/app/middleware/render.js +0 -213
- package/dist/app/middleware/requestMethods.js +0 -19
- package/dist/app/registerGetters.js +0 -45
- package/dist/app/registerSetters.js +0 -45
- package/dist/app/runGetter.js +0 -103
- package/dist/app/runSetter.js +0 -103
- package/dist/app/runUploader.js +0 -143
- package/dist/app/sanitizeAPIResponse.js +0 -27
- package/dist/app/utils/process.js +0 -193
- package/dist/app/validateSession.js +0 -16
- package/dist/app/validateUploaderOptions.js +0 -53
- package/dist/app/validateUploads.js +0 -102
- package/dist/email/render.js +0 -50
- package/dist/email/send.js +0 -55
- package/dist/email/send.test.js +0 -37
- package/dist/email/templates/base.css +0 -194
- package/dist/email/templates/base.html +0 -28
- package/dist/email/templates/reset-password.js +0 -14
- package/dist/email/validateSMTPSettings.js +0 -27
- package/dist/lib/escapeHTML.js +0 -9
- package/dist/lib/escapeKeyValuePair.js +0 -13
- package/dist/lib/formatAPIError.js +0 -12
- package/dist/lib/formatErrorString.js +0 -8
- package/dist/lib/generateCookie.js +0 -14
- package/dist/lib/generateId.js +0 -13
- package/dist/lib/generateMachineId.js +0 -15
- package/dist/lib/getBuildPath.js +0 -10
- package/dist/lib/getErrorObject.js +0 -9
- package/dist/lib/getPlatformSafeFilePath.js +0 -8
- package/dist/lib/getPlatformSafePath.js +0 -8
- package/dist/lib/getSSLCertificates.js +0 -19
- package/dist/lib/isValidHTTPMethod.js +0 -7
- package/dist/lib/isValidJSONString.js +0 -11
- package/dist/lib/nodeUrlPolyfills.js +0 -14
- package/dist/lib/objectToSQLKeysString.js +0 -18
- package/dist/lib/objectToSQLValuesString.js +0 -16
- package/dist/lib/obscenedb/debounce.js +0 -12
- package/dist/lib/obscenedb/index.js +0 -61
- package/dist/lib/parseDatabasesFromEnvironment.js +0 -9
- package/dist/lib/rainbowRoad.js +0 -7
- package/dist/lib/readDirectory.js +0 -24
- package/dist/lib/replaceBackslashesWithForwardSlashes.js +0 -8
- package/dist/lib/replaceFileProtocol.js +0 -8
- package/dist/lib/replaceForwardSlashesWithBackslashes.js +0 -8
- package/dist/lib/serializeQueryParameters.js +0 -8
- package/dist/lib/serverAvailable.js +0 -0
- package/dist/lib/setCookie.js +0 -16
- package/dist/lib/supportedHTTPMethods.js +0 -4
- package/dist/lib/unsetCookie.js +0 -13
- package/dist/push/logs/index.js +0 -55
- package/dist/settings/index.js +0 -5
- package/dist/settings/load.js +0 -30
- package/dist/ssr/compileCSS.js +0 -85
- package/dist/ssr/findComponentInTree.js +0 -29
- package/dist/ssr/formatCSS.js +0 -6
- package/dist/ssr/getCSSFromTree.js +0 -33
- package/dist/ssr/index.js +0 -441
- package/dist/ssr/replaceWhenTags.js +0 -37
- package/dist/ssr/setHeadTagsInHTML.js +0 -84
- package/dist/validation/index.js +0 -10
- package/dist/validation/index.test.js +0 -463
- package/dist/validation/inputWithSchema/index.js +0 -105
- package/dist/validation/lib/constants.js +0 -162
- package/dist/validation/lib/getValueFromObject.js +0 -12
- package/dist/validation/lib/getValueFromObject.test.js +0 -7
- package/dist/validation/lib/isArrayPath.js +0 -6
- package/dist/validation/lib/throwError.js +0 -6
- package/dist/validation/lib/typeValidators.js +0 -38
- package/dist/validation/lib/validateType.js +0 -33
- package/dist/validation/schema/index.js +0 -44
- package/dist/websockets/emitWebsocketEvent.js +0 -12
- package/dist/websockets/index.js +0 -12
- package/notes +0 -1
package/dist/api/get.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import runGetter from "../app/runGetter.js";
|
|
2
|
-
var get_default = ({
|
|
3
|
-
getterName = "",
|
|
4
|
-
getterOptions = {},
|
|
5
|
-
input = null,
|
|
6
|
-
output = null,
|
|
7
|
-
context = {},
|
|
8
|
-
APIOptions = {}
|
|
9
|
-
}) => {
|
|
10
|
-
return new Promise((resolve, reject) => {
|
|
11
|
-
if (!getterOptions?.skip) {
|
|
12
|
-
runGetter({
|
|
13
|
-
getterName,
|
|
14
|
-
getterOptions,
|
|
15
|
-
input,
|
|
16
|
-
output,
|
|
17
|
-
APIOptions,
|
|
18
|
-
context
|
|
19
|
-
}).then((response) => {
|
|
20
|
-
return resolve(response);
|
|
21
|
-
}).catch((response) => {
|
|
22
|
-
return reject(JSON.stringify(response));
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
};
|
|
27
|
-
export {
|
|
28
|
-
get_default as default
|
|
29
|
-
};
|
package/dist/api/getOrigin.js
DELETED
package/dist/api/index.js
DELETED
package/dist/api/set.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import runSetter from "../app/runSetter.js";
|
|
2
|
-
var set_default = ({
|
|
3
|
-
setterName = "",
|
|
4
|
-
setterOptions = {},
|
|
5
|
-
input = null,
|
|
6
|
-
output = null,
|
|
7
|
-
context = {},
|
|
8
|
-
APIOptions = {}
|
|
9
|
-
}) => {
|
|
10
|
-
return new Promise((resolve, reject) => {
|
|
11
|
-
if (!setterOptions?.skip) {
|
|
12
|
-
runSetter({
|
|
13
|
-
setterName,
|
|
14
|
-
setterOptions,
|
|
15
|
-
input,
|
|
16
|
-
output,
|
|
17
|
-
APIOptions,
|
|
18
|
-
context
|
|
19
|
-
}).then((response) => {
|
|
20
|
-
return resolve(response);
|
|
21
|
-
}).catch((response) => {
|
|
22
|
-
return reject(JSON.stringify(response));
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
};
|
|
27
|
-
export {
|
|
28
|
-
set_default as default
|
|
29
|
-
};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import crypto from "crypto-extra";
|
|
2
|
-
import formatErrorString from "../../lib/formatErrorString";
|
|
3
|
-
import runUserQuery from "./runUserQuery";
|
|
4
|
-
const setTokenOnUser = (emailAddress = "", token = "") => {
|
|
5
|
-
try {
|
|
6
|
-
return runUserQuery("addPasswordResetToken", { emailAddress, token });
|
|
7
|
-
} catch (exception) {
|
|
8
|
-
reject(formatErrorString("generateResetToken.setTokenOnUser", exception));
|
|
9
|
-
}
|
|
10
|
-
};
|
|
11
|
-
const generateResetToken = async (options, { resolve, reject: reject2 }) => {
|
|
12
|
-
try {
|
|
13
|
-
if (!options.emailAddress) {
|
|
14
|
-
return reject2("Email address is required.");
|
|
15
|
-
}
|
|
16
|
-
const token = crypto.randomString(32);
|
|
17
|
-
await setTokenOnUser(options.emailAddress, token);
|
|
18
|
-
resolve(token);
|
|
19
|
-
} catch (exception) {
|
|
20
|
-
reject2(formatErrorString("generateResetToken", exception));
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
var generateResetToken_default = (options) => new Promise((resolve, reject2) => {
|
|
24
|
-
generateResetToken(options, { resolve, reject: reject2 });
|
|
25
|
-
});
|
|
26
|
-
export {
|
|
27
|
-
generateResetToken_default as default
|
|
28
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import dayjs from "dayjs";
|
|
2
|
-
import generateId from "../../lib/generateId";
|
|
3
|
-
if (process.env.NODE_ENV !== "test") {
|
|
4
|
-
const utc = await import("dayjs/plugin/utc");
|
|
5
|
-
dayjs.extend(utc.default);
|
|
6
|
-
}
|
|
7
|
-
var generateSession_default = () => {
|
|
8
|
-
return {
|
|
9
|
-
token: generateId(64),
|
|
10
|
-
tokenExpiresAt: dayjs().utc().add(30, "days").format()
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
export {
|
|
14
|
-
generateSession_default as default
|
|
15
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { isObject } from "../../validation/lib/typeValidators";
|
|
2
|
-
import escapeKeyValuePair from "../../lib/escapeKeyValuePair.js";
|
|
3
|
-
var getBrowserSafeUser_default = (user = null) => {
|
|
4
|
-
if (!user || !isObject(user)) {
|
|
5
|
-
return null;
|
|
6
|
-
}
|
|
7
|
-
const unsafeFields = [
|
|
8
|
-
"password",
|
|
9
|
-
"sessions",
|
|
10
|
-
"oauth"
|
|
11
|
-
];
|
|
12
|
-
const browserSafeUser = Object.entries(user).filter(([field]) => {
|
|
13
|
-
return !unsafeFields.includes(field);
|
|
14
|
-
}).reduce((fields, [field, value]) => {
|
|
15
|
-
if (!fields[field]) {
|
|
16
|
-
fields[field] = value;
|
|
17
|
-
return fields;
|
|
18
|
-
}
|
|
19
|
-
}, {});
|
|
20
|
-
return escapeKeyValuePair(browserSafeUser);
|
|
21
|
-
};
|
|
22
|
-
export {
|
|
23
|
-
getBrowserSafeUser_default as default
|
|
24
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import dayjs from "dayjs";
|
|
2
|
-
import unsetAuthenticationCookie from "./unsetAuthenticationCookie";
|
|
3
|
-
var hasLoginTokenExpired_default = async (res, token = null, tokenExpiresAt = null) => {
|
|
4
|
-
if (!token || !tokenExpiresAt) {
|
|
5
|
-
unsetAuthenticationCookie(res);
|
|
6
|
-
return true;
|
|
7
|
-
}
|
|
8
|
-
const _dayjs = process.env.NODE_ENV === "test" ? (await import("../../tests/mocks/dayjs")).default : null;
|
|
9
|
-
const hasExpired = process.env.NODE_ENV === "test" ? _dayjs().isAfter(_dayjs(tokenExpiresAt)) : dayjs().isAfter(dayjs(tokenExpiresAt));
|
|
10
|
-
if (hasExpired) {
|
|
11
|
-
unsetAuthenticationCookie(res);
|
|
12
|
-
return true;
|
|
13
|
-
}
|
|
14
|
-
return false;
|
|
15
|
-
};
|
|
16
|
-
export {
|
|
17
|
-
hasLoginTokenExpired_default as default
|
|
18
|
-
};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import generateResetToken from "./generateResetToken";
|
|
2
|
-
import sendEmail from "../../email/send";
|
|
3
|
-
import settings from "../../settings";
|
|
4
|
-
var recoverPassword_default = async (options = {}) => {
|
|
5
|
-
try {
|
|
6
|
-
const resetToken = await generateResetToken({
|
|
7
|
-
emailAddress: options.emailAddress
|
|
8
|
-
});
|
|
9
|
-
const domain = process.env.ROOT_URL || `http://localhost:${process.env.PORT}`;
|
|
10
|
-
const url = `${domain}/reset-password/${resetToken}`;
|
|
11
|
-
if (process.env.NODE_ENV === "development") {
|
|
12
|
-
console.log({ url });
|
|
13
|
-
}
|
|
14
|
-
await sendEmail({
|
|
15
|
-
to: options.emailAddress,
|
|
16
|
-
from: settings?.config?.email?.from,
|
|
17
|
-
subject: "Reset Your Password",
|
|
18
|
-
template: "reset-password",
|
|
19
|
-
props: {
|
|
20
|
-
emailAddress: options.emailAddress,
|
|
21
|
-
url
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
return true;
|
|
25
|
-
} catch (exception) {
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
export {
|
|
29
|
-
recoverPassword_default as default
|
|
30
|
-
};
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import hashString from "./hashString";
|
|
2
|
-
import runUserQuery from "./runUserQuery";
|
|
3
|
-
import generateSession from "./generateSession";
|
|
4
|
-
import getOutput from "../getOutput";
|
|
5
|
-
const deleteOldSessions = (userId = null) => {
|
|
6
|
-
try {
|
|
7
|
-
return runUserQuery("deleteOldSessions", { userId });
|
|
8
|
-
} catch (error) {
|
|
9
|
-
throw new Error(formatErrorString("resetPassword.deleteOldSessions", error));
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
const removeTokenFromUser = (userId = null, token = null) => {
|
|
13
|
-
try {
|
|
14
|
-
return runUserQuery("removeResetToken", { userId, token });
|
|
15
|
-
} catch (error) {
|
|
16
|
-
throw new Error(formatErrorString("resetPassword.removeTokenFromUser", error));
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
const addSessionToUser = (userId = null, session = null) => {
|
|
20
|
-
try {
|
|
21
|
-
return runUserQuery("addSession", { userId, session });
|
|
22
|
-
} catch (error) {
|
|
23
|
-
throw new Error(formatErrorString("resetPassword.addSessionToUser", error));
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
const setNewPasswordOnUser = async (userId = "", password = "") => {
|
|
27
|
-
try {
|
|
28
|
-
const hashedPassword = await hashString(password);
|
|
29
|
-
await runUserQuery("setNewPassword", { userId, hashedPassword });
|
|
30
|
-
return hashedPassword;
|
|
31
|
-
} catch (exception) {
|
|
32
|
-
throw new Error(`[resetPassword.setNewPasswordOnUser] ${exception.message}`);
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
const getUserWithToken = (token = "") => {
|
|
36
|
-
try {
|
|
37
|
-
return runUserQuery("userWithResetToken", {
|
|
38
|
-
"passwordResetTokens.token": token
|
|
39
|
-
});
|
|
40
|
-
} catch (exception) {
|
|
41
|
-
throw new Error(`[resetPassword.getUserWithToken] ${exception.message}`);
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
const resetPassword = async (options, { resolve, reject }) => {
|
|
45
|
-
try {
|
|
46
|
-
const user = await getUserWithToken(options.token);
|
|
47
|
-
if (!user) {
|
|
48
|
-
reject("Sorry, that token is invalid. Please try again.");
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
const hashedNewPassword = await setNewPasswordOnUser(user?._id || user?.user_id, options.password);
|
|
52
|
-
const updatedUser = await removeTokenFromUser(user?._id || user?.user_id, options.token);
|
|
53
|
-
await deleteOldSessions(user?._id || user?.user_id);
|
|
54
|
-
const session = await generateSession({
|
|
55
|
-
userId: updatedUser?._id || updatedUser?.user_id,
|
|
56
|
-
emailAddress: updatedUser?.emailAddress || updatedUser?.email_address,
|
|
57
|
-
password: hashedNewPassword
|
|
58
|
-
});
|
|
59
|
-
await addSessionToUser(updatedUser?._id || updatedUser?.user_id, session);
|
|
60
|
-
resolve({
|
|
61
|
-
user: getOutput(updatedUser, options?.output),
|
|
62
|
-
...session
|
|
63
|
-
});
|
|
64
|
-
} catch (exception) {
|
|
65
|
-
reject(`[resetPassword] ${exception.message}`);
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
var resetPassword_default = (options) => new Promise((resolve, reject) => {
|
|
69
|
-
resetPassword(options, { resolve, reject });
|
|
70
|
-
});
|
|
71
|
-
export {
|
|
72
|
-
resetPassword_default as default
|
|
73
|
-
};
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { jest } from "@jest/globals";
|
|
2
|
-
import { killPortProcess } from "kill-port-process";
|
|
3
|
-
import setAppSettingsForTest from "../../../tests/lib/setAppSettingsForTest";
|
|
4
|
-
import startTestDatabase from "../../../tests/lib/databases/start";
|
|
5
|
-
import stopTestDatabase from "../../../tests/lib/databases/stop";
|
|
6
|
-
import { beforeEach, expect, test } from "@jest/globals";
|
|
7
|
-
import roles from "./index";
|
|
8
|
-
import accounts from "../index";
|
|
9
|
-
jest.mock("../../../../node_modules/dayjs", () => {
|
|
10
|
-
const _dayjs = jest.requireActual("../../../../node_modules/dayjs");
|
|
11
|
-
const _utc = jest.requireActual("../../../../node_modules/dayjs/plugin/utc");
|
|
12
|
-
_dayjs.extend(_utc);
|
|
13
|
-
return () => _dayjs("2022-01-01T00:00:00.000Z");
|
|
14
|
-
});
|
|
15
|
-
setAppSettingsForTest({
|
|
16
|
-
"config": {
|
|
17
|
-
"databases": [
|
|
18
|
-
{
|
|
19
|
-
"provider": "mongodb",
|
|
20
|
-
"users": true,
|
|
21
|
-
"options": {}
|
|
22
|
-
}
|
|
23
|
-
],
|
|
24
|
-
"i18n": {
|
|
25
|
-
"defaultLanguage": "en-US"
|
|
26
|
-
},
|
|
27
|
-
"middleware": {},
|
|
28
|
-
"email": {
|
|
29
|
-
"from": "app@test.com",
|
|
30
|
-
"smtp": {
|
|
31
|
-
"host": "fake.email.com",
|
|
32
|
-
"port": 587,
|
|
33
|
-
"username": "test",
|
|
34
|
-
"password": "password"
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
"global": {},
|
|
39
|
-
"public": {},
|
|
40
|
-
"private": {}
|
|
41
|
-
});
|
|
42
|
-
global.joystick = {
|
|
43
|
-
settings: {
|
|
44
|
-
config: {
|
|
45
|
-
databases: [{
|
|
46
|
-
"provider": "mongodb",
|
|
47
|
-
"users": true,
|
|
48
|
-
"options": {}
|
|
49
|
-
}]
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
const app = (await import("../../index")).default;
|
|
54
|
-
let instance;
|
|
55
|
-
describe("app/accounts/roles/index.js", () => {
|
|
56
|
-
beforeAll(async () => {
|
|
57
|
-
process.env.PORT = 3600;
|
|
58
|
-
});
|
|
59
|
-
beforeEach(async () => {
|
|
60
|
-
instance = await app({});
|
|
61
|
-
});
|
|
62
|
-
afterEach(async () => {
|
|
63
|
-
if (instance?.server?.close && typeof instance.server.close === "function") {
|
|
64
|
-
instance.server.close();
|
|
65
|
-
}
|
|
66
|
-
await killPortProcess(process.env.PORT);
|
|
67
|
-
});
|
|
68
|
-
afterAll(async () => {
|
|
69
|
-
});
|
|
70
|
-
test("roles.add adds role to roles collection in database", async () => {
|
|
71
|
-
await roles.add("admin");
|
|
72
|
-
const roleExists = await process.databases.mongodb.collection("roles").findOne({ role: "admin" });
|
|
73
|
-
expect(!!roleExists).toBe(true);
|
|
74
|
-
});
|
|
75
|
-
test("roles.remove removes role from roles collection in database", async () => {
|
|
76
|
-
await roles.add("admin");
|
|
77
|
-
await roles.remove("admin");
|
|
78
|
-
const roleExists = await process.databases.mongodb.collection("roles").findOne({ role: "admin" });
|
|
79
|
-
expect(!!roleExists).toBe(false);
|
|
80
|
-
});
|
|
81
|
-
test("roles.list returns a list of roles in the roles collection in database", async () => {
|
|
82
|
-
await roles.add("admin");
|
|
83
|
-
await roles.add("manager");
|
|
84
|
-
await roles.add("employee");
|
|
85
|
-
const rolesInDatabase = await roles.list();
|
|
86
|
-
await roles.remove("admin");
|
|
87
|
-
await roles.remove("manager");
|
|
88
|
-
await roles.remove("employee");
|
|
89
|
-
expect(rolesInDatabase).toEqual(["admin", "manager", "employee"]);
|
|
90
|
-
});
|
|
91
|
-
test("roles.grant adds role to user in users collection in database", async () => {
|
|
92
|
-
await process.databases.mongodb.collection("users").deleteOne({ emailAddress: "test@test.com" });
|
|
93
|
-
const user = await accounts.signup({ emailAddress: "test@test.com", password: "password" });
|
|
94
|
-
await roles.grant(user?.userId, "admin");
|
|
95
|
-
await roles.grant(user?.userId, "rolethatdoesntexist");
|
|
96
|
-
const userAfterGrant = await process.databases.mongodb.collection("users").findOne({ _id: user?.userId });
|
|
97
|
-
const rolesCreated = await process.databases.mongodb.collection("roles").find().toArray();
|
|
98
|
-
expect(userAfterGrant?.roles?.includes("admin")).toBe(true);
|
|
99
|
-
expect(rolesCreated?.length).toBe(2);
|
|
100
|
-
});
|
|
101
|
-
test("roles.revoke removes role from user in users collection in database", async () => {
|
|
102
|
-
await process.databases.mongodb.collection("users").deleteOne({ emailAddress: "test@test.com" });
|
|
103
|
-
const user = await accounts.signup({ emailAddress: "test@test.com", password: "password" });
|
|
104
|
-
await roles.grant(user?.userId, "admin");
|
|
105
|
-
await roles.revoke(user?.userId, "admin");
|
|
106
|
-
const userAfterGrant = await process.databases.mongodb.collection("users").findOne({ _id: user?.userId });
|
|
107
|
-
expect(userAfterGrant?.roles?.includes("admin")).toBe(false);
|
|
108
|
-
});
|
|
109
|
-
test("roles.userHasRole returns true if user has role", async () => {
|
|
110
|
-
await process.databases.mongodb.collection("users").deleteOne({ emailAddress: "test@test.com" });
|
|
111
|
-
const user = await accounts.signup({ emailAddress: "test@test.com", password: "password" });
|
|
112
|
-
await roles.grant(user?.userId, "admin");
|
|
113
|
-
const userHasRole = await roles.userHasRole(user?.userId, "admin");
|
|
114
|
-
expect(userHasRole).toBe(true);
|
|
115
|
-
});
|
|
116
|
-
test("roles.userHasRole returns false if user does not have role", async () => {
|
|
117
|
-
await process.databases.mongodb.collection("users").deleteOne({ emailAddress: "test@test.com" });
|
|
118
|
-
const user = await accounts.signup({ emailAddress: "test@test.com", password: "password" });
|
|
119
|
-
await roles.grant(user?.userId, "admin");
|
|
120
|
-
const userHasRole = await roles.userHasRole(user?.userId, "manager");
|
|
121
|
-
expect(userHasRole).toBe(false);
|
|
122
|
-
});
|
|
123
|
-
});
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import queryMap from "../databases/queryMap";
|
|
2
|
-
import getTargetDatabaseConnection from "../databases/getTargetDatabaseConnection.js";
|
|
3
|
-
var runUserQuery_default = async (queryName = "", inputs = {}) => {
|
|
4
|
-
const usersDatabase = getTargetDatabaseConnection("users");
|
|
5
|
-
const queryMapForDatabase = usersDatabase && queryMap && queryMap[usersDatabase?.provider] && queryMap[usersDatabase?.provider]?.accounts;
|
|
6
|
-
const query = queryMapForDatabase && queryMapForDatabase[queryName];
|
|
7
|
-
if (usersDatabase?.connection && query) {
|
|
8
|
-
const response = await queryMapForDatabase[queryName](inputs, usersDatabase?.connection);
|
|
9
|
-
return Promise.resolve(response);
|
|
10
|
-
}
|
|
11
|
-
return null;
|
|
12
|
-
};
|
|
13
|
-
export {
|
|
14
|
-
runUserQuery_default as default
|
|
15
|
-
};
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import loadSettings from "../../settings/load";
|
|
2
|
-
import sendEmail from "../../email/send";
|
|
3
|
-
import runUserQuery from "./runUserQuery";
|
|
4
|
-
const sendVerificationEmail = (emailAddress = "", token = "") => {
|
|
5
|
-
try {
|
|
6
|
-
const settings = loadSettings();
|
|
7
|
-
return sendEmail({
|
|
8
|
-
to: emailAddress,
|
|
9
|
-
from: settings?.config?.email?.from,
|
|
10
|
-
subject: settings?.config?.email?.verify?.subject || "Verify your email address",
|
|
11
|
-
template: settings?.config?.email?.verify?.template || "verify-email",
|
|
12
|
-
props: {
|
|
13
|
-
emailAddress,
|
|
14
|
-
url: process.env.NODE_ENV === "development" ? `http://localhost:${process.env.PORT}/api/_accounts/verify-email?token=${token}` : `${process.env.ROOT_URL}/api/_accounts/verify-email?token=${token}`
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
} catch (exception) {
|
|
18
|
-
throw new Error(`[sendEmailVerification.sendVerificationEmail] ${exception.message}`);
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
const getEmailVerificationToken = (userId = "") => {
|
|
22
|
-
try {
|
|
23
|
-
return runUserQuery("createEmailVerificationToken", {
|
|
24
|
-
userId
|
|
25
|
-
});
|
|
26
|
-
} catch (exception) {
|
|
27
|
-
throw new Error(`[sendEmailVerification.getEmailVerificationToken] ${exception.message}`);
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
const getUser = (userId = "") => {
|
|
31
|
-
try {
|
|
32
|
-
return runUserQuery("user", { _id: userId });
|
|
33
|
-
} catch (exception) {
|
|
34
|
-
throw new Error(`[sendEmailVerification.getUser] ${exception.message}`);
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
const validateOptions = (options) => {
|
|
38
|
-
try {
|
|
39
|
-
if (!options)
|
|
40
|
-
throw new Error("options object is required.");
|
|
41
|
-
if (!options.userId)
|
|
42
|
-
throw new Error("options.userId is required.");
|
|
43
|
-
} catch (exception) {
|
|
44
|
-
throw new Error(`[sendEmailVerification.validateOptions] ${exception.message}`);
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
const sendEmailVerification = async (options, { resolve, reject }) => {
|
|
48
|
-
try {
|
|
49
|
-
validateOptions(options);
|
|
50
|
-
const user = await getUser(options?.userId);
|
|
51
|
-
if (!user?.emailVerified && !user?.emailVerifiedAt) {
|
|
52
|
-
const token = await getEmailVerificationToken(user?._id || user?.user_id);
|
|
53
|
-
await sendVerificationEmail(user?.emailAddress, token);
|
|
54
|
-
}
|
|
55
|
-
resolve();
|
|
56
|
-
} catch (exception) {
|
|
57
|
-
reject(`[sendEmailVerification] ${exception.message}`);
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
var sendEmailVerification_default = (options) => new Promise((resolve, reject) => {
|
|
61
|
-
sendEmailVerification(options, { resolve, reject });
|
|
62
|
-
});
|
|
63
|
-
export {
|
|
64
|
-
sendEmailVerification_default as default
|
|
65
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import generateCookie from "../../lib/generateCookie.js";
|
|
2
|
-
var setAuthenticationCookie_default = (res = null, authentication = null) => {
|
|
3
|
-
if (!res || !authentication)
|
|
4
|
-
return null;
|
|
5
|
-
res.cookie("joystickLoginToken", authentication.token, generateCookie(authentication.tokenExpiresAt));
|
|
6
|
-
res.cookie("joystickLoginTokenExpiresAt", authentication.tokenExpiresAt, generateCookie(authentication.tokenExpiresAt));
|
|
7
|
-
return res;
|
|
8
|
-
};
|
|
9
|
-
export {
|
|
10
|
-
setAuthenticationCookie_default as default
|
|
11
|
-
};
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import hashString from "./hashString";
|
|
2
|
-
import runUserQuery from "./runUserQuery";
|
|
3
|
-
const deleteOldSessions = (userId = null) => {
|
|
4
|
-
try {
|
|
5
|
-
return runUserQuery("deleteOldSessions", { userId });
|
|
6
|
-
} catch (error) {
|
|
7
|
-
throw new Error(formatErrorString("setPassword.deleteOldSessions", error));
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
const setNewPasswordOnUser = async (userId = "", password = "") => {
|
|
11
|
-
try {
|
|
12
|
-
const hashedPassword = await hashString(password);
|
|
13
|
-
await runUserQuery("setNewPassword", { userId, hashedPassword });
|
|
14
|
-
return hashedPassword;
|
|
15
|
-
} catch (exception) {
|
|
16
|
-
throw new Error(`[setPassword.setNewPasswordOnUser] ${exception.message}`);
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
const getUser = (userId = "") => {
|
|
20
|
-
try {
|
|
21
|
-
return runUserQuery("user", { _id: userId });
|
|
22
|
-
} catch (exception) {
|
|
23
|
-
throw new Error(`[setPassword.getUser] ${exception.message}`);
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
const setPassword = async (options, { resolve, reject }) => {
|
|
27
|
-
try {
|
|
28
|
-
const user = await getUser(options.userId);
|
|
29
|
-
if (!user) {
|
|
30
|
-
reject("Sorry, that userId is invalid. Please try again.");
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
await setNewPasswordOnUser(user?._id || user?.user_id, options.password);
|
|
34
|
-
await deleteOldSessions(user?._id || user?.user_id);
|
|
35
|
-
resolve();
|
|
36
|
-
} catch (exception) {
|
|
37
|
-
reject(`[setPassword] ${exception.message}`);
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
var setPassword_default = (options) => new Promise((resolve, reject) => {
|
|
41
|
-
setPassword(options, { resolve, reject });
|
|
42
|
-
});
|
|
43
|
-
export {
|
|
44
|
-
setPassword_default as default
|
|
45
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import unsetCookie from "../../lib/unsetCookie.js";
|
|
2
|
-
var unsetAuthenticationCookie_default = (res = null) => {
|
|
3
|
-
if (!res)
|
|
4
|
-
return null;
|
|
5
|
-
unsetCookie("joystickLoginToken", res);
|
|
6
|
-
unsetCookie("joystickLoginTokenExpiresAt", res);
|
|
7
|
-
return res;
|
|
8
|
-
};
|
|
9
|
-
export {
|
|
10
|
-
unsetAuthenticationCookie_default as default
|
|
11
|
-
};
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import runUserQuery from "./runUserQuery";
|
|
2
|
-
const markEmailVerifiedAt = (userId = "", token = "") => {
|
|
3
|
-
try {
|
|
4
|
-
return runUserQuery("markEmailVerifiedAt", { userId, token });
|
|
5
|
-
} catch (exception) {
|
|
6
|
-
throw new Error(`[actionName.markEmailVerifiedAt] ${exception.message}`);
|
|
7
|
-
}
|
|
8
|
-
};
|
|
9
|
-
const getUserFromToken = (verifyEmailToken = "") => {
|
|
10
|
-
try {
|
|
11
|
-
return runUserQuery("userWithVerifyEmailToken", {
|
|
12
|
-
token: verifyEmailToken
|
|
13
|
-
});
|
|
14
|
-
} catch (exception) {
|
|
15
|
-
throw new Error(`[verifyEmail.getUserFromToken] ${exception.message}`);
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
const validateOptions = (options) => {
|
|
19
|
-
try {
|
|
20
|
-
if (!options)
|
|
21
|
-
throw new Error("options object is required.");
|
|
22
|
-
if (!options.token)
|
|
23
|
-
throw new Error("options.token is required.");
|
|
24
|
-
} catch (exception) {
|
|
25
|
-
throw new Error(`[verifyEmail.validateOptions] ${exception.message}`);
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
const verifyEmail = async (options, { resolve, reject }) => {
|
|
29
|
-
try {
|
|
30
|
-
validateOptions(options);
|
|
31
|
-
const user = await getUserFromToken(options?.token);
|
|
32
|
-
if (!user) {
|
|
33
|
-
throw new Error(`A user with this token could not be found.`);
|
|
34
|
-
}
|
|
35
|
-
await markEmailVerifiedAt(user?._id || user?.user_id, options?.token);
|
|
36
|
-
resolve();
|
|
37
|
-
} catch (exception) {
|
|
38
|
-
reject(`[verifyEmail] ${exception.message}`);
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
var verifyEmail_default = (options) => new Promise((resolve, reject) => {
|
|
42
|
-
verifyEmail(options, { resolve, reject });
|
|
43
|
-
});
|
|
44
|
-
export {
|
|
45
|
-
verifyEmail_default as default
|
|
46
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import loadSettings from "../../settings/load";
|
|
2
|
-
var getTargetDatabase_default = (databaseType = "users") => {
|
|
3
|
-
const settings = loadSettings();
|
|
4
|
-
const databases = settings?.config?.databases || [];
|
|
5
|
-
const targetDatabase = databases.find((database) => !!database[databaseType]);
|
|
6
|
-
return targetDatabase && targetDatabase.provider;
|
|
7
|
-
};
|
|
8
|
-
export {
|
|
9
|
-
getTargetDatabase_default as default
|
|
10
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import loadSettings from "../../settings/load";
|
|
2
|
-
var getTargetDatabaseConnection_default = (databaseType = "users") => {
|
|
3
|
-
const settings = loadSettings();
|
|
4
|
-
const databases = settings?.config?.databases || [];
|
|
5
|
-
const targetDatabaseIndex = databases.findIndex((database) => !!database[databaseType]);
|
|
6
|
-
const targetDatabaseInSettings = databases[targetDatabaseIndex];
|
|
7
|
-
if (!targetDatabaseInSettings) {
|
|
8
|
-
return null;
|
|
9
|
-
}
|
|
10
|
-
const hasMultipleOfProvider = databases?.filter((database) => database?.provider === targetDatabaseInSettings?.provider)?.length > 1;
|
|
11
|
-
const databasePort = parseInt(process.env.PORT, 10) + 10 + targetDatabaseIndex;
|
|
12
|
-
return {
|
|
13
|
-
provider: targetDatabaseInSettings?.provider,
|
|
14
|
-
connection: !hasMultipleOfProvider ? process.databases[targetDatabaseInSettings?.provider] : process.databases[targetDatabaseInSettings?.provider][targetDatabaseInSettings?.name || `${targetDatabaseInSettings?.provider}_${databasePort}`]
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
export {
|
|
18
|
-
getTargetDatabaseConnection_default as default
|
|
19
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import loadSettings from "../../settings/load";
|
|
2
|
-
var getTargetDatabaseProvider_default = (databaseType = "users") => {
|
|
3
|
-
const settings = loadSettings();
|
|
4
|
-
const databases = settings?.config?.databases || [];
|
|
5
|
-
const targetDatabase = databases.find((database) => !!database[databaseType]);
|
|
6
|
-
return targetDatabase && targetDatabase.provider;
|
|
7
|
-
};
|
|
8
|
-
export {
|
|
9
|
-
getTargetDatabaseProvider_default as default
|
|
10
|
-
};
|