@pkcprotocol/pkc-js 0.0.103 → 0.0.105

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 (155) hide show
  1. package/dist/browser/clients/base-client-manager.d.ts +1 -0
  2. package/dist/browser/clients/base-client-manager.js +85 -15
  3. package/dist/browser/clients/base-client-manager.js.map +1 -1
  4. package/dist/browser/community/community-client-manager.d.ts +3 -0
  5. package/dist/browser/community/community-client-manager.js +87 -14
  6. package/dist/browser/community/community-client-manager.js.map +1 -1
  7. package/dist/browser/community/remote-community.js +3 -0
  8. package/dist/browser/community/remote-community.js.map +1 -1
  9. package/dist/browser/community/schema.d.ts +4 -0
  10. package/dist/browser/community/schema.js +7 -1
  11. package/dist/browser/community/schema.js.map +1 -1
  12. package/dist/browser/constants.d.ts +3 -0
  13. package/dist/browser/constants.js +35 -0
  14. package/dist/browser/constants.js.map +1 -1
  15. package/dist/browser/errors.d.ts +5 -1
  16. package/dist/browser/errors.js +7 -1
  17. package/dist/browser/errors.js.map +1 -1
  18. package/dist/browser/generated-version.d.ts +1 -1
  19. package/dist/browser/generated-version.js +1 -1
  20. package/dist/browser/index-with-compile-cache.d.ts +2 -0
  21. package/dist/browser/index.d.ts +2 -0
  22. package/dist/browser/pkc/pkc.d.ts +4 -0
  23. package/dist/browser/pkc/pkc.js +30 -1
  24. package/dist/browser/pkc/pkc.js.map +1 -1
  25. package/dist/browser/pkc-error.d.ts +1 -1
  26. package/dist/browser/publications/comment/comment-client-manager.js +11 -0
  27. package/dist/browser/publications/comment/comment-client-manager.js.map +1 -1
  28. package/dist/browser/publications/comment/comment.js +8 -6
  29. package/dist/browser/publications/comment/comment.js.map +1 -1
  30. package/dist/browser/publications/comment/crosspost-runtime.js +3 -2
  31. package/dist/browser/publications/comment/crosspost-runtime.js.map +1 -1
  32. package/dist/browser/rpc/src/index.js +6 -0
  33. package/dist/browser/rpc/src/index.js.map +1 -1
  34. package/dist/browser/rpc/src/lib/pkc-js/index.d.ts +1 -0
  35. package/dist/browser/rpc/src/schema.d.ts +6 -0
  36. package/dist/browser/runtime/node/community/challenges/exclude/exclude.d.ts +11 -1
  37. package/dist/browser/runtime/node/community/challenges/exclude/exclude.js +32 -21
  38. package/dist/browser/runtime/node/community/challenges/exclude/exclude.js.map +1 -1
  39. package/dist/browser/runtime/node/community/challenges/index.d.ts +10 -3
  40. package/dist/browser/runtime/node/community/challenges/index.js +82 -16
  41. package/dist/browser/runtime/node/community/challenges/index.js.map +1 -1
  42. package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/blacklist.js +7 -4
  43. package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/blacklist.js.map +1 -1
  44. package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/whitelist.js +13 -5
  45. package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/whitelist.js.map +1 -1
  46. package/dist/browser/runtime/node/community/local-community/author-identity.d.ts +37 -2
  47. package/dist/browser/runtime/node/community/local-community/author-identity.js +73 -13
  48. package/dist/browser/runtime/node/community/local-community/author-identity.js.map +1 -1
  49. package/dist/browser/runtime/node/community/local-community/challenges.d.ts +16 -2
  50. package/dist/browser/runtime/node/community/local-community/challenges.js +40 -9
  51. package/dist/browser/runtime/node/community/local-community/challenges.js.map +1 -1
  52. package/dist/browser/runtime/node/community/local-community/editing.js +7 -2
  53. package/dist/browser/runtime/node/community/local-community/editing.js.map +1 -1
  54. package/dist/browser/runtime/node/community/local-community/publication-store.d.ts +13 -2
  55. package/dist/browser/runtime/node/community/local-community/publication-store.js +29 -7
  56. package/dist/browser/runtime/node/community/local-community/publication-store.js.map +1 -1
  57. package/dist/browser/runtime/node/community/local-community/publication-validation.d.ts +13 -3
  58. package/dist/browser/runtime/node/community/local-community/publication-validation.js +60 -27
  59. package/dist/browser/runtime/node/community/local-community/publication-validation.js.map +1 -1
  60. package/dist/browser/runtime/node/community/local-community.d.ts +2 -2
  61. package/dist/browser/runtime/node/community/local-community.js +6 -4
  62. package/dist/browser/runtime/node/community/local-community.js.map +1 -1
  63. package/dist/browser/runtime/node/util.js +18 -8
  64. package/dist/browser/runtime/node/util.js.map +1 -1
  65. package/dist/browser/schema.d.ts +8 -0
  66. package/dist/browser/test/test-util.d.ts +6 -0
  67. package/dist/browser/test/test-util.js +32 -1
  68. package/dist/browser/test/test-util.js.map +1 -1
  69. package/dist/browser/types.d.ts +1 -0
  70. package/dist/browser/util.d.ts +2 -0
  71. package/dist/browser/util.js +24 -0
  72. package/dist/browser/util.js.map +1 -1
  73. package/dist/bundled/bundle-manifest.json +32 -32
  74. package/dist/bundled/chunks/{helia-for-pkc-BqRIFXGX.js → helia-for-pkc-DanrSDp0.js} +2 -2
  75. package/dist/bundled/chunks/{local-community-mF7g4deD.js → local-community-Bsj3T9vI.js} +1 -1
  76. package/dist/bundled/chunks/{local-community-D0dqj6lQ.js → local-community-h9j5crnN.js} +159 -60
  77. package/dist/bundled/chunks/{node--l7gxhms.js → node-Czo2D65i.js} +19 -8
  78. package/dist/bundled/chunks/{rpc-local-community-C3o1AzHp.js → rpc-local-community-CP0JZU-Q.js} +291 -113
  79. package/dist/bundled/chunks/{schema-MeRr3oiN.js → schema-bdQ9ufF9.js} +26 -4
  80. package/dist/bundled/chunks/{util-CjRKlVEE.js → util-CEpMupHn.js} +1 -1
  81. package/dist/bundled/index.js +1 -1
  82. package/dist/bundled/rpc/src/index.js +9 -4
  83. package/dist/node/clients/base-client-manager.d.ts +1 -0
  84. package/dist/node/clients/base-client-manager.js +85 -15
  85. package/dist/node/clients/base-client-manager.js.map +1 -1
  86. package/dist/node/community/community-client-manager.d.ts +3 -0
  87. package/dist/node/community/community-client-manager.js +87 -14
  88. package/dist/node/community/community-client-manager.js.map +1 -1
  89. package/dist/node/community/remote-community.js +3 -0
  90. package/dist/node/community/remote-community.js.map +1 -1
  91. package/dist/node/community/schema.d.ts +4 -0
  92. package/dist/node/community/schema.js +7 -1
  93. package/dist/node/community/schema.js.map +1 -1
  94. package/dist/node/constants.d.ts +3 -0
  95. package/dist/node/constants.js +35 -0
  96. package/dist/node/constants.js.map +1 -1
  97. package/dist/node/errors.d.ts +5 -1
  98. package/dist/node/errors.js +7 -1
  99. package/dist/node/errors.js.map +1 -1
  100. package/dist/node/generated-version.d.ts +1 -1
  101. package/dist/node/generated-version.js +1 -1
  102. package/dist/node/index-with-compile-cache.d.ts +2 -0
  103. package/dist/node/index.d.ts +2 -0
  104. package/dist/node/pkc/pkc.d.ts +4 -0
  105. package/dist/node/pkc/pkc.js +30 -1
  106. package/dist/node/pkc/pkc.js.map +1 -1
  107. package/dist/node/pkc-error.d.ts +1 -1
  108. package/dist/node/publications/comment/comment-client-manager.js +11 -0
  109. package/dist/node/publications/comment/comment-client-manager.js.map +1 -1
  110. package/dist/node/publications/comment/comment.js +8 -6
  111. package/dist/node/publications/comment/comment.js.map +1 -1
  112. package/dist/node/publications/comment/crosspost-runtime.js +3 -2
  113. package/dist/node/publications/comment/crosspost-runtime.js.map +1 -1
  114. package/dist/node/rpc/src/index.js +6 -0
  115. package/dist/node/rpc/src/index.js.map +1 -1
  116. package/dist/node/rpc/src/lib/pkc-js/index.d.ts +1 -0
  117. package/dist/node/rpc/src/schema.d.ts +6 -0
  118. package/dist/node/runtime/node/community/challenges/exclude/exclude.d.ts +11 -1
  119. package/dist/node/runtime/node/community/challenges/exclude/exclude.js +32 -21
  120. package/dist/node/runtime/node/community/challenges/exclude/exclude.js.map +1 -1
  121. package/dist/node/runtime/node/community/challenges/index.d.ts +10 -3
  122. package/dist/node/runtime/node/community/challenges/index.js +82 -16
  123. package/dist/node/runtime/node/community/challenges/index.js.map +1 -1
  124. package/dist/node/runtime/node/community/challenges/pkc-js-challenges/blacklist.js +7 -4
  125. package/dist/node/runtime/node/community/challenges/pkc-js-challenges/blacklist.js.map +1 -1
  126. package/dist/node/runtime/node/community/challenges/pkc-js-challenges/whitelist.js +13 -5
  127. package/dist/node/runtime/node/community/challenges/pkc-js-challenges/whitelist.js.map +1 -1
  128. package/dist/node/runtime/node/community/local-community/author-identity.d.ts +37 -2
  129. package/dist/node/runtime/node/community/local-community/author-identity.js +73 -13
  130. package/dist/node/runtime/node/community/local-community/author-identity.js.map +1 -1
  131. package/dist/node/runtime/node/community/local-community/challenges.d.ts +16 -2
  132. package/dist/node/runtime/node/community/local-community/challenges.js +40 -9
  133. package/dist/node/runtime/node/community/local-community/challenges.js.map +1 -1
  134. package/dist/node/runtime/node/community/local-community/editing.js +7 -2
  135. package/dist/node/runtime/node/community/local-community/editing.js.map +1 -1
  136. package/dist/node/runtime/node/community/local-community/publication-store.d.ts +13 -2
  137. package/dist/node/runtime/node/community/local-community/publication-store.js +29 -7
  138. package/dist/node/runtime/node/community/local-community/publication-store.js.map +1 -1
  139. package/dist/node/runtime/node/community/local-community/publication-validation.d.ts +13 -3
  140. package/dist/node/runtime/node/community/local-community/publication-validation.js +60 -27
  141. package/dist/node/runtime/node/community/local-community/publication-validation.js.map +1 -1
  142. package/dist/node/runtime/node/community/local-community.d.ts +2 -2
  143. package/dist/node/runtime/node/community/local-community.js +6 -4
  144. package/dist/node/runtime/node/community/local-community.js.map +1 -1
  145. package/dist/node/runtime/node/util.js +18 -8
  146. package/dist/node/runtime/node/util.js.map +1 -1
  147. package/dist/node/schema.d.ts +8 -0
  148. package/dist/node/test/test-util.d.ts +6 -0
  149. package/dist/node/test/test-util.js +32 -1
  150. package/dist/node/test/test-util.js.map +1 -1
  151. package/dist/node/types.d.ts +1 -0
  152. package/dist/node/util.d.ts +2 -0
  153. package/dist/node/util.js +24 -0
  154. package/dist/node/util.js.map +1 -1
  155. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  import { i as __toESM, r as __require, t as __commonJSMin } from "./chunk-2rV9d50f.js";
