acebase-server 1.15.2 → 1.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +49 -0
- package/README.md +10 -0
- package/build-vars.js +16 -0
- package/dist/cjs/auth.js +2 -2
- package/dist/cjs/cluster.js +2 -2
- package/dist/cjs/middleware/cors.js +3 -3
- package/dist/cjs/oauth-providers/dropbox.js +22 -22
- package/dist/cjs/oauth-providers/facebook.js +16 -16
- package/dist/cjs/oauth-providers/google.js +33 -39
- package/dist/cjs/oauth-providers/index.js +1 -1
- package/dist/cjs/oauth-providers/instagram.js +12 -12
- package/dist/cjs/oauth-providers/oauth-provider.js +0 -5
- package/dist/cjs/oauth-providers/spotify.js +34 -34
- package/dist/cjs/routes/auth-change-password.js +5 -5
- package/dist/cjs/routes/auth-delete.js +1 -1
- package/dist/cjs/routes/auth-forgot-password.js +2 -2
- package/dist/cjs/routes/auth-reset-password.js +11 -9
- package/dist/cjs/routes/auth-signin.js +1 -1
- package/dist/cjs/routes/auth-signout.js +1 -1
- package/dist/cjs/routes/auth-signup.js +5 -5
- package/dist/cjs/routes/auth-update.js +1 -1
- package/dist/cjs/routes/auth-verify-email.js +8 -6
- package/dist/cjs/routes/auth.js +1 -1
- package/dist/cjs/routes/data-export.js +1 -1
- package/dist/cjs/routes/data-get.js +2 -2
- package/dist/cjs/routes/data-index-list.js +0 -1
- package/dist/cjs/routes/data-query.js +1 -1
- package/dist/cjs/routes/data-reflect.js +4 -4
- package/dist/cjs/routes/data-schema-get.js +1 -1
- package/dist/cjs/routes/data-schemas-list.js +1 -1
- package/dist/cjs/routes/data-transaction.js +1 -1
- package/dist/cjs/routes/docs.js +57 -54
- package/dist/cjs/routes/meta-info.js +6 -12
- package/dist/cjs/routes/meta-logs.js +1 -1
- package/dist/cjs/routes/oauth2-init.js +8 -5
- package/dist/cjs/routes/oauth2-refresh.js +2 -2
- package/dist/cjs/routes/oauth2-signin.js +23 -23
- package/dist/cjs/routes/webmanager.js +4 -4
- package/dist/cjs/rules.js +8 -8
- package/dist/cjs/schema/user.js +1 -2
- package/dist/cjs/server.js +74 -31
- package/dist/cjs/settings/email.js +0 -2
- package/dist/cjs/settings/index.js +19 -4
- package/dist/cjs/shared/email.js +0 -4
- package/dist/cjs/shared/env.js +0 -2
- package/dist/cjs/shared/error.js +0 -1
- package/dist/cjs/shared/http.js +9 -1
- package/dist/cjs/shared/password.js +5 -5
- package/dist/cjs/shared/rootpath.js +1 -1
- package/dist/cjs/shared/signin.js +3 -3
- package/dist/cjs/shared/simple-fetch.js +5 -5
- package/dist/cjs/shared/tokens.js +3 -3
- package/dist/cjs/start.js +6 -6
- package/dist/cjs/websocket/index.js +11 -11
- package/dist/cjs/websocket/socket.io.js +2 -1
- package/dist/esm/auth.js +5 -5
- package/dist/esm/cluster.js +2 -2
- package/dist/esm/middleware/admin-only.js +1 -1
- package/dist/esm/middleware/cors.js +3 -3
- package/dist/esm/middleware/user.js +3 -3
- package/dist/esm/oauth-providers/dropbox.js +47 -51
- package/dist/esm/oauth-providers/facebook.js +34 -38
- package/dist/esm/oauth-providers/google.js +33 -39
- package/dist/esm/oauth-providers/index.js +1 -1
- package/dist/esm/oauth-providers/instagram.js +28 -32
- package/dist/esm/oauth-providers/oauth-provider.js +0 -5
- package/dist/esm/oauth-providers/spotify.js +46 -52
- package/dist/esm/routes/auth-change-password.js +5 -5
- package/dist/esm/routes/auth-delete.js +1 -1
- package/dist/esm/routes/auth-forgot-password.js +2 -2
- package/dist/esm/routes/auth-reset-password.js +11 -9
- package/dist/esm/routes/auth-signin.js +1 -1
- package/dist/esm/routes/auth-signout.js +1 -1
- package/dist/esm/routes/auth-signup.js +5 -5
- package/dist/esm/routes/auth-update.js +1 -1
- package/dist/esm/routes/auth-verify-email.js +8 -6
- package/dist/esm/routes/auth.js +1 -1
- package/dist/esm/routes/data-export.js +1 -1
- package/dist/esm/routes/data-get.js +2 -2
- package/dist/esm/routes/data-index-list.js +0 -1
- package/dist/esm/routes/data-query.js +1 -1
- package/dist/esm/routes/data-reflect.js +4 -4
- package/dist/esm/routes/data-schema-get.js +1 -1
- package/dist/esm/routes/data-schemas-list.js +1 -1
- package/dist/esm/routes/data-transaction.js +1 -1
- package/dist/esm/routes/data.js +1 -1
- package/dist/esm/routes/docs.js +56 -54
- package/dist/esm/routes/meta-info.js +6 -12
- package/dist/esm/routes/meta-logs.js +1 -1
- package/dist/esm/routes/oauth2-init.js +8 -5
- package/dist/esm/routes/oauth2-refresh.js +2 -2
- package/dist/esm/routes/oauth2-signin.js +20 -20
- package/dist/esm/routes/webmanager.js +5 -5
- package/dist/esm/rules.js +8 -8
- package/dist/esm/schema/user.js +1 -2
- package/dist/esm/server.js +72 -30
- package/dist/esm/settings/email.js +0 -2
- package/dist/esm/settings/index.js +19 -4
- package/dist/esm/shared/email.js +0 -4
- package/dist/esm/shared/env.js +0 -2
- package/dist/esm/shared/error.js +0 -1
- package/dist/esm/shared/http.js +7 -0
- package/dist/esm/shared/password.js +5 -5
- package/dist/esm/shared/rootpath.js +2 -2
- package/dist/esm/shared/signin.js +6 -6
- package/dist/esm/shared/simple-fetch.js +5 -5
- package/dist/esm/shared/tokens.js +3 -3
- package/dist/esm/start.js +6 -6
- package/dist/esm/websocket/index.js +15 -15
- package/dist/esm/websocket/manager.js +1 -1
- package/dist/esm/websocket/socket.io.js +2 -1
- package/dist/types/auth.d.ts +1 -1
- package/dist/types/logger.d.ts +1 -1
- package/dist/types/middleware/404.d.ts +1 -1
- package/dist/types/middleware/admin-only.d.ts +3 -3
- package/dist/types/middleware/cache.d.ts +1 -1
- package/dist/types/middleware/context.d.ts +1 -1
- package/dist/types/middleware/cors.d.ts +1 -1
- package/dist/types/middleware/swagger.d.ts +1 -1
- package/dist/types/middleware/user.d.ts +1 -1
- package/dist/types/oauth-providers/dropbox.d.ts +1 -1
- package/dist/types/oauth-providers/facebook.d.ts +1 -1
- package/dist/types/oauth-providers/google.d.ts +1 -1
- package/dist/types/oauth-providers/instagram.d.ts +1 -1
- package/dist/types/oauth-providers/spotify.d.ts +1 -1
- package/dist/types/routes/auth-change-password.d.ts +2 -2
- package/dist/types/routes/auth-delete.d.ts +2 -2
- package/dist/types/routes/auth-forgot-password.d.ts +2 -2
- package/dist/types/routes/auth-reset-password.d.ts +2 -2
- package/dist/types/routes/auth-signin.d.ts +2 -2
- package/dist/types/routes/auth-signout.d.ts +2 -2
- package/dist/types/routes/auth-signup.d.ts +2 -2
- package/dist/types/routes/auth-state.d.ts +3 -3
- package/dist/types/routes/auth-update.d.ts +2 -2
- package/dist/types/routes/auth-verify-email.d.ts +2 -2
- package/dist/types/routes/data-exists.d.ts +1 -1
- package/dist/types/routes/data-export.d.ts +1 -1
- package/dist/types/routes/data-get.d.ts +1 -1
- package/dist/types/routes/data-import.d.ts +1 -1
- package/dist/types/routes/data-index-create.d.ts +2 -2
- package/dist/types/routes/data-index-delete.d.ts +1 -1
- package/dist/types/routes/data-index-list.d.ts +2 -2
- package/dist/types/routes/data-query.d.ts +1 -1
- package/dist/types/routes/data-reflect.d.ts +1 -1
- package/dist/types/routes/data-schema-get.d.ts +1 -1
- package/dist/types/routes/data-schema-set.d.ts +1 -1
- package/dist/types/routes/data-schema-test.d.ts +1 -1
- package/dist/types/routes/data-schemas-list.d.ts +1 -1
- package/dist/types/routes/data-set.d.ts +1 -1
- package/dist/types/routes/data-sync-changes.d.ts +1 -1
- package/dist/types/routes/data-sync-mutations.d.ts +1 -1
- package/dist/types/routes/data-transaction.d.ts +2 -2
- package/dist/types/routes/data-update.d.ts +1 -1
- package/dist/types/routes/data.d.ts +1 -1
- package/dist/types/routes/meta-info.d.ts +1 -1
- package/dist/types/routes/meta-logs.d.ts +1 -1
- package/dist/types/routes/meta-ping.d.ts +1 -1
- package/dist/types/routes/meta-stats.d.ts +1 -1
- package/dist/types/routes/oauth2-init.d.ts +1 -1
- package/dist/types/routes/oauth2-refresh.d.ts +1 -1
- package/dist/types/routes/oauth2-signin.d.ts +1 -1
- package/dist/types/routes/webmanager.d.ts +1 -1
- package/dist/types/schema/user.d.ts +2 -2
- package/dist/types/server.d.ts +3 -0
- package/dist/types/settings/index.d.ts +23 -0
- package/dist/types/shared/clients.d.ts +3 -3
- package/dist/types/shared/env.d.ts +2 -1
- package/dist/types/shared/http.d.ts +5 -0
- package/dist/types/shared/signin.d.ts +4 -4
- package/dist/types/shared/validate.d.ts +1 -1
- package/dist/types/websocket/index.d.ts +1 -1
- package/dist/types/websocket/manager.d.ts +1 -1
- package/img/acebase-swagger-ui.png +0 -0
- package/img/acebase-webmanager.png +0 -0
- package/package.json +12 -6
- package/src/routes/auth-signin.yaml +2 -2
- package/webmanager/acebase-client-browser.min.js +8 -11
- package/webmanager/index.html +1 -0
- package/webmanager/index.js +67 -71
- package/.vscode/launch.json +0 -24
- package/create-package-files +0 -25
- package/dist/cjs/auth.js.map +0 -1
- package/dist/cjs/cluster.js.map +0 -1
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/logger.js.map +0 -1
- package/dist/cjs/middleware/404.js.map +0 -1
- package/dist/cjs/middleware/admin-only.js.map +0 -1
- package/dist/cjs/middleware/cache.js.map +0 -1
- package/dist/cjs/middleware/connection.js.map +0 -1
- package/dist/cjs/middleware/context.js.map +0 -1
- package/dist/cjs/middleware/cors.js.map +0 -1
- package/dist/cjs/middleware/swagger.js.map +0 -1
- package/dist/cjs/middleware/user.js.map +0 -1
- package/dist/cjs/oauth-providers/dropbox.js.map +0 -1
- package/dist/cjs/oauth-providers/facebook.js.map +0 -1
- package/dist/cjs/oauth-providers/google.js.map +0 -1
- package/dist/cjs/oauth-providers/index.js.map +0 -1
- package/dist/cjs/oauth-providers/instagram.js.map +0 -1
- package/dist/cjs/oauth-providers/oauth-provider.js.map +0 -1
- package/dist/cjs/oauth-providers/spotify.js.map +0 -1
- package/dist/cjs/routes/auth-change-password.js.map +0 -1
- package/dist/cjs/routes/auth-delete.js.map +0 -1
- package/dist/cjs/routes/auth-forgot-password.js.map +0 -1
- package/dist/cjs/routes/auth-reset-password.js.map +0 -1
- package/dist/cjs/routes/auth-signin.js.map +0 -1
- package/dist/cjs/routes/auth-signout.js.map +0 -1
- package/dist/cjs/routes/auth-signup.js.map +0 -1
- package/dist/cjs/routes/auth-state.js.map +0 -1
- package/dist/cjs/routes/auth-update.js.map +0 -1
- package/dist/cjs/routes/auth-verify-email.js.map +0 -1
- package/dist/cjs/routes/auth.js.map +0 -1
- package/dist/cjs/routes/data-exists.js.map +0 -1
- package/dist/cjs/routes/data-export.js.map +0 -1
- package/dist/cjs/routes/data-get.js.map +0 -1
- package/dist/cjs/routes/data-import.js.map +0 -1
- package/dist/cjs/routes/data-index-create.js.map +0 -1
- package/dist/cjs/routes/data-index-delete.js.map +0 -1
- package/dist/cjs/routes/data-index-list.js.map +0 -1
- package/dist/cjs/routes/data-query.js.map +0 -1
- package/dist/cjs/routes/data-reflect.js.map +0 -1
- package/dist/cjs/routes/data-schema-get.js.map +0 -1
- package/dist/cjs/routes/data-schema-set.js.map +0 -1
- package/dist/cjs/routes/data-schema-test.js.map +0 -1
- package/dist/cjs/routes/data-schemas-list.js.map +0 -1
- package/dist/cjs/routes/data-set.js.map +0 -1
- package/dist/cjs/routes/data-sync-changes.js.map +0 -1
- package/dist/cjs/routes/data-sync-mutations.js.map +0 -1
- package/dist/cjs/routes/data-transaction.js.map +0 -1
- package/dist/cjs/routes/data-update.js.map +0 -1
- package/dist/cjs/routes/data.js.map +0 -1
- package/dist/cjs/routes/docs.js.map +0 -1
- package/dist/cjs/routes/meta-info.js.map +0 -1
- package/dist/cjs/routes/meta-logs.js.map +0 -1
- package/dist/cjs/routes/meta-ping.js.map +0 -1
- package/dist/cjs/routes/meta-stats.js.map +0 -1
- package/dist/cjs/routes/meta.js.map +0 -1
- package/dist/cjs/routes/oauth2-init.js.map +0 -1
- package/dist/cjs/routes/oauth2-refresh.js.map +0 -1
- package/dist/cjs/routes/oauth2-signin.js.map +0 -1
- package/dist/cjs/routes/webmanager.js.map +0 -1
- package/dist/cjs/rules.js.map +0 -1
- package/dist/cjs/schema/user.js.map +0 -1
- package/dist/cjs/server.js.map +0 -1
- package/dist/cjs/settings/email.js.map +0 -1
- package/dist/cjs/settings/index.js.map +0 -1
- package/dist/cjs/shared/clients.js.map +0 -1
- package/dist/cjs/shared/email.js.map +0 -1
- package/dist/cjs/shared/env.js.map +0 -1
- package/dist/cjs/shared/error.js.map +0 -1
- package/dist/cjs/shared/http.js.map +0 -1
- package/dist/cjs/shared/password.js.map +0 -1
- package/dist/cjs/shared/rootpath.js.map +0 -1
- package/dist/cjs/shared/signin.js.map +0 -1
- package/dist/cjs/shared/simple-fetch.js.map +0 -1
- package/dist/cjs/shared/tokens.js.map +0 -1
- package/dist/cjs/shared/validate.js.map +0 -1
- package/dist/cjs/start.js.map +0 -1
- package/dist/cjs/test.js.map +0 -1
- package/dist/cjs/websocket/index.js.map +0 -1
- package/dist/cjs/websocket/manager.js.map +0 -1
- package/dist/cjs/websocket/socket.io.js.map +0 -1
- package/dist/esm/auth.js.map +0 -1
- package/dist/esm/cluster.js.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/logger.js.map +0 -1
- package/dist/esm/middleware/404.js.map +0 -1
- package/dist/esm/middleware/admin-only.js.map +0 -1
- package/dist/esm/middleware/cache.js.map +0 -1
- package/dist/esm/middleware/connection.js.map +0 -1
- package/dist/esm/middleware/context.js.map +0 -1
- package/dist/esm/middleware/cors.js.map +0 -1
- package/dist/esm/middleware/swagger.js.map +0 -1
- package/dist/esm/middleware/user.js.map +0 -1
- package/dist/esm/oauth-providers/dropbox.js.map +0 -1
- package/dist/esm/oauth-providers/facebook.js.map +0 -1
- package/dist/esm/oauth-providers/google.js.map +0 -1
- package/dist/esm/oauth-providers/index.js.map +0 -1
- package/dist/esm/oauth-providers/instagram.js.map +0 -1
- package/dist/esm/oauth-providers/oauth-provider.js.map +0 -1
- package/dist/esm/oauth-providers/spotify.js.map +0 -1
- package/dist/esm/routes/auth-change-password.js.map +0 -1
- package/dist/esm/routes/auth-delete.js.map +0 -1
- package/dist/esm/routes/auth-forgot-password.js.map +0 -1
- package/dist/esm/routes/auth-reset-password.js.map +0 -1
- package/dist/esm/routes/auth-signin.js.map +0 -1
- package/dist/esm/routes/auth-signout.js.map +0 -1
- package/dist/esm/routes/auth-signup.js.map +0 -1
- package/dist/esm/routes/auth-state.js.map +0 -1
- package/dist/esm/routes/auth-update.js.map +0 -1
- package/dist/esm/routes/auth-verify-email.js.map +0 -1
- package/dist/esm/routes/auth.js.map +0 -1
- package/dist/esm/routes/data-exists.js.map +0 -1
- package/dist/esm/routes/data-export.js.map +0 -1
- package/dist/esm/routes/data-get.js.map +0 -1
- package/dist/esm/routes/data-import.js.map +0 -1
- package/dist/esm/routes/data-index-create.js.map +0 -1
- package/dist/esm/routes/data-index-delete.js.map +0 -1
- package/dist/esm/routes/data-index-list.js.map +0 -1
- package/dist/esm/routes/data-query.js.map +0 -1
- package/dist/esm/routes/data-reflect.js.map +0 -1
- package/dist/esm/routes/data-schema-get.js.map +0 -1
- package/dist/esm/routes/data-schema-set.js.map +0 -1
- package/dist/esm/routes/data-schema-test.js.map +0 -1
- package/dist/esm/routes/data-schemas-list.js.map +0 -1
- package/dist/esm/routes/data-set.js.map +0 -1
- package/dist/esm/routes/data-sync-changes.js.map +0 -1
- package/dist/esm/routes/data-sync-mutations.js.map +0 -1
- package/dist/esm/routes/data-transaction.js.map +0 -1
- package/dist/esm/routes/data-update.js.map +0 -1
- package/dist/esm/routes/data.js.map +0 -1
- package/dist/esm/routes/docs.js.map +0 -1
- package/dist/esm/routes/meta-info.js.map +0 -1
- package/dist/esm/routes/meta-logs.js.map +0 -1
- package/dist/esm/routes/meta-ping.js.map +0 -1
- package/dist/esm/routes/meta-stats.js.map +0 -1
- package/dist/esm/routes/meta.js.map +0 -1
- package/dist/esm/routes/oauth2-init.js.map +0 -1
- package/dist/esm/routes/oauth2-refresh.js.map +0 -1
- package/dist/esm/routes/oauth2-signin.js.map +0 -1
- package/dist/esm/routes/webmanager.js.map +0 -1
- package/dist/esm/rules.js.map +0 -1
- package/dist/esm/schema/user.js.map +0 -1
- package/dist/esm/server.js.map +0 -1
- package/dist/esm/settings/email.js.map +0 -1
- package/dist/esm/settings/index.js.map +0 -1
- package/dist/esm/shared/clients.js.map +0 -1
- package/dist/esm/shared/email.js.map +0 -1
- package/dist/esm/shared/env.js.map +0 -1
- package/dist/esm/shared/error.js.map +0 -1
- package/dist/esm/shared/http.js.map +0 -1
- package/dist/esm/shared/password.js.map +0 -1
- package/dist/esm/shared/rootpath.js.map +0 -1
- package/dist/esm/shared/signin.js.map +0 -1
- package/dist/esm/shared/simple-fetch.js.map +0 -1
- package/dist/esm/shared/tokens.js.map +0 -1
- package/dist/esm/shared/validate.js.map +0 -1
- package/dist/esm/start.js.map +0 -1
- package/dist/esm/test.js.map +0 -1
- package/dist/esm/websocket/index.js.map +0 -1
- package/dist/esm/websocket/manager.js.map +0 -1
- package/dist/esm/websocket/socket.io.js.map +0 -1
- package/dist/types/auth.d.ts.map +0 -1
- package/dist/types/cluster.d.ts.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/logger.d.ts.map +0 -1
- package/dist/types/middleware/404.d.ts.map +0 -1
- package/dist/types/middleware/admin-only.d.ts.map +0 -1
- package/dist/types/middleware/cache.d.ts.map +0 -1
- package/dist/types/middleware/connection.d.ts.map +0 -1
- package/dist/types/middleware/context.d.ts.map +0 -1
- package/dist/types/middleware/cors.d.ts.map +0 -1
- package/dist/types/middleware/swagger.d.ts.map +0 -1
- package/dist/types/middleware/user.d.ts.map +0 -1
- package/dist/types/oauth-providers/dropbox.d.ts.map +0 -1
- package/dist/types/oauth-providers/facebook.d.ts.map +0 -1
- package/dist/types/oauth-providers/google.d.ts.map +0 -1
- package/dist/types/oauth-providers/index.d.ts.map +0 -1
- package/dist/types/oauth-providers/instagram.d.ts.map +0 -1
- package/dist/types/oauth-providers/oauth-provider.d.ts.map +0 -1
- package/dist/types/oauth-providers/spotify.d.ts.map +0 -1
- package/dist/types/routes/auth-change-password.d.ts.map +0 -1
- package/dist/types/routes/auth-delete.d.ts.map +0 -1
- package/dist/types/routes/auth-forgot-password.d.ts.map +0 -1
- package/dist/types/routes/auth-reset-password.d.ts.map +0 -1
- package/dist/types/routes/auth-signin.d.ts.map +0 -1
- package/dist/types/routes/auth-signout.d.ts.map +0 -1
- package/dist/types/routes/auth-signup.d.ts.map +0 -1
- package/dist/types/routes/auth-state.d.ts.map +0 -1
- package/dist/types/routes/auth-update.d.ts.map +0 -1
- package/dist/types/routes/auth-verify-email.d.ts.map +0 -1
- package/dist/types/routes/auth.d.ts.map +0 -1
- package/dist/types/routes/data-exists.d.ts.map +0 -1
- package/dist/types/routes/data-export.d.ts.map +0 -1
- package/dist/types/routes/data-get.d.ts.map +0 -1
- package/dist/types/routes/data-import.d.ts.map +0 -1
- package/dist/types/routes/data-index-create.d.ts.map +0 -1
- package/dist/types/routes/data-index-delete.d.ts.map +0 -1
- package/dist/types/routes/data-index-list.d.ts.map +0 -1
- package/dist/types/routes/data-query.d.ts.map +0 -1
- package/dist/types/routes/data-reflect.d.ts.map +0 -1
- package/dist/types/routes/data-schema-get.d.ts.map +0 -1
- package/dist/types/routes/data-schema-set.d.ts.map +0 -1
- package/dist/types/routes/data-schema-test.d.ts.map +0 -1
- package/dist/types/routes/data-schemas-list.d.ts.map +0 -1
- package/dist/types/routes/data-set.d.ts.map +0 -1
- package/dist/types/routes/data-sync-changes.d.ts.map +0 -1
- package/dist/types/routes/data-sync-mutations.d.ts.map +0 -1
- package/dist/types/routes/data-transaction.d.ts.map +0 -1
- package/dist/types/routes/data-update.d.ts.map +0 -1
- package/dist/types/routes/data.d.ts.map +0 -1
- package/dist/types/routes/docs.d.ts.map +0 -1
- package/dist/types/routes/meta-info.d.ts.map +0 -1
- package/dist/types/routes/meta-logs.d.ts.map +0 -1
- package/dist/types/routes/meta-ping.d.ts.map +0 -1
- package/dist/types/routes/meta-stats.d.ts.map +0 -1
- package/dist/types/routes/meta.d.ts.map +0 -1
- package/dist/types/routes/oauth2-init.d.ts.map +0 -1
- package/dist/types/routes/oauth2-refresh.d.ts.map +0 -1
- package/dist/types/routes/oauth2-signin.d.ts.map +0 -1
- package/dist/types/routes/webmanager.d.ts.map +0 -1
- package/dist/types/rules.d.ts.map +0 -1
- package/dist/types/schema/user.d.ts.map +0 -1
- package/dist/types/server.d.ts.map +0 -1
- package/dist/types/settings/email.d.ts.map +0 -1
- package/dist/types/settings/index.d.ts.map +0 -1
- package/dist/types/shared/clients.d.ts.map +0 -1
- package/dist/types/shared/email.d.ts.map +0 -1
- package/dist/types/shared/env.d.ts.map +0 -1
- package/dist/types/shared/error.d.ts.map +0 -1
- package/dist/types/shared/http.d.ts.map +0 -1
- package/dist/types/shared/password.d.ts.map +0 -1
- package/dist/types/shared/rootpath.d.ts.map +0 -1
- package/dist/types/shared/signin.d.ts.map +0 -1
- package/dist/types/shared/simple-fetch.d.ts.map +0 -1
- package/dist/types/shared/tokens.d.ts.map +0 -1
- package/dist/types/shared/validate.d.ts.map +0 -1
- package/dist/types/start.d.ts.map +0 -1
- package/dist/types/test.d.ts.map +0 -1
- package/dist/types/websocket/index.d.ts.map +0 -1
- package/dist/types/websocket/manager.d.ts.map +0 -1
- package/dist/types/websocket/socket.io.d.ts.map +0 -1
- package/src/auth.ts +0 -87
- package/src/cluster.ts +0 -62
- package/src/index.ts +0 -4
- package/src/logger.ts +0 -56
- package/src/middleware/404.ts +0 -13
- package/src/middleware/admin-only.ts +0 -29
- package/src/middleware/cache.ts +0 -15
- package/src/middleware/connection.ts +0 -48
- package/src/middleware/context.ts +0 -23
- package/src/middleware/cors.ts +0 -49
- package/src/middleware/swagger.ts +0 -19
- package/src/middleware/user.ts +0 -51
- package/src/oauth-providers/dropbox.ts +0 -144
- package/src/oauth-providers/facebook.ts +0 -103
- package/src/oauth-providers/google.ts +0 -147
- package/src/oauth-providers/index.ts +0 -21
- package/src/oauth-providers/instagram.ts +0 -98
- package/src/oauth-providers/oauth-provider.ts +0 -65
- package/src/oauth-providers/spotify.ts +0 -127
- package/src/placeholder.d.ts +0 -12
- package/src/routes/auth-change-password.ts +0 -92
- package/src/routes/auth-delete.ts +0 -49
- package/src/routes/auth-forgot-password.ts +0 -77
- package/src/routes/auth-reset-password.ts +0 -96
- package/src/routes/auth-signin.ts +0 -55
- package/src/routes/auth-signout.ts +0 -64
- package/src/routes/auth-signup.ts +0 -164
- package/src/routes/auth-state.ts +0 -20
- package/src/routes/auth-update.ts +0 -149
- package/src/routes/auth-verify-email.ts +0 -75
- package/src/routes/auth.ts +0 -67
- package/src/routes/data-exists.ts +0 -31
- package/src/routes/data-export.ts +0 -51
- package/src/routes/data-get.ts +0 -67
- package/src/routes/data-import.ts +0 -56
- package/src/routes/data-index-create.ts +0 -82
- package/src/routes/data-index-delete.ts +0 -36
- package/src/routes/data-index-list.ts +0 -39
- package/src/routes/data-query.ts +0 -97
- package/src/routes/data-reflect.ts +0 -91
- package/src/routes/data-schema-get.ts +0 -36
- package/src/routes/data-schema-set.ts +0 -35
- package/src/routes/data-schema-test.ts +0 -48
- package/src/routes/data-schemas-list.ts +0 -31
- package/src/routes/data-set.ts +0 -83
- package/src/routes/data-sync-changes.ts +0 -77
- package/src/routes/data-sync-mutations.ts +0 -77
- package/src/routes/data-transaction.ts +0 -166
- package/src/routes/data-update.ts +0 -84
- package/src/routes/data.ts +0 -79
- package/src/routes/docs.ts +0 -249
- package/src/routes/meta-info.ts +0 -80
- package/src/routes/meta-logs.ts +0 -57
- package/src/routes/meta-ping.ts +0 -15
- package/src/routes/meta-stats.ts +0 -31
- package/src/routes/meta.ts +0 -22
- package/src/routes/oauth2-init.ts +0 -44
- package/src/routes/oauth2-refresh.ts +0 -39
- package/src/routes/oauth2-signin.ts +0 -286
- package/src/routes/webmanager.ts +0 -29
- package/src/rules.ts +0 -189
- package/src/schema/user.ts +0 -99
- package/src/server.ts +0 -419
- package/src/settings/email.ts +0 -18
- package/src/settings/index.ts +0 -241
- package/src/shared/clients.ts +0 -31
- package/src/shared/email.ts +0 -33
- package/src/shared/env.ts +0 -38
- package/src/shared/error.ts +0 -37
- package/src/shared/http.ts +0 -26
- package/src/shared/password.ts +0 -41
- package/src/shared/rootpath.ts +0 -17
- package/src/shared/signin.ts +0 -149
- package/src/shared/simple-fetch.ts +0 -65
- package/src/shared/tokens.ts +0 -77
- package/src/shared/validate.ts +0 -53
- package/src/start.ts +0 -48
- package/src/test.ts +0 -10
- package/src/websocket/index.ts +0 -336
- package/src/websocket/manager.ts +0 -46
- package/src/websocket/socket.io.ts +0 -90
- package/tsconfig-cjs.json +0 -11
- package/tsconfig.json +0 -22
package/dist/esm/server.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ColorStyle, DebugLogger, SimpleEventEmitter } from 'acebase-core';
|
|
2
2
|
import { AceBaseServerConfig } from './settings/index.js';
|
|
3
|
-
import { createApp } from './shared/http.js';
|
|
3
|
+
import { createApp, createRouter } from './shared/http.js';
|
|
4
4
|
import { addWebsocketServer } from './websocket/index.js';
|
|
5
5
|
import { AceBase } from 'acebase';
|
|
6
6
|
import { createServer } from 'http';
|
|
@@ -12,16 +12,17 @@ import addCorsMiddleware from './middleware/cors.js';
|
|
|
12
12
|
import addAuthenticionRoutes from './routes/auth.js';
|
|
13
13
|
import setupAuthentication from './auth.js';
|
|
14
14
|
import addDataRoutes from './routes/data.js';
|
|
15
|
-
import addDocsRoute from './routes/docs.js';
|
|
16
15
|
import addWebManagerRoutes from './routes/webmanager.js';
|
|
17
16
|
import addMetadataRoutes from './routes/meta.js';
|
|
18
|
-
import addSwaggerMiddleware from './middleware/swagger.js';
|
|
19
17
|
import addCacheMiddleware from './middleware/cache.js';
|
|
20
18
|
import { DatabaseLog } from './logger.js';
|
|
21
19
|
// type PrivateLocalSettings = AceBaseLocalSettings & { storage: PrivateStorageSettings };
|
|
22
20
|
export class AceBaseServerNotReadyError extends Error {
|
|
23
21
|
constructor() { super('Server is not ready yet'); }
|
|
24
22
|
}
|
|
23
|
+
export class AceBaseExternalServerError extends Error {
|
|
24
|
+
constructor() { super('This method is not available with an external server'); }
|
|
25
|
+
}
|
|
25
26
|
export class AceBaseServer extends SimpleEventEmitter {
|
|
26
27
|
constructor(dbname, options) {
|
|
27
28
|
super();
|
|
@@ -49,6 +50,8 @@ export class AceBaseServer extends SimpleEventEmitter {
|
|
|
49
50
|
},
|
|
50
51
|
transactions: this.config.transactions,
|
|
51
52
|
ipc: this.config.ipc,
|
|
53
|
+
sponsor: this.config.sponsor,
|
|
54
|
+
logColors: this.config.logColors,
|
|
52
55
|
};
|
|
53
56
|
this.db = new AceBase(dbname, dbOptions);
|
|
54
57
|
const otherDbsPath = `${this.config.path}/${this.db.name}.acebase`;
|
|
@@ -83,7 +86,7 @@ export class AceBaseServer extends SimpleEventEmitter {
|
|
|
83
86
|
* Gets the url the server is running at
|
|
84
87
|
*/
|
|
85
88
|
get url() {
|
|
86
|
-
return `http${this.config.https.enabled ? 's' : ''}://${this.config.host}:${this.config.port}`;
|
|
89
|
+
return `http${this.config.https.enabled ? 's' : ''}://${this.config.host}:${this.config.port}/${this.config.rootPath}`;
|
|
87
90
|
}
|
|
88
91
|
async init(env) {
|
|
89
92
|
const config = this.config;
|
|
@@ -92,11 +95,12 @@ export class AceBaseServer extends SimpleEventEmitter {
|
|
|
92
95
|
// Wait for databases to be ready to use
|
|
93
96
|
await Promise.all([
|
|
94
97
|
db.ready(),
|
|
95
|
-
authDb?.ready()
|
|
98
|
+
authDb?.ready(),
|
|
96
99
|
]);
|
|
97
100
|
// Create http server
|
|
98
101
|
const app = this.app;
|
|
99
|
-
|
|
102
|
+
this.config.server?.on('request', app);
|
|
103
|
+
const server = this.config.server || (config.https.enabled ? createSecureServer(config.https, app) : createServer(app));
|
|
100
104
|
const clients = new Map();
|
|
101
105
|
const securityRef = authDb ? authDb === db ? db.ref('__auth__/security') : authDb.ref('security') : null;
|
|
102
106
|
const authRef = authDb ? authDb === db ? db.ref('__auth__/accounts') : authDb.ref('accounts') : null;
|
|
@@ -105,12 +109,14 @@ export class AceBaseServer extends SimpleEventEmitter {
|
|
|
105
109
|
// Setup rules
|
|
106
110
|
const rulesFilePath = `${this.config.path}/${this.db.name}.acebase/rules.json`;
|
|
107
111
|
const rules = new PathBasedRules(rulesFilePath, config.auth.defaultAccessRule, { db, debug: this.debug, authEnabled: this.config.auth.enabled });
|
|
112
|
+
const router = createRouter();
|
|
108
113
|
const routeEnv = {
|
|
109
114
|
config: this.config,
|
|
110
115
|
server,
|
|
111
116
|
db: db,
|
|
112
117
|
authDb,
|
|
113
|
-
app,
|
|
118
|
+
app: router,
|
|
119
|
+
rootPath: this.config.rootPath,
|
|
114
120
|
debug: this.debug,
|
|
115
121
|
securityRef,
|
|
116
122
|
authRef,
|
|
@@ -119,7 +125,7 @@ export class AceBaseServer extends SimpleEventEmitter {
|
|
|
119
125
|
clients,
|
|
120
126
|
authCache: null,
|
|
121
127
|
authProviders: this.authProviders,
|
|
122
|
-
rules
|
|
128
|
+
rules,
|
|
123
129
|
};
|
|
124
130
|
// Add connection middleware
|
|
125
131
|
const killConnections = addConnectionMiddleware(routeEnv);
|
|
@@ -138,10 +144,10 @@ export class AceBaseServer extends SimpleEventEmitter {
|
|
|
138
144
|
// Add metadata endpoints
|
|
139
145
|
addMetadataRoutes(routeEnv);
|
|
140
146
|
// If environment is development, add API docs
|
|
141
|
-
if (process.env.NODE_ENV
|
|
147
|
+
if (process.env.NODE_ENV && process.env.NODE_ENV.trim() === 'development') {
|
|
142
148
|
this.debug.warn('DEVELOPMENT MODE: adding API docs endpoint at /docs');
|
|
143
|
-
|
|
144
|
-
|
|
149
|
+
(await import('./routes/docs.js')).addRoute(routeEnv);
|
|
150
|
+
(await import('./middleware/swagger.js')).addMiddleware(routeEnv);
|
|
145
151
|
}
|
|
146
152
|
// Add data endpoints
|
|
147
153
|
addDataRoutes(routeEnv);
|
|
@@ -155,19 +161,26 @@ export class AceBaseServer extends SimpleEventEmitter {
|
|
|
155
161
|
};
|
|
156
162
|
// Create websocket server
|
|
157
163
|
addWebsocketServer(routeEnv);
|
|
164
|
+
// Register all the routes for the app
|
|
165
|
+
app.use(`/${this.config.rootPath}`, router);
|
|
158
166
|
// Last but not least, add 404 handler
|
|
159
167
|
// DISABLED because it causes server extension routes through server.extend (see above) not be be executed
|
|
160
168
|
// add404Middleware(routeEnv);
|
|
161
|
-
// Start listening
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
169
|
+
// Start listening, if no external server
|
|
170
|
+
if (!this.config.server) {
|
|
171
|
+
server.listen(config.port, config.host, () => {
|
|
172
|
+
// Ready!!
|
|
173
|
+
this.debug.log(`"${db.name}" database server running at ${this.url}`);
|
|
174
|
+
this._ready = true;
|
|
175
|
+
this.emitOnce(`ready`);
|
|
176
|
+
});
|
|
177
|
+
}
|
|
168
178
|
// Setup pause and resume methods
|
|
169
179
|
let paused = false;
|
|
170
180
|
this.pause = async () => {
|
|
181
|
+
if (this.config.server) {
|
|
182
|
+
throw new AceBaseExternalServerError();
|
|
183
|
+
}
|
|
171
184
|
if (paused) {
|
|
172
185
|
throw new Error('Server is already paused');
|
|
173
186
|
}
|
|
@@ -177,6 +190,9 @@ export class AceBaseServer extends SimpleEventEmitter {
|
|
|
177
190
|
paused = true;
|
|
178
191
|
};
|
|
179
192
|
this.resume = async () => {
|
|
193
|
+
if (this.config.server) {
|
|
194
|
+
throw new AceBaseExternalServerError();
|
|
195
|
+
}
|
|
180
196
|
if (!paused) {
|
|
181
197
|
throw new Error('Server is not paused');
|
|
182
198
|
}
|
|
@@ -215,36 +231,35 @@ export class AceBaseServer extends SimpleEventEmitter {
|
|
|
215
231
|
// interval.unref();
|
|
216
232
|
server.close(err => {
|
|
217
233
|
if (err) {
|
|
218
|
-
|
|
234
|
+
this.debug.error(`server.close() error: ${err.message}`);
|
|
219
235
|
}
|
|
220
236
|
else {
|
|
221
|
-
|
|
237
|
+
this.debug.log(`server.close() success`);
|
|
222
238
|
}
|
|
223
239
|
resolve();
|
|
224
240
|
});
|
|
225
241
|
// If for some reason connection aren't broken in time - do proceed with shutdown sequence
|
|
226
242
|
const timeout = setTimeout(() => {
|
|
227
|
-
|
|
243
|
+
if (clients.size === 0) {
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
this.debug.warn(`server.close() timed out, there are still open connections`);
|
|
228
247
|
killConnections();
|
|
229
|
-
// resolve();
|
|
230
248
|
}, 5000);
|
|
231
249
|
timeout.unref();
|
|
232
|
-
|
|
250
|
+
this.debug.log(`Closing ${clients.size} websocket connections`);
|
|
233
251
|
clients.forEach((client, id) => {
|
|
234
252
|
const socket = client.socket;
|
|
235
253
|
socket.once('disconnect', reason => {
|
|
236
|
-
|
|
254
|
+
this.debug.log(`Socket ${socket.id} disconnected: ${reason}`);
|
|
237
255
|
});
|
|
238
256
|
socket.disconnect(true);
|
|
239
257
|
});
|
|
240
|
-
// clients.list.slice().forEach(client => {
|
|
241
|
-
// client.socket.disconnect(true);
|
|
242
|
-
// });
|
|
243
258
|
});
|
|
244
259
|
this.debug.warn('closing database');
|
|
245
260
|
await db.close();
|
|
246
261
|
this.debug.warn('shutdown complete');
|
|
247
|
-
// Emit events to let the outside world know we shut down.
|
|
262
|
+
// Emit events to let the outside world know we shut down.
|
|
248
263
|
// This is especially important if this instance was running in a Node.js cluster: the process will
|
|
249
264
|
// not exit automatically after this shutdown because Node.js' IPC channel between worker and master is still open.
|
|
250
265
|
// By sending these events, the cluster manager can determine if it should (and when to) execute process.exit()
|
|
@@ -258,8 +273,35 @@ export class AceBaseServer extends SimpleEventEmitter {
|
|
|
258
273
|
}
|
|
259
274
|
this.emit('shutdown'); // Emit on AceBaseServer instance
|
|
260
275
|
};
|
|
261
|
-
this.shutdown = async () =>
|
|
262
|
-
|
|
276
|
+
this.shutdown = async () => {
|
|
277
|
+
if (this.config.server) {
|
|
278
|
+
throw new AceBaseExternalServerError();
|
|
279
|
+
}
|
|
280
|
+
await shutdown({ sigint: false });
|
|
281
|
+
};
|
|
282
|
+
// Offload shutdown control to an external server
|
|
283
|
+
if (this.config.server) {
|
|
284
|
+
server.on('close', function close() {
|
|
285
|
+
server.off('request', app);
|
|
286
|
+
server.off('close', close);
|
|
287
|
+
shutdown({ sigint: false });
|
|
288
|
+
});
|
|
289
|
+
const ready = () => {
|
|
290
|
+
this.debug.log(`"${db.name}" database server running at ${this.url}`);
|
|
291
|
+
this._ready = true;
|
|
292
|
+
this.emitOnce(`ready`);
|
|
293
|
+
server.off('listening', ready);
|
|
294
|
+
};
|
|
295
|
+
if (server.listening) {
|
|
296
|
+
ready();
|
|
297
|
+
}
|
|
298
|
+
else {
|
|
299
|
+
server.on('listening', ready);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
else {
|
|
303
|
+
process.on('SIGINT', () => shutdown({ sigint: true }));
|
|
304
|
+
}
|
|
263
305
|
}
|
|
264
306
|
/**
|
|
265
307
|
* Reset a user's password. This can also be done using the auth/reset_password API endpoint
|
|
@@ -2,7 +2,7 @@ import { readFileSync } from 'fs';
|
|
|
2
2
|
export class AceBaseServerHttpsConfig {
|
|
3
3
|
constructor(settings) {
|
|
4
4
|
this.enabled = true;
|
|
5
|
-
this.enabled = typeof settings ===
|
|
5
|
+
this.enabled = typeof settings === 'object' && settings.enabled !== false;
|
|
6
6
|
if (!this.enabled) {
|
|
7
7
|
return;
|
|
8
8
|
}
|
|
@@ -19,7 +19,7 @@ export class AceBaseServerHttpsConfig {
|
|
|
19
19
|
export const AUTH_ACCESS_DEFAULT = {
|
|
20
20
|
DENY_ALL: 'deny',
|
|
21
21
|
ALLOW_ALL: 'allow',
|
|
22
|
-
ALLOW_AUTHENTICATED: 'auth'
|
|
22
|
+
ALLOW_AUTHENTICATED: 'auth',
|
|
23
23
|
};
|
|
24
24
|
export class AceBaseServerAuthenticationSettings {
|
|
25
25
|
constructor(settings) {
|
|
@@ -47,7 +47,7 @@ export class AceBaseServerAuthenticationSettings {
|
|
|
47
47
|
* Whether to use a separate database for auth and logging. 'v2' will store data in auth.db, which is NOT TESTED YET!
|
|
48
48
|
*/
|
|
49
49
|
this.separateDb = false;
|
|
50
|
-
if (typeof settings !==
|
|
50
|
+
if (typeof settings !== 'object') {
|
|
51
51
|
settings = {};
|
|
52
52
|
}
|
|
53
53
|
if (typeof settings.enabled === 'boolean') {
|
|
@@ -115,7 +115,10 @@ export class AceBaseServerConfig {
|
|
|
115
115
|
this.path = '.';
|
|
116
116
|
this.maxPayloadSize = '10mb';
|
|
117
117
|
this.allowOrigin = '*';
|
|
118
|
-
|
|
118
|
+
this.rootPath = '';
|
|
119
|
+
this.sponsor = false;
|
|
120
|
+
this.logColors = true;
|
|
121
|
+
if (typeof settings !== 'object') {
|
|
119
122
|
settings = {};
|
|
120
123
|
}
|
|
121
124
|
if (typeof settings.logLevel === 'string') {
|
|
@@ -130,6 +133,12 @@ export class AceBaseServerConfig {
|
|
|
130
133
|
if (typeof settings.path === 'string') {
|
|
131
134
|
this.path = settings.path;
|
|
132
135
|
}
|
|
136
|
+
if (typeof settings.server === 'object') {
|
|
137
|
+
this.server = settings.server;
|
|
138
|
+
}
|
|
139
|
+
if (typeof settings.rootPath === 'string') {
|
|
140
|
+
this.rootPath = settings.rootPath.replace(/^\/|\/$/g, '');
|
|
141
|
+
}
|
|
133
142
|
this.https = new AceBaseServerHttpsConfig(settings.https);
|
|
134
143
|
this.auth = new AceBaseServerAuthenticationSettings(settings.authentication);
|
|
135
144
|
if (typeof settings.maxPayloadSize === 'string') {
|
|
@@ -146,6 +155,12 @@ export class AceBaseServerConfig {
|
|
|
146
155
|
if (typeof settings.storage === 'object') {
|
|
147
156
|
this.storage = settings.storage;
|
|
148
157
|
}
|
|
158
|
+
if (typeof settings.sponsor === 'boolean') {
|
|
159
|
+
this.sponsor = settings.sponsor;
|
|
160
|
+
}
|
|
161
|
+
if (typeof settings.logColors === 'boolean') {
|
|
162
|
+
this.logColors = settings.logColors;
|
|
163
|
+
}
|
|
149
164
|
}
|
|
150
165
|
}
|
|
151
166
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/shared/email.js
CHANGED
package/dist/esm/shared/env.js
CHANGED
package/dist/esm/shared/error.js
CHANGED
|
@@ -8,7 +8,6 @@ export const sendUnauthorizedError = (res, code, message) => {
|
|
|
8
8
|
res.statusMessage = 'Unauthorized';
|
|
9
9
|
res.contentType('application/json').send({ code, message });
|
|
10
10
|
};
|
|
11
|
-
;
|
|
12
11
|
export const sendError = (res, err) => {
|
|
13
12
|
res.contentType('application/json');
|
|
14
13
|
if (typeof err.code === 'string') {
|
package/dist/esm/shared/http.js
CHANGED
|
@@ -13,4 +13,11 @@ export const createApp = (settings) => {
|
|
|
13
13
|
app.use(express.json({ limit: settings.maxPayloadSize })); // , extended: true ?
|
|
14
14
|
return app;
|
|
15
15
|
};
|
|
16
|
+
/**
|
|
17
|
+
* Creates an express router
|
|
18
|
+
* @returns
|
|
19
|
+
*/
|
|
20
|
+
export const createRouter = () => {
|
|
21
|
+
return createExpress.Router();
|
|
22
|
+
};
|
|
16
23
|
//# sourceMappingURL=http.js.map
|
|
@@ -12,12 +12,12 @@ export const generatePassword = () => {
|
|
|
12
12
|
* @param password password to hash
|
|
13
13
|
*/
|
|
14
14
|
export const createPasswordHash = (password) => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
const length = 16;
|
|
16
|
+
const salt = crypto.randomBytes(Math.ceil(length / 2)).toString('hex').slice(0, length);
|
|
17
|
+
const hash = crypto.createHmac('sha512', salt).update(password).digest('hex');
|
|
18
18
|
return {
|
|
19
19
|
salt,
|
|
20
|
-
hash
|
|
20
|
+
hash,
|
|
21
21
|
};
|
|
22
22
|
};
|
|
23
23
|
/**
|
|
@@ -32,7 +32,7 @@ export const getPasswordHash = (password, salt) => {
|
|
|
32
32
|
* Backward compatibility with old saltless md5 passwords. Becomes obsolete once all passwords have been updated (probably already so)
|
|
33
33
|
*/
|
|
34
34
|
export const getOldPasswordHash = (password) => {
|
|
35
|
-
// Backward compatibility with old saltless md5 passwords.
|
|
35
|
+
// Backward compatibility with old saltless md5 passwords.
|
|
36
36
|
// Becomes obsolete once all passwords have been updated
|
|
37
37
|
return crypto.createHash('md5').update(password).digest('hex');
|
|
38
38
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { resolve } from
|
|
1
|
+
import { resolve } from 'path';
|
|
2
2
|
// This file is in ./src/shared/rootpath.ts
|
|
3
3
|
// When this code runs it is at ./dist/cjs/shared/rootpath.js or ./dist/esm/shared/rootpath.js
|
|
4
4
|
// So, the package root is at ../../..
|
|
@@ -7,7 +7,7 @@ if (process.platform === 'win32' && currentDir.startsWith('/')) {
|
|
|
7
7
|
// tsc-esm-fix does not handle win32 file urls correctly, the drive letter in import.meta.url is prefixed with a slash: file:///C:/dir/file.js
|
|
8
8
|
currentDir = currentDir.slice(1);
|
|
9
9
|
}
|
|
10
|
-
// tsc-esm-fix also does not use decodeURI to remove encoded characters (such as %20 for spaces)
|
|
10
|
+
// tsc-esm-fix also does not use decodeURI to remove encoded characters (such as %20 for spaces)
|
|
11
11
|
currentDir = decodeURI(currentDir);
|
|
12
12
|
export const packageRootPath = resolve(currentDir, '../../..');
|
|
13
13
|
export default packageRootPath;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ID } from
|
|
2
|
-
import { createPasswordHash, getOldPasswordHash, getPasswordHash } from
|
|
3
|
-
import { decodePublicAccessToken } from
|
|
1
|
+
import { ID } from 'acebase-core';
|
|
2
|
+
import { createPasswordHash, getOldPasswordHash, getPasswordHash } from './password.js';
|
|
3
|
+
import { decodePublicAccessToken } from './tokens.js';
|
|
4
4
|
export class SignInError extends Error {
|
|
5
5
|
constructor(code, message, details = {}) {
|
|
6
6
|
super(message);
|
|
@@ -80,7 +80,7 @@ export const signIn = async (credentials, env, req) => {
|
|
|
80
80
|
}
|
|
81
81
|
if (credentials.method === 'account' || credentials.method === 'email') {
|
|
82
82
|
// Check password
|
|
83
|
-
|
|
83
|
+
const hash = user.password_salt ? getPasswordHash(credentials.password, user.password_salt) : getOldPasswordHash(credentials.password);
|
|
84
84
|
if (user.password !== hash) {
|
|
85
85
|
throw new SignInError('wrong_password', 'Incorrect password');
|
|
86
86
|
}
|
|
@@ -91,12 +91,12 @@ export const signIn = async (credentials, env, req) => {
|
|
|
91
91
|
prev_signin: user.last_signin,
|
|
92
92
|
prev_signin_ip: user.last_signin_ip,
|
|
93
93
|
last_signin: new Date(),
|
|
94
|
-
last_signin_ip: req.ip
|
|
94
|
+
last_signin_ip: req.ip,
|
|
95
95
|
};
|
|
96
96
|
if ('password' in credentials) {
|
|
97
97
|
if (!user.password_salt) {
|
|
98
98
|
// OLD md5 password hash, convert to new salted hash
|
|
99
|
-
|
|
99
|
+
const pwd = createPasswordHash(credentials.password);
|
|
100
100
|
updates.password = pwd.hash;
|
|
101
101
|
updates.password_salt = pwd.salt;
|
|
102
102
|
}
|
|
@@ -9,9 +9,9 @@ export function fetch(url, options) {
|
|
|
9
9
|
const method = options?.method || 'GET';
|
|
10
10
|
const headers = options?.headers;
|
|
11
11
|
const req = request(url, { method, headers }, res => {
|
|
12
|
-
// res.setEncoding('binary'); // will result in strings!!!!
|
|
12
|
+
// res.setEncoding('binary'); // will result in strings!!!!
|
|
13
13
|
const ready = new Promise((resolve, reject) => {
|
|
14
|
-
|
|
14
|
+
const chunks = [];
|
|
15
15
|
res.on('data', data => {
|
|
16
16
|
chunks.push(data);
|
|
17
17
|
});
|
|
@@ -28,12 +28,12 @@ export function fetch(url, options) {
|
|
|
28
28
|
get headers() {
|
|
29
29
|
return {
|
|
30
30
|
get(name) {
|
|
31
|
-
|
|
31
|
+
const val = res.headers[name.toLowerCase()];
|
|
32
32
|
if (val instanceof Array) {
|
|
33
33
|
return val.join(', ');
|
|
34
34
|
}
|
|
35
35
|
return val;
|
|
36
|
-
}
|
|
36
|
+
},
|
|
37
37
|
};
|
|
38
38
|
},
|
|
39
39
|
async text() {
|
|
@@ -48,7 +48,7 @@ export function fetch(url, options) {
|
|
|
48
48
|
const data = await ready;
|
|
49
49
|
const arrayBuffer = data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
|
|
50
50
|
return arrayBuffer;
|
|
51
|
-
}
|
|
51
|
+
},
|
|
52
52
|
};
|
|
53
53
|
resolve(response);
|
|
54
54
|
});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as crypto from 'crypto';
|
|
2
2
|
export const createPublicAccessToken = (uid, ip, dbToken, password) => {
|
|
3
|
-
|
|
3
|
+
const obj = {
|
|
4
4
|
t: dbToken,
|
|
5
5
|
c: Date.now(),
|
|
6
6
|
u: uid,
|
|
7
|
-
i: ip
|
|
7
|
+
i: ip,
|
|
8
8
|
};
|
|
9
9
|
// let str = JSON.stringify(obj);
|
|
10
10
|
// str = Buffer.from(str).toString('base64');
|
|
@@ -19,7 +19,7 @@ export const decodePublicAccessToken = (accessToken, password) => {
|
|
|
19
19
|
access_token: obj.t,
|
|
20
20
|
uid: obj.u,
|
|
21
21
|
created: obj.c,
|
|
22
|
-
ip: obj.i
|
|
22
|
+
ip: obj.i,
|
|
23
23
|
};
|
|
24
24
|
if (!details.access_token || !details.uid || !details.created || !details.ip) {
|
|
25
25
|
throw new Error('Invalid token');
|
package/dist/esm/start.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AceBaseServer } from './server.js';
|
|
2
2
|
// If one executes "node start.js [dbname=name] [host=ip] [port=nr]"
|
|
3
3
|
function getVariable(name, defaultValue) {
|
|
4
|
-
// Checks if an argument with the name was passed,
|
|
4
|
+
// Checks if an argument with the name was passed,
|
|
5
5
|
// or if an environment variable was set with that name,
|
|
6
6
|
// else it will return the default value
|
|
7
7
|
name = name.toUpperCase();
|
|
@@ -14,13 +14,13 @@ function getVariable(name, defaultValue) {
|
|
|
14
14
|
}
|
|
15
15
|
return defaultValue;
|
|
16
16
|
}
|
|
17
|
-
;
|
|
18
17
|
const path = getVariable('DBPATH', '.');
|
|
19
18
|
const dbname = getVariable('DBNAME', 'default');
|
|
20
19
|
const host = getVariable('HOST', 'localhost'); // '0.0.0.0'
|
|
21
20
|
const port = +getVariable('PORT', 3000);
|
|
22
21
|
const ipcPort = +getVariable('IPC_PORT', 0);
|
|
23
|
-
const
|
|
22
|
+
const rootPath = getVariable('ROOT_PATH', '');
|
|
23
|
+
const options = { host, port, path, rootPath };
|
|
24
24
|
if (ipcPort > 0) {
|
|
25
25
|
const role = getVariable('IPC_ROLE');
|
|
26
26
|
if (!['master', 'worker'].includes(role)) {
|
|
@@ -31,20 +31,20 @@ if (ipcPort > 0) {
|
|
|
31
31
|
port: ipcPort,
|
|
32
32
|
ssl: +getVariable('IPC_SSL', 0) === 1,
|
|
33
33
|
token: getVariable('IPC_TOKEN'),
|
|
34
|
-
role
|
|
34
|
+
role,
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
37
|
if (+getVariable('TXLOG', 0) === 1) {
|
|
38
38
|
options.transactions = {
|
|
39
39
|
log: true,
|
|
40
|
-
maxAge: +getVariable('TXDAYS', 30)
|
|
40
|
+
maxAge: +getVariable('TXDAYS', 30),
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
43
|
if (+getVariable('AUTH', 1) === 0) {
|
|
44
44
|
options.authentication = { enabled: false };
|
|
45
45
|
}
|
|
46
46
|
const server = new AceBaseServer(dbname, options);
|
|
47
|
-
server.once(
|
|
47
|
+
server.once('ready', () => {
|
|
48
48
|
server.debug.log(`AceBase server running`);
|
|
49
49
|
process.send?.('ready'); // When using pm2, you can use --wait-ready flag (see https://pm2.keymetrics.io/docs/usage/signals-clean-restart/)
|
|
50
50
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ColorStyle, Transport } from
|
|
2
|
-
import { ConnectedClient } from
|
|
3
|
-
import { decodePublicAccessToken } from
|
|
4
|
-
import { createServer } from
|
|
1
|
+
import { ColorStyle, Transport } from 'acebase-core';
|
|
2
|
+
import { ConnectedClient } from '../shared/clients.js';
|
|
3
|
+
import { decodePublicAccessToken } from '../shared/tokens.js';
|
|
4
|
+
import { createServer } from './socket.io.js';
|
|
5
5
|
export class SocketRequestError extends Error {
|
|
6
6
|
constructor(code, message) {
|
|
7
7
|
super(message);
|
|
@@ -41,14 +41,14 @@ export const addWebsocketServer = (env) => {
|
|
|
41
41
|
// subscr.callback
|
|
42
42
|
// })
|
|
43
43
|
// });
|
|
44
|
-
|
|
44
|
+
const remove = [];
|
|
45
45
|
subscribedPaths.forEach(path => {
|
|
46
46
|
remove.push(...client.subscriptions[path]);
|
|
47
47
|
});
|
|
48
48
|
remove.forEach(subscr => {
|
|
49
49
|
// Unsubscribe them at db level and remove from our list
|
|
50
50
|
env.db.api.unsubscribe(subscr.path, subscr.event, subscr.callback); //db.ref(subscr.path).off(subscr.event, subscr.callback);
|
|
51
|
-
|
|
51
|
+
const pathSubs = client.subscriptions[subscr.path];
|
|
52
52
|
pathSubs.splice(pathSubs.indexOf(subscr), 1);
|
|
53
53
|
});
|
|
54
54
|
}
|
|
@@ -56,7 +56,7 @@ export const addWebsocketServer = (env) => {
|
|
|
56
56
|
env.debug.verbose(`Socket disconnected, total: ${env.clients.size}`);
|
|
57
57
|
});
|
|
58
58
|
serverManager.on('signin', event => {
|
|
59
|
-
// client sends this request once user has been signed in, binds the user to the socket,
|
|
59
|
+
// client sends this request once user has been signed in, binds the user to the socket,
|
|
60
60
|
// deprecated since client v0.9.4, which sends client_id with signin api call
|
|
61
61
|
// const client = clients.get(socket.id);
|
|
62
62
|
const client = getClientBySocketId(event.socket_id, 'signin');
|
|
@@ -104,7 +104,7 @@ export const addWebsocketServer = (env) => {
|
|
|
104
104
|
// Send acknowledgement
|
|
105
105
|
serverManager.send(socket, 'result', {
|
|
106
106
|
success: true,
|
|
107
|
-
req_id: requestId
|
|
107
|
+
req_id: requestId,
|
|
108
108
|
});
|
|
109
109
|
};
|
|
110
110
|
const failRequest = (socket, requestId, code) => {
|
|
@@ -112,7 +112,7 @@ export const addWebsocketServer = (env) => {
|
|
|
112
112
|
serverManager.send(socket, 'result', {
|
|
113
113
|
success: false,
|
|
114
114
|
reason: code,
|
|
115
|
-
req_id: requestId
|
|
115
|
+
req_id: requestId,
|
|
116
116
|
});
|
|
117
117
|
};
|
|
118
118
|
serverManager.on('subscribe', event => {
|
|
@@ -150,9 +150,9 @@ export const addWebsocketServer = (env) => {
|
|
|
150
150
|
if (err) {
|
|
151
151
|
return;
|
|
152
152
|
}
|
|
153
|
-
|
|
153
|
+
const val = Transport.serialize({
|
|
154
154
|
current: currentValue,
|
|
155
|
-
previous: previousValue
|
|
155
|
+
previous: previousValue,
|
|
156
156
|
});
|
|
157
157
|
env.debug.verbose(`Sending data event "${event.data.event}" for path "/${path}" to client ${event.socket_id}`.colorize([ColorStyle.bgWhite, ColorStyle.black]));
|
|
158
158
|
// TODO: let large data events notify the client, then let them download the data manually so it doesn't have to be transmitted through the websocket
|
|
@@ -161,14 +161,14 @@ export const addWebsocketServer = (env) => {
|
|
|
161
161
|
path,
|
|
162
162
|
event: event.data.event,
|
|
163
163
|
val,
|
|
164
|
-
context
|
|
164
|
+
context,
|
|
165
165
|
});
|
|
166
166
|
};
|
|
167
167
|
let pathSubs = client.subscriptions[subscriptionPath];
|
|
168
168
|
if (!pathSubs) {
|
|
169
169
|
pathSubs = client.subscriptions[subscriptionPath] = [];
|
|
170
170
|
}
|
|
171
|
-
|
|
171
|
+
const subscr = { path: subscriptionPath, event: event.data.event, callback };
|
|
172
172
|
pathSubs.push(subscr);
|
|
173
173
|
env.db.api.subscribe(subscriptionPath, event.data.event, callback);
|
|
174
174
|
acknowledgeRequest(event.socket, event.data.req_id);
|
|
@@ -181,7 +181,7 @@ export const addWebsocketServer = (env) => {
|
|
|
181
181
|
}
|
|
182
182
|
env.debug.verbose(`Client ${event.socket_id} is unsubscribing from event "${event.data.event || '(any)'}" on path "/${event.data.path}"`.colorize([ColorStyle.bgWhite, ColorStyle.black]));
|
|
183
183
|
// const client = clients.get(socket.id);
|
|
184
|
-
|
|
184
|
+
const pathSubs = client.subscriptions[event.data.path];
|
|
185
185
|
if (!pathSubs) {
|
|
186
186
|
// We have no knowledge of any active subscriptions on this path
|
|
187
187
|
return acknowledgeRequest(event.socket, event.data.req_id);
|
|
@@ -236,7 +236,7 @@ export const addWebsocketServer = (env) => {
|
|
|
236
236
|
tx.finish(); // Finish without value cancels the transaction
|
|
237
237
|
env.log.error(LOG_ACTION, 'timeout', LOG_DETAILS);
|
|
238
238
|
serverManager.send(event.socket, 'tx_error', { id: tx.id, reason: 'timeout' });
|
|
239
|
-
}, TRANSACTION_TIMEOUT_MS)
|
|
239
|
+
}, TRANSACTION_TIMEOUT_MS),
|
|
240
240
|
};
|
|
241
241
|
const access = env.rules.userHasAccess(client.user, data.path, true);
|
|
242
242
|
if (!access.allow) {
|
|
@@ -33,10 +33,11 @@ export const createServer = (env) => {
|
|
|
33
33
|
pingInterval: 5000,
|
|
34
34
|
pingTimeout: 5000,
|
|
35
35
|
maxHttpBufferSize: maxPayloadBytes,
|
|
36
|
+
path: `/${env.rootPath ? `${env.rootPath}/` : ''}socket.io`,
|
|
36
37
|
// Allow socket.io 2.x clients (using engine.io 3.x):
|
|
37
38
|
allowEIO3: true,
|
|
38
39
|
// socket.io 3+ uses cors package:
|
|
39
|
-
cors: getCorsOptions(env.config.allowOrigin)
|
|
40
|
+
cors: getCorsOptions(env.config.allowOrigin),
|
|
40
41
|
});
|
|
41
42
|
// Setup event emitter for communication with consuming server
|
|
42
43
|
const manager = new SocketIOManager();
|
package/dist/types/auth.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RouteInitEnvironment } from
|
|
1
|
+
import { RouteInitEnvironment } from './shared/env';
|
|
2
2
|
export declare const setupAuthentication: (env: RouteInitEnvironment) => Promise<void>;
|
|
3
3
|
export default setupAuthentication;
|
|
4
4
|
//# sourceMappingURL=auth.d.ts.map
|
package/dist/types/logger.d.ts
CHANGED