@pkcprotocol/pkc-js 0.0.114 → 0.0.116

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 (149) hide show
  1. package/dist/browser/challenges.d.ts +1 -0
  2. package/dist/browser/challenges.js +1 -1
  3. package/dist/browser/challenges.js.map +1 -1
  4. package/dist/browser/clients/base-client-manager.js +25 -2
  5. package/dist/browser/clients/base-client-manager.js.map +1 -1
  6. package/dist/browser/clients/rpc-client/rpc-schema-util.d.ts +2 -2
  7. package/dist/browser/clients/rpc-client/schema.d.ts +7 -7
  8. package/dist/browser/community/schema.d.ts +72 -72
  9. package/dist/browser/constants.d.ts +2 -1
  10. package/dist/browser/constants.js +3 -0
  11. package/dist/browser/constants.js.map +1 -1
  12. package/dist/browser/errors.d.ts +1 -0
  13. package/dist/browser/errors.js +1 -0
  14. package/dist/browser/errors.js.map +1 -1
  15. package/dist/browser/generated-version.d.ts +1 -1
  16. package/dist/browser/generated-version.js +1 -1
  17. package/dist/browser/index-with-compile-cache.d.ts +4 -4
  18. package/dist/browser/index.d.ts +8 -8
  19. package/dist/browser/page-sorts.d.ts +2 -0
  20. package/dist/browser/page-sorts.js +2 -0
  21. package/dist/browser/page-sorts.js.map +1 -0
  22. package/dist/browser/pages/schema.d.ts +17 -17
  23. package/dist/browser/pkc-error.d.ts +1 -1
  24. package/dist/browser/publications/comment/schema.d.ts +18 -18
  25. package/dist/browser/publications/comment-edit/schema.d.ts +5 -5
  26. package/dist/browser/publications/comment-moderation/schema.d.ts +4 -4
  27. package/dist/browser/publications/community-edit/schema.d.ts +4 -4
  28. package/dist/browser/pubsub-messages/schema.d.ts +9 -9
  29. package/dist/browser/rpc/src/index.d.ts +2 -0
  30. package/dist/browser/rpc/src/index.js +22 -0
  31. package/dist/browser/rpc/src/index.js.map +1 -1
  32. package/dist/browser/rpc/src/lib/pkc-js/index.d.ts +4 -4
  33. package/dist/browser/rpc/src/lib/pkc-js/index.js +3 -1
  34. package/dist/browser/rpc/src/lib/pkc-js/index.js.map +1 -1
  35. package/dist/browser/rpc/src/schema.d.ts +30 -30
  36. package/dist/browser/runtime/node/community/db-handler.d.ts +6 -0
  37. package/dist/browser/runtime/node/community/db-handler.js +33 -1
  38. package/dist/browser/runtime/node/community/db-handler.js.map +1 -1
  39. package/dist/browser/runtime/node/community/local-community/challenges.js +0 -2
  40. package/dist/browser/runtime/node/community/local-community/challenges.js.map +1 -1
  41. package/dist/browser/runtime/node/community/local-community/cleanup.d.ts +4 -2
  42. package/dist/browser/runtime/node/community/local-community/cleanup.js +11 -6
  43. package/dist/browser/runtime/node/community/local-community/cleanup.js.map +1 -1
  44. package/dist/browser/runtime/node/community/local-community/editing.d.ts +2 -1
  45. package/dist/browser/runtime/node/community/local-community/editing.js +10 -7
  46. package/dist/browser/runtime/node/community/local-community/editing.js.map +1 -1
  47. package/dist/browser/runtime/node/community/local-community/ipns-publishing.js +11 -1
  48. package/dist/browser/runtime/node/community/local-community/ipns-publishing.js.map +1 -1
  49. package/dist/browser/runtime/node/community/local-community/lifecycle.js +7 -3
  50. package/dist/browser/runtime/node/community/local-community/lifecycle.js.map +1 -1
  51. package/dist/browser/runtime/node/community/local-community/publication-store.js +51 -27
  52. package/dist/browser/runtime/node/community/local-community/publication-store.js.map +1 -1
  53. package/dist/browser/runtime/node/community/local-community/registry-sync.d.ts +7 -0
  54. package/dist/browser/runtime/node/community/local-community/registry-sync.js +80 -0
  55. package/dist/browser/runtime/node/community/local-community/registry-sync.js.map +1 -0
  56. package/dist/browser/runtime/node/community/local-community.d.ts +2 -1
  57. package/dist/browser/runtime/node/community/local-community.js +3 -0
  58. package/dist/browser/runtime/node/community/local-community.js.map +1 -1
  59. package/dist/browser/runtime/node/community/page-sorts/index.d.ts +9 -0
  60. package/dist/browser/runtime/node/community/page-sorts/index.js +64 -6
  61. package/dist/browser/runtime/node/community/page-sorts/index.js.map +1 -1
  62. package/dist/browser/schema/schema-util.d.ts +12 -12
  63. package/dist/browser/schema.d.ts +32 -32
  64. package/dist/browser/test/test-util.d.ts +30 -30
  65. package/dist/browser/validate-package-factories.d.ts +7 -0
  66. package/dist/browser/validate-package-factories.js +37 -0
  67. package/dist/browser/validate-package-factories.js.map +1 -0
  68. package/dist/bundled/bundle-manifest.json +62 -27
  69. package/dist/bundled/challenges.js +2 -1
  70. package/dist/bundled/chunks/{helia-for-pkc-hSpmyI9D.js → helia-for-pkc-BvltkMx7.js} +2 -2
  71. package/dist/bundled/chunks/{local-community-Dc_fNPrx.js → local-community-Cm4X7RjW.js} +1 -1
  72. package/dist/bundled/chunks/{local-community-EeQMdfYM.js → local-community-nSmHRx5s.js} +165 -46
  73. package/dist/bundled/chunks/{node-apYZl3B3.js → node-CaeXEQ5O.js} +5 -5
  74. package/dist/bundled/chunks/page-sort-scoring-Bj73WnwW.js +112 -0
  75. package/dist/bundled/chunks/{rpc-local-community-C_0FRCqg.js → rpc-local-community-DfJ3wj-p.js} +80 -124
  76. package/dist/bundled/chunks/{util-B2SuJZg-.js → util-DkyQHyK7.js} +1 -1
  77. package/dist/bundled/chunks/{util-DFGl6QDd.js → util-vJMTa4rC.js} +2 -1
  78. package/dist/bundled/chunks/validate-package-factories-tZC8XxoO.js +41 -0
  79. package/dist/bundled/index.js +1 -1
  80. package/dist/bundled/page-sorts.js +2 -0
  81. package/dist/bundled/rpc/src/index.js +17 -4
  82. package/dist/node/challenges.d.ts +1 -0
  83. package/dist/node/challenges.js +1 -1
  84. package/dist/node/challenges.js.map +1 -1
  85. package/dist/node/clients/base-client-manager.js +25 -2
  86. package/dist/node/clients/base-client-manager.js.map +1 -1
  87. package/dist/node/clients/rpc-client/rpc-schema-util.d.ts +2 -2
  88. package/dist/node/clients/rpc-client/schema.d.ts +7 -7
  89. package/dist/node/community/schema.d.ts +72 -72
  90. package/dist/node/constants.d.ts +2 -1
  91. package/dist/node/constants.js +3 -0
  92. package/dist/node/constants.js.map +1 -1
  93. package/dist/node/errors.d.ts +1 -0
  94. package/dist/node/errors.js +1 -0
  95. package/dist/node/errors.js.map +1 -1
  96. package/dist/node/generated-version.d.ts +1 -1
  97. package/dist/node/generated-version.js +1 -1
  98. package/dist/node/index-with-compile-cache.d.ts +4 -4
  99. package/dist/node/index.d.ts +8 -8
  100. package/dist/node/page-sorts.d.ts +2 -0
  101. package/dist/node/page-sorts.js +2 -0
  102. package/dist/node/page-sorts.js.map +1 -0
  103. package/dist/node/pages/schema.d.ts +17 -17
  104. package/dist/node/pkc-error.d.ts +1 -1
  105. package/dist/node/publications/comment/schema.d.ts +18 -18
  106. package/dist/node/publications/comment-edit/schema.d.ts +5 -5
  107. package/dist/node/publications/comment-moderation/schema.d.ts +4 -4
  108. package/dist/node/publications/community-edit/schema.d.ts +4 -4
  109. package/dist/node/pubsub-messages/schema.d.ts +9 -9
  110. package/dist/node/rpc/src/index.d.ts +2 -0
  111. package/dist/node/rpc/src/index.js +22 -0
  112. package/dist/node/rpc/src/index.js.map +1 -1
  113. package/dist/node/rpc/src/lib/pkc-js/index.d.ts +4 -4
  114. package/dist/node/rpc/src/lib/pkc-js/index.js +3 -1
  115. package/dist/node/rpc/src/lib/pkc-js/index.js.map +1 -1
  116. package/dist/node/rpc/src/schema.d.ts +30 -30
  117. package/dist/node/runtime/node/community/db-handler.d.ts +6 -0
  118. package/dist/node/runtime/node/community/db-handler.js +33 -1
  119. package/dist/node/runtime/node/community/db-handler.js.map +1 -1
  120. package/dist/node/runtime/node/community/local-community/challenges.js +0 -2
  121. package/dist/node/runtime/node/community/local-community/challenges.js.map +1 -1
  122. package/dist/node/runtime/node/community/local-community/cleanup.d.ts +4 -2
  123. package/dist/node/runtime/node/community/local-community/cleanup.js +11 -6
  124. package/dist/node/runtime/node/community/local-community/cleanup.js.map +1 -1
  125. package/dist/node/runtime/node/community/local-community/editing.d.ts +2 -1
  126. package/dist/node/runtime/node/community/local-community/editing.js +10 -7
  127. package/dist/node/runtime/node/community/local-community/editing.js.map +1 -1
  128. package/dist/node/runtime/node/community/local-community/ipns-publishing.js +11 -1
  129. package/dist/node/runtime/node/community/local-community/ipns-publishing.js.map +1 -1
  130. package/dist/node/runtime/node/community/local-community/lifecycle.js +7 -3
  131. package/dist/node/runtime/node/community/local-community/lifecycle.js.map +1 -1
  132. package/dist/node/runtime/node/community/local-community/publication-store.js +51 -27
  133. package/dist/node/runtime/node/community/local-community/publication-store.js.map +1 -1
  134. package/dist/node/runtime/node/community/local-community/registry-sync.d.ts +7 -0
  135. package/dist/node/runtime/node/community/local-community/registry-sync.js +80 -0
  136. package/dist/node/runtime/node/community/local-community/registry-sync.js.map +1 -0
  137. package/dist/node/runtime/node/community/local-community.d.ts +2 -1
  138. package/dist/node/runtime/node/community/local-community.js +3 -0
  139. package/dist/node/runtime/node/community/local-community.js.map +1 -1
  140. package/dist/node/runtime/node/community/page-sorts/index.d.ts +9 -0
  141. package/dist/node/runtime/node/community/page-sorts/index.js +64 -6
  142. package/dist/node/runtime/node/community/page-sorts/index.js.map +1 -1
  143. package/dist/node/schema/schema-util.d.ts +12 -12
  144. package/dist/node/schema.d.ts +32 -32
  145. package/dist/node/test/test-util.d.ts +30 -30
  146. package/dist/node/validate-package-factories.d.ts +7 -0
  147. package/dist/node/validate-package-factories.js +37 -0
  148. package/dist/node/validate-package-factories.js.map +1 -0
  149. package/package.json +6 -1
