acebase-server 1.15.1 → 1.16.0
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/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 +8 -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 +8 -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 +9 -4
- 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/src/shared/clients.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { EventSubscriptionCallback, Query, QueryOptions } from "acebase-core";
|
|
2
|
-
import { DbUserAccountDetails } from "../schema/user";
|
|
3
|
-
import { HttpSocket } from "./http";
|
|
4
|
-
|
|
5
|
-
export class ConnectedClient {
|
|
6
|
-
readonly id: string;
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
*
|
|
10
|
-
* @param socket Socket object used by the framework
|
|
11
|
-
* @param id optional: use if the socket object does not have an `id` property.
|
|
12
|
-
*/
|
|
13
|
-
constructor (public socket: HttpSocket, id?: string) {
|
|
14
|
-
this.id = id ?? socket.id;
|
|
15
|
-
if (!this.id) { throw new Error('Socket has no id'); }
|
|
16
|
-
}
|
|
17
|
-
// get id() { return this.socket.id; };
|
|
18
|
-
readonly connectedDate: Date = new Date();
|
|
19
|
-
|
|
20
|
-
/** user details if this socket client is signed in */
|
|
21
|
-
user?: DbUserAccountDetails;
|
|
22
|
-
|
|
23
|
-
/** Active event subscriptions for this client */
|
|
24
|
-
subscriptions: { [path: string]: Array<{ path: string, event: string, callback: EventSubscriptionCallback }> } = {};
|
|
25
|
-
|
|
26
|
-
/** Active realtime query subscriptions for this client */
|
|
27
|
-
realtimeQueries: { [id: string]: { path: string; query: Query, options: QueryOptions }} = {};
|
|
28
|
-
|
|
29
|
-
/** Currently running transactions */
|
|
30
|
-
transactions: { [id: string]: { id: string; started: number; path: string; context: any; finish?: (val?: any) => Promise<{ cursor?: string }>; timeout: NodeJS.Timeout } } = {};
|
|
31
|
-
}
|
package/src/shared/email.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
export interface AceBaseEmailRequest {
|
|
2
|
-
/** email request type */
|
|
3
|
-
type: string;
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
export interface AceBaseUserEmailRequest extends AceBaseEmailRequest {
|
|
7
|
-
user: { uid: string; email: string; username?: string; displayName?: string; settings?: any };
|
|
8
|
-
ip: string;
|
|
9
|
-
date: Date
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export interface AceBaseUserSignupEmailRequest extends AceBaseUserEmailRequest {
|
|
13
|
-
type: 'user_signup';
|
|
14
|
-
activationCode: string;
|
|
15
|
-
emailVerified: boolean;
|
|
16
|
-
provider: string;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export interface AceBaseUserSignInEmailRequest extends AceBaseUserEmailRequest {
|
|
20
|
-
type: 'user_signin';
|
|
21
|
-
activationCode: string;
|
|
22
|
-
emailVerified: boolean;
|
|
23
|
-
provider: string;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export interface AceBaseUserResetPasswordEmailRequest extends AceBaseUserEmailRequest {
|
|
27
|
-
type: 'user_reset_password';
|
|
28
|
-
resetCode: string;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export interface AceBaseUserResetPasswordSuccessEmailRequest extends AceBaseUserEmailRequest {
|
|
32
|
-
type: 'user_reset_password_success';
|
|
33
|
-
}
|
package/src/shared/env.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type { HttpApp, Request } from './http';
|
|
2
|
-
import type { AceBase, DataReference } from 'acebase';
|
|
3
|
-
import type { AceBaseServerConfig } from '../settings';
|
|
4
|
-
import type { DbUserAccountDetails } from '../schema/user';
|
|
5
|
-
import type { ConnectedClient } from './clients';
|
|
6
|
-
import type { DebugLogger, SimpleCache, Api } from 'acebase-core';
|
|
7
|
-
import type { OAuth2Provider } from '../oauth-providers/oauth-provider';
|
|
8
|
-
import type { Server as HttpServer } from 'http';
|
|
9
|
-
import type { Server as SecureHttpServer } from 'https';
|
|
10
|
-
import type { PathBasedRules } from '../rules';
|
|
11
|
-
import { DatabaseLog } from '../logger';
|
|
12
|
-
|
|
13
|
-
export interface RouteInitEnvironment {
|
|
14
|
-
server: HttpServer | SecureHttpServer;
|
|
15
|
-
app: HttpApp;
|
|
16
|
-
config: AceBaseServerConfig;
|
|
17
|
-
db: AceBase & { api: Api };
|
|
18
|
-
authDb: AceBase;
|
|
19
|
-
debug: DebugLogger;
|
|
20
|
-
securityRef: DataReference;
|
|
21
|
-
authRef: DataReference;
|
|
22
|
-
log: DatabaseLog; // logRef: DataReference;
|
|
23
|
-
tokenSalt: string;
|
|
24
|
-
clients: Map<string, ConnectedClient>;
|
|
25
|
-
authCache: SimpleCache<string, DbUserAccountDetails>;
|
|
26
|
-
authProviders: { [providerName: string]: OAuth2Provider };
|
|
27
|
-
rules: PathBasedRules
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export interface RouteRequestEnvironment {
|
|
31
|
-
/** If the request has an Authentication: bearer token, the user will be bound to the incoming request */
|
|
32
|
-
user?: DbUserAccountDetails;
|
|
33
|
-
|
|
34
|
-
/** If context is sent through AceBase-Context header, it will be bound to the incoming request */
|
|
35
|
-
context: { [key: string]: any };
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export type RouteRequest<Params = any, ResBody = any, ReqBody = any, ReqQuery = any, Locals extends Record<string, any> = Record<string, any>> = Request<Params, ResBody, ReqBody, ReqQuery, Locals> & RouteRequestEnvironment;
|
package/src/shared/error.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { Response } from './http';
|
|
2
|
-
|
|
3
|
-
export const sendNotAuthenticatedError = (res: Response, code: string, message: string) => {
|
|
4
|
-
res.statusCode = 401; // Unauthorized (not unauthenticated)
|
|
5
|
-
res.statusMessage = 'Not Authenticated';
|
|
6
|
-
res.contentType('application/json').send({ code, message });
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export const sendUnauthorizedError = (res: Response, code: string, message: string) => {
|
|
10
|
-
res.statusCode = 403; // Forbidden
|
|
11
|
-
res.statusMessage = 'Unauthorized';
|
|
12
|
-
res.contentType('application/json').send({ code, message });
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
interface ErrorLike {
|
|
16
|
-
code?: string;
|
|
17
|
-
message: string;
|
|
18
|
-
stack?: string;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export const sendError = (res: Response, err: ErrorLike) => {
|
|
22
|
-
res.contentType('application/json');
|
|
23
|
-
if (typeof err.code === 'string') {
|
|
24
|
-
sendBadRequestError(res, err as { code: string; message: string }); //res.status(400).send({ code: err.code, message: err.message }); // Bad Request
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
sendUnexpectedError(res, err as Error); // res.status(500).send({ code: 'unknown', message: 'server error', details: err.message }); // Internal server error
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export const sendBadRequestError = (res: Response, err: { code: string, message: string }) => {
|
|
32
|
-
res.status(400).contentType('application/json').send({ code: err.code, message: err.message }); // Bad Request
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export const sendUnexpectedError = (res: Response, err: Error) => {
|
|
36
|
-
res.status(500).contentType('application/json').send({ code: 'unexpected', message: 'server error', details: err.message }); // Internal server error
|
|
37
|
-
}
|
package/src/shared/http.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { Socket } from 'socket.io';
|
|
2
|
-
export type { Express, Request, Response } from 'express';
|
|
3
|
-
import * as express from 'express';
|
|
4
|
-
const createExpress = (express as any).default ?? express; // ESM and CJS compatible approach
|
|
5
|
-
|
|
6
|
-
export type HttpApp = express.Express;
|
|
7
|
-
export type HttpSocket = Socket;
|
|
8
|
-
export type HttpRequest = express.Request;
|
|
9
|
-
export type HttpResponse = express.Response;
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Creates an app that handles http requests, adds json body parsing.
|
|
13
|
-
* @param settings
|
|
14
|
-
* @returns
|
|
15
|
-
*/
|
|
16
|
-
export const createApp = (settings: { trustProxy: boolean; maxPayloadSize: string }) => {
|
|
17
|
-
const app = createExpress();
|
|
18
|
-
|
|
19
|
-
// When behind a trusted proxy server, req.ip and req.hostname will be set the right way
|
|
20
|
-
app.set('trust proxy', settings.trustProxy);
|
|
21
|
-
|
|
22
|
-
// Parse json request bodies
|
|
23
|
-
app.use(express.json({ limit: settings.maxPayloadSize })); // , extended: true ?
|
|
24
|
-
|
|
25
|
-
return app as HttpApp;
|
|
26
|
-
}
|
package/src/shared/password.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import * as crypto from 'crypto';
|
|
2
|
-
|
|
3
|
-
export const generatePassword = () => {
|
|
4
|
-
return Array.prototype.reduce.call('abcedefghijkmnopqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ012345789!@#$%&', (password, c, i, chars) => {
|
|
5
|
-
if (i > 15) { return password; }
|
|
6
|
-
return password + chars[Math.floor(Math.random() * chars.length)];
|
|
7
|
-
}, '');
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Generates a random salt and hashes the provided password with it. The resulting salt and hash should be stored in the database
|
|
12
|
-
* @param password password to hash
|
|
13
|
-
*/
|
|
14
|
-
export const createPasswordHash = (password: string) => {
|
|
15
|
-
let length = 16;
|
|
16
|
-
let salt = crypto.randomBytes(Math.ceil(length/2)).toString('hex').slice(0,length);
|
|
17
|
-
let hash = crypto.createHmac('sha512', salt).update(password).digest('hex');
|
|
18
|
-
return {
|
|
19
|
-
salt,
|
|
20
|
-
hash
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* For checking passwords: uses given password and salt to get the hash that can be compared to a stored version.
|
|
26
|
-
* @param password A password prodived by the user trying to sign in
|
|
27
|
-
* @param salt the salt used to generate the hash, must be stored with the hash in the database
|
|
28
|
-
*/
|
|
29
|
-
export const getPasswordHash = (password: string, salt: string) => {
|
|
30
|
-
return crypto.createHmac('sha512', salt).update(password).digest('hex');
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Backward compatibility with old saltless md5 passwords. Becomes obsolete once all passwords have been updated (probably already so)
|
|
35
|
-
*/
|
|
36
|
-
export const getOldPasswordHash = (password: string) => {
|
|
37
|
-
// Backward compatibility with old saltless md5 passwords.
|
|
38
|
-
// Becomes obsolete once all passwords have been updated
|
|
39
|
-
return crypto.createHash('md5').update(password).digest('hex');
|
|
40
|
-
};
|
|
41
|
-
|
package/src/shared/rootpath.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { resolve } from "path";
|
|
2
|
-
|
|
3
|
-
// This file is in ./src/shared/rootpath.ts
|
|
4
|
-
// When this code runs it is at ./dist/cjs/shared/rootpath.js or ./dist/esm/shared/rootpath.js
|
|
5
|
-
// So, the package root is at ../../..
|
|
6
|
-
let currentDir = __dirname;
|
|
7
|
-
|
|
8
|
-
if (process.platform === 'win32' && currentDir.startsWith('/')) {
|
|
9
|
-
// 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
|
|
10
|
-
currentDir = currentDir.slice(1);
|
|
11
|
-
}
|
|
12
|
-
// tsc-esm-fix also does not use decodeURI to remove encoded characters (such as %20 for spaces)
|
|
13
|
-
currentDir = decodeURI(currentDir);
|
|
14
|
-
|
|
15
|
-
export const packageRootPath = resolve(currentDir, '../../..');
|
|
16
|
-
|
|
17
|
-
export default packageRootPath;
|
package/src/shared/signin.ts
DELETED
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
import { ID } from "acebase-core";
|
|
2
|
-
import { DbUserAccountDetails } from "../schema/user";
|
|
3
|
-
import { RouteInitEnvironment, RouteRequest } from "./env";
|
|
4
|
-
import { createPasswordHash, getOldPasswordHash, getPasswordHash } from "./password";
|
|
5
|
-
import { decodePublicAccessToken } from "./tokens";
|
|
6
|
-
|
|
7
|
-
export type SignInCredentials =
|
|
8
|
-
{ method: 'token'; access_token: string } |
|
|
9
|
-
{ method: 'internal'; access_token: string } |
|
|
10
|
-
{ method: 'email'; email: string; password: string } |
|
|
11
|
-
{ method: 'account', username: string, password: string };
|
|
12
|
-
|
|
13
|
-
export class SignInError extends Error {
|
|
14
|
-
constructor(public code: string, message: string, public details: Object = {}) {
|
|
15
|
-
super(message);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Signs in a user and logs the request. If successful, adds the user to authCache, binds the user to the http request and returns the user details.
|
|
21
|
-
* Throws a `SignInError` if sign in fails for a known reason.
|
|
22
|
-
* @param credentials credentials to sign in the user with
|
|
23
|
-
* @param env environment state
|
|
24
|
-
* @param req current http request
|
|
25
|
-
* @returns
|
|
26
|
-
*/
|
|
27
|
-
export const signIn = async (credentials: SignInCredentials, env: RouteInitEnvironment, req: RouteRequest) => {
|
|
28
|
-
|
|
29
|
-
const LOG_ACTION = 'auth.signin';
|
|
30
|
-
const LOG_DETAILS = { ip: req.ip, method: credentials.method };
|
|
31
|
-
|
|
32
|
-
try {
|
|
33
|
-
const query = env.authRef.query();
|
|
34
|
-
let tokenDetails: ReturnType<typeof decodePublicAccessToken>;
|
|
35
|
-
switch (credentials.method) {
|
|
36
|
-
case 'token': {
|
|
37
|
-
if (typeof credentials.access_token !== 'string') {
|
|
38
|
-
throw new SignInError('invalid_details', 'sign in request has invalid arguments');
|
|
39
|
-
}
|
|
40
|
-
try {
|
|
41
|
-
tokenDetails = decodePublicAccessToken(credentials.access_token, env.tokenSalt);
|
|
42
|
-
query.filter('access_token', '==', tokenDetails.access_token);
|
|
43
|
-
}
|
|
44
|
-
catch (err) {
|
|
45
|
-
throw new SignInError('invalid_token', err.message);
|
|
46
|
-
}
|
|
47
|
-
break;
|
|
48
|
-
}
|
|
49
|
-
case 'internal': {
|
|
50
|
-
// Method used internally: uses the access token extracted from a public access token (see tokenDetails.access_token in above 'token' case)
|
|
51
|
-
if (typeof credentials.access_token !== 'string') {
|
|
52
|
-
throw new SignInError('invalid_details', 'sign in request has invalid arguments');
|
|
53
|
-
}
|
|
54
|
-
query.filter('access_token', '==', credentials.access_token);
|
|
55
|
-
break;
|
|
56
|
-
}
|
|
57
|
-
case 'email': {
|
|
58
|
-
if (typeof credentials.email !== 'string' || typeof credentials.password !== 'string') {
|
|
59
|
-
throw new SignInError('invalid_details', 'sign in request has invalid arguments');
|
|
60
|
-
}
|
|
61
|
-
query.filter('email', '==', credentials.email);
|
|
62
|
-
break;
|
|
63
|
-
}
|
|
64
|
-
case 'account': {
|
|
65
|
-
if (typeof credentials.username !== 'string' || typeof credentials.password !== 'string') {
|
|
66
|
-
throw new SignInError('invalid_details', 'sign in request has invalid arguments');
|
|
67
|
-
}
|
|
68
|
-
query.filter('username', '==', credentials.username);
|
|
69
|
-
break;
|
|
70
|
-
}
|
|
71
|
-
default: {
|
|
72
|
-
throw new SignInError('invalid_method', `Unsupported sign in method ${(credentials as any).method}`);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const snaps = await query.get();
|
|
77
|
-
if (snaps.length === 0) {
|
|
78
|
-
throw new SignInError('not_found', `account not found`);
|
|
79
|
-
}
|
|
80
|
-
else if (snaps.length > 1) {
|
|
81
|
-
throw new SignInError('duplicate', `${snaps.length} users found with the same ${credentials.method}. Contact your database administrator`, { count: snaps.length });
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const snap = snaps[0];
|
|
85
|
-
const user: DbUserAccountDetails = snap.val();
|
|
86
|
-
user.uid = snap.key as string;
|
|
87
|
-
|
|
88
|
-
if (user.is_disabled === true) {
|
|
89
|
-
throw new SignInError('account_disabled', 'Your account has been disabled. Contact your database administrator');
|
|
90
|
-
}
|
|
91
|
-
if (credentials.method === 'token' && tokenDetails.uid !== user.uid) {
|
|
92
|
-
throw new SignInError('token_mismatch', 'Sign in again');
|
|
93
|
-
}
|
|
94
|
-
if (credentials.method === 'account' || credentials.method === 'email') {
|
|
95
|
-
// Check password
|
|
96
|
-
let hash = user.password_salt ? getPasswordHash(credentials.password, user.password_salt) : getOldPasswordHash(credentials.password);
|
|
97
|
-
if (user.password !== hash) {
|
|
98
|
-
throw new SignInError('wrong_password', 'Incorrect password');
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// Keep track of properties to update, both in db and in our object
|
|
103
|
-
const updates: Partial<DbUserAccountDetails> = {
|
|
104
|
-
// Update prev / last sign in stats
|
|
105
|
-
prev_signin: user.last_signin,
|
|
106
|
-
prev_signin_ip: user.last_signin_ip,
|
|
107
|
-
last_signin: new Date(),
|
|
108
|
-
last_signin_ip: req.ip
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
if ('password' in credentials) {
|
|
112
|
-
if (!user.password_salt) {
|
|
113
|
-
// OLD md5 password hash, convert to new salted hash
|
|
114
|
-
let pwd = createPasswordHash(credentials.password);
|
|
115
|
-
updates.password = pwd.hash;
|
|
116
|
-
updates.password_salt = pwd.salt;
|
|
117
|
-
}
|
|
118
|
-
if (!user.access_token) {
|
|
119
|
-
// Generate access token
|
|
120
|
-
updates.access_token = ID.generate();
|
|
121
|
-
updates.access_token_created = new Date();
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// Update user object
|
|
126
|
-
Object.assign(user, updates);
|
|
127
|
-
|
|
128
|
-
// Update db
|
|
129
|
-
await snap.ref.update(updates);
|
|
130
|
-
|
|
131
|
-
// Log history item
|
|
132
|
-
if (credentials.method !== 'internal') {
|
|
133
|
-
env.log.event(LOG_ACTION, LOG_DETAILS);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// Add to cache
|
|
137
|
-
env.authCache.set(user.uid, user);
|
|
138
|
-
|
|
139
|
-
// Bind user to current request
|
|
140
|
-
req.user = user;
|
|
141
|
-
|
|
142
|
-
return user;
|
|
143
|
-
}
|
|
144
|
-
catch (err) {
|
|
145
|
-
// Log error
|
|
146
|
-
env.log.error(LOG_ACTION, err.code ?? 'unexpected', LOG_DETAILS, typeof err.code === 'undefined' ? err : null);
|
|
147
|
-
throw err;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { request } from 'https';
|
|
2
|
-
export interface SimpleFetchResponse {
|
|
3
|
-
readonly status: number;
|
|
4
|
-
readonly headers: { get(name: string): string }
|
|
5
|
-
text(): Promise<string>
|
|
6
|
-
json(): Promise<any>
|
|
7
|
-
arrayBuffer(): Promise<ArrayBuffer>
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Very lightweight custom fetch implementation to avoid additional dependencies
|
|
11
|
-
* @param url
|
|
12
|
-
* @param options
|
|
13
|
-
*/
|
|
14
|
-
export function fetch(url: string, options?: { method?: 'GET'|'POST'|'PUT'|'DELETE', headers?: { [name: string]: string }, body?: string }): Promise<SimpleFetchResponse> {
|
|
15
|
-
return new Promise((resolve, reject) => {
|
|
16
|
-
const method = options?.method || 'GET';
|
|
17
|
-
const headers = options?.headers;
|
|
18
|
-
const req = request(url, { method, headers }, res => {
|
|
19
|
-
|
|
20
|
-
// res.setEncoding('binary'); // will result in strings!!!!
|
|
21
|
-
const ready = new Promise<Buffer>((resolve, reject) => {
|
|
22
|
-
let chunks = [];
|
|
23
|
-
res.on('data', data => {
|
|
24
|
-
chunks.push(data);
|
|
25
|
-
});
|
|
26
|
-
res.on('end', () => {
|
|
27
|
-
const buffer = Buffer.concat(chunks);
|
|
28
|
-
resolve(buffer);
|
|
29
|
-
});
|
|
30
|
-
res.on('error', (err) => {
|
|
31
|
-
reject(err);
|
|
32
|
-
})
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
const response: SimpleFetchResponse = {
|
|
36
|
-
get status() { return res.statusCode },
|
|
37
|
-
get headers() { return {
|
|
38
|
-
get(name: string) {
|
|
39
|
-
let val = res.headers[name.toLowerCase()];
|
|
40
|
-
if (val instanceof Array) { return val.join(', '); }
|
|
41
|
-
return val;
|
|
42
|
-
}
|
|
43
|
-
} },
|
|
44
|
-
async text() {
|
|
45
|
-
const buffer = await ready;
|
|
46
|
-
return buffer.toString('utf8');
|
|
47
|
-
},
|
|
48
|
-
json() {
|
|
49
|
-
// return Promise.resolve(JSON.parse(body));
|
|
50
|
-
return this.text().then(json => JSON.parse(json));
|
|
51
|
-
},
|
|
52
|
-
async arrayBuffer() {
|
|
53
|
-
const data = await ready;
|
|
54
|
-
const arrayBuffer = data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
|
|
55
|
-
return arrayBuffer;
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
resolve(response);
|
|
60
|
-
});
|
|
61
|
-
req.on('error', reject);
|
|
62
|
-
options?.body && req.write(options.body, 'utf8');
|
|
63
|
-
req.end();
|
|
64
|
-
})
|
|
65
|
-
}
|
package/src/shared/tokens.ts
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import * as crypto from 'crypto';
|
|
2
|
-
|
|
3
|
-
export const createPublicAccessToken = (uid: string, ip: string, dbToken: string, password: string) => {
|
|
4
|
-
let obj = {
|
|
5
|
-
t: dbToken,
|
|
6
|
-
c: Date.now(),
|
|
7
|
-
u: uid,
|
|
8
|
-
i: ip
|
|
9
|
-
};
|
|
10
|
-
// let str = JSON.stringify(obj);
|
|
11
|
-
// str = Buffer.from(str).toString('base64');
|
|
12
|
-
// return 'a' + str; // version a
|
|
13
|
-
return 'b' + createSignedPublicToken(obj, password);
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export const decodePublicAccessToken = (accessToken: string, password: string) : { access_token: string; uid: string; created: number; ip: string } => {
|
|
17
|
-
if (accessToken[0] === 'b') {
|
|
18
|
-
// New signed version
|
|
19
|
-
const obj = parseSignedPublicToken(accessToken.slice(1), password);
|
|
20
|
-
const details = {
|
|
21
|
-
access_token: obj.t,
|
|
22
|
-
uid: obj.u,
|
|
23
|
-
created: obj.c,
|
|
24
|
-
ip: obj.i
|
|
25
|
-
}
|
|
26
|
-
if (!details.access_token || !details.uid || !details.created || !details.ip) {
|
|
27
|
-
throw new Error('Invalid token');
|
|
28
|
-
}
|
|
29
|
-
return details;
|
|
30
|
-
}
|
|
31
|
-
else if (accessToken[0] === 'a') {
|
|
32
|
-
// Old insecure version, previously allowed until August 1, 2020.
|
|
33
|
-
throw new Error('Old token version not allowed');
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const getSignature = (content, salt) => {
|
|
39
|
-
// Use fast md5 with salt to sign with. Large salt recommended!!
|
|
40
|
-
return crypto.createHash('md5').update(salt + content).digest('hex');
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Sign objects with an md5 hash. An attacker might base4 decode it and see the content and generated checksum hash,
|
|
45
|
-
* but will need to guess the password used to generate the hash to manipulate it. This is not impossible but will take
|
|
46
|
-
* a very long time when using a large password
|
|
47
|
-
* @param obj data object to sign
|
|
48
|
-
* @param password password to use as salt for the generated md5 hash
|
|
49
|
-
* @returns base64 encoded signed token
|
|
50
|
-
*/
|
|
51
|
-
export const createSignedPublicToken = (obj: any, password: string) => {
|
|
52
|
-
const str = JSON.stringify(obj);
|
|
53
|
-
const checksum = getSignature(str, password);
|
|
54
|
-
return Buffer.from(JSON.stringify({ v: 1, cs: checksum, d: str })).toString('base64');
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Parses and validates a signed token that was previouslt generated by `createSignedPublicToken`
|
|
59
|
-
* @param str token previously generated by `createSignedPublicToken`
|
|
60
|
-
* @param password the same password used to create the token with
|
|
61
|
-
* @returns the original data object
|
|
62
|
-
*/
|
|
63
|
-
export const parseSignedPublicToken = (str: string, password: string) => {
|
|
64
|
-
const json = Buffer.from(str, 'base64').toString('utf8');
|
|
65
|
-
const obj = JSON.parse(json) as { v: number; cs: string; d: string };
|
|
66
|
-
if (obj.v !== 1) {
|
|
67
|
-
throw new Error(`Unsupported version`);
|
|
68
|
-
}
|
|
69
|
-
if (typeof obj.cs !== 'string' || typeof obj.d !== 'string') {
|
|
70
|
-
throw new Error('Invalid token');
|
|
71
|
-
}
|
|
72
|
-
const checksum = obj.cs;
|
|
73
|
-
if (checksum !== getSignature(obj.d, password)) {
|
|
74
|
-
throw new Error(`compromised object`);
|
|
75
|
-
}
|
|
76
|
-
return JSON.parse(obj.d);
|
|
77
|
-
};
|
package/src/shared/validate.ts
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { DataReference } from "acebase-core";
|
|
2
|
-
|
|
3
|
-
export const isValidEmail = (email: string): boolean => {
|
|
4
|
-
return /[a-z0-9_.+]+@([a-z0-9\-]+\.)+[a-z]{2,}/i.test(email);
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
export const isValidNewEmailAddress = async (authRef: DataReference, email: string): Promise<boolean> => {
|
|
8
|
-
const exists = await authRef.query().filter('email', '==', email).exists();
|
|
9
|
-
return !exists;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export const isValidNewUsername = async (authRef: DataReference, username): Promise<boolean> => {
|
|
13
|
-
const exists = await authRef.query().filter('username', '==', username).exists();
|
|
14
|
-
return !exists;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export const isValidUsername = (username: string): boolean => {
|
|
18
|
-
return username !== 'admin' && typeof username === 'string' && username.length >= 5 && /^[a-z0-9]+$/.test(username);
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export const isValidDisplayName = (displayName: string): boolean => {
|
|
22
|
-
return typeof displayName === 'string' && displayName.length >= 5;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export const isValidPassword = (password: string): boolean => {
|
|
26
|
-
// return typeof password === 'string' && password.length >= 8 && password.indexOf(' ') < 0 && /[0-9]/.test(password) && /[a-z]/.test(password) && /[A-Z]/.test(password);
|
|
27
|
-
return typeof password === 'string' && password.length >= 8 && password.indexOf(' ') < 0; // Let client application set their own password rules. Keep minimum length of 8 and no spaces requirement.
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export const isValidPicture = (picture: any): boolean => {
|
|
31
|
-
return picture === null || (typeof picture === 'object' && typeof picture.url === 'string' && typeof picture.width === 'number' && typeof picture.height === 'number');
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export const isValidSettings = (settings: any): boolean => {
|
|
35
|
-
return typeof settings === 'undefined'
|
|
36
|
-
|| (
|
|
37
|
-
typeof settings === 'object'
|
|
38
|
-
&& Object.keys(settings).length <= 100 // max 100 settings
|
|
39
|
-
&& Object.keys(settings).map(key => typeof settings[key]).every(t => ['string','number','boolean'].indexOf(t) >= 0) // only string, number, boolean values
|
|
40
|
-
&& Object.keys(settings).filter(key => typeof settings[key] === 'string').every(key => settings[key].length <= 250) // strings values <= 250 chars
|
|
41
|
-
);
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
export type ValidationError<Code> = { code: Code, message: string };
|
|
45
|
-
export const invalidEmailError: ValidationError<'invalid_email'> = { code: 'invalid_email', message: 'Invalid email address' };
|
|
46
|
-
export const invalidUsernameError: ValidationError<'invalid_username'> = { code: 'invalid_username', message: 'Invalid username, must be at least 5 characters and can only contain lowercase characters a-z and 0-9' };
|
|
47
|
-
export const emailExistsError: ValidationError<'email_conflict'> = { code: 'email_conflict', message: 'Account with email address exists already' };
|
|
48
|
-
export const usernameExistsError: ValidationError<'username_conflict'> = { code: 'username_conflict', message: 'Account with username exists already' };
|
|
49
|
-
export const emailOrUsernameExistsError: ValidationError<'conflict'> = { code: 'conflict', message: `Account with username and/or email already exists` };
|
|
50
|
-
export const invalidDisplayNameError: ValidationError<'invalid_display_name'> = { code: 'invalid_display_name', message: 'Invalid display_name, must be at least 5 characters' };
|
|
51
|
-
export const invalidPasswordError: ValidationError<'invalid_password'> = { code: 'invalid_password', message: 'Invalid password, must be at least 8 characters and cannot contain spaces' };
|
|
52
|
-
export const invalidPictureError: ValidationError<'invalid_picture'> = { code: 'invalid_picture', message: 'Invalid picture, must be an object with url, width and height properties'};
|
|
53
|
-
export const invalidSettingsError: ValidationError<'invalid_settings'> = { code: 'invalid_settings', message: 'Invalid settings, must be an object and contain only string, number and/or boolean values. Additionaly, string values can have a maximum length of 250, and a maximum of 100 settings can be added' };
|
package/src/start.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { AceBaseServer } from './server';
|
|
2
|
-
import { AceBaseServerSettings } from './settings';
|
|
3
|
-
|
|
4
|
-
// If one executes "node start.js [dbname=name] [host=ip] [port=nr]"
|
|
5
|
-
function getVariable(name: string, defaultValue?: any) {
|
|
6
|
-
// Checks if an argument with the name was passed,
|
|
7
|
-
// or if an environment variable was set with that name,
|
|
8
|
-
// else it will return the default value
|
|
9
|
-
name = name.toUpperCase();
|
|
10
|
-
const arg = process.argv.find(arg => arg.toUpperCase().startsWith(`${name}=`));
|
|
11
|
-
if (arg) { return arg.split('=')[1]; }
|
|
12
|
-
if (typeof process.env[name] !== 'undefined') { return process.env[name]; }
|
|
13
|
-
return defaultValue;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
const path = getVariable('DBPATH', '.');
|
|
17
|
-
const dbname = getVariable('DBNAME', 'default');
|
|
18
|
-
const host = getVariable('HOST', 'localhost'); // '0.0.0.0'
|
|
19
|
-
const port = +getVariable('PORT', 3000);
|
|
20
|
-
const ipcPort = +getVariable('IPC_PORT', 0);
|
|
21
|
-
const options: AceBaseServerSettings = { host, port, path };
|
|
22
|
-
if (ipcPort > 0) {
|
|
23
|
-
const role = getVariable('IPC_ROLE');
|
|
24
|
-
if (!['master','worker'].includes(role)) {
|
|
25
|
-
throw new Error('IPC_ROLE must be either "master" or "worker"');
|
|
26
|
-
}
|
|
27
|
-
options.ipc = {
|
|
28
|
-
host: getVariable('IPC_HOST'),
|
|
29
|
-
port: ipcPort,
|
|
30
|
-
ssl: +getVariable('IPC_SSL', 0) === 1,
|
|
31
|
-
token: getVariable('IPC_TOKEN'),
|
|
32
|
-
role
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
if (+getVariable('TXLOG', 0) === 1) {
|
|
36
|
-
options.transactions = {
|
|
37
|
-
log: true,
|
|
38
|
-
maxAge: +getVariable('TXDAYS', 30)
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
if (+getVariable('AUTH', 1) === 0) {
|
|
42
|
-
options.authentication = { enabled: false };
|
|
43
|
-
}
|
|
44
|
-
const server = new AceBaseServer(dbname, options);
|
|
45
|
-
server.once("ready", () => {
|
|
46
|
-
server.debug.log(`AceBase server running`);
|
|
47
|
-
process.send?.('ready'); // When using pm2, you can use --wait-ready flag (see https://pm2.keymetrics.io/docs/usage/signals-clean-restart/)
|
|
48
|
-
});
|
package/src/test.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
// Starts a test server for debugging sessions
|
|
2
|
-
import { AceBaseServer } from './server';
|
|
3
|
-
|
|
4
|
-
// Make sure development environment is set
|
|
5
|
-
process.env.NODE_ENV = 'development';
|
|
6
|
-
|
|
7
|
-
const server = new AceBaseServer('default', { logLevel: 'verbose', host: 'localhost', port: 3000, path: '.' });
|
|
8
|
-
server.once('ready', () => {
|
|
9
|
-
console.log(`Ready to debug!`);
|
|
10
|
-
});
|