@helia/block-brokers 4.2.4-93aa4645 → 4.2.4-e502d45f

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.
@@ -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';
@@ -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
@@ -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. This lets you modify the fetch options to pass custom headers or other necessary things.
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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AAC,IAAI,CAAC,GAAG,CAAC,CAAA;gBAC3B,CAAC;qBAAM,CAAC;oBACN,eAAe,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,qCAAqC,GAAG,iBAAiB,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAA;gBACzG,CAAC;gBAED,uCAAuC;gBACvC,IAAI,OAAO,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,EAAE,CAAC;oBACrC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,qEAAqE,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,CAAA;oBACvG,MAAK;gBACP,CAAC;YACH,CAAC;QACH,CAAC;QAED,IAAI,eAAe,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC/B,MAAM,IAAI,cAAc,CAAC,eAAe,EAAE,qCAAqC,GAAG,mBAAmB,CAAC,CAAA;QACxG,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CAAC,qCAAqC,GAAG,mBAAmB,CAAC,CAAA;QAC9E,CAAC;IACH,CAAC;IAED,aAAa,CAAE,UAAgD,EAAE;QAC/D,OAAO,6BAA6B,CAAC;YACnC,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB,EAAE;YACD,GAAG,OAAO;YACV,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,oBAAoB,EAAE,IAAI,CAAC,oBAAoB;SAChD,CAAC,CAAA;IACJ,CAAC;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@helia/block-brokers",
3
- "version": "4.2.4-93aa4645",
3
+ "version": "4.2.4-e502d45f",
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",
@@ -47,9 +47,9 @@
47
47
  "test:electron-main": "aegir test -t electron-main"
48
48
  },
49
49
  "dependencies": {
50
- "@helia/bitswap": "2.2.0-93aa4645",
51
- "@helia/interface": "5.4.0-93aa4645",
52
- "@helia/utils": "1.4.0-93aa4645",
50
+ "@helia/bitswap": "2.2.0-e502d45f",
51
+ "@helia/interface": "5.4.0-e502d45f",
52
+ "@helia/utils": "1.4.0-e502d45f",
53
53
  "@libp2p/interface": "^3.0.2",
54
54
  "@libp2p/utils": "^7.0.5",
55
55
  "@multiformats/multiaddr": "^13.0.1",
@@ -71,6 +71,7 @@
71
71
  "aegir": "^47.0.22",
72
72
  "cors": "^2.8.5",
73
73
  "polka": "^0.5.2",
74
+ "race-signal": "^2.0.0",
74
75
  "sinon": "^21.0.0",
75
76
  "sinon-ts": "^2.0.0",
76
77
  "uint8arrays": "^5.1.0"
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. This lets you modify the fetch options to pass custom headers or other necessary things.
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
  }