acebase-server 1.16.2 → 1.17.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 (250) hide show
  1. package/README.md +180 -10
  2. package/build-vars.js +2 -1
  3. package/dist/cjs/auth.js +88 -88
  4. package/dist/cjs/cluster.js +56 -56
  5. package/dist/cjs/index.d.ts +1 -1
  6. package/dist/cjs/index.js +24 -24
  7. package/dist/cjs/logger.js +73 -73
  8. package/dist/cjs/middleware/404.js +14 -14
  9. package/dist/cjs/middleware/admin-only.js +28 -28
  10. package/dist/cjs/middleware/cache.js +14 -14
  11. package/dist/cjs/middleware/connection.js +49 -49
  12. package/dist/cjs/middleware/context.js +20 -20
  13. package/dist/cjs/middleware/cors.js +50 -50
  14. package/dist/cjs/middleware/swagger.js +17 -17
  15. package/dist/cjs/middleware/user.js +57 -57
  16. package/dist/cjs/oauth-providers/dropbox.js +109 -109
  17. package/dist/cjs/oauth-providers/facebook.js +85 -85
  18. package/dist/cjs/oauth-providers/google.js +119 -119
  19. package/dist/cjs/oauth-providers/index.js +26 -26
  20. package/dist/cjs/oauth-providers/instagram.js +80 -80
  21. package/dist/cjs/oauth-providers/oauth-provider.js +20 -20
  22. package/dist/cjs/oauth-providers/spotify.js +113 -113
  23. package/dist/cjs/routes/auth-change-password.js +87 -87
  24. package/dist/cjs/routes/auth-delete.js +52 -52
  25. package/dist/cjs/routes/auth-forgot-password.js +77 -77
  26. package/dist/cjs/routes/auth-reset-password.js +97 -97
  27. package/dist/cjs/routes/auth-signin.js +46 -46
  28. package/dist/cjs/routes/auth-signout.js +61 -61
  29. package/dist/cjs/routes/auth-signup.js +142 -142
  30. package/dist/cjs/routes/auth-state.js +25 -25
  31. package/dist/cjs/routes/auth-update.js +131 -131
  32. package/dist/cjs/routes/auth-verify-email.js +71 -71
  33. package/dist/cjs/routes/auth.js +57 -54
  34. package/dist/cjs/routes/data-exists.js +33 -33
  35. package/dist/cjs/routes/data-export.js +48 -48
  36. package/dist/cjs/routes/data-get.js +70 -66
  37. package/dist/cjs/routes/data-import.js +54 -54
  38. package/dist/cjs/routes/data-index-create.js +42 -42
  39. package/dist/cjs/routes/data-index-delete.js +33 -33
  40. package/dist/cjs/routes/data-index-list.js +31 -31
  41. package/dist/cjs/routes/data-query.js +80 -70
  42. package/dist/cjs/routes/data-reflect.js +97 -86
  43. package/dist/cjs/routes/data-schema-get.js +36 -36
  44. package/dist/cjs/routes/data-schema-set.js +30 -30
  45. package/dist/cjs/routes/data-schema-test.js +43 -43
  46. package/dist/cjs/routes/data-schemas-list.js +32 -32
  47. package/dist/cjs/routes/data-set.js +85 -75
  48. package/dist/cjs/routes/data-sync-changes.js +81 -67
  49. package/dist/cjs/routes/data-sync-mutations.js +81 -67
  50. package/dist/cjs/routes/data-transaction.js +159 -139
  51. package/dist/cjs/routes/data-update.js +86 -75
  52. package/dist/cjs/routes/data.js +62 -62
  53. package/dist/cjs/routes/docs.js +258 -251
  54. package/dist/cjs/routes/meta-info.js +63 -63
  55. package/dist/cjs/routes/meta-logs.js +49 -49
  56. package/dist/cjs/routes/meta-ping.js +11 -11
  57. package/dist/cjs/routes/meta-stats.js +27 -27
  58. package/dist/cjs/routes/meta.js +19 -19
  59. package/dist/cjs/routes/oauth2-init.js +54 -54
  60. package/dist/cjs/routes/oauth2-refresh.js +42 -42
  61. package/dist/cjs/routes/oauth2-signin.js +265 -265
  62. package/dist/cjs/routes/webmanager.js +26 -26
  63. package/dist/cjs/rules.js +380 -167
  64. package/dist/cjs/sandbox.js +28 -0
  65. package/dist/cjs/schema/user.js +24 -24
  66. package/dist/cjs/server.js +415 -407
  67. package/dist/cjs/settings/email.js +2 -2
  68. package/dist/cjs/settings/index.js +175 -172
  69. package/dist/cjs/shared/clients.js +26 -26
  70. package/dist/cjs/shared/email.js +2 -2
  71. package/dist/cjs/shared/env.js +2 -2
  72. package/dist/cjs/shared/error.js +33 -33
  73. package/dist/cjs/shared/http.js +28 -28
  74. package/dist/cjs/shared/password.js +45 -45
  75. package/dist/cjs/shared/rootpath.js +16 -16
  76. package/dist/cjs/shared/signin.js +143 -143
  77. package/dist/cjs/shared/simple-fetch.js +76 -76
  78. package/dist/cjs/shared/tokens.js +79 -79
  79. package/dist/cjs/shared/validate.js +61 -61
  80. package/dist/cjs/start.js +53 -53
  81. package/dist/cjs/test.js +10 -10
  82. package/dist/cjs/websocket/index.js +331 -319
  83. package/dist/cjs/websocket/manager.js +15 -15
  84. package/dist/cjs/websocket/socket.io.js +76 -76
  85. package/dist/esm/auth.js +75 -75
  86. package/dist/esm/cluster.js +54 -54
  87. package/dist/esm/index.d.ts +1 -1
  88. package/dist/esm/index.js +4 -4
  89. package/dist/esm/logger.js +51 -51
  90. package/dist/esm/middleware/404.js +10 -10
  91. package/dist/esm/middleware/admin-only.js +24 -24
  92. package/dist/esm/middleware/cache.js +10 -10
  93. package/dist/esm/middleware/connection.js +45 -45
  94. package/dist/esm/middleware/context.js +16 -16
  95. package/dist/esm/middleware/cors.js +44 -44
  96. package/dist/esm/middleware/swagger.js +13 -13
  97. package/dist/esm/middleware/user.js +44 -44
  98. package/dist/esm/oauth-providers/dropbox.js +90 -90
  99. package/dist/esm/oauth-providers/facebook.js +66 -66
  100. package/dist/esm/oauth-providers/google.js +96 -96
  101. package/dist/esm/oauth-providers/index.js +18 -18
  102. package/dist/esm/oauth-providers/instagram.js +61 -61
  103. package/dist/esm/oauth-providers/oauth-provider.js +16 -16
  104. package/dist/esm/oauth-providers/spotify.js +92 -92
  105. package/dist/esm/routes/auth-change-password.js +72 -72
  106. package/dist/esm/routes/auth-delete.js +37 -37
  107. package/dist/esm/routes/auth-forgot-password.js +62 -62
  108. package/dist/esm/routes/auth-reset-password.js +81 -81
  109. package/dist/esm/routes/auth-signin.js +33 -33
  110. package/dist/esm/routes/auth-signout.js +47 -47
  111. package/dist/esm/routes/auth-signup.js +127 -127
  112. package/dist/esm/routes/auth-state.js +12 -12
  113. package/dist/esm/routes/auth-update.js +116 -116
  114. package/dist/esm/routes/auth-verify-email.js +57 -57
  115. package/dist/esm/routes/auth.js +53 -50
  116. package/dist/esm/routes/data-exists.js +20 -20
  117. package/dist/esm/routes/data-export.js +35 -35
  118. package/dist/esm/routes/data-get.js +56 -52
  119. package/dist/esm/routes/data-import.js +41 -41
  120. package/dist/esm/routes/data-index-create.js +28 -28
  121. package/dist/esm/routes/data-index-delete.js +20 -20
  122. package/dist/esm/routes/data-index-list.js +18 -18
  123. package/dist/esm/routes/data-query.js +66 -56
  124. package/dist/esm/routes/data-reflect.js +83 -72
  125. package/dist/esm/routes/data-schema-get.js +23 -23
  126. package/dist/esm/routes/data-schema-set.js +17 -17
  127. package/dist/esm/routes/data-schema-test.js +29 -29
  128. package/dist/esm/routes/data-schemas-list.js +19 -19
  129. package/dist/esm/routes/data-set.js +70 -60
  130. package/dist/esm/routes/data-sync-changes.js +67 -53
  131. package/dist/esm/routes/data-sync-mutations.js +67 -53
  132. package/dist/esm/routes/data-transaction.js +142 -123
  133. package/dist/esm/routes/data-update.js +71 -60
  134. package/dist/esm/routes/data.js +58 -58
  135. package/dist/esm/routes/docs.js +252 -245
  136. package/dist/esm/routes/meta-info.js +59 -59
  137. package/dist/esm/routes/meta-logs.js +35 -35
  138. package/dist/esm/routes/meta-ping.js +7 -7
  139. package/dist/esm/routes/meta-stats.js +14 -14
  140. package/dist/esm/routes/meta.js +15 -15
  141. package/dist/esm/routes/oauth2-init.js +41 -41
  142. package/dist/esm/routes/oauth2-refresh.js +29 -29
  143. package/dist/esm/routes/oauth2-signin.js +251 -251
  144. package/dist/esm/routes/webmanager.js +22 -22
  145. package/dist/esm/rules.js +374 -163
  146. package/dist/esm/sandbox.js +12 -0
  147. package/dist/esm/schema/user.js +19 -19
  148. package/dist/esm/server.js +395 -387
  149. package/dist/esm/settings/email.js +1 -1
  150. package/dist/esm/settings/index.js +168 -165
  151. package/dist/esm/shared/clients.js +22 -22
  152. package/dist/esm/shared/email.js +1 -1
  153. package/dist/esm/shared/env.js +1 -1
  154. package/dist/esm/shared/error.js +25 -25
  155. package/dist/esm/shared/http.js +22 -22
  156. package/dist/esm/shared/password.js +38 -38
  157. package/dist/esm/shared/rootpath.js +13 -13
  158. package/dist/esm/shared/signin.js +128 -128
  159. package/dist/esm/shared/simple-fetch.js +59 -59
  160. package/dist/esm/shared/tokens.js +72 -72
  161. package/dist/esm/shared/validate.js +41 -41
  162. package/dist/esm/start.js +50 -50
  163. package/dist/esm/test.js +8 -8
  164. package/dist/esm/websocket/index.js +313 -302
  165. package/dist/esm/websocket/manager.js +11 -11
  166. package/dist/esm/websocket/socket.io.js +71 -71
  167. package/dist/types/auth.d.ts +3 -3
  168. package/dist/types/cluster.d.ts +1 -1
  169. package/dist/types/index.d.ts +4 -4
  170. package/dist/types/logger.d.ts +35 -35
  171. package/dist/types/middleware/404.d.ts +7 -7
  172. package/dist/types/middleware/admin-only.d.ts +19 -19
  173. package/dist/types/middleware/cache.d.ts +3 -3
  174. package/dist/types/middleware/connection.d.ts +7 -7
  175. package/dist/types/middleware/context.d.ts +3 -3
  176. package/dist/types/middleware/cors.d.ts +25 -25
  177. package/dist/types/middleware/swagger.d.ts +3 -3
  178. package/dist/types/middleware/user.d.ts +2 -2
  179. package/dist/types/oauth-providers/dropbox.d.ts +52 -52
  180. package/dist/types/oauth-providers/facebook.d.ts +41 -41
  181. package/dist/types/oauth-providers/google.d.ts +43 -43
  182. package/dist/types/oauth-providers/index.d.ts +10 -10
  183. package/dist/types/oauth-providers/instagram.d.ts +50 -50
  184. package/dist/types/oauth-providers/oauth-provider.d.ts +74 -74
  185. package/dist/types/oauth-providers/spotify.d.ts +53 -53
  186. package/dist/types/routes/auth-change-password.d.ts +20 -20
  187. package/dist/types/routes/auth-delete.d.ts +16 -16
  188. package/dist/types/routes/auth-forgot-password.d.ts +16 -16
  189. package/dist/types/routes/auth-reset-password.d.ts +23 -23
  190. package/dist/types/routes/auth-signin.d.ts +24 -24
  191. package/dist/types/routes/auth-signout.d.ts +14 -14
  192. package/dist/types/routes/auth-signup.d.ts +32 -32
  193. package/dist/types/routes/auth-state.d.ts +13 -13
  194. package/dist/types/routes/auth-update.d.ts +33 -33
  195. package/dist/types/routes/auth-verify-email.d.ts +21 -21
  196. package/dist/types/routes/auth.d.ts +6 -6
  197. package/dist/types/routes/data-exists.d.ts +9 -9
  198. package/dist/types/routes/data-export.d.ts +10 -10
  199. package/dist/types/routes/data-get.d.ts +14 -14
  200. package/dist/types/routes/data-import.d.ts +13 -13
  201. package/dist/types/routes/data-index-create.d.ts +51 -51
  202. package/dist/types/routes/data-index-delete.d.ts +17 -17
  203. package/dist/types/routes/data-index-list.d.ts +21 -21
  204. package/dist/types/routes/data-query.d.ts +49 -49
  205. package/dist/types/routes/data-reflect.d.ts +29 -29
  206. package/dist/types/routes/data-schema-get.d.ts +11 -11
  207. package/dist/types/routes/data-schema-set.d.ts +19 -19
  208. package/dist/types/routes/data-schema-test.d.ts +19 -19
  209. package/dist/types/routes/data-schemas-list.d.ts +11 -11
  210. package/dist/types/routes/data-set.d.ts +27 -27
  211. package/dist/types/routes/data-sync-changes.d.ts +25 -28
  212. package/dist/types/routes/data-sync-mutations.d.ts +25 -28
  213. package/dist/types/routes/data-transaction.d.ts +34 -34
  214. package/dist/types/routes/data-update.d.ts +27 -27
  215. package/dist/types/routes/data.d.ts +3 -3
  216. package/dist/types/routes/docs.d.ts +3 -3
  217. package/dist/types/routes/meta-info.d.ts +11 -11
  218. package/dist/types/routes/meta-logs.d.ts +20 -20
  219. package/dist/types/routes/meta-ping.d.ts +7 -7
  220. package/dist/types/routes/meta-stats.d.ts +13 -13
  221. package/dist/types/routes/meta.d.ts +3 -3
  222. package/dist/types/routes/oauth2-init.d.ts +13 -13
  223. package/dist/types/routes/oauth2-refresh.d.ts +17 -17
  224. package/dist/types/routes/oauth2-signin.d.ts +15 -15
  225. package/dist/types/routes/webmanager.d.ts +3 -3
  226. package/dist/types/rules.d.ts +73 -34
  227. package/dist/types/sandbox.d.ts +3 -0
  228. package/dist/types/schema/user.d.ts +85 -85
  229. package/dist/types/server.d.ts +117 -111
  230. package/dist/types/settings/email.d.ts +14 -14
  231. package/dist/types/settings/index.d.ts +195 -187
  232. package/dist/types/shared/clients.d.ts +46 -46
  233. package/dist/types/shared/email.d.ts +34 -34
  234. package/dist/types/shared/env.d.ts +47 -44
  235. package/dist/types/shared/error.d.ts +15 -15
  236. package/dist/types/shared/http.d.ts +22 -21
  237. package/dist/types/shared/password.d.ts +19 -19
  238. package/dist/types/shared/rootpath.d.ts +2 -2
  239. package/dist/types/shared/signin.d.ts +31 -31
  240. package/dist/types/shared/simple-fetch.d.ts +21 -21
  241. package/dist/types/shared/tokens.d.ts +24 -24
  242. package/dist/types/shared/validate.d.ts +22 -22
  243. package/dist/types/start.d.ts +1 -1
  244. package/dist/types/test.d.ts +1 -1
  245. package/dist/types/websocket/index.d.ts +6 -6
  246. package/dist/types/websocket/manager.d.ts +99 -99
  247. package/dist/types/websocket/socket.io.d.ts +10 -10
  248. package/package.json +4 -4
  249. package/src/routes/data-set.yaml +5 -5
  250. package/src/routes/data-update.yaml +4 -4
