@pkcprotocol/pkc-js 0.0.99 → 0.0.101

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 (140) hide show
  1. package/README.md +1 -1
  2. package/dist/browser/clients/base-client-manager.js +16 -3
  3. package/dist/browser/clients/base-client-manager.js.map +1 -1
  4. package/dist/browser/clients/rpc-client/rpc-schema-util.d.ts +3 -2
  5. package/dist/browser/clients/rpc-client/schema.d.ts +3 -2
  6. package/dist/browser/community/community-client-manager.d.ts +5 -0
  7. package/dist/browser/community/community-client-manager.js +134 -23
  8. package/dist/browser/community/community-client-manager.js.map +1 -1
  9. package/dist/browser/community/schema.d.ts +110 -51
  10. package/dist/browser/community/schema.js +21 -5
  11. package/dist/browser/community/schema.js.map +1 -1
  12. package/dist/browser/domain-util.d.ts +3 -0
  13. package/dist/browser/domain-util.js +16 -0
  14. package/dist/browser/domain-util.js.map +1 -0
  15. package/dist/browser/errors.d.ts +5 -0
  16. package/dist/browser/errors.js +5 -0
  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/generated-version.js.map +1 -1
  21. package/dist/browser/helia/util.js +4 -3
  22. package/dist/browser/helia/util.js.map +1 -1
  23. package/dist/browser/index-with-compile-cache.d.ts +18 -12
  24. package/dist/browser/index.d.ts +18 -12
  25. package/dist/browser/pkc-error.d.ts +1 -1
  26. package/dist/browser/publications/community-edit/schema.d.ts +12 -8
  27. package/dist/browser/publications/publication.d.ts +1 -0
  28. package/dist/browser/publications/publication.js +56 -17
  29. package/dist/browser/publications/publication.js.map +1 -1
  30. package/dist/browser/pubsub-messages/schema.d.ts +6 -4
  31. package/dist/browser/rpc/src/lib/pkc-js/index.d.ts +9 -6
  32. package/dist/browser/rpc/src/schema.d.ts +54 -36
  33. package/dist/browser/runtime/node/community/challenges/exclude/exclude.d.ts +1 -1
  34. package/dist/browser/runtime/node/community/challenges/exclude/exclude.js +41 -16
  35. package/dist/browser/runtime/node/community/challenges/exclude/exclude.js.map +1 -1
  36. package/dist/browser/runtime/node/community/challenges/exclude/utils.d.ts +2 -3
  37. package/dist/browser/runtime/node/community/challenges/exclude/utils.js +1 -15
  38. package/dist/browser/runtime/node/community/challenges/exclude/utils.js.map +1 -1
  39. package/dist/browser/runtime/node/community/challenges/index.js +1 -1
  40. package/dist/browser/runtime/node/community/challenges/index.js.map +1 -1
  41. package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/blacklist.js +18 -13
  42. package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/blacklist.js.map +1 -1
  43. package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/whitelist.js +18 -13
  44. package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/whitelist.js.map +1 -1
  45. package/dist/browser/runtime/node/community/db-handler.d.ts +3 -2
  46. package/dist/browser/runtime/node/community/db-handler.js +20 -2
  47. package/dist/browser/runtime/node/community/db-handler.js.map +1 -1
  48. package/dist/browser/runtime/node/community/local-community/author-identity.d.ts +19 -0
  49. package/dist/browser/runtime/node/community/local-community/author-identity.js +50 -0
  50. package/dist/browser/runtime/node/community/local-community/author-identity.js.map +1 -0
  51. package/dist/browser/runtime/node/community/local-community/ipns-publishing.js +7 -1
  52. package/dist/browser/runtime/node/community/local-community/ipns-publishing.js.map +1 -1
  53. package/dist/browser/runtime/node/community/local-community/publication-validation.js +8 -22
  54. package/dist/browser/runtime/node/community/local-community/publication-validation.js.map +1 -1
  55. package/dist/browser/schema/schema-util.d.ts +27 -18
  56. package/dist/browser/schema.d.ts +72 -48
  57. package/dist/browser/test/mock-ipfs-client.js +6 -0
  58. package/dist/browser/test/mock-ipfs-client.js.map +1 -1
  59. package/dist/browser/test/test-util.d.ts +13 -10
  60. package/dist/browser/test/test-util.js +2 -2
  61. package/dist/browser/test/test-util.js.map +1 -1
  62. package/dist/browser/util.d.ts +1 -4
  63. package/dist/browser/util.js +4 -10
  64. package/dist/browser/util.js.map +1 -1
  65. package/dist/browser/version.js +1 -1
  66. package/dist/bundled/bundle-manifest.json +33 -31
  67. package/dist/bundled/chunks/{helia-for-pkc-DUaUFShG.js → helia-for-pkc-DSF3IY_M.js} +33 -33
  68. package/dist/bundled/chunks/{local-community-CM2GS9Ya.js → local-community-CTd_1kw_.js} +1 -1
  69. package/dist/bundled/chunks/{local-community-BGcQIioy.js → local-community-DtlDCcc2.js} +54 -49
  70. package/dist/bundled/chunks/{node-CF18iVMW.js → node-pGNrsJuH.js} +47 -25
  71. package/dist/bundled/chunks/{rpc-local-community-CTyhIJyD.js → rpc-local-community-pLvHO4g9.js} +160 -54
  72. package/dist/bundled/chunks/{schema-f2Zr1ZxK.js → schema-DdD_6tTd.js} +30 -19
  73. package/dist/bundled/chunks/{util-BbXV7Dcu.js → util-N0_wIz2O.js} +2 -2
  74. package/dist/bundled/index.js +1 -1
  75. package/dist/bundled/rpc/src/index.js +4 -4
  76. package/dist/node/clients/base-client-manager.js +16 -3
  77. package/dist/node/clients/base-client-manager.js.map +1 -1
  78. package/dist/node/clients/rpc-client/rpc-schema-util.d.ts +3 -2
  79. package/dist/node/clients/rpc-client/schema.d.ts +3 -2
  80. package/dist/node/community/community-client-manager.d.ts +5 -0
  81. package/dist/node/community/community-client-manager.js +134 -23
  82. package/dist/node/community/community-client-manager.js.map +1 -1
  83. package/dist/node/community/schema.d.ts +110 -51
  84. package/dist/node/community/schema.js +21 -5
  85. package/dist/node/community/schema.js.map +1 -1
  86. package/dist/node/domain-util.d.ts +3 -0
  87. package/dist/node/domain-util.js +16 -0
  88. package/dist/node/domain-util.js.map +1 -0
  89. package/dist/node/errors.d.ts +5 -0
  90. package/dist/node/errors.js +5 -0
  91. package/dist/node/errors.js.map +1 -1
  92. package/dist/node/generated-version.d.ts +1 -1
  93. package/dist/node/generated-version.js +1 -1
  94. package/dist/node/generated-version.js.map +1 -1
  95. package/dist/node/helia/util.js +4 -3
  96. package/dist/node/helia/util.js.map +1 -1
  97. package/dist/node/index-with-compile-cache.d.ts +18 -12
  98. package/dist/node/index.d.ts +18 -12
  99. package/dist/node/pkc-error.d.ts +1 -1
  100. package/dist/node/publications/community-edit/schema.d.ts +12 -8
  101. package/dist/node/publications/publication.d.ts +1 -0
  102. package/dist/node/publications/publication.js +56 -17
  103. package/dist/node/publications/publication.js.map +1 -1
  104. package/dist/node/pubsub-messages/schema.d.ts +6 -4
  105. package/dist/node/rpc/src/lib/pkc-js/index.d.ts +9 -6
  106. package/dist/node/rpc/src/schema.d.ts +54 -36
  107. package/dist/node/runtime/node/community/challenges/exclude/exclude.d.ts +1 -1
  108. package/dist/node/runtime/node/community/challenges/exclude/exclude.js +41 -16
  109. package/dist/node/runtime/node/community/challenges/exclude/exclude.js.map +1 -1
  110. package/dist/node/runtime/node/community/challenges/exclude/utils.d.ts +2 -3
  111. package/dist/node/runtime/node/community/challenges/exclude/utils.js +1 -15
  112. package/dist/node/runtime/node/community/challenges/exclude/utils.js.map +1 -1
  113. package/dist/node/runtime/node/community/challenges/index.js +1 -1
  114. package/dist/node/runtime/node/community/challenges/index.js.map +1 -1
  115. package/dist/node/runtime/node/community/challenges/pkc-js-challenges/blacklist.js +18 -13
  116. package/dist/node/runtime/node/community/challenges/pkc-js-challenges/blacklist.js.map +1 -1
  117. package/dist/node/runtime/node/community/challenges/pkc-js-challenges/whitelist.js +18 -13
  118. package/dist/node/runtime/node/community/challenges/pkc-js-challenges/whitelist.js.map +1 -1
  119. package/dist/node/runtime/node/community/db-handler.d.ts +3 -2
  120. package/dist/node/runtime/node/community/db-handler.js +20 -2
  121. package/dist/node/runtime/node/community/db-handler.js.map +1 -1
  122. package/dist/node/runtime/node/community/local-community/author-identity.d.ts +19 -0
  123. package/dist/node/runtime/node/community/local-community/author-identity.js +50 -0
  124. package/dist/node/runtime/node/community/local-community/author-identity.js.map +1 -0
  125. package/dist/node/runtime/node/community/local-community/ipns-publishing.js +7 -1
  126. package/dist/node/runtime/node/community/local-community/ipns-publishing.js.map +1 -1
  127. package/dist/node/runtime/node/community/local-community/publication-validation.js +8 -22
  128. package/dist/node/runtime/node/community/local-community/publication-validation.js.map +1 -1
  129. package/dist/node/schema/schema-util.d.ts +27 -18
  130. package/dist/node/schema.d.ts +72 -48
  131. package/dist/node/test/mock-ipfs-client.js +6 -0
  132. package/dist/node/test/mock-ipfs-client.js.map +1 -1
  133. package/dist/node/test/test-util.d.ts +13 -10
  134. package/dist/node/test/test-util.js +2 -2
  135. package/dist/node/test/test-util.js.map +1 -1
  136. package/dist/node/util.d.ts +1 -4
  137. package/dist/node/util.js +4 -10
  138. package/dist/node/util.js.map +1 -1
  139. package/dist/node/version.js +1 -1
  140. package/package.json +3 -2
