@pkcprotocol/pkc-js 0.0.47 → 0.0.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/clients/base-client-manager.js +5 -14
- package/dist/browser/clients/base-client-manager.js.map +1 -1
- package/dist/browser/community/community-client-manager.js +4 -11
- 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 +26 -17
- package/dist/browser/helia/helia-for-pkc.js.map +1 -1
- package/dist/browser/publications/comment/comment.js +6 -9
- package/dist/browser/publications/comment/comment.js.map +1 -1
- package/dist/browser/runtime/node/community/challenges/exclude/exclude.d.ts +1 -0
- package/dist/browser/runtime/node/community/challenges/exclude/exclude.js +6 -1
- package/dist/browser/runtime/node/community/challenges/exclude/exclude.js.map +1 -1
- package/dist/browser/runtime/node/community/db-handler.d.ts +1 -0
- package/dist/browser/runtime/node/community/db-handler.js +3 -0
- package/dist/browser/runtime/node/community/db-handler.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/comment-updates.js +11 -3
- package/dist/browser/runtime/node/community/local-community/comment-updates.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/lifecycle.js +4 -10
- package/dist/browser/runtime/node/community/local-community/lifecycle.js.map +1 -1
- package/dist/browser/signer/encryption.d.ts +2 -2
- package/dist/browser/signer/util.d.ts +1 -1
- package/dist/browser/util.d.ts +2 -0
- package/dist/browser/util.js +45 -0
- package/dist/browser/util.js.map +1 -1
- package/dist/bundled/bundle-manifest.json +81 -77
- package/dist/bundled/chunks/{helia-for-pkc-Kr0fvym5.js → helia-for-pkc-BZ6rZnW_.js} +16 -15
- package/dist/bundled/chunks/{local-community-DyL61Q84.js → local-community-CPvHllf9.js} +1 -1
- package/dist/bundled/chunks/{local-community-1YWTMINk.js → local-community-CbMGlscJ.js} +12 -13
- package/dist/bundled/chunks/{node-7bvDHqBl.js → node-eJCx_6gz.js} +8 -9
- package/dist/bundled/chunks/{rpc-local-community-Xpx65cbz.js → rpc-local-community-CTDbXkkP.js} +5 -17
- package/dist/bundled/chunks/{schema-CijXm_fr.js → schema-D0I45iuK.js} +3811 -3411
- package/dist/bundled/chunks/{util-RR1J0iZB.js → util-C0EAYvmS.js} +1 -1
- package/dist/bundled/index.js +1 -1
- package/dist/bundled/rpc/src/index.js +4 -4
- package/dist/node/clients/base-client-manager.js +5 -14
- package/dist/node/clients/base-client-manager.js.map +1 -1
- package/dist/node/community/community-client-manager.js +4 -11
- 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 +26 -17
- package/dist/node/helia/helia-for-pkc.js.map +1 -1
- package/dist/node/publications/comment/comment.js +6 -9
- package/dist/node/publications/comment/comment.js.map +1 -1
- package/dist/node/runtime/node/community/challenges/exclude/exclude.d.ts +1 -0
- package/dist/node/runtime/node/community/challenges/exclude/exclude.js +6 -1
- package/dist/node/runtime/node/community/challenges/exclude/exclude.js.map +1 -1
- package/dist/node/runtime/node/community/db-handler.d.ts +1 -0
- package/dist/node/runtime/node/community/db-handler.js +3 -0
- package/dist/node/runtime/node/community/db-handler.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/comment-updates.js +11 -3
- package/dist/node/runtime/node/community/local-community/comment-updates.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/lifecycle.js +4 -10
- package/dist/node/runtime/node/community/local-community/lifecycle.js.map +1 -1
- package/dist/node/signer/encryption.d.ts +2 -2
- package/dist/node/signer/util.d.ts +1 -1
- package/dist/node/util.d.ts +2 -0
- package/dist/node/util.js +45 -0
- package/dist/node/util.js.map +1 -1
- package/package.json +16 -16
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { L as hideClassPrivateProps, R as ipnsNameToIpnsOverPubsubTopic,
|
|
2
|
-
import { n as getHeliaDebugContext, t as connectToPubsubPeers } from "./util-
|
|
1
|
+
import { L as hideClassPrivateProps, R as ipnsNameToIpnsOverPubsubTopic, cr as logger_default, or as PKCError } from "./schema-D0I45iuK.js";
|
|
2
|
+
import { n as getHeliaDebugContext, t as connectToPubsubPeers } from "./util-C0EAYvmS.js";
|
|
3
3
|
import { CID } from "multiformats/cid";
|
|
4
|
+
import { NotFoundError } from "@libp2p/interface";
|
|
4
5
|
import { peerIdFromString } from "@libp2p/peer-id";
|
|
5
6
|
import { multihashToIPNSRoutingKey, unmarshalIPNSRecord } from "ipns";
|
|
6
7
|
import { ipnsValidator } from "ipns/validator";
|
|
@@ -11,7 +12,7 @@ import { ipns } from "@helia/ipns";
|
|
|
11
12
|
import { gossipsub } from "@libp2p/gossipsub";
|
|
12
13
|
import { identify } from "@libp2p/identify";
|
|
13
14
|
import { bitswap } from "@helia/block-brokers";
|
|
14
|
-
import {
|
|
15
|
+
import { delegatedRoutingV1HttpApiClientContentRouting } from "@helia/delegated-routing-v1-http-api-client";
|
|
15
16
|
import { unixfs } from "@helia/unixfs";
|
|
16
17
|
import { fetch } from "@libp2p/fetch";
|
|
17
18
|
import { pubsub } from "@helia/ipns/routing";
|
|
@@ -40,11 +41,14 @@ const creatingLibp2pJsClients = {};
|
|
|
40
41
|
function getDelegatedRoutingFields(routers) {
|
|
41
42
|
const routersObj = {};
|
|
42
43
|
for (let i = 0; i < routers.length; i++) {
|
|
43
|
-
const factory =
|
|
44
|
+
const factory = delegatedRoutingV1HttpApiClientContentRouting({ url: routers[i] });
|
|
44
45
|
routersObj["delegatedRouting" + i] = (components) => {
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
const routing = factory(components);
|
|
47
|
+
routing.get = async () => {
|
|
48
|
+
throw new NotFoundError("pkc HTTP routers do not serve IPNS records");
|
|
49
|
+
};
|
|
50
|
+
routing.put = async () => {};
|
|
51
|
+
return routing;
|
|
48
52
|
};
|
|
49
53
|
}
|
|
50
54
|
return routersObj;
|
|
@@ -97,6 +101,10 @@ async function createLibp2pJsClientOrUseExistingOne(pkcOptions) {
|
|
|
97
101
|
pubsubEventHandler.emit(evt.detail.topic, msgFormatted);
|
|
98
102
|
});
|
|
99
103
|
const heliaFs = unixfs(helia);
|
|
104
|
+
const asHeliaCatCid = (ipfsPathOrCid) => {
|
|
105
|
+
CID.parse(ipfsPathOrCid.split("/")[0]);
|
|
106
|
+
return ipfsPathOrCid;
|
|
107
|
+
};
|
|
100
108
|
const ipnsNameResolver = ipns(helia, { routers: [pubsub(helia)] });
|
|
101
109
|
ipnsNameResolver.routers = ipnsNameResolver.routers.filter((r) => r?.constructor?.name !== "LocalStoreRouting");
|
|
102
110
|
const WARMUP_MAX_PEERS = 4;
|
|
@@ -184,14 +192,7 @@ async function createLibp2pJsClientOrUseExistingOne(pkcOptions) {
|
|
|
184
192
|
} },
|
|
185
193
|
cat(ipfsPath, options) {
|
|
186
194
|
throwIfHeliaIsStoppingOrStopped();
|
|
187
|
-
|
|
188
|
-
const rootCid = ipfsPath.split("/")[0];
|
|
189
|
-
const path = ipfsPath.split("/").slice(1).join("/");
|
|
190
|
-
return heliaFs.cat(CID.parse(rootCid), {
|
|
191
|
-
...options,
|
|
192
|
-
path
|
|
193
|
-
});
|
|
194
|
-
} else return heliaFs.cat(CID.parse(ipfsPath), options);
|
|
195
|
+
return heliaFs.cat(asHeliaCatCid(ipfsPath), options);
|
|
195
196
|
},
|
|
196
197
|
pubsub: {
|
|
197
198
|
ls: async () => helia.libp2p.services.pubsub.getTopics(),
|
|
@@ -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-CbMGlscJ.js";
|
|
2
2
|
export { LocalCommunity, createNewLocalCommunityDb, updateInstancePropsWithStartedCommunityOrDb };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { $ as pubsubTopicToDhtKey, At as
|
|
2
|
-
import { A as getDefaultCommunityDbConfig, At as cleanWireAuthor, Bt as encode, C as calculateExpectedSignatureSize, Ct as verifyCommentModeration, D as deriveCommentIpfsFromCommentTableRow, Dt as verifyCommunityEdit, E as deleteOldCommunityInWindows, Et as verifyCommunity, Gn as require_lodash_merge, Gt as getPublicKeyFromPrivateKey, H as POST_REPLIES_SORT_TYPES, Ht as getIpfsKeyFromPrivateKey, I as moveCommunityDbToDeletedDirectory, It as getCommunityNameFromWire, Kt as createSchemaRowParser, L as resolveDbPostsCidRefs, Lt as getCommunityPublicKeyFromWire, M as getThumbnailPropsOfLink, Mt as getAuthorNameFromWire, N as importSignerIntoKuboNode, O as deriveDbPosts, Ot as verifyVote, S as backupCommunityDb, St as verifyCommentIpfs, Tt as verifyCommentUpdate, U as REPLY_REPLIES_SORT_TYPES, Un as stringify, Ut as getPKCAddressFromPublicKey, V as POSTS_SORT_TYPES, W as TIMEFRAMES_TO_SECONDS, Wn as STORAGE_KEYS, Wt as getPKCAddressFromPublicKeySync, Y as iterateOverPageCidsToFindAllCids, _t as verifyChallengeAnswer, a as pkcJsChallenges, an as parseCommunityIpfsSchemaPassthroughWithPKCErrorIfItFails, b as encryptEd25519AesGcmPublicKeyBuffer, ct as signChallengeVerification, ft as signCommentUpdate, h as SignerWithPublicKeyAddress, hn as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, i as getCommunityChallengeFromCommunityChallengeSettings, it as cleanUpBeforePublishing, k as deriveDbReplies, kt as buildRuntimeAuthor, l as MAX_FILE_SIZE_BYTES_FOR_COMMUNITY_IPFS, lt as signComment, mt as signCommunity, o as TrackedInstanceRegistry, ot as signChallengeMessage, pt as signCommentUpdateForChallengeVerification, r as getChallengeVerification, rn as parseCommunityEditOptionsSchemaWithPKCErrorIfItFails, s as LRUCache, t as RpcLocalCommunity, tt as pLimit, u as KeyvBetterSqlite3, ut as signCommentEdit, v as decryptEd25519AesGcmPublicKeyBuffer, vn as parseJsonWithPKCErrorIfFails, w as calculateInlineRepliesBudget, wt as verifyCommentPubsubMessage, x as BackupAbortError, xt as verifyCommentEdit, yt as verifyChallengeRequest, zt as decode } from "./rpc-local-community-
|
|
1
|
+
import { $ as pubsubTopicToDhtKey, At as trackStartedCommunity, Bt as CommunityEditPublicationPubsubReservedFields, C as contentContainsMarkdownAudio, Ct as findUpdatingCommunity, Dr as __require, En as CommentUpdateSchema, F as getIpnsRecordInLocalKuboNode, Fn as CommentEditPubsubMessagePublicationSchema, Ft as untrackUpdatingCommunity, G as isLinkOfAudio, Gt as CommentModerationPubsubMessagePublicationSchema, In as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema, It as require_sha256, J as isLinkOfVideo, Jt as CommentModerationsTableRowSchema, K as isLinkOfImage, Kt as CommentModerationReservedFields, L as hideClassPrivateProps, Ln as CommentEditReservedFields, M as genToArray, Mt as trackUpdatingCommunity, N as getEquivalentCommunityAddresses, Nt as untrackStartedCommunity, O as derivePublicationFromChallengeRequest, On as CommentUpdateTableRowSchema, Or as __toESM, P as getErrorCodeFromMessage, Q as isStringDomain, R as ipnsNameToIpnsOverPubsubTopic, S as calculateStringSizeSameAsIpfsAddCidV0, T as contentContainsMarkdownVideos, Tr as __commonJSMin, Un as AuthorReservedFields, W as isLinkOfAnimatedImage, Xn as require_commonjs, Y as isLinkValid, Zn as require_retry, _t as timestamp, a as ChallengeRequestMessageSchema, at as removeNullUndefinedValues, b as areEquivalentCommunityAddresses, bt as findCommunityInRegistry, cr as logger_default, d as DecryptedChallengeRequestSchema, dt as retryKuboIpfsAddAndProvide, fn as VotePubsubMessagePublicationSchema, hn as VoteTablesRowSchema, ht as statMfsPathSafely, k as doesDomainAddressHaveCapitalLetter, kn as CommentsTableRowSchema, kt as syncCommunityRegistryEntry, lt as retryKuboBlockPutPinAndProvidePubsubTopic, mt as sleepUntilTimeoutOrAbort, nn as CommunityIpfsSchema, nt as removeBlocksFromKuboNode, or as PKCError, pn as VotePubsubReservedFields, q as isLinkOfMedia, r as ChallengeMessageSchema, rn as CommunitySignedPropertyNames, rt as removeMfsFilesSafely, s as ChallengeVerificationMessageSchema, sr as messages, t as ChallengeAnswerMessageSchema, u as DecryptedChallengeRequestPublicationSchema, vn as CommentIpfsSchema, w as contentContainsMarkdownImages, x as calculateIpfsCidV0, xr as ZodError, xt as findStartedCommunity, y as version_default, yn as CommentPubsubMessageReservedFields, yt as writeKuboFilesWithTimeout, zn as CommentEditsTableRowSchema } from "./schema-D0I45iuK.js";
|
|
2
|
+
import { A as getDefaultCommunityDbConfig, At as cleanWireAuthor, Bt as encode, C as calculateExpectedSignatureSize, Ct as verifyCommentModeration, D as deriveCommentIpfsFromCommentTableRow, Dt as verifyCommunityEdit, E as deleteOldCommunityInWindows, Et as verifyCommunity, Gn as require_lodash_merge, Gt as getPublicKeyFromPrivateKey, H as POST_REPLIES_SORT_TYPES, Ht as getIpfsKeyFromPrivateKey, I as moveCommunityDbToDeletedDirectory, It as getCommunityNameFromWire, Kt as createSchemaRowParser, L as resolveDbPostsCidRefs, Lt as getCommunityPublicKeyFromWire, M as getThumbnailPropsOfLink, Mt as getAuthorNameFromWire, N as importSignerIntoKuboNode, O as deriveDbPosts, Ot as verifyVote, S as backupCommunityDb, St as verifyCommentIpfs, Tt as verifyCommentUpdate, U as REPLY_REPLIES_SORT_TYPES, Un as stringify, Ut as getPKCAddressFromPublicKey, V as POSTS_SORT_TYPES, W as TIMEFRAMES_TO_SECONDS, Wn as STORAGE_KEYS, Wt as getPKCAddressFromPublicKeySync, Y as iterateOverPageCidsToFindAllCids, _t as verifyChallengeAnswer, a as pkcJsChallenges, an as parseCommunityIpfsSchemaPassthroughWithPKCErrorIfItFails, b as encryptEd25519AesGcmPublicKeyBuffer, ct as signChallengeVerification, ft as signCommentUpdate, h as SignerWithPublicKeyAddress, hn as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, i as getCommunityChallengeFromCommunityChallengeSettings, it as cleanUpBeforePublishing, k as deriveDbReplies, kt as buildRuntimeAuthor, l as MAX_FILE_SIZE_BYTES_FOR_COMMUNITY_IPFS, lt as signComment, mt as signCommunity, o as TrackedInstanceRegistry, ot as signChallengeMessage, pt as signCommentUpdateForChallengeVerification, r as getChallengeVerification, rn as parseCommunityEditOptionsSchemaWithPKCErrorIfItFails, s as LRUCache, t as RpcLocalCommunity, tt as pLimit, u as KeyvBetterSqlite3, ut as signCommentEdit, v as decryptEd25519AesGcmPublicKeyBuffer, vn as parseJsonWithPKCErrorIfFails, w as calculateInlineRepliesBudget, wt as verifyCommentPubsubMessage, x as BackupAbortError, xt as verifyCommentEdit, yt as verifyChallengeRequest, zt as decode } from "./rpc-local-community-CTDbXkkP.js";
|
|
3
3
|
import { randomFillSync, randomUUID } from "node:crypto";
|
|
4
4
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
5
5
|
import path from "node:path";
|
|
@@ -148,12 +148,15 @@ async function syncPostUpdatesWithIpfs(community, commentUpdateRowsToPublishToIp
|
|
|
148
148
|
const postUpdatesDirectory = `/${community.address}`;
|
|
149
149
|
const commentUpdatesWithLocalPath = commentUpdateRowsToPublishToIpfs.filter((row) => typeof row.localMfsPath === "string");
|
|
150
150
|
if (commentUpdatesWithLocalPath.length === 0) throw Error("No comment updates of posts to publish to postUpdates directory. This is a critical bug");
|
|
151
|
+
const liveCommentUpdates = commentUpdatesWithLocalPath.filter((row) => community._dbHandler.commentExistsInDb(row.newCommentUpdate.cid));
|
|
152
|
+
const purgedMidSyncCount = commentUpdatesWithLocalPath.length - liveCommentUpdates.length;
|
|
153
|
+
if (purgedMidSyncCount > 0) log(`Skipping ${purgedMidSyncCount} post CommentUpdate(s) for community ${community.address} whose comment was purged mid-sync`);
|
|
151
154
|
const kuboRpc = community._clientsManager.getDefaultKuboRpcClient();
|
|
152
155
|
const removedMfsPaths = await rmUnneededMfsPaths(community);
|
|
153
156
|
let postUpdatesDirectoryCid;
|
|
154
157
|
const BATCH_SIZE = 50;
|
|
155
|
-
for (let index = 0; index <
|
|
156
|
-
const batch =
|
|
158
|
+
for (let index = 0; index < liveCommentUpdates.length; index += BATCH_SIZE) {
|
|
159
|
+
const batch = liveCommentUpdates.slice(index, index + BATCH_SIZE);
|
|
157
160
|
await Promise.all(batch.map(async (row) => {
|
|
158
161
|
const { localMfsPath, newCommentUpdate } = row;
|
|
159
162
|
const content = stringify(newCommentUpdate);
|
|
@@ -174,7 +177,7 @@ async function syncPostUpdatesWithIpfs(community, commentUpdateRowsToPublishToIp
|
|
|
174
177
|
postUpdatesDirectoryCid = await kuboRpc._client.files.flush(postUpdatesDirectory);
|
|
175
178
|
}
|
|
176
179
|
const postUpdatesDirectoryCidString = postUpdatesDirectoryCid?.toString();
|
|
177
|
-
log("Community", community.address, "Synced",
|
|
180
|
+
log("Community", community.address, "Synced", liveCommentUpdates.length, "post CommentUpdates", "with MFS postUpdates directory", postUpdatesDirectoryCidString);
|
|
178
181
|
community._dbHandler.markCommentsAsPublishedToPostUpdates(commentUpdateRowsToPublishToIpfs.map((row) => row.newCommentUpdate.cid));
|
|
179
182
|
}
|
|
180
183
|
async function adjustPostUpdatesBucketsIfNeeded(community) {
|
|
@@ -4449,6 +4452,9 @@ var DbHandler = class {
|
|
|
4449
4452
|
if (!row) return void 0;
|
|
4450
4453
|
return this._parseCommentsTableRow(row);
|
|
4451
4454
|
}
|
|
4455
|
+
commentExistsInDb(cid) {
|
|
4456
|
+
return this._db.prepare(`SELECT 1 FROM ${TABLES.COMMENTS} WHERE cid = ? LIMIT 1`).get(cid) !== void 0;
|
|
4457
|
+
}
|
|
4452
4458
|
queryPseudonymityAliasByCommentCid(commentCid) {
|
|
4453
4459
|
return this._db.prepare(`SELECT commentCid, aliasPrivateKey, originalAuthorPublicKey, originalAuthorName, mode, insertedAt FROM ${TABLES.PSEUDONYMITY_ALIASES} WHERE commentCid = ?`).get(commentCid);
|
|
4454
4460
|
}
|
|
@@ -6405,14 +6411,7 @@ async function updateLoop(community) {
|
|
|
6405
6411
|
log.error("Error in update loop", e);
|
|
6406
6412
|
community.emit("error", e);
|
|
6407
6413
|
} finally {
|
|
6408
|
-
await
|
|
6409
|
-
if (community._updateLoopAbortController?.signal.aborted) return resolve();
|
|
6410
|
-
const timer = setTimeout(resolve, community._pkc.updateInterval);
|
|
6411
|
-
community._updateLoopAbortController?.signal.addEventListener("abort", () => {
|
|
6412
|
-
clearTimeout(timer);
|
|
6413
|
-
resolve();
|
|
6414
|
-
}, { once: true });
|
|
6415
|
-
});
|
|
6414
|
+
await sleepUntilTimeoutOrAbort(community._pkc.updateInterval, community._updateLoopAbortController?.signal);
|
|
6416
6415
|
}
|
|
6417
6416
|
}
|
|
6418
6417
|
async function update(community) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { $ as PKCClientsManager, $t as parseCommentModerationPubsubMessagePublicationSchemaWithPKCErrorIfItFails, An as RpcCommunityPageParamSchema, At as cleanWireAuthor, B as CommentClientsManager, Bn as RpcSubscriptionIdResultSchema, Ct as verifyCommentModeration, Dn as RpcCidParamSchema, Dt as verifyCommunityEdit, En as RpcCancelExportParamSchema, F as monitorCommunitiesDirectory, Fn as RpcExportCommunityResultSchema, Ft as getCommunityAddressFromRecord, Hn as RpcUnsubscribeParamSchema, In as RpcFetchCidParamSchema, It as getCommunityNameFromWire, J as findCommentInPageInstanceRecursively, Kn as nativeFunctions$2, Ln as RpcFetchCidResultSchema, Lt as getCommunityPublicKeyFromWire, Mn as RpcExportCommunityModLogsParamSchema, Nn as RpcExportCommunityModLogsResultSchema, Nt as normalizeCreatePublicationAuthor, On as RpcCommentRepliesPageParamSchema, Ot as verifyVote, P as listCommunitiesSync, Pn as RpcExportCommunityParamSchema, Pt as buildRuntimeCommunityFields, Q as PublicationClientsManager, R as setNativeFunctions$1, Rn as RpcPublishChallengeAnswersParamSchema, Rt as normalizeCommunityInputFromCommunity, Sn as parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, St as verifyCommentIpfs, T as createKuboRpcClient, Tn as RpcAuthorNameParamSchema, Tt as verifyCommentUpdate, Vn as RpcSuccessResultSchema, Vt as getBufferedPKCAddressFromPublicKey, X as parseRawPages, Xt as parseCommentEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, Z as RepliesPages, Zt as parseCommentIpfsSchemaWithPKCErrorIfItFails, _ as decryptEd25519AesGcm, _n as parseDecryptedChallengeWithPKCErrorIfItFails, a as pkcJsChallenges, at as signChallengeAnswer, bn as parseRpcCommentEventWithPKCErrorIfItFails, bt as verifyChallengeVerification, c as RemoteCommunity, cn as parseCreateCommentOptionsSchemaWithPKCErrorIfItFails, d as decodeRpcChallengeAnswerPubsubMsg, dt as signCommentModeration, en as parseCommentPubsubMessagePublicationWithPKCErrorIfItFails, et as InflightFetchManager, f as decodeRpcChallengePubsubMsg, fn as parseCreateRemoteCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, g as createSigner, gn as parseDecryptedChallengeVerification, gt as signVote, hn as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, ht as signCommunityEdit, in as parseCommunityEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, it as cleanUpBeforePublishing, j as getDefaultDataPath, jn as RpcEditCommunityParamSchema, jt as getAuthorNameFromRuntime, kn as RpcCommunityIdentifierParamSchema, kt as buildRuntimeAuthor, ln as parseCreateCommunityEditPublicationOptionsSchemaWithPKCErrorIfItFails, lt as signComment, m as decodeRpcChallengeVerificationPubsubMsg, mn as parseCreateVoteOptionsSchemaWithPKCErrorIfItFails, n as RpcRemoteCommunity, nt as PKCTypedEmitter, o as TrackedInstanceRegistry, on as parseCreateCommentEditOptionsSchemaWithPKCErrorIfItFails, p as decodeRpcChallengeRequestPubsubMsg, pn as parseCreateRpcCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, q as extractCommunityRuntimeFieldsFromParsedPages, qn as require_undici, qt as parseCidStringSchemaWithPKCErrorIfItFails, rt as require_lib$1, s as LRUCache, sn as parseCreateCommentModerationOptionsSchemaWithPKCErrorIfItFails, st as signChallengeRequest, t as RpcLocalCommunity, tn as parseCommunityAddressWithPKCErrorIfItFails, u as KeyvBetterSqlite3, ut as signCommentEdit, vn as parseJsonWithPKCErrorIfFails, vt as verifyChallengeMessage, wn as parseVotePubsubMessagePublicationSchemaWithPKCErrorIfItFails, wt as verifyCommentPubsubMessage, xn as parseRpcCommentUpdateEventWithPKCErrorIfItFails, xt as verifyCommentEdit, y as encryptEd25519AesGcm, yn as parsePKCUserOptionsSchemaWithPKCErrorIfItFails, z as tryToDeleteCommunitiesThatFailedToBeDeletedBefore, zn as RpcResolveAuthorNameResultSchema, zt as decode } from "./rpc-local-community-
|
|
3
|
-
import { n as getHeliaDebugContext } from "./util-
|
|
1
|
+
import { B as isIpfsCid, Cn as CommentUpdateForChallengeVerificationSchema, Cr as parsedType, Ct as findUpdatingCommunity, D as deepMergeRuntimeFields, Dr as __require, Dt as refreshTrackedCommentAliases, E as createAbortError, En as CommentUpdateSchema, Et as listUpdatingCommunities, It as require_sha256, L as hideClassPrivateProps, Lt as TimeoutError, Or as __toESM, Pt as untrackUpdatingComment, Q as isStringDomain, Qn as CID, Rt as pTimeout, Sr as joinValues, St as findUpdatingComment, Tr as __commonJSMin, Tt as listUpdatingComments, Xn as require_commonjs, Zn as require_retry, _t as timestamp, a as ChallengeRequestMessageSchema, b as areEquivalentCommunityAddresses, cn as PubsubTopicSchema, cr as logger_default, ct as resolveWhenPredicateIsTrue, dr as setErrorMap, ft as shortifyAddress, jt as trackUpdatingComment, k as doesDomainAddressHaveCapitalLetter, mt as sleepUntilTimeoutOrAbort, nn as CommunityIpfsSchema, or as PKCError, ot as removeUndefinedValuesRecursively, pt as shortifyCid, r as ChallengeMessageSchema, s as ChallengeVerificationMessageSchema, sr as messages, st as replaceXWithY, t as ChallengeAnswerMessageSchema, tr as FailedToFetchCommentIpfsFromGatewaysError, ut as retryKuboIpfsAdd, vn as CommentIpfsSchema, vt as waitForUpdateInCommunityInstanceWithErrorAndTimeout, wr as stringifyPrimitive, wt as listStartedCommunities, xt as findStartedCommunity, y as version_default, z as isAbortError } from "./schema-D0I45iuK.js";
|
|
2
|
+
import { $ as PKCClientsManager, $t as parseCommentModerationPubsubMessagePublicationSchemaWithPKCErrorIfItFails, An as RpcCommunityPageParamSchema, At as cleanWireAuthor, B as CommentClientsManager, Bn as RpcSubscriptionIdResultSchema, Ct as verifyCommentModeration, Dn as RpcCidParamSchema, Dt as verifyCommunityEdit, En as RpcCancelExportParamSchema, F as monitorCommunitiesDirectory, Fn as RpcExportCommunityResultSchema, Ft as getCommunityAddressFromRecord, Hn as RpcUnsubscribeParamSchema, In as RpcFetchCidParamSchema, It as getCommunityNameFromWire, J as findCommentInPageInstanceRecursively, Kn as nativeFunctions$2, Ln as RpcFetchCidResultSchema, Lt as getCommunityPublicKeyFromWire, Mn as RpcExportCommunityModLogsParamSchema, Nn as RpcExportCommunityModLogsResultSchema, Nt as normalizeCreatePublicationAuthor, On as RpcCommentRepliesPageParamSchema, Ot as verifyVote, P as listCommunitiesSync, Pn as RpcExportCommunityParamSchema, Pt as buildRuntimeCommunityFields, Q as PublicationClientsManager, R as setNativeFunctions$1, Rn as RpcPublishChallengeAnswersParamSchema, Rt as normalizeCommunityInputFromCommunity, Sn as parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, St as verifyCommentIpfs, T as createKuboRpcClient, Tn as RpcAuthorNameParamSchema, Tt as verifyCommentUpdate, Vn as RpcSuccessResultSchema, Vt as getBufferedPKCAddressFromPublicKey, X as parseRawPages, Xt as parseCommentEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, Z as RepliesPages, Zt as parseCommentIpfsSchemaWithPKCErrorIfItFails, _ as decryptEd25519AesGcm, _n as parseDecryptedChallengeWithPKCErrorIfItFails, a as pkcJsChallenges, at as signChallengeAnswer, bn as parseRpcCommentEventWithPKCErrorIfItFails, bt as verifyChallengeVerification, c as RemoteCommunity, cn as parseCreateCommentOptionsSchemaWithPKCErrorIfItFails, d as decodeRpcChallengeAnswerPubsubMsg, dt as signCommentModeration, en as parseCommentPubsubMessagePublicationWithPKCErrorIfItFails, et as InflightFetchManager, f as decodeRpcChallengePubsubMsg, fn as parseCreateRemoteCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, g as createSigner, gn as parseDecryptedChallengeVerification, gt as signVote, hn as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, ht as signCommunityEdit, in as parseCommunityEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, it as cleanUpBeforePublishing, j as getDefaultDataPath, jn as RpcEditCommunityParamSchema, jt as getAuthorNameFromRuntime, kn as RpcCommunityIdentifierParamSchema, kt as buildRuntimeAuthor, ln as parseCreateCommunityEditPublicationOptionsSchemaWithPKCErrorIfItFails, lt as signComment, m as decodeRpcChallengeVerificationPubsubMsg, mn as parseCreateVoteOptionsSchemaWithPKCErrorIfItFails, n as RpcRemoteCommunity, nt as PKCTypedEmitter, o as TrackedInstanceRegistry, on as parseCreateCommentEditOptionsSchemaWithPKCErrorIfItFails, p as decodeRpcChallengeRequestPubsubMsg, pn as parseCreateRpcCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, q as extractCommunityRuntimeFieldsFromParsedPages, qn as require_undici, qt as parseCidStringSchemaWithPKCErrorIfItFails, rt as require_lib$1, s as LRUCache, sn as parseCreateCommentModerationOptionsSchemaWithPKCErrorIfItFails, st as signChallengeRequest, t as RpcLocalCommunity, tn as parseCommunityAddressWithPKCErrorIfItFails, u as KeyvBetterSqlite3, ut as signCommentEdit, vn as parseJsonWithPKCErrorIfFails, vt as verifyChallengeMessage, wn as parseVotePubsubMessagePublicationSchemaWithPKCErrorIfItFails, wt as verifyCommentPubsubMessage, xn as parseRpcCommentUpdateEventWithPKCErrorIfItFails, xt as verifyCommentEdit, y as encryptEd25519AesGcm, yn as parsePKCUserOptionsSchemaWithPKCErrorIfItFails, z as tryToDeleteCommunitiesThatFailedToBeDeletedBefore, zn as RpcResolveAuthorNameResultSchema, zt as decode } from "./rpc-local-community-CTDbXkkP.js";
|
|
3
|
+
import { n as getHeliaDebugContext } from "./util-C0EAYvmS.js";
|
|
4
4
|
import path from "path";
|
|
5
5
|
import assert from "assert";
|
|
6
6
|
import fs from "fs";
|
|
@@ -1431,7 +1431,8 @@ var Comment = class extends Publication {
|
|
|
1431
1431
|
_scheduleParallelCommunityConnect(log) {
|
|
1432
1432
|
if (!this.communityName && !this.communityPublicKey) return;
|
|
1433
1433
|
const stopSignal = this._getStopAbortSignal();
|
|
1434
|
-
|
|
1434
|
+
(async () => {
|
|
1435
|
+
await sleepUntilTimeoutOrAbort(5e3, stopSignal);
|
|
1435
1436
|
if (this.raw.comment) return;
|
|
1436
1437
|
if (this._isStopAbortRequested() || this._pkc.destroyed) return;
|
|
1437
1438
|
log("Starting parallel pkc.getCommunity for", this.cid, "so bitswap can fetch the comment block from community peers");
|
|
@@ -1443,9 +1444,7 @@ var Comment = class extends Publication {
|
|
|
1443
1444
|
} catch (err) {
|
|
1444
1445
|
if (!isAbortError(err)) log.error("Parallel pkc.getCommunity failed for", this.cid, err);
|
|
1445
1446
|
}
|
|
1446
|
-
}
|
|
1447
|
-
if (stopSignal) if (stopSignal.aborted) clearTimeout(timer);
|
|
1448
|
-
else stopSignal.addEventListener("abort", () => clearTimeout(timer), { once: true });
|
|
1447
|
+
})();
|
|
1449
1448
|
}
|
|
1450
1449
|
async _attemptToFetchCommentIpfsIfNeeded(log) {
|
|
1451
1450
|
if (this.cid && !this.raw.comment) {
|
|
@@ -6805,7 +6804,7 @@ var PKC$1 = class extends PKCTypedEmitter {
|
|
|
6805
6804
|
this.clients.libp2pJsClients = {};
|
|
6806
6805
|
if (!this.libp2pJsClientsOptions) return;
|
|
6807
6806
|
if (!this.httpRoutersOptions) throw Error("httpRoutersOptions is required for libp2pJsClient");
|
|
6808
|
-
const { createLibp2pJsClientOrUseExistingOne } = await import("./helia-for-pkc-
|
|
6807
|
+
const { createLibp2pJsClientOrUseExistingOne } = await import("./helia-for-pkc-BZ6rZnW_.js");
|
|
6809
6808
|
for (const clientOptions of this.libp2pJsClientsOptions) {
|
|
6810
6809
|
const heliaNode = await createLibp2pJsClientOrUseExistingOne({
|
|
6811
6810
|
...clientOptions,
|
|
@@ -7044,7 +7043,7 @@ var PKC$1 = class extends PKCTypedEmitter {
|
|
|
7044
7043
|
const log = logger_default("pkc-js:pkc:createLocalCommunity");
|
|
7045
7044
|
log.trace("Received community options to create a local community instance:", options);
|
|
7046
7045
|
if (!this._canCreateNewLocalCommunity()) throw new PKCError("ERR_CAN_NOT_CREATE_A_LOCAL_COMMUNITY", { pkcOptions: this._userPKCOptions });
|
|
7047
|
-
const { LocalCommunity, createNewLocalCommunityDb, updateInstancePropsWithStartedCommunityOrDb } = await import("./local-community-
|
|
7046
|
+
const { LocalCommunity, createNewLocalCommunityDb, updateInstancePropsWithStartedCommunityOrDb } = await import("./local-community-CPvHllf9.js");
|
|
7048
7047
|
const isLocalCommunity = (await listCommunitiesSync(this)).includes(options.address);
|
|
7049
7048
|
const community = new LocalCommunity(this);
|
|
7050
7049
|
if (isLocalCommunity) {
|
package/dist/bundled/chunks/{rpc-local-community-Xpx65cbz.js → rpc-local-community-CTDbXkkP.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as pubsubTopicToDhtKey, $n as
|
|
1
|
+
import { $ as pubsubTopicToDhtKey, $n as create, $t as CommunityEditOptionsSchema, A as extractNetworkErrorDetails, An as CreateCommentOptionsWithRefinementSchema, At as trackStartedCommunity, B as isIpfsCid, Bn as CreateCommentEditOptionsWithRefinementSchema, Ct as findUpdatingCommunity, D as deepMergeRuntimeFields, Dn as CommentUpdateSignedPropertyNames, Dr as __require, E as createAbortError, En as CommentUpdateSchema, Er as __exportAll, 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 __toESM, Ot as refreshTrackedCommunityAliases, Pn as CommentEditChallengeRequestToEncryptSchema, Q as isStringDomain, Qn as CID$1, Qt as CommunityChallengeSettingSchema, R as ipnsNameToIpnsOverPubsubTopic, Rn as CommentEditSignedPropertyNames, Rt as pTimeout, Sn as CommentUpdateChallengeReservedFieldNames, St as findUpdatingComment, Tn as CommentUpdateReservedFields, Tr as __commonJSMin, 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 require_commonjs$4, Xt as ChallengeFileFactorySchema, Yn as CreateSignerSchema, Yt as CreateCommentModerationOptionsWithRefinementSchema, Z as isRequestPubsubPublicationOfReply, Zn as require_retry$1, Zt as ChallengeFileSchema, _ as PKCUserOptionBaseSchema, _n as CommentIpfsReservedFields, _r as number, _t as timestamp, an as CreateRemoteCommunityFunctionArgumentSchema, ar as FailedToFetchPageIpfsFromGatewaysError, b as areEquivalentCommunityAddresses, bn as CommentPubsubMessageWithFlexibleAuthorRefinementSchema, br as string, c as ChallengeVerificationMessageSignedPropertyNames, cr as logger_default, ct as resolveWhenPredicateIsTrue, dn as VoteChallengeRequestToEncryptSchema, en as CommunityExportRecordsSchema, er as all, f as DecryptedChallengeSchema, fn as VotePubsubMessagePublicationSchema, fr as _enum, ft as shortifyAddress, g as PKCParsedOptionsSchema, gn as CommentChallengeRequestToEncryptSchema, gr as literal, gt as throwIfAbortSignalAborted, h as NameResolverSerializedSchema, hr as custom, i as ChallengeMessageSignedPropertyNames, in as CreateNewLocalCommunityUserOptionsSchema, ir as FailedToFetchGenericIpfsFromGatewaysError, it as removeNullUndefinedEmptyObjectsValuesRecursively, j as fetchAndValidateIpnsRecordFromGateway, jn as GetPageParamSchema, k as doesDomainAddressHaveCapitalLetter, l as DecryptedChallengeAnswerSchema, ln as RpcRemoteCommunityUpdateEventResultSchema, lr as require_supports_color, m as NameResolveCacheOptionsSchema, mn as VoteSignedPropertyNames, mr as boolean, mt as sleepUntilTimeoutOrAbort, n as ChallengeAnswerMessageSignedPropertyNames, nn as CommunityIpfsSchema, nr as FailedToFetchCommentUpdateFromGatewaysError, o as ChallengeRequestMessageSignedPropertyNames, on as CreateRpcCommunityFunctionArgumentSchema, or as PKCError, p as DecryptedChallengeVerificationSchema, pr as array, pt as shortifyCid, qn as CommunityAddressSchema, qt as CommentModerationSignedPropertyNames, rn as CommunitySignedPropertyNames, rr as FailedToFetchCommunityFromGatewaysError, sn as ExportCommunityModLogsOptionsSchema, sr as messages, tn as CommunityIpfsReservedFields, tr as FailedToFetchCommentIpfsFromGatewaysError, tt as raceAgainstAbort, un as CreateVoteUserOptionsWithRefinementSchema, ur as require_ms$1, v as PKCUserOptionsSchema, vn as CommentIpfsSchema, vr as object, vt as waitForUpdateInCommunityInstanceWithErrorAndTimeout, wn as CommentUpdateForChallengeVerificationSignedPropertyNames, wt as listStartedCommunities, x as calculateIpfsCidV0, xn as CommentSignedPropertyNames, xt as findStartedCommunity, yr as record, z as isAbortError, zt as CommunityEditPublicationChallengeRequestToEncryptSchema } from "./schema-D0I45iuK.js";
|
|
2
2
|
import { createHash } from "node:crypto";
|
|
3
3
|
import { pathToFileURL } from "node:url";
|
|
4
4
|
import dns from "node:dns";
|
|
@@ -98914,14 +98914,10 @@ var BaseClientsManager = class BaseClientsManager {
|
|
|
98914
98914
|
});
|
|
98915
98915
|
try {
|
|
98916
98916
|
throwIfAbortSignalAborted(abortSignal);
|
|
98917
|
-
const
|
|
98917
|
+
const result = await raceAgainstAbort(nameResolver.resolve({
|
|
98918
98918
|
name,
|
|
98919
98919
|
abortSignal
|
|
98920
|
-
});
|
|
98921
|
-
const result = abortSignal ? await Promise.race([resolvePromise, new Promise((_, reject) => {
|
|
98922
|
-
if (abortSignal.aborted) reject(createAbortError());
|
|
98923
|
-
else abortSignal.addEventListener("abort", () => reject(createAbortError()), { once: true });
|
|
98924
|
-
})]) : await resolvePromise;
|
|
98920
|
+
}), abortSignal);
|
|
98925
98921
|
throwIfAbortSignalAborted(abortSignal);
|
|
98926
98922
|
value = result?.publicKey;
|
|
98927
98923
|
} catch (e) {
|
|
@@ -124598,15 +124594,7 @@ var CommunityClientsManager = class extends PKCClientsManager {
|
|
|
124598
124594
|
} catch (e) {
|
|
124599
124595
|
log.error(`Failed to update community ${this._community.address} for this iteration, will retry later`, e);
|
|
124600
124596
|
} finally {
|
|
124601
|
-
await
|
|
124602
|
-
const stopSignal = this._community._getStopAbortSignal();
|
|
124603
|
-
if (stopSignal?.aborted) return resolve();
|
|
124604
|
-
const timer = setTimeout(resolve, updateInterval);
|
|
124605
|
-
stopSignal?.addEventListener("abort", () => {
|
|
124606
|
-
clearTimeout(timer);
|
|
124607
|
-
resolve();
|
|
124608
|
-
}, { once: true });
|
|
124609
|
-
});
|
|
124597
|
+
await sleepUntilTimeoutOrAbort(updateInterval, this._community._getStopAbortSignal());
|
|
124610
124598
|
}
|
|
124611
124599
|
this._community._clearStopAbortController();
|
|
124612
124600
|
log("Community", this._community.address, "is no longer updating");
|
|
@@ -127360,7 +127348,7 @@ const shouldExcludeChallengeCommentCids = async (communityChallenge, challengeRe
|
|
|
127360
127348
|
} catch (e) {
|
|
127361
127349
|
throw e;
|
|
127362
127350
|
} finally {
|
|
127363
|
-
getCommentPending[pendingKey]
|
|
127351
|
+
delete getCommentPending[pendingKey];
|
|
127364
127352
|
}
|
|
127365
127353
|
};
|
|
127366
127354
|
const validateComment = async (commentCid, addressesSet, exclude) => {
|