@pkcprotocol/pkc-js 0.0.123 → 0.0.125

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 (114) hide show
  1. package/README.md +54 -54
  2. package/dist/browser/clients/rpc-client/pkc-rpc-client.d.ts +3 -1
  3. package/dist/browser/clients/rpc-client/pkc-rpc-client.js +18 -3
  4. package/dist/browser/clients/rpc-client/pkc-rpc-client.js.map +1 -1
  5. package/dist/browser/clients/rpc-client/rpc-schema-util.d.ts +16 -0
  6. package/dist/browser/clients/rpc-client/rpc-schema-util.js +6 -1
  7. package/dist/browser/clients/rpc-client/rpc-schema-util.js.map +1 -1
  8. package/dist/browser/clients/rpc-client/schema.d.ts +12 -0
  9. package/dist/browser/clients/rpc-client/schema.js +9 -0
  10. package/dist/browser/clients/rpc-client/schema.js.map +1 -1
  11. package/dist/browser/clients/rpc-client/types.d.ts +5 -1
  12. package/dist/browser/community-list/community-list.d.ts +143 -0
  13. package/dist/browser/community-list/community-list.js +401 -0
  14. package/dist/browser/community-list/community-list.js.map +1 -0
  15. package/dist/browser/community-list/schema.d.ts +239 -0
  16. package/dist/browser/community-list/schema.js +95 -0
  17. package/dist/browser/community-list/schema.js.map +1 -0
  18. package/dist/browser/community-list/types.d.ts +19 -0
  19. package/dist/browser/community-list/types.js +2 -0
  20. package/dist/browser/community-list/types.js.map +1 -0
  21. package/dist/browser/domain-util.d.ts +1 -0
  22. package/dist/browser/domain-util.js +10 -0
  23. package/dist/browser/domain-util.js.map +1 -1
  24. package/dist/browser/errors.d.ts +18 -1
  25. package/dist/browser/errors.js +18 -0
  26. package/dist/browser/errors.js.map +1 -1
  27. package/dist/browser/generated-version.d.ts +1 -1
  28. package/dist/browser/generated-version.js +1 -1
  29. package/dist/browser/index.d.ts +2 -0
  30. package/dist/browser/pkc/pkc-client-manager.d.ts +4 -1
  31. package/dist/browser/pkc/pkc-client-manager.js +6 -4
  32. package/dist/browser/pkc/pkc-client-manager.js.map +1 -1
  33. package/dist/browser/pkc/pkc.d.ts +7 -0
  34. package/dist/browser/pkc/pkc.js +93 -0
  35. package/dist/browser/pkc/pkc.js.map +1 -1
  36. package/dist/browser/pkc-error.d.ts +1 -1
  37. package/dist/browser/rpc/src/index.d.ts +3 -1
  38. package/dist/browser/rpc/src/index.js +45 -3
  39. package/dist/browser/rpc/src/index.js.map +1 -1
  40. package/dist/browser/runtime/node/community/local-community/author-identity.js +3 -3
  41. package/dist/browser/runtime/node/community/local-community/author-identity.js.map +1 -1
  42. package/dist/browser/schema/schema-util.d.ts +3 -0
  43. package/dist/browser/schema/schema-util.js +10 -0
  44. package/dist/browser/schema/schema-util.js.map +1 -1
  45. package/dist/browser/signer/signatures.d.ts +9 -0
  46. package/dist/browser/signer/signatures.js +30 -1
  47. package/dist/browser/signer/signatures.js.map +1 -1
  48. package/dist/browser/util.d.ts +1 -1
  49. package/dist/browser/util.js +3 -9
  50. package/dist/browser/util.js.map +1 -1
  51. package/dist/bundled/bundle-manifest.json +48 -44
  52. package/dist/bundled/challenges.js +1 -1
  53. package/dist/bundled/chunks/{helia-for-pkc-BtJGszgv.js → helia-for-pkc-DXygdFt-.js} +2 -2
  54. package/dist/bundled/chunks/{local-community-TY_gAkZm.js → local-community-Bbqx5IaD.js} +1 -1
  55. package/dist/bundled/chunks/{local-community-CAkggMcY.js → local-community-D4I0gLqX.js} +3 -3
  56. package/dist/bundled/chunks/{node-1HiEdVe5.js → node-oqffR7Bn.js} +423 -109
  57. package/dist/bundled/chunks/{page-sort-scoring-D6-geqGX.js → page-sort-scoring-CK4vshII.js} +1 -1
  58. package/dist/bundled/chunks/{rpc-local-community-ai5r92Ty.js → rpc-local-community-UpO9cs7k.js} +2253 -843
  59. package/dist/bundled/chunks/{util-BEHFLjBG.js → util-D3vx4Na0.js} +1 -1
  60. package/dist/bundled/chunks/{util-ZnZWh_jj.js → util-nmnnrzbz.js} +2709 -993
  61. package/dist/bundled/chunks/{validate-package-factories-BUhAFdOB.js → validate-package-factories-DkJmLpRe.js} +2 -2
  62. package/dist/bundled/index.js +1 -1
  63. package/dist/bundled/page-sorts.js +1 -1
  64. package/dist/bundled/rpc/src/index.js +31 -4
  65. package/dist/node/clients/rpc-client/pkc-rpc-client.d.ts +3 -1
  66. package/dist/node/clients/rpc-client/pkc-rpc-client.js +18 -3
  67. package/dist/node/clients/rpc-client/pkc-rpc-client.js.map +1 -1
  68. package/dist/node/clients/rpc-client/rpc-schema-util.d.ts +16 -0
  69. package/dist/node/clients/rpc-client/rpc-schema-util.js +6 -1
  70. package/dist/node/clients/rpc-client/rpc-schema-util.js.map +1 -1
  71. package/dist/node/clients/rpc-client/schema.d.ts +12 -0
  72. package/dist/node/clients/rpc-client/schema.js +9 -0
  73. package/dist/node/clients/rpc-client/schema.js.map +1 -1
  74. package/dist/node/clients/rpc-client/types.d.ts +5 -1
  75. package/dist/node/community-list/community-list.d.ts +143 -0
  76. package/dist/node/community-list/community-list.js +401 -0
  77. package/dist/node/community-list/community-list.js.map +1 -0
  78. package/dist/node/community-list/schema.d.ts +239 -0
  79. package/dist/node/community-list/schema.js +95 -0
  80. package/dist/node/community-list/schema.js.map +1 -0
  81. package/dist/node/community-list/types.d.ts +19 -0
  82. package/dist/node/community-list/types.js +2 -0
  83. package/dist/node/community-list/types.js.map +1 -0
  84. package/dist/node/domain-util.d.ts +1 -0
  85. package/dist/node/domain-util.js +10 -0
  86. package/dist/node/domain-util.js.map +1 -1
  87. package/dist/node/errors.d.ts +18 -1
  88. package/dist/node/errors.js +18 -0
  89. package/dist/node/errors.js.map +1 -1
  90. package/dist/node/generated-version.d.ts +1 -1
  91. package/dist/node/generated-version.js +1 -1
  92. package/dist/node/index.d.ts +2 -0
  93. package/dist/node/pkc/pkc-client-manager.d.ts +4 -1
  94. package/dist/node/pkc/pkc-client-manager.js +6 -4
  95. package/dist/node/pkc/pkc-client-manager.js.map +1 -1
  96. package/dist/node/pkc/pkc.d.ts +7 -0
  97. package/dist/node/pkc/pkc.js +93 -0
  98. package/dist/node/pkc/pkc.js.map +1 -1
  99. package/dist/node/pkc-error.d.ts +1 -1
  100. package/dist/node/rpc/src/index.d.ts +3 -1
  101. package/dist/node/rpc/src/index.js +45 -3
  102. package/dist/node/rpc/src/index.js.map +1 -1
  103. package/dist/node/runtime/node/community/local-community/author-identity.js +3 -3
  104. package/dist/node/runtime/node/community/local-community/author-identity.js.map +1 -1
  105. package/dist/node/schema/schema-util.d.ts +3 -0
  106. package/dist/node/schema/schema-util.js +10 -0
  107. package/dist/node/schema/schema-util.js.map +1 -1
  108. package/dist/node/signer/signatures.d.ts +9 -0
  109. package/dist/node/signer/signatures.js +30 -1
  110. package/dist/node/signer/signatures.js.map +1 -1
  111. package/dist/node/util.d.ts +1 -1
  112. package/dist/node/util.js +3 -9
  113. package/dist/node/util.js.map +1 -1
  114. package/package.json +6 -6