@@ -1,16 +1,16 @@
1
- import { Response } from './http';
2
- export declare const sendNotAuthenticatedError: (res: Response, code: string, message: string) => void;
3
- export declare const sendUnauthorizedError: (res: Response, code: string, message: string) => void;
4
- interface ErrorLike {
5
- code?: string;
6
- message: string;
7
- stack?: string;
8
- }
9
- export declare const sendError: (res: Response, err: ErrorLike) => void;
10
- export declare const sendBadRequestError: (res: Response, err: {
11
- code: string;
12
- message: string;
13
- }) => void;
14
- export declare const sendUnexpectedError: (res: Response, err: Error) => void;
15
- export {};
1
+ import { Response } from './http';
2
+ export declare const sendNotAuthenticatedError: (res: Response, code: string, message: string) => void;
3
+ export declare const sendUnauthorizedError: (res: Response, code: string, message: string) => void;
4
+ interface ErrorLike {
5
+ code?: string;
6
+ message: string;
7
+ stack?: string;
8
+ }
9
+ export declare const sendError: (res: Response, err: ErrorLike) => void;
10
+ export declare const sendBadRequestError: (res: Response, err: {
11
+ code: string;
12
+ message: string;
13
+ }) => void;
14
+ export declare const sendUnexpectedError: (res: Response, err: Error) => void;
15
+ export {};
16
16
  //# sourceMappingURL=error.d.ts.map
