@pkcprotocol/pkc-js 0.0.126 → 0.0.128
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.d.ts +8 -0
- package/dist/browser/clients/base-client-manager.js +39 -2
- package/dist/browser/clients/base-client-manager.js.map +1 -1
- package/dist/browser/community/community-client-manager.js +2 -1
- package/dist/browser/community/community-client-manager.js.map +1 -1
- package/dist/browser/generated-version.d.ts +1 -1
- package/dist/browser/generated-version.js +1 -1
- package/dist/browser/helia/helia-for-pkc.js +88 -22
- package/dist/browser/helia/helia-for-pkc.js.map +1 -1
- package/dist/browser/helia/types.d.ts +4 -1
- package/dist/browser/pages/page-size.d.ts +2 -0
- package/dist/browser/pages/page-size.js +11 -0
- package/dist/browser/pages/page-size.js.map +1 -0
- package/dist/browser/pages/pages-client-manager.js +2 -1
- package/dist/browser/pages/pages-client-manager.js.map +1 -1
- package/dist/browser/pages/util.js +3 -2
- package/dist/browser/pages/util.js.map +1 -1
- package/dist/browser/publications/comment/comment-client-manager.d.ts +5 -2
- package/dist/browser/publications/comment/comment-client-manager.js +104 -40
- package/dist/browser/publications/comment/comment-client-manager.js.map +1 -1
- package/dist/browser/publications/comment/comment.d.ts +4 -0
- package/dist/browser/publications/comment/comment.js +4 -0
- package/dist/browser/publications/comment/comment.js.map +1 -1
- package/dist/browser/runtime/node/community/page-generator.js +8 -7
- package/dist/browser/runtime/node/community/page-generator.js.map +1 -1
- package/dist/bundled/bundle-manifest.json +47 -46
- package/dist/bundled/challenges.js +1 -1
- package/dist/bundled/chunks/{helia-for-pkc-vQZvQcs_.js → helia-for-pkc-6kkeZX1a.js} +123 -69
- package/dist/bundled/chunks/{local-community-51NzNBUS.js → local-community-B79BAYRo.js} +34 -35
- package/dist/bundled/chunks/{local-community-dcM1R3k5.js → local-community-BST1U_f3.js} +1 -1
- package/dist/bundled/chunks/{node-agDtcKUp.js → node-BEH8NA_I.js} +108 -32
- package/dist/bundled/chunks/{page-sort-scoring-BSBLegpC.js → page-sort-scoring-2FkqYYNf.js} +1 -1
- package/dist/bundled/chunks/{rpc-local-community-DOcUqswi.js → rpc-local-community-SmLDPm1j.js} +44 -9
- package/dist/bundled/chunks/{util-PGPkG-gU.js → util-LwSS90AE.js} +1 -1
- package/dist/bundled/chunks/{util-DNYbha6W.js → util-jyIDYw_Q.js} +1 -1
- package/dist/bundled/chunks/{validate-package-factories-2U8SCIxZ.js → validate-package-factories-_KKnb8At.js} +2 -2
- package/dist/bundled/index.js +1 -1
- package/dist/bundled/page-sorts.js +1 -1
- package/dist/bundled/rpc/src/index.js +4 -4
- package/dist/node/clients/base-client-manager.d.ts +8 -0
- package/dist/node/clients/base-client-manager.js +39 -2
- package/dist/node/clients/base-client-manager.js.map +1 -1
- package/dist/node/community/community-client-manager.js +2 -1
- package/dist/node/community/community-client-manager.js.map +1 -1
- package/dist/node/generated-version.d.ts +1 -1
- package/dist/node/generated-version.js +1 -1
- package/dist/node/helia/helia-for-pkc.js +88 -22
- package/dist/node/helia/helia-for-pkc.js.map +1 -1
- package/dist/node/helia/types.d.ts +4 -1
- package/dist/node/pages/page-size.d.ts +2 -0
- package/dist/node/pages/page-size.js +11 -0
- package/dist/node/pages/page-size.js.map +1 -0
- package/dist/node/pages/pages-client-manager.js +2 -1
- package/dist/node/pages/pages-client-manager.js.map +1 -1
- package/dist/node/pages/util.js +3 -2
- package/dist/node/pages/util.js.map +1 -1
- package/dist/node/publications/comment/comment-client-manager.d.ts +5 -2
- package/dist/node/publications/comment/comment-client-manager.js +104 -40
- package/dist/node/publications/comment/comment-client-manager.js.map +1 -1
- package/dist/node/publications/comment/comment.d.ts +4 -0
- package/dist/node/publications/comment/comment.js +4 -0
- package/dist/node/publications/comment/comment.js.map +1 -1
- package/dist/node/runtime/node/community/page-generator.js +8 -7
- package/dist/node/runtime/node/community/page-generator.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { i as __toESM, r as __require, t as __commonJSMin } from "./chunk-2rV9d50f.js";
|
|
2
|
-
import { $ as retryKuboIpfsAddAndProvide, $n as CommentEditReservedFields, An as VoteTablesRowSchema, At as ChallengeAnswerMessageSchema, Bt as DecryptedChallengeRequestSchema, C as hideClassPrivateProps, Ct as trackUpdatingCommunity, Dn as VotePubsubMessagePublicationSchema, Dt as require_sha256, Et as untrackUpdatingCommunity, F as isLinkOfVideo, G as removeMfsFilesSafely, I as isLinkValid, It as ChallengeVerificationMessageSchema, Jt as version_default, Lr as PKCError, M as isLinkOfAudio, Mt as ChallengeMessageSchema, N as isLinkOfImage, Nn as CommentIpfsSchema, On as VotePubsubReservedFields, Or as t$4, P as isLinkOfMedia, Pn as CommentPubsubMessageReservedFields, Pt as ChallengeRequestMessageSchema, Qn as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema, Rr as messages, Sr as e, T as ipnsNameToIpnsOverPubsubTopic, Tr as t$3, Un as CommentUpdateTableRowSchema, Vn as CommentUpdateSchema, W as removeBlocksFromKuboNode, Wn as CommentsTableRowSchema, Xt as CommunityEditPublicationPubsubReservedFields, Z as retryKuboBlockPutPinAndProvidePubsubTopic, Zn as CommentEditPubsubMessagePublicationSchema, _ as genToArray, _r as t$7, at as timestamp, b as getIpnsRecordInLocalKuboNode, br as t$6, bt as syncCommunityRegistryEntry, c as contentContainsMarkdownImages, ct as withSortedKeysDeep, dt as findStartedCommunity, f as derivePublicationFromChallengeRequest, g as findMalformedUnicodeString, gr as n$3, i as calculateStringSizeSameAsIpfsAddCidV0, in as CommentModerationsTableRowSchema, j as isLinkOfAnimatedImage, jr as require_retry, kr as t$2, kt as pTimeout, l as contentContainsMarkdownVideos, lt as writeKuboFilesWithTimeout, mn as CommunitySignedPropertyNames, nn as CommentModerationReservedFields, nt as sleepUntilTimeoutOrAbort, o as calculateUnixFsDagSizeCidV0, or as AuthorReservedFields, p as doesDomainAddressHaveCapitalLetter, pn as CommunityIpfsSchema, pt as findUpdatingCommunity, q as removeNullUndefinedValues, r as calculateIpfsCidV0, rt as statMfsPathSafely, s as contentContainsMarkdownAudio, st as withSortedKeys, t as areEquivalentCommunityAddresses, ti as ZodError, tn as CommentModerationPubsubMessagePublicationSchema, tr as CommentEditsTableRowSchema, ut as findCommunityInRegistry, v as getEquivalentCommunityAddresses, vr as n$2, wn as isStringDomain, wr as r$1, wt as untrackStartedCommunity, xr as e$1, xt as trackStartedCommunity, y as getErrorCodeFromMessage, yr as t$5, z as pubsubTopicToDhtKey, zr as logger_default, zt as DecryptedChallengeRequestPublicationSchema } from "./util-
|
|
3
|
-
import { $
|
|
4
|
-
import { a as scorePageCommentsWithFile, i as partitionPageCommentsForSort, n as filterRepliesForPageSort, o as stripRepliesFromPageComment, r as orderPageCommentsByScore, t as createDescendantsLookup } from "./page-sort-scoring-
|
|
2
|
+
import { $ as retryKuboIpfsAddAndProvide, $n as CommentEditReservedFields, An as VoteTablesRowSchema, At as ChallengeAnswerMessageSchema, Bt as DecryptedChallengeRequestSchema, C as hideClassPrivateProps, Ct as trackUpdatingCommunity, Dn as VotePubsubMessagePublicationSchema, Dt as require_sha256, Et as untrackUpdatingCommunity, F as isLinkOfVideo, G as removeMfsFilesSafely, I as isLinkValid, It as ChallengeVerificationMessageSchema, Jt as version_default, Lr as PKCError, M as isLinkOfAudio, Mt as ChallengeMessageSchema, N as isLinkOfImage, Nn as CommentIpfsSchema, On as VotePubsubReservedFields, Or as t$4, P as isLinkOfMedia, Pn as CommentPubsubMessageReservedFields, Pt as ChallengeRequestMessageSchema, Qn as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema, Rr as messages, Sr as e, T as ipnsNameToIpnsOverPubsubTopic, Tr as t$3, Un as CommentUpdateTableRowSchema, Vn as CommentUpdateSchema, W as removeBlocksFromKuboNode, Wn as CommentsTableRowSchema, Xt as CommunityEditPublicationPubsubReservedFields, Z as retryKuboBlockPutPinAndProvidePubsubTopic, Zn as CommentEditPubsubMessagePublicationSchema, _ as genToArray, _r as t$7, at as timestamp, b as getIpnsRecordInLocalKuboNode, br as t$6, bt as syncCommunityRegistryEntry, c as contentContainsMarkdownImages, ct as withSortedKeysDeep, dt as findStartedCommunity, f as derivePublicationFromChallengeRequest, g as findMalformedUnicodeString, gr as n$3, i as calculateStringSizeSameAsIpfsAddCidV0, in as CommentModerationsTableRowSchema, j as isLinkOfAnimatedImage, jr as require_retry, kr as t$2, kt as pTimeout, l as contentContainsMarkdownVideos, lt as writeKuboFilesWithTimeout, mn as CommunitySignedPropertyNames, nn as CommentModerationReservedFields, nt as sleepUntilTimeoutOrAbort, o as calculateUnixFsDagSizeCidV0, or as AuthorReservedFields, p as doesDomainAddressHaveCapitalLetter, pn as CommunityIpfsSchema, pt as findUpdatingCommunity, q as removeNullUndefinedValues, r as calculateIpfsCidV0, rt as statMfsPathSafely, s as contentContainsMarkdownAudio, st as withSortedKeys, t as areEquivalentCommunityAddresses, ti as ZodError, tn as CommentModerationPubsubMessagePublicationSchema, tr as CommentEditsTableRowSchema, ut as findCommunityInRegistry, v as getEquivalentCommunityAddresses, vr as n$2, wn as isStringDomain, wr as r$1, wt as untrackStartedCommunity, xr as e$1, xt as trackStartedCommunity, y as getErrorCodeFromMessage, yr as t$5, z as pubsubTopicToDhtKey, zr as logger_default, zt as DecryptedChallengeRequestPublicationSchema } from "./util-LwSS90AE.js";
|
|
3
|
+
import { $ as createSchemaRowParser, Ar as t$10, Cn as signCommentUpdate, Dr as resolveDbPostsCidRefs, Dt as parseJsonWithPKCErrorIfFails, Er as refreshCommunitiesList, Fn as verifyCommentModeration, Fr as n$4, Gn as getAuthorNameFromWire, Hn as buildRuntimeAuthor, In as verifyCommentPubsubMessage, Ln as verifyCommentUpdate, Lr as t$9, Mr as r$2, N as MAX_PAGE_SIZE_BYTES, Nn as verifyCommentEdit, Nr as t$8, Pn as verifyCommentIpfs, Pr as n$5, Q as collectSchemaRowCoercions, Rn as verifyCommunity, Rr as stringify, S as MAX_FILE_SIZE_BYTES_FOR_COMMUNITY_IPFS, Sr as importSignerIntoKuboNode, Tn as signCommunity, Tr as moveCommunityDbToDeletedDirectory, Un as cleanWireAuthor, Ur as STORAGE_KEYS, Vn as verifyVote, W as pLimit, Wr as require_lodash_merge, X as coerceSchemaRowBoolean, Xn as crosspostChainDepthUpTo, Z as coerceSchemaRowJson, Zn as effectiveMaxCrosspostDepth, _ as createAuthorIdentityMatcher, _n as signChallengeMessage, _r as deriveDbPosts, a as generatePagesReportingFailedSorts, b as KeyvBetterSqlite3, bn as signComment, c as resolvePageSortsOrThrow, cr as getPKCAddressFromPublicKeySync, d as getChallengeVerification, dn as decryptEd25519AesGcmPublicKeyBuffer, dr as backupCommunityDb, dt as parseCommunityEditOptionsSchemaWithPKCErrorIfItFails, er as getCommunityNameFromWire, f as getCommunityChallengeFromCommunityChallengeSettings, fr as calculateExpectedSignatureSize, g as authorNameResolveFailureReason, gr as deriveCommentIpfsFromCommentTableRow, h as authorIdentityMatcherForRequest, hn as cleanUpBeforePublishing, hr as deleteOldCommunityInWindows, i as derivePublicPageSorts, ir as encode, j as iterateOverPageCidsToFindAllCids, jn as verifyChallengeRequest, jr as t$11, kn as verifyChallengeAnswer, lr as getPublicKeyFromPrivateKey, m as pkcJsChallenges, mn as _validateSignatureOfPKCRecord, o as loadPageSortsForStartedCommunity, or as getIpfsKeyFromPrivateKey, p as loadChallengeFileFromCommunityChallengeSettings, pn as encryptEd25519AesGcmPublicKeyBuffer, pr as calculateInlineRepliesBudget, pt as parseCommunityIpfsSchemaPassthroughWithPKCErrorIfItFails, r as computePageSortsFingerprint, rr as decode, s as lookupPageSortFactories, sn as SignerWithPublicKeyAddress, sr as getPKCAddressFromPublicKey, t as RpcLocalCommunity, tr as getCommunityPublicKeyFromWire, u as deriveCommunityChallengesOrThrow, ur as BackupAbortError, v as TrackedInstanceRegistry, vr as deriveDbReplies, w as TIMEFRAMES_TO_SECONDS, wn as signCommentUpdateForChallengeVerification, wt as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, xn as signCommentEdit, xr as getThumbnailPropsOfLink, y as LRUCache, yn as signChallengeVerification, yr as getDefaultCommunityDbConfig, zn as verifyCommunityEdit } from "./rpc-local-community-SmLDPm1j.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-2FkqYYNf.js";
|
|
5
5
|
import { randomFillSync, randomUUID } from "node:crypto";
|
|
6
6
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
7
|
-
import
|
|
7
|
+
import path from "node:path";
|
|
8
8
|
import os from "os";
|
|
9
9
|
import { existsSync, promises } from "node:fs";
|
|
10
|
-
import path from "path";
|
|
10
|
+
import path$1 from "path";
|
|
11
11
|
import assert from "assert";
|
|
12
12
|
import { Buffer as Buffer$1 } from "buffer";
|
|
13
13
|
import fs from "fs";
|
|
@@ -1692,15 +1692,15 @@ async function throwIfChallengeSettingsAreInvalid({ challengeSettings, pkc, comm
|
|
|
1692
1692
|
const processStartedCommunities = new TrackedInstanceRegistry();
|
|
1693
1693
|
function normalizeRegistryDataPath(dataPath) {
|
|
1694
1694
|
if (dataPath === void 0) return void 0;
|
|
1695
|
-
const resolved = path.resolve(dataPath);
|
|
1695
|
+
const resolved = path$1.resolve(dataPath);
|
|
1696
1696
|
let existing = resolved;
|
|
1697
1697
|
let tail = "";
|
|
1698
1698
|
while (true) try {
|
|
1699
|
-
return path.join(fs.realpathSync.native(existing), tail);
|
|
1699
|
+
return path$1.join(fs.realpathSync.native(existing), tail);
|
|
1700
1700
|
} catch {
|
|
1701
|
-
const parent = path.dirname(existing);
|
|
1701
|
+
const parent = path$1.dirname(existing);
|
|
1702
1702
|
if (parent === existing) return resolved;
|
|
1703
|
-
tail = path.join(path.basename(existing), tail);
|
|
1703
|
+
tail = path$1.join(path$1.basename(existing), tail);
|
|
1704
1704
|
existing = parent;
|
|
1705
1705
|
}
|
|
1706
1706
|
}
|
|
@@ -1872,7 +1872,6 @@ var PageGenerator = class {
|
|
|
1872
1872
|
const ipfsClient = this._community._clientsManager.getDefaultKuboRpcClient();
|
|
1873
1873
|
const listOfPage = new Array(chunks.length);
|
|
1874
1874
|
const cids = new Array(chunks.length);
|
|
1875
|
-
let expectedSize = MB * Math.pow(2, chunks.length - 1);
|
|
1876
1875
|
for (let i = chunks.length - 1; i >= 0; i--) {
|
|
1877
1876
|
const modQueuePageIpfs = {
|
|
1878
1877
|
nextCid: cids[i + 1],
|
|
@@ -1887,6 +1886,7 @@ var PageGenerator = class {
|
|
|
1887
1886
|
provideOptions: { recursive: true },
|
|
1888
1887
|
provideInBackground: true
|
|
1889
1888
|
});
|
|
1889
|
+
const expectedSize = Math.min(MB * Math.pow(2, i), MAX_PAGE_SIZE_BYTES);
|
|
1890
1890
|
if (addRes.size > expectedSize) throw new PKCError("ERR_PAGE_GENERATED_IS_OVER_EXPECTED_SIZE", {
|
|
1891
1891
|
addRes,
|
|
1892
1892
|
pageIpfs: modQueuePageIpfs,
|
|
@@ -1896,7 +1896,6 @@ var PageGenerator = class {
|
|
|
1896
1896
|
});
|
|
1897
1897
|
cids[i] = addRes.path;
|
|
1898
1898
|
listOfPage[i] = modQueuePageIpfs;
|
|
1899
|
-
expectedSize = expectedSize / 2;
|
|
1900
1899
|
}
|
|
1901
1900
|
return {
|
|
1902
1901
|
pages: listOfPage,
|
|
@@ -1908,7 +1907,7 @@ var PageGenerator = class {
|
|
|
1908
1907
|
const cids = new Array(chunks.length);
|
|
1909
1908
|
for (let pageNum = chunks.length - 1; pageNum >= (embedFirst ? 1 : 0); pageNum--) {
|
|
1910
1909
|
const nextCid = cids[pageNum + 1];
|
|
1911
|
-
const maximumPageSize = MB * Math.pow(2, embedFirst ? Math.max(pageNum - 1, 0) : pageNum);
|
|
1910
|
+
const maximumPageSize = Math.min(MB * Math.pow(2, embedFirst ? Math.max(pageNum - 1, 0) : pageNum), MAX_PAGE_SIZE_BYTES);
|
|
1912
1911
|
const entries = chunks[pageNum];
|
|
1913
1912
|
const entrySizes = entries.map(serialized.sizeOf);
|
|
1914
1913
|
const calculatedSize = pageDagSize(entrySizes, nextCid !== void 0);
|
|
@@ -1972,7 +1971,7 @@ var PageGenerator = class {
|
|
|
1972
1971
|
let currentChunk = [];
|
|
1973
1972
|
let chunkIndex = 0;
|
|
1974
1973
|
let accumulatedSize = OBJECT_WRAPPER_WITH_CID;
|
|
1975
|
-
const getCurrentMaxSize = (index) => index === 0 ? FIRST_PAGE_SIZE : MB * Math.pow(2, index - 1);
|
|
1974
|
+
const getCurrentMaxSize = (index) => index === 0 ? FIRST_PAGE_SIZE : Math.min(MB * Math.pow(2, index - 1), MAX_PAGE_SIZE_BYTES);
|
|
1976
1975
|
for (let i = 0; i < comments.length; i++) {
|
|
1977
1976
|
const commentSize = calculateUnixFsDagSizeCidV0(entryBytes[i]);
|
|
1978
1977
|
const maxSize = getCurrentMaxSize(chunkIndex);
|
|
@@ -3081,9 +3080,9 @@ var DbHandler = class {
|
|
|
3081
3080
|
if (needToMigrate) {
|
|
3082
3081
|
if (dbExistsAlready && currentDbVersion > 0) {
|
|
3083
3082
|
this.destoryConnection();
|
|
3084
|
-
backupDbPath = path.join(path.dirname(dbPath), ".backup_before_migration", `${path.basename(dbPath)}.${currentDbVersion}.${timestamp()}`);
|
|
3085
|
-
log(`Copying db ${path.basename(dbPath)} to ${backupDbPath} before migration`);
|
|
3086
|
-
if (!fs.existsSync(path.dirname(backupDbPath))) await fs.promises.mkdir(path.dirname(backupDbPath), { recursive: true });
|
|
3083
|
+
backupDbPath = path$1.join(path$1.dirname(dbPath), ".backup_before_migration", `${path$1.basename(dbPath)}.${currentDbVersion}.${timestamp()}`);
|
|
3084
|
+
log(`Copying db ${path$1.basename(dbPath)} to ${backupDbPath} before migration`);
|
|
3085
|
+
if (!fs.existsSync(path$1.dirname(backupDbPath))) await fs.promises.mkdir(path$1.dirname(backupDbPath), { recursive: true });
|
|
3087
3086
|
const sourceDb = new Database(dbPath, { fileMustExist: true });
|
|
3088
3087
|
await sourceDb.backup(backupDbPath);
|
|
3089
3088
|
sourceDb.close();
|
|
@@ -5182,10 +5181,10 @@ var DbHandler = class {
|
|
|
5182
5181
|
if (this._db || this._keyv) await this.destoryConnection();
|
|
5183
5182
|
this._transactionDepth = 0;
|
|
5184
5183
|
const dataPath = this._community._pkc.dataPath;
|
|
5185
|
-
const oldPathString = path.join(dataPath, "communities", oldDbName);
|
|
5186
|
-
const newPathString = path.join(dataPath, "communities", newDbName);
|
|
5187
|
-
await fs.promises.mkdir(path.dirname(oldPathString), { recursive: true });
|
|
5188
|
-
await fs.promises.mkdir(path.dirname(newPathString), { recursive: true });
|
|
5184
|
+
const oldPathString = path$1.join(dataPath, "communities", oldDbName);
|
|
5185
|
+
const newPathString = path$1.join(dataPath, "communities", newDbName);
|
|
5186
|
+
await fs.promises.mkdir(path$1.dirname(oldPathString), { recursive: true });
|
|
5187
|
+
await fs.promises.mkdir(path$1.dirname(newPathString), { recursive: true });
|
|
5189
5188
|
try {
|
|
5190
5189
|
if (!fs.existsSync(oldPathString)) log(`Old DB file ${oldPathString} does not exist. Cannot backup/rename.`);
|
|
5191
5190
|
else {
|
|
@@ -5207,8 +5206,8 @@ var DbHandler = class {
|
|
|
5207
5206
|
}
|
|
5208
5207
|
async lockCommunityStart(communityAddress = this._community.address) {
|
|
5209
5208
|
const log = logger_default("pkc-js:local-community:db-handler:lock:start");
|
|
5210
|
-
const lockfilePath = path.join(this._community._pkc.dataPath, "communities", `${communityAddress}.start.lock`);
|
|
5211
|
-
const communityDbPath = path.join(this._community._pkc.dataPath, "communities", communityAddress);
|
|
5209
|
+
const lockfilePath = path$1.join(this._community._pkc.dataPath, "communities", `${communityAddress}.start.lock`);
|
|
5210
|
+
const communityDbPath = path$1.join(this._community._pkc.dataPath, "communities", communityAddress);
|
|
5212
5211
|
try {
|
|
5213
5212
|
await import_src.default.lock(communityDbPath, {
|
|
5214
5213
|
lockfilePath,
|
|
@@ -5229,8 +5228,8 @@ var DbHandler = class {
|
|
|
5229
5228
|
async unlockCommunityStart(communityAddress = this._community.address) {
|
|
5230
5229
|
const log = logger_default("pkc-js:local-community:db-handler:unlock:start");
|
|
5231
5230
|
log.trace(`Attempting to unlock the start of community (${communityAddress})`);
|
|
5232
|
-
const lockfilePath = path.join(this._community._pkc.dataPath, "communities", `${communityAddress}.start.lock`);
|
|
5233
|
-
const communityDbPath = path.join(this._community._pkc.dataPath, "communities", communityAddress);
|
|
5231
|
+
const lockfilePath = path$1.join(this._community._pkc.dataPath, "communities", `${communityAddress}.start.lock`);
|
|
5232
|
+
const communityDbPath = path$1.join(this._community._pkc.dataPath, "communities", communityAddress);
|
|
5234
5233
|
if (!fs.existsSync(lockfilePath) || !fs.existsSync(communityDbPath)) return;
|
|
5235
5234
|
try {
|
|
5236
5235
|
await import_src.default.unlock(communityDbPath, { lockfilePath });
|
|
@@ -5241,8 +5240,8 @@ var DbHandler = class {
|
|
|
5241
5240
|
}
|
|
5242
5241
|
}
|
|
5243
5242
|
async isCommunityStartLocked(communityAddress = this._community.address) {
|
|
5244
|
-
const lockfilePath = path.join(this._community._pkc.dataPath, "communities", `${communityAddress}.start.lock`);
|
|
5245
|
-
const communityDbPath = path.join(this._community._pkc.dataPath, "communities", communityAddress);
|
|
5243
|
+
const lockfilePath = path$1.join(this._community._pkc.dataPath, "communities", `${communityAddress}.start.lock`);
|
|
5244
|
+
const communityDbPath = path$1.join(this._community._pkc.dataPath, "communities", communityAddress);
|
|
5246
5245
|
return await import_src.default.check(communityDbPath, {
|
|
5247
5246
|
lockfilePath,
|
|
5248
5247
|
realpath: false,
|
|
@@ -5251,8 +5250,8 @@ var DbHandler = class {
|
|
|
5251
5250
|
}
|
|
5252
5251
|
async lockCommunityState() {
|
|
5253
5252
|
const log = logger_default("pkc-js:local-community:db-handler:lock:lockCommunityState");
|
|
5254
|
-
const lockfilePath = path.join(this._community._pkc.dataPath, "communities", `${this._community.address}.state.lock`);
|
|
5255
|
-
const communityDbPath = path.join(this._community._pkc.dataPath, "communities", this._community.address);
|
|
5253
|
+
const lockfilePath = path$1.join(this._community._pkc.dataPath, "communities", `${this._community.address}.state.lock`);
|
|
5254
|
+
const communityDbPath = path$1.join(this._community._pkc.dataPath, "communities", this._community.address);
|
|
5256
5255
|
try {
|
|
5257
5256
|
await import_src.default.lock(communityDbPath, {
|
|
5258
5257
|
lockfilePath,
|
|
@@ -5269,8 +5268,8 @@ var DbHandler = class {
|
|
|
5269
5268
|
}
|
|
5270
5269
|
async unlockCommunityState() {
|
|
5271
5270
|
const log = logger_default("pkc-js:local-community:db-handler:lock:unlockCommunityState");
|
|
5272
|
-
const lockfilePath = path.join(this._community._pkc.dataPath, "communities", `${this._community.address}.state.lock`);
|
|
5273
|
-
const communityDbPath = path.join(this._community._pkc.dataPath, "communities", this._community.address);
|
|
5271
|
+
const lockfilePath = path$1.join(this._community._pkc.dataPath, "communities", `${this._community.address}.state.lock`);
|
|
5272
|
+
const communityDbPath = path$1.join(this._community._pkc.dataPath, "communities", this._community.address);
|
|
5274
5273
|
if (!fs.existsSync(lockfilePath)) return;
|
|
5275
5274
|
try {
|
|
5276
5275
|
await import_src.default.unlock(communityDbPath, { lockfilePath });
|
|
@@ -5280,7 +5279,7 @@ var DbHandler = class {
|
|
|
5280
5279
|
}
|
|
5281
5280
|
}
|
|
5282
5281
|
communityDbExists() {
|
|
5283
|
-
const communityDbPath = path.join(this._community._pkc.dataPath, "communities", this._community.address);
|
|
5282
|
+
const communityDbPath = path$1.join(this._community._pkc.dataPath, "communities", this._community.address);
|
|
5284
5283
|
return fs.existsSync(communityDbPath);
|
|
5285
5284
|
}
|
|
5286
5285
|
markCommentsAsPublishedToPostUpdates(commentCids) {
|
|
@@ -8361,11 +8360,11 @@ async function edit(community, newCommunityOptions) {
|
|
|
8361
8360
|
const EXPORTS_KEY = STORAGE_KEYS[STORAGE_KEYS.EXPORTS];
|
|
8362
8361
|
function defaultExportPathFor(community, exportId) {
|
|
8363
8362
|
if (typeof community._pkc.dataPath !== "string") throw new PKCError("ERR_DATA_PATH_IS_NOT_DEFINED", { communityAddress: community.address });
|
|
8364
|
-
return
|
|
8363
|
+
return path.join(community._pkc.dataPath, "exports", `${exportId}.sqlite`);
|
|
8365
8364
|
}
|
|
8366
8365
|
function sourceDbPathFor(community) {
|
|
8367
8366
|
if (typeof community._pkc.dataPath !== "string") throw new PKCError("ERR_DATA_PATH_IS_NOT_DEFINED", { communityAddress: community.address });
|
|
8368
|
-
return
|
|
8367
|
+
return path.join(community._pkc.dataPath, "communities", community.address);
|
|
8369
8368
|
}
|
|
8370
8369
|
async function persistExports(community) {
|
|
8371
8370
|
if (!community._dbHandler) return;
|
|
@@ -8441,9 +8440,9 @@ async function runExportTask(community, exportId, opts) {
|
|
|
8441
8440
|
async function exportCommunityEmbedded(community, options = {}) {
|
|
8442
8441
|
if (options.signal?.aborted) throw options.signal.reason ?? new DOMException("The operation was aborted.", "AbortError");
|
|
8443
8442
|
const exportId = v4();
|
|
8444
|
-
const destPath = options.exportPath ?
|
|
8443
|
+
const destPath = options.exportPath ? path.resolve(options.exportPath) : defaultExportPathFor(community, exportId);
|
|
8445
8444
|
const includePrivateKey = options.includePrivateKey === true;
|
|
8446
|
-
if (
|
|
8445
|
+
if (path.resolve(destPath) === path.resolve(sourceDbPathFor(community))) throw new PKCError("ERR_EXPORT_PATH_TARGETS_LIVE_DB", {
|
|
8447
8446
|
communityAddress: community.address,
|
|
8448
8447
|
exportPath: destPath
|
|
8449
8448
|
});
|
|
@@ -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-B79BAYRo.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 retryKuboIpfsAddAndProvide, At as ChallengeAnswerMessageSchema, C as hideClassPrivateProps, D as isIpfsCid, Dt as require_sha256, E as isAbortError, Et as untrackUpdatingCommunity, H as rejectWhenAbortSignalFires, Hr as setErrorMap, It as ChallengeVerificationMessageSchema, J as removeUndefinedValuesRecursively, Jt as version_default, Lr as PKCError, Mr as FailedToFetchCommentIpfsFromGatewaysError, Mt as ChallengeMessageSchema, Nn as CommentIpfsSchema, Nr as FailedToFetchCommentUpdateFromGatewaysError, Ot as TimeoutError, Pt as ChallengeRequestMessageSchema, Q as retryKuboIpfsAdd, Rn as CommentUpdateForChallengeVerificationSchema, Rr as messages, Sr as e$1, St as trackUpdatingComment, T as ipnsNameToIpnsOverPubsubTopic, Tt as untrackUpdatingComment, U as rejectWhenCommunityStopsOrAborts, Vn as CommentUpdateSchema, X as resolveWhenPredicateIsTrue, Y as replaceXWithY, _t as listUpdatingCommunities, a as calculateStringSizeSameAsIpfsAddCidV0Sync, at as timestamp, br as t$1, cn as CommunityAnchorSchema, d as deepMergeRuntimeFields, dt as findStartedCommunity, et as shortifyAddress, ft as findUpdatingComment, gr as n$2, gt as listUpdatingComments, ht as listStartedCommunities, i as calculateStringSizeSameAsIpfsAddCidV0, it as throwIfAbortSignalAborted, jr as require_retry, k as isIpns, kt as pTimeout, ni as en_default, nt as sleepUntilTimeoutOrAbort, ot as waitForUpdateInCommunityInstanceWithErrorAndTimeout, p as doesDomainAddressHaveCapitalLetter, pn as CommunityIpfsSchema, pt as findUpdatingCommunity, r as calculateIpfsCidV0, t as areEquivalentCommunityAddresses, tt as shortifyCid, u as createAbortError, vr as n$1, vt as refreshTrackedCommentAliases, wn as isStringDomain, wr as r, x as getPostUpdateTimestampRange, xn as PubsubTopicSchema, xr as e, zr as logger_default } from "./util-
|
|
3
|
-
import { $ as
|
|
4
|
-
import { s as getHeliaDebugContext } from "./util-
|
|
2
|
+
import { $ as retryKuboIpfsAddAndProvide, At as ChallengeAnswerMessageSchema, C as hideClassPrivateProps, D as isIpfsCid, Dt as require_sha256, E as isAbortError, Et as untrackUpdatingCommunity, H as rejectWhenAbortSignalFires, Hr as setErrorMap, It as ChallengeVerificationMessageSchema, J as removeUndefinedValuesRecursively, Jt as version_default, Lr as PKCError, Mr as FailedToFetchCommentIpfsFromGatewaysError, Mt as ChallengeMessageSchema, Nn as CommentIpfsSchema, Nr as FailedToFetchCommentUpdateFromGatewaysError, Ot as TimeoutError, Pt as ChallengeRequestMessageSchema, Q as retryKuboIpfsAdd, Rn as CommentUpdateForChallengeVerificationSchema, Rr as messages, Sr as e$1, St as trackUpdatingComment, T as ipnsNameToIpnsOverPubsubTopic, Tt as untrackUpdatingComment, U as rejectWhenCommunityStopsOrAborts, Vn as CommentUpdateSchema, X as resolveWhenPredicateIsTrue, Y as replaceXWithY, _t as listUpdatingCommunities, a as calculateStringSizeSameAsIpfsAddCidV0Sync, at as timestamp, br as t$1, cn as CommunityAnchorSchema, d as deepMergeRuntimeFields, dt as findStartedCommunity, et as shortifyAddress, ft as findUpdatingComment, gr as n$2, gt as listUpdatingComments, ht as listStartedCommunities, i as calculateStringSizeSameAsIpfsAddCidV0, it as throwIfAbortSignalAborted, jr as require_retry, k as isIpns, kt as pTimeout, ni as en_default, nt as sleepUntilTimeoutOrAbort, ot as waitForUpdateInCommunityInstanceWithErrorAndTimeout, p as doesDomainAddressHaveCapitalLetter, pn as CommunityIpfsSchema, pt as findUpdatingCommunity, r as calculateIpfsCidV0, t as areEquivalentCommunityAddresses, tt as shortifyCid, u as createAbortError, vr as n$1, vt as refreshTrackedCommentAliases, wn as isStringDomain, wr as r, x as getPostUpdateTimestampRange, xn as PubsubTopicSchema, xr as e, zr as logger_default } from "./util-LwSS90AE.js";
|
|
3
|
+
import { $n as getCommunityAddressFromRecord, $t as RpcPublishCommunityListResultSchema, A as findCommentInParsedPages, An as verifyChallengeMessage, Ar as t$5, At as parseRpcCommentUpdateEventWithPKCErrorIfItFails, B as GenericStateClient, Bn as verifyCommunityList, Br as NAME_RESOLVED_FALSE_TTL_MS, Bt as RpcCommunityPageParamSchema, C as RepliesPages, Cr as listCommunitiesSync, Ct as parseCreateVoteOptionsSchemaWithPKCErrorIfItFails, D as extractCommunityRuntimeFieldsFromParsedPages, Dn as signCommunityList, Dt as parseJsonWithPKCErrorIfFails, En as signCommunityEdit, Et as parseDecryptedChallengeWithPKCErrorIfItFails, F as cloneCrosspostForRuntime, Fn as verifyCommentModeration, Ft as RpcAuthorNameParamSchema, G as PKCTypedEmitter, Gn as getAuthorNameFromWire, Gr as nativeFunctions$2, Gt as RpcExportCommunityResultSchema, H as InflightResourceTypes, Hn as buildRuntimeAuthor, Hr as NAME_RESOLVE_FAILED_RETRY_FLOOR_MS, Ht as RpcExportCommunityModLogsParamSchema, I as collectCrosspostAuthorsToResolve, In as verifyCommentPubsubMessage, Ir as t$2, It as RpcCancelExportParamSchema, J as decodeRpcChallengeRequestPubsubMsg, Jn as CreateNewCommunityListOptionsSchema, Jt as RpcFetchCommunityListParamSchema, K as decodeRpcChallengeAnswerPubsubMsg, Kn as normalizeCreatePublicationAuthor, Kr as require_undici, Kt as RpcFetchCidParamSchema, Ln as verifyCommentUpdate, Lr as t$4, Lt as RpcCidParamSchema, M as parseRawPages, Mn as verifyChallengeVerification, Nn as verifyCommentEdit, Nr as t$3, Nt as parseVotePubsubMessagePublicationSchemaWithPKCErrorIfItFails, O as findCommentInPageInstance, On as signVote, Or as setNativeFunctions$1, Ot as parsePKCUserOptionsSchemaWithPKCErrorIfItFails, P as applyNameResolvedCacheToCrosspost, Pn as verifyCommentIpfs, Pr as n$3, Pt as RpcAnchorPublishPreparationResultSchema, Qn as buildRuntimeCommunityFields, Qt as RpcPublishCommunityListParamSchema, R as stripNameResolvedFromCrosspost, Rt as RpcCommentRepliesPageParamSchema, Sn as signCommentModeration, St as parseCreateRpcCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, Tt as parseDecryptedChallengeVerification, Un as cleanWireAuthor, Ut as RpcExportCommunityModLogsResultSchema, V as InflightFetchManager, Vn as verifyVote, Vr as NAME_RESOLVED_TRUE_TTL_MS, Vt as RpcEditCommunityParamSchema, Wn as getAuthorNameFromRuntime, Wt as RpcExportCommunityParamSchema, Xt as RpcPublishAnchorRecordParamSchema, Y as decodeRpcChallengeVerificationPubsubMsg, Yn as MAX_COMMUNITY_LIST_SIZE_BYTES, Yt as RpcFetchCommunityListResultSchema, Zt as RpcPublishChallengeAnswersParamSchema, _t as parseCreateCommentOptionsSchemaWithPKCErrorIfItFails, an as findCommunityRecordNameMismatch, ar as getBufferedPKCAddressFromPublicKey, b as KeyvBetterSqlite3, bn as signComment, br as getDefaultDataPath, cn as createSigner, cr as getPKCAddressFromPublicKeySync, ct as parseCommentUpdateSchemaWithPKCErrorIfItFails, en as RpcPublishedAnchorRecordResultSchema, er as getCommunityNameFromWire, et as parseCidStringSchemaWithPKCErrorIfItFails, fn as encryptEd25519AesGcm, ft as parseCommunityEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, gn as signChallengeAnswer, gt as parseCreateCommentModerationOptionsSchemaWithPKCErrorIfItFails, hn as cleanUpBeforePublishing, ht as parseCreateCommentEditOptionsSchemaWithPKCErrorIfItFails, in as RpcUnsubscribeParamSchema, it as parseCommentIpfsSchemaWithPKCErrorIfItFails, jt as parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, k as findCommentInPageInstanceRecursively, kr as tryToDeleteCommunitiesThatFailedToBeDeletedBefore, kt as parseRpcCommentEventWithPKCErrorIfItFails, l as pkcJsPageSorts, ln as createAnchorIpnsRecord$1, lt as parseCommunityAddressWithPKCErrorIfItFails, m as pkcJsChallenges, mr as createKuboRpcClient, mt as parseCommunityListSchemaWithPKCErrorIfItFails, n as RpcRemoteCommunity, nn as RpcSubscriptionIdResultSchema, nr as normalizeCommunityInputFromCommunity, on as require_lib$1, ot as parseCommentModerationPubsubMessagePublicationSchemaWithPKCErrorIfItFails, q as decodeRpcChallengePubsubMsg, qn as CreateCommunityListWithCidOptionsSchema, qt as RpcFetchCidResultSchema, rn as RpcSuccessResultSchema, rr as decode, rt as parseCommentEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, st as parseCommentPubsubMessagePublicationWithPKCErrorIfItFails, t as RpcLocalCommunity, tn as RpcResolveAuthorNameResultSchema, tr as getCommunityPublicKeyFromWire, un as decryptEd25519AesGcm, v as TrackedInstanceRegistry, vn as signChallengeRequest, vt as parseCreateCommunityEditPublicationOptionsSchemaWithPKCErrorIfItFails, wr as monitorCommunitiesDirectory, wt as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, x as RemoteCommunity, xn as signCommentEdit, xt as parseCreateRemoteCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, y as LRUCache, z as PKCClientsManager, zn as verifyCommunityEdit, zr as MAX_FILE_SIZE_BYTES_FOR_COMMENT_UPDATE, zt as RpcCommunityIdentifierParamSchema } from "./rpc-local-community-SmLDPm1j.js";
|
|
4
|
+
import { s as getHeliaDebugContext } from "./util-jyIDYw_Q.js";
|
|
5
5
|
import path from "path";
|
|
6
6
|
import assert from "assert";
|
|
7
7
|
import fs from "fs";
|
|
@@ -1560,24 +1560,78 @@ var CommentClientsManager = class extends PublicationClientsManager {
|
|
|
1560
1560
|
if ("_helia" in kuboRpcOrHelia) this.updateLibp2pJsClientState(newState, kuboRpcOrHelia._libp2pJsClientsOptions.key);
|
|
1561
1561
|
else this.updateKuboRpcState(newState, kuboRpcOrHelia.url);
|
|
1562
1562
|
}
|
|
1563
|
-
async
|
|
1563
|
+
async _isPostUpdateFileAlreadyJudged(folderCid, path, log, abortSignal) {
|
|
1564
|
+
const judged = this._comment._lastJudgedPostUpdate;
|
|
1565
|
+
if (judged?.path === path) return {
|
|
1566
|
+
alreadyJudged: true,
|
|
1567
|
+
cid: judged.cid
|
|
1568
|
+
};
|
|
1569
|
+
const cid = await this._resolveIpfsPathToCid({
|
|
1570
|
+
root: folderCid,
|
|
1571
|
+
path: path.slice(folderCid.length + 1),
|
|
1572
|
+
timeoutMs: this._pkc._timeouts["comment-update-ipfs"],
|
|
1573
|
+
abortSignal,
|
|
1574
|
+
log,
|
|
1575
|
+
bitswapSessionSeedScopeIpnsPubsubTopic: this._bitswapSessionSeedScopeIpnsPubsubTopic()
|
|
1576
|
+
});
|
|
1577
|
+
if (cid === void 0 || cid !== judged?.cid) return {
|
|
1578
|
+
alreadyJudged: false,
|
|
1579
|
+
cid
|
|
1580
|
+
};
|
|
1581
|
+
this._comment._lastJudgedPostUpdate = {
|
|
1582
|
+
path,
|
|
1583
|
+
cid
|
|
1584
|
+
};
|
|
1585
|
+
return {
|
|
1586
|
+
alreadyJudged: true,
|
|
1587
|
+
cid
|
|
1588
|
+
};
|
|
1589
|
+
}
|
|
1590
|
+
_markRecordPostUpdateJudgedIfItsPagesHoldTheHeldUpdate(community) {
|
|
1591
|
+
const record = community.raw.communityIpfs;
|
|
1592
|
+
const postCid = this._comment.postCid;
|
|
1593
|
+
const heldUpdatedAt = this._comment.raw?.commentUpdate?.updatedAt;
|
|
1594
|
+
if (!record?.postUpdates || !postCid || !this._comment.cid || typeof this._comment.timestamp !== "number") return false;
|
|
1595
|
+
const inRecordPages = findCommentInPageInstance(community.posts, this._comment.cid);
|
|
1596
|
+
if (!inRecordPages || inRecordPages.commentUpdate.updatedAt !== heldUpdatedAt) return false;
|
|
1597
|
+
const [timestampRange] = getPostUpdateTimestampRange(record.postUpdates, this._comment.timestamp);
|
|
1598
|
+
if (!timestampRange) return false;
|
|
1599
|
+
const path = this._calculatePathForPostCommentUpdate(record.postUpdates[timestampRange], postCid);
|
|
1600
|
+
if (this._comment._lastJudgedPostUpdate?.path !== path) this._comment._lastJudgedPostUpdate = {
|
|
1601
|
+
path,
|
|
1602
|
+
cid: void 0
|
|
1603
|
+
};
|
|
1604
|
+
return true;
|
|
1605
|
+
}
|
|
1606
|
+
_isNotNewerThanHeldCommentUpdate(commentUpdate) {
|
|
1607
|
+
return commentUpdate.updatedAt <= (this._comment.raw?.commentUpdate?.updatedAt || 0);
|
|
1608
|
+
}
|
|
1609
|
+
async _fetchPostCommentUpdateIpfsP2P(subIpns, timestampRanges, log, abortSignal) {
|
|
1564
1610
|
const attemptedPathsToLoadErrors = {};
|
|
1565
1611
|
const kuboRpcOrHelia = this.getDefaultKuboRpcClientOrHelia();
|
|
1566
|
-
if (timestampRanges.some((timestampRange) => {
|
|
1567
|
-
if (!this._comment._commentUpdateIpfsPath) return false;
|
|
1568
|
-
return subIpns.postUpdates[timestampRange] === this._comment._commentUpdateIpfsPath.split("/")[0];
|
|
1569
|
-
})) {
|
|
1570
|
-
log("Comment", this._comment.cid, "last post update range has same folder cid", this._comment._commentUpdateIpfsPath, "will be skipping loading CommentUpdate");
|
|
1571
|
-
return;
|
|
1572
|
-
}
|
|
1573
|
-
this._comment._setUpdatingStateWithEmissionIfNewState("fetching-update-ipfs");
|
|
1574
1612
|
for (const timestampRange of timestampRanges) {
|
|
1575
1613
|
const folderCid = subIpns.postUpdates[timestampRange];
|
|
1576
1614
|
const path = this._calculatePathForPostCommentUpdate(folderCid, this._comment.postCid);
|
|
1615
|
+
throwIfAbortSignalAborted(abortSignal);
|
|
1616
|
+
let judgedLookup;
|
|
1617
|
+
try {
|
|
1618
|
+
judgedLookup = await this._isPostUpdateFileAlreadyJudged(folderCid, path, log, abortSignal);
|
|
1619
|
+
} catch (e) {
|
|
1620
|
+
throwIfAbortSignalAborted(abortSignal);
|
|
1621
|
+
log.trace(`Timed out resolving CommentUpdate path (${path}) with IPFS P2P. Trying the next timestamp range`);
|
|
1622
|
+
attemptedPathsToLoadErrors[path] = e;
|
|
1623
|
+
continue;
|
|
1624
|
+
}
|
|
1625
|
+
const { alreadyJudged, cid } = judgedLookup;
|
|
1626
|
+
throwIfAbortSignalAborted(abortSignal);
|
|
1627
|
+
if (alreadyJudged) {
|
|
1628
|
+
log.trace("Comment", this._comment.cid, "already judged the CommentUpdate at", path, "skipping it");
|
|
1629
|
+
return;
|
|
1630
|
+
}
|
|
1631
|
+
this._comment._setUpdatingStateWithEmissionIfNewState("fetching-update-ipfs");
|
|
1577
1632
|
this._updateKuboRpcClientOrHeliaState("fetching-update-ipfs", kuboRpcOrHelia);
|
|
1578
1633
|
let res;
|
|
1579
1634
|
const commentUpdateTimeoutMs = this._pkc._timeouts["comment-update-ipfs"];
|
|
1580
|
-
const abortSignal = this._combinedAbortSignalForRetry();
|
|
1581
1635
|
try {
|
|
1582
1636
|
res = await this._retryTransientP2PFetch(() => this._fetchCidP2P(path, {
|
|
1583
1637
|
maxFileSizeBytes: MAX_FILE_SIZE_BYTES_FOR_COMMENT_UPDATE,
|
|
@@ -1590,6 +1644,7 @@ var CommentClientsManager = class extends PublicationClientsManager {
|
|
|
1590
1644
|
context: `post-update ${path}`
|
|
1591
1645
|
});
|
|
1592
1646
|
} catch (e) {
|
|
1647
|
+
throwIfAbortSignalAborted(abortSignal);
|
|
1593
1648
|
log.trace(`Failed to fetch CommentUpdate from path (${path}) with IPFS P2P. Trying the next timestamp range`);
|
|
1594
1649
|
attemptedPathsToLoadErrors[path] = e;
|
|
1595
1650
|
continue;
|
|
@@ -1598,13 +1653,23 @@ var CommentClientsManager = class extends PublicationClientsManager {
|
|
|
1598
1653
|
}
|
|
1599
1654
|
try {
|
|
1600
1655
|
const commentUpdate = parseCommentUpdateSchemaWithPKCErrorIfItFails(parseJsonWithPKCErrorIfFails(res));
|
|
1656
|
+
if (this._isNotNewerThanHeldCommentUpdate(commentUpdate)) {
|
|
1657
|
+
this._comment._lastJudgedPostUpdate = {
|
|
1658
|
+
path,
|
|
1659
|
+
cid
|
|
1660
|
+
};
|
|
1661
|
+
this._logIgnoredNotNewerPostCommentUpdate(log, path, commentUpdate);
|
|
1662
|
+
return;
|
|
1663
|
+
}
|
|
1601
1664
|
await this._throwIfCommentUpdateHasInvalidSignature(commentUpdate, subIpns);
|
|
1602
|
-
|
|
1665
|
+
this._comment._lastJudgedPostUpdate = {
|
|
1666
|
+
path,
|
|
1667
|
+
cid
|
|
1668
|
+
};
|
|
1669
|
+
return {
|
|
1603
1670
|
commentUpdate,
|
|
1604
1671
|
commentUpdateIpfsPath: path
|
|
1605
1672
|
};
|
|
1606
|
-
this._logIgnoredNotNewerPostCommentUpdate(log, path, commentUpdate);
|
|
1607
|
-
return;
|
|
1608
1673
|
} catch (e) {
|
|
1609
1674
|
this._comment._invalidCommentUpdateMfsPaths.add(path);
|
|
1610
1675
|
if (e instanceof PKCError) e.details = {
|
|
@@ -1659,14 +1724,7 @@ var CommentClientsManager = class extends PublicationClientsManager {
|
|
|
1659
1724
|
verifyOptions
|
|
1660
1725
|
});
|
|
1661
1726
|
}
|
|
1662
|
-
async _fetchPostCommentUpdateFromGateways(subIpns, timestampRanges, log) {
|
|
1663
|
-
if (timestampRanges.some((timestampRange) => {
|
|
1664
|
-
if (!this._comment._commentUpdateIpfsPath) return false;
|
|
1665
|
-
return subIpns.postUpdates[timestampRange] === this._comment._commentUpdateIpfsPath.split("/")[0];
|
|
1666
|
-
})) {
|
|
1667
|
-
log("Comment", this._comment.cid, "last post update range has same folder cid", this._comment._commentUpdateIpfsPath, "will be skipping loading CommentUpdate");
|
|
1668
|
-
return;
|
|
1669
|
-
}
|
|
1727
|
+
async _fetchPostCommentUpdateFromGateways(subIpns, timestampRanges, log, abortSignal) {
|
|
1670
1728
|
const attemptedPathsToLoadErrors = {};
|
|
1671
1729
|
let commentUpdate;
|
|
1672
1730
|
const validateCommentFromGateway = async (res) => {
|
|
@@ -1675,10 +1733,17 @@ var CommentClientsManager = class extends PublicationClientsManager {
|
|
|
1675
1733
|
await this._throwIfCommentUpdateHasInvalidSignature(commentUpdateBeforeSignature, subIpns);
|
|
1676
1734
|
commentUpdate = commentUpdateBeforeSignature;
|
|
1677
1735
|
};
|
|
1678
|
-
this._comment._setUpdatingStateWithEmissionIfNewState("fetching-update-ipfs");
|
|
1679
1736
|
for (const timestampRange of timestampRanges) {
|
|
1680
1737
|
const folderCid = subIpns.postUpdates[timestampRange];
|
|
1681
1738
|
const path = this._calculatePathForPostCommentUpdate(folderCid, this._comment.postCid);
|
|
1739
|
+
throwIfAbortSignalAborted(abortSignal);
|
|
1740
|
+
const { alreadyJudged, cid } = await this._isPostUpdateFileAlreadyJudged(folderCid, path, log, abortSignal);
|
|
1741
|
+
throwIfAbortSignalAborted(abortSignal);
|
|
1742
|
+
if (alreadyJudged) {
|
|
1743
|
+
log.trace("Comment", this._comment.cid, "already judged the CommentUpdate at", path, "skipping it");
|
|
1744
|
+
return;
|
|
1745
|
+
}
|
|
1746
|
+
this._comment._setUpdatingStateWithEmissionIfNewState("fetching-update-ipfs");
|
|
1682
1747
|
try {
|
|
1683
1748
|
await this.fetchFromMultipleGateways({
|
|
1684
1749
|
recordIpfsType: "ipfs",
|
|
@@ -1689,16 +1754,21 @@ var CommentClientsManager = class extends PublicationClientsManager {
|
|
|
1689
1754
|
log,
|
|
1690
1755
|
maxFileSizeBytes: MAX_FILE_SIZE_BYTES_FOR_COMMENT_UPDATE,
|
|
1691
1756
|
timeoutMs: this._pkc._timeouts["comment-update-ipfs"],
|
|
1692
|
-
abortSignal
|
|
1757
|
+
abortSignal
|
|
1693
1758
|
});
|
|
1694
1759
|
if (!commentUpdate) throw Error("Failed to load comment update from gateways. This is a critical logic error");
|
|
1695
|
-
|
|
1760
|
+
this._comment._lastJudgedPostUpdate = {
|
|
1761
|
+
path,
|
|
1762
|
+
cid
|
|
1763
|
+
};
|
|
1764
|
+
if (!this._isNotNewerThanHeldCommentUpdate(commentUpdate)) return {
|
|
1696
1765
|
commentUpdate,
|
|
1697
1766
|
commentUpdateIpfsPath: path
|
|
1698
1767
|
};
|
|
1699
1768
|
this._logIgnoredNotNewerPostCommentUpdate(log, path, commentUpdate);
|
|
1700
1769
|
return;
|
|
1701
1770
|
} catch (e) {
|
|
1771
|
+
throwIfAbortSignalAborted(abortSignal);
|
|
1702
1772
|
if (this._shouldWeFetchCommentUpdateFromNextTimestamp(e)) {
|
|
1703
1773
|
attemptedPathsToLoadErrors[path] = e;
|
|
1704
1774
|
log.trace(`Failed to fetch CommentUpdate from path (${path}) from gateways. Trying the next timestamp range`);
|
|
@@ -1742,10 +1812,11 @@ var CommentClientsManager = class extends PublicationClientsManager {
|
|
|
1742
1812
|
if (typeof postTimestamp !== "number") throw Error("Post timestamp is not defined by the time we're fetching from postUpdates");
|
|
1743
1813
|
const timestampRanges = getPostUpdateTimestampRange(subIpfs.postUpdates, postTimestamp);
|
|
1744
1814
|
if (timestampRanges.length === 0) throw Error("Post has no timestamp range bucket");
|
|
1815
|
+
const abortSignal = this._combinedAbortSignalForRetry();
|
|
1745
1816
|
let newCommentUpdate;
|
|
1746
1817
|
try {
|
|
1747
|
-
if (Object.keys(this._pkc.clients.kuboRpcClients).length > 0 || Object.keys(this._pkc.clients.libp2pJsClients).length > 0) newCommentUpdate = await this._fetchPostCommentUpdateIpfsP2P(subIpfs, timestampRanges, log);
|
|
1748
|
-
else newCommentUpdate = await this._fetchPostCommentUpdateFromGateways(subIpfs, timestampRanges, log);
|
|
1818
|
+
if (Object.keys(this._pkc.clients.kuboRpcClients).length > 0 || Object.keys(this._pkc.clients.libp2pJsClients).length > 0) newCommentUpdate = await this._fetchPostCommentUpdateIpfsP2P(subIpfs, timestampRanges, log, abortSignal);
|
|
1819
|
+
else newCommentUpdate = await this._fetchPostCommentUpdateFromGateways(subIpfs, timestampRanges, log, abortSignal);
|
|
1749
1820
|
} catch (e) {
|
|
1750
1821
|
if (e instanceof Error) {
|
|
1751
1822
|
if (isAbortError(e)) return;
|
|
@@ -1773,7 +1844,7 @@ var CommentClientsManager = class extends PublicationClientsManager {
|
|
|
1773
1844
|
}
|
|
1774
1845
|
if (newCommentUpdate) this._useLoadedCommentUpdateIfNewInfo(newCommentUpdate, subIpfs, log);
|
|
1775
1846
|
else if (newCommentUpdate === void 0) {
|
|
1776
|
-
log.trace(`Comment`, this._comment.cid, "
|
|
1847
|
+
log.trace(`Comment`, this._comment.cid, "has no newer CommentUpdate under postUpdates");
|
|
1777
1848
|
this._comment._setUpdatingStateWithEmissionIfNewState("waiting-retry");
|
|
1778
1849
|
}
|
|
1779
1850
|
}
|
|
@@ -1981,6 +2052,10 @@ var CommentClientsManager = class extends PublicationClientsManager {
|
|
|
1981
2052
|
if (postInUpdatingCommunity && postInUpdatingCommunity.commentUpdate.updatedAt > (this._comment.raw?.commentUpdate?.updatedAt || 0)) {
|
|
1982
2053
|
const log = logger_default("pkc-js:comment:update:handleUpdateEventFromCommunity:find-comment-update-in-updating-community-or-comments-pages");
|
|
1983
2054
|
this._useLoadedCommentUpdateIfNewInfo({ commentUpdate: postInUpdatingCommunity.commentUpdate }, community.raw.communityIpfs, log);
|
|
2055
|
+
this._markRecordPostUpdateJudgedIfItsPagesHoldTheHeldUpdate(community);
|
|
2056
|
+
} else if (this._markRecordPostUpdateJudgedIfItsPagesHoldTheHeldUpdate(community)) {
|
|
2057
|
+
log.trace("Comment", this._comment.cid, "is current with the record's pages, nothing to fetch from postUpdates");
|
|
2058
|
+
this._comment._setUpdatingStateWithEmissionIfNewState("waiting-retry");
|
|
1984
2059
|
} else try {
|
|
1985
2060
|
await this.useCommunityPostUpdatesToFetchCommentUpdateForPost(community.raw.communityIpfs);
|
|
1986
2061
|
} catch (e) {
|
|
@@ -2293,6 +2368,7 @@ var Comment = class extends Publication {
|
|
|
2293
2368
|
this.raw = {};
|
|
2294
2369
|
this._commentUpdateIpfsPath = void 0;
|
|
2295
2370
|
this._invalidCommentUpdateMfsPaths = /* @__PURE__ */ new Set();
|
|
2371
|
+
this._lastJudgedPostUpdate = void 0;
|
|
2296
2372
|
this._commentIpfsloadingOperation = void 0;
|
|
2297
2373
|
this._updateRpcSubscriptionId = void 0;
|
|
2298
2374
|
this._stopAbortController = void 0;
|
|
@@ -8669,7 +8745,7 @@ var PKC$1 = class extends PKCTypedEmitter {
|
|
|
8669
8745
|
this.clients.libp2pJsClients = {};
|
|
8670
8746
|
if (!this.libp2pJsClientsOptions) return;
|
|
8671
8747
|
if (!this.httpRoutersOptions) throw Error("httpRoutersOptions is required for libp2pJsClient");
|
|
8672
|
-
const { createLibp2pJsClientOrUseExistingOne } = await import("./helia-for-pkc-
|
|
8748
|
+
const { createLibp2pJsClientOrUseExistingOne } = await import("./helia-for-pkc-6kkeZX1a.js");
|
|
8673
8749
|
for (const clientOptions of this.libp2pJsClientsOptions) {
|
|
8674
8750
|
const heliaNode = await createLibp2pJsClientOrUseExistingOne({
|
|
8675
8751
|
...clientOptions,
|
|
@@ -9033,7 +9109,7 @@ var PKC$1 = class extends PKCTypedEmitter {
|
|
|
9033
9109
|
const log = logger_default("pkc-js:pkc:createLocalCommunity");
|
|
9034
9110
|
log.trace("Received community options to create a local community instance:", options);
|
|
9035
9111
|
if (!this._canCreateNewLocalCommunity()) throw new PKCError("ERR_CAN_NOT_CREATE_A_LOCAL_COMMUNITY", { pkcOptions: this._userPKCOptions });
|
|
9036
|
-
const { LocalCommunity, createNewLocalCommunityDb, updateInstancePropsWithStartedCommunityOrDb } = await import("./local-community-
|
|
9112
|
+
const { LocalCommunity, createNewLocalCommunityDb, updateInstancePropsWithStartedCommunityOrDb } = await import("./local-community-BST1U_f3.js");
|
|
9037
9113
|
const isLocalCommunity = (await listCommunitiesSync(this)).includes(options.address);
|
|
9038
9114
|
const community = new LocalCommunity(this);
|
|
9039
9115
|
if (isLocalCommunity) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { bn as PageSortFileSchema, v as getEquivalentCommunityAddresses, wn as isStringDomain } from "./util-
|
|
1
|
+
import { bn as PageSortFileSchema, v as getEquivalentCommunityAddresses, wn as isStringDomain } from "./util-LwSS90AE.js";
|
|
2
2
|
//#region dist/node/pages/page-sort-scoring.js
|
|
3
3
|
function validatePageSortFile(rawFile) {
|
|
4
4
|
const validated = PageSortFileSchema.parse(rawFile);
|