@helia/verified-fetch 0.0.0 → 1.0.1
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 +353 -56
- package/dist/index.min.js +7 -29
- package/dist/src/index.d.ts +384 -69
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +345 -77
- package/dist/src/index.js.map +1 -1
- package/dist/src/singleton.d.ts +3 -0
- package/dist/src/singleton.d.ts.map +1 -0
- package/dist/src/singleton.js +15 -0
- package/dist/src/singleton.js.map +1 -0
- package/dist/src/types.d.ts +2 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +2 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/utils/dag-cbor-to-safe-json.d.ts +7 -0
- package/dist/src/utils/dag-cbor-to-safe-json.d.ts.map +1 -0
- package/dist/src/utils/dag-cbor-to-safe-json.js +25 -0
- package/dist/src/utils/dag-cbor-to-safe-json.js.map +1 -0
- package/dist/src/utils/get-content-disposition-filename.d.ts +6 -0
- package/dist/src/utils/get-content-disposition-filename.d.ts.map +1 -0
- package/dist/src/utils/get-content-disposition-filename.js +16 -0
- package/dist/src/utils/get-content-disposition-filename.js.map +1 -0
- package/dist/src/utils/get-e-tag.d.ts +28 -0
- package/dist/src/utils/get-e-tag.d.ts.map +1 -0
- package/dist/src/utils/get-e-tag.js +18 -0
- package/dist/src/utils/get-e-tag.js.map +1 -0
- package/dist/src/utils/get-stream-from-async-iterable.d.ts +10 -0
- package/dist/src/utils/get-stream-from-async-iterable.d.ts.map +1 -0
- package/dist/src/utils/{get-stream-and-content-type.js → get-stream-from-async-iterable.js} +11 -11
- package/dist/src/utils/get-stream-from-async-iterable.js.map +1 -0
- package/dist/src/utils/get-tar-stream.d.ts +4 -0
- package/dist/src/utils/get-tar-stream.d.ts.map +1 -0
- package/dist/src/utils/get-tar-stream.js +46 -0
- package/dist/src/utils/get-tar-stream.js.map +1 -0
- package/dist/src/utils/parse-resource.d.ts +6 -1
- package/dist/src/utils/parse-resource.d.ts.map +1 -1
- package/dist/src/utils/parse-resource.js +2 -2
- package/dist/src/utils/parse-resource.js.map +1 -1
- package/dist/src/utils/parse-url-string.d.ts +10 -3
- package/dist/src/utils/parse-url-string.d.ts.map +1 -1
- package/dist/src/utils/parse-url-string.js +8 -4
- package/dist/src/utils/parse-url-string.js.map +1 -1
- package/dist/src/utils/responses.d.ts +5 -0
- package/dist/src/utils/responses.d.ts.map +1 -0
- package/dist/src/utils/responses.js +27 -0
- package/dist/src/utils/responses.js.map +1 -0
- package/dist/src/utils/select-output-type.d.ts +12 -0
- package/dist/src/utils/select-output-type.d.ts.map +1 -0
- package/dist/src/utils/select-output-type.js +148 -0
- package/dist/src/utils/select-output-type.js.map +1 -0
- package/dist/src/utils/walk-path.d.ts +2 -1
- package/dist/src/utils/walk-path.d.ts.map +1 -1
- package/dist/src/utils/walk-path.js +1 -3
- package/dist/src/utils/walk-path.js.map +1 -1
- package/dist/src/verified-fetch.d.ts +24 -27
- package/dist/src/verified-fetch.d.ts.map +1 -1
- package/dist/src/verified-fetch.js +297 -150
- package/dist/src/verified-fetch.js.map +1 -1
- package/dist/typedoc-urls.json +25 -18
- package/package.json +58 -116
- package/src/index.ts +391 -72
- package/src/singleton.ts +20 -0
- package/src/types.ts +1 -0
- package/src/utils/dag-cbor-to-safe-json.ts +27 -0
- package/src/utils/get-content-disposition-filename.ts +18 -0
- package/src/utils/get-e-tag.ts +36 -0
- package/src/utils/{get-stream-and-content-type.ts → get-stream-from-async-iterable.ts} +10 -9
- package/src/utils/get-tar-stream.ts +68 -0
- package/src/utils/parse-url-string.ts +17 -3
- package/src/utils/responses.ts +29 -0
- package/src/utils/select-output-type.ts +167 -0
- package/src/utils/walk-path.ts +4 -5
- package/src/verified-fetch.ts +340 -153
- package/dist/src/utils/get-content-type.d.ts +0 -11
- package/dist/src/utils/get-content-type.d.ts.map +0 -1
- package/dist/src/utils/get-content-type.js +0 -43
- package/dist/src/utils/get-content-type.js.map +0 -1
- package/dist/src/utils/get-stream-and-content-type.d.ts +0 -9
- package/dist/src/utils/get-stream-and-content-type.d.ts.map +0 -1
- package/dist/src/utils/get-stream-and-content-type.js.map +0 -1
- package/src/utils/get-content-type.ts +0 -55
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"walk-path.d.ts","sourceRoot":"","sources":["../../../src/utils/walk-path.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,KAAK,eAAe,EAAE,KAAK,eAAe,EAAE,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"walk-path.d.ts","sourceRoot":"","sources":["../../../src/utils/walk-path.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,KAAK,eAAe,EAAE,KAAK,eAAe,EAAE,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAC7H,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAE3C,MAAM,WAAW,iBAAkB,SAAQ,eAAe;CAEzD;AACD,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,GAAG,EAAE,CAAA;IAChB,eAAe,EAAE,WAAW,CAAA;CAE7B;AAED,MAAM,WAAW,YAAY;IAC3B,CAAC,UAAU,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAA;CACtG;AAED,wBAAsB,QAAQ,CAAE,UAAU,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAiBnI"}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { walkPath as exporterWalk } from 'ipfs-unixfs-exporter';
|
|
2
2
|
export async function walkPath(blockstore, path, options) {
|
|
3
|
-
const entries = [];
|
|
4
3
|
const ipfsRoots = [];
|
|
5
4
|
let terminalElement;
|
|
6
5
|
for await (const entry of exporterWalk(path, blockstore, options)) {
|
|
7
|
-
|
|
8
|
-
ipfsRoots.push(entry.cid.toString());
|
|
6
|
+
ipfsRoots.push(entry.cid);
|
|
9
7
|
terminalElement = entry;
|
|
10
8
|
}
|
|
11
9
|
if (terminalElement == null) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"walk-path.js","sourceRoot":"","sources":["../../../src/utils/walk-path.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,YAAY,EAAgE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"walk-path.js","sourceRoot":"","sources":["../../../src/utils/walk-path.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,YAAY,EAAgE,MAAM,sBAAsB,CAAA;AAgB7H,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAE,UAA2B,EAAE,IAAY,EAAE,OAA2B;IACpG,MAAM,SAAS,GAAU,EAAE,CAAA;IAC3B,IAAI,eAAwC,CAAA;IAE5C,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,YAAY,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,CAAC;QAClE,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QACzB,eAAe,GAAG,KAAK,CAAA;IACzB,CAAC;IAED,IAAI,eAAe,IAAI,IAAI,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAA;IAC9C,CAAC;IAED,OAAO;QACL,SAAS;QACT,eAAe;KAChB,CAAA;AACH,CAAC"}
|
|
@@ -1,53 +1,50 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import { type DAGJSON } from '@helia/dag-json';
|
|
3
|
-
import { type IPNS } from '@helia/ipns';
|
|
4
|
-
import { type JSON } from '@helia/json';
|
|
1
|
+
import { type DNSResolver, type IPNS } from '@helia/ipns';
|
|
5
2
|
import { type UnixFS as HeliaUnixFs } from '@helia/unixfs';
|
|
6
|
-
import {
|
|
7
|
-
import type { Resource, VerifiedFetchInit as VerifiedFetchOptions } from './index.js';
|
|
3
|
+
import type { ContentTypeParser, Resource, VerifiedFetchInit as VerifiedFetchOptions } from './index.js';
|
|
8
4
|
import type { Helia } from '@helia/interface';
|
|
9
5
|
interface VerifiedFetchComponents {
|
|
10
6
|
helia: Helia;
|
|
11
7
|
ipns?: IPNS;
|
|
12
8
|
unixfs?: HeliaUnixFs;
|
|
13
|
-
dagJson?: DAGJSON;
|
|
14
|
-
json?: JSON;
|
|
15
|
-
dagCbor?: DAGCBOR;
|
|
16
|
-
pathWalker?: PathWalkerFn;
|
|
17
9
|
}
|
|
18
10
|
/**
|
|
19
11
|
* Potential future options for the VerifiedFetch constructor.
|
|
20
12
|
*/
|
|
21
13
|
interface VerifiedFetchInit {
|
|
14
|
+
contentTypeParser?: ContentTypeParser;
|
|
15
|
+
dnsResolvers?: DNSResolver[];
|
|
22
16
|
}
|
|
23
17
|
export declare class VerifiedFetch {
|
|
24
18
|
private readonly helia;
|
|
25
19
|
private readonly ipns;
|
|
26
20
|
private readonly unixfs;
|
|
27
|
-
private readonly
|
|
28
|
-
private readonly
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
21
|
+
private readonly log;
|
|
22
|
+
private readonly contentTypeParser;
|
|
23
|
+
constructor({ helia, ipns, unixfs }: VerifiedFetchComponents, init?: VerifiedFetchInit);
|
|
24
|
+
/**
|
|
25
|
+
* Accepts an `ipns://...` URL as a string and returns a `Response` containing
|
|
26
|
+
* a raw IPNS record.
|
|
27
|
+
*/
|
|
32
28
|
private handleIPNSRecord;
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Accepts a `CID` and returns a `Response` with a body stream that is a CAR
|
|
31
|
+
* of the `DAG` referenced by the `CID`.
|
|
32
|
+
*/
|
|
33
|
+
private handleCar;
|
|
34
|
+
/**
|
|
35
|
+
* Accepts a UnixFS `CID` and returns a `.tar` file containing the file or
|
|
36
|
+
* directory structure referenced by the `CID`.
|
|
37
|
+
*/
|
|
38
|
+
private handleTar;
|
|
35
39
|
private handleJson;
|
|
36
40
|
private handleDagCbor;
|
|
37
41
|
private handleDagPb;
|
|
38
42
|
private handleRaw;
|
|
43
|
+
private setContentType;
|
|
39
44
|
/**
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* @see https://specs.ipfs.tech/http-gateways/path-gateway/#format-request-query-parameter
|
|
43
|
-
* @default 'raw'
|
|
44
|
-
*/
|
|
45
|
-
private getFormat;
|
|
46
|
-
/**
|
|
47
|
-
* Map of format to specific handlers for that format.
|
|
48
|
-
* These format handlers should adjust the response headers as specified in https://specs.ipfs.tech/http-gateways/path-gateway/#response-headers
|
|
45
|
+
* If the user has not specified an Accept header or format query string arg,
|
|
46
|
+
* use the CID codec to choose an appropriate handler for the block data.
|
|
49
47
|
*/
|
|
50
|
-
private readonly formatHandlers;
|
|
51
48
|
private readonly codecHandlers;
|
|
52
49
|
fetch(resource: Resource, opts?: VerifiedFetchOptions): Promise<Response>;
|
|
53
50
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verified-fetch.d.ts","sourceRoot":"","sources":["../../src/verified-fetch.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"verified-fetch.d.ts","sourceRoot":"","sources":["../../src/verified-fetch.ts"],"names":[],"mappings":"AACA,OAAO,EAAqB,KAAK,WAAW,EAAE,KAAK,IAAI,EAAE,MAAM,aAAa,CAAA;AAE5E,OAAO,EAAyB,KAAK,MAAM,IAAI,WAAW,EAAoB,MAAM,eAAe,CAAA;AAwBnG,OAAO,KAAK,EAAa,iBAAiB,EAAE,QAAQ,EAAE,iBAAiB,IAAI,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAEnH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAK7C,UAAU,uBAAuB;IAC/B,KAAK,EAAE,KAAK,CAAA;IAC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