@pkcprotocol/pkc-js 0.0.154 → 0.0.156

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 (172) hide show
  1. package/README.md +2 -2
  2. package/dist/browser/clients/rpc-client/schema.js +2 -2
  3. package/dist/browser/clients/rpc-client/schema.js.map +1 -1
  4. package/dist/browser/community/remote-community.js +8 -2
  5. package/dist/browser/community/remote-community.js.map +1 -1
  6. package/dist/browser/community/schema.js +4 -0
  7. package/dist/browser/community/schema.js.map +1 -1
  8. package/dist/browser/community-list/community-list.js +3 -2
  9. package/dist/browser/community-list/community-list.js.map +1 -1
  10. package/dist/browser/errors.d.ts +14 -0
  11. package/dist/browser/errors.js +14 -0
  12. package/dist/browser/errors.js.map +1 -1
  13. package/dist/browser/generated-version.d.ts +1 -1
  14. package/dist/browser/generated-version.js +1 -1
  15. package/dist/browser/pkc/pkc.js +13 -4
  16. package/dist/browser/pkc/pkc.js.map +1 -1
  17. package/dist/browser/pkc-error.d.ts +1 -1
  18. package/dist/browser/publications/comment/comment.js +25 -9
  19. package/dist/browser/publications/comment/comment.js.map +1 -1
  20. package/dist/browser/publications/comment/crosspost-runtime.js +10 -2
  21. package/dist/browser/publications/comment/crosspost-runtime.js.map +1 -1
  22. package/dist/browser/publications/comment/schema.d.ts +1 -1
  23. package/dist/browser/publications/comment/schema.js +30 -1
  24. package/dist/browser/publications/comment/schema.js.map +1 -1
  25. package/dist/browser/publications/publication.d.ts +4 -0
  26. package/dist/browser/publications/publication.js +135 -38
  27. package/dist/browser/publications/publication.js.map +1 -1
  28. package/dist/browser/rpc/src/index.js +3 -3
  29. package/dist/browser/rpc/src/index.js.map +1 -1
  30. package/dist/browser/runtime/browser/util.d.ts +3 -1
  31. package/dist/browser/runtime/browser/util.js +8 -2
  32. package/dist/browser/runtime/browser/util.js.map +1 -1
  33. package/dist/browser/runtime/node/blockstore.d.ts +2 -2
  34. package/dist/browser/runtime/node/blockstore.js +2 -2
  35. package/dist/browser/runtime/node/community/challenges/validate-challenge-result.js +2 -1
  36. package/dist/browser/runtime/node/community/challenges/validate-challenge-result.js.map +1 -1
  37. package/dist/browser/runtime/node/community/communities-registry.d.ts +96 -0
  38. package/dist/browser/runtime/node/community/communities-registry.js +964 -0
  39. package/dist/browser/runtime/node/community/communities-registry.js.map +1 -0
  40. package/dist/browser/runtime/node/community/db-handler.d.ts +3 -0
  41. package/dist/browser/runtime/node/community/db-handler.js +82 -35
  42. package/dist/browser/runtime/node/community/db-handler.js.map +1 -1
  43. package/dist/browser/runtime/node/community/local-community/editing.js +16 -8
  44. package/dist/browser/runtime/node/community/local-community/editing.js.map +1 -1
  45. package/dist/browser/runtime/node/community/local-community/lifecycle.js +68 -19
  46. package/dist/browser/runtime/node/community/local-community/lifecycle.js.map +1 -1
  47. package/dist/browser/runtime/node/community/local-community/publication-validation.d.ts +1 -2
  48. package/dist/browser/runtime/node/community/local-community/publication-validation.js +23 -0
  49. package/dist/browser/runtime/node/community/local-community/publication-validation.js.map +1 -1
  50. package/dist/browser/runtime/node/community/local-community.d.ts +2 -1
  51. package/dist/browser/runtime/node/community/local-community.js +5 -9
  52. package/dist/browser/runtime/node/community/local-community.js.map +1 -1
  53. package/dist/browser/runtime/node/community/pkc-instance-lock.d.ts +17 -0
  54. package/dist/browser/runtime/node/community/pkc-instance-lock.js +142 -0
  55. package/dist/browser/runtime/node/community/pkc-instance-lock.js.map +1 -0
  56. package/dist/browser/runtime/node/storage.js +5 -0
  57. package/dist/browser/runtime/node/storage.js.map +1 -1
  58. package/dist/browser/runtime/node/util.d.ts +4 -6
  59. package/dist/browser/runtime/node/util.js +32 -278
  60. package/dist/browser/runtime/node/util.js.map +1 -1
  61. package/dist/browser/schema/schema-util.js +18 -4
  62. package/dist/browser/schema/schema-util.js.map +1 -1
  63. package/dist/browser/signer/author-wallet-proof.d.ts +19 -0
  64. package/dist/browser/signer/author-wallet-proof.js +89 -0
  65. package/dist/browser/signer/author-wallet-proof.js.map +1 -0
  66. package/dist/browser/signer/signatures.js +29 -0
  67. package/dist/browser/signer/signatures.js.map +1 -1
  68. package/dist/browser/test/test-util.d.ts +12 -0
  69. package/dist/browser/test/test-util.js +23 -0
  70. package/dist/browser/test/test-util.js.map +1 -1
  71. package/dist/browser/unknown-props.d.ts +24 -0
  72. package/dist/browser/unknown-props.js +95 -0
  73. package/dist/browser/unknown-props.js.map +1 -0
  74. package/dist/browser/util.js +7 -0
  75. package/dist/browser/util.js.map +1 -1
  76. package/dist/browser/version.js +1 -1
  77. package/dist/bundled/bundle-manifest.json +66 -59
  78. package/dist/bundled/challenges.js +1 -1
  79. package/dist/bundled/chunks/{helia-for-pkc-CG9YohPs.js → helia-for-pkc-CceaAEzV.js} +4 -4
  80. package/dist/bundled/chunks/{local-community-V8_VyEhO.js → local-community-BzZbcwm-.js} +128 -57
  81. package/dist/bundled/chunks/{local-community-CaQmhX8D.js → local-community-C8Qwak8F.js} +1 -1
  82. package/dist/bundled/chunks/{node-c4vpD2VN.js → node-CleFjKjX.js} +161 -49
  83. package/dist/bundled/chunks/{page-sort-scoring-d1frahfd.js → page-sort-scoring-BAl6dNeR.js} +1 -1
  84. package/dist/bundled/chunks/{rpc-local-community-DDAibWpE.js → rpc-local-community-CW6GnMsd.js} +4482 -1673
  85. package/dist/bundled/chunks/{util-BwEIge-b.js → util-C0MpIK71.js} +62 -16
  86. package/dist/bundled/chunks/{util-B_dKP7Te.js → util-C29b1mlK.js} +1 -1
  87. package/dist/bundled/chunks/{validate-package-factories-DfpNf4oq.js → validate-package-factories-CAwF_8n6.js} +2 -2
  88. package/dist/bundled/index.js +1 -1
  89. package/dist/bundled/page-sorts.js +1 -1
  90. package/dist/bundled/rpc/src/index.js +5 -6
  91. package/dist/node/clients/rpc-client/schema.js +2 -2
  92. package/dist/node/clients/rpc-client/schema.js.map +1 -1
  93. package/dist/node/community/remote-community.js +8 -2
  94. package/dist/node/community/remote-community.js.map +1 -1
  95. package/dist/node/community/schema.js +4 -0
  96. package/dist/node/community/schema.js.map +1 -1
  97. package/dist/node/community-list/community-list.js +3 -2
  98. package/dist/node/community-list/community-list.js.map +1 -1
  99. package/dist/node/errors.d.ts +14 -0
  100. package/dist/node/errors.js +14 -0
  101. package/dist/node/errors.js.map +1 -1
  102. package/dist/node/generated-version.d.ts +1 -1
  103. package/dist/node/generated-version.js +1 -1
  104. package/dist/node/pkc/pkc.js +13 -4
  105. package/dist/node/pkc/pkc.js.map +1 -1
  106. package/dist/node/pkc-error.d.ts +1 -1
  107. package/dist/node/publications/comment/comment.js +25 -9
  108. package/dist/node/publications/comment/comment.js.map +1 -1
  109. package/dist/node/publications/comment/crosspost-runtime.js +10 -2
  110. package/dist/node/publications/comment/crosspost-runtime.js.map +1 -1
  111. package/dist/node/publications/comment/schema.d.ts +1 -1
  112. package/dist/node/publications/comment/schema.js +30 -1
  113. package/dist/node/publications/comment/schema.js.map +1 -1
  114. package/dist/node/publications/publication.d.ts +4 -0
  115. package/dist/node/publications/publication.js +135 -38
  116. package/dist/node/publications/publication.js.map +1 -1
  117. package/dist/node/rpc/src/index.js +3 -3
  118. package/dist/node/rpc/src/index.js.map +1 -1
  119. package/dist/node/runtime/browser/util.d.ts +3 -1
  120. package/dist/node/runtime/browser/util.js +8 -2
  121. package/dist/node/runtime/browser/util.js.map +1 -1
  122. package/dist/node/runtime/node/blockstore.d.ts +2 -2
  123. package/dist/node/runtime/node/blockstore.js +2 -2
  124. package/dist/node/runtime/node/community/challenges/validate-challenge-result.js +2 -1
  125. package/dist/node/runtime/node/community/challenges/validate-challenge-result.js.map +1 -1
  126. package/dist/node/runtime/node/community/communities-registry.d.ts +96 -0
  127. package/dist/node/runtime/node/community/communities-registry.js +964 -0
  128. package/dist/node/runtime/node/community/communities-registry.js.map +1 -0
  129. package/dist/node/runtime/node/community/db-handler.d.ts +3 -0
  130. package/dist/node/runtime/node/community/db-handler.js +82 -35
  131. package/dist/node/runtime/node/community/db-handler.js.map +1 -1
  132. package/dist/node/runtime/node/community/local-community/editing.js +16 -8
  133. package/dist/node/runtime/node/community/local-community/editing.js.map +1 -1
  134. package/dist/node/runtime/node/community/local-community/lifecycle.js +68 -19
  135. package/dist/node/runtime/node/community/local-community/lifecycle.js.map +1 -1
  136. package/dist/node/runtime/node/community/local-community/publication-validation.d.ts +1 -2
  137. package/dist/node/runtime/node/community/local-community/publication-validation.js +23 -0
  138. package/dist/node/runtime/node/community/local-community/publication-validation.js.map +1 -1
  139. package/dist/node/runtime/node/community/local-community.d.ts +2 -1
  140. package/dist/node/runtime/node/community/local-community.js +5 -9
  141. package/dist/node/runtime/node/community/local-community.js.map +1 -1
  142. package/dist/node/runtime/node/community/pkc-instance-lock.d.ts +17 -0
  143. package/dist/node/runtime/node/community/pkc-instance-lock.js +142 -0
  144. package/dist/node/runtime/node/community/pkc-instance-lock.js.map +1 -0
  145. package/dist/node/runtime/node/storage.js +5 -0
  146. package/dist/node/runtime/node/storage.js.map +1 -1
  147. package/dist/node/runtime/node/util.d.ts +4 -6
  148. package/dist/node/runtime/node/util.js +32 -278
  149. package/dist/node/runtime/node/util.js.map +1 -1
  150. package/dist/node/schema/schema-util.js +18 -4
  151. package/dist/node/schema/schema-util.js.map +1 -1
  152. package/dist/node/signer/author-wallet-proof.d.ts +19 -0
  153. package/dist/node/signer/author-wallet-proof.js +89 -0
  154. package/dist/node/signer/author-wallet-proof.js.map +1 -0
  155. package/dist/node/signer/signatures.js +29 -0
  156. package/dist/node/signer/signatures.js.map +1 -1
  157. package/dist/node/test/test-util.d.ts +12 -0
  158. package/dist/node/test/test-util.js +23 -0
  159. package/dist/node/test/test-util.js.map +1 -1
  160. package/dist/node/unknown-props.d.ts +24 -0
  161. package/dist/node/unknown-props.js +95 -0
  162. package/dist/node/unknown-props.js.map +1 -0
  163. package/dist/node/util.js +7 -0
  164. package/dist/node/util.js.map +1 -1
  165. package/dist/node/version.js +1 -1
  166. package/package.json +3 -2
  167. package/dist/browser/runtime/node/community/start-lock.d.ts +0 -17
  168. package/dist/browser/runtime/node/community/start-lock.js +0 -161
  169. package/dist/browser/runtime/node/community/start-lock.js.map +0 -1
  170. package/dist/node/runtime/node/community/start-lock.d.ts +0 -17
  171. package/dist/node/runtime/node/community/start-lock.js +0 -161
  172. package/dist/node/runtime/node/community/start-lock.js.map +0 -1
