acebase-server 1.15.2 → 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 +10 -5
- 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
|
@@ -19,7 +19,7 @@ const socketSignInFailed = `<html><script>window.close()</script><body>Failed to
|
|
|
19
19
|
const addRoute = (env) => {
|
|
20
20
|
env.app.get(`/oauth2/${env.db.name}/signin`, (req, res) => __awaiter(void 0, void 0, void 0, function* () {
|
|
21
21
|
// This is where the user is redirected to by the provider after signin or error
|
|
22
|
-
var _a, _b;
|
|
22
|
+
var _a, _b, _c;
|
|
23
23
|
const LOG_ACTION = 'oauth2.signin';
|
|
24
24
|
const LOG_DETAILS = { ip: req.ip, provider: null };
|
|
25
25
|
try {
|
|
@@ -41,13 +41,13 @@ const addRoute = (env) => {
|
|
|
41
41
|
LOG_DETAILS.provider = state.provider;
|
|
42
42
|
// Get access & refresh tokens
|
|
43
43
|
const tokens = yield provider.getAccessToken({ type: 'auth', auth_code: authCode, redirect_url: `${req.protocol}://${req.headers.host}/oauth2/${env.db.name}/signin` });
|
|
44
|
-
let user_details;
|
|
44
|
+
// let user_details;
|
|
45
45
|
// TODO: Have we got an id_token?
|
|
46
46
|
// if (tokens.id_token) {
|
|
47
47
|
// // decode, extract user information
|
|
48
48
|
// }
|
|
49
49
|
// else {
|
|
50
|
-
user_details = yield provider.getUserInfo(tokens.access_token);
|
|
50
|
+
const user_details = yield provider.getUserInfo(tokens.access_token);
|
|
51
51
|
// }
|
|
52
52
|
if (user_details.picture && user_details.picture.length > 0) {
|
|
53
53
|
// Download it, convert to base64
|
|
@@ -55,13 +55,13 @@ const addRoute = (env) => {
|
|
|
55
55
|
try {
|
|
56
56
|
const response = yield (0, simple_fetch_1.fetch)(best.url);
|
|
57
57
|
const contentType = response.headers.get('Content-Type');
|
|
58
|
-
if (contentType === 'image/png') { //state.provider === 'google' &&
|
|
58
|
+
if (contentType === 'image/png') { //state.provider === 'google' &&
|
|
59
59
|
// Don't accept image/png, because it's probably a placeholder image. Google does this by creating a png with people's initials
|
|
60
60
|
user_details.picture = [];
|
|
61
61
|
}
|
|
62
62
|
else {
|
|
63
63
|
const image = yield response.arrayBuffer();
|
|
64
|
-
|
|
64
|
+
const buff = Buffer.from(image);
|
|
65
65
|
best.url = `data:${contentType};base64,${buff.toString('base64')}`;
|
|
66
66
|
user_details.picture = [best]; // Only keep the best one
|
|
67
67
|
}
|
|
@@ -93,15 +93,15 @@ const addRoute = (env) => {
|
|
|
93
93
|
// Use the signed in uid to link this account to. This allows multiple auth provider
|
|
94
94
|
// accounts (with different email addresses) to be linked to the account the user
|
|
95
95
|
// is signed into, and also allows multiple AceBase users to link to the same provider
|
|
96
|
-
// accounts, eg if a client app allows users to link their own account to a shared
|
|
96
|
+
// accounts, eg if a client app allows users to link their own account to a shared
|
|
97
97
|
// family Spotify / Dropbox account.
|
|
98
|
-
|
|
98
|
+
const snap = yield env.authRef.child(state.uid).get();
|
|
99
99
|
if (!snap.exists()) {
|
|
100
100
|
// This is wrong!
|
|
101
101
|
throw new Error(`Invalid uid`);
|
|
102
102
|
}
|
|
103
103
|
snaps = [snap];
|
|
104
|
-
|
|
104
|
+
const user = snap.val();
|
|
105
105
|
addToExistingAccount = user.email === user_details.email;
|
|
106
106
|
}
|
|
107
107
|
else {
|
|
@@ -117,8 +117,8 @@ const addRoute = (env) => {
|
|
|
117
117
|
snaps = yield query.get();
|
|
118
118
|
}
|
|
119
119
|
if (snaps.length === 0 && user_details.email) {
|
|
120
|
-
// Try again with providerUsername, use might previously have denied access to email,
|
|
121
|
-
// and now has granted access. In that case, we'll already have an account with the
|
|
120
|
+
// Try again with providerUsername, use might previously have denied access to email,
|
|
121
|
+
// and now has granted access. In that case, we'll already have an account with the
|
|
122
122
|
// generated providerUsername
|
|
123
123
|
snaps = yield env.authRef.query().filter('username', '==', providerUsername).get();
|
|
124
124
|
}
|
|
@@ -131,7 +131,7 @@ const addRoute = (env) => {
|
|
|
131
131
|
// Update user details
|
|
132
132
|
user.email_verified = user.email_verified || user_details.email_verified;
|
|
133
133
|
user.email = user.email || user_details.email;
|
|
134
|
-
if (user_details.picture
|
|
134
|
+
if (((_a = user_details.picture) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
135
135
|
user.picture = user_details.picture[0];
|
|
136
136
|
}
|
|
137
137
|
yield env.authRef.child(uid).update({
|
|
@@ -139,7 +139,7 @@ const addRoute = (env) => {
|
|
|
139
139
|
email_verified: user.email_verified,
|
|
140
140
|
last_signin: new Date(),
|
|
141
141
|
last_signin_ip: req.ip,
|
|
142
|
-
picture: user.picture
|
|
142
|
+
picture: user.picture,
|
|
143
143
|
});
|
|
144
144
|
}
|
|
145
145
|
// Add provider details
|
|
@@ -156,15 +156,15 @@ const addRoute = (env) => {
|
|
|
156
156
|
username: user.username,
|
|
157
157
|
email: user.email,
|
|
158
158
|
displayName: user.display_name,
|
|
159
|
-
settings: user.settings
|
|
159
|
+
settings: user.settings,
|
|
160
160
|
},
|
|
161
161
|
date: user.created,
|
|
162
162
|
ip: req.ip,
|
|
163
163
|
activationCode: user.email_verified ? null : (0, tokens_1.createSignedPublicToken)({ uid: user.uid }, env.tokenSalt),
|
|
164
164
|
emailVerified: user.email_verified,
|
|
165
|
-
provider: state.provider
|
|
165
|
+
provider: state.provider,
|
|
166
166
|
};
|
|
167
|
-
(
|
|
167
|
+
(_b = env.config.email) === null || _b === void 0 ? void 0 : _b.send(request).catch(err => {
|
|
168
168
|
env.log.error(LOG_ACTION + '.email', 'unexpected', Object.assign(Object.assign({}, LOG_DETAILS), { uid, request }), err);
|
|
169
169
|
});
|
|
170
170
|
}
|
|
@@ -176,7 +176,7 @@ const addRoute = (env) => {
|
|
|
176
176
|
return res.send({ code: 'admin_only', message: 'Only admin is allowed to create users' });
|
|
177
177
|
}
|
|
178
178
|
// Create user with Generated password
|
|
179
|
-
|
|
179
|
+
const pwd = (0, password_1.createPasswordHash)((0, password_1.generatePassword)());
|
|
180
180
|
user = {
|
|
181
181
|
uid: null,
|
|
182
182
|
username: typeof user_details.email === 'undefined' ? providerUsername : null,
|
|
@@ -192,7 +192,7 @@ const addRoute = (env) => {
|
|
|
192
192
|
last_signin: new Date(),
|
|
193
193
|
last_signin_ip: req.ip,
|
|
194
194
|
picture: user_details.picture && user_details.picture[0],
|
|
195
|
-
settings: getProviderSettings()
|
|
195
|
+
settings: getProviderSettings(),
|
|
196
196
|
};
|
|
197
197
|
const userRef = yield env.authRef.push(user);
|
|
198
198
|
const uid = userRef.key;
|
|
@@ -209,15 +209,15 @@ const addRoute = (env) => {
|
|
|
209
209
|
username: user.username,
|
|
210
210
|
email: user.email,
|
|
211
211
|
displayName: user.display_name,
|
|
212
|
-
settings: user.settings
|
|
212
|
+
settings: user.settings,
|
|
213
213
|
},
|
|
214
214
|
date: user.created,
|
|
215
215
|
ip: user.created_ip,
|
|
216
216
|
activationCode: user.email_verified ? null : (0, tokens_1.createSignedPublicToken)({ uid: user.uid }, env.tokenSalt),
|
|
217
217
|
emailVerified: user.email_verified,
|
|
218
|
-
provider: state.provider
|
|
218
|
+
provider: state.provider,
|
|
219
219
|
};
|
|
220
|
-
(
|
|
220
|
+
(_c = env.config.email) === null || _c === void 0 ? void 0 : _c.send(request).catch(err => {
|
|
221
221
|
env.log.error(LOG_ACTION + '.email', 'unexpected', Object.assign(Object.assign({}, LOG_DETAILS), { uid, request }), err);
|
|
222
222
|
});
|
|
223
223
|
}
|
|
@@ -233,16 +233,16 @@ const addRoute = (env) => {
|
|
|
233
233
|
return res.redirect(callbackUrl);
|
|
234
234
|
}
|
|
235
235
|
}
|
|
236
|
-
|
|
236
|
+
const result = {
|
|
237
237
|
provider: {
|
|
238
238
|
name: state.provider,
|
|
239
239
|
access_token: tokens.access_token,
|
|
240
240
|
refresh_token: tokens.refresh_token,
|
|
241
|
-
expires_in: tokens.expires_in
|
|
241
|
+
expires_in: tokens.expires_in,
|
|
242
242
|
},
|
|
243
243
|
access_token: (0, tokens_1.createPublicAccessToken)(user.uid, req.ip, user.access_token, env.tokenSalt),
|
|
244
244
|
// Disabled sending user details because:
|
|
245
|
-
// 1) they might be too big to send as redirect header,
|
|
245
|
+
// 1) they might be too big to send as redirect header,
|
|
246
246
|
// 2) client should verify the sent access token and get user details from the server
|
|
247
247
|
// user: getPublicAccountDetails(user)
|
|
248
248
|
};
|
|
@@ -4,14 +4,14 @@ exports.addRoutes = void 0;
|
|
|
4
4
|
const rootpath_1 = require("../shared/rootpath");
|
|
5
5
|
const path_1 = require("path");
|
|
6
6
|
const addRoutes = (env) => {
|
|
7
|
-
const webManagerDir =
|
|
7
|
+
const webManagerDir = `webmanager`;
|
|
8
8
|
// Add redirect from root to webmanager
|
|
9
9
|
env.app.get('/', (req, res) => {
|
|
10
|
-
res.redirect(webManagerDir);
|
|
10
|
+
res.redirect(`/${env.rootPath ? `${env.rootPath}/` : ''}${webManagerDir}/`);
|
|
11
11
|
});
|
|
12
12
|
// Serve static files from webmanager directory
|
|
13
|
-
env.app.get(
|
|
14
|
-
const filePath = req.path.slice(webManagerDir.length);
|
|
13
|
+
env.app.get(`/${webManagerDir}/*`, (req, res) => {
|
|
14
|
+
const filePath = req.path.slice(webManagerDir.length + 2);
|
|
15
15
|
const assetsPath = (0, path_1.join)(rootpath_1.packageRootPath, '/webmanager');
|
|
16
16
|
if (filePath.length === 0) {
|
|
17
17
|
// Send default file
|
package/dist/cjs/rules.js
CHANGED
|
@@ -41,9 +41,9 @@ class PathBasedRules {
|
|
|
41
41
|
})(defaultAccess);
|
|
42
42
|
const defaultRules = {
|
|
43
43
|
rules: {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
44
|
+
'.read': defaultAccessRule,
|
|
45
|
+
'.write': defaultAccessRule,
|
|
46
|
+
},
|
|
47
47
|
};
|
|
48
48
|
let accessRules = defaultRules;
|
|
49
49
|
if (!fs.existsSync(rulesFilePath)) {
|
|
@@ -112,20 +112,20 @@ class PathBasedRules {
|
|
|
112
112
|
return allow;
|
|
113
113
|
}
|
|
114
114
|
else if (path.startsWith('__')) {
|
|
115
|
-
// NEW: with the auth database now integrated into the main database,
|
|
115
|
+
// NEW: with the auth database now integrated into the main database,
|
|
116
116
|
// deny access to private resources starting with '__' for non-admins
|
|
117
117
|
return { allow: false, code: 'private', message: `Access to private resource "${path}" not allowed` };
|
|
118
118
|
}
|
|
119
|
-
const env = { now: Date.now(), auth: user || null }; // IDEA: Add functions like "exists" and "value". These will be async (so that requires refactoring) and can be used like "await exists('./shared/' + auth.uid)" and "await value('./writable') === true"
|
|
119
|
+
const env = { now: Date.now(), auth: user || null }; // IDEA: Add functions like "exists" and "value". These will be async (so that requires refactoring) and can be used like "await exists('./shared/' + auth.uid)" and "await value('./writable') === true"
|
|
120
120
|
const pathKeys = acebase_core_1.PathInfo.getPathKeys(path);
|
|
121
121
|
let rule = this.accessRules.rules;
|
|
122
|
-
|
|
122
|
+
const rulePath = [];
|
|
123
123
|
while (true) {
|
|
124
124
|
if (!rule) {
|
|
125
125
|
// TODO: check if this one is redundant with the pathKeys.length === 0 near the end
|
|
126
126
|
return { allow: false, code: 'no_rule', message: `No rules set for requested path "${path}", defaulting to false` };
|
|
127
127
|
}
|
|
128
|
-
|
|
128
|
+
const checkRule = write ? rule['.write'] : rule['.read'];
|
|
129
129
|
if (typeof checkRule === 'boolean') {
|
|
130
130
|
if (!checkRule) {
|
|
131
131
|
return { allow: false, code: 'rule', message: `Access denied to path "${path}" by set rule`, rule: checkRule, rulePath: rulePath.join('/') };
|
|
@@ -149,7 +149,7 @@ class PathBasedRules {
|
|
|
149
149
|
return { allow: false, code: 'no_rule', message: `No rule found for path ${path}` };
|
|
150
150
|
}
|
|
151
151
|
let nextKey = pathKeys.shift();
|
|
152
|
-
// if nextKey is '*' or '$something', rule[nextKey] will be undefined (or match a variable) so there is no
|
|
152
|
+
// if nextKey is '*' or '$something', rule[nextKey] will be undefined (or match a variable) so there is no
|
|
153
153
|
// need to change things here for usage of wildcard paths in subscriptions
|
|
154
154
|
if (typeof rule[nextKey] === 'undefined') {
|
|
155
155
|
// Check if current rule has a wildcard child
|
package/dist/cjs/schema/user.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getPublicAccountDetails = void 0;
|
|
4
|
-
;
|
|
5
4
|
const getPublicAccountDetails = (account) => {
|
|
6
5
|
var _a, _b, _c, _d, _e;
|
|
7
6
|
return {
|
|
@@ -19,7 +18,7 @@ const getPublicAccountDetails = (account) => {
|
|
|
19
18
|
changePassword: account.change_password,
|
|
20
19
|
changePasswordRequested: (_d = account.change_password_requested) === null || _d === void 0 ? void 0 : _d.toISOString(),
|
|
21
20
|
changePasswordBefore: (_e = account.change_password_before) === null || _e === void 0 ? void 0 : _e.toISOString(),
|
|
22
|
-
settings: account.settings
|
|
21
|
+
settings: account.settings,
|
|
23
22
|
};
|
|
24
23
|
};
|
|
25
24
|
exports.getPublicAccountDetails = getPublicAccountDetails;
|
package/dist/cjs/server.js
CHANGED
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.AceBaseServer = exports.AceBaseServerNotReadyError = void 0;
|
|
12
|
+
exports.AceBaseServer = exports.AceBaseExternalServerError = exports.AceBaseServerNotReadyError = void 0;
|
|
13
13
|
const acebase_core_1 = require("acebase-core");
|
|
14
14
|
const settings_1 = require("./settings");
|
|
15
15
|
const http_1 = require("./shared/http");
|
|
@@ -24,10 +24,8 @@ const cors_1 = require("./middleware/cors");
|
|
|
24
24
|
const auth_1 = require("./routes/auth");
|
|
25
25
|
const auth_2 = require("./auth");
|
|
26
26
|
const data_1 = require("./routes/data");
|
|
27
|
-
const docs_1 = require("./routes/docs");
|
|
28
27
|
const webmanager_1 = require("./routes/webmanager");
|
|
29
28
|
const meta_1 = require("./routes/meta");
|
|
30
|
-
const swagger_1 = require("./middleware/swagger");
|
|
31
29
|
const cache_1 = require("./middleware/cache");
|
|
32
30
|
const logger_1 = require("./logger");
|
|
33
31
|
// type PrivateLocalSettings = AceBaseLocalSettings & { storage: PrivateStorageSettings };
|
|
@@ -35,6 +33,10 @@ class AceBaseServerNotReadyError extends Error {
|
|
|
35
33
|
constructor() { super('Server is not ready yet'); }
|
|
36
34
|
}
|
|
37
35
|
exports.AceBaseServerNotReadyError = AceBaseServerNotReadyError;
|
|
36
|
+
class AceBaseExternalServerError extends Error {
|
|
37
|
+
constructor() { super('This method is not available with an external server'); }
|
|
38
|
+
}
|
|
39
|
+
exports.AceBaseExternalServerError = AceBaseExternalServerError;
|
|
38
40
|
class AceBaseServer extends acebase_core_1.SimpleEventEmitter {
|
|
39
41
|
constructor(dbname, options) {
|
|
40
42
|
super();
|
|
@@ -62,6 +64,8 @@ class AceBaseServer extends acebase_core_1.SimpleEventEmitter {
|
|
|
62
64
|
},
|
|
63
65
|
transactions: this.config.transactions,
|
|
64
66
|
ipc: this.config.ipc,
|
|
67
|
+
sponsor: this.config.sponsor,
|
|
68
|
+
logColors: this.config.logColors,
|
|
65
69
|
};
|
|
66
70
|
this.db = new acebase_1.AceBase(dbname, dbOptions);
|
|
67
71
|
const otherDbsPath = `${this.config.path}/${this.db.name}.acebase`;
|
|
@@ -98,10 +102,10 @@ class AceBaseServer extends acebase_core_1.SimpleEventEmitter {
|
|
|
98
102
|
* Gets the url the server is running at
|
|
99
103
|
*/
|
|
100
104
|
get url() {
|
|
101
|
-
return `http${this.config.https.enabled ? 's' : ''}://${this.config.host}:${this.config.port}`;
|
|
105
|
+
return `http${this.config.https.enabled ? 's' : ''}://${this.config.host}:${this.config.port}/${this.config.rootPath}`;
|
|
102
106
|
}
|
|
103
107
|
init(env) {
|
|
104
|
-
var _a
|
|
108
|
+
var _a;
|
|
105
109
|
return __awaiter(this, void 0, void 0, function* () {
|
|
106
110
|
const config = this.config;
|
|
107
111
|
const db = this.db;
|
|
@@ -109,11 +113,12 @@ class AceBaseServer extends acebase_core_1.SimpleEventEmitter {
|
|
|
109
113
|
// Wait for databases to be ready to use
|
|
110
114
|
yield Promise.all([
|
|
111
115
|
db.ready(),
|
|
112
|
-
authDb === null || authDb === void 0 ? void 0 : authDb.ready()
|
|
116
|
+
authDb === null || authDb === void 0 ? void 0 : authDb.ready(),
|
|
113
117
|
]);
|
|
114
118
|
// Create http server
|
|
115
119
|
const app = this.app;
|
|
116
|
-
|
|
120
|
+
(_a = this.config.server) === null || _a === void 0 ? void 0 : _a.on('request', app);
|
|
121
|
+
const server = this.config.server || (config.https.enabled ? (0, https_1.createServer)(config.https, app) : (0, http_2.createServer)(app));
|
|
117
122
|
const clients = new Map();
|
|
118
123
|
const securityRef = authDb ? authDb === db ? db.ref('__auth__/security') : authDb.ref('security') : null;
|
|
119
124
|
const authRef = authDb ? authDb === db ? db.ref('__auth__/accounts') : authDb.ref('accounts') : null;
|
|
@@ -122,12 +127,14 @@ class AceBaseServer extends acebase_core_1.SimpleEventEmitter {
|
|
|
122
127
|
// Setup rules
|
|
123
128
|
const rulesFilePath = `${this.config.path}/${this.db.name}.acebase/rules.json`;
|
|
124
129
|
const rules = new rules_1.PathBasedRules(rulesFilePath, config.auth.defaultAccessRule, { db, debug: this.debug, authEnabled: this.config.auth.enabled });
|
|
130
|
+
const router = (0, http_1.createRouter)();
|
|
125
131
|
const routeEnv = {
|
|
126
132
|
config: this.config,
|
|
127
133
|
server,
|
|
128
134
|
db: db,
|
|
129
135
|
authDb,
|
|
130
|
-
app,
|
|
136
|
+
app: router,
|
|
137
|
+
rootPath: this.config.rootPath,
|
|
131
138
|
debug: this.debug,
|
|
132
139
|
securityRef,
|
|
133
140
|
authRef,
|
|
@@ -136,7 +143,7 @@ class AceBaseServer extends acebase_core_1.SimpleEventEmitter {
|
|
|
136
143
|
clients,
|
|
137
144
|
authCache: null,
|
|
138
145
|
authProviders: this.authProviders,
|
|
139
|
-
rules
|
|
146
|
+
rules,
|
|
140
147
|
};
|
|
141
148
|
// Add connection middleware
|
|
142
149
|
const killConnections = (0, connection_1.default)(routeEnv);
|
|
@@ -155,10 +162,10 @@ class AceBaseServer extends acebase_core_1.SimpleEventEmitter {
|
|
|
155
162
|
// Add metadata endpoints
|
|
156
163
|
(0, meta_1.default)(routeEnv);
|
|
157
164
|
// If environment is development, add API docs
|
|
158
|
-
if (
|
|
165
|
+
if (process.env.NODE_ENV && process.env.NODE_ENV.trim() === 'development') {
|
|
159
166
|
this.debug.warn('DEVELOPMENT MODE: adding API docs endpoint at /docs');
|
|
160
|
-
(
|
|
161
|
-
(
|
|
167
|
+
(yield Promise.resolve().then(() => require('./routes/docs'))).addRoute(routeEnv);
|
|
168
|
+
(yield Promise.resolve().then(() => require('./middleware/swagger'))).addMiddleware(routeEnv);
|
|
162
169
|
}
|
|
163
170
|
// Add data endpoints
|
|
164
171
|
(0, data_1.default)(routeEnv);
|
|
@@ -172,19 +179,26 @@ class AceBaseServer extends acebase_core_1.SimpleEventEmitter {
|
|
|
172
179
|
};
|
|
173
180
|
// Create websocket server
|
|
174
181
|
(0, websocket_1.addWebsocketServer)(routeEnv);
|
|
182
|
+
// Register all the routes for the app
|
|
183
|
+
app.use(`/${this.config.rootPath}`, router);
|
|
175
184
|
// Last but not least, add 404 handler
|
|
176
185
|
// DISABLED because it causes server extension routes through server.extend (see above) not be be executed
|
|
177
186
|
// add404Middleware(routeEnv);
|
|
178
|
-
// Start listening
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
187
|
+
// Start listening, if no external server
|
|
188
|
+
if (!this.config.server) {
|
|
189
|
+
server.listen(config.port, config.host, () => {
|
|
190
|
+
// Ready!!
|
|
191
|
+
this.debug.log(`"${db.name}" database server running at ${this.url}`);
|
|
192
|
+
this._ready = true;
|
|
193
|
+
this.emitOnce(`ready`);
|
|
194
|
+
});
|
|
195
|
+
}
|
|
185
196
|
// Setup pause and resume methods
|
|
186
197
|
let paused = false;
|
|
187
198
|
this.pause = () => __awaiter(this, void 0, void 0, function* () {
|
|
199
|
+
if (this.config.server) {
|
|
200
|
+
throw new AceBaseExternalServerError();
|
|
201
|
+
}
|
|
188
202
|
if (paused) {
|
|
189
203
|
throw new Error('Server is already paused');
|
|
190
204
|
}
|
|
@@ -194,6 +208,9 @@ class AceBaseServer extends acebase_core_1.SimpleEventEmitter {
|
|
|
194
208
|
paused = true;
|
|
195
209
|
});
|
|
196
210
|
this.resume = () => __awaiter(this, void 0, void 0, function* () {
|
|
211
|
+
if (this.config.server) {
|
|
212
|
+
throw new AceBaseExternalServerError();
|
|
213
|
+
}
|
|
197
214
|
if (!paused) {
|
|
198
215
|
throw new Error('Server is not paused');
|
|
199
216
|
}
|
|
@@ -232,36 +249,35 @@ class AceBaseServer extends acebase_core_1.SimpleEventEmitter {
|
|
|
232
249
|
// interval.unref();
|
|
233
250
|
server.close(err => {
|
|
234
251
|
if (err) {
|
|
235
|
-
|
|
252
|
+
this.debug.error(`server.close() error: ${err.message}`);
|
|
236
253
|
}
|
|
237
254
|
else {
|
|
238
|
-
|
|
255
|
+
this.debug.log(`server.close() success`);
|
|
239
256
|
}
|
|
240
257
|
resolve();
|
|
241
258
|
});
|
|
242
259
|
// If for some reason connection aren't broken in time - do proceed with shutdown sequence
|
|
243
260
|
const timeout = setTimeout(() => {
|
|
244
|
-
|
|
261
|
+
if (clients.size === 0) {
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
this.debug.warn(`server.close() timed out, there are still open connections`);
|
|
245
265
|
killConnections();
|
|
246
|
-
// resolve();
|
|
247
266
|
}, 5000);
|
|
248
267
|
timeout.unref();
|
|
249
|
-
|
|
268
|
+
this.debug.log(`Closing ${clients.size} websocket connections`);
|
|
250
269
|
clients.forEach((client, id) => {
|
|
251
270
|
const socket = client.socket;
|
|
252
271
|
socket.once('disconnect', reason => {
|
|
253
|
-
|
|
272
|
+
this.debug.log(`Socket ${socket.id} disconnected: ${reason}`);
|
|
254
273
|
});
|
|
255
274
|
socket.disconnect(true);
|
|
256
275
|
});
|
|
257
|
-
// clients.list.slice().forEach(client => {
|
|
258
|
-
// client.socket.disconnect(true);
|
|
259
|
-
// });
|
|
260
276
|
});
|
|
261
277
|
this.debug.warn('closing database');
|
|
262
278
|
yield db.close();
|
|
263
279
|
this.debug.warn('shutdown complete');
|
|
264
|
-
// Emit events to let the outside world know we shut down.
|
|
280
|
+
// Emit events to let the outside world know we shut down.
|
|
265
281
|
// This is especially important if this instance was running in a Node.js cluster: the process will
|
|
266
282
|
// not exit automatically after this shutdown because Node.js' IPC channel between worker and master is still open.
|
|
267
283
|
// By sending these events, the cluster manager can determine if it should (and when to) execute process.exit()
|
|
@@ -275,8 +291,35 @@ class AceBaseServer extends acebase_core_1.SimpleEventEmitter {
|
|
|
275
291
|
}
|
|
276
292
|
this.emit('shutdown'); // Emit on AceBaseServer instance
|
|
277
293
|
});
|
|
278
|
-
this.shutdown = () => __awaiter(this, void 0, void 0, function* () {
|
|
279
|
-
|
|
294
|
+
this.shutdown = () => __awaiter(this, void 0, void 0, function* () {
|
|
295
|
+
if (this.config.server) {
|
|
296
|
+
throw new AceBaseExternalServerError();
|
|
297
|
+
}
|
|
298
|
+
yield shutdown({ sigint: false });
|
|
299
|
+
});
|
|
300
|
+
// Offload shutdown control to an external server
|
|
301
|
+
if (this.config.server) {
|
|
302
|
+
server.on('close', function close() {
|
|
303
|
+
server.off('request', app);
|
|
304
|
+
server.off('close', close);
|
|
305
|
+
shutdown({ sigint: false });
|
|
306
|
+
});
|
|
307
|
+
const ready = () => {
|
|
308
|
+
this.debug.log(`"${db.name}" database server running at ${this.url}`);
|
|
309
|
+
this._ready = true;
|
|
310
|
+
this.emitOnce(`ready`);
|
|
311
|
+
server.off('listening', ready);
|
|
312
|
+
};
|
|
313
|
+
if (server.listening) {
|
|
314
|
+
ready();
|
|
315
|
+
}
|
|
316
|
+
else {
|
|
317
|
+
server.on('listening', ready);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
else {
|
|
321
|
+
process.on('SIGINT', () => shutdown({ sigint: true }));
|
|
322
|
+
}
|
|
280
323
|
});
|
|
281
324
|
}
|
|
282
325
|
/**
|
|
@@ -5,7 +5,7 @@ const fs_1 = require("fs");
|
|
|
5
5
|
class AceBaseServerHttpsConfig {
|
|
6
6
|
constructor(settings) {
|
|
7
7
|
this.enabled = true;
|
|
8
|
-
this.enabled = typeof settings ===
|
|
8
|
+
this.enabled = typeof settings === 'object' && settings.enabled !== false;
|
|
9
9
|
if (!this.enabled) {
|
|
10
10
|
return;
|
|
11
11
|
}
|
|
@@ -23,7 +23,7 @@ exports.AceBaseServerHttpsConfig = AceBaseServerHttpsConfig;
|
|
|
23
23
|
exports.AUTH_ACCESS_DEFAULT = {
|
|
24
24
|
DENY_ALL: 'deny',
|
|
25
25
|
ALLOW_ALL: 'allow',
|
|
26
|
-
ALLOW_AUTHENTICATED: 'auth'
|
|
26
|
+
ALLOW_AUTHENTICATED: 'auth',
|
|
27
27
|
};
|
|
28
28
|
class AceBaseServerAuthenticationSettings {
|
|
29
29
|
constructor(settings) {
|
|
@@ -51,7 +51,7 @@ class AceBaseServerAuthenticationSettings {
|
|
|
51
51
|
* Whether to use a separate database for auth and logging. 'v2' will store data in auth.db, which is NOT TESTED YET!
|
|
52
52
|
*/
|
|
53
53
|
this.separateDb = false;
|
|
54
|
-
if (typeof settings !==
|
|
54
|
+
if (typeof settings !== 'object') {
|
|
55
55
|
settings = {};
|
|
56
56
|
}
|
|
57
57
|
if (typeof settings.enabled === 'boolean') {
|
|
@@ -121,7 +121,10 @@ class AceBaseServerConfig {
|
|
|
121
121
|
this.path = '.';
|
|
122
122
|
this.maxPayloadSize = '10mb';
|
|
123
123
|
this.allowOrigin = '*';
|
|
124
|
-
|
|
124
|
+
this.rootPath = '';
|
|
125
|
+
this.sponsor = false;
|
|
126
|
+
this.logColors = true;
|
|
127
|
+
if (typeof settings !== 'object') {
|
|
125
128
|
settings = {};
|
|
126
129
|
}
|
|
127
130
|
if (typeof settings.logLevel === 'string') {
|
|
@@ -136,6 +139,12 @@ class AceBaseServerConfig {
|
|
|
136
139
|
if (typeof settings.path === 'string') {
|
|
137
140
|
this.path = settings.path;
|
|
138
141
|
}
|
|
142
|
+
if (typeof settings.server === 'object') {
|
|
143
|
+
this.server = settings.server;
|
|
144
|
+
}
|
|
145
|
+
if (typeof settings.rootPath === 'string') {
|
|
146
|
+
this.rootPath = settings.rootPath.replace(/^\/|\/$/g, '');
|
|
147
|
+
}
|
|
139
148
|
this.https = new AceBaseServerHttpsConfig(settings.https);
|
|
140
149
|
this.auth = new AceBaseServerAuthenticationSettings(settings.authentication);
|
|
141
150
|
if (typeof settings.maxPayloadSize === 'string') {
|
|
@@ -152,6 +161,12 @@ class AceBaseServerConfig {
|
|
|
152
161
|
if (typeof settings.storage === 'object') {
|
|
153
162
|
this.storage = settings.storage;
|
|
154
163
|
}
|
|
164
|
+
if (typeof settings.sponsor === 'boolean') {
|
|
165
|
+
this.sponsor = settings.sponsor;
|
|
166
|
+
}
|
|
167
|
+
if (typeof settings.logColors === 'boolean') {
|
|
168
|
+
this.logColors = settings.logColors;
|
|
169
|
+
}
|
|
155
170
|
}
|
|
156
171
|
}
|
|
157
172
|
exports.AceBaseServerConfig = AceBaseServerConfig;
|
package/dist/cjs/shared/email.js
CHANGED
package/dist/cjs/shared/env.js
CHANGED
package/dist/cjs/shared/error.js
CHANGED
|
@@ -13,7 +13,6 @@ const sendUnauthorizedError = (res, code, message) => {
|
|
|
13
13
|
res.contentType('application/json').send({ code, message });
|
|
14
14
|
};
|
|
15
15
|
exports.sendUnauthorizedError = sendUnauthorizedError;
|
|
16
|
-
;
|
|
17
16
|
const sendError = (res, err) => {
|
|
18
17
|
res.contentType('application/json');
|
|
19
18
|
if (typeof err.code === 'string') {
|
package/dist/cjs/shared/http.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var _a;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.createApp = void 0;
|
|
4
|
+
exports.createRouter = exports.createApp = void 0;
|
|
5
5
|
const express = require("express");
|
|
6
6
|
const createExpress = (_a = express.default) !== null && _a !== void 0 ? _a : express; // ESM and CJS compatible approach
|
|
7
7
|
/**
|
|
@@ -18,4 +18,12 @@ const createApp = (settings) => {
|
|
|
18
18
|
return app;
|
|
19
19
|
};
|
|
20
20
|
exports.createApp = createApp;
|
|
21
|
+
/**
|
|
22
|
+
* Creates an express router
|
|
23
|
+
* @returns
|
|
24
|
+
*/
|
|
25
|
+
const createRouter = () => {
|
|
26
|
+
return createExpress.Router();
|
|
27
|
+
};
|
|
28
|
+
exports.createRouter = createRouter;
|
|
21
29
|
//# sourceMappingURL=http.js.map
|
|
@@ -16,12 +16,12 @@ exports.generatePassword = generatePassword;
|
|
|
16
16
|
* @param password password to hash
|
|
17
17
|
*/
|
|
18
18
|
const createPasswordHash = (password) => {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
const length = 16;
|
|
20
|
+
const salt = crypto.randomBytes(Math.ceil(length / 2)).toString('hex').slice(0, length);
|
|
21
|
+
const hash = crypto.createHmac('sha512', salt).update(password).digest('hex');
|
|
22
22
|
return {
|
|
23
23
|
salt,
|
|
24
|
-
hash
|
|
24
|
+
hash,
|
|
25
25
|
};
|
|
26
26
|
};
|
|
27
27
|
exports.createPasswordHash = createPasswordHash;
|
|
@@ -38,7 +38,7 @@ exports.getPasswordHash = getPasswordHash;
|
|
|
38
38
|
* Backward compatibility with old saltless md5 passwords. Becomes obsolete once all passwords have been updated (probably already so)
|
|
39
39
|
*/
|
|
40
40
|
const getOldPasswordHash = (password) => {
|
|
41
|
-
// Backward compatibility with old saltless md5 passwords.
|
|
41
|
+
// Backward compatibility with old saltless md5 passwords.
|
|
42
42
|
// Becomes obsolete once all passwords have been updated
|
|
43
43
|
return crypto.createHash('md5').update(password).digest('hex');
|
|
44
44
|
};
|
|
@@ -10,7 +10,7 @@ if (process.platform === 'win32' && currentDir.startsWith('/')) {
|
|
|
10
10
|
// 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
|
|
11
11
|
currentDir = currentDir.slice(1);
|
|
12
12
|
}
|
|
13
|
-
// tsc-esm-fix also does not use decodeURI to remove encoded characters (such as %20 for spaces)
|
|
13
|
+
// tsc-esm-fix also does not use decodeURI to remove encoded characters (such as %20 for spaces)
|
|
14
14
|
currentDir = decodeURI(currentDir);
|
|
15
15
|
exports.packageRootPath = (0, path_1.resolve)(currentDir, '../../..');
|
|
16
16
|
exports.default = exports.packageRootPath;
|