@helia/ipns 4.0.0-ece384a → 4.0.0-f2853f8
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 +41 -3
- package/dist/index.min.js +4 -4
- package/dist/src/index.d.ts +44 -4
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +69 -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 +8 -9
- package/src/index.ts +73 -6
- 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/src/routing/libp2p.ts +0 -47
|
@@ -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/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
|
-
}
|