@pkcprotocol/pkc-js 0.0.86 → 0.0.87

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 (43) hide show
  1. package/dist/browser/generated-version.d.ts +1 -1
  2. package/dist/browser/generated-version.js +1 -1
  3. package/dist/browser/pkc/tracked-instance-registry-util.d.ts +3 -4
  4. package/dist/browser/pkc/tracked-instance-registry-util.js +43 -14
  5. package/dist/browser/pkc/tracked-instance-registry-util.js.map +1 -1
  6. package/dist/browser/runtime/node/community/local-community/db-state.js +5 -6
  7. package/dist/browser/runtime/node/community/local-community/db-state.js.map +1 -1
  8. package/dist/browser/runtime/node/community/local-community/editing.js +4 -4
  9. package/dist/browser/runtime/node/community/local-community/editing.js.map +1 -1
  10. package/dist/browser/runtime/node/community/local-community/lifecycle.js +6 -6
  11. package/dist/browser/runtime/node/community/local-community/lifecycle.js.map +1 -1
  12. package/dist/browser/runtime/node/community/local-community/registry.d.ts +14 -1
  13. package/dist/browser/runtime/node/community/local-community/registry.js +37 -0
  14. package/dist/browser/runtime/node/community/local-community/registry.js.map +1 -1
  15. package/dist/browser/runtime/node/util.js +2 -5
  16. package/dist/browser/runtime/node/util.js.map +1 -1
  17. package/dist/bundled/bundle-manifest.json +31 -31
  18. package/dist/bundled/chunks/{helia-for-pkc-yqf2rWMx.js → helia-for-pkc-CjrfyXsA.js} +33 -33
  19. package/dist/bundled/chunks/{local-community-NUwjwbZz.js → local-community-Ba5iR3bD.js} +61 -50
  20. package/dist/bundled/chunks/{local-community-BURzF_1m.js → local-community-DbfQyZow.js} +1 -1
  21. package/dist/bundled/chunks/{node-BbvETZ1u.js → node-gCrky-14.js} +5 -5
  22. package/dist/bundled/chunks/{rpc-local-community-Cpw9_Nuo.js → rpc-local-community-BYd-0Aw4.js} +3 -5
  23. package/dist/bundled/chunks/{schema-BT0023M6.js → schema-0b9XHoqX.js} +25 -15
  24. package/dist/bundled/chunks/{util-BmT_84kq.js → util-CvgcZ9iH.js} +1 -1
  25. package/dist/bundled/index.js +1 -1
  26. package/dist/bundled/rpc/src/index.js +4 -4
  27. package/dist/node/generated-version.d.ts +1 -1
  28. package/dist/node/generated-version.js +1 -1
  29. package/dist/node/pkc/tracked-instance-registry-util.d.ts +3 -4
  30. package/dist/node/pkc/tracked-instance-registry-util.js +43 -14
  31. package/dist/node/pkc/tracked-instance-registry-util.js.map +1 -1
  32. package/dist/node/runtime/node/community/local-community/db-state.js +5 -6
  33. package/dist/node/runtime/node/community/local-community/db-state.js.map +1 -1
  34. package/dist/node/runtime/node/community/local-community/editing.js +4 -4
  35. package/dist/node/runtime/node/community/local-community/editing.js.map +1 -1
  36. package/dist/node/runtime/node/community/local-community/lifecycle.js +6 -6
  37. package/dist/node/runtime/node/community/local-community/lifecycle.js.map +1 -1
  38. package/dist/node/runtime/node/community/local-community/registry.d.ts +14 -1
  39. package/dist/node/runtime/node/community/local-community/registry.js +37 -0
  40. package/dist/node/runtime/node/community/local-community/registry.js.map +1 -1
  41. package/dist/node/runtime/node/util.js +2 -5
  42. package/dist/node/runtime/node/util.js.map +1 -1
  43. package/package.json +5 -5
@@ -1,12 +1,12 @@
1
1
  import { i as __toESM, r as __require, t as __commonJSMin } from "./chunk-2rV9d50f.js";
2
- import { $ as pubsubTopicToDhtKey, $n as n$4, Bn as CommentEditReservedFields, C as contentContainsMarkdownAudio, Ct as findStartedCommunity, F as getIpnsRecordInLocalKuboNode, Fr as ZodError, Ft as untrackStartedCommunity, G as isLinkOfAudio, Hn as CommentEditsTableRowSchema, Ht as CommunityEditPublicationPubsubReservedFields, J as isLinkOfVideo, Jt as CommentModerationReservedFields, K as isLinkOfImage, Kn as AuthorReservedFields, L as hideClassPrivateProps, Lt as untrackUpdatingCommunity, M as genToArray, Mn as CommentsTableRowSchema, Mt as trackStartedCommunity, N as getEquivalentCommunityAddresses, O as derivePublicationFromChallengeRequest, P as getErrorCodeFromMessage, Pt as trackUpdatingCommunity, Q as isStringDomain, R as ipnsNameToIpnsOverPubsubTopic, Rn as CommentEditPubsubMessagePublicationSchema, Rt as require_sha256, S as calculateStringSizeSameAsIpfsAddCidV0, Sn as CommentPubsubMessageReservedFields, Sr as logger_default, St as findCommunityInRegistry, T as contentContainsMarkdownVideos, Tt as findUpdatingCommunity, W as isLinkOfAnimatedImage, Xt as CommentModerationsTableRowSchema, Y as isLinkValid, _t as statMfsPathSafely, a as ChallengeRequestMessageSchema, an as CommunityIpfsSchema, ar as e$1, at as removeMfsFilesSafely, b as areEquivalentCommunityAddresses, br as PKCError, cr as t$4, d as DecryptedChallengeRequestSchema, dr as t$5, dt as retryKuboBlockPutPinAndProvidePubsubTopic, er as t$8, fr as t$3, gn as VotePubsubReservedFields, gt as sleepUntilTimeoutOrAbort, hn as VotePubsubMessagePublicationSchema, ir as e, it as removeBlocksFromKuboNode, jn as CommentUpdateTableRowSchema, jt as syncCommunityRegistryEntry, k as doesDomainAddressHaveCapitalLetter, kn as CommentUpdateSchema, mr as require_retry, nr as t$7, on as CommunitySignedPropertyNames, pt as retryKuboIpfsAddAndProvide, q as isLinkOfMedia, qt as CommentModerationPubsubMessagePublicationSchema, r as ChallengeMessageSchema, rr as t$6, s as ChallengeVerificationMessageSchema, sr as r$1, st as removeNullUndefinedValues, t as ChallengeAnswerMessageSchema, tr as n$3, u as DecryptedChallengeRequestPublicationSchema, vn as VoteTablesRowSchema, w as contentContainsMarkdownImages, x as calculateIpfsCidV0, xn as CommentIpfsSchema, xr as messages, xt as writeKuboFilesWithTimeout, y as version_default, yt as timestamp, zn as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema } from "./schema-BT0023M6.js";
3
- import { $t as getPublicKeyFromPrivateKey, A as deriveDbPosts, At as verifyCommentIpfs, Bt as getAuthorNameFromWire, C as BackupAbortError, Cn as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, Dt as verifyChallengeRequest, E as calculateInlineRepliesBudget, En as parseJsonWithPKCErrorIfFails, F as importSignerIntoKuboNode, Ft as verifyCommunityEdit, G as REPLY_REPLIES_SORT_TYPES, Gt as getCommunityPublicKeyFromWire, It as verifyVote, Jt as encode, K as TIMEFRAMES_TO_SECONDS, Lt as buildRuntimeAuthor, M as getDefaultCommunityDbConfig, Mt as verifyCommentPubsubMessage, Nt as verifyCommentUpdate, O as deleteOldCommunityInWindows, P as getThumbnailPropsOfLink, Pt as verifyCommunity, Qt as getPKCAddressFromPublicKeySync, R as moveCommunityDbToDeletedDirectory, Rt as cleanWireAuthor, S as encryptEd25519AesGcmPublicKeyBuffer, St as signCommunity, T as calculateExpectedSignatureSize, Tt as verifyChallengeAnswer, U as POSTS_SORT_TYPES, W as POST_REPLIES_SORT_TYPES, Wt as getCommunityNameFromWire, Xt as getIpfsKeyFromPrivateKey, Z as iterateOverPageCidsToFindAllCids, Zt as getPKCAddressFromPublicKey, _t as signComment, a as loadChallengeFileFromCommunityChallengeSettings, ar as t$11, b as decryptEd25519AesGcmPublicKeyBuffer, bt as signCommentUpdate, c as LRUCache, d as KeyvBetterSqlite3, dn as parseCommunityEditOptionsSchemaWithPKCErrorIfItFails, dr as STORAGE_KEYS, en as createSchemaRowParser, er as crosspostChainDepthUpTo, fr as require_lodash_merge, ft as cleanUpBeforePublishing, g as SignerWithPublicKeyAddress, gt as signChallengeVerification, i as getCommunityChallengeFromCommunityChallengeSettings, ir as r$2, j as deriveDbReplies, jt as verifyCommentModeration, k as deriveCommentIpfsFromCommentTableRow, kt as verifyCommentEdit, lr as t$10, lt as pLimit, mt as signChallengeMessage, nr as t$9, o as pkcJsChallenges, or as n$6, pn as parseCommunityIpfsSchemaPassthroughWithPKCErrorIfItFails, qt as decode, r as getChallengeVerification, rr as t$12, s as TrackedInstanceRegistry, sr as n$5, t as RpcLocalCommunity, tr as effectiveMaxCrosspostDepth, u as MAX_FILE_SIZE_BYTES_FOR_COMMUNITY_IPFS, ur as stringify, vt as signCommentEdit, w as backupCommunityDb, xt as signCommentUpdateForChallengeVerification, z as resolveDbPostsCidRefs } from "./rpc-local-community-Cpw9_Nuo.js";
2
+ import { $ as pubsubTopicToDhtKey, $n as n$4, Bn as CommentEditReservedFields, C as contentContainsMarkdownAudio, Ct as findStartedCommunity, F as getIpnsRecordInLocalKuboNode, Fr as ZodError, Ft as untrackStartedCommunity, G as isLinkOfAudio, Hn as CommentEditsTableRowSchema, Ht as CommunityEditPublicationPubsubReservedFields, J as isLinkOfVideo, Jt as CommentModerationReservedFields, K as isLinkOfImage, Kn as AuthorReservedFields, L as hideClassPrivateProps, Lt as untrackUpdatingCommunity, M as genToArray, Mn as CommentsTableRowSchema, Mt as trackStartedCommunity, N as getEquivalentCommunityAddresses, O as derivePublicationFromChallengeRequest, P as getErrorCodeFromMessage, Pt as trackUpdatingCommunity, Q as isStringDomain, R as ipnsNameToIpnsOverPubsubTopic, Rn as CommentEditPubsubMessagePublicationSchema, Rt as require_sha256, S as calculateStringSizeSameAsIpfsAddCidV0, Sn as CommentPubsubMessageReservedFields, Sr as logger_default, St as findCommunityInRegistry, T as contentContainsMarkdownVideos, Tt as findUpdatingCommunity, W as isLinkOfAnimatedImage, Xt as CommentModerationsTableRowSchema, Y as isLinkValid, _t as statMfsPathSafely, a as ChallengeRequestMessageSchema, an as CommunityIpfsSchema, ar as e$1, at as removeMfsFilesSafely, b as areEquivalentCommunityAddresses, br as PKCError, cr as t$4, d as DecryptedChallengeRequestSchema, dr as t$5, dt as retryKuboBlockPutPinAndProvidePubsubTopic, er as t$8, fr as t$3, gn as VotePubsubReservedFields, gt as sleepUntilTimeoutOrAbort, hn as VotePubsubMessagePublicationSchema, ir as e, it as removeBlocksFromKuboNode, jn as CommentUpdateTableRowSchema, jt as syncCommunityRegistryEntry, k as doesDomainAddressHaveCapitalLetter, kn as CommentUpdateSchema, mr as require_retry, nr as t$7, on as CommunitySignedPropertyNames, pt as retryKuboIpfsAddAndProvide, q as isLinkOfMedia, qt as CommentModerationPubsubMessagePublicationSchema, r as ChallengeMessageSchema, rr as t$6, s as ChallengeVerificationMessageSchema, sr as r$1, st as removeNullUndefinedValues, t as ChallengeAnswerMessageSchema, tr as n$3, u as DecryptedChallengeRequestPublicationSchema, vn as VoteTablesRowSchema, w as contentContainsMarkdownImages, x as calculateIpfsCidV0, xn as CommentIpfsSchema, xr as messages, xt as writeKuboFilesWithTimeout, y as version_default, yt as timestamp, zn as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema } from "./schema-0b9XHoqX.js";
3
+ import { $t as getPublicKeyFromPrivateKey, A as deriveDbPosts, At as verifyCommentIpfs, Bt as getAuthorNameFromWire, C as BackupAbortError, Cn as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, Dt as verifyChallengeRequest, E as calculateInlineRepliesBudget, En as parseJsonWithPKCErrorIfFails, F as importSignerIntoKuboNode, Ft as verifyCommunityEdit, G as REPLY_REPLIES_SORT_TYPES, Gt as getCommunityPublicKeyFromWire, It as verifyVote, Jt as encode, K as TIMEFRAMES_TO_SECONDS, Lt as buildRuntimeAuthor, M as getDefaultCommunityDbConfig, Mt as verifyCommentPubsubMessage, Nt as verifyCommentUpdate, O as deleteOldCommunityInWindows, P as getThumbnailPropsOfLink, Pt as verifyCommunity, Qt as getPKCAddressFromPublicKeySync, R as moveCommunityDbToDeletedDirectory, Rt as cleanWireAuthor, S as encryptEd25519AesGcmPublicKeyBuffer, St as signCommunity, T as calculateExpectedSignatureSize, Tt as verifyChallengeAnswer, U as POSTS_SORT_TYPES, W as POST_REPLIES_SORT_TYPES, Wt as getCommunityNameFromWire, Xt as getIpfsKeyFromPrivateKey, Z as iterateOverPageCidsToFindAllCids, Zt as getPKCAddressFromPublicKey, _t as signComment, a as loadChallengeFileFromCommunityChallengeSettings, ar as t$11, b as decryptEd25519AesGcmPublicKeyBuffer, bt as signCommentUpdate, c as LRUCache, d as KeyvBetterSqlite3, dn as parseCommunityEditOptionsSchemaWithPKCErrorIfItFails, dr as STORAGE_KEYS, en as createSchemaRowParser, er as crosspostChainDepthUpTo, fr as require_lodash_merge, ft as cleanUpBeforePublishing, g as SignerWithPublicKeyAddress, gt as signChallengeVerification, i as getCommunityChallengeFromCommunityChallengeSettings, ir as r$2, j as deriveDbReplies, jt as verifyCommentModeration, k as deriveCommentIpfsFromCommentTableRow, kt as verifyCommentEdit, lr as t$10, lt as pLimit, mt as signChallengeMessage, nr as t$9, o as pkcJsChallenges, or as n$6, pn as parseCommunityIpfsSchemaPassthroughWithPKCErrorIfItFails, qt as decode, r as getChallengeVerification, rr as t$12, s as TrackedInstanceRegistry, sr as n$5, t as RpcLocalCommunity, tr as effectiveMaxCrosspostDepth, u as MAX_FILE_SIZE_BYTES_FOR_COMMUNITY_IPFS, ur as stringify, vt as signCommentEdit, w as backupCommunityDb, xt as signCommentUpdateForChallengeVerification, z as resolveDbPostsCidRefs } from "./rpc-local-community-BYd-0Aw4.js";
4
4
  import { randomFillSync, randomUUID } from "node:crypto";
