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
package/.eslintrc.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"env": {
|
|
3
|
+
"browser": true,
|
|
4
|
+
"es2021": true,
|
|
5
|
+
"node": true
|
|
6
|
+
},
|
|
7
|
+
"extends": [
|
|
8
|
+
"plugin:@typescript-eslint/recommended"
|
|
9
|
+
],
|
|
10
|
+
"parser": "@typescript-eslint/parser",
|
|
11
|
+
"parserOptions": {
|
|
12
|
+
"ecmaVersion": "latest",
|
|
13
|
+
"sourceType": "module"
|
|
14
|
+
},
|
|
15
|
+
"plugins": [
|
|
16
|
+
"@typescript-eslint"
|
|
17
|
+
],
|
|
18
|
+
"rules": {
|
|
19
|
+
"indent": [ "error", 4, { "SwitchCase": 1, "VariableDeclarator": 1, "MemberExpression": 1, "CallExpression": { "arguments": 1 } }],
|
|
20
|
+
"quotes": ["error", "single", { "avoidEscape": false, "allowTemplateLiterals": true }],
|
|
21
|
+
"semi": ["error", "always"],
|
|
22
|
+
"@typescript-eslint/no-explicit-any": [
|
|
23
|
+
"off", // "error" if we want to enforce usage of `unknown` instead
|
|
24
|
+
{
|
|
25
|
+
"ignoreRestArgs": false,
|
|
26
|
+
"fixToUnknown": true
|
|
27
|
+
}
|
|
28
|
+
],
|
|
29
|
+
"comma-dangle": "off",
|
|
30
|
+
"@typescript-eslint/comma-dangle": ["error", {
|
|
31
|
+
"arrays": "always-multiline",
|
|
32
|
+
"objects": "always-multiline",
|
|
33
|
+
"imports": "always-multiline",
|
|
34
|
+
"exports": "always-multiline",
|
|
35
|
+
"enums": "always-multiline",
|
|
36
|
+
"functions": "only-multiline"
|
|
37
|
+
}],
|
|
38
|
+
"no-trailing-spaces": "error",
|
|
39
|
+
"eol-last": "error",
|
|
40
|
+
"curly": "error"
|
|
41
|
+
},
|
|
42
|
+
"overrides": [{
|
|
43
|
+
"files": "*.js",
|
|
44
|
+
"rules": {
|
|
45
|
+
"@typescript-eslint/no-var-requires": "off"
|
|
46
|
+
}
|
|
47
|
+
}],
|
|
48
|
+
"ignorePatterns": ["dist/**/*.*", "webmanager/*.min.js"]
|
|
49
|
+
}
|
package/README.md
CHANGED
|
@@ -2,10 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
This repository is to setup an http endpoint for a local AceBase database instance. See [AceBase](https://www.npmjs.com/package/acebase) for more information about AceBase databases and usage.
|
|
4
4
|
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+

|
|
8
|
+
|
|
5
9
|
## Getting started
|
|
6
10
|
|
|
7
11
|
Install the *acebase-server* npm package: ```npm install acebase-server``` ([github](https://github.com/appy-one/acebase-server), [npm](https://www.npmjs.com/package/acebase-server))
|
|
8
12
|
|
|
13
|
+
To test running an AceBase server with authentication on localhost:3000, execute the following commands
|
|
14
|
+
* `cd ./node_modules/acebase-server`
|
|
15
|
+
* `npm run test`
|
|
16
|
+
* Open [http://localhost:3000](http://localhost:3000) in your browser. To sign into the webmanager, use db name `default`, username `admin` and the generated password displayed in your console output. The webmanager allows browsing your database content and performing updates.
|
|
17
|
+
* Open [http://localhost:3000/docs](http://localhost:3000/docs) to open the Swagger UI that is enabled in development mode. All REST API methods are documented and can be executed here.
|
|
18
|
+
|
|
9
19
|
## Creating an AceBase server
|
|
10
20
|
|
|
11
21
|
To launch an AceBase webserver using default settings
|
package/dist/cjs/auth.js
CHANGED
|
@@ -20,7 +20,7 @@ const setupAuthentication = (env) => __awaiter(void 0, void 0, void 0, function*
|
|
|
20
20
|
yield env.securityRef.child('token_salt').transaction(snap => {
|
|
21
21
|
env.tokenSalt = snap.val();
|
|
22
22
|
if (!env.tokenSalt) {
|
|
23
|
-
|
|
23
|
+
const length = 256;
|
|
24
24
|
env.tokenSalt = (0, crypto_1.randomBytes)(Math.ceil(length / 2)).toString('hex').slice(0, length);
|
|
25
25
|
return env.tokenSalt;
|
|
26
26
|
}
|
|
@@ -42,7 +42,7 @@ const setupAuthentication = (env) => __awaiter(void 0, void 0, void 0, function*
|
|
|
42
42
|
change_password: true,
|
|
43
43
|
created: new Date(),
|
|
44
44
|
access_token: null,
|
|
45
|
-
settings: {}
|
|
45
|
+
settings: {},
|
|
46
46
|
};
|
|
47
47
|
env.debug.warn(`__________________________________________________________________`.colorize(acebase_core_1.ColorStyle.red));
|
|
48
48
|
env.debug.warn(``.colorize(acebase_core_1.ColorStyle.red));
|
package/dist/cjs/cluster.js
CHANGED
|
@@ -12,8 +12,8 @@ const numCPUs = 2; //os.cpus().length;
|
|
|
12
12
|
* To do that, see https://github.com/appy-one/acebase-ipc-server
|
|
13
13
|
*
|
|
14
14
|
*/
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
const dbname = 'default';
|
|
16
|
+
const options = { /* default options */}; // Load from cluster.config.js!
|
|
17
17
|
options.authentication = { enabled: false };
|
|
18
18
|
options.https = { enabled: false };
|
|
19
19
|
if (cluster.isMaster) {
|
|
@@ -10,7 +10,7 @@ const getCorsOptions = (allowedOrigins) => {
|
|
|
10
10
|
return {
|
|
11
11
|
origin: allowedOrigins === '*' ? true : allowedOrigins === '' ? false : allowedOrigins.split(/,\s*/),
|
|
12
12
|
methods: 'GET,PUT,POST,DELETE,OPTIONS',
|
|
13
|
-
allowedHeaders: 'Content-Type, Authorization, Content-Length, Accept, Origin, X-Requested-With, AceBase-Context'
|
|
13
|
+
allowedHeaders: 'Content-Type, Authorization, Content-Length, Accept, Origin, X-Requested-With, AceBase-Context',
|
|
14
14
|
};
|
|
15
15
|
};
|
|
16
16
|
exports.getCorsOptions = getCorsOptions;
|
|
@@ -29,14 +29,14 @@ const getCorsHeaders = (allowedOrigins, currentOrigin) => {
|
|
|
29
29
|
'Access-Control-Allow-Origin': origins,
|
|
30
30
|
'Access-Control-Allow-Methods': corsOptions.methods,
|
|
31
31
|
'Access-Control-Allow-Headers': corsOptions.allowedHeaders,
|
|
32
|
-
'Access-Control-Expose-Headers': 'Date, AceBase-Context' // Prevent browsers from stripping these headers from the response for programmatic access in cross-origin requests
|
|
32
|
+
'Access-Control-Expose-Headers': 'Date, AceBase-Context', // Prevent browsers from stripping these headers from the response for programmatic access in cross-origin requests
|
|
33
33
|
};
|
|
34
34
|
};
|
|
35
35
|
exports.getCorsHeaders = getCorsHeaders;
|
|
36
36
|
const addMiddleware = (env) => {
|
|
37
37
|
env.app.use((req, res, next) => {
|
|
38
38
|
const headers = (0, exports.getCorsHeaders)(env.config.allowOrigin, req.headers.origin);
|
|
39
|
-
for (
|
|
39
|
+
for (const name in headers) {
|
|
40
40
|
res.setHeader(name, headers[name]);
|
|
41
41
|
}
|
|
42
42
|
if (req.method === 'OPTIONS') {
|
|
@@ -42,18 +42,18 @@ class DropboxAuthProvider extends oauth_provider_1.OAuth2Provider {
|
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
44
|
getAccessToken(params) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
45
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
// Request access & refresh tokens with authorization code
|
|
47
|
+
const response = yield (0, simple_fetch_1.fetch)('https://api.dropbox.com/oauth2/token', {
|
|
48
|
+
method: 'POST',
|
|
49
|
+
headers: {
|
|
50
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
51
|
+
},
|
|
52
|
+
body: `client_id=${this.settings.client_id}&client_secret=${this.settings.client_secret}` +
|
|
53
|
+
(params.type === 'refresh'
|
|
54
|
+
? `&grant_type=refresh_token&refresh_token=${params.refresh_token}`
|
|
55
|
+
: `&grant_type=authorization_code&code=${params.auth_code}&redirect_uri=${encodeURIComponent(params.redirect_url)}`),
|
|
56
|
+
});
|
|
57
57
|
if (response.status !== 200) {
|
|
58
58
|
// Handle error
|
|
59
59
|
const code = response.status;
|
|
@@ -65,16 +65,16 @@ class DropboxAuthProvider extends oauth_provider_1.OAuth2Provider {
|
|
|
65
65
|
const secondsToExpiry = result.expires_in;
|
|
66
66
|
result.expires = new Date(Date.now() + (secondsToExpiry * 1000));
|
|
67
67
|
return result;
|
|
68
|
-
})
|
|
68
|
+
});
|
|
69
69
|
}
|
|
70
70
|
getUserInfo(access_token) {
|
|
71
|
-
return (0,
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
71
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
72
|
+
const response = yield (0, simple_fetch_1.fetch)(`https://api.dropboxapi.com/2/users/get_current_account`, {
|
|
73
|
+
method: 'POST',
|
|
74
|
+
headers: {
|
|
75
|
+
'Authorization': `Bearer ${access_token}`,
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
78
|
if (response.status !== 200) {
|
|
79
79
|
const code = response.status;
|
|
80
80
|
const hasJSON = response.headers.get('Content-Type') === 'application/json';
|
|
@@ -100,9 +100,9 @@ class DropboxAuthProvider extends oauth_provider_1.OAuth2Provider {
|
|
|
100
100
|
// team_id: user.team.id,
|
|
101
101
|
// team_name: user.team.name,
|
|
102
102
|
// team_member_id: user.team_member_id
|
|
103
|
-
}
|
|
103
|
+
},
|
|
104
104
|
};
|
|
105
|
-
})
|
|
105
|
+
});
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
exports.DropboxAuthProvider = DropboxAuthProvider;
|
|
@@ -35,32 +35,32 @@ class FacebookAuthProvider extends oauth_provider_1.OAuth2Provider {
|
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
37
|
getAccessToken(params) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
.
|
|
38
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
// Request access token with authorization code, or previously granted (short or long-lived) access_token
|
|
40
|
+
const url = `https://graph.facebook.com/v7.0/oauth/access_token?client_id=${this.settings.client_id}&client_secret=${this.settings.client_secret}` +
|
|
41
|
+
(params.type === 'refresh'
|
|
42
|
+
? `&grant_type=fb_exchange_token&fb_exchange_token=${params.refresh_token}`
|
|
43
|
+
: `&code=${params.auth_code}&redirect_uri=${encodeURIComponent(params.redirect_url)}`);
|
|
44
|
+
const response = yield (0, simple_fetch_1.fetch)(url);
|
|
45
|
+
const result = yield response.json();
|
|
46
46
|
if (result.error) {
|
|
47
47
|
const error = result.error;
|
|
48
48
|
throw new Error(`${error.type} ${error.code}: ${error.message}`);
|
|
49
49
|
}
|
|
50
50
|
const secondsToExpiry = result.expires_in;
|
|
51
51
|
result.expires = new Date(Date.now() + (secondsToExpiry * 1000));
|
|
52
|
-
// A short-lived access token can be exchanged for a long-lived (60 day) token.
|
|
53
|
-
// Not sure if a long-lived token can be used to get a new long-lived token,
|
|
52
|
+
// A short-lived access token can be exchanged for a long-lived (60 day) token.
|
|
53
|
+
// Not sure if a long-lived token can be used to get a new long-lived token,
|
|
54
54
|
// needs testing. See docs at: https://developers.facebook.com/docs/facebook-login/access-tokens/refreshing/
|
|
55
55
|
result.refresh_token = result.access_token;
|
|
56
56
|
return result;
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
59
|
getUserInfo(access_token) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
+
// TODO: Check if any requested scopes have not been granted access
|
|
62
|
+
// await fetch(`https://graph.facebook.com/v7.0/me/permissions`);
|
|
63
|
+
const response = yield (0, simple_fetch_1.fetch)(`https://graph.facebook.com/v7.0/me?fields=email,name,short_name,picture&access_token=${access_token}`);
|
|
64
64
|
const result = yield response.json();
|
|
65
65
|
if (response.status !== 200) {
|
|
66
66
|
const error = result;
|
|
@@ -76,9 +76,9 @@ class FacebookAuthProvider extends oauth_provider_1.OAuth2Provider {
|
|
|
76
76
|
email_verified: typeof user.email === 'string',
|
|
77
77
|
other: {
|
|
78
78
|
// We haven't requested more, so we didn't get more
|
|
79
|
-
}
|
|
79
|
+
},
|
|
80
80
|
};
|
|
81
|
-
})
|
|
81
|
+
});
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
exports.FacebookAuthProvider = FacebookAuthProvider;
|
|
@@ -60,64 +60,58 @@ class GoogleAuthProvider extends oauth_provider_1.OAuth2Provider {
|
|
|
60
60
|
// Request access & refresh tokens with authorization code, or refresh token
|
|
61
61
|
const config = yield this.getOpenIDConfig();
|
|
62
62
|
// 'https://oauth2.googleapis.com/token'
|
|
63
|
-
|
|
63
|
+
const response = yield (0, simple_fetch_1.fetch)(config.token_endpoint, {
|
|
64
64
|
method: 'POST',
|
|
65
65
|
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
66
66
|
body: `client_id=${this.settings.client_id}&client_secret=${this.settings.client_secret}&code=`
|
|
67
67
|
+ (params.type === 'refresh'
|
|
68
68
|
? `${params.refresh_token}&grant_type=refresh_token`
|
|
69
|
-
: `${params.auth_code}&grant_type=authorization_code&redirect_uri=${encodeURIComponent(params.redirect_url)}`)
|
|
70
|
-
})
|
|
71
|
-
.then(response => response.json())
|
|
72
|
-
.then((result) => {
|
|
73
|
-
if (result.error) {
|
|
74
|
-
throw new Error(result.error);
|
|
75
|
-
}
|
|
76
|
-
const secondsToExpiry = result.expires_in;
|
|
77
|
-
result.expires = new Date(Date.now() + (secondsToExpiry * 1000));
|
|
78
|
-
return result;
|
|
69
|
+
: `${params.auth_code}&grant_type=authorization_code&redirect_uri=${encodeURIComponent(params.redirect_url)}`),
|
|
79
70
|
});
|
|
71
|
+
const result = yield response.json();
|
|
72
|
+
if (result.error) {
|
|
73
|
+
throw new Error(result.error);
|
|
74
|
+
}
|
|
75
|
+
const secondsToExpiry = result.expires_in;
|
|
76
|
+
result.expires = new Date(Date.now() + (secondsToExpiry * 1000));
|
|
77
|
+
return result;
|
|
80
78
|
});
|
|
81
79
|
}
|
|
82
80
|
revokeAccess(access_token) {
|
|
83
81
|
return __awaiter(this, void 0, void 0, function* () {
|
|
84
82
|
const config = yield this.getOpenIDConfig();
|
|
85
83
|
// https://oauth2.googleapis.com/revoke
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
});
|
|
84
|
+
const response = yield (0, simple_fetch_1.fetch)(`${config.revocation_endpoint}?token=${access_token}`);
|
|
85
|
+
if (response.status !== 200) {
|
|
86
|
+
throw new Error(`Revoke failed, error ${response.status}`);
|
|
87
|
+
}
|
|
92
88
|
});
|
|
93
89
|
}
|
|
94
90
|
getUserInfo(access_token) {
|
|
95
91
|
return __awaiter(this, void 0, void 0, function* () {
|
|
96
92
|
const config = yield this.getOpenIDConfig();
|
|
97
93
|
// https://openidconnect.googleapis.com/v1/userinfo
|
|
98
|
-
|
|
94
|
+
const response = yield (0, simple_fetch_1.fetch)(config.userinfo_endpoint, {
|
|
99
95
|
method: 'GET',
|
|
100
|
-
headers: { 'Authorization': `Bearer ${access_token}` }
|
|
101
|
-
})
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
};
|
|
120
|
-
}));
|
|
96
|
+
headers: { 'Authorization': `Bearer ${access_token}` },
|
|
97
|
+
});
|
|
98
|
+
const result = yield response.json();
|
|
99
|
+
if (response.status !== 200) {
|
|
100
|
+
const error = result;
|
|
101
|
+
throw new Error(`${error.error}: ${error.error_description}`);
|
|
102
|
+
}
|
|
103
|
+
const user = result;
|
|
104
|
+
return {
|
|
105
|
+
id: user.sub,
|
|
106
|
+
name: user.name,
|
|
107
|
+
display_name: user.nickname || user.given_name,
|
|
108
|
+
picture: user.picture ? [{ url: user.picture }] : [],
|
|
109
|
+
email: user.email,
|
|
110
|
+
email_verified: user.email_verified,
|
|
111
|
+
other: Object.keys(user)
|
|
112
|
+
.filter(key => !['sub', 'name', 'picture', 'email', 'email_verified'].includes(key))
|
|
113
|
+
.reduce((obj, key) => { obj[key] = user[key]; return obj; }, {}),
|
|
114
|
+
};
|
|
121
115
|
});
|
|
122
116
|
}
|
|
123
117
|
}
|
|
@@ -21,7 +21,7 @@ const oAuth2Providers = {
|
|
|
21
21
|
facebook: facebook_1.FacebookAuthProvider,
|
|
22
22
|
google: google_1.GoogleAuthProvider,
|
|
23
23
|
instagram: instagram_1.InstagramAuthProvider,
|
|
24
|
-
spotify: spotify_1.SpotifyAuthProvider
|
|
24
|
+
spotify: spotify_1.SpotifyAuthProvider,
|
|
25
25
|
};
|
|
26
26
|
exports.default = oAuth2Providers;
|
|
27
27
|
//# sourceMappingURL=index.js.map
|
|
@@ -39,14 +39,14 @@ class InstagramAuthProvider extends oauth_provider_1.OAuth2Provider {
|
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
41
|
getAccessToken(params) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
.
|
|
42
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
// Request access & refresh tokens with authorization code
|
|
44
|
+
const response = yield (0, simple_fetch_1.fetch)(`https://api.instagram.com/oauth/access_token`, {
|
|
45
|
+
method: 'POST',
|
|
46
|
+
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
47
|
+
body: `client_id=${this.settings.client_id}&client_secret=${this.settings.client_secret}&code=${params.auth_code}&redirect_uri=${encodeURIComponent(params.redirect_url)}`,
|
|
48
|
+
});
|
|
49
|
+
const result = yield response.json();
|
|
50
50
|
if (result.error) {
|
|
51
51
|
throw new Error(result.error);
|
|
52
52
|
}
|
|
@@ -54,8 +54,8 @@ class InstagramAuthProvider extends oauth_provider_1.OAuth2Provider {
|
|
|
54
54
|
});
|
|
55
55
|
}
|
|
56
56
|
getUserInfo(access_token) {
|
|
57
|
-
return (0,
|
|
58
|
-
|
|
57
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
58
|
+
const response = yield (0, simple_fetch_1.fetch)(`https://api.instagram.com/v1/users/self/?access_token=${access_token}`);
|
|
59
59
|
const result = yield response.json();
|
|
60
60
|
if (response.status !== 200) {
|
|
61
61
|
const error = result;
|
|
@@ -71,9 +71,9 @@ class InstagramAuthProvider extends oauth_provider_1.OAuth2Provider {
|
|
|
71
71
|
email_verified: false,
|
|
72
72
|
other: Object.keys(user)
|
|
73
73
|
.filter(key => !['id', 'username', 'full_name', 'profile_picture'].includes(key))
|
|
74
|
-
.reduce((obj, key) => { obj[key] = user[key]; return obj; }, {})
|
|
74
|
+
.reduce((obj, key) => { obj[key] = user[key]; return obj; }, {}),
|
|
75
75
|
};
|
|
76
|
-
})
|
|
76
|
+
});
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
exports.InstagramAuthProvider = InstagramAuthProvider;
|
|
@@ -14,13 +14,8 @@ class OAuth2Provider {
|
|
|
14
14
|
this.settings = settings;
|
|
15
15
|
}
|
|
16
16
|
init(info) { throw new NotImplementedError(); }
|
|
17
|
-
;
|
|
18
17
|
getAccessToken(param) { throw new NotImplementedError(); }
|
|
19
|
-
;
|
|
20
|
-
;
|
|
21
18
|
getUserInfo(access_token) { throw new NotImplementedError(); }
|
|
22
|
-
;
|
|
23
|
-
;
|
|
24
19
|
}
|
|
25
20
|
exports.OAuth2Provider = OAuth2Provider;
|
|
26
21
|
//# sourceMappingURL=oauth-provider.js.map
|
|
@@ -38,19 +38,19 @@ class SpotifyAuthProvider extends oauth_provider_1.OAuth2Provider {
|
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
40
|
getAccessToken(params) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
.
|
|
41
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
// Request access & refresh tokens with authorization code
|
|
43
|
+
const response = yield (0, simple_fetch_1.fetch)('https://accounts.spotify.com/api/token', {
|
|
44
|
+
method: 'POST',
|
|
45
|
+
headers: {
|
|
46
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
47
|
+
},
|
|
48
|
+
body: `client_id=${this.settings.client_id}&client_secret=${this.settings.client_secret}` +
|
|
49
|
+
(params.type === 'refresh'
|
|
50
|
+
? `&grant_type=refresh_token&refresh_token=${params.refresh_token}`
|
|
51
|
+
: `&grant_type=authorization_code&code=${params.auth_code}&redirect_uri=${encodeURIComponent(params.redirect_url)}`),
|
|
52
|
+
});
|
|
53
|
+
const result = yield response.json();
|
|
54
54
|
if (result.error) {
|
|
55
55
|
throw new Error(result.error);
|
|
56
56
|
}
|
|
@@ -60,17 +60,17 @@ class SpotifyAuthProvider extends oauth_provider_1.OAuth2Provider {
|
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
62
|
getClientAccessToken() {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
.
|
|
63
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
64
|
+
// Gets client only access to Spotify API, without signed in user
|
|
65
|
+
const response = yield (0, simple_fetch_1.fetch)('https://accounts.spotify.com/api/token', {
|
|
66
|
+
method: 'POST',
|
|
67
|
+
headers: {
|
|
68
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
69
|
+
'Authorization': `Basic ${Buffer.from(`${this.settings.client_id}:${this.settings.client_secret}`).toString('base64')}`,
|
|
70
|
+
},
|
|
71
|
+
body: `grant_type=client_credentials`,
|
|
72
|
+
});
|
|
73
|
+
const result = yield response.json();
|
|
74
74
|
if (result.error) {
|
|
75
75
|
throw new Error(result.error);
|
|
76
76
|
}
|
|
@@ -78,13 +78,13 @@ class SpotifyAuthProvider extends oauth_provider_1.OAuth2Provider {
|
|
|
78
78
|
});
|
|
79
79
|
}
|
|
80
80
|
getUserInfo(access_token) {
|
|
81
|
-
return (0,
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
81
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
+
const response = yield (0, simple_fetch_1.fetch)('https://api.spotify.com/v1/me', {
|
|
83
|
+
method: 'GET',
|
|
84
|
+
headers: {
|
|
85
|
+
'Authorization': `Bearer ${access_token}`,
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
88
|
const result = yield response.json();
|
|
89
89
|
if (response.status !== 200) {
|
|
90
90
|
const error = result;
|
|
@@ -103,10 +103,10 @@ class SpotifyAuthProvider extends oauth_provider_1.OAuth2Provider {
|
|
|
103
103
|
followers: user.followers ? user.followers.total : null,
|
|
104
104
|
country: user.country,
|
|
105
105
|
// external_urls: user.external_urls,
|
|
106
|
-
uri: user.uri
|
|
107
|
-
}
|
|
106
|
+
uri: user.uri,
|
|
107
|
+
},
|
|
108
108
|
};
|
|
109
|
-
})
|
|
109
|
+
});
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
exports.SpotifyAuthProvider = SpotifyAuthProvider;
|
|
@@ -24,7 +24,7 @@ exports.ChangePasswordError = ChangePasswordError;
|
|
|
24
24
|
const addRoute = (env) => {
|
|
25
25
|
env.app.post(`/auth/${env.db.name}/change_password`, (req, res) => __awaiter(void 0, void 0, void 0, function* () {
|
|
26
26
|
var _a, _b;
|
|
27
|
-
|
|
27
|
+
const access_token = (_a = req.user) === null || _a === void 0 ? void 0 : _a.access_token;
|
|
28
28
|
const details = req.body;
|
|
29
29
|
const LOG_ACTION = 'auth.change_password';
|
|
30
30
|
const LOG_DETAILS = { ip: req.ip, uid: (_b = details.uid) !== null && _b !== void 0 ? _b : null };
|
|
@@ -45,21 +45,21 @@ const addRoute = (env) => {
|
|
|
45
45
|
if (!snap.exists()) {
|
|
46
46
|
throw new ChangePasswordError('unknown_uid', `Unknown uid`);
|
|
47
47
|
}
|
|
48
|
-
|
|
48
|
+
const user = snap.val();
|
|
49
49
|
user.uid = snap.key;
|
|
50
|
-
|
|
50
|
+
const hash = user.password_salt ? (0, password_1.getPasswordHash)(details.password, user.password_salt) : (0, password_1.getOldPasswordHash)(details.password);
|
|
51
51
|
if (user.password !== hash) {
|
|
52
52
|
throw new ChangePasswordError('wrong_password', `Wrong password`);
|
|
53
53
|
}
|
|
54
54
|
if (access_token && access_token !== user.access_token) {
|
|
55
55
|
throw new ChangePasswordError('wrong_access_token', `Cannot change password while signed in as other user, or with an old token`);
|
|
56
56
|
}
|
|
57
|
-
|
|
57
|
+
const pwd = (0, password_1.createPasswordHash)(details.new_password);
|
|
58
58
|
const updates = {
|
|
59
59
|
access_token: acebase_core_1.ID.generate(),
|
|
60
60
|
access_token_created: new Date(),
|
|
61
61
|
password: pwd.hash,
|
|
62
|
-
password_salt: pwd.salt
|
|
62
|
+
password_salt: pwd.salt,
|
|
63
63
|
};
|
|
64
64
|
// Update user object
|
|
65
65
|
Object.assign(user, updates);
|
|
@@ -21,7 +21,7 @@ exports.DeleteError = DeleteError;
|
|
|
21
21
|
const addRoute = (env) => {
|
|
22
22
|
env.app.post(`/auth/${env.db.name}/delete`, (req, res) => __awaiter(void 0, void 0, void 0, function* () {
|
|
23
23
|
var _a, _b, _c, _d;
|
|
24
|
-
|
|
24
|
+
const details = req.body;
|
|
25
25
|
const LOG_ACTION = 'auth.delete';
|
|
26
26
|
const LOG_DETAILS = { ip: req.ip, uid: (_b = (_a = req.user) === null || _a === void 0 ? void 0 : _a.uid) !== null && _b !== void 0 ? _b : null, delete_uid: details.uid };
|
|
27
27
|
if (!req.user) {
|
|
@@ -52,8 +52,8 @@ const addRoute = (env) => {
|
|
|
52
52
|
uid: user.uid,
|
|
53
53
|
username: user.username,
|
|
54
54
|
settings: user.settings,
|
|
55
|
-
displayName: user.display_name
|
|
56
|
-
}
|
|
55
|
+
displayName: user.display_name,
|
|
56
|
+
},
|
|
57
57
|
};
|
|
58
58
|
yield snap.ref.update({ password_reset_code: user.password_reset_code });
|
|
59
59
|
yield env.config.email.send(request).catch(err => {
|
|
@@ -28,12 +28,14 @@ exports.ResetPasswordError = ResetPasswordError;
|
|
|
28
28
|
const addRoute = (env) => {
|
|
29
29
|
const resetPassword = (clientIp, code, newPassword) => __awaiter(void 0, void 0, void 0, function* () {
|
|
30
30
|
var _a;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
const verification = (() => {
|
|
32
|
+
try {
|
|
33
|
+
return (0, tokens_1.parseSignedPublicToken)(code, env.tokenSalt);
|
|
34
|
+
}
|
|
35
|
+
catch (err) {
|
|
36
|
+
throw new ResetPasswordError('invalid_code', err.message);
|
|
37
|
+
}
|
|
38
|
+
})();
|
|
37
39
|
const snap = yield env.authRef.child(verification.uid).get();
|
|
38
40
|
if (!snap.exists()) {
|
|
39
41
|
throw new ResetPasswordError('unknown_user', 'Uknown user');
|
|
@@ -51,7 +53,7 @@ const addRoute = (env) => {
|
|
|
51
53
|
yield snap.ref.update({
|
|
52
54
|
password: pwd.hash,
|
|
53
55
|
password_salt: pwd.salt,
|
|
54
|
-
password_reset_code: null
|
|
56
|
+
password_reset_code: null,
|
|
55
57
|
});
|
|
56
58
|
// Send confirmation email
|
|
57
59
|
const request = {
|
|
@@ -63,8 +65,8 @@ const addRoute = (env) => {
|
|
|
63
65
|
email: user.email,
|
|
64
66
|
username: user.username,
|
|
65
67
|
displayName: user.display_name,
|
|
66
|
-
settings: user.settings
|
|
67
|
-
}
|
|
68
|
+
settings: user.settings,
|
|
69
|
+
},
|
|
68
70
|
};
|
|
69
71
|
(_a = env.config.email) === null || _a === void 0 ? void 0 : _a.send(request);
|
|
70
72
|
return user;
|