@helia/libp2p 2.1.0 → 2.1.1-91ed35a4

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,37 +0,0 @@
1
- import { libp2pDefaults } from './libp2p-defaults.ts'
2
- import type { Helia } from '@helia/interface'
3
- import type { Libp2p, PrivateKey } from '@libp2p/interface'
4
- import type { KeychainInit } from '@libp2p/keychain'
5
- import type { DNS } from '@multiformats/dns'
6
- import type { Libp2pOptions } from 'libp2p'
7
-
8
- export interface CreateLibp2pOptions<T extends Record<string, unknown>> extends Libp2pOptions<T> {
9
- keychain?: KeychainInit
10
- }
11
-
12
- export interface Libp2pDefaultsOptions {
13
- privateKey?: PrivateKey
14
- keychain?: KeychainInit
15
- dns?: DNS
16
- name?: string
17
- version?: string
18
- }
19
-
20
- export async function createLibp2pOptions <T extends Record<string, unknown>> (helia: Helia, options: CreateLibp2pOptions<T>): Promise<Libp2p<T>> {
21
- const libp2pOptions = options ?? {}
22
-
23
- const defaults: any = libp2pDefaults({
24
- ...libp2pOptions,
25
- nodeInfo: {
26
- ...libp2pOptions.nodeInfo,
27
- name: libp2pOptions.nodeInfo?.name ?? helia.info.name,
28
- version: libp2pOptions.nodeInfo?.version ?? helia.info.version
29
- }
30
- })
31
- defaults.datastore = defaults.datastore ?? options.datastore
32
-
33
- return {
34
- ...defaults,
35
- ...libp2pOptions
36
- }
37
- }