@friggframework/core 2.0.0--canary.684.e113124.0 → 2.0.0--canary.684.bfb48ef.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.
@@ -534,10 +534,14 @@ function setEntityRoutes(router, authenticateUser, useCases) {
534
534
  router.route('/api/authorize').get(
535
535
  catchAsyncError(async (req, res) => {
536
536
  const user = await authenticateUser.execute(req);
537
- const userId = user.getId();
538
537
  const params = checkRequiredParams(req.query, ['entityType']);
538
+ // The owner POST stores under, so GET and POST describe one connection.
539
+ const { ownerId } = authorizeEntityForUser.resolveOwnership({
540
+ user,
541
+ entityType: params.entityType,
542
+ });
539
543
  const module = await getModuleInstanceFromType.execute(
540
- userId,
544
+ ownerId,
541
545
  params.entityType,
542
546
  { state: req.query.state }
543
547
  );
@@ -373,14 +373,15 @@ class ModuleRepositoryDocumentDB extends ModuleRepositoryInterface {
373
373
  _mapEntity(doc, credential) {
374
374
  const dynamicData = doc?.data || {};
375
375
  return {
376
+ // First, so no stored provider field can replace a column below
377
+ // (identity, owner or organization decide who sees the entity).
378
+ ...dynamicData,
376
379
  id: fromObjectId(doc?._id),
377
380
  credential,
378
381
  userId: fromObjectId(doc?.userId),
379
382
  name: doc?.name ?? null,
380
383
  externalId: doc?.externalId ?? null,
381
384
  moduleName: doc?.moduleName ?? null,
382
- ...dynamicData,
383
- // After the spread: a provider field of the same name must not decide visibility.
384
385
  organizationId: fromObjectId(doc?.organizationId) ?? null,
385
386
  };
386
387
  }
@@ -79,19 +79,20 @@ class ModuleRepositoryMongo extends ModuleRepositoryInterface {
79
79
 
80
80
  /**
81
81
  * The one place a stored entity row becomes the entity the application sees.
82
- * `organizationId` comes after the entity data: a provider field of the same
83
- * name must not decide who sees the entity.
82
+ * The provider's `data` is spread FIRST and every column is pinned after it:
83
+ * a stored `id`, `userId` or `organizationId` in `data` must not decide who
84
+ * owns the entity or who sees it.
84
85
  * @private
85
86
  */
86
87
  _mapEntity(row, credential) {
87
88
  return {
89
+ ...(row.data || {}),
88
90
  id: row.id,
89
91
  credential,
90
92
  userId: row.userId,
91
93
  name: row.name,
92
94
  externalId: row.externalId,
93
95
  moduleName: row.moduleName,
94
- ...(row.data || {}),
95
96
  organizationId: row.organizationId ?? null,
96
97
  };
97
98
  }
@@ -110,19 +110,20 @@ class ModuleRepositoryPostgres extends ModuleRepositoryInterface {
110
110
 
111
111
  /**
112
112
  * The one place a stored entity row becomes the entity the application sees.
113
- * `organizationId` comes after the entity data: a provider field of the same
114
- * name must not decide who sees the entity.
113
+ * The provider's `data` is spread FIRST and every column is pinned after it:
114
+ * a stored `id`, `userId` or `organizationId` in `data` must not decide who
115
+ * owns the entity or who sees it.
115
116
  * @private
116
117
  */
117
118
  _mapEntity(row, credential) {
118
119
  return {
120
+ ...(row.data || {}),
119
121
  id: row.id.toString(),
120
122
  credential,
121
123
  userId: row.userId?.toString(),
122
124
  name: row.name,
123
125
  externalId: row.externalId,
124
126
  moduleName: row.moduleName,
125
- ...(row.data || {}),
126
127
  organizationId: row.organizationId?.toString() ?? null,
127
128
  };
128
129
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@friggframework/core",
3
3
  "prettier": "@friggframework/prettier-config",
4
- "version": "2.0.0--canary.684.e113124.0",
4
+ "version": "2.0.0--canary.684.bfb48ef.0",
5
5
  "dependencies": {
6
6
  "@aws-sdk/client-apigatewaymanagementapi": "^3.588.0",
7
7
  "@aws-sdk/client-kms": "^3.588.0",
@@ -48,9 +48,9 @@
48
48
  }
49
49
  },
50
50
  "devDependencies": {
51
- "@friggframework/eslint-config": "2.0.0--canary.684.e113124.0",
52
- "@friggframework/prettier-config": "2.0.0--canary.684.e113124.0",
53
- "@friggframework/test": "2.0.0--canary.684.e113124.0",
51
+ "@friggframework/eslint-config": "2.0.0--canary.684.bfb48ef.0",
52
+ "@friggframework/prettier-config": "2.0.0--canary.684.bfb48ef.0",
53
+ "@friggframework/test": "2.0.0--canary.684.bfb48ef.0",
54
54
  "@prisma/client": "^6.19.3",
55
55
  "@types/lodash": "4.17.15",
56
56
  "@typescript-eslint/eslint-plugin": "^8.0.0",
@@ -90,5 +90,5 @@
90
90
  "publishConfig": {
91
91
  "access": "public"
92
92
  },
93
- "gitHead": "e1131240a890bf30cfee08ba3786458c9e2d1135"
93
+ "gitHead": "bfb48ef7325e5052da0628e130ee6a77807d544e"
94
94
  }