@helia/block-brokers 4.2.4 → 5.0.0-d9051cdc
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 +62 -0
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +4 -4
- package/dist/src/bitswap.js +4 -4
- package/dist/src/bitswap.js.map +1 -1
- package/dist/src/index.d.ts +48 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +48 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/trustless-gateway/broker.d.ts +4 -1
- package/dist/src/trustless-gateway/broker.d.ts.map +1 -1
- package/dist/src/trustless-gateway/broker.js.map +1 -1
- package/dist/src/trustless-gateway/utils.d.ts +2 -2
- package/dist/src/trustless-gateway/utils.d.ts.map +1 -1
- package/dist/src/trustless-gateway/utils.js +3 -3
- package/dist/src/trustless-gateway/utils.js.map +1 -1
- package/package.json +20 -26
- package/src/bitswap.ts +4 -4
- package/src/index.ts +49 -0
- package/src/trustless-gateway/broker.ts +5 -1
- package/src/trustless-gateway/utils.ts +6 -5
- package/dist/typedoc-urls.json +0 -9
package/dist/src/bitswap.js
CHANGED
|
@@ -25,8 +25,8 @@ class BitswapBlockBroker {
|
|
|
25
25
|
await this.bitswap.stop();
|
|
26
26
|
this.started = false;
|
|
27
27
|
}
|
|
28
|
-
async announce(cid,
|
|
29
|
-
await this.bitswap.notify(cid,
|
|
28
|
+
async announce(cid, options) {
|
|
29
|
+
await this.bitswap.notify(cid, options);
|
|
30
30
|
}
|
|
31
31
|
async retrieve(cid, options = {}) {
|
|
32
32
|
return this.bitswap.want(cid, options);
|
|
@@ -34,8 +34,8 @@ class BitswapBlockBroker {
|
|
|
34
34
|
createSession(options) {
|
|
35
35
|
const session = this.bitswap.createSession(options);
|
|
36
36
|
return {
|
|
37
|
-
announce: async (cid,
|
|
38
|
-
await this.bitswap.notify(cid,
|
|
37
|
+
announce: async (cid, options) => {
|
|
38
|
+
await this.bitswap.notify(cid, options);
|
|
39
39
|
},
|
|
40
40
|
retrieve: async (cid, options) => {
|
|
41
41
|
return session.retrieve(cid, options);
|
package/dist/src/bitswap.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bitswap.js","sourceRoot":"","sources":["../../src/bitswap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAoB9C,MAAM,kBAAkB;IACL,OAAO,CAAS;IACzB,OAAO,CAAS;IAExB,YAAa,UAAwC,EAAE,OAA+B,EAAE;QACtF,MAAM,EAAE,SAAS,EAAE,GAAG,UAAU,CAAA;QAEhC,IAAI,CAAC,OAAO,GAAG,aAAa,CAAC,UAAU,EAAE;YACvC,UAAU,EAAE;gBACV,SAAS,EAAE,KAAK,EAAE,WAAmB,EAAoC,EAAE;oBACzE,OAAO,SAAS,CAAC,WAAW,CAAC,CAAA;gBAC/B,CAAC;aACF;YACD,GAAG,IAAI;SACR,CAAC,CAAA;QACF,IAAI,CAAC,OAAO,GAAG,KAAK,CAAA;IACtB,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC,OAAO,CAAA;IACrB,CAAC;IAED,KAAK,CAAC,KAAK;QACT,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAA;QAC1B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAA;IACrB,CAAC;IAED,KAAK,CAAC,IAAI;QACR,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAA;QACzB,IAAI,CAAC,OAAO,GAAG,KAAK,CAAA;IACtB,CAAC;IAED,KAAK,CAAC,QAAQ,CAAE,GAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"bitswap.js","sourceRoot":"","sources":["../../src/bitswap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAoB9C,MAAM,kBAAkB;IACL,OAAO,CAAS;IACzB,OAAO,CAAS;IAExB,YAA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QAAQ,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE;gBAC/B,OAAO,OAAO,CAAC,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;YACvC,CAAC;SACF,CAAA;IACH,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,UAAU,OAAO,CAAE,OAA+B,EAAE;IACxD,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,IAAI,kBAAkB,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;AACjE,CAAC"}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,3 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
*
|
|
4
|
+
* This module contains Helia block brokers, currently for [bitswap](https://docs.ipfs.tech/concepts/bitswap/)
|
|
5
|
+
* and [Trustless Gateways](https://specs.ipfs.tech/http-gateways/trustless-gateway/).
|
|
6
|
+
*
|
|
7
|
+
* ## Trustless Gateway Block Broker
|
|
8
|
+
*
|
|
9
|
+
* The TrustlessGatewayBlockBroker fetches blocks from HTTP gateways.
|
|
10
|
+
*
|
|
11
|
+
* @example Customizing fetch requests with custom headers
|
|
12
|
+
*
|
|
13
|
+
* It is possible to modify outgoing requests to (for example) include
|
|
14
|
+
* authentication information (such as a JWT token in a header).
|
|
15
|
+
*
|
|
16
|
+
* ```typescript
|
|
17
|
+
* import { createHelia } from 'helia'
|
|
18
|
+
* import { trustlessGateway } from '@helia/block-brokers'
|
|
19
|
+
* import { unixfs } from '@helia/unixfs'
|
|
20
|
+
* import { CID } from 'multiformats/cid'
|
|
21
|
+
* import { concat } from 'uint8arrays/concat'
|
|
22
|
+
* import all from 'it-all'
|
|
23
|
+
*
|
|
24
|
+
* const helia = await createHelia({
|
|
25
|
+
* blockBrokers: [
|
|
26
|
+
* trustlessGateway({
|
|
27
|
+
* transformRequestInit: (requestInit) => {
|
|
28
|
+
* // modify the request init object as required
|
|
29
|
+
* requestInit.headers = {
|
|
30
|
+
* ...requestInit.headers,
|
|
31
|
+
* 'User-Agent': 'Helia Example Script'
|
|
32
|
+
* }
|
|
33
|
+
* return requestInit
|
|
34
|
+
* }
|
|
35
|
+
* })
|
|
36
|
+
* ]
|
|
37
|
+
* })
|
|
38
|
+
*
|
|
39
|
+
* const cid = CID.parse('bafkreife2klsil6kaxqhvmhgldpsvk5yutzm4i5bgjoq6fydefwtihnesa')
|
|
40
|
+
* const fs = unixfs(helia)
|
|
41
|
+
*
|
|
42
|
+
* for await (const chunk of fs.cat(cid, {
|
|
43
|
+
* signal: AbortSignal.timeout(10_000)
|
|
44
|
+
* })) {
|
|
45
|
+
* console.info(chunk)
|
|
46
|
+
* }
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
1
49
|
export { bitswap } from './bitswap.js';
|
|
2
50
|
export type { BitswapBlockBrokerInit, BitswapBlockBrokerComponents } from './bitswap.js';
|
|
3
51
|
export { trustlessGateway } from './trustless-gateway/index.js';
|
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,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,YAAY,EAAE,sBAAsB,EAAE,4BAA4B,EAAE,MAAM,cAAc,CAAA;AACxF,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAA;AAC/D,YAAY,EAAE,+BAA+B,EAAE,qCAAqC,EAAE,sCAAsC,EAAE,MAAM,8BAA8B,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,YAAY,EAAE,sBAAsB,EAAE,4BAA4B,EAAE,MAAM,cAAc,CAAA;AACxF,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAA;AAC/D,YAAY,EAAE,+BAA+B,EAAE,qCAAqC,EAAE,sCAAsC,EAAE,MAAM,8BAA8B,CAAA"}
|
package/dist/src/index.js
CHANGED
|
@@ -1,3 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
*
|
|
4
|
+
* This module contains Helia block brokers, currently for [bitswap](https://docs.ipfs.tech/concepts/bitswap/)
|
|
5
|
+
* and [Trustless Gateways](https://specs.ipfs.tech/http-gateways/trustless-gateway/).
|
|
6
|
+
*
|
|
7
|
+
* ## Trustless Gateway Block Broker
|
|
8
|
+
*
|
|
9
|
+
* The TrustlessGatewayBlockBroker fetches blocks from HTTP gateways.
|
|
10
|
+
*
|
|
11
|
+
* @example Customizing fetch requests with custom headers
|
|
12
|
+
*
|
|
13
|
+
* It is possible to modify outgoing requests to (for example) include
|
|
14
|
+
* authentication information (such as a JWT token in a header).
|
|
15
|
+
*
|
|
16
|
+
* ```typescript
|
|
17
|
+
* import { createHelia } from 'helia'
|
|
18
|
+
* import { trustlessGateway } from '@helia/block-brokers'
|
|
19
|
+
* import { unixfs } from '@helia/unixfs'
|
|
20
|
+
* import { CID } from 'multiformats/cid'
|
|
21
|
+
* import { concat } from 'uint8arrays/concat'
|
|
22
|
+
* import all from 'it-all'
|
|
23
|
+
*
|
|
24
|
+
* const helia = await createHelia({
|
|
25
|
+
* blockBrokers: [
|
|
26
|
+
* trustlessGateway({
|
|
27
|
+
* transformRequestInit: (requestInit) => {
|
|
28
|
+
* // modify the request init object as required
|
|
29
|
+
* requestInit.headers = {
|
|
30
|
+
* ...requestInit.headers,
|
|
31
|
+
* 'User-Agent': 'Helia Example Script'
|
|
32
|
+
* }
|
|
33
|
+
* return requestInit
|
|
34
|
+
* }
|
|
35
|
+
* })
|
|
36
|
+
* ]
|
|
37
|
+
* })
|
|
38
|
+
*
|
|
39
|
+
* const cid = CID.parse('bafkreife2klsil6kaxqhvmhgldpsvk5yutzm4i5bgjoq6fydefwtihnesa')
|
|
40
|
+
* const fs = unixfs(helia)
|
|
41
|
+
*
|
|
42
|
+
* for await (const chunk of fs.cat(cid, {
|
|
43
|
+
* signal: AbortSignal.timeout(10_000)
|
|
44
|
+
* })) {
|
|
45
|
+
* console.info(chunk)
|
|
46
|
+
* }
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
1
49
|
export { bitswap } from './bitswap.js';
|
|
2
50
|
export { trustlessGateway } from './trustless-gateway/index.js';
|
|
3
51
|
//# 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,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAEtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAEtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAA"}
|
|
@@ -18,7 +18,10 @@ export interface CreateTrustlessGatewaySessionOptions extends CreateSessionOptio
|
|
|
18
18
|
*/
|
|
19
19
|
allowLocal?: boolean;
|
|
20
20
|
/**
|
|
21
|
-
* Provide a function that will be called before querying trustless-gateways.
|
|
21
|
+
* Provide a function that will be called before querying trustless-gateways.
|
|
22
|
+
*
|
|
23
|
+
* This lets you modify the fetch options to pass custom headers or other
|
|
24
|
+
* necessary things.
|
|
22
25
|
*/
|
|
23
26
|
transformRequestInit?: TransformRequestInit;
|
|
24
27
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"broker.d.ts","sourceRoot":"","sources":["../../../src/trust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AAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAC,CAAsB;IAC5D,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAQ;IAC5B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiB;gBAE3B,UAAU,EAAE,qCAAqC,EAAE,IAAI,GAAE,+BAAoC;IASpG,QAAQ,CAAE,GAAG,EAAE,GAAG,EAAE,OAAO,GAAE,qBAAqB,CAAC,sCAAsC,CAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IA2C3H,aAAa,CAAE,OAAO,GAAE,oCAAyC,GAAG,WAAW,CAAC,sCAAsC,CAAC;CAWxH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"broker.js","sourceRoot":"","sources":["../../../src/trustless-gateway/broker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,MAAM,cAAc,CAAA;AAC5D,OAAO,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAA;AACrD,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"broker.js","sourceRoot":"","sources":["../../../src/trustless-gateway/broker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,MAAM,cAAc,CAAA;AAC5D,OAAO,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAA;AACrD,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAiCxE;;;GAGG;AACH,MAAM,OAAO,2BAA2B;IACrB,aAAa,CAAS;IACtB,UAAU,CAAS;IACnB,oBAAoB,CAAuB;IAC3C,OAAO,CAAS;IAChB,GAAG,CAAQ;IACX,MAAM,CAAiB;IAExC,YAAa,UAAiD,EAAE,OAAwC,EAAE;QACxG,IAAI,CAAC,GAAG,GAAG,UAAU,CAAC,MAAM,CAAC,YA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|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { TrustlessGateway } from './trustless-gateway.js';
|
|
2
2
|
import type { TransformRequestInit } from './trustless-gateway.js';
|
|
3
3
|
import type { Routing } from '@helia/interface';
|
|
4
|
-
import type { ComponentLogger, Logger } from '@libp2p/interface';
|
|
5
|
-
import type {
|
|
4
|
+
import type { ComponentLogger, Logger, AbortOptions } from '@libp2p/interface';
|
|
5
|
+
import type { Multiaddr } from '@multiformats/multiaddr';
|
|
6
6
|
import type { CID } from 'multiformats/cid';
|
|
7
7
|
export declare function filterNonHTTPMultiaddrs(multiaddrs: Multiaddr[], allowInsecure: boolean, allowLocal: boolean): Multiaddr[];
|
|
8
8
|
export interface FindHttpGatewayProvidersOptions extends AbortOptions {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/trustless-gateway/utils.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AACzD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAClE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAC/C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/trustless-gateway/utils.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AACzD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAClE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAC/C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAC9E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAE3C,wBAAgB,uBAAuB,CAAE,UAAU,EAAE,SAAS,EAAE,EAAE,aAAa,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,GAAG,SAAS,EAAE,CAyB1H;AAED,MAAM,WAAW,+BAAgC,SAAQ,YAAY;IACnE,oBAAoB,CAAC,EAAE,oBAAoB,CAAA;CAC5C;AAED,wBAAwB,wBAAwB,CAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,aAAa,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,GAAE,+BAAoC,GAAG,cAAc,CAAC,gBAAgB,CAAC,CAiBnO;AAED,UAAU,sBAAsB;IAC9B,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,GAAG,CAAC,EAAE,MAAM,CAAA;CACb;AAED;;;;;GAKG;AACH,wBAAsB,eAAe,CAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,sBAAsB,GAAG,OAAO,CAAC,UAAU,CAAC,CAqDnI"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getNetConfig, isPrivate } from '@libp2p/utils';
|
|
2
2
|
import { DNS, HTTP, HTTPS } from '@multiformats/multiaddr-matcher';
|
|
3
3
|
import { multiaddrToUri } from '@multiformats/multiaddr-to-uri';
|
|
4
4
|
import { Uint8ArrayList } from 'uint8arraylist';
|
|
@@ -12,11 +12,11 @@ export function filterNonHTTPMultiaddrs(multiaddrs, allowInsecure, allowLocal) {
|
|
|
12
12
|
if (DNS.matches(ma)) {
|
|
13
13
|
return true;
|
|
14
14
|
}
|
|
15
|
-
return
|
|
15
|
+
return isPrivate(ma) === false;
|
|
16
16
|
}
|
|
17
17
|
// When allowInsecure is false and allowLocal is true, allow multiaddrs with "127.0.0.1", "localhost", or any subdomain ending with ".localhost"
|
|
18
18
|
if (!allowInsecure && allowLocal) {
|
|
19
|
-
const { host } = ma
|
|
19
|
+
const { host } = getNetConfig(ma);
|
|
20
20
|
if (host === '127.0.0.1' || host === 'localhost' || host.endsWith('.localhost')) {
|
|
21
21
|
return true;
|
|
22
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/trustless-gateway/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/trustless-gateway/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AACvD,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,iCAAiC,CAAA;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAOzD,MAAM,UAAU,uBAAuB,CAAE,UAAuB,EAAE,aAAsB,EAAE,UAAmB;IAC3G,OAAO,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE;QAC5B,IAAI,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,aAAa,IAAI,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;YAC7D,IAAI,UAAU,EAAE,CAAC;gBACf,OAAO,IAAI,CAAA;YACb,CAAC;YAED,IAAI,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC;gBACpB,OAAO,IAAI,CAAA;YACb,CAAC;YAED,OAAO,SAAS,CAAC,EAAE,CAAC,KAAK,KAAK,CAAA;QAChC,CAAC;QAED,gJAAgJ;QAChJ,IAAI,CAAC,aAAa,IAAI,UAAU,EAAE,CAAC;YACjC,MAAM,EAAE,IAAI,E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AAC,4CAA4C,SAAS,eAAe,SAAS,CAAC,UAAU,SAAS,CAAC,CAAA;YACpH,CAAC;QACH,CAAC;IACH,CAAC;YAAS,CAAC;QACT,MAAM,CAAC,MAAM,EAAE;aACZ,KAAK,CAAC,GAAG,CAAC,EAAE;YACX,GAAG,EAAE,KAAK,CAAC,8BAA8B,EAAE,GAAG,CAAC,CAAA;QACjD,CAAC,CAAC;aACD,OAAO,CAAC,GAAG,EAAE;YACZ,MAAM,CAAC,WAAW,EAAE,CAAA;QACtB,CAAC,CAAC,CAAA;IACN,CAAC;IAED,OAAO,SAAS,CAAC,QAAQ,EAAE,CAAA;AAC7B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@helia/block-brokers",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0-d9051cdc",
|
|
4
4
|
"description": "Block brokers for Helia",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/ipfs/helia/tree/main/packages/block-brokers#readme",
|
|
@@ -32,13 +32,6 @@
|
|
|
32
32
|
"import": "./dist/src/index.js"
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
|
-
"eslintConfig": {
|
|
36
|
-
"extends": "ipfs",
|
|
37
|
-
"parserOptions": {
|
|
38
|
-
"project": true,
|
|
39
|
-
"sourceType": "module"
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
35
|
"scripts": {
|
|
43
36
|
"clean": "aegir clean",
|
|
44
37
|
"lint": "aegir lint",
|
|
@@ -54,31 +47,32 @@
|
|
|
54
47
|
"test:electron-main": "aegir test -t electron-main"
|
|
55
48
|
},
|
|
56
49
|
"dependencies": {
|
|
57
|
-
"@helia/bitswap": "
|
|
58
|
-
"@helia/interface": "
|
|
59
|
-
"@helia/utils": "
|
|
60
|
-
"@libp2p/interface": "^
|
|
61
|
-
"@libp2p/utils": "^
|
|
62
|
-
"@multiformats/multiaddr": "^
|
|
63
|
-
"@multiformats/multiaddr-matcher": "^
|
|
64
|
-
"@multiformats/multiaddr-to-uri": "^
|
|
65
|
-
"interface-blockstore": "^
|
|
66
|
-
"interface-store": "^
|
|
67
|
-
"multiformats": "^13.
|
|
50
|
+
"@helia/bitswap": "3.0.0-d9051cdc",
|
|
51
|
+
"@helia/interface": "6.0.0-d9051cdc",
|
|
52
|
+
"@helia/utils": "2.0.0-d9051cdc",
|
|
53
|
+
"@libp2p/interface": "^3.0.2",
|
|
54
|
+
"@libp2p/utils": "^7.0.5",
|
|
55
|
+
"@multiformats/multiaddr": "^13.0.1",
|
|
56
|
+
"@multiformats/multiaddr-matcher": "^3.0.1",
|
|
57
|
+
"@multiformats/multiaddr-to-uri": "^12.0.0",
|
|
58
|
+
"interface-blockstore": "^6.0.1",
|
|
59
|
+
"interface-store": "^7.0.0",
|
|
60
|
+
"multiformats": "^13.4.1",
|
|
68
61
|
"progress-events": "^1.0.1",
|
|
69
62
|
"uint8arraylist": "^2.4.8"
|
|
70
63
|
},
|
|
71
64
|
"devDependencies": {
|
|
72
|
-
"@libp2p/crypto": "^5.
|
|
73
|
-
"@libp2p/logger": "^
|
|
74
|
-
"@libp2p/peer-id": "^
|
|
75
|
-
"@multiformats/uri-to-multiaddr": "^
|
|
65
|
+
"@libp2p/crypto": "^5.1.12",
|
|
66
|
+
"@libp2p/logger": "^6.0.5",
|
|
67
|
+
"@libp2p/peer-id": "^6.0.3",
|
|
68
|
+
"@multiformats/uri-to-multiaddr": "^10.0.0",
|
|
76
69
|
"@types/polka": "^0.5.7",
|
|
77
|
-
"@types/sinon": "^17.0.
|
|
78
|
-
"aegir": "^47.0.
|
|
70
|
+
"@types/sinon": "^17.0.4",
|
|
71
|
+
"aegir": "^47.0.22",
|
|
79
72
|
"cors": "^2.8.5",
|
|
80
73
|
"polka": "^0.5.2",
|
|
81
|
-
"
|
|
74
|
+
"race-signal": "^2.0.0",
|
|
75
|
+
"sinon": "^21.0.0",
|
|
82
76
|
"sinon-ts": "^2.0.0",
|
|
83
77
|
"uint8arrays": "^5.1.0"
|
|
84
78
|
}
|
package/src/bitswap.ts
CHANGED
|
@@ -50,8 +50,8 @@ class BitswapBlockBroker implements BlockBroker<BitswapWantBlockProgressEvents,
|
|
|
50
50
|
this.started = false
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
async announce (cid: CID,
|
|
54
|
-
await this.bitswap.notify(cid,
|
|
53
|
+
async announce (cid: CID, options?: BlockAnnounceOptions<BitswapNotifyProgressEvents>): Promise<void> {
|
|
54
|
+
await this.bitswap.notify(cid, options)
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
async retrieve (cid: CID, options: BlockRetrievalOptions<BitswapWantBlockProgressEvents> = {}): Promise<Uint8Array> {
|
|
@@ -62,8 +62,8 @@ class BitswapBlockBroker implements BlockBroker<BitswapWantBlockProgressEvents,
|
|
|
62
62
|
const session = this.bitswap.createSession(options)
|
|
63
63
|
|
|
64
64
|
return {
|
|
65
|
-
announce: async (cid,
|
|
66
|
-
await this.bitswap.notify(cid,
|
|
65
|
+
announce: async (cid, options) => {
|
|
66
|
+
await this.bitswap.notify(cid, options)
|
|
67
67
|
},
|
|
68
68
|
|
|
69
69
|
retrieve: async (cid, options) => {
|
package/src/index.ts
CHANGED
|
@@ -1,3 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
*
|
|
4
|
+
* This module contains Helia block brokers, currently for [bitswap](https://docs.ipfs.tech/concepts/bitswap/)
|
|
5
|
+
* and [Trustless Gateways](https://specs.ipfs.tech/http-gateways/trustless-gateway/).
|
|
6
|
+
*
|
|
7
|
+
* ## Trustless Gateway Block Broker
|
|
8
|
+
*
|
|
9
|
+
* The TrustlessGatewayBlockBroker fetches blocks from HTTP gateways.
|
|
10
|
+
*
|
|
11
|
+
* @example Customizing fetch requests with custom headers
|
|
12
|
+
*
|
|
13
|
+
* It is possible to modify outgoing requests to (for example) include
|
|
14
|
+
* authentication information (such as a JWT token in a header).
|
|
15
|
+
*
|
|
16
|
+
* ```typescript
|
|
17
|
+
* import { createHelia } from 'helia'
|
|
18
|
+
* import { trustlessGateway } from '@helia/block-brokers'
|
|
19
|
+
* import { unixfs } from '@helia/unixfs'
|
|
20
|
+
* import { CID } from 'multiformats/cid'
|
|
21
|
+
* import { concat } from 'uint8arrays/concat'
|
|
22
|
+
* import all from 'it-all'
|
|
23
|
+
*
|
|
24
|
+
* const helia = await createHelia({
|
|
25
|
+
* blockBrokers: [
|
|
26
|
+
* trustlessGateway({
|
|
27
|
+
* transformRequestInit: (requestInit) => {
|
|
28
|
+
* // modify the request init object as required
|
|
29
|
+
* requestInit.headers = {
|
|
30
|
+
* ...requestInit.headers,
|
|
31
|
+
* 'User-Agent': 'Helia Example Script'
|
|
32
|
+
* }
|
|
33
|
+
* return requestInit
|
|
34
|
+
* }
|
|
35
|
+
* })
|
|
36
|
+
* ]
|
|
37
|
+
* })
|
|
38
|
+
*
|
|
39
|
+
* const cid = CID.parse('bafkreife2klsil6kaxqhvmhgldpsvk5yutzm4i5bgjoq6fydefwtihnesa')
|
|
40
|
+
* const fs = unixfs(helia)
|
|
41
|
+
*
|
|
42
|
+
* for await (const chunk of fs.cat(cid, {
|
|
43
|
+
* signal: AbortSignal.timeout(10_000)
|
|
44
|
+
* })) {
|
|
45
|
+
* console.info(chunk)
|
|
46
|
+
* }
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
|
|
1
50
|
export { bitswap } from './bitswap.js'
|
|
2
51
|
export type { BitswapBlockBrokerInit, BitswapBlockBrokerComponents } from './bitswap.js'
|
|
3
52
|
export { trustlessGateway } from './trustless-gateway/index.js'
|
|
@@ -23,8 +23,12 @@ export interface CreateTrustlessGatewaySessionOptions extends CreateSessionOptio
|
|
|
23
23
|
* @default false
|
|
24
24
|
*/
|
|
25
25
|
allowLocal?: boolean
|
|
26
|
+
|
|
26
27
|
/**
|
|
27
|
-
* Provide a function that will be called before querying trustless-gateways.
|
|
28
|
+
* Provide a function that will be called before querying trustless-gateways.
|
|
29
|
+
*
|
|
30
|
+
* This lets you modify the fetch options to pass custom headers or other
|
|
31
|
+
* necessary things.
|
|
28
32
|
*/
|
|
29
33
|
transformRequestInit?: TransformRequestInit
|
|
30
34
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getNetConfig, isPrivate } from '@libp2p/utils'
|
|
2
2
|
import { DNS, HTTP, HTTPS } from '@multiformats/multiaddr-matcher'
|
|
3
3
|
import { multiaddrToUri } from '@multiformats/multiaddr-to-uri'
|
|
4
4
|
import { Uint8ArrayList } from 'uint8arraylist'
|
|
5
5
|
import { TrustlessGateway } from './trustless-gateway.js'
|
|
6
6
|
import type { TransformRequestInit } from './trustless-gateway.js'
|
|
7
7
|
import type { Routing } from '@helia/interface'
|
|
8
|
-
import type { ComponentLogger, Logger } from '@libp2p/interface'
|
|
9
|
-
import type {
|
|
8
|
+
import type { ComponentLogger, Logger, AbortOptions } from '@libp2p/interface'
|
|
9
|
+
import type { Multiaddr } from '@multiformats/multiaddr'
|
|
10
10
|
import type { CID } from 'multiformats/cid'
|
|
11
11
|
|
|
12
12
|
export function filterNonHTTPMultiaddrs (multiaddrs: Multiaddr[], allowInsecure: boolean, allowLocal: boolean): Multiaddr[] {
|
|
@@ -20,12 +20,13 @@ export function filterNonHTTPMultiaddrs (multiaddrs: Multiaddr[], allowInsecure:
|
|
|
20
20
|
return true
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
return
|
|
23
|
+
return isPrivate(ma) === false
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
// When allowInsecure is false and allowLocal is true, allow multiaddrs with "127.0.0.1", "localhost", or any subdomain ending with ".localhost"
|
|
27
27
|
if (!allowInsecure && allowLocal) {
|
|
28
|
-
const { host } = ma
|
|
28
|
+
const { host } = getNetConfig(ma)
|
|
29
|
+
|
|
29
30
|
if (host === '127.0.0.1' || host === 'localhost' || host.endsWith('.localhost')) {
|
|
30
31
|
return true
|
|
31
32
|
}
|
package/dist/typedoc-urls.json
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"BitswapBlockBrokerComponents": "https://ipfs.github.io/helia/interfaces/_helia_block-brokers.BitswapBlockBrokerComponents.html",
|
|
3
|
-
"BitswapBlockBrokerInit": "https://ipfs.github.io/helia/interfaces/_helia_block-brokers.BitswapBlockBrokerInit.html",
|
|
4
|
-
"TrustlessGatewayBlockBrokerComponents": "https://ipfs.github.io/helia/interfaces/_helia_block-brokers.TrustlessGatewayBlockBrokerComponents.html",
|
|
5
|
-
"TrustlessGatewayBlockBrokerInit": "https://ipfs.github.io/helia/interfaces/_helia_block-brokers.TrustlessGatewayBlockBrokerInit.html",
|
|
6
|
-
"TrustlessGatewayGetBlockProgressEvents": "https://ipfs.github.io/helia/types/_helia_block-brokers.TrustlessGatewayGetBlockProgressEvents.html",
|
|
7
|
-
"bitswap": "https://ipfs.github.io/helia/functions/_helia_block-brokers.bitswap.html",
|
|
8
|
-
"trustlessGateway": "https://ipfs.github.io/helia/functions/_helia_block-brokers.trustlessGateway.html"
|
|
9
|
-
}
|