@helia/routers 4.0.3 → 4.0.4-7676912e
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 +19 -15
- package/dist/index.min.js.map +4 -4
- package/dist/src/delegated-http-routing.d.ts +6 -0
- package/dist/src/delegated-http-routing.d.ts.map +1 -1
- package/dist/src/delegated-http-routing.js +17 -8
- package/dist/src/delegated-http-routing.js.map +1 -1
- package/package.json +4 -3
- package/src/delegated-http-routing.ts +25 -7
- package/dist/typedoc-urls.json +0 -7
|
@@ -3,5 +3,11 @@ import type { Routing } from '@helia/interface';
|
|
|
3
3
|
/**
|
|
4
4
|
* Creates a Helia Router that connects to an endpoint that supports the [Delegated Routing V1 HTTP API](https://specs.ipfs.tech/routing/http-routing-v1/) spec.
|
|
5
5
|
*/
|
|
6
|
+
export declare function delegatedHTTPRouting(init: DelegatedRoutingV1HttpApiClientInit & {
|
|
7
|
+
url: string | URL;
|
|
8
|
+
}): (components: any) => Routing;
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated Use `delegatedHTTPRouting(init)` instead
|
|
11
|
+
*/
|
|
6
12
|
export declare function delegatedHTTPRouting(url: string | URL, init?: DelegatedRoutingV1HttpApiClientInit): Routing;
|
|
7
13
|
//# sourceMappingURL=delegated-http-routing.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delegated-http-routing.d.ts","sourceRoot":"","sources":["../../src/delegated-http-routing.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"delegated-http-routing.d.ts","sourceRoot":"","sources":["../../src/delegated-http-routing.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAA8E,mCAAmC,EAAE,MAAM,6CAA6C,CAAA;AAClL,OAAO,KAAK,EAAY,OAAO,EAAkB,MAAM,kBAAkB,CAAA;AAyFzE;;GAEG;AACH,wBAAgB,oBAAoB,CAAE,IAAI,EAAE,mCAAmC,GAAG;IAAE,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,GAAG,CAAC,UAAU,EAAE,GAAG,KAAK,OAAO,CAAA;AACtI;;GAEG;AACH,wBAAgB,oBAAoB,CAAE,GAAG,EAAE,MAAM,GAAG,GAAG,EAAE,IAAI,CAAC,EAAE,mCAAmC,GAAG,OAAO,CAAA"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { delegatedRoutingV1HttpApiClient } from '@helia/delegated-routing-v1-http-api-client';
|
|
2
2
|
import { NotFoundError } from '@libp2p/interface';
|
|
3
|
+
import { defaultLogger } from '@libp2p/logger';
|
|
3
4
|
import { marshalIPNSRecord, multihashFromIPNSRoutingKey, unmarshalIPNSRecord } from 'ipns';
|
|
4
5
|
import first from 'it-first';
|
|
5
6
|
import map from 'it-map';
|
|
@@ -13,8 +14,8 @@ function isIPNSKey(key) {
|
|
|
13
14
|
}
|
|
14
15
|
class DelegatedHTTPRouter {
|
|
15
16
|
client;
|
|
16
|
-
constructor(
|
|
17
|
-
this.client =
|
|
17
|
+
constructor(components, init) {
|
|
18
|
+
this.client = delegatedRoutingV1HttpApiClient(init)(components);
|
|
18
19
|
}
|
|
19
20
|
async provide(cid, options) {
|
|
20
21
|
// noop
|
|
@@ -74,11 +75,19 @@ class DelegatedHTTPRouter {
|
|
|
74
75
|
// noop
|
|
75
76
|
}
|
|
76
77
|
}
|
|
77
|
-
/**
|
|
78
|
-
* Creates a Helia Router that connects to an endpoint that supports the [Delegated Routing V1 HTTP API](https://specs.ipfs.tech/routing/http-routing-v1/) spec.
|
|
79
|
-
*/
|
|
80
78
|
export function delegatedHTTPRouting(url, init) {
|
|
81
|
-
|
|
82
|
-
|
|
79
|
+
if (typeof url === 'string' || url instanceof URL) {
|
|
80
|
+
return new DelegatedHTTPRouter({
|
|
81
|
+
logger: defaultLogger()
|
|
82
|
+
}, {
|
|
83
|
+
...delegatedHTTPRoutingDefaults(),
|
|
84
|
+
...init,
|
|
85
|
+
url: new URL(url)
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
return (components) => new DelegatedHTTPRouter(components, {
|
|
89
|
+
...delegatedHTTPRoutingDefaults(),
|
|
90
|
+
...url
|
|
91
|
+
});
|
|
83
92
|
}
|
|
84
93
|
//# sourceMappingURL=delegated-http-routing.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delegated-http-routing.js","sourceRoot":"","sources":["../../src/delegated-http-routing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"delegated-http-routing.js","sourceRoot":"","sources":["../../src/delegated-http-routing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,+BAA+B,EAAE,MAAM,6CAA6C,CAAA;AAC7F,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,EAAE,iBAAiB,EAAE,2BAA2B,EAAE,mBAAmB,EAAE,MAAM,MAAM,CAAA;AAC1F,OAAO,KAAK,MAAM,UAAU,CAAA;AAC5B,OAAO,GAAG,MAAM,QAAQ,CAAA;AACxB,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AACtC,OAAO,EAAE,MAAM,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAC/D,OAAO,EAAE,UAAU,IAAI,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAC5E,OAAO,EAAE,4BAA4B,EAAE,MAAM,4CAA4C,CAAA;AAMzF,MAAM,WAAW,GAAG,oBAAoB,CAAC,QAAQ,CAAC,CAAA;AAElD,SAAS,SAAS,CAAE,GAAe;IACjC,OAAO,gBAAgB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,EAAE,WAAW,CAAC,UAAU,CAAC,EAAE,WAAW,CAAC,CAAA;AAC/E,CAAC;AAED,MAAM,mBAAmB;IACN,MAAM,CAAiC;IAExD,YAAa,UAAqD,EAAE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AAI;YACP,GAAG,EAAE,IAAI,GAAG,CAAC,GAAG,CAAC;SAClB,CAAC,CAAA;IACJ,CAAC;IAED,OAAO,CAAC,UAAe,EAAE,EAAE,CAAC,IAAI,mBAAmB,CAAC,UAAU,EAAE;QAC9D,GAAG,4BAA4B,EAAE;QACjC,GAAG,GAAG;KACP,CAAC,CAAA;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@helia/routers",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.4-7676912e",
|
|
4
4
|
"description": "Routers for Helia",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/ipfs/helia/tree/main/packages/routers#readme",
|
|
@@ -47,9 +47,10 @@
|
|
|
47
47
|
"test:electron-main": "aegir test -t electron-main"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@helia/delegated-routing-v1-http-api-client": "^5.
|
|
51
|
-
"@helia/interface": "
|
|
50
|
+
"@helia/delegated-routing-v1-http-api-client": "^5.1.2",
|
|
51
|
+
"@helia/interface": "6.0.2-7676912e",
|
|
52
52
|
"@libp2p/interface": "^3.1.0",
|
|
53
|
+
"@libp2p/logger": "^6.2.0",
|
|
53
54
|
"@libp2p/peer-id": "^6.0.3",
|
|
54
55
|
"@multiformats/uri-to-multiaddr": "^10.0.0",
|
|
55
56
|
"ipns": "^10.1.2",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { delegatedRoutingV1HttpApiClient } from '@helia/delegated-routing-v1-http-api-client'
|
|
2
2
|
import { NotFoundError } from '@libp2p/interface'
|
|
3
|
+
import { defaultLogger } from '@libp2p/logger'
|
|
3
4
|
import { marshalIPNSRecord, multihashFromIPNSRoutingKey, unmarshalIPNSRecord } from 'ipns'
|
|
4
5
|
import first from 'it-first'
|
|
5
6
|
import map from 'it-map'
|
|
@@ -7,7 +8,7 @@ import { CID } from 'multiformats/cid'
|
|
|
7
8
|
import { equals as uint8ArrayEquals } from 'uint8arrays/equals'
|
|
8
9
|
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
|
|
9
10
|
import { delegatedHTTPRoutingDefaults } from './utils/delegated-http-routing-defaults.js'
|
|
10
|
-
import type { DelegatedRoutingV1HttpApiClient, DelegatedRoutingV1HttpApiClientInit } from '@helia/delegated-routing-v1-http-api-client'
|
|
11
|
+
import type { DelegatedRoutingV1HttpApiClient, DelegatedRoutingV1HttpApiClientComponents, DelegatedRoutingV1HttpApiClientInit } from '@helia/delegated-routing-v1-http-api-client'
|
|
11
12
|
import type { Provider, Routing, RoutingOptions } from '@helia/interface'
|
|
12
13
|
import type { PeerId, PeerInfo } from '@libp2p/interface'
|
|
13
14
|
import type { Version } from 'multiformats'
|
|
@@ -21,8 +22,8 @@ function isIPNSKey (key: Uint8Array): boolean {
|
|
|
21
22
|
class DelegatedHTTPRouter implements Routing {
|
|
22
23
|
private readonly client: DelegatedRoutingV1HttpApiClient
|
|
23
24
|
|
|
24
|
-
constructor (
|
|
25
|
-
this.client =
|
|
25
|
+
constructor (components: DelegatedRoutingV1HttpApiClientComponents, init: DelegatedRoutingV1HttpApiClientInit & { url: string | URL }) {
|
|
26
|
+
this.client = delegatedRoutingV1HttpApiClient(init)(components)
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
async provide (cid: CID, options?: RoutingOptions): Promise<void> {
|
|
@@ -100,7 +101,24 @@ class DelegatedHTTPRouter implements Routing {
|
|
|
100
101
|
/**
|
|
101
102
|
* Creates a Helia Router that connects to an endpoint that supports the [Delegated Routing V1 HTTP API](https://specs.ipfs.tech/routing/http-routing-v1/) spec.
|
|
102
103
|
*/
|
|
103
|
-
export function delegatedHTTPRouting (url: string | URL
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
export function delegatedHTTPRouting (init: DelegatedRoutingV1HttpApiClientInit & { url: string | URL }): (components: any) => Routing
|
|
105
|
+
/**
|
|
106
|
+
* @deprecated Use `delegatedHTTPRouting(init)` instead
|
|
107
|
+
*/
|
|
108
|
+
export function delegatedHTTPRouting (url: string | URL, init?: DelegatedRoutingV1HttpApiClientInit): Routing
|
|
109
|
+
export function delegatedHTTPRouting (url: string | URL | (DelegatedRoutingV1HttpApiClientInit & { url: string | URL }), init?: DelegatedRoutingV1HttpApiClientInit): Routing | ((components: any) => Routing) {
|
|
110
|
+
if (typeof url === 'string' || url instanceof URL) {
|
|
111
|
+
return new DelegatedHTTPRouter({
|
|
112
|
+
logger: defaultLogger()
|
|
113
|
+
}, {
|
|
114
|
+
...delegatedHTTPRoutingDefaults(),
|
|
115
|
+
...init,
|
|
116
|
+
url: new URL(url)
|
|
117
|
+
})
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return (components: any) => new DelegatedHTTPRouter(components, {
|
|
121
|
+
...delegatedHTTPRoutingDefaults(),
|
|
122
|
+
...url
|
|
123
|
+
})
|
|
106
124
|
}
|
package/dist/typedoc-urls.json
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"HTTPGatewayRouterInit": "https://ipfs.github.io/helia/interfaces/_helia_routers.HTTPGatewayRouterInit.html",
|
|
3
|
-
"delegatedHTTPRouting": "https://ipfs.github.io/helia/functions/_helia_routers.delegatedHTTPRouting.html",
|
|
4
|
-
"delegatedHTTPRoutingDefaults": "https://ipfs.github.io/helia/functions/_helia_routers.delegatedHTTPRoutingDefaults.html",
|
|
5
|
-
"httpGatewayRouting": "https://ipfs.github.io/helia/functions/_helia_routers.httpGatewayRouting.html",
|
|
6
|
-
"libp2pRouting": "https://ipfs.github.io/helia/functions/_helia_routers.libp2pRouting.html"
|
|
7
|
-
}
|