@@ -1,7 +1,7 @@
1
1
  import { i as __toESM, r as __require, t as __commonJSMin } from "./chunk-2rV9d50f.js";
2
- import { $ as retryKuboIpfsAdd, At as ChallengeAnswerMessageSchema, C as hideClassPrivateProps, D as isIpfsCid, Dt as require_sha256, E as isAbortError, Et as untrackUpdatingCommunity, Hr as setErrorMap, In as CommentUpdateForChallengeVerificationSchema, Ir as FailedToFetchPageIpfsFromGatewaysError, It as ChallengeVerificationMessageSchema, Jt as version_default, Lr as PKCError, Mr as FailedToFetchCommentIpfsFromGatewaysError, Mt as ChallengeMessageSchema, Nr as FailedToFetchCommentUpdateFromGatewaysError, Ot as TimeoutError, Pt as ChallengeRequestMessageSchema, Rr as messages, Sr as e$1, St as trackUpdatingComment, T as ipnsNameToIpnsOverPubsubTopic, Tt as untrackUpdatingComment, U as rejectWhenAbortSignalFires, W as rejectWhenCommunityStopsOrAborts, X as replaceXWithY, Y as removeUndefinedValuesRecursively, Z as resolveWhenPredicateIsTrue, _t as listUpdatingCommunities, a as calculateStringSizeSameAsIpfsAddCidV0Sync, at as throwIfAbortSignalAborted, br as t$1, cn as CommunityAnchorSchema, d as deepMergeRuntimeFields, dt as findStartedCommunity, et as retryKuboIpfsAddAndProvide, ft as findUpdatingComment, gr as n$2, gt as listUpdatingComments, hr as isStringDomain, ht as listStartedCommunities, i as calculateStringSizeSameAsIpfsAddCidV0, jn as CommentIpfsSchema, jr as require_retry$1, k as isIpns, kt as pTimeout, ni as en_default, nt as shortifyCid, ot as timestamp, p as doesDomainAddressHaveCapitalLetter, pn as CommunityIpfsSchema, pt as findUpdatingCommunity, r as calculateIpfsCidV0, rt as sleepUntilTimeoutOrAbort, st as waitForUpdateInCommunityInstanceWithErrorAndTimeout, tt as shortifyAddress, u as createAbortError, vr as n$1, vt as refreshTrackedCommentAliases, wr as r, x as getPostUpdateTimestampRange, xn as PubsubTopicSchema, xr as e, z as linkAbortSignals, zn as CommentUpdateSchema, zr as logger_default } from "./util-BwEIge-b.js";
3
- import { $n as buildRuntimeCommunityFields, $r as NAME_RESOLVE_FAILED_RETRY_FLOOR_MS, $t as RpcPublishCommunityListParamSchema, A as findCommentInParsedPages, At as parseRpcCommentUpdateEventWithPKCErrorIfItFails, B as GenericStateClient, Bn as verifyCommunityEdit, Bt as RpcCommunityIdentifierParamSchema, C as RepliesPages, Cn as signCommentModeration, Cr as getDefaultDataPath, Ct as parseCreateVoteOptionsSchemaWithPKCErrorIfItFails, D as extractCommunityRuntimeFieldsFromParsedPages, Dn as signCommunityEdit, Dr as monitorCommunitiesDirectory, Dt as parseJsonWithPKCErrorIfFails, Er as listCommunitiesSync, Et as parseDecryptedChallengeWithPKCErrorIfItFails, F as cloneCrosspostForRuntime, Fn as verifyCommentIpfs, Fr as toCommunitiesEntry, Ft as RpcAuthorNameParamSchema, G as PKCTypedEmitter, Gn as getAuthorNameFromRuntime, Gr as n$3, Gt as RpcExportCommunityParamSchema, H as InflightResourceTypes, Hn as verifyVote, Ht as RpcEditCommunityParamSchema, I as collectCrosspostAuthorsToResolve, In as verifyCommentModeration, It as RpcCancelExportParamSchema, J as decodeRpcChallengeRequestPubsubMsg, Jn as CreateCommunityListWithCidOptionsSchema, Jr as t$4, Jt as RpcFetchCidResultSchema, K as decodeRpcChallengeAnswerPubsubMsg, Kn as getAuthorNameFromWire, Kt as RpcExportCommunityResultSchema, Ln as verifyCommentPubsubMessage, Lt as RpcCidParamSchema, M as parseRawPages, Mr as setNativeFunctions$1, Nn as verifyChallengeVerification, Nr as tryToDeleteCommunitiesThatFailedToBeDeletedBefore, Nt as parseVotePubsubMessagePublicationSchemaWithPKCErrorIfItFails, O as findCommentInPageInstance, On as signCommunityList, Ot as parsePKCUserOptionsSchemaWithPKCErrorIfItFails, P as applyNameResolvedCacheToCrosspost, Pn as verifyCommentEdit, Pr as findCommunitiesEntry, Pt as RpcAnchorPublishPreparationResultSchema, Qr as NAME_RESOLVED_TRUE_TTL_MS, Qt as RpcPublishChallengeAnswersParamSchema, R as stripNameResolvedFromCrosspost, Rn as verifyCommentUpdate, Rt as RpcCommentRepliesPageParamSchema, Sn as signCommentEdit, St as parseCreateRpcCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, Tt as parseDecryptedChallengeVerification, Un as buildRuntimeAuthor, Ut as RpcExportCommunityModLogsParamSchema, V as InflightFetchManager, Vn as verifyCommunityList, Vr as t$5, Vt as RpcCommunityPageParamSchema, Wn as cleanWireAuthor, Wr as t$3, Wt as RpcExportCommunityModLogsResultSchema, Xn as MAX_COMMUNITY_LIST_SIZE_BYTES, Xr as MAX_FILE_SIZE_BYTES_FOR_COMMENT_UPDATE, Xt as RpcFetchCommunityListResultSchema, Y as decodeRpcChallengeVerificationPubsubMsg, Yn as CreateNewCommunityListOptionsSchema, Yt as RpcFetchCommunityListParamSchema, Zr as NAME_RESOLVED_FALSE_TTL_MS, Zt as RpcPublishAnchorRecordParamSchema, _n as signChallengeAnswer, _t as parseCreateCommentOptionsSchemaWithPKCErrorIfItFails, an as RpcUnsubscribeParamSchema, b as KeyvBetterSqlite3, br as findLocalCommunityAddress, ct as parseCommentUpdateSchemaWithPKCErrorIfItFails, dn as decryptEd25519AesGcm, en as RpcPublishCommunityListResultSchema, er as getCommunityAddressFromRecord, et as parseCidStringSchemaWithPKCErrorIfItFails, ft as parseCommunityEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, gn as cleanUpBeforePublishing, gt as parseCreateCommentModerationOptionsSchemaWithPKCErrorIfItFails, hr as createKuboRpcClient, ht as parseCreateCommentEditOptionsSchemaWithPKCErrorIfItFails, in as RpcSuccessResultSchema, ir as decode, it as parseCommentIpfsSchemaWithPKCErrorIfItFails, jn as verifyChallengeMessage, jt as parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, k as findCommentInPageInstanceRecursively, kn as signVote, kt as parseRpcCommentEventWithPKCErrorIfItFails, l as pkcJsPageSorts, ln as createSigner, lr as getPKCAddressFromPublicKeySync, lt as parseCommunityAddressWithPKCErrorIfItFails, m as pkcJsChallenges, mt as parseCommunityListSchemaWithPKCErrorIfItFails, n as RpcRemoteCommunity, ni as nativeFunctions$2, nn as RpcResolveAuthorNameResultSchema, nr as getCommunityPublicKeyFromWire, on as findCommunityRecordNameMismatch, or as getBufferedPKCAddressFromPublicKey, ot as parseCommentModerationPubsubMessagePublicationSchemaWithPKCErrorIfItFails, pn as encryptEd25519AesGcm, q as decodeRpcChallengePubsubMsg, qn as normalizeCreatePublicationAuthor, qr as t$2, qt as RpcFetchCidParamSchema, rn as RpcSubscriptionIdResultSchema, rr as normalizeCommunityInputFromCommunity, rt as parseCommentEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, sn as require_lib$1, st as parseCommentPubsubMessagePublicationWithPKCErrorIfItFails, t as RpcLocalCommunity, tn as RpcPublishedAnchorRecordResultSchema, tr as getCommunityNameFromWire, un as createAnchorIpnsRecord$1, v as TrackedInstanceRegistry, vt as parseCreateCommunityEditPublicationOptionsSchemaWithPKCErrorIfItFails, wt as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, x as RemoteCommunity, xn as signComment, xt as parseCreateRemoteCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, y as LRUCache, yn as signChallengeRequest, z as PKCClientsManager, zt as RpcCommunitiesChangeEventResultSchema } from "./rpc-local-community-DDAibWpE.js";
4
- import { s as getHeliaDebugContext } from "./util-B_dKP7Te.js";
2
+ import { $ as retryKuboIpfsAdd, At as ChallengeAnswerMessageSchema, Br as messages, C as hideClassPrivateProps, Cr as e, D as isIpfsCid, Dt as require_sha256, E as isAbortError, Er as r, Et as untrackUpdatingCommunity, Fr as FailedToFetchCommentUpdateFromGatewaysError, In as CommentUpdateForChallengeVerificationSchema, It as ChallengeVerificationMessageSchema, Jt as version_default, Mt as ChallengeMessageSchema, Nr as require_retry$1, Ot as TimeoutError, Pr as FailedToFetchCommentIpfsFromGatewaysError, Pt as ChallengeRequestMessageSchema, Rr as FailedToFetchPageIpfsFromGatewaysError, Sr as t$1, St as trackUpdatingComment, T as ipnsNameToIpnsOverPubsubTopic, Tt as untrackUpdatingComment, U as rejectWhenAbortSignalFires, Vr as logger_default, W as rejectWhenCommunityStopsOrAborts, Wr as setErrorMap, X as replaceXWithY, Y as removeUndefinedValuesRecursively, Z as resolveWhenPredicateIsTrue, _t as listUpdatingCommunities, a as calculateStringSizeSameAsIpfsAddCidV0Sync, at as throwIfAbortSignalAborted, br as n$1, cn as CommunityAnchorSchema, d as deepMergeRuntimeFields, dt as findStartedCommunity, et as retryKuboIpfsAddAndProvide, ft as findUpdatingComment, gr as isStringDomain, gt as listUpdatingComments, ht as listStartedCommunities, i as calculateStringSizeSameAsIpfsAddCidV0, ii as en_default, jn as CommentIpfsSchema, k as isIpns, kt as pTimeout, nt as shortifyCid, ot as timestamp, p as doesDomainAddressHaveCapitalLetter, pn as CommunityIpfsSchema, pt as findUpdatingCommunity, r as calculateIpfsCidV0, rt as sleepUntilTimeoutOrAbort, st as waitForUpdateInCommunityInstanceWithErrorAndTimeout, tt as shortifyAddress, u as createAbortError, vr as n$2, vt as refreshTrackedCommentAliases, wr as e$1, x as getPostUpdateTimestampRange, xn as PubsubTopicSchema, z as linkAbortSignals, zn as CommentUpdateSchema, zr as PKCError } from "./util-C0MpIK71.js";
3
+ import { $r as t$2, $t as RpcPublishCommunityListParamSchema, A as findCommentInParsedPages, An as signVote, At as parseRpcCommentUpdateEventWithPKCErrorIfItFails, B as GenericStateClient, Br as tryToDeleteCommunitiesThatFailedToBeDeletedBefore, Bt as RpcCommunityIdentifierParamSchema, C as RepliesPages, Cn as signCommentEdit, Ct as parseCreateVoteOptionsSchemaWithPKCErrorIfItFails, D as extractCommunityRuntimeFieldsFromParsedPages, Dt as parseJsonWithPKCErrorIfFails, Er as findLocalCommunityAddress, Et as parseDecryptedChallengeWithPKCErrorIfItFails, F as cloneCrosspostForRuntime, Fn as verifyCommentEdit, Ft as RpcAuthorNameParamSchema, G as PKCTypedEmitter, Gr as toCommunitiesEntry, Gt as RpcExportCommunityParamSchema, H as InflightResourceTypes, Hn as verifyCommunityList, Ht as RpcEditCommunityParamSchema, I as collectCrosspostAuthorsToResolve, In as verifyCommentIpfs, Ir as registerLocalCommunity, It as RpcCancelExportParamSchema, J as decodeRpcChallengeRequestPubsubMsg, Jn as buildRuntimeAuthor, Jt as RpcFetchCidResultSchema, K as decodeRpcChallengeAnswerPubsubMsg, Kn as mergeAuthorProps, Kt as RpcExportCommunityResultSchema, Ln as verifyCommentModeration, Lt as RpcCidParamSchema, M as parseRawPages, Mn as verifyChallengeMessage, Mr as isLocalCommunityAddress, Nr as markLocalCommunityDbAsBeingWritten, Nt as parseVotePubsubMessagePublicationSchemaWithPKCErrorIfItFails, O as findCommentInPageInstance, On as signCommunityEdit, Ot as parsePKCUserOptionsSchemaWithPKCErrorIfItFails, P as applyNameResolvedCacheToCrosspost, Pn as verifyChallengeVerification, Pr as monitorCommunitiesDirectory, Pt as RpcAnchorPublishPreparationResultSchema, Qn as normalizeCreatePublicationAuthor, Qt as RpcPublishChallengeAnswersParamSchema, R as stripNameResolvedFromCrosspost, Rn as verifyCommentPubsubMessage, Rt as RpcCommentRepliesPageParamSchema, Sn as signComment, St as parseCreateRpcCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, Tt as parseDecryptedChallengeVerification, Un as verifyVote, Ut as RpcExportCommunityModLogsParamSchema, V as InflightFetchManager, Vn as verifyCommunityEdit, Vt as RpcCommunityPageParamSchema, Wn as assignUnknownProps, Wr as findCommunitiesEntry, Wt as RpcExportCommunityModLogsResultSchema, Xn as getAuthorNameFromRuntime, Xr as t$3, Xt as RpcFetchCommunityListResultSchema, Y as decodeRpcChallengeVerificationPubsubMsg, Yn as cleanWireAuthor, Yt as RpcFetchCommunityListParamSchema, Zn as getAuthorNameFromWire, Zr as n$3, Zt as RpcPublishAnchorRecordParamSchema, _n as cleanUpBeforePublishing, _t as parseCreateCommentOptionsSchemaWithPKCErrorIfItFails, an as RpcUnsubscribeParamSchema, ar as buildRuntimeCommunityFields, b as KeyvBetterSqlite3, bn as signChallengeRequest, cn as require_lib$1, cr as getCommunityPublicKeyFromWire, ct as parseCommentUpdateSchemaWithPKCErrorIfItFails, dn as createAnchorIpnsRecord$1, ei as t$4, en as RpcPublishCommunityListResultSchema, er as CreateCommunityListWithCidOptionsSchema, et as parseCidStringSchemaWithPKCErrorIfItFails, fn as decryptEd25519AesGcm, fr as getBufferedPKCAddressFromPublicKey, ft as parseCommunityEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, gt as parseCreateCommentModerationOptionsSchemaWithPKCErrorIfItFails, hr as getPKCAddressFromPublicKeySync, ht as parseCreateCommentEditOptionsSchemaWithPKCErrorIfItFails, ii as NAME_RESOLVE_FAILED_RETRY_FLOOR_MS, in as RpcSuccessResultSchema, it as parseCommentIpfsSchemaWithPKCErrorIfItFails, jt as parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, k as findCommentInPageInstanceRecursively, kn as signCommunityList, kr as getDefaultDataPath, kt as parseRpcCommentEventWithPKCErrorIfItFails, l as pkcJsPageSorts, lr as normalizeCommunityInputFromCommunity, lt as parseCommunityAddressWithPKCErrorIfItFails, m as pkcJsChallenges, mn as encryptEd25519AesGcm, mt as parseCommunityListSchemaWithPKCErrorIfItFails, n as RpcRemoteCommunity, ni as NAME_RESOLVED_FALSE_TTL_MS, nn as RpcResolveAuthorNameResultSchema, nr as MAX_COMMUNITY_LIST_SIZE_BYTES, on as findCommunityRecordNameMismatch, or as getCommunityAddressFromRecord, ot as parseCommentModerationPubsubMessagePublicationSchemaWithPKCErrorIfItFails, q as decodeRpcChallengePubsubMsg, qn as withoutForbiddenKeys, qr as t$5, qt as RpcFetchCidParamSchema, ri as NAME_RESOLVED_TRUE_TTL_MS, rn as RpcSubscriptionIdResultSchema, rt as parseCommentEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, si as nativeFunctions$2, sn as verifyAuthorWalletEntry, sr as getCommunityNameFromWire, st as parseCommentPubsubMessagePublicationWithPKCErrorIfItFails, t as RpcLocalCommunity, ti as MAX_FILE_SIZE_BYTES_FOR_COMMENT_UPDATE, tn as RpcPublishedAnchorRecordResultSchema, tr as CreateNewCommunityListOptionsSchema, un as createSigner, ur as decode, v as TrackedInstanceRegistry, vn as signChallengeAnswer, vt as parseCreateCommunityEditPublicationOptionsSchemaWithPKCErrorIfItFails, wn as signCommentModeration, wt as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, x as RemoteCommunity, xr as createKuboRpcClient, xt as parseCreateRemoteCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, y as LRUCache, z as PKCClientsManager, zn as verifyCommentUpdate, zr as setNativeFunctions$1, zt as RpcCommunitiesChangeEventResultSchema } from "./rpc-local-community-CW6GnMsd.js";
4
+ import { s as getHeliaDebugContext } from "./util-C29b1mlK.js";
5
5
  import path from "path";
