@pkcprotocol/pkc-js 0.0.103 → 0.0.105
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/clients/base-client-manager.d.ts +1 -0
- package/dist/browser/clients/base-client-manager.js +85 -15
- package/dist/browser/clients/base-client-manager.js.map +1 -1
- package/dist/browser/community/community-client-manager.d.ts +3 -0
- package/dist/browser/community/community-client-manager.js +87 -14
- package/dist/browser/community/community-client-manager.js.map +1 -1
- package/dist/browser/community/remote-community.js +3 -0
- package/dist/browser/community/remote-community.js.map +1 -1
- package/dist/browser/community/schema.d.ts +4 -0
- package/dist/browser/community/schema.js +7 -1
- package/dist/browser/community/schema.js.map +1 -1
- package/dist/browser/constants.d.ts +3 -0
- package/dist/browser/constants.js +35 -0
- package/dist/browser/constants.js.map +1 -1
- package/dist/browser/errors.d.ts +5 -1
- package/dist/browser/errors.js +7 -1
- 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/index-with-compile-cache.d.ts +2 -0
- package/dist/browser/index.d.ts +2 -0
- package/dist/browser/pkc/pkc.d.ts +4 -0
- package/dist/browser/pkc/pkc.js +30 -1
- package/dist/browser/pkc/pkc.js.map +1 -1
- package/dist/browser/pkc-error.d.ts +1 -1
- package/dist/browser/publications/comment/comment-client-manager.js +11 -0
- package/dist/browser/publications/comment/comment-client-manager.js.map +1 -1
- package/dist/browser/publications/comment/comment.js +8 -6
- package/dist/browser/publications/comment/comment.js.map +1 -1
- package/dist/browser/publications/comment/crosspost-runtime.js +3 -2
- package/dist/browser/publications/comment/crosspost-runtime.js.map +1 -1
- package/dist/browser/rpc/src/index.js +6 -0
- package/dist/browser/rpc/src/index.js.map +1 -1
- package/dist/browser/rpc/src/lib/pkc-js/index.d.ts +1 -0
- package/dist/browser/rpc/src/schema.d.ts +6 -0
- package/dist/browser/runtime/node/community/challenges/exclude/exclude.d.ts +11 -1
- package/dist/browser/runtime/node/community/challenges/exclude/exclude.js +32 -21
- package/dist/browser/runtime/node/community/challenges/exclude/exclude.js.map +1 -1
- package/dist/browser/runtime/node/community/challenges/index.d.ts +10 -3
- package/dist/browser/runtime/node/community/challenges/index.js +82 -16
- package/dist/browser/runtime/node/community/challenges/index.js.map +1 -1
- package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/blacklist.js +7 -4
- package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/blacklist.js.map +1 -1
- package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/whitelist.js +13 -5
- package/dist/browser/runtime/node/community/challenges/pkc-js-challenges/whitelist.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/author-identity.d.ts +37 -2
- package/dist/browser/runtime/node/community/local-community/author-identity.js +73 -13
- package/dist/browser/runtime/node/community/local-community/author-identity.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/challenges.d.ts +16 -2
- package/dist/browser/runtime/node/community/local-community/challenges.js +40 -9
- package/dist/browser/runtime/node/community/local-community/challenges.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/editing.js +7 -2
- package/dist/browser/runtime/node/community/local-community/editing.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/publication-store.d.ts +13 -2
- package/dist/browser/runtime/node/community/local-community/publication-store.js +29 -7
- package/dist/browser/runtime/node/community/local-community/publication-store.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/publication-validation.d.ts +13 -3
- package/dist/browser/runtime/node/community/local-community/publication-validation.js +60 -27
- package/dist/browser/runtime/node/community/local-community/publication-validation.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community.d.ts +2 -2
- package/dist/browser/runtime/node/community/local-community.js +6 -4
- package/dist/browser/runtime/node/community/local-community.js.map +1 -1
- package/dist/browser/runtime/node/util.js +18 -8
- package/dist/browser/runtime/node/util.js.map +1 -1
- package/dist/browser/schema.d.ts +8 -0
- package/dist/browser/test/test-util.d.ts +6 -0
- package/dist/browser/test/test-util.js +32 -1
- package/dist/browser/test/test-util.js.map +1 -1
- package/dist/browser/types.d.ts +1 -0
- package/dist/browser/util.d.ts +2 -0
- package/dist/browser/util.js +24 -0
- package/dist/browser/util.js.map +1 -1
- package/dist/bundled/bundle-manifest.json +32 -32
- package/dist/bundled/chunks/{helia-for-pkc-BqRIFXGX.js → helia-for-pkc-DanrSDp0.js} +2 -2
- package/dist/bundled/chunks/{local-community-mF7g4deD.js → local-community-Bsj3T9vI.js} +1 -1
- package/dist/bundled/chunks/{local-community-D0dqj6lQ.js → local-community-h9j5crnN.js} +159 -60
- package/dist/bundled/chunks/{node--l7gxhms.js → node-Czo2D65i.js} +19 -8
- package/dist/bundled/chunks/{rpc-local-community-C3o1AzHp.js → rpc-local-community-CP0JZU-Q.js} +291 -113
- package/dist/bundled/chunks/{schema-MeRr3oiN.js → schema-bdQ9ufF9.js} +26 -4
- package/dist/bundled/chunks/{util-CjRKlVEE.js → util-CEpMupHn.js} +1 -1
- package/dist/bundled/index.js +1 -1
- package/dist/bundled/rpc/src/index.js +9 -4
- package/dist/node/clients/base-client-manager.d.ts +1 -0
- package/dist/node/clients/base-client-manager.js +85 -15
- package/dist/node/clients/base-client-manager.js.map +1 -1
- package/dist/node/community/community-client-manager.d.ts +3 -0
- package/dist/node/community/community-client-manager.js +87 -14
- package/dist/node/community/community-client-manager.js.map +1 -1
- package/dist/node/community/remote-community.js +3 -0
- package/dist/node/community/remote-community.js.map +1 -1
- package/dist/node/community/schema.d.ts +4 -0
- package/dist/node/community/schema.js +7 -1
- package/dist/node/community/schema.js.map +1 -1
- package/dist/node/constants.d.ts +3 -0
- package/dist/node/constants.js +35 -0
- package/dist/node/constants.js.map +1 -1
- package/dist/node/errors.d.ts +5 -1
- package/dist/node/errors.js +7 -1
- 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/index-with-compile-cache.d.ts +2 -0
- package/dist/node/index.d.ts +2 -0
- package/dist/node/pkc/pkc.d.ts +4 -0
- package/dist/node/pkc/pkc.js +30 -1
- package/dist/node/pkc/pkc.js.map +1 -1
- package/dist/node/pkc-error.d.ts +1 -1
- package/dist/node/publications/comment/comment-client-manager.js +11 -0
- package/dist/node/publications/comment/comment-client-manager.js.map +1 -1
- package/dist/node/publications/comment/comment.js +8 -6
- package/dist/node/publications/comment/comment.js.map +1 -1
- package/dist/node/publications/comment/crosspost-runtime.js +3 -2
- package/dist/node/publications/comment/crosspost-runtime.js.map +1 -1
- package/dist/node/rpc/src/index.js +6 -0
- package/dist/node/rpc/src/index.js.map +1 -1
- package/dist/node/rpc/src/lib/pkc-js/index.d.ts +1 -0
- package/dist/node/rpc/src/schema.d.ts +6 -0
- package/dist/node/runtime/node/community/challenges/exclude/exclude.d.ts +11 -1
- package/dist/node/runtime/node/community/challenges/exclude/exclude.js +32 -21
- package/dist/node/runtime/node/community/challenges/exclude/exclude.js.map +1 -1
- package/dist/node/runtime/node/community/challenges/index.d.ts +10 -3
- package/dist/node/runtime/node/community/challenges/index.js +82 -16
- package/dist/node/runtime/node/community/challenges/index.js.map +1 -1
- package/dist/node/runtime/node/community/challenges/pkc-js-challenges/blacklist.js +7 -4
- package/dist/node/runtime/node/community/challenges/pkc-js-challenges/blacklist.js.map +1 -1
- package/dist/node/runtime/node/community/challenges/pkc-js-challenges/whitelist.js +13 -5
- package/dist/node/runtime/node/community/challenges/pkc-js-challenges/whitelist.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/author-identity.d.ts +37 -2
- package/dist/node/runtime/node/community/local-community/author-identity.js +73 -13
- package/dist/node/runtime/node/community/local-community/author-identity.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/challenges.d.ts +16 -2
- package/dist/node/runtime/node/community/local-community/challenges.js +40 -9
- package/dist/node/runtime/node/community/local-community/challenges.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/editing.js +7 -2
- package/dist/node/runtime/node/community/local-community/editing.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/publication-store.d.ts +13 -2
- package/dist/node/runtime/node/community/local-community/publication-store.js +29 -7
- package/dist/node/runtime/node/community/local-community/publication-store.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/publication-validation.d.ts +13 -3
- package/dist/node/runtime/node/community/local-community/publication-validation.js +60 -27
- package/dist/node/runtime/node/community/local-community/publication-validation.js.map +1 -1
- package/dist/node/runtime/node/community/local-community.d.ts +2 -2
- package/dist/node/runtime/node/community/local-community.js +6 -4
- package/dist/node/runtime/node/community/local-community.js.map +1 -1
- package/dist/node/runtime/node/util.js +18 -8
- package/dist/node/runtime/node/util.js.map +1 -1
- package/dist/node/schema.d.ts +8 -0
- package/dist/node/test/test-util.d.ts +6 -0
- package/dist/node/test/test-util.js +32 -1
- package/dist/node/test/test-util.js.map +1 -1
- package/dist/node/types.d.ts +1 -0
- package/dist/node/util.d.ts +2 -0
- package/dist/node/util.js +24 -0
- package/dist/node/util.js.map +1 -1
- package/package.json +1 -1
package/dist/bundled/chunks/{rpc-local-community-C3o1AzHp.js → rpc-local-community-CP0JZU-Q.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
|
|
2
|
+
import { $ as isRequestPubsubPublicationOfPost, $n as CommunityAddressSchema, $t as CreateCommentModerationOptionsWithRefinementSchema, A as doesDomainAddressHaveCapitalLetter, An as CommentUpdateForChallengeVerificationSignedPropertyNames, Ar as array, At as listUpdatingCommunities, B as interruptibleSleep, Bn as CommentEditChallengeRequestToEncryptSchema, Bt as require_sha256$1, Cn as CommentIpfsReservedFields, Cr as PKCError, D as createAbortError, Dn as CommentSignedPropertyNames, Dr as require_ms$1, Dt as findUpdatingCommunity, En as CommentPubsubMessageWithFlexibleAuthorRefinementSchema, Er as require_supports_color, Et as findUpdatingComment, Fr as object, G as isIpns, Gt as CommunityEditPublicationSignedPropertyNames, H as isAbortError, Hn as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema, Ht as pTimeout, In as CreateCommentOptionsWithRefinementSchema, Ir as record, It as trackUpdatingCommunity, Jn as AuthorCommentIpfsReservedFields, Jt as CommentModerationChallengeRequestToEncryptSchema, K as isIpnsPath, Kn as CreateCommentEditOptionsWithRefinementSchema, Kt as CommunityEditPubsubMessagePublicationSchema, L as getPostUpdateTimestampRange, Ln as GetPageParamSchema, Lr as string, Lt as untrackStartedCommunity, M as fetchAndValidateIpnsRecordFromGateway, Mn as CommentUpdateSchema, Mr as custom, Mt as refreshTrackedCommunityAliases, Nn as CommentUpdateSignedPropertyNames, Nr as literal, O as deepMergeRuntimeFields, On as CommentUpdateChallengeReservedFieldNames, Ot as listStartedCommunities, Pr as number, Pt as trackStartedCommunity, Qn as CidStringSchema, Qt as CommentModerationsTableRowSchema, R as hasTransientNetworkErrorCode, Rn as ModQueuePageIpfsSchema, Rt as untrackUpdatingComment, S as calculateIpfsCidV0, Sn as CommentChallengeRequestToEncryptSchema, Sr as FailedToFetchPageIpfsFromGatewaysError, St as waitForUpdateInCommunityInstanceWithErrorAndTimeout, Tr as logger_default, Tt as findStartedCommunity, U as isIpfsCid, Ut as CommunityEditPublicationChallengeRequestToEncryptSchema, V as ipnsNameToIpnsOverPubsubTopic, W as isIpfsPath, Wn as CommentEditSignedPropertyNames, Xn as ChallengeAnswersSchema, Yt as CommentModerationPubsubMessagePublicationSchema, Zn as CidPathSchema, Zt as CommentModerationSignedPropertyNames, _ as PKCUserOptionBaseSchema, _n as VoteChallengeRequestToEncryptSchema, _r as require_retry$1, _t as shortifyCid, an as CommunityExportRecordsSchema, b as areEquivalentCommunityAddresses, bn as VoteSignedPropertyNames, br as FailedToFetchCommunityFromGatewaysError, bt as throwIfAbortSignalAborted, c as ChallengeVerificationMessageSignedPropertyNames, cn as CommunitySignedPropertyNames, cr as e$5, ct as removeNullUndefinedEmptyObjectsValuesRecursively, dn as CreateRpcCommunityFunctionArgumentSchema, dr as t$12, en as ChallengeFileFactorySchema, er as CommunityAuthorChallengeReservedFieldNames, et as isRequestPubsubPublicationOfReply, f as DecryptedChallengeSchema, fn as ExportCommunityModLogsOptionsSchema, fr as n$8, ft as resolveWhenPredicateIsTrue, g as PKCParsedOptionsSchema, gn as CreateVoteUserOptionsWithRefinementSchema, gr as e$4, gt as shortifyAddress, h as NameResolverSerializedSchema, hn as isStringDomain, hr as t$9, i as ChallengeMessageSignedPropertyNames, in as CommunityEditOptionsSchema, ir as n$9, j as extractNetworkErrorDetails, jn as CommentUpdateReservedFields, jr as boolean, k as derivePublicationFromChallengeRequest, kr as _enum, l as DecryptedChallengeAnswerSchema, ln as CreateNewLocalCommunityUserOptionsSchema, lr as t$11, m as NameResolveCacheOptionsSchema, mn as RpcRemoteCommunityUpdateEventResultSchema, mr as t$10, n as ChallengeAnswerMessageSignedPropertyNames, nr as n$10, o as ChallengeRequestMessageSignedPropertyNames, on as CommunityIpfsReservedFields, or as t$13, p as DecryptedChallengeVerificationSchema, pr as r$7, qn as AuthorAddressSchema, qt as CreateCommunityEditPublicationOptionsWithRefinementSchema, rn as CommunityChallengeSettingSchema, rt as raceAgainstAbort, sn as CommunityIpfsSchema, sr as e$6, tn as ChallengeFileSchema, tr as CreateSignerSchema, tt as pubsubTopicToDhtKey, un as CreateRemoteCommunityFunctionArgumentSchema, ur as r$8, v as PKCUserOptionsSchema, vn as VotePubsubMessagePublicationSchema, vr as FailedToFetchCommentIpfsFromGatewaysError, vt as sleepUntilTimeoutOrAbort, wn as CommentIpfsSchema, wr as messages, xr as FailedToFetchGenericIpfsFromGatewaysError, xt as timestamp, yr as FailedToFetchCommentUpdateFromGatewaysError, z as hideClassPrivateProps, zn as PageIpfsSchema, zt as untrackUpdatingCommunity } from "./schema-bdQ9ufF9.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";
|
|
@@ -91428,6 +91428,9 @@ var STORAGE_KEYS;
|
|
|
91428
91428
|
STORAGE_KEYS[STORAGE_KEYS["ANCHOR_IPNS_RECORD"] = 5] = "ANCHOR_IPNS_RECORD";
|
|
91429
91429
|
STORAGE_KEYS[STORAGE_KEYS["HIGHEST_ACCEPTED_ANCHOR_SEQUENCE"] = 6] = "HIGHEST_ACCEPTED_ANCHOR_SEQUENCE";
|
|
91430
91430
|
})(STORAGE_KEYS || (STORAGE_KEYS = {}));
|
|
91431
|
+
const NAME_RESOLVED_FALSE_TTL_MS = 6e4;
|
|
91432
|
+
const NAME_RESOLVED_TRUE_TTL_MS = 36e5;
|
|
91433
|
+
const NAME_RESOLVE_FAILED_RETRY_FLOOR_MS = 1e4;
|
|
91431
91434
|
//#endregion
|
|
91432
91435
|
//#region node_modules/safe-stable-stringify/index.js
|
|
91433
91436
|
var require_safe_stable_stringify = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
@@ -99621,21 +99624,24 @@ var BaseClientsManager = class BaseClientsManager {
|
|
|
99621
99624
|
});
|
|
99622
99625
|
} catch (error) {
|
|
99623
99626
|
if (isAbortError(error)) throw error;
|
|
99624
|
-
const
|
|
99627
|
+
const isOpaqueResolverError = !(error instanceof PKCError);
|
|
99628
|
+
const p2pValidationNote = isOpaqueResolverError ? "Resolution failed inside the IPNS resolver (kubo/helia). Over P2P the resolver performs per-record signature validation, so a forged/tampered/unverifiable record appears here as a resolution failure, not an explicit forgery error (cf. the gateway path's ERR_GATEWAY_IPNS_RECORD_CHAIN_INVALID). See docs/protocol/delegated-ipns.md." : void 0;
|
|
99625
99629
|
error.details = {
|
|
99626
99630
|
...error.details,
|
|
99627
99631
|
ipnsName,
|
|
99628
99632
|
ipnsResolveOpts,
|
|
99629
99633
|
...p2pValidationNote ? { note: p2pValidationNote } : {}
|
|
99630
99634
|
};
|
|
99631
|
-
|
|
99632
|
-
|
|
99635
|
+
const networkErrorDetails = isOpaqueResolverError ? extractNetworkErrorDetails(error) : void 0;
|
|
99636
|
+
if (error instanceof Error && networkErrorDetails && hasTransientNetworkErrorCode(networkErrorDetails)) {
|
|
99637
|
+
log.error(`Failed to resolve IPNS ${ipnsName}: ${error.message} (${error.name})`, networkErrorDetails);
|
|
99633
99638
|
throw new PKCError("ERR_FAILED_TO_RESOLVE_IPNS_VIA_IPFS_P2P", {
|
|
99634
99639
|
ipnsName,
|
|
99635
99640
|
ipnsResolveOpts,
|
|
99636
99641
|
error,
|
|
99637
99642
|
errorMessage: error.message,
|
|
99638
99643
|
errorName: error.name,
|
|
99644
|
+
networkErrorDetails,
|
|
99639
99645
|
note: p2pValidationNote
|
|
99640
99646
|
});
|
|
99641
99647
|
}
|
|
@@ -99753,6 +99759,8 @@ var BaseClientsManager = class BaseClientsManager {
|
|
|
99753
99759
|
const persistentCache = this._getNameResolutionCache();
|
|
99754
99760
|
let value;
|
|
99755
99761
|
let anyResolverCanHandle = false;
|
|
99762
|
+
let anyResolverAnswered = false;
|
|
99763
|
+
const resolverErrors = {};
|
|
99756
99764
|
for (const nameResolver of nameResolvers) {
|
|
99757
99765
|
if (!nameResolver.canResolve({ name })) continue;
|
|
99758
99766
|
anyResolverCanHandle = true;
|
|
@@ -99764,6 +99772,7 @@ var BaseClientsManager = class BaseClientsManager {
|
|
|
99764
99772
|
});
|
|
99765
99773
|
if (cached) {
|
|
99766
99774
|
value = cached.publicKey;
|
|
99775
|
+
anyResolverAnswered = true;
|
|
99767
99776
|
break;
|
|
99768
99777
|
}
|
|
99769
99778
|
this.preResolveNameResolver({
|
|
@@ -99790,8 +99799,13 @@ var BaseClientsManager = class BaseClientsManager {
|
|
|
99790
99799
|
if (abortSignal?.aborted) throwIfAbortSignalAborted(abortSignal);
|
|
99791
99800
|
if (isAbortError(error)) throw error;
|
|
99792
99801
|
log.trace(`Resolver ${nameResolver.key} failed for ${name}`, error);
|
|
99802
|
+
resolverErrors[nameResolver.key] = {
|
|
99803
|
+
provider: nameResolver.provider,
|
|
99804
|
+
error
|
|
99805
|
+
};
|
|
99793
99806
|
continue;
|
|
99794
99807
|
}
|
|
99808
|
+
anyResolverAnswered = true;
|
|
99795
99809
|
this.postResolveNameResolverSuccess({
|
|
99796
99810
|
address: name,
|
|
99797
99811
|
resolveType,
|
|
@@ -99816,8 +99830,17 @@ var BaseClientsManager = class BaseClientsManager {
|
|
|
99816
99830
|
}
|
|
99817
99831
|
}
|
|
99818
99832
|
if (!anyResolverCanHandle) throw new PKCError("ERR_NO_RESOLVER_FOR_NAME", { address: name });
|
|
99833
|
+
if (!value && !anyResolverAnswered) throw new PKCError("ERR_ALL_NAME_RESOLVERS_FAILED", {
|
|
99834
|
+
address: name,
|
|
99835
|
+
resolverErrors
|
|
99836
|
+
});
|
|
99819
99837
|
return value || null;
|
|
99820
99838
|
}
|
|
99839
|
+
canResolveName(name) {
|
|
99840
|
+
const nameResolvers = this._pkc.nameResolvers;
|
|
99841
|
+
if (!nameResolvers || nameResolvers.length === 0) return false;
|
|
99842
|
+
return nameResolvers.some((nameResolver) => nameResolver.canResolve({ name }));
|
|
99843
|
+
}
|
|
99821
99844
|
async resolveCommunityNameIfNeeded({ communityName, abortSignal, cache }) {
|
|
99822
99845
|
assert(typeof communityName === "string", "communityName needs to be a string to be resolved");
|
|
99823
99846
|
if (!isStringDomain(communityName)) return communityName;
|
|
@@ -99850,14 +99873,20 @@ var BaseClientsManager = class BaseClientsManager {
|
|
|
99850
99873
|
resolveAuthorNamesInBackground({ authors, onResolved, abortSignal }) {
|
|
99851
99874
|
const log = logger_default("pkc-js:base-client-manager:resolveAuthorNamesInBackground");
|
|
99852
99875
|
const verificationCache = this._pkc._memCaches.nameResolvedCache;
|
|
99876
|
+
const inFlight = this._pkc._authorNameResolvesInFlight;
|
|
99877
|
+
const failedRecently = this._pkc._memCaches.nameResolveFailedCache;
|
|
99853
99878
|
const seen = /* @__PURE__ */ new Set();
|
|
99854
99879
|
const toResolve = [];
|
|
99855
99880
|
for (const { authorName, signaturePublicKey } of authors) {
|
|
99856
99881
|
if (!isStringDomain(authorName)) continue;
|
|
99882
|
+
if (!this.canResolveName(authorName)) continue;
|
|
99857
99883
|
const cacheKey = (0, import_sha256.sha256)(authorName + signaturePublicKey);
|
|
99858
99884
|
if (seen.has(cacheKey)) continue;
|
|
99859
99885
|
seen.add(cacheKey);
|
|
99860
99886
|
if (typeof verificationCache.get(cacheKey) === "boolean") continue;
|
|
99887
|
+
if (inFlight.has(cacheKey)) continue;
|
|
99888
|
+
if (failedRecently.get(cacheKey)) continue;
|
|
99889
|
+
inFlight.add(cacheKey);
|
|
99861
99890
|
toResolve.push({
|
|
99862
99891
|
authorName,
|
|
99863
99892
|
signaturePublicKey,
|
|
@@ -99865,27 +99894,34 @@ var BaseClientsManager = class BaseClientsManager {
|
|
|
99865
99894
|
});
|
|
99866
99895
|
}
|
|
99867
99896
|
if (toResolve.length === 0) return;
|
|
99897
|
+
const setVerdict = (cacheKey, verdict) => verdict ? verificationCache.set(cacheKey, true, { ttl: this._pkc._nameResolvedTrueTtlMs }) : verificationCache.set(cacheKey, false, { ttl: this._pkc._nameResolvedFalseTtlMs });
|
|
99868
99898
|
const limit = pLimit(MAX_CONCURRENT_AUTHOR_NAME_RESOLUTIONS);
|
|
99869
99899
|
const resolveOne = async (entry) => {
|
|
99870
|
-
if (abortSignal?.aborted) return false;
|
|
99871
99900
|
try {
|
|
99901
|
+
if (abortSignal?.aborted) return false;
|
|
99872
99902
|
const { resolvedAuthorName: resolved } = await this.resolveAuthorNameIfNeeded({
|
|
99873
99903
|
authorName: entry.authorName,
|
|
99874
99904
|
abortSignal,
|
|
99875
99905
|
cache: { maxAge: 3600 }
|
|
99876
99906
|
});
|
|
99877
|
-
if (typeof resolved !== "string")
|
|
99907
|
+
if (typeof resolved !== "string") {
|
|
99908
|
+
setVerdict(entry.cacheKey, false);
|
|
99909
|
+
return true;
|
|
99910
|
+
}
|
|
99878
99911
|
const signerAddress = await getPKCAddressFromPublicKey(entry.signaturePublicKey);
|
|
99879
|
-
|
|
99912
|
+
setVerdict(entry.cacheKey, resolved === signerAddress);
|
|
99880
99913
|
return true;
|
|
99881
99914
|
} catch (e) {
|
|
99882
99915
|
if (isAbortError(e)) return false;
|
|
99883
|
-
if (e instanceof PKCError && e.code === "
|
|
99884
|
-
|
|
99916
|
+
if (e instanceof PKCError && e.code === "ERR_RESOLVED_TEXT_RECORD_TO_NON_IPNS") {
|
|
99917
|
+
setVerdict(entry.cacheKey, false);
|
|
99885
99918
|
return true;
|
|
99886
99919
|
}
|
|
99887
99920
|
log.error("Failed to resolve author name in background", entry.authorName, e);
|
|
99921
|
+
failedRecently.set(entry.cacheKey, true, { ttl: this._pkc._nameResolveFailedRetryFloorMs });
|
|
99888
99922
|
return false;
|
|
99923
|
+
} finally {
|
|
99924
|
+
inFlight.delete(entry.cacheKey);
|
|
99889
99925
|
}
|
|
99890
99926
|
};
|
|
99891
99927
|
Promise.allSettled(toResolve.map((entry) => limit(() => resolveOne(entry)))).then((results) => {
|
|
@@ -100619,7 +100655,6 @@ function collectCrosspostAuthorsToResolve({ crosspost, maxLevels = CROSSPOST_LEV
|
|
|
100619
100655
|
const authors = [];
|
|
100620
100656
|
const chain = _chainOf(crosspost).slice(0, maxLevels);
|
|
100621
100657
|
for (const level of chain) {
|
|
100622
|
-
if (typeof level.comment.author?.nameResolved === "boolean") continue;
|
|
100623
100658
|
const authorName = getAuthorNameFromWire(level.comment.author);
|
|
100624
100659
|
if (!authorName) continue;
|
|
100625
100660
|
authors.push({
|
|
@@ -101998,6 +102033,7 @@ var CommentClientsManager = class extends PublicationClientsManager {
|
|
|
101998
102033
|
return;
|
|
101999
102034
|
}
|
|
102000
102035
|
this._resetFreshHandlerAbortController();
|
|
102036
|
+
if (!this._pkc._pkcRpcClient) this._comment._resolveAuthorNamesInBackground();
|
|
102001
102037
|
const postInUpdatingCommunity = this._findCommentInPagesOfUpdatingCommentsOrCommunity({ community });
|
|
102002
102038
|
if (postInUpdatingCommunity && postInUpdatingCommunity.commentUpdate.updatedAt > (this._comment.raw?.commentUpdate?.updatedAt || 0)) {
|
|
102003
102039
|
const log = logger_default("pkc-js:comment:update:handleUpdateEventFromCommunity:find-comment-update-in-updating-community-or-comments-pages");
|
|
@@ -102181,6 +102217,7 @@ var CommentClientsManager = class extends PublicationClientsManager {
|
|
|
102181
102217
|
const log = logger_default("pkc-js:comment:update:handleUpdateEventFromPost");
|
|
102182
102218
|
log("Received update event from post", postInstance.cid, "for reply", this._comment.cid, "with depth", this._comment.depth);
|
|
102183
102219
|
this._resetFreshHandlerAbortController();
|
|
102220
|
+
if (!this._pkc._pkcRpcClient) this._comment._resolveAuthorNamesInBackground();
|
|
102184
102221
|
if (Object.keys(postInstance.replies.pageCids).length === 0 && Object.keys(postInstance.replies.pages).length === 0) {
|
|
102185
102222
|
log("Post", postInstance.cid, "has no replies, therefore reply", this._comment.cid, "will wait until another update event by post");
|
|
102186
102223
|
this._comment._setUpdatingStateWithEmissionIfNewState("waiting-retry");
|
|
@@ -102458,24 +102495,27 @@ async function tryToDeleteCommunitiesThatFailedToBeDeletedBefore(pkc, log) {
|
|
|
102458
102495
|
}
|
|
102459
102496
|
}
|
|
102460
102497
|
function listCommunitiesSync(pkc) {
|
|
102461
|
-
logger_default("pkc-js:listCommunitiesSync");
|
|
102498
|
+
const log = logger_default("pkc-js:listCommunitiesSync");
|
|
102462
102499
|
if (typeof pkc.dataPath !== "string") throw Error("pkc.dataPath needs to be defined to listCommunities");
|
|
102463
102500
|
const communitiesPath = path.join(pkc.dataPath, "communities");
|
|
102464
102501
|
const files = readdirSync(communitiesPath, {
|
|
102465
102502
|
recursive: false,
|
|
102466
|
-
withFileTypes:
|
|
102467
|
-
}).
|
|
102503
|
+
withFileTypes: true
|
|
102504
|
+
}).filter((dirent) => dirent.isFile()).map((dirent) => dirent.name).filter((file) => !file.includes(".lock") && !file.endsWith("-journal") && !file.endsWith("-shm") && !file.endsWith("-wal"));
|
|
102468
102505
|
const communityFilesWeDontNeedToCheck = pkc.communities ? files.filter((address) => pkc.communities.includes(address)) : [];
|
|
102469
102506
|
const sqliteFiles = files.filter((address) => !communityFilesWeDontNeedToCheck.includes(address)).filter((address) => {
|
|
102507
|
+
const filePath = path.join(communitiesPath, address);
|
|
102470
102508
|
try {
|
|
102471
|
-
const filePath = path.join(communitiesPath, address);
|
|
102472
|
-
if (!existsSync(filePath)) return false;
|
|
102473
102509
|
const fd = openSync(filePath, "r");
|
|
102474
102510
|
const buffer = Buffer.alloc(16);
|
|
102475
|
-
|
|
102476
|
-
|
|
102511
|
+
try {
|
|
102512
|
+
readSync(fd, buffer, 0, 16, 0);
|
|
102513
|
+
} finally {
|
|
102514
|
+
closeSync(fd);
|
|
102515
|
+
}
|
|
102477
102516
|
return buffer.toString().startsWith("SQLite format 3");
|
|
102478
102517
|
} catch (e) {
|
|
102518
|
+
if (!(e instanceof Error && "code" in e && e.code === "ENOENT")) log.error(`Failed to check whether ${filePath} is a SQLite file, skipping it`, e);
|
|
102479
102519
|
return false;
|
|
102480
102520
|
}
|
|
102481
102521
|
});
|
|
@@ -125434,6 +125474,7 @@ var CommunityClientsManager = class extends PKCClientsManager {
|
|
|
125434
125474
|
this._pendingIpnsArrivalHopTargets = /* @__PURE__ */ new Set();
|
|
125435
125475
|
this._nextResolveRevalidatesNetwork = false;
|
|
125436
125476
|
this._lastForcedIpnsNetworkRevalidationAtMs = 0;
|
|
125477
|
+
this._nameResolveInFlight = false;
|
|
125437
125478
|
this._community = community;
|
|
125438
125479
|
this._initPKCRpcClients();
|
|
125439
125480
|
hideClassPrivateProps(this);
|
|
@@ -125492,6 +125533,7 @@ var CommunityClientsManager = class extends PKCClientsManager {
|
|
|
125492
125533
|
}
|
|
125493
125534
|
postResolveNameResolverSuccess(opts) {
|
|
125494
125535
|
super.postResolveNameResolverSuccess(opts);
|
|
125536
|
+
if (opts.resolveType !== "community") return;
|
|
125495
125537
|
if (!opts.resolvedValue && this._community.state === "updating") throw new PKCError("ERR_DOMAIN_TXT_RECORD_NOT_FOUND", { name: opts.address });
|
|
125496
125538
|
}
|
|
125497
125539
|
_getCommunityAddressFromInstance() {
|
|
@@ -125578,9 +125620,13 @@ var CommunityClientsManager = class extends PKCClientsManager {
|
|
|
125578
125620
|
const publicKeyBeforeApply = this._community.publicKey;
|
|
125579
125621
|
this._community.initCommunityIpfsPropsNoMerge(communityLoadingRes.community);
|
|
125580
125622
|
this._community.updateCid = communityLoadingRes.cid;
|
|
125581
|
-
if (publicKeyBeforeApply && this._community.publicKey !== publicKeyBeforeApply)
|
|
125582
|
-
|
|
125583
|
-
|
|
125623
|
+
if (publicKeyBeforeApply && this._community.publicKey !== publicKeyBeforeApply) {
|
|
125624
|
+
this._community.nameResolved = void 0;
|
|
125625
|
+
this._nameResolvedFalseAtMs = void 0;
|
|
125626
|
+
this._nameResolveFailedAtMs = void 0;
|
|
125627
|
+
}
|
|
125628
|
+
if (!isStringDomain(this._community.address) && this._community.name && this._community.publicKey && this._community.nameResolved !== true) this._resolveNameInBackground(this._community.name);
|
|
125629
|
+
else if (isStringDomain(this._community.address) && this._community.publicKey && this._community.nameResolved !== true) this._resolveNameInBackground(this._community.address);
|
|
125584
125630
|
log(`Remote Community`, this._community.address, `received a new update. Will emit an update event with updatedAt`, this._community.updatedAt, "that's", timestamp() - this._community.updatedAt, "seconds old");
|
|
125585
125631
|
this._community._changeStateEmitEventEmitStateChangeEvent({
|
|
125586
125632
|
event: {
|
|
@@ -125778,11 +125824,18 @@ var CommunityClientsManager = class extends PKCClientsManager {
|
|
|
125778
125824
|
}
|
|
125779
125825
|
_resolveNameInBackground(name) {
|
|
125780
125826
|
const log = logger_default("pkc-js:community-client-manager:_resolveNameInBackground");
|
|
125827
|
+
if (this._nameResolveInFlight) return;
|
|
125828
|
+
if (!this.canResolveName(name)) return;
|
|
125829
|
+
if (typeof this._nameResolveFailedAtMs === "number" && Date.now() - this._nameResolveFailedAtMs < this._pkc._nameResolveFailedRetryFloorMs) return;
|
|
125830
|
+
if (this._community.nameResolved === false && typeof this._nameResolvedFalseAtMs === "number" && Date.now() - this._nameResolvedFalseAtMs < this._pkc._nameResolvedFalseTtlMs) return;
|
|
125781
125831
|
const setNameResolvedAndEmitUpdate = (newNameResolved) => {
|
|
125832
|
+
this._nameResolvedFalseAtMs = newNameResolved === false ? Date.now() : void 0;
|
|
125833
|
+
this._nameResolveFailedAtMs = void 0;
|
|
125782
125834
|
if (this._community.nameResolved === newNameResolved) return;
|
|
125783
125835
|
this._community.nameResolved = newNameResolved;
|
|
125784
125836
|
if (typeof this._community.updatedAt === "number") this._community.emit("update", this._community);
|
|
125785
125837
|
};
|
|
125838
|
+
this._nameResolveInFlight = true;
|
|
125786
125839
|
this._resolveCommunityNameWithoutUpdatingState({
|
|
125787
125840
|
communityName: name,
|
|
125788
125841
|
abortSignal: this._community._getStopAbortSignal(),
|
|
@@ -125801,8 +125854,14 @@ var CommunityClientsManager = class extends PKCClientsManager {
|
|
|
125801
125854
|
} else if (resolved) setNameResolvedAndEmitUpdate(true);
|
|
125802
125855
|
if (!resolved && this._community.name) setNameResolvedAndEmitUpdate(false);
|
|
125803
125856
|
}).catch((e) => {
|
|
125804
|
-
if (e instanceof PKCError && (e.code === "
|
|
125805
|
-
else
|
|
125857
|
+
if (e instanceof PKCError && (e.code === "ERR_DOMAIN_TXT_RECORD_NOT_FOUND" || e.code === "ERR_RESOLVED_TEXT_RECORD_TO_NON_IPNS")) setNameResolvedAndEmitUpdate(false);
|
|
125858
|
+
else if (isAbortError(e)) return;
|
|
125859
|
+
else {
|
|
125860
|
+
log.trace("Background name resolution failed for", name, e);
|
|
125861
|
+
this._nameResolveFailedAtMs = Date.now();
|
|
125862
|
+
}
|
|
125863
|
+
}).finally(() => {
|
|
125864
|
+
this._nameResolveInFlight = false;
|
|
125806
125865
|
});
|
|
125807
125866
|
}
|
|
125808
125867
|
_resolvePageAuthorNamesInBackground() {
|
|
@@ -125814,7 +125873,7 @@ var CommunityClientsManager = class extends PKCClientsManager {
|
|
|
125814
125873
|
if (!page) continue;
|
|
125815
125874
|
for (const comment of page.comments) {
|
|
125816
125875
|
const domain = getAuthorNameFromRuntime(comment.author);
|
|
125817
|
-
if (domain
|
|
125876
|
+
if (domain) authors.push({
|
|
125818
125877
|
authorName: domain,
|
|
125819
125878
|
signaturePublicKey: comment.signature.publicKey
|
|
125820
125879
|
});
|
|
@@ -125847,7 +125906,7 @@ var CommunityClientsManager = class extends PKCClientsManager {
|
|
|
125847
125906
|
abortSignal: this._community._getStopAbortSignal(),
|
|
125848
125907
|
cache: { maxAge: 3600 }
|
|
125849
125908
|
});
|
|
125850
|
-
if (!isDomain && this._community.name && this._community.publicKey &&
|
|
125909
|
+
if (!isDomain && this._community.name && this._community.publicKey && this._community.nameResolved !== true) this._resolveNameInBackground(this._community.name);
|
|
125851
125910
|
if (!ipnsName) throw Error("Failed to resolve community address to an IPNS name");
|
|
125852
125911
|
if (this._community.ipnsName !== ipnsName) {
|
|
125853
125912
|
this._community.ipnsName = ipnsName;
|
|
@@ -128508,70 +128567,22 @@ const addToRateLimiter = (communityChallenges, request, challengeSuccess) => {
|
|
|
128508
128567
|
for (const rateLimiter of Object.values(rateLimiters)) rateLimiter.tryRemoveTokens(1);
|
|
128509
128568
|
};
|
|
128510
128569
|
//#endregion
|
|
128511
|
-
//#region dist/node/runtime/node/community/local-community/author-identity.js
|
|
128512
|
-
function createAuthorIdentityMatcher({ community, publication }) {
|
|
128513
|
-
const log = logger_default("pkc-js:local-community:author-identity");
|
|
128514
|
-
const signerAddress = getPKCAddressFromPublicKeySync(publication.signature.publicKey);
|
|
128515
|
-
const wireName = getAuthorNameFromWire(publication.author);
|
|
128516
|
-
let nameResolvesToSignerPromise;
|
|
128517
|
-
const nameResolvesToSigner = () => {
|
|
128518
|
-
if (!wireName || !isStringDomain(wireName)) return Promise.resolve(false);
|
|
128519
|
-
if (!nameResolvesToSignerPromise) nameResolvesToSignerPromise = (async () => {
|
|
128520
|
-
try {
|
|
128521
|
-
const { resolvedAuthorName } = await community._clientsManager.resolveAuthorNameIfNeeded({
|
|
128522
|
-
authorName: wireName,
|
|
128523
|
-
abortSignal: AbortSignal.timeout(community._pkc._timeouts["resolve-author-name"]),
|
|
128524
|
-
cache: { maxAge: 0 }
|
|
128525
|
-
});
|
|
128526
|
-
return resolvedAuthorName === signerAddress;
|
|
128527
|
-
} catch (e) {
|
|
128528
|
-
log("Failed to resolve author name while matching identity, treating as no match", wireName, e);
|
|
128529
|
-
return false;
|
|
128530
|
-
}
|
|
128531
|
-
})();
|
|
128532
|
-
return nameResolvesToSignerPromise;
|
|
128533
|
-
};
|
|
128534
|
-
const matchesIdentity = async (identity) => {
|
|
128535
|
-
if (!isStringDomain(identity)) return identity === signerAddress;
|
|
128536
|
-
if (identity !== wireName) return false;
|
|
128537
|
-
return nameResolvesToSigner();
|
|
128538
|
-
};
|
|
128539
|
-
const matchesAnyIdentity = async (identities) => {
|
|
128540
|
-
let nameListed = false;
|
|
128541
|
-
for (const identity of identities) {
|
|
128542
|
-
if (identity === signerAddress) return true;
|
|
128543
|
-
if (wireName && identity === wireName) nameListed = true;
|
|
128544
|
-
}
|
|
128545
|
-
return nameListed ? nameResolvesToSigner() : false;
|
|
128546
|
-
};
|
|
128547
|
-
return {
|
|
128548
|
-
signerAddress,
|
|
128549
|
-
wireName,
|
|
128550
|
-
matchesIdentity,
|
|
128551
|
-
matchesAnyIdentity
|
|
128552
|
-
};
|
|
128553
|
-
}
|
|
128554
|
-
//#endregion
|
|
128555
128570
|
//#region dist/node/runtime/node/community/challenges/exclude/exclude.js
|
|
128556
|
-
const testRole = async (excludeRole,
|
|
128557
|
-
if (!communityRoles) return false;
|
|
128571
|
+
const testRole = async ({ excludeRole, identityMatcher, communityRoles }) => {
|
|
128572
|
+
if (!communityRoles) return { matched: false };
|
|
128558
128573
|
const roleKeys = Object.keys(communityRoles).filter((roleKey) => excludeRole.includes(communityRoles[roleKey].role));
|
|
128559
|
-
if (roleKeys.length === 0) return false;
|
|
128560
|
-
return
|
|
128574
|
+
if (roleKeys.length === 0) return { matched: false };
|
|
128575
|
+
return identityMatcher.matchesAnyIdentity(roleKeys);
|
|
128561
128576
|
};
|
|
128562
|
-
const shouldExcludePublication = async (communityChallenge, request, community) => {
|
|
128577
|
+
const shouldExcludePublication = async ({ communityChallenge, request, community, identityMatcher }) => {
|
|
128563
128578
|
if (!communityChallenge) throw Error(`shouldExcludePublication invalid communityChallenge argument '${communityChallenge}'`);
|
|
128564
128579
|
const publication = derivePublicationFromChallengeRequest(request);
|
|
128565
128580
|
if (!publication?.author) throw Error(`shouldExcludePublication invalid publication argument '${publication}'`);
|
|
128566
128581
|
const author = publication.author;
|
|
128567
|
-
if (!communityChallenge.exclude) return false;
|
|
128582
|
+
if (!communityChallenge.exclude) return { shouldExclude: false };
|
|
128568
128583
|
if (!Array.isArray(communityChallenge.exclude)) throw Error(`shouldExcludePublication invalid communityChallenge argument '${communityChallenge}' communityChallenge.exclude not an array`);
|
|
128569
128584
|
let authorPublicationCounts;
|
|
128570
|
-
let
|
|
128571
|
-
const getIdentityMatcher = () => identityMatcher ??= createAuthorIdentityMatcher({
|
|
128572
|
-
community,
|
|
128573
|
-
publication
|
|
128574
|
-
});
|
|
128585
|
+
let nameFailure;
|
|
128575
128586
|
for (const exclude of communityChallenge.exclude) {
|
|
128576
128587
|
if (typeof exclude.postScore !== "number" && typeof exclude.replyScore !== "number" && typeof exclude.postCount !== "number" && typeof exclude.replyCount !== "number" && typeof exclude.firstCommentTimestamp !== "number" && !exclude.publicKeys?.length && !exclude.names?.length && exclude.publicationType === void 0 && exclude.rateLimit === void 0 && !exclude.roles?.length) continue;
|
|
128577
128588
|
let shouldExclude = true;
|
|
@@ -128580,17 +128591,36 @@ const shouldExcludePublication = async (communityChallenge, request, community)
|
|
|
128580
128591
|
if (!testFirstCommentTimestamp(exclude.firstCommentTimestamp, author.community?.firstCommentTimestamp)) shouldExclude = false;
|
|
128581
128592
|
if (!testPublicationType(exclude.publicationType, request)) shouldExclude = false;
|
|
128582
128593
|
if (!testRateLimit(exclude, request)) shouldExclude = false;
|
|
128583
|
-
if (exclude.publicKeys && !exclude.publicKeys.includes(
|
|
128584
|
-
if (exclude.names && !await getIdentityMatcher().matchesAnyIdentity(exclude.names)) shouldExclude = false;
|
|
128585
|
-
if (Array.isArray(exclude.roles) && !await testRole(exclude.roles, getIdentityMatcher, community?.roles)) shouldExclude = false;
|
|
128594
|
+
if (exclude.publicKeys && !exclude.publicKeys.includes(identityMatcher.signerAddress)) shouldExclude = false;
|
|
128586
128595
|
if (typeof exclude.postCount === "number" || typeof exclude.replyCount === "number") {
|
|
128587
|
-
if (!authorPublicationCounts && community?._dbHandler) authorPublicationCounts = community._dbHandler.queryAuthorPublicationCounts(
|
|
128596
|
+
if (!authorPublicationCounts && community?._dbHandler) authorPublicationCounts = community._dbHandler.queryAuthorPublicationCounts(identityMatcher.signerAddress);
|
|
128588
128597
|
if (!testScore(exclude.postCount, authorPublicationCounts?.postCount)) shouldExclude = false;
|
|
128589
128598
|
if (!testScore(exclude.replyCount, authorPublicationCounts?.replyCount)) shouldExclude = false;
|
|
128590
128599
|
}
|
|
128591
|
-
if (shouldExclude)
|
|
128600
|
+
if (shouldExclude && exclude.names) {
|
|
128601
|
+
const namesMatch = await identityMatcher.matchesAnyIdentity(exclude.names);
|
|
128602
|
+
if (!namesMatch.matched) {
|
|
128603
|
+
shouldExclude = false;
|
|
128604
|
+
nameFailure ??= namesMatch.nameFailure;
|
|
128605
|
+
}
|
|
128606
|
+
}
|
|
128607
|
+
if (shouldExclude && Array.isArray(exclude.roles)) {
|
|
128608
|
+
const roleMatch = await testRole({
|
|
128609
|
+
excludeRole: exclude.roles,
|
|
128610
|
+
identityMatcher,
|
|
128611
|
+
communityRoles: community?.roles
|
|
128612
|
+
});
|
|
128613
|
+
if (!roleMatch.matched) {
|
|
128614
|
+
shouldExclude = false;
|
|
128615
|
+
nameFailure ??= roleMatch.nameFailure;
|
|
128616
|
+
}
|
|
128617
|
+
}
|
|
128618
|
+
if (shouldExclude) return { shouldExclude: true };
|
|
128592
128619
|
}
|
|
128593
|
-
return
|
|
128620
|
+
return {
|
|
128621
|
+
shouldExclude: false,
|
|
128622
|
+
nameFailure
|
|
128623
|
+
};
|
|
128594
128624
|
};
|
|
128595
128625
|
const shouldExcludeChallengeSuccess = (communityChallenge, communityChallengeIndex, challengeResults) => {
|
|
128596
128626
|
if (!communityChallenge) throw Error(`shouldExcludeChallengeSuccess invalid communityChallenge argument '${communityChallenge}'`);
|
|
@@ -128723,6 +128753,98 @@ const shouldExcludeChallengeCommentCids = async (communityChallenge, challengeRe
|
|
|
128723
128753
|
return false;
|
|
128724
128754
|
};
|
|
128725
128755
|
//#endregion
|
|
128756
|
+
//#region dist/node/runtime/node/community/local-community/author-identity.js
|
|
128757
|
+
const NO_MATCH = { matched: false };
|
|
128758
|
+
const MATCH = { matched: true };
|
|
128759
|
+
/**
|
|
128760
|
+
* The message a publisher is owed when their author name could not be verified: one remedy per outcome, and
|
|
128761
|
+
* one table for both places that classify a resolve, the identity matcher here and `checkAuthorIdentity`, so
|
|
128762
|
+
* the two can never disagree about the same failure. `error: null` is the resolvers answering "no record";
|
|
128763
|
+
* anything else is whatever the resolve threw. Issue #353.
|
|
128764
|
+
*/
|
|
128765
|
+
function authorNameResolveFailureReason({ error }) {
|
|
128766
|
+
if (error === null) return messages.ERR_AUTHOR_NAME_HAS_NO_RECORD;
|
|
128767
|
+
const code = error instanceof PKCError ? error.code : void 0;
|
|
128768
|
+
if (code === "ERR_NO_RESOLVER_FOR_NAME") return messages.ERR_COMMUNITY_HAS_NO_RESOLVER_FOR_AUTHOR_NAME_TLD;
|
|
128769
|
+
if (code === "ERR_RESOLVED_TEXT_RECORD_TO_NON_IPNS") return messages.ERR_AUTHOR_NAME_RECORD_IS_NOT_A_VALID_KEY;
|
|
128770
|
+
return messages.ERR_COMMUNITY_FAILED_TO_RESOLVE_AUTHOR_NAME;
|
|
128771
|
+
}
|
|
128772
|
+
/**
|
|
128773
|
+
* The matcher for an author nothing can refer to: no signature to derive an identity from, so every configured
|
|
128774
|
+
* identity string is a non-match, and a non-match with no `nameFailure` because no name was ever consulted.
|
|
128775
|
+
* Answering "no match" beats throwing from deep inside validation or the challenge runner.
|
|
128776
|
+
*/
|
|
128777
|
+
const NO_OP_AUTHOR_IDENTITY_MATCHER = {
|
|
128778
|
+
signerAddress: "",
|
|
128779
|
+
wireName: void 0,
|
|
128780
|
+
matchesIdentity: async () => NO_MATCH,
|
|
128781
|
+
matchesAnyIdentity: async () => NO_MATCH
|
|
128782
|
+
};
|
|
128783
|
+
function authorIdentityMatcherForRequest({ community, request }) {
|
|
128784
|
+
const publication = derivePublicationFromChallengeRequest(request);
|
|
128785
|
+
if (typeof publication?.signature?.publicKey !== "string") return NO_OP_AUTHOR_IDENTITY_MATCHER;
|
|
128786
|
+
return createAuthorIdentityMatcher({
|
|
128787
|
+
community,
|
|
128788
|
+
publication
|
|
128789
|
+
});
|
|
128790
|
+
}
|
|
128791
|
+
function createAuthorIdentityMatcher({ community, publication }) {
|
|
128792
|
+
const log = logger_default("pkc-js:local-community:author-identity");
|
|
128793
|
+
const signerAddress = getPKCAddressFromPublicKeySync(publication.signature.publicKey);
|
|
128794
|
+
const wireName = getAuthorNameFromWire(publication.author);
|
|
128795
|
+
let nameOutcomePromise;
|
|
128796
|
+
const nameResolvesToSigner = () => {
|
|
128797
|
+
if (!wireName || !isStringDomain(wireName)) return Promise.resolve(NO_MATCH);
|
|
128798
|
+
if (!nameOutcomePromise) nameOutcomePromise = (async () => {
|
|
128799
|
+
try {
|
|
128800
|
+
const { resolvedAuthorName } = await community._clientsManager.resolveAuthorNameIfNeeded({
|
|
128801
|
+
authorName: wireName,
|
|
128802
|
+
abortSignal: AbortSignal.timeout(community._pkc._timeouts["resolve-author-name"]),
|
|
128803
|
+
cache: { maxAge: 0 }
|
|
128804
|
+
});
|
|
128805
|
+
if (resolvedAuthorName === signerAddress) return MATCH;
|
|
128806
|
+
if (resolvedAuthorName === null) {
|
|
128807
|
+
log("Author name has no record while matching identity", wireName);
|
|
128808
|
+
return {
|
|
128809
|
+
matched: false,
|
|
128810
|
+
nameFailure: { reason: authorNameResolveFailureReason({ error: null }) }
|
|
128811
|
+
};
|
|
128812
|
+
}
|
|
128813
|
+
return NO_MATCH;
|
|
128814
|
+
} catch (e) {
|
|
128815
|
+
log("Failed to resolve author name while matching identity", wireName, e instanceof PKCError ? e.code : void 0, e);
|
|
128816
|
+
return {
|
|
128817
|
+
matched: false,
|
|
128818
|
+
nameFailure: {
|
|
128819
|
+
reason: authorNameResolveFailureReason({ error: e }),
|
|
128820
|
+
error: e
|
|
128821
|
+
}
|
|
128822
|
+
};
|
|
128823
|
+
}
|
|
128824
|
+
})();
|
|
128825
|
+
return nameOutcomePromise;
|
|
128826
|
+
};
|
|
128827
|
+
const matchesIdentity = async (identity) => {
|
|
128828
|
+
if (!isStringDomain(identity)) return identity === signerAddress ? MATCH : NO_MATCH;
|
|
128829
|
+
if (identity !== wireName) return NO_MATCH;
|
|
128830
|
+
return nameResolvesToSigner();
|
|
128831
|
+
};
|
|
128832
|
+
const matchesAnyIdentity = async (identities) => {
|
|
128833
|
+
let nameListed = false;
|
|
128834
|
+
for (const identity of identities) {
|
|
128835
|
+
if (identity === signerAddress) return MATCH;
|
|
128836
|
+
if (wireName && identity === wireName) nameListed = true;
|
|
128837
|
+
}
|
|
128838
|
+
return nameListed ? nameResolvesToSigner() : NO_MATCH;
|
|
128839
|
+
};
|
|
128840
|
+
return {
|
|
128841
|
+
signerAddress,
|
|
128842
|
+
wireName,
|
|
128843
|
+
matchesIdentity,
|
|
128844
|
+
matchesAnyIdentity
|
|
128845
|
+
};
|
|
128846
|
+
}
|
|
128847
|
+
//#endregion
|
|
128726
128848
|
//#region dist/node/runtime/node/community/challenges/pkc-js-challenges/text-math.js
|
|
128727
128849
|
const optionInputs$5 = [{
|
|
128728
128850
|
option: "difficulty",
|
|
@@ -128897,16 +129019,16 @@ var UrlsAddressesSet$1 = class {
|
|
|
128897
129019
|
}
|
|
128898
129020
|
};
|
|
128899
129021
|
const urlsAddressesSet$1 = new UrlsAddressesSet$1();
|
|
128900
|
-
const getChallenge$3 = async ({ challengeSettings, challengeRequestMessage, community }) => {
|
|
129022
|
+
const getChallenge$3 = async ({ challengeSettings, challengeRequestMessage, community, authorIdentityMatcher }) => {
|
|
128901
129023
|
const error = challengeSettings?.options?.error;
|
|
128902
129024
|
const addresses = challengeSettings?.options?.addresses?.split(",").map((u) => u.trim()).filter(Boolean);
|
|
128903
129025
|
const addressesSet = new Set(addresses);
|
|
128904
129026
|
const publication = derivePublicationFromChallengeRequest(challengeRequestMessage);
|
|
128905
|
-
const identityMatcher = createAuthorIdentityMatcher({
|
|
129027
|
+
const identityMatcher = authorIdentityMatcher ?? createAuthorIdentityMatcher({
|
|
128906
129028
|
community,
|
|
128907
129029
|
publication
|
|
128908
129030
|
});
|
|
128909
|
-
if (await identityMatcher.matchesAnyIdentity(addressesSet) || await identityMatcher.matchesAnyIdentity(await urlsAddressesSet$1.getAddresses(getCommunityAddressFromRecord(publication), challengeSettings?.options?.urls))) return {
|
|
129031
|
+
if ((await identityMatcher.matchesAnyIdentity(addressesSet)).matched || (await identityMatcher.matchesAnyIdentity(await urlsAddressesSet$1.getAddresses(getCommunityAddressFromRecord(publication), challengeSettings?.options?.urls))).matched) return {
|
|
128910
129032
|
success: false,
|
|
128911
129033
|
error: error || `You're blacklisted.`
|
|
128912
129034
|
};
|
|
@@ -128988,19 +129110,29 @@ var UrlsAddressesSet = class {
|
|
|
128988
129110
|
}
|
|
128989
129111
|
};
|
|
128990
129112
|
const urlsAddressesSet = new UrlsAddressesSet();
|
|
128991
|
-
const getChallenge$2 = async ({ challengeSettings, challengeRequestMessage, community }) => {
|
|
129113
|
+
const getChallenge$2 = async ({ challengeSettings, challengeRequestMessage, community, authorIdentityMatcher }) => {
|
|
128992
129114
|
const error = challengeSettings?.options?.error;
|
|
128993
129115
|
const addresses = challengeSettings?.options?.addresses?.split(",").map((u) => u.trim()).filter(Boolean);
|
|
128994
129116
|
const addressesSet = new Set(addresses);
|
|
128995
129117
|
const publication = derivePublicationFromChallengeRequest(challengeRequestMessage);
|
|
128996
|
-
const identityMatcher = createAuthorIdentityMatcher({
|
|
129118
|
+
const identityMatcher = authorIdentityMatcher ?? createAuthorIdentityMatcher({
|
|
128997
129119
|
community,
|
|
128998
129120
|
publication
|
|
128999
129121
|
});
|
|
129000
|
-
|
|
129001
|
-
|
|
129002
|
-
|
|
129003
|
-
|
|
129122
|
+
const directMatch = await identityMatcher.matchesAnyIdentity(addressesSet);
|
|
129123
|
+
const urlMatch = directMatch.matched ? directMatch : await identityMatcher.matchesAnyIdentity(await urlsAddressesSet.getAddresses(getCommunityAddressFromRecord(publication), challengeSettings?.options?.urls));
|
|
129124
|
+
if (!urlMatch.matched) {
|
|
129125
|
+
const nameFailure = directMatch.nameFailure ?? urlMatch.nameFailure;
|
|
129126
|
+
if (nameFailure) return {
|
|
129127
|
+
success: false,
|
|
129128
|
+
error: nameFailure.reason,
|
|
129129
|
+
reason: nameFailure.reason
|
|
129130
|
+
};
|
|
129131
|
+
return {
|
|
129132
|
+
success: false,
|
|
129133
|
+
error: error || `You're not whitelisted.`
|
|
129134
|
+
};
|
|
129135
|
+
}
|
|
129004
129136
|
return { success: true };
|
|
129005
129137
|
};
|
|
129006
129138
|
function ChallengeFileFactory$2({ challengeSettings }) {
|
|
@@ -129321,14 +129453,15 @@ const loadChallengeFile = async ({ communityChallengeSettings, challengeIndex, c
|
|
|
129321
129453
|
});
|
|
129322
129454
|
return { challengeFile };
|
|
129323
129455
|
};
|
|
129324
|
-
const callGetChallenge = async ({ challengeFile, communityChallengeSettings, challengeRequestMessage, challengeIndex, community }) => {
|
|
129456
|
+
const callGetChallenge = async ({ challengeFile, communityChallengeSettings, challengeRequestMessage, challengeIndex, community, authorIdentityMatcher }) => {
|
|
129325
129457
|
let challengeOrChallengeResult;
|
|
129326
129458
|
try {
|
|
129327
129459
|
challengeOrChallengeResult = await challengeFile.getChallenge({
|
|
129328
129460
|
challengeSettings: communityChallengeSettings,
|
|
129329
129461
|
challengeRequestMessage,
|
|
129330
129462
|
challengeIndex,
|
|
129331
|
-
community
|
|
129463
|
+
community,
|
|
129464
|
+
authorIdentityMatcher
|
|
129332
129465
|
});
|
|
129333
129466
|
validateChallengeOrChallengeResult({
|
|
129334
129467
|
challengeOrChallengeResult,
|
|
@@ -129411,7 +129544,11 @@ const canFailedChallengeStillBeExcluded = (i, communityChallenges, decided, resu
|
|
|
129411
129544
|
}
|
|
129412
129545
|
return false;
|
|
129413
129546
|
};
|
|
129414
|
-
const getPendingChallengesOrChallengeVerification = async ({ challengeRequestMessage, community }) => {
|
|
129547
|
+
const getPendingChallengesOrChallengeVerification = async ({ challengeRequestMessage, community, authorIdentityMatcher }) => {
|
|
129548
|
+
const identityMatcher = authorIdentityMatcher ?? authorIdentityMatcherForRequest({
|
|
129549
|
+
community,
|
|
129550
|
+
request: challengeRequestMessage
|
|
129551
|
+
});
|
|
129415
129552
|
if (!Array.isArray(community.settings?.challenges)) return {
|
|
129416
129553
|
challengeSuccess: true,
|
|
129417
129554
|
pendingApprovalSuccess: false
|
|
@@ -129428,12 +129565,23 @@ const getPendingChallengesOrChallengeVerification = async ({ challengeRequestMes
|
|
|
129428
129565
|
challengeIndex: i,
|
|
129429
129566
|
community
|
|
129430
129567
|
})).challengeFile));
|
|
129568
|
+
const identityNameFailureByIndex = new Array(challengeCount);
|
|
129431
129569
|
await Promise.all(communityChallenges.map(async (communityChallenge, i) => {
|
|
129432
|
-
|
|
129570
|
+
const excludeResult = await shouldExcludePublication({
|
|
129571
|
+
communityChallenge,
|
|
129572
|
+
request: challengeRequestMessage,
|
|
129573
|
+
community,
|
|
129574
|
+
identityMatcher
|
|
129575
|
+
});
|
|
129576
|
+
if (excludeResult.shouldExclude) {
|
|
129433
129577
|
decided[i] = true;
|
|
129434
129578
|
return;
|
|
129435
129579
|
}
|
|
129436
|
-
if (await shouldExcludeChallengeCommentCids(communityChallenge, challengeRequestMessage, community._pkc))
|
|
129580
|
+
if (await shouldExcludeChallengeCommentCids(communityChallenge, challengeRequestMessage, community._pkc)) {
|
|
129581
|
+
decided[i] = true;
|
|
129582
|
+
return;
|
|
129583
|
+
}
|
|
129584
|
+
identityNameFailureByIndex[i] = excludeResult.nameFailure;
|
|
129437
129585
|
}));
|
|
129438
129586
|
const deferred = new Array(challengeCount).fill(false);
|
|
129439
129587
|
let shortCircuitToFailure = false;
|
|
@@ -129466,7 +129614,8 @@ const getPendingChallengesOrChallengeVerification = async ({ challengeRequestMes
|
|
|
129466
129614
|
communityChallengeSettings: community.settings.challenges[i],
|
|
129467
129615
|
challengeRequestMessage,
|
|
129468
129616
|
challengeIndex: i,
|
|
129469
|
-
community
|
|
129617
|
+
community,
|
|
129618
|
+
authorIdentityMatcher: identityMatcher
|
|
129470
129619
|
})).challengeOrChallengeResult;
|
|
129471
129620
|
decided[i] = true;
|
|
129472
129621
|
}
|
|
@@ -129492,7 +129641,8 @@ const getPendingChallengesOrChallengeVerification = async ({ challengeRequestMes
|
|
|
129492
129641
|
communityChallengeSettings: community.settings.challenges[firstUndecided],
|
|
129493
129642
|
challengeRequestMessage,
|
|
129494
129643
|
challengeIndex: firstUndecided,
|
|
129495
|
-
community
|
|
129644
|
+
community,
|
|
129645
|
+
authorIdentityMatcher: identityMatcher
|
|
129496
129646
|
})).challengeOrChallengeResult;
|
|
129497
129647
|
decided[firstUndecided] = true;
|
|
129498
129648
|
}
|
|
@@ -129553,18 +129703,24 @@ const getPendingChallengesOrChallengeVerification = async ({ challengeRequestMes
|
|
|
129553
129703
|
if (challengeSuccess === false) return {
|
|
129554
129704
|
challengeSuccess,
|
|
129555
129705
|
challengeErrors,
|
|
129556
|
-
aggregatedReason: agg.aggregatedReason
|
|
129706
|
+
aggregatedReason: agg.aggregatedReason,
|
|
129707
|
+
identityNameFailureByIndex
|
|
129557
129708
|
};
|
|
129558
129709
|
return {
|
|
129559
129710
|
pendingChallenges,
|
|
129560
129711
|
pendingApprovalSuccess,
|
|
129561
129712
|
deferredChallenges: deferredChallenges.length > 0 ? deferredChallenges : void 0,
|
|
129562
129713
|
partialResults: results,
|
|
129563
|
-
communityChallenges
|
|
129714
|
+
communityChallenges,
|
|
129715
|
+
identityNameFailureByIndex
|
|
129564
129716
|
};
|
|
129565
129717
|
};
|
|
129566
|
-
const getChallengeVerificationFromChallengeAnswers = async ({ pendingChallenges, challengeAnswers, community, challengeRequestMessage, deferredChallenges, partialResults, communityChallenges }) => {
|
|
129718
|
+
const getChallengeVerificationFromChallengeAnswers = async ({ pendingChallenges, challengeAnswers, community, challengeRequestMessage, deferredChallenges, partialResults, communityChallenges, authorIdentityMatcher }) => {
|
|
129567
129719
|
if (!Array.isArray(community.settings?.challenges)) throw Error("community.settings?.challenges is not defined");
|
|
129720
|
+
const identityMatcher = authorIdentityMatcher ?? (challengeRequestMessage ? authorIdentityMatcherForRequest({
|
|
129721
|
+
community,
|
|
129722
|
+
request: challengeRequestMessage
|
|
129723
|
+
}) : NO_OP_AUTHOR_IDENTITY_MATCHER);
|
|
129568
129724
|
const challengeCount = community.settings.challenges.length;
|
|
129569
129725
|
const verifyChallengePromises = [];
|
|
129570
129726
|
for (const i in pendingChallenges) verifyChallengePromises.push(Promise.resolve(pendingChallenges[i].verify(challengeAnswers[i])));
|
|
@@ -129613,7 +129769,8 @@ const getChallengeVerificationFromChallengeAnswers = async ({ pendingChallenges,
|
|
|
129613
129769
|
communityChallengeSettings: community.settings.challenges[i],
|
|
129614
129770
|
challengeRequestMessage,
|
|
129615
129771
|
challengeIndex: i,
|
|
129616
|
-
community
|
|
129772
|
+
community,
|
|
129773
|
+
authorIdentityMatcher: identityMatcher
|
|
129617
129774
|
})).challengeOrChallengeResult;
|
|
129618
129775
|
decided[i] = true;
|
|
129619
129776
|
}
|
|
@@ -129640,7 +129797,8 @@ const getChallengeVerificationFromChallengeAnswers = async ({ pendingChallenges,
|
|
|
129640
129797
|
communityChallengeSettings: community.settings.challenges[firstUndecided],
|
|
129641
129798
|
challengeRequestMessage,
|
|
129642
129799
|
challengeIndex: firstUndecided,
|
|
129643
|
-
community
|
|
129800
|
+
community,
|
|
129801
|
+
authorIdentityMatcher: identityMatcher
|
|
129644
129802
|
})).challengeOrChallengeResult;
|
|
129645
129803
|
decided[firstUndecided] = true;
|
|
129646
129804
|
}
|
|
@@ -129683,19 +129841,29 @@ const getChallengeVerificationFromChallengeAnswers = async ({ pendingChallenges,
|
|
|
129683
129841
|
...successAgg
|
|
129684
129842
|
};
|
|
129685
129843
|
};
|
|
129686
|
-
const getChallengeVerification = async ({ challengeRequestMessage, community, getChallengeAnswers }) => {
|
|
129844
|
+
const getChallengeVerification = async ({ challengeRequestMessage, community, getChallengeAnswers, authorIdentityMatcher }) => {
|
|
129687
129845
|
if (!challengeRequestMessage) throw Error(`getChallengeVerification invalid challengeRequestMessage argument '${challengeRequestMessage}'`);
|
|
129688
129846
|
if (typeof community?._pkc?.getComment !== "function") throw Error(`getChallengeVerification invalid community argument '${community}' invalid community.pkc instance`);
|
|
129689
129847
|
if (typeof getChallengeAnswers !== "function") throw Error(`getChallengeVerification invalid getChallengeAnswers argument '${getChallengeAnswers}' not a function`);
|
|
129690
129848
|
if (!Array.isArray(community.settings?.challenges)) throw Error("community.settings?.challenges is not defined");
|
|
129691
129849
|
const res = await getPendingChallengesOrChallengeVerification({
|
|
129692
129850
|
challengeRequestMessage,
|
|
129693
|
-
community
|
|
129851
|
+
community,
|
|
129852
|
+
authorIdentityMatcher: authorIdentityMatcher ?? authorIdentityMatcherForRequest({
|
|
129853
|
+
community,
|
|
129854
|
+
request: challengeRequestMessage
|
|
129855
|
+
})
|
|
129694
129856
|
});
|
|
129695
129857
|
let pendingApprovalSuccess = "pendingApprovalSuccess" in res ? res.pendingApprovalSuccess : false;
|
|
129858
|
+
const identityNameFailureByIndex = "identityNameFailureByIndex" in res ? res.identityNameFailureByIndex : void 0;
|
|
129696
129859
|
let challengeVerification;
|
|
129860
|
+
let postAnswerAuthorIdentityMatcher;
|
|
129697
129861
|
if ("pendingChallenges" in res) {
|
|
129698
129862
|
const challengeAnswers = await getChallengeAnswers(res.pendingChallenges.map((challenge) => n$9(challenge, ["index", "verify"])));
|
|
129863
|
+
postAnswerAuthorIdentityMatcher = authorIdentityMatcherForRequest({
|
|
129864
|
+
community,
|
|
129865
|
+
request: challengeRequestMessage
|
|
129866
|
+
});
|
|
129699
129867
|
const verificationFromPending = await getChallengeVerificationFromChallengeAnswers({
|
|
129700
129868
|
pendingChallenges: res.pendingChallenges,
|
|
129701
129869
|
challengeAnswers,
|
|
@@ -129703,7 +129871,8 @@ const getChallengeVerification = async ({ challengeRequestMessage, community, ge
|
|
|
129703
129871
|
challengeRequestMessage,
|
|
129704
129872
|
deferredChallenges: res.deferredChallenges,
|
|
129705
129873
|
partialResults: res.partialResults,
|
|
129706
|
-
communityChallenges: res.communityChallenges
|
|
129874
|
+
communityChallenges: res.communityChallenges,
|
|
129875
|
+
authorIdentityMatcher: postAnswerAuthorIdentityMatcher
|
|
129707
129876
|
});
|
|
129708
129877
|
if ("pendingApprovalSuccess" in verificationFromPending) {
|
|
129709
129878
|
pendingApprovalSuccess = pendingApprovalSuccess || verificationFromPending.pendingApprovalSuccess;
|
|
@@ -129719,12 +129888,21 @@ const getChallengeVerification = async ({ challengeRequestMessage, community, ge
|
|
|
129719
129888
|
if ("aggregatedCommentUpdate" in res && res.aggregatedCommentUpdate) challengeVerification.aggregatedCommentUpdate = res.aggregatedCommentUpdate;
|
|
129720
129889
|
if ("aggregatedReason" in res && res.aggregatedReason) challengeVerification.aggregatedReason = res.aggregatedReason;
|
|
129721
129890
|
}
|
|
129891
|
+
const failedChallengeIndexes = Object.keys(challengeVerification.challengeErrors ?? {});
|
|
129892
|
+
const decisiveNameFailure = failedChallengeIndexes.length > 0 && identityNameFailureByIndex ? failedChallengeIndexes.every((index) => identityNameFailureByIndex[Number(index)]) ? identityNameFailureByIndex[Number(failedChallengeIndexes[0])] : void 0 : void 0;
|
|
129893
|
+
if (challengeVerification.challengeSuccess === false && decisiveNameFailure) challengeVerification.aggregatedReason = decisiveNameFailure.reason;
|
|
129722
129894
|
addToRateLimiter(community.settings?.challenges, challengeRequestMessage, challengeVerification.challengeSuccess);
|
|
129723
|
-
|
|
129895
|
+
const shouldSendToPendingApproval = Boolean(challengeRequestMessage.comment) && challengeVerification.challengeSuccess === true && pendingApprovalSuccess;
|
|
129896
|
+
const postAnswerMatcherField = postAnswerAuthorIdentityMatcher ? { postAnswerAuthorIdentityMatcher } : {};
|
|
129897
|
+
if (shouldSendToPendingApproval) return {
|
|
129898
|
+
...challengeVerification,
|
|
129899
|
+
pendingApproval: true,
|
|
129900
|
+
...postAnswerMatcherField
|
|
129901
|
+
};
|
|
129902
|
+
return {
|
|
129724
129903
|
...challengeVerification,
|
|
129725
|
-
|
|
129904
|
+
...postAnswerMatcherField
|
|
129726
129905
|
};
|
|
129727
|
-
return challengeVerification;
|
|
129728
129906
|
};
|
|
129729
129907
|
const derivePublicOptions = (communityChallengeSettings) => {
|
|
129730
129908
|
const { publicOptions, options } = communityChallengeSettings;
|
|
@@ -130389,4 +130567,4 @@ var RpcLocalCommunity = class extends RpcRemoteCommunity {
|
|
|
130389
130567
|
}
|
|
130390
130568
|
};
|
|
130391
130569
|
//#endregion
|
|
130392
|
-
export {
|
|
130570
|
+
export { findCommentInPageInstanceRecursively as $, RpcResolveAuthorNameResultSchema as $n, getIpfsKeyFromPrivateKey as $t, createKuboRpcClient as A, parsePKCUserOptionsSchemaWithPKCErrorIfItFails as An, verifyChallengeRequest as At, monitorCommunitiesDirectory as B, RpcCommentRepliesPageParamSchema as Bn, buildRuntimeAuthor as Bt, decryptEd25519AesGcmPublicKeyBuffer as C, parseCreateRemoteCommunityFunctionArgumentSchemaWithPKCErrorIfItFails as Cn, signCommentUpdate as Ct, backupCommunityDb as D, parseDecryptedChallengeVerification as Dn, signVote as Dt, BackupAbortError as E, parseDecryptedChallengeAnswerWithPKCErrorIfItFails as En, signCommunityEdit as Et, getDefaultCommunityDbConfig as F, parseVotePubsubMessagePublicationSchemaWithPKCErrorIfItFails as Fn, verifyCommentPubsubMessage as Ft, CommentClientsManager as G, RpcExportCommunityModLogsResultSchema as Gn, buildRuntimeCommunityFields as Gt, resolveDbPostsCidRefs as H, RpcCommunityPageParamSchema as Hn, getAuthorNameFromRuntime as Ht, getDefaultDataPath as I, RpcAnchorPublishPreparationResultSchema as In, verifyCommentUpdate as It, REPLY_REPLIES_SORT_TYPES as J, RpcFetchCidParamSchema as Jn, getCommunityPublicKeyFromWire as Jt, POSTS_SORT_TYPES as K, RpcExportCommunityParamSchema as Kn, getCommunityAddressFromRecord as Kt, getThumbnailPropsOfLink as L, RpcAuthorNameParamSchema as Ln, verifyCommunity as Lt, deriveCommentIpfsFromCommentTableRow as M, parseRpcCommentUpdateEventWithPKCErrorIfItFails as Mn, verifyCommentEdit as Mt, deriveDbPosts as N, parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails as Nn, verifyCommentIpfs as Nt, calculateExpectedSignatureSize as O, parseDecryptedChallengeWithPKCErrorIfItFails as On, verifyChallengeAnswer as Ot, deriveDbReplies as P, parseVoteChallengeRequestToEncryptSchemaWithPKCErrorIfItFails as Pn, verifyCommentModeration as Pt, extractCommunityRuntimeFieldsFromParsedPages as Q, RpcPublishedAnchorRecordResultSchema as Qn, getBufferedPKCAddressFromPublicKey as Qt, importSignerIntoKuboNode as R, RpcCancelExportParamSchema as Rn, verifyCommunityEdit as Rt, decryptEd25519AesGcm as S, parseCreatePKCWsServerOptionsSchemaWithPKCErrorIfItFails as Sn, signCommentModeration as St, encryptEd25519AesGcmPublicKeyBuffer as T, parseCreateVoteOptionsSchemaWithPKCErrorIfItFails as Tn, signCommunity as Tt, setNativeFunctions as U, RpcEditCommunityParamSchema as Un, getAuthorNameFromWire as Ut, moveCommunityDbToDeletedDirectory as V, RpcCommunityIdentifierParamSchema as Vn, cleanWireAuthor as Vt, tryToDeleteCommunitiesThatFailedToBeDeletedBefore as W, RpcExportCommunityModLogsParamSchema as Wn, normalizeCreatePublicationAuthor as Wt, buildPageRuntimeFields as X, RpcPublishAnchorRecordParamSchema as Xn, decode as Xt, TIMEFRAMES_TO_SECONDS as Y, RpcFetchCidResultSchema as Yn, normalizeCommunityInputFromCommunity as Yt, buildPagesRuntimeFields as Z, RpcPublishChallengeAnswersParamSchema as Zn, encode as Zt, decodeRpcChallengeRequestPubsubMsg as _, parseCreateCommentEditOptionsSchemaWithPKCErrorIfItFails as _n, STORAGE_KEYS as _r, signChallengeMessage as _t, loadChallengeFileFromCommunityChallengeSettings as a, parseCommentChallengeRequestToEncryptSchemaWithPKCErrorIfItFails as an, t$2 as ar, collectCrosspostAuthorsToResolve as at, createSigner as b, parseCreateCommunityEditPublicationOptionsSchemaWithPKCErrorIfItFails as bn, require_undici as br, signComment as bt, authorNameResolveFailureReason as c, parseCommentIpfsSchemaWithPKCErrorIfItFails as cn, t$5 as cr, PublicationClientsManager as ct, LRUCache as d, parseCommentPubsubMessagePublicationWithPKCErrorIfItFails as dn, t$7 as dr, pRetry as dt, getPKCAddressFromPublicKey as en, RpcSubscriptionIdResultSchema as er, iterateOverPageCidsToFindAllCids as et, RemoteCommunity as f, parseCommunityAddressWithPKCErrorIfItFails as fn, t$8 as fr, pLimit as ft, decodeRpcChallengePubsubMsg as g, parseCommunityIpfsSchemaPassthroughWithPKCErrorIfItFails as gn, NAME_RESOLVE_FAILED_RETRY_FLOOR_MS as gr, signChallengeAnswer as gt, decodeRpcChallengeAnswerPubsubMsg as h, parseCommunityEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails as hn, NAME_RESOLVED_TRUE_TTL_MS as hr, cleanUpBeforePublishing as ht, getCommunityChallengeFromCommunityChallengeSettings as i, parseCidStringSchemaWithPKCErrorIfItFails as in, effectiveMaxCrosspostDepth as ir, cloneCrosspostForRuntime as it, deleteOldCommunityInWindows as j, parseRpcCommentEventWithPKCErrorIfItFails as jn, verifyChallengeVerification as jt, calculateInlineRepliesBudget as k, parseJsonWithPKCErrorIfFails as kn, verifyChallengeMessage as kt, createAuthorIdentityMatcher as l, parseCommentModerationChallengeRequestToEncryptSchemaWithPKCErrorIfItFails as ln, n$5 as lr, PKCClientsManager as lt, KeyvBetterSqlite3 as m, parseCommunityEditOptionsSchemaWithPKCErrorIfItFails as mn, NAME_RESOLVED_FALSE_TTL_MS as mr, require_lib$1 as mt, RpcRemoteCommunity as n, getPublicKeyFromPrivateKey as nn, RpcUnsubscribeParamSchema as nr, RepliesPages as nt, pkcJsChallenges as o, parseCommentEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails as on, t$4 as or, extractCrosspostRuntimeFields as ot, MAX_FILE_SIZE_BYTES_FOR_COMMUNITY_IPFS as p, parseCommunityEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails as pn, stringify as pr, PKCTypedEmitter as pt, POST_REPLIES_SORT_TYPES as q, RpcExportCommunityResultSchema as qn, getCommunityNameFromWire$1 as qt, getChallengeVerification as r, createSchemaRowParser as rn, crosspostChainDepthUpTo as rr, applyNameResolvedCacheToCrosspost as rt, authorIdentityMatcherForRequest as s, parseCommentEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails as sn, r as sr, stripNameResolvedFromCrosspost as st, RpcLocalCommunity as t, getPKCAddressFromPublicKeySync as tn, RpcSuccessResultSchema as tr, parseRawPages as tt, TrackedInstanceRegistry as u, parseCommentModerationPubsubMessagePublicationSchemaWithPKCErrorIfItFails as un, n$6 as ur, InflightFetchManager as ut, decodeRpcChallengeVerificationPubsubMsg as v, parseCreateCommentModerationOptionsSchemaWithPKCErrorIfItFails as vn, require_lodash_merge as vr, signChallengeRequest as vt, encryptEd25519AesGcm as w, parseCreateRpcCommunityFunctionArgumentSchemaWithPKCErrorIfItFails as wn, signCommentUpdateForChallengeVerification as wt, createAnchorIpnsRecord as x, parseCreateNewLocalCommunityUserOptionsSchemaWithPKCErrorIfItFails as xn, signCommentEdit as xt, SignerWithPublicKeyAddress as y, parseCreateCommentOptionsSchemaWithPKCErrorIfItFails as yn, nativeFunctions$1 as yr, signChallengeVerification as yt, listCommunitiesSync as z, RpcCidParamSchema as zn, verifyVote as zt };
|