@@ -1,7 +1,7 @@
1
1
  import { i as __toESM, r as __require, t as __commonJSMin } from "./chunk-2rV9d50f.js";
2
- import { $ as shortifyAddress, An as CommentIpfsSchema, Ar as PKCError, At as ChallengeMessageSchema, Ct as untrackUpdatingComment, Dt as pTimeout, E as isIpfsCid, Er as FailedToFetchCommentUpdateFromGatewaysError, Et as TimeoutError, Fn as CommentUpdateForChallengeVerificationSchema, Fr as setErrorMap, H as rejectWhenCommunityStopsOrAborts, J as replaceXWithY, Jr as stringifyPrimitive, Kr as joinValues, Kt as version_default, Mr as logger_default, Mt as ChallengeRequestMessageSchema, O as isIpns, Ot as ChallengeAnswerMessageSchema, Pt as ChallengeVerificationMessageSchema, Rn as CommentUpdateSchema, S as hideClassPrivateProps, T as isAbortError, Tr as FailedToFetchCommentIpfsFromGatewaysError, Tt as require_sha256, V as rejectWhenAbortSignalFires, Y as resolveWhenPredicateIsTrue, Z as retryKuboIpfsAdd, _r as r, at as waitForUpdateInCommunityInstanceWithErrorAndTimeout, b as getPostUpdateTimestampRange, bt as trackUpdatingComment, dn as CommunityIpfsSchema, dr as n$1, dt as findUpdatingComment, et as shortifyCid, f as doesDomainAddressHaveCapitalLetter, ft as findUpdatingCommunity, gt as refreshTrackedCommentAliases, hr as e$1, ht as listUpdatingCommunities, it as timestamp, jr as messages, l as createAbortError, lr as n$2, mr as e, mt as listUpdatingComments, on as CommunityAnchorSchema, pr as t$1, pt as listStartedCommunities, q as removeUndefinedValuesRecursively, qr as parsedType, rt as throwIfAbortSignalAborted, t as areEquivalentCommunityAddresses, tt as sleepUntilTimeoutOrAbort, u as deepMergeRuntimeFields, ut as findStartedCommunity, w as ipnsNameToIpnsOverPubsubTopic, wr as require_retry, wt as untrackUpdatingCommunity, xn as isStringDomain, yn as PubsubTopicSchema } from "./util-ZnZWh_jj.js";
3
- import { $ as parseCidStringSchemaWithPKCErrorIfItFails, $t as require_lib$1, A as findCommentInParsedPages, Ar as NAME_RESOLVE_FAILED_RETRY_FLOOR_MS, B as InflightFetchManager, Bn as buildRuntimeCommunityFields, Bt as RpcExportCommunityModLogsParamSchema, C as RepliesPages, Ct as parseDecryptedChallengeVerification, D as extractCommunityRuntimeFieldsFromParsedPages, Dn as verifyCommentModeration, Dr as MAX_FILE_SIZE_BYTES_FOR_COMMENT_UPDATE, Dt as parseRpcCommentEventWithPKCErrorIfItFails, En as verifyCommentIpfs, Et as parsePKCUserOptionsSchemaWithPKCErrorIfItFails, F as collectCrosspostAuthorsToResolve, Fn as getAuthorNameFromRuntime, Ft as RpcCidParamSchema, G as decodeRpcChallengeAnswerPubsubMsg, Gn as decode, Gt as RpcFetchCidResultSchema, Hn as getCommunityNameFromWire, Ht as RpcExportCommunityParamSchema, In as getAuthorNameFromWire, It as RpcCommentRepliesPageParamSchema, J as decodeRpcChallengeVerificationPubsubMsg, Jt as RpcPublishedAnchorRecordResultSchema, K as decodeRpcChallengePubsubMsg, Kt as RpcPublishAnchorRecordParamSchema, L as stripNameResolvedFromCrosspost, Ln as normalizeCreatePublicationAuthor, Lt as RpcCommunityIdentifierParamSchema, M as parseRawPages, Mn as verifyVote, Mt as RpcAnchorPublishPreparationResultSchema, N as applyNameResolvedCacheToCrosspost, Nn as buildRuntimeAuthor, Nr as nativeFunctions$2, Nt as RpcAuthorNameParamSchema, O as findCommentInPageInstance, On as verifyCommentPubsubMessage, Or as NAME_RESOLVED_FALSE_TTL_MS, Ot as parseRpcCommentUpdateEventWithPKCErrorIfItFails, P as cloneCrosspostForRuntime, Pn as cleanWireAuthor, Pr as require_undici, Pt as RpcCancelExportParamSchema, Qt as RpcUnsubscribeParamSchema, R as PKCClientsManager, Rt as RpcCommunityPageParamSchema, S as KeyvBetterSqlite3, Sn as verifyChallengeMessage, Sr as n$3, St as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, Tn as verifyCommentEdit, Tr as t$4, Tt as parseJsonWithPKCErrorIfFails, Un as getCommunityPublicKeyFromWire, Ut as RpcExportCommunityResultSchema, V as InflightResourceTypes, Vn as getCommunityAddressFromRecord, Vt as RpcExportCommunityModLogsResultSchema, W as PKCTypedEmitter, Wn as normalizeCommunityInputFromCommunity, Wt as RpcFetchCidParamSchema, Xn as getPKCAddressFromPublicKeySync, Xt as RpcSubscriptionIdResultSchema, Yt as RpcResolveAuthorNameResultSchema, Zt as RpcSuccessResultSchema, _r as tryToDeleteCommunitiesThatFailedToBeDeletedBefore, an as encryptEd25519AesGcm, at as parseCommentModerationPubsubMessagePublicationSchemaWithPKCErrorIfItFails, b as RemoteCommunity, bn as signVote, bt as parseCreateRpcCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, cn as cleanUpBeforePublishing, cr as getDefaultDataPath, ct as parseCommunityAddressWithPKCErrorIfItFails, dn as signChallengeRequest, dr as listCommunitiesSync, dt as parseCommunityEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, fr as monitorCommunitiesDirectory, gr as setNativeFunctions$1, gt as parseCreateCommunityEditPublicationOptionsSchemaWithPKCErrorIfItFails, hn as signCommentModeration, ht as parseCreateCommentOptionsSchemaWithPKCErrorIfItFails, jn as verifyCommunityEdit, jt as parseVotePubsubMessagePublicationSchemaWithPKCErrorIfItFails, k as findCommentInPageInstanceRecursively, kn as verifyCommentUpdate, kr as NAME_RESOLVED_TRUE_TTL_MS, kt as parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, l as pkcJsPageSorts, ln as signChallengeAnswer, m as pkcJsChallenges, mn as signCommentEdit, mt as parseCreateCommentModerationOptionsSchemaWithPKCErrorIfItFails, n as RpcRemoteCommunity, nn as createAnchorIpnsRecord$1, nr as createKuboRpcClient, nt as parseCommentEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, ot as parseCommentPubsubMessagePublicationWithPKCErrorIfItFails, pn as signComment, pt as parseCreateCommentEditOptionsSchemaWithPKCErrorIfItFails, q as decodeRpcChallengeRequestPubsubMsg, qn as getBufferedPKCAddressFromPublicKey, qt as RpcPublishChallengeAnswersParamSchema, rn as decryptEd25519AesGcm, rt as parseCommentIpfsSchemaWithPKCErrorIfItFails, st as parseCommentUpdateSchemaWithPKCErrorIfItFails, t as RpcLocalCommunity, tn as createSigner, v as TrackedInstanceRegistry, vr as t$5, wn as verifyChallengeVerification, wr as t$2, wt as parseDecryptedChallengeWithPKCErrorIfItFails, xr as t$3, xt as parseCreateVoteOptionsSchemaWithPKCErrorIfItFails, y as LRUCache, yn as signCommunityEdit, yt as parseCreateRemoteCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, z as GenericStateClient, zt as RpcEditCommunityParamSchema } from "./rpc-local-community-ai5r92Ty.js";
4
- import { s as getHeliaDebugContext } from "./util-BEHFLjBG.js";
2
+ import { $ as retryKuboIpfsAddAndProvide, Ar as require_retry, Bn as CommentUpdateSchema, C as hideClassPrivateProps, Cn as isStringDomain, Cr as r, D as isIpfsCid, Dt as TimeoutError, E as isAbortError, Et as require_sha256, Ft as ChallengeVerificationMessageSchema, H as rejectWhenAbortSignalFires, Ir as PKCError, J as removeUndefinedValuesRecursively, Ln as CommentUpdateForChallengeVerificationSchema, Lr as messages, Mn as CommentIpfsSchema, Mr as FailedToFetchCommentUpdateFromGatewaysError, Nt as ChallengeRequestMessageSchema, Ot as pTimeout, Q as retryKuboIpfsAdd, Rr as logger_default, T as ipnsNameToIpnsOverPubsubTopic, Tt as untrackUpdatingCommunity, U as rejectWhenCommunityStopsOrAborts, Vr as setErrorMap, X as resolveWhenPredicateIsTrue, Y as replaceXWithY, _r as n$1, _t as refreshTrackedCommentAliases, a as calculateStringSizeSameAsIpfsAddCidV0Sync, at as timestamp, bn as PubsubTopicSchema, br as e, d as deepMergeRuntimeFields, dt as findStartedCommunity, et as shortifyAddress, fn as CommunityIpfsSchema, ft as findUpdatingComment, gt as listUpdatingCommunities, hr as n$2, ht as listUpdatingComments, i as calculateStringSizeSameAsIpfsAddCidV0, it as throwIfAbortSignalAborted, jr as FailedToFetchCommentIpfsFromGatewaysError, jt as ChallengeMessageSchema, k as isIpns, kt as ChallengeAnswerMessageSchema, mt as listStartedCommunities, nt as sleepUntilTimeoutOrAbort, ot as waitForUpdateInCommunityInstanceWithErrorAndTimeout, p as doesDomainAddressHaveCapitalLetter, pt as findUpdatingCommunity, qt as version_default, r as calculateIpfsCidV0, sn as CommunityAnchorSchema, t as areEquivalentCommunityAddresses, ti as en_default, tt as shortifyCid, u as createAbortError, wt as untrackUpdatingComment, x as getPostUpdateTimestampRange, xr as e$1, xt as trackUpdatingComment, yr as t$1 } from "./util-nmnnrzbz.js";
3
+ import { $ as parseCidStringSchemaWithPKCErrorIfItFails, $n as getCommunityPublicKeyFromWire, $t as RpcPublishedAnchorRecordResultSchema, A as findCommentInParsedPages, An as verifyChallengeVerification, At as parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, B as InflightFetchManager, Bn as buildRuntimeAuthor, Br as NAME_RESOLVE_FAILED_RETRY_FLOOR_MS, Bt as RpcEditCommunityParamSchema, C as RepliesPages, Ct as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, D as extractCommunityRuntimeFieldsFromParsedPages, Dr as tryToDeleteCommunitiesThatFailedToBeDeletedBefore, Dt as parsePKCUserOptionsSchemaWithPKCErrorIfItFails, En as signVote, Er as setNativeFunctions$1, Et as parseJsonWithPKCErrorIfFails, F as collectCrosspostAuthorsToResolve, Fn as verifyCommentUpdate, Fr as t$4, Ft as RpcCancelExportParamSchema, G as decodeRpcChallengeAnswerPubsubMsg, Gn as CreateCommunityListWithCidOptionsSchema, Gt as RpcFetchCidParamSchema, Hn as getAuthorNameFromRuntime, Ht as RpcExportCommunityModLogsResultSchema, It as RpcCidParamSchema, J as decodeRpcChallengeVerificationPubsubMsg, Jt as RpcFetchCommunityListResultSchema, K as decodeRpcChallengePubsubMsg, Kn as CreateNewCommunityListOptionsSchema, Kt as RpcFetchCidResultSchema, L as stripNameResolvedFromCrosspost, Ln as verifyCommunityEdit, Lr as MAX_FILE_SIZE_BYTES_FOR_COMMENT_UPDATE, Lt as RpcCommentRepliesPageParamSchema, M as parseRawPages, Mn as verifyCommentIpfs, Mr as n$3, Mt as parseVotePubsubMessagePublicationSchemaWithPKCErrorIfItFails, N as applyNameResolvedCacheToCrosspost, Nn as verifyCommentModeration, Nt as RpcAnchorPublishPreparationResultSchema, O as findCommentInPageInstance, On as verifyChallengeMessage, Or as t$5, Ot as parseRpcCommentEventWithPKCErrorIfItFails, P as cloneCrosspostForRuntime, Pn as verifyCommentPubsubMessage, Pr as t$2, Pt as RpcAuthorNameParamSchema, Qn as getCommunityNameFromWire, Qt as RpcPublishCommunityListResultSchema, R as PKCClientsManager, Rn as verifyCommunityList, Rr as NAME_RESOLVED_FALSE_TTL_MS, Rt as RpcCommunityIdentifierParamSchema, S as KeyvBetterSqlite3, Sr as monitorCommunitiesDirectory, St as parseCreateVoteOptionsSchemaWithPKCErrorIfItFails, Tn as signCommunityList, Tt as parseDecryptedChallengeWithPKCErrorIfItFails, Un as getAuthorNameFromWire, Ur as nativeFunctions$2, Ut as RpcExportCommunityParamSchema, V as InflightResourceTypes, Vn as cleanWireAuthor, Vt as RpcExportCommunityModLogsParamSchema, W as PKCTypedEmitter, Wn as normalizeCreatePublicationAuthor, Wr as require_undici, Wt as RpcExportCommunityResultSchema, Xn as buildRuntimeCommunityFields, Xt as RpcPublishChallengeAnswersParamSchema, Yt as RpcPublishAnchorRecordParamSchema, Zn as getCommunityAddressFromRecord, Zt as RpcPublishCommunityListParamSchema, _t as parseCreateCommunityEditPublicationOptionsSchemaWithPKCErrorIfItFails, at as parseCommentModerationPubsubMessagePublicationSchemaWithPKCErrorIfItFails, b as RemoteCommunity, bn as signCommentModeration, bt as parseCreateRemoteCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, cn as decryptEd25519AesGcm, ct as parseCommunityAddressWithPKCErrorIfItFails, dt as parseCommunityEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, en as RpcResolveAuthorNameResultSchema, er as normalizeCommunityInputFromCommunity, fr as createKuboRpcClient, gn as signChallengeRequest, gt as parseCreateCommentOptionsSchemaWithPKCErrorIfItFails, ht as parseCreateCommentModerationOptionsSchemaWithPKCErrorIfItFails, in as require_lib$1, jn as verifyCommentEdit, jr as t$3, k as findCommentInPageInstanceRecursively, kt as parseRpcCommentUpdateEventWithPKCErrorIfItFails, l as pkcJsPageSorts, m as pkcJsChallenges, mn as signChallengeAnswer, mt as parseCreateCommentEditOptionsSchemaWithPKCErrorIfItFails, n as RpcRemoteCommunity, nn as RpcSuccessResultSchema, nt as parseCommentEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, on as createSigner, or as getPKCAddressFromPublicKeySync, ot as parseCommentPubsubMessagePublicationWithPKCErrorIfItFails, pn as cleanUpBeforePublishing, pt as parseCommunityListSchemaWithPKCErrorIfItFails, q as decodeRpcChallengeRequestPubsubMsg, qn as MAX_COMMUNITY_LIST_SIZE_BYTES, qt as RpcFetchCommunityListParamSchema, rn as RpcUnsubscribeParamSchema, rr as getBufferedPKCAddressFromPublicKey, rt as parseCommentIpfsSchemaWithPKCErrorIfItFails, sn as createAnchorIpnsRecord$1, st as parseCommentUpdateSchemaWithPKCErrorIfItFails, t as RpcLocalCommunity, tn as RpcSubscriptionIdResultSchema, tr as decode, un as encryptEd25519AesGcm, v as TrackedInstanceRegistry, vn as signComment, vr as getDefaultDataPath, wn as signCommunityEdit, wt as parseDecryptedChallengeVerification, xr as listCommunitiesSync, xt as parseCreateRpcCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, y as LRUCache, yn as signCommentEdit, z as GenericStateClient, zn as verifyVote, zr as NAME_RESOLVED_TRUE_TTL_MS, zt as RpcCommunityPageParamSchema } from "./rpc-local-community-UpO9cs7k.js";
4
+ import { s as getHeliaDebugContext } from "./util-D3vx4Na0.js";
5
5
  import path from "path";
