devframe 1.3.2 → 1.3.3
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/{_shared-CnKu5myY.d.mts → _shared-BxeuukaL.d.mts} +2 -2
- package/dist/{_shared-BGb9aDxr.mjs → _shared-CtXCQFTV.mjs} +1 -1
- package/dist/adapters/build.d.mts +1 -1
- package/dist/adapters/cac.d.mts +1 -1
- package/dist/adapters/cac.mjs +2 -2
- package/dist/adapters/dev.d.mts +4 -4
- package/dist/adapters/dev.mjs +2 -2
- package/dist/adapters/embedded.d.mts +1 -1
- package/dist/adapters/initiate.d.mts +4 -4
- package/dist/adapters/initiate.mjs +1 -1
- package/dist/adapters/mcp.d.mts +2 -2
- package/dist/{agentic-CCstJ5yv.d.mts → agentic-DVgUzwhV.d.mts} +1 -1
- package/dist/client/index.d.mts +5 -5
- package/dist/{context-CsdPs3po.d.mts → context-B-AARy_U.d.mts} +1 -1
- package/dist/{dev-DaHYh5YK.mjs → dev-Cu_iwSCy.mjs} +2 -2
- package/dist/{dist-DJydMELP.mjs → dist-CZ-TySHD.mjs} +1 -2
- package/dist/in-page-channel/index.d.mts +3 -2
- package/dist/{context-WxTq6kqb.d.mts → index-BhUqJUHG.d.mts} +1404 -1404
- package/dist/index.d.mts +5 -4
- package/dist/{instance-registry-CmZfF5u3.mjs → instance-registry-DwmnWyCK.mjs} +1 -1
- package/dist/{instance-shell-Dk2SejFT.mjs → instance-shell-Coid7CP6.mjs} +4 -4
- package/dist/{instance-shell-Bujp0BhE.d.mts → instance-shell-DTk514M9.d.mts} +4 -4
- package/dist/internal/index.d.mts +7 -7
- package/dist/internal/index.mjs +4 -4
- package/dist/{mcp-content-CQQBt2An.d.mts → mcp-content-0a0mpCL5.d.mts} +1 -1
- package/dist/node/auth.d.mts +84 -3
- package/dist/node/hub-internals.d.mts +11 -2
- package/dist/node/hub-internals.mjs +1 -1
- package/dist/node/index.d.mts +4 -2
- package/dist/recipes/interactive-auth.d.mts +2 -2
- package/dist/{rolldown-runtime-DYf_mQCB.mjs → rolldown-runtime-BVN1G_yT.mjs} +4 -4
- package/dist/rpc/dump.d.mts +1 -1
- package/dist/rpc/index.d.mts +121 -3
- package/dist/rpc/transports/sse-client.d.mts +34 -2
- package/dist/rpc/transports/sse-server.d.mts +2 -2
- package/dist/rpc/transports/ws-bun.d.mts +2 -2
- package/dist/rpc/transports/ws-client.d.mts +27 -2
- package/dist/rpc/transports/ws-deno.d.mts +2 -2
- package/dist/rpc/transports/ws-server.d.mts +150 -3
- package/dist/{rpc-core-CDUizUQB.mjs → rpc-core-BmDHiDR6.mjs} +1 -1
- package/dist/{rpc-core-CFwyV10r.d.mts → rpc-core-CblgPYJ_.d.mts} +3 -3
- package/dist/types/index.d.mts +3 -3
- package/dist/{types-844OBepb.d.mts → types-KZOyhez5.d.mts} +1 -0
- package/dist/utils/debounce.d.mts +6 -0
- package/dist/utils/events.d.mts +1 -1
- package/dist/utils/get-port.mjs +1 -1
- package/dist/utils/launch-editor.mjs +1 -1
- package/dist/utils/nostics.d.mts +40 -2
- package/dist/utils/origin.d.mts +55 -2
- package/dist/utils/serve-static.d.mts +1 -1
- package/dist/utils/shared-state.d.mts +1 -1
- package/dist/utils/streaming-channel.d.mts +1 -1
- package/package.json +5 -5
- package/dist/index-D0qrBkhO.d.mts +0 -121
- package/dist/index-HMJPlexc.d.mts +0 -84
- package/dist/nostics-Dgwh7ytT.d.mts +0 -40
- package/dist/origin-D5i7K_Zb.d.mts +0 -56
- package/dist/sse-client-B2PrSz-H.d.mts +0 -35
- package/dist/ws-client-lqOeANcn.d.mts +0 -28
- package/dist/ws-server-CYHkeyA-.d.mts +0 -150
|
@@ -1,4 +1,151 @@
|
|
|
1
|
+
import { a as ChannelOptions, n as BirpcGroup } from "../../index-BKu9BxcT.mjs";
|
|
2
|
+
import { g as RpcFunctionDefinitionAny } from "../../types-KZOyhez5.mjs";
|
|
1
3
|
import { a as DevframeWsPeer, i as DevframeRpcTransportKind, n as DevframeRpcConnection, r as DevframeRpcConnectionRequest, t as DevframeNodeRpcSessionMeta } from "../../session-Y9R6tqg4.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
4
|
+
import { isAllowedOrigin, isLoopbackHostname } from "../../utils/origin.mjs";
|
|
5
|
+
import { Hooks } from "crossws";
|
|
6
|
+
import { NodeAdapter } from "crossws/adapters/node";
|
|
7
|
+
import { Buffer } from "node:buffer";
|
|
8
|
+
import { IncomingMessage, Server } from "node:http";
|
|
9
|
+
import { Server as Server$1, ServerOptions } from "node:https";
|
|
10
|
+
import { AddressInfo } from "node:net";
|
|
11
|
+
import { Duplex } from "node:stream";
|
|
12
|
+
export interface WsRpcTransportOptions {
|
|
13
|
+
/**
|
|
14
|
+
* Attach to an existing HTTP(S) server, sharing its port. Combine with
|
|
15
|
+
* `path` to bind the WS endpoint to a single route so it coexists with
|
|
16
|
+
* other upgrade handlers on the same server (e.g. a Vite dev server's HMR
|
|
17
|
+
* socket). The shared server's lifecycle is owned by the caller; closing
|
|
18
|
+
* this transport detaches the upgrade listener without closing the server.
|
|
19
|
+
*/
|
|
20
|
+
server?: Server | Server$1;
|
|
21
|
+
/**
|
|
22
|
+
* Port for the standalone WebSocket server. Defaults to `0`, which lets the
|
|
23
|
+
* operating system assign an available port.
|
|
24
|
+
*/
|
|
25
|
+
port?: number;
|
|
26
|
+
/** Host for the standalone WebSocket server. Defaults to `localhost`. */
|
|
27
|
+
host?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Restrict the WS endpoint to a single upgrade route (e.g. `/__ws`). When
|
|
30
|
+
* sharing a `server`, non-matching upgrade requests are left untouched for
|
|
31
|
+
* other listeners to handle, so devframe's socket can sit alongside
|
|
32
|
+
* framework sockets (Vite HMR, etc.).
|
|
33
|
+
*/
|
|
34
|
+
path?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Create the adapter without binding it to anything: no server is created,
|
|
37
|
+
* no port is bound, no `upgrade` listener is installed. The caller drives
|
|
38
|
+
* the socket itself through {@link WsRpcTransport.handleUpgrade} (from its
|
|
39
|
+
* own `upgrade` listener) or {@link WsRpcTransport.attach} (to bind a
|
|
40
|
+
* server later). Takes precedence over `server` / `port` / `https`.
|
|
41
|
+
*/
|
|
42
|
+
unbound?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Destroy upgrade requests that don't match `path` instead of leaving them
|
|
45
|
+
* for other listeners. Enable this when devframe owns the shared server
|
|
46
|
+
* outright (nothing else handles its upgrades), so an off-route client is
|
|
47
|
+
* rejected promptly rather than left hanging. Default: `false`
|
|
48
|
+
* (coexist-friendly); servers this transport creates itself always
|
|
49
|
+
* destroy unmatched upgrades.
|
|
50
|
+
*/
|
|
51
|
+
destroyUnmatched?: boolean;
|
|
52
|
+
/** When set, a new https.Server is created and the WS endpoint is attached to it. */
|
|
53
|
+
https?: ServerOptions;
|
|
54
|
+
/**
|
|
55
|
+
* Extra origins to accept on the WS upgrade beyond the loopback default.
|
|
56
|
+
* Add your LAN/tunnel origin here when reaching the tool from another host.
|
|
57
|
+
* Pass `false` to disable origin checking entirely (not recommended).
|
|
58
|
+
* Default: loopback-only.
|
|
59
|
+
*/
|
|
60
|
+
allowedOrigins?: readonly string[] | WsOriginRegistry | false;
|
|
61
|
+
/**
|
|
62
|
+
* RPC function definitions, used by the per-call wire serializer to
|
|
63
|
+
* dispatch between strict-JSON and structured-clone encoding based
|
|
64
|
+
* on each function's `jsonSerializable` flag.
|
|
65
|
+
*
|
|
66
|
+
* When omitted, all messages fall back to structured-clone: safe but
|
|
67
|
+
* loses dev-time validation for `jsonSerializable: true` declarations.
|
|
68
|
+
*/
|
|
69
|
+
definitions?: ReadonlyMap<string, Pick<RpcFunctionDefinitionAny, 'jsonSerializable'>>;
|
|
70
|
+
onConnected?: (connection: DevframeRpcConnection, meta: DevframeNodeRpcSessionMeta) => void;
|
|
71
|
+
onDisconnected?: (connection: DevframeRpcConnection, meta: DevframeNodeRpcSessionMeta) => void;
|
|
72
|
+
/** Override the default per-call serializer. Most callers should leave this unset. */
|
|
73
|
+
serialize?: ChannelOptions['serialize'];
|
|
74
|
+
/** Override the default per-call deserializer. Most callers should leave this unset. */
|
|
75
|
+
deserialize?: ChannelOptions['deserialize'];
|
|
76
|
+
}
|
|
77
|
+
export interface CreateWsOriginRegistryOptions {
|
|
78
|
+
/** Origins allowed before any external viewers are registered. */
|
|
79
|
+
allowedOrigins?: readonly string[];
|
|
80
|
+
/** Additional validation to run after the registration token is verified. */
|
|
81
|
+
validateOrigin?: (origin: string) => boolean;
|
|
82
|
+
}
|
|
83
|
+
export interface WsOriginRegistry {
|
|
84
|
+
/** Registration token to include in connection metadata. */
|
|
85
|
+
readonly token: string;
|
|
86
|
+
/** Read and register an origin from a connection bootstrap URL. */
|
|
87
|
+
registerFromUrl: (url: string) => string | undefined;
|
|
88
|
+
/** Check whether an origin is currently allowed. */
|
|
89
|
+
isAllowed: (origin: string | undefined) => boolean;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Create a live, token-protected origin allowlist for external browser
|
|
93
|
+
* viewers. Pass it to {@link WsRpcTransportOptions.allowedOrigins}, then use
|
|
94
|
+
* `registerFromUrl()` in the connection metadata handler to authorize a
|
|
95
|
+
* viewer without sharing a mutable array or disabling DNS-rebinding protection.
|
|
96
|
+
*/
|
|
97
|
+
export declare function createWsOriginRegistry(options?: CreateWsOriginRegistryOptions): WsOriginRegistry;
|
|
98
|
+
export interface WsRpcTransport {
|
|
99
|
+
/**
|
|
100
|
+
* The crossws node adapter driving the socket; exposes the connected
|
|
101
|
+
* `peers` and pub/sub. See https://crossws.h3.dev.
|
|
102
|
+
*/
|
|
103
|
+
ws: NodeAdapter;
|
|
104
|
+
/** Resolves when the transport-owned server is listening. */
|
|
105
|
+
ready: Promise<void>;
|
|
106
|
+
/** Returns the bound address, or `null` when the server is not listening. */
|
|
107
|
+
address: () => AddressInfo | string | null;
|
|
108
|
+
/**
|
|
109
|
+
* Complete a `node:http` `upgrade` event on this transport, applying the
|
|
110
|
+
* same `path` filter and origin gate the transport's own listener uses.
|
|
111
|
+
* Wire it into a host server directly (`server.on('upgrade',
|
|
112
|
+
* transport.handleUpgrade)`) or call it from an existing listener.
|
|
113
|
+
*/
|
|
114
|
+
handleUpgrade: (req: IncomingMessage, socket: Duplex, head: Buffer) => void;
|
|
115
|
+
/**
|
|
116
|
+
* Route a server's `upgrade` events to this transport, returning a detach
|
|
117
|
+
* function. Use it to bind an `unbound` transport once the host server
|
|
118
|
+
* exists; {@link WsRpcTransport.close} detaches every server attached this
|
|
119
|
+
* way (without closing them, since the caller owns their lifecycle).
|
|
120
|
+
*/
|
|
121
|
+
attach: (server: Server | Server$1) => () => void;
|
|
122
|
+
/** Remove the upgrade listener from a shared `server` (a no-op otherwise). */
|
|
123
|
+
detach: () => void;
|
|
124
|
+
/**
|
|
125
|
+
* Tear the transport down deterministically: detach from a shared server,
|
|
126
|
+
* force-terminate every connected peer, and close any server this
|
|
127
|
+
* transport created itself (`port` / `https` modes).
|
|
128
|
+
*/
|
|
129
|
+
close: () => Promise<void>;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* The per-peer lifecycle hooks driving a devframe RPC WebSocket, shaped for
|
|
133
|
+
* any [crossws](https://crossws.h3.dev) adapter. {@link attachWsRpcTransport}
|
|
134
|
+
* feeds them to the Node adapter; runtime-specific attachments (e.g. Bun's
|
|
135
|
+
* fetch-upgrade adapter) reuse the same hooks so every transport speaks the
|
|
136
|
+
* identical wire protocol: one birpc channel per peer, per-method
|
|
137
|
+
* `jsonSerializable` dispatch between strict JSON and structured-clone.
|
|
138
|
+
*/
|
|
139
|
+
export declare function createWsRpcPeerHooks<ClientFunctions extends object, ServerFunctions extends object>(rpcGroup: BirpcGroup<ClientFunctions, ServerFunctions, false>, options?: Pick<WsRpcTransportOptions, 'onConnected' | 'onDisconnected' | 'definitions' | 'serialize' | 'deserialize'>): Partial<Hooks>;
|
|
140
|
+
/**
|
|
141
|
+
* Attach a WebSocket transport to an existing RPC group, powered by
|
|
142
|
+
* [crossws](https://crossws.h3.dev). Either attach to an existing HTTP(S)
|
|
143
|
+
* `server` (sharing its port, optionally scoped to a `path`), or let this
|
|
144
|
+
* helper create a standalone server from `port` / `host` / `https`.
|
|
145
|
+
*
|
|
146
|
+
* Returns the crossws node adapter, standalone-server readiness/address
|
|
147
|
+
* accessors, `detach` (remove the upgrade listener from a shared `server`),
|
|
148
|
+
* and `close` (full deterministic teardown).
|
|
149
|
+
*/
|
|
150
|
+
export declare function attachWsRpcTransport<ClientFunctions extends object, ServerFunctions extends object>(rpcGroup: BirpcGroup<ClientFunctions, ServerFunctions, false>, options?: WsRpcTransportOptions): WsRpcTransport;
|
|
151
|
+
export { type DevframeNodeRpcSessionMeta, type DevframeRpcConnection, type DevframeRpcConnectionRequest, type DevframeRpcTransportKind, type DevframeWsPeer, isAllowedOrigin, isLoopbackHostname };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as __exportAll } from "./rolldown-runtime-
|
|
1
|
+
import { n as __exportAll } from "./rolldown-runtime-BVN1G_yT.mjs";
|
|
2
2
|
import { createRpcServer } from "./rpc/server.mjs";
|
|
3
3
|
import { n as getRpcResolvedSetupResult, t as getRpcHandler } from "./handler-DkLlj3-B.mjs";
|
|
4
4
|
import { t as diagnostics } from "./diagnostics-DC1-WcvN.mjs";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { n as BirpcGroup, o as EventOptions } from "./index-BKu9BxcT.mjs";
|
|
2
|
-
import "./ws-server
|
|
2
|
+
import "./rpc/transports/ws-server.mjs";
|
|
3
3
|
import { n as DevframeRpcConnection, t as DevframeNodeRpcSessionMeta } from "./session-Y9R6tqg4.mjs";
|
|
4
|
-
import {
|
|
5
|
-
import "./
|
|
4
|
+
import { B as DevframeNodeRpcSession, J as DevframeRpcClientFunctions, Y as DevframeRpcServerFunctions, k as DevframeAuthHandler, z as DevframeNodeContext } from "./index-BhUqJUHG.mjs";
|
|
5
|
+
import "./node/auth.mjs";
|
|
6
6
|
interface CreateContextRpcServerOptions {
|
|
7
7
|
context: DevframeNodeContext;
|
|
8
8
|
/**
|
package/dist/types/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { m as RpcFunctionAgentOptions } from "../types-
|
|
2
|
-
import { $ as
|
|
1
|
+
import { m as RpcFunctionAgentOptions } from "../types-KZOyhez5.mjs";
|
|
2
|
+
import { $ as DevframeServiceId, $t as AgentToolProviderHandle, B as DevframeNodeRpcSession, C as McpPromptResult, Ct as DevframeDiagnosticsHost, D as McpResourcesChangedHook, E as McpResourceTemplateEntry, F as ConnectionMetaSse, G as RpcStreamingChannel, Gt as AgentHandle, H as RpcFunctionsHost, I as ConnectionMetaWebsocket, J as DevframeRpcClientFunctions, Jt as AgentResourceContent, K as RpcStreamingChannelOptions, Kt as AgentManifest, L as DevframeCapabilities, O as McpServerHandle, P as ConnectionMeta, Q as DevframeServiceDescriptor, Qt as AgentToolProvider, R as DevframeConnectionConfigsRegistry, S as McpPromptMessage, St as DevframeStorageScope, T as McpResourceTemplateContent, U as RpcSharedStateGetOptions, V as RpcBroadcastOptions, W as RpcSharedStateHost, X as DevframeRpcSharedStates, Xt as AgentTool, Y as DevframeRpcServerFunctions, Yt as AgentResourceInput, Z as DevframeServiceDefinition, Zt as AgentToolInput, _ as McpConnectionInfo, _t as ScopedServerFunctions, a as DevframeDuplicationStrategy, at as DevframeServicesRegistry, b as McpPrompt, bt as DevframeViewHost, c as DevframeSnapshotRpcEntry, ct as DevframeScopedNodeContext, d as DevframeWsOptions, dt as DevframeSettings, en as DevframeAgentHost, et as DevframeServiceInput, f as McpAuthorization, ft as DevframeSettingsRegistry, g as CreateMcpServerOptions, gt as ScopedRpcFn, h as CreateMcpFetchHandlerOptions, ht as ScopedClientFunctions, i as DevframeDockDefaults, in as EventsMap, it as DevframeServicesHost, l as DevframeSnapshotRpcInputs, lt as DevframeScopedNodeRpc, m as McpSetting, mt as ScopedBroadcastOptions, n as DevframeDefinition, nn as EventEmitter, nt as DevframeServiceOf, o as DevframeRpcOptions, ot as DevframeServicesScopeRegistry, p as McpRouteOptions, pt as DevframeSettingsStore, q as RpcStreamingHost, qt as AgentResource, r as DevframeDeploymentKind, rn as EventUnsubscribe, rt as DevframeServiceScopeOf, s as DevframeSetupInfo, st as DevframeServicesState, t as DevframeCliOptions, tn as DevframeAgentHostEvents, tt as DevframeServiceMeta, u as DevframeSseOptions, ut as DevframeScopedStreamingHost, v as McpContentBlock, vt as ScopedSharedStates, w as McpResourceTemplate, wt as DevframeDiagnosticsLogger, x as McpPromptArgument, xt as DevframeHost, y as McpFetchHandler, yt as SettingsForNamespace, z as DevframeNodeContext } from "../index-BhUqJUHG.mjs";
|
|
3
3
|
import { a as DevframeWsPeer, i as DevframeRpcTransportKind, n as DevframeRpcConnection, r as DevframeRpcConnectionRequest, t as DevframeNodeRpcSessionMeta } from "../session-Y9R6tqg4.mjs";
|
|
4
|
+
import { DevframeDefineDiagnosticsOptions } from "../utils/nostics.mjs";
|
|
4
5
|
import { a as RemoteAssetsStore, i as RemoteAssetsProviderCustom, n as RemoteAssetsErrorMessage, o as StaticAssetsSource, r as RemoteAssetsProvider, t as RemoteAssets } from "../remote-assets-5AQMHZnV.mjs";
|
|
5
|
-
import { i as DevframeDefineDiagnosticsOptions } from "../nostics-Dgwh7ytT.mjs";
|
|
6
6
|
export { AgentHandle, AgentManifest, AgentResource, AgentResourceContent, AgentResourceInput, AgentTool, AgentToolInput, AgentToolProvider, AgentToolProviderHandle, ConnectionMeta, ConnectionMetaSse, ConnectionMetaWebsocket, CreateMcpFetchHandlerOptions, CreateMcpServerOptions, DevframeAgentHost, DevframeAgentHostEvents, DevframeCapabilities, DevframeCliOptions, DevframeConnectionConfigsRegistry, type DevframeDefineDiagnosticsOptions, DevframeDefinition, DevframeDeploymentKind, DevframeDiagnosticsHost, DevframeDiagnosticsLogger, DevframeDockDefaults, DevframeDuplicationStrategy, DevframeHost, DevframeNodeContext, DevframeNodeRpcSession, type DevframeNodeRpcSessionMeta, DevframeRpcClientFunctions, type DevframeRpcConnection, type DevframeRpcConnectionRequest, DevframeRpcOptions, DevframeRpcServerFunctions, DevframeRpcSharedStates, type DevframeRpcTransportKind, DevframeScopedNodeContext, DevframeScopedNodeRpc, DevframeScopedStreamingHost, DevframeServiceDefinition, DevframeServiceDescriptor, DevframeServiceId, DevframeServiceInput, DevframeServiceMeta, DevframeServiceOf, DevframeServiceScopeOf, DevframeServicesHost, DevframeServicesRegistry, DevframeServicesScopeRegistry, DevframeServicesState, DevframeSettings, DevframeSettingsRegistry, DevframeSettingsStore, DevframeSetupInfo, DevframeSnapshotRpcEntry, DevframeSnapshotRpcInputs, DevframeSseOptions, DevframeStorageScope, DevframeViewHost, DevframeWsOptions, type DevframeWsPeer, EventEmitter, EventUnsubscribe, EventsMap, McpAuthorization, McpConnectionInfo, McpContentBlock, McpFetchHandler, McpPrompt, McpPromptArgument, McpPromptMessage, McpPromptResult, McpResourceTemplate, McpResourceTemplateContent, McpResourceTemplateEntry, McpResourcesChangedHook, McpRouteOptions, McpServerHandle, McpSetting, RemoteAssets, RemoteAssetsErrorMessage, RemoteAssetsProvider, RemoteAssetsProviderCustom, RemoteAssetsStore, RpcBroadcastOptions, type RpcFunctionAgentOptions, RpcFunctionsHost, RpcSharedStateGetOptions, RpcSharedStateHost, RpcStreamingChannel, RpcStreamingChannelOptions, RpcStreamingHost, ScopedBroadcastOptions, ScopedClientFunctions, ScopedRpcFn, ScopedServerFunctions, ScopedSharedStates, SettingsForNamespace, StaticAssetsSource };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { t as StandardSchemaV1 } from "./index-BIRF0E5l.mjs";
|
|
2
|
+
import "./index-BKu9BxcT.mjs";
|
|
2
3
|
/** Infers a TypeScript argument tuple from a Standard Schema array */
|
|
3
4
|
type InferArgsType<S extends RpcArgsSchema | undefined> = S extends readonly [] ? [] : S extends readonly [infer H, ...infer T] ? H extends StandardSchemaV1 ? T extends readonly StandardSchemaV1[] ? [StandardSchemaV1.InferInput<H>, ...InferArgsType<T>] : never : never : never;
|
|
4
5
|
/** Infers a TypeScript return type from a Standard Schema */
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Promise-aware debounce, bundled in so any integration can reuse it through
|
|
3
|
+
* `devframe/utils/debounce` without adding its own `perfect-debounce`
|
|
4
|
+
* dependency. Thin re-export of `perfect-debounce`'s `debounce`; the bytes
|
|
5
|
+
* live once in devframe's dist.
|
|
6
|
+
*/
|
|
1
7
|
//#region src/index.d.ts
|
|
2
8
|
interface DebounceOptions {
|
|
3
9
|
/**
|
package/dist/utils/events.d.mts
CHANGED
package/dist/utils/get-port.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { n as getPort } from "../dist-
|
|
1
|
+
export { n as getPort } from "../dist-CZ-TySHD.mjs";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as __toESM, r as __require, t as __commonJSMin } from "../rolldown-runtime-
|
|
1
|
+
import { i as __toESM, r as __require, t as __commonJSMin } from "../rolldown-runtime-BVN1G_yT.mjs";
|
|
2
2
|
// ../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js
|
|
3
3
|
var require_picocolors = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
4
4
|
let p = process || {};
|
package/dist/utils/nostics.d.mts
CHANGED
|
@@ -1,2 +1,40 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { AnyDiagnosticReporter, AnyDiagnosticReporter as AnyDiagnosticReporter$1, ConsoleMethod, ConsoleReporterOptions, Diagnostic, Diagnostic as Diagnostic$1, DiagnosticCallParams, DiagnosticDefinition, DiagnosticDefinition as DiagnosticDefinition$1, DiagnosticHandle, DiagnosticInit, DiagnosticReporter, Diagnostics, Diagnostics as Diagnostics$1, createConsoleReporter, defineProdDiagnostics, formatDiagnostic } from "nostics";
|
|
2
|
+
import { ansiFormatter } from "nostics/formatters/ansi";
|
|
3
|
+
/**
|
|
4
|
+
* The reporter every {@link defineDiagnostics} call below wires in ahead of
|
|
5
|
+
* any caller-supplied ones: prints the diagnostic through devframe's own
|
|
6
|
+
* ANSI colors via `console[method]` (default `'warn'`).
|
|
7
|
+
*/
|
|
8
|
+
declare function devframeReporter(d: Diagnostic$1, { method }?: {
|
|
9
|
+
method?: 'log' | 'warn' | 'error';
|
|
10
|
+
}): void;
|
|
11
|
+
/**
|
|
12
|
+
* Options accepted by {@link defineDiagnostics}, identical to `nostics`'s
|
|
13
|
+
* own `DefineDiagnosticsOptions`, minus the reporter devframe already
|
|
14
|
+
* prepends.
|
|
15
|
+
*/
|
|
16
|
+
export type DevframeDefineDiagnosticsOptions<Codes extends Record<string, DiagnosticDefinition$1>, Reporters extends readonly AnyDiagnosticReporter$1[] = []> = Parameters<typeof defineDiagnostics<Codes, Reporters>>[0];
|
|
17
|
+
/**
|
|
18
|
+
* Drop-in replacement for `nostics`'s `defineDiagnostics()` with devframe's
|
|
19
|
+
* ANSI console reporter pre-wired ahead of any `reporters` passed in. Every
|
|
20
|
+
* `diagnostics.ts` in devframe core, `@devframes/hub`, `@devframes/json-render`,
|
|
21
|
+
* and the built-in plugins defines its codes through this instead of
|
|
22
|
+
* `nostics`'s own `defineDiagnostics`; the reporter registration lives
|
|
23
|
+
* here, once, so none of them need to build their own reporter (`colors`,
|
|
24
|
+
* `ansiFormatter`) or take a direct dependency on `nostics` themselves.
|
|
25
|
+
*/
|
|
26
|
+
export declare function defineDiagnostics<const Codes extends Record<string, DiagnosticDefinition$1>, const Reporters extends readonly AnyDiagnosticReporter$1[] = []>(options: {
|
|
27
|
+
docsBase?: string | ((code: keyof Codes) => string | undefined);
|
|
28
|
+
codes: Codes;
|
|
29
|
+
reporters?: Reporters;
|
|
30
|
+
}): DevframeDiagnostics<Codes, Reporters>;
|
|
31
|
+
/**
|
|
32
|
+
* The `Diagnostics` object returned by devframe's {@link defineDiagnostics}
|
|
33
|
+
* (devframe's ANSI console reporter is always prepended). Integrations that
|
|
34
|
+
* export their own `defineDiagnostics(...)` result as public API annotate it
|
|
35
|
+
* with this type, so the reference resolves through `devframe/utils/nostics`
|
|
36
|
+
* rather than inlining `nostics`'s types or taking a direct `nostics`
|
|
37
|
+
* dependency.
|
|
38
|
+
*/
|
|
39
|
+
export type DevframeDiagnostics<Codes extends Record<string, DiagnosticDefinition$1>, Reporters extends readonly AnyDiagnosticReporter$1[] = []> = Diagnostics$1<Codes, readonly [typeof devframeReporter, ...Reporters]>;
|
|
40
|
+
export { type AnyDiagnosticReporter, type ConsoleMethod, type ConsoleReporterOptions, type Diagnostic, type DiagnosticCallParams, type DiagnosticDefinition, type DiagnosticHandle, type DiagnosticInit, type DiagnosticReporter, type Diagnostics, ansiFormatter, createConsoleReporter, defineProdDiagnostics, formatDiagnostic };
|
package/dist/utils/origin.d.mts
CHANGED
|
@@ -1,2 +1,55 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Origin and hostname predicates shared by the RPC transports (the WS upgrade,
|
|
3
|
+
* SSE, and MCP origin gates) and the instance shell's authentication-link
|
|
4
|
+
* origin validation. Kept dependency-free and runtime-agnostic so any consumer
|
|
5
|
+
* can pull in a single check without dragging in a transport's `crossws`
|
|
6
|
+
* import.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Whether `hostname` names a loopback host: `localhost` (or any `*.localhost`
|
|
10
|
+
* subdomain), the IPv6 loopback `::1`, or an IPv4 literal inside the
|
|
11
|
+
* `127.0.0.0/8` loopback block.
|
|
12
|
+
*
|
|
13
|
+
* The IPv4 case is matched **structurally**: the whole hostname must be a
|
|
14
|
+
* canonical dotted-decimal IPv4 literal whose first octet is `127`. A bare
|
|
15
|
+
* `startsWith('127.')` prefix check would also accept an attacker-controlled
|
|
16
|
+
* DNS name that merely *begins* with `127.` (`127.attacker.example`,
|
|
17
|
+
* `127.0.0.1.attacker.example`), letting a cross-origin browser page defeat
|
|
18
|
+
* the loopback origin gate that guards the RPC/MCP surface (a DNS-rebinding /
|
|
19
|
+
* cross-site WebSocket-hijacking bypass). Requiring a real IPv4 literal keeps
|
|
20
|
+
* genuine loopback addresses (`127.0.0.1`, `127.5.5.5`) allowed while rejecting
|
|
21
|
+
* those DNS names.
|
|
22
|
+
*/
|
|
23
|
+
export declare function isLoopbackHostname(hostname: string): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Whether `address` is a loopback peer address as reported by a socket
|
|
26
|
+
* (`net.Socket.remoteAddress`): the IPv6 loopback `::1`, an IPv4 literal in
|
|
27
|
+
* `127.0.0.0/8`, or an IPv4-mapped IPv6 form of one (`::ffff:127.0.0.1`).
|
|
28
|
+
*
|
|
29
|
+
* Unlike {@link isLoopbackHostname} this takes a raw address, not a hostname:
|
|
30
|
+
* it never accepts a `localhost`-style name (a socket peer is always a literal
|
|
31
|
+
* address) and understands the IPv4-mapped IPv6 form the OS hands back on a
|
|
32
|
+
* dual-stack listener. Used to prove a same-machine caller from the connected
|
|
33
|
+
* peer, which a client cannot forge, rather than from the `Origin` header,
|
|
34
|
+
* which it can.
|
|
35
|
+
*/
|
|
36
|
+
export declare function isLoopbackAddress(address: string): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Default origin policy for a localhost dev tool: allow requests with no
|
|
39
|
+
* `Origin` header (native, non-browser clients), allow any loopback origin
|
|
40
|
+
* (so cross-port localhost dev setups keep working), and allow explicitly
|
|
41
|
+
* configured origins. Everything else, such as a real remote page in the dev's
|
|
42
|
+
* browser, is rejected.
|
|
43
|
+
*/
|
|
44
|
+
export declare function isAllowedOrigin(origin: string | undefined, allowedOrigins: readonly string[]): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Decide whether a request-derived origin candidate may back a devframe's
|
|
47
|
+
* advertised public origin, the destination of the OTP magic link. Stricter
|
|
48
|
+
* than {@link isAllowedOrigin}: it rejects credentials, a path, a query, a
|
|
49
|
+
* fragment, a malformed port, and non-HTTP(S) schemes, and adopts a candidate
|
|
50
|
+
* only when its hostname is loopback or its canonical origin exactly matches
|
|
51
|
+
* an `allowedOrigins` entry (a caller with no static list passes none, so only
|
|
52
|
+
* loopback qualifies). Returns the canonical origin to adopt, or `undefined`
|
|
53
|
+
* to reject. Forwarded headers are never consulted.
|
|
54
|
+
*/
|
|
55
|
+
export declare function validateOriginCandidate(candidate: string, allowedOrigins?: readonly string[]): string | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as RemoteAssetsStore } from "../remote-assets-5AQMHZnV.mjs";
|
|
2
|
-
import { EventHandler, H3 } from "h3";
|
|
3
2
|
import { IncomingMessage, ServerResponse } from "node:http";
|
|
3
|
+
import { EventHandler, H3 } from "h3";
|
|
4
4
|
/**
|
|
5
5
|
* What the static-serving engine accepts: a local directory, or a resolved
|
|
6
6
|
* {@link RemoteAssetsStore} back-proxy (from `devframe/utils/remote-assets`).
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Bt as SharedState, Ft as Immutable, Ht as SharedStateOptions, It as ImmutableArray, Lt as ImmutableMap, Rt as ImmutableObject, Ut as SharedStatePatch, Vt as SharedStateEvents, Wt as createSharedState, zt as ImmutableSet } from "../index-BhUqJUHG.mjs";
|
|
2
2
|
export { Immutable, ImmutableArray, ImmutableMap, ImmutableObject, ImmutableSet, SharedState, SharedStateEvents, SharedStateOptions, SharedStatePatch, createSharedState };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { At as StreamReader, Dt as CreateStreamReaderOptions, Et as BufferedChunk, Mt as StreamSinkEvents, Nt as createStreamReader, Ot as CreateStreamSinkOptions, Pt as createStreamSink, jt as StreamSink, kt as StreamErrorPayload } from "../index-BhUqJUHG.mjs";
|
|
2
2
|
export { BufferedChunk, CreateStreamReaderOptions, CreateStreamSinkOptions, StreamErrorPayload, StreamReader, StreamSink, StreamSinkEvents, createStreamReader, createStreamSink };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "devframe",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.3.
|
|
4
|
+
"version": "1.3.3",
|
|
5
5
|
"description": "Framework for building one portable devtool integration that runs in any viewer.",
|
|
6
6
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"skills"
|
|
78
78
|
],
|
|
79
79
|
"peerDependencies": {
|
|
80
|
-
"@devframes/agentic": "1.3.
|
|
80
|
+
"@devframes/agentic": "1.3.3",
|
|
81
81
|
"cac": "^7.0.0"
|
|
82
82
|
},
|
|
83
83
|
"peerDependenciesMeta": {
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
"pathe": "^2.0.3"
|
|
96
96
|
},
|
|
97
97
|
"devDependencies": {
|
|
98
|
-
"@devframes/agentic": "1.3.
|
|
98
|
+
"@devframes/agentic": "1.3.3",
|
|
99
99
|
"@standard-schema/spec": "^1.1.0",
|
|
100
100
|
"birpc": "^4.2.0",
|
|
101
101
|
"cac": "^7.1.0",
|
|
@@ -110,12 +110,12 @@
|
|
|
110
110
|
"perfect-debounce": "^2.1.0",
|
|
111
111
|
"structured-clone-es": "^2.0.1",
|
|
112
112
|
"tinyglobby": "^0.2.17",
|
|
113
|
-
"tsdown": "^0.23.
|
|
113
|
+
"tsdown": "^0.23.7",
|
|
114
114
|
"typescript": "^6.0.3",
|
|
115
115
|
"ua-parser-modern": "^0.1.1",
|
|
116
116
|
"valibot": "^1.5.0",
|
|
117
117
|
"whenexpr": "^0.1.2",
|
|
118
|
-
"ws": "^8.22.
|
|
118
|
+
"ws": "^8.22.2"
|
|
119
119
|
},
|
|
120
120
|
"scripts": {
|
|
121
121
|
"build": "tsdown",
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import { C as RpcFunctionType, S as RpcFunctionSetupResult, T as RpcReturnSchema, g as RpcFunctionDefinitionAny, h as RpcFunctionDefinition, n as RpcArgsSchema, w as RpcFunctionsCollector } from "./types-844OBepb.mjs";
|
|
2
|
-
interface RpcCacheOptions {
|
|
3
|
-
functions: string[];
|
|
4
|
-
keySerializer?: (args: unknown[]) => string;
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* @experimental API is expected to change.
|
|
8
|
-
*/
|
|
9
|
-
declare class RpcCacheManager {
|
|
10
|
-
private cacheMap;
|
|
11
|
-
private options;
|
|
12
|
-
private keySerializer;
|
|
13
|
-
constructor(options: RpcCacheOptions);
|
|
14
|
-
updateOptions(options: Partial<RpcCacheOptions>): void;
|
|
15
|
-
cached<T>(m: string, a: unknown[]): T | undefined;
|
|
16
|
-
has(m: string, a: unknown[]): boolean;
|
|
17
|
-
apply(req: {
|
|
18
|
-
m: string;
|
|
19
|
-
a: unknown[];
|
|
20
|
-
}, res: unknown): void;
|
|
21
|
-
validate(m: string): boolean;
|
|
22
|
-
clear(fn?: string): void;
|
|
23
|
-
}
|
|
24
|
-
declare class RpcFunctionsCollectorBase<LocalFunctions extends Record<string, any>, SetupContext> implements RpcFunctionsCollector<LocalFunctions, SetupContext> {
|
|
25
|
-
readonly context: SetupContext;
|
|
26
|
-
readonly definitions: Map<string, RpcFunctionDefinition<string, any, any, any, any, any, SetupContext>>;
|
|
27
|
-
readonly functions: LocalFunctions;
|
|
28
|
-
private readonly _onChanged;
|
|
29
|
-
constructor(context: SetupContext);
|
|
30
|
-
register(fnDef: RpcFunctionDefinition<string, any, any, any, any, any, SetupContext>, force?: boolean): void;
|
|
31
|
-
update(fn: RpcFunctionDefinition<string, any, any, any, any, any, SetupContext>, force?: boolean): void;
|
|
32
|
-
onChanged(fn: (id?: string) => void): () => void;
|
|
33
|
-
getHandler<T extends keyof LocalFunctions>(name: T): Promise<LocalFunctions[T]>;
|
|
34
|
-
getSchema<T extends keyof LocalFunctions>(name: T): {
|
|
35
|
-
args: RpcArgsSchema | undefined;
|
|
36
|
-
returns: RpcReturnSchema | undefined;
|
|
37
|
-
};
|
|
38
|
-
has(name: string): boolean;
|
|
39
|
-
get(name: string): RpcFunctionDefinition<string, any, any, any, any, any, SetupContext> | undefined;
|
|
40
|
-
list(): string[];
|
|
41
|
-
}
|
|
42
|
-
declare function defineRpcFunction<NAME extends string, TYPE extends RpcFunctionType, ARGS extends any[], RETURN = void, const AS extends RpcArgsSchema | undefined = undefined, const RS extends RpcReturnSchema | undefined = undefined>(definition: RpcFunctionDefinition<NAME, TYPE, ARGS, RETURN, AS, RS>): RpcFunctionDefinition<NAME, TYPE, ARGS, RETURN, AS, RS>;
|
|
43
|
-
declare function createDefineWrapperWithContext<CONTEXT>(): <NAME extends string, TYPE extends RpcFunctionType, ARGS extends any[], RETURN = void, const AS extends RpcArgsSchema | undefined = undefined, const RS extends RpcReturnSchema | undefined = undefined>(definition: RpcFunctionDefinition<NAME, TYPE, ARGS, RETURN, AS, RS, CONTEXT>) => RpcFunctionDefinition<NAME, TYPE, ARGS, RETURN, AS, RS, CONTEXT>;
|
|
44
|
-
declare function getRpcResolvedSetupResult<NAME extends string, TYPE extends RpcFunctionType, ARGS extends any[], RETURN = void, CONTEXT = undefined>(definition: RpcFunctionDefinition<NAME, TYPE, ARGS, RETURN, any, any, CONTEXT>, context: CONTEXT): Promise<RpcFunctionSetupResult<ARGS, RETURN>>;
|
|
45
|
-
declare function getRpcHandler<NAME extends string, TYPE extends RpcFunctionType, ARGS extends any[], RETURN = void, CONTEXT = undefined>(definition: RpcFunctionDefinition<NAME, TYPE, ARGS, RETURN, any, any, CONTEXT>, context: CONTEXT): Promise<(...args: ARGS) => RETURN>;
|
|
46
|
-
/**
|
|
47
|
-
* Wire format used by the live RPC transports (WebSocket and SSE).
|
|
48
|
-
*
|
|
49
|
-
* - **JSON (default, unprefixed):** payload is plain JSON text. Used when
|
|
50
|
-
* the dispatched method is declared `jsonSerializable: true`. Encoded
|
|
51
|
-
* via {@link strictJsonStringify} (rejects non-JSON values), decoded
|
|
52
|
-
* via `JSON.parse`.
|
|
53
|
-
* - **Structured-clone (`s:` prefix):** payload is `s:` followed by
|
|
54
|
-
* `structured-clone-es` text. Used when the method is declared
|
|
55
|
-
* `jsonSerializable: false` (or omitted, the default). Round-trips
|
|
56
|
-
* `Map`, `Set`, `Date`, `BigInt`, cycles, and class instances.
|
|
57
|
-
*
|
|
58
|
-
* birpc envelopes always start with `{`, so a leading byte that is not
|
|
59
|
-
* `s` is unambiguously JSON. Each direction independently chooses its
|
|
60
|
-
* encoding from local definitions; request and response are not
|
|
61
|
-
* coupled by a mirror rule.
|
|
62
|
-
*/
|
|
63
|
-
declare const STRUCTURED_CLONE_PREFIX = "s:";
|
|
64
|
-
/**
|
|
65
|
-
* `JSON.stringify` with a single-pass strict replacer.
|
|
66
|
-
*
|
|
67
|
-
* Throws `DF0020` synchronously when the value contains a type JSON
|
|
68
|
-
* cannot round-trip losslessly: `Map`, `Set`, `Date`, `BigInt`, class
|
|
69
|
-
* instances, or `undefined` inside an array (silently becomes `null`).
|
|
70
|
-
*
|
|
71
|
-
* Native pass-throughs (no extra work needed):
|
|
72
|
-
* - circular references: `JSON.stringify` raises `TypeError`.
|
|
73
|
-
* - `BigInt` at top level: caught here for a friendlier error path.
|
|
74
|
-
*
|
|
75
|
-
* Lenient cases (allowed without throwing):
|
|
76
|
-
* - `undefined` as an object property: legitimate optional field;
|
|
77
|
-
* JSON.stringify just omits it.
|
|
78
|
-
* - `undefined` at the root: legitimate "action returned nothing".
|
|
79
|
-
* - `Symbol` / `Function` values: semantically "drop me" in JSON.
|
|
80
|
-
*
|
|
81
|
-
* `fnName` is used only for the diagnostic message; pass the RPC
|
|
82
|
-
* function name when calling from a wire serializer / dump writer so
|
|
83
|
-
* the error points at the offending function.
|
|
84
|
-
*/
|
|
85
|
-
declare function strictJsonStringify(value: unknown, fnName?: string): string;
|
|
86
|
-
/**
|
|
87
|
-
* Validate positional arguments against their declared schemas. Only
|
|
88
|
-
* indices with a schema are checked; extra arguments pass through
|
|
89
|
-
* untouched. Throws `DF0038` on the first failing argument.
|
|
90
|
-
*
|
|
91
|
-
* Validation guards the payload without rewriting it: the original values
|
|
92
|
-
* are handed to the handler unchanged, so a schema that describes a subset
|
|
93
|
-
* of an object never silently strips the sender's extra fields (and any
|
|
94
|
-
* declared transforms stay a purely type-level concern).
|
|
95
|
-
*
|
|
96
|
-
* @internal
|
|
97
|
-
*/
|
|
98
|
-
declare function validateRpcArgs(name: string, argsSchema: RpcArgsSchema | undefined, args: readonly unknown[]): Promise<unknown[]>;
|
|
99
|
-
/**
|
|
100
|
-
* Validate a handler's resolved return value against its declared schema.
|
|
101
|
-
* Throws `DF0039` when the value fails the schema, otherwise returns the
|
|
102
|
-
* original value unchanged (guard-only, never rewriting the payload; see
|
|
103
|
-
* {@link validateRpcArgs}). Passes through when no return schema is set.
|
|
104
|
-
*
|
|
105
|
-
* @internal
|
|
106
|
-
*/
|
|
107
|
-
declare function validateRpcReturn(name: string, returnSchema: RpcReturnSchema | undefined, value: unknown): Promise<unknown>;
|
|
108
|
-
/**
|
|
109
|
-
* Validates RPC function definitions.
|
|
110
|
-
* Action and event functions cannot have dumps (side effects should not be cached).
|
|
111
|
-
*
|
|
112
|
-
* @throws {Error} If an action or event function has a dump configuration
|
|
113
|
-
*/
|
|
114
|
-
declare function validateDefinitions(definitions: readonly RpcFunctionDefinitionAny[]): void;
|
|
115
|
-
/**
|
|
116
|
-
* Validates a single RPC function definition.
|
|
117
|
-
*
|
|
118
|
-
* @throws {Error} If an action or event function has a dump configuration
|
|
119
|
-
*/
|
|
120
|
-
declare function validateDefinition(definition: RpcFunctionDefinitionAny): void;
|
|
121
|
-
export { STRUCTURED_CLONE_PREFIX as a, getRpcResolvedSetupResult as c, RpcFunctionsCollectorBase as d, RpcCacheManager as f, validateRpcReturn as i, createDefineWrapperWithContext as l, validateDefinitions as n, strictJsonStringify as o, RpcCacheOptions as p, validateRpcArgs as r, getRpcHandler as s, validateDefinition as t, defineRpcFunction as u };
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { k as SharedState, o as DevframeNodeContext, s as DevframeNodeRpcSession } from "./context-WxTq6kqb.mjs";
|
|
2
|
-
import { n as InternalAnonymousAuthStorage } from "./context-CsdPs3po.mjs";
|
|
3
|
-
/**
|
|
4
|
-
* Flip `isTrusted` to false on any live WS clients connected with `token`
|
|
5
|
-
* and broadcast the `auth:revoked` event so they can react.
|
|
6
|
-
*
|
|
7
|
-
* Shared between persisted-auth revocation and remote-dock token revocation.
|
|
8
|
-
*/
|
|
9
|
-
declare function revokeActiveConnectionsForToken(context: DevframeNodeContext, token: string): Promise<void>;
|
|
10
|
-
/**
|
|
11
|
-
* Revoke an auth token: remove from storage and notify all connected clients
|
|
12
|
-
* using this token that they are no longer trusted.
|
|
13
|
-
*/
|
|
14
|
-
declare function revokeAuthToken(context: DevframeNodeContext, storage: SharedState<InternalAnonymousAuthStorage>, token: string): Promise<void>;
|
|
15
|
-
/**
|
|
16
|
-
* Format a raw `navigator.userAgent` string into the short display label
|
|
17
|
-
* shown for a trusted device (e.g. "Chrome 120 | macOS 14 desktop").
|
|
18
|
-
*
|
|
19
|
-
* The client used to parse+format this itself, but that pulled
|
|
20
|
-
* `ua-parser-modern` into the browser bundle for a label nothing else on
|
|
21
|
-
* the client needs; the client now sends the raw string and parsing
|
|
22
|
-
* happens here, at the server ingress, keeping the persisted label format
|
|
23
|
-
* identical.
|
|
24
|
-
*/
|
|
25
|
-
declare function describeUA(userAgent: string): string;
|
|
26
|
-
/**
|
|
27
|
-
* The current one-time authentication code. Display this to the user (e.g. in
|
|
28
|
-
* the dev-server terminal) so they can type it into the browser to authenticate.
|
|
29
|
-
*/
|
|
30
|
-
declare function getTempAuthCode(): string;
|
|
31
|
-
/**
|
|
32
|
-
* The current code plus its expiry timestamp, for display (e.g. the auth
|
|
33
|
-
* banner). An already-expired code is rotated first, so the returned code is
|
|
34
|
-
* always redeemable for its remaining lifetime.
|
|
35
|
-
*/
|
|
36
|
-
declare function getTempAuthCodeInfo(): {
|
|
37
|
-
code: string;
|
|
38
|
-
expireAt: number;
|
|
39
|
-
};
|
|
40
|
-
/**
|
|
41
|
-
* Rotate the authentication code, resetting its expiry window and failed-attempt
|
|
42
|
-
* counter. Call this when a new authentication flow begins (e.g. when an
|
|
43
|
-
* untrusted client starts authenticating) so the displayed code is freshly
|
|
44
|
-
* valid for its full TTL.
|
|
45
|
-
*/
|
|
46
|
-
declare function refreshTempAuthCode(): string;
|
|
47
|
-
/**
|
|
48
|
-
* Build a "magic link" authentication URL that embeds a one-time code (OTP) in
|
|
49
|
-
* the URL **fragment**. Opening it authenticates the client without typing;
|
|
50
|
-
* print it on startup (devframe stays headless, so the host prints its own
|
|
51
|
-
* banner). Defaults to the current code; the link is subject to the same TTL.
|
|
52
|
-
*
|
|
53
|
-
* The code rides the fragment (`#devframe_otp=…`), not the query string, so it
|
|
54
|
-
* is never sent to the server, written to an access log, or leaked in a
|
|
55
|
-
* `Referer` header; the browser client reads it locally (see
|
|
56
|
-
* `consumeOtpFromUrl`). Any existing fragment parameters are preserved.
|
|
57
|
-
*/
|
|
58
|
-
declare function buildOtpAuthUrl(baseUrl: string, code?: string): string;
|
|
59
|
-
/**
|
|
60
|
-
* Re-authenticate a connection that presents a previously-issued bearer token.
|
|
61
|
-
* Returns `true` and marks the session trusted when the token is known.
|
|
62
|
-
*
|
|
63
|
-
* Used by the `anonymous:devframe:auth` handler so a client that already
|
|
64
|
-
* authenticated (token persisted in the browser) is trusted on reconnect
|
|
65
|
-
* without entering the code again.
|
|
66
|
-
*/
|
|
67
|
-
declare function verifyAuthToken(token: string, session: DevframeNodeRpcSession, storage: SharedState<InternalAnonymousAuthStorage>): boolean;
|
|
68
|
-
/**
|
|
69
|
-
* Exchange a one-time authentication code for a fresh, node-issued bearer token.
|
|
70
|
-
*
|
|
71
|
-
* On success this mints a high-entropy token, records it in the trusted store,
|
|
72
|
-
* marks the calling session trusted, rotates the code, and returns the token
|
|
73
|
-
* for the client to persist. Returns `null` on any failure.
|
|
74
|
-
*
|
|
75
|
-
* Because the code is short and human-typed, verification is hardened against
|
|
76
|
-
* brute force: it enforces a time-to-live, compares in constant time, and
|
|
77
|
-
* rotates the code after {@link TEMP_AUTH_MAX_ATTEMPTS} failed attempts so an
|
|
78
|
-
* attacker cannot keep guessing against the same code.
|
|
79
|
-
*/
|
|
80
|
-
declare function exchangeTempAuthCode(code: string, session: DevframeNodeRpcSession, info: {
|
|
81
|
-
ua: string;
|
|
82
|
-
origin: string;
|
|
83
|
-
}, storage: SharedState<InternalAnonymousAuthStorage>): string | null;
|
|
84
|
-
export { getTempAuthCodeInfo as a, revokeActiveConnectionsForToken as c, getTempAuthCode as i, revokeAuthToken as l, describeUA as n, refreshTempAuthCode as o, exchangeTempAuthCode as r, verifyAuthToken as s, buildOtpAuthUrl as t };
|