@pkcprotocol/pkc-js 0.0.63 → 0.0.64
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.
- package/dist/browser/clients/base-client-manager.js +14 -14
- package/dist/browser/clients/base-client-manager.js.map +1 -1
- package/dist/browser/community/community-client-manager.js +9 -11
- package/dist/browser/community/community-client-manager.js.map +1 -1
- package/dist/browser/community/community-gateway-selection.js +4 -4
- package/dist/browser/community/community-gateway-selection.js.map +1 -1
- package/dist/browser/community/community-wire.js +3 -3
- package/dist/browser/community/community-wire.js.map +1 -1
- package/dist/browser/community/remote-community.d.ts +1 -1
- package/dist/browser/community/remote-community.js +10 -7
- package/dist/browser/community/remote-community.js.map +1 -1
- package/dist/browser/community/rpc-local-community.js +3 -3
- package/dist/browser/community/rpc-local-community.js.map +1 -1
- package/dist/browser/community/rpc-remote-community.js +5 -5
- package/dist/browser/community/rpc-remote-community.js.map +1 -1
- package/dist/browser/community/schema.js +5 -5
- package/dist/browser/community/schema.js.map +1 -1
- package/dist/browser/generated-version.d.ts +1 -1
- package/dist/browser/generated-version.js +1 -1
- package/dist/browser/pages/pages-client-manager.js +11 -15
- package/dist/browser/pages/pages-client-manager.js.map +1 -1
- package/dist/browser/pages/util.js +9 -9
- package/dist/browser/pages/util.js.map +1 -1
- package/dist/browser/pkc/pkc-client-manager.js +6 -6
- package/dist/browser/pkc/pkc-client-manager.js.map +1 -1
- package/dist/browser/pkc/pkc.js +7 -7
- package/dist/browser/pkc/pkc.js.map +1 -1
- package/dist/browser/publications/comment/comment-client-manager.js +5 -5
- package/dist/browser/publications/comment/comment-client-manager.js.map +1 -1
- package/dist/browser/publications/comment/comment.js +15 -15
- package/dist/browser/publications/comment/comment.js.map +1 -1
- package/dist/browser/publications/comment/schema.js +17 -17
- package/dist/browser/publications/comment/schema.js.map +1 -1
- package/dist/browser/publications/comment-edit/schema.js +7 -7
- package/dist/browser/publications/comment-edit/schema.js.map +1 -1
- package/dist/browser/publications/comment-moderation/schema.js +11 -7
- package/dist/browser/publications/comment-moderation/schema.js.map +1 -1
- package/dist/browser/publications/community-edit/schema.js +6 -6
- package/dist/browser/publications/community-edit/schema.js.map +1 -1
- package/dist/browser/publications/publication-author.js +3 -3
- package/dist/browser/publications/publication-author.js.map +1 -1
- package/dist/browser/publications/publication-client-manager.js +4 -4
- package/dist/browser/publications/publication-client-manager.js.map +1 -1
- package/dist/browser/publications/publication.js +9 -9
- package/dist/browser/publications/publication.js.map +1 -1
- package/dist/browser/publications/vote/schema.js +11 -7
- package/dist/browser/publications/vote/schema.js.map +1 -1
- package/dist/browser/publications/vote/vote.js.map +1 -1
- package/dist/browser/pubsub-messages/schema.js +5 -5
- package/dist/browser/pubsub-messages/schema.js.map +1 -1
- package/dist/browser/rpc/src/index.js +12 -12
- package/dist/browser/rpc/src/index.js.map +1 -1
- package/dist/browser/runtime/browser/localforage-lru.js +2 -2
- package/dist/browser/runtime/browser/localforage-lru.js.map +1 -1
- package/dist/browser/runtime/node/addresses-rewriter-proxy-server.js +3 -3
- package/dist/browser/runtime/node/addresses-rewriter-proxy-server.js.map +1 -1
- package/dist/browser/runtime/node/community/challenges/index.js +3 -3
- package/dist/browser/runtime/node/community/challenges/index.js.map +1 -1
- package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/publication-match.js +4 -4
- package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/publication-match.js.map +1 -1
- package/dist/browser/runtime/node/community/db-handler.js +32 -32
- package/dist/browser/runtime/node/community/db-handler.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/challenges.js +7 -7
- package/dist/browser/runtime/node/community/local-community/challenges.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/comment-updates.js +5 -5
- package/dist/browser/runtime/node/community/local-community/comment-updates.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/db-state.js +8 -8
- package/dist/browser/runtime/node/community/local-community/db-state.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/editing.js +6 -6
- package/dist/browser/runtime/node/community/local-community/editing.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/ipns-publishing.js +10 -7
- package/dist/browser/runtime/node/community/local-community/ipns-publishing.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/lifecycle.js +4 -4
- package/dist/browser/runtime/node/community/local-community/lifecycle.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/publication-store.js +13 -19
- package/dist/browser/runtime/node/community/local-community/publication-store.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/publication-validation.js +10 -10
- package/dist/browser/runtime/node/community/local-community/publication-validation.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/reprovide-on-address-change.js +5 -5
- package/dist/browser/runtime/node/community/local-community/reprovide-on-address-change.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community.js +7 -7
- package/dist/browser/runtime/node/community/local-community.js.map +1 -1
- package/dist/browser/runtime/node/community/page-generator.js +5 -7
- package/dist/browser/runtime/node/community/page-generator.js.map +1 -1
- package/dist/browser/runtime/node/setup-kubo-address-rewriter-and-http-router.js +2 -2
- package/dist/browser/runtime/node/setup-kubo-address-rewriter-and-http-router.js.map +1 -1
- package/dist/browser/runtime/node/sqlite-lru-cache.js +2 -2
- package/dist/browser/runtime/node/sqlite-lru-cache.js.map +1 -1
- package/dist/browser/runtime/node/util.js +8 -6
- package/dist/browser/runtime/node/util.js.map +1 -1
- package/dist/browser/schema/schema.js +3 -3
- package/dist/browser/schema/schema.js.map +1 -1
- package/dist/browser/signer/constants.d.ts +1 -2
- package/dist/browser/signer/constants.js +9 -1
- package/dist/browser/signer/constants.js.map +1 -1
- package/dist/browser/signer/signatures.js +14 -12
- package/dist/browser/signer/signatures.js.map +1 -1
- package/dist/browser/stats.js +5 -5
- package/dist/browser/stats.js.map +1 -1
- package/dist/browser/test/test-util.d.ts +9 -10
- package/dist/browser/test/test-util.js +25 -37
- package/dist/browser/test/test-util.js.map +1 -1
- package/dist/browser/util.js +18 -17
- package/dist/browser/util.js.map +1 -1
- package/dist/bundled/bundle-manifest.json +61 -190
- package/dist/bundled/chunks/{helia-for-pkc-C6vMsrJ-.js → helia-for-pkc-CYDRSysz.js} +2 -2
- package/dist/bundled/chunks/{local-community-BQmiwsV4.js → local-community-DYvRQWsK.js} +146 -97
- package/dist/bundled/chunks/{local-community-BoIoFZHk.js → local-community-DyaGG6lj.js} +1 -1
- package/dist/bundled/chunks/{node-G40jxRL2.js → node-DadVit9c.js} +40 -37
- package/dist/bundled/chunks/{rpc-local-community-D4-NEPJb.js → rpc-local-community-1Uvl5iwp.js} +321 -92
- package/dist/bundled/chunks/{schema-SPGmy_14.js → schema-Dtvt2tQ8.js} +250 -3903
- package/dist/bundled/chunks/{util-CJ6nXIW9.js → util-CjfTxkQ8.js} +1 -1
- package/dist/bundled/index.js +1 -1
- package/dist/bundled/rpc/src/index.js +18 -22
- package/dist/node/clients/base-client-manager.js +14 -14
- package/dist/node/clients/base-client-manager.js.map +1 -1
- package/dist/node/community/community-client-manager.js +9 -11
- package/dist/node/community/community-client-manager.js.map +1 -1
- package/dist/node/community/community-gateway-selection.js +4 -4
- package/dist/node/community/community-gateway-selection.js.map +1 -1
- package/dist/node/community/community-wire.js +3 -3
- package/dist/node/community/community-wire.js.map +1 -1
- package/dist/node/community/remote-community.d.ts +1 -1
- package/dist/node/community/remote-community.js +10 -7
- package/dist/node/community/remote-community.js.map +1 -1
- package/dist/node/community/rpc-local-community.js +3 -3
- package/dist/node/community/rpc-local-community.js.map +1 -1
- package/dist/node/community/rpc-remote-community.js +5 -5
- package/dist/node/community/rpc-remote-community.js.map +1 -1
- package/dist/node/community/schema.js +5 -5
- package/dist/node/community/schema.js.map +1 -1
- package/dist/node/generated-version.d.ts +1 -1
- package/dist/node/generated-version.js +1 -1
- package/dist/node/pages/pages-client-manager.js +11 -15
- package/dist/node/pages/pages-client-manager.js.map +1 -1
- package/dist/node/pages/util.js +9 -9
- package/dist/node/pages/util.js.map +1 -1
- package/dist/node/pkc/pkc-client-manager.js +6 -6
- package/dist/node/pkc/pkc-client-manager.js.map +1 -1
- package/dist/node/pkc/pkc.js +7 -7
- package/dist/node/pkc/pkc.js.map +1 -1
- package/dist/node/publications/comment/comment-client-manager.js +5 -5
- package/dist/node/publications/comment/comment-client-manager.js.map +1 -1
- package/dist/node/publications/comment/comment.js +15 -15
- package/dist/node/publications/comment/comment.js.map +1 -1
- package/dist/node/publications/comment/schema.js +17 -17
- package/dist/node/publications/comment/schema.js.map +1 -1
- package/dist/node/publications/comment-edit/schema.js +7 -7
- package/dist/node/publications/comment-edit/schema.js.map +1 -1
- package/dist/node/publications/comment-moderation/schema.js +11 -7
- package/dist/node/publications/comment-moderation/schema.js.map +1 -1
- package/dist/node/publications/community-edit/schema.js +6 -6
- package/dist/node/publications/community-edit/schema.js.map +1 -1
- package/dist/node/publications/publication-author.js +3 -3
- package/dist/node/publications/publication-author.js.map +1 -1
- package/dist/node/publications/publication-client-manager.js +4 -4
- package/dist/node/publications/publication-client-manager.js.map +1 -1
- package/dist/node/publications/publication.js +9 -9
- package/dist/node/publications/publication.js.map +1 -1
- package/dist/node/publications/vote/schema.js +11 -7
- package/dist/node/publications/vote/schema.js.map +1 -1
- package/dist/node/publications/vote/vote.js.map +1 -1
- package/dist/node/pubsub-messages/schema.js +5 -5
- package/dist/node/pubsub-messages/schema.js.map +1 -1
- package/dist/node/rpc/src/index.js +12 -12
- package/dist/node/rpc/src/index.js.map +1 -1
- package/dist/node/runtime/browser/localforage-lru.js +2 -2
- package/dist/node/runtime/browser/localforage-lru.js.map +1 -1
- package/dist/node/runtime/node/addresses-rewriter-proxy-server.js +3 -3
- package/dist/node/runtime/node/addresses-rewriter-proxy-server.js.map +1 -1
- package/dist/node/runtime/node/community/challenges/index.js +3 -3
- package/dist/node/runtime/node/community/challenges/index.js.map +1 -1
- package/dist/node/runtime/node/community/challenges/pkc-js-challenges/publication-match.js +4 -4
- package/dist/node/runtime/node/community/challenges/pkc-js-challenges/publication-match.js.map +1 -1
- package/dist/node/runtime/node/community/db-handler.js +32 -32
- package/dist/node/runtime/node/community/db-handler.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/challenges.js +7 -7
- package/dist/node/runtime/node/community/local-community/challenges.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/comment-updates.js +5 -5
- package/dist/node/runtime/node/community/local-community/comment-updates.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/db-state.js +8 -8
- package/dist/node/runtime/node/community/local-community/db-state.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/editing.js +6 -6
- package/dist/node/runtime/node/community/local-community/editing.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/ipns-publishing.js +10 -7
- package/dist/node/runtime/node/community/local-community/ipns-publishing.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/lifecycle.js +4 -4
- package/dist/node/runtime/node/community/local-community/lifecycle.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/publication-store.js +13 -19
- package/dist/node/runtime/node/community/local-community/publication-store.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/publication-validation.js +10 -10
- package/dist/node/runtime/node/community/local-community/publication-validation.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/reprovide-on-address-change.js +5 -5
- package/dist/node/runtime/node/community/local-community/reprovide-on-address-change.js.map +1 -1
- package/dist/node/runtime/node/community/local-community.js +7 -7
- package/dist/node/runtime/node/community/local-community.js.map +1 -1
- package/dist/node/runtime/node/community/page-generator.js +5 -7
- package/dist/node/runtime/node/community/page-generator.js.map +1 -1
- package/dist/node/runtime/node/setup-kubo-address-rewriter-and-http-router.js +2 -2
- package/dist/node/runtime/node/setup-kubo-address-rewriter-and-http-router.js.map +1 -1
- package/dist/node/runtime/node/sqlite-lru-cache.js +2 -2
- package/dist/node/runtime/node/sqlite-lru-cache.js.map +1 -1
- package/dist/node/runtime/node/util.js +8 -6
- package/dist/node/runtime/node/util.js.map +1 -1
- package/dist/node/schema/schema.js +3 -3
- package/dist/node/schema/schema.js.map +1 -1
- package/dist/node/signer/constants.d.ts +1 -2
- package/dist/node/signer/constants.js +9 -1
- package/dist/node/signer/constants.js.map +1 -1
- package/dist/node/signer/signatures.js +14 -12
- package/dist/node/signer/signatures.js.map +1 -1
- package/dist/node/stats.js +5 -5
- package/dist/node/stats.js.map +1 -1
- package/dist/node/test/test-util.d.ts +9 -10
- package/dist/node/test/test-util.js +25 -37
- package/dist/node/test/test-util.js.map +1 -1
- package/dist/node/util.js +18 -17
- package/dist/node/util.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { i as __toESM, r as __require, t as __commonJSMin } from "./chunk-2rV9d50f.js";
|
|
2
|
-
import { $ as pubsubTopicToDhtKey, At as trackStartedCommunity, Bt as CommunityEditPublicationPubsubReservedFields, C as contentContainsMarkdownAudio, Ct as findUpdatingCommunity, En as CommentUpdateSchema, F as getIpnsRecordInLocalKuboNode, Fn as CommentEditPubsubMessagePublicationSchema, Ft as untrackUpdatingCommunity, G as isLinkOfAudio, Gt as CommentModerationPubsubMessagePublicationSchema, In as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema, It as require_sha256, J as isLinkOfVideo, Jt as CommentModerationsTableRowSchema, K as isLinkOfImage, Kt as CommentModerationReservedFields, L as hideClassPrivateProps, Ln as CommentEditReservedFields, M as genToArray, Mt as trackUpdatingCommunity, N as getEquivalentCommunityAddresses, Nt as untrackStartedCommunity, O as derivePublicationFromChallengeRequest, On as CommentUpdateTableRowSchema, P as getErrorCodeFromMessage, Q as isStringDomain, R as ipnsNameToIpnsOverPubsubTopic, Rt as pTimeout, S as calculateStringSizeSameAsIpfsAddCidV0, T as contentContainsMarkdownVideos, Un as AuthorReservedFields, W as isLinkOfAnimatedImage, Xn as
|
|
3
|
-
import { A as deriveDbPosts, At as verifyCommunityEdit, Bt as getCommunityPublicKeyFromWire, C as BackupAbortError, Dt as verifyCommentPubsubMessage, E as calculateInlineRepliesBudget, Et as verifyCommentModeration, F as importSignerIntoKuboNode, Ft as getAuthorNameFromWire, G as REPLY_REPLIES_SORT_TYPES, Gt as getIpfsKeyFromPrivateKey, Ht as decode, Jn as
|
|
2
|
+
import { $ as pubsubTopicToDhtKey, $n as t$7, At as trackStartedCommunity, Bt as CommunityEditPublicationPubsubReservedFields, C as contentContainsMarkdownAudio, Ct as findUpdatingCommunity, En as CommentUpdateSchema, F as getIpnsRecordInLocalKuboNode, Fn as CommentEditPubsubMessagePublicationSchema, Ft as untrackUpdatingCommunity, G as isLinkOfAudio, Gt as CommentModerationPubsubMessagePublicationSchema, In as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema, It as require_sha256, J as isLinkOfVideo, Jt as CommentModerationsTableRowSchema, K as isLinkOfImage, Kt as CommentModerationReservedFields, L as hideClassPrivateProps, Ln as CommentEditReservedFields, M as genToArray, Mr as ZodError, Mt as trackUpdatingCommunity, N as getEquivalentCommunityAddresses, Nt as untrackStartedCommunity, O as derivePublicationFromChallengeRequest, On as CommentUpdateTableRowSchema, P as getErrorCodeFromMessage, Q as isStringDomain, Qn as n$3, R as ipnsNameToIpnsOverPubsubTopic, Rt as pTimeout, S as calculateStringSizeSameAsIpfsAddCidV0, T as contentContainsMarkdownVideos, Un as AuthorReservedFields, W as isLinkOfAnimatedImage, Xn as n$4, Y as isLinkValid, Zn as t$8, _r as PKCError, _t as timestamp, a as ChallengeRequestMessageSchema, ar as t$4, at as removeNullUndefinedValues, b as areEquivalentCommunityAddresses, bt as findCommunityInRegistry, cr as t$5, d as DecryptedChallengeRequestSchema, dr as require_retry, dt as retryKuboIpfsAddAndProvide, er as t$6, fn as VotePubsubMessagePublicationSchema, hn as VoteTablesRowSchema, ht as statMfsPathSafely, ir as r$1, k as doesDomainAddressHaveCapitalLetter, kn as CommentsTableRowSchema, kt as syncCommunityRegistryEntry, lr as t$3, lt as retryKuboBlockPutPinAndProvidePubsubTopic, mt as sleepUntilTimeoutOrAbort, nn as CommunityIpfsSchema, nr as e$1, nt as removeBlocksFromKuboNode, pn as VotePubsubReservedFields, q as isLinkOfMedia, r as ChallengeMessageSchema, rn as CommunitySignedPropertyNames, rt as removeMfsFilesSafely, s as ChallengeVerificationMessageSchema, t as ChallengeAnswerMessageSchema, tr as e, u as DecryptedChallengeRequestPublicationSchema, vn as CommentIpfsSchema, vr as messages, w as contentContainsMarkdownImages, x as calculateIpfsCidV0, xt as findStartedCommunity, y as version_default, yn as CommentPubsubMessageReservedFields, yr as logger_default, yt as writeKuboFilesWithTimeout, zn as CommentEditsTableRowSchema } from "./schema-Dtvt2tQ8.js";
|
|
3
|
+
import { $n as t$10, A as deriveDbPosts, At as verifyCommunityEdit, Bt as getCommunityPublicKeyFromWire, C as BackupAbortError, Dt as verifyCommentPubsubMessage, E as calculateInlineRepliesBudget, Et as verifyCommentModeration, F as importSignerIntoKuboNode, Ft as getAuthorNameFromWire, G as REPLY_REPLIES_SORT_TYPES, Gt as getIpfsKeyFromPrivateKey, Ht as decode, Jn as r$2, Jt as getPublicKeyFromPrivateKey, K as TIMEFRAMES_TO_SECONDS, Kn as t$9, Kt as getPKCAddressFromPublicKey, M as getDefaultCommunityDbConfig, Mt as buildRuntimeAuthor, Nt as cleanWireAuthor, O as deleteOldCommunityInWindows, Ot as verifyCommentUpdate, P as getThumbnailPropsOfLink, R as moveCommunityDbToDeletedDirectory, S as encryptEd25519AesGcmPublicKeyBuffer, St as verifyChallengeRequest, T as calculateExpectedSignatureSize, Tt as verifyCommentIpfs, U as POSTS_SORT_TYPES, Ut as encode, W as POST_REPLIES_SORT_TYPES, Xn as n$6, Yn as t$11, Yt as createSchemaRowParser, Z as iterateOverPageCidsToFindAllCids, Zn as n$5, _ as SignerWithPublicKeyAddress, _t as signCommunity, a as pkcJsChallenges, b as decryptEd25519AesGcmPublicKeyBuffer, bt as verifyChallengeAnswer, cn as parseCommunityIpfsSchemaPassthroughWithPKCErrorIfItFails, d as MAX_FILE_SIZE_BYTES_FOR_COMMUNITY_IPFS, dt as signChallengeVerification, er as stringify, f as KeyvBetterSqlite3, ft as signComment, gt as signCommentUpdateForChallengeVerification, ht as signCommentUpdate, i as getCommunityChallengeFromCommunityChallengeSettings, it as pLimit, j as deriveDbReplies, jt as verifyVote, k as deriveCommentIpfsFromCommentTableRow, kt as verifyCommunity, l as normalizeSelfAddrsForProvider, lt as signChallengeMessage, nr as require_lodash_merge, o as TrackedInstanceRegistry, on as parseCommunityEditOptionsSchemaWithPKCErrorIfItFails, pt as signCommentEdit, qn as t$12, qt as getPKCAddressFromPublicKeySync, r as getChallengeVerification, s as LRUCache, st as cleanUpBeforePublishing, t as RpcLocalCommunity, tr as STORAGE_KEYS, vn as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, w as backupCommunityDb, wt as verifyCommentEdit, xn as parseJsonWithPKCErrorIfFails, z as resolveDbPostsCidRefs, zt as getCommunityNameFromWire } from "./rpc-local-community-1Uvl5iwp.js";
|
|
4
4
|
import { randomFillSync, randomUUID } from "node:crypto";
|
|
5
5
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
6
6
|
import path from "node:path";
|
|
@@ -12,8 +12,59 @@ import fs from "fs";
|
|
|
12
12
|
import Database from "better-sqlite3";
|
|
13
13
|
import { CID } from "multiformats/cid";
|
|
14
14
|
import { of } from "typestub-ipfs-only-hash";
|
|
15
|
+
//#region node_modules/remeda/dist/entries.js
|
|
16
|
+
function t$2(...t) {
|
|
17
|
+
return t$3(Object.entries, t);
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region node_modules/remeda/dist/groupBy.js
|
|
21
|
+
function t$1(...t) {
|
|
22
|
+
return t$3(n$2, t);
|
|
23
|
+
}
|
|
24
|
+
const n$2 = (e, t) => {
|
|
25
|
+
let n = Object.create(null);
|
|
26
|
+
for (let r = 0; r < e.length; r++) {
|
|
27
|
+
let i = e[r], a = t(i, r, e);
|
|
28
|
+
if (a !== void 0) {
|
|
29
|
+
let e = n[a];
|
|
30
|
+
e === void 0 ? n[a] = [i] : e.push(i);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return Object.setPrototypeOf(n, Object.prototype), n;
|
|
34
|
+
};
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region node_modules/remeda/dist/sumBy.js
|
|
37
|
+
function t(...t) {
|
|
38
|
+
return t$3(n$1, t);
|
|
39
|
+
}
|
|
40
|
+
const n$1 = (e, t) => {
|
|
41
|
+
let n = e.entries(), r = n.next();
|
|
42
|
+
if (`done` in r && r.done) return 0;
|
|
43
|
+
let { value: [, i] } = r, a = t(i, 0, e);
|
|
44
|
+
for (let [r, i] of n) {
|
|
45
|
+
let n = t(i, r, e);
|
|
46
|
+
a += n;
|
|
47
|
+
}
|
|
48
|
+
return a;
|
|
49
|
+
};
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region node_modules/remeda/dist/uniqueBy.js
|
|
52
|
+
function n(...e) {
|
|
53
|
+
return t$4(r, e);
|
|
54
|
+
}
|
|
55
|
+
function r(t) {
|
|
56
|
+
let n = t, r = /* @__PURE__ */ new Set();
|
|
57
|
+
return (t, i, a) => {
|
|
58
|
+
let o = n(t, i, a);
|
|
59
|
+
return r.has(o) ? t$5 : (r.add(o), {
|
|
60
|
+
done: !1,
|
|
61
|
+
hasNext: !0,
|
|
62
|
+
next: t
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
//#endregion
|
|
15
67
|
//#region dist/node/runtime/node/community/local-community/comment-updates.js
|
|
16
|
-
var import_commonjs = /* @__PURE__ */ __toESM(require_commonjs(), 1);
|
|
17
68
|
function pubsubTopicWithfallback(community) {
|
|
18
69
|
return community.pubsubTopic || community.address;
|
|
19
70
|
}
|
|
@@ -54,7 +105,7 @@ async function calculateNewCommentUpdate(community, comment) {
|
|
|
54
105
|
if ("singlePreloadedPage" in generatedRepliesPages) commentUpdatePriorToSigning.replies = { pages: generatedRepliesPages.singlePreloadedPage };
|
|
55
106
|
else if (generatedRepliesPages.pageCids) commentUpdatePriorToSigning.replies = {
|
|
56
107
|
pageCids: generatedRepliesPages.pageCids,
|
|
57
|
-
pages:
|
|
108
|
+
pages: t$9(generatedRepliesPages.pages, [preloadedRepliesPages])
|
|
58
109
|
};
|
|
59
110
|
}
|
|
60
111
|
const allPageCids = generatedRepliesPages && !("singlePreloadedPage" in generatedRepliesPages) ? generatedRepliesPages.allPageCids : void 0;
|
|
@@ -119,13 +170,13 @@ async function updateCommentsThatNeedToBeUpdated(community) {
|
|
|
119
170
|
if (commentsToUpdate.length === 0) return [];
|
|
120
171
|
community._communityUpdateTrigger = true;
|
|
121
172
|
log(`Will update ${commentsToUpdate.length} comments in this update loop for community (${community.address})`);
|
|
122
|
-
const commentsByPostCid =
|
|
173
|
+
const commentsByPostCid = t$1(commentsToUpdate, (x) => x.postCid);
|
|
123
174
|
const allCommentUpdateRows = [];
|
|
124
175
|
const postLimit = pLimit(10);
|
|
125
176
|
const postProcessingPromises = Object.entries(commentsByPostCid).map(([postCid, commentsForPost]) => postLimit(async () => {
|
|
126
177
|
try {
|
|
127
|
-
const commentsByDepth =
|
|
128
|
-
const depthsKeySorted =
|
|
178
|
+
const commentsByDepth = t$1(commentsForPost, (x) => x.depth);
|
|
179
|
+
const depthsKeySorted = t$6(commentsByDepth).sort((a, b) => Number(b) - Number(a));
|
|
129
180
|
const postUpdateRows = [];
|
|
130
181
|
for (const depthKey of depthsKeySorted) {
|
|
131
182
|
const commentsAtDepth = commentsByDepth[depthKey];
|
|
@@ -426,7 +477,7 @@ async function publishChallenges(community, challenges, request) {
|
|
|
426
477
|
const pubsubClient = community._clientsManager.getDefaultKuboPubsubClient();
|
|
427
478
|
community._clientsManager.updateKuboRpcPubsubState("publishing-challenge", pubsubClient.url);
|
|
428
479
|
if (!community._challengeExchangesFromLocalPublishers[request.challengeRequestId.toString()]) await community._clientsManager.pubsubPublish(pubsubTopicWithfallback(community), challengeMessage);
|
|
429
|
-
log(`Community ${community.address} with pubsub topic ${pubsubTopicWithfallback(community)} published ${challengeMessage.type} over pubsub: `,
|
|
480
|
+
log(`Community ${community.address} with pubsub topic ${pubsubTopicWithfallback(community)} published ${challengeMessage.type} over pubsub: `, t$9(toSignChallenge, ["timestamp"]), toEncryptChallenge.challenges.map((challenge) => challenge.type));
|
|
430
481
|
community._clientsManager.updateKuboRpcPubsubState("waiting-challenge-answers", pubsubClient.url);
|
|
431
482
|
community.emit("challenge", {
|
|
432
483
|
...challengeMessage,
|
|
@@ -454,7 +505,7 @@ async function publishFailedChallengeVerification(community, result, challengeRe
|
|
|
454
505
|
};
|
|
455
506
|
const pubsubClient = community._clientsManager.getDefaultKuboPubsubClient();
|
|
456
507
|
community._clientsManager.updateKuboRpcPubsubState("publishing-challenge-verification", pubsubClient.url);
|
|
457
|
-
log(`Will publish ${challengeVerification.type} over pubsub topic ${pubsubTopicWithfallback(community)} on community ${community.address}:`,
|
|
508
|
+
log(`Will publish ${challengeVerification.type} over pubsub topic ${pubsubTopicWithfallback(community)} on community ${community.address}:`, n$3(toSignVerification, ["challengeRequestId"]));
|
|
458
509
|
if (!community._challengeExchangesFromLocalPublishers[challengeRequestId.toString()]) await community._clientsManager.pubsubPublish(pubsubTopicWithfallback(community), challengeVerification);
|
|
459
510
|
community._clientsManager.updateKuboRpcPubsubState("waiting-challenge-requests", pubsubClient.url);
|
|
460
511
|
community.emit("challengeverification", challengeVerification);
|
|
@@ -604,7 +655,7 @@ async function publishChallengeVerification(community, challengeResult, request,
|
|
|
604
655
|
community._ongoingChallengeExchanges.delete(request.challengeRequestId.toString());
|
|
605
656
|
delete community._challengeExchangesFromLocalPublishers[request.challengeRequestId.toString()];
|
|
606
657
|
cleanUpChallengeAnswerPromise(community, request.challengeRequestId.toString());
|
|
607
|
-
log.trace(`Published ${challengeVerification.type} over pubsub topic ${pubsubTopicWithfallback(community)}:`,
|
|
658
|
+
log.trace(`Published ${challengeVerification.type} over pubsub topic ${pubsubTopicWithfallback(community)}:`, n$3(objectToEmit, [
|
|
608
659
|
"signature",
|
|
609
660
|
"encrypted",
|
|
610
661
|
"challengeRequestId"
|
|
@@ -640,7 +691,7 @@ function buildRuntimeChallengeRequestPublication({ publication, authorCommunity
|
|
|
640
691
|
};
|
|
641
692
|
}
|
|
642
693
|
function buildRuntimeChallengeRequest({ request, authorCommunity }) {
|
|
643
|
-
const runtimeRequest =
|
|
694
|
+
const runtimeRequest = t$10(request);
|
|
644
695
|
if (request.comment) runtimeRequest.comment = buildRuntimeChallengeRequestPublication({
|
|
645
696
|
publication: request.comment,
|
|
646
697
|
authorCommunity
|
|
@@ -665,7 +716,7 @@ function buildRuntimeChallengeRequest({ request, authorCommunity }) {
|
|
|
665
716
|
}
|
|
666
717
|
async function parseAndValidateChallengeRequest(community, request, log) {
|
|
667
718
|
const decryptedRequest = await parseChallengeRequestPublicationOrRespondWithFailure(community, request, await decryptOrRespondWithFailure(community, request));
|
|
668
|
-
const publicationFieldNames =
|
|
719
|
+
const publicationFieldNames = t$6(DecryptedChallengeRequestPublicationSchema.shape);
|
|
669
720
|
let publication;
|
|
670
721
|
try {
|
|
671
722
|
publication = derivePublicationFromChallengeRequest(decryptedRequest);
|
|
@@ -789,7 +840,7 @@ async function handleChallengeRequest(community, request, isLocalPublisher) {
|
|
|
789
840
|
request,
|
|
790
841
|
validateTimestampRange: true
|
|
791
842
|
});
|
|
792
|
-
if (!requestSignatureValidation.valid) throw new PKCError(getErrorCodeFromMessage(requestSignatureValidation.reason), { challengeRequest:
|
|
843
|
+
if (!requestSignatureValidation.valid) throw new PKCError(getErrorCodeFromMessage(requestSignatureValidation.reason), { challengeRequest: n$3(request, ["encrypted"]) });
|
|
793
844
|
const parsed = await parseAndValidateChallengeRequest(community, request, log);
|
|
794
845
|
if (!parsed) return;
|
|
795
846
|
const challengeVerification = await runChallengeExchangeIfNeeded(community, parsed, log);
|
|
@@ -886,7 +937,7 @@ async function handleChallengeExchange(community, pubsubMsg) {
|
|
|
886
937
|
//#endregion
|
|
887
938
|
//#region dist/node/runtime/node/community/local-community/publication-validation.js
|
|
888
939
|
function isFlairInAllowedList(flair, allowedFlairs) {
|
|
889
|
-
return allowedFlairs.some((allowed) =>
|
|
940
|
+
return allowedFlairs.some((allowed) => t$11(allowed, flair));
|
|
890
941
|
}
|
|
891
942
|
async function isPublicationAuthorPartOfRoles(community, publication, rolesToCheckAgainst) {
|
|
892
943
|
if (!community.roles) return false;
|
|
@@ -954,7 +1005,7 @@ async function checkWireFormatAndCommunityAuthor(community, publication, authorC
|
|
|
954
1005
|
if (typeof authorCommunity?.banExpiresAt === "number" && authorCommunity.banExpiresAt > timestamp()) return messages.ERR_AUTHOR_IS_BANNED;
|
|
955
1006
|
}
|
|
956
1007
|
async function checkAuthorIdentity(community, publication, log) {
|
|
957
|
-
if (publication.author &&
|
|
1008
|
+
if (publication.author && r$2(t$6(publication.author), AuthorReservedFields).length > 0) return messages.ERR_PUBLICATION_AUTHOR_HAS_RESERVED_FIELD;
|
|
958
1009
|
const authorName = getAuthorNameFromWire(publication.author);
|
|
959
1010
|
if (authorName && !isStringDomain(authorName)) {
|
|
960
1011
|
log("Rejecting publication: author.name is not a domain", authorName);
|
|
@@ -1011,7 +1062,7 @@ async function checkParentAndPostState(community, request, publication) {
|
|
|
1011
1062
|
async function checkCommentPublication(community, request) {
|
|
1012
1063
|
if (!request.comment) return void 0;
|
|
1013
1064
|
const commentPublication = request.comment;
|
|
1014
|
-
if (
|
|
1065
|
+
if (r$2(t$6(commentPublication), CommentPubsubMessageReservedFields).length > 0) return messages.ERR_COMMENT_HAS_RESERVED_FIELD;
|
|
1015
1066
|
if (community.features?.requirePostLink && !commentPublication.parentCid && (!commentPublication.link || !community.features?.requirePostLinkIsMedia && !isLinkValid(commentPublication.link))) return messages.ERR_COMMENT_HAS_INVALID_LINK_FIELD;
|
|
1016
1067
|
if (community.features?.requirePostLinkIsMedia && commentPublication.link && (!isLinkValid(commentPublication.link) || !isLinkOfMedia(commentPublication.link))) return messages.ERR_POST_LINK_IS_NOT_OF_MEDIA;
|
|
1017
1068
|
if (community.features?.requireReplyLink && commentPublication.parentCid && (!commentPublication.link || !community.features?.requireReplyLinkIsMedia && !isLinkValid(commentPublication.link))) return messages.ERR_REPLY_HAS_INVALID_LINK_FIELD;
|
|
@@ -1068,7 +1119,7 @@ async function checkCommentPublication(community, request) {
|
|
|
1068
1119
|
async function checkVotePublication(community, request) {
|
|
1069
1120
|
if (!request.vote) return void 0;
|
|
1070
1121
|
const votePublication = request.vote;
|
|
1071
|
-
if (
|
|
1122
|
+
if (r$2(VotePubsubReservedFields, t$6(votePublication)).length > 0) return messages.ERR_VOTE_HAS_RESERVED_FIELD;
|
|
1072
1123
|
if (community.features?.noUpvotes && votePublication.vote === 1) return messages.ERR_NOT_ALLOWED_TO_PUBLISH_UPVOTES;
|
|
1073
1124
|
if (community.features?.noDownvotes && votePublication.vote === -1) return messages.ERR_NOT_ALLOWED_TO_PUBLISH_DOWNVOTES;
|
|
1074
1125
|
const commentToVoteOn = community._dbHandler.queryComment(request.vote.commentCid);
|
|
@@ -1082,7 +1133,7 @@ async function checkVotePublication(community, request) {
|
|
|
1082
1133
|
async function checkCommentModerationPublication(community, request) {
|
|
1083
1134
|
if (!request.commentModeration) return void 0;
|
|
1084
1135
|
const commentModerationPublication = request.commentModeration;
|
|
1085
|
-
if (
|
|
1136
|
+
if (r$2(CommentModerationReservedFields, t$6(commentModerationPublication)).length > 0) return messages.ERR_COMMENT_MODERATION_HAS_RESERVED_FIELD;
|
|
1086
1137
|
const isAuthorMod = await isPublicationAuthorPartOfRoles(community, commentModerationPublication, [
|
|
1087
1138
|
"owner",
|
|
1088
1139
|
"moderator",
|
|
@@ -1099,18 +1150,18 @@ async function checkCommentModerationPublication(community, request) {
|
|
|
1099
1150
|
async function checkCommunityEditPublication(community, request) {
|
|
1100
1151
|
if (!request.communityEdit) return void 0;
|
|
1101
1152
|
const communityEdit = request.communityEdit;
|
|
1102
|
-
if (
|
|
1153
|
+
if (r$2(CommunityEditPublicationPubsubReservedFields, t$6(communityEdit)).length > 0) return messages.ERR_COMMUNITY_EDIT_HAS_RESERVED_FIELD;
|
|
1103
1154
|
if (communityEdit.communityEdit.roles || communityEdit.communityEdit.address) {
|
|
1104
1155
|
if (!await isPublicationAuthorPartOfRoles(community, communityEdit, ["owner"])) return messages.ERR_COMMUNITY_EDIT_ATTEMPTED_TO_MODIFY_OWNER_EXCLUSIVE_PROPS;
|
|
1105
1156
|
}
|
|
1106
1157
|
if (!await isPublicationAuthorPartOfRoles(community, communityEdit, ["owner", "admin"])) return messages.ERR_COMMUNITY_EDIT_ATTEMPTED_TO_MODIFY_COMMUNITY_WITHOUT_BEING_OWNER_OR_ADMIN;
|
|
1107
|
-
const allowedCommunityEditKeys = [...
|
|
1108
|
-
if (
|
|
1158
|
+
const allowedCommunityEditKeys = [...t$6(CommunityIpfsSchema.shape), "address"];
|
|
1159
|
+
if (r$1(t$6(communityEdit.communityEdit), allowedCommunityEditKeys).length > 0) return messages.ERR_COMMUNITY_EDIT_ATTEMPTED_TO_NON_PUBLIC_PROPS;
|
|
1109
1160
|
}
|
|
1110
1161
|
async function checkCommentEditPublication(community, request) {
|
|
1111
1162
|
if (!request.commentEdit) return void 0;
|
|
1112
1163
|
const commentEditPublication = request.commentEdit;
|
|
1113
|
-
if (
|
|
1164
|
+
if (r$2(CommentEditReservedFields, t$6(commentEditPublication)).length > 0) return messages.ERR_COMMENT_EDIT_HAS_RESERVED_FIELD;
|
|
1114
1165
|
const commentToBeEdited = community._dbHandler.queryComment(commentEditPublication.commentCid);
|
|
1115
1166
|
if (!commentToBeEdited) return messages.ERR_COMMENT_EDIT_NO_COMMENT_TO_EDIT;
|
|
1116
1167
|
if (community._dbHandler.hasCommentEditWithSignatureEncoded(commentEditPublication.signature.signature)) return messages.ERR_DUPLICATE_COMMENT_EDIT;
|
|
@@ -1219,7 +1270,7 @@ async function prepareCommentWithAnonymity(community, originalComment) {
|
|
|
1219
1270
|
});
|
|
1220
1271
|
const displayName = originalComment.author?.displayName;
|
|
1221
1272
|
const sanitizedAuthor = cleanWireAuthor(displayName !== void 0 ? { displayName } : void 0);
|
|
1222
|
-
const anonymizedComment =
|
|
1273
|
+
const anonymizedComment = t$10(originalComment);
|
|
1223
1274
|
if (sanitizedAuthor !== void 0) anonymizedComment.author = sanitizedAuthor;
|
|
1224
1275
|
else delete anonymizedComment.author;
|
|
1225
1276
|
anonymizedComment.signature = await signComment({
|
|
@@ -1247,7 +1298,7 @@ async function prepareCommentEditWithAlias(community, originalEdit) {
|
|
|
1247
1298
|
privateKey: aliasSignerOfComment.aliasPrivateKey,
|
|
1248
1299
|
type: "ed25519"
|
|
1249
1300
|
});
|
|
1250
|
-
const commentEditSignedByAlias =
|
|
1301
|
+
const commentEditSignedByAlias = t$10(originalEdit);
|
|
1251
1302
|
delete commentEditSignedByAlias.author;
|
|
1252
1303
|
commentEditSignedByAlias.signature = await signCommentEdit({
|
|
1253
1304
|
edit: {
|
|
@@ -1275,10 +1326,10 @@ async function storeCommentEdit(community, commentEditRaw, challengeRequestId) {
|
|
|
1275
1326
|
authorSignerAddress,
|
|
1276
1327
|
insertedAt: timestamp()
|
|
1277
1328
|
};
|
|
1278
|
-
const extraPropsInEdit =
|
|
1329
|
+
const extraPropsInEdit = r$1(t$6(commentEditRaw), t$6(CommentEditPubsubMessagePublicationSchema.shape)).filter((key) => key !== "communityAddress");
|
|
1279
1330
|
if (extraPropsInEdit.length > 0) {
|
|
1280
1331
|
log("Found extra props on CommentEdit", extraPropsInEdit, "Will be adding them to extraProps column");
|
|
1281
|
-
editTableRow.extraProps =
|
|
1332
|
+
editTableRow.extraProps = t$9(commentEditRaw, extraPropsInEdit);
|
|
1282
1333
|
}
|
|
1283
1334
|
if (community._dbHandler.hasCommentEditWithSignatureEncoded(editTableRow.signature.signature)) throw new PKCError("ERR_DUPLICATE_COMMENT_EDIT", { editTableRow });
|
|
1284
1335
|
community._dbHandler.insertCommentEdits([editTableRow]);
|
|
@@ -1322,10 +1373,10 @@ async function storeCommentModeration(community, commentModRaw, challengeRequest
|
|
|
1322
1373
|
targetAuthorDomain
|
|
1323
1374
|
};
|
|
1324
1375
|
if (community._dbHandler.hasCommentModerationWithSignatureEncoded(modTableRow.signature.signature)) throw new PKCError("ERR_DUPLICATE_COMMENT_MODERATION", { modTableRow });
|
|
1325
|
-
const extraPropsInMod =
|
|
1376
|
+
const extraPropsInMod = r$1(t$6(commentModRaw), t$6(CommentModerationPubsubMessagePublicationSchema.shape)).filter((key) => key !== "communityAddress");
|
|
1326
1377
|
if (extraPropsInMod.length > 0) {
|
|
1327
1378
|
log("Found extra props on CommentModeration", extraPropsInMod, "Will be adding them to extraProps column");
|
|
1328
|
-
modTableRow.extraProps =
|
|
1379
|
+
modTableRow.extraProps = t$9(commentModRaw, extraPropsInMod);
|
|
1329
1380
|
}
|
|
1330
1381
|
if (modTableRow.commentModeration.purged) {
|
|
1331
1382
|
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);
|
|
@@ -1357,7 +1408,7 @@ async function storeVote(community, newVoteProps, challengeRequestId) {
|
|
|
1357
1408
|
const authorSignerAddress = await getPKCAddressFromPublicKey(newVoteProps.signature.publicKey);
|
|
1358
1409
|
community._dbHandler.deleteVote(authorSignerAddress, newVoteProps.commentCid);
|
|
1359
1410
|
const voteTableRow = {
|
|
1360
|
-
...
|
|
1411
|
+
...t$9(newVoteProps, [
|
|
1361
1412
|
"vote",
|
|
1362
1413
|
"commentCid",
|
|
1363
1414
|
"protocolVersion",
|
|
@@ -1366,10 +1417,10 @@ async function storeVote(community, newVoteProps, challengeRequestId) {
|
|
|
1366
1417
|
authorSignerAddress,
|
|
1367
1418
|
insertedAt: timestamp()
|
|
1368
1419
|
};
|
|
1369
|
-
const extraPropsInVote =
|
|
1420
|
+
const extraPropsInVote = r$1(t$6(newVoteProps), t$6(VotePubsubMessagePublicationSchema.shape));
|
|
1370
1421
|
if (extraPropsInVote.length > 0) {
|
|
1371
1422
|
log("Found extra props on Vote", extraPropsInVote, "Will be adding them to extraProps column");
|
|
1372
|
-
voteTableRow.extraProps =
|
|
1423
|
+
voteTableRow.extraProps = t$9(newVoteProps, extraPropsInVote);
|
|
1373
1424
|
}
|
|
1374
1425
|
community._dbHandler.insertVotes([voteTableRow]);
|
|
1375
1426
|
log("Inserted vote", "of comment", voteTableRow.commentCid, "into db", "with props", voteTableRow);
|
|
@@ -1379,7 +1430,7 @@ async function storeCommunityEditPublication(community, editProps, challengeRequ
|
|
|
1379
1430
|
const authorSignerAddress = await getPKCAddressFromPublicKey(editProps.signature.publicKey);
|
|
1380
1431
|
const authorIdentity = getAuthorNameFromWire(editProps.author) || authorSignerAddress;
|
|
1381
1432
|
log("Received community edit", editProps.communityEdit, "from author", authorIdentity, "with signer address", authorSignerAddress, "Will be using these props to edit the community props");
|
|
1382
|
-
const propsAfterEdit =
|
|
1433
|
+
const propsAfterEdit = t$9(community, t$6(editProps.communityEdit));
|
|
1383
1434
|
log("Current props from community edit (not edited yet)", propsAfterEdit);
|
|
1384
1435
|
(0, import_lodash_merge.default)(propsAfterEdit, editProps.communityEdit);
|
|
1385
1436
|
await community.edit(propsAfterEdit);
|
|
@@ -1429,10 +1480,10 @@ async function storeComment(community, opts) {
|
|
|
1429
1480
|
insertedAt: timestamp(),
|
|
1430
1481
|
pendingApproval
|
|
1431
1482
|
};
|
|
1432
|
-
const unknownProps =
|
|
1483
|
+
const unknownProps = r$1(t$6(commentIpfs), t$6(CommentIpfsSchema.shape)).filter((key) => key !== "communityAddress");
|
|
1433
1484
|
if (unknownProps.length > 0) {
|
|
1434
1485
|
log("Found extra props on Comment", unknownProps, "Will be adding them to extraProps column");
|
|
1435
|
-
commentRow.extraProps =
|
|
1486
|
+
commentRow.extraProps = t$9(commentIpfs, unknownProps);
|
|
1436
1487
|
}
|
|
1437
1488
|
if (challengeAggregate?.aggregatedCommentUpdate && Object.keys(challengeAggregate.aggregatedCommentUpdate).length > 0) commentRow.challengeCommentUpdate = challengeAggregate.aggregatedCommentUpdate;
|
|
1438
1489
|
if (originalCommentSignatureEncoded) commentRow.originalCommentSignatureEncoded = originalCommentSignatureEncoded;
|
|
@@ -3203,7 +3254,7 @@ var DbHandler = class {
|
|
|
3203
3254
|
"reply",
|
|
3204
3255
|
"vote"
|
|
3205
3256
|
];
|
|
3206
|
-
const newSettings =
|
|
3257
|
+
const newSettings = t$10(oldSettings);
|
|
3207
3258
|
if (Array.isArray(newSettings.challenges)) {
|
|
3208
3259
|
newSettings.challenges = newSettings.challenges.filter((cs) => !cs.name || cs.path || cs.name in pkcJsChallenges);
|
|
3209
3260
|
for (const oldChallengeSetting of newSettings.challenges) if (oldChallengeSetting.exclude) for (const oldExcludeSetting of oldChallengeSetting.exclude) for (const fieldToMove of fieldsToRemove) delete oldExcludeSetting[fieldToMove];
|
|
@@ -3396,7 +3447,7 @@ var DbHandler = class {
|
|
|
3396
3447
|
const commentToBeEdited = this.queryComment(srcRecord.commentCid);
|
|
3397
3448
|
if (!commentToBeEdited) throw Error(`Failed to compute isAuthorEdit for ${srcRecord.commentCid}`);
|
|
3398
3449
|
srcRecord["isAuthorEdit"] = parsedSig.publicKey === commentToBeEdited.signature.publicKey;
|
|
3399
|
-
const extraProps = removeNullUndefinedValues(
|
|
3450
|
+
const extraProps = removeNullUndefinedValues(t$9(srcRecord, ["removed"]));
|
|
3400
3451
|
if (Object.keys(extraProps).length > 0) srcRecord.extraProps = {
|
|
3401
3452
|
...srcRecord.extraProps,
|
|
3402
3453
|
...extraProps
|
|
@@ -3407,7 +3458,7 @@ var DbHandler = class {
|
|
|
3407
3458
|
srcRecord["authorSignerAddress"] = await getPKCAddressFromPublicKey(sig["publicKey"]);
|
|
3408
3459
|
}
|
|
3409
3460
|
if (srcTable === TABLES.COMMENTS) {
|
|
3410
|
-
const extraProps = removeNullUndefinedValues(
|
|
3461
|
+
const extraProps = removeNullUndefinedValues(t$9(srcRecord, ["ipnsName"]));
|
|
3411
3462
|
if (Object.keys(extraProps).length > 0) srcRecord.extraProps = {
|
|
3412
3463
|
...srcRecord.extraProps,
|
|
3413
3464
|
...extraProps
|
|
@@ -3528,7 +3579,7 @@ var DbHandler = class {
|
|
|
3528
3579
|
}
|
|
3529
3580
|
const commentEditWithExtraProps = this._spreadExtraProps({ ...commentEditRecord });
|
|
3530
3581
|
const validRes = await verifyCommentEdit({
|
|
3531
|
-
edit:
|
|
3582
|
+
edit: t$9(commentEditWithExtraProps, [...commentEditWithExtraProps.signature.signedPropertyNames, "signature"]),
|
|
3532
3583
|
resolveAuthorNames: false,
|
|
3533
3584
|
clientsManager: this._community._clientsManager
|
|
3534
3585
|
});
|
|
@@ -3614,7 +3665,7 @@ var DbHandler = class {
|
|
|
3614
3665
|
(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)
|
|
3615
3666
|
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)
|
|
3616
3667
|
`);
|
|
3617
|
-
const defaults =
|
|
3668
|
+
const defaults = t$7(columnNames, (column) => [column, null]);
|
|
3618
3669
|
this._db.transaction((items) => {
|
|
3619
3670
|
for (const comment of items) {
|
|
3620
3671
|
const completeComment = {
|
|
@@ -3655,7 +3706,7 @@ var DbHandler = class {
|
|
|
3655
3706
|
publishedToPostUpdatesMFS = excluded.publishedToPostUpdatesMFS,
|
|
3656
3707
|
insertedAt = excluded.insertedAt
|
|
3657
3708
|
`);
|
|
3658
|
-
const defaults =
|
|
3709
|
+
const defaults = t$7(columnNames, (column) => [column, null]);
|
|
3659
3710
|
this._db.transaction((items) => {
|
|
3660
3711
|
for (const update of items) {
|
|
3661
3712
|
const completeUpdate = {
|
|
@@ -3675,7 +3726,7 @@ var DbHandler = class {
|
|
|
3675
3726
|
(commentCid, author, signature, modSignerAddress, protocolVersion, communityPublicKey, communityName, timestamp, commentModeration, insertedAt, extraProps, targetAuthorSignerAddress, targetAuthorDomain)
|
|
3676
3727
|
VALUES (@commentCid, @author, @signature, @modSignerAddress, @protocolVersion, @communityPublicKey, @communityName, @timestamp, @commentModeration, @insertedAt, @extraProps, @targetAuthorSignerAddress, @targetAuthorDomain)
|
|
3677
3728
|
`);
|
|
3678
|
-
const defaults =
|
|
3729
|
+
const defaults = t$7(columnNames, (column) => [column, null]);
|
|
3679
3730
|
this._db.transaction((items) => {
|
|
3680
3731
|
for (const mod of items) {
|
|
3681
3732
|
const completeMod = {
|
|
@@ -3695,7 +3746,7 @@ var DbHandler = class {
|
|
|
3695
3746
|
(commentCid, authorSignerAddress, author, signature, protocolVersion, communityPublicKey, communityName, timestamp, content, reason, deleted, flairs, spoiler, nsfw, isAuthorEdit, insertedAt, extraProps)
|
|
3696
3747
|
VALUES (@commentCid, @authorSignerAddress, @author, @signature, @protocolVersion, @communityPublicKey, @communityName, @timestamp, @content, @reason, @deleted, @flairs, @spoiler, @nsfw, @isAuthorEdit, @insertedAt, @extraProps)
|
|
3697
3748
|
`);
|
|
3698
|
-
const defaults =
|
|
3749
|
+
const defaults = t$7(columnNames, (column) => [column, null]);
|
|
3699
3750
|
this._db.transaction((items) => {
|
|
3700
3751
|
for (const edit of items) {
|
|
3701
3752
|
const completeEdit = {
|
|
@@ -3811,8 +3862,8 @@ var DbHandler = class {
|
|
|
3811
3862
|
return result.max_timestamp;
|
|
3812
3863
|
}
|
|
3813
3864
|
queryPageComments(options) {
|
|
3814
|
-
const commentUpdateSelects =
|
|
3815
|
-
const commentIpfsSelects = [...
|
|
3865
|
+
const commentUpdateSelects = t$6(options.commentUpdateFieldsToExclude ? n$3(CommentUpdateSchema.shape, options.commentUpdateFieldsToExclude) : CommentUpdateSchema.shape).map((col) => `${TABLES.COMMENT_UPDATES}.${col} AS commentUpdate_${col}`);
|
|
3866
|
+
const commentIpfsSelects = [...t$6(CommentIpfsSchema.shape), "extraProps"].map((col) => `${TABLES.COMMENTS}.${col} AS commentIpfs_${col}`);
|
|
3816
3867
|
const { whereClauses, params } = this._buildPageQueryParts(options);
|
|
3817
3868
|
const queryStr = `
|
|
3818
3869
|
SELECT ${commentIpfsSelects.join(", ")}, ${commentUpdateSelects.join(", ")}
|
|
@@ -3828,8 +3879,8 @@ var DbHandler = class {
|
|
|
3828
3879
|
});
|
|
3829
3880
|
}
|
|
3830
3881
|
queryPageCommentsWithResolvedReplies(options) {
|
|
3831
|
-
const commentUpdateCols =
|
|
3832
|
-
const commentIpfsCols = [...
|
|
3882
|
+
const commentUpdateCols = t$6(CommentUpdateSchema.shape);
|
|
3883
|
+
const commentIpfsCols = [...t$6(CommentIpfsSchema.shape), "extraProps"];
|
|
3833
3884
|
const baseCommentUpdateSelects = commentUpdateCols.map((col) => `${TABLES.COMMENT_UPDATES}.${col} AS commentUpdate_${col}`);
|
|
3834
3885
|
const baseCommentIpfsSelects = commentIpfsCols.map((col) => `${TABLES.COMMENTS}.${col} AS commentIpfs_${col}`);
|
|
3835
3886
|
const recCommentUpdateSelects = commentUpdateCols.map((col) => `cu2.${col} AS commentUpdate_${col}`);
|
|
@@ -3925,8 +3976,8 @@ var DbHandler = class {
|
|
|
3925
3976
|
}));
|
|
3926
3977
|
}
|
|
3927
3978
|
resolveRepliesCidRefsForEntries(entries) {
|
|
3928
|
-
const commentUpdateCols =
|
|
3929
|
-
const commentIpfsCols = [...
|
|
3979
|
+
const commentUpdateCols = t$6(CommentUpdateSchema.shape);
|
|
3980
|
+
const commentIpfsCols = [...t$6(CommentIpfsSchema.shape), "extraProps"];
|
|
3930
3981
|
const allCids = [];
|
|
3931
3982
|
for (const entry of entries) {
|
|
3932
3983
|
const replies = entry.commentUpdate.replies;
|
|
@@ -4060,9 +4111,9 @@ var DbHandler = class {
|
|
|
4060
4111
|
});
|
|
4061
4112
|
}
|
|
4062
4113
|
queryFlattenedPageReplies(options) {
|
|
4063
|
-
const commentUpdateCols =
|
|
4114
|
+
const commentUpdateCols = t$6(options.commentUpdateFieldsToExclude ? n$3(CommentUpdateSchema.shape, options.commentUpdateFieldsToExclude) : CommentUpdateSchema.shape);
|
|
4064
4115
|
commentUpdateCols.map((col) => `c_updates.${col} AS commentUpdate_${col}`);
|
|
4065
|
-
const commentIpfsSelects = [...
|
|
4116
|
+
const commentIpfsSelects = [...t$6(CommentIpfsSchema.shape), "extraProps"].map((col) => `comments_alias.${col} AS commentIpfs_${col}`);
|
|
4066
4117
|
let baseWhereClausesStr = "";
|
|
4067
4118
|
let recursiveWhereClausesStr = "";
|
|
4068
4119
|
const params = [options.parentCid];
|
|
@@ -4561,8 +4612,8 @@ var DbHandler = class {
|
|
|
4561
4612
|
if (!row) return void 0;
|
|
4562
4613
|
const parsed = this._spreadExtraProps(this._parseCommentEditsRow(row));
|
|
4563
4614
|
const signedKeys = parsed.signature.signedPropertyNames;
|
|
4564
|
-
const commentEditFields =
|
|
4565
|
-
return
|
|
4615
|
+
const commentEditFields = t$6(CommentEditPubsubMessagePublicationSchema.shape);
|
|
4616
|
+
return t$9(parsed, [
|
|
4566
4617
|
"signature",
|
|
4567
4618
|
...signedKeys,
|
|
4568
4619
|
...commentEditFields
|
|
@@ -4701,7 +4752,7 @@ var DbHandler = class {
|
|
|
4701
4752
|
`;
|
|
4702
4753
|
const flags = this._db.prepare(query).get(cid);
|
|
4703
4754
|
if (!flags) return {};
|
|
4704
|
-
return
|
|
4755
|
+
return t$12(removeNullUndefinedValues(flags), Boolean);
|
|
4705
4756
|
}
|
|
4706
4757
|
queryAuthorEditDeleted(cid) {
|
|
4707
4758
|
const result = this._db.prepare(`
|
|
@@ -4924,11 +4975,11 @@ var DbHandler = class {
|
|
|
4924
4975
|
}
|
|
4925
4976
|
const authorPosts = authorCommentsData.filter((c) => c.depth === 0);
|
|
4926
4977
|
const authorReplies = authorCommentsData.filter((c) => c.depth > 0);
|
|
4927
|
-
const postScore =
|
|
4928
|
-
const replyScore =
|
|
4929
|
-
const lastCommentCid =
|
|
4978
|
+
const postScore = t(authorPosts, (p) => p.upvoteCount) - t(authorPosts, (p) => p.downvoteCount);
|
|
4979
|
+
const replyScore = t(authorReplies, (r) => r.upvoteCount) - t(authorReplies, (r) => r.downvoteCount);
|
|
4980
|
+
const lastCommentCid = n$5(authorCommentsData, [(c) => c.rowid, "desc"])?.cid;
|
|
4930
4981
|
if (!lastCommentCid) throw Error("Failed to query communityAuthor.lastCommentCid");
|
|
4931
|
-
const firstCommentTimestamp =
|
|
4982
|
+
const firstCommentTimestamp = n$5(authorCommentsData, (c) => c.rowid)?.timestamp;
|
|
4932
4983
|
if (typeof firstCommentTimestamp !== "number") throw Error("Failed to query communityAuthor.firstCommentTimestamp");
|
|
4933
4984
|
return {
|
|
4934
4985
|
postScore,
|
|
@@ -5015,7 +5066,7 @@ var DbHandler = class {
|
|
|
5015
5066
|
if (allCommentsToUpdate.length > 0) this.forceUpdateOnAllCommentsWithCid(allCommentsToUpdate);
|
|
5016
5067
|
}
|
|
5017
5068
|
if (!isNestedCall) this.commitTransaction();
|
|
5018
|
-
return
|
|
5069
|
+
return n(purgedRecords, (record) => record.commentTableRow.cid);
|
|
5019
5070
|
} catch (error) {
|
|
5020
5071
|
log.error(`Error during comment purge for ${cid}: ${error}`);
|
|
5021
5072
|
if (!isNestedCall) this.rollbackTransaction();
|
|
@@ -5189,9 +5240,9 @@ var DbHandler = class {
|
|
|
5189
5240
|
${activeScoreDescendantWhere}
|
|
5190
5241
|
) SELECT post_cid, MAX(timestamp) as active_score FROM descendants GROUP BY post_cid
|
|
5191
5242
|
`;
|
|
5192
|
-
const commentUpdateSelects =
|
|
5243
|
+
const commentUpdateSelects = t$6(pageOptions.commentUpdateFieldsToExclude ? n$3(CommentUpdateSchema.shape, pageOptions.commentUpdateFieldsToExclude) : CommentUpdateSchema.shape).map((col) => `cu.${col} AS commentUpdate_${col}`);
|
|
5193
5244
|
let postsQueryStr = `
|
|
5194
|
-
SELECT ${[...
|
|
5245
|
+
SELECT ${[...t$6(CommentIpfsSchema.shape), "extraProps"].map((col) => `c.${col} AS commentIpfs_${col}`).join(", ")}, ${commentUpdateSelects.join(", ")}, asc_scores.active_score
|
|
5195
5246
|
FROM ${TABLES.COMMENTS} c INNER JOIN ${TABLES.COMMENT_UPDATES} cu ON c.cid = cu.cid
|
|
5196
5247
|
INNER JOIN (${activeScoresCte}) AS asc_scores ON c.cid = asc_scores.post_cid
|
|
5197
5248
|
`;
|
|
@@ -5221,7 +5272,7 @@ var DbHandler = class {
|
|
|
5221
5272
|
_processRecordsForDbBeforeInsert(records) {
|
|
5222
5273
|
return records.map((record) => {
|
|
5223
5274
|
const processed = { ...record };
|
|
5224
|
-
for (const [key, value] of
|
|
5275
|
+
for (const [key, value] of t$2(processed)) if (e(value) || Array.isArray(value)) processed[key] = JSON.stringify(value);
|
|
5225
5276
|
else if (typeof value === "boolean") processed[key] = value ? 1 : 0;
|
|
5226
5277
|
return processed;
|
|
5227
5278
|
});
|
|
@@ -5455,7 +5506,7 @@ var PageGenerator = class {
|
|
|
5455
5506
|
const timestampLower = options.baseTimestamp - TIMEFRAMES_TO_SECONDS[sortProps.timeframe];
|
|
5456
5507
|
unpinnedComments = unpinnedComments.filter((obj) => obj.comment.timestamp >= timestampLower);
|
|
5457
5508
|
}
|
|
5458
|
-
const commentsSorted = pinnedComments.concat(unpinnedComments).map((comment) =>
|
|
5509
|
+
const commentsSorted = pinnedComments.concat(unpinnedComments).map((comment) => n$3(comment, ["activeScore"]));
|
|
5459
5510
|
if (commentsSorted.length === 0) return [];
|
|
5460
5511
|
return await this._chunkComments({
|
|
5461
5512
|
comments: commentsSorted,
|
|
@@ -5502,7 +5553,7 @@ var PageGenerator = class {
|
|
|
5502
5553
|
if (preloadedChunk.length === 1) return { singlePreloadedPage: { [preloadedPageSortName]: { comments: preloadedChunk[0] } } };
|
|
5503
5554
|
const sortResults = [];
|
|
5504
5555
|
sortResults.push(await this.addPreloadedCommentChunksToIpfs(preloadedChunk, preloadedPageSortName));
|
|
5505
|
-
const nonPreloadedSorts =
|
|
5556
|
+
const nonPreloadedSorts = t$6(POSTS_SORT_TYPES).filter((sortName) => sortName !== preloadedPageSortName);
|
|
5506
5557
|
await Promise.all(nonPreloadedSorts.map(async (sortName) => {
|
|
5507
5558
|
sortResults.push(await this.sortChunkAddIpfsNonPreloaded(rawPosts, sortName, {
|
|
5508
5559
|
...pageOptions,
|
|
@@ -5574,7 +5625,7 @@ var PageGenerator = class {
|
|
|
5574
5625
|
firstPageSizeBytes: 1024 * 1024
|
|
5575
5626
|
}));
|
|
5576
5627
|
else sortResults.push(await this.addPreloadedCommentChunksToIpfs(preloadedChunk, preloadedReplyPageSortName));
|
|
5577
|
-
const nonPreloadedSorts =
|
|
5628
|
+
const nonPreloadedSorts = t$6(POST_REPLIES_SORT_TYPES).filter((sortName) => sortName !== preloadedReplyPageSortName);
|
|
5578
5629
|
const flattenedReplies = this._community._dbHandler.queryFlattenedPageReplies({
|
|
5579
5630
|
...pageOptions,
|
|
5580
5631
|
commentUpdateFieldsToExclude: ["replies"]
|
|
@@ -5614,7 +5665,7 @@ var PageGenerator = class {
|
|
|
5614
5665
|
});
|
|
5615
5666
|
const disablePreload = await getSerializedCommentsSize(preloadedChunk[0], preloadedChunk.length > 1) > preloadedPageSizeBytes;
|
|
5616
5667
|
if (!disablePreload && preloadedChunk.length === 1) return { singlePreloadedPage: { [preloadedReplyPageSortName]: { comments: preloadedChunk[0] } } };
|
|
5617
|
-
const nonPreloadedSorts =
|
|
5668
|
+
const nonPreloadedSorts = t$6(REPLY_REPLIES_SORT_TYPES).filter((sortName) => sortName !== preloadedReplyPageSortName);
|
|
5618
5669
|
const sortResults = [];
|
|
5619
5670
|
if (disablePreload) sortResults.push(await this.sortChunkAddIpfsNonPreloaded(hierarchalReplies, preloadedReplyPageSortName, {
|
|
5620
5671
|
...pageOptions,
|
|
@@ -5685,7 +5736,7 @@ async function getDbInternalState(community, lock) {
|
|
|
5685
5736
|
}
|
|
5686
5737
|
async function updateDbInternalState(community, props) {
|
|
5687
5738
|
const log = logger_default("pkc-js:local-community:_updateDbInternalState");
|
|
5688
|
-
if (
|
|
5739
|
+
if (e$1(props)) throw Error("props to update DB internal state should not be empty");
|
|
5689
5740
|
await community._dbHandler.initDbIfNeeded();
|
|
5690
5741
|
props._internalStateUpdateId = v4();
|
|
5691
5742
|
let lockedIt = false;
|
|
@@ -5780,7 +5831,7 @@ async function setChallengesToDefaultIfNotDefined(community, log) {
|
|
|
5780
5831
|
if (community._usingDefaultChallenge) {
|
|
5781
5832
|
const currentAnswer = community.settings?.challenges?.[0]?.options?.answer;
|
|
5782
5833
|
if (currentAnswer && isDefaultChallengeStructure(community._defaultCommunityChallenges)) community._defaultCommunityChallenges = generateDefaultChallenges(currentAnswer);
|
|
5783
|
-
if (!
|
|
5834
|
+
if (!t$11(community.settings?.challenges, community._defaultCommunityChallenges)) {
|
|
5784
5835
|
await community.edit({ settings: {
|
|
5785
5836
|
...community.settings,
|
|
5786
5837
|
challenges: community._defaultCommunityChallenges
|
|
@@ -5796,7 +5847,7 @@ async function createNewLocalCommunityDb(community) {
|
|
|
5796
5847
|
await community._dbHandler.initDbIfNeeded({ fileMustExist: false });
|
|
5797
5848
|
await community._dbHandler.createOrMigrateTablesIfNeeded();
|
|
5798
5849
|
await initSignerProps(community, community.signer);
|
|
5799
|
-
if (!community.pubsubTopic) community.pubsubTopic =
|
|
5850
|
+
if (!community.pubsubTopic) community.pubsubTopic = t$10(community.signer.address);
|
|
5800
5851
|
if (typeof community.createdAt !== "number") community.createdAt = timestamp();
|
|
5801
5852
|
if (!community.protocolVersion) community.protocolVersion = version_default.PROTOCOL_VERSION;
|
|
5802
5853
|
if (!community.settings?.maxPendingApprovalCount) community.settings = {
|
|
@@ -5859,9 +5910,9 @@ async function initInternalCommunityAfterFirstUpdateNoMerge(community, newProps)
|
|
|
5859
5910
|
}
|
|
5860
5911
|
const keysOfCommunityIpfs = [...CommunitySignedPropertyNames, "signature"];
|
|
5861
5912
|
community.initRpcInternalCommunityAfterFirstUpdateNoMerge({
|
|
5862
|
-
community:
|
|
5913
|
+
community: t$9(newProps, keysOfCommunityIpfs),
|
|
5863
5914
|
localCommunity: {
|
|
5864
|
-
signer:
|
|
5915
|
+
signer: t$9(newProps.signer, [
|
|
5865
5916
|
"publicKey",
|
|
5866
5917
|
"address",
|
|
5867
5918
|
"shortAddress",
|
|
@@ -5885,12 +5936,12 @@ async function initInternalCommunityAfterFirstUpdateNoMerge(community, newProps)
|
|
|
5885
5936
|
}
|
|
5886
5937
|
async function initInternalCommunityBeforeFirstUpdateNoMerge(community, newProps) {
|
|
5887
5938
|
community.initRpcInternalCommunityBeforeFirstUpdateNoMerge({ localCommunity: {
|
|
5888
|
-
...
|
|
5939
|
+
...n$3(newProps, [
|
|
5889
5940
|
"signer",
|
|
5890
5941
|
"_internalStateUpdateId",
|
|
5891
5942
|
"_pendingEditProps"
|
|
5892
5943
|
]),
|
|
5893
|
-
signer:
|
|
5944
|
+
signer: t$9(newProps.signer, [
|
|
5894
5945
|
"publicKey",
|
|
5895
5946
|
"address",
|
|
5896
5947
|
"shortAddress",
|
|
@@ -5963,7 +6014,7 @@ async function calculateNewPostUpdates(community) {
|
|
|
5963
6014
|
});
|
|
5964
6015
|
if (statRes.blocks !== 0) postUpdates[String(timeBucket)] = String(statRes.cid);
|
|
5965
6016
|
} catch {}
|
|
5966
|
-
if (
|
|
6017
|
+
if (e$1(postUpdates)) return void 0;
|
|
5967
6018
|
return postUpdates;
|
|
5968
6019
|
}
|
|
5969
6020
|
function calculateLatestUpdateTrigger(community) {
|
|
@@ -6006,7 +6057,7 @@ async function addOldPageCidsToCidsToUnpin(community, curPages, newPages, addToB
|
|
|
6006
6057
|
pages: newPages,
|
|
6007
6058
|
clientManager: community._clientsManager
|
|
6008
6059
|
});
|
|
6009
|
-
|
|
6060
|
+
r$1(n$4(allPageCidsUnderCurPages), allPageCidsUnderNewPages).forEach((cid) => {
|
|
6010
6061
|
community._cidsToUnPin.add(cid);
|
|
6011
6062
|
if (addToBlockRm) community._blocksToRm.push(cid);
|
|
6012
6063
|
});
|
|
@@ -6054,10 +6105,10 @@ async function calculateNextCommunityRecord(community, commentUpdateRowsToPublis
|
|
|
6054
6105
|
const currentTimestamp = timestamp();
|
|
6055
6106
|
const updatedAt = typeof community?.updatedAt === "number" && community.updatedAt >= currentTimestamp ? community.updatedAt + 1 : currentTimestamp;
|
|
6056
6107
|
const editIdsToIncludeInNextUpdate = community._pendingEditProps.map((editProps) => editProps.editId);
|
|
6057
|
-
const pendingCommunityIpfsEditProps = Object.assign({}, ...community._pendingEditProps.map((editProps) =>
|
|
6108
|
+
const pendingCommunityIpfsEditProps = Object.assign({}, ...community._pendingEditProps.map((editProps) => t$9(editProps, t$6(CommunityIpfsSchema.shape))));
|
|
6058
6109
|
if (community._pendingEditProps.length > 0) log("Including edit props in next IPNS update", community._pendingEditProps);
|
|
6059
6110
|
const newIpns = { ...cleanUpBeforePublishing({
|
|
6060
|
-
...
|
|
6111
|
+
...n$3(community._toJSONIpfsBaseNoPosts(), ["signature"]),
|
|
6061
6112
|
...pendingCommunityIpfsEditProps,
|
|
6062
6113
|
lastPostCid: latestPost?.cid,
|
|
6063
6114
|
lastCommentCid: latestComment?.cid,
|
|
@@ -6076,7 +6127,7 @@ async function calculateNextCommunityRecord(community, commentUpdateRowsToPublis
|
|
|
6076
6127
|
if ("singlePreloadedPage" in generatedPosts) newIpns.posts = { pages: generatedPosts.singlePreloadedPage };
|
|
6077
6128
|
else if (generatedPosts.pageCids) newIpns.posts = {
|
|
6078
6129
|
pageCids: generatedPosts.pageCids,
|
|
6079
|
-
pages:
|
|
6130
|
+
pages: t$9(generatedPosts.pages, [preloadedPostsPages])
|
|
6080
6131
|
};
|
|
6081
6132
|
} else await community._updateDbInternalState({ posts: void 0 });
|
|
6082
6133
|
{
|
|
@@ -6161,7 +6212,7 @@ async function publishCommunityRecordToIpns(community, build, newCommunityRecord
|
|
|
6161
6212
|
community.updateCid = file.path;
|
|
6162
6213
|
community._pendingEditProps = community._pendingEditProps.filter((editProps) => !editIdsToIncludeInNextUpdate.includes(editProps.editId));
|
|
6163
6214
|
if (community._pendingEditProps.length > 0) {
|
|
6164
|
-
const remainingEditProps = Object.assign({}, ...community._pendingEditProps.map((editProps) =>
|
|
6215
|
+
const remainingEditProps = Object.assign({}, ...community._pendingEditProps.map((editProps) => t$9(editProps, t$6(CommunityIpfsSchema.shape))));
|
|
6165
6216
|
Object.assign(community, remainingEditProps);
|
|
6166
6217
|
}
|
|
6167
6218
|
community._communityUpdateTrigger = false;
|
|
@@ -6223,11 +6274,10 @@ async function getBrowserDialableSelfAddrs(client) {
|
|
|
6223
6274
|
const idRes = await client.id();
|
|
6224
6275
|
const peerId = idRes.id.toString();
|
|
6225
6276
|
const swarmListeningAddresses = (await client.swarm.addrs()).filter((swarmAddr) => swarmAddr.id.toString() === peerId);
|
|
6226
|
-
|
|
6227
|
-
return import_commonjs.unique(normalized.filter(isBrowserDialableAddr)).sort();
|
|
6277
|
+
return n$4(normalizeSelfAddrsForProvider([...idRes.addresses.map((addr) => addr.toString()), ...n$6(swarmListeningAddresses.map((swarmAddr) => swarmAddr.addrs.map((addr) => addr.toString())))], peerId).filter(isBrowserDialableAddr)).sort();
|
|
6228
6278
|
}
|
|
6229
6279
|
function connectionCriticalCids(community) {
|
|
6230
|
-
return
|
|
6280
|
+
return n$4([community.pubsubTopicRoutingCid, community.ipnsPubsubTopicRoutingCid].filter((cid) => typeof cid === "string"));
|
|
6231
6281
|
}
|
|
6232
6282
|
/**
|
|
6233
6283
|
* Re-provide the connection-critical CIDs when the node's browser-dialable (WSS/WebRTC) self-addresses
|
|
@@ -6250,7 +6300,7 @@ async function reprovideConnectionCidsIfBrowserAddrsChanged(community) {
|
|
|
6250
6300
|
browserAddrs: current
|
|
6251
6301
|
};
|
|
6252
6302
|
}
|
|
6253
|
-
if (
|
|
6303
|
+
if (t$11(previous, current)) return {
|
|
6254
6304
|
reprovided: false,
|
|
6255
6305
|
providedCids: [],
|
|
6256
6306
|
browserAddrs: current
|
|
@@ -6436,7 +6486,7 @@ async function initMirroringStartedOrUpdatingCommunity(community, startedCommuni
|
|
|
6436
6486
|
community._mirroredStartedOrUpdatingCommunity.community.on("challengeverification", community._mirroredStartedOrUpdatingCommunity.challengeverification);
|
|
6437
6487
|
community._mirroredStartedOrUpdatingCommunity.community.on("challengeanswer", community._mirroredStartedOrUpdatingCommunity.challengeanswer);
|
|
6438
6488
|
community._mirroredStartedOrUpdatingCommunity.community.on("challenge", community._mirroredStartedOrUpdatingCommunity.challenge);
|
|
6439
|
-
const clientKeys =
|
|
6489
|
+
const clientKeys = t$6(community.clients);
|
|
6440
6490
|
for (const clientType of clientKeys) if (community.clients[clientType]) {
|
|
6441
6491
|
for (const clientUrl of Object.keys(community.clients[clientType])) if (clientUrl in community._mirroredStartedOrUpdatingCommunity.community.clients[clientType]) community.clients[clientType][clientUrl].mirror(community._mirroredStartedOrUpdatingCommunity.community.clients[clientType][clientUrl]);
|
|
6442
6492
|
}
|
|
@@ -6455,7 +6505,7 @@ async function cleanUpMirroredStartedOrUpdatingCommunity(community) {
|
|
|
6455
6505
|
community._mirroredStartedOrUpdatingCommunity.community.removeListener("challengeverification", community._mirroredStartedOrUpdatingCommunity.challengeverification);
|
|
6456
6506
|
community._mirroredStartedOrUpdatingCommunity.community.removeListener("challengeanswer", community._mirroredStartedOrUpdatingCommunity.challengeanswer);
|
|
6457
6507
|
community._mirroredStartedOrUpdatingCommunity.community.removeListener("challenge", community._mirroredStartedOrUpdatingCommunity.challenge);
|
|
6458
|
-
const clientKeys =
|
|
6508
|
+
const clientKeys = t$6(community.clients);
|
|
6459
6509
|
for (const clientType of clientKeys) if (community.clients[clientType]) for (const clientUrl of Object.keys(community.clients[clientType])) community.clients[clientType][clientUrl].unmirror();
|
|
6460
6510
|
community._mirroredStartedOrUpdatingCommunity = void 0;
|
|
6461
6511
|
}
|
|
@@ -6485,7 +6535,7 @@ async function updateOnce(community) {
|
|
|
6485
6535
|
return;
|
|
6486
6536
|
}
|
|
6487
6537
|
trackUpdatingCommunity(community._pkc, community);
|
|
6488
|
-
const oldUpdateId =
|
|
6538
|
+
const oldUpdateId = t$10(community._internalStateUpdateId);
|
|
6489
6539
|
await updateInstancePropsWithStartedCommunityOrDb(community);
|
|
6490
6540
|
if (community._internalStateUpdateId !== oldUpdateId) {
|
|
6491
6541
|
log(`Local Community (${community.address}) received a new update from db with updatedAt (${community.updatedAt}). Will emit an update event`);
|
|
@@ -6687,7 +6737,7 @@ async function parseRolesToEdit(community, newRawRoles) {
|
|
|
6687
6737
|
if (!resolved) throw new PKCError("ERR_ROLE_ADDRESS_NAME_COULD_NOT_BE_RESOLVED", { roleAddress });
|
|
6688
6738
|
}
|
|
6689
6739
|
}
|
|
6690
|
-
return
|
|
6740
|
+
return t$8(newRawRoles, (val, key) => val === void 0 || val === null);
|
|
6691
6741
|
}
|
|
6692
6742
|
async function parseChallengesToEdit(community, newChallengeSettings) {
|
|
6693
6743
|
return {
|
|
@@ -6712,7 +6762,7 @@ async function validateNewAddressBeforeEditing(community, newAddress, log) {
|
|
|
6712
6762
|
}
|
|
6713
6763
|
async function editPropsOnStartedCommunity(community, parsedEditOptions) {
|
|
6714
6764
|
const log = logger_default("pkc-js:local-community:start:editPropsOnStartedCommunity");
|
|
6715
|
-
const oldAddress =
|
|
6765
|
+
const oldAddress = t$10(community.address);
|
|
6716
6766
|
if (typeof parsedEditOptions.address === "string" && community.address !== parsedEditOptions.address) {
|
|
6717
6767
|
await validateNewAddressBeforeEditing(community, parsedEditOptions.address, log);
|
|
6718
6768
|
log(`Attempting to edit community.address from ${oldAddress} to ${parsedEditOptions.address}. We will stop community first`);
|
|
@@ -6739,7 +6789,7 @@ async function editPropsOnStartedCommunity(community, parsedEditOptions) {
|
|
|
6739
6789
|
_internalStateUpdateId: uniqueEditId
|
|
6740
6790
|
});
|
|
6741
6791
|
community._communityUpdateTrigger = true;
|
|
6742
|
-
log(`Community (${community.address}) props (${
|
|
6792
|
+
log(`Community (${community.address}) props (${t$6(parsedEditOptions)}) has been edited. Will be including edited props in next update: `, t$9(community, t$6(parsedEditOptions)));
|
|
6743
6793
|
community.emit("update", community);
|
|
6744
6794
|
if (community.address !== oldAddress) {
|
|
6745
6795
|
trackStartedCommunity(community._pkc, community);
|
|
@@ -6749,7 +6799,7 @@ async function editPropsOnStartedCommunity(community, parsedEditOptions) {
|
|
|
6749
6799
|
}
|
|
6750
6800
|
async function editPropsOnNotStartedCommunity(community, parsedEditOptions) {
|
|
6751
6801
|
const log = logger_default("pkc-js:local-community:edit:editPropsOnNotStartedCommunity");
|
|
6752
|
-
const oldAddress =
|
|
6802
|
+
const oldAddress = t$10(community.address);
|
|
6753
6803
|
await community.initDbHandlerIfNeeded();
|
|
6754
6804
|
await community._dbHandler.initDbIfNeeded();
|
|
6755
6805
|
if (typeof parsedEditOptions.address === "string" && community.address !== parsedEditOptions.address) {
|
|
@@ -6802,7 +6852,7 @@ async function edit(community, newCommunityOptions) {
|
|
|
6802
6852
|
...editWithDerivedName?.settings?.challenges ? await parseChallengesToEdit(community, editWithDerivedName.settings.challenges) : void 0
|
|
6803
6853
|
};
|
|
6804
6854
|
const newProps = {
|
|
6805
|
-
...
|
|
6855
|
+
...n$3(editWithDerivedName, ["roles"]),
|
|
6806
6856
|
...newInternalProps
|
|
6807
6857
|
};
|
|
6808
6858
|
if (!community.started && !startedCommunity) return editPropsOnNotStartedCommunity(community, newProps);
|
|
@@ -7051,9 +7101,9 @@ var LocalCommunity = class extends RpcLocalCommunity {
|
|
|
7051
7101
|
const rpcJson = this.toJSONInternalRpcAfterFirstUpdate();
|
|
7052
7102
|
return {
|
|
7053
7103
|
...rpcJson.community,
|
|
7054
|
-
...
|
|
7104
|
+
...n$3(rpcJson.localCommunity, ["started", "startedState"]),
|
|
7055
7105
|
updateCid: rpcJson.runtimeFields.updateCid,
|
|
7056
|
-
signer:
|
|
7106
|
+
signer: t$9(this.signer, [
|
|
7057
7107
|
"privateKey",
|
|
7058
7108
|
"type",
|
|
7059
7109
|
"address",
|
|
@@ -7067,10 +7117,9 @@ var LocalCommunity = class extends RpcLocalCommunity {
|
|
|
7067
7117
|
};
|
|
7068
7118
|
}
|
|
7069
7119
|
toJSONInternalBeforeFirstUpdate() {
|
|
7070
|
-
const rpcJson = this.toJSONInternalRpcBeforeFirstUpdate();
|
|
7071
7120
|
return {
|
|
7072
|
-
...
|
|
7073
|
-
signer:
|
|
7121
|
+
...n$3(this.toJSONInternalRpcBeforeFirstUpdate().localCommunity, ["started", "startedState"]),
|
|
7122
|
+
signer: t$9(this.signer, [
|
|
7074
7123
|
"privateKey",
|
|
7075
7124
|
"type",
|
|
7076
7125
|
"address",
|
|
@@ -7087,7 +7136,7 @@ var LocalCommunity = class extends RpcLocalCommunity {
|
|
|
7087
7136
|
...base,
|
|
7088
7137
|
localCommunity: {
|
|
7089
7138
|
...base.localCommunity,
|
|
7090
|
-
signer:
|
|
7139
|
+
signer: t$9(this.signer, [
|
|
7091
7140
|
"publicKey",
|
|
7092
7141
|
"address",
|
|
7093
7142
|
"shortAddress",
|
|
@@ -7099,7 +7148,7 @@ var LocalCommunity = class extends RpcLocalCommunity {
|
|
|
7099
7148
|
toJSONInternalRpcBeforeFirstUpdate() {
|
|
7100
7149
|
return { localCommunity: {
|
|
7101
7150
|
...super.toJSONInternalRpcBeforeFirstUpdate().localCommunity,
|
|
7102
|
-
signer:
|
|
7151
|
+
signer: t$9(this.signer, [
|
|
7103
7152
|
"publicKey",
|
|
7104
7153
|
"address",
|
|
7105
7154
|
"shortAddress",
|