acebase-server 1.15.2 → 1.16.1

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.
Files changed (504) hide show
  1. package/.eslintrc.json +49 -0
  2. package/README.md +10 -0
  3. package/build-vars.js +16 -0
  4. package/dist/cjs/auth.js +2 -2
  5. package/dist/cjs/cluster.js +2 -2
  6. package/dist/cjs/middleware/cors.js +3 -3
  7. package/dist/cjs/oauth-providers/dropbox.js +22 -22
  8. package/dist/cjs/oauth-providers/facebook.js +16 -16
  9. package/dist/cjs/oauth-providers/google.js +33 -39
  10. package/dist/cjs/oauth-providers/index.js +1 -1
  11. package/dist/cjs/oauth-providers/instagram.js +12 -12
  12. package/dist/cjs/oauth-providers/oauth-provider.js +0 -5
  13. package/dist/cjs/oauth-providers/spotify.js +34 -34
  14. package/dist/cjs/routes/auth-change-password.js +5 -5
  15. package/dist/cjs/routes/auth-delete.js +1 -1
  16. package/dist/cjs/routes/auth-forgot-password.js +2 -2
  17. package/dist/cjs/routes/auth-reset-password.js +11 -9
  18. package/dist/cjs/routes/auth-signin.js +1 -1
  19. package/dist/cjs/routes/auth-signout.js +1 -1
  20. package/dist/cjs/routes/auth-signup.js +5 -5
  21. package/dist/cjs/routes/auth-update.js +1 -1
  22. package/dist/cjs/routes/auth-verify-email.js +8 -6
  23. package/dist/cjs/routes/auth.js +1 -1
  24. package/dist/cjs/routes/data-export.js +1 -1
  25. package/dist/cjs/routes/data-get.js +2 -2
  26. package/dist/cjs/routes/data-index-list.js +0 -1
  27. package/dist/cjs/routes/data-query.js +1 -1
  28. package/dist/cjs/routes/data-reflect.js +4 -4
  29. package/dist/cjs/routes/data-schema-get.js +1 -1
  30. package/dist/cjs/routes/data-schemas-list.js +1 -1
  31. package/dist/cjs/routes/data-transaction.js +1 -1
  32. package/dist/cjs/routes/docs.js +57 -54
  33. package/dist/cjs/routes/meta-info.js +6 -12
  34. package/dist/cjs/routes/meta-logs.js +1 -1
  35. package/dist/cjs/routes/oauth2-init.js +8 -5
  36. package/dist/cjs/routes/oauth2-refresh.js +2 -2
  37. package/dist/cjs/routes/oauth2-signin.js +23 -23
  38. package/dist/cjs/routes/webmanager.js +4 -4
  39. package/dist/cjs/rules.js +8 -8
  40. package/dist/cjs/schema/user.js +1 -2
  41. package/dist/cjs/server.js +74 -31
  42. package/dist/cjs/settings/email.js +0 -2
  43. package/dist/cjs/settings/index.js +19 -4
  44. package/dist/cjs/shared/email.js +0 -4
  45. package/dist/cjs/shared/env.js +0 -2
  46. package/dist/cjs/shared/error.js +0 -1
  47. package/dist/cjs/shared/http.js +9 -1
  48. package/dist/cjs/shared/password.js +5 -5
  49. package/dist/cjs/shared/rootpath.js +1 -1
  50. package/dist/cjs/shared/signin.js +3 -3
  51. package/dist/cjs/shared/simple-fetch.js +5 -5
  52. package/dist/cjs/shared/tokens.js +3 -3
  53. package/dist/cjs/start.js +6 -6
  54. package/dist/cjs/websocket/index.js +11 -11
  55. package/dist/cjs/websocket/socket.io.js +2 -1
  56. package/dist/esm/auth.js +5 -5
  57. package/dist/esm/cluster.js +2 -2
  58. package/dist/esm/middleware/admin-only.js +1 -1
  59. package/dist/esm/middleware/cors.js +3 -3
  60. package/dist/esm/middleware/user.js +3 -3
  61. package/dist/esm/oauth-providers/dropbox.js +47 -51
  62. package/dist/esm/oauth-providers/facebook.js +34 -38
  63. package/dist/esm/oauth-providers/google.js +33 -39
  64. package/dist/esm/oauth-providers/index.js +1 -1
  65. package/dist/esm/oauth-providers/instagram.js +28 -32
  66. package/dist/esm/oauth-providers/oauth-provider.js +0 -5
  67. package/dist/esm/oauth-providers/spotify.js +46 -52
  68. package/dist/esm/routes/auth-change-password.js +5 -5
  69. package/dist/esm/routes/auth-delete.js +1 -1
  70. package/dist/esm/routes/auth-forgot-password.js +2 -2
  71. package/dist/esm/routes/auth-reset-password.js +11 -9
  72. package/dist/esm/routes/auth-signin.js +1 -1
  73. package/dist/esm/routes/auth-signout.js +1 -1
  74. package/dist/esm/routes/auth-signup.js +5 -5
  75. package/dist/esm/routes/auth-update.js +1 -1
  76. package/dist/esm/routes/auth-verify-email.js +8 -6
  77. package/dist/esm/routes/auth.js +1 -1
  78. package/dist/esm/routes/data-export.js +1 -1
  79. package/dist/esm/routes/data-get.js +2 -2
  80. package/dist/esm/routes/data-index-list.js +0 -1
  81. package/dist/esm/routes/data-query.js +1 -1
  82. package/dist/esm/routes/data-reflect.js +4 -4
  83. package/dist/esm/routes/data-schema-get.js +1 -1
  84. package/dist/esm/routes/data-schemas-list.js +1 -1
  85. package/dist/esm/routes/data-transaction.js +1 -1
  86. package/dist/esm/routes/data.js +1 -1
  87. package/dist/esm/routes/docs.js +56 -54
  88. package/dist/esm/routes/meta-info.js +6 -12
  89. package/dist/esm/routes/meta-logs.js +1 -1
  90. package/dist/esm/routes/oauth2-init.js +8 -5
  91. package/dist/esm/routes/oauth2-refresh.js +2 -2
  92. package/dist/esm/routes/oauth2-signin.js +20 -20
  93. package/dist/esm/routes/webmanager.js +5 -5
  94. package/dist/esm/rules.js +8 -8
  95. package/dist/esm/schema/user.js +1 -2
  96. package/dist/esm/server.js +72 -30
  97. package/dist/esm/settings/email.js +0 -2
  98. package/dist/esm/settings/index.js +19 -4
  99. package/dist/esm/shared/email.js +0 -4
  100. package/dist/esm/shared/env.js +0 -2
  101. package/dist/esm/shared/error.js +0 -1
  102. package/dist/esm/shared/http.js +7 -0
  103. package/dist/esm/shared/password.js +5 -5
  104. package/dist/esm/shared/rootpath.js +2 -2
  105. package/dist/esm/shared/signin.js +6 -6
  106. package/dist/esm/shared/simple-fetch.js +5 -5
  107. package/dist/esm/shared/tokens.js +3 -3
  108. package/dist/esm/start.js +6 -6
  109. package/dist/esm/websocket/index.js +15 -15
  110. package/dist/esm/websocket/manager.js +1 -1
  111. package/dist/esm/websocket/socket.io.js +2 -1
  112. package/dist/types/auth.d.ts +1 -1
  113. package/dist/types/logger.d.ts +1 -1
  114. package/dist/types/middleware/404.d.ts +1 -1
  115. package/dist/types/middleware/admin-only.d.ts +3 -3
  116. package/dist/types/middleware/cache.d.ts +1 -1
  117. package/dist/types/middleware/context.d.ts +1 -1
  118. package/dist/types/middleware/cors.d.ts +1 -1
  119. package/dist/types/middleware/swagger.d.ts +1 -1
  120. package/dist/types/middleware/user.d.ts +1 -1
  121. package/dist/types/oauth-providers/dropbox.d.ts +1 -1
  122. package/dist/types/oauth-providers/facebook.d.ts +1 -1
  123. package/dist/types/oauth-providers/google.d.ts +1 -1
  124. package/dist/types/oauth-providers/instagram.d.ts +1 -1
  125. package/dist/types/oauth-providers/spotify.d.ts +1 -1
  126. package/dist/types/routes/auth-change-password.d.ts +2 -2
  127. package/dist/types/routes/auth-delete.d.ts +2 -2
  128. package/dist/types/routes/auth-forgot-password.d.ts +2 -2
  129. package/dist/types/routes/auth-reset-password.d.ts +2 -2
  130. package/dist/types/routes/auth-signin.d.ts +2 -2
  131. package/dist/types/routes/auth-signout.d.ts +2 -2
  132. package/dist/types/routes/auth-signup.d.ts +2 -2
  133. package/dist/types/routes/auth-state.d.ts +3 -3
  134. package/dist/types/routes/auth-update.d.ts +2 -2
  135. package/dist/types/routes/auth-verify-email.d.ts +2 -2
  136. package/dist/types/routes/data-exists.d.ts +1 -1
  137. package/dist/types/routes/data-export.d.ts +1 -1
  138. package/dist/types/routes/data-get.d.ts +1 -1
  139. package/dist/types/routes/data-import.d.ts +1 -1
  140. package/dist/types/routes/data-index-create.d.ts +2 -2
  141. package/dist/types/routes/data-index-delete.d.ts +1 -1
  142. package/dist/types/routes/data-index-list.d.ts +2 -2
  143. package/dist/types/routes/data-query.d.ts +1 -1
  144. package/dist/types/routes/data-reflect.d.ts +1 -1
  145. package/dist/types/routes/data-schema-get.d.ts +1 -1
  146. package/dist/types/routes/data-schema-set.d.ts +1 -1
  147. package/dist/types/routes/data-schema-test.d.ts +1 -1
  148. package/dist/types/routes/data-schemas-list.d.ts +1 -1
  149. package/dist/types/routes/data-set.d.ts +1 -1
  150. package/dist/types/routes/data-sync-changes.d.ts +1 -1
  151. package/dist/types/routes/data-sync-mutations.d.ts +1 -1
  152. package/dist/types/routes/data-transaction.d.ts +2 -2
  153. package/dist/types/routes/data-update.d.ts +1 -1
  154. package/dist/types/routes/data.d.ts +1 -1
  155. package/dist/types/routes/meta-info.d.ts +1 -1
  156. package/dist/types/routes/meta-logs.d.ts +1 -1
  157. package/dist/types/routes/meta-ping.d.ts +1 -1
  158. package/dist/types/routes/meta-stats.d.ts +1 -1
  159. package/dist/types/routes/oauth2-init.d.ts +1 -1
  160. package/dist/types/routes/oauth2-refresh.d.ts +1 -1
  161. package/dist/types/routes/oauth2-signin.d.ts +1 -1
  162. package/dist/types/routes/webmanager.d.ts +1 -1
  163. package/dist/types/schema/user.d.ts +2 -2
  164. package/dist/types/server.d.ts +3 -0
  165. package/dist/types/settings/index.d.ts +23 -0
  166. package/dist/types/shared/clients.d.ts +3 -3
  167. package/dist/types/shared/env.d.ts +2 -1
  168. package/dist/types/shared/http.d.ts +5 -0
  169. package/dist/types/shared/signin.d.ts +4 -4
  170. package/dist/types/shared/validate.d.ts +1 -1
  171. package/dist/types/websocket/index.d.ts +1 -1
  172. package/dist/types/websocket/manager.d.ts +1 -1
  173. package/img/acebase-swagger-ui.png +0 -0
  174. package/img/acebase-webmanager.png +0 -0
  175. package/package.json +12 -6
  176. package/src/routes/auth-signin.yaml +2 -2
  177. package/webmanager/acebase-client-browser.min.js +8 -11
  178. package/webmanager/index.html +1 -0
  179. package/webmanager/index.js +67 -71
  180. package/.vscode/launch.json +0 -24
  181. package/create-package-files +0 -25
  182. package/dist/cjs/auth.js.map +0 -1
  183. package/dist/cjs/cluster.js.map +0 -1
  184. package/dist/cjs/index.js.map +0 -1
  185. package/dist/cjs/logger.js.map +0 -1
  186. package/dist/cjs/middleware/404.js.map +0 -1
  187. package/dist/cjs/middleware/admin-only.js.map +0 -1
  188. package/dist/cjs/middleware/cache.js.map +0 -1
  189. package/dist/cjs/middleware/connection.js.map +0 -1
  190. package/dist/cjs/middleware/context.js.map +0 -1
  191. package/dist/cjs/middleware/cors.js.map +0 -1
  192. package/dist/cjs/middleware/swagger.js.map +0 -1
  193. package/dist/cjs/middleware/user.js.map +0 -1
  194. package/dist/cjs/oauth-providers/dropbox.js.map +0 -1
  195. package/dist/cjs/oauth-providers/facebook.js.map +0 -1
  196. package/dist/cjs/oauth-providers/google.js.map +0 -1
  197. package/dist/cjs/oauth-providers/index.js.map +0 -1
  198. package/dist/cjs/oauth-providers/instagram.js.map +0 -1
  199. package/dist/cjs/oauth-providers/oauth-provider.js.map +0 -1
  200. package/dist/cjs/oauth-providers/spotify.js.map +0 -1
  201. package/dist/cjs/routes/auth-change-password.js.map +0 -1
  202. package/dist/cjs/routes/auth-delete.js.map +0 -1
  203. package/dist/cjs/routes/auth-forgot-password.js.map +0 -1
  204. package/dist/cjs/routes/auth-reset-password.js.map +0 -1
  205. package/dist/cjs/routes/auth-signin.js.map +0 -1
  206. package/dist/cjs/routes/auth-signout.js.map +0 -1
  207. package/dist/cjs/routes/auth-signup.js.map +0 -1
  208. package/dist/cjs/routes/auth-state.js.map +0 -1
  209. package/dist/cjs/routes/auth-update.js.map +0 -1
  210. package/dist/cjs/routes/auth-verify-email.js.map +0 -1
  211. package/dist/cjs/routes/auth.js.map +0 -1
  212. package/dist/cjs/routes/data-exists.js.map +0 -1
  213. package/dist/cjs/routes/data-export.js.map +0 -1
  214. package/dist/cjs/routes/data-get.js.map +0 -1
  215. package/dist/cjs/routes/data-import.js.map +0 -1
  216. package/dist/cjs/routes/data-index-create.js.map +0 -1
  217. package/dist/cjs/routes/data-index-delete.js.map +0 -1
  218. package/dist/cjs/routes/data-index-list.js.map +0 -1
  219. package/dist/cjs/routes/data-query.js.map +0 -1
  220. package/dist/cjs/routes/data-reflect.js.map +0 -1
  221. package/dist/cjs/routes/data-schema-get.js.map +0 -1
  222. package/dist/cjs/routes/data-schema-set.js.map +0 -1
  223. package/dist/cjs/routes/data-schema-test.js.map +0 -1
  224. package/dist/cjs/routes/data-schemas-list.js.map +0 -1
  225. package/dist/cjs/routes/data-set.js.map +0 -1
  226. package/dist/cjs/routes/data-sync-changes.js.map +0 -1
  227. package/dist/cjs/routes/data-sync-mutations.js.map +0 -1
  228. package/dist/cjs/routes/data-transaction.js.map +0 -1
  229. package/dist/cjs/routes/data-update.js.map +0 -1
  230. package/dist/cjs/routes/data.js.map +0 -1
  231. package/dist/cjs/routes/docs.js.map +0 -1
  232. package/dist/cjs/routes/meta-info.js.map +0 -1
  233. package/dist/cjs/routes/meta-logs.js.map +0 -1
  234. package/dist/cjs/routes/meta-ping.js.map +0 -1
  235. package/dist/cjs/routes/meta-stats.js.map +0 -1
  236. package/dist/cjs/routes/meta.js.map +0 -1
  237. package/dist/cjs/routes/oauth2-init.js.map +0 -1
  238. package/dist/cjs/routes/oauth2-refresh.js.map +0 -1
  239. package/dist/cjs/routes/oauth2-signin.js.map +0 -1
  240. package/dist/cjs/routes/webmanager.js.map +0 -1
  241. package/dist/cjs/rules.js.map +0 -1
  242. package/dist/cjs/schema/user.js.map +0 -1
  243. package/dist/cjs/server.js.map +0 -1
  244. package/dist/cjs/settings/email.js.map +0 -1
  245. package/dist/cjs/settings/index.js.map +0 -1
  246. package/dist/cjs/shared/clients.js.map +0 -1
  247. package/dist/cjs/shared/email.js.map +0 -1
  248. package/dist/cjs/shared/env.js.map +0 -1
  249. package/dist/cjs/shared/error.js.map +0 -1
  250. package/dist/cjs/shared/http.js.map +0 -1
  251. package/dist/cjs/shared/password.js.map +0 -1
  252. package/dist/cjs/shared/rootpath.js.map +0 -1
  253. package/dist/cjs/shared/signin.js.map +0 -1
  254. package/dist/cjs/shared/simple-fetch.js.map +0 -1
  255. package/dist/cjs/shared/tokens.js.map +0 -1
  256. package/dist/cjs/shared/validate.js.map +0 -1
  257. package/dist/cjs/start.js.map +0 -1
  258. package/dist/cjs/test.js.map +0 -1
  259. package/dist/cjs/websocket/index.js.map +0 -1
  260. package/dist/cjs/websocket/manager.js.map +0 -1
  261. package/dist/cjs/websocket/socket.io.js.map +0 -1
  262. package/dist/esm/auth.js.map +0 -1
  263. package/dist/esm/cluster.js.map +0 -1
  264. package/dist/esm/index.js.map +0 -1
  265. package/dist/esm/logger.js.map +0 -1
  266. package/dist/esm/middleware/404.js.map +0 -1
  267. package/dist/esm/middleware/admin-only.js.map +0 -1
  268. package/dist/esm/middleware/cache.js.map +0 -1
  269. package/dist/esm/middleware/connection.js.map +0 -1
  270. package/dist/esm/middleware/context.js.map +0 -1
  271. package/dist/esm/middleware/cors.js.map +0 -1
  272. package/dist/esm/middleware/swagger.js.map +0 -1
  273. package/dist/esm/middleware/user.js.map +0 -1
  274. package/dist/esm/oauth-providers/dropbox.js.map +0 -1
  275. package/dist/esm/oauth-providers/facebook.js.map +0 -1
  276. package/dist/esm/oauth-providers/google.js.map +0 -1
  277. package/dist/esm/oauth-providers/index.js.map +0 -1
  278. package/dist/esm/oauth-providers/instagram.js.map +0 -1
  279. package/dist/esm/oauth-providers/oauth-provider.js.map +0 -1
  280. package/dist/esm/oauth-providers/spotify.js.map +0 -1
  281. package/dist/esm/routes/auth-change-password.js.map +0 -1
  282. package/dist/esm/routes/auth-delete.js.map +0 -1
  283. package/dist/esm/routes/auth-forgot-password.js.map +0 -1
  284. package/dist/esm/routes/auth-reset-password.js.map +0 -1
  285. package/dist/esm/routes/auth-signin.js.map +0 -1
  286. package/dist/esm/routes/auth-signout.js.map +0 -1
  287. package/dist/esm/routes/auth-signup.js.map +0 -1
  288. package/dist/esm/routes/auth-state.js.map +0 -1
  289. package/dist/esm/routes/auth-update.js.map +0 -1
  290. package/dist/esm/routes/auth-verify-email.js.map +0 -1
  291. package/dist/esm/routes/auth.js.map +0 -1
  292. package/dist/esm/routes/data-exists.js.map +0 -1
  293. package/dist/esm/routes/data-export.js.map +0 -1
  294. package/dist/esm/routes/data-get.js.map +0 -1
  295. package/dist/esm/routes/data-import.js.map +0 -1
  296. package/dist/esm/routes/data-index-create.js.map +0 -1
  297. package/dist/esm/routes/data-index-delete.js.map +0 -1
  298. package/dist/esm/routes/data-index-list.js.map +0 -1
  299. package/dist/esm/routes/data-query.js.map +0 -1
  300. package/dist/esm/routes/data-reflect.js.map +0 -1
  301. package/dist/esm/routes/data-schema-get.js.map +0 -1
  302. package/dist/esm/routes/data-schema-set.js.map +0 -1
  303. package/dist/esm/routes/data-schema-test.js.map +0 -1
  304. package/dist/esm/routes/data-schemas-list.js.map +0 -1
  305. package/dist/esm/routes/data-set.js.map +0 -1
  306. package/dist/esm/routes/data-sync-changes.js.map +0 -1
  307. package/dist/esm/routes/data-sync-mutations.js.map +0 -1
  308. package/dist/esm/routes/data-transaction.js.map +0 -1
  309. package/dist/esm/routes/data-update.js.map +0 -1
  310. package/dist/esm/routes/data.js.map +0 -1
  311. package/dist/esm/routes/docs.js.map +0 -1
  312. package/dist/esm/routes/meta-info.js.map +0 -1
  313. package/dist/esm/routes/meta-logs.js.map +0 -1
  314. package/dist/esm/routes/meta-ping.js.map +0 -1
  315. package/dist/esm/routes/meta-stats.js.map +0 -1
  316. package/dist/esm/routes/meta.js.map +0 -1
  317. package/dist/esm/routes/oauth2-init.js.map +0 -1
  318. package/dist/esm/routes/oauth2-refresh.js.map +0 -1
  319. package/dist/esm/routes/oauth2-signin.js.map +0 -1
  320. package/dist/esm/routes/webmanager.js.map +0 -1
  321. package/dist/esm/rules.js.map +0 -1
  322. package/dist/esm/schema/user.js.map +0 -1
  323. package/dist/esm/server.js.map +0 -1
  324. package/dist/esm/settings/email.js.map +0 -1
  325. package/dist/esm/settings/index.js.map +0 -1
  326. package/dist/esm/shared/clients.js.map +0 -1
  327. package/dist/esm/shared/email.js.map +0 -1
  328. package/dist/esm/shared/env.js.map +0 -1
  329. package/dist/esm/shared/error.js.map +0 -1
  330. package/dist/esm/shared/http.js.map +0 -1
  331. package/dist/esm/shared/password.js.map +0 -1
  332. package/dist/esm/shared/rootpath.js.map +0 -1
  333. package/dist/esm/shared/signin.js.map +0 -1
  334. package/dist/esm/shared/simple-fetch.js.map +0 -1
  335. package/dist/esm/shared/tokens.js.map +0 -1
  336. package/dist/esm/shared/validate.js.map +0 -1
  337. package/dist/esm/start.js.map +0 -1
  338. package/dist/esm/test.js.map +0 -1
  339. package/dist/esm/websocket/index.js.map +0 -1
  340. package/dist/esm/websocket/manager.js.map +0 -1
  341. package/dist/esm/websocket/socket.io.js.map +0 -1
  342. package/dist/types/auth.d.ts.map +0 -1
  343. package/dist/types/cluster.d.ts.map +0 -1
  344. package/dist/types/index.d.ts.map +0 -1
  345. package/dist/types/logger.d.ts.map +0 -1
  346. package/dist/types/middleware/404.d.ts.map +0 -1
  347. package/dist/types/middleware/admin-only.d.ts.map +0 -1
  348. package/dist/types/middleware/cache.d.ts.map +0 -1
  349. package/dist/types/middleware/connection.d.ts.map +0 -1
  350. package/dist/types/middleware/context.d.ts.map +0 -1
  351. package/dist/types/middleware/cors.d.ts.map +0 -1
  352. package/dist/types/middleware/swagger.d.ts.map +0 -1
  353. package/dist/types/middleware/user.d.ts.map +0 -1
  354. package/dist/types/oauth-providers/dropbox.d.ts.map +0 -1
  355. package/dist/types/oauth-providers/facebook.d.ts.map +0 -1
  356. package/dist/types/oauth-providers/google.d.ts.map +0 -1
  357. package/dist/types/oauth-providers/index.d.ts.map +0 -1
  358. package/dist/types/oauth-providers/instagram.d.ts.map +0 -1
  359. package/dist/types/oauth-providers/oauth-provider.d.ts.map +0 -1
  360. package/dist/types/oauth-providers/spotify.d.ts.map +0 -1
  361. package/dist/types/routes/auth-change-password.d.ts.map +0 -1
  362. package/dist/types/routes/auth-delete.d.ts.map +0 -1
  363. package/dist/types/routes/auth-forgot-password.d.ts.map +0 -1
  364. package/dist/types/routes/auth-reset-password.d.ts.map +0 -1
  365. package/dist/types/routes/auth-signin.d.ts.map +0 -1
  366. package/dist/types/routes/auth-signout.d.ts.map +0 -1
  367. package/dist/types/routes/auth-signup.d.ts.map +0 -1
  368. package/dist/types/routes/auth-state.d.ts.map +0 -1
  369. package/dist/types/routes/auth-update.d.ts.map +0 -1
  370. package/dist/types/routes/auth-verify-email.d.ts.map +0 -1
  371. package/dist/types/routes/auth.d.ts.map +0 -1
  372. package/dist/types/routes/data-exists.d.ts.map +0 -1
  373. package/dist/types/routes/data-export.d.ts.map +0 -1
  374. package/dist/types/routes/data-get.d.ts.map +0 -1
  375. package/dist/types/routes/data-import.d.ts.map +0 -1
  376. package/dist/types/routes/data-index-create.d.ts.map +0 -1
  377. package/dist/types/routes/data-index-delete.d.ts.map +0 -1
  378. package/dist/types/routes/data-index-list.d.ts.map +0 -1
  379. package/dist/types/routes/data-query.d.ts.map +0 -1
  380. package/dist/types/routes/data-reflect.d.ts.map +0 -1
  381. package/dist/types/routes/data-schema-get.d.ts.map +0 -1
  382. package/dist/types/routes/data-schema-set.d.ts.map +0 -1
  383. package/dist/types/routes/data-schema-test.d.ts.map +0 -1
  384. package/dist/types/routes/data-schemas-list.d.ts.map +0 -1
  385. package/dist/types/routes/data-set.d.ts.map +0 -1
  386. package/dist/types/routes/data-sync-changes.d.ts.map +0 -1
  387. package/dist/types/routes/data-sync-mutations.d.ts.map +0 -1
  388. package/dist/types/routes/data-transaction.d.ts.map +0 -1
  389. package/dist/types/routes/data-update.d.ts.map +0 -1
  390. package/dist/types/routes/data.d.ts.map +0 -1
  391. package/dist/types/routes/docs.d.ts.map +0 -1
  392. package/dist/types/routes/meta-info.d.ts.map +0 -1
  393. package/dist/types/routes/meta-logs.d.ts.map +0 -1
  394. package/dist/types/routes/meta-ping.d.ts.map +0 -1
  395. package/dist/types/routes/meta-stats.d.ts.map +0 -1
  396. package/dist/types/routes/meta.d.ts.map +0 -1
  397. package/dist/types/routes/oauth2-init.d.ts.map +0 -1
  398. package/dist/types/routes/oauth2-refresh.d.ts.map +0 -1
  399. package/dist/types/routes/oauth2-signin.d.ts.map +0 -1
  400. package/dist/types/routes/webmanager.d.ts.map +0 -1
  401. package/dist/types/rules.d.ts.map +0 -1
  402. package/dist/types/schema/user.d.ts.map +0 -1
  403. package/dist/types/server.d.ts.map +0 -1
  404. package/dist/types/settings/email.d.ts.map +0 -1
  405. package/dist/types/settings/index.d.ts.map +0 -1
  406. package/dist/types/shared/clients.d.ts.map +0 -1
  407. package/dist/types/shared/email.d.ts.map +0 -1
  408. package/dist/types/shared/env.d.ts.map +0 -1
  409. package/dist/types/shared/error.d.ts.map +0 -1
  410. package/dist/types/shared/http.d.ts.map +0 -1
  411. package/dist/types/shared/password.d.ts.map +0 -1
  412. package/dist/types/shared/rootpath.d.ts.map +0 -1
  413. package/dist/types/shared/signin.d.ts.map +0 -1
  414. package/dist/types/shared/simple-fetch.d.ts.map +0 -1
  415. package/dist/types/shared/tokens.d.ts.map +0 -1
  416. package/dist/types/shared/validate.d.ts.map +0 -1
  417. package/dist/types/start.d.ts.map +0 -1
  418. package/dist/types/test.d.ts.map +0 -1
  419. package/dist/types/websocket/index.d.ts.map +0 -1
  420. package/dist/types/websocket/manager.d.ts.map +0 -1
  421. package/dist/types/websocket/socket.io.d.ts.map +0 -1
  422. package/src/auth.ts +0 -87
  423. package/src/cluster.ts +0 -62
  424. package/src/index.ts +0 -4
  425. package/src/logger.ts +0 -56
  426. package/src/middleware/404.ts +0 -13
  427. package/src/middleware/admin-only.ts +0 -29
  428. package/src/middleware/cache.ts +0 -15
  429. package/src/middleware/connection.ts +0 -48
  430. package/src/middleware/context.ts +0 -23
  431. package/src/middleware/cors.ts +0 -49
  432. package/src/middleware/swagger.ts +0 -19
  433. package/src/middleware/user.ts +0 -51
  434. package/src/oauth-providers/dropbox.ts +0 -144
  435. package/src/oauth-providers/facebook.ts +0 -103
  436. package/src/oauth-providers/google.ts +0 -147
  437. package/src/oauth-providers/index.ts +0 -21
  438. package/src/oauth-providers/instagram.ts +0 -98
  439. package/src/oauth-providers/oauth-provider.ts +0 -65
  440. package/src/oauth-providers/spotify.ts +0 -127
  441. package/src/placeholder.d.ts +0 -12
  442. package/src/routes/auth-change-password.ts +0 -92
  443. package/src/routes/auth-delete.ts +0 -49
  444. package/src/routes/auth-forgot-password.ts +0 -77
  445. package/src/routes/auth-reset-password.ts +0 -96
  446. package/src/routes/auth-signin.ts +0 -55
  447. package/src/routes/auth-signout.ts +0 -64
  448. package/src/routes/auth-signup.ts +0 -164
  449. package/src/routes/auth-state.ts +0 -20
  450. package/src/routes/auth-update.ts +0 -149
  451. package/src/routes/auth-verify-email.ts +0 -75
  452. package/src/routes/auth.ts +0 -67
  453. package/src/routes/data-exists.ts +0 -31
  454. package/src/routes/data-export.ts +0 -51
  455. package/src/routes/data-get.ts +0 -67
  456. package/src/routes/data-import.ts +0 -56
  457. package/src/routes/data-index-create.ts +0 -82
  458. package/src/routes/data-index-delete.ts +0 -36
  459. package/src/routes/data-index-list.ts +0 -39
  460. package/src/routes/data-query.ts +0 -97
  461. package/src/routes/data-reflect.ts +0 -91
  462. package/src/routes/data-schema-get.ts +0 -36
  463. package/src/routes/data-schema-set.ts +0 -35
  464. package/src/routes/data-schema-test.ts +0 -48
  465. package/src/routes/data-schemas-list.ts +0 -31
  466. package/src/routes/data-set.ts +0 -83
  467. package/src/routes/data-sync-changes.ts +0 -77
  468. package/src/routes/data-sync-mutations.ts +0 -77
  469. package/src/routes/data-transaction.ts +0 -166
  470. package/src/routes/data-update.ts +0 -84
  471. package/src/routes/data.ts +0 -79
  472. package/src/routes/docs.ts +0 -249
  473. package/src/routes/meta-info.ts +0 -80
  474. package/src/routes/meta-logs.ts +0 -57
  475. package/src/routes/meta-ping.ts +0 -15
  476. package/src/routes/meta-stats.ts +0 -31
  477. package/src/routes/meta.ts +0 -22
  478. package/src/routes/oauth2-init.ts +0 -44
  479. package/src/routes/oauth2-refresh.ts +0 -39
  480. package/src/routes/oauth2-signin.ts +0 -286
  481. package/src/routes/webmanager.ts +0 -29
  482. package/src/rules.ts +0 -189
  483. package/src/schema/user.ts +0 -99
  484. package/src/server.ts +0 -419
  485. package/src/settings/email.ts +0 -18
  486. package/src/settings/index.ts +0 -241
  487. package/src/shared/clients.ts +0 -31
  488. package/src/shared/email.ts +0 -33
  489. package/src/shared/env.ts +0 -38
  490. package/src/shared/error.ts +0 -37
  491. package/src/shared/http.ts +0 -26
  492. package/src/shared/password.ts +0 -41
  493. package/src/shared/rootpath.ts +0 -17
  494. package/src/shared/signin.ts +0 -149
  495. package/src/shared/simple-fetch.ts +0 -65
  496. package/src/shared/tokens.ts +0 -77
  497. package/src/shared/validate.ts +0 -53
  498. package/src/start.ts +0 -48
  499. package/src/test.ts +0 -10
  500. package/src/websocket/index.ts +0 -336
  501. package/src/websocket/manager.ts +0 -46
  502. package/src/websocket/socket.io.ts +0 -90
  503. package/tsconfig-cjs.json +0 -11
  504. 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
