@pkcprotocol/pkc-js 0.0.114 → 0.0.115
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/challenges.d.ts +1 -0
- package/dist/browser/challenges.js +1 -1
- package/dist/browser/challenges.js.map +1 -1
- package/dist/browser/clients/base-client-manager.js +25 -2
- package/dist/browser/clients/base-client-manager.js.map +1 -1
- package/dist/browser/clients/rpc-client/rpc-schema-util.d.ts +2 -2
- package/dist/browser/clients/rpc-client/schema.d.ts +7 -7
- package/dist/browser/community/schema.d.ts +72 -72
- package/dist/browser/constants.d.ts +2 -1
- package/dist/browser/constants.js +3 -0
- package/dist/browser/constants.js.map +1 -1
- package/dist/browser/errors.d.ts +1 -0
- package/dist/browser/errors.js +1 -0
- package/dist/browser/errors.js.map +1 -1
- package/dist/browser/generated-version.d.ts +1 -1
- package/dist/browser/generated-version.js +1 -1
- package/dist/browser/index-with-compile-cache.d.ts +4 -4
- package/dist/browser/index.d.ts +8 -8
- package/dist/browser/page-sorts.d.ts +2 -0
- package/dist/browser/page-sorts.js +2 -0
- package/dist/browser/page-sorts.js.map +1 -0
- package/dist/browser/pages/schema.d.ts +17 -17
- package/dist/browser/pkc-error.d.ts +1 -1
- package/dist/browser/publications/comment/schema.d.ts +18 -18
- package/dist/browser/publications/comment-edit/schema.d.ts +5 -5
- package/dist/browser/publications/comment-moderation/schema.d.ts +4 -4
- package/dist/browser/publications/community-edit/schema.d.ts +4 -4
- package/dist/browser/pubsub-messages/schema.d.ts +9 -9
- package/dist/browser/rpc/src/index.d.ts +2 -0
- package/dist/browser/rpc/src/index.js +22 -0
- package/dist/browser/rpc/src/index.js.map +1 -1
- package/dist/browser/rpc/src/lib/pkc-js/index.d.ts +4 -4
- package/dist/browser/rpc/src/lib/pkc-js/index.js +3 -1
- package/dist/browser/rpc/src/lib/pkc-js/index.js.map +1 -1
- package/dist/browser/rpc/src/schema.d.ts +30 -30
- package/dist/browser/runtime/node/community/db-handler.d.ts +6 -0
- package/dist/browser/runtime/node/community/db-handler.js +32 -0
- package/dist/browser/runtime/node/community/db-handler.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/challenges.js +0 -2
- package/dist/browser/runtime/node/community/local-community/challenges.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/editing.d.ts +2 -1
- package/dist/browser/runtime/node/community/local-community/editing.js +10 -7
- package/dist/browser/runtime/node/community/local-community/editing.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/ipns-publishing.js +3 -0
- package/dist/browser/runtime/node/community/local-community/ipns-publishing.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/lifecycle.js +7 -3
- package/dist/browser/runtime/node/community/local-community/lifecycle.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/publication-store.js +23 -23
- package/dist/browser/runtime/node/community/local-community/publication-store.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/registry-sync.d.ts +7 -0
- package/dist/browser/runtime/node/community/local-community/registry-sync.js +80 -0
- package/dist/browser/runtime/node/community/local-community/registry-sync.js.map +1 -0
- package/dist/browser/runtime/node/community/local-community.d.ts +2 -1
- package/dist/browser/runtime/node/community/local-community.js +3 -0
- package/dist/browser/runtime/node/community/local-community.js.map +1 -1
- package/dist/browser/runtime/node/community/page-sorts/index.d.ts +9 -0
- package/dist/browser/runtime/node/community/page-sorts/index.js +64 -6
- package/dist/browser/runtime/node/community/page-sorts/index.js.map +1 -1
- package/dist/browser/schema/schema-util.d.ts +12 -12
- package/dist/browser/schema.d.ts +32 -32
- package/dist/browser/test/test-util.d.ts +30 -30
- package/dist/browser/validate-package-factories.d.ts +7 -0
- package/dist/browser/validate-package-factories.js +37 -0
- package/dist/browser/validate-package-factories.js.map +1 -0
- package/dist/bundled/bundle-manifest.json +80 -45
- package/dist/bundled/challenges.js +2 -1
- package/dist/bundled/chunks/{helia-for-pkc-hSpmyI9D.js → helia-for-pkc-BB8P6KYw.js} +2 -2
- package/dist/bundled/chunks/{local-community-EeQMdfYM.js → local-community-XrLSKipf.js} +135 -35
- package/dist/bundled/chunks/{local-community-Dc_fNPrx.js → local-community-wAvG_J_u.js} +1 -1
- package/dist/bundled/chunks/{node-apYZl3B3.js → node-D5riLTOu.js} +5 -5
- package/dist/bundled/chunks/page-sort-scoring-3svUUHW_.js +112 -0
- package/dist/bundled/chunks/{rpc-local-community-C_0FRCqg.js → rpc-local-community-D5ZdqFYc.js} +80 -124
- package/dist/bundled/chunks/{util-DFGl6QDd.js → util-CabVOL7E.js} +2 -1
- package/dist/bundled/chunks/{util-B2SuJZg-.js → util-Cnpgfqwn.js} +1 -1
- package/dist/bundled/chunks/validate-package-factories-CxIg67oP.js +41 -0
- package/dist/bundled/index.js +1 -1
- package/dist/bundled/page-sorts.js +2 -0
- package/dist/bundled/rpc/src/index.js +17 -4
- package/dist/node/challenges.d.ts +1 -0
- package/dist/node/challenges.js +1 -1
- package/dist/node/challenges.js.map +1 -1
- package/dist/node/clients/base-client-manager.js +25 -2
- package/dist/node/clients/base-client-manager.js.map +1 -1
- package/dist/node/clients/rpc-client/rpc-schema-util.d.ts +2 -2
- package/dist/node/clients/rpc-client/schema.d.ts +7 -7
- package/dist/node/community/schema.d.ts +72 -72
- package/dist/node/constants.d.ts +2 -1
- package/dist/node/constants.js +3 -0
- package/dist/node/constants.js.map +1 -1
- package/dist/node/errors.d.ts +1 -0
- package/dist/node/errors.js +1 -0
- package/dist/node/errors.js.map +1 -1
- package/dist/node/generated-version.d.ts +1 -1
- package/dist/node/generated-version.js +1 -1
- package/dist/node/index-with-compile-cache.d.ts +4 -4
- package/dist/node/index.d.ts +8 -8
- package/dist/node/page-sorts.d.ts +2 -0
- package/dist/node/page-sorts.js +2 -0
- package/dist/node/page-sorts.js.map +1 -0
- package/dist/node/pages/schema.d.ts +17 -17
- package/dist/node/pkc-error.d.ts +1 -1
- package/dist/node/publications/comment/schema.d.ts +18 -18
- package/dist/node/publications/comment-edit/schema.d.ts +5 -5
- package/dist/node/publications/comment-moderation/schema.d.ts +4 -4
- package/dist/node/publications/community-edit/schema.d.ts +4 -4
- package/dist/node/pubsub-messages/schema.d.ts +9 -9
- package/dist/node/rpc/src/index.d.ts +2 -0
- package/dist/node/rpc/src/index.js +22 -0
- package/dist/node/rpc/src/index.js.map +1 -1
- package/dist/node/rpc/src/lib/pkc-js/index.d.ts +4 -4
- package/dist/node/rpc/src/lib/pkc-js/index.js +3 -1
- package/dist/node/rpc/src/lib/pkc-js/index.js.map +1 -1
- package/dist/node/rpc/src/schema.d.ts +30 -30
- package/dist/node/runtime/node/community/db-handler.d.ts +6 -0
- package/dist/node/runtime/node/community/db-handler.js +32 -0
- package/dist/node/runtime/node/community/db-handler.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/challenges.js +0 -2
- package/dist/node/runtime/node/community/local-community/challenges.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/editing.d.ts +2 -1
- package/dist/node/runtime/node/community/local-community/editing.js +10 -7
- package/dist/node/runtime/node/community/local-community/editing.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/ipns-publishing.js +3 -0
- package/dist/node/runtime/node/community/local-community/ipns-publishing.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/lifecycle.js +7 -3
- package/dist/node/runtime/node/community/local-community/lifecycle.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/publication-store.js +23 -23
- package/dist/node/runtime/node/community/local-community/publication-store.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/registry-sync.d.ts +7 -0
- package/dist/node/runtime/node/community/local-community/registry-sync.js +80 -0
- package/dist/node/runtime/node/community/local-community/registry-sync.js.map +1 -0
- package/dist/node/runtime/node/community/local-community.d.ts +2 -1
- package/dist/node/runtime/node/community/local-community.js +3 -0
- package/dist/node/runtime/node/community/local-community.js.map +1 -1
- package/dist/node/runtime/node/community/page-sorts/index.d.ts +9 -0
- package/dist/node/runtime/node/community/page-sorts/index.js +64 -6
- package/dist/node/runtime/node/community/page-sorts/index.js.map +1 -1
- package/dist/node/schema/schema-util.d.ts +12 -12
- package/dist/node/schema.d.ts +32 -32
- package/dist/node/test/test-util.d.ts +30 -30
- package/dist/node/validate-package-factories.d.ts +7 -0
- package/dist/node/validate-package-factories.js +37 -0
- package/dist/node/validate-package-factories.js.map +1 -0
- package/package.json +6 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { i as __toESM, r as __require, t as __commonJSMin } from "./chunk-2rV9d50f.js";
|
|
2
|
-
import { $t as CommentModerationPubsubMessagePublicationSchema, A as isLinkOfAnimatedImage, An as CommentIpfsSchema, Ar as PKCError, At as ChallengeMessageSchema, Bn as CommentUpdateTableRowSchema, Dn as VoteTablesRowSchema, Dt as pTimeout, F as isLinkValid, Gr as ZodError, Jn as CommentEditPubsubMessagePublicationSchema, Jt as CommunityEditPublicationPubsubReservedFields, K as removeNullUndefinedValues, Kt as version_default, Lt as DecryptedChallengeRequestPublicationSchema, M as isLinkOfImage, Mr as logger_default, Mt as ChallengeRequestMessageSchema, N as isLinkOfMedia, Ot as ChallengeAnswerMessageSchema, P as isLinkOfVideo, Pt as ChallengeVerificationMessageSchema, Q as retryKuboIpfsAddAndProvide, Qn as CommentEditsTableRowSchema, R as pubsubTopicToDhtKey, Rn as CommentUpdateSchema, Rt as DecryptedChallengeRequestSchema, S as hideClassPrivateProps, Sr as t$2, St as untrackStartedCommunity, Tn as VotePubsubReservedFields, Tt as require_sha256, U as removeBlocksFromKuboNode, Vn as CommentsTableRowSchema, W as removeMfsFilesSafely, X as retryKuboBlockPutPinAndProvidePubsubTopic, Xn as CommentEditReservedFields, Yn as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema, _ as getEquivalentCommunityAddresses, _r as r$1, a as calculateUnixFsDagSizeCidV0, c as contentContainsMarkdownVideos, ct as writeKuboFilesWithTimeout, d as derivePublicationFromChallengeRequest, dn as CommunityIpfsSchema, dr as n$2, en as CommentModerationReservedFields, f as doesDomainAddressHaveCapitalLetter, fn as CommunitySignedPropertyNames, fr as t$5, ft as findUpdatingCommunity, g as genToArray, h as findMalformedUnicodeString, hr as e, i as calculateStringSizeSameAsIpfsAddCidV0, it as timestamp, j as isLinkOfAudio, jn as CommentPubsubMessageReservedFields, jr as messages, lr as n$3, lt as findCommunityInRegistry, mr as e$1, nn as CommentModerationsTableRowSchema, nr as AuthorReservedFields, nt as statMfsPathSafely, o as contentContainsMarkdownAudio, ot as withSortedKeys, pr as t$6, r as calculateIpfsCidV0, s as contentContainsMarkdownImages, st as withSortedKeysDeep, t as areEquivalentCommunityAddresses, tt as sleepUntilTimeoutOrAbort, ur as t$7, ut as findStartedCommunity, v as getErrorCodeFromMessage, vr as t$3, vt as syncCommunityRegistryEntry, w as ipnsNameToIpnsOverPubsubTopic, wn as VotePubsubMessagePublicationSchema, wr as require_retry, wt as untrackUpdatingCommunity, xn as isStringDomain, xr as t$4, xt as trackUpdatingCommunity, y as getIpnsRecordInLocalKuboNode, yt as trackStartedCommunity } from "./util-
|
|
3
|
-
import { $ as
|
|
2
|
+
import { $t as CommentModerationPubsubMessagePublicationSchema, A as isLinkOfAnimatedImage, An as CommentIpfsSchema, Ar as PKCError, At as ChallengeMessageSchema, Bn as CommentUpdateTableRowSchema, Dn as VoteTablesRowSchema, Dt as pTimeout, F as isLinkValid, Gr as ZodError, Jn as CommentEditPubsubMessagePublicationSchema, Jt as CommunityEditPublicationPubsubReservedFields, K as removeNullUndefinedValues, Kt as version_default, Lt as DecryptedChallengeRequestPublicationSchema, M as isLinkOfImage, Mr as logger_default, Mt as ChallengeRequestMessageSchema, N as isLinkOfMedia, Ot as ChallengeAnswerMessageSchema, P as isLinkOfVideo, Pt as ChallengeVerificationMessageSchema, Q as retryKuboIpfsAddAndProvide, Qn as CommentEditsTableRowSchema, R as pubsubTopicToDhtKey, Rn as CommentUpdateSchema, Rt as DecryptedChallengeRequestSchema, S as hideClassPrivateProps, Sr as t$2, St as untrackStartedCommunity, Tn as VotePubsubReservedFields, Tt as require_sha256, U as removeBlocksFromKuboNode, Vn as CommentsTableRowSchema, W as removeMfsFilesSafely, X as retryKuboBlockPutPinAndProvidePubsubTopic, Xn as CommentEditReservedFields, Yn as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema, _ as getEquivalentCommunityAddresses, _r as r$1, a as calculateUnixFsDagSizeCidV0, c as contentContainsMarkdownVideos, ct as writeKuboFilesWithTimeout, d as derivePublicationFromChallengeRequest, dn as CommunityIpfsSchema, dr as n$2, en as CommentModerationReservedFields, f as doesDomainAddressHaveCapitalLetter, fn as CommunitySignedPropertyNames, fr as t$5, ft as findUpdatingCommunity, g as genToArray, h as findMalformedUnicodeString, hr as e, i as calculateStringSizeSameAsIpfsAddCidV0, it as timestamp, j as isLinkOfAudio, jn as CommentPubsubMessageReservedFields, jr as messages, lr as n$3, lt as findCommunityInRegistry, mr as e$1, nn as CommentModerationsTableRowSchema, nr as AuthorReservedFields, nt as statMfsPathSafely, o as contentContainsMarkdownAudio, ot as withSortedKeys, pr as t$6, r as calculateIpfsCidV0, s as contentContainsMarkdownImages, st as withSortedKeysDeep, t as areEquivalentCommunityAddresses, tt as sleepUntilTimeoutOrAbort, ur as t$7, ut as findStartedCommunity, v as getErrorCodeFromMessage, vr as t$3, vt as syncCommunityRegistryEntry, w as ipnsNameToIpnsOverPubsubTopic, wn as VotePubsubMessagePublicationSchema, wr as require_retry, wt as untrackUpdatingCommunity, xn as isStringDomain, xr as t$4, xt as trackUpdatingCommunity, y as getIpnsRecordInLocalKuboNode, yt as trackStartedCommunity } from "./util-CabVOL7E.js";
|
|
3
|
+
import { $n as calculateExpectedSignatureSize, $t as SignerWithPublicKeyAddress, A as iterateOverPageCidsToFindAllCids, An as verifyCommunityEdit, Ar as require_lodash_merge, C as TIMEFRAMES_TO_SECONDS, Cr as t$9, Dn as verifyCommentPubsubMessage, En as verifyCommentModeration, Fn as getAuthorNameFromWire, Gn as encode, H as pLimit, Hn as getCommunityPublicKeyFromWire, J as coerceSchemaRowBoolean, Jn as getPKCAddressFromPublicKey, Ln as crosspostChainDepthUpTo, Mn as buildRuntimeAuthor, Nn as cleanWireAuthor, On as verifyCommentUpdate, Qn as backupCommunityDb, Rn as effectiveMaxCrosspostDepth, Sn as verifyChallengeRequest, Tn as verifyCommentIpfs, Vn as getCommunityNameFromWire, Wn as decode, X as collectSchemaRowCoercions, Xn as getPublicKeyFromPrivateKey, Y as coerceSchemaRowJson, Yn as getPKCAddressFromPublicKeySync, Z as createSchemaRowParser, Zn as BackupAbortError, _ as TrackedInstanceRegistry, _n as signCommunity, _r as t$11, a as generatePagesReportingFailedSorts, an as encryptEd25519AesGcmPublicKeyBuffer, ar as deriveDbReplies, b as MAX_FILE_SIZE_BYTES_FOR_COMMUNITY_IPFS, bn as verifyChallengeAnswer, br as n$5, c as resolvePageSortsOrThrow, cr as getThumbnailPropsOfLink, d as getCommunityChallengeFromCommunityChallengeSettings, dn as signChallengeVerification, dt as parseCommunityIpfsSchemaPassthroughWithPKCErrorIfItFails, er as calculateInlineRepliesBudget, f as loadChallengeFileFromCommunityChallengeSettings, fn as signComment, fr as moveCommunityDbToDeletedDirectory, g as createAuthorIdentityMatcher, gn as signCommentUpdateForChallengeVerification, gr as t$10, h as authorNameResolveFailureReason, hn as signCommentUpdate, i as derivePublicPageSorts, ir as deriveDbPosts, jn as verifyVote, kn as verifyCommunity, kr as STORAGE_KEYS, ln as signChallengeMessage, lr as importSignerIntoKuboNode, lt as parseCommunityEditOptionsSchemaWithPKCErrorIfItFails, m as authorIdentityMatcherForRequest, nr as deleteOldCommunityInWindows, o as loadPageSortsForStartedCommunity, on as _validateSignatureOfPKCRecord, or as getDefaultCommunityDbConfig, p as pkcJsChallenges, pn as signCommentEdit, pr as resolveDbPostsCidRefs, qn as getIpfsKeyFromPrivateKey, r as computePageSortsFingerprint, rn as decryptEd25519AesGcmPublicKeyBuffer, rr as deriveCommentIpfsFromCommentTableRow, s as lookupPageSortFactories, sn as cleanUpBeforePublishing, t as RpcLocalCommunity, u as getChallengeVerification, v as LRUCache, vr as r$2, wn as verifyCommentEdit, wr as stringify, wt as parseJsonWithPKCErrorIfFails, x as KeyvBetterSqlite3, xr as n$4, xt as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, yr as t$8 } from "./rpc-local-community-D5ZdqFYc.js";
|
|
4
|
+
import { a as scorePageCommentsWithFile, i as partitionPageCommentsForSort, n as filterRepliesForPageSort, o as stripRepliesFromPageComment, r as orderPageCommentsByScore, t as createDescendantsLookup } from "./page-sort-scoring-3svUUHW_.js";
|
|
4
5
|
import { randomFillSync, randomUUID } from "node:crypto";
|
|
5
6
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
6
7
|
import path from "node:path";
|
|
@@ -2714,6 +2715,7 @@ function deriveAliasOriginalAuthorSignerAddress(originalAuthorPublicKey) {
|
|
|
2714
2715
|
}
|
|
2715
2716
|
var DbHandler = class {
|
|
2716
2717
|
constructor(community) {
|
|
2718
|
+
this._transactionGeneration = 0;
|
|
2717
2719
|
this._publicationWriteGeneration = 0;
|
|
2718
2720
|
this._community = community;
|
|
2719
2721
|
this._transactionDepth = 0;
|
|
@@ -2824,9 +2826,31 @@ var DbHandler = class {
|
|
|
2824
2826
|
log("Destroyed DB connection to community", this._community.address, "successfully");
|
|
2825
2827
|
}
|
|
2826
2828
|
createTransaction() {
|
|
2827
|
-
if (this._transactionDepth === 0)
|
|
2829
|
+
if (this._transactionDepth === 0) {
|
|
2830
|
+
this._db.exec("BEGIN");
|
|
2831
|
+
this._guardAgainstTransactionAcrossAwait();
|
|
2832
|
+
}
|
|
2828
2833
|
this._transactionDepth++;
|
|
2829
2834
|
}
|
|
2835
|
+
_guardAgainstTransactionAcrossAwait() {
|
|
2836
|
+
const transactionGeneration = ++this._transactionGeneration;
|
|
2837
|
+
queueMicrotask(() => {
|
|
2838
|
+
if (this._transactionDepth === 0 || this._transactionGeneration !== transactionGeneration) return;
|
|
2839
|
+
const error = /* @__PURE__ */ new Error("A DB transaction was left open across an await. Transactions must open and close synchronously (issue #417)");
|
|
2840
|
+
logger_default("pkc-js:local-community:db-handler:createTransaction").error(error);
|
|
2841
|
+
if (process.env["VITEST"]) throw error;
|
|
2842
|
+
});
|
|
2843
|
+
}
|
|
2844
|
+
readBackWithoutStoring(opts) {
|
|
2845
|
+
this._db.exec("SAVEPOINT read_back_without_storing");
|
|
2846
|
+
try {
|
|
2847
|
+
opts.write();
|
|
2848
|
+
return opts.read();
|
|
2849
|
+
} finally {
|
|
2850
|
+
this._db.exec("ROLLBACK TO read_back_without_storing");
|
|
2851
|
+
this._db.exec("RELEASE read_back_without_storing");
|
|
2852
|
+
}
|
|
2853
|
+
}
|
|
2830
2854
|
commitTransaction() {
|
|
2831
2855
|
if (this._transactionDepth > 0) {
|
|
2832
2856
|
this._transactionDepth--;
|
|
@@ -6460,13 +6484,11 @@ async function handleChallengeExchange(community, pubsubMsg) {
|
|
|
6460
6484
|
await handleChallengeRequest(community, parsedPubsubMsg, false);
|
|
6461
6485
|
} catch (e) {
|
|
6462
6486
|
log.error(`Failed to process challenge request message received at (${timeReceived})`, e);
|
|
6463
|
-
community._dbHandler.rollbackTransaction();
|
|
6464
6487
|
}
|
|
6465
6488
|
else if (parsedPubsubMsg.type === "CHALLENGEANSWER") try {
|
|
6466
6489
|
await handleChallengeAnswer(community, parsedPubsubMsg);
|
|
6467
6490
|
} catch (e) {
|
|
6468
6491
|
log.error(`Failed to process challenge answer message received at (${timeReceived})`, e);
|
|
6469
|
-
community._dbHandler.rollbackTransaction();
|
|
6470
6492
|
}
|
|
6471
6493
|
}
|
|
6472
6494
|
//#endregion
|
|
@@ -6896,9 +6918,12 @@ async function prepareCommentEditWithAlias(community, originalEdit) {
|
|
|
6896
6918
|
return commentEditSignedByAlias;
|
|
6897
6919
|
}
|
|
6898
6920
|
async function assertStoredCommentIsVerbatim(opts) {
|
|
6899
|
-
const { community, commentCid, log } = opts;
|
|
6900
|
-
const storedRow = community._dbHandler.
|
|
6901
|
-
|
|
6921
|
+
const { community, commentRow, commentCid, log } = opts;
|
|
6922
|
+
const storedRow = community._dbHandler.readBackWithoutStoring({
|
|
6923
|
+
write: () => community._dbHandler.insertComments([commentRow]),
|
|
6924
|
+
read: () => community._dbHandler.queryComment(commentCid)
|
|
6925
|
+
});
|
|
6926
|
+
if (!storedRow) throw Error(`Comment ${commentCid} could not be read back from the DB after inserting it`);
|
|
6902
6927
|
const storedComment = deriveCommentIpfsFromCommentTableRow(storedRow);
|
|
6903
6928
|
const storedCid = await calculateIpfsCidV0(stringify(storedComment));
|
|
6904
6929
|
const storedValidity = await verifyCommentIpfs({
|
|
@@ -6919,9 +6944,12 @@ async function assertStoredCommentIsVerbatim(opts) {
|
|
|
6919
6944
|
throw error;
|
|
6920
6945
|
}
|
|
6921
6946
|
async function assertStoredAuthorEditIsVerbatim(opts) {
|
|
6922
|
-
const { community, commentEditRaw, authorSignerAddress, log } = opts;
|
|
6923
|
-
const storedEdit = community._dbHandler.
|
|
6924
|
-
|
|
6947
|
+
const { community, editTableRow, commentEditRaw, authorSignerAddress, log } = opts;
|
|
6948
|
+
const storedEdit = community._dbHandler.readBackWithoutStoring({
|
|
6949
|
+
write: () => community._dbHandler.insertCommentEdits([editTableRow]),
|
|
6950
|
+
read: () => community._dbHandler.queryLatestAuthorEdit(commentEditRaw.commentCid, authorSignerAddress)
|
|
6951
|
+
});
|
|
6952
|
+
if (!storedEdit || storedEdit.signature.signature !== commentEditRaw.signature.signature) throw Error(`Edit of comment ${commentEditRaw.commentCid} could not be read back from the DB after inserting it`);
|
|
6925
6953
|
const storedValidity = await _validateSignatureOfPKCRecord(storedEdit);
|
|
6926
6954
|
if (storedValidity.valid) return;
|
|
6927
6955
|
const error = new PKCError("ERR_COMMUNITY_CANNOT_STORE_PUBLICATION_VERBATIM", {
|
|
@@ -6954,20 +6982,14 @@ async function storeCommentEdit(community, commentEditRaw, challengeRequestId) {
|
|
|
6954
6982
|
editTableRow.extraProps = t$10(commentEditRaw, extraPropsInEdit);
|
|
6955
6983
|
}
|
|
6956
6984
|
if (community._dbHandler.hasCommentEditWithSignatureEncoded(editTableRow.signature.signature)) throw new PKCError("ERR_DUPLICATE_COMMENT_EDIT", { editTableRow });
|
|
6957
|
-
|
|
6958
|
-
|
|
6959
|
-
|
|
6960
|
-
|
|
6961
|
-
|
|
6962
|
-
|
|
6963
|
-
|
|
6964
|
-
|
|
6965
|
-
});
|
|
6966
|
-
community._dbHandler.commitTransaction();
|
|
6967
|
-
} catch (e) {
|
|
6968
|
-
community._dbHandler.rollbackTransaction();
|
|
6969
|
-
throw e;
|
|
6970
|
-
}
|
|
6985
|
+
if (editSignedByOriginalAuthor) await assertStoredAuthorEditIsVerbatim({
|
|
6986
|
+
community,
|
|
6987
|
+
editTableRow,
|
|
6988
|
+
commentEditRaw,
|
|
6989
|
+
authorSignerAddress,
|
|
6990
|
+
log
|
|
6991
|
+
});
|
|
6992
|
+
community._dbHandler.insertCommentEdits([editTableRow]);
|
|
6971
6993
|
if (commentEditRaw.deleted === true) {
|
|
6972
6994
|
const isPending = commentToBeEdited.pendingApproval;
|
|
6973
6995
|
const disapprovalResult = community._dbHandler._queryIsCommentApproved(commentToBeEdited);
|
|
@@ -7123,6 +7145,12 @@ async function storeComment(community, opts) {
|
|
|
7123
7145
|
}
|
|
7124
7146
|
if (challengeAggregate?.aggregatedCommentUpdate && Object.keys(challengeAggregate.aggregatedCommentUpdate).length > 0) commentRow.challengeCommentUpdate = challengeAggregate.aggregatedCommentUpdate;
|
|
7125
7147
|
if (originalCommentSignatureEncoded) commentRow.originalCommentSignatureEncoded = originalCommentSignatureEncoded;
|
|
7148
|
+
await assertStoredCommentIsVerbatim({
|
|
7149
|
+
community,
|
|
7150
|
+
commentRow,
|
|
7151
|
+
commentCid,
|
|
7152
|
+
log
|
|
7153
|
+
});
|
|
7126
7154
|
community._dbHandler.createTransaction();
|
|
7127
7155
|
try {
|
|
7128
7156
|
if (!pendingApproval) {
|
|
@@ -7131,11 +7159,6 @@ async function storeComment(community, opts) {
|
|
|
7131
7159
|
if (typeof postNumber === "number") commentRow.postNumber = postNumber;
|
|
7132
7160
|
}
|
|
7133
7161
|
community._dbHandler.insertComments([commentRow]);
|
|
7134
|
-
await assertStoredCommentIsVerbatim({
|
|
7135
|
-
community,
|
|
7136
|
-
commentCid,
|
|
7137
|
-
log
|
|
7138
|
-
});
|
|
7139
7162
|
if (typeof community.settings?.maxPendingApprovalCount === "number") community._dbHandler.removeOldestPendingCommentIfWeHitMaxPendingCount(community.settings.maxPendingApprovalCount);
|
|
7140
7163
|
community._dbHandler.commitTransaction();
|
|
7141
7164
|
} catch (e) {
|
|
@@ -7263,6 +7286,74 @@ async function providePubsubTopicRoutingCidsIfNeeded(community, force = false) {
|
|
|
7263
7286
|
}
|
|
7264
7287
|
}
|
|
7265
7288
|
//#endregion
|
|
7289
|
+
//#region dist/node/runtime/node/community/local-community/registry-sync.js
|
|
7290
|
+
const PAGE_SORTS_FINGERPRINT_KEY = STORAGE_KEYS[STORAGE_KEYS.PAGE_SORTS_FINGERPRINT];
|
|
7291
|
+
async function setResolvedPageSorts(community, resolved, factories) {
|
|
7292
|
+
const pagesSettings = community.settings?.pages;
|
|
7293
|
+
community._pageSorts = resolved;
|
|
7294
|
+
community._pageSortFactories = factories;
|
|
7295
|
+
community.pageSorts = derivePublicPageSorts({
|
|
7296
|
+
pagesSettings,
|
|
7297
|
+
resolved
|
|
7298
|
+
});
|
|
7299
|
+
await community._dbHandler.keyvSet(PAGE_SORTS_FINGERPRINT_KEY, computePageSortsFingerprint({
|
|
7300
|
+
pagesSettings,
|
|
7301
|
+
resolved,
|
|
7302
|
+
factories
|
|
7303
|
+
}));
|
|
7304
|
+
}
|
|
7305
|
+
const sameFactories = (a, b) => a !== void 0 && a.length === b.length && a.every((factory, i) => factory === b[i]);
|
|
7306
|
+
async function syncPageSortsWithRegistry(community) {
|
|
7307
|
+
const log = logger_default("pkc-js:local-community:registry-sync:page-sorts");
|
|
7308
|
+
await community._dbHandler.initDbIfNeeded();
|
|
7309
|
+
const pagesSettings = community.settings?.pages;
|
|
7310
|
+
const currentFactories = lookupPageSortFactories({
|
|
7311
|
+
pagesSettings,
|
|
7312
|
+
pkc: community._pkc
|
|
7313
|
+
});
|
|
7314
|
+
const inMemory = community._pageSorts !== void 0 && community._pageSortFactories !== void 0;
|
|
7315
|
+
if (inMemory && sameFactories(community._pageSortFactories, currentFactories)) return;
|
|
7316
|
+
const previousFingerprint = community._dbHandler.keyvGet(PAGE_SORTS_FINGERPRINT_KEY);
|
|
7317
|
+
const previousPublicPageSorts = stringify(community.pageSorts ?? null);
|
|
7318
|
+
const resolved = await loadPageSortsForStartedCommunity(community);
|
|
7319
|
+
const factories = community._pageSortFactories;
|
|
7320
|
+
const fingerprint = computePageSortsFingerprint({
|
|
7321
|
+
pagesSettings,
|
|
7322
|
+
resolved,
|
|
7323
|
+
factories
|
|
7324
|
+
});
|
|
7325
|
+
const changed = inMemory || previousFingerprint !== void 0 && previousFingerprint !== fingerprint;
|
|
7326
|
+
await setResolvedPageSorts(community, resolved, factories);
|
|
7327
|
+
if (changed) {
|
|
7328
|
+
log("Page sort factories changed in the registry, regenerating every CommentUpdate", community.address);
|
|
7329
|
+
community._dbHandler.forceUpdateOnAllComments();
|
|
7330
|
+
community._communityUpdateTrigger = true;
|
|
7331
|
+
} else if (stringify(community.pageSorts ?? null) !== previousPublicPageSorts) community._communityUpdateTrigger = true;
|
|
7332
|
+
}
|
|
7333
|
+
async function syncChallengesWithRegistry(community) {
|
|
7334
|
+
const log = logger_default("pkc-js:local-community:registry-sync:challenges");
|
|
7335
|
+
const challengeSettings = community.settings?.challenges;
|
|
7336
|
+
if (!Array.isArray(challengeSettings)) return;
|
|
7337
|
+
let challenges;
|
|
7338
|
+
try {
|
|
7339
|
+
challenges = await Promise.all(challengeSettings.map(async (cs) => (await getCommunityChallengeFromCommunityChallengeSettings({
|
|
7340
|
+
communityChallengeSettings: cs,
|
|
7341
|
+
pkc: community._pkc
|
|
7342
|
+
})).communityChallenge));
|
|
7343
|
+
} catch (e) {
|
|
7344
|
+
log.error("Could not recompute community.challenges from the registry, keeping the previous ones", community.address, e);
|
|
7345
|
+
return;
|
|
7346
|
+
}
|
|
7347
|
+
if (stringify(challenges) === stringify(community.challenges ?? null)) return;
|
|
7348
|
+
log("community.challenges changed in the registry, republishing", community.address);
|
|
7349
|
+
community.challenges = challenges;
|
|
7350
|
+
community._communityUpdateTrigger = true;
|
|
7351
|
+
}
|
|
7352
|
+
async function syncWithRegistries(community) {
|
|
7353
|
+
await syncChallengesWithRegistry(community);
|
|
7354
|
+
await syncPageSortsWithRegistry(community);
|
|
7355
|
+
}
|
|
7356
|
+
//#endregion
|
|
7266
7357
|
//#region dist/node/runtime/node/community/local-community/ipns-publishing.js
|
|
7267
7358
|
async function calculateNewPostUpdates(community) {
|
|
7268
7359
|
const postUpdates = {};
|
|
@@ -7517,6 +7608,7 @@ async function syncIpnsWithDb(community) {
|
|
|
7517
7608
|
community._setStartedStateWithEmission("publishing-ipns");
|
|
7518
7609
|
community._clientsManager.updateKuboRpcState("publishing-ipns", kuboRpc.url);
|
|
7519
7610
|
await purgeDisapprovedCommentsOlderThan(community);
|
|
7611
|
+
await syncWithRegistries(community);
|
|
7520
7612
|
const cidsUpdatedInThisCycle = await updateCommentsAndWritePostUpdates(community);
|
|
7521
7613
|
requireCommunityUpdateIfModQueueChanged(community);
|
|
7522
7614
|
await updateCommunityIpnsIfNeeded(community, cidsUpdatedInThisCycle);
|
|
@@ -7734,7 +7826,9 @@ async function start(community) {
|
|
|
7734
7826
|
pkc: community._pkc
|
|
7735
7827
|
})).communityChallenge));
|
|
7736
7828
|
await emitChallengeSettingsValidationErrors(community, log);
|
|
7737
|
-
|
|
7829
|
+
community._pageSorts = void 0;
|
|
7830
|
+
community._pageSortFactories = void 0;
|
|
7831
|
+
await syncPageSortsWithRegistry(community);
|
|
7738
7832
|
} catch (e) {
|
|
7739
7833
|
await community.stop();
|
|
7740
7834
|
e.details = {
|
|
@@ -8068,6 +8162,10 @@ async function parseChallengesToEdit(community, newChallengeSettings) {
|
|
|
8068
8162
|
}
|
|
8069
8163
|
async function parsePagesToEdit(community, newSettings) {
|
|
8070
8164
|
await community._dbHandler.initDbIfNeeded();
|
|
8165
|
+
const factories = lookupPageSortFactories({
|
|
8166
|
+
pagesSettings: newSettings.pages,
|
|
8167
|
+
pkc: community._pkc
|
|
8168
|
+
});
|
|
8071
8169
|
const resolved = await resolvePageSortsOrThrow({
|
|
8072
8170
|
pagesSettings: newSettings.pages,
|
|
8073
8171
|
pkc: community._pkc,
|
|
@@ -8080,13 +8178,14 @@ async function parsePagesToEdit(community, newSettings) {
|
|
|
8080
8178
|
resolved
|
|
8081
8179
|
}),
|
|
8082
8180
|
resolved,
|
|
8181
|
+
factories,
|
|
8083
8182
|
pagesChanged
|
|
8084
8183
|
};
|
|
8085
8184
|
}
|
|
8086
|
-
function applyPagesEdit(community, pagesEdit) {
|
|
8185
|
+
async function applyPagesEdit(community, pagesEdit) {
|
|
8087
8186
|
if (!pagesEdit) return;
|
|
8088
8187
|
if (pagesEdit.pagesChanged) community._dbHandler.forceUpdateOnAllComments();
|
|
8089
|
-
community.
|
|
8188
|
+
await setResolvedPageSorts(community, pagesEdit.resolved, pagesEdit.factories);
|
|
8090
8189
|
}
|
|
8091
8190
|
async function validateNewAddressBeforeEditing(community, newAddress, log) {
|
|
8092
8191
|
if (doesDomainAddressHaveCapitalLetter(newAddress)) throw new PKCError("ERR_COMMUNITY_NAME_HAS_CAPITAL_LETTER", { communityAddress: newAddress });
|
|
@@ -8128,7 +8227,7 @@ async function editPropsOnStartedCommunity(community, parsedEditOptions, pagesEd
|
|
|
8128
8227
|
...parsedEditOptions,
|
|
8129
8228
|
_internalStateUpdateId: uniqueEditId
|
|
8130
8229
|
});
|
|
8131
|
-
applyPagesEdit(community, pagesEdit);
|
|
8230
|
+
await applyPagesEdit(community, pagesEdit);
|
|
8132
8231
|
community._communityUpdateTrigger = true;
|
|
8133
8232
|
log(`Community (${community.address}) props (${t$6(parsedEditOptions)}) has been edited. Will be including edited props in next update: `, t$10(community, t$6(parsedEditOptions)));
|
|
8134
8233
|
community.emit("update", community);
|
|
@@ -8156,7 +8255,7 @@ async function editPropsOnNotStartedCommunity(community, parsedEditOptions, page
|
|
|
8156
8255
|
const mergedInternalState = await updateDbInternalState(community, parsedEditOptions);
|
|
8157
8256
|
if ("updatedAt" in mergedInternalState && mergedInternalState.updatedAt) await community.initInternalCommunityAfterFirstUpdateNoMerge(mergedInternalState);
|
|
8158
8257
|
else await community.initInternalCommunityBeforeFirstUpdateNoMerge(mergedInternalState);
|
|
8159
|
-
applyPagesEdit(community, pagesEdit);
|
|
8258
|
+
await applyPagesEdit(community, pagesEdit);
|
|
8160
8259
|
await community._dbHandler.destoryConnection();
|
|
8161
8260
|
community.emit("update", community);
|
|
8162
8261
|
return community;
|
|
@@ -8415,6 +8514,7 @@ var LocalCommunity = class extends RpcLocalCommunity {
|
|
|
8415
8514
|
this._communityUpdateTrigger = false;
|
|
8416
8515
|
this._combinedHashOfPendingCommentsCids = (0, import_sha256.sha256)("");
|
|
8417
8516
|
this._pageSorts = void 0;
|
|
8517
|
+
this._pageSortFactories = void 0;
|
|
8418
8518
|
this._publishLoopPromise = void 0;
|
|
8419
8519
|
this._updateLoopPromise = void 0;
|
|
8420
8520
|
this._firstUpdateAfterStart = true;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as createNewLocalCommunityDb, r as updateInstancePropsWithStartedCommunityOrDb, t as LocalCommunity } from "./local-community-
|
|
1
|
+
import { n as createNewLocalCommunityDb, r as updateInstancePropsWithStartedCommunityOrDb, t as LocalCommunity } from "./local-community-XrLSKipf.js";
|
|
2
2
|
export { LocalCommunity, createNewLocalCommunityDb, updateInstancePropsWithStartedCommunityOrDb };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { i as __toESM, r as __require, t as __commonJSMin } from "./chunk-2rV9d50f.js";
|
|
2
|
-
import { $ as shortifyAddress, An as CommentIpfsSchema, Ar as PKCError, At as ChallengeMessageSchema, Ct as untrackUpdatingComment, Dt as pTimeout, E as isIpfsCid, Er as FailedToFetchCommentUpdateFromGatewaysError, Et as TimeoutError, Fn as CommentUpdateForChallengeVerificationSchema, Fr as setErrorMap, H as rejectWhenCommunityStopsOrAborts, J as replaceXWithY, Jr as stringifyPrimitive, Kr as joinValues, Kt as version_default, Mr as logger_default, Mt as ChallengeRequestMessageSchema, O as isIpns, Ot as ChallengeAnswerMessageSchema, Pt as ChallengeVerificationMessageSchema, Rn as CommentUpdateSchema, S as hideClassPrivateProps, T as isAbortError, Tr as FailedToFetchCommentIpfsFromGatewaysError, Tt as require_sha256, V as rejectWhenAbortSignalFires, Y as resolveWhenPredicateIsTrue, Z as retryKuboIpfsAdd, _r as r, at as waitForUpdateInCommunityInstanceWithErrorAndTimeout, b as getPostUpdateTimestampRange, bt as trackUpdatingComment, dn as CommunityIpfsSchema, dr as n$1, dt as findUpdatingComment, et as shortifyCid, f as doesDomainAddressHaveCapitalLetter, ft as findUpdatingCommunity, gt as refreshTrackedCommentAliases, hr as e$1, ht as listUpdatingCommunities, it as timestamp, jr as messages, l as createAbortError, lr as n$2, mr as e, mt as listUpdatingComments, on as CommunityAnchorSchema, pr as t$1, pt as listStartedCommunities, q as removeUndefinedValuesRecursively, qr as parsedType, rt as throwIfAbortSignalAborted, t as areEquivalentCommunityAddresses, tt as sleepUntilTimeoutOrAbort, u as deepMergeRuntimeFields, ut as findStartedCommunity, w as ipnsNameToIpnsOverPubsubTopic, wr as require_retry, wt as untrackUpdatingCommunity, xn as isStringDomain, yn as PubsubTopicSchema } from "./util-
|
|
3
|
-
import {
|
|
4
|
-
import { s as getHeliaDebugContext } from "./util-
|
|
2
|
+
import { $ as shortifyAddress, An as CommentIpfsSchema, Ar as PKCError, At as ChallengeMessageSchema, Ct as untrackUpdatingComment, Dt as pTimeout, E as isIpfsCid, Er as FailedToFetchCommentUpdateFromGatewaysError, Et as TimeoutError, Fn as CommentUpdateForChallengeVerificationSchema, Fr as setErrorMap, H as rejectWhenCommunityStopsOrAborts, J as replaceXWithY, Jr as stringifyPrimitive, Kr as joinValues, Kt as version_default, Mr as logger_default, Mt as ChallengeRequestMessageSchema, O as isIpns, Ot as ChallengeAnswerMessageSchema, Pt as ChallengeVerificationMessageSchema, Rn as CommentUpdateSchema, S as hideClassPrivateProps, T as isAbortError, Tr as FailedToFetchCommentIpfsFromGatewaysError, Tt as require_sha256, V as rejectWhenAbortSignalFires, Y as resolveWhenPredicateIsTrue, Z as retryKuboIpfsAdd, _r as r, at as waitForUpdateInCommunityInstanceWithErrorAndTimeout, b as getPostUpdateTimestampRange, bt as trackUpdatingComment, dn as CommunityIpfsSchema, dr as n$1, dt as findUpdatingComment, et as shortifyCid, f as doesDomainAddressHaveCapitalLetter, ft as findUpdatingCommunity, gt as refreshTrackedCommentAliases, hr as e$1, ht as listUpdatingCommunities, it as timestamp, jr as messages, l as createAbortError, lr as n$2, mr as e, mt as listUpdatingComments, on as CommunityAnchorSchema, pr as t$1, pt as listStartedCommunities, q as removeUndefinedValuesRecursively, qr as parsedType, rt as throwIfAbortSignalAborted, t as areEquivalentCommunityAddresses, tt as sleepUntilTimeoutOrAbort, u as deepMergeRuntimeFields, ut as findStartedCommunity, w as ipnsNameToIpnsOverPubsubTopic, wr as require_retry, wt as untrackUpdatingCommunity, xn as isStringDomain, yn as PubsubTopicSchema } from "./util-CabVOL7E.js";
|
|
3
|
+
import { An as verifyCommunityEdit, At as parseVotePubsubMessagePublicationSchemaWithPKCErrorIfItFails, B as InflightResourceTypes, Bn as getCommunityAddressFromRecord, Bt as RpcExportCommunityModLogsResultSchema, Cn as verifyChallengeVerification, Cr as t$4, Ct as parseDecryptedChallengeWithPKCErrorIfItFails, D as findCommentInPageInstance, Dn as verifyCommentPubsubMessage, Dr as NAME_RESOLVED_TRUE_TTL_MS, Dt as parseRpcCommentUpdateEventWithPKCErrorIfItFails, E as extractCommunityRuntimeFieldsFromParsedPages, En as verifyCommentModeration, Er as NAME_RESOLVED_FALSE_TTL_MS, Et as parseRpcCommentEventWithPKCErrorIfItFails, Ft as RpcCommentRepliesPageParamSchema, G as decodeRpcChallengePubsubMsg, Gt as RpcPublishAnchorRecordParamSchema, Hn as getCommunityPublicKeyFromWire, Ht as RpcExportCommunityResultSchema, I as stripNameResolvedFromCrosspost, In as normalizeCreatePublicationAuthor, It as RpcCommunityIdentifierParamSchema, Jt as RpcResolveAuthorNameResultSchema, K as decodeRpcChallengeRequestPubsubMsg, Kn as getBufferedPKCAddressFromPublicKey, Kt as RpcPublishChallengeAnswersParamSchema, L as PKCClientsManager, Lt as RpcCommunityPageParamSchema, M as applyNameResolvedCacheToCrosspost, Mn as buildRuntimeAuthor, Mr as require_undici, Mt as RpcAuthorNameParamSchema, N as cloneCrosspostForRuntime, Nn as cleanWireAuthor, Nt as RpcCancelExportParamSchema, O as findCommentInPageInstanceRecursively, On as verifyCommentUpdate, Or as NAME_RESOLVE_FAILED_RETRY_FLOOR_MS, Ot as parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, P as collectCrosspostAuthorsToResolve, Pn as getAuthorNameFromRuntime, Pt as RpcCidParamSchema, Q as parseCidStringSchemaWithPKCErrorIfItFails, Qt as require_lib$1, R as GenericStateClient, Rt as RpcEditCommunityParamSchema, S as RepliesPages, Sr as t$2, St as parseDecryptedChallengeVerification, Tn as verifyCommentIpfs, Tr as MAX_FILE_SIZE_BYTES_FOR_COMMENT_UPDATE, Tt as parsePKCUserOptionsSchemaWithPKCErrorIfItFails, U as PKCTypedEmitter, Un as normalizeCommunityInputFromCommunity, Ut as RpcFetchCidParamSchema, Vn as getCommunityNameFromWire, Vt as RpcExportCommunityParamSchema, W as decodeRpcChallengeAnswerPubsubMsg, Wn as decode, Wt as RpcFetchCidResultSchema, Xt as RpcSuccessResultSchema, Yn as getPKCAddressFromPublicKeySync, Yt as RpcSubscriptionIdResultSchema, Zt as RpcUnsubscribeParamSchema, _ as TrackedInstanceRegistry, at as parseCommentPubsubMessagePublicationWithPKCErrorIfItFails, br as n$3, bt as parseCreateVoteOptionsSchemaWithPKCErrorIfItFails, cn as signChallengeAnswer, dr as monitorCommunitiesDirectory, en as createSigner, fn as signComment, ft as parseCreateCommentEditOptionsSchemaWithPKCErrorIfItFails, gr as t$5, hr as tryToDeleteCommunitiesThatFailedToBeDeletedBefore, ht as parseCreateCommunityEditPublicationOptionsSchemaWithPKCErrorIfItFails, in as encryptEd25519AesGcm, it as parseCommentModerationPubsubMessagePublicationSchemaWithPKCErrorIfItFails, j as parseRawPages, jn as verifyVote, jr as nativeFunctions$2, jt as RpcAnchorPublishPreparationResultSchema, k as findCommentInParsedPages, l as pkcJsPageSorts, mn as signCommentModeration, mr as setNativeFunctions$1, mt as parseCreateCommentOptionsSchemaWithPKCErrorIfItFails, n as RpcRemoteCommunity, nn as decryptEd25519AesGcm, nt as parseCommentIpfsSchemaWithPKCErrorIfItFails, ot as parseCommentUpdateSchemaWithPKCErrorIfItFails, p as pkcJsChallenges, pn as signCommentEdit, pt as parseCreateCommentModerationOptionsSchemaWithPKCErrorIfItFails, q as decodeRpcChallengeVerificationPubsubMsg, qt as RpcPublishedAnchorRecordResultSchema, sn as cleanUpBeforePublishing, sr as getDefaultDataPath, st as parseCommunityAddressWithPKCErrorIfItFails, t as RpcLocalCommunity, tn as createAnchorIpnsRecord$1, tr as createKuboRpcClient, tt as parseCommentEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, un as signChallengeRequest, ur as listCommunitiesSync, ut as parseCommunityEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, v as LRUCache, vn as signCommunityEdit, vt as parseCreateRemoteCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, wn as verifyCommentEdit, wt as parseJsonWithPKCErrorIfFails, x as KeyvBetterSqlite3, xn as verifyChallengeMessage, xt as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, y as RemoteCommunity, yn as signVote, yr as t$3, yt as parseCreateRpcCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, z as InflightFetchManager, zn as buildRuntimeCommunityFields, zt as RpcExportCommunityModLogsParamSchema } from "./rpc-local-community-D5ZdqFYc.js";
|
|
4
|
+
import { s as getHeliaDebugContext } from "./util-Cnpgfqwn.js";
|
|
5
5
|
import path from "path";
|
|
6
6
|
import assert from "assert";
|
|
7
7
|
import fs from "fs";
|
|
@@ -8254,7 +8254,7 @@ var PKC$1 = class extends PKCTypedEmitter {
|
|
|
8254
8254
|
this.clients.libp2pJsClients = {};
|
|
8255
8255
|
if (!this.libp2pJsClientsOptions) return;
|
|
8256
8256
|
if (!this.httpRoutersOptions) throw Error("httpRoutersOptions is required for libp2pJsClient");
|
|
8257
|
-
const { createLibp2pJsClientOrUseExistingOne } = await import("./helia-for-pkc-
|
|
8257
|
+
const { createLibp2pJsClientOrUseExistingOne } = await import("./helia-for-pkc-BB8P6KYw.js");
|
|
8258
8258
|
for (const clientOptions of this.libp2pJsClientsOptions) {
|
|
8259
8259
|
const heliaNode = await createLibp2pJsClientOrUseExistingOne({
|
|
8260
8260
|
...clientOptions,
|
|
@@ -8533,7 +8533,7 @@ var PKC$1 = class extends PKCTypedEmitter {
|
|
|
8533
8533
|
const log = logger_default("pkc-js:pkc:createLocalCommunity");
|
|
8534
8534
|
log.trace("Received community options to create a local community instance:", options);
|
|
8535
8535
|
if (!this._canCreateNewLocalCommunity()) throw new PKCError("ERR_CAN_NOT_CREATE_A_LOCAL_COMMUNITY", { pkcOptions: this._userPKCOptions });
|
|
8536
|
-
const { LocalCommunity, createNewLocalCommunityDb, updateInstancePropsWithStartedCommunityOrDb } = await import("./local-community-
|
|
8536
|
+
const { LocalCommunity, createNewLocalCommunityDb, updateInstancePropsWithStartedCommunityOrDb } = await import("./local-community-wAvG_J_u.js");
|
|
8537
8537
|
const isLocalCommunity = (await listCommunitiesSync(this)).includes(options.address);
|
|
8538
8538
|
const community = new LocalCommunity(this);
|
|
8539
8539
|
if (isLocalCommunity) {
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { _ as getEquivalentCommunityAddresses, vn as PageSortFileSchema } from "./util-CabVOL7E.js";
|
|
2
|
+
//#region dist/node/pages/page-sort-scoring.js
|
|
3
|
+
function validatePageSortFile(rawFile) {
|
|
4
|
+
const validated = PageSortFileSchema.parse(rawFile);
|
|
5
|
+
const raw = rawFile;
|
|
6
|
+
return {
|
|
7
|
+
...validated,
|
|
8
|
+
score: raw.score,
|
|
9
|
+
...raw.validatePageSortSettings ? { validatePageSortSettings: raw.validatePageSortSettings } : {}
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
function applyPageSortExclusions({ comments, exclusions, communityAddress }) {
|
|
13
|
+
const equivalentAddresses = communityAddress ? new Set(getEquivalentCommunityAddresses(communityAddress)) : void 0;
|
|
14
|
+
return comments.filter(({ comment, commentUpdate }) => {
|
|
15
|
+
if (exclusions.excludeRemovedComments && commentUpdate.removed === true) return false;
|
|
16
|
+
if (exclusions.excludeDeletedComments && commentUpdate.edit?.deleted === true) return false;
|
|
17
|
+
if (exclusions.excludeCommentWithApprovedFalse && commentUpdate.approved === false) return false;
|
|
18
|
+
if (exclusions.excludeCommentPendingApproval && commentUpdate.pendingApproval === true) return false;
|
|
19
|
+
if (exclusions.excludeCommentsWithDifferentCommunityAddress && equivalentAddresses) {
|
|
20
|
+
if (!((comment.communityPublicKey ? equivalentAddresses.has(comment.communityPublicKey) : false) || (comment.communityName ? equivalentAddresses.has(comment.communityName) : false))) return false;
|
|
21
|
+
}
|
|
22
|
+
return true;
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
function filterRepliesForPageSort({ replies, communityAddress }) {
|
|
26
|
+
return applyPageSortExclusions({
|
|
27
|
+
comments: replies,
|
|
28
|
+
exclusions: {
|
|
29
|
+
excludeRemovedComments: false,
|
|
30
|
+
excludeDeletedComments: false,
|
|
31
|
+
excludeCommentWithApprovedFalse: false,
|
|
32
|
+
excludeCommentPendingApproval: false,
|
|
33
|
+
excludeCommentsWithDifferentCommunityAddress: true
|
|
34
|
+
},
|
|
35
|
+
communityAddress
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
function partitionPageCommentsForSort({ comments, reserved, baseTimestamp }) {
|
|
39
|
+
const pinned = reserved.pinnedFirst ? comments.filter((entry) => entry.commentUpdate.pinned === true) : [];
|
|
40
|
+
let unpinned = reserved.pinnedFirst ? comments.filter((entry) => entry.commentUpdate.pinned !== true) : comments;
|
|
41
|
+
if (typeof reserved.maxAgeSeconds === "number") {
|
|
42
|
+
const timestampLower = baseTimestamp - reserved.maxAgeSeconds;
|
|
43
|
+
unpinned = unpinned.filter((entry) => entry.comment.timestamp >= timestampLower);
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
pinned,
|
|
47
|
+
unpinned
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function orderPageCommentsByScore({ pinned, unpinned, scoreOf, sortName }) {
|
|
51
|
+
const kept = (entries) => {
|
|
52
|
+
const scored = [];
|
|
53
|
+
for (const entry of entries) {
|
|
54
|
+
const score = scoreOf(entry);
|
|
55
|
+
if (score === null) continue;
|
|
56
|
+
if (typeof score !== "number" || Number.isNaN(score)) throw Error(`Page sort ${sortName} returned no numeric score for comment ${entry.commentUpdate.cid}`);
|
|
57
|
+
scored.push({
|
|
58
|
+
entry,
|
|
59
|
+
score
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
return scored.sort((a, b) => b.score - a.score).map(({ entry }) => entry);
|
|
63
|
+
};
|
|
64
|
+
return kept(pinned).concat(kept(unpinned));
|
|
65
|
+
}
|
|
66
|
+
function stripRepliesFromPageComment(entry) {
|
|
67
|
+
if (!("replies" in entry.commentUpdate)) return entry;
|
|
68
|
+
const { replies: _replies, ...commentUpdate } = entry.commentUpdate;
|
|
69
|
+
return {
|
|
70
|
+
comment: entry.comment,
|
|
71
|
+
commentUpdate
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function createDescendantsLookup(replies) {
|
|
75
|
+
const childrenByParent = /* @__PURE__ */ new Map();
|
|
76
|
+
for (const entry of replies) {
|
|
77
|
+
const stripped = stripRepliesFromPageComment(entry);
|
|
78
|
+
const parentCid = stripped.comment.parentCid;
|
|
79
|
+
if (!parentCid) continue;
|
|
80
|
+
const siblings = childrenByParent.get(parentCid);
|
|
81
|
+
if (siblings) siblings.push(stripped);
|
|
82
|
+
else childrenByParent.set(parentCid, [stripped]);
|
|
83
|
+
}
|
|
84
|
+
return (cid) => {
|
|
85
|
+
const collected = [];
|
|
86
|
+
const stack = [cid];
|
|
87
|
+
while (stack.length) {
|
|
88
|
+
const children = childrenByParent.get(stack.pop());
|
|
89
|
+
if (!children) continue;
|
|
90
|
+
for (const child of children) {
|
|
91
|
+
collected.push(child);
|
|
92
|
+
stack.push(child.commentUpdate.cid);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return collected;
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
function scorePageCommentsWithFile({ file, options, baseTimestamp, replies, stripEntry = stripRepliesFromPageComment, descendantsOf: descendantsOfOverride }) {
|
|
99
|
+
const descendantsOf = file.requireReplies ? descendantsOfOverride ?? createDescendantsLookup(replies ?? []) : void 0;
|
|
100
|
+
return (entry) => {
|
|
101
|
+
const { comment, commentUpdate } = stripEntry(entry);
|
|
102
|
+
return file.score({
|
|
103
|
+
comment,
|
|
104
|
+
commentUpdate,
|
|
105
|
+
options,
|
|
106
|
+
baseTimestamp,
|
|
107
|
+
...descendantsOf ? { replies: descendantsOf(commentUpdate.cid) } : {}
|
|
108
|
+
});
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
//#endregion
|
|
112
|
+
export { scorePageCommentsWithFile as a, partitionPageCommentsForSort as i, filterRepliesForPageSort as n, stripRepliesFromPageComment as o, orderPageCommentsByScore as r, validatePageSortFile as s, createDescendantsLookup as t };
|