@helia/libp2p 2.1.4-d4962087 → 2.1.5-05d3e4cc

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.
@@ -18,54 +18,36 @@
18
18
  *
19
19
  * By default `withLibp2p` configures a libp2p node for the current environment.
20
20
  *
21
- * Any options passed will be merged with the default config.
21
+ * Each option passed replaces the default for that key. Pass `config: 'merge'`
22
+ * to merge the options into the default config instead.
22
23
  *
23
- * For full control over your node (and the bundle size), use `withLibp2pLight`:
24
+ * For full control over your node (and the bundle size), use `withLibp2pLight`
25
+ * from `@helia/libp2p/light`. That entry point does not load the default
26
+ * config or any of its dependencies:
24
27
  *
25
28
  * ```ts
26
- * import { createHelia } from 'helia'
27
- * import { withLibp2pLight } from '@helia/libp2p'
29
+ * import { createHeliaLight } from 'helia/light'
30
+ * import { withLibp2pLight } from '@helia/libp2p/light'
28
31
  *
29
- * const node = await withLibp2pLight(createHelia(), {
32
+ * const node = await withLibp2pLight(createHeliaLight(), {
30
33
  * //... libp2p config here
31
34
  * }).start()
32
35
  *
33
36
  * console.info(node.libp2p.peerId) // 12D3Koo...
34
37
  * ```
35
38
  */
39
+ import { libp2pRouting, withLibp2pLight } from './light.ts';
40
+ import type { CreateLibp2pOptions, HeliaWithLibp2p } from './light.ts';
36
41
  import type { DefaultLibp2pServices } from './utils/libp2p-defaults.ts';
37
42
  import type { Helia } from '@helia/interface';
38
- import type { Libp2p, ServiceMap } from '@libp2p/interface';
39
- import type { KeychainInit } from '@libp2p/keychain';
40
- import type { Libp2pOptions } from 'libp2p';
43
+ import type { ServiceMap } from '@libp2p/interface';
44
+ export { libp2pRouting, withLibp2pLight };
45
+ export type { CreateLibp2pOptions, HeliaWithLibp2p };
41
46
  export { libp2pDefaults } from './utils/libp2p-defaults.ts';
42
47
  export type { DefaultLibp2pServices } from './utils/libp2p-defaults.ts';
43
- export interface CreateLibp2pOptions<T extends ServiceMap = ServiceMap> extends Libp2pOptions<T> {
44
- /**
45
- * If 'merge', any passed config will be merged into the default set. If
46
- * 'replace' any passed config keys will replace those in the default set.
47
- *
48
- * @default 'replace'
49
- */
50
- config?: 'merge' | 'replace';
51
- keychain?: KeychainInit;
52
- }
53
- export interface HeliaWithLibp2p<M extends ServiceMap = DefaultLibp2pServices> extends Helia {
54
- /**
55
- * Libp2p provides a peer identity and a networking layer
56
- */
57
- libp2p: Libp2p<M>;
58
- }
59
48
  /**
60
49
  * Return a Helia node augmented with a libp2p instance
61
50
  */
62
51
  export declare function withLibp2p<H extends Helia>(helia: H): H & HeliaWithLibp2p<DefaultLibp2pServices>;
63
52
  export declare function withLibp2p<H extends Helia, M extends ServiceMap>(helia: H, opts?: CreateLibp2pOptions<M>): H & HeliaWithLibp2p<DefaultLibp2pServices & M>;
64
- /**
65
- * Return a Helia node augmented with a libp2p instance. The passed
66
- * configuration is passed to `createLibp2p` without adding any default config.
67
- *
68
- * Use this if you do not wish to have any extra config added.
69
- */
70
- export declare function withLibp2pLight<H extends Helia, M extends ServiceMap = ServiceMap>(helia: H, opts: CreateLibp2pOptions<M>): H & HeliaWithLibp2p<M>;
71
53
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAUH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AACvE,OAAO,KAAK,EAAE,KAAK,EAA8B,MAAM,kBAAkB,CAAA;AACzE,OAAO,KAAK,EAAE,MAAM,EAAY,UAAU,EAAE,MAAM,mBAAmB,CAAA;AACrE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAEpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAA;AAG3C,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAC3D,YAAY,EAAE,qBAA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AE,MAAM,4BAA4B,CAAA;AACvE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAEnD,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,CAAA;AACzC,YAAY,EAAE,mBAAmB,EAAE,eAAe,EAAE,CAAA;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAC3D,YAAY,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AAEvE;;GAEG;AACH,wBAAgB,UAAU,CAAE,CAAC,SAAS,KAAK,EAAG,KAAK,EAAE,CAAC,GAAG,CAAC,GAAG,eAAe,CAAC,qBAAqB,CAAC,CAAA;AACnG,wBAAgB,UAAU,CAAE,CAAC,SAAS,KAAK,EAAE,CAAC,SAAS,UAAU,EAAG,KAAK,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,mBAAmB,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,eAAe,CAAC,qBAAqB,GAAG,CAAC,CAAC,CAAA"}
package/dist/src/index.js CHANGED
@@ -18,129 +18,29 @@
18
18
  *
