@flowerforce/flowerbase 1.7.3-beta.1 → 1.7.3-beta.3

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.
@@ -1 +1 @@
1
- {"version":3,"file":"jwt.d.ts","sourceRoot":"","sources":["../../../src/auth/plugins/jwt.ts"],"names":[],"mappings":"AAKA,KAAK,OAAO,GAAG;IACb,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AAQD;;;;;;;GAOG;iUAC8C,OAAO;AAAxD,wBA4GE"}
1
+ {"version":3,"file":"jwt.d.ts","sourceRoot":"","sources":["../../../src/auth/plugins/jwt.ts"],"names":[],"mappings":"AAKA,KAAK,OAAO,GAAG;IACb,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AAeD;;;;;;;GAOG;iUAC8C,OAAO;AAAxD,wBA4GE"}
@@ -16,6 +16,12 @@ const jwt_1 = __importDefault(require("@fastify/jwt"));
16
16
  const fastify_plugin_1 = __importDefault(require("fastify-plugin"));
17
17
  const mongodb_1 = require("mongodb");
18
18
  const constants_1 = require("../../constants");
19
+ const unauthorizedSessionError = {
20
+ message: 'Unauthorized',
21
+ error: 'unauthorized',
22
+ errorCode: 'InvalidSession',
23
+ error_code: 'InvalidSession'
24
+ };
19
25
  /**
20
26
  * This module is a Fastify plugin that sets up JWT-based authentication and token creation.
21
27
  * It registers JWT authentication, and provides methods to create access and refresh tokens.
@@ -38,7 +44,7 @@ exports.default = (0, fastify_plugin_1.default)(function (fastify, opts) {
38
44
  }
39
45
  catch (err) {
40
46
  fastify.log.warn({ err }, 'JWT authentication failed');
41
- reply.code(401).send({ message: 'Unauthorized' });
47
+ reply.code(401).send(unauthorizedSessionError);
42
48
  return;
43
49
  }
44
50
  if (((_a = request.user) === null || _a === void 0 ? void 0 : _a.typ) !== 'access') {
@@ -50,7 +56,7 @@ exports.default = (0, fastify_plugin_1.default)(function (fastify, opts) {
50
56
  return;
51
57
  }
52
58
  if (!request.user.sub) {
53
- reply.code(401).send({ message: 'Unauthorized' });
59
+ reply.code(401).send(unauthorizedSessionError);
54
60
  return;
55
61
  }
56
62
  let authUser;
@@ -61,11 +67,11 @@ exports.default = (0, fastify_plugin_1.default)(function (fastify, opts) {
61
67
  }
62
68
  catch (err) {
63
69
  fastify.log.warn({ err }, 'Failed to lookup user during JWT authentication');
64
- reply.code(401).send({ message: 'Unauthorized' });
70
+ reply.code(401).send(unauthorizedSessionError);
65
71
  return;
66
72
  }
67
73
  if (!authUser) {
68
- reply.code(401).send({ message: 'Unauthorized' });
74
+ reply.code(401).send(unauthorizedSessionError);
69
75
  return;
70
76
  }
71
77
  const lastLogoutAt = authUser.lastLogoutAt ? new Date(authUser.lastLogoutAt) : null;
@@ -81,7 +87,7 @@ exports.default = (0, fastify_plugin_1.default)(function (fastify, opts) {
81
87
  typeof issuedAt === 'number' &&
82
88
  !Number.isNaN(issuedAt) &&
83
89
  lastLogoutAt.getTime() >= issuedAt * 1000) {
84
- reply.code(401).send({ message: 'Unauthorized' });
90
+ reply.code(401).send(unauthorizedSessionError);
85
91
  return;
86
92
  }
87
93
  });
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/mongodb-atlas/index.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAyC,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAysCrF,QAAA,MAAM,YAAY,EAAE,oBA6BlB,CAAA;AAEF,eAAe,YAAY,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/mongodb-atlas/index.ts"],"names":[],"mappings":"AAuBA,OAAO,EAGL,oBAAoB,EAErB,MAAM,SAAS,CAAA;AA0tChB,QAAA,MAAM,YAAY,EAAE,oBA6BlB,CAAA;AAEF,eAAe,YAAY,CAAA"}
@@ -8,15 +8,26 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
+ var __rest = (this && this.__rest) || function (s, e) {
12
+ var t = {};
13
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
14
+ t[p] = s[p];
15
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
16
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
17
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
18
+ t[p[i]] = s[p[i]];
19
+ }
20
+ return t;
21
+ };
11
22
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
23
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
24
  };
14
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
+ const cloneDeep_1 = __importDefault(require("lodash/cloneDeep"));
15
27
  const get_1 = __importDefault(require("lodash/get"));
16
28
  const isEqual_1 = __importDefault(require("lodash/isEqual"));
17
29
  const set_1 = __importDefault(require("lodash/set"));
18
30
  const unset_1 = __importDefault(require("lodash/unset"));
19
- const cloneDeep_1 = __importDefault(require("lodash/cloneDeep"));
20
31
  const utils_1 = require("../../monitoring/utils");
21
32
  const machines_1 = require("../../utils/roles/machines");
22
33
  const utils_2 = require("../../utils/roles/machines/utils");
@@ -92,6 +103,15 @@ const normalizeInsertManyResult = (result) => {
92
103
  return result;
93
104
  return Object.assign(Object.assign({}, result), { insertedIds: Object.values(result.insertedIds) });
94
105
  };
106
+ const normalizeFindOneAndUpdateOptions = (options) => {
107
+ if (!options)
108
+ return undefined;
109
+ const { returnNewDocument } = options, rest = __rest(options, ["returnNewDocument"]);
110
+ if (typeof returnNewDocument !== 'boolean' || typeof rest.returnDocument !== 'undefined') {
111
+ return rest;
112
+ }
113
+ return Object.assign(Object.assign({}, rest), { returnDocument: returnNewDocument ? 'after' : 'before' });
114
+ };
95
115
  const hasAtomicOperators = (data) => Object.keys(data).some((key) => key.startsWith('$'));
96
116
  const normalizeUpdatePayload = (data) => hasAtomicOperators(data) ? data : { $set: data };
97
117
  const hasOperatorExpressions = (value) => isPlainObject(value) && Object.keys(value).some((key) => key.startsWith('$'));
@@ -569,6 +589,7 @@ const getOperators = (collection, { rules, collName, user, run_as_system, monito
569
589
  findOneAndUpdate: (query, data, options) => __awaiter(void 0, void 0, void 0, function* () {
570
590
  var _a;
571
591
  try {
592
+ const normalizedOptions = normalizeFindOneAndUpdateOptions(options);
572
593
  if (!run_as_system) {
573
594
  (0, utils_3.checkDenyOperation)(normalizedRules, collection.collectionName, model_1.CRUD_OPERATIONS.UPDATE);
574
595
  const formattedQuery = (0, utils_3.getFormattedQuery)(filters, query, user);
@@ -605,8 +626,8 @@ const getOperators = (collection, { rules, collName, user, run_as_system, monito
605
626
  if (!status || !areDocumentsEqual) {
606
627
  throw new Error('Update not permitted');
607
628
  }
608
- const updateResult = options
609
- ? yield collection.findOneAndUpdate({ $and: safeQuery }, normalizedData, options)
629
+ const updateResult = normalizedOptions
630
+ ? yield collection.findOneAndUpdate({ $and: safeQuery }, normalizedData, normalizedOptions)
610
631
  : yield collection.findOneAndUpdate({ $and: safeQuery }, normalizedData);
611
632
  if (!updateResult) {
612
633
  emitMongoEvent('findOneAndUpdate');
@@ -625,8 +646,8 @@ const getOperators = (collection, { rules, collName, user, run_as_system, monito
625
646
  emitMongoEvent('findOneAndUpdate');
626
647
  return sanitizedDoc;
627
648
  }
628
- const updateResult = options
629
- ? yield collection.findOneAndUpdate(query, data, options)
649
+ const updateResult = normalizedOptions
650
+ ? yield collection.findOneAndUpdate(query, data, normalizedOptions)
630
651
  : yield collection.findOneAndUpdate(query, data);
631
652
  emitMongoEvent('findOneAndUpdate');
632
653
  return updateResult;
@@ -29,11 +29,11 @@ export type GetOperatorsFunction = (collection: Collection<Document>, { rules, c
29
29
  collName: string;
30
30
  monitoringOrigin?: string;
31
31
  }) => {
32
+ findOneAndUpdate: (filter: MongoFilter<Document>, update: UpdateFilter<Document> | Document[], options?: RealmCompatibleFindOneAndUpdateOptions) => Promise<Document | null>;
32
33
  findOne: (filter?: MongoFilter<Document>, projection?: Document, options?: FindOneOptions) => ReturnType<Method<'findOne'>>;
33
34
  deleteOne: (...params: Parameters<Method<'deleteOne'>>) => ReturnType<Method<'deleteOne'>>;
34
35
  insertOne: (...params: Parameters<Method<'insertOne'>>) => ReturnType<Method<'insertOne'>>;
35
36
  updateOne: (...params: Parameters<Method<'updateOne'>>) => ReturnType<Method<'updateOne'>>;
36
- findOneAndUpdate: (filter: MongoFilter<Document>, update: UpdateFilter<Document> | Document[], options?: FindOneAndUpdateOptions) => Promise<Document | null>;
37
37
  find: (filter?: MongoFilter<Document>, projection?: Document, options?: FindOptions) => FindCursor;
38
38
  count: (...params: Parameters<Method<'countDocuments'>>) => ReturnType<Method<'countDocuments'>>;
39
39
  countDocuments: (...params: Parameters<Method<'countDocuments'>>) => ReturnType<Method<'countDocuments'>>;
@@ -43,6 +43,9 @@ export type GetOperatorsFunction = (collection: Collection<Document>, { rules, c
43
43
  updateMany: (...params: Parameters<Method<'updateMany'>>) => ReturnType<Method<'updateMany'>>;
44
44
  deleteMany: (...params: Parameters<Method<'deleteMany'>>) => ReturnType<Method<'deleteMany'>>;
45
45
  };
46
+ export type RealmCompatibleFindOneAndUpdateOptions = FindOneAndUpdateOptions & {
47
+ returnNewDocument?: boolean;
48
+ };
46
49
  export declare enum CRUD_OPERATIONS {
47
50
  CREATE = "CREATE",
48
51
  READ = "READ",
@@ -1 +1 @@
1
- {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../../src/services/mongodb-atlas/model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AACzC,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,UAAU,EACV,QAAQ,EACR,UAAU,EACV,uBAAuB,EACvB,cAAc,EACd,WAAW,EACX,MAAM,IAAI,WAAW,EACrB,YAAY,EACZ,MAAM,EACP,MAAM,SAAS,CAAA;AAChB,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AACtC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AAC,gBAAgB,CAAC,CAAC,CAAA;IACzC,cAAc,EAAE,CACd,GAAG,MAAM,EAAE,UAAU,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,KAC5C,UAAU,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAA;IACzC,KAAK,EAAE,CAAC,GAAG,MAAM,EAAE,UAAU,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,UAAU,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAA;IAC9E,SAAS,EAAE,CACT,GAAG,MAAM,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,KAC/D,UAAU,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAA;IACpC,UAAU,EAAE,CACV,GAAG,MAAM,EAAE,UAAU,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,KACxC,UAAU,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAA;IACrC,UAAU,EAAE,CACV,GAAG,MAAM,EAAE,UAAU,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,KACxC,UAAU,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAA;IACrC,UAAU,EAAE,CACV,GAAG,MAAM,EAAE,UAAU,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,KACxC,UAAU,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAA;CACtC,CAAA;AAED,MAAM,MAAM,sCAAsC,GAAG,uBAAuB,GAAG;IAC7E,iBAAiB,CAAC,EAAE,OAAO,CAAA;CAC5B,CAAA;AAGD,oBAAY,eAAe;IACzB,MAAM,WAAW;IACjB,IAAI,SAAS;IACb,MAAM,WAAW;IACjB,MAAM,WAAW;CAElB"}
@@ -15,7 +15,7 @@ type JwtUtils = {
15
15
  * @param currentFunction -> the function's name that should be called
16
16
  * @param functionsList -> the list of all functions
17
17
  */
