Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: create @helia/verified-fetch #392

Merged
merged 108 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from 106 commits
Commits
Show all changes
108 commits
Select commit Hold shift + click to select a range
2a66379
feat: create @helia/verified-fetch
SgtPooki Jan 17, 2024
ab0f994
fix: dep-check passes with no warnings
SgtPooki Jan 18, 2024
7a5dc75
test: adding some tests
SgtPooki Jan 18, 2024
8c15f05
test: adding gateway test
SgtPooki Jan 18, 2024
94cf631
chore: lint succeeds
SgtPooki Jan 18, 2024
56008e8
chore: fix dep-check
SgtPooki Jan 18, 2024
b8a5f67
docs: update custom helia example
SgtPooki Jan 18, 2024
84adcbb
Update packages/verified-fetch/src/interface.ts
SgtPooki Jan 18, 2024
603fb7f
docs: Update packages/verified-fetch/README.md
SgtPooki Jan 18, 2024
a49d353
docs: remove support for CID string
SgtPooki Jan 18, 2024
2444ca3
chore: change default mime-type
SgtPooki Jan 18, 2024
a92ed83
chore: car & ipns-record return 501 not implemented
SgtPooki Jan 18, 2024
6b42abe
chore: address header comments
SgtPooki Jan 18, 2024
2dd264f
test: add fixture for importing CID content from the network
SgtPooki Jan 18, 2024
516d896
test: add test for multiblock-json unixfs content
SgtPooki Jan 18, 2024
ccb1739
chore: fix types and tests
SgtPooki Jan 18, 2024
44c4c20
fix: unmarshal unixfs data with transform stream
SgtPooki Jan 18, 2024
22cadfe
chore: many updates
SgtPooki Jan 18, 2024
16a2629
fix: url parsing in firefox
SgtPooki Jan 19, 2024
58a2c87
Merge branch 'main' into feat/create-verified-fetch
SgtPooki Jan 19, 2024
ade40b2
test: test than IPNS:// urls are handled properly
SgtPooki Jan 19, 2024
4cc599a
test: peerId urls
SgtPooki Jan 19, 2024
ff25ff1
feat: support custom modules in verifiedFetch constructor
SgtPooki Jan 19, 2024
3f347d8
fix: dep-check
SgtPooki Jan 19, 2024
b11db65
chore: change unixfs stream log from error to trace
SgtPooki Jan 22, 2024
84ef988
Merge branch 'main' into feat/create-verified-fetch
SgtPooki Jan 22, 2024
71c1b74
chore: move verified-fetch interop tests
SgtPooki Jan 22, 2024
0f20f0b
fix: peer-job-queue import in @libp2p/circuit-relay
SgtPooki Jan 22, 2024
20803f9
test: move verified-fetch e2e tests to @helia/interop
SgtPooki Jan 22, 2024
b96fd28
fix: return 501 for directories without root
SgtPooki Jan 22, 2024
fae6ea3
chore: remove signal from .cat options
SgtPooki Jan 22, 2024
fb5e883
test(interop): verified-fetch returns 501 on dir without root file
SgtPooki Jan 22, 2024
27abe76
test(verified-fetch): re-enable heliaP2P instantiation
SgtPooki Jan 22, 2024
3db9838
test: disable delegated routing in browsers
SgtPooki Jan 22, 2024
250ad55
chore: minor version and test fixes
SgtPooki Jan 22, 2024
254b94e
fix: parse-url-string supports queryStrings
SgtPooki Jan 22, 2024
129b560
test: add tests for unimplemented formats
SgtPooki Jan 22, 2024
b76e16c
test: move parse-resource out of verifiedFetch class
SgtPooki Jan 23, 2024
a76b836
chore: remove file-type mentions and unixFsTransformStream
SgtPooki Jan 23, 2024
a01398a
test: content-type tests
SgtPooki Jan 23, 2024
6e21e06
test: add url parse failure states
SgtPooki Jan 23, 2024
b32eb7e
chore: some more moving around
SgtPooki Jan 23, 2024
e4f4a94
test(verified-fetch): root lookup for vnd.ipld.raw
SgtPooki Jan 23, 2024
a1e6bf8
test(verified-fetch): 501 on failure to find root file
SgtPooki Jan 23, 2024
1692c61
test(verified-fetch): get-stream-and-content-type
SgtPooki Jan 23, 2024
0290d5e
test(verified-fetch): capture last iter value when done
SgtPooki Jan 23, 2024
dee5095
fix: some dag-json CID support
SgtPooki Jan 23, 2024
539fe9a
chore: remove noisy onProgress trace log
SgtPooki Jan 23, 2024
a25d5b0
test(interop): verified-fetch for blog.libp2p.io
SgtPooki Jan 23, 2024
a40369d
feat: json CID support
SgtPooki Jan 24, 2024
7802acb
chore: remove duplicate return of default mime type
SgtPooki Jan 24, 2024
aad723a
test(verified-fetch): parse-resource failure case
SgtPooki Jan 24, 2024
44d6c82
test(verified-fetch): stop and start coverage
SgtPooki Jan 24, 2024
96adb51
test(verified-fetch): parse-url-string coverage
SgtPooki Jan 24, 2024
48d960b
chore: remove dns.quad9 from resolver due to CORS
SgtPooki Jan 24, 2024
5f75863
Merge branch 'main' into feat/create-verified-fetch
SgtPooki Jan 25, 2024
cb3e95e
chore: use latest deployed versions of packages
SgtPooki Jan 25, 2024
0e3a767
chore: remove unused fixture fn
SgtPooki Jan 25, 2024
6a25298
chore: add @helia/verified-fetch after main merge
SgtPooki Jan 25, 2024
28a2dc4
chore: add onProgress event types
SgtPooki Jan 25, 2024
9476118
feat: add some onProgress events
SgtPooki Jan 25, 2024
09d8349
feat: pipe through onProgress events
SgtPooki Jan 25, 2024
0538e24
test: add hamt-sharded-directory test
SgtPooki Jan 25, 2024
ce51c89
chore: revert handleIPLDRaw changes in last commit
SgtPooki Jan 25, 2024
1747cc2
test: skip HAMT test until we get a smaller fixture
SgtPooki Jan 26, 2024
a55b172
chore: Apply suggestions from code review
SgtPooki Jan 26, 2024
9293622
chore: add init obj typeguard for createVerifiedFetch
SgtPooki Jan 26, 2024
9b2fa77
fix: replace magic code numbers with imports of actual codes
SgtPooki Jan 26, 2024
8dcb35a
chore: cache-control on
SgtPooki Jan 26, 2024
c8f3cff
chore: type fixes
SgtPooki Jan 26, 2024
d0d7fba
feat: optimizations to reduce if branching
SgtPooki Jan 26, 2024
fdd8980
docs: npm description -> trustless+verified
SgtPooki Jan 26, 2024
f864f44
chore: replace fixture server with aegir/fixtures
SgtPooki Jan 26, 2024
b177f3e
chore: remove empty .aegir.js config file
SgtPooki Jan 26, 2024
ec664a8
chore: remove typeVersions from package.json
SgtPooki Jan 26, 2024
db3dd3a
chore: remove unused browser property in package.json
SgtPooki Jan 26, 2024
deb9c1f
chore: move ParsedUrlStringResults
SgtPooki Jan 26, 2024
e88b62b
chore: move CreateVerifiedFetchWithOptions
SgtPooki Jan 26, 2024
9a0c13c
chore: moved types
SgtPooki Jan 26, 2024
cb09852
fix: onProgress detail should be object, not detail.detail
SgtPooki Jan 26, 2024
2845b0e
docs: move large chunk of README to @packageDocumentation
SgtPooki Jan 26, 2024
a34119b
chore: parse-url-string parsing order
SgtPooki Jan 26, 2024
c42b99b
feat: support @helia/ipns onProgress
SgtPooki Jan 29, 2024
8bc259c
feat: cache ipns lookups
SgtPooki Jan 30, 2024
b520235
chore: split constructor args
SgtPooki Jan 30, 2024
25444d7
chore: add tlru cache copy from what is used by @helia/ipns
SgtPooki Jan 30, 2024
99b7066
fix: verifiedFetch accepts fetch like signal
SgtPooki Jan 30, 2024
0e0c287
feat: add dag-cbor direct support
SgtPooki Jan 30, 2024
2d90412
test: unixfs-chunked json test name
SgtPooki Jan 30, 2024
4890b6b
fix: @helia/ipns doesn't enforce no-path
SgtPooki Jan 30, 2024
a669b28
Merge branch 'main' into feat/create-verified-fetch
SgtPooki Jan 31, 2024
97f6cf3
chore: verified-fetch uses latest @helia/ipns
SgtPooki Jan 31, 2024
6d05614
fix(verified-fetch): only check for index.html in dirs
SgtPooki Feb 1, 2024
08580bf
docs: close block & better videoStream var name
SgtPooki Feb 1, 2024
793ecb4
docs: example gateway urls
SgtPooki Feb 1, 2024
b488bc9
docs: addressing more comments
SgtPooki Feb 1, 2024
f1098cf
chore: 501 for explicit vnd.ipld.raw requests
SgtPooki Feb 1, 2024
e073d1f
feat: use ipfs-unixfs-exporter for walking paths
SgtPooki Feb 1, 2024
feac1a0
feat: support raw codec
SgtPooki Feb 1, 2024
2491c19
chore: edits for consistency, update project config
achingbrain Feb 2, 2024
d496d98
chore: simplify factory
achingbrain Feb 2, 2024
53699d0
chore: update readme and fix linting
achingbrain Feb 2, 2024
3da55b9
fix: use helia logger
achingbrain Feb 2, 2024
e21ca11
chore: fix types and tests
achingbrain Feb 2, 2024
5d10747
chore: cids as objects until stringinfication is necessary
achingbrain Feb 2, 2024
4a514bd
fix: remove unused var and make process events consistent
achingbrain Feb 2, 2024
a855339
chore: simplify factory again
achingbrain Feb 2, 2024
c590a47
fix: allow tree shaking
achingbrain Feb 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
"packages/unixfs": "3.0.0",
"packages/utils": "0.0.1",
"packages/http": "1.0.1",
"packages/routers": "1.0.0"
"packages/routers": "1.0.0",
"packages/verified-fetch": "0.0.0"
}
3 changes: 2 additions & 1 deletion .release-please.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"packages/routers": {},
"packages/strings": {},
"packages/unixfs": {},
"packages/utils": {}
"packages/utils": {},
"packages/verified-fetch": {}
}
}
5 changes: 3 additions & 2 deletions packages/interop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,10 @@
"@helia/routers": "^1.0.0",
"@helia/strings": "^3.0.0",
"@helia/unixfs": "^3.0.0",
"@helia/verified-fetch": "^0.0.0",
"@ipld/car": "^5.2.5",
"@ipld/dag-cbor": "^9.0.7",
"@libp2p/interface": "^1.1.1",
"@ipld/dag-cbor": "^9.1.0",
"@libp2p/interface": "^1.1.2",
"@libp2p/kad-dht": "^12.0.2",
"@libp2p/keychain": "^4.0.7",
"@libp2p/peer-id": "^4.0.5",
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
9 changes: 9 additions & 0 deletions packages/interop/src/fixtures/load-fixture-data.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import loadFixture from 'aegir/fixtures'
import drain from 'it-drain'
import type { Controller } from 'ipfsd-ctl'

