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.
Files changed (503) hide show
  1. package/.eslintrc.json +49 -0
  2. package/README.md +10 -0
  3. package/dist/cjs/auth.js +2 -2
  4. package/dist/cjs/cluster.js +2 -2
  5. package/dist/cjs/middleware/cors.js +3 -3
  6. package/dist/cjs/oauth-providers/dropbox.js +22 -22
  7. package/dist/cjs/oauth-providers/facebook.js +16 -16
  8. package/dist/cjs/oauth-providers/google.js +33 -39
  9. package/dist/cjs/oauth-providers/index.js +1 -1
  10. package/dist/cjs/oauth-providers/instagram.js +12 -12
  11. package/dist/cjs/oauth-providers/oauth-provider.js +0 -5
  12. package/dist/cjs/oauth-providers/spotify.js +34 -34
  13. package/dist/cjs/routes/auth-change-password.js +5 -5
  14. package/dist/cjs/routes/auth-delete.js +1 -1
  15. package/dist/cjs/routes/auth-forgot-password.js +2 -2
  16. package/dist/cjs/routes/auth-reset-password.js +11 -9
  17. package/dist/cjs/routes/auth-signin.js +1 -1
  18. package/dist/cjs/routes/auth-signout.js +1 -1
  19. package/dist/cjs/routes/auth-signup.js +5 -5
  20. package/dist/cjs/routes/auth-update.js +1 -1
  21. package/dist/cjs/routes/auth-verify-email.js +8 -6
  22. package/dist/cjs/routes/auth.js +1 -1
  23. package/dist/cjs/routes/data-export.js +1 -1
  24. package/dist/cjs/routes/data-get.js +2 -2
  25. package/dist/cjs/routes/data-index-list.js +0 -1
  26. package/dist/cjs/routes/data-query.js +1 -1
  27. package/dist/cjs/routes/data-reflect.js +4 -4
  28. package/dist/cjs/routes/data-schema-get.js +1 -1
  29. package/dist/cjs/routes/data-schemas-list.js +1 -1
  30. package/dist/cjs/routes/data-transaction.js +1 -1
  31. package/dist/cjs/routes/docs.js +57 -54
  32. package/dist/cjs/routes/meta-info.js +8 -12
  33. package/dist/cjs/routes/meta-logs.js +1 -1
  34. package/dist/cjs/routes/oauth2-init.js +8 -5
  35. package/dist/cjs/routes/oauth2-refresh.js +2 -2
  36. package/dist/cjs/routes/oauth2-signin.js +23 -23
  37. package/dist/cjs/routes/webmanager.js +4 -4
  38. package/dist/cjs/rules.js +8 -8
  39. package/dist/cjs/schema/user.js +1 -2
  40. package/dist/cjs/server.js +74 -31
  41. package/dist/cjs/settings/email.js +0 -2
  42. package/dist/cjs/settings/index.js +19 -4
  43. package/dist/cjs/shared/email.js +0 -4
  44. package/dist/cjs/shared/env.js +0 -2
  45. package/dist/cjs/shared/error.js +0 -1
  46. package/dist/cjs/shared/http.js +9 -1
  47. package/dist/cjs/shared/password.js +5 -5
  48. package/dist/cjs/shared/rootpath.js +1 -1
  49. package/dist/cjs/shared/signin.js +3 -3
  50. package/dist/cjs/shared/simple-fetch.js +5 -5
  51. package/dist/cjs/shared/tokens.js +3 -3
  52. package/dist/cjs/start.js +6 -6
  53. package/dist/cjs/websocket/index.js +11 -11
  54. package/dist/cjs/websocket/socket.io.js +2 -1
  55. package/dist/esm/auth.js +5 -5
  56. package/dist/esm/cluster.js +2 -2
  57. package/dist/esm/middleware/admin-only.js +1 -1
  58. package/dist/esm/middleware/cors.js +3 -3
  59. package/dist/esm/middleware/user.js +3 -3
  60. package/dist/esm/oauth-providers/dropbox.js +47 -51
  61. package/dist/esm/oauth-providers/facebook.js +34 -38
  62. package/dist/esm/oauth-providers/google.js +33 -39
  63. package/dist/esm/oauth-providers/index.js +1 -1
  64. package/dist/esm/oauth-providers/instagram.js +28 -32
  65. package/dist/esm/oauth-providers/oauth-provider.js +0 -5
  66. package/dist/esm/oauth-providers/spotify.js +46 -52
  67. package/dist/esm/routes/auth-change-password.js +5 -5
  68. package/dist/esm/routes/auth-delete.js +1 -1
  69. package/dist/esm/routes/auth-forgot-password.js +2 -2
  70. package/dist/esm/routes/auth-reset-password.js +11 -9
  71. package/dist/esm/routes/auth-signin.js +1 -1
  72. package/dist/esm/routes/auth-signout.js +1 -1
  73. package/dist/esm/routes/auth-signup.js +5 -5
  74. package/dist/esm/routes/auth-update.js +1 -1
  75. package/dist/esm/routes/auth-verify-email.js +8 -6
  76. package/dist/esm/routes/auth.js +1 -1
  77. package/dist/esm/routes/data-export.js +1 -1
  78. package/dist/esm/routes/data-get.js +2 -2
  79. package/dist/esm/routes/data-index-list.js +0 -1
  80. package/dist/esm/routes/data-query.js +1 -1
  81. package/dist/esm/routes/data-reflect.js +4 -4
  82. package/dist/esm/routes/data-schema-get.js +1 -1
  83. package/dist/esm/routes/data-schemas-list.js +1 -1
  84. package/dist/esm/routes/data-transaction.js +1 -1
  85. package/dist/esm/routes/data.js +1 -1
  86. package/dist/esm/routes/docs.js +56 -54
  87. package/dist/esm/routes/meta-info.js +8 -12
  88. package/dist/esm/routes/meta-logs.js +1 -1
  89. package/dist/esm/routes/oauth2-init.js +8 -5
  90. package/dist/esm/routes/oauth2-refresh.js +2 -2
  91. package/dist/esm/routes/oauth2-signin.js +20 -20
  92. package/dist/esm/routes/webmanager.js +5 -5
  93. package/dist/esm/rules.js +8 -8
  94. package/dist/esm/schema/user.js +1 -2
  95. package/dist/esm/server.js +72 -30
  96. package/dist/esm/settings/email.js +0 -2
  97. package/dist/esm/settings/index.js +19 -4
  98. package/dist/esm/shared/email.js +0 -4
  99. package/dist/esm/shared/env.js +0 -2
  100. package/dist/esm/shared/error.js +0 -1
  101. package/dist/esm/shared/http.js +7 -0
  102. package/dist/esm/shared/password.js +5 -5
  103. package/dist/esm/shared/rootpath.js +2 -2
  104. package/dist/esm/shared/signin.js +6 -6
  105. package/dist/esm/shared/simple-fetch.js +5 -5
  106. package/dist/esm/shared/tokens.js +3 -3
  107. package/dist/esm/start.js +6 -6
  108. package/dist/esm/websocket/index.js +15 -15
  109. package/dist/esm/websocket/manager.js +1 -1
  110. package/dist/esm/websocket/socket.io.js +2 -1
  111. package/dist/types/auth.d.ts +1 -1
  112. package/dist/types/logger.d.ts +1 -1
  113. package/dist/types/middleware/404.d.ts +1 -1
  114. package/dist/types/middleware/admin-only.d.ts +3 -3
  115. package/dist/types/middleware/cache.d.ts +1 -1
  116. package/dist/types/middleware/context.d.ts +1 -1
  117. package/dist/types/middleware/cors.d.ts +1 -1
  118. package/dist/types/middleware/swagger.d.ts +1 -1
  119. package/dist/types/middleware/user.d.ts +1 -1
  120. package/dist/types/oauth-providers/dropbox.d.ts +1 -1
  121. package/dist/types/oauth-providers/facebook.d.ts +1 -1
  122. package/dist/types/oauth-providers/google.d.ts +1 -1
  123. package/dist/types/oauth-providers/instagram.d.ts +1 -1
  124. package/dist/types/oauth-providers/spotify.d.ts +1 -1
  125. package/dist/types/routes/auth-change-password.d.ts +2 -2
  126. package/dist/types/routes/auth-delete.d.ts +2 -2
  127. package/dist/types/routes/auth-forgot-password.d.ts +2 -2
  128. package/dist/types/routes/auth-reset-password.d.ts +2 -2
  129. package/dist/types/routes/auth-signin.d.ts +2 -2
  130. package/dist/types/routes/auth-signout.d.ts +2 -2
  131. package/dist/types/routes/auth-signup.d.ts +2 -2
  132. package/dist/types/routes/auth-state.d.ts +3 -3
  133. package/dist/types/routes/auth-update.d.ts +2 -2
  134. package/dist/types/routes/auth-verify-email.d.ts +2 -2
  135. package/dist/types/routes/data-exists.d.ts +1 -1
  136. package/dist/types/routes/data-export.d.ts +1 -1
  137. package/dist/types/routes/data-get.d.ts +1 -1
  138. package/dist/types/routes/data-import.d.ts +1 -1
  139. package/dist/types/routes/data-index-create.d.ts +2 -2
  140. package/dist/types/routes/data-index-delete.d.ts +1 -1
  141. package/dist/types/routes/data-index-list.d.ts +2 -2
  142. package/dist/types/routes/data-query.d.ts +1 -1
  143. package/dist/types/routes/data-reflect.d.ts +1 -1
  144. package/dist/types/routes/data-schema-get.d.ts +1 -1
  145. package/dist/types/routes/data-schema-set.d.ts +1 -1
  146. package/dist/types/routes/data-schema-test.d.ts +1 -1
  147. package/dist/types/routes/data-schemas-list.d.ts +1 -1
  148. package/dist/types/routes/data-set.d.ts +1 -1
  149. package/dist/types/routes/data-sync-changes.d.ts +1 -1
  150. package/dist/types/routes/data-sync-mutations.d.ts +1 -1
  151. package/dist/types/routes/data-transaction.d.ts +2 -2
  152. package/dist/types/routes/data-update.d.ts +1 -1
  153. package/dist/types/routes/data.d.ts +1 -1
  154. package/dist/types/routes/meta-info.d.ts +1 -1
  155. package/dist/types/routes/meta-logs.d.ts +1 -1
  156. package/dist/types/routes/meta-ping.d.ts +1 -1
  157. package/dist/types/routes/meta-stats.d.ts +1 -1
  158. package/dist/types/routes/oauth2-init.d.ts +1 -1
  159. package/dist/types/routes/oauth2-refresh.d.ts +1 -1
  160. package/dist/types/routes/oauth2-signin.d.ts +1 -1
  161. package/dist/types/routes/webmanager.d.ts +1 -1
  162. package/dist/types/schema/user.d.ts +2 -2
  163. package/dist/types/server.d.ts +3 -0
  164. package/dist/types/settings/index.d.ts +23 -0
  165. package/dist/types/shared/clients.d.ts +3 -3
  166. package/dist/types/shared/env.d.ts +2 -1
  167. package/dist/types/shared/http.d.ts +5 -0
  168. package/dist/types/shared/signin.d.ts +4 -4
  169. package/dist/types/shared/validate.d.ts +1 -1
  170. package/dist/types/websocket/index.d.ts +1 -1
  171. package/dist/types/websocket/manager.d.ts +1 -1
  172. package/img/acebase-swagger-ui.png +0 -0
  173. package/img/acebase-webmanager.png +0 -0
  174. package/package.json +10 -5
  175. package/src/routes/auth-signin.yaml +2 -2
  176. package/webmanager/acebase-client-browser.min.js +8 -11
  177. package/webmanager/index.html +1 -0
  178. package/webmanager/index.js +67 -71
  179. package/.vscode/launch.json +0 -24
  180. package/create-package-files +0 -25
  181. package/dist/cjs/auth.js.map +0 -1
  182. package/dist/cjs/cluster.js.map +0 -1
  183. package/dist/cjs/index.js.map +0 -1
  184. package/dist/cjs/logger.js.map +0 -1
  185. package/dist/cjs/middleware/404.js.map +0 -1
  186. package/dist/cjs/middleware/admin-only.js.map +0 -1
  187. package/dist/cjs/middleware/cache.js.map +0 -1
  188. package/dist/cjs/middleware/connection.js.map +0 -1
  189. package/dist/cjs/middleware/context.js.map +0 -1
  190. package/dist/cjs/middleware/cors.js.map +0 -1
  191. package/dist/cjs/middleware/swagger.js.map +0 -1
  192. package/dist/cjs/middleware/user.js.map +0 -1
  193. package/dist/cjs/oauth-providers/dropbox.js.map +0 -1
  194. package/dist/cjs/oauth-providers/facebook.js.map +0 -1
  195. package/dist/cjs/oauth-providers/google.js.map +0 -1
  196. package/dist/cjs/oauth-providers/index.js.map +0 -1
  197. package/dist/cjs/oauth-providers/instagram.js.map +0 -1
  198. package/dist/cjs/oauth-providers/oauth-provider.js.map +0 -1
  199. package/dist/cjs/oauth-providers/spotify.js.map +0 -1
  200. package/dist/cjs/routes/auth-change-password.js.map +0 -1
  201. package/dist/cjs/routes/auth-delete.js.map +0 -1
  202. package/dist/cjs/routes/auth-forgot-password.js.map +0 -1
  203. package/dist/cjs/routes/auth-reset-password.js.map +0 -1
  204. package/dist/cjs/routes/auth-signin.js.map +0 -1
  205. package/dist/cjs/routes/auth-signout.js.map +0 -1
  206. package/dist/cjs/routes/auth-signup.js.map +0 -1
  207. package/dist/cjs/routes/auth-state.js.map +0 -1
  208. package/dist/cjs/routes/auth-update.js.map +0 -1
  209. package/dist/cjs/routes/auth-verify-email.js.map +0 -1
  210. package/dist/cjs/routes/auth.js.map +0 -1
  211. package/dist/cjs/routes/data-exists.js.map +0 -1
  212. package/dist/cjs/routes/data-export.js.map +0 -1
  213. package/dist/cjs/routes/data-get.js.map +0 -1
  214. package/dist/cjs/routes/data-import.js.map +0 -1
  215. package/dist/cjs/routes/data-index-create.js.map +0 -1
  216. package/dist/cjs/routes/data-index-delete.js.map +0 -1
  217. package/dist/cjs/routes/data-index-list.js.map +0 -1
  218. package/dist/cjs/routes/data-query.js.map +0 -1
  219. package/dist/cjs/routes/data-reflect.js.map +0 -1
  220. package/dist/cjs/routes/data-schema-get.js.map +0 -1
  221. package/dist/cjs/routes/data-schema-set.js.map +0 -1
  222. package/dist/cjs/routes/data-schema-test.js.map +0 -1
  223. package/dist/cjs/routes/data-schemas-list.js.map +0 -1
  224. package/dist/cjs/routes/data-set.js.map +0 -1
  225. package/dist/cjs/routes/data-sync-changes.js.map +0 -1
  226. package/dist/cjs/routes/data-sync-mutations.js.map +0 -1
  227. package/dist/cjs/routes/data-transaction.js.map +0 -1
  228. package/dist/cjs/routes/data-update.js.map +0 -1
  229. package/dist/cjs/routes/data.js.map +0 -1
  230. package/dist/cjs/routes/docs.js.map +0 -1
  231. package/dist/cjs/routes/meta-info.js.map +0 -1
  232. package/dist/cjs/routes/meta-logs.js.map +0 -1
  233. package/dist/cjs/routes/meta-ping.js.map +0 -1
  234. package/dist/cjs/routes/meta-stats.js.map +0 -1
  235. package/dist/cjs/routes/meta.js.map +0 -1
  236. package/dist/cjs/routes/oauth2-init.js.map +0 -1
  237. package/dist/cjs/routes/oauth2-refresh.js.map +0 -1
  238. package/dist/cjs/routes/oauth2-signin.js.map +0 -1
  239. package/dist/cjs/routes/webmanager.js.map +0 -1
  240. package/dist/cjs/rules.js.map +0 -1
  241. package/dist/cjs/schema/user.js.map +0 -1
  242. package/dist/cjs/server.js.map +0 -1
  243. package/dist/cjs/settings/email.js.map +0 -1
  244. package/dist/cjs/settings/index.js.map +0 -1
  245. package/dist/cjs/shared/clients.js.map +0 -1
  246. package/dist/cjs/shared/email.js.map +0 -1
  247. package/dist/cjs/shared/env.js.map +0 -1
  248. package/dist/cjs/shared/error.js.map +0 -1
  249. package/dist/cjs/shared/http.js.map +0 -1
  250. package/dist/cjs/shared/password.js.map +0 -1
  251. package/dist/cjs/shared/rootpath.js.map +0 -1
  252. package/dist/cjs/shared/signin.js.map +0 -1
  253. package/dist/cjs/shared/simple-fetch.js.map +0 -1
  254. package/dist/cjs/shared/tokens.js.map +0 -1
  255. package/dist/cjs/shared/validate.js.map +0 -1
  256. package/dist/cjs/start.js.map +0 -1
  257. package/dist/cjs/test.js.map +0 -1
  258. package/dist/cjs/websocket/index.js.map +0 -1
  259. package/dist/cjs/websocket/manager.js.map +0 -1
  260. package/dist/cjs/websocket/socket.io.js.map +0 -1
  261. package/dist/esm/auth.js.map +0 -1
  262. package/dist/esm/cluster.js.map +0 -1
  263. package/dist/esm/index.js.map +0 -1
  264. package/dist/esm/logger.js.map +0 -1
  265. package/dist/esm/middleware/404.js.map +0 -1
  266. package/dist/esm/middleware/admin-only.js.map +0 -1
  267. package/dist/esm/middleware/cache.js.map +0 -1
  268. package/dist/esm/middleware/connection.js.map +0 -1
  269. package/dist/esm/middleware/context.js.map +0 -1
  270. package/dist/esm/middleware/cors.js.map +0 -1
  271. package/dist/esm/middleware/swagger.js.map +0 -1
  272. package/dist/esm/middleware/user.js.map +0 -1
  273. package/dist/esm/oauth-providers/dropbox.js.map +0 -1
  274. package/dist/esm/oauth-providers/facebook.js.map +0 -1
  275. package/dist/esm/oauth-providers/google.js.map +0 -1
  276. package/dist/esm/oauth-providers/index.js.map +0 -1
  277. package/dist/esm/oauth-providers/instagram.js.map +0 -1
  278. package/dist/esm/oauth-providers/oauth-provider.js.map +0 -1
  279. package/dist/esm/oauth-providers/spotify.js.map +0 -1
  280. package/dist/esm/routes/auth-change-password.js.map +0 -1
  281. package/dist/esm/routes/auth-delete.js.map +0 -1
  282. package/dist/esm/routes/auth-forgot-password.js.map +0 -1
  283. package/dist/esm/routes/auth-reset-password.js.map +0 -1
  284. package/dist/esm/routes/auth-signin.js.map +0 -1
  285. package/dist/esm/routes/auth-signout.js.map +0 -1
  286. package/dist/esm/routes/auth-signup.js.map +0 -1
  287. package/dist/esm/routes/auth-state.js.map +0 -1
  288. package/dist/esm/routes/auth-update.js.map +0 -1
  289. package/dist/esm/routes/auth-verify-email.js.map +0 -1
  290. package/dist/esm/routes/auth.js.map +0 -1
  291. package/dist/esm/routes/data-exists.js.map +0 -1
  292. package/dist/esm/routes/data-export.js.map +0 -1
  293. package/dist/esm/routes/data-get.js.map +0 -1
  294. package/dist/esm/routes/data-import.js.map +0 -1
  295. package/dist/esm/routes/data-index-create.js.map +0 -1
  296. package/dist/esm/routes/data-index-delete.js.map +0 -1
  297. package/dist/esm/routes/data-index-list.js.map +0 -1
  298. package/dist/esm/routes/data-query.js.map +0 -1
  299. package/dist/esm/routes/data-reflect.js.map +0 -1
  300. package/dist/esm/routes/data-schema-get.js.map +0 -1
  301. package/dist/esm/routes/data-schema-set.js.map +0 -1
  302. package/dist/esm/routes/data-schema-test.js.map +0 -1
  303. package/dist/esm/routes/data-schemas-list.js.map +0 -1
  304. package/dist/esm/routes/data-set.js.map +0 -1
  305. package/dist/esm/routes/data-sync-changes.js.map +0 -1
  306. package/dist/esm/routes/data-sync-mutations.js.map +0 -1
  307. package/dist/esm/routes/data-transaction.js.map +0 -1
  308. package/dist/esm/routes/data-update.js.map +0 -1
  309. package/dist/esm/routes/data.js.map +0 -1
  310. package/dist/esm/routes/docs.js.map +0 -1
  311. package/dist/esm/routes/meta-info.js.map +0 -1
  312. package/dist/esm/routes/meta-logs.js.map +0 -1
  313. package/dist/esm/routes/meta-ping.js.map +0 -1
  314. package/dist/esm/routes/meta-stats.js.map +0 -1
  315. package/dist/esm/routes/meta.js.map +0 -1
  316. package/dist/esm/routes/oauth2-init.js.map +0 -1
  317. package/dist/esm/routes/oauth2-refresh.js.map +0 -1
  318. package/dist/esm/routes/oauth2-signin.js.map +0 -1
  319. package/dist/esm/routes/webmanager.js.map +0 -1
  320. package/dist/esm/rules.js.map +0 -1
  321. package/dist/esm/schema/user.js.map +0 -1
  322. package/dist/esm/server.js.map +0 -1
  323. package/dist/esm/settings/email.js.map +0 -1
  324. package/dist/esm/settings/index.js.map +0 -1
  325. package/dist/esm/shared/clients.js.map +0 -1
  326. package/dist/esm/shared/email.js.map +0 -1
  327. package/dist/esm/shared/env.js.map +0 -1
  328. package/dist/esm/shared/error.js.map +0 -1
  329. package/dist/esm/shared/http.js.map +0 -1
  330. package/dist/esm/shared/password.js.map +0 -1
  331. package/dist/esm/shared/rootpath.js.map +0 -1
  332. package/dist/esm/shared/signin.js.map +0 -1
  333. package/dist/esm/shared/simple-fetch.js.map +0 -1
  334. package/dist/esm/shared/tokens.js.map +0 -1
  335. package/dist/esm/shared/validate.js.map +0 -1
  336. package/dist/esm/start.js.map +0 -1
  337. package/dist/esm/test.js.map +0 -1
  338. package/dist/esm/websocket/index.js.map +0 -1
  339. package/dist/esm/websocket/manager.js.map +0 -1
  340. package/dist/esm/websocket/socket.io.js.map +0 -1
  341. package/dist/types/auth.d.ts.map +0 -1
  342. package/dist/types/cluster.d.ts.map +0 -1
  343. package/dist/types/index.d.ts.map +0 -1
  344. package/dist/types/logger.d.ts.map +0 -1
  345. package/dist/types/middleware/404.d.ts.map +0 -1
  346. package/dist/types/middleware/admin-only.d.ts.map +0 -1
  347. package/dist/types/middleware/cache.d.ts.map +0 -1
  348. package/dist/types/middleware/connection.d.ts.map +0 -1
  349. package/dist/types/middleware/context.d.ts.map +0 -1
  350. package/dist/types/middleware/cors.d.ts.map +0 -1
  351. package/dist/types/middleware/swagger.d.ts.map +0 -1
  352. package/dist/types/middleware/user.d.ts.map +0 -1
  353. package/dist/types/oauth-providers/dropbox.d.ts.map +0 -1
  354. package/dist/types/oauth-providers/facebook.d.ts.map +0 -1
  355. package/dist/types/oauth-providers/google.d.ts.map +0 -1
  356. package/dist/types/oauth-providers/index.d.ts.map +0 -1
  357. package/dist/types/oauth-providers/instagram.d.ts.map +0 -1
  358. package/dist/types/oauth-providers/oauth-provider.d.ts.map +0 -1
  359. package/dist/types/oauth-providers/spotify.d.ts.map +0 -1
  360. package/dist/types/routes/auth-change-password.d.ts.map +0 -1
  361. package/dist/types/routes/auth-delete.d.ts.map +0 -1
  362. package/dist/types/routes/auth-forgot-password.d.ts.map +0 -1
  363. package/dist/types/routes/auth-reset-password.d.ts.map +0 -1
  364. package/dist/types/routes/auth-signin.d.ts.map +0 -1
  365. package/dist/types/routes/auth-signout.d.ts.map +0 -1
  366. package/dist/types/routes/auth-signup.d.ts.map +0 -1
  367. package/dist/types/routes/auth-state.d.ts.map +0 -1
  368. package/dist/types/routes/auth-update.d.ts.map +0 -1
  369. package/dist/types/routes/auth-verify-email.d.ts.map +0 -1
  370. package/dist/types/routes/auth.d.ts.map +0 -1
  371. package/dist/types/routes/data-exists.d.ts.map +0 -1
  372. package/dist/types/routes/data-export.d.ts.map +0 -1
  373. package/dist/types/routes/data-get.d.ts.map +0 -1
  374. package/dist/types/routes/data-import.d.ts.map +0 -1
  375. package/dist/types/routes/data-index-create.d.ts.map +0 -1
  376. package/dist/types/routes/data-index-delete.d.ts.map +0 -1
  377. package/dist/types/routes/data-index-list.d.ts.map +0 -1
  378. package/dist/types/routes/data-query.d.ts.map +0 -1
  379. package/dist/types/routes/data-reflect.d.ts.map +0 -1
  380. package/dist/types/routes/data-schema-get.d.ts.map +0 -1
  381. package/dist/types/routes/data-schema-set.d.ts.map +0 -1
  382. package/dist/types/routes/data-schema-test.d.ts.map +0 -1
  383. package/dist/types/routes/data-schemas-list.d.ts.map +0 -1
  384. package/dist/types/routes/data-set.d.ts.map +0 -1
  385. package/dist/types/routes/data-sync-changes.d.ts.map +0 -1
  386. package/dist/types/routes/data-sync-mutations.d.ts.map +0 -1
  387. package/dist/types/routes/data-transaction.d.ts.map +0 -1
  388. package/dist/types/routes/data-update.d.ts.map +0 -1
  389. package/dist/types/routes/data.d.ts.map +0 -1
  390. package/dist/types/routes/docs.d.ts.map +0 -1
  391. package/dist/types/routes/meta-info.d.ts.map +0 -1
  392. package/dist/types/routes/meta-logs.d.ts.map +0 -1
  393. package/dist/types/routes/meta-ping.d.ts.map +0 -1
  394. package/dist/types/routes/meta-stats.d.ts.map +0 -1
  395. package/dist/types/routes/meta.d.ts.map +0 -1
  396. package/dist/types/routes/oauth2-init.d.ts.map +0 -1
  397. package/dist/types/routes/oauth2-refresh.d.ts.map +0 -1
  398. package/dist/types/routes/oauth2-signin.d.ts.map +0 -1
  399. package/dist/types/routes/webmanager.d.ts.map +0 -1
  400. package/dist/types/rules.d.ts.map +0 -1
  401. package/dist/types/schema/user.d.ts.map +0 -1
  402. package/dist/types/server.d.ts.map +0 -1
  403. package/dist/types/settings/email.d.ts.map +0 -1
  404. package/dist/types/settings/index.d.ts.map +0 -1
  405. package/dist/types/shared/clients.d.ts.map +0 -1
  406. package/dist/types/shared/email.d.ts.map +0 -1
  407. package/dist/types/shared/env.d.ts.map +0 -1
  408. package/dist/types/shared/error.d.ts.map +0 -1
  409. package/dist/types/shared/http.d.ts.map +0 -1
  410. package/dist/types/shared/password.d.ts.map +0 -1
  411. package/dist/types/shared/rootpath.d.ts.map +0 -1
  412. package/dist/types/shared/signin.d.ts.map +0 -1
  413. package/dist/types/shared/simple-fetch.d.ts.map +0 -1
  414. package/dist/types/shared/tokens.d.ts.map +0 -1
  415. package/dist/types/shared/validate.d.ts.map +0 -1
  416. package/dist/types/start.d.ts.map +0 -1
  417. package/dist/types/test.d.ts.map +0 -1
  418. package/dist/types/websocket/index.d.ts.map +0 -1
  419. package/dist/types/websocket/manager.d.ts.map +0 -1
  420. package/dist/types/websocket/socket.io.d.ts.map +0 -1
  421. package/src/auth.ts +0 -87
  422. package/src/cluster.ts +0 -62
  423. package/src/index.ts +0 -4
  424. package/src/logger.ts +0 -56
  425. package/src/middleware/404.ts +0 -13
  426. package/src/middleware/admin-only.ts +0 -29
  427. package/src/middleware/cache.ts +0 -15
  428. package/src/middleware/connection.ts +0 -48
  429. package/src/middleware/context.ts +0 -23
  430. package/src/middleware/cors.ts +0 -49
  431. package/src/middleware/swagger.ts +0 -19
  432. package/src/middleware/user.ts +0 -51
  433. package/src/oauth-providers/dropbox.ts +0 -144
  434. package/src/oauth-providers/facebook.ts +0 -103
  435. package/src/oauth-providers/google.ts +0 -147
  436. package/src/oauth-providers/index.ts +0 -21
  437. package/src/oauth-providers/instagram.ts +0 -98
  438. package/src/oauth-providers/oauth-provider.ts +0 -65
  439. package/src/oauth-providers/spotify.ts +0 -127
  440. package/src/placeholder.d.ts +0 -12
  441. package/src/routes/auth-change-password.ts +0 -92
  442. package/src/routes/auth-delete.ts +0 -49
  443. package/src/routes/auth-forgot-password.ts +0 -77
  444. package/src/routes/auth-reset-password.ts +0 -96
  445. package/src/routes/auth-signin.ts +0 -55
  446. package/src/routes/auth-signout.ts +0 -64
  447. package/src/routes/auth-signup.ts +0 -164
  448. package/src/routes/auth-state.ts +0 -20
  449. package/src/routes/auth-update.ts +0 -149
  450. package/src/routes/auth-verify-email.ts +0 -75
  451. package/src/routes/auth.ts +0 -67
  452. package/src/routes/data-exists.ts +0 -31
  453. package/src/routes/data-export.ts +0 -51
  454. package/src/routes/data-get.ts +0 -67
  455. package/src/routes/data-import.ts +0 -56
  456. package/src/routes/data-index-create.ts +0 -82
  457. package/src/routes/data-index-delete.ts +0 -36
  458. package/src/routes/data-index-list.ts +0 -39
  459. package/src/routes/data-query.ts +0 -97
  460. package/src/routes/data-reflect.ts +0 -91
  461. package/src/routes/data-schema-get.ts +0 -36
  462. package/src/routes/data-schema-set.ts +0 -35
  463. package/src/routes/data-schema-test.ts +0 -48
  464. package/src/routes/data-schemas-list.ts +0 -31
  465. package/src/routes/data-set.ts +0 -83
  466. package/src/routes/data-sync-changes.ts +0 -77
  467. package/src/routes/data-sync-mutations.ts +0 -77
  468. package/src/routes/data-transaction.ts +0 -166
  469. package/src/routes/data-update.ts +0 -84
  470. package/src/routes/data.ts +0 -79
  471. package/src/routes/docs.ts +0 -249
  472. package/src/routes/meta-info.ts +0 -80
  473. package/src/routes/meta-logs.ts +0 -57
  474. package/src/routes/meta-ping.ts +0 -15
  475. package/src/routes/meta-stats.ts +0 -31
  476. package/src/routes/meta.ts +0 -22
  477. package/src/routes/oauth2-init.ts +0 -44
  478. package/src/routes/oauth2-refresh.ts +0 -39
  479. package/src/routes/oauth2-signin.ts +0 -286
  480. package/src/routes/webmanager.ts +0 -29
  481. package/src/rules.ts +0 -189
  482. package/src/schema/user.ts +0 -99
  483. package/src/server.ts +0 -419
  484. package/src/settings/email.ts +0 -18
  485. package/src/settings/index.ts +0 -241
  486. package/src/shared/clients.ts +0 -31
  487. package/src/shared/email.ts +0 -33
  488. package/src/shared/env.ts +0 -38
  489. package/src/shared/error.ts +0 -37
  490. package/src/shared/http.ts +0 -26
  491. package/src/shared/password.ts +0 -41
  492. package/src/shared/rootpath.ts +0 -17
  493. package/src/shared/signin.ts +0 -149
  494. package/src/shared/simple-fetch.ts +0 -65
  495. package/src/shared/tokens.ts +0 -77
  496. package/src/shared/validate.ts +0 -53
  497. package/src/start.ts +0 -48
  498. package/src/test.ts +0 -10
  499. package/src/websocket/index.ts +0 -336
  500. package/src/websocket/manager.ts +0 -46
  501. package/src/websocket/socket.io.ts +0 -90
  502. package/tsconfig-cjs.json +0 -11
  503. package/tsconfig.json +0 -22
