@pkcprotocol/pkc-js 0.0.50 → 0.0.52
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 +1 -1
- package/dist/browser/generated-version.d.ts +1 -1
- package/dist/browser/generated-version.js +1 -1
- package/dist/browser/pkc/pkc.d.ts +2 -3
- package/dist/browser/pkc/pkc.js +16 -41
- package/dist/browser/pkc/pkc.js.map +1 -1
- package/dist/browser/runtime/browser/setup-kubo-address-rewriter-and-http-router.d.ts +1 -0
- package/dist/browser/runtime/browser/setup-kubo-address-rewriter-and-http-router.js +4 -0
- package/dist/browser/runtime/browser/setup-kubo-address-rewriter-and-http-router.js.map +1 -0
- package/dist/browser/runtime/node/address-rewriter-db.d.ts +32 -0
- package/dist/browser/runtime/node/address-rewriter-db.js +156 -0
- package/dist/browser/runtime/node/address-rewriter-db.js.map +1 -0
- package/dist/browser/runtime/node/addresses-rewriter-proxy-server.d.ts +46 -0
- package/dist/browser/runtime/node/addresses-rewriter-proxy-server.js +512 -0
- package/dist/browser/runtime/node/addresses-rewriter-proxy-server.js.map +1 -0
- package/dist/browser/runtime/node/community/local-community/cleanup.js +21 -0
- package/dist/browser/runtime/node/community/local-community/cleanup.js.map +1 -1
- package/dist/browser/runtime/node/setup-kubo-address-rewriter-and-http-router.d.ts +4 -0
- package/dist/browser/runtime/node/setup-kubo-address-rewriter-and-http-router.js +249 -0
- package/dist/browser/runtime/node/setup-kubo-address-rewriter-and-http-router.js.map +1 -0
- package/dist/browser/schema.js +3 -1
- package/dist/browser/schema.js.map +1 -1
- package/dist/bundled/bundle-manifest.json +49 -32
- package/dist/bundled/chunks/{helia-for-pkc-CoiCnGzf.js → helia-for-pkc-BOtcXXpQ.js} +2 -2
- package/dist/bundled/chunks/{local-community-PMOePYFy.js → local-community-04QX5cq0.js} +11 -2
- package/dist/bundled/chunks/{local-community-DiTjNeA_.js → local-community-o0hMcCA2.js} +1 -1
- package/dist/bundled/chunks/{node-2IRJmtOa.js → node-BxNfBS8t.js} +2799 -360
- package/dist/bundled/chunks/{rpc-local-community-DUD2jTEu.js → rpc-local-community-CNzfRWd9.js} +1 -1
- package/dist/bundled/chunks/{schema-DEqa38Xx.js → schema-TpjAJ8NM.js} +4 -2
- package/dist/bundled/chunks/{util-CcKyKVLs.js → util-CuHylCUx.js} +1 -1
- package/dist/bundled/index.js +1 -1
- package/dist/bundled/rpc/src/index.js +4 -4
- package/dist/node/generated-version.d.ts +1 -1
- package/dist/node/generated-version.js +1 -1
- package/dist/node/pkc/pkc.d.ts +2 -3
- package/dist/node/pkc/pkc.js +16 -41
- package/dist/node/pkc/pkc.js.map +1 -1
- package/dist/node/runtime/browser/setup-kubo-address-rewriter-and-http-router.d.ts +1 -0
- package/dist/node/runtime/browser/setup-kubo-address-rewriter-and-http-router.js +4 -0
- package/dist/node/runtime/browser/setup-kubo-address-rewriter-and-http-router.js.map +1 -0
- package/dist/node/runtime/node/address-rewriter-db.d.ts +32 -0
- package/dist/node/runtime/node/address-rewriter-db.js +156 -0
- package/dist/node/runtime/node/address-rewriter-db.js.map +1 -0
- package/dist/node/runtime/node/addresses-rewriter-proxy-server.d.ts +46 -0
- package/dist/node/runtime/node/addresses-rewriter-proxy-server.js +512 -0
- package/dist/node/runtime/node/addresses-rewriter-proxy-server.js.map +1 -0
- package/dist/node/runtime/node/community/local-community/cleanup.js +21 -0
- package/dist/node/runtime/node/community/local-community/cleanup.js.map +1 -1
- package/dist/node/runtime/node/setup-kubo-address-rewriter-and-http-router.d.ts +4 -0
- package/dist/node/runtime/node/setup-kubo-address-rewriter-and-http-router.js +249 -0
- package/dist/node/runtime/node/setup-kubo-address-rewriter-and-http-router.js.map +1 -0
- package/dist/node/schema.js +3 -1
- package/dist/node/schema.js.map +1 -1
- package/package.json +2 -2
- package/dist/browser/runtime/browser/setup-kubo-http-routers.d.ts +0 -2
- package/dist/browser/runtime/browser/setup-kubo-http-routers.js +0 -14
- package/dist/browser/runtime/browser/setup-kubo-http-routers.js.map +0 -1
- package/dist/browser/runtime/node/setup-kubo-http-routers.d.ts +0 -10
- package/dist/browser/runtime/node/setup-kubo-http-routers.js +0 -347
- package/dist/browser/runtime/node/setup-kubo-http-routers.js.map +0 -1
- package/dist/node/runtime/browser/setup-kubo-http-routers.d.ts +0 -2
- package/dist/node/runtime/browser/setup-kubo-http-routers.js +0 -14
- package/dist/node/runtime/browser/setup-kubo-http-routers.js.map +0 -1
- package/dist/node/runtime/node/setup-kubo-http-routers.d.ts +0 -10
- package/dist/node/runtime/node/setup-kubo-http-routers.js +0 -347
- package/dist/node/runtime/node/setup-kubo-http-routers.js.map +0 -1
|
@@ -1,347 +0,0 @@
|
|
|
1
|
-
import retry from "retry";
|
|
2
|
-
import Logger from "../../logger.js";
|
|
3
|
-
import { PKCError } from "../../pkc-error.js";
|
|
4
|
-
import * as remeda from "remeda";
|
|
5
|
-
// fetch() resolves even on HTTP 4xx/5xx — it only rejects on a network failure — so a kubo RPC
|
|
6
|
-
// error response would otherwise be treated as success and skip our retries. POST to the kubo
|
|
7
|
-
// RPC and throw on a non-2xx status (reading the body for kubo's own error message). Each caller
|
|
8
|
-
// wraps the throw into its specific PKCError. Shared by every kubo RPC POST in this file.
|
|
9
|
-
async function _postToKuboRpc(kuboClient, url) {
|
|
10
|
-
const res = await fetch(url, { method: "POST", headers: kuboClient._clientOptions.headers });
|
|
11
|
-
if (!res.ok) {
|
|
12
|
-
const body = await res.text().catch(() => "");
|
|
13
|
-
throw Error(`kubo RPC responded with non-2xx status ${res.status} ${res.statusText}${body ? `: ${body}` : ""}`);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
function _mergeRouterConfigs(existingConfig, newConfig) {
|
|
17
|
-
if (!existingConfig?.Routers)
|
|
18
|
-
return newConfig;
|
|
19
|
-
const existingRoutersByEndpoint = new Map();
|
|
20
|
-
Object.entries(existingConfig.Routers).forEach(([routerName, router]) => {
|
|
21
|
-
if (router.Parameters?.Endpoint) {
|
|
22
|
-
existingRoutersByEndpoint.set(router.Parameters.Endpoint, { routerName, router });
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
const mergedRouters = { ...newConfig.Routers };
|
|
26
|
-
Object.entries(newConfig.Routers).forEach(([newRouterName, newRouter]) => {
|
|
27
|
-
if (newRouter.Parameters?.Endpoint) {
|
|
28
|
-
const existing = existingRoutersByEndpoint.get(newRouter.Parameters.Endpoint);
|
|
29
|
-
if (existing) {
|
|
30
|
-
mergedRouters[newRouterName] = {
|
|
31
|
-
...existing.router,
|
|
32
|
-
...newRouter,
|
|
33
|
-
Parameters: { ...existing.router.Parameters, ...newRouter.Parameters }
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
return {
|
|
39
|
-
...newConfig,
|
|
40
|
-
Routers: mergedRouters
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
async function _setProvideDhtSweepEnabledOnKuboNode(kuboClient, sweepEnabled) {
|
|
44
|
-
const log = Logger("pkc-js:pkc:_init:retrySettingHttpRoutersOnIpfsNodes:setProvideDhtSweepEnabledOnIpfsNode");
|
|
45
|
-
const configKey = "Provide.DHT.SweepEnabled";
|
|
46
|
-
const url = `${kuboClient._clientOptions.url}/config?arg=${configKey}&arg=${JSON.stringify(sweepEnabled)}&json=true`;
|
|
47
|
-
try {
|
|
48
|
-
await _postToKuboRpc(kuboClient, url);
|
|
49
|
-
}
|
|
50
|
-
catch (e) {
|
|
51
|
-
const error = new PKCError("ERR_FAILED_TO_SET_CONFIG_ON_KUBO_NODE", {
|
|
52
|
-
fullUrl: url,
|
|
53
|
-
actualError: e,
|
|
54
|
-
kuboEndpoint: kuboClient._clientOptions.url,
|
|
55
|
-
configKey,
|
|
56
|
-
configValueToBeSet: sweepEnabled
|
|
57
|
-
});
|
|
58
|
-
log.error(e);
|
|
59
|
-
throw error;
|
|
60
|
-
}
|
|
61
|
-
log.trace("Succeeded in setting config key", configKey, "on node", kuboClient._clientOptions.url, "to be", sweepEnabled);
|
|
62
|
-
}
|
|
63
|
-
async function _setHttpRouterOptionsOnKuboNode(kuboClient, routingValue) {
|
|
64
|
-
const log = Logger("pkc-js:pkc:_init:retrySettingHttpRoutersOnIpfsNodes:setHttpRouterOptionsOnIpfsNode");
|
|
65
|
-
const routingKey = "Routing";
|
|
66
|
-
let routingConfigBeforeChanging;
|
|
67
|
-
try {
|
|
68
|
-
routingConfigBeforeChanging = await kuboClient._client.config.get(routingKey);
|
|
69
|
-
}
|
|
70
|
-
catch (e) {
|
|
71
|
-
const error = new PKCError("ERR_FAILED_TO_GET_CONFIG_ON_KUBO_NODE", {
|
|
72
|
-
actualError: e,
|
|
73
|
-
kuboEndpoint: kuboClient._clientOptions.url,
|
|
74
|
-
configKey: routingKey
|
|
75
|
-
});
|
|
76
|
-
log.error(e);
|
|
77
|
-
throw error;
|
|
78
|
-
}
|
|
79
|
-
const mergedRoutingValue = _mergeRouterConfigs(routingConfigBeforeChanging, routingValue);
|
|
80
|
-
const url = `${kuboClient._clientOptions.url}/config?arg=${routingKey}&arg=${JSON.stringify(mergedRoutingValue)}&json=true`;
|
|
81
|
-
try {
|
|
82
|
-
await _postToKuboRpc(kuboClient, url);
|
|
83
|
-
}
|
|
84
|
-
catch (e) {
|
|
85
|
-
const error = new PKCError("ERR_FAILED_TO_SET_CONFIG_ON_KUBO_NODE", {
|
|
86
|
-
fullUrl: url,
|
|
87
|
-
actualError: e,
|
|
88
|
-
kuboEndpoint: kuboClient._clientOptions.url,
|
|
89
|
-
configKey: routingKey,
|
|
90
|
-
configValueToBeSet: mergedRoutingValue
|
|
91
|
-
});
|
|
92
|
-
log.error(e);
|
|
93
|
-
throw error;
|
|
94
|
-
}
|
|
95
|
-
log.trace("Succeeded in setting config key", routingKey, "on node", kuboClient._clientOptions.url, "to be", mergedRoutingValue);
|
|
96
|
-
await _setProvideDhtSweepEnabledOnKuboNode(kuboClient, false);
|
|
97
|
-
const endpointsBefore = Object.values(routingConfigBeforeChanging?.["Routers"] || {}).map(
|
|
98
|
-
//@ts-expect-error
|
|
99
|
-
(router) => router["Parameters"]["Endpoint"]);
|
|
100
|
-
//@ts-expect-error
|
|
101
|
-
const endpointsAfter = Object.values(mergedRoutingValue.Routers).map((router) => router["Parameters"]["Endpoint"]);
|
|
102
|
-
if (!remeda.isDeepEqual(endpointsBefore.sort(), endpointsAfter.sort())) {
|
|
103
|
-
log("Config on kubo node has been changed. PKC-js will send shutdown command to node", kuboClient._clientOptions.url, "Clients of pkc-js should restart ipfs node");
|
|
104
|
-
const shutdownUrl = `${kuboClient._clientOptions.url}/shutdown`;
|
|
105
|
-
try {
|
|
106
|
-
await _postToKuboRpc(kuboClient, shutdownUrl);
|
|
107
|
-
}
|
|
108
|
-
catch (e) {
|
|
109
|
-
const error = new PKCError("ERR_FAILED_TO_SHUTDOWN_KUBO_NODE", {
|
|
110
|
-
actualError: e,
|
|
111
|
-
kuboEndpoint: kuboClient._clientOptions.url,
|
|
112
|
-
shutdownUrl
|
|
113
|
-
});
|
|
114
|
-
log.error(e);
|
|
115
|
-
throw error;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
// ============================================================================================
|
|
120
|
-
// TODO(kubo#11369): DELETE THIS ENTIRE WORKAROUND once ipfs/kubo#11369 is fixed.
|
|
121
|
-
// Everything from here to the end of this file that concerns AppendAnnounce — the IP/host
|
|
122
|
-
// helpers (_isPrivateOrLoopbackIpv4/Ipv6, _hasPublicHost), selectBrowserDialableAddrsToAppendAnnounce,
|
|
123
|
-
// _setKuboConfigJson, _syncAppendAnnounceOnKuboNode, syncKuboAppendAnnounce — plus the
|
|
124
|
-
// browser stub (src/runtime/browser/setup-kubo-http-routers.ts), the scheduler/timer wiring in
|
|
125
|
-
// src/pkc/pkc.ts (_appendAnnounceTimer, _runAppendAnnounceSyncAndReschedule, the destroy()
|
|
126
|
-
// cleanup), and test/node/kubo-append-announce.unit.test.ts exist ONLY to compensate for that
|
|
127
|
-
// kubo bug. When kubo#11369 ships a fix, remove all of it.
|
|
128
|
-
// --------------------------------------------------------------------------------------------
|
|
129
|
-
// Why it exists: a publicly-reachable kubo node advertises its browser-dialable transports
|
|
130
|
-
// (AutoTLS Secure-WebSocket `/tls/ws` and `webrtc-direct/certhash`) in `ipfs id`, but kubo does
|
|
131
|
-
// NOT announce those two address types to delegated HTTP routers once AutoNAT v2 has confirmed
|
|
132
|
-
// reachability — it only announces tcp/quic-v1/webtransport. Browser libp2p/helia clients
|
|
133
|
-
// therefore never learn a dialable address. We force-announce the node's own browser-dialable
|
|
134
|
-
// addresses via `Addresses.AppendAnnounce`, which go-libp2p applies AFTER the reachability
|
|
135
|
-
// filter, so they survive into provider records.
|
|
136
|
-
// ============================================================================================
|
|
137
|
-
function _isPrivateOrLoopbackIpv4(ip) {
|
|
138
|
-
if (/^(10|127|0)\./.test(ip) || /^169\.254\./.test(ip) || /^192\.168\./.test(ip))
|
|
139
|
-
return true;
|
|
140
|
-
const m172 = ip.match(/^172\.(\d{1,3})\./); // 172.16.0.0 - 172.31.255.255
|
|
141
|
-
if (m172 && Number(m172[1]) >= 16 && Number(m172[1]) <= 31)
|
|
142
|
-
return true;
|
|
143
|
-
const m100 = ip.match(/^100\.(\d{1,3})\./); // 100.64.0.0/10 (CGNAT)
|
|
144
|
-
if (m100 && Number(m100[1]) >= 64 && Number(m100[1]) <= 127)
|
|
145
|
-
return true;
|
|
146
|
-
return false;
|
|
147
|
-
}
|
|
148
|
-
function _isPrivateOrLoopbackIpv6(ip) {
|
|
149
|
-
const l = ip.toLowerCase();
|
|
150
|
-
return l === "::1" || l === "::" || l.startsWith("fe80") || l.startsWith("fc") || l.startsWith("fd");
|
|
151
|
-
}
|
|
152
|
-
// Is the address rooted at a public host (public IP, or a DNS name like the AutoTLS
|
|
153
|
-
// `*.libp2p.direct` domain)? Private/loopback/link-local/CGNAT addresses are excluded so we
|
|
154
|
-
// never force-announce an undialable LAN address.
|
|
155
|
-
function _hasPublicHost(addr) {
|
|
156
|
-
const parts = addr.split("/"); // ["", "ip4", "1.2.3.4", ...]
|
|
157
|
-
const proto = parts[1];
|
|
158
|
-
const host = parts[2] ?? "";
|
|
159
|
-
if (proto === "ip4")
|
|
160
|
-
return !_isPrivateOrLoopbackIpv4(host);
|
|
161
|
-
if (proto === "ip6")
|
|
162
|
-
return !_isPrivateOrLoopbackIpv6(host);
|
|
163
|
-
if (proto === "dns" || proto === "dns4" || proto === "dns6" || proto === "dnsaddr")
|
|
164
|
-
return true;
|
|
165
|
-
return false;
|
|
166
|
-
}
|
|
167
|
-
// Pure: from the multiaddrs reported by `ipfs id`, pick the node's own public browser-dialable
|
|
168
|
-
// addresses that kubo withholds from provider records — webrtc-direct (with certhash) and the
|
|
169
|
-
// AutoTLS Secure-WebSocket (`/tls/ws`, on a `libp2p.direct` domain). `/p2p/...` suffixes are
|
|
170
|
-
// stripped (AppendAnnounce entries are addresses; kubo appends the peer id).
|
|
171
|
-
export function selectBrowserDialableAddrsToAppendAnnounce(idAddrs) {
|
|
172
|
-
const webrtcDirect = new Set();
|
|
173
|
-
const wss = new Set();
|
|
174
|
-
for (const raw of idAddrs) {
|
|
175
|
-
const addr = String(raw).replace(/\/p2p\/[^/]+$/, "");
|
|
176
|
-
if (!_hasPublicHost(addr))
|
|
177
|
-
continue;
|
|
178
|
-
if (addr.includes("/webrtc-direct/") && addr.includes("/certhash/"))
|
|
179
|
-
webrtcDirect.add(addr);
|
|
180
|
-
// Only real browser-dialable Secure-WebSocket forms: the plain `.../tls/ws` and the
|
|
181
|
-
// AutoTLS IP+SNI `.../tls/sni/<*.libp2p.direct>/ws`. Matching any `libp2p.direct` substring
|
|
182
|
-
// would be too broad — a non-`/ws` address on that domain could falsely satisfy `wssPresent`
|
|
183
|
-
// and stop the retry loop before the WSS address actually lands.
|
|
184
|
-
else if (addr.endsWith("/ws") && (addr.includes("/tls/ws") || (addr.includes("/tls/sni/") && addr.includes("libp2p.direct"))))
|
|
185
|
-
wss.add(addr);
|
|
186
|
-
}
|
|
187
|
-
return { webrtcDirect: [...webrtcDirect], wss: [...wss], all: [...webrtcDirect, ...wss] };
|
|
188
|
-
}
|
|
189
|
-
async function _setKuboConfigJson(kuboClient, configKey, value) {
|
|
190
|
-
const log = Logger("pkc-js:pkc:_init:syncKuboAppendAnnounce:setConfig");
|
|
191
|
-
const url = `${kuboClient._clientOptions.url}/config?arg=${configKey}&arg=${JSON.stringify(value)}&json=true`;
|
|
192
|
-
try {
|
|
193
|
-
await _postToKuboRpc(kuboClient, url);
|
|
194
|
-
}
|
|
195
|
-
catch (e) {
|
|
196
|
-
const error = new PKCError("ERR_FAILED_TO_SET_CONFIG_ON_KUBO_NODE", {
|
|
197
|
-
fullUrl: url,
|
|
198
|
-
actualError: e,
|
|
199
|
-
kuboEndpoint: kuboClient._clientOptions.url,
|
|
200
|
-
configKey,
|
|
201
|
-
configValueToBeSet: value
|
|
202
|
-
});
|
|
203
|
-
log.error(e);
|
|
204
|
-
throw error;
|
|
205
|
-
}
|
|
206
|
-
log.trace("Set config key", configKey, "on node", kuboClient._clientOptions.url);
|
|
207
|
-
}
|
|
208
|
-
// Sync one kubo node's AppendAnnounce. Returns whether it changed, whether the AutoTLS WSS is
|
|
209
|
-
// now present, and whether AutoTLS is enabled (so the caller can decide when to stop re-checking).
|
|
210
|
-
async function _syncAppendAnnounceOnKuboNode(pkc, kuboClient) {
|
|
211
|
-
const log = Logger("pkc-js:pkc:_init:syncKuboAppendAnnounce");
|
|
212
|
-
const idResult = await kuboClient._client.id();
|
|
213
|
-
const idAddrs = (idResult.addresses ?? []).map((a) => String(a));
|
|
214
|
-
const desired = selectBrowserDialableAddrsToAppendAnnounce(idAddrs);
|
|
215
|
-
let autoTlsEnabled = false;
|
|
216
|
-
try {
|
|
217
|
-
// config.get returns the JSON value (a boolean here) typed loosely as string | object
|
|
218
|
-
autoTlsEnabled = String(await kuboClient._client.config.get("AutoTLS.Enabled")) === "true";
|
|
219
|
-
}
|
|
220
|
-
catch {
|
|
221
|
-
// older kubo / key absent — treat as disabled
|
|
222
|
-
}
|
|
223
|
-
const current = ((await kuboClient._client.config.get("Addresses.AppendAnnounce")) ?? []);
|
|
224
|
-
const currentArr = Array.isArray(current) ? current.map((a) => String(a)) : [];
|
|
225
|
-
const currentSet = new Set(currentArr);
|
|
226
|
-
const merged = [...currentArr];
|
|
227
|
-
let changed = false;
|
|
228
|
-
for (const addr of desired.all)
|
|
229
|
-
if (!currentSet.has(addr)) {
|
|
230
|
-
merged.push(addr);
|
|
231
|
-
currentSet.add(addr);
|
|
232
|
-
changed = true;
|
|
233
|
-
}
|
|
234
|
-
// Don't mutate the node (config write + shutdown) if pkc was destroyed while we were reading
|
|
235
|
-
// its `ipfs id` / config above — destroy() must stop the sync from touching kubo any further.
|
|
236
|
-
if (changed && !pkc.destroyed) {
|
|
237
|
-
await _setKuboConfigJson(kuboClient, "Addresses.AppendAnnounce", merged);
|
|
238
|
-
// AppendAnnounce is only read at kubo startup (verified: a running daemon ignores a live
|
|
239
|
-
// config.set until restart). Shut down so the operator's supervisor restarts the node and
|
|
240
|
-
// the addresses go live — same mechanism setupKuboHttpRouters uses for Routing changes.
|
|
241
|
-
log("Added browser-dialable addresses to AppendAnnounce on kubo node", kuboClient._clientOptions.url, desired.all, "- sending shutdown so the node restarts and announces them");
|
|
242
|
-
const shutdownUrl = `${kuboClient._clientOptions.url}/shutdown`;
|
|
243
|
-
try {
|
|
244
|
-
await _postToKuboRpc(kuboClient, shutdownUrl);
|
|
245
|
-
}
|
|
246
|
-
catch (e) {
|
|
247
|
-
const error = new PKCError("ERR_FAILED_TO_SHUTDOWN_KUBO_NODE", {
|
|
248
|
-
actualError: e,
|
|
249
|
-
kuboEndpoint: kuboClient._clientOptions.url,
|
|
250
|
-
shutdownUrl
|
|
251
|
-
});
|
|
252
|
-
log.error(e);
|
|
253
|
-
throw error;
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
const wssPresent = desired.wss.length > 0 && desired.wss.every((a) => currentSet.has(a));
|
|
257
|
-
return { changed, wssPresent, autoTlsEnabled };
|
|
258
|
-
}
|
|
259
|
-
// Sync AppendAnnounce on every connected kubo node. Returns allDone = true once every node has
|
|
260
|
-
// its AutoTLS WSS announced (or has AutoTLS disabled, in which case the one-shot webrtc-direct
|
|
261
|
-
// sync is all there is to do) — the caller stops the 10-minute re-check loop when allDone.
|
|
262
|
-
export async function syncKuboAppendAnnounce(pkc) {
|
|
263
|
-
const log = Logger("pkc-js:pkc:_init:syncKuboAppendAnnounce");
|
|
264
|
-
if (pkc.destroyed)
|
|
265
|
-
return { allDone: true };
|
|
266
|
-
let allDone = true;
|
|
267
|
-
for (const kuboClient of Object.values(pkc.clients.kuboRpcClients)) {
|
|
268
|
-
if (pkc.destroyed)
|
|
269
|
-
return { allDone: true }; // destroyed mid-sync — stop touching nodes
|
|
270
|
-
try {
|
|
271
|
-
const { wssPresent, autoTlsEnabled } = await _syncAppendAnnounceOnKuboNode(pkc, kuboClient);
|
|
272
|
-
// Keep re-checking while AutoTLS is enabled but its (slow to provision) /tls/ws hasn't
|
|
273
|
-
// landed in AppendAnnounce yet. When AutoTLS is off there is no WSS to wait for.
|
|
274
|
-
if (autoTlsEnabled && !wssPresent)
|
|
275
|
-
allDone = false;
|
|
276
|
-
}
|
|
277
|
-
catch (e) {
|
|
278
|
-
log.error("Failed to sync AppendAnnounce on kubo node", kuboClient._clientOptions.url, e);
|
|
279
|
-
allDone = false; // retry on the next tick
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
return { allDone };
|
|
283
|
-
}
|
|
284
|
-
export async function setupKuboHttpRouters(pkc) {
|
|
285
|
-
if (pkc.destroyed)
|
|
286
|
-
return;
|
|
287
|
-
if (!Array.isArray(pkc.kuboRpcClientsOptions) || pkc.kuboRpcClientsOptions.length <= 0)
|
|
288
|
-
throw Error("need ipfs http client to be defined");
|
|
289
|
-
if (!Array.isArray(pkc.httpRoutersOptions) || pkc.httpRoutersOptions.length <= 0)
|
|
290
|
-
throw Error("Need http router options to defined");
|
|
291
|
-
const httpRouterUrls = [...pkc.httpRoutersOptions].sort(); // make sure it's always the same order
|
|
292
|
-
// Set up http routers directly on the kubo nodes
|
|
293
|
-
const kuboClients = pkc.clients.kuboRpcClients;
|
|
294
|
-
const httpRoutersConfig = {
|
|
295
|
-
HttpRoutersParallel: { Type: "parallel", Parameters: { Routers: [] } },
|
|
296
|
-
HttpRouterNotSupported: { Type: "http", Parameters: { Endpoint: "http://kubohttprouternotsupported" } }
|
|
297
|
-
};
|
|
298
|
-
for (const [i, httpRouterUrl] of httpRouterUrls.entries()) {
|
|
299
|
-
const RouterName = `HttpRouter${i + 1}`;
|
|
300
|
-
httpRoutersConfig[RouterName] = {
|
|
301
|
-
Type: "http",
|
|
302
|
-
Parameters: {
|
|
303
|
-
Endpoint: httpRouterUrl
|
|
304
|
-
}
|
|
305
|
-
};
|
|
306
|
-
httpRoutersConfig.HttpRoutersParallel.Parameters.Routers[i] = {
|
|
307
|
-
RouterName: RouterName,
|
|
308
|
-
IgnoreErrors: true,
|
|
309
|
-
Timeout: "10s"
|
|
310
|
-
};
|
|
311
|
-
}
|
|
312
|
-
const httpRoutersMethodsConfig = {
|
|
313
|
-
"find-providers": { RouterName: "HttpRoutersParallel" },
|
|
314
|
-
provide: { RouterName: "HttpRoutersParallel" },
|
|
315
|
-
// not supported by pkc trackers
|
|
316
|
-
"find-peers": { RouterName: "HttpRouterNotSupported" },
|
|
317
|
-
"get-ipns": { RouterName: "HttpRouterNotSupported" },
|
|
318
|
-
"put-ipns": { RouterName: "HttpRouterNotSupported" }
|
|
319
|
-
};
|
|
320
|
-
const routingValue = {
|
|
321
|
-
Type: "custom",
|
|
322
|
-
Methods: httpRoutersMethodsConfig,
|
|
323
|
-
Routers: httpRoutersConfig
|
|
324
|
-
};
|
|
325
|
-
const settingOptionRetryOption = retry.operation({ forever: true, factor: 2 });
|
|
326
|
-
const setHttpRouterOnAllNodes = new Promise((resolve) => {
|
|
327
|
-
settingOptionRetryOption.attempt(async (curAttempt) => {
|
|
328
|
-
if (pkc.destroyed) {
|
|
329
|
-
resolve(1);
|
|
330
|
-
return;
|
|
331
|
-
}
|
|
332
|
-
for (const kuboClient of Object.values(kuboClients)) {
|
|
333
|
-
try {
|
|
334
|
-
await _setHttpRouterOptionsOnKuboNode(kuboClient, routingValue);
|
|
335
|
-
}
|
|
336
|
-
catch (e) {
|
|
337
|
-
settingOptionRetryOption.retry(e);
|
|
338
|
-
return;
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
resolve(1);
|
|
342
|
-
});
|
|
343
|
-
});
|
|
344
|
-
await setHttpRouterOnAllNodes;
|
|
345
|
-
settingOptionRetryOption.stop();
|
|
346
|
-
}
|
|
347
|
-
//# sourceMappingURL=setup-kubo-http-routers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"setup-kubo-http-routers.js","sourceRoot":"","sources":["../../../../src/runtime/browser/setup-kubo-http-routers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAEjC,+FAA+F;AAC/F,8FAA8F;AAC9F,iGAAiG;AACjG,0FAA0F;AAC1F,KAAK,UAAU,cAAc,CAAC,UAAoD,EAAE,GAAW;IAC3F,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC,CAAC;IAC7F,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;QACV,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;QAC9C,MAAM,KAAK,CAAC,0CAA0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O,CAAC,CAAC,OAAO,EAAE,EAAE;QACpD,wBAAwB,CAAC,OAAO,CAAC,KAAK,EAAE,UAAU,EAAE,EAAE;YAClD,IAAI,GAAG,CAAC,SAAS,EAAE,CAAC;gBAChB,OAAO,CAAC,CAAC,CAAC,CAAC;gBACX,OAAO;YACX,CAAC;YACD,KAAK,MAAM,UAAU,IAAI,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC;gBAClD,IAAI,CAAC;oBACD,MAAM,+BAA+B,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;gBACpE,CAAC;gBAAC,OAAO,CAAC,EAAE,CAAC;oBACT,wBAAwB,CAAC,KAAK,CAAQ,CAAC,CAAC,CAAC;oBACzC,OAAO;gBACX,CAAC;YACL,CAAC;YACD,OAAO,CAAC,CAAC,CAAC,CAAC;QACf,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAEH,MAAM,uBAAuB,CAAC;IAC9B,wBAAwB,CAAC,IAAI,EAAE,CAAC;AACpC,CAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
// Node-only stubs. The browser build is a string-replace copy of dist/node that rewrites
|
|
2
|
-
// `runtime/node/` imports to `runtime/browser/`, so every export the shared code (src/pkc/)
|
|
3
|
-
// imports from the node module must also exist here, or esbuild fails to bundle it. Neither is
|
|
4
|
-
// ever invoked in a browser (the callers are guarded by _canCreateNewLocalCommunity()).
|
|
5
|
-
//
|
|
6
|
-
// `syncKuboAppendAnnounce` is part of the kubo#11369 workaround — delete this stub together
|
|
7
|
-
// with the node implementation and its pkc.ts wiring once ipfs/kubo#11369 is fixed.
|
|
8
|
-
export function setupKuboHttpRouters() {
|
|
9
|
-
throw Error("Should not be called in browser");
|
|
10
|
-
}
|
|
11
|
-
export function syncKuboAppendAnnounce() {
|
|
12
|
-
throw Error("Should not be called in browser");
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=setup-kubo-http-routers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"setup-kubo-http-routers.js","sourceRoot":"","sources":["../../../../src/runtime/browser/setup-kubo-http-routers.ts"],"names":[],"mappings":"AAAA,yFAAyF;AACzF,4FAA4F;AAC5F,+FAA+F;AAC/F,wFAAwF;AACxF,EAAE;AACF,4FAA4F;AAC5F,oFAAoF;AACpF,MAAM,UAAU,oBAAoB;IAChC,MAAM,KAAK,CAAC,iCAAiC,CAAC,CAAC;AACnD,CAAC;AAED,MAAM,UAAU,sBAAsB;IAClC,MAAM,KAAK,CAAC,iCAAiC,CAAC,CAAC;AACnD,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { PKC } from "../../pkc/pkc.js";
|
|
2
|
-
export declare function selectBrowserDialableAddrsToAppendAnnounce(idAddrs: string[]): {
|
|
3
|
-
webrtcDirect: string[];
|
|
4
|
-
wss: string[];
|
|
5
|
-
all: string[];
|
|
6
|
-
};
|
|
7
|
-
export declare function syncKuboAppendAnnounce(pkc: PKC): Promise<{
|
|
8
|
-
allDone: boolean;
|
|
9
|
-
}>;
|
|
10
|
-
export declare function setupKuboHttpRouters(pkc: PKC): Promise<void>;
|