@helia/verified-fetch-interop 1.25.0 → 1.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/dist/index.min.js +1 -0
- package/dist/index.min.js.map +7 -0
- package/dist/src/direct-retrieval.spec.d.ts +2 -0
- package/dist/src/direct-retrieval.spec.d.ts.map +1 -0
- package/dist/src/direct-retrieval.spec.js +37 -0
- package/dist/src/direct-retrieval.spec.js.map +1 -0
- package/dist/src/fixtures/create-kubo.d.ts +1 -1
- package/dist/src/fixtures/create-kubo.d.ts.map +1 -1
- package/dist/src/fixtures/create-kubo.js +5 -1
- package/dist/src/fixtures/create-kubo.js.map +1 -1
- package/dist/src/fixtures/load-fixtures.d.ts.map +1 -1
- package/dist/src/fixtures/load-fixtures.js +9 -2
- package/dist/src/fixtures/load-fixtures.js.map +1 -1
- package/dist/src/ipns.spec.d.ts +2 -0
- package/dist/src/ipns.spec.d.ts.map +1 -0
- package/dist/src/ipns.spec.js +27 -0
- package/dist/src/ipns.spec.js.map +1 -0
- package/dist/src/json.spec.js +13 -1
- package/dist/src/json.spec.js.map +1 -1
- package/dist/src/unixfs-dir.spec.js +5 -3
- package/dist/src/unixfs-dir.spec.js.map +1 -1
- package/package.json +108 -11
- package/src/direct-retrieval.spec.ts +44 -0
- package/src/fixtures/create-kubo.ts +7 -2
- package/src/fixtures/data/bafybeibc5sgo2plmjkq2tzmhrn54bk3crhnc23zd2msg4ea7a4pxrkgfna.car +0 -0
- package/src/fixtures/data/k51qzi5uqu5dk3v4rmjber23h16xnr23bsggmqqil9z2gduiis5se8dht36dam.ipns-record +0 -0
- package/src/fixtures/load-fixtures.ts +11 -2
- package/src/ipns.spec.ts +32 -0
- package/src/json.spec.ts +14 -1
- package/src/unixfs-dir.spec.ts +5 -3
- package/LICENSE +0 -4
package/README.md
CHANGED
|
@@ -27,23 +27,23 @@ $ KUBO_BINARY=/path/to/kubo helia-interop
|
|
|
27
27
|
# Install
|
|
28
28
|
|
|
29
29
|
```console
|
|
30
|
-
$ npm i @helia/interop
|
|
30
|
+
$ npm i @helia/verified-fetch-interop
|
|
31
31
|
```
|
|
32
32
|
|
|
33
33
|
## Browser `<script>` tag
|
|
34
34
|
|
|
35
|
-
Loading this module through a script tag will make
|
|
35
|
+
Loading this module through a script tag will make its exports available as `HeliaVerifiedFetchInterop` in the global namespace.
|
|
36
36
|
|
|
37
37
|
```html
|
|
38
|
-
<script src="https://unpkg.com/@helia/interop/dist/index.min.js"></script>
|
|
38
|
+
<script src="https://unpkg.com/@helia/verified-fetch-interop/dist/index.min.js"></script>
|
|
39
39
|
```
|
|
40
40
|
|
|
41
41
|
# License
|
|
42
42
|
|
|
43
43
|
Licensed under either of
|
|
44
44
|
|
|
45
|
-
- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
|
|
46
|
-
- MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)
|
|
45
|
+
- Apache 2.0, ([LICENSE-APACHE](https://github.com/ipfs/helia-verified-fetch/blob/main/packages/interop/LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
|
|
46
|
+
- MIT ([LICENSE-MIT](https://github.com/ipfs/helia-verified-fetch/blob/main/packages/interop/LICENSE-MIT) / <http://opensource.org/licenses/MIT>)
|
|
47
47
|
|
|
48
48
|
# Contribute
|
|
49
49
|
|
package/dist/index.min.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.HeliaVerifiedFetchInterop = factory()}(typeof self !== 'undefined' ? self : this, function () {
|
|
2
2
|
"use strict";var HeliaVerifiedFetchInterop=(()=>{var t=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var d=(o,e,x,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let p of b(e))!c.call(o,p)&&p!==x&&t(o,p,{get:()=>e[p],enumerable:!(r=a(e,p))||r.enumerable});return o};var f=o=>d(t({},"__esModule",{value:!0}),o);var g={};return f(g);})();
|
|
3
3
|
return HeliaVerifiedFetchInterop}));
|
|
4
|
+
//# sourceMappingURL=index.min.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * @packageDocumentation\n *\n * Runs interop tests between @helia/verified-fetch and Kubo.\n *\n * @example Testing a new Kubo release\n *\n * ```console\n * $ npm i @helia/verified-fetch-interop\n * $ KUBO_BINARY=/path/to/kubo helia-verified-fetch-interop\n * ```\n */\n\nexport {}\n"],
|
|
5
|
+
"mappings": ";mZAAA,IAAAA,EAAA",
|
|
6
|
+
"names": ["index_exports"]
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"direct-retrieval.spec.d.ts","sourceRoot":"","sources":["../../src/direct-retrieval.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { createVerifiedFetch } from '@helia/verified-fetch';
|
|
2
|
+
import { expect } from 'aegir/chai';
|
|
3
|
+
import { isNode, isBrowser } from 'wherearewe';
|
|
4
|
+
/**
|
|
5
|
+
* Currently only testing browser and node
|
|
6
|
+
*/
|
|
7
|
+
const describe = isNode || isBrowser ? global.describe : global.describe.skip;
|
|
8
|
+
describe('@helia/verified-fetch - direct retrieval', () => {
|
|
9
|
+
let directRetrievalRouterUrl;
|
|
10
|
+
let createVerifiedFetchInit;
|
|
11
|
+
beforeEach(async () => {
|
|
12
|
+
if (process.env.KUBO_DIRECT_RETRIEVAL_ROUTER == null || process.env.KUBO_DIRECT_RETRIEVAL_ROUTER === '') {
|
|
13
|
+
throw new Error('KUBO_DIRECT_RETRIEVAL_ROUTER environment variable is required');
|
|
14
|
+
}
|
|
15
|
+
directRetrievalRouterUrl = process.env.KUBO_DIRECT_RETRIEVAL_ROUTER;
|
|
16
|
+
createVerifiedFetchInit = {
|
|
17
|
+
gateways: [],
|
|
18
|
+
routers: [directRetrievalRouterUrl]
|
|
19
|
+
};
|
|
20
|
+
if (!isNode) {
|
|
21
|
+
createVerifiedFetchInit.libp2pConfig = {
|
|
22
|
+
connectionGater: {
|
|
23
|
+
denyDialMultiaddr: () => false
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
it('can fetch content directly from another node', async () => {
|
|
29
|
+
const fetch = await createVerifiedFetch(createVerifiedFetchInit);
|
|
30
|
+
const res = await fetch('ipfs://QmbQDovX7wRe9ek7u6QXe9zgCXkTzoUSsTFJEkrYV1HrVR/1 - Barrel - Part 1 - alt.txt');
|
|
31
|
+
expect(res.status).to.equal(200);
|
|
32
|
+
const body = await res.text();
|
|
33
|
+
expect(body).to.equal('Don\'t we all.');
|
|
34
|
+
await fetch.stop();
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
//# sourceMappingURL=direct-retrieval.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"direct-retrieval.spec.js","sourceRoot":"","sources":["../../src/direct-retrieval.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AACnC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAG9C;;GAEG;AACH,MAAM,QAAQ,GAAG,MAAM,IAAI,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAA;AAE7E,QAAQ,CAAC,0CAA0C,EAAE,GAAG,EAAE;IACxD,IAAI,wBAAgC,CAAA;IACpC,IAAI,uBAAgD,CAAA;IAEpD,UAAU,CAAC,KAAK,IAAI,EAAE;QACpB,IAAI,OAAO,CAAC,GAAG,CAAC,4BAA4B,IAAI,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,4BAA4B,KAAK,EAAE,EAAE,CAAC;YACxG,MAAM,IAAI,KAAK,CAAC,+DAA+D,CAAC,CAAA;QAClF,CAAC;QACD,wBAAwB,GAAG,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAA;QACnE,uBAAuB,GAAG;YACxB,QAAQ,EAAE,EAAE;YACZ,OAAO,EAAE,CAAC,wBAAwB,CAAC;SACpC,CAAA;QACD,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,uBAAuB,CAAC,YAAY,GAAG;gBACrC,eAAe,EAAE;oBACf,iBAAiB,EAAE,GAAG,EAAE,CAAC,KAAK;iBAC/B;aACF,CAAA;QACH,CAAC;IACH,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,8CAA8C,EAAE,KAAK,IAAI,EAAE;QAC5D,MAAM,KAAK,GAAG,MAAM,mBAAmB,CAAC,uBAAuB,CAAC,CAAA;QAEhE,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,qFAAqF,CAAC,CAAA;QAE9G,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QAChC,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAA;QAC7B,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAA;QAEvC,MAAM,KAAK,CAAC,IAAI,EAAE,CAAA;IACpB,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-kubo.d.ts","sourceRoot":"","sources":["../../../src/fixtures/create-kubo.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create-kubo.d.ts","sourceRoot":"","sources":["../../../src/fixtures/create-kubo.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAEzC,wBAAsB,cAAc,CAAE,QAAQ,YAAY,GAAG,OAAO,CAAC,QAAQ,CAAC,CAgC7E"}
|
|
@@ -13,7 +13,11 @@ export async function createKuboNode(repoPath = undefined) {
|
|
|
13
13
|
Addresses: {
|
|
14
14
|
Swarm: [
|
|
15
15
|
'/ip4/0.0.0.0/tcp/4001',
|
|
16
|
-
'/ip4/0.0.0.0/tcp/4002/ws'
|
|
16
|
+
'/ip4/0.0.0.0/tcp/4002/ws',
|
|
17
|
+
'/ip4/0.0.0.0/udp/4001/webrtc-direct',
|
|
18
|
+
'/ip4/0.0.0.0/udp/4001/quic-v1/webtransport',
|
|
19
|
+
'/ip6/::/udp/4001/webrtc-direct',
|
|
20
|
+
'/ip6/::/udp/4001/quic-v1/webtransport'
|
|
17
21
|
],
|
|
18
22
|
Gateway: '/ip4/127.0.0.1/tcp/8180'
|
|
19
23
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-kubo.js","sourceRoot":"","sources":["../../../src/fixtures/create-kubo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"create-kubo.js","sourceRoot":"","sources":["../../../src/fixtures/create-kubo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AACtC,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,MAAM,MAAM,CAAA;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAGxC,MAAM,CAAC,KAAK,UAAU,cAAc,CAAE,QAAQ,GAAG,SAAS;IACxD,OAAO,UAAU,CAAC;QAChB,IAAI,EAAE,MAAM;QACZ,GAAG,EAAE,MAAM;QACX,GAAG,EAAE,QAAQ,EAAE;QACf,IAAI,EAAE,IAAI;QACV,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE;YACJ,MAAM,EAAE;gBACN,SAAS,EAAE;oBACT,KAAK,EAAE;wBACL,uBAAuB;wBACvB,0BAA0B;wBAC1B,qCAAqC;wBACrC,4CAA4C;wBAC5C,gCAAgC;wBAChC,uCAAuC;qBACxC;oBACD,OAAO,EAAE,yBAAyB;iBACnC;gBACD,OAAO,EAAE;oBACP,OAAO,EAAE,IAAI;oBACb,gBAAgB,EAAE,IAAI;oBACtB,WAAW,EAAE;wBACX,6BAA6B,EAAE,CAAC,GAAG,CAAC;wBACpC,8BAA8B,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,CAAC;qBAClE;iBACF;aACF;SACF;QACD,IAAI,EAAE,CAAC,4BAA4B,EAAE,yBAAyB,CAAC;KAChE,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-fixtures.d.ts","sourceRoot":"","sources":["../../../src/fixtures/load-fixtures.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"load-fixtures.d.ts","sourceRoot":"","sources":["../../../src/fixtures/load-fixtures.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,wBAAsB,YAAY,CAAE,SAAS,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAcxE"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { basename } from 'node:path';
|
|
1
2
|
import { $ } from 'execa';
|
|
2
|
-
import
|
|
3
|
+
import { glob } from 'glob';
|
|
3
4
|
import { path as kuboPath } from 'kubo';
|
|
4
5
|
/**
|
|
5
6
|
* Only callable from node (intended to be consumed by .aegir.js)
|
|
@@ -7,8 +8,14 @@ import { path as kuboPath } from 'kubo';
|
|
|
7
8
|
*/
|
|
8
9
|
export async function loadFixtures(IPFS_PATH = undefined) {
|
|
9
10
|
const kuboBinary = process.env.KUBO_BINARY ?? kuboPath();
|
|
10
|
-
|
|
11
|
+
const carFiles = await glob('**/fixtures/data/*.car', { cwd: process.cwd() });
|
|
12
|
+
const ipnsRecordFiles = await glob('**/fixtures/data/*.ipns-record', { cwd: process.cwd() });
|
|
13
|
+
await Promise.allSettled(carFiles.map(async (carFile) => {
|
|
11
14
|
await $({ env: { IPFS_PATH } }) `${kuboBinary} dag import --pin-roots=false --offline ${carFile}`;
|
|
15
|
+
}));
|
|
16
|
+
for (const ipnsRecord of ipnsRecordFiles) {
|
|
17
|
+
const key = basename(ipnsRecord, '.ipns-record').split('_')[0];
|
|
18
|
+
await $({ env: { IPFS_PATH } }) `${kuboBinary} routing put --allow-offline /ipns/${key} ${ipnsRecord}`;
|
|
12
19
|
}
|
|
13
20
|
}
|
|
14
21
|
//# sourceMappingURL=load-fixtures.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-fixtures.js","sourceRoot":"","sources":["../../../src/fixtures/load-fixtures.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"load-fixtures.js","sourceRoot":"","sources":["../../../src/fixtures/load-fixtures.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AACpC,OAAO,EAAE,CAAC,EAAE,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAC3B,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,MAAM,MAAM,CAAA;AAEvC;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAE,SAAS,GAAG,SAAS;IACvD,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,QAAQ,EAAE,CAAA;IAExD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,wBAAwB,EAAE,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAA;IAC7E,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC,gCAAgC,EAAE,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAA;IAE5F,MAAM,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;QACtD,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,SAAS,EAAE,EAAE,CAAC,CAAA,GAAG,UAAU,2CAA2C,OAAO,EAAE,CAAA;IAClG,CAAC,CAAC,CAAC,CAAA;IAEH,KAAK,MAAM,UAAU,IAAI,eAAe,EAAE,CAAC;QACzC,MAAM,GAAG,GAAG,QAAQ,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;QAC9D,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,SAAS,EAAE,EAAE,CAAC,CAAA,GAAG,UAAU,sCAAsC,GAAG,IAAI,UAAU,EAAE,CAAA;IACvG,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ipns.spec.d.ts","sourceRoot":"","sources":["../../src/ipns.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { createVerifiedFetch } from '@helia/verified-fetch';
|
|
2
|
+
import { expect } from 'aegir/chai';
|
|
3
|
+
describe('@helia/verified-fetch - ipns', () => {
|
|
4
|
+
let verifiedFetch;
|
|
5
|
+
before(async () => {
|
|
6
|
+
verifiedFetch = await createVerifiedFetch({
|
|
7
|
+
gateways: ['http://127.0.0.1:8180'],
|
|
8
|
+
routers: ['http://127.0.0.1:8180'],
|
|
9
|
+
allowInsecure: true,
|
|
10
|
+
allowLocal: true
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
after(async () => {
|
|
14
|
+
await verifiedFetch.stop();
|
|
15
|
+
});
|
|
16
|
+
it('should be able to load /ipns/<libp2p-key>', async () => {
|
|
17
|
+
// ensure the key is being returned by the ipfs gateway itself
|
|
18
|
+
const kuboResponse = await fetch('http://127.0.0.1:8180/ipns/k51qzi5uqu5dk3v4rmjber23h16xnr23bsggmqqil9z2gduiis5se8dht36dam');
|
|
19
|
+
const kuboResponseBody = await kuboResponse.text();
|
|
20
|
+
expect(kuboResponseBody).to.equal('hello\n');
|
|
21
|
+
const res = await verifiedFetch('/ipns/k51qzi5uqu5dk3v4rmjber23h16xnr23bsggmqqil9z2gduiis5se8dht36dam');
|
|
22
|
+
expect(res.status).to.equal(200);
|
|
23
|
+
const body = await res.text();
|
|
24
|
+
expect(body).to.equal('hello\n');
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
//# sourceMappingURL=ipns.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ipns.spec.js","sourceRoot":"","sources":["../../src/ipns.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAGnC,QAAQ,CAAC,8BAA8B,EAAE,GAAG,EAAE;IAC5C,IAAI,aAA4B,CAAA;IAEhC,MAAM,CAAC,KAAK,IAAI,EAAE;QAChB,aAAa,GAAG,MAAM,mBAAmB,CAAC;YACxC,QAAQ,EAAE,CAAC,uBAAuB,CAAC;YACnC,OAAO,EAAE,CAAC,uBAAuB,CAAC;YAClC,aAAa,EAAE,IAAI;YACnB,UAAU,EAAE,IAAI;SACjB,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IAEF,KAAK,CAAC,KAAK,IAAI,EAAE;QACf,MAAM,aAAa,CAAC,IAAI,EAAE,CAAA;IAC5B,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,2CAA2C,EAAE,KAAK,IAAI,EAAE;QACzD,8DAA8D;QAC9D,MAAM,YAAY,GAAG,MAAM,KAAK,CAAC,2FAA2F,CAAC,CAAA;QAC7H,MAAM,gBAAgB,GAAG,MAAM,YAAY,CAAC,IAAI,EAAE,CAAA;QAClD,MAAM,CAAC,gBAAgB,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,CAAA;QAE5C,MAAM,GAAG,GAAG,MAAM,aAAa,CAAC,sEAAsE,CAAC,CAAA;QACvG,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QAChC,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAA;QAC7B,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,CAAA;IAClC,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
package/dist/src/json.spec.js
CHANGED
|
@@ -3,7 +3,7 @@ import { createVerifiedFetch } from '@helia/verified-fetch';
|
|
|
3
3
|
import { expect } from 'aegir/chai';
|
|
4
4
|
import { CID } from 'multiformats/cid';
|
|
5
5
|
describe('@helia/verified-fetch - json', () => {
|
|
6
|
-
describe('unixfs -
|
|
6
|
+
describe('unixfs - multi-block', () => {
|
|
7
7
|
let verifiedFetch;
|
|
8
8
|
before(async () => {
|
|
9
9
|
// As of 2024-01-18, https://cloudflare-ipfs.com/ipns/tokens.uniswap.org resolves to:
|
|
@@ -36,6 +36,18 @@ describe('@helia/verified-fetch - json', () => {
|
|
|
36
36
|
expect(jsonObj).to.have.property('keywords').to.deep.equal(['uniswap', 'default']);
|
|
37
37
|
expect(jsonObj.tokens).to.be.an('array').of.length(767);
|
|
38
38
|
});
|
|
39
|
+
it('handles hamt-sharded directory with json file', async () => {
|
|
40
|
+
const resp = await verifiedFetch('ipfs://bafybeibc5sgo2plmjkq2tzmhrn54bk3crhnc23zd2msg4ea7a4pxrkgfna/371', {
|
|
41
|
+
allowLocal: true,
|
|
42
|
+
allowInsecure: true
|
|
43
|
+
});
|
|
44
|
+
expect(resp).to.be.ok();
|
|
45
|
+
expect(resp.status).to.equal(200);
|
|
46
|
+
expect(resp.headers.get('content-type')).to.equal('application/json');
|
|
47
|
+
const jsonObj = await resp.json();
|
|
48
|
+
expect(jsonObj).to.be.ok();
|
|
49
|
+
expect(jsonObj).to.have.property('name').equal('Pudgy Penguin #371');
|
|
50
|
+
});
|
|
39
51
|
});
|
|
40
52
|
});
|
|
41
53
|
//# sourceMappingURL=json.spec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json.spec.js","sourceRoot":"","sources":["../../src/json.spec.ts"],"names":[],"mappings":"AAAA,sBAAsB;AACtB,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AACnC,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAEtC,QAAQ,CAAC,8BAA8B,EAAE,GAAG,EAAE;IAC5C,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"json.spec.js","sourceRoot":"","sources":["../../src/json.spec.ts"],"names":[],"mappings":"AAAA,sBAAsB;AACtB,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AACnC,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAEtC,QAAQ,CAAC,8BAA8B,EAAE,GAAG,EAAE;IAC5C,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;QACpC,IAAI,aAA8D,CAAA;QAElE,MAAM,CAAC,KAAK,IAAI,EAAE;YAChB,qFAAqF;YACrF,uDAAuD;YACvD,yEAAyE;YACzE,yEAAyE;YACzE,aAAa,GAAG,MAAM,mBAAmB,CAAC;gBACxC,QAAQ,EAAE,CAAC,uBAAuB,CAAC;gBACnC,OAAO,EAAE,CAAC,uBAAuB,CAAC;gBAClC,aAAa,EAAE,IAAI;gBACnB,UAAU,EAAE,IAAI;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expect(resp).to.be.ok();
|
|
45
45
|
expect(resp.status).to.equal(501); // TODO: we should do a directory listing instead
|
|
46
46
|
});
|
|
47
|
-
it('can return a string for unixfs
|
|
47
|
+
it('can return a string for deep-linked unixfs data', async () => {
|
|
48
48
|
const resp = await verifiedFetch('ipfs://QmbQDovX7wRe9ek7u6QXe9zgCXkTzoUSsTFJEkrYV1HrVR/1 - Barrel - Part 1 - alt.txt', {
|
|
49
49
|
allowLocal: true,
|
|
50
50
|
allowInsecure: true
|
|
@@ -53,7 +53,7 @@ describe('@helia/verified-fetch - unixfs directory', () => {
|
|
|
53
53
|
const text = await resp.text();
|
|
54
54
|
expect(text).to.equal('Don\'t we all.');
|
|
55
55
|
});
|
|
56
|
-
it('can return an image for unixfs
|
|
56
|
+
it('can return an image for deep-linked unixfs data', async () => {
|
|
57
57
|
const resp = await verifiedFetch('ipfs://QmbQDovX7wRe9ek7u6QXe9zgCXkTzoUSsTFJEkrYV1HrVR/1 - Barrel - Part 1.png', {
|
|
58
58
|
allowLocal: true,
|
|
59
59
|
allowInsecure: true
|
|
@@ -78,7 +78,7 @@ describe('@helia/verified-fetch - unixfs directory', () => {
|
|
|
78
78
|
}
|
|
79
79
|
});
|
|
80
80
|
});
|
|
81
|
-
it('can return an image content-type for unixfs
|
|
81
|
+
it('can return an image content-type for deep-linked unixfs data', async () => {
|
|
82
82
|
const resp = await verifiedFetch('ipfs://QmbQDovX7wRe9ek7u6QXe9zgCXkTzoUSsTFJEkrYV1HrVR/1 - Barrel - Part 1.png', {
|
|
83
83
|
allowLocal: true,
|
|
84
84
|
allowInsecure: true
|
|
@@ -97,9 +97,11 @@ describe('@helia/verified-fetch - unixfs directory', () => {
|
|
|
97
97
|
expect(resp).to.be.ok();
|
|
98
98
|
const text = await resp.text();
|
|
99
99
|
// npx kubo@0.25.0 cat '/ipfs/bafybeidbclfqleg2uojchspzd4bob56dqetqjsj27gy2cq3klkkgxtpn4i/685.txt'
|
|
100
|
+
// spell-checker: disable
|
|
100
101
|
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.
|
|
101
102
|
|
|
102
103
|
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.`);
|
|
104
|
+
// spell-checker: enable
|
|
103
105
|
});
|
|
104
106
|
});
|
|
105
107
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unixfs-dir.spec.js","sourceRoot":"","sources":["../../src/unixfs-dir.spec.ts"],"names":[],"mappings":"AAAA,sBAAsB;AACtB,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAG7C,QAAQ,CAAC,0CAA0C,EAAE,GAAG,EAAE;IACxD,IAAI,aAA4B,CAAA;IAEhC,MAAM,CAAC,KAAK,IAAI,EAAE;QAChB,aAAa,GAAG,MAAM,mBAAmB,CAAC;YACxC,QAAQ,EAAE,CAAC,uBAAuB,CAAC;YACnC,OAAO,EAAE,EAAE;YACX,aAAa,EAAE,IAAI;YACnB,UAAU,EAAE,IAA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E,CAAC,KAAK,CAAC,YAAY,CAAC,CAAA;QACjE,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IAEF,6KAA6K;IAC7K,QAAQ,CAAC,wBAAwB,EAAE,GAAG,EAAE;QACtC,EAAE,CAAC,sFAAsF,EAAE,KAAK,IAAI,EAAE;YACpG,MAAM,IAAI,GAAG,MAAM,aAAa,CAAC,4EAA4E,EAAE;gBAC7G,UAAU,EAAE,IAAI;gBAChB,aAAa,EAAE,IAAI;aACpB,CAAC,CAAA;YACF,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAA;YACvB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAA;YAC9B,kGAAkG;YAClG,yBAAyB;YACzB,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;;icAEqa,CAAC,CAAA;YAC5b,wBAAwB;QAC1B,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@helia/verified-fetch-interop",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.26.0",
|
|
4
4
|
"description": "Interop tests for @helia/verified-fetch",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/ipfs/helia-verified-fetch/tree/main/packages/interop#readme",
|
|
@@ -42,6 +42,99 @@
|
|
|
42
42
|
"sourceType": "module"
|
|
43
43
|
}
|
|
44
44
|
},
|
|
45
|
+
"release": {
|
|
46
|
+
"branches": [
|
|
47
|
+
"main"
|
|
48
|
+
],
|
|
49
|
+
"plugins": [
|
|
50
|
+
[
|
|
51
|
+
"@semantic-release/commit-analyzer",
|
|
52
|
+
{
|
|
53
|
+
"preset": "conventionalcommits",
|
|
54
|
+
"releaseRules": [
|
|
55
|
+
{
|
|
56
|
+
"breaking": true,
|
|
57
|
+
"release": "major"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"revert": true,
|
|
61
|
+
"release": "patch"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"type": "feat",
|
|
65
|
+
"release": "minor"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"type": "fix",
|
|
69
|
+
"release": "patch"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"type": "docs",
|
|
73
|
+
"release": "patch"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"type": "test",
|
|
77
|
+
"release": "patch"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"type": "deps",
|
|
81
|
+
"release": "patch"
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"scope": "no-release",
|
|
85
|
+
"release": false
|
|
86
|
+
}
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
],
|
|
90
|
+
[
|
|
91
|
+
"@semantic-release/release-notes-generator",
|
|
92
|
+
{
|
|
93
|
+
"preset": "conventionalcommits",
|
|
94
|
+
"presetConfig": {
|
|
95
|
+
"types": [
|
|
96
|
+
{
|
|
97
|
+
"type": "feat",
|
|
98
|
+
"section": "Features"
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"type": "fix",
|
|
102
|
+
"section": "Bug Fixes"
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"type": "chore",
|
|
106
|
+
"section": "Trivial Changes"
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"type": "docs",
|
|
110
|
+
"section": "Documentation"
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"type": "deps",
|
|
114
|
+
"section": "Dependencies"
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
"type": "test",
|
|
118
|
+
"section": "Tests"
|
|
119
|
+
}
|
|
120
|
+
]
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
],
|
|
124
|
+
"@semantic-release/changelog",
|
|
125
|
+
"@semantic-release/npm",
|
|
126
|
+
"@semantic-release/github",
|
|
127
|
+
[
|
|
128
|
+
"@semantic-release/git",
|
|
129
|
+
{
|
|
130
|
+
"assets": [
|
|
131
|
+
"CHANGELOG.md",
|
|
132
|
+
"package.json"
|
|
133
|
+
]
|
|
134
|
+
}
|
|
135
|
+
]
|
|
136
|
+
]
|
|
137
|
+
},
|
|
45
138
|
"scripts": {
|
|
46
139
|
"clean": "aegir clean",
|
|
47
140
|
"lint": "aegir lint",
|
|
@@ -54,18 +147,22 @@
|
|
|
54
147
|
"test:firefox": "aegir test -t browser -- --browser firefox",
|
|
55
148
|
"test:firefox-webworker": "aegir test -t webworker -- --browser firefox",
|
|
56
149
|
"test:node": "aegir test -t node --cov",
|
|
57
|
-
"test:electron-main": "aegir test -t electron-main"
|
|
150
|
+
"test:electron-main": "aegir test -t electron-main",
|
|
151
|
+
"release": "aegir release"
|
|
58
152
|
},
|
|
59
153
|
"dependencies": {
|
|
60
|
-
"@helia/
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"kubo
|
|
67
|
-
"
|
|
68
|
-
"
|
|
154
|
+
"@helia/delegated-routing-v1-http-api-server": "^4.0.6",
|
|
155
|
+
"@helia/verified-fetch": "^2.0.0",
|
|
156
|
+
"aegir": "^46.0.1",
|
|
157
|
+
"execa": "^9.5.3",
|
|
158
|
+
"glob": "^11.0.2",
|
|
159
|
+
"ipfsd-ctl": "^15.0.2",
|
|
160
|
+
"kubo": "^0.34.1",
|
|
161
|
+
"kubo-rpc-client": "^5.1.0",
|
|
162
|
+
"magic-bytes.js": "^1.12.1",
|
|
163
|
+
"multiformats": "^13.3.3",
|
|
164
|
+
"sinon-ts": "^2.0.0",
|
|
165
|
+
"wherearewe": "^2.0.1"
|
|
69
166
|
},
|
|
70
167
|
"browser": {
|
|
71
168
|
"./dist/src/fixtures/create-kubo.js": "./dist/src/fixtures/create-kubo.browser.js",
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { createVerifiedFetch } from '@helia/verified-fetch'
|
|
2
|
+
import { expect } from 'aegir/chai'
|
|
3
|
+
import { isNode, isBrowser } from 'wherearewe'
|
|
4
|
+
import type { CreateVerifiedFetchInit } from '@helia/verified-fetch'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Currently only testing browser and node
|
|
8
|
+
*/
|
|
9
|
+
const describe = isNode || isBrowser ? global.describe : global.describe.skip
|
|
10
|
+
|
|
11
|
+
describe('@helia/verified-fetch - direct retrieval', () => {
|
|
12
|
+
let directRetrievalRouterUrl: string
|
|
13
|
+
let createVerifiedFetchInit: CreateVerifiedFetchInit
|
|
14
|
+
|
|
15
|
+
beforeEach(async () => {
|
|
16
|
+
if (process.env.KUBO_DIRECT_RETRIEVAL_ROUTER == null || process.env.KUBO_DIRECT_RETRIEVAL_ROUTER === '') {
|
|
17
|
+
throw new Error('KUBO_DIRECT_RETRIEVAL_ROUTER environment variable is required')
|
|
18
|
+
}
|
|
19
|
+
directRetrievalRouterUrl = process.env.KUBO_DIRECT_RETRIEVAL_ROUTER
|
|
20
|
+
createVerifiedFetchInit = {
|
|
21
|
+
gateways: [],
|
|
22
|
+
routers: [directRetrievalRouterUrl]
|
|
23
|
+
}
|
|
24
|
+
if (!isNode) {
|
|
25
|
+
createVerifiedFetchInit.libp2pConfig = {
|
|
26
|
+
connectionGater: {
|
|
27
|
+
denyDialMultiaddr: () => false
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
it('can fetch content directly from another node', async () => {
|
|
34
|
+
const fetch = await createVerifiedFetch(createVerifiedFetchInit)
|
|
35
|
+
|
|
36
|
+
const res = await fetch('ipfs://QmbQDovX7wRe9ek7u6QXe9zgCXkTzoUSsTFJEkrYV1HrVR/1 - Barrel - Part 1 - alt.txt')
|
|
37
|
+
|
|
38
|
+
expect(res.status).to.equal(200)
|
|
39
|
+
const body = await res.text()
|
|
40
|
+
expect(body).to.equal('Don\'t we all.')
|
|
41
|
+
|
|
42
|
+
await fetch.stop()
|
|
43
|
+
})
|
|
44
|
+
})
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { createNode
|
|
1
|
+
import { createNode } from 'ipfsd-ctl'
|
|
2
2
|
import { path as kuboPath } from 'kubo'
|
|
3
3
|
import { create } from 'kubo-rpc-client'
|
|
4
|
+
import type { KuboNode } from 'ipfsd-ctl'
|
|
4
5
|
|
|
5
6
|
export async function createKuboNode (repoPath = undefined): Promise<KuboNode> {
|
|
6
7
|
return createNode({
|
|
@@ -14,7 +15,11 @@ export async function createKuboNode (repoPath = undefined): Promise<KuboNode> {
|
|
|
14
15
|
Addresses: {
|
|
15
16
|
Swarm: [
|
|
16
17
|
'/ip4/0.0.0.0/tcp/4001',
|
|
17
|
-
'/ip4/0.0.0.0/tcp/4002/ws'
|
|
18
|
+
'/ip4/0.0.0.0/tcp/4002/ws',
|
|
19
|
+
'/ip4/0.0.0.0/udp/4001/webrtc-direct',
|
|
20
|
+
'/ip4/0.0.0.0/udp/4001/quic-v1/webtransport',
|
|
21
|
+
'/ip6/::/udp/4001/webrtc-direct',
|
|
22
|
+
'/ip6/::/udp/4001/quic-v1/webtransport'
|
|
18
23
|
],
|
|
19
24
|
Gateway: '/ip4/127.0.0.1/tcp/8180'
|
|
20
25
|
},
|
|
Binary file
|
package/src/fixtures/data/k51qzi5uqu5dk3v4rmjber23h16xnr23bsggmqqil9z2gduiis5se8dht36dam.ipns-record
ADDED
|
Binary file
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { basename } from 'node:path'
|
|
1
2
|
import { $ } from 'execa'
|
|
2
|
-
import
|
|
3
|
+
import { glob } from 'glob'
|
|
3
4
|
import { path as kuboPath } from 'kubo'
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -9,7 +10,15 @@ import { path as kuboPath } from 'kubo'
|
|
|
9
10
|
export async function loadFixtures (IPFS_PATH = undefined): Promise<void> {
|
|
10
11
|
const kuboBinary = process.env.KUBO_BINARY ?? kuboPath()
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
const carFiles = await glob('**/fixtures/data/*.car', { cwd: process.cwd() })
|
|
14
|
+
const ipnsRecordFiles = await glob('**/fixtures/data/*.ipns-record', { cwd: process.cwd() })
|
|
15
|
+
|
|
16
|
+
await Promise.allSettled(carFiles.map(async (carFile) => {
|
|
13
17
|
await $({ env: { IPFS_PATH } })`${kuboBinary} dag import --pin-roots=false --offline ${carFile}`
|
|
18
|
+
}))
|
|
19
|
+
|
|
20
|
+
for (const ipnsRecord of ipnsRecordFiles) {
|
|
21
|
+
const key = basename(ipnsRecord, '.ipns-record').split('_')[0]
|
|
22
|
+
await $({ env: { IPFS_PATH } })`${kuboBinary} routing put --allow-offline /ipns/${key} ${ipnsRecord}`
|
|
14
23
|
}
|
|
15
24
|
}
|
package/src/ipns.spec.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { createVerifiedFetch } from '@helia/verified-fetch'
|
|
2
|
+
import { expect } from 'aegir/chai'
|
|
3
|
+
import type { VerifiedFetch } from '@helia/verified-fetch'
|
|
4
|
+
|
|
5
|
+
describe('@helia/verified-fetch - ipns', () => {
|
|
6
|
+
let verifiedFetch: VerifiedFetch
|
|
7
|
+
|
|
8
|
+
before(async () => {
|
|
9
|
+
verifiedFetch = await createVerifiedFetch({
|
|
10
|
+
gateways: ['http://127.0.0.1:8180'],
|
|
11
|
+
routers: ['http://127.0.0.1:8180'],
|
|
12
|
+
allowInsecure: true,
|
|
13
|
+
allowLocal: true
|
|
14
|
+
})
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
after(async () => {
|
|
18
|
+
await verifiedFetch.stop()
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
it('should be able to load /ipns/<libp2p-key>', async () => {
|
|
22
|
+
// ensure the key is being returned by the ipfs gateway itself
|
|
23
|
+
const kuboResponse = await fetch('http://127.0.0.1:8180/ipns/k51qzi5uqu5dk3v4rmjber23h16xnr23bsggmqqil9z2gduiis5se8dht36dam')
|
|
24
|
+
const kuboResponseBody = await kuboResponse.text()
|
|
25
|
+
expect(kuboResponseBody).to.equal('hello\n')
|
|
26
|
+
|
|
27
|
+
const res = await verifiedFetch('/ipns/k51qzi5uqu5dk3v4rmjber23h16xnr23bsggmqqil9z2gduiis5se8dht36dam')
|
|
28
|
+
expect(res.status).to.equal(200)
|
|
29
|
+
const body = await res.text()
|
|
30
|
+
expect(body).to.equal('hello\n')
|
|
31
|
+
})
|
|
32
|
+
})
|
package/src/json.spec.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { expect } from 'aegir/chai'
|
|
|
4
4
|
import { CID } from 'multiformats/cid'
|
|
5
5
|
|
|
6
6
|
describe('@helia/verified-fetch - json', () => {
|
|
7
|
-
describe('unixfs -
|
|
7
|
+
describe('unixfs - multi-block', () => {
|
|
8
8
|
let verifiedFetch: Awaited<ReturnType<typeof createVerifiedFetch>>
|
|
9
9
|
|
|
10
10
|
before(async () => {
|
|
@@ -40,5 +40,18 @@ describe('@helia/verified-fetch - json', () => {
|
|
|
40
40
|
expect(jsonObj).to.have.property('keywords').to.deep.equal(['uniswap', 'default'])
|
|
41
41
|
expect(jsonObj.tokens).to.be.an('array').of.length(767)
|
|
42
42
|
})
|
|
43
|
+
|
|
44
|
+
it('handles hamt-sharded directory with json file', async () => {
|
|
45
|
+
const resp = await verifiedFetch('ipfs://bafybeibc5sgo2plmjkq2tzmhrn54bk3crhnc23zd2msg4ea7a4pxrkgfna/371', {
|
|
46
|
+
allowLocal: true,
|
|
47
|
+
allowInsecure: true
|
|
48
|
+
})
|
|
49
|
+
expect(resp).to.be.ok()
|
|
50
|
+
expect(resp.status).to.equal(200)
|
|
51
|
+
expect(resp.headers.get('content-type')).to.equal('application/json')
|
|
52
|
+
const jsonObj = await resp.json()
|
|
53
|
+
expect(jsonObj).to.be.ok()
|
|
54
|
+
expect(jsonObj).to.have.property('name').equal('Pudgy Penguin #371')
|
|
55
|
+
})
|
|
43
56
|
})
|
|
44
57
|
})
|
package/src/unixfs-dir.spec.ts
CHANGED
|
@@ -51,7 +51,7 @@ describe('@helia/verified-fetch - unixfs directory', () => {
|
|
|
51
51
|
expect(resp.status).to.equal(501) // TODO: we should do a directory listing instead
|
|
52
52
|
})
|
|
53
53
|
|
|
54
|
-
it('can return a string for unixfs
|
|
54
|
+
it('can return a string for deep-linked unixfs data', async () => {
|
|
55
55
|
const resp = await verifiedFetch('ipfs://QmbQDovX7wRe9ek7u6QXe9zgCXkTzoUSsTFJEkrYV1HrVR/1 - Barrel - Part 1 - alt.txt', {
|
|
56
56
|
allowLocal: true,
|
|
57
57
|
allowInsecure: true
|
|
@@ -61,7 +61,7 @@ describe('@helia/verified-fetch - unixfs directory', () => {
|
|
|
61
61
|
expect(text).to.equal('Don\'t we all.')
|
|
62
62
|
})
|
|
63
63
|
|
|
64
|
-
it('can return an image for unixfs
|
|
64
|
+
it('can return an image for deep-linked unixfs data', async () => {
|
|
65
65
|
const resp = await verifiedFetch('ipfs://QmbQDovX7wRe9ek7u6QXe9zgCXkTzoUSsTFJEkrYV1HrVR/1 - Barrel - Part 1.png', {
|
|
66
66
|
allowLocal: true,
|
|
67
67
|
allowInsecure: true
|
|
@@ -88,7 +88,7 @@ describe('@helia/verified-fetch - unixfs directory', () => {
|
|
|
88
88
|
})
|
|
89
89
|
})
|
|
90
90
|
|
|
91
|
-
it('can return an image content-type for unixfs
|
|
91
|
+
it('can return an image content-type for deep-linked unixfs data', async () => {
|
|
92
92
|
const resp = await verifiedFetch('ipfs://QmbQDovX7wRe9ek7u6QXe9zgCXkTzoUSsTFJEkrYV1HrVR/1 - Barrel - Part 1.png', {
|
|
93
93
|
allowLocal: true,
|
|
94
94
|
allowInsecure: true
|
|
@@ -108,9 +108,11 @@ describe('@helia/verified-fetch - unixfs directory', () => {
|
|
|
108
108
|
expect(resp).to.be.ok()
|
|
109
109
|
const text = await resp.text()
|
|
110
110
|
// npx kubo@0.25.0 cat '/ipfs/bafybeidbclfqleg2uojchspzd4bob56dqetqjsj27gy2cq3klkkgxtpn4i/685.txt'
|
|
111
|
+
// spell-checker: disable
|
|
111
112
|
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.
|
|
112
113
|
|
|
113
114
|
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.`)
|
|
115
|
+
// spell-checker: enable
|
|
114
116
|
})
|
|
115
117
|
})
|
|
116
118
|
})
|
package/LICENSE
DELETED