@helia/ipns 3.0.1 → 4.0.0-031519c

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 CHANGED
@@ -8,8 +8,8 @@
8
8
 
9
9
  [![ipfs.tech](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](https://ipfs.tech)
10
10
  [![Discuss](https://img.shields.io/discourse/https/discuss.ipfs.tech/posts.svg?style=flat-square)](https://discuss.ipfs.tech)
11
- [![codecov](https://img.shields.io/codecov/c/github/ipfs/helia-ipns.svg?style=flat-square)](https://codecov.io/gh/ipfs/helia-ipns)
12
- [![CI](https://img.shields.io/github/actions/workflow/status/ipfs/helia-ipns/js-test-and-release.yml?branch=main\&style=flat-square)](https://github.com/ipfs/helia-ipns/actions/workflows/js-test-and-release.yml?query=branch%3Amain)
11
+ [![codecov](https://img.shields.io/codecov/c/github/ipfs/helia.svg?style=flat-square)](https://codecov.io/gh/ipfs/helia)
12
+ [![CI](https://img.shields.io/github/actions/workflow/status/ipfs/helia/main.yml?branch=main\&style=flat-square)](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,27 +17,65 @@
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 { dht, pubsub } from '@helia/ipns/routing'
27
+ import { unixfs } from '@helia/unixfs'
28
+
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 } from 'helia'
65
+ import { ipns } from '@helia/ipns'
66
+ import { pubsub } from '@helia/ipns/routing'
28
67
  import { unixfs } from '@helia/unixfs'
29
68
 
30
69
  const helia = await createHelia()
31
70
  const name = ipns(helia, {
32
71
  routers: [
33
- dht(helia),
34
72
  pubsub(helia)
35
73
  ]
36
74
  })
37
75
 
38
76
  // create a public key to publish as an IPNS name
39
- const keyInfo = await helia.libp2p.keychain.createKey('my-key')
40
- const peerId = await helia.libp2p.keychain.exportPeerId(keyInfo.name)
77
+ const keyInfo = await helia.libp2p.services.keychain.createKey('my-key')
78
+ const peerId = await helia.libp2p.services.keychain.exportPeerId(keyInfo.name)
41
79
 
42
80
  // store some data to publish
43
81
  const fs = unixfs(helia)
@@ -50,7 +88,7 @@ await name.publish(peerId, cid)
50
88
  const cid = name.resolve(peerId)
51
89
  ```
52
90
 
53
- ## Example
91
+ ## Example - Using custom DNS over HTTPS resolvers
54
92
 
55
93
  With default DNSResolver resolvers:
56
94
 
@@ -70,7 +108,7 @@ const name = ipns(helia, {
70
108
  const cid = name.resolveDns('some-domain-with-dnslink-entry.com')
71
109
  ```
72
110
 
73
- ## Example
111
+ ## Example - Resolving a domain with a dnslink entry
74
112
 
75
113
  Calling `resolveDns` with the `@helia/ipns` instance:
76
114
 
@@ -90,7 +128,7 @@ console.info(cid)
90
128
  // QmWebsite
91
129
  ```
92
130
 
93
- ## Example
131
+ ## Example - Using DNS-Over-HTTPS
94
132
 
95
133
  This example uses the Mozilla provided RFC 1035 DNS over HTTPS service. This
96
134
  uses binary DNS records so requires extra dependencies to process the
@@ -109,7 +147,7 @@ const cid = name.resolveDns('ipfs.io', {
109
147
  })
110
148
  ```
111
149
 
112
- ## Example
150
+ ## Example - Using DNS-JSON-Over-HTTPS
113
151
 
114
152
  DNS-JSON-Over-HTTPS resolvers use the RFC 8427 `application/dns-json` and can
115
153
  result in a smaller browser bundle due to the response being plain JSON.
@@ -124,3 +162,40 @@ const cid = name.resolveDns('ipfs.io', {
124
162
  ]
125
163
  })
126
164
  ```
165
+
166
+ # Install
167
+
168
+ ```console
169
+ $ npm i @helia/ipns
170
+ ```
171
+
172
+ ## Browser `<script>` tag
173
+
174
+ Loading this module through a script tag will make it's exports available as `HeliaIpns` in the global namespace.
175
+
176
+ ```html
177
+ <script src="https://unpkg.com/@helia/ipns/dist/index.min.js"></script>
178
+ ```
179
+
180
+ # API Docs
181
+
182
+ - <https://ipfs.github.io/helia/modules/_helia_ipns.html>
183
+
184
+ # License
185
+
186
+ Licensed under either of
187
+
188
+ - Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
189
+ - MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)
190
+
191
+ # Contribute
192
+
193
+ Contributions welcome! Please check out [the issues](https://github.com/ipfs/helia/issues).
194
+
195
+ 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.
196
+
197
+ Please be aware that all interactions related to this repo are subject to the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md).
198
+
199
+ Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
200
+
201
+ [![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md)