Refuse a bind the server cannot record as it refuses one authenticate turns down
Mirror / push (push) Successful in 6s
Test / lint (pull_request) Successful in 24s
Test / test (18) (pull_request) Successful in 38s
Test / test (20) (pull_request) Successful in 32s
Test / test (22) (pull_request) Successful in 32s
Test / test (24) (pull_request) Successful in 34s
Test / test (26) (pull_request) Successful in 32s

This commit is contained in:
2026-09-28 04:05:07 +02:00
parent 2ac72fb3f4
commit 9a07f75bdf
3 changed files with 14 additions and 20 deletions
+2 -4
View File
@@ -123,16 +123,14 @@ export const undeclaredInterfaceVersion = 0x00;
export type SessionBind = { as: BindType; peerVersion: number };
const bindTypes: readonly string[] = ['receiver', 'transceiver', 'transmitter'];
function isBindType(value: unknown): value is BindType {
return typeof value === 'string' && bindTypes.includes(value);
return typeof value === 'string' && bindTypeFromCommand(`bind_${value}`) !== undefined;
}
/** A bind as `Session.bound()` records it: undefined declares no version, which is pre-3.4. */
export function checkedBind(bindType: unknown, declaredVersion: unknown): Result<{ bind: SessionBind }> {
if (!isBindType(bindType)) {
return { err: new Error(`bindType must be ${bindTypes.join(', ')}, got ${namedValue(bindType)}`) };
return { err: new Error(`bindType must be receiver, transceiver or transmitter, got ${namedValue(bindType)}`) };
}
if (declaredVersion === undefined) return { bind: { as: bindType, peerVersion: undeclaredInterfaceVersion } };