6
6
  import assert from "assert";
7
7
  import fs from "fs";
@@ -27382,7 +27382,7 @@ var Publication = class extends import_lib.TypedEmitter {
27382
27382
  this._updatePublishingStateWithEmission("stopped");
27383
27383
  this._setStateWithEmission("stopped");
27384
27384
  this._initClients();
27385
- this._handleChallengeExchange = this._handleChallengeExchange.bind(this);
27385
+ this._handleChallengeExchange = this._guardDetachedHandler("_handleChallengeExchange", this._handleChallengeExchange.bind(this));
27386
27386
  this.publish = this.publish.bind(this);
27387
27387
  this.on("error", (...args) => this.listenerCount("error") === 1 && this._pkc.emit("error", ...args));
27388
27388
  this._publishToDifferentProviderThresholdSeconds = 10;
@@ -27409,10 +27409,16 @@ var Publication = class extends import_lib.TypedEmitter {
27409
27409
  author: props.author,
27410
27410
  signaturePublicKey: props.signature.publicKey
27411
27411
  });
27412
- this.author = {
27413
- ...runtimeAuthor,
27414
- shortAddress: shortifyAddress(runtimeAuthor.address)
27415
- };
27412
+ const author = {};
27413
+ const { skipped } = mergeAuthorProps({
27414
+ target: author,
27415
+ props: {
27416
+ ...runtimeAuthor,
27417
+ shortAddress: shortifyAddress(runtimeAuthor.address)
27418
+ }
27419
+ });
27420
+ if (skipped.length > 0) logger_default("pkc-js:publication:_initAuthor").error("Refused author props of a record that collide with an object", skipped);
27421
+ this.author = author;
27416
27422
  this.protocolVersion = props.protocolVersion;
