@pkcprotocol/pkc-js 0.0.116 → 0.0.118

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 (75) hide show
  1. package/dist/browser/clients/rpc-client/pkc-rpc-client.d.ts +16 -0
  2. package/dist/browser/clients/rpc-client/pkc-rpc-client.js +199 -43
  3. package/dist/browser/clients/rpc-client/pkc-rpc-client.js.map +1 -1
  4. package/dist/browser/errors.d.ts +4 -0
  5. package/dist/browser/errors.js +4 -0
  6. package/dist/browser/errors.js.map +1 -1
  7. package/dist/browser/generated-version.d.ts +1 -1
  8. package/dist/browser/generated-version.js +1 -1
  9. package/dist/browser/pkc-error.d.ts +1 -1
  10. package/dist/browser/rpc/src/index.d.ts +5 -1
  11. package/dist/browser/rpc/src/index.js +28 -2
  12. package/dist/browser/rpc/src/index.js.map +1 -1
  13. package/dist/browser/runtime/node/community/challenges/index.d.ts +17 -3
  14. package/dist/browser/runtime/node/community/challenges/index.js +58 -16
  15. package/dist/browser/runtime/node/community/challenges/index.js.map +1 -1
  16. package/dist/browser/runtime/node/community/challenges/validate-challenge-settings.js +1 -1
  17. package/dist/browser/runtime/node/community/challenges/validate-challenge-settings.js.map +1 -1
  18. package/dist/browser/runtime/node/community/local-community/challenges.js +7 -1
  19. package/dist/browser/runtime/node/community/local-community/challenges.js.map +1 -1
  20. package/dist/browser/runtime/node/community/local-community/db-state.js +5 -2
  21. package/dist/browser/runtime/node/community/local-community/db-state.js.map +1 -1
  22. package/dist/browser/runtime/node/community/local-community/editing.js +5 -2
  23. package/dist/browser/runtime/node/community/local-community/editing.js.map +1 -1
  24. package/dist/browser/runtime/node/community/local-community/lifecycle.js +19 -4
  25. package/dist/browser/runtime/node/community/local-community/lifecycle.js.map +1 -1
  26. package/dist/browser/runtime/node/community/local-community/registry-sync.js +20 -5
  27. package/dist/browser/runtime/node/community/local-community/registry-sync.js.map +1 -1
  28. package/dist/browser/runtime/node/community/local-community.d.ts +1 -0
  29. package/dist/browser/runtime/node/community/local-community.js +3 -0
  30. package/dist/browser/runtime/node/community/local-community.js.map +1 -1
  31. package/dist/bundled/bundle-manifest.json +40 -40
  32. package/dist/bundled/challenges.js +1 -1
  33. package/dist/bundled/chunks/{helia-for-pkc-BvltkMx7.js → helia-for-pkc-DMzV8Gsa.js} +2 -2
  34. package/dist/bundled/chunks/{local-community-nSmHRx5s.js → local-community-DvEh9Nte.js} +37 -14
  35. package/dist/bundled/chunks/{local-community-Cm4X7RjW.js → local-community-YoJAmva8.js} +1 -1
  36. package/dist/bundled/chunks/{node-CaeXEQ5O.js → node-CH9-YjYa.js} +169 -53
  37. package/dist/bundled/chunks/{page-sort-scoring-Bj73WnwW.js → page-sort-scoring-C1XYRQ1w.js} +1 -1
  38. package/dist/bundled/chunks/{rpc-local-community-DfJ3wj-p.js → rpc-local-community-DqKbZLIy.js} +64 -20
  39. package/dist/bundled/chunks/{util-DkyQHyK7.js → util-CpoO437x.js} +1 -1
  40. package/dist/bundled/chunks/{util-vJMTa4rC.js → util-DEmcezee.js} +5 -1
  41. package/dist/bundled/chunks/{validate-package-factories-tZC8XxoO.js → validate-package-factories-C9A4AtCN.js} +2 -2
  42. package/dist/bundled/index.js +1 -1
  43. package/dist/bundled/page-sorts.js +1 -1
  44. package/dist/bundled/rpc/src/index.js +23 -6
  45. package/dist/node/clients/rpc-client/pkc-rpc-client.d.ts +16 -0
  46. package/dist/node/clients/rpc-client/pkc-rpc-client.js +199 -43
  47. package/dist/node/clients/rpc-client/pkc-rpc-client.js.map +1 -1
  48. package/dist/node/errors.d.ts +4 -0
  49. package/dist/node/errors.js +4 -0
  50. package/dist/node/errors.js.map +1 -1
  51. package/dist/node/generated-version.d.ts +1 -1
  52. package/dist/node/generated-version.js +1 -1
  53. package/dist/node/pkc-error.d.ts +1 -1
  54. package/dist/node/rpc/src/index.d.ts +5 -1
  55. package/dist/node/rpc/src/index.js +28 -2
  56. package/dist/node/rpc/src/index.js.map +1 -1
  57. package/dist/node/runtime/node/community/challenges/index.d.ts +17 -3
  58. package/dist/node/runtime/node/community/challenges/index.js +58 -16
  59. package/dist/node/runtime/node/community/challenges/index.js.map +1 -1
  60. package/dist/node/runtime/node/community/challenges/validate-challenge-settings.js +1 -1
  61. package/dist/node/runtime/node/community/challenges/validate-challenge-settings.js.map +1 -1
  62. package/dist/node/runtime/node/community/local-community/challenges.js +7 -1
  63. package/dist/node/runtime/node/community/local-community/challenges.js.map +1 -1
  64. package/dist/node/runtime/node/community/local-community/db-state.js +5 -2
  65. package/dist/node/runtime/node/community/local-community/db-state.js.map +1 -1
  66. package/dist/node/runtime/node/community/local-community/editing.js +5 -2
  67. package/dist/node/runtime/node/community/local-community/editing.js.map +1 -1
  68. package/dist/node/runtime/node/community/local-community/lifecycle.js +19 -4
  69. package/dist/node/runtime/node/community/local-community/lifecycle.js.map +1 -1
  70. package/dist/node/runtime/node/community/local-community/registry-sync.js +20 -5
  71. package/dist/node/runtime/node/community/local-community/registry-sync.js.map +1 -1
  72. package/dist/node/runtime/node/community/local-community.d.ts +1 -0
  73. package/dist/node/runtime/node/community/local-community.js +3 -0
  74. package/dist/node/runtime/node/community/local-community.js.map +1 -1
  75. package/package.json +1 -1
