@pkcprotocol/pkc-js 0.0.84 → 0.0.85

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 (113) hide show
  1. package/dist/browser/clients/rpc-client/rpc-schema-util.d.ts +1 -0
  2. package/dist/browser/clients/rpc-client/schema.d.ts +1 -0
  3. package/dist/browser/community/schema.d.ts +106 -2
  4. package/dist/browser/community/schema.js +25 -6
  5. package/dist/browser/community/schema.js.map +1 -1
  6. package/dist/browser/errors.d.ts +6 -1
  7. package/dist/browser/errors.js +8 -0
  8. package/dist/browser/errors.js.map +1 -1
  9. package/dist/browser/generated-version.d.ts +1 -1
  10. package/dist/browser/generated-version.js +1 -1
  11. package/dist/browser/index-with-compile-cache.d.ts +88 -2
  12. package/dist/browser/index.d.ts +88 -2
  13. package/dist/browser/pkc-error.d.ts +1 -1
  14. package/dist/browser/publications/community-edit/schema.d.ts +4 -0
  15. package/dist/browser/pubsub-messages/schema.d.ts +2 -0
  16. package/dist/browser/rpc/src/index.js +4 -1
  17. package/dist/browser/rpc/src/index.js.map +1 -1
  18. package/dist/browser/rpc/src/lib/pkc-js/index.d.ts +44 -1
  19. package/dist/browser/rpc/src/schema.d.ts +265 -7
  20. package/dist/browser/rpc/src/schema.js +4 -2
  21. package/dist/browser/rpc/src/schema.js.map +1 -1
  22. package/dist/browser/runtime/node/community/challenges/exclude/exclude.d.ts +2 -2
  23. package/dist/browser/runtime/node/community/challenges/exclude/exclude.js +5 -1
  24. package/dist/browser/runtime/node/community/challenges/exclude/exclude.js.map +1 -1
  25. package/dist/browser/runtime/node/community/challenges/index.d.ts +7 -3
  26. package/dist/browser/runtime/node/community/challenges/index.js +29 -6
  27. package/dist/browser/runtime/node/community/challenges/index.js.map +1 -1
  28. package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/address-list-validation.d.ts +4 -0
  29. package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/address-list-validation.js +27 -0
  30. package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/address-list-validation.js.map +1 -0
  31. package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/blacklist.js +2 -1
  32. package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/blacklist.js.map +1 -1
  33. package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/publication-match.js +34 -1
  34. package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/publication-match.js.map +1 -1
  35. package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/question.js +8 -1
  36. package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/question.js.map +1 -1
  37. package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/whitelist.js +2 -1
  38. package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/whitelist.js.map +1 -1
  39. package/dist/browser/runtime/node/community/challenges/validate-challenge-settings.d.ts +22 -0
  40. package/dist/browser/runtime/node/community/challenges/validate-challenge-settings.js +92 -0
  41. package/dist/browser/runtime/node/community/challenges/validate-challenge-settings.js.map +1 -0
  42. package/dist/browser/runtime/node/community/db-handler.d.ts +1 -0
  43. package/dist/browser/runtime/node/community/local-community/db-state.js +8 -0
  44. package/dist/browser/runtime/node/community/local-community/db-state.js.map +1 -1
  45. package/dist/browser/runtime/node/community/local-community/editing.js +8 -0
  46. package/dist/browser/runtime/node/community/local-community/editing.js.map +1 -1
  47. package/dist/browser/runtime/node/community/local-community/lifecycle.js +29 -0
  48. package/dist/browser/runtime/node/community/local-community/lifecycle.js.map +1 -1
  49. package/dist/browser/schema/schema-util.d.ts +9 -0
  50. package/dist/browser/schema.d.ts +352 -8
  51. package/dist/browser/test/test-util.d.ts +2 -0
  52. package/dist/bundled/bundle-manifest.json +33 -31
  53. package/dist/bundled/chunks/{helia-for-pkc-BlDudTLN.js → helia-for-pkc-C5Oe_ZSx.js} +33 -33
  54. package/dist/bundled/chunks/{local-community-5PMI-TDB.js → local-community-BqxmCg5p.js} +131 -26
  55. package/dist/bundled/chunks/{local-community-4wIeaqty.js → local-community-D4SjlAKS.js} +1 -1
  56. package/dist/bundled/chunks/{node-B7GkmuSc.js → node-C2DKW30L.js} +5 -5
  57. package/dist/bundled/chunks/{rpc-local-community-r51cTBYd.js → rpc-local-community-o0teUvw_.js} +76 -10
  58. package/dist/bundled/chunks/{schema-AXrL86Q4.js → schema-qhSDu1BU.js} +48 -5
  59. package/dist/bundled/chunks/{util-CwzCEPKs.js → util-BVGNNIgn.js} +1 -1
  60. package/dist/bundled/index.js +1 -1
  61. package/dist/bundled/rpc/src/index.js +5 -5
  62. package/dist/node/clients/rpc-client/rpc-schema-util.d.ts +1 -0
  63. package/dist/node/clients/rpc-client/schema.d.ts +1 -0
  64. package/dist/node/community/schema.d.ts +106 -2
  65. package/dist/node/community/schema.js +25 -6
  66. package/dist/node/community/schema.js.map +1 -1
  67. package/dist/node/errors.d.ts +6 -1
  68. package/dist/node/errors.js +8 -0
  69. package/dist/node/errors.js.map +1 -1
  70. package/dist/node/generated-version.d.ts +1 -1
  71. package/dist/node/generated-version.js +1 -1
  72. package/dist/node/index-with-compile-cache.d.ts +88 -2
  73. package/dist/node/index.d.ts +88 -2
  74. package/dist/node/pkc-error.d.ts +1 -1
  75. package/dist/node/publications/community-edit/schema.d.ts +4 -0
  76. package/dist/node/pubsub-messages/schema.d.ts +2 -0
  77. package/dist/node/rpc/src/index.js +4 -1
  78. package/dist/node/rpc/src/index.js.map +1 -1
  79. package/dist/node/rpc/src/lib/pkc-js/index.d.ts +44 -1
  80. package/dist/node/rpc/src/schema.d.ts +265 -7
  81. package/dist/node/rpc/src/schema.js +4 -2
  82. package/dist/node/rpc/src/schema.js.map +1 -1
  83. package/dist/node/runtime/node/community/challenges/exclude/exclude.d.ts +2 -2
  84. package/dist/node/runtime/node/community/challenges/exclude/exclude.js +5 -1
  85. package/dist/node/runtime/node/community/challenges/exclude/exclude.js.map +1 -1
  86. package/dist/node/runtime/node/community/challenges/index.d.ts +7 -3
  87. package/dist/node/runtime/node/community/challenges/index.js +29 -6
  88. package/dist/node/runtime/node/community/challenges/index.js.map +1 -1
  89. package/dist/node/runtime/node/community/challenges/pkc-js-challenges/address-list-validation.d.ts +4 -0
  90. package/dist/node/runtime/node/community/challenges/pkc-js-challenges/address-list-validation.js +27 -0
  91. package/dist/node/runtime/node/community/challenges/pkc-js-challenges/address-list-validation.js.map +1 -0
  92. package/dist/node/runtime/node/community/challenges/pkc-js-challenges/blacklist.js +2 -1
  93. package/dist/node/runtime/node/community/challenges/pkc-js-challenges/blacklist.js.map +1 -1
  94. package/dist/node/runtime/node/community/challenges/pkc-js-challenges/publication-match.js +34 -1
  95. package/dist/node/runtime/node/community/challenges/pkc-js-challenges/publication-match.js.map +1 -1
  96. package/dist/node/runtime/node/community/challenges/pkc-js-challenges/question.js +8 -1
  97. package/dist/node/runtime/node/community/challenges/pkc-js-challenges/question.js.map +1 -1
  98. package/dist/node/runtime/node/community/challenges/pkc-js-challenges/whitelist.js +2 -1
  99. package/dist/node/runtime/node/community/challenges/pkc-js-challenges/whitelist.js.map +1 -1
  100. package/dist/node/runtime/node/community/challenges/validate-challenge-settings.d.ts +22 -0
  101. package/dist/node/runtime/node/community/challenges/validate-challenge-settings.js +92 -0
  102. package/dist/node/runtime/node/community/challenges/validate-challenge-settings.js.map +1 -0
  103. package/dist/node/runtime/node/community/db-handler.d.ts +1 -0
  104. package/dist/node/runtime/node/community/local-community/db-state.js +8 -0
  105. package/dist/node/runtime/node/community/local-community/db-state.js.map +1 -1
  106. package/dist/node/runtime/node/community/local-community/editing.js +8 -0
  107. package/dist/node/runtime/node/community/local-community/editing.js.map +1 -1
  108. package/dist/node/runtime/node/community/local-community/lifecycle.js +29 -0
  109. package/dist/node/runtime/node/community/local-community/lifecycle.js.map +1 -1
  110. package/dist/node/schema/schema-util.d.ts +9 -0
  111. package/dist/node/schema.d.ts +352 -8
  112. package/dist/node/test/test-util.d.ts +2 -0
  113. package/package.json +3 -3
@@ -1,12 +1,12 @@
1
1
  import { i as __toESM, r as __require, t as __commonJSMin } from "./chunk-2rV9d50f.js";