27417
27423
  }
27418
27424
  _initUnsignedLocalProps(opts) {
@@ -27497,18 +27503,21 @@ var Publication = class extends import_lib.TypedEmitter {
27497
27503
  await this._tearDownThenWriteFailure(e);
27498
27504
  return;
27499
27505
  }
27500
- if (this instanceof Comment && runtimeFields) deepMergeRuntimeFields(this, runtimeFields);
27501
- this._setRpcClientState("stopped");
27502
- const newPublishingState = verification.challengeSuccess ? "succeeded" : "failed";
27503
- this._changePublicationStateEmitEventEmitStateChangeEvent({
27504
- newPublishingState,
27505
- newState: "stopped",
27506
- event: {
27507
- name: "challengeverification",
27508
- args: [verification, this instanceof Comment && verification.comment ? this : void 0]
27509
- }
27510
- });
27511
- await this._postSucessOrFailurePublishing();
27506
+ try {
27507
+ if (this instanceof Comment && runtimeFields) deepMergeRuntimeFields(this, runtimeFields);
27508
+ this._setRpcClientState("stopped");
27509
+ const newPublishingState = verification.challengeSuccess ? "succeeded" : "failed";
27510
+ this._changePublicationStateEmitEventEmitStateChangeEvent({
27511
+ newPublishingState,
27512
+ newState: "stopped",
27513
+ event: {
27514
+ name: "challengeverification",
27515
+ args: [verification, this instanceof Comment && verification.comment ? this : void 0]
27516
+ }
27517
+ });
27518
+ } finally {
27519
+ await this._tearDownWithoutThrowing();
27520
+ }
27512
27521
  }
