@helia/libp2p 2.0.0 → 2.1.0-cd1c4a76

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,5 +1,3 @@
1
- import { loadOrCreateSelfKey } from '@libp2p/config'
2
- import { createLibp2p as create } from 'libp2p'
3
1
  import { libp2pDefaults } from './libp2p-defaults.ts'
4
2
  import type { Helia } from '@helia/interface'
5
3
  import type { Libp2p, PrivateKey } from '@libp2p/interface'
@@ -19,25 +17,21 @@ export interface Libp2pDefaultsOptions {
19
17
  version?: string
20
18
  }
21
19
 
22
- export async function createLibp2p <T extends Record<string, unknown>> (helia: Helia, options: CreateLibp2pOptions<T>): Promise<Libp2p<T>> {
20
+ export async function createLibp2pOptions <T extends Record<string, unknown>> (helia: Helia, options: CreateLibp2pOptions<T>): Promise<Libp2p<T>> {
23
21
  const libp2pOptions = options ?? {}
24
22
 
25
- // if no peer id was passed, try to load it from the keychain
26
- if (libp2pOptions.privateKey == null && options.datastore != null) {
27
- libp2pOptions.privateKey = await loadOrCreateSelfKey(options.datastore, options.keychain)
28
- }
29
-
30
23
  const defaults: any = libp2pDefaults({
31
24
  ...libp2pOptions,
32
- name: libp2pOptions.nodeInfo?.name ?? helia.info.name,
33
- version: libp2pOptions.nodeInfo?.version ?? helia.info.version
25
+ nodeInfo: {
26
+ ...libp2pOptions.nodeInfo,
27
+ name: libp2pOptions.nodeInfo?.name ?? helia.info.name,
28
+ version: libp2pOptions.nodeInfo?.version ?? helia.info.version
29
+ }
34
30
  })
35
31
  defaults.datastore = defaults.datastore ?? options.datastore
36
32
 
37
- const node = await create<T>({
33
+ return {
38
34
  ...defaults,
39
35
  ...libp2pOptions
40
- })
41
-
42
- return node
36
+ }
43
37
  }
@@ -1,9 +0,0 @@
1
- {
2
- "CreateLibp2pOptions": "https://ipfs.github.io/helia/interfaces/_helia_libp2p.CreateLibp2pOptions.html",
3
- "DefaultLibp2pServices": "https://ipfs.github.io/helia/interfaces/_helia_libp2p.DefaultLibp2pServices.html",
4
- "HeliaWithLibp2p": "https://ipfs.github.io/helia/interfaces/_helia_libp2p.HeliaWithLibp2p.html",
5
- ".:HeliaWithLibp2p": "https://ipfs.github.io/helia/interfaces/_helia_libp2p.HeliaWithLibp2p.html",
6
- "libp2pDefaults": "https://ipfs.github.io/helia/functions/_helia_libp2p.libp2pDefaults.html",
7
- "withLibp2p": "https://ipfs.github.io/helia/functions/_helia_libp2p.withLibp2p.html",
8
- ".:withLibp2p": "https://ipfs.github.io/helia/functions/_helia_libp2p.withLibp2p.html"
9
- }