@stacksjs/rpx 0.4.1 → 0.5.0
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.js +353 -226
- package/dist/config.d.ts +3 -2
- package/dist/https.d.ts +13 -7
- package/dist/index.js +461 -324
- package/dist/start.d.ts +2 -4
- package/dist/types.d.ts +12 -18
- package/dist/utils.d.ts +7 -2
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -17,11 +17,10 @@ var __toESM = (mod, isNodeMode, target) => {
|
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
// src/start.ts
|
|
20
|
-
import * as fs5 from "fs";
|
|
21
20
|
import * as http from "http";
|
|
22
21
|
import * as https from "https";
|
|
23
22
|
import * as net from "net";
|
|
24
|
-
import
|
|
23
|
+
import process9 from "process";
|
|
25
24
|
|
|
26
25
|
// node_modules/@stacksjs/cli/dist/index.js
|
|
27
26
|
import { formatWithOptions } from "util";
|
|
@@ -20468,18 +20467,90 @@ var quotes = collect([
|
|
|
20468
20467
|
]);
|
|
20469
20468
|
var export_prompts = import_prompts.default;
|
|
20470
20469
|
// package.json
|
|
20471
|
-
var version = "0.
|
|
20470
|
+
var version = "0.5.0";
|
|
20471
|
+
|
|
20472
|
+
// src/config.ts
|
|
20473
|
+
import { homedir } from "os";
|
|
20474
|
+
import { join as join2 } from "path";
|
|
20475
|
+
|
|
20476
|
+
// node_modules/bun-config/dist/index.js
|
|
20477
|
+
import { resolve } from "path";
|
|
20478
|
+
import process2 from "process";
|
|
20479
|
+
function deepMerge(target, source) {
|
|
20480
|
+
if (Array.isArray(source) && !Array.isArray(target)) {
|
|
20481
|
+
return source;
|
|
20482
|
+
}
|
|
20483
|
+
if (Array.isArray(source) && Array.isArray(target)) {
|
|
20484
|
+
return source.map((sourceItem, index) => {
|
|
20485
|
+
const targetItem = target[index];
|
|
20486
|
+
if (isObject3(sourceItem) && isObject3(targetItem)) {
|
|
20487
|
+
return deepMerge(targetItem, sourceItem);
|
|
20488
|
+
}
|
|
20489
|
+
return sourceItem;
|
|
20490
|
+
});
|
|
20491
|
+
}
|
|
20492
|
+
if (!isObject3(source) || !isObject3(target)) {
|
|
20493
|
+
return source;
|
|
20494
|
+
}
|
|
20495
|
+
const merged = { ...target };
|
|
20496
|
+
for (const key in source) {
|
|
20497
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
20498
|
+
const sourceValue = source[key];
|
|
20499
|
+
const targetValue = merged[key];
|
|
20500
|
+
if (sourceValue === null || sourceValue === undefined) {
|
|
20501
|
+
merged[key] = sourceValue;
|
|
20502
|
+
} else if (isObject3(sourceValue) && isObject3(targetValue)) {
|
|
20503
|
+
merged[key] = deepMerge(targetValue, sourceValue);
|
|
20504
|
+
} else {
|
|
20505
|
+
merged[key] = sourceValue;
|
|
20506
|
+
}
|
|
20507
|
+
}
|
|
20508
|
+
}
|
|
20509
|
+
return merged;
|
|
20510
|
+
}
|
|
20511
|
+
function isObject3(item) {
|
|
20512
|
+
return Boolean(item && typeof item === "object" && !Array.isArray(item));
|
|
20513
|
+
}
|
|
20514
|
+
async function loadConfig({ name, cwd, defaultConfig }) {
|
|
20515
|
+
const configPath = resolve(cwd || process2.cwd(), `${name}.config`);
|
|
20516
|
+
try {
|
|
20517
|
+
const importedConfig = await import(configPath);
|
|
20518
|
+
const loadedConfig = importedConfig.default || importedConfig;
|
|
20519
|
+
return deepMerge(defaultConfig, loadedConfig);
|
|
20520
|
+
} catch (error) {
|
|
20521
|
+
return defaultConfig;
|
|
20522
|
+
}
|
|
20523
|
+
}
|
|
20524
|
+
|
|
20525
|
+
// src/config.ts
|
|
20526
|
+
var defaultConfig = {
|
|
20527
|
+
from: "localhost:5173",
|
|
20528
|
+
to: "stacks.localhost",
|
|
20529
|
+
https: {
|
|
20530
|
+
basePath: "",
|
|
20531
|
+
caCertPath: join2(homedir(), ".stacks", "ssl", `stacks.localhost.ca.crt`),
|
|
20532
|
+
certPath: join2(homedir(), ".stacks", "ssl", `stacks.localhost.crt`),
|
|
20533
|
+
keyPath: join2(homedir(), ".stacks", "ssl", `stacks.localhost.crt.key`)
|
|
20534
|
+
},
|
|
20535
|
+
etcHostsCleanup: true,
|
|
20536
|
+
verbose: true
|
|
20537
|
+
};
|
|
20538
|
+
var config4 = await loadConfig({
|
|
20539
|
+
name: "reverse-proxy",
|
|
20540
|
+
defaultConfig
|
|
20541
|
+
});
|
|
20472
20542
|
|
|
20473
20543
|
// src/hosts.ts
|
|
20474
20544
|
import { spawn } from "child_process";
|
|
20475
|
-
import
|
|
20476
|
-
import
|
|
20477
|
-
import
|
|
20478
|
-
import
|
|
20545
|
+
import fs5 from "fs";
|
|
20546
|
+
import os3 from "os";
|
|
20547
|
+
import path4 from "path";
|
|
20548
|
+
import process3 from "process";
|
|
20479
20549
|
|
|
20480
20550
|
// src/https.ts
|
|
20481
|
-
import
|
|
20482
|
-
import
|
|
20551
|
+
import fs3 from "fs/promises";
|
|
20552
|
+
import { homedir as homedir2 } from "os";
|
|
20553
|
+
import { join as join4 } from "path";
|
|
20483
20554
|
|
|
20484
20555
|
// node_modules/@stacksjs/tlsx/dist/index.js
|
|
20485
20556
|
import fs2 from "fs";
|
|
@@ -20503,7 +20574,7 @@ import {
|
|
|
20503
20574
|
dirname as dirname3,
|
|
20504
20575
|
extname as extname2,
|
|
20505
20576
|
isAbsolute as isAbsolute2,
|
|
20506
|
-
join as
|
|
20577
|
+
join as join3,
|
|
20507
20578
|
normalize as normalize2,
|
|
20508
20579
|
parse as parse2,
|
|
20509
20580
|
relative as relative2,
|
|
@@ -20528,8 +20599,8 @@ import process172 from "process";
|
|
|
20528
20599
|
import process192 from "process";
|
|
20529
20600
|
import os22 from "os";
|
|
20530
20601
|
import path from "path";
|
|
20531
|
-
import { resolve } from "path";
|
|
20532
|
-
import
|
|
20602
|
+
import { resolve as resolve3 } from "path";
|
|
20603
|
+
import process22 from "process";
|
|
20533
20604
|
import fs from "fs";
|
|
20534
20605
|
import path2 from "path";
|
|
20535
20606
|
var __create3 = Object.create;
|
|
@@ -36874,11 +36945,11 @@ var __export3 = (target, all) => {
|
|
|
36874
36945
|
});
|
|
36875
36946
|
};
|
|
36876
36947
|
var __esm2 = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
36877
|
-
function
|
|
36948
|
+
function isObject5(value) {
|
|
36878
36949
|
return value !== null && typeof value === "object";
|
|
36879
36950
|
}
|
|
36880
36951
|
function _defu2(baseObject, defaults, namespace = ".", merger) {
|
|
36881
|
-
if (!
|
|
36952
|
+
if (!isObject5(defaults)) {
|
|
36882
36953
|
return _defu2(baseObject, {}, namespace, merger);
|
|
36883
36954
|
}
|
|
36884
36955
|
const object = Object.assign({}, defaults);
|
|
@@ -36895,7 +36966,7 @@ function _defu2(baseObject, defaults, namespace = ".", merger) {
|
|
|
36895
36966
|
}
|
|
36896
36967
|
if (Array.isArray(value) && Array.isArray(object[key])) {
|
|
36897
36968
|
object[key] = [...value, ...object[key]];
|
|
36898
|
-
} else if (
|
|
36969
|
+
} else if (isObject5(value) && isObject5(object[key])) {
|
|
36899
36970
|
object[key] = _defu2(value, object[key], (namespace ? `${namespace}.` : "") + key.toString(), merger);
|
|
36900
36971
|
} else {
|
|
36901
36972
|
object[key] = value;
|
|
@@ -41302,7 +41373,7 @@ var require_prompt3 = __commonJS22((exports, module) => {
|
|
|
41302
41373
|
module.exports = Prompt;
|
|
41303
41374
|
});
|
|
41304
41375
|
var require_text3 = __commonJS22((exports, module) => {
|
|
41305
|
-
function asyncGeneratorStep(gen,
|
|
41376
|
+
function asyncGeneratorStep(gen, resolve32, reject, _next, _throw, key, arg) {
|
|
41306
41377
|
try {
|
|
41307
41378
|
var info = gen[key](arg);
|
|
41308
41379
|
var value = info.value;
|
|
@@ -41311,7 +41382,7 @@ var require_text3 = __commonJS22((exports, module) => {
|
|
|
41311
41382
|
return;
|
|
41312
41383
|
}
|
|
41313
41384
|
if (info.done) {
|
|
41314
|
-
|
|
41385
|
+
resolve32(value);
|
|
41315
41386
|
} else {
|
|
41316
41387
|
Promise.resolve(value).then(_next, _throw);
|
|
41317
41388
|
}
|
|
@@ -41319,13 +41390,13 @@ var require_text3 = __commonJS22((exports, module) => {
|
|
|
41319
41390
|
function _asyncToGenerator(fn) {
|
|
41320
41391
|
return function() {
|
|
41321
41392
|
var self2 = this, args = arguments;
|
|
41322
|
-
return new Promise(function(
|
|
41393
|
+
return new Promise(function(resolve32, reject) {
|
|
41323
41394
|
var gen = fn.apply(self2, args);
|
|
41324
41395
|
function _next(value) {
|
|
41325
|
-
asyncGeneratorStep(gen,
|
|
41396
|
+
asyncGeneratorStep(gen, resolve32, reject, _next, _throw, "next", value);
|
|
41326
41397
|
}
|
|
41327
41398
|
function _throw(err2) {
|
|
41328
|
-
asyncGeneratorStep(gen,
|
|
41399
|
+
asyncGeneratorStep(gen, resolve32, reject, _next, _throw, "throw", err2);
|
|
41329
41400
|
}
|
|
41330
41401
|
_next(undefined);
|
|
41331
41402
|
});
|
|
@@ -42017,7 +42088,7 @@ var require_dateparts3 = __commonJS22((exports, module) => {
|
|
|
42017
42088
|
};
|
|
42018
42089
|
});
|
|
42019
42090
|
var require_date3 = __commonJS22((exports, module) => {
|
|
42020
|
-
function asyncGeneratorStep(gen,
|
|
42091
|
+
function asyncGeneratorStep(gen, resolve32, reject, _next, _throw, key, arg) {
|
|
42021
42092
|
try {
|
|
42022
42093
|
var info = gen[key](arg);
|
|
42023
42094
|
var value = info.value;
|
|
@@ -42026,7 +42097,7 @@ var require_date3 = __commonJS22((exports, module) => {
|
|
|
42026
42097
|
return;
|
|
42027
42098
|
}
|
|
42028
42099
|
if (info.done) {
|
|
42029
|
-
|
|
42100
|
+
resolve32(value);
|
|
42030
42101
|
} else {
|
|
42031
42102
|
Promise.resolve(value).then(_next, _throw);
|
|
42032
42103
|
}
|
|
@@ -42034,13 +42105,13 @@ var require_date3 = __commonJS22((exports, module) => {
|
|
|
42034
42105
|
function _asyncToGenerator(fn) {
|
|
42035
42106
|
return function() {
|
|
42036
42107
|
var self2 = this, args = arguments;
|
|
42037
|
-
return new Promise(function(
|
|
42108
|
+
return new Promise(function(resolve32, reject) {
|
|
42038
42109
|
var gen = fn.apply(self2, args);
|
|
42039
42110
|
function _next(value) {
|
|
42040
|
-
asyncGeneratorStep(gen,
|
|
42111
|
+
asyncGeneratorStep(gen, resolve32, reject, _next, _throw, "next", value);
|
|
42041
42112
|
}
|
|
42042
42113
|
function _throw(err2) {
|
|
42043
|
-
asyncGeneratorStep(gen,
|
|
42114
|
+
asyncGeneratorStep(gen, resolve32, reject, _next, _throw, "throw", err2);
|
|
42044
42115
|
}
|
|
42045
42116
|
_next(undefined);
|
|
42046
42117
|
});
|
|
@@ -42242,7 +42313,7 @@ ${i ? ` ` : figures.pointerSmall} ${color.red().italic(l3)}`, ``);
|
|
|
42242
42313
|
module.exports = DatePrompt;
|
|
42243
42314
|
});
|
|
42244
42315
|
var require_number3 = __commonJS22((exports, module) => {
|
|
42245
|
-
function asyncGeneratorStep(gen,
|
|
42316
|
+
function asyncGeneratorStep(gen, resolve32, reject, _next, _throw, key, arg) {
|
|
42246
42317
|
try {
|
|
42247
42318
|
var info = gen[key](arg);
|
|
42248
42319
|
var value = info.value;
|
|
@@ -42251,7 +42322,7 @@ var require_number3 = __commonJS22((exports, module) => {
|
|
|
42251
42322
|
return;
|
|
42252
42323
|
}
|
|
42253
42324
|
if (info.done) {
|
|
42254
|
-
|
|
42325
|
+
resolve32(value);
|
|
42255
42326
|
} else {
|
|
42256
42327
|
Promise.resolve(value).then(_next, _throw);
|
|
42257
42328
|
}
|
|
@@ -42259,13 +42330,13 @@ var require_number3 = __commonJS22((exports, module) => {
|
|
|
42259
42330
|
function _asyncToGenerator(fn) {
|
|
42260
42331
|
return function() {
|
|
42261
42332
|
var self2 = this, args = arguments;
|
|
42262
|
-
return new Promise(function(
|
|
42333
|
+
return new Promise(function(resolve32, reject) {
|
|
42263
42334
|
var gen = fn.apply(self2, args);
|
|
42264
42335
|
function _next(value) {
|
|
42265
|
-
asyncGeneratorStep(gen,
|
|
42336
|
+
asyncGeneratorStep(gen, resolve32, reject, _next, _throw, "next", value);
|
|
42266
42337
|
}
|
|
42267
42338
|
function _throw(err2) {
|
|
42268
|
-
asyncGeneratorStep(gen,
|
|
42339
|
+
asyncGeneratorStep(gen, resolve32, reject, _next, _throw, "throw", err2);
|
|
42269
42340
|
}
|
|
42270
42341
|
_next(undefined);
|
|
42271
42342
|
});
|
|
@@ -42697,7 +42768,7 @@ Instructions:
|
|
|
42697
42768
|
module.exports = MultiselectPrompt;
|
|
42698
42769
|
});
|
|
42699
42770
|
var require_autocomplete3 = __commonJS22((exports, module) => {
|
|
42700
|
-
function asyncGeneratorStep(gen,
|
|
42771
|
+
function asyncGeneratorStep(gen, resolve32, reject, _next, _throw, key, arg) {
|
|
42701
42772
|
try {
|
|
42702
42773
|
var info = gen[key](arg);
|
|
42703
42774
|
var value = info.value;
|
|
@@ -42706,7 +42777,7 @@ var require_autocomplete3 = __commonJS22((exports, module) => {
|
|
|
42706
42777
|
return;
|
|
42707
42778
|
}
|
|
42708
42779
|
if (info.done) {
|
|
42709
|
-
|
|
42780
|
+
resolve32(value);
|
|
42710
42781
|
} else {
|
|
42711
42782
|
Promise.resolve(value).then(_next, _throw);
|
|
42712
42783
|
}
|
|
@@ -42714,13 +42785,13 @@ var require_autocomplete3 = __commonJS22((exports, module) => {
|
|
|
42714
42785
|
function _asyncToGenerator(fn) {
|
|
42715
42786
|
return function() {
|
|
42716
42787
|
var self2 = this, args = arguments;
|
|
42717
|
-
return new Promise(function(
|
|
42788
|
+
return new Promise(function(resolve32, reject) {
|
|
42718
42789
|
var gen = fn.apply(self2, args);
|
|
42719
42790
|
function _next(value) {
|
|
42720
|
-
asyncGeneratorStep(gen,
|
|
42791
|
+
asyncGeneratorStep(gen, resolve32, reject, _next, _throw, "next", value);
|
|
42721
42792
|
}
|
|
42722
42793
|
function _throw(err2) {
|
|
42723
|
-
asyncGeneratorStep(gen,
|
|
42794
|
+
asyncGeneratorStep(gen, resolve32, reject, _next, _throw, "throw", err2);
|
|
42724
42795
|
}
|
|
42725
42796
|
_next(undefined);
|
|
42726
42797
|
});
|
|
@@ -43369,7 +43440,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
43369
43440
|
arr2[i] = arr[i];
|
|
43370
43441
|
return arr2;
|
|
43371
43442
|
}
|
|
43372
|
-
function asyncGeneratorStep(gen,
|
|
43443
|
+
function asyncGeneratorStep(gen, resolve32, reject, _next, _throw, key, arg) {
|
|
43373
43444
|
try {
|
|
43374
43445
|
var info = gen[key](arg);
|
|
43375
43446
|
var value = info.value;
|
|
@@ -43378,7 +43449,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
43378
43449
|
return;
|
|
43379
43450
|
}
|
|
43380
43451
|
if (info.done) {
|
|
43381
|
-
|
|
43452
|
+
resolve32(value);
|
|
43382
43453
|
} else {
|
|
43383
43454
|
Promise.resolve(value).then(_next, _throw);
|
|
43384
43455
|
}
|
|
@@ -43386,13 +43457,13 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
43386
43457
|
function _asyncToGenerator(fn) {
|
|
43387
43458
|
return function() {
|
|
43388
43459
|
var self2 = this, args = arguments;
|
|
43389
|
-
return new Promise(function(
|
|
43460
|
+
return new Promise(function(resolve32, reject) {
|
|
43390
43461
|
var gen = fn.apply(self2, args);
|
|
43391
43462
|
function _next(value) {
|
|
43392
|
-
asyncGeneratorStep(gen,
|
|
43463
|
+
asyncGeneratorStep(gen, resolve32, reject, _next, _throw, "next", value);
|
|
43393
43464
|
}
|
|
43394
43465
|
function _throw(err2) {
|
|
43395
|
-
asyncGeneratorStep(gen,
|
|
43466
|
+
asyncGeneratorStep(gen, resolve32, reject, _next, _throw, "throw", err2);
|
|
43396
43467
|
}
|
|
43397
43468
|
_next(undefined);
|
|
43398
43469
|
});
|
|
@@ -48079,7 +48150,7 @@ function projectPath2(filePath = "", options2) {
|
|
|
48079
48150
|
function storagePath2(path22) {
|
|
48080
48151
|
return projectPath2(`storage/${path22 || ""}`);
|
|
48081
48152
|
}
|
|
48082
|
-
var
|
|
48153
|
+
var config6 = {
|
|
48083
48154
|
ai: {
|
|
48084
48155
|
deploy: false,
|
|
48085
48156
|
models: [
|
|
@@ -48656,7 +48727,7 @@ var config4 = {
|
|
|
48656
48727
|
}
|
|
48657
48728
|
}
|
|
48658
48729
|
};
|
|
48659
|
-
var defaults_default2 =
|
|
48730
|
+
var defaults_default2 = config6;
|
|
48660
48731
|
var ai_default2 = {
|
|
48661
48732
|
default: "meta.llama2-70b-chat-v1",
|
|
48662
48733
|
models: [
|
|
@@ -53276,11 +53347,11 @@ var createNeverThrowError2 = (message, result, config5 = defaultErrorConfig2) =>
|
|
|
53276
53347
|
};
|
|
53277
53348
|
function __awaiter2(thisArg, _arguments, P22, generator) {
|
|
53278
53349
|
function adopt(value) {
|
|
53279
|
-
return value instanceof P22 ? value : new P22(function(
|
|
53280
|
-
|
|
53350
|
+
return value instanceof P22 ? value : new P22(function(resolve32) {
|
|
53351
|
+
resolve32(value);
|
|
53281
53352
|
});
|
|
53282
53353
|
}
|
|
53283
|
-
return new (P22 || (P22 = Promise))(function(
|
|
53354
|
+
return new (P22 || (P22 = Promise))(function(resolve32, reject) {
|
|
53284
53355
|
function fulfilled(value) {
|
|
53285
53356
|
try {
|
|
53286
53357
|
step(generator.next(value));
|
|
@@ -53296,7 +53367,7 @@ function __awaiter2(thisArg, _arguments, P22, generator) {
|
|
|
53296
53367
|
}
|
|
53297
53368
|
}
|
|
53298
53369
|
function step(result) {
|
|
53299
|
-
result.done ?
|
|
53370
|
+
result.done ? resolve32(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
53300
53371
|
}
|
|
53301
53372
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
53302
53373
|
});
|
|
@@ -53384,14 +53455,14 @@ function __asyncValues2(o) {
|
|
|
53384
53455
|
}, i);
|
|
53385
53456
|
function verb(n) {
|
|
53386
53457
|
i[n] = o[n] && function(v22) {
|
|
53387
|
-
return new Promise(function(
|
|
53388
|
-
v22 = o[n](v22), settle(
|
|
53458
|
+
return new Promise(function(resolve32, reject) {
|
|
53459
|
+
v22 = o[n](v22), settle(resolve32, reject, v22.done, v22.value);
|
|
53389
53460
|
});
|
|
53390
53461
|
};
|
|
53391
53462
|
}
|
|
53392
|
-
function settle(
|
|
53463
|
+
function settle(resolve32, reject, d, v22) {
|
|
53393
53464
|
Promise.resolve(v22).then(function(v3) {
|
|
53394
|
-
|
|
53465
|
+
resolve32({ value: v3, done: d });
|
|
53395
53466
|
}, reject);
|
|
53396
53467
|
}
|
|
53397
53468
|
}
|
|
@@ -56703,7 +56774,7 @@ var quotes2 = collect2([
|
|
|
56703
56774
|
]);
|
|
56704
56775
|
var export_prompts2 = import_prompts2.default;
|
|
56705
56776
|
var import_node_forge2 = __toESM3(require_lib2(), 1);
|
|
56706
|
-
function
|
|
56777
|
+
function deepMerge2(target, source) {
|
|
56707
56778
|
if (Array.isArray(source) && !Array.isArray(target)) {
|
|
56708
56779
|
return source;
|
|
56709
56780
|
}
|
|
@@ -56711,7 +56782,7 @@ function deepMerge(target, source) {
|
|
|
56711
56782
|
return source.map((sourceItem, index) => {
|
|
56712
56783
|
const targetItem = target[index];
|
|
56713
56784
|
if (isObject32(sourceItem) && isObject32(targetItem)) {
|
|
56714
|
-
return
|
|
56785
|
+
return deepMerge2(targetItem, sourceItem);
|
|
56715
56786
|
}
|
|
56716
56787
|
return sourceItem;
|
|
56717
56788
|
});
|
|
@@ -56727,7 +56798,7 @@ function deepMerge(target, source) {
|
|
|
56727
56798
|
if (sourceValue === null || sourceValue === undefined) {
|
|
56728
56799
|
merged[key] = sourceValue;
|
|
56729
56800
|
} else if (isObject32(sourceValue) && isObject32(targetValue)) {
|
|
56730
|
-
merged[key] =
|
|
56801
|
+
merged[key] = deepMerge2(targetValue, sourceValue);
|
|
56731
56802
|
} else {
|
|
56732
56803
|
merged[key] = sourceValue;
|
|
56733
56804
|
}
|
|
@@ -56738,35 +56809,37 @@ function deepMerge(target, source) {
|
|
|
56738
56809
|
function isObject32(item) {
|
|
56739
56810
|
return Boolean(item && typeof item === "object" && !Array.isArray(item));
|
|
56740
56811
|
}
|
|
56741
|
-
async function
|
|
56742
|
-
const configPath =
|
|
56812
|
+
async function loadConfig2({ name, cwd, defaultConfig: defaultConfig2 }) {
|
|
56813
|
+
const configPath = resolve3(cwd || process22.cwd(), `${name}.config`);
|
|
56743
56814
|
try {
|
|
56744
56815
|
const importedConfig = await import(configPath);
|
|
56745
56816
|
const loadedConfig = importedConfig.default || importedConfig;
|
|
56746
|
-
return
|
|
56817
|
+
return deepMerge2(defaultConfig2, loadedConfig);
|
|
56747
56818
|
} catch (error) {
|
|
56748
|
-
return
|
|
56749
|
-
}
|
|
56750
|
-
}
|
|
56751
|
-
var
|
|
56819
|
+
return defaultConfig2;
|
|
56820
|
+
}
|
|
56821
|
+
}
|
|
56822
|
+
var defaultConfig2 = {
|
|
56823
|
+
altNameIPs: ["127.0.0.1"],
|
|
56824
|
+
altNameURIs: ["localhost"],
|
|
56825
|
+
organizationName: "Local Development",
|
|
56826
|
+
countryName: "US",
|
|
56827
|
+
stateName: "California",
|
|
56828
|
+
localityName: "Playa Vista",
|
|
56829
|
+
commonName: "stacks.localhost",
|
|
56830
|
+
validityDays: 825,
|
|
56831
|
+
hostCertCN: "stacks.localhost",
|
|
56832
|
+
domain: "stacks.localhost",
|
|
56833
|
+
rootCA: { certificate: "", privateKey: "" },
|
|
56834
|
+
basePath: "",
|
|
56835
|
+
caCertPath: path.join(os22.homedir(), ".stacks", "ssl", `stacks.localhost.ca.crt`),
|
|
56836
|
+
certPath: path.join(os22.homedir(), ".stacks", "ssl", `stacks.localhost.crt`),
|
|
56837
|
+
keyPath: path.join(os22.homedir(), ".stacks", "ssl", `stacks.localhost.crt.key`),
|
|
56838
|
+
verbose: false
|
|
56839
|
+
};
|
|
56840
|
+
var config42 = await loadConfig2({
|
|
56752
56841
|
name: "tls",
|
|
56753
|
-
defaultConfig:
|
|
56754
|
-
altNameIPs: ["127.0.0.1"],
|
|
56755
|
-
altNameURIs: ["localhost"],
|
|
56756
|
-
organizationName: "Local Development",
|
|
56757
|
-
countryName: "US",
|
|
56758
|
-
stateName: "California",
|
|
56759
|
-
localityName: "Playa Vista",
|
|
56760
|
-
commonName: "stacks.localhost",
|
|
56761
|
-
validityDays: 825,
|
|
56762
|
-
hostCertCN: "stacks.localhost",
|
|
56763
|
-
domain: "stacks.localhost",
|
|
56764
|
-
rootCAObject: { certificate: "", privateKey: "" },
|
|
56765
|
-
caCertPath: path.join(os22.homedir(), ".stacks", "ssl", `stacks.localhost.ca.crt`),
|
|
56766
|
-
certPath: path.join(os22.homedir(), ".stacks", "ssl", `stacks.localhost.crt`),
|
|
56767
|
-
keyPath: path.join(os22.homedir(), ".stacks", "ssl", `stacks.localhost.crt.key`),
|
|
56768
|
-
verbose: false
|
|
56769
|
-
}
|
|
56842
|
+
defaultConfig: defaultConfig2
|
|
56770
56843
|
});
|
|
56771
56844
|
var import_node_forge = __toESM3(require_lib2(), 1);
|
|
56772
56845
|
function makeNumberPositive(hexString) {
|
|
@@ -56900,12 +56973,12 @@ async function createRootCA(options22 = {}) {
|
|
|
56900
56973
|
async function generateCertificate(options22) {
|
|
56901
56974
|
debugLog("cert", "Generating new certificate", options22.verbose);
|
|
56902
56975
|
debugLog("cert", `Options: ${JSON.stringify(options22)}`, options22.verbose);
|
|
56903
|
-
if (!options22.
|
|
56976
|
+
if (!options22.rootCA?.certificate || !options22.rootCA?.privateKey) {
|
|
56904
56977
|
throw new Error("Root CA certificate and private key are required");
|
|
56905
56978
|
}
|
|
56906
|
-
const caCert = import_node_forge2.pki.certificateFromPem(options22.
|
|
56907
|
-
const caKey = import_node_forge2.pki.privateKeyFromPem(options22.
|
|
56908
|
-
debugLog("cert", "Generating 2048-bit RSA key pair for host certificate", options22
|
|
56979
|
+
const caCert = import_node_forge2.pki.certificateFromPem(options22.rootCA.certificate);
|
|
56980
|
+
const caKey = import_node_forge2.pki.privateKeyFromPem(options22.rootCA.privateKey);
|
|
56981
|
+
debugLog("cert", "Generating 2048-bit RSA key pair for host certificate", options22.verbose);
|
|
56909
56982
|
const keySize = 2048;
|
|
56910
56983
|
const { privateKey, publicKey } = import_node_forge2.pki.rsa.generateKeyPair(keySize);
|
|
56911
56984
|
const attributes = options22.certificateAttributes || [
|
|
@@ -56978,8 +57051,8 @@ async function addCertToSystemTrustStoreAndSaveCert(cert, caCert, options22) {
|
|
|
56978
57051
|
}
|
|
56979
57052
|
function storeCertificate(cert, options22) {
|
|
56980
57053
|
debugLog("storage", `Storing certificate and private key with options: ${JSON.stringify(options22)}`, options22?.verbose);
|
|
56981
|
-
const certPath = options22?.certPath || config42.certPath;
|
|
56982
|
-
const certKeyPath = options22?.keyPath || config42.keyPath;
|
|
57054
|
+
const certPath = path3.join(options22?.basePath || config42.basePath, options22?.certPath || config42.certPath);
|
|
57055
|
+
const certKeyPath = path3.join(options22?.basePath || config42.basePath, options22?.keyPath || config42.keyPath);
|
|
56983
57056
|
debugLog("storage", `Certificate path: ${certPath}`, options22?.verbose);
|
|
56984
57057
|
debugLog("storage", `Private key path: ${certKeyPath}`, options22?.verbose);
|
|
56985
57058
|
const certDir = path3.dirname(certPath);
|
|
@@ -57001,7 +57074,7 @@ function storeCertificate(cert, options22) {
|
|
|
57001
57074
|
}
|
|
57002
57075
|
function storeCACertificate(caCert, options22) {
|
|
57003
57076
|
debugLog("storage", "Storing CA certificate", options22?.verbose);
|
|
57004
|
-
const caCertPath = options22?.caCertPath || config42.caCertPath;
|
|
57077
|
+
const caCertPath = path3.join(options22?.basePath || config42.basePath, options22?.caCertPath || config42.caCertPath);
|
|
57005
57078
|
debugLog("storage", `CA certificate path: ${caCertPath}`, options22?.verbose);
|
|
57006
57079
|
const caCertDir = path3.dirname(caCertPath);
|
|
57007
57080
|
if (!fs2.existsSync(caCertDir)) {
|
|
@@ -57017,172 +57090,155 @@ var export_tls = import_node_forge2.tls;
|
|
|
57017
57090
|
var export_pki = import_node_forge2.pki;
|
|
57018
57091
|
var export_forge = import_node_forge2.default;
|
|
57019
57092
|
|
|
57020
|
-
// src/
|
|
57021
|
-
|
|
57022
|
-
|
|
57023
|
-
|
|
57024
|
-
// node_modules/bun-config/dist/index.js
|
|
57025
|
-
import { resolve as resolve3 } from "path";
|
|
57026
|
-
import process3 from "process";
|
|
57027
|
-
function deepMerge2(target, source) {
|
|
57028
|
-
if (Array.isArray(source) && !Array.isArray(target)) {
|
|
57029
|
-
return source;
|
|
57030
|
-
}
|
|
57031
|
-
if (Array.isArray(source) && Array.isArray(target)) {
|
|
57032
|
-
return source.map((sourceItem, index) => {
|
|
57033
|
-
const targetItem = target[index];
|
|
57034
|
-
if (isObject5(sourceItem) && isObject5(targetItem)) {
|
|
57035
|
-
return deepMerge2(targetItem, sourceItem);
|
|
57036
|
-
}
|
|
57037
|
-
return sourceItem;
|
|
57038
|
-
});
|
|
57039
|
-
}
|
|
57040
|
-
if (!isObject5(source) || !isObject5(target)) {
|
|
57041
|
-
return source;
|
|
57042
|
-
}
|
|
57043
|
-
const merged = { ...target };
|
|
57044
|
-
for (const key in source) {
|
|
57045
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
57046
|
-
const sourceValue = source[key];
|
|
57047
|
-
const targetValue = merged[key];
|
|
57048
|
-
if (sourceValue === null || sourceValue === undefined) {
|
|
57049
|
-
merged[key] = sourceValue;
|
|
57050
|
-
} else if (isObject5(sourceValue) && isObject5(targetValue)) {
|
|
57051
|
-
merged[key] = deepMerge2(targetValue, sourceValue);
|
|
57052
|
-
} else {
|
|
57053
|
-
merged[key] = sourceValue;
|
|
57054
|
-
}
|
|
57055
|
-
}
|
|
57056
|
-
}
|
|
57057
|
-
return merged;
|
|
57093
|
+
// src/https.ts
|
|
57094
|
+
var cachedSSLConfig = null;
|
|
57095
|
+
function isMultiProxyConfig(options3) {
|
|
57096
|
+
return "proxies" in options3 && Array.isArray(options3.proxies);
|
|
57058
57097
|
}
|
|
57059
|
-
function
|
|
57060
|
-
return
|
|
57098
|
+
function isMultiProxyOptions(options3) {
|
|
57099
|
+
return "proxies" in options3 && Array.isArray(options3.proxies);
|
|
57061
57100
|
}
|
|
57062
|
-
|
|
57063
|
-
|
|
57064
|
-
try {
|
|
57065
|
-
const importedConfig = await import(configPath);
|
|
57066
|
-
const loadedConfig = importedConfig.default || importedConfig;
|
|
57067
|
-
return deepMerge2(defaultConfig, loadedConfig);
|
|
57068
|
-
} catch (error) {
|
|
57069
|
-
return defaultConfig;
|
|
57070
|
-
}
|
|
57101
|
+
function isSingleProxyOptions(options3) {
|
|
57102
|
+
return "to" in options3 && typeof options3.to === "string";
|
|
57071
57103
|
}
|
|
57072
|
-
|
|
57073
|
-
|
|
57074
|
-
|
|
57075
|
-
|
|
57076
|
-
|
|
57077
|
-
|
|
57078
|
-
|
|
57079
|
-
|
|
57080
|
-
|
|
57081
|
-
|
|
57082
|
-
|
|
57083
|
-
|
|
57084
|
-
|
|
57085
|
-
|
|
57104
|
+
function resolveSSLPaths(options3, defaultConfig3) {
|
|
57105
|
+
const domain = isMultiProxyConfig(options3) ? options3.proxies[0].to || "stacks.localhost" : options3.to || "stacks.localhost";
|
|
57106
|
+
if (typeof options3.https === "object" && typeof defaultConfig3.https === "object") {
|
|
57107
|
+
const hasAllPaths = options3.https.caCertPath && options3.https.certPath && options3.https.keyPath;
|
|
57108
|
+
if (hasAllPaths) {
|
|
57109
|
+
const baseConfig = httpsConfig({
|
|
57110
|
+
...options3,
|
|
57111
|
+
to: domain,
|
|
57112
|
+
https: defaultConfig3.https
|
|
57113
|
+
});
|
|
57114
|
+
const altNameIPs = options3.https.altNameIPs?.filter((ip) => ip !== undefined) || baseConfig.altNameIPs;
|
|
57115
|
+
const altNameURIs = options3.https.altNameURIs?.filter((uri) => uri !== undefined) || baseConfig.altNameURIs;
|
|
57116
|
+
return {
|
|
57117
|
+
...baseConfig,
|
|
57118
|
+
caCertPath: options3.https.caCertPath || baseConfig.caCertPath,
|
|
57119
|
+
certPath: options3.https.certPath || baseConfig.certPath,
|
|
57120
|
+
keyPath: options3.https.keyPath || baseConfig.keyPath,
|
|
57121
|
+
basePath: options3.https.basePath || baseConfig.basePath,
|
|
57122
|
+
commonName: options3.https.commonName || baseConfig.commonName,
|
|
57123
|
+
organizationName: options3.https.organizationName || baseConfig.organizationName,
|
|
57124
|
+
countryName: options3.https.countryName || baseConfig.countryName,
|
|
57125
|
+
stateName: options3.https.stateName || baseConfig.stateName,
|
|
57126
|
+
localityName: options3.https.localityName || baseConfig.localityName,
|
|
57127
|
+
validityDays: options3.https.validityDays || baseConfig.validityDays,
|
|
57128
|
+
altNameIPs,
|
|
57129
|
+
altNameURIs,
|
|
57130
|
+
verbose: options3.verbose || baseConfig.verbose
|
|
57131
|
+
};
|
|
57132
|
+
}
|
|
57086
57133
|
}
|
|
57087
|
-
|
|
57088
|
-
|
|
57089
|
-
|
|
57090
|
-
|
|
57091
|
-
function isMultiProxyConfig(options3) {
|
|
57092
|
-
return "proxies" in options3;
|
|
57134
|
+
return httpsConfig({
|
|
57135
|
+
...options3,
|
|
57136
|
+
to: domain
|
|
57137
|
+
});
|
|
57093
57138
|
}
|
|
57094
57139
|
function generateWildcardPatterns(domain) {
|
|
57095
57140
|
const patterns = new Set;
|
|
57096
57141
|
patterns.add(domain);
|
|
57097
57142
|
const parts = domain.split(".");
|
|
57098
|
-
if (parts.length >= 2)
|
|
57143
|
+
if (parts.length >= 2)
|
|
57099
57144
|
patterns.add(`*.${parts.slice(1).join(".")}`);
|
|
57100
|
-
}
|
|
57101
57145
|
return Array.from(patterns);
|
|
57102
57146
|
}
|
|
57103
|
-
function
|
|
57104
|
-
|
|
57105
|
-
|
|
57106
|
-
|
|
57107
|
-
|
|
57108
|
-
|
|
57109
|
-
|
|
57110
|
-
|
|
57111
|
-
|
|
57112
|
-
|
|
57113
|
-
|
|
57114
|
-
|
|
57115
|
-
|
|
57116
|
-
|
|
57117
|
-
|
|
57118
|
-
|
|
57119
|
-
|
|
57120
|
-
|
|
57121
|
-
|
|
57122
|
-
|
|
57123
|
-
|
|
57124
|
-
const
|
|
57125
|
-
debugLog2("ssl", `Generated domain patterns: ${uniqueDomains.join(", ")}`, verbose);
|
|
57147
|
+
function getPrimaryDomain(options3) {
|
|
57148
|
+
if (!options3)
|
|
57149
|
+
return "stacks.localhost";
|
|
57150
|
+
if (isMultiProxyOptions(options3) && options3.proxies.length > 0)
|
|
57151
|
+
return options3.proxies[0].to || "stacks.localhost";
|
|
57152
|
+
if (isSingleProxyOptions(options3))
|
|
57153
|
+
return options3.to || "stacks.localhost";
|
|
57154
|
+
return "stacks.localhost";
|
|
57155
|
+
}
|
|
57156
|
+
function generateSSLPaths(options3) {
|
|
57157
|
+
const domain = getPrimaryDomain(options3);
|
|
57158
|
+
let basePath = "";
|
|
57159
|
+
if (typeof options3?.https === "object") {
|
|
57160
|
+
basePath = options3.https.basePath || "";
|
|
57161
|
+
return {
|
|
57162
|
+
caCertPath: options3.https.caCertPath || join4(basePath, `${domain}.ca.crt`),
|
|
57163
|
+
certPath: options3.https.certPath || join4(basePath, `${domain}.crt`),
|
|
57164
|
+
keyPath: options3.https.keyPath || join4(basePath, `${domain}.key`)
|
|
57165
|
+
};
|
|
57166
|
+
}
|
|
57167
|
+
const sslBase = basePath || join4(homedir2(), ".stacks", "ssl");
|
|
57168
|
+
const sanitizedDomain = domain.replace(/\*/g, "wildcard");
|
|
57126
57169
|
return {
|
|
57127
|
-
|
|
57128
|
-
|
|
57129
|
-
|
|
57130
|
-
certPath: httpsConfig?.certPath ?? path6.join(sslBase, "rpx.crt"),
|
|
57131
|
-
keyPath: httpsConfig?.keyPath ?? path6.join(sslBase, "rpx.key"),
|
|
57132
|
-
altNameIPs: httpsConfig?.altNameIPs ?? ["127.0.0.1", "::1"],
|
|
57133
|
-
altNameURIs: httpsConfig?.altNameURIs ?? [],
|
|
57134
|
-
commonName: httpsConfig?.commonName ?? domains[0],
|
|
57135
|
-
organizationName: httpsConfig?.organizationName ?? "Local Development",
|
|
57136
|
-
countryName: httpsConfig?.countryName ?? "US",
|
|
57137
|
-
stateName: httpsConfig?.stateName ?? "California",
|
|
57138
|
-
localityName: httpsConfig?.localityName ?? "Playa Vista",
|
|
57139
|
-
validityDays: httpsConfig?.validityDays ?? 825,
|
|
57140
|
-
verbose: verbose ?? false,
|
|
57141
|
-
subjectAltNames: uniqueDomains.map((domain) => ({
|
|
57142
|
-
type: 2,
|
|
57143
|
-
value: domain
|
|
57144
|
-
}))
|
|
57170
|
+
caCertPath: join4(sslBase, `${sanitizedDomain}.ca.crt`),
|
|
57171
|
+
certPath: join4(sslBase, `${sanitizedDomain}.crt`),
|
|
57172
|
+
keyPath: join4(sslBase, `${sanitizedDomain}.key`)
|
|
57145
57173
|
};
|
|
57146
57174
|
}
|
|
57147
|
-
function
|
|
57148
|
-
const
|
|
57149
|
-
|
|
57150
|
-
|
|
57151
|
-
|
|
57152
|
-
|
|
57153
|
-
|
|
57154
|
-
|
|
57155
|
-
|
|
57156
|
-
|
|
57157
|
-
|
|
57158
|
-
|
|
57159
|
-
|
|
57160
|
-
|
|
57161
|
-
|
|
57162
|
-
|
|
57163
|
-
verbose
|
|
57164
|
-
};
|
|
57175
|
+
function getAllDomains(options3) {
|
|
57176
|
+
const domains = new Set;
|
|
57177
|
+
if (isMultiProxyOptions(options3)) {
|
|
57178
|
+
options3.proxies.forEach((proxy) => {
|
|
57179
|
+
const domain = proxy.to || "stacks.localhost";
|
|
57180
|
+
generateWildcardPatterns(domain).forEach((pattern) => domains.add(pattern));
|
|
57181
|
+
});
|
|
57182
|
+
} else if (isSingleProxyOptions(options3)) {
|
|
57183
|
+
const domain = options3.to || "stacks.localhost";
|
|
57184
|
+
generateWildcardPatterns(domain).forEach((pattern) => domains.add(pattern));
|
|
57185
|
+
} else {
|
|
57186
|
+
domains.add("stacks.localhost");
|
|
57187
|
+
}
|
|
57188
|
+
domains.add("localhost");
|
|
57189
|
+
domains.add("*.localhost");
|
|
57190
|
+
return domains;
|
|
57165
57191
|
}
|
|
57166
|
-
function
|
|
57167
|
-
|
|
57192
|
+
async function loadSSLConfig(options3) {
|
|
57193
|
+
debugLog2("ssl", `Loading SSL configuration`, options3.verbose);
|
|
57194
|
+
const mergedOptions = {
|
|
57195
|
+
...config4,
|
|
57196
|
+
...options3
|
|
57197
|
+
};
|
|
57198
|
+
options3.https = httpsConfig(mergedOptions);
|
|
57199
|
+
if (!options3.https?.keyPath && !options3.https?.certPath) {
|
|
57200
|
+
debugLog2("ssl", "No SSL configuration provided", options3.verbose);
|
|
57201
|
+
return null;
|
|
57202
|
+
}
|
|
57203
|
+
if (options3.https?.keyPath && !options3.https?.certPath || !options3.https?.keyPath && options3.https?.certPath) {
|
|
57204
|
+
const missing = !options3.https?.keyPath ? "keyPath" : "certPath";
|
|
57205
|
+
debugLog2("ssl", `Invalid SSL configuration - missing ${missing}`, options3.verbose);
|
|
57206
|
+
throw new Error(`SSL Configuration requires both keyPath and certPath. Missing: ${missing}`);
|
|
57207
|
+
}
|
|
57208
|
+
try {
|
|
57209
|
+
if (!options3.https?.keyPath || !options3.https?.certPath)
|
|
57210
|
+
return null;
|
|
57211
|
+
try {
|
|
57212
|
+
debugLog2("ssl", "Reading SSL certificate files", options3.verbose);
|
|
57213
|
+
const key = await fs3.readFile(options3.https?.keyPath, "utf8");
|
|
57214
|
+
const cert = await fs3.readFile(options3.https?.certPath, "utf8");
|
|
57215
|
+
debugLog2("ssl", "SSL configuration loaded successfully", options3.verbose);
|
|
57216
|
+
return { key, cert };
|
|
57217
|
+
} catch (error) {
|
|
57218
|
+
debugLog2("ssl", `Failed to read certificates: ${error}`, options3.verbose);
|
|
57219
|
+
return null;
|
|
57220
|
+
}
|
|
57221
|
+
} catch (err3) {
|
|
57222
|
+
debugLog2("ssl", `SSL configuration error: ${err3}`, options3.verbose);
|
|
57223
|
+
throw err3;
|
|
57224
|
+
}
|
|
57168
57225
|
}
|
|
57169
57226
|
async function generateCertificate2(options3) {
|
|
57170
57227
|
if (cachedSSLConfig) {
|
|
57171
|
-
|
|
57172
|
-
debugLog2("ssl", "Using cached SSL configuration", verbose2);
|
|
57228
|
+
debugLog2("ssl", "Using cached SSL configuration", options3.verbose);
|
|
57173
57229
|
return;
|
|
57174
57230
|
}
|
|
57175
|
-
const domains =
|
|
57176
|
-
|
|
57177
|
-
|
|
57178
|
-
const rootCAConfig = generateRootCAConfig(verbose);
|
|
57231
|
+
const domains = isMultiProxyOptions(options3) ? options3.proxies.map((proxy) => proxy.to) : [options3.to];
|
|
57232
|
+
debugLog2("ssl", `Generating certificate for domains: ${domains.join(", ")}`, options3.verbose);
|
|
57233
|
+
const rootCAConfig = httpsConfig(options3, options3.verbose);
|
|
57179
57234
|
log.info("Generating Root CA certificate...");
|
|
57180
57235
|
const caCert = await createRootCA(rootCAConfig);
|
|
57181
|
-
const hostConfig =
|
|
57236
|
+
const hostConfig = httpsConfig(options3, options3.verbose);
|
|
57237
|
+
console.log("hostConfig", hostConfig);
|
|
57182
57238
|
log.info(`Generating host certificate for: ${domains.join(", ")}`);
|
|
57183
57239
|
const hostCert = await generateCertificate({
|
|
57184
57240
|
...hostConfig,
|
|
57185
|
-
|
|
57241
|
+
rootCA: {
|
|
57186
57242
|
certificate: caCert.certificate,
|
|
57187
57243
|
privateKey: caCert.privateKey
|
|
57188
57244
|
}
|
|
@@ -57194,11 +57250,86 @@ async function generateCertificate2(options3) {
|
|
|
57194
57250
|
ca: caCert.certificate
|
|
57195
57251
|
};
|
|
57196
57252
|
log.success(`Certificate generated successfully for ${domains.length} domain${domains.length > 1 ? "s" : ""}`);
|
|
57197
|
-
debugLog2("ssl", `Certificate includes domains: ${domains.join(", ")}`, verbose);
|
|
57253
|
+
debugLog2("ssl", `Certificate includes domains: ${domains.join(", ")}`, options3.verbose);
|
|
57198
57254
|
}
|
|
57199
57255
|
function getSSLConfig() {
|
|
57200
57256
|
return cachedSSLConfig;
|
|
57201
57257
|
}
|
|
57258
|
+
async function checkExistingCertificates(options3) {
|
|
57259
|
+
const name = getPrimaryDomain(options3);
|
|
57260
|
+
const paths = generateSSLPaths(options3);
|
|
57261
|
+
try {
|
|
57262
|
+
debugLog2("ssl", `Checking certificates for ${name} at paths:`, options3?.verbose);
|
|
57263
|
+
debugLog2("ssl", `CA: ${paths.caCertPath}`, options3?.verbose);
|
|
57264
|
+
debugLog2("ssl", `Cert: ${paths.certPath}`, options3?.verbose);
|
|
57265
|
+
debugLog2("ssl", `Key: ${paths.keyPath}`, options3?.verbose);
|
|
57266
|
+
const key = await fs3.readFile(paths.keyPath, "utf8");
|
|
57267
|
+
const cert = await fs3.readFile(paths.certPath, "utf8");
|
|
57268
|
+
let ca;
|
|
57269
|
+
if (paths.caCertPath) {
|
|
57270
|
+
try {
|
|
57271
|
+
ca = await fs3.readFile(paths.caCertPath, "utf8");
|
|
57272
|
+
} catch (err3) {
|
|
57273
|
+
debugLog2("ssl", `Failed to read CA cert: ${err3}`, options3?.verbose);
|
|
57274
|
+
}
|
|
57275
|
+
}
|
|
57276
|
+
return { key, cert, ca };
|
|
57277
|
+
} catch (err3) {
|
|
57278
|
+
debugLog2("ssl", `Failed to read certificates: ${err3}`, options3?.verbose);
|
|
57279
|
+
return null;
|
|
57280
|
+
}
|
|
57281
|
+
}
|
|
57282
|
+
function httpsConfig(options3, verbose) {
|
|
57283
|
+
const primaryDomain = getPrimaryDomain(options3);
|
|
57284
|
+
debugLog2("ssl", `Primary domain: ${primaryDomain}`, verbose);
|
|
57285
|
+
const defaultPaths = generateSSLPaths(options3);
|
|
57286
|
+
if (typeof options3.https === "object") {
|
|
57287
|
+
const config5 = {
|
|
57288
|
+
domain: primaryDomain,
|
|
57289
|
+
hostCertCN: primaryDomain,
|
|
57290
|
+
basePath: options3.https.basePath || "",
|
|
57291
|
+
caCertPath: options3.https.caCertPath || defaultPaths.caCertPath,
|
|
57292
|
+
certPath: options3.https.certPath || defaultPaths.certPath,
|
|
57293
|
+
keyPath: options3.https.keyPath || defaultPaths.keyPath,
|
|
57294
|
+
altNameIPs: ["127.0.0.1", "::1"],
|
|
57295
|
+
altNameURIs: [],
|
|
57296
|
+
commonName: options3.https.commonName || primaryDomain,
|
|
57297
|
+
organizationName: options3.https.organizationName || "Local Development",
|
|
57298
|
+
countryName: options3.https.countryName || "US",
|
|
57299
|
+
stateName: options3.https.stateName || "California",
|
|
57300
|
+
localityName: options3.https.localityName || "Playa Vista",
|
|
57301
|
+
validityDays: options3.https.validityDays || 825,
|
|
57302
|
+
verbose: verbose || false,
|
|
57303
|
+
subjectAltNames: Array.from(getAllDomains(options3)).map((domain) => ({
|
|
57304
|
+
type: 2,
|
|
57305
|
+
value: domain
|
|
57306
|
+
}))
|
|
57307
|
+
};
|
|
57308
|
+
if (isValidRootCA(options3.https.rootCA)) {
|
|
57309
|
+
config5.rootCA = options3.https.rootCA;
|
|
57310
|
+
}
|
|
57311
|
+
return config5;
|
|
57312
|
+
}
|
|
57313
|
+
return {
|
|
57314
|
+
domain: primaryDomain,
|
|
57315
|
+
hostCertCN: primaryDomain,
|
|
57316
|
+
basePath: "",
|
|
57317
|
+
...defaultPaths,
|
|
57318
|
+
altNameIPs: ["127.0.0.1", "::1"],
|
|
57319
|
+
altNameURIs: [],
|
|
57320
|
+
commonName: primaryDomain,
|
|
57321
|
+
organizationName: "Local Development",
|
|
57322
|
+
countryName: "US",
|
|
57323
|
+
stateName: "California",
|
|
57324
|
+
localityName: "Playa Vista",
|
|
57325
|
+
validityDays: 825,
|
|
57326
|
+
verbose: verbose || false,
|
|
57327
|
+
subjectAltNames: Array.from(getAllDomains(options3)).map((domain) => ({
|
|
57328
|
+
type: 2,
|
|
57329
|
+
value: domain
|
|
57330
|
+
}))
|
|
57331
|
+
};
|
|
57332
|
+
}
|
|
57202
57333
|
|
|
57203
57334
|
// src/utils.ts
|
|
57204
57335
|
function debugLog2(category, message, verbose) {
|
|
@@ -57206,37 +57337,43 @@ function debugLog2(category, message, verbose) {
|
|
|
57206
57337
|
console.debug(`[rpx:${category}] ${message}`);
|
|
57207
57338
|
}
|
|
57208
57339
|
}
|
|
57209
|
-
function
|
|
57210
|
-
if (
|
|
57340
|
+
function extractHostname(options3) {
|
|
57341
|
+
if (isMultiProxyOptions(options3)) {
|
|
57211
57342
|
return options3.proxies.map((proxy) => {
|
|
57212
|
-
const
|
|
57213
|
-
return
|
|
57343
|
+
const domain = proxy.to || "stacks.localhost";
|
|
57344
|
+
return domain.startsWith("http") ? new URL(domain).hostname : domain;
|
|
57214
57345
|
});
|
|
57215
57346
|
}
|
|
57216
|
-
|
|
57217
|
-
|
|
57347
|
+
if (isSingleProxyOptions(options3)) {
|
|
57348
|
+
const domain = options3.to || "stacks.localhost";
|
|
57349
|
+
return [domain.startsWith("http") ? new URL(domain).hostname : domain];
|
|
57350
|
+
}
|
|
57351
|
+
return ["stacks.localhost"];
|
|
57352
|
+
}
|
|
57353
|
+
function isValidRootCA(value) {
|
|
57354
|
+
return typeof value === "object" && value !== null && "certificate" in value && "privateKey" in value && typeof value.certificate === "string" && typeof value.privateKey === "string";
|
|
57218
57355
|
}
|
|
57219
57356
|
|
|
57220
57357
|
// src/hosts.ts
|
|
57221
|
-
var hostsFilePath =
|
|
57358
|
+
var hostsFilePath = process3.platform === "win32" ? path4.join(process3.env.windir || "C:\\Windows", "System32", "drivers", "etc", "hosts") : "/etc/hosts";
|
|
57222
57359
|
async function sudoWrite(operation, content) {
|
|
57223
57360
|
return new Promise((resolve4, reject) => {
|
|
57224
|
-
if (
|
|
57361
|
+
if (process3.platform === "win32") {
|
|
57225
57362
|
reject(new Error("Administrator privileges required on Windows"));
|
|
57226
57363
|
return;
|
|
57227
57364
|
}
|
|
57228
|
-
const tmpFile =
|
|
57365
|
+
const tmpFile = path4.join(os3.tmpdir(), "hosts.tmp");
|
|
57229
57366
|
try {
|
|
57230
57367
|
if (operation === "append") {
|
|
57231
|
-
const currentContent =
|
|
57232
|
-
|
|
57368
|
+
const currentContent = fs5.readFileSync(hostsFilePath, "utf8");
|
|
57369
|
+
fs5.writeFileSync(tmpFile, currentContent + content, "utf8");
|
|
57233
57370
|
} else {
|
|
57234
|
-
|
|
57371
|
+
fs5.writeFileSync(tmpFile, content, "utf8");
|
|
57235
57372
|
}
|
|
57236
57373
|
const sudo = spawn("sudo", ["cp", tmpFile, hostsFilePath]);
|
|
57237
57374
|
sudo.on("close", (code) => {
|
|
57238
57375
|
try {
|
|
57239
|
-
|
|
57376
|
+
fs5.unlinkSync(tmpFile);
|
|
57240
57377
|
if (code === 0)
|
|
57241
57378
|
resolve4();
|
|
57242
57379
|
else
|
|
@@ -57247,7 +57384,7 @@ async function sudoWrite(operation, content) {
|
|
|
57247
57384
|
});
|
|
57248
57385
|
sudo.on("error", (err3) => {
|
|
57249
57386
|
try {
|
|
57250
|
-
|
|
57387
|
+
fs5.unlinkSync(tmpFile);
|
|
57251
57388
|
} catch {
|
|
57252
57389
|
}
|
|
57253
57390
|
reject(err3);
|
|
@@ -57261,7 +57398,7 @@ async function addHosts(hosts, verbose) {
|
|
|
57261
57398
|
debugLog2("hosts", `Adding hosts: ${hosts.join(", ")}`, verbose);
|
|
57262
57399
|
debugLog2("hosts", `Using hosts file at: ${hostsFilePath}`, verbose);
|
|
57263
57400
|
try {
|
|
57264
|
-
const existingContent = await
|
|
57401
|
+
const existingContent = await fs5.promises.readFile(hostsFilePath, "utf-8");
|
|
57265
57402
|
const newEntries = hosts.filter((host) => {
|
|
57266
57403
|
const ipv4Entry = `127.0.0.1 ${host}`;
|
|
57267
57404
|
const ipv6Entry = `::1 ${host}`;
|
|
@@ -57278,7 +57415,7 @@ async function addHosts(hosts, verbose) {
|
|
|
57278
57415
|
::1 ${host}`).join(`
|
|
57279
57416
|
`);
|
|
57280
57417
|
try {
|
|
57281
|
-
await
|
|
57418
|
+
await fs5.promises.appendFile(hostsFilePath, hostEntries, { flag: "a" });
|
|
57282
57419
|
log.success(`Added new hosts: ${newEntries.join(", ")}`);
|
|
57283
57420
|
} catch (writeErr) {
|
|
57284
57421
|
if (writeErr.code === "EACCES") {
|
|
@@ -57291,7 +57428,7 @@ async function addHosts(hosts, verbose) {
|
|
|
57291
57428
|
log.warn("Please add these entries to your hosts file manually:");
|
|
57292
57429
|
hostEntries.split(`
|
|
57293
57430
|
`).forEach((entry) => log.warn(entry));
|
|
57294
|
-
if (
|
|
57431
|
+
if (process3.platform === "win32") {
|
|
57295
57432
|
log.warn(`
|
|
57296
57433
|
On Windows:`);
|
|
57297
57434
|
log.warn("1. Run notepad as administrator");
|
|
@@ -57316,7 +57453,7 @@ On Unix systems:`);
|
|
|
57316
57453
|
async function removeHosts(hosts, verbose) {
|
|
57317
57454
|
debugLog2("hosts", `Removing hosts: ${hosts.join(", ")}`, verbose);
|
|
57318
57455
|
try {
|
|
57319
|
-
const content = await
|
|
57456
|
+
const content = await fs5.promises.readFile(hostsFilePath, "utf-8");
|
|
57320
57457
|
const lines = content.split(`
|
|
57321
57458
|
`);
|
|
57322
57459
|
const filteredLines = lines.filter((line, index) => {
|
|
@@ -57332,7 +57469,7 @@ async function removeHosts(hosts, verbose) {
|
|
|
57332
57469
|
`)}
|
|
57333
57470
|
`;
|
|
57334
57471
|
try {
|
|
57335
|
-
await
|
|
57472
|
+
await fs5.promises.writeFile(hostsFilePath, newContent);
|
|
57336
57473
|
log.success("Hosts removed successfully");
|
|
57337
57474
|
} catch (writeErr) {
|
|
57338
57475
|
if (writeErr.code === "EACCES") {
|
|
@@ -57348,7 +57485,7 @@ async function removeHosts(hosts, verbose) {
|
|
|
57348
57485
|
log.warn(`127.0.0.1 ${host}`);
|
|
57349
57486
|
log.warn(`::1 ${host}`);
|
|
57350
57487
|
});
|
|
57351
|
-
if (
|
|
57488
|
+
if (process3.platform === "win32") {
|
|
57352
57489
|
log.warn(`
|
|
57353
57490
|
On Windows:`);
|
|
57354
57491
|
log.warn("1. Run notepad as administrator");
|
|
@@ -57372,7 +57509,7 @@ On Unix systems:`);
|
|
|
57372
57509
|
}
|
|
57373
57510
|
async function checkHosts(hosts, verbose) {
|
|
57374
57511
|
debugLog2("hosts", `Checking hosts: ${hosts}`, verbose);
|
|
57375
|
-
const content = await
|
|
57512
|
+
const content = await fs5.promises.readFile(hostsFilePath, "utf-8");
|
|
57376
57513
|
return hosts.map((host) => {
|
|
57377
57514
|
const ipv4Entry = `127.0.0.1 ${host}`;
|
|
57378
57515
|
const ipv6Entry = `::1 ${host}`;
|
|
@@ -57412,53 +57549,20 @@ async function cleanup(options3) {
|
|
|
57412
57549
|
await Promise.all(cleanupPromises);
|
|
57413
57550
|
debugLog2("cleanup", "All cleanup tasks completed successfully", options3?.verbose);
|
|
57414
57551
|
log.success("All cleanup tasks completed successfully");
|
|
57415
|
-
|
|
57552
|
+
process9.exit(0);
|
|
57416
57553
|
} catch (err3) {
|
|
57417
57554
|
debugLog2("cleanup", `Error during cleanup: ${err3}`, options3?.verbose);
|
|
57418
57555
|
log.error("Error during cleanup:", err3);
|
|
57419
|
-
|
|
57556
|
+
process9.exit(1);
|
|
57420
57557
|
}
|
|
57421
57558
|
}
|
|
57422
|
-
|
|
57423
|
-
|
|
57424
|
-
|
|
57559
|
+
process9.on("SIGINT", cleanup);
|
|
57560
|
+
process9.on("SIGTERM", cleanup);
|
|
57561
|
+
process9.on("uncaughtException", (err3) => {
|
|
57425
57562
|
debugLog2("process", `Uncaught exception: ${err3}`, true);
|
|
57426
57563
|
log.error("Uncaught exception:", err3);
|
|
57427
57564
|
cleanup();
|
|
57428
57565
|
});
|
|
57429
|
-
async function loadSSLConfig(options3) {
|
|
57430
|
-
debugLog2("ssl", `Loading SSL configuration`, options3.verbose);
|
|
57431
|
-
if (options3.https === true)
|
|
57432
|
-
options3.https = httpsConfig(options3);
|
|
57433
|
-
else if (options3.https === false)
|
|
57434
|
-
return null;
|
|
57435
|
-
if (!options3.https?.keyPath && !options3.https?.certPath) {
|
|
57436
|
-
debugLog2("ssl", "No SSL configuration provided", options3.verbose);
|
|
57437
|
-
return null;
|
|
57438
|
-
}
|
|
57439
|
-
if (options3.https?.keyPath && !options3.https?.certPath || !options3.https?.keyPath && options3.https?.certPath) {
|
|
57440
|
-
const missing = !options3.https?.keyPath ? "keyPath" : "certPath";
|
|
57441
|
-
debugLog2("ssl", `Invalid SSL configuration - missing ${missing}`, options3.verbose);
|
|
57442
|
-
throw new Error(`SSL Configuration requires both keyPath and certPath. Missing: ${missing}`);
|
|
57443
|
-
}
|
|
57444
|
-
try {
|
|
57445
|
-
if (!options3.https?.keyPath || !options3.https?.certPath)
|
|
57446
|
-
return null;
|
|
57447
|
-
try {
|
|
57448
|
-
debugLog2("ssl", "Reading SSL certificate files", options3.verbose);
|
|
57449
|
-
const key = await fs5.promises.readFile(options3.https?.keyPath, "utf8");
|
|
57450
|
-
const cert = await fs5.promises.readFile(options3.https?.certPath, "utf8");
|
|
57451
|
-
debugLog2("ssl", "SSL configuration loaded successfully", options3.verbose);
|
|
57452
|
-
return { key, cert };
|
|
57453
|
-
} catch (error) {
|
|
57454
|
-
debugLog2("ssl", `Failed to read certificates: ${error}`, options3.verbose);
|
|
57455
|
-
return null;
|
|
57456
|
-
}
|
|
57457
|
-
} catch (err3) {
|
|
57458
|
-
debugLog2("ssl", `SSL configuration error: ${err3}`, options3.verbose);
|
|
57459
|
-
throw err3;
|
|
57460
|
-
}
|
|
57461
|
-
}
|
|
57462
57566
|
function isPortInUse(port, hostname, verbose) {
|
|
57463
57567
|
debugLog2("port", `Checking if port ${port} is in use on ${hostname}`, verbose);
|
|
57464
57568
|
return new Promise((resolve4) => {
|
|
@@ -57514,8 +57618,8 @@ async function testConnection(hostname, port, verbose) {
|
|
|
57514
57618
|
}
|
|
57515
57619
|
async function startServer(options3) {
|
|
57516
57620
|
debugLog2("server", `Starting server with options: ${JSON.stringify(options3)}`, options3.verbose);
|
|
57517
|
-
const fromUrl = new URL(options3.from
|
|
57518
|
-
const toUrl = new URL(options3.to
|
|
57621
|
+
const fromUrl = new URL((options3.from?.startsWith("http") ? options3.from : `http://${options3.from}`) || "localhost:5173");
|
|
57622
|
+
const toUrl = new URL((options3.to?.startsWith("http") ? options3.to : `http://${options3.to}`) || "stacks.localhost");
|
|
57519
57623
|
const fromPort = Number.parseInt(fromUrl.port) || (fromUrl.protocol.includes("https:") ? 443 : 80);
|
|
57520
57624
|
const hostsToCheck = [toUrl.hostname];
|
|
57521
57625
|
if (!toUrl.hostname.includes("localhost") && !toUrl.hostname.includes("127.0.0.1")) {
|
|
@@ -57532,7 +57636,7 @@ async function startServer(options3) {
|
|
|
57532
57636
|
log.warn("You can manually add this entry to your hosts file:");
|
|
57533
57637
|
log.warn(`127.0.0.1 ${toUrl.hostname}`);
|
|
57534
57638
|
log.warn(`::1 ${toUrl.hostname}`);
|
|
57535
|
-
if (
|
|
57639
|
+
if (process9.platform === "win32") {
|
|
57536
57640
|
log.warn("On Windows:");
|
|
57537
57641
|
log.warn("1. Run notepad as administrator");
|
|
57538
57642
|
log.warn("2. Open C:\\Windows\\System32\\drivers\\etc\\hosts");
|
|
@@ -57553,7 +57657,7 @@ async function startServer(options3) {
|
|
|
57553
57657
|
} catch (err3) {
|
|
57554
57658
|
debugLog2("server", `Connection test failed: ${err3}`, options3.verbose);
|
|
57555
57659
|
log.error(err3.message);
|
|
57556
|
-
|
|
57660
|
+
process9.exit(1);
|
|
57557
57661
|
}
|
|
57558
57662
|
let sslConfig = options3._cachedSSLConfig || null;
|
|
57559
57663
|
if (options3.https) {
|
|
@@ -57599,7 +57703,7 @@ async function startServer(options3) {
|
|
|
57599
57703
|
debugLog2("server", `Setting up reverse proxy with SSL config for ${toUrl.hostname}`, options3.verbose);
|
|
57600
57704
|
await setupReverseProxy({
|
|
57601
57705
|
...options3,
|
|
57602
|
-
from: options3.from,
|
|
57706
|
+
from: options3.from || "localhost:5173",
|
|
57603
57707
|
to: toUrl.hostname,
|
|
57604
57708
|
fromPort,
|
|
57605
57709
|
sourceUrl: {
|
|
@@ -57754,51 +57858,77 @@ function startHttpRedirectServer(verbose) {
|
|
|
57754
57858
|
debugLog2("redirect", "HTTP redirect server started", verbose);
|
|
57755
57859
|
}
|
|
57756
57860
|
function startProxy(options3) {
|
|
57757
|
-
|
|
57861
|
+
const mergedOptions = {
|
|
57862
|
+
...config4,
|
|
57863
|
+
...options3
|
|
57864
|
+
};
|
|
57865
|
+
debugLog2("proxy", `Starting proxy with options: ${JSON.stringify(mergedOptions)}`, mergedOptions?.verbose);
|
|
57758
57866
|
const serverOptions = {
|
|
57759
|
-
from:
|
|
57760
|
-
to:
|
|
57761
|
-
https: httpsConfig(
|
|
57762
|
-
etcHostsCleanup:
|
|
57763
|
-
verbose:
|
|
57867
|
+
from: mergedOptions.from,
|
|
57868
|
+
to: mergedOptions.to,
|
|
57869
|
+
https: httpsConfig(mergedOptions),
|
|
57870
|
+
etcHostsCleanup: mergedOptions.etcHostsCleanup,
|
|
57871
|
+
verbose: mergedOptions.verbose
|
|
57764
57872
|
};
|
|
57765
57873
|
console.log("serverOptions", serverOptions);
|
|
57766
57874
|
startServer(serverOptions).catch((err3) => {
|
|
57767
|
-
debugLog2("proxy", `Failed to start proxy: ${err3}`,
|
|
57875
|
+
debugLog2("proxy", `Failed to start proxy: ${err3}`, mergedOptions.verbose);
|
|
57768
57876
|
log.error(`Failed to start proxy: ${err3.message}`);
|
|
57769
57877
|
cleanup({
|
|
57770
|
-
domains: [
|
|
57771
|
-
etcHostsCleanup:
|
|
57772
|
-
verbose:
|
|
57878
|
+
domains: [mergedOptions.to],
|
|
57879
|
+
etcHostsCleanup: mergedOptions.etcHostsCleanup,
|
|
57880
|
+
verbose: mergedOptions.verbose
|
|
57773
57881
|
});
|
|
57774
57882
|
});
|
|
57775
57883
|
}
|
|
57776
57884
|
async function startProxies(options3) {
|
|
57777
|
-
|
|
57778
|
-
|
|
57779
|
-
|
|
57780
|
-
|
|
57781
|
-
|
|
57885
|
+
debugLog2("proxies", "Starting proxy setup", options3?.verbose);
|
|
57886
|
+
const mergedOptions = {
|
|
57887
|
+
...config4,
|
|
57888
|
+
...options3
|
|
57889
|
+
};
|
|
57890
|
+
const primaryDomain = isMultiProxyConfig(mergedOptions) ? mergedOptions.proxies[0].to || "stacks.localhost" : mergedOptions.to || "stacks.localhost";
|
|
57891
|
+
if (mergedOptions.https) {
|
|
57892
|
+
const existingSSLConfig = await checkExistingCertificates(mergedOptions);
|
|
57893
|
+
if (existingSSLConfig) {
|
|
57894
|
+
debugLog2("ssl", `Using existing certificates for ${primaryDomain}`, mergedOptions.verbose);
|
|
57895
|
+
mergedOptions._cachedSSLConfig = existingSSLConfig;
|
|
57896
|
+
} else {
|
|
57897
|
+
debugLog2("ssl", `No valid certificates found for ${primaryDomain}, generating new ones`, mergedOptions.verbose);
|
|
57898
|
+
await generateCertificate2(mergedOptions);
|
|
57899
|
+
const sslConfig2 = await checkExistingCertificates(mergedOptions);
|
|
57900
|
+
if (!sslConfig2) {
|
|
57901
|
+
throw new Error(`Failed to load SSL certificates after generation for ${primaryDomain}. Please check file permissions and paths.`);
|
|
57902
|
+
}
|
|
57903
|
+
mergedOptions._cachedSSLConfig = sslConfig2;
|
|
57904
|
+
}
|
|
57782
57905
|
}
|
|
57783
|
-
const proxyOptions =
|
|
57906
|
+
const proxyOptions = isMultiProxyConfig(mergedOptions) ? mergedOptions.proxies.map((proxy) => ({
|
|
57784
57907
|
...proxy,
|
|
57785
|
-
https:
|
|
57786
|
-
etcHostsCleanup:
|
|
57787
|
-
verbose:
|
|
57788
|
-
_cachedSSLConfig:
|
|
57789
|
-
})) : [
|
|
57790
|
-
|
|
57791
|
-
|
|
57908
|
+
https: mergedOptions.https,
|
|
57909
|
+
etcHostsCleanup: mergedOptions.etcHostsCleanup,
|
|
57910
|
+
verbose: mergedOptions.verbose,
|
|
57911
|
+
_cachedSSLConfig: mergedOptions._cachedSSLConfig
|
|
57912
|
+
})) : [{
|
|
57913
|
+
from: mergedOptions.from || "localhost:5173",
|
|
57914
|
+
to: mergedOptions.to || "stacks.localhost",
|
|
57915
|
+
https: mergedOptions.https,
|
|
57916
|
+
etcHostsCleanup: mergedOptions.etcHostsCleanup,
|
|
57917
|
+
verbose: mergedOptions.verbose,
|
|
57918
|
+
_cachedSSLConfig: mergedOptions._cachedSSLConfig
|
|
57919
|
+
}];
|
|
57920
|
+
const domains = proxyOptions.map((opt) => opt.to || "stacks.localhost");
|
|
57921
|
+
const sslConfig = mergedOptions._cachedSSLConfig;
|
|
57792
57922
|
const cleanupHandler = () => cleanup({
|
|
57793
57923
|
domains,
|
|
57794
|
-
etcHostsCleanup:
|
|
57795
|
-
verbose:
|
|
57924
|
+
etcHostsCleanup: mergedOptions.etcHostsCleanup || false,
|
|
57925
|
+
verbose: mergedOptions.verbose || false
|
|
57796
57926
|
});
|
|
57797
|
-
|
|
57798
|
-
|
|
57799
|
-
|
|
57927
|
+
process9.on("SIGINT", cleanupHandler);
|
|
57928
|
+
process9.on("SIGTERM", cleanupHandler);
|
|
57929
|
+
process9.on("uncaughtException", (err3) => {
|
|
57800
57930
|
debugLog2("process", `Uncaught exception: ${err3}`, true);
|
|
57801
|
-
|
|
57931
|
+
console.error("Uncaught exception:", err3);
|
|
57802
57932
|
cleanupHandler();
|
|
57803
57933
|
});
|
|
57804
57934
|
for (const option of proxyOptions) {
|
|
@@ -57815,14 +57945,11 @@ async function startProxies(options3) {
|
|
|
57815
57945
|
});
|
|
57816
57946
|
} catch (err3) {
|
|
57817
57947
|
debugLog2("proxies", `Failed to start proxy for ${option.to}: ${err3}`, option.verbose);
|
|
57818
|
-
|
|
57948
|
+
console.error(`Failed to start proxy for ${option.to}:`, err3);
|
|
57819
57949
|
cleanupHandler();
|
|
57820
57950
|
}
|
|
57821
57951
|
}
|
|
57822
57952
|
}
|
|
57823
|
-
function isMultiProxyConfig2(options3) {
|
|
57824
|
-
return "proxies" in options3;
|
|
57825
|
-
}
|
|
57826
57953
|
|
|
57827
57954
|
// src/index.ts
|
|
57828
57955
|
var src_default = startProxies;
|
|
@@ -57832,17 +57959,27 @@ export {
|
|
|
57832
57959
|
startProxies,
|
|
57833
57960
|
startHttpRedirectServer,
|
|
57834
57961
|
setupReverseProxy,
|
|
57962
|
+
resolveSSLPaths,
|
|
57835
57963
|
removeHosts,
|
|
57964
|
+
loadSSLConfig,
|
|
57965
|
+
isValidRootCA,
|
|
57966
|
+
isSingleProxyOptions,
|
|
57967
|
+
isMultiProxyOptions,
|
|
57836
57968
|
isMultiProxyConfig,
|
|
57837
57969
|
httpsConfig,
|
|
57838
57970
|
hostsFilePath,
|
|
57839
57971
|
getSSLConfig,
|
|
57972
|
+
getPrimaryDomain,
|
|
57973
|
+
getAllDomains,
|
|
57974
|
+
generateWildcardPatterns,
|
|
57975
|
+
generateSSLPaths,
|
|
57840
57976
|
generateCertificate2 as generateCertificate,
|
|
57841
|
-
|
|
57977
|
+
extractHostname,
|
|
57842
57978
|
src_default as default,
|
|
57843
57979
|
debugLog2 as debugLog,
|
|
57844
|
-
|
|
57980
|
+
config4 as config,
|
|
57845
57981
|
cleanup,
|
|
57846
57982
|
checkHosts,
|
|
57983
|
+
checkExistingCertificates,
|
|
57847
57984
|
addHosts
|
|
57848
57985
|
};
|