@pkcprotocol/pkc-js 0.0.146 → 0.0.148

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 (102) hide show
  1. package/README.md +88 -55
  2. package/dist/browser/clients/base-client-manager.js +14 -2
  3. package/dist/browser/clients/base-client-manager.js.map +1 -1
  4. package/dist/browser/errors.d.ts +3 -0
  5. package/dist/browser/errors.js +3 -0
  6. package/dist/browser/errors.js.map +1 -1
  7. package/dist/browser/generated-version.d.ts +1 -1
  8. package/dist/browser/generated-version.js +1 -1
  9. package/dist/browser/pkc-error.d.ts +1 -1
  10. package/dist/browser/publications/comment/comment-client-manager.d.ts +15 -3
  11. package/dist/browser/publications/comment/comment-client-manager.js +221 -10
  12. package/dist/browser/publications/comment/comment-client-manager.js.map +1 -1
  13. package/dist/browser/publications/comment/comment.js +1 -0
  14. package/dist/browser/publications/comment/comment.js.map +1 -1
  15. package/dist/browser/runtime/node/community/challenges/exclude/exclude.js +1 -1
  16. package/dist/browser/runtime/node/community/challenges/exclude/exclude.js.map +1 -1
  17. package/dist/browser/runtime/node/community/challenges/exclude/rate-limiter.d.ts +2 -2
  18. package/dist/browser/runtime/node/community/challenges/exclude/rate-limiter.js +21 -17
  19. package/dist/browser/runtime/node/community/challenges/exclude/rate-limiter.js.map +1 -1
  20. package/dist/browser/runtime/node/community/challenges/index.js +1 -1
  21. package/dist/browser/runtime/node/community/challenges/index.js.map +1 -1
  22. package/dist/browser/runtime/node/community/db-handler.d.ts +5 -1
  23. package/dist/browser/runtime/node/community/db-handler.js +64 -12
  24. package/dist/browser/runtime/node/community/db-handler.js.map +1 -1
  25. package/dist/browser/runtime/node/community/local-community/challenges.js +21 -11
  26. package/dist/browser/runtime/node/community/local-community/challenges.js.map +1 -1
  27. package/dist/browser/runtime/node/community/local-community/db-state.js +95 -13
  28. package/dist/browser/runtime/node/community/local-community/db-state.js.map +1 -1
  29. package/dist/browser/runtime/node/community/local-community/editing.js +92 -22
  30. package/dist/browser/runtime/node/community/local-community/editing.js.map +1 -1
  31. package/dist/browser/runtime/node/community/local-community/lifecycle.d.ts +2 -0
  32. package/dist/browser/runtime/node/community/local-community/lifecycle.js +72 -20
  33. package/dist/browser/runtime/node/community/local-community/lifecycle.js.map +1 -1
  34. package/dist/browser/runtime/node/community/local-community/publication-store.js +9 -0
  35. package/dist/browser/runtime/node/community/local-community/publication-store.js.map +1 -1
  36. package/dist/browser/runtime/node/community/local-community.d.ts +1 -0
  37. package/dist/browser/runtime/node/community/local-community.js +3 -0
  38. package/dist/browser/runtime/node/community/local-community.js.map +1 -1
  39. package/dist/browser/runtime/node/util.d.ts +9 -0
  40. package/dist/browser/runtime/node/util.js +141 -25
  41. package/dist/browser/runtime/node/util.js.map +1 -1
  42. package/dist/browser/test/test-util.d.ts +7 -1
  43. package/dist/browser/test/test-util.js +45 -16
  44. package/dist/browser/test/test-util.js.map +1 -1
  45. package/dist/bundled/bundle-manifest.json +40 -40
  46. package/dist/bundled/challenges.js +1 -1
  47. package/dist/bundled/chunks/{helia-for-pkc-PaZmkxgn.js → helia-for-pkc-BUVgQgXa.js} +33 -33
  48. package/dist/bundled/chunks/{local-community-CeuVhBBn.js → local-community-GWqz4s3g.js} +1 -1
  49. package/dist/bundled/chunks/{local-community-BY1ouP1-.js → local-community-dVaQtJNM.js} +292 -91
  50. package/dist/bundled/chunks/{node-BXilwSVE.js → node-fEBX1Nar.js} +162 -16
  51. package/dist/bundled/chunks/{page-sort-scoring-DgSzIxmE.js → page-sort-scoring-DbI7k_K5.js} +1 -1
  52. package/dist/bundled/chunks/{rpc-local-community-BK_HGb_u.js → rpc-local-community-ouDezuGZ.js} +146 -47
  53. package/dist/bundled/chunks/{util-Bnqvxk-6.js → util-B81IOt07.js} +4 -1
  54. package/dist/bundled/chunks/{util-DRSzW-LU.js → util-DofMBAFz.js} +1 -1
  55. package/dist/bundled/chunks/{validate-package-factories-MG5ehoSU.js → validate-package-factories-Bi1OLIPw.js} +2 -2
  56. package/dist/bundled/index.js +1 -1
  57. package/dist/bundled/page-sorts.js +1 -1
  58. package/dist/bundled/rpc/src/index.js +4 -4
  59. package/dist/node/clients/base-client-manager.js +14 -2
  60. package/dist/node/clients/base-client-manager.js.map +1 -1
  61. package/dist/node/errors.d.ts +3 -0
  62. package/dist/node/errors.js +3 -0
  63. package/dist/node/errors.js.map +1 -1
  64. package/dist/node/generated-version.d.ts +1 -1
  65. package/dist/node/generated-version.js +1 -1
  66. package/dist/node/pkc-error.d.ts +1 -1
  67. package/dist/node/publications/comment/comment-client-manager.d.ts +15 -3
  68. package/dist/node/publications/comment/comment-client-manager.js +221 -10
  69. package/dist/node/publications/comment/comment-client-manager.js.map +1 -1
  70. package/dist/node/publications/comment/comment.js +1 -0
  71. package/dist/node/publications/comment/comment.js.map +1 -1
  72. package/dist/node/runtime/node/community/challenges/exclude/exclude.js +1 -1
  73. package/dist/node/runtime/node/community/challenges/exclude/exclude.js.map +1 -1
  74. package/dist/node/runtime/node/community/challenges/exclude/rate-limiter.d.ts +2 -2
  75. package/dist/node/runtime/node/community/challenges/exclude/rate-limiter.js +21 -17
  76. package/dist/node/runtime/node/community/challenges/exclude/rate-limiter.js.map +1 -1
  77. package/dist/node/runtime/node/community/challenges/index.js +1 -1
  78. package/dist/node/runtime/node/community/challenges/index.js.map +1 -1
  79. package/dist/node/runtime/node/community/db-handler.d.ts +5 -1
  80. package/dist/node/runtime/node/community/db-handler.js +64 -12
  81. package/dist/node/runtime/node/community/db-handler.js.map +1 -1
  82. package/dist/node/runtime/node/community/local-community/challenges.js +21 -11
  83. package/dist/node/runtime/node/community/local-community/challenges.js.map +1 -1
  84. package/dist/node/runtime/node/community/local-community/db-state.js +95 -13
  85. package/dist/node/runtime/node/community/local-community/db-state.js.map +1 -1
  86. package/dist/node/runtime/node/community/local-community/editing.js +92 -22
  87. package/dist/node/runtime/node/community/local-community/editing.js.map +1 -1
  88. package/dist/node/runtime/node/community/local-community/lifecycle.d.ts +2 -0
  89. package/dist/node/runtime/node/community/local-community/lifecycle.js +72 -20
  90. package/dist/node/runtime/node/community/local-community/lifecycle.js.map +1 -1
  91. package/dist/node/runtime/node/community/local-community/publication-store.js +9 -0
  92. package/dist/node/runtime/node/community/local-community/publication-store.js.map +1 -1
  93. package/dist/node/runtime/node/community/local-community.d.ts +1 -0
  94. package/dist/node/runtime/node/community/local-community.js +3 -0
  95. package/dist/node/runtime/node/community/local-community.js.map +1 -1
  96. package/dist/node/runtime/node/util.d.ts +9 -0
  97. package/dist/node/runtime/node/util.js +141 -25
  98. package/dist/node/runtime/node/util.js.map +1 -1
  99. package/dist/node/test/test-util.d.ts +7 -1
  100. package/dist/node/test/test-util.js +45 -16
  101. package/dist/node/test/test-util.js.map +1 -1
  102. package/package.json +1 -1
@@ -1,12 +1,12 @@
1
1
  import { i as __toESM, n as __exportAll, r as __require, t as __commonJSMin } from "./chunk-2rV9d50f.js";
