From f1f1b200ce0c8565f3e0b5eea32ba1148bf1a075 Mon Sep 17 00:00:00 2001 From: Alex Potsides Date: Wed, 11 Dec 2024 17:58:03 +0000 Subject: [PATCH 1/3] fix: log correct response status When the second request fails, log the status of the second request, not the first. --- src/auth/client.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/auth/client.ts b/src/auth/client.ts index 45b5218..de890a6 100644 --- a/src/auth/client.ts +++ b/src/auth/client.ts @@ -189,7 +189,7 @@ export class ClientAuth { const resp2 = await fetch(request) if (!resp2.ok) { - throw new BadResponseError(`Unexpected status code ${resp.status}`) + throw new BadResponseError(`Unexpected status code ${resp2.status}`) } const serverAuthHeader = resp2.headers.get('Authentication-Info') From 58c4088d5af58e14dbd23e100d536243563863cc Mon Sep 17 00:00:00 2001 From: achingbrain Date: Wed, 11 Dec 2024 18:09:53 +0000 Subject: [PATCH 2/3] chore: fix build --- test/index.spec.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/test/index.spec.ts b/test/index.spec.ts index 11027a8..9951a32 100644 --- a/test/index.spec.ts +++ b/test/index.spec.ts @@ -4,7 +4,7 @@ import { isPeerId, start, stop } from '@libp2p/interface' import { streamPair } from '@libp2p/interface-compliance-tests/mocks' import { defaultLogger } from '@libp2p/logger' import { peerIdFromString } from '@libp2p/peer-id' -import { multiaddr, type Multiaddr, type Protocol } from '@multiformats/multiaddr' +import { multiaddr, type Multiaddr } from '@multiformats/multiaddr' import { expect } from 'aegir/chai' import { duplexPair } from 'it-pair/duplex' import { type Libp2p } from 'libp2p' @@ -45,20 +45,24 @@ describe('whatwg-fetch', () => { let serverCB: StreamHandler const serverCBRegistered = pDefer() - serverComponents.registrar.handle.callsFake(async (protocol: Protocol, cb: StreamHandler) => { + serverComponents.registrar.handle.callsFake(async (protocol: string, cb: StreamHandler) => { serverCB = cb serverCBRegistered.resolve() }) const conn = stubInterface() - conn.newStream.callsFake(async (protos: Protocol[], options?: any) => { + conn.newStream.callsFake(async (protos: string | string[], options?: any) => { const duplexes = duplexPair() const streams = streamPair({ duplex: duplexes[0] }, { duplex: duplexes[1] }) serverCB({ stream: streams[0], connection: conn }) return streams[1] }) - clientComponents.connectionManager.openConnection.callsFake(async (peer: PeerId | Multiaddr, options?: any) => { + clientComponents.connectionManager.openConnection.callsFake(async (peer: PeerId | Multiaddr | Multiaddr[], options?: any) => { + if (Array.isArray(peer)) { + peer = peer[0] + } + if (isPeerId(peer) ? peer.equals(serverPeerID) : peer.getPeerId() === serverMultiaddr.getPeerId()) { await serverCBRegistered.promise return conn From 40e29550f23b95ac6ecff12b18282535580ecb2a Mon Sep 17 00:00:00 2001 From: achingbrain Date: Wed, 11 Dec 2024 18:11:00 +0000 Subject: [PATCH 3/3] chore: fix ci --- .github/workflows/test-examples.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-examples.yml b/.github/workflows/test-examples.yml index 6b25e67..807ecf4 100644 --- a/.github/workflows/test-examples.yml +++ b/.github/workflows/test-examples.yml @@ -17,7 +17,7 @@ jobs: node-version: lts/* - run: npm i working-directory: ./examples - - uses: ipfs/aegir/actions/cache-node-modules@master + - uses: ipfs/aegir/actions/cache-node-modules@main with: directories: | ./examples/node_modules @@ -30,7 +30,7 @@ jobs: - uses: actions/setup-node@v4 with: node-version: lts/* - - uses: ipfs/aegir/actions/cache-node-modules@master + - uses: ipfs/aegir/actions/cache-node-modules@main with: directories: | ./examples/node_modules