27513
27522
  async _handleIncomingChallengePubsubMessage(msg) {
27514
27523
  const log = logger_default("pkc-js:publication:_handleIncomingChallengePubsubMessage");
@@ -27677,16 +27686,19 @@ var Publication = class extends import_lib.TypedEmitter {
27677
27686
  }
27678
27687
  log("Updated the props of this instance with challengeverification.encrypted");
27679
27688
  }
27680
- Object.values(this._challengeExchanges).forEach((exchange) => this._updatePubsubState("stopped", exchange.providerUrl));
27681
- this._changePublicationStateEmitEventEmitStateChangeEvent({
27682
- newPublishingState,
27683
- newState: "stopped",
27684
- event: {
27685
- name: "challengeverification",
27686
- args: [challengeVerificationMsg, this instanceof Comment && decryptedChallengeVerification ? this : void 0]
27687
- }
27688
- });
27689
- await this._postSucessOrFailurePublishing();
27689
+ try {
27690
+ Object.values(this._challengeExchanges).forEach((exchange) => this._updatePubsubState("stopped", exchange.providerUrl));
27691
+ this._changePublicationStateEmitEventEmitStateChangeEvent({
27692
+ newPublishingState,
27693
+ newState: "stopped",
27694
+ event: {
27695
+ name: "challengeverification",
27696
+ args: [challengeVerificationMsg, this instanceof Comment && decryptedChallengeVerification ? this : void 0]
27697
+ }
27698
+ });
27699
+ } finally {
27700
+ await this._tearDownWithoutThrowing();
27701
+ }
27690
27702
  }
