@helia/ipns 7.2.3-23e62e1 → 7.2.3-4f14996
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 +85 -57
- package/dist/src/index.d.ts +85 -57
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +85 -57
- package/dist/src/index.js.map +1 -1
- package/dist/src/routing/index.d.ts +4 -0
- package/dist/src/routing/index.d.ts.map +1 -1
- package/dist/src/routing/index.js.map +1 -1
- package/package.json +3 -2
- package/src/index.ts +85 -57
- package/src/routing/index.ts +5 -0
package/README.md
CHANGED
|
@@ -40,23 +40,23 @@ With IPNSRouting routers:
|
|
|
40
40
|
import { createHelia } from 'helia'
|
|
41
41
|
import { ipns } from '@helia/ipns'
|
|
42
42
|
import { unixfs } from '@helia/unixfs'
|
|
43
|
+
import { generateKeyPair } from '@libp2p/crypto/keys'
|
|
43
44
|
|
|
44
45
|
const helia = await createHelia()
|
|
45
46
|
const name = ipns(helia)
|
|
46
47
|
|
|
47
|
-
// create a
|
|
48
|
-
const
|
|
49
|
-
const peerId = await helia.libp2p.services.keychain.exportPeerId(keyInfo.name)
|
|
48
|
+
// create a keypair to publish an IPNS name
|
|
49
|
+
const privateKey = await generateKeyPair('Ed25519')
|
|
50
50
|
|
|
51
51
|
// store some data to publish
|
|
52
52
|
const fs = unixfs(helia)
|
|
53
|
-
const cid = await fs.
|
|
53
|
+
const cid = await fs.addBytes(Uint8Array.from([0, 1, 2, 3, 4]))
|
|
54
54
|
|
|
55
55
|
// publish the name
|
|
56
|
-
await name.publish(
|
|
56
|
+
await name.publish(privateKey, cid)
|
|
57
57
|
|
|
58
58
|
// resolve the name
|
|
59
|
-
const result = name.resolve(
|
|
59
|
+
const result = await name.resolve(privateKey.publicKey)
|
|
60
60
|
|
|
61
61
|
console.info(result.cid, result.path)
|
|
62
62
|
```
|
|
@@ -70,30 +70,29 @@ value.
|
|
|
70
70
|
import { createHelia } from 'helia'
|
|
71
71
|
import { ipns } from '@helia/ipns'
|
|
72
72
|
import { unixfs } from '@helia/unixfs'
|
|
73
|
+
import { generateKeyPair } from '@libp2p/crypto/keys'
|
|
73
74
|
|
|
74
75
|
const helia = await createHelia()
|
|
75
76
|
const name = ipns(helia)
|
|
76
77
|
|
|
77
|
-
// create a
|
|
78
|
-
const
|
|
79
|
-
const peerId = await helia.libp2p.services.keychain.exportPeerId(keyInfo.name)
|
|
78
|
+
// create a keypair to publish an IPNS name
|
|
79
|
+
const privateKey = await generateKeyPair('Ed25519')
|
|
80
80
|
|
|
81
81
|
// store some data to publish
|
|
82
82
|
const fs = unixfs(helia)
|
|
83
|
-
const cid = await fs.
|
|
83
|
+
const cid = await fs.addBytes(Uint8Array.from([0, 1, 2, 3, 4]))
|
|
84
84
|
|
|
85
85
|
// publish the name
|
|
86
|
-
await name.publish(
|
|
86
|
+
await name.publish(privateKey, cid)
|
|
87
87
|
|
|
88
|
-
// create another
|
|
89
|
-
const
|
|
90
|
-
const recursivePeerId = await helia.libp2p.services.keychain.exportPeerId(recursiveKeyInfo.name)
|
|
88
|
+
// create another keypair to re-publish the original record
|
|
89
|
+
const recursivePrivateKey = await generateKeyPair('Ed25519')
|
|
91
90
|
|
|
92
91
|
// publish the recursive name
|
|
93
|
-
await name.publish(
|
|
92
|
+
await name.publish(recursivePrivateKey, privateKey.publicKey)
|
|
94
93
|
|
|
95
94
|
// resolve the name recursively - it resolves until a CID is found
|
|
96
|
-
const result = name.resolve(
|
|
95
|
+
const result = await name.resolve(recursivePrivateKey.publicKey)
|
|
97
96
|
console.info(result.cid.toString() === cid.toString()) // true
|
|
98
97
|
```
|
|
99
98
|
|
|
@@ -105,27 +104,27 @@ It is possible to publish CIDs with an associated path.
|
|
|
105
104
|
import { createHelia } from 'helia'
|
|
106
105
|
import { ipns } from '@helia/ipns'
|
|
107
106
|
import { unixfs } from '@helia/unixfs'
|
|
107
|
+
import { generateKeyPair } from '@libp2p/crypto/keys'
|
|
108
108
|
|
|
109
109
|
const helia = await createHelia()
|
|
110
110
|
const name = ipns(helia)
|
|
111
111
|
|
|
112
|
-
// create a
|
|
113
|
-
const
|
|
114
|
-
const peerId = await helia.libp2p.services.keychain.exportPeerId(keyInfo.name)
|
|
112
|
+
// create a keypair to publish an IPNS name
|
|
113
|
+
const privateKey = await generateKeyPair('Ed25519')
|
|
115
114
|
|
|
116
115
|
// store some data to publish
|
|
117
116
|
const fs = unixfs(helia)
|
|
118
|
-
const fileCid = await fs.
|
|
117
|
+
const fileCid = await fs.addBytes(Uint8Array.from([0, 1, 2, 3, 4]))
|
|
119
118
|
|
|
120
119
|
// store the file in a directory
|
|
121
|
-
const dirCid = await fs.
|
|
120
|
+
const dirCid = await fs.addDirectory()
|
|
122
121
|
const finalDirCid = await fs.cp(fileCid, dirCid, '/foo.txt')
|
|
123
122
|
|
|
124
123
|
// publish the name
|
|
125
|
-
await name.publish(
|
|
124
|
+
await name.publish(privateKey, `/ipfs/${finalDirCid}/foo.txt`)
|
|
126
125
|
|
|
127
126
|
// resolve the name
|
|
128
|
-
const result = name.resolve(
|
|
127
|
+
const result = await name.resolve(privateKey.publicKey)
|
|
129
128
|
|
|
130
129
|
console.info(result.cid, result.path) // QmFoo.. 'foo.txt'
|
|
131
130
|
```
|
|
@@ -152,11 +151,14 @@ import { ipns } from '@helia/ipns'
|
|
|
152
151
|
import { pubsub } from '@helia/ipns/routing'
|
|
153
152
|
import { unixfs } from '@helia/unixfs'
|
|
154
153
|
import { gossipsub } from '@chainsafe/libp2p-gossipsub'
|
|
154
|
+
import { generateKeyPair } from '@libp2p/crypto/keys'
|
|
155
|
+
import type { Libp2p, PubSub } from '@libp2p/interface'
|
|
156
|
+
import type { DefaultLibp2pServices } from 'helia'
|
|
155
157
|
|
|
156
158
|
const libp2pOptions = libp2pDefaults()
|
|
157
159
|
libp2pOptions.services.pubsub = gossipsub()
|
|
158
160
|
|
|
159
|
-
const helia = await createHelia({
|
|
161
|
+
const helia = await createHelia<Libp2p<DefaultLibp2pServices & { pubsub: PubSub }>>({
|
|
160
162
|
libp2p: libp2pOptions
|
|
161
163
|
})
|
|
162
164
|
const name = ipns(helia, {
|
|
@@ -165,44 +167,50 @@ const name = ipns(helia, {
|
|
|
165
167
|
]
|
|
166
168
|
})
|
|
167
169
|
|
|
168
|
-
// create a
|
|
169
|
-
const
|
|
170
|
-
const peerId = await helia.libp2p.services.keychain.exportPeerId(keyInfo.name)
|
|
170
|
+
// create a keypair to publish an IPNS name
|
|
171
|
+
const privateKey = await generateKeyPair('Ed25519')
|
|
171
172
|
|
|
172
173
|
// store some data to publish
|
|
173
174
|
const fs = unixfs(helia)
|
|
174
|
-
const cid = await fs.
|
|
175
|
+
const cid = await fs.addBytes(Uint8Array.from([0, 1, 2, 3, 4]))
|
|
175
176
|
|
|
176
177
|
// publish the name
|
|
177
|
-
await name.publish(
|
|
178
|
+
await name.publish(privateKey, cid)
|
|
178
179
|
|
|
179
180
|
// resolve the name
|
|
180
|
-
const
|
|
181
|
+
const result = await name.resolve(privateKey.publicKey)
|
|
181
182
|
```
|
|
182
183
|
|
|
183
184
|
## Example - Using custom DNS over HTTPS resolvers
|
|
184
185
|
|
|
185
|
-
|
|
186
|
+
To use custom resolvers, configure Helia's `dns` option:
|
|
186
187
|
|
|
187
188
|
```TypeScript
|
|
188
189
|
import { createHelia } from 'helia'
|
|
189
190
|
import { ipns } from '@helia/ipns'
|
|
190
|
-
import {
|
|
191
|
-
import { dnsOverHttps } from '@
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
const
|
|
195
|
-
|
|
196
|
-
|
|
191
|
+
import { dns } from '@multiformats/dns'
|
|
192
|
+
import { dnsOverHttps } from '@multiformats/dns/resolvers'
|
|
193
|
+
import { helia } from '@helia/ipns/routing'
|
|
194
|
+
|
|
195
|
+
const node = await createHelia({
|
|
196
|
+
dns: dns({
|
|
197
|
+
resolvers: {
|
|
198
|
+
'.': dnsOverHttps('https://private-dns-server.me/dns-query')
|
|
199
|
+
}
|
|
200
|
+
})
|
|
201
|
+
})
|
|
202
|
+
const name = ipns(node, {
|
|
203
|
+
routers: [
|
|
204
|
+
helia(node.routing)
|
|
197
205
|
]
|
|
198
206
|
})
|
|
199
207
|
|
|
200
|
-
const
|
|
208
|
+
const result = name.resolveDNSLink('some-domain-with-dnslink-entry.com')
|
|
201
209
|
```
|
|
202
210
|
|
|
203
211
|
## Example - Resolving a domain with a dnslink entry
|
|
204
212
|
|
|
205
|
-
Calling `
|
|
213
|
+
Calling `resolveDNSLink` with the `@helia/ipns` instance:
|
|
206
214
|
|
|
207
215
|
```TypeScript
|
|
208
216
|
// resolve a CID from a TXT record in a DNS zone file, using the default
|
|
@@ -214,10 +222,16 @@ Calling `resolveDns` with the `@helia/ipns` instance:
|
|
|
214
222
|
// ;; ANSWER SECTION:
|
|
215
223
|
// _dnslink.website.ipfs.io. 60 IN TXT "dnslink=/ipfs/QmWebsite"
|
|
216
224
|
|
|
217
|
-
|
|
225
|
+
import { createHelia } from 'helia'
|
|
226
|
+
import { ipns } from '@helia/ipns'
|
|
227
|
+
|
|
228
|
+
const node = await createHelia()
|
|
229
|
+
const name = ipns(node)
|
|
218
230
|
|
|
219
|
-
|
|
220
|
-
|
|
231
|
+
const { answer } = await name.resolveDNSLink('ipfs.io')
|
|
232
|
+
|
|
233
|
+
console.info(answer)
|
|
234
|
+
// { data: '/ipfs/QmWebsite' }
|
|
221
235
|
```
|
|
222
236
|
|
|
223
237
|
## Example - Using DNS-Over-HTTPS
|
|
@@ -229,14 +243,21 @@ response which can increase browser bundle sizes.
|
|
|
229
243
|
If this is a concern, use the DNS-JSON-Over-HTTPS resolver instead.
|
|
230
244
|
|
|
231
245
|
```TypeScript
|
|
232
|
-
|
|
233
|
-
import {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
246
|
+
import { createHelia } from 'helia'
|
|
247
|
+
import { ipns } from '@helia/ipns'
|
|
248
|
+
import { dns } from '@multiformats/dns'
|
|
249
|
+
import { dnsOverHttps } from '@multiformats/dns/resolvers'
|
|
250
|
+
|
|
251
|
+
const node = await createHelia({
|
|
252
|
+
dns: dns({
|
|
253
|
+
resolvers: {
|
|
254
|
+
'.': dnsOverHttps('https://mozilla.cloudflare-dns.com/dns-query')
|
|
255
|
+
}
|
|
256
|
+
})
|
|
239
257
|
})
|
|
258
|
+
const name = ipns(node)
|
|
259
|
+
|
|
260
|
+
const result = await name.resolveDNSLink('ipfs.io')
|
|
240
261
|
```
|
|
241
262
|
|
|
242
263
|
## Example - Using DNS-JSON-Over-HTTPS
|
|
@@ -245,14 +266,21 @@ DNS-JSON-Over-HTTPS resolvers use the RFC 8427 `application/dns-json` and can
|
|
|
245
266
|
result in a smaller browser bundle due to the response being plain JSON.
|
|
246
267
|
|
|
247
268
|
```TypeScript
|
|
248
|
-
|
|
249
|
-
import {
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
269
|
+
import { createHelia } from 'helia'
|
|
270
|
+
import { ipns } from '@helia/ipns'
|
|
271
|
+
import { dns } from '@multiformats/dns'
|
|
272
|
+
import { dnsJsonOverHttps } from '@multiformats/dns/resolvers'
|
|
273
|
+
|
|
274
|
+
const node = await createHelia({
|
|
275
|
+
dns: dns({
|
|
276
|
+
resolvers: {
|
|
277
|
+
'.': dnsJsonOverHttps('https://mozilla.cloudflare-dns.com/dns-query')
|
|
278
|
+
}
|
|
279
|
+
})
|
|
255
280
|
})
|
|
281
|
+
const name = ipns(node)
|
|
282
|
+
|
|
283
|
+
const result = await name.resolveDNSLink('ipfs.io')
|
|
256
284
|
```
|
|
257
285
|
|
|
258
286
|
# Install
|
package/dist/src/index.d.ts
CHANGED
|
@@ -11,23 +11,23 @@
|
|
|
11
11
|
* import { createHelia } from 'helia'
|
|
12
12
|
* import { ipns } from '@helia/ipns'
|
|
13
13
|
* import { unixfs } from '@helia/unixfs'
|
|
14
|
+
* import { generateKeyPair } from '@libp2p/crypto/keys'
|
|
14
15
|
*
|
|
15
16
|
* const helia = await createHelia()
|
|
16
17
|
* const name = ipns(helia)
|
|
17
18
|
*
|
|
18
|
-
* // create a
|
|
19
|
-
* const
|
|
20
|
-
* const peerId = await helia.libp2p.services.keychain.exportPeerId(keyInfo.name)
|
|
19
|
+
* // create a keypair to publish an IPNS name
|
|
20
|
+
* const privateKey = await generateKeyPair('Ed25519')
|
|
21
21
|
*
|
|
22
22
|
* // store some data to publish
|
|
23
23
|
* const fs = unixfs(helia)
|
|
24
|
-
* const cid = await fs.
|
|
24
|
+
* const cid = await fs.addBytes(Uint8Array.from([0, 1, 2, 3, 4]))
|
|
25
25
|
*
|
|
26
26
|
* // publish the name
|
|
27
|
-
* await name.publish(
|
|
27
|
+
* await name.publish(privateKey, cid)
|
|
28
28
|
*
|
|
29
29
|
* // resolve the name
|
|
30
|
-
* const result = name.resolve(
|
|
30
|
+
* const result = await name.resolve(privateKey.publicKey)
|
|
31
31
|
*
|
|
32
32
|
* console.info(result.cid, result.path)
|
|
33
33
|
* ```
|
|
@@ -41,30 +41,29 @@
|
|
|
41
41
|
* import { createHelia } from 'helia'
|
|
42
42
|
* import { ipns } from '@helia/ipns'
|
|
43
43
|
* import { unixfs } from '@helia/unixfs'
|
|
44
|
+
* import { generateKeyPair } from '@libp2p/crypto/keys'
|
|
44
45
|
*
|
|
45
46
|
* const helia = await createHelia()
|
|
46
47
|
* const name = ipns(helia)
|
|
47
48
|
*
|
|
48
|
-
* // create a
|
|
49
|
-
* const
|
|
50
|
-
* const peerId = await helia.libp2p.services.keychain.exportPeerId(keyInfo.name)
|
|
49
|
+
* // create a keypair to publish an IPNS name
|
|
50
|
+
* const privateKey = await generateKeyPair('Ed25519')
|
|
51
51
|
*
|
|
52
52
|
* // store some data to publish
|
|
53
53
|
* const fs = unixfs(helia)
|
|
54
|
-
* const cid = await fs.
|
|
54
|
+
* const cid = await fs.addBytes(Uint8Array.from([0, 1, 2, 3, 4]))
|
|
55
55
|
*
|
|
56
56
|
* // publish the name
|
|
57
|
-
* await name.publish(
|
|
57
|
+
* await name.publish(privateKey, cid)
|
|
58
58
|
*
|
|
59
|
-
* // create another
|
|
60
|
-
* const
|
|
61
|
-
* const recursivePeerId = await helia.libp2p.services.keychain.exportPeerId(recursiveKeyInfo.name)
|
|
59
|
+
* // create another keypair to re-publish the original record
|
|
60
|
+
* const recursivePrivateKey = await generateKeyPair('Ed25519')
|
|
62
61
|
*
|
|
63
62
|
* // publish the recursive name
|
|
64
|
-
* await name.publish(
|
|
63
|
+
* await name.publish(recursivePrivateKey, privateKey.publicKey)
|
|
65
64
|
*
|
|
66
65
|
* // resolve the name recursively - it resolves until a CID is found
|
|
67
|
-
* const result = name.resolve(
|
|
66
|
+
* const result = await name.resolve(recursivePrivateKey.publicKey)
|
|
68
67
|
* console.info(result.cid.toString() === cid.toString()) // true
|
|
69
68
|
* ```
|
|
70
69
|
*
|
|
@@ -76,27 +75,27 @@
|
|
|
76
75
|
* import { createHelia } from 'helia'
|
|
77
76
|
* import { ipns } from '@helia/ipns'
|
|
78
77
|
* import { unixfs } from '@helia/unixfs'
|
|
78
|
+
* import { generateKeyPair } from '@libp2p/crypto/keys'
|
|
79
79
|
*
|
|
80
80
|
* const helia = await createHelia()
|
|
81
81
|
* const name = ipns(helia)
|
|
82
82
|
*
|
|
83
|
-
* // create a
|
|
84
|
-
* const
|
|
85
|
-
* const peerId = await helia.libp2p.services.keychain.exportPeerId(keyInfo.name)
|
|
83
|
+
* // create a keypair to publish an IPNS name
|
|
84
|
+
* const privateKey = await generateKeyPair('Ed25519')
|
|
86
85
|
*
|
|
87
86
|
* // store some data to publish
|
|
88
87
|
* const fs = unixfs(helia)
|
|
89
|
-
* const fileCid = await fs.
|
|
88
|
+
* const fileCid = await fs.addBytes(Uint8Array.from([0, 1, 2, 3, 4]))
|
|
90
89
|
*
|
|
91
90
|
* // store the file in a directory
|
|
92
|
-
* const dirCid = await fs.
|
|
91
|
+
* const dirCid = await fs.addDirectory()
|
|
93
92
|
* const finalDirCid = await fs.cp(fileCid, dirCid, '/foo.txt')
|
|
94
93
|
*
|
|
95
94
|
* // publish the name
|
|
96
|
-
* await name.publish(
|
|
95
|
+
* await name.publish(privateKey, `/ipfs/${finalDirCid}/foo.txt`)
|
|
97
96
|
*
|
|
98
97
|
* // resolve the name
|
|
99
|
-
* const result = name.resolve(
|
|
98
|
+
* const result = await name.resolve(privateKey.publicKey)
|
|
100
99
|
*
|
|
101
100
|
* console.info(result.cid, result.path) // QmFoo.. 'foo.txt'
|
|
102
101
|
* ```
|
|
@@ -123,11 +122,14 @@
|
|
|
123
122
|
* import { pubsub } from '@helia/ipns/routing'
|
|
124
123
|
* import { unixfs } from '@helia/unixfs'
|
|
125
124
|
* import { gossipsub } from '@chainsafe/libp2p-gossipsub'
|
|
125
|
+
* import { generateKeyPair } from '@libp2p/crypto/keys'
|
|
126
|
+
* import type { Libp2p, PubSub } from '@libp2p/interface'
|
|
127
|
+
* import type { DefaultLibp2pServices } from 'helia'
|
|
126
128
|
*
|
|
127
129
|
* const libp2pOptions = libp2pDefaults()
|
|
128
130
|
* libp2pOptions.services.pubsub = gossipsub()
|
|
129
131
|
*
|
|
130
|
-
* const helia = await createHelia({
|
|
132
|
+
* const helia = await createHelia<Libp2p<DefaultLibp2pServices & { pubsub: PubSub }>>({
|
|
131
133
|
* libp2p: libp2pOptions
|
|
132
134
|
* })
|
|
133
135
|
* const name = ipns(helia, {
|
|
@@ -136,44 +138,50 @@
|
|
|
136
138
|
* ]
|
|
137
139
|
* })
|
|
138
140
|
*
|
|
139
|
-
* // create a
|
|
140
|
-
* const
|
|
141
|
-
* const peerId = await helia.libp2p.services.keychain.exportPeerId(keyInfo.name)
|
|
141
|
+
* // create a keypair to publish an IPNS name
|
|
142
|
+
* const privateKey = await generateKeyPair('Ed25519')
|
|
142
143
|
*
|
|
143
144
|
* // store some data to publish
|
|
144
145
|
* const fs = unixfs(helia)
|
|
145
|
-
* const cid = await fs.
|
|
146
|
+
* const cid = await fs.addBytes(Uint8Array.from([0, 1, 2, 3, 4]))
|
|
146
147
|
*
|
|
147
148
|
* // publish the name
|
|
148
|
-
* await name.publish(
|
|
149
|
+
* await name.publish(privateKey, cid)
|
|
149
150
|
*
|
|
150
151
|
* // resolve the name
|
|
151
|
-
* const
|
|
152
|
+
* const result = await name.resolve(privateKey.publicKey)
|
|
152
153
|
* ```
|
|
153
154
|
*
|
|
154
155
|
* @example Using custom DNS over HTTPS resolvers
|
|
155
156
|
*
|
|
156
|
-
*
|
|
157
|
+
* To use custom resolvers, configure Helia's `dns` option:
|
|
157
158
|
*
|
|
158
159
|
* ```TypeScript
|
|
159
160
|
* import { createHelia } from 'helia'
|
|
160
161
|
* import { ipns } from '@helia/ipns'
|
|
161
|
-
* import {
|
|
162
|
-
* import { dnsOverHttps } from '@
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
* const
|
|
166
|
-
*
|
|
167
|
-
*
|
|
162
|
+
* import { dns } from '@multiformats/dns'
|
|
163
|
+
* import { dnsOverHttps } from '@multiformats/dns/resolvers'
|
|
164
|
+
* import { helia } from '@helia/ipns/routing'
|
|
165
|
+
*
|
|
166
|
+
* const node = await createHelia({
|
|
167
|
+
* dns: dns({
|
|
168
|
+
* resolvers: {
|
|
169
|
+
* '.': dnsOverHttps('https://private-dns-server.me/dns-query')
|
|
170
|
+
* }
|
|
171
|
+
* })
|
|
172
|
+
* })
|
|
173
|
+
* const name = ipns(node, {
|
|
174
|
+
* routers: [
|
|
175
|
+
* helia(node.routing)
|
|
168
176
|
* ]
|
|
169
177
|
* })
|
|
170
178
|
*
|
|
171
|
-
* const
|
|
179
|
+
* const result = name.resolveDNSLink('some-domain-with-dnslink-entry.com')
|
|
172
180
|
* ```
|
|
173
181
|
*
|
|
174
182
|
* @example Resolving a domain with a dnslink entry
|
|
175
183
|
*
|
|
176
|
-
* Calling `
|
|
184
|
+
* Calling `resolveDNSLink` with the `@helia/ipns` instance:
|
|
177
185
|
*
|
|
178
186
|
* ```TypeScript
|
|
179
187
|
* // resolve a CID from a TXT record in a DNS zone file, using the default
|
|
@@ -185,10 +193,16 @@
|
|
|
185
193
|
* // ;; ANSWER SECTION:
|
|
186
194
|
* // _dnslink.website.ipfs.io. 60 IN TXT "dnslink=/ipfs/QmWebsite"
|
|
187
195
|
*
|
|
188
|
-
*
|
|
196
|
+
* import { createHelia } from 'helia'
|
|
197
|
+
* import { ipns } from '@helia/ipns'
|
|
198
|
+
*
|
|
199
|
+
* const node = await createHelia()
|
|
200
|
+
* const name = ipns(node)
|
|
189
201
|
*
|
|
190
|
-
*
|
|
191
|
-
*
|
|
202
|
+
* const { answer } = await name.resolveDNSLink('ipfs.io')
|
|
203
|
+
*
|
|
204
|
+
* console.info(answer)
|
|
205
|
+
* // { data: '/ipfs/QmWebsite' }
|
|
192
206
|
* ```
|
|
193
207
|
*
|
|
194
208
|
* @example Using DNS-Over-HTTPS
|
|
@@ -200,14 +214,21 @@
|
|
|
200
214
|
* If this is a concern, use the DNS-JSON-Over-HTTPS resolver instead.
|
|
201
215
|
*
|
|
202
216
|
* ```TypeScript
|
|
203
|
-
*
|
|
204
|
-
* import {
|
|
205
|
-
*
|
|
206
|
-
*
|
|
207
|
-
*
|
|
208
|
-
*
|
|
209
|
-
*
|
|
217
|
+
* import { createHelia } from 'helia'
|
|
218
|
+
* import { ipns } from '@helia/ipns'
|
|
219
|
+
* import { dns } from '@multiformats/dns'
|
|
220
|
+
* import { dnsOverHttps } from '@multiformats/dns/resolvers'
|
|
221
|
+
*
|
|
222
|
+
* const node = await createHelia({
|
|
223
|
+
* dns: dns({
|
|
224
|
+
* resolvers: {
|
|
225
|
+
* '.': dnsOverHttps('https://mozilla.cloudflare-dns.com/dns-query')
|
|
226
|
+
* }
|
|
227
|
+
* })
|
|
210
228
|
* })
|
|
229
|
+
* const name = ipns(node)
|
|
230
|
+
*
|
|
231
|
+
* const result = await name.resolveDNSLink('ipfs.io')
|
|
211
232
|
* ```
|
|
212
233
|
*
|
|
213
234
|
* @example Using DNS-JSON-Over-HTTPS
|
|
@@ -216,14 +237,21 @@
|
|
|
216
237
|
* result in a smaller browser bundle due to the response being plain JSON.
|
|
217
238
|
*
|
|
218
239
|
* ```TypeScript
|
|
219
|
-
*
|
|
220
|
-
* import {
|
|
221
|
-
*
|
|
222
|
-
*
|
|
223
|
-
*
|
|
224
|
-
*
|
|
225
|
-
*
|
|
240
|
+
* import { createHelia } from 'helia'
|
|
241
|
+
* import { ipns } from '@helia/ipns'
|
|
242
|
+
* import { dns } from '@multiformats/dns'
|
|
243
|
+
* import { dnsJsonOverHttps } from '@multiformats/dns/resolvers'
|
|
244
|
+
*
|
|
245
|
+
* const node = await createHelia({
|
|
246
|
+
* dns: dns({
|
|
247
|
+
* resolvers: {
|
|
248
|
+
* '.': dnsJsonOverHttps('https://mozilla.cloudflare-dns.com/dns-query')
|
|
249
|
+
* }
|
|
250
|
+
* })
|
|
226
251
|
* })
|
|
252
|
+
* const name = ipns(node)
|
|
253
|
+
*
|
|
254
|
+
* const result = await name.resolveDNSLink('ipfs.io')
|
|
227
255
|
* ```
|
|
228
256
|
*/
|
|
229
257
|
import { type IPNSRecord } from 'ipns';
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+PG;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AAE,GAAG,GAAG,SAAS,GAAG,eAAe,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;IAEvI;;;OAGG;IACH,OAAO,CAAC,GAAG,EAAE,SAAS,GAAG,eAAe,CAAC,IAAI,GAAG,IAAI,CAAC,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAA;IAE5G;;OAEG;IACH,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAA;IAE9F;;OAEG;IACH,SAAS,CAAC,OAAO,CAAC,EAAE,gBAAgB,GAAG,IAAI,CAAA;CAC5C;AAED,YAAY,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAErD,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,SAAS,CAAA;IACpB,OAAO,EAAE,OAAO,CAAA;IAChB,GAAG,EAAE,GAAG,CAAA;IACR,MAAM,EAAE,eAAe,CAAA;CACxB;AA2QD,MAAM,WAAW,WAAW;IAC1B,OAAO,CAAC,EAAE,WAAW,EAAE,CAAA;CACxB;AAED,wBAAgB,IAAI,CAAE,UAAU,EAAE,cAAc,EAAE,EAAE,OAAY,EAAE,GAAE,WAAgB,GAAG,IAAI,CAE1F;AAED,OAAO,EAAE,aAAa,EAAE,KAAK,iBAAiB,EAAE,CAAA;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA"}
|
package/dist/src/index.js
CHANGED
|
@@ -11,23 +11,23 @@
|
|
|
11
11
|
* import { createHelia } from 'helia'
|
|
12
12
|
* import { ipns } from '@helia/ipns'
|
|
13
13
|
* import { unixfs } from '@helia/unixfs'
|
|
14
|
+
* import { generateKeyPair } from '@libp2p/crypto/keys'
|
|
14
15
|
*
|
|
15
16
|
* const helia = await createHelia()
|
|
16
17
|
* const name = ipns(helia)
|
|
17
18
|
*
|
|
18
|
-
* // create a
|
|
19
|
-
* const
|
|
20
|
-
* const peerId = await helia.libp2p.services.keychain.exportPeerId(keyInfo.name)
|
|
19
|
+
* // create a keypair to publish an IPNS name
|
|
20
|
+
* const privateKey = await generateKeyPair('Ed25519')
|
|
21
21
|
*
|
|
22
22
|
* // store some data to publish
|
|
23
23
|
* const fs = unixfs(helia)
|
|
24
|
-
* const cid = await fs.
|
|
24
|
+
* const cid = await fs.addBytes(Uint8Array.from([0, 1, 2, 3, 4]))
|
|
25
25
|
*
|
|
26
26
|
* // publish the name
|
|
27
|
-
* await name.publish(
|
|
27
|
+
* await name.publish(privateKey, cid)
|
|
28
28
|
*
|
|
29
29
|
* // resolve the name
|
|
30
|
-
* const result = name.resolve(
|
|
30
|
+
* const result = await name.resolve(privateKey.publicKey)
|
|
31
31
|
*
|
|
32
32
|
* console.info(result.cid, result.path)
|
|
33
33
|
* ```
|
|
@@ -41,30 +41,29 @@
|
|
|
41
41
|
* import { createHelia } from 'helia'
|
|
42
42
|
* import { ipns } from '@helia/ipns'
|
|
43
43
|
* import { unixfs } from '@helia/unixfs'
|
|
44
|
+
* import { generateKeyPair } from '@libp2p/crypto/keys'
|
|
44
45
|
*
|
|
45
46
|
* const helia = await createHelia()
|
|
46
47
|
* const name = ipns(helia)
|
|
47
48
|
*
|
|
48
|
-
* // create a
|
|
49
|
-
* const
|
|
50
|
-
* const peerId = await helia.libp2p.services.keychain.exportPeerId(keyInfo.name)
|
|
49
|
+
* // create a keypair to publish an IPNS name
|
|
50
|
+
* const privateKey = await generateKeyPair('Ed25519')
|
|
51
51
|
*
|
|
52
52
|
* // store some data to publish
|
|
53
53
|
* const fs = unixfs(helia)
|
|
54
|
-
* const cid = await fs.
|
|
54
|
+
* const cid = await fs.addBytes(Uint8Array.from([0, 1, 2, 3, 4]))
|
|
55
55
|
*
|
|
56
56
|
* // publish the name
|
|
57
|
-
* await name.publish(
|
|
57
|
+
* await name.publish(privateKey, cid)
|
|
58
58
|
*
|
|
59
|
-
* // create another
|
|
60
|
-
* const
|
|
61
|
-
* const recursivePeerId = await helia.libp2p.services.keychain.exportPeerId(recursiveKeyInfo.name)
|
|
59
|
+
* // create another keypair to re-publish the original record
|
|
60
|
+
* const recursivePrivateKey = await generateKeyPair('Ed25519')
|
|
62
61
|
*
|
|
63
62
|
* // publish the recursive name
|
|
64
|
-
* await name.publish(
|
|
63
|
+
* await name.publish(recursivePrivateKey, privateKey.publicKey)
|
|
65
64
|
*
|
|
66
65
|
* // resolve the name recursively - it resolves until a CID is found
|
|
67
|
-
* const result = name.resolve(
|
|
66
|
+
* const result = await name.resolve(recursivePrivateKey.publicKey)
|
|
68
67
|
* console.info(result.cid.toString() === cid.toString()) // true
|
|
69
68
|
* ```
|
|
70
69
|
*
|
|
@@ -76,27 +75,27 @@
|
|
|
76
75
|
* import { createHelia } from 'helia'
|
|
77
76
|
* import { ipns } from '@helia/ipns'
|
|
78
77
|
* import { unixfs } from '@helia/unixfs'
|
|
78
|
+
* import { generateKeyPair } from '@libp2p/crypto/keys'
|
|
79
79
|
*
|
|
80
80
|
* const helia = await createHelia()
|
|
81
81
|
* const name = ipns(helia)
|
|
82
82
|
*
|
|
83
|
-
* // create a
|
|
84
|
-
* const
|
|
85
|
-
* const peerId = await helia.libp2p.services.keychain.exportPeerId(keyInfo.name)
|
|
83
|
+
* // create a keypair to publish an IPNS name
|
|
84
|
+
* const privateKey = await generateKeyPair('Ed25519')
|
|
86
85
|
*
|
|
87
86
|
* // store some data to publish
|
|
88
87
|
* const fs = unixfs(helia)
|
|
89
|
-
* const fileCid = await fs.
|
|
88
|
+
* const fileCid = await fs.addBytes(Uint8Array.from([0, 1, 2, 3, 4]))
|
|
90
89
|
*
|
|
91
90
|
* // store the file in a directory
|
|
92
|
-
* const dirCid = await fs.
|
|
91
|
+
* const dirCid = await fs.addDirectory()
|
|
93
92
|
* const finalDirCid = await fs.cp(fileCid, dirCid, '/foo.txt')
|
|
94
93
|
*
|
|
95
94
|
* // publish the name
|
|
96
|
-
* await name.publish(
|
|
95
|
+
* await name.publish(privateKey, `/ipfs/${finalDirCid}/foo.txt`)
|
|
97
96
|
*
|
|
98
97
|
* // resolve the name
|
|
99
|
-
* const result = name.resolve(
|
|
98
|
+
* const result = await name.resolve(privateKey.publicKey)
|
|
100
99
|
*
|
|
101
100
|
* console.info(result.cid, result.path) // QmFoo.. 'foo.txt'
|
|
102
101
|
* ```
|
|
@@ -123,11 +122,14 @@
|
|
|
123
122
|
* import { pubsub } from '@helia/ipns/routing'
|
|
124
123
|
* import { unixfs } from '@helia/unixfs'
|
|
125
124
|
* import { gossipsub } from '@chainsafe/libp2p-gossipsub'
|
|
125
|
+
* import { generateKeyPair } from '@libp2p/crypto/keys'
|
|
126
|
+
* import type { Libp2p, PubSub } from '@libp2p/interface'
|
|
127
|
+
* import type { DefaultLibp2pServices } from 'helia'
|
|
126
128
|
*
|
|
127
129
|
* const libp2pOptions = libp2pDefaults()
|
|
128
130
|
* libp2pOptions.services.pubsub = gossipsub()
|
|
129
131
|
*
|
|
130
|
-
* const helia = await createHelia({
|
|
132
|
+
* const helia = await createHelia<Libp2p<DefaultLibp2pServices & { pubsub: PubSub }>>({
|
|
131
133
|
* libp2p: libp2pOptions
|
|
132
134
|
* })
|
|
133
135
|
* const name = ipns(helia, {
|
|
@@ -136,44 +138,50 @@
|
|
|
136
138
|
* ]
|
|
137
139
|
* })
|
|
138
140
|
*
|
|
139
|
-
* // create a
|
|
140
|
-
* const
|
|
141
|
-
* const peerId = await helia.libp2p.services.keychain.exportPeerId(keyInfo.name)
|
|
141
|
+
* // create a keypair to publish an IPNS name
|
|
142
|
+
* const privateKey = await generateKeyPair('Ed25519')
|
|
142
143
|
*
|
|
143
144
|
* // store some data to publish
|
|
144
145
|
* const fs = unixfs(helia)
|
|
145
|
-
* const cid = await fs.
|
|
146
|
+
* const cid = await fs.addBytes(Uint8Array.from([0, 1, 2, 3, 4]))
|
|
146
147
|
*
|
|
147
148
|
* // publish the name
|
|
148
|
-
* await name.publish(
|
|
149
|
+
* await name.publish(privateKey, cid)
|
|
149
150
|
*
|
|
150
151
|
* // resolve the name
|
|
151
|
-
* const
|
|
152
|
+
* const result = await name.resolve(privateKey.publicKey)
|
|
152
153
|
* ```
|
|
153
154
|
*
|
|
154
155
|
* @example Using custom DNS over HTTPS resolvers
|
|
155
156
|
*
|
|
156
|
-
*
|
|
157
|
+
* To use custom resolvers, configure Helia's `dns` option:
|
|
157
158
|
*
|
|
158
159
|
* ```TypeScript
|
|
159
160
|
* import { createHelia } from 'helia'
|
|
160
161
|
* import { ipns } from '@helia/ipns'
|
|
161
|
-
* import {
|
|
162
|
-
* import { dnsOverHttps } from '@
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
* const
|
|
166
|
-
*
|
|
167
|
-
*
|
|
162
|
+
* import { dns } from '@multiformats/dns'
|
|
163
|
+
* import { dnsOverHttps } from '@multiformats/dns/resolvers'
|
|
164
|
+
* import { helia } from '@helia/ipns/routing'
|
|
165
|
+
*
|
|
166
|
+
* const node = await createHelia({
|
|
167
|
+
* dns: dns({
|
|
168
|
+
* resolvers: {
|
|
169
|
+
* '.': dnsOverHttps('https://private-dns-server.me/dns-query')
|
|
170
|
+
* }
|
|
171
|
+
* })
|
|
172
|
+
* })
|
|
173
|
+
* const name = ipns(node, {
|
|
174
|
+
* routers: [
|
|
175
|
+
* helia(node.routing)
|
|
168
176
|
* ]
|
|
169
177
|
* })
|
|
170
178
|
*
|
|
171
|
-
* const
|
|
179
|
+
* const result = name.resolveDNSLink('some-domain-with-dnslink-entry.com')
|
|
172
180
|
* ```
|
|
173
181
|
*
|
|
174
182
|
* @example Resolving a domain with a dnslink entry
|
|
175
183
|
*
|
|
176
|
-
* Calling `
|
|
184
|
+
* Calling `resolveDNSLink` with the `@helia/ipns` instance:
|
|
177
185
|
*
|
|
178
186
|
* ```TypeScript
|
|
179
187
|
* // resolve a CID from a TXT record in a DNS zone file, using the default
|
|
@@ -185,10 +193,16 @@
|
|
|
185
193
|
* // ;; ANSWER SECTION:
|
|
186
194
|
* // _dnslink.website.ipfs.io. 60 IN TXT "dnslink=/ipfs/QmWebsite"
|
|
187
195
|
*
|
|
188
|
-
*
|
|
196
|
+
* import { createHelia } from 'helia'
|
|
197
|
+
* import { ipns } from '@helia/ipns'
|
|
198
|
+
*
|
|
199
|
+
* const node = await createHelia()
|
|
200
|
+
* const name = ipns(node)
|
|
189
201
|
*
|
|
190
|
-
*
|
|
191
|
-
*
|
|
202
|
+
* const { answer } = await name.resolveDNSLink('ipfs.io')
|
|
203
|
+
*
|
|
204
|
+
* console.info(answer)
|
|
205
|
+
* // { data: '/ipfs/QmWebsite' }
|
|
192
206
|
* ```
|
|
193
207
|
*
|
|
194
208
|
* @example Using DNS-Over-HTTPS
|
|
@@ -200,14 +214,21 @@
|
|
|
200
214
|
* If this is a concern, use the DNS-JSON-Over-HTTPS resolver instead.
|
|
201
215
|
*
|
|
202
216
|
* ```TypeScript
|
|
203
|
-
*
|
|
204
|
-
* import {
|
|
205
|
-
*
|
|
206
|
-
*
|
|
207
|
-
*
|
|
208
|
-
*
|
|
209
|
-
*
|
|
217
|
+
* import { createHelia } from 'helia'
|
|
218
|
+
* import { ipns } from '@helia/ipns'
|
|
219
|
+
* import { dns } from '@multiformats/dns'
|
|
220
|
+
* import { dnsOverHttps } from '@multiformats/dns/resolvers'
|
|
221
|
+
*
|
|
222
|
+
* const node = await createHelia({
|
|
223
|
+
* dns: dns({
|
|
224
|
+
* resolvers: {
|
|
225
|
+
* '.': dnsOverHttps('https://mozilla.cloudflare-dns.com/dns-query')
|
|
226
|
+
* }
|
|
227
|
+
* })
|
|
210
228
|
* })
|
|
229
|
+
* const name = ipns(node)
|
|
230
|
+
*
|
|
231
|
+
* const result = await name.resolveDNSLink('ipfs.io')
|
|
211
232
|
* ```
|
|
212
233
|
*
|
|
213
234
|
* @example Using DNS-JSON-Over-HTTPS
|
|
@@ -216,14 +237,21 @@
|
|
|
216
237
|
* result in a smaller browser bundle due to the response being plain JSON.
|
|
217
238
|
*
|
|
218
239
|
* ```TypeScript
|
|
219
|
-
*
|
|
220
|
-
* import {
|
|
221
|
-
*
|
|
222
|
-
*
|
|
223
|
-
*
|
|
224
|
-
*
|
|
225
|
-
*
|
|
240
|
+
* import { createHelia } from 'helia'
|
|
241
|
+
* import { ipns } from '@helia/ipns'
|
|
242
|
+
* import { dns } from '@multiformats/dns'
|
|
243
|
+
* import { dnsJsonOverHttps } from '@multiformats/dns/resolvers'
|
|
244
|
+
*
|
|
245
|
+
* const node = await createHelia({
|
|
246
|
+
* dns: dns({
|
|
247
|
+
* resolvers: {
|
|
248
|
+
* '.': dnsJsonOverHttps('https://mozilla.cloudflare-dns.com/dns-query')
|
|
249
|
+
* }
|
|
250
|
+
* })
|
|
226
251
|
* })
|
|
252
|
+
* const name = ipns(node)
|
|
253
|
+
*
|
|
254
|
+
* const result = await name.resolveDNSLink('ipfs.io')
|
|
227
255
|
* ```
|
|
228
256
|
*/
|
|
229
257
|
import { NotFoundError, isPublicKey } from '@libp2p/interface';
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+PG;AAEH,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,M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CAAC,GAAG,YAAY,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,YAAY,UAAU,CAAC,CAAC,CAAC,QAAQ,0BAA0B,YAAY,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,UAAU,CAAC,CAAA;YACzK,CAAC;YAED,MAAM,IAAI,aAAa,CAAC,uCAAuC,CAAC,CAAA;QAClE,CAAC;QAED,MAAM,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC,CAAA;QAEzD,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;QAEtD,OAAO,mBAAmB,CAAC,MAAM,CAAC,CAAA;IACpC,CAAC;CACF;AAMD,MAAM,UAAU,IAAI,CAAE,UAA0B,EAAE,EAAE,OAAO,GAAG,EAAE,KAAkB,EAAE;IAClF,OAAO,IAAI,WAAW,CAAC,UAAU,EAAE,OAAO,CAAC,CAAA;AAC7C,CAAC;AAED,OAAO,EAAE,aAAa,EAA0B,CAAA;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA"}
|
|
@@ -17,7 +17,11 @@ export interface IPNSRouting {
|
|
|
17
17
|
put(routingKey: Uint8Array, marshaledRecord: Uint8Array, options?: PutOptions): Promise<void>;
|
|
18
18
|
get(routingKey: Uint8Array, options?: GetOptions): Promise<Uint8Array>;
|
|
19
19
|
}
|
|
20
|
+
export type { DatastoreProgressEvents };
|
|
21
|
+
export type { HeliaRoutingProgressEvents };
|
|
22
|
+
export type { PubSubProgressEvents };
|
|
20
23
|
export type IPNSRoutingEvents = DatastoreProgressEvents | HeliaRoutingProgressEvents | PubSubProgressEvents;
|
|
21
24
|
export { helia } from './helia.js';
|
|
22
25
|
export { pubsub } from './pubsub.js';
|
|
26
|
+
export type { PubsubRoutingComponents } from './pubsub.js';
|
|
23
27
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/routing/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAA;AAC5D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAA;AAC/D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AACrD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEtD,MAAM,WAAW,UAAW,SAAQ,YAAY,EAAE,eAAe;CAEhE;AAED,MAAM,WAAW,UAAW,SAAQ,YAAY,EAAE,eAAe;IAC/D;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAED,MAAM,WAAW,WAAW;IAC1B,GAAG,CAAC,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC7F,GAAG,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;CACvE;AAED,MAAM,MAAM,iBAAiB,GAC3B,uBAAuB,GACvB,0BAA0B,GAC1B,oBAAoB,CAAA;AAEtB,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/routing/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAA;AAC5D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAA;AAC/D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AACrD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEtD,MAAM,WAAW,UAAW,SAAQ,YAAY,EAAE,eAAe;CAEhE;AAED,MAAM,WAAW,UAAW,SAAQ,YAAY,EAAE,eAAe;IAC/D;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAED,MAAM,WAAW,WAAW;IAC1B,GAAG,CAAC,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC7F,GAAG,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;CACvE;AAED,YAAY,EAAE,uBAAuB,EAAE,CAAA;AACvC,YAAY,EAAE,0BAA0B,EAAE,CAAA;AAC1C,YAAY,EAAE,oBAAoB,EAAE,CAAA;AAEpC,MAAM,MAAM,iBAAiB,GAC3B,uBAAuB,GACvB,0BAA0B,GAC1B,oBAAoB,CAAA;AAEtB,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,YAAY,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/routing/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/routing/index.ts"],"names":[],"mappings":"AAiCA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@helia/ipns",
|
|
3
|
-
"version": "7.2.3-
|
|
3
|
+
"version": "7.2.3-4f14996",
|
|
4
4
|
"description": "An implementation of IPNS for Helia",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/ipfs/helia/tree/main/packages/ipns#readme",
|
|
@@ -152,6 +152,7 @@
|
|
|
152
152
|
"clean": "aegir clean",
|
|
153
153
|
"lint": "aegir lint",
|
|
154
154
|
"dep-check": "aegir dep-check",
|
|
155
|
+
"doc-check": "aegir doc-check",
|
|
155
156
|
"build": "aegir build",
|
|
156
157
|
"docs": "aegir docs",
|
|
157
158
|
"test": "aegir test",
|
|
@@ -164,7 +165,7 @@
|
|
|
164
165
|
"release": "aegir release"
|
|
165
166
|
},
|
|
166
167
|
"dependencies": {
|
|
167
|
-
"@helia/interface": "4.3.1-
|
|
168
|
+
"@helia/interface": "4.3.1-4f14996",
|
|
168
169
|
"@libp2p/interface": "^2.0.0",
|
|
169
170
|
"@libp2p/kad-dht": "^13.0.0",
|
|
170
171
|
"@libp2p/logger": "^5.0.0",
|
package/src/index.ts
CHANGED
|
@@ -11,23 +11,23 @@
|
|
|
11
11
|
* import { createHelia } from 'helia'
|
|
12
12
|
* import { ipns } from '@helia/ipns'
|
|
13
13
|
* import { unixfs } from '@helia/unixfs'
|
|
14
|
+
* import { generateKeyPair } from '@libp2p/crypto/keys'
|
|
14
15
|
*
|
|
15
16
|
* const helia = await createHelia()
|
|
16
17
|
* const name = ipns(helia)
|
|
17
18
|
*
|
|
18
|
-
* // create a
|
|
19
|
-
* const
|
|
20
|
-
* const peerId = await helia.libp2p.services.keychain.exportPeerId(keyInfo.name)
|
|
19
|
+
* // create a keypair to publish an IPNS name
|
|
20
|
+
* const privateKey = await generateKeyPair('Ed25519')
|
|
21
21
|
*
|
|
22
22
|
* // store some data to publish
|
|
23
23
|
* const fs = unixfs(helia)
|
|
24
|
-
* const cid = await fs.
|
|
24
|
+
* const cid = await fs.addBytes(Uint8Array.from([0, 1, 2, 3, 4]))
|
|
25
25
|
*
|
|
26
26
|
* // publish the name
|
|
27
|
-
* await name.publish(
|
|
27
|
+
* await name.publish(privateKey, cid)
|
|
28
28
|
*
|
|
29
29
|
* // resolve the name
|
|
30
|
-
* const result = name.resolve(
|
|
30
|
+
* const result = await name.resolve(privateKey.publicKey)
|
|
31
31
|
*
|
|
32
32
|
* console.info(result.cid, result.path)
|
|
33
33
|
* ```
|
|
@@ -41,30 +41,29 @@
|
|
|
41
41
|
* import { createHelia } from 'helia'
|
|
42
42
|
* import { ipns } from '@helia/ipns'
|
|
43
43
|
* import { unixfs } from '@helia/unixfs'
|
|
44
|
+
* import { generateKeyPair } from '@libp2p/crypto/keys'
|
|
44
45
|
*
|
|
45
46
|
* const helia = await createHelia()
|
|
46
47
|
* const name = ipns(helia)
|
|
47
48
|
*
|
|
48
|
-
* // create a
|
|
49
|
-
* const
|
|
50
|
-
* const peerId = await helia.libp2p.services.keychain.exportPeerId(keyInfo.name)
|
|
49
|
+
* // create a keypair to publish an IPNS name
|
|
50
|
+
* const privateKey = await generateKeyPair('Ed25519')
|
|
51
51
|
*
|
|
52
52
|
* // store some data to publish
|
|
53
53
|
* const fs = unixfs(helia)
|
|
54
|
-
* const cid = await fs.
|
|
54
|
+
* const cid = await fs.addBytes(Uint8Array.from([0, 1, 2, 3, 4]))
|
|
55
55
|
*
|
|
56
56
|
* // publish the name
|
|
57
|
-
* await name.publish(
|
|
57
|
+
* await name.publish(privateKey, cid)
|
|
58
58
|
*
|
|
59
|
-
* // create another
|
|
60
|
-
* const
|
|
61
|
-
* const recursivePeerId = await helia.libp2p.services.keychain.exportPeerId(recursiveKeyInfo.name)
|
|
59
|
+
* // create another keypair to re-publish the original record
|
|
60
|
+
* const recursivePrivateKey = await generateKeyPair('Ed25519')
|
|
62
61
|
*
|
|
63
62
|
* // publish the recursive name
|
|
64
|
-
* await name.publish(
|
|
63
|
+
* await name.publish(recursivePrivateKey, privateKey.publicKey)
|
|
65
64
|
*
|
|
66
65
|
* // resolve the name recursively - it resolves until a CID is found
|
|
67
|
-
* const result = name.resolve(
|
|
66
|
+
* const result = await name.resolve(recursivePrivateKey.publicKey)
|
|
68
67
|
* console.info(result.cid.toString() === cid.toString()) // true
|
|
69
68
|
* ```
|
|
70
69
|
*
|
|
@@ -76,27 +75,27 @@
|
|
|
76
75
|
* import { createHelia } from 'helia'
|
|
77
76
|
* import { ipns } from '@helia/ipns'
|
|
78
77
|
* import { unixfs } from '@helia/unixfs'
|
|
78
|
+
* import { generateKeyPair } from '@libp2p/crypto/keys'
|
|
79
79
|
*
|
|
80
80
|
* const helia = await createHelia()
|
|
81
81
|
* const name = ipns(helia)
|
|
82
82
|
*
|
|
83
|
-
* // create a
|
|
84
|
-
* const
|
|
85
|
-
* const peerId = await helia.libp2p.services.keychain.exportPeerId(keyInfo.name)
|
|
83
|
+
* // create a keypair to publish an IPNS name
|
|
84
|
+
* const privateKey = await generateKeyPair('Ed25519')
|
|
86
85
|
*
|
|
87
86
|
* // store some data to publish
|
|
88
87
|
* const fs = unixfs(helia)
|
|
89
|
-
* const fileCid = await fs.
|
|
88
|
+
* const fileCid = await fs.addBytes(Uint8Array.from([0, 1, 2, 3, 4]))
|
|
90
89
|
*
|
|
91
90
|
* // store the file in a directory
|
|
92
|
-
* const dirCid = await fs.
|
|
91
|
+
* const dirCid = await fs.addDirectory()
|
|
93
92
|
* const finalDirCid = await fs.cp(fileCid, dirCid, '/foo.txt')
|
|
94
93
|
*
|
|
95
94
|
* // publish the name
|
|
96
|
-
* await name.publish(
|
|
95
|
+
* await name.publish(privateKey, `/ipfs/${finalDirCid}/foo.txt`)
|
|
97
96
|
*
|
|
98
97
|
* // resolve the name
|
|
99
|
-
* const result = name.resolve(
|
|
98
|
+
* const result = await name.resolve(privateKey.publicKey)
|
|
100
99
|
*
|
|
101
100
|
* console.info(result.cid, result.path) // QmFoo.. 'foo.txt'
|
|
102
101
|
* ```
|
|
@@ -123,11 +122,14 @@
|
|
|
123
122
|
* import { pubsub } from '@helia/ipns/routing'
|
|
124
123
|
* import { unixfs } from '@helia/unixfs'
|
|
125
124
|
* import { gossipsub } from '@chainsafe/libp2p-gossipsub'
|
|
125
|
+
* import { generateKeyPair } from '@libp2p/crypto/keys'
|
|
126
|
+
* import type { Libp2p, PubSub } from '@libp2p/interface'
|
|
127
|
+
* import type { DefaultLibp2pServices } from 'helia'
|
|
126
128
|
*
|
|
127
129
|
* const libp2pOptions = libp2pDefaults()
|
|
128
130
|
* libp2pOptions.services.pubsub = gossipsub()
|
|
129
131
|
*
|
|
130
|
-
* const helia = await createHelia({
|
|
132
|
+
* const helia = await createHelia<Libp2p<DefaultLibp2pServices & { pubsub: PubSub }>>({
|
|
131
133
|
* libp2p: libp2pOptions
|
|
132
134
|
* })
|
|
133
135
|
* const name = ipns(helia, {
|
|
@@ -136,44 +138,50 @@
|
|
|
136
138
|
* ]
|
|
137
139
|
* })
|
|
138
140
|
*
|
|
139
|
-
* // create a
|
|
140
|
-
* const
|
|
141
|
-
* const peerId = await helia.libp2p.services.keychain.exportPeerId(keyInfo.name)
|
|
141
|
+
* // create a keypair to publish an IPNS name
|
|
142
|
+
* const privateKey = await generateKeyPair('Ed25519')
|
|
142
143
|
*
|
|
143
144
|
* // store some data to publish
|
|
144
145
|
* const fs = unixfs(helia)
|
|
145
|
-
* const cid = await fs.
|
|
146
|
+
* const cid = await fs.addBytes(Uint8Array.from([0, 1, 2, 3, 4]))
|
|
146
147
|
*
|
|
147
148
|
* // publish the name
|
|
148
|
-
* await name.publish(
|
|
149
|
+
* await name.publish(privateKey, cid)
|
|
149
150
|
*
|
|
150
151
|
* // resolve the name
|
|
151
|
-
* const
|
|
152
|
+
* const result = await name.resolve(privateKey.publicKey)
|
|
152
153
|
* ```
|
|
153
154
|
*
|
|
154
155
|
* @example Using custom DNS over HTTPS resolvers
|
|
155
156
|
*
|
|
156
|
-
*
|
|
157
|
+
* To use custom resolvers, configure Helia's `dns` option:
|
|
157
158
|
*
|
|
158
159
|
* ```TypeScript
|
|
159
160
|
* import { createHelia } from 'helia'
|
|
160
161
|
* import { ipns } from '@helia/ipns'
|
|
161
|
-
* import {
|
|
162
|
-
* import { dnsOverHttps } from '@
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
* const
|
|
166
|
-
*
|
|
167
|
-
*
|
|
162
|
+
* import { dns } from '@multiformats/dns'
|
|
163
|
+
* import { dnsOverHttps } from '@multiformats/dns/resolvers'
|
|
164
|
+
* import { helia } from '@helia/ipns/routing'
|
|
165
|
+
*
|
|
166
|
+
* const node = await createHelia({
|
|
167
|
+
* dns: dns({
|
|
168
|
+
* resolvers: {
|
|
169
|
+
* '.': dnsOverHttps('https://private-dns-server.me/dns-query')
|
|
170
|
+
* }
|
|
171
|
+
* })
|
|
172
|
+
* })
|
|
173
|
+
* const name = ipns(node, {
|
|
174
|
+
* routers: [
|
|
175
|
+
* helia(node.routing)
|
|
168
176
|
* ]
|
|
169
177
|
* })
|
|
170
178
|
*
|
|
171
|
-
* const
|
|
179
|
+
* const result = name.resolveDNSLink('some-domain-with-dnslink-entry.com')
|
|
172
180
|
* ```
|
|
173
181
|
*
|
|
174
182
|
* @example Resolving a domain with a dnslink entry
|
|
175
183
|
*
|
|
176
|
-
* Calling `
|
|
184
|
+
* Calling `resolveDNSLink` with the `@helia/ipns` instance:
|
|
177
185
|
*
|
|
178
186
|
* ```TypeScript
|
|
179
187
|
* // resolve a CID from a TXT record in a DNS zone file, using the default
|
|
@@ -185,10 +193,16 @@
|
|
|
185
193
|
* // ;; ANSWER SECTION:
|
|
186
194
|
* // _dnslink.website.ipfs.io. 60 IN TXT "dnslink=/ipfs/QmWebsite"
|
|
187
195
|
*
|
|
188
|
-
*
|
|
196
|
+
* import { createHelia } from 'helia'
|
|
197
|
+
* import { ipns } from '@helia/ipns'
|
|
198
|
+
*
|
|
199
|
+
* const node = await createHelia()
|
|
200
|
+
* const name = ipns(node)
|
|
189
201
|
*
|
|
190
|
-
*
|
|
191
|
-
*
|
|
202
|
+
* const { answer } = await name.resolveDNSLink('ipfs.io')
|
|
203
|
+
*
|
|
204
|
+
* console.info(answer)
|
|
205
|
+
* // { data: '/ipfs/QmWebsite' }
|
|
192
206
|
* ```
|
|
193
207
|
*
|
|
194
208
|
* @example Using DNS-Over-HTTPS
|
|
@@ -200,14 +214,21 @@
|
|
|
200
214
|
* If this is a concern, use the DNS-JSON-Over-HTTPS resolver instead.
|
|
201
215
|
*
|
|
202
216
|
* ```TypeScript
|
|
203
|
-
*
|
|
204
|
-
* import {
|
|
205
|
-
*
|
|
206
|
-
*
|
|
207
|
-
*
|
|
208
|
-
*
|
|
209
|
-
*
|
|
217
|
+
* import { createHelia } from 'helia'
|
|
218
|
+
* import { ipns } from '@helia/ipns'
|
|
219
|
+
* import { dns } from '@multiformats/dns'
|
|
220
|
+
* import { dnsOverHttps } from '@multiformats/dns/resolvers'
|
|
221
|
+
*
|
|
222
|
+
* const node = await createHelia({
|
|
223
|
+
* dns: dns({
|
|
224
|
+
* resolvers: {
|
|
225
|
+
* '.': dnsOverHttps('https://mozilla.cloudflare-dns.com/dns-query')
|
|
226
|
+
* }
|
|
227
|
+
* })
|
|
210
228
|
* })
|
|
229
|
+
* const name = ipns(node)
|
|
230
|
+
*
|
|
231
|
+
* const result = await name.resolveDNSLink('ipfs.io')
|
|
211
232
|
* ```
|
|
212
233
|
*
|
|
213
234
|
* @example Using DNS-JSON-Over-HTTPS
|
|
@@ -216,14 +237,21 @@
|
|
|
216
237
|
* result in a smaller browser bundle due to the response being plain JSON.
|
|
217
238
|
*
|
|
218
239
|
* ```TypeScript
|
|
219
|
-
*
|
|
220
|
-
* import {
|
|
221
|
-
*
|
|
222
|
-
*
|
|
223
|
-
*
|
|
224
|
-
*
|
|
225
|
-
*
|
|
240
|
+
* import { createHelia } from 'helia'
|
|
241
|
+
* import { ipns } from '@helia/ipns'
|
|
242
|
+
* import { dns } from '@multiformats/dns'
|
|
243
|
+
* import { dnsJsonOverHttps } from '@multiformats/dns/resolvers'
|
|
244
|
+
*
|
|
245
|
+
* const node = await createHelia({
|
|
246
|
+
* dns: dns({
|
|
247
|
+
* resolvers: {
|
|
248
|
+
* '.': dnsJsonOverHttps('https://mozilla.cloudflare-dns.com/dns-query')
|
|
249
|
+
* }
|
|
250
|
+
* })
|
|
226
251
|
* })
|
|
252
|
+
* const name = ipns(node)
|
|
253
|
+
*
|
|
254
|
+
* const result = await name.resolveDNSLink('ipfs.io')
|
|
227
255
|
* ```
|
|
228
256
|
*/
|
|
229
257
|
|
package/src/routing/index.ts
CHANGED
|
@@ -22,6 +22,10 @@ export interface IPNSRouting {
|
|
|
22
22
|
get(routingKey: Uint8Array, options?: GetOptions): Promise<Uint8Array>
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
export type { DatastoreProgressEvents }
|
|
26
|
+
export type { HeliaRoutingProgressEvents }
|
|
27
|
+
export type { PubSubProgressEvents }
|
|
28
|
+
|
|
25
29
|
export type IPNSRoutingEvents =
|
|
26
30
|
DatastoreProgressEvents |
|
|
27
31
|
HeliaRoutingProgressEvents |
|
|
@@ -29,3 +33,4 @@ export type IPNSRoutingEvents =
|
|
|
29
33
|
|
|
30
34
|
export { helia } from './helia.js'
|
|
31
35
|
export { pubsub } from './pubsub.js'
|
|
36
|
+
export type { PubsubRoutingComponents } from './pubsub.js'
|