@helia/dnslink 1.0.1 → 1.1.0-eb91b810
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/dist/index.min.js +1 -1
- package/dist/index.min.js.map +4 -4
- package/dist/src/constants.d.ts +3 -0
- package/dist/src/constants.d.ts.map +1 -1
- package/dist/src/constants.js +3 -0
- package/dist/src/constants.js.map +1 -1
- package/dist/src/dnslink.d.ts +8 -6
- package/dist/src/dnslink.d.ts.map +1 -1
- package/dist/src/dnslink.js +47 -2
- package/dist/src/dnslink.js.map +1 -1
- package/dist/src/index.d.ts +33 -12
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/namespaces/ipfs.d.ts +2 -2
- package/dist/src/namespaces/ipfs.d.ts.map +1 -1
- package/dist/src/namespaces/ipfs.js +11 -13
- package/dist/src/namespaces/ipfs.js.map +1 -1
- package/dist/src/namespaces/ipns.d.ts +2 -2
- package/dist/src/namespaces/ipns.d.ts.map +1 -1
- package/dist/src/namespaces/ipns.js +11 -13
- package/dist/src/namespaces/ipns.js.map +1 -1
- package/package.json +4 -2
- package/src/constants.ts +3 -0
- package/src/dnslink.ts +66 -10
- package/src/index.ts +38 -13
- package/src/namespaces/ipfs.ts +12 -14
- package/src/namespaces/ipns.ts +12 -14
- package/dist/typedoc-urls.json +0 -22
package/src/namespaces/ipfs.ts
CHANGED
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
import { CID } from 'multiformats/cid'
|
|
2
2
|
import { InvalidNamespaceError } from '../errors.ts'
|
|
3
|
-
import type {
|
|
3
|
+
import type { DNSLinkParser, DNSLinkIPFSResult } from '../index.js'
|
|
4
4
|
import type { Answer } from '@multiformats/dns'
|
|
5
5
|
|
|
6
|
-
export const ipfs:
|
|
7
|
-
|
|
8
|
-
const [, protocol, cid, ...rest] = value.split('/')
|
|
6
|
+
export const ipfs: DNSLinkParser<DNSLinkIPFSResult> = (value: string, answer: Answer): DNSLinkIPFSResult => {
|
|
7
|
+
const [, protocol, cid, ...rest] = value.split('/')
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
if (protocol !== 'ipfs') {
|
|
10
|
+
throw new InvalidNamespaceError(`Namespace ${protocol} was not "ipfs"`)
|
|
11
|
+
}
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
13
|
+
// if the result is a CID, we've reached the end of the recursion
|
|
14
|
+
return {
|
|
15
|
+
namespace: 'ipfs',
|
|
16
|
+
cid: CID.parse(cid),
|
|
17
|
+
path: rest.length > 0 ? `/${rest.join('/')}` : '',
|
|
18
|
+
answer
|
|
21
19
|
}
|
|
22
20
|
}
|
package/src/namespaces/ipns.ts
CHANGED
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
import { peerIdFromString } from '@libp2p/peer-id'
|
|
2
2
|
import { InvalidNamespaceError } from '../errors.ts'
|
|
3
|
-
import type {
|
|
3
|
+
import type { DNSLinkParser, DNSLinkIPNSResult } from '../index.js'
|
|
4
4
|
import type { Answer } from '@multiformats/dns'
|
|
5
5
|
|
|
6
|
-
export const ipns:
|
|
7
|
-
|
|
8
|
-
const [, protocol, peerId, ...rest] = value.split('/')
|
|
6
|
+
export const ipns: DNSLinkParser<DNSLinkIPNSResult> = (value: string, answer: Answer): DNSLinkIPNSResult => {
|
|
7
|
+
const [, protocol, peerId, ...rest] = value.split('/')
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
if (protocol !== 'ipns') {
|
|
10
|
+
throw new InvalidNamespaceError(`Namespace ${protocol} was not "ipns"`)
|
|
11
|
+
}
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
13
|
+
// if the result is a CID, we've reached the end of the recursion
|
|
14
|
+
return {
|
|
15
|
+
namespace: 'ipns',
|
|
16
|
+
peerId: peerIdFromString(peerId),
|
|
17
|
+
path: rest.length > 0 ? `/${rest.join('/')}` : '',
|
|
18
|
+
answer
|
|
21
19
|
}
|
|
22
20
|
}
|
package/dist/typedoc-urls.json
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"DNSLink": "https://ipfs.github.io/helia/interfaces/_helia_dnslink.DNSLink.html",
|
|
3
|
-
".:DNSLink": "https://ipfs.github.io/helia/interfaces/_helia_dnslink.DNSLink.html",
|
|
4
|
-
"DNSLinkComponents": "https://ipfs.github.io/helia/interfaces/_helia_dnslink.DNSLinkComponents.html",
|
|
5
|
-
".:DNSLinkComponents": "https://ipfs.github.io/helia/interfaces/_helia_dnslink.DNSLinkComponents.html",
|
|
6
|
-
"DNSLinkIPFSResult": "https://ipfs.github.io/helia/interfaces/_helia_dnslink.DNSLinkIPFSResult.html",
|
|
7
|
-
".:DNSLinkIPFSResult": "https://ipfs.github.io/helia/interfaces/_helia_dnslink.DNSLinkIPFSResult.html",
|
|
8
|
-
"DNSLinkIPNSResult": "https://ipfs.github.io/helia/interfaces/_helia_dnslink.DNSLinkIPNSResult.html",
|
|
9
|
-
".:DNSLinkIPNSResult": "https://ipfs.github.io/helia/interfaces/_helia_dnslink.DNSLinkIPNSResult.html",
|
|
10
|
-
"DNSLinkNamespace": "https://ipfs.github.io/helia/interfaces/_helia_dnslink.DNSLinkNamespace.html",
|
|
11
|
-
".:DNSLinkNamespace": "https://ipfs.github.io/helia/interfaces/_helia_dnslink.DNSLinkNamespace.html",
|
|
12
|
-
"DNSLinkOptions": "https://ipfs.github.io/helia/interfaces/_helia_dnslink.DNSLinkOptions.html",
|
|
13
|
-
".:DNSLinkOptions": "https://ipfs.github.io/helia/interfaces/_helia_dnslink.DNSLinkOptions.html",
|
|
14
|
-
"DNSLinkOtherResult": "https://ipfs.github.io/helia/interfaces/_helia_dnslink.DNSLinkOtherResult.html",
|
|
15
|
-
".:DNSLinkOtherResult": "https://ipfs.github.io/helia/interfaces/_helia_dnslink.DNSLinkOtherResult.html",
|
|
16
|
-
"ResolveDNSLinkOptions": "https://ipfs.github.io/helia/interfaces/_helia_dnslink.ResolveDNSLinkOptions.html",
|
|
17
|
-
".:ResolveDNSLinkOptions": "https://ipfs.github.io/helia/interfaces/_helia_dnslink.ResolveDNSLinkOptions.html",
|
|
18
|
-
"DNSLinkResult": "https://ipfs.github.io/helia/types/_helia_dnslink.DNSLinkResult.html",
|
|
19
|
-
".:DNSLinkResult": "https://ipfs.github.io/helia/types/_helia_dnslink.DNSLinkResult.html",
|
|
20
|
-
"dnsLink": "https://ipfs.github.io/helia/functions/_helia_dnslink.dnsLink.html",
|
|
21
|
-
".:dnsLink": "https://ipfs.github.io/helia/functions/_helia_dnslink.dnsLink.html"
|
|
22
|
-
}
|