@base44-preview/cli 0.0.50-pr.475.9d797d7 → 0.0.50-pr.475.feeb89c

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
@@ -243244,6 +243244,7 @@ var package_default = {
243244
243244
  typescript: "^5.7.2",
243245
243245
  vitest: "^4.0.16",
243246
243246
  yaml: "^2.8.2",
243247
+ qs: "^6.12.3",
243247
243248
  zod: "^4.3.5"
243248
243249
  },
243249
243250
  engines: {
@@ -253321,6 +253322,7 @@ class Validator {
253321
253322
 
253322
253323
  // src/cli/dev/dev-server/db/database.ts
253323
253324
  var USER_COLLECTION = "user";
253325
+ var PRIVATE_COLLECTION_PREFIX = "$";
253324
253326
 
253325
253327
  class Database {
253326
253328
  collections = new Map;
@@ -253342,6 +253344,7 @@ class Database {
253342
253344
  this.schemas.set(USER_COLLECTION, this.buildUserSchema(userEntity));
253343
253345
  const collection = new import_nedb.default;
253344
253346
  this.collections.set(USER_COLLECTION, collection);
253347
+ this.collections.set(PRIVATE_COLLECTION_PREFIX + USER_COLLECTION, new import_nedb.default);
253345
253348
  const userInfo = await readAuth();
253346
253349
  const now = getNowISOTimestamp();
253347
253350
  await collection.insertAsync({
@@ -253383,7 +253386,9 @@ class Database {
253383
253386
  return this.collections.get(this.normalizeName(name2));
253384
253387
  }
253385
253388
  getCollectionNames() {
253386
- return Array.from(this.collections.keys());
253389
+ return Array.from(this.collections.keys()).filter((name2) => {
253390
+ return !name2.startsWith(PRIVATE_COLLECTION_PREFIX);
253391
+ });
253387
253392
  }
253388
253393
  dropAll() {
253389
253394
  for (const collection of this.collections.values()) {
@@ -253460,26 +253465,30 @@ var createJwtToken = (email3) => {
253460
253465
  expiresIn: "360d"
253461
253466
  });
253462
253467
  };
253463
- var UserRegiterSchema = object({
253464
- id: string2(),
253465
- email: email2(),
253466
- otpCode: string2().length(6),
253467
- password: string2().min(8),
253468
- createdAt: number2().min(1)
253469
- });
253470
253468
  function createAuthRouter(db2, logger2) {
253471
253469
  const router = import_express2.Router({ mergeParams: true });
253472
- const userRegitrPendingMap = new Map;
253470
+ const userRegistrPendingMap = new Map;
253473
253471
  const parseBody = import_express2.json();
253474
253472
  router.post("/login", parseBody, async (req, res) => {
253475
- const { email: email3, password: _password } = req.body;
253473
+ const { email: email3, password } = req.body;
253476
253474
  const result = await db2.getCollection(USER_COLLECTION)?.findOneAsync({ email: email3 });
253477
253475
  if (result) {
253478
- res.json({
253479
- access_token: createJwtToken(email3),
253480
- success: true,
253481
- user: {}
253482
- });
253476
+ const registeredUserData = userRegistrPendingMap.get(email3);
253477
+ if (result.role === "admin" || registeredUserData?.password === password) {
253478
+ res.json({
253479
+ access_token: createJwtToken(email3),
253480
+ success: true,
253481
+ user: {}
253482
+ });
253483
+ } else {
253484
+ res.status(400).json({
253485
+ detail: "Invalid email or password",
253486
+ error_type: "HTTPException",
253487
+ message: "Invalid email or password",
253488
+ request_id: null,
253489
+ traceback: ""
253490
+ });
253491
+ }
253483
253492
  return;
253484
253493
  }
253485
253494
  res.status(401).json({ error: "Unauthorized" });
@@ -253509,7 +253518,7 @@ function createAuthRouter(db2, logger2) {
253509
253518
  }
253510
253519
  const otpCode = generateCode();
253511
253520
  const id2 = nanoid3();
253512
- userRegitrPendingMap.set(email3, {
253521
+ userRegistrPendingMap.set(email3, {
253513
253522
  id: id2,
253514
253523
  email: email3,
253515
253524
  otpCode,
@@ -253527,9 +253536,10 @@ In order to complete registration use this verification code: ${otpCode}
253527
253536
  });
253528
253537
  router.post("/verify-otp", parseBody, async (req, res) => {
253529
253538
  const { email: email3, otp_code } = req.body;
253530
- const userData = userRegitrPendingMap.get(email3);
253539
+ const userData = userRegistrPendingMap.get(email3);
253531
253540
  if (userData && userData.otpCode === otp_code) {
253532
253541
  if (+Date.now() - userData.createdAt < 10 * 60 * 1000) {
253542
+ userData.otpCode = undefined;
253533
253543
  const collection = db2.getCollection(USER_COLLECTION);
253534
253544
  const now = getNowISOTimestamp();
253535
253545
  const nameFromEmailMatch = /^([^@]+)/.exec(email3);
@@ -255715,7 +255725,7 @@ class WatchBase44 extends EventEmitter4 {
255715
255725
  var DEFAULT_PORT = 4400;
255716
255726
  var BASE44_APP_URL = "https://base44.app";
255717
255727
  async function createDevServer(options8) {
255718
- const { port: userPort, cwd } = options8;
255728
+ const { port: userPort } = options8;
255719
255729
  const port = userPort ?? await getPorts({ port: DEFAULT_PORT });
255720
255730
  const baseUrl = `http://localhost:${port}`;
255721
255731
  const { functions, entities, project: project2 } = await options8.loadResources();
@@ -260359,4 +260369,4 @@ export {
260359
260369
  CLIExitError
260360
260370
  };
260361
260371
 
260362
- //# debugId=5FDDF606296BF31964756E2164756E21
260372
+ //# debugId=F5DEA59E4A91DAEE64756E2164756E21