@helia/ipns v7.2.2
@helia/ipns
An implementation of IPNS for Helia
About
IPNS operations using a Helia node
Example - Using libp2p and pubsub routers
With IPNSRouting routers:
import { createHelia } from 'helia'
import { ipns } from '@helia/ipns'
import { libp2p, pubsub } from '@helia/ipns/routing'
import { unixfs } from '@helia/unixfs'
const helia = await createHelia()
const name = ipns(helia, {
routers: [
libp2p(helia),
pubsub(helia)
]
})
// create a public key to publish as an IPNS name
const keyInfo = await helia.libp2p.services.keychain.createKey('my-key')
const peerId = await helia.libp2p.services.keychain.exportPeerId(keyInfo.name)
// store some data to publish
const fs = unixfs(helia)
const cid = await fs.add(Uint8Array.from([0, 1, 2, 3, 4]))
// publish the name
await name.publish(peerId, cid)
// resolve the name
const cid = name.resolve(peerId)
Example - Using custom DNS over HTTPS resolvers
With default DNSResolver resolvers:
import { createHelia } from 'helia'
import { ipns } from '@helia/ipns'
import { unixfs } from '@helia/unixfs'
import { dnsOverHttps } from '@helia/ipns/dns-resolvers'
const helia = await createHelia()
const name = ipns(helia, {
resolvers: [
dnsOverHttps('https://private-dns-server.me/dns-query'),
]
})
const cid = name.resolveDns('some-domain-with-dnslink-entry.com')
Example - Resolving a domain with a dnslink entry
Calling resolveDns
with the @helia/ipns
instance:
// resolve a CID from a TXT record in a DNS zone file, using the default
// resolver for the current platform eg:
// > dig _dnslink.ipfs.io TXT
// ;; ANSWER SECTION:
// _dnslink.ipfs.io. 60 IN TXT "dnslink=/ipns/website.ipfs.io"
// > dig _dnslink.website.ipfs.io TXT
// ;; ANSWER SECTION:
// _dnslink.website.ipfs.io. 60 IN TXT "dnslink=/ipfs/QmWebsite"
const cid = name.resolveDns('ipfs.io')
console.info(cid)
// QmWebsite
Example - Using DNS-Over-HTTPS
This example uses the Mozilla provided RFC 1035 DNS over HTTPS service. This uses binary DNS records so requires extra dependencies to process the response which can increase browser bundle sizes.
If this is a concern, use the DNS-JSON-Over-HTTPS resolver instead.
// use DNS-Over-HTTPS
import { dnsOverHttps } from '@helia/ipns/dns-resolvers'
const cid = name.resolveDns('ipfs.io', {
resolvers: [
dnsOverHttps('https://mozilla.cloudflare-dns.com/dns-query')
]
})
Example - Using DNS-JSON-Over-HTTPS
DNS-JSON-Over-HTTPS resolvers use the RFC 8427 application/dns-json
and can
result in a smaller browser bundle due to the response being plain JSON.
// use DNS-JSON-Over-HTTPS
import { dnsJsonOverHttps } from '@helia/ipns/dns-resolvers'
const cid = name.resolveDns('ipfs.io', {
resolvers: [
dnsJsonOverHttps('https://mozilla.cloudflare-dns.com/dns-query')
]
})
Install
$ npm i @helia/ipns
Browser <script>
tag
Loading this module through a script tag will make it's exports available as HeliaIpns
in the global namespace.
<script src="https://unpkg.com/@helia/ipns/dist/index.min.js"></script>
API Docs
License
Licensed under either of
- Apache 2.0, (LICENSE-APACHE / http://www.apache.org/licenses/LICENSE-2.0)
- MIT (LICENSE-MIT / http://opensource.org/licenses/MIT)
Contribute
Contributions welcome! Please check out the issues.
Also see our contributing document for more information on how we work, and about contributing in general.
Please be aware that all interactions related to this repo are subject to the IPFS Code of Conduct.
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.
2 days ago
2 days ago
4 days ago
4 days ago
4 days ago
5 days ago
5 days ago
9 days ago
9 days ago
10 days ago
11 days ago
11 days ago
12 days ago
12 days ago
13 days ago
12 days ago
12 days ago
13 days ago
13 days ago
14 days ago
14 days ago
20 days ago
20 days ago
20 days ago
20 days ago
26 days ago
25 days ago
26 days ago
26 days ago
26 days ago
26 days ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
5 months ago
5 months ago
8 months ago
8 months ago
8 months ago
8 months ago
6 months ago
6 months ago
7 months ago
8 months ago
1 year ago
12 months ago
12 months ago
1 year ago
1 year ago
1 year ago
1 year ago