export async function loadFixtureDataCar (controller: Controller, path: string): Promise<void> {
const fixtureData = `src/fixtures/data/${path}`
const buf = loadFixture(fixtureData)
await drain(controller.api.dag.import([buf]))
}
48 changes: 48 additions & 0 deletions packages/interop/src/verified-fetch-json.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/* eslint-env mocha */
import { createVerifiedFetch } from '@helia/verified-fetch'
import { expect } from 'aegir/chai'
import { CID } from 'multiformats/cid'
import { createKuboNode } from './fixtures/create-kubo.js'
import { loadFixtureDataCar } from './fixtures/load-fixture-data.js'
import type { Controller } from 'ipfsd-ctl'

describe('@helia/verified-fetch - json', () => {
describe('unixfs - multiblock', () => {
let controller: Controller<'go'>
let verifiedFetch: Awaited<ReturnType<typeof createVerifiedFetch>>

before(async () => {
controller = await createKuboNode()
await controller.start()
// As of 2024-01-18, https://cloudflare-ipfs.com/ipns/tokens.uniswap.org resolves to:
// root: QmQJ8fxavY54CUsxMSx9aE9Rdcmvhx8awJK2jzJp4iAqCr
// child1: QmNik5N4ryNwzzXYq5hCYKGcRjAf9QtigxtiJh9o8aXXbG // partial JSON
// child2: QmWNBJX6fZyNTLWNYBHxAHpBctCP43R2zeqV2G8uavqFZn // partial JSON
await loadFixtureDataCar(controller, 'QmQJ8fxavY54CUsxMSx9aE9Rdcmvhx8awJK2jzJp4iAqCr-tokens.uniswap.org-2024-01-18.car')
verifiedFetch = await createVerifiedFetch({
gateways: [`http://${controller.api.gatewayHost}:${controller.api.gatewayPort}`],
// Temporarily disabling delegated routers in browser until CORS issue is fixed. see https://github.com/ipshipyard/waterworks-community/issues/4
routers: process.env.RUNNER_ENV === 'node' ? [`http://${controller.api.gatewayHost}:${controller.api.gatewayPort}`] : []
})
})

after(async () => {
await controller.stop()
await verifiedFetch.stop()
})

it('handles UnixFS-chunked JSON file', async () => {
const resp = await verifiedFetch(CID.parse('QmQJ8fxavY54CUsxMSx9aE9Rdcmvhx8awJK2jzJp4iAqCr'))
expect(resp).to.be.ok()
const jsonObj = await resp.json()
expect(jsonObj).to.be.ok()
expect(jsonObj).to.have.property('name').equal('Uniswap Labs Default')
expect(jsonObj).to.have.property('timestamp').equal('2023-12-13T18:25:25.830Z')
expect(jsonObj).to.have.property('version').to.deep.equal({ major: 11, minor: 11, patch: 0 })
expect(jsonObj).to.have.property('tags')
expect(jsonObj).to.have.property('logoURI').equal('ipfs://QmNa8mQkrNKp1WEEeGjFezDmDeodkWRevGFN8JCV7b4Xir')
expect(jsonObj).to.have.property('keywords').to.deep.equal(['uniswap', 'default'])
expect(jsonObj.tokens).to.be.an('array').of.length(767)
})
})
})
76 changes: 76 additions & 0 deletions packages/interop/src/verified-fetch-unixfs-dir.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/* eslint-env mocha */
import { createVerifiedFetch } from '@helia/verified-fetch'
import { expect } from 'aegir/chai'
import { createKuboNode } from './fixtures/create-kubo.js'
import { loadFixtureDataCar } from './fixtures/load-fixture-data.js'
import type { Controller } from 'ipfsd-ctl'