19
19
  * By default `withLibp2p` configures a libp2p node for the current environment.
20
20
  *
21
- * Any options passed will be merged with the default config.
21
+ * Each option passed replaces the default for that key. Pass `config: 'merge'`
22
+ * to merge the options into the default config instead.
22
23
  *
23
- * For full control over your node (and the bundle size), use `withLibp2pLight`:
24
+ * For full control over your node (and the bundle size), use `withLibp2pLight`
25
+ * from `@helia/libp2p/light`. That entry point does not load the default
26
+ * config or any of its dependencies:
24
27
  *
25
28
  * ```ts
26
- * import { createHelia } from 'helia'
27
- * import { withLibp2pLight } from '@helia/libp2p'
29
+ * import { createHeliaLight } from 'helia/light'
30
+ * import { withLibp2pLight } from '@helia/libp2p/light'
28
31
  *
29
- * const node = await withLibp2pLight(createHelia(), {
32
+ * const node = await withLibp2pLight(createHeliaLight(), {
30
33
  * //... libp2p config here
31
34
  * }).start()
32
35
  *
33
36
  * console.info(node.libp2p.peerId) // 12D3Koo...
34
37
  * ```
35
38
  */
36
- import { loadOrCreateSelfKey } from '@libp2p/config';
37
- import { NotStartedError } from '@libp2p/interface';
38
- import { peerIdFromCID } from '@libp2p/peer-id';
39
- import forEach from 'it-foreach';
40
- import { createLibp2p, isLibp2p } from 'libp2p';
41
- import { userAgent } from 'libp2p/user-agent';
42
- import { libp2pRouting } from "./routing.js";
39
+ import { libp2pRouting, withLibp2pLight } from "./light.js";
43
40
  import { libp2pDefaults } from "./utils/libp2p-defaults.js";
41
+ export { libp2pRouting, withLibp2pLight };
44
42
  export { libp2pDefaults } from "./utils/libp2p-defaults.js";
45
43
  export function withLibp2p(helia, opts) {
46
44
  return withLibp2pLight(helia, libp2pDefaults(opts));
47
45
  }