+ ![AceBase server webmanager](./img/acebase-webmanager.png)
6
+
7
+ ![AceBase server Swagger UI](./img/acebase-swagger-ui.png)
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/build-vars.js ADDED
@@ -0,0 +1,16 @@
1
+ // Executed by npm "version" hook
2
+ const { readFileSync, writeFileSync } = require('fs');
3
+ const { execSync } = require('child_process');
4
+ const packageInfo = require('./package.json');
5
+
6
+ const files = ['./dist/cjs/routes/meta-info.js', './dist/esm/routes/meta-info.js'];
7
+ files.forEach(file => {
8
+ const originalContent = readFileSync(file, 'utf8');
9
+ content = originalContent.replace(/%SERVER_VERSION%/g, packageInfo.version);
10
+ if (content !== originalContent) {
11
+ writeFileSync(file, content, 'utf8');
12
+ console.log(`Replaced variable %SERVER_VERSION% with ${packageInfo.version} in ${file}`);
13
+ }
14
+ });
15
+
16
+ execSync(`git add dist`);
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
- let length = 256;
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));
@@ -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
- let dbname = "default";
16
- let options = { /* default options */}; // Load from cluster.config.js!
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 (let name in headers) {
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
- // Request access & refresh tokens with authorization code
46
- return (0, simple_fetch_1.fetch)('https://api.dropbox.com/oauth2/token', {
47
- method: 'POST',
48
- headers: {
49
- "Content-Type": "application/x-www-form-urlencoded"
50
- },
51
- body: `client_id=${this.settings.client_id}&client_secret=${this.settings.client_secret}` +
52
- (params.type === 'refresh'
53
- ? `&grant_type=refresh_token&refresh_token=${params.refresh_token}`
54
- : `&grant_type=authorization_code&code=${params.auth_code}&redirect_uri=${encodeURIComponent(params.redirect_url)}`)
55
- })
56
- .then((response) => __awaiter(this, void 0, void 0, function* () {
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, simple_fetch_1.fetch)(`https://api.dropboxapi.com/2/users/get_current_account`, {
72
- method: 'POST',
73
- headers: {
74
- 'Authorization': `Bearer ${access_token}`
75
- }
76
- })
77
- .then((response) => __awaiter(this, void 0, void 0, function* () {
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
- // Request access token with authorization code, or previously granted (short or long-lived) access_token
39
- const url = `https://graph.facebook.com/v7.0/oauth/access_token?client_id=${this.settings.client_id}&client_secret=${this.settings.client_secret}` +
40
- (params.type === 'refresh'
41
- ? `&grant_type=fb_exchange_token&fb_exchange_token=${params.refresh_token}`
42
- : `&code=${params.auth_code}&redirect_uri=${encodeURIComponent(params.redirect_url)}`);
43
- return (0, simple_fetch_1.fetch)(url)
44
- .then(response => response.json())
45
- .then((result) => {
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
- // TODO: Check if any requested scopes have not been granted access
61
- // await fetch(`https://graph.facebook.com/v7.0/me/permissions`);
62
- return (0, simple_fetch_1.fetch)(`https://graph.facebook.com/v7.0/me?fields=email,name,short_name,picture&access_token=${access_token}`)
63
- .then((response) => __awaiter(this, void 0, void 0, function* () {
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
- return (0, simple_fetch_1.fetch)(config.token_endpoint, {
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
- return (0, simple_fetch_1.fetch)(`${config.revocation_endpoint}?token=${access_token}`)
87
- .then(response => {
88
- if (response.status !== 200) {
89
- throw new Error(`Revoke failed, error ${response.status}`);
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
- return (0, simple_fetch_1.fetch)(config.userinfo_endpoint, {
94
+ const response = yield (0, simple_fetch_1.fetch)(config.userinfo_endpoint, {
99
95
  method: 'GET',
100
- headers: { 'Authorization': `Bearer ${access_token}` }
101
- })
102
- .then((response) => __awaiter(this, void 0, void 0, function* () {
103
- const result = yield response.json();
104
- if (response.status !== 200) {
105
- const error = result;
106
- throw new Error(`${error.error}: ${error.error_description}`);
107
- }
108
- const user = result;
109
- return {
110
- id: user.sub,
111
- name: user.name,
112
- display_name: user.nickname || user.given_name,
113
- picture: user.picture ? [{ url: user.picture }] : [],
114
- email: user.email,
115
- email_verified: user.email_verified,
116
- other: Object.keys(user)
117
- .filter(key => !['sub', 'name', 'picture', 'email', 'email_verified'].includes(key))
118
- .reduce((obj, key) => { obj[key] = user[key]; return obj; }, {})
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
- // Request access & refresh tokens with authorization code
43
- return (0, simple_fetch_1.fetch)(`https://api.instagram.com/oauth/access_token`, {
44
- method: 'POST',
45
- headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
46
- body: `client_id=${this.settings.client_id}&client_secret=${this.settings.client_secret}&code=${params.auth_code}&redirect_uri=${encodeURIComponent(params.redirect_url)}`
47
- })
48
- .then(response => response.json())
49
- .then((result) => {
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, simple_fetch_1.fetch)(`https://api.instagram.com/v1/users/self/?access_token=${access_token}`)
58
- .then((response) => __awaiter(this, void 0, void 0, function* () {
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
- // Request access & refresh tokens with authorization code
42
- return (0, simple_fetch_1.fetch)('https://accounts.spotify.com/api/token', {
43
- method: 'POST',
44
- headers: {
45
- "Content-Type": "application/x-www-form-urlencoded"
46
- },
47
- body: `client_id=${this.settings.client_id}&client_secret=${this.settings.client_secret}` +
48
- (params.type === 'refresh'
49
- ? `&grant_type=refresh_token&refresh_token=${params.refresh_token}`
50
- : `&grant_type=authorization_code&code=${params.auth_code}&redirect_uri=${encodeURIComponent(params.redirect_url)}`)
51
- })
52
- .then(response => response.json())
53
- .then((result) => {
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
- // Gets client only access to Spotify API, without signed in user
64
- return (0, simple_fetch_1.fetch)('https://accounts.spotify.com/api/token', {
65
- method: 'POST',
66
- headers: {
67
- "Content-Type": "application/x-www-form-urlencoded",
68
- "Authorization": `Basic ${Buffer.from(`${this.settings.client_id}:${this.settings.client_secret}`).toString('base64')}`
69
- },
70
- body: `grant_type=client_credentials`
71
- })
72
- .then(response => response.json())
73
- .then((result) => {
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, simple_fetch_1.fetch)('https://api.spotify.com/v1/me', {
82
- method: 'GET',
83
- headers: {
84
- "Authorization": `Bearer ${access_token}`
85
- },
86
- })
87
- .then((response) => __awaiter(this, void 0, void 0, function* () {
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
- let access_token = (_a = req.user) === null || _a === void 0 ? void 0 : _a.access_token;
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
- let user = snap.val();
48
+ const user = snap.val();
49
49
  user.uid = snap.key;
50
- let hash = user.password_salt ? (0, password_1.getPasswordHash)(details.password, user.password_salt) : (0, password_1.getOldPasswordHash)(details.password);
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
- let pwd = (0, password_1.createPasswordHash)(details.new_password);
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
- let details = req.body;
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 => {