@pkcprotocol/pkc-js 0.0.73 → 0.0.74

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 (110) hide show
  1. package/README.md +1 -0
  2. package/dist/browser/clients/base-client-manager.d.ts +1 -0
  3. package/dist/browser/clients/base-client-manager.js +9 -2
  4. package/dist/browser/clients/base-client-manager.js.map +1 -1
  5. package/dist/browser/clients/rpc-client/rpc-schema-util.d.ts +1 -0
  6. package/dist/browser/clients/rpc-client/schema.d.ts +1 -0
  7. package/dist/browser/community/community-client-manager.d.ts +1 -0
  8. package/dist/browser/community/community-client-manager.js +7 -0
  9. package/dist/browser/community/community-client-manager.js.map +1 -1
  10. package/dist/browser/community/remote-community.js +18 -9
  11. package/dist/browser/community/remote-community.js.map +1 -1
  12. package/dist/browser/community/schema.d.ts +6 -0
  13. package/dist/browser/community/schema.js +4 -1
  14. package/dist/browser/community/schema.js.map +1 -1
  15. package/dist/browser/community/types.d.ts +1 -0
  16. package/dist/browser/errors.d.ts +2 -0
  17. package/dist/browser/errors.js +2 -0
  18. package/dist/browser/errors.js.map +1 -1
  19. package/dist/browser/generated-version.d.ts +1 -1
  20. package/dist/browser/generated-version.js +1 -1
  21. package/dist/browser/pkc-error.d.ts +1 -1
  22. package/dist/browser/publications/community-edit/schema.d.ts +4 -0
  23. package/dist/browser/publications/publication.d.ts +2 -1
  24. package/dist/browser/publications/publication.js +63 -24
  25. package/dist/browser/publications/publication.js.map +1 -1
  26. package/dist/browser/pubsub-messages/schema.d.ts +2 -0
  27. package/dist/browser/runtime/node/community/db-handler.d.ts +1 -0
  28. package/dist/browser/runtime/node/community/local-community/challenges.js +26 -25
  29. package/dist/browser/runtime/node/community/local-community/challenges.js.map +1 -1
  30. package/dist/browser/runtime/node/community/local-community/comment-updates.d.ts +2 -1
  31. package/dist/browser/runtime/node/community/local-community/comment-updates.js +14 -2
  32. package/dist/browser/runtime/node/community/local-community/comment-updates.js.map +1 -1
  33. package/dist/browser/runtime/node/community/local-community/db-state.js +12 -1
  34. package/dist/browser/runtime/node/community/local-community/db-state.js.map +1 -1
  35. package/dist/browser/runtime/node/community/local-community/ipns-publishing.js +22 -1
  36. package/dist/browser/runtime/node/community/local-community/ipns-publishing.js.map +1 -1
  37. package/dist/browser/runtime/node/community/local-community/lifecycle.js +17 -5
  38. package/dist/browser/runtime/node/community/local-community/lifecycle.js.map +1 -1
  39. package/dist/browser/runtime/node/community/local-community/pubsub.js +42 -4
  40. package/dist/browser/runtime/node/community/local-community/pubsub.js.map +1 -1
  41. package/dist/browser/runtime/node/community/local-community.d.ts +1 -0
  42. package/dist/browser/runtime/node/community/local-community.js +10 -1
  43. package/dist/browser/runtime/node/community/local-community.js.map +1 -1
  44. package/dist/browser/schema/schema-util.d.ts +4 -0
  45. package/dist/browser/signer/signatures.d.ts +4 -4
  46. package/dist/browser/signer/signatures.js +23 -4
  47. package/dist/browser/signer/signatures.js.map +1 -1
  48. package/dist/browser/test/test-util.d.ts +3 -0
  49. package/dist/browser/test/test-util.js +15 -1
  50. package/dist/browser/test/test-util.js.map +1 -1
  51. package/dist/bundled/bundle-manifest.json +25 -25
  52. package/dist/bundled/chunks/{helia-for-pkc-DooZDxJi.js → helia-for-pkc-B-75U9z9.js} +2 -2
  53. package/dist/bundled/chunks/{local-community-DLVCXKMM.js → local-community-Br1ipu1Z.js} +92 -55
  54. package/dist/bundled/chunks/{local-community-EFv2VpQI.js → local-community-CIVs_iuS.js} +1 -1
  55. package/dist/bundled/chunks/{node-Dpuw7iSW.js → node-Cn7VaPDJ.js} +53 -27
  56. package/dist/bundled/chunks/{rpc-local-community-8CqOzaX3.js → rpc-local-community-DtdeJBOq.js} +38 -27
  57. package/dist/bundled/chunks/{schema-DMHTAMSM.js → schema-B1Ot-kux.js} +5 -2
  58. package/dist/bundled/chunks/{util-hdyyy-HI.js → util-B6v5HAdy.js} +1 -1
  59. package/dist/bundled/index.js +1 -1
  60. package/dist/bundled/rpc/src/index.js +4 -4
  61. package/dist/node/clients/base-client-manager.d.ts +1 -0
  62. package/dist/node/clients/base-client-manager.js +9 -2
  63. package/dist/node/clients/base-client-manager.js.map +1 -1
  64. package/dist/node/clients/rpc-client/rpc-schema-util.d.ts +1 -0
  65. package/dist/node/clients/rpc-client/schema.d.ts +1 -0
  66. package/dist/node/community/community-client-manager.d.ts +1 -0
  67. package/dist/node/community/community-client-manager.js +7 -0
  68. package/dist/node/community/community-client-manager.js.map +1 -1
  69. package/dist/node/community/remote-community.js +18 -9
  70. package/dist/node/community/remote-community.js.map +1 -1
  71. package/dist/node/community/schema.d.ts +6 -0
  72. package/dist/node/community/schema.js +4 -1
  73. package/dist/node/community/schema.js.map +1 -1
  74. package/dist/node/community/types.d.ts +1 -0
  75. package/dist/node/errors.d.ts +2 -0
  76. package/dist/node/errors.js +2 -0
  77. package/dist/node/errors.js.map +1 -1
  78. package/dist/node/generated-version.d.ts +1 -1
  79. package/dist/node/generated-version.js +1 -1
  80. package/dist/node/pkc-error.d.ts +1 -1
  81. package/dist/node/publications/community-edit/schema.d.ts +4 -0
  82. package/dist/node/publications/publication.d.ts +2 -1
  83. package/dist/node/publications/publication.js +63 -24
  84. package/dist/node/publications/publication.js.map +1 -1
  85. package/dist/node/pubsub-messages/schema.d.ts +2 -0
  86. package/dist/node/runtime/node/community/db-handler.d.ts +1 -0
  87. package/dist/node/runtime/node/community/local-community/challenges.js +26 -25
  88. package/dist/node/runtime/node/community/local-community/challenges.js.map +1 -1
  89. package/dist/node/runtime/node/community/local-community/comment-updates.d.ts +2 -1
  90. package/dist/node/runtime/node/community/local-community/comment-updates.js +14 -2
  91. package/dist/node/runtime/node/community/local-community/comment-updates.js.map +1 -1
  92. package/dist/node/runtime/node/community/local-community/db-state.js +12 -1
  93. package/dist/node/runtime/node/community/local-community/db-state.js.map +1 -1
  94. package/dist/node/runtime/node/community/local-community/ipns-publishing.js +22 -1
  95. package/dist/node/runtime/node/community/local-community/ipns-publishing.js.map +1 -1
  96. package/dist/node/runtime/node/community/local-community/lifecycle.js +17 -5
  97. package/dist/node/runtime/node/community/local-community/lifecycle.js.map +1 -1
  98. package/dist/node/runtime/node/community/local-community/pubsub.js +42 -4
  99. package/dist/node/runtime/node/community/local-community/pubsub.js.map +1 -1
  100. package/dist/node/runtime/node/community/local-community.d.ts +1 -0
  101. package/dist/node/runtime/node/community/local-community.js +10 -1
  102. package/dist/node/runtime/node/community/local-community.js.map +1 -1
  103. package/dist/node/schema/schema-util.d.ts +4 -0
  104. package/dist/node/signer/signatures.d.ts +4 -4
  105. package/dist/node/signer/signatures.js +23 -4
  106. package/dist/node/signer/signatures.js.map +1 -1
  107. package/dist/node/test/test-util.d.ts +3 -0
  108. package/dist/node/test/test-util.js +15 -1
  109. package/dist/node/test/test-util.js.map +1 -1
  110. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  import { i as __toESM, r as __require, t as __commonJSMin } from "./chunk-2rV9d50f.js";
