@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.
@@ -12,18 +12,10 @@
12
12
  * ```typescript
13
13
  * import { withHTTP } from '@helia/http'
14
14
  * import { unixfs } from '@helia/unixfs'
15
- * import { createHeliaLight } from 'helia'
15
+ * import { createHelia } from 'helia'
16
16
  * import { CID } from 'multiformats/cid'
17
17
  *
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()
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 { createHeliaLight } from 'helia'
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 createHeliaLight({
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://trustless-gateway.link', 'https://4everland.io']
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
- * 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;
55
+ routers?: Router[];
56
+ blockBrokers?: BlockBroker[];
90
57
  }
91
58
  /**
92
59
  * Augment a Helia node with HTTP routers and block brokers
@@ -1 +1 @@
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"}
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 { createHeliaLight } from 'helia'
15
+ * import { createHelia } from 'helia'
16
16
  * import { CID } from 'multiformats/cid'
17
17
  *
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()
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 { createHeliaLight } from 'helia'
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 createHeliaLight({
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://trustless-gateway.link', 'https://4everland.io']
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?.delegatedRouters ?? [
75
- 'https://delegated-ipfs.dev'
76
- ].forEach(url => {
77
- helia.addRouter(delegatedHTTPRouter({
78
- url
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
@@ -1 +1 @@
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"}
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-ef258e7e",
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-ef258e7e",
52
- "@helia/fallback-router": "1.0.1-ef258e7e",
53
- "@helia/interface": "7.0.1-ef258e7e",
54
- "@helia/trustless-gateway-client": "1.0.1-ef258e7e"
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 { createHeliaLight } from 'helia'
15
+ * import { createHelia } from 'helia'
16
16
  * import { CID } from 'multiformats/cid'
17
17
  *
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()
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 { createHeliaLight } from 'helia'
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 createHeliaLight({
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://trustless-gateway.link', 'https://4everland.io']
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
- * 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
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?.delegatedRouters ?? [
111
- 'https://delegated-ipfs.dev'
112
- ].forEach(url => {
113
- helia.addRouter(delegatedHTTPRouter({
114
- url
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
- 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
- }
77
+ init?.blockBrokers ?? [
78
+ trustlessGatewayBlockBroker()
79
+ ].forEach(broker => {
80
+ helia.addBlockBroker(broker)
81
+ })
126
82
 
127
83
  return helia
128
84
  }