@pkcprotocol/pkc-js 0.0.34 → 0.0.36

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 (114) hide show
  1. package/README.md +18 -0
  2. package/dist/browser/community/remote-community.d.ts +3 -3
  3. package/dist/browser/community/remote-community.js.map +1 -1
  4. package/dist/browser/generated-version.d.ts +1 -1
  5. package/dist/browser/generated-version.js +1 -1
  6. package/dist/browser/helia/helia-for-pkc.js +30 -12
  7. package/dist/browser/helia/helia-for-pkc.js.map +1 -1
  8. package/dist/browser/helia/util.js +142 -42
  9. package/dist/browser/helia/util.js.map +1 -1
  10. package/dist/browser/pkc/pkc.js +3 -3
  11. package/dist/browser/pkc/pkc.js.map +1 -1
  12. package/dist/browser/runtime/browser/community/local-community.d.ts +2 -0
  13. package/dist/browser/runtime/browser/community/local-community.js +6 -0
  14. package/dist/browser/runtime/browser/community/local-community.js.map +1 -1
  15. package/dist/browser/runtime/node/community/db-handler.js +6 -4
  16. package/dist/browser/runtime/node/community/db-handler.js.map +1 -1
  17. package/dist/browser/runtime/node/community/local-community/challenges.d.ts +26 -0
  18. package/dist/browser/runtime/node/community/local-community/challenges.js +519 -0
  19. package/dist/browser/runtime/node/community/local-community/challenges.js.map +1 -0
  20. package/dist/browser/runtime/node/community/local-community/cleanup.d.ts +9 -0
  21. package/dist/browser/runtime/node/community/local-community/cleanup.js +165 -0
  22. package/dist/browser/runtime/node/community/local-community/cleanup.js.map +1 -0
  23. package/dist/browser/runtime/node/community/local-community/comment-updates.d.ts +11 -0
  24. package/dist/browser/runtime/node/community/local-community/comment-updates.js +218 -0
  25. package/dist/browser/runtime/node/community/local-community/comment-updates.js.map +1 -0
  26. package/dist/browser/runtime/node/community/local-community/db-state.d.ts +15 -0
  27. package/dist/browser/runtime/node/community/local-community/db-state.js +323 -0
  28. package/dist/browser/runtime/node/community/local-community/db-state.js.map +1 -0
  29. package/dist/browser/runtime/node/community/local-community/defaults.d.ts +12 -0
  30. package/dist/browser/runtime/node/community/local-community/defaults.js +29 -0
  31. package/dist/browser/runtime/node/community/local-community/defaults.js.map +1 -0
  32. package/dist/browser/runtime/node/community/local-community/editing.d.ts +10 -0
  33. package/dist/browser/runtime/node/community/local-community/editing.js +188 -0
  34. package/dist/browser/runtime/node/community/local-community/editing.js.map +1 -0
  35. package/dist/browser/runtime/node/community/local-community/ipns-publishing.d.ts +12 -0
  36. package/dist/browser/runtime/node/community/local-community/ipns-publishing.js +340 -0
  37. package/dist/browser/runtime/node/community/local-community/ipns-publishing.js.map +1 -0
  38. package/dist/browser/runtime/node/community/local-community/lifecycle.d.ts +11 -0
  39. package/dist/browser/runtime/node/community/local-community/lifecycle.js +428 -0
  40. package/dist/browser/runtime/node/community/local-community/lifecycle.js.map +1 -0
  41. package/dist/browser/runtime/node/community/local-community/publication-store.d.ts +100 -0
  42. package/dist/browser/runtime/node/community/local-community/publication-store.js +395 -0
  43. package/dist/browser/runtime/node/community/local-community/publication-store.js.map +1 -0
  44. package/dist/browser/runtime/node/community/local-community/publication-validation.d.ts +9 -0
  45. package/dist/browser/runtime/node/community/local-community/publication-validation.js +493 -0
  46. package/dist/browser/runtime/node/community/local-community/publication-validation.js.map +1 -0
  47. package/dist/browser/runtime/node/community/local-community/pubsub.d.ts +3 -0
  48. package/dist/browser/runtime/node/community/local-community/pubsub.js +43 -0
  49. package/dist/browser/runtime/node/community/local-community/pubsub.js.map +1 -0
  50. package/dist/browser/runtime/node/community/local-community/registry.d.ts +3 -0
  51. package/dist/browser/runtime/node/community/local-community/registry.js +4 -0
  52. package/dist/browser/runtime/node/community/local-community/registry.js.map +1 -0
  53. package/dist/browser/runtime/node/community/local-community.d.ts +68 -105
  54. package/dist/browser/runtime/node/community/local-community.js +127 -2927
  55. package/dist/browser/runtime/node/community/local-community.js.map +1 -1
  56. package/dist/browser/test/test-util.js +0 -1
  57. package/dist/browser/test/test-util.js.map +1 -1
  58. package/dist/node/community/remote-community.d.ts +3 -3
  59. package/dist/node/community/remote-community.js.map +1 -1
  60. package/dist/node/generated-version.d.ts +1 -1
  61. package/dist/node/generated-version.js +1 -1
  62. package/dist/node/helia/helia-for-pkc.js +30 -12
  63. package/dist/node/helia/helia-for-pkc.js.map +1 -1
  64. package/dist/node/helia/util.js +142 -42
  65. package/dist/node/helia/util.js.map +1 -1
  66. package/dist/node/pkc/pkc.js +3 -3
  67. package/dist/node/pkc/pkc.js.map +1 -1
  68. package/dist/node/runtime/browser/community/local-community.d.ts +2 -0
  69. package/dist/node/runtime/browser/community/local-community.js +6 -0
  70. package/dist/node/runtime/browser/community/local-community.js.map +1 -1
  71. package/dist/node/runtime/node/community/db-handler.js +6 -4
  72. package/dist/node/runtime/node/community/db-handler.js.map +1 -1
  73. package/dist/node/runtime/node/community/local-community/challenges.d.ts +26 -0
  74. package/dist/node/runtime/node/community/local-community/challenges.js +519 -0
  75. package/dist/node/runtime/node/community/local-community/challenges.js.map +1 -0
  76. package/dist/node/runtime/node/community/local-community/cleanup.d.ts +9 -0
  77. package/dist/node/runtime/node/community/local-community/cleanup.js +165 -0
  78. package/dist/node/runtime/node/community/local-community/cleanup.js.map +1 -0
  79. package/dist/node/runtime/node/community/local-community/comment-updates.d.ts +11 -0
  80. package/dist/node/runtime/node/community/local-community/comment-updates.js +218 -0
  81. package/dist/node/runtime/node/community/local-community/comment-updates.js.map +1 -0
  82. package/dist/node/runtime/node/community/local-community/db-state.d.ts +15 -0
  83. package/dist/node/runtime/node/community/local-community/db-state.js +323 -0
  84. package/dist/node/runtime/node/community/local-community/db-state.js.map +1 -0
  85. package/dist/node/runtime/node/community/local-community/defaults.d.ts +12 -0
  86. package/dist/node/runtime/node/community/local-community/defaults.js +29 -0
  87. package/dist/node/runtime/node/community/local-community/defaults.js.map +1 -0
  88. package/dist/node/runtime/node/community/local-community/editing.d.ts +10 -0
  89. package/dist/node/runtime/node/community/local-community/editing.js +188 -0
  90. package/dist/node/runtime/node/community/local-community/editing.js.map +1 -0
  91. package/dist/node/runtime/node/community/local-community/ipns-publishing.d.ts +12 -0
  92. package/dist/node/runtime/node/community/local-community/ipns-publishing.js +340 -0
  93. package/dist/node/runtime/node/community/local-community/ipns-publishing.js.map +1 -0
  94. package/dist/node/runtime/node/community/local-community/lifecycle.d.ts +11 -0
  95. package/dist/node/runtime/node/community/local-community/lifecycle.js +428 -0
  96. package/dist/node/runtime/node/community/local-community/lifecycle.js.map +1 -0
  97. package/dist/node/runtime/node/community/local-community/publication-store.d.ts +100 -0
  98. package/dist/node/runtime/node/community/local-community/publication-store.js +395 -0
  99. package/dist/node/runtime/node/community/local-community/publication-store.js.map +1 -0
  100. package/dist/node/runtime/node/community/local-community/publication-validation.d.ts +9 -0
  101. package/dist/node/runtime/node/community/local-community/publication-validation.js +493 -0
  102. package/dist/node/runtime/node/community/local-community/publication-validation.js.map +1 -0
  103. package/dist/node/runtime/node/community/local-community/pubsub.d.ts +3 -0
  104. package/dist/node/runtime/node/community/local-community/pubsub.js +43 -0
  105. package/dist/node/runtime/node/community/local-community/pubsub.js.map +1 -0
  106. package/dist/node/runtime/node/community/local-community/registry.d.ts +3 -0
  107. package/dist/node/runtime/node/community/local-community/registry.js +4 -0
  108. package/dist/node/runtime/node/community/local-community/registry.js.map +1 -0
  109. package/dist/node/runtime/node/community/local-community.d.ts +68 -105
  110. package/dist/node/runtime/node/community/local-community.js +127 -2927
  111. package/dist/node/runtime/node/community/local-community.js.map +1 -1
  112. package/dist/node/test/test-util.js +0 -1
  113. package/dist/node/test/test-util.js.map +1 -1
  114. package/package.json +3 -2
