@pkcprotocol/pkc-js 0.0.65 → 0.0.67
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/browser/clients/rpc-client/pkc-rpc-client.d.ts +1 -0
- package/dist/browser/clients/rpc-client/pkc-rpc-client.js +14 -1
- package/dist/browser/clients/rpc-client/pkc-rpc-client.js.map +1 -1
- package/dist/browser/community/community-client-manager.js +11 -0
- package/dist/browser/community/community-client-manager.js.map +1 -1
- package/dist/browser/errors.d.ts +2 -0
- package/dist/browser/errors.js +2 -0
- package/dist/browser/errors.js.map +1 -1
- package/dist/browser/generated-version.d.ts +1 -1
- package/dist/browser/generated-version.js +1 -1
- package/dist/browser/helia/helia-for-pkc.js +173 -5
- package/dist/browser/helia/helia-for-pkc.js.map +1 -1
- package/dist/browser/helia/util.d.ts +7 -0
- package/dist/browser/helia/util.js +42 -2
- package/dist/browser/helia/util.js.map +1 -1
- package/dist/browser/pkc-error.d.ts +1 -1
- package/dist/browser/rpc/src/index.js +7 -1
- package/dist/browser/rpc/src/index.js.map +1 -1
- package/dist/browser/signer/signatures.js +26 -0
- package/dist/browser/signer/signatures.js.map +1 -1
- package/dist/bundled/bundle-manifest.json +31 -31
- package/dist/bundled/chunks/{helia-for-pkc-h-rjuHh7.js → helia-for-pkc-CTxzGps-.js} +110 -3
- package/dist/bundled/chunks/{local-community-DdDpaZqk.js → local-community-DJX_xmB4.js} +1 -1
- package/dist/bundled/chunks/{local-community-DEWf2apw.js → local-community-T3mSbjdf.js} +2 -2
- package/dist/bundled/chunks/{node-CrnvA79m.js → node-zemQ3e2S.js} +14 -6
- package/dist/bundled/chunks/{rpc-local-community-CpN6R3ZN.js → rpc-local-community-ByjBdSQ5.js} +22 -1
- package/dist/bundled/chunks/{schema-Db4geGeo.js → schema-B47aYWNu.js} +3 -1
- package/dist/bundled/chunks/{util-DrHyKxFe.js → util-P3adfecj.js} +22 -3
- package/dist/bundled/index.js +1 -1
- package/dist/bundled/rpc/src/index.js +11 -6
- package/dist/node/clients/rpc-client/pkc-rpc-client.d.ts +1 -0
- package/dist/node/clients/rpc-client/pkc-rpc-client.js +14 -1
- package/dist/node/clients/rpc-client/pkc-rpc-client.js.map +1 -1
- package/dist/node/community/community-client-manager.js +11 -0
- package/dist/node/community/community-client-manager.js.map +1 -1
- package/dist/node/errors.d.ts +2 -0
- package/dist/node/errors.js +2 -0
- package/dist/node/errors.js.map +1 -1
- package/dist/node/generated-version.d.ts +1 -1
- package/dist/node/generated-version.js +1 -1
- package/dist/node/helia/helia-for-pkc.js +173 -5
- package/dist/node/helia/helia-for-pkc.js.map +1 -1
- package/dist/node/helia/util.d.ts +7 -0
- package/dist/node/helia/util.js +42 -2
- package/dist/node/helia/util.js.map +1 -1
- package/dist/node/pkc-error.d.ts +1 -1
- package/dist/node/rpc/src/index.js +7 -1
- package/dist/node/rpc/src/index.js.map +1 -1
- package/dist/node/signer/signatures.js +26 -0
- package/dist/node/signer/signatures.js.map +1 -1
- package/package.json +1 -1
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"node:module"
|
|
15
15
|
],
|
|
16
16
|
"dynamicImports": [
|
|
17
|
-
"chunks/node-
|
|
17
|
+
"chunks/node-zemQ3e2S.js"
|
|
18
18
|
],
|
|
19
19
|
"inputs": [
|
|
20
20
|
"dist/node/runtime/node/compile-cache.js",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"index.js": {
|
|
25
25
|
"isEntry": true,
|
|
26
26
|
"imports": [
|
|
27
|
-
"chunks/node-
|
|
27
|
+
"chunks/node-zemQ3e2S.js"
|
|
28
28
|
],
|
|
29
29
|
"dynamicImports": [],
|
|
30
30
|
"inputs": []
|
|
@@ -32,10 +32,10 @@
|
|
|
32
32
|
"rpc/src/index.js": {
|
|
33
33
|
"isEntry": true,
|
|
34
34
|
"imports": [
|
|
35
|
-
"chunks/rpc-local-community-
|
|
36
|
-
"chunks/node-
|
|
37
|
-
"chunks/schema-
|
|
38
|
-
"chunks/local-community-
|
|
35
|
+
"chunks/rpc-local-community-ByjBdSQ5.js",
|
|
36
|
+
"chunks/node-zemQ3e2S.js",
|
|
37
|
+
"chunks/schema-B47aYWNu.js",
|
|
38
|
+
"chunks/local-community-T3mSbjdf.js",
|
|
39
39
|
"node:url",
|
|
40
40
|
"path",
|
|
41
41
|
"assert",
|
|
@@ -64,11 +64,11 @@
|
|
|
64
64
|
"\u0000rolldown/runtime.js"
|
|
65
65
|
]
|
|
66
66
|
},
|
|
67
|
-
"chunks/helia-for-pkc-
|
|
67
|
+
"chunks/helia-for-pkc-CTxzGps-.js": {
|
|
68
68
|
"isEntry": false,
|
|
69
69
|
"imports": [
|
|
70
|
-
"chunks/schema-
|
|
71
|
-
"chunks/util-
|
|
70
|
+
"chunks/schema-B47aYWNu.js",
|
|
71
|
+
"chunks/util-P3adfecj.js",
|
|
72
72
|
"multiformats/cid",
|
|
73
73
|
"@libp2p/peer-id",
|
|
74
74
|
"events",
|
|
@@ -94,12 +94,20 @@
|
|
|
94
94
|
"dist/node/helia/helia-for-pkc.js"
|
|
95
95
|
]
|
|
96
96
|
},
|
|
97
|
-
"chunks/local-community-
|
|
97
|
+
"chunks/local-community-DJX_xmB4.js": {
|
|
98
|
+
"isEntry": false,
|
|
99
|
+
"imports": [
|
|
100
|
+
"chunks/local-community-T3mSbjdf.js"
|
|
101
|
+
],
|
|
102
|
+
"dynamicImports": [],
|
|
103
|
+
"inputs": []
|
|
104
|
+
},
|
|
105
|
+
"chunks/local-community-T3mSbjdf.js": {
|
|
98
106
|
"isEntry": false,
|
|
99
107
|
"imports": [
|
|
100
108
|
"chunks/chunk-2rV9d50f.js",
|
|
101
|
-
"chunks/rpc-local-community-
|
|
102
|
-
"chunks/schema-
|
|
109
|
+
"chunks/rpc-local-community-ByjBdSQ5.js",
|
|
110
|
+
"chunks/schema-B47aYWNu.js",
|
|
103
111
|
"node:crypto",
|
|
104
112
|
"node:url",
|
|
105
113
|
"node:path",
|
|
@@ -152,21 +160,13 @@
|
|
|
152
160
|
"dist/node/runtime/node/community/local-community.js"
|
|
153
161
|
]
|
|
154
162
|
},
|
|
155
|
-
"chunks/
|
|
156
|
-
"isEntry": false,
|
|
157
|
-
"imports": [
|
|
158
|
-
"chunks/local-community-DEWf2apw.js"
|
|
159
|
-
],
|
|
160
|
-
"dynamicImports": [],
|
|
161
|
-
"inputs": []
|
|
162
|
-
},
|
|
163
|
-
"chunks/node-CrnvA79m.js": {
|
|
163
|
+
"chunks/node-zemQ3e2S.js": {
|
|
164
164
|
"isEntry": false,
|
|
165
165
|
"imports": [
|
|
166
166
|
"chunks/chunk-2rV9d50f.js",
|
|
167
|
-
"chunks/rpc-local-community-
|
|
168
|
-
"chunks/schema-
|
|
169
|
-
"chunks/util-
|
|
167
|
+
"chunks/rpc-local-community-ByjBdSQ5.js",
|
|
168
|
+
"chunks/schema-B47aYWNu.js",
|
|
169
|
+
"chunks/util-P3adfecj.js",
|
|
170
170
|
"path",
|
|
171
171
|
"assert",
|
|
172
172
|
"fs",
|
|
@@ -177,8 +177,8 @@
|
|
|
177
177
|
"rpc-websockets"
|
|
178
178
|
],
|
|
179
179
|
"dynamicImports": [
|
|
180
|
-
"chunks/helia-for-pkc-
|
|
181
|
-
"chunks/local-community-
|
|
180
|
+
"chunks/helia-for-pkc-CTxzGps-.js",
|
|
181
|
+
"chunks/local-community-T3mSbjdf.js"
|
|
182
182
|
],
|
|
183
183
|
"inputs": [
|
|
184
184
|
"node_modules/zod/v4/locales/en.js",
|
|
@@ -231,11 +231,11 @@
|
|
|
231
231
|
"dist/node/index.js"
|
|
232
232
|
]
|
|
233
233
|
},
|
|
234
|
-
"chunks/rpc-local-community-
|
|
234
|
+
"chunks/rpc-local-community-ByjBdSQ5.js": {
|
|
235
235
|
"isEntry": false,
|
|
236
236
|
"imports": [
|
|
237
237
|
"chunks/chunk-2rV9d50f.js",
|
|
238
|
-
"chunks/schema-
|
|
238
|
+
"chunks/schema-B47aYWNu.js",
|
|
239
239
|
"chunks/src-CYIMjhjK.js",
|
|
240
240
|
"node:http",
|
|
241
241
|
"node:crypto",
|
|
@@ -791,7 +791,7 @@
|
|
|
791
791
|
"dist/node/community/rpc-local-community.js"
|
|
792
792
|
]
|
|
793
793
|
},
|
|
794
|
-
"chunks/schema-
|
|
794
|
+
"chunks/schema-B47aYWNu.js": {
|
|
795
795
|
"isEntry": false,
|
|
796
796
|
"imports": [
|
|
797
797
|
"chunks/chunk-2rV9d50f.js",
|
|
@@ -1228,10 +1228,10 @@
|
|
|
1228
1228
|
"node_modules/it-all/dist/src/index.js"
|
|
1229
1229
|
]
|
|
1230
1230
|
},
|
|
1231
|
-
"chunks/util-
|
|
1231
|
+
"chunks/util-P3adfecj.js": {
|
|
1232
1232
|
"isEntry": false,
|
|
1233
1233
|
"imports": [
|
|
1234
|
-
"chunks/schema-
|
|
1234
|
+
"chunks/schema-B47aYWNu.js"
|
|
1235
1235
|
],
|
|
1236
1236
|
"dynamicImports": [],
|
|
1237
1237
|
"inputs": [
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { L as hideClassPrivateProps, R as ipnsNameToIpnsOverPubsubTopic, _r as PKCError, yr as logger_default } from "./schema-
|
|
2
|
-
import { n as directFetchIpnsRecordFromProviders, r as getHeliaDebugContext, t as connectToPubsubPeers } from "./util-
|
|
1
|
+
import { L as hideClassPrivateProps, R as ipnsNameToIpnsOverPubsubTopic, _r as PKCError, yr as logger_default } from "./schema-B47aYWNu.js";
|
|
2
|
+
import { i as selectBitswapSessionSeedPeers, n as directFetchIpnsRecordFromProviders, r as getHeliaDebugContext, t as connectToPubsubPeers } from "./util-P3adfecj.js";
|
|
3
3
|
import { CID } from "multiformats/cid";
|
|
4
4
|
import { peerIdFromString } from "@libp2p/peer-id";
|
|
5
5
|
import { EventEmitter as EventEmitter$1 } from "events";
|
|
@@ -129,6 +129,66 @@ async function createLibp2pJsClientOrUseExistingOne(pkcOptions) {
|
|
|
129
129
|
CID.parse(ipfsPathOrCid.split("/")[0]);
|
|
130
130
|
return ipfsPathOrCid;
|
|
131
131
|
};
|
|
132
|
+
const MAX_BITSWAP_SESSION_SEED_PEERS = 3;
|
|
133
|
+
const RECENT_IPNS_RECORD_SERVERS_MAX = 8;
|
|
134
|
+
const recentIpnsRecordServerPeerIdStrings = [];
|
|
135
|
+
const rememberIpnsRecordServerPeer = (peerIdString) => {
|
|
136
|
+
const existingIndex = recentIpnsRecordServerPeerIdStrings.indexOf(peerIdString);
|
|
137
|
+
if (existingIndex !== -1) recentIpnsRecordServerPeerIdStrings.splice(existingIndex, 1);
|
|
138
|
+
recentIpnsRecordServerPeerIdStrings.unshift(peerIdString);
|
|
139
|
+
if (recentIpnsRecordServerPeerIdStrings.length > RECENT_IPNS_RECORD_SERVERS_MAX) recentIpnsRecordServerPeerIdStrings.pop();
|
|
140
|
+
};
|
|
141
|
+
const getBitswapSessionSeedPeers = () => {
|
|
142
|
+
const pubsub = helia.libp2p.services.pubsub;
|
|
143
|
+
return selectBitswapSessionSeedPeers({
|
|
144
|
+
connectedPeers: helia.libp2p.getPeers(),
|
|
145
|
+
pubsubSubscriberPeerIdStrings: pubsub.getTopics().flatMap((topic) => pubsub.getSubscribers(topic).map(String)),
|
|
146
|
+
recentIpnsRecordServerPeerIdStrings,
|
|
147
|
+
maxSeeds: MAX_BITSWAP_SESSION_SEED_PEERS
|
|
148
|
+
});
|
|
149
|
+
};
|
|
150
|
+
const KUBO_DURATION_UNIT_TO_MS = {
|
|
151
|
+
ns: 1e-6,
|
|
152
|
+
us: .001,
|
|
153
|
+
µs: .001,
|
|
154
|
+
ms: 1,
|
|
155
|
+
s: 1e3,
|
|
156
|
+
m: 6e4,
|
|
157
|
+
h: 36e5
|
|
158
|
+
};
|
|
159
|
+
const parseKuboStyleTimeoutMs = (timeout) => {
|
|
160
|
+
if (timeout === void 0 || timeout === null) return void 0;
|
|
161
|
+
if (typeof timeout === "number" && Number.isFinite(timeout) && timeout > 0) return timeout;
|
|
162
|
+
if (typeof timeout === "string") {
|
|
163
|
+
let totalMs = 0;
|
|
164
|
+
let matchedLength = 0;
|
|
165
|
+
for (const component of timeout.matchAll(/(\d+(?:\.\d+)?)(ns|us|µs|ms|s|m|h)/g)) {
|
|
166
|
+
totalMs += parseFloat(component[1]) * KUBO_DURATION_UNIT_TO_MS[component[2]];
|
|
167
|
+
matchedLength += component[0].length;
|
|
168
|
+
}
|
|
169
|
+
if (matchedLength === timeout.length && totalMs > 0) return totalMs;
|
|
170
|
+
}
|
|
171
|
+
throw new PKCError("ERR_INVALID_KUBO_STYLE_TIMEOUT", { invalidTimeout: timeout });
|
|
172
|
+
};
|
|
173
|
+
const SESSION_NO_PROVIDERS_RETRY_BASE_DELAY_MS = 500;
|
|
174
|
+
const isCausedByInsufficientProviders = (error) => {
|
|
175
|
+
if (!(error instanceof Error)) return false;
|
|
176
|
+
if (error.name === "InsufficientProvidersError") return true;
|
|
177
|
+
if (error instanceof AggregateError && error.errors.some(isCausedByInsufficientProviders)) return true;
|
|
178
|
+
return isCausedByInsufficientProviders(error.cause);
|
|
179
|
+
};
|
|
180
|
+
const delayAbortable = (ms, signal) => new Promise((resolve) => {
|
|
181
|
+
if (signal.aborted) return resolve();
|
|
182
|
+
const onAbort = () => {
|
|
183
|
+
clearTimeout(timer);
|
|
184
|
+
resolve();
|
|
185
|
+
};
|
|
186
|
+
const timer = setTimeout(() => {
|
|
187
|
+
signal.removeEventListener("abort", onAbort);
|
|
188
|
+
resolve();
|
|
189
|
+
}, ms);
|
|
190
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
191
|
+
});
|
|
132
192
|
const ipnsNameResolver = ipns(helia, { routers: [pubsub(helia)] });
|
|
133
193
|
ipnsNameResolver.routers = ipnsNameResolver.routers.filter((r) => r?.constructor?.name !== "LocalStoreRouting");
|
|
134
194
|
const WARMUP_MAX_PEERS = 4;
|
|
@@ -188,6 +248,7 @@ async function createLibp2pJsClientOrUseExistingOne(pkcOptions) {
|
|
|
188
248
|
source: direct.source,
|
|
189
249
|
peerId: direct.peerId
|
|
190
250
|
};
|
|
251
|
+
rememberIpnsRecordServerPeer(direct.peerId);
|
|
191
252
|
yield unmarshalIPNSRecord(direct.recordBytes).value;
|
|
192
253
|
return;
|
|
193
254
|
}
|
|
@@ -259,7 +320,53 @@ async function createLibp2pJsClientOrUseExistingOne(pkcOptions) {
|
|
|
259
320
|
} },
|
|
260
321
|
cat(ipfsPath, options) {
|
|
261
322
|
throwIfHeliaIsStoppingOrStopped();
|
|
262
|
-
|
|
323
|
+
const rootCid = CID.parse(ipfsPath.split("/")[0]);
|
|
324
|
+
const timeoutMs = parseKuboStyleTimeoutMs(options?.timeout);
|
|
325
|
+
return (async function* () {
|
|
326
|
+
const controller = new AbortController();
|
|
327
|
+
const callerSignal = options?.signal;
|
|
328
|
+
const abortFromCallerSignal = () => controller.abort(callerSignal?.reason);
|
|
329
|
+
if (callerSignal?.aborted) abortFromCallerSignal();
|
|
330
|
+
else callerSignal?.addEventListener("abort", abortFromCallerSignal, { once: true });
|
|
331
|
+
const timeoutTimer = timeoutMs !== void 0 ? setTimeout(() => controller.abort(new PKCError("ERR_FETCH_CID_P2P_TIMEOUT", {
|
|
332
|
+
ipfsPath,
|
|
333
|
+
timeoutMs
|
|
334
|
+
})), timeoutMs) : void 0;
|
|
335
|
+
try {
|
|
336
|
+
for (let attempt = 0;; attempt++) {
|
|
337
|
+
const session = helia.blockstore.createSession(rootCid, { providers: getBitswapSessionSeedPeers() });
|
|
338
|
+
let yieldedAnyBytes = false;
|
|
339
|
+
try {
|
|
340
|
+
const catIterable = unixfs({ blockstore: session }).cat(asHeliaCatCid(ipfsPath), {
|
|
341
|
+
...options,
|
|
342
|
+
signal: controller.signal
|
|
343
|
+
});
|
|
344
|
+
for await (const chunk of catIterable) {
|
|
345
|
+
yieldedAnyBytes = true;
|
|
346
|
+
yield chunk;
|
|
347
|
+
}
|
|
348
|
+
return;
|
|
349
|
+
} catch (catError) {
|
|
350
|
+
if (controller.signal.aborted) throw controller.signal.reason instanceof Error ? controller.signal.reason : catError;
|
|
351
|
+
if (yieldedAnyBytes || !isCausedByInsufficientProviders(catError)) throw catError;
|
|
352
|
+
log.trace("Bitswap session found no providers for", ipfsPath, "- retrying, attempt", attempt + 1);
|
|
353
|
+
} finally {
|
|
354
|
+
session.close();
|
|
355
|
+
}
|
|
356
|
+
await delayAbortable(Math.min(SESSION_NO_PROVIDERS_RETRY_BASE_DELAY_MS * 2 ** attempt, 8e3), controller.signal);
|
|
357
|
+
if (controller.signal.aborted) {
|
|
358
|
+
if (controller.signal.reason instanceof Error) throw controller.signal.reason;
|
|
359
|
+
throw new PKCError("ERR_FETCH_CID_P2P_TIMEOUT", {
|
|
360
|
+
ipfsPath,
|
|
361
|
+
timeoutMs
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
} finally {
|
|
366
|
+
if (timeoutTimer !== void 0) clearTimeout(timeoutTimer);
|
|
367
|
+
callerSignal?.removeEventListener("abort", abortFromCallerSignal);
|
|
368
|
+
}
|
|
369
|
+
})();
|
|
263
370
|
},
|
|
264
371
|
pubsub: {
|
|
265
372
|
ls: async () => helia.libp2p.services.pubsub.getTopics(),
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as createNewLocalCommunityDb, r as updateInstancePropsWithStartedCommunityOrDb, t as LocalCommunity } from "./local-community-
|
|
1
|
+
import { n as createNewLocalCommunityDb, r as updateInstancePropsWithStartedCommunityOrDb, t as LocalCommunity } from "./local-community-T3mSbjdf.js";
|
|
2
2
|
export { LocalCommunity, createNewLocalCommunityDb, updateInstancePropsWithStartedCommunityOrDb };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { i as __toESM, r as __require, t as __commonJSMin } from "./chunk-2rV9d50f.js";
|
|
2
|
-
import { $ as pubsubTopicToDhtKey, $n as t$7, At as trackStartedCommunity, Bt as CommunityEditPublicationPubsubReservedFields, C as contentContainsMarkdownAudio, Ct as findUpdatingCommunity, En as CommentUpdateSchema, F as getIpnsRecordInLocalKuboNode, Fn as CommentEditPubsubMessagePublicationSchema, Ft as untrackUpdatingCommunity, G as isLinkOfAudio, Gt as CommentModerationPubsubMessagePublicationSchema, In as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema, It as require_sha256, J as isLinkOfVideo, Jt as CommentModerationsTableRowSchema, K as isLinkOfImage, Kt as CommentModerationReservedFields, L as hideClassPrivateProps, Ln as CommentEditReservedFields, M as genToArray, Mr as ZodError, Mt as trackUpdatingCommunity, N as getEquivalentCommunityAddresses, Nt as untrackStartedCommunity, O as derivePublicationFromChallengeRequest, On as CommentUpdateTableRowSchema, P as getErrorCodeFromMessage, Q as isStringDomain, Qn as n$3, R as ipnsNameToIpnsOverPubsubTopic, Rt as pTimeout, S as calculateStringSizeSameAsIpfsAddCidV0, T as contentContainsMarkdownVideos, Un as AuthorReservedFields, W as isLinkOfAnimatedImage, Xn as n$4, Y as isLinkValid, Zn as t$8, _r as PKCError, _t as timestamp, a as ChallengeRequestMessageSchema, ar as t$4, at as removeNullUndefinedValues, b as areEquivalentCommunityAddresses, bt as findCommunityInRegistry, cr as t$5, d as DecryptedChallengeRequestSchema, dr as require_retry, dt as retryKuboIpfsAddAndProvide, er as t$6, fn as VotePubsubMessagePublicationSchema, hn as VoteTablesRowSchema, ht as statMfsPathSafely, ir as r$1, k as doesDomainAddressHaveCapitalLetter, kn as CommentsTableRowSchema, kt as syncCommunityRegistryEntry, lr as t$3, lt as retryKuboBlockPutPinAndProvidePubsubTopic, mt as sleepUntilTimeoutOrAbort, nn as CommunityIpfsSchema, nr as e$1, nt as removeBlocksFromKuboNode, pn as VotePubsubReservedFields, q as isLinkOfMedia, r as ChallengeMessageSchema, rn as CommunitySignedPropertyNames, rt as removeMfsFilesSafely, s as ChallengeVerificationMessageSchema, t as ChallengeAnswerMessageSchema, tr as e, u as DecryptedChallengeRequestPublicationSchema, vn as CommentIpfsSchema, vr as messages, w as contentContainsMarkdownImages, x as calculateIpfsCidV0, xt as findStartedCommunity, y as version_default, yn as CommentPubsubMessageReservedFields, yr as logger_default, yt as writeKuboFilesWithTimeout, zn as CommentEditsTableRowSchema } from "./schema-
|
|
3
|
-
import { $n as t$10, A as deriveDbPosts, At as verifyCommunityEdit, Bt as getCommunityPublicKeyFromWire, C as BackupAbortError, Dt as verifyCommentPubsubMessage, E as calculateInlineRepliesBudget, Et as verifyCommentModeration, F as importSignerIntoKuboNode, Ft as getAuthorNameFromWire, G as REPLY_REPLIES_SORT_TYPES, Gt as getIpfsKeyFromPrivateKey, Ht as decode, Jn as r$2, Jt as getPublicKeyFromPrivateKey, K as TIMEFRAMES_TO_SECONDS, Kn as t$9, Kt as getPKCAddressFromPublicKey, M as getDefaultCommunityDbConfig, Mt as buildRuntimeAuthor, Nt as cleanWireAuthor, O as deleteOldCommunityInWindows, Ot as verifyCommentUpdate, P as getThumbnailPropsOfLink, R as moveCommunityDbToDeletedDirectory, S as encryptEd25519AesGcmPublicKeyBuffer, St as verifyChallengeRequest, T as calculateExpectedSignatureSize, Tt as verifyCommentIpfs, U as POSTS_SORT_TYPES, Ut as encode, W as POST_REPLIES_SORT_TYPES, Xn as n$6, Yn as t$11, Yt as createSchemaRowParser, Z as iterateOverPageCidsToFindAllCids, Zn as n$5, _ as SignerWithPublicKeyAddress, _t as signCommunity, a as pkcJsChallenges, b as decryptEd25519AesGcmPublicKeyBuffer, bt as verifyChallengeAnswer, cn as parseCommunityIpfsSchemaPassthroughWithPKCErrorIfItFails, d as MAX_FILE_SIZE_BYTES_FOR_COMMUNITY_IPFS, dt as signChallengeVerification, er as stringify, f as KeyvBetterSqlite3, ft as signComment, gt as signCommentUpdateForChallengeVerification, ht as signCommentUpdate, i as getCommunityChallengeFromCommunityChallengeSettings, it as pLimit, j as deriveDbReplies, jt as verifyVote, k as deriveCommentIpfsFromCommentTableRow, kt as verifyCommunity, l as normalizeSelfAddrsForProvider, lt as signChallengeMessage, nr as require_lodash_merge, o as TrackedInstanceRegistry, on as parseCommunityEditOptionsSchemaWithPKCErrorIfItFails, pt as signCommentEdit, qn as t$12, qt as getPKCAddressFromPublicKeySync, r as getChallengeVerification, s as LRUCache, st as cleanUpBeforePublishing, t as RpcLocalCommunity, tr as STORAGE_KEYS, vn as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, w as backupCommunityDb, wt as verifyCommentEdit, xn as parseJsonWithPKCErrorIfFails, z as resolveDbPostsCidRefs, zt as getCommunityNameFromWire } from "./rpc-local-community-
|
|
2
|
+
import { $ as pubsubTopicToDhtKey, $n as t$7, At as trackStartedCommunity, Bt as CommunityEditPublicationPubsubReservedFields, C as contentContainsMarkdownAudio, Ct as findUpdatingCommunity, En as CommentUpdateSchema, F as getIpnsRecordInLocalKuboNode, Fn as CommentEditPubsubMessagePublicationSchema, Ft as untrackUpdatingCommunity, G as isLinkOfAudio, Gt as CommentModerationPubsubMessagePublicationSchema, In as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema, It as require_sha256, J as isLinkOfVideo, Jt as CommentModerationsTableRowSchema, K as isLinkOfImage, Kt as CommentModerationReservedFields, L as hideClassPrivateProps, Ln as CommentEditReservedFields, M as genToArray, Mr as ZodError, Mt as trackUpdatingCommunity, N as getEquivalentCommunityAddresses, Nt as untrackStartedCommunity, O as derivePublicationFromChallengeRequest, On as CommentUpdateTableRowSchema, P as getErrorCodeFromMessage, Q as isStringDomain, Qn as n$3, R as ipnsNameToIpnsOverPubsubTopic, Rt as pTimeout, S as calculateStringSizeSameAsIpfsAddCidV0, T as contentContainsMarkdownVideos, Un as AuthorReservedFields, W as isLinkOfAnimatedImage, Xn as n$4, Y as isLinkValid, Zn as t$8, _r as PKCError, _t as timestamp, a as ChallengeRequestMessageSchema, ar as t$4, at as removeNullUndefinedValues, b as areEquivalentCommunityAddresses, bt as findCommunityInRegistry, cr as t$5, d as DecryptedChallengeRequestSchema, dr as require_retry, dt as retryKuboIpfsAddAndProvide, er as t$6, fn as VotePubsubMessagePublicationSchema, hn as VoteTablesRowSchema, ht as statMfsPathSafely, ir as r$1, k as doesDomainAddressHaveCapitalLetter, kn as CommentsTableRowSchema, kt as syncCommunityRegistryEntry, lr as t$3, lt as retryKuboBlockPutPinAndProvidePubsubTopic, mt as sleepUntilTimeoutOrAbort, nn as CommunityIpfsSchema, nr as e$1, nt as removeBlocksFromKuboNode, pn as VotePubsubReservedFields, q as isLinkOfMedia, r as ChallengeMessageSchema, rn as CommunitySignedPropertyNames, rt as removeMfsFilesSafely, s as ChallengeVerificationMessageSchema, t as ChallengeAnswerMessageSchema, tr as e, u as DecryptedChallengeRequestPublicationSchema, vn as CommentIpfsSchema, vr as messages, w as contentContainsMarkdownImages, x as calculateIpfsCidV0, xt as findStartedCommunity, y as version_default, yn as CommentPubsubMessageReservedFields, yr as logger_default, yt as writeKuboFilesWithTimeout, zn as CommentEditsTableRowSchema } from "./schema-B47aYWNu.js";
|
|
3
|
+
import { $n as t$10, A as deriveDbPosts, At as verifyCommunityEdit, Bt as getCommunityPublicKeyFromWire, C as BackupAbortError, Dt as verifyCommentPubsubMessage, E as calculateInlineRepliesBudget, Et as verifyCommentModeration, F as importSignerIntoKuboNode, Ft as getAuthorNameFromWire, G as REPLY_REPLIES_SORT_TYPES, Gt as getIpfsKeyFromPrivateKey, Ht as decode, Jn as r$2, Jt as getPublicKeyFromPrivateKey, K as TIMEFRAMES_TO_SECONDS, Kn as t$9, Kt as getPKCAddressFromPublicKey, M as getDefaultCommunityDbConfig, Mt as buildRuntimeAuthor, Nt as cleanWireAuthor, O as deleteOldCommunityInWindows, Ot as verifyCommentUpdate, P as getThumbnailPropsOfLink, R as moveCommunityDbToDeletedDirectory, S as encryptEd25519AesGcmPublicKeyBuffer, St as verifyChallengeRequest, T as calculateExpectedSignatureSize, Tt as verifyCommentIpfs, U as POSTS_SORT_TYPES, Ut as encode, W as POST_REPLIES_SORT_TYPES, Xn as n$6, Yn as t$11, Yt as createSchemaRowParser, Z as iterateOverPageCidsToFindAllCids, Zn as n$5, _ as SignerWithPublicKeyAddress, _t as signCommunity, a as pkcJsChallenges, b as decryptEd25519AesGcmPublicKeyBuffer, bt as verifyChallengeAnswer, cn as parseCommunityIpfsSchemaPassthroughWithPKCErrorIfItFails, d as MAX_FILE_SIZE_BYTES_FOR_COMMUNITY_IPFS, dt as signChallengeVerification, er as stringify, f as KeyvBetterSqlite3, ft as signComment, gt as signCommentUpdateForChallengeVerification, ht as signCommentUpdate, i as getCommunityChallengeFromCommunityChallengeSettings, it as pLimit, j as deriveDbReplies, jt as verifyVote, k as deriveCommentIpfsFromCommentTableRow, kt as verifyCommunity, l as normalizeSelfAddrsForProvider, lt as signChallengeMessage, nr as require_lodash_merge, o as TrackedInstanceRegistry, on as parseCommunityEditOptionsSchemaWithPKCErrorIfItFails, pt as signCommentEdit, qn as t$12, qt as getPKCAddressFromPublicKeySync, r as getChallengeVerification, s as LRUCache, st as cleanUpBeforePublishing, t as RpcLocalCommunity, tr as STORAGE_KEYS, vn as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, w as backupCommunityDb, wt as verifyCommentEdit, xn as parseJsonWithPKCErrorIfFails, z as resolveDbPostsCidRefs, zt as getCommunityNameFromWire } from "./rpc-local-community-ByjBdSQ5.js";
|
|
4
4
|
import { randomFillSync, randomUUID } from "node:crypto";
|
|
5
5
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
6
6
|
import Path from "node:path";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { i as __toESM, r as __require, t as __commonJSMin } from "./chunk-2rV9d50f.js";
|
|
2
|
-
import { B as isIpfsCid, Cn as CommentUpdateForChallengeVerificationSchema, Ct as findUpdatingCommunity, D as deepMergeRuntimeFields, Dt as refreshTrackedCommentAliases, E as createAbortError, En as CommentUpdateSchema, Et as listUpdatingCommunities, Fr as stringifyPrimitive, It as require_sha256, L as hideClassPrivateProps, Lt as TimeoutError, Nr as joinValues, Pr as parsedType, Pt as untrackUpdatingComment, Q as isStringDomain, Qn as n$1, Rt as pTimeout, Sr as setErrorMap, St as findUpdatingComment, Tt as listUpdatingComments, Xn as n$2, _r as PKCError, _t as timestamp, a as ChallengeRequestMessageSchema, b as areEquivalentCommunityAddresses, br as require_supports_color, cn as PubsubTopicSchema, ct as resolveWhenPredicateIsTrue, dr as require_retry, er as t$1, fr as FailedToFetchCommentIpfsFromGatewaysError, ft as shortifyAddress, ir as r, jt as trackUpdatingComment, k as doesDomainAddressHaveCapitalLetter, mt as sleepUntilTimeoutOrAbort, nn as CommunityIpfsSchema, nr as e$1, ot as removeUndefinedValuesRecursively, pt as shortifyCid, r as ChallengeMessageSchema, s as ChallengeVerificationMessageSchema, st as replaceXWithY, t as ChallengeAnswerMessageSchema, tr as e, ut as retryKuboIpfsAdd, vn as CommentIpfsSchema, vr as messages, vt as waitForUpdateInCommunityInstanceWithErrorAndTimeout, wt as listStartedCommunities, xt as findStartedCommunity, y as version_default, yr as logger_default, z as isAbortError } from "./schema-
|
|
3
|
-
import { $ as RepliesPages, $n as t$5, $t as parseCommentEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, An as RpcCidParamSchema, At as verifyCommunityEdit, B as setNativeFunctions$1, Bn as RpcFetchCidResultSchema, Bt as getCommunityPublicKeyFromWire, Cn as parseRpcCommentEventWithPKCErrorIfItFails, Ct as verifyChallengeVerification, D as createKuboRpcClient, Dn as parseVotePubsubMessagePublicationSchemaWithPKCErrorIfItFails, Dt as verifyCommentPubsubMessage, Et as verifyCommentModeration, Fn as RpcExportCommunityModLogsParamSchema, Gn as RpcUnsubscribeParamSchema, H as CommentClientsManager, Hn as RpcResolveAuthorNameResultSchema, Ht as decode, I as listCommunitiesSync, In as RpcExportCommunityModLogsResultSchema, It as normalizeCreatePublicationAuthor, Kn as t$4, L as monitorCommunitiesDirectory, Ln as RpcExportCommunityParamSchema, Lt as buildRuntimeCommunityFields, Mn as RpcCommunityIdentifierParamSchema, Mt as buildRuntimeAuthor, N as getDefaultDataPath, Nn as RpcCommunityPageParamSchema, Nt as cleanWireAuthor, On as RpcAuthorNameParamSchema, Ot as verifyCommentUpdate, Pn as RpcEditCommunityParamSchema, Pt as getAuthorNameFromRuntime, Q as parseRawPages, Qn as t$2, Rn as RpcExportCommunityResultSchema, Rt as getCommunityAddressFromRecord, Sn as parsePKCUserOptionsSchemaWithPKCErrorIfItFails, Tn as parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, Tt as verifyCommentIpfs, Un as RpcSubscriptionIdResultSchema, V as tryToDeleteCommunitiesThatFailedToBeDeletedBefore, Vn as RpcPublishChallengeAnswersParamSchema, Vt as normalizeCommunityInputFromCommunity, Wn as RpcSuccessResultSchema, Wt as getBufferedPKCAddressFromPublicKey, X as findCommentInPageInstanceRecursively, Xn as n$3, Xt as parseCidStringSchemaWithPKCErrorIfItFails, Y as extractCommunityRuntimeFieldsFromParsedPages, Yn as t$3, _n as parseCreateVoteOptionsSchemaWithPKCErrorIfItFails, a as pkcJsChallenges, at as PKCTypedEmitter, bn as parseDecryptedChallengeWithPKCErrorIfItFails, c as AddressesRewriterProxyServer, ct as signChallengeAnswer, dn as parseCreateCommentOptionsSchemaWithPKCErrorIfItFails, en as parseCommentIpfsSchemaWithPKCErrorIfItFails, et as PublicationClientsManager, f as KeyvBetterSqlite3, fn as parseCreateCommunityEditPublicationOptionsSchemaWithPKCErrorIfItFails, ft as signComment, g as decodeRpcChallengeVerificationPubsubMsg, gn as parseCreateRpcCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, h as decodeRpcChallengeRequestPubsubMsg, hn as parseCreateRemoteCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, in as parseCommunityAddressWithPKCErrorIfItFails, ir as require_undici, jn as RpcCommentRepliesPageParamSchema, jt as verifyVote, kn as RpcCancelExportParamSchema, ln as parseCreateCommentEditOptionsSchemaWithPKCErrorIfItFails, m as decodeRpcChallengePubsubMsg, mt as signCommentModeration, n as RpcRemoteCommunity, nn as parseCommentModerationPubsubMessagePublicationSchemaWithPKCErrorIfItFails, nt as InflightFetchManager, o as TrackedInstanceRegistry, ot as require_lib$1, p as decodeRpcChallengeAnswerPubsubMsg, pt as signCommentEdit, rn as parseCommentPubsubMessagePublicationWithPKCErrorIfItFails, rr as nativeFunctions$2, s as LRUCache, sn as parseCommunityEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, st as cleanUpBeforePublishing, t as RpcLocalCommunity, tt as PKCClientsManager, u as RemoteCommunity, un as parseCreateCommentModerationOptionsSchemaWithPKCErrorIfItFails, ut as signChallengeRequest, v as createSigner, vn as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, vt as signCommunityEdit, wn as parseRpcCommentUpdateEventWithPKCErrorIfItFails, wt as verifyCommentEdit, x as encryptEd25519AesGcm, xn as parseJsonWithPKCErrorIfFails, xt as verifyChallengeMessage, y as decryptEd25519AesGcm, yn as parseDecryptedChallengeVerification, yt as signVote, zn as RpcFetchCidParamSchema, zt as getCommunityNameFromWire } from "./rpc-local-community-
|
|
4
|
-
import { r as getHeliaDebugContext } from "./util-
|
|
2
|
+
import { B as isIpfsCid, Cn as CommentUpdateForChallengeVerificationSchema, Ct as findUpdatingCommunity, D as deepMergeRuntimeFields, Dt as refreshTrackedCommentAliases, E as createAbortError, En as CommentUpdateSchema, Et as listUpdatingCommunities, Fr as stringifyPrimitive, It as require_sha256, L as hideClassPrivateProps, Lt as TimeoutError, Nr as joinValues, Pr as parsedType, Pt as untrackUpdatingComment, Q as isStringDomain, Qn as n$1, Rt as pTimeout, Sr as setErrorMap, St as findUpdatingComment, Tt as listUpdatingComments, Xn as n$2, _r as PKCError, _t as timestamp, a as ChallengeRequestMessageSchema, b as areEquivalentCommunityAddresses, br as require_supports_color, cn as PubsubTopicSchema, ct as resolveWhenPredicateIsTrue, dr as require_retry, er as t$1, fr as FailedToFetchCommentIpfsFromGatewaysError, ft as shortifyAddress, ir as r, jt as trackUpdatingComment, k as doesDomainAddressHaveCapitalLetter, mt as sleepUntilTimeoutOrAbort, nn as CommunityIpfsSchema, nr as e$1, ot as removeUndefinedValuesRecursively, pt as shortifyCid, r as ChallengeMessageSchema, s as ChallengeVerificationMessageSchema, st as replaceXWithY, t as ChallengeAnswerMessageSchema, tr as e, ut as retryKuboIpfsAdd, vn as CommentIpfsSchema, vr as messages, vt as waitForUpdateInCommunityInstanceWithErrorAndTimeout, wt as listStartedCommunities, xt as findStartedCommunity, y as version_default, yr as logger_default, z as isAbortError } from "./schema-B47aYWNu.js";
|
|
3
|
+
import { $ as RepliesPages, $n as t$5, $t as parseCommentEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, An as RpcCidParamSchema, At as verifyCommunityEdit, B as setNativeFunctions$1, Bn as RpcFetchCidResultSchema, Bt as getCommunityPublicKeyFromWire, Cn as parseRpcCommentEventWithPKCErrorIfItFails, Ct as verifyChallengeVerification, D as createKuboRpcClient, Dn as parseVotePubsubMessagePublicationSchemaWithPKCErrorIfItFails, Dt as verifyCommentPubsubMessage, Et as verifyCommentModeration, Fn as RpcExportCommunityModLogsParamSchema, Gn as RpcUnsubscribeParamSchema, H as CommentClientsManager, Hn as RpcResolveAuthorNameResultSchema, Ht as decode, I as listCommunitiesSync, In as RpcExportCommunityModLogsResultSchema, It as normalizeCreatePublicationAuthor, Kn as t$4, L as monitorCommunitiesDirectory, Ln as RpcExportCommunityParamSchema, Lt as buildRuntimeCommunityFields, Mn as RpcCommunityIdentifierParamSchema, Mt as buildRuntimeAuthor, N as getDefaultDataPath, Nn as RpcCommunityPageParamSchema, Nt as cleanWireAuthor, On as RpcAuthorNameParamSchema, Ot as verifyCommentUpdate, Pn as RpcEditCommunityParamSchema, Pt as getAuthorNameFromRuntime, Q as parseRawPages, Qn as t$2, Rn as RpcExportCommunityResultSchema, Rt as getCommunityAddressFromRecord, Sn as parsePKCUserOptionsSchemaWithPKCErrorIfItFails, Tn as parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, Tt as verifyCommentIpfs, Un as RpcSubscriptionIdResultSchema, V as tryToDeleteCommunitiesThatFailedToBeDeletedBefore, Vn as RpcPublishChallengeAnswersParamSchema, Vt as normalizeCommunityInputFromCommunity, Wn as RpcSuccessResultSchema, Wt as getBufferedPKCAddressFromPublicKey, X as findCommentInPageInstanceRecursively, Xn as n$3, Xt as parseCidStringSchemaWithPKCErrorIfItFails, Y as extractCommunityRuntimeFieldsFromParsedPages, Yn as t$3, _n as parseCreateVoteOptionsSchemaWithPKCErrorIfItFails, a as pkcJsChallenges, at as PKCTypedEmitter, bn as parseDecryptedChallengeWithPKCErrorIfItFails, c as AddressesRewriterProxyServer, ct as signChallengeAnswer, dn as parseCreateCommentOptionsSchemaWithPKCErrorIfItFails, en as parseCommentIpfsSchemaWithPKCErrorIfItFails, et as PublicationClientsManager, f as KeyvBetterSqlite3, fn as parseCreateCommunityEditPublicationOptionsSchemaWithPKCErrorIfItFails, ft as signComment, g as decodeRpcChallengeVerificationPubsubMsg, gn as parseCreateRpcCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, h as decodeRpcChallengeRequestPubsubMsg, hn as parseCreateRemoteCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, in as parseCommunityAddressWithPKCErrorIfItFails, ir as require_undici, jn as RpcCommentRepliesPageParamSchema, jt as verifyVote, kn as RpcCancelExportParamSchema, ln as parseCreateCommentEditOptionsSchemaWithPKCErrorIfItFails, m as decodeRpcChallengePubsubMsg, mt as signCommentModeration, n as RpcRemoteCommunity, nn as parseCommentModerationPubsubMessagePublicationSchemaWithPKCErrorIfItFails, nt as InflightFetchManager, o as TrackedInstanceRegistry, ot as require_lib$1, p as decodeRpcChallengeAnswerPubsubMsg, pt as signCommentEdit, rn as parseCommentPubsubMessagePublicationWithPKCErrorIfItFails, rr as nativeFunctions$2, s as LRUCache, sn as parseCommunityEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, st as cleanUpBeforePublishing, t as RpcLocalCommunity, tt as PKCClientsManager, u as RemoteCommunity, un as parseCreateCommentModerationOptionsSchemaWithPKCErrorIfItFails, ut as signChallengeRequest, v as createSigner, vn as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, vt as signCommunityEdit, wn as parseRpcCommentUpdateEventWithPKCErrorIfItFails, wt as verifyCommentEdit, x as encryptEd25519AesGcm, xn as parseJsonWithPKCErrorIfFails, xt as verifyChallengeMessage, y as decryptEd25519AesGcm, yn as parseDecryptedChallengeVerification, yt as signVote, zn as RpcFetchCidParamSchema, zt as getCommunityNameFromWire } from "./rpc-local-community-ByjBdSQ5.js";
|
|
4
|
+
import { r as getHeliaDebugContext } from "./util-P3adfecj.js";
|
|
5
5
|
import path from "path";
|
|
6
6
|
import assert from "assert";
|
|
7
7
|
import fs from "fs";
|
|
@@ -2106,6 +2106,8 @@ var PKCRpcClient = class extends import_lib.TypedEmitter {
|
|
|
2106
2106
|
assert(rpcServerUrl, "pkc.pkcRpcClientsOptions needs to be defined to create a new rpc client");
|
|
2107
2107
|
this._websocketServerUrl = rpcServerUrl;
|
|
2108
2108
|
this._timeoutSeconds = 20;
|
|
2109
|
+
const envCallTimeoutMs = typeof process !== "undefined" ? Number(process.env?.["PKC_RPC_CALL_TIMEOUT_MS"]) : NaN;
|
|
2110
|
+
this._callTimeoutMs = envCallTimeoutMs > 0 ? envCallTimeoutMs : 3e5;
|
|
2109
2111
|
this.communities = [];
|
|
2110
2112
|
this._subscriptionEvents = {};
|
|
2111
2113
|
this.on("communitieschange", (newSubs) => {
|
|
@@ -2176,7 +2178,13 @@ var PKCRpcClient = class extends import_lib.TypedEmitter {
|
|
|
2176
2178
|
this._webSocketClient.call = async (...args) => {
|
|
2177
2179
|
try {
|
|
2178
2180
|
await this._init();
|
|
2179
|
-
return await originalWebsocketCall(...args)
|
|
2181
|
+
return await pTimeout(originalWebsocketCall(...args), {
|
|
2182
|
+
milliseconds: this._callTimeoutMs,
|
|
2183
|
+
message: new PKCError("ERR_RPC_CALL_TIMED_OUT", {
|
|
2184
|
+
rpcMethod: args[0],
|
|
2185
|
+
timeoutMs: this._callTimeoutMs
|
|
2186
|
+
})
|
|
2187
|
+
});
|
|
2180
2188
|
} catch (e) {
|
|
2181
2189
|
const typedError = e;
|
|
2182
2190
|
typedError.details = {
|
|
@@ -8866,7 +8874,7 @@ var PKC$1 = class extends PKCTypedEmitter {
|
|
|
8866
8874
|
this.clients.libp2pJsClients = {};
|
|
8867
8875
|
if (!this.libp2pJsClientsOptions) return;
|
|
8868
8876
|
if (!this.httpRoutersOptions) throw Error("httpRoutersOptions is required for libp2pJsClient");
|
|
8869
|
-
const { createLibp2pJsClientOrUseExistingOne } = await import("./helia-for-pkc-
|
|
8877
|
+
const { createLibp2pJsClientOrUseExistingOne } = await import("./helia-for-pkc-CTxzGps-.js");
|
|
8870
8878
|
for (const clientOptions of this.libp2pJsClientsOptions) {
|
|
8871
8879
|
const heliaNode = await createLibp2pJsClientOrUseExistingOne({
|
|
8872
8880
|
...clientOptions,
|
|
@@ -9114,7 +9122,7 @@ var PKC$1 = class extends PKCTypedEmitter {
|
|
|
9114
9122
|
const log = logger_default("pkc-js:pkc:createLocalCommunity");
|
|
9115
9123
|
log.trace("Received community options to create a local community instance:", options);
|
|
9116
9124
|
if (!this._canCreateNewLocalCommunity()) throw new PKCError("ERR_CAN_NOT_CREATE_A_LOCAL_COMMUNITY", { pkcOptions: this._userPKCOptions });
|
|
9117
|
-
const { LocalCommunity, createNewLocalCommunityDb, updateInstancePropsWithStartedCommunityOrDb } = await import("./local-community-
|
|
9125
|
+
const { LocalCommunity, createNewLocalCommunityDb, updateInstancePropsWithStartedCommunityOrDb } = await import("./local-community-DJX_xmB4.js");
|
|
9118
9126
|
const isLocalCommunity = (await listCommunitiesSync(this)).includes(options.address);
|
|
9119
9127
|
const community = new LocalCommunity(this);
|
|
9120
9128
|
if (isLocalCommunity) {
|
package/dist/bundled/chunks/{rpc-local-community-CpN6R3ZN.js → rpc-local-community-ByjBdSQ5.js}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { i as __toESM, n as __exportAll, r as __require, t as __commonJSMin } from "./chunk-2rV9d50f.js";
|
|
2
|
-
import { $ as pubsubTopicToDhtKey, $t as CommunityEditOptionsSchema, A as extractNetworkErrorDetails, An as CreateCommentOptionsWithRefinementSchema, Ar as record, At as trackStartedCommunity, B as isIpfsCid, Bn as CreateCommentEditOptionsWithRefinementSchema, Cr as _enum, Ct as findUpdatingCommunity, D as deepMergeRuntimeFields, Dn as CommentUpdateSignedPropertyNames, Dr as literal, E as createAbortError, En as CommentUpdateSchema, Er as custom, Et as listUpdatingCommunities, Ft as untrackUpdatingCommunity, Gn as CidPathSchema, Gt as CommentModerationPubsubMessagePublicationSchema, H as isIpns, Hn as AuthorCommentIpfsReservedFields, Ht as CommunityEditPubsubMessagePublicationSchema, I as getPostUpdateTimestampRange, In as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema, It as require_sha256$1, Jn as CommunityAuthorChallengeReservedFieldNames, Jt as CommentModerationsTableRowSchema, Kn as CidStringSchema, L as hideClassPrivateProps, Mn as ModQueuePageIpfsSchema, Mt as trackUpdatingCommunity, Nn as PageIpfsSchema, Nt as untrackStartedCommunity, O as derivePublicationFromChallengeRequest, Or as number, Ot as refreshTrackedCommunityAliases, Pn as CommentEditChallengeRequestToEncryptSchema, Q as isStringDomain, Qn as n$9, Qt as CommunityChallengeSettingSchema, R as ipnsNameToIpnsOverPubsubTopic, Rn as CommentEditSignedPropertyNames, Rt as pTimeout, Sn as CommentUpdateChallengeReservedFieldNames, St as findUpdatingComment, Tn as CommentUpdateReservedFields, Tr as boolean, U as isIpnsPath, Ut as CreateCommunityEditPublicationOptionsWithRefinementSchema, V as isIpfsPath, Vn as AuthorAddressSchema, Vt as CommunityEditPublicationSignedPropertyNames, Wn as ChallengeAnswersSchema, Wt as CommentModerationChallengeRequestToEncryptSchema, X as isRequestPubsubPublicationOfPost, Xn as n$10, Xt as ChallengeFileFactorySchema, Yn as CreateSignerSchema, Yt as CreateCommentModerationOptionsWithRefinementSchema, Z as isRequestPubsubPublicationOfReply, Zt as ChallengeFileSchema, _ as PKCUserOptionBaseSchema, _n as CommentIpfsReservedFields, _r as PKCError, _t as timestamp, an as CreateRemoteCommunityFunctionArgumentSchema, ar as t$12, b as areEquivalentCommunityAddresses, bn as CommentPubsubMessageWithFlexibleAuthorRefinementSchema, br as require_supports_color, c as ChallengeVerificationMessageSignedPropertyNames, cr as t$10, ct as resolveWhenPredicateIsTrue, dn as VoteChallengeRequestToEncryptSchema, dr as require_retry$1, en as CommunityExportRecordsSchema, er as t$13, f as DecryptedChallengeSchema, fn as VotePubsubMessagePublicationSchema, fr as FailedToFetchCommentIpfsFromGatewaysError, ft as shortifyAddress, g as PKCParsedOptionsSchema, gn as CommentChallengeRequestToEncryptSchema, gr as FailedToFetchPageIpfsFromGatewaysError, gt as throwIfAbortSignalAborted, h as NameResolverSerializedSchema, hr as FailedToFetchGenericIpfsFromGatewaysError, i as ChallengeMessageSignedPropertyNames, in as CreateNewLocalCommunityUserOptionsSchema, ir as r$8, it as removeNullUndefinedEmptyObjectsValuesRecursively, j as fetchAndValidateIpnsRecordFromGateway, jn as GetPageParamSchema, jr as string, k as doesDomainAddressHaveCapitalLetter, kr as object, l as DecryptedChallengeAnswerSchema, ln as RpcRemoteCommunityUpdateEventResultSchema, lr as t$9, m as NameResolveCacheOptionsSchema, mn as VoteSignedPropertyNames, mr as FailedToFetchCommunityFromGatewaysError, mt as sleepUntilTimeoutOrAbort, n as ChallengeAnswerMessageSignedPropertyNames, nn as CommunityIpfsSchema, nr as e$5, o as ChallengeRequestMessageSignedPropertyNames, on as CreateRpcCommunityFunctionArgumentSchema, or as n$8, p as DecryptedChallengeVerificationSchema, pr as FailedToFetchCommentUpdateFromGatewaysError, pt as shortifyCid, qn as CommunityAddressSchema, qt as CommentModerationSignedPropertyNames, rn as CommunitySignedPropertyNames, rr as t$11, sn as ExportCommunityModLogsOptionsSchema, sr as r$7, tn as CommunityIpfsReservedFields, tr as e$6, tt as raceAgainstAbort, un as CreateVoteUserOptionsWithRefinementSchema, ur as e$4, v as PKCUserOptionsSchema, vn as CommentIpfsSchema, vr as messages, vt as waitForUpdateInCommunityInstanceWithErrorAndTimeout, wn as CommentUpdateForChallengeVerificationSignedPropertyNames, wr as array, wt as listStartedCommunities, x as calculateIpfsCidV0, xn as CommentSignedPropertyNames, xr as require_ms$1, xt as findStartedCommunity, yr as logger_default, z as isAbortError, zt as CommunityEditPublicationChallengeRequestToEncryptSchema } from "./schema-
|
|
2
|
+
import { $ as pubsubTopicToDhtKey, $t as CommunityEditOptionsSchema, A as extractNetworkErrorDetails, An as CreateCommentOptionsWithRefinementSchema, Ar as record, At as trackStartedCommunity, B as isIpfsCid, Bn as CreateCommentEditOptionsWithRefinementSchema, Cr as _enum, Ct as findUpdatingCommunity, D as deepMergeRuntimeFields, Dn as CommentUpdateSignedPropertyNames, Dr as literal, E as createAbortError, En as CommentUpdateSchema, Er as custom, Et as listUpdatingCommunities, Ft as untrackUpdatingCommunity, Gn as CidPathSchema, Gt as CommentModerationPubsubMessagePublicationSchema, H as isIpns, Hn as AuthorCommentIpfsReservedFields, Ht as CommunityEditPubsubMessagePublicationSchema, I as getPostUpdateTimestampRange, In as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema, It as require_sha256$1, Jn as CommunityAuthorChallengeReservedFieldNames, Jt as CommentModerationsTableRowSchema, Kn as CidStringSchema, L as hideClassPrivateProps, Mn as ModQueuePageIpfsSchema, Mt as trackUpdatingCommunity, Nn as PageIpfsSchema, Nt as untrackStartedCommunity, O as derivePublicationFromChallengeRequest, Or as number, Ot as refreshTrackedCommunityAliases, Pn as CommentEditChallengeRequestToEncryptSchema, Q as isStringDomain, Qn as n$9, Qt as CommunityChallengeSettingSchema, R as ipnsNameToIpnsOverPubsubTopic, Rn as CommentEditSignedPropertyNames, Rt as pTimeout, Sn as CommentUpdateChallengeReservedFieldNames, St as findUpdatingComment, Tn as CommentUpdateReservedFields, Tr as boolean, U as isIpnsPath, Ut as CreateCommunityEditPublicationOptionsWithRefinementSchema, V as isIpfsPath, Vn as AuthorAddressSchema, Vt as CommunityEditPublicationSignedPropertyNames, Wn as ChallengeAnswersSchema, Wt as CommentModerationChallengeRequestToEncryptSchema, X as isRequestPubsubPublicationOfPost, Xn as n$10, Xt as ChallengeFileFactorySchema, Yn as CreateSignerSchema, Yt as CreateCommentModerationOptionsWithRefinementSchema, Z as isRequestPubsubPublicationOfReply, Zt as ChallengeFileSchema, _ as PKCUserOptionBaseSchema, _n as CommentIpfsReservedFields, _r as PKCError, _t as timestamp, an as CreateRemoteCommunityFunctionArgumentSchema, ar as t$12, b as areEquivalentCommunityAddresses, bn as CommentPubsubMessageWithFlexibleAuthorRefinementSchema, br as require_supports_color, c as ChallengeVerificationMessageSignedPropertyNames, cr as t$10, ct as resolveWhenPredicateIsTrue, dn as VoteChallengeRequestToEncryptSchema, dr as require_retry$1, en as CommunityExportRecordsSchema, er as t$13, f as DecryptedChallengeSchema, fn as VotePubsubMessagePublicationSchema, fr as FailedToFetchCommentIpfsFromGatewaysError, ft as shortifyAddress, g as PKCParsedOptionsSchema, gn as CommentChallengeRequestToEncryptSchema, gr as FailedToFetchPageIpfsFromGatewaysError, gt as throwIfAbortSignalAborted, h as NameResolverSerializedSchema, hr as FailedToFetchGenericIpfsFromGatewaysError, i as ChallengeMessageSignedPropertyNames, in as CreateNewLocalCommunityUserOptionsSchema, ir as r$8, it as removeNullUndefinedEmptyObjectsValuesRecursively, j as fetchAndValidateIpnsRecordFromGateway, jn as GetPageParamSchema, jr as string, k as doesDomainAddressHaveCapitalLetter, kr as object, l as DecryptedChallengeAnswerSchema, ln as RpcRemoteCommunityUpdateEventResultSchema, lr as t$9, m as NameResolveCacheOptionsSchema, mn as VoteSignedPropertyNames, mr as FailedToFetchCommunityFromGatewaysError, mt as sleepUntilTimeoutOrAbort, n as ChallengeAnswerMessageSignedPropertyNames, nn as CommunityIpfsSchema, nr as e$5, o as ChallengeRequestMessageSignedPropertyNames, on as CreateRpcCommunityFunctionArgumentSchema, or as n$8, p as DecryptedChallengeVerificationSchema, pr as FailedToFetchCommentUpdateFromGatewaysError, pt as shortifyCid, qn as CommunityAddressSchema, qt as CommentModerationSignedPropertyNames, rn as CommunitySignedPropertyNames, rr as t$11, sn as ExportCommunityModLogsOptionsSchema, sr as r$7, tn as CommunityIpfsReservedFields, tr as e$6, tt as raceAgainstAbort, un as CreateVoteUserOptionsWithRefinementSchema, ur as e$4, v as PKCUserOptionsSchema, vn as CommentIpfsSchema, vr as messages, vt as waitForUpdateInCommunityInstanceWithErrorAndTimeout, wn as CommentUpdateForChallengeVerificationSignedPropertyNames, wr as array, wt as listStartedCommunities, x as calculateIpfsCidV0, xn as CommentSignedPropertyNames, xr as require_ms$1, xt as findStartedCommunity, yr as logger_default, z as isAbortError, zt as CommunityEditPublicationChallengeRequestToEncryptSchema } from "./schema-B47aYWNu.js";
|
|
3
3
|
import { t as all } from "./src-CYIMjhjK.js";
|
|
4
4
|
import http from "node:http";
|
|
5
5
|
import { createHash } from "node:crypto";
|
|
@@ -97555,12 +97555,27 @@ const signBufferEd25519 = async (bufferToSign, privateKeyBase64) => {
|
|
|
97555
97555
|
if (privateKeyBuffer.length !== 32) throw Error(`verifyBufferEd25519 publicKeyBase64 ed25519 public key length not 32 bytes (${privateKeyBuffer.length} bytes)`);
|
|
97556
97556
|
return ed25519.sign(bufferToSign, privateKeyBuffer);
|
|
97557
97557
|
};
|
|
97558
|
+
let webCryptoEd25519Supported;
|
|
97559
|
+
const _isWebCryptoEd25519Supported = async () => {
|
|
97560
|
+
if (webCryptoEd25519Supported === void 0) try {
|
|
97561
|
+
const knownValidPublicKey = ed25519.getPublicKey(new Uint8Array(32).fill(1));
|
|
97562
|
+
await globalThis.crypto.subtle.importKey("raw", knownValidPublicKey, { name: "Ed25519" }, false, ["verify"]);
|
|
97563
|
+
webCryptoEd25519Supported = true;
|
|
97564
|
+
} catch {
|
|
97565
|
+
webCryptoEd25519Supported = false;
|
|
97566
|
+
}
|
|
97567
|
+
return webCryptoEd25519Supported;
|
|
97568
|
+
};
|
|
97558
97569
|
const verifyBufferEd25519 = async (bufferToSign, bufferSignature, publicKeyBase64) => {
|
|
97559
97570
|
if (!isProbablyBuffer$1(bufferToSign)) throw Error(`verifyBufferEd25519 invalid bufferSignature '${bufferToSign}' not buffer`);
|
|
97560
97571
|
if (!isProbablyBuffer$1(bufferSignature)) throw Error(`verifyBufferEd25519 invalid bufferSignature '${bufferSignature}' not buffer`);
|
|
97561
97572
|
if (!publicKeyBase64 || typeof publicKeyBase64 !== "string") throw Error(`verifyBufferEd25519 publicKeyBase64 '${publicKeyBase64}' not a string`);
|
|
97562
97573
|
const publicKeyBuffer = fromString(publicKeyBase64, "base64");
|
|
97563
97574
|
if (publicKeyBuffer.length !== 32) throw Error(`verifyBufferEd25519 publicKeyBase64 '${publicKeyBase64}' ed25519 public key length not 32 bytes (${publicKeyBuffer.length} bytes)`);
|
|
97575
|
+
if (await _isWebCryptoEd25519Supported()) try {
|
|
97576
|
+
const cryptoKey = await globalThis.crypto.subtle.importKey("raw", publicKeyBuffer, { name: "Ed25519" }, false, ["verify"]);
|
|
97577
|
+
if (await globalThis.crypto.subtle.verify("Ed25519", cryptoKey, bufferSignature, bufferToSign)) return true;
|
|
97578
|
+
} catch {}
|
|
97564
97579
|
return ed25519.verify(bufferSignature, bufferToSign, publicKeyBuffer);
|
|
97565
97580
|
};
|
|
97566
97581
|
async function _validateAuthorAddressBeforeSigning(author, signer, pkc) {
|
|
@@ -124788,6 +124803,8 @@ var CommunityClientsManager = class extends PKCClientsManager {
|
|
|
124788
124803
|
}
|
|
124789
124804
|
async updateOnce() {
|
|
124790
124805
|
const log = logger_default("pkc-js:remote-community:update");
|
|
124806
|
+
const publicKeyAtFetchStart = this._community.publicKey;
|
|
124807
|
+
const stopSignalAtFetchStart = this._community._getStopAbortSignal();
|
|
124791
124808
|
this._ipnsLoadingOperation = import_retry.operation({
|
|
124792
124809
|
forever: true,
|
|
124793
124810
|
factor: 2,
|
|
@@ -124795,6 +124812,10 @@ var CommunityClientsManager = class extends PKCClientsManager {
|
|
|
124795
124812
|
});
|
|
124796
124813
|
const communityLoadingRes = await this._retryLoadingCommunityAddress(this._community.address);
|
|
124797
124814
|
this._ipnsLoadingOperation.stop();
|
|
124815
|
+
if (stopSignalAtFetchStart?.aborted || this._community.publicKey !== publicKeyAtFetchStart) {
|
|
124816
|
+
log(`Community ${this._community.address} fetch result discarded: it was fetched under public key ${publicKeyAtFetchStart} but the community's operations were aborted or its public key changed to ${this._community.publicKey} mid-fetch (key migration)`);
|
|
124817
|
+
return;
|
|
124818
|
+
}
|
|
124798
124819
|
if (communityLoadingRes && "aborted" in communityLoadingRes) return;
|
|
124799
124820
|
else if (communityLoadingRes && "criticalError" in communityLoadingRes) {
|
|
124800
124821
|
if (communityLoadingRes.criticalError instanceof FailedToFetchCommunityFromGatewaysError) for (const [gatewayUrl, gatewayError] of Object.entries(communityLoadingRes.criticalError.details.gatewayToError)) log.error(`Community ${this._community.address} gateway ${gatewayUrl} non-retriable error:`, gatewayError);
|
|
@@ -5203,6 +5203,7 @@ var messages;
|
|
|
5203
5203
|
messages["ERR_REMOTE_COMMUNITY_RECEIVED_ALREADY_PROCCESSED_RECORD"] = "We loaded a community record but it's a record we already consumed before";
|
|
5204
5204
|
messages["ERR_COMMENT_RECEIVED_ALREADY_PROCESSED_COMMENT_UPDATE"] = "We loaded a CommentUpdate but it's a record we already consumed";
|
|
5205
5205
|
messages["ERR_FETCH_CID_P2P_TIMEOUT"] = "Fetching CID via Kubo-rpc-client/helia P2P has timed out";
|
|
5206
|
+
messages["ERR_INVALID_KUBO_STYLE_TIMEOUT"] = "The timeout option is not a number of milliseconds or a kubo-style duration string (e.g. \"30s\", \"2m\")";
|
|
5206
5207
|
messages["ERR_FETCH_CID_P2P_TIMEOUT_AFTER_RETRIES"] = "Fetching CID via Kubo-rpc-client/helia P2P has timed out after all retry attempts";
|
|
5207
5208
|
messages["ERR_RESOLVED_IPNS_P2P_TO_UNDEFINED"] = "Resolved IPNS name to undefined. Does this IPNS name exist?";
|
|
5208
5209
|
messages["ERR_IPNS_RESOLUTION_P2P_TIMEOUT"] = "IPNS resolution P2P timed out";
|
|
@@ -5477,6 +5478,7 @@ var messages;
|
|
|
5477
5478
|
messages["ERR_RPC_CLIENT_TRYING_TO_EDIT_REMOTE_COMMUNITY"] = "RPC client is attempting to edit remote community";
|
|
5478
5479
|
messages["ERR_RPC_CLIENT_TRYING_TO_DELETE_REMOTE_COMMUNITY"] = "RPC client is attempting to delete remote community";
|
|
5479
5480
|
messages["ERR_GENERIC_RPC_CLIENT_CALL_ERROR"] = "RPC client received an unknown error when executing call over websocket";
|
|
5481
|
+
messages["ERR_RPC_CALL_TIMED_OUT"] = "RPC client call timed out without receiving a response from the RPC server";
|
|
5480
5482
|
messages["ERR_RPC_CLIENT_CHALLENGE_NAME_NOT_AVAILABLE_ON_SERVER"] = "The challenge name is not available on the RPC server. Available challenges are listed in details.availableChallenges";
|
|
5481
5483
|
messages["ERR_ROLE_ADDRESS_NAME_COULD_NOT_BE_RESOLVED"] = "Role address name could not be resolved";
|
|
5482
5484
|
messages["ERR_COMMUNITY_NOT_LOCAL"] = "community.export() can only be called on a LocalCommunity on this daemon";
|
|
@@ -16030,7 +16032,7 @@ function extractNetworkErrorDetails(err, depth = 0) {
|
|
|
16030
16032
|
}
|
|
16031
16033
|
//#endregion
|
|
16032
16034
|
//#region dist/node/generated-version.js
|
|
16033
|
-
const version = "0.0.
|
|
16035
|
+
const version = "0.0.67";
|
|
16034
16036
|
//#endregion
|
|
16035
16037
|
//#region dist/node/version.js
|
|
16036
16038
|
const protocolVersion = ProtocolVersionSchema.parse("1.0.0");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _r as PKCError, et as pubsubTopicToDhtKeyCid } from "./schema-
|
|
1
|
+
import { _r as PKCError, et as pubsubTopicToDhtKeyCid } from "./schema-B47aYWNu.js";
|
|
2
2
|
//#region dist/node/helia/util.js
|
|
3
3
|
const TOPIC_SUBSCRIBER_WAIT_TIMEOUT_MS = 1e4;
|
|
4
4
|
const MESH_PEER_WAIT_TIMEOUT_MS = 3e3;
|
|
@@ -202,6 +202,23 @@ async function connectToPubsubPeers({ helia, pubsubTopic, maxPeers, options, log
|
|
|
202
202
|
}
|
|
203
203
|
return connectedPeersWithContent;
|
|
204
204
|
}
|
|
205
|
+
function selectBitswapSessionSeedPeers(args) {
|
|
206
|
+
if (args.connectedPeers.length === 0 || args.maxSeeds <= 0) return [];
|
|
207
|
+
const connectedByString = new Map(args.connectedPeers.map((peer) => [peer.toString(), peer]));
|
|
208
|
+
const seeds = [];
|
|
209
|
+
const seededStrings = /* @__PURE__ */ new Set();
|
|
210
|
+
const pushIfConnected = (peerIdString) => {
|
|
211
|
+
const connectedPeer = connectedByString.get(peerIdString);
|
|
212
|
+
if (connectedPeer && !seededStrings.has(peerIdString)) {
|
|
213
|
+
seededStrings.add(peerIdString);
|
|
214
|
+
seeds.push(connectedPeer);
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
args.recentIpnsRecordServerPeerIdStrings.forEach(pushIfConnected);
|
|
218
|
+
args.pubsubSubscriberPeerIdStrings.forEach(pushIfConnected);
|
|
219
|
+
for (const peer of args.connectedPeers) pushIfConnected(peer.toString());
|
|
220
|
+
return seeds.slice(0, args.maxSeeds);
|
|
221
|
+
}
|
|
205
222
|
async function directFetchIpnsRecordFromProviders({ helia, pubsubTopic, routingKey, maxPeers, validate, options, log }) {
|
|
206
223
|
if (options?.signal?.aborted) throw new PKCError("ERR_IPNS_DIRECT_FETCH_ABORTED", {
|
|
207
224
|
pubsubTopic,
|
|
@@ -266,6 +283,8 @@ async function directFetchIpnsRecordFromProviders({ helia, pubsubTopic, routingK
|
|
|
266
283
|
signal: findProvidersSignal
|
|
267
284
|
})) {
|
|
268
285
|
if (resultController.signal.aborted) break;
|
|
286
|
+
const announcedAddrs = peer.multiaddrs ?? [];
|
|
287
|
+
const hasDialableAddr = announcedAddrs.length > 0 && await helia.libp2p.isDialable(announcedAddrs);
|
|
269
288
|
dialFetchTasks.push((async () => {
|
|
270
289
|
try {
|
|
271
290
|
if (peer.multiaddrs?.length) await helia.libp2p.peerStore.merge(peer.id, { multiaddrs: peer.multiaddrs });
|
|
@@ -276,7 +295,7 @@ async function directFetchIpnsRecordFromProviders({ helia, pubsubTopic, routingK
|
|
|
276
295
|
recordErr(peer.id, e);
|
|
277
296
|
}
|
|
278
297
|
})());
|
|
279
|
-
if (++attempted >= maxPeers) {
|
|
298
|
+
if (hasDialableAddr && ++attempted >= maxPeers) {
|
|
280
299
|
findProvidersAbort.abort();
|
|
281
300
|
break;
|
|
282
301
|
}
|
|
@@ -298,4 +317,4 @@ async function directFetchIpnsRecordFromProviders({ helia, pubsubTopic, routingK
|
|
|
298
317
|
});
|
|
299
318
|
}
|
|
300
319
|
//#endregion
|
|
301
|
-
export { directFetchIpnsRecordFromProviders as n, getHeliaDebugContext as r, connectToPubsubPeers as t };
|
|
320
|
+
export { selectBitswapSessionSeedPeers as i, directFetchIpnsRecordFromProviders as n, getHeliaDebugContext as r, connectToPubsubPeers as t };
|
package/dist/bundled/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as nativeFunctions, i as getShortCid, n as challenges, o as setNativeFunctions, r as getShortAddress, t as PKC } from "./chunks/node-
|
|
1
|
+
import { a as nativeFunctions, i as getShortCid, n as challenges, o as setNativeFunctions, r as getShortAddress, t as PKC } from "./chunks/node-zemQ3e2S.js";
|
|
2
2
|
export { challenges, PKC as default, getShortAddress, getShortCid, nativeFunctions, setNativeFunctions };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { L as hideClassPrivateProps, Qn as n, _r as PKCError, er as t, st as replaceXWithY, xt as findStartedCommunity, yr as logger_default } from "../../chunks/schema-
|
|
2
|
-
import { _ as parseRpcUnsubscribeParam, c as parseRpcCancelExportParam, d as parseRpcCommunityIdentifierParam, f as parseRpcCommunityPageParam, g as parseRpcPublishChallengeAnswersParam, h as parseRpcExportCommunityParam, l as parseRpcCidParam, m as parseRpcExportCommunityModLogsParam, p as parseRpcEditCommunityParam, s as parseRpcAuthorNameParam, t as PKC, u as parseRpcCommentRepliesPageParam } from "../../chunks/node-
|
|
3
|
-
import { En as parseVoteChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, J as buildPagesRuntimeFields, Qt as parseCommentEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, Tn as parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, Zt as parseCommentChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, an as parseCommunityEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, er as stringify, it as pLimit, mn as parseCreatePKCWsServerOptionsSchemaWithPKCErrorIfItFails, on as parseCommunityEditOptionsSchemaWithPKCErrorIfItFails, ot as require_lib, pn as parseCreateNewLocalCommunityUserOptionsSchemaWithPKCErrorIfItFails, q as buildPageRuntimeFields, qn as t$1, rt as pRetry, tn as parseCommentModerationChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, vn as parseDecryptedChallengeAnswerWithPKCErrorIfItFails } from "../../chunks/rpc-local-community-
|
|
4
|
-
import { t as LocalCommunity } from "../../chunks/local-community-
|
|
1
|
+
import { L as hideClassPrivateProps, Qn as n, _r as PKCError, er as t, st as replaceXWithY, xt as findStartedCommunity, yr as logger_default } from "../../chunks/schema-B47aYWNu.js";
|
|
2
|
+
import { _ as parseRpcUnsubscribeParam, c as parseRpcCancelExportParam, d as parseRpcCommunityIdentifierParam, f as parseRpcCommunityPageParam, g as parseRpcPublishChallengeAnswersParam, h as parseRpcExportCommunityParam, l as parseRpcCidParam, m as parseRpcExportCommunityModLogsParam, p as parseRpcEditCommunityParam, s as parseRpcAuthorNameParam, t as PKC, u as parseRpcCommentRepliesPageParam } from "../../chunks/node-zemQ3e2S.js";
|
|
3
|
+
import { En as parseVoteChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, J as buildPagesRuntimeFields, Qt as parseCommentEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, Tn as parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, Zt as parseCommentChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, an as parseCommunityEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, er as stringify, it as pLimit, mn as parseCreatePKCWsServerOptionsSchemaWithPKCErrorIfItFails, on as parseCommunityEditOptionsSchemaWithPKCErrorIfItFails, ot as require_lib, pn as parseCreateNewLocalCommunityUserOptionsSchemaWithPKCErrorIfItFails, q as buildPageRuntimeFields, qn as t$1, rt as pRetry, tn as parseCommentModerationChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, vn as parseDecryptedChallengeAnswerWithPKCErrorIfItFails } from "../../chunks/rpc-local-community-ByjBdSQ5.js";
|
|
4
|
+
import { t as LocalCommunity } from "../../chunks/local-community-T3mSbjdf.js";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
6
|
import path from "path";
|
|
7
7
|
import assert from "assert";
|
|
@@ -349,12 +349,17 @@ var PKCWsServer = class extends import_lib.TypedEmitter {
|
|
|
349
349
|
}
|
|
350
350
|
}
|
|
351
351
|
rpcWebsocketsRegister(method, callback) {
|
|
352
|
+
let invocationCounter = 0;
|
|
352
353
|
const callbackWithErrorHandled = async (params, connectionId) => {
|
|
354
|
+
const invocationId = `${method}#${++invocationCounter}`;
|
|
353
355
|
try {
|
|
354
|
-
|
|
356
|
+
log.trace(`Received RPC call (${invocationId}) from connection (${connectionId})`);
|
|
357
|
+
const res = await callback(params, connectionId);
|
|
358
|
+
log.trace(`Dispatching RPC response for call (${invocationId}) to connection (${connectionId})`);
|
|
359
|
+
return res;
|
|
355
360
|
} catch (e) {
|
|
356
361
|
const typedError = e;
|
|
357
|
-
log.error(`${callback.name} error`, {
|
|
362
|
+
log.error(`${callback.name} error (${invocationId})`, {
|
|
358
363
|
params,
|
|
359
364
|
error: typedError
|
|
360
365
|
});
|
|
@@ -21,6 +21,7 @@ export default class PKCRpcClient extends TypedEmitter<PKCRpcClientEvents> {
|
|
|
21
21
|
private _subscriptionEvents;
|
|
22
22
|
private _pendingSubscriptionMsgs;
|
|
23
23
|
private _timeoutSeconds;
|
|
24
|
+
private _callTimeoutMs;
|
|
24
25
|
private _openConnectionPromise?;
|
|
25
26
|
private _destroyRequested;
|
|
26
27
|
constructor(rpcServerUrl: string);
|
|
@@ -17,6 +17,11 @@ export default class PKCRpcClient extends TypedEmitter {
|
|
|
17
17
|
assert(rpcServerUrl, "pkc.pkcRpcClientsOptions needs to be defined to create a new rpc client");
|
|
18
18
|
this._websocketServerUrl = rpcServerUrl; // default to first for now. Will change later
|
|
19
19
|
this._timeoutSeconds = 20;
|
|
20
|
+
// Generous because some calls do unbounded server-side work (e.g. startCommunity repins a whole
|
|
21
|
+
// community). Its purpose is turning a lost RPC response into a diagnosable error instead of an
|
|
22
|
+
// infinite hang (issue #195), not bounding slow calls.
|
|
23
|
+
const envCallTimeoutMs = typeof process !== "undefined" ? Number(process.env?.["PKC_RPC_CALL_TIMEOUT_MS"]) : Number.NaN;
|
|
24
|
+
this._callTimeoutMs = envCallTimeoutMs > 0 ? envCallTimeoutMs : 300_000;
|
|
20
25
|
this.communities = [];
|
|
21
26
|
this._subscriptionEvents = {};
|
|
22
27
|
this.on("communitieschange", (newSubs) => {
|
|
@@ -107,7 +112,15 @@ export default class PKCRpcClient extends TypedEmitter {
|
|
|
107
112
|
this._webSocketClient.call = async (...args) => {
|
|
108
113
|
try {
|
|
109
114
|
await this._init();
|
|
110
|
-
|
|
115
|
+
// A dropped/unmatched JSON-RPC response would otherwise leave this promise pending
|
|
116
|
+
// forever (issue #195) — rpc-websockets applies no timeout of its own
|
|
117
|
+
return await pTimeout(originalWebsocketCall(...args), {
|
|
118
|
+
milliseconds: this._callTimeoutMs,
|
|
119
|
+
message: new PKCError("ERR_RPC_CALL_TIMED_OUT", {
|
|
120
|
+
rpcMethod: args[0],
|
|
121
|
+
timeoutMs: this._callTimeoutMs
|
|
122
|
+
})
|
|
123
|
+
});
|
|
111
124
|
}
|
|
112
125
|
catch (e) {
|
|
113
126
|
const typedError = e;
|