@pkcprotocol/pkc-js 0.0.102 → 0.0.104

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 (140) hide show
  1. package/README.md +35 -8
  2. package/dist/browser/clients/base-client-manager.d.ts +1 -0
  3. package/dist/browser/clients/base-client-manager.js +72 -11
  4. package/dist/browser/clients/base-client-manager.js.map +1 -1
  5. package/dist/browser/community/community-client-manager.d.ts +3 -0
  6. package/dist/browser/community/community-client-manager.js +87 -14
  7. package/dist/browser/community/community-client-manager.js.map +1 -1
  8. package/dist/browser/community/remote-community.js +3 -0
  9. package/dist/browser/community/remote-community.js.map +1 -1
  10. package/dist/browser/community/schema.d.ts +4 -0
  11. package/dist/browser/community/schema.js +7 -1
  12. package/dist/browser/community/schema.js.map +1 -1
  13. package/dist/browser/constants.d.ts +3 -0
  14. package/dist/browser/constants.js +35 -0
  15. package/dist/browser/constants.js.map +1 -1
  16. package/dist/browser/errors.d.ts +5 -1
  17. package/dist/browser/errors.js +7 -1
  18. package/dist/browser/errors.js.map +1 -1
  19. package/dist/browser/generated-version.d.ts +1 -1
  20. package/dist/browser/generated-version.js +1 -1
  21. package/dist/browser/index-with-compile-cache.d.ts +2 -0
  22. package/dist/browser/index.d.ts +2 -0
  23. package/dist/browser/pkc/pkc.d.ts +4 -0
  24. package/dist/browser/pkc/pkc.js +30 -1
  25. package/dist/browser/pkc/pkc.js.map +1 -1
  26. package/dist/browser/pkc-error.d.ts +1 -1
  27. package/dist/browser/publications/comment/comment-client-manager.js +11 -0
  28. package/dist/browser/publications/comment/comment-client-manager.js.map +1 -1
  29. package/dist/browser/publications/comment/comment.js +8 -6
  30. package/dist/browser/publications/comment/comment.js.map +1 -1
  31. package/dist/browser/publications/comment/crosspost-runtime.js +3 -2
  32. package/dist/browser/publications/comment/crosspost-runtime.js.map +1 -1
  33. package/dist/browser/rpc/src/index.js +6 -0
  34. package/dist/browser/rpc/src/index.js.map +1 -1
  35. package/dist/browser/rpc/src/lib/pkc-js/index.d.ts +1 -0
  36. package/dist/browser/rpc/src/schema.d.ts +6 -0
  37. package/dist/browser/runtime/node/community/challenges/exclude/exclude.d.ts +11 -1
  38. package/dist/browser/runtime/node/community/challenges/exclude/exclude.js +32 -21
  39. package/dist/browser/runtime/node/community/challenges/exclude/exclude.js.map +1 -1
  40. package/dist/browser/runtime/node/community/challenges/index.d.ts +10 -3
  41. package/dist/browser/runtime/node/community/challenges/index.js +82 -16
  42. package/dist/browser/runtime/node/community/challenges/index.js.map +1 -1
  43. package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/blacklist.js +7 -4
  44. package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/blacklist.js.map +1 -1
  45. package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/whitelist.js +13 -5
  46. package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/whitelist.js.map +1 -1
  47. package/dist/browser/runtime/node/community/local-community/author-identity.d.ts +37 -2
  48. package/dist/browser/runtime/node/community/local-community/author-identity.js +73 -13
  49. package/dist/browser/runtime/node/community/local-community/author-identity.js.map +1 -1
  50. package/dist/browser/runtime/node/community/local-community/challenges.d.ts +16 -2
  51. package/dist/browser/runtime/node/community/local-community/challenges.js +40 -9
  52. package/dist/browser/runtime/node/community/local-community/challenges.js.map +1 -1
  53. package/dist/browser/runtime/node/community/local-community/editing.js +7 -2
  54. package/dist/browser/runtime/node/community/local-community/editing.js.map +1 -1
  55. package/dist/browser/runtime/node/community/local-community/publication-store.d.ts +13 -2
  56. package/dist/browser/runtime/node/community/local-community/publication-store.js +29 -7
  57. package/dist/browser/runtime/node/community/local-community/publication-store.js.map +1 -1
  58. package/dist/browser/runtime/node/community/local-community/publication-validation.d.ts +13 -3
  59. package/dist/browser/runtime/node/community/local-community/publication-validation.js +63 -28
  60. package/dist/browser/runtime/node/community/local-community/publication-validation.js.map +1 -1
  61. package/dist/browser/runtime/node/community/local-community.d.ts +2 -2
  62. package/dist/browser/runtime/node/community/local-community.js +6 -4
  63. package/dist/browser/runtime/node/community/local-community.js.map +1 -1
  64. package/dist/browser/schema.d.ts +8 -0
  65. package/dist/browser/types.d.ts +1 -0
  66. package/dist/bundled/bundle-manifest.json +26 -26
  67. package/dist/bundled/chunks/{helia-for-pkc-ZbhRl9a-.js → helia-for-pkc-CQM2gwO-.js} +2 -2
  68. package/dist/bundled/chunks/{local-community-Cu95rtju.js → local-community-CaK2PibY.js} +1 -1
  69. package/dist/bundled/chunks/{local-community-L-1IkV1x.js → local-community-Cad8EnIh.js} +160 -61
  70. package/dist/bundled/chunks/{node-DaN6R9HB.js → node-C6LbmJAq.js} +19 -8
  71. package/dist/bundled/chunks/{rpc-local-community-aV790d8_.js → rpc-local-community-Dciiw7xH.js} +275 -103
  72. package/dist/bundled/chunks/{schema-gif6qroG.js → schema-CRAfzWYa.js} +8 -3
  73. package/dist/bundled/chunks/{util-BsJoElMm.js → util-BWhDfSw9.js} +1 -1
  74. package/dist/bundled/index.js +1 -1
  75. package/dist/bundled/rpc/src/index.js +9 -4
  76. package/dist/node/clients/base-client-manager.d.ts +1 -0
  77. package/dist/node/clients/base-client-manager.js +72 -11
  78. package/dist/node/clients/base-client-manager.js.map +1 -1
  79. package/dist/node/community/community-client-manager.d.ts +3 -0
  80. package/dist/node/community/community-client-manager.js +87 -14
  81. package/dist/node/community/community-client-manager.js.map +1 -1
  82. package/dist/node/community/remote-community.js +3 -0
  83. package/dist/node/community/remote-community.js.map +1 -1
  84. package/dist/node/community/schema.d.ts +4 -0
  85. package/dist/node/community/schema.js +7 -1
  86. package/dist/node/community/schema.js.map +1 -1
  87. package/dist/node/constants.d.ts +3 -0
  88. package/dist/node/constants.js +35 -0
  89. package/dist/node/constants.js.map +1 -1
  90. package/dist/node/errors.d.ts +5 -1
  91. package/dist/node/errors.js +7 -1
  92. package/dist/node/errors.js.map +1 -1
  93. package/dist/node/generated-version.d.ts +1 -1
  94. package/dist/node/generated-version.js +1 -1
  95. package/dist/node/index-with-compile-cache.d.ts +2 -0
  96. package/dist/node/index.d.ts +2 -0
  97. package/dist/node/pkc/pkc.d.ts +4 -0
  98. package/dist/node/pkc/pkc.js +30 -1
  99. package/dist/node/pkc/pkc.js.map +1 -1
  100. package/dist/node/pkc-error.d.ts +1 -1
  101. package/dist/node/publications/comment/comment-client-manager.js +11 -0
  102. package/dist/node/publications/comment/comment-client-manager.js.map +1 -1
  103. package/dist/node/publications/comment/comment.js +8 -6
  104. package/dist/node/publications/comment/comment.js.map +1 -1
  105. package/dist/node/publications/comment/crosspost-runtime.js +3 -2
  106. package/dist/node/publications/comment/crosspost-runtime.js.map +1 -1
  107. package/dist/node/rpc/src/index.js +6 -0
  108. package/dist/node/rpc/src/index.js.map +1 -1
  109. package/dist/node/rpc/src/lib/pkc-js/index.d.ts +1 -0
  110. package/dist/node/rpc/src/schema.d.ts +6 -0
  111. package/dist/node/runtime/node/community/challenges/exclude/exclude.d.ts +11 -1
  112. package/dist/node/runtime/node/community/challenges/exclude/exclude.js +32 -21
  113. package/dist/node/runtime/node/community/challenges/exclude/exclude.js.map +1 -1
  114. package/dist/node/runtime/node/community/challenges/index.d.ts +10 -3
  115. package/dist/node/runtime/node/community/challenges/index.js +82 -16
  116. package/dist/node/runtime/node/community/challenges/index.js.map +1 -1
  117. package/dist/node/runtime/node/community/challenges/pkc-js-challenges/blacklist.js +7 -4
  118. package/dist/node/runtime/node/community/challenges/pkc-js-challenges/blacklist.js.map +1 -1
  119. package/dist/node/runtime/node/community/challenges/pkc-js-challenges/whitelist.js +13 -5
  120. package/dist/node/runtime/node/community/challenges/pkc-js-challenges/whitelist.js.map +1 -1
  121. package/dist/node/runtime/node/community/local-community/author-identity.d.ts +37 -2
  122. package/dist/node/runtime/node/community/local-community/author-identity.js +73 -13
  123. package/dist/node/runtime/node/community/local-community/author-identity.js.map +1 -1
  124. package/dist/node/runtime/node/community/local-community/challenges.d.ts +16 -2
  125. package/dist/node/runtime/node/community/local-community/challenges.js +40 -9
  126. package/dist/node/runtime/node/community/local-community/challenges.js.map +1 -1
  127. package/dist/node/runtime/node/community/local-community/editing.js +7 -2
  128. package/dist/node/runtime/node/community/local-community/editing.js.map +1 -1
  129. package/dist/node/runtime/node/community/local-community/publication-store.d.ts +13 -2
  130. package/dist/node/runtime/node/community/local-community/publication-store.js +29 -7
  131. package/dist/node/runtime/node/community/local-community/publication-store.js.map +1 -1
  132. package/dist/node/runtime/node/community/local-community/publication-validation.d.ts +13 -3
  133. package/dist/node/runtime/node/community/local-community/publication-validation.js +63 -28
  134. package/dist/node/runtime/node/community/local-community/publication-validation.js.map +1 -1
  135. package/dist/node/runtime/node/community/local-community.d.ts +2 -2
  136. package/dist/node/runtime/node/community/local-community.js +6 -4
  137. package/dist/node/runtime/node/community/local-community.js.map +1 -1
  138. package/dist/node/schema.d.ts +8 -0
  139. package/dist/node/types.d.ts +1 -0
  140. package/package.json +1 -1
