@helia/http 4.0.2 → 4.0.3-da4aa40a

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.
@@ -61,7 +61,7 @@
61
61
  import type { Helia } from '@helia/interface';
62
62
  import type { TrustlessGatewayBlockBrokerInit } from '@helia/trustless-gateway-client';
63
63
  export declare const DEFAULT_TRUSTLESS_GATEWAYS: string[];
64
- export interface HTTPOptions {
64
+ export interface HTTPOptions extends TrustlessGatewayBlockBrokerInit {
65
65
  /**
66
66
  * Delegated routers are servers that make routing requests on behalf of peers
67
67
  * with less capable network connectivity.
@@ -82,11 +82,21 @@ export interface HTTPOptions {
82
82
  */
83
83
  recursiveGateways?: string[];
84
84
  /**
85
- * Init arg passed to the trustless gateway block broker
85
+ * List of protocols to filter in the PeerRecords as defined in IPIP-484
86
+ * If undefined, PeerRecords are not filtered by protocol
86
87
  *
87
- * @see https://docs.ipfs.tech/reference/http/gateway/#trusted-vs-trustless
88
+ * @see https://github.com/ipfs/specs/pull/484
89
+ * @default undefined
88
90
  */
89
- trustlessGatewayBlockBrokerInit?: TrustlessGatewayBlockBrokerInit;
91
+ filterProtocols?: string[];
92
+ /**
93
+ * Array of address filters to filter PeerRecords's addresses as defined in IPIP-484
94
+ * If undefined, PeerRecords are not filtered by address
95
+ *
96
+ * @see https://github.com/ipfs/specs/pull/484
97
+ * @default undefined
98
+ */
99
+ filterAddrs?: string[];
90
100
  }
91
101
  /**
92
102
  * 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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,WAAY,SAAQ,+BAA+B;IAClE;;;;;;OAMG;IACH,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAA;IAE3B;;;;;;;;;OASG;IACH,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAA;IAE5B;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,MAAM,EAAE,CAAA;IAE1B;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;CACvB;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAE,CAAC,SAAS,KAAK,EAAG,KAAK,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,CAAC,CAwB3E"}
package/dist/src/index.js CHANGED
@@ -71,19 +71,24 @@ export const DEFAULT_TRUSTLESS_GATEWAYS = [
71
71
  * Augment a Helia node with HTTP routers and block brokers
72
72
  */
73
73
  export function withHTTP(helia, init) {
74
- init?.delegatedRouters ?? [
74
+ (init?.delegatedRouters ?? [
75
75
  'https://delegated-ipfs.dev'
76
- ].forEach(url => {
76
+ ]).forEach(url => {
77
77
  helia.addRouter(delegatedHTTPRouter({
78
+ ...init,
78
79
  url
79
80
  }));
80
81
  });
81
- helia.addRouter(fallbackRouter({
82
- gateways: init?.recursiveGateways ?? DEFAULT_TRUSTLESS_GATEWAYS
83
- }));
82
+ // add recursive gateways as fallback if configured
83
+ const recursiveGateways = init?.recursiveGateways ?? DEFAULT_TRUSTLESS_GATEWAYS;
84
+ if (recursiveGateways.length > 0) {
85
+ helia.addRouter(fallbackRouter({
86
+ gateways: recursiveGateways
87
+ }));
88
+ }
84
89
  // add trustless gateway block broker
85
90
  if (!helia.hasBlockBroker('trustless-gateway')) {
86
- helia.addBlockBroker(trustlessGatewayBlockBroker(init?.trustlessGatewayBlockBrokerInit));
91
+ helia.addBlockBroker(trustlessGatewayBlockBroker(init));
87
92
  }
88
93
  return helia;
89
94
  }
@@ -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,SAA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AM,GAAG,CAAC,EAAE,CAAC;QACjC,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC;YAC7B,QAAQ,EAAE,iBAAiB;SAC5B,CAAC,CAAC,CAAA;IACL,CAAC;IAED,qCAAqC;IACrC,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,mBAAmB,CAAC,EAAE,CAAC;QAC/C,KAAK,CAAC,cAAc,CAAC,2BAA2B,CAAC,IAAI,CAAC,CAAC,CAAA;IACzD,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.2",
3
+ "version": "4.0.3-da4aa40a",
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.2",
52
- "@helia/fallback-router": "^1.0.2",
53
- "@helia/interface": "^7.0.2",
54
- "@helia/trustless-gateway-client": "^1.0.2"
51
+ "@helia/delegated-routing-client": "1.0.3-da4aa40a",
52
+ "@helia/fallback-router": "1.0.2-da4aa40a",
53
+ "@helia/interface": "7.0.2-da4aa40a",
54
+ "@helia/trustless-gateway-client": "1.0.2-da4aa40a"
55
55
  },
56
56
  "devDependencies": {
57
57
  "aegir": "^48.0.11",
package/src/index.ts CHANGED
@@ -73,7 +73,7 @@ export const DEFAULT_TRUSTLESS_GATEWAYS = [
73
73
  'https://4everland.io'
74
74
  ]
75
75
 
76
- export interface HTTPOptions {
76
+ export interface HTTPOptions extends TrustlessGatewayBlockBrokerInit {
77
77
  /**
78
78
  * Delegated routers are servers that make routing requests on behalf of peers
79
79
  * with less capable network connectivity.
@@ -96,32 +96,48 @@ export interface HTTPOptions {
96
96
  recursiveGateways?: string[]
97
97
 
98
98
  /**
99
- * Init arg passed to the trustless gateway block broker
99
+ * List of protocols to filter in the PeerRecords as defined in IPIP-484
100
+ * If undefined, PeerRecords are not filtered by protocol
100
101
  *
101
- * @see https://docs.ipfs.tech/reference/http/gateway/#trusted-vs-trustless
102
+ * @see https://github.com/ipfs/specs/pull/484
103
+ * @default undefined
102
104
  */
103
- trustlessGatewayBlockBrokerInit?: TrustlessGatewayBlockBrokerInit
105
+ filterProtocols?: string[]
106
+
107
+ /**
108
+ * Array of address filters to filter PeerRecords's addresses as defined in IPIP-484
109
+ * If undefined, PeerRecords are not filtered by address
110
+ *
111
+ * @see https://github.com/ipfs/specs/pull/484
112
+ * @default undefined
113
+ */
114
+ filterAddrs?: string[]
104
115
  }
105
116
 
106
117
  /**
107
118
  * Augment a Helia node with HTTP routers and block brokers
108
119
  */
109
120
  export function withHTTP <H extends Helia> (helia: H, init?: HTTPOptions): H {
110
- init?.delegatedRouters ?? [
121
+ (init?.delegatedRouters ?? [
111
122
  'https://delegated-ipfs.dev'
112
- ].forEach(url => {
123
+ ]).forEach(url => {
113
124
  helia.addRouter(delegatedHTTPRouter({
125
+ ...init,
114
126
  url
115
127
  }))
116
128
  })
117
129
 
118
- helia.addRouter(fallbackRouter({
119
- gateways: init?.recursiveGateways ?? DEFAULT_TRUSTLESS_GATEWAYS
120
- }))
130
+ // add recursive gateways as fallback if configured
131
+ const recursiveGateways = init?.recursiveGateways ?? DEFAULT_TRUSTLESS_GATEWAYS
132
+ if (recursiveGateways.length > 0) {
133
+ helia.addRouter(fallbackRouter({
134
+ gateways: recursiveGateways
135
+ }))
136
+ }
121
137
 
122
138
  // add trustless gateway block broker
123
139
  if (!helia.hasBlockBroker('trustless-gateway')) {
124
- helia.addBlockBroker(trustlessGatewayBlockBroker(init?.trustlessGatewayBlockBrokerInit))
140
+ helia.addBlockBroker(trustlessGatewayBlockBroker(init))
125
141
  }
126
142
 
127
143
  return helia
@@ -1,8 +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
- "DEFAULT_TRUSTLESS_GATEWAYS": "https://ipfs.github.io/helia/variables/_helia_http.DEFAULT_TRUSTLESS_GATEWAYS.html",
5
- ".:DEFAULT_TRUSTLESS_GATEWAYS": "https://ipfs.github.io/helia/variables/_helia_http.DEFAULT_TRUSTLESS_GATEWAYS.html",
6
- "withHTTP": "https://ipfs.github.io/helia/functions/_helia_http.withHTTP.html",
7
- ".:withHTTP": "https://ipfs.github.io/helia/functions/_helia_http.withHTTP.html"
8
- }