xypriss 9.14.25 → 9.14.28
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/cjs/index.js +114 -58
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +114 -59
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.ts +8037 -8059
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -145,7 +145,7 @@ const DEFAULT_LOGGER_CONFIG = {
|
|
|
145
145
|
},
|
|
146
146
|
};
|
|
147
147
|
|
|
148
|
-
function getSysApi() {
|
|
148
|
+
function getSysApi$1() {
|
|
149
149
|
if (typeof globalThis !== "undefined" && globalThis.__sys__) {
|
|
150
150
|
return globalThis.__sys__;
|
|
151
151
|
}
|
|
@@ -983,7 +983,7 @@ function initializeLogger(config) {
|
|
|
983
983
|
* in the `.env` file — useful for staging environments that mimic dev but
|
|
984
984
|
* must not relax CSP/HSTS/COEP.
|
|
985
985
|
*/
|
|
986
|
-
const sys = getSysApi();
|
|
986
|
+
const sys = getSysApi$1();
|
|
987
987
|
const isDev = sys?.__env__
|
|
988
988
|
? sys.__env__.isDevelopment() &&
|
|
989
989
|
sys.__env__.get("XSEC_TRUST", "true") === "true"
|
|
@@ -1096,8 +1096,8 @@ const xemsKeyPlaceholder = "CHANGE_ME_TO_A_SECURE_32_CHAR_KEY";
|
|
|
1096
1096
|
* This configuration is used when no custom configuration is provided.
|
|
1097
1097
|
*
|
|
1098
1098
|
*/
|
|
1099
|
-
const DEFAULT_HOST = getSysApi()?.__env__?.get("XYPRISS_HOST") || "localhost";
|
|
1100
|
-
const DEFAULT_PORT = (getSysApi()?.__env__?.get("XYPRISS_PORT") ||
|
|
1099
|
+
const DEFAULT_HOST = getSysApi$1()?.__env__?.get("XYPRISS_HOST") || "localhost";
|
|
1100
|
+
const DEFAULT_PORT = (getSysApi$1()?.__env__?.get("XYPRISS_PORT") ||
|
|
1101
1101
|
8085);
|
|
1102
1102
|
// Default configuration
|
|
1103
1103
|
const DEFAULT_OPTIONS = {
|
|
@@ -1314,7 +1314,7 @@ const DEFAULT_OPTIONS = {
|
|
|
1314
1314
|
* once `__sys__` is initialized, deliberately avoiding reliance on Node.js core modules (`node:os`).
|
|
1315
1315
|
*/
|
|
1316
1316
|
get tempFileDir() {
|
|
1317
|
-
return getSysApi()?.path.tmpUserDir + "/.uploads/";
|
|
1317
|
+
return getSysApi$1()?.path.tmpUserDir + "/.uploads/";
|
|
1318
1318
|
},
|
|
1319
1319
|
createParentPath: true,
|
|
1320
1320
|
preservePath: false,
|
|
@@ -1872,7 +1872,7 @@ class FileUploadManager {
|
|
|
1872
1872
|
return;
|
|
1873
1873
|
if (this.config?.storage === "memory" && file.path) {
|
|
1874
1874
|
try {
|
|
1875
|
-
const sys = getSysApi();
|
|
1875
|
+
const sys = getSysApi$1();
|
|
1876
1876
|
if (sys.fs.exist(file.path)) {
|
|
1877
1877
|
file.buffer = await sys.fs.readBytes(file.path);
|
|
1878
1878
|
sys.fs.rm(file.path, { force: true });
|
|
@@ -1904,7 +1904,7 @@ class FileUploadManager {
|
|
|
1904
1904
|
}
|
|
1905
1905
|
if (file.path) {
|
|
1906
1906
|
try {
|
|
1907
|
-
const sys = getSysApi();
|
|
1907
|
+
const sys = getSysApi$1();
|
|
1908
1908
|
if (sys.fs.exist(file.path)) {
|
|
1909
1909
|
_cachedBuffer = sys.fs.readBytesSync(file.path);
|
|
1910
1910
|
return _cachedBuffer;
|
|
@@ -1924,7 +1924,7 @@ class FileUploadManager {
|
|
|
1924
1924
|
if (!file.toBuffer) {
|
|
1925
1925
|
file.toBuffer = async function () {
|
|
1926
1926
|
if (file.path) {
|
|
1927
|
-
const sys = getSysApi();
|
|
1927
|
+
const sys = getSysApi$1();
|
|
1928
1928
|
if (sys.fs.exist(file.path)) {
|
|
1929
1929
|
return await sys.fs.readBytes(file.path);
|
|
1930
1930
|
}
|
|
@@ -1935,7 +1935,7 @@ class FileUploadManager {
|
|
|
1935
1935
|
}
|
|
1936
1936
|
if (!file.getStream) {
|
|
1937
1937
|
file.getStream = function () {
|
|
1938
|
-
const sys = getSysApi();
|
|
1938
|
+
const sys = getSysApi$1();
|
|
1939
1939
|
if (file.path && sys.fs.exist(file.path)) {
|
|
1940
1940
|
return sys.fs.createReadStream(file.path);
|
|
1941
1941
|
}
|
|
@@ -1999,7 +1999,7 @@ class FileUploadManager {
|
|
|
1999
1999
|
}
|
|
2000
2000
|
}
|
|
2001
2001
|
if (this.config?.allowedExtensions) {
|
|
2002
|
-
const sys = getSysApi();
|
|
2002
|
+
const sys = getSysApi$1();
|
|
2003
2003
|
const ext = sys.path.extname(file.originalname).toLowerCase();
|
|
2004
2004
|
this.logger.debug("server", `Checking extensions: ${this.config.allowedExtensions.join(", ")}, file ext: ${ext}`);
|
|
2005
2005
|
if (!this.config.allowedExtensions.includes(ext)) {
|
|
@@ -4181,7 +4181,7 @@ class ConfigSyntaxParser {
|
|
|
4181
4181
|
}
|
|
4182
4182
|
getFile(filePath) {
|
|
4183
4183
|
try {
|
|
4184
|
-
const sys = getSysApi();
|
|
4184
|
+
const sys = getSysApi$1();
|
|
4185
4185
|
// In XyPriss config, a leading / is often intended as project-root relative
|
|
4186
4186
|
// especially when the separator dot consumes the '.' of './path'
|
|
4187
4187
|
const cleanPath = filePath.startsWith("/")
|
|
@@ -4508,13 +4508,15 @@ function identifyProjectRoot(filePath) {
|
|
|
4508
4508
|
if (manifest?.roots) {
|
|
4509
4509
|
for (const [pluginRoot, _pluginName] of Object.entries(manifest.roots)) {
|
|
4510
4510
|
const normPluginRoot = pluginRoot.replace(/\\/g, "/");
|
|
4511
|
-
if (normalized === normPluginRoot ||
|
|
4511
|
+
if (normalized === normPluginRoot ||
|
|
4512
|
+
normalized.startsWith(normPluginRoot + "/")) {
|
|
4512
4513
|
return pluginRoot;
|
|
4513
4514
|
}
|
|
4514
4515
|
}
|
|
4515
4516
|
}
|
|
4516
4517
|
// 2. Direct match against primary project root
|
|
4517
|
-
if (normalized === primaryRoot ||
|
|
4518
|
+
if (normalized === primaryRoot ||
|
|
4519
|
+
normalized.startsWith(primaryRoot + "/")) {
|
|
4518
4520
|
// If inside node_modules, it is an undeclared/untrusted dependency, NOT the application root!
|
|
4519
4521
|
if (normalized.includes("/node_modules/")) {
|
|
4520
4522
|
return undefined;
|
|
@@ -4589,7 +4591,9 @@ function captureNativeFrames() {
|
|
|
4589
4591
|
const fnName = typeof site.getFunctionName === "function"
|
|
4590
4592
|
? site.getFunctionName() || ""
|
|
4591
4593
|
: "";
|
|
4592
|
-
const isEval = typeof site.isEval === "function"
|
|
4594
|
+
const isEval = typeof site.isEval === "function"
|
|
4595
|
+
? Boolean(site.isEval())
|
|
4596
|
+
: false;
|
|
4593
4597
|
frames.push({
|
|
4594
4598
|
filePath: normalizeScriptName(rawFile),
|
|
4595
4599
|
fnName,
|
|
@@ -4612,7 +4616,8 @@ function captureNativeFrames() {
|
|
|
4612
4616
|
frames.push({
|
|
4613
4617
|
filePath: normalizeScriptName(rawScript),
|
|
4614
4618
|
fnName,
|
|
4615
|
-
isEval: !rawScript &&
|
|
4619
|
+
isEval: !rawScript &&
|
|
4620
|
+
(fnName === "eval" || fnName === "anonymous"),
|
|
4616
4621
|
});
|
|
4617
4622
|
}
|
|
4618
4623
|
}
|
|
@@ -4759,7 +4764,9 @@ function loadXyConfig(projectRoot) {
|
|
|
4759
4764
|
try {
|
|
4760
4765
|
pkgJson = JSON.parse(fs$1.readFileSync(pkgPath, "utf-8"));
|
|
4761
4766
|
}
|
|
4762
|
-
catch {
|
|
4767
|
+
catch {
|
|
4768
|
+
/* ignore */
|
|
4769
|
+
}
|
|
4763
4770
|
}
|
|
4764
4771
|
// Resolve references &(pkg), &(env), etc.
|
|
4765
4772
|
const sys = globalThis.__sys__;
|
|
@@ -4769,7 +4776,7 @@ function loadXyConfig(projectRoot) {
|
|
|
4769
4776
|
if (sys?.__env__?.[XY_ENV_INTERNAL_GET_FOR_ROOT]) {
|
|
4770
4777
|
envProvider = {
|
|
4771
4778
|
has: (key) => sys.__env__[XY_ENV_INTERNAL_GET_FOR_ROOT](key, projectRoot) !== undefined,
|
|
4772
|
-
get: (key) => sys.__env__[XY_ENV_INTERNAL_GET_FOR_ROOT](key, projectRoot)
|
|
4779
|
+
get: (key) => sys.__env__[XY_ENV_INTERNAL_GET_FOR_ROOT](key, projectRoot),
|
|
4773
4780
|
};
|
|
4774
4781
|
}
|
|
4775
4782
|
const parser = new ConfigSyntaxParser(pkgJson, envProvider);
|
|
@@ -5616,7 +5623,7 @@ class XyPrissRunner {
|
|
|
5616
5623
|
* @returns {string} Path to `<os.tmpdir>/nehonix.xypriss.data`
|
|
5617
5624
|
*/
|
|
5618
5625
|
function getXyprissTempDir() {
|
|
5619
|
-
const sys = getSysApi();
|
|
5626
|
+
const sys = getSysApi$1();
|
|
5620
5627
|
return sys.path.join(sys.path.tempDir(), "nehonix.xypriss.data");
|
|
5621
5628
|
}
|
|
5622
5629
|
/**
|
|
@@ -5626,7 +5633,7 @@ function getXyprissTempDir() {
|
|
|
5626
5633
|
* @returns {string} The absolute resolved temp sub-path.
|
|
5627
5634
|
*/
|
|
5628
5635
|
function createXyprissTempDir(_p) {
|
|
5629
|
-
const sys = getSysApi();
|
|
5636
|
+
const sys = getSysApi$1();
|
|
5630
5637
|
const base = getXyprissTempDir();
|
|
5631
5638
|
const segment = typeof _p === "string"
|
|
5632
5639
|
? _p
|
|
@@ -5666,7 +5673,7 @@ function generateXUserTmpDir() {
|
|
|
5666
5673
|
if (_sessionTmpDir !== null) {
|
|
5667
5674
|
return _sessionTmpDir;
|
|
5668
5675
|
}
|
|
5669
|
-
const sys = getSysApi();
|
|
5676
|
+
const sys = getSysApi$1();
|
|
5670
5677
|
// 1. Adopt the session directory allocated exclusively by the libProc supervisor
|
|
5671
5678
|
const envSession = sys?.__env__?.get("XYPRISS_USER_TMP") ||
|
|
5672
5679
|
sys?.__env__?.get("XESS_SESSION_TMP") ||
|
|
@@ -5688,7 +5695,7 @@ function generateXUserTmpDir() {
|
|
|
5688
5695
|
* Delegated exclusively to the libProc supervisor (Single Source of Truth).
|
|
5689
5696
|
*/
|
|
5690
5697
|
function getSessionHash() {
|
|
5691
|
-
const sys = getSysApi();
|
|
5698
|
+
const sys = getSysApi$1();
|
|
5692
5699
|
const envHash = sys?.__env__?.get("XYPRISS_SESSION_HASH") ||
|
|
5693
5700
|
(typeof process !== "undefined" ? process.env?.XYPRISS_SESSION_HASH : undefined);
|
|
5694
5701
|
if (envHash && typeof envHash === "string") {
|
|
@@ -6589,7 +6596,7 @@ class QuickLogger {
|
|
|
6589
6596
|
return new QuickLogger(context);
|
|
6590
6597
|
}
|
|
6591
6598
|
static shouldLog(level) {
|
|
6592
|
-
const sys = getSysApi();
|
|
6599
|
+
const sys = getSysApi$1();
|
|
6593
6600
|
let isDebug = false;
|
|
6594
6601
|
if (sys?.__env__) {
|
|
6595
6602
|
isDebug =
|
|
@@ -6745,7 +6752,7 @@ class TempFileManager {
|
|
|
6745
6752
|
* Track a temporary file for automatic TTL expiration and process exit cleanup.
|
|
6746
6753
|
*/
|
|
6747
6754
|
track(filePath, options = {}) {
|
|
6748
|
-
const sys = getSysApi();
|
|
6755
|
+
const sys = getSysApi$1();
|
|
6749
6756
|
const ttlMs = TempFileManager.parseTTL(options.ttl);
|
|
6750
6757
|
const autoCleanup = options.autoCleanupOnExit !== false;
|
|
6751
6758
|
const now = Date.now();
|
|
@@ -6787,7 +6794,7 @@ class TempFileManager {
|
|
|
6787
6794
|
* Remove a single tracked temporary file safely using native XyPriss FS API.
|
|
6788
6795
|
*/
|
|
6789
6796
|
removeFile(filePath) {
|
|
6790
|
-
const sys = getSysApi();
|
|
6797
|
+
const sys = getSysApi$1();
|
|
6791
6798
|
const entry = this.trackedFiles.get(filePath);
|
|
6792
6799
|
if (entry?.timer) {
|
|
6793
6800
|
clearTimeout(entry.timer);
|
|
@@ -6809,7 +6816,7 @@ class TempFileManager {
|
|
|
6809
6816
|
* Clean up all active tracked temporary files.
|
|
6810
6817
|
*/
|
|
6811
6818
|
cleanupAll() {
|
|
6812
|
-
const sys = getSysApi();
|
|
6819
|
+
const sys = getSysApi$1();
|
|
6813
6820
|
let count = 0;
|
|
6814
6821
|
for (const [filePath, entry] of this.trackedFiles.entries()) {
|
|
6815
6822
|
if (entry.timer)
|
|
@@ -6833,7 +6840,7 @@ class TempFileManager {
|
|
|
6833
6840
|
return;
|
|
6834
6841
|
this.exitHooksRegistered = true;
|
|
6835
6842
|
const performExitCleanup = () => {
|
|
6836
|
-
const sys = getSysApi();
|
|
6843
|
+
const sys = getSysApi$1();
|
|
6837
6844
|
for (const [filePath, entry] of this.trackedFiles.entries()) {
|
|
6838
6845
|
if (entry.autoCleanupOnExit) {
|
|
6839
6846
|
try {
|
|
@@ -8849,6 +8856,8 @@ class VarsApi extends BaseApi {
|
|
|
8849
8856
|
|
|
8850
8857
|
const _envRunnerStore = new WeakMap();
|
|
8851
8858
|
const _sealKeyStore = new WeakMap();
|
|
8859
|
+
const _shieldedInstances = new WeakSet();
|
|
8860
|
+
const SHIELD_MARKER = Symbol("xypriss.internal.env.shielded");
|
|
8852
8861
|
class EnvApi {
|
|
8853
8862
|
/**
|
|
8854
8863
|
* @param runner - The XyPrissRunner used to invoke native Go binaries.
|
|
@@ -9418,9 +9427,9 @@ class EnvApi {
|
|
|
9418
9427
|
* @internal
|
|
9419
9428
|
*/
|
|
9420
9429
|
applyShield() {
|
|
9421
|
-
// Issue #43: Guard against multi-server sequential startup re-wrapping process.env
|
|
9422
|
-
|
|
9423
|
-
if (process.env[SHIELD_MARKER]) {
|
|
9430
|
+
// Issue #43 / XSA-008: Guard against multi-server sequential startup re-wrapping process.env.
|
|
9431
|
+
// Uses unforgeable private Symbol and WeakSet to defeat pre-bootstrap spoofing attacks.
|
|
9432
|
+
if (_shieldedInstances.has(process.env) || process.env[SHIELD_MARKER] === true) {
|
|
9424
9433
|
return;
|
|
9425
9434
|
}
|
|
9426
9435
|
// Per-key deduplication: every distinct blocked key gets exactly one
|
|
@@ -9439,6 +9448,37 @@ class EnvApi {
|
|
|
9439
9448
|
"DYLD_LIBRARY_PATH",
|
|
9440
9449
|
]);
|
|
9441
9450
|
let isInsideShieldCheck = false;
|
|
9451
|
+
/**
|
|
9452
|
+
* Verifies whether the caller that directly triggered a process.env Proxy trap
|
|
9453
|
+
* belongs to the internal XyPriss engine core or to external user/plugin code.
|
|
9454
|
+
*/
|
|
9455
|
+
function isProxyCallerEngineCore() {
|
|
9456
|
+
const frames = captureNativeFrames();
|
|
9457
|
+
let seenTrap = false;
|
|
9458
|
+
for (let i = 0; i < frames.length; i++) {
|
|
9459
|
+
const { filePath, fnName } = frames[i];
|
|
9460
|
+
if (!filePath)
|
|
9461
|
+
continue;
|
|
9462
|
+
if (filePath.startsWith("node:") ||
|
|
9463
|
+
filePath.startsWith("bun:") ||
|
|
9464
|
+
filePath === "native" ||
|
|
9465
|
+
filePath.includes("[eval]")) {
|
|
9466
|
+
continue;
|
|
9467
|
+
}
|
|
9468
|
+
if (fnName === "captureNativeFrames" ||
|
|
9469
|
+
fnName === "isProxyCallerEngineCore") {
|
|
9470
|
+
continue;
|
|
9471
|
+
}
|
|
9472
|
+
// The first frame after capture plumbing is the Proxy trap itself
|
|
9473
|
+
if (!seenTrap) {
|
|
9474
|
+
seenTrap = true;
|
|
9475
|
+
continue;
|
|
9476
|
+
}
|
|
9477
|
+
// The very first frame after the Proxy trap is the consumer that accessed process.env!
|
|
9478
|
+
return isEngineCorePath(filePath.replace(/\\/g, "/"));
|
|
9479
|
+
}
|
|
9480
|
+
return false;
|
|
9481
|
+
}
|
|
9442
9482
|
const envShield = new Proxy(process.env, {
|
|
9443
9483
|
get(target, prop, receiver) {
|
|
9444
9484
|
if (prop === SHIELD_MARKER) {
|
|
@@ -9452,13 +9492,21 @@ class EnvApi {
|
|
|
9452
9492
|
}
|
|
9453
9493
|
// Pass through whitelisted keys.
|
|
9454
9494
|
if (self.whitelistedFields.has(prop)) {
|
|
9495
|
+
// If this key is declared in the application's secure Vault (e.g. from .env via $env.whitelist),
|
|
9496
|
+
// return the authentic configuration value rather than the honeypot canary decoy.
|
|
9497
|
+
if (!self.defaultWhitelist.has(prop) || prop === "PORT") {
|
|
9498
|
+
const vaultVal = self.get(prop);
|
|
9499
|
+
if (vaultVal !== undefined) {
|
|
9500
|
+
return vaultVal;
|
|
9501
|
+
}
|
|
9502
|
+
}
|
|
9455
9503
|
return Reflect.get(target, prop, receiver);
|
|
9456
9504
|
}
|
|
9457
9505
|
// Internal framework operations: allow verified engine callers to read environment safely
|
|
9458
9506
|
isInsideShieldCheck = true;
|
|
9459
9507
|
try {
|
|
9460
9508
|
const caller = getVerifiedCallerInfo();
|
|
9461
|
-
if (!caller.isUntrusted &&
|
|
9509
|
+
if (!caller.isUntrusted && isProxyCallerEngineCore()) {
|
|
9462
9510
|
return Reflect.get(target, prop, receiver);
|
|
9463
9511
|
}
|
|
9464
9512
|
}
|
|
@@ -9507,7 +9555,7 @@ class EnvApi {
|
|
|
9507
9555
|
try {
|
|
9508
9556
|
const caller = getVerifiedCallerInfo();
|
|
9509
9557
|
if (!caller.isUntrusted &&
|
|
9510
|
-
|
|
9558
|
+
isProxyCallerEngineCore()) {
|
|
9511
9559
|
try {
|
|
9512
9560
|
target[key] = String(value);
|
|
9513
9561
|
}
|
|
@@ -9567,7 +9615,7 @@ class EnvApi {
|
|
|
9567
9615
|
isInsideShieldCheck = true;
|
|
9568
9616
|
try {
|
|
9569
9617
|
const caller = getVerifiedCallerInfo();
|
|
9570
|
-
if (!caller.isUntrusted &&
|
|
9618
|
+
if (!caller.isUntrusted && isProxyCallerEngineCore()) {
|
|
9571
9619
|
try {
|
|
9572
9620
|
delete target[prop];
|
|
9573
9621
|
}
|
|
@@ -9599,7 +9647,7 @@ class EnvApi {
|
|
|
9599
9647
|
isInsideShieldCheck = true;
|
|
9600
9648
|
try {
|
|
9601
9649
|
const caller = getVerifiedCallerInfo();
|
|
9602
|
-
if (!caller.isUntrusted &&
|
|
9650
|
+
if (!caller.isUntrusted && isProxyCallerEngineCore()) {
|
|
9603
9651
|
return Reflect.ownKeys(target);
|
|
9604
9652
|
}
|
|
9605
9653
|
}
|
|
@@ -9627,7 +9675,7 @@ class EnvApi {
|
|
|
9627
9675
|
isInsideShieldCheck = true;
|
|
9628
9676
|
try {
|
|
9629
9677
|
const caller = getVerifiedCallerInfo();
|
|
9630
|
-
return !caller.isUntrusted &&
|
|
9678
|
+
return !caller.isUntrusted && isProxyCallerEngineCore();
|
|
9631
9679
|
}
|
|
9632
9680
|
catch {
|
|
9633
9681
|
return false;
|
|
@@ -9639,6 +9687,8 @@ class EnvApi {
|
|
|
9639
9687
|
return false;
|
|
9640
9688
|
},
|
|
9641
9689
|
});
|
|
9690
|
+
_shieldedInstances.add(envShield);
|
|
9691
|
+
_shieldedInstances.add(process.env);
|
|
9642
9692
|
try {
|
|
9643
9693
|
Object.defineProperty(process, "env", {
|
|
9644
9694
|
value: envShield,
|
|
@@ -9647,11 +9697,13 @@ class EnvApi {
|
|
|
9647
9697
|
enumerable: true,
|
|
9648
9698
|
});
|
|
9649
9699
|
}
|
|
9650
|
-
catch {
|
|
9651
|
-
//
|
|
9652
|
-
//
|
|
9653
|
-
//
|
|
9654
|
-
//
|
|
9700
|
+
catch (err) {
|
|
9701
|
+
// Issue #52 (https://github.com/Nehonix-Team/XyPriss/issues/52)
|
|
9702
|
+
// Emits an explicit diagnostic notice if the host runtime, sandbox, or
|
|
9703
|
+
// strict VM has locked the process.env descriptor beforehand.
|
|
9704
|
+
// Avoids silent degradation so operators immediately know when the JS
|
|
9705
|
+
// proxy layer cannot replace process.env on the global object.
|
|
9706
|
+
process.stderr.write(`\x1b[33m[SECURITY] WARNING:\x1b[0m Unable to lock process.env descriptor: ${err?.message || err}. Shield proxy degradation active.\n`);
|
|
9655
9707
|
}
|
|
9656
9708
|
}
|
|
9657
9709
|
isCallerProjectCode() {
|
|
@@ -16384,7 +16436,7 @@ class MetaConfigRunner {
|
|
|
16384
16436
|
* Executes a specific meta configuration file
|
|
16385
16437
|
*/
|
|
16386
16438
|
runMetaFile(metaPath) {
|
|
16387
|
-
const sys = getSysApi();
|
|
16439
|
+
const sys = getSysApi$1();
|
|
16388
16440
|
const absolutePath = sys.path.resolve(metaPath);
|
|
16389
16441
|
if (this.executedMetas.has(absolutePath))
|
|
16390
16442
|
return;
|
|
@@ -16411,7 +16463,7 @@ class MetaConfigRunner {
|
|
|
16411
16463
|
* Discovers and executes meta configuration files based on priority
|
|
16412
16464
|
*/
|
|
16413
16465
|
executeMetaConfig(searchDir) {
|
|
16414
|
-
const sys = getSysApi();
|
|
16466
|
+
const sys = getSysApi$1();
|
|
16415
16467
|
const root = searchDir || getCallerProjectRoot() || __sys__$1.__root__;
|
|
16416
16468
|
const metaFiles = searchDir
|
|
16417
16469
|
? [
|
|
@@ -16461,7 +16513,7 @@ class ConfigLoader {
|
|
|
16461
16513
|
this.isConfigApplied = false;
|
|
16462
16514
|
this.packageJson = null;
|
|
16463
16515
|
this.metaRunner = new MetaConfigRunner();
|
|
16464
|
-
this.sys = getSysApi();
|
|
16516
|
+
this.sys = getSysApi$1();
|
|
16465
16517
|
}
|
|
16466
16518
|
/**
|
|
16467
16519
|
* Load all xypriss.config.json files found in the project and apply configurations
|
|
@@ -18535,7 +18587,7 @@ const MIME_MAP = {
|
|
|
18535
18587
|
function resolveMime(ext) {
|
|
18536
18588
|
return MIME_MAP[ext.toLowerCase()] ?? "application/octet-stream";
|
|
18537
18589
|
}
|
|
18538
|
-
getSysApi();
|
|
18590
|
+
getSysApi$1();
|
|
18539
18591
|
class SendFileHandler {
|
|
18540
18592
|
constructor(res, logger) {
|
|
18541
18593
|
this.res = res;
|
|
@@ -26776,7 +26828,7 @@ class XHSCWorker {
|
|
|
26776
26828
|
app.logger || initializeLogger(ConfigurationManager.get("logging"));
|
|
26777
26829
|
// Issue #43: Access system environment variables through getSysApi()
|
|
26778
26830
|
// to maintain compatibility with the XyPriss zero-trust model and shielded process.env
|
|
26779
|
-
const sys = getSysApi();
|
|
26831
|
+
const sys = getSysApi$1();
|
|
26780
26832
|
this.workerId =
|
|
26781
26833
|
options?.workerId ||
|
|
26782
26834
|
sys?.__env__?.get("XYPRISS_WORKER_ID") ||
|
|
@@ -27410,7 +27462,7 @@ class EngineManager {
|
|
|
27410
27462
|
? ["--plugins", uniquePluginPaths.join(",")]
|
|
27411
27463
|
: [];
|
|
27412
27464
|
// Access project root lazily via getSysApi() to break circular imports
|
|
27413
|
-
const sys = getSysApi();
|
|
27465
|
+
const sys = getSysApi$1();
|
|
27414
27466
|
const projectRoot = sys?.__root__ ||
|
|
27415
27467
|
getCallerProjectRoot() ||
|
|
27416
27468
|
identifyProjectRoot(process.cwd()) ||
|
|
@@ -27586,7 +27638,7 @@ class XHSCBridge {
|
|
|
27586
27638
|
// 0. Check if we are a worker spawned by Go (Clustering mode)
|
|
27587
27639
|
// Auxiliary servers should NEVER act as cluster workers for the primary instance.
|
|
27588
27640
|
// Issue #43: Access workerId via getSysApi() to adhere to XyPriss zero-trust environment model
|
|
27589
|
-
const sysApi = getSysApi();
|
|
27641
|
+
const sysApi = getSysApi$1();
|
|
27590
27642
|
const currentWorkerId = sysApi?.__env__?.get("XYPRISS_WORKER_ID");
|
|
27591
27643
|
if (currentWorkerId && currentWorkerId !== "master" && !this.app.configs?.isAuxiliary) {
|
|
27592
27644
|
this.logger.info("cluster", `Worker ${currentWorkerId} starting...`);
|
|
@@ -27625,7 +27677,7 @@ class XHSCBridge {
|
|
|
27625
27677
|
// Issue #43: Use getSysApi().__env__.set() instead of assigning to process.env directly.
|
|
27626
27678
|
// In strict JS runtimes like Bun (multi-server mode), mutating process.env when wrapped
|
|
27627
27679
|
// in an immutable descriptor causes fatal descriptor rejection exceptions.
|
|
27628
|
-
const sys = getSysApi();
|
|
27680
|
+
const sys = getSysApi$1();
|
|
27629
27681
|
sys?.__env__?.set("XYPRISS_WORKER_ID", "master");
|
|
27630
27682
|
sys?.__env__?.set("XYPRISS_IPC_PATH", this.socketPath);
|
|
27631
27683
|
}
|
|
@@ -28241,7 +28293,7 @@ class ConsoleInterceptor {
|
|
|
28241
28293
|
isActive: false,
|
|
28242
28294
|
};
|
|
28243
28295
|
// Issue #43: Access XYPRISS_IPC_PATH via getSysApi()
|
|
28244
|
-
this.ipcPath = getSysApi()?.__env__?.get("XYPRISS_IPC_PATH");
|
|
28296
|
+
this.ipcPath = getSysApi$1()?.__env__?.get("XYPRISS_IPC_PATH");
|
|
28245
28297
|
}
|
|
28246
28298
|
/**
|
|
28247
28299
|
* Decides whether a log line should be displayed given the current displayLimit config.
|
|
@@ -28301,7 +28353,7 @@ class ConsoleInterceptor {
|
|
|
28301
28353
|
this.stats.isActive = true;
|
|
28302
28354
|
// Try to sync config if IPC is already available (Issue #43)
|
|
28303
28355
|
this.ipcPath =
|
|
28304
|
-
this.ipcPath || getSysApi()?.__env__?.get("XYPRISS_IPC_PATH");
|
|
28356
|
+
this.ipcPath || getSysApi$1()?.__env__?.get("XYPRISS_IPC_PATH");
|
|
28305
28357
|
if (this.ipcPath) {
|
|
28306
28358
|
const ipc = new XHSCDirectIPC(this.ipcPath);
|
|
28307
28359
|
await ipc.sendCommand("console", "update-config", this.config);
|
|
@@ -28691,7 +28743,7 @@ class XyLifecycleManager {
|
|
|
28691
28743
|
async handleServerStartup(serverPort, host, callback) {
|
|
28692
28744
|
// Rust/Go-Managed Clustering Mode
|
|
28693
28745
|
// Issue #43: Retrieve workerId and ipcPath via getSysApi() rather than raw process.env
|
|
28694
|
-
const sys = getSysApi();
|
|
28746
|
+
const sys = getSysApi$1();
|
|
28695
28747
|
const workerId = sys?.__env__?.get("XYPRISS_WORKER_ID") ||
|
|
28696
28748
|
(typeof process !== "undefined"
|
|
28697
28749
|
? process.env?.XYPRISS_WORKER_ID
|
|
@@ -29177,12 +29229,12 @@ class XyprissApp {
|
|
|
29177
29229
|
this.settings = {
|
|
29178
29230
|
"x-powered-by": false,
|
|
29179
29231
|
etag: "weak",
|
|
29180
|
-
env: getSysApi()?.__env__?.get("NODE_ENV") || "development",
|
|
29232
|
+
env: getSysApi$1()?.__env__?.get("NODE_ENV") || "development",
|
|
29181
29233
|
"subdomain offset": 2,
|
|
29182
29234
|
"trust proxy": false,
|
|
29183
29235
|
"view cache": true,
|
|
29184
29236
|
"view engine": false,
|
|
29185
|
-
views: getSysApi()?.__env__?.get("XYPRISS_VIEWS") || process.cwd() + "/views",
|
|
29237
|
+
views: getSysApi$1()?.__env__?.get("XYPRISS_VIEWS") || process.cwd() + "/views",
|
|
29186
29238
|
};
|
|
29187
29239
|
}
|
|
29188
29240
|
// ===== HTTP METHOD IMPLEMENTATIONS =====
|
|
@@ -31205,7 +31257,7 @@ class SecurityMiddleware {
|
|
|
31205
31257
|
cookieOptions: {
|
|
31206
31258
|
httpOnly: true,
|
|
31207
31259
|
sameSite: "strict",
|
|
31208
|
-
secure: getSysApi().__env__.isProduction(),
|
|
31260
|
+
secure: getSysApi$1().__env__.isProduction(),
|
|
31209
31261
|
maxAge: 24 * 60 * 60 * 1000, // 24 hours
|
|
31210
31262
|
...(csrfConfig.cookieOptions || {}),
|
|
31211
31263
|
},
|
|
@@ -32490,7 +32542,7 @@ class WorkerPoolComponent {
|
|
|
32490
32542
|
// Add task execution method via IPC
|
|
32491
32543
|
// Issue #43: Access XYPRISS_IPC_PATH through getSysApi()
|
|
32492
32544
|
app.executeTask = (task) => {
|
|
32493
|
-
const ipcPath = getSysApi()?.__env__?.get("XYPRISS_IPC_PATH");
|
|
32545
|
+
const ipcPath = getSysApi$1()?.__env__?.get("XYPRISS_IPC_PATH");
|
|
32494
32546
|
if (this.isXHSC && ipcPath) {
|
|
32495
32547
|
// In worker mode, we send the task to Go via the global IPC handler
|
|
32496
32548
|
// We'll assume the XHSCWorker instance is available or
|
|
@@ -32577,7 +32629,7 @@ class ComponentManager {
|
|
|
32577
32629
|
}
|
|
32578
32630
|
async initializeWorkerPool() {
|
|
32579
32631
|
// Issue #43: Retrieve XYPRISS_WORKER_ID via getSysApi()
|
|
32580
|
-
const workerId = getSysApi()?.__env__?.get("XYPRISS_WORKER_ID");
|
|
32632
|
+
const workerId = getSysApi$1()?.__env__?.get("XYPRISS_WORKER_ID");
|
|
32581
32633
|
const isWorker = !!workerId && workerId !== "master";
|
|
32582
32634
|
if (this.options.workerPool?.enabled) {
|
|
32583
32635
|
this.refs.workerPoolComponent = new WorkerPoolComponent({ workerPool: this.options.workerPool }, { app: this.app, serverOptions: this.options });
|
|
@@ -32907,7 +32959,7 @@ class XyPrissServer {
|
|
|
32907
32959
|
* the XyPriss zero-trust model and avoid process.env shield traps.
|
|
32908
32960
|
*/
|
|
32909
32961
|
function handleWorkerMode(options) {
|
|
32910
|
-
const sys = getSysApi();
|
|
32962
|
+
const sys = getSysApi$1();
|
|
32911
32963
|
const env = sys?.__env__;
|
|
32912
32964
|
// Check if running in worker mode
|
|
32913
32965
|
const clusterMode = env?.get("XYPRISS_CLUSTER_MODE") ||
|
|
@@ -36713,7 +36765,7 @@ class XyServerCreator {
|
|
|
36713
36765
|
// 3. Setup environment
|
|
36714
36766
|
// Issue #43: Apply NODE_ENV through getSysApi().__env__.set() to avoid strict descriptor exceptions under Bun
|
|
36715
36767
|
if (options.env) {
|
|
36716
|
-
const sys = getSysApi();
|
|
36768
|
+
const sys = getSysApi$1();
|
|
36717
36769
|
if (sys?.__env__) {
|
|
36718
36770
|
sys.__env__.set("NODE_ENV", options.env);
|
|
36719
36771
|
}
|
|
@@ -36839,7 +36891,7 @@ class XMSStartupUI {
|
|
|
36839
36891
|
quiet: options.quiet !== false,
|
|
36840
36892
|
silent: options.silent === true,
|
|
36841
36893
|
};
|
|
36842
|
-
const sysEnv = getSysApi()?.__env__;
|
|
36894
|
+
const sysEnv = getSysApi$1()?.__env__;
|
|
36843
36895
|
const isCI = sysEnv ? sysEnv.get("CI") : (typeof process !== "undefined" && process.env?.CI);
|
|
36844
36896
|
const noColor = sysEnv ? sysEnv.get("NO_COLOR") : (typeof process !== "undefined" && process.env?.NO_COLOR);
|
|
36845
36897
|
const disableColors = sysEnv ? sysEnv.get("NODE_DISABLE_COLORS") : (typeof process !== "undefined" && process.env?.NODE_DISABLE_COLORS);
|
|
@@ -39009,6 +39061,9 @@ function getIp(req, enriched) {
|
|
|
39009
39061
|
if (typeof globalThis !== "undefined") {
|
|
39010
39062
|
configLoader.loadAndApplySysConfig();
|
|
39011
39063
|
}
|
|
39064
|
+
function getSysApi() {
|
|
39065
|
+
return __sys__$1;
|
|
39066
|
+
}
|
|
39012
39067
|
/**
|
|
39013
39068
|
* Default router instance for quick start
|
|
39014
39069
|
*/
|
|
@@ -39047,6 +39102,7 @@ exports.getInstanceId = getInstanceId;
|
|
|
39047
39102
|
exports.getIp = getIp;
|
|
39048
39103
|
exports.getMime = getMime;
|
|
39049
39104
|
exports.getMimes = getMimes;
|
|
39105
|
+
exports.getSysApi = getSysApi;
|
|
39050
39106
|
exports.identifyProjectRoot = identifyProjectRoot;
|
|
39051
39107
|
exports.initializeFileUpload = initializeFileUpload;
|
|
39052
39108
|
exports.mergeWithDefaults = mergeWithDefaults;
|