2
- import { $ as pubsubTopicToDhtKey, $n as n$4, Bn as CommentEditReservedFields, C as contentContainsMarkdownAudio, Ct as findStartedCommunity, F as getIpnsRecordInLocalKuboNode, Fr as ZodError, Ft as untrackStartedCommunity, G as isLinkOfAudio, Hn as CommentEditsTableRowSchema, Ht as CommunityEditPublicationPubsubReservedFields, J as isLinkOfVideo, Jt as CommentModerationReservedFields, K as isLinkOfImage, Kn as AuthorReservedFields, L as hideClassPrivateProps, Lt as untrackUpdatingCommunity, M as genToArray, Mn as CommentsTableRowSchema, Mt as trackStartedCommunity, N as getEquivalentCommunityAddresses, O as derivePublicationFromChallengeRequest, P as getErrorCodeFromMessage, Pt as trackUpdatingCommunity, Q as isStringDomain, R as ipnsNameToIpnsOverPubsubTopic, Rn as CommentEditPubsubMessagePublicationSchema, Rt as require_sha256, S as calculateStringSizeSameAsIpfsAddCidV0, Sn as CommentPubsubMessageReservedFields, Sr as logger_default, St as findCommunityInRegistry, T as contentContainsMarkdownVideos, Tt as findUpdatingCommunity, W as isLinkOfAnimatedImage, Xt as CommentModerationsTableRowSchema, Y as isLinkValid, _t as statMfsPathSafely, a as ChallengeRequestMessageSchema, an as CommunityIpfsSchema, ar as e$1, at as removeMfsFilesSafely, b as areEquivalentCommunityAddresses, br as PKCError, cr as t$4, d as DecryptedChallengeRequestSchema, dr as t$5, dt as retryKuboBlockPutPinAndProvidePubsubTopic, er as t$8, fr as t$3, gn as VotePubsubReservedFields, gt as sleepUntilTimeoutOrAbort, hn as VotePubsubMessagePublicationSchema, ir as e, it as removeBlocksFromKuboNode, jn as CommentUpdateTableRowSchema, jt as syncCommunityRegistryEntry, k as doesDomainAddressHaveCapitalLetter, kn as CommentUpdateSchema, mr as require_retry, nr as t$7, on as CommunitySignedPropertyNames, pt as retryKuboIpfsAddAndProvide, q as isLinkOfMedia, qt as CommentModerationPubsubMessagePublicationSchema, r as ChallengeMessageSchema, rr as t$6, s as ChallengeVerificationMessageSchema, sr as r$1, st as removeNullUndefinedValues, t as ChallengeAnswerMessageSchema, tr as n$3, u as DecryptedChallengeRequestPublicationSchema, vn as VoteTablesRowSchema, w as contentContainsMarkdownImages, x as calculateIpfsCidV0, xn as CommentIpfsSchema, xr as messages, xt as writeKuboFilesWithTimeout, y as version_default, yt as timestamp, zn as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema } from "./schema-AXrL86Q4.js";
3
- import { $n as crosspostChainDepthUpTo, $t as createSchemaRowParser, A as deriveDbReplies, At as verifyCommentModeration, C as backupCommunityDb, D as deleteOldCommunityInWindows, Et as verifyChallengeRequest, Ft as verifyVote, G as TIMEFRAMES_TO_SECONDS, H as POSTS_SORT_TYPES, It as buildRuntimeAuthor, Kt as decode, L as moveCommunityDbToDeletedDirectory, Lt as cleanWireAuthor, Mt as verifyCommentUpdate, N as getThumbnailPropsOfLink, Nt as verifyCommunity, O as deriveCommentIpfsFromCommentTableRow, Ot as verifyCommentEdit, P as importSignerIntoKuboNode, Pt as verifyCommunityEdit, Qt as getPublicKeyFromPrivateKey, R as resolveDbPostsCidRefs, S as BackupAbortError, Sn as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, T as calculateInlineRepliesBudget, Tn as parseJsonWithPKCErrorIfFails, U as POST_REPLIES_SORT_TYPES, Ut as getCommunityNameFromWire, W as REPLY_REPLIES_SORT_TYPES, Wt as getCommunityPublicKeyFromWire, X as iterateOverPageCidsToFindAllCids, Xt as getPKCAddressFromPublicKey, Yt as getIpfsKeyFromPrivateKey, Zt as getPKCAddressFromPublicKeySync, _t as signCommentEdit, a as pkcJsChallenges, ar as n$6, bt as signCommentUpdateForChallengeVerification, cr as t$10, ct as pLimit, dr as require_lodash_merge, dt as cleanUpBeforePublishing, er as effectiveMaxCrosspostDepth, fn as parseCommunityIpfsSchemaPassthroughWithPKCErrorIfItFails, gt as signComment, h as SignerWithPublicKeyAddress, ht as signChallengeVerification, i as getCommunityChallengeFromCommunityChallengeSettings, ir as t$11, j as getDefaultCommunityDbConfig, jt as verifyCommentPubsubMessage, k as deriveDbPosts, kt as verifyCommentIpfs, l as MAX_FILE_SIZE_BYTES_FOR_COMMUNITY_IPFS, lr as stringify, nr as t$12, o as TrackedInstanceRegistry, or as n$5, pt as signChallengeMessage, qt as encode, r as getChallengeVerification, rr as r$2, s as LRUCache, t as RpcLocalCommunity, tr as t$9, u as KeyvBetterSqlite3, un as parseCommunityEditOptionsSchemaWithPKCErrorIfItFails, ur as STORAGE_KEYS, w as calculateExpectedSignatureSize, wt as verifyChallengeAnswer, x as encryptEd25519AesGcmPublicKeyBuffer, xt as signCommunity, y as decryptEd25519AesGcmPublicKeyBuffer, yt as signCommentUpdate, zt as getAuthorNameFromWire } from "./rpc-local-community-r51cTBYd.js";
2
+ import { $ as pubsubTopicToDhtKey, $n as n$4, Bn as CommentEditReservedFields, C as contentContainsMarkdownAudio, Ct as findStartedCommunity, F as getIpnsRecordInLocalKuboNode, Fr as ZodError, Ft as untrackStartedCommunity, G as isLinkOfAudio, Hn as CommentEditsTableRowSchema, Ht as CommunityEditPublicationPubsubReservedFields, J as isLinkOfVideo, Jt as CommentModerationReservedFields, K as isLinkOfImage, Kn as AuthorReservedFields, L as hideClassPrivateProps, Lt as untrackUpdatingCommunity, M as genToArray, Mn as CommentsTableRowSchema, Mt as trackStartedCommunity, N as getEquivalentCommunityAddresses, O as derivePublicationFromChallengeRequest, P as getErrorCodeFromMessage, Pt as trackUpdatingCommunity, Q as isStringDomain, R as ipnsNameToIpnsOverPubsubTopic, Rn as CommentEditPubsubMessagePublicationSchema, Rt as require_sha256, S as calculateStringSizeSameAsIpfsAddCidV0, Sn as CommentPubsubMessageReservedFields, Sr as logger_default, St as findCommunityInRegistry, T as contentContainsMarkdownVideos, Tt as findUpdatingCommunity, W as isLinkOfAnimatedImage, Xt as CommentModerationsTableRowSchema, Y as isLinkValid, _t as statMfsPathSafely, a as ChallengeRequestMessageSchema, an as CommunityIpfsSchema, ar as e$1, at as removeMfsFilesSafely, b as areEquivalentCommunityAddresses, br as PKCError, cr as t$4, d as DecryptedChallengeRequestSchema, dr as t$5, dt as retryKuboBlockPutPinAndProvidePubsubTopic, er as t$8, fr as t$3, gn as VotePubsubReservedFields, gt as sleepUntilTimeoutOrAbort, hn as VotePubsubMessagePublicationSchema, ir as e, it as removeBlocksFromKuboNode, jn as CommentUpdateTableRowSchema, jt as syncCommunityRegistryEntry, k as doesDomainAddressHaveCapitalLetter, kn as CommentUpdateSchema, mr as require_retry, nr as t$7, on as CommunitySignedPropertyNames, pt as retryKuboIpfsAddAndProvide, q as isLinkOfMedia, qt as CommentModerationPubsubMessagePublicationSchema, r as ChallengeMessageSchema, rr as t$6, s as ChallengeVerificationMessageSchema, sr as r$1, st as removeNullUndefinedValues, t as ChallengeAnswerMessageSchema, tr as n$3, u as DecryptedChallengeRequestPublicationSchema, vn as VoteTablesRowSchema, w as contentContainsMarkdownImages, x as calculateIpfsCidV0, xn as CommentIpfsSchema, xr as messages, xt as writeKuboFilesWithTimeout, y as version_default, yt as timestamp, zn as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema } from "./schema-qhSDu1BU.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-o0teUvw_.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$1 from "path";
9
+ import path from "path";
10
10
  import assert from "assert";
11
11
  import fs from "fs";
12
12
  import Database from "better-sqlite3";
@@ -1739,6 +1739,77 @@ async function storePublication(community, request, pendingApproval, challengeAg
1739
1739
  else throw Error("Don't know how to store this publication" + request);
1740
1740
  }
1741
1741
  //#endregion