@@ -0,0 +1,395 @@
1
+ import Logger from "../../../../logger.js";
2
+ import * as remeda from "remeda";
3
+ import { default as lodashDeepMerge } from "lodash.merge";
4
+ import { stringify as deterministicStringify } from "safe-stable-stringify";
5
+ import { calculateIpfsCidV0, isStringDomain, retryKuboIpfsAddAndProvide, timestamp } from "../../../../util.js";
6
+ import { PKCError } from "../../../../pkc-error.js";
7
+ import { signComment, signCommentEdit } from "../../../../signer/signatures.js";
8
+ import { getPKCAddressFromPublicKey } from "../../../../signer/util.js";
9
+ import { cleanWireAuthor, getAuthorNameFromWire } from "../../../../publications/publication-author.js";
10
+ import { getThumbnailPropsOfLink } from "../../util.js";
11
+ import { CommentEditPubsubMessagePublicationSchema, CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema } from "../../../../publications/comment-edit/schema.js";
12
+ import { CommentIpfsSchema, CommentPubsubMessagePublicationSchema } from "../../../../publications/comment/schema.js";
13
+ import { CommentModerationPubsubMessagePublicationSchema } from "../../../../publications/comment-moderation/schema.js";
14
+ import { VotePubsubMessagePublicationSchema } from "../../../../publications/vote/schema.js";
15
+ import { addAllCidsUnderPurgedCommentToBeRemoved, rmUnneededMfsPaths } from "./cleanup.js";
16
+ import { isPublicationAuthorPartOfRoles } from "./publication-validation.js";
17
+ export function isPublicationReply(publication) {
18
+ return Boolean(publication.parentCid);
19
+ }
20
+ export function isPublicationPost(publication) {
21
+ return !publication.parentCid;
22
+ }
23
+ export async function calculateLinkProps(community, link) {
24
+ if (!link || !community.settings?.fetchThumbnailUrls)
25
+ return undefined;
26
+ return getThumbnailPropsOfLink(link, community, community.settings.fetchThumbnailUrlsProxyUrl);
27
+ }
28
+ export async function calculateLatestPostProps(community) {
29
+ community._dbHandler.createTransaction();
30
+ const previousCid = community._dbHandler.queryLatestPostCid()?.cid;
31
+ community._dbHandler.commitTransaction();
32
+ return { depth: 0, previousCid };
33
+ }
34
+ export async function calculateReplyProps(community, comment) {
35
+ if (!comment.parentCid)
36
+ throw Error("Reply has to have parentCid");
37
+ community._dbHandler.createTransaction();
38
+ const commentsUnderParent = community._dbHandler.queryCommentsUnderComment(comment.parentCid);
39
+ const parent = community._dbHandler.queryComment(comment.parentCid);
40
+ community._dbHandler.commitTransaction();
41
+ if (!parent)
42
+ throw Error("Failed to find parent of reply");
43
+ return {
44
+ depth: parent.depth + 1,
45
+ postCid: parent.postCid,
46
+ previousCid: commentsUnderParent[0]?.cid
47
+ };
48
+ }
49
+ export async function resolveAliasPrivateKeyForCommentPublication(community, opts) {
50
+ if (opts.mode === "per-post") {
51
+ // For a new post (no postCid yet), always generate a fresh alias; once stored the postCid will be used for reuse.
52
+ if (opts.postCid) {
53
+ const existing = community._dbHandler.queryPseudonymityAliasForPost(opts.originalAuthorPublicKey, opts.postCid);
54
+ if (existing?.aliasPrivateKey)
55
+ return existing.aliasPrivateKey;
56
+ }
57
+ return (await community._pkc.createSigner()).privateKey;
58
+ }
59
+ else if (opts.mode === "per-reply") {
60
+ const signer = await community._pkc.createSigner();
61
+ return signer.privateKey;
62
+ }
63
+ else if (opts.mode === "per-author") {
64
+ const existing = community._dbHandler.queryPseudonymityAliasForAuthor(opts.originalAuthorPublicKey);
65
+ if (existing?.aliasPrivateKey)
66
+ return existing.aliasPrivateKey;
67
+ const signer = await community._pkc.createSigner();
68
+ return signer.privateKey;
69
+ }
70
+ else
71
+ throw Error(`Unsupported pseudonymityMode (${opts.mode})`);
72
+ }
73
+ export async function prepareCommentWithAnonymity(community, originalComment) {
74
+ const mode = community.features?.pseudonymityMode;
75
+ if (!mode)
76
+ return { publication: originalComment };
77
+ // Mods (owner, admin, moderator) are never pseudonymized
78
+ const isAuthorMod = await isPublicationAuthorPartOfRoles(community, originalComment, ["owner", "admin", "moderator"]);
79
+ if (isAuthorMod)
80
+ return { publication: originalComment };
81
+ const originalAuthorPublicKey = originalComment.signature.publicKey;
82
+ const postCid = originalComment.postCid;
83
+ const aliasPrivateKey = await resolveAliasPrivateKeyForCommentPublication(community, {
84
+ mode,
85
+ originalAuthorPublicKey,
86
+ postCid
87
+ });
88
+ const aliasSigner = await community._pkc.createSigner({ privateKey: aliasPrivateKey, type: "ed25519" });
89
+ const displayName = originalComment.author?.displayName;
90
+ const sanitizedAuthor = cleanWireAuthor(displayName !== undefined ? { displayName } : undefined);
91
+ const anonymizedComment = remeda.clone(originalComment);
92
+ if (sanitizedAuthor !== undefined) {
93
+ anonymizedComment.author = sanitizedAuthor;
94
+ }
95
+ else {
96
+ delete anonymizedComment.author;
97
+ }
98
+ anonymizedComment.signature = await signComment({
99
+ comment: { ...anonymizedComment, signer: aliasSigner, communityAddress: community.address },
100
+ pkc: community._pkc
101
+ });
102
+ return {
103
+ publication: anonymizedComment,
104
+ anonymity: {
105
+ aliasPrivateKey,
106
+ originalAuthorPublicKey,
107
+ mode,
108
+ originalComment
109
+ }
110
+ };
111
+ }
112
+ export async function prepareCommentEditWithAlias(community, originalEdit) {
113
+ const aliasSignerOfComment = community._dbHandler.queryPseudonymityAliasByCommentCid(originalEdit.commentCid);
114
+ if (!aliasSignerOfComment)
115
+ return originalEdit;
116
+ const aliasSigner = await community._pkc.createSigner({
117
+ privateKey: aliasSignerOfComment.aliasPrivateKey,
118
+ type: "ed25519"
119
+ });
120
+ const commentEditSignedByAlias = remeda.clone(originalEdit);
121
+ delete commentEditSignedByAlias.author;
122
+ commentEditSignedByAlias.signature = await signCommentEdit({
123
+ edit: { ...commentEditSignedByAlias, signer: aliasSigner, communityAddress: community.address },
124
+ pkc: community._pkc
125
+ });
126
+ return commentEditSignedByAlias;
127
+ }
128
+ export async function storeCommentEdit(community, commentEditRaw, challengeRequestId) {
129
+ const log = Logger("pkc-js:local-community:storeCommentEdit");
130
+ const strippedOutEditPublication = CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema.strip().parse(commentEditRaw); // we strip out here so we don't store any extra props in commentedits table
131
+ strippedOutEditPublication.author = cleanWireAuthor(strippedOutEditPublication.author); // strip runtime-only author fields (address, publicKey, etc.)
132
+ // Normalize to new wire format: ensure communityPublicKey/communityName for DB columns
133
+ if (!strippedOutEditPublication.communityPublicKey)
134
+ strippedOutEditPublication.communityPublicKey = community.signer.address;
135
+ if (!strippedOutEditPublication.communityName && isStringDomain(community.address))
136
+ strippedOutEditPublication.communityName = community.address;
137
+ const commentToBeEdited = community._dbHandler.queryComment(commentEditRaw.commentCid); // We assume commentToBeEdited to be defined because we already tested for its existence above
138
+ if (!commentToBeEdited)
139
+ throw Error("The comment to edit doesn't exist"); // unlikely error to happen, but always a good idea to verify
140
+ const editSignedByOriginalAuthor = commentEditRaw.signature.publicKey === commentToBeEdited.signature.publicKey;
141
+ const authorSignerAddress = await getPKCAddressFromPublicKey(commentEditRaw.signature.publicKey);
142
+ const editTableRow = {
143
+ ...strippedOutEditPublication,
144
+ isAuthorEdit: editSignedByOriginalAuthor,
145
+ authorSignerAddress,
146
+ insertedAt: timestamp()
147
+ };
148
+ const extraPropsInEdit = remeda
149
+ .difference(remeda.keys.strict(commentEditRaw), remeda.keys.strict(CommentEditPubsubMessagePublicationSchema.shape))
150
+ .filter((key) => key !== "communityAddress"); // communityAddress is excluded because it's been converted to communityPublicKey/communityName above
151
+ if (extraPropsInEdit.length > 0) {
152
+ log("Found extra props on CommentEdit", extraPropsInEdit, "Will be adding them to extraProps column");
153
+ editTableRow.extraProps = remeda.pick(commentEditRaw, extraPropsInEdit);
154
+ }
155
+ const isEditDuplicate = community._dbHandler.hasCommentEditWithSignatureEncoded(editTableRow.signature.signature);
156
+ if (isEditDuplicate) {
157
+ throw new PKCError("ERR_DUPLICATE_COMMENT_EDIT", { editTableRow });
158
+ }
159
+ community._dbHandler.insertCommentEdits([editTableRow]);
160
+ // If author is deleting a pending or disapproved comment, purge it immediately from the database
161
+ if (commentEditRaw.deleted === true) {
162
+ const isPending = commentToBeEdited.pendingApproval;
163
+ const disapprovalResult = community._dbHandler._queryIsCommentApproved(commentToBeEdited);
164
+ const isDisapproved = disapprovalResult && !disapprovalResult.approved;
165
+ if (isPending || isDisapproved) {
166
+ log("Author deleted a pending/disapproved comment, purging immediately", commentEditRaw.commentCid);
167
+ community._dbHandler.purgeComment(commentEditRaw.commentCid);
168
+ community._communityUpdateTrigger = true;
169
+ }
170
+ }
171
+ }
172
+ export async function storeCommentModeration(community, commentModRaw, challengeRequestId) {
173
+ const log = Logger("pkc-js:local-community:storeCommentModeration");
174
+ const strippedOutModPublication = CommentModerationPubsubMessagePublicationSchema.strip().parse(commentModRaw); // we strip out here so we don't store any extra props in commentedits table
175
+ strippedOutModPublication.author = cleanWireAuthor(strippedOutModPublication.author); // strip runtime-only author fields (address, publicKey, etc.)
176
+ // Normalize to new wire format: ensure communityPublicKey/communityName for DB columns
177
+ if (!strippedOutModPublication.communityPublicKey)
178
+ strippedOutModPublication.communityPublicKey = community.signer.address;
179
+ if (!strippedOutModPublication.communityName && isStringDomain(community.address))
180
+ strippedOutModPublication.communityName = community.address;
181
+ const commentToBeEdited = community._dbHandler.queryComment(commentModRaw.commentCid); // We assume commentToBeEdited to be defined because we already tested for its existence above
182
+ if (!commentToBeEdited)
183
+ throw Error("The comment to edit doesn't exist"); // unlikely error to happen, but always a good idea to verify
184
+ const modSignerAddress = await getPKCAddressFromPublicKey(commentModRaw.signature.publicKey);
185
+ // Determine the target author signer address and domain if this moderation affects the author (ban/flair)
186
+ let targetAuthorSignerAddress;
187
+ let targetAuthorDomain;
188
+ if (strippedOutModPublication.commentModeration.author) {
189
+ // Check if the comment was published with pseudonymity - if so, get the original author address/domain
190
+ const aliasInfo = community._dbHandler.queryPseudonymityAliasByCommentCid(commentModRaw.commentCid);
191
+ if (aliasInfo) {
192
+ targetAuthorSignerAddress = await getPKCAddressFromPublicKey(aliasInfo.originalAuthorPublicKey);
193
+ targetAuthorDomain = aliasInfo.originalAuthorName || undefined;
194
+ }
195
+ else {
196
+ targetAuthorSignerAddress = commentToBeEdited.authorSignerAddress;
197
+ targetAuthorDomain = getAuthorNameFromWire(commentToBeEdited.author);
198
+ }
199
+ }
200
+ const modTableRow = {
201
+ ...strippedOutModPublication,
202
+ modSignerAddress,
203
+ insertedAt: timestamp(),
204
+ targetAuthorSignerAddress,
205
+ targetAuthorDomain
206
+ };
207
+ const isCommentModDuplicate = community._dbHandler.hasCommentModerationWithSignatureEncoded(modTableRow.signature.signature);
208
+ if (isCommentModDuplicate) {
209
+ throw new PKCError("ERR_DUPLICATE_COMMENT_MODERATION", { modTableRow });
210
+ }
211
+ const extraPropsInMod = remeda
212
+ .difference(remeda.keys.strict(commentModRaw), remeda.keys.strict(CommentModerationPubsubMessagePublicationSchema.shape))
213
+ .filter((key) => key !== "communityAddress"); // communityAddress is excluded because it's been converted to communityPublicKey/communityName above
214
+ if (extraPropsInMod.length > 0) {
215
+ log("Found extra props on CommentModeration", extraPropsInMod, "Will be adding them to extraProps column");
216
+ modTableRow.extraProps = remeda.pick(commentModRaw, extraPropsInMod);
217
+ }
218
+ if (modTableRow.commentModeration.purged) {
219
+ log("commentModeration.purged=true, and therefore will delete the post/comment and all its reply tree from the db as well as unpin the cids from ipfs", "comment cid is", modTableRow.commentCid);
220
+ const commentToPurge = community._dbHandler.queryComment(modTableRow.commentCid);
221
+ if (!commentToPurge)
222
+ throw Error("Comment to purge not found");
223
+ const purgedTableRows = community._dbHandler.purgeComment(modTableRow.commentCid);
224
+ for (const purgedTableRow of purgedTableRows)
225
+ await addAllCidsUnderPurgedCommentToBeRemoved(community, purgedTableRow);
226
+ log("Purged comment", modTableRow.commentCid, "and its comment and comment update children", "out of DB and IPFS");
227
+ await rmUnneededMfsPaths(community); // not sure if needed here
228
+ if (community.updateCid) {
229
+ // need to remove any update cids with reference to purged comment
230
+ community._blocksToRm.push(community.updateCid);
231
+ community._cidsToUnPin.add(community.updateCid);
232
+ }
233
+ }
234
+ else if ("approved" in modTableRow.commentModeration) {
235
+ if (modTableRow.commentModeration.approved) {
236
+ log("commentModeration.approved=true, and therefore move comment from pending approval and add it to IPFS", "comment cid is", modTableRow.commentCid);
237
+ await community._addCommentRowToIPFS(commentToBeEdited, Logger("pkc-js:local-community:storeCommentModeration:_addCommentRowToIPFS"));
238
+ community._dbHandler.approvePendingComment({ cid: modTableRow.commentCid });
239
+ }
240
+ else {
241
+ const shouldPurgeDisapprovedComment = Object.keys(modTableRow.commentModeration).length === 1; // no other props were included, if so purge the comment
242
+ log("commentModeration.approved=false, and therefore this comment will be removed entirely from DB", "should we purge this comment? = ", shouldPurgeDisapprovedComment, "comment cid is", modTableRow.commentCid);
243
+ if (shouldPurgeDisapprovedComment)
244
+ community._dbHandler.purgeComment(modTableRow.commentCid);
245
+ else
246
+ community._dbHandler.removeCommentFromPendingApproval({ cid: modTableRow.commentCid });
247
+ }
248
+ }
249
+ community._dbHandler.insertCommentModerations([modTableRow]);
250
+ community._communityUpdateTrigger = true;
251
+ log("Inserted comment moderation", "of comment", modTableRow.commentCid, "into db", "with props", modTableRow);
252
+ }
253
+ export async function storeVote(community, newVoteProps, challengeRequestId) {
254
+ const log = Logger("pkc-js:local-community:storeVote");
255
+ const authorSignerAddress = await getPKCAddressFromPublicKey(newVoteProps.signature.publicKey);
256
+ community._dbHandler.deleteVote(authorSignerAddress, newVoteProps.commentCid);
257
+ const voteTableRow = {
258
+ ...remeda.pick(newVoteProps, ["vote", "commentCid", "protocolVersion", "timestamp"]),
259
+ authorSignerAddress,
260
+ insertedAt: timestamp()
261
+ };
262
+ const extraPropsInVote = remeda.difference(remeda.keys.strict(newVoteProps), remeda.keys.strict(VotePubsubMessagePublicationSchema.shape));
263
+ if (extraPropsInVote.length > 0) {
264
+ log("Found extra props on Vote", extraPropsInVote, "Will be adding them to extraProps column");
265
+ voteTableRow.extraProps = remeda.pick(newVoteProps, extraPropsInVote);
266
+ }
267
+ community._dbHandler.insertVotes([voteTableRow]);
268
+ log("Inserted vote", "of comment", voteTableRow.commentCid, "into db", "with props", voteTableRow);
269
+ return undefined;
270
+ }
271
+ export async function storeCommunityEditPublication(community, editProps, challengeRequestId) {
272
+ const log = Logger("pkc-js:local-community:storeCommunityEdit");
273
+ const authorSignerAddress = await getPKCAddressFromPublicKey(editProps.signature.publicKey);
274
+ const authorIdentity = getAuthorNameFromWire(editProps.author) || authorSignerAddress;
275
+ log("Received community edit", editProps.communityEdit, "from author", authorIdentity, "with signer address", authorSignerAddress, "Will be using these props to edit the community props");
276
+ const propsAfterEdit = remeda.pick(community, remeda.keys.strict(editProps.communityEdit));
277
+ log("Current props from community edit (not edited yet)", propsAfterEdit);
278
+ lodashDeepMerge(propsAfterEdit, editProps.communityEdit);
279
+ await community.edit(propsAfterEdit);
280
+ return undefined;
281
+ }
282
+ export async function storeComment(community, opts) {
283
+ const { commentPubsub, pendingApproval, pseudonymityMode, originalCommentSignatureEncoded } = opts;
284
+ const log = Logger("pkc-js:local-community:handleChallengeExchange:storeComment");
285
+ const commentIpfs = {
286
+ ...commentPubsub,
287
+ ...(await calculateLinkProps(community, commentPubsub.link)),
288
+ ...(isPublicationPost(commentPubsub) && (await calculateLatestPostProps(community))),
289
+ ...(isPublicationReply(commentPubsub) && (await calculateReplyProps(community, commentPubsub))),
290
+ ...(pseudonymityMode ? { pseudonymityMode } : {})
291
+ };
292
+ // Normalize to new wire format: ensure communityPublicKey/communityName, remove old communityAddress
293
+ commentIpfs.communityPublicKey = community.signer.address;
294
+ if (isStringDomain(community.address))
295
+ commentIpfs.communityName = community.address;
296
+ delete commentIpfs.communityAddress;
297
+ // Strip runtime-only author fields (nameResolved, address, publicKey, etc.) before IPFS storage
298
+ commentIpfs.author = cleanWireAuthor(commentIpfs.author);
299
+ const ipfsClient = community._clientsManager.getDefaultKuboRpcClient();
300
+ const file = pendingApproval
301
+ ? undefined
302
+ : await retryKuboIpfsAddAndProvide({
303
+ ipfsClient: ipfsClient._client,
304
+ log,
305
+ content: deterministicStringify(commentIpfs),
306
+ addOptions: { pin: true },
307
+ provideOptions: { recursive: true },
308
+ provideInBackground: false
309
+ });
310
+ const commentCid = file?.path || (await calculateIpfsCidV0(deterministicStringify(commentIpfs)));
311
+ const postCid = commentIpfs.postCid || commentCid; // if postCid is not defined, then we're adding a post to IPFS, so its own cid is the postCid
312
+ const authorSignerAddress = await getPKCAddressFromPublicKey(commentPubsub.signature.publicKey);
313
+ const strippedOutCommentIpfs = CommentIpfsSchema.strip().parse(commentIpfs); // remove unknown props
314
+ strippedOutCommentIpfs.author = cleanWireAuthor(strippedOutCommentIpfs.author); // strip runtime-only author fields (address, publicKey, etc.)
315
+ const signaturesToCheck = Array.from(new Set([commentPubsub.signature.signature, originalCommentSignatureEncoded].filter((sig) => typeof sig === "string")));
316
+ const isCommentDuplicate = signaturesToCheck.some((signatureEncoded) => community._dbHandler.hasCommentWithSignatureEncoded(signatureEncoded));
317
+ if (isCommentDuplicate) {
318
+ community._cidsToUnPin.add(commentCid);
319
+ throw new PKCError("ERR_DUPLICATE_COMMENT", { file, commentIpfs, commentPubsub });
320
+ }
321
+ const commentRow = {
322
+ ...strippedOutCommentIpfs,
323
+ cid: commentCid,
324
+ postCid,
325
+ authorSignerAddress,
326
+ insertedAt: timestamp(),
327
+ pendingApproval
328
+ };
329
+ const unknownProps = remeda
330
+ .difference(remeda.keys.strict(commentPubsub), remeda.keys.strict(CommentPubsubMessagePublicationSchema.shape))
331
+ .filter((key) => key !== "communityAddress"); // communityAddress is excluded because it's been converted to communityPublicKey/communityName above
332
+ if (unknownProps.length > 0) {
333
+ log("Found extra props on Comment", unknownProps, "Will be adding them to extraProps column");
334
+ commentRow.extraProps = remeda.pick(commentPubsub, unknownProps);
335
+ }
336
+ if (originalCommentSignatureEncoded)
337
+ commentRow.originalCommentSignatureEncoded = originalCommentSignatureEncoded;
338
+ // we may need to query comment and verify its signature
339
+ community._dbHandler.createTransaction();
340
+ try {
341
+ if (!pendingApproval) {
342
+ const { number, postNumber } = community._dbHandler.getNextCommentNumbers(commentRow.depth);
343
+ commentRow.number = number;
344
+ if (typeof postNumber === "number")
345
+ commentRow.postNumber = postNumber;
346
+ }
347
+ community._dbHandler.insertComments([commentRow]);
348
+ if (typeof community.settings?.maxPendingApprovalCount === "number")
349
+ community._dbHandler.removeOldestPendingCommentIfWeHitMaxPendingCount(community.settings.maxPendingApprovalCount);
350
+ community._dbHandler.commitTransaction();
351
+ }
352
+ catch (e) {
353
+ community._dbHandler.rollbackTransaction();
354
+ throw e;
355
+ }
356
+ log("Inserted comment", commentRow.cid, "into db", "with props", commentRow);
357
+ return { comment: commentIpfs, cid: commentCid };
358
+ }
359
+ export async function storePublication(community, request, pendingApproval) {
360
+ if (request.vote)
361
+ return storeVote(community, request.vote, request.challengeRequestId);
362
+ else if (request.commentEdit) {
363
+ const commentEditWithAlias = await prepareCommentEditWithAlias(community, request.commentEdit);
364
+ return storeCommentEdit(community, commentEditWithAlias, request.challengeRequestId);
365
+ }
366
+ else if (request.commentModeration)
367
+ return storeCommentModeration(community, request.commentModeration, request.challengeRequestId);
368
+ else if (request.comment) {
369
+ const originalCommentSignatureEncoded = request.comment.signature.signature;
370
+ const { publication, anonymity } = await prepareCommentWithAnonymity(community, request.comment);
371
+ const storedComment = await storeComment(community, {
372
+ commentPubsub: publication,
373
+ pendingApproval,
374
+ pseudonymityMode: anonymity?.mode,
375
+ originalCommentSignatureEncoded: anonymity ? originalCommentSignatureEncoded : undefined
376
+ });
377
+ if (anonymity)
378
+ community._dbHandler.insertPseudonymityAliases([
379
+ {
380
+ commentCid: storedComment.cid,
381
+ aliasPrivateKey: anonymity.aliasPrivateKey,
382
+ originalAuthorPublicKey: anonymity.originalAuthorPublicKey,
383
+ originalAuthorName: getAuthorNameFromWire(anonymity.originalComment.author) || null,
384
+ mode: anonymity.mode,
385
+ insertedAt: timestamp()
386
+ }
387
+ ]);
388
+ return storedComment;
389
+ }
390
+ else if (request.communityEdit)
391
+ return storeCommunityEditPublication(community, request.communityEdit, request.challengeRequestId);
392
+ else
393
+ throw Error("Don't know how to store this publication" + request);
394
+ }
395
+ //# sourceMappingURL=publication-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"publication-store.js","sourceRoot":"","sources":["../../../../../../src/runtime/node/community/local-community/publication-store.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,uBAAuB,CAAC;AAC3C,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,SAAS,IAAI,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,cAAc,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A0C,GAAG,OAAO,CAAC,CAAC;AAC3E,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { messages } from "../../../../errors.js";
2
+ import type { CommentModerationPubsubMessagePublication } from "../../../../publications/comment-moderation/types.js";
3
+ import type { CommunityRoleNameUnion, Flair } from "../../../../community/types.js";
4
+ import type { DecryptedChallengeRequestMessageType, PublicationFromDecryptedChallengeRequest, PublicationWithCommunityAuthorFromDecryptedChallengeRequest } from "../../../../pubsub-messages/types.js";
5
+ import type { LocalCommunity } from "../local-community.js";
6
+ export declare function isFlairInAllowedList(flair: Flair, allowedFlairs: Flair[]): boolean;
7
+ export declare function isPublicationAuthorPartOfRoles(community: LocalCommunity, publication: Pick<CommentModerationPubsubMessagePublication, "author" | "signature">, rolesToCheckAgainst: CommunityRoleNameUnion[]): Promise<boolean>;
8
+ export declare function respondWithErrorIfSignatureOfPublicationIsInvalid(community: LocalCommunity, request: DecryptedChallengeRequestMessageType): Promise<void>;
9
+ export declare function checkPublicationValidity(community: LocalCommunity, request: DecryptedChallengeRequestMessageType, publication: PublicationFromDecryptedChallengeRequest, authorCommunity?: PublicationWithCommunityAuthorFromDecryptedChallengeRequest["author"]["community"]): Promise<messages | undefined>;