@pkcprotocol/pkc-js 0.0.147 → 0.0.149
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/generated-version.d.ts +1 -1
- package/dist/browser/generated-version.js +1 -1
- package/dist/browser/runtime/node/community/challenges/exclude/exclude.js +1 -1
- package/dist/browser/runtime/node/community/challenges/exclude/exclude.js.map +1 -1
- package/dist/browser/runtime/node/community/challenges/exclude/rate-limiter.d.ts +2 -2
- package/dist/browser/runtime/node/community/challenges/exclude/rate-limiter.js +21 -17
- package/dist/browser/runtime/node/community/challenges/exclude/rate-limiter.js.map +1 -1
- package/dist/browser/runtime/node/community/challenges/index.js +1 -1
- package/dist/browser/runtime/node/community/challenges/index.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/challenges.js +21 -11
- package/dist/browser/runtime/node/community/local-community/challenges.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/ipns-publishing.d.ts +7 -1
- package/dist/browser/runtime/node/community/local-community/ipns-publishing.js +49 -36
- package/dist/browser/runtime/node/community/local-community/ipns-publishing.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/lifecycle.js +0 -1
- package/dist/browser/runtime/node/community/local-community/lifecycle.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/publication-store.js +9 -0
- package/dist/browser/runtime/node/community/local-community/publication-store.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community.d.ts +0 -2
- package/dist/browser/runtime/node/community/local-community.js +1 -5
- package/dist/browser/runtime/node/community/local-community.js.map +1 -1
- package/dist/bundled/bundle-manifest.json +47 -47
- package/dist/bundled/challenges.js +1 -1
- package/dist/bundled/chunks/{helia-for-pkc-jM3y3OXF.js → helia-for-pkc-8iett8xl.js} +33 -33
- package/dist/bundled/chunks/{local-community-5X7bvOoN.js → local-community-BlBIYSsF.js} +89 -74
- package/dist/bundled/chunks/{local-community-P9e5jksW.js → local-community-ChZZa9bm.js} +1 -1
- package/dist/bundled/chunks/{node-By3og2hw.js → node-BH_HrtON.js} +5 -5
- package/dist/bundled/chunks/{page-sort-scoring-DwYGP_0d.js → page-sort-scoring-NpdjWYfa.js} +1 -1
- package/dist/bundled/chunks/{rpc-local-community-WnhiTbxm.js → rpc-local-community-Byj5ZmMa.js} +26 -20
- package/dist/bundled/chunks/{util-DMr7Hj-w.js → util-CUZ1U2Go.js} +1 -1
- package/dist/bundled/chunks/{util-7QtFMzpc.js → util-DmmLFRbV.js} +1 -1
- package/dist/bundled/chunks/{validate-package-factories-TwRblx9f.js → validate-package-factories-CkU4qFQx.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/generated-version.d.ts +1 -1
- package/dist/node/generated-version.js +1 -1
- package/dist/node/runtime/node/community/challenges/exclude/exclude.js +1 -1
- package/dist/node/runtime/node/community/challenges/exclude/exclude.js.map +1 -1
- package/dist/node/runtime/node/community/challenges/exclude/rate-limiter.d.ts +2 -2
- package/dist/node/runtime/node/community/challenges/exclude/rate-limiter.js +21 -17
- package/dist/node/runtime/node/community/challenges/exclude/rate-limiter.js.map +1 -1
- package/dist/node/runtime/node/community/challenges/index.js +1 -1
- package/dist/node/runtime/node/community/challenges/index.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/challenges.js +21 -11
- package/dist/node/runtime/node/community/local-community/challenges.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/ipns-publishing.d.ts +7 -1
- package/dist/node/runtime/node/community/local-community/ipns-publishing.js +49 -36
- package/dist/node/runtime/node/community/local-community/ipns-publishing.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/lifecycle.js +0 -1
- package/dist/node/runtime/node/community/local-community/lifecycle.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/publication-store.js +9 -0
- package/dist/node/runtime/node/community/local-community/publication-store.js.map +1 -1
- package/dist/node/runtime/node/community/local-community.d.ts +0 -2
- package/dist/node/runtime/node/community/local-community.js +1 -5
- package/dist/node/runtime/node/community/local-community.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { i as __toESM } from "./chunk-2rV9d50f.js";
|
|
2
|
-
import { Ar as t$2, At as pTimeout, B as pubsubTopicToDhtKey, Bn as CommentUpdateSchema, Br as logger_default, Bt as DecryptedChallengeRequestPublicationSchema, C as hideClassPrivateProps, Cr as e, Dn as VotePubsubReservedFields, Dt as untrackUpdatingCommunity, En as VotePubsubMessagePublicationSchema, Er as t$3, F as isLinkOfVideo, Ft as ChallengeRequestMessageSchema, G as removeBlocksFromKuboNode, Hn as CommentUpdateTableRowSchema, I as isLinkValid, J as removeNullUndefinedValues, K as removeMfsFilesSafely, Lt as ChallengeVerificationMessageSchema, M as isLinkOfAudio, Mn as CommentIpfsSchema, Mr as require_retry, N as isLinkOfImage, Nn as CommentPubsubMessageReservedFields, Nt as ChallengeMessageSchema, Ot as require_sha256, P as isLinkOfMedia, Q as retryKuboBlockPutPinAndProvidePubsubTopic, Qn as CommentEditReservedFields, Rr as PKCError, Sr as e$1, St as trackStartedCommunity, T as ipnsNameToIpnsOverPubsubTopic, Tr as r$1, Tt as untrackStartedCommunity, Un as CommentsTableRowSchema, Vt as DecryptedChallengeRequestSchema, Xn as CommentEditPubsubMessagePublicationSchema, Yt as version_default, Zn as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema, Zt as CommunityEditPublicationPubsubReservedFields, _ as genToArray, _r as n$3, an as CommentModerationsTableRowSchema, ar as AuthorReservedFields, b as getIpnsRecordInLocalKuboNode, br as t$5, c as contentContainsMarkdownImages, ct as withSortedKeys, dt as findCommunityInRegistry, er as CommentEditsTableRowSchema, et as retryKuboIpfsAddAndProvide, f as derivePublicationFromChallengeRequest, ft as findStartedCommunity, g as findMalformedUnicodeString, gr as isStringDomain, hn as CommunitySignedPropertyNames, i as calculateStringSizeSameAsIpfsAddCidV0, it as statMfsPathSafely, j as isLinkOfAnimatedImage, jt as ChallengeAnswerMessageSchema, kn as VoteTablesRowSchema, kr as t$4, l as contentContainsMarkdownVideos, lt as withSortedKeysDeep, mn as CommunityIpfsSchema, mt as findUpdatingCommunity, ni as ZodError, nn as CommentModerationPubsubMessagePublicationSchema, o as calculateUnixFsDagSizeCidV0, ot as timestamp, p as doesDomainAddressHaveCapitalLetter, r as calculateIpfsCidV0, rn as CommentModerationReservedFields, rt as sleepUntilTimeoutOrAbort, s as contentContainsMarkdownAudio, ut as writeKuboFilesWithTimeout, v as getEquivalentCommunityAddresses, vr as t$7, wt as trackUpdatingCommunity, xr as t$6, xt as syncCommunityRegistryEntry, y as getErrorCodeFromMessage, yr as n$2, zr as messages } from "./util-
|
|
3
|
-
import { $ as createSchemaRowParser, $r as require_lodash_merge, An as verifyChallengeAnswer, Ar as removeFileRetryingWhileBusy, Bn as verifyCommunityEdit, Br as t$11, Dt as parseJsonWithPKCErrorIfFails, En as signCommunity, Fn as verifyCommentIpfs, Hn as verifyVote, Hr as t$8, In as verifyCommentModeration, Kn as getAuthorNameFromWire, Kr as t$9, Ln as verifyCommentPubsubMessage, Lr as isCommunityStartLocked, Mn as verifyChallengeRequest, N as MAX_PAGE_SIZE_BYTES, Or as moveCommunityDbToDeletedDirectory, Pn as verifyCommentEdit, Pr as findCommunitiesEntry, Q as collectSchemaRowCoercions, Qn as effectiveMaxCrosspostDepth, Qr as STORAGE_KEYS, Rn as verifyCommentUpdate, Rr as require_src, S as MAX_FILE_SIZE_BYTES_FOR_COMMUNITY_IPFS, Sn as signCommentEdit, Sr as getDefaultCommunityDbConfig, Tn as signCommentUpdateForChallengeVerification, Tr as importSignerIntoKuboNode, Un as buildRuntimeAuthor, Ur as n$5, Vr as r$2, W as pLimit, Wn as cleanWireAuthor, Wr as n$4, X as coerceSchemaRowBoolean, Z as coerceSchemaRowJson, Zn as crosspostChainDepthUpTo, _ as createAuthorIdentityMatcher, _r as deriveCommentIpfsFromCommentTableRow, a as generatePagesReportingFailedSorts, ar as encode, b as KeyvBetterSqlite3, bn as signChallengeVerification, c as resolvePageSortsOrThrow, cn as SignerWithPublicKeyAddress, cr as getPKCAddressFromPublicKey, d as getChallengeVerification, dr as BackupAbortError, dt as parseCommunityEditOptionsSchemaWithPKCErrorIfItFails, f as getCommunityChallengeFromCommunityChallengeSettings, fn as decryptEd25519AesGcmPublicKeyBuffer, fr as backupCommunityDb, g as authorNameResolveFailureReason, gn as cleanUpBeforePublishing, gr as deleteOldCommunityInWindows, h as authorIdentityMatcherForRequest, hn as _validateSignatureOfPKCRecord, i as derivePublicPageSorts, ir as decode, j as iterateOverPageCidsToFindAllCids, jr as resolveDbPostsCidRefs, kr as refreshCommunitiesList, lr as getPKCAddressFromPublicKeySync, m as pkcJsChallenges, mn as encryptEd25519AesGcmPublicKeyBuffer, mr as calculateInlineRepliesBudget, nr as getCommunityPublicKeyFromWire, o as loadPageSortsForStartedCommunity, p as loadChallengeFileFromCommunityChallengeSettings, pr as calculateExpectedSignatureSize, pt as parseCommunityIpfsSchemaPassthroughWithPKCErrorIfItFails, qr as stringify, r as computePageSortsFingerprint, s as lookupPageSortFactories, sr as getIpfsKeyFromPrivateKey, t as RpcLocalCommunity, tr as getCommunityNameFromWire, u as deriveCommunityChallengesOrThrow, ur as getPublicKeyFromPrivateKey, v as TrackedInstanceRegistry, vn as signChallengeMessage, vr as deriveDbPosts, w as TIMEFRAMES_TO_SECONDS, wn as signCommentUpdate, wr as getThumbnailPropsOfLink, wt as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, xn as signComment, xr as forgetCommunityThatFailedToBeDeleted, y as LRUCache, yr as deriveDbReplies, zn as verifyCommunity, zr as t$10 } from "./rpc-local-community-
|
|
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 { Ar as t$2, At as pTimeout, B as pubsubTopicToDhtKey, Bn as CommentUpdateSchema, Br as logger_default, Bt as DecryptedChallengeRequestPublicationSchema, C as hideClassPrivateProps, Cr as e, Dn as VotePubsubReservedFields, Dt as untrackUpdatingCommunity, En as VotePubsubMessagePublicationSchema, Er as t$3, F as isLinkOfVideo, Ft as ChallengeRequestMessageSchema, G as removeBlocksFromKuboNode, Hn as CommentUpdateTableRowSchema, I as isLinkValid, J as removeNullUndefinedValues, K as removeMfsFilesSafely, Lt as ChallengeVerificationMessageSchema, M as isLinkOfAudio, Mn as CommentIpfsSchema, Mr as require_retry, N as isLinkOfImage, Nn as CommentPubsubMessageReservedFields, Nt as ChallengeMessageSchema, Ot as require_sha256, P as isLinkOfMedia, Q as retryKuboBlockPutPinAndProvidePubsubTopic, Qn as CommentEditReservedFields, Rr as PKCError, Sr as e$1, St as trackStartedCommunity, T as ipnsNameToIpnsOverPubsubTopic, Tr as r$1, Tt as untrackStartedCommunity, Un as CommentsTableRowSchema, Vt as DecryptedChallengeRequestSchema, Xn as CommentEditPubsubMessagePublicationSchema, Yt as version_default, Zn as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema, Zt as CommunityEditPublicationPubsubReservedFields, _ as genToArray, _r as n$3, an as CommentModerationsTableRowSchema, ar as AuthorReservedFields, b as getIpnsRecordInLocalKuboNode, br as t$5, c as contentContainsMarkdownImages, ct as withSortedKeys, dt as findCommunityInRegistry, er as CommentEditsTableRowSchema, et as retryKuboIpfsAddAndProvide, f as derivePublicationFromChallengeRequest, ft as findStartedCommunity, g as findMalformedUnicodeString, gr as isStringDomain, hn as CommunitySignedPropertyNames, i as calculateStringSizeSameAsIpfsAddCidV0, it as statMfsPathSafely, j as isLinkOfAnimatedImage, jt as ChallengeAnswerMessageSchema, kn as VoteTablesRowSchema, kr as t$4, l as contentContainsMarkdownVideos, lt as withSortedKeysDeep, mn as CommunityIpfsSchema, mt as findUpdatingCommunity, ni as ZodError, nn as CommentModerationPubsubMessagePublicationSchema, o as calculateUnixFsDagSizeCidV0, ot as timestamp, p as doesDomainAddressHaveCapitalLetter, r as calculateIpfsCidV0, rn as CommentModerationReservedFields, rt as sleepUntilTimeoutOrAbort, s as contentContainsMarkdownAudio, ut as writeKuboFilesWithTimeout, v as getEquivalentCommunityAddresses, vr as t$7, wt as trackUpdatingCommunity, xr as t$6, xt as syncCommunityRegistryEntry, y as getErrorCodeFromMessage, yr as n$2, zr as messages } from "./util-CUZ1U2Go.js";
|
|
3
|
+
import { $ as createSchemaRowParser, $r as require_lodash_merge, An as verifyChallengeAnswer, Ar as removeFileRetryingWhileBusy, Bn as verifyCommunityEdit, Br as t$11, Dt as parseJsonWithPKCErrorIfFails, En as signCommunity, Fn as verifyCommentIpfs, Hn as verifyVote, Hr as t$8, In as verifyCommentModeration, Kn as getAuthorNameFromWire, Kr as t$9, Ln as verifyCommentPubsubMessage, Lr as isCommunityStartLocked, Mn as verifyChallengeRequest, N as MAX_PAGE_SIZE_BYTES, Or as moveCommunityDbToDeletedDirectory, Pn as verifyCommentEdit, Pr as findCommunitiesEntry, Q as collectSchemaRowCoercions, Qn as effectiveMaxCrosspostDepth, Qr as STORAGE_KEYS, Rn as verifyCommentUpdate, Rr as require_src, S as MAX_FILE_SIZE_BYTES_FOR_COMMUNITY_IPFS, Sn as signCommentEdit, Sr as getDefaultCommunityDbConfig, Tn as signCommentUpdateForChallengeVerification, Tr as importSignerIntoKuboNode, Un as buildRuntimeAuthor, Ur as n$5, Vr as r$2, W as pLimit, Wn as cleanWireAuthor, Wr as n$4, X as coerceSchemaRowBoolean, Z as coerceSchemaRowJson, Zn as crosspostChainDepthUpTo, _ as createAuthorIdentityMatcher, _r as deriveCommentIpfsFromCommentTableRow, a as generatePagesReportingFailedSorts, ar as encode, b as KeyvBetterSqlite3, bn as signChallengeVerification, c as resolvePageSortsOrThrow, cn as SignerWithPublicKeyAddress, cr as getPKCAddressFromPublicKey, d as getChallengeVerification, dr as BackupAbortError, dt as parseCommunityEditOptionsSchemaWithPKCErrorIfItFails, f as getCommunityChallengeFromCommunityChallengeSettings, fn as decryptEd25519AesGcmPublicKeyBuffer, fr as backupCommunityDb, g as authorNameResolveFailureReason, gn as cleanUpBeforePublishing, gr as deleteOldCommunityInWindows, h as authorIdentityMatcherForRequest, hn as _validateSignatureOfPKCRecord, i as derivePublicPageSorts, ir as decode, j as iterateOverPageCidsToFindAllCids, jr as resolveDbPostsCidRefs, kr as refreshCommunitiesList, lr as getPKCAddressFromPublicKeySync, m as pkcJsChallenges, mn as encryptEd25519AesGcmPublicKeyBuffer, mr as calculateInlineRepliesBudget, nr as getCommunityPublicKeyFromWire, o as loadPageSortsForStartedCommunity, p as loadChallengeFileFromCommunityChallengeSettings, pr as calculateExpectedSignatureSize, pt as parseCommunityIpfsSchemaPassthroughWithPKCErrorIfItFails, qr as stringify, r as computePageSortsFingerprint, s as lookupPageSortFactories, sr as getIpfsKeyFromPrivateKey, t as RpcLocalCommunity, tr as getCommunityNameFromWire, u as deriveCommunityChallengesOrThrow, ur as getPublicKeyFromPrivateKey, v as TrackedInstanceRegistry, vn as signChallengeMessage, vr as deriveDbPosts, w as TIMEFRAMES_TO_SECONDS, wn as signCommentUpdate, wr as getThumbnailPropsOfLink, wt as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, xn as signComment, xr as forgetCommunityThatFailedToBeDeleted, y as LRUCache, yr as deriveDbReplies, zn as verifyCommunity, zr as t$10 } from "./rpc-local-community-Byj5ZmMa.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-NpdjWYfa.js";
|
|
5
5
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
6
|
-
import
|
|
6
|
+
import Path from "node:path";
|
|
7
7
|
import os from "os";
|
|
8
8
|
import fs, { closeSync, existsSync, openSync, promises } from "node:fs";
|
|
9
|
-
import path
|
|
9
|
+
import path from "path";
|
|
10
10
|
import assert from "assert";
|
|
11
11
|
import { Buffer as Buffer$1 } from "buffer";
|
|
12
12
|
import fs$1 from "fs";
|
|
@@ -316,15 +316,15 @@ async function throwIfChallengeSettingsAreInvalid({ challengeSettings, pkc, comm
|
|
|
316
316
|
const processStartedCommunities = new TrackedInstanceRegistry();
|
|
317
317
|
function normalizeRegistryDataPath(dataPath) {
|
|
318
318
|
if (dataPath === void 0) return void 0;
|
|
319
|
-
const resolved = path
|
|
319
|
+
const resolved = path.resolve(dataPath);
|
|
320
320
|
let existing = resolved;
|
|
321
321
|
let tail = "";
|
|
322
322
|
while (true) try {
|
|
323
|
-
return path
|
|
323
|
+
return path.join(fs$1.realpathSync.native(existing), tail);
|
|
324
324
|
} catch {
|
|
325
|
-
const parent = path
|
|
325
|
+
const parent = path.dirname(existing);
|
|
326
326
|
if (parent === existing) return resolved;
|
|
327
|
-
tail = path
|
|
327
|
+
tail = path.join(path.basename(existing), tail);
|
|
328
328
|
existing = parent;
|
|
329
329
|
}
|
|
330
330
|
}
|
|
@@ -1792,9 +1792,9 @@ var DbHandler = class {
|
|
|
1792
1792
|
if (needToMigrate) {
|
|
1793
1793
|
if (dbExistsAlready && currentDbVersion > 0) {
|
|
1794
1794
|
this.destoryConnection();
|
|
1795
|
-
backupDbPath = path
|
|
1796
|
-
log(`Copying db ${path
|
|
1797
|
-
if (!fs$1.existsSync(path
|
|
1795
|
+
backupDbPath = path.join(path.dirname(dbPath), ".backup_before_migration", `${path.basename(dbPath)}.${currentDbVersion}.${timestamp()}`);
|
|
1796
|
+
log(`Copying db ${path.basename(dbPath)} to ${backupDbPath} before migration`);
|
|
1797
|
+
if (!fs$1.existsSync(path.dirname(backupDbPath))) await fs$1.promises.mkdir(path.dirname(backupDbPath), { recursive: true });
|
|
1798
1798
|
const sourceDb = new Database(dbPath, { fileMustExist: true });
|
|
1799
1799
|
await sourceDb.backup(backupDbPath);
|
|
1800
1800
|
sourceDb.close();
|
|
@@ -3865,10 +3865,10 @@ var DbHandler = class {
|
|
|
3865
3865
|
if (this._db || this._keyv) await this.destoryConnection();
|
|
3866
3866
|
this._transactionDepth = 0;
|
|
3867
3867
|
const dataPath = this._community._pkc.dataPath;
|
|
3868
|
-
const oldPathString = path
|
|
3869
|
-
const newPathString = path
|
|
3870
|
-
await fs$1.promises.mkdir(path
|
|
3871
|
-
await fs$1.promises.mkdir(path
|
|
3868
|
+
const oldPathString = path.join(dataPath, "communities", oldDbName);
|
|
3869
|
+
const newPathString = path.join(dataPath, "communities", newDbName);
|
|
3870
|
+
await fs$1.promises.mkdir(path.dirname(oldPathString), { recursive: true });
|
|
3871
|
+
await fs$1.promises.mkdir(path.dirname(newPathString), { recursive: true });
|
|
3872
3872
|
try {
|
|
3873
3873
|
if (!fs$1.existsSync(oldPathString)) log(`Old DB file ${oldPathString} does not exist. Cannot backup/rename.`);
|
|
3874
3874
|
else {
|
|
@@ -3895,8 +3895,8 @@ var DbHandler = class {
|
|
|
3895
3895
|
async lockCommunityStart({ onCompromised }) {
|
|
3896
3896
|
const log = logger_default("pkc-js:local-community:db-handler:lock:start");
|
|
3897
3897
|
const communityAddress = this._community.address;
|
|
3898
|
-
const lockfilePath = path
|
|
3899
|
-
const communityDbPath = path
|
|
3898
|
+
const lockfilePath = path.join(this._community._pkc.dataPath, "communities", `${communityAddress}.start.lock`);
|
|
3899
|
+
const communityDbPath = path.join(this._community._pkc.dataPath, "communities", communityAddress);
|
|
3900
3900
|
const startLock = {};
|
|
3901
3901
|
try {
|
|
3902
3902
|
await import_src.default.lock(communityDbPath, {
|
|
@@ -3925,8 +3925,8 @@ var DbHandler = class {
|
|
|
3925
3925
|
const log = logger_default("pkc-js:local-community:db-handler:unlock:start");
|
|
3926
3926
|
log.trace(`Attempting to unlock the start of community (${communityAddress})`);
|
|
3927
3927
|
this._heldStartLock = void 0;
|
|
3928
|
-
const lockfilePath = path
|
|
3929
|
-
const communityDbPath = path
|
|
3928
|
+
const lockfilePath = path.join(this._community._pkc.dataPath, "communities", `${communityAddress}.start.lock`);
|
|
3929
|
+
const communityDbPath = path.join(this._community._pkc.dataPath, "communities", communityAddress);
|
|
3930
3930
|
if (!fs$1.existsSync(lockfilePath) || !fs$1.existsSync(communityDbPath)) return;
|
|
3931
3931
|
try {
|
|
3932
3932
|
await import_src.default.unlock(communityDbPath, { lockfilePath });
|
|
@@ -3944,8 +3944,8 @@ var DbHandler = class {
|
|
|
3944
3944
|
}
|
|
3945
3945
|
async lockCommunityState() {
|
|
3946
3946
|
const log = logger_default("pkc-js:local-community:db-handler:lock:lockCommunityState");
|
|
3947
|
-
const lockfilePath = path
|
|
3948
|
-
const communityDbPath = path
|
|
3947
|
+
const lockfilePath = path.join(this._community._pkc.dataPath, "communities", `${this._community.address}.state.lock`);
|
|
3948
|
+
const communityDbPath = path.join(this._community._pkc.dataPath, "communities", this._community.address);
|
|
3949
3949
|
try {
|
|
3950
3950
|
await import_src.default.lock(communityDbPath, {
|
|
3951
3951
|
lockfilePath,
|
|
@@ -3962,8 +3962,8 @@ var DbHandler = class {
|
|
|
3962
3962
|
}
|
|
3963
3963
|
async unlockCommunityState() {
|
|
3964
3964
|
const log = logger_default("pkc-js:local-community:db-handler:lock:unlockCommunityState");
|
|
3965
|
-
const lockfilePath = path
|
|
3966
|
-
const communityDbPath = path
|
|
3965
|
+
const lockfilePath = path.join(this._community._pkc.dataPath, "communities", `${this._community.address}.state.lock`);
|
|
3966
|
+
const communityDbPath = path.join(this._community._pkc.dataPath, "communities", this._community.address);
|
|
3967
3967
|
if (!fs$1.existsSync(lockfilePath)) return;
|
|
3968
3968
|
try {
|
|
3969
3969
|
await import_src.default.unlock(communityDbPath, { lockfilePath });
|
|
@@ -3973,7 +3973,7 @@ var DbHandler = class {
|
|
|
3973
3973
|
}
|
|
3974
3974
|
}
|
|
3975
3975
|
communityDbExists() {
|
|
3976
|
-
const communityDbPath = path
|
|
3976
|
+
const communityDbPath = path.join(this._community._pkc.dataPath, "communities", this._community.address);
|
|
3977
3977
|
return fs$1.existsSync(communityDbPath);
|
|
3978
3978
|
}
|
|
3979
3979
|
markCommentsAsPublishedToPostUpdates(commentCids) {
|
|
@@ -5280,12 +5280,19 @@ async function handleChallengeRequest(community, request, isLocalPublisher) {
|
|
|
5280
5280
|
community._challengeExchangesFromLocalPublishers[request.challengeRequestId.toString()] = true;
|
|
5281
5281
|
}
|
|
5282
5282
|
community._ongoingChallengeExchanges.set(request.challengeRequestId.toString(), true);
|
|
5283
|
-
|
|
5284
|
-
|
|
5285
|
-
|
|
5286
|
-
|
|
5287
|
-
|
|
5288
|
-
|
|
5283
|
+
let decrypted;
|
|
5284
|
+
try {
|
|
5285
|
+
const requestSignatureValidation = await verifyChallengeRequest({
|
|
5286
|
+
request,
|
|
5287
|
+
validateTimestampRange: true
|
|
5288
|
+
});
|
|
5289
|
+
if (!requestSignatureValidation.valid) throw new PKCError(getErrorCodeFromMessage(requestSignatureValidation.reason), { challengeRequest: n$2(request, ["encrypted"]) });
|
|
5290
|
+
decrypted = await parseChallengeRequest(community, request, log);
|
|
5291
|
+
} catch (e) {
|
|
5292
|
+
community._ongoingChallengeExchanges.delete(request.challengeRequestId.toString());
|
|
5293
|
+
delete community._challengeExchangesFromLocalPublishers[request.challengeRequestId.toString()];
|
|
5294
|
+
throw e;
|
|
5295
|
+
}
|
|
5289
5296
|
if (!decrypted) return;
|
|
5290
5297
|
const publicationSignature = decrypted.publication.signature.signature;
|
|
5291
5298
|
let waitedForInFlightExchange = false;
|
|
@@ -5341,12 +5348,7 @@ async function handleChallengeAnswer(community, challengeAnswer) {
|
|
|
5341
5348
|
answer: challengeAnswer,
|
|
5342
5349
|
validateTimestampRange: true
|
|
5343
5350
|
});
|
|
5344
|
-
if (!answerSignatureValidation.valid) {
|
|
5345
|
-
cleanUpChallengeAnswerPromise(community, challengeAnswer.challengeRequestId.toString());
|
|
5346
|
-
community._ongoingChallengeExchanges.delete(challengeAnswer.challengeRequestId.toString());
|
|
5347
|
-
delete community._challengeExchangesFromLocalPublishers[challengeAnswer.challengeRequestId.toString()];
|
|
5348
|
-
throw new PKCError(getErrorCodeFromMessage(answerSignatureValidation.reason), { challengeAnswer });
|
|
5349
|
-
}
|
|
5351
|
+
if (!answerSignatureValidation.valid) throw new PKCError(getErrorCodeFromMessage(answerSignatureValidation.reason), { challengeAnswer });
|
|
5350
5352
|
const decryptedAnswers = await parseChallengeAnswerOrRespondWithFailure(community, challengeAnswer, await decryptOrRespondWithFailure(community, challengeAnswer));
|
|
5351
5353
|
const decryptedChallengeAnswerPubsubMessage = {
|
|
5352
5354
|
...challengeAnswer,
|
|
@@ -6006,6 +6008,10 @@ async function storeCommentModeration(community, commentModRaw, challengeRequest
|
|
|
6006
6008
|
} else if ("approved" in modTableRow.commentModeration) if (modTableRow.commentModeration.approved) {
|
|
6007
6009
|
log("commentModeration.approved=true, and therefore move comment from pending approval and add it to IPFS", "comment cid is", modTableRow.commentCid);
|
|
6008
6010
|
await community._addCommentRowToIPFS(commentToBeEdited, logger_default("pkc-js:local-community:storeCommentModeration:_addCommentRowToIPFS"));
|
|
6011
|
+
if (!community._dbHandler.queryComment(modTableRow.commentCid)) {
|
|
6012
|
+
addAllCidsUnderPurgedCommentToBeRemoved(community, { commentTableRow: commentToBeEdited });
|
|
6013
|
+
throw new PKCError("ERR_COMMENT_MODERATION_NO_COMMENT_TO_EDIT", { commentCid: modTableRow.commentCid });
|
|
6014
|
+
}
|
|
6009
6015
|
community._dbHandler.approvePendingComment({ cid: modTableRow.commentCid });
|
|
6010
6016
|
} else {
|
|
6011
6017
|
const shouldPurgeDisapprovedComment = Object.keys(modTableRow.commentModeration).length === 1;
|
|
@@ -6347,18 +6353,6 @@ function requireCommunityUpdateIfModQueueChanged(community) {
|
|
|
6347
6353
|
const combinedHashOfAllQueuedComments = community._dbHandler.queryCombinedHashOfPendingComments();
|
|
6348
6354
|
if (community._combinedHashOfPendingCommentsCids !== combinedHashOfAllQueuedComments) community._communityUpdateTrigger = true;
|
|
6349
6355
|
}
|
|
6350
|
-
async function resolveIpnsAndLogIfPotentialProblematicSequence(community) {
|
|
6351
|
-
const log = logger_default("pkc-js:local-community:_resolveIpnsAndLogIfPotentialProblematicSequence");
|
|
6352
|
-
if (!community.signer.ipnsKeyName) throw Error("IPNS key name is not defined");
|
|
6353
|
-
if (!community.updateCid) return;
|
|
6354
|
-
try {
|
|
6355
|
-
const { cid: ipnsCid } = await community._clientsManager.resolveIpnsToCidP2P(community.signer.ipnsKeyName, { timeoutMs: 12e4 });
|
|
6356
|
-
log.trace("Resolved community", community.address, "IPNS key", community.signer.ipnsKeyName, "to", ipnsCid);
|
|
6357
|
-
if (ipnsCid && community.updateCid && ipnsCid !== community.updateCid) log.error("community", community.address, "IPNS key", community.signer.ipnsKeyName, "points to", ipnsCid, "but we expected it to point to", community.updateCid, "This could result an IPNS record with invalid sequence number");
|
|
6358
|
-
} catch (e) {
|
|
6359
|
-
log.trace("Failed to resolve community before publishing", community.address, "IPNS key", community.signer.ipnsKeyName, e);
|
|
6360
|
-
}
|
|
6361
|
-
}
|
|
6362
6356
|
async function addOldPageCidsToCidsToUnpin(community, curPages, newPages, addToBlockRm) {
|
|
6363
6357
|
if (!curPages && !newPages) return;
|
|
6364
6358
|
else if (curPages && !newPages) (await iterateOverPageCidsToFindAllCids({
|
|
@@ -6464,6 +6458,37 @@ async function validateAndSignCommunityRecord(community, build) {
|
|
|
6464
6458
|
await community._validateCommunitySizeSchemaAndSignatureBeforePublishing(newCommunityRecord);
|
|
6465
6459
|
return newCommunityRecord;
|
|
6466
6460
|
}
|
|
6461
|
+
function readStoredIpnsSequence(community) {
|
|
6462
|
+
const storedRecord = community._dbHandler.keyvGet(STORAGE_KEYS[STORAGE_KEYS.LAST_IPNS_RECORD]);
|
|
6463
|
+
if (!storedRecord) return void 0;
|
|
6464
|
+
const decodedRecord = decode(new Uint8Array(Object.values(storedRecord)), { allowBigInt: true });
|
|
6465
|
+
if (typeof decodedRecord.sequence !== "bigint" && typeof decodedRecord.sequence !== "number") return void 0;
|
|
6466
|
+
return BigInt(decodedRecord.sequence);
|
|
6467
|
+
}
|
|
6468
|
+
const KUBO_SEQUENCE_NOT_GREATER_ERROR_MESSAGE = "sequence number must be greater than the current record sequence";
|
|
6469
|
+
async function publishIpnsRecordContinuingStoredSequence({ community, kuboRpcClient, path, ttl }) {
|
|
6470
|
+
const log = logger_default("pkc-js:local-community:publishIpnsRecordContinuingStoredSequence");
|
|
6471
|
+
if (!community.signer.ipnsKeyName) throw Error("IPNS key name is not defined");
|
|
6472
|
+
const publishOptions = {
|
|
6473
|
+
key: community.signer.ipnsKeyName,
|
|
6474
|
+
allowOffline: true,
|
|
6475
|
+
resolve: true,
|
|
6476
|
+
ttl
|
|
6477
|
+
};
|
|
6478
|
+
const storedSequence = readStoredIpnsSequence(community);
|
|
6479
|
+
if (storedSequence === void 0) return kuboRpcClient._client.name.publish(path, publishOptions);
|
|
6480
|
+
const publishOptionsWithSequence = {
|
|
6481
|
+
...publishOptions,
|
|
6482
|
+
sequence: (storedSequence + 1n).toString()
|
|
6483
|
+
};
|
|
6484
|
+
try {
|
|
6485
|
+
return await kuboRpcClient._client.name.publish(path, publishOptionsWithSequence);
|
|
6486
|
+
} catch (e) {
|
|
6487
|
+
if (!(e instanceof Error) || !e.message.includes(KUBO_SEQUENCE_NOT_GREATER_ERROR_MESSAGE)) throw e;
|
|
6488
|
+
log("Kubo holds an IPNS record for community", community.address, "at or past the stored sequence", storedSequence, "so it is left to continue its own sequence");
|
|
6489
|
+
return kuboRpcClient._client.name.publish(path, publishOptions);
|
|
6490
|
+
}
|
|
6491
|
+
}
|
|
6467
6492
|
async function publishCommunityRecordToIpns(community, build, newCommunityRecord, cycleStartedAtMs) {
|
|
6468
6493
|
const { log, newIpns, newModQueue, editIdsToIncludeInNextUpdate } = build;
|
|
6469
6494
|
const kuboRpcClient = community._clientsManager.getDefaultKuboRpcClient();
|
|
@@ -6483,15 +6508,11 @@ async function publishCommunityRecordToIpns(community, build, newCommunityRecord
|
|
|
6483
6508
|
address: community.address
|
|
6484
6509
|
});
|
|
6485
6510
|
if (!community.signer.ipnsKeyName) throw Error("IPNS key name is not defined");
|
|
6486
|
-
if (community._firstUpdateAfterStart) await community._resolveIpnsAndLogIfPotentialProblematicSequence();
|
|
6487
6511
|
const ttl = `${community._pkc.publishInterval * 1}ms`;
|
|
6488
|
-
const
|
|
6489
|
-
|
|
6490
|
-
|
|
6491
|
-
|
|
6492
|
-
key: community.signer.ipnsKeyName,
|
|
6493
|
-
allowOffline: true,
|
|
6494
|
-
resolve: true,
|
|
6512
|
+
const publishRes = await publishIpnsRecordContinuingStoredSequence({
|
|
6513
|
+
community,
|
|
6514
|
+
kuboRpcClient,
|
|
6515
|
+
path: file.path,
|
|
6495
6516
|
ttl
|
|
6496
6517
|
});
|
|
6497
6518
|
log(`Published a new IPNS record for community(${community.address}) on IPNS (${publishRes.name}) that points to file (${publishRes.value}) with updatedAt (${newCommunityRecord.updatedAt}) and TTL (${ttl})`);
|
|
@@ -6522,12 +6543,11 @@ async function publishCommunityRecordToIpns(community, build, newCommunityRecord
|
|
|
6522
6543
|
const remainingEditProps = Object.assign({}, ...community._pendingEditProps.map((editProps) => t$10(editProps, t$6(CommunityIpfsSchema.shape))));
|
|
6523
6544
|
Object.assign(community, remainingEditProps);
|
|
6524
6545
|
}
|
|
6525
|
-
community._firstUpdateAfterStart = false;
|
|
6526
6546
|
try {
|
|
6527
6547
|
const ipnsRecord = await getIpnsRecordInLocalKuboNode(kuboRpcClient, community.signer.address);
|
|
6528
6548
|
await community._dbHandler.keyvSet(STORAGE_KEYS[STORAGE_KEYS.LAST_IPNS_RECORD], encode(ipnsRecord));
|
|
6529
6549
|
} catch (e) {
|
|
6530
|
-
log.
|
|
6550
|
+
log.error("Failed to store the published IPNS record in the community DB, its stored sequence is now behind", e);
|
|
6531
6551
|
}
|
|
6532
6552
|
community._combinedHashOfPendingCommentsCids = newModQueue?.combinedHashOfCids || (0, import_sha256.sha256)("");
|
|
6533
6553
|
log.trace("Updated combined hash of pending comments to", community._combinedHashOfPendingCommentsCids);
|
|
@@ -6785,7 +6805,6 @@ async function start(community) {
|
|
|
6785
6805
|
async function startCommunity({ community, releaseMark }) {
|
|
6786
6806
|
const log = logger_default("pkc-js:local-community:start");
|
|
6787
6807
|
community._stopHasBeenCalled = false;
|
|
6788
|
-
community._firstUpdateAfterStart = true;
|
|
6789
6808
|
community._lastProvidedBrowserDialableSelfAddrs = void 0;
|
|
6790
6809
|
community._lastAddressReprovideCheckAt = void 0;
|
|
6791
6810
|
if (!community._clientsManager.getDefaultKuboRpcClientOrHelia()) throw Error("You need to define an IPFS client in your pkc instance to be able to start a local community");
|
|
@@ -7302,9 +7321,9 @@ async function restartCommunityAfterFailedRename({ community, oldAddress, newAdd
|
|
|
7302
7321
|
}
|
|
7303
7322
|
}
|
|
7304
7323
|
async function removePartialDbCopy({ community, oldAddress, newAddress, log }) {
|
|
7305
|
-
const communitiesPath =
|
|
7306
|
-
const partialDbCopyPath =
|
|
7307
|
-
if (!fs.existsSync(
|
|
7324
|
+
const communitiesPath = Path.join(community._pkc.dataPath, "communities");
|
|
7325
|
+
const partialDbCopyPath = Path.join(communitiesPath, newAddress);
|
|
7326
|
+
if (!fs.existsSync(Path.join(communitiesPath, oldAddress))) return {
|
|
7308
7327
|
removed: false,
|
|
7309
7328
|
path: partialDbCopyPath
|
|
7310
7329
|
};
|
|
@@ -7321,7 +7340,7 @@ async function removePartialDbCopy({ community, oldAddress, newAddress, log }) {
|
|
|
7321
7340
|
}
|
|
7322
7341
|
}
|
|
7323
7342
|
async function undoRenameAfterDbRenameFailed({ community, oldAddress, newAddress, dbRenameError, log }) {
|
|
7324
|
-
const communitiesPath =
|
|
7343
|
+
const communitiesPath = Path.join(community._pkc.dataPath, "communities");
|
|
7325
7344
|
const partialDbCopy = await removePartialDbCopy({
|
|
7326
7345
|
community,
|
|
7327
7346
|
oldAddress,
|
|
@@ -7339,8 +7358,8 @@ async function undoRenameAfterDbRenameFailed({ community, oldAddress, newAddress
|
|
|
7339
7358
|
error: new PKCError("ERR_FAILED_TO_RENAME_COMMUNITY_DB", {
|
|
7340
7359
|
oldAddress,
|
|
7341
7360
|
newAddress,
|
|
7342
|
-
oldDbPath:
|
|
7343
|
-
newDbPath:
|
|
7361
|
+
oldDbPath: Path.join(communitiesPath, oldAddress),
|
|
7362
|
+
newDbPath: Path.join(communitiesPath, newAddress),
|
|
7344
7363
|
error: dbRenameError,
|
|
7345
7364
|
errorMessage: renameError?.message,
|
|
7346
7365
|
errorName: renameError?.name,
|
|
@@ -7523,11 +7542,11 @@ async function edit(community, newCommunityOptions) {
|
|
|
7523
7542
|
const EXPORTS_KEY = STORAGE_KEYS[STORAGE_KEYS.EXPORTS];
|
|
7524
7543
|
function defaultExportPathFor(community, exportId) {
|
|
7525
7544
|
if (typeof community._pkc.dataPath !== "string") throw new PKCError("ERR_DATA_PATH_IS_NOT_DEFINED", { communityAddress: community.address });
|
|
7526
|
-
return
|
|
7545
|
+
return Path.join(community._pkc.dataPath, "exports", `${exportId}.sqlite`);
|
|
7527
7546
|
}
|
|
7528
7547
|
function sourceDbPathFor(community) {
|
|
7529
7548
|
if (typeof community._pkc.dataPath !== "string") throw new PKCError("ERR_DATA_PATH_IS_NOT_DEFINED", { communityAddress: community.address });
|
|
7530
|
-
return
|
|
7549
|
+
return Path.join(community._pkc.dataPath, "communities", community.address);
|
|
7531
7550
|
}
|
|
7532
7551
|
async function persistExports(community) {
|
|
7533
7552
|
if (!community._dbHandler) return;
|
|
@@ -7603,9 +7622,9 @@ async function runExportTask(community, exportId, opts) {
|
|
|
7603
7622
|
async function exportCommunityEmbedded(community, options = {}) {
|
|
7604
7623
|
if (options.signal?.aborted) throw options.signal.reason ?? new DOMException("The operation was aborted.", "AbortError");
|
|
7605
7624
|
const exportId = v4();
|
|
7606
|
-
const destPath = options.exportPath ?
|
|
7625
|
+
const destPath = options.exportPath ? Path.resolve(options.exportPath) : defaultExportPathFor(community, exportId);
|
|
7607
7626
|
const includePrivateKey = options.includePrivateKey === true;
|
|
7608
|
-
if (
|
|
7627
|
+
if (Path.resolve(destPath) === Path.resolve(sourceDbPathFor(community))) throw new PKCError("ERR_EXPORT_PATH_TARGETS_LIVE_DB", {
|
|
7609
7628
|
communityAddress: community.address,
|
|
7610
7629
|
exportPath: destPath
|
|
7611
7630
|
});
|
|
@@ -7748,7 +7767,6 @@ var LocalCommunity = class extends RpcLocalCommunity {
|
|
|
7748
7767
|
this._startOrUpdateInFlight = void 0;
|
|
7749
7768
|
this._stopInFlight = void 0;
|
|
7750
7769
|
this._editStoresInFlight = /* @__PURE__ */ new Set();
|
|
7751
|
-
this._firstUpdateAfterStart = true;
|
|
7752
7770
|
this._internalStateUpdateId = "";
|
|
7753
7771
|
this._lastPubsubTopicRoutingProvideAt = void 0;
|
|
7754
7772
|
this._subscribedChallengePubsubTopic = void 0;
|
|
@@ -8045,9 +8063,6 @@ var LocalCommunity = class extends RpcLocalCommunity {
|
|
|
8045
8063
|
_calculateLatestUpdateTrigger() {
|
|
8046
8064
|
return calculateLatestUpdateTrigger(this);
|
|
8047
8065
|
}
|
|
8048
|
-
async _resolveIpnsAndLogIfPotentialProblematicSequence() {
|
|
8049
|
-
return resolveIpnsAndLogIfPotentialProblematicSequence(this);
|
|
8050
|
-
}
|
|
8051
8066
|
async _updateDbInternalState(props) {
|
|
8052
8067
|
return updateDbInternalState(this, props);
|
|
8053
8068
|
}
|
|
@@ -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-BlBIYSsF.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 retryKuboIpfsAdd, At as pTimeout, Bn as CommentUpdateSchema, Br as logger_default, C as hideClassPrivateProps, Cr as e$1, Ct as trackUpdatingComment, D as isIpfsCid, Dt as untrackUpdatingCommunity, E as isAbortError, Et as untrackUpdatingComment, Ft as ChallengeRequestMessageSchema, Ln as CommentUpdateForChallengeVerificationSchema, Lr as FailedToFetchPageIpfsFromGatewaysError, Lt as ChallengeVerificationMessageSchema, Mn as CommentIpfsSchema, Mr as require_retry$1, Nr as FailedToFetchCommentIpfsFromGatewaysError, Nt as ChallengeMessageSchema, Ot as require_sha256, Pr as FailedToFetchCommentUpdateFromGatewaysError, Rr as PKCError, Sn as PubsubTopicSchema, Sr as e, T as ipnsNameToIpnsOverPubsubTopic, Tr as r, U as rejectWhenAbortSignalFires, Ur as setErrorMap, W as rejectWhenCommunityStopsOrAborts, X as replaceXWithY, Y as removeUndefinedValuesRecursively, Yt as version_default, Z as resolveWhenPredicateIsTrue, _r as n$2, _t as listUpdatingComments, a as calculateStringSizeSameAsIpfsAddCidV0Sync, at as throwIfAbortSignalAborted, d as deepMergeRuntimeFields, et as retryKuboIpfsAddAndProvide, ft as findStartedCommunity, gr as isStringDomain, gt as listStartedCommunities, i as calculateStringSizeSameAsIpfsAddCidV0, jt as ChallengeAnswerMessageSchema, k as isIpns, kt as TimeoutError, ln as CommunityAnchorSchema, mn as CommunityIpfsSchema, mt as findUpdatingCommunity, nt as shortifyCid, ot as timestamp, p as doesDomainAddressHaveCapitalLetter, pt as findUpdatingComment, r as calculateIpfsCidV0, ri as en_default, rt as sleepUntilTimeoutOrAbort, st as waitForUpdateInCommunityInstanceWithErrorAndTimeout, tt as shortifyAddress, u as createAbortError, vt as listUpdatingCommunities, x as getPostUpdateTimestampRange, xr as t$1, yr as n$1, yt as refreshTrackedCommentAliases, z as linkAbortSignals, zr as messages } from "./util-
|
|
3
|
-
import { $n as buildRuntimeCommunityFields, $t as RpcPublishCommunityListParamSchema, A as findCommentInParsedPages, At as parseRpcCommentUpdateEventWithPKCErrorIfItFails, B as GenericStateClient, Bn as verifyCommunityEdit, Bt as RpcCommunityIdentifierParamSchema, C as RepliesPages, Cn as signCommentModeration, Cr as getDefaultDataPath, Ct as parseCreateVoteOptionsSchemaWithPKCErrorIfItFails, D as extractCommunityRuntimeFieldsFromParsedPages, Dn as signCommunityEdit, Dr as monitorCommunitiesDirectory, Dt as parseJsonWithPKCErrorIfFails, Er as listCommunitiesSync, Et as parseDecryptedChallengeWithPKCErrorIfItFails, F as cloneCrosspostForRuntime, Fn as verifyCommentIpfs, Fr as toCommunitiesEntry, Ft as RpcAuthorNameParamSchema, G as PKCTypedEmitter, Gn as getAuthorNameFromRuntime, Gr as t$2, Gt as RpcExportCommunityParamSchema, H as InflightResourceTypes, Hn as verifyVote, Hr as t$3, Ht as RpcEditCommunityParamSchema, I as collectCrosspostAuthorsToResolve, In as verifyCommentModeration, It as RpcCancelExportParamSchema, J as decodeRpcChallengeRequestPubsubMsg, Jn as CreateCommunityListWithCidOptionsSchema, Jr as MAX_FILE_SIZE_BYTES_FOR_COMMENT_UPDATE, Jt as RpcFetchCidResultSchema, K as decodeRpcChallengeAnswerPubsubMsg, Kn as getAuthorNameFromWire, Kr as t$4, Kt as RpcExportCommunityResultSchema, Ln as verifyCommentPubsubMessage, Lt as RpcCidParamSchema, M as parseRawPages, Mr as setNativeFunctions$1, Nn as verifyChallengeVerification, Nr as tryToDeleteCommunitiesThatFailedToBeDeletedBefore, Nt as parseVotePubsubMessagePublicationSchemaWithPKCErrorIfItFails, O as findCommentInPageInstance, On as signCommunityList, Ot as parsePKCUserOptionsSchemaWithPKCErrorIfItFails, P as applyNameResolvedCacheToCrosspost, Pn as verifyCommentEdit, Pr as findCommunitiesEntry, Pt as RpcAnchorPublishPreparationResultSchema, Qt as RpcPublishChallengeAnswersParamSchema, R as stripNameResolvedFromCrosspost, Rn as verifyCommentUpdate, Rt as RpcCommentRepliesPageParamSchema, Sn as signCommentEdit, St as parseCreateRpcCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, Tt as parseDecryptedChallengeVerification, Un as buildRuntimeAuthor, Ur as n$3, Ut as RpcExportCommunityModLogsParamSchema, V as InflightFetchManager, Vn as verifyCommunityList, Vt as RpcCommunityPageParamSchema, Wn as cleanWireAuthor, Wt as RpcExportCommunityModLogsResultSchema, Xn as MAX_COMMUNITY_LIST_SIZE_BYTES, Xr as NAME_RESOLVED_TRUE_TTL_MS, Xt as RpcFetchCommunityListResultSchema, Y as decodeRpcChallengeVerificationPubsubMsg, Yn as CreateNewCommunityListOptionsSchema, Yr as NAME_RESOLVED_FALSE_TTL_MS, Yt as RpcFetchCommunityListParamSchema, Zr as NAME_RESOLVE_FAILED_RETRY_FLOOR_MS, Zt as RpcPublishAnchorRecordParamSchema, _n as signChallengeAnswer, _t as parseCreateCommentOptionsSchemaWithPKCErrorIfItFails, an as RpcUnsubscribeParamSchema, b as KeyvBetterSqlite3, br as findLocalCommunityAddress, ct as parseCommentUpdateSchemaWithPKCErrorIfItFails, dn as decryptEd25519AesGcm, ei as nativeFunctions$2, en as RpcPublishCommunityListResultSchema, er as getCommunityAddressFromRecord, et as parseCidStringSchemaWithPKCErrorIfItFails, ft as parseCommunityEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, gn as cleanUpBeforePublishing, gt as parseCreateCommentModerationOptionsSchemaWithPKCErrorIfItFails, hr as createKuboRpcClient, ht as parseCreateCommentEditOptionsSchemaWithPKCErrorIfItFails, in as RpcSuccessResultSchema, ir as decode, it as parseCommentIpfsSchemaWithPKCErrorIfItFails, jn as verifyChallengeMessage, jt as parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, k as findCommentInPageInstanceRecursively, kn as signVote, kt as parseRpcCommentEventWithPKCErrorIfItFails, l as pkcJsPageSorts, ln as createSigner, lr as getPKCAddressFromPublicKeySync, lt as parseCommunityAddressWithPKCErrorIfItFails, m as pkcJsChallenges, mt as parseCommunityListSchemaWithPKCErrorIfItFails, n as RpcRemoteCommunity, nn as RpcResolveAuthorNameResultSchema, nr as getCommunityPublicKeyFromWire, on as findCommunityRecordNameMismatch, or as getBufferedPKCAddressFromPublicKey, ot as parseCommentModerationPubsubMessagePublicationSchemaWithPKCErrorIfItFails, pn as encryptEd25519AesGcm, q as decodeRpcChallengePubsubMsg, qn as normalizeCreatePublicationAuthor, qt as RpcFetchCidParamSchema, rn as RpcSubscriptionIdResultSchema, rr as normalizeCommunityInputFromCommunity, rt as parseCommentEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, sn as require_lib$1, st as parseCommentPubsubMessagePublicationWithPKCErrorIfItFails, t as RpcLocalCommunity, tn as RpcPublishedAnchorRecordResultSchema, tr as getCommunityNameFromWire, un as createAnchorIpnsRecord$1, v as TrackedInstanceRegistry, vt as parseCreateCommunityEditPublicationOptionsSchemaWithPKCErrorIfItFails, wt as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, x as RemoteCommunity, xn as signComment, xt as parseCreateRemoteCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, y as LRUCache, yn as signChallengeRequest, z as PKCClientsManager, zr as t$5, zt as RpcCommunitiesChangeEventResultSchema } from "./rpc-local-community-
|
|
4
|
-
import { s as getHeliaDebugContext } from "./util-
|
|
2
|
+
import { $ as retryKuboIpfsAdd, At as pTimeout, Bn as CommentUpdateSchema, Br as logger_default, C as hideClassPrivateProps, Cr as e$1, Ct as trackUpdatingComment, D as isIpfsCid, Dt as untrackUpdatingCommunity, E as isAbortError, Et as untrackUpdatingComment, Ft as ChallengeRequestMessageSchema, Ln as CommentUpdateForChallengeVerificationSchema, Lr as FailedToFetchPageIpfsFromGatewaysError, Lt as ChallengeVerificationMessageSchema, Mn as CommentIpfsSchema, Mr as require_retry$1, Nr as FailedToFetchCommentIpfsFromGatewaysError, Nt as ChallengeMessageSchema, Ot as require_sha256, Pr as FailedToFetchCommentUpdateFromGatewaysError, Rr as PKCError, Sn as PubsubTopicSchema, Sr as e, T as ipnsNameToIpnsOverPubsubTopic, Tr as r, U as rejectWhenAbortSignalFires, Ur as setErrorMap, W as rejectWhenCommunityStopsOrAborts, X as replaceXWithY, Y as removeUndefinedValuesRecursively, Yt as version_default, Z as resolveWhenPredicateIsTrue, _r as n$2, _t as listUpdatingComments, a as calculateStringSizeSameAsIpfsAddCidV0Sync, at as throwIfAbortSignalAborted, d as deepMergeRuntimeFields, et as retryKuboIpfsAddAndProvide, ft as findStartedCommunity, gr as isStringDomain, gt as listStartedCommunities, i as calculateStringSizeSameAsIpfsAddCidV0, jt as ChallengeAnswerMessageSchema, k as isIpns, kt as TimeoutError, ln as CommunityAnchorSchema, mn as CommunityIpfsSchema, mt as findUpdatingCommunity, nt as shortifyCid, ot as timestamp, p as doesDomainAddressHaveCapitalLetter, pt as findUpdatingComment, r as calculateIpfsCidV0, ri as en_default, rt as sleepUntilTimeoutOrAbort, st as waitForUpdateInCommunityInstanceWithErrorAndTimeout, tt as shortifyAddress, u as createAbortError, vt as listUpdatingCommunities, x as getPostUpdateTimestampRange, xr as t$1, yr as n$1, yt as refreshTrackedCommentAliases, z as linkAbortSignals, zr as messages } from "./util-CUZ1U2Go.js";
|
|
3
|
+
import { $n as buildRuntimeCommunityFields, $t as RpcPublishCommunityListParamSchema, A as findCommentInParsedPages, At as parseRpcCommentUpdateEventWithPKCErrorIfItFails, B as GenericStateClient, Bn as verifyCommunityEdit, Bt as RpcCommunityIdentifierParamSchema, C as RepliesPages, Cn as signCommentModeration, Cr as getDefaultDataPath, Ct as parseCreateVoteOptionsSchemaWithPKCErrorIfItFails, D as extractCommunityRuntimeFieldsFromParsedPages, Dn as signCommunityEdit, Dr as monitorCommunitiesDirectory, Dt as parseJsonWithPKCErrorIfFails, Er as listCommunitiesSync, Et as parseDecryptedChallengeWithPKCErrorIfItFails, F as cloneCrosspostForRuntime, Fn as verifyCommentIpfs, Fr as toCommunitiesEntry, Ft as RpcAuthorNameParamSchema, G as PKCTypedEmitter, Gn as getAuthorNameFromRuntime, Gr as t$2, Gt as RpcExportCommunityParamSchema, H as InflightResourceTypes, Hn as verifyVote, Hr as t$3, Ht as RpcEditCommunityParamSchema, I as collectCrosspostAuthorsToResolve, In as verifyCommentModeration, It as RpcCancelExportParamSchema, J as decodeRpcChallengeRequestPubsubMsg, Jn as CreateCommunityListWithCidOptionsSchema, Jr as MAX_FILE_SIZE_BYTES_FOR_COMMENT_UPDATE, Jt as RpcFetchCidResultSchema, K as decodeRpcChallengeAnswerPubsubMsg, Kn as getAuthorNameFromWire, Kr as t$4, Kt as RpcExportCommunityResultSchema, Ln as verifyCommentPubsubMessage, Lt as RpcCidParamSchema, M as parseRawPages, Mr as setNativeFunctions$1, Nn as verifyChallengeVerification, Nr as tryToDeleteCommunitiesThatFailedToBeDeletedBefore, Nt as parseVotePubsubMessagePublicationSchemaWithPKCErrorIfItFails, O as findCommentInPageInstance, On as signCommunityList, Ot as parsePKCUserOptionsSchemaWithPKCErrorIfItFails, P as applyNameResolvedCacheToCrosspost, Pn as verifyCommentEdit, Pr as findCommunitiesEntry, Pt as RpcAnchorPublishPreparationResultSchema, Qt as RpcPublishChallengeAnswersParamSchema, R as stripNameResolvedFromCrosspost, Rn as verifyCommentUpdate, Rt as RpcCommentRepliesPageParamSchema, Sn as signCommentEdit, St as parseCreateRpcCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, Tt as parseDecryptedChallengeVerification, Un as buildRuntimeAuthor, Ur as n$3, Ut as RpcExportCommunityModLogsParamSchema, V as InflightFetchManager, Vn as verifyCommunityList, Vt as RpcCommunityPageParamSchema, Wn as cleanWireAuthor, Wt as RpcExportCommunityModLogsResultSchema, Xn as MAX_COMMUNITY_LIST_SIZE_BYTES, Xr as NAME_RESOLVED_TRUE_TTL_MS, Xt as RpcFetchCommunityListResultSchema, Y as decodeRpcChallengeVerificationPubsubMsg, Yn as CreateNewCommunityListOptionsSchema, Yr as NAME_RESOLVED_FALSE_TTL_MS, Yt as RpcFetchCommunityListParamSchema, Zr as NAME_RESOLVE_FAILED_RETRY_FLOOR_MS, Zt as RpcPublishAnchorRecordParamSchema, _n as signChallengeAnswer, _t as parseCreateCommentOptionsSchemaWithPKCErrorIfItFails, an as RpcUnsubscribeParamSchema, b as KeyvBetterSqlite3, br as findLocalCommunityAddress, ct as parseCommentUpdateSchemaWithPKCErrorIfItFails, dn as decryptEd25519AesGcm, ei as nativeFunctions$2, en as RpcPublishCommunityListResultSchema, er as getCommunityAddressFromRecord, et as parseCidStringSchemaWithPKCErrorIfItFails, ft as parseCommunityEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, gn as cleanUpBeforePublishing, gt as parseCreateCommentModerationOptionsSchemaWithPKCErrorIfItFails, hr as createKuboRpcClient, ht as parseCreateCommentEditOptionsSchemaWithPKCErrorIfItFails, in as RpcSuccessResultSchema, ir as decode, it as parseCommentIpfsSchemaWithPKCErrorIfItFails, jn as verifyChallengeMessage, jt as parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, k as findCommentInPageInstanceRecursively, kn as signVote, kt as parseRpcCommentEventWithPKCErrorIfItFails, l as pkcJsPageSorts, ln as createSigner, lr as getPKCAddressFromPublicKeySync, lt as parseCommunityAddressWithPKCErrorIfItFails, m as pkcJsChallenges, mt as parseCommunityListSchemaWithPKCErrorIfItFails, n as RpcRemoteCommunity, nn as RpcResolveAuthorNameResultSchema, nr as getCommunityPublicKeyFromWire, on as findCommunityRecordNameMismatch, or as getBufferedPKCAddressFromPublicKey, ot as parseCommentModerationPubsubMessagePublicationSchemaWithPKCErrorIfItFails, pn as encryptEd25519AesGcm, q as decodeRpcChallengePubsubMsg, qn as normalizeCreatePublicationAuthor, qt as RpcFetchCidParamSchema, rn as RpcSubscriptionIdResultSchema, rr as normalizeCommunityInputFromCommunity, rt as parseCommentEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, sn as require_lib$1, st as parseCommentPubsubMessagePublicationWithPKCErrorIfItFails, t as RpcLocalCommunity, tn as RpcPublishedAnchorRecordResultSchema, tr as getCommunityNameFromWire, un as createAnchorIpnsRecord$1, v as TrackedInstanceRegistry, vt as parseCreateCommunityEditPublicationOptionsSchemaWithPKCErrorIfItFails, wt as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, x as RemoteCommunity, xn as signComment, xt as parseCreateRemoteCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, y as LRUCache, yn as signChallengeRequest, z as PKCClientsManager, zr as t$5, zt as RpcCommunitiesChangeEventResultSchema } from "./rpc-local-community-Byj5ZmMa.js";
|
|
4
|
+
import { s as getHeliaDebugContext } from "./util-DmmLFRbV.js";
|
|
5
5
|
import path from "path";
|
|
6
6
|
import assert from "assert";
|
|
7
7
|
import fs from "fs";
|
|
@@ -36102,7 +36102,7 @@ var PKC$1 = class extends PKCTypedEmitter {
|
|
|
36102
36102
|
this.clients.libp2pJsClients = {};
|
|
36103
36103
|
if (!this.libp2pJsClientsOptions) return;
|
|
36104
36104
|
if (!this.httpRoutersOptions) throw Error("httpRoutersOptions is required for libp2pJsClient");
|
|
36105
|
-
const { createLibp2pJsClientOrUseExistingOne } = await import("./helia-for-pkc-
|
|
36105
|
+
const { createLibp2pJsClientOrUseExistingOne } = await import("./helia-for-pkc-8iett8xl.js");
|
|
36106
36106
|
for (const clientOptions of this.libp2pJsClientsOptions) {
|
|
36107
36107
|
const heliaNode = await createLibp2pJsClientOrUseExistingOne({
|
|
36108
36108
|
...clientOptions,
|
|
@@ -36469,7 +36469,7 @@ var PKC$1 = class extends PKCTypedEmitter {
|
|
|
36469
36469
|
const log = logger_default("pkc-js:pkc:createLocalCommunity");
|
|
36470
36470
|
log.trace("Received community options to create a local community instance:", options);
|
|
36471
36471
|
if (!this._canCreateNewLocalCommunity()) throw new PKCError("ERR_CAN_NOT_CREATE_A_LOCAL_COMMUNITY", { pkcOptions: this._userPKCOptions });
|
|
36472
|
-
const { LocalCommunity, createNewLocalCommunityDb, updateInstancePropsWithStartedCommunityOrDb } = await import("./local-community-
|
|
36472
|
+
const { LocalCommunity, createNewLocalCommunityDb, updateInstancePropsWithStartedCommunityOrDb } = await import("./local-community-ChZZa9bm.js");
|
|
36473
36473
|
const isLocalCommunity = (await listCommunitiesSync(this)).includes(options.address);
|
|
36474
36474
|
const community = new LocalCommunity(this);
|
|
36475
36475
|
if (isLocalCommunity) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { gr as isStringDomain, v as getEquivalentCommunityAddresses, xn as PageSortFileSchema } from "./util-
|
|
1
|
+
import { gr as isStringDomain, v as getEquivalentCommunityAddresses, xn as PageSortFileSchema } from "./util-CUZ1U2Go.js";
|
|
2
2
|
//#region dist/node/pages/page-sort-scoring.js
|
|
3
3
|
function validatePageSortFile(rawFile) {
|
|
4
4
|
const validated = PageSortFileSchema.parse(rawFile);
|
package/dist/bundled/chunks/{rpc-local-community-WnhiTbxm.js → rpc-local-community-Byj5ZmMa.js}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { i as __toESM, n as __exportAll, r as __require, t as __commonJSMin } from "./chunk-2rV9d50f.js";
|
|
2
|
-
import { $n as CommentEditSignedPropertyNames, $r as record, $t as CommunityEditPubsubMessagePublicationSchema, A as isIpnsPath, An as CommentChallengeRequestToEncryptSchema, Ar as t$9, At as pTimeout, B as pubsubTopicToDhtKey, Bn as CommentUpdateSchema, Br as logger_default, C as hideClassPrivateProps, Cn as RpcRemoteCommunityUpdateEventResultSchema, Cr as e$5, D as isIpfsCid, Dr as n$8, Dt as untrackUpdatingCommunity, E as isAbortError, En as VotePubsubMessagePublicationSchema, Er as t$12, Fn as CommentSignedPropertyNames, Fr as FailedToFetchCommunityFromGatewaysError, Gn as GetPageParamSchema, Gr as array, Gt as NameResolverSerializedSchema, H as raceAgainstAbort, Hr as require_ms$1, Ht as DecryptedChallengeSchema, In as CommentUpdateChallengeReservedFieldNames, Ir as FailedToFetchGenericIpfsFromGatewaysError, It as ChallengeRequestMessageSignedPropertyNames, Jn as isReservedObjectKey, Jr as literal, Jt as PKCUserOptionsSchema, Kn as ModQueuePageIpfsSchema, Kr as boolean, Kt as PKCParsedOptionsSchema, L as isRequestPubsubPublicationOfPost, Lr as FailedToFetchPageIpfsFromGatewaysError, Mn as CommentIpfsSchema, Mr as require_retry$2, Mt as ChallengeAnswerMessageSignedPropertyNames, Nr as FailedToFetchCommentIpfsFromGatewaysError, O as isIpfsPath, On as VoteSignedPropertyNames, Or as r$7, Ot as require_sha256$1, Pn as CommentPubsubMessageWithFlexibleAuthorRefinementSchema, Pr as FailedToFetchCommentUpdateFromGatewaysError, Pt as ChallengeMessageSignedPropertyNames, Qr as preprocess, Qt as CommunityEditPublicationSignedPropertyNames, R as isRequestPubsubPublicationOfReply, Rn as CommentUpdateForChallengeVerificationSignedPropertyNames, Rr as PKCError, Rt as ChallengeVerificationMessageSignedPropertyNames, S as hasTransientNetworkErrorCode, Sr as e$6, St as trackStartedCommunity, T as ipnsNameToIpnsOverPubsubTopic, Tn as VoteChallengeRequestToEncryptSchema, Tr as r$8, Tt as untrackStartedCommunity, Ut as DecryptedChallengeVerificationSchema, Vn as CommentUpdateSignedPropertyNames, Vr as require_supports_color, Wn as CreateCommentOptionsWithRefinementSchema, Wr as _enum, Wt as NameResolveCacheOptionsSchema, Xr as number, Xt as CommunityEditPublicationChallengeRequestToEncryptSchema, Yn as CommentEditChallengeRequestToEncryptSchema, Yr as looseObject, Zn as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema, Zr as object, _n as CreateRemoteCommunityFunctionArgumentSchema, _r as n$9, an as CommentModerationsTableRowSchema, ar as AuthorReservedFields, at as throwIfAbortSignalAborted, bn as PageSortFileFactorySchema, bt as refreshTrackedCommunityAliases, cn as ChallengeFileSchema, cr as CidStringSchema, d as deepMergeRuntimeFields, dn as CommunityEditOptionsSchema, dr as CreateSignerSchema, ei as string, en as CreateCommunityEditPublicationOptionsWithRefinementSchema, f as derivePublicationFromChallengeRequest, fn as CommunityExportRecordsSchema, fr as JsonSignatureSchema, ft as findStartedCommunity, gn as CreateNewLocalCommunityUserOptionsSchema, gr as isStringDomain, h as fetchAndValidateIpnsRecordFromGateway, hn as CommunitySignedPropertyNames, hr as areEquivalentNames, ht as forgetTrackedUpdatingCommunityName, in as CommentModerationSignedPropertyNames, ir as AuthorPubsubSchema, jn as CommentIpfsReservedFields, jr as e$4, k as isIpns, kr as t$10, lr as CommunityAddressSchema, m as extractNetworkErrorDetails, mn as CommunityIpfsSchema, mr as ProtocolVersionSchema, mt as findUpdatingCommunity, nn as CommentModerationPubsubMessagePublicationSchema, nr as AuthorAddressSchema, nt as shortifyCid, on as CreateCommentModerationOptionsWithRefinementSchema, or as ChallengeAnswersSchema, ot as timestamp, p as doesDomainAddressHaveCapitalLetter, pn as CommunityIpfsReservedFields, pr as PKCTimestampSchema, q as removeNullUndefinedEmptyObjectsValuesRecursively, qn as PageIpfsSchema, qr as custom, qt as PKCUserOptionBaseSchema, r as calculateIpfsCidV0, rr as AuthorCommentIpfsReservedFields, rt as sleepUntilTimeoutOrAbort, sn as ChallengeFileFactorySchema, sr as CidPathSchema, t as areEquivalentCommunityAddresses, ti as union, tn as CommentModerationChallengeRequestToEncryptSchema, tr as CreateCommentEditOptionsWithRefinementSchema, tt as shortifyAddress, u as createAbortError, un as CommunityChallengeSettingSchema, ur as CommunityAuthorChallengeReservedFieldNames, vn as CreateRpcCommunityFunctionArgumentSchema, w as interruptibleSleep, wn as CreateVoteUserOptionsWithRefinementSchema, wr as t$11, wt as trackUpdatingCommunity, xn as PageSortFileSchema, xr as t$13, yn as ExportCommunityModLogsOptionsSchema, yr as n$10, z as linkAbortSignals, zn as CommentUpdateReservedFields, zr as messages, zt as DecryptedChallengeAnswerSchema } from "./util-
|
|
2
|
+
import { $n as CommentEditSignedPropertyNames, $r as record, $t as CommunityEditPubsubMessagePublicationSchema, A as isIpnsPath, An as CommentChallengeRequestToEncryptSchema, Ar as t$9, At as pTimeout, B as pubsubTopicToDhtKey, Bn as CommentUpdateSchema, Br as logger_default, C as hideClassPrivateProps, Cn as RpcRemoteCommunityUpdateEventResultSchema, Cr as e$5, D as isIpfsCid, Dr as n$8, Dt as untrackUpdatingCommunity, E as isAbortError, En as VotePubsubMessagePublicationSchema, Er as t$12, Fn as CommentSignedPropertyNames, Fr as FailedToFetchCommunityFromGatewaysError, Gn as GetPageParamSchema, Gr as array, Gt as NameResolverSerializedSchema, H as raceAgainstAbort, Hr as require_ms$1, Ht as DecryptedChallengeSchema, In as CommentUpdateChallengeReservedFieldNames, Ir as FailedToFetchGenericIpfsFromGatewaysError, It as ChallengeRequestMessageSignedPropertyNames, Jn as isReservedObjectKey, Jr as literal, Jt as PKCUserOptionsSchema, Kn as ModQueuePageIpfsSchema, Kr as boolean, Kt as PKCParsedOptionsSchema, L as isRequestPubsubPublicationOfPost, Lr as FailedToFetchPageIpfsFromGatewaysError, Mn as CommentIpfsSchema, Mr as require_retry$2, Mt as ChallengeAnswerMessageSignedPropertyNames, Nr as FailedToFetchCommentIpfsFromGatewaysError, O as isIpfsPath, On as VoteSignedPropertyNames, Or as r$7, Ot as require_sha256$1, Pn as CommentPubsubMessageWithFlexibleAuthorRefinementSchema, Pr as FailedToFetchCommentUpdateFromGatewaysError, Pt as ChallengeMessageSignedPropertyNames, Qr as preprocess, Qt as CommunityEditPublicationSignedPropertyNames, R as isRequestPubsubPublicationOfReply, Rn as CommentUpdateForChallengeVerificationSignedPropertyNames, Rr as PKCError, Rt as ChallengeVerificationMessageSignedPropertyNames, S as hasTransientNetworkErrorCode, Sr as e$6, St as trackStartedCommunity, T as ipnsNameToIpnsOverPubsubTopic, Tn as VoteChallengeRequestToEncryptSchema, Tr as r$8, Tt as untrackStartedCommunity, Ut as DecryptedChallengeVerificationSchema, Vn as CommentUpdateSignedPropertyNames, Vr as require_supports_color, Wn as CreateCommentOptionsWithRefinementSchema, Wr as _enum, Wt as NameResolveCacheOptionsSchema, Xr as number, Xt as CommunityEditPublicationChallengeRequestToEncryptSchema, Yn as CommentEditChallengeRequestToEncryptSchema, Yr as looseObject, Zn as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema, Zr as object, _n as CreateRemoteCommunityFunctionArgumentSchema, _r as n$9, an as CommentModerationsTableRowSchema, ar as AuthorReservedFields, at as throwIfAbortSignalAborted, bn as PageSortFileFactorySchema, bt as refreshTrackedCommunityAliases, cn as ChallengeFileSchema, cr as CidStringSchema, d as deepMergeRuntimeFields, dn as CommunityEditOptionsSchema, dr as CreateSignerSchema, ei as string, en as CreateCommunityEditPublicationOptionsWithRefinementSchema, f as derivePublicationFromChallengeRequest, fn as CommunityExportRecordsSchema, fr as JsonSignatureSchema, ft as findStartedCommunity, gn as CreateNewLocalCommunityUserOptionsSchema, gr as isStringDomain, h as fetchAndValidateIpnsRecordFromGateway, hn as CommunitySignedPropertyNames, hr as areEquivalentNames, ht as forgetTrackedUpdatingCommunityName, in as CommentModerationSignedPropertyNames, ir as AuthorPubsubSchema, jn as CommentIpfsReservedFields, jr as e$4, k as isIpns, kr as t$10, lr as CommunityAddressSchema, m as extractNetworkErrorDetails, mn as CommunityIpfsSchema, mr as ProtocolVersionSchema, mt as findUpdatingCommunity, nn as CommentModerationPubsubMessagePublicationSchema, nr as AuthorAddressSchema, nt as shortifyCid, on as CreateCommentModerationOptionsWithRefinementSchema, or as ChallengeAnswersSchema, ot as timestamp, p as doesDomainAddressHaveCapitalLetter, pn as CommunityIpfsReservedFields, pr as PKCTimestampSchema, q as removeNullUndefinedEmptyObjectsValuesRecursively, qn as PageIpfsSchema, qr as custom, qt as PKCUserOptionBaseSchema, r as calculateIpfsCidV0, rr as AuthorCommentIpfsReservedFields, rt as sleepUntilTimeoutOrAbort, sn as ChallengeFileFactorySchema, sr as CidPathSchema, t as areEquivalentCommunityAddresses, ti as union, tn as CommentModerationChallengeRequestToEncryptSchema, tr as CreateCommentEditOptionsWithRefinementSchema, tt as shortifyAddress, u as createAbortError, un as CommunityChallengeSettingSchema, ur as CommunityAuthorChallengeReservedFieldNames, vn as CreateRpcCommunityFunctionArgumentSchema, w as interruptibleSleep, wn as CreateVoteUserOptionsWithRefinementSchema, wr as t$11, wt as trackUpdatingCommunity, xn as PageSortFileSchema, xr as t$13, yn as ExportCommunityModLogsOptionsSchema, yr as n$10, z as linkAbortSignals, zn as CommentUpdateReservedFields, zr as messages, zt as DecryptedChallengeAnswerSchema } from "./util-CUZ1U2Go.js";
|
|
3
3
|
import { t as all } from "./src-CYIMjhjK.js";
|
|
4
|
-
import { s as validatePageSortFile } from "./page-sort-scoring-
|
|
4
|
+
import { s as validatePageSortFile } from "./page-sort-scoring-NpdjWYfa.js";
|
|
5
5
|
import { createHash } from "node:crypto";
|
|
6
6
|
import { pathToFileURL } from "node:url";
|
|
7
7
|
import dns from "node:dns";
|
|
@@ -153765,10 +153765,16 @@ var esm_exports = /* @__PURE__ */ __exportAll({
|
|
|
153765
153765
|
const { RateLimiter } = esm_exports;
|
|
153766
153766
|
const rateLimiters = new import_quick_lru.default({ maxSize: 5e4 });
|
|
153767
153767
|
const getPublicationType = (request) => isPost(request) ? "post" : isReply(request) ? "reply" : isVote(request) ? "vote" : isCommentEdit(request) ? "commentEdit" : isCommentModeration(request) ? "commentModeration" : isCommunityEdit(request) ? "communityEdit" : void 0;
|
|
153768
|
-
const getRateLimiterName = (exclude, publication, publicationType, challengeSuccess) =>
|
|
153769
|
-
|
|
153768
|
+
const getRateLimiterName = (communityAddress, exclude, publication, publicationType, challengeSuccess) => JSON.stringify([
|
|
153769
|
+
communityAddress,
|
|
153770
|
+
publication.author.address,
|
|
153771
|
+
exclude.rateLimit,
|
|
153772
|
+
publicationType,
|
|
153773
|
+
challengeSuccess
|
|
153774
|
+
]);
|
|
153775
|
+
const getOrCreateRateLimiter = (communityAddress, exclude, publication, publicationType, challengeSuccess) => {
|
|
153770
153776
|
if (typeof exclude.rateLimit !== "number") throw Error("Can't create a RateLimiter without exclude.rateLimit");
|
|
153771
|
-
const rateLimiterName = getRateLimiterName(exclude, publication, publicationType, challengeSuccess);
|
|
153777
|
+
const rateLimiterName = getRateLimiterName(communityAddress, exclude, publication, publicationType, challengeSuccess);
|
|
153772
153778
|
let rateLimiter = rateLimiters.get(rateLimiterName);
|
|
153773
153779
|
if (!rateLimiter) {
|
|
153774
153780
|
rateLimiter = new RateLimiter({
|
|
@@ -153781,47 +153787,47 @@ const getOrCreateRateLimiter = (exclude, publication, publicationType, challenge
|
|
|
153781
153787
|
}
|
|
153782
153788
|
return rateLimiter;
|
|
153783
153789
|
};
|
|
153784
|
-
const addFilteredRateLimiter = (exclude, publication, publicationType, challengeSuccess, filteredRateLimiters) => {
|
|
153785
|
-
filteredRateLimiters[getRateLimiterName(exclude, publication, publicationType, challengeSuccess)] = getOrCreateRateLimiter(exclude, publication, publicationType, challengeSuccess);
|
|
153790
|
+
const addFilteredRateLimiter = (communityAddress, exclude, publication, publicationType, challengeSuccess, filteredRateLimiters) => {
|
|
153791
|
+
filteredRateLimiters[getRateLimiterName(communityAddress, exclude, publication, publicationType, challengeSuccess)] = getOrCreateRateLimiter(communityAddress, exclude, publication, publicationType, challengeSuccess);
|
|
153786
153792
|
};
|
|
153787
|
-
const getRateLimitersToTest = (exclude, request, challengeSuccess) => {
|
|
153793
|
+
const getRateLimitersToTest = (exclude, request, challengeSuccess, communityAddress) => {
|
|
153788
153794
|
const publication = derivePublicationFromChallengeRequest(request);
|
|
153789
153795
|
const filteredRateLimiters = {};
|
|
153790
153796
|
if (testPublicationType(exclude.publicationType, request)) {
|
|
153791
153797
|
const publicationType = getPublicationType(request);
|
|
153792
|
-
if (publicationType) addFilteredRateLimiter(exclude, publication, publicationType, challengeSuccess, filteredRateLimiters);
|
|
153798
|
+
if (publicationType) addFilteredRateLimiter(communityAddress, exclude, publication, publicationType, challengeSuccess, filteredRateLimiters);
|
|
153793
153799
|
}
|
|
153794
153800
|
return filteredRateLimiters;
|
|
153795
153801
|
};
|
|
153796
|
-
const testRateLimit = (exclude, request) => {
|
|
153802
|
+
const testRateLimit = (exclude, request, communityAddress) => {
|
|
153797
153803
|
if (exclude?.rateLimit === void 0 || !testPublicationType(exclude.publicationType, request)) return true;
|
|
153798
153804
|
let challengeSuccess = true;
|
|
153799
153805
|
if (exclude.rateLimitChallengeSuccess === false) challengeSuccess = false;
|
|
153800
|
-
const rateLimiters = getRateLimitersToTest(exclude, request, challengeSuccess);
|
|
153806
|
+
const rateLimiters = getRateLimitersToTest(exclude, request, challengeSuccess, communityAddress);
|
|
153801
153807
|
for (const rateLimiter of Object.values(rateLimiters)) if (rateLimiter.getTokensRemaining() < 1) return false;
|
|
153802
153808
|
return true;
|
|
153803
153809
|
};
|
|
153804
|
-
const getRateLimitersToAddTo = (excludeArray, request, challengeSuccess) => {
|
|
153810
|
+
const getRateLimitersToAddTo = (excludeArray, request, challengeSuccess, communityAddress) => {
|
|
153805
153811
|
const filteredRateLimiters = {};
|
|
153806
153812
|
const publication = derivePublicationFromChallengeRequest(request);
|
|
153807
153813
|
for (const exclude of excludeArray) {
|
|
153808
153814
|
if (exclude?.rateLimit === void 0) continue;
|
|
153809
153815
|
const publicationType = getPublicationType(request);
|
|
153810
|
-
if (publicationType) addFilteredRateLimiter(exclude, publication, publicationType, challengeSuccess, filteredRateLimiters);
|
|
153811
|
-
if (request.commentEdit) addFilteredRateLimiter(exclude, publication, "commentEdit", challengeSuccess, filteredRateLimiters);
|
|
153812
|
-
if (request.commentModeration) addFilteredRateLimiter(exclude, publication, "commentModeration", challengeSuccess, filteredRateLimiters);
|
|
153813
|
-
if (request.communityEdit) addFilteredRateLimiter(exclude, publication, "communityEdit", challengeSuccess, filteredRateLimiters);
|
|
153816
|
+
if (publicationType) addFilteredRateLimiter(communityAddress, exclude, publication, publicationType, challengeSuccess, filteredRateLimiters);
|
|
153817
|
+
if (request.commentEdit) addFilteredRateLimiter(communityAddress, exclude, publication, "commentEdit", challengeSuccess, filteredRateLimiters);
|
|
153818
|
+
if (request.commentModeration) addFilteredRateLimiter(communityAddress, exclude, publication, "commentModeration", challengeSuccess, filteredRateLimiters);
|
|
153819
|
+
if (request.communityEdit) addFilteredRateLimiter(communityAddress, exclude, publication, "communityEdit", challengeSuccess, filteredRateLimiters);
|
|
153814
153820
|
}
|
|
153815
153821
|
return filteredRateLimiters;
|
|
153816
153822
|
};
|
|
153817
|
-
const addToRateLimiter = (communityChallenges, request, challengeSuccess) => {
|
|
153823
|
+
const addToRateLimiter = (communityChallenges, request, challengeSuccess, communityAddress) => {
|
|
153818
153824
|
if (!communityChallenges) return;
|
|
153819
153825
|
if (!Array.isArray(communityChallenges)) throw Error(`addToRateLimiter invalid argument communityChallenges '${communityChallenges}' not an array`);
|
|
153820
153826
|
if (typeof challengeSuccess !== "boolean") throw Error(`addToRateLimiter invalid argument challengeSuccess '${challengeSuccess}' not a boolean`);
|
|
153821
153827
|
const excludeArray = [];
|
|
153822
153828
|
for (const communityChallenge of communityChallenges) for (const exclude of communityChallenge?.exclude || []) excludeArray.push(exclude);
|
|
153823
153829
|
if (!excludeArray.length) return;
|
|
153824
|
-
const rateLimiters = getRateLimitersToAddTo(excludeArray, request, challengeSuccess);
|
|
153830
|
+
const rateLimiters = getRateLimitersToAddTo(excludeArray, request, challengeSuccess, communityAddress);
|
|
153825
153831
|
for (const rateLimiter of Object.values(rateLimiters)) rateLimiter.tryRemoveTokens(1);
|
|
153826
153832
|
};
|
|
153827
153833
|
//#endregion
|
|
@@ -153848,7 +153854,7 @@ const shouldExcludePublication = async ({ communityChallenge, request, community
|
|
|
153848
153854
|
if (!testScore(exclude.replyScore, author.community?.replyScore)) shouldExclude = false;
|
|
153849
153855
|
if (!testFirstCommentTimestamp(exclude.firstCommentTimestamp, author.community?.firstCommentTimestamp)) shouldExclude = false;
|
|
153850
153856
|
if (!testPublicationType(exclude.publicationType, request)) shouldExclude = false;
|
|
153851
|
-
if (!testRateLimit(exclude, request)) shouldExclude = false;
|
|
153857
|
+
if (!testRateLimit(exclude, request, community?.address)) shouldExclude = false;
|
|
153852
153858
|
if (exclude.publicKeys && !exclude.publicKeys.includes(identityMatcher.signerAddress)) shouldExclude = false;
|
|
153853
153859
|
if (typeof exclude.postCount === "number" || typeof exclude.replyCount === "number") {
|
|
153854
153860
|
if (!authorPublicationCounts && community?._dbHandler) authorPublicationCounts = community._dbHandler.queryAuthorPublicationCounts(identityMatcher.signerAddress);
|
|
@@ -155172,7 +155178,7 @@ const getChallengeVerification = async ({ challengeRequestMessage, community, ge
|
|
|
155172
155178
|
const failedChallengeIndexes = Object.keys(challengeVerification.challengeErrors ?? {});
|
|
155173
155179
|
const decisiveNameFailure = failedChallengeIndexes.length > 0 && identityNameFailureByIndex ? failedChallengeIndexes.every((index) => identityNameFailureByIndex[Number(index)]) ? identityNameFailureByIndex[Number(failedChallengeIndexes[0])] : void 0 : void 0;
|
|
155174
155180
|
if (challengeVerification.challengeSuccess === false && decisiveNameFailure) challengeVerification.aggregatedReason = decisiveNameFailure.reason;
|
|
155175
|
-
addToRateLimiter(community.settings?.challenges, challengeRequestMessage, challengeVerification.challengeSuccess);
|
|
155181
|
+
addToRateLimiter(community.settings?.challenges, challengeRequestMessage, challengeVerification.challengeSuccess, community.address);
|
|
155176
155182
|
const shouldSendToPendingApproval = Boolean(challengeRequestMessage.comment) && challengeVerification.challengeSuccess === true && pendingApprovalSuccess;
|
|
155177
155183
|
const postAnswerMatcherField = postAnswerAuthorIdentityMatcher ? { postAnswerAuthorIdentityMatcher } : {};
|
|
155178
155184
|
if (shouldSendToPendingApproval) return {
|
|
@@ -16556,7 +16556,7 @@ const CommunityEditPublicationPubsubReservedFields = r$2([
|
|
|
16556
16556
|
], t$3(CommunityEditPubsubMessagePublicationSchema.shape));
|
|
16557
16557
|
//#endregion
|
|
16558
16558
|
//#region dist/node/generated-version.js
|
|
16559
|
-
const version = "0.0.
|
|
16559
|
+
const version = "0.0.149";
|
|
16560
16560
|
//#endregion
|
|
16561
16561
|
//#region dist/node/version.js
|
|
16562
16562
|
const protocolVersion = ProtocolVersionSchema.parse("1.0.0");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Rr as PKCError, V as pubsubTopicToDhtKeyCid } from "./util-
|
|
1
|
+
import { Rr as PKCError, V as pubsubTopicToDhtKeyCid } from "./util-CUZ1U2Go.js";
|
|
2
2
|
import { ipnsSelector } from "ipns/selector";
|
|
3
3
|
import { ipnsValidator } from "ipns/validator";
|
|
4
4
|
import { unmarshalIPNSRecord } from "ipns";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Rr as PKCError, bn as PageSortFileFactorySchema, cn as ChallengeFileSchema, sn as ChallengeFileFactorySchema } from "./util-
|
|
2
|
-
import { s as validatePageSortFile } from "./page-sort-scoring-
|
|
1
|
+
import { Rr as PKCError, bn as PageSortFileFactorySchema, cn as ChallengeFileSchema, sn as ChallengeFileFactorySchema } from "./util-CUZ1U2Go.js";
|
|
2
|
+
import { s as validatePageSortFile } from "./page-sort-scoring-NpdjWYfa.js";
|
|
3
3
|
//#region dist/node/validate-package-factories.js
|
|
4
4
|
function validateChallengeFileFactory(factory, { name }) {
|
|
5
5
|
try {
|
package/dist/bundled/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as getShortCid, c as setNativeFunctions, i as getShortAddress, n as challenges, o as nativeFunctions, r as createAnchorIpnsRecord, s as pageSorts, t as PKC } from "./chunks/node-
|
|
1
|
+
import { a as getShortCid, c as setNativeFunctions, i as getShortAddress, n as challenges, o as nativeFunctions, r as createAnchorIpnsRecord, s as pageSorts, t as PKC } from "./chunks/node-BH_HrtON.js";
|
|
2
2
|
export { challenges, createAnchorIpnsRecord, PKC as default, getShortAddress, getShortCid, nativeFunctions, pageSorts, setNativeFunctions };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as validatePageSortFileFactory } from "./chunks/validate-package-factories-
|
|
1
|
+
import { n as validatePageSortFileFactory } from "./chunks/validate-package-factories-CkU4qFQx.js";
|
|
2
2
|
export { validatePageSortFileFactory };
|