1742
+ //#region dist/node/runtime/node/community/challenges/validate-challenge-settings.js
1743
+ const describeChallenge = (communityChallengeSettings) => communityChallengeSettings.name || communityChallengeSettings.path || "unknown challenge";
1744
+ const isOptionSet = (value) => value !== void 0 && value !== null;
1745
+ function validateChallengeSettingsAgainstChallengeFile({ challengeSettings, challengeFile, challengeIndex }) {
1746
+ const baseDetails = {
1747
+ challengeIndex,
1748
+ challengeName: describeChallenge(challengeSettings)
1749
+ };
1750
+ const { optionInputs } = challengeFile;
1751
+ if (optionInputs) {
1752
+ const declaredOptions = new Set(optionInputs.map((optionInput) => optionInput.option));
1753
+ for (const optionName of Object.keys(challengeSettings.options ?? {})) if (!declaredOptions.has(optionName)) return new PKCError("ERR_CHALLENGE_OPTION_NOT_DECLARED_IN_OPTION_INPUTS", {
1754
+ ...baseDetails,
1755
+ offendingOption: optionName,
1756
+ declaredOptions: [...declaredOptions]
1757
+ });
1758
+ for (const optionInput of optionInputs) if (optionInput.required && !isOptionSet(challengeSettings.options?.[optionInput.option])) return new PKCError("ERR_CHALLENGE_REQUIRED_OPTION_MISSING", {
1759
+ ...baseDetails,
1760
+ missingOption: optionInput.option
1761
+ });
1762
+ for (const optionName of challengeSettings.publicOptions ?? []) if (!declaredOptions.has(optionName)) return new PKCError("ERR_CHALLENGE_PUBLIC_OPTION_NOT_DECLARED_IN_OPTION_INPUTS", {
1763
+ ...baseDetails,
1764
+ offendingOption: optionName,
1765
+ declaredOptions: [...declaredOptions]
1766
+ });
1767
+ }
1768
+ if (challengeFile.validateChallengeSettings) try {
1769
+ challengeFile.validateChallengeSettings({ challengeSettings });
1770
+ } catch (e) {
1771
+ const wrapped = new PKCError("ERR_CHALLENGE_SETTINGS_VALIDATION_FAILED", {
1772
+ ...baseDetails,
1773
+ validationError: e instanceof Error ? e.message : String(e)
1774
+ });
1775
+ Object.assign(wrapped, { cause: e });
1776
+ return wrapped;
1777
+ }
1778
+ }
1779
+ async function collectChallengeSettingsValidationFailures({ challengeSettings, pkc }) {
1780
+ const failures = [];
1781
+ for (const [challengeIndex, communityChallengeSettings] of challengeSettings.entries()) {
1782
+ const error = validateChallengeSettingsAgainstChallengeFile({
1783
+ challengeSettings: communityChallengeSettings,
1784
+ challengeFile: await loadChallengeFileFromCommunityChallengeSettings({
1785
+ communityChallengeSettings,
1786
+ pkc
1787
+ }),
1788
+ challengeIndex
1789
+ });
1790
+ if (error) failures.push({
1791
+ challengeIndex,
1792
+ challengeName: describeChallenge(communityChallengeSettings),
1793
+ error
1794
+ });
1795
+ }
1796
+ return failures;
1797
+ }
1798
+ async function throwIfChallengeSettingsAreInvalid({ challengeSettings, pkc, communityAddress }) {
1799
+ const failures = await collectChallengeSettingsValidationFailures({
1800
+ challengeSettings,
1801
+ pkc
1802
+ });
1803
+ if (failures.length) throw new PKCError("ERR_CHALLENGE_SETTINGS_VALIDATION_FAILED_FOR_CHALLENGES", {
1804
+ communityAddress,
1805
+ failures: failures.map(({ challengeIndex, challengeName, error }) => ({
1806
+ challengeIndex,
1807
+ challengeName,
1808
+ error
1809
+ }))
1810
+ });
1811
+ }
1812
+ //#endregion
1742
1813
  //#region dist/node/runtime/node/community/local-community/registry.js
1743
1814
  const processStartedCommunities = new TrackedInstanceRegistry();
1744
1815
  //#endregion