48
- /**
49
- * Return a Helia node augmented with a libp2p instance. The passed
50
- * configuration is passed to `createLibp2p` without adding any default config.
51
- *
52
- * Use this if you do not wish to have any extra config added.
53
- */
54
- export function withLibp2pLight(helia, opts) {
55
- let libp2p;
56
- // add a getter that informs the user they need to start Helia
57
- Object.defineProperty(helia, 'libp2p', {
58
- configurable: true,
59
- enumerable: true,
60
- get() {
61
- if (libp2p != null) {
62
- return libp2p;
63
- }
64
- throw new NotStartedError();
65
- }
66
- });
67
- const mixin = {
68
- name: 'libp2p',
69
- start: async (helia) => {
70
- if (libp2p == null) {
71
- // if no peer id was passed, try to load it from the keychain
72
- if (opts.privateKey == null) {
73
- opts.privateKey = await loadOrCreateSelfKey(helia.datastore, opts.keychain);
74
- }
75
- // copy options from Helia node
76
- opts.nodeInfo ??= {};
77
- opts.nodeInfo.name ??= helia.info.name;
78
- opts.nodeInfo.version ??= helia.info.version;
79
- opts.nodeInfo.userAgent ??= `${helia.info.name}/${helia.info.version} ${userAgent()}`;
80
- opts.datastore ??= helia.datastore;
81
- libp2p = await createLibp2p(opts);
82
- // override peer discovery methods to ensure we persist peer data in the
83
- // peer store, otherwise we can't dial by peer id without extra lookups
84
- const findProviders = helia.routing.findProviders.bind(helia.routing);
85
- helia.routing.findProviders = async function* (cid, options) {
86
- yield* forEach(findProviders.call(helia.routing, cid, options), async (peer) => {
87
- if (peer.router !== 'libp2p-router') {
88
- // only need to do this for peers not found via the libp2p router
89
- const info = toPeerInfo(peer);
90
- await libp2p.peerStore.merge(info.id, info);
91
- }
92
- });
93
- };
94
- const findPeer = helia.routing.findPeer.bind(helia.routing);
95
- helia.routing.findPeer = async function (cid, options) {
96
- const peer = await findPeer(cid, options);
97
- if (peer.router !== 'libp2p-router') {
98
- // only need to do this for peers not found via the libp2p router
99
- const info = toPeerInfo(peer);
100
- await libp2p.peerStore.merge(info.id, info);
101
- }
102
- return peer;
103
- };
104
- // override peer discovery methods to ensure we persist peer data in the
105
- // peer store, otherwise we can't dial by peer id without extra lookups
106
- const getClosestPeers = helia.routing.getClosestPeers.bind(helia.routing);
107
- helia.routing.getClosestPeers = async function* (cid, options) {
108
- yield* forEach(getClosestPeers.call(helia.routing, cid, options), async (peer) => {
109
- if (peer.router !== 'libp2p-router') {
110
- // only need to do this for peers not found via the libp2p router
111
- const info = toPeerInfo(peer);
112
- await libp2p.peerStore.merge(info.id, info);
113
- }
114
- });
115
- };
116
- }
117
- try {
118
- if (!helia.hasRouter('libp2p-router')) {
119
- helia.addRouter(libp2pRouting(libp2p));
120
- }
121
- if (isLibp2p(helia.libp2p)) {
122
- // already configured libp2p
123
- await helia.libp2p.start();
124
- }
125
- }
126
- catch (err) {
127
- if (err.name !== 'NotStartedError') {
128
- throw err;
129
- }
130
- }
131
- },
132
- stop: async () => {
133
- await libp2p?.stop();
134
- }
135
- };
136
- helia.addMixin(mixin);
137
- // @ts-expect-error libp2p property is missing, even though we just defined it
138
- return helia;
139
- }
140
- function toPeerInfo(peer) {
141
- return {
142
- id: peerIdFromCID(peer.id),
143
- multiaddrs: peer.multiaddrs
144
- };
145
- }
146
46
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","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Ae,CAAC,KAAK,EAAE,cAAc,CAAC,IAAI,CAAC,CAAC,CAAA;AACrD,CAAC"}
@@ -0,0 +1,65 @@
1
+ /**
2
+ * @packageDocumentation
3
+ *
4
+ * Exports `withLibp2pLight`, which adds a libp2p node to Helia using only the
5
+ * config you pass to it.
6
+ *
7
+ * Unlike the main `@helia/libp2p` entry point, importing
8
+ * `@helia/libp2p/light` does not load the default libp2p config, so none of
9
+ * the default transports, services or their dependencies (including the native
10
+ * `node-datachannel` module used by `@libp2p/webrtc`) are loaded.
11
+ *
12
+ * @example Bring your own libp2p config
13
+ *
14
+ * ```ts
15
+ * import { createHeliaLight } from 'helia/light'
16
+ * import { withLibp2pLight } from '@helia/libp2p/light'
17
+ * import { tcp } from '@libp2p/tcp'
18
+ * import { noise } from '@libp2p/noise'
19
+ * import { yamux } from '@libp2p/yamux'
20
+ *
21
+ * const node = await withLibp2pLight(createHeliaLight(), {
22
+ * transports: [tcp()],
23
+ * connectionEncrypters: [noise()],
24
+ * streamMuxers: [yamux()]
25
+ * }).start()
26
+ *
27
+ * console.info(node.libp2p.peerId) // 12D3Koo...
28
+ * ```
29
+ */
30
+ import { libp2pRouting } from './routing.ts';
31
+ import type { DefaultLibp2pServices } from './utils/libp2p-defaults.ts';
32
+ import type { Helia } from '@helia/interface';
33
+ import type { Libp2p, ServiceMap } from '@libp2p/interface';
34
+ import type { KeychainInit } from '@libp2p/keychain';
35
+ import type { Libp2pOptions } from 'libp2p';
36
+ export { libp2pRouting };
37
+ export interface CreateLibp2pOptions<T extends ServiceMap = ServiceMap> extends Libp2pOptions<T> {
38
+ /**
39
+ * How `withLibp2p` combines these options with its default config. With
40
+ * 'merge' they are merged into the defaults, with 'replace' each key that is
41
+ * passed replaces the default for that key. `withLibp2pLight` has no default
42
+ * config, so it ignores this option.
43
+ *
44
+ * @default 'replace'
45
+ */
46
+ config?: 'merge' | 'replace';
47
+ keychain?: KeychainInit;
48
+ }
49
+ export interface HeliaWithLibp2p<M extends ServiceMap = DefaultLibp2pServices> extends Helia {
50
+ /**
51
+ * Libp2p provides a peer identity and a networking layer
52
+ */
53
+ libp2p: Libp2p<M>;
54
+ }
55
+ /**
56
+ * Return a Helia node augmented with a libp2p instance. The passed
57
+ * configuration is passed to `createLibp2p` without adding any default config.
58
+ *
59
+ * Use this if you do not wish to have any extra config added. To use the
60
+ * default config, call `withLibp2p` from `@helia/libp2p` instead.
61
+ *
62
+ * Import it from `@helia/libp2p/light` to avoid loading the default config.
63
+ */
64
+ export declare function withLibp2pLight<H extends Helia, M extends ServiceMap = ServiceMap>(helia: H, opts: CreateLibp2pOptions<M>): H & HeliaWithLibp2p<M>;
65
+ //# sourceMappingURL=light.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"light.d.ts","sourceRoot":"","sources":["../../src/light.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAQH,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAC5C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AACvE,OAAO,KAAK,EAAE,KAAK,EAA8B,MAAM,kBAAkB,CAAA;AACzE,OAAO,KAAK,EAAE,MAAM,EAAY,UAAU,EAAE,MAAM,mBAAmB,CAAA;AACrE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAEpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAA;AAG3C,OAAO,EAAE,aAAa,EAAE,CAAA;AAExB,MAAM,WAAW,mBAAmB,CAAC,CAAC,SAAS,UAAU,GAAG,UAAU,CAAE,SAAQ,aAAa,CAAC,CAAC,CAAC;IAC9F;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;IAC5B,QAAQ,CAAC,EAAE,YAAY,CAAA;CACxB;AAED,MAAM,WAAW,eAAe,CAAC,CAAC,SAAS,UAAU,GAAG,qBAAqB,CAAE,SAAQ,KAAK;IAC1F;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAA;CAClB;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAE,CAAC,SAAS,KAAK,EAAE,CAAC,SAAS,UAAU,GAAG,UAAU,EAAG,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,mBAAmB,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC,CAwGpJ"}
@@ -0,0 +1,142 @@
1
+ /**
2
+ * @packageDocumentation
3
+ *
4
+ * Exports `withLibp2pLight`, which adds a libp2p node to Helia using only the
5
+ * config you pass to it.
6
+ *
7
+ * Unlike the main `@helia/libp2p` entry point, importing
8
+ * `@helia/libp2p/light` does not load the default libp2p config, so none of
9
+ * the default transports, services or their dependencies (including the native
10
+ * `node-datachannel` module used by `@libp2p/webrtc`) are loaded.
11
+ *
12
+ * @example Bring your own libp2p config
13
+ *
14
+ * ```ts
15
+ * import { createHeliaLight } from 'helia/light'
16
+ * import { withLibp2pLight } from '@helia/libp2p/light'
17
+ * import { tcp } from '@libp2p/tcp'
18
+ * import { noise } from '@libp2p/noise'
19
+ * import { yamux } from '@libp2p/yamux'
20
+ *
21
+ * const node = await withLibp2pLight(createHeliaLight(), {
22
+ * transports: [tcp()],
23
+ * connectionEncrypters: [noise()],
24
+ * streamMuxers: [yamux()]
25
+ * }).start()
26
+ *
27
+ * console.info(node.libp2p.peerId) // 12D3Koo...
28
+ * ```
29
+ */
30
+ import { loadOrCreateSelfKey } from '@libp2p/config';
31
+ import { InvalidParametersError, NotStartedError } from '@libp2p/interface';
32
+ import { peerIdFromCID } from '@libp2p/peer-id';
33
+ import forEach from 'it-foreach';
34
+ import { createLibp2p, isLibp2p } from 'libp2p';
35
+ import { userAgent } from 'libp2p/user-agent';
36
+ import { libp2pRouting } from "./routing.js";
37
+ export { libp2pRouting };
38
+ /**
39
+ * Return a Helia node augmented with a libp2p instance. The passed
40
+ * configuration is passed to `createLibp2p` without adding any default config.
41
+ *
42
+ * Use this if you do not wish to have any extra config added. To use the
43
+ * default config, call `withLibp2p` from `@helia/libp2p` instead.
44
+ *
45
+ * Import it from `@helia/libp2p/light` to avoid loading the default config.
46
+ */
47
+ export function withLibp2pLight(helia, opts) {
48
+ if (opts == null) {
49
+ throw new InvalidParametersError('withLibp2pLight requires libp2p options. Use withLibp2p from @helia/libp2p for the default config');
50
+ }
51
+ let libp2p;
52
+ // add a getter that informs the user they need to start Helia
53
+ Object.defineProperty(helia, 'libp2p', {
54
+ configurable: true,
55
+ enumerable: true,
56
+ get() {
57
+ if (libp2p != null) {
58
+ return libp2p;
59
+ }
60
+ throw new NotStartedError();
61
+ }
62
+ });
63
+ const mixin = {
64
+ name: 'libp2p',
65
+ start: async (helia) => {
66
+ if (libp2p == null) {
67
+ // if no peer id was passed, try to load it from the keychain
68
+ if (opts.privateKey == null) {
69
+ opts.privateKey = await loadOrCreateSelfKey(helia.datastore, opts.keychain);
70
+ }
71
+ // copy options from Helia node
72
+ opts.nodeInfo ??= {};
73
+ opts.nodeInfo.name ??= helia.info.name;
74
+ opts.nodeInfo.version ??= helia.info.version;
75
+ opts.nodeInfo.userAgent ??= `${helia.info.name}/${helia.info.version} ${userAgent()}`;
76
+ opts.datastore ??= helia.datastore;
77
+ libp2p = await createLibp2p(opts);
78
+ // override peer discovery methods to ensure we persist peer data in the
79
+ // peer store, otherwise we can't dial by peer id without extra lookups
80
+ const findProviders = helia.routing.findProviders.bind(helia.routing);
81
+ helia.routing.findProviders = async function* (cid, options) {
82
+ yield* forEach(findProviders.call(helia.routing, cid, options), async (peer) => {
83
+ if (peer.router !== 'libp2p-router') {
84
+ // only need to do this for peers not found via the libp2p router
85
+ const info = toPeerInfo(peer);
86
+ await libp2p.peerStore.merge(info.id, info);
87
+ }
88
+ });
89
+ };
90
+ const findPeer = helia.routing.findPeer.bind(helia.routing);
91
+ helia.routing.findPeer = async function (cid, options) {
92
+ const peer = await findPeer(cid, options);
93
+ if (peer.router !== 'libp2p-router') {
94
+ // only need to do this for peers not found via the libp2p router
95
+ const info = toPeerInfo(peer);
96
+ await libp2p.peerStore.merge(info.id, info);
97
+ }
98
+ return peer;
99
+ };
100
+ // override peer discovery methods to ensure we persist peer data in the
101
+ // peer store, otherwise we can't dial by peer id without extra lookups
102
+ const getClosestPeers = helia.routing.getClosestPeers.bind(helia.routing);
103
+ helia.routing.getClosestPeers = async function* (cid, options) {
104
+ yield* forEach(getClosestPeers.call(helia.routing, cid, options), async (peer) => {
105
+ if (peer.router !== 'libp2p-router') {
106
+ // only need to do this for peers not found via the libp2p router
107
+ const info = toPeerInfo(peer);
108
+ await libp2p.peerStore.merge(info.id, info);
109
+ }
110
+ });
111
+ };
112
+ }
113
+ try {
114
+ if (!helia.hasRouter('libp2p-router')) {
115
+ helia.addRouter(libp2pRouting(libp2p));
116
+ }
117
+ if (isLibp2p(helia.libp2p)) {
118
+ // already configured libp2p
119
+ await helia.libp2p.start();
120
+ }
121
+ }
122
+ catch (err) {
123
+ if (err.name !== 'NotStartedError') {
124
+ throw err;
125
+ }
126
+ }
127
+ },
128
+ stop: async () => {
129
+ await libp2p?.stop();
130
+ }
131
+ };
132
+ helia.addMixin(mixin);
133
+ // @ts-expect-error libp2p property is missing, even though we just defined it
134
+ return helia;
135
+ }
136
+ function toPeerInfo(peer) {
137
+ return {
138
+ id: peerIdFromCID(peer.id),
139
+ multiaddrs: peer.multiaddrs
140
+ };
141
+ }
142
+ //# sourceMappingURL=light.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"light.js","sourceRoot":"","sources":["../../src/light.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAC3E,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C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,EAAE,CAAC;gBAClB,IAAI,GAAG,CAAC,IAAI,KAAK,iBAAiB,EAAE,CAAC;oBACnC,MAAM,GAAG,CAAA;gBACX,CAAC;YACH,CAAC;QACH,CAAC;QAED,IAAI,EAAE,KAAK,IAAI,EAAE;YACf,MAAM,MAAM,EAAE,IAAI,EAAE,CAAA;QACtB,CAAC;KACF,CAAA;IAED,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;IAErB,8EAA8E;IAC9E,OAAO,KAAK,CAAA;AACd,CAAC;AAED,SAAS,UAAU,CAAE,IAA0C;IAC7D,OAAO;QACL,EAAE,EAAE,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1B,UAAU,EAAE,IAAI,CAAC,UAAU;KAC5B,CAAA;AACH,CAAC"}
@@ -1,4 +1,33 @@
1
1
  import type { Router } from '@helia/interface';