2
- import { $n as CommentEditSignedPropertyNames, $r as record, $t as CommunityEditPubsubMessagePublicationSchema, A as isIpnsPath, An as CommentChallengeRequestToEncryptSchema, Ar as t$9, At as pTimeout, B as pubsubTopicToDhtKey, Bn as CommentUpdateSchema, Br as logger_default, C as hideClassPrivateProps, Cn as RpcRemoteCommunityUpdateEventResultSchema, Cr as e$5, D as isIpfsCid, Dr as n$8, Dt as untrackUpdatingCommunity, E as isAbortError, En as VotePubsubMessagePublicationSchema, Er as t$12, Fn as CommentSignedPropertyNames, Fr as FailedToFetchCommunityFromGatewaysError, Gn as GetPageParamSchema, Gr as array, Gt as NameResolverSerializedSchema, H as raceAgainstAbort, Hr as require_ms$1, Ht as DecryptedChallengeSchema, In as CommentUpdateChallengeReservedFieldNames, Ir as FailedToFetchGenericIpfsFromGatewaysError, It as ChallengeRequestMessageSignedPropertyNames, Jn as isReservedObjectKey, Jr as literal, Jt as PKCUserOptionsSchema, Kn as ModQueuePageIpfsSchema, Kr as boolean, Kt as PKCParsedOptionsSchema, L as isRequestPubsubPublicationOfPost, Lr as FailedToFetchPageIpfsFromGatewaysError, Mn as CommentIpfsSchema, Mr as require_retry$2, Mt as ChallengeAnswerMessageSignedPropertyNames, Nr as FailedToFetchCommentIpfsFromGatewaysError, O as isIpfsPath, On as VoteSignedPropertyNames, Or as r$7, Ot as require_sha256$1, Pn as CommentPubsubMessageWithFlexibleAuthorRefinementSchema, Pr as FailedToFetchCommentUpdateFromGatewaysError, Pt as ChallengeMessageSignedPropertyNames, Qr as preprocess, Qt as CommunityEditPublicationSignedPropertyNames, R as isRequestPubsubPublicationOfReply, Rn as CommentUpdateForChallengeVerificationSignedPropertyNames, Rr as PKCError, Rt as ChallengeVerificationMessageSignedPropertyNames, S as hasTransientNetworkErrorCode, Sr as e$6, St as trackStartedCommunity, T as ipnsNameToIpnsOverPubsubTopic, Tn as VoteChallengeRequestToEncryptSchema, Tr as r$8, Tt as untrackStartedCommunity, Ut as DecryptedChallengeVerificationSchema, Vn as CommentUpdateSignedPropertyNames, Vr as require_supports_color, Wn as CreateCommentOptionsWithRefinementSchema, Wr as _enum, Wt as NameResolveCacheOptionsSchema, Xr as number, Xt as CommunityEditPublicationChallengeRequestToEncryptSchema, Yn as CommentEditChallengeRequestToEncryptSchema, Yr as looseObject, Zn as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema, Zr as object, _n as CreateRemoteCommunityFunctionArgumentSchema, _r as n$9, an as CommentModerationsTableRowSchema, ar as AuthorReservedFields, at as throwIfAbortSignalAborted, bn as PageSortFileFactorySchema, bt as refreshTrackedCommunityAliases, cn as ChallengeFileSchema, cr as CidStringSchema, d as deepMergeRuntimeFields, dn as CommunityEditOptionsSchema, dr as CreateSignerSchema, ei as string, en as CreateCommunityEditPublicationOptionsWithRefinementSchema, f as derivePublicationFromChallengeRequest, fn as CommunityExportRecordsSchema, fr as JsonSignatureSchema, ft as findStartedCommunity, gn as CreateNewLocalCommunityUserOptionsSchema, gr as isStringDomain, h as fetchAndValidateIpnsRecordFromGateway, hn as CommunitySignedPropertyNames, hr as areEquivalentNames, ht as forgetTrackedUpdatingCommunityName, in as CommentModerationSignedPropertyNames, ir as AuthorPubsubSchema, jn as CommentIpfsReservedFields, jr as e$4, k as isIpns, kr as t$10, lr as CommunityAddressSchema, m as extractNetworkErrorDetails, mn as CommunityIpfsSchema, mr as ProtocolVersionSchema, mt as findUpdatingCommunity, nn as CommentModerationPubsubMessagePublicationSchema, nr as AuthorAddressSchema, nt as shortifyCid, on as CreateCommentModerationOptionsWithRefinementSchema, or as ChallengeAnswersSchema, ot as timestamp, p as doesDomainAddressHaveCapitalLetter, pn as CommunityIpfsReservedFields, pr as PKCTimestampSchema, q as removeNullUndefinedEmptyObjectsValuesRecursively, qn as PageIpfsSchema, qr as custom, qt as PKCUserOptionBaseSchema, r as calculateIpfsCidV0, rr as AuthorCommentIpfsReservedFields, rt as sleepUntilTimeoutOrAbort, sn as ChallengeFileFactorySchema, sr as CidPathSchema, t as areEquivalentCommunityAddresses, ti as union, tn as CommentModerationChallengeRequestToEncryptSchema, tr as CreateCommentEditOptionsWithRefinementSchema, tt as shortifyAddress, u as createAbortError, un as CommunityChallengeSettingSchema, ur as CommunityAuthorChallengeReservedFieldNames, vn as CreateRpcCommunityFunctionArgumentSchema, w as interruptibleSleep, wn as CreateVoteUserOptionsWithRefinementSchema, wr as t$11, wt as trackUpdatingCommunity, xn as PageSortFileSchema, xr as t$13, yn as ExportCommunityModLogsOptionsSchema, yr as n$10, z as linkAbortSignals, zn as CommentUpdateReservedFields, zr as messages, zt as DecryptedChallengeAnswerSchema } from "./util-Bnqvxk-6.js";
2
+ import { $n as CommentEditSignedPropertyNames, $r as record, $t as CommunityEditPubsubMessagePublicationSchema, A as isIpnsPath, An as CommentChallengeRequestToEncryptSchema, Ar as t$9, At as pTimeout, B as pubsubTopicToDhtKey, Bn as CommentUpdateSchema, Br as logger_default, C as hideClassPrivateProps, Cn as RpcRemoteCommunityUpdateEventResultSchema, Cr as e$5, D as isIpfsCid, Dr as n$8, Dt as untrackUpdatingCommunity, E as isAbortError, En as VotePubsubMessagePublicationSchema, Er as t$12, Fn as CommentSignedPropertyNames, Fr as FailedToFetchCommunityFromGatewaysError, Gn as GetPageParamSchema, Gr as array, Gt as NameResolverSerializedSchema, H as raceAgainstAbort, Hr as require_ms$1, Ht as DecryptedChallengeSchema, In as CommentUpdateChallengeReservedFieldNames, Ir as FailedToFetchGenericIpfsFromGatewaysError, It as ChallengeRequestMessageSignedPropertyNames, Jn as isReservedObjectKey, Jr as literal, Jt as PKCUserOptionsSchema, Kn as ModQueuePageIpfsSchema, Kr as boolean, Kt as PKCParsedOptionsSchema, L as isRequestPubsubPublicationOfPost, Lr as FailedToFetchPageIpfsFromGatewaysError, Mn as CommentIpfsSchema, Mr as require_retry$2, Mt as ChallengeAnswerMessageSignedPropertyNames, Nr as FailedToFetchCommentIpfsFromGatewaysError, O as isIpfsPath, On as VoteSignedPropertyNames, Or as r$7, Ot as require_sha256$1, Pn as CommentPubsubMessageWithFlexibleAuthorRefinementSchema, Pr as FailedToFetchCommentUpdateFromGatewaysError, Pt as ChallengeMessageSignedPropertyNames, Qr as preprocess, Qt as CommunityEditPublicationSignedPropertyNames, R as isRequestPubsubPublicationOfReply, Rn as CommentUpdateForChallengeVerificationSignedPropertyNames, Rr as PKCError, Rt as ChallengeVerificationMessageSignedPropertyNames, S as hasTransientNetworkErrorCode, Sr as e$6, St as trackStartedCommunity, T as ipnsNameToIpnsOverPubsubTopic, Tn as VoteChallengeRequestToEncryptSchema, Tr as r$8, Tt as untrackStartedCommunity, Ut as DecryptedChallengeVerificationSchema, Vn as CommentUpdateSignedPropertyNames, Vr as require_supports_color, Wn as CreateCommentOptionsWithRefinementSchema, Wr as _enum, Wt as NameResolveCacheOptionsSchema, Xr as number, Xt as CommunityEditPublicationChallengeRequestToEncryptSchema, Yn as CommentEditChallengeRequestToEncryptSchema, Yr as looseObject, Zn as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema, Zr as object, _n as CreateRemoteCommunityFunctionArgumentSchema, _r as n$9, an as CommentModerationsTableRowSchema, ar as AuthorReservedFields, at as throwIfAbortSignalAborted, bn as PageSortFileFactorySchema, bt as refreshTrackedCommunityAliases, cn as ChallengeFileSchema, cr as CidStringSchema, d as deepMergeRuntimeFields, dn as CommunityEditOptionsSchema, dr as CreateSignerSchema, ei as string, en as CreateCommunityEditPublicationOptionsWithRefinementSchema, f as derivePublicationFromChallengeRequest, fn as CommunityExportRecordsSchema, fr as JsonSignatureSchema, ft as findStartedCommunity, gn as CreateNewLocalCommunityUserOptionsSchema, gr as isStringDomain, h as fetchAndValidateIpnsRecordFromGateway, hn as CommunitySignedPropertyNames, hr as areEquivalentNames, ht as forgetTrackedUpdatingCommunityName, in as CommentModerationSignedPropertyNames, ir as AuthorPubsubSchema, jn as CommentIpfsReservedFields, jr as e$4, k as isIpns, kr as t$10, lr as CommunityAddressSchema, m as extractNetworkErrorDetails, mn as CommunityIpfsSchema, mr as ProtocolVersionSchema, mt as findUpdatingCommunity, nn as CommentModerationPubsubMessagePublicationSchema, nr as AuthorAddressSchema, nt as shortifyCid, on as CreateCommentModerationOptionsWithRefinementSchema, or as ChallengeAnswersSchema, ot as timestamp, p as doesDomainAddressHaveCapitalLetter, pn as CommunityIpfsReservedFields, pr as PKCTimestampSchema, q as removeNullUndefinedEmptyObjectsValuesRecursively, qn as PageIpfsSchema, qr as custom, qt as PKCUserOptionBaseSchema, r as calculateIpfsCidV0, rr as AuthorCommentIpfsReservedFields, rt as sleepUntilTimeoutOrAbort, sn as ChallengeFileFactorySchema, sr as CidPathSchema, t as areEquivalentCommunityAddresses, ti as union, tn as CommentModerationChallengeRequestToEncryptSchema, tr as CreateCommentEditOptionsWithRefinementSchema, tt as shortifyAddress, u as createAbortError, un as CommunityChallengeSettingSchema, ur as CommunityAuthorChallengeReservedFieldNames, vn as CreateRpcCommunityFunctionArgumentSchema, w as interruptibleSleep, wn as CreateVoteUserOptionsWithRefinementSchema, wr as t$11, wt as trackUpdatingCommunity, xn as PageSortFileSchema, xr as t$13, yn as ExportCommunityModLogsOptionsSchema, yr as n$10, z as linkAbortSignals, zn as CommentUpdateReservedFields, zr as messages, zt as DecryptedChallengeAnswerSchema } from "./util-B81IOt07.js";
3
3
  import { t as all } from "./src-CYIMjhjK.js";