6
6
  import assert from "assert";
7
7
  import fs from "fs";
@@ -10,108 +10,6 @@ import { CID } from "multiformats/cid";
10
10
  import { of } from "typestub-ipfs-only-hash";
11
11
  import EventEmitter from "events";
12
12
  import { Client } from "rpc-websockets";
13
- //#region node_modules/zod/v4/locales/en.js
14
- const error = () => {
15
- const Sizable = {
16
- string: {
17
- unit: "characters",
18
- verb: "to have"
19
- },
20
- file: {
21
- unit: "bytes",
22
- verb: "to have"
23
- },
24
- array: {
25
- unit: "items",
26
- verb: "to have"
27
- },
28
- set: {
29
- unit: "items",
30
- verb: "to have"
31
- },
32
- map: {
33
- unit: "entries",
34
- verb: "to have"
35
- }
36
- };
37
- function getSizing(origin) {
38
- return Sizable[origin] ?? null;
39
- }
40
- const FormatDictionary = {
41
- regex: "input",
42
- email: "email address",
43
- url: "URL",
44
- emoji: "emoji",
45
- uuid: "UUID",
46
- uuidv4: "UUIDv4",
47
- uuidv6: "UUIDv6",
48
- nanoid: "nanoid",
49
- guid: "GUID",
50
- cuid: "cuid",
51
- cuid2: "cuid2",
52
- ulid: "ULID",
53
- xid: "XID",
54
- ksuid: "KSUID",
55
- datetime: "ISO datetime",
56
- date: "ISO date",
57
- time: "ISO time",
58
- duration: "ISO duration",
59
- ipv4: "IPv4 address",
60
- ipv6: "IPv6 address",
61
- mac: "MAC address",
62
- cidrv4: "IPv4 range",
63
- cidrv6: "IPv6 range",
64
- base64: "base64-encoded string",
65
- base64url: "base64url-encoded string",
66
- json_string: "JSON string",
67
- e164: "E.164 number",
68
- jwt: "JWT",
69
- template_literal: "input"
70
- };
71
- const TypeDictionary = { nan: "NaN" };
72
- return (issue) => {
73
- switch (issue.code) {
74
- case "invalid_type": {
75
- const expected = TypeDictionary[issue.expected] ?? issue.expected;
76
- const receivedType = parsedType(issue.input);
77
- return `Invalid input: expected ${expected}, received ${TypeDictionary[receivedType] ?? receivedType}`;
78
- }
79
- case "invalid_value":
80
- if (issue.values.length === 1) return `Invalid input: expected ${stringifyPrimitive(issue.values[0])}`;
81
- return `Invalid option: expected one of ${joinValues(issue.values, "|")}`;
82
- case "too_big": {
83
- const adj = issue.inclusive ? "<=" : "<";
84
- const sizing = getSizing(issue.origin);
85
- if (sizing) return `Too big: expected ${issue.origin ?? "value"} to have ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elements"}`;
86
- return `Too big: expected ${issue.origin ?? "value"} to be ${adj}${issue.maximum.toString()}`;
87
- }
88
- case "too_small": {
89
- const adj = issue.inclusive ? ">=" : ">";
90
- const sizing = getSizing(issue.origin);
91
- if (sizing) return `Too small: expected ${issue.origin} to have ${adj}${issue.minimum.toString()} ${sizing.unit}`;
92
- return `Too small: expected ${issue.origin} to be ${adj}${issue.minimum.toString()}`;
93
- }
94
- case "invalid_format": {
95
- const _issue = issue;
96
- if (_issue.format === "starts_with") return `Invalid string: must start with "${_issue.prefix}"`;
97
- if (_issue.format === "ends_with") return `Invalid string: must end with "${_issue.suffix}"`;
98
- if (_issue.format === "includes") return `Invalid string: must include "${_issue.includes}"`;
99
- if (_issue.format === "regex") return `Invalid string: must match pattern ${_issue.pattern}`;
100
- return `Invalid ${FormatDictionary[_issue.format] ?? issue.format}`;
101
- }
102
- case "not_multiple_of": return `Invalid number: must be a multiple of ${issue.divisor}`;
103
- case "unrecognized_keys": return `Unrecognized key${issue.keys.length > 1 ? "s" : ""}: ${joinValues(issue.keys, ", ")}`;
104
- case "invalid_key": return `Invalid key in ${issue.origin}`;
105
- case "invalid_union": return "Invalid input";
106
- case "invalid_element": return `Invalid value in ${issue.origin}`;
107
- default: return `Invalid input`;
108
- }
109
- };
110
- };
111
- function en_default() {
112
- return { localeError: error() };
113
- }
114
- //#endregion
115
13
  //#region dist/node/zod-error-map.js
