@helia/http 4.0.3 → 4.0.4

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.
@@ -81,6 +81,22 @@ export interface HTTPOptions extends TrustlessGatewayBlockBrokerInit {
81
81
  * @see https://docs.ipfs.tech/concepts/ipfs-gateway/#recursive-vs-non-recursive-gateways
82
82
  */
83
83
  recursiveGateways?: string[];
84
+ /**
85
+ * List of protocols to filter in the PeerRecords as defined in IPIP-484
86
+ * If undefined, PeerRecords are not filtered by protocol
87
+ *
88
+ * @see https://github.com/ipfs/specs/pull/484
89
+ * @default undefined
90
+ */
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[];
84
100
  }
85
101
  /**
86
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,WAAY,SAAQ,+BAA+B;IAClE;;;;;;OAMG;IACH,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAA;IAE3B;;;;;;;;;OASG;IACH,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAA;CAC7B;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAE,CAAC,SAAS,KAAK,EAAG,KAAK,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,CAAC,CAqB3E"}
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
@@ -75,14 +75,17 @@ export function withHTTP(helia, init) {
75
75
  'https://delegated-ipfs.dev'
76
76
  ]).forEach(url => {
77
77
  helia.addRouter(delegatedHTTPRouter({
78
- url,
79
- filterProtocols: ['unknown', 'transport-ipfs-gateway-http'],
80
- filterAddrs: ['https', ...(init?.allowInsecure === true ? ['http'] : [])]
78
+ ...init,
79
+ url
81
80
  }));
82
81
  });
83
- helia.addRouter(fallbackRouter({
84
- gateways: init?.recursiveGateways ?? DEFAULT_TRUSTLESS_GATEWAYS
85
- }));
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
+ }
86
89
  // add trustless gateway block broker
87
90
  if (!helia.hasBlockBroker('trustless-gateway')) {
88
91
  helia.addBlockBroker(trustlessGatewayBlockBroker(init));
@@ -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;AAyBD;;GAEG;AACH,MAAM,UAAU,QAAQ,CAAoB,KAAQ,EAAE,IAAkB;IACtE,CAAC,IAAI,EAAE,gBAAgB,IAAI;QACzB,4BAA4B;KAC7B,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;QACf,KAAK,CAAC,SAAS,CAAC,mBAAmB,CAAC;YAClC,GAAG;YACH,eAAe,EAAE,CAAC,SAAS,EAAE,6BAA6B,CAAC;YAC3D,WAAW,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC,IAAI,EAAE,aAAa,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;SAC1E,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,C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;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",
3
+ "version": "4.0.4",
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.3",
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.4",
52
+ "@helia/fallback-router": "^1.0.3",
53
+ "@helia/interface": "^7.0.3",
54
+ "@helia/trustless-gateway-client": "^1.0.3"
55
55
  },
56
56
  "devDependencies": {
57
57
  "aegir": "^48.0.11",
package/src/index.ts CHANGED
@@ -94,6 +94,24 @@ export interface HTTPOptions extends TrustlessGatewayBlockBrokerInit {
94
94
  * @see https://docs.ipfs.tech/concepts/ipfs-gateway/#recursive-vs-non-recursive-gateways
95
95
  */
96
96
  recursiveGateways?: string[]
97
+
98
+ /**
99
+ * List of protocols to filter in the PeerRecords as defined in IPIP-484
100
+ * If undefined, PeerRecords are not filtered by protocol
101
+ *
102
+ * @see https://github.com/ipfs/specs/pull/484
103
+ * @default undefined
104
+ */
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[]
97
115
  }
98
116
 
99
117
  /**
@@ -104,15 +122,18 @@ export function withHTTP <H extends Helia> (helia: H, init?: HTTPOptions): H {
104
122
  'https://delegated-ipfs.dev'
105
123
  ]).forEach(url => {
106
124
  helia.addRouter(delegatedHTTPRouter({
107
- url,
108
- filterProtocols: ['unknown', 'transport-ipfs-gateway-http'],
109
- filterAddrs: ['https', ...(init?.allowInsecure === true ? ['http'] : [])]
125
+ ...init,
126
+ url
110
127
  }))
111
128
  })
112
129
 
113
- helia.addRouter(fallbackRouter({
114
- gateways: init?.recursiveGateways ?? DEFAULT_TRUSTLESS_GATEWAYS
115
- }))
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
+ }
116
137
 
117
138
  // add trustless gateway block broker
118
139
  if (!helia.hasBlockBroker('trustless-gateway')) {