4
- import { s as validatePageSortFile } from "./page-sort-scoring-DgSzIxmE.js";
4
+ import { s as validatePageSortFile } from "./page-sort-scoring-DbI7k_K5.js";
5
5
  import { createHash } from "node:crypto";
6
6
  import { pathToFileURL } from "node:url";
7
7
  import dns from "node:dns";
8
8
  import os from "os";
9
- import { closeSync, createReadStream, existsSync, openSync, promises, readSync, readdirSync, watch } from "node:fs";
9
+ import { closeSync, createReadStream, existsSync, openSync, promises, readSync, readdirSync, statSync, watch } from "node:fs";
10
10
  import path from "path";
11
11
  import assert from "assert";
12
12
  import { Agent } from "https";
@@ -117771,27 +117771,40 @@ const setNativeFunctions = (newNativeFunctions) => {
117771
117771
  for (const i in newNativeFunctions) nativeFunctions[i] = newNativeFunctions[i];
117772
117772
  };
117773
117773
  const WINDOWS_FILE_BUSY_ERROR_CODES = ["EBUSY", "EPERM"];
117774
+ async function removeFileRetryingWhileBusy(filePath, { timeoutMs = 1e4, log, keepIf }) {
117775
+ const deadline = Date.now() + timeoutMs;
117776
+ for (let retryDelayMs = 50;; retryDelayMs = Math.min(retryDelayMs * 2, 1e3)) {
117777
+ if (keepIf?.()) {
117778
+ log(`${filePath} is not to be removed any more, leaving it in place`);
117779
+ return;
117780
+ }
117781
+ try {
117782
+ await promises.rm(filePath, { force: true });
117783
+ return;
117784
+ } catch (e) {
117785
+ const code = e.code;
117786
+ if (!code || !WINDOWS_FILE_BUSY_ERROR_CODES.includes(code) || Date.now() + retryDelayMs >= deadline) throw e;
117787
+ log(`${filePath} is still busy (${code}), retrying its removal in ${retryDelayMs}ms`);
117788
+ await new Promise((resolve) => setTimeout(resolve, retryDelayMs));
117789
+ }
117790
+ }
117791
+ }
117774
117792
  const deleteOldCommunityInWindows = async (subPath, pkc, { timeoutMs = 1e4 } = {}) => {
117775
117793
  const log = logger_default("pkc-js:community:deleteStaleCommunityInWindows");
117776
117794
  const communityAddress = path.basename(subPath);
117777
- const deadline = Date.now() + timeoutMs;
117778
- for (let retryDelayMs = 50;; retryDelayMs = Math.min(retryDelayMs * 2, 1e3)) try {
117779
- await promises.rm(subPath, { force: true });
117795
+ try {
117796
+ await removeFileRetryingWhileBusy(subPath, {
117797
+ timeoutMs,
117798
+ log
117799
+ });
117780
117800
  log(`Succeeded in deleting old community (${communityAddress})`);
117781
- return;
117782
117801
  } catch (e) {
117783
- const code = e.code;
117784
- if (!code || !WINDOWS_FILE_BUSY_ERROR_CODES.includes(code) || Date.now() + retryDelayMs >= deadline) {
117785
- await recordCommunityThatFailedToBeDeleted({
117786
- communityAddress,
117787
- pkc,
117788
- error: e,
117789
- log
117790
- });
117791
- return;
117792
- }
117793
- log(`Old community (${communityAddress}) is still busy (${code}), retrying in ${retryDelayMs}ms`);
117794
- await new Promise((resolve) => setTimeout(resolve, retryDelayMs));
117802
+ await recordCommunityThatFailedToBeDeleted({
117803
+ communityAddress,
117804
+ pkc,
117805
+ error: e,
117806
+ log
117807
+ });
117795
117808
  }
117796
117809
  };
117797
117810
  async function recordCommunityThatFailedToBeDeleted({ communityAddress, pkc, error, log }) {
@@ -117802,6 +117815,16 @@ async function recordCommunityThatFailedToBeDeleted({ communityAddress, pkc, err
117802
117815
  await pkc._storage.setItem(storageKey, communitiesThatWeFailedToDelete);
117803
117816
  log(`Updated persistent deleted communities in storage`, communitiesThatWeFailedToDelete);
117804
117817
  }
117818
+ async function forgetCommunityThatFailedToBeDeleted({ communityAddress, pkc }) {
117819
+ const log = logger_default("pkc-js:community:forgetCommunityThatFailedToBeDeleted");
117820
+ const storageKey = STORAGE_KEYS[STORAGE_KEYS.PERSISTENT_DELETED_COMMUNITIES];
117821
+ const communitiesThatWeFailedToDelete = await pkc._storage.getItem(storageKey);
117822
+ if (!Array.isArray(communitiesThatWeFailedToDelete) || !communitiesThatWeFailedToDelete.includes(communityAddress)) return;
117823
+ const remaining = communitiesThatWeFailedToDelete.filter((address) => address !== communityAddress);
117824
+ if (remaining.length === 0) await pkc._storage.removeItem(storageKey);
117825
+ else await pkc._storage.setItem(storageKey, remaining);
117826
+ log(`A live DB is being written to communities/${communityAddress}, removed it from the persistent deleted communities`, remaining);
117827
+ }
117805
117828
  async function tryToDeleteCommunitiesThatFailedToBeDeletedBefore(pkc, log) {
117806
117829
  const deletedPersistentCommunities = await pkc._storage.getItem(STORAGE_KEYS[STORAGE_KEYS.PERSISTENT_DELETED_COMMUNITIES]);
117807
117830
  if (Array.isArray(deletedPersistentCommunities)) {
@@ -117839,6 +117862,37 @@ function getLocalCommunityIdentities(pkc) {
117839
117862
  if (!identities) localCommunityIdentities.set(pkc, identities = /* @__PURE__ */ new Map());
117840
117863
  return identities;
117841
117864
  }
117865
+ const unreadableLocalCommunityDbs = /* @__PURE__ */ new WeakMap();
117866
+ function getUnreadableLocalCommunityDbs(pkc) {
117867
+ let unreadable = unreadableLocalCommunityDbs.get(pkc);
117868
+ if (!unreadable) unreadableLocalCommunityDbs.set(pkc, unreadable = /* @__PURE__ */ new Map());
117869
+ return unreadable;
117870
+ }
117871
+ const sqliteHeaderChecks = /* @__PURE__ */ new WeakMap();
117872
+ function getSqliteHeaderChecks(pkc) {
117873
+ let checks = sqliteHeaderChecks.get(pkc);
117874
+ if (!checks) sqliteHeaderChecks.set(pkc, checks = /* @__PURE__ */ new Map());
117875
+ return checks;
117876
+ }
117877
+ function getCommunityDbStatSignature(dbPath) {
117878
+ const statOrUndefined = (filePath) => {
117879
+ try {
117880
+ return statSync(filePath, { bigint: true });
117881
+ } catch {
117882
+ return;
117883
+ }
117884
+ };
117885
+ const dbStat = statOrUndefined(dbPath);
117886
+ if (!dbStat) return void 0;
117887
+ const walStat = statOrUndefined(`${dbPath}-wal`);
117888
+ const walSignature = walStat && walStat.size > 0n ? `${walStat.size}:${walStat.mtimeNs}` : "empty";
117889
+ return `${dbStat.ino}:${dbStat.size}:${dbStat.mtimeNs}:${dbStat.ctimeNs}:${walSignature}`;
117890
+ }
117891
+ const SQLITE_ERROR_CODES_ABOUT_THE_FILE = [
117892
+ "SQLITE_NOTADB",
117893
+ "SQLITE_CORRUPT",
117894
+ "SQLITE_ERROR"
117895
+ ];
117842
117896
  function readLocalCommunityIdentity(pkc, communityAddress) {
117843
117897
  const log = logger_default("pkc-js:readLocalCommunityIdentity");
117844
117898
  const dbPath = path.join(pkc.dataPath, "communities", communityAddress);
@@ -117853,15 +117907,22 @@ function readLocalCommunityIdentity(pkc, communityAddress) {
117853
117907
  const publicKey = internalState?.anchor?.publicKey ?? internalState?.signer?.address;
117854
117908
  if (typeof publicKey !== "string") {
117855
117909
  log(`Community DB (${communityAddress}) has no internal state yet, leaving it out of pkc.communities for now`);
117856
- return;
117910
+ return {
117911
+ identity: void 0,
117912
+ unreadableUntilFileChanges: true
117913
+ };
117857
117914
  }
117858
- return isStringDomain(communityAddress) ? {
117915
+ return { identity: isStringDomain(communityAddress) ? {
117859
117916
  name: communityAddress,
117860
117917
  publicKey
117861
- } : { publicKey };
117918
+ } : { publicKey } };
117862
117919
  } catch (e) {
117863
117920
  log.error(`Failed to read the identity of community DB (${communityAddress}), leaving it out of pkc.communities for now`, e);
117864
- return;
117921
+ const code = e.code;
117922
+ return {
117923
+ identity: void 0,
117924
+ unreadableUntilFileChanges: e instanceof SyntaxError || typeof code === "string" && SQLITE_ERROR_CODES_ABOUT_THE_FILE.some((aboutTheFile) => code.startsWith(aboutTheFile))
117925
+ };
117865
117926
  } finally {
117866
117927
  db?.close();
117867
117928
  }
@@ -117870,12 +117931,22 @@ function listCommunitiesEntriesSync(pkc) {
117870
117931
  const communityAddresses = listCommunitiesSync(pkc);
117871
117932
  const identities = getLocalCommunityIdentities(pkc);
117872
117933
  for (const cachedAddress of identities.keys()) if (!communityAddresses.includes(cachedAddress)) identities.delete(cachedAddress);
117934
+ const unreadable = getUnreadableLocalCommunityDbs(pkc);
117935
+ for (const unreadableAddress of unreadable.keys()) if (!communityAddresses.includes(unreadableAddress)) unreadable.delete(unreadableAddress);
117873
117936
  const entries = [];
117874
117937
  for (const communityAddress of communityAddresses) {
117875
117938
  let identity = identities.get(communityAddress);
117876
117939
  if (!identity) {
117877
- identity = readLocalCommunityIdentity(pkc, communityAddress);
117878
- if (!identity) continue;
117940
+ const statSignature = getCommunityDbStatSignature(path.join(pkc.dataPath, "communities", communityAddress));
117941
+ if (statSignature !== void 0 && unreadable.get(communityAddress) === statSignature) continue;
117942
+ const read = readLocalCommunityIdentity(pkc, communityAddress);
117943
+ if (!read.identity) {
117944
+ if (statSignature !== void 0 && read.unreadableUntilFileChanges) unreadable.set(communityAddress, statSignature);
117945
+ else unreadable.delete(communityAddress);
117946
+ continue;
117947
+ }
117948
+ unreadable.delete(communityAddress);
117949
+ identity = read.identity;
117879
117950
  identities.set(communityAddress, identity);
117880
117951
  }
117881
117952
  entries.push(toCommunitiesEntry({
@@ -117915,8 +117986,23 @@ function listCommunitiesSync(pkc) {
117915
117986
  }).filter((dirent) => dirent.isFile()).map((dirent) => dirent.name).filter((file) => !file.includes(".lock") && !file.endsWith("-journal") && !file.endsWith("-shm") && !file.endsWith("-wal"));
117916
117987
  const knownCommunities = getLocalCommunityIdentities(pkc);
117917
117988
  const communityFilesWeDontNeedToCheck = files.filter((address) => knownCommunities.has(address));
117989
+ const headerChecks = getSqliteHeaderChecks(pkc);
117990
+ for (const checkedFile of headerChecks.keys()) if (!files.includes(checkedFile)) headerChecks.delete(checkedFile);
117918
117991
  const sqliteFiles = files.filter((address) => !communityFilesWeDontNeedToCheck.includes(address)).filter((address) => {
117919
117992
  const filePath = path.join(communitiesPath, address);
117993
+ const statSignature = getCommunityDbStatSignature(filePath);
117994
+ const lastCheck = headerChecks.get(address);
117995
+ if (statSignature !== void 0 && lastCheck?.statSignature === statSignature) return lastCheck.isSqlite;
117996
+ const isSqlite = isSqliteFile(filePath);
117997
+ if (statSignature !== void 0 && isSqlite !== void 0) headerChecks.set(address, {
117998
+ statSignature,
117999
+ isSqlite
118000
+ });
118001
+ else headerChecks.delete(address);
118002
+ return isSqlite === true;
118003
+ });
118004
+ return [...communityFilesWeDontNeedToCheck, ...sqliteFiles].sort();
118005
+ function isSqliteFile(filePath) {
117920
118006
  try {
117921
118007
  const fd = openSync(filePath, "r");
117922
118008
  const buffer = Buffer.alloc(16);
@@ -117928,10 +118014,9 @@ function listCommunitiesSync(pkc) {
117928
118014
  return buffer.toString().startsWith("SQLite format 3");
117929
118015
  } catch (e) {
117930
118016
  if (!(e instanceof Error && "code" in e && e.code === "ENOENT")) log.error(`Failed to check whether ${filePath} is a SQLite file, skipping it`, e);
117931
- return false;
118017
+ return;
117932
118018
  }
117933
- });
117934
- return [...communityFilesWeDontNeedToCheck, ...sqliteFiles].sort();
118019
+ }
117935
118020
  }
117936
118021
  async function importSignerIntoKuboNode(ipnsKeyName, ipfsKey, kuboRpcClientOptions) {
117937
118022
  const log = logger_default("pkc-js:local-community:importSignerIntoKuboNode");
@@ -148141,6 +148226,10 @@ const createUrlFromSubdomainResolution = (gateway, opts) => {
148141
148226
  };
148142
148227
  const GATEWAYS_THAT_SUPPORT_SUBDOMAIN_RESOLUTION = {};
148143
148228
  const MAX_CONCURRENT_AUTHOR_NAME_RESOLUTIONS = 100;
148229
+ function isIpfsPathNotInFolderError(error) {
148230
+ if (!(error instanceof Error)) return false;
148231
+ return error.name === "DoesNotExistError" || error.name === "HTTPError" && /^no link named /.test(error.message);
148232
+ }
148144
148233
  const waitForAuthorNameResolveInFlight = ({ inFlightResolve, abortSignal }) => new Promise((resolve) => {
148145
148234
  if (abortSignal?.aborted) return resolve("aborted");
148146
148235
  const onAbort = () => finish("aborted");
@@ -148689,6 +148778,10 @@ var BaseClientsManager = class BaseClientsManager {
148689
148778
  timeoutMs,
148690
148779
  error: e
148691
148780
  });
148781
+ if (isIpfsPathNotInFolderError(e)) throw new PKCError("ERR_IPFS_PATH_NOT_IN_FOLDER", {
148782
+ ipfsPath: `/ipfs/${root}/${path}`,
148783
+ error: e
148784
+ });
148692
148785
  log.trace("Could not resolve", `${root}/${path}`, "to a cid, the caller will fetch it", e);
148693
148786
  return;
148694
148787
  }
@@ -153672,10 +153765,16 @@ var esm_exports = /* @__PURE__ */ __exportAll({
153672
153765
  const { RateLimiter } = esm_exports;
153673
153766
  const rateLimiters = new import_quick_lru.default({ maxSize: 5e4 });
153674
153767
  const getPublicationType = (request) => isPost(request) ? "post" : isReply(request) ? "reply" : isVote(request) ? "vote" : isCommentEdit(request) ? "commentEdit" : isCommentModeration(request) ? "commentModeration" : isCommunityEdit(request) ? "communityEdit" : void 0;
153675
- const getRateLimiterName = (exclude, publication, publicationType, challengeSuccess) => `${publication.author.address}-${exclude.rateLimit}-${publicationType}-${challengeSuccess}`;
153676
- const getOrCreateRateLimiter = (exclude, publication, publicationType, challengeSuccess) => {
153768
+ const getRateLimiterName = (communityAddress, exclude, publication, publicationType, challengeSuccess) => JSON.stringify([
153769
+ communityAddress,
153770
+ publication.author.address,
153771
+ exclude.rateLimit,
153772
+ publicationType,
153773
+ challengeSuccess
153774
+ ]);
153775
+ const getOrCreateRateLimiter = (communityAddress, exclude, publication, publicationType, challengeSuccess) => {
153677
153776
  if (typeof exclude.rateLimit !== "number") throw Error("Can't create a RateLimiter without exclude.rateLimit");
153678
- const rateLimiterName = getRateLimiterName(exclude, publication, publicationType, challengeSuccess);
153777
+ const rateLimiterName = getRateLimiterName(communityAddress, exclude, publication, publicationType, challengeSuccess);
153679
153778
  let rateLimiter = rateLimiters.get(rateLimiterName);
153680
153779
  if (!rateLimiter) {
153681
153780
  rateLimiter = new RateLimiter({
@@ -153688,47 +153787,47 @@ const getOrCreateRateLimiter = (exclude, publication, publicationType, challenge
153688
153787
  }
153689
153788
  return rateLimiter;
153690
153789
  };
153691
- const addFilteredRateLimiter = (exclude, publication, publicationType, challengeSuccess, filteredRateLimiters) => {
153692
- filteredRateLimiters[getRateLimiterName(exclude, publication, publicationType, challengeSuccess)] = getOrCreateRateLimiter(exclude, publication, publicationType, challengeSuccess);
153790
+ const addFilteredRateLimiter = (communityAddress, exclude, publication, publicationType, challengeSuccess, filteredRateLimiters) => {
153791
+ filteredRateLimiters[getRateLimiterName(communityAddress, exclude, publication, publicationType, challengeSuccess)] = getOrCreateRateLimiter(communityAddress, exclude, publication, publicationType, challengeSuccess);
153693
153792
  };
153694
- const getRateLimitersToTest = (exclude, request, challengeSuccess) => {
153793
+ const getRateLimitersToTest = (exclude, request, challengeSuccess, communityAddress) => {
153695
153794
  const publication = derivePublicationFromChallengeRequest(request);
153696
153795
  const filteredRateLimiters = {};
153697
153796
  if (testPublicationType(exclude.publicationType, request)) {
153698
153797
  const publicationType = getPublicationType(request);
153699
- if (publicationType) addFilteredRateLimiter(exclude, publication, publicationType, challengeSuccess, filteredRateLimiters);
153798
+ if (publicationType) addFilteredRateLimiter(communityAddress, exclude, publication, publicationType, challengeSuccess, filteredRateLimiters);
153700
153799
  }
153701
153800
  return filteredRateLimiters;
153702
153801
  };
153703
- const testRateLimit = (exclude, request) => {
153802
+ const testRateLimit = (exclude, request, communityAddress) => {
153704
153803
  if (exclude?.rateLimit === void 0 || !testPublicationType(exclude.publicationType, request)) return true;
153705
153804
  let challengeSuccess = true;
153706
153805
  if (exclude.rateLimitChallengeSuccess === false) challengeSuccess = false;
153707
- const rateLimiters = getRateLimitersToTest(exclude, request, challengeSuccess);
153806
+ const rateLimiters = getRateLimitersToTest(exclude, request, challengeSuccess, communityAddress);
153708
153807
  for (const rateLimiter of Object.values(rateLimiters)) if (rateLimiter.getTokensRemaining() < 1) return false;
153709
153808
  return true;
153710
153809
  };
153711
- const getRateLimitersToAddTo = (excludeArray, request, challengeSuccess) => {
153810
+ const getRateLimitersToAddTo = (excludeArray, request, challengeSuccess, communityAddress) => {
153712
153811
  const filteredRateLimiters = {};
153713
153812
  const publication = derivePublicationFromChallengeRequest(request);
153714
153813
  for (const exclude of excludeArray) {
153715
153814
  if (exclude?.rateLimit === void 0) continue;
153716
153815
  const publicationType = getPublicationType(request);
153717
- if (publicationType) addFilteredRateLimiter(exclude, publication, publicationType, challengeSuccess, filteredRateLimiters);
153718
- if (request.commentEdit) addFilteredRateLimiter(exclude, publication, "commentEdit", challengeSuccess, filteredRateLimiters);
153719
- if (request.commentModeration) addFilteredRateLimiter(exclude, publication, "commentModeration", challengeSuccess, filteredRateLimiters);
153720
- if (request.communityEdit) addFilteredRateLimiter(exclude, publication, "communityEdit", challengeSuccess, filteredRateLimiters);
153816
+ if (publicationType) addFilteredRateLimiter(communityAddress, exclude, publication, publicationType, challengeSuccess, filteredRateLimiters);
153817
+ if (request.commentEdit) addFilteredRateLimiter(communityAddress, exclude, publication, "commentEdit", challengeSuccess, filteredRateLimiters);
153818
+ if (request.commentModeration) addFilteredRateLimiter(communityAddress, exclude, publication, "commentModeration", challengeSuccess, filteredRateLimiters);
153819
+ if (request.communityEdit) addFilteredRateLimiter(communityAddress, exclude, publication, "communityEdit", challengeSuccess, filteredRateLimiters);
153721
153820
  }
153722
153821
  return filteredRateLimiters;
153723
153822
  };
153724
- const addToRateLimiter = (communityChallenges, request, challengeSuccess) => {
153823
+ const addToRateLimiter = (communityChallenges, request, challengeSuccess, communityAddress) => {
153725
153824
  if (!communityChallenges) return;
153726
153825
  if (!Array.isArray(communityChallenges)) throw Error(`addToRateLimiter invalid argument communityChallenges '${communityChallenges}' not an array`);
153727
153826
  if (typeof challengeSuccess !== "boolean") throw Error(`addToRateLimiter invalid argument challengeSuccess '${challengeSuccess}' not a boolean`);
153728
153827
  const excludeArray = [];
153729
153828
  for (const communityChallenge of communityChallenges) for (const exclude of communityChallenge?.exclude || []) excludeArray.push(exclude);
153730
153829
  if (!excludeArray.length) return;
153731
- const rateLimiters = getRateLimitersToAddTo(excludeArray, request, challengeSuccess);
153830
+ const rateLimiters = getRateLimitersToAddTo(excludeArray, request, challengeSuccess, communityAddress);
153732
153831
  for (const rateLimiter of Object.values(rateLimiters)) rateLimiter.tryRemoveTokens(1);
153733
153832
  };
153734
153833
  //#endregion
@@ -153755,7 +153854,7 @@ const shouldExcludePublication = async ({ communityChallenge, request, community
153755
153854
  if (!testScore(exclude.replyScore, author.community?.replyScore)) shouldExclude = false;
153756
153855
  if (!testFirstCommentTimestamp(exclude.firstCommentTimestamp, author.community?.firstCommentTimestamp)) shouldExclude = false;
153757
153856
  if (!testPublicationType(exclude.publicationType, request)) shouldExclude = false;
153758
- if (!testRateLimit(exclude, request)) shouldExclude = false;
153857
+ if (!testRateLimit(exclude, request, community?.address)) shouldExclude = false;
153759
153858
  if (exclude.publicKeys && !exclude.publicKeys.includes(identityMatcher.signerAddress)) shouldExclude = false;
153760
153859
  if (typeof exclude.postCount === "number" || typeof exclude.replyCount === "number") {
153761
153860
  if (!authorPublicationCounts && community?._dbHandler) authorPublicationCounts = community._dbHandler.queryAuthorPublicationCounts(identityMatcher.signerAddress);
@@ -155079,7 +155178,7 @@ const getChallengeVerification = async ({ challengeRequestMessage, community, ge
155079
155178
  const failedChallengeIndexes = Object.keys(challengeVerification.challengeErrors ?? {});
155080
155179
  const decisiveNameFailure = failedChallengeIndexes.length > 0 && identityNameFailureByIndex ? failedChallengeIndexes.every((index) => identityNameFailureByIndex[Number(index)]) ? identityNameFailureByIndex[Number(failedChallengeIndexes[0])] : void 0 : void 0;
155081
155180
  if (challengeVerification.challengeSuccess === false && decisiveNameFailure) challengeVerification.aggregatedReason = decisiveNameFailure.reason;
155082
- addToRateLimiter(community.settings?.challenges, challengeRequestMessage, challengeVerification.challengeSuccess);
155181
+ addToRateLimiter(community.settings?.challenges, challengeRequestMessage, challengeVerification.challengeSuccess, community.address);
155083
155182
  const shouldSendToPendingApproval = Boolean(challengeRequestMessage.comment) && challengeVerification.challengeSuccess === true && pendingApprovalSuccess;
155084
155183
  const postAnswerMatcherField = postAnswerAuthorIdentityMatcher ? { postAnswerAuthorIdentityMatcher } : {};
155085
155184
  if (shouldSendToPendingApproval) return {
@@ -156491,4 +156590,4 @@ var RpcLocalCommunity = class extends RpcRemoteCommunity {
156491
156590
  }
156492
156591
  };
156493
156592
  //#endregion
156494
- export { createSchemaRowParser as $, buildRuntimeCommunityFields as $n, RpcPublishCommunityListParamSchema as $t, findCommentInParsedPages as A, verifyChallengeAnswer as An, setNativeFunctions as Ar, parseRpcCommentUpdateEventWithPKCErrorIfItFails as At, GenericStateClient as B, verifyCommunityEdit as Bn, t$5 as Br, RpcCommunityIdentifierParamSchema as Bt, RepliesPages as C, signCommentModeration as Cn, getThumbnailPropsOfLink as Cr, parseCreateVoteOptionsSchemaWithPKCErrorIfItFails as Ct, extractCommunityRuntimeFieldsFromParsedPages as D, signCommunityEdit as Dn, moveCommunityDbToDeletedDirectory as Dr, parseJsonWithPKCErrorIfFails as Dt, buildPagesRuntimeFields as E, signCommunity as En, monitorCommunitiesDirectory as Er, parseDecryptedChallengeWithPKCErrorIfItFails as Et, cloneCrosspostForRuntime as F, verifyCommentIpfs as Fn, isCommunityStartLocked as Fr, RpcAuthorNameParamSchema as Ft, PKCTypedEmitter as G, getAuthorNameFromRuntime as Gn, stringify as Gr, RpcExportCommunityParamSchema as Gt, InflightResourceTypes as H, verifyVote as Hn, n$6 as Hr, RpcEditCommunityParamSchema as Ht, collectCrosspostAuthorsToResolve as I, verifyCommentModeration as In, require_src as Ir, RpcCancelExportParamSchema as It, decodeRpcChallengeRequestPubsubMsg as J, CreateCommunityListWithCidOptionsSchema as Jn, NAME_RESOLVED_TRUE_TTL_MS as Jr, RpcFetchCidResultSchema as Jt, decodeRpcChallengeAnswerPubsubMsg as K, getAuthorNameFromWire as Kn, MAX_FILE_SIZE_BYTES_FOR_COMMENT_UPDATE as Kr, RpcExportCommunityResultSchema as Kt, extractCrosspostRuntimeFields as L, verifyCommentPubsubMessage as Ln, t$2 as Lr, RpcCidParamSchema as Lt, parseRawPages as M, verifyChallengeRequest as Mn, findCommunitiesEntry as Mr, parseVoteChallengeRequestToEncryptSchemaWithPKCErrorIfItFails as Mt, MAX_PAGE_SIZE_BYTES as N, verifyChallengeVerification as Nn, toCommunitiesEntry as Nr, parseVotePubsubMessagePublicationSchemaWithPKCErrorIfItFails as Nt, findCommentInPageInstance as O, signCommunityList as On, refreshCommunitiesList as Or, parsePKCUserOptionsSchemaWithPKCErrorIfItFails as Ot, applyNameResolvedCacheToCrosspost as P, verifyCommentEdit as Pn, toCommunitiesWireEntry as Pr, RpcAnchorPublishPreparationResultSchema as Pt, collectSchemaRowCoercions as Q, effectiveMaxCrosspostDepth as Qn, nativeFunctions$1 as Qr, RpcPublishChallengeAnswersParamSchema as Qt, stripNameResolvedFromCrosspost as R, verifyCommentUpdate as Rn, t$4 as Rr, RpcCommentRepliesPageParamSchema as Rt, MAX_FILE_SIZE_BYTES_FOR_COMMUNITY_IPFS as S, signCommentEdit as Sn, getDefaultDataPath as Sr, parseCreateRpcCommunityFunctionArgumentSchemaWithPKCErrorIfItFails as St, buildPageRuntimeFields as T, signCommentUpdateForChallengeVerification as Tn, listCommunitiesSync as Tr, parseDecryptedChallengeVerification as Tt, pRetry as U, buildRuntimeAuthor as Un, t$7 as Ur, RpcExportCommunityModLogsParamSchema as Ut, InflightFetchManager as V, verifyCommunityList as Vn, n$5 as Vr, RpcCommunityPageParamSchema as Vt, pLimit as W, cleanWireAuthor as Wn, t$8 as Wr, RpcExportCommunityModLogsResultSchema as Wt, coerceSchemaRowBoolean as X, MAX_COMMUNITY_LIST_SIZE_BYTES as Xn, STORAGE_KEYS as Xr, RpcFetchCommunityListResultSchema as Xt, decodeRpcChallengeVerificationPubsubMsg as Y, CreateNewCommunityListOptionsSchema as Yn, NAME_RESOLVE_FAILED_RETRY_FLOOR_MS as Yr, RpcFetchCommunityListParamSchema as Yt, coerceSchemaRowJson as Z, crosspostChainDepthUpTo as Zn, require_lodash_merge as Zr, RpcPublishAnchorRecordParamSchema as Zt, createAuthorIdentityMatcher as _, signChallengeAnswer as _n, deriveCommentIpfsFromCommentTableRow as _r, parseCreateCommentOptionsSchemaWithPKCErrorIfItFails as _t, generatePagesReportingFailedSorts as a, RpcUnsubscribeParamSchema as an, encode as ar, parseCommentModerationChallengeRequestToEncryptSchemaWithPKCErrorIfItFails as at, KeyvBetterSqlite3 as b, signChallengeVerification as bn, findLocalCommunityAddress as br, parseCreatePKCWsServerOptionsSchemaWithPKCErrorIfItFails as bt, resolvePageSortsOrThrow as c, SignerWithPublicKeyAddress as cn, getPKCAddressFromPublicKey as cr, parseCommentUpdateSchemaWithPKCErrorIfItFails as ct, getChallengeVerification as d, decryptEd25519AesGcm as dn, BackupAbortError as dr, parseCommunityEditOptionsSchemaWithPKCErrorIfItFails as dt, RpcPublishCommunityListResultSchema as en, getCommunityAddressFromRecord as er, parseCidStringSchemaWithPKCErrorIfItFails as et, getCommunityChallengeFromCommunityChallengeSettings as f, decryptEd25519AesGcmPublicKeyBuffer as fn, backupCommunityDb as fr, parseCommunityEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails as ft, authorNameResolveFailureReason as g, cleanUpBeforePublishing as gn, deleteOldCommunityInWindows as gr, parseCreateCommentModerationOptionsSchemaWithPKCErrorIfItFails as gt, authorIdentityMatcherForRequest as h, _validateSignatureOfPKCRecord as hn, createKuboRpcClient as hr, parseCreateCommentEditOptionsSchemaWithPKCErrorIfItFails as ht, derivePublicPageSorts as i, RpcSuccessResultSchema as in, decode as ir, parseCommentIpfsSchemaWithPKCErrorIfItFails as it, iterateOverPageCidsToFindAllCids as j, verifyChallengeMessage as jn, tryToDeleteCommunitiesThatFailedToBeDeletedBefore as jr, parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails as jt, findCommentInPageInstanceRecursively as k, signVote as kn, resolveDbPostsCidRefs as kr, parseRpcCommentEventWithPKCErrorIfItFails as kt, pkcJsPageSorts as l, createSigner as ln, getPKCAddressFromPublicKeySync as lr, parseCommunityAddressWithPKCErrorIfItFails as lt, pkcJsChallenges as m, encryptEd25519AesGcmPublicKeyBuffer as mn, calculateInlineRepliesBudget as mr, parseCommunityListSchemaWithPKCErrorIfItFails as mt, RpcRemoteCommunity as n, RpcResolveAuthorNameResultSchema as nn, getCommunityPublicKeyFromWire as nr, parseCommentEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails as nt, loadPageSortsForStartedCommunity as o, findCommunityRecordNameMismatch as on, getBufferedPKCAddressFromPublicKey as or, parseCommentModerationPubsubMessagePublicationSchemaWithPKCErrorIfItFails as ot, loadChallengeFileFromCommunityChallengeSettings as p, encryptEd25519AesGcm as pn, calculateExpectedSignatureSize as pr, parseCommunityIpfsSchemaPassthroughWithPKCErrorIfItFails as pt, decodeRpcChallengePubsubMsg as q, normalizeCreatePublicationAuthor as qn, NAME_RESOLVED_FALSE_TTL_MS as qr, RpcFetchCidParamSchema as qt, computePageSortsFingerprint as r, RpcSubscriptionIdResultSchema as rn, normalizeCommunityInputFromCommunity as rr, parseCommentEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails as rt, lookupPageSortFactories as s, require_lib as sn, getIpfsKeyFromPrivateKey as sr, parseCommentPubsubMessagePublicationWithPKCErrorIfItFails as st, RpcLocalCommunity as t, RpcPublishedAnchorRecordResultSchema as tn, getCommunityNameFromWire$1 as tr, parseCommentChallengeRequestToEncryptSchemaWithPKCErrorIfItFails as tt, deriveCommunityChallengesOrThrow as u, createAnchorIpnsRecord as un, getPublicKeyFromPrivateKey as ur, parseCommunityEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails as ut, TrackedInstanceRegistry as v, signChallengeMessage as vn, deriveDbPosts as vr, parseCreateCommunityEditPublicationOptionsSchemaWithPKCErrorIfItFails as vt, TIMEFRAMES_TO_SECONDS as w, signCommentUpdate as wn, importSignerIntoKuboNode as wr, parseDecryptedChallengeAnswerWithPKCErrorIfItFails as wt, RemoteCommunity as x, signComment as xn, getDefaultCommunityDbConfig as xr, parseCreateRemoteCommunityFunctionArgumentSchemaWithPKCErrorIfItFails as xt, LRUCache as y, signChallengeRequest as yn, deriveDbReplies as yr, parseCreateNewLocalCommunityUserOptionsSchemaWithPKCErrorIfItFails as yt, PKCClientsManager as z, verifyCommunity as zn, r as zr, RpcCommunitiesChangeEventResultSchema as zt };
156593
+ export { createSchemaRowParser as $, buildRuntimeCommunityFields as $n, require_lodash_merge as $r, RpcPublishCommunityListParamSchema as $t, findCommentInParsedPages as A, verifyChallengeAnswer as An, removeFileRetryingWhileBusy as Ar, parseRpcCommentUpdateEventWithPKCErrorIfItFails as At, GenericStateClient as B, verifyCommunityEdit as Bn, t$4 as Br, RpcCommunityIdentifierParamSchema as Bt, RepliesPages as C, signCommentModeration as Cn, getDefaultDataPath as Cr, parseCreateVoteOptionsSchemaWithPKCErrorIfItFails as Ct, extractCommunityRuntimeFieldsFromParsedPages as D, signCommunityEdit as Dn, monitorCommunitiesDirectory as Dr, parseJsonWithPKCErrorIfFails as Dt, buildPagesRuntimeFields as E, signCommunity as En, listCommunitiesSync as Er, parseDecryptedChallengeWithPKCErrorIfItFails as Et, cloneCrosspostForRuntime as F, verifyCommentIpfs as Fn, toCommunitiesEntry as Fr, RpcAuthorNameParamSchema as Ft, PKCTypedEmitter as G, getAuthorNameFromRuntime as Gn, t$7 as Gr, RpcExportCommunityParamSchema as Gt, InflightResourceTypes as H, verifyVote as Hn, t$5 as Hr, RpcEditCommunityParamSchema as Ht, collectCrosspostAuthorsToResolve as I, verifyCommentModeration as In, toCommunitiesWireEntry as Ir, RpcCancelExportParamSchema as It, decodeRpcChallengeRequestPubsubMsg as J, CreateCommunityListWithCidOptionsSchema as Jn, MAX_FILE_SIZE_BYTES_FOR_COMMENT_UPDATE as Jr, RpcFetchCidResultSchema as Jt, decodeRpcChallengeAnswerPubsubMsg as K, getAuthorNameFromWire as Kn, t$8 as Kr, RpcExportCommunityResultSchema as Kt, extractCrosspostRuntimeFields as L, verifyCommentPubsubMessage as Ln, isCommunityStartLocked as Lr, RpcCidParamSchema as Lt, parseRawPages as M, verifyChallengeRequest as Mn, setNativeFunctions as Mr, parseVoteChallengeRequestToEncryptSchemaWithPKCErrorIfItFails as Mt, MAX_PAGE_SIZE_BYTES as N, verifyChallengeVerification as Nn, tryToDeleteCommunitiesThatFailedToBeDeletedBefore as Nr, parseVotePubsubMessagePublicationSchemaWithPKCErrorIfItFails as Nt, findCommentInPageInstance as O, signCommunityList as On, moveCommunityDbToDeletedDirectory as Or, parsePKCUserOptionsSchemaWithPKCErrorIfItFails as Ot, applyNameResolvedCacheToCrosspost as P, verifyCommentEdit as Pn, findCommunitiesEntry as Pr, RpcAnchorPublishPreparationResultSchema as Pt, collectSchemaRowCoercions as Q, effectiveMaxCrosspostDepth as Qn, STORAGE_KEYS as Qr, RpcPublishChallengeAnswersParamSchema as Qt, stripNameResolvedFromCrosspost as R, verifyCommentUpdate as Rn, require_src as Rr, RpcCommentRepliesPageParamSchema as Rt, MAX_FILE_SIZE_BYTES_FOR_COMMUNITY_IPFS as S, signCommentEdit as Sn, getDefaultCommunityDbConfig as Sr, parseCreateRpcCommunityFunctionArgumentSchemaWithPKCErrorIfItFails as St, buildPageRuntimeFields as T, signCommentUpdateForChallengeVerification as Tn, importSignerIntoKuboNode as Tr, parseDecryptedChallengeVerification as Tt, pRetry as U, buildRuntimeAuthor as Un, n$5 as Ur, RpcExportCommunityModLogsParamSchema as Ut, InflightFetchManager as V, verifyCommunityList as Vn, r as Vr, RpcCommunityPageParamSchema as Vt, pLimit as W, cleanWireAuthor as Wn, n$6 as Wr, RpcExportCommunityModLogsResultSchema as Wt, coerceSchemaRowBoolean as X, MAX_COMMUNITY_LIST_SIZE_BYTES as Xn, NAME_RESOLVED_TRUE_TTL_MS as Xr, RpcFetchCommunityListResultSchema as Xt, decodeRpcChallengeVerificationPubsubMsg as Y, CreateNewCommunityListOptionsSchema as Yn, NAME_RESOLVED_FALSE_TTL_MS as Yr, RpcFetchCommunityListParamSchema as Yt, coerceSchemaRowJson as Z, crosspostChainDepthUpTo as Zn, NAME_RESOLVE_FAILED_RETRY_FLOOR_MS as Zr, RpcPublishAnchorRecordParamSchema as Zt, createAuthorIdentityMatcher as _, signChallengeAnswer as _n, deriveCommentIpfsFromCommentTableRow as _r, parseCreateCommentOptionsSchemaWithPKCErrorIfItFails as _t, generatePagesReportingFailedSorts as a, RpcUnsubscribeParamSchema as an, encode as ar, parseCommentModerationChallengeRequestToEncryptSchemaWithPKCErrorIfItFails as at, KeyvBetterSqlite3 as b, signChallengeVerification as bn, findLocalCommunityAddress as br, parseCreatePKCWsServerOptionsSchemaWithPKCErrorIfItFails as bt, resolvePageSortsOrThrow as c, SignerWithPublicKeyAddress as cn, getPKCAddressFromPublicKey as cr, parseCommentUpdateSchemaWithPKCErrorIfItFails as ct, getChallengeVerification as d, decryptEd25519AesGcm as dn, BackupAbortError as dr, parseCommunityEditOptionsSchemaWithPKCErrorIfItFails as dt, nativeFunctions$1 as ei, RpcPublishCommunityListResultSchema as en, getCommunityAddressFromRecord as er, parseCidStringSchemaWithPKCErrorIfItFails as et, getCommunityChallengeFromCommunityChallengeSettings as f, decryptEd25519AesGcmPublicKeyBuffer as fn, backupCommunityDb as fr, parseCommunityEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails as ft, authorNameResolveFailureReason as g, cleanUpBeforePublishing as gn, deleteOldCommunityInWindows as gr, parseCreateCommentModerationOptionsSchemaWithPKCErrorIfItFails as gt, authorIdentityMatcherForRequest as h, _validateSignatureOfPKCRecord as hn, createKuboRpcClient as hr, parseCreateCommentEditOptionsSchemaWithPKCErrorIfItFails as ht, derivePublicPageSorts as i, RpcSuccessResultSchema as in, decode as ir, parseCommentIpfsSchemaWithPKCErrorIfItFails as it, iterateOverPageCidsToFindAllCids as j, verifyChallengeMessage as jn, resolveDbPostsCidRefs as jr, parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails as jt, findCommentInPageInstanceRecursively as k, signVote as kn, refreshCommunitiesList as kr, parseRpcCommentEventWithPKCErrorIfItFails as kt, pkcJsPageSorts as l, createSigner as ln, getPKCAddressFromPublicKeySync as lr, parseCommunityAddressWithPKCErrorIfItFails as lt, pkcJsChallenges as m, encryptEd25519AesGcmPublicKeyBuffer as mn, calculateInlineRepliesBudget as mr, parseCommunityListSchemaWithPKCErrorIfItFails as mt, RpcRemoteCommunity as n, RpcResolveAuthorNameResultSchema as nn, getCommunityPublicKeyFromWire as nr, parseCommentEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails as nt, loadPageSortsForStartedCommunity as o, findCommunityRecordNameMismatch as on, getBufferedPKCAddressFromPublicKey as or, parseCommentModerationPubsubMessagePublicationSchemaWithPKCErrorIfItFails as ot, loadChallengeFileFromCommunityChallengeSettings as p, encryptEd25519AesGcm as pn, calculateExpectedSignatureSize as pr, parseCommunityIpfsSchemaPassthroughWithPKCErrorIfItFails as pt, decodeRpcChallengePubsubMsg as q, normalizeCreatePublicationAuthor as qn, stringify as qr, RpcFetchCidParamSchema as qt, computePageSortsFingerprint as r, RpcSubscriptionIdResultSchema as rn, normalizeCommunityInputFromCommunity as rr, parseCommentEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails as rt, lookupPageSortFactories as s, require_lib as sn, getIpfsKeyFromPrivateKey as sr, parseCommentPubsubMessagePublicationWithPKCErrorIfItFails as st, RpcLocalCommunity as t, RpcPublishedAnchorRecordResultSchema as tn, getCommunityNameFromWire$1 as tr, parseCommentChallengeRequestToEncryptSchemaWithPKCErrorIfItFails as tt, deriveCommunityChallengesOrThrow as u, createAnchorIpnsRecord as un, getPublicKeyFromPrivateKey as ur, parseCommunityEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails as ut, TrackedInstanceRegistry as v, signChallengeMessage as vn, deriveDbPosts as vr, parseCreateCommunityEditPublicationOptionsSchemaWithPKCErrorIfItFails as vt, TIMEFRAMES_TO_SECONDS as w, signCommentUpdate as wn, getThumbnailPropsOfLink as wr, parseDecryptedChallengeAnswerWithPKCErrorIfItFails as wt, RemoteCommunity as x, signComment as xn, forgetCommunityThatFailedToBeDeleted as xr, parseCreateRemoteCommunityFunctionArgumentSchemaWithPKCErrorIfItFails as xt, LRUCache as y, signChallengeRequest as yn, deriveDbReplies as yr, parseCreateNewLocalCommunityUserOptionsSchemaWithPKCErrorIfItFails as yt, PKCClientsManager as z, verifyCommunity as zn, t$2 as zr, RpcCommunitiesChangeEventResultSchema as zt };
@@ -6875,6 +6875,7 @@ var messages;
6875
6875
  messages["ERR_CID_IS_INVALID"] = "CID is invalid";
6876
6876
  messages["ERR_DATA_PATH_IS_NOT_DEFINED"] = "pkcOptions.dataPath needs to be defined with native functions";
6877
6877
  messages["ERR_COMMUNITY_OWNER_ATTEMPTED_EDIT_NEW_ADDRESS_THAT_ALREADY_EXISTS"] = "Community owner attempted to edit community.address to a new address that already exists";
6878
+ messages["ERR_FAILED_TO_RENAME_COMMUNITY_DB"] = "Failed to rename the community's DB file to its new address, so the community keeps its old address. details.error is the error the rename itself raised";
6878
6879
  messages["ERR_COMMUNITY_EDIT_NAME_AND_ADDRESS_MISMATCH"] = "community.edit() received both name and address, and they name different addresses. Pass one of them, or the same value for both";
6879
6880
  messages["ERR_COMMENT_MISSING_IPFS_AND_UPDATE"] = "Comment is missing CommentIpfs and CommentUpdate";
6880
6881
  messages["ERR_COMMENT_MISSING_CID"] = "Comment is missing cid";
@@ -6950,6 +6951,7 @@ var messages;
6950
6951
  messages["ERR_REMOTE_COMMUNITY_RECEIVED_ALREADY_PROCCESSED_RECORD"] = "We loaded a community record but it's a record we already consumed before";
6951
6952
  messages["ERR_COMMENT_RECEIVED_ALREADY_PROCESSED_COMMENT_UPDATE"] = "We loaded a CommentUpdate but it's a record we already consumed";
6952
6953
  messages["ERR_FETCH_CID_P2P_TIMEOUT"] = "Fetching CID via Kubo-rpc-client/helia P2P has timed out";
6954
+ messages["ERR_IPFS_PATH_NOT_IN_FOLDER"] = "The folder was read and has no entry for this IPFS path";
6953
6955
  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\")";
6954
6956
  messages["ERR_FETCH_CID_P2P_TIMEOUT_AFTER_RETRIES"] = "Fetching CID via Kubo-rpc-client/helia P2P has timed out after all retry attempts";
6955
6957
  messages["ERR_RESOLVED_IPNS_P2P_TO_UNDEFINED"] = "Resolved IPNS name to undefined. Does this IPNS name exist?";
@@ -7235,6 +7237,7 @@ var messages;
7235
7237
  messages["ERR_COMMUNITY_STATE_LOCKED"] = "The internal state of the community in DB is locked";
7236
7238
  messages["ERR_COMMUNITY_CREATION_LOCKED"] = "Community creation is locked";
7237
7239
  messages["ERR_COMMUNITY_ALREADY_STARTED"] = "Community already started";
7240
+ messages["ERR_COMMUNITY_START_LOCK_COMPROMISED"] = "This instance lost the start lock of this community (another process took it over, or the lock was removed), so it stopped running it";
7238
7241
  messages["ERR_FAILED_TO_IMPORT_IPFS_KEY"] = "Community failed to import IPFS key";
7239
7242
  messages["ERR_LOCAL_COMMUNITY_PRODUCED_INVALID_RECORD"] = "The local community has produced a new IPNS record with invalid signature. This is a critical error";
7240
7243
  messages["ERR_FAILED_TO_PARSE_LOCAL_RAW_IPNS_RECORD"] = "Failed to parse the local IPNS record within our kubo node";
@@ -16553,7 +16556,7 @@ const CommunityEditPublicationPubsubReservedFields = r$2([
16553
16556
  ], t$3(CommunityEditPubsubMessagePublicationSchema.shape));
16554
16557
  //#endregion
16555
16558
  //#region dist/node/generated-version.js
16556
- const version = "0.0.146";
16559
+ const version = "0.0.148";
16557
16560
  //#endregion
16558
16561
  //#region dist/node/version.js
16559
16562
  const protocolVersion = ProtocolVersionSchema.parse("1.0.0");
@@ -1,4 +1,4 @@
1
- import { Rr as PKCError, V as pubsubTopicToDhtKeyCid } from "./util-Bnqvxk-6.js";
1
+ import { Rr as PKCError, V as pubsubTopicToDhtKeyCid } from "./util-B81IOt07.js";
2
2
  import { ipnsSelector } from "ipns/selector";
3
3
  import { ipnsValidator } from "ipns/validator";
4
4
  import { unmarshalIPNSRecord } from "ipns";
@@ -1,5 +1,5 @@
1
- import { Rr as PKCError, bn as PageSortFileFactorySchema, cn as ChallengeFileSchema, sn as ChallengeFileFactorySchema } from "./util-Bnqvxk-6.js";
2
- import { s as validatePageSortFile } from "./page-sort-scoring-DgSzIxmE.js";
1
+ import { Rr as PKCError, bn as PageSortFileFactorySchema, cn as ChallengeFileSchema, sn as ChallengeFileFactorySchema } from "./util-B81IOt07.js";
2
+ import { s as validatePageSortFile } from "./page-sort-scoring-DbI7k_K5.js";
3
3
  //#region dist/node/validate-package-factories.js
4
4
  function validateChallengeFileFactory(factory, { name }) {
5
5
  try {
@@ -1,2 +1,2 @@
1
- import { a as getShortCid, c as setNativeFunctions, i as getShortAddress, n as challenges, o as nativeFunctions, r as createAnchorIpnsRecord, s as pageSorts, t as PKC } from "./chunks/node-BXilwSVE.js";
1
+ import { a as getShortCid, c as setNativeFunctions, i as getShortAddress, n as challenges, o as nativeFunctions, r as createAnchorIpnsRecord, s as pageSorts, t as PKC } from "./chunks/node-fEBX1Nar.js";
2
2
  export { challenges, createAnchorIpnsRecord, PKC as default, getShortAddress, getShortCid, nativeFunctions, pageSorts, setNativeFunctions };
@@ -1,2 +1,2 @@
1
- import { n as validatePageSortFileFactory } from "./chunks/validate-package-factories-MG5ehoSU.js";
1
+ import { n as validatePageSortFileFactory } from "./chunks/validate-package-factories-Bi1OLIPw.js";
2
2
  export { validatePageSortFileFactory };
@@ -1,7 +1,7 @@
1
- import { At as pTimeout, Br as logger_default, C as hideClassPrivateProps, Rr as PKCError, X as replaceXWithY, et as retryKuboIpfsAddAndProvide, ft as findStartedCommunity, i as calculateStringSizeSameAsIpfsAddCidV0, xr as t, yr as n } from "../../chunks/util-Bnqvxk-6.js";
2
- import { S as parseRpcUnsubscribeParam, _ as parseRpcExportCommunityParam, b as parseRpcPublishChallengeAnswersParam, d as parseRpcCidParam, f as parseRpcCommentRepliesPageParam, g as parseRpcExportCommunityModLogsParam, h as parseRpcEditCommunityParam, l as parseRpcAuthorNameParam, m as parseRpcCommunityPageParam, p as parseRpcCommunityIdentifierParam, t as PKC, u as parseRpcCancelExportParam, v as parseRpcFetchCommunityListParam, x as parseRpcPublishCommunityListParam, y as parseRpcPublishAnchorRecordParam } from "../../chunks/node-BXilwSVE.js";
3
- import { Dt as parseJsonWithPKCErrorIfFails, E as buildPagesRuntimeFields, Gr as stringify, L as extractCrosspostRuntimeFields, Mt as parseVoteChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, Pr as toCommunitiesWireEntry, Rr as t$1, T as buildPageRuntimeFields, Tr as listCommunitiesSync, U as pRetry, Vn as verifyCommunityList, W as pLimit, Xn as MAX_COMMUNITY_LIST_SIZE_BYTES, at as parseCommentModerationChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, br as findLocalCommunityAddress, bt as parseCreatePKCWsServerOptionsSchemaWithPKCErrorIfItFails, dt as parseCommunityEditOptionsSchemaWithPKCErrorIfItFails, jt as parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, mt as parseCommunityListSchemaWithPKCErrorIfItFails, nt as parseCommentEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, sn as require_lib, tt as parseCommentChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, ut as parseCommunityEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, wt as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, yt as parseCreateNewLocalCommunityUserOptionsSchemaWithPKCErrorIfItFails } from "../../chunks/rpc-local-community-BK_HGb_u.js";
4
- import { t as LocalCommunity } from "../../chunks/local-community-BY1ouP1-.js";
1
+ import { At as pTimeout, Br as logger_default, C as hideClassPrivateProps, Rr as PKCError, X as replaceXWithY, et as retryKuboIpfsAddAndProvide, ft as findStartedCommunity, i as calculateStringSizeSameAsIpfsAddCidV0, xr as t, yr as n } from "../../chunks/util-B81IOt07.js";
2
+ import { S as parseRpcUnsubscribeParam, _ as parseRpcExportCommunityParam, b as parseRpcPublishChallengeAnswersParam, d as parseRpcCidParam, f as parseRpcCommentRepliesPageParam, g as parseRpcExportCommunityModLogsParam, h as parseRpcEditCommunityParam, l as parseRpcAuthorNameParam, m as parseRpcCommunityPageParam, p as parseRpcCommunityIdentifierParam, t as PKC, u as parseRpcCancelExportParam, v as parseRpcFetchCommunityListParam, x as parseRpcPublishCommunityListParam, y as parseRpcPublishAnchorRecordParam } from "../../chunks/node-fEBX1Nar.js";
3
+ import { Br as t$1, Dt as parseJsonWithPKCErrorIfFails, E as buildPagesRuntimeFields, Er as listCommunitiesSync, Ir as toCommunitiesWireEntry, L as extractCrosspostRuntimeFields, Mt as parseVoteChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, T as buildPageRuntimeFields, U as pRetry, Vn as verifyCommunityList, W as pLimit, Xn as MAX_COMMUNITY_LIST_SIZE_BYTES, at as parseCommentModerationChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, br as findLocalCommunityAddress, bt as parseCreatePKCWsServerOptionsSchemaWithPKCErrorIfItFails, dt as parseCommunityEditOptionsSchemaWithPKCErrorIfItFails, jt as parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, mt as parseCommunityListSchemaWithPKCErrorIfItFails, nt as parseCommentEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, qr as stringify, sn as require_lib, tt as parseCommentChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, ut as parseCommunityEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, wt as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, yt as parseCreateNewLocalCommunityUserOptionsSchemaWithPKCErrorIfItFails } from "../../chunks/rpc-local-community-ouDezuGZ.js";
4
+ import { t as LocalCommunity } from "../../chunks/local-community-dVaQtJNM.js";
5
5
  import { fileURLToPath } from "node:url";
6
6
  import path from "path";
7
7
  import assert from "assert";
@@ -51,6 +51,14 @@ const GATEWAYS_THAT_SUPPORT_SUBDOMAIN_RESOLUTION = {}; // gateway url -> whether
51
51
  // 100 sits above the realistic batch window, so coalescing survives, and caps the burst for the
52
52
  // resolvers that do not batch.
53
53
  const MAX_CONCURRENT_AUTHOR_NAME_RESOLUTIONS = 100;
54
+ // Whether a path resolve failed because a directory on the way was read and has no entry of that name. Kubo's RPC
55
+ // reports it as an HTTP 500 whose message is `no link named "<name>" under <cid>`, with no code of its own, and helia's
56
+ // unixfs throws DoesNotExistError. A directory that could not be loaded fails differently (a timeout, no providers)
57
+ function isIpfsPathNotInFolderError(error) {
58
+ if (!(error instanceof Error))
59
+ return false;
60
+ return error.name === "DoesNotExistError" || (error.name === "HTTPError" && /^no link named /.test(error.message));
61
+ }
54
62
  // Waits for a resolve another caller started. A resolve is bounded only by its owner's signal, so the wait
55
63
  // ends as soon as the joiner is stopped and leaves nothing on the resolve: a stopped Comment or community must
56
64
  // not stay referenced through its onResolved until someone else's resolve settles.
@@ -688,8 +696,10 @@ export class BaseClientsManager {
688
696
  // The cid an /ipfs/ path names, as CIDv1, or undefined when it cannot be told. Files are content-addressed, so a
689
697
  // caller comparing it with the cid it last fetched can skip an unchanged file without reading it (issue #312).
690
698
  // Kubo and helia walk only the directory blocks on the way, which an unchanged path already has locally. Undefined
691
- // with only gateways. Throws only ERR_FETCH_CID_P2P_TIMEOUT: the walk could not reach the path's blocks in time, and
692
- // a fetch of the path would walk the same blocks. Any other failure is undefined, and the caller fetches anyway.
699
+ // with only gateways. Throws ERR_FETCH_CID_P2P_TIMEOUT when the walk could not reach the path's blocks in time: a
700
+ // fetch of the path would walk the same blocks. Throws ERR_IPFS_PATH_NOT_IN_FOLDER when the walk read the folder and
701
+ // it has no such entry: the folder is named by its cid, so that answer does not change and a fetch would only
702
+ // repeat it. Any other failure is undefined, and the caller fetches anyway.
693
703
  async _resolveIpfsPathToCid({ root, path, timeoutMs, abortSignal, log, bitswapSessionSeedScopeIpnsPubsubTopic }) {
694
704
  try {
695
705
  if (keys(this._pkc.clients.kuboRpcClients).length > 0 || keys(this._pkc.clients.libp2pJsClients).length > 0) {
@@ -716,6 +726,8 @@ export class BaseClientsManager {
716
726
  throw e; // helia's own timeout
717
727
  if (e instanceof Error && e.name === "TimeoutError" && !abortSignal?.aborted)
718
728
  throw new PKCError("ERR_FETCH_CID_P2P_TIMEOUT", { ipfsPath: `/ipfs/${root}/${path}`, timeoutMs, error: e });
729
+ if (isIpfsPathNotInFolderError(e))
730
+ throw new PKCError("ERR_IPFS_PATH_NOT_IN_FOLDER", { ipfsPath: `/ipfs/${root}/${path}`, error: e });
719
731
  log.trace("Could not resolve", `${root}/${path}`, "to a cid, the caller will fetch it", e);
720
732
  return undefined;
721
733
  }