@helia/ipns 4.0.0 → 5.0.0
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/README.md +51 -7
- package/dist/index.min.js +73 -26
- package/dist/src/index.d.ts +50 -4
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +75 -6
- package/dist/src/index.js.map +1 -1
- package/dist/src/routing/helia.d.ts +20 -0
- package/dist/src/routing/helia.d.ts.map +1 -0
- package/dist/src/routing/helia.js +32 -0
- package/dist/src/routing/helia.js.map +1 -0
- package/dist/src/routing/index.d.ts +9 -3
- package/dist/src/routing/index.d.ts.map +1 -1
- package/dist/src/routing/index.js +1 -1
- package/dist/src/routing/index.js.map +1 -1
- package/dist/typedoc-urls.json +40 -40
- package/package.json +13 -14
- package/src/index.ts +79 -6
- package/src/routing/helia.ts +45 -0
- package/src/routing/index.ts +9 -4
- package/dist/src/routing/libp2p.d.ts +0 -22
- package/dist/src/routing/libp2p.d.ts.map +0 -1
- package/dist/src/routing/libp2p.js +0 -32
- package/dist/src/routing/libp2p.js.map +0 -1
- package/src/routing/libp2p.ts +0 -47
package/README.md
CHANGED
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
|
|
9
9
|
[](https://ipfs.tech)
|
|
10
10
|
[](https://discuss.ipfs.tech)
|
|
11
|
-
[](https://codecov.io/gh/ipfs/helia)
|
|
12
|
+
[](https://github.com/ipfs/helia/actions/workflows/main.yml?query=branch%3Amain)
|
|
13
13
|
|
|
14
14
|
> An implementation of IPNS for Helia
|
|
15
15
|
|
|
@@ -17,20 +17,64 @@
|
|
|
17
17
|
|
|
18
18
|
IPNS operations using a Helia node
|
|
19
19
|
|
|
20
|
-
## Example -
|
|
20
|
+
## Example - Getting started
|
|
21
21
|
|
|
22
22
|
With IPNSRouting routers:
|
|
23
23
|
|
|
24
24
|
```typescript
|
|
25
25
|
import { createHelia } from 'helia'
|
|
26
26
|
import { ipns } from '@helia/ipns'
|
|
27
|
-
import { libp2p, pubsub } from '@helia/ipns/routing'
|
|
28
27
|
import { unixfs } from '@helia/unixfs'
|
|
29
28
|
|
|
30
29
|
const helia = await createHelia()
|
|
30
|
+
const name = ipns(helia)
|
|
31
|
+
|
|
32
|
+
// create a public key to publish as an IPNS name
|
|
33
|
+
const keyInfo = await helia.libp2p.services.keychain.createKey('my-key')
|
|
34
|
+
const peerId = await helia.libp2p.services.keychain.exportPeerId(keyInfo.name)
|
|
35
|
+
|
|
36
|
+
// store some data to publish
|
|
37
|
+
const fs = unixfs(helia)
|
|
38
|
+
const cid = await fs.add(Uint8Array.from([0, 1, 2, 3, 4]))
|
|
39
|
+
|
|
40
|
+
// publish the name
|
|
41
|
+
await name.publish(peerId, cid)
|
|
42
|
+
|
|
43
|
+
// resolve the name
|
|
44
|
+
const cid = name.resolve(peerId)
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Example - Using custom PubSub router
|
|
48
|
+
|
|
49
|
+
Additional IPNS routers can be configured - these enable alternative means to
|
|
50
|
+
publish and resolve IPNS names.
|
|
51
|
+
|
|
52
|
+
One example is the PubSub router - this requires an instance of Helia with
|
|
53
|
+
libp2p PubSub configured.
|
|
54
|
+
|
|
55
|
+
It works by subscribing to a pubsub topic for each IPNS name that we try to
|
|
56
|
+
resolve. Updated IPNS records are shared on these topics so an update must
|
|
57
|
+
occur before the name is resolvable.
|
|
58
|
+
|
|
59
|
+
This router is only suitable for networks where IPNS updates are frequent
|
|
60
|
+
and multiple peers are listening on the topic(s), otherwise update messages
|
|
61
|
+
may fail to be published with "Insufficient peers" errors.
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
import { createHelia, libp2pDefaults } from 'helia'
|
|
65
|
+
import { ipns } from '@helia/ipns'
|
|
66
|
+
import { pubsub } from '@helia/ipns/routing'
|
|
67
|
+
import { unixfs } from '@helia/unixfs'
|
|
68
|
+
import { gossipsub } from '@chainsafe/libp2p-gossipsub'
|
|
69
|
+
|
|
70
|
+
const libp2pOptions = libp2pDefaults()
|
|
71
|
+
libp2pOptions.services.pubsub = gossipsub()
|
|
72
|
+
|
|
73
|
+
const helia = await createHelia({
|
|
74
|
+
libp2p: libp2pOptions
|
|
75
|
+
})
|
|
31
76
|
const name = ipns(helia, {
|
|
32
77
|
routers: [
|
|
33
|
-
libp2p(helia),
|
|
34
78
|
pubsub(helia)
|
|
35
79
|
]
|
|
36
80
|
})
|
|
@@ -141,7 +185,7 @@ Loading this module through a script tag will make it's exports available as `He
|
|
|
141
185
|
|
|
142
186
|
# API Docs
|
|
143
187
|
|
|
144
|
-
- <https://ipfs.github.io/helia
|
|
188
|
+
- <https://ipfs.github.io/helia/modules/_helia_ipns.html>
|
|
145
189
|
|
|
146
190
|
# License
|
|
147
191
|
|
|
@@ -152,7 +196,7 @@ Licensed under either of
|
|
|
152
196
|
|
|
153
197
|
# Contribute
|
|
154
198
|
|
|
155
|
-
Contributions welcome! Please check out [the issues](https://github.com/ipfs/helia
|
|
199
|
+
Contributions welcome! Please check out [the issues](https://github.com/ipfs/helia/issues).
|
|
156
200
|
|
|
157
201
|
Also see our [contributing document](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md) for more information on how we work, and about contributing in general.
|
|
158
202
|
|