akanjs 3.3.0-rc.64 → 3.3.0-rc.65

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.
@@ -32,6 +32,8 @@ export interface WebsocketHeartbeatAckData {
32
32
  export const websocketCredentialContract = {
33
33
  expiredCode: 4401,
34
34
  expiredReason: "credential expired",
35
+
36
+ revokedReason: "credential revoked",
35
37
  expiresAtOf: (jwt: string): number | null => {
36
38
  try {
37
39
  const { exp } = decodeJwtPayload<{ exp?: unknown }>(jwt);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "akanjs",
3
- "version": "3.3.0-rc.64",
3
+ "version": "3.3.0-rc.65",
4
4
  "sourceType": "module",
5
5
  "type": "module",
6
6
  "publishConfig": {
package/server/akanApp.ts CHANGED
@@ -313,6 +313,9 @@ export class AkanApp {
313
313
  case "live.models":
314
314
  this.#rooms.setLiveModels(idx, message.models);
315
315
  return;
316
+ case "ws.revoke":
317
+ this.#children.fanoutToFederation(message, idx);
318
+ return;
316
319
  case "metrics.report":
317
320
  this.#children.updateMetrics(idx, message.metrics);
318
321
  return;
@@ -32,6 +32,7 @@ import { BuiltinRoutes } from "./routing/builtinRoutes";
32
32
  import { RouteHosts } from "./routing/routeHosts";
33
33
  import { type AkanAppPrepared, ServerListener } from "./routing/serverListener";
34
34
  import type { WebSurfaceHold } from "./routing/webSurfaceHold";
35
+ import { WsCredentialRevocation } from "./routing/wsCredentialRevocation";
35
36
  import { ServerConfig } from "./serverConfig";
36
37
  import { ServerMetrics } from "./serverMetrics";
37
38
  import { SessionRefresh } from "./sessionRefresh";
@@ -525,12 +526,14 @@ export class AkanServer {
525
526
  if (shouldListen) return this.listen();
526
527
  return await this.#start.unwound(async () => {
527
528
  const websocket = this.#di.getWebsocketAdaptor();
528
- if (websocket)
529
+ if (websocket) {
529
530
  SignalResolver.setLocalPublish(
530
531
  (roomId, data) => this.#listener.publishLocal(roomId, data),
531
532
  websocket,
532
533
  this.#di.live,
533
534
  );
535
+ WsCredentialRevocation.use(websocket);
536
+ }
534
537
  this.status = "running";
535
538
  if (isNoListenCommand) return this;
536
539
  Logger.role = this.serverMode;
package/server/index.ts CHANGED
@@ -250,6 +250,7 @@ export {
250
250
  type RemoteSourceProps,
251
251
  type RemoteTokens,
252
252
  } from "./remote";
253
+ export { WsCredentialRevocation } from "./routing/wsCredentialRevocation";
253
254
  export type { SessionRefreshHook } from "./sessionRefresh";
254
255
 
255
256
  export {
@@ -22,6 +22,7 @@ import { DevSurfacePolicy } from "./devSurfacePolicy";
22
22
  import type { HostAllowlist } from "./hostAllowlist";
23
23
  import { ServerLimits } from "./serverLimits";
24
24
  import { WsCredentialExpiry } from "./wsCredentialExpiry";
25
+ import { WsCredentialRevocation } from "./wsCredentialRevocation";
25
26
  import { WsUpgrade } from "./wsUpgrade";
26
27
 
27
28
  export interface HmrStateSource {
@@ -183,6 +184,7 @@ export class ApiRouter {
183
184
  }
184
185
  SignalResolver.handleWsOpen(ws, registry);
185
186
  WsCredentialExpiry.watch(ws);
187
+ WsCredentialRevocation.track(ws);
186
188
  },
187
189
  message: async (ws, message) => {
188
190
  const data = ws.data as WsTaggedData | undefined;
@@ -249,6 +251,7 @@ export class ApiRouter {
249
251
  return;
250
252
  }
251
253
  WsCredentialExpiry.unwatch(ws);
254
+ WsCredentialRevocation.untrack(ws);
252
255
  SignalResolver.handleWsClose(ws, registry, live);
253
256
  },
254
257
  };
@@ -57,8 +57,11 @@ export class AppWsData {
57
57
  return TrustedProxy.clientAddress(this.headers, ws.remoteAddress);
58
58
  }
59
59
 
60
+ credentialToken(): string | null {
61
+ return bearerTokenOf(this.headers.get("authorization")) ?? readSessionToken(this.jar).token ?? null;
62
+ }
60
63
  credentialExpiresAt(): number | null {
61
- const token = bearerTokenOf(this.headers.get("authorization")) ?? readSessionToken(this.jar).token;
64
+ const token = this.credentialToken();
62
65
  return token ? websocketCredentialContract.expiresAtOf(token) : null;
63
66
  }
64
67
  constructor(headers: Headers) {
@@ -19,6 +19,7 @@ import { localRoomsOf } from "./localRooms";
19
19
  import { RoomReplay } from "./roomReplay";
20
20
  import { ServerLimits } from "./serverLimits";
21
21
  import type { WebSurfaceHold } from "./webSurfaceHold";
22
+ import { WsCredentialRevocation } from "./wsCredentialRevocation";
22
23
 
23
24
  export interface AkanAppPrepared {
24
25
  routes: SignalRoutes["routes"];
@@ -255,6 +256,7 @@ export class ServerListener {
255
256
  coalesces: (roomId) => SignalResolver.coalescesRoom(roomId),
256
257
  });
257
258
  SignalResolver.setLocalPublish(rooms.publish, websocket, this.#di.live, roomReplay, rooms.resync);
259
+ WsCredentialRevocation.use(websocket);
258
260
  this.#localPublish = rooms.publish;
259
261
  this.#roomReplay = roomReplay;
260
262
  this.#websocket = websocket;
@@ -0,0 +1,55 @@
1
+ import { decodeJwtPayload, websocketCredentialContract } from "akanjs/common";
2
+ import type { WebsocketAdaptor, WsCredentialClaims } from "akanjs/service";
3
+ import { AppWsData } from "./appWsData";
4
+
5
+ export class WsCredentialRevocation {
6
+ static readonly #sockets = new Set<Bun.ServerWebSocket<unknown>>();
7
+ static #websocket: WebsocketAdaptor | null = null;
8
+
9
+ static use(websocket: WebsocketAdaptor) {
10
+ WsCredentialRevocation.#websocket = websocket;
11
+ websocket.onRevocation?.((claims) => WsCredentialRevocation.#closeMatching(claims));
12
+ }
13
+
14
+ static track(ws: Bun.ServerWebSocket<unknown>) {
15
+ WsCredentialRevocation.#sockets.add(ws);
16
+ }
17
+
18
+ static untrack(ws: Bun.ServerWebSocket<unknown>) {
19
+ WsCredentialRevocation.#sockets.delete(ws);
20
+ }
21
+
22
+ /**
23
+ * Closes, on every server of the app, each socket whose credential carries one of the values under one of the
24
+ * claims, with the code a client renews and reconnects on. Its frames already answer to the account middleware;
25
+ * what this ends is the broadcasts to the rooms it joined before.
26
+ */
27
+ static revoke(claims: WsCredentialClaims) {
28
+ if (!Object.values(claims).some((values) => values.length)) return;
29
+ WsCredentialRevocation.#closeMatching(claims);
30
+ WsCredentialRevocation.#websocket?.publishRevocation?.(claims);
31
+ }
32
+
33
+ static #closeMatching(claims: WsCredentialClaims) {
34
+ const revoked = Object.entries(claims).map(([claim, values]) => [claim, new Set(values)] as const);
35
+ for (const ws of WsCredentialRevocation.#sockets) {
36
+ const token = AppWsData.of(ws).credentialToken();
37
+ const payload = token ? WsCredentialRevocation.#payloadOf(token) : null;
38
+ if (!payload) continue;
39
+ const matches = revoked.some(([claim, values]) => {
40
+ const value = payload[claim];
41
+ return typeof value === "string" && values.has(value);
42
+ });
43
+ if (matches) ws.close(websocketCredentialContract.expiredCode, websocketCredentialContract.revokedReason);
44
+ }
45
+ }
46
+
47
+ static #payloadOf(token: string): Record<string, unknown> | null {
48
+ try {
49
+ const payload = decodeJwtPayload<unknown>(token);
50
+ return payload && typeof payload === "object" ? (payload as Record<string, unknown>) : null;
51
+ } catch {
52
+ return null;
53
+ }
54
+ }
55
+ }
@@ -1,5 +1,5 @@
1
1
  import type { LogRecord } from "akanjs/common";
2
- import type { LiveChange } from "./predefinedAdaptor/websocket.adaptor";
2
+ import type { LiveChange, WsCredentialClaims } from "./predefinedAdaptor/websocket.adaptor";
3
3
 
4
4
  export type AkanChildRole = "all" | "federation" | "batch";
5
5
 
@@ -218,6 +218,7 @@ export type AkanIpcMessage =
218
218
  | { type: "pubsub.snapshot.request" }
219
219
  | { type: "pubsub.snapshot"; rooms: string[]; liveModels?: string[]; pid?: number }
220
220
  | { type: "live.change"; change: LiveChange; origin?: string }
221
+ | { type: "ws.revoke"; claims: WsCredentialClaims; origin?: string }
221
222
  /** Child → gateway: every model the child holds live rooms for. */
222
223
  | { type: "live.models"; models: string[]; pid?: number }
223
224
  | { type: "queue.enqueued"; queue: string; name: string; jobId: string }
@@ -5,6 +5,7 @@ import type {
5
5
  LiveChange,
6
6
  LiveChangeHandler,
7
7
  WebsocketAdaptor,
8
+ WsCredentialClaims,
8
9
  WsRedisEventHandler,
9
10
  WsSocketData,
10
11
  } from "./websocket.adaptor";
@@ -34,6 +35,7 @@ export class SolidPubSub
34
35
  #lastAck = 0;
35
36
  #eventHandler: WsRedisEventHandler | null = null;
36
37
  #changeHandler: LiveChangeHandler | null = null;
38
+ #revocationHandler: ((claims: WsCredentialClaims) => void) | null = null;
37
39
  #liveModels: string[] = [];
38
40
  readonly #messageHandler = (message: unknown) => {
39
41
  if (!message || typeof message !== "object") return;
@@ -43,6 +45,7 @@ export class SolidPubSub
43
45
  data?: unknown;
44
46
  origin?: string;
45
47
  change?: LiveChange;
48
+ claims?: WsCredentialClaims;
46
49
  ack?: number;
47
50
  };
48
51
  if (data.type === "pubsub.subscribed" && data.ack !== undefined) {
@@ -57,6 +60,10 @@ export class SolidPubSub
57
60
  this.#changeHandler?.(data.change);
58
61
  return;
59
62
  }
63
+ if (data.type === "ws.revoke" && data.claims && data.origin !== this.serverId) {
64
+ this.#revocationHandler?.(data.claims);
65
+ return;
66
+ }
60
67
  if (data.type === "pubsub.snapshot.request") {
61
68
  sendAkanIpc({
62
69
  type: "pubsub.snapshot",
@@ -77,6 +84,7 @@ export class SolidPubSub
77
84
  this.#acks.clear();
78
85
  this.#eventHandler = null;
79
86
  this.#changeHandler = null;
87
+ this.#revocationHandler = null;
80
88
  this.#liveModels = [];
81
89
  this.#socketRooms.clear();
82
90
  }
@@ -93,6 +101,14 @@ export class SolidPubSub
93
101
  this.#changeHandler = handler;
94
102
  }
95
103
 
104
+ publishRevocation(claims: WsCredentialClaims): void {
105
+ sendAkanIpc({ type: "ws.revoke", claims, origin: this.serverId });
106
+ }
107
+
108
+ onRevocation(handler: (claims: WsCredentialClaims) => void): void {
109
+ this.#revocationHandler = handler;
110
+ }
111
+
96
112
  reportLiveModels(models: string[]): void {
97
113
  this.#liveModels = models;
98
114
  sendAkanIpc({ type: "live.models", models, pid: process.pid });
@@ -18,6 +18,9 @@ export interface LiveChange {
18
18
  }
19
19
  export type LiveChangeHandler = (change: LiveChange) => void;
20
20
 
21
+ /** Claim name to values: a socket whose credential carries any one of them is closed. */
22
+ export type WsCredentialClaims = Record<string, string[]>;
23
+
21
24
  export interface WebsocketPublishOption {
22
25
  /** Only the newest frame for the room matters, so an undelivered older one may be dropped for it. */
23
26
  coalesce?: boolean;
@@ -44,6 +47,9 @@ export interface WebsocketAdaptor {
44
47
  onChange?(handler: LiveChangeHandler): void;
45
48
  /** The models this server holds live rooms for, each time that changes, so changes to the rest pass it by. */
46
49
  reportLiveModels?(models: string[]): void;
50
+ /** To the app's other servers, each closing its own sockets whose credential carries one of the claims. */
51
+ publishRevocation?(claims: WsCredentialClaims): void;
52
+ onRevocation?(handler: (claims: WsCredentialClaims) => void): void;
47
53
  /** Resolves once what another server publishes to the room reaches this one, or sooner if that link is down or stalls. */
48
54
  joinRoom(ws: Bun.ServerWebSocket<unknown>, room: string, option?: WebsocketJoinOption): Promise<void>;
49
55
  leaveRoom(ws: Bun.ServerWebSocket<unknown>, room: string): Promise<void>;
@@ -67,6 +73,13 @@ interface HeldRoom {
67
73
  channel: string;
68
74
  }
69
75
 
76
+ interface RedisHandlers {
77
+ event: WsRedisEventHandler | null;
78
+ change: LiveChangeHandler | null;
79
+ recovery: ((rooms: string[]) => void) | null;
80
+ revocation: ((claims: WsCredentialClaims) => void) | null;
81
+ }
82
+
70
83
  interface ChannelHold {
71
84
  rooms: number;
72
85
  reply?: Promise<void>;
@@ -92,7 +105,7 @@ export class WebSocketRedisAdaptor
92
105
  {
93
106
 
94
107
  static readonly #version = 1;
95
- static readonly #kind = { json: 0x6a, bytes: 0x62, change: 0x63 } as const;
108
+ static readonly #kind = { json: 0x6a, bytes: 0x62, change: 0x63, revoke: 0x72 } as const;
96
109
 
97
110
  static readonly #shards = 16_384;
98
111
 
@@ -102,9 +115,7 @@ export class WebSocketRedisAdaptor
102
115
  readonly #rooms = new Map<string, HeldRoom>();
103
116
  readonly #socketRooms = new Map<string, Set<string>>();
104
117
  readonly #channels = new Map<string, ChannelHold>();
105
- #eventHandler: WsRedisEventHandler | null = null;
106
- #changeHandler: LiveChangeHandler | null = null;
107
- #recoveryHandler: ((rooms: string[]) => void) | null = null;
118
+ readonly #handlers: RedisHandlers = { event: null, change: null, recovery: null, revocation: null };
108
119
  #publisherReady = false;
109
120
  #draining = false;
110
121
  #drained: Promise<void> = Promise.resolve();
@@ -130,6 +141,10 @@ export class WebSocketRedisAdaptor
130
141
  return `${this.channelPrefix}ws:change:${refName}`;
131
142
  }
132
143
 
144
+ get #revocationChannel() {
145
+ return `${this.channelPrefix}ws:revoke`;
146
+ }
147
+
133
148
  override async onInit() {
134
149
 
135
150
  this.publisher.on("ready", () => {
@@ -165,6 +180,7 @@ export class WebSocketRedisAdaptor
165
180
  if (this.#destroyed) return;
166
181
 
167
182
  const replies = [...this.#channels].map(([channel, hold]) => this.#subscribe(channel, hold));
183
+ if (this.#handlers.revocation) this.#subscribeRevocations();
168
184
  const recovering = !this.#subscriberReady && this.#subscriberStarted && this.#channels.size > 0;
169
185
  this.#subscriberReady = true;
170
186
  this.#subscriberStarted = true;
@@ -173,7 +189,7 @@ export class WebSocketRedisAdaptor
173
189
 
174
190
  let lost = false;
175
191
  const recover = () => {
176
- if (!lost) this.#recoveryHandler?.([...this.#rooms.keys()]);
192
+ if (!lost) this.#handlers.recovery?.([...this.#rooms.keys()]);
177
193
  };
178
194
  const timer = setTimeout(recover, WebSocketRedisAdaptor.#subscribeTimeoutMs);
179
195
  const lose = () => {
@@ -221,9 +237,7 @@ export class WebSocketRedisAdaptor
221
237
 
222
238
  if (this.publisher.status !== "end") this.publisher.disconnect();
223
239
  }
224
- this.#eventHandler = null;
225
- this.#changeHandler = null;
226
- this.#recoveryHandler = null;
240
+ Object.assign(this.#handlers, { event: null, change: null, recovery: null, revocation: null });
227
241
  this.#rooms.clear();
228
242
  this.#socketRooms.clear();
229
243
  this.#channels.clear();
@@ -257,7 +271,28 @@ export class WebSocketRedisAdaptor
257
271
  }
258
272
 
259
273
  onChange(handler: LiveChangeHandler): void {
260
- this.#changeHandler = handler;
274
+ this.#handlers.change = handler;
275
+ }
276
+
277
+ publishRevocation(claims: WsCredentialClaims): void {
278
+ this.#send({
279
+ channel: this.#revocationChannel,
280
+ roomId: "",
281
+ message: this.#pack("revoke", "", JSON.stringify(claims)),
282
+ coalesce: false,
283
+ seq: this.#sent++,
284
+ });
285
+ }
286
+
287
+ onRevocation(handler: (claims: WsCredentialClaims) => void): void {
288
+ this.#handlers.revocation = handler;
289
+ if (this.#subscriberReady) this.#subscribeRevocations();
290
+ }
291
+
292
+ #subscribeRevocations() {
293
+ this.subscriber.subscribe(this.#revocationChannel).catch((err: Error) => {
294
+ this.logger.warn(`Subscribe to ${this.#revocationChannel} failed: ${err.message}`);
295
+ });
261
296
  }
262
297
 
263
298
  #send(buffered: BufferedMessage) {
@@ -275,15 +310,15 @@ export class WebSocketRedisAdaptor
275
310
  }
276
311
 
277
312
  setEventHandler(handler: WsRedisEventHandler): void {
278
- this.#eventHandler = handler;
313
+ this.#handlers.event = handler;
279
314
  }
280
315
 
281
316
  clearEventHandler(): void {
282
- this.#eventHandler = null;
317
+ this.#handlers.event = null;
283
318
  }
284
319
 
285
320
  onRecovered(handler: (rooms: string[]) => void): void {
286
- this.#recoveryHandler = handler;
321
+ this.#handlers.recovery = handler;
287
322
  }
288
323
 
289
324
  async joinRoom(ws: Bun.ServerWebSocket<unknown>, room: string, { live }: WebsocketJoinOption = {}): Promise<void> {
@@ -399,22 +434,27 @@ export class WebSocketRedisAdaptor
399
434
  const unpacked = this.#unpack(message);
400
435
  if (!unpacked || unpacked.origin === this.serverId) return;
401
436
  if (unpacked.kind === WebSocketRedisAdaptor.#kind.change) {
402
- this.#changeHandler?.(JSON.parse(unpacked.payload.toString()) as LiveChange);
437
+ this.#handlers.change?.(JSON.parse(unpacked.payload.toString()) as LiveChange);
438
+ return;
439
+ }
440
+ if (unpacked.kind === WebSocketRedisAdaptor.#kind.revoke) {
441
+ this.#handlers.revocation?.(JSON.parse(unpacked.payload.toString()) as WsCredentialClaims);
403
442
  return;
404
443
  }
405
444
 
406
- if (!this.#eventHandler || !this.#rooms.has(unpacked.roomId)) return;
445
+ const handleEvent = this.#handlers.event;
446
+ if (!handleEvent || !this.#rooms.has(unpacked.roomId)) return;
407
447
  const data =
408
448
  unpacked.kind === WebSocketRedisAdaptor.#kind.bytes
409
449
  ? new Uint8Array(unpacked.payload)
410
450
  : (JSON.parse(unpacked.payload.toString()) as unknown);
411
- this.#eventHandler(unpacked.roomId, data);
451
+ handleEvent(unpacked.roomId, data);
412
452
  } catch (err) {
413
453
  this.logger.warn(`Failed to handle Redis WS message: ${err instanceof Error ? err.message : String(err)}`);
414
454
  }
415
455
  }
416
456
 
417
- #pack(kind: "json" | "bytes" | "change", roomId: string, payload: string | Uint8Array): Buffer {
457
+ #pack(kind: "json" | "bytes" | "change" | "revoke", roomId: string, payload: string | Uint8Array): Buffer {
418
458
  const origin = Buffer.from(this.serverId, "utf-8");
419
459
  const room = Buffer.from(roomId, "utf-8");
420
460
  const header = Buffer.alloc(2 + 2 + origin.length + 2 + room.length);
@@ -22,6 +22,7 @@ export interface WebsocketHeartbeatAckData {
22
22
  export declare const websocketCredentialContract: {
23
23
  readonly expiredCode: 4401;
24
24
  readonly expiredReason: "credential expired";
25
+ readonly revokedReason: "credential revoked";
25
26
  readonly expiresAtOf: (jwt: string) => number | null;
26
27
  };
27
28
  export declare const websocketHeartbeatContract: {
@@ -19,6 +19,7 @@ export { type OAuthAddressLookup, OAuthAuthorize, type OAuthAuthorizeContext, ty
19
19
  export { ProcessMetricsCollector } from "./processMetricsCollector.d.ts";
20
20
  export { AkanResponse, copyBunRequestFields, HostBasePathWebProxy, LocaleWebProxy, type WebProxy, type WebProxyCls, type WebProxyMatcher, type WebProxyNextInit, type WebProxyRegistration, type WebProxyResult, type WebProxyReturn, WebProxyRunner, type WebProxyRunResult, } from "./proxy.d.ts";
21
21
  export { type RemoteAccess, type RemoteAddressLookup, type RemoteAuthServer, type RemoteClient, RemoteError, type RemoteErrorCode, RemoteFetch, type RemoteFetchOptions, RemoteMcp, type RemoteMcpCallResult, type RemoteMcpContent, type RemoteMcpOptions, type RemoteMcpTool, RemoteOAuth, type RemoteRequest, type RemoteResponse, type RemoteScreen, RemoteSource, type RemoteSourceProps, type RemoteTokens, } from "./remote.d.ts";
22
+ export { WsCredentialRevocation } from "./routing/wsCredentialRevocation.d.ts";
22
23
  export type { SessionRefreshHook } from "./sessionRefresh.d.ts";
23
24
  export { createDefaultSitemapUrls, createDefaultSitemapXml, createSitemapXml, type DefaultSitemapOptions, getSitemapBasePath, } from "./sitemap.d.ts";
24
25
  export type { SsrManifest, SsrManifestEntry } from "./ssrTypes.d.ts";
@@ -17,6 +17,7 @@ export declare class AppWsData {
17
17
  get ip(): string | null;
18
18
  get port(): number | null;
19
19
  ipOf(ws: Bun.ServerWebSocket<unknown>): string | null;
20
+ credentialToken(): string | null;
20
21
  credentialExpiresAt(): number | null;
21
22
  constructor(headers: Headers);
22
23
  }
@@ -0,0 +1,13 @@
1
+ import type { WebsocketAdaptor, WsCredentialClaims } from "akanjs/service";
2
+ export declare class WsCredentialRevocation {
3
+ #private;
4
+ static use(websocket: WebsocketAdaptor): void;
5
+ static track(ws: Bun.ServerWebSocket<unknown>): void;
6
+ static untrack(ws: Bun.ServerWebSocket<unknown>): void;
7
+ /**
8
+ * Closes, on every server of the app, each socket whose credential carries one of the values under one of the
9
+ * claims, with the code a client renews and reconnects on. Its frames already answer to the account middleware;
10
+ * what this ends is the broadcasts to the rooms it joined before.
11
+ */
12
+ static revoke(claims: WsCredentialClaims): void;
13
+ }
@@ -1,5 +1,5 @@
1
1
  import type { LogRecord } from "akanjs/common";
2
- import type { LiveChange } from "./predefinedAdaptor/websocket.adaptor";
2
+ import type { LiveChange, WsCredentialClaims } from "./predefinedAdaptor/websocket.adaptor";
3
3
  export type AkanChildRole = "all" | "federation" | "batch";
4
4
  export type AkanChildStatus = "starting" | "ready" | "healthy" | "draining" | "unhealthy" | "exited" | "crashed";
5
5
  /** A replica's RSC worker; `null` on a replica that renders no pages. */
@@ -264,6 +264,10 @@ export type AkanIpcMessage = {
264
264
  type: "live.change";
265
265
  change: LiveChange;
266
266
  origin?: string;
267
+ } | {
268
+ type: "ws.revoke";
269
+ claims: WsCredentialClaims;
270
+ origin?: string;
267
271
  }
268
272
  /** Child → gateway: every model the child holds live rooms for. */
269
273
  | {
@@ -1,4 +1,4 @@
1
- import type { LiveChange, LiveChangeHandler, WebsocketAdaptor, WsRedisEventHandler } from "./websocket.adaptor";
1
+ import type { LiveChange, LiveChangeHandler, WebsocketAdaptor, WsCredentialClaims, WsRedisEventHandler } from "./websocket.adaptor";
2
2
  declare const SolidPubSub_base: import("..").AdaptorCls<{}, {
3
3
  serverId: import("..").InjectInfo<"env", string, {
4
4
  [key: string]: any;
@@ -14,6 +14,8 @@ export declare class SolidPubSub extends SolidPubSub_base implements WebsocketAd
14
14
  publish(roomId: string, data: unknown): void;
15
15
  publishChange(change: LiveChange): void;
16
16
  onChange(handler: LiveChangeHandler): void;
17
+ publishRevocation(claims: WsCredentialClaims): void;
18
+ onRevocation(handler: (claims: WsCredentialClaims) => void): void;
17
19
  reportLiveModels(models: string[]): void;
18
20
  setEventHandler(handler: WsRedisEventHandler): void;
19
21
  clearEventHandler(): void;
@@ -11,6 +11,8 @@ export interface LiveChange {
11
11
  previous?: string;
12
12
  }
13
13
  export type LiveChangeHandler = (change: LiveChange) => void;
14
+ /** Claim name to values: a socket whose credential carries any one of them is closed. */
15
+ export type WsCredentialClaims = Record<string, string[]>;
14
16
  export interface WebsocketPublishOption {
15
17
  /** Only the newest frame for the room matters, so an undelivered older one may be dropped for it. */
16
18
  coalesce?: boolean;
@@ -35,6 +37,9 @@ export interface WebsocketAdaptor {
35
37
  onChange?(handler: LiveChangeHandler): void;
36
38
  /** The models this server holds live rooms for, each time that changes, so changes to the rest pass it by. */
37
39
  reportLiveModels?(models: string[]): void;
40
+ /** To the app's other servers, each closing its own sockets whose credential carries one of the claims. */
41
+ publishRevocation?(claims: WsCredentialClaims): void;
42
+ onRevocation?(handler: (claims: WsCredentialClaims) => void): void;
38
43
  /** Resolves once what another server publishes to the room reaches this one, or sooner if that link is down or stalls. */
39
44
  joinRoom(ws: Bun.ServerWebSocket<unknown>, room: string, option?: WebsocketJoinOption): Promise<void>;
40
45
  leaveRoom(ws: Bun.ServerWebSocket<unknown>, room: string): Promise<void>;
@@ -60,6 +65,8 @@ export declare class WebSocketRedisAdaptor extends WebSocketRedisAdaptor_base im
60
65
  publish(roomId: string, data: unknown, { coalesce }?: WebsocketPublishOption): void;
61
66
  publishChange(change: LiveChange): void;
62
67
  onChange(handler: LiveChangeHandler): void;
68
+ publishRevocation(claims: WsCredentialClaims): void;
69
+ onRevocation(handler: (claims: WsCredentialClaims) => void): void;
63
70
  setEventHandler(handler: WsRedisEventHandler): void;
64
71
  clearEventHandler(): void;
65
72
  onRecovered(handler: (rooms: string[]) => void): void;
@@ -2,14 +2,14 @@
2
2
  export declare const badgeRecipe: (variants?: Omit<({
3
3
  size?: "lg" | "md" | "sm" | "xs" | undefined;
4
4
  outline?: boolean | undefined;
5
- variant?: "error" | "default" | "info" | "warning" | "success" | "primary" | "outline" | "secondary" | "accent" | "neutral" | undefined;
5
+ variant?: "default" | "error" | "info" | "warning" | "success" | "primary" | "outline" | "secondary" | "accent" | "neutral" | undefined;
6
6
  } & {
7
7
  class?: import("tailwind-variants/lite").ClassValue;
8
8
  className?: never;
9
9
  }) | ({
10
10
  size?: "lg" | "md" | "sm" | "xs" | undefined;
11
11
  outline?: boolean | undefined;
12
- variant?: "error" | "default" | "info" | "warning" | "success" | "primary" | "outline" | "secondary" | "accent" | "neutral" | undefined;
12
+ variant?: "default" | "error" | "info" | "warning" | "success" | "primary" | "outline" | "secondary" | "accent" | "neutral" | undefined;
13
13
  } & {
14
14
  class?: never;
15
15
  className?: import("tailwind-variants/lite").ClassValue;
@@ -2,7 +2,7 @@
2
2
  export declare const buttonRecipe: (variants?: Omit<({
3
3
  size?: "xl" | "lg" | "md" | "sm" | "xs" | "icon" | undefined;
4
4
  outline?: boolean | undefined;
5
- variant?: "link" | "default" | "info" | "warning" | "success" | "destructive" | "primary" | "outline" | "secondary" | "accent" | "neutral" | "ghost" | undefined;
5
+ variant?: "default" | "link" | "info" | "warning" | "success" | "destructive" | "primary" | "outline" | "secondary" | "accent" | "neutral" | "ghost" | undefined;
6
6
  shape?: "default" | "circle" | "square" | undefined;
7
7
  } & {
8
8
  class?: import("tailwind-variants/lite").ClassValue;
@@ -10,7 +10,7 @@ export declare const buttonRecipe: (variants?: Omit<({
10
10
  }) | ({
11
11
  size?: "xl" | "lg" | "md" | "sm" | "xs" | "icon" | undefined;
12
12
  outline?: boolean | undefined;
13
- variant?: "link" | "default" | "info" | "warning" | "success" | "destructive" | "primary" | "outline" | "secondary" | "accent" | "neutral" | "ghost" | undefined;
13
+ variant?: "default" | "link" | "info" | "warning" | "success" | "destructive" | "primary" | "outline" | "secondary" | "accent" | "neutral" | "ghost" | undefined;
14
14
  shape?: "default" | "circle" | "square" | undefined;
15
15
  } & {
16
16
  class?: never;
@@ -2,14 +2,14 @@
2
2
  export declare const inputRecipe: (variants?: Omit<({
3
3
  kind?: "field" | "select" | "area" | undefined;
4
4
  size?: "xl" | "lg" | "md" | "sm" | "xs" | undefined;
5
- tone?: "error" | "default" | "primary" | undefined;
5
+ tone?: "default" | "error" | "primary" | undefined;
6
6
  } & {
7
7
  class?: import("tailwind-variants/lite").ClassValue;
8
8
  className?: never;
9
9
  }) | ({
10
10
  kind?: "field" | "select" | "area" | undefined;
11
11
  size?: "xl" | "lg" | "md" | "sm" | "xs" | undefined;
12
- tone?: "error" | "default" | "primary" | undefined;
12
+ tone?: "default" | "error" | "primary" | undefined;
13
13
  } & {
14
14
  class?: never;
15
15
  className?: import("tailwind-variants/lite").ClassValue;
@@ -21,7 +21,7 @@ export declare class CsrSlide {
21
21
  static get isCalm(): boolean;
22
22
  static settleMove(kind: "push" | "replace", from: Location, to: Location): boolean;
23
23
  /** How an entry moves: its own page's transition, or that of the page it took the place of. */
24
- static motionOf(location: Location): "stack" | "none" | "fade" | "bottomUp" | "scaleOut";
24
+ static motionOf(location: Location): "none" | "stack" | "fade" | "bottomUp" | "scaleOut";
25
25
  /** Whether an entry swipes back: its own page's `gesture`, or that of the page it took the place of. */
26
26
  static swipesBack(location: Location): boolean;
27
27
  static isStill(entryId: string | undefined): boolean;
@@ -17,8 +17,8 @@ export declare const useCsrRefs: () => {
17
17
  pageContentRef: import("react").RefObject<HTMLDivElement | null>;
18
18
  prevPageContentRef: import("react").RefObject<HTMLDivElement | null>;
19
19
  onBack: import("react").RefObject<{
20
- stack?: (() => Promise<void>) | undefined;
21
20
  none?: (() => Promise<void>) | undefined;
21
+ stack?: (() => Promise<void>) | undefined;
22
22
  fade?: (() => Promise<void>) | undefined;
23
23
  bottomUp?: (() => Promise<void>) | undefined;
24
24
  scaleOut?: (() => Promise<void>) | undefined;