@pkcprotocol/pkc-js 0.0.65 → 0.0.68

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.
Files changed (79) hide show
  1. package/dist/browser/clients/base-client-manager.d.ts +1 -0
  2. package/dist/browser/clients/base-client-manager.js +4 -1
  3. package/dist/browser/clients/base-client-manager.js.map +1 -1
  4. package/dist/browser/clients/rpc-client/pkc-rpc-client.d.ts +1 -0
  5. package/dist/browser/clients/rpc-client/pkc-rpc-client.js +14 -1
  6. package/dist/browser/clients/rpc-client/pkc-rpc-client.js.map +1 -1
  7. package/dist/browser/community/community-client-manager.js +13 -1
  8. package/dist/browser/community/community-client-manager.js.map +1 -1
  9. package/dist/browser/errors.d.ts +2 -0
  10. package/dist/browser/errors.js +2 -0
  11. package/dist/browser/errors.js.map +1 -1
  12. package/dist/browser/generated-version.d.ts +1 -1
  13. package/dist/browser/generated-version.js +1 -1
  14. package/dist/browser/helia/helia-for-pkc.js +167 -5
  15. package/dist/browser/helia/helia-for-pkc.js.map +1 -1
  16. package/dist/browser/helia/types.d.ts +3 -1
  17. package/dist/browser/helia/util.d.ts +7 -0
  18. package/dist/browser/helia/util.js +44 -2
  19. package/dist/browser/helia/util.js.map +1 -1
  20. package/dist/browser/pages/pages-client-manager.js +6 -1
  21. package/dist/browser/pages/pages-client-manager.js.map +1 -1
  22. package/dist/browser/pages/pages.d.ts +1 -0
  23. package/dist/browser/pages/pages.js.map +1 -1
  24. package/dist/browser/pkc-error.d.ts +1 -1
  25. package/dist/browser/publications/comment/comment-client-manager.d.ts +1 -0
  26. package/dist/browser/publications/comment/comment-client-manager.js +18 -3
  27. package/dist/browser/publications/comment/comment-client-manager.js.map +1 -1
  28. package/dist/browser/publications/comment/comment.js +6 -1
  29. package/dist/browser/publications/comment/comment.js.map +1 -1
  30. package/dist/browser/rpc/src/index.js +7 -1
  31. package/dist/browser/rpc/src/index.js.map +1 -1
  32. package/dist/browser/signer/signatures.js +26 -0
  33. package/dist/browser/signer/signatures.js.map +1 -1
  34. package/dist/browser/test/test-util.d.ts +1 -1
  35. package/dist/bundled/bundle-manifest.json +31 -31
  36. package/dist/bundled/chunks/{helia-for-pkc-h-rjuHh7.js → helia-for-pkc-R4yRqnHx.js} +102 -3
  37. package/dist/bundled/chunks/{local-community-DdDpaZqk.js → local-community-BD1ADX4_.js} +1 -1
  38. package/dist/bundled/chunks/{local-community-DEWf2apw.js → local-community-BlGJFwN6.js} +2 -2
  39. package/dist/bundled/chunks/{node-CrnvA79m.js → node-LHrRDb4V.js} +15 -6
  40. package/dist/bundled/chunks/{rpc-local-community-CpN6R3ZN.js → rpc-local-community-DCOszS5C.js} +39 -7
  41. package/dist/bundled/chunks/{schema-Db4geGeo.js → schema-V4BgFltI.js} +3 -1
  42. package/dist/bundled/chunks/{util-DrHyKxFe.js → util-BOhb3f5T.js} +22 -3
  43. package/dist/bundled/index.js +1 -1
  44. package/dist/bundled/rpc/src/index.js +11 -6
  45. package/dist/node/clients/base-client-manager.d.ts +1 -0
  46. package/dist/node/clients/base-client-manager.js +4 -1
  47. package/dist/node/clients/base-client-manager.js.map +1 -1
  48. package/dist/node/clients/rpc-client/pkc-rpc-client.d.ts +1 -0
  49. package/dist/node/clients/rpc-client/pkc-rpc-client.js +14 -1
  50. package/dist/node/clients/rpc-client/pkc-rpc-client.js.map +1 -1
  51. package/dist/node/community/community-client-manager.js +13 -1
  52. package/dist/node/community/community-client-manager.js.map +1 -1
  53. package/dist/node/errors.d.ts +2 -0
  54. package/dist/node/errors.js +2 -0
  55. package/dist/node/errors.js.map +1 -1
  56. package/dist/node/generated-version.d.ts +1 -1
  57. package/dist/node/generated-version.js +1 -1
  58. package/dist/node/helia/helia-for-pkc.js +167 -5
  59. package/dist/node/helia/helia-for-pkc.js.map +1 -1
  60. package/dist/node/helia/types.d.ts +3 -1
  61. package/dist/node/helia/util.d.ts +7 -0
  62. package/dist/node/helia/util.js +44 -2
  63. package/dist/node/helia/util.js.map +1 -1
  64. package/dist/node/pages/pages-client-manager.js +6 -1
  65. package/dist/node/pages/pages-client-manager.js.map +1 -1
  66. package/dist/node/pages/pages.d.ts +1 -0
  67. package/dist/node/pages/pages.js.map +1 -1
  68. package/dist/node/pkc-error.d.ts +1 -1
  69. package/dist/node/publications/comment/comment-client-manager.d.ts +1 -0
  70. package/dist/node/publications/comment/comment-client-manager.js +18 -3
  71. package/dist/node/publications/comment/comment-client-manager.js.map +1 -1
  72. package/dist/node/publications/comment/comment.js +6 -1
  73. package/dist/node/publications/comment/comment.js.map +1 -1
  74. package/dist/node/rpc/src/index.js +7 -1
  75. package/dist/node/rpc/src/index.js.map +1 -1
  76. package/dist/node/signer/signatures.js +26 -0
  77. package/dist/node/signer/signatures.js.map +1 -1
  78. package/dist/node/test/test-util.d.ts +1 -1
  79. package/package.json +1 -1