@@ -1,6 +1,7 @@
1
1
  import { i as __toESM, n as __exportAll, r as __require, t as __commonJSMin } from "./chunk-2rV9d50f.js";
2
- import { $ as shortifyAddress, $n as CreateCommentEditOptionsWithRefinementSchema, $t as CommentModerationPubsubMessagePublicationSchema, An as CommentIpfsSchema, Ar as PKCError, B as raceAgainstAbort, Br as literal, Bt as DecryptedChallengeVerificationSchema, C as interruptibleSleep, Cn as VoteChallengeRequestToEncryptSchema, Cr as e$4, D as isIpfsPath, Dr as FailedToFetchCommunityFromGatewaysError, Dt as pTimeout, E as isIpfsCid, En as VoteSignedPropertyNames, Er as FailedToFetchCommentUpdateFromGatewaysError, Ft as ChallengeVerificationMessageSignedPropertyNames, G as removeNullUndefinedEmptyObjectsValuesRecursively, Gn as PageIpfsSchema, Gt as PKCUserOptionsSchema, Hn as CreateCommentOptionsWithRefinementSchema, Hr as object, Ht as NameResolverSerializedSchema, I as isRequestPubsubPublicationOfPost, In as CommentUpdateForChallengeVerificationSignedPropertyNames, Ir as _enum, It as DecryptedChallengeAnswerSchema, Kn as isReservedObjectKey, L as isRequestPubsubPublicationOfReply, Ln as CommentUpdateReservedFields, Lr as array, Mn as CommentPubsubMessageWithFlexibleAuthorRefinementSchema, Mr as logger_default, Nn as CommentSignedPropertyNames, Nr as require_supports_color, Nt as ChallengeRequestMessageSignedPropertyNames, O as isIpns, On as CommentChallengeRequestToEncryptSchema, Or as FailedToFetchGenericIpfsFromGatewaysError, Pn as CommentUpdateChallengeReservedFieldNames, Pr as require_ms$1, Qt as CommentModerationChallengeRequestToEncryptSchema, R as pubsubTopicToDhtKey, Rn as CommentUpdateSchema, Rr as boolean, S as hideClassPrivateProps, Sn as CreateVoteUserOptionsWithRefinementSchema, Sr as t$9, St as untrackStartedCommunity, T as isAbortError, Tr as FailedToFetchCommentIpfsFromGatewaysError, Tt as require_sha256$1, Un as GetPageParamSchema, Ur as record, Ut as PKCParsedOptionsSchema, Vr as number, Vt as NameResolveCacheOptionsSchema, Wn as ModQueuePageIpfsSchema, Wr as string, Wt as PKCUserOptionBaseSchema, Xt as CommunityEditPubsubMessagePublicationSchema, Yn as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema, Yt as CommunityEditPublicationSignedPropertyNames, Zn as CommentEditSignedPropertyNames, Zt as CreateCommunityEditPublicationOptionsWithRefinementSchema, _ as getEquivalentCommunityAddresses, _n as PageSortFileFactorySchema, _r as r$8, _t as refreshTrackedCommunityAliases, an as ChallengeFileSchema, ar as CidStringSchema, bn as RpcRemoteCommunityUpdateEventResultSchema, br as r$7, cn as CommunityEditOptionsSchema, cr as CreateSignerSchema, d as derivePublicationFromChallengeRequest, dn as CommunityIpfsSchema, dr as n$10, er as AuthorAddressSchema, et as shortifyCid, f as doesDomainAddressHaveCapitalLetter, fn as CommunitySignedPropertyNames, ft as findUpdatingCommunity, gn as ExportCommunityModLogsOptionsSchema, gr as t$11, hn as CreateRpcCommunityFunctionArgumentSchema, hr as e$5, in as ChallengeFileFactorySchema, ir as CidPathSchema, it as timestamp, jr as messages, jt as ChallengeMessageSignedPropertyNames, k as isIpnsPath, kn as CommentIpfsReservedFields, kr as FailedToFetchPageIpfsFromGatewaysError, kt as ChallengeAnswerMessageSignedPropertyNames, l as createAbortError, ln as CommunityExportRecordsSchema, lr as n$9, m as fetchAndValidateIpnsRecordFromGateway, mn as CreateRemoteCommunityFunctionArgumentSchema, mr as e$6, nn as CommentModerationsTableRowSchema, or as CommunityAddressSchema, p as extractNetworkErrorDetails, pn as CreateNewLocalCommunityUserOptionsSchema, pr as t$13, qn as CommentEditChallengeRequestToEncryptSchema, qt as CommunityEditPublicationChallengeRequestToEncryptSchema, r as calculateIpfsCidV0, rn as CreateCommentModerationOptionsWithRefinementSchema, rr as ChallengeAnswersSchema, rt as throwIfAbortSignalAborted, sn as CommunityChallengeSettingSchema, sr as CommunityAuthorChallengeReservedFieldNames, t as areEquivalentCommunityAddresses, tn as CommentModerationSignedPropertyNames, tr as AuthorCommentIpfsReservedFields, tt as sleepUntilTimeoutOrAbort, u as deepMergeRuntimeFields, un as CommunityIpfsReservedFields, ut as findStartedCommunity, vn as PageSortFileSchema, vr as t$12, w as ipnsNameToIpnsOverPubsubTopic, wn as VotePubsubMessagePublicationSchema, wr as require_retry$1, wt as untrackUpdatingCommunity, x as hasTransientNetworkErrorCode, xn as isStringDomain, xr as t$10, xt as trackUpdatingCommunity, yr as n$8, yt as trackStartedCommunity, zn as CommentUpdateSignedPropertyNames, zr as custom, zt as DecryptedChallengeSchema } from "./util-DFGl6QDd.js";
2
+ import { $ as shortifyAddress, $n as CreateCommentEditOptionsWithRefinementSchema, $t as CommentModerationPubsubMessagePublicationSchema, An as CommentIpfsSchema, Ar as PKCError, B as raceAgainstAbort, Br as literal, Bt as DecryptedChallengeVerificationSchema, C as interruptibleSleep, Cn as VoteChallengeRequestToEncryptSchema, Cr as e$4, D as isIpfsPath, Dr as FailedToFetchCommunityFromGatewaysError, Dt as pTimeout, E as isIpfsCid, En as VoteSignedPropertyNames, Er as FailedToFetchCommentUpdateFromGatewaysError, Ft as ChallengeVerificationMessageSignedPropertyNames, G as removeNullUndefinedEmptyObjectsValuesRecursively, Gn as PageIpfsSchema, Gt as PKCUserOptionsSchema, Hn as CreateCommentOptionsWithRefinementSchema, Hr as object, Ht as NameResolverSerializedSchema, I as isRequestPubsubPublicationOfPost, In as CommentUpdateForChallengeVerificationSignedPropertyNames, Ir as _enum, It as DecryptedChallengeAnswerSchema, Kn as isReservedObjectKey, L as isRequestPubsubPublicationOfReply, Ln as CommentUpdateReservedFields, Lr as array, Mn as CommentPubsubMessageWithFlexibleAuthorRefinementSchema, Mr as logger_default, Nn as CommentSignedPropertyNames, Nr as require_supports_color, Nt as ChallengeRequestMessageSignedPropertyNames, O as isIpns, On as CommentChallengeRequestToEncryptSchema, Or as FailedToFetchGenericIpfsFromGatewaysError, Pn as CommentUpdateChallengeReservedFieldNames, Pr as require_ms$1, Qt as CommentModerationChallengeRequestToEncryptSchema, R as pubsubTopicToDhtKey, Rn as CommentUpdateSchema, Rr as boolean, S as hideClassPrivateProps, Sn as CreateVoteUserOptionsWithRefinementSchema, Sr as t$9, St as untrackStartedCommunity, T as isAbortError, Tr as FailedToFetchCommentIpfsFromGatewaysError, Tt as require_sha256$1, Un as GetPageParamSchema, Ur as record, Ut as PKCParsedOptionsSchema, Vr as number, Vt as NameResolveCacheOptionsSchema, Wn as ModQueuePageIpfsSchema, Wr as string, Wt as PKCUserOptionBaseSchema, Xt as CommunityEditPubsubMessagePublicationSchema, Yn as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema, Yt as CommunityEditPublicationSignedPropertyNames, Zn as CommentEditSignedPropertyNames, Zt as CreateCommunityEditPublicationOptionsWithRefinementSchema, _n as PageSortFileFactorySchema, _r as r$8, _t as refreshTrackedCommunityAliases, an as ChallengeFileSchema, ar as CidStringSchema, bn as RpcRemoteCommunityUpdateEventResultSchema, br as r$7, cn as CommunityEditOptionsSchema, cr as CreateSignerSchema, d as derivePublicationFromChallengeRequest, dn as CommunityIpfsSchema, dr as n$10, er as AuthorAddressSchema, et as shortifyCid, f as doesDomainAddressHaveCapitalLetter, fn as CommunitySignedPropertyNames, ft as findUpdatingCommunity, gn as ExportCommunityModLogsOptionsSchema, gr as t$11, hn as CreateRpcCommunityFunctionArgumentSchema, hr as e$5, in as ChallengeFileFactorySchema, ir as CidPathSchema, it as timestamp, jr as messages, jt as ChallengeMessageSignedPropertyNames, k as isIpnsPath, kn as CommentIpfsReservedFields, kr as FailedToFetchPageIpfsFromGatewaysError, kt as ChallengeAnswerMessageSignedPropertyNames, l as createAbortError, ln as CommunityExportRecordsSchema, lr as n$9, m as fetchAndValidateIpnsRecordFromGateway, mn as CreateRemoteCommunityFunctionArgumentSchema, mr as e$6, nn as CommentModerationsTableRowSchema, or as CommunityAddressSchema, p as extractNetworkErrorDetails, pn as CreateNewLocalCommunityUserOptionsSchema, pr as t$13, qn as CommentEditChallengeRequestToEncryptSchema, qt as CommunityEditPublicationChallengeRequestToEncryptSchema, r as calculateIpfsCidV0, rn as CreateCommentModerationOptionsWithRefinementSchema, rr as ChallengeAnswersSchema, rt as throwIfAbortSignalAborted, sn as CommunityChallengeSettingSchema, sr as CommunityAuthorChallengeReservedFieldNames, t as areEquivalentCommunityAddresses, tn as CommentModerationSignedPropertyNames, tr as AuthorCommentIpfsReservedFields, tt as sleepUntilTimeoutOrAbort, u as deepMergeRuntimeFields, un as CommunityIpfsReservedFields, ut as findStartedCommunity, vn as PageSortFileSchema, vr as t$12, w as ipnsNameToIpnsOverPubsubTopic, wn as VotePubsubMessagePublicationSchema, wr as require_retry$1, wt as untrackUpdatingCommunity, x as hasTransientNetworkErrorCode, xn as isStringDomain, xr as t$10, xt as trackUpdatingCommunity, yr as n$8, yt as trackStartedCommunity, zn as CommentUpdateSignedPropertyNames, zr as custom, zt as DecryptedChallengeSchema } from "./util-vJMTa4rC.js";
3
3
  import { t as all } from "./src-CYIMjhjK.js";