116
14
  const defaultLocaleError = en_default().localeError;
117
15
  const friendlyErrorMap = (rawIssue) => {
@@ -3444,6 +3342,10 @@ const parseRpcSubscriptionIdResult = (result) => RpcSubscriptionIdResultSchema.l
3444
3342
  const parseRpcPublishAnchorRecordParam = (params) => RpcPublishAnchorRecordParamSchema.loose().parse(params);
3445
3343
  const parseRpcAnchorPublishPreparationResult = (result) => RpcAnchorPublishPreparationResultSchema.loose().parse(result);
3446
3344
  const parseRpcPublishedAnchorRecordResult = (result) => RpcPublishedAnchorRecordResultSchema.loose().parse(result);
3345
+ const parseRpcPublishCommunityListParam = (params) => RpcPublishCommunityListParamSchema.loose().parse(params);
3346
+ const parseRpcPublishCommunityListResult = (result) => RpcPublishCommunityListResultSchema.loose().parse(result);
3347
+ const parseRpcFetchCommunityListParam = (params) => RpcFetchCommunityListParamSchema.loose().parse(params);
3348
+ const parseRpcFetchCommunityListResult = (result) => RpcFetchCommunityListResultSchema.loose().parse(result);
3447
3349
  const parseRpcExportCommunityParam = (params) => RpcExportCommunityParamSchema.loose().parse(params);
3448
3350
  const parseRpcCancelExportParam = (params) => RpcCancelExportParamSchema.loose().parse(params);
3449
3351
  const parseRpcExportCommunityResult = (result) => RpcExportCommunityResultSchema.loose().parse(result);
@@ -3561,7 +3463,7 @@ var PKCRpcClient = class extends import_lib.TypedEmitter {
3561
3463
  })