@@ -1,7 +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, _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";
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-DEmcezee.js";
3
3
  import { t as all } from "./src-CYIMjhjK.js";
4
- import { s as validatePageSortFile } from "./page-sort-scoring-Bj73WnwW.js";
4
+ import { s as validatePageSortFile } from "./page-sort-scoring-C1XYRQ1w.js";
5
5
  import { createHash } from "node:crypto";
6
6
  import { pathToFileURL } from "node:url";
7
7
  import dns from "node:dns";
@@ -128292,6 +128292,19 @@ const accumulateChallengeResultExtras = ({ challengeResult, challengeIndex, agg
128292
128292
  const resolveChallengeFactoryByName = ({ name, pkc }) => {
128293
128293
  return { factory: pkc?.settings?.challenges?.[name] ?? pkcJsChallenges[name] };
128294
128294
  };
128295
+ const listAvailableChallengeNames = ({ pkc }) => [...new Set([...Object.keys(pkcJsChallenges), ...Object.keys(pkc?.settings?.challenges ?? {})])].sort();
128296
+ const resolveRegisteredChallengeFactory = ({ name, challengeIndex, pkc }) => {
128297
+ const { factory } = resolveChallengeFactoryByName({
128298
+ name,
128299
+ pkc
128300
+ });
128301
+ if (!factory) throw new PKCError("ERR_CHALLENGE_NOT_REGISTERED", {
128302
+ challengeName: name,
128303
+ challengeIndex,
128304
+ availableChallengeNames: listAvailableChallengeNames({ pkc })
128305
+ });
128306
+ return factory;
128307
+ };
128295
128308
  const pkcJsChallenges = {
128296
128309
  "text-math": ChallengeFileFactory$5,
128297
128310
  fail: ChallengeFileFactory$4,
@@ -128326,16 +128339,15 @@ const validateChallengeOrChallengeResult = ({ challengeOrChallengeResult, challe
128326
128339
  return { ok: true };
128327
128340
  };
128328
128341
  const loadChallengeFile = async ({ communityChallengeSettings, challengeIndex, community }) => {
128329
- if (!communityChallengeSettings.path && !resolveChallengeFactoryByName({
128342
+ if (!communityChallengeSettings.path && !communityChallengeSettings.name) throw Error("You have to provide either path or a stored pkc-js challenge");
128343
+ const registeredFactory = communityChallengeSettings.path ? void 0 : resolveRegisteredChallengeFactory({
128330
128344
  name: communityChallengeSettings.name,
128345
+ challengeIndex,
128331
128346
  pkc: community._pkc
128332
- }).factory) throw Error("You have to provide either path or a stored pkc-js challenge");
128347
+ });
128333
128348
  let ChallengeFileFactory;
128334
128349
  try {
128335
- ChallengeFileFactory = ChallengeFileFactorySchema.parse(communityChallengeSettings.path ? (await import(pathToFileURL(communityChallengeSettings.path).href)).default : resolveChallengeFactoryByName({
128336
- name: communityChallengeSettings.name,
128337
- pkc: community._pkc
128338
- }).factory);
128350
+ ChallengeFileFactory = ChallengeFileFactorySchema.parse(communityChallengeSettings.path ? (await import(pathToFileURL(communityChallengeSettings.path).href)).default : registeredFactory);
128339
128351
  validateChallengeFileFactory({
128340
128352
  challengeFileFactory: ChallengeFileFactory,
128341
128353
  challengeIndex,
@@ -128460,8 +128472,9 @@ const getPendingChallengesOrChallengeVerification = async ({ challengeRequestMes
128460
128472
  const challengeCount = community.settings.challenges.length;
128461
128473
  const results = new Array(challengeCount);
128462
128474
  const decided = new Array(challengeCount).fill(false);
128463
- const communityChallenges = await Promise.all(community.settings.challenges.map(async (s) => (await getCommunityChallengeFromCommunityChallengeSettings({
128475
+ const communityChallenges = await Promise.all(community.settings.challenges.map(async (s, challengeIndex) => (await getCommunityChallengeFromCommunityChallengeSettings({
128464
128476
  communityChallengeSettings: s,
128477
+ challengeIndex,
128465
128478
  pkc: community._pkc
128466
128479
  })).communityChallenge));
128467
128480
  const challengeFiles = await Promise.all(community.settings.challenges.map(async (s, i) => (await loadChallengeFile({
@@ -128815,35 +128828,36 @@ const derivePublicOptions = (communityChallengeSettings) => {
128815
128828
  for (const optionName of publicOptions) if (typeof options[optionName] === "string") published[optionName] = options[optionName];
128816
128829
  return e$5(published) ? void 0 : published;
128817
128830
  };
128818
- const loadChallengeFileFromCommunityChallengeSettings = async ({ communityChallengeSettings, pkc }) => {
128831
+ const loadChallengeFileFromCommunityChallengeSettings = async ({ communityChallengeSettings, challengeIndex, pkc }) => {
128819
128832
  let challengeFile = void 0;
128820
128833
  if (communityChallengeSettings.path) try {
128821
128834
  const importedFile = await import(pathToFileURL(communityChallengeSettings.path).href);
128822
128835
  const ChallengeFileFactory = ChallengeFileFactorySchema.parse(importedFile.default);
128823
128836
  challengeFile = ChallengeFileSchema.parse(ChallengeFileFactory({ challengeSettings: communityChallengeSettings }));
128824
128837
  } catch (e) {
128825
- e.details = {
128826
- ...e.details,
128838
+ throw new PKCError("ERR_FAILED_TO_IMPORT_CHALLENGE_FILE_FACTORY", {
128827
128839
  path: communityChallengeSettings.path,
128828
- communityChallengeSettings
128829
- };
128830
- if (e instanceof Error) e.message = `getCommunityChallengeFromCommunityChallengeSettings failed importing challenge with path '${communityChallengeSettings.path}': ${e.message}`;
128831
- throw e;
128840
+ communityChallengeSettings,
128841
+ challengeIndex,
128842
+ error: e
128843
+ });
128832
128844
  }
128833
128845
  else if (communityChallengeSettings.name) {
128834
- const ChallengeFileFactory = ChallengeFileFactorySchema.parse(resolveChallengeFactoryByName({
128846
+ const ChallengeFileFactory = ChallengeFileFactorySchema.parse(resolveRegisteredChallengeFactory({
128835
128847
  name: communityChallengeSettings.name,
128848
+ challengeIndex,
128836
128849
  pkc
128837
- }).factory);
128850
+ }));
128838
128851
  challengeFile = ChallengeFileSchema.parse(ChallengeFileFactory({ challengeSettings: communityChallengeSettings }));
128839
128852
  }
128840
128853
  if (!challengeFile) throw Error("Failed to load challenge file");
128841
128854
  return challengeFile;
128842
128855
  };
128843
- const getCommunityChallengeFromCommunityChallengeSettings = async ({ communityChallengeSettings, pkc }) => {
128856
+ const getCommunityChallengeFromCommunityChallengeSettings = async ({ communityChallengeSettings, challengeIndex, pkc }) => {
128844
128857
  communityChallengeSettings = CommunityChallengeSettingSchema.parse(communityChallengeSettings);
128845
128858
  const challengeFile = await loadChallengeFileFromCommunityChallengeSettings({
128846
128859
  communityChallengeSettings,
128860
+ challengeIndex,
128847
128861
  pkc
128848
128862
  });
128849
128863
  const { challenge, type } = challengeFile;
@@ -128857,6 +128871,36 @@ const getCommunityChallengeFromCommunityChallengeSettings = async ({ communityCh
128857
128871
  publicOptions: derivePublicOptions(communityChallengeSettings)
128858
128872
  } };
128859
128873
  };
128874
+ const deriveCommunityChallengesOrThrow = async ({ challengeSettings, pkc, communityAddress }) => {
128875
+ const results = await Promise.allSettled(challengeSettings.map((communityChallengeSettings, challengeIndex) => getCommunityChallengeFromCommunityChallengeSettings({
128876
+ communityChallengeSettings,
128877
+ challengeIndex,
128878
+ pkc
128879
+ })));
128880
+ const failures = [];
128881
+ results.forEach((result, challengeIndex) => {
128882
+ if (result.status === "fulfilled") return;
128883
+ const { name: challengeName, path } = challengeSettings[challengeIndex];
128884
+ const error = result.reason instanceof PKCError ? result.reason : new PKCError("ERR_FAILED_TO_IMPORT_CHALLENGE_FILE_FACTORY", {
128885
+ challengeName,
128886
+ path,
128887
+ challengeIndex,
128888
+ error: result.reason
128889
+ });
128890
+ failures.push({
128891
+ challengeIndex,
128892
+ challengeName,
128893
+ path,
128894
+ error
128895
+ });
128896
+ });
128897
+ if (failures.length) throw new PKCError("ERR_COMMUNITY_CHALLENGES_FAILED_TO_LOAD", {
128898
+ communityAddress,
128899
+ failures,
128900
+ availableChallengeNames: listAvailableChallengeNames({ pkc })
128901
+ });
128902
+ return results.map((result) => result.value.communityChallenge);
128903
+ };
128860
128904
  //#endregion
128861
128905
  //#region dist/node/pages/page-sort-options.js
128862
128906
  const MAX_AGE_UNIT_SECONDS = Object.freeze({
@@ -130048,4 +130092,4 @@ var RpcLocalCommunity = class extends RpcRemoteCommunity {
130048
130092
  }
130049
130093
  };
130050
130094
  //#endregion
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 };
130095
+ export { parseCidStringSchemaWithPKCErrorIfItFails as $, backupCommunityDb as $n, require_lib as $t, findCommentInParsedPages as A, verifyCommunity as An, STORAGE_KEYS as Ar, parseVoteChallengeRequestToEncryptSchemaWithPKCErrorIfItFails as At, InflightFetchManager as B, buildRuntimeCommunityFields as Bn, RpcExportCommunityModLogsParamSchema as Bt, RepliesPages as C, verifyChallengeRequest as Cn, t$7 as Cr, parseDecryptedChallengeVerification as Ct, extractCommunityRuntimeFieldsFromParsedPages as D, verifyCommentModeration as Dn, NAME_RESOLVED_FALSE_TTL_MS as Dr, parseRpcCommentEventWithPKCErrorIfItFails as Dt, buildPagesRuntimeFields as E, verifyCommentIpfs as En, MAX_FILE_SIZE_BYTES_FOR_COMMENT_UPDATE as Er, parsePKCUserOptionsSchemaWithPKCErrorIfItFails as Et, collectCrosspostAuthorsToResolve as F, getAuthorNameFromRuntime as Fn, RpcCidParamSchema as Ft, decodeRpcChallengeAnswerPubsubMsg as G, decode as Gn, RpcFetchCidResultSchema as Gt, pRetry as H, getCommunityNameFromWire$1 as Hn, RpcExportCommunityParamSchema as Ht, extractCrosspostRuntimeFields as I, getAuthorNameFromWire as In, RpcCommentRepliesPageParamSchema as It, decodeRpcChallengeVerificationPubsubMsg as J, getIpfsKeyFromPrivateKey as Jn, RpcPublishedAnchorRecordResultSchema as Jt, decodeRpcChallengePubsubMsg as K, encode as Kn, RpcPublishAnchorRecordParamSchema as Kt, stripNameResolvedFromCrosspost as L, normalizeCreatePublicationAuthor as Ln, RpcCommunityIdentifierParamSchema as Lt, parseRawPages as M, verifyVote as Mn, nativeFunctions$1 as Mr, RpcAnchorPublishPreparationResultSchema as Mt, applyNameResolvedCacheToCrosspost as N, buildRuntimeAuthor as Nn, require_undici as Nr, RpcAuthorNameParamSchema as Nt, findCommentInPageInstance as O, verifyCommentPubsubMessage as On, NAME_RESOLVED_TRUE_TTL_MS as Or, parseRpcCommentUpdateEventWithPKCErrorIfItFails as Ot, cloneCrosspostForRuntime as P, cleanWireAuthor as Pn, RpcCancelExportParamSchema as Pt, createSchemaRowParser as Q, BackupAbortError as Qn, RpcUnsubscribeParamSchema as Qt, PKCClientsManager as R, crosspostChainDepthUpTo as Rn, RpcCommunityPageParamSchema as Rt, KeyvBetterSqlite3 as S, verifyChallengeMessage as Sn, n$6 as Sr, parseDecryptedChallengeAnswerWithPKCErrorIfItFails as St, buildPageRuntimeFields as T, verifyCommentEdit as Tn, stringify as Tr, parseJsonWithPKCErrorIfFails as Tt, pLimit as U, getCommunityPublicKeyFromWire as Un, RpcExportCommunityResultSchema as Ut, InflightResourceTypes as V, getCommunityAddressFromRecord as Vn, RpcExportCommunityModLogsResultSchema as Vt, PKCTypedEmitter as W, normalizeCommunityInputFromCommunity as Wn, RpcFetchCidParamSchema as Wt, coerceSchemaRowJson as X, getPKCAddressFromPublicKeySync as Xn, RpcSubscriptionIdResultSchema as Xt, coerceSchemaRowBoolean as Y, getPKCAddressFromPublicKey as Yn, RpcResolveAuthorNameResultSchema as Yt, collectSchemaRowCoercions as Z, getPublicKeyFromPrivateKey as Zn, RpcSuccessResultSchema as Zt, createAuthorIdentityMatcher as _, signCommentUpdateForChallengeVerification as _n, t$2 as _r, parseCreateNewLocalCommunityUserOptionsSchemaWithPKCErrorIfItFails as _t, generatePagesReportingFailedSorts as a, encryptEd25519AesGcm as an, deriveDbPosts as ar, parseCommentModerationPubsubMessagePublicationSchemaWithPKCErrorIfItFails as at, RemoteCommunity as b, signVote as bn, t$5 as br, parseCreateRpcCommunityFunctionArgumentSchemaWithPKCErrorIfItFails as bt, resolvePageSortsOrThrow as c, cleanUpBeforePublishing as cn, getDefaultDataPath as cr, parseCommunityAddressWithPKCErrorIfItFails as ct, getChallengeVerification as d, signChallengeRequest as dn, listCommunitiesSync as dr, parseCommunityEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails as dt, SignerWithPublicKeyAddress as en, calculateExpectedSignatureSize as er, parseCommentChallengeRequestToEncryptSchemaWithPKCErrorIfItFails as et, getCommunityChallengeFromCommunityChallengeSettings as f, signChallengeVerification as fn, monitorCommunitiesDirectory as fr, parseCommunityIpfsSchemaPassthroughWithPKCErrorIfItFails as ft, authorNameResolveFailureReason as g, signCommentUpdate as gn, tryToDeleteCommunitiesThatFailedToBeDeletedBefore as gr, parseCreateCommunityEditPublicationOptionsSchemaWithPKCErrorIfItFails as gt, authorIdentityMatcherForRequest as h, signCommentModeration as hn, setNativeFunctions as hr, parseCreateCommentOptionsSchemaWithPKCErrorIfItFails as ht, derivePublicPageSorts as i, decryptEd25519AesGcmPublicKeyBuffer as in, deriveCommentIpfsFromCommentTableRow as ir, parseCommentModerationChallengeRequestToEncryptSchemaWithPKCErrorIfItFails as it, iterateOverPageCidsToFindAllCids as j, verifyCommunityEdit as jn, require_lodash_merge as jr, parseVotePubsubMessagePublicationSchemaWithPKCErrorIfItFails as jt, findCommentInPageInstanceRecursively as k, verifyCommentUpdate as kn, NAME_RESOLVE_FAILED_RETRY_FLOOR_MS as kr, parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails as kt, pkcJsPageSorts as l, signChallengeAnswer as ln, getThumbnailPropsOfLink as lr, parseCommunityEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails as lt, pkcJsChallenges as m, signCommentEdit as mn, resolveDbPostsCidRefs as mr, parseCreateCommentModerationOptionsSchemaWithPKCErrorIfItFails as mt, RpcRemoteCommunity as n, createAnchorIpnsRecord as nn, createKuboRpcClient as nr, parseCommentEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails as nt, loadPageSortsForStartedCommunity as o, encryptEd25519AesGcmPublicKeyBuffer as on, deriveDbReplies as or, parseCommentPubsubMessagePublicationWithPKCErrorIfItFails as ot, loadChallengeFileFromCommunityChallengeSettings as p, signComment as pn, moveCommunityDbToDeletedDirectory as pr, parseCreateCommentEditOptionsSchemaWithPKCErrorIfItFails as pt, decodeRpcChallengeRequestPubsubMsg as q, getBufferedPKCAddressFromPublicKey as qn, RpcPublishChallengeAnswersParamSchema as qt, computePageSortsFingerprint as r, decryptEd25519AesGcm as rn, deleteOldCommunityInWindows as rr, parseCommentIpfsSchemaWithPKCErrorIfItFails as rt, lookupPageSortFactories as s, _validateSignatureOfPKCRecord as sn, getDefaultCommunityDbConfig as sr, parseCommentUpdateSchemaWithPKCErrorIfItFails as st, RpcLocalCommunity as t, createSigner as tn, calculateInlineRepliesBudget as tr, parseCommentEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails as tt, deriveCommunityChallengesOrThrow as u, signChallengeMessage as un, importSignerIntoKuboNode as ur, parseCommunityEditOptionsSchemaWithPKCErrorIfItFails as ut, TrackedInstanceRegistry as v, signCommunity as vn, t$4 as vr, parseCreatePKCWsServerOptionsSchemaWithPKCErrorIfItFails as vt, TIMEFRAMES_TO_SECONDS as w, verifyChallengeVerification as wn, t$8 as wr, parseDecryptedChallengeWithPKCErrorIfItFails as wt, MAX_FILE_SIZE_BYTES_FOR_COMMUNITY_IPFS as x, verifyChallengeAnswer as xn, n$5 as xr, parseCreateVoteOptionsSchemaWithPKCErrorIfItFails as xt, LRUCache as y, signCommunityEdit as yn, r as yr, parseCreateRemoteCommunityFunctionArgumentSchemaWithPKCErrorIfItFails as yt, GenericStateClient as z, effectiveMaxCrosspostDepth as zn, RpcEditCommunityParamSchema as zt };
@@ -1,4 +1,4 @@
1
- import { Ar as PKCError, z as pubsubTopicToDhtKeyCid } from "./util-vJMTa4rC.js";
1
+ import { Ar as PKCError, z as pubsubTopicToDhtKeyCid } from "./util-DEmcezee.js";
2
2
  import { ipnsSelector } from "ipns/selector";
3
3
  import { ipnsValidator } from "ipns/validator";
4
4
  import { unmarshalIPNSRecord } from "ipns";
@@ -5553,11 +5553,13 @@ var messages;
5553
5553
  messages["ERR_FAILED_TO_OPEN_CONNECTION_TO_RPC"] = "Failed to open connection to RPC";
5554
5554
  messages["ERR_FAILED_TO_CREATE_WS_RPC_SERVER"] = "Failed to create WebSocket RPC server";
5555
5555
  messages["ERR_RPC_CLIENT_ATTEMPTING_TO_START_A_REMOTE_COMMUNITY"] = "Attempting to start a community that is not local";
5556
+ messages["ERR_RPC_COMMUNITY_NOT_RUNNING"] = "The community is not running on the PKC RPC server and was stopped on purpose, so the RPC client did not start it again after reconnecting";
5556
5557
  messages["ERR_RPC_CLIENT_TRYING_TO_STOP_COMMUNITY_THAT_IS_NOT_RUNNING"] = "RPC client is attempting to stop a local community that is not running";
5557
5558
  messages["ERR_RPC_CLIENT_TRYING_TO_STOP_REMOTE_COMMUNITY"] = "RPC client is attempting to stop a remote community";
5558
5559
  messages["ERR_RPC_CLIENT_TRYING_TO_EDIT_REMOTE_COMMUNITY"] = "RPC client is attempting to edit remote community";
5559
5560
  messages["ERR_RPC_CLIENT_TRYING_TO_DELETE_REMOTE_COMMUNITY"] = "RPC client is attempting to delete remote community";
5560
5561
  messages["ERR_RPC_CLIENT_TRYING_TO_USE_ANCHOR_METHOD_ON_NON_LOCAL_COMMUNITY"] = "RPC client is attempting to prepare or publish an anchor record for a community this node does not host locally";
5562
+ messages["ERR_RPC_PUBLICATION_LOST_WITH_CONNECTION"] = "The connection to the PKC RPC server closed while the publication was in flight. The server stopped the publication, so publish it again";
5561
5563
  messages["ERR_RPC_CLIENT_NO_ACTIVE_PUBLISH_SUBSCRIPTION"] = "Cannot publish challenge answers over PKC RPC: there is no active publish subscription. The challenge exchange has concluded, the publication was stopped, or publish() was never called";
5562
5564
  messages["ERR_GENERIC_RPC_CLIENT_CALL_ERROR"] = "RPC client received an unknown error when executing call over websocket";
5563
5565
  messages["ERR_RPC_CALL_TIMED_OUT"] = "RPC client call timed out without receiving a response from the RPC server";
@@ -5580,6 +5582,8 @@ var messages;
5580
5582
  messages["ERR_CHALLENGE_PUBLIC_OPTION_NOT_DECLARED_IN_OPTION_INPUTS"] = "settings.challenges[i].publicOptions names an option that no optionInputs entry of the challenge declares";
5581
5583
  messages["ERR_CHALLENGE_SETTINGS_VALIDATION_FAILED"] = "The challenge's validateChallengeSettings hook rejected settings.challenges[i]";
5582
5584
  messages["ERR_CHALLENGE_SETTINGS_VALIDATION_FAILED_FOR_CHALLENGES"] = "One or more challenges in settings.challenges failed validation";
5585
+ messages["ERR_CHALLENGE_NOT_REGISTERED"] = "settings.challenges[i].name is not a challenge registered on this node, install its package or remove it from settings.challenges";
5586
+ messages["ERR_COMMUNITY_CHALLENGES_FAILED_TO_LOAD"] = "One or more challenges in settings.challenges could not be loaded, so the community cannot start until they are installed or removed from settings.challenges";
5583
5587
  messages["ERR_FAILED_TO_IMPORT_PAGE_SORT_FILE_FACTORY"] = "Failed to import page sort file factory";
5584
5588
  messages["ERR_PAGE_SORT_FILE_INVALID"] = "The page sort file did not return a valid PageSortFile";
5585
5589
  messages["ERR_PAGE_SORT_DUPLICATE_SORT_NAME"] = "Two entries of settings.pages resolve to the same sortName";
@@ -14797,7 +14801,7 @@ const CommunityEditPublicationPubsubReservedFields = r$2([
14797
14801
  ], t$3(CommunityEditPubsubMessagePublicationSchema.shape));
14798
14802
  //#endregion
14799
14803
  //#region dist/node/generated-version.js
14800
- const version = "0.0.116";
14804
+ const version = "0.0.118";
14801
14805
  //#endregion
14802
14806
  //#region dist/node/version.js
14803
14807
  const protocolVersion = ProtocolVersionSchema.parse("1.0.0");
@@ -1,5 +1,5 @@
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";
1
+ import { Ar as PKCError, _n as PageSortFileFactorySchema, an as ChallengeFileSchema, in as ChallengeFileFactorySchema } from "./util-DEmcezee.js";
2
+ import { s as validatePageSortFile } from "./page-sort-scoring-C1XYRQ1w.js";
3
3
  //#region dist/node/validate-package-factories.js
4
4
  function validateChallengeFileFactory(factory, { name }) {
5
5
  try {
@@ -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-CaeXEQ5O.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-CH9-YjYa.js";
2
2
  export { challenges, createAnchorIpnsRecord, PKC as default, getShortAddress, getShortCid, nativeFunctions, pageSorts, setNativeFunctions };
@@ -1,2 +1,2 @@
1
- import { n as validatePageSortFileFactory } from "./chunks/validate-package-factories-tZC8XxoO.js";
1
+ import { n as validatePageSortFileFactory } from "./chunks/validate-package-factories-C9A4AtCN.js";
2
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-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";
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-DEmcezee.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-CH9-YjYa.js";
3
+ import { $t as require_lib, At as parseVoteChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, E as buildPagesRuntimeFields, H as pRetry, I as extractCrosspostRuntimeFields, St as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, T as buildPageRuntimeFields, Tr as stringify, U as pLimit, _t as parseCreateNewLocalCommunityUserOptionsSchemaWithPKCErrorIfItFails, et as parseCommentChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, it as parseCommentModerationChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, kt as parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, lt as parseCommunityEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, tt as parseCommentEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, ut as parseCommunityEditOptionsSchemaWithPKCErrorIfItFails, vr as t$1, vt as parseCreatePKCWsServerOptionsSchemaWithPKCErrorIfItFails } from "../../chunks/rpc-local-community-DqKbZLIy.js";
4
+ import { t as LocalCommunity } from "../../chunks/local-community-DvEh9Nte.js";
5
5
  import { fileURLToPath } from "node:url";
6
6
  import path from "path";
7
7
  import assert from "assert";
@@ -203,6 +203,7 @@ var PKCWsServer = class extends import_lib.TypedEmitter {
203
203
  this.rpcWebsocketsRegister("getCommentPage", this.getCommentPage.bind(this));
204
204
  this.rpcWebsocketsRegister("createCommunity", this.createCommunity.bind(this));
205
205
  this.rpcWebsocketsRegister("startCommunity", this.startCommunity.bind(this));
206
+ this.rpcWebsocketsRegister("startedCommunitySubscribe", this.startedCommunitySubscribe.bind(this));
206
207
  this.rpcWebsocketsRegister("stopCommunity", this.stopCommunity.bind(this));
207
208
  this.rpcWebsocketsRegister("editCommunity", this.editCommunity.bind(this));
208
209
  this.rpcWebsocketsRegister("deleteCommunity", this.deleteCommunity.bind(this));
@@ -505,7 +506,7 @@ var PKCWsServer = class extends import_lib.TypedEmitter {
505
506
  if (listeners.size === 0) listenersByEvent.delete(event);
506
507
  if (listenersByEvent.size === 0) this._trackedCommunityListeners.delete(community);
507
508
  }
508
- _setupStartedEvents(community, connectionId, subscriptionId) {
509
+ _setupStartedEvents(community, connectionId, subscriptionId, opts) {
509
510
  const sendEvent = (event, result) => this.jsonRpcSendNotification({
510
511
  method: "startCommunity",
511
512
  subscription: subscriptionId,
@@ -522,6 +523,7 @@ var PKCWsServer = class extends import_lib.TypedEmitter {
522
523
  };
523
524
  community.on("update", updateListener);
524
525
  this._trackCommunityListener(community, "update", updateListener);
526
+ if (opts?.sendSnapshot) updateListener();
525
527
  const startedStateListener = () => sendEvent("startedstatechange", { state: community.startedState });
526
528
  community.on("startedstatechange", startedStateListener);
527
529
  this._trackCommunityListener(community, "startedstatechange", startedStateListener);
@@ -583,7 +585,7 @@ var PKCWsServer = class extends import_lib.TypedEmitter {
583
585
  const pkc = await this._getPKCInstance();
584
586
  if (address in this._startedCommunities) {
585
587
  const community = await this.getStartedCommunity(address);
586
- this._setupStartedEvents(community, connectionId, subscriptionId);
588
+ this._setupStartedEvents(community, connectionId, subscriptionId, { sendSnapshot: true });
587
589
  } else try {
588
590
  this._startedCommunities[address] = "pending";
589
591
  const community = await pkc.createCommunity({ address });
@@ -621,6 +623,21 @@ var PKCWsServer = class extends import_lib.TypedEmitter {
621
623
  await startCommunityImpl();
622
624
  return { subscriptionId };
623
625
  }
626
+ async startedCommunitySubscribe(params, connectionId) {
627
+ const { name, publicKey } = parseRpcCommunityIdentifierParam(params[0]);
628
+ await this._getPKCInstance();
629
+ const address = this._findCommunityAddress({
630
+ name,
631
+ publicKey
632
+ });
633
+ if (!address) throw new PKCError("ERR_RPC_CLIENT_ATTEMPTING_TO_START_A_REMOTE_COMMUNITY", { communityAddress: name || publicKey });
634
+ if (!(address in this._startedCommunities) && !this._wasStartedAndNotExplicitlyStopped(address)) throw new PKCError("ERR_RPC_COMMUNITY_NOT_RUNNING", { communityAddress: address });
635
+ return this.startCommunity(params, connectionId);
636
+ }
637
+ _wasStartedAndNotExplicitlyStopped(address) {
638
+ const row = this._getRpcStateDb()?.prepare("SELECT wasStarted, wasExplicitlyStopped FROM community_states WHERE address = ?").get(address);
639
+ return Boolean(row && row.wasStarted === 1 && row.wasExplicitlyStopped === 0);
640
+ }
624
641
  async stopCommunity(params) {
625
642
  const { name, publicKey } = parseRpcCommunityIdentifierParam(params[0]);
626
643
  await this._getPKCInstance();
@@ -23,6 +23,15 @@ export default class PKCRpcClient extends TypedEmitter<PKCRpcClientEvents> {
23
23
  private _pendingSubscriptionMsgs;
24
24
  private _timeoutSeconds;
25
25
  private _callTimeoutMs;
26
+ private _serverIdByLocalId;
27
+ private _localIdByServerId;
28
+ private _resubscribeCalls;
29
+ private _publishSubscriptionIds;
30
+ private _hasConnectedBefore;
31
+ private _socketsWithNotificationHandler;
32
+ private _reconnectBaseIntervalMs;
33
+ private _reconnectMaxIntervalMs;
34
+ private _reconnectIntervalMs;
26
35
  private _openConnectionPromise?;
27
36
  private _destroyRequested;
28
37
  constructor(rpcServerUrl: string);
@@ -33,6 +42,13 @@ export default class PKCRpcClient extends TypedEmitter<PKCRpcClientEvents> {
33
42
  toJSON(): undefined;
34
43
  getSubscription(subscriptionId: number): EventEmitter<[never]>;
35
44
  unsubscribe(subscriptionId: number): Promise<void>;
45
+ private _attachNotificationHandler;
46
+ private _dispatchNotification;
47
+ private _backOffReconnectInterval;
48
+ private _subscribe;
49
+ private _resubscribeAllAfterReconnect;
50
+ private _resubscribe;
51
+ private _failPublicationsLostWithConnection;
36
52
  private _deserializeRpcError;
37
53
  private _setErrorName;
38
54
  private _assignAdditionalProps;