xypriss 9.14.31 → 9.14.33
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 +83 -49
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +35 -1
- 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');
|
|
@@ -4784,6 +4783,41 @@ Discovery.STANDARD_PATHS = [
|
|
|
4784
4783
|
path.join("tools", "XHSC", "dist"),
|
|
4785
4784
|
];
|
|
4786
4785
|
|
|
4786
|
+
/******************************************************************************
|
|
4787
|
+
Copyright (c) Microsoft Corporation.
|
|
4788
|
+
|
|
4789
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
4790
|
+
purpose with or without fee is hereby granted.
|
|
4791
|
+
|
|
4792
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
4793
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
4794
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
4795
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
4796
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
4797
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
4798
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
4799
|
+
***************************************************************************** */
|
|
4800
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
4801
|
+
|
|
4802
|
+
|
|
4803
|
+
function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
4804
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
4805
|
+
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");
|
|
4806
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
4807
|
+
}
|
|
4808
|
+
|
|
4809
|
+
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
|
4810
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4811
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4812
|
+
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");
|
|
4813
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
4814
|
+
}
|
|
4815
|
+
|
|
4816
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
4817
|
+
var e = new Error(message);
|
|
4818
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
4819
|
+
};
|
|
4820
|
+
|
|
4787
4821
|
/* *****************************************************************************
|
|
4788
4822
|
* Nehonix libSynapx — Synchronous Zero-Process-Spawn Shared Memory Bridge
|
|
4789
4823
|
*
|
|
@@ -5247,14 +5281,14 @@ class SynapxClient {
|
|
|
5247
5281
|
this.sessionHash =
|
|
5248
5282
|
process.env.XYPRISS_SESSION_HASH ||
|
|
5249
5283
|
(sessionDir ? path__namespace.basename(sessionDir) : "");
|
|
5250
|
-
|
|
5284
|
+
__classPrivateFieldSet(this, _SynapxClient_authToken, process.env.XYPRISS_INTERNAL_TOKEN ||
|
|
5251
5285
|
process.env.XYPRISS_XESS_AUTH_TOKEN ||
|
|
5252
5286
|
"", "f");
|
|
5253
|
-
if (!
|
|
5287
|
+
if (!__classPrivateFieldGet(this, _SynapxClient_authToken, "f") && sessionDir) {
|
|
5254
5288
|
try {
|
|
5255
5289
|
const tokenFile = path__namespace.join(sessionDir, ".auth_token");
|
|
5256
5290
|
if (fs__namespace.existsSync(tokenFile)) {
|
|
5257
|
-
|
|
5291
|
+
__classPrivateFieldSet(this, _SynapxClient_authToken, fs__namespace.readFileSync(tokenFile, "utf8").trim(), "f");
|
|
5258
5292
|
}
|
|
5259
5293
|
}
|
|
5260
5294
|
catch { }
|
|
@@ -5369,7 +5403,7 @@ class SynapxClient {
|
|
|
5369
5403
|
* Connects to the libSynapx server and performs the Zero-Trust handshake.
|
|
5370
5404
|
*/
|
|
5371
5405
|
async connect() {
|
|
5372
|
-
if (
|
|
5406
|
+
if (__classPrivateFieldGet(this, _SynapxClient_socket, "f") && !__classPrivateFieldGet(this, _SynapxClient_socket, "f").destroyed && this.isHandshakeComplete) {
|
|
5373
5407
|
return;
|
|
5374
5408
|
}
|
|
5375
5409
|
if (!this.isAvailable()) {
|
|
@@ -5383,7 +5417,7 @@ class SynapxClient {
|
|
|
5383
5417
|
return reject(new Error("libSynapx: No active session socket path configured (XYPRISS_USER_TMP is unset)"));
|
|
5384
5418
|
}
|
|
5385
5419
|
const client = net__namespace.createConnection(this.socketPath, () => {
|
|
5386
|
-
|
|
5420
|
+
__classPrivateFieldSet(this, _SynapxClient_socket, client, "f");
|
|
5387
5421
|
this.performHandshake()
|
|
5388
5422
|
.then(() => {
|
|
5389
5423
|
this.isHandshakeComplete = true;
|
|
@@ -5413,14 +5447,14 @@ class SynapxClient {
|
|
|
5413
5447
|
* Writes a framed packet to the socket.
|
|
5414
5448
|
*/
|
|
5415
5449
|
writeFrame(msgType, payload) {
|
|
5416
|
-
if (!
|
|
5450
|
+
if (!__classPrivateFieldGet(this, _SynapxClient_socket, "f") || __classPrivateFieldGet(this, _SynapxClient_socket, "f").destroyed) {
|
|
5417
5451
|
throw new Error("libSynapx: socket is not connected");
|
|
5418
5452
|
}
|
|
5419
5453
|
const header = Buffer.alloc(HEADER_SIZE$1);
|
|
5420
5454
|
header.writeUInt8(MAGIC_BYTE, 0);
|
|
5421
5455
|
header.writeUInt8(msgType, 1);
|
|
5422
5456
|
header.writeUInt32BE(payload.length, 2);
|
|
5423
|
-
|
|
5457
|
+
__classPrivateFieldGet(this, _SynapxClient_socket, "f").write(Buffer.concat([header, payload]));
|
|
5424
5458
|
}
|
|
5425
5459
|
/**
|
|
5426
5460
|
* Performs initial zero-trust handshake.
|
|
@@ -5432,7 +5466,7 @@ class SynapxClient {
|
|
|
5432
5466
|
}, 3000);
|
|
5433
5467
|
const hsPayload = Buffer.from(JSON.stringify({
|
|
5434
5468
|
sessionHash: this.sessionHash,
|
|
5435
|
-
token:
|
|
5469
|
+
token: __classPrivateFieldGet(this, _SynapxClient_authToken, "f"),
|
|
5436
5470
|
clientPid: process.pid,
|
|
5437
5471
|
}));
|
|
5438
5472
|
// Temporarily intercept handshake response frame
|
|
@@ -5459,9 +5493,9 @@ class SynapxClient {
|
|
|
5459
5493
|
try {
|
|
5460
5494
|
const ack = JSON.parse(payloadBuf.toString("utf8"));
|
|
5461
5495
|
if (ack.auth) {
|
|
5462
|
-
|
|
5496
|
+
__classPrivateFieldSet(this, _SynapxClient_sessionKey, ack.sessionKey || "", "f");
|
|
5463
5497
|
try {
|
|
5464
|
-
|
|
5498
|
+
__classPrivateFieldGet(this, _SynapxClient_socket, "f")?.unref();
|
|
5465
5499
|
}
|
|
5466
5500
|
catch { }
|
|
5467
5501
|
return resolve();
|
|
@@ -5626,10 +5660,10 @@ class SynapxClient {
|
|
|
5626
5660
|
}
|
|
5627
5661
|
}
|
|
5628
5662
|
try {
|
|
5629
|
-
if (!
|
|
5630
|
-
|
|
5663
|
+
if (!__classPrivateFieldGet(this, _SynapxClient_syncBridge, "f")) {
|
|
5664
|
+
__classPrivateFieldSet(this, _SynapxClient_syncBridge, SynapxSyncBridge.getInstance(this.socketPath, this.sessionHash, __classPrivateFieldGet(this, _SynapxClient_authToken, "f")), "f");
|
|
5631
5665
|
}
|
|
5632
|
-
return
|
|
5666
|
+
return __classPrivateFieldGet(this, _SynapxClient_syncBridge, "f").callSync(module, action, args, opts);
|
|
5633
5667
|
}
|
|
5634
5668
|
catch {
|
|
5635
5669
|
// Resilient fallback to stdin subprocess pipeline
|
|
@@ -5730,7 +5764,7 @@ setTimeout(() => process.exit(1), 5000);
|
|
|
5730
5764
|
script,
|
|
5731
5765
|
this.socketPath,
|
|
5732
5766
|
this.sessionHash,
|
|
5733
|
-
|
|
5767
|
+
__classPrivateFieldGet(this, _SynapxClient_authToken, "f"),
|
|
5734
5768
|
], {
|
|
5735
5769
|
input: inputPayload,
|
|
5736
5770
|
encoding: "utf8",
|
|
@@ -5746,14 +5780,14 @@ setTimeout(() => process.exit(1), 5000);
|
|
|
5746
5780
|
}
|
|
5747
5781
|
destroy() {
|
|
5748
5782
|
this.isHandshakeComplete = false;
|
|
5749
|
-
if (
|
|
5750
|
-
|
|
5751
|
-
|
|
5783
|
+
if (__classPrivateFieldGet(this, _SynapxClient_syncBridge, "f")) {
|
|
5784
|
+
__classPrivateFieldGet(this, _SynapxClient_syncBridge, "f").destroy();
|
|
5785
|
+
__classPrivateFieldSet(this, _SynapxClient_syncBridge, null, "f");
|
|
5752
5786
|
}
|
|
5753
|
-
if (
|
|
5754
|
-
|
|
5755
|
-
|
|
5756
|
-
|
|
5787
|
+
if (__classPrivateFieldGet(this, _SynapxClient_socket, "f")) {
|
|
5788
|
+
__classPrivateFieldGet(this, _SynapxClient_socket, "f").removeAllListeners();
|
|
5789
|
+
__classPrivateFieldGet(this, _SynapxClient_socket, "f").destroy();
|
|
5790
|
+
__classPrivateFieldSet(this, _SynapxClient_socket, null, "f");
|
|
5757
5791
|
}
|
|
5758
5792
|
for (const [id, pending] of this.pendingCalls.entries()) {
|
|
5759
5793
|
clearTimeout(pending.timeout);
|
|
@@ -6785,24 +6819,24 @@ class FileHandle {
|
|
|
6785
6819
|
_FileHandle_id.set(this, void 0);
|
|
6786
6820
|
_FileHandle_runner.set(this, void 0);
|
|
6787
6821
|
_FileHandle_synapx.set(this, void 0);
|
|
6788
|
-
|
|
6789
|
-
|
|
6790
|
-
|
|
6822
|
+
__classPrivateFieldSet(this, _FileHandle_id, id, "f");
|
|
6823
|
+
__classPrivateFieldSet(this, _FileHandle_runner, runner, "f");
|
|
6824
|
+
__classPrivateFieldSet(this, _FileHandle_synapx, SynapxClient.getInstance(), "f");
|
|
6791
6825
|
}
|
|
6792
6826
|
/**
|
|
6793
6827
|
* **Get Native Handle ID**
|
|
6794
6828
|
*/
|
|
6795
6829
|
get nativeId() {
|
|
6796
|
-
return
|
|
6830
|
+
return __classPrivateFieldGet(this, _FileHandle_id, "f");
|
|
6797
6831
|
}
|
|
6798
6832
|
/**
|
|
6799
6833
|
* **Read from File**
|
|
6800
6834
|
* @param length - Max bytes to read
|
|
6801
6835
|
*/
|
|
6802
6836
|
async read(length) {
|
|
6803
|
-
if (
|
|
6804
|
-
const res = await
|
|
6805
|
-
String(
|
|
6837
|
+
if (__classPrivateFieldGet(this, _FileHandle_synapx, "f").isAvailable()) {
|
|
6838
|
+
const res = await __classPrivateFieldGet(this, _FileHandle_synapx, "f").call("fs", "read-handle", [
|
|
6839
|
+
String(__classPrivateFieldGet(this, _FileHandle_id, "f")),
|
|
6806
6840
|
String(length),
|
|
6807
6841
|
]);
|
|
6808
6842
|
if (typeof res === "string") {
|
|
@@ -6815,8 +6849,8 @@ class FileHandle {
|
|
|
6815
6849
|
}
|
|
6816
6850
|
return Buffer.from(res || "");
|
|
6817
6851
|
}
|
|
6818
|
-
const res = (await
|
|
6819
|
-
String(
|
|
6852
|
+
const res = (await __classPrivateFieldGet(this, _FileHandle_runner, "f").runAsync("fs", "read-handle", [
|
|
6853
|
+
String(__classPrivateFieldGet(this, _FileHandle_id, "f")),
|
|
6820
6854
|
String(length),
|
|
6821
6855
|
]));
|
|
6822
6856
|
return Buffer.from(res?.content || res || "", "hex");
|
|
@@ -6827,15 +6861,15 @@ class FileHandle {
|
|
|
6827
6861
|
*/
|
|
6828
6862
|
async write(data) {
|
|
6829
6863
|
const raw = typeof data === "string" ? Buffer.from(data) : data;
|
|
6830
|
-
if (
|
|
6831
|
-
const res = await
|
|
6832
|
-
String(
|
|
6864
|
+
if (__classPrivateFieldGet(this, _FileHandle_synapx, "f").isAvailable()) {
|
|
6865
|
+
const res = await __classPrivateFieldGet(this, _FileHandle_synapx, "f").call("fs", "write-handle", [
|
|
6866
|
+
String(__classPrivateFieldGet(this, _FileHandle_id, "f")),
|
|
6833
6867
|
raw.toString("hex"),
|
|
6834
6868
|
]);
|
|
6835
6869
|
return typeof res === "number" ? res : (res?.n ?? raw.length);
|
|
6836
6870
|
}
|
|
6837
|
-
const res = (await
|
|
6838
|
-
String(
|
|
6871
|
+
const res = (await __classPrivateFieldGet(this, _FileHandle_runner, "f").runAsync("fs", "write-handle", [
|
|
6872
|
+
String(__classPrivateFieldGet(this, _FileHandle_id, "f")),
|
|
6839
6873
|
raw.toString("hex"),
|
|
6840
6874
|
]));
|
|
6841
6875
|
return typeof res === "number" ? res : (res?.n ?? raw.length);
|
|
@@ -6846,16 +6880,16 @@ class FileHandle {
|
|
|
6846
6880
|
* @param whence - 0: Start, 1: Current, 2: End
|
|
6847
6881
|
*/
|
|
6848
6882
|
async seek(offset, whence = 0) {
|
|
6849
|
-
if (
|
|
6850
|
-
const res = await
|
|
6851
|
-
String(
|
|
6883
|
+
if (__classPrivateFieldGet(this, _FileHandle_synapx, "f").isAvailable()) {
|
|
6884
|
+
const res = await __classPrivateFieldGet(this, _FileHandle_synapx, "f").call("fs", "seek-handle", [
|
|
6885
|
+
String(__classPrivateFieldGet(this, _FileHandle_id, "f")),
|
|
6852
6886
|
String(offset),
|
|
6853
6887
|
String(whence),
|
|
6854
6888
|
]);
|
|
6855
6889
|
return typeof res === "number" ? res : (res?.pos ?? 0);
|
|
6856
6890
|
}
|
|
6857
|
-
const res = (await
|
|
6858
|
-
String(
|
|
6891
|
+
const res = (await __classPrivateFieldGet(this, _FileHandle_runner, "f").runAsync("fs", "seek-handle", [
|
|
6892
|
+
String(__classPrivateFieldGet(this, _FileHandle_id, "f")),
|
|
6859
6893
|
String(offset),
|
|
6860
6894
|
String(whence),
|
|
6861
6895
|
]));
|
|
@@ -6865,24 +6899,24 @@ class FileHandle {
|
|
|
6865
6899
|
* **Get File Statistics**
|
|
6866
6900
|
*/
|
|
6867
6901
|
async stat() {
|
|
6868
|
-
if (
|
|
6869
|
-
return await
|
|
6870
|
-
String(
|
|
6902
|
+
if (__classPrivateFieldGet(this, _FileHandle_synapx, "f").isAvailable()) {
|
|
6903
|
+
return await __classPrivateFieldGet(this, _FileHandle_synapx, "f").call("fs", "stat-handle", [
|
|
6904
|
+
String(__classPrivateFieldGet(this, _FileHandle_id, "f")),
|
|
6871
6905
|
]);
|
|
6872
6906
|
}
|
|
6873
|
-
return (await
|
|
6874
|
-
String(
|
|
6907
|
+
return (await __classPrivateFieldGet(this, _FileHandle_runner, "f").runAsync("fs", "stat-handle", [
|
|
6908
|
+
String(__classPrivateFieldGet(this, _FileHandle_id, "f")),
|
|
6875
6909
|
]));
|
|
6876
6910
|
}
|
|
6877
6911
|
/**
|
|
6878
6912
|
* **Close Handle**
|
|
6879
6913
|
*/
|
|
6880
6914
|
async close() {
|
|
6881
|
-
if (
|
|
6882
|
-
await
|
|
6915
|
+
if (__classPrivateFieldGet(this, _FileHandle_synapx, "f").isAvailable()) {
|
|
6916
|
+
await __classPrivateFieldGet(this, _FileHandle_synapx, "f").call("fs", "close", [String(__classPrivateFieldGet(this, _FileHandle_id, "f"))]);
|
|
6883
6917
|
}
|
|
6884
6918
|
else {
|
|
6885
|
-
await
|
|
6919
|
+
await __classPrivateFieldGet(this, _FileHandle_runner, "f").runAsync("fs", "close", [String(__classPrivateFieldGet(this, _FileHandle_id, "f"))]);
|
|
6886
6920
|
}
|
|
6887
6921
|
}
|
|
6888
6922
|
}
|