@pkcprotocol/pkc-js 0.0.67 → 0.0.69
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 +1 -0
- package/dist/browser/clients/base-client-manager.js +4 -1
- 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 +42 -24
- package/dist/browser/helia/helia-for-pkc.js.map +1 -1
- package/dist/browser/helia/types.d.ts +3 -1
- package/dist/browser/helia/util.d.ts +20 -1
- package/dist/browser/helia/util.js +27 -5
- package/dist/browser/helia/util.js.map +1 -1
- package/dist/browser/pages/pages-client-manager.js +6 -1
- package/dist/browser/pages/pages-client-manager.js.map +1 -1
- package/dist/browser/pages/pages.d.ts +1 -0
- package/dist/browser/pages/pages.js.map +1 -1
- package/dist/browser/publications/comment/comment-client-manager.d.ts +1 -0
- package/dist/browser/publications/comment/comment-client-manager.js +18 -3
- package/dist/browser/publications/comment/comment-client-manager.js.map +1 -1
- package/dist/browser/publications/comment/comment.js +6 -1
- package/dist/browser/publications/comment/comment.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/comment-updates.d.ts +5 -1
- package/dist/browser/runtime/node/community/local-community/comment-updates.js +7 -3
- package/dist/browser/runtime/node/community/local-community/comment-updates.js.map +1 -1
- package/dist/browser/test/test-util.d.ts +1 -1
- package/dist/bundled/bundle-manifest.json +98 -96
- package/dist/bundled/chunks/{helia-for-pkc-CTxzGps-.js → helia-for-pkc-x-xe-CrX.js} +21 -17
- package/dist/bundled/chunks/{local-community-T3mSbjdf.js → local-community-B6IwJoBu.js} +35 -29
- package/dist/bundled/chunks/{local-community-DJX_xmB4.js → local-community-BuseLMgO.js} +1 -1
- package/dist/bundled/chunks/{node-zemQ3e2S.js → node-Dz5IKip2.js} +6 -5
- package/dist/bundled/chunks/{rpc-local-community-ByjBdSQ5.js → rpc-local-community-D8woL19t.js} +34 -23
- package/dist/bundled/chunks/{schema-B47aYWNu.js → schema-C_l9RSe0.js} +2 -2
- package/dist/bundled/chunks/{util-P3adfecj.js → util-bpDx_Vq2.js} +13 -3
- package/dist/bundled/index.js +1 -1
- package/dist/bundled/rpc/src/index.js +4 -4
- package/dist/node/clients/base-client-manager.d.ts +1 -0
- package/dist/node/clients/base-client-manager.js +4 -1
- 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 +42 -24
- package/dist/node/helia/helia-for-pkc.js.map +1 -1
- package/dist/node/helia/types.d.ts +3 -1
- package/dist/node/helia/util.d.ts +20 -1
- package/dist/node/helia/util.js +27 -5
- package/dist/node/helia/util.js.map +1 -1
- package/dist/node/pages/pages-client-manager.js +6 -1
- package/dist/node/pages/pages-client-manager.js.map +1 -1
- package/dist/node/pages/pages.d.ts +1 -0
- package/dist/node/pages/pages.js.map +1 -1
- package/dist/node/publications/comment/comment-client-manager.d.ts +1 -0
- package/dist/node/publications/comment/comment-client-manager.js +18 -3
- package/dist/node/publications/comment/comment-client-manager.js.map +1 -1
- package/dist/node/publications/comment/comment.js +6 -1
- package/dist/node/publications/comment/comment.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/comment-updates.d.ts +5 -1
- package/dist/node/runtime/node/community/local-community/comment-updates.js +7 -3
- package/dist/node/runtime/node/community/local-community/comment-updates.js.map +1 -1
- package/dist/node/test/test-util.d.ts +1 -1
- package/package.json +1 -1
- package/dist/bundled/chunks/{src-0J9-Tmgd.js → src-o_MYSn-E.js} +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { L as hideClassPrivateProps, R as ipnsNameToIpnsOverPubsubTopic, _r as PKCError, yr as logger_default } from "./schema-
|
|
2
|
-
import {
|
|
1
|
+
import { L as hideClassPrivateProps, R as ipnsNameToIpnsOverPubsubTopic, _r as PKCError, yr as logger_default } from "./schema-C_l9RSe0.js";
|
|
2
|
+
import { a as selectBitswapSessionSeedPeers, i as getHeliaDebugContext, n as connectToPubsubPeers, r as directFetchIpnsRecordFromProviders, t as cacheIpnsRecordInPubsubLocalStore } from "./util-bpDx_Vq2.js";
|
|
3
3
|
import { CID } from "multiformats/cid";
|
|
4
4
|
import { peerIdFromString } from "@libp2p/peer-id";
|
|
5
5
|
import { EventEmitter as EventEmitter$1 } from "events";
|
|
@@ -130,20 +130,12 @@ async function createLibp2pJsClientOrUseExistingOne(pkcOptions) {
|
|
|
130
130
|
return ipfsPathOrCid;
|
|
131
131
|
};
|
|
132
132
|
const MAX_BITSWAP_SESSION_SEED_PEERS = 3;
|
|
133
|
-
const
|
|
134
|
-
const recentIpnsRecordServerPeerIdStrings = [];
|
|
135
|
-
const rememberIpnsRecordServerPeer = (peerIdString) => {
|
|
136
|
-
const existingIndex = recentIpnsRecordServerPeerIdStrings.indexOf(peerIdString);
|
|
137
|
-
if (existingIndex !== -1) recentIpnsRecordServerPeerIdStrings.splice(existingIndex, 1);
|
|
138
|
-
recentIpnsRecordServerPeerIdStrings.unshift(peerIdString);
|
|
139
|
-
if (recentIpnsRecordServerPeerIdStrings.length > RECENT_IPNS_RECORD_SERVERS_MAX) recentIpnsRecordServerPeerIdStrings.pop();
|
|
140
|
-
};
|
|
141
|
-
const getBitswapSessionSeedPeers = () => {
|
|
133
|
+
const getBitswapSessionSeedPeers = (scopeIpnsPubsubTopic) => {
|
|
142
134
|
const pubsub = helia.libp2p.services.pubsub;
|
|
143
135
|
return selectBitswapSessionSeedPeers({
|
|
144
136
|
connectedPeers: helia.libp2p.getPeers(),
|
|
137
|
+
scopedPubsubSubscriberPeerIdStrings: scopeIpnsPubsubTopic ? pubsub.getSubscribers(scopeIpnsPubsubTopic).map(String) : [],
|
|
145
138
|
pubsubSubscriberPeerIdStrings: pubsub.getTopics().flatMap((topic) => pubsub.getSubscribers(topic).map(String)),
|
|
146
|
-
recentIpnsRecordServerPeerIdStrings,
|
|
147
139
|
maxSeeds: MAX_BITSWAP_SESSION_SEED_PEERS
|
|
148
140
|
});
|
|
149
141
|
};
|
|
@@ -189,7 +181,9 @@ async function createLibp2pJsClientOrUseExistingOne(pkcOptions) {
|
|
|
189
181
|
}, ms);
|
|
190
182
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
191
183
|
});
|
|
192
|
-
const
|
|
184
|
+
const ipnsPubsubRouter = pubsub(helia);
|
|
185
|
+
const ipnsPubsubLocalStore = ipnsPubsubRouter.localStore;
|
|
186
|
+
const ipnsNameResolver = ipns(helia, { routers: [ipnsPubsubRouter] });
|
|
193
187
|
ipnsNameResolver.routers = ipnsNameResolver.routers.filter((r) => r?.constructor?.name !== "LocalStoreRouting");
|
|
194
188
|
const WARMUP_MAX_PEERS = 4;
|
|
195
189
|
const warmupPromisesByTopic = /* @__PURE__ */ new Map();
|
|
@@ -248,8 +242,17 @@ async function createLibp2pJsClientOrUseExistingOne(pkcOptions) {
|
|
|
248
242
|
source: direct.source,
|
|
249
243
|
peerId: direct.peerId
|
|
250
244
|
};
|
|
251
|
-
|
|
252
|
-
|
|
245
|
+
const record = unmarshalIPNSRecord(direct.recordBytes);
|
|
246
|
+
try {
|
|
247
|
+
await cacheIpnsRecordInPubsubLocalStore({
|
|
248
|
+
localStore: ipnsPubsubLocalStore,
|
|
249
|
+
routingKey,
|
|
250
|
+
marshalledRecord: direct.recordBytes
|
|
251
|
+
});
|
|
252
|
+
} catch (cacheErr) {
|
|
253
|
+
log.trace("Failed to cache direct-fetched IPNS record at the pubsub routing layer for", ipnsPubsubTopic, cacheErr);
|
|
254
|
+
}
|
|
255
|
+
yield record.value;
|
|
253
256
|
return;
|
|
254
257
|
}
|
|
255
258
|
directFetchOutcome = {
|
|
@@ -322,6 +325,7 @@ async function createLibp2pJsClientOrUseExistingOne(pkcOptions) {
|
|
|
322
325
|
throwIfHeliaIsStoppingOrStopped();
|
|
323
326
|
const rootCid = CID.parse(ipfsPath.split("/")[0]);
|
|
324
327
|
const timeoutMs = parseKuboStyleTimeoutMs(options?.timeout);
|
|
328
|
+
const { bitswapSessionSeedScopeIpnsPubsubTopic, ...unixfsCatOptions } = options ?? {};
|
|
325
329
|
return (async function* () {
|
|
326
330
|
const controller = new AbortController();
|
|
327
331
|
const callerSignal = options?.signal;
|
|
@@ -334,11 +338,11 @@ async function createLibp2pJsClientOrUseExistingOne(pkcOptions) {
|
|
|
334
338
|
})), timeoutMs) : void 0;
|
|
335
339
|
try {
|
|
336
340
|
for (let attempt = 0;; attempt++) {
|
|
337
|
-
const session = helia.blockstore.createSession(rootCid, { providers: getBitswapSessionSeedPeers() });
|
|
341
|
+
const session = helia.blockstore.createSession(rootCid, { providers: getBitswapSessionSeedPeers(bitswapSessionSeedScopeIpnsPubsubTopic) });
|
|
338
342
|
let yieldedAnyBytes = false;
|
|
339
343
|
try {
|
|
340
344
|
const catIterable = unixfs({ blockstore: session }).cat(asHeliaCatCid(ipfsPath), {
|
|
341
|
-
...
|
|
345
|
+
...unixfsCatOptions,
|
|
342
346
|
signal: controller.signal
|
|
343
347
|
});
|
|
344
348
|
for await (const chunk of catIterable) {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { i as __toESM, r as __require, t as __commonJSMin } from "./chunk-2rV9d50f.js";
|
|
2
|
-
import { $ as pubsubTopicToDhtKey, $n as t$7, At as trackStartedCommunity, Bt as CommunityEditPublicationPubsubReservedFields, C as contentContainsMarkdownAudio, Ct as findUpdatingCommunity, En as CommentUpdateSchema, F as getIpnsRecordInLocalKuboNode, Fn as CommentEditPubsubMessagePublicationSchema, Ft as untrackUpdatingCommunity, G as isLinkOfAudio, Gt as CommentModerationPubsubMessagePublicationSchema, In as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema, It as require_sha256, J as isLinkOfVideo, Jt as CommentModerationsTableRowSchema, K as isLinkOfImage, Kt as CommentModerationReservedFields, L as hideClassPrivateProps, Ln as CommentEditReservedFields, M as genToArray, Mr as ZodError, Mt as trackUpdatingCommunity, N as getEquivalentCommunityAddresses, Nt as untrackStartedCommunity, O as derivePublicationFromChallengeRequest, On as CommentUpdateTableRowSchema, P as getErrorCodeFromMessage, Q as isStringDomain, Qn as n$3, R as ipnsNameToIpnsOverPubsubTopic, Rt as pTimeout, S as calculateStringSizeSameAsIpfsAddCidV0, T as contentContainsMarkdownVideos, Un as AuthorReservedFields, W as isLinkOfAnimatedImage, Xn as n$4, Y as isLinkValid, Zn as t$8, _r as PKCError, _t as timestamp, a as ChallengeRequestMessageSchema, ar as t$4, at as removeNullUndefinedValues, b as areEquivalentCommunityAddresses, bt as findCommunityInRegistry, cr as t$5, d as DecryptedChallengeRequestSchema, dr as require_retry, dt as retryKuboIpfsAddAndProvide, er as t$6, fn as VotePubsubMessagePublicationSchema, hn as VoteTablesRowSchema, ht as statMfsPathSafely, ir as r$1, k as doesDomainAddressHaveCapitalLetter, kn as CommentsTableRowSchema, kt as syncCommunityRegistryEntry, lr as t$3, lt as retryKuboBlockPutPinAndProvidePubsubTopic, mt as sleepUntilTimeoutOrAbort, nn as CommunityIpfsSchema, nr as e$1, nt as removeBlocksFromKuboNode, pn as VotePubsubReservedFields, q as isLinkOfMedia, r as ChallengeMessageSchema, rn as CommunitySignedPropertyNames, rt as removeMfsFilesSafely, s as ChallengeVerificationMessageSchema, t as ChallengeAnswerMessageSchema, tr as e, u as DecryptedChallengeRequestPublicationSchema, vn as CommentIpfsSchema, vr as messages, w as contentContainsMarkdownImages, x as calculateIpfsCidV0, xt as findStartedCommunity, y as version_default, yn as CommentPubsubMessageReservedFields, yr as logger_default, yt as writeKuboFilesWithTimeout, zn as CommentEditsTableRowSchema } from "./schema-
|
|
3
|
-
import { $n as t$10, A as deriveDbPosts, At as verifyCommunityEdit, Bt as getCommunityPublicKeyFromWire, C as BackupAbortError, Dt as verifyCommentPubsubMessage, E as calculateInlineRepliesBudget, Et as verifyCommentModeration, F as importSignerIntoKuboNode, Ft as getAuthorNameFromWire, G as REPLY_REPLIES_SORT_TYPES, Gt as getIpfsKeyFromPrivateKey, Ht as decode, Jn as r$2, Jt as getPublicKeyFromPrivateKey, K as TIMEFRAMES_TO_SECONDS, Kn as t$9, Kt as getPKCAddressFromPublicKey, M as getDefaultCommunityDbConfig, Mt as buildRuntimeAuthor, Nt as cleanWireAuthor, O as deleteOldCommunityInWindows, Ot as verifyCommentUpdate, P as getThumbnailPropsOfLink, R as moveCommunityDbToDeletedDirectory, S as encryptEd25519AesGcmPublicKeyBuffer, St as verifyChallengeRequest, T as calculateExpectedSignatureSize, Tt as verifyCommentIpfs, U as POSTS_SORT_TYPES, Ut as encode, W as POST_REPLIES_SORT_TYPES, Xn as n$6, Yn as t$11, Yt as createSchemaRowParser, Z as iterateOverPageCidsToFindAllCids, Zn as n$5, _ as SignerWithPublicKeyAddress, _t as signCommunity, a as pkcJsChallenges, b as decryptEd25519AesGcmPublicKeyBuffer, bt as verifyChallengeAnswer, cn as parseCommunityIpfsSchemaPassthroughWithPKCErrorIfItFails, d as MAX_FILE_SIZE_BYTES_FOR_COMMUNITY_IPFS, dt as signChallengeVerification, er as stringify, f as KeyvBetterSqlite3, ft as signComment, gt as signCommentUpdateForChallengeVerification, ht as signCommentUpdate, i as getCommunityChallengeFromCommunityChallengeSettings, it as pLimit, j as deriveDbReplies, jt as verifyVote, k as deriveCommentIpfsFromCommentTableRow, kt as verifyCommunity, l as normalizeSelfAddrsForProvider, lt as signChallengeMessage, nr as require_lodash_merge, o as TrackedInstanceRegistry, on as parseCommunityEditOptionsSchemaWithPKCErrorIfItFails, pt as signCommentEdit, qn as t$12, qt as getPKCAddressFromPublicKeySync, r as getChallengeVerification, s as LRUCache, st as cleanUpBeforePublishing, t as RpcLocalCommunity, tr as STORAGE_KEYS, vn as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, w as backupCommunityDb, wt as verifyCommentEdit, xn as parseJsonWithPKCErrorIfFails, z as resolveDbPostsCidRefs, zt as getCommunityNameFromWire } from "./rpc-local-community-
|
|
2
|
+
import { $ as pubsubTopicToDhtKey, $n as t$7, At as trackStartedCommunity, Bt as CommunityEditPublicationPubsubReservedFields, C as contentContainsMarkdownAudio, Ct as findUpdatingCommunity, En as CommentUpdateSchema, F as getIpnsRecordInLocalKuboNode, Fn as CommentEditPubsubMessagePublicationSchema, Ft as untrackUpdatingCommunity, G as isLinkOfAudio, Gt as CommentModerationPubsubMessagePublicationSchema, In as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema, It as require_sha256, J as isLinkOfVideo, Jt as CommentModerationsTableRowSchema, K as isLinkOfImage, Kt as CommentModerationReservedFields, L as hideClassPrivateProps, Ln as CommentEditReservedFields, M as genToArray, Mr as ZodError, Mt as trackUpdatingCommunity, N as getEquivalentCommunityAddresses, Nt as untrackStartedCommunity, O as derivePublicationFromChallengeRequest, On as CommentUpdateTableRowSchema, P as getErrorCodeFromMessage, Q as isStringDomain, Qn as n$3, R as ipnsNameToIpnsOverPubsubTopic, Rt as pTimeout, S as calculateStringSizeSameAsIpfsAddCidV0, T as contentContainsMarkdownVideos, Un as AuthorReservedFields, W as isLinkOfAnimatedImage, Xn as n$4, Y as isLinkValid, Zn as t$8, _r as PKCError, _t as timestamp, a as ChallengeRequestMessageSchema, ar as t$4, at as removeNullUndefinedValues, b as areEquivalentCommunityAddresses, bt as findCommunityInRegistry, cr as t$5, d as DecryptedChallengeRequestSchema, dr as require_retry, dt as retryKuboIpfsAddAndProvide, er as t$6, fn as VotePubsubMessagePublicationSchema, hn as VoteTablesRowSchema, ht as statMfsPathSafely, ir as r$1, k as doesDomainAddressHaveCapitalLetter, kn as CommentsTableRowSchema, kt as syncCommunityRegistryEntry, lr as t$3, lt as retryKuboBlockPutPinAndProvidePubsubTopic, mt as sleepUntilTimeoutOrAbort, nn as CommunityIpfsSchema, nr as e$1, nt as removeBlocksFromKuboNode, pn as VotePubsubReservedFields, q as isLinkOfMedia, r as ChallengeMessageSchema, rn as CommunitySignedPropertyNames, rt as removeMfsFilesSafely, s as ChallengeVerificationMessageSchema, t as ChallengeAnswerMessageSchema, tr as e, u as DecryptedChallengeRequestPublicationSchema, vn as CommentIpfsSchema, vr as messages, w as contentContainsMarkdownImages, x as calculateIpfsCidV0, xt as findStartedCommunity, y as version_default, yn as CommentPubsubMessageReservedFields, yr as logger_default, yt as writeKuboFilesWithTimeout, zn as CommentEditsTableRowSchema } from "./schema-C_l9RSe0.js";
|
|
3
|
+
import { $n as t$10, A as deriveDbPosts, At as verifyCommunityEdit, Bt as getCommunityPublicKeyFromWire, C as BackupAbortError, Dt as verifyCommentPubsubMessage, E as calculateInlineRepliesBudget, Et as verifyCommentModeration, F as importSignerIntoKuboNode, Ft as getAuthorNameFromWire, G as REPLY_REPLIES_SORT_TYPES, Gt as getIpfsKeyFromPrivateKey, Ht as decode, Jn as r$2, Jt as getPublicKeyFromPrivateKey, K as TIMEFRAMES_TO_SECONDS, Kn as t$9, Kt as getPKCAddressFromPublicKey, M as getDefaultCommunityDbConfig, Mt as buildRuntimeAuthor, Nt as cleanWireAuthor, O as deleteOldCommunityInWindows, Ot as verifyCommentUpdate, P as getThumbnailPropsOfLink, R as moveCommunityDbToDeletedDirectory, S as encryptEd25519AesGcmPublicKeyBuffer, St as verifyChallengeRequest, T as calculateExpectedSignatureSize, Tt as verifyCommentIpfs, U as POSTS_SORT_TYPES, Ut as encode, W as POST_REPLIES_SORT_TYPES, Xn as n$6, Yn as t$11, Yt as createSchemaRowParser, Z as iterateOverPageCidsToFindAllCids, Zn as n$5, _ as SignerWithPublicKeyAddress, _t as signCommunity, a as pkcJsChallenges, b as decryptEd25519AesGcmPublicKeyBuffer, bt as verifyChallengeAnswer, cn as parseCommunityIpfsSchemaPassthroughWithPKCErrorIfItFails, d as MAX_FILE_SIZE_BYTES_FOR_COMMUNITY_IPFS, dt as signChallengeVerification, er as stringify, f as KeyvBetterSqlite3, ft as signComment, gt as signCommentUpdateForChallengeVerification, ht as signCommentUpdate, i as getCommunityChallengeFromCommunityChallengeSettings, it as pLimit, j as deriveDbReplies, jt as verifyVote, k as deriveCommentIpfsFromCommentTableRow, kt as verifyCommunity, l as normalizeSelfAddrsForProvider, lt as signChallengeMessage, nr as require_lodash_merge, o as TrackedInstanceRegistry, on as parseCommunityEditOptionsSchemaWithPKCErrorIfItFails, pt as signCommentEdit, qn as t$12, qt as getPKCAddressFromPublicKeySync, r as getChallengeVerification, s as LRUCache, st as cleanUpBeforePublishing, t as RpcLocalCommunity, tr as STORAGE_KEYS, vn as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, w as backupCommunityDb, wt as verifyCommentEdit, xn as parseJsonWithPKCErrorIfFails, z as resolveDbPostsCidRefs, zt as getCommunityNameFromWire } from "./rpc-local-community-D8woL19t.js";
|
|
4
4
|
import { randomFillSync, randomUUID } from "node:crypto";
|
|
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 { existsSync, promises } from "node:fs";
|
|
9
|
-
import path from "path";
|
|
9
|
+
import path$1 from "path";
|
|
10
10
|
import assert from "assert";
|
|
11
11
|
import fs from "fs";
|
|
12
12
|
import Database from "better-sqlite3";
|
|
@@ -77,7 +77,8 @@ function calculateLocalMfsPathForCommentUpdate(community, postDbComment, timesta
|
|
|
77
77
|
"update"
|
|
78
78
|
].join("/");
|
|
79
79
|
}
|
|
80
|
-
async function calculateNewCommentUpdate(
|
|
80
|
+
async function calculateNewCommentUpdate(opts) {
|
|
81
|
+
const { community, comment, batchStartTimestamp } = opts;
|
|
81
82
|
const log = logger_default("pkc-js:local-community:_calculateNewCommentUpdate");
|
|
82
83
|
log.trace(`Attempting to calculate new CommentUpdate for comment (${comment.cid}) on community`, community.address);
|
|
83
84
|
const storedCommentUpdate = community._dbHandler.queryCommentUpdateTimestampBucketReplies({ cid: comment.cid });
|
|
@@ -139,7 +140,7 @@ async function calculateNewCommentUpdate(community, comment) {
|
|
|
139
140
|
}),
|
|
140
141
|
postUpdatesBucket: newPostUpdateBucket,
|
|
141
142
|
publishedToPostUpdatesMFS: false,
|
|
142
|
-
insertedAt:
|
|
143
|
+
insertedAt: batchStartTimestamp
|
|
143
144
|
},
|
|
144
145
|
localMfsPath: newLocalMfsPath,
|
|
145
146
|
pendingApproval: comment.pendingApproval
|
|
@@ -166,6 +167,7 @@ async function validateCommentUpdateSignature(community, newCommentUpdate, comme
|
|
|
166
167
|
}
|
|
167
168
|
async function updateCommentsThatNeedToBeUpdated(community) {
|
|
168
169
|
const log = logger_default(`pkc-js:local-community:_updateCommentsThatNeedToBeUpdated`);
|
|
170
|
+
const batchStartTimestamp = timestamp();
|
|
169
171
|
const commentsToUpdate = community._dbHandler.queryCommentsToBeUpdated();
|
|
170
172
|
if (commentsToUpdate.length === 0) return [];
|
|
171
173
|
community._communityUpdateTrigger = true;
|
|
@@ -181,7 +183,11 @@ async function updateCommentsThatNeedToBeUpdated(community) {
|
|
|
181
183
|
for (const depthKey of depthsKeySorted) {
|
|
182
184
|
const commentsAtDepth = commentsByDepth[depthKey];
|
|
183
185
|
const depthLimit = pLimit(50);
|
|
184
|
-
const depthUpdatePromises = commentsAtDepth.map((comment) => depthLimit(async () => await calculateNewCommentUpdate(
|
|
186
|
+
const depthUpdatePromises = commentsAtDepth.map((comment) => depthLimit(async () => await calculateNewCommentUpdate({
|
|
187
|
+
community,
|
|
188
|
+
comment,
|
|
189
|
+
batchStartTimestamp
|
|
190
|
+
})));
|
|
185
191
|
const depthResults = await Promise.all(depthUpdatePromises);
|
|
186
192
|
community._dbHandler.upsertCommentUpdates(depthResults.map((r) => r.newCommentUpdateToWriteToDb));
|
|
187
193
|
postUpdateRows.push(...depthResults);
|
|
@@ -3273,9 +3279,9 @@ var DbHandler = class {
|
|
|
3273
3279
|
if (needToMigrate) {
|
|
3274
3280
|
if (dbExistsAlready && currentDbVersion > 0) {
|
|
3275
3281
|
this.destoryConnection();
|
|
3276
|
-
backupDbPath = path.join(path.dirname(dbPath), ".backup_before_migration", `${path.basename(dbPath)}.${currentDbVersion}.${timestamp()}`);
|
|
3277
|
-
log(`Copying db ${path.basename(dbPath)} to ${backupDbPath} before migration`);
|
|
3278
|
-
if (!fs.existsSync(path.dirname(backupDbPath))) await fs.promises.mkdir(path.dirname(backupDbPath), { recursive: true });
|
|
3282
|
+
backupDbPath = path$1.join(path$1.dirname(dbPath), ".backup_before_migration", `${path$1.basename(dbPath)}.${currentDbVersion}.${timestamp()}`);
|
|
3283
|
+
log(`Copying db ${path$1.basename(dbPath)} to ${backupDbPath} before migration`);
|
|
3284
|
+
if (!fs.existsSync(path$1.dirname(backupDbPath))) await fs.promises.mkdir(path$1.dirname(backupDbPath), { recursive: true });
|
|
3279
3285
|
const sourceDb = new Database(dbPath, { fileMustExist: true });
|
|
3280
3286
|
await sourceDb.backup(backupDbPath);
|
|
3281
3287
|
sourceDb.close();
|
|
@@ -5078,10 +5084,10 @@ var DbHandler = class {
|
|
|
5078
5084
|
if (this._db || this._keyv) await this.destoryConnection();
|
|
5079
5085
|
this._transactionDepth = 0;
|
|
5080
5086
|
const dataPath = this._community._pkc.dataPath;
|
|
5081
|
-
const oldPathString = path.join(dataPath, "communities", oldDbName);
|
|
5082
|
-
const newPathString = path.join(dataPath, "communities", newDbName);
|
|
5083
|
-
await fs.promises.mkdir(path.dirname(oldPathString), { recursive: true });
|
|
5084
|
-
await fs.promises.mkdir(path.dirname(newPathString), { recursive: true });
|
|
5087
|
+
const oldPathString = path$1.join(dataPath, "communities", oldDbName);
|
|
5088
|
+
const newPathString = path$1.join(dataPath, "communities", newDbName);
|
|
5089
|
+
await fs.promises.mkdir(path$1.dirname(oldPathString), { recursive: true });
|
|
5090
|
+
await fs.promises.mkdir(path$1.dirname(newPathString), { recursive: true });
|
|
5085
5091
|
try {
|
|
5086
5092
|
if (!fs.existsSync(oldPathString)) log(`Old DB file ${oldPathString} does not exist. Cannot backup/rename.`);
|
|
5087
5093
|
else {
|
|
@@ -5103,8 +5109,8 @@ var DbHandler = class {
|
|
|
5103
5109
|
}
|
|
5104
5110
|
async lockCommunityStart(communityAddress = this._community.address) {
|
|
5105
5111
|
const log = logger_default("pkc-js:local-community:db-handler:lock:start");
|
|
5106
|
-
const lockfilePath = path.join(this._community._pkc.dataPath, "communities", `${communityAddress}.start.lock`);
|
|
5107
|
-
const communityDbPath = path.join(this._community._pkc.dataPath, "communities", communityAddress);
|
|
5112
|
+
const lockfilePath = path$1.join(this._community._pkc.dataPath, "communities", `${communityAddress}.start.lock`);
|
|
5113
|
+
const communityDbPath = path$1.join(this._community._pkc.dataPath, "communities", communityAddress);
|
|
5108
5114
|
try {
|
|
5109
5115
|
await import_src.default.lock(communityDbPath, {
|
|
5110
5116
|
lockfilePath,
|
|
@@ -5125,8 +5131,8 @@ var DbHandler = class {
|
|
|
5125
5131
|
async unlockCommunityStart(communityAddress = this._community.address) {
|
|
5126
5132
|
const log = logger_default("pkc-js:local-community:db-handler:unlock:start");
|
|
5127
5133
|
log.trace(`Attempting to unlock the start of community (${communityAddress})`);
|
|
5128
|
-
const lockfilePath = path.join(this._community._pkc.dataPath, "communities", `${communityAddress}.start.lock`);
|
|
5129
|
-
const communityDbPath = path.join(this._community._pkc.dataPath, "communities", communityAddress);
|
|
5134
|
+
const lockfilePath = path$1.join(this._community._pkc.dataPath, "communities", `${communityAddress}.start.lock`);
|
|
5135
|
+
const communityDbPath = path$1.join(this._community._pkc.dataPath, "communities", communityAddress);
|
|
5130
5136
|
if (!fs.existsSync(lockfilePath) || !fs.existsSync(communityDbPath)) return;
|
|
5131
5137
|
try {
|
|
5132
5138
|
await import_src.default.unlock(communityDbPath, { lockfilePath });
|
|
@@ -5137,8 +5143,8 @@ var DbHandler = class {
|
|
|
5137
5143
|
}
|
|
5138
5144
|
}
|
|
5139
5145
|
async isCommunityStartLocked(communityAddress = this._community.address) {
|
|
5140
|
-
const lockfilePath = path.join(this._community._pkc.dataPath, "communities", `${communityAddress}.start.lock`);
|
|
5141
|
-
const communityDbPath = path.join(this._community._pkc.dataPath, "communities", communityAddress);
|
|
5146
|
+
const lockfilePath = path$1.join(this._community._pkc.dataPath, "communities", `${communityAddress}.start.lock`);
|
|
5147
|
+
const communityDbPath = path$1.join(this._community._pkc.dataPath, "communities", communityAddress);
|
|
5142
5148
|
return await import_src.default.check(communityDbPath, {
|
|
5143
5149
|
lockfilePath,
|
|
5144
5150
|
realpath: false,
|
|
@@ -5147,8 +5153,8 @@ var DbHandler = class {
|
|
|
5147
5153
|
}
|
|
5148
5154
|
async lockCommunityState() {
|
|
5149
5155
|
const log = logger_default("pkc-js:local-community:db-handler:lock:lockCommunityState");
|
|
5150
|
-
const lockfilePath = path.join(this._community._pkc.dataPath, "communities", `${this._community.address}.state.lock`);
|
|
5151
|
-
const communityDbPath = path.join(this._community._pkc.dataPath, "communities", this._community.address);
|
|
5156
|
+
const lockfilePath = path$1.join(this._community._pkc.dataPath, "communities", `${this._community.address}.state.lock`);
|
|
5157
|
+
const communityDbPath = path$1.join(this._community._pkc.dataPath, "communities", this._community.address);
|
|
5152
5158
|
try {
|
|
5153
5159
|
await import_src.default.lock(communityDbPath, {
|
|
5154
5160
|
lockfilePath,
|
|
@@ -5165,8 +5171,8 @@ var DbHandler = class {
|
|
|
5165
5171
|
}
|
|
5166
5172
|
async unlockCommunityState() {
|
|
5167
5173
|
const log = logger_default("pkc-js:local-community:db-handler:lock:unlockCommunityState");
|
|
5168
|
-
const lockfilePath = path.join(this._community._pkc.dataPath, "communities", `${this._community.address}.state.lock`);
|
|
5169
|
-
const communityDbPath = path.join(this._community._pkc.dataPath, "communities", this._community.address);
|
|
5174
|
+
const lockfilePath = path$1.join(this._community._pkc.dataPath, "communities", `${this._community.address}.state.lock`);
|
|
5175
|
+
const communityDbPath = path$1.join(this._community._pkc.dataPath, "communities", this._community.address);
|
|
5170
5176
|
if (!fs.existsSync(lockfilePath)) return;
|
|
5171
5177
|
try {
|
|
5172
5178
|
await import_src.default.unlock(communityDbPath, { lockfilePath });
|
|
@@ -5176,7 +5182,7 @@ var DbHandler = class {
|
|
|
5176
5182
|
}
|
|
5177
5183
|
}
|
|
5178
5184
|
communityDbExists() {
|
|
5179
|
-
const communityDbPath = path.join(this._community._pkc.dataPath, "communities", this._community.address);
|
|
5185
|
+
const communityDbPath = path$1.join(this._community._pkc.dataPath, "communities", this._community.address);
|
|
5180
5186
|
return fs.existsSync(communityDbPath);
|
|
5181
5187
|
}
|
|
5182
5188
|
markCommentsAsPublishedToPostUpdates(commentCids) {
|
|
@@ -6867,11 +6873,11 @@ async function edit(community, newCommunityOptions) {
|
|
|
6867
6873
|
const EXPORTS_KEY = STORAGE_KEYS[STORAGE_KEYS.EXPORTS];
|
|
6868
6874
|
function defaultExportPathFor(community, exportId) {
|
|
6869
6875
|
if (typeof community._pkc.dataPath !== "string") throw new PKCError("ERR_DATA_PATH_IS_NOT_DEFINED", { communityAddress: community.address });
|
|
6870
|
-
return
|
|
6876
|
+
return path.join(community._pkc.dataPath, "exports", `${exportId}.sqlite`);
|
|
6871
6877
|
}
|
|
6872
6878
|
function sourceDbPathFor(community) {
|
|
6873
6879
|
if (typeof community._pkc.dataPath !== "string") throw new PKCError("ERR_DATA_PATH_IS_NOT_DEFINED", { communityAddress: community.address });
|
|
6874
|
-
return
|
|
6880
|
+
return path.join(community._pkc.dataPath, "communities", community.address);
|
|
6875
6881
|
}
|
|
6876
6882
|
async function persistExports(community) {
|
|
6877
6883
|
if (!community._dbHandler) return;
|
|
@@ -6947,9 +6953,9 @@ async function runExportTask(community, exportId, opts) {
|
|
|
6947
6953
|
async function exportCommunityEmbedded(community, options = {}) {
|
|
6948
6954
|
if (options.signal?.aborted) throw options.signal.reason ?? new DOMException("The operation was aborted.", "AbortError");
|
|
6949
6955
|
const exportId = v4();
|
|
6950
|
-
const destPath = options.exportPath ?
|
|
6956
|
+
const destPath = options.exportPath ? path.resolve(options.exportPath) : defaultExportPathFor(community, exportId);
|
|
6951
6957
|
const includePrivateKey = options.includePrivateKey === true;
|
|
6952
|
-
if (
|
|
6958
|
+
if (path.resolve(destPath) === path.resolve(sourceDbPathFor(community))) throw new PKCError("ERR_EXPORT_PATH_TARGETS_LIVE_DB", {
|
|
6953
6959
|
communityAddress: community.address,
|
|
6954
6960
|
exportPath: destPath
|
|
6955
6961
|
});
|
|
@@ -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-B6IwJoBu.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 { B as isIpfsCid, Cn as CommentUpdateForChallengeVerificationSchema, Ct as findUpdatingCommunity, D as deepMergeRuntimeFields, Dt as refreshTrackedCommentAliases, E as createAbortError, En as CommentUpdateSchema, Et as listUpdatingCommunities, Fr as stringifyPrimitive, It as require_sha256, L as hideClassPrivateProps, Lt as TimeoutError, Nr as joinValues, Pr as parsedType, Pt as untrackUpdatingComment, Q as isStringDomain, Qn as n$1, Rt as pTimeout, Sr as setErrorMap, St as findUpdatingComment, Tt as listUpdatingComments, Xn as n$2, _r as PKCError, _t as timestamp, a as ChallengeRequestMessageSchema, b as areEquivalentCommunityAddresses, br as require_supports_color, cn as PubsubTopicSchema, ct as resolveWhenPredicateIsTrue, dr as require_retry, er as t$1, fr as FailedToFetchCommentIpfsFromGatewaysError, ft as shortifyAddress, ir as r, jt as trackUpdatingComment, k as doesDomainAddressHaveCapitalLetter, mt as sleepUntilTimeoutOrAbort, nn as CommunityIpfsSchema, nr as e$1, ot as removeUndefinedValuesRecursively, pt as shortifyCid, r as ChallengeMessageSchema, s as ChallengeVerificationMessageSchema, st as replaceXWithY, t as ChallengeAnswerMessageSchema, tr as e, ut as retryKuboIpfsAdd, vn as CommentIpfsSchema, vr as messages, vt as waitForUpdateInCommunityInstanceWithErrorAndTimeout, wt as listStartedCommunities, xt as findStartedCommunity, y as version_default, yr as logger_default, z as isAbortError } from "./schema-
|
|
3
|
-
import { $ as RepliesPages, $n as t$5, $t as parseCommentEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, An as RpcCidParamSchema, At as verifyCommunityEdit, B as setNativeFunctions$1, Bn as RpcFetchCidResultSchema, Bt as getCommunityPublicKeyFromWire, Cn as parseRpcCommentEventWithPKCErrorIfItFails, Ct as verifyChallengeVerification, D as createKuboRpcClient, Dn as parseVotePubsubMessagePublicationSchemaWithPKCErrorIfItFails, Dt as verifyCommentPubsubMessage, Et as verifyCommentModeration, Fn as RpcExportCommunityModLogsParamSchema, Gn as RpcUnsubscribeParamSchema, H as CommentClientsManager, Hn as RpcResolveAuthorNameResultSchema, Ht as decode, I as listCommunitiesSync, In as RpcExportCommunityModLogsResultSchema, It as normalizeCreatePublicationAuthor, Kn as t$4, L as monitorCommunitiesDirectory, Ln as RpcExportCommunityParamSchema, Lt as buildRuntimeCommunityFields, Mn as RpcCommunityIdentifierParamSchema, Mt as buildRuntimeAuthor, N as getDefaultDataPath, Nn as RpcCommunityPageParamSchema, Nt as cleanWireAuthor, On as RpcAuthorNameParamSchema, Ot as verifyCommentUpdate, Pn as RpcEditCommunityParamSchema, Pt as getAuthorNameFromRuntime, Q as parseRawPages, Qn as t$2, Rn as RpcExportCommunityResultSchema, Rt as getCommunityAddressFromRecord, Sn as parsePKCUserOptionsSchemaWithPKCErrorIfItFails, Tn as parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, Tt as verifyCommentIpfs, Un as RpcSubscriptionIdResultSchema, V as tryToDeleteCommunitiesThatFailedToBeDeletedBefore, Vn as RpcPublishChallengeAnswersParamSchema, Vt as normalizeCommunityInputFromCommunity, Wn as RpcSuccessResultSchema, Wt as getBufferedPKCAddressFromPublicKey, X as findCommentInPageInstanceRecursively, Xn as n$3, Xt as parseCidStringSchemaWithPKCErrorIfItFails, Y as extractCommunityRuntimeFieldsFromParsedPages, Yn as t$3, _n as parseCreateVoteOptionsSchemaWithPKCErrorIfItFails, a as pkcJsChallenges, at as PKCTypedEmitter, bn as parseDecryptedChallengeWithPKCErrorIfItFails, c as AddressesRewriterProxyServer, ct as signChallengeAnswer, dn as parseCreateCommentOptionsSchemaWithPKCErrorIfItFails, en as parseCommentIpfsSchemaWithPKCErrorIfItFails, et as PublicationClientsManager, f as KeyvBetterSqlite3, fn as parseCreateCommunityEditPublicationOptionsSchemaWithPKCErrorIfItFails, ft as signComment, g as decodeRpcChallengeVerificationPubsubMsg, gn as parseCreateRpcCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, h as decodeRpcChallengeRequestPubsubMsg, hn as parseCreateRemoteCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, in as parseCommunityAddressWithPKCErrorIfItFails, ir as require_undici, jn as RpcCommentRepliesPageParamSchema, jt as verifyVote, kn as RpcCancelExportParamSchema, ln as parseCreateCommentEditOptionsSchemaWithPKCErrorIfItFails, m as decodeRpcChallengePubsubMsg, mt as signCommentModeration, n as RpcRemoteCommunity, nn as parseCommentModerationPubsubMessagePublicationSchemaWithPKCErrorIfItFails, nt as InflightFetchManager, o as TrackedInstanceRegistry, ot as require_lib$1, p as decodeRpcChallengeAnswerPubsubMsg, pt as signCommentEdit, rn as parseCommentPubsubMessagePublicationWithPKCErrorIfItFails, rr as nativeFunctions$2, s as LRUCache, sn as parseCommunityEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, st as cleanUpBeforePublishing, t as RpcLocalCommunity, tt as PKCClientsManager, u as RemoteCommunity, un as parseCreateCommentModerationOptionsSchemaWithPKCErrorIfItFails, ut as signChallengeRequest, v as createSigner, vn as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, vt as signCommunityEdit, wn as parseRpcCommentUpdateEventWithPKCErrorIfItFails, wt as verifyCommentEdit, x as encryptEd25519AesGcm, xn as parseJsonWithPKCErrorIfFails, xt as verifyChallengeMessage, y as decryptEd25519AesGcm, yn as parseDecryptedChallengeVerification, yt as signVote, zn as RpcFetchCidParamSchema, zt as getCommunityNameFromWire } from "./rpc-local-community-
|
|
4
|
-
import {
|
|
2
|
+
import { B as isIpfsCid, Cn as CommentUpdateForChallengeVerificationSchema, Ct as findUpdatingCommunity, D as deepMergeRuntimeFields, Dt as refreshTrackedCommentAliases, E as createAbortError, En as CommentUpdateSchema, Et as listUpdatingCommunities, Fr as stringifyPrimitive, H as isIpns, It as require_sha256, L as hideClassPrivateProps, Lt as TimeoutError, Nr as joinValues, Pr as parsedType, Pt as untrackUpdatingComment, Q as isStringDomain, Qn as n$1, R as ipnsNameToIpnsOverPubsubTopic, Rt as pTimeout, Sr as setErrorMap, St as findUpdatingComment, Tt as listUpdatingComments, Xn as n$2, _r as PKCError, _t as timestamp, a as ChallengeRequestMessageSchema, b as areEquivalentCommunityAddresses, br as require_supports_color, cn as PubsubTopicSchema, ct as resolveWhenPredicateIsTrue, dr as require_retry, er as t$1, fr as FailedToFetchCommentIpfsFromGatewaysError, ft as shortifyAddress, ir as r, jt as trackUpdatingComment, k as doesDomainAddressHaveCapitalLetter, mt as sleepUntilTimeoutOrAbort, nn as CommunityIpfsSchema, nr as e$1, ot as removeUndefinedValuesRecursively, pt as shortifyCid, r as ChallengeMessageSchema, s as ChallengeVerificationMessageSchema, st as replaceXWithY, t as ChallengeAnswerMessageSchema, tr as e, ut as retryKuboIpfsAdd, vn as CommentIpfsSchema, vr as messages, vt as waitForUpdateInCommunityInstanceWithErrorAndTimeout, wt as listStartedCommunities, xt as findStartedCommunity, y as version_default, yr as logger_default, z as isAbortError } from "./schema-C_l9RSe0.js";
|
|
3
|
+
import { $ as RepliesPages, $n as t$5, $t as parseCommentEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, An as RpcCidParamSchema, At as verifyCommunityEdit, B as setNativeFunctions$1, Bn as RpcFetchCidResultSchema, Bt as getCommunityPublicKeyFromWire, Cn as parseRpcCommentEventWithPKCErrorIfItFails, Ct as verifyChallengeVerification, D as createKuboRpcClient, Dn as parseVotePubsubMessagePublicationSchemaWithPKCErrorIfItFails, Dt as verifyCommentPubsubMessage, Et as verifyCommentModeration, Fn as RpcExportCommunityModLogsParamSchema, Gn as RpcUnsubscribeParamSchema, H as CommentClientsManager, Hn as RpcResolveAuthorNameResultSchema, Ht as decode, I as listCommunitiesSync, In as RpcExportCommunityModLogsResultSchema, It as normalizeCreatePublicationAuthor, Kn as t$4, L as monitorCommunitiesDirectory, Ln as RpcExportCommunityParamSchema, Lt as buildRuntimeCommunityFields, Mn as RpcCommunityIdentifierParamSchema, Mt as buildRuntimeAuthor, N as getDefaultDataPath, Nn as RpcCommunityPageParamSchema, Nt as cleanWireAuthor, On as RpcAuthorNameParamSchema, Ot as verifyCommentUpdate, Pn as RpcEditCommunityParamSchema, Pt as getAuthorNameFromRuntime, Q as parseRawPages, Qn as t$2, Rn as RpcExportCommunityResultSchema, Rt as getCommunityAddressFromRecord, Sn as parsePKCUserOptionsSchemaWithPKCErrorIfItFails, Tn as parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, Tt as verifyCommentIpfs, Un as RpcSubscriptionIdResultSchema, V as tryToDeleteCommunitiesThatFailedToBeDeletedBefore, Vn as RpcPublishChallengeAnswersParamSchema, Vt as normalizeCommunityInputFromCommunity, Wn as RpcSuccessResultSchema, Wt as getBufferedPKCAddressFromPublicKey, X as findCommentInPageInstanceRecursively, Xn as n$3, Xt as parseCidStringSchemaWithPKCErrorIfItFails, Y as extractCommunityRuntimeFieldsFromParsedPages, Yn as t$3, _n as parseCreateVoteOptionsSchemaWithPKCErrorIfItFails, a as pkcJsChallenges, at as PKCTypedEmitter, bn as parseDecryptedChallengeWithPKCErrorIfItFails, c as AddressesRewriterProxyServer, ct as signChallengeAnswer, dn as parseCreateCommentOptionsSchemaWithPKCErrorIfItFails, en as parseCommentIpfsSchemaWithPKCErrorIfItFails, et as PublicationClientsManager, f as KeyvBetterSqlite3, fn as parseCreateCommunityEditPublicationOptionsSchemaWithPKCErrorIfItFails, ft as signComment, g as decodeRpcChallengeVerificationPubsubMsg, gn as parseCreateRpcCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, h as decodeRpcChallengeRequestPubsubMsg, hn as parseCreateRemoteCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, in as parseCommunityAddressWithPKCErrorIfItFails, ir as require_undici, jn as RpcCommentRepliesPageParamSchema, jt as verifyVote, kn as RpcCancelExportParamSchema, ln as parseCreateCommentEditOptionsSchemaWithPKCErrorIfItFails, m as decodeRpcChallengePubsubMsg, mt as signCommentModeration, n as RpcRemoteCommunity, nn as parseCommentModerationPubsubMessagePublicationSchemaWithPKCErrorIfItFails, nt as InflightFetchManager, o as TrackedInstanceRegistry, ot as require_lib$1, p as decodeRpcChallengeAnswerPubsubMsg, pt as signCommentEdit, rn as parseCommentPubsubMessagePublicationWithPKCErrorIfItFails, rr as nativeFunctions$2, s as LRUCache, sn as parseCommunityEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, st as cleanUpBeforePublishing, t as RpcLocalCommunity, tt as PKCClientsManager, u as RemoteCommunity, un as parseCreateCommentModerationOptionsSchemaWithPKCErrorIfItFails, ut as signChallengeRequest, v as createSigner, vn as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, vt as signCommunityEdit, wn as parseRpcCommentUpdateEventWithPKCErrorIfItFails, wt as verifyCommentEdit, x as encryptEd25519AesGcm, xn as parseJsonWithPKCErrorIfFails, xt as verifyChallengeMessage, y as decryptEd25519AesGcm, yn as parseDecryptedChallengeVerification, yt as signVote, zn as RpcFetchCidParamSchema, zt as getCommunityNameFromWire } from "./rpc-local-community-D8woL19t.js";
|
|
4
|
+
import { i as getHeliaDebugContext } from "./util-bpDx_Vq2.js";
|
|
5
5
|
import path from "path";
|
|
6
6
|
import assert from "assert";
|
|
7
7
|
import fs from "fs";
|
|
@@ -1389,6 +1389,7 @@ var Comment = class extends Publication {
|
|
|
1389
1389
|
super.setCommunityAddress(newCommunityAddress);
|
|
1390
1390
|
this.replies._community.publicKey = this.communityPublicKey;
|
|
1391
1391
|
this.replies._community.name = this.communityName;
|
|
1392
|
+
this.replies._community.ipnsPubsubTopic = isIpns(newCommunityAddress) ? ipnsNameToIpnsOverPubsubTopic(newCommunityAddress) : void 0;
|
|
1392
1393
|
}
|
|
1393
1394
|
_isCommentIpfsErrorRetriable(err) {
|
|
1394
1395
|
if (!(err instanceof PKCError)) return false;
|
|
@@ -8874,7 +8875,7 @@ var PKC$1 = class extends PKCTypedEmitter {
|
|
|
8874
8875
|
this.clients.libp2pJsClients = {};
|
|
8875
8876
|
if (!this.libp2pJsClientsOptions) return;
|
|
8876
8877
|
if (!this.httpRoutersOptions) throw Error("httpRoutersOptions is required for libp2pJsClient");
|
|
8877
|
-
const { createLibp2pJsClientOrUseExistingOne } = await import("./helia-for-pkc-
|
|
8878
|
+
const { createLibp2pJsClientOrUseExistingOne } = await import("./helia-for-pkc-x-xe-CrX.js");
|
|
8878
8879
|
for (const clientOptions of this.libp2pJsClientsOptions) {
|
|
8879
8880
|
const heliaNode = await createLibp2pJsClientOrUseExistingOne({
|
|
8880
8881
|
...clientOptions,
|
|
@@ -9122,7 +9123,7 @@ var PKC$1 = class extends PKCTypedEmitter {
|
|
|
9122
9123
|
const log = logger_default("pkc-js:pkc:createLocalCommunity");
|
|
9123
9124
|
log.trace("Received community options to create a local community instance:", options);
|
|
9124
9125
|
if (!this._canCreateNewLocalCommunity()) throw new PKCError("ERR_CAN_NOT_CREATE_A_LOCAL_COMMUNITY", { pkcOptions: this._userPKCOptions });
|
|
9125
|
-
const { LocalCommunity, createNewLocalCommunityDb, updateInstancePropsWithStartedCommunityOrDb } = await import("./local-community-
|
|
9126
|
+
const { LocalCommunity, createNewLocalCommunityDb, updateInstancePropsWithStartedCommunityOrDb } = await import("./local-community-BuseLMgO.js");
|
|
9126
9127
|
const isLocalCommunity = (await listCommunitiesSync(this)).includes(options.address);
|
|
9127
9128
|
const community = new LocalCommunity(this);
|
|
9128
9129
|
if (isLocalCommunity) {
|
package/dist/bundled/chunks/{rpc-local-community-ByjBdSQ5.js → rpc-local-community-D8woL19t.js}
RENAMED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { i as __toESM, n as __exportAll, r as __require, t as __commonJSMin } from "./chunk-2rV9d50f.js";
|
|
2
|
-
import { $ as pubsubTopicToDhtKey, $t as CommunityEditOptionsSchema, A as extractNetworkErrorDetails, An as CreateCommentOptionsWithRefinementSchema, Ar as record, At as trackStartedCommunity, B as isIpfsCid, Bn as CreateCommentEditOptionsWithRefinementSchema, Cr as _enum, Ct as findUpdatingCommunity, D as deepMergeRuntimeFields, Dn as CommentUpdateSignedPropertyNames, Dr as literal, E as createAbortError, En as CommentUpdateSchema, Er as custom, Et as listUpdatingCommunities, Ft as untrackUpdatingCommunity, Gn as CidPathSchema, Gt as CommentModerationPubsubMessagePublicationSchema, H as isIpns, Hn as AuthorCommentIpfsReservedFields, Ht as CommunityEditPubsubMessagePublicationSchema, I as getPostUpdateTimestampRange, In as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema, It as require_sha256$1, Jn as CommunityAuthorChallengeReservedFieldNames, Jt as CommentModerationsTableRowSchema, Kn as CidStringSchema, L as hideClassPrivateProps, Mn as ModQueuePageIpfsSchema, Mt as trackUpdatingCommunity, Nn as PageIpfsSchema, Nt as untrackStartedCommunity, O as derivePublicationFromChallengeRequest, Or as number, Ot as refreshTrackedCommunityAliases, Pn as CommentEditChallengeRequestToEncryptSchema, Q as isStringDomain, Qn as n$9, Qt as CommunityChallengeSettingSchema, R as ipnsNameToIpnsOverPubsubTopic, Rn as CommentEditSignedPropertyNames, Rt as pTimeout, Sn as CommentUpdateChallengeReservedFieldNames, St as findUpdatingComment, Tn as CommentUpdateReservedFields, Tr as boolean, U as isIpnsPath, Ut as CreateCommunityEditPublicationOptionsWithRefinementSchema, V as isIpfsPath, Vn as AuthorAddressSchema, Vt as CommunityEditPublicationSignedPropertyNames, Wn as ChallengeAnswersSchema, Wt as CommentModerationChallengeRequestToEncryptSchema, X as isRequestPubsubPublicationOfPost, Xn as n$10, Xt as ChallengeFileFactorySchema, Yn as CreateSignerSchema, Yt as CreateCommentModerationOptionsWithRefinementSchema, Z as isRequestPubsubPublicationOfReply, Zt as ChallengeFileSchema, _ as PKCUserOptionBaseSchema, _n as CommentIpfsReservedFields, _r as PKCError, _t as timestamp, an as CreateRemoteCommunityFunctionArgumentSchema, ar as t$12, b as areEquivalentCommunityAddresses, bn as CommentPubsubMessageWithFlexibleAuthorRefinementSchema, br as require_supports_color, c as ChallengeVerificationMessageSignedPropertyNames, cr as t$10, ct as resolveWhenPredicateIsTrue, dn as VoteChallengeRequestToEncryptSchema, dr as require_retry$1, en as CommunityExportRecordsSchema, er as t$13, f as DecryptedChallengeSchema, fn as VotePubsubMessagePublicationSchema, fr as FailedToFetchCommentIpfsFromGatewaysError, ft as shortifyAddress, g as PKCParsedOptionsSchema, gn as CommentChallengeRequestToEncryptSchema, gr as FailedToFetchPageIpfsFromGatewaysError, gt as throwIfAbortSignalAborted, h as NameResolverSerializedSchema, hr as FailedToFetchGenericIpfsFromGatewaysError, i as ChallengeMessageSignedPropertyNames, in as CreateNewLocalCommunityUserOptionsSchema, ir as r$8, it as removeNullUndefinedEmptyObjectsValuesRecursively, j as fetchAndValidateIpnsRecordFromGateway, jn as GetPageParamSchema, jr as string, k as doesDomainAddressHaveCapitalLetter, kr as object, l as DecryptedChallengeAnswerSchema, ln as RpcRemoteCommunityUpdateEventResultSchema, lr as t$9, m as NameResolveCacheOptionsSchema, mn as VoteSignedPropertyNames, mr as FailedToFetchCommunityFromGatewaysError, mt as sleepUntilTimeoutOrAbort, n as ChallengeAnswerMessageSignedPropertyNames, nn as CommunityIpfsSchema, nr as e$5, o as ChallengeRequestMessageSignedPropertyNames, on as CreateRpcCommunityFunctionArgumentSchema, or as n$8, p as DecryptedChallengeVerificationSchema, pr as FailedToFetchCommentUpdateFromGatewaysError, pt as shortifyCid, qn as CommunityAddressSchema, qt as CommentModerationSignedPropertyNames, rn as CommunitySignedPropertyNames, rr as t$11, sn as ExportCommunityModLogsOptionsSchema, sr as r$7, tn as CommunityIpfsReservedFields, tr as e$6, tt as raceAgainstAbort, un as CreateVoteUserOptionsWithRefinementSchema, ur as e$4, v as PKCUserOptionsSchema, vn as CommentIpfsSchema, vr as messages, vt as waitForUpdateInCommunityInstanceWithErrorAndTimeout, wn as CommentUpdateForChallengeVerificationSignedPropertyNames, wr as array, wt as listStartedCommunities, x as calculateIpfsCidV0, xn as CommentSignedPropertyNames, xr as require_ms$1, xt as findStartedCommunity, yr as logger_default, z as isAbortError, zt as CommunityEditPublicationChallengeRequestToEncryptSchema } from "./schema-
|
|
2
|
+
import { $ as pubsubTopicToDhtKey, $t as CommunityEditOptionsSchema, A as extractNetworkErrorDetails, An as CreateCommentOptionsWithRefinementSchema, Ar as record, At as trackStartedCommunity, B as isIpfsCid, Bn as CreateCommentEditOptionsWithRefinementSchema, Cr as _enum, Ct as findUpdatingCommunity, D as deepMergeRuntimeFields, Dn as CommentUpdateSignedPropertyNames, Dr as literal, E as createAbortError, En as CommentUpdateSchema, Er as custom, Et as listUpdatingCommunities, Ft as untrackUpdatingCommunity, Gn as CidPathSchema, Gt as CommentModerationPubsubMessagePublicationSchema, H as isIpns, Hn as AuthorCommentIpfsReservedFields, Ht as CommunityEditPubsubMessagePublicationSchema, I as getPostUpdateTimestampRange, In as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema, It as require_sha256$1, Jn as CommunityAuthorChallengeReservedFieldNames, Jt as CommentModerationsTableRowSchema, Kn as CidStringSchema, L as hideClassPrivateProps, Mn as ModQueuePageIpfsSchema, Mt as trackUpdatingCommunity, Nn as PageIpfsSchema, Nt as untrackStartedCommunity, O as derivePublicationFromChallengeRequest, Or as number, Ot as refreshTrackedCommunityAliases, Pn as CommentEditChallengeRequestToEncryptSchema, Q as isStringDomain, Qn as n$9, Qt as CommunityChallengeSettingSchema, R as ipnsNameToIpnsOverPubsubTopic, Rn as CommentEditSignedPropertyNames, Rt as pTimeout, Sn as CommentUpdateChallengeReservedFieldNames, St as findUpdatingComment, Tn as CommentUpdateReservedFields, Tr as boolean, U as isIpnsPath, Ut as CreateCommunityEditPublicationOptionsWithRefinementSchema, V as isIpfsPath, Vn as AuthorAddressSchema, Vt as CommunityEditPublicationSignedPropertyNames, Wn as ChallengeAnswersSchema, Wt as CommentModerationChallengeRequestToEncryptSchema, X as isRequestPubsubPublicationOfPost, Xn as n$10, Xt as ChallengeFileFactorySchema, Yn as CreateSignerSchema, Yt as CreateCommentModerationOptionsWithRefinementSchema, Z as isRequestPubsubPublicationOfReply, Zt as ChallengeFileSchema, _ as PKCUserOptionBaseSchema, _n as CommentIpfsReservedFields, _r as PKCError, _t as timestamp, an as CreateRemoteCommunityFunctionArgumentSchema, ar as t$12, b as areEquivalentCommunityAddresses, bn as CommentPubsubMessageWithFlexibleAuthorRefinementSchema, br as require_supports_color, c as ChallengeVerificationMessageSignedPropertyNames, cr as t$10, ct as resolveWhenPredicateIsTrue, dn as VoteChallengeRequestToEncryptSchema, dr as require_retry$1, en as CommunityExportRecordsSchema, er as t$13, f as DecryptedChallengeSchema, fn as VotePubsubMessagePublicationSchema, fr as FailedToFetchCommentIpfsFromGatewaysError, ft as shortifyAddress, g as PKCParsedOptionsSchema, gn as CommentChallengeRequestToEncryptSchema, gr as FailedToFetchPageIpfsFromGatewaysError, gt as throwIfAbortSignalAborted, h as NameResolverSerializedSchema, hr as FailedToFetchGenericIpfsFromGatewaysError, i as ChallengeMessageSignedPropertyNames, in as CreateNewLocalCommunityUserOptionsSchema, ir as r$8, it as removeNullUndefinedEmptyObjectsValuesRecursively, j as fetchAndValidateIpnsRecordFromGateway, jn as GetPageParamSchema, jr as string, k as doesDomainAddressHaveCapitalLetter, kr as object, l as DecryptedChallengeAnswerSchema, ln as RpcRemoteCommunityUpdateEventResultSchema, lr as t$9, m as NameResolveCacheOptionsSchema, mn as VoteSignedPropertyNames, mr as FailedToFetchCommunityFromGatewaysError, mt as sleepUntilTimeoutOrAbort, n as ChallengeAnswerMessageSignedPropertyNames, nn as CommunityIpfsSchema, nr as e$5, o as ChallengeRequestMessageSignedPropertyNames, on as CreateRpcCommunityFunctionArgumentSchema, or as n$8, p as DecryptedChallengeVerificationSchema, pr as FailedToFetchCommentUpdateFromGatewaysError, pt as shortifyCid, qn as CommunityAddressSchema, qt as CommentModerationSignedPropertyNames, rn as CommunitySignedPropertyNames, rr as t$11, sn as ExportCommunityModLogsOptionsSchema, sr as r$7, tn as CommunityIpfsReservedFields, tr as e$6, tt as raceAgainstAbort, un as CreateVoteUserOptionsWithRefinementSchema, ur as e$4, v as PKCUserOptionsSchema, vn as CommentIpfsSchema, vr as messages, vt as waitForUpdateInCommunityInstanceWithErrorAndTimeout, wn as CommentUpdateForChallengeVerificationSignedPropertyNames, wr as array, wt as listStartedCommunities, x as calculateIpfsCidV0, xn as CommentSignedPropertyNames, xr as require_ms$1, xt as findStartedCommunity, yr as logger_default, z as isAbortError, zt as CommunityEditPublicationChallengeRequestToEncryptSchema } from "./schema-C_l9RSe0.js";
|
|
3
3
|
import { t as all } from "./src-CYIMjhjK.js";
|
|
4
4
|
import http from "node:http";
|
|
5
5
|
import { createHash } from "node:crypto";
|
|
6
6
|
import { pathToFileURL } from "node:url";
|
|
7
7
|
import fsp from "node:fs/promises";
|
|
8
|
-
import
|
|
8
|
+
import path from "node:path";
|
|
9
9
|
import dns from "node:dns";
|
|
10
10
|
import os from "os";
|
|
11
11
|
import { closeSync, createReadStream, existsSync, openSync, promises, readSync, readdirSync, rm, watch } from "node:fs";
|
|
12
|
-
import path from "path";
|
|
12
|
+
import path$1 from "path";
|
|
13
13
|
import assert from "assert";
|
|
14
14
|
import { Agent } from "https";
|
|
15
15
|
import { Agent as Agent$1 } from "http";
|
|
@@ -99041,12 +99041,14 @@ var BaseClientsManager = class BaseClientsManager {
|
|
|
99041
99041
|
async _fetchCidP2P(cidV0, loadOpts) {
|
|
99042
99042
|
const log = logger_default("pkc-js:clients-manager:_fetchCidP2P");
|
|
99043
99043
|
throwIfAbortSignalAborted(loadOpts.abortSignal);
|
|
99044
|
-
this.getDefaultKuboRpcClientOrHelia();
|
|
99044
|
+
const kuboRpcOrHelia = this.getDefaultKuboRpcClientOrHelia();
|
|
99045
99045
|
const ipfsClient = this.getIpfsClientWithKuboRpcClientFunctions();
|
|
99046
99046
|
const fetchPromise = async () => {
|
|
99047
|
+
const seedScopeOptions = "_helia" in kuboRpcOrHelia && loadOpts.bitswapSessionSeedScopeIpnsPubsubTopic ? { bitswapSessionSeedScopeIpnsPubsubTopic: loadOpts.bitswapSessionSeedScopeIpnsPubsubTopic } : void 0;
|
|
99047
99048
|
const data = concat(await all(ipfsClient.cat(cidV0, {
|
|
99048
99049
|
length: loadOpts.maxFileSizeBytes,
|
|
99049
|
-
timeout: `${loadOpts.timeoutMs}ms
|
|
99050
|
+
timeout: `${loadOpts.timeoutMs}ms`,
|
|
99051
|
+
...seedScopeOptions
|
|
99050
99052
|
})));
|
|
99051
99053
|
const fileContent = toString(data);
|
|
99052
99054
|
if (typeof fileContent !== "string") {
|
|
@@ -99812,7 +99814,8 @@ var BasePagesClientsManager = class extends BaseClientsManager {
|
|
|
99812
99814
|
const rawJson = await this._retryTransientP2PFetch(() => this._fetchCidP2P(pageCid, {
|
|
99813
99815
|
maxFileSizeBytes: pageMaxSize,
|
|
99814
99816
|
timeoutMs: pageTimeoutMs,
|
|
99815
|
-
abortSignal
|
|
99817
|
+
abortSignal,
|
|
99818
|
+
bitswapSessionSeedScopeIpnsPubsubTopic: this._pages._community.ipnsPubsubTopic
|
|
99816
99819
|
}), {
|
|
99817
99820
|
log,
|
|
99818
99821
|
context: `page ${pageCid}`,
|
|
@@ -100863,6 +100866,11 @@ var CommentClientsManager = class extends PublicationClientsManager {
|
|
|
100863
100866
|
_calculatePathForPostCommentUpdate(folderCid, postCid) {
|
|
100864
100867
|
return `${folderCid}/` + postCid + "/update";
|
|
100865
100868
|
}
|
|
100869
|
+
_bitswapSessionSeedScopeIpnsPubsubTopic() {
|
|
100870
|
+
if (this._communityForUpdating?.community?.ipnsPubsubTopic) return this._communityForUpdating.community.ipnsPubsubTopic;
|
|
100871
|
+
const communityAddress = this._comment.communityAddress;
|
|
100872
|
+
if (communityAddress && isIpns(communityAddress)) return ipnsNameToIpnsOverPubsubTopic(communityAddress);
|
|
100873
|
+
}
|
|
100866
100874
|
_updateKuboRpcClientOrHeliaState(newState, kuboRpcOrHelia) {
|
|
100867
100875
|
if ("_helia" in kuboRpcOrHelia) this.updateLibp2pJsClientState(newState, kuboRpcOrHelia._libp2pJsClientsOptions.key);
|
|
100868
100876
|
else this.updateKuboRpcState(newState, kuboRpcOrHelia.url);
|
|
@@ -100889,7 +100897,8 @@ var CommentClientsManager = class extends PublicationClientsManager {
|
|
|
100889
100897
|
res = await this._retryTransientP2PFetch(() => this._fetchCidP2P(path, {
|
|
100890
100898
|
maxFileSizeBytes: MAX_FILE_SIZE_BYTES_FOR_COMMENT_UPDATE,
|
|
100891
100899
|
timeoutMs: commentUpdateTimeoutMs,
|
|
100892
|
-
abortSignal
|
|
100900
|
+
abortSignal,
|
|
100901
|
+
bitswapSessionSeedScopeIpnsPubsubTopic: this._bitswapSessionSeedScopeIpnsPubsubTopic()
|
|
100893
100902
|
}), {
|
|
100894
100903
|
abortSignal,
|
|
100895
100904
|
log,
|
|
@@ -101090,7 +101099,8 @@ var CommentClientsManager = class extends PublicationClientsManager {
|
|
|
101090
101099
|
commentRawString = await this._fetchCidP2P(cid, {
|
|
101091
101100
|
maxFileSizeBytes: 1024 * 1024,
|
|
101092
101101
|
timeoutMs: commentTimeoutMs,
|
|
101093
|
-
abortSignal: this._comment._getStopAbortSignal()
|
|
101102
|
+
abortSignal: this._comment._getStopAbortSignal(),
|
|
101103
|
+
bitswapSessionSeedScopeIpnsPubsubTopic: this._bitswapSessionSeedScopeIpnsPubsubTopic()
|
|
101094
101104
|
});
|
|
101095
101105
|
} catch (e) {
|
|
101096
101106
|
e.details = {
|
|
@@ -101582,14 +101592,14 @@ var CommentClientsManager = class extends PublicationClientsManager {
|
|
|
101582
101592
|
};
|
|
101583
101593
|
//#endregion
|
|
101584
101594
|
//#region dist/node/runtime/node/util.js
|
|
101585
|
-
const getDefaultDataPath = () => path.join(process.cwd(), ".pkc");
|
|
101595
|
+
const getDefaultDataPath = () => path$1.join(process.cwd(), ".pkc");
|
|
101586
101596
|
const getDefaultCommunityDbConfig = async (communityAddress, pkc) => {
|
|
101587
101597
|
let filename;
|
|
101588
101598
|
if (pkc.noData) filename = ":memory:";
|
|
101589
101599
|
else {
|
|
101590
101600
|
assert(typeof pkc.dataPath === "string", "pkc.dataPath need to be defined to get default community db config");
|
|
101591
|
-
filename = path.join(pkc.dataPath, "communities", communityAddress);
|
|
101592
|
-
await promises.mkdir(path.dirname(filename), { recursive: true });
|
|
101601
|
+
filename = path$1.join(pkc.dataPath, "communities", communityAddress);
|
|
101602
|
+
await promises.mkdir(path$1.dirname(filename), { recursive: true });
|
|
101593
101603
|
}
|
|
101594
101604
|
return {
|
|
101595
101605
|
filename,
|
|
@@ -101688,7 +101698,7 @@ const setNativeFunctions = (newNativeFunctions) => {
|
|
|
101688
101698
|
};
|
|
101689
101699
|
const deleteOldCommunityInWindows = async (subPath, pkc) => {
|
|
101690
101700
|
const log = logger_default("pkc-js:community:deleteStaleCommunityInWindows");
|
|
101691
|
-
const communityAddress = path.basename(subPath);
|
|
101701
|
+
const communityAddress = path$1.basename(subPath);
|
|
101692
101702
|
await new Promise((resolve) => setTimeout(resolve, 1e4));
|
|
101693
101703
|
try {
|
|
101694
101704
|
await promises.rm(subPath, { force: true });
|
|
@@ -101712,7 +101722,7 @@ async function tryToDeleteCommunitiesThatFailedToBeDeletedBefore(pkc, log) {
|
|
|
101712
101722
|
}
|
|
101713
101723
|
const communitiesThatWereDeletedSuccessfully = [];
|
|
101714
101724
|
for (const communityAddress of deletedPersistentCommunities) {
|
|
101715
|
-
const communityPath = path.join(pkc.dataPath, "communities", communityAddress);
|
|
101725
|
+
const communityPath = path$1.join(pkc.dataPath, "communities", communityAddress);
|
|
101716
101726
|
try {
|
|
101717
101727
|
await promises.rm(communityPath, { force: true });
|
|
101718
101728
|
log(`Succeeded in deleting old db path (${communityAddress})`);
|
|
@@ -101736,7 +101746,7 @@ async function tryToDeleteCommunitiesThatFailedToBeDeletedBefore(pkc, log) {
|
|
|
101736
101746
|
function listCommunitiesSync(pkc) {
|
|
101737
101747
|
logger_default("pkc-js:listCommunitiesSync");
|
|
101738
101748
|
if (typeof pkc.dataPath !== "string") throw Error("pkc.dataPath needs to be defined to listCommunities");
|
|
101739
|
-
const communitiesPath = path.join(pkc.dataPath, "communities");
|
|
101749
|
+
const communitiesPath = path$1.join(pkc.dataPath, "communities");
|
|
101740
101750
|
const files = readdirSync(communitiesPath, {
|
|
101741
101751
|
recursive: false,
|
|
101742
101752
|
withFileTypes: false
|
|
@@ -101744,7 +101754,7 @@ function listCommunitiesSync(pkc) {
|
|
|
101744
101754
|
const communityFilesWeDontNeedToCheck = pkc.communities ? files.filter((address) => pkc.communities.includes(address)) : [];
|
|
101745
101755
|
const sqliteFiles = files.filter((address) => !communityFilesWeDontNeedToCheck.includes(address)).filter((address) => {
|
|
101746
101756
|
try {
|
|
101747
|
-
const filePath = path.join(communitiesPath, address);
|
|
101757
|
+
const filePath = path$1.join(communitiesPath, address);
|
|
101748
101758
|
if (!existsSync(filePath)) return false;
|
|
101749
101759
|
const fd = openSync(filePath, "r");
|
|
101750
101760
|
const buffer = Buffer.alloc(16);
|
|
@@ -101825,7 +101835,7 @@ var BackupAbortError = class extends Error {
|
|
|
101825
101835
|
async function backupCommunityDb(opts) {
|
|
101826
101836
|
const { sourcePath, destPath, includePrivateKey, onProgress, signal } = opts;
|
|
101827
101837
|
if (signal?.aborted) throw new BackupAbortError();
|
|
101828
|
-
await promises.mkdir(path.dirname(destPath), { recursive: true });
|
|
101838
|
+
await promises.mkdir(path$1.dirname(destPath), { recursive: true });
|
|
101829
101839
|
const partialPath = destPath + ".partial";
|
|
101830
101840
|
try {
|
|
101831
101841
|
await promises.unlink(partialPath);
|
|
@@ -101909,9 +101919,9 @@ async function statAndHashFile(filePath) {
|
|
|
101909
101919
|
}
|
|
101910
101920
|
async function moveCommunityDbToDeletedDirectory(communityAddress, pkc) {
|
|
101911
101921
|
if (typeof pkc.dataPath !== "string") throw Error("pkc.dataPath is not defined");
|
|
101912
|
-
const oldPath = path.join(pkc.dataPath, "communities", communityAddress);
|
|
101913
|
-
const newPath = path.join(pkc.dataPath, "communities", "deleted", communityAddress);
|
|
101914
|
-
await promises.mkdir(path.join(pkc.dataPath, "communities", "deleted"), { recursive: true });
|
|
101922
|
+
const oldPath = path$1.join(pkc.dataPath, "communities", communityAddress);
|
|
101923
|
+
const newPath = path$1.join(pkc.dataPath, "communities", "deleted", communityAddress);
|
|
101924
|
+
await promises.mkdir(path$1.join(pkc.dataPath, "communities", "deleted"), { recursive: true });
|
|
101915
101925
|
if (!existsSync(oldPath)) throw Error(`Source database ${oldPath} does not exist`);
|
|
101916
101926
|
try {
|
|
101917
101927
|
const sourceDb = new Database(oldPath, { fileMustExist: true });
|
|
@@ -101947,7 +101957,7 @@ async function createKuboRpcClient(kuboRpcClientOptions) {
|
|
|
101947
101957
|
}
|
|
101948
101958
|
async function monitorCommunitiesDirectory(pkc) {
|
|
101949
101959
|
const watchAbortController = new AbortController();
|
|
101950
|
-
const communitiesPath = path.join(pkc.dataPath, "communities");
|
|
101960
|
+
const communitiesPath = path$1.join(pkc.dataPath, "communities");
|
|
101951
101961
|
await promises.mkdir(communitiesPath, { recursive: true });
|
|
101952
101962
|
const extensionsToIgnore = [
|
|
101953
101963
|
".lock",
|
|
@@ -125009,7 +125019,8 @@ var CommunityClientsManager = class extends PKCClientsManager {
|
|
|
125009
125019
|
rawCommunityJsonString = await this._fetchCidP2P(latestCommunityCid, {
|
|
125010
125020
|
maxFileSizeBytes: MAX_FILE_SIZE_BYTES_FOR_COMMUNITY_IPFS,
|
|
125011
125021
|
timeoutMs: this._pkc._timeouts["community-ipfs"],
|
|
125012
|
-
abortSignal: this._community._getStopAbortSignal()
|
|
125022
|
+
abortSignal: this._community._getStopAbortSignal(),
|
|
125023
|
+
bitswapSessionSeedScopeIpnsPubsubTopic: this._community.ipnsPubsubTopic
|
|
125013
125024
|
});
|
|
125014
125025
|
} catch (e) {
|
|
125015
125026
|
e.details = {
|
|
@@ -125846,11 +125857,11 @@ var AddressRewriterDatabase = class {
|
|
|
125846
125857
|
if (kuboConfig && typeof kuboConfig === "object" && "host" in kuboConfig && "port" in kuboConfig) kuboIdentifier = `${kuboConfig.host}_${kuboConfig.port}`;
|
|
125847
125858
|
const proxyIdentifier = `${proxyTarget.hostname}_${proxyTarget.port || (proxyTarget.protocol === "https:" ? "443" : "80")}`;
|
|
125848
125859
|
const fileName = `address_rewriter_${kuboIdentifier}_${proxyIdentifier}.db`;
|
|
125849
|
-
return
|
|
125860
|
+
return path.join(dataPath, ".address-rewriter", fileName);
|
|
125850
125861
|
}
|
|
125851
125862
|
async initialize() {
|
|
125852
125863
|
try {
|
|
125853
|
-
const dbDir =
|
|
125864
|
+
const dbDir = path.dirname(this._dbPath);
|
|
125854
125865
|
await fsp.mkdir(dbDir, { recursive: true });
|
|
125855
125866
|
this._db = new Database(this._dbPath);
|
|
125856
125867
|
this._db.exec(`
|
|
@@ -15994,7 +15994,7 @@ async function fetchAndValidateIpnsRecordFromGateway(gatewayUrl, ipnsName, opts)
|
|
|
15994
15994
|
const textEncoder = new TextEncoder();
|
|
15995
15995
|
async function calculateStringSizeSameAsIpfsAddCidV0(content) {
|
|
15996
15996
|
const { MemoryBlockstore } = await import("blockstore-core");
|
|
15997
|
-
const { importFile } = await import("./src-
|
|
15997
|
+
const { importFile } = await import("./src-o_MYSn-E.js");
|
|
15998
15998
|
const blockstore = new MemoryBlockstore();
|
|
15999
15999
|
const entry = await importFile({
|
|
16000
16000
|
path: "content.json",
|
|
@@ -16032,7 +16032,7 @@ function extractNetworkErrorDetails(err, depth = 0) {
|
|
|
16032
16032
|
}
|
|
16033
16033
|
//#endregion
|
|
16034
16034
|
//#region dist/node/generated-version.js
|
|
16035
|
-
const version = "0.0.
|
|
16035
|
+
const version = "0.0.69";
|
|
16036
16036
|
//#endregion
|
|
16037
16037
|
//#region dist/node/version.js
|
|
16038
16038
|
const protocolVersion = ProtocolVersionSchema.parse("1.0.0");
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { _r as PKCError, et as pubsubTopicToDhtKeyCid } from "./schema-
|
|
1
|
+
import { _r as PKCError, et as pubsubTopicToDhtKeyCid } from "./schema-C_l9RSe0.js";
|
|
2
|
+
import { ipnsSelector } from "ipns/selector";
|
|
3
|
+
import { equals } from "uint8arrays/equals";
|
|
2
4
|
//#region dist/node/helia/util.js
|
|
3
5
|
const TOPIC_SUBSCRIBER_WAIT_TIMEOUT_MS = 1e4;
|
|
4
6
|
const MESH_PEER_WAIT_TIMEOUT_MS = 3e3;
|
|
@@ -214,7 +216,7 @@ function selectBitswapSessionSeedPeers(args) {
|
|
|
214
216
|
seeds.push(connectedPeer);
|
|
215
217
|
}
|
|
216
218
|
};
|
|
217
|
-
args.
|
|
219
|
+
args.scopedPubsubSubscriberPeerIdStrings.forEach(pushIfConnected);
|
|
218
220
|
args.pubsubSubscriberPeerIdStrings.forEach(pushIfConnected);
|
|
219
221
|
for (const peer of args.connectedPeers) pushIfConnected(peer.toString());
|
|
220
222
|
return seeds.slice(0, args.maxSeeds);
|
|
@@ -316,5 +318,13 @@ async function directFetchIpnsRecordFromProviders({ helia, pubsubTopic, routingK
|
|
|
316
318
|
...getHeliaDebugContext(helia)
|
|
317
319
|
});
|
|
318
320
|
}
|
|
321
|
+
async function cacheIpnsRecordInPubsubLocalStore({ localStore, routingKey, marshalledRecord }) {
|
|
322
|
+
if (await localStore.has(routingKey)) {
|
|
323
|
+
const { record: currentRecord } = await localStore.get(routingKey);
|
|
324
|
+
if (equals(currentRecord, marshalledRecord)) return;
|
|
325
|
+
if (ipnsSelector(routingKey, [currentRecord, marshalledRecord]) === 0) return;
|
|
326
|
+
}
|
|
327
|
+
await localStore.put(routingKey, marshalledRecord);
|
|
328
|
+
}
|
|
319
329
|
//#endregion
|
|
320
|
-
export { selectBitswapSessionSeedPeers as i,
|
|
330
|
+
export { selectBitswapSessionSeedPeers as a, getHeliaDebugContext as i, connectToPubsubPeers as n, directFetchIpnsRecordFromProviders as r, cacheIpnsRecordInPubsubLocalStore as t };
|
package/dist/bundled/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as nativeFunctions, i as getShortCid, n as challenges, o as setNativeFunctions, r as getShortAddress, t as PKC } from "./chunks/node-
|
|
1
|
+
import { a as nativeFunctions, i as getShortCid, n as challenges, o as setNativeFunctions, r as getShortAddress, t as PKC } from "./chunks/node-Dz5IKip2.js";
|
|
2
2
|
export { challenges, PKC as default, getShortAddress, getShortCid, nativeFunctions, setNativeFunctions };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { L as hideClassPrivateProps, Qn as n, _r as PKCError, er as t, st as replaceXWithY, xt as findStartedCommunity, yr as logger_default } from "../../chunks/schema-
|
|
2
|
-
import { _ as parseRpcUnsubscribeParam, c as parseRpcCancelExportParam, d as parseRpcCommunityIdentifierParam, f as parseRpcCommunityPageParam, g as parseRpcPublishChallengeAnswersParam, h as parseRpcExportCommunityParam, l as parseRpcCidParam, m as parseRpcExportCommunityModLogsParam, p as parseRpcEditCommunityParam, s as parseRpcAuthorNameParam, t as PKC, u as parseRpcCommentRepliesPageParam } from "../../chunks/node-
|
|
3
|
-
import { En as parseVoteChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, J as buildPagesRuntimeFields, Qt as parseCommentEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, Tn as parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, Zt as parseCommentChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, an as parseCommunityEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, er as stringify, it as pLimit, mn as parseCreatePKCWsServerOptionsSchemaWithPKCErrorIfItFails, on as parseCommunityEditOptionsSchemaWithPKCErrorIfItFails, ot as require_lib, pn as parseCreateNewLocalCommunityUserOptionsSchemaWithPKCErrorIfItFails, q as buildPageRuntimeFields, qn as t$1, rt as pRetry, tn as parseCommentModerationChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, vn as parseDecryptedChallengeAnswerWithPKCErrorIfItFails } from "../../chunks/rpc-local-community-
|
|
4
|
-
import { t as LocalCommunity } from "../../chunks/local-community-
|
|
1
|
+
import { L as hideClassPrivateProps, Qn as n, _r as PKCError, er as t, st as replaceXWithY, xt as findStartedCommunity, yr as logger_default } from "../../chunks/schema-C_l9RSe0.js";
|
|
2
|
+
import { _ as parseRpcUnsubscribeParam, c as parseRpcCancelExportParam, d as parseRpcCommunityIdentifierParam, f as parseRpcCommunityPageParam, g as parseRpcPublishChallengeAnswersParam, h as parseRpcExportCommunityParam, l as parseRpcCidParam, m as parseRpcExportCommunityModLogsParam, p as parseRpcEditCommunityParam, s as parseRpcAuthorNameParam, t as PKC, u as parseRpcCommentRepliesPageParam } from "../../chunks/node-Dz5IKip2.js";
|
|
3
|
+
import { En as parseVoteChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, J as buildPagesRuntimeFields, Qt as parseCommentEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, Tn as parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, Zt as parseCommentChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, an as parseCommunityEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, er as stringify, it as pLimit, mn as parseCreatePKCWsServerOptionsSchemaWithPKCErrorIfItFails, on as parseCommunityEditOptionsSchemaWithPKCErrorIfItFails, ot as require_lib, pn as parseCreateNewLocalCommunityUserOptionsSchemaWithPKCErrorIfItFails, q as buildPageRuntimeFields, qn as t$1, rt as pRetry, tn as parseCommentModerationChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, vn as parseDecryptedChallengeAnswerWithPKCErrorIfItFails } from "../../chunks/rpc-local-community-D8woL19t.js";
|
|
4
|
+
import { t as LocalCommunity } from "../../chunks/local-community-B6IwJoBu.js";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
6
|
import path from "path";
|
|
7
7
|
import assert from "assert";
|
|
@@ -103,6 +103,7 @@ export declare class BaseClientsManager {
|
|
|
103
103
|
maxFileSizeBytes: number;
|
|
104
104
|
timeoutMs: number;
|
|
105
105
|
abortSignal?: AbortSignal;
|
|
106
|
+
bitswapSessionSeedScopeIpnsPubsubTopic?: string;
|
|
106
107
|
}): Promise<string>;
|
|
107
108
|
protected _retryTransientP2PFetch<T>(fetcher: () => Promise<T>, opts: {
|
|
108
109
|
abortSignal?: AbortSignal;
|