xypriss 9.14.31 → 9.14.34
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 +96 -50
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +48 -2
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -9,7 +9,6 @@ var util = require('node:util');
|
|
|
9
9
|
var node_url = require('node:url');
|
|
10
10
|
var node_child_process = require('node:child_process');
|
|
11
11
|
var fs$1 = require('node:fs');
|
|
12
|
-
var tslib_es6_js = require('/home/idevo/Documents/projects/XyPriss/node_modules/.xfpm/vstore/@rollup+plugin-typescript@11.1.6/node_modules/tslib/tslib.es6.js');
|
|
13
12
|
var net = require('node:net');
|
|
14
13
|
var node_worker_threads = require('node:worker_threads');
|
|
15
14
|
var os = require('node:os');
|
|
@@ -2326,6 +2325,7 @@ function getVerifiedCallerInfo() {
|
|
|
2326
2325
|
const frames = captureNativeFrames();
|
|
2327
2326
|
let immediateCallerRoot;
|
|
2328
2327
|
let immediateCallerFile = "";
|
|
2328
|
+
let hasNonEngineFrame = false;
|
|
2329
2329
|
for (let i = 0; i < frames.length; i++) {
|
|
2330
2330
|
const { filePath, isEval } = frames[i];
|
|
2331
2331
|
if (isEval ||
|
|
@@ -2348,6 +2348,7 @@ function getVerifiedCallerInfo() {
|
|
|
2348
2348
|
if (isEngineCorePath(filePath)) {
|
|
2349
2349
|
continue;
|
|
2350
2350
|
}
|
|
2351
|
+
hasNonEngineFrame = true;
|
|
2351
2352
|
// Skip genuine CLI TypeScript loaders (tsx / ts-node) at the bottom of the stack
|
|
2352
2353
|
// ONLY if an application caller has already been established above in the call chain.
|
|
2353
2354
|
// A loader can never be the direct caller of restricted APIs!
|
|
@@ -2377,6 +2378,13 @@ function getVerifiedCallerInfo() {
|
|
|
2377
2378
|
callerFile: immediateCallerFile,
|
|
2378
2379
|
};
|
|
2379
2380
|
}
|
|
2381
|
+
if (!hasNonEngineFrame && frames.length > 0) {
|
|
2382
|
+
return {
|
|
2383
|
+
root: ENGINE_CORE_DIR || undefined,
|
|
2384
|
+
isUntrusted: false,
|
|
2385
|
+
callerFile: "<engine-core>",
|
|
2386
|
+
};
|
|
2387
|
+
}
|
|
2380
2388
|
/**
|
|
2381
2389
|
* Fail-Closed Security Policy:
|
|
2382
2390
|
* When the call stack cannot be unambiguously attributed to an authorized application caller
|
|
@@ -4784,6 +4792,41 @@ Discovery.STANDARD_PATHS = [
|
|
|
4784
4792
|
path.join("tools", "XHSC", "dist"),
|
|
4785
4793
|
];
|
|
4786
4794
|
|
|
4795
|
+
/******************************************************************************
|
|
4796
|
+
Copyright (c) Microsoft Corporation.
|
|
4797
|
+
|
|
4798
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
4799
|
+
purpose with or without fee is hereby granted.
|
|
4800
|
+
|
|
4801
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
4802
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
4803
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
4804
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
4805
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
4806
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
4807
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
4808
|
+
***************************************************************************** */
|
|
4809
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
4810
|
+
|
|
4811
|
+
|
|
4812
|
+
function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
4813
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
4814
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
4815
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
4816
|
+
}
|
|
4817
|
+
|
|
4818
|
+
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
|
4819
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4820
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4821
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
4822
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
4823
|
+
}
|
|
4824
|
+
|
|
4825
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
4826
|
+
var e = new Error(message);
|
|
4827
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
4828
|
+
};
|
|
4829
|
+
|
|
4787
4830
|
/* *****************************************************************************
|
|
4788
4831
|
* Nehonix libSynapx — Synchronous Zero-Process-Spawn Shared Memory Bridge
|
|
4789
4832
|
*
|
|
@@ -5247,14 +5290,14 @@ class SynapxClient {
|
|
|
5247
5290
|
this.sessionHash =
|
|
5248
5291
|
process.env.XYPRISS_SESSION_HASH ||
|
|
5249
5292
|
(sessionDir ? path__namespace.basename(sessionDir) : "");
|
|
5250
|
-
|
|
5293
|
+
__classPrivateFieldSet(this, _SynapxClient_authToken, process.env.XYPRISS_INTERNAL_TOKEN ||
|
|
5251
5294
|
process.env.XYPRISS_XESS_AUTH_TOKEN ||
|
|
5252
5295
|
"", "f");
|
|
5253
|
-
if (!
|
|
5296
|
+
if (!__classPrivateFieldGet(this, _SynapxClient_authToken, "f") && sessionDir) {
|
|
5254
5297
|
try {
|
|
5255
5298
|
const tokenFile = path__namespace.join(sessionDir, ".auth_token");
|
|
5256
5299
|
if (fs__namespace.existsSync(tokenFile)) {
|
|
5257
|
-
|
|
5300
|
+
__classPrivateFieldSet(this, _SynapxClient_authToken, fs__namespace.readFileSync(tokenFile, "utf8").trim(), "f");
|
|
5258
5301
|
}
|
|
5259
5302
|
}
|
|
5260
5303
|
catch { }
|
|
@@ -5369,7 +5412,7 @@ class SynapxClient {
|
|
|
5369
5412
|
* Connects to the libSynapx server and performs the Zero-Trust handshake.
|
|
5370
5413
|
*/
|
|
5371
5414
|
async connect() {
|
|
5372
|
-
if (
|
|
5415
|
+
if (__classPrivateFieldGet(this, _SynapxClient_socket, "f") && !__classPrivateFieldGet(this, _SynapxClient_socket, "f").destroyed && this.isHandshakeComplete) {
|
|
5373
5416
|
return;
|
|
5374
5417
|
}
|
|
5375
5418
|
if (!this.isAvailable()) {
|
|
@@ -5383,7 +5426,7 @@ class SynapxClient {
|
|
|
5383
5426
|
return reject(new Error("libSynapx: No active session socket path configured (XYPRISS_USER_TMP is unset)"));
|
|
5384
5427
|
}
|
|
5385
5428
|
const client = net__namespace.createConnection(this.socketPath, () => {
|
|
5386
|
-
|
|
5429
|
+
__classPrivateFieldSet(this, _SynapxClient_socket, client, "f");
|
|
5387
5430
|
this.performHandshake()
|
|
5388
5431
|
.then(() => {
|
|
5389
5432
|
this.isHandshakeComplete = true;
|
|
@@ -5413,14 +5456,14 @@ class SynapxClient {
|
|
|
5413
5456
|
* Writes a framed packet to the socket.
|
|
5414
5457
|
*/
|
|
5415
5458
|
writeFrame(msgType, payload) {
|
|
5416
|
-
if (!
|
|
5459
|
+
if (!__classPrivateFieldGet(this, _SynapxClient_socket, "f") || __classPrivateFieldGet(this, _SynapxClient_socket, "f").destroyed) {
|
|
5417
5460
|
throw new Error("libSynapx: socket is not connected");
|
|
5418
5461
|
}
|
|
5419
5462
|
const header = Buffer.alloc(HEADER_SIZE$1);
|
|
5420
5463
|
header.writeUInt8(MAGIC_BYTE, 0);
|
|
5421
5464
|
header.writeUInt8(msgType, 1);
|
|
5422
5465
|
header.writeUInt32BE(payload.length, 2);
|
|
5423
|
-
|
|
5466
|
+
__classPrivateFieldGet(this, _SynapxClient_socket, "f").write(Buffer.concat([header, payload]));
|
|
5424
5467
|
}
|
|
5425
5468
|
/**
|
|
5426
5469
|
* Performs initial zero-trust handshake.
|
|
@@ -5432,7 +5475,7 @@ class SynapxClient {
|
|
|
5432
5475
|
}, 3000);
|
|
5433
5476
|
const hsPayload = Buffer.from(JSON.stringify({
|
|
5434
5477
|
sessionHash: this.sessionHash,
|
|
5435
|
-
token:
|
|
5478
|
+
token: __classPrivateFieldGet(this, _SynapxClient_authToken, "f"),
|
|
5436
5479
|
clientPid: process.pid,
|
|
5437
5480
|
}));
|
|
5438
5481
|
// Temporarily intercept handshake response frame
|
|
@@ -5459,9 +5502,9 @@ class SynapxClient {
|
|
|
5459
5502
|
try {
|
|
5460
5503
|
const ack = JSON.parse(payloadBuf.toString("utf8"));
|
|
5461
5504
|
if (ack.auth) {
|
|
5462
|
-
|
|
5505
|
+
__classPrivateFieldSet(this, _SynapxClient_sessionKey, ack.sessionKey || "", "f");
|
|
5463
5506
|
try {
|
|
5464
|
-
|
|
5507
|
+
__classPrivateFieldGet(this, _SynapxClient_socket, "f")?.unref();
|
|
5465
5508
|
}
|
|
5466
5509
|
catch { }
|
|
5467
5510
|
return resolve();
|
|
@@ -5626,10 +5669,10 @@ class SynapxClient {
|
|
|
5626
5669
|
}
|
|
5627
5670
|
}
|
|
5628
5671
|
try {
|
|
5629
|
-
if (!
|
|
5630
|
-
|
|
5672
|
+
if (!__classPrivateFieldGet(this, _SynapxClient_syncBridge, "f")) {
|
|
5673
|
+
__classPrivateFieldSet(this, _SynapxClient_syncBridge, SynapxSyncBridge.getInstance(this.socketPath, this.sessionHash, __classPrivateFieldGet(this, _SynapxClient_authToken, "f")), "f");
|
|
5631
5674
|
}
|
|
5632
|
-
return
|
|
5675
|
+
return __classPrivateFieldGet(this, _SynapxClient_syncBridge, "f").callSync(module, action, args, opts);
|
|
5633
5676
|
}
|
|
5634
5677
|
catch {
|
|
5635
5678
|
// Resilient fallback to stdin subprocess pipeline
|
|
@@ -5730,7 +5773,7 @@ setTimeout(() => process.exit(1), 5000);
|
|
|
5730
5773
|
script,
|
|
5731
5774
|
this.socketPath,
|
|
5732
5775
|
this.sessionHash,
|
|
5733
|
-
|
|
5776
|
+
__classPrivateFieldGet(this, _SynapxClient_authToken, "f"),
|
|
5734
5777
|
], {
|
|
5735
5778
|
input: inputPayload,
|
|
5736
5779
|
encoding: "utf8",
|
|
@@ -5746,14 +5789,14 @@ setTimeout(() => process.exit(1), 5000);
|
|
|
5746
5789
|
}
|
|
5747
5790
|
destroy() {
|
|
5748
5791
|
this.isHandshakeComplete = false;
|
|
5749
|
-
if (
|
|
5750
|
-
|
|
5751
|
-
|
|
5792
|
+
if (__classPrivateFieldGet(this, _SynapxClient_syncBridge, "f")) {
|
|
5793
|
+
__classPrivateFieldGet(this, _SynapxClient_syncBridge, "f").destroy();
|
|
5794
|
+
__classPrivateFieldSet(this, _SynapxClient_syncBridge, null, "f");
|
|
5752
5795
|
}
|
|
5753
|
-
if (
|
|
5754
|
-
|
|
5755
|
-
|
|
5756
|
-
|
|
5796
|
+
if (__classPrivateFieldGet(this, _SynapxClient_socket, "f")) {
|
|
5797
|
+
__classPrivateFieldGet(this, _SynapxClient_socket, "f").removeAllListeners();
|
|
5798
|
+
__classPrivateFieldGet(this, _SynapxClient_socket, "f").destroy();
|
|
5799
|
+
__classPrivateFieldSet(this, _SynapxClient_socket, null, "f");
|
|
5757
5800
|
}
|
|
5758
5801
|
for (const [id, pending] of this.pendingCalls.entries()) {
|
|
5759
5802
|
clearTimeout(pending.timeout);
|
|
@@ -6785,24 +6828,24 @@ class FileHandle {
|
|
|
6785
6828
|
_FileHandle_id.set(this, void 0);
|
|
6786
6829
|
_FileHandle_runner.set(this, void 0);
|
|
6787
6830
|
_FileHandle_synapx.set(this, void 0);
|
|
6788
|
-
|
|
6789
|
-
|
|
6790
|
-
|
|
6831
|
+
__classPrivateFieldSet(this, _FileHandle_id, id, "f");
|
|
6832
|
+
__classPrivateFieldSet(this, _FileHandle_runner, runner, "f");
|
|
6833
|
+
__classPrivateFieldSet(this, _FileHandle_synapx, SynapxClient.getInstance(), "f");
|
|
6791
6834
|
}
|
|
6792
6835
|
/**
|
|
6793
6836
|
* **Get Native Handle ID**
|
|
6794
6837
|
*/
|
|
6795
6838
|
get nativeId() {
|
|
6796
|
-
return
|
|
6839
|
+
return __classPrivateFieldGet(this, _FileHandle_id, "f");
|
|
6797
6840
|
}
|
|
6798
6841
|
/**
|
|
6799
6842
|
* **Read from File**
|
|
6800
6843
|
* @param length - Max bytes to read
|
|
6801
6844
|
*/
|
|
6802
6845
|
async read(length) {
|
|
6803
|
-
if (
|
|
6804
|
-
const res = await
|
|
6805
|
-
String(
|
|
6846
|
+
if (__classPrivateFieldGet(this, _FileHandle_synapx, "f").isAvailable()) {
|
|
6847
|
+
const res = await __classPrivateFieldGet(this, _FileHandle_synapx, "f").call("fs", "read-handle", [
|
|
6848
|
+
String(__classPrivateFieldGet(this, _FileHandle_id, "f")),
|
|
6806
6849
|
String(length),
|
|
6807
6850
|
]);
|
|
6808
6851
|
if (typeof res === "string") {
|
|
@@ -6815,8 +6858,8 @@ class FileHandle {
|
|
|
6815
6858
|
}
|
|
6816
6859
|
return Buffer.from(res || "");
|
|
6817
6860
|
}
|
|
6818
|
-
const res = (await
|
|
6819
|
-
String(
|
|
6861
|
+
const res = (await __classPrivateFieldGet(this, _FileHandle_runner, "f").runAsync("fs", "read-handle", [
|
|
6862
|
+
String(__classPrivateFieldGet(this, _FileHandle_id, "f")),
|
|
6820
6863
|
String(length),
|
|
6821
6864
|
]));
|
|
6822
6865
|
return Buffer.from(res?.content || res || "", "hex");
|
|
@@ -6827,15 +6870,15 @@ class FileHandle {
|
|
|
6827
6870
|
*/
|
|
6828
6871
|
async write(data) {
|
|
6829
6872
|
const raw = typeof data === "string" ? Buffer.from(data) : data;
|
|
6830
|
-
if (
|
|
6831
|
-
const res = await
|
|
6832
|
-
String(
|
|
6873
|
+
if (__classPrivateFieldGet(this, _FileHandle_synapx, "f").isAvailable()) {
|
|
6874
|
+
const res = await __classPrivateFieldGet(this, _FileHandle_synapx, "f").call("fs", "write-handle", [
|
|
6875
|
+
String(__classPrivateFieldGet(this, _FileHandle_id, "f")),
|
|
6833
6876
|
raw.toString("hex"),
|
|
6834
6877
|
]);
|
|
6835
6878
|
return typeof res === "number" ? res : (res?.n ?? raw.length);
|
|
6836
6879
|
}
|
|
6837
|
-
const res = (await
|
|
6838
|
-
String(
|
|
6880
|
+
const res = (await __classPrivateFieldGet(this, _FileHandle_runner, "f").runAsync("fs", "write-handle", [
|
|
6881
|
+
String(__classPrivateFieldGet(this, _FileHandle_id, "f")),
|
|
6839
6882
|
raw.toString("hex"),
|
|
6840
6883
|
]));
|
|
6841
6884
|
return typeof res === "number" ? res : (res?.n ?? raw.length);
|
|
@@ -6846,16 +6889,16 @@ class FileHandle {
|
|
|
6846
6889
|
* @param whence - 0: Start, 1: Current, 2: End
|
|
6847
6890
|
*/
|
|
6848
6891
|
async seek(offset, whence = 0) {
|
|
6849
|
-
if (
|
|
6850
|
-
const res = await
|
|
6851
|
-
String(
|
|
6892
|
+
if (__classPrivateFieldGet(this, _FileHandle_synapx, "f").isAvailable()) {
|
|
6893
|
+
const res = await __classPrivateFieldGet(this, _FileHandle_synapx, "f").call("fs", "seek-handle", [
|
|
6894
|
+
String(__classPrivateFieldGet(this, _FileHandle_id, "f")),
|
|
6852
6895
|
String(offset),
|
|
6853
6896
|
String(whence),
|
|
6854
6897
|
]);
|
|
6855
6898
|
return typeof res === "number" ? res : (res?.pos ?? 0);
|
|
6856
6899
|
}
|
|
6857
|
-
const res = (await
|
|
6858
|
-
String(
|
|
6900
|
+
const res = (await __classPrivateFieldGet(this, _FileHandle_runner, "f").runAsync("fs", "seek-handle", [
|
|
6901
|
+
String(__classPrivateFieldGet(this, _FileHandle_id, "f")),
|
|
6859
6902
|
String(offset),
|
|
6860
6903
|
String(whence),
|
|
6861
6904
|
]));
|
|
@@ -6865,24 +6908,24 @@ class FileHandle {
|
|
|
6865
6908
|
* **Get File Statistics**
|
|
6866
6909
|
*/
|
|
6867
6910
|
async stat() {
|
|
6868
|
-
if (
|
|
6869
|
-
return await
|
|
6870
|
-
String(
|
|
6911
|
+
if (__classPrivateFieldGet(this, _FileHandle_synapx, "f").isAvailable()) {
|
|
6912
|
+
return await __classPrivateFieldGet(this, _FileHandle_synapx, "f").call("fs", "stat-handle", [
|
|
6913
|
+
String(__classPrivateFieldGet(this, _FileHandle_id, "f")),
|
|
6871
6914
|
]);
|
|
6872
6915
|
}
|
|
6873
|
-
return (await
|
|
6874
|
-
String(
|
|
6916
|
+
return (await __classPrivateFieldGet(this, _FileHandle_runner, "f").runAsync("fs", "stat-handle", [
|
|
6917
|
+
String(__classPrivateFieldGet(this, _FileHandle_id, "f")),
|
|
6875
6918
|
]));
|
|
6876
6919
|
}
|
|
6877
6920
|
/**
|
|
6878
6921
|
* **Close Handle**
|
|
6879
6922
|
*/
|
|
6880
6923
|
async close() {
|
|
6881
|
-
if (
|
|
6882
|
-
await
|
|
6924
|
+
if (__classPrivateFieldGet(this, _FileHandle_synapx, "f").isAvailable()) {
|
|
6925
|
+
await __classPrivateFieldGet(this, _FileHandle_synapx, "f").call("fs", "close", [String(__classPrivateFieldGet(this, _FileHandle_id, "f"))]);
|
|
6883
6926
|
}
|
|
6884
6927
|
else {
|
|
6885
|
-
await
|
|
6928
|
+
await __classPrivateFieldGet(this, _FileHandle_runner, "f").runAsync("fs", "close", [String(__classPrivateFieldGet(this, _FileHandle_id, "f"))]);
|
|
6886
6929
|
}
|
|
6887
6930
|
}
|
|
6888
6931
|
}
|
|
@@ -27301,7 +27344,10 @@ class XStatic {
|
|
|
27301
27344
|
const projectRoot = this.sys.__root__;
|
|
27302
27345
|
// Synchronous Sandbox Check (Project Root Violation)
|
|
27303
27346
|
if (!options.allowOutsideRoot && !options.unsafe && projectRoot) {
|
|
27304
|
-
|
|
27347
|
+
const relProject = this.sys.path.relative(projectRoot, resolvedDir);
|
|
27348
|
+
const isInsideProject = !relProject.startsWith("..") &&
|
|
27349
|
+
!this.sys.path.isAbsolute(relProject);
|
|
27350
|
+
if (!isInsideProject && resolvedDir !== projectRoot) {
|
|
27305
27351
|
this.qLog.warn(`Blocked attempt to mount static directory outside project root: ${resolvedDir}`);
|
|
27306
27352
|
throw new Error(`Forbidden: Project Root Violation for path ${resolvedDir}`);
|
|
27307
27353
|
}
|