@helia/http 4.0.0 → 4.0.1-688bd9de
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 +13 -5
- package/dist/index.min.js +11 -11
- package/dist/index.min.js.map +3 -3
- package/dist/src/index.d.ts +41 -8
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +32 -17
- package/dist/src/index.js.map +1 -1
- package/package.json +5 -5
- package/src/index.ts +64 -20
- package/dist/typedoc-urls.json +0 -6
package/dist/src/index.d.ts
CHANGED
|
@@ -12,10 +12,18 @@
|
|
|
12
12
|
* ```typescript
|
|
13
13
|
* import { withHTTP } from '@helia/http'
|
|
14
14
|
* import { unixfs } from '@helia/unixfs'
|
|
15
|
-
* import {
|
|
15
|
+
* import { createHeliaLight } from 'helia'
|
|
16
16
|
* import { CID } from 'multiformats/cid'
|
|
17
17
|
*
|
|
18
|
-
* const helia = await withHTTP(
|
|
18
|
+
* const helia = await withHTTP(createHeliaLight(), {
|
|
19
|
+
* delegatedRouters: [
|
|
20
|
+
* 'https://delegated-ipfs.dev'
|
|
21
|
+
* ],
|
|
22
|
+
* recursiveGateways: [
|
|
23
|
+
* 'https://trustless-gateway.link',
|
|
24
|
+
* 'https://4everland.io'
|
|
25
|
+
* ]
|
|
26
|
+
* }).start()
|
|
19
27
|
*
|
|
20
28
|
* const fs = unixfs(helia)
|
|
21
29
|
* fs.cat(CID.parse('bafyFoo'))
|
|
@@ -25,14 +33,14 @@
|
|
|
25
33
|
* It's possible to manually configure your node without using this module.
|
|
26
34
|
*
|
|
27
35
|
* ```typescript
|
|
28
|
-
* import {
|
|
36
|
+
* import { createHeliaLight } from 'helia'
|
|
29
37
|
* import { trustlessGatewayBlockBroker } from '@helia/trustless-gateway-client'
|
|
30
38
|
* import { fallbackRouter } from '@helia/fallback-router'
|
|
31
39
|
* import { delegatedHTTPRouter } from '@helia/delegated-http-routing-client'
|
|
32
40
|
* import { unixfs } from '@helia/unixfs'
|
|
33
41
|
* import { CID } from 'multiformats/cid'
|
|
34
42
|
*
|
|
35
|
-
* const helia = await
|
|
43
|
+
* const helia = await createHeliaLight({
|
|
36
44
|
* blockBrokers: [
|
|
37
45
|
* trustlessGatewayBlockBroker()
|
|
38
46
|
* ],
|
|
@@ -41,7 +49,7 @@
|
|
|
41
49
|
* url: 'https://delegated-ipfs.dev'
|
|
42
50
|
* }),
|
|
43
51
|
* fallbackRouter({
|
|
44
|
-
* gateways: ['https://
|
|
52
|
+
* gateways: ['https://trustless-gateway.link', 'https://4everland.io']
|
|
45
53
|
* })
|
|
46
54
|
* ]
|
|
47
55
|
* }).start()
|
|
@@ -50,10 +58,35 @@
|
|
|
50
58
|
* fs.cat(CID.parse('bafyFoo'))
|
|
51
59
|
* ```
|
|
52
60
|
*/
|
|
53
|
-
import type {
|
|
61
|
+
import type { Helia } from '@helia/interface';
|
|
62
|
+
import type { TrustlessGatewayBlockBrokerInit } from '@helia/trustless-gateway-client';
|
|
63
|
+
export declare const DEFAULT_TRUSTLESS_GATEWAYS: string[];
|
|
54
64
|
export interface HTTPOptions {
|
|
55
|
-
|
|
56
|
-
|
|
65
|
+
/**
|
|
66
|
+
* Delegated routers are servers that make routing requests on behalf of peers
|
|
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;
|
|
57
90
|
}
|
|
58
91
|
/**
|
|
59
92
|
* 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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AAKH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,iCAAiC,CAAA;AAEtF,eAAO,MAAM,0BAA0B,UAMtC,CAAA;AAED,MAAM,WAAW,WAAW;IAC1B;;;;;;OAMG;IACH,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAA;IAE3B;;;;;;;;;OASG;IACH,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAA;IAE5B;;;;OAIG;IACH,+BAA+B,CAAC,EAAE,+BAA+B,CAAA;CAClE;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAE,CAAC,SAAS,KAAK,EAAG,KAAK,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,CAAC,CAmB3E"}
|
package/dist/src/index.js
CHANGED
|
@@ -12,10 +12,18 @@
|
|
|
12
12
|
* ```typescript
|
|
13
13
|
* import { withHTTP } from '@helia/http'
|
|
14
14
|
* import { unixfs } from '@helia/unixfs'
|
|
15
|
-
* import {
|
|
15
|
+
* import { createHeliaLight } from 'helia'
|
|
16
16
|
* import { CID } from 'multiformats/cid'
|
|
17
17
|
*
|
|
18
|
-
* const helia = await withHTTP(
|
|
18
|
+
* const helia = await withHTTP(createHeliaLight(), {
|
|
19
|
+
* delegatedRouters: [
|
|
20
|
+
* 'https://delegated-ipfs.dev'
|
|
21
|
+
* ],
|
|
22
|
+
* recursiveGateways: [
|
|
23
|
+
* 'https://trustless-gateway.link',
|
|
24
|
+
* 'https://4everland.io'
|
|
25
|
+
* ]
|
|
26
|
+
* }).start()
|
|
19
27
|
*
|
|
20
28
|
* const fs = unixfs(helia)
|
|
21
29
|
* fs.cat(CID.parse('bafyFoo'))
|
|
@@ -25,14 +33,14 @@
|
|
|
25
33
|
* It's possible to manually configure your node without using this module.
|
|
26
34
|
*
|
|
27
35
|
* ```typescript
|
|
28
|
-
* import {
|
|
36
|
+
* import { createHeliaLight } from 'helia'
|
|
29
37
|
* import { trustlessGatewayBlockBroker } from '@helia/trustless-gateway-client'
|
|
30
38
|
* import { fallbackRouter } from '@helia/fallback-router'
|
|
31
39
|
* import { delegatedHTTPRouter } from '@helia/delegated-http-routing-client'
|
|
32
40
|
* import { unixfs } from '@helia/unixfs'
|
|
33
41
|
* import { CID } from 'multiformats/cid'
|
|
34
42
|
*
|
|
35
|
-
* const helia = await
|
|
43
|
+
* const helia = await createHeliaLight({
|
|
36
44
|
* blockBrokers: [
|
|
37
45
|
* trustlessGatewayBlockBroker()
|
|
38
46
|
* ],
|
|
@@ -41,7 +49,7 @@
|
|
|
41
49
|
* url: 'https://delegated-ipfs.dev'
|
|
42
50
|
* }),
|
|
43
51
|
* fallbackRouter({
|
|
44
|
-
* gateways: ['https://
|
|
52
|
+
* gateways: ['https://trustless-gateway.link', 'https://4everland.io']
|
|
45
53
|
* })
|
|
46
54
|
* ]
|
|
47
55
|
* }).start()
|
|
@@ -53,23 +61,30 @@
|
|
|
53
61
|
import { delegatedHTTPRouter } from '@helia/delegated-routing-client';
|
|
54
62
|
import { fallbackRouter } from '@helia/fallback-router';
|
|
55
63
|
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
|
+
];
|
|
56
70
|
/**
|
|
57
71
|
* Augment a Helia node with HTTP routers and block brokers
|
|
58
72
|
*/
|
|
59
73
|
export function withHTTP(helia, init) {
|
|
60
|
-
init?.
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
helia.addRouter(router);
|
|
67
|
-
});
|
|
68
|
-
init?.blockBrokers ?? [
|
|
69
|
-
trustlessGatewayBlockBroker()
|
|
70
|
-
].forEach(broker => {
|
|
71
|
-
helia.addBlockBroker(broker);
|
|
74
|
+
init?.delegatedRouters ?? [
|
|
75
|
+
'https://delegated-ipfs.dev'
|
|
76
|
+
].forEach(url => {
|
|
77
|
+
helia.addRouter(delegatedHTTPRouter({
|
|
78
|
+
url
|
|
79
|
+
}));
|
|
72
80
|
});
|
|
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
|
+
}
|
|
73
88
|
return helia;
|
|
74
89
|
}
|
|
75
90
|
//# 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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAA;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AACvD,OAAO,EAAE,2BAA2B,EAAE,MAAM,iCAAiC,CAAA;AAI7E,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACxC,sGAAsG;IACtG,gCAAgC;IAEhC,sGAAsG;IACtG,sBAAsB;CACvB,CAAA;AAgCD;;GAEG;AACH,MAAM,UAAU,QAAQ,CAAoB,KAAQ,EAAE,IAAkB;IACtE,IAAI,EAAE,gBAAgB,IAAI;QACxB,4BAA4B;KAC7B,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;QACd,KAAK,CAAC,SAAS,CAAC,mBAAmB,CAAC;YAClC,GAAG;SACJ,CAAC,CAAC,CAAA;IACL,CAAC,CAAC,CAAA;IAEF,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC;QAC7B,QAAQ,EAAE,IAAI,EAAE,iBAAiB,IAAI,0BAA0B;KAChE,CAAC,CAAC,CAAA;IAEH,qCAAqC;IACrC,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,mBAAmB,CAAC,EAAE,CAAC;QAC/C,KAAK,CAAC,cAAc,CAAC,2BAA2B,CAAC,IAAI,EAAE,+BAA+B,CAAC,CAAC,CAAA;IAC1F,CAAC;IAED,OAAO,KAAK,CAAA;AACd,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@helia/http",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.1-688bd9de",
|
|
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": "
|
|
52
|
-
"@helia/fallback-router": "
|
|
53
|
-
"@helia/interface": "
|
|
54
|
-
"@helia/trustless-gateway-client": "
|
|
51
|
+
"@helia/delegated-routing-client": "1.0.1-688bd9de",
|
|
52
|
+
"@helia/fallback-router": "1.0.1-688bd9de",
|
|
53
|
+
"@helia/interface": "7.0.1-688bd9de",
|
|
54
|
+
"@helia/trustless-gateway-client": "1.0.1-688bd9de"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"aegir": "^48.0.11",
|
package/src/index.ts
CHANGED
|
@@ -12,10 +12,18 @@
|
|
|
12
12
|
* ```typescript
|
|
13
13
|
* import { withHTTP } from '@helia/http'
|
|
14
14
|
* import { unixfs } from '@helia/unixfs'
|
|
15
|
-
* import {
|
|
15
|
+
* import { createHeliaLight } from 'helia'
|
|
16
16
|
* import { CID } from 'multiformats/cid'
|
|
17
17
|
*
|
|
18
|
-
* const helia = await withHTTP(
|
|
18
|
+
* const helia = await withHTTP(createHeliaLight(), {
|
|
19
|
+
* delegatedRouters: [
|
|
20
|
+
* 'https://delegated-ipfs.dev'
|
|
21
|
+
* ],
|
|
22
|
+
* recursiveGateways: [
|
|
23
|
+
* 'https://trustless-gateway.link',
|
|
24
|
+
* 'https://4everland.io'
|
|
25
|
+
* ]
|
|
26
|
+
* }).start()
|
|
19
27
|
*
|
|
20
28
|
* const fs = unixfs(helia)
|
|
21
29
|
* fs.cat(CID.parse('bafyFoo'))
|
|
@@ -25,14 +33,14 @@
|
|
|
25
33
|
* It's possible to manually configure your node without using this module.
|
|
26
34
|
*
|
|
27
35
|
* ```typescript
|
|
28
|
-
* import {
|
|
36
|
+
* import { createHeliaLight } from 'helia'
|
|
29
37
|
* import { trustlessGatewayBlockBroker } from '@helia/trustless-gateway-client'
|
|
30
38
|
* import { fallbackRouter } from '@helia/fallback-router'
|
|
31
39
|
* import { delegatedHTTPRouter } from '@helia/delegated-http-routing-client'
|
|
32
40
|
* import { unixfs } from '@helia/unixfs'
|
|
33
41
|
* import { CID } from 'multiformats/cid'
|
|
34
42
|
*
|
|
35
|
-
* const helia = await
|
|
43
|
+
* const helia = await createHeliaLight({
|
|
36
44
|
* blockBrokers: [
|
|
37
45
|
* trustlessGatewayBlockBroker()
|
|
38
46
|
* ],
|
|
@@ -41,7 +49,7 @@
|
|
|
41
49
|
* url: 'https://delegated-ipfs.dev'
|
|
42
50
|
* }),
|
|
43
51
|
* fallbackRouter({
|
|
44
|
-
* gateways: ['https://
|
|
52
|
+
* gateways: ['https://trustless-gateway.link', 'https://4everland.io']
|
|
45
53
|
* })
|
|
46
54
|
* ]
|
|
47
55
|
* }).start()
|
|
@@ -54,31 +62,67 @@
|
|
|
54
62
|
import { delegatedHTTPRouter } from '@helia/delegated-routing-client'
|
|
55
63
|
import { fallbackRouter } from '@helia/fallback-router'
|
|
56
64
|
import { trustlessGatewayBlockBroker } from '@helia/trustless-gateway-client'
|
|
57
|
-
import type {
|
|
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
|
+
]
|
|
58
75
|
|
|
59
76
|
export interface HTTPOptions {
|
|
60
|
-
|
|
61
|
-
|
|
77
|
+
/**
|
|
78
|
+
* Delegated routers are servers that make routing requests on behalf of peers
|
|
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
|
|
62
104
|
}
|
|
63
105
|
|
|
64
106
|
/**
|
|
65
107
|
* Augment a Helia node with HTTP routers and block brokers
|
|
66
108
|
*/
|
|
67
109
|
export function withHTTP <H extends Helia> (helia: H, init?: HTTPOptions): H {
|
|
68
|
-
init?.
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
helia.addRouter(router)
|
|
110
|
+
init?.delegatedRouters ?? [
|
|
111
|
+
'https://delegated-ipfs.dev'
|
|
112
|
+
].forEach(url => {
|
|
113
|
+
helia.addRouter(delegatedHTTPRouter({
|
|
114
|
+
url
|
|
115
|
+
}))
|
|
75
116
|
})
|
|
76
117
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
118
|
+
helia.addRouter(fallbackRouter({
|
|
119
|
+
gateways: init?.recursiveGateways ?? DEFAULT_TRUSTLESS_GATEWAYS
|
|
120
|
+
}))
|
|
121
|
+
|
|
122
|
+
// add trustless gateway block broker
|
|
123
|
+
if (!helia.hasBlockBroker('trustless-gateway')) {
|
|
124
|
+
helia.addBlockBroker(trustlessGatewayBlockBroker(init?.trustlessGatewayBlockBrokerInit))
|
|
125
|
+
}
|
|
82
126
|
|
|
83
127
|
return helia
|
|
84
128
|
}
|
package/dist/typedoc-urls.json
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
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
|
-
}
|