@helia/ipns 3.0.0 → 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 +59 -27
- package/dist/index.min.js +73 -26
- package/dist/src/index.d.ts +55 -14
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +79 -14
- 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/src/routing/pubsub.d.ts +9 -2
- package/dist/src/routing/pubsub.d.ts.map +1 -1
- package/dist/src/routing/pubsub.js +9 -9
- package/dist/src/routing/pubsub.js.map +1 -1
- package/dist/src/utils/dns.js +1 -1
- package/dist/src/utils/dns.js.map +1 -1
- package/package.json +29 -25
- package/src/index.ts +85 -17
- package/src/routing/helia.ts +45 -0
- package/src/routing/index.ts +9 -4
- package/src/routing/pubsub.ts +10 -11
- package/src/utils/dns.ts +1 -1
- package/dist/src/routing/dht.d.ts +0 -18
- package/dist/src/routing/dht.d.ts.map +0 -1
- package/dist/src/routing/dht.js +0 -28
- package/dist/src/routing/dht.js.map +0 -1
- package/dist/typedoc-urls.json +0 -40
- package/src/routing/dht.ts +0 -43
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,26 +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
|
-
import {
|
|
26
|
+
import { ipns } from '@helia/ipns'
|
|
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'
|
|
27
67
|
import { unixfs } from '@helia/unixfs'
|
|
28
68
|
|
|
29
69
|
const helia = await createHelia()
|
|
30
70
|
const name = ipns(helia, {
|
|
31
71
|
routers: [
|
|
32
|
-
dht(helia),
|
|
33
72
|
pubsub(helia)
|
|
34
73
|
]
|
|
35
74
|
})
|
|
36
75
|
|
|
37
76
|
// create a public key to publish as an IPNS name
|
|
38
|
-
const keyInfo = await helia.libp2p.keychain.createKey('my-key')
|
|
39
|
-
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)
|
|
40
79
|
|
|
41
80
|
// store some data to publish
|
|
42
81
|
const fs = unixfs(helia)
|
|
@@ -49,14 +88,15 @@ await name.publish(peerId, cid)
|
|
|
49
88
|
const cid = name.resolve(peerId)
|
|
50
89
|
```
|
|
51
90
|
|
|
52
|
-
## Example
|
|
91
|
+
## Example - Using custom DNS over HTTPS resolvers
|
|
53
92
|
|
|
54
93
|
With default DNSResolver resolvers:
|
|
55
94
|
|
|
56
95
|
```typescript
|
|
57
96
|
import { createHelia } from 'helia'
|
|
58
|
-
import {
|
|
97
|
+
import { ipns } from '@helia/ipns'
|
|
59
98
|
import { unixfs } from '@helia/unixfs'
|
|
99
|
+
import { dnsOverHttps } from '@helia/ipns/dns-resolvers'
|
|
60
100
|
|
|
61
101
|
const helia = await createHelia()
|
|
62
102
|
const name = ipns(helia, {
|
|
@@ -68,7 +108,7 @@ const name = ipns(helia, {
|
|
|
68
108
|
const cid = name.resolveDns('some-domain-with-dnslink-entry.com')
|
|
69
109
|
```
|
|
70
110
|
|
|
71
|
-
## Example
|
|
111
|
+
## Example - Resolving a domain with a dnslink entry
|
|
72
112
|
|
|
73
113
|
Calling `resolveDns` with the `@helia/ipns` instance:
|
|
74
114
|
|
|
@@ -88,7 +128,7 @@ console.info(cid)
|
|
|
88
128
|
// QmWebsite
|
|
89
129
|
```
|
|
90
130
|
|
|
91
|
-
## Example
|
|
131
|
+
## Example - Using DNS-Over-HTTPS
|
|
92
132
|
|
|
93
133
|
This example uses the Mozilla provided RFC 1035 DNS over HTTPS service. This
|
|
94
134
|
uses binary DNS records so requires extra dependencies to process the
|
|
@@ -107,7 +147,7 @@ const cid = name.resolveDns('ipfs.io', {
|
|
|
107
147
|
})
|
|
108
148
|
```
|
|
109
149
|
|
|
110
|
-
## Example
|
|
150
|
+
## Example - Using DNS-JSON-Over-HTTPS
|
|
111
151
|
|
|
112
152
|
DNS-JSON-Over-HTTPS resolvers use the RFC 8427 `application/dns-json` and can
|
|
113
153
|
result in a smaller browser bundle due to the response being plain JSON.
|
|
@@ -123,21 +163,13 @@ const cid = name.resolveDns('ipfs.io', {
|
|
|
123
163
|
})
|
|
124
164
|
```
|
|
125
165
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
- [Install](#install)
|
|
129
|
-
- [Browser `<script>` tag](#browser-script-tag)
|
|
130
|
-
- [API Docs](#api-docs)
|
|
131
|
-
- [License](#license)
|
|
132
|
-
- [Contribute](#contribute)
|
|
133
|
-
|
|
134
|
-
## Install
|
|
166
|
+
# Install
|
|
135
167
|
|
|
136
168
|
```console
|
|
137
169
|
$ npm i @helia/ipns
|
|
138
170
|
```
|
|
139
171
|
|
|
140
|
-
|
|
172
|
+
## Browser `<script>` tag
|
|
141
173
|
|
|
142
174
|
Loading this module through a script tag will make it's exports available as `HeliaIpns` in the global namespace.
|
|
143
175
|
|
|
@@ -145,20 +177,20 @@ Loading this module through a script tag will make it's exports available as `He
|
|
|
145
177
|
<script src="https://unpkg.com/@helia/ipns/dist/index.min.js"></script>
|
|
146
178
|
```
|
|
147
179
|
|
|
148
|
-
|
|
180
|
+
# API Docs
|
|
149
181
|
|
|
150
|
-
- <https://ipfs.github.io/helia
|
|
182
|
+
- <https://ipfs.github.io/helia/modules/_helia_ipns.html>
|
|
151
183
|
|
|
152
|
-
|
|
184
|
+
# License
|
|
153
185
|
|
|
154
186
|
Licensed under either of
|
|
155
187
|
|
|
156
188
|
- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
|
|
157
189
|
- MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)
|
|
158
190
|
|
|
159
|
-
|
|
191
|
+
# Contribute
|
|
160
192
|
|
|
161
|
-
Contributions welcome! Please check out [the issues](https://github.com/ipfs/helia
|
|
193
|
+
Contributions welcome! Please check out [the issues](https://github.com/ipfs/helia/issues).
|
|
162
194
|
|
|
163
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.
|
|
164
196
|
|