3562
3464
  });
3563
3465
  } catch (e) {
3564
- const typedError = e;
3466
+ const typedError = e instanceof Error ? e : this._deserializeRpcError(e);
3565
3467
  typedError.details = {
3566
3468
  ...typedError.details,
3567
3469
  rpcArgs: args,
@@ -3943,6 +3845,14 @@ var PKCRpcClient = class extends import_lib.TypedEmitter {
3943
3845
  const parsedFetchCidArgs = parseRpcFetchCidParam(args);
3944
3846
  return parseRpcFetchCidResult(await this._webSocketClient.call("fetchCid", [parsedFetchCidArgs]));
3945
3847
  }
3848
+ async publishCommunityList(args) {
3849
+ const parsedArgs = parseRpcPublishCommunityListParam(args);
3850
+ return parseRpcPublishCommunityListResult(await this._webSocketClient.call("publishCommunityList", [parsedArgs]));
3851
+ }
3852
+ async fetchCommunityList(args) {
3853
+ const parsedArgs = parseRpcFetchCommunityListParam(args);
3854
+ return parseRpcFetchCommunityListResult(await this._webSocketClient.call("fetchCommunityList", [parsedArgs]));
3855
+ }
3946
3856
  async setSettings(settings) {
3947
3857
  const parsedSettings = parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails(settings);
3948
3858
  return parseRpcSuccessResult(await this._webSocketClient.call("setSettings", [parsedSettings]));
@@ -8244,6 +8154,325 @@ var CommunityEdit = class extends Publication {
8244
8154
  }
8245
8155
  };
8246
8156
  //#endregion
8157
+ //#region dist/node/community-list/community-list.js
8158
+ var CommunityList = class extends import_lib.TypedEmitter {
8159
+ constructor(pkc) {
8160
+ super();
8161
+ this.state = "stopped";
8162
+ this.raw = {};
8163
+ this._pkc = pkc;
8164
+ this.on("error", (...args) => this.listenerCount("error") === 1 && this._pkc.emit("error", ...args));
8165
+ }
8166
+ _initWithCidOnly(cid) {
8167
+ this.cid = cid;
8168
+ this.shortCid = shortifyCid(cid);
8169
+ }
8170
+ _initUnsignedProps({ signer, ...props }) {
8171
+ this.signer = signer;
8172
+ this._unsignedProps = props;
8173
+ this.title = props.title;
8174
+ this.description = props.description;
8175
+ this.timestamp = props.timestamp;
8176
+ this.protocolVersion = props.protocolVersion;
8177
+ this.communities = props.communities.map((entry) => this._buildRuntimeEntry(entry));
8178
+ this.author = this._buildRuntimeAuthor(props.author, signer.publicKey);
8179
+ }
8180
+ _buildRuntimeEntry(entry) {
8181
+ const address = entry.name || entry.publicKey;
8182
+ return {
8183
+ ...entry,
8184
+ address,
8185
+ shortAddress: shortifyAddress(address)
8186
+ };
8187
+ }
8188
+ _buildRuntimeAuthor(wireAuthor, signaturePublicKey) {
8189
+ const runtimeAuthor = buildRuntimeAuthor({
8190
+ author: wireAuthor,
8191
+ signaturePublicKey
8192
+ });
8193
+ return {
8194
+ ...runtimeAuthor,
8195
+ shortAddress: shortifyAddress(runtimeAuthor.address)
8196
+ };
8197
+ }
8198
+ _initFromWireRecord(record, cid) {
8199
+ this.raw.communityList = record;
8200
+ this.cid = cid;
8201
+ this.shortCid = shortifyCid(cid);
8202
+ this.title = record.title;
8203
+ this.description = record.description;
8204
+ this.timestamp = record.timestamp;
8205
+ this.protocolVersion = record.protocolVersion;
8206
+ this.signature = record.signature;
8207
+ this.communities = record.communities.map((entry) => this._buildRuntimeEntry(entry));
8208
+ const previousNameResolved = this.author?.nameResolved;
8209
+ this.author = this._buildRuntimeAuthor(record.author, record.signature.publicKey);
8210
+ if (typeof previousNameResolved === "boolean") this.author.nameResolved = previousNameResolved;
8211
+ else this._setAuthorNameResolvedFromCache();
8212
+ }
8213
+ _setAuthorNameResolvedFromCache() {
8214
+ const authorDomain = this._authorDomainToSettle();
8215
+ if (!authorDomain || !this.author) return;
8216
+ const cached = this._pkc._memCaches.nameResolvedCache.get(this._nameResolvedCacheKey(authorDomain));
8217
+ if (typeof cached === "boolean") this.author.nameResolved = cached;
8218
+ }
8219
+ toJSON() {
8220
+ return {
8221
+ ...this.raw.communityList ?? this._unsignedProps,
8222
+ ...this.author ? { author: this.author } : void 0,
8223
+ ...this.communities ? { communities: this.communities } : void 0,
8224
+ cid: this.cid,
8225
+ shortCid: this.shortCid
8226
+ };
8227
+ }
8228
+ _setState(newState) {
8229
+ if (this.state === newState) return;
8230
+ this.state = newState;
8231
+ this.emit("statechange", newState);
8232
+ }
8233
+ _throwIfPublishAborted(signal) {
8234
+ if (signal.aborted) throw new PKCError("ERR_COMMUNITY_LIST_PUBLISH_ABORTED", { cid: this.cid });
8235
+ }
8236
+ async publish() {
8237
+ const log = logger_default("pkc-js:community-list:publish");
8238
+ if (!this.signer || !this._unsignedProps) throw new PKCError("ERR_COMMUNITY_LIST_HAS_NO_SIGNER", { cid: this.cid });
8239
+ if (this.state === "publishing") throw new PKCError("ERR_COMMUNITY_LIST_ALREADY_PUBLISHING", {});
8240
+ if (this.state === "updating") throw new PKCError("ERR_COMMUNITY_LIST_ALREADY_UPDATING", {});
8241
+ this._setState("publishing");
8242
+ this._stopAbortController = new AbortController();
8243
+ const signal = this._stopAbortController.signal;
8244
+ try {
8245
+ const cleanedProps = cleanUpBeforePublishing(this._unsignedProps);
8246
+ const signature = await signCommunityList({
8247
+ communityList: cleanedProps,
8248
+ signer: this.signer,
8249
+ pkc: this._pkc
8250
+ });
8251
+ const record = {
8252
+ ...cleanedProps,
8253
+ signature
8254
+ };
8255
+ parseCommunityListSchemaWithPKCErrorIfItFails(record);
8256
+ const recordString = JSON.stringify(record);
8257
+ const sizeBytes = await calculateStringSizeSameAsIpfsAddCidV0(recordString);
8258
+ if (sizeBytes > 2097152) throw new PKCError("ERR_COMMUNITY_LIST_OVER_ALLOWED_SIZE", {
8259
+ sizeBytes,
8260
+ maxSizeBytes: MAX_COMMUNITY_LIST_SIZE_BYTES
8261
+ });
8262
+ this._throwIfPublishAborted(signal);
8263
+ let cid;
8264
+ if (this._pkc._pkcRpcClient) {
8265
+ const res = await this._pkc._pkcRpcClient.publishCommunityList({ communityListRawString: recordString });
8266
+ const expectedCid = await calculateIpfsCidV0(recordString);
8267
+ if (res.cid !== expectedCid) throw new PKCError("ERR_ADDED_COMMUNITY_LIST_TO_IPFS_BUT_GOT_DIFFERENT_CID", {
8268
+ expectedCid,
8269
+ cidFromRpcServer: res.cid
8270
+ });
8271
+ cid = res.cid;
8272
+ } else {
8273
+ const addRes = await retryKuboIpfsAddAndProvide({
8274
+ ipfsClient: this._pkc._clientsManager.getDefaultKuboRpcClient()._client,
8275
+ log,
8276
+ content: recordString,
8277
+ addOptions: { pin: true },
8278
+ provideInBackground: true
8279
+ });
8280
+ cid = String(addRes.cid);
8281
+ }
8282
+ this._throwIfPublishAborted(signal);
8283
+ this._initFromWireRecord(record, cid);
8284
+ log(`Published CommunityList (${cid}) with ${record.communities.length} entries`);
8285
+ return cid;
8286
+ } finally {
8287
+ if (this._stopAbortController?.signal === signal) this._setState("stopped");
8288
+ }
8289
+ }
8290
+ async update() {
8291
+ if (this.state === "updating") return;
8292
+ if (this.state === "publishing") throw new PKCError("ERR_COMMUNITY_LIST_ALREADY_PUBLISHING", {});
8293
+ if (!this.cid) throw new PKCError("ERR_COMMUNITY_LIST_HAS_NO_CID", {});
8294
+ this._setState("updating");
8295
+ this._stopAbortController = new AbortController();
8296
+ const signal = this._stopAbortController.signal;
8297
+ this._pkc._updatingCommunityLists.add(this);
8298
+ this._runUpdateLoop(signal);
8299
+ }
8300
+ async _runUpdateLoop(signal) {
8301
+ const log = logger_default("pkc-js:community-list:update");
8302
+ await new Promise((resolve) => setTimeout(resolve, 0));
8303
+ if (signal.aborted) return;
8304
+ try {
8305
+ if (!this.raw.communityList) await this._loadCommunityListIpfsWithRetries(signal);
8306
+ else this.emit("update", this);
8307
+ if (signal.aborted) return;
8308
+ await this._settleAuthorNameResolvedIfNeeded(signal);
8309
+ if (!signal.aborted) await this.stop();
8310
+ } catch (e) {
8311
+ if (signal.aborted) return;
8312
+ log.error(`Failed to update CommunityList (${this.cid})`, e);
8313
+ this.emit("error", e);
8314
+ await this.stop();
8315
+ }
8316
+ }
8317
+ _isNonRetriableError(e) {
8318
+ const { code, details } = e ?? {};
8319
+ if (code === "ERR_FAILED_TO_FETCH_GENERIC_IPFS_FROM_GATEWAYS") {
8320
+ const gatewayErrors = Object.values(details?.gatewayToError ?? {});
8321
+ return gatewayErrors.length > 0 && gatewayErrors.every((gatewayError) => this._isNonRetriableError(gatewayError));
8322
+ }
8323
+ return typeof code === "string" && [
8324
+ "ERR_INVALID_JSON",
8325
+ "ERR_INVALID_COMMUNITY_LIST_SCHEMA",
8326
+ "ERR_COMMUNITY_LIST_SIGNATURE_IS_INVALID",
8327
+ "ERR_OVER_DOWNLOAD_LIMIT",
8328
+ "ERR_CALCULATED_CID_DOES_NOT_MATCH"
8329
+ ].includes(code);
8330
+ }
8331
+ async _loadCommunityListIpfsWithRetries(outerSignal) {
8332
+ if (this.raw.communityList) return;
8333
+ const cid = this.cid;
8334
+ if (!cid) throw new PKCError("ERR_COMMUNITY_LIST_HAS_NO_CID", {});
8335
+ const abortController = new AbortController();
8336
+ const operation = import_retry.operation({
8337
+ forever: true,
8338
+ factor: 2
8339
+ });
8340
+ this._loadingAbortController = abortController;
8341
+ this._loadingOperation = operation;
8342
+ const signal = abortController.signal;
8343
+ const onOuterAbort = () => abortController.abort(outerSignal?.reason);
8344
+ outerSignal?.addEventListener("abort", onOuterAbort, { once: true });
8345
+ try {
8346
+ const record = await new Promise((resolve, reject) => {
8347
+ const rejectOnAbort = () => reject(signal.reason || /* @__PURE__ */ new Error("Aborted loading CommunityList"));
8348
+ signal.addEventListener("abort", rejectOnAbort, { once: true });
8349
+ operation.attempt(async () => {
8350
+ if (signal.aborted) return rejectOnAbort();
8351
+ try {
8352
+ resolve(await this._fetchAndVerifyOnce(cid, signal));
8353
+ } catch (e) {
8354
+ if (signal.aborted || this._isNonRetriableError(e)) return reject(e);
8355
+ this.emit("error", e);
8356
+ operation.retry(e);
8357
+ }
8358
+ });
8359
+ });
8360
+ if (signal.aborted) return;
8361
+ this._initFromWireRecord(record, cid);
8362
+ this.emit("update", this);
8363
+ } finally {
8364
+ operation.stop();
8365
+ outerSignal?.removeEventListener("abort", onOuterAbort);
8366
+ if (this._loadingOperation === operation) this._loadingOperation = void 0;
8367
+ if (this._loadingAbortController === abortController) this._loadingAbortController = void 0;
8368
+ }
8369
+ }
8370
+ async _fetchAndVerifyOnce(cid, signal) {
8371
+ let rawString;
8372
+ if (this._pkc._pkcRpcClient) {
8373
+ rawString = (await this._pkc._pkcRpcClient.fetchCommunityList({ cid })).communityListRawString;
8374
+ const sizeBytes = calculateStringSizeSameAsIpfsAddCidV0Sync(rawString);
8375
+ if (sizeBytes > 2097152) throw new PKCError("ERR_OVER_DOWNLOAD_LIMIT", {
8376
+ cid,
8377
+ sizeBytes,
8378
+ maxSizeBytes: MAX_COMMUNITY_LIST_SIZE_BYTES
8379
+ });
8380
+ const calculatedCid = await calculateIpfsCidV0(rawString);
8381
+ if (calculatedCid !== cid) throw new PKCError("ERR_CALCULATED_CID_DOES_NOT_MATCH", {
8382
+ calculatedCid,
8383
+ cid
8384
+ });
8385
+ } else rawString = await this._pkc._clientsManager.fetchCid(cid, {
8386
+ maxFileSizeBytes: MAX_COMMUNITY_LIST_SIZE_BYTES,
8387
+ abortSignal: signal
8388
+ });
8389
+ const record = parseCommunityListSchemaWithPKCErrorIfItFails(parseJsonWithPKCErrorIfFails(rawString));
8390
+ const validity = await verifyCommunityList({ communityList: record });
8391
+ if (!validity.valid) throw new PKCError("ERR_COMMUNITY_LIST_SIGNATURE_IS_INVALID", {
8392
+ validity,
8393
+ cid
8394
+ });
8395
+ return record;
8396
+ }
8397
+ _authorDomainToSettle() {
8398
+ const wireAuthorName = this.raw.communityList?.author?.name;
8399
+ if (typeof wireAuthorName !== "string" || !isStringDomain(wireAuthorName)) return void 0;
8400
+ return wireAuthorName;
8401
+ }
8402
+ _nameResolvedCacheKey(authorDomain) {
8403
+ return (0, import_sha256.sha256)(authorDomain + this.raw.communityList.signature.publicKey);
8404
+ }
8405
+ async _resolveAuthorNameVerdictOnce(authorDomain) {
8406
+ const cache = this._pkc._memCaches.nameResolvedCache;
8407
+ const cacheKey = this._nameResolvedCacheKey(authorDomain);
8408
+ const cached = cache.get(cacheKey);
8409
+ if (typeof cached === "boolean") return cached;
8410
+ try {
8411
+ const { resolvedAuthorName } = await this._pkc.resolveAuthorName({ name: authorDomain });
8412
+ const ttlOf = (verdict) => verdict ? this._pkc._nameResolvedTrueTtlMs : this._pkc._nameResolvedFalseTtlMs;
8413
+ if (typeof resolvedAuthorName !== "string") {
8414
+ cache.set(cacheKey, false, { ttl: ttlOf(false) });
8415
+ return false;
8416
+ }
8417
+ const verdict = resolvedAuthorName === getPKCAddressFromPublicKeySync(this.raw.communityList.signature.publicKey);
8418
+ cache.set(cacheKey, verdict, { ttl: ttlOf(verdict) });
8419
+ return verdict;
8420
+ } catch (e) {
8421
+ const code = e?.code;
8422
+ if (code === "ERR_RESOLVED_TEXT_RECORD_TO_NON_IPNS") {
8423
+ cache.set(cacheKey, false, { ttl: this._pkc._nameResolvedFalseTtlMs });
8424
+ return false;
8425
+ }
8426
+ if (code === "ERR_NO_RESOLVER_FOR_NAME") return false;
8427
+ return;
8428
+ }
8429
+ }
8430
+ _kickOffBackgroundAuthorNameResolution() {
8431
+ const log = logger_default("pkc-js:community-list:resolve-author-name");
8432
+ const authorDomain = this._authorDomainToSettle();
8433
+ if (!authorDomain || !this._pkc.resolveAuthorNames) return;
8434
+ this._resolveAuthorNameVerdictOnce(authorDomain).catch((e) => log.error("Failed background author name resolution", authorDomain, e));
8435
+ }
8436
+ async _settleAuthorNameResolvedIfNeeded(signal) {
8437
+ const authorDomain = this._authorDomainToSettle();
8438
+ if (!authorDomain || !this.author || !this._pkc.resolveAuthorNames) return;
8439
+ let attempt = 0;
8440
+ while (!signal.aborted) {
8441
+ const verdict = await this._resolveAuthorNameVerdictOnce(authorDomain);
8442
+ if (signal.aborted) return;
8443
+ if (typeof verdict === "boolean") {
8444
+ this.author.nameResolved = verdict;
8445
+ this.emit("update", this);
8446
+ return;
8447
+ }
8448
+ attempt++;
8449
+ await this._delayWithAbort(Math.min(1e3 * 2 ** attempt, 6e4), signal);
8450
+ }
8451
+ }
8452
+ async _delayWithAbort(ms, signal) {
8453
+ if (signal.aborted) return;
8454
+ await new Promise((resolve) => {
8455
+ const timeout = setTimeout(() => {
8456
+ signal.removeEventListener("abort", onAbort);
8457
+ resolve();
8458
+ }, ms);
8459
+ const onAbort = () => {
8460
+ clearTimeout(timeout);
8461
+ resolve();
8462
+ };
8463
+ signal.addEventListener("abort", onAbort, { once: true });
8464
+ });
8465
+ }
8466
+ async stop() {
8467
+ this._pkc._updatingCommunityLists.delete(this);
8468
+ this._stopAbortController?.abort();
8469
+ this._loadingAbortController?.abort();
8470
+ this._loadingOperation?.stop();
8471
+ if (this.state === "stopped") return;
8472
+ this._setState("stopped");
8473
+ }
8474
+ };
8475
+ //#endregion
8247
8476
  //#region dist/node/pkc/pkc.js
8248
8477
  var PKC$1 = class extends PKCTypedEmitter {
8249
8478
  constructor(options) {
@@ -8253,6 +8482,7 @@ var PKC$1 = class extends PKCTypedEmitter {
8253
8482
  this._updatingComments = new TrackedInstanceRegistry();
8254
8483
  this._startedCommunities = new TrackedInstanceRegistry();
8255
8484
  this._publishingPublications = /* @__PURE__ */ new Set();
8485
+ this._updatingCommunityLists = /* @__PURE__ */ new Set();
8256
8486
  this.destroyed = false;
8257
8487
  this._storageLRUs = {};
8258
8488
  this._nameResolvedFalseTtlMs = NAME_RESOLVED_FALSE_TTL_MS;
@@ -8386,7 +8616,7 @@ var PKC$1 = class extends PKCTypedEmitter {
8386
8616
  this.clients.libp2pJsClients = {};
8387
8617
  if (!this.libp2pJsClientsOptions) return;
8388
8618
  if (!this.httpRoutersOptions) throw Error("httpRoutersOptions is required for libp2pJsClient");
8389
- const { createLibp2pJsClientOrUseExistingOne } = await import("./helia-for-pkc-BtJGszgv.js");
8619
+ const { createLibp2pJsClientOrUseExistingOne } = await import("./helia-for-pkc-DXygdFt-.js");
8390
8620
  for (const clientOptions of this.libp2pJsClientsOptions) {
8391
8621
  const heliaNode = await createLibp2pJsClientOrUseExistingOne({
8392
8622
  ...clientOptions,
@@ -8506,6 +8736,88 @@ var PKC$1 = class extends PKCTypedEmitter {
8506
8736
  await comment.stop();
8507
8737
  }
8508
8738
  }
8739
+ async createCommunityList(options) {
8740
+ if (options && typeof options === "object" && "cid" in options) {
8741
+ const parseRes = CreateCommunityListWithCidOptionsSchema.safeParse(options);
8742
+ if (!parseRes.success) throw new PKCError("ERR_INVALID_CREATE_COMMUNITY_LIST_OPTIONS_SCHEMA", {
8743
+ zodError: parseRes.error,
8744
+ options
8745
+ });
8746
+ const communityList = new CommunityList(this);
8747
+ communityList._initWithCidOnly(parseRes.data.cid);
8748
+ return communityList;
8749
+ }
8750
+ const parseRes = CreateNewCommunityListOptionsSchema.safeParse(options);
8751
+ if (!parseRes.success) throw new PKCError("ERR_INVALID_CREATE_COMMUNITY_LIST_OPTIONS_SCHEMA", {
8752
+ zodError: parseRes.error,
8753
+ options
8754
+ });
8755
+ const parsedOptions = parseRes.data;
8756
+ const signer = await this.createSigner(parsedOptions.signer);
8757
+ const cleanedAuthor = cleanWireAuthor(normalizeCreatePublicationAuthor(parsedOptions.author));
8758
+ const communityList = new CommunityList(this);
8759
+ communityList._initUnsignedProps({
8760
+ signer,
8761
+ title: parsedOptions.title,
8762
+ description: parsedOptions.description,
8763
+ author: cleanedAuthor,
8764
+ communities: parsedOptions.communities,
8765
+ timestamp: typeof parsedOptions.timestamp === "number" ? parsedOptions.timestamp : timestamp(),
8766
+ protocolVersion: parsedOptions.protocolVersion || version_default.PROTOCOL_VERSION
8767
+ });
8768
+ return communityList;
8769
+ }
8770
+ async getCommunityList(getCommunityListArgs) {
8771
+ const { abortSignal, ...cidArgs } = getCommunityListArgs;
8772
+ const parseRes = CreateCommunityListWithCidOptionsSchema.safeParse(cidArgs);
8773
+ if (!parseRes.success) throw new PKCError("ERR_INVALID_CREATE_COMMUNITY_LIST_OPTIONS_SCHEMA", {
8774
+ zodError: parseRes.error,
8775
+ getCommunityListArgs
8776
+ });
8777
+ const cid = parseRes.data.cid;
8778
+ if (abortSignal?.aborted) throw new PKCError("ERR_GET_COMMUNITY_LIST_ABORTED", {
8779
+ cid,
8780
+ abortReason: abortSignal.reason
8781
+ });
8782
+ const communityList = await this.createCommunityList(parseRes.data);
8783
+ let lastUpdateError;
8784
+ const errorListener = (err) => lastUpdateError = err;
8785
+ communityList.on("error", errorListener);
8786
+ let abortError;
8787
+ let abortReject;
8788
+ const abortListener = () => {
8789
+ abortError = new PKCError("ERR_GET_COMMUNITY_LIST_ABORTED", {
8790
+ cid,
8791
+ abortReason: abortSignal?.reason,
8792
+ lastUpdateError
8793
+ });
8794
+ abortReject?.(abortError);
8795
+ };
8796
+ const abortPromise = new Promise((_, reject) => {
8797
+ abortReject = reject;
8798
+ });
8799
+ abortPromise.catch(() => {});
8800
+ abortSignal?.addEventListener("abort", abortListener);
8801
+ const timeoutMs = this._timeouts["generic-ipfs"];
8802
+ const timeoutError = new TimeoutError(`pkc.getCommunityList({cid: ${cid}}) timed out after ${timeoutMs}ms`);
8803
+ try {
8804
+ await pTimeout(Promise.race([communityList._loadCommunityListIpfsWithRetries(abortSignal), abortPromise]), {
8805
+ milliseconds: timeoutMs,
8806
+ message: timeoutError
8807
+ });
8808
+ if (!communityList.signature) throw Error("Failed to load CommunityList");
8809
+ communityList._kickOffBackgroundAuthorNameResolution();
8810
+ return communityList;
8811
+ } catch (e) {
8812
+ if (abortError) throw abortError;
8813
+ if (e === timeoutError && lastUpdateError) throw lastUpdateError;
8814
+ throw e;
8815
+ } finally {
8816
+ abortSignal?.removeEventListener("abort", abortListener);
8817
+ communityList.removeListener("error", errorListener);
8818
+ await communityList.stop();
8819
+ }
8820
+ }
8509
8821
  async _initMissingFieldsOfPublicationBeforeSigning(pubOptions, log) {
8510
8822
  const finalOptions = t$4(pubOptions);
8511
8823
  if (!finalOptions.signer) throw Error("User did not provide a signer to create a local publication");
@@ -8668,7 +8980,7 @@ var PKC$1 = class extends PKCTypedEmitter {
8668
8980
  const log = logger_default("pkc-js:pkc:createLocalCommunity");
8669
8981
  log.trace("Received community options to create a local community instance:", options);
8670
8982
  if (!this._canCreateNewLocalCommunity()) throw new PKCError("ERR_CAN_NOT_CREATE_A_LOCAL_COMMUNITY", { pkcOptions: this._userPKCOptions });
8671
- const { LocalCommunity, createNewLocalCommunityDb, updateInstancePropsWithStartedCommunityOrDb } = await import("./local-community-TY_gAkZm.js");
8983
+ const { LocalCommunity, createNewLocalCommunityDb, updateInstancePropsWithStartedCommunityOrDb } = await import("./local-community-Bbqx5IaD.js");
8672
8984
  const isLocalCommunity = (await listCommunitiesSync(this)).includes(options.address);
8673
8985
  const community = new LocalCommunity(this);
8674
8986
  if (isLocalCommunity) {
@@ -9053,6 +9365,8 @@ var PKC$1 = class extends PKCTypedEmitter {
9053
9365
  await Promise.all([...this._publishingPublications].map((publication) => publication.stop().catch((e) => log.error("Error stopping publication during destroy", e))));
9054
9366
  this._publishingPublications.clear();
9055
9367
  for (const comment of listUpdatingComments(this)) await comment.stop();
9368
+ for (const communityList of [...this._updatingCommunityLists]) await communityList.stop().catch((e) => log.error("Error stopping CommunityList during destroy", e));
9369
+ this._updatingCommunityLists.clear();
9056
9370
  for (const community of listUpdatingCommunities(this)) await community.stop();
9057
9371
  await Promise.all(listStartedCommunities(this).map((community) => community.stop()));
9058
9372
  if (this._communityFsWatchAbort) this._communityFsWatchAbort.abort();
@@ -9251,4 +9565,4 @@ const challenges = PKC.challenges;
9251
9565
  const pageSorts = PKC.pageSorts;
9252
9566
  const createAnchorIpnsRecord = PKC.createAnchorIpnsRecord;
9253
9567
  //#endregion
9254
- export { parseRpcExportCommunityParam as _, getShortCid as a, parseRpcUnsubscribeParam as b, setNativeFunctions as c, parseRpcCidParam as d, parseRpcCommentRepliesPageParam as f, parseRpcExportCommunityModLogsParam as g, parseRpcEditCommunityParam as h, getShortAddress as i, parseRpcAuthorNameParam as l, parseRpcCommunityPageParam as m, challenges as n, nativeFunctions as o, parseRpcCommunityIdentifierParam as p, createAnchorIpnsRecord as r, pageSorts as s, PKC as t, parseRpcCancelExportParam as u, parseRpcPublishAnchorRecordParam as v, parseRpcPublishChallengeAnswersParam as y };
9568
+ export { parseRpcUnsubscribeParam as S, parseRpcExportCommunityParam as _, getShortCid as a, parseRpcPublishChallengeAnswersParam as b, setNativeFunctions as c, parseRpcCidParam as d, parseRpcCommentRepliesPageParam as f, parseRpcExportCommunityModLogsParam as g, parseRpcEditCommunityParam as h, getShortAddress as i, parseRpcAuthorNameParam as l, parseRpcCommunityPageParam as m, challenges as n, nativeFunctions as o, parseRpcCommunityIdentifierParam as p, createAnchorIpnsRecord as r, pageSorts as s, PKC as t, parseRpcCancelExportParam as u, parseRpcFetchCommunityListParam as v, parseRpcPublishCommunityListParam as x, parseRpcPublishAnchorRecordParam as y };
@@ -1,4 +1,4 @@
1
- import { _ as getEquivalentCommunityAddresses, vn as PageSortFileSchema, xn as isStringDomain } from "./util-ZnZWh_jj.js";
1
+ import { Cn as isStringDomain, v as getEquivalentCommunityAddresses, yn as PageSortFileSchema } from "./util-nmnnrzbz.js";
2
2
  //#region dist/node/pages/page-sort-scoring.js
3
3
  function validatePageSortFile(rawFile) {
4
4
  const validated = PageSortFileSchema.parse(rawFile);