@@ -1,22 +1,23 @@
1
- import type { Socket } from 'socket.io';
2
- export type { Express, Request, Response } from 'express';
3
- import * as express from 'express';
4
- export declare type HttpApp = express.Express;
5
- export declare type HttpSocket = Socket;
6
- export declare type HttpRequest = express.Request;
7
- export declare type HttpResponse = express.Response;
8
- /**
9
- * Creates an app that handles http requests, adds json body parsing.
10
- * @param settings
11
- * @returns
12
- */
13
- export declare const createApp: (settings: {
14
- trustProxy: boolean;
15
- maxPayloadSize: string;
16
- }) => express.Express;
17
- /**
18
- * Creates an express router
19
- * @returns
20
- */
21
- export declare const createRouter: () => any;
1
+ import type { Socket } from 'socket.io';
2
+ export type { Express, Request, Response } from 'express';
3
+ import * as express from 'express';
4
+ export type HttpApp = express.Express;
5
+ export type HttpRouter = express.Router;
6
+ export type HttpSocket = Socket;
7
+ export type HttpRequest = express.Request;
8
+ export type HttpResponse = express.Response;
9
+ /**
10
+ * Creates an app that handles http requests, adds json body parsing.
11
+ * @param settings
12
+ * @returns
13
+ */
14
+ export declare const createApp: (settings: {
15
+ trustProxy: boolean;
16
+ maxPayloadSize: string;
17
+ }) => express.Express;
18
+ /**
19
+ * Creates an express router
20
+ * @returns
21
+ */
22
+ export declare const createRouter: () => express.Router;
22
23
  //# sourceMappingURL=http.d.ts.map
