helia 5.1.1-e45e1de → 5.2.0-6542cf2
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/dist/index.min.js +11 -11
- package/dist/src/utils/libp2p.d.ts.map +1 -1
- package/dist/src/utils/libp2p.js +6 -27
- package/dist/src/utils/libp2p.js.map +1 -1
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/package.json +7 -8
- package/src/utils/libp2p.ts +7 -30
- package/src/version.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"libp2p.d.ts","sourceRoot":"","sources":["../../../src/utils/libp2p.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"libp2p.d.ts","sourceRoot":"","sources":["../../../src/utils/libp2p.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;AACjE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC5E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAA;AAC5C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAA;AAE3C,MAAM,WAAW,mBAAmB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACpE,SAAS,EAAE,SAAS,CAAA;IACpB,MAAM,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC,CAAA;IACzB,MAAM,CAAC,EAAE,eAAe,CAAA;IACxB,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB;AAED,MAAM,WAAW,qBAAqB;IACpC,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB,GAAG,CAAC,EAAE,GAAG,CAAA;CACV;AAED,wBAAsB,YAAY,CAAE,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,qBAAqB,EAAG,OAAO,EAAE,mBAAmB,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAmBnJ"}
|
package/dist/src/utils/libp2p.js
CHANGED
|
@@ -1,39 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { keychain } from '@libp2p/keychain';
|
|
3
|
-
import { defaultLogger } from '@libp2p/logger';
|
|
4
|
-
import { Key } from 'interface-datastore';
|
|
1
|
+
import { loadOrCreateSelfKey } from '@libp2p/config';
|
|
5
2
|
import { createLibp2p as create } from 'libp2p';
|
|
6
3
|
import { libp2pDefaults } from './libp2p-defaults.js';
|
|
7
4
|
export async function createLibp2p(options) {
|
|
8
|
-
const
|
|
9
|
-
const logger = options.logger ?? defaultLogger();
|
|
10
|
-
const selfKey = new Key('/pkcs8/self');
|
|
11
|
-
let chain;
|
|
5
|
+
const libp2pOptions = options.libp2p ?? {};
|
|
12
6
|
// if no peer id was passed, try to load it from the keychain
|
|
13
|
-
if (privateKey == null && options.datastore != null) {
|
|
14
|
-
|
|
15
|
-
datastore: options.datastore,
|
|
16
|
-
logger
|
|
17
|
-
});
|
|
18
|
-
options.libp2p = options.libp2p ?? {};
|
|
19
|
-
if (await options.datastore.has(selfKey)) {
|
|
20
|
-
// load the peer id from the keychain
|
|
21
|
-
options.libp2p.privateKey = await chain.exportKey('self');
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
const privateKey = await generateKeyPair('Ed25519');
|
|
25
|
-
options.libp2p.privateKey = privateKey;
|
|
26
|
-
// persist the peer id in the keychain for next time
|
|
27
|
-
await chain.importKey('self', privateKey);
|
|
28
|
-
}
|
|
7
|
+
if (libp2pOptions.privateKey == null && options.datastore != null) {
|
|
8
|
+
libp2pOptions.privateKey = await loadOrCreateSelfKey(options.datastore, options.keychain);
|
|
29
9
|
}
|
|
30
|
-
const defaults = libp2pDefaults(
|
|
10
|
+
const defaults = libp2pDefaults(libp2pOptions);
|
|
31
11
|
defaults.datastore = defaults.datastore ?? options.datastore;
|
|
32
|
-
options = options ?? {};
|
|
33
12
|
// @ts-expect-error derived ServiceMap is not compatible with ServiceFactoryMap
|
|
34
13
|
const node = await create({
|
|
35
14
|
...defaults,
|
|
36
|
-
...
|
|
15
|
+
...libp2pOptions,
|
|
37
16
|
start: false
|
|
38
17
|
});
|
|
39
18
|
return node;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"libp2p.js","sourceRoot":"","sources":["../../../src/utils/libp2p.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"libp2p.js","sourceRoot":"","sources":["../../../src/utils/libp2p.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,EAAE,YAAY,IAAI,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAsBrD,MAAM,CAAC,KAAK,UAAU,YAAY,CAA8D,OAA+B;IAC7H,MAAM,aAAa,GAAG,OAAO,CAAC,MAAM,IAAI,EAAE,CAAA;IAE1C,6DAA6D;IAC7D,IAAI,aAAa,CAAC,UAAU,IAAI,IAAI,IAAI,OAAO,CAAC,SAAS,IAAI,IAAI,EAAE,CAAC;QAClE,aAAa,CAAC,UAAU,GAAG,MAAM,mBAAmB,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAA;IAC3F,CAAC;IAED,MAAM,QAAQ,GAAG,cAAc,CAAC,aAAa,CAAC,CAAA;IAC9C,QAAQ,CAAC,SAAS,GAAG,QAAQ,CAAC,SAAS,IAAI,OAAO,CAAC,SAAS,CAAA;IAE5D,+EAA+E;IAC/E,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC;QACxB,GAAG,QAAQ;QACX,GAAG,aAAa;QAChB,KAAK,EAAE,KAAK;KACb,CAAC,CAAA;IAEF,OAAO,IAAI,CAAA;AACb,CAAC"}
|
package/dist/src/version.d.ts
CHANGED
package/dist/src/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "helia",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.2.0-6542cf2",
|
|
4
4
|
"description": "An implementation of IPFS in JavaScript",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/ipfs/helia/tree/main/packages/helia#readme",
|
|
@@ -57,28 +57,27 @@
|
|
|
57
57
|
"dependencies": {
|
|
58
58
|
"@chainsafe/libp2p-noise": "^16.0.0",
|
|
59
59
|
"@chainsafe/libp2p-yamux": "^7.0.1",
|
|
60
|
-
"@helia/block-brokers": "4.0.
|
|
60
|
+
"@helia/block-brokers": "4.0.3-6542cf2",
|
|
61
61
|
"@helia/delegated-routing-v1-http-api-client": "^4.2.1",
|
|
62
|
-
"@helia/interface": "5.
|
|
63
|
-
"@helia/routers": "
|
|
64
|
-
"@helia/utils": "1.
|
|
62
|
+
"@helia/interface": "5.2.0-6542cf2",
|
|
63
|
+
"@helia/routers": "3.0.0-6542cf2",
|
|
64
|
+
"@helia/utils": "1.2.0-6542cf2",
|
|
65
65
|
"@libp2p/auto-tls": "^1.0.4",
|
|
66
66
|
"@libp2p/autonat": "^2.0.12",
|
|
67
67
|
"@libp2p/bootstrap": "^11.0.13",
|
|
68
68
|
"@libp2p/circuit-relay-v2": "^3.1.3",
|
|
69
|
-
"@libp2p/
|
|
69
|
+
"@libp2p/config": "^1.0.1",
|
|
70
70
|
"@libp2p/dcutr": "^2.0.12",
|
|
71
71
|
"@libp2p/identify": "^3.0.12",
|
|
72
72
|
"@libp2p/interface": "^2.2.1",
|
|
73
73
|
"@libp2p/kad-dht": "^14.1.3",
|
|
74
74
|
"@libp2p/keychain": "^5.0.10",
|
|
75
|
-
"@libp2p/logger": "^5.1.4",
|
|
76
75
|
"@libp2p/mdns": "^11.0.13",
|
|
77
76
|
"@libp2p/mplex": "^11.0.13",
|
|
78
77
|
"@libp2p/ping": "^2.0.12",
|
|
79
78
|
"@libp2p/tcp": "^10.0.13",
|
|
80
79
|
"@libp2p/tls": "^2.0.11",
|
|
81
|
-
"@libp2p/upnp-nat": "^
|
|
80
|
+
"@libp2p/upnp-nat": "^3.0.4",
|
|
82
81
|
"@libp2p/webrtc": "^5.0.19",
|
|
83
82
|
"@libp2p/websockets": "^9.0.13",
|
|
84
83
|
"@multiformats/dns": "^1.0.6",
|
package/src/utils/libp2p.ts
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { keychain } from '@libp2p/keychain'
|
|
3
|
-
import { defaultLogger } from '@libp2p/logger'
|
|
4
|
-
import { Key } from 'interface-datastore'
|
|
1
|
+
import { loadOrCreateSelfKey } from '@libp2p/config'
|
|
5
2
|
import { createLibp2p as create } from 'libp2p'
|
|
6
3
|
import { libp2pDefaults } from './libp2p-defaults.js'
|
|
7
4
|
import type { DefaultLibp2pServices } from './libp2p-defaults.js'
|
|
8
5
|
import type { ComponentLogger, Libp2p, PrivateKey } from '@libp2p/interface'
|
|
9
|
-
import type {
|
|
6
|
+
import type { KeychainInit } from '@libp2p/keychain'
|
|
10
7
|
import type { DNS } from '@multiformats/dns'
|
|
11
8
|
import type { Datastore } from 'interface-datastore'
|
|
12
9
|
import type { Libp2pOptions } from 'libp2p'
|
|
@@ -26,40 +23,20 @@ export interface Libp2pDefaultsOptions {
|
|
|
26
23
|
}
|
|
27
24
|
|
|
28
25
|
export async function createLibp2p <T extends Record<string, unknown> = DefaultLibp2pServices> (options: CreateLibp2pOptions<T>): Promise<Libp2p<T>> {
|
|
29
|
-
const
|
|
30
|
-
const logger = options.logger ?? defaultLogger()
|
|
31
|
-
const selfKey = new Key('/pkcs8/self')
|
|
32
|
-
let chain: Keychain | undefined
|
|
26
|
+
const libp2pOptions = options.libp2p ?? {}
|
|
33
27
|
|
|
34
28
|
// if no peer id was passed, try to load it from the keychain
|
|
35
|
-
if (privateKey == null && options.datastore != null) {
|
|
36
|
-
|
|
37
|
-
datastore: options.datastore,
|
|
38
|
-
logger
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
options.libp2p = options.libp2p ?? {}
|
|
42
|
-
|
|
43
|
-
if (await options.datastore.has(selfKey)) {
|
|
44
|
-
// load the peer id from the keychain
|
|
45
|
-
options.libp2p.privateKey = await chain.exportKey('self')
|
|
46
|
-
} else {
|
|
47
|
-
const privateKey = await generateKeyPair('Ed25519')
|
|
48
|
-
options.libp2p.privateKey = privateKey
|
|
49
|
-
|
|
50
|
-
// persist the peer id in the keychain for next time
|
|
51
|
-
await chain.importKey('self', privateKey)
|
|
52
|
-
}
|
|
29
|
+
if (libp2pOptions.privateKey == null && options.datastore != null) {
|
|
30
|
+
libp2pOptions.privateKey = await loadOrCreateSelfKey(options.datastore, options.keychain)
|
|
53
31
|
}
|
|
54
32
|
|
|
55
|
-
const defaults = libp2pDefaults(
|
|
33
|
+
const defaults = libp2pDefaults(libp2pOptions)
|
|
56
34
|
defaults.datastore = defaults.datastore ?? options.datastore
|
|
57
|
-
options = options ?? {}
|
|
58
35
|
|
|
59
36
|
// @ts-expect-error derived ServiceMap is not compatible with ServiceFactoryMap
|
|
60
37
|
const node = await create({
|
|
61
38
|
...defaults,
|
|
62
|
-
...
|
|
39
|
+
...libp2pOptions,
|
|
63
40
|
start: false
|
|
64
41
|
})
|
|
65
42
|
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const version = '5.
|
|
1
|
+
export const version = '5.2.0-6542cf2'
|
|
2
2
|
export const name = 'helia'
|