acebase-server 1.9.1 → 1.10.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/.vscode/launch.json +24 -0
- package/create-package-files +12 -0
- package/dist/cjs/auth.js +89 -0
- package/dist/cjs/auth.js.map +1 -0
- package/dist/cjs/cluster.js +57 -0
- package/dist/cjs/cluster.js.map +1 -0
- package/dist/cjs/index.js +9 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/middleware/404.js +15 -0
- package/dist/cjs/middleware/404.js.map +1 -0
- package/dist/cjs/middleware/cache.js +15 -0
- package/dist/cjs/middleware/cache.js.map +1 -0
- package/dist/cjs/middleware/connection.js +50 -0
- package/dist/cjs/middleware/connection.js.map +1 -0
- package/dist/cjs/middleware/context.js +21 -0
- package/dist/cjs/middleware/context.js.map +1 -0
- package/dist/cjs/middleware/cors.js +51 -0
- package/dist/cjs/middleware/cors.js.map +1 -0
- package/dist/cjs/middleware/swagger.js +18 -0
- package/dist/cjs/middleware/swagger.js.map +1 -0
- package/dist/cjs/middleware/user.js +58 -0
- package/dist/cjs/middleware/user.js.map +1 -0
- package/dist/cjs/oauth-providers/dropbox.js +109 -0
- package/dist/cjs/oauth-providers/dropbox.js.map +1 -0
- package/dist/cjs/oauth-providers/facebook.js +85 -0
- package/dist/cjs/oauth-providers/facebook.js.map +1 -0
- package/dist/cjs/oauth-providers/google.js +125 -0
- package/dist/cjs/oauth-providers/google.js.map +1 -0
- package/dist/cjs/oauth-providers/index.js +27 -0
- package/dist/cjs/oauth-providers/index.js.map +1 -0
- package/dist/cjs/oauth-providers/instagram.js +80 -0
- package/dist/cjs/oauth-providers/instagram.js.map +1 -0
- package/dist/cjs/oauth-providers/oauth-provider.js +3 -0
- package/dist/cjs/oauth-providers/oauth-provider.js.map +1 -0
- package/dist/cjs/oauth-providers/spotify.js +113 -0
- package/dist/cjs/oauth-providers/spotify.js.map +1 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/routes/auth-change-password.js +85 -0
- package/dist/cjs/routes/auth-change-password.js.map +1 -0
- package/dist/cjs/routes/auth-delete.js +51 -0
- package/dist/cjs/routes/auth-delete.js.map +1 -0
- package/dist/cjs/routes/auth-forgot-password.js +75 -0
- package/dist/cjs/routes/auth-forgot-password.js.map +1 -0
- package/dist/cjs/routes/auth-reset-password.js +94 -0
- package/dist/cjs/routes/auth-reset-password.js.map +1 -0
- package/dist/cjs/routes/auth-signin.js +47 -0
- package/dist/cjs/routes/auth-signin.js.map +1 -0
- package/dist/cjs/routes/auth-signout.js +60 -0
- package/dist/cjs/routes/auth-signout.js.map +1 -0
- package/dist/cjs/routes/auth-signup.js +141 -0
- package/dist/cjs/routes/auth-signup.js.map +1 -0
- package/dist/cjs/routes/auth-state.js +26 -0
- package/dist/cjs/routes/auth-state.js.map +1 -0
- package/dist/cjs/routes/auth-update.js +129 -0
- package/dist/cjs/routes/auth-update.js.map +1 -0
- package/dist/cjs/routes/auth-verify-email.js +67 -0
- package/dist/cjs/routes/auth-verify-email.js.map +1 -0
- package/dist/cjs/routes/auth.js +55 -0
- package/dist/cjs/routes/auth.js.map +1 -0
- package/dist/cjs/routes/data-exists.js +34 -0
- package/dist/cjs/routes/data-exists.js.map +1 -0
- package/dist/cjs/routes/data-export.js +49 -0
- package/dist/cjs/routes/data-export.js.map +1 -0
- package/dist/cjs/routes/data-get.js +67 -0
- package/dist/cjs/routes/data-get.js.map +1 -0
- package/dist/cjs/routes/data-import.js +55 -0
- package/dist/cjs/routes/data-import.js.map +1 -0
- package/dist/cjs/routes/data-index-create.js +45 -0
- package/dist/cjs/routes/data-index-create.js.map +1 -0
- package/dist/cjs/routes/data-index-delete.js +36 -0
- package/dist/cjs/routes/data-index-delete.js.map +1 -0
- package/dist/cjs/routes/data-index-list.js +35 -0
- package/dist/cjs/routes/data-index-list.js.map +1 -0
- package/dist/cjs/routes/data-query.js +71 -0
- package/dist/cjs/routes/data-query.js.map +1 -0
- package/dist/cjs/routes/data-reflect.js +89 -0
- package/dist/cjs/routes/data-reflect.js.map +1 -0
- package/dist/cjs/routes/data-schema-get.js +39 -0
- package/dist/cjs/routes/data-schema-get.js.map +1 -0
- package/dist/cjs/routes/data-schema-set.js +33 -0
- package/dist/cjs/routes/data-schema-set.js.map +1 -0
- package/dist/cjs/routes/data-schema-test.js +46 -0
- package/dist/cjs/routes/data-schema-test.js.map +1 -0
- package/dist/cjs/routes/data-schemas-list.js +35 -0
- package/dist/cjs/routes/data-schemas-list.js.map +1 -0
- package/dist/cjs/routes/data-set.js +72 -0
- package/dist/cjs/routes/data-set.js.map +1 -0
- package/dist/cjs/routes/data-sync-changes.js +68 -0
- package/dist/cjs/routes/data-sync-changes.js.map +1 -0
- package/dist/cjs/routes/data-sync-mutations.js +68 -0
- package/dist/cjs/routes/data-sync-mutations.js.map +1 -0
- package/dist/cjs/routes/data-transaction.js +120 -0
- package/dist/cjs/routes/data-transaction.js.map +1 -0
- package/dist/cjs/routes/data-update.js +71 -0
- package/dist/cjs/routes/data-update.js.map +1 -0
- package/dist/cjs/routes/data.js +63 -0
- package/dist/cjs/routes/data.js.map +1 -0
- package/dist/cjs/routes/docs.js +249 -0
- package/dist/cjs/routes/docs.js.map +1 -0
- package/dist/cjs/routes/meta-info.js +70 -0
- package/dist/cjs/routes/meta-info.js.map +1 -0
- package/dist/cjs/routes/meta-ping.js +12 -0
- package/dist/cjs/routes/meta-ping.js.map +1 -0
- package/dist/cjs/routes/meta-stats.js +28 -0
- package/dist/cjs/routes/meta-stats.js.map +1 -0
- package/dist/cjs/routes/meta.js +17 -0
- package/dist/cjs/routes/meta.js.map +1 -0
- package/dist/cjs/routes/oauth2-init.js +52 -0
- package/dist/cjs/routes/oauth2-init.js.map +1 -0
- package/dist/cjs/routes/oauth2-refresh.js +43 -0
- package/dist/cjs/routes/oauth2-refresh.js.map +1 -0
- package/dist/cjs/routes/oauth2-signin.js +262 -0
- package/dist/cjs/routes/oauth2-signin.js.map +1 -0
- package/dist/cjs/routes/webmanager.js +27 -0
- package/dist/cjs/routes/webmanager.js.map +1 -0
- package/dist/cjs/rules.js +175 -0
- package/dist/cjs/rules.js.map +1 -0
- package/dist/cjs/schema/user.js +26 -0
- package/dist/cjs/schema/user.js.map +1 -0
- package/dist/cjs/server.js +363 -0
- package/dist/cjs/server.js.map +1 -0
- package/dist/cjs/settings/email.js +5 -0
- package/dist/cjs/settings/email.js.map +1 -0
- package/dist/cjs/settings/index.js +159 -0
- package/dist/cjs/settings/index.js.map +1 -0
- package/dist/cjs/shared/clients.js +27 -0
- package/dist/cjs/shared/clients.js.map +1 -0
- package/dist/cjs/shared/email.js +7 -0
- package/dist/cjs/shared/email.js.map +1 -0
- package/{src/oauth-providers/oauth-provider.js → dist/cjs/shared/env.js} +3 -0
- package/dist/cjs/shared/env.js.map +1 -0
- package/dist/cjs/shared/error.js +35 -0
- package/dist/cjs/shared/error.js.map +1 -0
- package/dist/cjs/shared/http.js +21 -0
- package/dist/cjs/shared/http.js.map +1 -0
- package/dist/cjs/shared/password.js +46 -0
- package/dist/cjs/shared/password.js.map +1 -0
- package/dist/cjs/shared/rootpath.js +15 -0
- package/dist/cjs/shared/rootpath.js.map +1 -0
- package/dist/cjs/shared/signin.js +139 -0
- package/dist/cjs/shared/signin.js.map +1 -0
- package/dist/cjs/shared/simple-fetch.js +77 -0
- package/dist/cjs/shared/simple-fetch.js.map +1 -0
- package/dist/cjs/shared/tokens.js +79 -0
- package/dist/cjs/shared/tokens.js.map +1 -0
- package/dist/cjs/shared/validate.js +62 -0
- package/dist/cjs/shared/validate.js.map +1 -0
- package/dist/cjs/start.js +51 -0
- package/dist/cjs/start.js.map +1 -0
- package/dist/cjs/test.js +11 -0
- package/dist/cjs/test.js.map +1 -0
- package/dist/cjs/websocket/index.js +301 -0
- package/dist/cjs/websocket/index.js.map +1 -0
- package/dist/cjs/websocket/manager.js +16 -0
- package/dist/cjs/websocket/manager.js.map +1 -0
- package/dist/cjs/websocket/socket.io.js +79 -0
- package/dist/cjs/websocket/socket.io.js.map +1 -0
- package/dist/esm/auth.js +76 -0
- package/dist/esm/auth.js.map +1 -0
- package/{src → dist/esm}/cluster.js +9 -14
- package/dist/esm/cluster.js.map +1 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/middleware/404.js +11 -0
- package/dist/esm/middleware/404.js.map +1 -0
- package/dist/esm/middleware/cache.js +11 -0
- package/dist/esm/middleware/cache.js.map +1 -0
- package/dist/esm/middleware/connection.js +46 -0
- package/dist/esm/middleware/connection.js.map +1 -0
- package/dist/esm/middleware/context.js +17 -0
- package/dist/esm/middleware/context.js.map +1 -0
- package/dist/esm/middleware/cors.js +45 -0
- package/dist/esm/middleware/cors.js.map +1 -0
- package/dist/esm/middleware/swagger.js +14 -0
- package/dist/esm/middleware/swagger.js.map +1 -0
- package/dist/esm/middleware/user.js +45 -0
- package/dist/esm/middleware/user.js.map +1 -0
- package/{src → dist/esm}/oauth-providers/dropbox.js +11 -9
- package/dist/esm/oauth-providers/dropbox.js.map +1 -0
- package/{src → dist/esm}/oauth-providers/facebook.js +6 -9
- package/dist/esm/oauth-providers/facebook.js.map +1 -0
- package/{src → dist/esm}/oauth-providers/google.js +8 -11
- package/dist/esm/oauth-providers/google.js.map +1 -0
- package/dist/esm/oauth-providers/index.js +19 -0
- package/dist/esm/oauth-providers/index.js.map +1 -0
- package/{src → dist/esm}/oauth-providers/instagram.js +6 -9
- package/dist/esm/oauth-providers/instagram.js.map +1 -0
- package/dist/esm/oauth-providers/oauth-provider.js +2 -0
- package/dist/esm/oauth-providers/oauth-provider.js.map +1 -0
- package/{src → dist/esm}/oauth-providers/spotify.js +7 -10
- package/dist/esm/oauth-providers/spotify.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/routes/auth-change-password.js +70 -0
- package/dist/esm/routes/auth-change-password.js.map +1 -0
- package/dist/esm/routes/auth-delete.js +36 -0
- package/dist/esm/routes/auth-delete.js.map +1 -0
- package/dist/esm/routes/auth-forgot-password.js +61 -0
- package/dist/esm/routes/auth-forgot-password.js.map +1 -0
- package/dist/esm/routes/auth-reset-password.js +78 -0
- package/dist/esm/routes/auth-reset-password.js.map +1 -0
- package/dist/esm/routes/auth-signin.js +34 -0
- package/dist/esm/routes/auth-signin.js.map +1 -0
- package/dist/esm/routes/auth-signout.js +46 -0
- package/dist/esm/routes/auth-signout.js.map +1 -0
- package/dist/esm/routes/auth-signup.js +126 -0
- package/dist/esm/routes/auth-signup.js.map +1 -0
- package/dist/esm/routes/auth-state.js +13 -0
- package/dist/esm/routes/auth-state.js.map +1 -0
- package/dist/esm/routes/auth-update.js +115 -0
- package/dist/esm/routes/auth-update.js.map +1 -0
- package/dist/esm/routes/auth-verify-email.js +52 -0
- package/dist/esm/routes/auth-verify-email.js.map +1 -0
- package/dist/esm/routes/auth.js +51 -0
- package/dist/esm/routes/auth.js.map +1 -0
- package/dist/esm/routes/data-exists.js +21 -0
- package/dist/esm/routes/data-exists.js.map +1 -0
- package/dist/esm/routes/data-export.js +36 -0
- package/dist/esm/routes/data-export.js.map +1 -0
- package/dist/esm/routes/data-get.js +53 -0
- package/dist/esm/routes/data-get.js.map +1 -0
- package/dist/esm/routes/data-import.js +42 -0
- package/dist/esm/routes/data-import.js.map +1 -0
- package/dist/esm/routes/data-index-create.js +31 -0
- package/dist/esm/routes/data-index-create.js.map +1 -0
- package/dist/esm/routes/data-index-delete.js +23 -0
- package/dist/esm/routes/data-index-delete.js.map +1 -0
- package/dist/esm/routes/data-index-list.js +22 -0
- package/dist/esm/routes/data-index-list.js.map +1 -0
- package/dist/esm/routes/data-query.js +57 -0
- package/dist/esm/routes/data-query.js.map +1 -0
- package/dist/esm/routes/data-reflect.js +76 -0
- package/dist/esm/routes/data-reflect.js.map +1 -0
- package/dist/esm/routes/data-schema-get.js +26 -0
- package/dist/esm/routes/data-schema-get.js.map +1 -0
- package/dist/esm/routes/data-schema-set.js +20 -0
- package/dist/esm/routes/data-schema-set.js.map +1 -0
- package/dist/esm/routes/data-schema-test.js +32 -0
- package/dist/esm/routes/data-schema-test.js.map +1 -0
- package/dist/esm/routes/data-schemas-list.js +22 -0
- package/dist/esm/routes/data-schemas-list.js.map +1 -0
- package/dist/esm/routes/data-set.js +57 -0
- package/dist/esm/routes/data-set.js.map +1 -0
- package/dist/esm/routes/data-sync-changes.js +54 -0
- package/dist/esm/routes/data-sync-changes.js.map +1 -0
- package/dist/esm/routes/data-sync-mutations.js +54 -0
- package/dist/esm/routes/data-sync-mutations.js.map +1 -0
- package/dist/esm/routes/data-transaction.js +104 -0
- package/dist/esm/routes/data-transaction.js.map +1 -0
- package/dist/esm/routes/data-update.js +56 -0
- package/dist/esm/routes/data-update.js.map +1 -0
- package/dist/esm/routes/data.js +59 -0
- package/dist/esm/routes/data.js.map +1 -0
- package/dist/esm/routes/docs.js +244 -0
- package/dist/esm/routes/docs.js.map +1 -0
- package/dist/esm/routes/meta-info.js +66 -0
- package/dist/esm/routes/meta-info.js.map +1 -0
- package/dist/esm/routes/meta-ping.js +8 -0
- package/dist/esm/routes/meta-ping.js.map +1 -0
- package/dist/esm/routes/meta-stats.js +15 -0
- package/dist/esm/routes/meta-stats.js.map +1 -0
- package/dist/esm/routes/meta.js +13 -0
- package/dist/esm/routes/meta.js.map +1 -0
- package/dist/esm/routes/oauth2-init.js +39 -0
- package/dist/esm/routes/oauth2-init.js.map +1 -0
- package/dist/esm/routes/oauth2-refresh.js +30 -0
- package/dist/esm/routes/oauth2-refresh.js.map +1 -0
- package/dist/esm/routes/oauth2-signin.js +248 -0
- package/dist/esm/routes/oauth2-signin.js.map +1 -0
- package/dist/esm/routes/webmanager.js +23 -0
- package/dist/esm/routes/webmanager.js.map +1 -0
- package/dist/esm/rules.js +171 -0
- package/dist/esm/rules.js.map +1 -0
- package/dist/esm/schema/user.js +21 -0
- package/dist/esm/schema/user.js.map +1 -0
- package/dist/esm/server.js +344 -0
- package/dist/esm/server.js.map +1 -0
- package/dist/esm/settings/email.js +4 -0
- package/dist/esm/settings/email.js.map +1 -0
- package/dist/esm/settings/index.js +152 -0
- package/dist/esm/settings/index.js.map +1 -0
- package/dist/esm/shared/clients.js +23 -0
- package/dist/esm/shared/clients.js.map +1 -0
- package/dist/esm/shared/email.js +6 -0
- package/dist/esm/shared/email.js.map +1 -0
- package/dist/esm/shared/env.js +4 -0
- package/dist/esm/shared/env.js.map +1 -0
- package/dist/esm/shared/error.js +27 -0
- package/dist/esm/shared/error.js.map +1 -0
- package/dist/esm/shared/http.js +16 -0
- package/dist/esm/shared/http.js.map +1 -0
- package/dist/esm/shared/password.js +39 -0
- package/dist/esm/shared/password.js.map +1 -0
- package/dist/esm/shared/rootpath.js +12 -0
- package/dist/esm/shared/rootpath.js.map +1 -0
- package/dist/esm/shared/signin.js +125 -0
- package/dist/esm/shared/signin.js.map +1 -0
- package/{src/oauth-providers → dist/esm/shared}/simple-fetch.js +7 -10
- package/dist/esm/shared/simple-fetch.js.map +1 -0
- package/dist/esm/shared/tokens.js +72 -0
- package/dist/esm/shared/tokens.js.map +1 -0
- package/dist/esm/shared/validate.js +42 -0
- package/dist/esm/shared/validate.js.map +1 -0
- package/dist/esm/start.js +48 -0
- package/dist/esm/start.js.map +1 -0
- package/dist/esm/test.js +9 -0
- package/dist/esm/test.js.map +1 -0
- package/dist/esm/websocket/index.js +288 -0
- package/dist/esm/websocket/index.js.map +1 -0
- package/dist/esm/websocket/manager.js +12 -0
- package/dist/esm/websocket/manager.js.map +1 -0
- package/dist/esm/websocket/socket.io.js +73 -0
- package/dist/esm/websocket/socket.io.js.map +1 -0
- package/dist/types/auth.d.ts +3 -0
- package/dist/types/cluster.d.ts +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/middleware/404.d.ts +7 -0
- package/dist/types/middleware/cache.d.ts +3 -0
- package/dist/types/middleware/connection.d.ts +7 -0
- package/dist/types/middleware/context.d.ts +3 -0
- package/dist/types/middleware/cors.d.ts +25 -0
- package/dist/types/middleware/swagger.d.ts +3 -0
- package/dist/types/middleware/user.d.ts +2 -0
- package/dist/types/oauth-providers/dropbox.d.ts +63 -0
- package/dist/types/oauth-providers/facebook.d.ts +45 -0
- package/dist/types/oauth-providers/google.d.ts +47 -0
- package/dist/types/oauth-providers/index.d.ts +18 -0
- package/dist/types/oauth-providers/instagram.d.ts +54 -0
- package/dist/types/oauth-providers/oauth-provider.d.ts +70 -0
- package/dist/types/oauth-providers/spotify.d.ts +57 -0
- package/dist/types/routes/auth-change-password.d.ts +20 -0
- package/dist/types/routes/auth-delete.d.ts +16 -0
- package/dist/types/routes/auth-forgot-password.d.ts +16 -0
- package/dist/types/routes/auth-reset-password.d.ts +23 -0
- package/dist/types/routes/auth-signin.d.ts +24 -0
- package/dist/types/routes/auth-signout.d.ts +14 -0
- package/dist/types/routes/auth-signup.d.ts +32 -0
- package/dist/types/routes/auth-state.d.ts +13 -0
- package/dist/types/routes/auth-update.d.ts +33 -0
- package/dist/types/routes/auth-verify-email.d.ts +21 -0
- package/dist/types/routes/auth.d.ts +6 -0
- package/dist/types/routes/data-exists.d.ts +9 -0
- package/dist/types/routes/data-export.d.ts +10 -0
- package/dist/types/routes/data-get.d.ts +14 -0
- package/dist/types/routes/data-import.d.ts +13 -0
- package/dist/types/routes/data-index-create.d.ts +51 -0
- package/dist/types/routes/data-index-delete.d.ts +17 -0
- package/dist/types/routes/data-index-list.d.ts +21 -0
- package/dist/types/routes/data-query.d.ts +49 -0
- package/dist/types/routes/data-reflect.d.ts +29 -0
- package/dist/types/routes/data-schema-get.d.ts +11 -0
- package/dist/types/routes/data-schema-set.d.ts +19 -0
- package/dist/types/routes/data-schema-test.d.ts +21 -0
- package/dist/types/routes/data-schemas-list.d.ts +11 -0
- package/dist/types/routes/data-set.d.ts +27 -0
- package/dist/types/routes/data-sync-changes.d.ts +28 -0
- package/dist/types/routes/data-sync-mutations.d.ts +28 -0
- package/dist/types/routes/data-transaction.d.ts +34 -0
- package/dist/types/routes/data-update.d.ts +27 -0
- package/dist/types/routes/data.d.ts +3 -0
- package/dist/types/routes/docs.d.ts +3 -0
- package/dist/types/routes/meta-info.d.ts +11 -0
- package/dist/types/routes/meta-ping.d.ts +7 -0
- package/dist/types/routes/meta-stats.d.ts +13 -0
- package/dist/types/routes/meta.d.ts +3 -0
- package/dist/types/routes/oauth2-init.d.ts +13 -0
- package/dist/types/routes/oauth2-refresh.d.ts +17 -0
- package/dist/types/routes/oauth2-signin.d.ts +15 -0
- package/dist/types/routes/webmanager.d.ts +3 -0
- package/dist/types/rules.d.ts +41 -0
- package/dist/types/schema/user.d.ts +85 -0
- package/dist/types/server.d.ts +106 -0
- package/dist/types/settings/email.d.ts +14 -0
- package/dist/types/settings/index.d.ts +165 -0
- package/dist/types/shared/clients.d.ts +44 -0
- package/dist/types/shared/email.d.ts +34 -0
- package/dist/types/shared/env.d.ts +42 -0
- package/dist/types/shared/error.d.ts +15 -0
- package/dist/types/shared/http.d.ts +14 -0
- package/dist/types/shared/password.d.ts +19 -0
- package/dist/types/shared/rootpath.d.ts +2 -0
- package/dist/types/shared/signin.d.ts +31 -0
- package/dist/types/shared/simple-fetch.d.ts +21 -0
- package/dist/types/shared/tokens.d.ts +23 -0
- package/dist/types/shared/validate.d.ts +22 -0
- package/dist/types/start.d.ts +1 -0
- package/dist/types/test.d.ts +1 -0
- package/dist/types/websocket/index.d.ts +2 -0
- package/dist/types/websocket/manager.d.ts +99 -0
- package/dist/types/websocket/socket.io.d.ts +10 -0
- package/package.json +23 -8
- package/src/auth.ts +87 -0
- package/src/cluster.ts +62 -0
- package/src/index.ts +2 -0
- package/src/middleware/404.ts +13 -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/{ts/oauth-providers → oauth-providers}/dropbox.ts +1 -1
- package/src/{ts/oauth-providers → oauth-providers}/facebook.ts +1 -1
- package/src/{ts/oauth-providers → oauth-providers}/google.ts +1 -1
- package/src/oauth-providers/index.ts +20 -0
- package/src/{ts/oauth-providers → oauth-providers}/instagram.ts +1 -1
- package/src/{ts/oauth-providers → oauth-providers}/oauth-provider.ts +0 -0
- package/src/{ts/oauth-providers → oauth-providers}/spotify.ts +1 -1
- package/src/routes/auth-change-password.ts +89 -0
- package/src/{ts/routes → routes}/auth-change-password.yaml +0 -2
- package/src/routes/auth-delete.ts +47 -0
- package/src/{ts/routes → routes}/auth-delete.yaml +0 -0
- package/src/routes/auth-forgot-password.ts +73 -0
- package/src/{ts/routes → routes}/auth-forgot-password.yaml +0 -0
- package/src/routes/auth-reset-password.ts +93 -0
- package/src/{ts/routes → routes}/auth-reset-password.yaml +0 -0
- package/src/routes/auth-signin.ts +55 -0
- package/src/{ts/routes → routes}/auth-signin.yaml +5 -5
- package/src/routes/auth-signout.ts +61 -0
- package/src/{ts/routes → routes}/auth-signout.yaml +0 -0
- package/src/routes/auth-signup.ts +161 -0
- package/src/{ts/routes → routes}/auth-signup.yaml +15 -0
- package/src/routes/auth-state.ts +20 -0
- package/src/{ts/routes → routes}/auth-state.yaml +0 -0
- package/src/routes/auth-update.ts +147 -0
- package/src/{ts/routes → routes}/auth-update.yaml +22 -2
- package/src/routes/auth-verify-email.ts +67 -0
- package/src/{ts/routes → routes}/auth-verify-email.yaml +0 -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 +68 -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 +85 -0
- package/src/routes/data-index-create.yaml +105 -0
- package/src/routes/data-index-delete.ts +39 -0
- package/src/routes/data-index-delete.yaml +51 -0
- package/src/routes/data-index-list.ts +42 -0
- package/src/routes/data-index-list.yaml +80 -0
- package/src/routes/data-query.ts +97 -0
- package/src/routes/data-query.yaml +166 -0
- package/src/routes/data-reflect.ts +94 -0
- package/src/routes/data-reflect.yaml +124 -0
- package/src/routes/data-schema-get.ts +38 -0
- package/src/routes/data-schema-get.yaml +53 -0
- package/src/routes/data-schema-set.ts +38 -0
- package/src/routes/data-schema-set.yaml +60 -0
- package/src/routes/data-schema-test.ts +53 -0
- package/src/routes/data-schema-test.yaml +66 -0
- package/src/routes/data-schemas-list.ts +33 -0
- package/src/routes/data-schemas-list.yaml +41 -0
- package/src/routes/data-set.ts +76 -0
- package/src/routes/data-set.yaml +71 -0
- package/src/routes/data-sync-changes.ts +78 -0
- package/src/routes/data-sync-changes.yaml +67 -0
- package/src/routes/data-sync-mutations.ts +78 -0
- package/src/routes/data-sync-mutations.yaml +67 -0
- package/src/routes/data-transaction-finish.yaml +76 -0
- package/src/routes/data-transaction-start.yaml +58 -0
- package/src/routes/data-transaction.ts +144 -0
- package/src/routes/data-update.ts +77 -0
- package/src/routes/data-update.yaml +71 -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-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 +18 -0
- package/src/routes/oauth2-init.ts +44 -0
- package/src/{ts/routes → routes}/oauth2-init.yaml +0 -0
- package/src/routes/oauth2-refresh.ts +39 -0
- package/src/{ts/routes → routes}/oauth2-refresh.yaml +0 -0
- package/src/routes/oauth2-signin.ts +281 -0
- package/src/{ts/routes → routes}/oauth2-signin.yaml +0 -0
- package/src/routes/webmanager.ts +29 -0
- package/src/rules.ts +196 -0
- package/src/schema/user.ts +99 -0
- package/src/server.ts +416 -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 +24 -0
- package/src/shared/password.ts +41 -0
- package/src/shared/rootpath.ts +15 -0
- package/src/shared/signin.ts +143 -0
- package/src/{ts/oauth-providers → shared}/simple-fetch.ts +2 -2
- package/src/shared/tokens.ts +77 -0
- package/src/shared/validate.ts +53 -0
- package/src/{start.js → start.ts} +7 -5
- package/src/test.ts +10 -0
- package/src/websocket/index.ts +320 -0
- package/src/websocket/manager.ts +46 -0
- package/src/websocket/socket.io.ts +91 -0
- package/tsconfig-cjs.json +10 -0
- package/tsconfig.json +13 -5
- package/{src/webmanager → webmanager}/index.html +0 -0
- package/{src/webmanager → webmanager}/index.js +0 -0
- package/src/acebase-server.js +0 -3060
- package/src/index.d.ts +0 -212
- package/src/index.js +0 -2
- package/src/routes/docs.js +0 -97
- package/src/ts/routes/docs.ts +0 -100
|
@@ -0,0 +1,147 @@
|
|
|
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
|
+
|
|
40
|
+
if (!req.user) {
|
|
41
|
+
env.logRef.push({ action: 'update', success: false, code: 'unauthenticated_update', update_uid: details.uid, ip: req.ip, date: new Date() });
|
|
42
|
+
return sendNotAuthenticatedError(res, 'unauthenticated_update', 'Sign in to change details');
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const uid = details.uid || req.user.uid;
|
|
46
|
+
|
|
47
|
+
if (req.user.uid !== 'admin' && (uid !== req.user.uid || typeof details.is_disabled === 'boolean')) {
|
|
48
|
+
env.logRef.push({ action: 'update', success: false, code: 'unauthorized_update', auth_uid: req.user.uid, update_uid: details.uid, ip: req.ip, date: new Date() });
|
|
49
|
+
return sendUnauthorizedError(res, 'unauthorized_update', 'You are not authorized to perform this update. This attempt has been logged.');
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (typeof details.display_name === 'undefined' && typeof details.displayName === 'string') {
|
|
53
|
+
// Allow displayName to be sent also (which is used in signup endpoint)
|
|
54
|
+
details.display_name = details.displayName;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Check if sent details are ok
|
|
58
|
+
let err: { code: UpdateError['code'], message: string };
|
|
59
|
+
if (details.email && !isValidEmail(details.email)) {
|
|
60
|
+
err = invalidEmailError;
|
|
61
|
+
}
|
|
62
|
+
else if (details.email && !await isValidNewEmailAddress(env.authRef, details.email)) {
|
|
63
|
+
err = emailExistsError;
|
|
64
|
+
}
|
|
65
|
+
else if (details.username && !isValidUsername(details.username)) {
|
|
66
|
+
err = invalidUsernameError;
|
|
67
|
+
}
|
|
68
|
+
else if (details.username && !await isValidNewUsername(env.authRef, details.username)) {
|
|
69
|
+
err = usernameExistsError;
|
|
70
|
+
}
|
|
71
|
+
else if (details.display_name && !isValidDisplayName(details.display_name)) {
|
|
72
|
+
err = invalidDisplayNameError;
|
|
73
|
+
}
|
|
74
|
+
else if (details.picture && !isValidPicture(details.picture)) {
|
|
75
|
+
err = invalidPictureError;
|
|
76
|
+
}
|
|
77
|
+
else if (!isValidSettings(details.settings)) {
|
|
78
|
+
err = invalidSettingsError;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (err) {
|
|
82
|
+
// Log failure
|
|
83
|
+
env.logRef.push({ action: 'update', success: false, code: err.code, auth_uid: req.user.uid, update_uid: uid, ip: req.ip, date: new Date() });
|
|
84
|
+
res.status(422).send(err); // Unprocessable Entity
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
try {
|
|
89
|
+
let user: DbUserAccountDetails;
|
|
90
|
+
await env.authRef.child(uid).transaction(snap => {
|
|
91
|
+
if (!snap.exists()) {
|
|
92
|
+
throw new UpdateError('user_not_found', `No user found with uid ${uid}`);
|
|
93
|
+
}
|
|
94
|
+
user = snap.val();
|
|
95
|
+
if (details.email && details.email !== user.email) {
|
|
96
|
+
user.email = details.email;
|
|
97
|
+
user.email_verified = false; // TODO: send verification email
|
|
98
|
+
}
|
|
99
|
+
if (details.username) { user.username = details.username; }
|
|
100
|
+
if (details.display_name) { user.display_name = details.display_name; }
|
|
101
|
+
if (details.picture) { user.picture = details.picture; }
|
|
102
|
+
if (details.settings) {
|
|
103
|
+
if (typeof user.settings !== 'object') {
|
|
104
|
+
user.settings = {};
|
|
105
|
+
}
|
|
106
|
+
Object.keys(details.settings).forEach(key => {
|
|
107
|
+
user.settings[key] = details.settings[key];
|
|
108
|
+
});
|
|
109
|
+
if (!isValidSettings(user.settings)) {
|
|
110
|
+
err = invalidSettingsError;
|
|
111
|
+
env.logRef.push({ action: 'update', success: false, code: 'too_many_settings', auth_uid: req.user.uid, update_uid: details.uid, ip: req.ip, date: new Date() });
|
|
112
|
+
res.statusCode = 422; // Unprocessable Entity
|
|
113
|
+
res.send(err);
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
if (typeof details.is_disabled === 'boolean') {
|
|
118
|
+
user.is_disabled = details.is_disabled;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return user; // Update db user
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
// Update cache
|
|
125
|
+
env.authCache.set(user.uid, user);
|
|
126
|
+
|
|
127
|
+
// Send merged results back
|
|
128
|
+
res.send({ user: getPublicAccountDetails(user) });
|
|
129
|
+
}
|
|
130
|
+
catch (err) {
|
|
131
|
+
|
|
132
|
+
// All known errors except user_not_found will have been sent already
|
|
133
|
+
if (err.code === 'user_not_found') {
|
|
134
|
+
env.logRef.push({ action: 'update', success: false, code: err.code, auth_uid: req.user.uid, update_uid: details.uid, ip: req.ip, date: new Date() });
|
|
135
|
+
|
|
136
|
+
res.statusCode = 404; // Not Found
|
|
137
|
+
res.send(err);
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
// Unexpected
|
|
141
|
+
env.logRef.push({ action: 'update', success: false, code: err.code || 'unexpected', message: err.message, auth_uid: req.user.uid, update_uid: details.uid, ip: req.ip, date: new Date() });
|
|
142
|
+
sendUnexpectedError(res, err);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
});
|
|
147
|
+
};
|
|
@@ -31,11 +31,15 @@
|
|
|
31
31
|
username:
|
|
32
32
|
type: string
|
|
33
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)
|
|
34
37
|
display_name:
|
|
35
38
|
type: string
|
|
36
|
-
description: Name of the user for public displaying purposes. Consider this a real name, alias or handle. (NOTE this property
|
|
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)
|
|
37
40
|
picture:
|
|
38
41
|
type: object
|
|
42
|
+
description: Profile picture
|
|
39
43
|
properties:
|
|
40
44
|
url:
|
|
41
45
|
type: string
|
|
@@ -98,6 +102,22 @@
|
|
|
98
102
|
example:
|
|
99
103
|
code: unauthorized_update
|
|
100
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
|
|
101
121
|
422:
|
|
102
122
|
description: When the sent request details are incorrect, this "422 Unprocessable Entity" is returned
|
|
103
123
|
content:
|
|
@@ -116,7 +136,7 @@
|
|
|
116
136
|
- invalid_display_name
|
|
117
137
|
- invalid_picture
|
|
118
138
|
- invalid_settings
|
|
119
|
-
example:
|
|
139
|
+
example: user_not_found
|
|
120
140
|
message:
|
|
121
141
|
type: string
|
|
122
142
|
description: Description of the error
|
|
@@ -0,0 +1,67 @@
|
|
|
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 verifyEmailAddress = async (clientIp: string, code: string) => {
|
|
25
|
+
try {
|
|
26
|
+
var verification = parseSignedPublicToken(code, env.tokenSalt);
|
|
27
|
+
}
|
|
28
|
+
catch (err) {
|
|
29
|
+
throw new VerifyEmailError('invalid_code', err.message);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const snap = await env.authRef.child(verification.uid).get();
|
|
33
|
+
if (!snap.exists()) {
|
|
34
|
+
throw new VerifyEmailError('unknown_user', 'Unknown user');
|
|
35
|
+
}
|
|
36
|
+
const user: DbUserAccountDetails = snap.val();
|
|
37
|
+
user.uid = snap.key as string;
|
|
38
|
+
|
|
39
|
+
// No need to do further checks, code was signed by us so we can trust the contents
|
|
40
|
+
// Mark account as verified
|
|
41
|
+
await snap.ref.update({ email_verified: true });
|
|
42
|
+
|
|
43
|
+
env.logRef.push({ action: 'verify_email', success: true, ip: clientIp, date: new Date(), uid: user.uid });
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
env.app.post(`/auth/${env.db.name}/verify_email`, async (req: Request, res) => {
|
|
47
|
+
|
|
48
|
+
const details = req.body;
|
|
49
|
+
try {
|
|
50
|
+
await verifyEmailAddress(req.ip, details.code);
|
|
51
|
+
res.send('OK');
|
|
52
|
+
}
|
|
53
|
+
catch (err) {
|
|
54
|
+
env.logRef.push({ action: 'verify_email', success: false, code: err.code, message: err.message, ip: req.ip, date: new Date(), uid: req.user?.uid ?? null });
|
|
55
|
+
if (err.code) {
|
|
56
|
+
sendBadRequestError(res, err);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
sendUnexpectedError(res, err);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
return verifyEmailAddress;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export default addRoute;
|
|
File without changes
|
|
@@ -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;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { RouteInitEnvironment, RouteRequest } from '../shared/env';
|
|
2
|
+
import { sendUnauthorizedError } from '../shared/error';
|
|
3
|
+
|
|
4
|
+
export type RequestQuery = null;
|
|
5
|
+
export type RequestBody = null;
|
|
6
|
+
export type ResponseBody = { exists: boolean };
|
|
7
|
+
export type Request = RouteRequest<any, ResponseBody, RequestBody, RequestQuery>;
|
|
8
|
+
|
|
9
|
+
export const addRoute = (env: RouteInitEnvironment) => {
|
|
10
|
+
|
|
11
|
+
env.app.get(`/exists/${env.db.name}/*`, async (req: Request, res) => {
|
|
12
|
+
// Exists query
|
|
13
|
+
const path = req.path.slice(env.db.name.length + 9);
|
|
14
|
+
const access = env.rules.userHasAccess(req.user, path, false);
|
|
15
|
+
if (!access.allow) {
|
|
16
|
+
return sendUnauthorizedError(res, access.code, access.message);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
try {
|
|
20
|
+
const exists = await env.db.ref(path).exists();
|
|
21
|
+
res.send({ exists });
|
|
22
|
+
}
|
|
23
|
+
catch(err) {
|
|
24
|
+
res.statusCode = 500;
|
|
25
|
+
res.send(err);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export default addRoute;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/exists/{dbname}/{path}:
|
|
2
|
+
get:
|
|
3
|
+
tags:
|
|
4
|
+
- data
|
|
5
|
+
summary: Get existence of a path
|
|
6
|
+
description: Gets the existence of a path in the database
|
|
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
|
+
- name: path
|
|
16
|
+
in: path
|
|
17
|
+
description: database path
|
|
18
|
+
required: true
|
|
19
|
+
schema:
|
|
20
|
+
type: string
|
|
21
|
+
example: collection/child/property
|
|
22
|
+
responses:
|
|
23
|
+
200:
|
|
24
|
+
description: returns whether the target path exists in the database
|
|
25
|
+
content:
|
|
26
|
+
'application/json':
|
|
27
|
+
schema:
|
|
28
|
+
type: object
|
|
29
|
+
properties:
|
|
30
|
+
exists:
|
|
31
|
+
type: boolean
|
|
32
|
+
example: true
|
|
33
|
+
403:
|
|
34
|
+
description: Returns a "403 Forbidden" if the signed in user is not allowed to read from the target path
|
|
35
|
+
content:
|
|
36
|
+
'application/json':
|
|
37
|
+
schema:
|
|
38
|
+
$ref: '#/components/schemas/Error'
|
|
39
|
+
500:
|
|
40
|
+
description: An unexpected error occurred
|
|
41
|
+
content:
|
|
42
|
+
'application/json':
|
|
43
|
+
schema:
|
|
44
|
+
$ref: '#/components/schemas/UnexpectedError'
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { RouteInitEnvironment, RouteRequest } from '../shared/env';
|
|
2
|
+
import { sendUnauthorizedError } from '../shared/error';
|
|
3
|
+
|
|
4
|
+
export type RequestQuery = {
|
|
5
|
+
format?: 'json';
|
|
6
|
+
type_safe?: '0'|'1'
|
|
7
|
+
};
|
|
8
|
+
export type RequestBody = null;
|
|
9
|
+
export type ResponseBody = any;
|
|
10
|
+
export type Request = RouteRequest<any, ResponseBody, RequestBody, RequestQuery>;
|
|
11
|
+
|
|
12
|
+
export const addRoute = (env: RouteInitEnvironment) => {
|
|
13
|
+
|
|
14
|
+
env.app.get(`/export/${env.db.name}/*`, async (req: Request, res) => {
|
|
15
|
+
// Export API
|
|
16
|
+
const path = req.path.slice(env.db.name.length + 9);
|
|
17
|
+
const access = env.rules.userHasAccess(req.user, path, false);
|
|
18
|
+
if (!access.allow) {
|
|
19
|
+
return sendUnauthorizedError(res, access.code, access.message);
|
|
20
|
+
}
|
|
21
|
+
const format = req.query.format || 'json';
|
|
22
|
+
const type_safe = req.query.type_safe !== '0';
|
|
23
|
+
|
|
24
|
+
const write = async (chunk) => {
|
|
25
|
+
let ok = res.write(chunk);
|
|
26
|
+
if (!ok) {
|
|
27
|
+
await new Promise(resolve => res.once('drain', resolve));
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const ref = env.db.ref(path);
|
|
32
|
+
res.setHeader('Content-Disposition', `attachment; filename=${ref.key || 'export'}.json`); // Will be treated as a download in browser
|
|
33
|
+
|
|
34
|
+
try {
|
|
35
|
+
await ref.export(write, { format, type_safe });
|
|
36
|
+
}
|
|
37
|
+
catch (err) {
|
|
38
|
+
env.debug.error(`Error exporting data for path "/${path}": `, err);
|
|
39
|
+
if (!res.headersSent) {
|
|
40
|
+
res.statusCode = 500;
|
|
41
|
+
res.send(err);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
finally {
|
|
45
|
+
res.end();
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export default addRoute;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/export/{dbname}/{path}:
|
|
2
|
+
get:
|
|
3
|
+
tags:
|
|
4
|
+
- data
|
|
5
|
+
summary: Export (stream) the value of a path
|
|
6
|
+
description: Exports the value of a path in the database by streaming its content in a serialized format
|
|
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
|
+
- name: path
|
|
16
|
+
in: path
|
|
17
|
+
description: database path
|
|
18
|
+
required: true
|
|
19
|
+
schema:
|
|
20
|
+
type: string
|
|
21
|
+
example: collection
|
|
22
|
+
- name: format
|
|
23
|
+
in: query
|
|
24
|
+
description: desired output format. Only `json` is currently supported
|
|
25
|
+
schema:
|
|
26
|
+
type: string
|
|
27
|
+
enum:
|
|
28
|
+
- json
|
|
29
|
+
example: json
|
|
30
|
+
- name: type_safe
|
|
31
|
+
in: query
|
|
32
|
+
description: Whether to add type information for data that has no native JSON representation (such as dates, binary data etc)
|
|
33
|
+
schema:
|
|
34
|
+
type: string
|
|
35
|
+
enum:
|
|
36
|
+
- 0
|
|
37
|
+
- 1
|
|
38
|
+
example: 1
|
|
39
|
+
responses:
|
|
40
|
+
200:
|
|
41
|
+
description: Streams the data of requested path in the requested format. In the browser, this will trigger a file download.
|
|
42
|
+
headers:
|
|
43
|
+
'Content-Disposition':
|
|
44
|
+
description: Tells the browser to download the data as a file
|
|
45
|
+
schema:
|
|
46
|
+
type: string
|
|
47
|
+
example: attachment; filename=[target_key].json
|
|
48
|
+
content:
|
|
49
|
+
'text/plain':
|
|
50
|
+
schema:
|
|
51
|
+
type: object
|
|
52
|
+
example: {"l27mgh8r000009mhh84jdp9c":{"name":"My todo list","stats":{"size":216,"created":{".type":"date",".val":"2022-04-07T15:11:42.000Z"},"modified":{".type":"date",".val":"2022-03-08T12:24:05.000Z"}}},"l27mhwz2000109mh11yi7rbo":{"name":"Another child"},"l27mjf9k000209mhafylc3eo":{"name":"And another.."}}
|
|
53
|
+
403:
|
|
54
|
+
description: Returns a "403 Forbidden" if the signed in user is not allowed to read from the target path
|
|
55
|
+
content:
|
|
56
|
+
'application/json':
|
|
57
|
+
schema:
|
|
58
|
+
$ref: '#/components/schemas/Error'
|
|
59
|
+
500:
|
|
60
|
+
description: An unexpected error occurred
|
|
61
|
+
content:
|
|
62
|
+
'application/json':
|
|
63
|
+
schema:
|
|
64
|
+
$ref: '#/components/schemas/UnexpectedError'
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { Transport } from 'acebase-core';
|
|
2
|
+
import { SerializedValue } from 'acebase-core/types/transport';
|
|
3
|
+
import { RouteInitEnvironment, RouteRequest } from '../shared/env';
|
|
4
|
+
import { sendUnauthorizedError } from '../shared/error';
|
|
5
|
+
|
|
6
|
+
export type RequestQuery = { include?: string; exclude?: string; child_objects?: boolean };
|
|
7
|
+
export type RequestBody = null;
|
|
8
|
+
export type ResponseBody = SerializedValue & { exists: boolean };
|
|
9
|
+
export type Request = RouteRequest<any, ResponseBody, RequestBody, RequestQuery>;
|
|
10
|
+
|
|
11
|
+
export const addRoute = (env: RouteInitEnvironment) => {
|
|
12
|
+
|
|
13
|
+
env.app.get(`/data/${env.db.name}/*`, async (req: Request, res) => {
|
|
14
|
+
// Request data
|
|
15
|
+
const path = req.path.slice(env.db.name.length + 7);
|
|
16
|
+
const access = env.rules.userHasAccess(req.user, path, false);
|
|
17
|
+
if (!access.allow) {
|
|
18
|
+
return sendUnauthorizedError(res, access.code, access.message);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const options: { include?: string[]; exclude?: string[]; child_objects?: boolean } = {};
|
|
22
|
+
if (req.query.include) {
|
|
23
|
+
options.include = req.query.include.split(',');
|
|
24
|
+
}
|
|
25
|
+
if (req.query.exclude) {
|
|
26
|
+
options.exclude = req.query.exclude.split(',');
|
|
27
|
+
}
|
|
28
|
+
if (typeof req.query.child_objects === 'boolean') {
|
|
29
|
+
options.child_objects = req.query.child_objects;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (path === '') {
|
|
33
|
+
// If user has access to the root of database (NOT recommended for others than admin...)
|
|
34
|
+
// Do not return private server data. If the admin user wants access, they should use
|
|
35
|
+
// direct requests on those paths (GET /data/dbname/__auth__), or use reflection
|
|
36
|
+
|
|
37
|
+
if (options.include) {
|
|
38
|
+
// Remove all includes for private paths
|
|
39
|
+
options.include = options.include.filter(path => !path.startsWith('__'));
|
|
40
|
+
}
|
|
41
|
+
// Add private paths to exclude
|
|
42
|
+
options.exclude = [...options.exclude || [], '__auth__', '__log__'];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
try {
|
|
46
|
+
// const snap = await db.ref(path).get(options);
|
|
47
|
+
// const value = snap.val(), context = snap.context();
|
|
48
|
+
const { value, context } = await env.db.api.get(path, options);
|
|
49
|
+
if (!env.config.transactions?.log) {
|
|
50
|
+
delete context.acebase_cursor;
|
|
51
|
+
}
|
|
52
|
+
const serialized = Transport.serialize(value);
|
|
53
|
+
|
|
54
|
+
res.setHeader('AceBase-Context', JSON.stringify(context));
|
|
55
|
+
res.send({
|
|
56
|
+
exists: value !== null,
|
|
57
|
+
val: serialized.val,
|
|
58
|
+
map: serialized.map
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
catch (err) {
|
|
62
|
+
res.status(500).send(err);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export default addRoute;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/data/{dbname}/{path}:
|
|
2
|
+
get:
|
|
3
|
+
tags:
|
|
4
|
+
- data
|
|
5
|
+
summary: Get the value of a path
|
|
6
|
+
description: Gets the stored value of a path in the database
|
|
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
|
+
- name: path
|
|
16
|
+
in: path
|
|
17
|
+
description: database path
|
|
18
|
+
required: true
|
|
19
|
+
schema:
|
|
20
|
+
type: string
|
|
21
|
+
example: collection/child/property
|
|
22
|
+
responses:
|
|
23
|
+
200:
|
|
24
|
+
description: Returns the serialized value of the target path, and whether it exists in the database
|
|
25
|
+
content:
|
|
26
|
+
'application/json':
|
|
27
|
+
schema:
|
|
28
|
+
required:
|
|
29
|
+
- val
|
|
30
|
+
- exists
|
|
31
|
+
allOf:
|
|
32
|
+
- type: object
|
|
33
|
+
properties:
|
|
34
|
+
exists:
|
|
35
|
+
type: boolean
|
|
36
|
+
description: indicates if the path exists (when `false`, `val` property will be `null`)
|
|
37
|
+
example: true
|
|
38
|
+
- $ref: '#/components/schemas/SerializedValue'
|
|
39
|
+
example:
|
|
40
|
+
exists: true
|
|
41
|
+
val: { name: 'My todo list', stats: { size: 216, created: '2022-04-07T15:11:42Z', modified: '2022-03-08T12:24:05Z' } }
|
|
42
|
+
map: { 'stats/created': 'date', 'stats/modified': 'date' }
|
|
43
|
+
403:
|
|
44
|
+
description: Returns a "403 Forbidden" if the signed in user is not allowed to read from the target path
|
|
45
|
+
content:
|
|
46
|
+
'application/json':
|
|
47
|
+
schema:
|
|
48
|
+
$ref: '#/components/schemas/Error'
|
|
49
|
+
500:
|
|
50
|
+
description: An unexpected error occurred
|
|
51
|
+
content:
|
|
52
|
+
'application/json':
|
|
53
|
+
schema:
|
|
54
|
+
$ref: '#/components/schemas/UnexpectedError'
|