refactor(server): inline client capability parsing
With capability negotiation in place, the consumer-side tolerance pattern is unnecessary. Drop the dead readDeclaredClientCapabilities helper, inline the parsing in ClientCapabilities.fromHello, delete a tautological assertion in the relay reconnect test, and document the compatibility rules in architecture.md.
This commit is contained in:
@@ -3,21 +3,3 @@ export const CLIENT_CAPS = {
|
||||
} as const;
|
||||
|
||||
export type ClientCapability = (typeof CLIENT_CAPS)[keyof typeof CLIENT_CAPS];
|
||||
|
||||
const CLIENT_CAPABILITY_SET = new Set<string>(Object.values(CLIENT_CAPS));
|
||||
|
||||
export function isClientCapability(value: string): value is ClientCapability {
|
||||
return CLIENT_CAPABILITY_SET.has(value);
|
||||
}
|
||||
|
||||
export function readDeclaredClientCapabilities(
|
||||
capabilities: Record<string, unknown> | null | undefined,
|
||||
): ClientCapability[] {
|
||||
if (!capabilities) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Object.entries(capabilities).flatMap(([key, value]) =>
|
||||
value === true && isClientCapability(key) ? [key] : [],
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user