acebase-server 1.19.2 → 1.20.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 (63) hide show
  1. package/README.md +19 -33
  2. package/api-clients/thunder-client/README.md +32 -0
  3. package/api-clients/thunder-client/collection.json +1069 -0
  4. package/api-clients/thunder-client/environment.json +25 -0
  5. package/dist/cjs/auth.js +10 -7
  6. package/dist/cjs/logger.js +3 -3
  7. package/dist/cjs/middleware/user.js +6 -13
  8. package/dist/cjs/oauth-providers/facebook.js +1 -1
  9. package/dist/cjs/oauth-providers/instagram.js +1 -1
  10. package/dist/cjs/routes/auth-change-password.js +12 -9
  11. package/dist/cjs/routes/auth-reset-password.js +6 -5
  12. package/dist/cjs/routes/auth-signin.js +15 -2
  13. package/dist/cjs/routes/data-reflect.js +1 -1
  14. package/dist/cjs/routes/data-transaction.js +7 -7
  15. package/dist/cjs/routes/docs.js +1 -1
  16. package/dist/cjs/routes/meta-info.js +2 -2
  17. package/dist/cjs/routes/oauth2-signin.js +2 -2
  18. package/dist/cjs/rules.js +4 -2
  19. package/dist/cjs/sandbox.js +2 -3
  20. package/dist/cjs/server.js +5 -2
  21. package/dist/cjs/shared/admin.js +1 -2
  22. package/dist/cjs/shared/error.js +2 -1
  23. package/dist/cjs/shared/http.js +17 -0
  24. package/dist/cjs/shared/signin.js +72 -76
  25. package/dist/cjs/shared/simple-fetch.js +1 -2
  26. package/dist/cjs/shared/tokens.js +1 -1
  27. package/dist/cjs/start.js +1 -1
  28. package/dist/cjs/websocket/index.js +10 -10
  29. package/dist/cjs/websocket/socket.io.js +2 -2
  30. package/dist/esm/auth.js +10 -7
  31. package/dist/esm/middleware/user.js +6 -13
  32. package/dist/esm/oauth-providers/facebook.js +1 -1
  33. package/dist/esm/oauth-providers/instagram.js +1 -1
  34. package/dist/esm/routes/auth-change-password.js +11 -8
  35. package/dist/esm/routes/auth-reset-password.js +3 -3
  36. package/dist/esm/routes/auth-signin.js +17 -4
  37. package/dist/esm/routes/data-reflect.js +1 -1
  38. package/dist/esm/routes/docs.js +1 -1
  39. package/dist/esm/routes/meta-info.js +2 -2
  40. package/dist/esm/routes/oauth2-signin.js +2 -2
  41. package/dist/esm/rules.js +4 -2
  42. package/dist/esm/server.js +4 -1
  43. package/dist/esm/shared/error.js +1 -1
  44. package/dist/esm/shared/http.js +17 -0
  45. package/dist/esm/shared/signin.js +87 -75
  46. package/dist/esm/shared/tokens.js +1 -1
  47. package/dist/esm/start.js +1 -1
  48. package/dist/esm/websocket/socket.io.js +2 -2
  49. package/dist/types/routes/auth-change-password.d.ts +1 -0
  50. package/dist/types/rules.d.ts +1 -1
  51. package/dist/types/schema/user.d.ts +4 -0
  52. package/dist/types/settings/index.d.ts +0 -2
  53. package/dist/types/shared/clients.d.ts +0 -1
  54. package/dist/types/shared/env.d.ts +12 -11
  55. package/dist/types/shared/http.d.ts +2 -2
  56. package/dist/types/shared/password.d.ts +1 -1
  57. package/dist/types/shared/signin.d.ts +4 -6
  58. package/dist/types/shared/simple-fetch.d.ts +2 -2
  59. package/dist/types/shared/tokens.d.ts +1 -1
  60. package/package.json +10 -11
  61. package/release_notes.md +21 -2
  62. package/src/routes/auth-change-password.yaml +9 -0
  63. package/src/routes/auth-signin.yaml +2 -1
