@helia/ipns 4.0.0 → 5.0.0-e554493
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 +51 -7
- package/dist/index.min.js +73 -26
- package/dist/src/index.d.ts +51 -5
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +75 -6
- 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/package.json +13 -14
- package/src/index.ts +80 -7
- package/src/routing/helia.ts +45 -0
- package/src/routing/index.ts +9 -4
- package/dist/src/routing/libp2p.d.ts +0 -22
- package/dist/src/routing/libp2p.d.ts.map +0 -1
- package/dist/src/routing/libp2p.js +0 -32
- package/dist/src/routing/libp2p.js.map +0 -1
- package/dist/typedoc-urls.json +0 -42
- package/src/routing/libp2p.ts +0 -47
package/src/routing/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { HeliaRoutingProgressEvents } from './helia.js'
|
|
2
2
|
import type { DatastoreProgressEvents } from './local-store.js'
|
|
3
3
|
import type { PubSubProgressEvents } from './pubsub.js'
|
|
4
4
|
import type { AbortOptions } from '@libp2p/interface'
|
|
@@ -9,7 +9,12 @@ export interface PutOptions extends AbortOptions, ProgressOptions {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export interface GetOptions extends AbortOptions, ProgressOptions {
|
|
12
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Pass false to not perform validation actions
|
|
14
|
+
*
|
|
15
|
+
* @default true
|
|
16
|
+
*/
|
|
17
|
+
validate?: boolean
|
|
13
18
|
}
|
|
14
19
|
|
|
15
20
|
export interface IPNSRouting {
|
|
@@ -19,8 +24,8 @@ export interface IPNSRouting {
|
|
|
19
24
|
|
|
20
25
|
export type IPNSRoutingEvents =
|
|
21
26
|
DatastoreProgressEvents |
|
|
22
|
-
|
|
27
|
+
HeliaRoutingProgressEvents |
|
|
23
28
|
PubSubProgressEvents
|
|
24
29
|
|
|
25
|
-
export {
|
|
30
|
+
export { helia } from './helia.js'
|
|
26
31
|
export { pubsub } from './pubsub.js'
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { type ProgressEvent } from 'progress-events';
|
|
2
|
-
import type { GetOptions, PutOptions } from './index.js';
|
|
3
|
-
import type { IPNSRouting } from '../index.js';
|
|
4
|
-
import type { ContentRouting } from '@libp2p/interface';
|
|
5
|
-
export interface Libp2pContentRoutingComponents {
|
|
6
|
-
libp2p: {
|
|
7
|
-
contentRouting: ContentRouting;
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
export type Libp2pContentRoutingProgressEvents = ProgressEvent<'ipns:routing:libp2p:error', Error>;
|
|
11
|
-
export declare class Libp2pContentRouting implements IPNSRouting {
|
|
12
|
-
private readonly contentRouting;
|
|
13
|
-
constructor(components: Libp2pContentRoutingComponents);
|
|
14
|
-
put(routingKey: Uint8Array, marshaledRecord: Uint8Array, options?: PutOptions): Promise<void>;
|
|
15
|
-
get(routingKey: Uint8Array, options?: GetOptions): Promise<Uint8Array>;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* The libp2p routing uses any available Content Routers configured on the
|
|
19
|
-
* passed libp2p node. This could be KadDHT, HTTP API Delegated Routing, etc.
|
|
20
|
-
*/
|
|
21
|
-
export declare function libp2p(components: Libp2pContentRoutingComponents): IPNSRouting;
|
|
22
|
-
//# sourceMappingURL=libp2p.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"libp2p.d.ts","sourceRoot":"","sources":["../../../src/routing/libp2p.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAA;AACzE,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAEvD,MAAM,WAAW,8BAA8B;IAC7C,MAAM,EAAE;QACN,cAAc,EAAE,cAAc,CAAA;KAC/B,CAAA;CACF;AAED,MAAM,MAAM,kCAAkC,GAC5C,aAAa,CAAC,2BAA2B,EAAE,KAAK,CAAC,CAAA;AAEnD,qBAAa,oBAAqB,YAAW,WAAW;IACtD,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAgB;gBAElC,UAAU,EAAE,8BAA8B;IAIjD,GAAG,CAAE,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,UAAU,EAAE,OAAO,GAAE,UAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAQlG,GAAG,CAAE,UAAU,EAAE,UAAU,EAAE,OAAO,GAAE,UAAe,GAAG,OAAO,CAAC,UAAU,CAAC;CASlF;AAED;;;GAGG;AACH,wBAAgB,MAAM,CAAE,UAAU,EAAE,8BAA8B,GAAG,WAAW,CAE/E"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { CustomProgressEvent } from 'progress-events';
|
|
2
|
-
export class Libp2pContentRouting {
|
|
3
|
-
contentRouting;
|
|
4
|
-
constructor(components) {
|
|
5
|
-
this.contentRouting = components.libp2p.contentRouting;
|
|
6
|
-
}
|
|
7
|
-
async put(routingKey, marshaledRecord, options = {}) {
|
|
8
|
-
try {
|
|
9
|
-
await this.contentRouting.put(routingKey, marshaledRecord, options);
|
|
10
|
-
}
|
|
11
|
-
catch (err) {
|
|
12
|
-
options.onProgress?.(new CustomProgressEvent('ipns:routing:libp2p:error', err));
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
async get(routingKey, options = {}) {
|
|
16
|
-
try {
|
|
17
|
-
return await this.contentRouting.get(routingKey, options);
|
|
18
|
-
}
|
|
19
|
-
catch (err) {
|
|
20
|
-
options.onProgress?.(new CustomProgressEvent('ipns:routing:libp2p:error', err));
|
|
21
|
-
}
|
|
22
|
-
throw new Error('Not found');
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* The libp2p routing uses any available Content Routers configured on the
|
|
27
|
-
* passed libp2p node. This could be KadDHT, HTTP API Delegated Routing, etc.
|
|
28
|
-
*/
|
|
29
|
-
export function libp2p(components) {
|
|
30
|
-
return new Libp2pContentRouting(components);
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=libp2p.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"libp2p.js","sourceRoot":"","sources":["../../../src/routing/libp2p.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAsB,MAAM,iBAAiB,CAAA;AAczE,MAAM,OAAO,oBAAoB;IACd,cAAc,CAAgB;IAE/C,YAAa,UAA0C;QACrD,IAAI,CAAC,cAAc,GAAG,UAAU,CAAC,MAAM,CAAC,cAAc,CAAA;IACxD,CAAC;IAED,KAAK,CAAC,GAAG,CAAE,UAAsB,EAAE,eAA2B,EAAE,UAAsB,EAAE;QACtF,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,UAAU,EAAE,eAAe,EAAE,OAAO,CAAC,CAAA;QACrE,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,OAAO,CAAC,UAAU,EAAE,CAAC,IAAI,mBAAmB,CAAQ,2BAA2B,EAAE,GAAG,CAAC,CAAC,CAAA;QACxF,CAAC;IACH,CAAC;IAED,KAAK,CAAC,GAAG,CAAE,UAAsB,EAAE,UAAsB,EAAE;QACzD,IAAI,CAAC;YACH,OAAO,MAAM,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,UAAU,EAAE,OAAO,CAAC,CAAA;QAC3D,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,OAAO,CAAC,UAAU,EAAE,CAAC,IAAI,mBAAmB,CAAQ,2BAA2B,EAAE,GAAG,CAAC,CAAC,CAAA;QACxF,CAAC;QAED,MAAM,IAAI,KAAK,CAAC,WAAW,CAAC,CAAA;IAC9B,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,UAAU,MAAM,CAAE,UAA0C;IAChE,OAAO,IAAI,oBAAoB,CAAC,UAAU,CAAC,CAAA;AAC7C,CAAC"}
|
package/dist/typedoc-urls.json
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"dnsJsonOverHttps": "https://ipfs.github.io/helia-ipns/functions/dns_resolvers.dnsJsonOverHttps.html",
|
|
3
|
-
"dnsOverHttps": "https://ipfs.github.io/helia-ipns/functions/dns_resolvers.dnsOverHttps.html",
|
|
4
|
-
"DNSResolver": "https://ipfs.github.io/helia-ipns/interfaces/index.DNSResolver.html",
|
|
5
|
-
".:DNSResolver": "https://ipfs.github.io/helia-ipns/interfaces/index.DNSResolver.html",
|
|
6
|
-
"IPNS": "https://ipfs.github.io/helia-ipns/interfaces/index.IPNS.html",
|
|
7
|
-
".:IPNS": "https://ipfs.github.io/helia-ipns/interfaces/index.IPNS.html",
|
|
8
|
-
"IPNSComponents": "https://ipfs.github.io/helia-ipns/interfaces/index.IPNSComponents.html",
|
|
9
|
-
".:IPNSComponents": "https://ipfs.github.io/helia-ipns/interfaces/index.IPNSComponents.html",
|
|
10
|
-
"IPNSOptions": "https://ipfs.github.io/helia-ipns/interfaces/index.IPNSOptions.html",
|
|
11
|
-
".:IPNSOptions": "https://ipfs.github.io/helia-ipns/interfaces/index.IPNSOptions.html",
|
|
12
|
-
"PublishOptions": "https://ipfs.github.io/helia-ipns/interfaces/index.PublishOptions.html",
|
|
13
|
-
".:PublishOptions": "https://ipfs.github.io/helia-ipns/interfaces/index.PublishOptions.html",
|
|
14
|
-
"RepublishOptions": "https://ipfs.github.io/helia-ipns/interfaces/index.RepublishOptions.html",
|
|
15
|
-
".:RepublishOptions": "https://ipfs.github.io/helia-ipns/interfaces/index.RepublishOptions.html",
|
|
16
|
-
"ResolveDNSOptions": "https://ipfs.github.io/helia-ipns/interfaces/index.ResolveDNSOptions.html",
|
|
17
|
-
".:ResolveDNSOptions": "https://ipfs.github.io/helia-ipns/interfaces/index.ResolveDNSOptions.html",
|
|
18
|
-
"ResolveDnsLinkOptions": "https://ipfs.github.io/helia-ipns/interfaces/index.ResolveDnsLinkOptions.html",
|
|
19
|
-
".:ResolveDnsLinkOptions": "https://ipfs.github.io/helia-ipns/interfaces/index.ResolveDnsLinkOptions.html",
|
|
20
|
-
"ResolveOptions": "https://ipfs.github.io/helia-ipns/interfaces/index.ResolveOptions.html",
|
|
21
|
-
".:ResolveOptions": "https://ipfs.github.io/helia-ipns/interfaces/index.ResolveOptions.html",
|
|
22
|
-
"PublishProgressEvents": "https://ipfs.github.io/helia-ipns/types/index.PublishProgressEvents.html",
|
|
23
|
-
".:PublishProgressEvents": "https://ipfs.github.io/helia-ipns/types/index.PublishProgressEvents.html",
|
|
24
|
-
"RepublishProgressEvents": "https://ipfs.github.io/helia-ipns/types/index.RepublishProgressEvents.html",
|
|
25
|
-
".:RepublishProgressEvents": "https://ipfs.github.io/helia-ipns/types/index.RepublishProgressEvents.html",
|
|
26
|
-
"ResolveDnsLinkProgressEvents": "https://ipfs.github.io/helia-ipns/types/index.ResolveDnsLinkProgressEvents.html",
|
|
27
|
-
".:ResolveDnsLinkProgressEvents": "https://ipfs.github.io/helia-ipns/types/index.ResolveDnsLinkProgressEvents.html",
|
|
28
|
-
"ResolveProgressEvents": "https://ipfs.github.io/helia-ipns/types/index.ResolveProgressEvents.html",
|
|
29
|
-
".:ResolveProgressEvents": "https://ipfs.github.io/helia-ipns/types/index.ResolveProgressEvents.html",
|
|
30
|
-
"ipns": "https://ipfs.github.io/helia-ipns/functions/index.ipns-1.html",
|
|
31
|
-
".:ipns": "https://ipfs.github.io/helia-ipns/functions/index.ipns-1.html",
|
|
32
|
-
"GetOptions": "https://ipfs.github.io/helia-ipns/interfaces/routing.GetOptions.html",
|
|
33
|
-
"./routing:GetOptions": "https://ipfs.github.io/helia-ipns/interfaces/routing.GetOptions.html",
|
|
34
|
-
"IPNSRouting": "https://ipfs.github.io/helia-ipns/interfaces/routing.IPNSRouting.html",
|
|
35
|
-
"./routing:IPNSRouting": "https://ipfs.github.io/helia-ipns/interfaces/routing.IPNSRouting.html",
|
|
36
|
-
"PutOptions": "https://ipfs.github.io/helia-ipns/interfaces/routing.PutOptions.html",
|
|
37
|
-
"./routing:PutOptions": "https://ipfs.github.io/helia-ipns/interfaces/routing.PutOptions.html",
|
|
38
|
-
"IPNSRoutingEvents": "https://ipfs.github.io/helia-ipns/types/routing.IPNSRoutingEvents.html",
|
|
39
|
-
"./routing:IPNSRoutingEvents": "https://ipfs.github.io/helia-ipns/types/routing.IPNSRoutingEvents.html",
|
|
40
|
-
"libp2p": "https://ipfs.github.io/helia-ipns/functions/routing.libp2p.html",
|
|
41
|
-
"pubsub": "https://ipfs.github.io/helia-ipns/functions/routing.pubsub.html"
|
|
42
|
-
}
|
package/src/routing/libp2p.ts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { CustomProgressEvent, type ProgressEvent } from 'progress-events'
|
|
2
|
-
import type { GetOptions, PutOptions } from './index.js'
|
|
3
|
-
import type { IPNSRouting } from '../index.js'
|
|
4
|
-
import type { ContentRouting } from '@libp2p/interface'
|
|
5
|
-
|
|
6
|
-
export interface Libp2pContentRoutingComponents {
|
|
7
|
-
libp2p: {
|
|
8
|
-
contentRouting: ContentRouting
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export type Libp2pContentRoutingProgressEvents =
|
|
13
|
-
ProgressEvent<'ipns:routing:libp2p:error', Error>
|
|
14
|
-
|
|
15
|
-
export class Libp2pContentRouting implements IPNSRouting {
|
|
16
|
-
private readonly contentRouting: ContentRouting
|
|
17
|
-
|
|
18
|
-
constructor (components: Libp2pContentRoutingComponents) {
|
|
19
|
-
this.contentRouting = components.libp2p.contentRouting
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
async put (routingKey: Uint8Array, marshaledRecord: Uint8Array, options: PutOptions = {}): Promise<void> {
|
|
23
|
-
try {
|
|
24
|
-
await this.contentRouting.put(routingKey, marshaledRecord, options)
|
|
25
|
-
} catch (err: any) {
|
|
26
|
-
options.onProgress?.(new CustomProgressEvent<Error>('ipns:routing:libp2p:error', err))
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
async get (routingKey: Uint8Array, options: GetOptions = {}): Promise<Uint8Array> {
|
|
31
|
-
try {
|
|
32
|
-
return await this.contentRouting.get(routingKey, options)
|
|
33
|
-
} catch (err: any) {
|
|
34
|
-
options.onProgress?.(new CustomProgressEvent<Error>('ipns:routing:libp2p:error', err))
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
throw new Error('Not found')
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* The libp2p routing uses any available Content Routers configured on the
|
|
43
|
-
* passed libp2p node. This could be KadDHT, HTTP API Delegated Routing, etc.
|
|
44
|
-
*/
|
|
45
|
-
export function libp2p (components: Libp2pContentRoutingComponents): IPNSRouting {
|
|
46
|
-
return new Libp2pContentRouting(components)
|
|
47
|
-
}
|