Skip to content

Commit 8920b82

Browse files
committed
Format
1 parent 69f262d commit 8920b82

3 files changed

Lines changed: 15 additions & 4 deletions

File tree

src/client.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,10 @@ export function client<T extends Router>(
396396
auth.secret !== undefined ? await auth.secret() : EMPTY_SECRET;
397397
if (state !== "handshaking" || epoch !== currentEpoch) return;
398398

399-
if (!(secretBytes instanceof Uint8Array) || secretBytes.length < KEY_LEN) {
399+
if (
400+
!(secretBytes instanceof Uint8Array) ||
401+
secretBytes.length < KEY_LEN
402+
) {
400403
throw new RPCError(
401404
"HANDSHAKE",
402405
`secret must be a Uint8Array of at least ${KEY_LEN} bytes`,

test/security/handshake-attacks.test.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,10 @@ describe("security / handshake attacks", () => {
9898
const srv = server(
9999
{ ping: chain().handler(async () => "pong") } as Router,
100100
a,
101-
{ auth: { secret: () => psk }, onError: (e) => errors.push(e as RPCError) },
101+
{
102+
auth: { secret: () => psk },
103+
onError: (e) => errors.push(e as RPCError),
104+
},
102105
);
103106

104107
const badPayload = mpEncode({
@@ -131,7 +134,10 @@ describe("security / handshake attacks", () => {
131134
const srv = server(
132135
{ ping: chain().handler(async () => "pong") } as Router,
133136
a,
134-
{ auth: { secret: () => psk }, onError: (e) => errors.push(e as RPCError) },
137+
{
138+
auth: { secret: () => psk },
139+
onError: (e) => errors.push(e as RPCError),
140+
},
135141
);
136142

137143
mitm.injectToA(

test/unit/psk-auth.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ describe("deriveSessionSecret", () => {
6666

6767
it("rejects a secret shorter than KEY_LEN", () => {
6868
for (const len of [0, 1, 16, 31]) {
69-
expect(() => deriveSessionSecret("s", randomBytes(len))).toThrow(TypeError);
69+
expect(() => deriveSessionSecret("s", randomBytes(len))).toThrow(
70+
TypeError,
71+
);
7072
}
7173
});
7274

0 commit comments

Comments
 (0)