acebase-server 1.13.2 → 1.14.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/create-package-files +25 -0
- package/dist/cjs/auth.js.map +1 -0
- package/dist/cjs/cluster.js.map +1 -0
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/logger.js.map +1 -0
- package/dist/cjs/middleware/404.js.map +1 -0
- package/dist/cjs/middleware/admin-only.js.map +1 -0
- package/dist/cjs/middleware/cache.js.map +1 -0
- package/dist/cjs/middleware/connection.js.map +1 -0
- package/dist/cjs/middleware/context.js.map +1 -0
- package/dist/cjs/middleware/cors.js.map +1 -0
- package/dist/cjs/middleware/swagger.js.map +1 -0
- package/dist/cjs/middleware/user.js.map +1 -0
- package/dist/cjs/oauth-providers/dropbox.js.map +1 -0
- package/dist/cjs/oauth-providers/facebook.js.map +1 -0
- package/dist/cjs/oauth-providers/google.js.map +1 -0
- package/dist/cjs/oauth-providers/index.js.map +1 -0
- package/dist/cjs/oauth-providers/instagram.js.map +1 -0
- package/dist/cjs/oauth-providers/oauth-provider.js.map +1 -0
- package/dist/cjs/oauth-providers/spotify.js.map +1 -0
- package/dist/cjs/routes/auth-change-password.js.map +1 -0
- package/dist/cjs/routes/auth-delete.js.map +1 -0
- package/dist/cjs/routes/auth-forgot-password.js.map +1 -0
- package/dist/cjs/routes/auth-reset-password.js.map +1 -0
- package/dist/cjs/routes/auth-signin.js.map +1 -0
- package/dist/cjs/routes/auth-signout.js.map +1 -0
- package/dist/cjs/routes/auth-signup.js.map +1 -0
- package/dist/cjs/routes/auth-state.js.map +1 -0
- package/dist/cjs/routes/auth-update.js.map +1 -0
- package/dist/cjs/routes/auth-verify-email.js.map +1 -0
- package/dist/cjs/routes/auth.js.map +1 -0
- package/dist/cjs/routes/data-exists.js.map +1 -0
- package/dist/cjs/routes/data-export.js.map +1 -0
- package/dist/cjs/routes/data-get.js.map +1 -0
- package/dist/cjs/routes/data-import.js.map +1 -0
- package/dist/cjs/routes/data-index-create.js.map +1 -0
- package/dist/cjs/routes/data-index-delete.js.map +1 -0
- package/dist/cjs/routes/data-index-list.js.map +1 -0
- package/dist/cjs/routes/data-query.js.map +1 -0
- package/dist/cjs/routes/data-reflect.js.map +1 -0
- package/dist/cjs/routes/data-schema-get.js.map +1 -0
- package/dist/cjs/routes/data-schema-set.js.map +1 -0
- package/dist/cjs/routes/data-schema-test.js.map +1 -0
- package/dist/cjs/routes/data-schemas-list.js.map +1 -0
- package/dist/cjs/routes/data-set.js.map +1 -0
- package/dist/cjs/routes/data-sync-changes.js.map +1 -0
- package/dist/cjs/routes/data-sync-mutations.js.map +1 -0
- package/dist/cjs/routes/data-transaction.js.map +1 -0
- package/dist/cjs/routes/data-update.js.map +1 -0
- package/dist/cjs/routes/data.js.map +1 -0
- package/dist/cjs/routes/docs.js.map +1 -0
- package/dist/cjs/routes/meta-info.js.map +1 -0
- package/dist/cjs/routes/meta-logs.js.map +1 -0
- package/dist/cjs/routes/meta-ping.js.map +1 -0
- package/dist/cjs/routes/meta-stats.js.map +1 -0
- package/dist/cjs/routes/meta.js.map +1 -0
- package/dist/cjs/routes/oauth2-init.js.map +1 -0
- package/dist/cjs/routes/oauth2-refresh.js.map +1 -0
- package/dist/cjs/routes/oauth2-signin.js.map +1 -0
- package/dist/cjs/routes/webmanager.js.map +1 -0
- package/dist/cjs/rules.js +2 -9
- package/dist/cjs/rules.js.map +1 -0
- package/dist/cjs/schema/user.js.map +1 -0
- package/dist/cjs/server.js +1 -1
- package/dist/cjs/server.js.map +1 -0
- package/dist/cjs/settings/email.js.map +1 -0
- package/dist/cjs/settings/index.js +1 -1
- package/dist/cjs/settings/index.js.map +1 -0
- package/dist/cjs/shared/clients.js.map +1 -0
- package/dist/cjs/shared/email.js.map +1 -0
- package/dist/cjs/shared/env.js.map +1 -0
- package/dist/cjs/shared/error.js.map +1 -0
- package/dist/cjs/shared/http.js.map +1 -0
- package/dist/cjs/shared/password.js.map +1 -0
- package/dist/cjs/shared/rootpath.js.map +1 -0
- package/dist/cjs/shared/signin.js.map +1 -0
- package/dist/cjs/shared/simple-fetch.js.map +1 -0
- package/dist/cjs/shared/tokens.js.map +1 -0
- package/dist/cjs/shared/validate.js.map +1 -0
- package/dist/cjs/start.js.map +1 -0
- package/dist/cjs/test.js.map +1 -0
- package/dist/cjs/websocket/index.js.map +1 -0
- package/dist/cjs/websocket/manager.js +1 -1
- package/dist/cjs/websocket/manager.js.map +1 -0
- package/dist/cjs/websocket/socket.io.js.map +1 -0
- package/dist/esm/auth.js.map +1 -0
- package/dist/esm/cluster.js.map +1 -0
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/logger.js.map +1 -0
- package/dist/esm/middleware/404.js.map +1 -0
- package/dist/esm/middleware/admin-only.js.map +1 -0
- package/dist/esm/middleware/cache.js.map +1 -0
- package/dist/esm/middleware/connection.js.map +1 -0
- package/dist/esm/middleware/context.js.map +1 -0
- package/dist/esm/middleware/cors.js.map +1 -0
- package/dist/esm/middleware/swagger.js.map +1 -0
- package/dist/esm/middleware/user.js.map +1 -0
- package/dist/esm/oauth-providers/dropbox.js.map +1 -0
- package/dist/esm/oauth-providers/facebook.js.map +1 -0
- package/dist/esm/oauth-providers/google.js.map +1 -0
- package/dist/esm/oauth-providers/index.js.map +1 -0
- package/dist/esm/oauth-providers/instagram.js.map +1 -0
- package/dist/esm/oauth-providers/oauth-provider.js.map +1 -0
- package/dist/esm/oauth-providers/spotify.js.map +1 -0
- package/dist/esm/routes/auth-change-password.js.map +1 -0
- package/dist/esm/routes/auth-delete.js.map +1 -0
- package/dist/esm/routes/auth-forgot-password.js.map +1 -0
- package/dist/esm/routes/auth-reset-password.js.map +1 -0
- package/dist/esm/routes/auth-signin.js.map +1 -0
- package/dist/esm/routes/auth-signout.js.map +1 -0
- package/dist/esm/routes/auth-signup.js.map +1 -0
- package/dist/esm/routes/auth-state.js.map +1 -0
- package/dist/esm/routes/auth-update.js.map +1 -0
- package/dist/esm/routes/auth-verify-email.js.map +1 -0
- package/dist/esm/routes/auth.js.map +1 -0
- package/dist/esm/routes/data-exists.js.map +1 -0
- package/dist/esm/routes/data-export.js.map +1 -0
- package/dist/esm/routes/data-get.js.map +1 -0
- package/dist/esm/routes/data-import.js.map +1 -0
- package/dist/esm/routes/data-index-create.js.map +1 -0
- package/dist/esm/routes/data-index-delete.js.map +1 -0
- package/dist/esm/routes/data-index-list.js.map +1 -0
- package/dist/esm/routes/data-query.js.map +1 -0
- package/dist/esm/routes/data-reflect.js.map +1 -0
- package/dist/esm/routes/data-schema-get.js.map +1 -0
- package/dist/esm/routes/data-schema-set.js.map +1 -0
- package/dist/esm/routes/data-schema-test.js.map +1 -0
- package/dist/esm/routes/data-schemas-list.js.map +1 -0
- package/dist/esm/routes/data-set.js.map +1 -0
- package/dist/esm/routes/data-sync-changes.js.map +1 -0
- package/dist/esm/routes/data-sync-mutations.js.map +1 -0
- package/dist/esm/routes/data-transaction.js.map +1 -0
- package/dist/esm/routes/data-update.js.map +1 -0
- package/dist/esm/routes/data.js.map +1 -0
- package/dist/esm/routes/docs.js.map +1 -0
- package/dist/esm/routes/meta-info.js.map +1 -0
- package/dist/esm/routes/meta-logs.js.map +1 -0
- package/dist/esm/routes/meta-ping.js.map +1 -0
- package/dist/esm/routes/meta-stats.js.map +1 -0
- package/dist/esm/routes/meta.js.map +1 -0
- package/dist/esm/routes/oauth2-init.js.map +1 -0
- package/dist/esm/routes/oauth2-refresh.js.map +1 -0
- package/dist/esm/routes/oauth2-signin.js.map +1 -0
- package/dist/esm/routes/webmanager.js.map +1 -0
- package/dist/esm/rules.js +2 -9
- package/dist/esm/rules.js.map +1 -0
- package/dist/esm/schema/user.js.map +1 -0
- package/dist/esm/server.js +1 -1
- package/dist/esm/server.js.map +1 -0
- package/dist/esm/settings/email.js.map +1 -0
- package/dist/esm/settings/index.js +1 -1
- package/dist/esm/settings/index.js.map +1 -0
- package/dist/esm/shared/clients.js.map +1 -0
- package/dist/esm/shared/email.js.map +1 -0
- package/dist/esm/shared/env.js.map +1 -0
- package/dist/esm/shared/error.js.map +1 -0
- package/dist/esm/shared/http.js.map +1 -0
- package/dist/esm/shared/password.js.map +1 -0
- package/dist/esm/shared/rootpath.js.map +1 -0
- package/dist/esm/shared/signin.js.map +1 -0
- package/dist/esm/shared/simple-fetch.js.map +1 -0
- package/dist/esm/shared/tokens.js.map +1 -0
- package/dist/esm/shared/validate.js.map +1 -0
- package/dist/esm/start.js.map +1 -0
- package/dist/esm/test.js.map +1 -0
- package/dist/esm/websocket/index.js.map +1 -0
- package/dist/esm/websocket/manager.js +1 -1
- package/dist/esm/websocket/manager.js.map +1 -0
- package/dist/esm/websocket/socket.io.js.map +1 -0
- package/dist/types/auth.d.ts +1 -0
- package/dist/types/auth.d.ts.map +1 -0
- package/dist/types/cluster.d.ts +1 -0
- package/dist/types/cluster.d.ts.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/logger.d.ts +1 -0
- package/dist/types/logger.d.ts.map +1 -0
- package/dist/types/middleware/404.d.ts +1 -0
- package/dist/types/middleware/404.d.ts.map +1 -0
- package/dist/types/middleware/admin-only.d.ts +1 -0
- package/dist/types/middleware/admin-only.d.ts.map +1 -0
- package/dist/types/middleware/cache.d.ts +1 -0
- package/dist/types/middleware/cache.d.ts.map +1 -0
- package/dist/types/middleware/connection.d.ts +1 -0
- package/dist/types/middleware/connection.d.ts.map +1 -0
- package/dist/types/middleware/context.d.ts +1 -0
- package/dist/types/middleware/context.d.ts.map +1 -0
- package/dist/types/middleware/cors.d.ts +1 -0
- package/dist/types/middleware/cors.d.ts.map +1 -0
- package/dist/types/middleware/swagger.d.ts +1 -0
- package/dist/types/middleware/swagger.d.ts.map +1 -0
- package/dist/types/middleware/user.d.ts +1 -0
- package/dist/types/middleware/user.d.ts.map +1 -0
- package/dist/types/oauth-providers/dropbox.d.ts +1 -0
- package/dist/types/oauth-providers/dropbox.d.ts.map +1 -0
- package/dist/types/oauth-providers/facebook.d.ts +1 -0
- package/dist/types/oauth-providers/facebook.d.ts.map +1 -0
- package/dist/types/oauth-providers/google.d.ts +1 -0
- package/dist/types/oauth-providers/google.d.ts.map +1 -0
- package/dist/types/oauth-providers/index.d.ts +1 -0
- package/dist/types/oauth-providers/index.d.ts.map +1 -0
- package/dist/types/oauth-providers/instagram.d.ts +1 -0
- package/dist/types/oauth-providers/instagram.d.ts.map +1 -0
- package/dist/types/oauth-providers/oauth-provider.d.ts +1 -0
- package/dist/types/oauth-providers/oauth-provider.d.ts.map +1 -0
- package/dist/types/oauth-providers/spotify.d.ts +1 -0
- package/dist/types/oauth-providers/spotify.d.ts.map +1 -0
- package/dist/types/routes/auth-change-password.d.ts +1 -0
- package/dist/types/routes/auth-change-password.d.ts.map +1 -0
- package/dist/types/routes/auth-delete.d.ts +1 -0
- package/dist/types/routes/auth-delete.d.ts.map +1 -0
- package/dist/types/routes/auth-forgot-password.d.ts +1 -0
- package/dist/types/routes/auth-forgot-password.d.ts.map +1 -0
- package/dist/types/routes/auth-reset-password.d.ts +1 -0
- package/dist/types/routes/auth-reset-password.d.ts.map +1 -0
- package/dist/types/routes/auth-signin.d.ts +1 -0
- package/dist/types/routes/auth-signin.d.ts.map +1 -0
- package/dist/types/routes/auth-signout.d.ts +1 -0
- package/dist/types/routes/auth-signout.d.ts.map +1 -0
- package/dist/types/routes/auth-signup.d.ts +1 -0
- package/dist/types/routes/auth-signup.d.ts.map +1 -0
- package/dist/types/routes/auth-state.d.ts +1 -0
- package/dist/types/routes/auth-state.d.ts.map +1 -0
- package/dist/types/routes/auth-update.d.ts +1 -0
- package/dist/types/routes/auth-update.d.ts.map +1 -0
- package/dist/types/routes/auth-verify-email.d.ts +1 -0
- package/dist/types/routes/auth-verify-email.d.ts.map +1 -0
- package/dist/types/routes/auth.d.ts +1 -0
- package/dist/types/routes/auth.d.ts.map +1 -0
- package/dist/types/routes/data-exists.d.ts +1 -0
- package/dist/types/routes/data-exists.d.ts.map +1 -0
- package/dist/types/routes/data-export.d.ts +1 -0
- package/dist/types/routes/data-export.d.ts.map +1 -0
- package/dist/types/routes/data-get.d.ts +3 -2
- package/dist/types/routes/data-get.d.ts.map +1 -0
- package/dist/types/routes/data-import.d.ts +1 -0
- package/dist/types/routes/data-import.d.ts.map +1 -0
- package/dist/types/routes/data-index-create.d.ts +1 -0
- package/dist/types/routes/data-index-create.d.ts.map +1 -0
- package/dist/types/routes/data-index-delete.d.ts +1 -0
- package/dist/types/routes/data-index-delete.d.ts.map +1 -0
- package/dist/types/routes/data-index-list.d.ts +1 -0
- package/dist/types/routes/data-index-list.d.ts.map +1 -0
- package/dist/types/routes/data-query.d.ts +1 -0
- package/dist/types/routes/data-query.d.ts.map +1 -0
- package/dist/types/routes/data-reflect.d.ts +1 -0
- package/dist/types/routes/data-reflect.d.ts.map +1 -0
- package/dist/types/routes/data-schema-get.d.ts +1 -0
- package/dist/types/routes/data-schema-get.d.ts.map +1 -0
- package/dist/types/routes/data-schema-set.d.ts +2 -1
- package/dist/types/routes/data-schema-set.d.ts.map +1 -0
- package/dist/types/routes/data-schema-test.d.ts +3 -4
- package/dist/types/routes/data-schema-test.d.ts.map +1 -0
- package/dist/types/routes/data-schemas-list.d.ts +1 -0
- package/dist/types/routes/data-schemas-list.d.ts.map +1 -0
- package/dist/types/routes/data-set.d.ts +3 -2
- package/dist/types/routes/data-set.d.ts.map +1 -0
- package/dist/types/routes/data-sync-changes.d.ts +2 -1
- package/dist/types/routes/data-sync-changes.d.ts.map +1 -0
- package/dist/types/routes/data-sync-mutations.d.ts +2 -1
- package/dist/types/routes/data-sync-mutations.d.ts.map +1 -0
- package/dist/types/routes/data-transaction.d.ts +3 -2
- package/dist/types/routes/data-transaction.d.ts.map +1 -0
- package/dist/types/routes/data-update.d.ts +3 -2
- package/dist/types/routes/data-update.d.ts.map +1 -0
- package/dist/types/routes/data.d.ts +1 -0
- package/dist/types/routes/data.d.ts.map +1 -0
- package/dist/types/routes/docs.d.ts +1 -0
- package/dist/types/routes/docs.d.ts.map +1 -0
- package/dist/types/routes/meta-info.d.ts +1 -0
- package/dist/types/routes/meta-info.d.ts.map +1 -0
- package/dist/types/routes/meta-logs.d.ts +2 -1
- package/dist/types/routes/meta-logs.d.ts.map +1 -0
- package/dist/types/routes/meta-ping.d.ts +1 -0
- package/dist/types/routes/meta-ping.d.ts.map +1 -0
- package/dist/types/routes/meta-stats.d.ts +1 -0
- package/dist/types/routes/meta-stats.d.ts.map +1 -0
- package/dist/types/routes/meta.d.ts +1 -0
- package/dist/types/routes/meta.d.ts.map +1 -0
- package/dist/types/routes/oauth2-init.d.ts +1 -0
- package/dist/types/routes/oauth2-init.d.ts.map +1 -0
- package/dist/types/routes/oauth2-refresh.d.ts +1 -0
- package/dist/types/routes/oauth2-refresh.d.ts.map +1 -0
- package/dist/types/routes/oauth2-signin.d.ts +1 -0
- package/dist/types/routes/oauth2-signin.d.ts.map +1 -0
- package/dist/types/routes/webmanager.d.ts +1 -0
- package/dist/types/routes/webmanager.d.ts.map +1 -0
- package/dist/types/rules.d.ts +1 -7
- package/dist/types/rules.d.ts.map +1 -0
- package/dist/types/schema/user.d.ts +1 -0
- package/dist/types/schema/user.d.ts.map +1 -0
- package/dist/types/server.d.ts +1 -0
- package/dist/types/server.d.ts.map +1 -0
- package/dist/types/settings/email.d.ts +1 -0
- package/dist/types/settings/email.d.ts.map +1 -0
- package/dist/types/settings/index.d.ts +2 -1
- package/dist/types/settings/index.d.ts.map +1 -0
- package/dist/types/shared/clients.d.ts +4 -3
- package/dist/types/shared/clients.d.ts.map +1 -0
- package/dist/types/shared/email.d.ts +1 -0
- package/dist/types/shared/email.d.ts.map +1 -0
- package/dist/types/shared/env.d.ts +2 -2
- package/dist/types/shared/env.d.ts.map +1 -0
- package/dist/types/shared/error.d.ts +1 -0
- package/dist/types/shared/error.d.ts.map +1 -0
- package/dist/types/shared/http.d.ts +1 -0
- package/dist/types/shared/http.d.ts.map +1 -0
- package/dist/types/shared/password.d.ts +1 -0
- package/dist/types/shared/password.d.ts.map +1 -0
- package/dist/types/shared/rootpath.d.ts +1 -0
- package/dist/types/shared/rootpath.d.ts.map +1 -0
- package/dist/types/shared/signin.d.ts +1 -0
- package/dist/types/shared/signin.d.ts.map +1 -0
- package/dist/types/shared/simple-fetch.d.ts +1 -0
- package/dist/types/shared/simple-fetch.d.ts.map +1 -0
- package/dist/types/shared/tokens.d.ts +1 -0
- package/dist/types/shared/tokens.d.ts.map +1 -0
- package/dist/types/shared/validate.d.ts +1 -0
- package/dist/types/shared/validate.d.ts.map +1 -0
- package/dist/types/start.d.ts +1 -0
- package/dist/types/start.d.ts.map +1 -0
- package/dist/types/test.d.ts +1 -0
- package/dist/types/test.d.ts.map +1 -0
- package/dist/types/websocket/index.d.ts +1 -0
- package/dist/types/websocket/index.d.ts.map +1 -0
- package/dist/types/websocket/manager.d.ts +11 -10
- package/dist/types/websocket/manager.d.ts.map +1 -0
- package/dist/types/websocket/socket.io.d.ts +1 -0
- package/dist/types/websocket/socket.io.d.ts.map +1 -0
- package/package.json +4 -4
- package/src/auth.ts +87 -0
- package/src/cluster.ts +62 -0
- package/src/index.ts +4 -0
- package/src/logger.ts +56 -0
- package/src/middleware/404.ts +13 -0
- package/src/middleware/admin-only.ts +29 -0
- package/src/middleware/cache.ts +15 -0
- package/src/middleware/connection.ts +48 -0
- package/src/middleware/context.ts +23 -0
- package/src/middleware/cors.ts +49 -0
- package/src/middleware/swagger.ts +19 -0
- package/src/middleware/user.ts +51 -0
- package/src/oauth-providers/dropbox.ts +144 -0
- package/src/oauth-providers/facebook.ts +103 -0
- package/src/oauth-providers/google.ts +147 -0
- package/src/oauth-providers/index.ts +21 -0
- package/src/oauth-providers/instagram.ts +98 -0
- package/src/oauth-providers/oauth-provider.ts +65 -0
- package/src/oauth-providers/spotify.ts +127 -0
- package/src/placeholder.d.ts +12 -0
- package/src/routes/auth-change-password.ts +92 -0
- package/src/routes/auth-change-password.yaml +74 -0
- package/src/routes/auth-delete.ts +49 -0
- package/src/routes/auth-delete.yaml +78 -0
- package/src/routes/auth-forgot-password.ts +77 -0
- package/src/routes/auth-forgot-password.yaml +50 -0
- package/src/routes/auth-reset-password.ts +96 -0
- package/src/routes/auth-reset-password.yaml +54 -0
- package/src/routes/auth-signin.ts +55 -0
- package/src/routes/auth-signin.yaml +130 -0
- package/src/routes/auth-signout.ts +64 -0
- package/src/routes/auth-signout.yaml +46 -0
- package/src/routes/auth-signup.ts +164 -0
- package/src/routes/auth-signup.yaml +136 -0
- package/src/routes/auth-state.ts +20 -0
- package/src/routes/auth-state.yaml +29 -0
- package/src/routes/auth-update.ts +149 -0
- package/src/routes/auth-update.yaml +152 -0
- package/src/routes/auth-verify-email.ts +75 -0
- package/src/routes/auth-verify-email.yaml +53 -0
- package/src/routes/auth.ts +67 -0
- package/src/routes/data-exists.ts +31 -0
- package/src/routes/data-exists.yaml +44 -0
- package/src/routes/data-export.ts +51 -0
- package/src/routes/data-export.yaml +64 -0
- package/src/routes/data-get.ts +67 -0
- package/src/routes/data-get.yaml +54 -0
- package/src/routes/data-import.ts +56 -0
- package/src/routes/data-import.yaml +75 -0
- package/src/routes/data-index-create.ts +82 -0
- package/src/routes/data-index-create.yaml +105 -0
- package/src/routes/data-index-delete.ts +36 -0
- package/src/routes/data-index-delete.yaml +51 -0
- package/src/routes/data-index-list.ts +39 -0
- package/src/routes/data-index-list.yaml +84 -0
- package/src/routes/data-query.ts +97 -0
- package/src/routes/data-query.yaml +166 -0
- package/src/routes/data-reflect.ts +91 -0
- package/src/routes/data-reflect.yaml +124 -0
- package/src/routes/data-schema-get.ts +36 -0
- package/src/routes/data-schema-get.yaml +53 -0
- package/src/routes/data-schema-set.ts +35 -0
- package/src/routes/data-schema-set.yaml +60 -0
- package/src/routes/data-schema-test.ts +48 -0
- package/src/routes/data-schema-test.yaml +66 -0
- package/src/routes/data-schemas-list.ts +31 -0
- package/src/routes/data-schemas-list.yaml +41 -0
- package/src/routes/data-set.ts +83 -0
- package/src/routes/data-set.yaml +77 -0
- package/src/routes/data-sync-changes.ts +77 -0
- package/src/routes/data-sync-changes.yaml +67 -0
- package/src/routes/data-sync-mutations.ts +77 -0
- package/src/routes/data-sync-mutations.yaml +67 -0
- package/src/routes/data-transaction-finish.yaml +82 -0
- package/src/routes/data-transaction-start.yaml +58 -0
- package/src/routes/data-transaction.ts +166 -0
- package/src/routes/data-update.ts +84 -0
- package/src/routes/data-update.yaml +77 -0
- package/src/routes/data.ts +79 -0
- package/src/routes/docs.ts +249 -0
- package/src/routes/meta-info.ts +80 -0
- package/src/routes/meta-info.yaml +41 -0
- package/src/routes/meta-logs.ts +57 -0
- package/src/routes/meta-ping.ts +15 -0
- package/src/routes/meta-ping.yaml +23 -0
- package/src/routes/meta-stats.ts +31 -0
- package/src/routes/meta-stats.yaml +41 -0
- package/src/routes/meta.ts +22 -0
- package/src/routes/oauth2-init.ts +44 -0
- package/src/routes/oauth2-init.yaml +63 -0
- package/src/routes/oauth2-refresh.ts +39 -0
- package/src/routes/oauth2-refresh.yaml +65 -0
- package/src/routes/oauth2-signin.ts +286 -0
- package/src/routes/oauth2-signin.yaml +66 -0
- package/src/routes/webmanager.ts +29 -0
- package/src/rules.ts +189 -0
- package/src/schema/user.ts +99 -0
- package/src/server.ts +419 -0
- package/src/settings/email.ts +18 -0
- package/src/settings/index.ts +241 -0
- package/src/shared/clients.ts +31 -0
- package/src/shared/email.ts +33 -0
- package/src/shared/env.ts +38 -0
- package/src/shared/error.ts +37 -0
- package/src/shared/http.ts +26 -0
- package/src/shared/password.ts +41 -0
- package/src/shared/rootpath.ts +17 -0
- package/src/shared/signin.ts +149 -0
- package/src/shared/simple-fetch.ts +65 -0
- package/src/shared/tokens.ts +77 -0
- package/src/shared/validate.ts +53 -0
- package/src/start.ts +48 -0
- package/src/test.ts +10 -0
- package/src/websocket/index.ts +336 -0
- package/src/websocket/manager.ts +46 -0
- package/src/websocket/socket.io.ts +90 -0
- package/tsconfig-cjs.json +11 -0
- package/tsconfig.json +22 -0
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/auth/{dbname}/signup:
|
|
2
|
+
post:
|
|
3
|
+
tags:
|
|
4
|
+
- auth
|
|
5
|
+
summary: Create a new user
|
|
6
|
+
description: Signs up a new user (must be enabled in the server config)
|
|
7
|
+
parameters:
|
|
8
|
+
- name: dbname
|
|
9
|
+
in: path
|
|
10
|
+
description: name of the database
|
|
11
|
+
required: true
|
|
12
|
+
schema:
|
|
13
|
+
type: string
|
|
14
|
+
example: mydb
|
|
15
|
+
requestBody:
|
|
16
|
+
description: new user details
|
|
17
|
+
content:
|
|
18
|
+
'application/json':
|
|
19
|
+
schema:
|
|
20
|
+
type: object
|
|
21
|
+
properties:
|
|
22
|
+
username:
|
|
23
|
+
type: string
|
|
24
|
+
description: Requested username (optional if `email` provided)
|
|
25
|
+
email:
|
|
26
|
+
type: string
|
|
27
|
+
description: Email address (optional if `username` provided)
|
|
28
|
+
displayName:
|
|
29
|
+
type: string
|
|
30
|
+
description: Name of the user for public displaying purposes. Consider this a real name, alias or handle
|
|
31
|
+
password:
|
|
32
|
+
type: string
|
|
33
|
+
format: password
|
|
34
|
+
description: Password to set for the account
|
|
35
|
+
picture:
|
|
36
|
+
type: object
|
|
37
|
+
description: Profile picture
|
|
38
|
+
properties:
|
|
39
|
+
url:
|
|
40
|
+
type: string
|
|
41
|
+
width:
|
|
42
|
+
type: number
|
|
43
|
+
height:
|
|
44
|
+
type: number
|
|
45
|
+
example:
|
|
46
|
+
url: https://my.profile.pic/me.jpg
|
|
47
|
+
width: 500
|
|
48
|
+
height: 500
|
|
49
|
+
settings:
|
|
50
|
+
type: object
|
|
51
|
+
otherProperties: true
|
|
52
|
+
desciption: (optional) miscellanious other info to store with the user account
|
|
53
|
+
required:
|
|
54
|
+
- username
|
|
55
|
+
- email
|
|
56
|
+
- displayName
|
|
57
|
+
- password
|
|
58
|
+
example:
|
|
59
|
+
email: user@example.com
|
|
60
|
+
displayName: Real Name
|
|
61
|
+
password: sup3rs3cr3t
|
|
62
|
+
responses:
|
|
63
|
+
200:
|
|
64
|
+
description: When signup succeeds, it returns an object with the result
|
|
65
|
+
content:
|
|
66
|
+
'application/json':
|
|
67
|
+
schema:
|
|
68
|
+
type: object
|
|
69
|
+
properties:
|
|
70
|
+
access_token:
|
|
71
|
+
description: The access token that provides access to API calls that require authentication. This access token should be added to the Authorization header of those requests. The token is allowed to be cached by the client to sign in witht the token method later
|
|
72
|
+
type: string
|
|
73
|
+
example: ewufh387f3fyubqwekrjbcqwkuiec7gq3euyfbqwkuyebqjk..
|
|
74
|
+
user:
|
|
75
|
+
$ref: '#/components/schemas/User'
|
|
76
|
+
403:
|
|
77
|
+
description: If user signup is disabled in the server config, only the admin user can create new accounts and `"403 Forbidden"` is returned
|
|
78
|
+
content:
|
|
79
|
+
'application/json':
|
|
80
|
+
schema:
|
|
81
|
+
type: object
|
|
82
|
+
properties:
|
|
83
|
+
code:
|
|
84
|
+
type: string
|
|
85
|
+
value: admin_only
|
|
86
|
+
message:
|
|
87
|
+
type: string
|
|
88
|
+
value: Only admin is allowed to create users
|
|
89
|
+
example:
|
|
90
|
+
code: admin_only
|
|
91
|
+
message: Only admin is allowed to create users
|
|
92
|
+
409:
|
|
93
|
+
description: An account with the same username or email address exists already
|
|
94
|
+
content:
|
|
95
|
+
'application/json':
|
|
96
|
+
schema:
|
|
97
|
+
type: object
|
|
98
|
+
properties:
|
|
99
|
+
code:
|
|
100
|
+
type: string
|
|
101
|
+
value: conflict
|
|
102
|
+
message:
|
|
103
|
+
type: string
|
|
104
|
+
value: Account with username and/or email already exists
|
|
105
|
+
422:
|
|
106
|
+
description: When the sent request details are incorrect, `"422 Unprocessable Entity"` is returned
|
|
107
|
+
content:
|
|
108
|
+
'application/json':
|
|
109
|
+
schema:
|
|
110
|
+
type: object
|
|
111
|
+
properties:
|
|
112
|
+
code:
|
|
113
|
+
type: string
|
|
114
|
+
description: The exact error code
|
|
115
|
+
enum:
|
|
116
|
+
- missing_details
|
|
117
|
+
- invalid_email
|
|
118
|
+
- invalid_username
|
|
119
|
+
- invalid_display_name
|
|
120
|
+
- invalid_password
|
|
121
|
+
- invalid_settings
|
|
122
|
+
- invalid_picture
|
|
123
|
+
example: missing_details
|
|
124
|
+
message:
|
|
125
|
+
type: string
|
|
126
|
+
description: Description of the error
|
|
127
|
+
example: No username or email provided
|
|
128
|
+
example:
|
|
129
|
+
code: invalid_password
|
|
130
|
+
message: Invalid password, must be at least 8 characters and cannot contain spaces
|
|
131
|
+
500:
|
|
132
|
+
description: An unenexpected error occurred on the server
|
|
133
|
+
content:
|
|
134
|
+
'application/json':
|
|
135
|
+
schema:
|
|
136
|
+
$ref: '#/components/schemas/UnexpectedError'
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { RouteInitEnvironment, RouteRequest } from '../shared/env';
|
|
2
|
+
import { AceBaseUser, getPublicAccountDetails } from '../schema/user';
|
|
3
|
+
|
|
4
|
+
export type RequestQuery = {};
|
|
5
|
+
export type RequestBody = {};
|
|
6
|
+
export type ResponseBody = { signed_in: false } | { signed_in: true; user: AceBaseUser };
|
|
7
|
+
export type Request = RouteRequest<any, ResponseBody, RequestBody, RequestQuery>;
|
|
8
|
+
|
|
9
|
+
export const addRoute = (env: RouteInitEnvironment) => {
|
|
10
|
+
env.app.get(`/auth/${env.db.name}/state`, async (req: Request, res) => {
|
|
11
|
+
if (req.user) {
|
|
12
|
+
res.send({ signed_in: true, user: getPublicAccountDetails(req.user) });
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
res.send({ signed_in: false });
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export default addRoute;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/auth/{dbname}/state:
|
|
2
|
+
get:
|
|
3
|
+
tags:
|
|
4
|
+
- auth
|
|
5
|
+
summary: Get authentication state
|
|
6
|
+
description: Gets current auth state
|
|
7
|
+
parameters:
|
|
8
|
+
- name: dbname
|
|
9
|
+
in: path
|
|
10
|
+
description: name of the database
|
|
11
|
+
required: true
|
|
12
|
+
schema:
|
|
13
|
+
type: string
|
|
14
|
+
example: mydb
|
|
15
|
+
responses:
|
|
16
|
+
200:
|
|
17
|
+
description: returns whether the request was authenticated and by which user (determined by the sent Authorization header)
|
|
18
|
+
content:
|
|
19
|
+
'application/json':
|
|
20
|
+
schema:
|
|
21
|
+
type: object
|
|
22
|
+
properties:
|
|
23
|
+
signed_in:
|
|
24
|
+
type: boolean
|
|
25
|
+
example: true
|
|
26
|
+
user:
|
|
27
|
+
$ref: '#/components/schemas/User'
|
|
28
|
+
required:
|
|
29
|
+
- signed_in
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { RouteInitEnvironment, RouteRequest } from '../shared/env';
|
|
2
|
+
import { AceBaseUser, DbUserAccountDetails, getPublicAccountDetails, UserProfilePicture } from '../schema/user';
|
|
3
|
+
import { emailExistsError, invalidDisplayNameError, invalidEmailError, invalidPictureError, invalidSettingsError, invalidUsernameError, isValidDisplayName, isValidEmail, isValidNewEmailAddress, isValidNewUsername, isValidPicture, isValidSettings, isValidUsername, usernameExistsError } from '../shared/validate';
|
|
4
|
+
import { sendNotAuthenticatedError, sendUnauthorizedError, sendUnexpectedError } from '../shared/error';
|
|
5
|
+
|
|
6
|
+
export class UpdateError extends Error {
|
|
7
|
+
constructor(public code: 'unauthenticated_update'|'unauthorized_update'|'user_not_found'|'invalid_email'|'email_conflict'|'invalid_username'|'username_conflict'|'invalid_display_name'|'invalid_picture'|'invalid_settings', message: string) {
|
|
8
|
+
super(message);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type RequestQuery = {};
|
|
13
|
+
export type RequestBody = {
|
|
14
|
+
/** admin only: specifies user account to update */
|
|
15
|
+
uid: string;
|
|
16
|
+
/** Admin only: whether to enable or disable the account */
|
|
17
|
+
is_disabled?: boolean;
|
|
18
|
+
email?: string;
|
|
19
|
+
username?: string;
|
|
20
|
+
displayName?: string;
|
|
21
|
+
display_name?: string;
|
|
22
|
+
picture?: UserProfilePicture;
|
|
23
|
+
settings?: {
|
|
24
|
+
[name: string]: string|number|boolean
|
|
25
|
+
};
|
|
26
|
+
} & (
|
|
27
|
+
// Allow both spellings of display name. display_name is used in the db, displayName in public user detail server responses.
|
|
28
|
+
// displayName is preferred and documented in the OpenAPI docs
|
|
29
|
+
{ displayName: string; } | { display_name: string; }
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
export type ResponseBody = { user: AceBaseUser } | { code: UpdateError['code']; message: string };
|
|
33
|
+
export type Request = RouteRequest<any, ResponseBody, RequestBody, RequestQuery>;
|
|
34
|
+
|
|
35
|
+
export const addRoute = (env: RouteInitEnvironment) => {
|
|
36
|
+
env.app.post(`/auth/${env.db.name}/update`, async (req: Request, res) => {
|
|
37
|
+
|
|
38
|
+
let details = req.body;
|
|
39
|
+
const LOG_ACTION = 'auth.update';
|
|
40
|
+
const LOG_DETAILS = { ip: req.ip, uid: req.user?.uid ?? null, update_uid: details.uid ?? null };
|
|
41
|
+
|
|
42
|
+
if (!req.user) {
|
|
43
|
+
env.log.error(LOG_ACTION, 'unauthenticated_update', LOG_DETAILS);
|
|
44
|
+
return sendNotAuthenticatedError(res, 'unauthenticated_update', 'Sign in to change details');
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const uid = details.uid || req.user.uid;
|
|
48
|
+
|
|
49
|
+
if (req.user.uid !== 'admin' && (uid !== req.user.uid || typeof details.is_disabled === 'boolean')) {
|
|
50
|
+
env.log.error(LOG_ACTION, 'unauthorized_update', LOG_DETAILS);
|
|
51
|
+
return sendUnauthorizedError(res, 'unauthorized_update', 'You are not authorized to perform this update. This attempt has been logged.');
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (typeof details.display_name === 'undefined' && typeof details.displayName === 'string') {
|
|
55
|
+
// Allow displayName to be sent also (which is used in signup endpoint)
|
|
56
|
+
details.display_name = details.displayName;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Check if sent details are ok
|
|
60
|
+
let err: { code: UpdateError['code'], message: string };
|
|
61
|
+
if (details.email && !isValidEmail(details.email)) {
|
|
62
|
+
err = invalidEmailError;
|
|
63
|
+
}
|
|
64
|
+
else if (details.email && !await isValidNewEmailAddress(env.authRef, details.email)) {
|
|
65
|
+
err = emailExistsError;
|
|
66
|
+
}
|
|
67
|
+
else if (details.username && !isValidUsername(details.username)) {
|
|
68
|
+
err = invalidUsernameError;
|
|
69
|
+
}
|
|
70
|
+
else if (details.username && !await isValidNewUsername(env.authRef, details.username)) {
|
|
71
|
+
err = usernameExistsError;
|
|
72
|
+
}
|
|
73
|
+
else if (details.display_name && !isValidDisplayName(details.display_name)) {
|
|
74
|
+
err = invalidDisplayNameError;
|
|
75
|
+
}
|
|
76
|
+
else if (details.picture && !isValidPicture(details.picture)) {
|
|
77
|
+
err = invalidPictureError;
|
|
78
|
+
}
|
|
79
|
+
else if (!isValidSettings(details.settings)) {
|
|
80
|
+
err = invalidSettingsError;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (err) {
|
|
84
|
+
// Log failure
|
|
85
|
+
env.log.error(LOG_ACTION, err.code, LOG_DETAILS);
|
|
86
|
+
res.status(422).send(err); // Unprocessable Entity
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
try {
|
|
91
|
+
let user: DbUserAccountDetails;
|
|
92
|
+
await env.authRef.child(uid).transaction(snap => {
|
|
93
|
+
if (!snap.exists()) {
|
|
94
|
+
throw new UpdateError('user_not_found', `No user found with uid ${uid}`);
|
|
95
|
+
}
|
|
96
|
+
user = snap.val();
|
|
97
|
+
if (details.email && details.email !== user.email) {
|
|
98
|
+
user.email = details.email;
|
|
99
|
+
user.email_verified = false; // TODO: send verification email
|
|
100
|
+
}
|
|
101
|
+
if (details.username) { user.username = details.username; }
|
|
102
|
+
if (details.display_name) { user.display_name = details.display_name; }
|
|
103
|
+
if (details.picture) { user.picture = details.picture; }
|
|
104
|
+
if (details.settings) {
|
|
105
|
+
if (typeof user.settings !== 'object') {
|
|
106
|
+
user.settings = {};
|
|
107
|
+
}
|
|
108
|
+
Object.keys(details.settings).forEach(key => {
|
|
109
|
+
user.settings[key] = details.settings[key];
|
|
110
|
+
});
|
|
111
|
+
if (!isValidSettings(user.settings)) {
|
|
112
|
+
err = invalidSettingsError;
|
|
113
|
+
env.log.error(LOG_ACTION, 'too_many_settings', LOG_DETAILS);
|
|
114
|
+
res.statusCode = 422; // Unprocessable Entity
|
|
115
|
+
res.send(err);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
if (typeof details.is_disabled === 'boolean') {
|
|
120
|
+
user.is_disabled = details.is_disabled;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return user; // Update db user
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
// Update cache
|
|
127
|
+
env.authCache.set(user.uid, user);
|
|
128
|
+
|
|
129
|
+
// Send merged results back
|
|
130
|
+
res.send({ user: getPublicAccountDetails(user) });
|
|
131
|
+
}
|
|
132
|
+
catch (err) {
|
|
133
|
+
|
|
134
|
+
// All known errors except user_not_found will have been sent already
|
|
135
|
+
if (err.code === 'user_not_found') {
|
|
136
|
+
env.log.error(LOG_ACTION, err.code, LOG_DETAILS);
|
|
137
|
+
|
|
138
|
+
res.statusCode = 404; // Not Found
|
|
139
|
+
res.send(err);
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
// Unexpected
|
|
143
|
+
env.log.error(LOG_ACTION, err.code ?? 'unexpected', LOG_DETAILS, err);
|
|
144
|
+
sendUnexpectedError(res, err);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
});
|
|
149
|
+
};
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/auth/{dbname}/update:
|
|
2
|
+
post:
|
|
3
|
+
tags:
|
|
4
|
+
- auth
|
|
5
|
+
summary: Update user details
|
|
6
|
+
description: Updates user account details
|
|
7
|
+
parameters:
|
|
8
|
+
- name: dbname
|
|
9
|
+
in: path
|
|
10
|
+
description: name of the database
|
|
11
|
+
required: true
|
|
12
|
+
schema:
|
|
13
|
+
type: string
|
|
14
|
+
example: mydb
|
|
15
|
+
requestBody:
|
|
16
|
+
description: user details to update
|
|
17
|
+
content:
|
|
18
|
+
'application/json':
|
|
19
|
+
schema:
|
|
20
|
+
type: object
|
|
21
|
+
properties:
|
|
22
|
+
uid:
|
|
23
|
+
type: string
|
|
24
|
+
description: (admin user only) to change a user's account settings, the target account `uid` must be passed with the request
|
|
25
|
+
is_disabled:
|
|
26
|
+
type: boolean
|
|
27
|
+
description: (admin user only) whether the target account should be disabled to enable/disable signin
|
|
28
|
+
email:
|
|
29
|
+
type: string
|
|
30
|
+
description: New email address
|
|
31
|
+
username:
|
|
32
|
+
type: string
|
|
33
|
+
description: New username
|
|
34
|
+
displayName:
|
|
35
|
+
type: string
|
|
36
|
+
description: Name of the user for public displaying purposes. Consider this a real name, alias or handle. (NOTE this property is equivalent to the deprecated `display_name`, both are allowed to be used from acebase-server v1.8.1)
|
|
37
|
+
display_name:
|
|
38
|
+
type: string
|
|
39
|
+
description: Name of the user for public displaying purposes. Consider this a real name, alias or handle. (NOTE this property deprecated, use `displayName` instead)
|
|
40
|
+
picture:
|
|
41
|
+
type: object
|
|
42
|
+
description: Profile picture
|
|
43
|
+
properties:
|
|
44
|
+
url:
|
|
45
|
+
type: string
|
|
46
|
+
width:
|
|
47
|
+
type: number
|
|
48
|
+
height:
|
|
49
|
+
type: number
|
|
50
|
+
example:
|
|
51
|
+
url: https://my.profile.pic/me.jpg
|
|
52
|
+
width: 500
|
|
53
|
+
height: 500
|
|
54
|
+
settings:
|
|
55
|
+
type: object
|
|
56
|
+
otherProperties: true
|
|
57
|
+
desciption: (optional) miscellanious other info to store with the user account
|
|
58
|
+
required:
|
|
59
|
+
- username
|
|
60
|
+
- email
|
|
61
|
+
- displayName
|
|
62
|
+
- password
|
|
63
|
+
responses:
|
|
64
|
+
200:
|
|
65
|
+
description: When update succeeds, it returns an object with the new user details
|
|
66
|
+
content:
|
|
67
|
+
'application/json':
|
|
68
|
+
schema:
|
|
69
|
+
type: object
|
|
70
|
+
properties:
|
|
71
|
+
user:
|
|
72
|
+
$ref: '#/components/schemas/User'
|
|
73
|
+
401:
|
|
74
|
+
description: If this is an unauthenticated request (not signed in), `"401 Unauthorized"` is returned
|
|
75
|
+
content:
|
|
76
|
+
'application/json':
|
|
77
|
+
schema:
|
|
78
|
+
type: object
|
|
79
|
+
properties:
|
|
80
|
+
code:
|
|
81
|
+
type: string
|
|
82
|
+
value: unauthenticated_update
|
|
83
|
+
message:
|
|
84
|
+
type: string
|
|
85
|
+
value: Sign in to change details
|
|
86
|
+
example:
|
|
87
|
+
code: unauthenticated_update
|
|
88
|
+
message: Sign in to change details
|
|
89
|
+
403:
|
|
90
|
+
description: If a non-admin user tries to update a user's account details, `"403 Forbidden"` is returned
|
|
91
|
+
content:
|
|
92
|
+
'application/json':
|
|
93
|
+
schema:
|
|
94
|
+
type: object
|
|
95
|
+
properties:
|
|
96
|
+
code:
|
|
97
|
+
type: string
|
|
98
|
+
value: unauthorized_update
|
|
99
|
+
message:
|
|
100
|
+
type: string
|
|
101
|
+
value: You are not authorized to perform this update. This attempt has been logged.
|
|
102
|
+
example:
|
|
103
|
+
code: unauthorized_update
|
|
104
|
+
message: You are not authorized to perform this update. This attempt has been logged.
|
|
105
|
+
404:
|
|
106
|
+
description: User account to update does not exist
|
|
107
|
+
content:
|
|
108
|
+
'application/json':
|
|
109
|
+
schema:
|
|
110
|
+
type: object
|
|
111
|
+
properties:
|
|
112
|
+
code:
|
|
113
|
+
type: string
|
|
114
|
+
value: user_not_found
|
|
115
|
+
message:
|
|
116
|
+
type: string
|
|
117
|
+
value: No user found with uid jld2cjxh0000qzrmn831i7rn
|
|
118
|
+
example:
|
|
119
|
+
code: user_not_found
|
|
120
|
+
message: No user found with uid jld2cjxh0000qzrmn831i7rn
|
|
121
|
+
422:
|
|
122
|
+
description: When the sent request details are incorrect, this "422 Unprocessable Entity" is returned
|
|
123
|
+
content:
|
|
124
|
+
'application/json':
|
|
125
|
+
schema:
|
|
126
|
+
type: object
|
|
127
|
+
properties:
|
|
128
|
+
code:
|
|
129
|
+
type: string
|
|
130
|
+
description: The exact error code
|
|
131
|
+
enum:
|
|
132
|
+
- invalid_email
|
|
133
|
+
- email_conflict
|
|
134
|
+
- invalid_username
|
|
135
|
+
- username_conflict
|
|
136
|
+
- invalid_display_name
|
|
137
|
+
- invalid_picture
|
|
138
|
+
- invalid_settings
|
|
139
|
+
example: user_not_found
|
|
140
|
+
message:
|
|
141
|
+
type: string
|
|
142
|
+
description: Description of the error
|
|
143
|
+
example: Account with email address exists already
|
|
144
|
+
example:
|
|
145
|
+
code: username_conflict
|
|
146
|
+
message: Account with username exists already
|
|
147
|
+
500:
|
|
148
|
+
description: An unenexpected error occurred on the server
|
|
149
|
+
content:
|
|
150
|
+
'application/json':
|
|
151
|
+
schema:
|
|
152
|
+
$ref: '#/components/schemas/UnexpectedError'
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { RouteInitEnvironment, RouteRequest } from '../shared/env';
|
|
2
|
+
import { DbUserAccountDetails } from '../schema/user';
|
|
3
|
+
import { parseSignedPublicToken } from '../shared/tokens';
|
|
4
|
+
import { sendBadRequestError, sendUnexpectedError } from '../shared/error';
|
|
5
|
+
|
|
6
|
+
export class VerifyEmailError extends Error {
|
|
7
|
+
constructor(public code: 'invalid_code'|'unknown_user', message: string) {
|
|
8
|
+
super(message);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type RequestQuery = {};
|
|
13
|
+
export type RequestBody = { code: string };
|
|
14
|
+
export type ResponseBody = 'OK' | { code: string; message: string };
|
|
15
|
+
export type Request = RouteRequest<any, ResponseBody, RequestBody, RequestQuery>;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Adds the verify_email route and returns the verification function that can be used to manually verify an email address
|
|
19
|
+
* @param env environment
|
|
20
|
+
* @returns returns the verification function
|
|
21
|
+
*/
|
|
22
|
+
export const addRoute = (env: RouteInitEnvironment) => {
|
|
23
|
+
|
|
24
|
+
const LOG_ACTION = 'auth.verify_email';
|
|
25
|
+
|
|
26
|
+
const verifyEmailAddress = async (clientIp: string, code: string) => {
|
|
27
|
+
|
|
28
|
+
const LOG_DETAILS = { ip: clientIp, uid: null };
|
|
29
|
+
|
|
30
|
+
try {
|
|
31
|
+
var verification = parseSignedPublicToken(code, env.tokenSalt);
|
|
32
|
+
}
|
|
33
|
+
catch (err) {
|
|
34
|
+
throw new VerifyEmailError('invalid_code', err.message);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
LOG_DETAILS.uid = verification.uid;
|
|
38
|
+
const snap = await env.authRef.child(verification.uid).get();
|
|
39
|
+
if (!snap.exists()) {
|
|
40
|
+
env.log.error(LOG_ACTION, 'unknown_user', LOG_DETAILS);
|
|
41
|
+
throw new VerifyEmailError('unknown_user', 'Unknown user');
|
|
42
|
+
}
|
|
43
|
+
const user: DbUserAccountDetails = snap.val();
|
|
44
|
+
user.uid = snap.key as string;
|
|
45
|
+
|
|
46
|
+
// No need to do further checks, code was signed by us so we can trust the contents
|
|
47
|
+
// Mark account as verified
|
|
48
|
+
await snap.ref.update({ email_verified: true });
|
|
49
|
+
|
|
50
|
+
env.log.event(LOG_ACTION, LOG_DETAILS);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
env.app.post(`/auth/${env.db.name}/verify_email`, async (req: Request, res) => {
|
|
54
|
+
|
|
55
|
+
const details = req.body;
|
|
56
|
+
|
|
57
|
+
try {
|
|
58
|
+
await verifyEmailAddress(req.ip, details.code);
|
|
59
|
+
res.send('OK');
|
|
60
|
+
}
|
|
61
|
+
catch (err) {
|
|
62
|
+
if (err.code) {
|
|
63
|
+
sendBadRequestError(res, err);
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
env.log.error(LOG_ACTION, 'unexpected', { ip: req.ip, message: err.message, verificaion_code: details.code });
|
|
67
|
+
sendUnexpectedError(res, err);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
return verifyEmailAddress;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export default addRoute;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/auth/{dbname}/verify_email:
|
|
2
|
+
post:
|
|
3
|
+
tags:
|
|
4
|
+
- auth
|
|
5
|
+
summary: Verifies an email address
|
|
6
|
+
description: Verifies an email address with a code sent through their email address
|
|
7
|
+
parameters:
|
|
8
|
+
- name: dbname
|
|
9
|
+
in: path
|
|
10
|
+
description: name of the database
|
|
11
|
+
required: true
|
|
12
|
+
schema:
|
|
13
|
+
type: string
|
|
14
|
+
example: mydb
|
|
15
|
+
requestBody:
|
|
16
|
+
description: verification object
|
|
17
|
+
content:
|
|
18
|
+
'application/json':
|
|
19
|
+
schema:
|
|
20
|
+
type: object
|
|
21
|
+
properties:
|
|
22
|
+
code:
|
|
23
|
+
type: string
|
|
24
|
+
description: Verification code that was sent to the user's email address
|
|
25
|
+
required:
|
|
26
|
+
- code
|
|
27
|
+
example:
|
|
28
|
+
code: ewrg235235g23gwrvsdb34g524rvqewwrv425gervqew...
|
|
29
|
+
responses:
|
|
30
|
+
200:
|
|
31
|
+
description: If the email address is successfully verified, returns the string `"OK"`
|
|
32
|
+
content:
|
|
33
|
+
'text/plain':
|
|
34
|
+
schema:
|
|
35
|
+
type: 'string'
|
|
36
|
+
value: OK
|
|
37
|
+
example: OK
|
|
38
|
+
description: The string `"OK"`
|
|
39
|
+
401:
|
|
40
|
+
description: Returns a `"401 Bad Request"` if the code sent with the request is invalid
|
|
41
|
+
content:
|
|
42
|
+
'application/json':
|
|
43
|
+
schema:
|
|
44
|
+
$ref: '#/components/schemas/Error'
|
|
45
|
+
example:
|
|
46
|
+
code: invalid_code
|
|
47
|
+
message: Invalid token
|
|
48
|
+
500:
|
|
49
|
+
description: An unexpected error occurred
|
|
50
|
+
content:
|
|
51
|
+
'application/json':
|
|
52
|
+
schema:
|
|
53
|
+
$ref: '#/components/schemas/UnexpectedError'
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { RouteInitEnvironment } from '../shared/env';
|
|
2
|
+
import { addMiddleware as addBearerAuthMiddleware } from '../middleware/user';
|
|
3
|
+
import { addRoute as addStateRoute } from './auth-state';
|
|
4
|
+
import { addRoute as addSignInRoute } from './auth-signin';
|
|
5
|
+
import { addRoute as addSignOutRoute } from './auth-signout';
|
|
6
|
+
import { addRoute as addVerifyEmailRoute } from './auth-verify-email';
|
|
7
|
+
import { addRoute as addResetPasswordRoute } from './auth-reset-password';
|
|
8
|
+
import { addRoute as addChangePasswordRoute } from './auth-change-password';
|
|
9
|
+
import { addRoute as addSignUpRoute } from './auth-signup';
|
|
10
|
+
import { addRoute as addUpdateRoute } from './auth-update';
|
|
11
|
+
import { addRoute as addDeleteRoute } from './auth-delete';
|
|
12
|
+
import { addRoute as addOAuth2InitRoute } from './oauth2-init';
|
|
13
|
+
import { addRoute as addOAuth2SignInRoute } from './oauth2-signin';
|
|
14
|
+
import { addRoute as addOAuth2RefreshRoute } from './oauth2-refresh';
|
|
15
|
+
|
|
16
|
+
export const addAuthenticionRoutes = (env: RouteInitEnvironment) => {
|
|
17
|
+
if (!env.config.auth.enabled) {
|
|
18
|
+
throw new Error('Authentication not enabled in the server settings');
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Bearer authentication middleware
|
|
22
|
+
addBearerAuthMiddleware(env);
|
|
23
|
+
|
|
24
|
+
// Auth state endpoint
|
|
25
|
+
addStateRoute(env);
|
|
26
|
+
|
|
27
|
+
// signin endpoint
|
|
28
|
+
addSignInRoute(env);
|
|
29
|
+
|
|
30
|
+
// signout endpoint
|
|
31
|
+
addSignOutRoute(env);
|
|
32
|
+
|
|
33
|
+
// verify email endpoint
|
|
34
|
+
const verifyEmailAddress = addVerifyEmailRoute(env);
|
|
35
|
+
|
|
36
|
+
// reset password endpoint
|
|
37
|
+
const resetPassword = addResetPasswordRoute(env);
|
|
38
|
+
|
|
39
|
+
// change password endpoint
|
|
40
|
+
addChangePasswordRoute(env);
|
|
41
|
+
|
|
42
|
+
// signup endpoint
|
|
43
|
+
addSignUpRoute(env);
|
|
44
|
+
|
|
45
|
+
// update enpoint
|
|
46
|
+
addUpdateRoute(env);
|
|
47
|
+
|
|
48
|
+
// delete endpoint
|
|
49
|
+
addDeleteRoute(env);
|
|
50
|
+
|
|
51
|
+
// OAuth2 init endpoint
|
|
52
|
+
addOAuth2InitRoute(env);
|
|
53
|
+
|
|
54
|
+
// OAuth2 signin endpoint
|
|
55
|
+
addOAuth2SignInRoute(env);
|
|
56
|
+
|
|
57
|
+
// OAuth2 token refresh endpoint
|
|
58
|
+
addOAuth2RefreshRoute(env);
|
|
59
|
+
|
|
60
|
+
// Return auth functions that can be used directly through an AceBaseServer instance
|
|
61
|
+
return {
|
|
62
|
+
verifyEmailAddress,
|
|
63
|
+
resetPassword
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export default addAuthenticionRoutes;
|