@@ -1,12 +1,12 @@
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, Bt as require_sha256, C as calculateStringSizeSameAsIpfsAddCidV0, Cn as CommentIpfsSchema, Cr as messages, Ct as writeKuboFilesWithTimeout, Dt as findUpdatingCommunity, E as contentContainsMarkdownVideos, F as getErrorCodeFromMessage, Hn as CommentEditReservedFields, Ht as pTimeout, I as getIpnsRecordInLocalKuboNode, It as trackUpdatingCommunity, J as isLinkOfImage, Jn as AuthorReservedFields, K as isLinkOfAnimatedImage, Lr as ZodError, Lt as untrackStartedCommunity, N as genToArray, Nn as CommentUpdateTableRowSchema, Nt as syncCommunityRegistryEntry, P as getEquivalentCommunityAddresses, Pn as CommentsTableRowSchema, Pt as trackStartedCommunity, Qt as CommentModerationsTableRowSchema, R as hideClassPrivateProps, S as calculateIpfsCidV0, Sr as PKCError, T as contentContainsMarkdownImages, Tt as findStartedCommunity, Vn as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema, Wn as CommentEditsTableRowSchema, Wt as CommunityEditPublicationPubsubReservedFields, X as isLinkOfVideo, Xt as CommentModerationReservedFields, Y as isLinkOfMedia, Yt as CommentModerationPubsubMessagePublicationSchema, Z as isLinkValid, _n as VotePubsubMessagePublicationSchema, a as ChallengeRequestMessageSchema, ar as t$6, b as areEquivalentCommunityAddresses, bn as VoteTablesRowSchema, cn as CommunitySignedPropertyNames, d as DecryptedChallengeRequestSchema, et as isStringDomain, gr as require_retry, ht as retryKuboIpfsAddAndProvide, ir as t$7, jn as CommentUpdateSchema, k as derivePublicationFromChallengeRequest, lr as r$1, lt as removeNullUndefinedValues, mr as t$3, nr as t$8, or as e, ot as removeBlocksFromKuboNode, pr as t$5, pt as retryKuboBlockPutPinAndProvidePubsubTopic, q as isLinkOfAudio, r as ChallengeMessageSchema, rr as n$3, s as ChallengeVerificationMessageSchema, sn as CommunityIpfsSchema, sr as e$1, st as removeMfsFilesSafely, t as ChallengeAnswerMessageSchema, tr as n$4, tt as pubsubTopicToDhtKey, u as DecryptedChallengeRequestPublicationSchema, ur as t$4, vn as VotePubsubReservedFields, vt as sleepUntilTimeoutOrAbort, w as contentContainsMarkdownAudio, wn as CommentPubsubMessageReservedFields, wr as logger_default, wt as findCommunityInRegistry, xt as timestamp, y as version_default, yt as statMfsPathSafely, zt as untrackUpdatingCommunity } from "./schema-f2Zr1ZxK.js";
3
- import { $t as getPublicKeyFromPrivateKey, A as deriveDbPosts, At as verifyCommentIpfs, Bt as getAuthorNameFromWire, C as BackupAbortError, Cn as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, Dt as verifyChallengeRequest, E as calculateInlineRepliesBudget, En as parseJsonWithPKCErrorIfFails, F as importSignerIntoKuboNode, Ft as verifyCommunityEdit, G as REPLY_REPLIES_SORT_TYPES, Gt as getCommunityPublicKeyFromWire, It as verifyVote, Jt as encode, K as TIMEFRAMES_TO_SECONDS, Lt as buildRuntimeAuthor, M as getDefaultCommunityDbConfig, Mt as verifyCommentPubsubMessage, Nt as verifyCommentUpdate, O as deleteOldCommunityInWindows, P as getThumbnailPropsOfLink, Pt as verifyCommunity, Qt as getPKCAddressFromPublicKeySync, R as moveCommunityDbToDeletedDirectory, Rt as cleanWireAuthor, S as encryptEd25519AesGcmPublicKeyBuffer, St as signCommunity, T as calculateExpectedSignatureSize, Tt as verifyChallengeAnswer, U as POSTS_SORT_TYPES, W as POST_REPLIES_SORT_TYPES, Wt as getCommunityNameFromWire, Xt as getIpfsKeyFromPrivateKey, Z as iterateOverPageCidsToFindAllCids, Zt as getPKCAddressFromPublicKey, _t as signComment, a as loadChallengeFileFromCommunityChallengeSettings, ar as t$11, b as decryptEd25519AesGcmPublicKeyBuffer, bt as signCommentUpdate, c as LRUCache, d as KeyvBetterSqlite3, dn as parseCommunityEditOptionsSchemaWithPKCErrorIfItFails, dr as STORAGE_KEYS, en as createSchemaRowParser, er as crosspostChainDepthUpTo, fr as require_lodash_merge, ft as cleanUpBeforePublishing, g as SignerWithPublicKeyAddress, gt as signChallengeVerification, i as getCommunityChallengeFromCommunityChallengeSettings, ir as r$2, j as deriveDbReplies, jt as verifyCommentModeration, k as deriveCommentIpfsFromCommentTableRow, kt as verifyCommentEdit, lr as t$10, lt as pLimit, mt as signChallengeMessage, nr as t$9, o as pkcJsChallenges, or as n$6, pn as parseCommunityIpfsSchemaPassthroughWithPKCErrorIfItFails, qt as decode, r as getChallengeVerification, rr as t$12, s as TrackedInstanceRegistry, sr as n$5, t as RpcLocalCommunity, tr as effectiveMaxCrosspostDepth, u as MAX_FILE_SIZE_BYTES_FOR_COMMUNITY_IPFS, ur as stringify, vt as signCommentEdit, w as backupCommunityDb, xt as signCommentUpdateForChallengeVerification, z as resolveDbPostsCidRefs } from "./rpc-local-community-CTyhIJyD.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-DdD_6tTd.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-pLvHO4g9.js";
4
4
  import { randomFillSync, randomUUID } from "node:crypto";