@@ -1,20 +1,20 @@
1
- export declare const generatePassword: () => any;
2
- /**
3
- * Generates a random salt and hashes the provided password with it. The resulting salt and hash should be stored in the database
4
- * @param password password to hash
5
- */
6
- export declare const createPasswordHash: (password: string) => {
7
- salt: string;
8
- hash: string;
9
- };
10
- /**
11
- * For checking passwords: uses given password and salt to get the hash that can be compared to a stored version.
12
- * @param password A password prodived by the user trying to sign in
13
- * @param salt the salt used to generate the hash, must be stored with the hash in the database
14
- */
15
- export declare const getPasswordHash: (password: string, salt: string) => string;
16
- /**
17
- * Backward compatibility with old saltless md5 passwords. Becomes obsolete once all passwords have been updated (probably already so)
18
- */
19
- export declare const getOldPasswordHash: (password: string) => string;
1
+ export declare const generatePassword: () => any;
2
+ /**
3
+ * Generates a random salt and hashes the provided password with it. The resulting salt and hash should be stored in the database
4
+ * @param password password to hash
5
+ */
6
+ export declare const createPasswordHash: (password: string) => {
7
+ salt: string;
8
+ hash: string;
9
+ };
10
+ /**
11
+ * For checking passwords: uses given password and salt to get the hash that can be compared to a stored version.
12
+ * @param password A password prodived by the user trying to sign in
13
+ * @param salt the salt used to generate the hash, must be stored with the hash in the database
14
+ */
15
+ export declare const getPasswordHash: (password: string, salt: string) => string;
16
+ /**
17
+ * Backward compatibility with old saltless md5 passwords. Becomes obsolete once all passwords have been updated (probably already so)
18
+ */
19
+ export declare const getOldPasswordHash: (password: string) => string;
20
20
  //# sourceMappingURL=password.d.ts.map
@@ -1,3 +1,3 @@
1
- export declare const packageRootPath: string;
2
- export default packageRootPath;
1
+ export declare const packageRootPath: string;
2
+ export default packageRootPath;
3
3
  //# sourceMappingURL=rootpath.d.ts.map
