@nice-code/action 0.24.0 → 0.26.0
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 +106 -6
- package/build/{AcceptorHandler-11-QMdx2.d.mts → AcceptorHandler-CLbwu2Pa.d.mts} +179 -18
- package/build/{AcceptorHandler-CxD0c1BE.d.cts → AcceptorHandler-Du292dpC.d.cts} +179 -18
- package/build/{ActionDevtoolsCore-37JP4bOG.d.cts → ActionDevtoolsCore-DGwzONZT.d.mts} +2 -2
- package/build/{ActionDevtoolsCore-Cgq-go1R.d.mts → ActionDevtoolsCore-dH4K4w3B.d.cts} +2 -2
- package/build/advanced/index.cjs +1 -1
- package/build/advanced/index.d.cts +12 -101
- package/build/advanced/index.d.mts +12 -101
- package/build/advanced/index.mjs +1 -1
- package/build/{createHibernatableWsServerAdapter-C07RfUTH.mjs → createHibernatableWsServerAdapter-BD5n-Ev9.mjs} +186 -83
- package/build/createHibernatableWsServerAdapter-BD5n-Ev9.mjs.map +1 -0
- package/build/{createHibernatableWsServerAdapter-BNi4k9j3.cjs → createHibernatableWsServerAdapter-j96U9vgo.cjs} +185 -82
- package/build/createHibernatableWsServerAdapter-j96U9vgo.cjs.map +1 -0
- package/build/devtools/browser/index.cjs.map +1 -1
- package/build/devtools/browser/index.d.cts +1 -1
- package/build/devtools/browser/index.d.mts +1 -1
- package/build/devtools/browser/index.mjs.map +1 -1
- package/build/devtools/server/index.d.cts +1 -1
- package/build/devtools/server/index.d.mts +1 -1
- package/build/{httpAcceptorCarrier-C3S_bDkL.cjs → httpAcceptorCarrier-By0Qa__L.cjs} +2 -2
- package/build/httpAcceptorCarrier-By0Qa__L.cjs.map +1 -0
- package/build/{httpAcceptorCarrier-DPBEuewS.mjs → httpAcceptorCarrier-moSmtBxr.mjs} +2 -2
- package/build/httpAcceptorCarrier-moSmtBxr.mjs.map +1 -0
- package/build/index.cjs +6 -2
- package/build/index.cjs.map +1 -1
- package/build/index.d.cts +2 -2
- package/build/index.d.mts +2 -2
- package/build/index.mjs +3 -3
- package/build/index.mjs.map +1 -1
- package/build/platform/cloudflare/index.cjs +45 -1
- package/build/platform/cloudflare/index.cjs.map +1 -1
- package/build/platform/cloudflare/index.d.cts +40 -2
- package/build/platform/cloudflare/index.d.mts +40 -2
- package/build/platform/cloudflare/index.mjs +45 -2
- package/build/platform/cloudflare/index.mjs.map +1 -1
- package/build/react-query/index.d.cts +1 -1
- package/build/react-query/index.d.mts +1 -1
- package/package.json +5 -4
- package/build/createHibernatableWsServerAdapter-BNi4k9j3.cjs.map +0 -1
- package/build/createHibernatableWsServerAdapter-C07RfUTH.mjs.map +0 -1
- package/build/httpAcceptorCarrier-C3S_bDkL.cjs.map +0 -1
- package/build/httpAcceptorCarrier-DPBEuewS.mjs.map +0 -1
|
@@ -781,6 +781,16 @@ declare function createInMemoryTofuVerifyKeyResolver(): IClientVerifyKeyResolver
|
|
|
781
781
|
* Storage-backed trust-on-first-use resolver: pins survive process restarts / Durable Object eviction
|
|
782
782
|
* (e.g. back it with `createDurableObjectStorageAdapter`). Same policy as the in-memory variant — trust
|
|
783
783
|
* + pin the first verify key per client identity, reject a different one thereafter.
|
|
784
|
+
*
|
|
785
|
+
* Fail-closed by construction: a thrown storage read (`getJson`) or first-pin write (`updateJsonWithDef`)
|
|
786
|
+
* propagates out of `resolve`, which makes `onProve` reject the handshake — a storage error can never be
|
|
787
|
+
* mistaken for "first use" and silently trusted. (A genuine `undefined`/absent read is the only path to
|
|
788
|
+
* a fresh pin; the underlying adapters never coerce a thrown read to `undefined`.) Keep it that way: do
|
|
789
|
+
* not wrap the storage calls in a `try/catch` that swallows the error.
|
|
790
|
+
*
|
|
791
|
+
* On an *eventually-consistent* store a stale "absent" read re-pins the **same** verify key the client
|
|
792
|
+
* just presented (it is signature-verified before this runs), so the worst case is a harmless re-write,
|
|
793
|
+
* never a weakened trust decision. Cross-isolate-strong pinning still wants a strongly-consistent store.
|
|
784
794
|
*/
|
|
785
795
|
declare function createStorageTofuVerifyKeyResolver(storageAdapter: StorageAdapter): IClientVerifyKeyResolver;
|
|
786
796
|
interface IClientHandshakeConfig {
|
|
@@ -808,11 +818,37 @@ interface IServerHandshakeConfig {
|
|
|
808
818
|
/** Trust decision for a client's verify key. Defaults to in-memory TOFU. */
|
|
809
819
|
verifyKeyResolver?: IClientVerifyKeyResolver;
|
|
810
820
|
}
|
|
811
|
-
|
|
821
|
+
/**
|
|
822
|
+
* The server handshake's in-flight state between `onHello` and `onProve` — everything `onProve` needs
|
|
823
|
+
* to verify the client's proof and settle the result. Fully serializable (all JSON / serialized-key
|
|
824
|
+
* strings), so a stateless server can {@link IServerHandshake.exportPending} it after `hello`, carry it
|
|
825
|
+
* across requests (e.g. sealed into a continuation token), and {@link IServerHandshake.restorePending}
|
|
826
|
+
* it on a *different* instance before `prove` — no in-memory handshake to co-locate. The `serverNonce`
|
|
827
|
+
* is already folded into `challenge`, so it need not be carried separately.
|
|
828
|
+
*/
|
|
829
|
+
interface IServerHandshakePending {
|
|
830
|
+
client: IRuntimeCoordinate;
|
|
831
|
+
linkedClientId: TTypeAndId;
|
|
832
|
+
challenge: string;
|
|
833
|
+
clientVerifyKey: TSerializedCryptoKeyData_Ed25519_Raw;
|
|
834
|
+
negotiatedLevel: ESecurityLevel;
|
|
835
|
+
keyMaterial?: IHandshakeEncryptionKeyMaterial;
|
|
836
|
+
}
|
|
837
|
+
interface IServerHandshake {
|
|
812
838
|
onHello(hello: THsHello): Promise<THsWelcome | THsReject>;
|
|
813
|
-
onProve(prove: THsProve): Promise<THsAccept | THsReject>;
|
|
839
|
+
onProve(prove: THsProve): Promise<THsAccept | THsReject>;
|
|
814
840
|
getResult(): IHandshakeResult | undefined;
|
|
815
|
-
}
|
|
841
|
+
/** The serializable in-flight state after `onHello` (else `undefined`). See {@link IServerHandshakePending}. */
|
|
842
|
+
exportPending(): IServerHandshakePending | undefined;
|
|
843
|
+
/**
|
|
844
|
+
* Restore exported `pending` onto a *fresh* handshake instance so `onProve` can run without the
|
|
845
|
+
* `onHello` that produced it (the stateless / cross-instance path). Re-links the client's verify key
|
|
846
|
+
* — `onHello`'s `linkClient` was in-memory only and won't exist on this instance — so the signature
|
|
847
|
+
* check in `onProve` succeeds. Build the instance with the same `config` (identity link + coordinate).
|
|
848
|
+
*/
|
|
849
|
+
restorePending(pending: IServerHandshakePending): Promise<void>;
|
|
850
|
+
}
|
|
851
|
+
declare function createServerHandshake(config: IServerHandshakeConfig): IServerHandshake;
|
|
816
852
|
//#endregion
|
|
817
853
|
//#region src/ActionRuntime/Handler/PeerLink/Acceptor/createSecureActionServer.d.ts
|
|
818
854
|
interface ISecureAcceptorHandlerOptions<TConn> {
|
|
@@ -820,9 +856,10 @@ interface ISecureAcceptorHandlerOptions<TConn> {
|
|
|
820
856
|
channel: IActionChannel;
|
|
821
857
|
/**
|
|
822
858
|
* Coordinate of the *connecting clients* (typically env-only, e.g. `RuntimeCoordinate.env("web_app")`),
|
|
823
|
-
* used
|
|
859
|
+
* used as the offline-return scoring fallback (a live connection always wins regardless). Optional —
|
|
860
|
+
* omit it for a multi-role server accepting several client envs over one acceptor.
|
|
824
861
|
*/
|
|
825
|
-
clientEnv
|
|
862
|
+
clientEnv?: RuntimeCoordinate;
|
|
826
863
|
/** This server's runtime — its coordinate is the server identity presented in the handshake. */
|
|
827
864
|
runtime: ActionRuntime;
|
|
828
865
|
/**
|
|
@@ -1832,9 +1869,12 @@ interface IConnectionContext<TConn, TApp = unknown> {
|
|
|
1832
1869
|
interface IServeChannelOptions<TO_ACCEPTOR extends readonly ActionDomain<any>[], TConn, TApp = unknown> {
|
|
1833
1870
|
/**
|
|
1834
1871
|
* Coordinate of the *connecting clients* (typically env-only, e.g. `RuntimeCoordinate.env("web_app")`),
|
|
1835
|
-
* used
|
|
1872
|
+
* used only as the offline-return scoring fallback — a result/push to a live client always routes over
|
|
1873
|
+
* the carrier it connected on regardless of this. Optional: omit it for a multi-role server that accepts
|
|
1874
|
+
* clients of several envs over one acceptor (it then scores 0 against every client, so the live
|
|
1875
|
+
* connection always decides).
|
|
1836
1876
|
*/
|
|
1837
|
-
clientEnv
|
|
1877
|
+
clientEnv?: RuntimeCoordinate;
|
|
1838
1878
|
/**
|
|
1839
1879
|
* One backing store for the server's crypto identity *and* its trust-on-first-use verify-key pins
|
|
1840
1880
|
* (their keys don't collide). It is built once and shared across every carrier, so the WebSocket and the
|
|
@@ -1843,6 +1883,14 @@ interface IServeChannelOptions<TO_ACCEPTOR extends readonly ActionDomain<any>[],
|
|
|
1843
1883
|
*
|
|
1844
1884
|
* Required only when at least one carrier is secure (the default). A fully-plain server (every carrier
|
|
1845
1885
|
* `secure: false`) needs no storage and may omit it.
|
|
1886
|
+
*
|
|
1887
|
+
* The secure HTTP exchange is stateless — its handshake + session ride sealed tokens, so it touches
|
|
1888
|
+
* this store only for the (read-mostly) identity, never per session. That lets a single secure-exchange
|
|
1889
|
+
* server (`carriers: [httpAcceptorCarrier()]`) run on a stateless Worker/Node backend with no Durable
|
|
1890
|
+
* Object. On a *strongly-consistent* store (DO storage, D1, Node memory) the default lazy identity is
|
|
1891
|
+
* fork-safe. On an *eventually-consistent* store (Cloudflare KV) pass an explicit {@link link} built
|
|
1892
|
+
* with `identityMode: "required"` and `provisionIdentity()` it once out-of-band, so a transient read
|
|
1893
|
+
* miss can never fork a second identity (which pinned clients would then permanently reject).
|
|
1846
1894
|
*/
|
|
1847
1895
|
storage?: StorageAdapter;
|
|
1848
1896
|
/**
|
|
@@ -2265,6 +2313,115 @@ declare const err_nice_transport: import("@nice-code/error").NiceErrorDomain<{
|
|
|
2265
2313
|
};
|
|
2266
2314
|
}>;
|
|
2267
2315
|
//#endregion
|
|
2316
|
+
//#region src/ActionRuntime/Transport/SecureSession/exchangeAcceptor.d.ts
|
|
2317
|
+
/** Acceptor secure config for the exchange (HTTP) endpoint — same identity an `AcceptorHandler` uses. */
|
|
2318
|
+
interface IExchangeAcceptorSecurity {
|
|
2319
|
+
/** This acceptor's crypto identity (verify + exchange key pairs, optionally persisted). */
|
|
2320
|
+
link: ClientCryptoKeyLink;
|
|
2321
|
+
/** This acceptor's coordinate — its identity to clients during the handshake. */
|
|
2322
|
+
localCoordinate: IRuntimeCoordinate;
|
|
2323
|
+
/** Wire dictionary version; the handshake rejects a client on a mismatch. */
|
|
2324
|
+
dictionaryVersion: string;
|
|
2325
|
+
/** Accepted level(s) — a single level is strict, an array is a negotiable allowed set. */
|
|
2326
|
+
securityLevel: ESecurityLevel | readonly ESecurityLevel[];
|
|
2327
|
+
/** Trust decision for a client's verify key (defaults to in-memory TOFU inside the handshake). */
|
|
2328
|
+
verifyKeyResolver?: IClientVerifyKeyResolver;
|
|
2329
|
+
}
|
|
2330
|
+
interface IExchangeAcceptorConfig {
|
|
2331
|
+
security: IExchangeAcceptorSecurity;
|
|
2332
|
+
/** The runtime that executes an inbound action wire and produces its result. */
|
|
2333
|
+
runtime: ActionRuntime;
|
|
2334
|
+
/**
|
|
2335
|
+
* How long a minted session ticket stays valid (ms). After it expires the client's next action is
|
|
2336
|
+
* rejected and it must re-handshake. Defaults to 12h — long enough for an ordinary session's life,
|
|
2337
|
+
* since a sealed ticket carries no server state to revoke before then. Keep it shorter for a more
|
|
2338
|
+
* tightly time-boxed session.
|
|
2339
|
+
*/
|
|
2340
|
+
sessionTtlMs?: number;
|
|
2341
|
+
}
|
|
2342
|
+
/**
|
|
2343
|
+
* Acceptor (accept-in) side of the secure exchange protocol — the HTTP counterpart to
|
|
2344
|
+
* {@link AcceptorSecureSession}. Each POST body is one {@link decodeExchangeRequest} envelope; the
|
|
2345
|
+
* acceptor drives the server handshake over the two `hs` POSTs, mints a session **token** on accept, and
|
|
2346
|
+
* on every later `act` POST resolves the session by token, decrypts the body (at `encrypted`), routes it
|
|
2347
|
+
* through the runtime, and returns the (encrypted) result inline as the reply.
|
|
2348
|
+
*
|
|
2349
|
+
* **Stateless.** It holds no in-memory handshakes or sessions: the in-flight handshake `pending` is
|
|
2350
|
+
* sealed into the `hsc` continuation token returned on `welcome` and echoed back on `prove`, and the live
|
|
2351
|
+
* session is sealed into the `t` token replayed on every `act`. Both are sealed under the acceptor's own
|
|
2352
|
+
* persisted identity ({@link createExchangeTicketSealer}), so any isolate that loaded the same identity
|
|
2353
|
+
* can serve any POST — no request needs to co-locate with another (no Durable Object required just to
|
|
2354
|
+
* pin a handshake to one instance). A tampered, wrong-key, or expired token opens to "no valid session".
|
|
2355
|
+
*/
|
|
2356
|
+
declare class ExchangeAcceptor {
|
|
2357
|
+
private readonly _security;
|
|
2358
|
+
private readonly _runtime;
|
|
2359
|
+
private readonly _allowedLevels;
|
|
2360
|
+
private readonly _noneAllowed;
|
|
2361
|
+
private readonly _sealer;
|
|
2362
|
+
private readonly _sessionTtlMs;
|
|
2363
|
+
constructor(config: IExchangeAcceptorConfig);
|
|
2364
|
+
/** Process one POST body (an exchange envelope), returning the reply body to send back. */
|
|
2365
|
+
handlePost(body: string): Promise<string>;
|
|
2366
|
+
private _makeHandshake;
|
|
2367
|
+
private _handleHandshake;
|
|
2368
|
+
private _handleAction;
|
|
2369
|
+
private _err;
|
|
2370
|
+
}
|
|
2371
|
+
//#endregion
|
|
2372
|
+
//#region src/ActionRuntime/Transport/SecureSession/exchangeProtocol.d.ts
|
|
2373
|
+
/**
|
|
2374
|
+
* The application-level envelope for secure action traffic over an {@link IExchangeCarrier} (HTTP). An
|
|
2375
|
+
* exchange carrier only moves one request frame → one reply frame with no unsolicited push, so the
|
|
2376
|
+
* handshake and the per-action token + crypto all ride in this envelope (a JSON string body) rather than
|
|
2377
|
+
* on a persistent channel. The three security levels share it:
|
|
2378
|
+
*
|
|
2379
|
+
* - `none` — no handshake, no token: an `act` envelope carries the plaintext wire both ways.
|
|
2380
|
+
* - `authenticated` — a one-time handshake yields a session `token`; each later `act` carries it +
|
|
2381
|
+
* the plaintext wire.
|
|
2382
|
+
* - `encrypted` — same, but the wire is AES-GCM ciphertext, base64 in the `c` field.
|
|
2383
|
+
*
|
|
2384
|
+
* The handshake runs as two `hs` exchanges (hello→welcome, prove→accept). The acceptor keeps **no**
|
|
2385
|
+
* in-flight state between them: the `welcome` reply carries a sealed handshake-continuation token `hsc`
|
|
2386
|
+
* (the acceptor's `pending` state, opaque to the client), which the connector echoes on the `prove`
|
|
2387
|
+
* request. The `accept` reply then carries the (sealed) session `t`oken replayed on every later `act`.
|
|
2388
|
+
* All server-side continuity rides these sealed tokens, so no request needs to co-locate with another.
|
|
2389
|
+
*/
|
|
2390
|
+
type TWireJson = TActionPayload_Any_JsonObject<any, any>;
|
|
2391
|
+
/** Connector → acceptor request envelope. */
|
|
2392
|
+
type TExchangeRequest = {
|
|
2393
|
+
k: "hs";
|
|
2394
|
+
m: string;
|
|
2395
|
+
hsc?: string;
|
|
2396
|
+
} | {
|
|
2397
|
+
k: "act";
|
|
2398
|
+
t?: string;
|
|
2399
|
+
w: TWireJson;
|
|
2400
|
+
} | {
|
|
2401
|
+
k: "act";
|
|
2402
|
+
t?: string;
|
|
2403
|
+
c: string;
|
|
2404
|
+
};
|
|
2405
|
+
/** Acceptor → connector reply envelope. */
|
|
2406
|
+
type TExchangeReply = {
|
|
2407
|
+
k: "hs";
|
|
2408
|
+
m: string;
|
|
2409
|
+
hsc?: string;
|
|
2410
|
+
t?: string;
|
|
2411
|
+
} | {
|
|
2412
|
+
k: "act";
|
|
2413
|
+
w: TWireJson;
|
|
2414
|
+
} | {
|
|
2415
|
+
k: "act";
|
|
2416
|
+
c: string;
|
|
2417
|
+
} | {
|
|
2418
|
+
k: "err";
|
|
2419
|
+
message: string;
|
|
2420
|
+
};
|
|
2421
|
+
declare function encodeExchange(envelope: TExchangeRequest | TExchangeReply): string;
|
|
2422
|
+
declare function decodeExchangeRequest(raw: string): TExchangeRequest | undefined;
|
|
2423
|
+
declare function decodeExchangeReply(raw: string): TExchangeReply | undefined;
|
|
2424
|
+
//#endregion
|
|
2268
2425
|
//#region src/errors/err_nice_action.d.ts
|
|
2269
2426
|
declare enum EErrId_NiceAction {
|
|
2270
2427
|
not_implemented = "not_implemented",
|
|
@@ -2646,11 +2803,13 @@ declare class ActionRuntime {
|
|
|
2646
2803
|
* Used to locate the return-path channel for dispatching results back to the action origin.
|
|
2647
2804
|
* Returns `undefined` if no handler matches (score > 0 required, i.e. at least id must match).
|
|
2648
2805
|
*
|
|
2649
|
-
* A handler that currently holds the origin's *live* connection always wins
|
|
2650
|
-
*
|
|
2651
|
-
*
|
|
2652
|
-
*
|
|
2653
|
-
*
|
|
2806
|
+
* A handler that currently holds the origin's *live* connection always wins, regardless of its
|
|
2807
|
+
* coordinate score — owning the live socket bound to the origin's exact coordinate (set from the
|
|
2808
|
+
* handshake) is a strictly more precise match than any env-level `peerClient` score. This lets one
|
|
2809
|
+
* server accept clients of *several* envs over a single acceptor (a multi-role Durable Object): the
|
|
2810
|
+
* result/push routes back over the carrier the client actually connected on even when the handler's
|
|
2811
|
+
* `clientEnv` is unset or names a different env. Only when no handler owns a live connection do we fall
|
|
2812
|
+
* back to the plain best-coordinate-score pick (the offline-return and connector-only cases).
|
|
2654
2813
|
*/
|
|
2655
2814
|
getReturnHandlerForOrigin(originClient: RuntimeCoordinate): PeerLinkHandler | undefined;
|
|
2656
2815
|
resetRuntime(): void;
|
|
@@ -2788,11 +2947,13 @@ interface IAcceptorSecurity {
|
|
|
2788
2947
|
}
|
|
2789
2948
|
interface IAcceptorHandlerBaseOptions<TConn> {
|
|
2790
2949
|
/**
|
|
2791
|
-
* Coordinate of the *connecting clients* (typically env-only, e.g. `RuntimeCoordinate.env("web_app")`)
|
|
2792
|
-
*
|
|
2793
|
-
*
|
|
2950
|
+
* Coordinate of the *connecting clients* (typically env-only, e.g. `RuntimeCoordinate.env("web_app")`),
|
|
2951
|
+
* scored against an action's `originClient` to pick this handler when *no* handler holds the client's
|
|
2952
|
+
* live connection (the offline-return fallback). A handler that currently owns the live socket always
|
|
2953
|
+
* wins regardless, so this is optional: omit it for a multi-role server that accepts several client envs
|
|
2954
|
+
* over one acceptor — it then defaults to `RuntimeCoordinate.unknown` (scores 0 against every client).
|
|
2794
2955
|
*/
|
|
2795
|
-
clientEnv
|
|
2956
|
+
clientEnv?: RuntimeCoordinate;
|
|
2796
2957
|
/** Write an encoded frame to a specific live connection (e.g. `(ws, frame) => ws.send(frame)`). */
|
|
2797
2958
|
send: (connection: TConn, frame: string | Uint8Array | ArrayBuffer) => void;
|
|
2798
2959
|
/**
|
|
@@ -2993,5 +3154,5 @@ declare class AcceptorHandler<TConn = unknown> extends PeerLinkHandler {
|
|
|
2993
3154
|
}
|
|
2994
3155
|
declare const createAcceptorHandler: <TConn = unknown>(options: IAcceptorHandlerOptions<TConn>) => AcceptorHandler<TConn>;
|
|
2995
3156
|
//#endregion
|
|
2996
|
-
export {
|
|
2997
|
-
//# sourceMappingURL=AcceptorHandler-
|
|
3157
|
+
export { httpAcceptorCarrier as $, createInMemoryTofuVerifyKeyResolver as $n, TCarrier as $t, TActionResultOutcome as A, TOnResolveIncomingResponseJson as An, IActionCore_JsonObject as Ar, IHibernatableWsServerAdapterOptions as At, decodeExchangeReply as B, Transport as Bn, TPossibleDomainIdList as Br, TChannelAcceptorCases as Bt, IActionProgress_Custom as C, IUpdateActionRunConfig_Output as Cn, IRuntimeCoordinate as Cr, serveChannel as Ct, TActionPayload_Any_Instance as D, TOnResolveIncomingRequest as Dn, TRuntimeCoordinateEnvId as Dr, TAcceptorCarrier as Dt, IActionRouteItemHandler as E, TOnResolveAnyIncomingActionData_Json as En, RuntimeCoordinate as Er, IExchangeAcceptorCarrier as Et, decodeActionFrame as F, TTransportStatusInfo as Fn, TActionDomainSchema as Fr, createConnectionStateStore as Ft, IExchangeAcceptorSecurity as G, IClientHandshakeConfig as Gn, TActionSchemaOptions as Gr, defineChannel as Gt, encodeExchange as H, createSecureAcceptorHandler as Hn, EActionResponseMode as Hr, acceptChannel as Ht, EErrId_NiceAction as I, TTransportStatusInfo_GetTransport_Output as In, TDomainActionId as Ir, IAcceptChannelOptions as It, IHttpCarrierOptions as J, IHandshakeEncryptionKeyMaterial as Jn, IActionWireFormat as Jt, EErrId_NiceTransport as K, IClientVerifyKeyResolveInput as Kn, TActionSerializationDefinition as Kr, IBinaryWireSessionOptions as Kt, err_nice_action as L, TUpdateActionRunConfig as Ln, TInferInputFromSchema as Lr, IActionChannel as Lt, isActionPayload_Request_JsonObject as M, TSendReturnDataMethod as Mn, IActionDomainChildOptions as Mr, ConnectionStateStore as Mt, isActionPayload_Any_JsonObject as N, TTransportCache as Nn, IActionRootDomain as Nr, IConnectionAttachment as Nt, TActionPayload_Any_JsonObject as O, TOnResolveIncomingRequestJson as On, TRuntimeCoordinateStringId as Or, isExchangeAcceptorCarrier as Ot, IActionFrameDecoder as P, TTransportInitializationFinishedInfo as Pn, TActionDomainChildDef as Pr, IConnectionStateStoreOptions as Pt, IHttpAcceptorCarrierOptions as Q, createClientHandshake as Qn, IExchangeCarrierSource as Qt, TExchangeReply as R, TransportConnection as Rn, TInferOutputFromSchema as Rr, IConnectChannelOptions as Rt, IActionPayload_Result_JsonObject as S, ITransportStatusInfo_Unsupported as Sn, ActionPayload_Progress as Sr, IServeConnectionStateOptions as St, IActionProgress_Percentage as T, TOnResolveAnyIncomingActionData as Tn, IRuntimeFullCoordinates as Tr, IDuplexAcceptorCarrier as Tt, ExchangeAcceptor as U, EHandshakeMessageType as Un, TInferActionError as Ur, acceptChannelConnections as Ut, decodeExchangeRequest as V, ISecureAcceptorHandlerOptions as Vn, ActionSchema as Vr, TChannelPushHandlers as Vt, IExchangeAcceptorConfig as W, ESecurityLevel as Wn, actionSchema as Wr, connectChannel as Wt, TCarrierFetch as X, IServerHandshakeConfig as Xn, IDuplexCarrierSource as Xt, IHttpCarrierRequest as Y, IHandshakeResult as Yn, IDuplexCarrier as Yt, httpCarrier as Z, THandshakeMessage as Zn, IExchangeCarrier as Zt, IActionPayload_Data_Base as _, ITransportRouteInfo as _n, IRunningActionUpdate_Success as _r, TServeHostOptions as _t, TAcceptorConnectionCaseFn as a, ETransportStatus as an, ActionLocalHandler as ar, err_nice_transport_ws as at, IActionPayload_Request_JsonObject as b, ITransportStatusInfo_Initializing as bn, TRunningActionUpdateListener as br, IConnectionContext as bt, createAcceptorHandler as c, IActionTransportReady as cn, createActionRootDomain as cr, IRtcDataChannelLike as ct, ActionCore as d, IActionTransportResolvers as dn, ERunningActionFinishedType as dr, inMemoryCarrier as dt, TFrame$1 as en, createServerHandshake as er, IWsCarrierOptions as et, ActionPayload_Request as f, ISecureClientConfig as fn, ERunningActionState as fr, IInMemoryChannelPair as ft, IActionPayload_Base_JsonObject as g, ITransportRouteClientParams as gn, IRunningActionUpdate_Started as gr, IChannelHostAdapter as gt, IActionPayload_Base as h, ITransportRouteActionParams as hn, IRunningActionUpdate_Progress as hr, err_nice_external_client as ht, TAcceptorCaseFn as i, ETransportShape as in, runtimeLinkId as ir, EErrId_NiceTransport_WebSocket as it, isActionPayload_Result_JsonObject as j, TSendActionDataMethod as jn, IActionDomain as jr, createHibernatableWsServerAdapter as jt, TActionProgress as k, TOnResolveIncomingResponse as kn, IActionCore as kr, IDuplexConnectionRouter as kt, ActionDomain as l, IActionTransportReadyData_Base as ln, ActionRootDomain as lr, rtcDataChannelByteChannel as lt, EActionProgressType as m, ITransportMethod_SendActionData_Input as mn, IRunningActionUpdate_Abort as mr, createInMemoryChannelPair as mt, IAcceptorConnectionBinding as n, createConnectorHandler as nn, decodeHandshakeMessage as nr, IWsAcceptorCarrierOptions as nt, TActionChannelFormatMessage as o, IActionTransportDef as on, createLocalHandler as or, IRtcCarrierOptions as ot, EActionPayloadType as p, ITransportDispatchAction as pn, ERunningActionUpdateType as pr, IInMemoryServerEndpoint as pt, err_nice_transport as q, IClientVerifyKeyResolver as qn, TTransportedValue as qr, createBinaryWireSessionFactory as qt, IAcceptorHandlerOptions as r, PeerLinkHandler as rn, encodeHandshakeMessage as rr, wsAcceptorCarrier as rt, TActionConnectionEncoding as s, IActionTransportInitialized as sn, MaybePromise as sr, rtcCarrier as st, AcceptorHandler as t, ConnectorHandler as tn, createStorageTofuVerifyKeyResolver as tr, wsCarrier as tt, ActionRuntime as u, IActionTransportReadyData_Methods as un, RunningAction as ur, IInMemoryCarrier as ut, IActionPayload_Progress as v, ITransportStatusInfo_Base as vn, TRunningActionUpdate as vr, serveHost as vt, IActionProgress_None as w, TGetTransportFn as wn, IRuntimeCoordinateSpecifics as wr, IAcceptorAttachmentStore as wt, IActionPayload_Result as x, ITransportStatusInfo_Ready as xn, ActionPayload_Result as xr, IServeChannelOptions as xt, IActionPayload_Progress_JsonObject as y, ITransportStatusInfo_Failed as yn, TRunningActionUpdateFinished as yr, IChannelServer as yt, TExchangeRequest as z, ITransportConnectionContext as zn, TPossibleDomainId as zr, IConnectTransport as zt };
|
|
3158
|
+
//# sourceMappingURL=AcceptorHandler-Du292dpC.d.cts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Cr as IRuntimeCoordinate, k as TActionProgress } from "./AcceptorHandler-CLbwu2Pa.mjs";
|
|
2
2
|
//#region ../nice-devtools-shared/src/components/PanelChrome.d.ts
|
|
3
3
|
/** Where a devtools panel is docked. */
|
|
4
4
|
type TDevtoolsPosition = "dock-bottom" | "dock-top" | "dock-left" | "dock-right";
|
|
@@ -76,4 +76,4 @@ declare class ActionDevtoolsCore {
|
|
|
76
76
|
}
|
|
77
77
|
//#endregion
|
|
78
78
|
export { TDevtoolsActionStatus as a, IDevtoolsObservableDomain as i, IActionDevtoolsCoreOptions as n, TDevtoolsListener as o, IDevtoolsActionEntry as r, TDevtoolsPosition as s, ActionDevtoolsCore as t };
|
|
79
|
-
//# sourceMappingURL=ActionDevtoolsCore-
|
|
79
|
+
//# sourceMappingURL=ActionDevtoolsCore-DGwzONZT.d.mts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Cr as IRuntimeCoordinate, k as TActionProgress } from "./AcceptorHandler-Du292dpC.cjs";
|
|
2
2
|
//#region ../nice-devtools-shared/src/components/PanelChrome.d.ts
|
|
3
3
|
/** Where a devtools panel is docked. */
|
|
4
4
|
type TDevtoolsPosition = "dock-bottom" | "dock-top" | "dock-left" | "dock-right";
|
|
@@ -76,4 +76,4 @@ declare class ActionDevtoolsCore {
|
|
|
76
76
|
}
|
|
77
77
|
//#endregion
|
|
78
78
|
export { TDevtoolsActionStatus as a, IDevtoolsObservableDomain as i, IActionDevtoolsCoreOptions as n, TDevtoolsListener as o, IDevtoolsActionEntry as r, TDevtoolsPosition as s, ActionDevtoolsCore as t };
|
|
79
|
-
//# sourceMappingURL=ActionDevtoolsCore-
|
|
79
|
+
//# sourceMappingURL=ActionDevtoolsCore-dH4K4w3B.d.cts.map
|
package/build/advanced/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_createHibernatableWsServerAdapter = require("../createHibernatableWsServerAdapter-
|
|
2
|
+
const require_createHibernatableWsServerAdapter = require("../createHibernatableWsServerAdapter-j96U9vgo.cjs");
|
|
3
3
|
let msgpackr = require("msgpackr");
|
|
4
4
|
//#region src/ActionRuntime/Transport/codec/createBinaryWireAdapter.ts
|
|
5
5
|
/**
|
|
@@ -1,52 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ClientCryptoKeyLink
|
|
1
|
+
import { An as TOnResolveIncomingResponseJson, At as IHibernatableWsServerAdapterOptions, B as decodeExchangeReply, Bn as Transport, Cn as IUpdateActionRunConfig_Output, Dn as TOnResolveIncomingRequest, En as TOnResolveAnyIncomingActionData_Json, Fn as TTransportStatusInfo, Ft as createConnectionStateStore, G as IExchangeAcceptorSecurity, Gn as IClientHandshakeConfig, H as encodeExchange, Hn as createSecureAcceptorHandler, In as TTransportStatusInfo_GetTransport_Output, Jn as IHandshakeEncryptionKeyMaterial, Jt as IActionWireFormat, Kt as IBinaryWireSessionOptions, Ln as TUpdateActionRunConfig, Mn as TSendReturnDataMethod, Mt as ConnectionStateStore, Nn as TTransportCache, Nt as IConnectionAttachment, On as TOnResolveIncomingRequestJson, Pn as TTransportInitializationFinishedInfo, Pt as IConnectionStateStoreOptions, Qn as createClientHandshake, R as TExchangeReply, Rn as TransportConnection, Sn as ITransportStatusInfo_Unsupported, Tn as TOnResolveAnyIncomingActionData, U as ExchangeAcceptor, Un as EHandshakeMessageType, V as decodeExchangeRequest, Vn as ISecureAcceptorHandlerOptions, W as IExchangeAcceptorConfig, Xn as IServerHandshakeConfig, Yn as IHandshakeResult, Yt as IDuplexCarrier, Zn as THandshakeMessage, Zt as IExchangeCarrier, _n as ITransportRouteInfo, a as TAcceptorConnectionCaseFn, an as ETransportStatus, bn as ITransportStatusInfo_Initializing, c as createAcceptorHandler, cn as IActionTransportReady, dn as IActionTransportResolvers, er as createServerHandshake, fn as ISecureClientConfig, gn as ITransportRouteClientParams, hn as ITransportRouteActionParams, i as TAcceptorCaseFn, in as ETransportShape, jn as TSendActionDataMethod, jt as createHibernatableWsServerAdapter, kn as TOnResolveIncomingResponse, kt as IDuplexConnectionRouter, l as ActionDomain, ln as IActionTransportReadyData_Base, mn as ITransportMethod_SendActionData_Input, n as IAcceptorConnectionBinding, nn as createConnectorHandler, nr as decodeHandshakeMessage, o as TActionChannelFormatMessage, on as IActionTransportDef, pn as ITransportDispatchAction, qt as createBinaryWireSessionFactory, r as IAcceptorHandlerOptions, rn as PeerLinkHandler, rr as encodeHandshakeMessage, s as TActionConnectionEncoding, sn as IActionTransportInitialized, t as AcceptorHandler, tn as ConnectorHandler, u as ActionRuntime, un as IActionTransportReadyData_Methods, vn as ITransportStatusInfo_Base, wn as TGetTransportFn, xn as ITransportStatusInfo_Ready, yn as ITransportStatusInfo_Failed, z as TExchangeRequest, zn as ITransportConnectionContext } from "../AcceptorHandler-Du292dpC.cjs";
|
|
2
|
+
import { ClientCryptoKeyLink } from "@nice-code/util";
|
|
3
3
|
|
|
4
|
-
//#region src/ActionRuntime/Transport/SecureSession/exchangeAcceptor.d.ts
|
|
5
|
-
/** Acceptor secure config for the exchange (HTTP) endpoint — same identity an `AcceptorHandler` uses. */
|
|
6
|
-
interface IExchangeAcceptorSecurity {
|
|
7
|
-
/** This acceptor's crypto identity (verify + exchange key pairs, optionally persisted). */
|
|
8
|
-
link: ClientCryptoKeyLink;
|
|
9
|
-
/** This acceptor's coordinate — its identity to clients during the handshake. */
|
|
10
|
-
localCoordinate: IRuntimeCoordinate;
|
|
11
|
-
/** Wire dictionary version; the handshake rejects a client on a mismatch. */
|
|
12
|
-
dictionaryVersion: string;
|
|
13
|
-
/** Accepted level(s) — a single level is strict, an array is a negotiable allowed set. */
|
|
14
|
-
securityLevel: ESecurityLevel | readonly ESecurityLevel[];
|
|
15
|
-
/** Trust decision for a client's verify key (defaults to in-memory TOFU inside the handshake). */
|
|
16
|
-
verifyKeyResolver?: IClientVerifyKeyResolver;
|
|
17
|
-
}
|
|
18
|
-
interface IExchangeAcceptorConfig {
|
|
19
|
-
security: IExchangeAcceptorSecurity;
|
|
20
|
-
/** The runtime that executes an inbound action wire and produces its result. */
|
|
21
|
-
runtime: ActionRuntime;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Acceptor (accept-in) side of the secure exchange protocol — the HTTP counterpart to
|
|
25
|
-
* {@link AcceptorSecureSession}. Each POST body is one {@link decodeExchangeRequest} envelope; the
|
|
26
|
-
* acceptor drives the server handshake over the two `hs` POSTs (correlated by `hsid`, since stateless
|
|
27
|
-
* requests can't rely on channel ordering), mints a session **token** on accept, and on every later `act`
|
|
28
|
-
* POST resolves the session by token, decrypts the body (at `encrypted`), routes it through the runtime,
|
|
29
|
-
* and returns the (encrypted) result inline as the reply.
|
|
30
|
-
*
|
|
31
|
-
* Sessions and in-flight handshakes are held in memory — fine for a single-instance server. (Surviving a
|
|
32
|
-
* Durable-Object eviction would persist each token's `keyMaterial` and re-derive the key on a miss, the
|
|
33
|
-
* same primitive `AcceptorSecureSession.rehydrate` uses; left as a follow-up.)
|
|
34
|
-
*/
|
|
35
|
-
declare class ExchangeAcceptor {
|
|
36
|
-
private readonly _security;
|
|
37
|
-
private readonly _runtime;
|
|
38
|
-
private readonly _allowedLevels;
|
|
39
|
-
private readonly _noneAllowed;
|
|
40
|
-
private readonly _pendingHandshakes;
|
|
41
|
-
private readonly _sessions;
|
|
42
|
-
constructor(config: IExchangeAcceptorConfig);
|
|
43
|
-
/** Process one POST body (an exchange envelope), returning the reply body to send back. */
|
|
44
|
-
handlePost(body: string): Promise<string>;
|
|
45
|
-
private _handleHandshake;
|
|
46
|
-
private _handleAction;
|
|
47
|
-
private _err;
|
|
48
|
-
}
|
|
49
|
-
//#endregion
|
|
50
4
|
//#region src/ActionRuntime/Handler/PeerLink/Acceptor/createActionFetchHandler.d.ts
|
|
51
5
|
interface IActionFetchHandlerOptions {
|
|
52
6
|
/**
|
|
@@ -145,16 +99,22 @@ interface IActionFrameCrypto {
|
|
|
145
99
|
}
|
|
146
100
|
interface IActionFrameCryptoConfig {
|
|
147
101
|
link: ClientCryptoKeyLink;
|
|
148
|
-
/**
|
|
149
|
-
|
|
102
|
+
/**
|
|
103
|
+
* This session's handshake key material. The shared AES-GCM key is derived from it **once** and held
|
|
104
|
+
* for the life of the connection — it is NOT re-read per frame from the link's per-`linkedClientId`
|
|
105
|
+
* cache, so a second secure session to the same peer (e.g. a secure HTTP exchange beside a secure
|
|
106
|
+
* WebSocket, both sharing one DO crypto identity) can't overwrite this connection's key.
|
|
107
|
+
*/
|
|
108
|
+
keyMaterial: IHandshakeEncryptionKeyMaterial;
|
|
150
109
|
}
|
|
151
110
|
/**
|
|
152
111
|
* Build the encrypt/decrypt transform for a connection whose handshake settled on the `encrypted`
|
|
153
|
-
* level.
|
|
112
|
+
* level. The shared key is derived once from {@link IActionFrameCryptoConfig.keyMaterial} and captured
|
|
113
|
+
* for this connection alone, decoupling it from the link's shared key cache.
|
|
154
114
|
*/
|
|
155
115
|
declare function createActionFrameCrypto({
|
|
156
116
|
link,
|
|
157
|
-
|
|
117
|
+
keyMaterial
|
|
158
118
|
}: IActionFrameCryptoConfig): IActionFrameCrypto;
|
|
159
119
|
//#endregion
|
|
160
120
|
//#region src/ActionRuntime/Transport/Exchange/TransportExchange.types.d.ts
|
|
@@ -291,54 +251,5 @@ declare class LinkTransport extends Transport<ETransportShape.duplex> {
|
|
|
291
251
|
getRouteInfo(input: ITransportRouteActionParams): ITransportRouteInfo;
|
|
292
252
|
}
|
|
293
253
|
//#endregion
|
|
294
|
-
//#region src/ActionRuntime/Transport/SecureSession/exchangeProtocol.d.ts
|
|
295
|
-
/**
|
|
296
|
-
* The application-level envelope for secure action traffic over an {@link IExchangeCarrier} (HTTP). An
|
|
297
|
-
* exchange carrier only moves one request frame → one reply frame with no unsolicited push, so the
|
|
298
|
-
* handshake and the per-action token + crypto all ride in this envelope (a JSON string body) rather than
|
|
299
|
-
* on a persistent channel. The three security levels share it:
|
|
300
|
-
*
|
|
301
|
-
* - `none` — no handshake, no token: an `act` envelope carries the plaintext wire both ways.
|
|
302
|
-
* - `authenticated` — a one-time handshake yields a session `token`; each later `act` carries it +
|
|
303
|
-
* the plaintext wire.
|
|
304
|
-
* - `encrypted` — same, but the wire is AES-GCM ciphertext, base64 in the `c` field.
|
|
305
|
-
*
|
|
306
|
-
* The handshake runs as two `hs` exchanges (hello→welcome, prove→accept) correlated by a client-chosen
|
|
307
|
-
* `hsid`, since stateless requests can't rely on channel ordering. The `accept` reply carries the token.
|
|
308
|
-
*/
|
|
309
|
-
type TWireJson = TActionPayload_Any_JsonObject<any, any>;
|
|
310
|
-
/** Connector → acceptor request envelope. */
|
|
311
|
-
type TExchangeRequest = {
|
|
312
|
-
k: "hs";
|
|
313
|
-
hsid: string;
|
|
314
|
-
m: string;
|
|
315
|
-
} | {
|
|
316
|
-
k: "act";
|
|
317
|
-
t?: string;
|
|
318
|
-
w: TWireJson;
|
|
319
|
-
} | {
|
|
320
|
-
k: "act";
|
|
321
|
-
t?: string;
|
|
322
|
-
c: string;
|
|
323
|
-
};
|
|
324
|
-
/** Acceptor → connector reply envelope. */
|
|
325
|
-
type TExchangeReply = {
|
|
326
|
-
k: "hs";
|
|
327
|
-
m: string;
|
|
328
|
-
t?: string;
|
|
329
|
-
} | {
|
|
330
|
-
k: "act";
|
|
331
|
-
w: TWireJson;
|
|
332
|
-
} | {
|
|
333
|
-
k: "act";
|
|
334
|
-
c: string;
|
|
335
|
-
} | {
|
|
336
|
-
k: "err";
|
|
337
|
-
message: string;
|
|
338
|
-
};
|
|
339
|
-
declare function encodeExchange(envelope: TExchangeRequest | TExchangeReply): string;
|
|
340
|
-
declare function decodeExchangeRequest(raw: string): TExchangeRequest | undefined;
|
|
341
|
-
declare function decodeExchangeReply(raw: string): TExchangeReply | undefined;
|
|
342
|
-
//#endregion
|
|
343
254
|
export { AcceptorHandler, ConnectionStateStore, ConnectorHandler, EHandshakeMessageType, ETransportShape, ETransportStatus, ExchangeAcceptor, ExchangeTransport, type IAcceptorConnectionBinding, type IAcceptorHandlerOptions, type IActionFetchHandlerOptions, type IActionFrameCrypto, type IActionFrameCryptoConfig, IActionTransportDef, IActionTransportInitialized, IActionTransportReady, IActionTransportReadyData_Base, type IActionTransportReadyData_Exchange, type IActionTransportReadyData_Link, IActionTransportReadyData_Methods, IActionTransportResolvers, type IActionWireFormat, type IBinaryWireSessionOptions, type IClientHandshakeConfig, type IConnectionAttachment, type IConnectionStateStoreOptions, type IDuplexConnectionRouter, type IExchangeAcceptorConfig, type IExchangeAcceptorSecurity, type IExchangeTransportOptions, type IHandshakeEncryptionKeyMaterial, type IHandshakeResult, type IHibernatableWsServerAdapterOptions, type ILinkTransportOptions, type ISecureAcceptorHandlerOptions, ISecureClientConfig, type IServerHandshakeConfig, type ITransportConnectionContext, ITransportDispatchAction, ITransportMethod_SendActionData_Input, ITransportRouteActionParams, ITransportRouteClientParams, ITransportRouteInfo, ITransportStatusInfo_Base, ITransportStatusInfo_Failed, ITransportStatusInfo_Initializing, ITransportStatusInfo_Ready, ITransportStatusInfo_Unsupported, IUpdateActionRunConfig_Output, LinkTransport, PeerLinkHandler, type TAcceptorCaseFn, type TAcceptorConnectionCaseFn, type TActionChannelFormatMessage, type TActionConnectionEncoding, type TExchangeReply, type TExchangeRequest, TGetTransportFn, type THandshakeMessage, type TLinkFormatMessage, TOnResolveAnyIncomingActionData, TOnResolveAnyIncomingActionData_Json, TOnResolveIncomingRequest, TOnResolveIncomingRequestJson, TOnResolveIncomingResponse, TOnResolveIncomingResponseJson, TSendActionDataMethod, TSendReturnDataMethod, TTransportCache, TTransportInitializationFinishedInfo, TTransportStatusInfo, TTransportStatusInfo_GetTransport_Output, TUpdateActionRunConfig, Transport, createAcceptorHandler, createActionFetchHandler, createActionFrameCrypto, createBinaryWireAdapter, createBinaryWireSessionFactory, createClientHandshake, createConnectionStateStore, createConnectorHandler, createHibernatableWsServerAdapter, createSecureAcceptorHandler, createServerHandshake, decodeExchangeReply, decodeExchangeRequest, decodeHandshakeMessage, encodeExchange, encodeHandshakeMessage };
|
|
344
255
|
//# sourceMappingURL=index.d.cts.map
|
|
@@ -1,52 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ClientCryptoKeyLink
|
|
1
|
+
import { An as TOnResolveIncomingResponseJson, At as IHibernatableWsServerAdapterOptions, B as decodeExchangeReply, Bn as Transport, Cn as IUpdateActionRunConfig_Output, Dn as TOnResolveIncomingRequest, En as TOnResolveAnyIncomingActionData_Json, Fn as TTransportStatusInfo, Ft as createConnectionStateStore, G as IExchangeAcceptorSecurity, Gn as IClientHandshakeConfig, H as encodeExchange, Hn as createSecureAcceptorHandler, In as TTransportStatusInfo_GetTransport_Output, Jn as IHandshakeEncryptionKeyMaterial, Jt as IActionWireFormat, Kt as IBinaryWireSessionOptions, Ln as TUpdateActionRunConfig, Mn as TSendReturnDataMethod, Mt as ConnectionStateStore, Nn as TTransportCache, Nt as IConnectionAttachment, On as TOnResolveIncomingRequestJson, Pn as TTransportInitializationFinishedInfo, Pt as IConnectionStateStoreOptions, Qn as createClientHandshake, R as TExchangeReply, Rn as TransportConnection, Sn as ITransportStatusInfo_Unsupported, Tn as TOnResolveAnyIncomingActionData, U as ExchangeAcceptor, Un as EHandshakeMessageType, V as decodeExchangeRequest, Vn as ISecureAcceptorHandlerOptions, W as IExchangeAcceptorConfig, Xn as IServerHandshakeConfig, Yn as IHandshakeResult, Yt as IDuplexCarrier, Zn as THandshakeMessage, Zt as IExchangeCarrier, _n as ITransportRouteInfo, a as TAcceptorConnectionCaseFn, an as ETransportStatus, bn as ITransportStatusInfo_Initializing, c as createAcceptorHandler, cn as IActionTransportReady, dn as IActionTransportResolvers, er as createServerHandshake, fn as ISecureClientConfig, gn as ITransportRouteClientParams, hn as ITransportRouteActionParams, i as TAcceptorCaseFn, in as ETransportShape, jn as TSendActionDataMethod, jt as createHibernatableWsServerAdapter, kn as TOnResolveIncomingResponse, kt as IDuplexConnectionRouter, l as ActionDomain, ln as IActionTransportReadyData_Base, mn as ITransportMethod_SendActionData_Input, n as IAcceptorConnectionBinding, nn as createConnectorHandler, nr as decodeHandshakeMessage, o as TActionChannelFormatMessage, on as IActionTransportDef, pn as ITransportDispatchAction, qt as createBinaryWireSessionFactory, r as IAcceptorHandlerOptions, rn as PeerLinkHandler, rr as encodeHandshakeMessage, s as TActionConnectionEncoding, sn as IActionTransportInitialized, t as AcceptorHandler, tn as ConnectorHandler, u as ActionRuntime, un as IActionTransportReadyData_Methods, vn as ITransportStatusInfo_Base, wn as TGetTransportFn, xn as ITransportStatusInfo_Ready, yn as ITransportStatusInfo_Failed, z as TExchangeRequest, zn as ITransportConnectionContext } from "../AcceptorHandler-CLbwu2Pa.mjs";
|
|
2
|
+
import { ClientCryptoKeyLink } from "@nice-code/util";
|
|
3
3
|
|
|
4
|
-
//#region src/ActionRuntime/Transport/SecureSession/exchangeAcceptor.d.ts
|
|
5
|
-
/** Acceptor secure config for the exchange (HTTP) endpoint — same identity an `AcceptorHandler` uses. */
|
|
6
|
-
interface IExchangeAcceptorSecurity {
|
|
7
|
-
/** This acceptor's crypto identity (verify + exchange key pairs, optionally persisted). */
|
|
8
|
-
link: ClientCryptoKeyLink;
|
|
9
|
-
/** This acceptor's coordinate — its identity to clients during the handshake. */
|
|
10
|
-
localCoordinate: IRuntimeCoordinate;
|
|
11
|
-
/** Wire dictionary version; the handshake rejects a client on a mismatch. */
|
|
12
|
-
dictionaryVersion: string;
|
|
13
|
-
/** Accepted level(s) — a single level is strict, an array is a negotiable allowed set. */
|
|
14
|
-
securityLevel: ESecurityLevel | readonly ESecurityLevel[];
|
|
15
|
-
/** Trust decision for a client's verify key (defaults to in-memory TOFU inside the handshake). */
|
|
16
|
-
verifyKeyResolver?: IClientVerifyKeyResolver;
|
|
17
|
-
}
|
|
18
|
-
interface IExchangeAcceptorConfig {
|
|
19
|
-
security: IExchangeAcceptorSecurity;
|
|
20
|
-
/** The runtime that executes an inbound action wire and produces its result. */
|
|
21
|
-
runtime: ActionRuntime;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Acceptor (accept-in) side of the secure exchange protocol — the HTTP counterpart to
|
|
25
|
-
* {@link AcceptorSecureSession}. Each POST body is one {@link decodeExchangeRequest} envelope; the
|
|
26
|
-
* acceptor drives the server handshake over the two `hs` POSTs (correlated by `hsid`, since stateless
|
|
27
|
-
* requests can't rely on channel ordering), mints a session **token** on accept, and on every later `act`
|
|
28
|
-
* POST resolves the session by token, decrypts the body (at `encrypted`), routes it through the runtime,
|
|
29
|
-
* and returns the (encrypted) result inline as the reply.
|
|
30
|
-
*
|
|
31
|
-
* Sessions and in-flight handshakes are held in memory — fine for a single-instance server. (Surviving a
|
|
32
|
-
* Durable-Object eviction would persist each token's `keyMaterial` and re-derive the key on a miss, the
|
|
33
|
-
* same primitive `AcceptorSecureSession.rehydrate` uses; left as a follow-up.)
|
|
34
|
-
*/
|
|
35
|
-
declare class ExchangeAcceptor {
|
|
36
|
-
private readonly _security;
|
|
37
|
-
private readonly _runtime;
|
|
38
|
-
private readonly _allowedLevels;
|
|
39
|
-
private readonly _noneAllowed;
|
|
40
|
-
private readonly _pendingHandshakes;
|
|
41
|
-
private readonly _sessions;
|
|
42
|
-
constructor(config: IExchangeAcceptorConfig);
|
|
43
|
-
/** Process one POST body (an exchange envelope), returning the reply body to send back. */
|
|
44
|
-
handlePost(body: string): Promise<string>;
|
|
45
|
-
private _handleHandshake;
|
|
46
|
-
private _handleAction;
|
|
47
|
-
private _err;
|
|
48
|
-
}
|
|
49
|
-
//#endregion
|
|
50
4
|
//#region src/ActionRuntime/Handler/PeerLink/Acceptor/createActionFetchHandler.d.ts
|
|
51
5
|
interface IActionFetchHandlerOptions {
|
|
52
6
|
/**
|
|
@@ -145,16 +99,22 @@ interface IActionFrameCrypto {
|
|
|
145
99
|
}
|
|
146
100
|
interface IActionFrameCryptoConfig {
|
|
147
101
|
link: ClientCryptoKeyLink;
|
|
148
|
-
/**
|
|
149
|
-
|
|
102
|
+
/**
|
|
103
|
+
* This session's handshake key material. The shared AES-GCM key is derived from it **once** and held
|
|
104
|
+
* for the life of the connection — it is NOT re-read per frame from the link's per-`linkedClientId`
|
|
105
|
+
* cache, so a second secure session to the same peer (e.g. a secure HTTP exchange beside a secure
|
|
106
|
+
* WebSocket, both sharing one DO crypto identity) can't overwrite this connection's key.
|
|
107
|
+
*/
|
|
108
|
+
keyMaterial: IHandshakeEncryptionKeyMaterial;
|
|
150
109
|
}
|
|
151
110
|
/**
|
|
152
111
|
* Build the encrypt/decrypt transform for a connection whose handshake settled on the `encrypted`
|
|
153
|
-
* level.
|
|
112
|
+
* level. The shared key is derived once from {@link IActionFrameCryptoConfig.keyMaterial} and captured
|
|
113
|
+
* for this connection alone, decoupling it from the link's shared key cache.
|
|
154
114
|
*/
|
|
155
115
|
declare function createActionFrameCrypto({
|
|
156
116
|
link,
|
|
157
|
-
|
|
117
|
+
keyMaterial
|
|
158
118
|
}: IActionFrameCryptoConfig): IActionFrameCrypto;
|
|
159
119
|
//#endregion
|
|
160
120
|
//#region src/ActionRuntime/Transport/Exchange/TransportExchange.types.d.ts
|
|
@@ -291,54 +251,5 @@ declare class LinkTransport extends Transport<ETransportShape.duplex> {
|
|
|
291
251
|
getRouteInfo(input: ITransportRouteActionParams): ITransportRouteInfo;
|
|
292
252
|
}
|
|
293
253
|
//#endregion
|
|
294
|
-
//#region src/ActionRuntime/Transport/SecureSession/exchangeProtocol.d.ts
|
|
295
|
-
/**
|
|
296
|
-
* The application-level envelope for secure action traffic over an {@link IExchangeCarrier} (HTTP). An
|
|
297
|
-
* exchange carrier only moves one request frame → one reply frame with no unsolicited push, so the
|
|
298
|
-
* handshake and the per-action token + crypto all ride in this envelope (a JSON string body) rather than
|
|
299
|
-
* on a persistent channel. The three security levels share it:
|
|
300
|
-
*
|
|
301
|
-
* - `none` — no handshake, no token: an `act` envelope carries the plaintext wire both ways.
|
|
302
|
-
* - `authenticated` — a one-time handshake yields a session `token`; each later `act` carries it +
|
|
303
|
-
* the plaintext wire.
|
|
304
|
-
* - `encrypted` — same, but the wire is AES-GCM ciphertext, base64 in the `c` field.
|
|
305
|
-
*
|
|
306
|
-
* The handshake runs as two `hs` exchanges (hello→welcome, prove→accept) correlated by a client-chosen
|
|
307
|
-
* `hsid`, since stateless requests can't rely on channel ordering. The `accept` reply carries the token.
|
|
308
|
-
*/
|
|
309
|
-
type TWireJson = TActionPayload_Any_JsonObject<any, any>;
|
|
310
|
-
/** Connector → acceptor request envelope. */
|
|
311
|
-
type TExchangeRequest = {
|
|
312
|
-
k: "hs";
|
|
313
|
-
hsid: string;
|
|
314
|
-
m: string;
|
|
315
|
-
} | {
|
|
316
|
-
k: "act";
|
|
317
|
-
t?: string;
|
|
318
|
-
w: TWireJson;
|
|
319
|
-
} | {
|
|
320
|
-
k: "act";
|
|
321
|
-
t?: string;
|
|
322
|
-
c: string;
|
|
323
|
-
};
|
|
324
|
-
/** Acceptor → connector reply envelope. */
|
|
325
|
-
type TExchangeReply = {
|
|
326
|
-
k: "hs";
|
|
327
|
-
m: string;
|
|
328
|
-
t?: string;
|
|
329
|
-
} | {
|
|
330
|
-
k: "act";
|
|
331
|
-
w: TWireJson;
|
|
332
|
-
} | {
|
|
333
|
-
k: "act";
|
|
334
|
-
c: string;
|
|
335
|
-
} | {
|
|
336
|
-
k: "err";
|
|
337
|
-
message: string;
|
|
338
|
-
};
|
|
339
|
-
declare function encodeExchange(envelope: TExchangeRequest | TExchangeReply): string;
|
|
340
|
-
declare function decodeExchangeRequest(raw: string): TExchangeRequest | undefined;
|
|
341
|
-
declare function decodeExchangeReply(raw: string): TExchangeReply | undefined;
|
|
342
|
-
//#endregion
|
|
343
254
|
export { AcceptorHandler, ConnectionStateStore, ConnectorHandler, EHandshakeMessageType, ETransportShape, ETransportStatus, ExchangeAcceptor, ExchangeTransport, type IAcceptorConnectionBinding, type IAcceptorHandlerOptions, type IActionFetchHandlerOptions, type IActionFrameCrypto, type IActionFrameCryptoConfig, IActionTransportDef, IActionTransportInitialized, IActionTransportReady, IActionTransportReadyData_Base, type IActionTransportReadyData_Exchange, type IActionTransportReadyData_Link, IActionTransportReadyData_Methods, IActionTransportResolvers, type IActionWireFormat, type IBinaryWireSessionOptions, type IClientHandshakeConfig, type IConnectionAttachment, type IConnectionStateStoreOptions, type IDuplexConnectionRouter, type IExchangeAcceptorConfig, type IExchangeAcceptorSecurity, type IExchangeTransportOptions, type IHandshakeEncryptionKeyMaterial, type IHandshakeResult, type IHibernatableWsServerAdapterOptions, type ILinkTransportOptions, type ISecureAcceptorHandlerOptions, ISecureClientConfig, type IServerHandshakeConfig, type ITransportConnectionContext, ITransportDispatchAction, ITransportMethod_SendActionData_Input, ITransportRouteActionParams, ITransportRouteClientParams, ITransportRouteInfo, ITransportStatusInfo_Base, ITransportStatusInfo_Failed, ITransportStatusInfo_Initializing, ITransportStatusInfo_Ready, ITransportStatusInfo_Unsupported, IUpdateActionRunConfig_Output, LinkTransport, PeerLinkHandler, type TAcceptorCaseFn, type TAcceptorConnectionCaseFn, type TActionChannelFormatMessage, type TActionConnectionEncoding, type TExchangeReply, type TExchangeRequest, TGetTransportFn, type THandshakeMessage, type TLinkFormatMessage, TOnResolveAnyIncomingActionData, TOnResolveAnyIncomingActionData_Json, TOnResolveIncomingRequest, TOnResolveIncomingRequestJson, TOnResolveIncomingResponse, TOnResolveIncomingResponseJson, TSendActionDataMethod, TSendReturnDataMethod, TTransportCache, TTransportInitializationFinishedInfo, TTransportStatusInfo, TTransportStatusInfo_GetTransport_Output, TUpdateActionRunConfig, Transport, createAcceptorHandler, createActionFetchHandler, createActionFrameCrypto, createBinaryWireAdapter, createBinaryWireSessionFactory, createClientHandshake, createConnectionStateStore, createConnectorHandler, createHibernatableWsServerAdapter, createSecureAcceptorHandler, createServerHandshake, decodeExchangeReply, decodeExchangeRequest, decodeHandshakeMessage, encodeExchange, encodeHandshakeMessage };
|
|
344
255
|
//# sourceMappingURL=index.d.mts.map
|