@@ -11,6 +11,23 @@ export const createApp = (settings) => {
11
11
  app.set('trust proxy', settings.trustProxy);
12
12
  // Parse json request bodies
13
13
  app.use(express.json({ limit: settings.maxPayloadSize })); // , extended: true ?
14
+ // Handle body parsing errors ourselves, preventing Express' default error handler from
15
+ // sending detailed error info (including stack trace) to the client
16
+ app.use((err, req, res, next) => {
17
+ if (typeof err?.type !== 'string' || typeof err?.status !== 'number') {
18
+ // Not a body-parser error
19
+ return next(err);
20
+ }
21
+ const code = err.type === 'entity.parse.failed' ? 'invalid_json'
22
+ : err.type === 'entity.too.large' ? 'payload_too_large'
23
+ : 'invalid_body';
24
+ const message = err.type === 'entity.parse.failed' ? 'Request body is not valid JSON'
25
+ : err.type === 'entity.too.large' ? 'Request body is too large'
26
+ : 'Request body could not be read';
27
+ res.status(err.status >= 400 && err.status < 500 ? err.status : 400)
28
+ .contentType('application/json')
29
+ .send({ code, message });
30
+ });
14
31
  return app;
15
32
  };
16
33
  /**
@@ -1,6 +1,5 @@
1
1
  import { ID } from 'acebase-core';
2
2
  import { createPasswordHash, getOldPasswordHash, getPasswordHash } from './password.js';
3
- import { decodePublicAccessToken } from './tokens.js';
4
3
  export class SignInError extends Error {
5
4
  constructor(code, message, details = {}) {
6
5
  super(message);
@@ -8,42 +7,22 @@ export class SignInError extends Error {
8
7
  this.details = details;
9
8
  }
10
9
  }
11
- /**
12
- * 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.
13
- * Throws a `SignInError` if sign in fails for a known reason.
14
- * @param credentials credentials to sign in the user with
15
- * @param env environment state
16
- * @param req current http request
17
- * @returns
18
- */
19
- export const signIn = async (credentials, env, req) => {
20
- const LOG_ACTION = 'auth.signin';
21
- const LOG_DETAILS = { ip: req.ip, method: credentials.method };
22
- try {
10
+ const queryUser = async (credentials, env) => {
11
+ let user;
12
+ if (credentials.method === 'token') {
13
+ // Uses the uid and access token extracted from a public access token
14
+ if (typeof credentials.access_token !== 'string') {
15
+ throw new SignInError('invalid_details', 'sign in request has invalid arguments');
16
+ }
17
+ const snap = await env.authRef.child(credentials.uid).get();
18
+ if (snap.exists()) {
19
+ user = snap.val();
20
+ user.uid = snap.key;
21
+ }
22
+ }
23
+ else {
23
24
  const query = env.authRef.query();
24
- let tokenDetails;
25
25
  switch (credentials.method) {
26
- case 'token': {
27
- if (typeof credentials.access_token !== 'string') {
28
- throw new SignInError('invalid_details', 'sign in request has invalid arguments');
29
- }
30
- try {
31
- tokenDetails = decodePublicAccessToken(credentials.access_token, env.tokenSalt);
32
- query.filter('access_token', '==', tokenDetails.access_token);
33
- }
34
- catch (err) {
35
- throw new SignInError('invalid_token', err.message);
36
- }
37
- break;
38
- }
39
- case 'internal': {
40
- // Method used internally: uses the access token extracted from a public access token (see tokenDetails.access_token in above 'token' case)
41
- if (typeof credentials.access_token !== 'string') {
42
- throw new SignInError('invalid_details', 'sign in request has invalid arguments');
43
- }
44
- query.filter('access_token', '==', credentials.access_token);
45
- break;
46
- }
47
26
  case 'email': {
48
27
  if (typeof credentials.email !== 'string' || typeof credentials.password !== 'string') {
49
28
  throw new SignInError('invalid_details', 'sign in request has invalid arguments');
@@ -63,21 +42,48 @@ export const signIn = async (credentials, env, req) => {
63
42
  }
64
43
  }
65
44
  const snaps = await query.get();
66
- if (snaps.length === 0) {
67
- throw new SignInError('not_found', `account not found`);
68
- }
69
- else if (snaps.length > 1) {
45
+ if (snaps.length > 1) {
70
46
  throw new SignInError('duplicate', `${snaps.length} users found with the same ${credentials.method}. Contact your database administrator`, { count: snaps.length });
71
47
  }
72
- const snap = snaps[0];
73
- const user = snap.val();
74
- user.uid = snap.key;
48
+ else if (snaps.length === 1) {
49
+ const snap = snaps[0];
50
+ user = snap.val();
51
+ user.uid = snap.key;
52
+ }
53
+ }
54
+ if (!user) {
55
+ throw new SignInError('not_found', `account not found`);
56
+ }
57
+ return user;
58
+ };
59
+ /**
60
+ * Signs in a user and logs the request. Uses cache for token sign-in method. If successful, adds the user to cache and returns the user details.
61
+ * Throws a `SignInError` if sign in fails for a known reason.
62
+ * @param credentials credentials to sign in the user with
63
+ * @param env environment state
64
+ * @param req current http request
65
+ * @returns
66
+ */
67
+ export const signIn = async (credentials, env, ip, isNewSession) => {
68
+ const LOG_ACTION = 'auth.signin';
69
+ const LOG_DETAILS = {
70
+ ip,
71
+ method: credentials.method,
72
+ ...('uid' in credentials && { uid: credentials.uid }),
73
+ ...('username' in credentials && { username: credentials.username }),
74
+ ...('email' in credentials && { email: credentials.email }),
75
+ };
76
+ try {
77
+ const isCached = credentials.method === 'token' && env.authCache.has(credentials.uid);
78
+ const user = isCached
79
+ ? env.authCache.get(credentials.uid)
80
+ : await queryUser(credentials, env);
81
+ if (credentials.method === 'token' && credentials.access_token !== user.access_token) {
82
+ throw new SignInError('expired_token', `Access token has expired. Sign in again`);
83
+ }
75
84
  if (user.is_disabled === true) {
76
85
  throw new SignInError('account_disabled', 'Your account has been disabled. Contact your database administrator');
77
86
  }
78
- if (credentials.method === 'token' && tokenDetails.uid !== user.uid) {
79
- throw new SignInError('token_mismatch', 'Sign in again');
80
- }
81
87
  if (credentials.method === 'account' || credentials.method === 'email') {
82
88
  // Check password
83
89
  const hash = user.password_salt ? getPasswordHash(credentials.password, user.password_salt) : getOldPasswordHash(credentials.password);
@@ -85,44 +91,50 @@ export const signIn = async (credentials, env, req) => {
85
91
  throw new SignInError('wrong_password', 'Incorrect password');
86
92
  }
87
93
  }
88
- // Keep track of properties to update, both in db and in our object
89
- const updates = {
90
- // Update prev / last sign in stats
91
- prev_signin: user.last_signin,
92
- prev_signin_ip: user.last_signin_ip,
93
- last_signin: new Date(),
94
- last_signin_ip: req.ip,
95
- };
96
- if ('password' in credentials) {
97
- if (!user.password_salt) {
98
- // OLD md5 password hash, convert to new salted hash
99
- const pwd = createPasswordHash(credentials.password);
100
- updates.password = pwd.hash;
101
- updates.password_salt = pwd.salt;
94
+ if (isNewSession) {
95
+ // Keep track of properties to update, both in db and cached details
96
+ const updates = {
97
+ last_session_start: new Date(),
98
+ last_session_ip: ip,
99
+ ...(credentials.method !== 'token' && {
100
+ // Update prev / last sign in stats
101
+ ...(user.last_signin && { prev_signin: user.last_signin }),
102
+ ...(user.last_signin_ip && { prev_signin_ip: user.last_signin_ip }),
103
+ last_signin: new Date(),
104
+ last_signin_ip: ip,
105
+ }),
106
+ };
107
+ if ('password' in credentials) {
108
+ if (!user.password_salt) {
109
+ // OLD md5 password hash, convert to new salted hash
110
+ const pwd = createPasswordHash(credentials.password);
111
+ updates.password = pwd.hash;
112
+ updates.password_salt = pwd.salt;
113
+ }
114
+ if (!user.access_token) {
115
+ // Generate access token
116
+ updates.access_token = ID.generate();
117
+ updates.access_token_created = new Date();
118
+ }
102
119
  }
103
- if (!user.access_token) {
104
- // Generate access token
105
- updates.access_token = ID.generate();
106
- updates.access_token_created = new Date();
120
+ // Update user object
121
+ Object.assign(user, updates);
122
+ // Update db
123
+ await env.authRef.child(user.uid).update(updates);
124
+ // Log history item
125
+ if (!LOG_DETAILS.uid) {
126
+ LOG_DETAILS.uid = user.uid;
107
127
  }
128
+ env.log.event(LOG_ACTION, LOG_DETAILS).catch((err) => env.debug.fatal(`Failed to log successful sign in to db`, err));
108
129
  }
109
- // Update user object
110
- Object.assign(user, updates);
111
- // Update db
112
- await snap.ref.update(updates);
113
- // Log history item
114
- if (credentials.method !== 'internal') {
115
- env.log.event(LOG_ACTION, LOG_DETAILS);
116
- }
117
- // Add to cache
130
+ // Update cache
118
131
  env.authCache.set(user.uid, user);
119
- // Bind user to current request
120
- req.user = user;
121
132
  return user;
122
133
  }
123
134
  catch (err) {
124
135
  // Log error
125
- env.log.error(LOG_ACTION, err.code ?? 'unexpected', LOG_DETAILS, typeof err.code === 'undefined' ? err : null);
136
+ env.log.error(LOG_ACTION, err?.code ?? 'unexpected', LOG_DETAILS, err?.code ?? err ?? null)
137
+ .catch((err) => env.debug.fatal(`Failed to log failed sign in to db`, err));
126
138
  throw err;
127
139
  }
128
140
  };
@@ -38,7 +38,7 @@ const getSignature = (content, salt) => {
38
38
  };
39
39
  /**
40
40
  * Sign objects with an md5 hash. An attacker might base4 decode it and see the content and generated checksum hash,
41
- * but will need to guess the password used to generate the hash to manipulate it. This is not impossible but will take
41
+ * but will need to guess the password used to generate the hash to manipulate it. This is not impossible but will take
42
42
  * a very long time when using a large password
43
43
  * @param obj data object to sign
44
44
  * @param password password to use as salt for the generated md5 hash
package/dist/esm/start.js CHANGED
@@ -100,7 +100,7 @@ if (getVariable('AUTH', 'true') === 'true' || +getVariable('AUTH', 1) === 1) {
100
100
  allowUserSignup: +getVariable('AUTH_USER_SIGNUP', 1) === 1,
101
101
  defaultAccessRule: getVariable('AUTH_DEFAULT_ACCESS_RULE'),
102
102
  defaultAdminPassword: getVariable('AUTH_DEFAULT_ADMIN_PASSWORD'),
103
- newUserRateLimit: +getVariable('AUTH_NEW_USER_RATE_LIMIT', 0),
103
+ newUserRateLimit: +getVariable('AUTH_NEW_USER_RATE_LIMIT', 0), // No implemented yet
104
104
  separateDb: getVariable('AUTH_SEPARATE_DB', false),
105
105
  tokensExpire: +getVariable('AUTH_TOKENS_EXPIRE', 0), // No implemented yet
106
106
  };
@@ -30,8 +30,8 @@ export const createServer = (env) => {
30
30
  const maxPayloadBytes = 10e7; // Socket is closed if sent message exceeds this. Socket.io 2.x default is 10e7 (100MB)
31
31
  const server = createSocketIOServer(env.server, {
32
32
  // See https://socket.io/docs/v2/server-initialization/ and https://socket.io/docs/v3/server-initialization/
33
- pingInterval: 5000,
34
- pingTimeout: 5000,
33
+ pingInterval: 5000, // socket.io 2.x default is 25000
34
+ pingTimeout: 5000, // socket.io 2.x default is 5000, 3.x default = 20000
35
35
  maxHttpBufferSize: maxPayloadBytes,
36
36
  path: `/${env.rootPath ? `${env.rootPath}/` : ''}socket.io`,
37
37
  // Allow socket.io 2.x clients (using engine.io 3.x):
@@ -8,6 +8,7 @@ export type RequestBody = {
8
8
  uid: string;
9
9
  password: string;
10
10
  new_password: string;
11
+ sign_out?: boolean;
11
12
  };
12
13
  export type ResponseBody = {
13
14
  access_token: string;
@@ -67,7 +67,7 @@ export declare class PathBasedRules {
67
67
  db: AceBase;
68
68
  authEnabled: boolean;
69
69
  });
70
- isOperationAllowed(user: Pick<DbUserAccountDetails, 'uid' | 'roles'>, path: string, operation: AccessCheckOperation, data?: Record<string, any>): Promise<HasAccessResult>;
70
+ isOperationAllowed(user: Pick<DbUserAccountDetails, 'uid' | 'roles'> | undefined, path: string, operation: AccessCheckOperation, data?: Record<string, any>): Promise<HasAccessResult>;
71
71
  add(rulePaths: string | string[], ruleTypes: PathRuleType | PathRuleType[], callback: PathRuleFunction): void;
72
72
  }
73
73
  export {};
@@ -85,6 +85,10 @@ export type DbUserAccountDetails = ({
85
85
  settings: UserSettings;
86
86
  /** roles this user has */
87
87
  roles?: string[];
88
+ /** date/time of the last registered session */
89
+ last_session_start?: Date;
90
+ /** ip address of last registered session */
91
+ last_session_ip?: string;
88
92
  };
89
93
  export declare const getPublicAccountDetails: (account: DbUserAccountDetails) => AceBaseUser;
90
94
  //# sourceMappingURL=user.d.ts.map
@@ -1,5 +1,3 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
1
  import { AceBaseStorageSettings } from 'acebase';
4
2
  import { AceBaseServerEmailSettings } from './email';
5
3
  import { Server } from 'http';
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { EventSubscriptionCallback, Query, QueryOptions } from 'acebase-core';
3
2
  import { DbUserAccountDetails } from '../schema/user';
4
3
  import { HttpSocket } from './http';
@@ -1,6 +1,3 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- /// <reference types="express" />
4
1
  import type { HttpApp, HttpRouter, Request } from './http';
5
2
  import type { AceBase, DataReference } from 'acebase';
6
3
  import type { AceBaseServerConfig } from '../settings';
@@ -36,13 +33,17 @@ export interface RouteInitEnvironment {
36
33
  rules: PathBasedRules;
37
34
  instance: AceBaseServer;
38
35
  }
39
- export interface RouteRequestEnvironment {
40
- /** If the request has an Authentication: bearer token, the user will be bound to the incoming request */
41
- user?: DbUserAccountDetails;
42
- /** If context is sent through AceBase-Context header, it will be bound to the incoming request */
43
- context: {
44
- [key: string]: any;
45
- };
36
+ declare global {
37
+ namespace Express {
38
+ interface Request {
39
+ /** If the request has an Authentication: bearer token, the user will be bound to the incoming request */
40
+ user?: DbUserAccountDetails;
41
+ /** If context is sent through AceBase-Context header, it will be bound to the incoming request */
42
+ context: {
43
+ [key: string]: any;
44
+ };
45
+ }
46
+ }
46
47
  }
47
- export type RouteRequest<ReqQuery = any, ReqBody = any, ResBody = any> = Request<any, ResBody, ReqBody, ReqQuery> & RouteRequestEnvironment;
48
+ export type RouteRequest<ReqQuery = any, ReqBody = any, ResBody = any> = Request<any, ResBody, ReqBody, ReqQuery>;
48
49
  //# sourceMappingURL=env.d.ts.map
@@ -14,10 +14,10 @@ export type HttpResponse = express.Response;
14
14
  export declare const createApp: (settings: {
15
15
  trustProxy: boolean;
16
16
  maxPayloadSize: string;
17
- }) => express.Express;
17
+ }) => HttpApp;
18
18
  /**
19
19
  * Creates an express router
20
20
  * @returns
21
21
  */
22
- export declare const createRouter: () => express.Router;
22
+ export declare const createRouter: () => HttpRouter;
23
23
  //# sourceMappingURL=http.d.ts.map
@@ -1,4 +1,4 @@
1
- export declare const generatePassword: () => any;
1
+ export declare const generatePassword: () => string;
2
2
  /**
3
3
  * Generates a random salt and hashes the provided password with it. The resulting salt and hash should be stored in the database
4
4
  * @param password password to hash
@@ -1,10 +1,8 @@
1
1
  import { DbUserAccountDetails } from '../schema/user';
2
- import { RouteInitEnvironment, RouteRequest } from './env';
2
+ import { RouteInitEnvironment } from './env';
3
3
  export type SignInCredentials = {
4
4
  method: 'token';
5
- access_token: string;
6
- } | {
7
- method: 'internal';
5
+ uid: string;
8
6
  access_token: string;
9
7
  } | {
10
8
  method: 'email';
@@ -21,12 +19,12 @@ export declare class SignInError extends Error {
21
19
  constructor(code: string, message: string, details?: any);
22
20
  }
23
21
  /**
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.
22
+ * Signs in a user and logs the request. Uses cache for token sign-in method. If successful, adds the user to cache and returns the user details.
25
23
  * Throws a `SignInError` if sign in fails for a known reason.
26
24
  * @param credentials credentials to sign in the user with
27
25
  * @param env environment state
28
26
  * @param req current http request
29
27
  * @returns
30
28
  */
31
- export declare const signIn: (credentials: SignInCredentials, env: RouteInitEnvironment, req: RouteRequest) => Promise<DbUserAccountDetails>;
29
+ export declare const signIn: (credentials: SignInCredentials, env: RouteInitEnvironment, ip: string, isNewSession: boolean) => Promise<DbUserAccountDetails>;
32
30
  //# sourceMappingURL=signin.d.ts.map
@@ -1,7 +1,7 @@
1
1
  export interface SimpleFetchResponse {
2
- readonly status: number;
2
+ readonly status?: number;
3
3
  readonly headers: {
4
- get(name: string): string;
4
+ get(name: string): string | undefined;
5
5
  };
6
6
  text(): Promise<string>;
7
7
  json(): Promise<any>;
@@ -8,7 +8,7 @@ export type PublicAccessToken = {
8
8
  export declare const decodePublicAccessToken: (accessToken: string, password: string) => PublicAccessToken;
9
9
  /**
10
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
11
+ * but will need to guess the password used to generate the hash to manipulate it. This is not impossible but will take
12
12
  * a very long time when using a large password
13
13
  * @param obj data object to sign
14
14
  * @param password password to use as salt for the generated md5 hash
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "acebase-server",
3
- "version": "1.19.2",
3
+ "version": "1.20.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",
7
7
  "types": "./dist/types/index.d.ts",
8
8
  "exports": {
9
9
  ".": {
10
+ "types": "./dist/types/index.d.ts",
10
11
  "import": "./dist/esm/index.js",
11
- "require": "./dist/cjs/index.js",
12
- "types": "./dist/types/index.d.ts"
12
+ "require": "./dist/cjs/index.js"
13
13
  }
14
14
  },
15
15
  "bin": {
@@ -19,7 +19,7 @@
19
19
  "repository": "github:appy-one/acebase-server",
20
20
  "scripts": {
21
21
  "start": "node dist/esm/start.js DBNAME=default DBPATH=. HOST=localhost PORT=3000 TXLOG=1 AUTH=1",
22
- "test": "set NODE_ENV=development && npm run start",
22
+ "test": "NODE_ENV=development npm run start",
23
23
  "lint": "eslint .",
24
24
  "lint:fix": "eslint . --fix",
25
25
  "build": "npm run build:clean && npm run build:esm && npm run build:cjs && npm run build:packages && npm run build:vars && echo Done!",
@@ -63,21 +63,20 @@
63
63
  "author": "Ewout Stortenbeker <me@appy.one> (http://appy.one)",
64
64
  "license": "MIT",
65
65
  "dependencies": {
66
- "acebase": "^1.29.12",
66
+ "acebase": "^1.29.15",
67
67
  "acebase-core": "^1.28.1",
68
- "express": "^4.17.1",
69
- "socket.io": "^4.5.0",
68
+ "express": "^4.22.3",
69
+ "socket.io": "^4.8.4",
70
70
  "swagger-jsdoc": "^6.1.0",
71
71
  "swagger-ui-express": "^4.3.0"
72
72
  },
73
73
  "devDependencies": {
74
- "@types/express": "^4.17.13",
75
- "@types/node": "^10.17.60",
76
- "@types/socket.io": "^3.0.2",
74
+ "@types/express": "^4.17.25",
75
+ "@types/node": "^20.19.43",
77
76
  "@typescript-eslint/eslint-plugin": "^5.46.1",
78
77
  "@typescript-eslint/parser": "^5.46.1",
79
78
  "eslint": "^8.30.0",
80
79
  "tsc-esm-fix": "^2.12.4",
81
- "typescript": "^5.0.4"
80
+ "typescript": "^5.9.3"
82
81
  }
83
82
  }
package/release_notes.md CHANGED
@@ -1,2 +1,21 @@
1
- - Use acebase file dependencies for dev (65dbc48)
2
- - chore: release v1.19.1 [skip ci] (a2fe93c)
1
+ - middleware: handle bodyparser errors to prevent sending stacktraces back to the client (3c8b98c)
2
+ - dependencies: bump express to v4.22.3 (98e6955)
3
+ - dependencies: bump socket.io to v4.8.4 (4037546)
4
+ - Authentication: only update session/signin details in db when called from the signin endpoint (6959a91)
5
+ - package-lock.json (037bb9e)
6
+ - Sign in: fix public token sign in method (real access token needs to be extracted from public token) (a6cf9ec)
7
+ - Thunder collection: replace stub example passwords with ... (7af3363)
8
+ - package: move types export to top (9bf80e2)
9
+ - Docs: use `await` in examples (d848be2)
10
+ - Server: remove SIGINT handler once triggered (a19d273)
11
+ - Server: remove SIGINT handler upon server shutdown to prevent `MaxListenersExceededWarning`s if servers are started and shutdown by code in the same process (c16eccf)
12
+ - Add Thunder Client collection and environment (1bee2c7)
13
+ - Update typescript and @types/node dev dependencies (7c420c1)
14
+ - Fix test script on Linux/Mac (8de066c)
15
+ - TS fixes (dda8ba2)
16
+ - Add guard if `err` is not an object or has no `message` (3f06f2e)
17
+ - Add new `last_session_start` and `last_session_ip` properties to user accounts in db (a043a5a)
18
+ - Fix typescript errors for custom request object properties (6274119)
19
+ - Auth middleware: improve access token auth flow and logging. Using an expired token now returns new `expired_token` error code instead of `not_found`, which made it look like the user account didn't exist. User's `last_signin` and `prev_signin` (and the corresponding `_ip` fields) are now only updated when signing in with a password. When signing in with an access token, the new `last_session_start` and `last_session_ip` fields are set: a session being the time the account details are present in server memory cache. (7f201d9)
20
+ - Authentication: fix issue where changing the account password caused other clients to be signed out because their access token was invalidated. This is now made optional using a new `sign_out` property (which defaults to `false`). The default behaviour is now in line with the forgot password flow that doesn't change the access token either. (845a7dc)
21
+ - chore: release v1.19.2 [skip ci] (29e1f66)
@@ -28,10 +28,19 @@
28
28
  new_password:
29
29
  type: string
30
30
  description: New password to set on the account
31
+ sign_out:
32
+ type: boolean
33
+ description: Whether currently signed in clients should be signed out. Default is `false`
34
+ default: false
31
35
  required:
32
36
  - uid
33
37
  - password
34
38
  - new_password
39
+ example:
40
+ uid: mbwosl8h0z77i9jxhxht3uyq
41
+ password: OldPassword1#
42
+ new_password: NewPassword2$
43
+ sign_out: false
35
44
  responses:
36
45
  200:
37
46
  description: If the password change is successful, returns an object with a new access token
@@ -110,10 +110,11 @@
110
110
  description: The exact error code
111
111
  enum:
112
112
  - invalid_token
113
+ - expired_token
113
114
  - not_found
114
115
  - duplicate
115
- - token_mismatch
116
116
  - wrong_password
117
+ - invalid_method
117
118
  example: not_found
118
119
  message:
119
120
  type: string