2
- import { B as isIpfsCid, Cn as CommentUpdateForChallengeVerificationSchema, Ct as findUpdatingCommunity, D as deepMergeRuntimeFields, Dt as refreshTrackedCommentAliases, E as createAbortError, En as CommentUpdateSchema, Et as listUpdatingCommunities, Fr as stringifyPrimitive, H as isIpns, It as require_sha256, L as hideClassPrivateProps, Lt as TimeoutError, Nr as joinValues, Pr as parsedType, Pt as untrackUpdatingComment, Q as isStringDomain, Qn as n$1, R as ipnsNameToIpnsOverPubsubTopic, Rt as pTimeout, Sr as setErrorMap, St as findUpdatingComment, Tt as listUpdatingComments, Xn as n$2, _r as PKCError, _t as timestamp, a as ChallengeRequestMessageSchema, b as areEquivalentCommunityAddresses, br as require_supports_color, cn as PubsubTopicSchema, ct as resolveWhenPredicateIsTrue, dr as require_retry, er as t$1, fr as FailedToFetchCommentIpfsFromGatewaysError, ft as shortifyAddress, ir as r, jt as trackUpdatingComment, k as doesDomainAddressHaveCapitalLetter, mt as sleepUntilTimeoutOrAbort, nn as CommunityIpfsSchema, nr as e$1, ot as removeUndefinedValuesRecursively, pt as shortifyCid, r as ChallengeMessageSchema, s as ChallengeVerificationMessageSchema, st as replaceXWithY, t as ChallengeAnswerMessageSchema, tr as e, ut as retryKuboIpfsAdd, vn as CommentIpfsSchema, vr as messages, vt as waitForUpdateInCommunityInstanceWithErrorAndTimeout, wt as listStartedCommunities, xt as findStartedCommunity, y as version_default, yr as logger_default, z as isAbortError } from "./schema-DMHTAMSM.js";
3
- import { $ as RepliesPages, $n as t$5, $t as parseCommentEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, An as RpcCidParamSchema, At as verifyCommunityEdit, B as setNativeFunctions$1, Bn as RpcFetchCidResultSchema, Bt as getCommunityPublicKeyFromWire, Cn as parseRpcCommentEventWithPKCErrorIfItFails, Ct as verifyChallengeVerification, D as createKuboRpcClient, Dn as parseVotePubsubMessagePublicationSchemaWithPKCErrorIfItFails, Dt as verifyCommentPubsubMessage, Et as verifyCommentModeration, Fn as RpcExportCommunityModLogsParamSchema, Gn as RpcUnsubscribeParamSchema, H as CommentClientsManager, Hn as RpcResolveAuthorNameResultSchema, Ht as decode, I as listCommunitiesSync, In as RpcExportCommunityModLogsResultSchema, It as normalizeCreatePublicationAuthor, Kn as t$4, L as monitorCommunitiesDirectory, Ln as RpcExportCommunityParamSchema, Lt as buildRuntimeCommunityFields, Mn as RpcCommunityIdentifierParamSchema, Mt as buildRuntimeAuthor, N as getDefaultDataPath, Nn as RpcCommunityPageParamSchema, Nt as cleanWireAuthor, On as RpcAuthorNameParamSchema, Ot as verifyCommentUpdate, Pn as RpcEditCommunityParamSchema, Pt as getAuthorNameFromRuntime, Q as parseRawPages, Qn as t$2, Rn as RpcExportCommunityResultSchema, Rt as getCommunityAddressFromRecord, Sn as parsePKCUserOptionsSchemaWithPKCErrorIfItFails, Tn as parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, Tt as verifyCommentIpfs, Un as RpcSubscriptionIdResultSchema, V as tryToDeleteCommunitiesThatFailedToBeDeletedBefore, Vn as RpcPublishChallengeAnswersParamSchema, Vt as normalizeCommunityInputFromCommunity, Wn as RpcSuccessResultSchema, Wt as getBufferedPKCAddressFromPublicKey, X as findCommentInPageInstanceRecursively, Xn as n$3, Xt as parseCidStringSchemaWithPKCErrorIfItFails, Y as extractCommunityRuntimeFieldsFromParsedPages, Yn as t$3, _n as parseCreateVoteOptionsSchemaWithPKCErrorIfItFails, a as pkcJsChallenges, at as PKCTypedEmitter, bn as parseDecryptedChallengeWithPKCErrorIfItFails, c as AddressesRewriterProxyServer, ct as signChallengeAnswer, dn as parseCreateCommentOptionsSchemaWithPKCErrorIfItFails, en as parseCommentIpfsSchemaWithPKCErrorIfItFails, et as PublicationClientsManager, f as KeyvBetterSqlite3, fn as parseCreateCommunityEditPublicationOptionsSchemaWithPKCErrorIfItFails, ft as signComment, g as decodeRpcChallengeVerificationPubsubMsg, gn as parseCreateRpcCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, h as decodeRpcChallengeRequestPubsubMsg, hn as parseCreateRemoteCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, in as parseCommunityAddressWithPKCErrorIfItFails, ir as require_undici, jn as RpcCommentRepliesPageParamSchema, jt as verifyVote, kn as RpcCancelExportParamSchema, ln as parseCreateCommentEditOptionsSchemaWithPKCErrorIfItFails, m as decodeRpcChallengePubsubMsg, mt as signCommentModeration, n as RpcRemoteCommunity, nn as parseCommentModerationPubsubMessagePublicationSchemaWithPKCErrorIfItFails, nt as InflightFetchManager, o as TrackedInstanceRegistry, ot as require_lib$1, p as decodeRpcChallengeAnswerPubsubMsg, pt as signCommentEdit, rn as parseCommentPubsubMessagePublicationWithPKCErrorIfItFails, rr as nativeFunctions$2, s as LRUCache, sn as parseCommunityEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, st as cleanUpBeforePublishing, t as RpcLocalCommunity, tt as PKCClientsManager, u as RemoteCommunity, un as parseCreateCommentModerationOptionsSchemaWithPKCErrorIfItFails, ut as signChallengeRequest, v as createSigner, vn as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, vt as signCommunityEdit, wn as parseRpcCommentUpdateEventWithPKCErrorIfItFails, wt as verifyCommentEdit, x as encryptEd25519AesGcm, xn as parseJsonWithPKCErrorIfFails, xt as verifyChallengeMessage, y as decryptEd25519AesGcm, yn as parseDecryptedChallengeVerification, yt as signVote, zn as RpcFetchCidParamSchema, zt as getCommunityNameFromWire } from "./rpc-local-community-8CqOzaX3.js";
4
- import { o as getHeliaDebugContext } from "./util-hdyyy-HI.js";
2
+ import { B as isIpfsCid, Cn as CommentUpdateForChallengeVerificationSchema, Ct as findUpdatingCommunity, D as deepMergeRuntimeFields, Dt as refreshTrackedCommentAliases, E as createAbortError, En as CommentUpdateSchema, Et as listUpdatingCommunities, Fr as stringifyPrimitive, H as isIpns, It as require_sha256, L as hideClassPrivateProps, Lt as TimeoutError, Nr as joinValues, Pr as parsedType, Pt as untrackUpdatingComment, Q as isStringDomain, Qn as n$1, R as ipnsNameToIpnsOverPubsubTopic, Rt as pTimeout, Sr as setErrorMap, St as findUpdatingComment, Tt as listUpdatingComments, Xn as n$2, _r as PKCError, _t as timestamp, a as ChallengeRequestMessageSchema, b as areEquivalentCommunityAddresses, br as require_supports_color, cn as PubsubTopicSchema, ct as resolveWhenPredicateIsTrue, dr as require_retry, er as t$1, fr as FailedToFetchCommentIpfsFromGatewaysError, ft as shortifyAddress, ir as r, jt as trackUpdatingComment, k as doesDomainAddressHaveCapitalLetter, mt as sleepUntilTimeoutOrAbort, nn as CommunityIpfsSchema, nr as e$1, ot as removeUndefinedValuesRecursively, pt as shortifyCid, r as ChallengeMessageSchema, s as ChallengeVerificationMessageSchema, st as replaceXWithY, t as ChallengeAnswerMessageSchema, tr as e, ut as retryKuboIpfsAdd, vn as CommentIpfsSchema, vr as messages, vt as waitForUpdateInCommunityInstanceWithErrorAndTimeout, wt as listStartedCommunities, xt as findStartedCommunity, y as version_default, yr as logger_default, z as isAbortError } from "./schema-B1Ot-kux.js";
3
+ import { $ as RepliesPages, $n as t$5, $t as parseCommentEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, An as RpcCidParamSchema, At as verifyCommunityEdit, B as setNativeFunctions$1, Bn as RpcFetchCidResultSchema, Bt as getCommunityPublicKeyFromWire, Cn as parseRpcCommentEventWithPKCErrorIfItFails, Ct as verifyChallengeVerification, D as createKuboRpcClient, Dn as parseVotePubsubMessagePublicationSchemaWithPKCErrorIfItFails, Dt as verifyCommentPubsubMessage, Et as verifyCommentModeration, Fn as RpcExportCommunityModLogsParamSchema, Gn as RpcUnsubscribeParamSchema, H as CommentClientsManager, Hn as RpcResolveAuthorNameResultSchema, Ht as decode, I as listCommunitiesSync, In as RpcExportCommunityModLogsResultSchema, It as normalizeCreatePublicationAuthor, Kn as t$4, L as monitorCommunitiesDirectory, Ln as RpcExportCommunityParamSchema, Lt as buildRuntimeCommunityFields, Mn as RpcCommunityIdentifierParamSchema, Mt as buildRuntimeAuthor, N as getDefaultDataPath, Nn as RpcCommunityPageParamSchema, Nt as cleanWireAuthor, On as RpcAuthorNameParamSchema, Ot as verifyCommentUpdate, Pn as RpcEditCommunityParamSchema, Pt as getAuthorNameFromRuntime, Q as parseRawPages, Qn as t$2, Rn as RpcExportCommunityResultSchema, Rt as getCommunityAddressFromRecord, Sn as parsePKCUserOptionsSchemaWithPKCErrorIfItFails, Tn as parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, Tt as verifyCommentIpfs, Un as RpcSubscriptionIdResultSchema, V as tryToDeleteCommunitiesThatFailedToBeDeletedBefore, Vn as RpcPublishChallengeAnswersParamSchema, Vt as normalizeCommunityInputFromCommunity, Wn as RpcSuccessResultSchema, Wt as getBufferedPKCAddressFromPublicKey, X as findCommentInPageInstanceRecursively, Xn as n$3, Xt as parseCidStringSchemaWithPKCErrorIfItFails, Y as extractCommunityRuntimeFieldsFromParsedPages, Yn as t$3, _n as parseCreateVoteOptionsSchemaWithPKCErrorIfItFails, a as pkcJsChallenges, at as PKCTypedEmitter, bn as parseDecryptedChallengeWithPKCErrorIfItFails, c as AddressesRewriterProxyServer, ct as signChallengeAnswer, dn as parseCreateCommentOptionsSchemaWithPKCErrorIfItFails, en as parseCommentIpfsSchemaWithPKCErrorIfItFails, et as PublicationClientsManager, f as KeyvBetterSqlite3, fn as parseCreateCommunityEditPublicationOptionsSchemaWithPKCErrorIfItFails, ft as signComment, g as decodeRpcChallengeVerificationPubsubMsg, gn as parseCreateRpcCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, h as decodeRpcChallengeRequestPubsubMsg, hn as parseCreateRemoteCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, in as parseCommunityAddressWithPKCErrorIfItFails, ir as require_undici, jn as RpcCommentRepliesPageParamSchema, jt as verifyVote, kn as RpcCancelExportParamSchema, ln as parseCreateCommentEditOptionsSchemaWithPKCErrorIfItFails, m as decodeRpcChallengePubsubMsg, mt as signCommentModeration, n as RpcRemoteCommunity, nn as parseCommentModerationPubsubMessagePublicationSchemaWithPKCErrorIfItFails, nt as InflightFetchManager, o as TrackedInstanceRegistry, ot as require_lib$1, p as decodeRpcChallengeAnswerPubsubMsg, pt as signCommentEdit, qt as getPKCAddressFromPublicKeySync, rn as parseCommentPubsubMessagePublicationWithPKCErrorIfItFails, rr as nativeFunctions$2, s as LRUCache, sn as parseCommunityEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, st as cleanUpBeforePublishing, t as RpcLocalCommunity, tt as PKCClientsManager, u as RemoteCommunity, un as parseCreateCommentModerationOptionsSchemaWithPKCErrorIfItFails, ut as signChallengeRequest, v as createSigner, vn as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, vt as signCommunityEdit, wn as parseRpcCommentUpdateEventWithPKCErrorIfItFails, wt as verifyCommentEdit, x as encryptEd25519AesGcm, xn as parseJsonWithPKCErrorIfFails, xt as verifyChallengeMessage, y as decryptEd25519AesGcm, yn as parseDecryptedChallengeVerification, yt as signVote, zn as RpcFetchCidParamSchema, zt as getCommunityNameFromWire } from "./rpc-local-community-DtdeJBOq.js";
4
+ import { o as getHeliaDebugContext } from "./util-B6v5HAdy.js";
5
5
  import path from "path";
