Skip to content

Commit

Permalink
fix: respect trustless gateway options for sessions (#566)
Browse files Browse the repository at this point in the history
pass down trustless gateway options to session subclass

---------

Co-authored-by: Daniel N <[email protected]>
Co-authored-by: Alex Potsides <[email protected]>
  • Loading branch information
3 people authored Jul 25, 2024
1 parent f16c9ea commit 5643b1d
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/block-brokers/src/trustless-gateway/broker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ export class TrustlessGatewayBlockBroker implements BlockBroker<TrustlessGateway
return createTrustlessGatewaySession({
logger: this.logger,
routing: this.routing
}, options)
}, {
...options,
allowLocal: this.allowLocal,
allowInsecure: this.allowInsecure
})
}
}
30 changes: 30 additions & 0 deletions packages/block-brokers/test/trustless-gateway-utils.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { uriToMultiaddr } from '@multiformats/uri-to-multiaddr'
import { expect } from 'aegir/chai'
import { filterNonHTTPMultiaddrs } from '../src/trustless-gateway/utils.js'

describe('trustless-gateway-block-broker-utils', () => {
it('filterNonHTTPMultiaddrs respects allowInsecure multiaddrs correctly', async function () {
const nonSecureMaddr = uriToMultiaddr('http://mygw.com')
const secureMaddr = uriToMultiaddr('https://mygw.com')

const filtered = filterNonHTTPMultiaddrs([nonSecureMaddr, secureMaddr], true, true)

expect(filtered.length).to.deep.equal(2)
})

it('filterNonHTTPMultiaddrs filters local multiaddrs correctly', async function () {
const localMaddr = uriToMultiaddr('http://localhost')

const filtered = filterNonHTTPMultiaddrs([localMaddr], true, true)

expect(filtered.length).to.deep.equal(1)
})

it('filterNonHTTPMultiaddrs filters multiaddrs correctly', async function () {
const localMaddr = uriToMultiaddr('http://localhost')

const filtered = filterNonHTTPMultiaddrs([localMaddr], false, false)

expect(filtered.length).to.deep.equal(0)
})
})

0 comments on commit 5643b1d

Please sign in to comment.