2
2
  import type { Libp2p } from '@libp2p/interface';
3
+ /**
4
+ * Return a Helia router that uses the passed libp2p node to find providers,
5
+ * peers and records.
6
+ *
7
+ * `withLibp2pLight` and `withLibp2p` add this for you. Use it directly when you
8
+ * create the libp2p node yourself, and do not combine it with either of them,
9
+ * otherwise Helia routes through your node while `helia.libp2p` is a second,
10
+ * separate node.
11
+ *
12
+ * A node you create yourself is not started or stopped by Helia and does not
13
+ * use Helia's datastore or identity. This only adds routing, so add a block
14
+ * broker (for example bitswap) to fetch blocks over libp2p.
15
+ *
16
+ * @example
17
+ *
18
+ * ```ts
19
+ * import { createHeliaLight } from 'helia/light'
20
+ * import { libp2pRouting } from '@helia/libp2p/light'
21
+ * import { createLibp2p } from 'libp2p'
22
+ *
23
+ * const libp2p = await createLibp2p({
24
+ * //... libp2p config here
25
+ * })
26
+ *
27
+ * const helia = await createHeliaLight({
28
+ * routers: [libp2pRouting(libp2p)]
29
+ * }).start()
30
+ * ```
31
+ */
3
32
  export declare function libp2pRouting(libp2p: Libp2p): Router;
