@pkcprotocol/pkc-js 0.0.119 → 0.0.121
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 +2 -2
- package/dist/browser/community/community-client-manager.js +8 -2
- package/dist/browser/community/community-client-manager.js.map +1 -1
- package/dist/browser/errors.d.ts +2 -0
- package/dist/browser/errors.js +2 -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/pages/page-sort-options.d.ts +1 -0
- package/dist/browser/pages/page-sort-options.js +7 -6
- package/dist/browser/pages/page-sort-options.js.map +1 -1
- package/dist/browser/pages/page-sort-scoring.d.ts +5 -1
- package/dist/browser/pages/page-sort-scoring.js +23 -13
- package/dist/browser/pages/page-sort-scoring.js.map +1 -1
- package/dist/browser/pages/types.d.ts +1 -1
- package/dist/browser/pkc-error.d.ts +1 -1
- package/dist/browser/publications/publication.d.ts +2 -0
- package/dist/browser/publications/publication.js +24 -1
- package/dist/browser/publications/publication.js.map +1 -1
- package/dist/browser/rpc/src/index.d.ts +4 -0
- package/dist/browser/rpc/src/index.js +74 -19
- package/dist/browser/rpc/src/index.js.map +1 -1
- package/dist/browser/runtime/node/community/db-handler.d.ts +2 -2
- package/dist/browser/runtime/node/community/db-handler.js +42 -58
- package/dist/browser/runtime/node/community/db-handler.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/editing.d.ts +1 -0
- package/dist/browser/runtime/node/community/local-community/editing.js +25 -4
- package/dist/browser/runtime/node/community/local-community/editing.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/ipns-publishing.js +7 -4
- package/dist/browser/runtime/node/community/local-community/ipns-publishing.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/lifecycle.js +17 -4
- package/dist/browser/runtime/node/community/local-community/lifecycle.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/publication-validation.js +4 -0
- package/dist/browser/runtime/node/community/local-community/publication-validation.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community.d.ts +4 -1
- package/dist/browser/runtime/node/community/local-community.js +12 -1
- package/dist/browser/runtime/node/community/local-community.js.map +1 -1
- package/dist/browser/runtime/node/community/page-generator.d.ts +0 -1
- package/dist/browser/runtime/node/community/page-generator.js.map +1 -1
- package/dist/browser/runtime/node/community/page-sorts/index.js +22 -4
- package/dist/browser/runtime/node/community/page-sorts/index.js.map +1 -1
- package/dist/browser/runtime/node/util.d.ts +4 -1
- package/dist/browser/runtime/node/util.js +41 -24
- package/dist/browser/runtime/node/util.js.map +1 -1
- package/dist/browser/signer/encryption.js +5 -1
- package/dist/browser/signer/encryption.js.map +1 -1
- package/dist/bundled/bundle-manifest.json +52 -52
- package/dist/bundled/challenges.js +1 -1
- package/dist/bundled/chunks/{helia-for-pkc-Cr90E9ul.js → helia-for-pkc-Bw9KzcSY.js} +2 -2
- package/dist/bundled/chunks/{local-community-DngOEreY.js → local-community-CMkVMrOZ.js} +90 -73
- package/dist/bundled/chunks/{local-community-B-UbNa-z.js → local-community-feziLP2d.js} +1 -1
- package/dist/bundled/chunks/{node-BHLzTAo9.js → node-ByPmdQSD.js} +21 -5
- package/dist/bundled/chunks/{page-sort-scoring-Drqxj8Pi.js → page-sort-scoring-DEib5648.js} +11 -7
- package/dist/bundled/chunks/{rpc-local-community-_ooAoNPM.js → rpc-local-community-WmgDVdST.js} +61 -28
- package/dist/bundled/chunks/{util-DX2ZJtU4.js → util-BzXGIQ9v.js} +1 -1
- package/dist/bundled/chunks/{util-B-JWgzlN.js → util-ok4F-vdA.js} +3 -1
- package/dist/bundled/chunks/{validate-package-factories-BSmEBl_0.js → validate-package-factories-DoUgLmab.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 +56 -19
- package/dist/node/community/community-client-manager.js +8 -2
- package/dist/node/community/community-client-manager.js.map +1 -1
- package/dist/node/errors.d.ts +2 -0
- package/dist/node/errors.js +2 -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/pages/page-sort-options.d.ts +1 -0
- package/dist/node/pages/page-sort-options.js +7 -6
- package/dist/node/pages/page-sort-options.js.map +1 -1
- package/dist/node/pages/page-sort-scoring.d.ts +5 -1
- package/dist/node/pages/page-sort-scoring.js +23 -13
- package/dist/node/pages/page-sort-scoring.js.map +1 -1
- package/dist/node/pages/types.d.ts +1 -1
- package/dist/node/pkc-error.d.ts +1 -1
- package/dist/node/publications/publication.d.ts +2 -0
- package/dist/node/publications/publication.js +24 -1
- package/dist/node/publications/publication.js.map +1 -1
- package/dist/node/rpc/src/index.d.ts +4 -0
- package/dist/node/rpc/src/index.js +74 -19
- package/dist/node/rpc/src/index.js.map +1 -1
- package/dist/node/runtime/node/community/db-handler.d.ts +2 -2
- package/dist/node/runtime/node/community/db-handler.js +42 -58
- package/dist/node/runtime/node/community/db-handler.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/editing.d.ts +1 -0
- package/dist/node/runtime/node/community/local-community/editing.js +25 -4
- package/dist/node/runtime/node/community/local-community/editing.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/ipns-publishing.js +7 -4
- package/dist/node/runtime/node/community/local-community/ipns-publishing.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/lifecycle.js +17 -4
- package/dist/node/runtime/node/community/local-community/lifecycle.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/publication-validation.js +4 -0
- package/dist/node/runtime/node/community/local-community/publication-validation.js.map +1 -1
- package/dist/node/runtime/node/community/local-community.d.ts +4 -1
- package/dist/node/runtime/node/community/local-community.js +12 -1
- package/dist/node/runtime/node/community/local-community.js.map +1 -1
- package/dist/node/runtime/node/community/page-generator.d.ts +0 -1
- package/dist/node/runtime/node/community/page-generator.js.map +1 -1
- package/dist/node/runtime/node/community/page-sorts/index.js +22 -4
- package/dist/node/runtime/node/community/page-sorts/index.js.map +1 -1
- package/dist/node/runtime/node/util.d.ts +4 -1
- package/dist/node/runtime/node/util.js +41 -24
- package/dist/node/runtime/node/util.js.map +1 -1
- package/dist/node/signer/encryption.js +5 -1
- package/dist/node/signer/encryption.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 { $ as shortifyAddress, An as CommentIpfsSchema, Ar as PKCError, At as ChallengeMessageSchema, Ct as untrackUpdatingComment, Dt as pTimeout, E as isIpfsCid, Er as FailedToFetchCommentUpdateFromGatewaysError, Et as TimeoutError, Fn as CommentUpdateForChallengeVerificationSchema, Fr as setErrorMap, H as rejectWhenCommunityStopsOrAborts, J as replaceXWithY, Jr as stringifyPrimitive, Kr as joinValues, Kt as version_default, Mr as logger_default, Mt as ChallengeRequestMessageSchema, O as isIpns, Ot as ChallengeAnswerMessageSchema, Pt as ChallengeVerificationMessageSchema, Rn as CommentUpdateSchema, S as hideClassPrivateProps, T as isAbortError, Tr as FailedToFetchCommentIpfsFromGatewaysError, Tt as require_sha256, V as rejectWhenAbortSignalFires, Y as resolveWhenPredicateIsTrue, Z as retryKuboIpfsAdd, _r as r, at as waitForUpdateInCommunityInstanceWithErrorAndTimeout, b as getPostUpdateTimestampRange, bt as trackUpdatingComment, dn as CommunityIpfsSchema, dr as n$1, dt as findUpdatingComment, et as shortifyCid, f as doesDomainAddressHaveCapitalLetter, ft as findUpdatingCommunity, gt as refreshTrackedCommentAliases, hr as e$1, ht as listUpdatingCommunities, it as timestamp, jr as messages, l as createAbortError, lr as n$2, mr as e, mt as listUpdatingComments, on as CommunityAnchorSchema, pr as t$1, pt as listStartedCommunities, q as removeUndefinedValuesRecursively, qr as parsedType, rt as throwIfAbortSignalAborted, t as areEquivalentCommunityAddresses, tt as sleepUntilTimeoutOrAbort, u as deepMergeRuntimeFields, ut as findStartedCommunity, w as ipnsNameToIpnsOverPubsubTopic, wr as require_retry, wt as untrackUpdatingCommunity, xn as isStringDomain, yn as PubsubTopicSchema } from "./util-
|
|
3
|
-
import { $ as parseCidStringSchemaWithPKCErrorIfItFails, $t as require_lib$1, A as findCommentInParsedPages, B as InflightFetchManager, Bn as buildRuntimeCommunityFields, Bt as RpcExportCommunityModLogsParamSchema, C as RepliesPages,
|
|
4
|
-
import { s as getHeliaDebugContext } from "./util-
|
|
2
|
+
import { $ as shortifyAddress, An as CommentIpfsSchema, Ar as PKCError, At as ChallengeMessageSchema, Ct as untrackUpdatingComment, Dt as pTimeout, E as isIpfsCid, Er as FailedToFetchCommentUpdateFromGatewaysError, Et as TimeoutError, Fn as CommentUpdateForChallengeVerificationSchema, Fr as setErrorMap, H as rejectWhenCommunityStopsOrAborts, J as replaceXWithY, Jr as stringifyPrimitive, Kr as joinValues, Kt as version_default, Mr as logger_default, Mt as ChallengeRequestMessageSchema, O as isIpns, Ot as ChallengeAnswerMessageSchema, Pt as ChallengeVerificationMessageSchema, Rn as CommentUpdateSchema, S as hideClassPrivateProps, T as isAbortError, Tr as FailedToFetchCommentIpfsFromGatewaysError, Tt as require_sha256, V as rejectWhenAbortSignalFires, Y as resolveWhenPredicateIsTrue, Z as retryKuboIpfsAdd, _r as r, at as waitForUpdateInCommunityInstanceWithErrorAndTimeout, b as getPostUpdateTimestampRange, bt as trackUpdatingComment, dn as CommunityIpfsSchema, dr as n$1, dt as findUpdatingComment, et as shortifyCid, f as doesDomainAddressHaveCapitalLetter, ft as findUpdatingCommunity, gt as refreshTrackedCommentAliases, hr as e$1, ht as listUpdatingCommunities, it as timestamp, jr as messages, l as createAbortError, lr as n$2, mr as e, mt as listUpdatingComments, on as CommunityAnchorSchema, pr as t$1, pt as listStartedCommunities, q as removeUndefinedValuesRecursively, qr as parsedType, rt as throwIfAbortSignalAborted, t as areEquivalentCommunityAddresses, tt as sleepUntilTimeoutOrAbort, u as deepMergeRuntimeFields, ut as findStartedCommunity, w as ipnsNameToIpnsOverPubsubTopic, wr as require_retry, wt as untrackUpdatingCommunity, xn as isStringDomain, yn as PubsubTopicSchema } from "./util-ok4F-vdA.js";
|
|
3
|
+
import { $ as parseCidStringSchemaWithPKCErrorIfItFails, $t as require_lib$1, A as findCommentInParsedPages, Ar as NAME_RESOLVE_FAILED_RETRY_FLOOR_MS, B as InflightFetchManager, Bn as buildRuntimeCommunityFields, Bt as RpcExportCommunityModLogsParamSchema, C as RepliesPages, Ct as parseDecryptedChallengeVerification, D as extractCommunityRuntimeFieldsFromParsedPages, Dn as verifyCommentModeration, Dr as MAX_FILE_SIZE_BYTES_FOR_COMMENT_UPDATE, Dt as parseRpcCommentEventWithPKCErrorIfItFails, En as verifyCommentIpfs, Et as parsePKCUserOptionsSchemaWithPKCErrorIfItFails, F as collectCrosspostAuthorsToResolve, Fn as getAuthorNameFromRuntime, Ft as RpcCidParamSchema, G as decodeRpcChallengeAnswerPubsubMsg, Gn as decode, Gt as RpcFetchCidResultSchema, Hn as getCommunityNameFromWire, Ht as RpcExportCommunityParamSchema, It as RpcCommentRepliesPageParamSchema, J as decodeRpcChallengeVerificationPubsubMsg, Jt as RpcPublishedAnchorRecordResultSchema, K as decodeRpcChallengePubsubMsg, Kt as RpcPublishAnchorRecordParamSchema, L as stripNameResolvedFromCrosspost, Ln as normalizeCreatePublicationAuthor, Lt as RpcCommunityIdentifierParamSchema, M as parseRawPages, Mn as verifyVote, Mt as RpcAnchorPublishPreparationResultSchema, N as applyNameResolvedCacheToCrosspost, Nn as buildRuntimeAuthor, Nr as nativeFunctions$2, Nt as RpcAuthorNameParamSchema, O as findCommentInPageInstance, On as verifyCommentPubsubMessage, Or as NAME_RESOLVED_FALSE_TTL_MS, Ot as parseRpcCommentUpdateEventWithPKCErrorIfItFails, P as cloneCrosspostForRuntime, Pn as cleanWireAuthor, Pr as require_undici, Pt as RpcCancelExportParamSchema, Qt as RpcUnsubscribeParamSchema, R as PKCClientsManager, Rt as RpcCommunityPageParamSchema, S as KeyvBetterSqlite3, Sn as verifyChallengeMessage, Sr as n$3, St as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, Tn as verifyCommentEdit, Tr as t$4, Tt as parseJsonWithPKCErrorIfFails, Un as getCommunityPublicKeyFromWire, Ut as RpcExportCommunityResultSchema, V as InflightResourceTypes, Vn as getCommunityAddressFromRecord, Vt as RpcExportCommunityModLogsResultSchema, W as PKCTypedEmitter, Wn as normalizeCommunityInputFromCommunity, Wt as RpcFetchCidParamSchema, Xn as getPKCAddressFromPublicKeySync, Xt as RpcSubscriptionIdResultSchema, Yt as RpcResolveAuthorNameResultSchema, Zt as RpcSuccessResultSchema, _r as tryToDeleteCommunitiesThatFailedToBeDeletedBefore, an as encryptEd25519AesGcm, at as parseCommentModerationPubsubMessagePublicationSchemaWithPKCErrorIfItFails, b as RemoteCommunity, bn as signVote, bt as parseCreateRpcCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, cn as cleanUpBeforePublishing, cr as getDefaultDataPath, ct as parseCommunityAddressWithPKCErrorIfItFails, dn as signChallengeRequest, dr as listCommunitiesSync, dt as parseCommunityEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, fr as monitorCommunitiesDirectory, gr as setNativeFunctions$1, gt as parseCreateCommunityEditPublicationOptionsSchemaWithPKCErrorIfItFails, hn as signCommentModeration, ht as parseCreateCommentOptionsSchemaWithPKCErrorIfItFails, jn as verifyCommunityEdit, jt as parseVotePubsubMessagePublicationSchemaWithPKCErrorIfItFails, k as findCommentInPageInstanceRecursively, kn as verifyCommentUpdate, kr as NAME_RESOLVED_TRUE_TTL_MS, kt as parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, l as pkcJsPageSorts, ln as signChallengeAnswer, m as pkcJsChallenges, mn as signCommentEdit, mt as parseCreateCommentModerationOptionsSchemaWithPKCErrorIfItFails, n as RpcRemoteCommunity, nn as createAnchorIpnsRecord$1, nr as createKuboRpcClient, nt as parseCommentEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, ot as parseCommentPubsubMessagePublicationWithPKCErrorIfItFails, pn as signComment, pt as parseCreateCommentEditOptionsSchemaWithPKCErrorIfItFails, q as decodeRpcChallengeRequestPubsubMsg, qn as getBufferedPKCAddressFromPublicKey, qt as RpcPublishChallengeAnswersParamSchema, rn as decryptEd25519AesGcm, rt as parseCommentIpfsSchemaWithPKCErrorIfItFails, st as parseCommentUpdateSchemaWithPKCErrorIfItFails, t as RpcLocalCommunity, tn as createSigner, v as TrackedInstanceRegistry, vr as t$5, wn as verifyChallengeVerification, wr as t$2, wt as parseDecryptedChallengeWithPKCErrorIfItFails, xr as t$3, xt as parseCreateVoteOptionsSchemaWithPKCErrorIfItFails, y as LRUCache, yn as signCommunityEdit, yt as parseCreateRemoteCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, z as GenericStateClient, zt as RpcEditCommunityParamSchema } from "./rpc-local-community-WmgDVdST.js";
|
|
4
|
+
import { s as getHeliaDebugContext } from "./util-BzXGIQ9v.js";
|
|
5
5
|
import path from "path";
|
|
6
6
|
import assert from "assert";
|
|
7
7
|
import fs from "fs";
|
|
@@ -376,6 +376,7 @@ var Publication = class extends import_lib.TypedEmitter {
|
|
|
376
376
|
super();
|
|
377
377
|
this.raw = {};
|
|
378
378
|
this._community = void 0;
|
|
379
|
+
this._signedWithKnownCommunityFields = void 0;
|
|
379
380
|
this._challengeExchanges = {};
|
|
380
381
|
this._rpcPublishSubscriptionId = void 0;
|
|
381
382
|
this._pkc = pkc;
|
|
@@ -461,10 +462,19 @@ var Publication = class extends import_lib.TypedEmitter {
|
|
|
461
462
|
}
|
|
462
463
|
async _signPublicationWithKnownCommunityFieldsIfAvailable() {
|
|
463
464
|
if (!this.communityPublicKey || this.raw.pubsubMessageToPublish || !this.raw.unsignedPublicationOptions) return;
|
|
465
|
+
const unsignedOptions = this.raw.unsignedPublicationOptions;
|
|
464
466
|
await this._signPublication({ communityFields: {
|
|
465
467
|
communityPublicKey: this.communityPublicKey,
|
|
466
468
|
...this.communityName ? { communityName: this.communityName } : {}
|
|
467
469
|
} });
|
|
470
|
+
if (this.raw.pubsubMessageToPublish) this._signedWithKnownCommunityFields = {
|
|
471
|
+
message: this.raw.pubsubMessageToPublish,
|
|
472
|
+
unsignedOptions
|
|
473
|
+
};
|
|
474
|
+
}
|
|
475
|
+
_isSignedWithoutTheLoadedCommunityName() {
|
|
476
|
+
const signed = this._signedWithKnownCommunityFields;
|
|
477
|
+
return Boolean(signed && this.raw.pubsubMessageToPublish === signed.message && this._community?.name && !getCommunityNameFromWire(signed.message));
|
|
468
478
|
}
|
|
469
479
|
async _validateSignatureHook() {}
|
|
470
480
|
async _verifyDecryptedChallengeVerificationAndUpdateCommentProps(decryptedVerification) {
|
|
@@ -1280,6 +1290,12 @@ var Publication = class extends import_lib.TypedEmitter {
|
|
|
1280
1290
|
this._setStateWithEmission("publishing");
|
|
1281
1291
|
await this._initCommunity();
|
|
1282
1292
|
if (this.raw.unsignedPublicationOptions && !this.raw.pubsubMessageToPublish) await this._signPublicationWithCommunityFields();
|
|
1293
|
+
else if (this._isSignedWithoutTheLoadedCommunityName()) {
|
|
1294
|
+
log(`Re-signing the ${this.getType()} with the name of community ${this._community.name}; it was created with only the community's key`);
|
|
1295
|
+
this.raw.unsignedPublicationOptions = this._signedWithKnownCommunityFields.unsignedOptions;
|
|
1296
|
+
this._signedWithKnownCommunityFields = void 0;
|
|
1297
|
+
await this._signPublicationWithCommunityFields();
|
|
1298
|
+
}
|
|
1283
1299
|
await this._validateSignatureHook();
|
|
1284
1300
|
if (this._pkc._pkcRpcClient) return this._publishWithRpc();
|
|
1285
1301
|
const options = { acceptedChallengeTypes: [] };
|
|
@@ -8370,7 +8386,7 @@ var PKC$1 = class extends PKCTypedEmitter {
|
|
|
8370
8386
|
this.clients.libp2pJsClients = {};
|
|
8371
8387
|
if (!this.libp2pJsClientsOptions) return;
|
|
8372
8388
|
if (!this.httpRoutersOptions) throw Error("httpRoutersOptions is required for libp2pJsClient");
|
|
8373
|
-
const { createLibp2pJsClientOrUseExistingOne } = await import("./helia-for-pkc-
|
|
8389
|
+
const { createLibp2pJsClientOrUseExistingOne } = await import("./helia-for-pkc-Bw9KzcSY.js");
|
|
8374
8390
|
for (const clientOptions of this.libp2pJsClientsOptions) {
|
|
8375
8391
|
const heliaNode = await createLibp2pJsClientOrUseExistingOne({
|
|
8376
8392
|
...clientOptions,
|
|
@@ -8649,7 +8665,7 @@ var PKC$1 = class extends PKCTypedEmitter {
|
|
|
8649
8665
|
const log = logger_default("pkc-js:pkc:createLocalCommunity");
|
|
8650
8666
|
log.trace("Received community options to create a local community instance:", options);
|
|
8651
8667
|
if (!this._canCreateNewLocalCommunity()) throw new PKCError("ERR_CAN_NOT_CREATE_A_LOCAL_COMMUNITY", { pkcOptions: this._userPKCOptions });
|
|
8652
|
-
const { LocalCommunity, createNewLocalCommunityDb, updateInstancePropsWithStartedCommunityOrDb } = await import("./local-community-
|
|
8668
|
+
const { LocalCommunity, createNewLocalCommunityDb, updateInstancePropsWithStartedCommunityOrDb } = await import("./local-community-feziLP2d.js");
|
|
8653
8669
|
const isLocalCommunity = (await listCommunitiesSync(this)).includes(options.address);
|
|
8654
8670
|
const community = new LocalCommunity(this);
|
|
8655
8671
|
if (isLocalCommunity) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as getEquivalentCommunityAddresses, vn as PageSortFileSchema } from "./util-
|
|
1
|
+
import { _ as getEquivalentCommunityAddresses, vn as PageSortFileSchema, xn as isStringDomain } from "./util-ok4F-vdA.js";
|
|
2
2
|
//#region dist/node/pages/page-sort-scoring.js
|
|
3
3
|
function validatePageSortFile(rawFile) {
|
|
4
4
|
const validated = PageSortFileSchema.parse(rawFile);
|
|
@@ -9,16 +9,21 @@ function validatePageSortFile(rawFile) {
|
|
|
9
9
|
...raw.validatePageSortSettings ? { validatePageSortSettings: raw.validatePageSortSettings } : {}
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
|
+
function createCommunityIdentityRowFilter(communityAddress) {
|
|
13
|
+
if (isStringDomain(communityAddress)) {
|
|
14
|
+
const equivalentNames = new Set(getEquivalentCommunityAddresses(communityAddress));
|
|
15
|
+
return (comment) => !comment.communityName || equivalentNames.has(comment.communityName);
|
|
16
|
+
}
|
|
17
|
+
return (comment) => !comment.communityPublicKey || comment.communityPublicKey === communityAddress;
|
|
18
|
+
}
|
|
12
19
|
function applyPageSortExclusions({ comments, exclusions, communityAddress }) {
|
|
13
|
-
const
|
|
20
|
+
const belongsToCommunity = createCommunityIdentityRowFilter(communityAddress);
|
|
14
21
|
return comments.filter(({ comment, commentUpdate }) => {
|
|
22
|
+
if (!belongsToCommunity(comment)) return false;
|
|
15
23
|
if (exclusions.excludeRemovedComments && commentUpdate.removed === true) return false;
|
|
16
24
|
if (exclusions.excludeDeletedComments && commentUpdate.edit?.deleted === true) return false;
|
|
17
25
|
if (exclusions.excludeCommentWithApprovedFalse && commentUpdate.approved === false) return false;
|
|
18
26
|
if (exclusions.excludeCommentPendingApproval && commentUpdate.pendingApproval === true) return false;
|
|
19
|
-
if (exclusions.excludeCommentsWithDifferentCommunityAddress && equivalentAddresses) {
|
|
20
|
-
if (!((comment.communityPublicKey ? equivalentAddresses.has(comment.communityPublicKey) : false) || (comment.communityName ? equivalentAddresses.has(comment.communityName) : false))) return false;
|
|
21
|
-
}
|
|
22
27
|
return true;
|
|
23
28
|
});
|
|
24
29
|
}
|
|
@@ -29,8 +34,7 @@ function filterRepliesForPageSort({ replies, communityAddress }) {
|
|
|
29
34
|
excludeRemovedComments: false,
|
|
30
35
|
excludeDeletedComments: false,
|
|
31
36
|
excludeCommentWithApprovedFalse: false,
|
|
32
|
-
excludeCommentPendingApproval: false
|
|
33
|
-
excludeCommentsWithDifferentCommunityAddress: true
|
|
37
|
+
excludeCommentPendingApproval: false
|
|
34
38
|
},
|
|
35
39
|
communityAddress
|
|
36
40
|
});
|
package/dist/bundled/chunks/{rpc-local-community-_ooAoNPM.js → rpc-local-community-WmgDVdST.js}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { i as __toESM, n as __exportAll, r as __require, t as __commonJSMin } from "./chunk-2rV9d50f.js";
|
|
2
|
-
import { $ as shortifyAddress, $n as CreateCommentEditOptionsWithRefinementSchema, $t as CommentModerationPubsubMessagePublicationSchema, An as CommentIpfsSchema, Ar as PKCError, B as raceAgainstAbort, Br as literal, Bt as DecryptedChallengeVerificationSchema, C as interruptibleSleep, Cn as VoteChallengeRequestToEncryptSchema, Cr as e$4, D as isIpfsPath, Dr as FailedToFetchCommunityFromGatewaysError, Dt as pTimeout, E as isIpfsCid, En as VoteSignedPropertyNames, Er as FailedToFetchCommentUpdateFromGatewaysError, Ft as ChallengeVerificationMessageSignedPropertyNames, G as removeNullUndefinedEmptyObjectsValuesRecursively, Gn as PageIpfsSchema, Gt as PKCUserOptionsSchema, Hn as CreateCommentOptionsWithRefinementSchema, Hr as object, Ht as NameResolverSerializedSchema, I as isRequestPubsubPublicationOfPost, In as CommentUpdateForChallengeVerificationSignedPropertyNames, Ir as _enum, It as DecryptedChallengeAnswerSchema, Kn as isReservedObjectKey, L as isRequestPubsubPublicationOfReply, Ln as CommentUpdateReservedFields, Lr as array, Mn as CommentPubsubMessageWithFlexibleAuthorRefinementSchema, Mr as logger_default, Nn as CommentSignedPropertyNames, Nr as require_supports_color, Nt as ChallengeRequestMessageSignedPropertyNames, O as isIpns, On as CommentChallengeRequestToEncryptSchema, Or as FailedToFetchGenericIpfsFromGatewaysError, Pn as CommentUpdateChallengeReservedFieldNames, Pr as require_ms$1, Qt as CommentModerationChallengeRequestToEncryptSchema, R as pubsubTopicToDhtKey, Rn as CommentUpdateSchema, Rr as boolean, S as hideClassPrivateProps, Sn as CreateVoteUserOptionsWithRefinementSchema, Sr as t$9, St as untrackStartedCommunity, T as isAbortError, Tr as FailedToFetchCommentIpfsFromGatewaysError, Tt as require_sha256$1, Un as GetPageParamSchema, Ur as record, Ut as PKCParsedOptionsSchema, Vr as number, Vt as NameResolveCacheOptionsSchema, Wn as ModQueuePageIpfsSchema, Wr as string, Wt as PKCUserOptionBaseSchema, Xt as CommunityEditPubsubMessagePublicationSchema, Yn as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema, Yt as CommunityEditPublicationSignedPropertyNames, Zn as CommentEditSignedPropertyNames, Zt as CreateCommunityEditPublicationOptionsWithRefinementSchema, _n as PageSortFileFactorySchema, _r as r$8, _t as refreshTrackedCommunityAliases, an as ChallengeFileSchema, ar as CidStringSchema, bn as RpcRemoteCommunityUpdateEventResultSchema, br as r$7, cn as CommunityEditOptionsSchema, cr as CreateSignerSchema, d as derivePublicationFromChallengeRequest, dn as CommunityIpfsSchema, dr as n$10, er as AuthorAddressSchema, et as shortifyCid, f as doesDomainAddressHaveCapitalLetter, fn as CommunitySignedPropertyNames, ft as findUpdatingCommunity, gn as ExportCommunityModLogsOptionsSchema, gr as t$11, hn as CreateRpcCommunityFunctionArgumentSchema, hr as e$5, in as ChallengeFileFactorySchema, ir as CidPathSchema, it as timestamp, jr as messages, jt as ChallengeMessageSignedPropertyNames, k as isIpnsPath, kn as CommentIpfsReservedFields, kr as FailedToFetchPageIpfsFromGatewaysError, kt as ChallengeAnswerMessageSignedPropertyNames, l as createAbortError, ln as CommunityExportRecordsSchema, lr as n$9, m as fetchAndValidateIpnsRecordFromGateway, mn as CreateRemoteCommunityFunctionArgumentSchema, mr as e$6, nn as CommentModerationsTableRowSchema, or as CommunityAddressSchema, p as extractNetworkErrorDetails, pn as CreateNewLocalCommunityUserOptionsSchema, pr as t$13, qn as CommentEditChallengeRequestToEncryptSchema, qt as CommunityEditPublicationChallengeRequestToEncryptSchema, r as calculateIpfsCidV0, rn as CreateCommentModerationOptionsWithRefinementSchema, rr as ChallengeAnswersSchema, rt as throwIfAbortSignalAborted, sn as CommunityChallengeSettingSchema, sr as CommunityAuthorChallengeReservedFieldNames, t as areEquivalentCommunityAddresses, tn as CommentModerationSignedPropertyNames, tr as AuthorCommentIpfsReservedFields, tt as sleepUntilTimeoutOrAbort, u as deepMergeRuntimeFields, un as CommunityIpfsReservedFields, ut as findStartedCommunity, vn as PageSortFileSchema, vr as t$12, w as ipnsNameToIpnsOverPubsubTopic, wn as VotePubsubMessagePublicationSchema, wr as require_retry$1, wt as untrackUpdatingCommunity, x as hasTransientNetworkErrorCode, xn as isStringDomain, xr as t$10, xt as trackUpdatingCommunity, yr as n$8, yt as trackStartedCommunity, zn as CommentUpdateSignedPropertyNames, zr as custom, zt as DecryptedChallengeSchema } from "./util-
|
|
2
|
+
import { $ as shortifyAddress, $n as CreateCommentEditOptionsWithRefinementSchema, $t as CommentModerationPubsubMessagePublicationSchema, An as CommentIpfsSchema, Ar as PKCError, B as raceAgainstAbort, Br as literal, Bt as DecryptedChallengeVerificationSchema, C as interruptibleSleep, Cn as VoteChallengeRequestToEncryptSchema, Cr as e$4, D as isIpfsPath, Dr as FailedToFetchCommunityFromGatewaysError, Dt as pTimeout, E as isIpfsCid, En as VoteSignedPropertyNames, Er as FailedToFetchCommentUpdateFromGatewaysError, Ft as ChallengeVerificationMessageSignedPropertyNames, G as removeNullUndefinedEmptyObjectsValuesRecursively, Gn as PageIpfsSchema, Gt as PKCUserOptionsSchema, Hn as CreateCommentOptionsWithRefinementSchema, Hr as object, Ht as NameResolverSerializedSchema, I as isRequestPubsubPublicationOfPost, In as CommentUpdateForChallengeVerificationSignedPropertyNames, Ir as _enum, It as DecryptedChallengeAnswerSchema, Kn as isReservedObjectKey, L as isRequestPubsubPublicationOfReply, Ln as CommentUpdateReservedFields, Lr as array, Mn as CommentPubsubMessageWithFlexibleAuthorRefinementSchema, Mr as logger_default, Nn as CommentSignedPropertyNames, Nr as require_supports_color, Nt as ChallengeRequestMessageSignedPropertyNames, O as isIpns, On as CommentChallengeRequestToEncryptSchema, Or as FailedToFetchGenericIpfsFromGatewaysError, Pn as CommentUpdateChallengeReservedFieldNames, Pr as require_ms$1, Qt as CommentModerationChallengeRequestToEncryptSchema, R as pubsubTopicToDhtKey, Rn as CommentUpdateSchema, Rr as boolean, S as hideClassPrivateProps, Sn as CreateVoteUserOptionsWithRefinementSchema, Sr as t$9, St as untrackStartedCommunity, T as isAbortError, Tr as FailedToFetchCommentIpfsFromGatewaysError, Tt as require_sha256$1, Un as GetPageParamSchema, Ur as record, Ut as PKCParsedOptionsSchema, Vr as number, Vt as NameResolveCacheOptionsSchema, Wn as ModQueuePageIpfsSchema, Wr as string, Wt as PKCUserOptionBaseSchema, Xt as CommunityEditPubsubMessagePublicationSchema, Yn as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema, Yt as CommunityEditPublicationSignedPropertyNames, Zn as CommentEditSignedPropertyNames, Zt as CreateCommunityEditPublicationOptionsWithRefinementSchema, _n as PageSortFileFactorySchema, _r as r$8, _t as refreshTrackedCommunityAliases, an as ChallengeFileSchema, ar as CidStringSchema, bn as RpcRemoteCommunityUpdateEventResultSchema, br as r$7, cn as CommunityEditOptionsSchema, cr as CreateSignerSchema, d as derivePublicationFromChallengeRequest, dn as CommunityIpfsSchema, dr as n$10, er as AuthorAddressSchema, et as shortifyCid, f as doesDomainAddressHaveCapitalLetter, fn as CommunitySignedPropertyNames, ft as findUpdatingCommunity, gn as ExportCommunityModLogsOptionsSchema, gr as t$11, hn as CreateRpcCommunityFunctionArgumentSchema, hr as e$5, in as ChallengeFileFactorySchema, ir as CidPathSchema, it as timestamp, jr as messages, jt as ChallengeMessageSignedPropertyNames, k as isIpnsPath, kn as CommentIpfsReservedFields, kr as FailedToFetchPageIpfsFromGatewaysError, kt as ChallengeAnswerMessageSignedPropertyNames, l as createAbortError, ln as CommunityExportRecordsSchema, lr as n$9, m as fetchAndValidateIpnsRecordFromGateway, mn as CreateRemoteCommunityFunctionArgumentSchema, mr as e$6, nn as CommentModerationsTableRowSchema, or as CommunityAddressSchema, p as extractNetworkErrorDetails, pn as CreateNewLocalCommunityUserOptionsSchema, pr as t$13, qn as CommentEditChallengeRequestToEncryptSchema, qt as CommunityEditPublicationChallengeRequestToEncryptSchema, r as calculateIpfsCidV0, rn as CreateCommentModerationOptionsWithRefinementSchema, rr as ChallengeAnswersSchema, rt as throwIfAbortSignalAborted, sn as CommunityChallengeSettingSchema, sr as CommunityAuthorChallengeReservedFieldNames, t as areEquivalentCommunityAddresses, tn as CommentModerationSignedPropertyNames, tr as AuthorCommentIpfsReservedFields, tt as sleepUntilTimeoutOrAbort, u as deepMergeRuntimeFields, un as CommunityIpfsReservedFields, ut as findStartedCommunity, vn as PageSortFileSchema, vr as t$12, w as ipnsNameToIpnsOverPubsubTopic, wn as VotePubsubMessagePublicationSchema, wr as require_retry$1, wt as untrackUpdatingCommunity, x as hasTransientNetworkErrorCode, xn as isStringDomain, xr as t$10, xt as trackUpdatingCommunity, yr as n$8, yt as trackStartedCommunity, zn as CommentUpdateSignedPropertyNames, zr as custom, zt as DecryptedChallengeSchema } from "./util-ok4F-vdA.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-DEib5648.js";
|
|
5
5
|
import { createHash } from "node:crypto";
|
|
6
6
|
import { pathToFileURL } from "node:url";
|
|
7
7
|
import dns from "node:dns";
|
|
@@ -92178,22 +92178,38 @@ const setNativeFunctions = (newNativeFunctions) => {
|
|
|
92178
92178
|
if (!newNativeFunctions) throw Error(`User passed an undefined object to setNativeFunctions`);
|
|
92179
92179
|
for (const i in newNativeFunctions) nativeFunctions[i] = newNativeFunctions[i];
|
|
92180
92180
|
};
|
|
92181
|
-
const
|
|
92181
|
+
const WINDOWS_FILE_BUSY_ERROR_CODES = ["EBUSY", "EPERM"];
|
|
92182
|
+
const deleteOldCommunityInWindows = async (subPath, pkc, { timeoutMs = 1e4 } = {}) => {
|
|
92182
92183
|
const log = logger_default("pkc-js:community:deleteStaleCommunityInWindows");
|
|
92183
92184
|
const communityAddress = path.basename(subPath);
|
|
92184
|
-
|
|
92185
|
-
try {
|
|
92185
|
+
const deadline = Date.now() + timeoutMs;
|
|
92186
|
+
for (let retryDelayMs = 50;; retryDelayMs = Math.min(retryDelayMs * 2, 1e3)) try {
|
|
92186
92187
|
await promises.rm(subPath, { force: true });
|
|
92187
92188
|
log(`Succeeded in deleting old community (${communityAddress})`);
|
|
92189
|
+
return;
|
|
92188
92190
|
} catch (e) {
|
|
92189
|
-
|
|
92190
|
-
|
|
92191
|
-
|
|
92192
|
-
|
|
92193
|
-
|
|
92194
|
-
|
|
92191
|
+
const code = e.code;
|
|
92192
|
+
if (!code || !WINDOWS_FILE_BUSY_ERROR_CODES.includes(code) || Date.now() + retryDelayMs >= deadline) {
|
|
92193
|
+
await recordCommunityThatFailedToBeDeleted({
|
|
92194
|
+
communityAddress,
|
|
92195
|
+
pkc,
|
|
92196
|
+
error: e,
|
|
92197
|
+
log
|
|
92198
|
+
});
|
|
92199
|
+
return;
|
|
92200
|
+
}
|
|
92201
|
+
log(`Old community (${communityAddress}) is still busy (${code}), retrying in ${retryDelayMs}ms`);
|
|
92202
|
+
await new Promise((resolve) => setTimeout(resolve, retryDelayMs));
|
|
92195
92203
|
}
|
|
92196
92204
|
};
|
|
92205
|
+
async function recordCommunityThatFailedToBeDeleted({ communityAddress, pkc, error, log }) {
|
|
92206
|
+
log.error(`Failed to delete old community (${communityAddress}). Restarting the node process or daemon should make this error disappear`, error);
|
|
92207
|
+
const storageKey = STORAGE_KEYS[STORAGE_KEYS.PERSISTENT_DELETED_COMMUNITIES];
|
|
92208
|
+
const communitiesThatWeFailedToDelete = await pkc._storage.getItem(storageKey) || [];
|
|
92209
|
+
if (!communitiesThatWeFailedToDelete.includes(communityAddress)) communitiesThatWeFailedToDelete.push(communityAddress);
|
|
92210
|
+
await pkc._storage.setItem(storageKey, communitiesThatWeFailedToDelete);
|
|
92211
|
+
log(`Updated persistent deleted communities in storage`, communitiesThatWeFailedToDelete);
|
|
92212
|
+
}
|
|
92197
92213
|
async function tryToDeleteCommunitiesThatFailedToBeDeletedBefore(pkc, log) {
|
|
92198
92214
|
const deletedPersistentCommunities = await pkc._storage.getItem(STORAGE_KEYS[STORAGE_KEYS.PERSISTENT_DELETED_COMMUNITIES]);
|
|
92199
92215
|
if (Array.isArray(deletedPersistentCommunities)) {
|
|
@@ -92225,6 +92241,10 @@ async function tryToDeleteCommunitiesThatFailedToBeDeletedBefore(pkc, log) {
|
|
|
92225
92241
|
}
|
|
92226
92242
|
}
|
|
92227
92243
|
}
|
|
92244
|
+
function refreshCommunitiesList(pkc) {
|
|
92245
|
+
const currentCommunities = listCommunitiesSync(pkc);
|
|
92246
|
+
if (stringify(currentCommunities) !== stringify(pkc.communities)) pkc.emit("communitieschange", currentCommunities);
|
|
92247
|
+
}
|
|
92228
92248
|
function listCommunitiesSync(pkc) {
|
|
92229
92249
|
const log = logger_default("pkc-js:listCommunitiesSync");
|
|
92230
92250
|
if (typeof pkc.dataPath !== "string") throw Error("pkc.dataPath needs to be defined to listCommunities");
|
|
@@ -92449,8 +92469,7 @@ async function monitorCommunitiesDirectory(pkc) {
|
|
|
92449
92469
|
"-wal"
|
|
92450
92470
|
];
|
|
92451
92471
|
let isProcessingChange = false;
|
|
92452
|
-
|
|
92453
|
-
if (stringify(initialCommunities) !== stringify(pkc.communities)) pkc.emit("communitieschange", initialCommunities);
|
|
92472
|
+
refreshCommunitiesList(pkc);
|
|
92454
92473
|
watch(communitiesPath, {
|
|
92455
92474
|
signal: watchAbortController.signal,
|
|
92456
92475
|
persistent: false
|
|
@@ -92459,8 +92478,7 @@ async function monitorCommunitiesDirectory(pkc) {
|
|
|
92459
92478
|
if (isProcessingChange) return;
|
|
92460
92479
|
isProcessingChange = true;
|
|
92461
92480
|
try {
|
|
92462
|
-
|
|
92463
|
-
if (stringify(currentCommunities) !== stringify(pkc.communities)) pkc.emit("communitieschange", currentCommunities);
|
|
92481
|
+
refreshCommunitiesList(pkc);
|
|
92464
92482
|
} catch (error) {} finally {
|
|
92465
92483
|
isProcessingChange = false;
|
|
92466
92484
|
}
|
|
@@ -120836,7 +120854,7 @@ const decryptStringAesGcm = async (ciphertext, key, iv, tag) => {
|
|
|
120836
120854
|
tag: tagAsForgeBuffer
|
|
120837
120855
|
});
|
|
120838
120856
|
cipher.update(uint8ArrayToNodeForgeBuffer(ciphertext));
|
|
120839
|
-
cipher.finish();
|
|
120857
|
+
if (!cipher.finish()) throw Error("decryptStringAesGcm failed to decrypt, the AES-GCM authentication tag does not match the ciphertext, key and iv");
|
|
120840
120858
|
return cipher.output.toString();
|
|
120841
120859
|
};
|
|
120842
120860
|
const encryptEd25519AesGcm = async (plaintext, privateKeyBase64, publicKeyBase64) => {
|
|
@@ -124842,13 +124860,15 @@ var CommunityClientsManager = class extends PKCClientsManager {
|
|
|
124842
124860
|
if (subRes?.community) {
|
|
124843
124861
|
const identityPublicKey = subRes.community.anchor?.publicKey ?? ipnsName;
|
|
124844
124862
|
const anchorIdentityAddress = subRes.community.name || identityPublicKey;
|
|
124845
|
-
|
|
124863
|
+
const communityForPublishing = {
|
|
124846
124864
|
encryption: subRes.community.encryption,
|
|
124847
124865
|
pubsubTopic: subRes.community.pubsubTopic,
|
|
124848
124866
|
address: anchorIdentityAddress,
|
|
124849
124867
|
publicKey: identityPublicKey,
|
|
124850
124868
|
name: subRes.community.name
|
|
124851
|
-
}
|
|
124869
|
+
};
|
|
124870
|
+
this._pkc._memCaches.communityForPublishing.set(anchorIdentityAddress, communityForPublishing);
|
|
124871
|
+
if (anchorIdentityAddress !== identityPublicKey) this._pkc._memCaches.communityForPublishing.set(identityPublicKey, communityForPublishing);
|
|
124852
124872
|
}
|
|
124853
124873
|
return subRes;
|
|
124854
124874
|
});
|
|
@@ -128923,9 +128943,9 @@ const PAGE_SORT_EXCLUSION_OPTION_NAMES = Object.freeze([
|
|
|
128923
128943
|
"excludeRemovedComments",
|
|
128924
128944
|
"excludeDeletedComments",
|
|
128925
128945
|
"excludeCommentPendingApproval",
|
|
128926
|
-
"excludeCommentWithApprovedFalse"
|
|
128927
|
-
"excludeCommentsWithDifferentCommunityAddress"
|
|
128946
|
+
"excludeCommentWithApprovedFalse"
|
|
128928
128947
|
]);
|
|
128948
|
+
const REMOVED_PAGE_SORT_OPTION_NAMES = Object.freeze(["excludeCommentsWithDifferentCommunityAddress"]);
|
|
128929
128949
|
const RESERVED_PAGE_SORT_OPTION_NAMES = Object.freeze([
|
|
128930
128950
|
"maxAge",
|
|
128931
128951
|
"pinnedFirst",
|
|
@@ -128937,16 +128957,14 @@ const DEFAULT_RESERVED_OPTIONS = Object.freeze({
|
|
|
128937
128957
|
excludeRemovedComments: "true",
|
|
128938
128958
|
excludeDeletedComments: "true",
|
|
128939
128959
|
excludeCommentPendingApproval: "true",
|
|
128940
|
-
excludeCommentWithApprovedFalse: "true"
|
|
128941
|
-
excludeCommentsWithDifferentCommunityAddress: "true"
|
|
128960
|
+
excludeCommentWithApprovedFalse: "true"
|
|
128942
128961
|
},
|
|
128943
128962
|
replies: {
|
|
128944
128963
|
pinnedFirst: "true",
|
|
128945
128964
|
excludeRemovedComments: "false",
|
|
128946
128965
|
excludeDeletedComments: "false",
|
|
128947
128966
|
excludeCommentPendingApproval: "true",
|
|
128948
|
-
excludeCommentWithApprovedFalse: "false"
|
|
128949
|
-
excludeCommentsWithDifferentCommunityAddress: "true"
|
|
128967
|
+
excludeCommentWithApprovedFalse: "false"
|
|
128950
128968
|
}
|
|
128951
128969
|
});
|
|
128952
128970
|
function parseBooleanOption(raw) {
|
|
@@ -129243,6 +129261,20 @@ async function loadPageSortFile({ pageSortSettings, pkc }) {
|
|
|
129243
129261
|
}
|
|
129244
129262
|
return file;
|
|
129245
129263
|
}
|
|
129264
|
+
function withoutRemovedPageSortOptions(options, pageSortName) {
|
|
129265
|
+
const removed = Object.keys(options).filter((optionName) => REMOVED_PAGE_SORT_OPTION_NAMES.includes(optionName));
|
|
129266
|
+
if (removed.length === 0) return options;
|
|
129267
|
+
logger_default("pkc-js:local-community:page-sorts:resolve")(`Ignoring removed page sort options ${removed.join(", ")} of sort ${pageSortName}; the community identity rule now always applies (issue #401)`);
|
|
129268
|
+
return Object.fromEntries(Object.entries(options).filter(([optionName]) => !removed.includes(optionName)));
|
|
129269
|
+
}
|
|
129270
|
+
function withoutRemovedPageSortSettingOptions(pageSortSettings) {
|
|
129271
|
+
if (!pageSortSettings.options) return pageSortSettings;
|
|
129272
|
+
const options = withoutRemovedPageSortOptions(pageSortSettings.options, describePageSort(pageSortSettings));
|
|
129273
|
+
return options === pageSortSettings.options ? pageSortSettings : {
|
|
129274
|
+
...pageSortSettings,
|
|
129275
|
+
options
|
|
129276
|
+
};
|
|
129277
|
+
}
|
|
129246
129278
|
function resolveOneEntry({ pageSortSettings, file, scope, pageSortIndex }) {
|
|
129247
129279
|
const baseDetails = {
|
|
129248
129280
|
scope,
|
|
@@ -129277,11 +129309,11 @@ function resolveOneEntry({ pageSortSettings, file, scope, pageSortIndex }) {
|
|
|
129277
129309
|
offendingOption: optionName
|
|
129278
129310
|
}) };
|
|
129279
129311
|
}
|
|
129280
|
-
const options = {
|
|
129312
|
+
const options = withoutRemovedPageSortOptions({
|
|
129281
129313
|
...DEFAULT_RESERVED_OPTIONS[scope],
|
|
129282
129314
|
...file.defaultOptions,
|
|
129283
129315
|
...entryOptions
|
|
129284
|
-
};
|
|
129316
|
+
}, baseDetails.pageSortName);
|
|
129285
129317
|
let reserved;
|
|
129286
129318
|
try {
|
|
129287
129319
|
reserved = parseReservedPageSortOptions(options);
|
|
@@ -129322,7 +129354,8 @@ async function resolvePageSortsAndCollectFailures({ pagesSettings, pkc, tolerate
|
|
|
129322
129354
|
};
|
|
129323
129355
|
for (const { scope, entries } of entriesOfEveryScope(pagesSettings)) {
|
|
129324
129356
|
const seenSortNames = /* @__PURE__ */ new Set();
|
|
129325
|
-
for (const [pageSortIndex,
|
|
129357
|
+
for (const [pageSortIndex, storedPageSortSettings] of entries.entries()) {
|
|
129358
|
+
const pageSortSettings = withoutRemovedPageSortSettingOptions(storedPageSortSettings);
|
|
129326
129359
|
const pageSortName = describePageSort(pageSortSettings);
|
|
129327
129360
|
let file;
|
|
129328
129361
|
try {
|
|
@@ -130092,4 +130125,4 @@ var RpcLocalCommunity = class extends RpcRemoteCommunity {
|
|
|
130092
130125
|
}
|
|
130093
130126
|
};
|
|
130094
130127
|
//#endregion
|
|
130095
|
-
export { parseCidStringSchemaWithPKCErrorIfItFails as $, backupCommunityDb as $n, require_lib as $t, findCommentInParsedPages as A, verifyCommunity as An,
|
|
130128
|
+
export { parseCidStringSchemaWithPKCErrorIfItFails as $, backupCommunityDb as $n, require_lib as $t, findCommentInParsedPages as A, verifyCommunity as An, NAME_RESOLVE_FAILED_RETRY_FLOOR_MS as Ar, parseVoteChallengeRequestToEncryptSchemaWithPKCErrorIfItFails as At, InflightFetchManager as B, buildRuntimeCommunityFields as Bn, RpcExportCommunityModLogsParamSchema as Bt, RepliesPages as C, verifyChallengeRequest as Cn, n$6 as Cr, parseDecryptedChallengeVerification as Ct, extractCommunityRuntimeFieldsFromParsedPages as D, verifyCommentModeration as Dn, MAX_FILE_SIZE_BYTES_FOR_COMMENT_UPDATE as Dr, parseRpcCommentEventWithPKCErrorIfItFails as Dt, buildPagesRuntimeFields as E, verifyCommentIpfs as En, stringify as Er, parsePKCUserOptionsSchemaWithPKCErrorIfItFails as Et, collectCrosspostAuthorsToResolve as F, getAuthorNameFromRuntime as Fn, RpcCidParamSchema as Ft, decodeRpcChallengeAnswerPubsubMsg as G, decode as Gn, RpcFetchCidResultSchema as Gt, pRetry as H, getCommunityNameFromWire$1 as Hn, RpcExportCommunityParamSchema as Ht, extractCrosspostRuntimeFields as I, getAuthorNameFromWire as In, RpcCommentRepliesPageParamSchema as It, decodeRpcChallengeVerificationPubsubMsg as J, getIpfsKeyFromPrivateKey as Jn, RpcPublishedAnchorRecordResultSchema as Jt, decodeRpcChallengePubsubMsg as K, encode as Kn, RpcPublishAnchorRecordParamSchema as Kt, stripNameResolvedFromCrosspost as L, normalizeCreatePublicationAuthor as Ln, RpcCommunityIdentifierParamSchema as Lt, parseRawPages as M, verifyVote as Mn, require_lodash_merge as Mr, RpcAnchorPublishPreparationResultSchema as Mt, applyNameResolvedCacheToCrosspost as N, buildRuntimeAuthor as Nn, nativeFunctions$1 as Nr, RpcAuthorNameParamSchema as Nt, findCommentInPageInstance as O, verifyCommentPubsubMessage as On, NAME_RESOLVED_FALSE_TTL_MS as Or, parseRpcCommentUpdateEventWithPKCErrorIfItFails as Ot, cloneCrosspostForRuntime as P, cleanWireAuthor as Pn, require_undici as Pr, RpcCancelExportParamSchema as Pt, createSchemaRowParser as Q, BackupAbortError as Qn, RpcUnsubscribeParamSchema as Qt, PKCClientsManager as R, crosspostChainDepthUpTo as Rn, RpcCommunityPageParamSchema as Rt, KeyvBetterSqlite3 as S, verifyChallengeMessage as Sn, n$5 as Sr, parseDecryptedChallengeAnswerWithPKCErrorIfItFails as St, buildPageRuntimeFields as T, verifyCommentEdit as Tn, t$8 as Tr, parseJsonWithPKCErrorIfFails as Tt, pLimit as U, getCommunityPublicKeyFromWire as Un, RpcExportCommunityResultSchema as Ut, InflightResourceTypes as V, getCommunityAddressFromRecord as Vn, RpcExportCommunityModLogsResultSchema as Vt, PKCTypedEmitter as W, normalizeCommunityInputFromCommunity as Wn, RpcFetchCidParamSchema as Wt, coerceSchemaRowJson as X, getPKCAddressFromPublicKeySync as Xn, RpcSubscriptionIdResultSchema as Xt, coerceSchemaRowBoolean as Y, getPKCAddressFromPublicKey as Yn, RpcResolveAuthorNameResultSchema as Yt, collectSchemaRowCoercions as Z, getPublicKeyFromPrivateKey as Zn, RpcSuccessResultSchema as Zt, createAuthorIdentityMatcher as _, signCommentUpdateForChallengeVerification as _n, tryToDeleteCommunitiesThatFailedToBeDeletedBefore as _r, parseCreateNewLocalCommunityUserOptionsSchemaWithPKCErrorIfItFails as _t, generatePagesReportingFailedSorts as a, encryptEd25519AesGcm as an, deriveDbPosts as ar, parseCommentModerationPubsubMessagePublicationSchemaWithPKCErrorIfItFails as at, RemoteCommunity as b, signVote as bn, r as br, parseCreateRpcCommunityFunctionArgumentSchemaWithPKCErrorIfItFails as bt, resolvePageSortsOrThrow as c, cleanUpBeforePublishing as cn, getDefaultDataPath as cr, parseCommunityAddressWithPKCErrorIfItFails as ct, getChallengeVerification as d, signChallengeRequest as dn, listCommunitiesSync as dr, parseCommunityEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails as dt, SignerWithPublicKeyAddress as en, calculateExpectedSignatureSize as er, parseCommentChallengeRequestToEncryptSchemaWithPKCErrorIfItFails as et, getCommunityChallengeFromCommunityChallengeSettings as f, signChallengeVerification as fn, monitorCommunitiesDirectory as fr, parseCommunityIpfsSchemaPassthroughWithPKCErrorIfItFails as ft, authorNameResolveFailureReason as g, signCommentUpdate as gn, setNativeFunctions as gr, parseCreateCommunityEditPublicationOptionsSchemaWithPKCErrorIfItFails as gt, authorIdentityMatcherForRequest as h, signCommentModeration as hn, resolveDbPostsCidRefs as hr, parseCreateCommentOptionsSchemaWithPKCErrorIfItFails as ht, derivePublicPageSorts as i, decryptEd25519AesGcmPublicKeyBuffer as in, deriveCommentIpfsFromCommentTableRow as ir, parseCommentModerationChallengeRequestToEncryptSchemaWithPKCErrorIfItFails as it, iterateOverPageCidsToFindAllCids as j, verifyCommunityEdit as jn, STORAGE_KEYS as jr, parseVotePubsubMessagePublicationSchemaWithPKCErrorIfItFails as jt, findCommentInPageInstanceRecursively as k, verifyCommentUpdate as kn, NAME_RESOLVED_TRUE_TTL_MS as kr, parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails as kt, pkcJsPageSorts as l, signChallengeAnswer as ln, getThumbnailPropsOfLink as lr, parseCommunityEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails as lt, pkcJsChallenges as m, signCommentEdit as mn, refreshCommunitiesList as mr, parseCreateCommentModerationOptionsSchemaWithPKCErrorIfItFails as mt, RpcRemoteCommunity as n, createAnchorIpnsRecord as nn, createKuboRpcClient as nr, parseCommentEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails as nt, loadPageSortsForStartedCommunity as o, encryptEd25519AesGcmPublicKeyBuffer as on, deriveDbReplies as or, parseCommentPubsubMessagePublicationWithPKCErrorIfItFails as ot, loadChallengeFileFromCommunityChallengeSettings as p, signComment as pn, moveCommunityDbToDeletedDirectory as pr, parseCreateCommentEditOptionsSchemaWithPKCErrorIfItFails as pt, decodeRpcChallengeRequestPubsubMsg as q, getBufferedPKCAddressFromPublicKey as qn, RpcPublishChallengeAnswersParamSchema as qt, computePageSortsFingerprint as r, decryptEd25519AesGcm as rn, deleteOldCommunityInWindows as rr, parseCommentIpfsSchemaWithPKCErrorIfItFails as rt, lookupPageSortFactories as s, _validateSignatureOfPKCRecord as sn, getDefaultCommunityDbConfig as sr, parseCommentUpdateSchemaWithPKCErrorIfItFails as st, RpcLocalCommunity as t, createSigner as tn, calculateInlineRepliesBudget as tr, parseCommentEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails as tt, deriveCommunityChallengesOrThrow as u, signChallengeMessage as un, importSignerIntoKuboNode as ur, parseCommunityEditOptionsSchemaWithPKCErrorIfItFails as ut, TrackedInstanceRegistry as v, signCommunity as vn, t$2 as vr, parseCreatePKCWsServerOptionsSchemaWithPKCErrorIfItFails as vt, TIMEFRAMES_TO_SECONDS as w, verifyChallengeVerification as wn, t$7 as wr, parseDecryptedChallengeWithPKCErrorIfItFails as wt, MAX_FILE_SIZE_BYTES_FOR_COMMUNITY_IPFS as x, verifyChallengeAnswer as xn, t$5 as xr, parseCreateVoteOptionsSchemaWithPKCErrorIfItFails as xt, LRUCache as y, signCommunityEdit as yn, t$4 as yr, parseCreateRemoteCommunityFunctionArgumentSchemaWithPKCErrorIfItFails as yt, GenericStateClient as z, effectiveMaxCrosspostDepth as zn, RpcEditCommunityParamSchema as zt };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Ar as PKCError, z as pubsubTopicToDhtKeyCid } from "./util-
|
|
1
|
+
import { Ar as PKCError, z as pubsubTopicToDhtKeyCid } from "./util-ok4F-vdA.js";
|
|
2
2
|
import { ipnsSelector } from "ipns/selector";
|
|
3
3
|
import { ipnsValidator } from "ipns/validator";
|
|
4
4
|
import { unmarshalIPNSRecord } from "ipns";
|
|
@@ -5180,6 +5180,7 @@ var messages;
|
|
|
5180
5180
|
messages["ERR_CID_IS_INVALID"] = "CID is invalid";
|
|
5181
5181
|
messages["ERR_DATA_PATH_IS_NOT_DEFINED"] = "pkcOptions.dataPath needs to be defined with native functions";
|
|
5182
5182
|
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";
|
|
5183
|
+
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";
|
|
5183
5184
|
messages["ERR_COMMENT_MISSING_IPFS_AND_UPDATE"] = "Comment is missing CommentIpfs and CommentUpdate";
|
|
5184
5185
|
messages["ERR_COMMENT_MISSING_CID"] = "Comment is missing cid";
|
|
5185
5186
|
messages["ERR_COMMENT_MISSING_IPFS"] = "Comment is missing CommentIpfs props";
|
|
@@ -5435,6 +5436,7 @@ var messages;
|
|
|
5435
5436
|
messages["ERR_PUBLICATION_INVALID_COMMUNITY_PUBLIC_KEY"] = "The communityPublicKey field of publication does not match the community's IPNS key";
|
|
5436
5437
|
messages["ERR_PUBLICATION_SIGNED_TO_MINTER_INSTEAD_OF_ANCHOR"] = "The communityPublicKey field of publication is this delegated community's minter key; publications must be signed to the community's anchor identity";
|
|
5437
5438
|
messages["ERR_PUBLICATION_INVALID_COMMUNITY_NAME"] = "The communityName field of publication does not match the community's address";
|
|
5439
|
+
messages["ERR_PUBLICATION_MISSING_COMMUNITY_NAME"] = "The publication has no communityName, but the community it is published to has a name; sign it with the community's name";
|
|
5438
5440
|
messages["ERR_AUTHOR_IS_BANNED"] = "Author is banned";
|
|
5439
5441
|
messages["ERR_PUBLICATION_HAS_NO_AUTHOR_ADDRESS"] = "Publication has no author.address";
|
|
5440
5442
|
messages["ERR_COMMUNITY_PUBLICATION_PARENT_HAS_BEEN_REMOVED"] = "The parent of this publication has been removed";
|
|
@@ -14802,7 +14804,7 @@ const CommunityEditPublicationPubsubReservedFields = r$2([
|
|
|
14802
14804
|
], t$3(CommunityEditPubsubMessagePublicationSchema.shape));
|
|
14803
14805
|
//#endregion
|
|
14804
14806
|
//#region dist/node/generated-version.js
|
|
14805
|
-
const version = "0.0.
|
|
14807
|
+
const version = "0.0.121";
|
|
14806
14808
|
//#endregion
|
|
14807
14809
|
//#region dist/node/version.js
|
|
14808
14810
|
const protocolVersion = ProtocolVersionSchema.parse("1.0.0");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Ar as PKCError, _n as PageSortFileFactorySchema, an as ChallengeFileSchema, in as ChallengeFileFactorySchema } from "./util-
|
|
2
|
-
import { s as validatePageSortFile } from "./page-sort-scoring-
|
|
1
|
+
import { Ar as PKCError, _n as PageSortFileFactorySchema, an as ChallengeFileSchema, in as ChallengeFileFactorySchema } from "./util-ok4F-vdA.js";
|
|
2
|
+
import { s as validatePageSortFile } from "./page-sort-scoring-DEib5648.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-ByPmdQSD.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-DoUgLmab.js";
|
|
2
2
|
export { validatePageSortFileFactory };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Ar as PKCError, Dt as pTimeout, J as replaceXWithY, Mr as logger_default, S as hideClassPrivateProps, dr as n, pr as t, ut as findStartedCommunity } from "../../chunks/util-
|
|
2
|
-
import { _ as parseRpcExportCommunityParam, b as parseRpcUnsubscribeParam, 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 parseRpcPublishAnchorRecordParam, y as parseRpcPublishChallengeAnswersParam } from "../../chunks/node-
|
|
3
|
-
import { $t as require_lib, At as parseVoteChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, E as buildPagesRuntimeFields, H as pRetry, I as extractCrosspostRuntimeFields, St as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, T as buildPageRuntimeFields,
|
|
4
|
-
import { t as LocalCommunity } from "../../chunks/local-community-
|
|
1
|
+
import { Ar as PKCError, Dt as pTimeout, J as replaceXWithY, Mr as logger_default, S as hideClassPrivateProps, dr as n, pr as t, ut as findStartedCommunity } from "../../chunks/util-ok4F-vdA.js";
|
|
2
|
+
import { _ as parseRpcExportCommunityParam, b as parseRpcUnsubscribeParam, 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 parseRpcPublishAnchorRecordParam, y as parseRpcPublishChallengeAnswersParam } from "../../chunks/node-ByPmdQSD.js";
|
|
3
|
+
import { $t as require_lib, At as parseVoteChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, E as buildPagesRuntimeFields, Er as stringify, H as pRetry, I as extractCrosspostRuntimeFields, St as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, T as buildPageRuntimeFields, U as pLimit, _t as parseCreateNewLocalCommunityUserOptionsSchemaWithPKCErrorIfItFails, et as parseCommentChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, it as parseCommentModerationChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, kt as parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, lt as parseCommunityEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, tt as parseCommentEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, ut as parseCommunityEditOptionsSchemaWithPKCErrorIfItFails, vt as parseCreatePKCWsServerOptionsSchemaWithPKCErrorIfItFails, yr as t$1 } from "../../chunks/rpc-local-community-WmgDVdST.js";
|
|
4
|
+
import { t as LocalCommunity } from "../../chunks/local-community-CMkVMrOZ.js";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
6
|
import path from "path";
|
|
7
7
|
import assert from "assert";
|
|
@@ -138,6 +138,7 @@ var PKCWsServer = class extends import_lib.TypedEmitter {
|
|
|
138
138
|
this._onSettingsChange = {};
|
|
139
139
|
this._settingsSenders = /* @__PURE__ */ new Map();
|
|
140
140
|
this._startedCommunities = {};
|
|
141
|
+
this._addressChangeListeners = /* @__PURE__ */ new WeakMap();
|
|
141
142
|
this._autoStartOnBoot = false;
|
|
142
143
|
this._exportCommunityInstances = /* @__PURE__ */ new Map();
|
|
143
144
|
this._ownsHttpServer = false;
|
|
@@ -238,6 +239,13 @@ var PKCWsServer = class extends import_lib.TypedEmitter {
|
|
|
238
239
|
const { name, publicKey } = identifier;
|
|
239
240
|
if (!name && !publicKey) throw new Error("At least one of name or publicKey must be provided");
|
|
240
241
|
if (name && name in this._startedCommunities) return name;
|
|
242
|
+
if (publicKey) {
|
|
243
|
+
const startedAddress = Object.keys(this._startedCommunities).find((address) => {
|
|
244
|
+
const entry = this._startedCommunities[address];
|
|
245
|
+
return entry !== "pending" && entry.publicKey === publicKey;
|
|
246
|
+
});
|
|
247
|
+
if (startedAddress) return startedAddress;
|
|
248
|
+
}
|
|
241
249
|
if (name && this.pkc.communities.includes(name)) return name;
|
|
242
250
|
if (publicKey && publicKey in this._startedCommunities) return publicKey;
|
|
243
251
|
if (publicKey && this.pkc.communities.includes(publicKey)) return publicKey;
|
|
@@ -279,6 +287,31 @@ var PKCWsServer = class extends import_lib.TypedEmitter {
|
|
|
279
287
|
if (!db) return;
|
|
280
288
|
db.prepare("DELETE FROM community_states WHERE address = ?").run(address);
|
|
281
289
|
}
|
|
290
|
+
_moveCommunityState(oldAddress, newAddress) {
|
|
291
|
+
const db = this._getRpcStateDb();
|
|
292
|
+
if (!db || oldAddress === newAddress) return;
|
|
293
|
+
db.prepare("UPDATE OR REPLACE community_states SET address = @newAddress WHERE address = @oldAddress").run({
|
|
294
|
+
newAddress,
|
|
295
|
+
oldAddress
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
_fileStartedCommunityUnderItsAddress(community) {
|
|
299
|
+
if (this._startedCommunities[community.address] === community) return;
|
|
300
|
+
const filedAddress = Object.keys(this._startedCommunities).find((address) => this._startedCommunities[address] === community);
|
|
301
|
+
if (filedAddress === void 0) return;
|
|
302
|
+
this._startedCommunities[community.address] = community;
|
|
303
|
+
delete this._startedCommunities[filedAddress];
|
|
304
|
+
this._moveCommunityState(filedAddress, community.address);
|
|
305
|
+
}
|
|
306
|
+
_followAddressChanges(community) {
|
|
307
|
+
let listener = this._addressChangeListeners.get(community);
|
|
308
|
+
if (!listener) {
|
|
309
|
+
listener = () => this._fileStartedCommunityUnderItsAddress(community);
|
|
310
|
+
this._addressChangeListeners.set(community, listener);
|
|
311
|
+
}
|
|
312
|
+
if (community.listeners("update").includes(listener)) return;
|
|
313
|
+
community.on("update", listener);
|
|
314
|
+
}
|
|
282
315
|
async _autoStartPreviousCommunities() {
|
|
283
316
|
if (!this._autoStartOnBoot) return;
|
|
284
317
|
const autoStartLog = logger_default("pkc-js-rpc:pkc-ws-server:auto-start");
|
|
@@ -340,6 +373,8 @@ var PKCWsServer = class extends import_lib.TypedEmitter {
|
|
|
340
373
|
wasStarted: true,
|
|
341
374
|
wasExplicitlyStopped: false
|
|
342
375
|
});
|
|
376
|
+
this._followAddressChanges(community);
|
|
377
|
+
this._fileStartedCommunityUnderItsAddress(community);
|
|
343
378
|
return community;
|
|
344
379
|
} catch (e) {
|
|
345
380
|
delete this._startedCommunities[address];
|
|
@@ -598,6 +633,8 @@ var PKCWsServer = class extends import_lib.TypedEmitter {
|
|
|
598
633
|
wasStarted: true,
|
|
599
634
|
wasExplicitlyStopped: false
|
|
600
635
|
});
|
|
636
|
+
this._followAddressChanges(community);
|
|
637
|
+
this._fileStartedCommunityUnderItsAddress(community);
|
|
601
638
|
} catch (e) {
|
|
602
639
|
const cleanup = this.subscriptionCleanups?.[connectionId]?.[subscriptionId];
|
|
603
640
|
if (cleanup) await cleanup();
|
|
@@ -606,17 +643,21 @@ var PKCWsServer = class extends import_lib.TypedEmitter {
|
|
|
606
643
|
}
|
|
607
644
|
};
|
|
608
645
|
this._onSettingsChange[connectionId][subscriptionId] = async ({ newPKC }) => {
|
|
609
|
-
const
|
|
646
|
+
const filedAddress = this._findCommunityAddress({
|
|
647
|
+
name,
|
|
648
|
+
publicKey
|
|
649
|
+
}) ?? address;
|
|
650
|
+
const current = this._startedCommunities[filedAddress];
|
|
610
651
|
if (!current || current === "pending") return;
|
|
611
|
-
const community = await this.getStartedCommunity(
|
|
612
|
-
this._startedCommunities[
|
|
652
|
+
const community = await this.getStartedCommunity(filedAddress);
|
|
653
|
+
this._startedCommunities[filedAddress] = "pending";
|
|
613
654
|
try {
|
|
614
655
|
await community.stop();
|
|
615
656
|
community._pkc = newPKC;
|
|
616
657
|
await community.start();
|
|
617
|
-
this._startedCommunities[
|
|
658
|
+
this._startedCommunities[filedAddress] = community;
|
|
618
659
|
} catch (error) {
|
|
619
|
-
delete this._startedCommunities[
|
|
660
|
+
delete this._startedCommunities[filedAddress];
|
|
620
661
|
throw error;
|
|
621
662
|
}
|
|
622
663
|
};
|
|
@@ -662,6 +703,8 @@ var PKCWsServer = class extends import_lib.TypedEmitter {
|
|
|
662
703
|
for (const [event, listeners] of trackedListeners) for (const listener of listeners) community.removeListener(event, listener);
|
|
663
704
|
this._trackedCommunityListeners.delete(community);
|
|
664
705
|
}
|
|
706
|
+
const addressChangeListener = this._addressChangeListeners.get(community);
|
|
707
|
+
if (addressChangeListener) community.removeListener("update", addressChangeListener);
|
|
665
708
|
}
|
|
666
709
|
async editCommunity(params) {
|
|
667
710
|
const rawParam = params[0];
|
|
@@ -674,8 +717,9 @@ var PKCWsServer = class extends import_lib.TypedEmitter {
|
|
|
674
717
|
publicKey
|
|
675
718
|
});
|
|
676
719
|
if (!address) throw new PKCError("ERR_RPC_CLIENT_TRYING_TO_EDIT_REMOTE_COMMUNITY", { communityAddress: name || publicKey });
|
|
720
|
+
const startedCommunity = address in this._startedCommunities ? await this.getStartedCommunity(address) : void 0;
|
|
677
721
|
let community;
|
|
678
|
-
if (
|
|
722
|
+
if (startedCommunity instanceof LocalCommunity) community = startedCommunity;
|
|
679
723
|
else {
|
|
680
724
|
community = await pkc.createCommunity({ address });
|
|
681
725
|
community.once("error", (error) => {
|
|
@@ -683,15 +727,8 @@ var PKCWsServer = class extends import_lib.TypedEmitter {
|
|
|
683
727
|
});
|
|
684
728
|
}
|
|
685
729
|
await community.edit(editCommunityOptions);
|
|
686
|
-
if (
|
|
687
|
-
|
|
688
|
-
delete this._startedCommunities[address];
|
|
689
|
-
const db = this._getRpcStateDb();
|
|
690
|
-
if (db) db.prepare("UPDATE community_states SET address = @newAddress WHERE address = @oldAddress").run({
|
|
691
|
-
newAddress: editCommunityOptions.address,
|
|
692
|
-
oldAddress: address
|
|
693
|
-
});
|
|
694
|
-
}
|
|
730
|
+
if (community.address !== address) if (startedCommunity === community) this._fileStartedCommunityUnderItsAddress(community);
|
|
731
|
+
else this._moveCommunityState(address, community.address);
|
|
695
732
|
if (typeof community.updatedAt === "number") return community.toJSONInternalRpcAfterFirstUpdate();
|
|
696
733
|
else return community.toJSONInternalRpcBeforeFirstUpdate();
|
|
697
734
|
}
|
|
@@ -874,13 +874,19 @@ export class CommunityClientsManager extends PKCClientsManager {
|
|
|
874
874
|
// non-delegated community (no claim) ipnsName is the identity, unchanged.
|
|
875
875
|
const identityPublicKey = subRes.community.anchor?.publicKey ?? ipnsName;
|
|
876
876
|
const anchorIdentityAddress = subRes.community.name || identityPublicKey;
|
|
877
|
-
|
|
877
|
+
const communityForPublishing = {
|
|
878
878
|
encryption: subRes.community.encryption,
|
|
879
879
|
pubsubTopic: subRes.community.pubsubTopic,
|
|
880
880
|
address: anchorIdentityAddress,
|
|
881
881
|
publicKey: identityPublicKey,
|
|
882
882
|
name: subRes.community.name
|
|
883
|
-
}
|
|
883
|
+
};
|
|
884
|
+
// Under the name and under the key: a publication created with only the key reads the community's
|
|
885
|
+
// current name here to re-sign with it (issue #401), so the key's entry must not keep a record from
|
|
886
|
+
// before the community got its name
|
|
887
|
+
this._pkc._memCaches.communityForPublishing.set(anchorIdentityAddress, communityForPublishing);
|
|
888
|
+
if (anchorIdentityAddress !== identityPublicKey)
|
|
889
|
+
this._pkc._memCaches.communityForPublishing.set(identityPublicKey, communityForPublishing);
|
|
884
890
|
}
|
|
885
891
|
return subRes;
|
|
886
892
|
});
|