@@ -1,32 +1,32 @@
1
- import { DbUserAccountDetails } from '../schema/user';
2
- import { RouteInitEnvironment, RouteRequest } from './env';
3
- export declare type SignInCredentials = {
4
- method: 'token';
5
- access_token: string;
6
- } | {
7
- method: 'internal';
8
- access_token: string;
9
- } | {
10
- method: 'email';
11
- email: string;
12
- password: string;
13
- } | {
14
- method: 'account';
15
- username: string;
16
- password: string;
17
- };
18
- export declare class SignInError extends Error {
19
- code: string;
20
- details: any;
21
- constructor(code: string, message: string, details?: any);
22
- }
23
- /**
24
- * Signs in a user and logs the request. If successful, adds the user to authCache, binds the user to the http request and returns the user details.
25
- * Throws a `SignInError` if sign in fails for a known reason.
26
- * @param credentials credentials to sign in the user with
27
- * @param env environment state
28
- * @param req current http request
29
- * @returns
30
- */
31
- export declare const signIn: (credentials: SignInCredentials, env: RouteInitEnvironment, req: RouteRequest) => Promise<DbUserAccountDetails>;
1
+ import { DbUserAccountDetails } from '../schema/user';
2
+ import { RouteInitEnvironment, RouteRequest } from './env';
3
+ export type SignInCredentials = {
4
+ method: 'token';
5
+ access_token: string;
6
+ } | {
7
+ method: 'internal';
8
+ access_token: string;
9
+ } | {
10
+ method: 'email';
11
+ email: string;
12
+ password: string;
13
+ } | {
14
+ method: 'account';
15
+ username: string;
16
+ password: string;
17
+ };
18
+ export declare class SignInError extends Error {
19
+ code: string;
20
+ details: any;
21
+ constructor(code: string, message: string, details?: any);
22
+ }
23
+ /**
24
+ * Signs in a user and logs the request. If successful, adds the user to authCache, binds the user to the http request and returns the user details.
25
+ * Throws a `SignInError` if sign in fails for a known reason.
26
+ * @param credentials credentials to sign in the user with
27
+ * @param env environment state
28
+ * @param req current http request
29
+ * @returns
30
+ */
31
+ export declare const signIn: (credentials: SignInCredentials, env: RouteInitEnvironment, req: RouteRequest) => Promise<DbUserAccountDetails>;
32
32
  //# sourceMappingURL=signin.d.ts.map
@@ -1,22 +1,22 @@
1
- export interface SimpleFetchResponse {
2
- readonly status: number;
3
- readonly headers: {
4
- get(name: string): string;
5
- };
6
- text(): Promise<string>;
7
- json(): Promise<any>;
8
- arrayBuffer(): Promise<ArrayBuffer>;
9
- }
10
- /**
11
- * Very lightweight custom fetch implementation to avoid additional dependencies
12
- * @param url
13
- * @param options
14
- */
15
- export declare function fetch(url: string, options?: {
16
- method?: 'GET' | 'POST' | 'PUT' | 'DELETE';
17
- headers?: {
18
- [name: string]: string;
19
- };
20
- body?: string;
21
- }): Promise<SimpleFetchResponse>;
1
+ export interface SimpleFetchResponse {
2
+ readonly status: number;
3
+ readonly headers: {
4
+ get(name: string): string;
5
+ };
6
+ text(): Promise<string>;
7
+ json(): Promise<any>;
8
+ arrayBuffer(): Promise<ArrayBuffer>;
9
+ }
10
+ /**
11
+ * Very lightweight custom fetch implementation to avoid additional dependencies
12
+ * @param url
13
+ * @param options
14
+ */
15
+ export declare function fetch(url: string, options?: {
16
+ method?: 'GET' | 'POST' | 'PUT' | 'DELETE';
17
+ headers?: {
18
+ [name: string]: string;
19
+ };
20
+ body?: string;
21
+ }): Promise<SimpleFetchResponse>;
22
22
  //# sourceMappingURL=simple-fetch.d.ts.map
@@ -1,25 +1,25 @@
1
- export declare const createPublicAccessToken: (uid: string, ip: string, dbToken: string, password: string) => string;
2
- export declare type PublicAccessToken = {
3
- access_token: string;
4
- uid: string;
5
- created: number;
6
- ip: string;
7
- };
8
- export declare const decodePublicAccessToken: (accessToken: string, password: string) => PublicAccessToken;
9
- /**
10
- * Sign objects with an md5 hash. An attacker might base4 decode it and see the content and generated checksum hash,
11
- * but will need to guess the password used to generate the hash to manipulate it. This is not impossible but will take
12
- * a very long time when using a large password
13
- * @param obj data object to sign
14
- * @param password password to use as salt for the generated md5 hash
15
- * @returns base64 encoded signed token
16
- */
17
- export declare const createSignedPublicToken: (obj: any, password: string) => string;
18
- /**
19
- * Parses and validates a signed token that was previouslt generated by `createSignedPublicToken`
20
- * @param str token previously generated by `createSignedPublicToken`
21
- * @param password the same password used to create the token with
22
- * @returns the original data object
23
- */
24
- export declare const parseSignedPublicToken: (str: string, password: string) => any;
1
+ export declare const createPublicAccessToken: (uid: string, ip: string, dbToken: string, password: string) => string;
2
+ export type PublicAccessToken = {
3
+ access_token: string;
4
+ uid: string;
5
+ created: number;
6
+ ip: string;
7
+ };
8
+ export declare const decodePublicAccessToken: (accessToken: string, password: string) => PublicAccessToken;
9
+ /**
10
+ * Sign objects with an md5 hash. An attacker might base4 decode it and see the content and generated checksum hash,
11
+ * but will need to guess the password used to generate the hash to manipulate it. This is not impossible but will take
12
+ * a very long time when using a large password
13
+ * @param obj data object to sign
14
+ * @param password password to use as salt for the generated md5 hash
15
+ * @returns base64 encoded signed token
16
+ */
17
+ export declare const createSignedPublicToken: (obj: any, password: string) => string;
18
+ /**
19
+ * Parses and validates a signed token that was previouslt generated by `createSignedPublicToken`
20
+ * @param str token previously generated by `createSignedPublicToken`
21
+ * @param password the same password used to create the token with
22
+ * @returns the original data object
23
+ */
24
+ export declare const parseSignedPublicToken: (str: string, password: string) => any;
25
25
  //# sourceMappingURL=tokens.d.ts.map
