@pkcprotocol/pkc-js 0.0.82 → 0.0.84
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 +16 -0
- package/dist/browser/community/rpc-remote-community.js +15 -8
- package/dist/browser/community/rpc-remote-community.js.map +1 -1
- package/dist/browser/community/schema.js +3 -1
- package/dist/browser/community/schema.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/pkc-with-rpc-client.d.ts +5 -3
- package/dist/browser/pkc/pkc-with-rpc-client.js +45 -7
- package/dist/browser/pkc/pkc-with-rpc-client.js.map +1 -1
- package/dist/browser/pkc/pkc.d.ts +6 -3
- package/dist/browser/pkc/pkc.js +71 -9
- package/dist/browser/pkc/pkc.js.map +1 -1
- package/dist/browser/pkc-error.d.ts +1 -1
- package/dist/browser/publications/comment/schema.d.ts +1 -1
- package/dist/browser/publications/comment/schema.js +5 -1
- package/dist/browser/publications/comment/schema.js.map +1 -1
- package/dist/browser/publications/publication-client-manager.js +10 -2
- package/dist/browser/publications/publication-client-manager.js.map +1 -1
- package/dist/browser/publications/publication.d.ts +4 -0
- package/dist/browser/publications/publication.js +36 -2
- package/dist/browser/publications/publication.js.map +1 -1
- package/dist/browser/runtime/node/community/db-handler.d.ts +2 -0
- package/dist/browser/runtime/node/community/db-handler.js +21 -4
- package/dist/browser/runtime/node/community/db-handler.js.map +1 -1
- package/dist/browser/types.d.ts +5 -0
- package/dist/browser/util.d.ts +20 -1
- package/dist/browser/util.js +100 -2
- package/dist/browser/util.js.map +1 -1
- package/dist/bundled/bundle-manifest.json +25 -25
- package/dist/bundled/chunks/{helia-for-pkc-CQY3-UYD.js → helia-for-pkc-BlDudTLN.js} +2 -2
- package/dist/bundled/chunks/{local-community-AZAEiiht.js → local-community-4wIeaqty.js} +1 -1
- package/dist/bundled/chunks/{local-community-DRm3r1-Y.js → local-community-5PMI-TDB.js} +15 -6
- package/dist/bundled/chunks/{node-B1J8psGZ.js → node-B7GkmuSc.js} +110 -22
- package/dist/bundled/chunks/{rpc-local-community-0XmKyOdO.js → rpc-local-community-r51cTBYd.js} +16 -10
- package/dist/bundled/chunks/{schema-BUUhufdT.js → schema-AXrL86Q4.js} +79 -6
- package/dist/bundled/chunks/{util-Cct7-RT3.js → util-CwzCEPKs.js} +1 -1
- package/dist/bundled/index.js +1 -1
- package/dist/bundled/rpc/src/index.js +4 -4
- package/dist/node/community/rpc-remote-community.js +15 -8
- package/dist/node/community/rpc-remote-community.js.map +1 -1
- package/dist/node/community/schema.js +3 -1
- package/dist/node/community/schema.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/pkc-with-rpc-client.d.ts +5 -3
- package/dist/node/pkc/pkc-with-rpc-client.js +45 -7
- package/dist/node/pkc/pkc-with-rpc-client.js.map +1 -1
- package/dist/node/pkc/pkc.d.ts +6 -3
- package/dist/node/pkc/pkc.js +71 -9
- package/dist/node/pkc/pkc.js.map +1 -1
- package/dist/node/pkc-error.d.ts +1 -1
- package/dist/node/publications/comment/schema.d.ts +1 -1
- package/dist/node/publications/comment/schema.js +5 -1
- package/dist/node/publications/comment/schema.js.map +1 -1
- package/dist/node/publications/publication-client-manager.js +10 -2
- package/dist/node/publications/publication-client-manager.js.map +1 -1
- package/dist/node/publications/publication.d.ts +4 -0
- package/dist/node/publications/publication.js +36 -2
- package/dist/node/publications/publication.js.map +1 -1
- package/dist/node/runtime/node/community/db-handler.d.ts +2 -0
- package/dist/node/runtime/node/community/db-handler.js +21 -4
- package/dist/node/runtime/node/community/db-handler.js.map +1 -1
- package/dist/node/types.d.ts +5 -0
- package/dist/node/util.d.ts +20 -1
- package/dist/node/util.js +100 -2
- package/dist/node/util.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { i as __toESM, r as __require, t as __commonJSMin } from "./chunk-2rV9d50f.js";
|
|
2
|
-
import { $n as n$
|
|
3
|
-
import { $ as applyNameResolvedCacheToCrosspost, At as verifyCommentModeration, B as tryToDeleteCommunitiesThatFailedToBeDeletedBefore, Bn as RpcExportCommunityModLogsParamSchema, Bt as normalizeCreatePublicationAuthor, Cn as parseDecryptedChallengeVerification, Ct as signVote, Dn as parseRpcCommentEventWithPKCErrorIfItFails, Dt as verifyChallengeVerification, E as createKuboRpcClient, En as parsePKCUserOptionsSchemaWithPKCErrorIfItFails, F as listCommunitiesSync, Fn as RpcCidParamSchema, Ft as verifyVote, Gn as RpcFetchCidResultSchema, Gt as normalizeCommunityInputFromCommunity, Hn as RpcExportCommunityParamSchema, Ht as getCommunityAddressFromRecord, I as monitorCommunitiesDirectory, In as RpcCommentRepliesPageParamSchema, It as buildRuntimeAuthor, J as extractCommunityRuntimeFieldsFromParsedPages, Jn as RpcPublishedAnchorRecordResultSchema, Jt as getBufferedPKCAddressFromPublicKey, Kn as RpcPublishAnchorRecordParamSchema, Kt as decode, Ln as RpcCommunityIdentifierParamSchema, Lt as cleanWireAuthor, M as getDefaultDataPath, Mn as RpcAnchorPublishPreparationResultSchema, Mt as verifyCommentUpdate, Nn as RpcAuthorNameParamSchema, On as parseRpcCommentUpdateEventWithPKCErrorIfItFails, Ot as verifyCommentEdit, Pn as RpcCancelExportParamSchema, Pt as verifyCommunityEdit, Q as RepliesPages, Qn as RpcUnsubscribeParamSchema, Rn as RpcCommunityPageParamSchema, Rt as getAuthorNameFromRuntime, Sn as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, St as signCommunityEdit, Tn as parseJsonWithPKCErrorIfFails, Tt as verifyChallengeMessage, Un as RpcExportCommunityResultSchema, Ut as getCommunityNameFromWire, V as CommentClientsManager, Vn as RpcExportCommunityModLogsResultSchema, Vt as buildRuntimeCommunityFields, Wn as RpcFetchCidParamSchema, Wt as getCommunityPublicKeyFromWire, Xn as RpcSubscriptionIdResultSchema, Y as findCommentInPageInstanceRecursively, Yn as RpcResolveAuthorNameResultSchema, Z as parseRawPages, Zn as RpcSuccessResultSchema, Zt as getPKCAddressFromPublicKeySync, _ as createAnchorIpnsRecord$1, _t as signCommentEdit, a as pkcJsChallenges, ar as n$3, at as PKCClientsManager, b as encryptEd25519AesGcm, bn as parseCreateRpcCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, c as RemoteCommunity, cn as parseCommunityAddressWithPKCErrorIfItFails, cr as t$5, d as decodeRpcChallengeAnswerPubsubMsg, dn as parseCommunityEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, dt as cleanUpBeforePublishing, en as parseCidStringSchemaWithPKCErrorIfItFails, et as cloneCrosspostForRuntime, f as decodeRpcChallengePubsubMsg, fr as nativeFunctions$2, ft as signChallengeAnswer, g as createSigner, gn as parseCreateCommunityEditPublicationOptionsSchemaWithPKCErrorIfItFails, gt as signComment, hn as parseCreateCommentOptionsSchemaWithPKCErrorIfItFails, in as parseCommentIpfsSchemaWithPKCErrorIfItFails, ir as t$3, it as PublicationClientsManager, jn as parseVotePubsubMessagePublicationSchemaWithPKCErrorIfItFails, jt as verifyCommentPubsubMessage, kn as parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, kt as verifyCommentIpfs, lt as PKCTypedEmitter, m as decodeRpcChallengeVerificationPubsubMsg, mn as parseCreateCommentModerationOptionsSchemaWithPKCErrorIfItFails, mt as signChallengeRequest, n as RpcRemoteCommunity, o as TrackedInstanceRegistry, on as parseCommentModerationPubsubMessagePublicationSchemaWithPKCErrorIfItFails, ot as InflightFetchManager, p as decodeRpcChallengeRequestPubsubMsg, pn as parseCreateCommentEditOptionsSchemaWithPKCErrorIfItFails, pr as require_undici, qn as RpcPublishChallengeAnswersParamSchema, rn as parseCommentEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, rt as stripNameResolvedFromCrosspost, s as LRUCache, sn as parseCommentPubsubMessagePublicationWithPKCErrorIfItFails, sr as t$2, t as RpcLocalCommunity, tr as t$4, tt as collectCrosspostAuthorsToResolve, u as KeyvBetterSqlite3, ut as require_lib$1, v as decryptEd25519AesGcm, vt as signCommentModeration, wn as parseDecryptedChallengeWithPKCErrorIfItFails, xn as parseCreateVoteOptionsSchemaWithPKCErrorIfItFails, yn as parseCreateRemoteCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, z as setNativeFunctions$1, zn as RpcEditCommunityParamSchema } from "./rpc-local-community-
|
|
4
|
-
import { o as getHeliaDebugContext } from "./util-
|
|
2
|
+
import { $n as n$2, B as isIpfsCid, Bt as pTimeout, Ct as findStartedCommunity, D as deepMergeRuntimeFields, Dt as listUpdatingComments, E as createAbortError, En as CommentUpdateForChallengeVerificationSchema, Et as listStartedCommunities, H as isIpns, Ir as joinValues, It as untrackUpdatingComment, L as hideClassPrivateProps, Lr as parsedType, Nt as trackUpdatingComment, Ot as listUpdatingCommunities, Q as isStringDomain, R as ipnsNameToIpnsOverPubsubTopic, Rr as stringifyPrimitive, Rt as require_sha256, Sr as logger_default, Tr as setErrorMap, Tt as findUpdatingCommunity, a as ChallengeRequestMessageSchema, an as CommunityIpfsSchema, ar as e$1, b as areEquivalentCommunityAddresses, br as PKCError, bt as waitForUpdateInCommunityInstanceWithErrorAndTimeout, ct as removeUndefinedValuesRecursively, dn as PubsubTopicSchema, en as CommunityAnchorSchema, ft as retryKuboIpfsAdd, gt as sleepUntilTimeoutOrAbort, hr as FailedToFetchCommentIpfsFromGatewaysError, ht as shortifyCid, ir as e, k as doesDomainAddressHaveCapitalLetter, kn as CommentUpdateSchema, kt as refreshTrackedCommentAliases, lt as replaceXWithY, mr as require_retry, mt as shortifyAddress, nt as rejectWhenAbortSignalFires, r as ChallengeMessageSchema, rr as t$1, rt as rejectWhenCommunityStopsOrAborts, s as ChallengeVerificationMessageSchema, sr as r, t as ChallengeAnswerMessageSchema, tr as n$1, ut as resolveWhenPredicateIsTrue, vt as throwIfAbortSignalAborted, wt as findUpdatingComment, xn as CommentIpfsSchema, xr as messages, y as version_default, yt as timestamp, z as isAbortError, zt as TimeoutError } from "./schema-AXrL86Q4.js";
|
|
3
|
+
import { $ as applyNameResolvedCacheToCrosspost, At as verifyCommentModeration, B as tryToDeleteCommunitiesThatFailedToBeDeletedBefore, Bn as RpcExportCommunityModLogsParamSchema, Bt as normalizeCreatePublicationAuthor, Cn as parseDecryptedChallengeVerification, Ct as signVote, Dn as parseRpcCommentEventWithPKCErrorIfItFails, Dt as verifyChallengeVerification, E as createKuboRpcClient, En as parsePKCUserOptionsSchemaWithPKCErrorIfItFails, F as listCommunitiesSync, Fn as RpcCidParamSchema, Ft as verifyVote, Gn as RpcFetchCidResultSchema, Gt as normalizeCommunityInputFromCommunity, Hn as RpcExportCommunityParamSchema, Ht as getCommunityAddressFromRecord, I as monitorCommunitiesDirectory, In as RpcCommentRepliesPageParamSchema, It as buildRuntimeAuthor, J as extractCommunityRuntimeFieldsFromParsedPages, Jn as RpcPublishedAnchorRecordResultSchema, Jt as getBufferedPKCAddressFromPublicKey, Kn as RpcPublishAnchorRecordParamSchema, Kt as decode, Ln as RpcCommunityIdentifierParamSchema, Lt as cleanWireAuthor, M as getDefaultDataPath, Mn as RpcAnchorPublishPreparationResultSchema, Mt as verifyCommentUpdate, Nn as RpcAuthorNameParamSchema, On as parseRpcCommentUpdateEventWithPKCErrorIfItFails, Ot as verifyCommentEdit, Pn as RpcCancelExportParamSchema, Pt as verifyCommunityEdit, Q as RepliesPages, Qn as RpcUnsubscribeParamSchema, Rn as RpcCommunityPageParamSchema, Rt as getAuthorNameFromRuntime, Sn as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, St as signCommunityEdit, Tn as parseJsonWithPKCErrorIfFails, Tt as verifyChallengeMessage, Un as RpcExportCommunityResultSchema, Ut as getCommunityNameFromWire, V as CommentClientsManager, Vn as RpcExportCommunityModLogsResultSchema, Vt as buildRuntimeCommunityFields, Wn as RpcFetchCidParamSchema, Wt as getCommunityPublicKeyFromWire, Xn as RpcSubscriptionIdResultSchema, Y as findCommentInPageInstanceRecursively, Yn as RpcResolveAuthorNameResultSchema, Z as parseRawPages, Zn as RpcSuccessResultSchema, Zt as getPKCAddressFromPublicKeySync, _ as createAnchorIpnsRecord$1, _t as signCommentEdit, a as pkcJsChallenges, ar as n$3, at as PKCClientsManager, b as encryptEd25519AesGcm, bn as parseCreateRpcCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, c as RemoteCommunity, cn as parseCommunityAddressWithPKCErrorIfItFails, cr as t$5, d as decodeRpcChallengeAnswerPubsubMsg, dn as parseCommunityEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, dt as cleanUpBeforePublishing, en as parseCidStringSchemaWithPKCErrorIfItFails, et as cloneCrosspostForRuntime, f as decodeRpcChallengePubsubMsg, fr as nativeFunctions$2, ft as signChallengeAnswer, g as createSigner, gn as parseCreateCommunityEditPublicationOptionsSchemaWithPKCErrorIfItFails, gt as signComment, hn as parseCreateCommentOptionsSchemaWithPKCErrorIfItFails, in as parseCommentIpfsSchemaWithPKCErrorIfItFails, ir as t$3, it as PublicationClientsManager, jn as parseVotePubsubMessagePublicationSchemaWithPKCErrorIfItFails, jt as verifyCommentPubsubMessage, kn as parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, kt as verifyCommentIpfs, lt as PKCTypedEmitter, m as decodeRpcChallengeVerificationPubsubMsg, mn as parseCreateCommentModerationOptionsSchemaWithPKCErrorIfItFails, mt as signChallengeRequest, n as RpcRemoteCommunity, o as TrackedInstanceRegistry, on as parseCommentModerationPubsubMessagePublicationSchemaWithPKCErrorIfItFails, ot as InflightFetchManager, p as decodeRpcChallengeRequestPubsubMsg, pn as parseCreateCommentEditOptionsSchemaWithPKCErrorIfItFails, pr as require_undici, qn as RpcPublishChallengeAnswersParamSchema, rn as parseCommentEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, rt as stripNameResolvedFromCrosspost, s as LRUCache, sn as parseCommentPubsubMessagePublicationWithPKCErrorIfItFails, sr as t$2, t as RpcLocalCommunity, tr as t$4, tt as collectCrosspostAuthorsToResolve, u as KeyvBetterSqlite3, ut as require_lib$1, v as decryptEd25519AesGcm, vt as signCommentModeration, wn as parseDecryptedChallengeWithPKCErrorIfItFails, xn as parseCreateVoteOptionsSchemaWithPKCErrorIfItFails, yn as parseCreateRemoteCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, z as setNativeFunctions$1, zn as RpcEditCommunityParamSchema } from "./rpc-local-community-r51cTBYd.js";
|
|
4
|
+
import { o as getHeliaDebugContext } from "./util-CwzCEPKs.js";
|
|
5
5
|
import path from "path";
|
|
6
6
|
import assert from "assert";
|
|
7
7
|
import fs from "fs";
|
|
@@ -612,6 +612,17 @@ var Publication = class extends import_lib.TypedEmitter {
|
|
|
612
612
|
if (typeof encryptionPublicKey !== "string") throw Error("Failed to load the encryption public key of community");
|
|
613
613
|
return getPKCAddressFromPublicKeySync(encryptionPublicKey);
|
|
614
614
|
}
|
|
615
|
+
_getCommunityFetchAbortSignal() {
|
|
616
|
+
if (!this._communityFetchAbortSignal) {
|
|
617
|
+
this._communityFetchAbortController = new AbortController();
|
|
618
|
+
this._communityFetchAbortSignal = AbortSignal.any([this._communityFetchAbortController.signal, this._pkc._getDestroyAbortSignal()]);
|
|
619
|
+
}
|
|
620
|
+
return this._communityFetchAbortSignal;
|
|
621
|
+
}
|
|
622
|
+
_resetCommunityFetchAbortSignal() {
|
|
623
|
+
this._communityFetchAbortController = void 0;
|
|
624
|
+
this._communityFetchAbortSignal = void 0;
|
|
625
|
+
}
|
|
615
626
|
_getCommunityCache() {
|
|
616
627
|
const cached = this._pkc._memCaches.communityForPublishing.get(this.communityAddress, { allowStale: true });
|
|
617
628
|
if (cached) return cached;
|
|
@@ -639,8 +650,12 @@ var Publication = class extends import_lib.TypedEmitter {
|
|
|
639
650
|
log("The cache of community is stale, we will use the cached and update in the background");
|
|
640
651
|
const refresh = this._pkc.getCommunity({
|
|
641
652
|
publicKey: this.communityPublicKey,
|
|
642
|
-
name: this.communityName
|
|
643
|
-
|
|
653
|
+
name: this.communityName,
|
|
654
|
+
abortSignal: this._getCommunityFetchAbortSignal()
|
|
655
|
+
}).catch((e) => {
|
|
656
|
+
if (e?.code === "ERR_GET_COMMUNITY_ABORTED") log("Stopped the background refresh of the community cache", this.communityAddress);
|
|
657
|
+
else log.error("Failed to update cache of community", this.communityAddress, e);
|
|
658
|
+
}).finally(() => {
|
|
644
659
|
if (this._backgroundCommunityRefresh === refresh) this._backgroundCommunityRefresh = void 0;
|
|
645
660
|
});
|
|
646
661
|
this._backgroundCommunityRefresh = refresh;
|
|
@@ -649,6 +664,10 @@ var Publication = class extends import_lib.TypedEmitter {
|
|
|
649
664
|
} else return this._clientsManager.fetchCommunityForPublishingWithCacheGuard();
|
|
650
665
|
}
|
|
651
666
|
async stop() {
|
|
667
|
+
this._communityFetchAbortController?.abort(new PKCError("ERR_GET_COMMUNITY_ABORTED", {
|
|
668
|
+
publicationType: this.getType(),
|
|
669
|
+
communityAddress: this.communityAddress
|
|
670
|
+
}));
|
|
652
671
|
try {
|
|
653
672
|
await this._postSucessOrFailurePublishing();
|
|
654
673
|
} finally {
|
|
@@ -985,6 +1004,7 @@ var Publication = class extends import_lib.TypedEmitter {
|
|
|
985
1004
|
}
|
|
986
1005
|
async publish() {
|
|
987
1006
|
this._validatePublicationFields();
|
|
1007
|
+
if (this._getCommunityFetchAbortSignal().aborted) this._resetCommunityFetchAbortSignal();
|
|
988
1008
|
this._pkc._publishingPublications.add(this);
|
|
989
1009
|
try {
|
|
990
1010
|
return await this._publishAfterRegistering();
|
|
@@ -6928,7 +6948,7 @@ var PKC$1 = class extends PKCTypedEmitter {
|
|
|
6928
6948
|
this.clients.libp2pJsClients = {};
|
|
6929
6949
|
if (!this.libp2pJsClientsOptions) return;
|
|
6930
6950
|
if (!this.httpRoutersOptions) throw Error("httpRoutersOptions is required for libp2pJsClient");
|
|
6931
|
-
const { createLibp2pJsClientOrUseExistingOne } = await import("./helia-for-pkc-
|
|
6951
|
+
const { createLibp2pJsClientOrUseExistingOne } = await import("./helia-for-pkc-BlDudTLN.js");
|
|
6932
6952
|
for (const clientOptions of this.libp2pJsClientsOptions) {
|
|
6933
6953
|
const heliaNode = await createLibp2pJsClientOrUseExistingOne({
|
|
6934
6954
|
...clientOptions,
|
|
@@ -6987,32 +7007,63 @@ var PKC$1 = class extends PKCTypedEmitter {
|
|
|
6987
7007
|
hideClassPrivateProps(this);
|
|
6988
7008
|
}
|
|
6989
7009
|
async getCommunity(getCommunityArgs) {
|
|
6990
|
-
|
|
6991
|
-
|
|
7010
|
+
const { abortSignal, ...communityIdentifier } = getCommunityArgs;
|
|
7011
|
+
if (!communityIdentifier.address && !communityIdentifier.name && !communityIdentifier.publicKey) throw new Error("At least one of address, name, or publicKey must be provided");
|
|
7012
|
+
if (abortSignal?.aborted) throw new PKCError("ERR_GET_COMMUNITY_ABORTED", {
|
|
7013
|
+
communityIdentifier,
|
|
7014
|
+
abortReason: abortSignal.reason
|
|
7015
|
+
});
|
|
7016
|
+
const community = await this.createCommunity(communityIdentifier, { abortSignal });
|
|
6992
7017
|
if (typeof community.createdAt === "number") return community;
|
|
6993
7018
|
const timeoutMs = this._timeouts["community-ipns"];
|
|
6994
|
-
await waitForUpdateInCommunityInstanceWithErrorAndTimeout(
|
|
7019
|
+
await waitForUpdateInCommunityInstanceWithErrorAndTimeout({
|
|
7020
|
+
community,
|
|
7021
|
+
timeoutMs,
|
|
7022
|
+
abortSignal
|
|
7023
|
+
});
|
|
6995
7024
|
return community;
|
|
6996
7025
|
}
|
|
6997
|
-
async getComment(
|
|
7026
|
+
async getComment(getCommentArgs) {
|
|
6998
7027
|
logger_default("pkc-js:pkc:getComment");
|
|
6999
|
-
const
|
|
7028
|
+
const { abortSignal, ...cidArgs } = getCommentArgs;
|
|
7029
|
+
const parsedGetCommentArgs = parseRpcCidParam(cidArgs);
|
|
7030
|
+
if (abortSignal?.aborted) throw new PKCError("ERR_GET_COMMENT_ABORTED", {
|
|
7031
|
+
getCommentArgs: parsedGetCommentArgs,
|
|
7032
|
+
abortReason: abortSignal.reason
|
|
7033
|
+
});
|
|
7000
7034
|
const comment = await this.createComment(parsedGetCommentArgs);
|
|
7001
7035
|
let lastUpdateError;
|
|
7002
7036
|
const errorListener = (err) => lastUpdateError = err;
|
|
7003
7037
|
comment.on("error", errorListener);
|
|
7038
|
+
let abortError;
|
|
7039
|
+
let abortReject;
|
|
7040
|
+
const abortListener = () => {
|
|
7041
|
+
abortError = new PKCError("ERR_GET_COMMENT_ABORTED", {
|
|
7042
|
+
getCommentArgs: parsedGetCommentArgs,
|
|
7043
|
+
abortReason: abortSignal?.reason,
|
|
7044
|
+
lastUpdateError
|
|
7045
|
+
});
|
|
7046
|
+
abortReject?.(abortError);
|
|
7047
|
+
};
|
|
7048
|
+
const abortPromise = new Promise((_, reject) => {
|
|
7049
|
+
abortReject = reject;
|
|
7050
|
+
});
|
|
7051
|
+
abortPromise.catch(() => {});
|
|
7052
|
+
abortSignal?.addEventListener("abort", abortListener);
|
|
7004
7053
|
const commentTimeout = this._timeouts["comment-ipfs"];
|
|
7005
7054
|
try {
|
|
7006
|
-
await pTimeout(comment._attemptInfintelyToLoadCommentIpfs(), {
|
|
7055
|
+
await pTimeout(Promise.race([comment._attemptInfintelyToLoadCommentIpfs(), abortPromise]), {
|
|
7007
7056
|
milliseconds: commentTimeout,
|
|
7008
7057
|
message: lastUpdateError || new TimeoutError(`pkc.getComment({cid: ${parsedGetCommentArgs}}) timed out after ${commentTimeout}ms`)
|
|
7009
7058
|
});
|
|
7010
7059
|
if (!comment.signature) throw Error("Failed to load CommentIpfs");
|
|
7011
7060
|
return comment;
|
|
7012
7061
|
} catch (e) {
|
|
7062
|
+
if (abortError) throw abortError;
|
|
7013
7063
|
if (lastUpdateError) throw lastUpdateError;
|
|
7014
7064
|
throw e;
|
|
7015
7065
|
} finally {
|
|
7066
|
+
abortSignal?.removeEventListener("abort", abortListener);
|
|
7016
7067
|
comment.removeListener("error", errorListener);
|
|
7017
7068
|
await comment.stop();
|
|
7018
7069
|
}
|
|
@@ -7176,7 +7227,7 @@ var PKC$1 = class extends PKCTypedEmitter {
|
|
|
7176
7227
|
const log = logger_default("pkc-js:pkc:createLocalCommunity");
|
|
7177
7228
|
log.trace("Received community options to create a local community instance:", options);
|
|
7178
7229
|
if (!this._canCreateNewLocalCommunity()) throw new PKCError("ERR_CAN_NOT_CREATE_A_LOCAL_COMMUNITY", { pkcOptions: this._userPKCOptions });
|
|
7179
|
-
const { LocalCommunity, createNewLocalCommunityDb, updateInstancePropsWithStartedCommunityOrDb } = await import("./local-community-
|
|
7230
|
+
const { LocalCommunity, createNewLocalCommunityDb, updateInstancePropsWithStartedCommunityOrDb } = await import("./local-community-4wIeaqty.js");
|
|
7180
7231
|
const isLocalCommunity = (await listCommunitiesSync(this)).includes(options.address);
|
|
7181
7232
|
const community = new LocalCommunity(this);
|
|
7182
7233
|
if (isLocalCommunity) {
|
|
@@ -7199,8 +7250,9 @@ var PKC$1 = class extends PKCTypedEmitter {
|
|
|
7199
7250
|
if (this.communities.includes(jsonfied.address)) return this._createLocalCommunity(jsonfied);
|
|
7200
7251
|
else return this._createRemoteCommunityInstance(jsonfied);
|
|
7201
7252
|
}
|
|
7202
|
-
async createCommunity(options = {}) {
|
|
7253
|
+
async createCommunity(options = {}, opts) {
|
|
7203
7254
|
const log = logger_default("pkc-js:pkc:createCommunity");
|
|
7255
|
+
throwIfAbortSignalAborted(opts?.abortSignal);
|
|
7204
7256
|
if ("clients" in options) return this._createCommunityInstanceFromJsonifiedCommunity(options);
|
|
7205
7257
|
const parsedOptions = options;
|
|
7206
7258
|
log.trace("Received options: ", parsedOptions);
|
|
@@ -7532,9 +7584,16 @@ var PKC$1 = class extends PKCTypedEmitter {
|
|
|
7532
7584
|
return this._storageLRUs[opts.cacheName];
|
|
7533
7585
|
}
|
|
7534
7586
|
_getDestroyAbortSignal() {
|
|
7535
|
-
if (!this._destroyAbortController)
|
|
7587
|
+
if (!this._destroyAbortController) {
|
|
7588
|
+
this._destroyAbortController = new AbortController();
|
|
7589
|
+
if (this.destroyed) this._destroyAbortController.abort(new PKCError("ERR_PKC_IS_DESTROYED"));
|
|
7590
|
+
}
|
|
7536
7591
|
return this._destroyAbortController.signal;
|
|
7537
7592
|
}
|
|
7593
|
+
_combineWithDestroyAbortSignal(abortSignal) {
|
|
7594
|
+
const destroySignal = this._getDestroyAbortSignal();
|
|
7595
|
+
return abortSignal ? AbortSignal.any([abortSignal, destroySignal]) : destroySignal;
|
|
7596
|
+
}
|
|
7538
7597
|
async destroy() {
|
|
7539
7598
|
const log = logger_default("pkc-js:pkc:destroy");
|
|
7540
7599
|
if (this.destroyed) return;
|
|
@@ -7624,9 +7683,22 @@ var PKCWithRpcClient = class extends PKC$1 {
|
|
|
7624
7683
|
await super.destroy();
|
|
7625
7684
|
await this._pkcRpcClient.destroy();
|
|
7626
7685
|
}
|
|
7627
|
-
async getComment(
|
|
7628
|
-
const
|
|
7629
|
-
const
|
|
7686
|
+
async getComment(getCommentArgs) {
|
|
7687
|
+
const { abortSignal, ...cidArgs } = getCommentArgs;
|
|
7688
|
+
const parsedArgs = parseRpcCidParam(cidArgs);
|
|
7689
|
+
const cancellation = rejectWhenAbortSignalFires({
|
|
7690
|
+
abortSignal: this._combineWithDestroyAbortSignal(abortSignal),
|
|
7691
|
+
error: () => new PKCError("ERR_GET_COMMENT_ABORTED", {
|
|
7692
|
+
getCommentArgs: parsedArgs,
|
|
7693
|
+
abortReason: abortSignal?.reason
|
|
7694
|
+
})
|
|
7695
|
+
});
|
|
7696
|
+
let commentIpfs;
|
|
7697
|
+
try {
|
|
7698
|
+
commentIpfs = await Promise.race([this._pkcRpcClient.getComment(parsedArgs), cancellation.promise]);
|
|
7699
|
+
} finally {
|
|
7700
|
+
cancellation.cleanup();
|
|
7701
|
+
}
|
|
7630
7702
|
return this.createComment({
|
|
7631
7703
|
...parsedArgs,
|
|
7632
7704
|
raw: {
|
|
@@ -7639,8 +7711,9 @@ var PKCWithRpcClient = class extends PKC$1 {
|
|
|
7639
7711
|
if (!getCommunityArgs.address && !getCommunityArgs.name && !getCommunityArgs.publicKey) throw new Error("At least one of address, name, or publicKey must be provided");
|
|
7640
7712
|
return super.getCommunity(getCommunityArgs);
|
|
7641
7713
|
}
|
|
7642
|
-
async createCommunity(options = {}) {
|
|
7714
|
+
async createCommunity(options = {}, opts) {
|
|
7643
7715
|
const log = logger_default("pkc-js:pkc-with-rpc-client:createCommunity");
|
|
7716
|
+
throwIfAbortSignalAborted(opts?.abortSignal);
|
|
7644
7717
|
const parsedRpcOptions = "clients" in options ? options : parseCreateRpcCommunityFunctionArgumentSchemaWithPKCErrorIfItFails(options);
|
|
7645
7718
|
log.trace("Received community options to create a community instance over RPC:", options);
|
|
7646
7719
|
const hasIdentifier = "address" in parsedRpcOptions && typeof parsedRpcOptions.address === "string" || "name" in parsedRpcOptions && typeof parsedRpcOptions.name === "string" || "publicKey" in parsedRpcOptions && typeof parsedRpcOptions.publicKey === "string";
|
|
@@ -7663,9 +7736,24 @@ var PKCWithRpcClient = class extends PKC$1 {
|
|
|
7663
7736
|
const updatePromise = new Promise((resolve) => community.once("update", resolve));
|
|
7664
7737
|
let error;
|
|
7665
7738
|
const errorPromise = new Promise((resolve) => community.once("error", (err) => resolve(error = err)));
|
|
7666
|
-
|
|
7667
|
-
|
|
7668
|
-
|
|
7739
|
+
const cancellation = rejectWhenCommunityStopsOrAborts({
|
|
7740
|
+
community,
|
|
7741
|
+
abortSignal: this._combineWithDestroyAbortSignal(opts?.abortSignal)
|
|
7742
|
+
});
|
|
7743
|
+
try {
|
|
7744
|
+
await Promise.race([community._createAndSubscribeToNewUpdatingCommunity(community), cancellation.promise]);
|
|
7745
|
+
await Promise.race([community.update(), cancellation.promise]);
|
|
7746
|
+
await Promise.race([
|
|
7747
|
+
updatePromise,
|
|
7748
|
+
errorPromise,
|
|
7749
|
+
cancellation.promise
|
|
7750
|
+
]);
|
|
7751
|
+
} catch (e) {
|
|
7752
|
+
await community.stop().catch((stopErr) => log.error("Failed to stop a cancelled community instance", stopErr));
|
|
7753
|
+
throw e;
|
|
7754
|
+
} finally {
|
|
7755
|
+
cancellation.cleanup();
|
|
7756
|
+
}
|
|
7669
7757
|
await community.stop();
|
|
7670
7758
|
if (error) throw error;
|
|
7671
7759
|
await community._attachExportsSubscription();
|
package/dist/bundled/chunks/{rpc-local-community-0XmKyOdO.js → rpc-local-community-r51cTBYd.js}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { i as __toESM, n as __exportAll, r as __require, t as __commonJSMin } from "./chunk-2rV9d50f.js";
|
|
2
|
-
import { $ as pubsubTopicToDhtKey, $n as n$
|
|
2
|
+
import { $ as pubsubTopicToDhtKey, $n as n$10, $t as ChallengeFileSchema, A as extractNetworkErrorDetails, An as CommentUpdateSignedPropertyNames, Ar as literal, At as refreshTrackedCommunityAliases, B as isIpfsCid, Bt as pTimeout, Cn as CommentPubsubMessageWithFlexibleAuthorRefinementSchema, Cr as require_supports_color, Ct as findStartedCommunity, D as deepMergeRuntimeFields, Dn as CommentUpdateForChallengeVerificationSignedPropertyNames, Dr as array, E as createAbortError, Er as _enum, Et as listStartedCommunities, Fn as ModQueuePageIpfsSchema, Ft as untrackStartedCommunity, Gn as AuthorCommentIpfsReservedFields, Gt as CreateCommunityEditPublicationOptionsWithRefinementSchema, H as isIpns, I as getPostUpdateTimestampRange, In as PageIpfsSchema, It as untrackUpdatingComment, Jn as CidPathSchema, Kt as CommentModerationChallengeRequestToEncryptSchema, L as hideClassPrivateProps, Ln as CommentEditChallengeRequestToEncryptSchema, Lt as untrackUpdatingCommunity, Mr as object, Mt as trackStartedCommunity, Nn as CreateCommentOptionsWithRefinementSchema, Nr as record, O as derivePublicationFromChallengeRequest, On as CommentUpdateReservedFields, Or as boolean, Ot as listUpdatingCommunities, Pn as GetPageParamSchema, Pr as string, Pt as trackUpdatingCommunity, Q as isStringDomain, Qn as CreateSignerSchema, Qt as ChallengeFileFactorySchema, R as ipnsNameToIpnsOverPubsubTopic, Rt as require_sha256$1, Sr as logger_default, Tn as CommentUpdateChallengeReservedFieldNames, Tt as findUpdatingCommunity, U as isIpnsPath, Un as CreateCommentEditOptionsWithRefinementSchema, Ut as CommunityEditPublicationSignedPropertyNames, V as isIpfsPath, Vn as CommentEditSignedPropertyNames, Vt as CommunityEditPublicationChallengeRequestToEncryptSchema, Wn as AuthorAddressSchema, Wt as CommunityEditPubsubMessagePublicationSchema, X as isRequestPubsubPublicationOfPost, Xn as CommunityAddressSchema, Xt as CommentModerationsTableRowSchema, Yn as CidStringSchema, Yt as CommentModerationSignedPropertyNames, Z as isRequestPubsubPublicationOfReply, Zn as CommunityAuthorChallengeReservedFieldNames, Zt as CreateCommentModerationOptionsWithRefinementSchema, _ as PKCUserOptionBaseSchema, _n as VoteSignedPropertyNames, _r as FailedToFetchCommunityFromGatewaysError, an as CommunityIpfsSchema, ar as e$5, b as areEquivalentCommunityAddresses, bn as CommentIpfsReservedFields, br as PKCError, bt as waitForUpdateInCommunityInstanceWithErrorAndTimeout, c as ChallengeVerificationMessageSignedPropertyNames, cn as CreateRemoteCommunityFunctionArgumentSchema, cr as t$12, dr as t$10, f as DecryptedChallengeSchema, fn as RpcRemoteCommunityUpdateEventResultSchema, fr as t$9, g as PKCParsedOptionsSchema, gr as FailedToFetchCommentUpdateFromGatewaysError, gt as sleepUntilTimeoutOrAbort, h as NameResolverSerializedSchema, hn as VotePubsubMessagePublicationSchema, hr as FailedToFetchCommentIpfsFromGatewaysError, ht as shortifyCid, i as ChallengeMessageSignedPropertyNames, in as CommunityIpfsReservedFields, ir as e$6, j as fetchAndValidateIpnsRecordFromGateway, jr as number, k as doesDomainAddressHaveCapitalLetter, kn as CommentUpdateSchema, kr as custom, l as DecryptedChallengeAnswerSchema, ln as CreateRpcCommunityFunctionArgumentSchema, lr as n$8, m as NameResolveCacheOptionsSchema, mn as VoteChallengeRequestToEncryptSchema, mr as require_retry$1, mt as shortifyAddress, n as ChallengeAnswerMessageSignedPropertyNames, nn as CommunityEditOptionsSchema, o as ChallengeRequestMessageSignedPropertyNames, on as CommunitySignedPropertyNames, or as t$11, ot as removeNullUndefinedEmptyObjectsValuesRecursively, p as DecryptedChallengeVerificationSchema, pn as CreateVoteUserOptionsWithRefinementSchema, pr as e$4, qn as ChallengeAnswersSchema, qt as CommentModerationPubsubMessagePublicationSchema, rn as CommunityExportRecordsSchema, rr as t$13, sn as CreateNewLocalCommunityUserOptionsSchema, sr as r$8, tn as CommunityChallengeSettingSchema, tr as n$9, tt as raceAgainstAbort, un as ExportCommunityModLogsOptionsSchema, ur as r$7, ut as resolveWhenPredicateIsTrue, v as PKCUserOptionsSchema, vr as FailedToFetchGenericIpfsFromGatewaysError, vt as throwIfAbortSignalAborted, wn as CommentSignedPropertyNames, wr as require_ms$1, wt as findUpdatingComment, x as calculateIpfsCidV0, xn as CommentIpfsSchema, xr as messages, yn as CommentChallengeRequestToEncryptSchema, yr as FailedToFetchPageIpfsFromGatewaysError, yt as timestamp, z as isAbortError, zn as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema } from "./schema-AXrL86Q4.js";
|
|
3
3
|
import { t as all } from "./src-CYIMjhjK.js";
|
|
4
4
|
import { createHash } from "node:crypto";
|
|
5
5
|
import { pathToFileURL } from "node:url";
|
|
@@ -99717,7 +99717,7 @@ var PublicationClientsManager = class extends PKCClientsManager {
|
|
|
99717
99717
|
const community = directCommunityInstance || await this._pkc.createCommunity({
|
|
99718
99718
|
name: this._publication.communityName,
|
|
99719
99719
|
publicKey: this._publication.communityPublicKey
|
|
99720
|
-
});
|
|
99720
|
+
}, { abortSignal: this._publication._getCommunityFetchAbortSignal() });
|
|
99721
99721
|
this._communityForUpdating = {
|
|
99722
99722
|
community,
|
|
99723
99723
|
error: this.handleErrorEventFromCommunity.bind(this),
|
|
@@ -99806,7 +99806,11 @@ var PublicationClientsManager = class extends PKCClientsManager {
|
|
|
99806
99806
|
if (!updatingCommunityInstance.community.raw.communityIpfs) {
|
|
99807
99807
|
const timeoutMs = this._pkc._timeouts["community-ipns"];
|
|
99808
99808
|
try {
|
|
99809
|
-
await waitForUpdateInCommunityInstanceWithErrorAndTimeout(
|
|
99809
|
+
await waitForUpdateInCommunityInstanceWithErrorAndTimeout({
|
|
99810
|
+
community: updatingCommunityInstance.community,
|
|
99811
|
+
timeoutMs,
|
|
99812
|
+
abortSignal: this._publication._getCommunityFetchAbortSignal()
|
|
99813
|
+
});
|
|
99810
99814
|
communityIpfs = updatingCommunityInstance.community.raw.communityIpfs;
|
|
99811
99815
|
} catch (e) {
|
|
99812
99816
|
await this.cleanUpUpdatingCommunityInstance();
|
|
@@ -129211,14 +129215,16 @@ var RpcRemoteCommunity = class extends RemoteCommunity {
|
|
|
129211
129215
|
const log = logger_default("pkc-js:rpc-remote-community:stop");
|
|
129212
129216
|
if (this.state === "stopped") return;
|
|
129213
129217
|
if (this._updatingRpcCommunityInstanceWithListeners) await this._cleanupMirroringUpdatingCommunity();
|
|
129214
|
-
else
|
|
129215
|
-
|
|
129216
|
-
|
|
129217
|
-
|
|
129218
|
-
|
|
129218
|
+
else {
|
|
129219
|
+
if (this._updateRpcSubscriptionId) {
|
|
129220
|
+
try {
|
|
129221
|
+
await this._pkc._pkcRpcClient.unsubscribe(this._updateRpcSubscriptionId);
|
|
129222
|
+
} catch (e) {
|
|
129223
|
+
log.error("Failed to unsubscribe from communityUpdate", e);
|
|
129224
|
+
}
|
|
129225
|
+
this._updateRpcSubscriptionId = void 0;
|
|
129226
|
+
log.trace(`Stopped the update of remote community (${this.address}) via RPC`);
|
|
129219
129227
|
}
|
|
129220
|
-
this._updateRpcSubscriptionId = void 0;
|
|
129221
|
-
log.trace(`Stopped the update of remote community (${this.address}) via RPC`);
|
|
129222
129228
|
untrackUpdatingCommunity(this._pkc, this);
|
|
129223
129229
|
}
|
|
129224
129230
|
this._setRpcClientStateWithEmission("stopped");
|
|
@@ -5153,6 +5153,9 @@ var messages;
|
|
|
5153
5153
|
messages["ERR_FETCH_OVER_IPNS_OVER_PUBSUB_RETURNED_UNDEFINED"] = "libp2p Fetch over IPNS-Over-Pubsub returned undefined when requested from a peer";
|
|
5154
5154
|
messages["ERR_FAILED_TO_DIAL_ANY_PEERS_PROVIDING_CID"] = "Failed to dial and connect to any peers providing a CID";
|
|
5155
5155
|
messages["ERR_GET_COMMUNITY_TIMED_OUT"] = "pkc.getCommunity({address}) timed out";
|
|
5156
|
+
messages["ERR_GET_COMMUNITY_ABORTED"] = "Aborted while waiting for the community record to load";
|
|
5157
|
+
messages["ERR_COMMUNITY_STOPPED_WHILE_LOADING"] = "The community instance was stopped while its record was being loaded";
|
|
5158
|
+
messages["ERR_GET_COMMENT_ABORTED"] = "Aborted while waiting for the comment record to load";
|
|
5156
5159
|
messages["ERR_TIMEOUT_WAITING_FOR_PUBSUB_TOPIC_PEERS"] = "Timeout waiting for propagation of pubsub topic peers";
|
|
5157
5160
|
messages["ERR_PUBSUB_TOPIC_PEER_WAIT_ABORTED"] = "Aborted while waiting for a peer to subscribe to a pubsub topic";
|
|
5158
5161
|
messages["ERR_IPNS_DIRECT_FETCH_ABORTED"] = "Aborted while fetching an IPNS record directly from subscribers/providers";
|
|
@@ -6463,7 +6466,8 @@ const additionalCommentReservedFields = [
|
|
|
6463
6466
|
"publishingState",
|
|
6464
6467
|
"updatingState",
|
|
6465
6468
|
"rowid",
|
|
6466
|
-
"nameResolved"
|
|
6469
|
+
"nameResolved",
|
|
6470
|
+
"abortSignal"
|
|
6467
6471
|
];
|
|
6468
6472
|
const CommentPubsubMessageReservedFields = r$2(n([
|
|
6469
6473
|
...t$3(CommentIpfsSchema.shape),
|
|
@@ -6817,7 +6821,8 @@ const CommunityIpfsReservedFields = r$2([
|
|
|
6817
6821
|
"publishingState",
|
|
6818
6822
|
"updatingState",
|
|
6819
6823
|
"started",
|
|
6820
|
-
"exports"
|
|
6824
|
+
"exports",
|
|
6825
|
+
"abortSignal"
|
|
6821
6826
|
], t$3(CommunityIpfsSchema.shape));
|
|
6822
6827
|
//#endregion
|
|
6823
6828
|
//#region dist/node/publications/comment-moderation/schema.js
|
|
@@ -15613,7 +15618,50 @@ async function resolveWhenPredicateIsTrue(options) {
|
|
|
15613
15618
|
listener();
|
|
15614
15619
|
});
|
|
15615
15620
|
}
|
|
15616
|
-
|
|
15621
|
+
function rejectWhenAbortSignalFires(opts) {
|
|
15622
|
+
const { abortSignal, error } = opts;
|
|
15623
|
+
let rejectPromise;
|
|
15624
|
+
const promise = new Promise((_, reject) => {
|
|
15625
|
+
rejectPromise = reject;
|
|
15626
|
+
});
|
|
15627
|
+
promise.catch(() => {});
|
|
15628
|
+
const onAbort = () => rejectPromise?.(error());
|
|
15629
|
+
abortSignal?.addEventListener("abort", onAbort);
|
|
15630
|
+
const cleanup = () => abortSignal?.removeEventListener("abort", onAbort);
|
|
15631
|
+
if (abortSignal?.aborted) onAbort();
|
|
15632
|
+
return {
|
|
15633
|
+
promise,
|
|
15634
|
+
cleanup
|
|
15635
|
+
};
|
|
15636
|
+
}
|
|
15637
|
+
function rejectWhenCommunityStopsOrAborts(opts) {
|
|
15638
|
+
const { community, abortSignal } = opts;
|
|
15639
|
+
let rejectPromise;
|
|
15640
|
+
const promise = new Promise((_, reject) => {
|
|
15641
|
+
rejectPromise = reject;
|
|
15642
|
+
});
|
|
15643
|
+
promise.catch(() => {});
|
|
15644
|
+
const onAbort = () => rejectPromise?.(new PKCError("ERR_GET_COMMUNITY_ABORTED", {
|
|
15645
|
+
communityAddress: community.address,
|
|
15646
|
+
abortReason: abortSignal?.reason
|
|
15647
|
+
}));
|
|
15648
|
+
const onStateChange = (newState) => {
|
|
15649
|
+
if (newState === "stopped") rejectPromise?.(new PKCError("ERR_COMMUNITY_STOPPED_WHILE_LOADING", { communityAddress: community.address }));
|
|
15650
|
+
};
|
|
15651
|
+
community.on("statechange", onStateChange);
|
|
15652
|
+
abortSignal?.addEventListener("abort", onAbort);
|
|
15653
|
+
const cleanup = () => {
|
|
15654
|
+
community.removeListener("statechange", onStateChange);
|
|
15655
|
+
abortSignal?.removeEventListener("abort", onAbort);
|
|
15656
|
+
};
|
|
15657
|
+
if (abortSignal?.aborted) onAbort();
|
|
15658
|
+
return {
|
|
15659
|
+
promise,
|
|
15660
|
+
cleanup
|
|
15661
|
+
};
|
|
15662
|
+
}
|
|
15663
|
+
async function waitForUpdateInCommunityInstanceWithErrorAndTimeout(opts) {
|
|
15664
|
+
const { community, timeoutMs, abortSignal } = opts;
|
|
15617
15665
|
const wasUpdating = community.state === "updating";
|
|
15618
15666
|
const updatingStates = [];
|
|
15619
15667
|
const updatingStateChangeListener = (state) => updatingStates.push(state);
|
|
@@ -15642,10 +15690,33 @@ async function waitForUpdateInCommunityInstanceWithErrorAndTimeout(community, ti
|
|
|
15642
15690
|
}
|
|
15643
15691
|
};
|
|
15644
15692
|
community.on("error", errorListener);
|
|
15693
|
+
let abortError;
|
|
15694
|
+
let abortReject;
|
|
15695
|
+
const abortListener = () => {
|
|
15696
|
+
abortError = new PKCError("ERR_GET_COMMUNITY_ABORTED", {
|
|
15697
|
+
communityAddress: community.address,
|
|
15698
|
+
abortReason: abortSignal?.reason,
|
|
15699
|
+
updatingStates,
|
|
15700
|
+
errors
|
|
15701
|
+
});
|
|
15702
|
+
abortReject?.(abortError);
|
|
15703
|
+
};
|
|
15704
|
+
const abortPromise = new Promise((_, reject) => {
|
|
15705
|
+
abortReject = reject;
|
|
15706
|
+
});
|
|
15707
|
+
abortPromise.catch(() => {});
|
|
15708
|
+
if (abortSignal) if (abortSignal.aborted) abortListener();
|
|
15709
|
+
else abortSignal.addEventListener("abort", abortListener);
|
|
15645
15710
|
try {
|
|
15711
|
+
if (abortError) throw abortError;
|
|
15646
15712
|
if (community.state !== "started") await community.update();
|
|
15713
|
+
if (abortError) throw abortError;
|
|
15647
15714
|
if (criticalError) throw criticalError;
|
|
15648
|
-
await pTimeout(Promise.race([
|
|
15715
|
+
await pTimeout(Promise.race([
|
|
15716
|
+
updatePromise,
|
|
15717
|
+
nonRetriableErrorPromise,
|
|
15718
|
+
abortPromise
|
|
15719
|
+
]), {
|
|
15649
15720
|
milliseconds: timeoutMs,
|
|
15650
15721
|
message: criticalError || errors.at(-1) || new PKCError("ERR_GET_COMMUNITY_TIMED_OUT", {
|
|
15651
15722
|
communityAddress: community.address,
|
|
@@ -15657,6 +15728,7 @@ async function waitForUpdateInCommunityInstanceWithErrorAndTimeout(community, ti
|
|
|
15657
15728
|
});
|
|
15658
15729
|
if (criticalError) throw criticalError;
|
|
15659
15730
|
} catch (e) {
|
|
15731
|
+
if (abortError) throw abortError;
|
|
15660
15732
|
if (criticalError) throw criticalError;
|
|
15661
15733
|
if (errors.length > 0) throw errors.at(-1);
|
|
15662
15734
|
const updatingCommunity = findUpdatingCommunity(community._pkc, {
|
|
@@ -15666,6 +15738,7 @@ async function waitForUpdateInCommunityInstanceWithErrorAndTimeout(community, ti
|
|
|
15666
15738
|
if (updatingCommunity?._clientsManager._ipnsLoadingOperation?.mainError()) throw updatingCommunity._clientsManager._ipnsLoadingOperation.mainError();
|
|
15667
15739
|
throw e;
|
|
15668
15740
|
} finally {
|
|
15741
|
+
abortSignal?.removeEventListener("abort", abortListener);
|
|
15669
15742
|
if (updateListener) community.removeListener("update", updateListener);
|
|
15670
15743
|
community.removeListener("error", errorListener);
|
|
15671
15744
|
community.removeListener("updatingstatechange", updatingStateChangeListener);
|
|
@@ -16078,7 +16151,7 @@ function extractNetworkErrorDetails(err, depth = 0) {
|
|
|
16078
16151
|
}
|
|
16079
16152
|
//#endregion
|
|
16080
16153
|
//#region dist/node/generated-version.js
|
|
16081
|
-
const version = "0.0.
|
|
16154
|
+
const version = "0.0.84";
|
|
16082
16155
|
//#endregion
|
|
16083
16156
|
//#region dist/node/version.js
|
|
16084
16157
|
const protocolVersion = ProtocolVersionSchema.parse("1.0.0");
|
|
@@ -16232,4 +16305,4 @@ const DecryptedChallengeVerificationSchema = object({
|
|
|
16232
16305
|
}).strict();
|
|
16233
16306
|
const ChallengeVerificationMessageSignedPropertyNames = t$3(n$3(ChallengeVerificationMessageSchema.shape, ["signature"]));
|
|
16234
16307
|
//#endregion
|
|
16235
|
-
export { pubsubTopicToDhtKey as $, n
|
|
16308
|
+
export { pubsubTopicToDhtKey as $, n as $n, ChallengeFileSchema as $t, extractNetworkErrorDetails as A, CommentUpdateSignedPropertyNames as An, literal as Ar, refreshTrackedCommunityAliases as At, isIpfsCid as B, CommentEditReservedFields as Bn, pTimeout as Bt, contentContainsMarkdownAudio as C, CommentPubsubMessageWithFlexibleAuthorRefinementSchema as Cn, require_supports_color as Cr, findStartedCommunity as Ct, deepMergeRuntimeFields as D, CommentUpdateForChallengeVerificationSignedPropertyNames as Dn, array as Dr, listUpdatingComments as Dt, createAbortError as E, CommentUpdateForChallengeVerificationSchema as En, _enum as Er, listStartedCommunities as Et, getIpnsRecordInLocalKuboNode as F, ModQueuePageIpfsSchema as Fn, ZodError as Fr, untrackStartedCommunity as Ft, isLinkOfAudio as G, AuthorCommentIpfsReservedFields as Gn, CreateCommunityEditPublicationOptionsWithRefinementSchema as Gt, isIpns as H, CommentEditsTableRowSchema as Hn, CommunityEditPublicationPubsubReservedFields as Ht, getPostUpdateTimestampRange as I, PageIpfsSchema as In, joinValues as Ir, untrackUpdatingComment as It, isLinkOfVideo as J, CidPathSchema as Jn, CommentModerationReservedFields as Jt, isLinkOfImage as K, AuthorReservedFields as Kn, CommentModerationChallengeRequestToEncryptSchema as Kt, hideClassPrivateProps as L, CommentEditChallengeRequestToEncryptSchema as Ln, parsedType as Lr, untrackUpdatingCommunity as Lt, genToArray as M, CommentsTableRowSchema as Mn, object as Mr, trackStartedCommunity as Mt, getEquivalentCommunityAddresses as N, CreateCommentOptionsWithRefinementSchema as Nn, record as Nr, trackUpdatingComment as Nt, derivePublicationFromChallengeRequest as O, CommentUpdateReservedFields as On, boolean as Or, listUpdatingCommunities as Ot, getErrorCodeFromMessage as P, GetPageParamSchema as Pn, string as Pr, trackUpdatingCommunity as Pt, isStringDomain as Q, CreateSignerSchema as Qn, ChallengeFileFactorySchema as Qt, ipnsNameToIpnsOverPubsubTopic as R, CommentEditPubsubMessagePublicationSchema as Rn, stringifyPrimitive as Rr, require_sha256 as Rt, calculateStringSizeSameAsIpfsAddCidV0 as S, CommentPubsubMessageReservedFields as Sn, logger_default as Sr, findCommunityInRegistry as St, contentContainsMarkdownVideos as T, CommentUpdateChallengeReservedFieldNames as Tn, setErrorMap as Tr, findUpdatingCommunity as Tt, isIpnsPath as U, CreateCommentEditOptionsWithRefinementSchema as Un, CommunityEditPublicationSignedPropertyNames as Ut, isIpfsPath as V, CommentEditSignedPropertyNames as Vn, CommunityEditPublicationChallengeRequestToEncryptSchema as Vt, isLinkOfAnimatedImage as W, AuthorAddressSchema as Wn, CommunityEditPubsubMessagePublicationSchema as Wt, isRequestPubsubPublicationOfPost as X, CommunityAddressSchema as Xn, CommentModerationsTableRowSchema as Xt, isLinkValid as Y, CidStringSchema as Yn, CommentModerationSignedPropertyNames as Yt, isRequestPubsubPublicationOfReply as Z, CommunityAuthorChallengeReservedFieldNames as Zn, CreateCommentModerationOptionsWithRefinementSchema as Zt, PKCUserOptionBaseSchema as _, VoteSignedPropertyNames as _n, FailedToFetchCommunityFromGatewaysError as _r, statMfsPathSafely as _t, ChallengeRequestMessageSchema as a, CommunityIpfsSchema as an, e$2 as ar, removeMfsFilesSafely as at, areEquivalentCommunityAddresses as b, CommentIpfsReservedFields as bn, PKCError as br, waitForUpdateInCommunityInstanceWithErrorAndTimeout as bt, ChallengeVerificationMessageSignedPropertyNames as c, CreateRemoteCommunityFunctionArgumentSchema as cn, t$5 as cr, removeUndefinedValuesRecursively as ct, DecryptedChallengeRequestSchema as d, PubsubTopicSchema as dn, t$7 as dr, retryKuboBlockPutPinAndProvidePubsubTopic as dt, CommunityAnchorSchema as en, t$1 as er, pubsubTopicToDhtKeyCid as et, DecryptedChallengeSchema as f, RpcRemoteCommunityUpdateEventResultSchema as fn, t$8 as fr, retryKuboIpfsAdd as ft, PKCParsedOptionsSchema as g, VotePubsubReservedFields as gn, FailedToFetchCommentUpdateFromGatewaysError as gr, sleepUntilTimeoutOrAbort as gt, NameResolverSerializedSchema as h, VotePubsubMessagePublicationSchema as hn, FailedToFetchCommentIpfsFromGatewaysError as hr, shortifyCid as ht, ChallengeMessageSignedPropertyNames as i, CommunityIpfsReservedFields as in, e as ir, removeBlocksFromKuboNode as it, fetchAndValidateIpnsRecordFromGateway as j, CommentUpdateTableRowSchema as jn, number as jr, syncCommunityRegistryEntry as jt, doesDomainAddressHaveCapitalLetter as k, CommentUpdateSchema as kn, custom as kr, refreshTrackedCommentAliases as kt, DecryptedChallengeAnswerSchema as l, CreateRpcCommunityFunctionArgumentSchema as ln, n$7 as lr, replaceXWithY as lt, NameResolveCacheOptionsSchema as m, VoteChallengeRequestToEncryptSchema as mn, require_retry as mr, shortifyAddress as mt, ChallengeAnswerMessageSignedPropertyNames as n, CommunityEditOptionsSchema as nn, t$2 as nr, rejectWhenAbortSignalFires as nt, ChallengeRequestMessageSignedPropertyNames as o, CommunitySignedPropertyNames as on, t$4 as or, removeNullUndefinedEmptyObjectsValuesRecursively as ot, DecryptedChallengeVerificationSchema as p, CreateVoteUserOptionsWithRefinementSchema as pn, e$4 as pr, retryKuboIpfsAddAndProvide as pt, isLinkOfMedia as q, ChallengeAnswersSchema as qn, CommentModerationPubsubMessagePublicationSchema as qt, ChallengeMessageSchema as r, CommunityExportRecordsSchema as rn, t$3 as rr, rejectWhenCommunityStopsOrAborts as rt, ChallengeVerificationMessageSchema as s, CreateNewLocalCommunityUserOptionsSchema as sn, r$2 as sr, removeNullUndefinedValues as st, ChallengeAnswerMessageSchema as t, CommunityChallengeSettingSchema as tn, n$3 as tr, raceAgainstAbort as tt, DecryptedChallengeRequestPublicationSchema as u, ExportCommunityModLogsOptionsSchema as un, r$4 as ur, resolveWhenPredicateIsTrue as ut, PKCUserOptionsSchema as v, VoteTablesRowSchema as vn, FailedToFetchGenericIpfsFromGatewaysError as vr, throwIfAbortSignalAborted as vt, contentContainsMarkdownImages as w, CommentSignedPropertyNames as wn, require_ms as wr, findUpdatingComment as wt, calculateIpfsCidV0 as x, CommentIpfsSchema as xn, messages as xr, writeKuboFilesWithTimeout as xt, version_default as y, CommentChallengeRequestToEncryptSchema as yn, FailedToFetchPageIpfsFromGatewaysError as yr, timestamp as yt, isAbortError as z, CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema as zn, TimeoutError as zt };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { br as PKCError, et as pubsubTopicToDhtKeyCid } from "./schema-AXrL86Q4.js";
|
|
2
2
|
import { ipnsSelector } from "ipns/selector";
|
|
3
3
|
import { equals } from "uint8arrays/equals";
|
|
4
4
|
//#region dist/node/helia/util.js
|
package/dist/bundled/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as getShortCid, i as getShortAddress, n as challenges, o as nativeFunctions, r as createAnchorIpnsRecord, s as setNativeFunctions, t as PKC } from "./chunks/node-
|
|
1
|
+
import { a as getShortCid, i as getShortAddress, n as challenges, o as nativeFunctions, r as createAnchorIpnsRecord, s as setNativeFunctions, t as PKC } from "./chunks/node-B7GkmuSc.js";
|
|
2
2
|
export { challenges, createAnchorIpnsRecord, PKC as default, getShortAddress, getShortCid, nativeFunctions, setNativeFunctions };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { _ as parseRpcPublishAnchorRecordParam, c as parseRpcAuthorNameParam, d as parseRpcCommentRepliesPageParam, f as parseRpcCommunityIdentifierParam, g as parseRpcExportCommunityParam, h as parseRpcExportCommunityModLogsParam, l as parseRpcCancelExportParam, m as parseRpcEditCommunityParam, p as parseRpcCommunityPageParam, t as PKC, u as parseRpcCidParam, v as parseRpcPublishChallengeAnswersParam, y as parseRpcUnsubscribeParam } from "../../chunks/node-
|
|
3
|
-
import { An as parseVoteChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, K as buildPageRuntimeFields, Sn as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, _n as parseCreateNewLocalCommunityUserOptionsSchemaWithPKCErrorIfItFails, an as parseCommentModerationChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, ct as pLimit, kn as parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, ln as parseCommunityEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, lr as stringify, nn as parseCommentEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, nr as t$1, nt as extractCrosspostRuntimeFields, q as buildPagesRuntimeFields, st as pRetry, tn as parseCommentChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, un as parseCommunityEditOptionsSchemaWithPKCErrorIfItFails, ut as require_lib, vn as parseCreatePKCWsServerOptionsSchemaWithPKCErrorIfItFails } from "../../chunks/rpc-local-community-
|
|
4
|
-
import { t as LocalCommunity } from "../../chunks/local-community-
|
|
1
|
+
import { Ct as findStartedCommunity, L as hideClassPrivateProps, Sr as logger_default, br as PKCError, lt as replaceXWithY, rr as t, tr as n } from "../../chunks/schema-AXrL86Q4.js";
|
|
2
|
+
import { _ as parseRpcPublishAnchorRecordParam, c as parseRpcAuthorNameParam, d as parseRpcCommentRepliesPageParam, f as parseRpcCommunityIdentifierParam, g as parseRpcExportCommunityParam, h as parseRpcExportCommunityModLogsParam, l as parseRpcCancelExportParam, m as parseRpcEditCommunityParam, p as parseRpcCommunityPageParam, t as PKC, u as parseRpcCidParam, v as parseRpcPublishChallengeAnswersParam, y as parseRpcUnsubscribeParam } from "../../chunks/node-B7GkmuSc.js";
|
|
3
|
+
import { An as parseVoteChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, K as buildPageRuntimeFields, Sn as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, _n as parseCreateNewLocalCommunityUserOptionsSchemaWithPKCErrorIfItFails, an as parseCommentModerationChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, ct as pLimit, kn as parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, ln as parseCommunityEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, lr as stringify, nn as parseCommentEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, nr as t$1, nt as extractCrosspostRuntimeFields, q as buildPagesRuntimeFields, st as pRetry, tn as parseCommentChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, un as parseCommunityEditOptionsSchemaWithPKCErrorIfItFails, ut as require_lib, vn as parseCreatePKCWsServerOptionsSchemaWithPKCErrorIfItFails } from "../../chunks/rpc-local-community-r51cTBYd.js";
|
|
4
|
+
import { t as LocalCommunity } from "../../chunks/local-community-5PMI-TDB.js";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
6
|
import path from "path";
|
|
7
7
|
import assert from "assert";
|
|
@@ -282,15 +282,22 @@ export class RpcRemoteCommunity extends RemoteCommunity {
|
|
|
282
282
|
if (this._updatingRpcCommunityInstanceWithListeners) {
|
|
283
283
|
await this._cleanupMirroringUpdatingCommunity();
|
|
284
284
|
}
|
|
285
|
-
else
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
285
|
+
else {
|
|
286
|
+
if (this._updateRpcSubscriptionId) {
|
|
287
|
+
try {
|
|
288
|
+
await this._pkc._pkcRpcClient.unsubscribe(this._updateRpcSubscriptionId);
|
|
289
|
+
}
|
|
290
|
+
catch (e) {
|
|
291
|
+
log.error("Failed to unsubscribe from communityUpdate", e);
|
|
292
|
+
}
|
|
293
|
+
this._updateRpcSubscriptionId = undefined;
|
|
294
|
+
log.trace(`Stopped the update of remote community (${this.address}) via RPC`);
|
|
291
295
|
}
|
|
292
|
-
|
|
293
|
-
|
|
296
|
+
// Untracked even without a subscription id. _createAndSubscribeToNewUpdatingCommunity
|
|
297
|
+
// tracks the instance BEFORE _initRpcUpdateSubscription assigns that id, so a subscribe
|
|
298
|
+
// that fails or is cancelled used to leave a stopped instance sitting in
|
|
299
|
+
// _updatingCommunities for findUpdatingCommunity to hand out (issue #277). untrack() is
|
|
300
|
+
// identity-keyed and a no-op for an instance that was never tracked.
|
|
294
301
|
untrackUpdatingCommunity(this._pkc, this);
|
|
295
302
|
}
|
|
296
303
|
this._setRpcClientStateWithEmission("stopped");
|