@base44-preview/cli 0.1.27-pr.653.981b966 → 0.1.29-pr.655.1f8f35a

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/cli/index.js CHANGED
@@ -239374,7 +239374,7 @@ import { join as join13 } from "node:path";
239374
239374
  // package.json
239375
239375
  var package_default = {
239376
239376
  name: "base44",
239377
- version: "0.1.27",
239377
+ version: "0.1.29",
239378
239378
  description: "Base44 CLI - Unified interface for managing Base44 applications",
239379
239379
  type: "module",
239380
239380
  bin: {
@@ -261311,7 +261311,7 @@ function shardOf(group, response, verdict, options) {
261311
261311
  gzipBytes: verdict.gzipBytes,
261312
261312
  ...response.activation ? { activation: response.activation } : {},
261313
261313
  wrapper: {
261314
- secrets: response.activation ? `blob-${response.activation}` : "binding",
261314
+ secrets: response.activation ? `blob_${response.activation}` : "binding",
261315
261315
  postResponseTelemetry: options.postResponseTelemetry ?? false,
261316
261316
  staticEgress: STATIC_EGRESS_ARTIFACT_MARKER
261317
261317
  }
@@ -264179,7 +264179,7 @@ In order to complete registration use this verification code: ${otpCode}
264179
264179
  is_verified: true,
264180
264180
  disabled: null,
264181
264181
  role: "user",
264182
- collaborator_role: "editor",
264182
+ collaborator_role: null,
264183
264183
  created_date: now,
264184
264184
  updated_date: now
264185
264185
  });
@@ -264198,6 +264198,7 @@ In order to complete registration use this verification code: ${otpCode}
264198
264198
  var import_express4 = __toESM(require_express(), 1);
264199
264199
 
264200
264200
  // src/cli/dev/dev-server/db/rls.ts
264201
+ import { isDeepStrictEqual as isDeepStrictEqual5 } from "node:util";
264201
264202
  function getRLSFieldValue(key, source) {
264202
264203
  const DATA_FIELD_PREFIX = "data.";
264203
264204
  return source[key.startsWith(DATA_FIELD_PREFIX) ? key.slice(DATA_FIELD_PREFIX.length) : key];
@@ -264315,6 +264316,23 @@ function applyFLS(record, schema, user, operation) {
264315
264316
  return result;
264316
264317
  }
264317
264318
 
264319
+ class FLSWriteError extends Error {
264320
+ constructor(operation, deniedFields) {
264321
+ const verb = operation === "create" ? "set" : "modify";
264322
+ super(`You're not allowed to ${verb} the following fields: ${deniedFields.join(", ")}`);
264323
+ }
264324
+ }
264325
+ function assertFLSWrite(changes, context, schema, user, operation) {
264326
+ const denied = Object.entries(changes).filter(([key, value]) => {
264327
+ const rls = schema.properties[key]?.rls;
264328
+ const rule = rls?.[operation] ?? rls?.write;
264329
+ return rule !== undefined && !isDeepStrictEqual5(context[key], value) && !checkRLS(rule, context, user);
264330
+ }).map(([key]) => `data.${key}`);
264331
+ if (denied.length > 0) {
264332
+ throw new FLSWriteError(operation, denied);
264333
+ }
264334
+ }
264335
+
264318
264336
  // src/cli/dev/dev-server/db/entity-queries.ts
264319
264337
  function parseSort(sort) {
264320
264338
  if (!sort) {
@@ -264486,6 +264504,10 @@ function createUserRouter(db, logger) {
264486
264504
  id
264487
264505
  });
264488
264506
  if (userRecord) {
264507
+ if (id !== currentUser.id && currentUser.collaborator_role !== "editor" && !currentUser.is_service) {
264508
+ res.status(403).json({ message: "You are not authorized to update this user" });
264509
+ return;
264510
+ }
264489
264511
  try {
264490
264512
  const { id: _id, created_date: _created_date, ...body } = req.body;
264491
264513
  const filteredBody = db.prepareRecord(USER_COLLECTION, body, true);
@@ -264495,6 +264517,7 @@ function createUserRouter(db, logger) {
264495
264517
  allowedFields[key] = property;
264496
264518
  }
264497
264519
  }
264520
+ assertFLSWrite(allowedFields, { ...userRecord, created_by: userRecord.email }, db.getSchema(USER_COLLECTION), currentUser, "update");
264498
264521
  db.validate(USER_COLLECTION, allowedFields, true);
264499
264522
  const updateData = {
264500
264523
  ...allowedFields,
@@ -264510,6 +264533,10 @@ function createUserRouter(db, logger) {
264510
264533
  res.status(422).json(error.context);
264511
264534
  return;
264512
264535
  }
264536
+ if (error instanceof FLSWriteError) {
264537
+ res.status(403).json({ message: error.message });
264538
+ return;
264539
+ }
264513
264540
  logger.error(`Error in PUT /${USER_COLLECTION}/${req.params.id}:`, error);
264514
264541
  res.status(500).json({ error: "Internal server error" });
264515
264542
  }
@@ -264572,7 +264599,8 @@ async function createEntityRoutes(db, logger, broadcast) {
264572
264599
  }, currentUser)) {
264573
264600
  return;
264574
264601
  }
264575
- const filteredBody = applyFLS(db.prepareRecord(entityName, recordBody), schema, currentUser, "write");
264602
+ assertFLSWrite(recordBody, ownerFields, schema, currentUser, "create");
264603
+ const filteredBody = db.prepareRecord(entityName, recordBody);
264576
264604
  db.validate(entityName, filteredBody);
264577
264605
  return {
264578
264606
  ...filteredBody,
@@ -264640,6 +264668,10 @@ async function createEntityRoutes(db, logger, broadcast) {
264640
264668
  res.status(422).json(error.context);
264641
264669
  return;
264642
264670
  }
264671
+ if (error instanceof FLSWriteError) {
264672
+ res.status(403).json({ message: error.message });
264673
+ return;
264674
+ }
264643
264675
  logger.error(`Error in POST /${entityName}:`, error);
264644
264676
  res.status(500).json({ error: "Internal server error" });
264645
264677
  }
@@ -264669,6 +264701,10 @@ async function createEntityRoutes(db, logger, broadcast) {
264669
264701
  res.status(422).json(error.context);
264670
264702
  return;
264671
264703
  }
264704
+ if (error instanceof FLSWriteError) {
264705
+ res.status(403).json({ message: error.message });
264706
+ return;
264707
+ }
264672
264708
  logger.error(`Error in POST /${entityName}/bulk:`, error);
264673
264709
  res.status(500).json({ error: "Internal server error" });
264674
264710
  }
@@ -264677,20 +264713,19 @@ async function createEntityRoutes(db, logger, broadcast) {
264677
264713
  const { appId, entityName, id } = req.params;
264678
264714
  const { id: _id, created_date: _created_date, ...body } = req.body;
264679
264715
  try {
264680
- if (schema.rls?.update !== undefined) {
264681
- const existing = await collection.findOneAsync({ id });
264682
- if (!existing) {
264683
- res.status(404).json({ error: `Record with id "${id}" not found` });
264684
- return;
264685
- }
264686
- if (!checkRLS(schema.rls.update, existing, currentUser)) {
264687
- res.status(404).json({
264688
- message: `Entity ${entityName} with ID ${id} not found`
264689
- });
264690
- return;
264691
- }
264716
+ const existing = await collection.findOneAsync({ id });
264717
+ if (!existing) {
264718
+ res.status(404).json({ error: `Record with id "${id}" not found` });
264719
+ return;
264692
264720
  }
264693
- const filteredBody = applyFLS(db.prepareRecord(entityName, body, true), schema, currentUser, "write");
264721
+ if (!checkRLS(schema.rls?.update, existing, currentUser)) {
264722
+ res.status(404).json({
264723
+ message: `Entity ${entityName} with ID ${id} not found`
264724
+ });
264725
+ return;
264726
+ }
264727
+ const filteredBody = db.prepareRecord(entityName, body, true);
264728
+ assertFLSWrite(filteredBody, existing, schema, currentUser, "update");
264694
264729
  db.validate(entityName, filteredBody, true);
264695
264730
  const updateData = {
264696
264731
  ...filteredBody,
@@ -264709,6 +264744,10 @@ async function createEntityRoutes(db, logger, broadcast) {
264709
264744
  res.status(422).json(error.context);
264710
264745
  return;
264711
264746
  }
264747
+ if (error instanceof FLSWriteError) {
264748
+ res.status(403).json({ message: error.message });
264749
+ return;
264750
+ }
264712
264751
  logger.error(`Error in PUT /${entityName}/${id}:`, error);
264713
264752
  res.status(500).json({ error: "Internal server error" });
264714
264753
  }
@@ -271221,4 +271260,4 @@ export {
271221
271260
  runCLI
271222
271261
  };
271223
271262
 
271224
- //# debugId=0A00CB7F15CA88CB64756E2164756E21
271263
+ //# debugId=E5E7C98F673394D264756E2164756E21