@@ -1,23 +1,23 @@
1
- import { DataReference } from 'acebase-core';
2
- export declare const isValidEmail: (email: string) => boolean;
3
- export declare const isValidNewEmailAddress: (authRef: DataReference, email: string) => Promise<boolean>;
4
- export declare const isValidNewUsername: (authRef: DataReference, username: any) => Promise<boolean>;
5
- export declare const isValidUsername: (username: string) => boolean;
6
- export declare const isValidDisplayName: (displayName: string) => boolean;
7
- export declare const isValidPassword: (password: string) => boolean;
8
- export declare const isValidPicture: (picture: any) => boolean;
9
- export declare const isValidSettings: (settings: any) => boolean;
10
- export declare type ValidationError<Code> = {
11
- code: Code;
12
- message: string;
13
- };
14
- export declare const invalidEmailError: ValidationError<'invalid_email'>;
15
- export declare const invalidUsernameError: ValidationError<'invalid_username'>;
16
- export declare const emailExistsError: ValidationError<'email_conflict'>;
17
- export declare const usernameExistsError: ValidationError<'username_conflict'>;
18
- export declare const emailOrUsernameExistsError: ValidationError<'conflict'>;
19
- export declare const invalidDisplayNameError: ValidationError<'invalid_display_name'>;
20
- export declare const invalidPasswordError: ValidationError<'invalid_password'>;
21
- export declare const invalidPictureError: ValidationError<'invalid_picture'>;
22
- export declare const invalidSettingsError: ValidationError<'invalid_settings'>;
1
+ import { DataReference } from 'acebase-core';
2
+ export declare const isValidEmail: (email: string) => boolean;
3
+ export declare const isValidNewEmailAddress: (authRef: DataReference, email: string) => Promise<boolean>;
4
+ export declare const isValidNewUsername: (authRef: DataReference, username: any) => Promise<boolean>;
5
+ export declare const isValidUsername: (username: string) => boolean;
6
+ export declare const isValidDisplayName: (displayName: string) => boolean;
7
+ export declare const isValidPassword: (password: string) => boolean;
8
+ export declare const isValidPicture: (picture: any) => boolean;
9
+ export declare const isValidSettings: (settings: any) => boolean;
10
+ export type ValidationError<Code> = {
11
+ code: Code;
12
+ message: string;
13
+ };
14
+ export declare const invalidEmailError: ValidationError<'invalid_email'>;
15
+ export declare const invalidUsernameError: ValidationError<'invalid_username'>;
16
+ export declare const emailExistsError: ValidationError<'email_conflict'>;
17
+ export declare const usernameExistsError: ValidationError<'username_conflict'>;
18
+ export declare const emailOrUsernameExistsError: ValidationError<'conflict'>;
19
+ export declare const invalidDisplayNameError: ValidationError<'invalid_display_name'>;
20
+ export declare const invalidPasswordError: ValidationError<'invalid_password'>;
21
+ export declare const invalidPictureError: ValidationError<'invalid_picture'>;
22
+ export declare const invalidSettingsError: ValidationError<'invalid_settings'>;
23
23
  //# sourceMappingURL=validate.d.ts.map
@@ -1,2 +1,2 @@
1
- export {};
1
+ export {};
2
2
  //# sourceMappingURL=start.d.ts.map
@@ -1,2 +1,2 @@
1
- export {};
1
+ export {};
2
2
  //# sourceMappingURL=test.d.ts.map
@@ -1,7 +1,7 @@
1
- import { RouteInitEnvironment } from '../shared/env';
2
- export declare class SocketRequestError extends Error {
3
- code: string;
4
- constructor(code: string, message: string);
5
- }
6
- export declare const addWebsocketServer: (env: RouteInitEnvironment) => import("./socket.io").SocketIOManager;
1
+ import { RouteInitEnvironment } from '../shared/env';
2
+ export declare class SocketRequestError extends Error {
3
+ code: string;
4
+ constructor(code: string, message: string);
5
+ }
6
+ export declare const addWebsocketServer: (env: RouteInitEnvironment) => import("./socket.io").SocketIOManager;
7
7
  //# sourceMappingURL=index.d.ts.map