4
+ import { s as validatePageSortFile } from "./page-sort-scoring-Bj73WnwW.js";
4
5
  import { createHash } from "node:crypto";
5
6
  import { pathToFileURL } from "node:url";
6
7
  import dns from "node:dns";
@@ -91427,6 +91428,7 @@ var STORAGE_KEYS;
91427
91428
  STORAGE_KEYS[STORAGE_KEYS["EXPORTS"] = 4] = "EXPORTS";
91428
91429
  STORAGE_KEYS[STORAGE_KEYS["ANCHOR_IPNS_RECORD"] = 5] = "ANCHOR_IPNS_RECORD";
91429
91430
  STORAGE_KEYS[STORAGE_KEYS["HIGHEST_ACCEPTED_ANCHOR_SEQUENCE"] = 6] = "HIGHEST_ACCEPTED_ANCHOR_SEQUENCE";
91431
+ STORAGE_KEYS[STORAGE_KEYS["PAGE_SORTS_FINGERPRINT"] = 7] = "PAGE_SORTS_FINGERPRINT";
91430
91432
  })(STORAGE_KEYS || (STORAGE_KEYS = {}));
91431
91433
  const MAX_FILE_SIZE_BYTES_FOR_COMMENT_UPDATE = 1024 * 1024;
91432
91434
  const NAME_RESOLVED_FALSE_TTL_MS = 6e4;
@@ -95726,6 +95728,7 @@ const getPKCAddressFromPublicKeySync = (publicKeyBase64) => {
95726
95728
  };
95727
95729
  //#endregion
95728
95730
  //#region node_modules/cborg/lib/is.js