5
5
  import { fileURLToPath, pathToFileURL } from "node:url";
6
- import Path from "node:path";
6
+ import path from "node:path";
7
7
  import os from "os";
8
8
  import { existsSync, promises } from "node:fs";
9
- import path from "path";
9
+ import path$1 from "path";
10
10
  import assert from "assert";
11
11
  import fs from "fs";
12
12
  import Database from "better-sqlite3";
@@ -1264,22 +1264,12 @@ function isFlairInAllowedList(flair, allowedFlairs) {
1264
1264
  }
1265
1265
  async function isPublicationAuthorPartOfRoles(community, publication, rolesToCheckAgainst) {
1266
1266
  if (!community.roles) return false;
1267
- const signerAddress = await getPKCAddressFromPublicKey(publication.signature.publicKey);
1268
- if (rolesToCheckAgainst.includes(community.roles[signerAddress]?.role)) return true;
1269
- const authorName = getAuthorNameFromWire(publication.author);
1270
- if (typeof authorName === "string") {
1271
- if (rolesToCheckAgainst.includes(community.roles[authorName]?.role)) return true;
1272
- if (community._pkc.resolveAuthorNames && isStringDomain(authorName)) {
1273
- const { resolvedAuthorName: resolvedSignerAddress } = await community._clientsManager.resolveAuthorNameIfNeeded({
1274
- authorName,
1275
- abortSignal: AbortSignal.timeout(community._pkc._timeouts["resolve-author-name"]),
1276
- cache: { maxAge: 0 }
1277
- });
1278
- if (resolvedSignerAddress !== signerAddress) return false;
1279
- if (rolesToCheckAgainst.includes(community.roles[resolvedSignerAddress]?.role)) return true;
1280
- }
1281
- }
1282
- return false;
1267
+ 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);
1283
1273
  }