2
- import { A as doesDomainAddressHaveCapitalLetter, B as ipnsNameToIpnsOverPubsubTopic, Bn as CommentEditPubsubMessagePublicationSchema, C as calculateStringSizeSameAsIpfsAddCidV0, Cn as CommentIpfsSchema, Cr as messages, Ct as findCommunityInRegistry, E as contentContainsMarkdownVideos, Et as findUpdatingCommunity, F as getErrorCodeFromMessage, Ft as trackUpdatingCommunity, Hn as CommentEditReservedFields, I as getIpnsRecordInLocalKuboNode, It as untrackStartedCommunity, J as isLinkOfImage, Jn as AuthorReservedFields, Jt as CommentModerationPubsubMessagePublicationSchema, K as isLinkOfAnimatedImage, Lr as ZodError, Mt as syncCommunityRegistryEntry, N as genToArray, Nn as CommentUpdateTableRowSchema, Nt as trackStartedCommunity, P as getEquivalentCommunityAddresses, Pn as CommentsTableRowSchema, R as hideClassPrivateProps, Rt as untrackUpdatingCommunity, S as calculateIpfsCidV0, Sr as PKCError, St as writeKuboFilesWithTimeout, T as contentContainsMarkdownImages, Ut as CommunityEditPublicationPubsubReservedFields, Vn as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema, Vt as pTimeout, Wn as CommentEditsTableRowSchema, X as isLinkOfVideo, Y as isLinkOfMedia, Yt as CommentModerationReservedFields, Z as isLinkValid, Zt as CommentModerationsTableRowSchema, _n as VotePubsubMessagePublicationSchema, _t as sleepUntilTimeoutOrAbort, a as ChallengeRequestMessageSchema, ar as t$6, at as removeBlocksFromKuboNode, b as areEquivalentCommunityAddresses, bn as VoteTablesRowSchema, bt as timestamp, ct as removeNullUndefinedValues, d as DecryptedChallengeRequestSchema, et as pubsubTopicToDhtKey, ft as retryKuboBlockPutPinAndProvidePubsubTopic, gr as require_retry, ir as t$7, jn as CommentUpdateSchema, k as derivePublicationFromChallengeRequest, lr as r$1, mn as isStringDomain, mr as t$3, mt as retryKuboIpfsAddAndProvide, nr as t$8, on as CommunityIpfsSchema, or as e, ot as removeMfsFilesSafely, pr as t$5, q as isLinkOfAudio, r as ChallengeMessageSchema, rr as n$3, s as ChallengeVerificationMessageSchema, sn as CommunitySignedPropertyNames, sr as e$1, t as ChallengeAnswerMessageSchema, tr as n$4, u as DecryptedChallengeRequestPublicationSchema, ur as t$4, vn as VotePubsubReservedFields, vt as statMfsPathSafely, w as contentContainsMarkdownAudio, wn as CommentPubsubMessageReservedFields, wr as logger_default, wt as findStartedCommunity, y as version_default, zt as require_sha256 } from "./schema-MeRr3oiN.js";
3
- import { $t as getPKCAddressFromPublicKeySync, A as deriveCommentIpfsFromCommentTableRow, At as verifyCommentEdit, B as resolveDbPostsCidRefs, C as encryptEd25519AesGcmPublicKeyBuffer, Ct as signCommunity, D as calculateInlineRepliesBudget, Dn as parseJsonWithPKCErrorIfFails, E as calculateExpectedSignatureSize, Et as verifyChallengeAnswer, F as getThumbnailPropsOfLink, Ft as verifyCommunity, G as POST_REPLIES_SORT_TYPES, Gt as getCommunityNameFromWire, I as importSignerIntoKuboNode, It as verifyCommunityEdit, Jt as decode, K as REPLY_REPLIES_SORT_TYPES, Kt as getCommunityPublicKeyFromWire, Lt as verifyVote, M as deriveDbReplies, Mt as verifyCommentModeration, N as getDefaultCommunityDbConfig, Nt as verifyCommentPubsubMessage, Ot as verifyChallengeRequest, Pt as verifyCommentUpdate, Q as iterateOverPageCidsToFindAllCids, Qt as getPKCAddressFromPublicKey, Rt as buildRuntimeAuthor, St as signCommentUpdateForChallengeVerification, T as backupCommunityDb, Vt as getAuthorNameFromWire, W as POSTS_SORT_TYPES, Yt as encode, Zt as getIpfsKeyFromPrivateKey, _ as SignerWithPublicKeyAddress, _t as signChallengeVerification, a as loadChallengeFileFromCommunityChallengeSettings, ar as r$2, c as TrackedInstanceRegistry, cr as n$5, d as MAX_FILE_SIZE_BYTES_FOR_COMMUNITY_IPFS, dr as stringify, en as getPublicKeyFromPrivateKey, f as KeyvBetterSqlite3, fn as parseCommunityEditOptionsSchemaWithPKCErrorIfItFails, fr as STORAGE_KEYS, ht as signChallengeMessage, i as getCommunityChallengeFromCommunityChallengeSettings, ir as t$12, j as deriveDbPosts, jt as verifyCommentIpfs, k as deleteOldCommunityInWindows, l as LRUCache, mn as parseCommunityIpfsSchemaPassthroughWithPKCErrorIfItFails, nr as effectiveMaxCrosspostDepth, o as pkcJsChallenges, or as t$11, pr as require_lodash_merge, pt as cleanUpBeforePublishing, q as TIMEFRAMES_TO_SECONDS, r as getChallengeVerification, rr as t$9, s as createAuthorIdentityMatcher, sr as n$6, t as RpcLocalCommunity, tn as createSchemaRowParser, tr as crosspostChainDepthUpTo, ur as t$10, ut as pLimit, vt as signComment, w as BackupAbortError, wn as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, x as decryptEd25519AesGcmPublicKeyBuffer, xt as signCommentUpdate, yt as signCommentEdit, z as moveCommunityDbToDeletedDirectory, zt as cleanWireAuthor } from "./rpc-local-community-C3o1AzHp.js";
2
+ import { A as doesDomainAddressHaveCapitalLetter, Bt as require_sha256, C as calculateStringSizeSameAsIpfsAddCidV0, Cr as PKCError, Ct as writeKuboFilesWithTimeout, Dt as findUpdatingCommunity, E as contentContainsMarkdownVideos, F as getErrorCodeFromMessage, Fn as CommentsTableRowSchema, Gn as CommentEditsTableRowSchema, Hn as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema, Ht as pTimeout, I as getIpnsRecordInLocalKuboNode, It as trackUpdatingCommunity, J as isLinkOfAudio, Lt as untrackStartedCommunity, Mn as CommentUpdateSchema, N as genToArray, Nt as syncCommunityRegistryEntry, P as getEquivalentCommunityAddresses, Pn as CommentUpdateTableRowSchema, Pt as trackStartedCommunity, Q as isLinkValid, Qt as CommentModerationsTableRowSchema, Rr as ZodError, S as calculateIpfsCidV0, T as contentContainsMarkdownImages, Tn as CommentPubsubMessageReservedFields, Tr as logger_default, Tt as findStartedCommunity, Un as CommentEditReservedFields, V as ipnsNameToIpnsOverPubsubTopic, Vn as CommentEditPubsubMessagePublicationSchema, Wt as CommunityEditPublicationPubsubReservedFields, X as isLinkOfMedia, Xt as CommentModerationReservedFields, Y as isLinkOfImage, Yn as AuthorReservedFields, Yt as CommentModerationPubsubMessagePublicationSchema, Z as isLinkOfVideo, _r as require_retry, a as ChallengeRequestMessageSchema, ar as t$7, b as areEquivalentCommunityAddresses, cn as CommunitySignedPropertyNames, cr as e$1, d as DecryptedChallengeRequestSchema, dr as t$4, hn as isStringDomain, hr as t$3, ht as retryKuboIpfsAddAndProvide, ir as n$3, k as derivePublicationFromChallengeRequest, lt as removeNullUndefinedValues, mr as t$5, nr as n$4, or as t$6, ot as removeBlocksFromKuboNode, pt as retryKuboBlockPutPinAndProvidePubsubTopic, q as isLinkOfAnimatedImage, r as ChallengeMessageSchema, rr as t$8, s as ChallengeVerificationMessageSchema, sn as CommunityIpfsSchema, sr as e, st as removeMfsFilesSafely, t as ChallengeAnswerMessageSchema, tt as pubsubTopicToDhtKey, u as DecryptedChallengeRequestPublicationSchema, ur as r$1, vn as VotePubsubMessagePublicationSchema, vt as sleepUntilTimeoutOrAbort, w as contentContainsMarkdownAudio, wn as CommentIpfsSchema, wr as messages, wt as findCommunityInRegistry, xn as VoteTablesRowSchema, xt as timestamp, y as version_default, yn as VotePubsubReservedFields, yt as statMfsPathSafely, z as hideClassPrivateProps, zt as untrackUpdatingCommunity } from "./schema-bdQ9ufF9.js";
3
+ import { $t as getIpfsKeyFromPrivateKey, At as verifyChallengeRequest, Bt as buildRuntimeAuthor, C as decryptEd25519AesGcmPublicKeyBuffer, Ct as signCommentUpdate, D as backupCommunityDb, E as BackupAbortError, En as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, F as getDefaultCommunityDbConfig, Ft as verifyCommentPubsubMessage, H as resolveDbPostsCidRefs, It as verifyCommentUpdate, J as REPLY_REPLIES_SORT_TYPES, Jt as getCommunityPublicKeyFromWire, K as POSTS_SORT_TYPES, L as getThumbnailPropsOfLink, Lt as verifyCommunity, M as deriveCommentIpfsFromCommentTableRow, Mt as verifyCommentEdit, N as deriveDbPosts, Nt as verifyCommentIpfs, O as calculateExpectedSignatureSize, Ot as verifyChallengeAnswer, P as deriveDbReplies, Pt as verifyCommentModeration, R as importSignerIntoKuboNode, Rt as verifyCommunityEdit, T as encryptEd25519AesGcmPublicKeyBuffer, Tt as signCommunity, Ut as getAuthorNameFromWire, V as moveCommunityDbToDeletedDirectory, Vt as cleanWireAuthor, Xt as decode, Y as TIMEFRAMES_TO_SECONDS, Zt as encode, _r as STORAGE_KEYS, _t as signChallengeMessage, a as loadChallengeFileFromCommunityChallengeSettings, ar as t$9, bt as signComment, c as authorNameResolveFailureReason, cr as t$11, d as LRUCache, en as getPKCAddressFromPublicKey, et as iterateOverPageCidsToFindAllCids, fr as t$10, ft as pLimit, gn as parseCommunityIpfsSchemaPassthroughWithPKCErrorIfItFails, ht as cleanUpBeforePublishing, i as getCommunityChallengeFromCommunityChallengeSettings, ir as effectiveMaxCrosspostDepth, j as deleteOldCommunityInWindows, k as calculateInlineRepliesBudget, kn as parseJsonWithPKCErrorIfFails, l as createAuthorIdentityMatcher, lr as n$6, m as KeyvBetterSqlite3, mn as parseCommunityEditOptionsSchemaWithPKCErrorIfItFails, nn as getPublicKeyFromPrivateKey, o as pkcJsChallenges, or as t$12, p as MAX_FILE_SIZE_BYTES_FOR_COMMUNITY_IPFS, pr as stringify, q as POST_REPLIES_SORT_TYPES, qt as getCommunityNameFromWire, r as getChallengeVerification, rn as createSchemaRowParser, rr as crosspostChainDepthUpTo, s as authorIdentityMatcherForRequest, sr as r$2, t as RpcLocalCommunity, tn as getPKCAddressFromPublicKeySync, u as TrackedInstanceRegistry, ur as n$5, vr as require_lodash_merge, wt as signCommentUpdateForChallengeVerification, xt as signCommentEdit, y as SignerWithPublicKeyAddress, yt as signChallengeVerification, zt as verifyVote } from "./rpc-local-community-CP0JZU-Q.js";
4
4
  import { randomFillSync, randomUUID } from "node:crypto";
