acebase-server 1.15.2 → 1.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +49 -0
- package/README.md +10 -0
- package/dist/cjs/auth.js +2 -2
- package/dist/cjs/cluster.js +2 -2
- package/dist/cjs/middleware/cors.js +3 -3
- package/dist/cjs/oauth-providers/dropbox.js +22 -22
- package/dist/cjs/oauth-providers/facebook.js +16 -16
- package/dist/cjs/oauth-providers/google.js +33 -39
- package/dist/cjs/oauth-providers/index.js +1 -1
- package/dist/cjs/oauth-providers/instagram.js +12 -12
- package/dist/cjs/oauth-providers/oauth-provider.js +0 -5
- package/dist/cjs/oauth-providers/spotify.js +34 -34
- package/dist/cjs/routes/auth-change-password.js +5 -5
- package/dist/cjs/routes/auth-delete.js +1 -1
- package/dist/cjs/routes/auth-forgot-password.js +2 -2
- package/dist/cjs/routes/auth-reset-password.js +11 -9
- package/dist/cjs/routes/auth-signin.js +1 -1
- package/dist/cjs/routes/auth-signout.js +1 -1
- package/dist/cjs/routes/auth-signup.js +5 -5
- package/dist/cjs/routes/auth-update.js +1 -1
- package/dist/cjs/routes/auth-verify-email.js +8 -6
- package/dist/cjs/routes/auth.js +1 -1
- package/dist/cjs/routes/data-export.js +1 -1
- package/dist/cjs/routes/data-get.js +2 -2
- package/dist/cjs/routes/data-index-list.js +0 -1
- package/dist/cjs/routes/data-query.js +1 -1
- package/dist/cjs/routes/data-reflect.js +4 -4
- package/dist/cjs/routes/data-schema-get.js +1 -1
- package/dist/cjs/routes/data-schemas-list.js +1 -1
- package/dist/cjs/routes/data-transaction.js +1 -1
- package/dist/cjs/routes/docs.js +57 -54
- package/dist/cjs/routes/meta-info.js +8 -12
- package/dist/cjs/routes/meta-logs.js +1 -1
- package/dist/cjs/routes/oauth2-init.js +8 -5
- package/dist/cjs/routes/oauth2-refresh.js +2 -2
- package/dist/cjs/routes/oauth2-signin.js +23 -23
- package/dist/cjs/routes/webmanager.js +4 -4
- package/dist/cjs/rules.js +8 -8
- package/dist/cjs/schema/user.js +1 -2
- package/dist/cjs/server.js +74 -31
- package/dist/cjs/settings/email.js +0 -2
- package/dist/cjs/settings/index.js +19 -4
- package/dist/cjs/shared/email.js +0 -4
- package/dist/cjs/shared/env.js +0 -2
- package/dist/cjs/shared/error.js +0 -1
- package/dist/cjs/shared/http.js +9 -1
- package/dist/cjs/shared/password.js +5 -5
- package/dist/cjs/shared/rootpath.js +1 -1
- package/dist/cjs/shared/signin.js +3 -3
- package/dist/cjs/shared/simple-fetch.js +5 -5
- package/dist/cjs/shared/tokens.js +3 -3
- package/dist/cjs/start.js +6 -6
- package/dist/cjs/websocket/index.js +11 -11
- package/dist/cjs/websocket/socket.io.js +2 -1
- package/dist/esm/auth.js +5 -5
- package/dist/esm/cluster.js +2 -2
- package/dist/esm/middleware/admin-only.js +1 -1
- package/dist/esm/middleware/cors.js +3 -3
- package/dist/esm/middleware/user.js +3 -3
- package/dist/esm/oauth-providers/dropbox.js +47 -51
- package/dist/esm/oauth-providers/facebook.js +34 -38
- package/dist/esm/oauth-providers/google.js +33 -39
- package/dist/esm/oauth-providers/index.js +1 -1
- package/dist/esm/oauth-providers/instagram.js +28 -32
- package/dist/esm/oauth-providers/oauth-provider.js +0 -5
- package/dist/esm/oauth-providers/spotify.js +46 -52
- package/dist/esm/routes/auth-change-password.js +5 -5
- package/dist/esm/routes/auth-delete.js +1 -1
- package/dist/esm/routes/auth-forgot-password.js +2 -2
- package/dist/esm/routes/auth-reset-password.js +11 -9
- package/dist/esm/routes/auth-signin.js +1 -1
- package/dist/esm/routes/auth-signout.js +1 -1
- package/dist/esm/routes/auth-signup.js +5 -5
- package/dist/esm/routes/auth-update.js +1 -1
- package/dist/esm/routes/auth-verify-email.js +8 -6
- package/dist/esm/routes/auth.js +1 -1
- package/dist/esm/routes/data-export.js +1 -1
- package/dist/esm/routes/data-get.js +2 -2
- package/dist/esm/routes/data-index-list.js +0 -1
- package/dist/esm/routes/data-query.js +1 -1
- package/dist/esm/routes/data-reflect.js +4 -4
- package/dist/esm/routes/data-schema-get.js +1 -1
- package/dist/esm/routes/data-schemas-list.js +1 -1
- package/dist/esm/routes/data-transaction.js +1 -1
- package/dist/esm/routes/data.js +1 -1
- package/dist/esm/routes/docs.js +56 -54
- package/dist/esm/routes/meta-info.js +8 -12
- package/dist/esm/routes/meta-logs.js +1 -1
- package/dist/esm/routes/oauth2-init.js +8 -5
- package/dist/esm/routes/oauth2-refresh.js +2 -2
- package/dist/esm/routes/oauth2-signin.js +20 -20
- package/dist/esm/routes/webmanager.js +5 -5
- package/dist/esm/rules.js +8 -8
- package/dist/esm/schema/user.js +1 -2
- package/dist/esm/server.js +72 -30
- package/dist/esm/settings/email.js +0 -2
- package/dist/esm/settings/index.js +19 -4
- package/dist/esm/shared/email.js +0 -4
- package/dist/esm/shared/env.js +0 -2
- package/dist/esm/shared/error.js +0 -1
- package/dist/esm/shared/http.js +7 -0
- package/dist/esm/shared/password.js +5 -5
- package/dist/esm/shared/rootpath.js +2 -2
- package/dist/esm/shared/signin.js +6 -6
- package/dist/esm/shared/simple-fetch.js +5 -5
- package/dist/esm/shared/tokens.js +3 -3
- package/dist/esm/start.js +6 -6
- package/dist/esm/websocket/index.js +15 -15
- package/dist/esm/websocket/manager.js +1 -1
- package/dist/esm/websocket/socket.io.js +2 -1
- package/dist/types/auth.d.ts +1 -1
- package/dist/types/logger.d.ts +1 -1
- package/dist/types/middleware/404.d.ts +1 -1
- package/dist/types/middleware/admin-only.d.ts +3 -3
- package/dist/types/middleware/cache.d.ts +1 -1
- package/dist/types/middleware/context.d.ts +1 -1
- package/dist/types/middleware/cors.d.ts +1 -1
- package/dist/types/middleware/swagger.d.ts +1 -1
- package/dist/types/middleware/user.d.ts +1 -1
- package/dist/types/oauth-providers/dropbox.d.ts +1 -1
- package/dist/types/oauth-providers/facebook.d.ts +1 -1
- package/dist/types/oauth-providers/google.d.ts +1 -1
- package/dist/types/oauth-providers/instagram.d.ts +1 -1
- package/dist/types/oauth-providers/spotify.d.ts +1 -1
- package/dist/types/routes/auth-change-password.d.ts +2 -2
- package/dist/types/routes/auth-delete.d.ts +2 -2
- package/dist/types/routes/auth-forgot-password.d.ts +2 -2
- package/dist/types/routes/auth-reset-password.d.ts +2 -2
- package/dist/types/routes/auth-signin.d.ts +2 -2
- package/dist/types/routes/auth-signout.d.ts +2 -2
- package/dist/types/routes/auth-signup.d.ts +2 -2
- package/dist/types/routes/auth-state.d.ts +3 -3
- package/dist/types/routes/auth-update.d.ts +2 -2
- package/dist/types/routes/auth-verify-email.d.ts +2 -2
- package/dist/types/routes/data-exists.d.ts +1 -1
- package/dist/types/routes/data-export.d.ts +1 -1
- package/dist/types/routes/data-get.d.ts +1 -1
- package/dist/types/routes/data-import.d.ts +1 -1
- package/dist/types/routes/data-index-create.d.ts +2 -2
- package/dist/types/routes/data-index-delete.d.ts +1 -1
- package/dist/types/routes/data-index-list.d.ts +2 -2
- package/dist/types/routes/data-query.d.ts +1 -1
- package/dist/types/routes/data-reflect.d.ts +1 -1
- package/dist/types/routes/data-schema-get.d.ts +1 -1
- package/dist/types/routes/data-schema-set.d.ts +1 -1
- package/dist/types/routes/data-schema-test.d.ts +1 -1
- package/dist/types/routes/data-schemas-list.d.ts +1 -1
- package/dist/types/routes/data-set.d.ts +1 -1
- package/dist/types/routes/data-sync-changes.d.ts +1 -1
- package/dist/types/routes/data-sync-mutations.d.ts +1 -1
- package/dist/types/routes/data-transaction.d.ts +2 -2
- package/dist/types/routes/data-update.d.ts +1 -1
- package/dist/types/routes/data.d.ts +1 -1
- package/dist/types/routes/meta-info.d.ts +1 -1
- package/dist/types/routes/meta-logs.d.ts +1 -1
- package/dist/types/routes/meta-ping.d.ts +1 -1
- package/dist/types/routes/meta-stats.d.ts +1 -1
- package/dist/types/routes/oauth2-init.d.ts +1 -1
- package/dist/types/routes/oauth2-refresh.d.ts +1 -1
- package/dist/types/routes/oauth2-signin.d.ts +1 -1
- package/dist/types/routes/webmanager.d.ts +1 -1
- package/dist/types/schema/user.d.ts +2 -2
- package/dist/types/server.d.ts +3 -0
- package/dist/types/settings/index.d.ts +23 -0
- package/dist/types/shared/clients.d.ts +3 -3
- package/dist/types/shared/env.d.ts +2 -1
- package/dist/types/shared/http.d.ts +5 -0
- package/dist/types/shared/signin.d.ts +4 -4
- package/dist/types/shared/validate.d.ts +1 -1
- package/dist/types/websocket/index.d.ts +1 -1
- package/dist/types/websocket/manager.d.ts +1 -1
- package/img/acebase-swagger-ui.png +0 -0
- package/img/acebase-webmanager.png +0 -0
- package/package.json +10 -5
- package/src/routes/auth-signin.yaml +2 -2
- package/webmanager/acebase-client-browser.min.js +8 -11
- package/webmanager/index.html +1 -0
- package/webmanager/index.js +67 -71
- package/.vscode/launch.json +0 -24
- package/create-package-files +0 -25
- package/dist/cjs/auth.js.map +0 -1
- package/dist/cjs/cluster.js.map +0 -1
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/logger.js.map +0 -1
- package/dist/cjs/middleware/404.js.map +0 -1
- package/dist/cjs/middleware/admin-only.js.map +0 -1
- package/dist/cjs/middleware/cache.js.map +0 -1
- package/dist/cjs/middleware/connection.js.map +0 -1
- package/dist/cjs/middleware/context.js.map +0 -1
- package/dist/cjs/middleware/cors.js.map +0 -1
- package/dist/cjs/middleware/swagger.js.map +0 -1
- package/dist/cjs/middleware/user.js.map +0 -1
- package/dist/cjs/oauth-providers/dropbox.js.map +0 -1
- package/dist/cjs/oauth-providers/facebook.js.map +0 -1
- package/dist/cjs/oauth-providers/google.js.map +0 -1
- package/dist/cjs/oauth-providers/index.js.map +0 -1
- package/dist/cjs/oauth-providers/instagram.js.map +0 -1
- package/dist/cjs/oauth-providers/oauth-provider.js.map +0 -1
- package/dist/cjs/oauth-providers/spotify.js.map +0 -1
- package/dist/cjs/routes/auth-change-password.js.map +0 -1
- package/dist/cjs/routes/auth-delete.js.map +0 -1
- package/dist/cjs/routes/auth-forgot-password.js.map +0 -1
- package/dist/cjs/routes/auth-reset-password.js.map +0 -1
- package/dist/cjs/routes/auth-signin.js.map +0 -1
- package/dist/cjs/routes/auth-signout.js.map +0 -1
- package/dist/cjs/routes/auth-signup.js.map +0 -1
- package/dist/cjs/routes/auth-state.js.map +0 -1
- package/dist/cjs/routes/auth-update.js.map +0 -1
- package/dist/cjs/routes/auth-verify-email.js.map +0 -1
- package/dist/cjs/routes/auth.js.map +0 -1
- package/dist/cjs/routes/data-exists.js.map +0 -1
- package/dist/cjs/routes/data-export.js.map +0 -1
- package/dist/cjs/routes/data-get.js.map +0 -1
- package/dist/cjs/routes/data-import.js.map +0 -1
- package/dist/cjs/routes/data-index-create.js.map +0 -1
- package/dist/cjs/routes/data-index-delete.js.map +0 -1
- package/dist/cjs/routes/data-index-list.js.map +0 -1
- package/dist/cjs/routes/data-query.js.map +0 -1
- package/dist/cjs/routes/data-reflect.js.map +0 -1
- package/dist/cjs/routes/data-schema-get.js.map +0 -1
- package/dist/cjs/routes/data-schema-set.js.map +0 -1
- package/dist/cjs/routes/data-schema-test.js.map +0 -1
- package/dist/cjs/routes/data-schemas-list.js.map +0 -1
- package/dist/cjs/routes/data-set.js.map +0 -1
- package/dist/cjs/routes/data-sync-changes.js.map +0 -1
- package/dist/cjs/routes/data-sync-mutations.js.map +0 -1
- package/dist/cjs/routes/data-transaction.js.map +0 -1
- package/dist/cjs/routes/data-update.js.map +0 -1
- package/dist/cjs/routes/data.js.map +0 -1
- package/dist/cjs/routes/docs.js.map +0 -1
- package/dist/cjs/routes/meta-info.js.map +0 -1
- package/dist/cjs/routes/meta-logs.js.map +0 -1
- package/dist/cjs/routes/meta-ping.js.map +0 -1
- package/dist/cjs/routes/meta-stats.js.map +0 -1
- package/dist/cjs/routes/meta.js.map +0 -1
- package/dist/cjs/routes/oauth2-init.js.map +0 -1
- package/dist/cjs/routes/oauth2-refresh.js.map +0 -1
- package/dist/cjs/routes/oauth2-signin.js.map +0 -1
- package/dist/cjs/routes/webmanager.js.map +0 -1
- package/dist/cjs/rules.js.map +0 -1
- package/dist/cjs/schema/user.js.map +0 -1
- package/dist/cjs/server.js.map +0 -1
- package/dist/cjs/settings/email.js.map +0 -1
- package/dist/cjs/settings/index.js.map +0 -1
- package/dist/cjs/shared/clients.js.map +0 -1
- package/dist/cjs/shared/email.js.map +0 -1
- package/dist/cjs/shared/env.js.map +0 -1
- package/dist/cjs/shared/error.js.map +0 -1
- package/dist/cjs/shared/http.js.map +0 -1
- package/dist/cjs/shared/password.js.map +0 -1
- package/dist/cjs/shared/rootpath.js.map +0 -1
- package/dist/cjs/shared/signin.js.map +0 -1
- package/dist/cjs/shared/simple-fetch.js.map +0 -1
- package/dist/cjs/shared/tokens.js.map +0 -1
- package/dist/cjs/shared/validate.js.map +0 -1
- package/dist/cjs/start.js.map +0 -1
- package/dist/cjs/test.js.map +0 -1
- package/dist/cjs/websocket/index.js.map +0 -1
- package/dist/cjs/websocket/manager.js.map +0 -1
- package/dist/cjs/websocket/socket.io.js.map +0 -1
- package/dist/esm/auth.js.map +0 -1
- package/dist/esm/cluster.js.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/logger.js.map +0 -1
- package/dist/esm/middleware/404.js.map +0 -1
- package/dist/esm/middleware/admin-only.js.map +0 -1
- package/dist/esm/middleware/cache.js.map +0 -1
- package/dist/esm/middleware/connection.js.map +0 -1
- package/dist/esm/middleware/context.js.map +0 -1
- package/dist/esm/middleware/cors.js.map +0 -1
- package/dist/esm/middleware/swagger.js.map +0 -1
- package/dist/esm/middleware/user.js.map +0 -1
- package/dist/esm/oauth-providers/dropbox.js.map +0 -1
- package/dist/esm/oauth-providers/facebook.js.map +0 -1
- package/dist/esm/oauth-providers/google.js.map +0 -1
- package/dist/esm/oauth-providers/index.js.map +0 -1
- package/dist/esm/oauth-providers/instagram.js.map +0 -1
- package/dist/esm/oauth-providers/oauth-provider.js.map +0 -1
- package/dist/esm/oauth-providers/spotify.js.map +0 -1
- package/dist/esm/routes/auth-change-password.js.map +0 -1
- package/dist/esm/routes/auth-delete.js.map +0 -1
- package/dist/esm/routes/auth-forgot-password.js.map +0 -1
- package/dist/esm/routes/auth-reset-password.js.map +0 -1
- package/dist/esm/routes/auth-signin.js.map +0 -1
- package/dist/esm/routes/auth-signout.js.map +0 -1
- package/dist/esm/routes/auth-signup.js.map +0 -1
- package/dist/esm/routes/auth-state.js.map +0 -1
- package/dist/esm/routes/auth-update.js.map +0 -1
- package/dist/esm/routes/auth-verify-email.js.map +0 -1
- package/dist/esm/routes/auth.js.map +0 -1
- package/dist/esm/routes/data-exists.js.map +0 -1
- package/dist/esm/routes/data-export.js.map +0 -1
- package/dist/esm/routes/data-get.js.map +0 -1
- package/dist/esm/routes/data-import.js.map +0 -1
- package/dist/esm/routes/data-index-create.js.map +0 -1
- package/dist/esm/routes/data-index-delete.js.map +0 -1
- package/dist/esm/routes/data-index-list.js.map +0 -1
- package/dist/esm/routes/data-query.js.map +0 -1
- package/dist/esm/routes/data-reflect.js.map +0 -1
- package/dist/esm/routes/data-schema-get.js.map +0 -1
- package/dist/esm/routes/data-schema-set.js.map +0 -1
- package/dist/esm/routes/data-schema-test.js.map +0 -1
- package/dist/esm/routes/data-schemas-list.js.map +0 -1
- package/dist/esm/routes/data-set.js.map +0 -1
- package/dist/esm/routes/data-sync-changes.js.map +0 -1
- package/dist/esm/routes/data-sync-mutations.js.map +0 -1
- package/dist/esm/routes/data-transaction.js.map +0 -1
- package/dist/esm/routes/data-update.js.map +0 -1
- package/dist/esm/routes/data.js.map +0 -1
- package/dist/esm/routes/docs.js.map +0 -1
- package/dist/esm/routes/meta-info.js.map +0 -1
- package/dist/esm/routes/meta-logs.js.map +0 -1
- package/dist/esm/routes/meta-ping.js.map +0 -1
- package/dist/esm/routes/meta-stats.js.map +0 -1
- package/dist/esm/routes/meta.js.map +0 -1
- package/dist/esm/routes/oauth2-init.js.map +0 -1
- package/dist/esm/routes/oauth2-refresh.js.map +0 -1
- package/dist/esm/routes/oauth2-signin.js.map +0 -1
- package/dist/esm/routes/webmanager.js.map +0 -1
- package/dist/esm/rules.js.map +0 -1
- package/dist/esm/schema/user.js.map +0 -1
- package/dist/esm/server.js.map +0 -1
- package/dist/esm/settings/email.js.map +0 -1
- package/dist/esm/settings/index.js.map +0 -1
- package/dist/esm/shared/clients.js.map +0 -1
- package/dist/esm/shared/email.js.map +0 -1
- package/dist/esm/shared/env.js.map +0 -1
- package/dist/esm/shared/error.js.map +0 -1
- package/dist/esm/shared/http.js.map +0 -1
- package/dist/esm/shared/password.js.map +0 -1
- package/dist/esm/shared/rootpath.js.map +0 -1
- package/dist/esm/shared/signin.js.map +0 -1
- package/dist/esm/shared/simple-fetch.js.map +0 -1
- package/dist/esm/shared/tokens.js.map +0 -1
- package/dist/esm/shared/validate.js.map +0 -1
- package/dist/esm/start.js.map +0 -1
- package/dist/esm/test.js.map +0 -1
- package/dist/esm/websocket/index.js.map +0 -1
- package/dist/esm/websocket/manager.js.map +0 -1
- package/dist/esm/websocket/socket.io.js.map +0 -1
- package/dist/types/auth.d.ts.map +0 -1
- package/dist/types/cluster.d.ts.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/logger.d.ts.map +0 -1
- package/dist/types/middleware/404.d.ts.map +0 -1
- package/dist/types/middleware/admin-only.d.ts.map +0 -1
- package/dist/types/middleware/cache.d.ts.map +0 -1
- package/dist/types/middleware/connection.d.ts.map +0 -1
- package/dist/types/middleware/context.d.ts.map +0 -1
- package/dist/types/middleware/cors.d.ts.map +0 -1
- package/dist/types/middleware/swagger.d.ts.map +0 -1
- package/dist/types/middleware/user.d.ts.map +0 -1
- package/dist/types/oauth-providers/dropbox.d.ts.map +0 -1
- package/dist/types/oauth-providers/facebook.d.ts.map +0 -1
- package/dist/types/oauth-providers/google.d.ts.map +0 -1
- package/dist/types/oauth-providers/index.d.ts.map +0 -1
- package/dist/types/oauth-providers/instagram.d.ts.map +0 -1
- package/dist/types/oauth-providers/oauth-provider.d.ts.map +0 -1
- package/dist/types/oauth-providers/spotify.d.ts.map +0 -1
- package/dist/types/routes/auth-change-password.d.ts.map +0 -1
- package/dist/types/routes/auth-delete.d.ts.map +0 -1
- package/dist/types/routes/auth-forgot-password.d.ts.map +0 -1
- package/dist/types/routes/auth-reset-password.d.ts.map +0 -1
- package/dist/types/routes/auth-signin.d.ts.map +0 -1
- package/dist/types/routes/auth-signout.d.ts.map +0 -1
- package/dist/types/routes/auth-signup.d.ts.map +0 -1
- package/dist/types/routes/auth-state.d.ts.map +0 -1
- package/dist/types/routes/auth-update.d.ts.map +0 -1
- package/dist/types/routes/auth-verify-email.d.ts.map +0 -1
- package/dist/types/routes/auth.d.ts.map +0 -1
- package/dist/types/routes/data-exists.d.ts.map +0 -1
- package/dist/types/routes/data-export.d.ts.map +0 -1
- package/dist/types/routes/data-get.d.ts.map +0 -1
- package/dist/types/routes/data-import.d.ts.map +0 -1
- package/dist/types/routes/data-index-create.d.ts.map +0 -1
- package/dist/types/routes/data-index-delete.d.ts.map +0 -1
- package/dist/types/routes/data-index-list.d.ts.map +0 -1
- package/dist/types/routes/data-query.d.ts.map +0 -1
- package/dist/types/routes/data-reflect.d.ts.map +0 -1
- package/dist/types/routes/data-schema-get.d.ts.map +0 -1
- package/dist/types/routes/data-schema-set.d.ts.map +0 -1
- package/dist/types/routes/data-schema-test.d.ts.map +0 -1
- package/dist/types/routes/data-schemas-list.d.ts.map +0 -1
- package/dist/types/routes/data-set.d.ts.map +0 -1
- package/dist/types/routes/data-sync-changes.d.ts.map +0 -1
- package/dist/types/routes/data-sync-mutations.d.ts.map +0 -1
- package/dist/types/routes/data-transaction.d.ts.map +0 -1
- package/dist/types/routes/data-update.d.ts.map +0 -1
- package/dist/types/routes/data.d.ts.map +0 -1
- package/dist/types/routes/docs.d.ts.map +0 -1
- package/dist/types/routes/meta-info.d.ts.map +0 -1
- package/dist/types/routes/meta-logs.d.ts.map +0 -1
- package/dist/types/routes/meta-ping.d.ts.map +0 -1
- package/dist/types/routes/meta-stats.d.ts.map +0 -1
- package/dist/types/routes/meta.d.ts.map +0 -1
- package/dist/types/routes/oauth2-init.d.ts.map +0 -1
- package/dist/types/routes/oauth2-refresh.d.ts.map +0 -1
- package/dist/types/routes/oauth2-signin.d.ts.map +0 -1
- package/dist/types/routes/webmanager.d.ts.map +0 -1
- package/dist/types/rules.d.ts.map +0 -1
- package/dist/types/schema/user.d.ts.map +0 -1
- package/dist/types/server.d.ts.map +0 -1
- package/dist/types/settings/email.d.ts.map +0 -1
- package/dist/types/settings/index.d.ts.map +0 -1
- package/dist/types/shared/clients.d.ts.map +0 -1
- package/dist/types/shared/email.d.ts.map +0 -1
- package/dist/types/shared/env.d.ts.map +0 -1
- package/dist/types/shared/error.d.ts.map +0 -1
- package/dist/types/shared/http.d.ts.map +0 -1
- package/dist/types/shared/password.d.ts.map +0 -1
- package/dist/types/shared/rootpath.d.ts.map +0 -1
- package/dist/types/shared/signin.d.ts.map +0 -1
- package/dist/types/shared/simple-fetch.d.ts.map +0 -1
- package/dist/types/shared/tokens.d.ts.map +0 -1
- package/dist/types/shared/validate.d.ts.map +0 -1
- package/dist/types/start.d.ts.map +0 -1
- package/dist/types/test.d.ts.map +0 -1
- package/dist/types/websocket/index.d.ts.map +0 -1
- package/dist/types/websocket/manager.d.ts.map +0 -1
- package/dist/types/websocket/socket.io.d.ts.map +0 -1
- package/src/auth.ts +0 -87
- package/src/cluster.ts +0 -62
- package/src/index.ts +0 -4
- package/src/logger.ts +0 -56
- package/src/middleware/404.ts +0 -13
- package/src/middleware/admin-only.ts +0 -29
- package/src/middleware/cache.ts +0 -15
- package/src/middleware/connection.ts +0 -48
- package/src/middleware/context.ts +0 -23
- package/src/middleware/cors.ts +0 -49
- package/src/middleware/swagger.ts +0 -19
- package/src/middleware/user.ts +0 -51
- package/src/oauth-providers/dropbox.ts +0 -144
- package/src/oauth-providers/facebook.ts +0 -103
- package/src/oauth-providers/google.ts +0 -147
- package/src/oauth-providers/index.ts +0 -21
- package/src/oauth-providers/instagram.ts +0 -98
- package/src/oauth-providers/oauth-provider.ts +0 -65
- package/src/oauth-providers/spotify.ts +0 -127
- package/src/placeholder.d.ts +0 -12
- package/src/routes/auth-change-password.ts +0 -92
- package/src/routes/auth-delete.ts +0 -49
- package/src/routes/auth-forgot-password.ts +0 -77
- package/src/routes/auth-reset-password.ts +0 -96
- package/src/routes/auth-signin.ts +0 -55
- package/src/routes/auth-signout.ts +0 -64
- package/src/routes/auth-signup.ts +0 -164
- package/src/routes/auth-state.ts +0 -20
- package/src/routes/auth-update.ts +0 -149
- package/src/routes/auth-verify-email.ts +0 -75
- package/src/routes/auth.ts +0 -67
- package/src/routes/data-exists.ts +0 -31
- package/src/routes/data-export.ts +0 -51
- package/src/routes/data-get.ts +0 -67
- package/src/routes/data-import.ts +0 -56
- package/src/routes/data-index-create.ts +0 -82
- package/src/routes/data-index-delete.ts +0 -36
- package/src/routes/data-index-list.ts +0 -39
- package/src/routes/data-query.ts +0 -97
- package/src/routes/data-reflect.ts +0 -91
- package/src/routes/data-schema-get.ts +0 -36
- package/src/routes/data-schema-set.ts +0 -35
- package/src/routes/data-schema-test.ts +0 -48
- package/src/routes/data-schemas-list.ts +0 -31
- package/src/routes/data-set.ts +0 -83
- package/src/routes/data-sync-changes.ts +0 -77
- package/src/routes/data-sync-mutations.ts +0 -77
- package/src/routes/data-transaction.ts +0 -166
- package/src/routes/data-update.ts +0 -84
- package/src/routes/data.ts +0 -79
- package/src/routes/docs.ts +0 -249
- package/src/routes/meta-info.ts +0 -80
- package/src/routes/meta-logs.ts +0 -57
- package/src/routes/meta-ping.ts +0 -15
- package/src/routes/meta-stats.ts +0 -31
- package/src/routes/meta.ts +0 -22
- package/src/routes/oauth2-init.ts +0 -44
- package/src/routes/oauth2-refresh.ts +0 -39
- package/src/routes/oauth2-signin.ts +0 -286
- package/src/routes/webmanager.ts +0 -29
- package/src/rules.ts +0 -189
- package/src/schema/user.ts +0 -99
- package/src/server.ts +0 -419
- package/src/settings/email.ts +0 -18
- package/src/settings/index.ts +0 -241
- package/src/shared/clients.ts +0 -31
- package/src/shared/email.ts +0 -33
- package/src/shared/env.ts +0 -38
- package/src/shared/error.ts +0 -37
- package/src/shared/http.ts +0 -26
- package/src/shared/password.ts +0 -41
- package/src/shared/rootpath.ts +0 -17
- package/src/shared/signin.ts +0 -149
- package/src/shared/simple-fetch.ts +0 -65
- package/src/shared/tokens.ts +0 -77
- package/src/shared/validate.ts +0 -53
- package/src/start.ts +0 -48
- package/src/test.ts +0 -10
- package/src/websocket/index.ts +0 -336
- package/src/websocket/manager.ts +0 -46
- package/src/websocket/socket.io.ts +0 -90
- package/tsconfig-cjs.json +0 -11
- package/tsconfig.json +0 -22
|
@@ -94,7 +94,7 @@ const signIn = (credentials, env, req) => __awaiter(void 0, void 0, void 0, func
|
|
|
94
94
|
}
|
|
95
95
|
if (credentials.method === 'account' || credentials.method === 'email') {
|
|
96
96
|
// Check password
|
|
97
|
-
|
|
97
|
+
const hash = user.password_salt ? (0, password_1.getPasswordHash)(credentials.password, user.password_salt) : (0, password_1.getOldPasswordHash)(credentials.password);
|
|
98
98
|
if (user.password !== hash) {
|
|
99
99
|
throw new SignInError('wrong_password', 'Incorrect password');
|
|
100
100
|
}
|
|
@@ -105,12 +105,12 @@ const signIn = (credentials, env, req) => __awaiter(void 0, void 0, void 0, func
|
|
|
105
105
|
prev_signin: user.last_signin,
|
|
106
106
|
prev_signin_ip: user.last_signin_ip,
|
|
107
107
|
last_signin: new Date(),
|
|
108
|
-
last_signin_ip: req.ip
|
|
108
|
+
last_signin_ip: req.ip,
|
|
109
109
|
};
|
|
110
110
|
if ('password' in credentials) {
|
|
111
111
|
if (!user.password_salt) {
|
|
112
112
|
// OLD md5 password hash, convert to new salted hash
|
|
113
|
-
|
|
113
|
+
const pwd = (0, password_1.createPasswordHash)(credentials.password);
|
|
114
114
|
updates.password = pwd.hash;
|
|
115
115
|
updates.password_salt = pwd.salt;
|
|
116
116
|
}
|
|
@@ -21,9 +21,9 @@ function fetch(url, options) {
|
|
|
21
21
|
const method = (options === null || options === void 0 ? void 0 : options.method) || 'GET';
|
|
22
22
|
const headers = options === null || options === void 0 ? void 0 : options.headers;
|
|
23
23
|
const req = (0, https_1.request)(url, { method, headers }, res => {
|
|
24
|
-
// res.setEncoding('binary'); // will result in strings!!!!
|
|
24
|
+
// res.setEncoding('binary'); // will result in strings!!!!
|
|
25
25
|
const ready = new Promise((resolve, reject) => {
|
|
26
|
-
|
|
26
|
+
const chunks = [];
|
|
27
27
|
res.on('data', data => {
|
|
28
28
|
chunks.push(data);
|
|
29
29
|
});
|
|
@@ -40,12 +40,12 @@ function fetch(url, options) {
|
|
|
40
40
|
get headers() {
|
|
41
41
|
return {
|
|
42
42
|
get(name) {
|
|
43
|
-
|
|
43
|
+
const val = res.headers[name.toLowerCase()];
|
|
44
44
|
if (val instanceof Array) {
|
|
45
45
|
return val.join(', ');
|
|
46
46
|
}
|
|
47
47
|
return val;
|
|
48
|
-
}
|
|
48
|
+
},
|
|
49
49
|
};
|
|
50
50
|
},
|
|
51
51
|
text() {
|
|
@@ -64,7 +64,7 @@ function fetch(url, options) {
|
|
|
64
64
|
const arrayBuffer = data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
|
|
65
65
|
return arrayBuffer;
|
|
66
66
|
});
|
|
67
|
-
}
|
|
67
|
+
},
|
|
68
68
|
};
|
|
69
69
|
resolve(response);
|
|
70
70
|
});
|
|
@@ -3,11 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.parseSignedPublicToken = exports.createSignedPublicToken = exports.decodePublicAccessToken = exports.createPublicAccessToken = void 0;
|
|
4
4
|
const crypto = require("crypto");
|
|
5
5
|
const createPublicAccessToken = (uid, ip, dbToken, password) => {
|
|
6
|
-
|
|
6
|
+
const obj = {
|
|
7
7
|
t: dbToken,
|
|
8
8
|
c: Date.now(),
|
|
9
9
|
u: uid,
|
|
10
|
-
i: ip
|
|
10
|
+
i: ip,
|
|
11
11
|
};
|
|
12
12
|
// let str = JSON.stringify(obj);
|
|
13
13
|
// str = Buffer.from(str).toString('base64');
|
|
@@ -23,7 +23,7 @@ const decodePublicAccessToken = (accessToken, password) => {
|
|
|
23
23
|
access_token: obj.t,
|
|
24
24
|
uid: obj.u,
|
|
25
25
|
created: obj.c,
|
|
26
|
-
ip: obj.i
|
|
26
|
+
ip: obj.i,
|
|
27
27
|
};
|
|
28
28
|
if (!details.access_token || !details.uid || !details.created || !details.ip) {
|
|
29
29
|
throw new Error('Invalid token');
|
package/dist/cjs/start.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const server_1 = require("./server");
|
|
4
4
|
// If one executes "node start.js [dbname=name] [host=ip] [port=nr]"
|
|
5
5
|
function getVariable(name, defaultValue) {
|
|
6
|
-
// Checks if an argument with the name was passed,
|
|
6
|
+
// Checks if an argument with the name was passed,
|
|
7
7
|
// or if an environment variable was set with that name,
|
|
8
8
|
// else it will return the default value
|
|
9
9
|
name = name.toUpperCase();
|
|
@@ -16,13 +16,13 @@ function getVariable(name, defaultValue) {
|
|
|
16
16
|
}
|
|
17
17
|
return defaultValue;
|
|
18
18
|
}
|
|
19
|
-
;
|
|
20
19
|
const path = getVariable('DBPATH', '.');
|
|
21
20
|
const dbname = getVariable('DBNAME', 'default');
|
|
22
21
|
const host = getVariable('HOST', 'localhost'); // '0.0.0.0'
|
|
23
22
|
const port = +getVariable('PORT', 3000);
|
|
24
23
|
const ipcPort = +getVariable('IPC_PORT', 0);
|
|
25
|
-
const
|
|
24
|
+
const rootPath = getVariable('ROOT_PATH', '');
|
|
25
|
+
const options = { host, port, path, rootPath };
|
|
26
26
|
if (ipcPort > 0) {
|
|
27
27
|
const role = getVariable('IPC_ROLE');
|
|
28
28
|
if (!['master', 'worker'].includes(role)) {
|
|
@@ -33,20 +33,20 @@ if (ipcPort > 0) {
|
|
|
33
33
|
port: ipcPort,
|
|
34
34
|
ssl: +getVariable('IPC_SSL', 0) === 1,
|
|
35
35
|
token: getVariable('IPC_TOKEN'),
|
|
36
|
-
role
|
|
36
|
+
role,
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
39
|
if (+getVariable('TXLOG', 0) === 1) {
|
|
40
40
|
options.transactions = {
|
|
41
41
|
log: true,
|
|
42
|
-
maxAge: +getVariable('TXDAYS', 30)
|
|
42
|
+
maxAge: +getVariable('TXDAYS', 30),
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
45
|
if (+getVariable('AUTH', 1) === 0) {
|
|
46
46
|
options.authentication = { enabled: false };
|
|
47
47
|
}
|
|
48
48
|
const server = new server_1.AceBaseServer(dbname, options);
|
|
49
|
-
server.once(
|
|
49
|
+
server.once('ready', () => {
|
|
50
50
|
var _a;
|
|
51
51
|
server.debug.log(`AceBase server running`);
|
|
52
52
|
(_a = process.send) === null || _a === void 0 ? void 0 : _a.call(process, 'ready'); // When using pm2, you can use --wait-ready flag (see https://pm2.keymetrics.io/docs/usage/signals-clean-restart/)
|
|
@@ -54,14 +54,14 @@ const addWebsocketServer = (env) => {
|
|
|
54
54
|
// subscr.callback
|
|
55
55
|
// })
|
|
56
56
|
// });
|
|
57
|
-
|
|
57
|
+
const remove = [];
|
|
58
58
|
subscribedPaths.forEach(path => {
|
|
59
59
|
remove.push(...client.subscriptions[path]);
|
|
60
60
|
});
|
|
61
61
|
remove.forEach(subscr => {
|
|
62
62
|
// Unsubscribe them at db level and remove from our list
|
|
63
63
|
env.db.api.unsubscribe(subscr.path, subscr.event, subscr.callback); //db.ref(subscr.path).off(subscr.event, subscr.callback);
|
|
64
|
-
|
|
64
|
+
const pathSubs = client.subscriptions[subscr.path];
|
|
65
65
|
pathSubs.splice(pathSubs.indexOf(subscr), 1);
|
|
66
66
|
});
|
|
67
67
|
}
|
|
@@ -69,7 +69,7 @@ const addWebsocketServer = (env) => {
|
|
|
69
69
|
env.debug.verbose(`Socket disconnected, total: ${env.clients.size}`);
|
|
70
70
|
});
|
|
71
71
|
serverManager.on('signin', event => {
|
|
72
|
-
// client sends this request once user has been signed in, binds the user to the socket,
|
|
72
|
+
// client sends this request once user has been signed in, binds the user to the socket,
|
|
73
73
|
// deprecated since client v0.9.4, which sends client_id with signin api call
|
|
74
74
|
// const client = clients.get(socket.id);
|
|
75
75
|
const client = getClientBySocketId(event.socket_id, 'signin');
|
|
@@ -117,7 +117,7 @@ const addWebsocketServer = (env) => {
|
|
|
117
117
|
// Send acknowledgement
|
|
118
118
|
serverManager.send(socket, 'result', {
|
|
119
119
|
success: true,
|
|
120
|
-
req_id: requestId
|
|
120
|
+
req_id: requestId,
|
|
121
121
|
});
|
|
122
122
|
};
|
|
123
123
|
const failRequest = (socket, requestId, code) => {
|
|
@@ -125,7 +125,7 @@ const addWebsocketServer = (env) => {
|
|
|
125
125
|
serverManager.send(socket, 'result', {
|
|
126
126
|
success: false,
|
|
127
127
|
reason: code,
|
|
128
|
-
req_id: requestId
|
|
128
|
+
req_id: requestId,
|
|
129
129
|
});
|
|
130
130
|
};
|
|
131
131
|
serverManager.on('subscribe', event => {
|
|
@@ -164,9 +164,9 @@ const addWebsocketServer = (env) => {
|
|
|
164
164
|
if (err) {
|
|
165
165
|
return;
|
|
166
166
|
}
|
|
167
|
-
|
|
167
|
+
const val = acebase_core_1.Transport.serialize({
|
|
168
168
|
current: currentValue,
|
|
169
|
-
previous: previousValue
|
|
169
|
+
previous: previousValue,
|
|
170
170
|
});
|
|
171
171
|
env.debug.verbose(`Sending data event "${event.data.event}" for path "/${path}" to client ${event.socket_id}`.colorize([acebase_core_1.ColorStyle.bgWhite, acebase_core_1.ColorStyle.black]));
|
|
172
172
|
// TODO: let large data events notify the client, then let them download the data manually so it doesn't have to be transmitted through the websocket
|
|
@@ -175,14 +175,14 @@ const addWebsocketServer = (env) => {
|
|
|
175
175
|
path,
|
|
176
176
|
event: event.data.event,
|
|
177
177
|
val,
|
|
178
|
-
context
|
|
178
|
+
context,
|
|
179
179
|
});
|
|
180
180
|
};
|
|
181
181
|
let pathSubs = client.subscriptions[subscriptionPath];
|
|
182
182
|
if (!pathSubs) {
|
|
183
183
|
pathSubs = client.subscriptions[subscriptionPath] = [];
|
|
184
184
|
}
|
|
185
|
-
|
|
185
|
+
const subscr = { path: subscriptionPath, event: event.data.event, callback };
|
|
186
186
|
pathSubs.push(subscr);
|
|
187
187
|
env.db.api.subscribe(subscriptionPath, event.data.event, callback);
|
|
188
188
|
acknowledgeRequest(event.socket, event.data.req_id);
|
|
@@ -195,7 +195,7 @@ const addWebsocketServer = (env) => {
|
|
|
195
195
|
}
|
|
196
196
|
env.debug.verbose(`Client ${event.socket_id} is unsubscribing from event "${event.data.event || '(any)'}" on path "/${event.data.path}"`.colorize([acebase_core_1.ColorStyle.bgWhite, acebase_core_1.ColorStyle.black]));
|
|
197
197
|
// const client = clients.get(socket.id);
|
|
198
|
-
|
|
198
|
+
const pathSubs = client.subscriptions[event.data.path];
|
|
199
199
|
if (!pathSubs) {
|
|
200
200
|
// We have no knowledge of any active subscriptions on this path
|
|
201
201
|
return acknowledgeRequest(event.socket, event.data.req_id);
|
|
@@ -251,7 +251,7 @@ const addWebsocketServer = (env) => {
|
|
|
251
251
|
tx.finish(); // Finish without value cancels the transaction
|
|
252
252
|
env.log.error(LOG_ACTION, 'timeout', LOG_DETAILS);
|
|
253
253
|
serverManager.send(event.socket, 'tx_error', { id: tx.id, reason: 'timeout' });
|
|
254
|
-
}, TRANSACTION_TIMEOUT_MS)
|
|
254
|
+
}, TRANSACTION_TIMEOUT_MS),
|
|
255
255
|
};
|
|
256
256
|
const access = env.rules.userHasAccess(client.user, data.path, true);
|
|
257
257
|
if (!access.allow) {
|
|
@@ -37,10 +37,11 @@ const createServer = (env) => {
|
|
|
37
37
|
pingInterval: 5000,
|
|
38
38
|
pingTimeout: 5000,
|
|
39
39
|
maxHttpBufferSize: maxPayloadBytes,
|
|
40
|
+
path: `/${env.rootPath ? `${env.rootPath}/` : ''}socket.io`,
|
|
40
41
|
// Allow socket.io 2.x clients (using engine.io 3.x):
|
|
41
42
|
allowEIO3: true,
|
|
42
43
|
// socket.io 3+ uses cors package:
|
|
43
|
-
cors: (0, cors_1.getCorsOptions)(env.config.allowOrigin)
|
|
44
|
+
cors: (0, cors_1.getCorsOptions)(env.config.allowOrigin),
|
|
44
45
|
});
|
|
45
46
|
// Setup event emitter for communication with consuming server
|
|
46
47
|
const manager = new SocketIOManager();
|
package/dist/esm/auth.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ColorStyle, SimpleCache } from
|
|
2
|
-
import { randomBytes } from
|
|
3
|
-
import { createPasswordHash, generatePassword, getOldPasswordHash, getPasswordHash } from
|
|
1
|
+
import { ColorStyle, SimpleCache } from 'acebase-core';
|
|
2
|
+
import { randomBytes } from 'crypto';
|
|
3
|
+
import { createPasswordHash, generatePassword, getOldPasswordHash, getPasswordHash } from './shared/password.js';
|
|
4
4
|
export const setupAuthentication = async (env) => {
|
|
5
5
|
// Setup auth cache
|
|
6
6
|
env.authCache = new SimpleCache({ expirySeconds: 300, cloneValues: false, maxEntries: 1000 });
|
|
@@ -8,7 +8,7 @@ export const setupAuthentication = async (env) => {
|
|
|
8
8
|
await env.securityRef.child('token_salt').transaction(snap => {
|
|
9
9
|
env.tokenSalt = snap.val();
|
|
10
10
|
if (!env.tokenSalt) {
|
|
11
|
-
|
|
11
|
+
const length = 256;
|
|
12
12
|
env.tokenSalt = randomBytes(Math.ceil(length / 2)).toString('hex').slice(0, length);
|
|
13
13
|
return env.tokenSalt;
|
|
14
14
|
}
|
|
@@ -30,7 +30,7 @@ export const setupAuthentication = async (env) => {
|
|
|
30
30
|
change_password: true,
|
|
31
31
|
created: new Date(),
|
|
32
32
|
access_token: null,
|
|
33
|
-
settings: {}
|
|
33
|
+
settings: {},
|
|
34
34
|
};
|
|
35
35
|
env.debug.warn(`__________________________________________________________________`.colorize(ColorStyle.red));
|
|
36
36
|
env.debug.warn(``.colorize(ColorStyle.red));
|
package/dist/esm/cluster.js
CHANGED
|
@@ -10,8 +10,8 @@ const numCPUs = 2; //os.cpus().length;
|
|
|
10
10
|
* To do that, see https://github.com/appy-one/acebase-ipc-server
|
|
11
11
|
*
|
|
12
12
|
*/
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
const dbname = 'default';
|
|
14
|
+
const options = { /* default options */}; // Load from cluster.config.js!
|
|
15
15
|
options.authentication = { enabled: false };
|
|
16
16
|
options.https = { enabled: false };
|
|
17
17
|
if (cluster.isMaster) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { sendUnauthorizedError } from
|
|
1
|
+
import { sendUnauthorizedError } from '../shared/error.js';
|
|
2
2
|
/**
|
|
3
3
|
* Middleware function that checks if the current user is `admin`. An 403 Forbidden error will be sent in the response if
|
|
4
4
|
* authentication is enabled on the server and the user is not signed in as admin.
|
|
@@ -7,7 +7,7 @@ export const getCorsOptions = (allowedOrigins) => {
|
|
|
7
7
|
return {
|
|
8
8
|
origin: allowedOrigins === '*' ? true : allowedOrigins === '' ? false : allowedOrigins.split(/,\s*/),
|
|
9
9
|
methods: 'GET,PUT,POST,DELETE,OPTIONS',
|
|
10
|
-
allowedHeaders: 'Content-Type, Authorization, Content-Length, Accept, Origin, X-Requested-With, AceBase-Context'
|
|
10
|
+
allowedHeaders: 'Content-Type, Authorization, Content-Length, Accept, Origin, X-Requested-With, AceBase-Context',
|
|
11
11
|
};
|
|
12
12
|
};
|
|
13
13
|
/**
|
|
@@ -25,13 +25,13 @@ export const getCorsHeaders = (allowedOrigins, currentOrigin) => {
|
|
|
25
25
|
'Access-Control-Allow-Origin': origins,
|
|
26
26
|
'Access-Control-Allow-Methods': corsOptions.methods,
|
|
27
27
|
'Access-Control-Allow-Headers': corsOptions.allowedHeaders,
|
|
28
|
-
'Access-Control-Expose-Headers': 'Date, AceBase-Context' // Prevent browsers from stripping these headers from the response for programmatic access in cross-origin requests
|
|
28
|
+
'Access-Control-Expose-Headers': 'Date, AceBase-Context', // Prevent browsers from stripping these headers from the response for programmatic access in cross-origin requests
|
|
29
29
|
};
|
|
30
30
|
};
|
|
31
31
|
export const addMiddleware = (env) => {
|
|
32
32
|
env.app.use((req, res, next) => {
|
|
33
33
|
const headers = getCorsHeaders(env.config.allowOrigin, req.headers.origin);
|
|
34
|
-
for (
|
|
34
|
+
for (const name in headers) {
|
|
35
35
|
res.setHeader(name, headers[name]);
|
|
36
36
|
}
|
|
37
37
|
if (req.method === 'OPTIONS') {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { sendNotAuthenticatedError } from
|
|
2
|
-
import { signIn } from
|
|
3
|
-
import { decodePublicAccessToken } from
|
|
1
|
+
import { sendNotAuthenticatedError } from '../shared/error.js';
|
|
2
|
+
import { signIn } from '../shared/signin.js';
|
|
3
|
+
import { decodePublicAccessToken } from '../shared/tokens.js';
|
|
4
4
|
export const addMiddleware = (env) => {
|
|
5
5
|
// Add bearer authentication middleware
|
|
6
6
|
env.app.use(async (req, res, next) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { OAuth2Provider } from
|
|
1
|
+
import { OAuth2Provider } from './oauth-provider.js';
|
|
2
2
|
import { fetch } from '../shared/simple-fetch.js';
|
|
3
3
|
export class DropboxAuthProvider extends OAuth2Provider {
|
|
4
4
|
constructor(settings) {
|
|
@@ -27,68 +27,64 @@ export class DropboxAuthProvider extends OAuth2Provider {
|
|
|
27
27
|
const authUrl = `https://www.dropbox.com/oauth2/authorize?response_type=code&token_access_type=offline&client_id=${this.settings.client_id}&scope=${encodeURIComponent(this.settings.scopes.join(' '))}&redirect_uri=${encodeURIComponent(info.redirect_url)}&locale=${options.locale || ''}&require_role=${options.require_role || ''}&force_reauthentication=${options.force_reauthentication === true}&force_reapprove=${options.force_reapprove === true}&disable_signup=${options.disable_signup === true}&state=${encodeURIComponent(info.state)}`;
|
|
28
28
|
return authUrl;
|
|
29
29
|
}
|
|
30
|
-
getAccessToken(params) {
|
|
30
|
+
async getAccessToken(params) {
|
|
31
31
|
// Request access & refresh tokens with authorization code
|
|
32
|
-
|
|
32
|
+
const response = await fetch('https://api.dropbox.com/oauth2/token', {
|
|
33
33
|
method: 'POST',
|
|
34
34
|
headers: {
|
|
35
|
-
|
|
35
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
36
36
|
},
|
|
37
37
|
body: `client_id=${this.settings.client_id}&client_secret=${this.settings.client_secret}` +
|
|
38
38
|
(params.type === 'refresh'
|
|
39
39
|
? `&grant_type=refresh_token&refresh_token=${params.refresh_token}`
|
|
40
|
-
: `&grant_type=authorization_code&code=${params.auth_code}&redirect_uri=${encodeURIComponent(params.redirect_url)}`)
|
|
41
|
-
})
|
|
42
|
-
.then(async (response) => {
|
|
43
|
-
if (response.status !== 200) {
|
|
44
|
-
// Handle error
|
|
45
|
-
const code = response.status;
|
|
46
|
-
const hasJSON = response.headers.get('Content-Type') === 'application/json';
|
|
47
|
-
const details = await (hasJSON ? response.json() : response.text());
|
|
48
|
-
throw new Error(`${code}: ${hasJSON ? details.error_description ? `${details.error}, ${details.error_description}` : details.error_summary : details}`);
|
|
49
|
-
}
|
|
50
|
-
const result = await response.json();
|
|
51
|
-
const secondsToExpiry = result.expires_in;
|
|
52
|
-
result.expires = new Date(Date.now() + (secondsToExpiry * 1000));
|
|
53
|
-
return result;
|
|
40
|
+
: `&grant_type=authorization_code&code=${params.auth_code}&redirect_uri=${encodeURIComponent(params.redirect_url)}`),
|
|
54
41
|
});
|
|
42
|
+
if (response.status !== 200) {
|
|
43
|
+
// Handle error
|
|
44
|
+
const code = response.status;
|
|
45
|
+
const hasJSON = response.headers.get('Content-Type') === 'application/json';
|
|
46
|
+
const details = await (hasJSON ? response.json() : response.text());
|
|
47
|
+
throw new Error(`${code}: ${hasJSON ? details.error_description ? `${details.error}, ${details.error_description}` : details.error_summary : details}`);
|
|
48
|
+
}
|
|
49
|
+
const result = await response.json();
|
|
50
|
+
const secondsToExpiry = result.expires_in;
|
|
51
|
+
result.expires = new Date(Date.now() + (secondsToExpiry * 1000));
|
|
52
|
+
return result;
|
|
55
53
|
}
|
|
56
|
-
getUserInfo(access_token) {
|
|
57
|
-
|
|
54
|
+
async getUserInfo(access_token) {
|
|
55
|
+
const response = await fetch(`https://api.dropboxapi.com/2/users/get_current_account`, {
|
|
58
56
|
method: 'POST',
|
|
59
57
|
headers: {
|
|
60
|
-
'Authorization': `Bearer ${access_token}
|
|
61
|
-
}
|
|
62
|
-
})
|
|
63
|
-
.then(async (response) => {
|
|
64
|
-
if (response.status !== 200) {
|
|
65
|
-
const code = response.status;
|
|
66
|
-
const hasJSON = response.headers.get('Content-Type') === 'application/json';
|
|
67
|
-
const details = await (hasJSON ? response.json() : response.text());
|
|
68
|
-
throw new Error(`${code}: ${hasJSON ? details.error_summary : details}`);
|
|
69
|
-
}
|
|
70
|
-
const result = await response.json();
|
|
71
|
-
const user = result;
|
|
72
|
-
return {
|
|
73
|
-
id: user.account_id,
|
|
74
|
-
name: `${user.name.given_name} ${user.name.surname}`,
|
|
75
|
-
display_name: user.name.display_name,
|
|
76
|
-
picture: user.profile_photo_url ? [{ url: user.profile_photo_url }] : null,
|
|
77
|
-
email: user.email,
|
|
78
|
-
email_verified: user.email_verified,
|
|
79
|
-
other: {
|
|
80
|
-
account_type: user.account_type['.tag'],
|
|
81
|
-
disabled: user.disabled,
|
|
82
|
-
locale: user.locale,
|
|
83
|
-
country: user.country,
|
|
84
|
-
// include the following?
|
|
85
|
-
// referral_link: user.referral_link,
|
|
86
|
-
// team_id: user.team.id,
|
|
87
|
-
// team_name: user.team.name,
|
|
88
|
-
// team_member_id: user.team_member_id
|
|
89
|
-
}
|
|
90
|
-
};
|
|
58
|
+
'Authorization': `Bearer ${access_token}`,
|
|
59
|
+
},
|
|
91
60
|
});
|
|
61
|
+
if (response.status !== 200) {
|
|
62
|
+
const code = response.status;
|
|
63
|
+
const hasJSON = response.headers.get('Content-Type') === 'application/json';
|
|
64
|
+
const details = await (hasJSON ? response.json() : response.text());
|
|
65
|
+
throw new Error(`${code}: ${hasJSON ? details.error_summary : details}`);
|
|
66
|
+
}
|
|
67
|
+
const result = await response.json();
|
|
68
|
+
const user = result;
|
|
69
|
+
return {
|
|
70
|
+
id: user.account_id,
|
|
71
|
+
name: `${user.name.given_name} ${user.name.surname}`,
|
|
72
|
+
display_name: user.name.display_name,
|
|
73
|
+
picture: user.profile_photo_url ? [{ url: user.profile_photo_url }] : null,
|
|
74
|
+
email: user.email,
|
|
75
|
+
email_verified: user.email_verified,
|
|
76
|
+
other: {
|
|
77
|
+
account_type: user.account_type['.tag'],
|
|
78
|
+
disabled: user.disabled,
|
|
79
|
+
locale: user.locale,
|
|
80
|
+
country: user.country,
|
|
81
|
+
// include the following?
|
|
82
|
+
// referral_link: user.referral_link,
|
|
83
|
+
// team_id: user.team.id,
|
|
84
|
+
// team_name: user.team.name,
|
|
85
|
+
// team_member_id: user.team_member_id
|
|
86
|
+
},
|
|
87
|
+
};
|
|
92
88
|
}
|
|
93
89
|
}
|
|
94
90
|
export const AuthProvider = DropboxAuthProvider;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { OAuth2Provider } from
|
|
1
|
+
import { OAuth2Provider } from './oauth-provider.js';
|
|
2
2
|
import { fetch } from '../shared/simple-fetch.js';
|
|
3
3
|
export class FacebookAuthProvider extends OAuth2Provider {
|
|
4
4
|
constructor(settings) {
|
|
@@ -20,51 +20,47 @@ export class FacebookAuthProvider extends OAuth2Provider {
|
|
|
20
20
|
const authUrl = `https://www.facebook.com/v7.0/dialog/oauth?response_type=code&client_id=${this.settings.client_id}&scope=${encodeURIComponent(this.settings.scopes.join(' '))}&redirect_uri=${encodeURIComponent(info.redirect_url)}&state=${encodeURIComponent(info.state)}`;
|
|
21
21
|
return authUrl;
|
|
22
22
|
}
|
|
23
|
-
getAccessToken(params) {
|
|
23
|
+
async getAccessToken(params) {
|
|
24
24
|
// Request access token with authorization code, or previously granted (short or long-lived) access_token
|
|
25
25
|
const url = `https://graph.facebook.com/v7.0/oauth/access_token?client_id=${this.settings.client_id}&client_secret=${this.settings.client_secret}` +
|
|
26
26
|
(params.type === 'refresh'
|
|
27
27
|
? `&grant_type=fb_exchange_token&fb_exchange_token=${params.refresh_token}`
|
|
28
28
|
: `&code=${params.auth_code}&redirect_uri=${encodeURIComponent(params.redirect_url)}`);
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return result;
|
|
43
|
-
});
|
|
29
|
+
const response = await fetch(url);
|
|
30
|
+
const result = await response.json();
|
|
31
|
+
if (result.error) {
|
|
32
|
+
const error = result.error;
|
|
33
|
+
throw new Error(`${error.type} ${error.code}: ${error.message}`);
|
|
34
|
+
}
|
|
35
|
+
const secondsToExpiry = result.expires_in;
|
|
36
|
+
result.expires = new Date(Date.now() + (secondsToExpiry * 1000));
|
|
37
|
+
// A short-lived access token can be exchanged for a long-lived (60 day) token.
|
|
38
|
+
// Not sure if a long-lived token can be used to get a new long-lived token,
|
|
39
|
+
// needs testing. See docs at: https://developers.facebook.com/docs/facebook-login/access-tokens/refreshing/
|
|
40
|
+
result.refresh_token = result.access_token;
|
|
41
|
+
return result;
|
|
44
42
|
}
|
|
45
|
-
getUserInfo(access_token) {
|
|
43
|
+
async getUserInfo(access_token) {
|
|
46
44
|
// TODO: Check if any requested scopes have not been granted access
|
|
47
45
|
// await fetch(`https://graph.facebook.com/v7.0/me/permissions`);
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
};
|
|
67
|
-
});
|
|
46
|
+
const response = await fetch(`https://graph.facebook.com/v7.0/me?fields=email,name,short_name,picture&access_token=${access_token}`);
|
|
47
|
+
const result = await response.json();
|
|
48
|
+
if (response.status !== 200) {
|
|
49
|
+
const error = result;
|
|
50
|
+
throw new Error(`${error.code}: ${error.message}`);
|
|
51
|
+
}
|
|
52
|
+
const user = result;
|
|
53
|
+
return {
|
|
54
|
+
id: user.id,
|
|
55
|
+
name: user.name,
|
|
56
|
+
display_name: user.short_name,
|
|
57
|
+
picture: user.picture.data.is_silhouette ? null : [{ width: user.picture.data.width, height: user.picture.data.height, url: user.picture.data.url }],
|
|
58
|
+
email: user.email,
|
|
59
|
+
email_verified: typeof user.email === 'string',
|
|
60
|
+
other: {
|
|
61
|
+
// We haven't requested more, so we didn't get more
|
|
62
|
+
},
|
|
63
|
+
};
|
|
68
64
|
}
|
|
69
65
|
}
|
|
70
66
|
export const AuthProvider = FacebookAuthProvider;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { OAuth2Provider } from
|
|
1
|
+
import { OAuth2Provider } from './oauth-provider.js';
|
|
2
2
|
import { fetch } from '../shared/simple-fetch.js';
|
|
3
3
|
export class GoogleAuthProvider extends OAuth2Provider {
|
|
4
4
|
constructor(settings) {
|
|
@@ -43,60 +43,54 @@ export class GoogleAuthProvider extends OAuth2Provider {
|
|
|
43
43
|
// Request access & refresh tokens with authorization code, or refresh token
|
|
44
44
|
const config = await this.getOpenIDConfig();
|
|
45
45
|
// 'https://oauth2.googleapis.com/token'
|
|
46
|
-
|
|
46
|
+
const response = await fetch(config.token_endpoint, {
|
|
47
47
|
method: 'POST',
|
|
48
48
|
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
49
49
|
body: `client_id=${this.settings.client_id}&client_secret=${this.settings.client_secret}&code=`
|
|
50
50
|
+ (params.type === 'refresh'
|
|
51
51
|
? `${params.refresh_token}&grant_type=refresh_token`
|
|
52
|
-
: `${params.auth_code}&grant_type=authorization_code&redirect_uri=${encodeURIComponent(params.redirect_url)}`)
|
|
53
|
-
})
|
|
54
|
-
.then(response => response.json())
|
|
55
|
-
.then((result) => {
|
|
56
|
-
if (result.error) {
|
|
57
|
-
throw new Error(result.error);
|
|
58
|
-
}
|
|
59
|
-
const secondsToExpiry = result.expires_in;
|
|
60
|
-
result.expires = new Date(Date.now() + (secondsToExpiry * 1000));
|
|
61
|
-
return result;
|
|
52
|
+
: `${params.auth_code}&grant_type=authorization_code&redirect_uri=${encodeURIComponent(params.redirect_url)}`),
|
|
62
53
|
});
|
|
54
|
+
const result = await response.json();
|
|
55
|
+
if (result.error) {
|
|
56
|
+
throw new Error(result.error);
|
|
57
|
+
}
|
|
58
|
+
const secondsToExpiry = result.expires_in;
|
|
59
|
+
result.expires = new Date(Date.now() + (secondsToExpiry * 1000));
|
|
60
|
+
return result;
|
|
63
61
|
}
|
|
64
62
|
async revokeAccess(access_token) {
|
|
65
63
|
const config = await this.getOpenIDConfig();
|
|
66
64
|
// https://oauth2.googleapis.com/revoke
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
});
|
|
65
|
+
const response = await fetch(`${config.revocation_endpoint}?token=${access_token}`);
|
|
66
|
+
if (response.status !== 200) {
|
|
67
|
+
throw new Error(`Revoke failed, error ${response.status}`);
|
|
68
|
+
}
|
|
73
69
|
}
|
|
74
70
|
async getUserInfo(access_token) {
|
|
75
71
|
const config = await this.getOpenIDConfig();
|
|
76
72
|
// https://openidconnect.googleapis.com/v1/userinfo
|
|
77
|
-
|
|
73
|
+
const response = await fetch(config.userinfo_endpoint, {
|
|
78
74
|
method: 'GET',
|
|
79
|
-
headers: { 'Authorization': `Bearer ${access_token}` }
|
|
80
|
-
})
|
|
81
|
-
.then(async (response) => {
|
|
82
|
-
const result = await response.json();
|
|
83
|
-
if (response.status !== 200) {
|
|
84
|
-
const error = result;
|
|
85
|
-
throw new Error(`${error.error}: ${error.error_description}`);
|
|
86
|
-
}
|
|
87
|
-
const user = result;
|
|
88
|
-
return {
|
|
89
|
-
id: user.sub,
|
|
90
|
-
name: user.name,
|
|
91
|
-
display_name: user.nickname || user.given_name,
|
|
92
|
-
picture: user.picture ? [{ url: user.picture }] : [],
|
|
93
|
-
email: user.email,
|
|
94
|
-
email_verified: user.email_verified,
|
|
95
|
-
other: Object.keys(user)
|
|
96
|
-
.filter(key => !['sub', 'name', 'picture', 'email', 'email_verified'].includes(key))
|
|
97
|
-
.reduce((obj, key) => { obj[key] = user[key]; return obj; }, {})
|
|
98
|
-
};
|
|
75
|
+
headers: { 'Authorization': `Bearer ${access_token}` },
|
|
99
76
|
});
|
|
77
|
+
const result = await response.json();
|
|
78
|
+
if (response.status !== 200) {
|
|
79
|
+
const error = result;
|
|
80
|
+
throw new Error(`${error.error}: ${error.error_description}`);
|
|
81
|
+
}
|
|
82
|
+
const user = result;
|
|
83
|
+
return {
|
|
84
|
+
id: user.sub,
|
|
85
|
+
name: user.name,
|
|
86
|
+
display_name: user.nickname || user.given_name,
|
|
87
|
+
picture: user.picture ? [{ url: user.picture }] : [],
|
|
88
|
+
email: user.email,
|
|
89
|
+
email_verified: user.email_verified,
|
|
90
|
+
other: Object.keys(user)
|
|
91
|
+
.filter(key => !['sub', 'name', 'picture', 'email', 'email_verified'].includes(key))
|
|
92
|
+
.reduce((obj, key) => { obj[key] = user[key]; return obj; }, {}),
|
|
93
|
+
};
|
|
100
94
|
}
|
|
101
95
|
}
|
|
102
96
|
export const AuthProvider = GoogleAuthProvider;
|
|
@@ -13,7 +13,7 @@ const oAuth2Providers = {
|
|
|
13
13
|
facebook: FacebookAuthProvider,
|
|
14
14
|
google: GoogleAuthProvider,
|
|
15
15
|
instagram: InstagramAuthProvider,
|
|
16
|
-
spotify: SpotifyAuthProvider
|
|
16
|
+
spotify: SpotifyAuthProvider,
|
|
17
17
|
};
|
|
18
18
|
export default oAuth2Providers;
|
|
19
19
|
//# sourceMappingURL=index.js.map
|