5
5
  import { fileURLToPath, pathToFileURL } from "node:url";
6
- import path from "node:path";
6
+ import Path from "node:path";
7
7
  import os from "os";
8
8
  import { existsSync, promises } from "node:fs";
9
- import path$1 from "path";
9
+ import path from "path";
10
10
  import assert from "assert";
11
11
  import fs from "fs";
12
12
  import Database from "better-sqlite3";
@@ -1812,6 +1812,32 @@ async function throwIfChallengeSettingsAreInvalid({ challengeSettings, pkc, comm
1812
1812
  //#endregion
1813
1813
  //#region dist/node/runtime/node/community/local-community/registry.js
1814
1814
  const processStartedCommunities = new TrackedInstanceRegistry();
1815
+ function normalizeRegistryDataPath(dataPath) {
1816
+ if (dataPath === void 0) return void 0;
1817
+ const resolved = path.resolve(dataPath);
1818
+ let existing = resolved;
1819
+ let tail = "";
1820
+ while (true) try {
1821
+ return path.join(fs.realpathSync.native(existing), tail);
1822
+ } catch {
1823
+ const parent = path.dirname(existing);
1824
+ if (parent === existing) return resolved;
1825
+ tail = path.join(path.basename(existing), tail);
1826
+ existing = parent;
1827
+ }
1828
+ }
1829
+ function getLookup(community) {
1830
+ return {
1831
+ publicKey: community.publicKey,
1832
+ name: community.name
1833
+ };
1834
+ }
1835
+ function findProcessStartedCommunity(community) {
1836
+ return findCommunityInRegistry(processStartedCommunities, getLookup(community), normalizeRegistryDataPath(community._pkc.dataPath));
1837
+ }
1838
+ function syncProcessStartedCommunity(community) {
1839
+ syncCommunityRegistryEntry(processStartedCommunities, community, normalizeRegistryDataPath(community._pkc.dataPath));
1840
+ }
1815
1841
  //#endregion
1816
1842
  //#region node_modules/graceful-fs/polyfills.js
1817
1843
  var require_polyfills = /* @__PURE__ */ __commonJSMin(((exports, module) => {
@@ -3552,9 +3578,9 @@ var DbHandler = class {
3552
3578
  if (needToMigrate) {
3553
3579
  if (dbExistsAlready && currentDbVersion > 0) {
3554
3580
  this.destoryConnection();
3555
- backupDbPath = path$1.join(path$1.dirname(dbPath), ".backup_before_migration", `${path$1.basename(dbPath)}.${currentDbVersion}.${timestamp()}`);
3556
- log(`Copying db ${path$1.basename(dbPath)} to ${backupDbPath} before migration`);
3557
- if (!fs.existsSync(path$1.dirname(backupDbPath))) await fs.promises.mkdir(path$1.dirname(backupDbPath), { recursive: true });
3581
+ backupDbPath = path.join(path.dirname(dbPath), ".backup_before_migration", `${path.basename(dbPath)}.${currentDbVersion}.${timestamp()}`);
3582
+ log(`Copying db ${path.basename(dbPath)} to ${backupDbPath} before migration`);
3583
+ if (!fs.existsSync(path.dirname(backupDbPath))) await fs.promises.mkdir(path.dirname(backupDbPath), { recursive: true });
3558
3584
  const sourceDb = new Database(dbPath, { fileMustExist: true });
3559
3585
  await sourceDb.backup(backupDbPath);
3560
3586
  sourceDb.close();
@@ -5372,10 +5398,10 @@ var DbHandler = class {
5372
5398
  if (this._db || this._keyv) await this.destoryConnection();
5373
5399
  this._transactionDepth = 0;
5374
5400
  const dataPath = this._community._pkc.dataPath;
5375
- const oldPathString = path$1.join(dataPath, "communities", oldDbName);
5376
- const newPathString = path$1.join(dataPath, "communities", newDbName);
5377
- await fs.promises.mkdir(path$1.dirname(oldPathString), { recursive: true });
5378
- await fs.promises.mkdir(path$1.dirname(newPathString), { recursive: true });
5401
+ const oldPathString = path.join(dataPath, "communities", oldDbName);
5402
+ const newPathString = path.join(dataPath, "communities", newDbName);
5403
+ await fs.promises.mkdir(path.dirname(oldPathString), { recursive: true });
5404
+ await fs.promises.mkdir(path.dirname(newPathString), { recursive: true });
5379
5405
  try {
5380
5406
  if (!fs.existsSync(oldPathString)) log(`Old DB file ${oldPathString} does not exist. Cannot backup/rename.`);
5381
5407
  else {
@@ -5397,8 +5423,8 @@ var DbHandler = class {
5397
5423
  }
5398
5424
  async lockCommunityStart(communityAddress = this._community.address) {
5399
5425
  const log = logger_default("pkc-js:local-community:db-handler:lock:start");
5400
- const lockfilePath = path$1.join(this._community._pkc.dataPath, "communities", `${communityAddress}.start.lock`);
5401
- const communityDbPath = path$1.join(this._community._pkc.dataPath, "communities", communityAddress);
5426
+ const lockfilePath = path.join(this._community._pkc.dataPath, "communities", `${communityAddress}.start.lock`);
5427
+ const communityDbPath = path.join(this._community._pkc.dataPath, "communities", communityAddress);
5402
5428
  try {
5403
5429
  await import_src.default.lock(communityDbPath, {
5404
5430
  lockfilePath,
@@ -5419,8 +5445,8 @@ var DbHandler = class {
5419
5445
  async unlockCommunityStart(communityAddress = this._community.address) {
5420
5446
  const log = logger_default("pkc-js:local-community:db-handler:unlock:start");
5421
5447
  log.trace(`Attempting to unlock the start of community (${communityAddress})`);
5422
- const lockfilePath = path$1.join(this._community._pkc.dataPath, "communities", `${communityAddress}.start.lock`);
5423
- const communityDbPath = path$1.join(this._community._pkc.dataPath, "communities", communityAddress);
5448
+ const lockfilePath = path.join(this._community._pkc.dataPath, "communities", `${communityAddress}.start.lock`);
5449
+ const communityDbPath = path.join(this._community._pkc.dataPath, "communities", communityAddress);
5424
5450
  if (!fs.existsSync(lockfilePath) || !fs.existsSync(communityDbPath)) return;
5425
5451
  try {
5426
5452
  await import_src.default.unlock(communityDbPath, { lockfilePath });
@@ -5431,8 +5457,8 @@ var DbHandler = class {
5431
5457
  }
5432
5458
  }
5433
5459
  async isCommunityStartLocked(communityAddress = this._community.address) {
5434
- const lockfilePath = path$1.join(this._community._pkc.dataPath, "communities", `${communityAddress}.start.lock`);
5435
- const communityDbPath = path$1.join(this._community._pkc.dataPath, "communities", communityAddress);
5460
+ const lockfilePath = path.join(this._community._pkc.dataPath, "communities", `${communityAddress}.start.lock`);
5461
+ const communityDbPath = path.join(this._community._pkc.dataPath, "communities", communityAddress);
5436
5462
  return await import_src.default.check(communityDbPath, {
5437
5463
  lockfilePath,
5438
5464
  realpath: false,
@@ -5441,8 +5467,8 @@ var DbHandler = class {
5441
5467
  }
5442
5468
  async lockCommunityState() {
5443
5469
  const log = logger_default("pkc-js:local-community:db-handler:lock:lockCommunityState");
5444
- const lockfilePath = path$1.join(this._community._pkc.dataPath, "communities", `${this._community.address}.state.lock`);
5445
- const communityDbPath = path$1.join(this._community._pkc.dataPath, "communities", this._community.address);
5470
+ const lockfilePath = path.join(this._community._pkc.dataPath, "communities", `${this._community.address}.state.lock`);
5471
+ const communityDbPath = path.join(this._community._pkc.dataPath, "communities", this._community.address);
5446
5472
  try {
5447
5473
  await import_src.default.lock(communityDbPath, {
5448
5474
  lockfilePath,
@@ -5459,8 +5485,8 @@ var DbHandler = class {
5459
5485
  }
5460
5486
  async unlockCommunityState() {
5461
5487
  const log = logger_default("pkc-js:local-community:db-handler:lock:unlockCommunityState");
5462
- const lockfilePath = path$1.join(this._community._pkc.dataPath, "communities", `${this._community.address}.state.lock`);
5463
- const communityDbPath = path$1.join(this._community._pkc.dataPath, "communities", this._community.address);
5488
+ const lockfilePath = path.join(this._community._pkc.dataPath, "communities", `${this._community.address}.state.lock`);
5489
+ const communityDbPath = path.join(this._community._pkc.dataPath, "communities", this._community.address);
5464
5490
  if (!fs.existsSync(lockfilePath)) return;
5465
5491
  try {
5466
5492
  await import_src.default.unlock(communityDbPath, { lockfilePath });
@@ -5470,7 +5496,7 @@ var DbHandler = class {
5470
5496
  }
5471
5497
  }
5472
5498
  communityDbExists() {
5473
- const communityDbPath = path$1.join(this._community._pkc.dataPath, "communities", this._community.address);
5499
+ const communityDbPath = path.join(this._community._pkc.dataPath, "communities", this._community.address);
5474
5500
  return fs.existsSync(communityDbPath);
5475
5501
  }
5476
5502
  markCommentsAsPublishedToPostUpdates(commentCids) {
@@ -6081,10 +6107,7 @@ async function updateInstancePropsWithStartedCommunityOrDb(community) {
6081
6107
  const startedCommunity = findStartedCommunity(community._pkc, {
6082
6108
  publicKey: community.publicKey,
6083
6109
  name: community.name
6084
- }) || findCommunityInRegistry(processStartedCommunities, {
6085
- publicKey: community.publicKey,
6086
- name: community.name
6087
- });
6110
+ }) || findProcessStartedCommunity(community);
6088
6111
  if (startedCommunity) {
6089
6112
  log("Loading local community", community.address, "from started community instance");
6090
6113
  if (startedCommunity.updatedAt) await community.initInternalCommunityAfterFirstUpdateNoMerge(startedCommunity.toJSONInternalAfterFirstUpdate());
@@ -6236,7 +6259,7 @@ async function initInternalCommunityAfterFirstUpdateNoMerge(community, newProps)
6236
6259
  if (Array.isArray(newProps._cidsToUnPin)) newProps._cidsToUnPin.forEach((cid) => community._cidsToUnPin.add(cid));
6237
6260
  if (Array.isArray(newProps._mfsPathsToRemove)) newProps._mfsPathsToRemove.forEach((path) => community._mfsPathsToRemove.add(path));
6238
6261
  community._updateIpnsPubsubPropsIfNeeded(newProps);
6239
- if (processStartedCommunities.has(community)) syncCommunityRegistryEntry(processStartedCommunities, community);
6262
+ if (processStartedCommunities.has(community)) syncProcessStartedCommunity(community);
6240
6263
  if (community.updateCid) community.raw.localCommunity = community.toJSONInternalRpcAfterFirstUpdate();
6241
6264
  }
6242
6265
  async function initInternalCommunityBeforeFirstUpdateNoMerge(community, newProps) {
@@ -6258,7 +6281,7 @@ async function initInternalCommunityBeforeFirstUpdateNoMerge(community, newProps
6258
6281
  await initSignerProps(community, newProps.signer);
6259
6282
  community._internalStateUpdateId = newProps._internalStateUpdateId;
6260
6283
  community._updateIpnsPubsubPropsIfNeeded(newProps);
6261
- if (processStartedCommunities.has(community)) syncCommunityRegistryEntry(processStartedCommunities, community);
6284
+ if (processStartedCommunities.has(community)) syncProcessStartedCommunity(community);
6262
6285
  community.raw.localCommunity = community.toJSONInternalRpcBeforeFirstUpdate();
6263
6286
  }
6264
6287
  async function initDbHandlerIfNeeded(community) {
@@ -6745,10 +6768,7 @@ async function start(community) {
6745
6768
  if (community.started || findStartedCommunity(community._pkc, {
6746
6769
  publicKey: community.publicKey,
6747
6770
  name: community.name
6748
- }) || findCommunityInRegistry(processStartedCommunities, {
6749
- publicKey: community.publicKey,
6750
- name: community.name
6751
- })) throw new PKCError("ERR_COMMUNITY_ALREADY_STARTED", { address: community.address });
6771
+ }) || findProcessStartedCommunity(community)) throw new PKCError("ERR_COMMUNITY_ALREADY_STARTED", { address: community.address });
6752
6772
  try {
6753
6773
  await initBeforeStarting(community);
6754
6774
  if (community.anchor && !getPersistedAnchorRecordBytes(community)) throw new PKCError("ERR_DELEGATED_COMMUNITY_HAS_NO_ANCHOR_RECORD", {
@@ -6760,7 +6780,7 @@ async function start(community) {
6760
6780
  await community._updateStartedValue();
6761
6781
  await community._dbHandler.lockCommunityStart();
6762
6782
  trackStartedCommunity(community._pkc, community);
6763
- syncCommunityRegistryEntry(processStartedCommunities, community);
6783
+ syncProcessStartedCommunity(community);
6764
6784
  await community._updateStartedValue();
6765
6785
  await community._dbHandler.initDbIfNeeded();
6766
6786
  await community._dbHandler.createOrMigrateTablesIfNeeded();
@@ -6864,10 +6884,7 @@ async function updateOnce(community) {
6864
6884
  const startedCommunity = findStartedCommunity(community._pkc, {
6865
6885
  publicKey: community.publicKey,
6866
6886
  name: community.name
6867
- }) || findCommunityInRegistry(processStartedCommunities, {
6868
- publicKey: community.publicKey,
6869
- name: community.name
6870
- });
6887
+ }) || findProcessStartedCommunity(community);
6871
6888
  if (community._mirroredStartedOrUpdatingCommunity) return;
6872
6889
  else if (startedCommunity) {
6873
6890
  await initMirroringStartedOrUpdatingCommunity(community, startedCommunity);
@@ -6994,10 +7011,7 @@ async function deleteCommunity(community) {
6994
7011
  const startedCommunity = findStartedCommunity(community._pkc, {
6995
7012
  publicKey: community.publicKey,
6996
7013
  name: community.name
6997
- }) || findCommunityInRegistry(processStartedCommunities, {
6998
- publicKey: community.publicKey,
6999
- name: community.name
7000
- });
7014
+ }) || findProcessStartedCommunity(community);
7001
7015
  if (startedCommunity && startedCommunity !== community) {
7002
7016
  await startedCommunity.delete();
7003
7017
  await community.stop();
@@ -7149,7 +7163,7 @@ async function editPropsOnStartedCommunity(community, parsedEditOptions) {
7149
7163
  community.emit("update", community);
7150
7164
  if (community.address !== oldAddress) {
7151
7165
  trackStartedCommunity(community._pkc, community);
7152
- syncCommunityRegistryEntry(processStartedCommunities, community);
7166
+ syncProcessStartedCommunity(community);
7153
7167
  }
7154
7168
  return community;
7155
7169
  }
@@ -7179,10 +7193,7 @@ async function edit(community, newCommunityOptions) {
7179
7193
  const startedCommunity = findStartedCommunity(community._pkc, {
7180
7194
  publicKey: community.publicKey,
7181
7195
  name: community.name
7182
- }) || findCommunityInRegistry(processStartedCommunities, {
7183
- publicKey: community.publicKey,
7184
- name: community.name
7185
- });
7196
+ }) || findProcessStartedCommunity(community);
7186
7197
  if (startedCommunity && community.state !== "started") {
7187
7198
  const editRes = await startedCommunity.edit(newCommunityOptions);
7188
7199
  community.setAddress(editRes.address);
@@ -7223,11 +7234,11 @@ async function edit(community, newCommunityOptions) {
7223
7234
  const EXPORTS_KEY = STORAGE_KEYS[STORAGE_KEYS.EXPORTS];
7224
7235
  function defaultExportPathFor(community, exportId) {
7225
7236
  if (typeof community._pkc.dataPath !== "string") throw new PKCError("ERR_DATA_PATH_IS_NOT_DEFINED", { communityAddress: community.address });
7226
- return path.join(community._pkc.dataPath, "exports", `${exportId}.sqlite`);
7237
+ return Path.join(community._pkc.dataPath, "exports", `${exportId}.sqlite`);
7227
7238
  }
7228
7239
  function sourceDbPathFor(community) {
7229
7240
  if (typeof community._pkc.dataPath !== "string") throw new PKCError("ERR_DATA_PATH_IS_NOT_DEFINED", { communityAddress: community.address });
7230
- return path.join(community._pkc.dataPath, "communities", community.address);
7241
+ return Path.join(community._pkc.dataPath, "communities", community.address);
7231
7242
  }
7232
7243
  async function persistExports(community) {
7233
7244
  if (!community._dbHandler) return;
@@ -7303,9 +7314,9 @@ async function runExportTask(community, exportId, opts) {
7303
7314
  async function exportCommunityEmbedded(community, options = {}) {
7304
7315
  if (options.signal?.aborted) throw options.signal.reason ?? new DOMException("The operation was aborted.", "AbortError");
7305
7316
  const exportId = v4();
7306
- const destPath = options.exportPath ? path.resolve(options.exportPath) : defaultExportPathFor(community, exportId);
7317
+ const destPath = options.exportPath ? Path.resolve(options.exportPath) : defaultExportPathFor(community, exportId);
7307
7318
  const includePrivateKey = options.includePrivateKey === true;
7308
- if (path.resolve(destPath) === path.resolve(sourceDbPathFor(community))) throw new PKCError("ERR_EXPORT_PATH_TARGETS_LIVE_DB", {
7319
+ if (Path.resolve(destPath) === Path.resolve(sourceDbPathFor(community))) throw new PKCError("ERR_EXPORT_PATH_TARGETS_LIVE_DB", {
7309
7320
  communityAddress: community.address,
7310
7321
  exportPath: destPath
7311
7322
  });
@@ -1,2 +1,2 @@
1
- import { n as createNewLocalCommunityDb, r as updateInstancePropsWithStartedCommunityOrDb, t as LocalCommunity } from "./local-community-NUwjwbZz.js";
1
+ import { n as createNewLocalCommunityDb, r as updateInstancePropsWithStartedCommunityOrDb, t as LocalCommunity } from "./local-community-Ba5iR3bD.js";
2
2
  export { LocalCommunity, createNewLocalCommunityDb, updateInstancePropsWithStartedCommunityOrDb };
@@ -1,7 +1,7 @@
1
1
  import { i as __toESM, r as __require, t as __commonJSMin } from "./chunk-2rV9d50f.js";
2
- import { $n as n$2, B as isIpfsCid, Bt as pTimeout, Ct as findStartedCommunity, D as deepMergeRuntimeFields, Dt as listUpdatingComments, E as createAbortError, En as CommentUpdateForChallengeVerificationSchema, Et as listStartedCommunities, H as isIpns, Ir as joinValues, It as untrackUpdatingComment, L as hideClassPrivateProps, Lr as parsedType, Nt as trackUpdatingComment, Ot as listUpdatingCommunities, Q as isStringDomain, R as ipnsNameToIpnsOverPubsubTopic, Rr as stringifyPrimitive, Rt as require_sha256, Sr as logger_default, Tr as setErrorMap, Tt as findUpdatingCommunity, a as ChallengeRequestMessageSchema, an as CommunityIpfsSchema, ar as e$1, b as areEquivalentCommunityAddresses, br as PKCError, bt as waitForUpdateInCommunityInstanceWithErrorAndTimeout, ct as removeUndefinedValuesRecursively, dn as PubsubTopicSchema, en as CommunityAnchorSchema, ft as retryKuboIpfsAdd, gt as sleepUntilTimeoutOrAbort, hr as FailedToFetchCommentIpfsFromGatewaysError, ht as shortifyCid, ir as e, k as doesDomainAddressHaveCapitalLetter, kn as CommentUpdateSchema, kt as refreshTrackedCommentAliases, lt as replaceXWithY, mr as require_retry, mt as shortifyAddress, nt as rejectWhenAbortSignalFires, r as ChallengeMessageSchema, rr as t$1, rt as rejectWhenCommunityStopsOrAborts, s as ChallengeVerificationMessageSchema, sr as r, t as ChallengeAnswerMessageSchema, tr as n$1, ut as resolveWhenPredicateIsTrue, vt as throwIfAbortSignalAborted, wt as findUpdatingComment, xn as CommentIpfsSchema, xr as messages, y as version_default, yt as timestamp, z as isAbortError, zt as TimeoutError } from "./schema-BT0023M6.js";
3
- import { $ as RepliesPages, $n as RpcUnsubscribeParamSchema, An as parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, At as verifyCommentIpfs, B as setNativeFunctions$1, Bn as RpcEditCommunityParamSchema, Cn as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, Ct as signCommunityEdit, D as createKuboRpcClient, Dn as parsePKCUserOptionsSchemaWithPKCErrorIfItFails, En as parseJsonWithPKCErrorIfFails, Et as verifyChallengeMessage, Fn as RpcCancelExportParamSchema, Ft as verifyCommunityEdit, Gn as RpcFetchCidParamSchema, Gt as getCommunityPublicKeyFromWire, H as CommentClientsManager, Hn as RpcExportCommunityModLogsResultSchema, Ht as buildRuntimeCommunityFields, I as listCommunitiesSync, In as RpcCidParamSchema, It as verifyVote, Jn as RpcPublishChallengeAnswersParamSchema, Kn as RpcFetchCidResultSchema, Kt as normalizeCommunityInputFromCommunity, L as monitorCommunitiesDirectory, Ln as RpcCommentRepliesPageParamSchema, Lt as buildRuntimeAuthor, Mn as parseVotePubsubMessagePublicationSchemaWithPKCErrorIfItFails, Mt as verifyCommentPubsubMessage, N as getDefaultDataPath, Nn as RpcAnchorPublishPreparationResultSchema, Nt as verifyCommentUpdate, On as parseRpcCommentEventWithPKCErrorIfItFails, Ot as verifyChallengeVerification, Pn as RpcAuthorNameParamSchema, Q as parseRawPages, Qn as RpcSuccessResultSchema, Qt as getPKCAddressFromPublicKeySync, Rn as RpcCommunityIdentifierParamSchema, Rt as cleanWireAuthor, Sn as parseCreateVoteOptionsSchemaWithPKCErrorIfItFails, Tn as parseDecryptedChallengeWithPKCErrorIfItFails, Un as RpcExportCommunityParamSchema, Ut as getCommunityAddressFromRecord, V as tryToDeleteCommunitiesThatFailedToBeDeletedBefore, Vn as RpcExportCommunityModLogsParamSchema, Vt as normalizeCreatePublicationAuthor, Wn as RpcExportCommunityResultSchema, Wt as getCommunityNameFromWire, X as findCommentInPageInstanceRecursively, Xn as RpcResolveAuthorNameResultSchema, Y as extractCommunityRuntimeFieldsFromParsedPages, Yn as RpcPublishedAnchorRecordResultSchema, Yt as getBufferedPKCAddressFromPublicKey, Zn as RpcSubscriptionIdResultSchema, _ as createSigner, _n as parseCreateCommunityEditPublicationOptionsSchemaWithPKCErrorIfItFails, _t as signComment, an as parseCommentIpfsSchemaWithPKCErrorIfItFails, ar as t$3, at as PublicationClientsManager, bn as parseCreateRemoteCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, c as LRUCache, cn as parseCommentPubsubMessagePublicationWithPKCErrorIfItFails, cr as t$2, d as KeyvBetterSqlite3, dt as require_lib$1, et as applyNameResolvedCacheToCrosspost, f as decodeRpcChallengeAnswerPubsubMsg, fn as parseCommunityEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, ft as cleanUpBeforePublishing, gn as parseCreateCommentOptionsSchemaWithPKCErrorIfItFails, h as decodeRpcChallengeVerificationPubsubMsg, hn as parseCreateCommentModerationOptionsSchemaWithPKCErrorIfItFails, ht as signChallengeRequest, in as parseCommentEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, it as stripNameResolvedFromCrosspost, jt as verifyCommentModeration, kn as parseRpcCommentUpdateEventWithPKCErrorIfItFails, kt as verifyCommentEdit, l as RemoteCommunity, ln as parseCommunityAddressWithPKCErrorIfItFails, lr as t$5, m as decodeRpcChallengeRequestPubsubMsg, mn as parseCreateCommentEditOptionsSchemaWithPKCErrorIfItFails, mr as require_undici, n as RpcRemoteCommunity, nr as t$4, nt as collectCrosspostAuthorsToResolve, o as pkcJsChallenges, or as n$3, ot as PKCClientsManager, p as decodeRpcChallengePubsubMsg, pr as nativeFunctions$2, pt as signChallengeAnswer, qn as RpcPublishAnchorRecordParamSchema, qt as decode, s as TrackedInstanceRegistry, sn as parseCommentModerationPubsubMessagePublicationSchemaWithPKCErrorIfItFails, st as InflightFetchManager, t as RpcLocalCommunity, tn as parseCidStringSchemaWithPKCErrorIfItFails, tt as cloneCrosspostForRuntime, ut as PKCTypedEmitter, v as createAnchorIpnsRecord$1, vt as signCommentEdit, wn as parseDecryptedChallengeVerification, wt as signVote, x as encryptEd25519AesGcm, xn as parseCreateRpcCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, y as decryptEd25519AesGcm, yt as signCommentModeration, zn as RpcCommunityPageParamSchema, zt as getAuthorNameFromRuntime } from "./rpc-local-community-Cpw9_Nuo.js";
4
- import { o as getHeliaDebugContext } from "./util-BmT_84kq.js";
2
+ import { $n as n$2, B as isIpfsCid, Bt as pTimeout, Ct as findStartedCommunity, D as deepMergeRuntimeFields, Dt as listUpdatingComments, E as createAbortError, En as CommentUpdateForChallengeVerificationSchema, Et as listStartedCommunities, H as isIpns, Ir as joinValues, It as untrackUpdatingComment, L as hideClassPrivateProps, Lr as parsedType, Nt as trackUpdatingComment, Ot as listUpdatingCommunities, Q as isStringDomain, R as ipnsNameToIpnsOverPubsubTopic, Rr as stringifyPrimitive, Rt as require_sha256, Sr as logger_default, Tr as setErrorMap, Tt as findUpdatingCommunity, a as ChallengeRequestMessageSchema, an as CommunityIpfsSchema, ar as e$1, b as areEquivalentCommunityAddresses, br as PKCError, bt as waitForUpdateInCommunityInstanceWithErrorAndTimeout, ct as removeUndefinedValuesRecursively, dn as PubsubTopicSchema, en as CommunityAnchorSchema, ft as retryKuboIpfsAdd, gt as sleepUntilTimeoutOrAbort, hr as FailedToFetchCommentIpfsFromGatewaysError, ht as shortifyCid, ir as e, k as doesDomainAddressHaveCapitalLetter, kn as CommentUpdateSchema, kt as refreshTrackedCommentAliases, lt as replaceXWithY, mr as require_retry, mt as shortifyAddress, nt as rejectWhenAbortSignalFires, r as ChallengeMessageSchema, rr as t$1, rt as rejectWhenCommunityStopsOrAborts, s as ChallengeVerificationMessageSchema, sr as r, t as ChallengeAnswerMessageSchema, tr as n$1, ut as resolveWhenPredicateIsTrue, vt as throwIfAbortSignalAborted, wt as findUpdatingComment, xn as CommentIpfsSchema, xr as messages, y as version_default, yt as timestamp, z as isAbortError, zt as TimeoutError } from "./schema-0b9XHoqX.js";
3
+ import { $ as RepliesPages, $n as RpcUnsubscribeParamSchema, An as parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, At as verifyCommentIpfs, B as setNativeFunctions$1, Bn as RpcEditCommunityParamSchema, Cn as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, Ct as signCommunityEdit, D as createKuboRpcClient, Dn as parsePKCUserOptionsSchemaWithPKCErrorIfItFails, En as parseJsonWithPKCErrorIfFails, Et as verifyChallengeMessage, Fn as RpcCancelExportParamSchema, Ft as verifyCommunityEdit, Gn as RpcFetchCidParamSchema, Gt as getCommunityPublicKeyFromWire, H as CommentClientsManager, Hn as RpcExportCommunityModLogsResultSchema, Ht as buildRuntimeCommunityFields, I as listCommunitiesSync, In as RpcCidParamSchema, It as verifyVote, Jn as RpcPublishChallengeAnswersParamSchema, Kn as RpcFetchCidResultSchema, Kt as normalizeCommunityInputFromCommunity, L as monitorCommunitiesDirectory, Ln as RpcCommentRepliesPageParamSchema, Lt as buildRuntimeAuthor, Mn as parseVotePubsubMessagePublicationSchemaWithPKCErrorIfItFails, Mt as verifyCommentPubsubMessage, N as getDefaultDataPath, Nn as RpcAnchorPublishPreparationResultSchema, Nt as verifyCommentUpdate, On as parseRpcCommentEventWithPKCErrorIfItFails, Ot as verifyChallengeVerification, Pn as RpcAuthorNameParamSchema, Q as parseRawPages, Qn as RpcSuccessResultSchema, Qt as getPKCAddressFromPublicKeySync, Rn as RpcCommunityIdentifierParamSchema, Rt as cleanWireAuthor, Sn as parseCreateVoteOptionsSchemaWithPKCErrorIfItFails, Tn as parseDecryptedChallengeWithPKCErrorIfItFails, Un as RpcExportCommunityParamSchema, Ut as getCommunityAddressFromRecord, V as tryToDeleteCommunitiesThatFailedToBeDeletedBefore, Vn as RpcExportCommunityModLogsParamSchema, Vt as normalizeCreatePublicationAuthor, Wn as RpcExportCommunityResultSchema, Wt as getCommunityNameFromWire, X as findCommentInPageInstanceRecursively, Xn as RpcResolveAuthorNameResultSchema, Y as extractCommunityRuntimeFieldsFromParsedPages, Yn as RpcPublishedAnchorRecordResultSchema, Yt as getBufferedPKCAddressFromPublicKey, Zn as RpcSubscriptionIdResultSchema, _ as createSigner, _n as parseCreateCommunityEditPublicationOptionsSchemaWithPKCErrorIfItFails, _t as signComment, an as parseCommentIpfsSchemaWithPKCErrorIfItFails, ar as t$3, at as PublicationClientsManager, bn as parseCreateRemoteCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, c as LRUCache, cn as parseCommentPubsubMessagePublicationWithPKCErrorIfItFails, cr as t$2, d as KeyvBetterSqlite3, dt as require_lib$1, et as applyNameResolvedCacheToCrosspost, f as decodeRpcChallengeAnswerPubsubMsg, fn as parseCommunityEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, ft as cleanUpBeforePublishing, gn as parseCreateCommentOptionsSchemaWithPKCErrorIfItFails, h as decodeRpcChallengeVerificationPubsubMsg, hn as parseCreateCommentModerationOptionsSchemaWithPKCErrorIfItFails, ht as signChallengeRequest, in as parseCommentEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, it as stripNameResolvedFromCrosspost, jt as verifyCommentModeration, kn as parseRpcCommentUpdateEventWithPKCErrorIfItFails, kt as verifyCommentEdit, l as RemoteCommunity, ln as parseCommunityAddressWithPKCErrorIfItFails, lr as t$5, m as decodeRpcChallengeRequestPubsubMsg, mn as parseCreateCommentEditOptionsSchemaWithPKCErrorIfItFails, mr as require_undici, n as RpcRemoteCommunity, nr as t$4, nt as collectCrosspostAuthorsToResolve, o as pkcJsChallenges, or as n$3, ot as PKCClientsManager, p as decodeRpcChallengePubsubMsg, pr as nativeFunctions$2, pt as signChallengeAnswer, qn as RpcPublishAnchorRecordParamSchema, qt as decode, s as TrackedInstanceRegistry, sn as parseCommentModerationPubsubMessagePublicationSchemaWithPKCErrorIfItFails, st as InflightFetchManager, t as RpcLocalCommunity, tn as parseCidStringSchemaWithPKCErrorIfItFails, tt as cloneCrosspostForRuntime, ut as PKCTypedEmitter, v as createAnchorIpnsRecord$1, vt as signCommentEdit, wn as parseDecryptedChallengeVerification, wt as signVote, x as encryptEd25519AesGcm, xn as parseCreateRpcCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, y as decryptEd25519AesGcm, yt as signCommentModeration, zn as RpcCommunityPageParamSchema, zt as getAuthorNameFromRuntime } from "./rpc-local-community-BYd-0Aw4.js";
4
+ import { o as getHeliaDebugContext } from "./util-CvgcZ9iH.js";
5
5
  import path from "path";
6
6
  import assert from "assert";
7
7
  import fs from "fs";
@@ -6948,7 +6948,7 @@ var PKC$1 = class extends PKCTypedEmitter {
6948
6948
  this.clients.libp2pJsClients = {};
6949
6949
  if (!this.libp2pJsClientsOptions) return;
6950
6950
  if (!this.httpRoutersOptions) throw Error("httpRoutersOptions is required for libp2pJsClient");
6951
- const { createLibp2pJsClientOrUseExistingOne } = await import("./helia-for-pkc-yqf2rWMx.js");
6951
+ const { createLibp2pJsClientOrUseExistingOne } = await import("./helia-for-pkc-CjrfyXsA.js");
6952
6952
  for (const clientOptions of this.libp2pJsClientsOptions) {
6953
6953
  const heliaNode = await createLibp2pJsClientOrUseExistingOne({
6954
6954
  ...clientOptions,
@@ -7227,7 +7227,7 @@ var PKC$1 = class extends PKCTypedEmitter {
7227
7227
  const log = logger_default("pkc-js:pkc:createLocalCommunity");
7228
7228
  log.trace("Received community options to create a local community instance:", options);
7229
7229
  if (!this._canCreateNewLocalCommunity()) throw new PKCError("ERR_CAN_NOT_CREATE_A_LOCAL_COMMUNITY", { pkcOptions: this._userPKCOptions });
7230
- const { LocalCommunity, createNewLocalCommunityDb, updateInstancePropsWithStartedCommunityOrDb } = await import("./local-community-BURzF_1m.js");
7230
+ const { LocalCommunity, createNewLocalCommunityDb, updateInstancePropsWithStartedCommunityOrDb } = await import("./local-community-DbfQyZow.js");
7231
7231
  const isLocalCommunity = (await listCommunitiesSync(this)).includes(options.address);
7232
7232
  const community = new LocalCommunity(this);
7233
7233
  if (isLocalCommunity) {
@@ -1,11 +1,11 @@
1
1
  import { i as __toESM, n as __exportAll, r as __require, t as __commonJSMin } from "./chunk-2rV9d50f.js";
2
- import { $ as pubsubTopicToDhtKey, $n as n$10, $t as ChallengeFileSchema, A as extractNetworkErrorDetails, An as CommentUpdateSignedPropertyNames, Ar as literal, At as refreshTrackedCommunityAliases, B as isIpfsCid, Bt as pTimeout, Cn as CommentPubsubMessageWithFlexibleAuthorRefinementSchema, Cr as require_supports_color, Ct as findStartedCommunity, D as deepMergeRuntimeFields, Dn as CommentUpdateForChallengeVerificationSignedPropertyNames, Dr as array, E as createAbortError, Er as _enum, Et as listStartedCommunities, Fn as ModQueuePageIpfsSchema, Ft as untrackStartedCommunity, Gn as AuthorCommentIpfsReservedFields, Gt as CreateCommunityEditPublicationOptionsWithRefinementSchema, H as isIpns, I as getPostUpdateTimestampRange, In as PageIpfsSchema, It as untrackUpdatingComment, Jn as CidPathSchema, Kt as CommentModerationChallengeRequestToEncryptSchema, L as hideClassPrivateProps, Ln as CommentEditChallengeRequestToEncryptSchema, Lt as untrackUpdatingCommunity, Mr as object, Mt as trackStartedCommunity, Nn as CreateCommentOptionsWithRefinementSchema, Nr as record, O as derivePublicationFromChallengeRequest, On as CommentUpdateReservedFields, Or as boolean, Ot as listUpdatingCommunities, Pn as GetPageParamSchema, Pr as string, Pt as trackUpdatingCommunity, Q as isStringDomain, Qn as CreateSignerSchema, Qt as ChallengeFileFactorySchema, R as ipnsNameToIpnsOverPubsubTopic, Rt as require_sha256$1, Sr as logger_default, Tn as CommentUpdateChallengeReservedFieldNames, Tt as findUpdatingCommunity, U as isIpnsPath, Un as CreateCommentEditOptionsWithRefinementSchema, Ut as CommunityEditPublicationSignedPropertyNames, V as isIpfsPath, Vn as CommentEditSignedPropertyNames, Vt as CommunityEditPublicationChallengeRequestToEncryptSchema, Wn as AuthorAddressSchema, Wt as CommunityEditPubsubMessagePublicationSchema, X as isRequestPubsubPublicationOfPost, Xn as CommunityAddressSchema, Xt as CommentModerationsTableRowSchema, Yn as CidStringSchema, Yt as CommentModerationSignedPropertyNames, Z as isRequestPubsubPublicationOfReply, Zn as CommunityAuthorChallengeReservedFieldNames, Zt as CreateCommentModerationOptionsWithRefinementSchema, _ as PKCUserOptionBaseSchema, _n as VoteSignedPropertyNames, _r as FailedToFetchCommunityFromGatewaysError, an as CommunityIpfsSchema, ar as e$5, b as areEquivalentCommunityAddresses, bn as CommentIpfsReservedFields, br as PKCError, bt as waitForUpdateInCommunityInstanceWithErrorAndTimeout, c as ChallengeVerificationMessageSignedPropertyNames, cn as CreateRemoteCommunityFunctionArgumentSchema, cr as t$12, dr as t$10, f as DecryptedChallengeSchema, fn as RpcRemoteCommunityUpdateEventResultSchema, fr as t$9, g as PKCParsedOptionsSchema, gr as FailedToFetchCommentUpdateFromGatewaysError, gt as sleepUntilTimeoutOrAbort, h as NameResolverSerializedSchema, hn as VotePubsubMessagePublicationSchema, hr as FailedToFetchCommentIpfsFromGatewaysError, ht as shortifyCid, i as ChallengeMessageSignedPropertyNames, in as CommunityIpfsReservedFields, ir as e$6, j as fetchAndValidateIpnsRecordFromGateway, jr as number, k as doesDomainAddressHaveCapitalLetter, kn as CommentUpdateSchema, kr as custom, l as DecryptedChallengeAnswerSchema, ln as CreateRpcCommunityFunctionArgumentSchema, lr as n$8, m as NameResolveCacheOptionsSchema, mn as VoteChallengeRequestToEncryptSchema, mr as require_retry$1, mt as shortifyAddress, n as ChallengeAnswerMessageSignedPropertyNames, nn as CommunityEditOptionsSchema, o as ChallengeRequestMessageSignedPropertyNames, on as CommunitySignedPropertyNames, or as t$11, ot as removeNullUndefinedEmptyObjectsValuesRecursively, p as DecryptedChallengeVerificationSchema, pn as CreateVoteUserOptionsWithRefinementSchema, pr as e$4, qn as ChallengeAnswersSchema, qt as CommentModerationPubsubMessagePublicationSchema, rn as CommunityExportRecordsSchema, rr as t$13, sn as CreateNewLocalCommunityUserOptionsSchema, sr as r$8, tn as CommunityChallengeSettingSchema, tr as n$9, tt as raceAgainstAbort, un as ExportCommunityModLogsOptionsSchema, ur as r$7, ut as resolveWhenPredicateIsTrue, v as PKCUserOptionsSchema, vr as FailedToFetchGenericIpfsFromGatewaysError, vt as throwIfAbortSignalAborted, wn as CommentSignedPropertyNames, wr as require_ms$1, wt as findUpdatingComment, x as calculateIpfsCidV0, xn as CommentIpfsSchema, xr as messages, yn as CommentChallengeRequestToEncryptSchema, yr as FailedToFetchPageIpfsFromGatewaysError, yt as timestamp, z as isAbortError, zn as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema } from "./schema-BT0023M6.js";
2
+ import { $ as pubsubTopicToDhtKey, $n as n$10, $t as ChallengeFileSchema, A as extractNetworkErrorDetails, An as CommentUpdateSignedPropertyNames, Ar as literal, At as refreshTrackedCommunityAliases, B as isIpfsCid, Bt as pTimeout, Cn as CommentPubsubMessageWithFlexibleAuthorRefinementSchema, Cr as require_supports_color, Ct as findStartedCommunity, D as deepMergeRuntimeFields, Dn as CommentUpdateForChallengeVerificationSignedPropertyNames, Dr as array, E as createAbortError, Er as _enum, Et as listStartedCommunities, Fn as ModQueuePageIpfsSchema, Ft as untrackStartedCommunity, Gn as AuthorCommentIpfsReservedFields, Gt as CreateCommunityEditPublicationOptionsWithRefinementSchema, H as isIpns, I as getPostUpdateTimestampRange, In as PageIpfsSchema, It as untrackUpdatingComment, Jn as CidPathSchema, Kt as CommentModerationChallengeRequestToEncryptSchema, L as hideClassPrivateProps, Ln as CommentEditChallengeRequestToEncryptSchema, Lt as untrackUpdatingCommunity, Mr as object, Mt as trackStartedCommunity, Nn as CreateCommentOptionsWithRefinementSchema, Nr as record, O as derivePublicationFromChallengeRequest, On as CommentUpdateReservedFields, Or as boolean, Ot as listUpdatingCommunities, Pn as GetPageParamSchema, Pr as string, Pt as trackUpdatingCommunity, Q as isStringDomain, Qn as CreateSignerSchema, Qt as ChallengeFileFactorySchema, R as ipnsNameToIpnsOverPubsubTopic, Rt as require_sha256$1, Sr as logger_default, Tn as CommentUpdateChallengeReservedFieldNames, Tt as findUpdatingCommunity, U as isIpnsPath, Un as CreateCommentEditOptionsWithRefinementSchema, Ut as CommunityEditPublicationSignedPropertyNames, V as isIpfsPath, Vn as CommentEditSignedPropertyNames, Vt as CommunityEditPublicationChallengeRequestToEncryptSchema, Wn as AuthorAddressSchema, Wt as CommunityEditPubsubMessagePublicationSchema, X as isRequestPubsubPublicationOfPost, Xn as CommunityAddressSchema, Xt as CommentModerationsTableRowSchema, Yn as CidStringSchema, Yt as CommentModerationSignedPropertyNames, Z as isRequestPubsubPublicationOfReply, Zn as CommunityAuthorChallengeReservedFieldNames, Zt as CreateCommentModerationOptionsWithRefinementSchema, _ as PKCUserOptionBaseSchema, _n as VoteSignedPropertyNames, _r as FailedToFetchCommunityFromGatewaysError, an as CommunityIpfsSchema, ar as e$5, b as areEquivalentCommunityAddresses, bn as CommentIpfsReservedFields, br as PKCError, bt as waitForUpdateInCommunityInstanceWithErrorAndTimeout, c as ChallengeVerificationMessageSignedPropertyNames, cn as CreateRemoteCommunityFunctionArgumentSchema, cr as t$12, dr as t$10, f as DecryptedChallengeSchema, fn as RpcRemoteCommunityUpdateEventResultSchema, fr as t$9, g as PKCParsedOptionsSchema, gr as FailedToFetchCommentUpdateFromGatewaysError, gt as sleepUntilTimeoutOrAbort, h as NameResolverSerializedSchema, hn as VotePubsubMessagePublicationSchema, hr as FailedToFetchCommentIpfsFromGatewaysError, ht as shortifyCid, i as ChallengeMessageSignedPropertyNames, in as CommunityIpfsReservedFields, ir as e$6, j as fetchAndValidateIpnsRecordFromGateway, jr as number, k as doesDomainAddressHaveCapitalLetter, kn as CommentUpdateSchema, kr as custom, l as DecryptedChallengeAnswerSchema, ln as CreateRpcCommunityFunctionArgumentSchema, lr as n$8, m as NameResolveCacheOptionsSchema, mn as VoteChallengeRequestToEncryptSchema, mr as require_retry$1, mt as shortifyAddress, n as ChallengeAnswerMessageSignedPropertyNames, nn as CommunityEditOptionsSchema, o as ChallengeRequestMessageSignedPropertyNames, on as CommunitySignedPropertyNames, or as t$11, ot as removeNullUndefinedEmptyObjectsValuesRecursively, p as DecryptedChallengeVerificationSchema, pn as CreateVoteUserOptionsWithRefinementSchema, pr as e$4, qn as ChallengeAnswersSchema, qt as CommentModerationPubsubMessagePublicationSchema, rn as CommunityExportRecordsSchema, rr as t$13, sn as CreateNewLocalCommunityUserOptionsSchema, sr as r$8, tn as CommunityChallengeSettingSchema, tr as n$9, tt as raceAgainstAbort, un as ExportCommunityModLogsOptionsSchema, ur as r$7, ut as resolveWhenPredicateIsTrue, v as PKCUserOptionsSchema, vr as FailedToFetchGenericIpfsFromGatewaysError, vt as throwIfAbortSignalAborted, wn as CommentSignedPropertyNames, wr as require_ms$1, wt as findUpdatingComment, x as calculateIpfsCidV0, xn as CommentIpfsSchema, xr as messages, yn as CommentChallengeRequestToEncryptSchema, yr as FailedToFetchPageIpfsFromGatewaysError, yt as timestamp, z as isAbortError, zn as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema } from "./schema-0b9XHoqX.js";
3
3
  import { t as all } from "./src-CYIMjhjK.js";
4
4
  import { createHash } from "node:crypto";
5
5
  import { pathToFileURL } from "node:url";
6
6
  import dns from "node:dns";
7
7
  import os from "os";
8
- import { closeSync, createReadStream, existsSync, openSync, promises, readSync, readdirSync, rm, watch } from "node:fs";
8
+ import { closeSync, createReadStream, existsSync, openSync, promises, readSync, readdirSync, watch } from "node:fs";
9
9
  import path from "path";
10
10
  import assert from "assert";
11
11
  import { Agent } from "https";
@@ -102212,9 +102212,7 @@ async function moveCommunityDbToDeletedDirectory(communityAddress, pkc) {
102212
102212
  await sourceDb.backup(newPath);
102213
102213
  sourceDb.close();
102214
102214
  if (os.type() === "Windows_NT") await deleteOldCommunityInWindows(oldPath, pkc);
102215
- else rm(oldPath, (err) => {
102216
- if (err) throw err;
102217
- });
102215
+ else await promises.rm(oldPath, { force: true });
102218
102216
  } catch (error) {
102219
102217
  error.details = {
102220
102218
  ...error.details,
@@ -15245,51 +15245,61 @@ function getEquivalentCommunityAliases(address) {
15245
15245
  function dedupeAliases(aliases) {
15246
15246
  return [...new Set(aliases.filter((alias) => typeof alias === "string" && alias.length > 0))];
15247
15247
  }
15248
- function getTrackedAliasHistory(target) {
15248
+ function getTrackedAliasHistory(target, registry) {
15249
15249
  const holder = target;
15250
15250
  if (!holder[trackedAliasHistorySymbol]) Object.defineProperty(holder, trackedAliasHistorySymbol, {
15251
- value: /* @__PURE__ */ new Set(),
15251
+ value: /* @__PURE__ */ new WeakMap(),
15252
15252
  enumerable: false,
15253
15253
  configurable: false,
15254
15254
  writable: false
15255
15255
  });
15256
- return holder[trackedAliasHistorySymbol];
15256
+ const histories = holder[trackedAliasHistorySymbol];
15257
+ let history = histories.get(registry);
15258
+ if (!history) {
15259
+ history = /* @__PURE__ */ new Set();
15260
+ histories.set(registry, history);
15261
+ }
15262
+ return history;
15257
15263
  }
15258
- function persistAliases(target, aliases) {
15259
- const aliasHistory = getTrackedAliasHistory(target);
15264
+ function persistAliases(target, registry, aliases) {
15265
+ const aliasHistory = getTrackedAliasHistory(target, registry);
15260
15266
  aliases.forEach((alias) => aliasHistory.add(alias));
15261
15267
  return [...aliasHistory];
15262
15268
  }
15263
- function getCommunityRegistryAliases(community) {
15269
+ const REGISTRY_SCOPE_SEPARATOR = "\0";
15270
+ function scopeAliasesToDataPath(aliases, dataPath) {
15271
+ if (dataPath === void 0) return aliases;
15272
+ return aliases.map((alias) => `${dataPath}${REGISTRY_SCOPE_SEPARATOR}${alias}`);
15273
+ }
15274
+ function getCommunityRegistryAliases(community, dataPath) {
15264
15275
  const aliases = dedupeAliases([
15265
- community.address,
15266
15276
  community.name,
15267
15277
  community.publicKey,
15268
15278
  community.signer?.address
15269
15279
  ]);
15270
15280
  if (aliases.length === 0) throw new PKCError("ERR_COMMUNITY_REGISTRY_LOOKUP_HAS_NO_ALIASES", { community });
15271
- return dedupeAliases(aliases.flatMap((alias) => {
15281
+ return scopeAliasesToDataPath(dedupeAliases(aliases.flatMap((alias) => {
15272
15282
  if (isEthAliasDomain$1(alias)) return getEquivalentCommunityAliases(alias);
15273
15283
  return [alias];
15274
- }));
15284
+ })), dataPath);
15275
15285
  }
15276
15286
  function getCommentRegistryAliases(comment) {
15277
15287
  return dedupeAliases([comment.cid]);
15278
15288
  }
15279
- function syncCommunityRegistryEntry(registry, community) {
15289
+ function syncCommunityRegistryEntry(registry, community, dataPath) {
15280
15290
  return registry.track({
15281
15291
  value: community,
15282
- aliases: persistAliases(community, getCommunityRegistryAliases(community))
15292
+ aliases: scopeAliasesToDataPath(persistAliases(community, registry, getCommunityRegistryAliases(community)), dataPath)
15283
15293
  });
15284
15294
  }
15285
15295
  function syncCommentRegistryEntry(registry, comment) {
15286
15296
  return registry.track({
15287
15297
  value: comment,
15288
- aliases: persistAliases(comment, getCommentRegistryAliases(comment))
15298
+ aliases: persistAliases(comment, registry, getCommentRegistryAliases(comment))
15289
15299
  });
15290
15300
  }
15291
- function findCommunityInRegistry(registry, lookup) {
15292
- return registry.findByAliases(getCommunityRegistryAliases(lookup));
15301
+ function findCommunityInRegistry(registry, lookup, dataPath) {
15302
+ return registry.findByAliases(getCommunityRegistryAliases(lookup, dataPath));
15293
15303
  }
15294
15304
  function findCommentInRegistry(registry, lookup) {
15295
15305
  return registry.findByAliases(getCommentRegistryAliases(lookup));
@@ -16195,7 +16205,7 @@ function extractNetworkErrorDetails(err, depth = 0) {
16195
16205
  }
16196
16206
  //#endregion
16197
16207
  //#region dist/node/generated-version.js
16198
- const version = "0.0.86";
16208
+ const version = "0.0.87";
16199
16209
  //#endregion
16200
16210
  //#region dist/node/version.js
16201
16211
  const protocolVersion = ProtocolVersionSchema.parse("1.0.0");
@@ -1,4 +1,4 @@
1
- import { br as PKCError, et as pubsubTopicToDhtKeyCid } from "./schema-BT0023M6.js";
1
+ import { br as PKCError, et as pubsubTopicToDhtKeyCid } from "./schema-0b9XHoqX.js";
2
2
  import { ipnsSelector } from "ipns/selector";
3
3
  import { equals } from "uint8arrays/equals";
4
4
  //#region dist/node/helia/util.js
@@ -1,2 +1,2 @@
1
- import { a as getShortCid, i as getShortAddress, n as challenges, o as nativeFunctions, r as createAnchorIpnsRecord, s as setNativeFunctions, t as PKC } from "./chunks/node-BbvETZ1u.js";
1
+ import { a as getShortCid, i as getShortAddress, n as challenges, o as nativeFunctions, r as createAnchorIpnsRecord, s as setNativeFunctions, t as PKC } from "./chunks/node-gCrky-14.js";
2
2
  export { challenges, createAnchorIpnsRecord, PKC as default, getShortAddress, getShortCid, nativeFunctions, setNativeFunctions };
@@ -1,7 +1,7 @@
1
- import { Ct as findStartedCommunity, L as hideClassPrivateProps, Sr as logger_default, br as PKCError, lt as replaceXWithY, rr as t, tr as n } from "../../chunks/schema-BT0023M6.js";
2
- import { _ as parseRpcPublishAnchorRecordParam, c as parseRpcAuthorNameParam, d as parseRpcCommentRepliesPageParam, f as parseRpcCommunityIdentifierParam, g as parseRpcExportCommunityParam, h as parseRpcExportCommunityModLogsParam, l as parseRpcCancelExportParam, m as parseRpcEditCommunityParam, p as parseRpcCommunityPageParam, t as PKC, u as parseRpcCidParam, v as parseRpcPublishChallengeAnswersParam, y as parseRpcUnsubscribeParam } from "../../chunks/node-BbvETZ1u.js";
3
- import { An as parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, Cn as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, J as buildPagesRuntimeFields, ct as pRetry, dn as parseCommunityEditOptionsSchemaWithPKCErrorIfItFails, dt as require_lib, jn as parseVoteChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, lt as pLimit, nn as parseCommentChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, on as parseCommentModerationChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, q as buildPageRuntimeFields, rn as parseCommentEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, rr as t$1, rt as extractCrosspostRuntimeFields, un as parseCommunityEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, ur as stringify, vn as parseCreateNewLocalCommunityUserOptionsSchemaWithPKCErrorIfItFails, yn as parseCreatePKCWsServerOptionsSchemaWithPKCErrorIfItFails } from "../../chunks/rpc-local-community-Cpw9_Nuo.js";
4
- import { t as LocalCommunity } from "../../chunks/local-community-NUwjwbZz.js";
1
+ import { Ct as findStartedCommunity, L as hideClassPrivateProps, Sr as logger_default, br as PKCError, lt as replaceXWithY, rr as t, tr as n } from "../../chunks/schema-0b9XHoqX.js";
2
+ import { _ as parseRpcPublishAnchorRecordParam, c as parseRpcAuthorNameParam, d as parseRpcCommentRepliesPageParam, f as parseRpcCommunityIdentifierParam, g as parseRpcExportCommunityParam, h as parseRpcExportCommunityModLogsParam, l as parseRpcCancelExportParam, m as parseRpcEditCommunityParam, p as parseRpcCommunityPageParam, t as PKC, u as parseRpcCidParam, v as parseRpcPublishChallengeAnswersParam, y as parseRpcUnsubscribeParam } from "../../chunks/node-gCrky-14.js";
3
+ import { An as parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, Cn as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, J as buildPagesRuntimeFields, ct as pRetry, dn as parseCommunityEditOptionsSchemaWithPKCErrorIfItFails, dt as require_lib, jn as parseVoteChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, lt as pLimit, nn as parseCommentChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, on as parseCommentModerationChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, q as buildPageRuntimeFields, rn as parseCommentEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, rr as t$1, rt as extractCrosspostRuntimeFields, un as parseCommunityEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, ur as stringify, vn as parseCreateNewLocalCommunityUserOptionsSchemaWithPKCErrorIfItFails, yn as parseCreatePKCWsServerOptionsSchemaWithPKCErrorIfItFails } from "../../chunks/rpc-local-community-BYd-0Aw4.js";
4
+ import { t as LocalCommunity } from "../../chunks/local-community-Ba5iR3bD.js";
5
5
  import { fileURLToPath } from "node:url";
6
6
  import path from "path";
7
7
  import assert from "assert";
@@ -1 +1 @@
1
- export declare const version = "0.0.86";
1
+ export declare const version = "0.0.87";
@@ -1,3 +1,3 @@
1
1
  // Auto-generated by config/generate-version.js — do not edit
2
- export const version = "0.0.86";
2
+ export const version = "0.0.87";
3
3
  //# sourceMappingURL=generated-version.js.map
@@ -12,7 +12,6 @@ type CommunityLookup = {
12
12
  publicKey?: string;
13
13
  };
14
14
  type CommunityWithAliases = {
15
- address?: string;
16
15
  name?: string;
17
16
  publicKey?: string;
18
17
  signer?: {
@@ -22,11 +21,11 @@ type CommunityWithAliases = {
22
21
  type CommentLookup = {
23
22
  cid?: string;
24
23
  };
25
- export declare function getCommunityRegistryAliases(community: CommunityWithAliases): string[];
24
+ export declare function getCommunityRegistryAliases(community: CommunityWithAliases, dataPath?: string): string[];
26
25
  export declare function getCommentRegistryAliases(comment: CommentLookup): string[];
27
- export declare function syncCommunityRegistryEntry<T extends CommunityWithAliases>(registry: TrackedInstanceRegistry<T>, community: T): T;
26
+ export declare function syncCommunityRegistryEntry<T extends CommunityWithAliases>(registry: TrackedInstanceRegistry<T>, community: T, dataPath?: string): T;
28
27
  export declare function syncCommentRegistryEntry<T extends CommentLookup>(registry: TrackedInstanceRegistry<T>, comment: T): T;
29
- export declare function findCommunityInRegistry<T extends CommunityWithAliases>(registry: TrackedInstanceRegistry<T>, lookup: CommunityLookup): T | undefined;
28
+ export declare function findCommunityInRegistry<T extends CommunityWithAliases>(registry: TrackedInstanceRegistry<T>, lookup: CommunityLookup, dataPath?: string): T | undefined;
30
29
  export declare function findCommentInRegistry<T extends CommentLookup>(registry: TrackedInstanceRegistry<T>, lookup: CommentLookup): T | undefined;
31
30
  export declare function listRegistryValues<T extends object>(registry: TrackedInstanceRegistry<T>): T[];
32
31
  export declare function trackUpdatingCommunity(pkc: PKC, community: TrackedCommunity): TrackedCommunity;
@@ -15,44 +15,73 @@ function getEquivalentCommunityAliases(address) {
15
15
  function dedupeAliases(aliases) {
16
16
  return [...new Set(aliases.filter((alias) => typeof alias === "string" && alias.length > 0))];
17
17
  }
18
- function getTrackedAliasHistory(target) {
18
+ function getTrackedAliasHistory(target, registry) {
19
19
  const holder = target;
20
20
  if (!holder[trackedAliasHistorySymbol]) {
21
21
  Object.defineProperty(holder, trackedAliasHistorySymbol, {
22
- value: new Set(),
22
+ value: new WeakMap(),
23
23
  enumerable: false,
24
24
  configurable: false,
25
25
  writable: false
26
26
  });
27
27
  }
28
- return holder[trackedAliasHistorySymbol];
28
+ const histories = holder[trackedAliasHistorySymbol];
29
+ let history = histories.get(registry);
30
+ if (!history) {
31
+ history = new Set();
32
+ histories.set(registry, history);
33
+ }
34
+ return history;
29
35
  }
30
- function persistAliases(target, aliases) {
31
- const aliasHistory = getTrackedAliasHistory(target);
36
+ function persistAliases(target, registry, aliases) {
37
+ const aliasHistory = getTrackedAliasHistory(target, registry);
32
38
  aliases.forEach((alias) => aliasHistory.add(alias));
33
39
  return [...aliasHistory];
34
40
  }
35
- export function getCommunityRegistryAliases(community) {
36
- const aliases = dedupeAliases([community.address, community.name, community.publicKey, community.signer?.address]);
41
+ // Aliases are scoped to the dataPath they belong to when one is given. processStartedCommunities is
42
+ // a module-level registry shared by every PKC instance in the process, and the registry matches on
43
+ // ANY alias, so without a scope two LocalCommunity instances backed by different dataPaths but
44
+ // sharing an address resolve to each other: one then adopts the other's posts/updateCid through a
45
+ // signer it does not hold, and every publish after that fails signature validation (issue #238).
46
+ // The scope is a prefix rather than an extra alias on purpose — a bare dataPath alias would instead
47
+ // make every community *within* one dataPath collide.
48
+ // A registry that is already scoped by construction (the per-PKC pkc._updatingCommunities and
49
+ // pkc._startedCommunities) passes no dataPath and is left unprefixed.
50
+ const REGISTRY_SCOPE_SEPARATOR = "\u0000";
51
+ function scopeAliasesToDataPath(aliases, dataPath) {
52
+ if (dataPath === undefined)
53
+ return aliases;
54
+ return aliases.map((alias) => `${dataPath}${REGISTRY_SCOPE_SEPARATOR}${alias}`);
55
+ }
56
+ export function getCommunityRegistryAliases(community, dataPath) {
57
+ // community.address is deliberately absent: setAddress keeps it equal to `name || publicKey`, so
58
+ // it is never an identity name/publicKey does not already carry. signer.address is NOT
59
+ // redundant — communityIdentityPublicKey() is `anchor?.publicKey ?? signer.address`, so on a
60
+ // delegated community publicKey is the anchor while signer.address is the minter that signs its
61
+ // records, and both have to resolve to the instance.
62
+ const aliases = dedupeAliases([community.name, community.publicKey, community.signer?.address]);
37
63
  if (aliases.length === 0)
38
64
  throw new PKCError("ERR_COMMUNITY_REGISTRY_LOOKUP_HAS_NO_ALIASES", { community });
39
- return dedupeAliases(aliases.flatMap((alias) => {
65
+ return scopeAliasesToDataPath(dedupeAliases(aliases.flatMap((alias) => {
40
66
  if (isEthAliasDomain(alias))
41
67
  return getEquivalentCommunityAliases(alias);
42
68
  return [alias];
43
- }));
69
+ })), dataPath);
44
70
  }
45
71
  export function getCommentRegistryAliases(comment) {
46
72
  return dedupeAliases([comment.cid]);
47
73
  }
48
- export function syncCommunityRegistryEntry(registry, community) {
49
- return registry.track({ value: community, aliases: persistAliases(community, getCommunityRegistryAliases(community)) });
74
+ export function syncCommunityRegistryEntry(registry, community, dataPath) {
75
+ return registry.track({
76
+ value: community,
77
+ aliases: scopeAliasesToDataPath(persistAliases(community, registry, getCommunityRegistryAliases(community)), dataPath)
78
+ });
50
79
  }
51
80
  export function syncCommentRegistryEntry(registry, comment) {
52
- return registry.track({ value: comment, aliases: persistAliases(comment, getCommentRegistryAliases(comment)) });
81
+ return registry.track({ value: comment, aliases: persistAliases(comment, registry, getCommentRegistryAliases(comment)) });
53
82
  }
54
- export function findCommunityInRegistry(registry, lookup) {
55
- return registry.findByAliases(getCommunityRegistryAliases(lookup));
83
+ export function findCommunityInRegistry(registry, lookup, dataPath) {
84
+ return registry.findByAliases(getCommunityRegistryAliases(lookup, dataPath));
56
85
  }
57
86
  export function findCommentInRegistry(registry, lookup) {
58
87
  return registry.findByAliases(getCommentRegistryAliases(lookup));