1284
1274
  async function respondWithErrorIfSignatureOfPublicationIsInvalid(community, request) {
1285
1275
  let validity;
@@ -1942,15 +1932,15 @@ async function throwIfChallengeSettingsAreInvalid({ challengeSettings, pkc, comm
1942
1932
  const processStartedCommunities = new TrackedInstanceRegistry();
1943
1933
  function normalizeRegistryDataPath(dataPath) {
1944
1934
  if (dataPath === void 0) return void 0;
1945
- const resolved = path.resolve(dataPath);
1935
+ const resolved = path$1.resolve(dataPath);
1946
1936
  let existing = resolved;
1947
1937
  let tail = "";
1948
1938
  while (true) try {
1949
- return path.join(fs.realpathSync.native(existing), tail);
1939
+ return path$1.join(fs.realpathSync.native(existing), tail);
1950
1940
  } catch {
1951
- const parent = path.dirname(existing);
1941
+ const parent = path$1.dirname(existing);
1952
1942
  if (parent === existing) return resolved;
1953
- tail = path.join(path.basename(existing), tail);
1943
+ tail = path$1.join(path$1.basename(existing), tail);
1954
1944
  existing = parent;
1955
1945
  }
1956
1946
  }
@@ -3685,12 +3675,27 @@ var DbHandler = class {
3685
3675
  const fieldsToRemove = [
3686
3676
  "post",
3687
3677
  "reply",
3688
- "vote"
3678
+ "vote",
3679
+ "address",
3680
+ "role"
3689
3681
  ];
3690
3682
  const newSettings = t$10(oldSettings);
3691
3683
  if (Array.isArray(newSettings.challenges)) {
3692
3684
  newSettings.challenges = newSettings.challenges.filter((cs) => !cs.name || cs.path || cs.name in pkcJsChallenges);
3693
- for (const oldChallengeSetting of newSettings.challenges) if (oldChallengeSetting.exclude) for (const oldExcludeSetting of oldChallengeSetting.exclude) for (const fieldToMove of fieldsToRemove) delete oldExcludeSetting[fieldToMove];
3685
+ for (const oldChallengeSetting of newSettings.challenges) if (oldChallengeSetting.exclude) for (const oldExcludeSetting of oldChallengeSetting.exclude) {
3686
+ if (Array.isArray(oldExcludeSetting.role)) {
3687
+ const oldRoles = oldExcludeSetting.role.filter((role) => typeof role === "string");
3688
+ if (oldRoles.length > 0) oldExcludeSetting.roles = [...new Set([...oldExcludeSetting.roles ?? [], ...oldRoles])];
3689
+ }
3690
+ if (Array.isArray(oldExcludeSetting.address)) {
3691
+ const oldAddresses = oldExcludeSetting.address.filter((address) => typeof address === "string");
3692
+ const domains = oldAddresses.filter((address) => isStringDomain(address));
3693
+ const signerAddresses = oldAddresses.filter((address) => !isStringDomain(address));
3694
+ if (domains.length > 0) oldExcludeSetting.names = [...new Set([...oldExcludeSetting.names ?? [], ...domains])];
3695
+ if (signerAddresses.length > 0) oldExcludeSetting.publicKeys = [...new Set([...oldExcludeSetting.publicKeys ?? [], ...signerAddresses])];
3696
+ }
3697
+ for (const fieldToMove of fieldsToRemove) delete oldExcludeSetting[fieldToMove];
3698
+ }
3694
3699
  }
3695
3700
  return newSettings;
3696
3701
  }
@@ -3706,9 +3711,9 @@ var DbHandler = class {
3706
3711
  if (needToMigrate) {
3707
3712
  if (dbExistsAlready && currentDbVersion > 0) {
3708
3713
  this.destoryConnection();
3709
- backupDbPath = path.join(path.dirname(dbPath), ".backup_before_migration", `${path.basename(dbPath)}.${currentDbVersion}.${timestamp()}`);
3710
- log(`Copying db ${path.basename(dbPath)} to ${backupDbPath} before migration`);
3711
- if (!fs.existsSync(path.dirname(backupDbPath))) await fs.promises.mkdir(path.dirname(backupDbPath), { recursive: true });
3714
+ backupDbPath = path$1.join(path$1.dirname(dbPath), ".backup_before_migration", `${path$1.basename(dbPath)}.${currentDbVersion}.${timestamp()}`);
3715
+ log(`Copying db ${path$1.basename(dbPath)} to ${backupDbPath} before migration`);
3716
+ if (!fs.existsSync(path$1.dirname(backupDbPath))) await fs.promises.mkdir(path$1.dirname(backupDbPath), { recursive: true });
3712
3717
  const sourceDb = new Database(dbPath, { fileMustExist: true });
3713
3718
  await sourceDb.backup(backupDbPath);
3714
3719
  sourceDb.close();
@@ -5526,10 +5531,10 @@ var DbHandler = class {
5526
5531
  if (this._db || this._keyv) await this.destoryConnection();
5527
5532
  this._transactionDepth = 0;
5528
5533
  const dataPath = this._community._pkc.dataPath;
5529
- const oldPathString = path.join(dataPath, "communities", oldDbName);
5530
- const newPathString = path.join(dataPath, "communities", newDbName);
5531
- await fs.promises.mkdir(path.dirname(oldPathString), { recursive: true });
5532
- await fs.promises.mkdir(path.dirname(newPathString), { recursive: true });
5534
+ const oldPathString = path$1.join(dataPath, "communities", oldDbName);
5535
+ const newPathString = path$1.join(dataPath, "communities", newDbName);
5536
+ await fs.promises.mkdir(path$1.dirname(oldPathString), { recursive: true });
5537
+ await fs.promises.mkdir(path$1.dirname(newPathString), { recursive: true });
5533
5538
  try {
5534
5539
  if (!fs.existsSync(oldPathString)) log(`Old DB file ${oldPathString} does not exist. Cannot backup/rename.`);
5535
5540
  else {
@@ -5551,8 +5556,8 @@ var DbHandler = class {
5551
5556
  }
5552
5557
  async lockCommunityStart(communityAddress = this._community.address) {
5553
5558
  const log = logger_default("pkc-js:local-community:db-handler:lock:start");
5554
- const lockfilePath = path.join(this._community._pkc.dataPath, "communities", `${communityAddress}.start.lock`);
5555
- const communityDbPath = path.join(this._community._pkc.dataPath, "communities", communityAddress);
5559
+ const lockfilePath = path$1.join(this._community._pkc.dataPath, "communities", `${communityAddress}.start.lock`);
5560
+ const communityDbPath = path$1.join(this._community._pkc.dataPath, "communities", communityAddress);
5556
5561
  try {
5557
5562
  await import_src.default.lock(communityDbPath, {
5558
5563
  lockfilePath,
@@ -5573,8 +5578,8 @@ var DbHandler = class {
5573
5578
  async unlockCommunityStart(communityAddress = this._community.address) {
5574
5579
  const log = logger_default("pkc-js:local-community:db-handler:unlock:start");
5575
5580
  log.trace(`Attempting to unlock the start of community (${communityAddress})`);
5576
- const lockfilePath = path.join(this._community._pkc.dataPath, "communities", `${communityAddress}.start.lock`);
5577
- const communityDbPath = path.join(this._community._pkc.dataPath, "communities", communityAddress);
5581
+ const lockfilePath = path$1.join(this._community._pkc.dataPath, "communities", `${communityAddress}.start.lock`);
5582
+ const communityDbPath = path$1.join(this._community._pkc.dataPath, "communities", communityAddress);
5578
5583
  if (!fs.existsSync(lockfilePath) || !fs.existsSync(communityDbPath)) return;
5579
5584
  try {
5580
5585
  await import_src.default.unlock(communityDbPath, { lockfilePath });
@@ -5585,8 +5590,8 @@ var DbHandler = class {
5585
5590
  }
5586
5591
  }
5587
5592
  async isCommunityStartLocked(communityAddress = this._community.address) {
5588
- const lockfilePath = path.join(this._community._pkc.dataPath, "communities", `${communityAddress}.start.lock`);
5589
- const communityDbPath = path.join(this._community._pkc.dataPath, "communities", communityAddress);
5593
+ const lockfilePath = path$1.join(this._community._pkc.dataPath, "communities", `${communityAddress}.start.lock`);
5594
+ const communityDbPath = path$1.join(this._community._pkc.dataPath, "communities", communityAddress);
5590
5595
  return await import_src.default.check(communityDbPath, {
5591
5596
  lockfilePath,
5592
5597
  realpath: false,
@@ -5595,8 +5600,8 @@ var DbHandler = class {
5595
5600
  }
5596
5601
  async lockCommunityState() {
5597
5602
  const log = logger_default("pkc-js:local-community:db-handler:lock:lockCommunityState");
5598
- const lockfilePath = path.join(this._community._pkc.dataPath, "communities", `${this._community.address}.state.lock`);
5599
- const communityDbPath = path.join(this._community._pkc.dataPath, "communities", this._community.address);
5603
+ const lockfilePath = path$1.join(this._community._pkc.dataPath, "communities", `${this._community.address}.state.lock`);
5604
+ const communityDbPath = path$1.join(this._community._pkc.dataPath, "communities", this._community.address);
5600
5605
  try {
5601
5606
  await import_src.default.lock(communityDbPath, {
5602
5607
  lockfilePath,
@@ -5613,8 +5618,8 @@ var DbHandler = class {
5613
5618
  }
5614
5619
  async unlockCommunityState() {
5615
5620
  const log = logger_default("pkc-js:local-community:db-handler:lock:unlockCommunityState");
5616
- const lockfilePath = path.join(this._community._pkc.dataPath, "communities", `${this._community.address}.state.lock`);
5617
- const communityDbPath = path.join(this._community._pkc.dataPath, "communities", this._community.address);
5621
+ const lockfilePath = path$1.join(this._community._pkc.dataPath, "communities", `${this._community.address}.state.lock`);
5622
+ const communityDbPath = path$1.join(this._community._pkc.dataPath, "communities", this._community.address);
5618
5623
  if (!fs.existsSync(lockfilePath)) return;
5619
5624
  try {
5620
5625
  await import_src.default.unlock(communityDbPath, { lockfilePath });
@@ -5624,7 +5629,7 @@ var DbHandler = class {
5624
5629
  }
5625
5630
  }
5626
5631
  communityDbExists() {
5627
- const communityDbPath = path.join(this._community._pkc.dataPath, "communities", this._community.address);
5632
+ const communityDbPath = path$1.join(this._community._pkc.dataPath, "communities", this._community.address);
5628
5633
  return fs.existsSync(communityDbPath);
5629
5634
  }
5630
5635
  markCommentsAsPublishedToPostUpdates(commentCids) {
@@ -6639,7 +6644,7 @@ async function publishCommunityRecordToIpns(community, build, newCommunityRecord
6639
6644
  });
6640
6645
  if (!community.signer.ipnsKeyName) throw Error("IPNS key name is not defined");
6641
6646
  if (community._firstUpdateAfterStart) await community._resolveIpnsAndLogIfPotentialProblematicSequence();
6642
- const ttl = `${community._pkc.publishInterval * 3}ms`;
6647
+ const ttl = `${community._pkc.publishInterval * 1}ms`;
6643
6648
  const lastPublishedIpnsRecordData = await community._dbHandler.keyvGet(STORAGE_KEYS[STORAGE_KEYS.LAST_IPNS_RECORD]);
6644
6649
  const decodedIpnsRecord = lastPublishedIpnsRecordData ? decode(new Uint8Array(Object.values(lastPublishedIpnsRecordData))) : void 0;
6645
6650
  decodedIpnsRecord && BigInt(decodedIpnsRecord.sequence) + 1n;
@@ -7369,11 +7374,11 @@ async function edit(community, newCommunityOptions) {
7369
7374
  const EXPORTS_KEY = STORAGE_KEYS[STORAGE_KEYS.EXPORTS];
7370
7375
  function defaultExportPathFor(community, exportId) {
7371
7376
  if (typeof community._pkc.dataPath !== "string") throw new PKCError("ERR_DATA_PATH_IS_NOT_DEFINED", { communityAddress: community.address });
7372
- return Path.join(community._pkc.dataPath, "exports", `${exportId}.sqlite`);
7377
+ return path.join(community._pkc.dataPath, "exports", `${exportId}.sqlite`);
7373
7378
  }
7374
7379
  function sourceDbPathFor(community) {
7375
7380
  if (typeof community._pkc.dataPath !== "string") throw new PKCError("ERR_DATA_PATH_IS_NOT_DEFINED", { communityAddress: community.address });
7376
- return Path.join(community._pkc.dataPath, "communities", community.address);
7381
+ return path.join(community._pkc.dataPath, "communities", community.address);
7377
7382
  }
7378
7383
  async function persistExports(community) {
7379
7384
  if (!community._dbHandler) return;
@@ -7449,9 +7454,9 @@ async function runExportTask(community, exportId, opts) {
7449
7454
  async function exportCommunityEmbedded(community, options = {}) {
7450
7455
  if (options.signal?.aborted) throw options.signal.reason ?? new DOMException("The operation was aborted.", "AbortError");
7451
7456
  const exportId = v4();
7452
- const destPath = options.exportPath ? Path.resolve(options.exportPath) : defaultExportPathFor(community, exportId);
7457
+ const destPath = options.exportPath ? path.resolve(options.exportPath) : defaultExportPathFor(community, exportId);
7453
7458
  const includePrivateKey = options.includePrivateKey === true;
7454
- if (Path.resolve(destPath) === Path.resolve(sourceDbPathFor(community))) throw new PKCError("ERR_EXPORT_PATH_TARGETS_LIVE_DB", {
7459
+ if (path.resolve(destPath) === path.resolve(sourceDbPathFor(community))) throw new PKCError("ERR_EXPORT_PATH_TARGETS_LIVE_DB", {
7455
7460
  communityAddress: community.address,
7456
7461
  exportPath: destPath
7457
7462
  });
@@ -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 listUpdatingCommunities, B as ipnsNameToIpnsOverPubsubTopic, Br as stringifyPrimitive, Bt as require_sha256, Cn as CommentIpfsSchema, Cr as messages, D as createAbortError, Dr as setErrorMap, Dt as findUpdatingCommunity, Et as findUpdatingComment, Ft as trackUpdatingComment, H as isIpfsCid, Ht as pTimeout, O as deepMergeRuntimeFields, On as CommentUpdateForChallengeVerificationSchema, Ot as listStartedCommunities, R as hideClassPrivateProps, Rr as joinValues, Rt as untrackUpdatingComment, Sr as PKCError, St as waitForUpdateInCommunityInstanceWithErrorAndTimeout, Tt as findStartedCommunity, V as isAbortError, Vt as TimeoutError, W as isIpns, _r as FailedToFetchCommentIpfsFromGatewaysError, _t as shortifyCid, a as ChallengeRequestMessageSchema, ar as t$1, at as rejectWhenCommunityStopsOrAborts, b as areEquivalentCommunityAddresses, bt as throwIfAbortSignalAborted, dt as replaceXWithY, et as isStringDomain, ft as resolveWhenPredicateIsTrue, gr as require_retry, gt as shortifyAddress, it as rejectWhenAbortSignalFires, jn as CommentUpdateSchema, jt as refreshTrackedCommentAliases, kt as listUpdatingComments, lr as r, mt as retryKuboIpfsAdd, nn as CommunityAnchorSchema, or as e, pn as PubsubTopicSchema, r as ChallengeMessageSchema, rr as n$1, s as ChallengeVerificationMessageSchema, sn as CommunityIpfsSchema, sr as e$1, t as ChallengeAnswerMessageSchema, tr as n$2, ut as removeUndefinedValuesRecursively, vt as sleepUntilTimeoutOrAbort, wr as logger_default, xt as timestamp, y as version_default, zr as parsedType } from "./schema-f2Zr1ZxK.js";
3
- import { $ as RepliesPages, $n as RpcUnsubscribeParamSchema, An as parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, At as verifyCommentIpfs, B as setNativeFunctions$1, Bn as RpcEditCommunityParamSchema, Cn as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, Ct as signCommunityEdit, D as createKuboRpcClient, Dn as parsePKCUserOptionsSchemaWithPKCErrorIfItFails, En as parseJsonWithPKCErrorIfFails, Et as verifyChallengeMessage, Fn as RpcCancelExportParamSchema, Ft as verifyCommunityEdit, Gn as RpcFetchCidParamSchema, Gt as getCommunityPublicKeyFromWire, H as CommentClientsManager, Hn as RpcExportCommunityModLogsResultSchema, Ht as buildRuntimeCommunityFields, I as listCommunitiesSync, In as RpcCidParamSchema, It as verifyVote, Jn as RpcPublishChallengeAnswersParamSchema, Kn as RpcFetchCidResultSchema, Kt as normalizeCommunityInputFromCommunity, L as monitorCommunitiesDirectory, Ln as RpcCommentRepliesPageParamSchema, Lt as buildRuntimeAuthor, Mn as parseVotePubsubMessagePublicationSchemaWithPKCErrorIfItFails, Mt as verifyCommentPubsubMessage, N as getDefaultDataPath, Nn as RpcAnchorPublishPreparationResultSchema, Nt as verifyCommentUpdate, On as parseRpcCommentEventWithPKCErrorIfItFails, Ot as verifyChallengeVerification, Pn as RpcAuthorNameParamSchema, Q as parseRawPages, Qn as RpcSuccessResultSchema, Qt as getPKCAddressFromPublicKeySync, Rn as RpcCommunityIdentifierParamSchema, Rt as cleanWireAuthor, Sn as parseCreateVoteOptionsSchemaWithPKCErrorIfItFails, Tn as parseDecryptedChallengeWithPKCErrorIfItFails, Un as RpcExportCommunityParamSchema, Ut as getCommunityAddressFromRecord, V as tryToDeleteCommunitiesThatFailedToBeDeletedBefore, Vn as RpcExportCommunityModLogsParamSchema, Vt as normalizeCreatePublicationAuthor, Wn as RpcExportCommunityResultSchema, Wt as getCommunityNameFromWire, X as findCommentInPageInstanceRecursively, Xn as RpcResolveAuthorNameResultSchema, Y as extractCommunityRuntimeFieldsFromParsedPages, Yn as RpcPublishedAnchorRecordResultSchema, Yt as getBufferedPKCAddressFromPublicKey, Zn as RpcSubscriptionIdResultSchema, _ as createSigner, _n as parseCreateCommunityEditPublicationOptionsSchemaWithPKCErrorIfItFails, _t as signComment, an as parseCommentIpfsSchemaWithPKCErrorIfItFails, ar as t$3, at as PublicationClientsManager, bn as parseCreateRemoteCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, c as LRUCache, cn as parseCommentPubsubMessagePublicationWithPKCErrorIfItFails, cr as t$2, d as KeyvBetterSqlite3, dt as require_lib$1, et as applyNameResolvedCacheToCrosspost, f as decodeRpcChallengeAnswerPubsubMsg, fn as parseCommunityEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, ft as cleanUpBeforePublishing, gn as parseCreateCommentOptionsSchemaWithPKCErrorIfItFails, h as decodeRpcChallengeVerificationPubsubMsg, hn as parseCreateCommentModerationOptionsSchemaWithPKCErrorIfItFails, ht as signChallengeRequest, in as parseCommentEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, it as stripNameResolvedFromCrosspost, jt as verifyCommentModeration, kn as parseRpcCommentUpdateEventWithPKCErrorIfItFails, kt as verifyCommentEdit, l as RemoteCommunity, ln as parseCommunityAddressWithPKCErrorIfItFails, lr as t$5, m as decodeRpcChallengeRequestPubsubMsg, mn as parseCreateCommentEditOptionsSchemaWithPKCErrorIfItFails, mr as require_undici, n as RpcRemoteCommunity, nr as t$4, nt as collectCrosspostAuthorsToResolve, o as pkcJsChallenges, or as n$3, ot as PKCClientsManager, p as decodeRpcChallengePubsubMsg, pr as nativeFunctions$2, pt as signChallengeAnswer, qn as RpcPublishAnchorRecordParamSchema, qt as decode, s as TrackedInstanceRegistry, sn as parseCommentModerationPubsubMessagePublicationSchemaWithPKCErrorIfItFails, st as InflightFetchManager, t as RpcLocalCommunity, tn as parseCidStringSchemaWithPKCErrorIfItFails, tt as cloneCrosspostForRuntime, ut as PKCTypedEmitter, v as createAnchorIpnsRecord$1, vt as signCommentEdit, wn as parseDecryptedChallengeVerification, wt as signVote, x as encryptEd25519AesGcm, xn as parseCreateRpcCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, y as decryptEd25519AesGcm, yt as signCommentModeration, zn as RpcCommunityPageParamSchema, zt as getAuthorNameFromRuntime } from "./rpc-local-community-CTyhIJyD.js";
4
- import { o as getHeliaDebugContext } from "./util-BbXV7Dcu.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-DdD_6tTd.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-pLvHO4g9.js";
4
+ import { o as getHeliaDebugContext } from "./util-N0_wIz2O.js";
5
5
  import path from "path";
6
6
  import assert from "assert";
7
7
  import fs from "fs";
@@ -358,6 +358,10 @@ var Publication = class extends import_lib.TypedEmitter {
358
358
  ...msg,
359
359
  ...decryptedChallenge
360
360
  };
361
+ if (Object.values(this._challengeExchanges).some((exchange) => exchange.challenge)) {
362
+ log.trace("Received a copy of a challenge that was already handled, ignoring it");
363
+ return;
364
+ }
361
365
  this._challengeExchanges[msg.challengeRequestId.toString()].challenge = decryptedChallengeMsg;
362
366
  this._updatePublishingStateWithEmission("waiting-challenge-answers");
363
367
  const challengeTopic = this._community?.pubsubTopic;
@@ -422,10 +426,6 @@ var Publication = class extends import_lib.TypedEmitter {
422
426
  this.emit("error", e);
423
427
  return;
424
428
  }
425
- if (decryptedChallengeVerification.comment) {
426
- await this._verifyDecryptedChallengeVerificationAndUpdateCommentProps(decryptedChallengeVerification);
427
- log("Updated the props of this instance with challengeverification.encrypted");
428
- }
429
429
  }
430
430
  } else {
431
431
  newPublishingState = "failed";
@@ -435,7 +435,15 @@ var Publication = class extends import_lib.TypedEmitter {
435
435
  ...msg,
436
436
  ...decryptedChallengeVerification
437
437
  };
438
+ if (this._challengeExchanges[msg.challengeRequestId.toString()].challengeVerification) {
439
+ log.trace("Received a copy of a challenge verification that was already handled, ignoring it");
440
+ return;
441
+ }
438
442
  this._challengeExchanges[msg.challengeRequestId.toString()].challengeVerification = challengeVerificationMsg;
443
+ if (decryptedChallengeVerification?.comment) {
444
+ await this._verifyDecryptedChallengeVerificationAndUpdateCommentProps(decryptedChallengeVerification);
445
+ log("Updated the props of this instance with challengeverification.encrypted");
446
+ }
439
447
  Object.values(this._challengeExchanges).forEach((exchange) => this._updatePubsubState("stopped", exchange.providerUrl));
440
448
  this._changePublicationStateEmitEventEmitStateChangeEvent({
441
449
  newPublishingState,
@@ -498,30 +506,43 @@ var Publication = class extends import_lib.TypedEmitter {
498
506
  if (challengeExchangesWithChallenge.length === 0) throw Error("No challenge exchanges with challenge");
499
507
  if (challengeExchangesWithChallenge.length > 1) throw Error("We should only have one challenge exchange with challenge");
500
508
  const challengeExchange = challengeExchangesWithChallenge[0];
509
+ const challengeRequestIdString = challengeExchange.challengeRequest.challengeRequestId.toString();
510
+ if (challengeExchange.challengeAnswer || challengeExchange.challengeAnswerPublishInFlight) throw new PKCError("ERR_CHALLENGE_ANSWER_ALREADY_PUBLISHED", {
511
+ challengeRequestId: challengeRequestIdString,
512
+ publishingState: this.publishingState
513
+ });
514
+ challengeExchange.challengeAnswerPublishInFlight = true;
501
515
  assert(this._community, "Local pkc-js needs publication._community to be defined to publish challenge answer");
502
516
  if (!challengeExchange.signer) throw Error("Signer is undefined for this challenge exchange");
503
- const encryptedChallengeAnswers = await encryptEd25519AesGcm(JSON.stringify(toEncryptAnswers), challengeExchange.signer.privateKey, this._community.encryption.publicKey);
504
- const toSignAnswer = cleanUpBeforePublishing({
505
- type: "CHALLENGEANSWER",
506
- challengeRequestId: challengeExchange.challengeRequest.challengeRequestId,
507
- encrypted: encryptedChallengeAnswers,
508
- userAgent: this._pkc.userAgent,
509
- protocolVersion: version_default.PROTOCOL_VERSION,
510
- timestamp: timestamp()
511
- });
512
- const answerMsgToPublish = {
513
- ...toSignAnswer,
514
- signature: await signChallengeAnswer({
515
- challengeAnswer: toSignAnswer,
516
- signer: challengeExchange.signer
517
- })
518
- };
517
+ let answerMsgToPublish;
518
+ try {
519
+ const encryptedChallengeAnswers = await encryptEd25519AesGcm(JSON.stringify(toEncryptAnswers), challengeExchange.signer.privateKey, this._community.encryption.publicKey);
520
+ const toSignAnswer = cleanUpBeforePublishing({
521
+ type: "CHALLENGEANSWER",
522
+ challengeRequestId: challengeExchange.challengeRequest.challengeRequestId,
523
+ encrypted: encryptedChallengeAnswers,
524
+ userAgent: this._pkc.userAgent,
525
+ protocolVersion: version_default.PROTOCOL_VERSION,
526
+ timestamp: timestamp()
527
+ });
528
+ answerMsgToPublish = {
529
+ ...toSignAnswer,
530
+ signature: await signChallengeAnswer({
531
+ challengeAnswer: toSignAnswer,
532
+ signer: challengeExchange.signer
533
+ })
534
+ };
535
+ } catch (e) {
536
+ challengeExchange.challengeAnswerPublishInFlight = false;
537
+ throw e;
538
+ }
519
539
  this._updatePublishingStateWithEmission("publishing-challenge-answer");
520
540
  this._updatePubsubState("publishing-challenge-answer", challengeExchange.providerUrl);
521
541
  if (this._publishingToLocalCommunity) try {
522
542
  await this._publishingToLocalCommunity.handleChallengeAnswer(answerMsgToPublish);
523
543
  } catch (e) {
524
544
  this._challengeExchanges[challengeExchange.challengeRequest.challengeRequestId.toString()].challengeAnswerPublishError = e;
545
+ challengeExchange.challengeAnswerPublishInFlight = false;
525
546
  this._updatePublishingStateWithEmission("failed");
526
547
  this._updatePubsubState("stopped", challengeExchange.providerUrl);
527
548
  throw e;
@@ -530,6 +551,7 @@ var Publication = class extends import_lib.TypedEmitter {
530
551
  await this._clientsManager.pubsubPublishOnProvider(this._communityChallengePubsubExchangeTopic(), answerMsgToPublish, challengeExchange.providerUrl);
531
552
  } catch (e) {
532
553
  this._challengeExchanges[challengeExchange.challengeRequest.challengeRequestId.toString()].challengeAnswerPublishError = e;
554
+ challengeExchange.challengeAnswerPublishInFlight = false;
533
555
  this._updatePublishingStateWithEmission("failed");
534
556
  this._updatePubsubState("stopped", challengeExchange.providerUrl);
535
557
  throw e;
@@ -7032,7 +7054,7 @@ var PKC$1 = class extends PKCTypedEmitter {
7032
7054
  this.clients.libp2pJsClients = {};
7033
7055
  if (!this.libp2pJsClientsOptions) return;
7034
7056
  if (!this.httpRoutersOptions) throw Error("httpRoutersOptions is required for libp2pJsClient");
7035
- const { createLibp2pJsClientOrUseExistingOne } = await import("./helia-for-pkc-DUaUFShG.js");
7057
+ const { createLibp2pJsClientOrUseExistingOne } = await import("./helia-for-pkc-DSF3IY_M.js");
7036
7058
  for (const clientOptions of this.libp2pJsClientsOptions) {
7037
7059
  const heliaNode = await createLibp2pJsClientOrUseExistingOne({
7038
7060
  ...clientOptions,
@@ -7311,7 +7333,7 @@ var PKC$1 = class extends PKCTypedEmitter {
7311
7333
  const log = logger_default("pkc-js:pkc:createLocalCommunity");
7312
7334
  log.trace("Received community options to create a local community instance:", options);
7313
7335
  if (!this._canCreateNewLocalCommunity()) throw new PKCError("ERR_CAN_NOT_CREATE_A_LOCAL_COMMUNITY", { pkcOptions: this._userPKCOptions });
7314
- const { LocalCommunity, createNewLocalCommunityDb, updateInstancePropsWithStartedCommunityOrDb } = await import("./local-community-CM2GS9Ya.js");
7336
+ const { LocalCommunity, createNewLocalCommunityDb, updateInstancePropsWithStartedCommunityOrDb } = await import("./local-community-CTd_1kw_.js");
7315
7337
  const isLocalCommunity = (await listCommunitiesSync(this)).includes(options.address);
7316
7338
  const community = new LocalCommunity(this);
7317
7339
  if (isLocalCommunity) {