@pkcprotocol/pkc-js 0.0.142 → 0.0.144
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 +1 -0
- package/dist/browser/clients/base-client-manager.d.ts +7 -1
- package/dist/browser/clients/base-client-manager.js +106 -28
- package/dist/browser/clients/base-client-manager.js.map +1 -1
- package/dist/browser/clients/rpc-client/rpc-schema-util.d.ts +2 -0
- package/dist/browser/clients/rpc-client/schema.d.ts +2 -0
- package/dist/browser/community/community-client-manager.js +40 -24
- package/dist/browser/community/community-client-manager.js.map +1 -1
- package/dist/browser/community/schema.d.ts +19 -0
- package/dist/browser/community/schema.js +7 -3
- package/dist/browser/community/schema.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 +4 -0
- package/dist/browser/object-key-util.js +5 -1
- package/dist/browser/object-key-util.js.map +1 -1
- package/dist/browser/pages/pkc-js-page-sorts/top.js +2 -1
- package/dist/browser/pages/pkc-js-page-sorts/top.js.map +1 -1
- package/dist/browser/pages/schema.js +3 -1
- package/dist/browser/pages/schema.js.map +1 -1
- package/dist/browser/pkc/pkc.d.ts +2 -1
- package/dist/browser/pkc/pkc.js +12 -2
- package/dist/browser/pkc/pkc.js.map +1 -1
- package/dist/browser/publications/comment/comment-client-manager.js +5 -2
- package/dist/browser/publications/comment/comment-client-manager.js.map +1 -1
- package/dist/browser/publications/comment/comment.js +4 -1
- package/dist/browser/publications/comment/comment.js.map +1 -1
- package/dist/browser/publications/community-edit/schema.d.ts +8 -0
- package/dist/browser/pubsub-messages/schema.d.ts +4 -0
- package/dist/browser/rpc/src/lib/pkc-js/index.d.ts +2 -0
- package/dist/browser/rpc/src/schema.d.ts +12 -0
- package/dist/browser/runtime/node/community/db-handler.d.ts +3 -0
- package/dist/browser/runtime/node/community/db-handler.js +17 -2
- package/dist/browser/runtime/node/community/db-handler.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/comment-updates.d.ts +1 -0
- package/dist/browser/runtime/node/community/local-community/comment-updates.js +70 -19
- package/dist/browser/runtime/node/community/local-community/comment-updates.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/post-updates-bucket.d.ts +14 -0
- package/dist/browser/runtime/node/community/local-community/post-updates-bucket.js +206 -0
- package/dist/browser/runtime/node/community/local-community/post-updates-bucket.js.map +1 -0
- package/dist/browser/runtime/node/community/local-community.d.ts +1 -0
- package/dist/browser/runtime/node/community/local-community.js +4 -0
- package/dist/browser/runtime/node/community/local-community.js.map +1 -1
- package/dist/browser/runtime/node/community/page-sorts/index.js +10 -10
- package/dist/browser/runtime/node/community/page-sorts/index.js.map +1 -1
- package/dist/browser/schema/schema-util.d.ts +8 -0
- package/dist/browser/schema.d.ts +16 -0
- package/dist/browser/util/inflight-fetch-manager.d.ts +7 -2
- package/dist/browser/util/inflight-fetch-manager.js +49 -7
- package/dist/browser/util/inflight-fetch-manager.js.map +1 -1
- package/dist/browser/util.d.ts +1 -0
- package/dist/browser/util.js +23 -5
- package/dist/browser/util.js.map +1 -1
- package/dist/bundled/bundle-manifest.json +165 -123
- package/dist/bundled/challenges.js +1 -1
- package/dist/bundled/chunks/{helia-for-pkc-pBsoz9YH.js → helia-for-pkc--Xw7hTTu.js} +33 -33
- package/dist/bundled/chunks/{local-community-B9D4Iu_Q.js → local-community-CH8vMgTr.js} +1 -1
- package/dist/bundled/chunks/{local-community-B4rXLDqy.js → local-community-DCVtQSci.js} +282 -45
- package/dist/bundled/chunks/{node-CsvN3ADZ.js → node-Coyk7lC6.js} +13 -10
- package/dist/bundled/chunks/{page-sort-scoring-2Q6exRbl.js → page-sort-scoring-DaW6urZ2.js} +1 -1
- package/dist/bundled/chunks/{rpc-local-community-D3V1Sto-.js → rpc-local-community-KgRrTYjv.js} +154 -58
- package/dist/bundled/chunks/src-ABfmT8J2.js +2323 -0
- package/dist/bundled/chunks/src-BC60-Q7v.js +2 -0
- package/dist/bundled/chunks/src-BHqirG63.js +2 -0
- package/dist/bundled/chunks/{src-BggJ_InF.js → src-Bj5iE3qB.js} +2 -1999
- package/dist/bundled/chunks/src-CNab3O7M.js +2001 -0
- package/dist/bundled/chunks/{src-BsiPSkhv.js → src-ltPxiZKf.js} +1312 -3632
- package/dist/bundled/chunks/{util-DVrZupXz.js → util-BYT-7zVn.js} +24 -9
- package/dist/bundled/chunks/{util-LhCb7940.js → util-DN7FMpHT.js} +1 -1
- package/dist/bundled/chunks/{validate-package-factories-Bl2AyT4N.js → validate-package-factories-CPVyODKw.js} +2 -2
- package/dist/bundled/index.js +1 -1
- package/dist/bundled/page-sorts.js +1 -1
- package/dist/bundled/rpc/src/index.js +4 -4
- package/dist/node/clients/base-client-manager.d.ts +7 -1
- package/dist/node/clients/base-client-manager.js +106 -28
- package/dist/node/clients/base-client-manager.js.map +1 -1
- package/dist/node/clients/rpc-client/rpc-schema-util.d.ts +2 -0
- package/dist/node/clients/rpc-client/schema.d.ts +2 -0
- package/dist/node/community/community-client-manager.js +40 -24
- package/dist/node/community/community-client-manager.js.map +1 -1
- package/dist/node/community/schema.d.ts +19 -0
- package/dist/node/community/schema.js +7 -3
- package/dist/node/community/schema.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 +4 -0
- package/dist/node/object-key-util.js +5 -1
- package/dist/node/object-key-util.js.map +1 -1
- package/dist/node/pages/pkc-js-page-sorts/top.js +2 -1
- package/dist/node/pages/pkc-js-page-sorts/top.js.map +1 -1
- package/dist/node/pages/schema.js +3 -1
- package/dist/node/pages/schema.js.map +1 -1
- package/dist/node/pkc/pkc.d.ts +2 -1
- package/dist/node/pkc/pkc.js +12 -2
- package/dist/node/pkc/pkc.js.map +1 -1
- package/dist/node/publications/comment/comment-client-manager.js +5 -2
- package/dist/node/publications/comment/comment-client-manager.js.map +1 -1
- package/dist/node/publications/comment/comment.js +4 -1
- package/dist/node/publications/comment/comment.js.map +1 -1
- package/dist/node/publications/community-edit/schema.d.ts +8 -0
- package/dist/node/pubsub-messages/schema.d.ts +4 -0
- package/dist/node/rpc/src/lib/pkc-js/index.d.ts +2 -0
- package/dist/node/rpc/src/schema.d.ts +12 -0
- package/dist/node/runtime/node/community/db-handler.d.ts +3 -0
- package/dist/node/runtime/node/community/db-handler.js +17 -2
- package/dist/node/runtime/node/community/db-handler.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/comment-updates.d.ts +1 -0
- package/dist/node/runtime/node/community/local-community/comment-updates.js +70 -19
- package/dist/node/runtime/node/community/local-community/comment-updates.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/post-updates-bucket.d.ts +14 -0
- package/dist/node/runtime/node/community/local-community/post-updates-bucket.js +206 -0
- package/dist/node/runtime/node/community/local-community/post-updates-bucket.js.map +1 -0
- package/dist/node/runtime/node/community/local-community.d.ts +1 -0
- package/dist/node/runtime/node/community/local-community.js +4 -0
- package/dist/node/runtime/node/community/local-community.js.map +1 -1
- package/dist/node/runtime/node/community/page-sorts/index.js +10 -10
- package/dist/node/runtime/node/community/page-sorts/index.js.map +1 -1
- package/dist/node/schema/schema-util.d.ts +8 -0
- package/dist/node/schema.d.ts +16 -0
- package/dist/node/util/inflight-fetch-manager.d.ts +7 -2
- package/dist/node/util/inflight-fetch-manager.js +49 -7
- package/dist/node/util/inflight-fetch-manager.js.map +1 -1
- package/dist/node/util.d.ts +1 -0
- package/dist/node/util.js +23 -5
- package/dist/node/util.js.map +1 -1
- package/package.json +4 -1
package/dist/bundled/chunks/{rpc-local-community-D3V1Sto-.js → rpc-local-community-KgRrTYjv.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 { $n as CommentEditSignedPropertyNames, $r as record, $t as CommunityEditPubsubMessagePublicationSchema, A as isIpnsPath, An as CommentChallengeRequestToEncryptSchema, Ar as t$9, At as pTimeout, B as pubsubTopicToDhtKey, Bn as CommentUpdateSchema, Br as logger_default, C as hideClassPrivateProps, Cn as RpcRemoteCommunityUpdateEventResultSchema, Cr as e$5, D as isIpfsCid, Dr as n$8, Dt as untrackUpdatingCommunity, E as isAbortError, En as VotePubsubMessagePublicationSchema, Er as t$12, Fn as CommentSignedPropertyNames, Fr as FailedToFetchCommunityFromGatewaysError, Gn as GetPageParamSchema, Gr as array, Gt as NameResolverSerializedSchema, H as raceAgainstAbort, Hr as require_ms$1, Ht as DecryptedChallengeSchema, In as CommentUpdateChallengeReservedFieldNames, Ir as FailedToFetchGenericIpfsFromGatewaysError, It as ChallengeRequestMessageSignedPropertyNames, Jn as isReservedObjectKey, Jr as literal, Jt as PKCUserOptionsSchema, Kn as ModQueuePageIpfsSchema, Kr as boolean, Kt as PKCParsedOptionsSchema, L as isRequestPubsubPublicationOfPost, Lr as FailedToFetchPageIpfsFromGatewaysError, Mn as CommentIpfsSchema, Mr as require_retry$2, Mt as ChallengeAnswerMessageSignedPropertyNames, Nr as FailedToFetchCommentIpfsFromGatewaysError, O as isIpfsPath, On as VoteSignedPropertyNames, Or as r$7, Ot as require_sha256$1, Pn as CommentPubsubMessageWithFlexibleAuthorRefinementSchema, Pr as FailedToFetchCommentUpdateFromGatewaysError, Pt as ChallengeMessageSignedPropertyNames, Qr as preprocess, Qt as CommunityEditPublicationSignedPropertyNames, R as isRequestPubsubPublicationOfReply, Rn as CommentUpdateForChallengeVerificationSignedPropertyNames, Rr as PKCError, Rt as ChallengeVerificationMessageSignedPropertyNames, S as hasTransientNetworkErrorCode, Sr as e$6, St as trackStartedCommunity, T as ipnsNameToIpnsOverPubsubTopic, Tn as VoteChallengeRequestToEncryptSchema, Tr as r$8, Tt as untrackStartedCommunity, Ut as DecryptedChallengeVerificationSchema, Vn as CommentUpdateSignedPropertyNames, Vr as require_supports_color, Wn as CreateCommentOptionsWithRefinementSchema, Wr as _enum, Wt as NameResolveCacheOptionsSchema, Xr as number, Xt as CommunityEditPublicationChallengeRequestToEncryptSchema, Yn as CommentEditChallengeRequestToEncryptSchema, Yr as looseObject, Zn as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema, Zr as object, _n as CreateRemoteCommunityFunctionArgumentSchema, _r as n$9, an as CommentModerationsTableRowSchema, ar as AuthorReservedFields, at as throwIfAbortSignalAborted, bn as PageSortFileFactorySchema, bt as refreshTrackedCommunityAliases, cn as ChallengeFileSchema, cr as CidStringSchema, d as deepMergeRuntimeFields, dn as CommunityEditOptionsSchema, dr as CreateSignerSchema, ei as string, en as CreateCommunityEditPublicationOptionsWithRefinementSchema, f as derivePublicationFromChallengeRequest, fn as CommunityExportRecordsSchema, fr as JsonSignatureSchema, ft as findStartedCommunity, gn as CreateNewLocalCommunityUserOptionsSchema, gr as isStringDomain, h as fetchAndValidateIpnsRecordFromGateway, hn as CommunitySignedPropertyNames, hr as areEquivalentNames, ht as forgetTrackedUpdatingCommunityName, in as CommentModerationSignedPropertyNames, ir as AuthorPubsubSchema, jn as CommentIpfsReservedFields, jr as e$4, k as isIpns, kr as t$10, lr as CommunityAddressSchema, m as extractNetworkErrorDetails, mn as CommunityIpfsSchema, mr as ProtocolVersionSchema, mt as findUpdatingCommunity, nn as CommentModerationPubsubMessagePublicationSchema, nr as AuthorAddressSchema, nt as shortifyCid, on as CreateCommentModerationOptionsWithRefinementSchema, or as ChallengeAnswersSchema, ot as timestamp, p as doesDomainAddressHaveCapitalLetter, pn as CommunityIpfsReservedFields, pr as PKCTimestampSchema, q as removeNullUndefinedEmptyObjectsValuesRecursively, qn as PageIpfsSchema, qr as custom, qt as PKCUserOptionBaseSchema, r as calculateIpfsCidV0, rr as AuthorCommentIpfsReservedFields, rt as sleepUntilTimeoutOrAbort, sn as ChallengeFileFactorySchema, sr as CidPathSchema, t as areEquivalentCommunityAddresses, ti as union, tn as CommentModerationChallengeRequestToEncryptSchema, tr as CreateCommentEditOptionsWithRefinementSchema, tt as shortifyAddress, u as createAbortError, un as CommunityChallengeSettingSchema, ur as CommunityAuthorChallengeReservedFieldNames, vn as CreateRpcCommunityFunctionArgumentSchema, w as interruptibleSleep, wn as CreateVoteUserOptionsWithRefinementSchema, wr as t$11, wt as trackUpdatingCommunity, xn as PageSortFileSchema, xr as t$13, yn as ExportCommunityModLogsOptionsSchema, yr as n$10, z as linkAbortSignals, zn as CommentUpdateReservedFields, zr as messages, zt as DecryptedChallengeAnswerSchema } from "./util-
|
|
2
|
+
import { $n as CommentEditSignedPropertyNames, $r as record, $t as CommunityEditPubsubMessagePublicationSchema, A as isIpnsPath, An as CommentChallengeRequestToEncryptSchema, Ar as t$9, At as pTimeout, B as pubsubTopicToDhtKey, Bn as CommentUpdateSchema, Br as logger_default, C as hideClassPrivateProps, Cn as RpcRemoteCommunityUpdateEventResultSchema, Cr as e$5, D as isIpfsCid, Dr as n$8, Dt as untrackUpdatingCommunity, E as isAbortError, En as VotePubsubMessagePublicationSchema, Er as t$12, Fn as CommentSignedPropertyNames, Fr as FailedToFetchCommunityFromGatewaysError, Gn as GetPageParamSchema, Gr as array, Gt as NameResolverSerializedSchema, H as raceAgainstAbort, Hr as require_ms$1, Ht as DecryptedChallengeSchema, In as CommentUpdateChallengeReservedFieldNames, Ir as FailedToFetchGenericIpfsFromGatewaysError, It as ChallengeRequestMessageSignedPropertyNames, Jn as isReservedObjectKey, Jr as literal, Jt as PKCUserOptionsSchema, Kn as ModQueuePageIpfsSchema, Kr as boolean, Kt as PKCParsedOptionsSchema, L as isRequestPubsubPublicationOfPost, Lr as FailedToFetchPageIpfsFromGatewaysError, Mn as CommentIpfsSchema, Mr as require_retry$2, Mt as ChallengeAnswerMessageSignedPropertyNames, Nr as FailedToFetchCommentIpfsFromGatewaysError, O as isIpfsPath, On as VoteSignedPropertyNames, Or as r$7, Ot as require_sha256$1, Pn as CommentPubsubMessageWithFlexibleAuthorRefinementSchema, Pr as FailedToFetchCommentUpdateFromGatewaysError, Pt as ChallengeMessageSignedPropertyNames, Qr as preprocess, Qt as CommunityEditPublicationSignedPropertyNames, R as isRequestPubsubPublicationOfReply, Rn as CommentUpdateForChallengeVerificationSignedPropertyNames, Rr as PKCError, Rt as ChallengeVerificationMessageSignedPropertyNames, S as hasTransientNetworkErrorCode, Sr as e$6, St as trackStartedCommunity, T as ipnsNameToIpnsOverPubsubTopic, Tn as VoteChallengeRequestToEncryptSchema, Tr as r$8, Tt as untrackStartedCommunity, Ut as DecryptedChallengeVerificationSchema, Vn as CommentUpdateSignedPropertyNames, Vr as require_supports_color, Wn as CreateCommentOptionsWithRefinementSchema, Wr as _enum, Wt as NameResolveCacheOptionsSchema, Xr as number, Xt as CommunityEditPublicationChallengeRequestToEncryptSchema, Yn as CommentEditChallengeRequestToEncryptSchema, Yr as looseObject, Zn as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema, Zr as object, _n as CreateRemoteCommunityFunctionArgumentSchema, _r as n$9, an as CommentModerationsTableRowSchema, ar as AuthorReservedFields, at as throwIfAbortSignalAborted, bn as PageSortFileFactorySchema, bt as refreshTrackedCommunityAliases, cn as ChallengeFileSchema, cr as CidStringSchema, d as deepMergeRuntimeFields, dn as CommunityEditOptionsSchema, dr as CreateSignerSchema, ei as string, en as CreateCommunityEditPublicationOptionsWithRefinementSchema, f as derivePublicationFromChallengeRequest, fn as CommunityExportRecordsSchema, fr as JsonSignatureSchema, ft as findStartedCommunity, gn as CreateNewLocalCommunityUserOptionsSchema, gr as isStringDomain, h as fetchAndValidateIpnsRecordFromGateway, hn as CommunitySignedPropertyNames, hr as areEquivalentNames, ht as forgetTrackedUpdatingCommunityName, in as CommentModerationSignedPropertyNames, ir as AuthorPubsubSchema, jn as CommentIpfsReservedFields, jr as e$4, k as isIpns, kr as t$10, lr as CommunityAddressSchema, m as extractNetworkErrorDetails, mn as CommunityIpfsSchema, mr as ProtocolVersionSchema, mt as findUpdatingCommunity, nn as CommentModerationPubsubMessagePublicationSchema, nr as AuthorAddressSchema, nt as shortifyCid, on as CreateCommentModerationOptionsWithRefinementSchema, or as ChallengeAnswersSchema, ot as timestamp, p as doesDomainAddressHaveCapitalLetter, pn as CommunityIpfsReservedFields, pr as PKCTimestampSchema, q as removeNullUndefinedEmptyObjectsValuesRecursively, qn as PageIpfsSchema, qr as custom, qt as PKCUserOptionBaseSchema, r as calculateIpfsCidV0, rr as AuthorCommentIpfsReservedFields, rt as sleepUntilTimeoutOrAbort, sn as ChallengeFileFactorySchema, sr as CidPathSchema, t as areEquivalentCommunityAddresses, ti as union, tn as CommentModerationChallengeRequestToEncryptSchema, tr as CreateCommentEditOptionsWithRefinementSchema, tt as shortifyAddress, u as createAbortError, un as CommunityChallengeSettingSchema, ur as CommunityAuthorChallengeReservedFieldNames, vn as CreateRpcCommunityFunctionArgumentSchema, w as interruptibleSleep, wn as CreateVoteUserOptionsWithRefinementSchema, wr as t$11, wt as trackUpdatingCommunity, xn as PageSortFileSchema, xr as t$13, yn as ExportCommunityModLogsOptionsSchema, yr as n$10, z as linkAbortSignals, zn as CommentUpdateReservedFields, zr as messages, zt as DecryptedChallengeAnswerSchema } from "./util-BYT-7zVn.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-DaW6urZ2.js";
|
|
5
5
|
import { createHash } from "node:crypto";
|
|
6
6
|
import { pathToFileURL } from "node:url";
|
|
7
7
|
import dns from "node:dns";
|
|
@@ -118106,7 +118106,7 @@ async function moveCommunityDbToDeletedDirectory(communityAddress, pkc) {
|
|
|
118106
118106
|
}
|
|
118107
118107
|
async function createKuboRpcClient(kuboRpcClientOptions) {
|
|
118108
118108
|
logger_default("pkc-js:pkc:createKuboRpcClient").trace("Creating a new kubo client on node with options", kuboRpcClientOptions);
|
|
118109
|
-
const { create: CreateKuboRpcClient } = await import("./src-
|
|
118109
|
+
const { create: CreateKuboRpcClient } = await import("./src-ltPxiZKf.js");
|
|
118110
118110
|
const Agent$2 = typeof kuboRpcClientOptions.url === "string" && kuboRpcClientOptions.url.startsWith("https") || kuboRpcClientOptions?.protocol === "https" || kuboRpcClientOptions.url instanceof URL && kuboRpcClientOptions?.url?.protocol === "https:" || kuboRpcClientOptions.url?.toString()?.includes("https") ? Agent : Agent$1;
|
|
118111
118111
|
const onehourMs = 1e3 * 60 * 60;
|
|
118112
118112
|
return CreateKuboRpcClient({
|
|
@@ -148034,14 +148034,15 @@ async function pRetry(input, options = {}) {
|
|
|
148034
148034
|
//#endregion
|
|
148035
148035
|
//#region dist/node/util/inflight-fetch-manager.js
|
|
148036
148036
|
var InflightFetchManager = class {
|
|
148037
|
-
constructor() {
|
|
148037
|
+
constructor({ isDestroyed } = {}) {
|
|
148038
148038
|
this._inflightFetches = /* @__PURE__ */ new Map();
|
|
148039
|
+
this._isDestroyed = isDestroyed ?? (() => false);
|
|
148039
148040
|
}
|
|
148040
148041
|
_getKey(resourceType, identifier) {
|
|
148041
148042
|
return `${resourceType}::${identifier}`;
|
|
148042
148043
|
}
|
|
148043
|
-
async withKey(key, fetcher) {
|
|
148044
|
-
|
|
148044
|
+
async withKey(key, fetcher, abortSignal) {
|
|
148045
|
+
const inflight = this._inflightFetches.get(key);
|
|
148045
148046
|
if (!inflight) {
|
|
148046
148047
|
let fetchPromiseRef;
|
|
148047
148048
|
const fetchPromise = (async () => {
|
|
@@ -148055,14 +148056,38 @@ var InflightFetchManager = class {
|
|
|
148055
148056
|
})();
|
|
148056
148057
|
fetchPromiseRef = fetchPromise;
|
|
148057
148058
|
this._inflightFetches.set(key, fetchPromise);
|
|
148058
|
-
|
|
148059
|
+
return fetchPromise;
|
|
148060
|
+
}
|
|
148061
|
+
try {
|
|
148062
|
+
return await this._waitUnlessAborted(inflight, abortSignal);
|
|
148063
|
+
} catch (e) {
|
|
148064
|
+
if (!(e instanceof Error && e.name === "AbortError") || abortSignal?.aborted || this._isDestroyed()) throw e;
|
|
148065
|
+
if (this._inflightFetches.get(key) === inflight) this._inflightFetches.delete(key);
|
|
148066
|
+
return this.withKey(key, fetcher, abortSignal);
|
|
148059
148067
|
}
|
|
148060
|
-
return inflight;
|
|
148061
148068
|
}
|
|
148062
|
-
async
|
|
148069
|
+
async _waitUnlessAborted(inflight, abortSignal) {
|
|
148070
|
+
if (!abortSignal) return inflight;
|
|
148071
|
+
let onAbort;
|
|
148072
|
+
try {
|
|
148073
|
+
return await Promise.race([inflight, new Promise((_, reject) => {
|
|
148074
|
+
const rejectWithAbort = () => {
|
|
148075
|
+
const error = /* @__PURE__ */ new Error("The caller that joined this fetch was stopped");
|
|
148076
|
+
error.name = "AbortError";
|
|
148077
|
+
reject(error);
|
|
148078
|
+
};
|
|
148079
|
+
if (abortSignal.aborted) return rejectWithAbort();
|
|
148080
|
+
onAbort = rejectWithAbort;
|
|
148081
|
+
abortSignal.addEventListener("abort", onAbort, { once: true });
|
|
148082
|
+
})]);
|
|
148083
|
+
} finally {
|
|
148084
|
+
if (onAbort) abortSignal.removeEventListener("abort", onAbort);
|
|
148085
|
+
}
|
|
148086
|
+
}
|
|
148087
|
+
async withResource(resourceType, identifier, fetcher, abortSignal) {
|
|
148063
148088
|
if (!resourceType) throw new Error("resourceType is required for inflight fetches");
|
|
148064
148089
|
if (typeof identifier !== "string" || identifier.length === 0) throw new Error("identifier is required for inflight fetches and must be a string");
|
|
148065
|
-
return this.withKey(this._getKey(resourceType, identifier), fetcher);
|
|
148090
|
+
return this.withKey(this._getKey(resourceType, identifier), fetcher, abortSignal);
|
|
148066
148091
|
}
|
|
148067
148092
|
};
|
|
148068
148093
|
const InflightResourceTypes = {
|
|
@@ -148116,6 +148141,23 @@ const createUrlFromSubdomainResolution = (gateway, opts) => {
|
|
|
148116
148141
|
};
|
|
148117
148142
|
const GATEWAYS_THAT_SUPPORT_SUBDOMAIN_RESOLUTION = {};
|
|
148118
148143
|
const MAX_CONCURRENT_AUTHOR_NAME_RESOLUTIONS = 100;
|
|
148144
|
+
const waitForAuthorNameResolveInFlight = ({ inFlightResolve, abortSignal }) => new Promise((resolve) => {
|
|
148145
|
+
if (abortSignal?.aborted) return resolve("aborted");
|
|
148146
|
+
const onAbort = () => finish("aborted");
|
|
148147
|
+
const finish = (outcome) => {
|
|
148148
|
+
inFlightResolve.joiners.delete(finish);
|
|
148149
|
+
if (abortSignal) {
|
|
148150
|
+
inFlightResolve.callers.delete(abortSignal);
|
|
148151
|
+
abortSignal.removeEventListener("abort", onAbort);
|
|
148152
|
+
}
|
|
148153
|
+
resolve(outcome);
|
|
148154
|
+
};
|
|
148155
|
+
inFlightResolve.joiners.add(finish);
|
|
148156
|
+
if (abortSignal) {
|
|
148157
|
+
inFlightResolve.callers.add(abortSignal);
|
|
148158
|
+
abortSignal.addEventListener("abort", onAbort, { once: true });
|
|
148159
|
+
}
|
|
148160
|
+
});
|
|
148119
148161
|
var BaseClientsManager = class BaseClientsManager {
|
|
148120
148162
|
constructor(pkc) {
|
|
148121
148163
|
this.pubsubProviderSubscriptions = {};
|
|
@@ -148486,16 +148528,23 @@ var BaseClientsManager = class BaseClientsManager {
|
|
|
148486
148528
|
throwIfAbortSignalAborted(loadOpts.abortSignal);
|
|
148487
148529
|
loadOpts.abortSignal.addEventListener("abort", onParentAbort, { once: true });
|
|
148488
148530
|
}
|
|
148489
|
-
for (const gateway of gatewaysSorted) {
|
|
148531
|
+
for (const [i, gateway] of gatewaysSorted.entries()) {
|
|
148490
148532
|
const abortController = new AbortController();
|
|
148491
|
-
|
|
148533
|
+
const gatewayFetch = {
|
|
148492
148534
|
abortController,
|
|
148493
|
-
|
|
148535
|
+
timeoutId: void 0
|
|
148536
|
+
};
|
|
148537
|
+
gatewayFetches[gateway] = gatewayFetch;
|
|
148538
|
+
const armTimeout = () => gatewayFetch.timeoutId = setTimeout(() => abortController.abort("Gateway request timed out"), timeoutMs);
|
|
148539
|
+
const startsAtOnce = i < concurrencyLimit;
|
|
148540
|
+
if (startsAtOnce) armTimeout();
|
|
148541
|
+
gatewayFetch.promise = queueLimit(() => {
|
|
148542
|
+
if (!startsAtOnce && !abortController.signal.aborted) armTimeout();
|
|
148543
|
+
return this._fetchWithGateway(gateway, {
|
|
148494
148544
|
...loadOpts,
|
|
148495
148545
|
abortController
|
|
148496
|
-
})
|
|
148497
|
-
|
|
148498
|
-
};
|
|
148546
|
+
});
|
|
148547
|
+
});
|
|
148499
148548
|
}
|
|
148500
148549
|
const gatewayPromises = Object.values(gatewayFetches).map((fetching) => fetching.promise);
|
|
148501
148550
|
const res = await Promise.race([this._firstResolve(gatewayPromises), Promise.allSettled(gatewayPromises)]);
|
|
@@ -148872,6 +148921,7 @@ var BaseClientsManager = class BaseClientsManager {
|
|
|
148872
148921
|
const failedRecently = this._pkc._memCaches.nameResolveFailedCache;
|
|
148873
148922
|
const seen = /* @__PURE__ */ new Set();
|
|
148874
148923
|
const toResolve = [];
|
|
148924
|
+
const joined = [];
|
|
148875
148925
|
for (const { authorName, signaturePublicKey } of authors) {
|
|
148876
148926
|
if (!isStringDomain(authorName)) continue;
|
|
148877
148927
|
if (!this.canResolveName(authorName)) continue;
|
|
@@ -148879,21 +148929,30 @@ var BaseClientsManager = class BaseClientsManager {
|
|
|
148879
148929
|
if (seen.has(cacheKey)) continue;
|
|
148880
148930
|
seen.add(cacheKey);
|
|
148881
148931
|
if (typeof verificationCache.get(cacheKey) === "boolean") continue;
|
|
148882
|
-
|
|
148932
|
+
const inFlightResolve = inFlight.get(cacheKey);
|
|
148933
|
+
if (inFlightResolve) {
|
|
148934
|
+
if (!abortSignal || !inFlightResolve.callers.has(abortSignal)) joined.push({
|
|
148935
|
+
author: {
|
|
148936
|
+
authorName,
|
|
148937
|
+
signaturePublicKey
|
|
148938
|
+
},
|
|
148939
|
+
inFlightResolve
|
|
148940
|
+
});
|
|
148941
|
+
continue;
|
|
148942
|
+
}
|
|
148883
148943
|
if (failedRecently.get(cacheKey)) continue;
|
|
148884
|
-
inFlight.add(cacheKey);
|
|
148885
148944
|
toResolve.push({
|
|
148886
148945
|
authorName,
|
|
148887
148946
|
signaturePublicKey,
|
|
148888
148947
|
cacheKey
|
|
148889
148948
|
});
|
|
148890
148949
|
}
|
|
148891
|
-
if (toResolve.length === 0) return;
|
|
148950
|
+
if (toResolve.length === 0 && joined.length === 0) return;
|
|
148892
148951
|
const setVerdict = (cacheKey, verdict) => verdict ? verificationCache.set(cacheKey, true, { ttl: this._pkc._nameResolvedTrueTtlMs }) : verificationCache.set(cacheKey, false, { ttl: this._pkc._nameResolvedFalseTtlMs });
|
|
148893
148952
|
const limit = pLimit(MAX_CONCURRENT_AUTHOR_NAME_RESOLUTIONS);
|
|
148894
148953
|
const resolveOne = async (entry) => {
|
|
148895
148954
|
try {
|
|
148896
|
-
if (abortSignal?.aborted) return
|
|
148955
|
+
if (abortSignal?.aborted) return "aborted";
|
|
148897
148956
|
const { resolvedAuthorName: resolved } = await this.resolveAuthorNameIfNeeded({
|
|
148898
148957
|
authorName: entry.authorName,
|
|
148899
148958
|
abortSignal,
|
|
@@ -148901,26 +148960,49 @@ var BaseClientsManager = class BaseClientsManager {
|
|
|
148901
148960
|
});
|
|
148902
148961
|
if (typeof resolved !== "string") {
|
|
148903
148962
|
setVerdict(entry.cacheKey, false);
|
|
148904
|
-
return
|
|
148963
|
+
return "verdict";
|
|
148905
148964
|
}
|
|
148906
148965
|
const signerAddress = await getPKCAddressFromPublicKey(entry.signaturePublicKey);
|
|
148907
148966
|
setVerdict(entry.cacheKey, resolved === signerAddress);
|
|
148908
|
-
return
|
|
148967
|
+
return "verdict";
|
|
148909
148968
|
} catch (e) {
|
|
148910
|
-
if (isAbortError(e)) return
|
|
148969
|
+
if (isAbortError(e)) return "aborted";
|
|
148911
148970
|
if (e instanceof PKCError && e.code === "ERR_RESOLVED_TEXT_RECORD_TO_NON_IPNS") {
|
|
148912
148971
|
setVerdict(entry.cacheKey, false);
|
|
148913
|
-
return
|
|
148972
|
+
return "verdict";
|
|
148914
148973
|
}
|
|
148915
148974
|
log.error("Failed to resolve author name in background", entry.authorName, e);
|
|
148916
148975
|
failedRecently.set(entry.cacheKey, true, { ttl: this._pkc._nameResolveFailedRetryFloorMs });
|
|
148917
|
-
return
|
|
148918
|
-
} finally {
|
|
148919
|
-
inFlight.delete(entry.cacheKey);
|
|
148976
|
+
return "failed";
|
|
148920
148977
|
}
|
|
148921
148978
|
};
|
|
148922
|
-
|
|
148923
|
-
|
|
148979
|
+
const ownAttempts = toResolve.map((entry) => {
|
|
148980
|
+
const inFlightResolve = {
|
|
148981
|
+
callers: new Set(abortSignal ? [abortSignal] : []),
|
|
148982
|
+
joiners: /* @__PURE__ */ new Set()
|
|
148983
|
+
};
|
|
148984
|
+
inFlight.set(entry.cacheKey, inFlightResolve);
|
|
148985
|
+
const settle = (outcome) => {
|
|
148986
|
+
if (inFlight.get(entry.cacheKey) === inFlightResolve) inFlight.delete(entry.cacheKey);
|
|
148987
|
+
for (const joiner of inFlightResolve.joiners) joiner(outcome);
|
|
148988
|
+
return outcome;
|
|
148989
|
+
};
|
|
148990
|
+
return limit(() => resolveOne(entry)).then(settle, () => settle("failed"));
|
|
148991
|
+
});
|
|
148992
|
+
for (const { author, inFlightResolve } of joined) waitForAuthorNameResolveInFlight({
|
|
148993
|
+
inFlightResolve,
|
|
148994
|
+
abortSignal
|
|
148995
|
+
}).then((outcome) => {
|
|
148996
|
+
if (abortSignal?.aborted) return;
|
|
148997
|
+
if (outcome === "verdict") onResolved();
|
|
148998
|
+
else if (outcome === "aborted" && !this._pkc.destroyed) this.resolveAuthorNamesInBackground({
|
|
148999
|
+
authors: [author],
|
|
149000
|
+
onResolved,
|
|
149001
|
+
abortSignal
|
|
149002
|
+
});
|
|
149003
|
+
}).catch((e) => log.error("Unexpected error in resolveAuthorNamesInBackground", e));
|
|
149004
|
+
if (ownAttempts.length > 0) Promise.allSettled(ownAttempts).then((results) => {
|
|
149005
|
+
if (results.some((r) => r.status === "fulfilled" && r.value === "verdict") && !abortSignal?.aborted) onResolved();
|
|
148924
149006
|
}).catch((e) => log.error("Unexpected error in resolveAuthorNamesInBackground", e));
|
|
148925
149007
|
}
|
|
148926
149008
|
emitError(e) {
|
|
@@ -148929,8 +149011,8 @@ var BaseClientsManager = class BaseClientsManager {
|
|
|
148929
149011
|
calculateIpfsCid(content) {
|
|
148930
149012
|
return calculateIpfsCidV0(content);
|
|
148931
149013
|
}
|
|
148932
|
-
async _withInflightCommunityFetch(communityAddress, fetcher) {
|
|
148933
|
-
return this._pkc._inflightFetchManager.withResource(InflightResourceTypes.COMMUNITY_IPNS, communityAddress, fetcher);
|
|
149014
|
+
async _withInflightCommunityFetch(communityAddress, fetcher, abortSignal) {
|
|
149015
|
+
return this._pkc._inflightFetchManager.withResource(InflightResourceTypes.COMMUNITY_IPNS, communityAddress, fetcher, abortSignal);
|
|
148934
149016
|
}
|
|
148935
149017
|
};
|
|
148936
149018
|
BaseClientsManager.MAX_IPNS_HOPS = 1;
|
|
@@ -150715,7 +150797,7 @@ var CommunityClientsManager = class extends PKCClientsManager {
|
|
|
150715
150797
|
if (this._community.publicKey && (isDomain || hasAnchorClaim || !isDomain && this._community.name && this._community.nameResolved === true)) return this._community.publicKey;
|
|
150716
150798
|
}
|
|
150717
150799
|
async fetchNewUpdateForCommunity(communityAddress) {
|
|
150718
|
-
|
|
150800
|
+
const fetchCommunity = async () => {
|
|
150719
150801
|
let ipnsName;
|
|
150720
150802
|
const isDomain = isStringDomain(communityAddress);
|
|
150721
150803
|
const pinnedIpnsName = this._pinnedIpnsName();
|
|
@@ -150774,7 +150856,8 @@ var CommunityClientsManager = class extends PKCClientsManager {
|
|
|
150774
150856
|
if (anchorIdentityAddress !== identityPublicKey) this._pkc._memCaches.communityForPublishing.set(identityPublicKey, communityForPublishing);
|
|
150775
150857
|
}
|
|
150776
150858
|
return subRes;
|
|
150777
|
-
}
|
|
150859
|
+
};
|
|
150860
|
+
return this._withInflightCommunityFetch(communityAddress, fetchCommunity, this._community._getStopAbortSignal());
|
|
150778
150861
|
}
|
|
150779
150862
|
_isIpnsPushChannelHealthyForName(libp2pJsClient, ipnsName) {
|
|
150780
150863
|
try {
|
|
@@ -150867,7 +150950,21 @@ var CommunityClientsManager = class extends PKCClientsManager {
|
|
|
150867
150950
|
});
|
|
150868
150951
|
const gatewaysSorted = t$13(this._pkc.clients.ipfsGateways).length <= concurrencyLimit ? t$13(this._pkc.clients.ipfsGateways) : await this._pkc._stats.sortGatewaysAccordingToScore("ipns");
|
|
150869
150952
|
const gatewayFetches = {};
|
|
150870
|
-
|
|
150953
|
+
const stopSignal = this._community._getStopAbortSignal();
|
|
150954
|
+
const onStopAbort = () => cleanUp();
|
|
150955
|
+
const cleanUp = () => {
|
|
150956
|
+
queueLimit.clearQueue();
|
|
150957
|
+
Object.values(gatewayFetches).forEach((gateway) => {
|
|
150958
|
+
if (!gateway.communityRecord && !gateway.error) gateway.abortController.abort("Cleaning up requests for community");
|
|
150959
|
+
clearTimeout(gateway.timeoutId);
|
|
150960
|
+
});
|
|
150961
|
+
if (stopSignal) stopSignal.removeEventListener("abort", onStopAbort);
|
|
150962
|
+
};
|
|
150963
|
+
if (stopSignal) {
|
|
150964
|
+
throwIfAbortSignalAborted(stopSignal);
|
|
150965
|
+
stopSignal.addEventListener("abort", onStopAbort, { once: true });
|
|
150966
|
+
}
|
|
150967
|
+
for (const [gatewayIndex, gatewayUrl] of gatewaysSorted.entries()) {
|
|
150871
150968
|
const abortController = new AbortController();
|
|
150872
150969
|
const throwIfGatewayRespondsWithInvalidCommunity = async (gatewayRes) => {
|
|
150873
150970
|
if (typeof gatewayRes.resText !== "string") throw Error("Gateway response has no body");
|
|
@@ -150974,9 +151071,14 @@ var CommunityClientsManager = class extends PKCClientsManager {
|
|
|
150974
151071
|
if (this._community.updateCid) etagsForConditionalRequest.add(`"${this._community.updateCid}"`);
|
|
150975
151072
|
for (const cid of Array.from(this._updateCidsAlreadyLoaded.values()).slice(-5)) etagsForConditionalRequest.add(`"${cid}"`);
|
|
150976
151073
|
const requestHeaders = etagsForConditionalRequest.size > 0 ? { "If-None-Match": Array.from(etagsForConditionalRequest).join(", ") } : void 0;
|
|
150977
|
-
|
|
150978
|
-
|
|
150979
|
-
|
|
151074
|
+
const gatewayFetch = { abortController };
|
|
151075
|
+
gatewayFetches[gatewayUrl] = gatewayFetch;
|
|
151076
|
+
const armTimeout = () => gatewayFetch.timeoutId = setTimeout(() => abortController.abort("Aborting community IPNS request because it timed out after " + timeoutMs + "ms"), timeoutMs);
|
|
151077
|
+
const startsAtOnce = gatewayIndex < concurrencyLimit;
|
|
151078
|
+
if (startsAtOnce) armTimeout();
|
|
151079
|
+
gatewayFetch.promise = queueLimit(() => {
|
|
151080
|
+
if (!startsAtOnce && !abortController.signal.aborted) armTimeout();
|
|
151081
|
+
return this._fetchWithGateway(gatewayUrl, {
|
|
150980
151082
|
recordIpfsType: "ipns",
|
|
150981
151083
|
root: ipnsName,
|
|
150982
151084
|
recordPKCType: "community",
|
|
@@ -150987,23 +151089,8 @@ var CommunityClientsManager = class extends PKCClientsManager {
|
|
|
150987
151089
|
timeoutMs: this._pkc._timeouts["community-ipns"],
|
|
150988
151090
|
log,
|
|
150989
151091
|
requestHeaders
|
|
150990
|
-
})
|
|
150991
|
-
timeoutId: setTimeout(() => abortController.abort("Aborting community IPNS request because it timed out after " + timeoutMs + "ms"), timeoutMs)
|
|
150992
|
-
};
|
|
150993
|
-
}
|
|
150994
|
-
const stopSignal = this._community._getStopAbortSignal();
|
|
150995
|
-
const onStopAbort = () => cleanUp();
|
|
150996
|
-
const cleanUp = () => {
|
|
150997
|
-
queueLimit.clearQueue();
|
|
150998
|
-
Object.values(gatewayFetches).forEach((gateway) => {
|
|
150999
|
-
if (!gateway.communityRecord && !gateway.error) gateway.abortController.abort("Cleaning up requests for community");
|
|
151000
|
-
clearTimeout(gateway.timeoutId);
|
|
151092
|
+
});
|
|
151001
151093
|
});
|
|
151002
|
-
if (stopSignal) stopSignal.removeEventListener("abort", onStopAbort);
|
|
151003
|
-
};
|
|
151004
|
-
if (stopSignal) {
|
|
151005
|
-
throwIfAbortSignalAborted(stopSignal);
|
|
151006
|
-
stopSignal.addEventListener("abort", onStopAbort, { once: true });
|
|
151007
151094
|
}
|
|
151008
151095
|
const _findRecentCommunity = () => {
|
|
151009
151096
|
const winner = selectWinningGatewayCommunity({
|
|
@@ -155386,6 +155473,7 @@ function computePageSortsFingerprint({ pagesSettings, resolved, factories }) {
|
|
|
155386
155473
|
}) ?? "");
|
|
155387
155474
|
}
|
|
155388
155475
|
const describePageSort = (pageSortSettings) => pageSortSettings.name || pageSortSettings.path || "unknown page sort";
|
|
155476
|
+
const resolveSortName = ({ pageSortSettings, file }) => pageSortSettings.sortName ?? file.sortName;
|
|
155389
155477
|
async function loadPageSortFile({ pageSortSettings, pkc }) {
|
|
155390
155478
|
let factory;
|
|
155391
155479
|
try {
|
|
@@ -155430,11 +155518,15 @@ function withoutRemovedPageSortSettingOptions(pageSortSettings) {
|
|
|
155430
155518
|
};
|
|
155431
155519
|
}
|
|
155432
155520
|
function resolveOneEntry({ pageSortSettings, file, scope, pageSortIndex }) {
|
|
155521
|
+
const sortName = resolveSortName({
|
|
155522
|
+
pageSortSettings,
|
|
155523
|
+
file
|
|
155524
|
+
});
|
|
155433
155525
|
const baseDetails = {
|
|
155434
155526
|
scope,
|
|
155435
155527
|
pageSortIndex,
|
|
155436
155528
|
pageSortName: describePageSort(pageSortSettings),
|
|
155437
|
-
sortName
|
|
155529
|
+
sortName
|
|
155438
155530
|
};
|
|
155439
155531
|
const entryOptions = pageSortSettings.options ?? {};
|
|
155440
155532
|
if (file.scope && file.scope !== scope) return { error: new PKCError("ERR_PAGE_SORT_SCOPE_MISMATCH", {
|
|
@@ -155491,7 +155583,7 @@ function resolveOneEntry({ pageSortSettings, file, scope, pageSortIndex }) {
|
|
|
155491
155583
|
}
|
|
155492
155584
|
return { resolved: {
|
|
155493
155585
|
...reserved,
|
|
155494
|
-
sortName
|
|
155586
|
+
sortName,
|
|
155495
155587
|
scope,
|
|
155496
155588
|
file,
|
|
155497
155589
|
settings: pageSortSettings,
|
|
@@ -155527,7 +155619,11 @@ async function resolvePageSortsAndCollectFailures({ pagesSettings, pkc, tolerate
|
|
|
155527
155619
|
});
|
|
155528
155620
|
continue;
|
|
155529
155621
|
}
|
|
155530
|
-
|
|
155622
|
+
const sortName = resolveSortName({
|
|
155623
|
+
pageSortSettings,
|
|
155624
|
+
file
|
|
155625
|
+
});
|
|
155626
|
+
if (seenSortNames.has(sortName)) {
|
|
155531
155627
|
failures.push({
|
|
155532
155628
|
scope,
|
|
155533
155629
|
pageSortIndex,
|
|
@@ -155536,12 +155632,12 @@ async function resolvePageSortsAndCollectFailures({ pagesSettings, pkc, tolerate
|
|
|
155536
155632
|
scope,
|
|
155537
155633
|
pageSortIndex,
|
|
155538
155634
|
pageSortName,
|
|
155539
|
-
sortName
|
|
155635
|
+
sortName
|
|
155540
155636
|
})
|
|
155541
155637
|
});
|
|
155542
155638
|
continue;
|
|
155543
155639
|
}
|
|
155544
|
-
seenSortNames.add(
|
|
155640
|
+
seenSortNames.add(sortName);
|
|
155545
155641
|
const result = resolveOneEntry({
|
|
155546
155642
|
pageSortSettings,
|
|
155547
155643
|
file,
|