@@ -3481,9 +3552,9 @@ var DbHandler = class {
3481
3552
  if (needToMigrate) {
3482
3553
  if (dbExistsAlready && currentDbVersion > 0) {
3483
3554
  this.destoryConnection();
3484
- backupDbPath = path$1.join(path$1.dirname(dbPath), ".backup_before_migration", `${path$1.basename(dbPath)}.${currentDbVersion}.${timestamp()}`);
3485
- log(`Copying db ${path$1.basename(dbPath)} to ${backupDbPath} before migration`);
3486
- if (!fs.existsSync(path$1.dirname(backupDbPath))) await fs.promises.mkdir(path$1.dirname(backupDbPath), { recursive: true });
3555
+ backupDbPath = path.join(path.dirname(dbPath), ".backup_before_migration", `${path.basename(dbPath)}.${currentDbVersion}.${timestamp()}`);
3556
+ log(`Copying db ${path.basename(dbPath)} to ${backupDbPath} before migration`);
3557
+ if (!fs.existsSync(path.dirname(backupDbPath))) await fs.promises.mkdir(path.dirname(backupDbPath), { recursive: true });
3487
3558
  const sourceDb = new Database(dbPath, { fileMustExist: true });
3488
3559
  await sourceDb.backup(backupDbPath);
3489
3560
  sourceDb.close();
@@ -5301,10 +5372,10 @@ var DbHandler = class {
5301
5372
  if (this._db || this._keyv) await this.destoryConnection();
5302
5373
  this._transactionDepth = 0;
5303
5374
  const dataPath = this._community._pkc.dataPath;
5304
- const oldPathString = path$1.join(dataPath, "communities", oldDbName);
5305
- const newPathString = path$1.join(dataPath, "communities", newDbName);
5306
- await fs.promises.mkdir(path$1.dirname(oldPathString), { recursive: true });
5307
- await fs.promises.mkdir(path$1.dirname(newPathString), { recursive: true });
5375
+ const oldPathString = path.join(dataPath, "communities", oldDbName);
5376
+ const newPathString = path.join(dataPath, "communities", newDbName);
5377
+ await fs.promises.mkdir(path.dirname(oldPathString), { recursive: true });
5378
+ await fs.promises.mkdir(path.dirname(newPathString), { recursive: true });
5308
5379
  try {
5309
5380
  if (!fs.existsSync(oldPathString)) log(`Old DB file ${oldPathString} does not exist. Cannot backup/rename.`);
5310
5381
  else {
@@ -5326,8 +5397,8 @@ var DbHandler = class {
5326
5397
  }
5327
5398
  async lockCommunityStart(communityAddress = this._community.address) {
5328
5399
  const log = logger_default("pkc-js:local-community:db-handler:lock:start");
5329
- const lockfilePath = path$1.join(this._community._pkc.dataPath, "communities", `${communityAddress}.start.lock`);
5330
- const communityDbPath = path$1.join(this._community._pkc.dataPath, "communities", communityAddress);
5400
+ const lockfilePath = path.join(this._community._pkc.dataPath, "communities", `${communityAddress}.start.lock`);
5401
+ const communityDbPath = path.join(this._community._pkc.dataPath, "communities", communityAddress);
5331
5402
  try {
5332
5403
  await import_src.default.lock(communityDbPath, {
5333
5404
  lockfilePath,
@@ -5348,8 +5419,8 @@ var DbHandler = class {
5348
5419
  async unlockCommunityStart(communityAddress = this._community.address) {
5349
5420
  const log = logger_default("pkc-js:local-community:db-handler:unlock:start");
5350
5421
  log.trace(`Attempting to unlock the start of community (${communityAddress})`);
5351
- const lockfilePath = path$1.join(this._community._pkc.dataPath, "communities", `${communityAddress}.start.lock`);
5352
- const communityDbPath = path$1.join(this._community._pkc.dataPath, "communities", communityAddress);
5422
+ const lockfilePath = path.join(this._community._pkc.dataPath, "communities", `${communityAddress}.start.lock`);
5423
+ const communityDbPath = path.join(this._community._pkc.dataPath, "communities", communityAddress);
5353
5424
  if (!fs.existsSync(lockfilePath) || !fs.existsSync(communityDbPath)) return;
5354
5425
  try {
5355
5426
  await import_src.default.unlock(communityDbPath, { lockfilePath });
@@ -5360,8 +5431,8 @@ var DbHandler = class {
5360
5431
  }
5361
5432
  }
5362
5433
  async isCommunityStartLocked(communityAddress = this._community.address) {
5363
- const lockfilePath = path$1.join(this._community._pkc.dataPath, "communities", `${communityAddress}.start.lock`);
5364
- const communityDbPath = path$1.join(this._community._pkc.dataPath, "communities", communityAddress);
5434
+ const lockfilePath = path.join(this._community._pkc.dataPath, "communities", `${communityAddress}.start.lock`);
5435
+ const communityDbPath = path.join(this._community._pkc.dataPath, "communities", communityAddress);
5365
5436
  return await import_src.default.check(communityDbPath, {
5366
5437
  lockfilePath,
5367
5438
  realpath: false,
@@ -5370,8 +5441,8 @@ var DbHandler = class {
5370
5441
  }
5371
5442
  async lockCommunityState() {
5372
5443
  const log = logger_default("pkc-js:local-community:db-handler:lock:lockCommunityState");
5373
- const lockfilePath = path$1.join(this._community._pkc.dataPath, "communities", `${this._community.address}.state.lock`);
5374
- const communityDbPath = path$1.join(this._community._pkc.dataPath, "communities", this._community.address);
5444
+ const lockfilePath = path.join(this._community._pkc.dataPath, "communities", `${this._community.address}.state.lock`);
5445
+ const communityDbPath = path.join(this._community._pkc.dataPath, "communities", this._community.address);
5375
5446
  try {
5376
5447
  await import_src.default.lock(communityDbPath, {
5377
5448
  lockfilePath,
@@ -5388,8 +5459,8 @@ var DbHandler = class {
5388
5459
  }
5389
5460
  async unlockCommunityState() {
5390
5461
  const log = logger_default("pkc-js:local-community:db-handler:lock:unlockCommunityState");
5391
- const lockfilePath = path$1.join(this._community._pkc.dataPath, "communities", `${this._community.address}.state.lock`);
5392
- const communityDbPath = path$1.join(this._community._pkc.dataPath, "communities", this._community.address);
5462
+ const lockfilePath = path.join(this._community._pkc.dataPath, "communities", `${this._community.address}.state.lock`);
5463
+ const communityDbPath = path.join(this._community._pkc.dataPath, "communities", this._community.address);
5393
5464
  if (!fs.existsSync(lockfilePath)) return;
5394
5465
  try {
5395
5466
  await import_src.default.unlock(communityDbPath, { lockfilePath });
@@ -5399,7 +5470,7 @@ var DbHandler = class {
5399
5470
  }
5400
5471
  }
5401
5472
  communityDbExists() {
5402
- const communityDbPath = path$1.join(this._community._pkc.dataPath, "communities", this._community.address);
5473
+ const communityDbPath = path.join(this._community._pkc.dataPath, "communities", this._community.address);
5403
5474
  return fs.existsSync(communityDbPath);
5404
5475
  }
5405
5476
  markCommentsAsPublishedToPostUpdates(commentCids) {
@@ -6091,6 +6162,11 @@ async function createNewLocalCommunityDb(community) {
6091
6162
  ...community.settings,
6092
6163
  purgeDisapprovedCommentsOlderThan: 121e4
6093
6164
  };
6165
+ await throwIfChallengeSettingsAreInvalid({
6166
+ challengeSettings: community.settings.challenges,
6167
+ pkc: community._pkc,
6168
+ communityAddress: community.address
6169
+ });
6094
6170
  community.challenges = await Promise.all(community.settings.challenges.map(async (cs) => (await getCommunityChallengeFromCommunityChallengeSettings({
6095
6171
  communityChallengeSettings: cs,
6096
6172
  pkc: community._pkc
@@ -6633,6 +6709,29 @@ async function initBeforeStarting(community) {
6633
6709
  });
6634
6710
  await community._dbHandler.initDbIfNeeded();
6635
6711
  }
6712
+ async function emitChallengeSettingsValidationErrors(community, log) {
6713
+ let failures;
6714
+ try {
6715
+ failures = await collectChallengeSettingsValidationFailures({
6716
+ challengeSettings: community.settings?.challenges ?? [],
6717
+ pkc: community._pkc
6718
+ });
6719
+ } catch (e) {
6720
+ log.error("Failed to validate settings.challenges on start", community.address, e);
6721
+ community.emit("error", e);
6722
+ return;
6723
+ }
6724
+ for (const { error, challengeIndex, challengeName } of failures) {
6725
+ error.details = {
6726
+ ...error.details,
6727
+ challengeIndex,
6728
+ challengeName,
6729
+ communityAddress: community.address
6730
+ };
6731
+ log.error("Invalid challenge settings on start", community.address, error);
6732
+ community.emit("error", error);
6733
+ }
6734
+ }
6636
6735
  async function start(community) {
6637
6736
  const log = logger_default("pkc-js:local-community:start");
6638
6737
  if (community.state === "updating") throw new PKCError("ERR_NEED_TO_STOP_UPDATING_COMMUNITY_BEFORE_STARTING", { address: community.address });
@@ -6680,6 +6779,7 @@ async function start(community) {
6680
6779
  communityChallengeSettings: cs,
6681
6780
  pkc: community._pkc
6682
6781
  })).communityChallenge));
6782
+ await emitChallengeSettingsValidationErrors(community, log);
6683
6783
  } catch (e) {
6684
6784
  await community.stop();
6685
6785
  e.details = {
@@ -6991,6 +7091,11 @@ async function parseRolesToEdit(community, newRawRoles) {
6991
7091
  return t$8(newRawRoles, (val, key) => val === void 0 || val === null);
6992
7092
  }
6993
7093
  async function parseChallengesToEdit(community, newChallengeSettings) {
7094
+ await throwIfChallengeSettingsAreInvalid({
7095
+ challengeSettings: newChallengeSettings,
7096
+ pkc: community._pkc,
7097
+ communityAddress: community.address
7098
+ });
6994
7099
  return {
6995
7100
  challenges: await Promise.all(newChallengeSettings.map(async (cs) => (await getCommunityChallengeFromCommunityChallengeSettings({
6996
7101
  communityChallengeSettings: cs,
@@ -7118,11 +7223,11 @@ async function edit(community, newCommunityOptions) {
7118
7223
  const EXPORTS_KEY = STORAGE_KEYS[STORAGE_KEYS.EXPORTS];
7119
7224
  function defaultExportPathFor(community, exportId) {
7120
7225
  if (typeof community._pkc.dataPath !== "string") throw new PKCError("ERR_DATA_PATH_IS_NOT_DEFINED", { communityAddress: community.address });
7121
- return path.join(community._pkc.dataPath, "exports", `${exportId}.sqlite`);
7226
+ return Path.join(community._pkc.dataPath, "exports", `${exportId}.sqlite`);
7122
7227
  }
7123
7228
  function sourceDbPathFor(community) {
7124
7229
  if (typeof community._pkc.dataPath !== "string") throw new PKCError("ERR_DATA_PATH_IS_NOT_DEFINED", { communityAddress: community.address });
7125
- return path.join(community._pkc.dataPath, "communities", community.address);
7230
+ return Path.join(community._pkc.dataPath, "communities", community.address);
7126
7231
  }
7127
7232
  async function persistExports(community) {
7128
7233
  if (!community._dbHandler) return;
@@ -7198,9 +7303,9 @@ async function runExportTask(community, exportId, opts) {
7198
7303
  async function exportCommunityEmbedded(community, options = {}) {
7199
7304
  if (options.signal?.aborted) throw options.signal.reason ?? new DOMException("The operation was aborted.", "AbortError");
7200
7305
  const exportId = v4();
7201
- const destPath = options.exportPath ? path.resolve(options.exportPath) : defaultExportPathFor(community, exportId);
7306
+ const destPath = options.exportPath ? Path.resolve(options.exportPath) : defaultExportPathFor(community, exportId);
7202
7307
  const includePrivateKey = options.includePrivateKey === true;
7203
- if (path.resolve(destPath) === path.resolve(sourceDbPathFor(community))) throw new PKCError("ERR_EXPORT_PATH_TARGETS_LIVE_DB", {
7308
+ if (Path.resolve(destPath) === Path.resolve(sourceDbPathFor(community))) throw new PKCError("ERR_EXPORT_PATH_TARGETS_LIVE_DB", {
7204
7309
  communityAddress: community.address,
7205
7310
  exportPath: destPath
7206
7311
  });
@@ -1,2 +1,2 @@
1
- import { n as createNewLocalCommunityDb, r as updateInstancePropsWithStartedCommunityOrDb, t as LocalCommunity } from "./local-community-5PMI-TDB.js";
1
+ import { n as createNewLocalCommunityDb, r as updateInstancePropsWithStartedCommunityOrDb, t as LocalCommunity } from "./local-community-BqxmCg5p.js";
2
2
  export { LocalCommunity, createNewLocalCommunityDb, updateInstancePropsWithStartedCommunityOrDb };
@@ -1,7 +1,7 @@
1
1
  import { i as __toESM, r as __require, t as __commonJSMin } from "./chunk-2rV9d50f.js";
2
- import { $n as n$2, B as isIpfsCid, Bt as pTimeout, Ct as findStartedCommunity, D as deepMergeRuntimeFields, Dt as listUpdatingComments, E as createAbortError, En as CommentUpdateForChallengeVerificationSchema, Et as listStartedCommunities, H as isIpns, Ir as joinValues, It as untrackUpdatingComment, L as hideClassPrivateProps, Lr as parsedType, Nt as trackUpdatingComment, Ot as listUpdatingCommunities, Q as isStringDomain, R as ipnsNameToIpnsOverPubsubTopic, Rr as stringifyPrimitive, Rt as require_sha256, Sr as logger_default, Tr as setErrorMap, Tt as findUpdatingCommunity, a as ChallengeRequestMessageSchema, an as CommunityIpfsSchema, ar as e$1, b as areEquivalentCommunityAddresses, br as PKCError, bt as waitForUpdateInCommunityInstanceWithErrorAndTimeout, ct as removeUndefinedValuesRecursively, dn as PubsubTopicSchema, en as CommunityAnchorSchema, ft as retryKuboIpfsAdd, gt as sleepUntilTimeoutOrAbort, hr as FailedToFetchCommentIpfsFromGatewaysError, ht as shortifyCid, ir as e, k as doesDomainAddressHaveCapitalLetter, kn as CommentUpdateSchema, kt as refreshTrackedCommentAliases, lt as replaceXWithY, mr as require_retry, mt as shortifyAddress, nt as rejectWhenAbortSignalFires, r as ChallengeMessageSchema, rr as t$1, rt as rejectWhenCommunityStopsOrAborts, s as ChallengeVerificationMessageSchema, sr as r, t as ChallengeAnswerMessageSchema, tr as n$1, ut as resolveWhenPredicateIsTrue, vt as throwIfAbortSignalAborted, wt as findUpdatingComment, xn as CommentIpfsSchema, xr as messages, y as version_default, yt as timestamp, z as isAbortError, zt as TimeoutError } from "./schema-AXrL86Q4.js";
3
- import { $ as applyNameResolvedCacheToCrosspost, At as verifyCommentModeration, B as tryToDeleteCommunitiesThatFailedToBeDeletedBefore, Bn as RpcExportCommunityModLogsParamSchema, Bt as normalizeCreatePublicationAuthor, Cn as parseDecryptedChallengeVerification, Ct as signVote, Dn as parseRpcCommentEventWithPKCErrorIfItFails, Dt as verifyChallengeVerification, E as createKuboRpcClient, En as parsePKCUserOptionsSchemaWithPKCErrorIfItFails, F as listCommunitiesSync, Fn as RpcCidParamSchema, Ft as verifyVote, Gn as RpcFetchCidResultSchema, Gt as normalizeCommunityInputFromCommunity, Hn as RpcExportCommunityParamSchema, Ht as getCommunityAddressFromRecord, I as monitorCommunitiesDirectory, In as RpcCommentRepliesPageParamSchema, It as buildRuntimeAuthor, J as extractCommunityRuntimeFieldsFromParsedPages, Jn as RpcPublishedAnchorRecordResultSchema, Jt as getBufferedPKCAddressFromPublicKey, Kn as RpcPublishAnchorRecordParamSchema, Kt as decode, Ln as RpcCommunityIdentifierParamSchema, Lt as cleanWireAuthor, M as getDefaultDataPath, Mn as RpcAnchorPublishPreparationResultSchema, Mt as verifyCommentUpdate, Nn as RpcAuthorNameParamSchema, On as parseRpcCommentUpdateEventWithPKCErrorIfItFails, Ot as verifyCommentEdit, Pn as RpcCancelExportParamSchema, Pt as verifyCommunityEdit, Q as RepliesPages, Qn as RpcUnsubscribeParamSchema, Rn as RpcCommunityPageParamSchema, Rt as getAuthorNameFromRuntime, Sn as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, St as signCommunityEdit, Tn as parseJsonWithPKCErrorIfFails, Tt as verifyChallengeMessage, Un as RpcExportCommunityResultSchema, Ut as getCommunityNameFromWire, V as CommentClientsManager, Vn as RpcExportCommunityModLogsResultSchema, Vt as buildRuntimeCommunityFields, Wn as RpcFetchCidParamSchema, Wt as getCommunityPublicKeyFromWire, Xn as RpcSubscriptionIdResultSchema, Y as findCommentInPageInstanceRecursively, Yn as RpcResolveAuthorNameResultSchema, Z as parseRawPages, Zn as RpcSuccessResultSchema, Zt as getPKCAddressFromPublicKeySync, _ as createAnchorIpnsRecord$1, _t as signCommentEdit, a as pkcJsChallenges, ar as n$3, at as PKCClientsManager, b as encryptEd25519AesGcm, bn as parseCreateRpcCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, c as RemoteCommunity, cn as parseCommunityAddressWithPKCErrorIfItFails, cr as t$5, d as decodeRpcChallengeAnswerPubsubMsg, dn as parseCommunityEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, dt as cleanUpBeforePublishing, en as parseCidStringSchemaWithPKCErrorIfItFails, et as cloneCrosspostForRuntime, f as decodeRpcChallengePubsubMsg, fr as nativeFunctions$2, ft as signChallengeAnswer, g as createSigner, gn as parseCreateCommunityEditPublicationOptionsSchemaWithPKCErrorIfItFails, gt as signComment, hn as parseCreateCommentOptionsSchemaWithPKCErrorIfItFails, in as parseCommentIpfsSchemaWithPKCErrorIfItFails, ir as t$3, it as PublicationClientsManager, jn as parseVotePubsubMessagePublicationSchemaWithPKCErrorIfItFails, jt as verifyCommentPubsubMessage, kn as parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, kt as verifyCommentIpfs, lt as PKCTypedEmitter, m as decodeRpcChallengeVerificationPubsubMsg, mn as parseCreateCommentModerationOptionsSchemaWithPKCErrorIfItFails, mt as signChallengeRequest, n as RpcRemoteCommunity, o as TrackedInstanceRegistry, on as parseCommentModerationPubsubMessagePublicationSchemaWithPKCErrorIfItFails, ot as InflightFetchManager, p as decodeRpcChallengeRequestPubsubMsg, pn as parseCreateCommentEditOptionsSchemaWithPKCErrorIfItFails, pr as require_undici, qn as RpcPublishChallengeAnswersParamSchema, rn as parseCommentEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, rt as stripNameResolvedFromCrosspost, s as LRUCache, sn as parseCommentPubsubMessagePublicationWithPKCErrorIfItFails, sr as t$2, t as RpcLocalCommunity, tr as t$4, tt as collectCrosspostAuthorsToResolve, u as KeyvBetterSqlite3, ut as require_lib$1, v as decryptEd25519AesGcm, vt as signCommentModeration, wn as parseDecryptedChallengeWithPKCErrorIfItFails, xn as parseCreateVoteOptionsSchemaWithPKCErrorIfItFails, yn as parseCreateRemoteCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, z as setNativeFunctions$1, zn as RpcEditCommunityParamSchema } from "./rpc-local-community-r51cTBYd.js";
4
- import { o as getHeliaDebugContext } from "./util-CwzCEPKs.js";
2
+ import { $n as n$2, B as isIpfsCid, Bt as pTimeout, Ct as findStartedCommunity, D as deepMergeRuntimeFields, Dt as listUpdatingComments, E as createAbortError, En as CommentUpdateForChallengeVerificationSchema, Et as listStartedCommunities, H as isIpns, Ir as joinValues, It as untrackUpdatingComment, L as hideClassPrivateProps, Lr as parsedType, Nt as trackUpdatingComment, Ot as listUpdatingCommunities, Q as isStringDomain, R as ipnsNameToIpnsOverPubsubTopic, Rr as stringifyPrimitive, Rt as require_sha256, Sr as logger_default, Tr as setErrorMap, Tt as findUpdatingCommunity, a as ChallengeRequestMessageSchema, an as CommunityIpfsSchema, ar as e$1, b as areEquivalentCommunityAddresses, br as PKCError, bt as waitForUpdateInCommunityInstanceWithErrorAndTimeout, ct as removeUndefinedValuesRecursively, dn as PubsubTopicSchema, en as CommunityAnchorSchema, ft as retryKuboIpfsAdd, gt as sleepUntilTimeoutOrAbort, hr as FailedToFetchCommentIpfsFromGatewaysError, ht as shortifyCid, ir as e, k as doesDomainAddressHaveCapitalLetter, kn as CommentUpdateSchema, kt as refreshTrackedCommentAliases, lt as replaceXWithY, mr as require_retry, mt as shortifyAddress, nt as rejectWhenAbortSignalFires, r as ChallengeMessageSchema, rr as t$1, rt as rejectWhenCommunityStopsOrAborts, s as ChallengeVerificationMessageSchema, sr as r, t as ChallengeAnswerMessageSchema, tr as n$1, ut as resolveWhenPredicateIsTrue, vt as throwIfAbortSignalAborted, wt as findUpdatingComment, xn as CommentIpfsSchema, xr as messages, y as version_default, yt as timestamp, z as isAbortError, zt as TimeoutError } from "./schema-qhSDu1BU.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-o0teUvw_.js";
4
+ import { o as getHeliaDebugContext } from "./util-BVGNNIgn.js";
5
5
  import path from "path";
6
6
  import assert from "assert";
7
7
  import fs from "fs";
@@ -6948,7 +6948,7 @@ var PKC$1 = class extends PKCTypedEmitter {
6948
6948
  this.clients.libp2pJsClients = {};
6949
6949
  if (!this.libp2pJsClientsOptions) return;
6950
6950
  if (!this.httpRoutersOptions) throw Error("httpRoutersOptions is required for libp2pJsClient");
6951
- const { createLibp2pJsClientOrUseExistingOne } = await import("./helia-for-pkc-BlDudTLN.js");
6951
+ const { createLibp2pJsClientOrUseExistingOne } = await import("./helia-for-pkc-C5Oe_ZSx.js");
6952
6952
  for (const clientOptions of this.libp2pJsClientsOptions) {
6953
6953
  const heliaNode = await createLibp2pJsClientOrUseExistingOne({
6954
6954
  ...clientOptions,
@@ -7227,7 +7227,7 @@ var PKC$1 = class extends PKCTypedEmitter {
7227
7227
  const log = logger_default("pkc-js:pkc:createLocalCommunity");
7228
7228
  log.trace("Received community options to create a local community instance:", options);
7229
7229
  if (!this._canCreateNewLocalCommunity()) throw new PKCError("ERR_CAN_NOT_CREATE_A_LOCAL_COMMUNITY", { pkcOptions: this._userPKCOptions });
7230
- const { LocalCommunity, createNewLocalCommunityDb, updateInstancePropsWithStartedCommunityOrDb } = await import("./local-community-4wIeaqty.js");
7230
+ const { LocalCommunity, createNewLocalCommunityDb, updateInstancePropsWithStartedCommunityOrDb } = await import("./local-community-D4SjlAKS.js");
7231
7231
  const isLocalCommunity = (await listCommunitiesSync(this)).includes(options.address);
7232
7232
  const community = new LocalCommunity(this);
7233
7233
  if (isLocalCommunity) {
@@ -1,5 +1,5 @@
1
1
  import { i as __toESM, n as __exportAll, r as __require, t as __commonJSMin } from "./chunk-2rV9d50f.js";
2
- import { $ as pubsubTopicToDhtKey, $n as n$10, $t as ChallengeFileSchema, A as extractNetworkErrorDetails, An as CommentUpdateSignedPropertyNames, Ar as literal, At as refreshTrackedCommunityAliases, B as isIpfsCid, Bt as pTimeout, Cn as CommentPubsubMessageWithFlexibleAuthorRefinementSchema, Cr as require_supports_color, Ct as findStartedCommunity, D as deepMergeRuntimeFields, Dn as CommentUpdateForChallengeVerificationSignedPropertyNames, Dr as array, E as createAbortError, Er as _enum, Et as listStartedCommunities, Fn as ModQueuePageIpfsSchema, Ft as untrackStartedCommunity, Gn as AuthorCommentIpfsReservedFields, Gt as CreateCommunityEditPublicationOptionsWithRefinementSchema, H as isIpns, I as getPostUpdateTimestampRange, In as PageIpfsSchema, It as untrackUpdatingComment, Jn as CidPathSchema, Kt as CommentModerationChallengeRequestToEncryptSchema, L as hideClassPrivateProps, Ln as CommentEditChallengeRequestToEncryptSchema, Lt as untrackUpdatingCommunity, Mr as object, Mt as trackStartedCommunity, Nn as CreateCommentOptionsWithRefinementSchema, Nr as record, O as derivePublicationFromChallengeRequest, On as CommentUpdateReservedFields, Or as boolean, Ot as listUpdatingCommunities, Pn as GetPageParamSchema, Pr as string, Pt as trackUpdatingCommunity, Q as isStringDomain, Qn as CreateSignerSchema, Qt as ChallengeFileFactorySchema, R as ipnsNameToIpnsOverPubsubTopic, Rt as require_sha256$1, Sr as logger_default, Tn as CommentUpdateChallengeReservedFieldNames, Tt as findUpdatingCommunity, U as isIpnsPath, Un as CreateCommentEditOptionsWithRefinementSchema, Ut as CommunityEditPublicationSignedPropertyNames, V as isIpfsPath, Vn as CommentEditSignedPropertyNames, Vt as CommunityEditPublicationChallengeRequestToEncryptSchema, Wn as AuthorAddressSchema, Wt as CommunityEditPubsubMessagePublicationSchema, X as isRequestPubsubPublicationOfPost, Xn as CommunityAddressSchema, Xt as CommentModerationsTableRowSchema, Yn as CidStringSchema, Yt as CommentModerationSignedPropertyNames, Z as isRequestPubsubPublicationOfReply, Zn as CommunityAuthorChallengeReservedFieldNames, Zt as CreateCommentModerationOptionsWithRefinementSchema, _ as PKCUserOptionBaseSchema, _n as VoteSignedPropertyNames, _r as FailedToFetchCommunityFromGatewaysError, an as CommunityIpfsSchema, ar as e$5, b as areEquivalentCommunityAddresses, bn as CommentIpfsReservedFields, br as PKCError, bt as waitForUpdateInCommunityInstanceWithErrorAndTimeout, c as ChallengeVerificationMessageSignedPropertyNames, cn as CreateRemoteCommunityFunctionArgumentSchema, cr as t$12, dr as t$10, f as DecryptedChallengeSchema, fn as RpcRemoteCommunityUpdateEventResultSchema, fr as t$9, g as PKCParsedOptionsSchema, gr as FailedToFetchCommentUpdateFromGatewaysError, gt as sleepUntilTimeoutOrAbort, h as NameResolverSerializedSchema, hn as VotePubsubMessagePublicationSchema, hr as FailedToFetchCommentIpfsFromGatewaysError, ht as shortifyCid, i as ChallengeMessageSignedPropertyNames, in as CommunityIpfsReservedFields, ir as e$6, j as fetchAndValidateIpnsRecordFromGateway, jr as number, k as doesDomainAddressHaveCapitalLetter, kn as CommentUpdateSchema, kr as custom, l as DecryptedChallengeAnswerSchema, ln as CreateRpcCommunityFunctionArgumentSchema, lr as n$8, m as NameResolveCacheOptionsSchema, mn as VoteChallengeRequestToEncryptSchema, mr as require_retry$1, mt as shortifyAddress, n as ChallengeAnswerMessageSignedPropertyNames, nn as CommunityEditOptionsSchema, o as ChallengeRequestMessageSignedPropertyNames, on as CommunitySignedPropertyNames, or as t$11, ot as removeNullUndefinedEmptyObjectsValuesRecursively, p as DecryptedChallengeVerificationSchema, pn as CreateVoteUserOptionsWithRefinementSchema, pr as e$4, qn as ChallengeAnswersSchema, qt as CommentModerationPubsubMessagePublicationSchema, rn as CommunityExportRecordsSchema, rr as t$13, sn as CreateNewLocalCommunityUserOptionsSchema, sr as r$8, tn as CommunityChallengeSettingSchema, tr as n$9, tt as raceAgainstAbort, un as ExportCommunityModLogsOptionsSchema, ur as r$7, ut as resolveWhenPredicateIsTrue, v as PKCUserOptionsSchema, vr as FailedToFetchGenericIpfsFromGatewaysError, vt as throwIfAbortSignalAborted, wn as CommentSignedPropertyNames, wr as require_ms$1, wt as findUpdatingComment, x as calculateIpfsCidV0, xn as CommentIpfsSchema, xr as messages, yn as CommentChallengeRequestToEncryptSchema, yr as FailedToFetchPageIpfsFromGatewaysError, yt as timestamp, z as isAbortError, zn as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema } from "./schema-AXrL86Q4.js";
2
+ import { $ as pubsubTopicToDhtKey, $n as n$10, $t as ChallengeFileSchema, A as extractNetworkErrorDetails, An as CommentUpdateSignedPropertyNames, Ar as literal, At as refreshTrackedCommunityAliases, B as isIpfsCid, Bt as pTimeout, Cn as CommentPubsubMessageWithFlexibleAuthorRefinementSchema, Cr as require_supports_color, Ct as findStartedCommunity, D as deepMergeRuntimeFields, Dn as CommentUpdateForChallengeVerificationSignedPropertyNames, Dr as array, E as createAbortError, Er as _enum, Et as listStartedCommunities, Fn as ModQueuePageIpfsSchema, Ft as untrackStartedCommunity, Gn as AuthorCommentIpfsReservedFields, Gt as CreateCommunityEditPublicationOptionsWithRefinementSchema, H as isIpns, I as getPostUpdateTimestampRange, In as PageIpfsSchema, It as untrackUpdatingComment, Jn as CidPathSchema, Kt as CommentModerationChallengeRequestToEncryptSchema, L as hideClassPrivateProps, Ln as CommentEditChallengeRequestToEncryptSchema, Lt as untrackUpdatingCommunity, Mr as object, Mt as trackStartedCommunity, Nn as CreateCommentOptionsWithRefinementSchema, Nr as record, O as derivePublicationFromChallengeRequest, On as CommentUpdateReservedFields, Or as boolean, Ot as listUpdatingCommunities, Pn as GetPageParamSchema, Pr as string, Pt as trackUpdatingCommunity, Q as isStringDomain, Qn as CreateSignerSchema, Qt as ChallengeFileFactorySchema, R as ipnsNameToIpnsOverPubsubTopic, Rt as require_sha256$1, Sr as logger_default, Tn as CommentUpdateChallengeReservedFieldNames, Tt as findUpdatingCommunity, U as isIpnsPath, Un as CreateCommentEditOptionsWithRefinementSchema, Ut as CommunityEditPublicationSignedPropertyNames, V as isIpfsPath, Vn as CommentEditSignedPropertyNames, Vt as CommunityEditPublicationChallengeRequestToEncryptSchema, Wn as AuthorAddressSchema, Wt as CommunityEditPubsubMessagePublicationSchema, X as isRequestPubsubPublicationOfPost, Xn as CommunityAddressSchema, Xt as CommentModerationsTableRowSchema, Yn as CidStringSchema, Yt as CommentModerationSignedPropertyNames, Z as isRequestPubsubPublicationOfReply, Zn as CommunityAuthorChallengeReservedFieldNames, Zt as CreateCommentModerationOptionsWithRefinementSchema, _ as PKCUserOptionBaseSchema, _n as VoteSignedPropertyNames, _r as FailedToFetchCommunityFromGatewaysError, an as CommunityIpfsSchema, ar as e$5, b as areEquivalentCommunityAddresses, bn as CommentIpfsReservedFields, br as PKCError, bt as waitForUpdateInCommunityInstanceWithErrorAndTimeout, c as ChallengeVerificationMessageSignedPropertyNames, cn as CreateRemoteCommunityFunctionArgumentSchema, cr as t$12, dr as t$10, f as DecryptedChallengeSchema, fn as RpcRemoteCommunityUpdateEventResultSchema, fr as t$9, g as PKCParsedOptionsSchema, gr as FailedToFetchCommentUpdateFromGatewaysError, gt as sleepUntilTimeoutOrAbort, h as NameResolverSerializedSchema, hn as VotePubsubMessagePublicationSchema, hr as FailedToFetchCommentIpfsFromGatewaysError, ht as shortifyCid, i as ChallengeMessageSignedPropertyNames, in as CommunityIpfsReservedFields, ir as e$6, j as fetchAndValidateIpnsRecordFromGateway, jr as number, k as doesDomainAddressHaveCapitalLetter, kn as CommentUpdateSchema, kr as custom, l as DecryptedChallengeAnswerSchema, ln as CreateRpcCommunityFunctionArgumentSchema, lr as n$8, m as NameResolveCacheOptionsSchema, mn as VoteChallengeRequestToEncryptSchema, mr as require_retry$1, mt as shortifyAddress, n as ChallengeAnswerMessageSignedPropertyNames, nn as CommunityEditOptionsSchema, o as ChallengeRequestMessageSignedPropertyNames, on as CommunitySignedPropertyNames, or as t$11, ot as removeNullUndefinedEmptyObjectsValuesRecursively, p as DecryptedChallengeVerificationSchema, pn as CreateVoteUserOptionsWithRefinementSchema, pr as e$4, qn as ChallengeAnswersSchema, qt as CommentModerationPubsubMessagePublicationSchema, rn as CommunityExportRecordsSchema, rr as t$13, sn as CreateNewLocalCommunityUserOptionsSchema, sr as r$8, tn as CommunityChallengeSettingSchema, tr as n$9, tt as raceAgainstAbort, un as ExportCommunityModLogsOptionsSchema, ur as r$7, ut as resolveWhenPredicateIsTrue, v as PKCUserOptionsSchema, vr as FailedToFetchGenericIpfsFromGatewaysError, vt as throwIfAbortSignalAborted, wn as CommentSignedPropertyNames, wr as require_ms$1, wt as findUpdatingComment, x as calculateIpfsCidV0, xn as CommentIpfsSchema, xr as messages, yn as CommentChallengeRequestToEncryptSchema, yr as FailedToFetchPageIpfsFromGatewaysError, yt as timestamp, z as isAbortError, zn as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema } from "./schema-qhSDu1BU.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";
@@ -91779,7 +91779,10 @@ const CreatePKCWsServerOptionsSchema = object({
91779
91779
  const SetNewSettingsPKCWsServerSchema = object({ pkcOptions: PKCUserOptionBaseSchema.extend({ nameResolvers: NameResolverSerializedSchema.array().optional() }).loose() });
91780
91780
  const PKCWsServerSettingsSerializedSchema = object({
91781
91781
  pkcOptions: PKCParsedOptionsSchema.loose(),
91782
- challenges: record(string(), ChallengeFileSchema.omit({ getChallenge: true }))
91782
+ challenges: record(string(), ChallengeFileSchema.omit({
91783
+ getChallenge: true,
91784
+ validateChallengeSettings: true
91785
+ }))
91783
91786
  });
91784
91787
  //#endregion
91785
91788
  //#region dist/node/schema/schema-util.js
@@ -128116,6 +128119,25 @@ function ChallengeFileFactory$4({ challengeSettings }) {
128116
128119
  };
128117
128120
  }
128118
128121
  //#endregion
128122
+ //#region dist/node/runtime/node/community/challenges/pkc-js-challenges/address-list-validation.js
128123
+ const splitCommaSeparated = (value) => value.split(",").map((entry) => entry.trim());
128124
+ function validateAddressListOptions({ challengeSettings }) {
128125
+ const { addresses, urls } = challengeSettings.options ?? {};
128126
+ if (addresses) {
128127
+ for (const [index, address] of splitCommaSeparated(addresses).entries()) if (!address) throw new Error(`addresses entry ${index} is empty, check for a stray or trailing comma`);
128128
+ }
128129
+ if (urls) for (const [index, url] of splitCommaSeparated(urls).entries()) {
128130
+ if (!url) throw new Error(`urls entry ${index} is empty, check for a stray or trailing comma`);
128131
+ let parsed;
128132
+ try {
128133
+ parsed = new URL(url);
128134
+ } catch {
128135
+ throw new Error(`urls entry ${index} ('${url}') is not a valid URL`);
128136
+ }
128137
+ if (parsed.protocol !== "http:" && parsed.protocol !== "https:") throw new Error(`urls entry ${index} ('${url}') must use http: or https:, it is fetched over HTTP`);
128138
+ }
128139
+ }
128140
+ //#endregion
128119
128141
  //#region dist/node/runtime/node/community/challenges/pkc-js-challenges/blacklist.js
128120
128142
  const optionInputs$3 = [
128121
128143
  {
@@ -128198,7 +128220,8 @@ function ChallengeFileFactory$3({ challengeSettings }) {
128198
128220
  getChallenge: getChallenge$3,
128199
128221
  optionInputs: optionInputs$3,
128200
128222
  type: type$3,
128201
- description: description$2
128223
+ description: description$2,
128224
+ validateChallengeSettings: validateAddressListOptions
128202
128225
  };
128203
128226
  }
128204
128227
  //#endregion
@@ -128284,7 +128307,8 @@ function ChallengeFileFactory$2({ challengeSettings }) {
128284
128307
  getChallenge: getChallenge$2,
128285
128308
  optionInputs: optionInputs$2,
128286
128309
  type: type$2,
128287
- description: description$1
128310
+ description: description$1,
128311
+ validateChallengeSettings: validateAddressListOptions
128288
128312
  };
128289
128313
  }
128290
128314
  //#endregion
@@ -128327,13 +128351,17 @@ const getChallenge$1 = async ({ challengeSettings, challengeRequestMessage, chal
128327
128351
  };
128328
128352
  return { success: true };
128329
128353
  };
128354
+ const validateChallengeSettings$1 = ({ challengeSettings }) => {
128355
+ if (challengeSettings.publicOptions?.includes("answer")) throw new Error("answer cannot be listed in publicOptions: publishing the answer means anyone can pass the challenge");
128356
+ };
128330
128357
  function ChallengeFileFactory$1({ challengeSettings }) {
128331
128358
  return {
128332
128359
  getChallenge: getChallenge$1,
128333
128360
  optionInputs: optionInputs$1,
128334
128361
  type: type$1,
128335
128362
  challenge: challengeSettings?.options?.question,
128336
- description
128363
+ description,
128364
+ validateChallengeSettings: validateChallengeSettings$1
128337
128365
  };
128338
128366
  }
128339
128367
  //#endregion
@@ -128434,12 +128462,35 @@ const getChallenge = async ({ challengeSettings, challengeRequestMessage }) => {
128434
128462
  error
128435
128463
  };
128436
128464
  };
128465
+ const validateChallengeSettings = ({ challengeSettings }) => {
128466
+ const matchesStr = challengeSettings.options?.matches;
128467
+ if (!matchesStr) return;
128468
+ let parsed;
128469
+ try {
128470
+ parsed = JSON.parse(matchesStr);
128471
+ } catch (e) {
128472
+ throw new Error(`matches is not valid JSON: ${e.message}`);
128473
+ }
128474
+ if (!Array.isArray(parsed)) throw new Error("matches must be a JSON array of {propertyName, regexp} objects");
128475
+ for (const [index, match] of parsed.entries()) {
128476
+ if (typeof match !== "object" || match === null || Array.isArray(match)) throw new Error(`matches[${index}] must be an object with propertyName and regexp`);
128477
+ const { propertyName, regexp } = match;
128478
+ if (typeof propertyName !== "string" || !propertyName) throw new Error(`matches[${index}].propertyName must be a non-empty string`);
128479
+ if (typeof regexp !== "string" || !regexp) throw new Error(`matches[${index}].regexp must be a non-empty string`);
128480
+ try {
128481
+ new RegExp(regexp);
128482
+ } catch (e) {
128483
+ throw new Error(`matches[${index}].regexp ('${regexp}') is not a valid regular expression: ${e.message}`);
128484
+ }
128485
+ }
128486
+ };
128437
128487
  function ChallengeFileFactory({ challengeSettings }) {
128438
128488
  return {
128439
128489
  getChallenge,
128440
128490
  optionInputs,
128441
128491
  type,
128442
- description: challengeSettings?.options?.description || defaultDescription
128492
+ description: challengeSettings?.options?.description || defaultDescription,
128493
+ validateChallengeSettings
128443
128494
  };
128444
128495
  }
128445
128496
  //#endregion
@@ -128974,8 +129025,14 @@ const getChallengeVerification = async ({ challengeRequestMessage, community, ge
128974
129025
  };
128975
129026
  return challengeVerification;
128976
129027
  };
128977
- const getCommunityChallengeFromCommunityChallengeSettings = async ({ communityChallengeSettings, pkc }) => {
128978
- communityChallengeSettings = CommunityChallengeSettingSchema.parse(communityChallengeSettings);
129028
+ const derivePublicOptions = (communityChallengeSettings) => {
129029
+ const { publicOptions, options } = communityChallengeSettings;
129030
+ if (!publicOptions?.length || !options) return void 0;
129031
+ const published = {};
129032
+ for (const optionName of publicOptions) if (typeof options[optionName] === "string") published[optionName] = options[optionName];
129033
+ return e$5(published) ? void 0 : published;
129034
+ };
129035
+ const loadChallengeFileFromCommunityChallengeSettings = async ({ communityChallengeSettings, pkc }) => {
128979
129036
  let challengeFile = void 0;
128980
129037
  if (communityChallengeSettings.path) try {
128981
129038
  const importedFile = await import(pathToFileURL(communityChallengeSettings.path).href);
@@ -128998,6 +129055,14 @@ const getCommunityChallengeFromCommunityChallengeSettings = async ({ communityCh
128998
129055
  challengeFile = ChallengeFileSchema.parse(ChallengeFileFactory({ challengeSettings: communityChallengeSettings }));
128999
129056
  }
129000
129057
  if (!challengeFile) throw Error("Failed to load challenge file");
129058
+ return challengeFile;
129059
+ };
129060
+ const getCommunityChallengeFromCommunityChallengeSettings = async ({ communityChallengeSettings, pkc }) => {
129061
+ communityChallengeSettings = CommunityChallengeSettingSchema.parse(communityChallengeSettings);
129062
+ const challengeFile = await loadChallengeFileFromCommunityChallengeSettings({
129063
+ communityChallengeSettings,
129064
+ pkc
129065
+ });
129001
129066
  const { challenge, type } = challengeFile;
129002
129067
  return { communityChallenge: {
129003
129068
  exclude: communityChallengeSettings.exclude,
@@ -129005,7 +129070,8 @@ const getCommunityChallengeFromCommunityChallengeSettings = async ({ communityCh
129005
129070
  challenge,
129006
129071
  type,
129007
129072
  caseInsensitive: challengeFile.caseInsensitive,
129008
- pendingApproval: communityChallengeSettings.pendingApproval
129073
+ pendingApproval: communityChallengeSettings.pendingApproval,
129074
+ publicOptions: derivePublicOptions(communityChallengeSettings)
129009
129075
  } };
129010
129076
  };
129011
129077
  //#endregion
@@ -129599,4 +129665,4 @@ var RpcLocalCommunity = class extends RpcRemoteCommunity {
129599
129665
  }
129600
129666
  };
129601
129667
  //#endregion
129602
- export { applyNameResolvedCacheToCrosspost as $, crosspostChainDepthUpTo as $n, createSchemaRowParser as $t, deriveDbReplies as A, parseVoteChallengeRequestToEncryptSchemaWithPKCErrorIfItFails as An, verifyCommentModeration as At, tryToDeleteCommunitiesThatFailedToBeDeletedBefore as B, RpcExportCommunityModLogsParamSchema as Bn, normalizeCreatePublicationAuthor as Bt, backupCommunityDb as C, parseDecryptedChallengeVerification as Cn, signVote as Ct, deleteOldCommunityInWindows as D, parseRpcCommentEventWithPKCErrorIfItFails as Dn, verifyChallengeVerification as Dt, createKuboRpcClient as E, parsePKCUserOptionsSchemaWithPKCErrorIfItFails as En, verifyChallengeRequest as Et, listCommunitiesSync as F, RpcCidParamSchema as Fn, verifyVote as Ft, TIMEFRAMES_TO_SECONDS as G, RpcFetchCidResultSchema as Gn, normalizeCommunityInputFromCommunity as Gt, POSTS_SORT_TYPES as H, RpcExportCommunityParamSchema as Hn, getCommunityAddressFromRecord as Ht, monitorCommunitiesDirectory as I, RpcCommentRepliesPageParamSchema as In, buildRuntimeAuthor as It, extractCommunityRuntimeFieldsFromParsedPages as J, RpcPublishedAnchorRecordResultSchema as Jn, getBufferedPKCAddressFromPublicKey as Jt, buildPageRuntimeFields as K, RpcPublishAnchorRecordParamSchema as Kn, decode as Kt, moveCommunityDbToDeletedDirectory as L, RpcCommunityIdentifierParamSchema as Ln, cleanWireAuthor as Lt, getDefaultDataPath as M, RpcAnchorPublishPreparationResultSchema as Mn, verifyCommentUpdate as Mt, getThumbnailPropsOfLink as N, RpcAuthorNameParamSchema as Nn, verifyCommunity as Nt, deriveCommentIpfsFromCommentTableRow as O, parseRpcCommentUpdateEventWithPKCErrorIfItFails as On, verifyCommentEdit as Ot, importSignerIntoKuboNode as P, RpcCancelExportParamSchema as Pn, verifyCommunityEdit as Pt, RepliesPages as Q, RpcUnsubscribeParamSchema as Qn, getPublicKeyFromPrivateKey as Qt, resolveDbPostsCidRefs as R, RpcCommunityPageParamSchema as Rn, getAuthorNameFromRuntime as Rt, BackupAbortError as S, parseDecryptedChallengeAnswerWithPKCErrorIfItFails as Sn, signCommunityEdit as St, calculateInlineRepliesBudget as T, parseJsonWithPKCErrorIfFails as Tn, verifyChallengeMessage as Tt, POST_REPLIES_SORT_TYPES as U, RpcExportCommunityResultSchema as Un, getCommunityNameFromWire$1 as Ut, CommentClientsManager as V, RpcExportCommunityModLogsResultSchema as Vn, buildRuntimeCommunityFields as Vt, REPLY_REPLIES_SORT_TYPES as W, RpcFetchCidParamSchema as Wn, getCommunityPublicKeyFromWire as Wt, iterateOverPageCidsToFindAllCids as X, RpcSubscriptionIdResultSchema as Xn, getPKCAddressFromPublicKey as Xt, findCommentInPageInstanceRecursively as Y, RpcResolveAuthorNameResultSchema as Yn, getIpfsKeyFromPrivateKey as Yt, parseRawPages as Z, RpcSuccessResultSchema as Zn, getPKCAddressFromPublicKeySync as Zt, createAnchorIpnsRecord as _, parseCreateNewLocalCommunityUserOptionsSchemaWithPKCErrorIfItFails as _n, signCommentEdit as _t, pkcJsChallenges as a, parseCommentModerationChallengeRequestToEncryptSchemaWithPKCErrorIfItFails as an, n$5 as ar, PKCClientsManager as at, encryptEd25519AesGcm as b, parseCreateRpcCommunityFunctionArgumentSchemaWithPKCErrorIfItFails as bn, signCommentUpdateForChallengeVerification as bt, RemoteCommunity as c, parseCommunityAddressWithPKCErrorIfItFails as cn, t$8 as cr, pLimit as ct, decodeRpcChallengeAnswerPubsubMsg as d, parseCommunityEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails as dn, require_lodash_merge as dr, cleanUpBeforePublishing as dt, parseCidStringSchemaWithPKCErrorIfItFails as en, effectiveMaxCrosspostDepth as er, cloneCrosspostForRuntime as et, decodeRpcChallengePubsubMsg as f, parseCommunityIpfsSchemaPassthroughWithPKCErrorIfItFails as fn, nativeFunctions$1 as fr, signChallengeAnswer as ft, createSigner as g, parseCreateCommunityEditPublicationOptionsSchemaWithPKCErrorIfItFails as gn, signComment as gt, SignerWithPublicKeyAddress as h, parseCreateCommentOptionsSchemaWithPKCErrorIfItFails as hn, signChallengeVerification as ht, getCommunityChallengeFromCommunityChallengeSettings as i, parseCommentIpfsSchemaWithPKCErrorIfItFails as in, t$5 as ir, PublicationClientsManager as it, getDefaultCommunityDbConfig as j, parseVotePubsubMessagePublicationSchemaWithPKCErrorIfItFails as jn, verifyCommentPubsubMessage as jt, deriveDbPosts as k, parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails as kn, verifyCommentIpfs as kt, MAX_FILE_SIZE_BYTES_FOR_COMMUNITY_IPFS as l, parseCommunityEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails as ln, stringify as lr, PKCTypedEmitter as lt, decodeRpcChallengeVerificationPubsubMsg as m, parseCreateCommentModerationOptionsSchemaWithPKCErrorIfItFails as mn, signChallengeRequest as mt, RpcRemoteCommunity as n, parseCommentEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails as nn, t$4 as nr, extractCrosspostRuntimeFields as nt, TrackedInstanceRegistry as o, parseCommentModerationPubsubMessagePublicationSchemaWithPKCErrorIfItFails as on, n$6 as or, InflightFetchManager as ot, decodeRpcChallengeRequestPubsubMsg as p, parseCreateCommentEditOptionsSchemaWithPKCErrorIfItFails as pn, require_undici as pr, signChallengeMessage as pt, buildPagesRuntimeFields as q, RpcPublishChallengeAnswersParamSchema as qn, encode as qt, getChallengeVerification as r, parseCommentEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails as rn, r as rr, stripNameResolvedFromCrosspost as rt, LRUCache as s, parseCommentPubsubMessagePublicationWithPKCErrorIfItFails as sn, t$7 as sr, pRetry as st, RpcLocalCommunity as t, parseCommentChallengeRequestToEncryptSchemaWithPKCErrorIfItFails as tn, t$2 as tr, collectCrosspostAuthorsToResolve as tt, KeyvBetterSqlite3 as u, parseCommunityEditOptionsSchemaWithPKCErrorIfItFails as un, STORAGE_KEYS as ur, require_lib$1 as ut, decryptEd25519AesGcm as v, parseCreatePKCWsServerOptionsSchemaWithPKCErrorIfItFails as vn, signCommentModeration as vt, calculateExpectedSignatureSize as w, parseDecryptedChallengeWithPKCErrorIfItFails as wn, verifyChallengeAnswer as wt, encryptEd25519AesGcmPublicKeyBuffer as x, parseCreateVoteOptionsSchemaWithPKCErrorIfItFails as xn, signCommunity as xt, decryptEd25519AesGcmPublicKeyBuffer as y, parseCreateRemoteCommunityFunctionArgumentSchemaWithPKCErrorIfItFails as yn, signCommentUpdate as yt, setNativeFunctions as z, RpcEditCommunityParamSchema as zn, getAuthorNameFromWire as zt };
129668
+ 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 };