18
- export declare const generateContextData: ({ user, services, app, rules, currentFunction, functionName, functionsList, GenerateContext, GenerateContextSync, request }: GenerateContextDataParams) => {
18
+ export declare const generateContextData: ({ user, services, app, rules, currentFunction, functionName, functionsList, GenerateContextSync, request }: GenerateContextDataParams) => {
19
19
  BSON: typeof mongodb.BSON;
20
20
  EJSON: {
21
21
  parse: (text: string, options?: mongodb.BSON.EJSONOptions) => any;
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/utils/context/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAE1C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAE3C,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAA;AAGvD,KAAK,QAAQ,GAAG;IACd,MAAM,EAAE,CACN,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,GAAG,MAAM,EACvB,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KACzC,MAAM,CAAA;IACX,MAAM,EAAE,CACN,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,MAAM,GAAG,MAAM,EACpB,YAAY,CAAC,EAAE,OAAO,EACtB,sBAAsB,CAAC,EAAE,MAAM,EAAE,KAC9B,OAAO,CAAA;CACb,CAAA;AAgFD;;;;;;;;;GASG;AACH,eAAO,MAAM,mBAAmB,GAAI,6HAWjC,yBAAyB;;;;;;;;;;;;;uBA4DP,SAAS;yBAGP,SAAS;;;;;;;;;;;;;;;;;;uBAcb,MAAM;;;;;;+BA5CU,MAAM,OAAO,QAAQ;;;;sCA3HrC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8BAsG+B,CAAC;iCAC5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;yBAGP,SAAS;;;;;;;;;;;;;;;;;;uBAcb,MAAM;;;;;;+BA5CU,MAAM,OAAO,QAAQ;;;;sCA1HrC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8BAsGT,CAAC;iCAAa,CAAC;;;;;;;;;;;;;;;;;;;kCAtGP,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BAsGT,CAAC;6BAAa,CAAC;;;;;;;;;;;;;;;;;;kCAtGP,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BAsGT,CAAC;6BAAa,CAAC;;;;;;;;;;;;;;;4BAyEF,MAAM,OAAO,aAAa,WAAW,SAAS;;;CAiBrE,CAAA"}
@@ -35,8 +35,8 @@ var __importStar = (this && this.__importStar) || (function () {
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.generateContextData = void 0;
37
37
  const mongodb_1 = require("@fastify/mongodb");
38
- const jwt = __importStar(require("jsonwebtoken"));
39
38
  const bson_1 = require("bson");
39
+ const jwt = __importStar(require("jsonwebtoken"));
40
40
  const normalizePayload = (payload) => {
41
41
  if (typeof payload !== 'string')
42
42
  return payload;
@@ -108,7 +108,7 @@ const createJwtUtils = () => {
108
108
  * @param currentFunction -> the function's name that should be called
109
109
  * @param functionsList -> the list of all functions
110
110
  */
111
- const generateContextData = ({ user, services, app, rules, currentFunction, functionName, functionsList, GenerateContext, GenerateContextSync, request }) => {
111
+ const generateContextData = ({ user, services, app, rules, currentFunction, functionName, functionsList, GenerateContextSync, request }) => {
112
112
  var _a;
113
113
  const BSON = mongodb_1.mongodb.BSON;
114
114
  const Binary = BSON === null || BSON === void 0 ? void 0 : BSON.Binary;
@@ -185,7 +185,8 @@ const generateContextData = ({ user, services, app, rules, currentFunction, func
185
185
  currentFunction,
186
186
  functionName: String(name),
187
187
  functionsList,
188
- services
188
+ services,
189
+ deserializeArgs: false
189
190
  });
190
191
  }
191
192
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowerforce/flowerbase",
3
- "version": "1.7.3-beta.1",
3
+ "version": "1.7.3-beta.3",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -40,6 +40,13 @@ describe('jwtAuthentication', () => {
40
40
  await app.close()
41
41
  })
42
42
 
43
+ const unauthorizedSessionError = {
44
+ message: 'Unauthorized',
45
+ error: 'unauthorized',
46
+ errorCode: 'InvalidSession',
47
+ error_code: 'InvalidSession'
48
+ }
49
+
43
50
  const setupMongo = (userPayload: { _id: ObjectId; lastLogoutAt?: Date }) => {
44
51
  const findOneMock = jest.fn().mockResolvedValue(userPayload)
45
52
  const collectionMock = { findOne: findOneMock }
@@ -88,6 +95,20 @@ describe('jwtAuthentication', () => {
88
95
  await app.jwtAuthentication(request as any, reply)
89
96
 
90
97
  expect(reply.code).toHaveBeenCalledWith(401)
91
- expect(reply.send).toHaveBeenCalledWith({ message: 'Unauthorized' })
98
+ expect(reply.send).toHaveBeenCalledWith(unauthorizedSessionError)
99
+ })
100
+
101
+ it('returns Realm-compatible unauthorized payload when jwt verification fails', async () => {
102
+ const request = {
103
+ jwtVerify: jest.fn(async () => {
104
+ throw new Error('jwt expired')
105
+ })
106
+ }
107
+ const reply = createReply()
108
+
109
+ await app.jwtAuthentication(request as any, reply)
110
+
111
+ expect(reply.code).toHaveBeenCalledWith(401)
112
+ expect(reply.send).toHaveBeenCalledWith(unauthorizedSessionError)
92
113
  })
93
114
  })
@@ -13,6 +13,13 @@ type JwtAccessWithTimestamp = {
13
13
  iat?: number
14
14
  }
15
15
 
16
+ const unauthorizedSessionError = {
17
+ message: 'Unauthorized',
18
+ error: 'unauthorized',
19
+ errorCode: 'InvalidSession',
20
+ error_code: 'InvalidSession'
21
+ } as const
22
+
16
23
  /**
17
24
  * This module is a Fastify plugin that sets up JWT-based authentication and token creation.
18
25
  * It registers JWT authentication, and provides methods to create access and refresh tokens.
@@ -33,7 +40,7 @@ export default fp(async function (fastify, opts: Options) {
33
40
  await request.jwtVerify()
34
41
  } catch (err) {
35
42
  fastify.log.warn({ err }, 'JWT authentication failed')
36
- reply.code(401).send({ message: 'Unauthorized' })
43
+ reply.code(401).send(unauthorizedSessionError)
37
44
  return
38
45
  }
39
46
 
@@ -48,7 +55,7 @@ export default fp(async function (fastify, opts: Options) {
48
55
  }
49
56
 
50
57
  if (!request.user.sub) {
51
- reply.code(401).send({ message: 'Unauthorized' })
58
+ reply.code(401).send(unauthorizedSessionError)
52
59
  return
53
60
  }
54
61
 
@@ -59,12 +66,12 @@ export default fp(async function (fastify, opts: Options) {
59
66
  .findOne({ _id: new ObjectId(request.user.sub) })
60
67
  } catch (err) {
61
68
  fastify.log.warn({ err }, 'Failed to lookup user during JWT authentication')
62
- reply.code(401).send({ message: 'Unauthorized' })
69
+ reply.code(401).send(unauthorizedSessionError)
63
70
  return
64
71
  }
65
72
 
66
73
  if (!authUser) {
67
- reply.code(401).send({ message: 'Unauthorized' })
74
+ reply.code(401).send(unauthorizedSessionError)
68
75
  return
69
76
  }
70
77
 
@@ -84,7 +91,7 @@ export default fp(async function (fastify, opts: Options) {
84
91
  !Number.isNaN(issuedAt) &&
85
92
  lastLogoutAt.getTime() >= issuedAt * 1000
86
93
  ) {
87
- reply.code(401).send({ message: 'Unauthorized' })
94
+ reply.code(401).send(unauthorizedSessionError)
88
95
  return
89
96
  }
90
97
  })
@@ -91,4 +91,38 @@ describe('mongodb-atlas findOneAndUpdate', () => {
91
91
  ).rejects.toThrow('Update not permitted')
92
92
  expect(findOneAndUpdate).not.toHaveBeenCalled()
93
93
  })
94
+
95
+ it('maps returnNewDocument=true to returnDocument=after', async () => {
96
+ const id = new ObjectId()
97
+ const existingDoc = { _id: id, value: 100, userId: 'user-1' }
98
+ const updatedDoc = { _id: id, value: 101, userId: 'user-1' }
99
+ const findOne = jest.fn().mockResolvedValue(existingDoc)
100
+ const findOneAndUpdate = jest.fn().mockResolvedValue(updatedDoc)
101
+ const collection = {
102
+ collectionName: 'todos',
103
+ findOne,
104
+ findOneAndUpdate
105
+ }
106
+
107
+ const app = createAppWithCollection(collection)
108
+ const operators = MongoDbAtlas(app as any, {
109
+ rules: createRules(),
110
+ user: { id: 'user-1' }
111
+ })
112
+ .db('db')
113
+ .collection('todos')
114
+
115
+ const result = await operators.findOneAndUpdate(
116
+ { _id: id },
117
+ { $inc: { value: 1 } },
118
+ { returnNewDocument: true } as any
119
+ )
120
+
121
+ expect(result).toEqual(updatedDoc)
122
+ expect(findOneAndUpdate).toHaveBeenCalledWith(
123
+ { $and: [{ _id: id }] },
124
+ { $inc: { value: 1 } },
125
+ { returnDocument: 'after' }
126
+ )
127
+ })
94
128
  })
@@ -153,6 +153,31 @@ describe('mongodb-atlas Realm compatibility', () => {
153
153
  expect(aggregate).not.toHaveBeenCalled()
154
154
  })
155
155
 
156
+ it('supports Realm returnNewDocument option in findOneAndUpdate', async () => {
157
+ const id = new ObjectId()
158
+ const findOneAndUpdate = jest.fn().mockResolvedValue({ _id: id, value: 101 })
159
+ const collection = {
160
+ collectionName: 'todos',
161
+ findOneAndUpdate
162
+ }
163
+ const operators = MongoDbAtlas(createAppWithCollection(collection) as any, {
164
+ run_as_system: true
165
+ }).db('db').collection('todos')
166
+
167
+ const result = await operators.findOneAndUpdate(
168
+ { _id: id },
169
+ { $inc: { value: 1 } } as any,
170
+ { returnNewDocument: true } as any
171
+ )
172
+
173
+ expect(result).toEqual({ _id: id, value: 101 })
174
+ expect(findOneAndUpdate).toHaveBeenCalledWith(
175
+ { _id: id },
176
+ { $inc: { value: 1 } },
177
+ { returnDocument: 'after' }
178
+ )
179
+ })
180
+
156
181
  it('supports operator updates in updateMany without using invalid aggregate stages', async () => {
157
182
  const id = new ObjectId()
158
183
  const find = jest.fn().mockReturnValue({
@@ -1,17 +1,17 @@
1
+ import cloneDeep from 'lodash/cloneDeep'
1
2
  import get from 'lodash/get'
2
3
  import isEqual from 'lodash/isEqual'
3
4
  import set from 'lodash/set'
4
5
  import unset from 'lodash/unset'
5
- import cloneDeep from 'lodash/cloneDeep'
6
6
  import {
7
7
  ClientSession,
8
8
  ClientSessionOptions,
9
9
  Collection,
10
10
  Document,
11
11
  EventsDescription,
12
+ FindOneAndUpdateOptions,
12
13
  FindOneOptions,
13
14
  FindOptions,
14
- FindOneAndUpdateOptions,
15
15
  Filter as MongoFilter,
16
16
  UpdateFilter,
17
17
  WithId
@@ -21,7 +21,12 @@ import { buildRulesMeta } from '../../monitoring/utils'
21
21
  import { checkValidation } from '../../utils/roles/machines'
22
22
  import { getWinningRole } from '../../utils/roles/machines/utils'
23
23
  import { emitServiceEvent } from '../monitoring'
24
- import { CRUD_OPERATIONS, GetOperatorsFunction, MongodbAtlasFunction } from './model'
24
+ import {
25
+ CRUD_OPERATIONS,
26
+ GetOperatorsFunction,
27
+ MongodbAtlasFunction,
28
+ RealmCompatibleFindOneAndUpdateOptions
29
+ } from './model'
25
30
  import {
26
31
  applyAccessControlToPipeline,
27
32
  checkDenyOperation,
@@ -115,6 +120,22 @@ const normalizeInsertManyResult = <T extends { insertedIds?: Record<string, unkn
115
120
  }
116
121
  }
117
122
 
123
+ const normalizeFindOneAndUpdateOptions = (
124
+ options?: RealmCompatibleFindOneAndUpdateOptions
125
+ ): FindOneAndUpdateOptions | undefined => {
126
+ if (!options) return undefined
127
+
128
+ const { returnNewDocument, ...rest } = options
129
+ if (typeof returnNewDocument !== 'boolean' || typeof rest.returnDocument !== 'undefined') {
130
+ return rest
131
+ }
132
+
133
+ return {
134
+ ...rest,
135
+ returnDocument: returnNewDocument ? 'after' : 'before'
136
+ }
137
+ }
138
+
118
139
  const hasAtomicOperators = (data: Document) => Object.keys(data).some((key) => key.startsWith('$'))
119
140
 
120
141
  const normalizeUpdatePayload = (data: Document) =>
@@ -653,9 +674,10 @@ const getOperators: GetOperatorsFunction = (
653
674
  findOneAndUpdate: async (
654
675
  query: MongoFilter<Document>,
655
676
  data: UpdateFilter<Document> | Document[],
656
- options?: FindOneAndUpdateOptions
677
+ options?: RealmCompatibleFindOneAndUpdateOptions
657
678
  ) => {
658
679
  try {
680
+ const normalizedOptions = normalizeFindOneAndUpdateOptions(options)
659
681
  if (!run_as_system) {
660
682
  checkDenyOperation(normalizedRules, collection.collectionName, CRUD_OPERATIONS.UPDATE)
661
683
  const formattedQuery = getFormattedQuery(filters, query, user)
@@ -702,8 +724,8 @@ const getOperators: GetOperatorsFunction = (
702
724
  throw new Error('Update not permitted')
703
725
  }
704
726
 
705
- const updateResult = options
706
- ? await collection.findOneAndUpdate({ $and: safeQuery }, normalizedData, options)
727
+ const updateResult = normalizedOptions
728
+ ? await collection.findOneAndUpdate({ $and: safeQuery }, normalizedData, normalizedOptions)
707
729
  : await collection.findOneAndUpdate({ $and: safeQuery }, normalizedData)
708
730
  if (!updateResult) {
709
731
  emitMongoEvent('findOneAndUpdate')
@@ -729,8 +751,8 @@ const getOperators: GetOperatorsFunction = (
729
751
  return sanitizedDoc
730
752
  }
731
753
 
732
- const updateResult = options
733
- ? await collection.findOneAndUpdate(query, data, options)
754
+ const updateResult = normalizedOptions
755
+ ? await collection.findOneAndUpdate(query, data, normalizedOptions)
734
756
  : await collection.findOneAndUpdate(query, data)
735
757
  emitMongoEvent('findOneAndUpdate')
736
758
  return updateResult
@@ -59,6 +59,11 @@ export type GetOperatorsFunction = (
59
59
  monitoringOrigin?: string
60
60
  }
61
61
  ) => {
62
+ findOneAndUpdate: (
63
+ filter: MongoFilter<Document>,
64
+ update: UpdateFilter<Document> | Document[],
65
+ options?: RealmCompatibleFindOneAndUpdateOptions
66
+ ) => Promise<Document | null>
62
67
  findOne: (
63
68
  filter?: MongoFilter<Document>,
64
69
  projection?: Document,
@@ -71,11 +76,6 @@ export type GetOperatorsFunction = (
71
76
  updateOne: (
72
77
  ...params: Parameters<Method<'updateOne'>>
73
78
  ) => ReturnType<Method<'updateOne'>>
74
- findOneAndUpdate: (
75
- filter: MongoFilter<Document>,
76
- update: UpdateFilter<Document> | Document[],
77
- options?: FindOneAndUpdateOptions
78
- ) => Promise<Document | null>
79
79
  find: (
80
80
  filter?: MongoFilter<Document>,
81
81
  projection?: Document,
@@ -102,6 +102,10 @@ export type GetOperatorsFunction = (
102
102
  ) => ReturnType<Method<'deleteMany'>>
103
103
  }
104
104
 
105
+ export type RealmCompatibleFindOneAndUpdateOptions = FindOneAndUpdateOptions & {
106
+ returnNewDocument?: boolean
107
+ }
108
+
105
109
 
106
110
  export enum CRUD_OPERATIONS {
107
111
  CREATE = "CREATE",
@@ -57,4 +57,38 @@ describe('context.functions.execute compatibility', () => {
57
57
  expect(result && typeof (result as Promise<unknown>).then).toBe('function')
58
58
  await expect(result).resolves.toEqual({ ok: true })
59
59
  })
60
+
61
+ it('passes circular native objects without EJSON deserialization', () => {
62
+ const functionsList = {
63
+ caller: {
64
+ code: `
65
+ module.exports = function() {
66
+ const session = { tx: true }
67
+ session.client = { sessionPool: { client: session } }
68
+ return context.functions.execute("target", session)
69
+ }
70
+ `
71
+ },
72
+ target: {
73
+ code: `
74
+ module.exports = function(session) {
75
+ return session.client.sessionPool.client === session
76
+ }
77
+ `
78
+ }
79
+ } as Functions
80
+
81
+ const result = GenerateContextSync({
82
+ args: [],
83
+ app: {} as any,
84
+ rules: {} as any,
85
+ user: {} as any,
86
+ currentFunction: functionsList.caller,
87
+ functionsList,
88
+ services: mockServices,
89
+ functionName: 'caller'
90
+ })
91
+
92
+ expect(result).toBe(true)
93
+ })
60
94
  })
@@ -1,9 +1,9 @@
1
1
  import { mongodb } from '@fastify/mongodb'
2
+ import { EJSON } from 'bson'
2
3
  import * as jwt from 'jsonwebtoken'
3
4
  import { Arguments } from '../../auth/dtos'
4
5
  import { Function } from '../../features/functions/interface'
5
6
  import { GenerateContextDataParams } from './interface'
6
- import { EJSON } from 'bson'
7
7
 
8
8
  type JwtUtils = {
9
9
  encode: (
@@ -116,7 +116,6 @@ export const generateContextData = ({
116
116
  currentFunction,
117
117
  functionName,
118
118
  functionsList,
119
- GenerateContext,
120
119
  GenerateContextSync,
121
120
  request
122
121
  }: GenerateContextDataParams) => {
@@ -215,7 +214,8 @@ export const generateContextData = ({
215
214
  currentFunction,
216
215
  functionName: String(name),
217
216
  functionsList,
218
- services
217
+ services,
218
+ deserializeArgs: false
219
219
  })
220
220
  }
221
221
  }