@@ -1,100 +1,100 @@
1
- import { SimpleEventEmitter } from 'acebase-core';
2
- export declare type WebSocketEventData<SocketType, DataType = undefined> = {
3
- socket: SocketType;
4
- socket_id: string;
5
- data?: DataType;
6
- };
7
- export declare type WebSocketEventCallback<SocketType, DataType = any> = (event: WebSocketEventData<SocketType, DataType>) => void;
8
- export declare abstract class WebSocketManager<SocketType> extends SimpleEventEmitter {
9
- readonly framework: string;
10
- constructor(framework: string);
11
- abstract disconnect(socket: SocketType): any;
12
- abstract send(socket: SocketType, event: string, message: any): any;
13
- on(event: 'connect', callback: WebSocketEventCallback<SocketType>): void;
14
- on(event: 'disconnect', callback: WebSocketEventCallback<SocketType>): void;
15
- /** @deprecated deprecated since client v0.9.4 */
16
- on(event: 'signin', callback: WebSocketEventCallback<SocketType, {
17
- accessToken: string;
18
- }>): void;
19
- /** @deprecated deprecated since client v0.9.4 */
20
- on(event: 'signout', callback: WebSocketEventCallback<SocketType>): void;
21
- on(event: 'oauth2-signin', callback: WebSocketEventCallback<SocketType, {
22
- server: {
23
- protocol: 'http' | 'https';
24
- host: string;
25
- port: number;
26
- };
27
- provider: string;
28
- options: any;
29
- }>): void;
30
- on(event: 'subscribe', callback: WebSocketEventCallback<SocketType, {
31
- req_id: string;
32
- path: string;
33
- event: string;
34
- }>): void;
35
- on(event: 'unsubscribe', callback: WebSocketEventCallback<SocketType, {
36
- req_id: string;
37
- path: string;
38
- event?: string;
39
- }>): void;
40
- on(event: 'query-unsubscribe', callback: WebSocketEventCallback<SocketType, {
41
- req_id: string;
42
- query_id: string;
43
- }>): void;
44
- on(event: 'transaction-start', callback: WebSocketEventCallback<SocketType, {
45
- action: 'start';
46
- id: string;
47
- path: string;
48
- context: any;
49
- }>): void;
50
- on(event: 'transaction-finish', callback: WebSocketEventCallback<SocketType, {
51
- action: 'finish';
52
- id: string;
53
- path: string;
54
- value: any;
55
- }>): void;
56
- emit(event: 'connect', data: WebSocketEventData<SocketType>): this;
57
- emit(event: 'disconnect', data: WebSocketEventData<SocketType, string>): this;
58
- /** @deprecated deprecated since client v0.9.4 */
59
- emit(event: 'signin', data: WebSocketEventData<SocketType, {
60
- accessToken: string;
61
- }>): this;
62
- /** @deprecated deprecated since client v0.9.4 */
63
- emit(event: 'signout', data: WebSocketEventData<SocketType>): this;
64
- emit(event: 'oauth2-signin', data: WebSocketEventData<SocketType, {
65
- server: {
66
- protocol: 'http' | 'https';
67
- host: string;
68
- port: number;
69
- };
70
- provider: string;
71
- options: any;
72
- }>): this;
73
- emit(event: 'subscribe', data: WebSocketEventData<SocketType, {
74
- req_id: string;
75
- path: string;
76
- event: string;
77
- }>): this;
78
- emit(event: 'unsubscribe', data: WebSocketEventData<SocketType, {
79
- req_id: string;
80
- path: string;
81
- event?: string;
82
- }>): this;
83
- emit(event: 'query-unsubscribe', data: WebSocketEventData<SocketType, {
84
- req_id: string;
85
- query_id: string;
86
- }>): this;
87
- emit(event: 'transaction-start', data: WebSocketEventData<SocketType, {
88
- action: 'start';
89
- id: string;
90
- path: string;
91
- context: any;
92
- }>): this;
93
- emit(event: 'transaction-finish', data: WebSocketEventData<SocketType, {
94
- action: 'finish';
95
- id: string;
96
- path: string;
97
- value: any;
98
- }>): this;
99
- }
1
+ import { SimpleEventEmitter } from 'acebase-core';
2
+ export type WebSocketEventData<SocketType, DataType = undefined> = {
3
+ socket: SocketType;
4
+ socket_id: string;
5
+ data?: DataType;
6
+ };
7
+ export type WebSocketEventCallback<SocketType, DataType = any> = (event: WebSocketEventData<SocketType, DataType>) => void;
8
+ export declare abstract class WebSocketManager<SocketType> extends SimpleEventEmitter {
9
+ readonly framework: string;
10
+ constructor(framework: string);
11
+ abstract disconnect(socket: SocketType): any;
12
+ abstract send(socket: SocketType, event: string, message: any): any;
13
+ on(event: 'connect', callback: WebSocketEventCallback<SocketType>): void;
14
+ on(event: 'disconnect', callback: WebSocketEventCallback<SocketType>): void;
15
+ /** @deprecated deprecated since client v0.9.4 */
16
+ on(event: 'signin', callback: WebSocketEventCallback<SocketType, {
17
+ accessToken: string;
18
+ }>): void;
19
+ /** @deprecated deprecated since client v0.9.4 */
20
+ on(event: 'signout', callback: WebSocketEventCallback<SocketType>): void;
21
+ on(event: 'oauth2-signin', callback: WebSocketEventCallback<SocketType, {
22
+ server: {
23
+ protocol: 'http' | 'https';
24
+ host: string;
25
+ port: number;
26
+ };
27
+ provider: string;
28
+ options: any;
29
+ }>): void;
30
+ on(event: 'subscribe', callback: WebSocketEventCallback<SocketType, {
31
+ req_id: string;
32
+ path: string;
33
+ event: string;
34
+ }>): void;
35
+ on(event: 'unsubscribe', callback: WebSocketEventCallback<SocketType, {
36
+ req_id: string;
37
+ path: string;
38
+ event?: string;
39
+ }>): void;
40
+ on(event: 'query-unsubscribe', callback: WebSocketEventCallback<SocketType, {
41
+ req_id: string;
42
+ query_id: string;
43
+ }>): void;
44
+ on(event: 'transaction-start', callback: WebSocketEventCallback<SocketType, {
45
+ action: 'start';
46
+ id: string;
47
+ path: string;
48
+ context: any;
49
+ }>): void;
50
+ on(event: 'transaction-finish', callback: WebSocketEventCallback<SocketType, {
51
+ action: 'finish';
52
+ id: string;
53
+ path: string;
54
+ value: any;
55
+ }>): void;
56
+ emit(event: 'connect', data: WebSocketEventData<SocketType>): this;
57
+ emit(event: 'disconnect', data: WebSocketEventData<SocketType, string>): this;
58
+ /** @deprecated deprecated since client v0.9.4 */
59
+ emit(event: 'signin', data: WebSocketEventData<SocketType, {
60
+ accessToken: string;
61
+ }>): this;
62
+ /** @deprecated deprecated since client v0.9.4 */
63
+ emit(event: 'signout', data: WebSocketEventData<SocketType>): this;
64
+ emit(event: 'oauth2-signin', data: WebSocketEventData<SocketType, {
65
+ server: {
66
+ protocol: 'http' | 'https';
67
+ host: string;
68
+ port: number;
69
+ };
70
+ provider: string;
71
+ options: any;
72
+ }>): this;
73
+ emit(event: 'subscribe', data: WebSocketEventData<SocketType, {
74
+ req_id: string;
75
+ path: string;
76
+ event: string;
77
+ }>): this;
78
+ emit(event: 'unsubscribe', data: WebSocketEventData<SocketType, {
79
+ req_id: string;
80
+ path: string;
81
+ event?: string;
82
+ }>): this;
83
+ emit(event: 'query-unsubscribe', data: WebSocketEventData<SocketType, {
84
+ req_id: string;
85
+ query_id: string;
86
+ }>): this;
87
+ emit(event: 'transaction-start', data: WebSocketEventData<SocketType, {
88
+ action: 'start';
89
+ id: string;
90
+ path: string;
91
+ context: any;
92
+ }>): this;
93
+ emit(event: 'transaction-finish', data: WebSocketEventData<SocketType, {
94
+ action: 'finish';
95
+ id: string;
96
+ path: string;
97
+ value: any;
98
+ }>): this;
99
+ }
100
100
  //# sourceMappingURL=manager.d.ts.map
