@pkcprotocol/pkc-js 0.0.81 → 0.0.82

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 (126) hide show
  1. package/README.md +3 -1
  2. package/dist/browser/clients/base-client-manager.js +19 -1
  3. package/dist/browser/clients/base-client-manager.js.map +1 -1
  4. package/dist/browser/clients/rpc-client/rpc-schema-util.d.ts +1 -0
  5. package/dist/browser/clients/rpc-client/schema.d.ts +3 -0
  6. package/dist/browser/community/schema.d.ts +24 -0
  7. package/dist/browser/community/schema.js +6 -1
  8. package/dist/browser/community/schema.js.map +1 -1
  9. package/dist/browser/errors.d.ts +10 -1
  10. package/dist/browser/errors.js +10 -1
  11. package/dist/browser/errors.js.map +1 -1
  12. package/dist/browser/generated-version.d.ts +1 -1
  13. package/dist/browser/generated-version.js +1 -1
  14. package/dist/browser/pages/pages.js +8 -0
  15. package/dist/browser/pages/pages.js.map +1 -1
  16. package/dist/browser/pages/schema.d.ts +4 -0
  17. package/dist/browser/pages/util.d.ts +2 -0
  18. package/dist/browser/pages/util.js +23 -3
  19. package/dist/browser/pages/util.js.map +1 -1
  20. package/dist/browser/pkc/pkc.d.ts +2 -0
  21. package/dist/browser/pkc/pkc.js +20 -0
  22. package/dist/browser/pkc/pkc.js.map +1 -1
  23. package/dist/browser/pkc-error.d.ts +1 -1
  24. package/dist/browser/publications/comment/comment-client-manager.js +22 -4
  25. package/dist/browser/publications/comment/comment-client-manager.js.map +1 -1
  26. package/dist/browser/publications/comment/comment.d.ts +2 -1
  27. package/dist/browser/publications/comment/comment.js +29 -6
  28. package/dist/browser/publications/comment/comment.js.map +1 -1
  29. package/dist/browser/publications/comment/crosspost-depth.d.ts +5 -0
  30. package/dist/browser/publications/comment/crosspost-depth.js +75 -0
  31. package/dist/browser/publications/comment/crosspost-depth.js.map +1 -0
  32. package/dist/browser/publications/comment/crosspost-runtime.d.ts +30 -0
  33. package/dist/browser/publications/comment/crosspost-runtime.js +133 -0
  34. package/dist/browser/publications/comment/crosspost-runtime.js.map +1 -0
  35. package/dist/browser/publications/comment/schema.d.ts +20 -2
  36. package/dist/browser/publications/comment/schema.js +21 -10
  37. package/dist/browser/publications/comment/schema.js.map +1 -1
  38. package/dist/browser/publications/comment/types.d.ts +10 -0
  39. package/dist/browser/publications/community-edit/schema.d.ts +4 -0
  40. package/dist/browser/publications/publication.d.ts +4 -0
  41. package/dist/browser/publications/publication.js +80 -5
  42. package/dist/browser/publications/publication.js.map +1 -1
  43. package/dist/browser/pubsub-messages/schema.d.ts +5 -0
  44. package/dist/browser/rpc/src/index.js +13 -1
  45. package/dist/browser/rpc/src/index.js.map +1 -1
  46. package/dist/browser/runtime/node/community/db-handler.js +3 -2
  47. package/dist/browser/runtime/node/community/db-handler.js.map +1 -1
  48. package/dist/browser/runtime/node/community/local-community/publication-validation.js +15 -0
  49. package/dist/browser/runtime/node/community/local-community/publication-validation.js.map +1 -1
  50. package/dist/browser/runtime/node/community/page-generator.d.ts +2 -0
  51. package/dist/browser/schema/schema-util.d.ts +17 -0
  52. package/dist/browser/schema/schema-util.js +49 -5
  53. package/dist/browser/schema/schema-util.js.map +1 -1
  54. package/dist/browser/signer/signatures.d.ts +1 -10
  55. package/dist/browser/signer/signatures.js +83 -0
  56. package/dist/browser/signer/signatures.js.map +1 -1
  57. package/dist/browser/test/test-util.d.ts +6 -0
  58. package/dist/browser/version.js +1 -1
  59. package/dist/bundled/bundle-manifest.json +27 -25
  60. package/dist/bundled/chunks/{helia-for-pkc-BcNF-orO.js → helia-for-pkc-CQY3-UYD.js} +2 -2
  61. package/dist/bundled/chunks/{local-community-B6-jaMsn.js → local-community-AZAEiiht.js} +1 -1
  62. package/dist/bundled/chunks/{local-community-CyX1HwD0.js → local-community-DRm3r1-Y.js} +10 -4
  63. package/dist/bundled/chunks/{node-BCXmIYLQ.js → node-B1J8psGZ.js} +67 -14
  64. package/dist/bundled/chunks/{rpc-local-community-BOiy8BX1.js → rpc-local-community-0XmKyOdO.js} +253 -12
  65. package/dist/bundled/chunks/{schema-DZyEx0YQ.js → schema-BUUhufdT.js} +23 -8
  66. package/dist/bundled/chunks/{util-BTPlI1yF.js → util-Cct7-RT3.js} +1 -1
  67. package/dist/bundled/index.js +1 -1
  68. package/dist/bundled/rpc/src/index.js +13 -5
  69. package/dist/node/clients/base-client-manager.js +19 -1
  70. package/dist/node/clients/base-client-manager.js.map +1 -1
  71. package/dist/node/clients/rpc-client/rpc-schema-util.d.ts +1 -0
  72. package/dist/node/clients/rpc-client/schema.d.ts +3 -0
  73. package/dist/node/community/schema.d.ts +24 -0
  74. package/dist/node/community/schema.js +6 -1
  75. package/dist/node/community/schema.js.map +1 -1
  76. package/dist/node/errors.d.ts +10 -1
  77. package/dist/node/errors.js +10 -1
  78. package/dist/node/errors.js.map +1 -1
  79. package/dist/node/generated-version.d.ts +1 -1
  80. package/dist/node/generated-version.js +1 -1
  81. package/dist/node/pages/pages.js +8 -0
  82. package/dist/node/pages/pages.js.map +1 -1
  83. package/dist/node/pages/schema.d.ts +4 -0
  84. package/dist/node/pages/util.d.ts +2 -0
  85. package/dist/node/pages/util.js +23 -3
  86. package/dist/node/pages/util.js.map +1 -1
  87. package/dist/node/pkc/pkc.d.ts +2 -0
  88. package/dist/node/pkc/pkc.js +20 -0
  89. package/dist/node/pkc/pkc.js.map +1 -1
  90. package/dist/node/pkc-error.d.ts +1 -1
  91. package/dist/node/publications/comment/comment-client-manager.js +22 -4
  92. package/dist/node/publications/comment/comment-client-manager.js.map +1 -1
  93. package/dist/node/publications/comment/comment.d.ts +2 -1
  94. package/dist/node/publications/comment/comment.js +29 -6
  95. package/dist/node/publications/comment/comment.js.map +1 -1
  96. package/dist/node/publications/comment/crosspost-depth.d.ts +5 -0
  97. package/dist/node/publications/comment/crosspost-depth.js +75 -0
  98. package/dist/node/publications/comment/crosspost-depth.js.map +1 -0
  99. package/dist/node/publications/comment/crosspost-runtime.d.ts +30 -0
  100. package/dist/node/publications/comment/crosspost-runtime.js +133 -0
  101. package/dist/node/publications/comment/crosspost-runtime.js.map +1 -0
  102. package/dist/node/publications/comment/schema.d.ts +20 -2
  103. package/dist/node/publications/comment/schema.js +21 -10
  104. package/dist/node/publications/comment/schema.js.map +1 -1
  105. package/dist/node/publications/comment/types.d.ts +10 -0
  106. package/dist/node/publications/community-edit/schema.d.ts +4 -0
  107. package/dist/node/publications/publication.d.ts +4 -0
  108. package/dist/node/publications/publication.js +80 -5
  109. package/dist/node/publications/publication.js.map +1 -1
  110. package/dist/node/pubsub-messages/schema.d.ts +5 -0
  111. package/dist/node/rpc/src/index.js +13 -1
  112. package/dist/node/rpc/src/index.js.map +1 -1
  113. package/dist/node/runtime/node/community/db-handler.js +3 -2
  114. package/dist/node/runtime/node/community/db-handler.js.map +1 -1
  115. package/dist/node/runtime/node/community/local-community/publication-validation.js +15 -0
  116. package/dist/node/runtime/node/community/local-community/publication-validation.js.map +1 -1
  117. package/dist/node/runtime/node/community/page-generator.d.ts +2 -0
  118. package/dist/node/schema/schema-util.d.ts +17 -0
  119. package/dist/node/schema/schema-util.js +49 -5
  120. package/dist/node/schema/schema-util.js.map +1 -1
  121. package/dist/node/signer/signatures.d.ts +1 -10
  122. package/dist/node/signer/signatures.js +83 -0
  123. package/dist/node/signer/signatures.js.map +1 -1
  124. package/dist/node/test/test-util.d.ts +6 -0
  125. package/dist/node/version.js +1 -1
  126. package/package.json +1 -1