6
6
  import assert from "assert";
7
7
  import fs from "fs";
@@ -289,7 +289,7 @@ var Publication = class extends import_lib.TypedEmitter {
289
289
  if (Object.values(this._challengeExchanges).some((exchange) => exchange.challenge)) return;
290
290
  const challengeMsgValidity = await verifyChallengeMessage({
291
291
  challenge: msg,
292
- pubsubTopic: this._communityPubsubTopicWithFallback(),
292
+ communityChallengeSignerAddress: this._communityChallengeMsgSignerAddress(),
293
293
  validateTimestampRange: true
294
294
  });
295
295
  if (!challengeMsgValidity.valid) {
@@ -359,7 +359,8 @@ var Publication = class extends import_lib.TypedEmitter {
359
359
  };
360
360
  this._challengeExchanges[msg.challengeRequestId.toString()].challenge = decryptedChallengeMsg;
361
361
  this._updatePublishingStateWithEmission("waiting-challenge-answers");
362
- Object.entries(this._clientsManager.pubsubProviderSubscriptions).filter(([, pubsubTopics]) => pubsubTopics.includes(this._communityPubsubTopicWithFallback())).map(([provider]) => provider).forEach((provider) => this._updatePubsubState("waiting-challenge-answers", provider));
362
+ const challengeTopic = this._community?.pubsubTopic;
363
+ Object.entries(this._clientsManager.pubsubProviderSubscriptions).filter(([, pubsubTopics]) => typeof challengeTopic === "string" && pubsubTopics.includes(challengeTopic)).map(([provider]) => provider).forEach((provider) => this._updatePubsubState("waiting-challenge-answers", provider));
363
364
  this.emit("challenge", decryptedChallengeMsg);
364
365
  }
365
366
  async _handleIncomingChallengeVerificationPubsubMessage(msg) {
@@ -367,7 +368,7 @@ var Publication = class extends import_lib.TypedEmitter {
367
368
  if (this._challengeExchanges[msg.challengeRequestId.toString()].challengeVerification) return;
368
369
  const signatureValidation = await verifyChallengeVerification({
369
370
  verification: msg,
370
- pubsubTopic: this._communityPubsubTopicWithFallback(),
371
+ communityChallengeSignerAddress: this._communityChallengeMsgSignerAddress(),
371
372
  validateTimestampRange: true
372
373
  });
373
374
  if (!signatureValidation.valid) {
@@ -522,7 +523,7 @@ var Publication = class extends import_lib.TypedEmitter {
522
523
  throw e;
523
524
  }
524
525
  else try {
525
- await this._clientsManager.pubsubPublishOnProvider(this._communityPubsubTopicWithFallback(), answerMsgToPublish, challengeExchange.providerUrl);
526
+ await this._clientsManager.pubsubPublishOnProvider(this._communityChallengePubsubExchangeTopic(), answerMsgToPublish, challengeExchange.providerUrl);
526
527
  } catch (e) {
527
528
  this._challengeExchanges[challengeExchange.challengeRequest.challengeRequestId.toString()].challengeAnswerPublishError = e;
528
529
  this._updatePublishingStateWithEmission("failed");
@@ -536,7 +537,8 @@ var Publication = class extends import_lib.TypedEmitter {
536
537
  this._challengeExchanges[challengeExchange.challengeRequest.challengeRequestId.toString()].challengeAnswer = decryptedChallengeAnswer;
537
538
  this._challengeExchanges[challengeExchange.challengeRequest.challengeRequestId.toString()].challengeAnswerPublishTimestamp = timestamp();
538
539
  this._updatePublishingStateWithEmission("waiting-challenge-verification");
539
- Object.entries(this._clientsManager.pubsubProviderSubscriptions).filter(([, pubsubTopics]) => pubsubTopics.includes(this._communityPubsubTopicWithFallback())).map(([provider]) => provider).forEach((provider) => this._updatePubsubState("waiting-challenge-verification", provider));
540
+ const challengeTopic = this._community?.pubsubTopic;
541
+ Object.entries(this._clientsManager.pubsubProviderSubscriptions).filter(([, pubsubTopics]) => typeof challengeTopic === "string" && pubsubTopics.includes(challengeTopic)).map(([provider]) => provider).forEach((provider) => this._updatePubsubState("waiting-challenge-verification", provider));
540
542
  log(`Responded to challenge with answers`, challengeAnswers);
541
543
  this.emit("challengeanswer", decryptedChallengeAnswer);
542
544
  }
@@ -556,10 +558,6 @@ var Publication = class extends import_lib.TypedEmitter {
556
558
  }
557
559
  _validateCommunityFields() {
558
560
  if (typeof this._community?.encryption?.publicKey !== "string") throw new PKCError("ERR_COMMUNITY_MISSING_FIELD", { communityPublicKey: this._community?.encryption?.publicKey });
559
- if (typeof this._communityPubsubTopicWithFallback() !== "string") throw new PKCError("ERR_COMMUNITY_MISSING_FIELD", {
560
- pubsubTopic: this._community?.pubsubTopic,
561
- address: this._community?.address
562
- });
563
561
  }
564
562
  _updatePublishingStateNoEmission(newState) {
565
563
  this.publishingState = newState;
@@ -599,11 +597,21 @@ var Publication = class extends import_lib.TypedEmitter {
599
597
  this.clients.pkcRpcClients[currentRpcUrl].state = newState;
600
598
  this.clients.pkcRpcClients[currentRpcUrl].emit("statechange", newState);
601
599
  }
602
- _communityPubsubTopicWithFallback() {
603
- const pubsubTopic = this._community?.pubsubTopic || this._community?.address;
604
- if (typeof pubsubTopic !== "string") throw Error("Failed to load the pubsub topic of community");
600
+ _communityChallengePubsubExchangeTopic() {
601
+ const pubsubTopic = this._community?.pubsubTopic;
602
+ if (typeof pubsubTopic !== "string") throw new PKCError("ERR_COMMUNITY_CHALLENGE_EXCHANGE_DISABLED", {
603
+ communityAddress: this._community?.address ?? this.communityAddress,
604
+ communityName: this._community?.name ?? this.communityName,
605
+ communityPublicKey: this._community?.publicKey ?? this.communityPublicKey,
606
+ publicationType: this.getType()
607
+ });
605
608
  return pubsubTopic;
606
609
  }
610
+ _communityChallengeMsgSignerAddress() {
611
+ const encryptionPublicKey = this._community?.encryption?.publicKey;
612
+ if (typeof encryptionPublicKey !== "string") throw Error("Failed to load the encryption public key of community");
613
+ return getPKCAddressFromPublicKeySync(encryptionPublicKey);
614
+ }
607
615
  _getCommunityCache() {
608
616
  const cached = this._pkc._memCaches.communityForPublishing.get(this.communityAddress, { allowStale: true });
609
617
  if (cached) return cached;
@@ -659,8 +667,8 @@ var Publication = class extends import_lib.TypedEmitter {
659
667
  }
660
668
  this._rpcPublishSubscriptionId = void 0;
661
669
  this._setRpcClientState("stopped");
662
- } else if (this._community) {
663
- await this._clientsManager.pubsubUnsubscribe(this._communityPubsubTopicWithFallback(), this._handleChallengeExchange);
670
+ } else if (typeof this._community?.pubsubTopic === "string") {
671
+ await this._clientsManager.pubsubUnsubscribe(this._community.pubsubTopic, this._handleChallengeExchange);
664
672
  Object.values(this._challengeExchanges).forEach((exchange) => this._updatePubsubState("stopped", exchange.providerUrl));
665
673
  }
666
674
  }
@@ -775,7 +783,7 @@ var Publication = class extends import_lib.TypedEmitter {
775
783
  timestamp: timestamp()
776
784
  });
777
785
  const challengeRequest = await this._signAndValidateChallengeRequestBeforePublishing(toSignMsg, pubsubMessageSigner);
778
- log("Attempting to publish", this.getType(), "to pubsub topic", this._communityPubsubTopicWithFallback(), "with provider", providerUrl, "request.encrypted=", pubsubMsgToEncrypt);
786
+ log("Attempting to publish", this.getType(), "to pubsub topic", this._community?.pubsubTopic, "with provider", providerUrl, "request.encrypted=", pubsubMsgToEncrypt);
779
787
  const decryptedChallengeRequest = {
780
788
  ...challengeRequest,
781
789
  ...pubsubMsgToEncrypt
@@ -868,9 +876,9 @@ var Publication = class extends import_lib.TypedEmitter {
868
876
  this._updatePublishingStateWithEmission("publishing-challenge-request");
869
877
  this._updatePubsubState("subscribing-pubsub", providerUrl);
870
878
  try {
871
- await this._clientsManager.pubsubSubscribeOnProvider(this._communityPubsubTopicWithFallback(), this._handleChallengeExchange, providerUrl);
879
+ await this._clientsManager.pubsubSubscribeOnProvider(this._communityChallengePubsubExchangeTopic(), this._handleChallengeExchange, providerUrl);
872
880
  this._updatePubsubState("publishing-challenge-request", providerUrl);
873
- await this._clientsManager.pubsubPublishOnProvider(this._communityPubsubTopicWithFallback(), challengeRequest, providerUrl);
881
+ await this._clientsManager.pubsubPublishOnProvider(this._communityChallengePubsubExchangeTopic(), challengeRequest, providerUrl);
874
882
  this._challengeExchanges[challengeRequest.challengeRequestId.toString()].challengeRequestPublishTimestamp = timestamp();
875
883
  } catch (e) {
876
884
  log.error("Failed to publish challenge request using provider ", providerUrl, e);
@@ -894,7 +902,7 @@ var Publication = class extends import_lib.TypedEmitter {
894
902
  await this._postSucessOrFailurePublishing();
895
903
  const allAttemptsFailedError = new PKCError("ERR_ALL_PUBSUB_PROVIDERS_THROW_ERRORS", {
896
904
  challengeExchanges: this._challengeExchangesFormattedForErrors(),
897
- pubsubTopic: this._communityPubsubTopicWithFallback(),
905
+ pubsubTopic: this._community?.pubsubTopic,
898
906
  providerHeliaContexts: this._libp2pJsClientHeliaContexts()
899
907
  });
900
908
  log.error("All attempts to publish", this.getType(), "has failed", allAttemptsFailedError);
@@ -958,12 +966,30 @@ var Publication = class extends import_lib.TypedEmitter {
958
966
  await this._validateSignatureHook();
959
967
  if (this._pkc._pkcRpcClient) return this._publishWithRpc();
960
968
  const options = { acceptedChallengeTypes: [] };
961
- const providers = this._getPubsubProviders();
962
969
  const startedCommunity = findStartedCommunity(this._pkc, {
963
970
  publicKey: this.communityPublicKey,
964
971
  name: this.communityName
965
972
  });
966
973
  if (startedCommunity) return this._publishWithLocalCommunity(startedCommunity, await this._generateChallengeRequestToPublish("publishing directly to local community instance", options.acceptedChallengeTypes));
974
+ if (typeof this._community?.pubsubTopic !== "string") {
975
+ await this._postSucessOrFailurePublishing();
976
+ const error = new PKCError("ERR_COMMUNITY_CHALLENGE_EXCHANGE_DISABLED", {
977
+ communityAddress: this._community?.address ?? this.communityAddress,
978
+ communityName: this._community?.name ?? this.communityName,
979
+ communityPublicKey: this._community?.publicKey ?? this.communityPublicKey,
980
+ publicationType: this.getType()
981
+ });
982
+ log.error("Community has its challenge exchange disabled, will not publish", this.getType(), error);
983
+ this._changePublicationStateEmitEventEmitStateChangeEvent({
984
+ newPublishingState: "failed",
985
+ event: {
986
+ name: "error",
987
+ args: [error]
988
+ }
989
+ });
990
+ throw error;
991
+ }
992
+ const providers = this._getPubsubProviders();
967
993
  let currentPubsubProviderIndex = 0;
968
994
  while (!this._didWeReceiveChallengeOrChallengeVerification() && currentPubsubProviderIndex < providers.length) {
969
995
  const providerUrl = providers[currentPubsubProviderIndex];
@@ -971,9 +997,9 @@ var Publication = class extends import_lib.TypedEmitter {
971
997
  this._updatePublishingStateWithEmission("publishing-challenge-request");
972
998
  this._updatePubsubState("subscribing-pubsub", providerUrl);
973
999
  try {
974
- await this._clientsManager.pubsubSubscribeOnProvider(this._communityPubsubTopicWithFallback(), this._handleChallengeExchange, providerUrl);
1000
+ await this._clientsManager.pubsubSubscribeOnProvider(this._communityChallengePubsubExchangeTopic(), this._handleChallengeExchange, providerUrl);
975
1001
  this._updatePubsubState("publishing-challenge-request", providerUrl);
976
- await this._clientsManager.pubsubPublishOnProvider(this._communityPubsubTopicWithFallback(), challengeRequest, providerUrl);
1002
+ await this._clientsManager.pubsubPublishOnProvider(this._communityChallengePubsubExchangeTopic(), challengeRequest, providerUrl);
977
1003
  this._challengeExchanges[challengeRequest.challengeRequestId.toString()].challengeRequestPublishTimestamp = timestamp();
978
1004
  } catch (e) {
979
1005
  this._updatePubsubState("stopped", providerUrl);
@@ -984,7 +1010,7 @@ var Publication = class extends import_lib.TypedEmitter {
984
1010
  await this._postSucessOrFailurePublishing();
985
1011
  const allAttemptsFailedError = new PKCError("ERR_ALL_PUBSUB_PROVIDERS_THROW_ERRORS", {
986
1012
  challengeExchanges: this._challengeExchangesFormattedForErrors(),
987
- pubsubTopic: this._communityPubsubTopicWithFallback(),
1013
+ pubsubTopic: this._community?.pubsubTopic,
988
1014
  providerHeliaContexts: this._libp2pJsClientHeliaContexts()
989
1015
  });
990
1016
  log.error("All attempts to publish", this.getType(), "has failed", allAttemptsFailedError);
@@ -8875,7 +8901,7 @@ var PKC$1 = class extends PKCTypedEmitter {
8875
8901
  this.clients.libp2pJsClients = {};
8876
8902
  if (!this.libp2pJsClientsOptions) return;
8877
8903
  if (!this.httpRoutersOptions) throw Error("httpRoutersOptions is required for libp2pJsClient");
8878
- const { createLibp2pJsClientOrUseExistingOne } = await import("./helia-for-pkc-DooZDxJi.js");
8904
+ const { createLibp2pJsClientOrUseExistingOne } = await import("./helia-for-pkc-B-75U9z9.js");
8879
8905
  for (const clientOptions of this.libp2pJsClientsOptions) {
8880
8906
  const heliaNode = await createLibp2pJsClientOrUseExistingOne({
8881
8907
  ...clientOptions,
@@ -9123,7 +9149,7 @@ var PKC$1 = class extends PKCTypedEmitter {
9123
9149
  const log = logger_default("pkc-js:pkc:createLocalCommunity");
9124
9150
  log.trace("Received community options to create a local community instance:", options);
9125
9151
  if (!this._canCreateNewLocalCommunity()) throw new PKCError("ERR_CAN_NOT_CREATE_A_LOCAL_COMMUNITY", { pkcOptions: this._userPKCOptions });
9126
- const { LocalCommunity, createNewLocalCommunityDb, updateInstancePropsWithStartedCommunityOrDb } = await import("./local-community-EFv2VpQI.js");
9152
+ const { LocalCommunity, createNewLocalCommunityDb, updateInstancePropsWithStartedCommunityOrDb } = await import("./local-community-CIVs_iuS.js");
9127
9153
  const isLocalCommunity = (await listCommunitiesSync(this)).includes(options.address);
9128
9154
  const community = new LocalCommunity(this);
9129
9155
  if (isLocalCommunity) {
@@ -1,15 +1,15 @@
1
1
  import { i as __toESM, n as __exportAll, r as __require, t as __commonJSMin } from "./chunk-2rV9d50f.js";
2
- import { $ as pubsubTopicToDhtKey, $t as CommunityEditOptionsSchema, A as extractNetworkErrorDetails, An as CreateCommentOptionsWithRefinementSchema, Ar as record, At as trackStartedCommunity, B as isIpfsCid, Bn as CreateCommentEditOptionsWithRefinementSchema, Cr as _enum, Ct as findUpdatingCommunity, D as deepMergeRuntimeFields, Dn as CommentUpdateSignedPropertyNames, Dr as literal, E as createAbortError, En as CommentUpdateSchema, Er as custom, Et as listUpdatingCommunities, Ft as untrackUpdatingCommunity, Gn as CidPathSchema, Gt as CommentModerationPubsubMessagePublicationSchema, H as isIpns, Hn as AuthorCommentIpfsReservedFields, Ht as CommunityEditPubsubMessagePublicationSchema, I as getPostUpdateTimestampRange, In as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema, It as require_sha256$1, Jn as CommunityAuthorChallengeReservedFieldNames, Jt as CommentModerationsTableRowSchema, Kn as CidStringSchema, L as hideClassPrivateProps, Mn as ModQueuePageIpfsSchema, Mt as trackUpdatingCommunity, Nn as PageIpfsSchema, Nt as untrackStartedCommunity, O as derivePublicationFromChallengeRequest, Or as number, Ot as refreshTrackedCommunityAliases, Pn as CommentEditChallengeRequestToEncryptSchema, Q as isStringDomain, Qn as n$9, Qt as CommunityChallengeSettingSchema, R as ipnsNameToIpnsOverPubsubTopic, Rn as CommentEditSignedPropertyNames, Rt as pTimeout, Sn as CommentUpdateChallengeReservedFieldNames, St as findUpdatingComment, Tn as CommentUpdateReservedFields, Tr as boolean, U as isIpnsPath, Ut as CreateCommunityEditPublicationOptionsWithRefinementSchema, V as isIpfsPath, Vn as AuthorAddressSchema, Vt as CommunityEditPublicationSignedPropertyNames, Wn as ChallengeAnswersSchema, Wt as CommentModerationChallengeRequestToEncryptSchema, X as isRequestPubsubPublicationOfPost, Xn as n$10, Xt as ChallengeFileFactorySchema, Yn as CreateSignerSchema, Yt as CreateCommentModerationOptionsWithRefinementSchema, Z as isRequestPubsubPublicationOfReply, Zt as ChallengeFileSchema, _ as PKCUserOptionBaseSchema, _n as CommentIpfsReservedFields, _r as PKCError, _t as timestamp, an as CreateRemoteCommunityFunctionArgumentSchema, ar as t$12, b as areEquivalentCommunityAddresses, bn as CommentPubsubMessageWithFlexibleAuthorRefinementSchema, br as require_supports_color, c as ChallengeVerificationMessageSignedPropertyNames, cr as t$10, ct as resolveWhenPredicateIsTrue, dn as VoteChallengeRequestToEncryptSchema, dr as require_retry$1, en as CommunityExportRecordsSchema, er as t$13, f as DecryptedChallengeSchema, fn as VotePubsubMessagePublicationSchema, fr as FailedToFetchCommentIpfsFromGatewaysError, ft as shortifyAddress, g as PKCParsedOptionsSchema, gn as CommentChallengeRequestToEncryptSchema, gr as FailedToFetchPageIpfsFromGatewaysError, gt as throwIfAbortSignalAborted, h as NameResolverSerializedSchema, hr as FailedToFetchGenericIpfsFromGatewaysError, i as ChallengeMessageSignedPropertyNames, in as CreateNewLocalCommunityUserOptionsSchema, ir as r$8, it as removeNullUndefinedEmptyObjectsValuesRecursively, j as fetchAndValidateIpnsRecordFromGateway, jn as GetPageParamSchema, jr as string, k as doesDomainAddressHaveCapitalLetter, kr as object, l as DecryptedChallengeAnswerSchema, ln as RpcRemoteCommunityUpdateEventResultSchema, lr as t$9, m as NameResolveCacheOptionsSchema, mn as VoteSignedPropertyNames, mr as FailedToFetchCommunityFromGatewaysError, mt as sleepUntilTimeoutOrAbort, n as ChallengeAnswerMessageSignedPropertyNames, nn as CommunityIpfsSchema, nr as e$5, o as ChallengeRequestMessageSignedPropertyNames, on as CreateRpcCommunityFunctionArgumentSchema, or as n$8, p as DecryptedChallengeVerificationSchema, pr as FailedToFetchCommentUpdateFromGatewaysError, pt as shortifyCid, qn as CommunityAddressSchema, qt as CommentModerationSignedPropertyNames, rn as CommunitySignedPropertyNames, rr as t$11, sn as ExportCommunityModLogsOptionsSchema, sr as r$7, tn as CommunityIpfsReservedFields, tr as e$6, tt as raceAgainstAbort, un as CreateVoteUserOptionsWithRefinementSchema, ur as e$4, v as PKCUserOptionsSchema, vn as CommentIpfsSchema, vr as messages, vt as waitForUpdateInCommunityInstanceWithErrorAndTimeout, wn as CommentUpdateForChallengeVerificationSignedPropertyNames, wr as array, wt as listStartedCommunities, x as calculateIpfsCidV0, xn as CommentSignedPropertyNames, xr as require_ms$1, xt as findStartedCommunity, yr as logger_default, z as isAbortError, zt as CommunityEditPublicationChallengeRequestToEncryptSchema } from "./schema-DMHTAMSM.js";
2
+ import { $ as pubsubTopicToDhtKey, $t as CommunityEditOptionsSchema, A as extractNetworkErrorDetails, An as CreateCommentOptionsWithRefinementSchema, Ar as record, At as trackStartedCommunity, B as isIpfsCid, Bn as CreateCommentEditOptionsWithRefinementSchema, Cr as _enum, Ct as findUpdatingCommunity, D as deepMergeRuntimeFields, Dn as CommentUpdateSignedPropertyNames, Dr as literal, E as createAbortError, En as CommentUpdateSchema, Er as custom, Et as listUpdatingCommunities, Ft as untrackUpdatingCommunity, Gn as CidPathSchema, Gt as CommentModerationPubsubMessagePublicationSchema, H as isIpns, Hn as AuthorCommentIpfsReservedFields, Ht as CommunityEditPubsubMessagePublicationSchema, I as getPostUpdateTimestampRange, In as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema, It as require_sha256$1, Jn as CommunityAuthorChallengeReservedFieldNames, Jt as CommentModerationsTableRowSchema, Kn as CidStringSchema, L as hideClassPrivateProps, Mn as ModQueuePageIpfsSchema, Mt as trackUpdatingCommunity, Nn as PageIpfsSchema, Nt as untrackStartedCommunity, O as derivePublicationFromChallengeRequest, Or as number, Ot as refreshTrackedCommunityAliases, Pn as CommentEditChallengeRequestToEncryptSchema, Q as isStringDomain, Qn as n$9, Qt as CommunityChallengeSettingSchema, R as ipnsNameToIpnsOverPubsubTopic, Rn as CommentEditSignedPropertyNames, Rt as pTimeout, Sn as CommentUpdateChallengeReservedFieldNames, St as findUpdatingComment, Tn as CommentUpdateReservedFields, Tr as boolean, U as isIpnsPath, Ut as CreateCommunityEditPublicationOptionsWithRefinementSchema, V as isIpfsPath, Vn as AuthorAddressSchema, Vt as CommunityEditPublicationSignedPropertyNames, Wn as ChallengeAnswersSchema, Wt as CommentModerationChallengeRequestToEncryptSchema, X as isRequestPubsubPublicationOfPost, Xn as n$10, Xt as ChallengeFileFactorySchema, Yn as CreateSignerSchema, Yt as CreateCommentModerationOptionsWithRefinementSchema, Z as isRequestPubsubPublicationOfReply, Zt as ChallengeFileSchema, _ as PKCUserOptionBaseSchema, _n as CommentIpfsReservedFields, _r as PKCError, _t as timestamp, an as CreateRemoteCommunityFunctionArgumentSchema, ar as t$12, b as areEquivalentCommunityAddresses, bn as CommentPubsubMessageWithFlexibleAuthorRefinementSchema, br as require_supports_color, c as ChallengeVerificationMessageSignedPropertyNames, cr as t$10, ct as resolveWhenPredicateIsTrue, dn as VoteChallengeRequestToEncryptSchema, dr as require_retry$1, en as CommunityExportRecordsSchema, er as t$13, f as DecryptedChallengeSchema, fn as VotePubsubMessagePublicationSchema, fr as FailedToFetchCommentIpfsFromGatewaysError, ft as shortifyAddress, g as PKCParsedOptionsSchema, gn as CommentChallengeRequestToEncryptSchema, gr as FailedToFetchPageIpfsFromGatewaysError, gt as throwIfAbortSignalAborted, h as NameResolverSerializedSchema, hr as FailedToFetchGenericIpfsFromGatewaysError, i as ChallengeMessageSignedPropertyNames, in as CreateNewLocalCommunityUserOptionsSchema, ir as r$8, it as removeNullUndefinedEmptyObjectsValuesRecursively, j as fetchAndValidateIpnsRecordFromGateway, jn as GetPageParamSchema, jr as string, k as doesDomainAddressHaveCapitalLetter, kr as object, l as DecryptedChallengeAnswerSchema, ln as RpcRemoteCommunityUpdateEventResultSchema, lr as t$9, m as NameResolveCacheOptionsSchema, mn as VoteSignedPropertyNames, mr as FailedToFetchCommunityFromGatewaysError, mt as sleepUntilTimeoutOrAbort, n as ChallengeAnswerMessageSignedPropertyNames, nn as CommunityIpfsSchema, nr as e$5, o as ChallengeRequestMessageSignedPropertyNames, on as CreateRpcCommunityFunctionArgumentSchema, or as n$8, p as DecryptedChallengeVerificationSchema, pr as FailedToFetchCommentUpdateFromGatewaysError, pt as shortifyCid, qn as CommunityAddressSchema, qt as CommentModerationSignedPropertyNames, rn as CommunitySignedPropertyNames, rr as t$11, sn as ExportCommunityModLogsOptionsSchema, sr as r$7, tn as CommunityIpfsReservedFields, tr as e$6, tt as raceAgainstAbort, un as CreateVoteUserOptionsWithRefinementSchema, ur as e$4, v as PKCUserOptionsSchema, vn as CommentIpfsSchema, vr as messages, vt as waitForUpdateInCommunityInstanceWithErrorAndTimeout, wn as CommentUpdateForChallengeVerificationSignedPropertyNames, wr as array, wt as listStartedCommunities, x as calculateIpfsCidV0, xn as CommentSignedPropertyNames, xr as require_ms$1, xt as findStartedCommunity, yr as logger_default, z as isAbortError, zt as CommunityEditPublicationChallengeRequestToEncryptSchema } from "./schema-B1Ot-kux.js";
3
3
  import { t as all } from "./src-CYIMjhjK.js";
4
4
  import http from "node:http";
5
5
  import { createHash } from "node:crypto";
6
6
  import { pathToFileURL } from "node:url";
7
7
  import fsp from "node:fs/promises";
8
- import Path from "node:path";
8
+ import path from "node:path";
9
9
  import dns from "node:dns";
10
10
  import os from "os";
11
11
  import { closeSync, createReadStream, existsSync, openSync, promises, readSync, readdirSync, rm, watch } from "node:fs";
12
- import path from "path";
12
+ import path$1 from "path";
13
13
  import assert from "assert";
14
14
  import { Agent } from "https";
15
15
  import { Agent as Agent$1 } from "http";
@@ -97854,6 +97854,10 @@ async function verifyCommunity({ community, communityIpnsName, resolveAuthorName
97854
97854
  valid: false,
97855
97855
  reason: messages.ERR_COMMUNITY_IPNS_NAME_DOES_NOT_MATCH_SIGNATURE_PUBLIC_KEY
97856
97856
  };
97857
+ if (!getPeerIdFromPublicKey(community.encryption.publicKey).equals(signaturePeerId)) return {
97858
+ valid: false,
97859
+ reason: messages.ERR_COMMUNITY_ENCRYPTION_PUBLIC_KEY_DOES_NOT_MATCH_SIGNATURE_PUBLIC_KEY
97860
+ };
97857
97861
  clientsManager._pkc._memCaches.communityVerificationCache.set(cacheKey, true);
97858
97862
  return { valid: true };
97859
97863
  }
@@ -97962,12 +97966,12 @@ async function verifyChallengeRequest({ request, validateTimestampRange }) {
97962
97966
  };
97963
97967
  return _validateSignatureOfPubsubMsg(request);
97964
97968
  }
97965
- async function verifyChallengeMessage({ challenge, pubsubTopic, validateTimestampRange }) {
97969
+ async function verifyChallengeMessage({ challenge, communityChallengeSignerAddress, validateTimestampRange }) {
97966
97970
  if (!_allFieldsOfRecordInSignedPropertyNames(challenge)) return {
97967
97971
  valid: false,
97968
97972
  reason: messages.ERR_CHALLENGE_INCLUDES_FIELD_NOT_IN_SIGNED_PROPERTY_NAMES
97969
97973
  };
97970
- if (await getPKCAddressFromPublicKeyBuffer(challenge.signature.publicKey) !== pubsubTopic) return {
97974
+ if (await getPKCAddressFromPublicKeyBuffer(challenge.signature.publicKey) !== communityChallengeSignerAddress) return {
97971
97975
  valid: false,
97972
97976
  reason: messages.ERR_CHALLENGE_MSG_SIGNER_IS_NOT_COMMUNITY
97973
97977
  };
@@ -97990,12 +97994,12 @@ async function verifyChallengeAnswer({ answer, validateTimestampRange }) {
97990
97994
  };
97991
97995
  return _validateSignatureOfPubsubMsg(answer);
97992
97996
  }
97993
- async function verifyChallengeVerification({ verification, pubsubTopic, validateTimestampRange }) {
97997
+ async function verifyChallengeVerification({ verification, communityChallengeSignerAddress, validateTimestampRange }) {
97994
97998
  if (!_allFieldsOfRecordInSignedPropertyNames(verification)) return {
97995
97999
  valid: false,
97996
98000
  reason: messages.ERR_CHALLENGE_VERIFICATION_INCLUDES_FIELD_NOT_IN_SIGNED_PROPERTY_NAMES
97997
98001
  };
97998
- if (await getPKCAddressFromPublicKeyBuffer(verification.signature.publicKey) !== pubsubTopic) return {
98002
+ if (await getPKCAddressFromPublicKeyBuffer(verification.signature.publicKey) !== communityChallengeSignerAddress) return {
97999
98003
  valid: false,
98000
98004
  reason: messages.ERR_CHALLENGE_VERIFICATION_MSG_SIGNER_IS_NOT_COMMUNITY
98001
98005
  };
@@ -98603,10 +98607,14 @@ var BaseClientsManager = class BaseClientsManager {
98603
98607
  });
98604
98608
  }
98605
98609
  getDefaultKuboPubsubClient() {
98606
- const defaultKuboPubsubClient = t$13(this._pkc.clients.pubsubKuboRpcClients)[0];
98607
- if (defaultKuboPubsubClient) return this._pkc.clients.pubsubKuboRpcClients[defaultKuboPubsubClient];
98610
+ const defaultKuboPubsubClient = this.getDefaultKuboPubsubClientIfAny();
98611
+ if (defaultKuboPubsubClient) return defaultKuboPubsubClient;
98608
98612
  throw new PKCError("ERR_NO_DEFAULT_KUBO_RPC_PUBSUB_PROVIDER", { pubsubKuboRpcClients: this._pkc.clients.pubsubKuboRpcClients });
98609
98613
  }
98614
+ getDefaultKuboPubsubClientIfAny() {
98615
+ const defaultKuboPubsubClient = t$13(this._pkc.clients.pubsubKuboRpcClients)[0];
98616
+ return defaultKuboPubsubClient ? this._pkc.clients.pubsubKuboRpcClients[defaultKuboPubsubClient] : void 0;
98617
+ }
98610
98618
  getIpfsClientWithKuboRpcClientFunctions() {
98611
98619
  const defaultKuboRpcClient = t$13(this._pkc.clients.kuboRpcClients)[0];
98612
98620
  if (defaultKuboRpcClient) return this._pkc.clients.kuboRpcClients[defaultKuboRpcClient]._client;
@@ -101592,14 +101600,14 @@ var CommentClientsManager = class extends PublicationClientsManager {
101592
101600
  };
101593
101601
  //#endregion
101594
101602
  //#region dist/node/runtime/node/util.js
101595
- const getDefaultDataPath = () => path.join(process.cwd(), ".pkc");
101603
+ const getDefaultDataPath = () => path$1.join(process.cwd(), ".pkc");
101596
101604
  const getDefaultCommunityDbConfig = async (communityAddress, pkc) => {
101597
101605
  let filename;
101598
101606
  if (pkc.noData) filename = ":memory:";
101599
101607
  else {
101600
101608
  assert(typeof pkc.dataPath === "string", "pkc.dataPath need to be defined to get default community db config");
101601
- filename = path.join(pkc.dataPath, "communities", communityAddress);
101602
- await promises.mkdir(path.dirname(filename), { recursive: true });
101609
+ filename = path$1.join(pkc.dataPath, "communities", communityAddress);
101610
+ await promises.mkdir(path$1.dirname(filename), { recursive: true });
101603
101611
  }
101604
101612
  return {
101605
101613
  filename,
@@ -101698,7 +101706,7 @@ const setNativeFunctions = (newNativeFunctions) => {
101698
101706
  };
101699
101707
  const deleteOldCommunityInWindows = async (subPath, pkc) => {
101700
101708
  const log = logger_default("pkc-js:community:deleteStaleCommunityInWindows");
101701
- const communityAddress = path.basename(subPath);
101709
+ const communityAddress = path$1.basename(subPath);
101702
101710
  await new Promise((resolve) => setTimeout(resolve, 1e4));
101703
101711
  try {
101704
101712
  await promises.rm(subPath, { force: true });
@@ -101722,7 +101730,7 @@ async function tryToDeleteCommunitiesThatFailedToBeDeletedBefore(pkc, log) {
101722
101730
  }
101723
101731
  const communitiesThatWereDeletedSuccessfully = [];
101724
101732
  for (const communityAddress of deletedPersistentCommunities) {
101725
- const communityPath = path.join(pkc.dataPath, "communities", communityAddress);
101733
+ const communityPath = path$1.join(pkc.dataPath, "communities", communityAddress);
101726
101734
  try {
101727
101735
  await promises.rm(communityPath, { force: true });
101728
101736
  log(`Succeeded in deleting old db path (${communityAddress})`);
@@ -101746,7 +101754,7 @@ async function tryToDeleteCommunitiesThatFailedToBeDeletedBefore(pkc, log) {
101746
101754
  function listCommunitiesSync(pkc) {
101747
101755
  logger_default("pkc-js:listCommunitiesSync");
101748
101756
  if (typeof pkc.dataPath !== "string") throw Error("pkc.dataPath needs to be defined to listCommunities");
101749
- const communitiesPath = path.join(pkc.dataPath, "communities");
101757
+ const communitiesPath = path$1.join(pkc.dataPath, "communities");
101750
101758
  const files = readdirSync(communitiesPath, {
101751
101759
  recursive: false,
101752
101760
  withFileTypes: false
@@ -101754,7 +101762,7 @@ function listCommunitiesSync(pkc) {
101754
101762
  const communityFilesWeDontNeedToCheck = pkc.communities ? files.filter((address) => pkc.communities.includes(address)) : [];
101755
101763
  const sqliteFiles = files.filter((address) => !communityFilesWeDontNeedToCheck.includes(address)).filter((address) => {
101756
101764
  try {
101757
- const filePath = path.join(communitiesPath, address);
101765
+ const filePath = path$1.join(communitiesPath, address);
101758
101766
  if (!existsSync(filePath)) return false;
101759
101767
  const fd = openSync(filePath, "r");
101760
101768
  const buffer = Buffer.alloc(16);
@@ -101835,7 +101843,7 @@ var BackupAbortError = class extends Error {
101835
101843
  async function backupCommunityDb(opts) {
101836
101844
  const { sourcePath, destPath, includePrivateKey, onProgress, signal } = opts;
101837
101845
  if (signal?.aborted) throw new BackupAbortError();
101838
- await promises.mkdir(path.dirname(destPath), { recursive: true });
101846
+ await promises.mkdir(path$1.dirname(destPath), { recursive: true });
101839
101847
  const partialPath = destPath + ".partial";
101840
101848
  try {
101841
101849
  await promises.unlink(partialPath);
@@ -101919,9 +101927,9 @@ async function statAndHashFile(filePath) {
101919
101927
  }
101920
101928
  async function moveCommunityDbToDeletedDirectory(communityAddress, pkc) {
101921
101929
  if (typeof pkc.dataPath !== "string") throw Error("pkc.dataPath is not defined");
101922
- const oldPath = path.join(pkc.dataPath, "communities", communityAddress);
101923
- const newPath = path.join(pkc.dataPath, "communities", "deleted", communityAddress);
101924
- await promises.mkdir(path.join(pkc.dataPath, "communities", "deleted"), { recursive: true });
101930
+ const oldPath = path$1.join(pkc.dataPath, "communities", communityAddress);
101931
+ const newPath = path$1.join(pkc.dataPath, "communities", "deleted", communityAddress);
101932
+ await promises.mkdir(path$1.join(pkc.dataPath, "communities", "deleted"), { recursive: true });
101925
101933
  if (!existsSync(oldPath)) throw Error(`Source database ${oldPath} does not exist`);
101926
101934
  try {
101927
101935
  const sourceDb = new Database(oldPath, { fileMustExist: true });
@@ -101957,7 +101965,7 @@ async function createKuboRpcClient(kuboRpcClientOptions) {
101957
101965
  }
101958
101966
  async function monitorCommunitiesDirectory(pkc) {
101959
101967
  const watchAbortController = new AbortController();
101960
- const communitiesPath = path.join(pkc.dataPath, "communities");
101968
+ const communitiesPath = path$1.join(pkc.dataPath, "communities");
101961
101969
  await promises.mkdir(communitiesPath, { recursive: true });
101962
101970
  const extensionsToIgnore = [
101963
101971
  ".lock",
@@ -124735,6 +124743,10 @@ var CommunityClientsManager = class extends PKCClientsManager {
124735
124743
  updateKuboRpcPubsubState(newState, pubsubProvider) {
124736
124744
  super.updateKuboRpcPubsubState(newState, pubsubProvider);
124737
124745
  }
124746
+ updateKuboRpcPubsubStateIfProviderExists(newState) {
124747
+ const pubsubClient = this.getDefaultKuboPubsubClientIfAny();
124748
+ if (pubsubClient) this.updateKuboRpcPubsubState(newState, pubsubClient.url);
124749
+ }
124738
124750
  updateGatewayState(newState, gateway) {
124739
124751
  super.updateGatewayState(newState, gateway);
124740
124752
  }
@@ -125488,6 +125500,7 @@ var RemoteCommunity = class extends import_lib$1.TypedEmitter {
125488
125500
  const log = logger_default("pkc-js:remote-community:initCommunityIpfsPropsNoMerge");
125489
125501
  this.raw.communityIpfs = newProps;
125490
125502
  this.initRemoteCommunityPropsNoMerge(newProps);
125503
+ this.pubsubTopicRoutingCid = newProps.pubsubTopic ? pubsubTopicToDhtKey(newProps.pubsubTopic) : void 0;
125491
125504
  const unknownProps = r$8(t$13(this.raw.communityIpfs), t$13(CommunityIpfsSchema.shape));
125492
125505
  if (unknownProps.length > 0) {
125493
125506
  log(`Found unknown props on community (${this.address}) ipfs record`, unknownProps);
@@ -125513,10 +125526,7 @@ var RemoteCommunity = class extends import_lib$1.TypedEmitter {
125513
125526
  this.ipnsPubsubTopic = ipnsNameToIpnsOverPubsubTopic(this.ipnsName);
125514
125527
  this.ipnsPubsubTopicRoutingCid = pubsubTopicToDhtKey(this.ipnsPubsubTopic);
125515
125528
  }
125516
- if (!this.pubsubTopicRoutingCid) {
125517
- if ("pubsubTopicRoutingCid" in newProps) this.pubsubTopicRoutingCid = newProps.pubsubTopicRoutingCid;
125518
- else if (this.raw.communityIpfs) this.pubsubTopicRoutingCid = pubsubTopicToDhtKey(newProps.pubsubTopic || this.pubsubTopic || ("address" in newProps ? newProps.address : void 0) || this.address);
125519
- }
125529
+ if (!this.pubsubTopicRoutingCid && "pubsubTopicRoutingCid" in newProps) this.pubsubTopicRoutingCid = newProps.pubsubTopicRoutingCid;
125520
125530
  }
125521
125531
  initRemoteCommunityPropsNoMerge(newProps) {
125522
125532
  const incomingIpnsHops = newProps.ipnsHops;
@@ -125584,6 +125594,7 @@ var RemoteCommunity = class extends import_lib$1.TypedEmitter {
125584
125594
  this.raw.communityIpfs = void 0;
125585
125595
  this.updateCid = void 0;
125586
125596
  this.initRemoteCommunityPropsNoMerge({});
125597
+ this.pubsubTopicRoutingCid = void 0;
125587
125598
  this.publicKey = newPublicKey;
125588
125599
  this.ipnsName = newPublicKey;
125589
125600
  this.ipnsPubsubTopic = ipnsNameToIpnsOverPubsubTopic(newPublicKey);
@@ -125857,11 +125868,11 @@ var AddressRewriterDatabase = class {
125857
125868
  if (kuboConfig && typeof kuboConfig === "object" && "host" in kuboConfig && "port" in kuboConfig) kuboIdentifier = `${kuboConfig.host}_${kuboConfig.port}`;
125858
125869
  const proxyIdentifier = `${proxyTarget.hostname}_${proxyTarget.port || (proxyTarget.protocol === "https:" ? "443" : "80")}`;
125859
125870
  const fileName = `address_rewriter_${kuboIdentifier}_${proxyIdentifier}.db`;
125860
- return Path.join(dataPath, ".address-rewriter", fileName);
125871
+ return path.join(dataPath, ".address-rewriter", fileName);
125861
125872
  }
125862
125873
  async initialize() {
125863
125874
  try {
125864
- const dbDir = Path.dirname(this._dbPath);
125875
+ const dbDir = path.dirname(this._dbPath);
125865
125876
  await fsp.mkdir(dbDir, { recursive: true });
125866
125877
  this._db = new Database(this._dbPath);
125867
125878
  this._db.exec(`
@@ -5136,6 +5136,7 @@ var messages;
5136
5136
  messages["ERR_COMMUNITY_CAN_EITHER_RUN_OR_UPDATE"] = "Community can either sync through .start() or update, but not both";
5137
5137
  messages["ERR_PUBLICATION_MISSING_FIELD"] = "Publication is missing field(s)";
5138
5138
  messages["ERR_COMMUNITY_MISSING_FIELD"] = "Community is missing field needed for publishing";
5139
+ messages["ERR_COMMUNITY_CHALLENGE_EXCHANGE_DISABLED"] = "The community record has no pubsubTopic, which means its challenge exchange is disabled and it does not accept publications over pubsub";
5139
5140
  messages["ERR_COMMUNITY_OPTIONS_MISSING_ADDRESS"] = "The options sent to pkc.createCommunity() is missing address or signer";
5140
5141
  messages["ERR_INVALID_COMMUNITY_ADDRESS_SCHEMA"] = "Community address is incorrect. Address should be either a domain or IPNS";
5141
5142
  messages["ERR_CID_IS_INVALID"] = "CID is invalid";
@@ -5284,6 +5285,7 @@ var messages;
5284
5285
  messages["ERR_AUTHOR_NOT_MATCHING_SIGNATURE"] = "comment.author.address doesn't match comment.signature.publicKey";
5285
5286
  messages["ERR_AUTHOR_NAME_MUST_BE_A_DOMAIN"] = "author.name must be a domain name (e.g. 'example.bso')";
5286
5287
  messages["ERR_COMMUNITY_IPNS_NAME_DOES_NOT_MATCH_SIGNATURE_PUBLIC_KEY"] = "The IPNS name of community doesn't match community.signature.publicKey";
5288
+ messages["ERR_COMMUNITY_ENCRYPTION_PUBLIC_KEY_DOES_NOT_MATCH_SIGNATURE_PUBLIC_KEY"] = "community.encryption.publicKey doesn't match community.signature.publicKey. The key that runs the challenge exchange must be the key that signed the record";
5287
5289
  messages["ERR_COMMENT_SHOULD_BE_THE_LATEST_EDIT"] = "comment.content is not set to the latest comment.authorEdit.content";
5288
5290
  messages["ERR_COMMENT_UPDATE_IS_NOT_SIGNED_BY_COMMUNITY"] = "Comment update is not signed by the community";
5289
5291
  messages["ERR_AUTHOR_EDIT_IS_NOT_SIGNED_BY_AUTHOR"] = "Author edit is not signed by original author of comment";
@@ -6687,7 +6689,8 @@ const CommunitySettingsSchema = object({
6687
6689
  fetchThumbnailUrlsProxyUrl: string().optional(),
6688
6690
  challenges: CommunityChallengeSettingSchema.array().optional(),
6689
6691
  maxPendingApprovalCount: number().int().nonnegative().optional(),
6690
- purgeDisapprovedCommentsOlderThan: number().int().nonnegative().optional()
6692
+ purgeDisapprovedCommentsOlderThan: number().int().nonnegative().optional(),
6693
+ disablePubsubChallengeExchange: boolean().optional()
6691
6694
  }).strict();
6692
6695
  const CommunityRolesToEditSchema = record(AuthorAddressSchema, CommunityRoleSchema.or(_undefined()));
6693
6696
  const CommunityEditOptionsSchema = CommunityIpfsSchema.pick({
@@ -16032,7 +16035,7 @@ function extractNetworkErrorDetails(err, depth = 0) {
16032
16035
  }
16033
16036
  //#endregion
16034
16037
  //#region dist/node/generated-version.js
16035
- const version = "0.0.73";
16038
+ const version = "0.0.74";
16036
16039
  //#endregion
16037
16040
  //#region dist/node/version.js
16038
16041
  const protocolVersion = ProtocolVersionSchema.parse("1.0.0");
@@ -1,4 +1,4 @@
1
- import { _r as PKCError, et as pubsubTopicToDhtKeyCid } from "./schema-DMHTAMSM.js";
1
+ import { _r as PKCError, et as pubsubTopicToDhtKeyCid } from "./schema-B1Ot-kux.js";
2
2
  import { ipnsSelector } from "ipns/selector";
3
3
  import { equals } from "uint8arrays/equals";
4
4
  //#region dist/node/helia/util.js
@@ -1,2 +1,2 @@
1
- import { a as nativeFunctions, i as getShortCid, n as challenges, o as setNativeFunctions, r as getShortAddress, t as PKC } from "./chunks/node-Dpuw7iSW.js";
1
+ import { a as nativeFunctions, i as getShortCid, n as challenges, o as setNativeFunctions, r as getShortAddress, t as PKC } from "./chunks/node-Cn7VaPDJ.js";
2
2
  export { challenges, PKC as default, getShortAddress, getShortCid, nativeFunctions, setNativeFunctions };
@@ -1,7 +1,7 @@
1
- import { L as hideClassPrivateProps, Qn as n, _r as PKCError, er as t, st as replaceXWithY, xt as findStartedCommunity, yr as logger_default } from "../../chunks/schema-DMHTAMSM.js";
2
- import { _ as parseRpcUnsubscribeParam, c as parseRpcCancelExportParam, d as parseRpcCommunityIdentifierParam, f as parseRpcCommunityPageParam, g as parseRpcPublishChallengeAnswersParam, h as parseRpcExportCommunityParam, l as parseRpcCidParam, m as parseRpcExportCommunityModLogsParam, p as parseRpcEditCommunityParam, s as parseRpcAuthorNameParam, t as PKC, u as parseRpcCommentRepliesPageParam } from "../../chunks/node-Dpuw7iSW.js";
3
- import { En as parseVoteChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, J as buildPagesRuntimeFields, Qt as parseCommentEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, Tn as parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, Zt as parseCommentChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, an as parseCommunityEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, er as stringify, it as pLimit, mn as parseCreatePKCWsServerOptionsSchemaWithPKCErrorIfItFails, on as parseCommunityEditOptionsSchemaWithPKCErrorIfItFails, ot as require_lib, pn as parseCreateNewLocalCommunityUserOptionsSchemaWithPKCErrorIfItFails, q as buildPageRuntimeFields, qn as t$1, rt as pRetry, tn as parseCommentModerationChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, vn as parseDecryptedChallengeAnswerWithPKCErrorIfItFails } from "../../chunks/rpc-local-community-8CqOzaX3.js";
4
- import { t as LocalCommunity } from "../../chunks/local-community-DLVCXKMM.js";
1
+ import { L as hideClassPrivateProps, Qn as n, _r as PKCError, er as t, st as replaceXWithY, xt as findStartedCommunity, yr as logger_default } from "../../chunks/schema-B1Ot-kux.js";
2
+ import { _ as parseRpcUnsubscribeParam, c as parseRpcCancelExportParam, d as parseRpcCommunityIdentifierParam, f as parseRpcCommunityPageParam, g as parseRpcPublishChallengeAnswersParam, h as parseRpcExportCommunityParam, l as parseRpcCidParam, m as parseRpcExportCommunityModLogsParam, p as parseRpcEditCommunityParam, s as parseRpcAuthorNameParam, t as PKC, u as parseRpcCommentRepliesPageParam } from "../../chunks/node-Cn7VaPDJ.js";
3
+ import { En as parseVoteChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, J as buildPagesRuntimeFields, Qt as parseCommentEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, Tn as parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, Zt as parseCommentChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, an as parseCommunityEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, er as stringify, it as pLimit, mn as parseCreatePKCWsServerOptionsSchemaWithPKCErrorIfItFails, on as parseCommunityEditOptionsSchemaWithPKCErrorIfItFails, ot as require_lib, pn as parseCreateNewLocalCommunityUserOptionsSchemaWithPKCErrorIfItFails, q as buildPageRuntimeFields, qn as t$1, rt as pRetry, tn as parseCommentModerationChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, vn as parseDecryptedChallengeAnswerWithPKCErrorIfItFails } from "../../chunks/rpc-local-community-DtdeJBOq.js";
4
+ import { t as LocalCommunity } from "../../chunks/local-community-Br1ipu1Z.js";
5
5
  import { fileURLToPath } from "node:url";
6
6
  import path from "path";
7
7
  import assert from "assert";
@@ -42,6 +42,7 @@ export declare class BaseClientsManager {
42
42
  getDefaultKuboRpcClientOrHelia(): PKC["clients"]["kuboRpcClients"][string] | PKC["clients"]["libp2pJsClients"][string];
43
43
  getDefaultKuboRpcClient(): import("../types.js").KuboRpcClient;
44
44
  getDefaultKuboPubsubClient(): import("../types.js").PubsubClient;
45
+ getDefaultKuboPubsubClientIfAny(): import("../types.js").PubsubClient | undefined;
45
46
  getIpfsClientWithKuboRpcClientFunctions(): import("../helia/types.js").HeliaWithKuboRpcClientFunctions | import("kubo-rpc-client").KuboRPCClient;
46
47
  pubsubSubscribeOnProvider(pubsubTopic: string, handler: PubsubSubscriptionHandler, kuboPubsubRpcUrlOrLibp2pJsKey: string): Promise<void>;
47
48
  pubsubSubscribe(pubsubTopic: string, handler: PubsubSubscriptionHandler): Promise<void>;
@@ -80,13 +80,20 @@ export class BaseClientsManager {
80
80
  });
81
81
  }
82
82
  getDefaultKuboPubsubClient() {
83
- const defaultKuboPubsubClient = keys(this._pkc.clients.pubsubKuboRpcClients)[0];
83
+ const defaultKuboPubsubClient = this.getDefaultKuboPubsubClientIfAny();
84
84
  if (defaultKuboPubsubClient)
85
- return this._pkc.clients.pubsubKuboRpcClients[defaultKuboPubsubClient];
85
+ return defaultKuboPubsubClient;
86
86
  throw new PKCError("ERR_NO_DEFAULT_KUBO_RPC_PUBSUB_PROVIDER", {
87
87
  pubsubKuboRpcClients: this._pkc.clients.pubsubKuboRpcClients
88
88
  });
89
89
  }
90
+ // A node that only runs read-only communities (settings.disablePubsubChallengeExchange, issue #229)
91
+ // may be configured with no pubsub provider at all. Use this wherever the client is only needed to
92
+ // label a diagnostic state, so its absence is not turned into a failure.
93
+ getDefaultKuboPubsubClientIfAny() {
94
+ const defaultKuboPubsubClient = keys(this._pkc.clients.pubsubKuboRpcClients)[0];
95
+ return defaultKuboPubsubClient ? this._pkc.clients.pubsubKuboRpcClients[defaultKuboPubsubClient] : undefined;
96
+ }
90
97
  getIpfsClientWithKuboRpcClientFunctions() {
91
98
  const defaultKuboRpcClient = keys(this._pkc.clients.kuboRpcClients)[0];
92
99
  if (defaultKuboRpcClient)