package/src/server.ts DELETED
@@ -1,419 +0,0 @@
1
- import { ColorStyle, DebugLogger, SimpleEventEmitter, Api } from 'acebase-core';
2
- import { AceBaseServerSettings, AceBaseServerConfig } from './settings';
3
- import { createApp, HttpRequest, HttpResponse } from './shared/http';
4
- import { addWebsocketServer } from './websocket';
5
- import { RouteInitEnvironment } from './shared/env';
6
- import { ConnectedClient } from './shared/clients';
7
- import { AceBase, AceBaseLocalSettings, AceBaseStorageSettings } from 'acebase';
8
- import { createServer } from 'http';
9
- import { createServer as createSecureServer } from 'https';
10
- import { OAuth2Provider } from './oauth-providers/oauth-provider';
11
- import oAuth2Providers from './oauth-providers';
12
- import { PathBasedRules } from './rules';
13
- import { DbUserAccountDetails } from './schema/user';
14
- import addConnectionMiddleware from './middleware/connection';
15
- import addCorsMiddleware from './middleware/cors';
16
- import addAuthenticionRoutes from './routes/auth';
17
- import setupAuthentication from './auth';
18
- import addDataRoutes from './routes/data';
19
- import addDocsRoute from './routes/docs';
20
- import addWebManagerRoutes from './routes/webmanager';
21
- import addMetadataRoutes from './routes/meta';
22
- import add404Middleware from './middleware/404';
23
- import addSwaggerMiddleware from './middleware/swagger';
24
- import addCacheMiddleware from './middleware/cache';
25
- import { DatabaseLog } from './logger';
26
-
27
- type PrivateStorageSettings = AceBaseStorageSettings & { info?: string; type?: 'data'|'transaction'|'auth'|'log' };
28
- // type PrivateLocalSettings = AceBaseLocalSettings & { storage: PrivateStorageSettings };
29
-
30
- export class AceBaseServerNotReadyError extends Error {
31
- constructor() { super('Server is not ready yet'); }
32
- }
33
-
34
- type HttpMethod = 'get'|'GET'|'put'|'PUT'|'post'|'POST'|'delete'|'DELETE';
35
-
36
- export class AceBaseServer extends SimpleEventEmitter {
37
-
38
- private _ready: boolean = false;
39
- get isReady() { return this._ready; }
40
-
41
- /**
42
- * Wait for the server to be ready to accept incoming connections
43
- * @param callback (optional) callback function that is called when ready. You can also use the returned promise
44
- * @returns returns a promise that resolves when ready
45
- */
46
- async ready(callback?: () => any) {
47
- if (!this._ready) {
48
- await this.once('ready');
49
- }
50
- callback?.();
51
- }
52
-
53
- /**
54
- * Gets the active server configuration
55
- */
56
- readonly config: AceBaseServerConfig;
57
-
58
- /**
59
- * Gets the url the server is running at
60
- */
61
- get url() {
62
- return `http${this.config.https.enabled ? 's' : ''}://${this.config.host}:${this.config.port}`;
63
- }
64
-
65
- readonly debug: DebugLogger;
66
-
67
- /**
68
- * Gets direct access to the database, this bypasses any security rules and schema validators.
69
- * You can use this to add custom event handlers ("cloud functions") to your database directly.
70
- * NOTE: your code will run in the same thread as the server, make sure you are not performing
71
- * CPU heavy tasks here. If you have to do heavy weightlifting, create a seperate app that connects
72
- * to your server with an AceBaseClient, or execute in a worker thread.
73
- * @example
74
- * server.db.ref('uploads/images').on('child_added', async snap => {
75
- * const image = snap.val();
76
- * const resizedImages = await createImageSizes(image); // Some function that creates multiple image sizes in worker thread
77
- * const targetRef = await server.db.ref('images').push(resizedImages); // Store them somewhere else
78
- * await snap.ref.remove(); // Remove original upload
79
- * });
80
- */
81
- readonly db: AceBase;
82
-
83
- /**
84
- * Exposes the used http frameworks app (currently Express) for external use.
85
- */
86
- readonly app: ReturnType<typeof createApp>;
87
-
88
- private readonly authProviders: { [provider: string]: OAuth2Provider } = {};
89
-
90
- constructor(dbname: string, options?: AceBaseServerSettings) {
91
- super();
92
-
93
- this.config = new AceBaseServerConfig(options);
94
- this.debug = new DebugLogger(this.config.logLevel, `[${dbname}]`.colorize(ColorStyle.green));
95
-
96
- if (this.config.auth.enabled && !this.config.https.enabled) {
97
- this.debug.warn(`WARNING: Authentication is enabled, but the server is not using https. Any password and other data transmitted may be intercepted!`.colorize(ColorStyle.red));
98
- }
99
- else if (!this.config.https.enabled) {
100
- this.debug.warn(`WARNING: Server is not using https, any data transmitted may be intercepted!`.colorize(ColorStyle.red));
101
- }
102
- if (!this.config.auth.enabled) {
103
- this.debug.warn(`WARNING: Authentication is disabled, *anyone* can do *anything* with your data!`.colorize(ColorStyle.red));
104
- }
105
-
106
- // Open database(s)
107
- const dbOptions: Partial<AceBaseLocalSettings> = {
108
- logLevel: this.config.logLevel,
109
- info: 'realtime database server',
110
- // NEW: Allow storage setting like AceBaseLocalSettings - could allow using other db backend (typed, but undocumented)
111
- storage: this.config.storage || {
112
- path: this.config.path,
113
- removeVoidProperties: true,
114
- },
115
- transactions: this.config.transactions,
116
- ipc: this.config.ipc,
117
- };
118
- this.db = new AceBase(dbname, dbOptions);
119
-
120
- const otherDbsPath = `${this.config.path}/${this.db.name}.acebase`;
121
- const authDb = (() => {
122
- if (!this.config.auth.enabled) {
123
- return null;
124
- }
125
- switch (this.config.auth.separateDb) {
126
- case true: return new AceBase('auth', { logLevel: dbOptions.logLevel, storage: <PrivateStorageSettings>{ path: otherDbsPath, removeVoidProperties: true, info: `${dbname} auth database` } });
127
- case 'v2': /*NOT TESTED YET*/return new AceBase(dbname, { logLevel: dbOptions.logLevel, storage: <PrivateStorageSettings>{ type: 'auth', path: this.config.path, removeVoidProperties: true, info: `${dbname} auth database` } });
128
- default: return this.db;
129
- }
130
- })();
131
-
132
- // Create Express app
133
- this.app = createApp({ trustProxy: true, maxPayloadSize: this.config.maxPayloadSize });
134
-
135
- // Initialize and start server
136
- this.init({ authDb });
137
- }
138
-
139
- private async init(env: { authDb?: AceBase }) {
140
- const config = this.config;
141
- const db = this.db;
142
- const authDb = env.authDb;
143
-
144
- // Wait for databases to be ready to use
145
- await Promise.all([
146
- db.ready(),
147
- authDb?.ready()
148
- ]);
149
-
150
- // Create http server
151
- const app = this.app;
152
- const server = config.https.enabled ? createSecureServer(config.https, app) : createServer(app);
153
- const clients = new Map<string, ConnectedClient>();
154
-
155
- const securityRef = authDb ? authDb === db ? db.ref('__auth__/security') : authDb.ref('security') : null;
156
- const authRef = authDb ? authDb === db ? db.ref('__auth__/accounts') : authDb.ref('accounts') : null;
157
- const logRef = authDb ? authDb === db ? db.ref('__log__') : authDb.ref('log') : null;
158
- const logger = new DatabaseLog(logRef);
159
-
160
- // Setup rules
161
- const rulesFilePath = `${this.config.path}/${this.db.name}.acebase/rules.json`;
162
- const rules = new PathBasedRules(rulesFilePath, config.auth.defaultAccessRule, { db, debug: this.debug, authEnabled: this.config.auth.enabled });
163
-
164
- const routeEnv: RouteInitEnvironment = {
165
- config: this.config,
166
- server,
167
- db: db as AceBase & { api: Api },
168
- authDb,
169
- app,
170
- debug: this.debug,
171
- securityRef,
172
- authRef,
173
- log: logger,
174
- tokenSalt: null,
175
- clients,
176
- authCache: null,
177
- authProviders: this.authProviders,
178
- rules
179
- };
180
-
181
- // Add connection middleware
182
- const killConnections = addConnectionMiddleware(routeEnv);
183
-
184
- // Add CORS middleware
185
- addCorsMiddleware(routeEnv);
186
-
187
- // Add cache middleware
188
- addCacheMiddleware(routeEnv);
189
-
190
- if (config.auth.enabled) {
191
- // Setup auth database
192
- await setupAuthentication(routeEnv);
193
-
194
- // Add auth endpoints
195
- const { resetPassword, verifyEmailAddress } = addAuthenticionRoutes(routeEnv);
196
- this.resetPassword = resetPassword;
197
- this.verifyEmailAddress = verifyEmailAddress;
198
- }
199
-
200
- // Add metadata endpoints
201
- addMetadataRoutes(routeEnv);
202
-
203
- // If environment is development, add API docs
204
- if (process.env.NODE_ENV?.trim?.() === 'development') {
205
- this.debug.warn('DEVELOPMENT MODE: adding API docs endpoint at /docs');
206
- addDocsRoute(routeEnv);
207
- addSwaggerMiddleware(routeEnv);
208
- }
209
-
210
- // Add data endpoints
211
- addDataRoutes(routeEnv);
212
-
213
- // Add webmanager endpoints
214
- addWebManagerRoutes(routeEnv);
215
-
216
- // Allow adding custom routes
217
- this.extend = (method: HttpMethod, ext_path: string, handler: (req: HttpRequest, res: HttpResponse) => any) => {
218
- const route = `/ext/${db.name}/${ext_path}`;
219
- this.debug.log(`Extending server: `, method, route);
220
- routeEnv.app[method.toLowerCase()](route, handler);
221
- };
222
-
223
- // Create websocket server
224
- addWebsocketServer(routeEnv);
225
-
226
- // Last but not least, add 404 handler
227
- // DISABLED because it causes server extension routes through server.extend (see above) not be be executed
228
- // add404Middleware(routeEnv);
229
-
230
- // Start listening
231
- server.listen(config.port, config.host, () => {
232
- // Ready!!
233
- this.debug.log(`"${db.name}" database server running at ${this.url}`);
234
- this._ready = true;
235
- this.emitOnce(`ready`);
236
- });
237
-
238
- // Setup pause and resume methods
239
- let paused = false;
240
- this.pause = async () => {
241
- if (paused) { throw new Error('Server is already paused'); }
242
- server.close();
243
- this.debug.warn(`Paused "${db.name}" database server at ${this.url}`);
244
- this.emit('pause');
245
- paused = true;
246
- };
247
- this.resume = async () => {
248
- if (!paused) { throw new Error('Server is not paused'); }
249
- return new Promise(resolve => {
250
- server.listen(config.port, config.host, () => {
251
- this.debug.warn(`Resumed "${db.name}" database server at ${this.url}`);
252
- this.emit('resume');
253
- paused = false;
254
- resolve();
255
- });
256
- })
257
- };
258
-
259
- // Handle SIGINT and shutdown requests
260
- const shutdown = async (request: { sigint: boolean }) => {
261
- this.debug.warn('shutting down server');
262
- routeEnv.rules.stop();
263
-
264
- const getConnectionsCount = () => {
265
- return new Promise<number>((resolve, reject) => {
266
- server.getConnections((err, connections) => {
267
- if (err) { reject(err); }
268
- else { resolve(connections); }
269
- });
270
- });
271
- };
272
- const connections = await getConnectionsCount();
273
- this.debug.log(`Server has ${connections} connections`);
274
-
275
- await new Promise<void>((resolve) => {
276
- // const interval = setInterval(async () => {
277
- // const connections = await getConnectionsCount();
278
- // this.debug.log(`Server still has ${connections} connections`);
279
- // }, 5000);
280
- // interval.unref();
281
-
282
- server.close(err => {
283
- if (err) { console.error(`server.close() error: ${err.message}`); }
284
- else { console.log(`server.close() success`); }
285
- resolve();
286
- });
287
-
288
- // If for some reason connection aren't broken in time - do proceed with shutdown sequence
289
- const timeout = setTimeout(() => {
290
- console.warn(`server.close() timed out, there are still open connections`);
291
- killConnections();
292
- // resolve();
293
- }, 5000);
294
- timeout.unref();
295
-
296
- console.log(`Closing ${clients.size} websocket connections`);
297
- clients.forEach((client, id) => {
298
- const socket = client.socket;
299
- socket.once('disconnect', reason => {
300
- console.log(`Socket ${socket.id} disconnected: ${reason}`);
301
- })
302
- socket.disconnect(true);
303
- });
304
-
305
- // clients.list.slice().forEach(client => {
306
- // client.socket.disconnect(true);
307
- // });
308
- });
309
- this.debug.warn('closing database');
310
- await db.close();
311
- this.debug.warn('shutdown complete');
312
-
313
- // Emit events to let the outside world know we shut down.
314
- // This is especially important if this instance was running in a Node.js cluster: the process will
315
- // not exit automatically after this shutdown because Node.js' IPC channel between worker and master is still open.
316
- // By sending these events, the cluster manager can determine if it should (and when to) execute process.exit()
317
-
318
- // process.emit('acebase-server-shutdown'); // Emit on process
319
- process.emit('beforeExit', request.sigint ? 130 : 0); // Emit on process
320
- try {
321
- process.send && process.send('acebase-server-shutdown'); // Send to master process when running in a Node.js cluster
322
- }
323
- catch(err) {
324
- // IPC Channel has apparently been closed already
325
- }
326
- this.emit('shutdown'); // Emit on AceBaseServer instance
327
- };
328
- this.shutdown = async () => await shutdown({ sigint: false });
329
- process.on('SIGINT', () => shutdown({ sigint: true }));
330
- }
331
-
332
- /**
333
- * Reset a user's password. This can also be done using the auth/reset_password API endpoint
334
- * @param clientIp ip address of the user
335
- * @param code reset code that was sent to the user's email address
336
- * @param newPassword new password chosen by the user
337
- */
338
- resetPassword (clientIp: string, code: string, newPassword: string): Promise<DbUserAccountDetails> {
339
- throw new AceBaseServerNotReadyError();
340
- }
341
-
342
- /**
343
- * Marks a user account's email address as validated. This can also be done using the auth/verify_email API endpoint
344
- * @param clientIp ip address of the user
345
- * @param code verification code sent to the user's email address
346
- */
347
- verifyEmailAddress (clientIp: string, code: string): Promise<void> {
348
- throw new AceBaseServerNotReadyError();
349
- }
350
-
351
- /**
352
- * Shuts down the server. Stops listening for incoming connections, breaks current connections and closes the database.
353
- * Is automatically executed when a "SIGINT" process event is received.
354
- *
355
- * Once the shutdown procedure is completed, it emits a "shutdown" event on the server instance, "acebase-server-shutdown" event on the `process`, and sends an 'acebase-server-shutdown' IPC message if Node.js clustering is used.
356
- * These events can be handled by cluster managing code to `kill` or `exit` the process safely.
357
- */
358
- shutdown() {
359
- throw new AceBaseServerNotReadyError();
360
- }
361
-
362
- /**
363
- * Temporarily stops the server from handling incoming connections, but keeps existing connections open
364
- */
365
- pause(): Promise<void> {
366
- throw new AceBaseServerNotReadyError();
367
- }
368
-
369
- /**
370
- * Resumes handling incoming connections
371
- */
372
- resume(): Promise<void> {
373
- throw new AceBaseServerNotReadyError();
374
- }
375
-
376
- /**
377
- * Extend the server API with your own custom functions. Your handler will be listening
378
- * on path /ext/[db name]/[ext_path].
379
- * @example
380
- * // Server side:
381
- * const _quotes = [...];
382
- * server.extend('get', 'quotes/random', (req, res) => {
383
- * let index = Math.round(Math.random() * _quotes.length);
384
- * res.send(quotes[index]);
385
- * })
386
- * // Client side:
387
- * client.callExtension('get', 'quotes/random')
388
- * .then(quote => {
389
- * console.log(`Got random quote: ${quote}`);
390
- * })
391
- * @param method http method to bind to
392
- * @param ext_path path to bind to (appended to /ext/)
393
- * @param handler your Express request handler callback
394
- */
395
- extend(method: HttpMethod, ext_path: string, handler: (req: HttpRequest, res: HttpResponse) => void) {
396
- throw new AceBaseServerNotReadyError();
397
- }
398
-
399
- /**
400
- * Configure an auth provider to allow users to sign in with Facebook, Google, etc
401
- * @param providerName name of the third party OAuth provider. Eg: "Facebook", "Google", "spotify" etc
402
- * @param settings API key & secret for the OAuth provider
403
- * @returns Returns the created auth provider instance, which can be used to call non-user specific methods the provider might support. (example: the Spotify auth provider supports getClientAuthToken, which allows API calls to be made to the core (non-user) spotify service)
404
- */
405
- configAuthProvider(providerName: string, settings: any) {
406
- if (!this.config.auth.enabled) {
407
- throw new Error(`Authentication is not enabled`);
408
- }
409
- try {
410
- const AuthProvider = oAuth2Providers[providerName];
411
- const provider = new AuthProvider(settings);
412
- this.authProviders[providerName] = provider;
413
- return provider;
414
- }
415
- catch(err) {
416
- throw new Error(`Failed to configure provider ${providerName}: ${err.message}`)
417
- }
418
- }
419
- }
@@ -1,18 +0,0 @@
1
- import { AceBaseEmailRequest } from '../shared/email';
2
-
3
- export interface AceBaseServerEmailServerSettings {
4
- host: string;
5
- port: number;
6
- username?: string;
7
- password?: string;
8
- secure: boolean;
9
- };
10
-
11
- export interface AceBaseServerEmailSettings {
12
-
13
- /** NOT IMPLEMENTED YET - Use send property for your own implementation */
14
- server?: AceBaseServerEmailServerSettings;
15
-
16
- /** function to call when an e-mail needs to be sent */
17
- send: (request: AceBaseEmailRequest) => Promise<void>;
18
- };
@@ -1,241 +0,0 @@
1
- import { AceBaseStorageSettings } from 'acebase';
2
- import { readFileSync } from 'fs';
3
- import { AceBaseServerEmailSettings } from './email';
4
-
5
- export type AceBaseServerHttpsSettings = {
6
- enabled?: boolean;
7
- keyPath?: string;
8
- certPath?: string
9
- pfxPath?: string;
10
- passphrase?: string
11
- } & (
12
- { keyPath: string; certPath: string } |
13
- { pfxPath: string; passphrase: string } |
14
- {}
15
- )
16
-
17
- export class AceBaseServerHttpsConfig {
18
- enabled: boolean = true;
19
- key?: Buffer;
20
- cert?: Buffer;
21
- pfx?: Buffer;
22
- passphrase?: string;
23
-
24
- constructor(settings: AceBaseServerHttpsSettings) {
25
- this.enabled = typeof settings === "object" && settings.enabled !== false;
26
- if (!this.enabled) { return; }
27
- if (settings.keyPath) {
28
- this.key = readFileSync(settings.keyPath);
29
- this.cert = readFileSync(settings.certPath);
30
- }
31
- else if (settings.pfxPath) {
32
- this.pfx = readFileSync(settings.pfxPath);
33
- this.passphrase = settings.passphrase;
34
- }
35
- }
36
- }
37
-
38
- export type AuthAccessDefault = 'deny'|'allow'|'auth';
39
- export const AUTH_ACCESS_DEFAULT: { [key: string]: AuthAccessDefault } = {
40
- DENY_ALL: 'deny',
41
- ALLOW_ALL: 'allow',
42
- ALLOW_AUTHENTICATED: 'auth'
43
- };
44
-
45
- export class AceBaseServerAuthenticationSettings {
46
-
47
- /**
48
- * Whether to enable authorization. Without authorization the entire db can be read and written to by anyone (not recommended 🤷🏼‍♂️)
49
- */
50
- readonly enabled: boolean = true;
51
-
52
- /**
53
- * Whether new users creation is allowed for anyone, or just the admin
54
- */
55
- readonly allowUserSignup: boolean = false;
56
-
57
- /**
58
- * How many new users can sign up per hour per IP address. not implemented yet
59
- */
60
- readonly newUserRateLimit: number = 0;
61
-
62
- /**
63
- * How many minutes before access tokens expire. 0 for no expiration. (not implemented yet)
64
- */
65
- readonly tokensExpire: number = 0;
66
-
67
- /**
68
- * When the server runs for the first time, what defaults to use to generate the rules.json file with. Options are: 'auth' (only authenticated access to db, default), 'deny' (deny access to anyone except admin user), 'allow' (allow access to anyone)
69
- */
70
- readonly defaultAccessRule: AuthAccessDefault = AUTH_ACCESS_DEFAULT.ALLOW_AUTHENTICATED;
71
-
72
- /**
73
- * When the server runs for the first time, what password to use for the admin user. If not supplied, a generated password will be used and shown ONCE in the console output.
74
- */
75
- readonly defaultAdminPassword?: string;
76
-
77
- /**
78
- * Whether to use a separate database for auth and logging. 'v2' will store data in auth.db, which is NOT TESTED YET!
79
- */
80
- readonly separateDb: boolean|'v2' = false;
81
-
82
- constructor(settings: Partial<AceBaseServerAuthenticationSettings>) {
83
- if (typeof settings !== "object") { settings = {}; }
84
- if (typeof settings.enabled === 'boolean') { this.enabled = settings.enabled; }
85
- if (typeof settings.allowUserSignup === 'boolean') { this.allowUserSignup = settings.allowUserSignup; }
86
- if (typeof settings.newUserRateLimit === 'number') { this.newUserRateLimit = settings.newUserRateLimit; }
87
- if (typeof settings.tokensExpire === 'number') { this.tokensExpire = settings.tokensExpire; }
88
- if (typeof settings.defaultAccessRule === 'string') { this.defaultAccessRule = settings.defaultAccessRule; }
89
- if (typeof settings.defaultAdminPassword === 'string') { this.defaultAdminPassword = settings.defaultAdminPassword; }
90
- if (typeof (settings as any).seperateDb === 'boolean') { this.separateDb = (settings as any).seperateDb; } // Handle previous _wrong_ spelling
91
- if (typeof settings.separateDb === 'boolean') { this.separateDb = settings.separateDb; }
92
- }
93
- }
94
-
95
- /**
96
- * TODO: Use AceBaseTransactionLogSettings from acebase
97
- */
98
- export class AceBaseServerTransactionSettings {
99
- /**
100
- * Whether to enable transaction logging
101
- */
102
- log: boolean = false;
103
-
104
- /**
105
- * Max age in days to keep transactions in the log file
106
- */
107
- maxAge: number = 30;
108
-
109
- /**
110
- * Whether database write operations should not wait until transaction has been logged
111
- */
112
- noWait: boolean = false;
113
-
114
- constructor(settings: Partial<AceBaseServerTransactionSettings>) {
115
- if (typeof settings !== 'object') { return; }
116
- if (typeof settings.log === 'boolean') { this.log = settings.log; }
117
- if (typeof settings.maxAge === 'number') { this.maxAge = settings.maxAge; }
118
- if (typeof settings.noWait === 'boolean') { this.noWait = settings.noWait; }
119
- }
120
- }
121
-
122
- export interface IPCClientSettings {
123
- /**
124
- * IPC Server host to connect to. Default is `"localhost"`
125
- */
126
- host?: string;
127
-
128
- /**
129
- * IPC Server port number
130
- */
131
- port: number;
132
-
133
- /**
134
- * Whether to use a secure connection to the server. Strongly recommended if `host` is not `"localhost"`. Default is `false`
135
- */
136
- ssl?: boolean;
137
-
138
- /**
139
- * Token used in the IPC Server configuration (optional). The server will refuse connections using the wrong token.
140
- */
141
- token?: string;
142
-
143
- /**
144
- * Determines the role of this IPC client. Only 1 process can be assigned the 'master' role, all other processes must use the role 'worker'
145
- */
146
- role: 'master'|'worker';
147
- }
148
-
149
- export type AceBaseServerSettings = Partial<{
150
- /**
151
- * Level of messages logged to console
152
- */
153
- logLevel: 'verbose'|'log'|'warn'|'error';
154
-
155
- /**
156
- * ip or hostname to start the server on
157
- */
158
- host: string;
159
-
160
- /**
161
- * port number the server will be listening
162
- */
163
- port: number;
164
-
165
- /**
166
- * target directory path to store/open the database. Default is '.'
167
- */
168
- path: string;
169
-
170
- /**
171
- * Whether to use secure sockets layer (ssl)
172
- */
173
- https: AceBaseServerHttpsSettings;
174
-
175
- /**
176
- * settings that define if and how authentication is used
177
- */
178
- authentication: Partial<AceBaseServerAuthenticationSettings>;
179
-
180
- /**
181
- * maximum size to allow for posted data, eg for updating nodes. Default is '10mb'
182
- */
183
- maxPayloadSize: string;
184
-
185
- /**
186
- * Value to use for Access-Control-Allow-Origin CORS header. Default is '*'
187
- */
188
- allowOrigin: string;
189
-
190
- /**
191
- * Email settings that enable AceBaseServer to send e-mails, eg for welcoming new users, to reset passwords, notify of new sign ins etc
192
- */
193
- email: AceBaseServerEmailSettings;
194
-
195
- /**
196
- * Transaction logging settings. Warning: BETA stage, do NOT use in production yet
197
- */
198
- transactions: Partial<AceBaseServerTransactionSettings>;
199
-
200
- /**
201
- * IPC settings for pm2 or cloud-based clusters. BETA stage, see https://github.com/appy-one/acebase-ipc-server
202
- */
203
- ipc: IPCClientSettings;
204
-
205
- /**
206
- * Allows overriding of default storage settings used by the database. ALPHA stage
207
- */
208
- storage: AceBaseStorageSettings;
209
- }>
210
-
211
- export class AceBaseServerConfig {
212
-
213
- readonly logLevel: 'verbose'|'log'|'warn'|'error' = 'log';
214
- readonly host: string = 'localhost';
215
- readonly port: number = 3000;
216
- readonly path: string = '.';
217
- readonly maxPayloadSize: string = '10mb';
218
- readonly allowOrigin: string = '*';
219
- readonly https: AceBaseServerHttpsConfig;
220
- readonly auth: AceBaseServerAuthenticationSettings;
221
- readonly email: AceBaseServerEmailSettings;
222
- readonly transactions: AceBaseServerTransactionSettings;
223
- readonly ipc: IPCClientSettings;
224
- readonly storage?: AceBaseStorageSettings;
225
-
226
- constructor(settings: AceBaseServerSettings) {
227
- if (typeof settings !== "object") { settings = {}; }
228
- if (typeof settings.logLevel === 'string') { this.logLevel = settings.logLevel; }
229
- if (typeof settings.host === 'string') { this.host = settings.host; }
230
- if (typeof settings.port === 'number') { this.port = settings.port; }
231
- if (typeof settings.path === 'string') { this.path = settings.path; }
232
- this.https = new AceBaseServerHttpsConfig(settings.https);
233
- this.auth = new AceBaseServerAuthenticationSettings(settings.authentication);
234
- if (typeof settings.maxPayloadSize === 'string') { this.maxPayloadSize = settings.maxPayloadSize; }
235
- if (typeof settings.allowOrigin === 'string') { this.allowOrigin = settings.allowOrigin; }
236
- if (typeof settings.email === 'object') { this.email = settings.email; }
237
- this.transactions = new AceBaseServerTransactionSettings(settings.transactions);
238
- this.ipc = settings.ipc;
239
- if (typeof settings.storage === 'object') { this.storage = settings.storage; }
240
- }
241
- }