@@ -14,7 +14,7 @@
14
14
  "node:module"
15
15
  ],
16
16
  "dynamicImports": [
17
- "chunks/node-CrnvA79m.js"
17
+ "chunks/node-LHrRDb4V.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-CrnvA79m.js"
27
+ "chunks/node-LHrRDb4V.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-CpN6R3ZN.js",
36
- "chunks/node-CrnvA79m.js",
37
- "chunks/schema-Db4geGeo.js",
38
- "chunks/local-community-DEWf2apw.js",
35
+ "chunks/rpc-local-community-DCOszS5C.js",
36
+ "chunks/node-LHrRDb4V.js",
37
+ "chunks/schema-V4BgFltI.js",
38
+ "chunks/local-community-BlGJFwN6.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-h-rjuHh7.js": {
67
+ "chunks/helia-for-pkc-R4yRqnHx.js": {
68
68
  "isEntry": false,
69
69
  "imports": [
70
- "chunks/schema-Db4geGeo.js",
71
- "chunks/util-DrHyKxFe.js",
70
+ "chunks/schema-V4BgFltI.js",
71
+ "chunks/util-BOhb3f5T.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-DEWf2apw.js": {
97
+ "chunks/local-community-BD1ADX4_.js": {
98
+ "isEntry": false,
99
+ "imports": [
100
+ "chunks/local-community-BlGJFwN6.js"
101
+ ],
102
+ "dynamicImports": [],
103
+ "inputs": []
104
+ },
105
+ "chunks/local-community-BlGJFwN6.js": {
98
106
  "isEntry": false,
99
107
  "imports": [
100
108
  "chunks/chunk-2rV9d50f.js",
101
- "chunks/rpc-local-community-CpN6R3ZN.js",
102
- "chunks/schema-Db4geGeo.js",
109
+ "chunks/rpc-local-community-DCOszS5C.js",
110
+ "chunks/schema-V4BgFltI.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/local-community-DdDpaZqk.js": {
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-LHrRDb4V.js": {
164
164
  "isEntry": false,
165
165
  "imports": [
166
166
  "chunks/chunk-2rV9d50f.js",
167
- "chunks/rpc-local-community-CpN6R3ZN.js",
168
- "chunks/schema-Db4geGeo.js",
169
- "chunks/util-DrHyKxFe.js",
167
+ "chunks/rpc-local-community-DCOszS5C.js",
168
+ "chunks/schema-V4BgFltI.js",
169
+ "chunks/util-BOhb3f5T.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-h-rjuHh7.js",
181
- "chunks/local-community-DEWf2apw.js"
180
+ "chunks/helia-for-pkc-R4yRqnHx.js",
181
+ "chunks/local-community-BlGJFwN6.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-CpN6R3ZN.js": {
234
+ "chunks/rpc-local-community-DCOszS5C.js": {
235
235
  "isEntry": false,
236
236
  "imports": [
237
237
  "chunks/chunk-2rV9d50f.js",
238
- "chunks/schema-Db4geGeo.js",
238
+ "chunks/schema-V4BgFltI.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-Db4geGeo.js": {
794
+ "chunks/schema-V4BgFltI.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-DrHyKxFe.js": {
1231
+ "chunks/util-BOhb3f5T.js": {
1232
1232
  "isEntry": false,
1233
1233
  "imports": [
1234
- "chunks/schema-Db4geGeo.js"
1234
+ "chunks/schema-V4BgFltI.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-Db4geGeo.js";
2
- import { n as directFetchIpnsRecordFromProviders, r as getHeliaDebugContext, t as connectToPubsubPeers } from "./util-DrHyKxFe.js";
1
+ import { L as hideClassPrivateProps, R as ipnsNameToIpnsOverPubsubTopic, _r as PKCError, yr as logger_default } from "./schema-V4BgFltI.js";
2
+ import { i as selectBitswapSessionSeedPeers, n as directFetchIpnsRecordFromProviders, r as getHeliaDebugContext, t as connectToPubsubPeers } from "./util-BOhb3f5T.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,58 @@ 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 getBitswapSessionSeedPeers = (scopeIpnsPubsubTopic) => {
134
+ const pubsub = helia.libp2p.services.pubsub;
135
+ return selectBitswapSessionSeedPeers({
136
+ connectedPeers: helia.libp2p.getPeers(),
137
+ scopedPubsubSubscriberPeerIdStrings: scopeIpnsPubsubTopic ? pubsub.getSubscribers(scopeIpnsPubsubTopic).map(String) : [],
138
+ pubsubSubscriberPeerIdStrings: pubsub.getTopics().flatMap((topic) => pubsub.getSubscribers(topic).map(String)),
139
+ maxSeeds: MAX_BITSWAP_SESSION_SEED_PEERS
140
+ });
141
+ };
142
+ const KUBO_DURATION_UNIT_TO_MS = {
143
+ ns: 1e-6,
144
+ us: .001,
145
+ µs: .001,
146
+ ms: 1,
147
+ s: 1e3,
148
+ m: 6e4,
149
+ h: 36e5
150
+ };
151
+ const parseKuboStyleTimeoutMs = (timeout) => {
152
+ if (timeout === void 0 || timeout === null) return void 0;
153
+ if (typeof timeout === "number" && Number.isFinite(timeout) && timeout > 0) return timeout;
154
+ if (typeof timeout === "string") {
155
+ let totalMs = 0;
156
+ let matchedLength = 0;
157
+ for (const component of timeout.matchAll(/(\d+(?:\.\d+)?)(ns|us|µs|ms|s|m|h)/g)) {
158
+ totalMs += parseFloat(component[1]) * KUBO_DURATION_UNIT_TO_MS[component[2]];
159
+ matchedLength += component[0].length;
160
+ }
161
+ if (matchedLength === timeout.length && totalMs > 0) return totalMs;
162
+ }
163
+ throw new PKCError("ERR_INVALID_KUBO_STYLE_TIMEOUT", { invalidTimeout: timeout });
164
+ };
165
+ const SESSION_NO_PROVIDERS_RETRY_BASE_DELAY_MS = 500;
166
+ const isCausedByInsufficientProviders = (error) => {
167
+ if (!(error instanceof Error)) return false;
168
+ if (error.name === "InsufficientProvidersError") return true;
169
+ if (error instanceof AggregateError && error.errors.some(isCausedByInsufficientProviders)) return true;
170
+ return isCausedByInsufficientProviders(error.cause);
171
+ };
172
+ const delayAbortable = (ms, signal) => new Promise((resolve) => {
173
+ if (signal.aborted) return resolve();
174
+ const onAbort = () => {
175
+ clearTimeout(timer);
176
+ resolve();
177
+ };
178
+ const timer = setTimeout(() => {
179
+ signal.removeEventListener("abort", onAbort);
180
+ resolve();
181
+ }, ms);
182
+ signal.addEventListener("abort", onAbort, { once: true });
183
+ });
132
184
  const ipnsNameResolver = ipns(helia, { routers: [pubsub(helia)] });
133
185
  ipnsNameResolver.routers = ipnsNameResolver.routers.filter((r) => r?.constructor?.name !== "LocalStoreRouting");
134
186
  const WARMUP_MAX_PEERS = 4;
@@ -259,7 +311,54 @@ async function createLibp2pJsClientOrUseExistingOne(pkcOptions) {
259
311
  } },
260
312
  cat(ipfsPath, options) {
261
313
  throwIfHeliaIsStoppingOrStopped();
262
- return heliaFs.cat(asHeliaCatCid(ipfsPath), options);
314
+ const rootCid = CID.parse(ipfsPath.split("/")[0]);
315
+ const timeoutMs = parseKuboStyleTimeoutMs(options?.timeout);
316
+ const { bitswapSessionSeedScopeIpnsPubsubTopic, ...unixfsCatOptions } = options ?? {};
317
+ return (async function* () {
318
+ const controller = new AbortController();
319
+ const callerSignal = options?.signal;
320
+ const abortFromCallerSignal = () => controller.abort(callerSignal?.reason);
321
+ if (callerSignal?.aborted) abortFromCallerSignal();
322
+ else callerSignal?.addEventListener("abort", abortFromCallerSignal, { once: true });
323
+ const timeoutTimer = timeoutMs !== void 0 ? setTimeout(() => controller.abort(new PKCError("ERR_FETCH_CID_P2P_TIMEOUT", {
324
+ ipfsPath,
325
+ timeoutMs
326
+ })), timeoutMs) : void 0;
327
+ try {
328
+ for (let attempt = 0;; attempt++) {
329
+ const session = helia.blockstore.createSession(rootCid, { providers: getBitswapSessionSeedPeers(bitswapSessionSeedScopeIpnsPubsubTopic) });
330
+ let yieldedAnyBytes = false;
331
+ try {
332
+ const catIterable = unixfs({ blockstore: session }).cat(asHeliaCatCid(ipfsPath), {
333
+ ...unixfsCatOptions,
334
+ signal: controller.signal
335
+ });
336
+ for await (const chunk of catIterable) {
337
+ yieldedAnyBytes = true;
338
+ yield chunk;
339
+ }
340
+ return;
341
+ } catch (catError) {
342
+ if (controller.signal.aborted) throw controller.signal.reason instanceof Error ? controller.signal.reason : catError;
343
+ if (yieldedAnyBytes || !isCausedByInsufficientProviders(catError)) throw catError;
344
+ log.trace("Bitswap session found no providers for", ipfsPath, "- retrying, attempt", attempt + 1);
345
+ } finally {
346
+ session.close();
347
+ }
348
+ await delayAbortable(Math.min(SESSION_NO_PROVIDERS_RETRY_BASE_DELAY_MS * 2 ** attempt, 8e3), controller.signal);
349
+ if (controller.signal.aborted) {
350
+ if (controller.signal.reason instanceof Error) throw controller.signal.reason;
351
+ throw new PKCError("ERR_FETCH_CID_P2P_TIMEOUT", {
352
+ ipfsPath,
353
+ timeoutMs
354
+ });
355
+ }
356
+ }
357
+ } finally {
358
+ if (timeoutTimer !== void 0) clearTimeout(timeoutTimer);
359
+ callerSignal?.removeEventListener("abort", abortFromCallerSignal);
360
+ }
361
+ })();
263
362
  },
264
363
  pubsub: {
265
364
  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-DEWf2apw.js";
1
+ import { n as createNewLocalCommunityDb, r as updateInstancePropsWithStartedCommunityOrDb, t as LocalCommunity } from "./local-community-BlGJFwN6.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-Db4geGeo.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-CpN6R3ZN.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-V4BgFltI.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-DCOszS5C.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-Db4geGeo.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-CpN6R3ZN.js";
4
- import { r as getHeliaDebugContext } from "./util-DrHyKxFe.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, H as isIpns, 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, R as ipnsNameToIpnsOverPubsubTopic, 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-V4BgFltI.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-DCOszS5C.js";
4
+ import { r as getHeliaDebugContext } from "./util-BOhb3f5T.js";
5
5
  import path from "path";
6
6
  import assert from "assert";
7
7
  import fs from "fs";
@@ -1389,6 +1389,7 @@ var Comment = class extends Publication {
1389
1389
  super.setCommunityAddress(newCommunityAddress);
1390
1390
  this.replies._community.publicKey = this.communityPublicKey;
1391
1391
  this.replies._community.name = this.communityName;
1392
+ this.replies._community.ipnsPubsubTopic = isIpns(newCommunityAddress) ? ipnsNameToIpnsOverPubsubTopic(newCommunityAddress) : void 0;
1392
1393
  }
1393
1394
  _isCommentIpfsErrorRetriable(err) {
1394
1395
  if (!(err instanceof PKCError)) return false;
@@ -2106,6 +2107,8 @@ var PKCRpcClient = class extends import_lib.TypedEmitter {
2106
2107
  assert(rpcServerUrl, "pkc.pkcRpcClientsOptions needs to be defined to create a new rpc client");
2107
2108
  this._websocketServerUrl = rpcServerUrl;
2108
2109
  this._timeoutSeconds = 20;
2110
+ const envCallTimeoutMs = typeof process !== "undefined" ? Number(process.env?.["PKC_RPC_CALL_TIMEOUT_MS"]) : NaN;
2111
+ this._callTimeoutMs = envCallTimeoutMs > 0 ? envCallTimeoutMs : 3e5;
2109
2112
  this.communities = [];
2110
2113
  this._subscriptionEvents = {};
2111
2114
  this.on("communitieschange", (newSubs) => {
@@ -2176,7 +2179,13 @@ var PKCRpcClient = class extends import_lib.TypedEmitter {
2176
2179
  this._webSocketClient.call = async (...args) => {
2177
2180
  try {
2178
2181
  await this._init();
2179
- return await originalWebsocketCall(...args);
2182
+ return await pTimeout(originalWebsocketCall(...args), {
2183
+ milliseconds: this._callTimeoutMs,
2184
+ message: new PKCError("ERR_RPC_CALL_TIMED_OUT", {
2185
+ rpcMethod: args[0],
2186
+ timeoutMs: this._callTimeoutMs
2187
+ })
2188
+ });
2180
2189
  } catch (e) {
2181
2190
  const typedError = e;
2182
2191
  typedError.details = {
@@ -8866,7 +8875,7 @@ var PKC$1 = class extends PKCTypedEmitter {
8866
8875
  this.clients.libp2pJsClients = {};
8867
8876
  if (!this.libp2pJsClientsOptions) return;
8868
8877
  if (!this.httpRoutersOptions) throw Error("httpRoutersOptions is required for libp2pJsClient");
8869
- const { createLibp2pJsClientOrUseExistingOne } = await import("./helia-for-pkc-h-rjuHh7.js");
8878
+ const { createLibp2pJsClientOrUseExistingOne } = await import("./helia-for-pkc-R4yRqnHx.js");
8870
8879
  for (const clientOptions of this.libp2pJsClientsOptions) {
8871
8880
  const heliaNode = await createLibp2pJsClientOrUseExistingOne({
8872
8881
  ...clientOptions,
@@ -9114,7 +9123,7 @@ var PKC$1 = class extends PKCTypedEmitter {
9114
9123
  const log = logger_default("pkc-js:pkc:createLocalCommunity");
9115
9124
  log.trace("Received community options to create a local community instance:", options);
9116
9125
  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-DdDpaZqk.js");
9126
+ const { LocalCommunity, createNewLocalCommunityDb, updateInstancePropsWithStartedCommunityOrDb } = await import("./local-community-BD1ADX4_.js");
9118
9127
  const isLocalCommunity = (await listCommunitiesSync(this)).includes(options.address);
9119
9128
  const community = new LocalCommunity(this);
9120
9129
  if (isLocalCommunity) {
@@ -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-Db4geGeo.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-V4BgFltI.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) {
@@ -99026,12 +99041,14 @@ var BaseClientsManager = class BaseClientsManager {
99026
99041
  async _fetchCidP2P(cidV0, loadOpts) {
99027
99042
  const log = logger_default("pkc-js:clients-manager:_fetchCidP2P");
99028
99043
  throwIfAbortSignalAborted(loadOpts.abortSignal);
99029
- this.getDefaultKuboRpcClientOrHelia();
99044
+ const kuboRpcOrHelia = this.getDefaultKuboRpcClientOrHelia();
99030
99045
  const ipfsClient = this.getIpfsClientWithKuboRpcClientFunctions();
99031
99046
  const fetchPromise = async () => {
99047
+ const seedScopeOptions = "_helia" in kuboRpcOrHelia && loadOpts.bitswapSessionSeedScopeIpnsPubsubTopic ? { bitswapSessionSeedScopeIpnsPubsubTopic: loadOpts.bitswapSessionSeedScopeIpnsPubsubTopic } : void 0;
99032
99048
  const data = concat(await all(ipfsClient.cat(cidV0, {
99033
99049
  length: loadOpts.maxFileSizeBytes,
99034
- timeout: `${loadOpts.timeoutMs}ms`
99050
+ timeout: `${loadOpts.timeoutMs}ms`,
99051
+ ...seedScopeOptions
99035
99052
  })));
99036
99053
  const fileContent = toString(data);
99037
99054
  if (typeof fileContent !== "string") {
@@ -99797,7 +99814,8 @@ var BasePagesClientsManager = class extends BaseClientsManager {
99797
99814
  const rawJson = await this._retryTransientP2PFetch(() => this._fetchCidP2P(pageCid, {
99798
99815
  maxFileSizeBytes: pageMaxSize,
99799
99816
  timeoutMs: pageTimeoutMs,
99800
- abortSignal
99817
+ abortSignal,
99818
+ bitswapSessionSeedScopeIpnsPubsubTopic: this._pages._community.ipnsPubsubTopic
99801
99819
  }), {
99802
99820
  log,
99803
99821
  context: `page ${pageCid}`,
@@ -100848,6 +100866,11 @@ var CommentClientsManager = class extends PublicationClientsManager {
100848
100866
  _calculatePathForPostCommentUpdate(folderCid, postCid) {
100849
100867
  return `${folderCid}/` + postCid + "/update";
100850
100868
  }
100869
+ _bitswapSessionSeedScopeIpnsPubsubTopic() {
100870
+ if (this._communityForUpdating?.community?.ipnsPubsubTopic) return this._communityForUpdating.community.ipnsPubsubTopic;
100871
+ const communityAddress = this._comment.communityAddress;
100872
+ if (communityAddress && isIpns(communityAddress)) return ipnsNameToIpnsOverPubsubTopic(communityAddress);
100873
+ }
100851
100874
  _updateKuboRpcClientOrHeliaState(newState, kuboRpcOrHelia) {
100852
100875
  if ("_helia" in kuboRpcOrHelia) this.updateLibp2pJsClientState(newState, kuboRpcOrHelia._libp2pJsClientsOptions.key);
100853
100876
  else this.updateKuboRpcState(newState, kuboRpcOrHelia.url);
@@ -100874,7 +100897,8 @@ var CommentClientsManager = class extends PublicationClientsManager {
100874
100897
  res = await this._retryTransientP2PFetch(() => this._fetchCidP2P(path, {
100875
100898
  maxFileSizeBytes: MAX_FILE_SIZE_BYTES_FOR_COMMENT_UPDATE,
100876
100899
  timeoutMs: commentUpdateTimeoutMs,
100877
- abortSignal
100900
+ abortSignal,
100901
+ bitswapSessionSeedScopeIpnsPubsubTopic: this._bitswapSessionSeedScopeIpnsPubsubTopic()
100878
100902
  }), {
100879
100903
  abortSignal,
100880
100904
  log,
@@ -101075,7 +101099,8 @@ var CommentClientsManager = class extends PublicationClientsManager {
101075
101099
  commentRawString = await this._fetchCidP2P(cid, {
101076
101100
  maxFileSizeBytes: 1024 * 1024,
101077
101101
  timeoutMs: commentTimeoutMs,
101078
- abortSignal: this._comment._getStopAbortSignal()
101102
+ abortSignal: this._comment._getStopAbortSignal(),
101103
+ bitswapSessionSeedScopeIpnsPubsubTopic: this._bitswapSessionSeedScopeIpnsPubsubTopic()
101079
101104
  });
101080
101105
  } catch (e) {
101081
101106
  e.details = {
@@ -124788,6 +124813,8 @@ var CommunityClientsManager = class extends PKCClientsManager {
124788
124813
  }
124789
124814
  async updateOnce() {
124790
124815
  const log = logger_default("pkc-js:remote-community:update");
124816
+ const publicKeyAtFetchStart = this._community.publicKey;
124817
+ const stopSignalAtFetchStart = this._community._getStopAbortSignal();
124791
124818
  this._ipnsLoadingOperation = import_retry.operation({
124792
124819
  forever: true,
124793
124820
  factor: 2,
@@ -124795,6 +124822,10 @@ var CommunityClientsManager = class extends PKCClientsManager {
124795
124822
  });
124796
124823
  const communityLoadingRes = await this._retryLoadingCommunityAddress(this._community.address);
124797
124824
  this._ipnsLoadingOperation.stop();
124825
+ if (stopSignalAtFetchStart?.aborted || this._community.publicKey !== publicKeyAtFetchStart) {
124826
+ 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)`);
124827
+ return;
124828
+ }
124798
124829
  if (communityLoadingRes && "aborted" in communityLoadingRes) return;
124799
124830
  else if (communityLoadingRes && "criticalError" in communityLoadingRes) {
124800
124831
  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);
@@ -124988,7 +125019,8 @@ var CommunityClientsManager = class extends PKCClientsManager {
124988
125019
  rawCommunityJsonString = await this._fetchCidP2P(latestCommunityCid, {
124989
125020
  maxFileSizeBytes: MAX_FILE_SIZE_BYTES_FOR_COMMUNITY_IPFS,
124990
125021
  timeoutMs: this._pkc._timeouts["community-ipfs"],
124991
- abortSignal: this._community._getStopAbortSignal()
125022
+ abortSignal: this._community._getStopAbortSignal(),
125023
+ bitswapSessionSeedScopeIpnsPubsubTopic: this._community.ipnsPubsubTopic
124992
125024
  });
124993
125025
  } catch (e) {
124994
125026
  e.details = {
@@ -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.65";
16035
+ const version = "0.0.68";
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-Db4geGeo.js";
1
+ import { _r as PKCError, et as pubsubTopicToDhtKeyCid } from "./schema-V4BgFltI.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.scopedPubsubSubscriberPeerIdStrings.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 };
@@ -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-CrnvA79m.js";
1
+ import { a as nativeFunctions, i as getShortCid, n as challenges, o as setNativeFunctions, r as getShortAddress, t as PKC } from "./chunks/node-LHrRDb4V.js";
2
2
  export { challenges, PKC as default, getShortAddress, getShortCid, nativeFunctions, setNativeFunctions };