@helia/http 4.0.1-ef258e7e → 4.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 +5 -13
- package/dist/index.min.js +3 -3
- package/dist/index.min.js.map +3 -3
- package/dist/src/index.d.ts +8 -41
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +17 -32
- package/dist/src/index.js.map +1 -1
- package/dist/typedoc-urls.json +6 -0
- package/package.json +5 -5
- package/src/index.ts +20 -64
package/dist/src/index.d.ts
CHANGED
|
@@ -12,18 +12,10 @@
|
|
|
12
12
|
* ```typescript
|
|
13
13
|
* import { withHTTP } from '@helia/http'
|
|
14
14
|
* import { unixfs } from '@helia/unixfs'
|
|
15
|
-
* import {
|
|
15
|
+
* import { createHelia } from 'helia'
|
|
16
16
|
* import { CID } from 'multiformats/cid'
|
|
17
17
|
*
|
|
18
|
-
* const helia = await withHTTP(
|
|
19
|
-
* delegatedRouters: [
|
|
20
|
-
* 'https://delegated-ipfs.dev'
|
|
21
|
-
* ],
|
|
22
|
-
* recursiveGateways: [
|
|
23
|
-
* 'https://trustless-gateway.link',
|
|
24
|
-
* 'https://4everland.io'
|
|
25
|
-
* ]
|
|
26
|
-
* }).start()
|
|
18
|
+
* const helia = await withHTTP(createHelia()).start()
|
|
27
19
|
*
|
|
28
20
|
* const fs = unixfs(helia)
|
|
29
21
|
* fs.cat(CID.parse('bafyFoo'))
|
|
@@ -33,14 +25,14 @@
|
|
|
33
25
|
* It's possible to manually configure your node without using this module.
|
|
34
26
|
*
|
|
35
27
|
* ```typescript
|
|
36
|
-
* import {
|
|
28
|
+
* import { createHelia } from 'helia'
|
|
37
29
|
* import { trustlessGatewayBlockBroker } from '@helia/trustless-gateway-client'
|
|
38
30
|
* import { fallbackRouter } from '@helia/fallback-router'
|
|
39
31
|
* import { delegatedHTTPRouter } from '@helia/delegated-http-routing-client'
|
|
40
32
|
* import { unixfs } from '@helia/unixfs'
|
|
41
33
|
* import { CID } from 'multiformats/cid'
|
|
42
34
|
*
|
|
43
|
-
* const helia = await
|
|
35
|
+
* const helia = await createHelia({
|
|
44
36
|
* blockBrokers: [
|
|
45
37
|
* trustlessGatewayBlockBroker()
|
|
46
38
|
* ],
|
|
@@ -49,7 +41,7 @@
|
|
|
49
41
|
* url: 'https://delegated-ipfs.dev'
|
|
50
42
|
* }),
|
|
51
43
|
* fallbackRouter({
|
|
52
|
-
* gateways: ['https://
|
|
44
|
+
* gateways: ['https://cloudflare-ipfs.com', 'https://ipfs.io']
|
|
53
45
|
* })
|
|
54
46
|
* ]
|
|
55
47
|
* }).start()
|
|
@@ -58,35 +50,10 @@
|
|
|
58
50
|
* fs.cat(CID.parse('bafyFoo'))
|
|
59
51
|
* ```
|
|
60
52
|
*/
|
|
61
|
-
import type { Helia } from '@helia/interface';
|
|
62
|
-
import type { TrustlessGatewayBlockBrokerInit } from '@helia/trustless-gateway-client';
|
|
63
|
-
export declare const DEFAULT_TRUSTLESS_GATEWAYS: string[];
|
|
53
|
+
import type { BlockBroker, Helia, Router } from '@helia/interface';
|
|
64
54
|
export interface HTTPOptions {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
* with less capable network connectivity.
|
|
68
|
-
*
|
|
69
|
-
* @see https://specs.ipfs.tech/routing/http-routing-v1/
|
|
70
|
-
* @default ['https://delegated-ipfs.dev']
|
|
71
|
-
*/
|
|
72
|
-
delegatedRouters?: string[];
|
|
73
|
-
/**
|
|
74
|
-
* A recursive gateway is one that will fetch content on behalf of peers with
|
|
75
|
-
* less capable network connectivity. For example it may fetch content from a
|
|
76
|
-
* node that supports transport(s) which the requesting peer does not.
|
|
77
|
-
*
|
|
78
|
-
* These are used as fallback routers which will always claim to be providers
|
|
79
|
-
* of a given block.
|
|
80
|
-
*
|
|
81
|
-
* @see https://docs.ipfs.tech/concepts/ipfs-gateway/#recursive-vs-non-recursive-gateways
|
|
82
|
-
*/
|
|
83
|
-
recursiveGateways?: string[];
|
|
84
|
-
/**
|
|
85
|
-
* Init arg passed to the trustless gateway block broker
|
|
86
|
-
*
|
|
87
|
-
* @see https://docs.ipfs.tech/reference/http/gateway/#trusted-vs-trustless
|
|
88
|
-
*/
|
|
89
|
-
trustlessGatewayBlockBrokerInit?: TrustlessGatewayBlockBrokerInit;
|
|
55
|
+
routers?: Router[];
|
|
56
|
+
blockBrokers?: BlockBroker[];
|
|
90
57
|
}
|
|
91
58
|
/**
|
|
92
59
|
* Augment a Helia node with HTTP routers and block brokers
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AAKH,OAAO,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAElE,MAAM,WAAW,WAAW;IAC1B,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;IAClB,YAAY,CAAC,EAAE,WAAW,EAAE,CAAA;CAC7B;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAE,CAAC,SAAS,KAAK,EAAG,KAAK,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,CAAC,CAiB3E"}
|
package/dist/src/index.js
CHANGED
|
@@ -12,18 +12,10 @@
|
|
|
12
12
|
* ```typescript
|
|
13
13
|
* import { withHTTP } from '@helia/http'
|
|
14
14
|
* import { unixfs } from '@helia/unixfs'
|
|
15
|
-
* import {
|
|
15
|
+
* import { createHelia } from 'helia'
|
|
16
16
|
* import { CID } from 'multiformats/cid'
|
|
17
17
|
*
|
|
18
|
-
* const helia = await withHTTP(
|
|
19
|
-
* delegatedRouters: [
|
|
20
|
-
* 'https://delegated-ipfs.dev'
|
|
21
|
-
* ],
|
|
22
|
-
* recursiveGateways: [
|
|
23
|
-
* 'https://trustless-gateway.link',
|
|
24
|
-
* 'https://4everland.io'
|
|
25
|
-
* ]
|
|
26
|
-
* }).start()
|
|
18
|
+
* const helia = await withHTTP(createHelia()).start()
|
|
27
19
|
*
|
|
28
20
|
* const fs = unixfs(helia)
|
|
29
21
|
* fs.cat(CID.parse('bafyFoo'))
|
|
@@ -33,14 +25,14 @@
|
|
|
33
25
|
* It's possible to manually configure your node without using this module.
|
|
34
26
|
*
|
|
35
27
|
* ```typescript
|
|
36
|
-
* import {
|
|
28
|
+
* import { createHelia } from 'helia'
|
|
37
29
|
* import { trustlessGatewayBlockBroker } from '@helia/trustless-gateway-client'
|
|
38
30
|
* import { fallbackRouter } from '@helia/fallback-router'
|
|
39
31
|
* import { delegatedHTTPRouter } from '@helia/delegated-http-routing-client'
|
|
40
32
|
* import { unixfs } from '@helia/unixfs'
|
|
41
33
|
* import { CID } from 'multiformats/cid'
|
|
42
34
|
*
|
|
43
|
-
* const helia = await
|
|
35
|
+
* const helia = await createHelia({
|
|
44
36
|
* blockBrokers: [
|
|
45
37
|
* trustlessGatewayBlockBroker()
|
|
46
38
|
* ],
|
|
@@ -49,7 +41,7 @@
|
|
|
49
41
|
* url: 'https://delegated-ipfs.dev'
|
|
50
42
|
* }),
|
|
51
43
|
* fallbackRouter({
|
|
52
|
-
* gateways: ['https://
|
|
44
|
+
* gateways: ['https://cloudflare-ipfs.com', 'https://ipfs.io']
|
|
53
45
|
* })
|
|
54
46
|
* ]
|
|
55
47
|
* }).start()
|
|
@@ -61,30 +53,23 @@
|
|
|
61
53
|
import { delegatedHTTPRouter } from '@helia/delegated-routing-client';
|
|
62
54
|
import { fallbackRouter } from '@helia/fallback-router';
|
|
63
55
|
import { trustlessGatewayBlockBroker } from '@helia/trustless-gateway-client';
|
|
64
|
-
export const DEFAULT_TRUSTLESS_GATEWAYS = [
|
|
65
|
-
// 2023-10-03: IPNS, Origin, and Block/CAR support from https://ipfs.github.io/public-gateway-checker/
|
|
66
|
-
'https://trustless-gateway.link',
|
|
67
|
-
// 2023-10-03: IPNS, Origin, and Block/CAR support from https://ipfs.github.io/public-gateway-checker/
|
|
68
|
-
'https://4everland.io'
|
|
69
|
-
];
|
|
70
56
|
/**
|
|
71
57
|
* Augment a Helia node with HTTP routers and block brokers
|
|
72
58
|
*/
|
|
73
59
|
export function withHTTP(helia, init) {
|
|
74
|
-
init?.
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
60
|
+
init?.routers ?? [
|
|
61
|
+
fallbackRouter(),
|
|
62
|
+
delegatedHTTPRouter({
|
|
63
|
+
url: 'https://delegated-ipfs.dev'
|
|
64
|
+
})
|
|
65
|
+
].forEach(router => {
|
|
66
|
+
helia.addRouter(router);
|
|
67
|
+
});
|
|
68
|
+
init?.blockBrokers ?? [
|
|
69
|
+
trustlessGatewayBlockBroker()
|
|
70
|
+
].forEach(broker => {
|
|
71
|
+
helia.addBlockBroker(broker);
|
|
80
72
|
});
|
|
81
|
-
helia.addRouter(fallbackRouter({
|
|
82
|
-
gateways: init?.recursiveGateways ?? DEFAULT_TRUSTLESS_GATEWAYS
|
|
83
|
-
}));
|
|
84
|
-
// add trustless gateway block broker
|
|
85
|
-
if (!helia.hasBlockBroker('trustless-gateway')) {
|
|
86
|
-
helia.addBlockBroker(trustlessGatewayBlockBroker(init?.trustlessGatewayBlockBrokerInit));
|
|
87
|
-
}
|
|
88
73
|
return helia;
|
|
89
74
|
}
|
|
90
75
|
//# sourceMappingURL=index.js.map
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAA;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AACvD,OAAO,EAAE,2BAA2B,EAAE,MAAM,iCAAiC,CAAA;AAQ7E;;GAEG;AACH,MAAM,UAAU,QAAQ,CAAoB,KAAQ,EAAE,IAAkB;IACtE,IAAI,EAAE,OAAO,IAAI;QACf,cAAc,EAAE;QAChB,mBAAmB,CAAC;YAClB,GAAG,EAAE,4BAA4B;SAClC,CAAC;KACH,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;QACjB,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;IACzB,CAAC,CAAC,CAAA;IAEF,IAAI,EAAE,YAAY,IAAI;QACpB,2BAA2B,EAAE;KAC9B,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;QACjB,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,CAAA;IAC9B,CAAC,CAAC,CAAA;IAEF,OAAO,KAAK,CAAA;AACd,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"HTTPOptions": "https://ipfs.github.io/helia/interfaces/_helia_http.HTTPOptions.html",
|
|
3
|
+
".:HTTPOptions": "https://ipfs.github.io/helia/interfaces/_helia_http.HTTPOptions.html",
|
|
4
|
+
"withHTTP": "https://ipfs.github.io/helia/functions/_helia_http.withHTTP.html",
|
|
5
|
+
".:withHTTP": "https://ipfs.github.io/helia/functions/_helia_http.withHTTP.html"
|
|
6
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@helia/http",
|
|
3
|
-
"version": "4.0.1
|
|
3
|
+
"version": "4.0.1",
|
|
4
4
|
"description": "A lightweight implementation of IPFS over HTTP in JavaScript",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/ipfs/helia/tree/main/packages/http#readme",
|
|
@@ -48,10 +48,10 @@
|
|
|
48
48
|
"test:electron-main": "aegir test -t electron-main"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@helia/delegated-routing-client": "1.0.1
|
|
52
|
-
"@helia/fallback-router": "1.0.1
|
|
53
|
-
"@helia/interface": "7.0.1
|
|
54
|
-
"@helia/trustless-gateway-client": "1.0.1
|
|
51
|
+
"@helia/delegated-routing-client": "^1.0.1",
|
|
52
|
+
"@helia/fallback-router": "^1.0.1",
|
|
53
|
+
"@helia/interface": "^7.0.1",
|
|
54
|
+
"@helia/trustless-gateway-client": "^1.0.1"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"aegir": "^48.0.11",
|
package/src/index.ts
CHANGED
|
@@ -12,18 +12,10 @@
|
|
|
12
12
|
* ```typescript
|
|
13
13
|
* import { withHTTP } from '@helia/http'
|
|
14
14
|
* import { unixfs } from '@helia/unixfs'
|
|
15
|
-
* import {
|
|
15
|
+
* import { createHelia } from 'helia'
|
|
16
16
|
* import { CID } from 'multiformats/cid'
|
|
17
17
|
*
|
|
18
|
-
* const helia = await withHTTP(
|
|
19
|
-
* delegatedRouters: [
|
|
20
|
-
* 'https://delegated-ipfs.dev'
|
|
21
|
-
* ],
|
|
22
|
-
* recursiveGateways: [
|
|
23
|
-
* 'https://trustless-gateway.link',
|
|
24
|
-
* 'https://4everland.io'
|
|
25
|
-
* ]
|
|
26
|
-
* }).start()
|
|
18
|
+
* const helia = await withHTTP(createHelia()).start()
|
|
27
19
|
*
|
|
28
20
|
* const fs = unixfs(helia)
|
|
29
21
|
* fs.cat(CID.parse('bafyFoo'))
|
|
@@ -33,14 +25,14 @@
|
|
|
33
25
|
* It's possible to manually configure your node without using this module.
|
|
34
26
|
*
|
|
35
27
|
* ```typescript
|
|
36
|
-
* import {
|
|
28
|
+
* import { createHelia } from 'helia'
|
|
37
29
|
* import { trustlessGatewayBlockBroker } from '@helia/trustless-gateway-client'
|
|
38
30
|
* import { fallbackRouter } from '@helia/fallback-router'
|
|
39
31
|
* import { delegatedHTTPRouter } from '@helia/delegated-http-routing-client'
|
|
40
32
|
* import { unixfs } from '@helia/unixfs'
|
|
41
33
|
* import { CID } from 'multiformats/cid'
|
|
42
34
|
*
|
|
43
|
-
* const helia = await
|
|
35
|
+
* const helia = await createHelia({
|
|
44
36
|
* blockBrokers: [
|
|
45
37
|
* trustlessGatewayBlockBroker()
|
|
46
38
|
* ],
|
|
@@ -49,7 +41,7 @@
|
|
|
49
41
|
* url: 'https://delegated-ipfs.dev'
|
|
50
42
|
* }),
|
|
51
43
|
* fallbackRouter({
|
|
52
|
-
* gateways: ['https://
|
|
44
|
+
* gateways: ['https://cloudflare-ipfs.com', 'https://ipfs.io']
|
|
53
45
|
* })
|
|
54
46
|
* ]
|
|
55
47
|
* }).start()
|
|
@@ -62,67 +54,31 @@
|
|
|
62
54
|
import { delegatedHTTPRouter } from '@helia/delegated-routing-client'
|
|
63
55
|
import { fallbackRouter } from '@helia/fallback-router'
|
|
64
56
|
import { trustlessGatewayBlockBroker } from '@helia/trustless-gateway-client'
|
|
65
|
-
import type { Helia } from '@helia/interface'
|
|
66
|
-
import type { TrustlessGatewayBlockBrokerInit } from '@helia/trustless-gateway-client'
|
|
67
|
-
|
|
68
|
-
export const DEFAULT_TRUSTLESS_GATEWAYS = [
|
|
69
|
-
// 2023-10-03: IPNS, Origin, and Block/CAR support from https://ipfs.github.io/public-gateway-checker/
|
|
70
|
-
'https://trustless-gateway.link',
|
|
71
|
-
|
|
72
|
-
// 2023-10-03: IPNS, Origin, and Block/CAR support from https://ipfs.github.io/public-gateway-checker/
|
|
73
|
-
'https://4everland.io'
|
|
74
|
-
]
|
|
57
|
+
import type { BlockBroker, Helia, Router } from '@helia/interface'
|
|
75
58
|
|
|
76
59
|
export interface HTTPOptions {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
* with less capable network connectivity.
|
|
80
|
-
*
|
|
81
|
-
* @see https://specs.ipfs.tech/routing/http-routing-v1/
|
|
82
|
-
* @default ['https://delegated-ipfs.dev']
|
|
83
|
-
*/
|
|
84
|
-
delegatedRouters?: string[]
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* A recursive gateway is one that will fetch content on behalf of peers with
|
|
88
|
-
* less capable network connectivity. For example it may fetch content from a
|
|
89
|
-
* node that supports transport(s) which the requesting peer does not.
|
|
90
|
-
*
|
|
91
|
-
* These are used as fallback routers which will always claim to be providers
|
|
92
|
-
* of a given block.
|
|
93
|
-
*
|
|
94
|
-
* @see https://docs.ipfs.tech/concepts/ipfs-gateway/#recursive-vs-non-recursive-gateways
|
|
95
|
-
*/
|
|
96
|
-
recursiveGateways?: string[]
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Init arg passed to the trustless gateway block broker
|
|
100
|
-
*
|
|
101
|
-
* @see https://docs.ipfs.tech/reference/http/gateway/#trusted-vs-trustless
|
|
102
|
-
*/
|
|
103
|
-
trustlessGatewayBlockBrokerInit?: TrustlessGatewayBlockBrokerInit
|
|
60
|
+
routers?: Router[]
|
|
61
|
+
blockBrokers?: BlockBroker[]
|
|
104
62
|
}
|
|
105
63
|
|
|
106
64
|
/**
|
|
107
65
|
* Augment a Helia node with HTTP routers and block brokers
|
|
108
66
|
*/
|
|
109
67
|
export function withHTTP <H extends Helia> (helia: H, init?: HTTPOptions): H {
|
|
110
|
-
init?.
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
68
|
+
init?.routers ?? [
|
|
69
|
+
fallbackRouter(),
|
|
70
|
+
delegatedHTTPRouter({
|
|
71
|
+
url: 'https://delegated-ipfs.dev'
|
|
72
|
+
})
|
|
73
|
+
].forEach(router => {
|
|
74
|
+
helia.addRouter(router)
|
|
116
75
|
})
|
|
117
76
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
if (!helia.hasBlockBroker('trustless-gateway')) {
|
|
124
|
-
helia.addBlockBroker(trustlessGatewayBlockBroker(init?.trustlessGatewayBlockBrokerInit))
|
|
125
|
-
}
|
|
77
|
+
init?.blockBrokers ?? [
|
|
78
|
+
trustlessGatewayBlockBroker()
|
|
79
|
+
].forEach(broker => {
|
|
80
|
+
helia.addBlockBroker(broker)
|
|
81
|
+
})
|
|
126
82
|
|
|
127
83
|
return helia
|
|
128
84
|
}
|