95731
+ var import_sha256 = require_sha256$1();
95729
95732
  const objectTypeNames = [
95730
95733
  "Object",
95731
95734
  "RegExp",
@@ -97875,7 +97878,6 @@ function normalizeCommunityInputFromCommunity({ communityInstance }) {
97875
97878
  }
97876
97879
  //#endregion
97877
97880
  //#region dist/node/publications/comment/crosspost-depth.js
97878
- var import_sha256 = require_sha256$1();
97879
97881
  const MAX_CROSSPOST_DEPTH = 10;
97880
97882
  function crosspostChainDepthUpTo(record, stopAt = 11) {
97881
97883
  let depth = 0;
@@ -122111,7 +122113,23 @@ var BaseClientsManager = class BaseClientsManager {
122111
122113
  };
122112
122114
  let error;
122113
122115
  try {
122114
- await pubsubClient.pubsub.subscribe(pubsubTopic, handler, { onError: handlePubsubError });
122116
+ await pRetry(async () => {
122117
+ try {
122118
+ await pubsubClient.pubsub.subscribe(pubsubTopic, handler, { onError: handlePubsubError });
122119
+ } catch (e) {
122120
+ const networkErrorDetails = extractNetworkErrorDetails(e);
122121
+ if (!(networkErrorDetails !== void 0 && hasTransientNetworkErrorCode(networkErrorDetails))) throw e instanceof Error ? new AbortError(e) : e;
122122
+ throw e;
122123
+ }
122124
+ }, {
122125
+ retries: 2,
122126
+ factor: 2,
122127
+ minTimeout: 250,
122128
+ maxTimeout: 1e3,
122129
+ onFailedAttempt: ({ error: attemptError, attemptNumber, retriesLeft }) => {
122130
+ if (retriesLeft > 0) log.trace(`Transient failure subscribing to pubsub topic (${pubsubTopic}) on (${kuboPubsubRpcUrlOrLibp2pJsKey}), attempt ${attemptNumber}/${attemptNumber + retriesLeft}`, attemptError?.message);
122131
+ }
122132
+ });
122115
122133
  if (error) throw error;
122116
122134
  await this._pkc._stats.recordGatewaySuccess(kuboPubsubRpcUrlOrLibp2pJsKey, "pubsub-subscribe", Date.now() - timeBefore);
122117
122135
  this.pubsubProviderSubscriptions[kuboPubsubRpcUrlOrLibp2pJsKey].push(pubsubTopic);
@@ -122136,7 +122154,7 @@ var BaseClientsManager = class BaseClientsManager {
122136
122154
  for (let i = 0; i < providersSorted.length; i++) {
122137
122155
  const pubsubProviderUrl = providersSorted[i];
122138
122156
  try {
122139
- return this.pubsubSubscribeOnProvider(pubsubTopic, handler, pubsubProviderUrl);
122157
+ return await this.pubsubSubscribeOnProvider(pubsubTopic, handler, pubsubProviderUrl);
122140
122158
  } catch (e) {
122141
122159
  providerToError[pubsubProviderUrl] = e;
122142
122160
  }
@@ -128840,116 +128858,6 @@ const getCommunityChallengeFromCommunityChallengeSettings = async ({ communityCh
128840
128858
  } };
128841
128859
  };
128842
128860
  //#endregion
128843
- //#region dist/node/pages/page-sort-scoring.js
128844
- function validatePageSortFile(rawFile) {
128845
- const validated = PageSortFileSchema.parse(rawFile);
128846
- const raw = rawFile;
128847
- return {
128848
- ...validated,
128849
- score: raw.score,
128850
- ...raw.validatePageSortSettings ? { validatePageSortSettings: raw.validatePageSortSettings } : {}
128851
- };
128852
- }
128853
- function applyPageSortExclusions({ comments, exclusions, communityAddress }) {
128854
- const equivalentAddresses = communityAddress ? new Set(getEquivalentCommunityAddresses(communityAddress)) : void 0;
128855
- return comments.filter(({ comment, commentUpdate }) => {
128856
- if (exclusions.excludeRemovedComments && commentUpdate.removed === true) return false;
128857
- if (exclusions.excludeDeletedComments && commentUpdate.edit?.deleted === true) return false;
128858
- if (exclusions.excludeCommentWithApprovedFalse && commentUpdate.approved === false) return false;
128859
- if (exclusions.excludeCommentPendingApproval && commentUpdate.pendingApproval === true) return false;
128860
- if (exclusions.excludeCommentsWithDifferentCommunityAddress && equivalentAddresses) {
128861
- if (!((comment.communityPublicKey ? equivalentAddresses.has(comment.communityPublicKey) : false) || (comment.communityName ? equivalentAddresses.has(comment.communityName) : false))) return false;
128862
- }
128863
- return true;
128864
- });
128865
- }
128866
- function filterRepliesForPageSort({ replies, communityAddress }) {
128867
- return applyPageSortExclusions({
128868
- comments: replies,
128869
- exclusions: {
128870
- excludeRemovedComments: false,
128871
- excludeDeletedComments: false,
128872
- excludeCommentWithApprovedFalse: false,
128873
- excludeCommentPendingApproval: false,
128874
- excludeCommentsWithDifferentCommunityAddress: true
128875
- },
128876
- communityAddress
128877
- });
128878
- }
128879
- function partitionPageCommentsForSort({ comments, reserved, baseTimestamp }) {
128880
- const pinned = reserved.pinnedFirst ? comments.filter((entry) => entry.commentUpdate.pinned === true) : [];
128881
- let unpinned = reserved.pinnedFirst ? comments.filter((entry) => entry.commentUpdate.pinned !== true) : comments;
128882
- if (typeof reserved.maxAgeSeconds === "number") {
128883
- const timestampLower = baseTimestamp - reserved.maxAgeSeconds;
128884
- unpinned = unpinned.filter((entry) => entry.comment.timestamp >= timestampLower);
128885
- }
128886
- return {
128887
- pinned,
128888
- unpinned
128889
- };
128890
- }
128891
- function orderPageCommentsByScore({ pinned, unpinned, scoreOf, sortName }) {
128892
- const kept = (entries) => {
128893
- const scored = [];
128894
- for (const entry of entries) {
128895
- const score = scoreOf(entry);
128896
- if (score === null) continue;
128897
- if (typeof score !== "number" || Number.isNaN(score)) throw Error(`Page sort ${sortName} returned no numeric score for comment ${entry.commentUpdate.cid}`);
128898
- scored.push({
128899
- entry,
128900
- score
128901
- });
128902
- }
128903
- return scored.sort((a, b) => b.score - a.score).map(({ entry }) => entry);
128904
- };
128905
- return kept(pinned).concat(kept(unpinned));
128906
- }
128907
- function stripRepliesFromPageComment(entry) {
128908
- if (!("replies" in entry.commentUpdate)) return entry;
128909
- const { replies: _replies, ...commentUpdate } = entry.commentUpdate;
128910
- return {
128911
- comment: entry.comment,
128912
- commentUpdate
128913
- };
128914
- }
128915
- function createDescendantsLookup(replies) {
128916
- const childrenByParent = /* @__PURE__ */ new Map();
128917
- for (const entry of replies) {
128918
- const stripped = stripRepliesFromPageComment(entry);
128919
- const parentCid = stripped.comment.parentCid;
128920
- if (!parentCid) continue;
128921
- const siblings = childrenByParent.get(parentCid);
128922
- if (siblings) siblings.push(stripped);
128923
- else childrenByParent.set(parentCid, [stripped]);
128924
- }
128925
- return (cid) => {
128926
- const collected = [];
128927
- const stack = [cid];
128928
- while (stack.length) {
128929
- const children = childrenByParent.get(stack.pop());
128930
- if (!children) continue;
128931
- for (const child of children) {
128932
- collected.push(child);
128933
- stack.push(child.commentUpdate.cid);
128934
- }
128935
- }
128936
- return collected;
128937
- };
128938
- }
128939
- function scorePageCommentsWithFile({ file, options, baseTimestamp, replies, stripEntry = stripRepliesFromPageComment, descendantsOf: descendantsOfOverride }) {
128940
- const descendantsOf = file.requireReplies ? descendantsOfOverride ?? createDescendantsLookup(replies ?? []) : void 0;
128941
- return (entry) => {
128942
- const { comment, commentUpdate } = stripEntry(entry);
128943
- return file.score({
128944
- comment,
128945
- commentUpdate,
128946
- options,
128947
- baseTimestamp,
128948
- ...descendantsOf ? { replies: descendantsOf(commentUpdate.cid) } : {}
128949
- });
128950
- };
128951
- }
128952
- //#endregion
128953
128861
  //#region dist/node/pages/page-sort-options.js
128954
128862
  const MAX_AGE_UNIT_SECONDS = Object.freeze({
128955
128863
  s: 1,
@@ -129211,6 +129119,56 @@ const DEFAULT_REPLY_SORT_SETTINGS = Object.freeze([
129211
129119
  { name: "oldFlat" }
129212
129120
  ]);
129213
129121
  const resolvePageSortFactoryByName = ({ name, pkc }) => pkc?.settings?.pageSorts?.[name] ?? pkcJsPageSorts[name];
129122
+ const shippedBuiltInPageSorts = Object.freeze({ ...pkcJsPageSorts });
129123
+ const entriesOfEveryScope = (pagesSettings) => [{
129124
+ scope: "posts",
129125
+ entries: pagesSettings?.posts ?? DEFAULT_POST_SORT_SETTINGS
129126
+ }, {
129127
+ scope: "replies",
129128
+ entries: pagesSettings?.replies ?? DEFAULT_REPLY_SORT_SETTINGS
129129
+ }];
129130
+ function lookupPageSortFactories({ pagesSettings, pkc }) {
129131
+ return entriesOfEveryScope(pagesSettings).flatMap(({ entries }) => entries.map((entry) => entry.name ? resolvePageSortFactoryByName({
129132
+ name: entry.name,
129133
+ pkc
129134
+ }) : void 0));
129135
+ }
129136
+ function computePageSortsFingerprint({ pagesSettings, resolved, factories }) {
129137
+ const entries = entriesOfEveryScope(pagesSettings).flatMap(({ entries }) => entries);
129138
+ const factoryOfEntry = new Map(entries.map((entry, i) => [entry, factories[i]]));
129139
+ const isShippedBuiltIn = (entry) => {
129140
+ const factory = factoryOfEntry.get(entry);
129141
+ return factory !== void 0 && typeof entry.name === "string" && shippedBuiltInPageSorts[entry.name] === factory;
129142
+ };
129143
+ const describeFactory = (entry) => {
129144
+ const factory = factoryOfEntry.get(entry);
129145
+ if (factory === void 0) return null;
129146
+ return isShippedBuiltIn(entry) ? "built-in" : factory.toString();
129147
+ };
129148
+ const describeResolved = (sort) => ({
129149
+ settings: sort.settings,
129150
+ sortName: sort.sortName,
129151
+ options: sort.options,
129152
+ file: {
129153
+ description: sort.file.description,
129154
+ optionInputs: sort.file.optionInputs,
129155
+ defaultOptions: sort.file.defaultOptions,
129156
+ scope: sort.file.scope,
129157
+ flat: sort.file.flat,
129158
+ requireReplies: sort.file.requireReplies,
129159
+ ...isShippedBuiltIn(sort.settings) ? {} : {
129160
+ score: sort.file.score.toString(),
129161
+ validatePageSortSettings: sort.file.validatePageSortSettings?.toString()
129162
+ }
129163
+ }
129164
+ });
129165
+ return (0, import_sha256.sha256)(stringify({
129166
+ pages: pagesSettings ?? null,
129167
+ factories: entries.map(describeFactory),
129168
+ posts: resolved.posts.map(describeResolved),
129169
+ replies: resolved.replies.map(describeResolved)
129170
+ }) ?? "");
129171
+ }
129214
129172
  const describePageSort = (pageSortSettings) => pageSortSettings.name || pageSortSettings.path || "unknown page sort";
129215
129173
  async function loadPageSortFile({ pageSortSettings, pkc }) {
129216
129174
  let factory;
@@ -129318,14 +129276,7 @@ async function resolvePageSortsAndCollectFailures({ pagesSettings, pkc, tolerate
129318
129276
  posts: [],
129319
129277
  replies: []
129320
129278
  };
129321
- const scopes = [{
129322
- scope: "posts",
129323
- entries: pagesSettings?.posts ?? DEFAULT_POST_SORT_SETTINGS
129324
- }, {
129325
- scope: "replies",
129326
- entries: pagesSettings?.replies ?? DEFAULT_REPLY_SORT_SETTINGS
129327
- }];
129328
- for (const { scope, entries } of scopes) {
129279
+ for (const { scope, entries } of entriesOfEveryScope(pagesSettings)) {
129329
129280
  const seenSortNames = /* @__PURE__ */ new Set();
129330
129281
  for (const [pageSortIndex, pageSortSettings] of entries.entries()) {
129331
129282
  const pageSortName = describePageSort(pageSortSettings);
@@ -129420,6 +129371,10 @@ function derivePublicPageSorts({ pagesSettings, resolved }) {
129420
129371
  async function loadPageSortsForStartedCommunity(community) {
129421
129372
  const log = logger_default("pkc-js:local-community:page-sorts:load");
129422
129373
  await community._dbHandler.initDbIfNeeded();
129374
+ const factories = lookupPageSortFactories({
129375
+ pagesSettings: community.settings?.pages,
129376
+ pkc: community._pkc
129377
+ });
129423
129378
  const { resolved, failures } = await resolvePageSortsAndCollectFailures({
129424
129379
  pagesSettings: community.settings?.pages,
129425
129380
  pkc: community._pkc,
@@ -129433,10 +129388,11 @@ async function loadPageSortsForStartedCommunity(community) {
129433
129388
  pageSortName,
129434
129389
  communityAddress: community.address
129435
129390
  };
129436
- log.error("Invalid settings.pages entry on start, skipping it", community.address, error);
129391
+ log.error("Invalid settings.pages entry, skipping it", community.address, error);
129437
129392
  community.emit("error", error);
129438
129393
  }
129439
129394
  community._pageSorts = resolved;
129395
+ community._pageSortFactories = factories;
129440
129396
  return resolved;
129441
129397
  }
129442
129398
  function reportFailedPageSorts(community, failedSorts, log) {
@@ -130092,4 +130048,4 @@ var RpcLocalCommunity = class extends RpcRemoteCommunity {
130092
130048
  }
130093
130049
  };
130094
130050
  //#endregion
130095
- export { coerceSchemaRowJson as $, getPKCAddressFromPublicKeySync as $n, RpcSubscriptionIdResultSchema as $t, extractCommunityRuntimeFieldsFromParsedPages as A, verifyCommentModeration as An, NAME_RESOLVED_FALSE_TTL_MS as Ar, parseRpcCommentEventWithPKCErrorIfItFails as At, stripNameResolvedFromCrosspost as B, normalizeCreatePublicationAuthor as Bn, RpcCommunityIdentifierParamSchema as Bt, RemoteCommunity as C, signVote as Cn, t$5 as Cr, parseCreateRpcCommunityFunctionArgumentSchemaWithPKCErrorIfItFails as Ct, TIMEFRAMES_TO_SECONDS as D, verifyChallengeVerification as Dn, t$8 as Dr, parseDecryptedChallengeWithPKCErrorIfItFails as Dt, RepliesPages as E, verifyChallengeRequest as En, t$7 as Er, parseDecryptedChallengeVerification as Et, parseRawPages as F, verifyVote as Fn, nativeFunctions$1 as Fr, RpcAnchorPublishPreparationResultSchema as Ft, pRetry as G, getCommunityNameFromWire$1 as Gn, RpcExportCommunityParamSchema as Gt, GenericStateClient as H, effectiveMaxCrosspostDepth as Hn, RpcEditCommunityParamSchema as Ht, applyNameResolvedCacheToCrosspost as I, buildRuntimeAuthor as In, require_undici as Ir, RpcAuthorNameParamSchema as It, decodeRpcChallengeAnswerPubsubMsg as J, decode as Jn, RpcFetchCidResultSchema as Jt, pLimit as K, getCommunityPublicKeyFromWire as Kn, RpcExportCommunityResultSchema as Kt, cloneCrosspostForRuntime as L, cleanWireAuthor as Ln, RpcCancelExportParamSchema as Lt, findCommentInPageInstanceRecursively as M, verifyCommentUpdate as Mn, NAME_RESOLVE_FAILED_RETRY_FLOOR_MS as Mr, parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails as Mt, findCommentInParsedPages as N, verifyCommunity as Nn, STORAGE_KEYS as Nr, parseVoteChallengeRequestToEncryptSchemaWithPKCErrorIfItFails as Nt, buildPageRuntimeFields as O, verifyCommentEdit as On, stringify as Or, parseJsonWithPKCErrorIfFails as Ot, iterateOverPageCidsToFindAllCids as P, verifyCommunityEdit as Pn, require_lodash_merge as Pr, parseVotePubsubMessagePublicationSchemaWithPKCErrorIfItFails as Pt, coerceSchemaRowBoolean as Q, getPKCAddressFromPublicKey as Qn, RpcResolveAuthorNameResultSchema as Qt, collectCrosspostAuthorsToResolve as R, getAuthorNameFromRuntime as Rn, RpcCidParamSchema as Rt, LRUCache as S, signCommunityEdit as Sn, r as Sr, parseCreateRemoteCommunityFunctionArgumentSchemaWithPKCErrorIfItFails as St, KeyvBetterSqlite3 as T, verifyChallengeMessage as Tn, n$6 as Tr, parseDecryptedChallengeAnswerWithPKCErrorIfItFails as Tt, InflightFetchManager as U, buildRuntimeCommunityFields as Un, RpcExportCommunityModLogsParamSchema as Ut, PKCClientsManager as V, crosspostChainDepthUpTo as Vn, RpcCommunityPageParamSchema as Vt, InflightResourceTypes as W, getCommunityAddressFromRecord as Wn, RpcExportCommunityModLogsResultSchema as Wt, decodeRpcChallengeRequestPubsubMsg as X, getBufferedPKCAddressFromPublicKey as Xn, RpcPublishChallengeAnswersParamSchema as Xt, decodeRpcChallengePubsubMsg as Y, encode as Yn, RpcPublishAnchorRecordParamSchema as Yt, decodeRpcChallengeVerificationPubsubMsg as Z, getIpfsKeyFromPrivateKey as Zn, RpcPublishedAnchorRecordResultSchema as Zt, pkcJsChallenges as _, signCommentEdit as _n, resolveDbPostsCidRefs as _r, parseCreateCommentModerationOptionsSchemaWithPKCErrorIfItFails as _t, loadPageSortsForStartedCommunity as a, createAnchorIpnsRecord as an, createKuboRpcClient as ar, parseCommentEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails as at, createAuthorIdentityMatcher as b, signCommentUpdateForChallengeVerification as bn, t$2 as br, parseCreateNewLocalCommunityUserOptionsSchemaWithPKCErrorIfItFails as bt, createDescendantsLookup as c, encryptEd25519AesGcm as cn, deriveDbPosts as cr, parseCommentModerationPubsubMessagePublicationSchemaWithPKCErrorIfItFails as ct, partitionPageCommentsForSort as d, cleanUpBeforePublishing as dn, getDefaultDataPath as dr, parseCommunityAddressWithPKCErrorIfItFails as dt, RpcSuccessResultSchema as en, getPublicKeyFromPrivateKey as er, collectSchemaRowCoercions as et, scorePageCommentsWithFile as f, signChallengeAnswer as fn, getThumbnailPropsOfLink as fr, parseCommunityEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails as ft, loadChallengeFileFromCommunityChallengeSettings as g, signComment as gn, moveCommunityDbToDeletedDirectory as gr, parseCreateCommentEditOptionsSchemaWithPKCErrorIfItFails as gt, getCommunityChallengeFromCommunityChallengeSettings as h, signChallengeVerification as hn, monitorCommunitiesDirectory as hr, parseCommunityIpfsSchemaPassthroughWithPKCErrorIfItFails as ht, generatePagesReportingFailedSorts as i, createSigner as in, calculateInlineRepliesBudget as ir, parseCommentEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails as it, findCommentInPageInstance as j, verifyCommentPubsubMessage as jn, NAME_RESOLVED_TRUE_TTL_MS as jr, parseRpcCommentUpdateEventWithPKCErrorIfItFails as jt, buildPagesRuntimeFields as k, verifyCommentIpfs as kn, MAX_FILE_SIZE_BYTES_FOR_COMMENT_UPDATE as kr, parsePKCUserOptionsSchemaWithPKCErrorIfItFails as kt, filterRepliesForPageSort as l, encryptEd25519AesGcmPublicKeyBuffer as ln, deriveDbReplies as lr, parseCommentPubsubMessagePublicationWithPKCErrorIfItFails as lt, getChallengeVerification as m, signChallengeRequest as mn, listCommunitiesSync as mr, parseCommunityEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails as mt, RpcRemoteCommunity as n, require_lib as nn, backupCommunityDb as nr, parseCidStringSchemaWithPKCErrorIfItFails as nt, resolvePageSortsOrThrow as o, decryptEd25519AesGcm as on, deleteOldCommunityInWindows as or, parseCommentIpfsSchemaWithPKCErrorIfItFails as ot, stripRepliesFromPageComment as p, signChallengeMessage as pn, importSignerIntoKuboNode as pr, parseCommunityEditOptionsSchemaWithPKCErrorIfItFails as pt, PKCTypedEmitter as q, normalizeCommunityInputFromCommunity as qn, RpcFetchCidParamSchema as qt, derivePublicPageSorts as r, SignerWithPublicKeyAddress as rn, calculateExpectedSignatureSize as rr, parseCommentChallengeRequestToEncryptSchemaWithPKCErrorIfItFails as rt, pkcJsPageSorts as s, decryptEd25519AesGcmPublicKeyBuffer as sn, deriveCommentIpfsFromCommentTableRow as sr, parseCommentModerationChallengeRequestToEncryptSchemaWithPKCErrorIfItFails as st, RpcLocalCommunity as t, RpcUnsubscribeParamSchema as tn, BackupAbortError as tr, createSchemaRowParser as tt, orderPageCommentsByScore as u, _validateSignatureOfPKCRecord as un, getDefaultCommunityDbConfig as ur, parseCommentUpdateSchemaWithPKCErrorIfItFails as ut, authorIdentityMatcherForRequest as v, signCommentModeration as vn, setNativeFunctions as vr, parseCreateCommentOptionsSchemaWithPKCErrorIfItFails as vt, MAX_FILE_SIZE_BYTES_FOR_COMMUNITY_IPFS as w, verifyChallengeAnswer as wn, n$5 as wr, parseCreateVoteOptionsSchemaWithPKCErrorIfItFails as wt, TrackedInstanceRegistry as x, signCommunity as xn, t$4 as xr, parseCreatePKCWsServerOptionsSchemaWithPKCErrorIfItFails as xt, authorNameResolveFailureReason as y, signCommentUpdate as yn, tryToDeleteCommunitiesThatFailedToBeDeletedBefore as yr, parseCreateCommunityEditPublicationOptionsSchemaWithPKCErrorIfItFails as yt, extractCrosspostRuntimeFields as z, getAuthorNameFromWire as zn, RpcCommentRepliesPageParamSchema as zt };
130051
+ export { parseCommentChallengeRequestToEncryptSchemaWithPKCErrorIfItFails as $, calculateExpectedSignatureSize as $n, SignerWithPublicKeyAddress as $t, iterateOverPageCidsToFindAllCids as A, verifyCommunityEdit as An, require_lodash_merge as Ar, parseVotePubsubMessagePublicationSchemaWithPKCErrorIfItFails as At, InflightResourceTypes as B, getCommunityAddressFromRecord as Bn, RpcExportCommunityModLogsResultSchema as Bt, TIMEFRAMES_TO_SECONDS as C, verifyChallengeVerification as Cn, t$8 as Cr, parseDecryptedChallengeWithPKCErrorIfItFails as Ct, findCommentInPageInstance as D, verifyCommentPubsubMessage as Dn, NAME_RESOLVED_TRUE_TTL_MS as Dr, parseRpcCommentUpdateEventWithPKCErrorIfItFails as Dt, extractCommunityRuntimeFieldsFromParsedPages as E, verifyCommentModeration as En, NAME_RESOLVED_FALSE_TTL_MS as Er, parseRpcCommentEventWithPKCErrorIfItFails as Et, extractCrosspostRuntimeFields as F, getAuthorNameFromWire as Fn, RpcCommentRepliesPageParamSchema as Ft, decodeRpcChallengePubsubMsg as G, encode as Gn, RpcPublishAnchorRecordParamSchema as Gt, pLimit as H, getCommunityPublicKeyFromWire as Hn, RpcExportCommunityResultSchema as Ht, stripNameResolvedFromCrosspost as I, normalizeCreatePublicationAuthor as In, RpcCommunityIdentifierParamSchema as It, coerceSchemaRowBoolean as J, getPKCAddressFromPublicKey as Jn, RpcResolveAuthorNameResultSchema as Jt, decodeRpcChallengeRequestPubsubMsg as K, getBufferedPKCAddressFromPublicKey as Kn, RpcPublishChallengeAnswersParamSchema as Kt, PKCClientsManager as L, crosspostChainDepthUpTo as Ln, RpcCommunityPageParamSchema as Lt, applyNameResolvedCacheToCrosspost as M, buildRuntimeAuthor as Mn, require_undici as Mr, RpcAuthorNameParamSchema as Mt, cloneCrosspostForRuntime as N, cleanWireAuthor as Nn, RpcCancelExportParamSchema as Nt, findCommentInPageInstanceRecursively as O, verifyCommentUpdate as On, NAME_RESOLVE_FAILED_RETRY_FLOOR_MS as Or, parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails as Ot, collectCrosspostAuthorsToResolve as P, getAuthorNameFromRuntime as Pn, RpcCidParamSchema as Pt, parseCidStringSchemaWithPKCErrorIfItFails as Q, backupCommunityDb as Qn, require_lib as Qt, GenericStateClient as R, effectiveMaxCrosspostDepth as Rn, RpcEditCommunityParamSchema as Rt, RepliesPages as S, verifyChallengeRequest as Sn, t$7 as Sr, parseDecryptedChallengeVerification as St, buildPagesRuntimeFields as T, verifyCommentIpfs as Tn, MAX_FILE_SIZE_BYTES_FOR_COMMENT_UPDATE as Tr, parsePKCUserOptionsSchemaWithPKCErrorIfItFails as Tt, PKCTypedEmitter as U, normalizeCommunityInputFromCommunity as Un, RpcFetchCidParamSchema as Ut, pRetry as V, getCommunityNameFromWire$1 as Vn, RpcExportCommunityParamSchema as Vt, decodeRpcChallengeAnswerPubsubMsg as W, decode as Wn, RpcFetchCidResultSchema as Wt, collectSchemaRowCoercions as X, getPublicKeyFromPrivateKey as Xn, RpcSuccessResultSchema as Xt, coerceSchemaRowJson as Y, getPKCAddressFromPublicKeySync as Yn, RpcSubscriptionIdResultSchema as Yt, createSchemaRowParser as Z, BackupAbortError as Zn, RpcUnsubscribeParamSchema as Zt, TrackedInstanceRegistry as _, signCommunity as _n, t$4 as _r, parseCreatePKCWsServerOptionsSchemaWithPKCErrorIfItFails as _t, generatePagesReportingFailedSorts as a, encryptEd25519AesGcmPublicKeyBuffer as an, deriveDbReplies as ar, parseCommentPubsubMessagePublicationWithPKCErrorIfItFails as at, MAX_FILE_SIZE_BYTES_FOR_COMMUNITY_IPFS as b, verifyChallengeAnswer as bn, n$5 as br, parseCreateVoteOptionsSchemaWithPKCErrorIfItFails as bt, resolvePageSortsOrThrow as c, signChallengeAnswer as cn, getThumbnailPropsOfLink as cr, parseCommunityEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails as ct, getCommunityChallengeFromCommunityChallengeSettings as d, signChallengeVerification as dn, monitorCommunitiesDirectory as dr, parseCommunityIpfsSchemaPassthroughWithPKCErrorIfItFails as dt, createSigner as en, calculateInlineRepliesBudget as er, parseCommentEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails as et, loadChallengeFileFromCommunityChallengeSettings as f, signComment as fn, moveCommunityDbToDeletedDirectory as fr, parseCreateCommentEditOptionsSchemaWithPKCErrorIfItFails as ft, createAuthorIdentityMatcher as g, signCommentUpdateForChallengeVerification as gn, t$2 as gr, parseCreateNewLocalCommunityUserOptionsSchemaWithPKCErrorIfItFails as gt, authorNameResolveFailureReason as h, signCommentUpdate as hn, tryToDeleteCommunitiesThatFailedToBeDeletedBefore as hr, parseCreateCommunityEditPublicationOptionsSchemaWithPKCErrorIfItFails as ht, derivePublicPageSorts as i, encryptEd25519AesGcm as in, deriveDbPosts as ir, parseCommentModerationPubsubMessagePublicationSchemaWithPKCErrorIfItFails as it, parseRawPages as j, verifyVote as jn, nativeFunctions$1 as jr, RpcAnchorPublishPreparationResultSchema as jt, findCommentInParsedPages as k, verifyCommunity as kn, STORAGE_KEYS as kr, parseVoteChallengeRequestToEncryptSchemaWithPKCErrorIfItFails as kt, pkcJsPageSorts as l, signChallengeMessage as ln, importSignerIntoKuboNode as lr, parseCommunityEditOptionsSchemaWithPKCErrorIfItFails as lt, authorIdentityMatcherForRequest as m, signCommentModeration as mn, setNativeFunctions as mr, parseCreateCommentOptionsSchemaWithPKCErrorIfItFails as mt, RpcRemoteCommunity as n, decryptEd25519AesGcm as nn, deleteOldCommunityInWindows as nr, parseCommentIpfsSchemaWithPKCErrorIfItFails as nt, loadPageSortsForStartedCommunity as o, _validateSignatureOfPKCRecord as on, getDefaultCommunityDbConfig as or, parseCommentUpdateSchemaWithPKCErrorIfItFails as ot, pkcJsChallenges as p, signCommentEdit as pn, resolveDbPostsCidRefs as pr, parseCreateCommentModerationOptionsSchemaWithPKCErrorIfItFails as pt, decodeRpcChallengeVerificationPubsubMsg as q, getIpfsKeyFromPrivateKey as qn, RpcPublishedAnchorRecordResultSchema as qt, computePageSortsFingerprint as r, decryptEd25519AesGcmPublicKeyBuffer as rn, deriveCommentIpfsFromCommentTableRow as rr, parseCommentModerationChallengeRequestToEncryptSchemaWithPKCErrorIfItFails as rt, lookupPageSortFactories as s, cleanUpBeforePublishing as sn, getDefaultDataPath as sr, parseCommunityAddressWithPKCErrorIfItFails as st, RpcLocalCommunity as t, createAnchorIpnsRecord as tn, createKuboRpcClient as tr, parseCommentEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails as tt, getChallengeVerification as u, signChallengeRequest as un, listCommunitiesSync as ur, parseCommunityEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails as ut, LRUCache as v, signCommunityEdit as vn, r as vr, parseCreateRemoteCommunityFunctionArgumentSchemaWithPKCErrorIfItFails as vt, buildPageRuntimeFields as w, verifyCommentEdit as wn, stringify as wr, parseJsonWithPKCErrorIfFails as wt, KeyvBetterSqlite3 as x, verifyChallengeMessage as xn, n$6 as xr, parseDecryptedChallengeAnswerWithPKCErrorIfItFails as xt, RemoteCommunity as y, signVote as yn, t$5 as yr, parseCreateRpcCommunityFunctionArgumentSchemaWithPKCErrorIfItFails as yt, InflightFetchManager as z, buildRuntimeCommunityFields as zn, RpcExportCommunityModLogsParamSchema as zt };
@@ -1,4 +1,4 @@
1
- import { Ar as PKCError, z as pubsubTopicToDhtKeyCid } from "./util-DFGl6QDd.js";
1
+ import { Ar as PKCError, z as pubsubTopicToDhtKeyCid } from "./util-vJMTa4rC.js";
2
2
  import { ipnsSelector } from "ipns/selector";
3
3
  import { ipnsValidator } from "ipns/validator";
4
4
  import { unmarshalIPNSRecord } from "ipns";
@@ -5533,6 +5533,7 @@ var messages;
5533
5533
  messages["ERR_FAILED_TO_LOAD_LOCAL_RAW_IPNS_RECORD"] = "Failed to load local IPNS record from within our kubo node";
5534
5534
  messages["ERR_FAILED_TO_IMPORT_CHALLENGE_FILE_FACTORY"] = "Failed to import challenge file factory";
5535
5535
  messages["ERR_FAILED_TO_IMPORT_CHALLENGE_FILE"] = "Failed to import challenge file";
5536
+ messages["ERR_CHALLENGE_FILE_INVALID"] = "The challenge file factory did not return a valid ChallengeFile";
5536
5537
  messages["ERR_INVALID_RESULT_FROM_GET_CHALLENGE_FUNCTION"] = "invalid getChallenge response from community challenge";
5537
5538
  messages["ERR_LOCAL_COMMUNITY_RECORD_TOO_LARGE"] = "Local community has produced a record that is too large. This is a critical error and a bug in pkc-js";
5538
5539
  messages["ERR_CAN_NOT_LOAD_DB_IF_LOCAL_COMMUNITY_ALREADY_STARTED_IN_ANOTHER_PROCESS"] = "Can't load a local community that's already started in another process. You need to use the same PKC instance to load the community";
@@ -14796,7 +14797,7 @@ const CommunityEditPublicationPubsubReservedFields = r$2([
14796
14797
  ], t$3(CommunityEditPubsubMessagePublicationSchema.shape));
14797
14798
  //#endregion
14798
14799
  //#region dist/node/generated-version.js
14799
- const version = "0.0.114";
14800
+ const version = "0.0.116";
14800
14801
  //#endregion
14801
14802
  //#region dist/node/version.js
14802
14803
  const protocolVersion = ProtocolVersionSchema.parse("1.0.0");
@@ -0,0 +1,41 @@
1
+ import { Ar as PKCError, _n as PageSortFileFactorySchema, an as ChallengeFileSchema, in as ChallengeFileFactorySchema } from "./util-vJMTa4rC.js";
2
+ import { s as validatePageSortFile } from "./page-sort-scoring-Bj73WnwW.js";
3
+ //#region dist/node/validate-package-factories.js
4
+ function validateChallengeFileFactory(factory, { name }) {
5
+ try {
6
+ ChallengeFileFactorySchema.parse(factory);
7
+ } catch (error) {
8
+ throw new PKCError("ERR_FAILED_TO_IMPORT_CHALLENGE_FILE_FACTORY", {
9
+ name,
10
+ error
11
+ });
12
+ }
13
+ try {
14
+ return ChallengeFileSchema.parse(factory({ challengeSettings: { name } }));
15
+ } catch (error) {
16
+ throw new PKCError("ERR_CHALLENGE_FILE_INVALID", {
17
+ name,
18
+ error
19
+ });
20
+ }
21
+ }
22
+ function validatePageSortFileFactory(factory, { name }) {
23
+ try {
24
+ PageSortFileFactorySchema.parse(factory);
25
+ } catch (error) {
26
+ throw new PKCError("ERR_FAILED_TO_IMPORT_PAGE_SORT_FILE_FACTORY", {
27
+ name,
28
+ error
29
+ });
30
+ }
31
+ try {
32
+ return validatePageSortFile(factory({ pageSortSettings: { name } }));
33
+ } catch (error) {
34
+ throw new PKCError("ERR_PAGE_SORT_FILE_INVALID", {
35
+ name,
36
+ error
37
+ });
38
+ }
39
+ }
40
+ //#endregion
41
+ export { validatePageSortFileFactory as n, validateChallengeFileFactory as t };
@@ -1,2 +1,2 @@
1
- import { a as getShortCid, c as setNativeFunctions, i as getShortAddress, n as challenges, o as nativeFunctions, r as createAnchorIpnsRecord, s as pageSorts, t as PKC } from "./chunks/node-apYZl3B3.js";
1
+ import { a as getShortCid, c as setNativeFunctions, i as getShortAddress, n as challenges, o as nativeFunctions, r as createAnchorIpnsRecord, s as pageSorts, t as PKC } from "./chunks/node-CaeXEQ5O.js";
2
2
  export { challenges, createAnchorIpnsRecord, PKC as default, getShortAddress, getShortCid, nativeFunctions, pageSorts, setNativeFunctions };
@@ -0,0 +1,2 @@
1
+ import { n as validatePageSortFileFactory } from "./chunks/validate-package-factories-tZC8XxoO.js";
2
+ export { validatePageSortFileFactory };
@@ -1,7 +1,7 @@
1
- import { Ar as PKCError, Dt as pTimeout, J as replaceXWithY, Mr as logger_default, S as hideClassPrivateProps, dr as n, pr as t, ut as findStartedCommunity } from "../../chunks/util-DFGl6QDd.js";
2
- import { _ as parseRpcExportCommunityParam, b as parseRpcUnsubscribeParam, d as parseRpcCidParam, f as parseRpcCommentRepliesPageParam, g as parseRpcExportCommunityModLogsParam, h as parseRpcEditCommunityParam, l as parseRpcAuthorNameParam, m as parseRpcCommunityPageParam, p as parseRpcCommunityIdentifierParam, t as PKC, u as parseRpcCancelExportParam, v as parseRpcPublishAnchorRecordParam, y as parseRpcPublishChallengeAnswersParam } from "../../chunks/node-apYZl3B3.js";
3
- import { G as pRetry, K as pLimit, Mt as parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, Nt as parseVoteChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, O as buildPageRuntimeFields, Or as stringify, Tt as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, bt as parseCreateNewLocalCommunityUserOptionsSchemaWithPKCErrorIfItFails, ft as parseCommunityEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, it as parseCommentEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, k as buildPagesRuntimeFields, nn as require_lib, pt as parseCommunityEditOptionsSchemaWithPKCErrorIfItFails, rt as parseCommentChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, st as parseCommentModerationChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, xr as t$1, xt as parseCreatePKCWsServerOptionsSchemaWithPKCErrorIfItFails, z as extractCrosspostRuntimeFields } from "../../chunks/rpc-local-community-C_0FRCqg.js";
4
- import { t as LocalCommunity } from "../../chunks/local-community-EeQMdfYM.js";
1
+ import { Ar as PKCError, Dt as pTimeout, J as replaceXWithY, Mr as logger_default, S as hideClassPrivateProps, dr as n, pr as t, ut as findStartedCommunity } from "../../chunks/util-vJMTa4rC.js";
2
+ import { _ as parseRpcExportCommunityParam, b as parseRpcUnsubscribeParam, d as parseRpcCidParam, f as parseRpcCommentRepliesPageParam, g as parseRpcExportCommunityModLogsParam, h as parseRpcEditCommunityParam, l as parseRpcAuthorNameParam, m as parseRpcCommunityPageParam, p as parseRpcCommunityIdentifierParam, t as PKC, u as parseRpcCancelExportParam, v as parseRpcPublishAnchorRecordParam, y as parseRpcPublishChallengeAnswersParam } from "../../chunks/node-CaeXEQ5O.js";
3
+ import { $ as parseCommentChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, F as extractCrosspostRuntimeFields, H as pLimit, Ot as parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, Qt as require_lib, T as buildPagesRuntimeFields, V as pRetry, _r as t$1, _t as parseCreatePKCWsServerOptionsSchemaWithPKCErrorIfItFails, ct as parseCommunityEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, et as parseCommentEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, gt as parseCreateNewLocalCommunityUserOptionsSchemaWithPKCErrorIfItFails, kt as parseVoteChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, lt as parseCommunityEditOptionsSchemaWithPKCErrorIfItFails, rt as parseCommentModerationChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, w as buildPageRuntimeFields, wr as stringify, xt as parseDecryptedChallengeAnswerWithPKCErrorIfItFails } from "../../chunks/rpc-local-community-DfJ3wj-p.js";
4
+ import { t as LocalCommunity } from "../../chunks/local-community-nSmHRx5s.js";
5
5
  import { fileURLToPath } from "node:url";
6
6
  import path from "path";
7
7
  import assert from "assert";
@@ -24,6 +24,7 @@ const PKCJs = { PKC };
24
24
  function setPKCJs(_PKC) {
25
25
  assert(typeof _PKC === "function", `setPKCJs invalid PKC argument '${_PKC}' not a function`);
26
26
  if (_PKC.challenges === void 0) _PKC.challenges = PKC.challenges;
27
+ if (_PKC.pageSorts === void 0) _PKC.pageSorts = PKC.pageSorts;
27
28
  PKCJs.PKC = _PKC;
28
29
  log$1("setPKCJs", _PKC?.constructor?.name);
29
30
  }
@@ -135,6 +136,7 @@ var PKCWsServer = class extends import_lib.TypedEmitter {
135
136
  this._trackedCommunityListeners = /* @__PURE__ */ new WeakMap();
136
137
  this._getIpFromConnectionRequest = (req) => req.socket.remoteAddress;
137
138
  this._onSettingsChange = {};
139
+ this._settingsSenders = /* @__PURE__ */ new Map();
138
140
  this._startedCommunities = {};
139
141
  this._autoStartOnBoot = false;
140
142
  this._exportCommunityInstances = /* @__PURE__ */ new Map();
@@ -771,10 +773,13 @@ var PKCWsServer = class extends import_lib.TypedEmitter {
771
773
  const sendRpcSettings = async ({ newPKC }) => {
772
774
  sendEvent("settingschange", this._serializeSettingsFromPKC(newPKC));
773
775
  };
776
+ const senderKey = `${connectionId}:${subscriptionId}`;
774
777
  this.subscriptionCleanups[connectionId][subscriptionId] = async () => {
775
778
  if (this._onSettingsChange[connectionId]) delete this._onSettingsChange[connectionId][subscriptionId];
779
+ this._settingsSenders.delete(senderKey);
776
780
  };
777
781
  this._onSettingsChange[connectionId][subscriptionId] = sendRpcSettings;
782
+ this._settingsSenders.set(senderKey, sendRpcSettings);
778
783
  await sendRpcSettings({ newPKC: this.pkc });
779
784
  return { subscriptionId };
780
785
  }
@@ -785,6 +790,14 @@ var PKCWsServer = class extends import_lib.TypedEmitter {
785
790
  async _createPKCInstanceFromSetSettings(newOptions) {
786
791
  return PKCJs.PKC(newOptions);
787
792
  }
793
+ async notifySettingsChange() {
794
+ await this._setSettingsQueue;
795
+ for (const [senderKey, send] of [...this._settingsSenders]) try {
796
+ await send({ newPKC: this.pkc });
797
+ } catch (error) {
798
+ log.error(`Failed to send settingschange to settings subscription ${senderKey}, continuing with the rest`, error);
799
+ }
800
+ }
788
801
  async setSettings(params) {
789
802
  const runSetSettings = async () => {
790
803
  const settings = parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails(params[0]);
@@ -1 +1,2 @@
1
+ export { validateChallengeFileFactory } from "./validate-package-factories.js";
1
2
  export type { ChallengeFileInput, ChallengeInput, ChallengeResultInput, GetChallengeArgsInput, CommunityChallengeSetting } from "./community/types.js";
@@ -1,2 +1,2 @@
1
- export {};
1
+ export { validateChallengeFileFactory } from "./validate-package-factories.js";
2
2
  //# sourceMappingURL=challenges.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"challenges.js","sourceRoot":"","sources":["../../src/challenges.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"challenges.js","sourceRoot":"","sources":["../../src/challenges.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,iCAAiC,CAAC"}
@@ -146,7 +146,30 @@ export class BaseClientsManager {
146
146
  };
147
147
  let error;
148
148
  try {
149
- await pubsubClient.pubsub.subscribe(pubsubTopic, handler, { onError: handlePubsubError });
149
+ await pRetry(async () => {
150
+ try {
151
+ await pubsubClient.pubsub.subscribe(pubsubTopic, handler, { onError: handlePubsubError });
152
+ }
153
+ catch (e) {
154
+ // Only a transient socket-level failure is retried, e.g. kubo's API refusing connections
155
+ // while saturated (#422). Anything else, including "Already subscribed", stops immediately.
156
+ const networkErrorDetails = extractNetworkErrorDetails(e);
157
+ const isTransient = networkErrorDetails !== undefined && hasTransientNetworkErrorCode(networkErrorDetails);
158
+ if (!isTransient)
159
+ throw e instanceof Error ? new PRetryAbortError(e) : e;
160
+ throw e;
161
+ }
162
+ }, {
163
+ // 2 retries + initial attempt = up to 3 attempts. Backoff 250ms, 500ms between retries.
164
+ retries: 2,
165
+ factor: 2,
166
+ minTimeout: 250,
167
+ maxTimeout: 1000,
168
+ onFailedAttempt: ({ error: attemptError, attemptNumber, retriesLeft }) => {
169
+ if (retriesLeft > 0)
170
+ log.trace(`Transient failure subscribing to pubsub topic (${pubsubTopic}) on (${kuboPubsubRpcUrlOrLibp2pJsKey}), attempt ${attemptNumber}/${attemptNumber + retriesLeft}`, attemptError?.message);
171
+ }
172
+ });
150
173
  if (error)
151
174
  throw error;
152
175
  await this._pkc._stats.recordGatewaySuccess(kuboPubsubRpcUrlOrLibp2pJsKey, "pubsub-subscribe", Date.now() - timeBefore);
@@ -170,7 +193,7 @@ export class BaseClientsManager {
170
193
  for (let i = 0; i < providersSorted.length; i++) {
171
194
  const pubsubProviderUrl = providersSorted[i];
172
195
  try {
173
- return this.pubsubSubscribeOnProvider(pubsubTopic, handler, pubsubProviderUrl);
196
+ return await this.pubsubSubscribeOnProvider(pubsubTopic, handler, pubsubProviderUrl);
174
197
  }
175
198
  catch (e) {
176
199
  providerToError[pubsubProviderUrl] = e;