27691
27703
  async _endExchangeWithUnreadableChallengeVerification({ verification, error }) {
27692
27704
  const exchange = this._challengeExchanges[verification.challengeRequestId.toString()];
@@ -27714,7 +27726,7 @@ var Publication = class extends import_lib.TypedEmitter {
27714
27726
  return writeFailure();
27715
27727
  }
27716
27728
  async _tearDownThenWriteFailure(error) {
27717
- await this._postSucessOrFailurePublishing();
27729
+ await this._tearDownWithoutThrowing();
27718
27730
  this._changePublicationStateEmitEventEmitStateChangeEvent({
27719
27731
  newPublishingState: "failed",
27720
27732
  event: {
@@ -27875,6 +27887,27 @@ var Publication = class extends import_lib.TypedEmitter {
27875
27887
  communityAddress: this.communityAddress
27876
27888
  });
27877
27889
  }
27890
+ _validateAuthorWalletProofs() {
27891
+ const signed = this.raw.pubsubMessageToPublish;
27892
+ const wallets = signed?.author?.wallets;
27893
+ if (!wallets || !signed?.signature?.publicKey) return;
27894
+ const authorPublicKey = getPKCAddressFromPublicKeySync(signed.signature.publicKey);
27895
+ for (const [chainTicker, entry] of Object.entries(wallets)) {
27896
+ const result = verifyAuthorWalletEntry({
27897
+ entry,
27898
+ authorPublicKey,
27899
+ nowSeconds: timestamp()
27900
+ });
27901
+ if (result.outcome === "invalid") {
27902
+ if (this.state === "publishing") this._setStateWithEmission("stopped");
27903
+ throw new PKCError("ERR_AUTHOR_WALLET_PROOF_IS_INVALID", {
27904
+ chainTicker,
27905
+ reason: result.reason,
27906
+ entry
27907
+ });
27908
+ }
27909
+ }
27910
+ }
27878
27911
  _validateCommunityFields() {
27879
27912
  if (typeof this._community?.encryption?.publicKey !== "string") throw new PKCError("ERR_COMMUNITY_MISSING_FIELD", { communityPublicKey: this._community?.encryption?.publicKey });
27880
27913
  }
@@ -28065,6 +28098,50 @@ var Publication = class extends import_lib.TypedEmitter {
28065
28098
  if (refresh) refresh.finally(() => this._pkc._publishingPublications.delete(this));
28066
28099
  else this._pkc._publishingPublications.delete(this);
28067
28100
  }
28101
+ _guardDetachedHandler(entryPoint, handler) {
28102
+ return async (...args) => {
28103
+ try {
28104
+ await handler(...args);
28105
+ } catch (e) {
28106
+ await this._endPublicationAfterDetachedFailure(entryPoint, e);
28107
+ }
28108
+ };
28109
+ }
28110
+ async _endPublicationAfterDetachedFailure(entryPoint, cause) {
28111
+ const log = logger_default("pkc-js:publication:_endPublicationAfterDetachedFailure");
28112
+ log.error(`Handler ${entryPoint} of a publication threw`, cause);
28113
+ const error = new PKCError("ERR_PUBLICATION_INTERNAL_ERROR", {
28114
+ entryPoint,
28115
+ cause
28116
+ });
28117
+ const endedBefore = this._publishEndedBy;
28118
+ const failsThePublication = this._claimPublishEnd("failure");
28119
+ try {
28120
+ if (failsThePublication) {
28121
+ try {
28122
+ await this._postSucessOrFailurePublishing();
28123
+ } catch (teardownError) {
28124
+ log.error(`Teardown after the failure of ${entryPoint} threw as well`, teardownError);
28125
+ }
28126
+ this._changePublicationStateEmitEventEmitStateChangeEvent({
28127
+ newPublishingState: "failed",
28128
+ event: {
28129
+ name: "error",
28130
+ args: [error]
28131
+ }
28132
+ });
28133
+ } else if (endedBefore !== "stop") this.emit("error", error);
28134
+ } catch (emitError) {
28135
+ log.error(`Could not report the failure of ${entryPoint}`, emitError);
28136
+ }
28137
+ }
28138
+ async _tearDownWithoutThrowing() {
28139
+ try {
28140
+ await this._postSucessOrFailurePublishing();
28141
+ } catch (teardownError) {
28142
+ logger_default("pkc-js:publication:_tearDownWithoutThrowing").error("The teardown that ends the publish threw", teardownError);
28143
+ }
28144
+ }
28068
28145
  async _postSucessOrFailurePublishing() {
28069
28146
  const log = logger_default("pkc-js:publication:_postSucessOrFailurePublishing");
28070
28147
  this._publishRunAbortController?.abort();
@@ -28182,7 +28259,7 @@ var Publication = class extends import_lib.TypedEmitter {
28182
28259
  rpcClient.attachSubscriptionHandlersDeferred({
28183
28260
  subscriptionId,
28184
28261
  isStale: () => this._rpcPublishSubscriptionId !== subscriptionId,
28185
- attach: (subscription) => subscription.on("challengerequest", unlessStopped(this._handleIncomingChallengeRequestFromRpc.bind(this))).on("challenge", unlessStopped(this._handleIncomingChallengeFromRpc.bind(this))).on("challengeanswer", unlessStopped(this._handleIncomingChallengeAnswerFromRpc.bind(this))).on("challengeverification", unlessStopped(this._handleIncomingChallengeVerificationFromRpc.bind(this))).on("publishingstatechange", unlessStopped(this._handleIncomingPublishingStateFromRpc.bind(this))).on("statechange", unlessStopped(this._handleIncomingStateFromRpc.bind(this))).on("error", unlessStopped(this._handleIncomingErrorFromRpc.bind(this))),
28262
+ attach: (subscription) => subscription.on("challengerequest", unlessStopped(this._guardDetachedHandler("_handleIncomingChallengeRequestFromRpc", this._handleIncomingChallengeRequestFromRpc.bind(this)))).on("challenge", unlessStopped(this._guardDetachedHandler("_handleIncomingChallengeFromRpc", this._handleIncomingChallengeFromRpc.bind(this)))).on("challengeanswer", unlessStopped(this._guardDetachedHandler("_handleIncomingChallengeAnswerFromRpc", this._handleIncomingChallengeAnswerFromRpc.bind(this)))).on("challengeverification", unlessStopped(this._guardDetachedHandler("_handleIncomingChallengeVerificationFromRpc", this._handleIncomingChallengeVerificationFromRpc.bind(this)))).on("publishingstatechange", unlessStopped(this._guardDetachedHandler("_handleIncomingPublishingStateFromRpc", this._handleIncomingPublishingStateFromRpc.bind(this)))).on("statechange", unlessStopped(this._guardDetachedHandler("_handleIncomingStateFromRpc", this._handleIncomingStateFromRpc.bind(this)))).on("error", unlessStopped(this._guardDetachedHandler("_handleIncomingErrorFromRpc", this._handleIncomingErrorFromRpc.bind(this)))),
28186
28263
  replayErrorContainment: {
28187
28264
  entityName: "publication",
28188
28265
  log: logger_default("pkc-js:publication:publish:_publishWithRpc"),
@@ -28394,24 +28471,24 @@ var Publication = class extends import_lib.TypedEmitter {
28394
28471
  this._publishingToLocalCommunity = community;
28395
28472
  const log = logger_default("pkc-js:publication:publish:_publishWithLocalCommunity");
28396
28473
  log("Community is local, will not publish over pubsub, and instead will publish directly to the community by accessing pkc._startedCommunities");
28397
- const communityChallengeListener = async (challenge) => {
28474
+ const communityChallengeListener = this._guardDetachedHandler("communityChallengeListener", async (challenge) => {
28398
28475
  if (this._hasPublishEnded()) return;
28399
28476
  if (challenge.challengeRequestId.toString() === challengeRequest.challengeRequestId.toString()) {
28400
28477
  const encryptedFields = ["challenges"];
28401
28478
  log("Received a challenge from the local community", challenge);
28402
28479
  await this._handleIncomingChallengePubsubMessage(n$1(challenge, encryptedFields));
28403
28480
  }
28404
- };
28481
+ });
28405
28482
  community.on("challenge", communityChallengeListener);
28406
28483
  let verificationHandling;
28407
- const communityChallengeVerificationListener = async (decryptedChallengeVerification) => {
28484
+ const communityChallengeVerificationListener = this._guardDetachedHandler("communityChallengeVerificationListener", async (decryptedChallengeVerification) => {
28408
28485
  if (this._hasPublishEnded()) return;
28409
28486
  if (decryptedChallengeVerification.challengeRequestId.toString() === challengeRequest.challengeRequestId.toString()) {
28410
28487
  log("Received a challenge verification from the local community", decryptedChallengeVerification);
28411
28488
  verificationHandling = this._handleIncomingChallengeVerificationPubsubMessage(n$1(decryptedChallengeVerification, ["comment", "commentUpdate"]));
28412
28489
  await verificationHandling;
28413
28490
  }
28414
- };
28491
+ });
28415
28492
  community.on("challengeverification", communityChallengeVerificationListener);
28416
28493
  this.emit("challengerequest", challengeRequest);
28417
28494
  community.handleChallengeRequest(challengeRequest, true).then(() => {
@@ -28478,6 +28555,7 @@ var Publication = class extends import_lib.TypedEmitter {
28478
28555
  await this._signPublicationWithCommunityFields();
28479
28556
  }
28480
28557
  await this._validateSignatureHook();
28558
+ this._validateAuthorWalletProofs();
28481
28559
  if (this._hasPublishEnded()) return;
28482
28560
  this._isPublishSpent = true;
28483
28561
  if (this._pkc._pkcRpcClient) return this._publishWithRpc();
@@ -28567,6 +28645,7 @@ var Publication = class extends import_lib.TypedEmitter {
28567
28645
  acceptedChallengeTypes: options.acceptedChallengeTypes
28568
28646
  }).catch((err) => {
28569
28647
  log.error("Failed to handle not receiving response to challenge request", err);
28648
+ this._endPublicationAfterDetachedFailure("_handleNotReceivingResponseToChallengeRequest", err);
28570
28649
  });
28571
28650
  }
28572
28651
  };
@@ -29862,9 +29941,13 @@ var Comment = class extends Publication {
29862
29941
  this._initProps(props);
29863
29942
  const unknownProps = r(t$1(props), t$1(CommentIpfsSchema.shape));
29864
29943
  if (unknownProps.length > 0) {
29865
- const unknownPropsWithValues = t$5(props, unknownProps);
29866
- log(`Found unknown props on loaded CommentIpfs (cid: ${this.cid})`, unknownPropsWithValues, "Full props:", props, "Will set them on the Comment instance");
29867
- Object.assign(this, unknownPropsWithValues);
29944
+ log(`Found unknown props on loaded CommentIpfs (cid: ${this.cid})`, t$5(props, unknownProps), "Will set them on the Comment instance");
29945
+ const { skipped } = assignUnknownProps({
29946
+ target: this,
29947
+ record: props,
29948
+ knownKeys: t$1(CommentIpfsSchema.shape)
29949
+ });
29950
+ if (skipped.length > 0) log.error(`Refused unknown props of CommentIpfs (cid: ${this.cid}) that collide with the instance`, skipped);
29868
29951
  }
29869
29952
  this._setAuthorNameResolvedFromCache();
29870
29953
  }
@@ -29959,7 +30042,12 @@ var Comment = class extends Publication {
29959
30042
  const unknownProps = r(t$1(props), t$1(CommentUpdateSchema.shape));
29960
30043
  if (unknownProps.length > 0) {
29961
30044
  log("Found unknown props on CommentUpdate record", unknownProps, "Will set them on Comment instance");
29962
- Object.assign(this, t$5(props, unknownProps));
30045
+ const { skipped } = assignUnknownProps({
30046
+ target: this,
30047
+ record: props,
30048
+ knownKeys: t$1(CommentUpdateSchema.shape)
30049
+ });
30050
+ if (skipped.length > 0) log.error("Refused unknown props of CommentUpdate that collide with the instance", skipped);
29963
30051
  }
29964
30052
  }
29965
30053
  this.upvoteCount = props.upvoteCount;
@@ -29977,7 +30065,13 @@ var Comment = class extends Publication {
29977
30065
  this.protocolVersion = props.protocolVersion;
29978
30066
  this.spoiler = typeof props.spoiler === "boolean" ? props.spoiler : typeof props.edit?.spoiler === "boolean" ? props.edit?.spoiler : this.spoiler;
29979
30067
  this.nsfw = typeof props.nsfw === "boolean" ? props.nsfw : typeof props.edit?.nsfw === "boolean" ? props.edit?.nsfw : this.nsfw;
29980
- if (props.author) Object.assign(this.author, props.author);
30068
+ if (props.author) {
30069
+ const { skipped } = mergeAuthorProps({
30070
+ target: this.author,
30071
+ props: props.author
30072
+ });
30073
+ if (skipped.length > 0) logger_default("pkc-js:comment:_initCommentUpdate").error("Refused author props of CommentUpdate that collide with an object", skipped);
30074
+ }
29981
30075
  if (props.edit?.content) this.content = props.edit.content;
29982
30076
  this.flairs = props.flairs || props.edit?.flairs || this.flairs;
29983
30077
  this.author.flairs = props.author?.community?.flairs || props.edit?.author?.flairs || this.author?.flairs;
@@ -30116,7 +30210,13 @@ var Comment = class extends Publication {
30116
30210
  }
30117
30211
  _initCommentUpdateFromChallengeVerificationProps(commentUpdate) {
30118
30212
  this.raw.commentUpdateFromChallengeVerification = commentUpdate;
30119
- if (commentUpdate.author) Object.assign(this.author, commentUpdate.author);
30213
+ if (commentUpdate.author) {
30214
+ const { skipped } = mergeAuthorProps({
30215
+ target: this.author,
30216
+ props: commentUpdate.author
30217
+ });
30218
+ if (skipped.length > 0) logger_default("pkc-js:comment:_initCommentUpdateFromChallengeVerificationProps").error("Refused author props of the challenge verification that collide with an object", skipped);
30219
+ }
30120
30220
  this.protocolVersion = commentUpdate.protocolVersion;
30121
30221
  if ("pendingApproval" in commentUpdate) this.pendingApproval = commentUpdate.pendingApproval;
30122
30222
  else this.pendingApproval = false;
@@ -30131,7 +30231,12 @@ var Comment = class extends Publication {
30131
30231
  const unknownProps = r(t$1(decryptedVerification.commentUpdate), t$1(CommentUpdateForChallengeVerificationSchema.shape));
30132
30232
  if (unknownProps.length > 0) {
30133
30233
  log("Found unknown props on decryptedVerification.commentUpdate record", unknownProps, "Will set them on Comment instance");
30134
- Object.assign(this, t$5(decryptedVerification.commentUpdate, unknownProps));
30234
+ const { skipped } = assignUnknownProps({
30235
+ target: this,
30236
+ record: decryptedVerification.commentUpdate,
30237
+ knownKeys: t$1(CommentUpdateForChallengeVerificationSchema.shape)
30238
+ });
30239
+ if (skipped.length > 0) log.error("Refused unknown props of the challenge verification that collide with the instance", skipped);
30135
30240
  }
30136
30241
  this.emit("update", this);
30137
30242
  if (!this._pkc._pkcRpcClient) this._resolveAuthorNamesInBackground();
@@ -30865,6 +30970,7 @@ var Storage = class {
30865
30970
  dbFilePath = path.join(this._pkc.dataPath, "storage.db");
30866
30971
  }
30867
30972
  this._db = new Database(dbFilePath);
30973
+ if (dbFilePath !== ":memory:") this._db.pragma("journal_mode = WAL");
30868
30974
  this._keyv = new KeyvBetterSqlite3(this._db);
30869
30975
  this._keyv.on("error", (err) => {
30870
30976
  err.details = {
@@ -35841,14 +35947,14 @@ var CommunityList = class extends import_lib.TypedEmitter {
35841
35947
  _buildRuntimeEntry(entry) {
35842
35948
  const address = entry.name || entry.publicKey;
35843
35949
  return {
35844
- ...entry,
35950
+ ...withoutForbiddenKeys(entry),
35845
35951
  address,
35846
35952
  shortAddress: shortifyAddress(address)
35847
35953
  };
35848
35954
  }
35849
35955
  _buildRuntimeAuthor(wireAuthor, signaturePublicKey) {
35850
35956
  const runtimeAuthor = buildRuntimeAuthor({
35851
- author: wireAuthor,
35957
+ author: wireAuthor && withoutForbiddenKeys(wireAuthor),
35852
35958
  signaturePublicKey
35853
35959
  });
35854
35960
  return {
@@ -36277,7 +36383,7 @@ var PKC$1 = class extends PKCTypedEmitter {
36277
36383
  this.clients.libp2pJsClients = {};
36278
36384
  if (!this.libp2pJsClientsOptions) return;
36279
36385
  if (!this.httpRoutersOptions) throw Error("httpRoutersOptions is required for libp2pJsClient");
36280
- const { createLibp2pJsClientOrUseExistingOne } = await import("./helia-for-pkc-CG9YohPs.js");
36386
+ const { createLibp2pJsClientOrUseExistingOne } = await import("./helia-for-pkc-CceaAEzV.js");
36281
36387
  for (const clientOptions of this.libp2pJsClientsOptions) {
36282
36388
  const heliaNode = await createLibp2pJsClientOrUseExistingOne({
36283
36389
  ...clientOptions,
@@ -36654,8 +36760,8 @@ var PKC$1 = class extends PKCTypedEmitter {
36654
36760
  const log = logger_default("pkc-js:pkc:createLocalCommunity");
36655
36761
  log.trace("Received community options to create a local community instance:", options);
36656
36762
  if (!this._canCreateNewLocalCommunity()) throw new PKCError("ERR_CAN_NOT_CREATE_A_LOCAL_COMMUNITY", { pkcOptions: this._userPKCOptions });
36657
- const { LocalCommunity, createNewLocalCommunityDb, updateInstancePropsWithStartedCommunityOrDb } = await import("./local-community-CaQmhX8D.js");
36658
- const isLocalCommunity = (await listCommunitiesSync(this)).includes(options.address);
36763
+ const { LocalCommunity, createNewLocalCommunityDb, updateInstancePropsWithStartedCommunityOrDb } = await import("./local-community-C8Qwak8F.js");
36764
+ const isLocalCommunity = isLocalCommunityAddress(this, options.address);
36659
36765
  const community = new LocalCommunity(this);
36660
36766
  if (isLocalCommunity) {
36661
36767
  community.setAddress(options.address);
@@ -36666,7 +36772,13 @@ var PKC$1 = class extends PKCTypedEmitter {
36666
36772
  } else if ("signer" in options) {
36667
36773
  const parsedOptions = options;
36668
36774
  await community.initNewLocalCommunityPropsNoMerge(parsedOptions);
36669
- await createNewLocalCommunityDb(community);
36775
+ const doneWritingDbFile = markLocalCommunityDbAsBeingWritten(this, community.address);
36776
+ try {
36777
+ await createNewLocalCommunityDb(community);
36778
+ } finally {
36779
+ doneWritingDbFile();
36780
+ }
36781
+ registerLocalCommunity(this, community.address);
36670
36782
  log.trace(`Created a new local community (${community.address}) with props:`);
36671
36783
  community.emit("update", community);
36672
36784
  await this._awaitCommunitiesToIncludeCommunity(community.address);
@@ -1,4 +1,4 @@
1
- import { bn as PageSortFileSchema, hr as isStringDomain, v as getEquivalentCommunityAddresses } from "./util-BwEIge-b.js";
1
+ import { bn as PageSortFileSchema, gr as isStringDomain, v as getEquivalentCommunityAddresses } from "./util-C0MpIK71.js";
2
2
  //#region dist/node/pages/page-sort-scoring.js
3
3
  function validatePageSortFile(rawFile) {
4
4
  const validated = PageSortFileSchema.parse(rawFile);