Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

Commit

Permalink
chore: update sibling dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
aegir[bot] committed Dec 5, 2023
1 parent ce35431 commit d0d84f0
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/interop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"@chainsafe/libp2p-noise": "^13.0.0",
"@chainsafe/libp2p-yamux": "^5.0.0",
"@helia/interface": "^2.0.0",
"@helia/ipns": "^2.0.0",
"@helia/ipns": "^3.0.0",
"@libp2p/interface": "^0.1.2",
"@libp2p/kad-dht": "^10.0.4",
"@libp2p/peer-id": "^3.0.2",
Expand Down
110 changes: 110 additions & 0 deletions packages/ipns/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,116 @@

> An implementation of IPNS for Helia
# About

IPNS operations using a Helia node

## Example

With IPNSRouting routers:

```typescript
import { createHelia } from 'helia'
import { dht, pubsub } from '@helia/ipns/routing'
import { unixfs } from '@helia/unixfs'

const helia = await createHelia()
const name = ipns(helia, {
routers: [
dht(helia),
pubsub(helia)
]
})

// create a public key to publish as an IPNS name
const keyInfo = await helia.libp2p.keychain.createKey('my-key')
const peerId = await helia.libp2p.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

With default DNSResolver resolvers:

```typescript
import { createHelia } from 'helia'
import { dht, pubsub } from '@helia/ipns/routing'
import { unixfs } from '@helia/unixfs'

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

Calling `resolveDns` with the `@helia/ipns` instance:

```typescript
// 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

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.

```typescript
// 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

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.

```typescript
// 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')
]
})
```

## Table of contents <!-- omit in toc -->

- [Install](#install)
Expand Down

0 comments on commit d0d84f0

Please sign in to comment.