@riceawa/dsh-lan-gateway 0.5.4 → 0.5.5
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/README.md +12 -6
- package/lib/client.js +157 -125
- package/lib/client.js.map +1 -1
- package/lib/index.d.ts +44 -5
- package/lib/index.js +1379 -985
- package/package.json +1 -1
- package/src/auth.ts +7 -14
- package/src/client/lan-gateway-card.tsx +61 -127
- package/src/config-fields.ts +137 -0
- package/src/gateway.ts +203 -240
- package/src/index.ts +272 -118
- package/src/login.ts +1 -17
- package/src/request-policy.ts +315 -0
- package/src/state.ts +16 -5
- package/src/tls.ts +23 -0
- package/src/upstream-session.ts +24 -8
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import z from "@deepseek-ai/schemastery";
|
|
2
|
-
import { IncomingMessage, ServerResponse } from "node:http";
|
|
3
2
|
import { Context } from "@deepseek-ai/cordis";
|
|
3
|
+
import { IncomingMessage, ServerResponse } from "http";
|
|
4
4
|
//#region src/index.d.ts
|
|
5
5
|
/** Stable Cordis plugin name. */
|
|
6
6
|
declare const name = "dsh-lan-gateway";
|
|
@@ -60,12 +60,17 @@ interface Config {
|
|
|
60
60
|
/**
|
|
61
61
|
* Removed capability: authentication is always required. Retained only so an
|
|
62
62
|
* explicit legacy `authRequired: false` is rejected loudly instead of
|
|
63
|
-
* silently ignored.
|
|
63
|
+
* silently ignored. Not card-editable and never written back to the user
|
|
64
|
+
* section — the config route builds its patch from the editable key set.
|
|
64
65
|
*/
|
|
65
66
|
authRequired?: boolean;
|
|
66
67
|
/** Session cookie lifetime in days. */
|
|
67
68
|
cookieMaxAgeDays: number;
|
|
68
|
-
/**
|
|
69
|
+
/**
|
|
70
|
+
* Cookie name. Deliberately not card-editable — see the editable key set in
|
|
71
|
+
* `config-fields.ts`; the config route applies a patch, so an operator's
|
|
72
|
+
* custom name survives every save from the Settings card.
|
|
73
|
+
*/
|
|
69
74
|
cookieName: string;
|
|
70
75
|
/** Whether the gateway listener speaks TLS. */
|
|
71
76
|
tlsEnabled: boolean;
|
|
@@ -75,7 +80,13 @@ interface Config {
|
|
|
75
80
|
tlsCertPath?: string;
|
|
76
81
|
/** Custom mode: path to the PEM private key. */
|
|
77
82
|
tlsKeyPath?: string;
|
|
78
|
-
/**
|
|
83
|
+
/**
|
|
84
|
+
* Self-signed mode: comma/space separated DNS names and IPs for the SANs.
|
|
85
|
+
*
|
|
86
|
+
* Read when a certificate is generated, not when it is served: changing it
|
|
87
|
+
* does not replace a certificate that already exists and is still valid. Use
|
|
88
|
+
* `lan_gateway tls-regenerate` for that.
|
|
89
|
+
*/
|
|
79
90
|
tlsSelfSignedHosts?: string;
|
|
80
91
|
/**
|
|
81
92
|
* Self-signed certificate validity in days (default 825 ≈ 27 months).
|
|
@@ -88,6 +99,8 @@ interface Config {
|
|
|
88
99
|
* self-signed certificate is either clicked through or trusted by hand,
|
|
89
100
|
* there is nothing to gain from the shorter window and a re-trust to lose
|
|
90
101
|
* every time it lapses.
|
|
102
|
+
*
|
|
103
|
+
* Like `tlsSelfSignedHosts`, this applies to the next generation only.
|
|
91
104
|
*/
|
|
92
105
|
tlsCertMaxAgeDays: number;
|
|
93
106
|
/**
|
|
@@ -99,6 +112,11 @@ interface Config {
|
|
|
99
112
|
* An identifier for a trusted TLS-terminating proxy in front of the gateway.
|
|
100
113
|
* Declaring one marks the ingress encrypted (Secure cookies, passes the
|
|
101
114
|
* encrypted-ingress gate) without this listener sending HSTS.
|
|
115
|
+
*
|
|
116
|
+
* Note the coupling with login rate limiting: the limiter is keyed by
|
|
117
|
+
* `socket.remoteAddress`, and `X-Forwarded-For` is deliberately untrusted, so
|
|
118
|
+
* behind such a proxy every browser shares one bucket — the login budget
|
|
119
|
+
* becomes per-deployment, not per-client.
|
|
102
120
|
*/
|
|
103
121
|
trustedTerminator?: string;
|
|
104
122
|
/**
|
|
@@ -144,6 +162,27 @@ declare function resolveSecureCookies(cfg: Pick<Config, 'secureCookies' | 'tlsEn
|
|
|
144
162
|
* used, and a state-changing method must carry that Origin. Exported for tests.
|
|
145
163
|
*/
|
|
146
164
|
declare function isTrustedConfigRequest(req: IncomingMessage): boolean;
|
|
165
|
+
/**
|
|
166
|
+
* Turn a submitted config patch into the next user section: only keys the card
|
|
167
|
+
* can edit, only real values, and `null` (or an emptied optional) removes the
|
|
168
|
+
* key rather than storing it.
|
|
169
|
+
*
|
|
170
|
+
* The patch is built from the *submitted* object, never from a schema call's
|
|
171
|
+
* output. Schemastery fills defaults into whatever it validates and passes
|
|
172
|
+
* unknown keys through, so deriving the section from `Config(submitted)` wrote
|
|
173
|
+
* `authRequired: true` (a capability that exists only to be refused) and any
|
|
174
|
+
* stray key into the user's settings on every save — and, because it also
|
|
175
|
+
* materialized `cookieName`, reset an operator's custom cookie name to the
|
|
176
|
+
* schema default.
|
|
177
|
+
*
|
|
178
|
+
* A `null` value is the card's clear: the key is dropped from the patch, which
|
|
179
|
+
* leaves it absent from the section, so it re-inherits the composition layer.
|
|
180
|
+
*/
|
|
181
|
+
declare function buildConfigPatch(submitted: Record<string, unknown>): {
|
|
182
|
+
patch: Record<string, unknown>;
|
|
183
|
+
clear: string[];
|
|
184
|
+
unknown: string[];
|
|
185
|
+
};
|
|
147
186
|
declare function apply(ctx: Context, config: Config): void;
|
|
148
187
|
//#endregion
|
|
149
|
-
export { Config, GatewayController, StartFacts, ToolResult, UpstreamConnectionSurface, WebServerSurface, apply, gatewayStartProblems, inject, isTrustedConfigRequest, name, resolveSecureCookies };
|
|
188
|
+
export { Config, GatewayController, StartFacts, ToolResult, UpstreamConnectionSurface, WebServerSurface, apply, buildConfigPatch, gatewayStartProblems, inject, isTrustedConfigRequest, name, resolveSecureCookies };
|