@constructive-io/graphql-server 5.20.7 → 5.20.8

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.
@@ -174,10 +174,16 @@ const buildPreset = (pool, schemas, anonRole, roleName, databaseSettings, apiId,
174
174
  'jwt.claims.principal_id': headerActorId,
175
175
  ...context
176
176
  };
177
+ // The entity pair travels together: the tenant's writers reject an
178
+ // entity id whose type they cannot interpret (`ENTITY_TYPE_REQUIRED`).
177
179
  const headerEntityId = req.get('X-Entity-Id');
180
+ const headerEntityType = req.get('X-Entity-Type');
178
181
  if (headerEntityId) {
179
182
  pgSettings['jwt.claims.entity_id'] = headerEntityId;
180
183
  }
184
+ if (headerEntityType) {
185
+ pgSettings['jwt.claims.entity_type'] = headerEntityType;
186
+ }
181
187
  const headerOrganizationId = req.get('X-Organization-Id');
182
188
  if (headerOrganizationId) {
183
189
  pgSettings['jwt.claims.organization_id'] = headerOrganizationId;
@@ -188,11 +194,20 @@ const buildPreset = (pool, schemas, anonRole, roleName, databaseSettings, apiId,
188
194
  return { pgSettings };
189
195
  }
190
196
  }
197
+ // No actor to name, so the tenant database the request addresses carries
198
+ // the attribution — the same rule the sync gateway applies to a request
199
+ // that arrives without a credential. Without it the tenant's own writers
200
+ // refuse the work an anonymous request legitimately does
201
+ // (`ATTRIBUTION_REQUIRED`), so a public mutation cannot enqueue a job.
191
202
  const anonSettings = {
192
203
  ...timeouts,
193
204
  role: anonRole,
194
205
  ...context
195
206
  };
207
+ if (req?.databaseId) {
208
+ anonSettings['jwt.claims.entity_id'] = req.databaseId;
209
+ anonSettings['jwt.claims.entity_type'] = 'database';
210
+ }
196
211
  if (req?.requestId) {
197
212
  anonSettings['request.id'] = req.requestId;
198
213
  }
@@ -180,10 +180,16 @@ const buildPreset = (pool, schemas, anonRole, roleName, databaseSettings, apiId,
180
180
  'jwt.claims.principal_id': headerActorId,
181
181
  ...context
182
182
  };
183
+ // The entity pair travels together: the tenant's writers reject an
184
+ // entity id whose type they cannot interpret (`ENTITY_TYPE_REQUIRED`).
183
185
  const headerEntityId = req.get('X-Entity-Id');
186
+ const headerEntityType = req.get('X-Entity-Type');
184
187
  if (headerEntityId) {
185
188
  pgSettings['jwt.claims.entity_id'] = headerEntityId;
186
189
  }
190
+ if (headerEntityType) {
191
+ pgSettings['jwt.claims.entity_type'] = headerEntityType;
192
+ }
187
193
  const headerOrganizationId = req.get('X-Organization-Id');
188
194
  if (headerOrganizationId) {
189
195
  pgSettings['jwt.claims.organization_id'] = headerOrganizationId;
@@ -194,11 +200,20 @@ const buildPreset = (pool, schemas, anonRole, roleName, databaseSettings, apiId,
194
200
  return { pgSettings };
195
201
  }
196
202
  }
203
+ // No actor to name, so the tenant database the request addresses carries
204
+ // the attribution — the same rule the sync gateway applies to a request
205
+ // that arrives without a credential. Without it the tenant's own writers
206
+ // refuse the work an anonymous request legitimately does
207
+ // (`ATTRIBUTION_REQUIRED`), so a public mutation cannot enqueue a job.
197
208
  const anonSettings = {
198
209
  ...timeouts,
199
210
  role: anonRole,
200
211
  ...context
201
212
  };
213
+ if (req?.databaseId) {
214
+ anonSettings['jwt.claims.entity_id'] = req.databaseId;
215
+ anonSettings['jwt.claims.entity_type'] = 'database';
216
+ }
202
217
  if (req?.requestId) {
203
218
  anonSettings['request.id'] = req.requestId;
204
219
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constructive-io/graphql-server",
3
- "version": "5.20.7",
3
+ "version": "5.20.8",
4
4
  "author": "Constructive <developers@constructive.io>",
5
5
  "description": "Constructive GraphQL Server",
6
6
  "main": "index.js",
@@ -96,5 +96,5 @@
96
96
  "supertest": "^7.2.2",
97
97
  "ts-node": "^10.9.2"
98
98
  },
99
- "gitHead": "5e0bfead2856d1a062b495d343a43e543343f9b8"
99
+ "gitHead": "4deb5b9a00ead37453857d24274007255092822e"
100
100
  }