@@ -14,7 +14,7 @@
14
14
  "node:module"
15
15
  ],
16
16
  "dynamicImports": [
17
- "chunks/node-DaN6R9HB.js"
17
+ "chunks/node-C6LbmJAq.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-DaN6R9HB.js"
27
+ "chunks/node-C6LbmJAq.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-aV790d8_.js",
36
- "chunks/node-DaN6R9HB.js",
37
- "chunks/schema-gif6qroG.js",
38
- "chunks/local-community-L-1IkV1x.js",
35
+ "chunks/rpc-local-community-Dciiw7xH.js",
36
+ "chunks/node-C6LbmJAq.js",
37
+ "chunks/schema-CRAfzWYa.js",
38
+ "chunks/local-community-Cad8EnIh.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-ZbhRl9a-.js": {
68
+ "chunks/helia-for-pkc-CQM2gwO-.js": {
69
69
  "isEntry": false,
70
70
  "imports": [
71
71
  "chunks/chunk-2rV9d50f.js",
72
- "chunks/schema-gif6qroG.js",
73
- "chunks/util-BsJoElMm.js",
72
+ "chunks/schema-CRAfzWYa.js",
73
+ "chunks/util-BWhDfSw9.js",
74
74
  "chunks/src-DKntVmyX.js",
75
75
  "chunks/src-Cpx2Sts8.js",
76
76
  "node:url",
@@ -187,20 +187,20 @@
187
187
  "dist/node/helia/helia-for-pkc.js"
188
188
  ]
189
189
  },
190
- "chunks/local-community-Cu95rtju.js": {
190
+ "chunks/local-community-CaK2PibY.js": {
191
191
  "isEntry": false,
192
192
  "imports": [
193
- "chunks/local-community-L-1IkV1x.js"
193
+ "chunks/local-community-Cad8EnIh.js"
194
194
  ],
195
195
  "dynamicImports": [],
196
196
  "inputs": []
197
197
  },
198
- "chunks/local-community-L-1IkV1x.js": {
198
+ "chunks/local-community-Cad8EnIh.js": {
199
199
  "isEntry": false,
200
200
  "imports": [
201
201
  "chunks/chunk-2rV9d50f.js",
202
- "chunks/rpc-local-community-aV790d8_.js",
203
- "chunks/schema-gif6qroG.js",
202
+ "chunks/rpc-local-community-Dciiw7xH.js",
203
+ "chunks/schema-CRAfzWYa.js",
204
204
  "node:crypto",
205
205
  "node:url",
206
206
  "node:path",
@@ -257,13 +257,13 @@
257
257
  "dist/node/runtime/node/community/local-community.js"
258
258
  ]
259
259
  },
260
- "chunks/node-DaN6R9HB.js": {
260
+ "chunks/node-C6LbmJAq.js": {
261
261
  "isEntry": false,
262
262
  "imports": [
263
263
  "chunks/chunk-2rV9d50f.js",
264
- "chunks/rpc-local-community-aV790d8_.js",
265
- "chunks/schema-gif6qroG.js",
266
- "chunks/util-BsJoElMm.js",
264
+ "chunks/rpc-local-community-Dciiw7xH.js",
265
+ "chunks/schema-CRAfzWYa.js",
266
+ "chunks/util-BWhDfSw9.js",
267
267
  "path",
268
268
  "assert",
269
269
  "fs",
@@ -274,8 +274,8 @@
274
274
  "rpc-websockets"
275
275
  ],
276
276
  "dynamicImports": [
277
- "chunks/helia-for-pkc-ZbhRl9a-.js",
278
- "chunks/local-community-L-1IkV1x.js"
277
+ "chunks/helia-for-pkc-CQM2gwO-.js",
278
+ "chunks/local-community-Cad8EnIh.js"
279
279
  ],
280
280
  "inputs": [
281
281
  "node_modules/zod/v4/locales/en.js",
@@ -317,11 +317,11 @@
317
317
  "dist/node/index.js"
318
318
  ]
319
319
  },
320
- "chunks/rpc-local-community-aV790d8_.js": {
320
+ "chunks/rpc-local-community-Dciiw7xH.js": {
321
321
  "isEntry": false,
322
322
  "imports": [
323
323
  "chunks/chunk-2rV9d50f.js",
324
- "chunks/schema-gif6qroG.js",
324
+ "chunks/schema-CRAfzWYa.js",
325
325
  "chunks/src-CYIMjhjK.js",
326
326
  "node:crypto",
327
327
  "node:url",
@@ -860,9 +860,9 @@
860
860
  "node_modules/limiter-es6-compat/dist/esm/RateLimiter.js",
861
861
  "node_modules/limiter-es6-compat/dist/esm/index.js",
862
862
  "dist/node/runtime/node/community/challenges/exclude/rate-limiter.js",
863
- "dist/node/runtime/node/community/local-community/author-identity.js",
864
863
  "dist/node/runtime/node/community/challenges/exclude/exclude.js",
865
864
  "dist/node/runtime/node/community/challenges/exclude/index.js",
865
+ "dist/node/runtime/node/community/local-community/author-identity.js",
866
866
  "dist/node/runtime/node/community/challenges/pkc-js-challenges/text-math.js",
867
867
  "dist/node/runtime/node/community/challenges/pkc-js-challenges/fail.js",
868
868
  "dist/node/runtime/node/community/challenges/pkc-js-challenges/address-list-validation.js",
@@ -876,7 +876,7 @@
876
876
  "dist/node/community/rpc-local-community.js"
877
877
  ]
878
878
  },
879
- "chunks/schema-gif6qroG.js": {
879
+ "chunks/schema-CRAfzWYa.js": {
880
880
  "isEntry": false,
881
881
  "imports": [
882
882
  "chunks/chunk-2rV9d50f.js",
@@ -1348,10 +1348,10 @@
1348
1348
  "node_modules/ipfs-unixfs-importer/dist/src/index.js"
1349
1349
  ]
1350
1350
  },
1351
- "chunks/util-BsJoElMm.js": {
1351
+ "chunks/util-BWhDfSw9.js": {
1352
1352
  "isEntry": false,
1353
1353
  "imports": [
1354
- "chunks/schema-gif6qroG.js",
1354
+ "chunks/schema-CRAfzWYa.js",
1355
1355
  "ipns/selector",
1356
1356
  "ipns/validator",
1357
1357
  "ipns",
@@ -1,6 +1,6 @@
1
1
  import { i as __toESM, r as __require, t as __commonJSMin } from "./chunk-2rV9d50f.js";
2
- import { B as ipnsNameToIpnsOverPubsubTopic, R as hideClassPrivateProps, Sr as PKCError, wr as logger_default, x as binaryKeyToPubsubTopic } from "./schema-gif6qroG.js";
3
- import { a as fetchBlockWithStalledSessionFailover, c as selectBitswapSessionSeedPeers, i as directFetchIpnsRecordFromProviders, n as cacheIpnsRecordInPubsubLocalStore, o as getHeliaDebugContext, r as connectToPubsubPeers, s as readFreshCachedIpnsRecordFromPubsubLocalStore } from "./util-BsJoElMm.js";
2
+ import { B as ipnsNameToIpnsOverPubsubTopic, R as hideClassPrivateProps, Sr as PKCError, wr as logger_default, x as binaryKeyToPubsubTopic } from "./schema-CRAfzWYa.js";
3
+ import { a as fetchBlockWithStalledSessionFailover, c as selectBitswapSessionSeedPeers, i as directFetchIpnsRecordFromProviders, n as cacheIpnsRecordInPubsubLocalStore, o as getHeliaDebugContext, r as connectToPubsubPeers, s as readFreshCachedIpnsRecordFromPubsubLocalStore } from "./util-BWhDfSw9.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-L-1IkV1x.js";
1
+ import { n as createNewLocalCommunityDb, r as updateInstancePropsWithStartedCommunityOrDb, t as LocalCommunity } from "./local-community-Cad8EnIh.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 { A as doesDomainAddressHaveCapitalLetter, B as ipnsNameToIpnsOverPubsubTopic, Bn as CommentEditPubsubMessagePublicationSchema, C as calculateStringSizeSameAsIpfsAddCidV0, Cn as CommentIpfsSchema, Cr as messages, Ct as findCommunityInRegistry, E as contentContainsMarkdownVideos, Et as findUpdatingCommunity, F as getErrorCodeFromMessage, Ft as trackUpdatingCommunity, Hn as CommentEditReservedFields, I as getIpnsRecordInLocalKuboNode, It as untrackStartedCommunity, J as isLinkOfImage, Jn as AuthorReservedFields, Jt as CommentModerationPubsubMessagePublicationSchema, K as isLinkOfAnimatedImage, Lr as ZodError, Mt as syncCommunityRegistryEntry, N as genToArray, Nn as CommentUpdateTableRowSchema, Nt as trackStartedCommunity, P as getEquivalentCommunityAddresses, Pn as CommentsTableRowSchema, R as hideClassPrivateProps, Rt as untrackUpdatingCommunity, S as calculateIpfsCidV0, Sr as PKCError, St as writeKuboFilesWithTimeout, T as contentContainsMarkdownImages, Ut as CommunityEditPublicationPubsubReservedFields, Vn as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema, Vt as pTimeout, Wn as CommentEditsTableRowSchema, X as isLinkOfVideo, Y as isLinkOfMedia, Yt as CommentModerationReservedFields, Z as isLinkValid, Zt as CommentModerationsTableRowSchema, _n as VotePubsubMessagePublicationSchema, _t as sleepUntilTimeoutOrAbort, a as ChallengeRequestMessageSchema, ar as t$6, at as removeBlocksFromKuboNode, b as areEquivalentCommunityAddresses, bn as VoteTablesRowSchema, bt as timestamp, ct as removeNullUndefinedValues, d as DecryptedChallengeRequestSchema, et as pubsubTopicToDhtKey, ft as retryKuboBlockPutPinAndProvidePubsubTopic, gr as require_retry, ir as t$7, jn as CommentUpdateSchema, k as derivePublicationFromChallengeRequest, lr as r$1, mn as isStringDomain, mr as t$3, mt as retryKuboIpfsAddAndProvide, nr as t$8, on as CommunityIpfsSchema, or as e, ot as removeMfsFilesSafely, pr as t$5, q as isLinkOfAudio, r as ChallengeMessageSchema, rr as n$3, s as ChallengeVerificationMessageSchema, sn as CommunitySignedPropertyNames, sr as e$1, t as ChallengeAnswerMessageSchema, tr as n$4, u as DecryptedChallengeRequestPublicationSchema, ur as t$4, vn as VotePubsubReservedFields, vt as statMfsPathSafely, w as contentContainsMarkdownAudio, wn as CommentPubsubMessageReservedFields, wr as logger_default, wt as findStartedCommunity, y as version_default, zt as require_sha256 } from "./schema-gif6qroG.js";
3
- import { $t as getPKCAddressFromPublicKeySync, A as deriveCommentIpfsFromCommentTableRow, At as verifyCommentEdit, B as resolveDbPostsCidRefs, C as encryptEd25519AesGcmPublicKeyBuffer, Ct as signCommunity, D as calculateInlineRepliesBudget, Dn as parseJsonWithPKCErrorIfFails, E as calculateExpectedSignatureSize, Et as verifyChallengeAnswer, F as getThumbnailPropsOfLink, Ft as verifyCommunity, G as POST_REPLIES_SORT_TYPES, Gt as getCommunityNameFromWire, I as importSignerIntoKuboNode, It as verifyCommunityEdit, Jt as decode, K as REPLY_REPLIES_SORT_TYPES, Kt as getCommunityPublicKeyFromWire, Lt as verifyVote, M as deriveDbReplies, Mt as verifyCommentModeration, N as getDefaultCommunityDbConfig, Nt as verifyCommentPubsubMessage, Ot as verifyChallengeRequest, Pt as verifyCommentUpdate, Q as iterateOverPageCidsToFindAllCids, Qt as getPKCAddressFromPublicKey, Rt as buildRuntimeAuthor, St as signCommentUpdateForChallengeVerification, T as backupCommunityDb, Vt as getAuthorNameFromWire, W as POSTS_SORT_TYPES, Yt as encode, Zt as getIpfsKeyFromPrivateKey, _ as SignerWithPublicKeyAddress, _t as signChallengeVerification, a as loadChallengeFileFromCommunityChallengeSettings, ar as r$2, c as TrackedInstanceRegistry, cr as n$5, d as MAX_FILE_SIZE_BYTES_FOR_COMMUNITY_IPFS, dr as stringify, en as getPublicKeyFromPrivateKey, f as KeyvBetterSqlite3, fn as parseCommunityEditOptionsSchemaWithPKCErrorIfItFails, fr as STORAGE_KEYS, ht as signChallengeMessage, i as getCommunityChallengeFromCommunityChallengeSettings, ir as t$12, j as deriveDbPosts, jt as verifyCommentIpfs, k as deleteOldCommunityInWindows, l as LRUCache, mn as parseCommunityIpfsSchemaPassthroughWithPKCErrorIfItFails, nr as effectiveMaxCrosspostDepth, o as pkcJsChallenges, or as t$11, pr as require_lodash_merge, pt as cleanUpBeforePublishing, q as TIMEFRAMES_TO_SECONDS, r as getChallengeVerification, rr as t$9, s as createAuthorIdentityMatcher, sr as n$6, t as RpcLocalCommunity, tn as createSchemaRowParser, tr as crosspostChainDepthUpTo, ur as t$10, ut as pLimit, vt as signComment, w as BackupAbortError, wn as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, x as decryptEd25519AesGcmPublicKeyBuffer, xt as signCommentUpdate, yt as signCommentEdit, z as moveCommunityDbToDeletedDirectory, zt as cleanWireAuthor } from "./rpc-local-community-aV790d8_.js";
2
+ import { A as doesDomainAddressHaveCapitalLetter, B as ipnsNameToIpnsOverPubsubTopic, Bn as CommentEditPubsubMessagePublicationSchema, C as calculateStringSizeSameAsIpfsAddCidV0, Cn as CommentIpfsSchema, Cr as messages, Ct as findCommunityInRegistry, E as contentContainsMarkdownVideos, Et as findUpdatingCommunity, F as getErrorCodeFromMessage, Ft as trackUpdatingCommunity, Hn as CommentEditReservedFields, I as getIpnsRecordInLocalKuboNode, It as untrackStartedCommunity, J as isLinkOfImage, Jn as AuthorReservedFields, Jt as CommentModerationPubsubMessagePublicationSchema, K as isLinkOfAnimatedImage, Lr as ZodError, Mt as syncCommunityRegistryEntry, N as genToArray, Nn as CommentUpdateTableRowSchema, Nt as trackStartedCommunity, P as getEquivalentCommunityAddresses, Pn as CommentsTableRowSchema, R as hideClassPrivateProps, Rt as untrackUpdatingCommunity, S as calculateIpfsCidV0, Sr as PKCError, St as writeKuboFilesWithTimeout, T as contentContainsMarkdownImages, Ut as CommunityEditPublicationPubsubReservedFields, Vn as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema, Vt as pTimeout, Wn as CommentEditsTableRowSchema, X as isLinkOfVideo, Y as isLinkOfMedia, Yt as CommentModerationReservedFields, Z as isLinkValid, Zt as CommentModerationsTableRowSchema, _n as VotePubsubMessagePublicationSchema, _t as sleepUntilTimeoutOrAbort, a as ChallengeRequestMessageSchema, ar as t$6, at as removeBlocksFromKuboNode, b as areEquivalentCommunityAddresses, bn as VoteTablesRowSchema, bt as timestamp, ct as removeNullUndefinedValues, d as DecryptedChallengeRequestSchema, et as pubsubTopicToDhtKey, ft as retryKuboBlockPutPinAndProvidePubsubTopic, gr as require_retry, ir as t$7, jn as CommentUpdateSchema, k as derivePublicationFromChallengeRequest, lr as r$1, mn as isStringDomain, mr as t$3, mt as retryKuboIpfsAddAndProvide, nr as t$8, on as CommunityIpfsSchema, or as e, ot as removeMfsFilesSafely, pr as t$5, q as isLinkOfAudio, r as ChallengeMessageSchema, rr as n$3, s as ChallengeVerificationMessageSchema, sn as CommunitySignedPropertyNames, sr as e$1, t as ChallengeAnswerMessageSchema, tr as n$4, u as DecryptedChallengeRequestPublicationSchema, ur as t$4, vn as VotePubsubReservedFields, vt as statMfsPathSafely, w as contentContainsMarkdownAudio, wn as CommentPubsubMessageReservedFields, wr as logger_default, wt as findStartedCommunity, y as version_default, zt as require_sha256 } from "./schema-CRAfzWYa.js";
3
+ import { $t as getIpfsKeyFromPrivateKey, At as verifyChallengeRequest, Bt as buildRuntimeAuthor, C as decryptEd25519AesGcmPublicKeyBuffer, Ct as signCommentUpdate, D as backupCommunityDb, E as BackupAbortError, En as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, F as getDefaultCommunityDbConfig, Ft as verifyCommentPubsubMessage, H as resolveDbPostsCidRefs, It as verifyCommentUpdate, J as REPLY_REPLIES_SORT_TYPES, Jt as getCommunityPublicKeyFromWire, K as POSTS_SORT_TYPES, L as getThumbnailPropsOfLink, Lt as verifyCommunity, M as deriveCommentIpfsFromCommentTableRow, Mt as verifyCommentEdit, N as deriveDbPosts, Nt as verifyCommentIpfs, O as calculateExpectedSignatureSize, Ot as verifyChallengeAnswer, P as deriveDbReplies, Pt as verifyCommentModeration, R as importSignerIntoKuboNode, Rt as verifyCommunityEdit, T as encryptEd25519AesGcmPublicKeyBuffer, Tt as signCommunity, Ut as getAuthorNameFromWire, V as moveCommunityDbToDeletedDirectory, Vt as cleanWireAuthor, Xt as decode, Y as TIMEFRAMES_TO_SECONDS, Zt as encode, _r as STORAGE_KEYS, _t as signChallengeMessage, a as loadChallengeFileFromCommunityChallengeSettings, ar as t$9, bt as signComment, c as authorNameResolveFailureReason, cr as t$11, d as LRUCache, en as getPKCAddressFromPublicKey, et as iterateOverPageCidsToFindAllCids, fr as t$10, ft as pLimit, gn as parseCommunityIpfsSchemaPassthroughWithPKCErrorIfItFails, ht as cleanUpBeforePublishing, i as getCommunityChallengeFromCommunityChallengeSettings, ir as effectiveMaxCrosspostDepth, j as deleteOldCommunityInWindows, k as calculateInlineRepliesBudget, kn as parseJsonWithPKCErrorIfFails, l as createAuthorIdentityMatcher, lr as n$6, m as KeyvBetterSqlite3, mn as parseCommunityEditOptionsSchemaWithPKCErrorIfItFails, nn as getPublicKeyFromPrivateKey, o as pkcJsChallenges, or as t$12, p as MAX_FILE_SIZE_BYTES_FOR_COMMUNITY_IPFS, pr as stringify, q as POST_REPLIES_SORT_TYPES, qt as getCommunityNameFromWire, r as getChallengeVerification, rn as createSchemaRowParser, rr as crosspostChainDepthUpTo, s as authorIdentityMatcherForRequest, sr as r$2, t as RpcLocalCommunity, tn as getPKCAddressFromPublicKeySync, u as TrackedInstanceRegistry, ur as n$5, vr as require_lodash_merge, wt as signCommentUpdateForChallengeVerification, xt as signCommentEdit, y as SignerWithPublicKeyAddress, yt as signChallengeVerification, zt as verifyVote } from "./rpc-local-community-Dciiw7xH.js";
4
4
  import { randomFillSync, randomUUID } from "node:crypto";
5
5
  import { fileURLToPath, pathToFileURL } from "node:url";
6
6
  import Path from "node:path";
@@ -831,8 +831,14 @@ async function publishIdempotentDuplicateVerification(community, request, challe
831
831
  delete community._challengeExchangesFromLocalPublishers[challengeRequestId.toString()];
832
832
  cleanUpChallengeAnswerPromise(community, challengeRequestId.toString());
833
833
  }
834
- async function storePublicationAndEncryptForChallengeVerification(community, request, pendingApproval, challengeAggregate) {
835
- const commentAfterAddingToIpfs = await storePublication(community, request, pendingApproval, challengeAggregate);
834
+ async function storePublicationAndEncryptForChallengeVerification({ community, request, pendingApproval, challengeAggregate, authorIdentityMatcher }) {
835
+ const commentAfterAddingToIpfs = await storePublication({
836
+ community,
837
+ request,
838
+ pendingApproval,
839
+ challengeAggregate,
840
+ authorIdentityMatcher
841
+ });
836
842
  if (!commentAfterAddingToIpfs) return void 0;
837
843
  const authorSignerAddress = await getPKCAddressFromPublicKey(commentAfterAddingToIpfs.comment.signature.publicKey);
838
844
  const authorDomain = getAuthorNameFromWire(commentAfterAddingToIpfs.comment.author);
@@ -864,14 +870,20 @@ async function storePublicationAndEncryptForChallengeVerification(community, req
864
870
  encrypted
865
871
  };
866
872
  }
867
- async function publishChallengeVerification(community, challengeResult, request, pendingApproval, challengeAggregate) {
873
+ async function publishChallengeVerification({ community, challengeResult, request, pendingApproval, challengeAggregate, authorIdentityMatcher }) {
868
874
  const log = logger_default("pkc-js:local-community:_publishChallengeVerification");
869
875
  if (!challengeResult.challengeSuccess) return publishFailedChallengeVerification(community, challengeResult, request.challengeRequestId);
870
876
  else {
871
877
  let failureReason;
872
878
  let toEncrypt;
873
879
  try {
874
- toEncrypt = await storePublicationAndEncryptForChallengeVerification(community, request, pendingApproval, challengeAggregate);
880
+ toEncrypt = await storePublicationAndEncryptForChallengeVerification({
881
+ community,
882
+ request,
883
+ pendingApproval,
884
+ challengeAggregate,
885
+ authorIdentityMatcher
886
+ });
875
887
  } catch (e) {
876
888
  const error = e;
877
889
  if (DUPLICATE_PUBLICATION_ERRORS.has(error.message)) {
@@ -1034,7 +1046,17 @@ async function validatePublicationOrRespondWithFailure({ community, decryptedReq
1034
1046
  request: decryptedRequestMsg,
1035
1047
  authorCommunity: communityAuthor
1036
1048
  });
1037
- const publicationInvalidityReason = await checkPublicationValidity(community, decryptedRequestMsg, publication, communityAuthor);
1049
+ const authorIdentityMatcher = createAuthorIdentityMatcher({
1050
+ community,
1051
+ publication
1052
+ });
1053
+ const publicationInvalidityReason = await checkPublicationValidity({
1054
+ community,
1055
+ request: decryptedRequestMsg,
1056
+ publication,
1057
+ authorCommunity: communityAuthor,
1058
+ authorIdentityMatcher
1059
+ });
1038
1060
  if (publicationInvalidityReason) {
1039
1061
  if (DUPLICATE_PUBLICATION_ERRORS.has(publicationInvalidityReason)) {
1040
1062
  const sig = publication.signature.signature;
@@ -1055,11 +1077,12 @@ async function validatePublicationOrRespondWithFailure({ community, decryptedReq
1055
1077
  decryptedRequestMsg,
1056
1078
  decryptedRequestWithCommunityAuthor,
1057
1079
  publication,
1058
- communityAuthor
1080
+ communityAuthor,
1081
+ authorIdentityMatcher
1059
1082
  };
1060
1083
  }
1061
1084
  async function runChallengeExchangeIfNeeded(community, parsed, log) {
1062
- const { decryptedRequestWithCommunityAuthor } = parsed;
1085
+ const { decryptedRequestWithCommunityAuthor, authorIdentityMatcher } = parsed;
1063
1086
  const answerPromiseKey = decryptedRequestWithCommunityAuthor.challengeRequestId.toString();
1064
1087
  const getChallengeAnswers = async (challenges) => {
1065
1088
  await publishChallenges(community, challenges, decryptedRequestWithCommunityAuthor);
@@ -1087,7 +1110,8 @@ async function runChallengeExchangeIfNeeded(community, parsed, log) {
1087
1110
  challengeVerification = await getChallengeVerification({
1088
1111
  challengeRequestMessage: decryptedRequestWithCommunityAuthor,
1089
1112
  community,
1090
- getChallengeAnswers
1113
+ getChallengeAnswers,
1114
+ authorIdentityMatcher
1091
1115
  });
1092
1116
  } catch (e) {
1093
1117
  if (e instanceof PKCError && e.code === "ERR_COMMUNITY_TIMED_OUT_WAITING_FOR_CHALLENGE_ANSWER") {
@@ -1114,11 +1138,18 @@ async function runVerificationAndStorePublication(community, parsed, challengeVe
1114
1138
  aggregatedCommentUpdate: challengeVerification.aggregatedCommentUpdate,
1115
1139
  aggregatedReason: challengeVerification.aggregatedReason
1116
1140
  };
1117
- await publishChallengeVerification(community, {
1118
- challengeSuccess: challengeVerification.challengeSuccess,
1119
- challengeErrors: challengeVerification.challengeErrors,
1120
- reason: challengeVerification.reason ?? challengeVerification.aggregatedReason
1121
- }, parsed.decryptedRequestMsg, challengeVerification.pendingApproval, aggregate);
1141
+ await publishChallengeVerification({
1142
+ community,
1143
+ challengeResult: {
1144
+ challengeSuccess: challengeVerification.challengeSuccess,
1145
+ challengeErrors: challengeVerification.challengeErrors,
1146
+ reason: challengeVerification.reason ?? challengeVerification.aggregatedReason
1147
+ },
1148
+ request: parsed.decryptedRequestMsg,
1149
+ pendingApproval: challengeVerification.pendingApproval,
1150
+ challengeAggregate: aggregate,
1151
+ authorIdentityMatcher: challengeVerification.postAnswerAuthorIdentityMatcher ?? parsed.authorIdentityMatcher
1152
+ });
1122
1153
  }
1123
1154
  async function handleChallengeRequest(community, request, isLocalPublisher) {
1124
1155
  const log = logger_default("pkc-js:local-community:handleChallengeRequest");
@@ -1262,14 +1293,11 @@ async function handleChallengeExchange(community, pubsubMsg) {
1262
1293
  function isFlairInAllowedList(flair, allowedFlairs) {
1263
1294
  return allowedFlairs.some((allowed) => t$11(allowed, flair));
1264
1295
  }
1265
- async function isPublicationAuthorPartOfRoles(community, publication, rolesToCheckAgainst) {
1266
- if (!community.roles) return false;
1296
+ async function matchPublicationAuthorAgainstRoles({ community, rolesToCheckAgainst, authorIdentityMatcher }) {
1297
+ if (!community.roles) return { matched: false };
1267
1298
  const roleKeys = Object.keys(community.roles).filter((roleKey) => rolesToCheckAgainst.includes(community.roles[roleKey].role));
1268
- if (roleKeys.length === 0) return false;
1269
- return createAuthorIdentityMatcher({
1270
- community,
1271
- publication
1272
- }).matchesAnyIdentity(roleKeys);
1299
+ if (roleKeys.length === 0) return { matched: false };
1300
+ return authorIdentityMatcher.matchesAnyIdentity(roleKeys);
1273
1301
  }
1274
1302
  async function respondWithErrorIfSignatureOfPublicationIsInvalid(community, request) {
1275
1303
  let validity;
@@ -1336,12 +1364,12 @@ async function checkAuthorIdentity(community, publication, log) {
1336
1364
  cache: { maxAge: 1800 }
1337
1365
  }));
1338
1366
  } catch (e) {
1339
- log("Rejecting publication with unresolvable author domain", authorName, e);
1340
- return messages.ERR_FAILED_TO_RESOLVE_AUTHOR_DOMAIN;
1367
+ log("Rejecting publication with unresolvable author name", authorName, e instanceof PKCError ? e.code : void 0, e);
1368
+ return authorNameResolveFailureReason({ error: e });
1341
1369
  }
1342
1370
  if (resolvedAddress === null) {
1343
- log("Rejecting publication: author domain could not be resolved", authorName);
1344
- return messages.ERR_FAILED_TO_RESOLVE_AUTHOR_DOMAIN;
1371
+ log("Rejecting publication: author name has no record", authorName);
1372
+ return authorNameResolveFailureReason({ error: null });
1345
1373
  }
1346
1374
  const signerAddress = await getPKCAddressFromPublicKey(publication.signature.publicKey);
1347
1375
  if (resolvedAddress !== signerAddress) {
@@ -1350,7 +1378,7 @@ async function checkAuthorIdentity(community, publication, log) {
1350
1378
  }
1351
1379
  }
1352
1380
  }
1353
- async function checkParentAndPostState(community, request, publication) {
1381
+ async function checkParentAndPostState(community, request, publication, authorIdentityMatcher) {
1354
1382
  if ("commentCid" in publication || "parentCid" in publication) {
1355
1383
  const parentCid = publication.parentCid || publication.commentCid;
1356
1384
  if (typeof parentCid !== "string") return messages.ERR_COMMUNITY_PUBLICATION_PARENT_CID_NOT_DEFINED;
@@ -1362,11 +1390,19 @@ async function checkParentAndPostState(community, request, publication) {
1362
1390
  if (postFlags.removed && !request.commentModeration) return messages.ERR_COMMUNITY_PUBLICATION_POST_HAS_BEEN_REMOVED;
1363
1391
  if (community._dbHandler.queryAuthorEditDeleted(parent.postCid)?.deleted && !request.commentModeration) return messages.ERR_COMMUNITY_PUBLICATION_POST_HAS_BEEN_DELETED;
1364
1392
  if (postFlags.locked && !request.commentModeration) {
1365
- if (!(!request.vote && await isPublicationAuthorPartOfRoles(community, publication, [
1366
- "owner",
1367
- "admin",
1368
- "moderator"
1369
- ]))) return messages.ERR_COMMUNITY_PUBLICATION_POST_IS_LOCKED;
1393
+ const lockBypass = request.vote ? { matched: false } : await matchPublicationAuthorAgainstRoles({
1394
+ community,
1395
+ rolesToCheckAgainst: [
1396
+ "owner",
1397
+ "admin",
1398
+ "moderator"
1399
+ ],
1400
+ authorIdentityMatcher
1401
+ });
1402
+ if (!lockBypass.matched) {
1403
+ if (lockBypass.nameFailure) return lockBypass.nameFailure.reason;
1404
+ return messages.ERR_COMMUNITY_PUBLICATION_POST_IS_LOCKED;
1405
+ }
1370
1406
  }
1371
1407
  if (postFlags.archived && !request.commentModeration) return messages.ERR_COMMUNITY_PUBLICATION_POST_IS_ARCHIVED;
1372
1408
  if (parent.timestamp > publication.timestamp) return messages.ERR_COMMUNITY_COMMENT_TIMESTAMP_IS_EARLIER_THAN_PARENT;
@@ -1451,16 +1487,24 @@ async function checkVotePublication(community, request) {
1451
1487
  const voteAuthorSignerAddress = await getPKCAddressFromPublicKey(votePublication.signature.publicKey);
1452
1488
  if (!community._dbHandler.queryVote(commentToVoteOn.cid, voteAuthorSignerAddress) && votePublication.vote === 0) return messages.ERR_THERE_IS_NO_PREVIOUS_VOTE_TO_CANCEL;
1453
1489
  }
1454
- async function checkCommentModerationPublication(community, request) {
1490
+ async function checkCommentModerationPublication(community, request, authorIdentityMatcher) {
1455
1491
  if (!request.commentModeration) return void 0;
1456
1492
  const commentModerationPublication = request.commentModeration;
1457
1493
  if (r$2(CommentModerationReservedFields, t$6(commentModerationPublication)).length > 0) return messages.ERR_COMMENT_MODERATION_HAS_RESERVED_FIELD;
1458
- const isAuthorMod = await isPublicationAuthorPartOfRoles(community, commentModerationPublication, [
1459
- "owner",
1460
- "moderator",
1461
- "admin"
1462
- ]);
1463
- if (!isAuthorMod) return messages.ERR_COMMENT_MODERATION_ATTEMPTED_WITHOUT_BEING_MODERATOR;
1494
+ const modMatch = await matchPublicationAuthorAgainstRoles({
1495
+ community,
1496
+ rolesToCheckAgainst: [
1497
+ "owner",
1498
+ "moderator",
1499
+ "admin"
1500
+ ],
1501
+ authorIdentityMatcher
1502
+ });
1503
+ const isAuthorMod = modMatch.matched;
1504
+ if (!isAuthorMod) {
1505
+ if (modMatch.nameFailure) return modMatch.nameFailure.reason;
1506
+ return messages.ERR_COMMENT_MODERATION_ATTEMPTED_WITHOUT_BEING_MODERATOR;
1507
+ }
1464
1508
  const commentToBeEdited = community._dbHandler.queryComment(commentModerationPublication.commentCid);
1465
1509
  if (!commentToBeEdited) return messages.ERR_COMMENT_MODERATION_NO_COMMENT_TO_EDIT;
1466
1510
  if (isAuthorMod && commentModerationPublication.commentModeration.locked && commentToBeEdited.depth !== 0) return messages.ERR_COMMUNITY_COMMENT_MOD_CAN_NOT_LOCK_REPLY;
@@ -1469,14 +1513,30 @@ async function checkCommentModerationPublication(community, request) {
1469
1513
  if (community._dbHandler.hasCommentModerationWithSignatureEncoded(commentModerationPublication.signature.signature)) return messages.ERR_DUPLICATE_COMMENT_MODERATION;
1470
1514
  if ("approved" in commentModerationPublication.commentModeration && !commentToBeEdited.pendingApproval) return messages.ERR_MOD_ATTEMPTING_TO_APPROVE_OR_DISAPPROVE_COMMENT_THAT_IS_NOT_PENDING;
1471
1515
  }
1472
- async function checkCommunityEditPublication(community, request) {
1516
+ async function checkCommunityEditPublication(community, request, authorIdentityMatcher) {
1473
1517
  if (!request.communityEdit) return void 0;
1474
1518
  const communityEdit = request.communityEdit;
1475
1519
  if (r$2(CommunityEditPublicationPubsubReservedFields, t$6(communityEdit)).length > 0) return messages.ERR_COMMUNITY_EDIT_HAS_RESERVED_FIELD;
1476
- if (communityEdit.communityEdit.roles || communityEdit.communityEdit.address) {
1477
- if (!await isPublicationAuthorPartOfRoles(community, communityEdit, ["owner"])) return messages.ERR_COMMUNITY_EDIT_ATTEMPTED_TO_MODIFY_OWNER_EXCLUSIVE_PROPS;
1520
+ if (communityEdit.communityEdit.roles || communityEdit.communityEdit.address || communityEdit.communityEdit.name) {
1521
+ const ownerMatch = await matchPublicationAuthorAgainstRoles({
1522
+ community,
1523
+ rolesToCheckAgainst: ["owner"],
1524
+ authorIdentityMatcher
1525
+ });
1526
+ if (!ownerMatch.matched) {
1527
+ if (ownerMatch.nameFailure) return ownerMatch.nameFailure.reason;
1528
+ return messages.ERR_COMMUNITY_EDIT_ATTEMPTED_TO_MODIFY_OWNER_EXCLUSIVE_PROPS;
1529
+ }
1530
+ }
1531
+ const ownerOrAdminMatch = await matchPublicationAuthorAgainstRoles({
1532
+ community,
1533
+ rolesToCheckAgainst: ["owner", "admin"],
1534
+ authorIdentityMatcher
1535
+ });
1536
+ if (!ownerOrAdminMatch.matched) {
1537
+ if (ownerOrAdminMatch.nameFailure) return ownerOrAdminMatch.nameFailure.reason;
1538
+ return messages.ERR_COMMUNITY_EDIT_ATTEMPTED_TO_MODIFY_COMMUNITY_WITHOUT_BEING_OWNER_OR_ADMIN;
1478
1539
  }
1479
- if (!await isPublicationAuthorPartOfRoles(community, communityEdit, ["owner", "admin"])) return messages.ERR_COMMUNITY_EDIT_ATTEMPTED_TO_MODIFY_COMMUNITY_WITHOUT_BEING_OWNER_OR_ADMIN;
1480
1540
  const allowedCommunityEditKeys = [...t$6(CommunityIpfsSchema.shape), "address"];
1481
1541
  if (r$1(t$6(communityEdit.communityEdit), allowedCommunityEditKeys).length > 0) return messages.ERR_COMMUNITY_EDIT_ATTEMPTED_TO_NON_PUBLIC_PROPS;
1482
1542
  }
@@ -1502,22 +1562,26 @@ async function checkCommentEditPublication(community, request) {
1502
1562
  for (const flair of commentEditPublication.flairs) if (!isFlairInAllowedList(flair, allowedPostFlairs)) return messages.ERR_POST_FLAIR_NOT_IN_ALLOWED_FLAIRS;
1503
1563
  }
1504
1564
  }
1505
- async function checkPublicationValidity(community, request, publication, authorCommunity) {
1565
+ async function checkPublicationValidity({ community, request, publication, authorCommunity, authorIdentityMatcher: sharedAuthorIdentityMatcher }) {
1566
+ const authorIdentityMatcher = sharedAuthorIdentityMatcher ?? authorIdentityMatcherForRequest({
1567
+ community,
1568
+ request
1569
+ });
1506
1570
  const log = logger_default("pkc-js:local-community:handleChallengeRequest:checkPublicationValidity");
1507
1571
  const wireResult = await checkWireFormatAndCommunityAuthor(community, publication, authorCommunity);
1508
1572
  if (wireResult) return wireResult;
1509
1573
  const authorResult = await checkAuthorIdentity(community, publication, log);
1510
1574
  if (authorResult) return authorResult;
1511
- const parentResult = await checkParentAndPostState(community, request, publication);
1575
+ const parentResult = await checkParentAndPostState(community, request, publication, authorIdentityMatcher);
1512
1576
  if (parentResult) return parentResult;
1513
1577
  if (Buffer.byteLength(JSON.stringify(publication)) / 1e3 > 40) return messages.ERR_REQUEST_PUBLICATION_OVER_ALLOWED_SIZE;
1514
1578
  const commentResult = await checkCommentPublication(community, request);
1515
1579
  if (commentResult) return commentResult;
1516
1580
  const voteResult = await checkVotePublication(community, request);
1517
1581
  if (voteResult) return voteResult;
1518
- const modResult = await checkCommentModerationPublication(community, request);
1582
+ const modResult = await checkCommentModerationPublication(community, request, authorIdentityMatcher);
1519
1583
  if (modResult) return modResult;
1520
- const communityEditResult = await checkCommunityEditPublication(community, request);
1584
+ const communityEditResult = await checkCommunityEditPublication(community, request, authorIdentityMatcher);
1521
1585
  if (communityEditResult) return communityEditResult;
1522
1586
  const commentEditResult = await checkCommentEditPublication(community, request);
1523
1587
  if (commentEditResult) return commentEditResult;
@@ -1571,14 +1635,26 @@ async function resolveAliasPrivateKeyForCommentPublication(community, opts) {
1571
1635
  return (await community._pkc.createSigner()).privateKey;
1572
1636
  } else throw Error(`Unsupported pseudonymityMode (${opts.mode})`);
1573
1637
  }
1574
- async function prepareCommentWithAnonymity(community, originalComment) {
1638
+ async function prepareCommentWithAnonymity({ community, originalComment, authorIdentityMatcher = createAuthorIdentityMatcher({
1639
+ community,
1640
+ publication: originalComment
1641
+ }) }) {
1575
1642
  const mode = community.features?.pseudonymityMode;
1576
1643
  if (!mode) return { publication: originalComment };
1577
- if (await isPublicationAuthorPartOfRoles(community, originalComment, [
1578
- "owner",
1579
- "admin",
1580
- "moderator"
1581
- ])) return { publication: originalComment };
1644
+ const modMatch = await matchPublicationAuthorAgainstRoles({
1645
+ community,
1646
+ rolesToCheckAgainst: [
1647
+ "owner",
1648
+ "admin",
1649
+ "moderator"
1650
+ ],
1651
+ authorIdentityMatcher
1652
+ });
1653
+ if (modMatch.matched) return { publication: originalComment };
1654
+ if (modMatch.nameFailure) throw new PKCError(getErrorCodeFromMessage(modMatch.nameFailure.reason), {
1655
+ comment: originalComment,
1656
+ nameFailureError: modMatch.nameFailure.error
1657
+ });
1582
1658
  const originalAuthorPublicKey = originalComment.signature.publicKey;
1583
1659
  const postCid = originalComment.postCid;
1584
1660
  const aliasPrivateKey = await resolveAliasPrivateKeyForCommentPublication(community, {
@@ -1831,13 +1907,20 @@ async function storeComment(community, opts) {
1831
1907
  cid: commentCid
1832
1908
  };
1833
1909
  }
1834
- async function storePublication(community, request, pendingApproval, challengeAggregate) {
1910
+ async function storePublication({ community, request, pendingApproval, challengeAggregate, authorIdentityMatcher }) {
1835
1911
  if (request.vote) return storeVote(community, request.vote, request.challengeRequestId);
1836
1912
  else if (request.commentEdit) return storeCommentEdit(community, await prepareCommentEditWithAlias(community, request.commentEdit), request.challengeRequestId);
1837
1913
  else if (request.commentModeration) return storeCommentModeration(community, request.commentModeration, request.challengeRequestId);
1838
1914
  else if (request.comment) {
1839
1915
  const originalCommentSignatureEncoded = request.comment.signature.signature;
1840
- const { publication, anonymity } = await prepareCommentWithAnonymity(community, request.comment);
1916
+ const { publication, anonymity } = await prepareCommentWithAnonymity({
1917
+ community,
1918
+ originalComment: request.comment,
1919
+ authorIdentityMatcher: authorIdentityMatcher ?? authorIdentityMatcherForRequest({
1920
+ community,
1921
+ request
1922
+ })
1923
+ });
1841
1924
  const storedComment = await storeComment(community, {
1842
1925
  commentPubsub: publication,
1843
1926
  pendingApproval,
@@ -7231,16 +7314,21 @@ async function parseRolesToEdit(community, newRawRoles) {
7231
7314
  if (roleValue === void 0 || roleValue === null) continue;
7232
7315
  if (isStringDomain(roleAddress)) {
7233
7316
  let resolved;
7317
+ let resolveError;
7234
7318
  try {
7235
7319
  ({resolvedAuthorName: resolved} = await community._clientsManager.resolveAuthorNameIfNeeded({
7236
7320
  authorName: roleAddress,
7237
7321
  abortSignal: AbortSignal.timeout(community._pkc._timeouts["resolve-author-name"]),
7238
7322
  cache: { maxAge: 0 }
7239
7323
  }));
7240
- } catch {
7324
+ } catch (e) {
7241
7325
  resolved = null;
7326
+ resolveError = e;
7242
7327
  }
7243
- if (!resolved) throw new PKCError("ERR_ROLE_ADDRESS_NAME_COULD_NOT_BE_RESOLVED", { roleAddress });
7328
+ if (!resolved) throw new PKCError("ERR_ROLE_ADDRESS_NAME_COULD_NOT_BE_RESOLVED", {
7329
+ roleAddress,
7330
+ resolveError
7331
+ });
7244
7332
  }
7245
7333
  }
7246
7334
  return t$8(newRawRoles, (val, key) => val === void 0 || val === null);
@@ -7853,7 +7941,11 @@ var LocalCommunity = class extends RpcLocalCommunity {
7853
7941
  return repinCommentsIPFSIfNeeded(this);
7854
7942
  }
7855
7943
  async storePublication(request, pendingApproval) {
7856
- return storePublication(this, request, pendingApproval);
7944
+ return storePublication({
7945
+ community: this,
7946
+ request,
7947
+ pendingApproval
7948
+ });
7857
7949
  }
7858
7950
  async updateCommunityIpnsIfNeeded(args) {
7859
7951
  return updateCommunityIpnsIfNeeded(this, args.commentUpdateRowsToPublishToIpfs);
@@ -7883,13 +7975,20 @@ var LocalCommunity = class extends RpcLocalCommunity {
7883
7975
  return purgeDisapprovedCommentsOlderThan(this);
7884
7976
  }
7885
7977
  async _publishChallengeVerification(challengeResult, request) {
7886
- return publishChallengeVerification(this, challengeResult, request);
7978
+ return publishChallengeVerification({
7979
+ community: this,
7980
+ challengeResult,
7981
+ request
7982
+ });
7887
7983
  }
7888
7984
  async _publishIdempotentDuplicateVerification(...args) {
7889
7985
  return publishIdempotentDuplicateVerification(this, ...args);
7890
7986
  }
7891
- async _checkPublicationValidity(...args) {
7892
- return checkPublicationValidity(this, ...args);
7987
+ async _checkPublicationValidity(args) {
7988
+ return checkPublicationValidity({
7989
+ ...args,
7990
+ community: this
7991
+ });
7893
7992
  }
7894
7993
  _calculateLocalMfsPathForCommentUpdate(...args) {
7895
7994
  return calculateLocalMfsPathForCommentUpdate(this, ...args);