@pkcprotocol/pkc-js 0.0.138 → 0.0.140
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 -1
- package/dist/browser/generated-version.d.ts +1 -1
- package/dist/browser/generated-version.js +1 -1
- package/dist/browser/helia/dial-address-sorter.d.ts +2 -0
- package/dist/browser/helia/dial-address-sorter.js +52 -0
- package/dist/browser/helia/dial-address-sorter.js.map +1 -0
- package/dist/browser/helia/dial-transport-filter.d.ts +1 -1
- package/dist/browser/helia/dial-transport-filter.js +12 -11
- package/dist/browser/helia/dial-transport-filter.js.map +1 -1
- package/dist/browser/helia/helia-for-pkc.js +11 -3
- package/dist/browser/helia/helia-for-pkc.js.map +1 -1
- package/dist/browser/helia/util.d.ts +3 -0
- package/dist/browser/helia/util.js +169 -55
- package/dist/browser/helia/util.js.map +1 -1
- package/dist/browser/runtime/browser/libp2p-extra-transports.js +7 -1
- package/dist/browser/runtime/browser/libp2p-extra-transports.js.map +1 -1
- package/dist/browser/runtime/browser/webtransport-close-shim.d.ts +24 -0
- package/dist/browser/runtime/browser/webtransport-close-shim.js +65 -0
- package/dist/browser/runtime/browser/webtransport-close-shim.js.map +1 -0
- package/dist/browser/runtime/node/community/local-community/reprovide-on-address-change.d.ts +1 -1
- package/dist/browser/runtime/node/community/local-community/reprovide-on-address-change.js +5 -4
- package/dist/browser/runtime/node/community/local-community/reprovide-on-address-change.js.map +1 -1
- package/dist/browser/runtime/node/community/page-generator.js +38 -15
- package/dist/browser/runtime/node/community/page-generator.js.map +1 -1
- package/dist/browser/runtime/node/webtransport-close-shim.d.ts +4 -0
- package/dist/browser/runtime/node/webtransport-close-shim.js +7 -0
- package/dist/browser/runtime/node/webtransport-close-shim.js.map +1 -0
- package/dist/bundled/bundle-manifest.json +39 -35
- package/dist/bundled/challenges.js +1 -1
- package/dist/bundled/chunks/{helia-for-pkc-DDElBMjg.js → helia-for-pkc-D8Yy6QjO.js} +67 -38
- package/dist/bundled/chunks/{local-community-CwWE5aZI.js → local-community-3TpfDDKX.js} +1 -1
- package/dist/bundled/chunks/{local-community-WiVmJqKT.js → local-community-BIYHcGS5.js} +59 -44
- package/dist/bundled/chunks/{node-IAC_ZNSw.js → node-D0SiFYRw.js} +5 -5
- package/dist/bundled/chunks/{page-sort-scoring-3zupKJrA.js → page-sort-scoring-I74ngMaI.js} +1 -1
- package/dist/bundled/chunks/{rpc-local-community-B-qRj5uG.js → rpc-local-community-BHMWTLg2.js} +2 -2
- package/dist/bundled/chunks/{util-Nmcf8S1j.js → util-DkGqBo7o.js} +1 -1
- package/dist/bundled/chunks/{util-PmT6BP1t.js → util-Hi455mZb.js} +102 -36
- package/dist/bundled/chunks/{validate-package-factories-DN-pv9-T.js → validate-package-factories-BjxAINy2.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/generated-version.d.ts +1 -1
- package/dist/node/generated-version.js +1 -1
- package/dist/node/helia/dial-address-sorter.d.ts +2 -0
- package/dist/node/helia/dial-address-sorter.js +52 -0
- package/dist/node/helia/dial-address-sorter.js.map +1 -0
- package/dist/node/helia/dial-transport-filter.d.ts +1 -1
- package/dist/node/helia/dial-transport-filter.js +12 -11
- package/dist/node/helia/dial-transport-filter.js.map +1 -1
- package/dist/node/helia/helia-for-pkc.js +11 -3
- package/dist/node/helia/helia-for-pkc.js.map +1 -1
- package/dist/node/helia/util.d.ts +3 -0
- package/dist/node/helia/util.js +169 -55
- package/dist/node/helia/util.js.map +1 -1
- package/dist/node/runtime/browser/libp2p-extra-transports.js +7 -1
- package/dist/node/runtime/browser/libp2p-extra-transports.js.map +1 -1
- package/dist/node/runtime/browser/webtransport-close-shim.d.ts +24 -0
- package/dist/node/runtime/browser/webtransport-close-shim.js +65 -0
- package/dist/node/runtime/browser/webtransport-close-shim.js.map +1 -0
- package/dist/node/runtime/node/community/local-community/reprovide-on-address-change.d.ts +1 -1
- package/dist/node/runtime/node/community/local-community/reprovide-on-address-change.js +5 -4
- package/dist/node/runtime/node/community/local-community/reprovide-on-address-change.js.map +1 -1
- package/dist/node/runtime/node/community/page-generator.js +38 -15
- package/dist/node/runtime/node/community/page-generator.js.map +1 -1
- package/dist/node/runtime/node/webtransport-close-shim.d.ts +4 -0
- package/dist/node/runtime/node/webtransport-close-shim.js +7 -0
- package/dist/node/runtime/node/webtransport-close-shim.js.map +1 -0
- package/package.json +3 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { i as __toESM, r as __require, t as __commonJSMin } from "./chunk-2rV9d50f.js";
|
|
2
|
-
import { $ as retryKuboIpfsAddAndProvide, At as ChallengeAnswerMessageSchema, C as hideClassPrivateProps, D as isIpfsCid, Dt as require_sha256, E as isAbortError, Et as untrackUpdatingCommunity, H as rejectWhenAbortSignalFires, Hr as setErrorMap, In as CommentUpdateForChallengeVerificationSchema, It as ChallengeVerificationMessageSchema, J as removeUndefinedValuesRecursively, Jt as version_default, Lr as PKCError, Mr as FailedToFetchCommentIpfsFromGatewaysError, Mt as ChallengeMessageSchema, Nr as FailedToFetchCommentUpdateFromGatewaysError, Ot as TimeoutError, Pt as ChallengeRequestMessageSchema, Q as retryKuboIpfsAdd, Rr as messages, Sr as e$1, St as trackUpdatingComment, T as ipnsNameToIpnsOverPubsubTopic, Tt as untrackUpdatingComment, U as rejectWhenCommunityStopsOrAborts, X as resolveWhenPredicateIsTrue, Y as replaceXWithY, _t as listUpdatingCommunities, a as calculateStringSizeSameAsIpfsAddCidV0Sync, at as timestamp, br as t$1, cn as CommunityAnchorSchema, d as deepMergeRuntimeFields, dt as findStartedCommunity, et as shortifyAddress, ft as findUpdatingComment, gr as n$2, gt as listUpdatingComments, hr as isStringDomain, ht as listStartedCommunities, i as calculateStringSizeSameAsIpfsAddCidV0, it as throwIfAbortSignalAborted, jn as CommentIpfsSchema, jr as require_retry$1, k as isIpns, kt as pTimeout, ni as en_default, nt as sleepUntilTimeoutOrAbort, ot as waitForUpdateInCommunityInstanceWithErrorAndTimeout, p as doesDomainAddressHaveCapitalLetter, pn as CommunityIpfsSchema, pt as findUpdatingCommunity, r as calculateIpfsCidV0, tt as shortifyCid, u as createAbortError, vr as n$1, vt as refreshTrackedCommentAliases, wr as r, x as getPostUpdateTimestampRange, xn as PubsubTopicSchema, xr as e, zn as CommentUpdateSchema, zr as logger_default } from "./util-
|
|
3
|
-
import { $n as buildRuntimeCommunityFields, $t as RpcPublishCommunityListParamSchema, A as findCommentInParsedPages, Ar as setNativeFunctions$1, At as parseRpcCommentUpdateEventWithPKCErrorIfItFails, B as GenericStateClient, Bn as verifyCommunityEdit, Br as t$3, Bt as RpcCommunityIdentifierParamSchema, C as RepliesPages, Cn as signCommentModeration, Ct as parseCreateVoteOptionsSchemaWithPKCErrorIfItFails, D as extractCommunityRuntimeFieldsFromParsedPages, Dn as signCommunityEdit, Dt as parseJsonWithPKCErrorIfFails, Er as monitorCommunitiesDirectory, Et as parseDecryptedChallengeWithPKCErrorIfItFails, F as cloneCrosspostForRuntime, Fn as verifyCommentIpfs, Ft as RpcAuthorNameParamSchema, G as PKCTypedEmitter, Gn as getAuthorNameFromRuntime, Gt as RpcExportCommunityParamSchema, H as InflightResourceTypes, Hn as verifyVote, Ht as RpcEditCommunityParamSchema, I as collectCrosspostAuthorsToResolve, In as verifyCommentModeration, It as RpcCancelExportParamSchema, J as decodeRpcChallengeRequestPubsubMsg, Jn as CreateCommunityListWithCidOptionsSchema, Jr as NAME_RESOLVED_TRUE_TTL_MS, Jt as RpcFetchCidResultSchema, K as decodeRpcChallengeAnswerPubsubMsg, Kn as getAuthorNameFromWire, Kr as MAX_FILE_SIZE_BYTES_FOR_COMMENT_UPDATE, Kt as RpcExportCommunityResultSchema, Ln as verifyCommentPubsubMessage, Lr as t$5, Lt as RpcCidParamSchema, M as parseRawPages, Mr as findCommunitiesEntry, Nn as verifyChallengeVerification, Nr as toCommunitiesEntry, Nt as parseVotePubsubMessagePublicationSchemaWithPKCErrorIfItFails, O as findCommentInPageInstance, On as signCommunityList, Ot as parsePKCUserOptionsSchemaWithPKCErrorIfItFails, P as applyNameResolvedCacheToCrosspost, Pn as verifyCommentEdit, Pt as RpcAnchorPublishPreparationResultSchema, Qr as nativeFunctions$2, Qt as RpcPublishChallengeAnswersParamSchema, R as stripNameResolvedFromCrosspost, Rn as verifyCommentUpdate, Rt as RpcCommentRepliesPageParamSchema, Sn as signCommentEdit, Sr as getDefaultDataPath, St as parseCreateRpcCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, Tr as listCommunitiesSync, Tt as parseDecryptedChallengeVerification, Un as buildRuntimeAuthor, Ur as t$2, Ut as RpcExportCommunityModLogsParamSchema, V as InflightFetchManager, Vn as verifyCommunityList, Vr as n$3, Vt as RpcCommunityPageParamSchema, Wn as cleanWireAuthor, Wr as t$4, Wt as RpcExportCommunityModLogsResultSchema, Xn as MAX_COMMUNITY_LIST_SIZE_BYTES, Xt as RpcFetchCommunityListResultSchema, Y as decodeRpcChallengeVerificationPubsubMsg, Yn as CreateNewCommunityListOptionsSchema, Yr as NAME_RESOLVE_FAILED_RETRY_FLOOR_MS, Yt as RpcFetchCommunityListParamSchema, Zt as RpcPublishAnchorRecordParamSchema, _n as signChallengeAnswer, _t as parseCreateCommentOptionsSchemaWithPKCErrorIfItFails, an as RpcUnsubscribeParamSchema, b as KeyvBetterSqlite3, br as findLocalCommunityAddress, ct as parseCommentUpdateSchemaWithPKCErrorIfItFails, dn as decryptEd25519AesGcm, en as RpcPublishCommunityListResultSchema, er as getCommunityAddressFromRecord, et as parseCidStringSchemaWithPKCErrorIfItFails, ft as parseCommunityEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, gn as cleanUpBeforePublishing, gt as parseCreateCommentModerationOptionsSchemaWithPKCErrorIfItFails, hr as createKuboRpcClient, ht as parseCreateCommentEditOptionsSchemaWithPKCErrorIfItFails, in as RpcSuccessResultSchema, ir as decode, it as parseCommentIpfsSchemaWithPKCErrorIfItFails, jn as verifyChallengeMessage, jr as tryToDeleteCommunitiesThatFailedToBeDeletedBefore, jt as parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, k as findCommentInPageInstanceRecursively, kn as signVote, kt as parseRpcCommentEventWithPKCErrorIfItFails, l as pkcJsPageSorts, ln as createSigner, lr as getPKCAddressFromPublicKeySync, lt as parseCommunityAddressWithPKCErrorIfItFails, m as pkcJsChallenges, mt as parseCommunityListSchemaWithPKCErrorIfItFails, n as RpcRemoteCommunity, nn as RpcResolveAuthorNameResultSchema, nr as getCommunityPublicKeyFromWire, on as findCommunityRecordNameMismatch, or as getBufferedPKCAddressFromPublicKey, ot as parseCommentModerationPubsubMessagePublicationSchemaWithPKCErrorIfItFails, pn as encryptEd25519AesGcm, q as decodeRpcChallengePubsubMsg, qn as normalizeCreatePublicationAuthor, qr as NAME_RESOLVED_FALSE_TTL_MS, qt as RpcFetchCidParamSchema, rn as RpcSubscriptionIdResultSchema, rr as normalizeCommunityInputFromCommunity, rt as parseCommentEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, sn as require_lib$1, st as parseCommentPubsubMessagePublicationWithPKCErrorIfItFails, t as RpcLocalCommunity, tn as RpcPublishedAnchorRecordResultSchema, tr as getCommunityNameFromWire, un as createAnchorIpnsRecord$1, v as TrackedInstanceRegistry, vt as parseCreateCommunityEditPublicationOptionsSchemaWithPKCErrorIfItFails, wt as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, x as RemoteCommunity, xn as signComment, xt as parseCreateRemoteCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, y as LRUCache, yn as signChallengeRequest, z as PKCClientsManager, zt as RpcCommunitiesChangeEventResultSchema } from "./rpc-local-community-
|
|
4
|
-
import { s as getHeliaDebugContext } from "./util-
|
|
2
|
+
import { $ as retryKuboIpfsAddAndProvide, At as ChallengeAnswerMessageSchema, C as hideClassPrivateProps, D as isIpfsCid, Dt as require_sha256, E as isAbortError, Et as untrackUpdatingCommunity, H as rejectWhenAbortSignalFires, Hr as setErrorMap, In as CommentUpdateForChallengeVerificationSchema, It as ChallengeVerificationMessageSchema, J as removeUndefinedValuesRecursively, Jt as version_default, Lr as PKCError, Mr as FailedToFetchCommentIpfsFromGatewaysError, Mt as ChallengeMessageSchema, Nr as FailedToFetchCommentUpdateFromGatewaysError, Ot as TimeoutError, Pt as ChallengeRequestMessageSchema, Q as retryKuboIpfsAdd, Rr as messages, Sr as e$1, St as trackUpdatingComment, T as ipnsNameToIpnsOverPubsubTopic, Tt as untrackUpdatingComment, U as rejectWhenCommunityStopsOrAborts, X as resolveWhenPredicateIsTrue, Y as replaceXWithY, _t as listUpdatingCommunities, a as calculateStringSizeSameAsIpfsAddCidV0Sync, at as timestamp, br as t$1, cn as CommunityAnchorSchema, d as deepMergeRuntimeFields, dt as findStartedCommunity, et as shortifyAddress, ft as findUpdatingComment, gr as n$2, gt as listUpdatingComments, hr as isStringDomain, ht as listStartedCommunities, i as calculateStringSizeSameAsIpfsAddCidV0, it as throwIfAbortSignalAborted, jn as CommentIpfsSchema, jr as require_retry$1, k as isIpns, kt as pTimeout, ni as en_default, nt as sleepUntilTimeoutOrAbort, ot as waitForUpdateInCommunityInstanceWithErrorAndTimeout, p as doesDomainAddressHaveCapitalLetter, pn as CommunityIpfsSchema, pt as findUpdatingCommunity, r as calculateIpfsCidV0, tt as shortifyCid, u as createAbortError, vr as n$1, vt as refreshTrackedCommentAliases, wr as r, x as getPostUpdateTimestampRange, xn as PubsubTopicSchema, xr as e, zn as CommentUpdateSchema, zr as logger_default } from "./util-DkGqBo7o.js";
|
|
3
|
+
import { $n as buildRuntimeCommunityFields, $t as RpcPublishCommunityListParamSchema, A as findCommentInParsedPages, Ar as setNativeFunctions$1, At as parseRpcCommentUpdateEventWithPKCErrorIfItFails, B as GenericStateClient, Bn as verifyCommunityEdit, Br as t$3, Bt as RpcCommunityIdentifierParamSchema, C as RepliesPages, Cn as signCommentModeration, Ct as parseCreateVoteOptionsSchemaWithPKCErrorIfItFails, D as extractCommunityRuntimeFieldsFromParsedPages, Dn as signCommunityEdit, Dt as parseJsonWithPKCErrorIfFails, Er as monitorCommunitiesDirectory, Et as parseDecryptedChallengeWithPKCErrorIfItFails, F as cloneCrosspostForRuntime, Fn as verifyCommentIpfs, Ft as RpcAuthorNameParamSchema, G as PKCTypedEmitter, Gn as getAuthorNameFromRuntime, Gt as RpcExportCommunityParamSchema, H as InflightResourceTypes, Hn as verifyVote, Ht as RpcEditCommunityParamSchema, I as collectCrosspostAuthorsToResolve, In as verifyCommentModeration, It as RpcCancelExportParamSchema, J as decodeRpcChallengeRequestPubsubMsg, Jn as CreateCommunityListWithCidOptionsSchema, Jr as NAME_RESOLVED_TRUE_TTL_MS, Jt as RpcFetchCidResultSchema, K as decodeRpcChallengeAnswerPubsubMsg, Kn as getAuthorNameFromWire, Kr as MAX_FILE_SIZE_BYTES_FOR_COMMENT_UPDATE, Kt as RpcExportCommunityResultSchema, Ln as verifyCommentPubsubMessage, Lr as t$5, Lt as RpcCidParamSchema, M as parseRawPages, Mr as findCommunitiesEntry, Nn as verifyChallengeVerification, Nr as toCommunitiesEntry, Nt as parseVotePubsubMessagePublicationSchemaWithPKCErrorIfItFails, O as findCommentInPageInstance, On as signCommunityList, Ot as parsePKCUserOptionsSchemaWithPKCErrorIfItFails, P as applyNameResolvedCacheToCrosspost, Pn as verifyCommentEdit, Pt as RpcAnchorPublishPreparationResultSchema, Qr as nativeFunctions$2, Qt as RpcPublishChallengeAnswersParamSchema, R as stripNameResolvedFromCrosspost, Rn as verifyCommentUpdate, Rt as RpcCommentRepliesPageParamSchema, Sn as signCommentEdit, Sr as getDefaultDataPath, St as parseCreateRpcCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, Tr as listCommunitiesSync, Tt as parseDecryptedChallengeVerification, Un as buildRuntimeAuthor, Ur as t$2, Ut as RpcExportCommunityModLogsParamSchema, V as InflightFetchManager, Vn as verifyCommunityList, Vr as n$3, Vt as RpcCommunityPageParamSchema, Wn as cleanWireAuthor, Wr as t$4, Wt as RpcExportCommunityModLogsResultSchema, Xn as MAX_COMMUNITY_LIST_SIZE_BYTES, Xt as RpcFetchCommunityListResultSchema, Y as decodeRpcChallengeVerificationPubsubMsg, Yn as CreateNewCommunityListOptionsSchema, Yr as NAME_RESOLVE_FAILED_RETRY_FLOOR_MS, Yt as RpcFetchCommunityListParamSchema, Zt as RpcPublishAnchorRecordParamSchema, _n as signChallengeAnswer, _t as parseCreateCommentOptionsSchemaWithPKCErrorIfItFails, an as RpcUnsubscribeParamSchema, b as KeyvBetterSqlite3, br as findLocalCommunityAddress, ct as parseCommentUpdateSchemaWithPKCErrorIfItFails, dn as decryptEd25519AesGcm, en as RpcPublishCommunityListResultSchema, er as getCommunityAddressFromRecord, et as parseCidStringSchemaWithPKCErrorIfItFails, ft as parseCommunityEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, gn as cleanUpBeforePublishing, gt as parseCreateCommentModerationOptionsSchemaWithPKCErrorIfItFails, hr as createKuboRpcClient, ht as parseCreateCommentEditOptionsSchemaWithPKCErrorIfItFails, in as RpcSuccessResultSchema, ir as decode, it as parseCommentIpfsSchemaWithPKCErrorIfItFails, jn as verifyChallengeMessage, jr as tryToDeleteCommunitiesThatFailedToBeDeletedBefore, jt as parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, k as findCommentInPageInstanceRecursively, kn as signVote, kt as parseRpcCommentEventWithPKCErrorIfItFails, l as pkcJsPageSorts, ln as createSigner, lr as getPKCAddressFromPublicKeySync, lt as parseCommunityAddressWithPKCErrorIfItFails, m as pkcJsChallenges, mt as parseCommunityListSchemaWithPKCErrorIfItFails, n as RpcRemoteCommunity, nn as RpcResolveAuthorNameResultSchema, nr as getCommunityPublicKeyFromWire, on as findCommunityRecordNameMismatch, or as getBufferedPKCAddressFromPublicKey, ot as parseCommentModerationPubsubMessagePublicationSchemaWithPKCErrorIfItFails, pn as encryptEd25519AesGcm, q as decodeRpcChallengePubsubMsg, qn as normalizeCreatePublicationAuthor, qr as NAME_RESOLVED_FALSE_TTL_MS, qt as RpcFetchCidParamSchema, rn as RpcSubscriptionIdResultSchema, rr as normalizeCommunityInputFromCommunity, rt as parseCommentEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, sn as require_lib$1, st as parseCommentPubsubMessagePublicationWithPKCErrorIfItFails, t as RpcLocalCommunity, tn as RpcPublishedAnchorRecordResultSchema, tr as getCommunityNameFromWire, un as createAnchorIpnsRecord$1, v as TrackedInstanceRegistry, vt as parseCreateCommunityEditPublicationOptionsSchemaWithPKCErrorIfItFails, wt as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, x as RemoteCommunity, xn as signComment, xt as parseCreateRemoteCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, y as LRUCache, yn as signChallengeRequest, z as PKCClientsManager, zt as RpcCommunitiesChangeEventResultSchema } from "./rpc-local-community-BHMWTLg2.js";
|
|
4
|
+
import { s as getHeliaDebugContext } from "./util-Hi455mZb.js";
|
|
5
5
|
import path from "path";
|
|
6
6
|
import assert from "assert";
|
|
7
7
|
import fs from "fs";
|
|
@@ -35902,7 +35902,7 @@ var PKC$1 = class extends PKCTypedEmitter {
|
|
|
35902
35902
|
this.clients.libp2pJsClients = {};
|
|
35903
35903
|
if (!this.libp2pJsClientsOptions) return;
|
|
35904
35904
|
if (!this.httpRoutersOptions) throw Error("httpRoutersOptions is required for libp2pJsClient");
|
|
35905
|
-
const { createLibp2pJsClientOrUseExistingOne } = await import("./helia-for-pkc-
|
|
35905
|
+
const { createLibp2pJsClientOrUseExistingOne } = await import("./helia-for-pkc-D8Yy6QjO.js");
|
|
35906
35906
|
for (const clientOptions of this.libp2pJsClientsOptions) {
|
|
35907
35907
|
const heliaNode = await createLibp2pJsClientOrUseExistingOne({
|
|
35908
35908
|
...clientOptions,
|
|
@@ -36267,7 +36267,7 @@ var PKC$1 = class extends PKCTypedEmitter {
|
|
|
36267
36267
|
const log = logger_default("pkc-js:pkc:createLocalCommunity");
|
|
36268
36268
|
log.trace("Received community options to create a local community instance:", options);
|
|
36269
36269
|
if (!this._canCreateNewLocalCommunity()) throw new PKCError("ERR_CAN_NOT_CREATE_A_LOCAL_COMMUNITY", { pkcOptions: this._userPKCOptions });
|
|
36270
|
-
const { LocalCommunity, createNewLocalCommunityDb, updateInstancePropsWithStartedCommunityOrDb } = await import("./local-community-
|
|
36270
|
+
const { LocalCommunity, createNewLocalCommunityDb, updateInstancePropsWithStartedCommunityOrDb } = await import("./local-community-3TpfDDKX.js");
|
|
36271
36271
|
const isLocalCommunity = (await listCommunitiesSync(this)).includes(options.address);
|
|
36272
36272
|
const community = new LocalCommunity(this);
|
|
36273
36273
|
if (isLocalCommunity) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { bn as PageSortFileSchema, hr as isStringDomain, v as getEquivalentCommunityAddresses } from "./util-
|
|
1
|
+
import { bn as PageSortFileSchema, hr as isStringDomain, v as getEquivalentCommunityAddresses } from "./util-DkGqBo7o.js";
|
|
2
2
|
//#region dist/node/pages/page-sort-scoring.js
|
|
3
3
|
function validatePageSortFile(rawFile) {
|
|
4
4
|
const validated = PageSortFileSchema.parse(rawFile);
|
package/dist/bundled/chunks/{rpc-local-community-B-qRj5uG.js → rpc-local-community-BHMWTLg2.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 { $r as string, $t as CreateCommunityEditPublicationOptionsWithRefinementSchema, A as isIpnsPath, An as CommentIpfsReservedFields, Ar as e$4, Bn as CommentUpdateSignedPropertyNames, Br as require_supports_color, C as hideClassPrivateProps, Cn as CreateVoteUserOptionsWithRefinementSchema, Cr as t$11, Ct as trackUpdatingCommunity, D as isIpfsCid, Dn as VoteSignedPropertyNames, Dr as r$7, Dt as require_sha256$1, E as isAbortError, Er as n$8, Et as untrackUpdatingCommunity, Fn as CommentUpdateChallengeReservedFieldNames, Fr as FailedToFetchGenericIpfsFromGatewaysError, Ft as ChallengeRequestMessageSignedPropertyNames, Gn as ModQueuePageIpfsSchema, Gr as boolean, Gt as PKCParsedOptionsSchema, Ht as DecryptedChallengeVerificationSchema, Ir as FailedToFetchPageIpfsFromGatewaysError, Jn as CommentEditChallengeRequestToEncryptSchema, Jr as looseObject, K as removeNullUndefinedEmptyObjectsValuesRecursively, Kn as PageIpfsSchema, Kr as custom, Kt as PKCUserOptionBaseSchema, L as isRequestPubsubPublicationOfPost, Ln as CommentUpdateForChallengeVerificationSignedPropertyNames, Lr as PKCError, Lt as ChallengeVerificationMessageSignedPropertyNames, Mr as FailedToFetchCommentIpfsFromGatewaysError, Nn as CommentPubsubMessageWithFlexibleAuthorRefinementSchema, Nr as FailedToFetchCommentUpdateFromGatewaysError, Nt as ChallengeMessageSignedPropertyNames, O as isIpfsPath, Or as t$10, Pn as CommentSignedPropertyNames, Pr as FailedToFetchCommunityFromGatewaysError, Qn as CommentEditSignedPropertyNames, Qr as record, Qt as CommunityEditPubsubMessagePublicationSchema, R as isRequestPubsubPublicationOfReply, Rn as CommentUpdateReservedFields, Rr as messages, Rt as DecryptedChallengeAnswerSchema, S as hasTransientNetworkErrorCode, Sn as RpcRemoteCommunityUpdateEventResultSchema, Sr as e$5, T as ipnsNameToIpnsOverPubsubTopic, Tn as VotePubsubMessagePublicationSchema, Tr as t$12, Un as CreateCommentOptionsWithRefinementSchema, Ur as _enum, Ut as NameResolveCacheOptionsSchema, V as raceAgainstAbort, Vr as require_ms$1, Vt as DecryptedChallengeSchema, Wn as GetPageParamSchema, Wr as array, Wt as NameResolverSerializedSchema, Xn as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema, Xr as object, Yr as number, Yt as CommunityEditPublicationChallengeRequestToEncryptSchema, Zr as preprocess, Zt as CommunityEditPublicationSignedPropertyNames, _n as CreateRpcCommunityFunctionArgumentSchema, an as CreateCommentModerationOptionsWithRefinementSchema, ar as ChallengeAnswersSchema, at as timestamp, bn as PageSortFileSchema, br as t$13, cr as CommunityAddressSchema, d as deepMergeRuntimeFields, dn as CommunityExportRecordsSchema, dr as JsonSignatureSchema, dt as findStartedCommunity, ei as union, en as CommentModerationChallengeRequestToEncryptSchema, er as CreateCommentEditOptionsWithRefinementSchema, et as shortifyAddress, f as derivePublicationFromChallengeRequest, fn as CommunityIpfsReservedFields, fr as PKCTimestampSchema, gn as CreateRemoteCommunityFunctionArgumentSchema, gr as n$9, h as fetchAndValidateIpnsRecordFromGateway, hn as CreateNewLocalCommunityUserOptionsSchema, hr as isStringDomain, in as CommentModerationsTableRowSchema, ir as AuthorReservedFields, it as throwIfAbortSignalAborted, jn as CommentIpfsSchema, jr as require_retry$2, jt as ChallengeAnswerMessageSignedPropertyNames, k as isIpns, kn as CommentChallengeRequestToEncryptSchema, kr as t$9, kt as pTimeout, ln as CommunityChallengeSettingSchema, lr as CommunityAuthorChallengeReservedFieldNames, m as extractNetworkErrorDetails, mn as CommunitySignedPropertyNames, mr as areEquivalentNames, mt as forgetTrackedUpdatingCommunityName, nr as AuthorCommentIpfsReservedFields, nt as sleepUntilTimeoutOrAbort, on as ChallengeFileFactorySchema, or as CidPathSchema, p as doesDomainAddressHaveCapitalLetter, pn as CommunityIpfsSchema, pr as ProtocolVersionSchema, pt as findUpdatingCommunity, qn as isReservedObjectKey, qr as literal, qt as PKCUserOptionsSchema, r as calculateIpfsCidV0, rn as CommentModerationSignedPropertyNames, rr as AuthorPubsubSchema, sn as ChallengeFileSchema, sr as CidStringSchema, t as areEquivalentCommunityAddresses, tn as CommentModerationPubsubMessagePublicationSchema, tr as AuthorAddressSchema, tt as shortifyCid, u as createAbortError, un as CommunityEditOptionsSchema, ur as CreateSignerSchema, vn as ExportCommunityModLogsOptionsSchema, vr as n$10, w as interruptibleSleep, wn as VoteChallengeRequestToEncryptSchema, wr as r$8, wt as untrackStartedCommunity, xr as e$6, xt as trackStartedCommunity, yn as PageSortFileFactorySchema, yt as refreshTrackedCommunityAliases, z as pubsubTopicToDhtKey, zn as CommentUpdateSchema, zr as logger_default } from "./util-
|
|
2
|
+
import { $r as string, $t as CreateCommunityEditPublicationOptionsWithRefinementSchema, A as isIpnsPath, An as CommentIpfsReservedFields, Ar as e$4, Bn as CommentUpdateSignedPropertyNames, Br as require_supports_color, C as hideClassPrivateProps, Cn as CreateVoteUserOptionsWithRefinementSchema, Cr as t$11, Ct as trackUpdatingCommunity, D as isIpfsCid, Dn as VoteSignedPropertyNames, Dr as r$7, Dt as require_sha256$1, E as isAbortError, Er as n$8, Et as untrackUpdatingCommunity, Fn as CommentUpdateChallengeReservedFieldNames, Fr as FailedToFetchGenericIpfsFromGatewaysError, Ft as ChallengeRequestMessageSignedPropertyNames, Gn as ModQueuePageIpfsSchema, Gr as boolean, Gt as PKCParsedOptionsSchema, Ht as DecryptedChallengeVerificationSchema, Ir as FailedToFetchPageIpfsFromGatewaysError, Jn as CommentEditChallengeRequestToEncryptSchema, Jr as looseObject, K as removeNullUndefinedEmptyObjectsValuesRecursively, Kn as PageIpfsSchema, Kr as custom, Kt as PKCUserOptionBaseSchema, L as isRequestPubsubPublicationOfPost, Ln as CommentUpdateForChallengeVerificationSignedPropertyNames, Lr as PKCError, Lt as ChallengeVerificationMessageSignedPropertyNames, Mr as FailedToFetchCommentIpfsFromGatewaysError, Nn as CommentPubsubMessageWithFlexibleAuthorRefinementSchema, Nr as FailedToFetchCommentUpdateFromGatewaysError, Nt as ChallengeMessageSignedPropertyNames, O as isIpfsPath, Or as t$10, Pn as CommentSignedPropertyNames, Pr as FailedToFetchCommunityFromGatewaysError, Qn as CommentEditSignedPropertyNames, Qr as record, Qt as CommunityEditPubsubMessagePublicationSchema, R as isRequestPubsubPublicationOfReply, Rn as CommentUpdateReservedFields, Rr as messages, Rt as DecryptedChallengeAnswerSchema, S as hasTransientNetworkErrorCode, Sn as RpcRemoteCommunityUpdateEventResultSchema, Sr as e$5, T as ipnsNameToIpnsOverPubsubTopic, Tn as VotePubsubMessagePublicationSchema, Tr as t$12, Un as CreateCommentOptionsWithRefinementSchema, Ur as _enum, Ut as NameResolveCacheOptionsSchema, V as raceAgainstAbort, Vr as require_ms$1, Vt as DecryptedChallengeSchema, Wn as GetPageParamSchema, Wr as array, Wt as NameResolverSerializedSchema, Xn as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema, Xr as object, Yr as number, Yt as CommunityEditPublicationChallengeRequestToEncryptSchema, Zr as preprocess, Zt as CommunityEditPublicationSignedPropertyNames, _n as CreateRpcCommunityFunctionArgumentSchema, an as CreateCommentModerationOptionsWithRefinementSchema, ar as ChallengeAnswersSchema, at as timestamp, bn as PageSortFileSchema, br as t$13, cr as CommunityAddressSchema, d as deepMergeRuntimeFields, dn as CommunityExportRecordsSchema, dr as JsonSignatureSchema, dt as findStartedCommunity, ei as union, en as CommentModerationChallengeRequestToEncryptSchema, er as CreateCommentEditOptionsWithRefinementSchema, et as shortifyAddress, f as derivePublicationFromChallengeRequest, fn as CommunityIpfsReservedFields, fr as PKCTimestampSchema, gn as CreateRemoteCommunityFunctionArgumentSchema, gr as n$9, h as fetchAndValidateIpnsRecordFromGateway, hn as CreateNewLocalCommunityUserOptionsSchema, hr as isStringDomain, in as CommentModerationsTableRowSchema, ir as AuthorReservedFields, it as throwIfAbortSignalAborted, jn as CommentIpfsSchema, jr as require_retry$2, jt as ChallengeAnswerMessageSignedPropertyNames, k as isIpns, kn as CommentChallengeRequestToEncryptSchema, kr as t$9, kt as pTimeout, ln as CommunityChallengeSettingSchema, lr as CommunityAuthorChallengeReservedFieldNames, m as extractNetworkErrorDetails, mn as CommunitySignedPropertyNames, mr as areEquivalentNames, mt as forgetTrackedUpdatingCommunityName, nr as AuthorCommentIpfsReservedFields, nt as sleepUntilTimeoutOrAbort, on as ChallengeFileFactorySchema, or as CidPathSchema, p as doesDomainAddressHaveCapitalLetter, pn as CommunityIpfsSchema, pr as ProtocolVersionSchema, pt as findUpdatingCommunity, qn as isReservedObjectKey, qr as literal, qt as PKCUserOptionsSchema, r as calculateIpfsCidV0, rn as CommentModerationSignedPropertyNames, rr as AuthorPubsubSchema, sn as ChallengeFileSchema, sr as CidStringSchema, t as areEquivalentCommunityAddresses, tn as CommentModerationPubsubMessagePublicationSchema, tr as AuthorAddressSchema, tt as shortifyCid, u as createAbortError, un as CommunityEditOptionsSchema, ur as CreateSignerSchema, vn as ExportCommunityModLogsOptionsSchema, vr as n$10, w as interruptibleSleep, wn as VoteChallengeRequestToEncryptSchema, wr as r$8, wt as untrackStartedCommunity, xr as e$6, xt as trackStartedCommunity, yn as PageSortFileFactorySchema, yt as refreshTrackedCommunityAliases, z as pubsubTopicToDhtKey, zn as CommentUpdateSchema, zr as logger_default } from "./util-DkGqBo7o.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-I74ngMaI.js";
|
|
5
5
|
import { createHash } from "node:crypto";
|
|
6
6
|
import { pathToFileURL } from "node:url";
|
|
7
7
|
import dns from "node:dns";
|
|
@@ -16552,7 +16552,7 @@ const CommunityEditPublicationPubsubReservedFields = r$2([
|
|
|
16552
16552
|
], t$3(CommunityEditPubsubMessagePublicationSchema.shape));
|
|
16553
16553
|
//#endregion
|
|
16554
16554
|
//#region dist/node/generated-version.js
|
|
16555
|
-
const version = "0.0.
|
|
16555
|
+
const version = "0.0.140";
|
|
16556
16556
|
//#endregion
|
|
16557
16557
|
//#region dist/node/version.js
|
|
16558
16558
|
const protocolVersion = ProtocolVersionSchema.parse("1.0.0");
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { B as pubsubTopicToDhtKeyCid, Lr as PKCError } from "./util-
|
|
1
|
+
import { B as pubsubTopicToDhtKeyCid, Lr as PKCError } from "./util-DkGqBo7o.js";
|
|
2
2
|
import { ipnsSelector } from "ipns/selector";
|
|
3
3
|
import { ipnsValidator } from "ipns/validator";
|
|
4
4
|
import { unmarshalIPNSRecord } from "ipns";
|
|
5
5
|
import { equals } from "uint8arrays/equals";
|
|
6
|
+
import { isLoopback, isPrivate } from "@libp2p/utils";
|
|
6
7
|
//#region dist/node/helia/util.js
|
|
7
8
|
const TOPIC_SUBSCRIBER_WAIT_TIMEOUT_MS = 1e4;
|
|
8
9
|
const MESH_PEER_WAIT_TIMEOUT_MS = 3e3;
|
|
@@ -27,6 +28,24 @@ function isDialRetryableAfterAddrMerge(error) {
|
|
|
27
28
|
function multiaddrIsCircuitRelay(addr) {
|
|
28
29
|
return addr.getComponents().some((component) => component.name === "p2p-circuit");
|
|
29
30
|
}
|
|
31
|
+
function multiaddrIsPrivateOrLoopback(addr) {
|
|
32
|
+
try {
|
|
33
|
+
if (isPrivate(addr) || isLoopback(addr)) return true;
|
|
34
|
+
const first = addr.getComponents()[0];
|
|
35
|
+
return first?.name === "ip6" && /^fe[c-f]/i.test(first.value ?? "");
|
|
36
|
+
} catch {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const PRIVATE_ONLY_PROVIDER_DIAL_DELAY_MS = 2e3;
|
|
41
|
+
async function providerIsReachableOnlyPrivately(helia, announcedAddrs) {
|
|
42
|
+
const directAddrs = announcedAddrs.filter((addr) => !multiaddrIsCircuitRelay(addr));
|
|
43
|
+
if (directAddrs.length === 0) return false;
|
|
44
|
+
const publicAddrs = directAddrs.filter((addr) => !multiaddrIsPrivateOrLoopback(addr));
|
|
45
|
+
if (publicAddrs.length > 0 && await helia.libp2p.isDialable(publicAddrs)) return false;
|
|
46
|
+
const privateAddrs = directAddrs.filter(multiaddrIsPrivateOrLoopback);
|
|
47
|
+
return privateAddrs.length > 0 && await helia.libp2p.isDialable(privateAddrs);
|
|
48
|
+
}
|
|
30
49
|
function createAddrMergeRetryScheduler({ helia, runRetry }) {
|
|
31
50
|
const retryablePeers = /* @__PURE__ */ new Map();
|
|
32
51
|
const inFlightOrDone = /* @__PURE__ */ new Set();
|
|
@@ -177,34 +196,55 @@ async function connectToPubsubPeers({ helia, pubsubTopic, maxPeers, options, log
|
|
|
177
196
|
}
|
|
178
197
|
}
|
|
179
198
|
});
|
|
199
|
+
const privateOnlyPeers = [];
|
|
200
|
+
let privateOnlyReleased = false;
|
|
201
|
+
let privateOnlyTimer;
|
|
202
|
+
const releasePrivateOnlyPeers = () => {
|
|
203
|
+
if (privateOnlyReleased) return;
|
|
204
|
+
privateOnlyReleased = true;
|
|
205
|
+
clearTimeout(privateOnlyTimer);
|
|
206
|
+
for (const peer of privateOnlyPeers.splice(0)) {
|
|
207
|
+
if (options?.signal?.aborted || connectedPeersWithContent.length >= maxPeers) break;
|
|
208
|
+
startDial(peer);
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
const startDial = (peer) => {
|
|
212
|
+
const dialPromise = (async () => {
|
|
213
|
+
try {
|
|
214
|
+
if (peer.multiaddrs?.length) await helia.libp2p.peerStore.merge(peer.id, { multiaddrs: peer.multiaddrs });
|
|
215
|
+
const conn = await helia.libp2p.dial(peer.id, dialOptions);
|
|
216
|
+
connectedPeersWithContent.push(conn);
|
|
217
|
+
if (connectedPeersWithContent.length >= maxPeers && !findProvidersAbort.signal.aborted) {
|
|
218
|
+
log.trace("Aborting findProviders after reaching maxPeers", maxPeers);
|
|
219
|
+
findProvidersAbort.abort();
|
|
220
|
+
}
|
|
221
|
+
} catch (e) {
|
|
222
|
+
const err = e;
|
|
223
|
+
if (isDialRetryableAfterAddrMerge(err)) retryScheduler.markRetryable(peer.id);
|
|
224
|
+
peerDialToError[peer.id.toString()] = {
|
|
225
|
+
multiaddrs: peer.multiaddrs.map(String),
|
|
226
|
+
errorName: err.name,
|
|
227
|
+
errorMessage: err.message,
|
|
228
|
+
errorStack: err.stack
|
|
229
|
+
};
|
|
230
|
+
log.trace("Failed to dial IPNS-Over-Pubsub peer", peer.id.toString(), "Due to error", e);
|
|
231
|
+
}
|
|
232
|
+
})();
|
|
233
|
+
inflightDialPromises.push(dialPromise);
|
|
234
|
+
};
|
|
180
235
|
try {
|
|
181
236
|
for await (const peer of helia.libp2p.contentRouting.findProviders(contentCid, {
|
|
182
237
|
...options,
|
|
183
238
|
signal: findProvidersSignal
|
|
184
239
|
})) {
|
|
185
240
|
peersWithContent.push(peer);
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
findProvidersAbort.abort();
|
|
194
|
-
}
|
|
195
|
-
} catch (e) {
|
|
196
|
-
const err = e;
|
|
197
|
-
if (isDialRetryableAfterAddrMerge(err)) retryScheduler.markRetryable(peer.id);
|
|
198
|
-
peerDialToError[peer.id.toString()] = {
|
|
199
|
-
multiaddrs: peer.multiaddrs.map(String),
|
|
200
|
-
errorName: err.name,
|
|
201
|
-
errorMessage: err.message,
|
|
202
|
-
errorStack: err.stack
|
|
203
|
-
};
|
|
204
|
-
log.trace("Failed to dial IPNS-Over-Pubsub peer", peer.id.toString(), "Due to error", e);
|
|
205
|
-
}
|
|
206
|
-
})();
|
|
207
|
-
inflightDialPromises.push(dialPromise);
|
|
241
|
+
if (!privateOnlyReleased && await providerIsReachableOnlyPrivately(helia, peer.multiaddrs ?? []) && !privateOnlyReleased) {
|
|
242
|
+
privateOnlyPeers.push(peer);
|
|
243
|
+
privateOnlyTimer ??= setTimeout(releasePrivateOnlyPeers, PRIVATE_ONLY_PROVIDER_DIAL_DELAY_MS);
|
|
244
|
+
log.trace("Deferring dial to private-only provider", peer.id.toString(), "for topic", pubsubTopic);
|
|
245
|
+
continue;
|
|
246
|
+
}
|
|
247
|
+
startDial(peer);
|
|
208
248
|
if (connectedPeersWithContent.length >= maxPeers) {
|
|
209
249
|
log.trace("Breaking findProviders loop after reaching maxPeers", maxPeers);
|
|
210
250
|
break;
|
|
@@ -223,11 +263,14 @@ async function connectToPubsubPeers({ helia, pubsubTopic, maxPeers, options, log
|
|
|
223
263
|
peerDialToError,
|
|
224
264
|
...getHeliaDebugContext(helia)
|
|
225
265
|
};
|
|
266
|
+
clearTimeout(privateOnlyTimer);
|
|
226
267
|
throw e;
|
|
227
268
|
}
|
|
228
269
|
} finally {
|
|
229
270
|
retryScheduler.onProviderStreamEnded();
|
|
230
271
|
}
|
|
272
|
+
if (privateOnlyPeers.length > 0) if (inflightDialPromises.length === 0) releasePrivateOnlyPeers();
|
|
273
|
+
else Promise.allSettled([...inflightDialPromises]).then(releasePrivateOnlyPeers);
|
|
231
274
|
inflightDialPromises.push(...retryScheduler.retryTasks);
|
|
232
275
|
let graftError = null;
|
|
233
276
|
try {
|
|
@@ -430,7 +473,34 @@ async function directFetchIpnsRecordFromProviders({ helia, pubsubTopic, routingK
|
|
|
430
473
|
return "done";
|
|
431
474
|
}
|
|
432
475
|
});
|
|
476
|
+
const dialAndFetch = async (peer) => {
|
|
477
|
+
try {
|
|
478
|
+
if (peer.multiaddrs?.length) await helia.libp2p.peerStore.merge(peer.id, { multiaddrs: peer.multiaddrs });
|
|
479
|
+
const dialSignal = options?.signal ? AbortSignal.any([options.signal, resultController.signal]) : resultController.signal;
|
|
480
|
+
await helia.libp2p.dial(peer.id, { signal: dialSignal });
|
|
481
|
+
markProviderDialed(peer.id);
|
|
482
|
+
await tryFetchFromPeer(peer.id, "provider");
|
|
483
|
+
} catch (e) {
|
|
484
|
+
if (isDialRetryableAfterAddrMerge(e)) retryScheduler.markRetryable(peer.id);
|
|
485
|
+
else markProviderDialed(peer.id);
|
|
486
|
+
recordErr(peer.id, e);
|
|
487
|
+
}
|
|
488
|
+
};
|
|
433
489
|
let attempted = 0;
|
|
490
|
+
const privateOnlyProviders = [];
|
|
491
|
+
const privateOnlyTasks = [];
|
|
492
|
+
let privateOnlyReleased = false;
|
|
493
|
+
let privateOnlyTimer;
|
|
494
|
+
const releasePrivateOnlyProviders = () => {
|
|
495
|
+
if (privateOnlyReleased) return;
|
|
496
|
+
privateOnlyReleased = true;
|
|
497
|
+
clearTimeout(privateOnlyTimer);
|
|
498
|
+
for (const peer of privateOnlyProviders.splice(0)) {
|
|
499
|
+
if (winner || resultController.signal.aborted || options?.signal?.aborted || attempted >= maxPeers) break;
|
|
500
|
+
attempted++;
|
|
501
|
+
privateOnlyTasks.push(dialAndFetch(peer));
|
|
502
|
+
}
|
|
503
|
+
};
|
|
434
504
|
try {
|
|
435
505
|
for await (const peer of helia.libp2p.contentRouting.findProviders(contentCid, {
|
|
436
506
|
...options,
|
|
@@ -455,19 +525,13 @@ async function directFetchIpnsRecordFromProviders({ helia, pubsubTopic, routingK
|
|
|
455
525
|
verdict: hasDialableAddr ? "dialed" : "no-dialable-addrs",
|
|
456
526
|
announcedAddrs: announcedAddrs.map(String)
|
|
457
527
|
});
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
} catch (e) {
|
|
466
|
-
if (isDialRetryableAfterAddrMerge(e)) retryScheduler.markRetryable(peer.id);
|
|
467
|
-
else markProviderDialed(peer.id);
|
|
468
|
-
recordErr(peer.id, e);
|
|
469
|
-
}
|
|
470
|
-
})());
|
|
528
|
+
if (!privateOnlyReleased && hasDialableAddr && await providerIsReachableOnlyPrivately(helia, announcedAddrs) && !privateOnlyReleased) {
|
|
529
|
+
privateOnlyProviders.push(peer);
|
|
530
|
+
privateOnlyTimer ??= setTimeout(releasePrivateOnlyProviders, PRIVATE_ONLY_PROVIDER_DIAL_DELAY_MS);
|
|
531
|
+
log.trace("Deferring dial to private-only provider", peer.id.toString(), "for topic", pubsubTopic);
|
|
532
|
+
continue;
|
|
533
|
+
}
|
|
534
|
+
dialFetchTasks.push(dialAndFetch(peer));
|
|
471
535
|
if (hasDialableAddr && ++attempted >= maxPeers) {
|
|
472
536
|
findProvidersAbort.abort();
|
|
473
537
|
break;
|
|
@@ -478,6 +542,8 @@ async function directFetchIpnsRecordFromProviders({ helia, pubsubTopic, routingK
|
|
|
478
542
|
}
|
|
479
543
|
retryScheduler.onProviderStreamEnded();
|
|
480
544
|
await Promise.allSettled(dialFetchTasks);
|
|
545
|
+
releasePrivateOnlyProviders();
|
|
546
|
+
await Promise.allSettled(privateOnlyTasks);
|
|
481
547
|
while (retryScheduler.retryTasks.length > 0) await Promise.allSettled(retryScheduler.retryTasks.splice(0));
|
|
482
548
|
})();
|
|
483
549
|
await Promise.allSettled([...subscriberTasks, providerBranch]);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Lr as PKCError, on as ChallengeFileFactorySchema, sn as ChallengeFileSchema, yn as PageSortFileFactorySchema } from "./util-
|
|
2
|
-
import { s as validatePageSortFile } from "./page-sort-scoring-
|
|
1
|
+
import { Lr as PKCError, on as ChallengeFileFactorySchema, sn as ChallengeFileSchema, yn as PageSortFileFactorySchema } from "./util-DkGqBo7o.js";
|
|
2
|
+
import { s as validatePageSortFile } from "./page-sort-scoring-I74ngMaI.js";
|
|
3
3
|
//#region dist/node/validate-package-factories.js
|
|
4
4
|
function validateChallengeFileFactory(factory, { name }) {
|
|
5
5
|
try {
|
package/dist/bundled/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as getShortCid, c as setNativeFunctions, i as getShortAddress, n as challenges, o as nativeFunctions, r as createAnchorIpnsRecord, s as pageSorts, t as PKC } from "./chunks/node-
|
|
1
|
+
import { a as getShortCid, c as setNativeFunctions, i as getShortAddress, n as challenges, o as nativeFunctions, r as createAnchorIpnsRecord, s as pageSorts, t as PKC } from "./chunks/node-D0SiFYRw.js";
|
|
2
2
|
export { challenges, createAnchorIpnsRecord, PKC as default, getShortAddress, getShortCid, nativeFunctions, pageSorts, setNativeFunctions };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as validatePageSortFileFactory } from "./chunks/validate-package-factories-
|
|
1
|
+
import { n as validatePageSortFileFactory } from "./chunks/validate-package-factories-BjxAINy2.js";
|
|
2
2
|
export { validatePageSortFileFactory };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { $ as retryKuboIpfsAddAndProvide, C as hideClassPrivateProps, Lr as PKCError, Y as replaceXWithY, br as t, dt as findStartedCommunity, i as calculateStringSizeSameAsIpfsAddCidV0, kt as pTimeout, vr as n, zr as logger_default } from "../../chunks/util-
|
|
2
|
-
import { S as parseRpcUnsubscribeParam, _ as parseRpcExportCommunityParam, b as parseRpcPublishChallengeAnswersParam, d as parseRpcCidParam, f as parseRpcCommentRepliesPageParam, g as parseRpcExportCommunityModLogsParam, h as parseRpcEditCommunityParam, l as parseRpcAuthorNameParam, m as parseRpcCommunityPageParam, p as parseRpcCommunityIdentifierParam, t as PKC, u as parseRpcCancelExportParam, v as parseRpcFetchCommunityListParam, x as parseRpcPublishCommunityListParam, y as parseRpcPublishAnchorRecordParam } from "../../chunks/node-
|
|
3
|
-
import { Dt as parseJsonWithPKCErrorIfFails, E as buildPagesRuntimeFields, Gr as stringify, L as extractCrosspostRuntimeFields, Mt as parseVoteChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, Pr as toCommunitiesWireEntry, Rr as t$1, T as buildPageRuntimeFields, Tr as listCommunitiesSync, U as pRetry, Vn as verifyCommunityList, W as pLimit, Xn as MAX_COMMUNITY_LIST_SIZE_BYTES, at as parseCommentModerationChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, br as findLocalCommunityAddress, bt as parseCreatePKCWsServerOptionsSchemaWithPKCErrorIfItFails, dt as parseCommunityEditOptionsSchemaWithPKCErrorIfItFails, jt as parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, mt as parseCommunityListSchemaWithPKCErrorIfItFails, nt as parseCommentEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, sn as require_lib, tt as parseCommentChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, ut as parseCommunityEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, wt as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, yt as parseCreateNewLocalCommunityUserOptionsSchemaWithPKCErrorIfItFails } from "../../chunks/rpc-local-community-
|
|
4
|
-
import { t as LocalCommunity } from "../../chunks/local-community-
|
|
1
|
+
import { $ as retryKuboIpfsAddAndProvide, C as hideClassPrivateProps, Lr as PKCError, Y as replaceXWithY, br as t, dt as findStartedCommunity, i as calculateStringSizeSameAsIpfsAddCidV0, kt as pTimeout, vr as n, zr as logger_default } from "../../chunks/util-DkGqBo7o.js";
|
|
2
|
+
import { S as parseRpcUnsubscribeParam, _ as parseRpcExportCommunityParam, b as parseRpcPublishChallengeAnswersParam, d as parseRpcCidParam, f as parseRpcCommentRepliesPageParam, g as parseRpcExportCommunityModLogsParam, h as parseRpcEditCommunityParam, l as parseRpcAuthorNameParam, m as parseRpcCommunityPageParam, p as parseRpcCommunityIdentifierParam, t as PKC, u as parseRpcCancelExportParam, v as parseRpcFetchCommunityListParam, x as parseRpcPublishCommunityListParam, y as parseRpcPublishAnchorRecordParam } from "../../chunks/node-D0SiFYRw.js";
|
|
3
|
+
import { Dt as parseJsonWithPKCErrorIfFails, E as buildPagesRuntimeFields, Gr as stringify, L as extractCrosspostRuntimeFields, Mt as parseVoteChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, Pr as toCommunitiesWireEntry, Rr as t$1, T as buildPageRuntimeFields, Tr as listCommunitiesSync, U as pRetry, Vn as verifyCommunityList, W as pLimit, Xn as MAX_COMMUNITY_LIST_SIZE_BYTES, at as parseCommentModerationChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, br as findLocalCommunityAddress, bt as parseCreatePKCWsServerOptionsSchemaWithPKCErrorIfItFails, dt as parseCommunityEditOptionsSchemaWithPKCErrorIfItFails, jt as parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, mt as parseCommunityListSchemaWithPKCErrorIfItFails, nt as parseCommentEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, sn as require_lib, tt as parseCommentChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, ut as parseCommunityEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, wt as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, yt as parseCreateNewLocalCommunityUserOptionsSchemaWithPKCErrorIfItFails } from "../../chunks/rpc-local-community-BHMWTLg2.js";
|
|
4
|
+
import { t as LocalCommunity } from "../../chunks/local-community-BIYHcGS5.js";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
6
|
import path from "path";
|
|
7
7
|
import assert from "assert";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "0.0.
|
|
1
|
+
export declare const version = "0.0.140";
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { circuitRelayAddressesLast, loopbackAddressLast, publicAddressesFirst, reliableTransportsFirst } from "@libp2p/utils";
|
|
2
|
+
// libp2p dials a peer's addresses one at a time, with a per-address timeout (6 s) inside a per-dial
|
|
3
|
+
// timeout (10 s). Some consumer networks drop IPv4 UDP to port 4001, so when a WebTransport address on
|
|
4
|
+
// IPv4 UDP 4001 sorts first the dial burns a whole per-address timeout before trying one that works
|
|
5
|
+
// (#475). This sorter keeps libp2p's default order (loopback last, public first, relayed last,
|
|
6
|
+
// certified first, then TCP > WSS > WS > WebRTC > WebRTC-direct > WebTransport) and only breaks the
|
|
7
|
+
// remaining ties between UDP addresses: UDP 443 first (the port networks have most reason to allow,
|
|
8
|
+
// since HTTP/3 uses it), then IPv6, then IPv4 on any other port.
|
|
9
|
+
function udpPreference(multiaddr) {
|
|
10
|
+
const components = multiaddr.getComponents();
|
|
11
|
+
const udp = components.find((component) => component.name === "udp");
|
|
12
|
+
if (!udp)
|
|
13
|
+
return undefined;
|
|
14
|
+
if (udp.value === "443")
|
|
15
|
+
return 0;
|
|
16
|
+
const family = components[0]?.name;
|
|
17
|
+
return family === "ip6" || family === "dns6" ? 1 : 2;
|
|
18
|
+
}
|
|
19
|
+
function certifiedAddressesFirst(a, b) {
|
|
20
|
+
if (a.isCertified && !b.isCertified)
|
|
21
|
+
return -1;
|
|
22
|
+
if (!a.isCertified && b.isCertified)
|
|
23
|
+
return 1;
|
|
24
|
+
return 0;
|
|
25
|
+
}
|
|
26
|
+
function isIp6(multiaddr) {
|
|
27
|
+
const family = multiaddr.getComponents()[0]?.name;
|
|
28
|
+
return family === "ip6" || family === "dns6";
|
|
29
|
+
}
|
|
30
|
+
function preferredUdpAddressesFirst(a, b) {
|
|
31
|
+
const preferenceA = udpPreference(a);
|
|
32
|
+
const preferenceB = udpPreference(b);
|
|
33
|
+
if (preferenceA === undefined || preferenceB === undefined)
|
|
34
|
+
return 0;
|
|
35
|
+
if (preferenceA !== preferenceB)
|
|
36
|
+
return preferenceA < preferenceB ? -1 : 1;
|
|
37
|
+
// same port class: IPv6 first, so a client on a network that filters IPv4 UDP still connects first try
|
|
38
|
+
const ip6A = isIp6(a);
|
|
39
|
+
const ip6B = isIp6(b);
|
|
40
|
+
if (ip6A && !ip6B)
|
|
41
|
+
return -1;
|
|
42
|
+
if (!ip6A && ip6B)
|
|
43
|
+
return 1;
|
|
44
|
+
return 0;
|
|
45
|
+
}
|
|
46
|
+
export const pkcDialAddressSorter = (a, b) => loopbackAddressLast(a.multiaddr, b.multiaddr) ||
|
|
47
|
+
publicAddressesFirst(a.multiaddr, b.multiaddr) ||
|
|
48
|
+
circuitRelayAddressesLast(a.multiaddr, b.multiaddr) ||
|
|
49
|
+
certifiedAddressesFirst(a, b) ||
|
|
50
|
+
reliableTransportsFirst(a.multiaddr, b.multiaddr) ||
|
|
51
|
+
preferredUdpAddressesFirst(a.multiaddr, b.multiaddr);
|
|
52
|
+
//# sourceMappingURL=dial-address-sorter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dial-address-sorter.js","sourceRoot":"","sources":["../../../src/helia/dial-address-sorter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,yBAAyB,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAE9H,oGAAoG;AACpG,uGAAuG;AACvG,oGAAoG;AACpG,+FAA+F;AAC/F,oGAAoG;AACpG,oGAAoG;AACpG,iEAAiE;AAEjE,SAAS,aAAa,CAAC,SAAoB;IACvC,MAAM,UAAU,GAAG,SAAS,CAAC,aAAa,EAAE,CAAC;IAC7C,MAAM,GAAG,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,KAAK,KAAK,CAAC,CAAC;IACrE,IAAI,CAAC,GAAG;QAAE,OAAO,SAAS,CAAC;IAC3B,IAAI,GAAG,CAAC,KAAK,KAAK,KAAK;QAAE,OAAO,CAAC,CAAC;IAClC,MAAM,MAAM,GAAG,UAAU,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC;IACnC,OAAO,MAAM,KAAK,KAAK,IAAI,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACzD,CAAC;AAED,SAAS,uBAAuB,CAAC,CAAU,EAAE,CAAU;IACnD,IAAI,CAAC,CAAC,WAAW,IAAI,CAAC,CAAC,CAAC,WAAW;QAAE,OAAO,CAAC,CAAC,CAAC;IAC/C,IAAI,CAAC,CAAC,CAAC,WAAW,IAAI,CAAC,CAAC,WAAW;QAAE,OAAO,CAAC,CAAC;IAC9C,OAAO,CAAC,CAAC;AACb,CAAC;AAED,SAAS,KAAK,CAAC,SAAoB;IAC/B,MAAM,MAAM,GAAG,SAAS,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC;IAClD,OAAO,MAAM,KAAK,KAAK,IAAI,MAAM,KAAK,MAAM,CAAC;AACjD,CAAC;AAED,SAAS,0BAA0B,CAAC,CAAY,EAAE,CAAY;IAC1D,MAAM,WAAW,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;IACrC,MAAM,WAAW,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;IACrC,IAAI,WAAW,KAAK,SAAS,IAAI,WAAW,KAAK,SAAS;QAAE,OAAO,CAAC,CAAC;IACrE,IAAI,WAAW,KAAK,WAAW;QAAE,OAAO,WAAW,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3E,uGAAuG;IACvG,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IACtB,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IACtB,IAAI,IAAI,IAAI,CAAC,IAAI;QAAE,OAAO,CAAC,CAAC,CAAC;IAC7B,IAAI,CAAC,IAAI,IAAI,IAAI;QAAE,OAAO,CAAC,CAAC;IAC5B,OAAO,CAAC,CAAC;AACb,CAAC;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAkB,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CACxD,mBAAmB,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,SAAS,CAAC;IAC7C,oBAAoB,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,SAAS,CAAC;IAC9C,yBAAyB,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,SAAS,CAAC;IACnD,uBAAuB,CAAC,CAAC,EAAE,CAAC,CAAC;IAC7B,uBAAuB,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,SAAS,CAAC;IACjD,0BAA0B,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ConnectionGater } from "@libp2p/interface";
|
|
2
2
|
import type { Multiaddr } from "@multiformats/multiaddr";
|
|
3
|
-
export declare const DENIED_DIAL_TRANSPORTS_BY_DEFAULT: readonly ["webrtc", "webrtc-direct"
|
|
3
|
+
export declare const DENIED_DIAL_TRANSPORTS_BY_DEFAULT: readonly ["webrtc", "webrtc-direct"];
|
|
4
4
|
export declare function multiaddrUsesDeniedTransport(multiaddr: Multiaddr): boolean;
|
|
5
5
|
export declare function createDefaultDialTransportGater(): Required<Pick<ConnectionGater, "denyDialMultiaddr">>;
|
|
@@ -1,24 +1,25 @@
|
|
|
1
|
-
// By default pkc-js
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
1
|
+
// By default pkc-js dials peers over WebSocket(/WSS), TCP and WebTransport. WebRTC dials are rejected:
|
|
2
|
+
// in the browser they add long, often-failing connection-establishment paths (STUN/ICE, SDP munging,
|
|
3
|
+
// certhash rotation) that slow down loads (#166). WebTransport is allowed (#475): it needs no
|
|
4
|
+
// certificate authority, so a seeder stays reachable from browsers when its WSS certificate does not
|
|
5
|
+
// (as in the 2026-10-31 AutoTLS outage). The browser build registers the transport; Node has none, so
|
|
6
|
+
// allowing it there changes nothing. Callers can override the gater via
|
|
7
|
+
// `libp2pJsClientsOptions[].libp2pOptions.connectionGater` (see createLibp2pJsClientOrUseExistingOne).
|
|
6
8
|
//
|
|
7
9
|
// These are multiaddr protocol/component names as reported by Multiaddr.getComponents():
|
|
8
10
|
// - "webrtc" => /webrtc (browser-to-browser / relayed WebRTC)
|
|
9
11
|
// - "webrtc-direct" => /webrtc-direct (server-reachable WebRTC, certhash-based)
|
|
10
|
-
|
|
11
|
-
export const DENIED_DIAL_TRANSPORTS_BY_DEFAULT = ["webrtc", "webrtc-direct", "webtransport"];
|
|
12
|
+
export const DENIED_DIAL_TRANSPORTS_BY_DEFAULT = ["webrtc", "webrtc-direct"];
|
|
12
13
|
export function multiaddrUsesDeniedTransport(multiaddr) {
|
|
13
14
|
const componentNames = multiaddr.getComponents().map((component) => component.name);
|
|
14
15
|
return DENIED_DIAL_TRANSPORTS_BY_DEFAULT.some((deniedProto) => componentNames.includes(deniedProto));
|
|
15
16
|
}
|
|
16
|
-
// A connectionGater that rejects dialing any multiaddr using WebRTC
|
|
17
|
-
//
|
|
18
|
-
//
|
|
17
|
+
// A connectionGater that rejects dialing any multiaddr using WebRTC, leaving WebSocket/TCP/WebTransport
|
|
18
|
+
// dials untouched. Helia's libp2p defaults (node + browser) do NOT set a connectionGater, so wiring
|
|
19
|
+
// this in does not clobber any upstream gating behaviour.
|
|
19
20
|
export function createDefaultDialTransportGater() {
|
|
20
21
|
return {
|
|
21
|
-
// Returning true prevents the dial.
|
|
22
|
+
// Returning true prevents the dial.
|
|
22
23
|
denyDialMultiaddr: (multiaddr) => multiaddrUsesDeniedTransport(multiaddr)
|
|
23
24
|
};
|
|
24
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dial-transport-filter.js","sourceRoot":"","sources":["../../../src/helia/dial-transport-filter.ts"],"names":[],"mappings":"AAGA,
|
|
1
|
+
{"version":3,"file":"dial-transport-filter.js","sourceRoot":"","sources":["../../../src/helia/dial-transport-filter.ts"],"names":[],"mappings":"AAGA,uGAAuG;AACvG,qGAAqG;AACrG,8FAA8F;AAC9F,qGAAqG;AACrG,sGAAsG;AACtG,wEAAwE;AACxE,uGAAuG;AACvG,EAAE;AACF,yFAAyF;AACzF,gFAAgF;AAChF,oFAAoF;AACpF,MAAM,CAAC,MAAM,iCAAiC,GAAG,CAAC,QAAQ,EAAE,eAAe,CAAU,CAAC;AAEtF,MAAM,UAAU,4BAA4B,CAAC,SAAoB;IAC7D,MAAM,cAAc,GAAG,SAAS,CAAC,aAAa,EAAE,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACpF,OAAO,iCAAiC,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,cAAc,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC;AACzG,CAAC;AAED,wGAAwG;AACxG,oGAAoG;AACpG,0DAA0D;AAC1D,MAAM,UAAU,+BAA+B;IAC3C,OAAO;QACH,oCAAoC;QACpC,iBAAiB,EAAE,CAAC,SAAoB,EAAE,EAAE,CAAC,4BAA4B,CAAC,SAAS,CAAC;KACvF,CAAC;AACN,CAAC"}
|
|
@@ -9,6 +9,7 @@ import { ipnsValidator } from "ipns/validator";
|
|
|
9
9
|
import { gossipsub } from "@libp2p/gossipsub";
|
|
10
10
|
import { identify } from "@libp2p/identify";
|
|
11
11
|
import extraLibp2pTransports from "../runtime/node/libp2p-extra-transports.js";
|
|
12
|
+
import { installWebTransportCloseShim } from "../runtime/node/webtransport-close-shim.js";
|
|
12
13
|
import { CID } from "multiformats/cid";
|
|
13
14
|
import { sha512 } from "multiformats/hashes/sha2";
|
|
14
15
|
import { peerIdFromString } from "@libp2p/peer-id";
|
|
@@ -25,6 +26,7 @@ import { PKCError } from "../pkc-error.js";
|
|
|
25
26
|
import { Libp2pJsClient } from "./libp2pjsClient.js";
|
|
26
27
|
import { BITSWAP_SESSION_STALLED_GET_FAILOVER_MS, cacheIpnsRecordInPubsubLocalStore, readFreshCachedIpnsRecordFromPubsubLocalStore, connectToPubsubPeers, directFetchIpnsRecordFromProviders, fetchBlockWithStalledSessionFailover, getHeliaDebugContext, REACHABILITY_DOCS_URL, selectBitswapSessionSeedPeers, summarizeProviderReachability } from "./util.js";
|
|
27
28
|
import { createDefaultDialTransportGater } from "./dial-transport-filter.js";
|
|
29
|
+
import { pkcDialAddressSorter } from "./dial-address-sorter.js";
|
|
28
30
|
import { binaryKeyToPubsubTopic, ipnsNameToIpnsOverPubsubTopic } from "../util.js";
|
|
29
31
|
const log = Logger("pkc-js:libp2p-js");
|
|
30
32
|
const libp2pJsClients = {}; // key => pkc.clients.libp2pJsClients[key]
|
|
@@ -149,6 +151,9 @@ export async function createLibp2pJsClientOrUseExistingOne(pkcOptions) {
|
|
|
149
151
|
let startedHelia;
|
|
150
152
|
let closeBlockstore = async () => { };
|
|
151
153
|
creatingLibp2pJsClients[pkcOptions.key] = (async () => {
|
|
154
|
+
// Must run before libp2p exists: Chromium crashes the tab when @libp2p/webtransport aborts a
|
|
155
|
+
// connection that has a write pending (pkc-js#495, libp2p/js-libp2p#3699). No-op outside browsers.
|
|
156
|
+
installWebTransportCloseShim();
|
|
152
157
|
deleteLeftoverDelegatedRoutingCache();
|
|
153
158
|
// A caller supplying their own heliaOptions.blockstore owns block storage entirely, so skip
|
|
154
159
|
// ours rather than opening a directory or IndexedDB database nothing will read.
|
|
@@ -186,12 +191,15 @@ export async function createLibp2pJsClientOrUseExistingOne(pkcOptions) {
|
|
|
186
191
|
// traffic and gets timed out, killing connections mid-fetch. Disable the abort
|
|
187
192
|
// (ping still runs as an RTT signal).
|
|
188
193
|
connectionMonitor: { abortConnectionOnPingFailure: false },
|
|
189
|
-
// By default reject WebRTC
|
|
190
|
-
//
|
|
194
|
+
// By default reject WebRTC dials so browser nodes connect over WebSocket(/WSS) or
|
|
195
|
+
// WebTransport (#166, #475). Helia's libp2p defaults set no connectionGater, so nothing
|
|
191
196
|
// upstream is clobbered. Placed BEFORE the spread so a caller can fully override
|
|
192
197
|
// it via libp2pJsClientsOptions[].libp2pOptions.connectionGater (e.g. to re-enable
|
|
193
|
-
// WebRTC
|
|
198
|
+
// WebRTC, or allow-all in tests).
|
|
194
199
|
connectionGater: createDefaultDialTransportGater(),
|
|
200
|
+
// Try UDP 443 and IPv6 before IPv4 UDP 4001, which some networks filter (#475). Same
|
|
201
|
+
// override rule: a caller's libp2pOptions.connectionManager replaces this object.
|
|
202
|
+
connectionManager: { addressSorter: pkcDialAddressSorter },
|
|
195
203
|
...pkcOptions.libp2pOptions,
|
|
196
204
|
// Configure connection manager to handle more concurrent streams
|
|
197
205
|
services: {
|