@pkcprotocol/pkc-js 0.0.100 → 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 (109) hide show
  1. package/dist/browser/clients/rpc-client/rpc-schema-util.d.ts +3 -2
  2. package/dist/browser/clients/rpc-client/schema.d.ts +3 -2
  3. package/dist/browser/community/schema.d.ts +110 -51
  4. package/dist/browser/community/schema.js +21 -5
  5. package/dist/browser/community/schema.js.map +1 -1
  6. package/dist/browser/domain-util.d.ts +3 -0
  7. package/dist/browser/domain-util.js +16 -0
  8. package/dist/browser/domain-util.js.map +1 -0
  9. package/dist/browser/errors.d.ts +4 -0
  10. package/dist/browser/errors.js +4 -0
  11. package/dist/browser/errors.js.map +1 -1
  12. package/dist/browser/generated-version.d.ts +1 -1
  13. package/dist/browser/generated-version.js +1 -1
  14. package/dist/browser/index-with-compile-cache.d.ts +18 -12
  15. package/dist/browser/index.d.ts +18 -12
  16. package/dist/browser/pkc-error.d.ts +1 -1
  17. package/dist/browser/publications/community-edit/schema.d.ts +12 -8
  18. package/dist/browser/pubsub-messages/schema.d.ts +6 -4
  19. package/dist/browser/rpc/src/lib/pkc-js/index.d.ts +9 -6
  20. package/dist/browser/rpc/src/schema.d.ts +54 -36
  21. package/dist/browser/runtime/node/community/challenges/exclude/exclude.d.ts +1 -1
  22. package/dist/browser/runtime/node/community/challenges/exclude/exclude.js +41 -16
  23. package/dist/browser/runtime/node/community/challenges/exclude/exclude.js.map +1 -1
  24. package/dist/browser/runtime/node/community/challenges/exclude/utils.d.ts +2 -3
  25. package/dist/browser/runtime/node/community/challenges/exclude/utils.js +1 -15
  26. package/dist/browser/runtime/node/community/challenges/exclude/utils.js.map +1 -1
  27. package/dist/browser/runtime/node/community/challenges/index.js +1 -1
  28. package/dist/browser/runtime/node/community/challenges/index.js.map +1 -1
  29. package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/blacklist.js +18 -13
  30. package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/blacklist.js.map +1 -1
  31. package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/whitelist.js +18 -13
  32. package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/whitelist.js.map +1 -1
  33. package/dist/browser/runtime/node/community/db-handler.d.ts +3 -2
  34. package/dist/browser/runtime/node/community/db-handler.js +20 -2
  35. package/dist/browser/runtime/node/community/db-handler.js.map +1 -1
  36. package/dist/browser/runtime/node/community/local-community/author-identity.d.ts +19 -0
  37. package/dist/browser/runtime/node/community/local-community/author-identity.js +50 -0
  38. package/dist/browser/runtime/node/community/local-community/author-identity.js.map +1 -0
  39. package/dist/browser/runtime/node/community/local-community/publication-validation.js +8 -22
  40. package/dist/browser/runtime/node/community/local-community/publication-validation.js.map +1 -1
  41. package/dist/browser/schema/schema-util.d.ts +27 -18
  42. package/dist/browser/schema.d.ts +72 -48
  43. package/dist/browser/test/test-util.d.ts +13 -10
  44. package/dist/browser/test/test-util.js +1 -1
  45. package/dist/browser/test/test-util.js.map +1 -1
  46. package/dist/browser/util.d.ts +1 -4
  47. package/dist/browser/util.js +4 -10
  48. package/dist/browser/util.js.map +1 -1
  49. package/dist/browser/version.js +1 -1
  50. package/dist/bundled/bundle-manifest.json +27 -25
  51. package/dist/bundled/chunks/{helia-for-pkc-Cq6VWePV.js → helia-for-pkc-DSF3IY_M.js} +33 -33
  52. package/dist/bundled/chunks/{local-community-CcHbWkoT.js → local-community-CTd_1kw_.js} +1 -1
  53. package/dist/bundled/chunks/{local-community-ph-pl_pg.js → local-community-DtlDCcc2.js} +53 -48
  54. package/dist/bundled/chunks/{node-2PkhAerB.js → node-pGNrsJuH.js} +5 -5
  55. package/dist/bundled/chunks/{rpc-local-community-BK1FjUk2.js → rpc-local-community-pLvHO4g9.js} +94 -35
  56. package/dist/bundled/chunks/{schema-CYR820MD.js → schema-DdD_6tTd.js} +29 -19
  57. package/dist/bundled/chunks/{util-gAVw5PrE.js → util-N0_wIz2O.js} +1 -1
  58. package/dist/bundled/index.js +1 -1
  59. package/dist/bundled/rpc/src/index.js +4 -4
  60. package/dist/node/clients/rpc-client/rpc-schema-util.d.ts +3 -2
  61. package/dist/node/clients/rpc-client/schema.d.ts +3 -2
  62. package/dist/node/community/schema.d.ts +110 -51
  63. package/dist/node/community/schema.js +21 -5
  64. package/dist/node/community/schema.js.map +1 -1
  65. package/dist/node/domain-util.d.ts +3 -0
  66. package/dist/node/domain-util.js +16 -0
  67. package/dist/node/domain-util.js.map +1 -0
  68. package/dist/node/errors.d.ts +4 -0
  69. package/dist/node/errors.js +4 -0
  70. package/dist/node/errors.js.map +1 -1
  71. package/dist/node/generated-version.d.ts +1 -1
  72. package/dist/node/generated-version.js +1 -1
  73. package/dist/node/index-with-compile-cache.d.ts +18 -12
  74. package/dist/node/index.d.ts +18 -12
  75. package/dist/node/pkc-error.d.ts +1 -1
  76. package/dist/node/publications/community-edit/schema.d.ts +12 -8
  77. package/dist/node/pubsub-messages/schema.d.ts +6 -4
  78. package/dist/node/rpc/src/lib/pkc-js/index.d.ts +9 -6
  79. package/dist/node/rpc/src/schema.d.ts +54 -36
  80. package/dist/node/runtime/node/community/challenges/exclude/exclude.d.ts +1 -1
  81. package/dist/node/runtime/node/community/challenges/exclude/exclude.js +41 -16
  82. package/dist/node/runtime/node/community/challenges/exclude/exclude.js.map +1 -1
  83. package/dist/node/runtime/node/community/challenges/exclude/utils.d.ts +2 -3
  84. package/dist/node/runtime/node/community/challenges/exclude/utils.js +1 -15
  85. package/dist/node/runtime/node/community/challenges/exclude/utils.js.map +1 -1
  86. package/dist/node/runtime/node/community/challenges/index.js +1 -1
  87. package/dist/node/runtime/node/community/challenges/index.js.map +1 -1
  88. package/dist/node/runtime/node/community/challenges/pkc-js-challenges/blacklist.js +18 -13
  89. package/dist/node/runtime/node/community/challenges/pkc-js-challenges/blacklist.js.map +1 -1
  90. package/dist/node/runtime/node/community/challenges/pkc-js-challenges/whitelist.js +18 -13
  91. package/dist/node/runtime/node/community/challenges/pkc-js-challenges/whitelist.js.map +1 -1
  92. package/dist/node/runtime/node/community/db-handler.d.ts +3 -2
  93. package/dist/node/runtime/node/community/db-handler.js +20 -2
  94. package/dist/node/runtime/node/community/db-handler.js.map +1 -1
  95. package/dist/node/runtime/node/community/local-community/author-identity.d.ts +19 -0
  96. package/dist/node/runtime/node/community/local-community/author-identity.js +50 -0
  97. package/dist/node/runtime/node/community/local-community/author-identity.js.map +1 -0
  98. package/dist/node/runtime/node/community/local-community/publication-validation.js +8 -22
  99. package/dist/node/runtime/node/community/local-community/publication-validation.js.map +1 -1
  100. package/dist/node/schema/schema-util.d.ts +27 -18
  101. package/dist/node/schema.d.ts +72 -48
  102. package/dist/node/test/test-util.d.ts +13 -10
  103. package/dist/node/test/test-util.js +1 -1
  104. package/dist/node/test/test-util.js.map +1 -1
  105. package/dist/node/util.d.ts +1 -4
  106. package/dist/node/util.js +4 -10
  107. package/dist/node/util.js.map +1 -1
  108. package/dist/node/version.js +1 -1
  109. 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-CYR820MD.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-BK1FjUk2.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) {
@@ -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-CYR820MD.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-BK1FjUk2.js";
4
- import { o as getHeliaDebugContext } from "./util-gAVw5PrE.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";
@@ -7054,7 +7054,7 @@ var PKC$1 = class extends PKCTypedEmitter {
7054
7054
  this.clients.libp2pJsClients = {};
7055
7055
  if (!this.libp2pJsClientsOptions) return;
7056
7056
  if (!this.httpRoutersOptions) throw Error("httpRoutersOptions is required for libp2pJsClient");
7057
- const { createLibp2pJsClientOrUseExistingOne } = await import("./helia-for-pkc-Cq6VWePV.js");
7057
+ const { createLibp2pJsClientOrUseExistingOne } = await import("./helia-for-pkc-DSF3IY_M.js");
7058
7058
  for (const clientOptions of this.libp2pJsClientsOptions) {
7059
7059
  const heliaNode = await createLibp2pJsClientOrUseExistingOne({
7060
7060
  ...clientOptions,
@@ -7333,7 +7333,7 @@ var PKC$1 = class extends PKCTypedEmitter {
7333
7333
  const log = logger_default("pkc-js:pkc:createLocalCommunity");
7334
7334
  log.trace("Received community options to create a local community instance:", options);
7335
7335
  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-CcHbWkoT.js");
7336
+ const { LocalCommunity, createNewLocalCommunityDb, updateInstancePropsWithStartedCommunityOrDb } = await import("./local-community-CTd_1kw_.js");
7337
7337
  const isLocalCommunity = (await listCommunitiesSync(this)).includes(options.address);
7338
7338
  const community = new LocalCommunity(this);
7339
7339
  if (isLocalCommunity) {
@@ -1,5 +1,5 @@
1
1
  import { i as __toESM, n as __exportAll, r as __require, t as __commonJSMin } from "./chunk-2rV9d50f.js";
2
- import { $ as isRequestPubsubPublicationOfReply, $n as CommunityAuthorChallengeReservedFieldNames, $t as CreateCommentModerationOptionsWithRefinementSchema, A as doesDomainAddressHaveCapitalLetter, An as CommentUpdateReservedFields, Ar as boolean, At as listUpdatingCommunities, B as ipnsNameToIpnsOverPubsubTopic, Bt as require_sha256$1, Cn as CommentIpfsSchema, Cr as messages, D as createAbortError, Dn as CommentUpdateChallengeReservedFieldNames, Dt as findUpdatingCommunity, En as CommentSignedPropertyNames, Er as require_ms$1, Et as findUpdatingComment, Fn as CreateCommentOptionsWithRefinementSchema, Fr as record, G as isIpnsPath, Gn as CreateCommentEditOptionsWithRefinementSchema, Gt as CommunityEditPublicationSignedPropertyNames, H as isIpfsCid, Ht as pTimeout, In as GetPageParamSchema, Ir as string, It as trackUpdatingCommunity, Jt as CommentModerationChallengeRequestToEncryptSchema, Kn as AuthorAddressSchema, Kt as CommunityEditPubsubMessagePublicationSchema, L as getPostUpdateTimestampRange, Ln as ModQueuePageIpfsSchema, Lt as untrackStartedCommunity, M as fetchAndValidateIpnsRecordFromGateway, Mn as CommentUpdateSignedPropertyNames, Mr as literal, Mt as refreshTrackedCommunityAliases, Nr as number, O as deepMergeRuntimeFields, Or as _enum, Ot as listStartedCommunities, Pr as object, Pt as trackStartedCommunity, Q as isRequestPubsubPublicationOfPost, Qn as CommunityAddressSchema, Qt as CommentModerationsTableRowSchema, R as hideClassPrivateProps, Rn as PageIpfsSchema, Rt as untrackUpdatingComment, S as calculateIpfsCidV0, Sn as CommentIpfsReservedFields, Sr as PKCError, St as waitForUpdateInCommunityInstanceWithErrorAndTimeout, Tn as CommentPubsubMessageWithFlexibleAuthorRefinementSchema, Tr as require_supports_color, Tt as findStartedCommunity, U as isIpfsPath, Un as CommentEditSignedPropertyNames, Ut as CommunityEditPublicationChallengeRequestToEncryptSchema, V as isAbortError, Vn as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema, W as isIpns, Xn as CidPathSchema, Yn as ChallengeAnswersSchema, Yt as CommentModerationPubsubMessagePublicationSchema, Zn as CidStringSchema, Zt as CommentModerationSignedPropertyNames, _ as PKCUserOptionBaseSchema, _n as VotePubsubMessagePublicationSchema, _r as FailedToFetchCommentIpfsFromGatewaysError, _t as shortifyCid, an as CommunityExportRecordsSchema, ar as t$13, b as areEquivalentCommunityAddresses, br as FailedToFetchGenericIpfsFromGatewaysError, bt as throwIfAbortSignalAborted, c as ChallengeVerificationMessageSignedPropertyNames, cn as CommunitySignedPropertyNames, cr as t$11, ct as removeNullUndefinedEmptyObjectsValuesRecursively, dn as CreateRpcCommunityFunctionArgumentSchema, dr as n$8, en as ChallengeFileFactorySchema, er as CreateSignerSchema, et as isStringDomain, f as DecryptedChallengeSchema, fn as ExportCommunityModLogsOptionsSchema, fr as r$7, ft as resolveWhenPredicateIsTrue, g as PKCParsedOptionsSchema, gn as VoteChallengeRequestToEncryptSchema, gr as require_retry$1, gt as shortifyAddress, h as NameResolverSerializedSchema, hn as CreateVoteUserOptionsWithRefinementSchema, hr as e$4, i as ChallengeMessageSignedPropertyNames, in as CommunityEditOptionsSchema, j as extractNetworkErrorDetails, jn as CommentUpdateSchema, jr as custom, k as derivePublicationFromChallengeRequest, kn as CommentUpdateForChallengeVerificationSignedPropertyNames, kr as array, l as DecryptedChallengeAnswerSchema, ln as CreateNewLocalCommunityUserOptionsSchema, lr as r$8, m as NameResolveCacheOptionsSchema, mn as RpcRemoteCommunityUpdateEventResultSchema, mr as t$9, n as ChallengeAnswerMessageSignedPropertyNames, o as ChallengeRequestMessageSignedPropertyNames, on as CommunityIpfsReservedFields, or as e$6, p as DecryptedChallengeVerificationSchema, pr as t$10, qn as AuthorCommentIpfsReservedFields, qt as CreateCommunityEditPublicationOptionsWithRefinementSchema, rn as CommunityChallengeSettingSchema, rr as n$9, rt as raceAgainstAbort, sn as CommunityIpfsSchema, sr as e$5, tn as ChallengeFileSchema, tr as n$10, tt as pubsubTopicToDhtKey, un as CreateRemoteCommunityFunctionArgumentSchema, ur as t$12, v as PKCUserOptionsSchema, vr as FailedToFetchCommentUpdateFromGatewaysError, vt as sleepUntilTimeoutOrAbort, wr as logger_default, xn as CommentChallengeRequestToEncryptSchema, xr as FailedToFetchPageIpfsFromGatewaysError, xt as timestamp, yn as VoteSignedPropertyNames, yr as FailedToFetchCommunityFromGatewaysError, z as interruptibleSleep, zn as CommentEditChallengeRequestToEncryptSchema, zt as untrackUpdatingCommunity } from "./schema-CYR820MD.js";
2
+ import { $ as isRequestPubsubPublicationOfReply, $n as CommunityAuthorChallengeReservedFieldNames, $t as ChallengeFileFactorySchema, A as doesDomainAddressHaveCapitalLetter, An as CommentUpdateReservedFields, Ar as boolean, B as ipnsNameToIpnsOverPubsubTopic, Cn as CommentIpfsSchema, Cr as messages, D as createAbortError, Dn as CommentUpdateChallengeReservedFieldNames, Dt as listStartedCommunities, En as CommentSignedPropertyNames, Er as require_ms$1, Et as findUpdatingCommunity, Fn as CreateCommentOptionsWithRefinementSchema, Fr as record, Ft as trackUpdatingCommunity, G as isIpnsPath, Gn as CreateCommentEditOptionsWithRefinementSchema, Gt as CommunityEditPubsubMessagePublicationSchema, H as isIpfsCid, Ht as CommunityEditPublicationChallengeRequestToEncryptSchema, In as GetPageParamSchema, Ir as string, It as untrackStartedCommunity, Jt as CommentModerationPubsubMessagePublicationSchema, Kn as AuthorAddressSchema, Kt as CreateCommunityEditPublicationOptionsWithRefinementSchema, L as getPostUpdateTimestampRange, Ln as ModQueuePageIpfsSchema, Lt as untrackUpdatingComment, M as fetchAndValidateIpnsRecordFromGateway, Mn as CommentUpdateSignedPropertyNames, Mr as literal, Nr as number, Nt as trackStartedCommunity, O as deepMergeRuntimeFields, Or as _enum, Pr as object, Q as isRequestPubsubPublicationOfPost, Qn as CommunityAddressSchema, Qt as CreateCommentModerationOptionsWithRefinementSchema, R as hideClassPrivateProps, Rn as PageIpfsSchema, Rt as untrackUpdatingCommunity, S as calculateIpfsCidV0, Sn as CommentIpfsReservedFields, Sr as PKCError, Tn as CommentPubsubMessageWithFlexibleAuthorRefinementSchema, Tr as require_supports_color, Tt as findUpdatingComment, U as isIpfsPath, Un as CommentEditSignedPropertyNames, V as isAbortError, Vn as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema, Vt as pTimeout, W as isIpns, Wt as CommunityEditPublicationSignedPropertyNames, Xn as CidPathSchema, Xt as CommentModerationSignedPropertyNames, Yn as ChallengeAnswersSchema, Zn as CidStringSchema, Zt as CommentModerationsTableRowSchema, _ as PKCUserOptionBaseSchema, _n as VotePubsubMessagePublicationSchema, _r as FailedToFetchCommentIpfsFromGatewaysError, _t as sleepUntilTimeoutOrAbort, an as CommunityIpfsReservedFields, ar as t$13, b as areEquivalentCommunityAddresses, br as FailedToFetchGenericIpfsFromGatewaysError, bt as timestamp, c as ChallengeVerificationMessageSignedPropertyNames, cn as CreateNewLocalCommunityUserOptionsSchema, cr as t$11, dn as ExportCommunityModLogsOptionsSchema, dr as n$8, dt as resolveWhenPredicateIsTrue, en as ChallengeFileSchema, er as CreateSignerSchema, et as pubsubTopicToDhtKey, f as DecryptedChallengeSchema, fr as r$7, g as PKCParsedOptionsSchema, gn as VoteChallengeRequestToEncryptSchema, gr as require_retry$1, gt as shortifyCid, h as NameResolverSerializedSchema, hn as CreateVoteUserOptionsWithRefinementSchema, hr as e$4, ht as shortifyAddress, i as ChallengeMessageSignedPropertyNames, in as CommunityExportRecordsSchema, j as extractNetworkErrorDetails, jn as CommentUpdateSchema, jr as custom, jt as refreshTrackedCommunityAliases, k as derivePublicationFromChallengeRequest, kn as CommentUpdateForChallengeVerificationSignedPropertyNames, kr as array, kt as listUpdatingCommunities, l as DecryptedChallengeAnswerSchema, ln as CreateRemoteCommunityFunctionArgumentSchema, lr as r$8, m as NameResolveCacheOptionsSchema, mn as isStringDomain, mr as t$9, n as ChallengeAnswerMessageSignedPropertyNames, nn as CommunityChallengeSettingSchema, nt as raceAgainstAbort, o as ChallengeRequestMessageSignedPropertyNames, on as CommunityIpfsSchema, or as e$6, p as DecryptedChallengeVerificationSchema, pn as RpcRemoteCommunityUpdateEventResultSchema, pr as t$10, qn as AuthorCommentIpfsReservedFields, qt as CommentModerationChallengeRequestToEncryptSchema, rn as CommunityEditOptionsSchema, rr as n$9, sn as CommunitySignedPropertyNames, sr as e$5, st as removeNullUndefinedEmptyObjectsValuesRecursively, tr as n$10, un as CreateRpcCommunityFunctionArgumentSchema, ur as t$12, v as PKCUserOptionsSchema, vr as FailedToFetchCommentUpdateFromGatewaysError, wr as logger_default, wt as findStartedCommunity, xn as CommentChallengeRequestToEncryptSchema, xr as FailedToFetchPageIpfsFromGatewaysError, xt as waitForUpdateInCommunityInstanceWithErrorAndTimeout, yn as VoteSignedPropertyNames, yr as FailedToFetchCommunityFromGatewaysError, yt as throwIfAbortSignalAborted, z as interruptibleSleep, zn as CommentEditChallengeRequestToEncryptSchema, zt as require_sha256$1 } from "./schema-DdD_6tTd.js";
3
3
  import { t as all } from "./src-CYIMjhjK.js";
4
4
  import { createHash } from "node:crypto";
5
5
  import { pathToFileURL } from "node:url";
@@ -128211,12 +128211,6 @@ var import_quick_lru = /* @__PURE__ */ __toESM(require_quick_lru(), 1);
128211
128211
  const getTimestampSecondsAgo = (secondsToGoBack) => Math.round(Date.now() / 1e3) - secondsToGoBack;
128212
128212
  const testScore = (excludeScore, authorScore) => excludeScore === void 0 || excludeScore <= (authorScore || 0);
128213
128213
  const testFirstCommentTimestamp = (excludeTime, authorFirstCommentTimestamp) => excludeTime === void 0 || getTimestampSecondsAgo(excludeTime) >= (authorFirstCommentTimestamp || Infinity);
128214
- const testRole = (excludeRole, authorAddress, communityRoles) => {
128215
- if (excludeRole === void 0) return true;
128216
- if (communityRoles === void 0) return false;
128217
- for (const roleName of excludeRole) if (communityRoles[authorAddress]?.role === roleName) return true;
128218
- return false;
128219
- };
128220
128214
  const isVote = (request) => Boolean(request.vote);
128221
128215
  const isReply = (request) => isRequestPubsubPublicationOfReply(request);
128222
128216
  const isPost = (request) => isRequestPubsubPublicationOfPost(request);
@@ -128514,8 +128508,58 @@ const addToRateLimiter = (communityChallenges, request, challengeSuccess) => {
128514
128508
  for (const rateLimiter of Object.values(rateLimiters)) rateLimiter.tryRemoveTokens(1);
128515
128509
  };
128516
128510
  //#endregion
128511
+ //#region dist/node/runtime/node/community/local-community/author-identity.js
128512
+ function createAuthorIdentityMatcher({ community, publication }) {
128513
+ const log = logger_default("pkc-js:local-community:author-identity");
128514
+ const signerAddress = getPKCAddressFromPublicKeySync(publication.signature.publicKey);
128515
+ const wireName = getAuthorNameFromWire(publication.author);
128516
+ let nameResolvesToSignerPromise;
128517
+ const nameResolvesToSigner = () => {
128518
+ if (!wireName || !isStringDomain(wireName)) return Promise.resolve(false);
128519
+ if (!nameResolvesToSignerPromise) nameResolvesToSignerPromise = (async () => {
128520
+ try {
128521
+ const { resolvedAuthorName } = await community._clientsManager.resolveAuthorNameIfNeeded({
128522
+ authorName: wireName,
128523
+ abortSignal: AbortSignal.timeout(community._pkc._timeouts["resolve-author-name"]),
128524
+ cache: { maxAge: 0 }
128525
+ });
128526
+ return resolvedAuthorName === signerAddress;
128527
+ } catch (e) {
128528
+ log("Failed to resolve author name while matching identity, treating as no match", wireName, e);
128529
+ return false;
128530
+ }
128531
+ })();
128532
+ return nameResolvesToSignerPromise;
128533
+ };
128534
+ const matchesIdentity = async (identity) => {
128535
+ if (!isStringDomain(identity)) return identity === signerAddress;
128536
+ if (identity !== wireName) return false;
128537
+ return nameResolvesToSigner();
128538
+ };
128539
+ const matchesAnyIdentity = async (identities) => {
128540
+ let nameListed = false;
128541
+ for (const identity of identities) {
128542
+ if (identity === signerAddress) return true;
128543
+ if (wireName && identity === wireName) nameListed = true;
128544
+ }
128545
+ return nameListed ? nameResolvesToSigner() : false;
128546
+ };
128547
+ return {
128548
+ signerAddress,
128549
+ wireName,
128550
+ matchesIdentity,
128551
+ matchesAnyIdentity
128552
+ };
128553
+ }
128554
+ //#endregion
128517
128555
  //#region dist/node/runtime/node/community/challenges/exclude/exclude.js
128518
- const shouldExcludePublication = (communityChallenge, request, community) => {
128556
+ const testRole = async (excludeRole, getIdentityMatcher, communityRoles) => {
128557
+ if (!communityRoles) return false;
128558
+ const roleKeys = Object.keys(communityRoles).filter((roleKey) => excludeRole.includes(communityRoles[roleKey].role));
128559
+ if (roleKeys.length === 0) return false;
128560
+ return getIdentityMatcher().matchesAnyIdentity(roleKeys);
128561
+ };
128562
+ const shouldExcludePublication = async (communityChallenge, request, community) => {
128519
128563
  if (!communityChallenge) throw Error(`shouldExcludePublication invalid communityChallenge argument '${communityChallenge}'`);
128520
128564
  const publication = derivePublicationFromChallengeRequest(request);
128521
128565
  if (!publication?.author) throw Error(`shouldExcludePublication invalid publication argument '${publication}'`);
@@ -128523,21 +128567,24 @@ const shouldExcludePublication = (communityChallenge, request, community) => {
128523
128567
  if (!communityChallenge.exclude) return false;
128524
128568
  if (!Array.isArray(communityChallenge.exclude)) throw Error(`shouldExcludePublication invalid communityChallenge argument '${communityChallenge}' communityChallenge.exclude not an array`);
128525
128569
  let authorPublicationCounts;
128570
+ let identityMatcher;
128571
+ const getIdentityMatcher = () => identityMatcher ??= createAuthorIdentityMatcher({
128572
+ community,
128573
+ publication
128574
+ });
128526
128575
  for (const exclude of communityChallenge.exclude) {
128527
- if (typeof exclude.postScore !== "number" && typeof exclude.replyScore !== "number" && typeof exclude.postCount !== "number" && typeof exclude.replyCount !== "number" && typeof exclude.firstCommentTimestamp !== "number" && !exclude.address?.length && exclude.publicationType === void 0 && exclude.rateLimit === void 0 && !exclude.role?.length) continue;
128576
+ if (typeof exclude.postScore !== "number" && typeof exclude.replyScore !== "number" && typeof exclude.postCount !== "number" && typeof exclude.replyCount !== "number" && typeof exclude.firstCommentTimestamp !== "number" && !exclude.publicKeys?.length && !exclude.names?.length && exclude.publicationType === void 0 && exclude.rateLimit === void 0 && !exclude.roles?.length) continue;
128528
128577
  let shouldExclude = true;
128529
128578
  if (!testScore(exclude.postScore, author.community?.postScore)) shouldExclude = false;
128530
128579
  if (!testScore(exclude.replyScore, author.community?.replyScore)) shouldExclude = false;
128531
128580
  if (!testFirstCommentTimestamp(exclude.firstCommentTimestamp, author.community?.firstCommentTimestamp)) shouldExclude = false;
128532
128581
  if (!testPublicationType(exclude.publicationType, request)) shouldExclude = false;
128533
128582
  if (!testRateLimit(exclude, request)) shouldExclude = false;
128534
- if (exclude.address && !exclude.address.includes(author.address)) shouldExclude = false;
128535
- if (Array.isArray(exclude.role) && !testRole(exclude.role, publication.author.address, community?.roles)) shouldExclude = false;
128583
+ if (exclude.publicKeys && !exclude.publicKeys.includes(getIdentityMatcher().signerAddress)) shouldExclude = false;
128584
+ if (exclude.names && !await getIdentityMatcher().matchesAnyIdentity(exclude.names)) shouldExclude = false;
128585
+ if (Array.isArray(exclude.roles) && !await testRole(exclude.roles, getIdentityMatcher, community?.roles)) shouldExclude = false;
128536
128586
  if (typeof exclude.postCount === "number" || typeof exclude.replyCount === "number") {
128537
- if (!authorPublicationCounts && community?._dbHandler) {
128538
- const signerAddress = getPKCAddressFromPublicKeySync(publication.signature.publicKey);
128539
- authorPublicationCounts = community._dbHandler.queryAuthorPublicationCounts(signerAddress);
128540
- }
128587
+ if (!authorPublicationCounts && community?._dbHandler) authorPublicationCounts = community._dbHandler.queryAuthorPublicationCounts(getIdentityMatcher().signerAddress);
128541
128588
  if (!testScore(exclude.postCount, authorPublicationCounts?.postCount)) shouldExclude = false;
128542
128589
  if (!testScore(exclude.replyCount, authorPublicationCounts?.replyCount)) shouldExclude = false;
128543
128590
  }
@@ -128582,9 +128629,13 @@ const shouldExcludeChallengeCommentCids = async (communityChallenge, challengeRe
128582
128629
  if (typeof pkc?.getComment !== "function") throw Error(`shouldExcludeChallengeCommentCids invalid pkc argument '${pkc}'`);
128583
128630
  const publication = derivePublicationFromChallengeRequest(challengeRequestMessage);
128584
128631
  const commentCids = challengeRequestMessage.challengeCommentCids;
128585
- const author = publication?.author;
128586
128632
  if (commentCids && !Array.isArray(commentCids)) throw Error(`shouldExcludeChallengeCommentCids invalid commentCids argument '${commentCids}'`);
128587
- if (!author?.address || typeof author?.address !== "string") throw Error(`shouldExcludeChallengeCommentCids invalid challengeRequestMessage.publication.author.address argument '${author?.address}'`);
128633
+ let signerAddress;
128634
+ const getSignerAddress = () => {
128635
+ if (signerAddress) return signerAddress;
128636
+ if (typeof publication?.signature?.publicKey !== "string") throw Error(`shouldExcludeChallengeCommentCids invalid challengeRequestMessage.publication.signature.publicKey argument '${publication?.signature?.publicKey}'`);
128637
+ return signerAddress = getPKCAddressFromPublicKeySync(publication.signature.publicKey);
128638
+ };
128588
128639
  const _getComment = async (commentCid, addressesSet) => {
128589
128640
  let cachedComment = commentCache.get(commentCid);
128590
128641
  let comment;
@@ -128592,12 +128643,12 @@ const shouldExcludeChallengeCommentCids = async (communityChallenge, challengeRe
128592
128643
  comment = await pkc.getComment({ cid: commentCid });
128593
128644
  cachedComment = {
128594
128645
  communityAddress: comment.communityAddress,
128595
- author: { address: comment.author.address }
128646
+ author: { publicKey: comment.author.publicKey }
128596
128647
  };
128597
128648
  commentCache.set(commentCid, cachedComment);
128598
128649
  }
128599
128650
  if (!addressesSet.has(cachedComment.communityAddress)) throw Error(`comment doesn't have matching community address`);
128600
- if (cachedComment?.author?.address !== author.address) throw Error(`comment author address doesn't match publication author address`);
128651
+ if (cachedComment?.author?.publicKey !== getSignerAddress()) throw Error(`comment author signer doesn't match publication signer`);
128601
128652
  let cachedCommentUpdate = commentUpdateCache.get(commentCid);
128602
128653
  if (!cachedCommentUpdate) {
128603
128654
  const commentUpdate = comment || await pkc.createComment({ cid: commentCid });
@@ -128811,13 +128862,13 @@ var UrlsAddressesSet$1 = class {
128811
128862
  this.communities = {};
128812
128863
  setInterval(() => this.refetchAndUpdateAllUrlsSets(), 1e3 * 60 * 5).unref?.();
128813
128864
  }
128814
- async has(address, communityAddress, urlsString) {
128815
- if (!address || !communityAddress || !urlsString) return false;
128865
+ async getAddresses(communityAddress, urlsString) {
128866
+ const addresses = /* @__PURE__ */ new Set();
128867
+ if (!communityAddress || !urlsString) return addresses;
128816
128868
  await this.setUrls(communityAddress, urlsString);
128817
128869
  const community = this.communities[communityAddress];
128818
- const urlsSets = community.urls.map((url) => community.urlsSets[url]).filter(Boolean);
128819
- for (const urlSet of urlsSets) if (urlSet.has(address)) return true;
128820
- return false;
128870
+ for (const url of community.urls) for (const address of community.urlsSets[url] || []) addresses.add(address);
128871
+ return addresses;
128821
128872
  }
128822
128873
  async setUrls(communityAddress, urlsString) {
128823
128874
  let community = this.communities[communityAddress];
@@ -128846,12 +128897,16 @@ var UrlsAddressesSet$1 = class {
128846
128897
  }
128847
128898
  };
128848
128899
  const urlsAddressesSet$1 = new UrlsAddressesSet$1();
128849
- const getChallenge$3 = async ({ challengeSettings, challengeRequestMessage }) => {
128900
+ const getChallenge$3 = async ({ challengeSettings, challengeRequestMessage, community }) => {
128850
128901
  const error = challengeSettings?.options?.error;
128851
128902
  const addresses = challengeSettings?.options?.addresses?.split(",").map((u) => u.trim()).filter(Boolean);
128852
128903
  const addressesSet = new Set(addresses);
128853
128904
  const publication = derivePublicationFromChallengeRequest(challengeRequestMessage);
128854
- if (addressesSet.has(publication?.author?.address) || await urlsAddressesSet$1.has(publication?.author?.address, getCommunityAddressFromRecord(publication), challengeSettings?.options?.urls)) return {
128905
+ const identityMatcher = createAuthorIdentityMatcher({
128906
+ community,
128907
+ publication
128908
+ });
128909
+ if (await identityMatcher.matchesAnyIdentity(addressesSet) || await identityMatcher.matchesAnyIdentity(await urlsAddressesSet$1.getAddresses(getCommunityAddressFromRecord(publication), challengeSettings?.options?.urls))) return {
128855
128910
  success: false,
128856
128911
  error: error || `You're blacklisted.`
128857
128912
  };
@@ -128898,13 +128953,13 @@ var UrlsAddressesSet = class {
128898
128953
  this.communities = {};
128899
128954
  setInterval(() => this.refetchAndUpdateAllUrlsSets(), 1e3 * 60 * 5).unref?.();
128900
128955
  }
128901
- async has(address, communityAddress, urlsString) {
128902
- if (!address || !communityAddress || !urlsString) return false;
128956
+ async getAddresses(communityAddress, urlsString) {
128957
+ const addresses = /* @__PURE__ */ new Set();
128958
+ if (!communityAddress || !urlsString) return addresses;
128903
128959
  await this.setUrls(communityAddress, urlsString);
128904
128960
  const community = this.communities[communityAddress];
128905
- const urlsSets = community.urls.map((url) => community.urlsSets[url]).filter(Boolean);
128906
- for (const urlSet of urlsSets) if (urlSet.has(address)) return true;
128907
- return false;
128961
+ for (const url of community.urls) for (const address of community.urlsSets[url] || []) addresses.add(address);
128962
+ return addresses;
128908
128963
  }
128909
128964
  async setUrls(communityAddress, urlsString) {
128910
128965
  let community = this.communities[communityAddress];
@@ -128933,12 +128988,16 @@ var UrlsAddressesSet = class {
128933
128988
  }
128934
128989
  };
128935
128990
  const urlsAddressesSet = new UrlsAddressesSet();
128936
- const getChallenge$2 = async ({ challengeSettings, challengeRequestMessage }) => {
128991
+ const getChallenge$2 = async ({ challengeSettings, challengeRequestMessage, community }) => {
128937
128992
  const error = challengeSettings?.options?.error;
128938
128993
  const addresses = challengeSettings?.options?.addresses?.split(",").map((u) => u.trim()).filter(Boolean);
128939
128994
  const addressesSet = new Set(addresses);
128940
128995
  const publication = derivePublicationFromChallengeRequest(challengeRequestMessage);
128941
- if (!addressesSet.has(publication?.author?.address) && !await urlsAddressesSet.has(publication?.author?.address, getCommunityAddressFromRecord(publication), challengeSettings?.options?.urls)) return {
128996
+ const identityMatcher = createAuthorIdentityMatcher({
128997
+ community,
128998
+ publication
128999
+ });
129000
+ if (!(await identityMatcher.matchesAnyIdentity(addressesSet) || await identityMatcher.matchesAnyIdentity(await urlsAddressesSet.getAddresses(getCommunityAddressFromRecord(publication), challengeSettings?.options?.urls)))) return {
128942
129001
  success: false,
128943
129002
  error: error || `You're not whitelisted.`
128944
129003
  };
@@ -129370,7 +129429,7 @@ const getPendingChallengesOrChallengeVerification = async ({ challengeRequestMes
129370
129429
  community
129371
129430
  })).challengeFile));
129372
129431
  await Promise.all(communityChallenges.map(async (communityChallenge, i) => {
129373
- if (shouldExcludePublication(communityChallenge, challengeRequestMessage, community)) {
129432
+ if (await shouldExcludePublication(communityChallenge, challengeRequestMessage, community)) {
129374
129433
  decided[i] = true;
129375
129434
  return;
129376
129435
  }
@@ -130330,4 +130389,4 @@ var RpcLocalCommunity = class extends RpcRemoteCommunity {
130330
130389
  }
130331
130390
  };
130332
130391
  //#endregion
130333
- export { RepliesPages as $, RpcUnsubscribeParamSchema as $n, getPublicKeyFromPrivateKey as $t, deriveDbPosts as A, parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails as An, verifyCommentIpfs as At, setNativeFunctions as B, RpcEditCommunityParamSchema as Bn, getAuthorNameFromWire as Bt, BackupAbortError as C, parseDecryptedChallengeAnswerWithPKCErrorIfItFails as Cn, signCommunityEdit as Ct, createKuboRpcClient as D, parsePKCUserOptionsSchemaWithPKCErrorIfItFails as Dn, verifyChallengeRequest as Dt, calculateInlineRepliesBudget as E, parseJsonWithPKCErrorIfFails as En, verifyChallengeMessage as Et, importSignerIntoKuboNode as F, RpcCancelExportParamSchema as Fn, verifyCommunityEdit as Ft, REPLY_REPLIES_SORT_TYPES as G, RpcFetchCidParamSchema as Gn, getCommunityPublicKeyFromWire as Gt, CommentClientsManager as H, RpcExportCommunityModLogsResultSchema as Hn, buildRuntimeCommunityFields as Ht, listCommunitiesSync as I, RpcCidParamSchema as In, verifyVote as It, buildPagesRuntimeFields as J, RpcPublishChallengeAnswersParamSchema as Jn, encode as Jt, TIMEFRAMES_TO_SECONDS as K, RpcFetchCidResultSchema as Kn, normalizeCommunityInputFromCommunity as Kt, monitorCommunitiesDirectory as L, RpcCommentRepliesPageParamSchema as Ln, buildRuntimeAuthor as Lt, getDefaultCommunityDbConfig as M, parseVotePubsubMessagePublicationSchemaWithPKCErrorIfItFails as Mn, verifyCommentPubsubMessage as Mt, getDefaultDataPath as N, RpcAnchorPublishPreparationResultSchema as Nn, verifyCommentUpdate as Nt, deleteOldCommunityInWindows as O, parseRpcCommentEventWithPKCErrorIfItFails as On, verifyChallengeVerification as Ot, getThumbnailPropsOfLink as P, RpcAuthorNameParamSchema as Pn, verifyCommunity as Pt, parseRawPages as Q, RpcSuccessResultSchema as Qn, getPKCAddressFromPublicKeySync as Qt, moveCommunityDbToDeletedDirectory as R, RpcCommunityIdentifierParamSchema as Rn, cleanWireAuthor as Rt, encryptEd25519AesGcmPublicKeyBuffer as S, parseCreateVoteOptionsSchemaWithPKCErrorIfItFails as Sn, signCommunity as St, calculateExpectedSignatureSize as T, parseDecryptedChallengeWithPKCErrorIfItFails as Tn, verifyChallengeAnswer as Tt, POSTS_SORT_TYPES as U, RpcExportCommunityParamSchema as Un, getCommunityAddressFromRecord as Ut, tryToDeleteCommunitiesThatFailedToBeDeletedBefore as V, RpcExportCommunityModLogsParamSchema as Vn, normalizeCreatePublicationAuthor as Vt, POST_REPLIES_SORT_TYPES as W, RpcExportCommunityResultSchema as Wn, getCommunityNameFromWire$1 as Wt, findCommentInPageInstanceRecursively as X, RpcResolveAuthorNameResultSchema as Xn, getIpfsKeyFromPrivateKey as Xt, extractCommunityRuntimeFieldsFromParsedPages as Y, RpcPublishedAnchorRecordResultSchema as Yn, getBufferedPKCAddressFromPublicKey as Yt, iterateOverPageCidsToFindAllCids as Z, RpcSubscriptionIdResultSchema as Zn, getPKCAddressFromPublicKey as Zt, createSigner as _, parseCreateCommunityEditPublicationOptionsSchemaWithPKCErrorIfItFails as _n, signComment as _t, loadChallengeFileFromCommunityChallengeSettings as a, parseCommentIpfsSchemaWithPKCErrorIfItFails as an, t$5 as ar, PublicationClientsManager as at, decryptEd25519AesGcmPublicKeyBuffer as b, parseCreateRemoteCommunityFunctionArgumentSchemaWithPKCErrorIfItFails as bn, signCommentUpdate as bt, LRUCache as c, parseCommentPubsubMessagePublicationWithPKCErrorIfItFails as cn, t$7 as cr, pRetry as ct, KeyvBetterSqlite3 as d, parseCommunityEditOptionsSchemaWithPKCErrorIfItFails as dn, STORAGE_KEYS as dr, require_lib$1 as dt, createSchemaRowParser as en, crosspostChainDepthUpTo as er, applyNameResolvedCacheToCrosspost as et, decodeRpcChallengeAnswerPubsubMsg as f, parseCommunityEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails as fn, require_lodash_merge as fr, cleanUpBeforePublishing as ft, SignerWithPublicKeyAddress as g, parseCreateCommentOptionsSchemaWithPKCErrorIfItFails as gn, signChallengeVerification as gt, decodeRpcChallengeVerificationPubsubMsg as h, parseCreateCommentModerationOptionsSchemaWithPKCErrorIfItFails as hn, signChallengeRequest as ht, getCommunityChallengeFromCommunityChallengeSettings as i, parseCommentEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails as in, r as ir, stripNameResolvedFromCrosspost as it, deriveDbReplies as j, parseVoteChallengeRequestToEncryptSchemaWithPKCErrorIfItFails as jn, verifyCommentModeration as jt, deriveCommentIpfsFromCommentTableRow as k, parseRpcCommentUpdateEventWithPKCErrorIfItFails as kn, verifyCommentEdit as kt, RemoteCommunity as l, parseCommunityAddressWithPKCErrorIfItFails as ln, t$8 as lr, pLimit as lt, decodeRpcChallengeRequestPubsubMsg as m, parseCreateCommentEditOptionsSchemaWithPKCErrorIfItFails as mn, require_undici as mr, signChallengeMessage as mt, RpcRemoteCommunity as n, parseCommentChallengeRequestToEncryptSchemaWithPKCErrorIfItFails as nn, t$2 as nr, collectCrosspostAuthorsToResolve as nt, pkcJsChallenges as o, parseCommentModerationChallengeRequestToEncryptSchemaWithPKCErrorIfItFails as on, n$5 as or, PKCClientsManager as ot, decodeRpcChallengePubsubMsg as p, parseCommunityIpfsSchemaPassthroughWithPKCErrorIfItFails as pn, nativeFunctions$1 as pr, signChallengeAnswer as pt, buildPageRuntimeFields as q, RpcPublishAnchorRecordParamSchema as qn, decode as qt, getChallengeVerification as r, parseCommentEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails as rn, t$4 as rr, extractCrosspostRuntimeFields as rt, TrackedInstanceRegistry as s, parseCommentModerationPubsubMessagePublicationSchemaWithPKCErrorIfItFails as sn, n$6 as sr, InflightFetchManager as st, RpcLocalCommunity as t, parseCidStringSchemaWithPKCErrorIfItFails as tn, effectiveMaxCrosspostDepth as tr, cloneCrosspostForRuntime as tt, MAX_FILE_SIZE_BYTES_FOR_COMMUNITY_IPFS as u, parseCommunityEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails as un, stringify as ur, PKCTypedEmitter as ut, createAnchorIpnsRecord as v, parseCreateNewLocalCommunityUserOptionsSchemaWithPKCErrorIfItFails as vn, signCommentEdit as vt, backupCommunityDb as w, parseDecryptedChallengeVerification as wn, signVote as wt, encryptEd25519AesGcm as x, parseCreateRpcCommunityFunctionArgumentSchemaWithPKCErrorIfItFails as xn, signCommentUpdateForChallengeVerification as xt, decryptEd25519AesGcm as y, parseCreatePKCWsServerOptionsSchemaWithPKCErrorIfItFails as yn, signCommentModeration as yt, resolveDbPostsCidRefs as z, RpcCommunityPageParamSchema as zn, getAuthorNameFromRuntime as zt };
130392
+ export { parseRawPages as $, RpcSuccessResultSchema as $n, getPKCAddressFromPublicKeySync as $t, deriveCommentIpfsFromCommentTableRow as A, parseRpcCommentUpdateEventWithPKCErrorIfItFails as An, verifyCommentEdit as At, resolveDbPostsCidRefs as B, RpcCommunityPageParamSchema as Bn, getAuthorNameFromRuntime as Bt, encryptEd25519AesGcmPublicKeyBuffer as C, parseCreateVoteOptionsSchemaWithPKCErrorIfItFails as Cn, signCommunity as Ct, calculateInlineRepliesBudget as D, parseJsonWithPKCErrorIfFails as Dn, verifyChallengeMessage as Dt, calculateExpectedSignatureSize as E, parseDecryptedChallengeWithPKCErrorIfItFails as En, verifyChallengeAnswer as Et, getThumbnailPropsOfLink as F, RpcAuthorNameParamSchema as Fn, verifyCommunity as Ft, POST_REPLIES_SORT_TYPES as G, RpcExportCommunityResultSchema as Gn, getCommunityNameFromWire$1 as Gt, tryToDeleteCommunitiesThatFailedToBeDeletedBefore as H, RpcExportCommunityModLogsParamSchema as Hn, normalizeCreatePublicationAuthor as Ht, importSignerIntoKuboNode as I, RpcCancelExportParamSchema as In, verifyCommunityEdit as It, buildPageRuntimeFields as J, RpcPublishAnchorRecordParamSchema as Jn, decode as Jt, REPLY_REPLIES_SORT_TYPES as K, RpcFetchCidParamSchema as Kn, getCommunityPublicKeyFromWire as Kt, listCommunitiesSync as L, RpcCidParamSchema as Ln, verifyVote as Lt, deriveDbReplies as M, parseVoteChallengeRequestToEncryptSchemaWithPKCErrorIfItFails as Mn, verifyCommentModeration as Mt, getDefaultCommunityDbConfig as N, parseVotePubsubMessagePublicationSchemaWithPKCErrorIfItFails as Nn, verifyCommentPubsubMessage as Nt, createKuboRpcClient as O, parsePKCUserOptionsSchemaWithPKCErrorIfItFails as On, verifyChallengeRequest as Ot, getDefaultDataPath as P, RpcAnchorPublishPreparationResultSchema as Pn, verifyCommentUpdate as Pt, iterateOverPageCidsToFindAllCids as Q, RpcSubscriptionIdResultSchema as Qn, getPKCAddressFromPublicKey as Qt, monitorCommunitiesDirectory as R, RpcCommentRepliesPageParamSchema as Rn, buildRuntimeAuthor as Rt, encryptEd25519AesGcm as S, parseCreateRpcCommunityFunctionArgumentSchemaWithPKCErrorIfItFails as Sn, signCommentUpdateForChallengeVerification as St, backupCommunityDb as T, parseDecryptedChallengeVerification as Tn, signVote as Tt, CommentClientsManager as U, RpcExportCommunityModLogsResultSchema as Un, buildRuntimeCommunityFields as Ut, setNativeFunctions as V, RpcEditCommunityParamSchema as Vn, getAuthorNameFromWire as Vt, POSTS_SORT_TYPES as W, RpcExportCommunityParamSchema as Wn, getCommunityAddressFromRecord as Wt, extractCommunityRuntimeFieldsFromParsedPages as X, RpcPublishedAnchorRecordResultSchema as Xn, getBufferedPKCAddressFromPublicKey as Xt, buildPagesRuntimeFields as Y, RpcPublishChallengeAnswersParamSchema as Yn, encode as Yt, findCommentInPageInstanceRecursively as Z, RpcResolveAuthorNameResultSchema as Zn, getIpfsKeyFromPrivateKey as Zt, SignerWithPublicKeyAddress as _, parseCreateCommentOptionsSchemaWithPKCErrorIfItFails as _n, signChallengeVerification as _t, loadChallengeFileFromCommunityChallengeSettings as a, parseCommentEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails as an, r as ar, stripNameResolvedFromCrosspost as at, decryptEd25519AesGcm as b, parseCreatePKCWsServerOptionsSchemaWithPKCErrorIfItFails as bn, signCommentModeration as bt, TrackedInstanceRegistry as c, parseCommentModerationPubsubMessagePublicationSchemaWithPKCErrorIfItFails as cn, n$6 as cr, InflightFetchManager as ct, MAX_FILE_SIZE_BYTES_FOR_COMMUNITY_IPFS as d, parseCommunityEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails as dn, stringify as dr, PKCTypedEmitter as dt, getPublicKeyFromPrivateKey as en, RpcUnsubscribeParamSchema as er, RepliesPages as et, KeyvBetterSqlite3 as f, parseCommunityEditOptionsSchemaWithPKCErrorIfItFails as fn, STORAGE_KEYS as fr, require_lib$1 as ft, decodeRpcChallengeVerificationPubsubMsg as g, parseCreateCommentModerationOptionsSchemaWithPKCErrorIfItFails as gn, signChallengeRequest as gt, decodeRpcChallengeRequestPubsubMsg as h, parseCreateCommentEditOptionsSchemaWithPKCErrorIfItFails as hn, require_undici as hr, signChallengeMessage as ht, getCommunityChallengeFromCommunityChallengeSettings as i, parseCommentEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails as in, t$4 as ir, extractCrosspostRuntimeFields as it, deriveDbPosts as j, parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails as jn, verifyCommentIpfs as jt, deleteOldCommunityInWindows as k, parseRpcCommentEventWithPKCErrorIfItFails as kn, verifyChallengeVerification as kt, LRUCache as l, parseCommentPubsubMessagePublicationWithPKCErrorIfItFails as ln, t$7 as lr, pRetry as lt, decodeRpcChallengePubsubMsg as m, parseCommunityIpfsSchemaPassthroughWithPKCErrorIfItFails as mn, nativeFunctions$1 as mr, signChallengeAnswer as mt, RpcRemoteCommunity as n, parseCidStringSchemaWithPKCErrorIfItFails as nn, effectiveMaxCrosspostDepth as nr, cloneCrosspostForRuntime as nt, pkcJsChallenges as o, parseCommentIpfsSchemaWithPKCErrorIfItFails as on, t$5 as or, PublicationClientsManager as ot, decodeRpcChallengeAnswerPubsubMsg as p, parseCommunityEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails as pn, require_lodash_merge as pr, cleanUpBeforePublishing as pt, TIMEFRAMES_TO_SECONDS as q, RpcFetchCidResultSchema as qn, normalizeCommunityInputFromCommunity as qt, getChallengeVerification as r, parseCommentChallengeRequestToEncryptSchemaWithPKCErrorIfItFails as rn, t$2 as rr, collectCrosspostAuthorsToResolve as rt, createAuthorIdentityMatcher as s, parseCommentModerationChallengeRequestToEncryptSchemaWithPKCErrorIfItFails as sn, n$5 as sr, PKCClientsManager as st, RpcLocalCommunity as t, createSchemaRowParser as tn, crosspostChainDepthUpTo as tr, applyNameResolvedCacheToCrosspost as tt, RemoteCommunity as u, parseCommunityAddressWithPKCErrorIfItFails as un, t$8 as ur, pLimit as ut, createSigner as v, parseCreateCommunityEditPublicationOptionsSchemaWithPKCErrorIfItFails as vn, signComment as vt, BackupAbortError as w, parseDecryptedChallengeAnswerWithPKCErrorIfItFails as wn, signCommunityEdit as wt, decryptEd25519AesGcmPublicKeyBuffer as x, parseCreateRemoteCommunityFunctionArgumentSchemaWithPKCErrorIfItFails as xn, signCommentUpdate as xt, createAnchorIpnsRecord as y, parseCreateNewLocalCommunityUserOptionsSchemaWithPKCErrorIfItFails as yn, signCommentEdit as yt, moveCommunityDbToDeletedDirectory as z, RpcCommunityIdentifierParamSchema as zn, cleanWireAuthor as zt };