5
5
  import { fileURLToPath, pathToFileURL } from "node:url";
6
6
  import Path from "node:path";
@@ -831,8 +831,14 @@ async function publishIdempotentDuplicateVerification(community, request, challe
831
831
  delete community._challengeExchangesFromLocalPublishers[challengeRequestId.toString()];
832
832
  cleanUpChallengeAnswerPromise(community, challengeRequestId.toString());
833
833
  }
834
- async function storePublicationAndEncryptForChallengeVerification(community, request, pendingApproval, challengeAggregate) {
835
- const commentAfterAddingToIpfs = await storePublication(community, request, pendingApproval, challengeAggregate);
834
+ async function storePublicationAndEncryptForChallengeVerification({ community, request, pendingApproval, challengeAggregate, authorIdentityMatcher }) {
835
+ const commentAfterAddingToIpfs = await storePublication({
836
+ community,
837
+ request,
838
+ pendingApproval,
839
+ challengeAggregate,
840
+ authorIdentityMatcher
841
+ });
836
842
  if (!commentAfterAddingToIpfs) return void 0;
837
843
  const authorSignerAddress = await getPKCAddressFromPublicKey(commentAfterAddingToIpfs.comment.signature.publicKey);
838
844
  const authorDomain = getAuthorNameFromWire(commentAfterAddingToIpfs.comment.author);
@@ -864,14 +870,20 @@ async function storePublicationAndEncryptForChallengeVerification(community, req
864
870
  encrypted
865
871
  };
866
872
  }
867
- async function publishChallengeVerification(community, challengeResult, request, pendingApproval, challengeAggregate) {
873
+ async function publishChallengeVerification({ community, challengeResult, request, pendingApproval, challengeAggregate, authorIdentityMatcher }) {
868
874
  const log = logger_default("pkc-js:local-community:_publishChallengeVerification");
869
875
  if (!challengeResult.challengeSuccess) return publishFailedChallengeVerification(community, challengeResult, request.challengeRequestId);
870
876
  else {
871
877
  let failureReason;
872
878
  let toEncrypt;
873
879
  try {
874
- toEncrypt = await storePublicationAndEncryptForChallengeVerification(community, request, pendingApproval, challengeAggregate);
880
+ toEncrypt = await storePublicationAndEncryptForChallengeVerification({
881
+ community,
882
+ request,
883
+ pendingApproval,
884
+ challengeAggregate,
885
+ authorIdentityMatcher
886
+ });
875
887
  } catch (e) {
876
888
  const error = e;
877
889
  if (DUPLICATE_PUBLICATION_ERRORS.has(error.message)) {
@@ -1034,7 +1046,17 @@ async function validatePublicationOrRespondWithFailure({ community, decryptedReq
1034
1046
  request: decryptedRequestMsg,
1035
1047
  authorCommunity: communityAuthor
1036
1048
  });
1037
- const publicationInvalidityReason = await checkPublicationValidity(community, decryptedRequestMsg, publication, communityAuthor);
1049
+ const authorIdentityMatcher = createAuthorIdentityMatcher({
1050
+ community,
1051
+ publication
1052
+ });
1053
+ const publicationInvalidityReason = await checkPublicationValidity({
1054
+ community,
1055
+ request: decryptedRequestMsg,
1056
+ publication,
1057
+ authorCommunity: communityAuthor,
1058
+ authorIdentityMatcher
1059
+ });
1038
1060
  if (publicationInvalidityReason) {
1039
1061
  if (DUPLICATE_PUBLICATION_ERRORS.has(publicationInvalidityReason)) {
1040
1062
  const sig = publication.signature.signature;
@@ -1055,11 +1077,12 @@ async function validatePublicationOrRespondWithFailure({ community, decryptedReq
1055
1077
  decryptedRequestMsg,
1056
1078
  decryptedRequestWithCommunityAuthor,
1057
1079
  publication,
1058
- communityAuthor
1080
+ communityAuthor,
1081
+ authorIdentityMatcher
1059
1082
  };
1060
1083
  }
1061
1084
  async function runChallengeExchangeIfNeeded(community, parsed, log) {
1062
- const { decryptedRequestWithCommunityAuthor } = parsed;
1085
+ const { decryptedRequestWithCommunityAuthor, authorIdentityMatcher } = parsed;
1063
1086
  const answerPromiseKey = decryptedRequestWithCommunityAuthor.challengeRequestId.toString();
1064
1087
  const getChallengeAnswers = async (challenges) => {
1065
1088
  await publishChallenges(community, challenges, decryptedRequestWithCommunityAuthor);
@@ -1087,7 +1110,8 @@ async function runChallengeExchangeIfNeeded(community, parsed, log) {
1087
1110
  challengeVerification = await getChallengeVerification({
1088
1111
  challengeRequestMessage: decryptedRequestWithCommunityAuthor,
1089
1112
  community,
1090
- getChallengeAnswers
1113
+ getChallengeAnswers,
1114
+ authorIdentityMatcher
1091
1115
  });
1092
1116
  } catch (e) {
1093
1117
  if (e instanceof PKCError && e.code === "ERR_COMMUNITY_TIMED_OUT_WAITING_FOR_CHALLENGE_ANSWER") {
@@ -1114,11 +1138,18 @@ async function runVerificationAndStorePublication(community, parsed, challengeVe
1114
1138
  aggregatedCommentUpdate: challengeVerification.aggregatedCommentUpdate,
1115
1139
  aggregatedReason: challengeVerification.aggregatedReason
1116
1140
  };
1117
- await publishChallengeVerification(community, {
1118
- challengeSuccess: challengeVerification.challengeSuccess,
1119
- challengeErrors: challengeVerification.challengeErrors,
1120
- reason: challengeVerification.reason ?? challengeVerification.aggregatedReason
1121
- }, parsed.decryptedRequestMsg, challengeVerification.pendingApproval, aggregate);
1141
+ await publishChallengeVerification({
1142
+ community,
1143
+ challengeResult: {
1144
+ challengeSuccess: challengeVerification.challengeSuccess,
1145
+ challengeErrors: challengeVerification.challengeErrors,
1146
+ reason: challengeVerification.reason ?? challengeVerification.aggregatedReason
1147
+ },
1148
+ request: parsed.decryptedRequestMsg,
1149
+ pendingApproval: challengeVerification.pendingApproval,
1150
+ challengeAggregate: aggregate,
1151
+ authorIdentityMatcher: challengeVerification.postAnswerAuthorIdentityMatcher ?? parsed.authorIdentityMatcher
1152
+ });
1122
1153
  }
1123
1154
  async function handleChallengeRequest(community, request, isLocalPublisher) {
1124
1155
  const log = logger_default("pkc-js:local-community:handleChallengeRequest");
@@ -1262,14 +1293,11 @@ async function handleChallengeExchange(community, pubsubMsg) {
1262
1293
  function isFlairInAllowedList(flair, allowedFlairs) {
1263
1294
  return allowedFlairs.some((allowed) => t$11(allowed, flair));
1264
1295
  }
1265
- async function isPublicationAuthorPartOfRoles(community, publication, rolesToCheckAgainst) {
1266
- if (!community.roles) return false;
1296
+ async function matchPublicationAuthorAgainstRoles({ community, rolesToCheckAgainst, authorIdentityMatcher }) {
1297
+ if (!community.roles) return { matched: false };
1267
1298
  const roleKeys = Object.keys(community.roles).filter((roleKey) => rolesToCheckAgainst.includes(community.roles[roleKey].role));
1268
- if (roleKeys.length === 0) return false;
1269
- return createAuthorIdentityMatcher({
1270
- community,
1271
- publication
1272
- }).matchesAnyIdentity(roleKeys);
1299
+ if (roleKeys.length === 0) return { matched: false };
1300
+ return authorIdentityMatcher.matchesAnyIdentity(roleKeys);
1273
1301
  }
1274
1302
  async function respondWithErrorIfSignatureOfPublicationIsInvalid(community, request) {
1275
1303
  let validity;
@@ -1336,12 +1364,12 @@ async function checkAuthorIdentity(community, publication, log) {
1336
1364
  cache: { maxAge: 1800 }
1337
1365
  }));
1338
1366
  } catch (e) {
1339
- log("Rejecting publication with unresolvable author domain", authorName, e);
1340
- return messages.ERR_FAILED_TO_RESOLVE_AUTHOR_DOMAIN;
1367
+ log("Rejecting publication with unresolvable author name", authorName, e instanceof PKCError ? e.code : void 0, e);
1368
+ return authorNameResolveFailureReason({ error: e });
1341
1369
  }
1342
1370
  if (resolvedAddress === null) {
1343
- log("Rejecting publication: author domain could not be resolved", authorName);
1344
- return messages.ERR_FAILED_TO_RESOLVE_AUTHOR_DOMAIN;
1371
+ log("Rejecting publication: author name has no record", authorName);
1372
+ return authorNameResolveFailureReason({ error: null });
1345
1373
  }
1346
1374
  const signerAddress = await getPKCAddressFromPublicKey(publication.signature.publicKey);
1347
1375
  if (resolvedAddress !== signerAddress) {
@@ -1350,7 +1378,7 @@ async function checkAuthorIdentity(community, publication, log) {
1350
1378
  }
1351
1379
  }
1352
1380
  }
1353
- async function checkParentAndPostState(community, request, publication) {
1381
+ async function checkParentAndPostState(community, request, publication, authorIdentityMatcher) {
1354
1382
  if ("commentCid" in publication || "parentCid" in publication) {
1355
1383
  const parentCid = publication.parentCid || publication.commentCid;
1356
1384
  if (typeof parentCid !== "string") return messages.ERR_COMMUNITY_PUBLICATION_PARENT_CID_NOT_DEFINED;
@@ -1362,11 +1390,19 @@ async function checkParentAndPostState(community, request, publication) {
1362
1390
  if (postFlags.removed && !request.commentModeration) return messages.ERR_COMMUNITY_PUBLICATION_POST_HAS_BEEN_REMOVED;
1363
1391
  if (community._dbHandler.queryAuthorEditDeleted(parent.postCid)?.deleted && !request.commentModeration) return messages.ERR_COMMUNITY_PUBLICATION_POST_HAS_BEEN_DELETED;
1364
1392
  if (postFlags.locked && !request.commentModeration) {
1365
- if (!(!request.vote && await isPublicationAuthorPartOfRoles(community, publication, [
1366
- "owner",
1367
- "admin",
1368
- "moderator"
1369
- ]))) return messages.ERR_COMMUNITY_PUBLICATION_POST_IS_LOCKED;
1393
+ const lockBypass = request.vote ? { matched: false } : await matchPublicationAuthorAgainstRoles({
1394
+ community,
1395
+ rolesToCheckAgainst: [
1396
+ "owner",
1397
+ "admin",
1398
+ "moderator"
1399
+ ],
1400
+ authorIdentityMatcher
1401
+ });
1402
+ if (!lockBypass.matched) {
1403
+ if (lockBypass.nameFailure) return lockBypass.nameFailure.reason;
1404
+ return messages.ERR_COMMUNITY_PUBLICATION_POST_IS_LOCKED;
1405
+ }
1370
1406
  }
1371
1407
  if (postFlags.archived && !request.commentModeration) return messages.ERR_COMMUNITY_PUBLICATION_POST_IS_ARCHIVED;
1372
1408
  if (parent.timestamp > publication.timestamp) return messages.ERR_COMMUNITY_COMMENT_TIMESTAMP_IS_EARLIER_THAN_PARENT;
@@ -1451,16 +1487,24 @@ async function checkVotePublication(community, request) {
1451
1487
  const voteAuthorSignerAddress = await getPKCAddressFromPublicKey(votePublication.signature.publicKey);
1452
1488
  if (!community._dbHandler.queryVote(commentToVoteOn.cid, voteAuthorSignerAddress) && votePublication.vote === 0) return messages.ERR_THERE_IS_NO_PREVIOUS_VOTE_TO_CANCEL;
1453
1489
  }
1454
- async function checkCommentModerationPublication(community, request) {
1490
+ async function checkCommentModerationPublication(community, request, authorIdentityMatcher) {
1455
1491
  if (!request.commentModeration) return void 0;
1456
1492
  const commentModerationPublication = request.commentModeration;
1457
1493
  if (r$2(CommentModerationReservedFields, t$6(commentModerationPublication)).length > 0) return messages.ERR_COMMENT_MODERATION_HAS_RESERVED_FIELD;
1458
- const isAuthorMod = await isPublicationAuthorPartOfRoles(community, commentModerationPublication, [
1459
- "owner",
1460
- "moderator",
1461
- "admin"
1462
- ]);
1463
- if (!isAuthorMod) return messages.ERR_COMMENT_MODERATION_ATTEMPTED_WITHOUT_BEING_MODERATOR;
1494
+ const modMatch = await matchPublicationAuthorAgainstRoles({
1495
+ community,
1496
+ rolesToCheckAgainst: [
1497
+ "owner",
1498
+ "moderator",
1499
+ "admin"
1500
+ ],
1501
+ authorIdentityMatcher
1502
+ });
1503
+ const isAuthorMod = modMatch.matched;
1504
+ if (!isAuthorMod) {
1505
+ if (modMatch.nameFailure) return modMatch.nameFailure.reason;
1506
+ return messages.ERR_COMMENT_MODERATION_ATTEMPTED_WITHOUT_BEING_MODERATOR;
1507
+ }
1464
1508
  const commentToBeEdited = community._dbHandler.queryComment(commentModerationPublication.commentCid);
1465
1509
  if (!commentToBeEdited) return messages.ERR_COMMENT_MODERATION_NO_COMMENT_TO_EDIT;
1466
1510
  if (isAuthorMod && commentModerationPublication.commentModeration.locked && commentToBeEdited.depth !== 0) return messages.ERR_COMMUNITY_COMMENT_MOD_CAN_NOT_LOCK_REPLY;
@@ -1469,14 +1513,30 @@ async function checkCommentModerationPublication(community, request) {
1469
1513
  if (community._dbHandler.hasCommentModerationWithSignatureEncoded(commentModerationPublication.signature.signature)) return messages.ERR_DUPLICATE_COMMENT_MODERATION;
1470
1514
  if ("approved" in commentModerationPublication.commentModeration && !commentToBeEdited.pendingApproval) return messages.ERR_MOD_ATTEMPTING_TO_APPROVE_OR_DISAPPROVE_COMMENT_THAT_IS_NOT_PENDING;
1471
1515
  }
1472
- async function checkCommunityEditPublication(community, request) {
1516
+ async function checkCommunityEditPublication(community, request, authorIdentityMatcher) {
1473
1517
  if (!request.communityEdit) return void 0;
1474
1518
  const communityEdit = request.communityEdit;
1475
1519
  if (r$2(CommunityEditPublicationPubsubReservedFields, t$6(communityEdit)).length > 0) return messages.ERR_COMMUNITY_EDIT_HAS_RESERVED_FIELD;
1476
1520
  if (communityEdit.communityEdit.roles || communityEdit.communityEdit.address || communityEdit.communityEdit.name) {
1477
- if (!await isPublicationAuthorPartOfRoles(community, communityEdit, ["owner"])) return messages.ERR_COMMUNITY_EDIT_ATTEMPTED_TO_MODIFY_OWNER_EXCLUSIVE_PROPS;
1521
+ const ownerMatch = await matchPublicationAuthorAgainstRoles({
1522
+ community,
1523
+ rolesToCheckAgainst: ["owner"],
1524
+ authorIdentityMatcher
1525
+ });
1526
+ if (!ownerMatch.matched) {
1527
+ if (ownerMatch.nameFailure) return ownerMatch.nameFailure.reason;
1528
+ return messages.ERR_COMMUNITY_EDIT_ATTEMPTED_TO_MODIFY_OWNER_EXCLUSIVE_PROPS;
1529
+ }
1530
+ }
1531
+ const ownerOrAdminMatch = await matchPublicationAuthorAgainstRoles({
1532
+ community,
1533
+ rolesToCheckAgainst: ["owner", "admin"],
1534
+ authorIdentityMatcher
1535
+ });
1536
+ if (!ownerOrAdminMatch.matched) {
1537
+ if (ownerOrAdminMatch.nameFailure) return ownerOrAdminMatch.nameFailure.reason;
1538
+ return messages.ERR_COMMUNITY_EDIT_ATTEMPTED_TO_MODIFY_COMMUNITY_WITHOUT_BEING_OWNER_OR_ADMIN;
1478
1539
  }
1479
- if (!await isPublicationAuthorPartOfRoles(community, communityEdit, ["owner", "admin"])) return messages.ERR_COMMUNITY_EDIT_ATTEMPTED_TO_MODIFY_COMMUNITY_WITHOUT_BEING_OWNER_OR_ADMIN;
1480
1540
  const allowedCommunityEditKeys = [...t$6(CommunityIpfsSchema.shape), "address"];
1481
1541
  if (r$1(t$6(communityEdit.communityEdit), allowedCommunityEditKeys).length > 0) return messages.ERR_COMMUNITY_EDIT_ATTEMPTED_TO_NON_PUBLIC_PROPS;
1482
1542
  }
@@ -1502,22 +1562,26 @@ async function checkCommentEditPublication(community, request) {
1502
1562
  for (const flair of commentEditPublication.flairs) if (!isFlairInAllowedList(flair, allowedPostFlairs)) return messages.ERR_POST_FLAIR_NOT_IN_ALLOWED_FLAIRS;
1503
1563
  }
1504
1564
  }
1505
- async function checkPublicationValidity(community, request, publication, authorCommunity) {
1565
+ async function checkPublicationValidity({ community, request, publication, authorCommunity, authorIdentityMatcher: sharedAuthorIdentityMatcher }) {
1566
+ const authorIdentityMatcher = sharedAuthorIdentityMatcher ?? authorIdentityMatcherForRequest({
1567
+ community,
1568
+ request
1569
+ });
1506
1570
  const log = logger_default("pkc-js:local-community:handleChallengeRequest:checkPublicationValidity");
1507
1571
  const wireResult = await checkWireFormatAndCommunityAuthor(community, publication, authorCommunity);
1508
1572
  if (wireResult) return wireResult;
1509
1573
  const authorResult = await checkAuthorIdentity(community, publication, log);
1510
1574
  if (authorResult) return authorResult;
1511
- const parentResult = await checkParentAndPostState(community, request, publication);
1575
+ const parentResult = await checkParentAndPostState(community, request, publication, authorIdentityMatcher);
1512
1576
  if (parentResult) return parentResult;
1513
1577
  if (Buffer.byteLength(JSON.stringify(publication)) / 1e3 > 40) return messages.ERR_REQUEST_PUBLICATION_OVER_ALLOWED_SIZE;
1514
1578
  const commentResult = await checkCommentPublication(community, request);
1515
1579
  if (commentResult) return commentResult;
1516
1580
  const voteResult = await checkVotePublication(community, request);
1517
1581
  if (voteResult) return voteResult;
1518
- const modResult = await checkCommentModerationPublication(community, request);
1582
+ const modResult = await checkCommentModerationPublication(community, request, authorIdentityMatcher);
1519
1583
  if (modResult) return modResult;
1520
- const communityEditResult = await checkCommunityEditPublication(community, request);
1584
+ const communityEditResult = await checkCommunityEditPublication(community, request, authorIdentityMatcher);
1521
1585
  if (communityEditResult) return communityEditResult;
1522
1586
  const commentEditResult = await checkCommentEditPublication(community, request);
1523
1587
  if (commentEditResult) return commentEditResult;
@@ -1571,14 +1635,26 @@ async function resolveAliasPrivateKeyForCommentPublication(community, opts) {
1571
1635
  return (await community._pkc.createSigner()).privateKey;
1572
1636
  } else throw Error(`Unsupported pseudonymityMode (${opts.mode})`);
1573
1637
  }
1574
- async function prepareCommentWithAnonymity(community, originalComment) {
1638
+ async function prepareCommentWithAnonymity({ community, originalComment, authorIdentityMatcher = createAuthorIdentityMatcher({
1639
+ community,
1640
+ publication: originalComment
1641
+ }) }) {
1575
1642
  const mode = community.features?.pseudonymityMode;
1576
1643
  if (!mode) return { publication: originalComment };
1577
- if (await isPublicationAuthorPartOfRoles(community, originalComment, [
1578
- "owner",
1579
- "admin",
1580
- "moderator"
1581
- ])) return { publication: originalComment };
1644
+ const modMatch = await matchPublicationAuthorAgainstRoles({
1645
+ community,
1646
+ rolesToCheckAgainst: [
1647
+ "owner",
1648
+ "admin",
1649
+ "moderator"
1650
+ ],
1651
+ authorIdentityMatcher
1652
+ });
1653
+ if (modMatch.matched) return { publication: originalComment };
1654
+ if (modMatch.nameFailure) throw new PKCError(getErrorCodeFromMessage(modMatch.nameFailure.reason), {
1655
+ comment: originalComment,
1656
+ nameFailureError: modMatch.nameFailure.error
1657
+ });
1582
1658
  const originalAuthorPublicKey = originalComment.signature.publicKey;
1583
1659
  const postCid = originalComment.postCid;
1584
1660
  const aliasPrivateKey = await resolveAliasPrivateKeyForCommentPublication(community, {
@@ -1831,13 +1907,20 @@ async function storeComment(community, opts) {
1831
1907
  cid: commentCid
1832
1908
  };
1833
1909
  }
1834
- async function storePublication(community, request, pendingApproval, challengeAggregate) {
1910
+ async function storePublication({ community, request, pendingApproval, challengeAggregate, authorIdentityMatcher }) {
1835
1911
  if (request.vote) return storeVote(community, request.vote, request.challengeRequestId);
1836
1912
  else if (request.commentEdit) return storeCommentEdit(community, await prepareCommentEditWithAlias(community, request.commentEdit), request.challengeRequestId);
1837
1913
  else if (request.commentModeration) return storeCommentModeration(community, request.commentModeration, request.challengeRequestId);
1838
1914
  else if (request.comment) {
1839
1915
  const originalCommentSignatureEncoded = request.comment.signature.signature;
1840
- const { publication, anonymity } = await prepareCommentWithAnonymity(community, request.comment);
1916
+ const { publication, anonymity } = await prepareCommentWithAnonymity({
1917
+ community,
1918
+ originalComment: request.comment,
1919
+ authorIdentityMatcher: authorIdentityMatcher ?? authorIdentityMatcherForRequest({
1920
+ community,
1921
+ request
1922
+ })
1923
+ });
1841
1924
  const storedComment = await storeComment(community, {
1842
1925
  commentPubsub: publication,
1843
1926
  pendingApproval,
@@ -7231,16 +7314,21 @@ async function parseRolesToEdit(community, newRawRoles) {
7231
7314
  if (roleValue === void 0 || roleValue === null) continue;
7232
7315
  if (isStringDomain(roleAddress)) {
7233
7316
  let resolved;
7317
+ let resolveError;
7234
7318
  try {
7235
7319
  ({resolvedAuthorName: resolved} = await community._clientsManager.resolveAuthorNameIfNeeded({
7236
7320
  authorName: roleAddress,
7237
7321
  abortSignal: AbortSignal.timeout(community._pkc._timeouts["resolve-author-name"]),
7238
7322
  cache: { maxAge: 0 }
7239
7323
  }));
7240
- } catch {
7324
+ } catch (e) {
7241
7325
  resolved = null;
7326
+ resolveError = e;
7242
7327
  }
7243
- if (!resolved) throw new PKCError("ERR_ROLE_ADDRESS_NAME_COULD_NOT_BE_RESOLVED", { roleAddress });
7328
+ if (!resolved) throw new PKCError("ERR_ROLE_ADDRESS_NAME_COULD_NOT_BE_RESOLVED", {
7329
+ roleAddress,
7330
+ resolveError
7331
+ });
7244
7332
  }
7245
7333
  }
7246
7334
  return t$8(newRawRoles, (val, key) => val === void 0 || val === null);
@@ -7853,7 +7941,11 @@ var LocalCommunity = class extends RpcLocalCommunity {
7853
7941
  return repinCommentsIPFSIfNeeded(this);
7854
7942
  }
7855
7943
  async storePublication(request, pendingApproval) {
7856
- return storePublication(this, request, pendingApproval);
7944
+ return storePublication({
7945
+ community: this,
7946
+ request,
7947
+ pendingApproval
7948
+ });
7857
7949
  }
7858
7950
  async updateCommunityIpnsIfNeeded(args) {
7859
7951
  return updateCommunityIpnsIfNeeded(this, args.commentUpdateRowsToPublishToIpfs);
@@ -7883,13 +7975,20 @@ var LocalCommunity = class extends RpcLocalCommunity {
7883
7975
  return purgeDisapprovedCommentsOlderThan(this);
7884
7976
  }
7885
7977
  async _publishChallengeVerification(challengeResult, request) {
7886
- return publishChallengeVerification(this, challengeResult, request);
7978
+ return publishChallengeVerification({
7979
+ community: this,
7980
+ challengeResult,
7981
+ request
7982
+ });
7887
7983
  }
7888
7984
  async _publishIdempotentDuplicateVerification(...args) {
7889
7985
  return publishIdempotentDuplicateVerification(this, ...args);
7890
7986
  }
7891
- async _checkPublicationValidity(...args) {
7892
- return checkPublicationValidity(this, ...args);
7987
+ async _checkPublicationValidity(args) {
7988
+ return checkPublicationValidity({
7989
+ ...args,
7990
+ community: this
7991
+ });
7893
7992
  }
7894
7993
  _calculateLocalMfsPathForCommentUpdate(...args) {
7895
7994
  return calculateLocalMfsPathForCommentUpdate(this, ...args);
@@ -1,7 +1,7 @@
1
1
  import { i as __toESM, r as __require, t as __commonJSMin } from "./chunk-2rV9d50f.js";
2
- import { A as doesDomainAddressHaveCapitalLetter, At as refreshTrackedCommentAliases, B as ipnsNameToIpnsOverPubsubTopic, Br as stringifyPrimitive, Bt as TimeoutError, Cn as CommentIpfsSchema, Cr as messages, D as createAbortError, Dr as setErrorMap, Dt as listStartedCommunities, Et as findUpdatingCommunity, H as isIpfsCid, Lt as untrackUpdatingComment, O as deepMergeRuntimeFields, On as CommentUpdateForChallengeVerificationSchema, Ot as listUpdatingComments, Pt as trackUpdatingComment, R as hideClassPrivateProps, Rr as joinValues, Sr as PKCError, Tt as findUpdatingComment, V as isAbortError, Vt as pTimeout, W as isIpns, _r as FailedToFetchCommentIpfsFromGatewaysError, _t as sleepUntilTimeoutOrAbort, a as ChallengeRequestMessageSchema, ar as t$1, b as areEquivalentCommunityAddresses, bt as timestamp, dt as resolveWhenPredicateIsTrue, fn as PubsubTopicSchema, gr as require_retry, gt as shortifyCid, ht as shortifyAddress, it as rejectWhenCommunityStopsOrAborts, jn as CommentUpdateSchema, kt as listUpdatingCommunities, lr as r, lt as removeUndefinedValuesRecursively, mn as isStringDomain, on as CommunityIpfsSchema, or as e, pt as retryKuboIpfsAdd, r as ChallengeMessageSchema, rr as n$1, rt as rejectWhenAbortSignalFires, s as ChallengeVerificationMessageSchema, sr as e$1, t as ChallengeAnswerMessageSchema, tn as CommunityAnchorSchema, tr as n$2, ut as replaceXWithY, wr as logger_default, wt as findStartedCommunity, xt as waitForUpdateInCommunityInstanceWithErrorAndTimeout, y as version_default, yt as throwIfAbortSignalAborted, zr as parsedType, zt as require_sha256 } from "./schema-MeRr3oiN.js";
3
- import { $ as parseRawPages, $n as RpcSuccessResultSchema, $t as getPKCAddressFromPublicKeySync, An as parseRpcCommentUpdateEventWithPKCErrorIfItFails, At as verifyCommentEdit, Bn as RpcCommunityPageParamSchema, Bt as getAuthorNameFromRuntime, Cn as parseCreateVoteOptionsSchemaWithPKCErrorIfItFails, Dn as parseJsonWithPKCErrorIfFails, Dt as verifyChallengeMessage, En as parseDecryptedChallengeWithPKCErrorIfItFails, Fn as RpcAuthorNameParamSchema, Gn as RpcExportCommunityResultSchema, Gt as getCommunityNameFromWire, H as tryToDeleteCommunitiesThatFailedToBeDeletedBefore, Hn as RpcExportCommunityModLogsParamSchema, Ht as normalizeCreatePublicationAuthor, In as RpcCancelExportParamSchema, It as verifyCommunityEdit, Jn as RpcPublishAnchorRecordParamSchema, Jt as decode, Kn as RpcFetchCidParamSchema, Kt as getCommunityPublicKeyFromWire, L as listCommunitiesSync, Ln as RpcCidParamSchema, Lt as verifyVote, Mt as verifyCommentModeration, Nn as parseVotePubsubMessagePublicationSchemaWithPKCErrorIfItFails, Nt as verifyCommentPubsubMessage, O as createKuboRpcClient, On as parsePKCUserOptionsSchemaWithPKCErrorIfItFails, P as getDefaultDataPath, Pn as RpcAnchorPublishPreparationResultSchema, Pt as verifyCommentUpdate, Qn as RpcSubscriptionIdResultSchema, R as monitorCommunitiesDirectory, Rn as RpcCommentRepliesPageParamSchema, Rt as buildRuntimeAuthor, S as encryptEd25519AesGcm, Sn as parseCreateRpcCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, Tn as parseDecryptedChallengeVerification, Tt as signVote, U as CommentClientsManager, Un as RpcExportCommunityModLogsResultSchema, Ut as buildRuntimeCommunityFields, V as setNativeFunctions$1, Vn as RpcEditCommunityParamSchema, Wn as RpcExportCommunityParamSchema, Wt as getCommunityAddressFromRecord, X as extractCommunityRuntimeFieldsFromParsedPages, Xn as RpcPublishedAnchorRecordResultSchema, Xt as getBufferedPKCAddressFromPublicKey, Yn as RpcPublishChallengeAnswersParamSchema, Z as findCommentInPageInstanceRecursively, Zn as RpcResolveAuthorNameResultSchema, _n as parseCreateCommentOptionsSchemaWithPKCErrorIfItFails, an as parseCommentEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, at as stripNameResolvedFromCrosspost, b as decryptEd25519AesGcm, bt as signCommentModeration, c as TrackedInstanceRegistry, cn as parseCommentModerationPubsubMessagePublicationSchemaWithPKCErrorIfItFails, ct as InflightFetchManager, dt as PKCTypedEmitter, er as RpcUnsubscribeParamSchema, et as RepliesPages, f as KeyvBetterSqlite3, ft as require_lib$1, g as decodeRpcChallengeVerificationPubsubMsg, gn as parseCreateCommentModerationOptionsSchemaWithPKCErrorIfItFails, gt as signChallengeRequest, h as decodeRpcChallengeRequestPubsubMsg, hn as parseCreateCommentEditOptionsSchemaWithPKCErrorIfItFails, hr as require_undici, jn as parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, jt as verifyCommentIpfs, kn as parseRpcCommentEventWithPKCErrorIfItFails, kt as verifyChallengeVerification, l as LRUCache, ln as parseCommentPubsubMessagePublicationWithPKCErrorIfItFails, lr as t$2, m as decodeRpcChallengePubsubMsg, mr as nativeFunctions$2, mt as signChallengeAnswer, n as RpcRemoteCommunity, nn as parseCidStringSchemaWithPKCErrorIfItFails, nt as cloneCrosspostForRuntime, o as pkcJsChallenges, on as parseCommentIpfsSchemaWithPKCErrorIfItFails, or as t$3, ot as PublicationClientsManager, p as decodeRpcChallengeAnswerPubsubMsg, pn as parseCommunityEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, pt as cleanUpBeforePublishing, qn as RpcFetchCidResultSchema, qt as normalizeCommunityInputFromCommunity, rr as t$4, rt as collectCrosspostAuthorsToResolve, sr as n$3, st as PKCClientsManager, t as RpcLocalCommunity, tt as applyNameResolvedCacheToCrosspost, u as RemoteCommunity, un as parseCommunityAddressWithPKCErrorIfItFails, ur as t$5, v as createSigner, vn as parseCreateCommunityEditPublicationOptionsSchemaWithPKCErrorIfItFails, vt as signComment, wn as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, wt as signCommunityEdit, xn as parseCreateRemoteCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, y as createAnchorIpnsRecord$1, yt as signCommentEdit, zn as RpcCommunityIdentifierParamSchema, zt as cleanWireAuthor } from "./rpc-local-community-C3o1AzHp.js";
4
- import { o as getHeliaDebugContext } from "./util-CjRKlVEE.js";
2
+ import { A as doesDomainAddressHaveCapitalLetter, At as listUpdatingCommunities, Br as parsedType, Bt as require_sha256, Cr as PKCError, D as createAbortError, Dt as findUpdatingCommunity, Et as findUpdatingComment, Ft as trackUpdatingComment, G as isIpns, H as isAbortError, Ht as pTimeout, Mn as CommentUpdateSchema, O as deepMergeRuntimeFields, Or as setErrorMap, Ot as listStartedCommunities, Rt as untrackUpdatingComment, St as waitForUpdateInCommunityInstanceWithErrorAndTimeout, Tr as logger_default, Tt as findStartedCommunity, U as isIpfsCid, V as ipnsNameToIpnsOverPubsubTopic, Vr as stringifyPrimitive, Vt as TimeoutError, _r as require_retry, _t as shortifyCid, a as ChallengeRequestMessageSchema, at as rejectWhenCommunityStopsOrAborts, b as areEquivalentCommunityAddresses, bt as throwIfAbortSignalAborted, cr as e$1, dt as replaceXWithY, ft as resolveWhenPredicateIsTrue, gt as shortifyAddress, hn as isStringDomain, ir as n$1, it as rejectWhenAbortSignalFires, jt as refreshTrackedCommentAliases, kn as CommentUpdateForChallengeVerificationSchema, kt as listUpdatingComments, mt as retryKuboIpfsAdd, nn as CommunityAnchorSchema, nr as n$2, or as t$1, pn as PubsubTopicSchema, r as ChallengeMessageSchema, s as ChallengeVerificationMessageSchema, sn as CommunityIpfsSchema, sr as e, t as ChallengeAnswerMessageSchema, ur as r, ut as removeUndefinedValuesRecursively, vr as FailedToFetchCommentIpfsFromGatewaysError, vt as sleepUntilTimeoutOrAbort, wn as CommentIpfsSchema, wr as messages, xt as timestamp, y as version_default, z as hideClassPrivateProps, zr as joinValues } from "./schema-bdQ9ufF9.js";
3
+ import { $ as findCommentInPageInstanceRecursively, $n as RpcResolveAuthorNameResultSchema, A as createKuboRpcClient, An as parsePKCUserOptionsSchemaWithPKCErrorIfItFails, B as monitorCommunitiesDirectory, Bn as RpcCommentRepliesPageParamSchema, Bt as buildRuntimeAuthor, Cn as parseCreateRemoteCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, Dn as parseDecryptedChallengeVerification, Dt as signVote, En as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, Et as signCommunityEdit, Fn as parseVotePubsubMessagePublicationSchemaWithPKCErrorIfItFails, Ft as verifyCommentPubsubMessage, G as CommentClientsManager, Gn as RpcExportCommunityModLogsResultSchema, Gt as buildRuntimeCommunityFields, Hn as RpcCommunityPageParamSchema, Ht as getAuthorNameFromRuntime, I as getDefaultDataPath, In as RpcAnchorPublishPreparationResultSchema, It as verifyCommentUpdate, Jn as RpcFetchCidParamSchema, Jt as getCommunityPublicKeyFromWire, Kn as RpcExportCommunityParamSchema, Kt as getCommunityAddressFromRecord, Ln as RpcAuthorNameParamSchema, Mn as parseRpcCommentUpdateEventWithPKCErrorIfItFails, Mt as verifyCommentEdit, Nn as parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, Nt as verifyCommentIpfs, On as parseDecryptedChallengeWithPKCErrorIfItFails, Pt as verifyCommentModeration, Q as extractCommunityRuntimeFieldsFromParsedPages, Qn as RpcPublishedAnchorRecordResultSchema, Qt as getBufferedPKCAddressFromPublicKey, Rn as RpcCancelExportParamSchema, Rt as verifyCommunityEdit, S as decryptEd25519AesGcm, St as signCommentModeration, Tn as parseCreateVoteOptionsSchemaWithPKCErrorIfItFails, U as setNativeFunctions$1, Un as RpcEditCommunityParamSchema, Vn as RpcCommunityIdentifierParamSchema, Vt as cleanWireAuthor, W as tryToDeleteCommunitiesThatFailedToBeDeletedBefore, Wn as RpcExportCommunityModLogsParamSchema, Wt as normalizeCreatePublicationAuthor, Xn as RpcPublishAnchorRecordParamSchema, Xt as decode, Yn as RpcFetchCidResultSchema, Yt as normalizeCommunityInputFromCommunity, Zn as RpcPublishChallengeAnswersParamSchema, _ as decodeRpcChallengeRequestPubsubMsg, _n as parseCreateCommentEditOptionsSchemaWithPKCErrorIfItFails, ar as t$4, at as collectCrosspostAuthorsToResolve, b as createSigner, bn as parseCreateCommunityEditPublicationOptionsSchemaWithPKCErrorIfItFails, br as require_undici, bt as signComment, cn as parseCommentIpfsSchemaWithPKCErrorIfItFails, cr as t$3, ct as PublicationClientsManager, d as LRUCache, dn as parseCommentPubsubMessagePublicationWithPKCErrorIfItFails, dr as t$2, er as RpcSubscriptionIdResultSchema, f as RemoteCommunity, fn as parseCommunityAddressWithPKCErrorIfItFails, fr as t$5, g as decodeRpcChallengePubsubMsg, gr as NAME_RESOLVE_FAILED_RETRY_FLOOR_MS, gt as signChallengeAnswer, h as decodeRpcChallengeAnswerPubsubMsg, hn as parseCommunityEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, hr as NAME_RESOLVED_TRUE_TTL_MS, ht as cleanUpBeforePublishing, in as parseCidStringSchemaWithPKCErrorIfItFails, it as cloneCrosspostForRuntime, jn as parseRpcCommentEventWithPKCErrorIfItFails, jt as verifyChallengeVerification, kn as parseJsonWithPKCErrorIfFails, kt as verifyChallengeMessage, lr as n$3, lt as PKCClientsManager, m as KeyvBetterSqlite3, mr as NAME_RESOLVED_FALSE_TTL_MS, mt as require_lib$1, n as RpcRemoteCommunity, nr as RpcUnsubscribeParamSchema, nt as RepliesPages, o as pkcJsChallenges, pt as PKCTypedEmitter, qn as RpcExportCommunityResultSchema, qt as getCommunityNameFromWire, rt as applyNameResolvedCacheToCrosspost, sn as parseCommentEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, st as stripNameResolvedFromCrosspost, t as RpcLocalCommunity, tn as getPKCAddressFromPublicKeySync, tr as RpcSuccessResultSchema, tt as parseRawPages, u as TrackedInstanceRegistry, un as parseCommentModerationPubsubMessagePublicationSchemaWithPKCErrorIfItFails, ut as InflightFetchManager, v as decodeRpcChallengeVerificationPubsubMsg, vn as parseCreateCommentModerationOptionsSchemaWithPKCErrorIfItFails, vt as signChallengeRequest, w as encryptEd25519AesGcm, wn as parseCreateRpcCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, x as createAnchorIpnsRecord$1, xt as signCommentEdit, yn as parseCreateCommentOptionsSchemaWithPKCErrorIfItFails, yr as nativeFunctions$2, z as listCommunitiesSync, zn as RpcCidParamSchema, zt as verifyVote } from "./rpc-local-community-CP0JZU-Q.js";
4
+ import { o as getHeliaDebugContext } from "./util-CEpMupHn.js";
5
5
  import path from "path";
6
6
  import assert from "assert";
7
7
  import fs from "fs";
@@ -1249,7 +1249,7 @@ var Comment = class extends Publication {
1249
1249
  _resolveAuthorNamesInBackground() {
1250
1250
  if (!this._pkc.resolveAuthorNames) return;
1251
1251
  const domain = getAuthorNameFromRuntime(this.author);
1252
- const ownAuthor = domain && typeof this.author.nameResolved !== "boolean" ? [{
1252
+ const ownAuthor = domain ? [{
1253
1253
  authorName: domain,
1254
1254
  signaturePublicKey: this.signature.publicKey
1255
1255
  }] : [];
@@ -1258,7 +1258,7 @@ var Comment = class extends Publication {
1258
1258
  if (!page) continue;
1259
1259
  for (const comment of page.comments) {
1260
1260
  const commentDomain = getAuthorNameFromRuntime(comment.author);
1261
- if (commentDomain && typeof comment.author.nameResolved !== "boolean") replyAuthors.push({
1261
+ if (commentDomain) replyAuthors.push({
1262
1262
  authorName: commentDomain,
1263
1263
  signaturePublicKey: comment.signature.publicKey
1264
1264
  });
@@ -6937,6 +6937,10 @@ var PKC$1 = class extends PKCTypedEmitter {
6937
6937
  this._publishingPublications = /* @__PURE__ */ new Set();
6938
6938
  this.destroyed = false;
6939
6939
  this._storageLRUs = {};
6940
+ this._nameResolvedFalseTtlMs = NAME_RESOLVED_FALSE_TTL_MS;
6941
+ this._nameResolvedTrueTtlMs = NAME_RESOLVED_TRUE_TTL_MS;
6942
+ this._nameResolveFailedRetryFloorMs = NAME_RESOLVE_FAILED_RETRY_FLOOR_MS;
6943
+ this._authorNameResolvesInFlight = /* @__PURE__ */ new Set();
6940
6944
  this._timeouts = {
6941
6945
  "community-ipns": 300 * 1e3,
6942
6946
  "community-ipfs": 60 * 1e3,
@@ -7016,7 +7020,14 @@ var PKC$1 = class extends PKCTypedEmitter {
7016
7020
  }),
7017
7021
  pageCidToSortTypes: new LRUCache({ max: 5e3 }),
7018
7022
  pagesMaxSize: new LRUCache({ max: 5e4 }),
7019
- nameResolvedCache: new LRUCache({ max: 5e3 })
7023
+ nameResolvedCache: new LRUCache({
7024
+ max: 5e3,
7025
+ ttl: NAME_RESOLVED_TRUE_TTL_MS
7026
+ }),
7027
+ nameResolveFailedCache: new LRUCache({
7028
+ max: 5e3,
7029
+ ttl: NAME_RESOLVE_FAILED_RETRY_FLOOR_MS
7030
+ })
7020
7031
  };
7021
7032
  }
7022
7033
  async _initKuboRpcClientsIfNeeded() {
@@ -7054,7 +7065,7 @@ var PKC$1 = class extends PKCTypedEmitter {
7054
7065
  this.clients.libp2pJsClients = {};
7055
7066
  if (!this.libp2pJsClientsOptions) return;
7056
7067
  if (!this.httpRoutersOptions) throw Error("httpRoutersOptions is required for libp2pJsClient");
7057
- const { createLibp2pJsClientOrUseExistingOne } = await import("./helia-for-pkc-BqRIFXGX.js");
7068
+ const { createLibp2pJsClientOrUseExistingOne } = await import("./helia-for-pkc-DanrSDp0.js");
7058
7069
  for (const clientOptions of this.libp2pJsClientsOptions) {
7059
7070
  const heliaNode = await createLibp2pJsClientOrUseExistingOne({
7060
7071
  ...clientOptions,
@@ -7333,7 +7344,7 @@ var PKC$1 = class extends PKCTypedEmitter {
7333
7344
  const log = logger_default("pkc-js:pkc:createLocalCommunity");
7334
7345
  log.trace("Received community options to create a local community instance:", options);
7335
7346
  if (!this._canCreateNewLocalCommunity()) throw new PKCError("ERR_CAN_NOT_CREATE_A_LOCAL_COMMUNITY", { pkcOptions: this._userPKCOptions });
7336
- const { LocalCommunity, createNewLocalCommunityDb, updateInstancePropsWithStartedCommunityOrDb } = await import("./local-community-mF7g4deD.js");
7347
+ const { LocalCommunity, createNewLocalCommunityDb, updateInstancePropsWithStartedCommunityOrDb } = await import("./local-community-Bsj3T9vI.js");
7337
7348
  const isLocalCommunity = (await listCommunitiesSync(this)).includes(options.address);
7338
7349
  const community = new LocalCommunity(this);
7339
7350
  if (isLocalCommunity) {