4
33
  //# sourceMappingURL=routing.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"routing.d.ts","sourceRoot":"","sources":["../../src/routing.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAkB,MAAM,EAAkB,MAAM,kBAAkB,CAAA;AAC9E,OAAO,KAAK,EAAE,MAAM,EAAY,MAAM,mBAAmB,CAAA;AA+DzD,wBAAgB,aAAa,CAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAErD"}
1
+ {"version":3,"file":"routing.d.ts","sourceRoot":"","sources":["../../src/routing.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAkB,MAAM,EAAkB,MAAM,kBAAkB,CAAA;AAC9E,OAAO,KAAK,EAAE,MAAM,EAAY,MAAM,mBAAmB,CAAA;AA+DzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,aAAa,CAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAErD"}
@@ -49,6 +49,35 @@ class Libp2pRouter {
49
49
  return 'Libp2pRouter()';
50
50
  }
51
51
  }
52
+ /**
53
+ * Return a Helia router that uses the passed libp2p node to find providers,
54
+ * peers and records.
55
+ *
56
+ * `withLibp2pLight` and `withLibp2p` add this for you. Use it directly when you
57
+ * create the libp2p node yourself, and do not combine it with either of them,
58
+ * otherwise Helia routes through your node while `helia.libp2p` is a second,
59
+ * separate node.
60
+ *
61
+ * A node you create yourself is not started or stopped by Helia and does not
62
+ * use Helia's datastore or identity. This only adds routing, so add a block
63
+ * broker (for example bitswap) to fetch blocks over libp2p.
64
+ *
65
+ * @example
66
+ *
67
+ * ```ts
68
+ * import { createHeliaLight } from 'helia/light'
69
+ * import { libp2pRouting } from '@helia/libp2p/light'
70
+ * import { createLibp2p } from 'libp2p'
71
+ *
72
+ * const libp2p = await createLibp2p({
73
+ * //... libp2p config here
74
+ * })
75
+ *
76
+ * const helia = await createHeliaLight({
77
+ * routers: [libp2pRouting(libp2p)]
78
+ * }).start()
79
+ * ```
80
+ */
52
81
  export function libp2pRouting(libp2p) {
53
82
  return new Libp2pRouter(lib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AAO,eAAe,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAA;IAC5E,CAAC;IAED,KAAK,CAAC,QAAQ,CAAE,MAAW,EAAE,OAAwB;QACnD,OAAO,cAAc,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,CAAC,CAAA;IAC/F,CAAC;IAED,KAAK,CAAC,CAAE,eAAe,CAAE,GAAe,EAAE,OAAwB;QAChE,KAAM,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,eAAe,CAAC,GAAG,EAAE,OAAO,CAAC,EAAE,cAAc,CAAC,CAAA;IACpF,CAAC;IAED,QAAQ;QACN,OAAO,gBAAgB,CAAA;IACzB,CAAC;CACF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,UAAU,aAAa,CAAE,MAAc;IAC3C,OAAO,IAAI,YAAY,CAAC,MAAM,CAAC,CAAA;AACjC,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { CreateLibp2pOptions } from '../index.ts';
1
+ import type { CreateLibp2pOptions } from '../light.ts';
2
2
  import type { HTTP } from '@libp2p/http';
3
3
  import type { Identify, IdentifyPush } from '@libp2p/identify';
4
4
  import type { ServiceMap } from '@libp2p/interface';
@@ -1,4 +1,4 @@
1
- import type { CreateLibp2pOptions } from '../index.ts';
1
+ import type { CreateLibp2pOptions } from '../light.ts';
2
2
  import type { AutoTLS } from '@ipshipyard/libp2p-auto-tls';
3
3
  import type { CircuitRelayService } from '@libp2p/circuit-relay-v2';
4
4
  import type { HTTP } from '@libp2p/http';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@helia/libp2p",
3
- "version": "2.1.4-d4962087",
3
+ "version": "2.1.5-05d3e4cc",
4
4
  "description": "libp2p functionality for Helia",
5
5
  "license": "Apache-2.0 OR MIT",
6
6
  "homepage": "https://github.com/ipfs/helia/tree/main/packages/libp2p#readme",
@@ -31,6 +31,11 @@
31
31
  "types": "./dist/src/index.d.ts",
32
32
  "import": "./dist/src/index.js",
33
33
  "module-sync": "./dist/src/index.js"
34
+ },
35
+ "./light": {
36
+ "types": "./dist/src/light.d.ts",
37
+ "import": "./dist/src/light.js",
38
+ "module-sync": "./dist/src/light.js"
34
39
  }
35
40
  },
36
41
  "scripts": {
@@ -48,9 +53,9 @@
48
53
  "test:electron-main": "aegir test -t electron-main"
49
54
  },
50
55
  "dependencies": {
51
- "@helia/delegated-routing-client": "1.0.6-d4962087",
56
+ "@helia/delegated-routing-client": "1.0.7-05d3e4cc",
52
57
  "@helia/delegated-routing-v1-http-api-client": "^9.0.0",
53
- "@helia/interface": "7.1.1-d4962087",
58
+ "@helia/interface": "7.1.2-05d3e4cc",
54
59
  "@ipshipyard/libp2p-auto-tls": "^2.0.1",
55
60
  "@libp2p/autonat": "^3.0.21",
56
61
  "@libp2p/bootstrap": "^12.0.24",