describe('@helia/verified-fetch - unixfs directory', () => {
let controller: Controller
let verifiedFetch: Awaited<ReturnType<typeof createVerifiedFetch>>

before(async () => {
controller = await createKuboNode()
await controller.start()
verifiedFetch = await createVerifiedFetch({
gateways: [`http://${controller.api.gatewayHost}:${controller.api.gatewayPort}`],
// Temporarily disabling delegated routers in browser until CORS issue is fixed. see https://github.com/ipshipyard/waterworks-community/issues/4
routers: process.env.RUNNER_ENV === 'node' ? [`http://${controller.api.gatewayHost}:${controller.api.gatewayPort}`] : []
})
})

after(async () => {
await controller.stop()
await verifiedFetch.stop()
})

describe('XKCD Barrel Part 1', () => {
before(async () => {
// This is the content of https://explore.ipld.io/#/explore/QmdmQXB2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7RgQm/1%20-%20Barrel%20-%20Part%201
await loadFixtureDataCar(controller, 'QmbQDovX7wRe9ek7u6QXe9zgCXkTzoUSsTFJEkrYV1HrVR-xkcd-Barrel-part-1.car')
})

it('fails to load when passed the root', async () => {
// The spec says we should generate HTML with directory listings, but we don't do that yet, so expect a failure
const resp = await verifiedFetch('ipfs://QmbQDovX7wRe9ek7u6QXe9zgCXkTzoUSsTFJEkrYV1HrVR')
expect(resp).to.be.ok()
expect(resp.status).to.equal(501) // TODO: we should do a directory listing instead
})

it('can return a string for unixfs pathed data', async () => {
const resp = await verifiedFetch('ipfs://QmbQDovX7wRe9ek7u6QXe9zgCXkTzoUSsTFJEkrYV1HrVR/1 - Barrel - Part 1 - alt.txt')
expect(resp).to.be.ok()
const text = await resp.text()
expect(text).to.equal('Don\'t we all.')
expect(resp.headers.get('content-type')).to.equal('text/plain')
})

it('can return an image for unixfs pathed data', async () => {
const resp = await verifiedFetch('ipfs://QmbQDovX7wRe9ek7u6QXe9zgCXkTzoUSsTFJEkrYV1HrVR/1 - Barrel - Part 1.png')
expect(resp).to.be.ok()
expect(resp.headers.get('content-type')).to.equal('image/png')
const imgData = await resp.blob()
expect(imgData).to.be.ok()
expect(imgData.size).to.equal(24848)
})
})

// TODO: find a smaller car file so the test doesn't timeout locally or flake on CI
describe.skip('HAMT-sharded directory', () => {
before(async () => {
// from https://github.com/ipfs/gateway-conformance/blob/193833b91f2e9b17daf45c84afaeeae61d9d7c7e/fixtures/trustless_gateway_car/single-layer-hamt-with-multi-block-files.car
await loadFixtureDataCar(controller, 'bafybeidbclfqleg2uojchspzd4bob56dqetqjsj27gy2cq3klkkgxtpn4i-single-layer-hamt-with-multi-block-files.car')

Check warning on line 62 in packages/interop/src/verified-fetch-unixfs-dir.spec.ts

View check run for this annotation

Codecov / codecov/patch

packages/interop/src/verified-fetch-unixfs-dir.spec.ts#L61-L62

Added lines #L61 - L62 were not covered by tests
})

it('loads path /ipfs/bafybeidbclfqleg2uojchspzd4bob56dqetqjsj27gy2cq3klkkgxtpn4i/685.txt', async () => {
const resp = await verifiedFetch('ipfs://bafybeidbclfqleg2uojchspzd4bob56dqetqjsj27gy2cq3klkkgxtpn4i/685.txt')
expect(resp).to.be.ok()
expect(resp.headers.get('content-type')).to.equal('text/plain')
const text = await resp.text()
// npx kubo@0.25.0 cat '/ipfs/bafybeidbclfqleg2uojchspzd4bob56dqetqjsj27gy2cq3klkkgxtpn4i/685.txt'
expect(text).to.equal(`Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc non imperdiet nunc. Proin ac quam ut nibh eleifend aliquet. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; Sed ligula dolor, imperdiet sagittis arcu et, semper tincidunt urna. Donec et tempor augue, quis sollicitudin metus. Curabitur semper ullamcorper aliquet. Mauris hendrerit sodales lectus eget fermentum. Proin sollicitudin vestibulum commodo. Vivamus nec lectus eu augue aliquet dignissim nec condimentum justo. In hac habitasse platea dictumst. Mauris vel sem neque.
Vivamus finibus, enim at lacinia semper, arcu erat gravida lacus, sit amet gravida magna orci sit amet est. Sed non leo lacus. Nullam viverra ipsum a tincidunt dapibus. Nulla pulvinar ligula sit amet ante ultrices tempus. Proin purus urna, semper sed lobortis quis, gravida vitae ipsum. Aliquam mi urna, pulvinar eu bibendum quis, convallis ac dolor. In gravida justo sed risus ullamcorper, vitae luctus massa hendrerit. Pellentesque habitant amet.`)

Check warning on line 73 in packages/interop/src/verified-fetch-unixfs-dir.spec.ts

View check run for this annotation

Codecov / codecov/patch

packages/interop/src/verified-fetch-unixfs-dir.spec.ts#L66-L73

Added lines #L66 - L73 were not covered by tests
})
})
})
87 changes: 87 additions & 0 deletions packages/interop/src/verified-fetch-websites.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/* eslint-env mocha */
import { createVerifiedFetch } from '@helia/verified-fetch'
import { expect } from 'aegir/chai'
import { createKuboNode } from './fixtures/create-kubo.js'
import { loadFixtureDataCar } from './fixtures/load-fixture-data.js'
import type { Controller } from 'ipfsd-ctl'

