@rebasepro/server-postgres 0.9.1-canary.eab7ae2 → 0.9.1-canary.ed943fa
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.
- package/dist/index.es.js +22 -3
- package/dist/index.es.js.map +1 -1
- package/dist/schema/doctor.d.ts +1 -1
- package/dist/security/policy-drift.d.ts +30 -0
- package/package.json +7 -6
- package/src/cli.ts +60 -0
- package/src/schema/doctor.ts +45 -20
- package/src/security/policy-drift.test.ts +106 -1
- package/src/security/policy-drift.ts +56 -0
- package/src/services/row-pipeline.ts +27 -3
package/dist/index.es.js
CHANGED
|
@@ -6524,8 +6524,27 @@ function coerceDeclaredNumbers(row, collection) {
|
|
|
6524
6524
|
return out;
|
|
6525
6525
|
}
|
|
6526
6526
|
/** Render one target row in the requested style. */
|
|
6527
|
+
/**
|
|
6528
|
+
* Drop every column the collection marked `excludeFromApi`.
|
|
6529
|
+
*
|
|
6530
|
+
* Password hashes and verification tokens have to be readable server-side but
|
|
6531
|
+
* must never reach a client — and "never" has to mean every exit from this
|
|
6532
|
+
* pipeline, including relation targets, or a secret leaks through whichever
|
|
6533
|
+
* path was overlooked. Keyed by both the property name and its column name,
|
|
6534
|
+
* since a row can arrive keyed either way depending on the caller.
|
|
6535
|
+
*/
|
|
6536
|
+
function stripExcluded(row, collection) {
|
|
6537
|
+
const properties = collection.properties;
|
|
6538
|
+
if (!properties) return row;
|
|
6539
|
+
for (const [key, property] of Object.entries(properties)) {
|
|
6540
|
+
if (!property?.excludeFromApi) continue;
|
|
6541
|
+
delete row[key];
|
|
6542
|
+
if (property.columnName) delete row[property.columnName];
|
|
6543
|
+
}
|
|
6544
|
+
return row;
|
|
6545
|
+
}
|
|
6527
6546
|
function renderTarget(targetRow, targetCollection, style, registry) {
|
|
6528
|
-
if (style === "inline") return coerceDeclaredNumbers({ ...targetRow }, targetCollection);
|
|
6547
|
+
if (style === "inline") return stripExcluded(coerceDeclaredNumbers({ ...targetRow }, targetCollection), targetCollection);
|
|
6529
6548
|
const address = relationTargetAddress(targetRow, targetCollection, registry);
|
|
6530
6549
|
const path = targetCollection.slug;
|
|
6531
6550
|
return createRelationRefWithData(address, path, {
|
|
@@ -6567,7 +6586,7 @@ function toCmsRow(row, collection, registry) {
|
|
|
6567
6586
|
normalized[key] = relData.map((item) => renderTarget(isJunctionRelation(relation) ? unwrapJunctionRow(item) : item, targetCollection, "ref", registry));
|
|
6568
6587
|
} else if (relation.cardinality === "one" && typeof relData === "object" && !Array.isArray(relData)) normalized[key] = renderTarget(relData, relation.target(), "ref", registry);
|
|
6569
6588
|
}
|
|
6570
|
-
return normalized;
|
|
6589
|
+
return stripExcluded(normalized, collection);
|
|
6571
6590
|
}
|
|
6572
6591
|
/**
|
|
6573
6592
|
* The row REST serves: every column under its own name, with the value Postgres
|
|
@@ -6592,7 +6611,7 @@ function toRestRow(row, collection, registry) {
|
|
|
6592
6611
|
else if (relation && typeof value === "object" && value !== null) flat[key] = renderTarget(value, relation.target(), "inline", registry);
|
|
6593
6612
|
else flat[key] = coerceDeclaredNumber(value, collection.properties?.[key]);
|
|
6594
6613
|
}
|
|
6595
|
-
return flat;
|
|
6614
|
+
return stripExcluded(flat, collection);
|
|
6596
6615
|
}
|
|
6597
6616
|
//#endregion
|
|
6598
6617
|
//#region src/services/FetchService.ts
|