@pkcprotocol/pkc-js 0.0.145 → 0.0.147
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/README.md +88 -55
- package/dist/browser/clients/base-client-manager.js +14 -2
- package/dist/browser/clients/base-client-manager.js.map +1 -1
- package/dist/browser/errors.d.ts +3 -0
- package/dist/browser/errors.js +3 -0
- package/dist/browser/errors.js.map +1 -1
- package/dist/browser/generated-version.d.ts +1 -1
- package/dist/browser/generated-version.js +1 -1
- package/dist/browser/pkc-error.d.ts +1 -1
- package/dist/browser/publications/comment/comment-client-manager.d.ts +15 -3
- package/dist/browser/publications/comment/comment-client-manager.js +221 -10
- package/dist/browser/publications/comment/comment-client-manager.js.map +1 -1
- package/dist/browser/publications/comment/comment.js +1 -0
- package/dist/browser/publications/comment/comment.js.map +1 -1
- package/dist/browser/publications/publication.d.ts +1 -0
- package/dist/browser/publications/publication.js +24 -5
- package/dist/browser/publications/publication.js.map +1 -1
- package/dist/browser/runtime/node/community/challenges/index.js +14 -0
- package/dist/browser/runtime/node/community/challenges/index.js.map +1 -1
- package/dist/browser/runtime/node/community/db-handler.d.ts +5 -1
- package/dist/browser/runtime/node/community/db-handler.js +64 -12
- package/dist/browser/runtime/node/community/db-handler.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/db-state.d.ts +3 -1
- package/dist/browser/runtime/node/community/local-community/db-state.js +104 -16
- package/dist/browser/runtime/node/community/local-community/db-state.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/defaults.d.ts +1 -0
- package/dist/browser/runtime/node/community/local-community/defaults.js +5 -0
- package/dist/browser/runtime/node/community/local-community/defaults.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/editing.js +121 -24
- package/dist/browser/runtime/node/community/local-community/editing.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/ipns-publishing.js +2 -1
- package/dist/browser/runtime/node/community/local-community/ipns-publishing.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/lifecycle.d.ts +2 -0
- package/dist/browser/runtime/node/community/local-community/lifecycle.js +153 -30
- package/dist/browser/runtime/node/community/local-community/lifecycle.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community.d.ts +5 -0
- package/dist/browser/runtime/node/community/local-community.js +10 -1
- package/dist/browser/runtime/node/community/local-community.js.map +1 -1
- package/dist/browser/runtime/node/util.d.ts +9 -0
- package/dist/browser/runtime/node/util.js +141 -25
- package/dist/browser/runtime/node/util.js.map +1 -1
- package/dist/browser/test/test-util.d.ts +7 -1
- package/dist/browser/test/test-util.js +45 -16
- package/dist/browser/test/test-util.js.map +1 -1
- package/dist/bundled/bundle-manifest.json +40 -40
- package/dist/bundled/challenges.js +1 -1
- package/dist/bundled/chunks/{helia-for-pkc-7vdzP67t.js → helia-for-pkc-jM3y3OXF.js} +2 -2
- package/dist/bundled/chunks/{local-community-UB_rVgR9.js → local-community-5X7bvOoN.js} +332 -70
- package/dist/bundled/chunks/{local-community-Bi1JGMMa.js → local-community-P9e5jksW.js} +1 -1
- package/dist/bundled/chunks/{node-BT3m9Nml.js → node-By3og2hw.js} +173 -17
- package/dist/bundled/chunks/{page-sort-scoring-Bsc4MAy1.js → page-sort-scoring-DwYGP_0d.js} +1 -1
- package/dist/bundled/chunks/{rpc-local-community-DVykDP0T.js → rpc-local-community-WnhiTbxm.js} +132 -29
- package/dist/bundled/chunks/{util-BxfB5cRB.js → util-7QtFMzpc.js} +1 -1
- package/dist/bundled/chunks/{util-D6z8nIoj.js → util-DMr7Hj-w.js} +4 -1
- package/dist/bundled/chunks/{validate-package-factories-CiY6DjnH.js → validate-package-factories-TwRblx9f.js} +2 -2
- package/dist/bundled/index.js +1 -1
- package/dist/bundled/page-sorts.js +1 -1
- package/dist/bundled/rpc/src/index.js +4 -4
- package/dist/node/clients/base-client-manager.js +14 -2
- package/dist/node/clients/base-client-manager.js.map +1 -1
- package/dist/node/errors.d.ts +3 -0
- package/dist/node/errors.js +3 -0
- package/dist/node/errors.js.map +1 -1
- package/dist/node/generated-version.d.ts +1 -1
- package/dist/node/generated-version.js +1 -1
- package/dist/node/pkc-error.d.ts +1 -1
- package/dist/node/publications/comment/comment-client-manager.d.ts +15 -3
- package/dist/node/publications/comment/comment-client-manager.js +221 -10
- package/dist/node/publications/comment/comment-client-manager.js.map +1 -1
- package/dist/node/publications/comment/comment.js +1 -0
- package/dist/node/publications/comment/comment.js.map +1 -1
- package/dist/node/publications/publication.d.ts +1 -0
- package/dist/node/publications/publication.js +24 -5
- package/dist/node/publications/publication.js.map +1 -1
- package/dist/node/runtime/node/community/challenges/index.js +14 -0
- package/dist/node/runtime/node/community/challenges/index.js.map +1 -1
- package/dist/node/runtime/node/community/db-handler.d.ts +5 -1
- package/dist/node/runtime/node/community/db-handler.js +64 -12
- package/dist/node/runtime/node/community/db-handler.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/db-state.d.ts +3 -1
- package/dist/node/runtime/node/community/local-community/db-state.js +104 -16
- package/dist/node/runtime/node/community/local-community/db-state.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/defaults.d.ts +1 -0
- package/dist/node/runtime/node/community/local-community/defaults.js +5 -0
- package/dist/node/runtime/node/community/local-community/defaults.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/editing.js +121 -24
- package/dist/node/runtime/node/community/local-community/editing.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/ipns-publishing.js +2 -1
- package/dist/node/runtime/node/community/local-community/ipns-publishing.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/lifecycle.d.ts +2 -0
- package/dist/node/runtime/node/community/local-community/lifecycle.js +153 -30
- package/dist/node/runtime/node/community/local-community/lifecycle.js.map +1 -1
- package/dist/node/runtime/node/community/local-community.d.ts +5 -0
- package/dist/node/runtime/node/community/local-community.js +10 -1
- package/dist/node/runtime/node/community/local-community.js.map +1 -1
- package/dist/node/runtime/node/util.d.ts +9 -0
- package/dist/node/runtime/node/util.js +141 -25
- package/dist/node/runtime/node/util.js.map +1 -1
- package/dist/node/test/test-util.d.ts +7 -1
- package/dist/node/test/test-util.js +45 -16
- package/dist/node/test/test-util.js.map +1 -1
- package/package.json +1 -1
package/dist/bundled/chunks/{rpc-local-community-DVykDP0T.js → rpc-local-community-WnhiTbxm.js}
RENAMED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { i as __toESM, n as __exportAll, r as __require, t as __commonJSMin } from "./chunk-2rV9d50f.js";
|
|
2
|
-
import { $n as CommentEditSignedPropertyNames, $r as record, $t as CommunityEditPubsubMessagePublicationSchema, A as isIpnsPath, An as CommentChallengeRequestToEncryptSchema, Ar as t$9, At as pTimeout, B as pubsubTopicToDhtKey, Bn as CommentUpdateSchema, Br as logger_default, C as hideClassPrivateProps, Cn as RpcRemoteCommunityUpdateEventResultSchema, Cr as e$5, D as isIpfsCid, Dr as n$8, Dt as untrackUpdatingCommunity, E as isAbortError, En as VotePubsubMessagePublicationSchema, Er as t$12, Fn as CommentSignedPropertyNames, Fr as FailedToFetchCommunityFromGatewaysError, Gn as GetPageParamSchema, Gr as array, Gt as NameResolverSerializedSchema, H as raceAgainstAbort, Hr as require_ms$1, Ht as DecryptedChallengeSchema, In as CommentUpdateChallengeReservedFieldNames, Ir as FailedToFetchGenericIpfsFromGatewaysError, It as ChallengeRequestMessageSignedPropertyNames, Jn as isReservedObjectKey, Jr as literal, Jt as PKCUserOptionsSchema, Kn as ModQueuePageIpfsSchema, Kr as boolean, Kt as PKCParsedOptionsSchema, L as isRequestPubsubPublicationOfPost, Lr as FailedToFetchPageIpfsFromGatewaysError, Mn as CommentIpfsSchema, Mr as require_retry$2, Mt as ChallengeAnswerMessageSignedPropertyNames, Nr as FailedToFetchCommentIpfsFromGatewaysError, O as isIpfsPath, On as VoteSignedPropertyNames, Or as r$7, Ot as require_sha256$1, Pn as CommentPubsubMessageWithFlexibleAuthorRefinementSchema, Pr as FailedToFetchCommentUpdateFromGatewaysError, Pt as ChallengeMessageSignedPropertyNames, Qr as preprocess, Qt as CommunityEditPublicationSignedPropertyNames, R as isRequestPubsubPublicationOfReply, Rn as CommentUpdateForChallengeVerificationSignedPropertyNames, Rr as PKCError, Rt as ChallengeVerificationMessageSignedPropertyNames, S as hasTransientNetworkErrorCode, Sr as e$6, St as trackStartedCommunity, T as ipnsNameToIpnsOverPubsubTopic, Tn as VoteChallengeRequestToEncryptSchema, Tr as r$8, Tt as untrackStartedCommunity, Ut as DecryptedChallengeVerificationSchema, Vn as CommentUpdateSignedPropertyNames, Vr as require_supports_color, Wn as CreateCommentOptionsWithRefinementSchema, Wr as _enum, Wt as NameResolveCacheOptionsSchema, Xr as number, Xt as CommunityEditPublicationChallengeRequestToEncryptSchema, Yn as CommentEditChallengeRequestToEncryptSchema, Yr as looseObject, Zn as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema, Zr as object, _n as CreateRemoteCommunityFunctionArgumentSchema, _r as n$9, an as CommentModerationsTableRowSchema, ar as AuthorReservedFields, at as throwIfAbortSignalAborted, bn as PageSortFileFactorySchema, bt as refreshTrackedCommunityAliases, cn as ChallengeFileSchema, cr as CidStringSchema, d as deepMergeRuntimeFields, dn as CommunityEditOptionsSchema, dr as CreateSignerSchema, ei as string, en as CreateCommunityEditPublicationOptionsWithRefinementSchema, f as derivePublicationFromChallengeRequest, fn as CommunityExportRecordsSchema, fr as JsonSignatureSchema, ft as findStartedCommunity, gn as CreateNewLocalCommunityUserOptionsSchema, gr as isStringDomain, h as fetchAndValidateIpnsRecordFromGateway, hn as CommunitySignedPropertyNames, hr as areEquivalentNames, ht as forgetTrackedUpdatingCommunityName, in as CommentModerationSignedPropertyNames, ir as AuthorPubsubSchema, jn as CommentIpfsReservedFields, jr as e$4, k as isIpns, kr as t$10, lr as CommunityAddressSchema, m as extractNetworkErrorDetails, mn as CommunityIpfsSchema, mr as ProtocolVersionSchema, mt as findUpdatingCommunity, nn as CommentModerationPubsubMessagePublicationSchema, nr as AuthorAddressSchema, nt as shortifyCid, on as CreateCommentModerationOptionsWithRefinementSchema, or as ChallengeAnswersSchema, ot as timestamp, p as doesDomainAddressHaveCapitalLetter, pn as CommunityIpfsReservedFields, pr as PKCTimestampSchema, q as removeNullUndefinedEmptyObjectsValuesRecursively, qn as PageIpfsSchema, qr as custom, qt as PKCUserOptionBaseSchema, r as calculateIpfsCidV0, rr as AuthorCommentIpfsReservedFields, rt as sleepUntilTimeoutOrAbort, sn as ChallengeFileFactorySchema, sr as CidPathSchema, t as areEquivalentCommunityAddresses, ti as union, tn as CommentModerationChallengeRequestToEncryptSchema, tr as CreateCommentEditOptionsWithRefinementSchema, tt as shortifyAddress, u as createAbortError, un as CommunityChallengeSettingSchema, ur as CommunityAuthorChallengeReservedFieldNames, vn as CreateRpcCommunityFunctionArgumentSchema, w as interruptibleSleep, wn as CreateVoteUserOptionsWithRefinementSchema, wr as t$11, wt as trackUpdatingCommunity, xn as PageSortFileSchema, xr as t$13, yn as ExportCommunityModLogsOptionsSchema, yr as n$10, z as linkAbortSignals, zn as CommentUpdateReservedFields, zr as messages, zt as DecryptedChallengeAnswerSchema } from "./util-
|
|
2
|
+
import { $n as CommentEditSignedPropertyNames, $r as record, $t as CommunityEditPubsubMessagePublicationSchema, A as isIpnsPath, An as CommentChallengeRequestToEncryptSchema, Ar as t$9, At as pTimeout, B as pubsubTopicToDhtKey, Bn as CommentUpdateSchema, Br as logger_default, C as hideClassPrivateProps, Cn as RpcRemoteCommunityUpdateEventResultSchema, Cr as e$5, D as isIpfsCid, Dr as n$8, Dt as untrackUpdatingCommunity, E as isAbortError, En as VotePubsubMessagePublicationSchema, Er as t$12, Fn as CommentSignedPropertyNames, Fr as FailedToFetchCommunityFromGatewaysError, Gn as GetPageParamSchema, Gr as array, Gt as NameResolverSerializedSchema, H as raceAgainstAbort, Hr as require_ms$1, Ht as DecryptedChallengeSchema, In as CommentUpdateChallengeReservedFieldNames, Ir as FailedToFetchGenericIpfsFromGatewaysError, It as ChallengeRequestMessageSignedPropertyNames, Jn as isReservedObjectKey, Jr as literal, Jt as PKCUserOptionsSchema, Kn as ModQueuePageIpfsSchema, Kr as boolean, Kt as PKCParsedOptionsSchema, L as isRequestPubsubPublicationOfPost, Lr as FailedToFetchPageIpfsFromGatewaysError, Mn as CommentIpfsSchema, Mr as require_retry$2, Mt as ChallengeAnswerMessageSignedPropertyNames, Nr as FailedToFetchCommentIpfsFromGatewaysError, O as isIpfsPath, On as VoteSignedPropertyNames, Or as r$7, Ot as require_sha256$1, Pn as CommentPubsubMessageWithFlexibleAuthorRefinementSchema, Pr as FailedToFetchCommentUpdateFromGatewaysError, Pt as ChallengeMessageSignedPropertyNames, Qr as preprocess, Qt as CommunityEditPublicationSignedPropertyNames, R as isRequestPubsubPublicationOfReply, Rn as CommentUpdateForChallengeVerificationSignedPropertyNames, Rr as PKCError, Rt as ChallengeVerificationMessageSignedPropertyNames, S as hasTransientNetworkErrorCode, Sr as e$6, St as trackStartedCommunity, T as ipnsNameToIpnsOverPubsubTopic, Tn as VoteChallengeRequestToEncryptSchema, Tr as r$8, Tt as untrackStartedCommunity, Ut as DecryptedChallengeVerificationSchema, Vn as CommentUpdateSignedPropertyNames, Vr as require_supports_color, Wn as CreateCommentOptionsWithRefinementSchema, Wr as _enum, Wt as NameResolveCacheOptionsSchema, Xr as number, Xt as CommunityEditPublicationChallengeRequestToEncryptSchema, Yn as CommentEditChallengeRequestToEncryptSchema, Yr as looseObject, Zn as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema, Zr as object, _n as CreateRemoteCommunityFunctionArgumentSchema, _r as n$9, an as CommentModerationsTableRowSchema, ar as AuthorReservedFields, at as throwIfAbortSignalAborted, bn as PageSortFileFactorySchema, bt as refreshTrackedCommunityAliases, cn as ChallengeFileSchema, cr as CidStringSchema, d as deepMergeRuntimeFields, dn as CommunityEditOptionsSchema, dr as CreateSignerSchema, ei as string, en as CreateCommunityEditPublicationOptionsWithRefinementSchema, f as derivePublicationFromChallengeRequest, fn as CommunityExportRecordsSchema, fr as JsonSignatureSchema, ft as findStartedCommunity, gn as CreateNewLocalCommunityUserOptionsSchema, gr as isStringDomain, h as fetchAndValidateIpnsRecordFromGateway, hn as CommunitySignedPropertyNames, hr as areEquivalentNames, ht as forgetTrackedUpdatingCommunityName, in as CommentModerationSignedPropertyNames, ir as AuthorPubsubSchema, jn as CommentIpfsReservedFields, jr as e$4, k as isIpns, kr as t$10, lr as CommunityAddressSchema, m as extractNetworkErrorDetails, mn as CommunityIpfsSchema, mr as ProtocolVersionSchema, mt as findUpdatingCommunity, nn as CommentModerationPubsubMessagePublicationSchema, nr as AuthorAddressSchema, nt as shortifyCid, on as CreateCommentModerationOptionsWithRefinementSchema, or as ChallengeAnswersSchema, ot as timestamp, p as doesDomainAddressHaveCapitalLetter, pn as CommunityIpfsReservedFields, pr as PKCTimestampSchema, q as removeNullUndefinedEmptyObjectsValuesRecursively, qn as PageIpfsSchema, qr as custom, qt as PKCUserOptionBaseSchema, r as calculateIpfsCidV0, rr as AuthorCommentIpfsReservedFields, rt as sleepUntilTimeoutOrAbort, sn as ChallengeFileFactorySchema, sr as CidPathSchema, t as areEquivalentCommunityAddresses, ti as union, tn as CommentModerationChallengeRequestToEncryptSchema, tr as CreateCommentEditOptionsWithRefinementSchema, tt as shortifyAddress, u as createAbortError, un as CommunityChallengeSettingSchema, ur as CommunityAuthorChallengeReservedFieldNames, vn as CreateRpcCommunityFunctionArgumentSchema, w as interruptibleSleep, wn as CreateVoteUserOptionsWithRefinementSchema, wr as t$11, wt as trackUpdatingCommunity, xn as PageSortFileSchema, xr as t$13, yn as ExportCommunityModLogsOptionsSchema, yr as n$10, z as linkAbortSignals, zn as CommentUpdateReservedFields, zr as messages, zt as DecryptedChallengeAnswerSchema } from "./util-DMr7Hj-w.js";
|
|
3
3
|
import { t as all } from "./src-CYIMjhjK.js";
|
|
4
|
-
import { s as validatePageSortFile } from "./page-sort-scoring-
|
|
4
|
+
import { s as validatePageSortFile } from "./page-sort-scoring-DwYGP_0d.js";
|
|
5
5
|
import { createHash } from "node:crypto";
|
|
6
6
|
import { pathToFileURL } from "node:url";
|
|
7
7
|
import dns from "node:dns";
|
|
8
8
|
import os from "os";
|
|
9
|
-
import { closeSync, createReadStream, existsSync, openSync, promises, readSync, readdirSync, watch } from "node:fs";
|
|
9
|
+
import { closeSync, createReadStream, existsSync, openSync, promises, readSync, readdirSync, statSync, watch } from "node:fs";
|
|
10
10
|
import path from "path";
|
|
11
11
|
import assert from "assert";
|
|
12
12
|
import { Agent } from "https";
|
|
@@ -117771,27 +117771,40 @@ const setNativeFunctions = (newNativeFunctions) => {
|
|
|
117771
117771
|
for (const i in newNativeFunctions) nativeFunctions[i] = newNativeFunctions[i];
|
|
117772
117772
|
};
|
|
117773
117773
|
const WINDOWS_FILE_BUSY_ERROR_CODES = ["EBUSY", "EPERM"];
|
|
117774
|
+
async function removeFileRetryingWhileBusy(filePath, { timeoutMs = 1e4, log, keepIf }) {
|
|
117775
|
+
const deadline = Date.now() + timeoutMs;
|
|
117776
|
+
for (let retryDelayMs = 50;; retryDelayMs = Math.min(retryDelayMs * 2, 1e3)) {
|
|
117777
|
+
if (keepIf?.()) {
|
|
117778
|
+
log(`${filePath} is not to be removed any more, leaving it in place`);
|
|
117779
|
+
return;
|
|
117780
|
+
}
|
|
117781
|
+
try {
|
|
117782
|
+
await promises.rm(filePath, { force: true });
|
|
117783
|
+
return;
|
|
117784
|
+
} catch (e) {
|
|
117785
|
+
const code = e.code;
|
|
117786
|
+
if (!code || !WINDOWS_FILE_BUSY_ERROR_CODES.includes(code) || Date.now() + retryDelayMs >= deadline) throw e;
|
|
117787
|
+
log(`${filePath} is still busy (${code}), retrying its removal in ${retryDelayMs}ms`);
|
|
117788
|
+
await new Promise((resolve) => setTimeout(resolve, retryDelayMs));
|
|
117789
|
+
}
|
|
117790
|
+
}
|
|
117791
|
+
}
|
|
117774
117792
|
const deleteOldCommunityInWindows = async (subPath, pkc, { timeoutMs = 1e4 } = {}) => {
|
|
117775
117793
|
const log = logger_default("pkc-js:community:deleteStaleCommunityInWindows");
|
|
117776
117794
|
const communityAddress = path.basename(subPath);
|
|
117777
|
-
|
|
117778
|
-
|
|
117779
|
-
|
|
117795
|
+
try {
|
|
117796
|
+
await removeFileRetryingWhileBusy(subPath, {
|
|
117797
|
+
timeoutMs,
|
|
117798
|
+
log
|
|
117799
|
+
});
|
|
117780
117800
|
log(`Succeeded in deleting old community (${communityAddress})`);
|
|
117781
|
-
return;
|
|
117782
117801
|
} catch (e) {
|
|
117783
|
-
|
|
117784
|
-
|
|
117785
|
-
|
|
117786
|
-
|
|
117787
|
-
|
|
117788
|
-
|
|
117789
|
-
log
|
|
117790
|
-
});
|
|
117791
|
-
return;
|
|
117792
|
-
}
|
|
117793
|
-
log(`Old community (${communityAddress}) is still busy (${code}), retrying in ${retryDelayMs}ms`);
|
|
117794
|
-
await new Promise((resolve) => setTimeout(resolve, retryDelayMs));
|
|
117802
|
+
await recordCommunityThatFailedToBeDeleted({
|
|
117803
|
+
communityAddress,
|
|
117804
|
+
pkc,
|
|
117805
|
+
error: e,
|
|
117806
|
+
log
|
|
117807
|
+
});
|
|
117795
117808
|
}
|
|
117796
117809
|
};
|
|
117797
117810
|
async function recordCommunityThatFailedToBeDeleted({ communityAddress, pkc, error, log }) {
|
|
@@ -117802,6 +117815,16 @@ async function recordCommunityThatFailedToBeDeleted({ communityAddress, pkc, err
|
|
|
117802
117815
|
await pkc._storage.setItem(storageKey, communitiesThatWeFailedToDelete);
|
|
117803
117816
|
log(`Updated persistent deleted communities in storage`, communitiesThatWeFailedToDelete);
|
|
117804
117817
|
}
|
|
117818
|
+
async function forgetCommunityThatFailedToBeDeleted({ communityAddress, pkc }) {
|
|
117819
|
+
const log = logger_default("pkc-js:community:forgetCommunityThatFailedToBeDeleted");
|
|
117820
|
+
const storageKey = STORAGE_KEYS[STORAGE_KEYS.PERSISTENT_DELETED_COMMUNITIES];
|
|
117821
|
+
const communitiesThatWeFailedToDelete = await pkc._storage.getItem(storageKey);
|
|
117822
|
+
if (!Array.isArray(communitiesThatWeFailedToDelete) || !communitiesThatWeFailedToDelete.includes(communityAddress)) return;
|
|
117823
|
+
const remaining = communitiesThatWeFailedToDelete.filter((address) => address !== communityAddress);
|
|
117824
|
+
if (remaining.length === 0) await pkc._storage.removeItem(storageKey);
|
|
117825
|
+
else await pkc._storage.setItem(storageKey, remaining);
|
|
117826
|
+
log(`A live DB is being written to communities/${communityAddress}, removed it from the persistent deleted communities`, remaining);
|
|
117827
|
+
}
|
|
117805
117828
|
async function tryToDeleteCommunitiesThatFailedToBeDeletedBefore(pkc, log) {
|
|
117806
117829
|
const deletedPersistentCommunities = await pkc._storage.getItem(STORAGE_KEYS[STORAGE_KEYS.PERSISTENT_DELETED_COMMUNITIES]);
|
|
117807
117830
|
if (Array.isArray(deletedPersistentCommunities)) {
|
|
@@ -117839,6 +117862,37 @@ function getLocalCommunityIdentities(pkc) {
|
|
|
117839
117862
|
if (!identities) localCommunityIdentities.set(pkc, identities = /* @__PURE__ */ new Map());
|
|
117840
117863
|
return identities;
|
|
117841
117864
|
}
|
|
117865
|
+
const unreadableLocalCommunityDbs = /* @__PURE__ */ new WeakMap();
|
|
117866
|
+
function getUnreadableLocalCommunityDbs(pkc) {
|
|
117867
|
+
let unreadable = unreadableLocalCommunityDbs.get(pkc);
|
|
117868
|
+
if (!unreadable) unreadableLocalCommunityDbs.set(pkc, unreadable = /* @__PURE__ */ new Map());
|
|
117869
|
+
return unreadable;
|
|
117870
|
+
}
|
|
117871
|
+
const sqliteHeaderChecks = /* @__PURE__ */ new WeakMap();
|
|
117872
|
+
function getSqliteHeaderChecks(pkc) {
|
|
117873
|
+
let checks = sqliteHeaderChecks.get(pkc);
|
|
117874
|
+
if (!checks) sqliteHeaderChecks.set(pkc, checks = /* @__PURE__ */ new Map());
|
|
117875
|
+
return checks;
|
|
117876
|
+
}
|
|
117877
|
+
function getCommunityDbStatSignature(dbPath) {
|
|
117878
|
+
const statOrUndefined = (filePath) => {
|
|
117879
|
+
try {
|
|
117880
|
+
return statSync(filePath, { bigint: true });
|
|
117881
|
+
} catch {
|
|
117882
|
+
return;
|
|
117883
|
+
}
|
|
117884
|
+
};
|
|
117885
|
+
const dbStat = statOrUndefined(dbPath);
|
|
117886
|
+
if (!dbStat) return void 0;
|
|
117887
|
+
const walStat = statOrUndefined(`${dbPath}-wal`);
|
|
117888
|
+
const walSignature = walStat && walStat.size > 0n ? `${walStat.size}:${walStat.mtimeNs}` : "empty";
|
|
117889
|
+
return `${dbStat.ino}:${dbStat.size}:${dbStat.mtimeNs}:${dbStat.ctimeNs}:${walSignature}`;
|
|
117890
|
+
}
|
|
117891
|
+
const SQLITE_ERROR_CODES_ABOUT_THE_FILE = [
|
|
117892
|
+
"SQLITE_NOTADB",
|
|
117893
|
+
"SQLITE_CORRUPT",
|
|
117894
|
+
"SQLITE_ERROR"
|
|
117895
|
+
];
|
|
117842
117896
|
function readLocalCommunityIdentity(pkc, communityAddress) {
|
|
117843
117897
|
const log = logger_default("pkc-js:readLocalCommunityIdentity");
|
|
117844
117898
|
const dbPath = path.join(pkc.dataPath, "communities", communityAddress);
|
|
@@ -117853,15 +117907,22 @@ function readLocalCommunityIdentity(pkc, communityAddress) {
|
|
|
117853
117907
|
const publicKey = internalState?.anchor?.publicKey ?? internalState?.signer?.address;
|
|
117854
117908
|
if (typeof publicKey !== "string") {
|
|
117855
117909
|
log(`Community DB (${communityAddress}) has no internal state yet, leaving it out of pkc.communities for now`);
|
|
117856
|
-
return
|
|
117910
|
+
return {
|
|
117911
|
+
identity: void 0,
|
|
117912
|
+
unreadableUntilFileChanges: true
|
|
117913
|
+
};
|
|
117857
117914
|
}
|
|
117858
|
-
return isStringDomain(communityAddress) ? {
|
|
117915
|
+
return { identity: isStringDomain(communityAddress) ? {
|
|
117859
117916
|
name: communityAddress,
|
|
117860
117917
|
publicKey
|
|
117861
|
-
} : { publicKey };
|
|
117918
|
+
} : { publicKey } };
|
|
117862
117919
|
} catch (e) {
|
|
117863
117920
|
log.error(`Failed to read the identity of community DB (${communityAddress}), leaving it out of pkc.communities for now`, e);
|
|
117864
|
-
|
|
117921
|
+
const code = e.code;
|
|
117922
|
+
return {
|
|
117923
|
+
identity: void 0,
|
|
117924
|
+
unreadableUntilFileChanges: e instanceof SyntaxError || typeof code === "string" && SQLITE_ERROR_CODES_ABOUT_THE_FILE.some((aboutTheFile) => code.startsWith(aboutTheFile))
|
|
117925
|
+
};
|
|
117865
117926
|
} finally {
|
|
117866
117927
|
db?.close();
|
|
117867
117928
|
}
|
|
@@ -117870,12 +117931,22 @@ function listCommunitiesEntriesSync(pkc) {
|
|
|
117870
117931
|
const communityAddresses = listCommunitiesSync(pkc);
|
|
117871
117932
|
const identities = getLocalCommunityIdentities(pkc);
|
|
117872
117933
|
for (const cachedAddress of identities.keys()) if (!communityAddresses.includes(cachedAddress)) identities.delete(cachedAddress);
|
|
117934
|
+
const unreadable = getUnreadableLocalCommunityDbs(pkc);
|
|
117935
|
+
for (const unreadableAddress of unreadable.keys()) if (!communityAddresses.includes(unreadableAddress)) unreadable.delete(unreadableAddress);
|
|
117873
117936
|
const entries = [];
|
|
117874
117937
|
for (const communityAddress of communityAddresses) {
|
|
117875
117938
|
let identity = identities.get(communityAddress);
|
|
117876
117939
|
if (!identity) {
|
|
117877
|
-
|
|
117878
|
-
if (
|
|
117940
|
+
const statSignature = getCommunityDbStatSignature(path.join(pkc.dataPath, "communities", communityAddress));
|
|
117941
|
+
if (statSignature !== void 0 && unreadable.get(communityAddress) === statSignature) continue;
|
|
117942
|
+
const read = readLocalCommunityIdentity(pkc, communityAddress);
|
|
117943
|
+
if (!read.identity) {
|
|
117944
|
+
if (statSignature !== void 0 && read.unreadableUntilFileChanges) unreadable.set(communityAddress, statSignature);
|
|
117945
|
+
else unreadable.delete(communityAddress);
|
|
117946
|
+
continue;
|
|
117947
|
+
}
|
|
117948
|
+
unreadable.delete(communityAddress);
|
|
117949
|
+
identity = read.identity;
|
|
117879
117950
|
identities.set(communityAddress, identity);
|
|
117880
117951
|
}
|
|
117881
117952
|
entries.push(toCommunitiesEntry({
|
|
@@ -117915,8 +117986,23 @@ function listCommunitiesSync(pkc) {
|
|
|
117915
117986
|
}).filter((dirent) => dirent.isFile()).map((dirent) => dirent.name).filter((file) => !file.includes(".lock") && !file.endsWith("-journal") && !file.endsWith("-shm") && !file.endsWith("-wal"));
|
|
117916
117987
|
const knownCommunities = getLocalCommunityIdentities(pkc);
|
|
117917
117988
|
const communityFilesWeDontNeedToCheck = files.filter((address) => knownCommunities.has(address));
|
|
117989
|
+
const headerChecks = getSqliteHeaderChecks(pkc);
|
|
117990
|
+
for (const checkedFile of headerChecks.keys()) if (!files.includes(checkedFile)) headerChecks.delete(checkedFile);
|
|
117918
117991
|
const sqliteFiles = files.filter((address) => !communityFilesWeDontNeedToCheck.includes(address)).filter((address) => {
|
|
117919
117992
|
const filePath = path.join(communitiesPath, address);
|
|
117993
|
+
const statSignature = getCommunityDbStatSignature(filePath);
|
|
117994
|
+
const lastCheck = headerChecks.get(address);
|
|
117995
|
+
if (statSignature !== void 0 && lastCheck?.statSignature === statSignature) return lastCheck.isSqlite;
|
|
117996
|
+
const isSqlite = isSqliteFile(filePath);
|
|
117997
|
+
if (statSignature !== void 0 && isSqlite !== void 0) headerChecks.set(address, {
|
|
117998
|
+
statSignature,
|
|
117999
|
+
isSqlite
|
|
118000
|
+
});
|
|
118001
|
+
else headerChecks.delete(address);
|
|
118002
|
+
return isSqlite === true;
|
|
118003
|
+
});
|
|
118004
|
+
return [...communityFilesWeDontNeedToCheck, ...sqliteFiles].sort();
|
|
118005
|
+
function isSqliteFile(filePath) {
|
|
117920
118006
|
try {
|
|
117921
118007
|
const fd = openSync(filePath, "r");
|
|
117922
118008
|
const buffer = Buffer.alloc(16);
|
|
@@ -117928,10 +118014,9 @@ function listCommunitiesSync(pkc) {
|
|
|
117928
118014
|
return buffer.toString().startsWith("SQLite format 3");
|
|
117929
118015
|
} catch (e) {
|
|
117930
118016
|
if (!(e instanceof Error && "code" in e && e.code === "ENOENT")) log.error(`Failed to check whether ${filePath} is a SQLite file, skipping it`, e);
|
|
117931
|
-
return
|
|
118017
|
+
return;
|
|
117932
118018
|
}
|
|
117933
|
-
}
|
|
117934
|
-
return [...communityFilesWeDontNeedToCheck, ...sqliteFiles].sort();
|
|
118019
|
+
}
|
|
117935
118020
|
}
|
|
117936
118021
|
async function importSignerIntoKuboNode(ipnsKeyName, ipfsKey, kuboRpcClientOptions) {
|
|
117937
118022
|
const log = logger_default("pkc-js:local-community:importSignerIntoKuboNode");
|
|
@@ -148141,6 +148226,10 @@ const createUrlFromSubdomainResolution = (gateway, opts) => {
|
|
|
148141
148226
|
};
|
|
148142
148227
|
const GATEWAYS_THAT_SUPPORT_SUBDOMAIN_RESOLUTION = {};
|
|
148143
148228
|
const MAX_CONCURRENT_AUTHOR_NAME_RESOLUTIONS = 100;
|
|
148229
|
+
function isIpfsPathNotInFolderError(error) {
|
|
148230
|
+
if (!(error instanceof Error)) return false;
|
|
148231
|
+
return error.name === "DoesNotExistError" || error.name === "HTTPError" && /^no link named /.test(error.message);
|
|
148232
|
+
}
|
|
148144
148233
|
const waitForAuthorNameResolveInFlight = ({ inFlightResolve, abortSignal }) => new Promise((resolve) => {
|
|
148145
148234
|
if (abortSignal?.aborted) return resolve("aborted");
|
|
148146
148235
|
const onAbort = () => finish("aborted");
|
|
@@ -148689,6 +148778,10 @@ var BaseClientsManager = class BaseClientsManager {
|
|
|
148689
148778
|
timeoutMs,
|
|
148690
148779
|
error: e
|
|
148691
148780
|
});
|
|
148781
|
+
if (isIpfsPathNotInFolderError(e)) throw new PKCError("ERR_IPFS_PATH_NOT_IN_FOLDER", {
|
|
148782
|
+
ipfsPath: `/ipfs/${root}/${path}`,
|
|
148783
|
+
error: e
|
|
148784
|
+
});
|
|
148692
148785
|
log.trace("Could not resolve", `${root}/${path}`, "to a cid, the caller will fetch it", e);
|
|
148693
148786
|
return;
|
|
148694
148787
|
}
|
|
@@ -154632,6 +154725,12 @@ const loadChallengeFile = async ({ communityChallengeSettings, challengeIndex, c
|
|
|
154632
154725
|
};
|
|
154633
154726
|
const callGetChallenge = async ({ challengeFile, communityChallengeSettings, challengeRequestMessage, challengeIndex, community, authorIdentityMatcher }) => {
|
|
154634
154727
|
let challengeOrChallengeResult;
|
|
154728
|
+
const challengeName = communityChallengeSettings.name || communityChallengeSettings.path;
|
|
154729
|
+
const startedAtMs = Date.now();
|
|
154730
|
+
const slowWarningTimer = setTimeout(() => {
|
|
154731
|
+
logger_default("pkc-js:local-community:challenges:callGetChallenge").error(`getChallenge() of challenge ${challengeIndex + 1} (${challengeName}) in community ${community.address} is still running after ${community._slowGetChallengeWarningMs / 1e3}s.`, "A publisher that receives no challenge or verification gives up after about two minutes and the publication looks failed to its author.", "Slow work belongs behind pendingApproval. challengeRequestId:", challengeRequestMessage.challengeRequestId.toString());
|
|
154732
|
+
}, community._slowGetChallengeWarningMs);
|
|
154733
|
+
slowWarningTimer.unref?.();
|
|
154635
154734
|
try {
|
|
154636
154735
|
challengeOrChallengeResult = await challengeFile.getChallenge({
|
|
154637
154736
|
challengeSettings: communityChallengeSettings,
|
|
@@ -154640,6 +154739,8 @@ const callGetChallenge = async ({ challengeFile, communityChallengeSettings, cha
|
|
|
154640
154739
|
community,
|
|
154641
154740
|
authorIdentityMatcher
|
|
154642
154741
|
});
|
|
154742
|
+
const elapsedMs = Date.now() - startedAtMs;
|
|
154743
|
+
if (elapsedMs >= community._slowGetChallengeWarningMs) logger_default("pkc-js:local-community:challenges:callGetChallenge").error(`getChallenge() of challenge ${challengeIndex + 1} (${challengeName}) in community ${community.address} took ${Math.round(elapsedMs / 1e3)}s`);
|
|
154643
154744
|
validateChallengeOrChallengeResult({
|
|
154644
154745
|
challengeOrChallengeResult,
|
|
154645
154746
|
challengeIndex,
|
|
@@ -154653,6 +154754,8 @@ const callGetChallenge = async ({ challengeFile, communityChallengeSettings, cha
|
|
|
154653
154754
|
challengeIndex: challengeIndex + 1,
|
|
154654
154755
|
error: e
|
|
154655
154756
|
});
|
|
154757
|
+
} finally {
|
|
154758
|
+
clearTimeout(slowWarningTimer);
|
|
154656
154759
|
}
|
|
154657
154760
|
return { challengeOrChallengeResult };
|
|
154658
154761
|
};
|
|
@@ -156481,4 +156584,4 @@ var RpcLocalCommunity = class extends RpcRemoteCommunity {
|
|
|
156481
156584
|
}
|
|
156482
156585
|
};
|
|
156483
156586
|
//#endregion
|
|
156484
|
-
export { createSchemaRowParser as $, buildRuntimeCommunityFields as $n, RpcPublishCommunityListParamSchema as $t, findCommentInParsedPages as A, verifyChallengeAnswer as An,
|
|
156587
|
+
export { createSchemaRowParser as $, buildRuntimeCommunityFields as $n, require_lodash_merge as $r, RpcPublishCommunityListParamSchema as $t, findCommentInParsedPages as A, verifyChallengeAnswer as An, removeFileRetryingWhileBusy as Ar, parseRpcCommentUpdateEventWithPKCErrorIfItFails as At, GenericStateClient as B, verifyCommunityEdit as Bn, t$4 as Br, RpcCommunityIdentifierParamSchema as Bt, RepliesPages as C, signCommentModeration as Cn, getDefaultDataPath as Cr, parseCreateVoteOptionsSchemaWithPKCErrorIfItFails as Ct, extractCommunityRuntimeFieldsFromParsedPages as D, signCommunityEdit as Dn, monitorCommunitiesDirectory as Dr, parseJsonWithPKCErrorIfFails as Dt, buildPagesRuntimeFields as E, signCommunity as En, listCommunitiesSync as Er, parseDecryptedChallengeWithPKCErrorIfItFails as Et, cloneCrosspostForRuntime as F, verifyCommentIpfs as Fn, toCommunitiesEntry as Fr, RpcAuthorNameParamSchema as Ft, PKCTypedEmitter as G, getAuthorNameFromRuntime as Gn, t$7 as Gr, RpcExportCommunityParamSchema as Gt, InflightResourceTypes as H, verifyVote as Hn, t$5 as Hr, RpcEditCommunityParamSchema as Ht, collectCrosspostAuthorsToResolve as I, verifyCommentModeration as In, toCommunitiesWireEntry as Ir, RpcCancelExportParamSchema as It, decodeRpcChallengeRequestPubsubMsg as J, CreateCommunityListWithCidOptionsSchema as Jn, MAX_FILE_SIZE_BYTES_FOR_COMMENT_UPDATE as Jr, RpcFetchCidResultSchema as Jt, decodeRpcChallengeAnswerPubsubMsg as K, getAuthorNameFromWire as Kn, t$8 as Kr, RpcExportCommunityResultSchema as Kt, extractCrosspostRuntimeFields as L, verifyCommentPubsubMessage as Ln, isCommunityStartLocked as Lr, RpcCidParamSchema as Lt, parseRawPages as M, verifyChallengeRequest as Mn, setNativeFunctions as Mr, parseVoteChallengeRequestToEncryptSchemaWithPKCErrorIfItFails as Mt, MAX_PAGE_SIZE_BYTES as N, verifyChallengeVerification as Nn, tryToDeleteCommunitiesThatFailedToBeDeletedBefore as Nr, parseVotePubsubMessagePublicationSchemaWithPKCErrorIfItFails as Nt, findCommentInPageInstance as O, signCommunityList as On, moveCommunityDbToDeletedDirectory as Or, parsePKCUserOptionsSchemaWithPKCErrorIfItFails as Ot, applyNameResolvedCacheToCrosspost as P, verifyCommentEdit as Pn, findCommunitiesEntry as Pr, RpcAnchorPublishPreparationResultSchema as Pt, collectSchemaRowCoercions as Q, effectiveMaxCrosspostDepth as Qn, STORAGE_KEYS as Qr, RpcPublishChallengeAnswersParamSchema as Qt, stripNameResolvedFromCrosspost as R, verifyCommentUpdate as Rn, require_src as Rr, RpcCommentRepliesPageParamSchema as Rt, MAX_FILE_SIZE_BYTES_FOR_COMMUNITY_IPFS as S, signCommentEdit as Sn, getDefaultCommunityDbConfig as Sr, parseCreateRpcCommunityFunctionArgumentSchemaWithPKCErrorIfItFails as St, buildPageRuntimeFields as T, signCommentUpdateForChallengeVerification as Tn, importSignerIntoKuboNode as Tr, parseDecryptedChallengeVerification as Tt, pRetry as U, buildRuntimeAuthor as Un, n$5 as Ur, RpcExportCommunityModLogsParamSchema as Ut, InflightFetchManager as V, verifyCommunityList as Vn, r as Vr, RpcCommunityPageParamSchema as Vt, pLimit as W, cleanWireAuthor as Wn, n$6 as Wr, RpcExportCommunityModLogsResultSchema as Wt, coerceSchemaRowBoolean as X, MAX_COMMUNITY_LIST_SIZE_BYTES as Xn, NAME_RESOLVED_TRUE_TTL_MS as Xr, RpcFetchCommunityListResultSchema as Xt, decodeRpcChallengeVerificationPubsubMsg as Y, CreateNewCommunityListOptionsSchema as Yn, NAME_RESOLVED_FALSE_TTL_MS as Yr, RpcFetchCommunityListParamSchema as Yt, coerceSchemaRowJson as Z, crosspostChainDepthUpTo as Zn, NAME_RESOLVE_FAILED_RETRY_FLOOR_MS as Zr, RpcPublishAnchorRecordParamSchema as Zt, createAuthorIdentityMatcher as _, signChallengeAnswer as _n, deriveCommentIpfsFromCommentTableRow as _r, parseCreateCommentOptionsSchemaWithPKCErrorIfItFails as _t, generatePagesReportingFailedSorts as a, RpcUnsubscribeParamSchema as an, encode as ar, parseCommentModerationChallengeRequestToEncryptSchemaWithPKCErrorIfItFails as at, KeyvBetterSqlite3 as b, signChallengeVerification as bn, findLocalCommunityAddress as br, parseCreatePKCWsServerOptionsSchemaWithPKCErrorIfItFails as bt, resolvePageSortsOrThrow as c, SignerWithPublicKeyAddress as cn, getPKCAddressFromPublicKey as cr, parseCommentUpdateSchemaWithPKCErrorIfItFails as ct, getChallengeVerification as d, decryptEd25519AesGcm as dn, BackupAbortError as dr, parseCommunityEditOptionsSchemaWithPKCErrorIfItFails as dt, nativeFunctions$1 as ei, RpcPublishCommunityListResultSchema as en, getCommunityAddressFromRecord as er, parseCidStringSchemaWithPKCErrorIfItFails as et, getCommunityChallengeFromCommunityChallengeSettings as f, decryptEd25519AesGcmPublicKeyBuffer as fn, backupCommunityDb as fr, parseCommunityEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails as ft, authorNameResolveFailureReason as g, cleanUpBeforePublishing as gn, deleteOldCommunityInWindows as gr, parseCreateCommentModerationOptionsSchemaWithPKCErrorIfItFails as gt, authorIdentityMatcherForRequest as h, _validateSignatureOfPKCRecord as hn, createKuboRpcClient as hr, parseCreateCommentEditOptionsSchemaWithPKCErrorIfItFails as ht, derivePublicPageSorts as i, RpcSuccessResultSchema as in, decode as ir, parseCommentIpfsSchemaWithPKCErrorIfItFails as it, iterateOverPageCidsToFindAllCids as j, verifyChallengeMessage as jn, resolveDbPostsCidRefs as jr, parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails as jt, findCommentInPageInstanceRecursively as k, signVote as kn, refreshCommunitiesList as kr, parseRpcCommentEventWithPKCErrorIfItFails as kt, pkcJsPageSorts as l, createSigner as ln, getPKCAddressFromPublicKeySync as lr, parseCommunityAddressWithPKCErrorIfItFails as lt, pkcJsChallenges as m, encryptEd25519AesGcmPublicKeyBuffer as mn, calculateInlineRepliesBudget as mr, parseCommunityListSchemaWithPKCErrorIfItFails as mt, RpcRemoteCommunity as n, RpcResolveAuthorNameResultSchema as nn, getCommunityPublicKeyFromWire as nr, parseCommentEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails as nt, loadPageSortsForStartedCommunity as o, findCommunityRecordNameMismatch as on, getBufferedPKCAddressFromPublicKey as or, parseCommentModerationPubsubMessagePublicationSchemaWithPKCErrorIfItFails as ot, loadChallengeFileFromCommunityChallengeSettings as p, encryptEd25519AesGcm as pn, calculateExpectedSignatureSize as pr, parseCommunityIpfsSchemaPassthroughWithPKCErrorIfItFails as pt, decodeRpcChallengePubsubMsg as q, normalizeCreatePublicationAuthor as qn, stringify as qr, RpcFetchCidParamSchema as qt, computePageSortsFingerprint as r, RpcSubscriptionIdResultSchema as rn, normalizeCommunityInputFromCommunity as rr, parseCommentEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails as rt, lookupPageSortFactories as s, require_lib as sn, getIpfsKeyFromPrivateKey as sr, parseCommentPubsubMessagePublicationWithPKCErrorIfItFails as st, RpcLocalCommunity as t, RpcPublishedAnchorRecordResultSchema as tn, getCommunityNameFromWire$1 as tr, parseCommentChallengeRequestToEncryptSchemaWithPKCErrorIfItFails as tt, deriveCommunityChallengesOrThrow as u, createAnchorIpnsRecord as un, getPublicKeyFromPrivateKey as ur, parseCommunityEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails as ut, TrackedInstanceRegistry as v, signChallengeMessage as vn, deriveDbPosts as vr, parseCreateCommunityEditPublicationOptionsSchemaWithPKCErrorIfItFails as vt, TIMEFRAMES_TO_SECONDS as w, signCommentUpdate as wn, getThumbnailPropsOfLink as wr, parseDecryptedChallengeAnswerWithPKCErrorIfItFails as wt, RemoteCommunity as x, signComment as xn, forgetCommunityThatFailedToBeDeleted as xr, parseCreateRemoteCommunityFunctionArgumentSchemaWithPKCErrorIfItFails as xt, LRUCache as y, signChallengeRequest as yn, deriveDbReplies as yr, parseCreateNewLocalCommunityUserOptionsSchemaWithPKCErrorIfItFails as yt, PKCClientsManager as z, verifyCommunity as zn, t$2 as zr, RpcCommunitiesChangeEventResultSchema as zt };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Rr as PKCError, V as pubsubTopicToDhtKeyCid } from "./util-
|
|
1
|
+
import { Rr as PKCError, V as pubsubTopicToDhtKeyCid } from "./util-DMr7Hj-w.js";
|
|
2
2
|
import { ipnsSelector } from "ipns/selector";
|
|
3
3
|
import { ipnsValidator } from "ipns/validator";
|
|
4
4
|
import { unmarshalIPNSRecord } from "ipns";
|
|
@@ -6875,6 +6875,7 @@ var messages;
|
|
|
6875
6875
|
messages["ERR_CID_IS_INVALID"] = "CID is invalid";
|
|
6876
6876
|
messages["ERR_DATA_PATH_IS_NOT_DEFINED"] = "pkcOptions.dataPath needs to be defined with native functions";
|
|
6877
6877
|
messages["ERR_COMMUNITY_OWNER_ATTEMPTED_EDIT_NEW_ADDRESS_THAT_ALREADY_EXISTS"] = "Community owner attempted to edit community.address to a new address that already exists";
|
|
6878
|
+
messages["ERR_FAILED_TO_RENAME_COMMUNITY_DB"] = "Failed to rename the community's DB file to its new address, so the community keeps its old address. details.error is the error the rename itself raised";
|
|
6878
6879
|
messages["ERR_COMMUNITY_EDIT_NAME_AND_ADDRESS_MISMATCH"] = "community.edit() received both name and address, and they name different addresses. Pass one of them, or the same value for both";
|
|
6879
6880
|
messages["ERR_COMMENT_MISSING_IPFS_AND_UPDATE"] = "Comment is missing CommentIpfs and CommentUpdate";
|
|
6880
6881
|
messages["ERR_COMMENT_MISSING_CID"] = "Comment is missing cid";
|
|
@@ -6950,6 +6951,7 @@ var messages;
|
|
|
6950
6951
|
messages["ERR_REMOTE_COMMUNITY_RECEIVED_ALREADY_PROCCESSED_RECORD"] = "We loaded a community record but it's a record we already consumed before";
|
|
6951
6952
|
messages["ERR_COMMENT_RECEIVED_ALREADY_PROCESSED_COMMENT_UPDATE"] = "We loaded a CommentUpdate but it's a record we already consumed";
|
|
6952
6953
|
messages["ERR_FETCH_CID_P2P_TIMEOUT"] = "Fetching CID via Kubo-rpc-client/helia P2P has timed out";
|
|
6954
|
+
messages["ERR_IPFS_PATH_NOT_IN_FOLDER"] = "The folder was read and has no entry for this IPFS path";
|
|
6953
6955
|
messages["ERR_INVALID_KUBO_STYLE_TIMEOUT"] = "The timeout option is not a number of milliseconds or a kubo-style duration string (e.g. \"30s\", \"2m\")";
|
|
6954
6956
|
messages["ERR_FETCH_CID_P2P_TIMEOUT_AFTER_RETRIES"] = "Fetching CID via Kubo-rpc-client/helia P2P has timed out after all retry attempts";
|
|
6955
6957
|
messages["ERR_RESOLVED_IPNS_P2P_TO_UNDEFINED"] = "Resolved IPNS name to undefined. Does this IPNS name exist?";
|
|
@@ -7235,6 +7237,7 @@ var messages;
|
|
|
7235
7237
|
messages["ERR_COMMUNITY_STATE_LOCKED"] = "The internal state of the community in DB is locked";
|
|
7236
7238
|
messages["ERR_COMMUNITY_CREATION_LOCKED"] = "Community creation is locked";
|
|
7237
7239
|
messages["ERR_COMMUNITY_ALREADY_STARTED"] = "Community already started";
|
|
7240
|
+
messages["ERR_COMMUNITY_START_LOCK_COMPROMISED"] = "This instance lost the start lock of this community (another process took it over, or the lock was removed), so it stopped running it";
|
|
7238
7241
|
messages["ERR_FAILED_TO_IMPORT_IPFS_KEY"] = "Community failed to import IPFS key";
|
|
7239
7242
|
messages["ERR_LOCAL_COMMUNITY_PRODUCED_INVALID_RECORD"] = "The local community has produced a new IPNS record with invalid signature. This is a critical error";
|
|
7240
7243
|
messages["ERR_FAILED_TO_PARSE_LOCAL_RAW_IPNS_RECORD"] = "Failed to parse the local IPNS record within our kubo node";
|
|
@@ -16553,7 +16556,7 @@ const CommunityEditPublicationPubsubReservedFields = r$2([
|
|
|
16553
16556
|
], t$3(CommunityEditPubsubMessagePublicationSchema.shape));
|
|
16554
16557
|
//#endregion
|
|
16555
16558
|
//#region dist/node/generated-version.js
|
|
16556
|
-
const version = "0.0.
|
|
16559
|
+
const version = "0.0.147";
|
|
16557
16560
|
//#endregion
|
|
16558
16561
|
//#region dist/node/version.js
|
|
16559
16562
|
const protocolVersion = ProtocolVersionSchema.parse("1.0.0");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Rr as PKCError, bn as PageSortFileFactorySchema, cn as ChallengeFileSchema, sn as ChallengeFileFactorySchema } from "./util-
|
|
2
|
-
import { s as validatePageSortFile } from "./page-sort-scoring-
|
|
1
|
+
import { Rr as PKCError, bn as PageSortFileFactorySchema, cn as ChallengeFileSchema, sn as ChallengeFileFactorySchema } from "./util-DMr7Hj-w.js";
|
|
2
|
+
import { s as validatePageSortFile } from "./page-sort-scoring-DwYGP_0d.js";
|
|
3
3
|
//#region dist/node/validate-package-factories.js
|
|
4
4
|
function validateChallengeFileFactory(factory, { name }) {
|
|
5
5
|
try {
|
package/dist/bundled/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as getShortCid, c as setNativeFunctions, i as getShortAddress, n as challenges, o as nativeFunctions, r as createAnchorIpnsRecord, s as pageSorts, t as PKC } from "./chunks/node-
|
|
1
|
+
import { a as getShortCid, c as setNativeFunctions, i as getShortAddress, n as challenges, o as nativeFunctions, r as createAnchorIpnsRecord, s as pageSorts, t as PKC } from "./chunks/node-By3og2hw.js";
|
|
2
2
|
export { challenges, createAnchorIpnsRecord, PKC as default, getShortAddress, getShortCid, nativeFunctions, pageSorts, setNativeFunctions };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as validatePageSortFileFactory } from "./chunks/validate-package-factories-
|
|
1
|
+
import { n as validatePageSortFileFactory } from "./chunks/validate-package-factories-TwRblx9f.js";
|
|
2
2
|
export { validatePageSortFileFactory };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { At as pTimeout, Br as logger_default, C as hideClassPrivateProps, Rr as PKCError, X as replaceXWithY, et as retryKuboIpfsAddAndProvide, ft as findStartedCommunity, i as calculateStringSizeSameAsIpfsAddCidV0, xr as t, yr as n } from "../../chunks/util-
|
|
2
|
-
import { S as parseRpcUnsubscribeParam, _ as parseRpcExportCommunityParam, b as parseRpcPublishChallengeAnswersParam, d as parseRpcCidParam, f as parseRpcCommentRepliesPageParam, g as parseRpcExportCommunityModLogsParam, h as parseRpcEditCommunityParam, l as parseRpcAuthorNameParam, m as parseRpcCommunityPageParam, p as parseRpcCommunityIdentifierParam, t as PKC, u as parseRpcCancelExportParam, v as parseRpcFetchCommunityListParam, x as parseRpcPublishCommunityListParam, y as parseRpcPublishAnchorRecordParam } from "../../chunks/node-
|
|
3
|
-
import {
|
|
4
|
-
import { t as LocalCommunity } from "../../chunks/local-community-
|
|
1
|
+
import { At as pTimeout, Br as logger_default, C as hideClassPrivateProps, Rr as PKCError, X as replaceXWithY, et as retryKuboIpfsAddAndProvide, ft as findStartedCommunity, i as calculateStringSizeSameAsIpfsAddCidV0, xr as t, yr as n } from "../../chunks/util-DMr7Hj-w.js";
|
|
2
|
+
import { S as parseRpcUnsubscribeParam, _ as parseRpcExportCommunityParam, b as parseRpcPublishChallengeAnswersParam, d as parseRpcCidParam, f as parseRpcCommentRepliesPageParam, g as parseRpcExportCommunityModLogsParam, h as parseRpcEditCommunityParam, l as parseRpcAuthorNameParam, m as parseRpcCommunityPageParam, p as parseRpcCommunityIdentifierParam, t as PKC, u as parseRpcCancelExportParam, v as parseRpcFetchCommunityListParam, x as parseRpcPublishCommunityListParam, y as parseRpcPublishAnchorRecordParam } from "../../chunks/node-By3og2hw.js";
|
|
3
|
+
import { Br as t$1, Dt as parseJsonWithPKCErrorIfFails, E as buildPagesRuntimeFields, Er as listCommunitiesSync, Ir as toCommunitiesWireEntry, L as extractCrosspostRuntimeFields, Mt as parseVoteChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, T as buildPageRuntimeFields, U as pRetry, Vn as verifyCommunityList, W as pLimit, Xn as MAX_COMMUNITY_LIST_SIZE_BYTES, at as parseCommentModerationChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, br as findLocalCommunityAddress, bt as parseCreatePKCWsServerOptionsSchemaWithPKCErrorIfItFails, dt as parseCommunityEditOptionsSchemaWithPKCErrorIfItFails, jt as parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, mt as parseCommunityListSchemaWithPKCErrorIfItFails, nt as parseCommentEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, qr as stringify, sn as require_lib, tt as parseCommentChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, ut as parseCommunityEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, wt as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, yt as parseCreateNewLocalCommunityUserOptionsSchemaWithPKCErrorIfItFails } from "../../chunks/rpc-local-community-WnhiTbxm.js";
|
|
4
|
+
import { t as LocalCommunity } from "../../chunks/local-community-5X7bvOoN.js";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
6
|
import path from "path";
|
|
7
7
|
import assert from "assert";
|
|
@@ -51,6 +51,14 @@ const GATEWAYS_THAT_SUPPORT_SUBDOMAIN_RESOLUTION = {}; // gateway url -> whether
|
|
|
51
51
|
// 100 sits above the realistic batch window, so coalescing survives, and caps the burst for the
|
|
52
52
|
// resolvers that do not batch.
|
|
53
53
|
const MAX_CONCURRENT_AUTHOR_NAME_RESOLUTIONS = 100;
|
|
54
|
+
// Whether a path resolve failed because a directory on the way was read and has no entry of that name. Kubo's RPC
|
|
55
|
+
// reports it as an HTTP 500 whose message is `no link named "<name>" under <cid>`, with no code of its own, and helia's
|
|
56
|
+
// unixfs throws DoesNotExistError. A directory that could not be loaded fails differently (a timeout, no providers)
|
|
57
|
+
function isIpfsPathNotInFolderError(error) {
|
|
58
|
+
if (!(error instanceof Error))
|
|
59
|
+
return false;
|
|
60
|
+
return error.name === "DoesNotExistError" || (error.name === "HTTPError" && /^no link named /.test(error.message));
|
|
61
|
+
}
|
|
54
62
|
// Waits for a resolve another caller started. A resolve is bounded only by its owner's signal, so the wait
|
|
55
63
|
// ends as soon as the joiner is stopped and leaves nothing on the resolve: a stopped Comment or community must
|
|
56
64
|
// not stay referenced through its onResolved until someone else's resolve settles.
|
|
@@ -688,8 +696,10 @@ export class BaseClientsManager {
|
|
|
688
696
|
// The cid an /ipfs/ path names, as CIDv1, or undefined when it cannot be told. Files are content-addressed, so a
|
|
689
697
|
// caller comparing it with the cid it last fetched can skip an unchanged file without reading it (issue #312).
|
|
690
698
|
// Kubo and helia walk only the directory blocks on the way, which an unchanged path already has locally. Undefined
|
|
691
|
-
// with only gateways. Throws
|
|
692
|
-
//
|
|
699
|
+
// with only gateways. Throws ERR_FETCH_CID_P2P_TIMEOUT when the walk could not reach the path's blocks in time: a
|
|
700
|
+
// fetch of the path would walk the same blocks. Throws ERR_IPFS_PATH_NOT_IN_FOLDER when the walk read the folder and
|
|
701
|
+
// it has no such entry: the folder is named by its cid, so that answer does not change and a fetch would only
|
|
702
|
+
// repeat it. Any other failure is undefined, and the caller fetches anyway.
|
|
693
703
|
async _resolveIpfsPathToCid({ root, path, timeoutMs, abortSignal, log, bitswapSessionSeedScopeIpnsPubsubTopic }) {
|
|
694
704
|
try {
|
|
695
705
|
if (keys(this._pkc.clients.kuboRpcClients).length > 0 || keys(this._pkc.clients.libp2pJsClients).length > 0) {
|
|
@@ -716,6 +726,8 @@ export class BaseClientsManager {
|
|
|
716
726
|
throw e; // helia's own timeout
|
|
717
727
|
if (e instanceof Error && e.name === "TimeoutError" && !abortSignal?.aborted)
|
|
718
728
|
throw new PKCError("ERR_FETCH_CID_P2P_TIMEOUT", { ipfsPath: `/ipfs/${root}/${path}`, timeoutMs, error: e });
|
|
729
|
+
if (isIpfsPathNotInFolderError(e))
|
|
730
|
+
throw new PKCError("ERR_IPFS_PATH_NOT_IN_FOLDER", { ipfsPath: `/ipfs/${root}/${path}`, error: e });
|
|
719
731
|
log.trace("Could not resolve", `${root}/${path}`, "to a cid, the caller will fetch it", e);
|
|
720
732
|
return undefined;
|
|
721
733
|
}
|