describe('@helia/verified-fetch - websites', () => {
describe('helia-identify.on.fleek.co', () => {
let controller: Controller<'go'>
let verifiedFetch: Awaited<ReturnType<typeof createVerifiedFetch>>

before(async () => {
controller = await createKuboNode()
await controller.start()
// 2024-01-22 CID for _dnslink.helia-identify.on.fleek.co
await loadFixtureDataCar(controller, 'QmbxpRxwKXxnJQjnPqm1kzDJSJ8YgkLxH23mcZURwPHjGv-helia-identify-website.car')
verifiedFetch = await createVerifiedFetch({
gateways: [`http://${controller.api.gatewayHost}:${controller.api.gatewayPort}`],
// Temporarily disabling delegated routers in browser until CORS issue is fixed. see https://github.com/ipshipyard/waterworks-community/issues/4
routers: process.env.RUNNER_ENV === 'node' ? [`http://${controller.api.gatewayHost}:${controller.api.gatewayPort}`] : []
})
})

after(async () => {
await controller.stop()
await verifiedFetch.stop()
})

it('loads index.html when passed helia-identify.on.fleek.co root CID', async () => {
const resp = await verifiedFetch('ipfs://QmbxpRxwKXxnJQjnPqm1kzDJSJ8YgkLxH23mcZURwPHjGv')
expect(resp).to.be.ok()
const html = await resp.text()
expect(html).to.be.ok()
expect(html).to.include('<title>Run Identify on a remote node with Helia</title>')
})

it('loads helia-identify.on.fleek.co index.html directly ', async () => {
const resp = await verifiedFetch('ipfs://QmbxpRxwKXxnJQjnPqm1kzDJSJ8YgkLxH23mcZURwPHjGv/index.html')
expect(resp).to.be.ok()
const html = await resp.text()
expect(html).to.be.ok()
expect(html).to.include('<title>Run Identify on a remote node with Helia</title>')
})
})

/**
*
* Created on 2024-01-23. /ipns/blog.libp2p.io/index.html resolved to QmVZNGy6SPvUbvQCXXaGDdp8kvfJm9MMozjU12dyzH6hKf
*
* ```shell
* mkdir fake-blog.libp2p.io
* npx kubo@0.25.0 cat '/ipfs/QmVZNGy6SPvUbvQCXXaGDdp8kvfJm9MMozjU12dyzH6hKf' > fake-blog.libp2p.io/index.html
* npx kubo@0.25.0 add -r fake-blog.libp2p.io
* npx kubo@0.25.0 dag export QmeiDMLtPUS3RT2xAcUwsNyZz169wPke2q7im9vZpVLSYw > QmeiDMLtPUS3RT2xAcUwsNyZz169wPke2q7im9vZpVLSYw-fake-blog.libp2p.io.car
* ```
*/
describe('fake blog.libp2p.io', () => {
let controller: Controller<'go'>
let verifiedFetch: Awaited<ReturnType<typeof createVerifiedFetch>>

before(async () => {
controller = await createKuboNode()
await controller.start()
await loadFixtureDataCar(controller, 'QmeiDMLtPUS3RT2xAcUwsNyZz169wPke2q7im9vZpVLSYw-fake-blog.libp2p.io.car')
verifiedFetch = await createVerifiedFetch({
gateways: [`http://${controller.api.gatewayHost}:${controller.api.gatewayPort}`],
// Temporarily disabling delegated routers in browser until CORS issue is fixed. see https://github.com/ipshipyard/waterworks-community/issues/4
routers: process.env.RUNNER_ENV === 'node' ? [`http://${controller.api.gatewayHost}:${controller.api.gatewayPort}`] : []
})
})

after(async () => {
await controller.stop()
await verifiedFetch.stop()
})

it('loads index.html when passed fake-blog.libp2p.io root CID', async () => {
const resp = await verifiedFetch('ipfs://QmeiDMLtPUS3RT2xAcUwsNyZz169wPke2q7im9vZpVLSYw')
expect(resp).to.be.ok()
const html = await resp.text()
expect(html).to.be.ok()
expect(html).to.include('<title>Home | libp2p Blog &#x26; News</title>')
expect(html).to.include('<link href="https://libp2p.io/" rel="canonical">')
})
})
})
3 changes: 3 additions & 0 deletions packages/interop/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
},
{
"path": "../unixfs"
},
{
"path": "../verified-fetch"
}
]
}
4 changes: 4 additions & 0 deletions packages/verified-fetch/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
This project is dual licensed under MIT and Apache-2.0.

MIT: https://www.opensource.org/licenses/mit
Apache-2.0: https://www.apache.org/licenses/license-2.0
5 changes: 5 additions & 0 deletions packages/verified-fetch/LICENSE-APACHE
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
19 changes: 19 additions & 0 deletions packages/verified-fetch/LICENSE-MIT
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Loading
Loading