@fuzdev/fuz_app 0.10.1 → 0.11.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/dist/actions/action_bridge.d.ts +8 -8
- package/dist/actions/action_bridge.d.ts.map +1 -1
- package/dist/actions/action_bridge.js +5 -5
- package/dist/actions/action_codegen.d.ts +18 -1
- package/dist/actions/action_codegen.d.ts.map +1 -1
- package/dist/actions/action_codegen.js +49 -6
- package/dist/actions/action_event.d.ts +60 -0
- package/dist/actions/action_event.d.ts.map +1 -0
- package/dist/actions/action_event.js +361 -0
- package/dist/actions/action_event_data.d.ts +639 -0
- package/dist/actions/action_event_data.d.ts.map +1 -0
- package/dist/actions/action_event_data.js +29 -0
- package/dist/actions/action_event_helpers.d.ts +73 -0
- package/dist/actions/action_event_helpers.d.ts.map +1 -0
- package/dist/actions/action_event_helpers.js +96 -0
- package/dist/actions/action_event_types.d.ts +31 -0
- package/dist/actions/action_event_types.d.ts.map +1 -0
- package/dist/actions/action_event_types.js +38 -0
- package/dist/actions/action_peer.d.ts +30 -0
- package/dist/actions/action_peer.d.ts.map +1 -0
- package/dist/actions/action_peer.js +146 -0
- package/dist/actions/action_spec.d.ts +1 -1
- package/dist/actions/action_spec.js +1 -1
- package/dist/actions/request_tracker.svelte.d.ts +69 -0
- package/dist/actions/request_tracker.svelte.d.ts.map +1 -0
- package/dist/actions/request_tracker.svelte.js +161 -0
- package/dist/actions/rpc_client.d.ts +43 -0
- package/dist/actions/rpc_client.d.ts.map +1 -0
- package/dist/actions/rpc_client.js +151 -0
- package/dist/actions/transports.d.ts +47 -0
- package/dist/actions/transports.d.ts.map +1 -0
- package/dist/actions/transports.js +108 -0
- package/dist/actions/transports_http.d.ts +16 -0
- package/dist/actions/transports_http.d.ts.map +1 -0
- package/dist/actions/transports_http.js +81 -0
- package/dist/actions/transports_ws.d.ts +26 -0
- package/dist/actions/transports_ws.d.ts.map +1 -0
- package/dist/actions/transports_ws.js +94 -0
- package/dist/actions/transports_ws_backend.d.ts +42 -0
- package/dist/actions/transports_ws_backend.d.ts.map +1 -0
- package/dist/actions/transports_ws_backend.js +133 -0
- package/dist/http/jsonrpc_errors.d.ts +2 -0
- package/dist/http/jsonrpc_errors.d.ts.map +1 -1
- package/dist/http/jsonrpc_errors.js +2 -0
- package/dist/http/surface.d.ts +3 -3
- package/dist/http/surface.d.ts.map +1 -1
- package/dist/realtime/sse.d.ts +5 -3
- package/dist/realtime/sse.d.ts.map +1 -1
- package/dist/realtime/sse_auth_guard.d.ts +2 -2
- package/dist/realtime/sse_auth_guard.d.ts.map +1 -1
- package/dist/server/app_server.d.ts +2 -2
- package/dist/server/app_server.d.ts.map +1 -1
- package/dist/testing/stubs.d.ts +2 -2
- package/dist/testing/stubs.d.ts.map +1 -1
- package/dist/uuid.d.ts +12 -0
- package/dist/uuid.d.ts.map +1 -0
- package/dist/uuid.js +9 -0
- package/package.json +1 -1
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WebSocket transport — sends JSON-RPC messages via WebSocket with request tracking.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { ThrownJsonrpcError, jsonrpc_error_messages, UNKNOWN_ERROR_MESSAGE, } from '../http/jsonrpc_errors.js';
|
|
7
|
+
import { is_jsonrpc_notification, is_jsonrpc_request, is_jsonrpc_response, is_jsonrpc_error_response, to_jsonrpc_message_id, create_jsonrpc_error_response, } from '../http/jsonrpc_helpers.js';
|
|
8
|
+
import { RequestTracker } from './request_tracker.svelte.js';
|
|
9
|
+
export class FrontendWebsocketTransport {
|
|
10
|
+
transport_name = 'frontend_websocket_rpc';
|
|
11
|
+
#connection;
|
|
12
|
+
#receive;
|
|
13
|
+
#request_tracker;
|
|
14
|
+
#remove_message_handler;
|
|
15
|
+
#remove_error_handler;
|
|
16
|
+
constructor(connection, receive, request_timeout_ms) {
|
|
17
|
+
this.#connection = connection;
|
|
18
|
+
this.#receive = receive;
|
|
19
|
+
this.#request_tracker = new RequestTracker(request_timeout_ms);
|
|
20
|
+
// TODO maybe we want to do this setup elsewhere, not hardcoded like this
|
|
21
|
+
this.#remove_message_handler = connection.add_message_handler(async (event) => {
|
|
22
|
+
try {
|
|
23
|
+
const data = JSON.parse(event.data);
|
|
24
|
+
// TODO the `data.id !== null` check should be refactored, maybe we want the "Error Message Response" concept for non-null ids
|
|
25
|
+
// Check if this is a response to one of our requests
|
|
26
|
+
if (is_jsonrpc_response(data) || (is_jsonrpc_error_response(data) && data.id !== null)) {
|
|
27
|
+
// This is a response to a request we sent
|
|
28
|
+
this.#request_tracker.handle_message(data);
|
|
29
|
+
}
|
|
30
|
+
else if (is_jsonrpc_request(data) || is_jsonrpc_notification(data)) {
|
|
31
|
+
// This is a new request/notification from the server
|
|
32
|
+
await this.#receive(data);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
console.warn('[ws_transport] received unknown message type:', data);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
console.error('[ws_transport] error parsing WebSocket message:', error);
|
|
40
|
+
// TODO maybe send the whole thing back wrapped in an error?
|
|
41
|
+
// can't reference anything else for a response
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
this.#remove_error_handler = connection.add_error_handler((event) => {
|
|
45
|
+
console.error('[ws_transport] WebSocket error:', event);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
async send(message) {
|
|
49
|
+
if (!this.is_ready()) {
|
|
50
|
+
return create_jsonrpc_error_response(to_jsonrpc_message_id(message), jsonrpc_error_messages.service_unavailable('WebSocket not connected'));
|
|
51
|
+
}
|
|
52
|
+
try {
|
|
53
|
+
// If this is a JSON-RPC request with an id (not a notification), set up request tracking.
|
|
54
|
+
if (is_jsonrpc_request(message)) {
|
|
55
|
+
// TODO track the whole request?
|
|
56
|
+
const deferred = this.#request_tracker.track_request(message.id);
|
|
57
|
+
this.#connection.send(message);
|
|
58
|
+
// Return the promise that will resolve when the response is received
|
|
59
|
+
const result = await deferred.promise;
|
|
60
|
+
return result;
|
|
61
|
+
}
|
|
62
|
+
else if (is_jsonrpc_notification(message)) {
|
|
63
|
+
// For notifications, just send without tracking
|
|
64
|
+
this.#connection.send(message);
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
// Invalid message type - return error with id if available
|
|
68
|
+
return create_jsonrpc_error_response(to_jsonrpc_message_id(message), jsonrpc_error_messages.invalid_request());
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
if (error instanceof ThrownJsonrpcError) {
|
|
72
|
+
return create_jsonrpc_error_response(to_jsonrpc_message_id(message), {
|
|
73
|
+
code: error.code,
|
|
74
|
+
message: error.message,
|
|
75
|
+
data: error.data,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
return create_jsonrpc_error_response(to_jsonrpc_message_id(message), jsonrpc_error_messages.internal_error(error.message || UNKNOWN_ERROR_MESSAGE));
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
is_ready() {
|
|
82
|
+
return this.#connection.connected;
|
|
83
|
+
}
|
|
84
|
+
dispose() {
|
|
85
|
+
if (this.#remove_message_handler) {
|
|
86
|
+
this.#remove_message_handler();
|
|
87
|
+
this.#remove_message_handler = null;
|
|
88
|
+
}
|
|
89
|
+
if (this.#remove_error_handler) {
|
|
90
|
+
this.#remove_error_handler();
|
|
91
|
+
this.#remove_error_handler = null;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Backend WebSocket transport — manages server-side WebSocket connections
|
|
3
|
+
* with session tracking and revocation support.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import type { WSContext } from 'hono/ws';
|
|
8
|
+
import type { JsonrpcNotification, JsonrpcRequest, JsonrpcResponseOrError, JsonrpcErrorResponse } from '../http/jsonrpc.js';
|
|
9
|
+
import { type Uuid } from '../uuid.js';
|
|
10
|
+
import { type Transport } from './transports.js';
|
|
11
|
+
export declare class BackendWebsocketTransport implements Transport {
|
|
12
|
+
#private;
|
|
13
|
+
readonly transport_name: "backend_websocket_rpc";
|
|
14
|
+
/**
|
|
15
|
+
* Add a new WebSocket connection with auth info.
|
|
16
|
+
* Session connections pass a token hash for targeted revocation.
|
|
17
|
+
* Bearer token connections (api_token, daemon_token) pass null —
|
|
18
|
+
* they're still reachable via {@link close_sockets_for_account}.
|
|
19
|
+
*/
|
|
20
|
+
add_connection(ws: WSContext, token_hash: string | null, account_id: Uuid): Uuid;
|
|
21
|
+
/**
|
|
22
|
+
* Remove a WebSocket connection and its auth tracking data.
|
|
23
|
+
* Idempotent — safe to call after revocation has already cleaned up.
|
|
24
|
+
*/
|
|
25
|
+
remove_connection(ws: WSContext): void;
|
|
26
|
+
/**
|
|
27
|
+
* Close all sockets associated with a specific session token hash.
|
|
28
|
+
*
|
|
29
|
+
* @returns the number of sockets closed
|
|
30
|
+
*/
|
|
31
|
+
close_sockets_for_session(token_hash: string): number;
|
|
32
|
+
/**
|
|
33
|
+
* Close all sockets associated with a specific account.
|
|
34
|
+
*
|
|
35
|
+
* @returns the number of sockets closed
|
|
36
|
+
*/
|
|
37
|
+
close_sockets_for_account(account_id: Uuid): number;
|
|
38
|
+
send(message: JsonrpcRequest): Promise<JsonrpcResponseOrError>;
|
|
39
|
+
send(message: JsonrpcNotification): Promise<JsonrpcErrorResponse | null>;
|
|
40
|
+
is_ready(): boolean;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=transports_ws_backend.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transports_ws_backend.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/transports_ws_backend.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,SAAS,CAAC;AACvC,OAAO,KAAK,EAGX,mBAAmB,EACnB,cAAc,EACd,sBAAsB,EACtB,oBAAoB,EACpB,MAAM,oBAAoB,CAAC;AAQ5B,OAAO,EAAc,KAAK,IAAI,EAAC,MAAM,YAAY,CAAC;AAClD,OAAO,EAA2B,KAAK,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAIzE,qBAAa,yBAA0B,YAAW,SAAS;;IAC1D,QAAQ,CAAC,cAAc,EAAG,uBAAuB,CAAU;IAY3D;;;;;OAKG;IACH,cAAc,CAAC,EAAE,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,EAAE,UAAU,EAAE,IAAI,GAAG,IAAI;IAWhF;;;OAGG;IACH,iBAAiB,CAAC,EAAE,EAAE,SAAS,GAAG,IAAI;IAOtC;;;;OAIG;IACH,yBAAyB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM;IAcrD;;;;OAIG;IACH,yBAAyB,CAAC,UAAU,EAAE,IAAI,GAAG,MAAM;IAiC7C,IAAI,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAC9D,IAAI,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;IA4C9E,QAAQ,IAAI,OAAO;CAGnB"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Backend WebSocket transport — manages server-side WebSocket connections
|
|
3
|
+
* with session tracking and revocation support.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import { jsonrpc_error_messages } from '../http/jsonrpc_errors.js';
|
|
8
|
+
import { create_jsonrpc_error_response, to_jsonrpc_message_id, is_jsonrpc_request, } from '../http/jsonrpc_helpers.js';
|
|
9
|
+
import { create_uuid } from '../uuid.js';
|
|
10
|
+
import { WS_CLOSE_SESSION_REVOKED } from './transports.js';
|
|
11
|
+
// TODO support a SSE backend transport
|
|
12
|
+
export class BackendWebsocketTransport {
|
|
13
|
+
transport_name = 'backend_websocket_rpc';
|
|
14
|
+
// Map connection IDs to WebSocket contexts
|
|
15
|
+
#connections = new Map();
|
|
16
|
+
// Reverse map to find connection ID by socket
|
|
17
|
+
#connection_ids = new WeakMap();
|
|
18
|
+
// Session auth tracking — parallel maps keyed by connection ID
|
|
19
|
+
#connection_token_hashes = new Map();
|
|
20
|
+
#connection_account_ids = new Map();
|
|
21
|
+
/**
|
|
22
|
+
* Add a new WebSocket connection with auth info.
|
|
23
|
+
* Session connections pass a token hash for targeted revocation.
|
|
24
|
+
* Bearer token connections (api_token, daemon_token) pass null —
|
|
25
|
+
* they're still reachable via {@link close_sockets_for_account}.
|
|
26
|
+
*/
|
|
27
|
+
add_connection(ws, token_hash, account_id) {
|
|
28
|
+
const connection_id = create_uuid();
|
|
29
|
+
this.#connections.set(connection_id, ws);
|
|
30
|
+
this.#connection_ids.set(ws, connection_id);
|
|
31
|
+
if (token_hash !== null) {
|
|
32
|
+
this.#connection_token_hashes.set(connection_id, token_hash);
|
|
33
|
+
}
|
|
34
|
+
this.#connection_account_ids.set(connection_id, account_id);
|
|
35
|
+
return connection_id;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Remove a WebSocket connection and its auth tracking data.
|
|
39
|
+
* Idempotent — safe to call after revocation has already cleaned up.
|
|
40
|
+
*/
|
|
41
|
+
remove_connection(ws) {
|
|
42
|
+
const connection_id = this.#connection_ids.get(ws);
|
|
43
|
+
if (connection_id) {
|
|
44
|
+
this.#cleanup_connection(connection_id, ws);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Close all sockets associated with a specific session token hash.
|
|
49
|
+
*
|
|
50
|
+
* @returns the number of sockets closed
|
|
51
|
+
*/
|
|
52
|
+
close_sockets_for_session(token_hash) {
|
|
53
|
+
let count = 0;
|
|
54
|
+
for (const [connection_id, hash] of this.#connection_token_hashes) {
|
|
55
|
+
if (hash === token_hash) {
|
|
56
|
+
const ws = this.#connections.get(connection_id);
|
|
57
|
+
if (ws) {
|
|
58
|
+
this.#revoke_connection(connection_id, ws);
|
|
59
|
+
count++;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return count;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Close all sockets associated with a specific account.
|
|
67
|
+
*
|
|
68
|
+
* @returns the number of sockets closed
|
|
69
|
+
*/
|
|
70
|
+
close_sockets_for_account(account_id) {
|
|
71
|
+
let count = 0;
|
|
72
|
+
for (const [connection_id, id] of this.#connection_account_ids) {
|
|
73
|
+
if (id === account_id) {
|
|
74
|
+
const ws = this.#connections.get(connection_id);
|
|
75
|
+
if (ws) {
|
|
76
|
+
this.#revoke_connection(connection_id, ws);
|
|
77
|
+
count++;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return count;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Remove all tracking state for a connection.
|
|
85
|
+
*/
|
|
86
|
+
#cleanup_connection(connection_id, ws) {
|
|
87
|
+
this.#connections.delete(connection_id);
|
|
88
|
+
this.#connection_ids.delete(ws);
|
|
89
|
+
this.#connection_token_hashes.delete(connection_id);
|
|
90
|
+
this.#connection_account_ids.delete(connection_id);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Clean up a connection and close its socket with a revocation code.
|
|
94
|
+
*/
|
|
95
|
+
#revoke_connection(connection_id, ws) {
|
|
96
|
+
this.#cleanup_connection(connection_id, ws);
|
|
97
|
+
ws.close(WS_CLOSE_SESSION_REVOKED, 'Session revoked');
|
|
98
|
+
}
|
|
99
|
+
async send(message) {
|
|
100
|
+
// TODO currently just broadcasts all messages to all clients, the transport abstraction is still a WIP
|
|
101
|
+
if (is_jsonrpc_request(message)) {
|
|
102
|
+
return create_jsonrpc_error_response(message.id,
|
|
103
|
+
// TODO maybe use a not yet implemented error message?
|
|
104
|
+
jsonrpc_error_messages.internal_error('TODO not yet implemented - backend WebSocket transport cannot send requests expecting responses yet'));
|
|
105
|
+
}
|
|
106
|
+
try {
|
|
107
|
+
await this.#broadcast(message);
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
return create_jsonrpc_error_response(to_jsonrpc_message_id(message), jsonrpc_error_messages.internal_error(error instanceof Error ? error.message : 'failed to broadcast notification'));
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Broadcast a message to all connected clients.
|
|
116
|
+
*/
|
|
117
|
+
#broadcast(message) {
|
|
118
|
+
const serialized = JSON.stringify(message);
|
|
119
|
+
for (const ws of this.#connections.values()) {
|
|
120
|
+
try {
|
|
121
|
+
ws.send(serialized);
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
console.error('[backend websocket transport] Error broadcasting to client:', error);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
// TODO hack - remove if not ever needed, I assume this will need to be async so let's hold that assumption
|
|
128
|
+
return Promise.resolve();
|
|
129
|
+
}
|
|
130
|
+
is_ready() {
|
|
131
|
+
return this.#connections.size > 0;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
@@ -17,6 +17,8 @@
|
|
|
17
17
|
* @module
|
|
18
18
|
*/
|
|
19
19
|
import { type JsonrpcErrorCode, type JsonrpcErrorObject } from './jsonrpc.js';
|
|
20
|
+
/** Default message for unknown errors. */
|
|
21
|
+
export declare const UNKNOWN_ERROR_MESSAGE = "unknown error";
|
|
20
22
|
/** Names of standard and general application JSON-RPC error codes. */
|
|
21
23
|
export type JsonrpcErrorName = 'parse_error' | 'invalid_request' | 'method_not_found' | 'invalid_params' | 'internal_error' | 'unauthenticated' | 'forbidden' | 'not_found' | 'conflict' | 'validation_error' | 'rate_limited' | 'service_unavailable' | 'timeout';
|
|
22
24
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsonrpc_errors.d.ts","sourceRoot":"../src/lib/","s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Y;CAK3F;AAWD;;;;GAIG;AACH,eAAO,MAAM,cAAc;8CAXQ,kBAAkB;kDAAlB,kBAAkB;gFAAlB,kBAAkB;+EAAlB,kBAAkB;+EAAlB,kBAAkB;gFAAlB,kBAAkB;0EAAlB,kBAAkB;2EAAlB,kBAAkB;yEAAlB,kBAAkB;iFAAlB,kBAAkB;6EAAlB,kBAAkB;oFAAlB,kBAAkB;wEAAlB,kBAAkB;CAyBqC,CAAC;AAI3F;;;;;GAKG;AACH,eAAO,MAAM,iCAAiC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAcpE,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,iCAAiC,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAMzC,CAAC;AAEvC;;;;;;;;GAQG;AACH,eAAO,MAAM,iCAAiC,GAAI,MAAM,gBAAgB,KAAG,MAClB,CAAC;AAE1D;;;;;;;GAOG;AACH,eAAO,MAAM,iCAAiC,GAAI,QAAQ,MAAM,KAAG,gBACa,CAAC"}
|
|
@@ -17,6 +17,8 @@
|
|
|
17
17
|
* @module
|
|
18
18
|
*/
|
|
19
19
|
import { JSONRPC_PARSE_ERROR, JSONRPC_INVALID_REQUEST, JSONRPC_METHOD_NOT_FOUND, JSONRPC_INVALID_PARAMS, JSONRPC_INTERNAL_ERROR, } from './jsonrpc.js';
|
|
20
|
+
/** Default message for unknown errors. */
|
|
21
|
+
export const UNKNOWN_ERROR_MESSAGE = 'unknown error';
|
|
20
22
|
/**
|
|
21
23
|
* Standard JSON-RPC error codes (5) plus general application codes (8).
|
|
22
24
|
*
|
package/dist/http/surface.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* @module
|
|
8
8
|
*/
|
|
9
9
|
import { z } from 'zod';
|
|
10
|
-
import type {
|
|
10
|
+
import type { EventSpec } from '../realtime/sse.js';
|
|
11
11
|
import type { MiddlewareSpec } from './middleware_spec.js';
|
|
12
12
|
import type { RouteAuth, RouteSpec } from './route_spec.js';
|
|
13
13
|
import type { RateLimitKey, RouteErrorSchemas } from './error_schemas.js';
|
|
@@ -114,7 +114,7 @@ export interface GenerateAppSurfaceOptions {
|
|
|
114
114
|
route_specs: Array<RouteSpec>;
|
|
115
115
|
middleware_specs: Array<MiddlewareSpec>;
|
|
116
116
|
env_schema?: z.ZodObject;
|
|
117
|
-
event_specs?: Array<
|
|
117
|
+
event_specs?: Array<EventSpec>;
|
|
118
118
|
rpc_endpoints?: Array<RpcEndpointSpec>;
|
|
119
119
|
}
|
|
120
120
|
/**
|
|
@@ -138,7 +138,7 @@ export declare const env_schema_to_surface: (schema: z.ZodObject) => Array<AppSu
|
|
|
138
138
|
* @param event_specs - event specs to convert
|
|
139
139
|
* @returns array of event surface entries
|
|
140
140
|
*/
|
|
141
|
-
export declare const events_to_surface: (event_specs: Array<
|
|
141
|
+
export declare const events_to_surface: (event_specs: Array<EventSpec>) => Array<AppSurfaceEvent>;
|
|
142
142
|
/**
|
|
143
143
|
* Generate a JSON-serializable attack surface from middleware, route specs,
|
|
144
144
|
* and optional env/event metadata.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"surface.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/http/surface.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB,OAAO,KAAK,EAAC,
|
|
1
|
+
{"version":3,"file":"surface.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/http/surface.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAC,SAAS,EAAE,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAC1D,OAAO,KA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AAC;IACxC,aAAa,EAAE,KAAK,CAAC,eAAe,CAAC,CAAC;CACtC;AAED,yDAAyD;AACzD,MAAM,WAAW,eAAe;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;CAC1B;AAED,0CAA0C;AAC1C,MAAM,WAAW,yBAAyB;IACzC,WAAW,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;IAC9B,gBAAgB,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;IACxC,UAAU,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC;IACzB,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;IAC/B,aAAa,CAAC,EAAE,KAAK,CAAC,eAAe,CAAC,CAAC;CACvC;AAID;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB,GACrC,YAAY,KAAK,CAAC,cAAc,CAAC,EACjC,YAAY,MAAM,KAChB,iBAAiB,GAAG,IAQtB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,GAAI,QAAQ,CAAC,CAAC,SAAS,KAAG,KAAK,CAAC,aAAa,CAe9E,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAAI,aAAa,KAAK,CAAC,SAAS,CAAC,KAAG,KAAK,CAAC,eAAe,CAOtF,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,GAAI,SAAS,yBAAyB,KAAG,UAwFzE,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,GAAI,SAAS,yBAAyB,KAAG,cAQ5E,CAAC"}
|
package/dist/realtime/sse.d.ts
CHANGED
|
@@ -55,13 +55,15 @@ export declare const create_sse_response: <T = unknown>(c: Context, log: Logger)
|
|
|
55
55
|
};
|
|
56
56
|
/** SSE comment sent on connect to flush headers through proxies. Exported for test assertions. */
|
|
57
57
|
export declare const SSE_CONNECTED_COMMENT = ": connected\n\n";
|
|
58
|
-
/** Spec for
|
|
59
|
-
export interface
|
|
58
|
+
/** Spec for a push event — declares params schema, description, and channel. */
|
|
59
|
+
export interface EventSpec {
|
|
60
60
|
method: string;
|
|
61
61
|
params: z.ZodType;
|
|
62
62
|
description: string;
|
|
63
63
|
channel?: string;
|
|
64
64
|
}
|
|
65
|
+
/** @deprecated Use `EventSpec` instead. */
|
|
66
|
+
export type SseEventSpec = EventSpec;
|
|
65
67
|
/**
|
|
66
68
|
* Create a broadcaster that validates events in DEV mode.
|
|
67
69
|
*
|
|
@@ -74,7 +76,7 @@ export interface SseEventSpec {
|
|
|
74
76
|
*/
|
|
75
77
|
export declare const create_validated_broadcaster: <T extends SseNotification>(broadcaster: {
|
|
76
78
|
broadcast: (channel: string, data: T) => void;
|
|
77
|
-
}, event_specs: Array<
|
|
79
|
+
}, event_specs: Array<EventSpec>, log: Logger) => {
|
|
78
80
|
broadcast: (channel: string, data: T) => void;
|
|
79
81
|
};
|
|
80
82
|
//# sourceMappingURL=sse.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sse.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/realtime/sse.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,MAAM,CAAC;AAElC,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,yBAAyB,CAAC;AAEpD;;;;GAIG;AACH,MAAM,WAAW,SAAS,CAAC,CAAC,GAAG,OAAO;IACrC,mDAAmD;IACnD,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,CAAC;IACxB,6CAA6C;IAC7C,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,wBAAwB;IACxB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,+FAA+F;IAC/F,QAAQ,EAAE,CAAC,EAAE,EAAE,M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;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,mBAAmB,GAAI,CAAC,GAAG,OAAO,EAC9C,GAAG,OAAO,EACV,KAAK,MAAM,KACT;IAAC,QAAQ,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,CAAA;CAiD3C,CAAC;AAEF,kGAAkG;AAClG,eAAO,MAAM,qBAAqB,oBAAoB,CAAC;AAEvD,gFAAgF;AAChF,MAAM,WAAW,SAAS;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,2CAA2C;AAC3C,MAAM,MAAM,YAAY,GAAG,SAAS,CAAC;AAErC;;;;;;;;;GASG;AACH,eAAO,MAAM,4BAA4B,GAAI,CAAC,SAAS,eAAe,EACrE,aAAa;IAAC,SAAS,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,KAAK,IAAI,CAAA;CAAC,EAC5D,aAAa,KAAK,CAAC,SAAS,CAAC,EAC7B,KAAK,MAAM,KACT;IAAC,SAAS,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,KAAK,IAAI,CAAA;CAmBhD,CAAC"}
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
import type { Logger } from '@fuzdev/fuz_util/log.js';
|
|
14
14
|
import { type AuditLogEvent } from '../auth/audit_log_schema.js';
|
|
15
15
|
import { SubscriberRegistry } from './subscriber_registry.js';
|
|
16
|
-
import type { SseStream, SseNotification,
|
|
16
|
+
import type { SseStream, SseNotification, EventSpec } from './sse.js';
|
|
17
17
|
/**
|
|
18
18
|
* Audit event types that trigger SSE stream disconnection.
|
|
19
19
|
*
|
|
@@ -84,7 +84,7 @@ export interface AuditLogSse {
|
|
|
84
84
|
* One spec per `AUDIT_EVENT_TYPES` entry, all sharing the `AuditLogEventJson` params schema.
|
|
85
85
|
* Pass to `create_app_server`'s `event_specs` for surface generation and DEV validation.
|
|
86
86
|
*/
|
|
87
|
-
export declare const AUDIT_LOG_EVENT_SPECS: Array<
|
|
87
|
+
export declare const AUDIT_LOG_EVENT_SPECS: Array<EventSpec>;
|
|
88
88
|
export declare const create_audit_log_sse: (options: {
|
|
89
89
|
/** Role required to access the SSE endpoint. Default `'admin'`. */
|
|
90
90
|
role?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sse_auth_guard.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/realtime/sse_auth_guard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,yBAAyB,CAAC;AAEpD,OAAO,EAGN,KAAK,aAAa,EAClB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAC,kBAAkB,EAAC,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAC,SAAS,EAAE,eAAe,EAAE,
|
|
1
|
+
{"version":3,"file":"sse_auth_guard.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/realtime/sse_auth_guard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,yBAAyB,CAAC;AAEpD,OAAO,EAGN,KAAK,aAAa,EAClB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAC,kBAAkB,EAAC,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAC,SAAS,EAAE,eAAe,EAAE,SAAS,EAAC,MAAM,UAAU,CAAC;AAEpE;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,EAAE,WAAW,CAAC,MAAM,CAIrD,CAAC;AAEH;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,qBAAqB,GAAI,CAAC,EACtC,UAAU,kBAAkB,CAAC,CAAC,CAAC,EAC/B,eAAe,MAAM,EACrB,KAAK,MAAM,KACT,CAAC,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAqBjC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC3B,8FAA8F;IAC9F,SAAS,EAAE,CACV,MAAM,EAAE,SAAS,CAAC,eAAe,CAAC,EAClC,QAAQ,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,EACxB,QAAQ,CAAC,EAAE,MAAM,KACb,MAAM,IAAI,CAAC;IAChB,kFAAkF;IAClF,GAAG,EAAE,MAAM,CAAC;IACZ,kGAAkG;IAClG,cAAc,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IAC/C,yEAAyE;IACzE,QAAQ,EAAE,kBAAkB,CAAC,eAAe,CAAC,CAAC;CAC9C;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,EAAE,KAAK,CAAC,SAAS,CAOlD,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,SAAS;IAC7C,mEAAmE;IACnE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACZ,KAAG,WAcH,CAAC"}
|
|
@@ -12,7 +12,7 @@ import { Hono, type Context } from 'hono';
|
|
|
12
12
|
import { z } from 'zod';
|
|
13
13
|
import { type SessionOptions } from '../auth/session_cookie.js';
|
|
14
14
|
import type { BootstrapAccountSuccess } from '../auth/bootstrap_account.js';
|
|
15
|
-
import type {
|
|
15
|
+
import type { EventSpec } from '../realtime/sse.js';
|
|
16
16
|
import { type AuditLogSse } from '../realtime/sse_auth_guard.js';
|
|
17
17
|
import type { AppSettings } from '../auth/app_settings_schema.js';
|
|
18
18
|
import { type RateLimiter } from '../rate_limiter.js';
|
|
@@ -128,7 +128,7 @@ export interface AppServerOptions {
|
|
|
128
128
|
role?: string;
|
|
129
129
|
};
|
|
130
130
|
/** SSE event specs for surface generation. Defaults to `[]` (no SSE events). */
|
|
131
|
-
event_specs?: Array<
|
|
131
|
+
event_specs?: Array<EventSpec>;
|
|
132
132
|
/** RPC endpoint specs for surface generation. */
|
|
133
133
|
rpc_endpoints?: Array<RpcEndpointSpec>;
|
|
134
134
|
/** Env schema for surface generation. Pass `z.object({})` when there are no env vars beyond `BaseServerEnv`. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app_server.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/server/app_server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAC,IAAI,EAAE,KAAK,OAAO,EAAC,MAAM,MAAM,CAAC;AAGxC,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB,OAAO,EAEN,KAAK,cAAc,EAEnB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAC,uBAAuB,EAAC,MAAM,8BAA8B,CAAC;AAC1E,OAAO,KAAK,EAAC,
|
|
1
|
+
{"version":3,"file":"app_server.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/server/app_server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAC,IAAI,EAAE,KAAK,OAAO,EAAC,MAAM,MAAM,CAAC;AAGxC,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB,OAAO,EAEN,KAAK,cAAc,EAEnB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAC,uBAAuB,EAAC,MAAM,8BAA8B,CAAC;AAC1E,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAGN,KAAK,WAAW,EAChB,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,gCAAgC,CAAC;AAEhE,OAAO,EAGN,KAAK,WAAW,EAChB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,yBAAyB,CAAC;AAC9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jD;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,GAAU,SAAS,gBAAgB,KAAG,OAAO,CAAC,SAAS,CA6PpF,CAAC"}
|
package/dist/testing/stubs.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import type { AppServerContext } from '../server/app_server.js';
|
|
|
7
7
|
import { Db } from '../db/db.js';
|
|
8
8
|
import { type RouteSpec } from '../http/route_spec.js';
|
|
9
9
|
import { type AppSurfaceSpec, type RpcEndpointSpec } from '../http/surface.js';
|
|
10
|
-
import type {
|
|
10
|
+
import type { EventSpec } from '../realtime/sse.js';
|
|
11
11
|
/**
|
|
12
12
|
* Create a Proxy that throws descriptive errors on any property access or method call.
|
|
13
13
|
*
|
|
@@ -75,7 +75,7 @@ export interface CreateTestAppSurfaceSpecOptions {
|
|
|
75
75
|
/** Env schema for surface generation (default: `BaseServerEnv`). */
|
|
76
76
|
env_schema?: z.ZodObject;
|
|
77
77
|
/** SSE event specs for surface generation. */
|
|
78
|
-
event_specs?: Array<
|
|
78
|
+
event_specs?: Array<EventSpec>;
|
|
79
79
|
/** RPC endpoint specs for surface generation. */
|
|
80
80
|
rpc_endpoints?: Array<RpcEndpointSpec>;
|
|
81
81
|
/** Transform middleware array (e.g., tx's `extend_middleware_for_tx_binary`). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stubs.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/stubs.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAa7B,OAAO,KAAK,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAE3B,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,4BAA4B,CAAC;AAE/D,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,yBAAyB,CAAC;AAC9D,OAAO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uuid.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UUID utilities — branded Zod schema and factory function.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
export declare const create_uuid: () => Uuid;
|
|
8
|
+
export declare const Uuid: z.core.$ZodBranded<z.ZodUUID, "Uuid", "out">;
|
|
9
|
+
export type Uuid = z.infer<typeof Uuid>;
|
|
10
|
+
export declare const UuidWithDefault: z.ZodDefault<z.core.$ZodBranded<z.ZodUUID, "Uuid", "out">>;
|
|
11
|
+
export type UuidWithDefault = z.infer<typeof UuidWithDefault>;
|
|
12
|
+
//# sourceMappingURL=uuid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uuid.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/uuid.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB,eAAO,MAAM,WAAW,QAAO,IAAmC,CAAC;AAEnE,eAAO,MAAM,IAAI,8CAAyB,CAAC;AAC3C,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;AACxC,eAAO,MAAM,eAAe,4DAA4B,CAAC;AACzD,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC"}
|
package/dist/uuid.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UUID utilities — branded Zod schema and factory function.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
export const create_uuid = () => crypto.randomUUID();
|
|
8
|
+
export const Uuid = z.uuid().brand('Uuid');
|
|
9
|
+
export const UuidWithDefault = Uuid.default(create_uuid);
|