@@ -303,6 +303,7 @@ export declare function createDelegatedCommunityIpns(communityOpts?: Partial<Com
303
303
  parentCid?: string | undefined;
304
304
  postCid?: string | undefined;
305
305
  quotedCids?: string[] | undefined;
306
+ crosspost?: import("../publications/comment/schema.js").Crosspost | undefined;
306
307
  author?: {
307
308
  [x: string]: unknown;
308
309
  name?: string | undefined;
@@ -490,6 +491,7 @@ export declare function createDelegatedCommunityIpns(communityOpts?: Partial<Com
490
491
  noReplyLinks?: boolean | undefined;
491
492
  noPolls?: boolean | undefined;
492
493
  noCrossposts?: boolean | undefined;
494
+ maxCrosspostDepth?: number | undefined;
493
495
  noNestedReplies?: boolean | undefined;
494
496
  safeForWork?: boolean | undefined;
495
497
  authorFlairs?: boolean | undefined;
@@ -639,6 +641,7 @@ export declare function createMockedCommunityIpns(communityOpts: CreateNewLocalC
639
641
  parentCid?: string | undefined;
640
642
  postCid?: string | undefined;
641
643
  quotedCids?: string[] | undefined;
644
+ crosspost?: import("../publications/comment/schema.js").Crosspost | undefined;
642
645
  author?: {
643
646
  [x: string]: unknown;
644
647
  name?: string | undefined;
@@ -826,6 +829,7 @@ export declare function createMockedCommunityIpns(communityOpts: CreateNewLocalC
826
829
  noReplyLinks?: boolean | undefined;
827
830
  noPolls?: boolean | undefined;
828
831
  noCrossposts?: boolean | undefined;
832
+ maxCrosspostDepth?: number | undefined;
829
833
  noNestedReplies?: boolean | undefined;
830
834
  safeForWork?: boolean | undefined;
831
835
  authorFlairs?: boolean | undefined;
@@ -939,6 +943,7 @@ export declare function jsonifyLocalCommunityWithNoInternalProps(community: Loca
939
943
  noReplyLinks?: boolean | undefined;
940
944
  noPolls?: boolean | undefined;
941
945
  noCrossposts?: boolean | undefined;
946
+ maxCrosspostDepth?: number | undefined;
942
947
  noNestedReplies?: boolean | undefined;
943
948
  safeForWork?: boolean | undefined;
944
949
  authorFlairs?: boolean | undefined;
@@ -1142,6 +1147,7 @@ export declare function createCommentUpdateWithInvalidSignature(commentCid: stri
1142
1147
  parentCid?: string | undefined;
1143
1148
  postCid?: string | undefined;
1144
1149
  quotedCids?: string[] | undefined;
1150
+ crosspost?: import("../publications/comment/schema.js").Crosspost | undefined;
1145
1151
  author?: {
1146
1152
  [x: string]: unknown;
1147
1153
  name?: string | undefined;
@@ -5,7 +5,7 @@ const pkcJsVersion = version;
5
5
  const userAgent = UserAgentSchema.parse(`/pkc-js:${pkcJsVersion}/`);
6
6
  export default {
7
7
  PKC_JS_VERSION: pkcJsVersion,
8
- DB_VERSION: 40,
8
+ DB_VERSION: 41,
9
9
  PROTOCOL_VERSION: protocolVersion,
10
10
  USER_AGENT: userAgent
11
11
  };
@@ -14,7 +14,7 @@
14
14
  "node:module"
15
15
  ],
16
16
  "dynamicImports": [
17
- "chunks/node-BCXmIYLQ.js"
17
+ "chunks/node-B1J8psGZ.js"
18
18
  ],
19
19
  "inputs": [
20
20
  "dist/node/runtime/node/compile-cache.js",
@@ -24,7 +24,7 @@
24
24
  "index.js": {
25
25
  "isEntry": true,
26
26
  "imports": [
27
- "chunks/node-BCXmIYLQ.js"
27
+ "chunks/node-B1J8psGZ.js"
28
28
  ],
29
29
  "dynamicImports": [],
30
30
  "inputs": []
@@ -32,10 +32,10 @@
32
32
  "rpc/src/index.js": {
33
33
  "isEntry": true,
34
34
  "imports": [
35
- "chunks/rpc-local-community-BOiy8BX1.js",
36
- "chunks/node-BCXmIYLQ.js",
37
- "chunks/schema-DZyEx0YQ.js",
38
- "chunks/local-community-CyX1HwD0.js",
35
+ "chunks/rpc-local-community-0XmKyOdO.js",
36
+ "chunks/node-B1J8psGZ.js",
37
+ "chunks/schema-BUUhufdT.js",
38
+ "chunks/local-community-DRm3r1-Y.js",
39
39
  "node:url",
40
40
  "path",
41
41
  "assert",
@@ -65,12 +65,12 @@
65
65
  "\u0000rolldown/runtime.js"
66
66
  ]
67
67
  },
68
- "chunks/helia-for-pkc-BcNF-orO.js": {
68
+ "chunks/helia-for-pkc-CQY3-UYD.js": {
69
69
  "isEntry": false,
70
70
  "imports": [
71
71
  "chunks/chunk-2rV9d50f.js",
72
- "chunks/schema-DZyEx0YQ.js",
73
- "chunks/util-BTPlI1yF.js",
72
+ "chunks/schema-BUUhufdT.js",
73
+ "chunks/util-Cct7-RT3.js",
74
74
  "chunks/src-DKntVmyX.js",
75
75
  "chunks/src-Cpx2Sts8.js",
76
76
  "node:url",
@@ -186,20 +186,20 @@
186
186
  "dist/node/helia/helia-for-pkc.js"
187
187
  ]
188
188
  },
189
- "chunks/local-community-B6-jaMsn.js": {
189
+ "chunks/local-community-AZAEiiht.js": {
190
190
  "isEntry": false,
191
191
  "imports": [
192
- "chunks/local-community-CyX1HwD0.js"
192
+ "chunks/local-community-DRm3r1-Y.js"
193
193
  ],
194
194
  "dynamicImports": [],
195
195
  "inputs": []
196
196
  },
197
- "chunks/local-community-CyX1HwD0.js": {
197
+ "chunks/local-community-DRm3r1-Y.js": {
198
198
  "isEntry": false,
199
199
  "imports": [
200
200
  "chunks/chunk-2rV9d50f.js",
201
- "chunks/rpc-local-community-BOiy8BX1.js",
202
- "chunks/schema-DZyEx0YQ.js",
201
+ "chunks/rpc-local-community-0XmKyOdO.js",
202
+ "chunks/schema-BUUhufdT.js",
203
203
  "node:crypto",
204
204
  "node:url",
205
205
  "node:path",
@@ -255,13 +255,13 @@
255
255
  "dist/node/runtime/node/community/local-community.js"
256
256
  ]
257
257
  },
258
- "chunks/node-BCXmIYLQ.js": {
258
+ "chunks/node-B1J8psGZ.js": {
259
259
  "isEntry": false,
260
260
  "imports": [
261
261
  "chunks/chunk-2rV9d50f.js",
262
- "chunks/rpc-local-community-BOiy8BX1.js",
263
- "chunks/schema-DZyEx0YQ.js",
264
- "chunks/util-BTPlI1yF.js",
262
+ "chunks/rpc-local-community-0XmKyOdO.js",
263
+ "chunks/schema-BUUhufdT.js",
264
+ "chunks/util-Cct7-RT3.js",
265
265
  "path",
266
266
  "assert",
267
267
  "fs",
@@ -272,8 +272,8 @@
272
272
  "rpc-websockets"
273
273
  ],
274
274
  "dynamicImports": [
275
- "chunks/helia-for-pkc-BcNF-orO.js",
276
- "chunks/local-community-CyX1HwD0.js"
275
+ "chunks/helia-for-pkc-CQY3-UYD.js",
276
+ "chunks/local-community-DRm3r1-Y.js"
277
277
  ],
278
278
  "inputs": [
279
279
  "node_modules/zod/v4/locales/en.js",
@@ -315,11 +315,11 @@
315
315
  "dist/node/index.js"
316
316
  ]
317
317
  },
318
- "chunks/rpc-local-community-BOiy8BX1.js": {
318
+ "chunks/rpc-local-community-0XmKyOdO.js": {
319
319
  "isEntry": false,
320
320
  "imports": [
321
321
  "chunks/chunk-2rV9d50f.js",
322
- "chunks/schema-DZyEx0YQ.js",
322
+ "chunks/schema-BUUhufdT.js",
323
323
  "chunks/src-CYIMjhjK.js",
324
324
  "node:crypto",
325
325
  "node:url",
@@ -732,6 +732,7 @@
732
732
  "node_modules/remeda/dist/withPrecision-CqXhgRqZ.js",
733
733
  "node_modules/remeda/dist/round.js",
734
734
  "node_modules/remeda/dist/stringToPath.js",
735
+ "dist/node/publications/comment/crosspost-depth.js",
735
736
  "dist/node/clients/rpc-client/schema.js",
736
737
  "dist/node/rpc/src/schema.js",
737
738
  "dist/node/schema/schema-util.js",
@@ -785,6 +786,7 @@
785
786
  "dist/node/pages/pages-clients.js",
786
787
  "dist/node/pages/pages-client-manager.js",
787
788
  "dist/node/pages/schema-util.js",
789
+ "dist/node/publications/comment/crosspost-runtime.js",
788
790
  "dist/node/pages/pages.js",
789
791
  "dist/node/pages/util.js",
790
792
  "dist/node/publications/comment/comment-clients.js",
@@ -870,7 +872,7 @@
870
872
  "dist/node/community/rpc-local-community.js"
871
873
  ]
872
874
  },
873
- "chunks/schema-DZyEx0YQ.js": {
875
+ "chunks/schema-BUUhufdT.js": {
874
876
  "isEntry": false,
875
877
  "imports": [
876
878
  "chunks/chunk-2rV9d50f.js",
@@ -1323,10 +1325,10 @@
1323
1325
  "node_modules/kubo-rpc-client/dist/src/index.js"
1324
1326
  ]
1325
1327
  },
1326
- "chunks/util-BTPlI1yF.js": {
1328
+ "chunks/util-Cct7-RT3.js": {
1327
1329
  "isEntry": false,
1328
1330
  "imports": [
1329
- "chunks/schema-DZyEx0YQ.js",
1331
+ "chunks/schema-BUUhufdT.js",
1330
1332
  "ipns/selector",
1331
1333
  "uint8arrays/equals"
1332
1334
  ],
@@ -1,6 +1,6 @@
1
1
  import { i as __toESM, r as __require, t as __commonJSMin } from "./chunk-2rV9d50f.js";
2
- import { L as hideClassPrivateProps, R as ipnsNameToIpnsOverPubsubTopic, br as logger_default, vr as PKCError } from "./schema-DZyEx0YQ.js";
3
- import { a as fetchBlockWithStalledSessionFailover, i as directFetchIpnsRecordFromProviders, n as cacheIpnsRecordInPubsubLocalStore, o as getHeliaDebugContext, r as connectToPubsubPeers, s as selectBitswapSessionSeedPeers } from "./util-BTPlI1yF.js";
2
+ import { L as hideClassPrivateProps, R as ipnsNameToIpnsOverPubsubTopic, br as logger_default, vr as PKCError } from "./schema-BUUhufdT.js";
3
+ import { a as fetchBlockWithStalledSessionFailover, i as directFetchIpnsRecordFromProviders, n as cacheIpnsRecordInPubsubLocalStore, o as getHeliaDebugContext, r as connectToPubsubPeers, s as selectBitswapSessionSeedPeers } from "./util-Cct7-RT3.js";
4
4
  import { t as map } from "./src-Cpx2Sts8.js";
5
5
  import { t as parallelBatch } from "./src-DKntVmyX.js";
6
6
  import { fileURLToPath } from "node:url";
@@ -1,2 +1,2 @@
1
- import { n as createNewLocalCommunityDb, r as updateInstancePropsWithStartedCommunityOrDb, t as LocalCommunity } from "./local-community-CyX1HwD0.js";
1
+ import { n as createNewLocalCommunityDb, r as updateInstancePropsWithStartedCommunityOrDb, t as LocalCommunity } from "./local-community-DRm3r1-Y.js";
2
2
  export { LocalCommunity, createNewLocalCommunityDb, updateInstancePropsWithStartedCommunityOrDb };
@@ -1,6 +1,6 @@
1
1
  import { i as __toESM, r as __require, t as __commonJSMin } from "./chunk-2rV9d50f.js";
2
- import { $ as pubsubTopicToDhtKey, $n as n$3, An as CommentsTableRowSchema, At as trackStartedCommunity, Bn as CommentEditsTableRowSchema, Bt as CommunityEditPublicationPubsubReservedFields, C as contentContainsMarkdownAudio, Ct as findUpdatingCommunity, Dn as CommentUpdateSchema, F as getIpnsRecordInLocalKuboNode, Ft as untrackUpdatingCommunity, G as isLinkOfAudio, Gt as CommentModerationPubsubMessagePublicationSchema, In as CommentEditPubsubMessagePublicationSchema, It as require_sha256, J as isLinkOfVideo, Jt as CommentModerationsTableRowSchema, K as isLinkOfImage, Kt as CommentModerationReservedFields, L as hideClassPrivateProps, Ln as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema, M as genToArray, Mt as trackUpdatingCommunity, N as getEquivalentCommunityAddresses, Nr as ZodError, Nt as untrackStartedCommunity, O as derivePublicationFromChallengeRequest, P as getErrorCodeFromMessage, Q as isStringDomain, Qn as t$8, R as ipnsNameToIpnsOverPubsubTopic, Rn as CommentEditReservedFields, S as calculateStringSizeSameAsIpfsAddCidV0, T as contentContainsMarkdownVideos, W as isLinkOfAnimatedImage, Wn as AuthorReservedFields, Y as isLinkValid, Zn as n$4, _t as timestamp, a as ChallengeRequestMessageSchema, ar as r$1, at as removeNullUndefinedValues, b as areEquivalentCommunityAddresses, bn as CommentPubsubMessageReservedFields, br as logger_default, bt as findCommunityInRegistry, d as DecryptedChallengeRequestSchema, dt as retryKuboIpfsAddAndProvide, er as t$7, fr as require_retry, gn as VoteTablesRowSchema, ht as statMfsPathSafely, in as CommunitySignedPropertyNames, k as doesDomainAddressHaveCapitalLetter, kn as CommentUpdateTableRowSchema, kt as syncCommunityRegistryEntry, lr as t$5, lt as retryKuboBlockPutPinAndProvidePubsubTopic, mn as VotePubsubReservedFields, mt as sleepUntilTimeoutOrAbort, nr as e, nt as removeBlocksFromKuboNode, or as t$4, pn as VotePubsubMessagePublicationSchema, q as isLinkOfMedia, r as ChallengeMessageSchema, rn as CommunityIpfsSchema, rr as e$1, rt as removeMfsFilesSafely, s as ChallengeVerificationMessageSchema, t as ChallengeAnswerMessageSchema, tr as t$6, u as DecryptedChallengeRequestPublicationSchema, ur as t$3, vr as PKCError, w as contentContainsMarkdownImages, x as calculateIpfsCidV0, xt as findStartedCommunity, y as version_default, yn as CommentIpfsSchema, yr as messages, yt as writeKuboFilesWithTimeout } from "./schema-DZyEx0YQ.js";
3
- import { $n as n$5, A as deriveDbReplies, At as verifyVote, C as backupCommunityDb, Ct as verifyCommentEdit, D as deleteOldCommunityInWindows, Dt as verifyCommentUpdate, Et as verifyCommentPubsubMessage, G as TIMEFRAMES_TO_SECONDS, Gt as getPKCAddressFromPublicKey, H as POSTS_SORT_TYPES, Ht as encode, Jn as t$9, Jt as createSchemaRowParser, Kt as getPKCAddressFromPublicKeySync, L as moveCommunityDbToDeletedDirectory, Mt as cleanWireAuthor, N as getThumbnailPropsOfLink, O as deriveCommentIpfsFromCommentTableRow, Ot as verifyCommunity, P as importSignerIntoKuboNode, Pt as getAuthorNameFromWire, Qn as n$6, R as resolveDbPostsCidRefs, Rt as getCommunityNameFromWire, S as BackupAbortError, T as calculateInlineRepliesBudget, Tt as verifyCommentModeration, U as POST_REPLIES_SORT_TYPES, Vt as decode, W as REPLY_REPLIES_SORT_TYPES, Wt as getIpfsKeyFromPrivateKey, X as iterateOverPageCidsToFindAllCids, Xn as r$2, Yn as t$12, Zn as t$11, _n as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, a as pkcJsChallenges, an as parseCommunityEditOptionsSchemaWithPKCErrorIfItFails, bn as parseJsonWithPKCErrorIfFails, ct as signChallengeMessage, dt as signComment, ft as signCommentEdit, gt as signCommunity, h as SignerWithPublicKeyAddress, ht as signCommentUpdateForChallengeVerification, i as getCommunityChallengeFromCommunityChallengeSettings, ir as require_lodash_merge, j as getDefaultCommunityDbConfig, jt as buildRuntimeAuthor, k as deriveDbPosts, kt as verifyCommunityEdit, l as MAX_FILE_SIZE_BYTES_FOR_COMMUNITY_IPFS, mt as signCommentUpdate, nr as stringify, o as TrackedInstanceRegistry, ot as cleanUpBeforePublishing, qt as getPublicKeyFromPrivateKey, r as getChallengeVerification, rr as STORAGE_KEYS, rt as pLimit, s as LRUCache, sn as parseCommunityIpfsSchemaPassthroughWithPKCErrorIfItFails, t as RpcLocalCommunity, tr as t$10, u as KeyvBetterSqlite3, ut as signChallengeVerification, w as calculateExpectedSignatureSize, wt as verifyCommentIpfs, x as encryptEd25519AesGcmPublicKeyBuffer, xt as verifyChallengeRequest, y as decryptEd25519AesGcmPublicKeyBuffer, yt as verifyChallengeAnswer, zt as getCommunityPublicKeyFromWire } from "./rpc-local-community-BOiy8BX1.js";
2
+ import { $ as pubsubTopicToDhtKey, $n as n$3, An as CommentsTableRowSchema, At as trackStartedCommunity, Bn as CommentEditsTableRowSchema, Bt as CommunityEditPublicationPubsubReservedFields, C as contentContainsMarkdownAudio, Ct as findUpdatingCommunity, Dn as CommentUpdateSchema, F as getIpnsRecordInLocalKuboNode, Ft as untrackUpdatingCommunity, G as isLinkOfAudio, Gt as CommentModerationPubsubMessagePublicationSchema, In as CommentEditPubsubMessagePublicationSchema, It as require_sha256, J as isLinkOfVideo, Jt as CommentModerationsTableRowSchema, K as isLinkOfImage, Kt as CommentModerationReservedFields, L as hideClassPrivateProps, Ln as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema, M as genToArray, Mt as trackUpdatingCommunity, N as getEquivalentCommunityAddresses, Nr as ZodError, Nt as untrackStartedCommunity, O as derivePublicationFromChallengeRequest, P as getErrorCodeFromMessage, Q as isStringDomain, Qn as t$8, R as ipnsNameToIpnsOverPubsubTopic, Rn as CommentEditReservedFields, S as calculateStringSizeSameAsIpfsAddCidV0, T as contentContainsMarkdownVideos, W as isLinkOfAnimatedImage, Wn as AuthorReservedFields, Y as isLinkValid, Zn as n$4, _t as timestamp, a as ChallengeRequestMessageSchema, ar as r$1, at as removeNullUndefinedValues, b as areEquivalentCommunityAddresses, bn as CommentPubsubMessageReservedFields, br as logger_default, bt as findCommunityInRegistry, d as DecryptedChallengeRequestSchema, dt as retryKuboIpfsAddAndProvide, er as t$7, fr as require_retry, gn as VoteTablesRowSchema, ht as statMfsPathSafely, in as CommunitySignedPropertyNames, k as doesDomainAddressHaveCapitalLetter, kn as CommentUpdateTableRowSchema, kt as syncCommunityRegistryEntry, lr as t$5, lt as retryKuboBlockPutPinAndProvidePubsubTopic, mn as VotePubsubReservedFields, mt as sleepUntilTimeoutOrAbort, nr as e, nt as removeBlocksFromKuboNode, or as t$4, pn as VotePubsubMessagePublicationSchema, q as isLinkOfMedia, r as ChallengeMessageSchema, rn as CommunityIpfsSchema, rr as e$1, rt as removeMfsFilesSafely, s as ChallengeVerificationMessageSchema, t as ChallengeAnswerMessageSchema, tr as t$6, u as DecryptedChallengeRequestPublicationSchema, ur as t$3, vr as PKCError, w as contentContainsMarkdownImages, x as calculateIpfsCidV0, xt as findStartedCommunity, y as version_default, yn as CommentIpfsSchema, yr as messages, yt as writeKuboFilesWithTimeout } from "./schema-BUUhufdT.js";
3
+ import { $n as crosspostChainDepthUpTo, $t as createSchemaRowParser, A as deriveDbReplies, At as verifyCommentModeration, C as backupCommunityDb, D as deleteOldCommunityInWindows, Et as verifyChallengeRequest, Ft as verifyVote, G as TIMEFRAMES_TO_SECONDS, H as POSTS_SORT_TYPES, It as buildRuntimeAuthor, Kt as decode, L as moveCommunityDbToDeletedDirectory, Lt as cleanWireAuthor, Mt as verifyCommentUpdate, N as getThumbnailPropsOfLink, Nt as verifyCommunity, O as deriveCommentIpfsFromCommentTableRow, Ot as verifyCommentEdit, P as importSignerIntoKuboNode, Pt as verifyCommunityEdit, Qt as getPublicKeyFromPrivateKey, R as resolveDbPostsCidRefs, S as BackupAbortError, Sn as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, T as calculateInlineRepliesBudget, Tn as parseJsonWithPKCErrorIfFails, U as POST_REPLIES_SORT_TYPES, Ut as getCommunityNameFromWire, W as REPLY_REPLIES_SORT_TYPES, Wt as getCommunityPublicKeyFromWire, X as iterateOverPageCidsToFindAllCids, Xt as getPKCAddressFromPublicKey, Yt as getIpfsKeyFromPrivateKey, Zt as getPKCAddressFromPublicKeySync, _t as signCommentEdit, a as pkcJsChallenges, ar as n$6, bt as signCommentUpdateForChallengeVerification, cr as t$10, ct as pLimit, dr as require_lodash_merge, dt as cleanUpBeforePublishing, er as effectiveMaxCrosspostDepth, fn as parseCommunityIpfsSchemaPassthroughWithPKCErrorIfItFails, gt as signComment, h as SignerWithPublicKeyAddress, ht as signChallengeVerification, i as getCommunityChallengeFromCommunityChallengeSettings, ir as t$11, j as getDefaultCommunityDbConfig, jt as verifyCommentPubsubMessage, k as deriveDbPosts, kt as verifyCommentIpfs, l as MAX_FILE_SIZE_BYTES_FOR_COMMUNITY_IPFS, lr as stringify, nr as t$12, o as TrackedInstanceRegistry, or as n$5, pt as signChallengeMessage, qt as encode, r as getChallengeVerification, rr as r$2, s as LRUCache, t as RpcLocalCommunity, tr as t$9, u as KeyvBetterSqlite3, un as parseCommunityEditOptionsSchemaWithPKCErrorIfItFails, ur as STORAGE_KEYS, w as calculateExpectedSignatureSize, wt as verifyChallengeAnswer, x as encryptEd25519AesGcmPublicKeyBuffer, xt as signCommunity, y as decryptEd25519AesGcmPublicKeyBuffer, yt as signCommentUpdate, zt as getAuthorNameFromWire } from "./rpc-local-community-0XmKyOdO.js";
4
4
  import { randomFillSync, randomUUID } from "node:crypto";
5
5
  import { fileURLToPath, pathToFileURL } from "node:url";
6
6
  import path from "node:path";
@@ -1304,6 +1304,11 @@ async function checkCommentPublication(community, request) {
1304
1304
  const parentsOfComment = community._dbHandler.queryParentsCids({ parentCid: commentPublication.parentCid });
1305
1305
  if (parentsOfComment[parentsOfComment.length - 1].cid !== commentPublication.postCid) return messages.ERR_REPLY_POST_CID_IS_NOT_PARENT_OF_REPLY;
1306
1306
  }
1307
+ if (commentPublication.crosspost) {
1308
+ if (community.features?.noCrossposts) return messages.ERR_NOT_ALLOWED_TO_PUBLISH_CROSSPOSTS;
1309
+ const maxDepth = effectiveMaxCrosspostDepth(community.features?.maxCrosspostDepth);
1310
+ if (crosspostChainDepthUpTo(commentPublication, maxDepth + 1) > maxDepth) return messages.ERR_CROSSPOST_CHAIN_EXCEEDS_COMMUNITY_MAX_DEPTH;
1311
+ }
1307
1312
  if (commentPublication.quotedCids && commentPublication.quotedCids.length > 0) {
1308
1313
  if (!commentPublication.parentCid) return messages.ERR_POST_CANNOT_HAVE_QUOTED_CIDS;
1309
1314
  const threadPostCid = commentPublication.postCid;
@@ -3336,6 +3341,7 @@ var DbHandler = class {
3336
3341
  nsfw INTEGER NULLABLE, -- BOOLEAN (0/1)
3337
3342
  pseudonymityMode TEXT NULLABLE,
3338
3343
  quotedCids TEXT NULLABLE, -- JSON array
3344
+ crosspost TEXT NULLABLE, -- JSON: {cid, comment} of the comment this one reposts, stored verbatim so the embedded record keeps reproducing its cid
3339
3345
  extraProps TEXT NULLABLE, -- JSON
3340
3346
  challengeCommentUpdate TEXT NULLABLE, -- JSON: challenge-supplied partial CommentUpdate seeded into queryCalculatedCommentUpdate with lowest priority
3341
3347
  protocolVersion TEXT NOT NULL,
@@ -3862,8 +3868,8 @@ var DbHandler = class {
3862
3868
  const columnNames = this._getColumnNames(TABLES.COMMENTS);
3863
3869
  const stmt = this._db.prepare(`
3864
3870
  INSERT INTO ${TABLES.COMMENTS}
3865
- (cid, authorSignerAddress, author, link, linkWidth, linkHeight, thumbnailUrl, thumbnailUrlWidth, thumbnailUrlHeight, parentCid, postCid, previousCid, communityPublicKey, communityName, content, timestamp, signature, originalCommentSignatureEncoded, title, depth, linkHtmlTagName, flairs, spoiler, pendingApproval, number, postNumber, nsfw, pseudonymityMode, quotedCids, extraProps, challengeCommentUpdate, protocolVersion, insertedAt)
3866
- VALUES (@cid, @authorSignerAddress, @author, @link, @linkWidth, @linkHeight, @thumbnailUrl, @thumbnailUrlWidth, @thumbnailUrlHeight, @parentCid, @postCid, @previousCid, @communityPublicKey, @communityName, @content, @timestamp, @signature, @originalCommentSignatureEncoded, @title, @depth, @linkHtmlTagName, @flairs, @spoiler, @pendingApproval, @number, @postNumber, @nsfw, @pseudonymityMode, @quotedCids, @extraProps, @challengeCommentUpdate, @protocolVersion, @insertedAt)
3871
+ (cid, authorSignerAddress, author, link, linkWidth, linkHeight, thumbnailUrl, thumbnailUrlWidth, thumbnailUrlHeight, parentCid, postCid, previousCid, communityPublicKey, communityName, content, timestamp, signature, originalCommentSignatureEncoded, title, depth, linkHtmlTagName, flairs, spoiler, pendingApproval, number, postNumber, nsfw, pseudonymityMode, quotedCids, crosspost, extraProps, challengeCommentUpdate, protocolVersion, insertedAt)
3872
+ VALUES (@cid, @authorSignerAddress, @author, @link, @linkWidth, @linkHeight, @thumbnailUrl, @thumbnailUrlWidth, @thumbnailUrlHeight, @parentCid, @postCid, @previousCid, @communityPublicKey, @communityName, @content, @timestamp, @signature, @originalCommentSignatureEncoded, @title, @depth, @linkHtmlTagName, @flairs, @spoiler, @pendingApproval, @number, @postNumber, @nsfw, @pseudonymityMode, @quotedCids, @crosspost, @extraProps, @challengeCommentUpdate, @protocolVersion, @insertedAt)
3867
3873
  `);
3868
3874
  const defaults = t$7(columnNames, (column) => [column, null]);
3869
3875
  this._db.transaction((items) => {
@@ -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$1, B as isIpfsCid, Cr as setErrorMap, Ct as findUpdatingCommunity, D as deepMergeRuntimeFields, Dn as CommentUpdateSchema, Dt as refreshTrackedCommentAliases, E as createAbortError, Et as listUpdatingCommunities, Fr as parsedType, H as isIpns, Ir as stringifyPrimitive, It as require_sha256, L as hideClassPrivateProps, Lt as TimeoutError, Pr as joinValues, Pt as untrackUpdatingComment, Q as isStringDomain, Qt as CommunityAnchorSchema, R as ipnsNameToIpnsOverPubsubTopic, Rt as pTimeout, St as findUpdatingComment, Tt as listUpdatingComments, Zn as n$2, _t as timestamp, a as ChallengeRequestMessageSchema, ar as r, b as areEquivalentCommunityAddresses, br as logger_default, ct as resolveWhenPredicateIsTrue, fr as require_retry, ft as shortifyAddress, jt as trackUpdatingComment, k as doesDomainAddressHaveCapitalLetter, ln as PubsubTopicSchema, mt as sleepUntilTimeoutOrAbort, nr as e, ot as removeUndefinedValuesRecursively, pr as FailedToFetchCommentIpfsFromGatewaysError, pt as shortifyCid, r as ChallengeMessageSchema, rn as CommunityIpfsSchema, rr as e$1, s as ChallengeVerificationMessageSchema, st as replaceXWithY, t as ChallengeAnswerMessageSchema, tr as t$1, ut as retryKuboIpfsAdd, vr as PKCError, vt as waitForUpdateInCommunityInstanceWithErrorAndTimeout, wn as CommentUpdateForChallengeVerificationSchema, wt as listStartedCommunities, xt as findStartedCommunity, y as version_default, yn as CommentIpfsSchema, yr as messages, z as isAbortError } from "./schema-DZyEx0YQ.js";
3
- import { $ as PublicationClientsManager, $t as parseCommentIpfsSchemaWithPKCErrorIfItFails, An as RpcCidParamSchema, At as verifyVote, B as tryToDeleteCommunitiesThatFailedToBeDeletedBefore, Bn as RpcFetchCidResultSchema, Bt as normalizeCommunityInputFromCommunity, Cn as parseRpcCommentUpdateEventWithPKCErrorIfItFails, Ct as verifyCommentEdit, Dn as RpcAnchorPublishPreparationResultSchema, Dt as verifyCommentUpdate, E as createKuboRpcClient, En as parseVotePubsubMessagePublicationSchemaWithPKCErrorIfItFails, Et as verifyCommentPubsubMessage, F as listCommunitiesSync, Fn as RpcExportCommunityModLogsParamSchema, Ft as normalizeCreatePublicationAuthor, Gn as RpcSubscriptionIdResultSchema, Hn as RpcPublishChallengeAnswersParamSchema, I as monitorCommunitiesDirectory, In as RpcExportCommunityModLogsResultSchema, It as buildRuntimeCommunityFields, J as extractCommunityRuntimeFieldsFromParsedPages, Jn as t$4, Kn as RpcSuccessResultSchema, Kt as getPKCAddressFromPublicKeySync, Ln as RpcExportCommunityParamSchema, Lt as getCommunityAddressFromRecord, M as getDefaultDataPath, Mn as RpcCommunityIdentifierParamSchema, Mt as cleanWireAuthor, Nn as RpcCommunityPageParamSchema, Nt as getAuthorNameFromRuntime, On as RpcAuthorNameParamSchema, Pn as RpcEditCommunityParamSchema, Q as RepliesPages, Qn as n$3, Qt as parseCommentEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, Rn as RpcExportCommunityResultSchema, Rt as getCommunityNameFromWire, Sn as parseRpcCommentEventWithPKCErrorIfItFails, St as verifyChallengeVerification, Tt as verifyCommentModeration, Un as RpcPublishedAnchorRecordResultSchema, Ut as getBufferedPKCAddressFromPublicKey, V as CommentClientsManager, Vn as RpcPublishAnchorRecordParamSchema, Vt as decode, Wn as RpcResolveAuthorNameResultSchema, Y as findCommentInPageInstanceRecursively, Yt as parseCidStringSchemaWithPKCErrorIfItFails, Z as parseRawPages, Zn as t$3, _ as createAnchorIpnsRecord$1, _n as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, _t as signCommunityEdit, a as pkcJsChallenges, ar as nativeFunctions$2, at as require_lib$1, b as encryptEd25519AesGcm, bn as parseJsonWithPKCErrorIfFails, bt as verifyChallengeMessage, c as RemoteCommunity, cn as parseCreateCommentEditOptionsSchemaWithPKCErrorIfItFails, d as decodeRpcChallengeAnswerPubsubMsg, dn as parseCreateCommunityEditPublicationOptionsSchemaWithPKCErrorIfItFails, dt as signComment, er as t$2, et as PKCClientsManager, f as decodeRpcChallengePubsubMsg, ft as signCommentEdit, g as createSigner, gn as parseCreateVoteOptionsSchemaWithPKCErrorIfItFails, hn as parseCreateRpcCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, it as PKCTypedEmitter, jn as RpcCommentRepliesPageParamSchema, jt as buildRuntimeAuthor, kn as RpcCancelExportParamSchema, kt as verifyCommunityEdit, ln as parseCreateCommentModerationOptionsSchemaWithPKCErrorIfItFails, lt as signChallengeRequest, m as decodeRpcChallengeVerificationPubsubMsg, mn as parseCreateRemoteCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, n as RpcRemoteCommunity, nn as parseCommentPubsubMessagePublicationWithPKCErrorIfItFails, o as TrackedInstanceRegistry, on as parseCommunityEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, or as require_undici, ot as cleanUpBeforePublishing, p as decodeRpcChallengeRequestPubsubMsg, pt as signCommentModeration, qn as RpcUnsubscribeParamSchema, rn as parseCommunityAddressWithPKCErrorIfItFails, s as LRUCache, st as signChallengeAnswer, t as RpcLocalCommunity, tn as parseCommentModerationPubsubMessagePublicationSchemaWithPKCErrorIfItFails, tr as t$5, tt as InflightFetchManager, u as KeyvBetterSqlite3, un as parseCreateCommentOptionsSchemaWithPKCErrorIfItFails, v as decryptEd25519AesGcm, vn as parseDecryptedChallengeVerification, vt as signVote, wn as parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, wt as verifyCommentIpfs, xn as parsePKCUserOptionsSchemaWithPKCErrorIfItFails, yn as parseDecryptedChallengeWithPKCErrorIfItFails, z as setNativeFunctions$1, zn as RpcFetchCidParamSchema, zt as getCommunityPublicKeyFromWire } from "./rpc-local-community-BOiy8BX1.js";
4
- import { o as getHeliaDebugContext } from "./util-BTPlI1yF.js";
2
+ import { $n as n$1, B as isIpfsCid, Cr as setErrorMap, Ct as findUpdatingCommunity, D as deepMergeRuntimeFields, Dn as CommentUpdateSchema, Dt as refreshTrackedCommentAliases, E as createAbortError, Et as listUpdatingCommunities, Fr as parsedType, H as isIpns, Ir as stringifyPrimitive, It as require_sha256, L as hideClassPrivateProps, Lt as TimeoutError, Pr as joinValues, Pt as untrackUpdatingComment, Q as isStringDomain, Qt as CommunityAnchorSchema, R as ipnsNameToIpnsOverPubsubTopic, Rt as pTimeout, St as findUpdatingComment, Tt as listUpdatingComments, Zn as n$2, _t as timestamp, a as ChallengeRequestMessageSchema, ar as r, b as areEquivalentCommunityAddresses, br as logger_default, ct as resolveWhenPredicateIsTrue, fr as require_retry, ft as shortifyAddress, jt as trackUpdatingComment, k as doesDomainAddressHaveCapitalLetter, ln as PubsubTopicSchema, mt as sleepUntilTimeoutOrAbort, nr as e, ot as removeUndefinedValuesRecursively, pr as FailedToFetchCommentIpfsFromGatewaysError, pt as shortifyCid, r as ChallengeMessageSchema, rn as CommunityIpfsSchema, rr as e$1, s as ChallengeVerificationMessageSchema, st as replaceXWithY, t as ChallengeAnswerMessageSchema, tr as t$1, ut as retryKuboIpfsAdd, vr as PKCError, vt as waitForUpdateInCommunityInstanceWithErrorAndTimeout, wn as CommentUpdateForChallengeVerificationSchema, wt as listStartedCommunities, xt as findStartedCommunity, y as version_default, yn as CommentIpfsSchema, yr as messages, z as isAbortError } from "./schema-BUUhufdT.js";
3
+ import { $ as applyNameResolvedCacheToCrosspost, At as verifyCommentModeration, B as tryToDeleteCommunitiesThatFailedToBeDeletedBefore, Bn as RpcExportCommunityModLogsParamSchema, Bt as normalizeCreatePublicationAuthor, Cn as parseDecryptedChallengeVerification, Ct as signVote, Dn as parseRpcCommentEventWithPKCErrorIfItFails, Dt as verifyChallengeVerification, E as createKuboRpcClient, En as parsePKCUserOptionsSchemaWithPKCErrorIfItFails, F as listCommunitiesSync, Fn as RpcCidParamSchema, Ft as verifyVote, Gn as RpcFetchCidResultSchema, Gt as normalizeCommunityInputFromCommunity, Hn as RpcExportCommunityParamSchema, Ht as getCommunityAddressFromRecord, I as monitorCommunitiesDirectory, In as RpcCommentRepliesPageParamSchema, It as buildRuntimeAuthor, J as extractCommunityRuntimeFieldsFromParsedPages, Jn as RpcPublishedAnchorRecordResultSchema, Jt as getBufferedPKCAddressFromPublicKey, Kn as RpcPublishAnchorRecordParamSchema, Kt as decode, Ln as RpcCommunityIdentifierParamSchema, Lt as cleanWireAuthor, M as getDefaultDataPath, Mn as RpcAnchorPublishPreparationResultSchema, Mt as verifyCommentUpdate, Nn as RpcAuthorNameParamSchema, On as parseRpcCommentUpdateEventWithPKCErrorIfItFails, Ot as verifyCommentEdit, Pn as RpcCancelExportParamSchema, Pt as verifyCommunityEdit, Q as RepliesPages, Qn as RpcUnsubscribeParamSchema, Rn as RpcCommunityPageParamSchema, Rt as getAuthorNameFromRuntime, Sn as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, St as signCommunityEdit, Tn as parseJsonWithPKCErrorIfFails, Tt as verifyChallengeMessage, Un as RpcExportCommunityResultSchema, Ut as getCommunityNameFromWire, V as CommentClientsManager, Vn as RpcExportCommunityModLogsResultSchema, Vt as buildRuntimeCommunityFields, Wn as RpcFetchCidParamSchema, Wt as getCommunityPublicKeyFromWire, Xn as RpcSubscriptionIdResultSchema, Y as findCommentInPageInstanceRecursively, Yn as RpcResolveAuthorNameResultSchema, Z as parseRawPages, Zn as RpcSuccessResultSchema, Zt as getPKCAddressFromPublicKeySync, _ as createAnchorIpnsRecord$1, _t as signCommentEdit, a as pkcJsChallenges, ar as n$3, at as PKCClientsManager, b as encryptEd25519AesGcm, bn as parseCreateRpcCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, c as RemoteCommunity, cn as parseCommunityAddressWithPKCErrorIfItFails, cr as t$5, d as decodeRpcChallengeAnswerPubsubMsg, dn as parseCommunityEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, dt as cleanUpBeforePublishing, en as parseCidStringSchemaWithPKCErrorIfItFails, et as cloneCrosspostForRuntime, f as decodeRpcChallengePubsubMsg, fr as nativeFunctions$2, ft as signChallengeAnswer, g as createSigner, gn as parseCreateCommunityEditPublicationOptionsSchemaWithPKCErrorIfItFails, gt as signComment, hn as parseCreateCommentOptionsSchemaWithPKCErrorIfItFails, in as parseCommentIpfsSchemaWithPKCErrorIfItFails, ir as t$3, it as PublicationClientsManager, jn as parseVotePubsubMessagePublicationSchemaWithPKCErrorIfItFails, jt as verifyCommentPubsubMessage, kn as parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, kt as verifyCommentIpfs, lt as PKCTypedEmitter, m as decodeRpcChallengeVerificationPubsubMsg, mn as parseCreateCommentModerationOptionsSchemaWithPKCErrorIfItFails, mt as signChallengeRequest, n as RpcRemoteCommunity, o as TrackedInstanceRegistry, on as parseCommentModerationPubsubMessagePublicationSchemaWithPKCErrorIfItFails, ot as InflightFetchManager, p as decodeRpcChallengeRequestPubsubMsg, pn as parseCreateCommentEditOptionsSchemaWithPKCErrorIfItFails, pr as require_undici, qn as RpcPublishChallengeAnswersParamSchema, rn as parseCommentEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, rt as stripNameResolvedFromCrosspost, s as LRUCache, sn as parseCommentPubsubMessagePublicationWithPKCErrorIfItFails, sr as t$2, t as RpcLocalCommunity, tr as t$4, tt as collectCrosspostAuthorsToResolve, u as KeyvBetterSqlite3, ut as require_lib$1, v as decryptEd25519AesGcm, vt as signCommentModeration, wn as parseDecryptedChallengeWithPKCErrorIfItFails, xn as parseCreateVoteOptionsSchemaWithPKCErrorIfItFails, yn as parseCreateRemoteCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, z as setNativeFunctions$1, zn as RpcEditCommunityParamSchema } from "./rpc-local-community-0XmKyOdO.js";
4
+ import { o as getHeliaDebugContext } from "./util-Cct7-RT3.js";
5
5
  import path from "path";
6
6
  import assert from "assert";
7
7
  import fs from "fs";
@@ -637,17 +637,24 @@ var Publication = class extends import_lib.TypedEmitter {
637
637
  if (cachedCommunity) {
638
638
  if (!this._pkc._memCaches.communityForPublishing.has(this.communityAddress)) {
639
639
  log("The cache of community is stale, we will use the cached and update in the background");
640
- this._pkc.getCommunity({
640
+ const refresh = this._pkc.getCommunity({
641
641
  publicKey: this.communityPublicKey,
642
642
  name: this.communityName
643
- }).catch((e) => log.error("Failed to update cache of community", this.communityAddress, e));
643
+ }).catch((e) => log.error("Failed to update cache of community", this.communityAddress, e)).finally(() => {
644
+ if (this._backgroundCommunityRefresh === refresh) this._backgroundCommunityRefresh = void 0;
645
+ });
646
+ this._backgroundCommunityRefresh = refresh;
644
647
  }
645
648
  return cachedCommunity;
646
649
  } else return this._clientsManager.fetchCommunityForPublishingWithCacheGuard();
647
650
  }
648
651
  async stop() {
649
- await this._postSucessOrFailurePublishing();
650
- this._updatePublishingStateWithEmission("stopped");
652
+ try {
653
+ await this._postSucessOrFailurePublishing();
654
+ } finally {
655
+ if (this._backgroundCommunityRefresh) await this._backgroundCommunityRefresh;
656
+ this._updatePublishingStateWithEmission("stopped");
657
+ }
651
658
  }
652
659
  _isAllAttemptsExhausted(maxNumOfChallengeExchanges) {
653
660
  if (Object.keys(this._challengeExchanges).length !== maxNumOfChallengeExchanges) return false;
@@ -656,8 +663,26 @@ var Publication = class extends import_lib.TypedEmitter {
656
663
  return typeof exchange.challengeRequestPublishTimestamp === "number" && exchange.challengeRequestPublishTimestamp + this._setProviderFailureThresholdSeconds <= timestamp();
657
664
  });
658
665
  }
666
+ async _abandonProviderIfStoppedWhileSubscribing(providerUrl) {
667
+ if (!this._pkc.destroyed && this.state !== "stopped") return false;
668
+ const log = logger_default("pkc-js:publication:publish:_abandonProviderIfStoppedWhileSubscribing");
669
+ log("Publication was stopped while subscribing to pubsub, will not publish a challenge request", providerUrl);
670
+ try {
671
+ await this._clientsManager.pubsubUnsubscribeOnProvider(this._communityChallengePubsubExchangeTopic(), providerUrl, this._handleChallengeExchange);
672
+ } catch (e) {
673
+ log.error("Failed to undo the pubsub subscription that resolved after being stopped", providerUrl, e);
674
+ }
675
+ this._updatePubsubState("stopped", providerUrl);
676
+ return true;
677
+ }
678
+ _unregisterFromPkcOncePublishWorkSettles() {
679
+ const refresh = this._backgroundCommunityRefresh;
680
+ if (refresh) refresh.finally(() => this._pkc._publishingPublications.delete(this));
681
+ else this._pkc._publishingPublications.delete(this);
682
+ }
659
683
  async _postSucessOrFailurePublishing() {
660
684
  const log = logger_default("pkc-js:publication:_postSucessOrFailurePublishing");
685
+ this._unregisterFromPkcOncePublishWorkSettles();
661
686
  this._setStateWithEmission("stopped");
662
687
  if (this._rpcPublishSubscriptionId) {
663
688
  try {
@@ -877,6 +902,7 @@ var Publication = class extends import_lib.TypedEmitter {
877
902
  this._updatePubsubState("subscribing-pubsub", providerUrl);
878
903
  try {
879
904
  await this._clientsManager.pubsubSubscribeOnProvider(this._communityChallengePubsubExchangeTopic(), this._handleChallengeExchange, providerUrl);
905
+ if (await this._abandonProviderIfStoppedWhileSubscribing(providerUrl)) return;
880
906
  this._updatePubsubState("publishing-challenge-request", providerUrl);
881
907
  await this._clientsManager.pubsubPublishOnProvider(this._communityChallengePubsubExchangeTopic(), challengeRequest, providerUrl);
882
908
  this._challengeExchanges[challengeRequest.challengeRequestId.toString()].challengeRequestPublishTimestamp = timestamp();
@@ -958,8 +984,17 @@ var Publication = class extends import_lib.TypedEmitter {
958
984
  });
959
985
  }
960
986
  async publish() {
961
- const log = logger_default("pkc-js:publication:publish");
962
987
  this._validatePublicationFields();
988
+ this._pkc._publishingPublications.add(this);
989
+ try {
990
+ return await this._publishAfterRegistering();
991
+ } catch (e) {
992
+ this._unregisterFromPkcOncePublishWorkSettles();
993
+ throw e;
994
+ }
995
+ }
996
+ async _publishAfterRegistering() {
997
+ const log = logger_default("pkc-js:publication:publish");
963
998
  this._setStateWithEmission("publishing");
964
999
  await this._initCommunity();
965
1000
  if (this.raw.unsignedPublicationOptions && !this.raw.pubsubMessageToPublish) await this._signPublicationWithCommunityFields();
@@ -998,6 +1033,7 @@ var Publication = class extends import_lib.TypedEmitter {
998
1033
  this._updatePubsubState("subscribing-pubsub", providerUrl);
999
1034
  try {
1000
1035
  await this._clientsManager.pubsubSubscribeOnProvider(this._communityChallengePubsubExchangeTopic(), this._handleChallengeExchange, providerUrl);
1036
+ if (await this._abandonProviderIfStoppedWhileSubscribing(providerUrl)) return;
1001
1037
  this._updatePubsubState("publishing-challenge-request", providerUrl);
1002
1038
  await this._clientsManager.pubsubPublishOnProvider(this._communityChallengePubsubExchangeTopic(), challengeRequest, providerUrl);
1003
1039
  this._challengeExchanges[challengeRequest.challengeRequestId.toString()].challengeRequestPublishTimestamp = timestamp();
@@ -1105,6 +1141,7 @@ var Comment = class extends Publication {
1105
1141
  this.nsfw = o.nsfw;
1106
1142
  this.flairs = o.flairs;
1107
1143
  this.quotedCids = o.quotedCids;
1144
+ this.crosspost = o.crosspost ? cloneCrosspostForRuntime(o.crosspost) : void 0;
1108
1145
  }
1109
1146
  _initLocalProps(props) {
1110
1147
  this._initPubsubMessageProps(props.comment);
@@ -1134,6 +1171,10 @@ var Comment = class extends Publication {
1134
1171
  this._setAuthorNameResolvedFromCache();
1135
1172
  }
1136
1173
  _setAuthorNameResolvedFromCache() {
1174
+ if (this.crosspost) applyNameResolvedCacheToCrosspost({
1175
+ crosspost: this.crosspost,
1176
+ cache: this._pkc._memCaches.nameResolvedCache
1177
+ });
1137
1178
  const domain = getAuthorNameFromRuntime(this.author);
1138
1179
  if (!domain) return;
1139
1180
  const cached = this._pkc._memCaches.nameResolvedCache.get((0, import_sha256.sha256)(domain + this.signature.publicKey));
@@ -1160,14 +1201,19 @@ var Comment = class extends Publication {
1160
1201
  });
1161
1202
  }
1162
1203
  }
1163
- if (ownAuthor.length === 0 && replyAuthors.length === 0) return;
1204
+ const crosspostAuthors = this.crosspost ? collectCrosspostAuthorsToResolve({ crosspost: this.crosspost }) : [];
1205
+ if (ownAuthor.length === 0 && replyAuthors.length === 0 && crosspostAuthors.length === 0) return;
1164
1206
  const previousNameResolved = this.author.nameResolved;
1165
1207
  const onResolved = () => {
1208
+ const crosspostChanged = this.crosspost ? applyNameResolvedCacheToCrosspost({
1209
+ crosspost: this.crosspost,
1210
+ cache: this._pkc._memCaches.nameResolvedCache
1211
+ }) : false;
1166
1212
  this._setAuthorNameResolvedFromCache();
1167
1213
  if (this.replies?.pages) {
1168
1214
  for (const page of Object.values(this.replies.pages)) if (page) this.replies._applyNameResolvedCacheToPage(page);
1169
1215
  }
1170
- if (this.author.nameResolved !== previousNameResolved) this.emit("update", this);
1216
+ if (this.author.nameResolved !== previousNameResolved || crosspostChanged) this.emit("update", this);
1171
1217
  };
1172
1218
  const abortSignal = this._getStopAbortSignal();
1173
1219
  if (ownAuthor.length > 0) this._clientsManager.resolveAuthorNamesInBackground({
@@ -1175,8 +1221,8 @@ var Comment = class extends Publication {
1175
1221
  onResolved,
1176
1222
  abortSignal
1177
1223
  });
1178
- if (replyAuthors.length > 0) this._pkc._clientsManager.resolveAuthorNamesInBackground({
1179
- authors: replyAuthors,
1224
+ if (replyAuthors.length > 0 || crosspostAuthors.length > 0) this._pkc._clientsManager.resolveAuthorNamesInBackground({
1225
+ authors: [...replyAuthors, ...crosspostAuthors],
1180
1226
  onResolved,
1181
1227
  abortSignal
1182
1228
  });
@@ -1194,6 +1240,7 @@ var Comment = class extends Publication {
1194
1240
  this.title = props.title;
1195
1241
  this.linkHtmlTagName = props.linkHtmlTagName;
1196
1242
  this.quotedCids = props.quotedCids;
1243
+ this.crosspost = props.crosspost ? cloneCrosspostForRuntime(props.crosspost) : void 0;
1197
1244
  if ("depth" in props && typeof props.depth === "number") {
1198
1245
  this.depth = props.depth;
1199
1246
  const postCid = props.postCid ? props.postCid : this.cid && this.depth === 0 ? this.cid : void 0;
@@ -6761,6 +6808,7 @@ var PKC$1 = class extends PKCTypedEmitter {
6761
6808
  this._updatingCommunities = new TrackedInstanceRegistry();
6762
6809
  this._updatingComments = new TrackedInstanceRegistry();
6763
6810
  this._startedCommunities = new TrackedInstanceRegistry();
6811
+ this._publishingPublications = /* @__PURE__ */ new Set();
6764
6812
  this.destroyed = false;
6765
6813
  this._storageLRUs = {};
6766
6814
  this._timeouts = {
@@ -6880,7 +6928,7 @@ var PKC$1 = class extends PKCTypedEmitter {
6880
6928
  this.clients.libp2pJsClients = {};
6881
6929
  if (!this.libp2pJsClientsOptions) return;
6882
6930
  if (!this.httpRoutersOptions) throw Error("httpRoutersOptions is required for libp2pJsClient");
6883
- const { createLibp2pJsClientOrUseExistingOne } = await import("./helia-for-pkc-BcNF-orO.js");
6931
+ const { createLibp2pJsClientOrUseExistingOne } = await import("./helia-for-pkc-CQY3-UYD.js");
6884
6932
  for (const clientOptions of this.libp2pJsClientsOptions) {
6885
6933
  const heliaNode = await createLibp2pJsClientOrUseExistingOne({
6886
6934
  ...clientOptions,
@@ -6980,6 +7028,7 @@ var PKC$1 = class extends PKCTypedEmitter {
6980
7028
  }
6981
7029
  if (e$1(cleanedAuthor)) cleanedAuthor = void 0;
6982
7030
  }
7031
+ if ("crosspost" in finalOptions && finalOptions.crosspost) stripNameResolvedFromCrosspost(finalOptions.crosspost);
6983
7032
  const filledTimestamp = typeof finalOptions.timestamp !== "number" ? timestamp() : finalOptions.timestamp;
6984
7033
  const filledSigner = await this.createSigner(finalOptions.signer);
6985
7034
  const filledProtocolVersion = finalOptions.protocolVersion || version_default.PROTOCOL_VERSION;
@@ -7028,6 +7077,7 @@ var PKC$1 = class extends PKCTypedEmitter {
7028
7077
  if ("commentUpdateFromChallengeVerification" in options.raw && options.raw.commentUpdateFromChallengeVerification) commentInstance._initCommentUpdateFromChallengeVerificationProps(options.raw.commentUpdateFromChallengeVerification);
7029
7078
  if (options.raw.commentUpdate) commentInstance._initCommentUpdate(options.raw.commentUpdate);
7030
7079
  if (commentInstance.author?.nameResolved !== void 0) delete commentInstance.author.nameResolved;
7080
+ if (commentInstance.crosspost) stripNameResolvedFromCrosspost(commentInstance.crosspost);
7031
7081
  return commentInstance;
7032
7082
  }
7033
7083
  async createComment(options) {
@@ -7046,6 +7096,7 @@ var PKC$1 = class extends PKCTypedEmitter {
7046
7096
  if (!("signature" in options)) Object.assign(commentInstance, options);
7047
7097
  else commentInstance._initIpfsProps(parseCommentIpfsSchemaWithPKCErrorIfItFails(commentIpfs));
7048
7098
  if (commentInstance.author?.nameResolved !== void 0) delete commentInstance.author.nameResolved;
7099
+ if (commentInstance.crosspost) stripNameResolvedFromCrosspost(commentInstance.crosspost);
7049
7100
  } else if ("signature" in options) {
7050
7101
  const parsedOptions = parseCommentPubsubMessagePublicationWithPKCErrorIfItFails(options);
7051
7102
  commentInstance._initPubsubMessageProps(parsedOptions);
@@ -7125,7 +7176,7 @@ var PKC$1 = class extends PKCTypedEmitter {
7125
7176
  const log = logger_default("pkc-js:pkc:createLocalCommunity");
7126
7177
  log.trace("Received community options to create a local community instance:", options);
7127
7178
  if (!this._canCreateNewLocalCommunity()) throw new PKCError("ERR_CAN_NOT_CREATE_A_LOCAL_COMMUNITY", { pkcOptions: this._userPKCOptions });
7128
- const { LocalCommunity, createNewLocalCommunityDb, updateInstancePropsWithStartedCommunityOrDb } = await import("./local-community-B6-jaMsn.js");
7179
+ const { LocalCommunity, createNewLocalCommunityDb, updateInstancePropsWithStartedCommunityOrDb } = await import("./local-community-AZAEiiht.js");
7129
7180
  const isLocalCommunity = (await listCommunitiesSync(this)).includes(options.address);
7130
7181
  const community = new LocalCommunity(this);
7131
7182
  if (isLocalCommunity) {
@@ -7499,6 +7550,8 @@ var PKC$1 = class extends PKCTypedEmitter {
7499
7550
  }
7500
7551
  }
7501
7552
  if (exportDonePromises.length) await Promise.all(exportDonePromises);
7553
+ await Promise.all([...this._publishingPublications].map((publication) => publication.stop().catch((e) => log.error("Error stopping publication during destroy", e))));
7554
+ this._publishingPublications.clear();
7502
7555
  for (const comment of listUpdatingComments(this)) await comment.stop();
7503
7556
  for (const community of listUpdatingCommunities(this)) await community.stop();
7504
7557
  await Promise.all(listStartedCommunities(this).map((community) => community.stop()));