@nekzus/liop 2.1.0-alpha.13 → 2.1.0-alpha.15
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/bin/agent.js +7 -5
- package/dist/bin/agent.js.map +1 -1
- package/dist/bridge.d.ts +2 -2
- package/dist/bridge.js +2 -1
- package/dist/{chunk-UVO7DII3.js → chunk-4LQPDN3W.js} +108 -15
- package/dist/chunk-4LQPDN3W.js.map +1 -0
- package/dist/chunk-636UOVSO.js +714 -0
- package/dist/chunk-636UOVSO.js.map +1 -0
- package/dist/{chunk-NJRSFFD7.js → chunk-74CISO2I.js} +60 -22
- package/dist/chunk-74CISO2I.js.map +1 -0
- package/dist/{chunk-E5QBDD5E.js → chunk-CRZBVFDV.js} +169 -22
- package/dist/chunk-CRZBVFDV.js.map +1 -0
- package/dist/chunk-JIJPZFR2.js +51 -0
- package/dist/chunk-JIJPZFR2.js.map +1 -0
- package/dist/{chunk-HB5DXX3Q.js → chunk-KF4DCCU3.js} +232 -48
- package/dist/chunk-KF4DCCU3.js.map +1 -0
- package/dist/chunk-OIMJZ64E.js +441 -0
- package/dist/chunk-OIMJZ64E.js.map +1 -0
- package/dist/chunk-PYKRQAER.js +77 -0
- package/dist/chunk-PYKRQAER.js.map +1 -0
- package/dist/{chunk-J3WPBMJ5.js → chunk-SONUORBT.js} +95 -6
- package/dist/chunk-SONUORBT.js.map +1 -0
- package/dist/{chunk-2JLG4DET.js → chunk-UBOQZVV5.js} +261 -107
- package/dist/chunk-UBOQZVV5.js.map +1 -0
- package/dist/chunk-WSW6YJNY.js +168 -0
- package/dist/chunk-WSW6YJNY.js.map +1 -0
- package/dist/client.d.ts +3 -2
- package/dist/client.js +4 -3
- package/dist/gateway.d.ts +5 -110
- package/dist/gateway.js +5 -4
- package/dist/hybrid-CF__0YnC.d.ts +170 -0
- package/dist/{index-BlGc0iym.d.ts → index-BW95kAL4.d.ts} +63 -2
- package/dist/index-cMV0_yD9.d.ts +200 -0
- package/dist/index.d.ts +267 -7
- package/dist/index.js +266 -13
- package/dist/index.js.map +1 -1
- package/dist/mesh.d.ts +14 -0
- package/dist/mesh.js +1 -1
- package/dist/server.d.ts +2 -2
- package/dist/server.js +5 -4
- package/dist/{types-sKeUxuky.d.ts → types-lJIxBlWF.d.ts} +71 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.js +1 -1
- package/dist/workers/logic-execution.d.ts +1 -0
- package/dist/workers/logic-execution.js +17 -1
- package/dist/workers/logic-execution.js.map +1 -1
- package/package.json +79 -31
- package/dist/chunk-2JLG4DET.js.map +0 -1
- package/dist/chunk-CT6NHSYP.js +0 -30
- package/dist/chunk-CT6NHSYP.js.map +0 -1
- package/dist/chunk-E5QBDD5E.js.map +0 -1
- package/dist/chunk-HB5DXX3Q.js.map +0 -1
- package/dist/chunk-IJHTRIZC.js +0 -56
- package/dist/chunk-IJHTRIZC.js.map +0 -1
- package/dist/chunk-J3WPBMJ5.js.map +0 -1
- package/dist/chunk-NJRSFFD7.js.map +0 -1
- package/dist/chunk-PHTWUTY7.js +0 -300
- package/dist/chunk-PHTWUTY7.js.map +0 -1
- package/dist/chunk-RDWCGZ2A.js +0 -87
- package/dist/chunk-RDWCGZ2A.js.map +0 -1
- package/dist/chunk-UVO7DII3.js.map +0 -1
- package/dist/index-qM8ZH8sC.d.ts +0 -101
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { log } from './chunk-72MNYFR6.js';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
import * as grpc2 from '@grpc/grpc-js';
|
|
5
|
+
import * as protoLoader from '@grpc/proto-loader';
|
|
6
|
+
import * as fs2 from 'fs';
|
|
7
|
+
|
|
8
|
+
// src/rpc/channel-options.ts
|
|
9
|
+
var GRPC_CHANNEL_OPTIONS = {
|
|
10
|
+
"grpc.keepalive_time_ms": 3e4,
|
|
11
|
+
"grpc.keepalive_timeout_ms": 1e4,
|
|
12
|
+
"grpc.keepalive_permit_without_calls": 1,
|
|
13
|
+
"grpc.max_send_message_length": -1,
|
|
14
|
+
"grpc.max_receive_message_length": -1,
|
|
15
|
+
"grpc.enable_retries": 1
|
|
16
|
+
};
|
|
17
|
+
var __filename2 = fileURLToPath(import.meta.url);
|
|
18
|
+
var __dirname2 = path.dirname(__filename2);
|
|
19
|
+
var PROD_PATHS = [
|
|
20
|
+
path.resolve(__dirname2, "./protocol/liop_core.proto"),
|
|
21
|
+
// Flat dist/ (tsup)
|
|
22
|
+
path.resolve(__dirname2, "../protocol/liop_core.proto")
|
|
23
|
+
// dist/rpc/ (tsc)
|
|
24
|
+
];
|
|
25
|
+
var DEV_PROTO_PATH = path.resolve(
|
|
26
|
+
__dirname2,
|
|
27
|
+
"../../../../protocol/proto/liop_core.proto"
|
|
28
|
+
);
|
|
29
|
+
var PROTO_PATH = PROD_PATHS.find((p) => fs2.existsSync(p)) || DEV_PROTO_PATH;
|
|
30
|
+
if (!fs2.existsSync(PROTO_PATH)) {
|
|
31
|
+
log.error(`[LIOP-Proto] CRITICAL: Proto file not found at ${PROTO_PATH}`);
|
|
32
|
+
}
|
|
33
|
+
var packageDefinition = protoLoader.loadSync(PROTO_PATH, {
|
|
34
|
+
keepCase: true,
|
|
35
|
+
longs: String,
|
|
36
|
+
enums: String,
|
|
37
|
+
defaults: true,
|
|
38
|
+
oneofs: true
|
|
39
|
+
});
|
|
40
|
+
var liopProto = grpc2.loadPackageDefinition(packageDefinition);
|
|
41
|
+
var liopV1 = liopProto.liop.v1;
|
|
42
|
+
var isTlsEnforced = () => process.env.NODE_ENV === "production" || process.env.LIOP_ENFORCE_TLS === "true";
|
|
43
|
+
function createServerCredentials(tls) {
|
|
44
|
+
if (tls?.mutualTls && !tls.rootCert && !tls.certManager?.getRootCert()) {
|
|
45
|
+
throw new Error(
|
|
46
|
+
"[LIOP-TLS] FATAL: Mutual TLS (mTLS) enabled but no root CA certificate (rootCert) provided to verify client certificates."
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
if (tls?.certManager) {
|
|
50
|
+
try {
|
|
51
|
+
const certChain = tls.certManager.getCertChain();
|
|
52
|
+
const privateKey = tls.certManager.getPrivateKey();
|
|
53
|
+
const rootCert = tls.certManager.getRootCert();
|
|
54
|
+
if (tls.mutualTls && !rootCert) {
|
|
55
|
+
throw new Error(
|
|
56
|
+
"[LIOP-TLS] FATAL: Mutual TLS (mTLS) enabled but CertManager has no root CA certificate loaded."
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
return grpc2.ServerCredentials.createSsl(
|
|
60
|
+
rootCert,
|
|
61
|
+
[{ cert_chain: certChain, private_key: privateKey }],
|
|
62
|
+
Boolean(tls.mutualTls)
|
|
63
|
+
);
|
|
64
|
+
} catch (error) {
|
|
65
|
+
if (isTlsEnforced()) {
|
|
66
|
+
throw new Error(
|
|
67
|
+
`[LIOP-TLS] FATAL: CertManager server credential creation failed in enforced mode: ${error}`
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
log.warn(
|
|
71
|
+
`[LIOP-TLS] CertManager failed, falling back to insecure: ${error}`
|
|
72
|
+
);
|
|
73
|
+
return grpc2.ServerCredentials.createInsecure();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (!tls?.certChain || !tls?.privateKey) {
|
|
77
|
+
if (isTlsEnforced()) {
|
|
78
|
+
throw new Error(
|
|
79
|
+
"[LIOP-TLS] FATAL: TLS certificates required in production or when LIOP_ENFORCE_TLS=true."
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
log.warn(
|
|
83
|
+
"[LIOP-TLS] No TLS certificates configured \u2014 using insecure server credentials"
|
|
84
|
+
);
|
|
85
|
+
return grpc2.ServerCredentials.createInsecure();
|
|
86
|
+
}
|
|
87
|
+
try {
|
|
88
|
+
const rootCert = tls.rootCert ? fs2.readFileSync(tls.rootCert) : null;
|
|
89
|
+
const certChain = fs2.readFileSync(tls.certChain);
|
|
90
|
+
const privateKey = fs2.readFileSync(tls.privateKey);
|
|
91
|
+
if (tls.mutualTls && !rootCert) {
|
|
92
|
+
throw new Error(
|
|
93
|
+
"[LIOP-TLS] FATAL: Mutual TLS (mTLS) enabled but no root CA certificate (rootCert) provided to verify client certificates."
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
return grpc2.ServerCredentials.createSsl(
|
|
97
|
+
rootCert,
|
|
98
|
+
[{ cert_chain: certChain, private_key: privateKey }],
|
|
99
|
+
Boolean(tls.mutualTls)
|
|
100
|
+
);
|
|
101
|
+
} catch (error) {
|
|
102
|
+
if (isTlsEnforced()) {
|
|
103
|
+
throw new Error(
|
|
104
|
+
`[LIOP-TLS] FATAL: Server certificate loading failed in production or enforced mode. Refusing insecure fallback to prevent MITM/eavesdropping: ${error}`
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
log.warn(
|
|
108
|
+
`[LIOP-TLS] Server certificate loading failed, falling back to insecure (dev mode): ${error}`
|
|
109
|
+
);
|
|
110
|
+
return grpc2.ServerCredentials.createInsecure();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
function createChannelCredentials(tls) {
|
|
114
|
+
if (tls?.certManager) {
|
|
115
|
+
try {
|
|
116
|
+
const rootCert = tls.certManager.getRootCert();
|
|
117
|
+
if (!rootCert) {
|
|
118
|
+
throw new Error(
|
|
119
|
+
"[LIOP-TLS] FATAL: Channel TLS requires a root CA certificate in CertManager."
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
const certChain = tls.certManager.getCertChain();
|
|
123
|
+
const privateKey = tls.certManager.getPrivateKey();
|
|
124
|
+
return grpc2.credentials.createSsl(rootCert, privateKey, certChain);
|
|
125
|
+
} catch (error) {
|
|
126
|
+
if (isTlsEnforced()) {
|
|
127
|
+
throw new Error(
|
|
128
|
+
`[LIOP-TLS] FATAL: Channel certificate loading failed in enforced mode: ${error}`
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
log.warn(
|
|
132
|
+
`[LIOP-TLS] Channel CertManager failed, falling back to insecure: ${error}`
|
|
133
|
+
);
|
|
134
|
+
return grpc2.credentials.createInsecure();
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
if (!tls?.rootCert) {
|
|
138
|
+
if (isTlsEnforced()) {
|
|
139
|
+
throw new Error(
|
|
140
|
+
"[LIOP-TLS] FATAL: TLS root certificate required in production or when LIOP_ENFORCE_TLS=true."
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
log.warn(
|
|
144
|
+
"[LIOP-TLS] No TLS root certificate configured \u2014 using insecure channel credentials"
|
|
145
|
+
);
|
|
146
|
+
return grpc2.credentials.createInsecure();
|
|
147
|
+
}
|
|
148
|
+
try {
|
|
149
|
+
const rootCert = fs2.readFileSync(tls.rootCert);
|
|
150
|
+
const certChain = tls.certChain ? fs2.readFileSync(tls.certChain) : void 0;
|
|
151
|
+
const privateKey = tls.privateKey ? fs2.readFileSync(tls.privateKey) : void 0;
|
|
152
|
+
return grpc2.credentials.createSsl(rootCert, privateKey, certChain);
|
|
153
|
+
} catch (error) {
|
|
154
|
+
if (isTlsEnforced()) {
|
|
155
|
+
throw new Error(
|
|
156
|
+
`[LIOP-TLS] FATAL: Channel certificate loading failed in production or enforced mode. Refusing insecure fallback to prevent MITM/eavesdropping: ${error}`
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
log.warn(
|
|
160
|
+
`[LIOP-TLS] Channel certificate loading failed, falling back to insecure (dev mode): ${error}`
|
|
161
|
+
);
|
|
162
|
+
return grpc2.credentials.createInsecure();
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export { GRPC_CHANNEL_OPTIONS, createChannelCredentials, createServerCredentials, liopV1 };
|
|
167
|
+
//# sourceMappingURL=chunk-WSW6YJNY.js.map
|
|
168
|
+
//# sourceMappingURL=chunk-WSW6YJNY.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/rpc/channel-options.ts","../src/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AY,SAAS,CAAA;AAAA,EAClE,SAAS,KAAA,EAAO;AACf,IAAA,IAAI,eAAc,EAAG;AACpB,MAAA,MAAM,IAAI,KAAA;AAAA,QACT,kJAC8D,KAAK,CAAA;AAAA,OACpE;AAAA,IACD;AACA,IAAA,GAAA,CAAI,IAAA;AAAA,MACH,uFAAuF,KAAK,CAAA;AAAA,KAC7F;AACA,IAAA,OAAY,kBAAY,cAAA,EAAe;AAAA,EACxC;AACD","file":"chunk-WSW6YJNY.js","sourcesContent":["/**\n * LIOP Production-Grade gRPC Channel Options\n *\n * Enforces bidirectional symmetry between LiopRpcServer, LiopRpcClient,\n * and gateway proxy channels per NIST SP 800-207 continuous verification.\n * Prevents silent disconnections behind corporate stateful firewalls and NAT gateways.\n */\nexport const GRPC_CHANNEL_OPTIONS: Readonly<Record<string, string | number>> = {\n\t\"grpc.keepalive_time_ms\": 30_000,\n\t\"grpc.keepalive_timeout_ms\": 10_000,\n\t\"grpc.keepalive_permit_without_calls\": 1,\n\t\"grpc.max_send_message_length\": -1,\n\t\"grpc.max_receive_message_length\": -1,\n\t\"grpc.enable_retries\": 1,\n};\n","import path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport * as grpc from \"@grpc/grpc-js\";\nimport * as protoLoader from \"@grpc/proto-loader\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\nimport * as fs from \"node:fs\";\nimport { log } from \"../utils/logger.js\";\n\n// Selection logic: support both flat dist/ and original src/ structure\nconst PROD_PATHS = [\n\tpath.resolve(__dirname, \"./protocol/liop_core.proto\"), // Flat dist/ (tsup)\n\tpath.resolve(__dirname, \"../protocol/liop_core.proto\"), // dist/rpc/ (tsc)\n];\n\nconst DEV_PROTO_PATH = path.resolve(\n\t__dirname,\n\t\"../../../../protocol/proto/liop_core.proto\",\n);\n\n// Selection logic\nconst PROTO_PATH = PROD_PATHS.find((p) => fs.existsSync(p)) || DEV_PROTO_PATH;\n\nif (!fs.existsSync(PROTO_PATH)) {\n\tlog.error(`[LIOP-Proto] CRITICAL: Proto file not found at ${PROTO_PATH}`);\n}\n\n/**\n * LIOP Proto Loader\n * Loads the core gRPC definitions for the Logic-Injection-on-Origin Protocol.\n */\nconst packageDefinition = protoLoader.loadSync(PROTO_PATH, {\n\tkeepCase: true,\n\tlongs: String,\n\tenums: String,\n\tdefaults: true,\n\toneofs: true,\n});\n\n// biome-ignore lint/suspicious/noExplicitAny: gRPC dynamic loading requires any for the service definition map\nexport const liopProto = grpc.loadPackageDefinition(packageDefinition) as any;\nexport const liopV1 = liopProto.liop.v1;\n","/**\n * LIOP TLS Configuration\n *\n * Provides conditional TLS credential factories for gRPC connections.\n * When TLS options are provided, connections are secured with mutual TLS.\n * Otherwise, falls back to insecure credentials (alpha/development mode).\n *\n * Production Hardening (Phase 128):\n * - When NODE_ENV=production and TLS is configured but certificate loading\n * fails, the system throws a fatal error instead of silently degrading\n * to insecure credentials. This prevents MITM/eavesdropping attacks\n * caused by misconfigured certificate paths going unnoticed.\n * - Reference: gRPC-node official docs — \"Using insecure credentials in\n * production poses significant security risks including eavesdropping,\n * MITM attacks, and lack of authentication.\"\n */\n\nimport * as fs from \"node:fs\";\nimport * as grpc from \"@grpc/grpc-js\";\nimport type { CertManager } from \"../security/cert-manager.js\";\nimport { log } from \"../utils/logger.js\";\n\nexport interface LiopTlsOptions {\n\t/** Path to the root CA certificate (PEM format) */\n\trootCert?: string;\n\t/** Path to the server/client certificate (PEM format) */\n\tcertChain?: string;\n\t/** Path to the private key (PEM format) */\n\tprivateKey?: string;\n\t/** Require mutual TLS (mTLS): verify client certificate against root CA */\n\tmutualTls?: boolean;\n\t/** Optional CertManager instance for automated certificate management and hot reloading */\n\tcertManager?: CertManager;\n}\n\nconst isTlsEnforced = () =>\n\tprocess.env.NODE_ENV === \"production\" ||\n\tprocess.env.LIOP_ENFORCE_TLS === \"true\";\n\n/**\n * Creates gRPC server credentials from TLS options.\n * In production or when LIOP_ENFORCE_TLS=true, refuses to fall back to insecure.\n * When mutualTls=true, enforces client certificate authentication against root CA.\n */\nexport function createServerCredentials(\n\ttls?: LiopTlsOptions,\n): grpc.ServerCredentials {\n\t// Mutual TLS requires a root CA certificate to authenticate clients\n\tif (tls?.mutualTls && !tls.rootCert && !tls.certManager?.getRootCert()) {\n\t\tthrow new Error(\n\t\t\t\"[LIOP-TLS] FATAL: Mutual TLS (mTLS) enabled but no root CA certificate (rootCert) provided to verify client certificates.\",\n\t\t);\n\t}\n\n\t// If CertManager is provided, use its in-memory cached buffers\n\tif (tls?.certManager) {\n\t\ttry {\n\t\t\tconst certChain = tls.certManager.getCertChain();\n\t\t\tconst privateKey = tls.certManager.getPrivateKey();\n\t\t\tconst rootCert = tls.certManager.getRootCert();\n\n\t\t\tif (tls.mutualTls && !rootCert) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"[LIOP-TLS] FATAL: Mutual TLS (mTLS) enabled but CertManager has no root CA certificate loaded.\",\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn grpc.ServerCredentials.createSsl(\n\t\t\t\trootCert,\n\t\t\t\t[{ cert_chain: certChain, private_key: privateKey }],\n\t\t\t\tBoolean(tls.mutualTls),\n\t\t\t);\n\t\t} catch (error) {\n\t\t\tif (isTlsEnforced()) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`[LIOP-TLS] FATAL: CertManager server credential creation failed in enforced mode: ${error}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tlog.warn(\n\t\t\t\t`[LIOP-TLS] CertManager failed, falling back to insecure: ${error}`,\n\t\t\t);\n\t\t\treturn grpc.ServerCredentials.createInsecure();\n\t\t}\n\t}\n\n\tif (!tls?.certChain || !tls?.privateKey) {\n\t\tif (isTlsEnforced()) {\n\t\t\tthrow new Error(\n\t\t\t\t\"[LIOP-TLS] FATAL: TLS certificates required in production or when LIOP_ENFORCE_TLS=true.\",\n\t\t\t);\n\t\t}\n\t\tlog.warn(\n\t\t\t\"[LIOP-TLS] No TLS certificates configured — using insecure server credentials\",\n\t\t);\n\t\treturn grpc.ServerCredentials.createInsecure();\n\t}\n\n\ttry {\n\t\tconst rootCert = tls.rootCert ? fs.readFileSync(tls.rootCert) : null;\n\t\tconst certChain = fs.readFileSync(tls.certChain);\n\t\tconst privateKey = fs.readFileSync(tls.privateKey);\n\n\t\tif (tls.mutualTls && !rootCert) {\n\t\t\tthrow new Error(\n\t\t\t\t\"[LIOP-TLS] FATAL: Mutual TLS (mTLS) enabled but no root CA certificate (rootCert) provided to verify client certificates.\",\n\t\t\t);\n\t\t}\n\n\t\treturn grpc.ServerCredentials.createSsl(\n\t\t\trootCert,\n\t\t\t[{ cert_chain: certChain, private_key: privateKey }],\n\t\t\tBoolean(tls.mutualTls),\n\t\t);\n\t} catch (error) {\n\t\tif (isTlsEnforced()) {\n\t\t\tthrow new Error(\n\t\t\t\t`[LIOP-TLS] FATAL: Server certificate loading failed in production or enforced mode. ` +\n\t\t\t\t\t`Refusing insecure fallback to prevent MITM/eavesdropping: ${error}`,\n\t\t\t);\n\t\t}\n\t\tlog.warn(\n\t\t\t`[LIOP-TLS] Server certificate loading failed, falling back to insecure (dev mode): ${error}`,\n\t\t);\n\t\treturn grpc.ServerCredentials.createInsecure();\n\t}\n}\n\n/**\n * Creates gRPC channel credentials from TLS options.\n * In production or when LIOP_ENFORCE_TLS=true, refuses to fall back to insecure.\n */\nexport function createChannelCredentials(\n\ttls?: LiopTlsOptions,\n): grpc.ChannelCredentials {\n\t// If CertManager is provided, use its in-memory cached credentials\n\tif (tls?.certManager) {\n\t\ttry {\n\t\t\tconst rootCert = tls.certManager.getRootCert();\n\t\t\tif (!rootCert) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"[LIOP-TLS] FATAL: Channel TLS requires a root CA certificate in CertManager.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst certChain = tls.certManager.getCertChain();\n\t\t\tconst privateKey = tls.certManager.getPrivateKey();\n\t\t\treturn grpc.credentials.createSsl(rootCert, privateKey, certChain);\n\t\t} catch (error) {\n\t\t\tif (isTlsEnforced()) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`[LIOP-TLS] FATAL: Channel certificate loading failed in enforced mode: ${error}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tlog.warn(\n\t\t\t\t`[LIOP-TLS] Channel CertManager failed, falling back to insecure: ${error}`,\n\t\t\t);\n\t\t\treturn grpc.credentials.createInsecure();\n\t\t}\n\t}\n\n\tif (!tls?.rootCert) {\n\t\tif (isTlsEnforced()) {\n\t\t\tthrow new Error(\n\t\t\t\t\"[LIOP-TLS] FATAL: TLS root certificate required in production or when LIOP_ENFORCE_TLS=true.\",\n\t\t\t);\n\t\t}\n\t\tlog.warn(\n\t\t\t\"[LIOP-TLS] No TLS root certificate configured — using insecure channel credentials\",\n\t\t);\n\t\treturn grpc.credentials.createInsecure();\n\t}\n\n\ttry {\n\t\tconst rootCert = fs.readFileSync(tls.rootCert);\n\t\tconst certChain = tls.certChain\n\t\t\t? fs.readFileSync(tls.certChain)\n\t\t\t: undefined;\n\t\tconst privateKey = tls.privateKey\n\t\t\t? fs.readFileSync(tls.privateKey)\n\t\t\t: undefined;\n\n\t\treturn grpc.credentials.createSsl(rootCert, privateKey, certChain);\n\t} catch (error) {\n\t\tif (isTlsEnforced()) {\n\t\t\tthrow new Error(\n\t\t\t\t`[LIOP-TLS] FATAL: Channel certificate loading failed in production or enforced mode. ` +\n\t\t\t\t\t`Refusing insecure fallback to prevent MITM/eavesdropping: ${error}`,\n\t\t\t);\n\t\t}\n\t\tlog.warn(\n\t\t\t`[LIOP-TLS] Channel certificate loading failed, falling back to insecure (dev mode): ${error}`,\n\t\t);\n\t\treturn grpc.credentials.createInsecure();\n\t}\n}\n"]}
|
package/dist/client.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import './verifier-COnid_dg.js';
|
|
2
2
|
import './mesh.js';
|
|
3
|
-
export {
|
|
4
|
-
import './types-
|
|
3
|
+
export { c as LiopClient } from './index-cMV0_yD9.js';
|
|
4
|
+
import './types-lJIxBlWF.js';
|
|
5
|
+
import 'node:events';
|
|
5
6
|
import 'zod';
|
|
6
7
|
import 'jose';
|
package/dist/client.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
export { LiopClient } from './chunk-
|
|
1
|
+
export { LiopClient } from './chunk-CRZBVFDV.js';
|
|
2
2
|
import './chunk-32ADSAJS.js';
|
|
3
3
|
import './chunk-OUUTDSOW.js';
|
|
4
4
|
import './chunk-QLCOEP5J.js';
|
|
5
|
-
import './chunk-
|
|
6
|
-
import './chunk-
|
|
5
|
+
import './chunk-WSW6YJNY.js';
|
|
6
|
+
import './chunk-PYKRQAER.js';
|
|
7
|
+
import './chunk-74CISO2I.js';
|
|
7
8
|
import './chunk-72MNYFR6.js';
|
|
8
9
|
//# sourceMappingURL=client.js.map
|
|
9
10
|
//# sourceMappingURL=client.js.map
|
package/dist/gateway.d.ts
CHANGED
|
@@ -1,112 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
import { M as McpRequest, A as AuthInfo, b as McpResponse } from './types-sKeUxuky.js';
|
|
1
|
+
import './mesh.js';
|
|
2
|
+
import './index-BW95kAL4.js';
|
|
3
|
+
export { L as LiopHybridGateway } from './hybrid-CF__0YnC.js';
|
|
5
4
|
import 'zod';
|
|
5
|
+
import './types-lJIxBlWF.js';
|
|
6
6
|
import 'jose';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* LIOP MCP Router
|
|
10
|
-
*
|
|
11
|
-
* Core logic for routing MCP requests to local or remote LIOP providers.
|
|
12
|
-
* Decoupled from transport (HTTP/Stdio).
|
|
13
|
-
*
|
|
14
|
-
* All tool discovery and port resolution is DYNAMIC via the
|
|
15
|
-
* /liop/manifest/1.0.0 protocol stream over Kademlia DHT.
|
|
16
|
-
*/
|
|
17
|
-
declare class LiopMcpRouter {
|
|
18
|
-
private liopServer;
|
|
19
|
-
private meshNode;
|
|
20
|
-
private defaultRpcPort;
|
|
21
|
-
/** Cached manifests from remote peers. Key = PeerID */
|
|
22
|
-
private manifestCache;
|
|
23
|
-
/** Guards against concurrent discovery storms */
|
|
24
|
-
private currentDiscovery;
|
|
25
|
-
/** Verifier for Tier-0 integrity checks */
|
|
26
|
-
verifier: LiopVerifier;
|
|
27
|
-
/** Callback when new remote tools are discovered */
|
|
28
|
-
onToolsChanged?: () => void;
|
|
29
|
-
/** Circuit-breaker state for peers that repeatedly fail manifest queries. */
|
|
30
|
-
private manifestFailureState;
|
|
31
|
-
private static readonly MANIFEST_FAILURE_BASE_COOLDOWN_MS;
|
|
32
|
-
private static readonly MANIFEST_FAILURE_MAX_COOLDOWN_MS;
|
|
33
|
-
private static readonly MANIFEST_SKIP_LOG_THROTTLE_MS;
|
|
34
|
-
constructor(liopServer: LiopServer, meshNode?: MeshNode | null, defaultRpcPort?: number);
|
|
35
|
-
private shouldSkipManifestQuery;
|
|
36
|
-
private recordManifestQuerySuccess;
|
|
37
|
-
private recordManifestQueryFailure;
|
|
38
|
-
dispatch(request: McpRequest, authInfo?: AuthInfo | null): Promise<McpResponse | null>;
|
|
39
|
-
/**
|
|
40
|
-
* MCP clients often send notifications/initialized then immediately tools/list.
|
|
41
|
-
* Start manifest discovery without blocking the notification handler.
|
|
42
|
-
*/
|
|
43
|
-
private kickDiscoveryAfterInitialized;
|
|
44
|
-
/**
|
|
45
|
-
* Discovers and caches manifests from all remote LIOP providers in the mesh.
|
|
46
|
-
* Uses Kademlia DHT to find "liop:manifest" providers, then opens
|
|
47
|
-
* /liop/manifest/1.0.0 protocol streams to retrieve their full metadata.
|
|
48
|
-
*/
|
|
49
|
-
refreshManifestCache(silent?: boolean): Promise<void>;
|
|
50
|
-
/**
|
|
51
|
-
* Returns the current manifest cache size for external telemetry.
|
|
52
|
-
* Used by the adaptive polling system to detect topology stabilization.
|
|
53
|
-
*/
|
|
54
|
-
getCacheSize(): number;
|
|
55
|
-
/**
|
|
56
|
-
* Returns all remote tools discovered via the manifest protocol.
|
|
57
|
-
*/
|
|
58
|
-
private getRemoteTools;
|
|
59
|
-
/**
|
|
60
|
-
* Returns all remote resources discovered via the manifest protocol.
|
|
61
|
-
*/
|
|
62
|
-
private getRemoteResources;
|
|
63
|
-
/**
|
|
64
|
-
* Resolves the gRPC target (host:port) AND the peerId for a given tool name
|
|
65
|
-
* by searching the manifest cache. Supports exact names and suffixed names.
|
|
66
|
-
*/
|
|
67
|
-
private resolveManifestTarget;
|
|
68
|
-
/**
|
|
69
|
-
* Redacts a PeerID for external-facing diagnostics.
|
|
70
|
-
* LIOP_DIAGNOSTIC_LEVEL controls verbosity:
|
|
71
|
-
* - "redacted" (default): truncated to last 8 chars
|
|
72
|
-
* - "full": complete PeerID (development only)
|
|
73
|
-
*/
|
|
74
|
-
private redactPeerId;
|
|
75
|
-
private transcodeMcpToLiop;
|
|
76
|
-
private routeToRemoteProvider;
|
|
77
|
-
/** Cached M2M token for dynamic gateway-to-node routing */
|
|
78
|
-
private meshAgentToken?;
|
|
79
|
-
/**
|
|
80
|
-
* Dynamically acquires an M2M access token from the Nexus Authorization Server.
|
|
81
|
-
* If peerId is provided, checks if there are node-specific environment tokens
|
|
82
|
-
* before falling back to the global static token or Nexus acquisition.
|
|
83
|
-
*/
|
|
84
|
-
private getOrAcquireMeshAgentToken;
|
|
85
|
-
private performTranscoding;
|
|
86
|
-
private encryptWithNonce;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* LIOP Hybrid Gateway
|
|
91
|
-
* High-level orchestration for connecting MCP (JSON-RPC) clients to the LIOP Mesh.
|
|
92
|
-
*/
|
|
93
|
-
declare class LiopHybridGateway {
|
|
94
|
-
private liopServer;
|
|
95
|
-
private meshNode;
|
|
96
|
-
private netServer;
|
|
97
|
-
private h2Server;
|
|
98
|
-
private h1Server;
|
|
99
|
-
private router;
|
|
100
|
-
private jwtValidator?;
|
|
101
|
-
private oauthProvider?;
|
|
102
|
-
constructor(liopServer: LiopServer, meshNode?: MeshNode | null, rpcPort?: number);
|
|
103
|
-
private setupH2Routes;
|
|
104
|
-
private setupH1Routes;
|
|
105
|
-
private handleGrpcStream;
|
|
106
|
-
private handleMcpH2Stream;
|
|
107
|
-
listen(port: number, host?: string): Promise<number>;
|
|
108
|
-
stop(): Promise<void>;
|
|
109
|
-
getRouter(): LiopMcpRouter;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export { LiopHybridGateway };
|
|
7
|
+
import './verifier-COnid_dg.js';
|
package/dist/gateway.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
export { LiopHybridGateway } from './chunk-
|
|
2
|
-
import './chunk-
|
|
1
|
+
export { LiopHybridGateway } from './chunk-636UOVSO.js';
|
|
2
|
+
import './chunk-KF4DCCU3.js';
|
|
3
3
|
import './chunk-32ADSAJS.js';
|
|
4
4
|
import './chunk-OUUTDSOW.js';
|
|
5
5
|
import './chunk-QLCOEP5J.js';
|
|
6
|
-
import './chunk-
|
|
7
|
-
import './chunk-
|
|
6
|
+
import './chunk-OIMJZ64E.js';
|
|
7
|
+
import './chunk-WSW6YJNY.js';
|
|
8
|
+
import './chunk-PYKRQAER.js';
|
|
8
9
|
import './chunk-72MNYFR6.js';
|
|
9
10
|
//# sourceMappingURL=gateway.js.map
|
|
10
11
|
//# sourceMappingURL=gateway.js.map
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { MeshNode } from './mesh.js';
|
|
2
|
+
import { L as LiopServer } from './index-BW95kAL4.js';
|
|
3
|
+
import { L as LiopVerifier } from './verifier-COnid_dg.js';
|
|
4
|
+
import { b as McpRequest, M as McpEra, A as AuthInfo, c as McpResponse } from './types-lJIxBlWF.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* LIOP Sliding-Window Rate Limiter
|
|
8
|
+
*
|
|
9
|
+
* High-performance, zero-dependency in-memory rate limiter designed
|
|
10
|
+
* to protect the LIOP Hybrid Gateway and Mesh Nodes against Denial of Service (DoS),
|
|
11
|
+
* worker pool exhaustion, and brute-force attacks.
|
|
12
|
+
*
|
|
13
|
+
* Conforms to OWASP API Security Top 10 (API4:2023 - Unrestricted Resource Consumption).
|
|
14
|
+
*/
|
|
15
|
+
interface RateLimiterOptions {
|
|
16
|
+
/** Window duration in milliseconds (default: 60,000ms = 1 minute) */
|
|
17
|
+
windowMs?: number;
|
|
18
|
+
/** Maximum number of allowed requests per window (default: 120) */
|
|
19
|
+
maxRequests?: number;
|
|
20
|
+
}
|
|
21
|
+
interface RateLimitStatus {
|
|
22
|
+
allowed: boolean;
|
|
23
|
+
remaining: number;
|
|
24
|
+
limit: number;
|
|
25
|
+
resetMs: number;
|
|
26
|
+
}
|
|
27
|
+
declare class InMemoryRateLimiter {
|
|
28
|
+
private readonly windowMs;
|
|
29
|
+
private readonly maxRequests;
|
|
30
|
+
private readonly records;
|
|
31
|
+
private cleanupTimer?;
|
|
32
|
+
constructor(options?: RateLimiterOptions);
|
|
33
|
+
/**
|
|
34
|
+
* Evaluates whether a request from the given key (IP, token, or clientId) is permitted.
|
|
35
|
+
*
|
|
36
|
+
* @param key Identifier for the client (e.g., remote IP or OAuth client ID)
|
|
37
|
+
* @returns Status containing allowed boolean, remaining quota, and time until reset
|
|
38
|
+
*/
|
|
39
|
+
check(key: string): RateLimitStatus;
|
|
40
|
+
/**
|
|
41
|
+
* Explicitly resets the rate limit bucket for a given key.
|
|
42
|
+
*/
|
|
43
|
+
reset(key: string): void;
|
|
44
|
+
/**
|
|
45
|
+
* Cleans up expired rate-limiting buckets to prevent memory leaks.
|
|
46
|
+
*/
|
|
47
|
+
cleanup(): void;
|
|
48
|
+
/**
|
|
49
|
+
* Destroys internal timers and clears records.
|
|
50
|
+
*/
|
|
51
|
+
close(): void;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* LIOP MCP Router
|
|
56
|
+
*
|
|
57
|
+
* Core logic for routing MCP requests to local or remote LIOP providers.
|
|
58
|
+
* Decoupled from transport (HTTP/Stdio).
|
|
59
|
+
*
|
|
60
|
+
* All tool discovery and port resolution is DYNAMIC via the
|
|
61
|
+
* /liop/manifest/1.0.0 protocol stream over Kademlia DHT.
|
|
62
|
+
*/
|
|
63
|
+
declare class LiopMcpRouter {
|
|
64
|
+
private liopServer;
|
|
65
|
+
private meshNode;
|
|
66
|
+
private defaultRpcPort;
|
|
67
|
+
/** Cached manifests from remote peers. Key = PeerID */
|
|
68
|
+
private manifestCache;
|
|
69
|
+
/** Guards against concurrent discovery storms */
|
|
70
|
+
private currentDiscovery;
|
|
71
|
+
/** Verifier for Tier-0 integrity checks */
|
|
72
|
+
verifier: LiopVerifier;
|
|
73
|
+
/** Callback when new remote tools are discovered */
|
|
74
|
+
onToolsChanged?: () => void;
|
|
75
|
+
/** Circuit-breaker state for peers that repeatedly fail manifest queries. */
|
|
76
|
+
private manifestFailureState;
|
|
77
|
+
private static readonly MANIFEST_FAILURE_BASE_COOLDOWN_MS;
|
|
78
|
+
private static readonly MANIFEST_FAILURE_MAX_COOLDOWN_MS;
|
|
79
|
+
private static readonly MANIFEST_SKIP_LOG_THROTTLE_MS;
|
|
80
|
+
constructor(liopServer: LiopServer, meshNode?: MeshNode | null, defaultRpcPort?: number);
|
|
81
|
+
getManifestCacheSize(): number;
|
|
82
|
+
private shouldSkipManifestQuery;
|
|
83
|
+
private recordManifestQuerySuccess;
|
|
84
|
+
private recordManifestQueryFailure;
|
|
85
|
+
/**
|
|
86
|
+
* Detects the protocol era of an incoming request.
|
|
87
|
+
* Modern requests carry '_meta' with protocol version "2026-07-28" or use modern RPCs.
|
|
88
|
+
* Legacy requests use 'initialize' handshake or lack '_meta' envelopes.
|
|
89
|
+
*/
|
|
90
|
+
detectEra(request: McpRequest): McpEra;
|
|
91
|
+
dispatch(request: McpRequest, authInfo?: AuthInfo | null): Promise<McpResponse | null>;
|
|
92
|
+
/**
|
|
93
|
+
* MCP clients often send notifications/initialized then immediately tools/list.
|
|
94
|
+
* Start manifest discovery without blocking the notification handler.
|
|
95
|
+
*/
|
|
96
|
+
private kickDiscoveryAfterInitialized;
|
|
97
|
+
/**
|
|
98
|
+
* Discovers and caches manifests from all remote LIOP providers in the mesh.
|
|
99
|
+
* Uses Kademlia DHT to find "liop:manifest" providers, then opens
|
|
100
|
+
* /liop/manifest/1.0.0 protocol streams to retrieve their full metadata.
|
|
101
|
+
*/
|
|
102
|
+
refreshManifestCache(silent?: boolean): Promise<void>;
|
|
103
|
+
/**
|
|
104
|
+
* Returns the current manifest cache size for external telemetry.
|
|
105
|
+
* Used by the adaptive polling system to detect topology stabilization.
|
|
106
|
+
*/
|
|
107
|
+
getCacheSize(): number;
|
|
108
|
+
/**
|
|
109
|
+
* Returns all remote tools discovered via the manifest protocol.
|
|
110
|
+
*/
|
|
111
|
+
private getRemoteTools;
|
|
112
|
+
/**
|
|
113
|
+
* Returns all remote resources discovered via the manifest protocol.
|
|
114
|
+
*/
|
|
115
|
+
private getRemoteResources;
|
|
116
|
+
/**
|
|
117
|
+
* Resolves the gRPC target (host:port) AND the peerId for a given tool name
|
|
118
|
+
* by searching the manifest cache. Supports exact names and suffixed names.
|
|
119
|
+
*/
|
|
120
|
+
private resolveManifestTarget;
|
|
121
|
+
/**
|
|
122
|
+
* Redacts a PeerID for external-facing diagnostics.
|
|
123
|
+
* LIOP_DIAGNOSTIC_LEVEL controls verbosity:
|
|
124
|
+
* - "redacted" (default): truncated to last 8 chars
|
|
125
|
+
* - "full": complete PeerID (development only)
|
|
126
|
+
*/
|
|
127
|
+
private redactPeerId;
|
|
128
|
+
private transcodeMcpToLiop;
|
|
129
|
+
private routeToRemoteProvider;
|
|
130
|
+
/** Cached M2M token for dynamic gateway-to-node routing */
|
|
131
|
+
private meshAgentToken?;
|
|
132
|
+
/**
|
|
133
|
+
* Dynamically acquires an M2M access token from the Nexus Authorization Server.
|
|
134
|
+
* If peerId is provided, checks if there are node-specific environment tokens
|
|
135
|
+
* before falling back to the global static token or Nexus acquisition.
|
|
136
|
+
*/
|
|
137
|
+
private getOrAcquireMeshAgentToken;
|
|
138
|
+
private performTranscoding;
|
|
139
|
+
private encryptWithNonce;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* LIOP Hybrid Gateway
|
|
144
|
+
* High-level orchestration for connecting MCP (JSON-RPC) clients to the LIOP Mesh.
|
|
145
|
+
*/
|
|
146
|
+
declare class LiopHybridGateway {
|
|
147
|
+
private liopServer;
|
|
148
|
+
private meshNode;
|
|
149
|
+
private netServer;
|
|
150
|
+
private h2Server;
|
|
151
|
+
private h1Server;
|
|
152
|
+
private router;
|
|
153
|
+
private jwtValidator?;
|
|
154
|
+
private oauthProvider?;
|
|
155
|
+
private rateLimiter;
|
|
156
|
+
private isDraining;
|
|
157
|
+
private activeRequests;
|
|
158
|
+
constructor(liopServer: LiopServer, meshNode?: MeshNode | null, rpcPort?: number, rateLimiterOptions?: RateLimiterOptions);
|
|
159
|
+
private setupH2Routes;
|
|
160
|
+
private setupH1Routes;
|
|
161
|
+
private handleGrpcStream;
|
|
162
|
+
private handleMcpH2Stream;
|
|
163
|
+
listen(port: number, host?: string): Promise<number>;
|
|
164
|
+
isDrained(): boolean;
|
|
165
|
+
drain(timeoutMs?: number): Promise<void>;
|
|
166
|
+
stop(): Promise<void>;
|
|
167
|
+
getRouter(): LiopMcpRouter;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export { InMemoryRateLimiter as I, LiopHybridGateway as L, type RateLimitStatus as R, LiopMcpRouter as a, type RateLimiterOptions as b };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { MeshNode } from './mesh.js';
|
|
3
|
-
import { J as JwtValidator, S as ServerInfo, a as CallToolResult, P as Prompt, G as GetPromptRequest,
|
|
3
|
+
import { J as JwtValidator, S as ServerInfo, a as CallToolResult, P as Prompt, G as GetPromptRequest, d as GetPromptResult, C as CallToolRequest, T as Tool, R as Resource } from './types-lJIxBlWF.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* LIOP OAuth 2.1 Hybrid Auth — Configuration Types
|
|
@@ -100,6 +100,60 @@ declare const AUTH_DEFAULTS: {
|
|
|
100
100
|
readonly signingAlgorithm: "EdDSA";
|
|
101
101
|
};
|
|
102
102
|
|
|
103
|
+
/**
|
|
104
|
+
* LIOP Immutable Audit Logger (Phase Beta-3)
|
|
105
|
+
* SOC 2 Type II & HIPAA compliant audit trail with cryptographic Hash-Chain.
|
|
106
|
+
* Guarantees tamper-evidence and non-repudiation for all Logic-on-Origin executions.
|
|
107
|
+
*/
|
|
108
|
+
type AuditStatus = "SUCCESS" | "BLOCKED_EGRESS" | "ERROR" | "POLICY_VIOLATION";
|
|
109
|
+
interface AuditEntry {
|
|
110
|
+
id: string;
|
|
111
|
+
timestamp: string;
|
|
112
|
+
traceId: string;
|
|
113
|
+
agentDid: string;
|
|
114
|
+
peerId: string;
|
|
115
|
+
toolName: string;
|
|
116
|
+
datasetHash: string;
|
|
117
|
+
fuelConsumed: number;
|
|
118
|
+
outputHash: string;
|
|
119
|
+
zkReceiptSig: string;
|
|
120
|
+
status: AuditStatus;
|
|
121
|
+
prevEntryHash: string;
|
|
122
|
+
entryHash: string;
|
|
123
|
+
}
|
|
124
|
+
interface AuditRecordParams {
|
|
125
|
+
timestamp?: string;
|
|
126
|
+
traceId?: string;
|
|
127
|
+
agentDid: string;
|
|
128
|
+
peerId: string;
|
|
129
|
+
toolName: string;
|
|
130
|
+
datasetHash?: string;
|
|
131
|
+
fuelConsumed: number;
|
|
132
|
+
outputHash?: string;
|
|
133
|
+
zkReceiptSig?: string;
|
|
134
|
+
status: AuditStatus;
|
|
135
|
+
}
|
|
136
|
+
declare const GENESIS_HASH: string;
|
|
137
|
+
declare function computeEntryHash(entryWithoutHash: Omit<AuditEntry, "entryHash">): string;
|
|
138
|
+
declare class AuditLogger {
|
|
139
|
+
private entries;
|
|
140
|
+
private lastEntryHash;
|
|
141
|
+
private filePath?;
|
|
142
|
+
constructor(filePath?: string);
|
|
143
|
+
recordExecution(params: AuditRecordParams): AuditEntry;
|
|
144
|
+
getEntries(): readonly AuditEntry[];
|
|
145
|
+
getEntryCount(): number;
|
|
146
|
+
verifyIntegrity(): {
|
|
147
|
+
valid: boolean;
|
|
148
|
+
totalEntries: number;
|
|
149
|
+
brokenIndex?: number;
|
|
150
|
+
reason?: string;
|
|
151
|
+
};
|
|
152
|
+
exportJsonl(): string;
|
|
153
|
+
private loadFromFile;
|
|
154
|
+
}
|
|
155
|
+
declare const globalAuditLogger: AuditLogger;
|
|
156
|
+
|
|
103
157
|
/** Single named entity detected by the NER scanner. */
|
|
104
158
|
interface NerEntity {
|
|
105
159
|
type: "person" | "place" | "organization";
|
|
@@ -278,6 +332,10 @@ interface LiopServerOptions {
|
|
|
278
332
|
* Must match SCREAMING_SNAKE_CASE: /^[A-Z][A-Z0-9_]*$/ (e.g., "BANK", "VAULT", "HFT_ORACLE").
|
|
279
333
|
*/
|
|
280
334
|
tokenSlug?: string;
|
|
335
|
+
/**
|
|
336
|
+
* SOC 2 Type II / HIPAA immutable audit logger instance.
|
|
337
|
+
*/
|
|
338
|
+
auditLogger?: AuditLogger;
|
|
281
339
|
/**
|
|
282
340
|
* Path to a shared JSON file for persistent Query Budget tracking across multiple server instances.
|
|
283
341
|
*/
|
|
@@ -363,6 +421,9 @@ declare class LiopServer {
|
|
|
363
421
|
private sessions;
|
|
364
422
|
private revokedTokenHashes;
|
|
365
423
|
private lastRevocationLoadTime;
|
|
424
|
+
private pqcKeyPair;
|
|
425
|
+
readonly auditLogger: AuditLogger;
|
|
426
|
+
getDatasetHash(): string;
|
|
366
427
|
private static readonly LIOP_COMPACT_REGEX;
|
|
367
428
|
private extractLogic;
|
|
368
429
|
private parseUnknownJson;
|
|
@@ -520,4 +581,4 @@ declare class LiopServer {
|
|
|
520
581
|
private applyInMemoryBudget;
|
|
521
582
|
}
|
|
522
583
|
|
|
523
|
-
export { AUTH_DEFAULTS as A, LiopServer as L, NerScanner as N, type OAuthClientConfig as O, PII_PATTERNS as P, type ToolHandler as T, type LiopServerOptions as a, type AggregationPolicy as b, type
|
|
584
|
+
export { AUTH_DEFAULTS as A, GENESIS_HASH as G, LiopServer as L, NerScanner as N, type OAuthClientConfig as O, PII_PATTERNS as P, type ToolHandler as T, type LiopServerOptions as a, type AggregationPolicy as b, type AuditEntry as c, AuditLogger as d, type AuditRecordParams as e, type AuditStatus as f, type AuthRole as g, type LiopAuthConfig as h, type LogicExecutionPolicy as i, type OutputSanitizerConfig as j, PII_PRESETS as k, type PiiRule as l, PiiScanner as m, computeEntryHash as n, globalAuditLogger as o, sanitizeOutput as s };
|