vite-plugin-rpx 0.11.22 → 0.11.23

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.
Files changed (2) hide show
  1. package/dist/index.js +65 -63
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -23778,6 +23778,24 @@ var init_proxy_handler = __esm(() => {
23778
23778
  ]);
23779
23779
  });
23780
23780
 
23781
+ // ../rpx/src/acme-challenge.ts
23782
+ import * as fs3 from "node:fs";
23783
+ import * as path3 from "node:path";
23784
+ function readAcmeChallenge(webroot, pathname) {
23785
+ if (!webroot || !pathname.startsWith(ACME_CHALLENGE_PREFIX2))
23786
+ return null;
23787
+ const token = pathname.slice(ACME_CHALLENGE_PREFIX2.length);
23788
+ if (!token || !/^[A-Za-z0-9_-]+$/.test(token))
23789
+ return null;
23790
+ try {
23791
+ return fs3.readFileSync(path3.join(webroot, token), "utf8");
23792
+ } catch {
23793
+ return null;
23794
+ }
23795
+ }
23796
+ var ACME_CHALLENGE_PREFIX2 = "/.well-known/acme-challenge/";
23797
+ var init_acme_challenge = () => {};
23798
+
23781
23799
  // ../rpx/src/host-match.ts
23782
23800
  function isWildcardPattern(pattern) {
23783
23801
  return pattern.startsWith("*.");
@@ -23790,10 +23808,10 @@ function matchesWildcard(hostname, pattern) {
23790
23808
  }
23791
23809
 
23792
23810
  // ../rpx/src/host-routes.ts
23793
- function normalizePathPrefix(path3) {
23794
- if (!path3 || path3 === "/")
23811
+ function normalizePathPrefix(path4) {
23812
+ if (!path4 || path4 === "/")
23795
23813
  return "/";
23796
- let p2 = path3.trim();
23814
+ let p2 = path4.trim();
23797
23815
  if (!p2.startsWith("/"))
23798
23816
  p2 = `/${p2}`;
23799
23817
  p2 = p2.replace(/\/+$/, "");
@@ -23820,8 +23838,8 @@ function buildHostRoutes(entries) {
23820
23838
  const table = new Map;
23821
23839
  for (const [host, paths] of byHost) {
23822
23840
  const list = [];
23823
- for (const [path3, route] of paths)
23824
- list.push({ path: path3, route });
23841
+ for (const [path4, route] of paths)
23842
+ list.push({ path: path4, route });
23825
23843
  list.sort((a2, b2) => b2.path.length - a2.path.length);
23826
23844
  table.set(host, list);
23827
23845
  }
@@ -23860,7 +23878,7 @@ var init_host_routes = () => {};
23860
23878
 
23861
23879
  // ../rpx/src/sni.ts
23862
23880
  import * as fsp from "node:fs/promises";
23863
- import * as path3 from "node:path";
23881
+ import * as path4 from "node:path";
23864
23882
  function serverNameFromCertFilename(filename) {
23865
23883
  if (!filename.endsWith(".crt"))
23866
23884
  return null;
@@ -23898,8 +23916,8 @@ async function buildSniTlsConfig(cfg, verbose) {
23898
23916
  continue;
23899
23917
  const base = name.slice(0, -".crt".length);
23900
23918
  bySrvName.set(serverName, {
23901
- certPath: path3.join(cfg.certsDir, name),
23902
- keyPath: path3.join(cfg.certsDir, `${base}.key`)
23919
+ certPath: path4.join(cfg.certsDir, name),
23920
+ keyPath: path4.join(cfg.certsDir, `${base}.key`)
23903
23921
  });
23904
23922
  }
23905
23923
  }
@@ -23921,7 +23939,7 @@ var init_sni = __esm(() => {
23921
23939
 
23922
23940
  // ../rpx/src/on-demand.ts
23923
23941
  import * as fsp2 from "node:fs/promises";
23924
- import * as path4 from "node:path";
23942
+ import * as path5 from "node:path";
23925
23943
  function matchesAllowedSuffix(host, suffixes) {
23926
23944
  if (!suffixes || suffixes.length === 0)
23927
23945
  return false;
@@ -24072,8 +24090,8 @@ class OnDemandCertManager {
24072
24090
  }
24073
24091
  pathsFor(host) {
24074
24092
  return {
24075
- certPath: path4.join(this.certsDir, `${host}.crt`),
24076
- keyPath: path4.join(this.certsDir, `${host}.key`)
24093
+ certPath: path5.join(this.certsDir, `${host}.crt`),
24094
+ keyPath: path5.join(this.certsDir, `${host}.key`)
24077
24095
  };
24078
24096
  }
24079
24097
  async persist(host, certPem, keyPem) {
@@ -24232,10 +24250,10 @@ var init_port_manager = __esm(() => {
24232
24250
  // ../rpx/src/registry.ts
24233
24251
  import * as fsp3 from "node:fs/promises";
24234
24252
  import { homedir as homedir9 } from "node:os";
24235
- import * as path5 from "node:path";
24253
+ import * as path6 from "node:path";
24236
24254
  import * as process23 from "node:process";
24237
24255
  function getRegistryDir() {
24238
- return path5.join(homedir9(), ".stacks", "rpx", "registry.d");
24256
+ return path6.join(homedir9(), ".stacks", "rpx", "registry.d");
24239
24257
  }
24240
24258
  function isValidId(id) {
24241
24259
  return typeof id === "string" && id.length > 0 && id.length <= 128 && ID_PATTERN.test(id);
@@ -24243,7 +24261,7 @@ function isValidId(id) {
24243
24261
  function entryPath(dir, id) {
24244
24262
  if (!isValidId(id))
24245
24263
  throw new Error(`invalid registry id: ${JSON.stringify(id)}`);
24246
- return path5.join(dir, `${id}.json`);
24264
+ return path6.join(dir, `${id}.json`);
24247
24265
  }
24248
24266
  function isPidAlive(pid2) {
24249
24267
  if (!Number.isInteger(pid2) || pid2 <= 0)
@@ -24301,11 +24319,11 @@ var init_registry = __esm(() => {
24301
24319
  });
24302
24320
 
24303
24321
  // ../rpx/src/site-supervisor.ts
24304
- import { closeSync as closeSync6, openSync as openSync6, readFileSync as readFileSync3 } from "node:fs";
24322
+ import { closeSync as closeSync6, openSync as openSync6, readFileSync as readFileSync4 } from "node:fs";
24305
24323
  import * as fsp4 from "node:fs/promises";
24306
24324
  import { spawn } from "node:child_process";
24307
24325
  import { homedir as homedir10 } from "node:os";
24308
- import * as path6 from "node:path";
24326
+ import * as path7 from "node:path";
24309
24327
  import * as process25 from "node:process";
24310
24328
 
24311
24329
  class SiteSupervisor {
@@ -24331,7 +24349,7 @@ class SiteSupervisor {
24331
24349
  constructor(opts) {
24332
24350
  this.resolver = opts.resolver;
24333
24351
  this.registryDir = opts.registryDir ?? getRegistryDir();
24334
- this.rpxDir = opts.rpxDir ?? path6.join(homedir10(), ".stacks", "rpx");
24352
+ this.rpxDir = opts.rpxDir ?? path7.join(homedir10(), ".stacks", "rpx");
24335
24353
  this.verbose = opts.verbose ?? false;
24336
24354
  this.startupTimeoutMs = opts.startupTimeoutMs ?? DEFAULT_STARTUP_TIMEOUT_MS;
24337
24355
  this.pollIntervalMs = opts.pollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS;
@@ -24386,8 +24404,8 @@ class SiteSupervisor {
24386
24404
  ports.set(route.portEnv, port);
24387
24405
  }
24388
24406
  }
24389
- const logPath = path6.join(this.rpxDir, "sites", `${site.id}.log`);
24390
- await fsp4.mkdir(path6.dirname(logPath), { recursive: true }).catch(() => {});
24407
+ const logPath = path7.join(this.rpxDir, "sites", `${site.id}.log`);
24408
+ await fsp4.mkdir(path7.dirname(logPath), { recursive: true }).catch(() => {});
24391
24409
  const env2 = this.buildEnv(site, ports);
24392
24410
  let handle = null;
24393
24411
  let startError;
@@ -24525,7 +24543,7 @@ class SiteSupervisor {
24525
24543
  }
24526
24544
  readLogTail(state, lines = 40) {
24527
24545
  try {
24528
- const text = readFileSync3(state.logPath, "utf8");
24546
+ const text = readFileSync4(state.logPath, "utf8");
24529
24547
  return text.split(`
24530
24548
  `).slice(-lines).join(`
24531
24549
  `).trim();
@@ -24683,12 +24701,12 @@ var init_site_supervisor = __esm(() => {
24683
24701
  // ../rpx/src/dns-state.ts
24684
24702
  import * as fsp5 from "node:fs/promises";
24685
24703
  import { homedir as homedir11 } from "node:os";
24686
- import * as path7 from "node:path";
24704
+ import * as path8 from "node:path";
24687
24705
  function defaultRpxDir() {
24688
- return path7.join(homedir11(), ".stacks", "rpx");
24706
+ return path8.join(homedir11(), ".stacks", "rpx");
24689
24707
  }
24690
24708
  function getDnsStatePath(rpxDir = defaultRpxDir()) {
24691
- return path7.join(rpxDir, RPX_DNS_STATE_FILE);
24709
+ return path8.join(rpxDir, RPX_DNS_STATE_FILE);
24692
24710
  }
24693
24711
  async function loadDnsState(rpxDir = defaultRpxDir()) {
24694
24712
  try {
@@ -24792,7 +24810,7 @@ __export(exports_dns, {
24792
24810
  });
24793
24811
  import dgram from "node:dgram";
24794
24812
  import * as fsp6 from "node:fs/promises";
24795
- import * as path8 from "node:path";
24813
+ import * as path9 from "node:path";
24796
24814
  import * as process26 from "node:process";
24797
24815
  function parseHeader(buffer) {
24798
24816
  return {
@@ -25027,7 +25045,7 @@ port ${DNS_PORT}
25027
25045
  `;
25028
25046
  }
25029
25047
  function resolverFilePath(basename) {
25030
- return path8.join(MACOS_RESOLVER_DIR, basename);
25048
+ return path9.join(MACOS_RESOLVER_DIR, basename);
25031
25049
  }
25032
25050
  function contentLooksLikeRpxResolver(content) {
25033
25051
  return content.includes("127.0.0.1") && content.includes(String(DNS_PORT));
@@ -25212,13 +25230,13 @@ var init_dns = __esm(() => {
25212
25230
  import { spawn as nodeSpawn } from "node:child_process";
25213
25231
  import * as fsp7 from "node:fs/promises";
25214
25232
  import { homedir as homedir12 } from "node:os";
25215
- import * as path9 from "node:path";
25233
+ import * as path10 from "node:path";
25216
25234
  import * as process27 from "node:process";
25217
25235
  function getDaemonRpxDir() {
25218
- return path9.join(homedir12(), ".stacks", "rpx");
25236
+ return path10.join(homedir12(), ".stacks", "rpx");
25219
25237
  }
25220
25238
  function getDaemonPidPath(rpxDir = getDaemonRpxDir()) {
25221
- return path9.join(rpxDir, "daemon.pid");
25239
+ return path10.join(rpxDir, "daemon.pid");
25222
25240
  }
25223
25241
  async function readDaemonPid(rpxDir = getDaemonRpxDir()) {
25224
25242
  try {
@@ -25238,7 +25256,7 @@ async function releaseDaemonLock(rpxDir = getDaemonRpxDir()) {
25238
25256
  }
25239
25257
  function defaultDaemonSpawnCommand() {
25240
25258
  const exec = process27.execPath;
25241
- const interpName = path9.basename(exec).toLowerCase();
25259
+ const interpName = path10.basename(exec).toLowerCase();
25242
25260
  const isInterpreter = interpName === "bun" || interpName === "node" || interpName.startsWith("bun-");
25243
25261
  if (isInterpreter && process27.argv[1])
25244
25262
  return [exec, process27.argv[1], "daemon:start"];
@@ -25296,6 +25314,7 @@ var init_daemon = __esm(() => {
25296
25314
  init_logger();
25297
25315
  init_https();
25298
25316
  init_proxy_handler();
25317
+ init_acme_challenge();
25299
25318
  init_host_routes();
25300
25319
  init_sni();
25301
25320
  init_on_demand();
@@ -25337,8 +25356,8 @@ init_daemon();
25337
25356
  init_logger();
25338
25357
  init_registry();
25339
25358
  init_utils();
25340
- import * as fs3 from "node:fs";
25341
- import * as path10 from "node:path";
25359
+ import * as fs4 from "node:fs";
25360
+ import * as path11 from "node:path";
25342
25361
  import * as process28 from "node:process";
25343
25362
  function deriveIdFromTarget(to, routePath) {
25344
25363
  const base = routePath && routePath !== "/" ? `${to}${routePath}` : to;
@@ -25414,7 +25433,7 @@ async function runViaDaemon(opts) {
25414
25433
  return;
25415
25434
  for (const id of idsForCleanup) {
25416
25435
  try {
25417
- fs3.unlinkSync(path10.join(dirForCleanup, `${id}.json`));
25436
+ fs4.unlinkSync(path11.join(dirForCleanup, `${id}.json`));
25418
25437
  } catch {}
25419
25438
  }
25420
25439
  });
@@ -25424,9 +25443,9 @@ async function runViaDaemon(opts) {
25424
25443
  // ../rpx/src/hosts.ts
25425
25444
  init_utils();
25426
25445
  import { exec } from "node:child_process";
25427
- import fs4 from "node:fs";
25446
+ import fs5 from "node:fs";
25428
25447
  import os2 from "node:os";
25429
- import path11 from "node:path";
25448
+ import path12 from "node:path";
25430
25449
  import * as process29 from "node:process";
25431
25450
  import { promisify } from "node:util";
25432
25451
  var execAsync = promisify(exec);
@@ -25434,7 +25453,7 @@ function isLoopbackDevelopmentHost(host) {
25434
25453
  const normalized = host.trim().toLowerCase();
25435
25454
  return normalized === "localhost" || normalized.endsWith(".localhost") || normalized.endsWith(".localhost.");
25436
25455
  }
25437
- var hostsFilePath = process29.platform === "win32" ? path11.join(process29.env.windir || "C:\\Windows", "System32", "drivers", "etc", "hosts") : "/etc/hosts";
25456
+ var hostsFilePath = process29.platform === "win32" ? path12.join(process29.env.windir || "C:\\Windows", "System32", "drivers", "etc", "hosts") : "/etc/hosts";
25438
25457
  var sudoPrivilegesAcquired = false;
25439
25458
  async function execSudo(command) {
25440
25459
  if (process29.platform === "win32")
@@ -25483,7 +25502,7 @@ async function addHosts(hosts, verbose) {
25483
25502
  try {
25484
25503
  let existingContent;
25485
25504
  try {
25486
- existingContent = await fs4.promises.readFile(hostsFilePath, "utf-8");
25505
+ existingContent = await fs5.promises.readFile(hostsFilePath, "utf-8");
25487
25506
  } catch {
25488
25507
  debugLog("hosts", "Reading hosts file requires elevated permissions, using sudo", verbose);
25489
25508
  try {
@@ -25508,9 +25527,9 @@ async function addHosts(hosts, verbose) {
25508
25527
  127.0.0.1 ${host}
25509
25528
  ::1 ${host}`).join(`
25510
25529
  `);
25511
- const tmpFile = path11.join(os2.tmpdir(), `rpx-hosts-${Date.now()}.tmp`);
25530
+ const tmpFile = path12.join(os2.tmpdir(), `rpx-hosts-${Date.now()}.tmp`);
25512
25531
  try {
25513
- await fs4.promises.writeFile(tmpFile, existingContent + hostEntries, "utf8");
25532
+ await fs5.promises.writeFile(tmpFile, existingContent + hostEntries, "utf8");
25514
25533
  await execSudo(`cat "${tmpFile}" | tee "${hostsFilePath}" > /dev/null`);
25515
25534
  console.log(` Hosts updated: ${newEntries.join(", ")}`);
25516
25535
  } catch (error) {
@@ -25523,7 +25542,7 @@ async function addHosts(hosts, verbose) {
25523
25542
  console.log(` Or run: sudo nano ${hostsFilePath}`);
25524
25543
  } finally {
25525
25544
  try {
25526
- await fs4.promises.unlink(tmpFile);
25545
+ await fs5.promises.unlink(tmpFile);
25527
25546
  } catch {}
25528
25547
  }
25529
25548
  } catch (err) {
@@ -25536,7 +25555,7 @@ async function removeHosts(hosts, verbose) {
25536
25555
  try {
25537
25556
  let content;
25538
25557
  try {
25539
- content = await fs4.promises.readFile(hostsFilePath, "utf-8");
25558
+ content = await fs5.promises.readFile(hostsFilePath, "utf-8");
25540
25559
  } catch {
25541
25560
  debugLog("hosts", "Reading hosts file requires elevated permissions, using sudo", verbose);
25542
25561
  try {
@@ -25570,16 +25589,16 @@ async function removeHosts(hosts, verbose) {
25570
25589
  const newContent = `${filteredLines.join(`
25571
25590
  `)}
25572
25591
  `;
25573
- const tmpFile = path11.join(os2.tmpdir(), `rpx-hosts-${Date.now()}.tmp`);
25592
+ const tmpFile = path12.join(os2.tmpdir(), `rpx-hosts-${Date.now()}.tmp`);
25574
25593
  try {
25575
- await fs4.promises.writeFile(tmpFile, newContent, "utf8");
25594
+ await fs5.promises.writeFile(tmpFile, newContent, "utf8");
25576
25595
  await execSudo(`cat "${tmpFile}" | tee "${hostsFilePath}" > /dev/null`);
25577
25596
  debugLog("hosts", "Hosts removed successfully", verbose);
25578
25597
  } catch (error) {
25579
25598
  debugLog("hosts", "Could not clean up hosts file automatically", verbose);
25580
25599
  } finally {
25581
25600
  try {
25582
- await fs4.promises.unlink(tmpFile);
25601
+ await fs5.promises.unlink(tmpFile);
25583
25602
  } catch (unlinkErr) {
25584
25603
  debugLog("hosts", `Failed to remove temporary file: ${unlinkErr}`, verbose);
25585
25604
  }
@@ -25592,7 +25611,7 @@ async function checkHosts(hosts, verbose) {
25592
25611
  debugLog("hosts", `Checking hosts: ${hosts}`, verbose);
25593
25612
  let content;
25594
25613
  try {
25595
- content = await fs4.promises.readFile(hostsFilePath, "utf-8");
25614
+ content = await fs5.promises.readFile(hostsFilePath, "utf-8");
25596
25615
  } catch (readErr) {
25597
25616
  debugLog("hosts", `Error reading hosts file: ${readErr}`, verbose);
25598
25617
  try {
@@ -25805,25 +25824,7 @@ function createOriginGuard(options) {
25805
25824
 
25806
25825
  // ../rpx/src/start.ts
25807
25826
  init_proxy_handler();
25808
-
25809
- // ../rpx/src/acme-challenge.ts
25810
- import * as fs5 from "node:fs";
25811
- import * as path12 from "node:path";
25812
- var ACME_CHALLENGE_PREFIX2 = "/.well-known/acme-challenge/";
25813
- function readAcmeChallenge(webroot, pathname) {
25814
- if (!webroot || !pathname.startsWith(ACME_CHALLENGE_PREFIX2))
25815
- return null;
25816
- const token = pathname.slice(ACME_CHALLENGE_PREFIX2.length);
25817
- if (!token || !/^[A-Za-z0-9_-]+$/.test(token))
25818
- return null;
25819
- try {
25820
- return fs5.readFileSync(path12.join(webroot, token), "utf8");
25821
- } catch {
25822
- return null;
25823
- }
25824
- }
25825
-
25826
- // ../rpx/src/start.ts
25827
+ init_acme_challenge();
25827
25828
  init_auth();
25828
25829
  init_host_routes();
25829
25830
  init_sni();
@@ -26655,6 +26656,7 @@ init_dns();
26655
26656
  init_dns_state();
26656
26657
  init_daemon();
26657
26658
  init_proxy_handler();
26659
+ init_acme_challenge();
26658
26660
  init_auth();
26659
26661
  init_host_routes();
26660
26662
  init_static_files();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vite-plugin-rpx",
3
3
  "type": "module",
4
- "version": "0.11.22",
4
+ "version": "0.11.23",
5
5
  "description": "A modern and smart reverse proxy. Vite plugin.",
6
6
  "author": "Chris Breuer <chris@stacksjs.org>",
7
7
  "license": "MIT",
@@ -47,7 +47,7 @@
47
47
  "typecheck": "bunx tsc --noEmit"
48
48
  },
49
49
  "dependencies": {
50
- "@stacksjs/rpx": "0.11.22",
50
+ "@stacksjs/rpx": "0.11.23",
51
51
  "@stacksjs/tlsx": "^0.13.9"
52
52
  },
53
53
  "simple-git-hooks": {