@base44-preview/cli 0.0.41-pr.251.81e7ce8 → 0.0.41-pr.379.099a4e6

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
@@ -18062,7 +18062,7 @@ var require_lodash = __commonJS((exports, module) => {
18062
18062
  function nth(array2, n2) {
18063
18063
  return array2 && array2.length ? baseNth(array2, toInteger(n2)) : undefined2;
18064
18064
  }
18065
- var pull2 = baseRest(pullAll);
18065
+ var pull = baseRest(pullAll);
18066
18066
  function pullAll(array2, values2) {
18067
18067
  return array2 && array2.length && values2 && values2.length ? basePullAll(array2, values2) : array2;
18068
18068
  }
@@ -19827,7 +19827,7 @@ __p += '`;
19827
19827
  lodash.pickBy = pickBy;
19828
19828
  lodash.property = property;
19829
19829
  lodash.propertyOf = propertyOf;
19830
- lodash.pull = pull2;
19830
+ lodash.pull = pull;
19831
19831
  lodash.pullAll = pullAll;
19832
19832
  lodash.pullAllBy = pullAllBy;
19833
19833
  lodash.pullAllWith = pullAllWith;
@@ -230612,10 +230612,6 @@ var GoogleBigQueryConnectorSchema = exports_external.object({
230612
230612
  type: exports_external.literal("googlebigquery"),
230613
230613
  scopes: exports_external.array(exports_external.string()).default([])
230614
230614
  });
230615
- var StripeConnectorSchema = exports_external.object({
230616
- type: exports_external.literal("stripe"),
230617
- scopes: exports_external.array(exports_external.string()).default([])
230618
- });
230619
230615
  var CustomTypeSchema = exports_external.string().min(1).regex(/^[a-z0-9_-]+$/i);
230620
230616
  var GenericConnectorSchema = exports_external.object({
230621
230617
  type: CustomTypeSchema,
@@ -230635,7 +230631,6 @@ var ConnectorResourceSchema = exports_external.union([
230635
230631
  HubspotConnectorSchema,
230636
230632
  LinkedInConnectorSchema,
230637
230633
  TikTokConnectorSchema,
230638
- StripeConnectorSchema,
230639
230634
  GenericConnectorSchema
230640
230635
  ]);
230641
230636
  var KnownIntegrationTypes = [
@@ -230651,8 +230646,7 @@ var KnownIntegrationTypes = [
230651
230646
  "salesforce",
230652
230647
  "hubspot",
230653
230648
  "linkedin",
230654
- "tiktok",
230655
- "stripe"
230649
+ "tiktok"
230656
230650
  ];
230657
230651
  var IntegrationTypeSchema = exports_external.union([
230658
230652
  exports_external.enum(KnownIntegrationTypes),
@@ -230705,18 +230699,6 @@ var RemoveConnectorResponseSchema = exports_external.object({
230705
230699
  status: data.status,
230706
230700
  integrationType: data.integration_type
230707
230701
  }));
230708
- var STRIPE_CONNECTOR_TYPE = "stripe";
230709
- var InstallStripeResponseSchema = exports_external.object({
230710
- already_installed: exports_external.boolean(),
230711
- claim_url: exports_external.string().nullable()
230712
- });
230713
- var StripeStatusResponseSchema = exports_external.object({
230714
- stripe_mode: exports_external.enum(["sandbox", "live"]).nullable(),
230715
- sandbox_claim_url: exports_external.string().nullable().optional()
230716
- });
230717
- var RemoveStripeResponseSchema = exports_external.object({
230718
- success: exports_external.boolean()
230719
- });
230720
230702
 
230721
230703
  // src/core/resources/connector/api.ts
230722
230704
  async function listConnectors() {
@@ -230784,54 +230766,6 @@ async function removeConnector(integrationType) {
230784
230766
  }
230785
230767
  return result.data;
230786
230768
  }
230787
- async function installStripe() {
230788
- const appClient = getAppClient();
230789
- let response;
230790
- try {
230791
- response = await appClient.post("payments/stripe/install", {
230792
- timeout: 60000
230793
- });
230794
- } catch (error48) {
230795
- throw await ApiError.fromHttpError(error48, "installing Stripe");
230796
- }
230797
- const result = InstallStripeResponseSchema.safeParse(await response.json());
230798
- if (!result.success) {
230799
- throw new SchemaValidationError("Invalid response from server", result.error);
230800
- }
230801
- return result.data;
230802
- }
230803
- async function getStripeStatus() {
230804
- const appClient = getAppClient();
230805
- let response;
230806
- try {
230807
- response = await appClient.get("payments/stripe/status", {
230808
- timeout: 60000
230809
- });
230810
- } catch (error48) {
230811
- throw await ApiError.fromHttpError(error48, "checking Stripe integration status");
230812
- }
230813
- const result = StripeStatusResponseSchema.safeParse(await response.json());
230814
- if (!result.success) {
230815
- throw new SchemaValidationError("Invalid response from server", result.error);
230816
- }
230817
- return result.data;
230818
- }
230819
- async function removeStripe() {
230820
- const appClient = getAppClient();
230821
- let response;
230822
- try {
230823
- response = await appClient.delete("payments/stripe", {
230824
- timeout: 60000
230825
- });
230826
- } catch (error48) {
230827
- throw await ApiError.fromHttpError(error48, "removing Stripe integration");
230828
- }
230829
- const result = RemoveStripeResponseSchema.safeParse(await response.json());
230830
- if (!result.success) {
230831
- throw new SchemaValidationError("Invalid response from server", result.error);
230832
- }
230833
- return result.data;
230834
- }
230835
230769
  // src/core/resources/connector/config.ts
230836
230770
  import { join as join4 } from "node:path";
230837
230771
  import { isDeepStrictEqual as isDeepStrictEqual2 } from "node:util";
@@ -230880,7 +230814,7 @@ async function readAllConnectors(connectorsDir) {
230880
230814
  async function writeConnectors(connectorsDir, remoteConnectors) {
230881
230815
  const entries = await readConnectorFiles(connectorsDir);
230882
230816
  const typeToEntry = buildTypeToEntryMap(entries);
230883
- const newTypes = new Set(remoteConnectors.map((c) => c.type));
230817
+ const newTypes = new Set(remoteConnectors.map((c) => c.integrationType));
230884
230818
  const deleted = [];
230885
230819
  for (const [type, entry] of typeToEntry) {
230886
230820
  if (!newTypes.has(type)) {
@@ -230890,44 +230824,22 @@ async function writeConnectors(connectorsDir, remoteConnectors) {
230890
230824
  }
230891
230825
  const written = [];
230892
230826
  for (const connector of remoteConnectors) {
230893
- const existing = typeToEntry.get(connector.type);
230894
- if (existing && isDeepStrictEqual2(existing.data, connector)) {
230827
+ const existing = typeToEntry.get(connector.integrationType);
230828
+ const localConnector = {
230829
+ type: connector.integrationType,
230830
+ scopes: connector.scopes
230831
+ };
230832
+ if (existing && isDeepStrictEqual2(existing.data, localConnector)) {
230895
230833
  continue;
230896
230834
  }
230897
- const filePath = existing?.filePath ?? join4(connectorsDir, `${connector.type}.${CONFIG_FILE_EXTENSION}`);
230898
- await writeJsonFile(filePath, connector);
230899
- written.push(connector.type);
230835
+ const filePath = existing?.filePath ?? join4(connectorsDir, `${connector.integrationType}.${CONFIG_FILE_EXTENSION}`);
230836
+ await writeJsonFile(filePath, localConnector);
230837
+ written.push(connector.integrationType);
230900
230838
  }
230901
230839
  return { written, deleted };
230902
230840
  }
230903
- // src/core/resources/connector/pull.ts
230904
- async function pullAllConnectors() {
230905
- const [oauthResponse, stripeStatus] = await Promise.all([
230906
- listConnectors(),
230907
- getStripeStatus()
230908
- ]);
230909
- const connectors = oauthResponse.integrations.map((i) => ({
230910
- type: i.integrationType,
230911
- scopes: i.scopes
230912
- }));
230913
- if (stripeStatus.stripe_mode !== null) {
230914
- connectors.push({ type: STRIPE_CONNECTOR_TYPE, scopes: [] });
230915
- }
230916
- return connectors;
230917
- }
230918
230841
  // src/core/resources/connector/push.ts
230919
230842
  async function pushConnectors(connectors) {
230920
- const stripeConnector = connectors.find((c) => c.type === STRIPE_CONNECTOR_TYPE);
230921
- const oauthConnectors = connectors.filter((c) => c.type !== STRIPE_CONNECTOR_TYPE);
230922
- const oauthResults = await syncOAuthConnectors(oauthConnectors);
230923
- const stripeResult = await syncStripeConnector(stripeConnector);
230924
- const results = [...oauthResults];
230925
- if (stripeResult) {
230926
- results.push(stripeResult);
230927
- }
230928
- return { results };
230929
- }
230930
- async function syncOAuthConnectors(connectors) {
230931
230843
  const results = [];
230932
230844
  const upstream = await listConnectors();
230933
230845
  const localTypes = new Set(connectors.map((c) => c.type));
@@ -230960,62 +230872,7 @@ async function syncOAuthConnectors(connectors) {
230960
230872
  }
230961
230873
  }
230962
230874
  }
230963
- return results;
230964
- }
230965
- async function syncStripeConnector(localStripe) {
230966
- const remoteStatus = await fetchStripeRemoteStatus();
230967
- if (remoteStatus === "error") {
230968
- return localStripe ? stripeError("Failed to check Stripe integration status") : null;
230969
- }
230970
- const isRemoteInstalled = remoteStatus.stripe_mode !== null;
230971
- const needsInstall = localStripe && !isRemoteInstalled;
230972
- const alreadySynced = localStripe && isRemoteInstalled;
230973
- const needsRemoval = !localStripe && isRemoteInstalled;
230974
- if (needsInstall) {
230975
- return handleStripeInstall();
230976
- }
230977
- if (alreadySynced) {
230978
- return stripeSynced();
230979
- }
230980
- if (needsRemoval) {
230981
- return handleStripeRemoval();
230982
- }
230983
- return null;
230984
- }
230985
- async function fetchStripeRemoteStatus() {
230986
- try {
230987
- return await getStripeStatus();
230988
- } catch {
230989
- return "error";
230990
- }
230991
- }
230992
- async function handleStripeInstall() {
230993
- try {
230994
- const result = await installStripe();
230995
- return stripeProvisioned(result.claim_url ?? undefined);
230996
- } catch (err) {
230997
- return stripeError(err instanceof Error ? err.message : String(err));
230998
- }
230999
- }
231000
- async function handleStripeRemoval() {
231001
- try {
231002
- await removeStripe();
231003
- return stripeRemoved();
231004
- } catch (err) {
231005
- return stripeError(err instanceof Error ? err.message : String(err));
231006
- }
231007
- }
231008
- function stripeSynced() {
231009
- return { type: STRIPE_CONNECTOR_TYPE, action: "synced" };
231010
- }
231011
- function stripeProvisioned(claimUrl) {
231012
- return { type: STRIPE_CONNECTOR_TYPE, action: "provisioned", claimUrl };
231013
- }
231014
- function stripeRemoved() {
231015
- return { type: STRIPE_CONNECTOR_TYPE, action: "removed" };
231016
- }
231017
- function stripeError(error48) {
231018
- return { type: STRIPE_CONNECTOR_TYPE, action: "error", error: error48 };
230875
+ return { results };
231019
230876
  }
231020
230877
  function getConnectorSyncResult(type, response) {
231021
230878
  if (response.error === "different_user") {
@@ -231033,7 +230890,7 @@ function getConnectorSyncResult(type, response) {
231033
230890
  type,
231034
230891
  action: "needs_oauth",
231035
230892
  redirectUrl: response.redirectUrl,
231036
- connectionId: response.connectionId ?? ""
230893
+ connectionId: response.connectionId ?? undefined
231037
230894
  };
231038
230895
  }
231039
230896
  return { type, action: "synced" };
@@ -239530,10 +239387,6 @@ function getDashboardUrl(projectId) {
239530
239387
  const id = projectId ?? getAppConfig().id;
239531
239388
  return `${getBase44ApiUrl()}/apps/${id}/editor/workspace/overview`;
239532
239389
  }
239533
- function getConnectorsUrl(projectId) {
239534
- const id = projectId ?? getAppConfig().id;
239535
- return `${getBase44ApiUrl()}/apps/${id}/editor/workspace/app-connections`;
239536
- }
239537
239390
  // src/cli/commands/agents/pull.ts
239538
239391
  async function pullAgentsAction() {
239539
239392
  const { project: project2 } = await readProjectConfig();
@@ -239638,13 +239491,13 @@ async function pullConnectorsAction() {
239638
239491
  const configDir = dirname8(project2.configPath);
239639
239492
  const connectorsDir = join11(configDir, project2.connectorsDir);
239640
239493
  const remoteConnectors = await runTask("Fetching connectors from Base44", async () => {
239641
- return await pullAllConnectors();
239494
+ return await listConnectors();
239642
239495
  }, {
239643
239496
  successMessage: "Connectors fetched successfully",
239644
239497
  errorMessage: "Failed to fetch connectors"
239645
239498
  });
239646
239499
  const { written, deleted } = await runTask("Syncing connector files", async () => {
239647
- return await writeConnectors(connectorsDir, remoteConnectors);
239500
+ return await writeConnectors(connectorsDir, remoteConnectors.integrations);
239648
239501
  }, {
239649
239502
  successMessage: "Connector files synced successfully",
239650
239503
  errorMessage: "Failed to sync connector files"
@@ -239659,7 +239512,7 @@ async function pullConnectorsAction() {
239659
239512
  R2.info("All connectors are already up to date");
239660
239513
  }
239661
239514
  return {
239662
- outroMessage: `Pulled ${remoteConnectors.length} connectors to ${connectorsDir}`
239515
+ outroMessage: `Pulled ${remoteConnectors.integrations.length} connectors to ${connectorsDir}`
239663
239516
  };
239664
239517
  }
239665
239518
  function getConnectorsPullCommand(context) {
@@ -240278,7 +240131,7 @@ var open_default = open;
240278
240131
  var POLL_INTERVAL_MS = 2000;
240279
240132
  var POLL_TIMEOUT_MS = 2 * 60 * 1000;
240280
240133
  function filterPendingOAuth(results) {
240281
- return results.filter((r) => r.action === "needs_oauth" && !!r.connectionId);
240134
+ return results.filter((r) => r.action === "needs_oauth" && !!r.redirectUrl && !!r.connectionId);
240282
240135
  }
240283
240136
  async function runOAuthFlowWithSkip(connector2) {
240284
240137
  await open_default(connector2.redirectUrl);
@@ -240358,49 +240211,32 @@ async function promptOAuthFlows(pending, options) {
240358
240211
  function printSummary(results, oauthOutcomes) {
240359
240212
  const synced = [];
240360
240213
  const added = [];
240361
- let provisioned;
240362
240214
  const removed = [];
240363
240215
  const skipped = [];
240364
240216
  const failed = [];
240365
240217
  for (const r of results) {
240366
- switch (r.action) {
240367
- case "provisioned":
240368
- provisioned = r;
240369
- break;
240370
- case "synced":
240371
- synced.push(r.type);
240372
- break;
240373
- case "removed":
240374
- removed.push(r.type);
240375
- break;
240376
- case "error":
240377
- failed.push({ type: r.type, error: r.error });
240378
- break;
240379
- case "needs_oauth": {
240380
- const oauthStatus = oauthOutcomes.get(r.type);
240381
- if (oauthStatus === "ACTIVE") {
240382
- added.push(r.type);
240383
- } else if (oauthStatus === "SKIPPED") {
240384
- skipped.push(r.type);
240385
- } else if (oauthStatus === "PENDING") {
240386
- failed.push({ type: r.type, error: "authorization timed out" });
240387
- } else if (oauthStatus === "FAILED") {
240388
- failed.push({ type: r.type, error: "authorization failed" });
240389
- } else {
240390
- failed.push({ type: r.type, error: "needs authorization" });
240391
- }
240392
- break;
240218
+ const oauthStatus = oauthOutcomes.get(r.type);
240219
+ if (r.action === "synced") {
240220
+ synced.push(r.type);
240221
+ } else if (r.action === "removed") {
240222
+ removed.push(r.type);
240223
+ } else if (r.action === "error") {
240224
+ failed.push({ type: r.type, error: r.error });
240225
+ } else if (r.action === "needs_oauth") {
240226
+ if (oauthStatus === "ACTIVE") {
240227
+ added.push(r.type);
240228
+ } else if (oauthStatus === "SKIPPED") {
240229
+ skipped.push(r.type);
240230
+ } else if (oauthStatus === "PENDING") {
240231
+ failed.push({ type: r.type, error: "authorization timed out" });
240232
+ } else if (oauthStatus === "FAILED") {
240233
+ failed.push({ type: r.type, error: "authorization failed" });
240234
+ } else {
240235
+ failed.push({ type: r.type, error: "needs authorization" });
240393
240236
  }
240394
240237
  }
240395
240238
  }
240396
240239
  R2.info(theme.styles.bold("Summary:"));
240397
- if (provisioned) {
240398
- R2.success("Stripe sandbox provisioned");
240399
- if (provisioned.claimUrl) {
240400
- R2.info(` Claim your Stripe sandbox: ${theme.colors.links(provisioned.claimUrl)}`);
240401
- }
240402
- R2.info(` Connectors dashboard: ${theme.colors.links(getConnectorsUrl())}`);
240403
- }
240404
240240
  if (synced.length > 0) {
240405
240241
  R2.success(`Synced: ${synced.join(", ")}`);
240406
240242
  }
@@ -240414,7 +240250,7 @@ function printSummary(results, oauthOutcomes) {
240414
240250
  R2.warn(`Skipped: ${skipped.join(", ")}`);
240415
240251
  }
240416
240252
  for (const r of failed) {
240417
- R2.error(`Failed: ${r.type} - ${r.error}`);
240253
+ R2.error(`Failed: ${r.type}${r.error ? ` - ${r.error}` : ""}`);
240418
240254
  }
240419
240255
  }
240420
240256
  async function pushConnectorsAction(isNonInteractive) {
@@ -240448,7 +240284,7 @@ function getConnectorsPushCommand(context) {
240448
240284
 
240449
240285
  // src/cli/commands/connectors/index.ts
240450
240286
  function getConnectorsCommand(context) {
240451
- return new Command("connectors").description("Manage project connectors").addCommand(getConnectorsPullCommand(context)).addCommand(getConnectorsPushCommand(context));
240287
+ return new Command("connectors").description("Manage project connectors (OAuth integrations)").addCommand(getConnectorsPullCommand(context)).addCommand(getConnectorsPushCommand(context));
240452
240288
  }
240453
240289
 
240454
240290
  // src/cli/commands/dashboard/open.ts
@@ -240762,11 +240598,15 @@ ${summaryLines.join(`
240762
240598
  successMessage: theme.colors.base44Orange("Deployment completed"),
240763
240599
  errorMessage: "Deployment failed"
240764
240600
  });
240765
- const connectorResults = result.connectorResults ?? [];
240766
- await handleOAuthConnectors(connectorResults, options);
240767
- const stripeResult = connectorResults.find((r) => r.action === "provisioned");
240768
- if (stripeResult) {
240769
- printStripeResult(stripeResult);
240601
+ const needsOAuth = filterPendingOAuth(result.connectorResults ?? []);
240602
+ if (needsOAuth.length > 0) {
240603
+ const oauthOutcomes = await promptOAuthFlows(needsOAuth, {
240604
+ skipPrompt: options.yes || options.isNonInteractive
240605
+ });
240606
+ const allAuthorized = oauthOutcomes.size > 0 && [...oauthOutcomes.values()].every((s) => s === "ACTIVE");
240607
+ if (!allAuthorized) {
240608
+ R2.info("Some connectors still require authorization. Run 'base44 connectors push' or open the links above in your browser.");
240609
+ }
240770
240610
  }
240771
240611
  R2.message(`${theme.styles.header("Dashboard")}: ${theme.colors.links(getDashboardUrl())}`);
240772
240612
  if (result.appUrl) {
@@ -240782,25 +240622,6 @@ function getDeployCommand(context) {
240782
240622
  }), { requireAuth: true }, context);
240783
240623
  });
240784
240624
  }
240785
- async function handleOAuthConnectors(connectorResults, options) {
240786
- const needsOAuth = filterPendingOAuth(connectorResults);
240787
- if (needsOAuth.length === 0)
240788
- return;
240789
- const oauthOutcomes = await promptOAuthFlows(needsOAuth, {
240790
- skipPrompt: options.yes || options.isNonInteractive
240791
- });
240792
- const allAuthorized = oauthOutcomes.size > 0 && [...oauthOutcomes.values()].every((s) => s === "ACTIVE");
240793
- if (!allAuthorized) {
240794
- R2.info("Some connectors still require authorization. Run 'base44 connectors push' or open the links above in your browser.");
240795
- }
240796
- }
240797
- function printStripeResult(r) {
240798
- R2.success("Stripe sandbox provisioned");
240799
- if (r.claimUrl) {
240800
- R2.info(` Claim your Stripe sandbox: ${theme.colors.links(r.claimUrl)}`);
240801
- }
240802
- R2.info(` Connectors dashboard: ${theme.colors.links(getConnectorsUrl())}`);
240803
- }
240804
240625
 
240805
240626
  // src/cli/commands/project/link.ts
240806
240627
  function validateNonInteractiveFlags2(command) {
@@ -242024,13 +241845,19 @@ function createEntityRoutes(db2, logger, remoteProxy, broadcast) {
242024
241845
  // src/cli/dev/dev-server/routes/integrations.ts
242025
241846
  var import_express3 = __toESM(require_express(), 1);
242026
241847
  var import_multer = __toESM(require_multer(), 1);
242027
- import { randomUUID as randomUUID4 } from "node:crypto";
241848
+ import { createHash, randomUUID as randomUUID4 } from "node:crypto";
242028
241849
  import fs28 from "node:fs";
242029
241850
  import path18 from "node:path";
241851
+ function createFileToken(fileUri) {
241852
+ return createHash("sha256").update(fileUri).digest("hex");
241853
+ }
242030
241854
  function createIntegrationRoutes(mediaFilesDir, baseUrl, remoteProxy, logger) {
242031
241855
  const router = import_express3.Router({ mergeParams: true });
242032
241856
  const parseBody = import_express3.json();
241857
+ const privateFilesDir = path18.join(mediaFilesDir, "private");
242033
241858
  fs28.mkdirSync(mediaFilesDir, { recursive: true });
241859
+ fs28.mkdirSync(privateFilesDir, { recursive: true });
241860
+ const MAX_FILE_SIZE = 50 * 1024 * 1024;
242034
241861
  const storage = import_multer.default.diskStorage({
242035
241862
  destination: mediaFilesDir,
242036
241863
  filename: (_req, file2, cb2) => {
@@ -242038,8 +241865,18 @@ function createIntegrationRoutes(mediaFilesDir, baseUrl, remoteProxy, logger) {
242038
241865
  cb2(null, `${randomUUID4()}${ext}`);
242039
241866
  }
242040
241867
  });
242041
- const MAX_FILE_SIZE = 50 * 1024 * 1024;
241868
+ const privateStorage = import_multer.default.diskStorage({
241869
+ destination: privateFilesDir,
241870
+ filename: (_req, file2, cb2) => {
241871
+ const ext = path18.extname(file2.originalname);
241872
+ cb2(null, `${randomUUID4()}${ext}`);
241873
+ }
241874
+ });
242042
241875
  const upload = import_multer.default({ storage, limits: { fileSize: MAX_FILE_SIZE } });
241876
+ const privateUpload = import_multer.default({
241877
+ storage: privateStorage,
241878
+ limits: { fileSize: MAX_FILE_SIZE }
241879
+ });
242043
241880
  router.post("/Core/UploadFile", upload.single("file"), (req, res) => {
242044
241881
  if (!req.file) {
242045
241882
  res.status(400).json({ error: "No file uploaded" });
@@ -242048,7 +241885,7 @@ function createIntegrationRoutes(mediaFilesDir, baseUrl, remoteProxy, logger) {
242048
241885
  const file_url = `${baseUrl}/media/${req.file.filename}`;
242049
241886
  res.json({ file_url });
242050
241887
  });
242051
- router.post("/Core/UploadPrivateFile", upload.single("file"), (req, res) => {
241888
+ router.post("/Core/UploadPrivateFile", privateUpload.single("file"), (req, res) => {
242052
241889
  if (!req.file) {
242053
241890
  res.status(400).json({ error: "No file uploaded" });
242054
241891
  return;
@@ -242062,8 +241899,8 @@ function createIntegrationRoutes(mediaFilesDir, baseUrl, remoteProxy, logger) {
242062
241899
  res.status(400).json({ error: "file_uri is required" });
242063
241900
  return;
242064
241901
  }
242065
- const signature = randomUUID4();
242066
- const signed_url = `${baseUrl}/media/${file_uri}?signature=${signature}`;
241902
+ const token2 = createFileToken(file_uri);
241903
+ const signed_url = `${baseUrl}/media/private/${file_uri}?token=${token2}`;
242067
241904
  res.json({ signed_url });
242068
241905
  });
242069
241906
  router.post("/Core/:endpointName", (req, res, next) => {
@@ -243832,6 +243669,24 @@ async function createDevServer(options8) {
243832
243669
  const entityRoutes = createEntityRoutes(db2, devLogger, remoteProxy, (...args) => emitEntityEvent(...args));
243833
243670
  app.use("/api/apps/:appId/entities", entityRoutes);
243834
243671
  const { path: mediaFilesDir } = await $dir();
243672
+ app.use("/media/private/:fileUri", (req, res, next) => {
243673
+ const { fileUri } = req.params;
243674
+ const token2 = req.query.token;
243675
+ if (!token2) {
243676
+ res.status(401).json({ error: "Missing token" });
243677
+ return;
243678
+ }
243679
+ const expectedToken = createFileToken(fileUri);
243680
+ if (token2 !== expectedToken) {
243681
+ res.status(400).json({
243682
+ error: "InvalidJWT",
243683
+ message: "signature verification failed",
243684
+ statusCode: "400"
243685
+ });
243686
+ return;
243687
+ }
243688
+ next();
243689
+ });
243835
243690
  app.use("/media", import_express4.default.static(mediaFilesDir));
243836
243691
  const integrationRoutes = createIntegrationRoutes(mediaFilesDir, baseUrl, remoteProxy, devLogger);
243837
243692
  app.use("/api/apps/:appId/integration-endpoints", integrationRoutes);
@@ -248282,4 +248137,4 @@ export {
248282
248137
  CLIExitError
248283
248138
  };
248284
248139
 
248285
- //# debugId=4DCA97D9C282E08464756E2164756E21
248140
+ //# debugId=E2A1C79322A8941664756E2164756E21