@@ -1,11 +1,11 @@
1
- import type { Socket } from 'socket.io';
2
- import { RouteInitEnvironment } from '../shared/env';
3
- import { WebSocketManager } from './manager';
4
- export declare type SocketType = Socket;
5
- export declare class SocketIOManager extends WebSocketManager<Socket> {
6
- constructor();
7
- disconnect(socket: Socket): void;
8
- send(socket: Socket, event: string, message?: any): void;
9
- }
10
- export declare const createServer: (env: RouteInitEnvironment) => SocketIOManager;
1
+ import type { Socket } from 'socket.io';
2
+ import { RouteInitEnvironment } from '../shared/env';
3
+ import { WebSocketManager } from './manager';
4
+ export type SocketType = Socket;
5
+ export declare class SocketIOManager extends WebSocketManager<Socket> {
6
+ constructor();
7
+ disconnect(socket: Socket): void;
8
+ send(socket: Socket, event: string, message?: any): void;
9
+ }
10
+ export declare const createServer: (env: RouteInitEnvironment) => SocketIOManager;
11
11
  //# sourceMappingURL=socket.io.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "acebase-server",
3
- "version": "1.16.2",
3
+ "version": "1.17.0",
4
4
  "description": "AceBase realtime database server (webserver endpoint to allow remote connections)",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.js",
@@ -61,8 +61,8 @@
61
61
  "author": "Ewout Stortenbeker <me@appy.one> (http://appy.one)",
62
62
  "license": "MIT",
63
63
  "dependencies": {
64
- "acebase": "^1.27.0",
65
- "acebase-core": "^1.25.0",
64
+ "acebase": "^1.28.5",
65
+ "acebase-core": "^1.26.2",
66
66
  "express": "^4.17.1",
67
67
  "socket.io": "^4.5.0",
68
68
  "swagger-jsdoc": "^6.1.0",
@@ -76,6 +76,6 @@
76
76
  "@typescript-eslint/parser": "^5.46.1",
77
77
  "eslint": "^8.30.0",
78
78
  "tsc-esm-fix": "^2.12.4",
79
- "typescript": "^4.7.4"
79
+ "typescript": "^5.0.4"
80
80
  }
81
81
  }
@@ -49,20 +49,20 @@
49
49
  type: boolean
50
50
  example: true
51
51
  400:
52
- description: Returns "400 Bad Request" if the sent value is incorrect
52
+ description: Returns "400 Bad Request if the sent value is incorrect
53
53
  content:
54
54
  'application/json':
55
55
  schema:
56
56
  $ref: '#/components/schemas/Error'
57
- example:
58
- code: invalid_serialized_value
59
- message: The sent value is not properly serialized
57
+ example:
58
+ code: invalid_serialized_value
59
+ message: The sent value is not properly serialized
60
60
  403:
61
61
  description: Returns "403 Forbidden" if the signed in user is not allowed to write to the target path
62
62
  content:
63
63
  'application/json':
64
64
  schema:
65
- $ref: '#/components/schemas/Error'
65
+ $ref: '#/components/schemas/RuleValidationError'
66
66
  422:
67
67
  description: Returns "422 Unprocessable Entity" if schema validation for the sent value failed.
68
68
  content: