@pkcprotocol/pkc-js 0.0.79 → 0.0.80
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/community/community-client-manager.d.ts +2 -0
- package/dist/browser/community/community-client-manager.js +164 -9
- package/dist/browser/community/community-client-manager.js.map +1 -1
- package/dist/browser/community/remote-community.d.ts +2 -1
- package/dist/browser/community/remote-community.js +30 -7
- package/dist/browser/community/remote-community.js.map +1 -1
- package/dist/browser/community/rpc-local-community.js.map +1 -1
- package/dist/browser/community/schema.d.ts +31 -4
- package/dist/browser/community/schema.js +16 -10
- package/dist/browser/community/schema.js.map +1 -1
- package/dist/browser/errors.d.ts +3 -0
- package/dist/browser/errors.js +3 -0
- package/dist/browser/errors.js.map +1 -1
- package/dist/browser/generated-version.d.ts +1 -1
- package/dist/browser/generated-version.js +1 -1
- package/dist/browser/pkc-error.d.ts +1 -1
- package/dist/browser/runtime/node/community/local-community/publication-validation.js +7 -1
- package/dist/browser/runtime/node/community/local-community/publication-validation.js.map +1 -1
- package/dist/browser/schema/schema-util.d.ts +15 -0
- package/dist/browser/signer/signatures.d.ts +1 -0
- package/dist/browser/signer/signatures.js +25 -2
- package/dist/browser/signer/signatures.js.map +1 -1
- package/dist/browser/test/test-util.d.ts +7 -0
- package/dist/browser/test/test-util.js +6 -0
- package/dist/browser/test/test-util.js.map +1 -1
- package/dist/bundled/bundle-manifest.json +25 -25
- package/dist/bundled/chunks/{helia-for-pkc-7wubsFuU.js → helia-for-pkc-BsYWQ7qS.js} +58 -58
- package/dist/bundled/chunks/{local-community-BhRsFFg0.js → local-community-CHzhypCp.js} +30 -27
- package/dist/bundled/chunks/{local-community-Cs0aQLE3.js → local-community-EqWKTLxr.js} +1 -1
- package/dist/bundled/chunks/{node-BKnzoR3G.js → node-4qAZNuJG.js} +5 -5
- package/dist/bundled/chunks/{rpc-local-community-DlgrBPH8.js → rpc-local-community-Cog5rZLG.js} +123 -34
- package/dist/bundled/chunks/{schema-C_dFmYMp.js → schema-Iavj-cRD.js} +6 -2
- package/dist/bundled/chunks/{util-CsiYk_QO.js → util-CfSUfLkV.js} +1 -1
- package/dist/bundled/index.js +1 -1
- package/dist/bundled/rpc/src/index.js +4 -4
- package/dist/node/community/community-client-manager.d.ts +2 -0
- package/dist/node/community/community-client-manager.js +164 -9
- package/dist/node/community/community-client-manager.js.map +1 -1
- package/dist/node/community/remote-community.d.ts +2 -1
- package/dist/node/community/remote-community.js +30 -7
- package/dist/node/community/remote-community.js.map +1 -1
- package/dist/node/community/rpc-local-community.js.map +1 -1
- package/dist/node/community/schema.d.ts +31 -4
- package/dist/node/community/schema.js +16 -10
- package/dist/node/community/schema.js.map +1 -1
- package/dist/node/errors.d.ts +3 -0
- package/dist/node/errors.js +3 -0
- package/dist/node/errors.js.map +1 -1
- package/dist/node/generated-version.d.ts +1 -1
- package/dist/node/generated-version.js +1 -1
- package/dist/node/pkc-error.d.ts +1 -1
- package/dist/node/runtime/node/community/local-community/publication-validation.js +7 -1
- package/dist/node/runtime/node/community/local-community/publication-validation.js.map +1 -1
- package/dist/node/schema/schema-util.d.ts +15 -0
- package/dist/node/signer/signatures.d.ts +1 -0
- package/dist/node/signer/signatures.js +25 -2
- package/dist/node/signer/signatures.js.map +1 -1
- package/dist/node/test/test-util.d.ts +7 -0
- package/dist/node/test/test-util.js +6 -0
- package/dist/node/test/test-util.js.map +1 -1
- package/package.json +1 -1
package/dist/bundled/chunks/{rpc-local-community-DlgrBPH8.js → rpc-local-community-Cog5rZLG.js}
RENAMED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { i as __toESM, n as __exportAll, r as __require, t as __commonJSMin } from "./chunk-2rV9d50f.js";
|
|
2
|
-
import { $ as pubsubTopicToDhtKey, $n as n$9, $t as CommunityChallengeSettingSchema, A as extractNetworkErrorDetails, Ar as object, At as trackStartedCommunity, B as isIpfsCid, Cn as CommentUpdateChallengeReservedFieldNames, Ct as findUpdatingCommunity, D as deepMergeRuntimeFields, Dn as CommentUpdateSchema, Dr as custom, E as createAbortError, En as CommentUpdateReservedFields, Er as boolean, Et as listUpdatingCommunities, Fn as CommentEditChallengeRequestToEncryptSchema, Ft as untrackUpdatingCommunity, Gn as ChallengeAnswersSchema, Gt as CommentModerationPubsubMessagePublicationSchema, H as isIpns, Hn as AuthorAddressSchema, Ht as CommunityEditPubsubMessagePublicationSchema, I as getPostUpdateTimestampRange, It as require_sha256$1, Jn as CommunityAddressSchema, Jt as CommentModerationsTableRowSchema, Kn as CidPathSchema, L as hideClassPrivateProps, Ln as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema, Mn as GetPageParamSchema, Mr as string, Mt as trackUpdatingCommunity, Nn as ModQueuePageIpfsSchema, Nt as untrackStartedCommunity, O as derivePublicationFromChallengeRequest, On as CommentUpdateSignedPropertyNames, Or as literal, Ot as refreshTrackedCommunityAliases, Pn as PageIpfsSchema, Q as isStringDomain, R as ipnsNameToIpnsOverPubsubTopic, Rt as pTimeout, Sn as CommentSignedPropertyNames, Sr as require_ms$1, St as findUpdatingComment, Tn as CommentUpdateForChallengeVerificationSignedPropertyNames, Tr as array, U as isIpnsPath, Un as AuthorCommentIpfsReservedFields, Ut as CreateCommunityEditPublicationOptionsWithRefinementSchema, V as isIpfsPath, Vn as CreateCommentEditOptionsWithRefinementSchema, Vt as CommunityEditPublicationSignedPropertyNames, Wt as CommentModerationChallengeRequestToEncryptSchema, X as isRequestPubsubPublicationOfPost, Xn as CreateSignerSchema, Xt as ChallengeFileFactorySchema, Yn as CommunityAuthorChallengeReservedFieldNames, Yt as CreateCommentModerationOptionsWithRefinementSchema, Z as isRequestPubsubPublicationOfReply, Zn as n$10, Zt as ChallengeFileSchema, _ as PKCUserOptionBaseSchema, _n as CommentChallengeRequestToEncryptSchema, _r as FailedToFetchPageIpfsFromGatewaysError, _t as timestamp, an as CreateNewLocalCommunityUserOptionsSchema, ar as r$8, b as areEquivalentCommunityAddresses, br as logger_default, c as ChallengeVerificationMessageSignedPropertyNames, cn as ExportCommunityModLogsOptionsSchema, cr as r$7, ct as resolveWhenPredicateIsTrue, dn as CreateVoteUserOptionsWithRefinementSchema, dr as e$4, en as CommunityEditOptionsSchema, f as DecryptedChallengeSchema, fn as VoteChallengeRequestToEncryptSchema, fr as require_retry$1, ft as shortifyAddress, g as PKCParsedOptionsSchema, gr as FailedToFetchGenericIpfsFromGatewaysError, gt as throwIfAbortSignalAborted, h as NameResolverSerializedSchema, hn as VoteSignedPropertyNames, hr as FailedToFetchCommunityFromGatewaysError, i as ChallengeMessageSignedPropertyNames, in as CommunitySignedPropertyNames, ir as t$11, it as removeNullUndefinedEmptyObjectsValuesRecursively, j as fetchAndValidateIpnsRecordFromGateway, jn as CreateCommentOptionsWithRefinementSchema, jr as record, k as doesDomainAddressHaveCapitalLetter, kr as number, l as DecryptedChallengeAnswerSchema, lr as t$10, m as NameResolveCacheOptionsSchema, mr as FailedToFetchCommentUpdateFromGatewaysError, mt as sleepUntilTimeoutOrAbort, n as ChallengeAnswerMessageSignedPropertyNames, nn as CommunityIpfsReservedFields, nr as e$6, o as ChallengeRequestMessageSignedPropertyNames, on as CreateRemoteCommunityFunctionArgumentSchema, or as t$12, p as DecryptedChallengeVerificationSchema, pn as VotePubsubMessagePublicationSchema, pr as FailedToFetchCommentIpfsFromGatewaysError, pt as shortifyCid, qn as CidStringSchema, qt as CommentModerationSignedPropertyNames, rn as CommunityIpfsSchema, rr as e$5, sn as CreateRpcCommunityFunctionArgumentSchema, sr as n$8, tn as CommunityExportRecordsSchema, tr as t$13, tt as raceAgainstAbort, un as RpcRemoteCommunityUpdateEventResultSchema, ur as t$9, v as PKCUserOptionsSchema, vn as CommentIpfsReservedFields, vr as PKCError, vt as waitForUpdateInCommunityInstanceWithErrorAndTimeout, wr as _enum, wt as listStartedCommunities, x as calculateIpfsCidV0, xn as CommentPubsubMessageWithFlexibleAuthorRefinementSchema, xr as require_supports_color, xt as findStartedCommunity, yn as CommentIpfsSchema, yr as messages, z as isAbortError, zn as CommentEditSignedPropertyNames, zt as CommunityEditPublicationChallengeRequestToEncryptSchema } from "./schema-
|
|
2
|
+
import { $ as pubsubTopicToDhtKey, $n as n$9, $t as CommunityChallengeSettingSchema, A as extractNetworkErrorDetails, Ar as object, At as trackStartedCommunity, B as isIpfsCid, Cn as CommentUpdateChallengeReservedFieldNames, Ct as findUpdatingCommunity, D as deepMergeRuntimeFields, Dn as CommentUpdateSchema, Dr as custom, E as createAbortError, En as CommentUpdateReservedFields, Er as boolean, Et as listUpdatingCommunities, Fn as CommentEditChallengeRequestToEncryptSchema, Ft as untrackUpdatingCommunity, Gn as ChallengeAnswersSchema, Gt as CommentModerationPubsubMessagePublicationSchema, H as isIpns, Hn as AuthorAddressSchema, Ht as CommunityEditPubsubMessagePublicationSchema, I as getPostUpdateTimestampRange, It as require_sha256$1, Jn as CommunityAddressSchema, Jt as CommentModerationsTableRowSchema, Kn as CidPathSchema, L as hideClassPrivateProps, Ln as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema, Mn as GetPageParamSchema, Mr as string, Mt as trackUpdatingCommunity, Nn as ModQueuePageIpfsSchema, Nt as untrackStartedCommunity, O as derivePublicationFromChallengeRequest, On as CommentUpdateSignedPropertyNames, Or as literal, Ot as refreshTrackedCommunityAliases, Pn as PageIpfsSchema, Q as isStringDomain, R as ipnsNameToIpnsOverPubsubTopic, Rt as pTimeout, Sn as CommentSignedPropertyNames, Sr as require_ms$1, St as findUpdatingComment, Tn as CommentUpdateForChallengeVerificationSignedPropertyNames, Tr as array, U as isIpnsPath, Un as AuthorCommentIpfsReservedFields, Ut as CreateCommunityEditPublicationOptionsWithRefinementSchema, V as isIpfsPath, Vn as CreateCommentEditOptionsWithRefinementSchema, Vt as CommunityEditPublicationSignedPropertyNames, Wt as CommentModerationChallengeRequestToEncryptSchema, X as isRequestPubsubPublicationOfPost, Xn as CreateSignerSchema, Xt as ChallengeFileFactorySchema, Yn as CommunityAuthorChallengeReservedFieldNames, Yt as CreateCommentModerationOptionsWithRefinementSchema, Z as isRequestPubsubPublicationOfReply, Zn as n$10, Zt as ChallengeFileSchema, _ as PKCUserOptionBaseSchema, _n as CommentChallengeRequestToEncryptSchema, _r as FailedToFetchPageIpfsFromGatewaysError, _t as timestamp, an as CreateNewLocalCommunityUserOptionsSchema, ar as r$8, b as areEquivalentCommunityAddresses, br as logger_default, c as ChallengeVerificationMessageSignedPropertyNames, cn as ExportCommunityModLogsOptionsSchema, cr as r$7, ct as resolveWhenPredicateIsTrue, dn as CreateVoteUserOptionsWithRefinementSchema, dr as e$4, en as CommunityEditOptionsSchema, f as DecryptedChallengeSchema, fn as VoteChallengeRequestToEncryptSchema, fr as require_retry$1, ft as shortifyAddress, g as PKCParsedOptionsSchema, gr as FailedToFetchGenericIpfsFromGatewaysError, gt as throwIfAbortSignalAborted, h as NameResolverSerializedSchema, hn as VoteSignedPropertyNames, hr as FailedToFetchCommunityFromGatewaysError, i as ChallengeMessageSignedPropertyNames, in as CommunitySignedPropertyNames, ir as t$11, it as removeNullUndefinedEmptyObjectsValuesRecursively, j as fetchAndValidateIpnsRecordFromGateway, jn as CreateCommentOptionsWithRefinementSchema, jr as record, k as doesDomainAddressHaveCapitalLetter, kr as number, l as DecryptedChallengeAnswerSchema, lr as t$10, m as NameResolveCacheOptionsSchema, mr as FailedToFetchCommentUpdateFromGatewaysError, mt as sleepUntilTimeoutOrAbort, n as ChallengeAnswerMessageSignedPropertyNames, nn as CommunityIpfsReservedFields, nr as e$6, o as ChallengeRequestMessageSignedPropertyNames, on as CreateRemoteCommunityFunctionArgumentSchema, or as t$12, p as DecryptedChallengeVerificationSchema, pn as VotePubsubMessagePublicationSchema, pr as FailedToFetchCommentIpfsFromGatewaysError, pt as shortifyCid, qn as CidStringSchema, qt as CommentModerationSignedPropertyNames, rn as CommunityIpfsSchema, rr as e$5, sn as CreateRpcCommunityFunctionArgumentSchema, sr as n$8, tn as CommunityExportRecordsSchema, tr as t$13, tt as raceAgainstAbort, un as RpcRemoteCommunityUpdateEventResultSchema, ur as t$9, v as PKCUserOptionsSchema, vn as CommentIpfsReservedFields, vr as PKCError, vt as waitForUpdateInCommunityInstanceWithErrorAndTimeout, wr as _enum, wt as listStartedCommunities, x as calculateIpfsCidV0, xn as CommentPubsubMessageWithFlexibleAuthorRefinementSchema, xr as require_supports_color, xt as findStartedCommunity, yn as CommentIpfsSchema, yr as messages, z as isAbortError, zn as CommentEditSignedPropertyNames, zt as CommunityEditPublicationChallengeRequestToEncryptSchema } from "./schema-Iavj-cRD.js";
|
|
3
3
|
import { t as all } from "./src-CYIMjhjK.js";
|
|
4
4
|
import http from "node:http";
|
|
5
5
|
import { createHash } from "node:crypto";
|
|
6
6
|
import { pathToFileURL } from "node:url";
|
|
7
|
-
import
|
|
8
|
-
import
|
|
7
|
+
import fs from "node:fs/promises";
|
|
8
|
+
import path from "node:path";
|
|
9
9
|
import dns from "node:dns";
|
|
10
10
|
import os from "os";
|
|
11
11
|
import { closeSync, createReadStream, existsSync, openSync, promises, readSync, readdirSync, rm, watch } from "node:fs";
|
|
12
|
-
import path from "path";
|
|
12
|
+
import path$1 from "path";
|
|
13
13
|
import assert from "assert";
|
|
14
14
|
import { Agent } from "https";
|
|
15
15
|
import { Agent as Agent$1 } from "http";
|
|
@@ -88345,7 +88345,7 @@ var require_package$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
88345
88345
|
//#endregion
|
|
88346
88346
|
//#region node_modules/needle/lib/needle.js
|
|
88347
88347
|
var require_needle = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
88348
|
-
var fs = __require("fs"), http$2 = __require("http"), https$1 = __require("https"), url = __require("url"), stream = __require("stream"), debug$2 = require_src()("needle"), stringify$1 = require_querystring().build, multipart = require_multipart(), auth = require_auth(), cookies = require_cookies(), parsers = require_parsers(), decoder = require_decoder();
|
|
88348
|
+
var fs$1 = __require("fs"), http$2 = __require("http"), https$1 = __require("https"), url = __require("url"), stream = __require("stream"), debug$2 = require_src()("needle"), stringify$1 = require_querystring().build, multipart = require_multipart(), auth = require_auth(), cookies = require_cookies(), parsers = require_parsers(), decoder = require_decoder();
|
|
88349
88349
|
var version = require_package$1().version;
|
|
88350
88350
|
var user_agent = "Needle/" + version;
|
|
88351
88351
|
user_agent += " (Node.js " + process.version + "; " + process.platform + " " + process.arch + ")";
|
|
@@ -88437,7 +88437,7 @@ var require_needle = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
88437
88437
|
function get_stream_length(stream, given_length, cb) {
|
|
88438
88438
|
if (given_length > 0) return cb(given_length);
|
|
88439
88439
|
if (stream.end !== void 0 && stream.end !== Infinity && stream.start !== void 0) return cb(stream.end + 1 - (stream.start || 0));
|
|
88440
|
-
fs.stat(stream.path, function(err, stat) {
|
|
88440
|
+
fs$1.stat(stream.path, function(err, stat) {
|
|
88441
88441
|
cb(stat ? stat.size - (stream.start || 0) : null);
|
|
88442
88442
|
});
|
|
88443
88443
|
}
|
|
@@ -88700,7 +88700,7 @@ var require_needle = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
88700
88700
|
if (err && err.message == "write after end") request.destroy();
|
|
88701
88701
|
});
|
|
88702
88702
|
if (config.output && resp.statusCode == 200) {
|
|
88703
|
-
var file = fs.createWriteStream(config.output);
|
|
88703
|
+
var file = fs$1.createWriteStream(config.output);
|
|
88704
88704
|
file.on("error", had_error);
|
|
88705
88705
|
out.on("end", function() {
|
|
88706
88706
|
if (file.writable) file.end();
|
|
@@ -97817,7 +97817,7 @@ function _allFieldsOfRecordInSignedPropertyNames(record) {
|
|
|
97817
97817
|
async function verifyCommunity({ community, communityIpnsHops, resolveAuthorNames, clientsManager, validatePages, cacheIfValid, abortSignal }) {
|
|
97818
97818
|
const log = logger_default("pkc-js:signatures:verifyCommunity");
|
|
97819
97819
|
if (!Array.isArray(communityIpnsHops) || communityIpnsHops.length === 0) throw Error("verifyCommunity needs a non-empty communityIpnsHops to verify a community record against");
|
|
97820
|
-
const communityIdentityIpnsName = communityIpnsHops[0];
|
|
97820
|
+
const communityIdentityIpnsName = community.anchor?.publicKey ?? communityIpnsHops[0];
|
|
97821
97821
|
const terminalIpnsName = communityIpnsHops[communityIpnsHops.length - 1];
|
|
97822
97822
|
if (!_allFieldsOfRecordInSignedPropertyNames(community)) return {
|
|
97823
97823
|
valid: false,
|
|
@@ -97827,6 +97827,10 @@ async function verifyCommunity({ community, communityIpnsHops, resolveAuthorName
|
|
|
97827
97827
|
valid: false,
|
|
97828
97828
|
reason: messages.ERR_COMMUNITY_RECORD_INCLUDES_RESERVED_FIELD
|
|
97829
97829
|
};
|
|
97830
|
+
if (communityIpnsHops.length > 1 && community.anchor?.publicKey !== communityIpnsHops[0]) return {
|
|
97831
|
+
valid: false,
|
|
97832
|
+
reason: messages.ERR_COMMUNITY_RECORD_ANCHOR_CLAIM_DOES_NOT_MATCH_CHAIN_ANCHOR
|
|
97833
|
+
};
|
|
97830
97834
|
if (!await _verifyJsonSignature(community)) return {
|
|
97831
97835
|
valid: false,
|
|
97832
97836
|
reason: messages.ERR_COMMUNITY_SIGNATURE_IS_INVALID
|
|
@@ -97838,7 +97842,8 @@ async function verifyCommunity({ community, communityIpnsHops, resolveAuthorName
|
|
|
97838
97842
|
const communityForPages = {
|
|
97839
97843
|
publicKey: communityIdentityIpnsName,
|
|
97840
97844
|
name: community.name,
|
|
97841
|
-
signature: community.signature
|
|
97845
|
+
signature: community.signature,
|
|
97846
|
+
anchor: community.anchor
|
|
97842
97847
|
};
|
|
97843
97848
|
if (community.posts?.pages && validatePages) for (const preloadedPageSortName of t$13(community.posts.pages)) {
|
|
97844
97849
|
const pageCid = community.posts.pageCids?.[preloadedPageSortName];
|
|
@@ -98053,6 +98058,13 @@ async function verifyPageComment({ pageComment, community, parentComment, resolv
|
|
|
98053
98058
|
};
|
|
98054
98059
|
}
|
|
98055
98060
|
const commentRecord = pageComment.comment;
|
|
98061
|
+
if (community.anchor?.publicKey) {
|
|
98062
|
+
const communityPublicKeyFromRecord = getCommunityPublicKeyFromWire(commentRecord);
|
|
98063
|
+
if (communityPublicKeyFromRecord && !areEquivalentCommunityAddresses(communityPublicKeyFromRecord, community.anchor.publicKey)) return {
|
|
98064
|
+
valid: false,
|
|
98065
|
+
reason: messages.ERR_COMMENT_IN_PAGE_BELONG_TO_DIFFERENT_COMMUNITY
|
|
98066
|
+
};
|
|
98067
|
+
}
|
|
98056
98068
|
if (community.name) {
|
|
98057
98069
|
const communityNameFromRecord = getCommunityNameFromWire$1(commentRecord);
|
|
98058
98070
|
if (communityNameFromRecord && !areEquivalentCommunityAddresses(communityNameFromRecord, community.name)) return {
|
|
@@ -101620,14 +101632,14 @@ var CommentClientsManager = class extends PublicationClientsManager {
|
|
|
101620
101632
|
};
|
|
101621
101633
|
//#endregion
|
|
101622
101634
|
//#region dist/node/runtime/node/util.js
|
|
101623
|
-
const getDefaultDataPath = () => path.join(process.cwd(), ".pkc");
|
|
101635
|
+
const getDefaultDataPath = () => path$1.join(process.cwd(), ".pkc");
|
|
101624
101636
|
const getDefaultCommunityDbConfig = async (communityAddress, pkc) => {
|
|
101625
101637
|
let filename;
|
|
101626
101638
|
if (pkc.noData) filename = ":memory:";
|
|
101627
101639
|
else {
|
|
101628
101640
|
assert(typeof pkc.dataPath === "string", "pkc.dataPath need to be defined to get default community db config");
|
|
101629
|
-
filename = path.join(pkc.dataPath, "communities", communityAddress);
|
|
101630
|
-
await promises.mkdir(path.dirname(filename), { recursive: true });
|
|
101641
|
+
filename = path$1.join(pkc.dataPath, "communities", communityAddress);
|
|
101642
|
+
await promises.mkdir(path$1.dirname(filename), { recursive: true });
|
|
101631
101643
|
}
|
|
101632
101644
|
return {
|
|
101633
101645
|
filename,
|
|
@@ -101726,7 +101738,7 @@ const setNativeFunctions = (newNativeFunctions) => {
|
|
|
101726
101738
|
};
|
|
101727
101739
|
const deleteOldCommunityInWindows = async (subPath, pkc) => {
|
|
101728
101740
|
const log = logger_default("pkc-js:community:deleteStaleCommunityInWindows");
|
|
101729
|
-
const communityAddress = path.basename(subPath);
|
|
101741
|
+
const communityAddress = path$1.basename(subPath);
|
|
101730
101742
|
await new Promise((resolve) => setTimeout(resolve, 1e4));
|
|
101731
101743
|
try {
|
|
101732
101744
|
await promises.rm(subPath, { force: true });
|
|
@@ -101750,7 +101762,7 @@ async function tryToDeleteCommunitiesThatFailedToBeDeletedBefore(pkc, log) {
|
|
|
101750
101762
|
}
|
|
101751
101763
|
const communitiesThatWereDeletedSuccessfully = [];
|
|
101752
101764
|
for (const communityAddress of deletedPersistentCommunities) {
|
|
101753
|
-
const communityPath = path.join(pkc.dataPath, "communities", communityAddress);
|
|
101765
|
+
const communityPath = path$1.join(pkc.dataPath, "communities", communityAddress);
|
|
101754
101766
|
try {
|
|
101755
101767
|
await promises.rm(communityPath, { force: true });
|
|
101756
101768
|
log(`Succeeded in deleting old db path (${communityAddress})`);
|
|
@@ -101774,7 +101786,7 @@ async function tryToDeleteCommunitiesThatFailedToBeDeletedBefore(pkc, log) {
|
|
|
101774
101786
|
function listCommunitiesSync(pkc) {
|
|
101775
101787
|
logger_default("pkc-js:listCommunitiesSync");
|
|
101776
101788
|
if (typeof pkc.dataPath !== "string") throw Error("pkc.dataPath needs to be defined to listCommunities");
|
|
101777
|
-
const communitiesPath = path.join(pkc.dataPath, "communities");
|
|
101789
|
+
const communitiesPath = path$1.join(pkc.dataPath, "communities");
|
|
101778
101790
|
const files = readdirSync(communitiesPath, {
|
|
101779
101791
|
recursive: false,
|
|
101780
101792
|
withFileTypes: false
|
|
@@ -101782,7 +101794,7 @@ function listCommunitiesSync(pkc) {
|
|
|
101782
101794
|
const communityFilesWeDontNeedToCheck = pkc.communities ? files.filter((address) => pkc.communities.includes(address)) : [];
|
|
101783
101795
|
const sqliteFiles = files.filter((address) => !communityFilesWeDontNeedToCheck.includes(address)).filter((address) => {
|
|
101784
101796
|
try {
|
|
101785
|
-
const filePath = path.join(communitiesPath, address);
|
|
101797
|
+
const filePath = path$1.join(communitiesPath, address);
|
|
101786
101798
|
if (!existsSync(filePath)) return false;
|
|
101787
101799
|
const fd = openSync(filePath, "r");
|
|
101788
101800
|
const buffer = Buffer.alloc(16);
|
|
@@ -101863,7 +101875,7 @@ var BackupAbortError = class extends Error {
|
|
|
101863
101875
|
async function backupCommunityDb(opts) {
|
|
101864
101876
|
const { sourcePath, destPath, includePrivateKey, onProgress, signal } = opts;
|
|
101865
101877
|
if (signal?.aborted) throw new BackupAbortError();
|
|
101866
|
-
await promises.mkdir(path.dirname(destPath), { recursive: true });
|
|
101878
|
+
await promises.mkdir(path$1.dirname(destPath), { recursive: true });
|
|
101867
101879
|
const partialPath = destPath + ".partial";
|
|
101868
101880
|
try {
|
|
101869
101881
|
await promises.unlink(partialPath);
|
|
@@ -101947,9 +101959,9 @@ async function statAndHashFile(filePath) {
|
|
|
101947
101959
|
}
|
|
101948
101960
|
async function moveCommunityDbToDeletedDirectory(communityAddress, pkc) {
|
|
101949
101961
|
if (typeof pkc.dataPath !== "string") throw Error("pkc.dataPath is not defined");
|
|
101950
|
-
const oldPath = path.join(pkc.dataPath, "communities", communityAddress);
|
|
101951
|
-
const newPath = path.join(pkc.dataPath, "communities", "deleted", communityAddress);
|
|
101952
|
-
await promises.mkdir(path.join(pkc.dataPath, "communities", "deleted"), { recursive: true });
|
|
101962
|
+
const oldPath = path$1.join(pkc.dataPath, "communities", communityAddress);
|
|
101963
|
+
const newPath = path$1.join(pkc.dataPath, "communities", "deleted", communityAddress);
|
|
101964
|
+
await promises.mkdir(path$1.join(pkc.dataPath, "communities", "deleted"), { recursive: true });
|
|
101953
101965
|
if (!existsSync(oldPath)) throw Error(`Source database ${oldPath} does not exist`);
|
|
101954
101966
|
try {
|
|
101955
101967
|
const sourceDb = new Database(oldPath, { fileMustExist: true });
|
|
@@ -101985,7 +101997,7 @@ async function createKuboRpcClient(kuboRpcClientOptions) {
|
|
|
101985
101997
|
}
|
|
101986
101998
|
async function monitorCommunitiesDirectory(pkc) {
|
|
101987
101999
|
const watchAbortController = new AbortController();
|
|
101988
|
-
const communitiesPath = path.join(pkc.dataPath, "communities");
|
|
102000
|
+
const communitiesPath = path$1.join(pkc.dataPath, "communities");
|
|
101989
102001
|
await promises.mkdir(communitiesPath, { recursive: true });
|
|
101990
102002
|
const extensionsToIgnore = [
|
|
101991
102003
|
".lock",
|
|
@@ -124882,9 +124894,12 @@ var CommunityClientsManager = class extends PKCClientsManager {
|
|
|
124882
124894
|
newUpdatingState: "failed"
|
|
124883
124895
|
});
|
|
124884
124896
|
} else if (communityLoadingRes?.community && (this._community.raw.communityIpfs?.updatedAt || 0) < communityLoadingRes.community.updatedAt) {
|
|
124897
|
+
const publicKeyBeforeApply = this._community.publicKey;
|
|
124885
124898
|
this._community.initCommunityIpfsPropsNoMerge(communityLoadingRes.community);
|
|
124886
124899
|
this._community.updateCid = communityLoadingRes.cid;
|
|
124900
|
+
if (publicKeyBeforeApply && this._community.publicKey !== publicKeyBeforeApply) this._community.nameResolved = void 0;
|
|
124887
124901
|
if (!isStringDomain(this._community.address) && this._community.name && this._community.publicKey && typeof this._community.nameResolved !== "boolean") this._resolveNameInBackground(this._community.name);
|
|
124902
|
+
else if (isStringDomain(this._community.address) && this._community.publicKey && typeof this._community.nameResolved !== "boolean") this._resolveNameInBackground(this._community.address);
|
|
124888
124903
|
log(`Remote Community`, this._community.address, `received a new update. Will emit an update event with updatedAt`, this._community.updatedAt, "that's", timestamp() - this._community.updatedAt, "seconds old");
|
|
124889
124904
|
this._community._changeStateEmitEventEmitStateChangeEvent({
|
|
124890
124905
|
event: {
|
|
@@ -124927,6 +124942,14 @@ var CommunityClientsManager = class extends PKCClientsManager {
|
|
|
124927
124942
|
this._suppressUpdatingStateForNameResolution--;
|
|
124928
124943
|
}
|
|
124929
124944
|
}
|
|
124945
|
+
_nonAnchorHopsOfLoadedChain() {
|
|
124946
|
+
const loadedRecord = this._community.raw.communityIpfs;
|
|
124947
|
+
if (!loadedRecord) return void 0;
|
|
124948
|
+
const chainKeys = new Set(this._community.ipnsHops ?? []);
|
|
124949
|
+
chainKeys.add(getPKCAddressFromPublicKeySync(loadedRecord.signature.publicKey));
|
|
124950
|
+
if (this._community.publicKey) chainKeys.delete(this._community.publicKey);
|
|
124951
|
+
return [...chainKeys];
|
|
124952
|
+
}
|
|
124930
124953
|
_resolveNameInBackground(name) {
|
|
124931
124954
|
const log = logger_default("pkc-js:community-client-manager:_resolveNameInBackground");
|
|
124932
124955
|
const setNameResolvedAndEmitUpdate = (newNameResolved) => {
|
|
@@ -124940,6 +124963,11 @@ var CommunityClientsManager = class extends PKCClientsManager {
|
|
|
124940
124963
|
cache: { maxAge: 3600 }
|
|
124941
124964
|
}).then((resolved) => {
|
|
124942
124965
|
if (resolved && resolved !== this._community.publicKey) {
|
|
124966
|
+
if (this._nonAnchorHopsOfLoadedChain()?.includes(resolved)) {
|
|
124967
|
+
log(`Community name ${name} resolves to ${resolved}, a non-anchor hop of the community's own chain, instead of its identity ${this._community.publicKey}. Marking nameResolved false`);
|
|
124968
|
+
setNameResolvedAndEmitUpdate(false);
|
|
124969
|
+
return;
|
|
124970
|
+
}
|
|
124943
124971
|
log("Key migration detected for", name, "old:", this._community.publicKey, "new:", resolved);
|
|
124944
124972
|
const previousPublicKey = this._community.publicKey;
|
|
124945
124973
|
const error = new PKCError("ERR_COMMUNITY_NAME_RESOLVES_TO_DIFFERENT_PUBLIC_KEY", {
|
|
@@ -124989,7 +125017,8 @@ var CommunityClientsManager = class extends PKCClientsManager {
|
|
|
124989
125017
|
return this._withInflightCommunityFetch(communityAddress, async () => {
|
|
124990
125018
|
let ipnsName;
|
|
124991
125019
|
const isDomain = isStringDomain(communityAddress);
|
|
124992
|
-
|
|
125020
|
+
const hasAnchorClaim = Boolean(this._community.anchor);
|
|
125021
|
+
if (this._community.publicKey && (isDomain || hasAnchorClaim || !isDomain && this._community.name && this._community.nameResolved === true)) {
|
|
124993
125022
|
ipnsName = this._community.publicKey;
|
|
124994
125023
|
if (isDomain) this._resolveNameInBackground(communityAddress);
|
|
124995
125024
|
} else ipnsName = await this.resolveCommunityNameIfNeeded({
|
|
@@ -125027,12 +125056,13 @@ var CommunityClientsManager = class extends PKCClientsManager {
|
|
|
125027
125056
|
}
|
|
125028
125057
|
} else subRes = await this._fetchCommunityFromGateways(ipnsName);
|
|
125029
125058
|
if (subRes?.community) {
|
|
125030
|
-
const
|
|
125059
|
+
const identityPublicKey = subRes.community.anchor?.publicKey ?? ipnsName;
|
|
125060
|
+
const anchorIdentityAddress = subRes.community.name || identityPublicKey;
|
|
125031
125061
|
this._pkc._memCaches.communityForPublishing.set(anchorIdentityAddress, {
|
|
125032
125062
|
encryption: subRes.community.encryption,
|
|
125033
125063
|
pubsubTopic: subRes.community.pubsubTopic,
|
|
125034
125064
|
address: anchorIdentityAddress,
|
|
125035
|
-
publicKey:
|
|
125065
|
+
publicKey: identityPublicKey,
|
|
125036
125066
|
name: subRes.community.name
|
|
125037
125067
|
});
|
|
125038
125068
|
}
|
|
@@ -125080,9 +125110,18 @@ var CommunityClientsManager = class extends PKCClientsManager {
|
|
|
125080
125110
|
this._updateCidsAlreadyLoaded.add(latestCommunityCid);
|
|
125081
125111
|
try {
|
|
125082
125112
|
const communityIpfs = parseCommunityIpfsSchemaPassthroughWithPKCErrorIfItFails(parseJsonWithPKCErrorIfFails(rawCommunityJsonString));
|
|
125113
|
+
const provenIpnsHops = await this._proveAnchorClaimIfUnwalked({
|
|
125114
|
+
communityJson: communityIpfs,
|
|
125115
|
+
ipnsHops,
|
|
125116
|
+
resolveChainOfClaimedAnchor: async (claimedAnchor) => (await this.resolveIpnsToCidP2P(claimedAnchor, {
|
|
125117
|
+
timeoutMs: this._pkc._timeouts["community-ipns"],
|
|
125118
|
+
abortSignal: this._community._getStopAbortSignal()
|
|
125119
|
+
})).ipnsHops
|
|
125120
|
+
});
|
|
125121
|
+
this._community.ipnsHops = provenIpnsHops;
|
|
125083
125122
|
const errInRecord = await this._findErrorInCommunityRecord({
|
|
125084
125123
|
communityJson: communityIpfs,
|
|
125085
|
-
communityIpnsHops:
|
|
125124
|
+
communityIpnsHops: provenIpnsHops,
|
|
125086
125125
|
cidOfCommunityIpns: latestCommunityCid
|
|
125087
125126
|
});
|
|
125088
125127
|
if (errInRecord) throw errInRecord;
|
|
@@ -125157,6 +125196,11 @@ var CommunityClientsManager = class extends PKCClientsManager {
|
|
|
125157
125196
|
gatewayUrl
|
|
125158
125197
|
});
|
|
125159
125198
|
}
|
|
125199
|
+
ipnsHops = await this._proveAnchorClaimIfUnwalked({
|
|
125200
|
+
communityJson: communityIpfs,
|
|
125201
|
+
ipnsHops,
|
|
125202
|
+
resolveChainOfClaimedAnchor: async (claimedAnchor) => (await this._resolveIpnsChainViaGateway(gatewayUrl, claimedAnchor, abortController.signal)).ipnsHops
|
|
125203
|
+
});
|
|
125160
125204
|
gatewayFetches[gatewayUrl].ipnsHops = ipnsHops;
|
|
125161
125205
|
const errorWithinRecord = await this._findErrorInCommunityRecord({
|
|
125162
125206
|
communityJson: communityIpfs,
|
|
@@ -125266,7 +125310,27 @@ var CommunityClientsManager = class extends PKCClientsManager {
|
|
|
125266
125310
|
cleanUp();
|
|
125267
125311
|
throwIfAbortSignalAborted(stopSignal);
|
|
125268
125312
|
const gatewayToError = t$4(gatewayFetches, (gatewayFetch) => gatewayFetch.error);
|
|
125269
|
-
if (Object.keys(gatewayFetches).map((gatewayUrl) => gatewayFetches[gatewayUrl].error).some((err) => err.details?.status === 304 || err.code === "ERR_GATEWAY_ABORTING_LOADING_COMMUNITY_BECAUSE_WE_ALREADY_LOADED_THIS_RECORD"))
|
|
125313
|
+
if (Object.keys(gatewayFetches).map((gatewayUrl) => gatewayFetches[gatewayUrl].error).some((err) => err.details?.status === 304 || err.code === "ERR_GATEWAY_ABORTING_LOADING_COMMUNITY_BECAUSE_WE_ALREADY_LOADED_THIS_RECORD")) {
|
|
125314
|
+
if (this._community.anchor && this._community.ipnsHops?.[0] !== ipnsName) {
|
|
125315
|
+
const confirmingGatewayUrl = Object.keys(gatewayFetches).find((gatewayUrl) => gatewayFetches[gatewayUrl].error?.details?.status === 304 || gatewayFetches[gatewayUrl].error?.code === "ERR_GATEWAY_ABORTING_LOADING_COMMUNITY_BECAUSE_WE_ALREADY_LOADED_THIS_RECORD");
|
|
125316
|
+
if (confirmingGatewayUrl) {
|
|
125317
|
+
const chainWalkAbortController = new AbortController();
|
|
125318
|
+
const chainWalkTimeoutId = setTimeout(() => chainWalkAbortController.abort("Aborting delegated chain upgrade because it timed out after " + timeoutMs + "ms"), timeoutMs);
|
|
125319
|
+
const onStopAbortChainWalk = () => chainWalkAbortController.abort(stopSignal?.reason);
|
|
125320
|
+
stopSignal?.addEventListener("abort", onStopAbortChainWalk, { once: true });
|
|
125321
|
+
try {
|
|
125322
|
+
const chain = await this._resolveIpnsChainViaGateway(confirmingGatewayUrl, ipnsName, chainWalkAbortController.signal);
|
|
125323
|
+
if (this._community.updateCid && chain.terminalCidV0 === this._community.updateCid) this._community.ipnsHops = chain.ipnsHops;
|
|
125324
|
+
} catch (chainWalkError) {
|
|
125325
|
+
log.trace(`Failed to upgrade the delegated chain of ${ipnsName} after a confirmed consumed record, will retry next poll`, chainWalkError);
|
|
125326
|
+
} finally {
|
|
125327
|
+
clearTimeout(chainWalkTimeoutId);
|
|
125328
|
+
stopSignal?.removeEventListener("abort", onStopAbortChainWalk);
|
|
125329
|
+
}
|
|
125330
|
+
}
|
|
125331
|
+
}
|
|
125332
|
+
return;
|
|
125333
|
+
}
|
|
125270
125334
|
const combinedError = new FailedToFetchCommunityFromGatewaysError({
|
|
125271
125335
|
ipnsName,
|
|
125272
125336
|
gatewayToError,
|
|
@@ -125330,6 +125394,26 @@ var CommunityClientsManager = class extends PKCClientsManager {
|
|
|
125330
125394
|
});
|
|
125331
125395
|
}
|
|
125332
125396
|
}
|
|
125397
|
+
async _proveAnchorClaimIfUnwalked({ communityJson, ipnsHops, resolveChainOfClaimedAnchor }) {
|
|
125398
|
+
const log = logger_default("pkc-js:community-client-manager:_proveAnchorClaimIfUnwalked");
|
|
125399
|
+
if (ipnsHops.length > 1) return ipnsHops;
|
|
125400
|
+
const claimedAnchor = communityJson.anchor?.publicKey;
|
|
125401
|
+
if (!claimedAnchor) return ipnsHops;
|
|
125402
|
+
const loadedName = ipnsHops[0];
|
|
125403
|
+
if (this._areEquivalentCommunityAddresses(claimedAnchor, loadedName)) return ipnsHops;
|
|
125404
|
+
const provenHops = await resolveChainOfClaimedAnchor(claimedAnchor);
|
|
125405
|
+
const anchorDelegatesTo = provenHops[provenHops.length - 1];
|
|
125406
|
+
if (!this._areEquivalentCommunityAddresses(anchorDelegatesTo, loadedName)) throw new PKCError("ERR_COMMUNITY_RECORD_ANCHOR_CLAIM_IS_NOT_ENDORSED", {
|
|
125407
|
+
claimedAnchor,
|
|
125408
|
+
recordIpnsName: loadedName,
|
|
125409
|
+
anchorDelegatesTo,
|
|
125410
|
+
claimedAnchorHops: provenHops,
|
|
125411
|
+
communityAddress: this._getCommunityAddressFromInstance(),
|
|
125412
|
+
recordSignerAddress: getPKCAddressFromPublicKeySync(communityJson.signature.publicKey)
|
|
125413
|
+
});
|
|
125414
|
+
log.trace(`Anchor claim of ${loadedName} proven: ${claimedAnchor} delegates to it. Adopting the chain`, provenHops);
|
|
125415
|
+
return provenHops;
|
|
125416
|
+
}
|
|
125333
125417
|
async _findErrorInCommunityRecord({ communityJson, communityIpnsHops, cidOfCommunityIpns }) {
|
|
125334
125418
|
const anchorIpnsName = communityIpnsHops[0];
|
|
125335
125419
|
const terminalIpnsName = communityIpnsHops[communityIpnsHops.length - 1];
|
|
@@ -125540,13 +125624,13 @@ var RemoteCommunity = class extends import_lib$1.TypedEmitter {
|
|
|
125540
125624
|
}
|
|
125541
125625
|
}
|
|
125542
125626
|
_updateIpnsPubsubPropsIfNeeded(newProps) {
|
|
125543
|
-
const
|
|
125627
|
+
const anchorFromClaimOrHops = this.anchor?.publicKey ?? this.ipnsHops?.[0];
|
|
125544
125628
|
if ("ipnsName" in newProps && newProps.ipnsName) {
|
|
125545
125629
|
this.ipnsName = newProps.ipnsName;
|
|
125546
125630
|
this.ipnsPubsubTopic = ipnsNameToIpnsOverPubsubTopic(this.ipnsName);
|
|
125547
125631
|
this.ipnsPubsubTopicRoutingCid = pubsubTopicToDhtKey(this.ipnsPubsubTopic);
|
|
125548
|
-
} else if (
|
|
125549
|
-
this.ipnsName =
|
|
125632
|
+
} else if (anchorFromClaimOrHops) {
|
|
125633
|
+
this.ipnsName = anchorFromClaimOrHops;
|
|
125550
125634
|
this.ipnsPubsubTopic = ipnsNameToIpnsOverPubsubTopic(this.ipnsName);
|
|
125551
125635
|
this.ipnsPubsubTopicRoutingCid = pubsubTopicToDhtKey(this.ipnsPubsubTopic);
|
|
125552
125636
|
} else if (newProps.signature?.publicKey && this.signature?.publicKey !== newProps.signature?.publicKey) {
|
|
@@ -125563,6 +125647,8 @@ var RemoteCommunity = class extends import_lib$1.TypedEmitter {
|
|
|
125563
125647
|
initRemoteCommunityPropsNoMerge(newProps) {
|
|
125564
125648
|
const incomingIpnsHops = newProps.ipnsHops;
|
|
125565
125649
|
if (Array.isArray(incomingIpnsHops) && incomingIpnsHops.length > 0) this._ipnsHops = incomingIpnsHops;
|
|
125650
|
+
if ("anchor" in newProps) this.anchor = newProps.anchor;
|
|
125651
|
+
else if (newProps.signature) this.anchor = void 0;
|
|
125566
125652
|
this.title = newProps.title;
|
|
125567
125653
|
this.description = newProps.description;
|
|
125568
125654
|
this.lastPostCid = newProps.lastPostCid;
|
|
@@ -125583,8 +125669,10 @@ var RemoteCommunity = class extends import_lib$1.TypedEmitter {
|
|
|
125583
125669
|
this.pubsubTopic = newProps.pubsubTopic;
|
|
125584
125670
|
this.signature = newProps.signature;
|
|
125585
125671
|
const explicitPublicKey = "publicKey" in newProps ? newProps.publicKey : void 0;
|
|
125672
|
+
const anchorFromClaim = this.anchor?.publicKey;
|
|
125586
125673
|
const anchorFromHops = this.ipnsHops?.[0];
|
|
125587
|
-
if (
|
|
125674
|
+
if (anchorFromClaim) this.publicKey = anchorFromClaim;
|
|
125675
|
+
else if (anchorFromHops) this.publicKey = anchorFromHops;
|
|
125588
125676
|
else if (newProps.signature?.publicKey) this.publicKey = getPKCAddressFromPublicKeySync(newProps.signature.publicKey);
|
|
125589
125677
|
else if (explicitPublicKey) this.publicKey = explicitPublicKey;
|
|
125590
125678
|
else if (!this.publicKey && "address" in newProps && typeof newProps.address === "string" && !isStringDomain(newProps.address)) this.publicKey = newProps.address;
|
|
@@ -125625,6 +125713,7 @@ var RemoteCommunity = class extends import_lib$1.TypedEmitter {
|
|
|
125625
125713
|
_clearDataForKeyMigration(newPublicKey) {
|
|
125626
125714
|
this.raw.communityIpfs = void 0;
|
|
125627
125715
|
this.updateCid = void 0;
|
|
125716
|
+
this.anchor = void 0;
|
|
125628
125717
|
this.initRemoteCommunityPropsNoMerge({});
|
|
125629
125718
|
this.pubsubTopicRoutingCid = void 0;
|
|
125630
125719
|
this.publicKey = newPublicKey;
|
|
@@ -125725,7 +125814,7 @@ var RemoteCommunity = class extends import_lib$1.TypedEmitter {
|
|
|
125725
125814
|
}
|
|
125726
125815
|
_isRetriableErrorWhenLoading(err) {
|
|
125727
125816
|
if (!(err instanceof PKCError)) return false;
|
|
125728
|
-
if (err.code === "ERR_COMMUNITY_SIGNATURE_IS_INVALID" || err.code === "ERR_INVALID_COMMUNITY_IPFS_SCHEMA" || err.code === "ERR_THE_COMMUNITY_IPNS_RECORD_POINTS_TO_DIFFERENT_ADDRESS_THAN_WE_EXPECTED" || err.code === "ERR_OVER_DOWNLOAD_LIMIT" || err.code === "ERR_INVALID_JSON" || err.code === "ERR_NO_RESOLVER_FOR_NAME" || err.code === "ERR_GATEWAY_IPNS_RECORD_CHAIN_INVALID" || err.code === "ERR_IPNS_MAX_HOPS_EXCEEDED" || err.code === "ERR_RESOLVED_IPNS_TO_UNSUPPORTED_VALUE") return false;
|
|
125817
|
+
if (err.code === "ERR_COMMUNITY_SIGNATURE_IS_INVALID" || err.code === "ERR_INVALID_COMMUNITY_IPFS_SCHEMA" || err.code === "ERR_THE_COMMUNITY_IPNS_RECORD_POINTS_TO_DIFFERENT_ADDRESS_THAN_WE_EXPECTED" || err.code === "ERR_OVER_DOWNLOAD_LIMIT" || err.code === "ERR_INVALID_JSON" || err.code === "ERR_NO_RESOLVER_FOR_NAME" || err.code === "ERR_GATEWAY_IPNS_RECORD_CHAIN_INVALID" || err.code === "ERR_IPNS_MAX_HOPS_EXCEEDED" || err.code === "ERR_RESOLVED_IPNS_TO_UNSUPPORTED_VALUE" || err.code === "ERR_COMMUNITY_RECORD_ANCHOR_CLAIM_IS_NOT_ENDORSED") return false;
|
|
125729
125818
|
if (err instanceof FailedToFetchCommunityFromGatewaysError) {
|
|
125730
125819
|
for (const gatewayError of Object.values(err.details.gatewayToError)) {
|
|
125731
125820
|
if (gatewayError instanceof PKCError && gatewayError.code === "ERR_COMMUNITY_SIGNATURE_IS_INVALID") return true;
|
|
@@ -125900,12 +125989,12 @@ var AddressRewriterDatabase = class {
|
|
|
125900
125989
|
if (kuboConfig && typeof kuboConfig === "object" && "host" in kuboConfig && "port" in kuboConfig) kuboIdentifier = `${kuboConfig.host}_${kuboConfig.port}`;
|
|
125901
125990
|
const proxyIdentifier = `${proxyTarget.hostname}_${proxyTarget.port || (proxyTarget.protocol === "https:" ? "443" : "80")}`;
|
|
125902
125991
|
const fileName = `address_rewriter_${kuboIdentifier}_${proxyIdentifier}.db`;
|
|
125903
|
-
return
|
|
125992
|
+
return path.join(dataPath, ".address-rewriter", fileName);
|
|
125904
125993
|
}
|
|
125905
125994
|
async initialize() {
|
|
125906
125995
|
try {
|
|
125907
|
-
const dbDir =
|
|
125908
|
-
await
|
|
125996
|
+
const dbDir = path.dirname(this._dbPath);
|
|
125997
|
+
await fs.mkdir(dbDir, { recursive: true });
|
|
125909
125998
|
this._db = new Database(this._dbPath);
|
|
125910
125999
|
this._db.exec(`
|
|
125911
126000
|
CREATE TABLE IF NOT EXISTS request_logs (
|
|
@@ -5315,6 +5315,8 @@ var messages;
|
|
|
5315
5315
|
messages["ERR_COMMUNITY_EDIT_HAS_RESERVED_FIELD"] = "CommunityEdit record includes a reserved field";
|
|
5316
5316
|
messages["ERR_COMMUNITY_SIGNATURE_IS_INVALID"] = "Community signature is invalid";
|
|
5317
5317
|
messages["ERR_COMMUNITY_RECORD_INCLUDES_RESERVED_FIELD"] = "The CommunityIpfs record includes a reserved field";
|
|
5318
|
+
messages["ERR_COMMUNITY_RECORD_ANCHOR_CLAIM_DOES_NOT_MATCH_CHAIN_ANCHOR"] = "The CommunityIpfs record was resolved through a delegated IPNS chain but its signed anchor claim does not match the chain's anchor";
|
|
5319
|
+
messages["ERR_COMMUNITY_RECORD_ANCHOR_CLAIM_IS_NOT_ENDORSED"] = "The CommunityIpfs record claims an anchor that does not delegate to it: resolving the claimed anchor does not lead to the key that signed this record, so the claim is forged";
|
|
5318
5320
|
messages["ERR_FAILED_TO_RESOLVE_COMMUNITY_DOMAIN"] = "Failed to resolve the community domain address to use for verification";
|
|
5319
5321
|
messages["ERR_FAILED_TO_RESOLVE_AUTHOR_DOMAIN"] = "Failed to resolve the author domain address to use for verification";
|
|
5320
5322
|
messages["ERR_AUTHOR_DOMAIN_RESOLVES_TO_DIFFERENT_SIGNER"] = "The author domain resolved to a public key that does not match the publication signer";
|
|
@@ -5371,6 +5373,7 @@ var messages;
|
|
|
5371
5373
|
messages["ERR_PUBLICATION_USES_DEPRECATED_SUBPLEBBIT_ADDRESS"] = "Publication uses the deprecated `subplebbitAddress` field; update your client to use `communityPublicKey`";
|
|
5372
5374
|
messages["ERR_PUBLICATION_USES_DEPRECATED_COMMUNITY_ADDRESS"] = "Publication uses the deprecated `communityAddress` field; update your client to use `communityPublicKey`";
|
|
5373
5375
|
messages["ERR_PUBLICATION_INVALID_COMMUNITY_PUBLIC_KEY"] = "The communityPublicKey field of publication does not match the community's IPNS key";
|
|
5376
|
+
messages["ERR_PUBLICATION_SIGNED_TO_MINTER_INSTEAD_OF_ANCHOR"] = "The communityPublicKey field of publication is this delegated community's minter key; publications must be signed to the community's anchor identity";
|
|
5374
5377
|
messages["ERR_PUBLICATION_INVALID_COMMUNITY_NAME"] = "The communityName field of publication does not match the community's address";
|
|
5375
5378
|
messages["ERR_AUTHOR_IS_BANNED"] = "Author is banned";
|
|
5376
5379
|
messages["ERR_PUBLICATION_HAS_NO_AUTHOR_ADDRESS"] = "Publication has no author.address";
|
|
@@ -6660,6 +6663,7 @@ const ChallengeFileFactorySchema = _function({
|
|
|
6660
6663
|
input: [object({ challengeSettings: CommunityChallengeSettingSchema })],
|
|
6661
6664
|
output: ChallengeFileSchema
|
|
6662
6665
|
});
|
|
6666
|
+
const CommunityAnchorSchema = object({ publicKey: string().refine((arg) => isIpnsName(arg), messages.ERR_ANCHOR_PUBLIC_KEY_IS_INVALID) }).strict();
|
|
6663
6667
|
const CommunityIpfsSchema = object({
|
|
6664
6668
|
posts: PostsPagesIpfsSchema.optional(),
|
|
6665
6669
|
modQueue: ModQueuePagesIpfsSchema.optional(),
|
|
@@ -6667,6 +6671,7 @@ const CommunityIpfsSchema = object({
|
|
|
6667
6671
|
signature: JsonSignatureSchema,
|
|
6668
6672
|
encryption: CommunityEncryptionSchema,
|
|
6669
6673
|
name: string().min(1).optional(),
|
|
6674
|
+
anchor: CommunityAnchorSchema.optional(),
|
|
6670
6675
|
createdAt: PKCTimestampSchema,
|
|
6671
6676
|
updatedAt: PKCTimestampSchema,
|
|
6672
6677
|
pubsubTopic: PubsubTopicSchema.optional(),
|
|
@@ -6725,7 +6730,6 @@ const CommunityEditOptionsSchema = CommunityIpfsSchema.pick({
|
|
|
6725
6730
|
settings: CommunitySettingsSchema.optional(),
|
|
6726
6731
|
roles: CommunityRolesToEditSchema.optional()
|
|
6727
6732
|
}).partial().strict();
|
|
6728
|
-
const CommunityAnchorSchema = object({ publicKey: string().refine((arg) => isIpnsName(arg), messages.ERR_ANCHOR_PUBLIC_KEY_IS_INVALID) }).strict();
|
|
6729
6733
|
const CreateNewLocalCommunityUserOptionsSchema = CommunityEditOptionsSchema.omit({ address: true }).extend({
|
|
6730
6734
|
signer: CreateSignerSchema.optional(),
|
|
6731
6735
|
anchor: CommunityAnchorSchema.optional(),
|
|
@@ -16059,7 +16063,7 @@ function extractNetworkErrorDetails(err, depth = 0) {
|
|
|
16059
16063
|
}
|
|
16060
16064
|
//#endregion
|
|
16061
16065
|
//#region dist/node/generated-version.js
|
|
16062
|
-
const version = "0.0.
|
|
16066
|
+
const version = "0.0.80";
|
|
16063
16067
|
//#endregion
|
|
16064
16068
|
//#region dist/node/version.js
|
|
16065
16069
|
const protocolVersion = ProtocolVersionSchema.parse("1.0.0");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { et as pubsubTopicToDhtKeyCid, vr as PKCError } from "./schema-
|
|
1
|
+
import { et as pubsubTopicToDhtKeyCid, vr as PKCError } from "./schema-Iavj-cRD.js";
|
|
2
2
|
import { ipnsSelector } from "ipns/selector";
|
|
3
3
|
import { equals } from "uint8arrays/equals";
|
|
4
4
|
//#region dist/node/helia/util.js
|
package/dist/bundled/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as getShortCid, i as getShortAddress, n as challenges, o as nativeFunctions, r as createAnchorIpnsRecord, s as setNativeFunctions, t as PKC } from "./chunks/node-
|
|
1
|
+
import { a as getShortCid, i as getShortAddress, n as challenges, o as nativeFunctions, r as createAnchorIpnsRecord, s as setNativeFunctions, t as PKC } from "./chunks/node-4qAZNuJG.js";
|
|
2
2
|
export { challenges, createAnchorIpnsRecord, PKC as default, getShortAddress, getShortCid, nativeFunctions, setNativeFunctions };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { $n as n, L as hideClassPrivateProps, br as logger_default, st as replaceXWithY, tr as t, vr as PKCError, xt as findStartedCommunity } from "../../chunks/schema-
|
|
2
|
-
import { _ as parseRpcPublishAnchorRecordParam, c as parseRpcAuthorNameParam, d as parseRpcCommentRepliesPageParam, f as parseRpcCommunityIdentifierParam, g as parseRpcExportCommunityParam, h as parseRpcExportCommunityModLogsParam, l as parseRpcCancelExportParam, m as parseRpcEditCommunityParam, p as parseRpcCommunityPageParam, t as PKC, u as parseRpcCidParam, v as parseRpcPublishChallengeAnswersParam, y as parseRpcUnsubscribeParam } from "../../chunks/node-
|
|
3
|
-
import { $t as parseCommentEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, Dn as parseVoteChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, En as parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, J as buildPageRuntimeFields, Qt as parseCommentChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, Y as buildPagesRuntimeFields, Zn as t$1, at as pLimit, hn as parseCreatePKCWsServerOptionsSchemaWithPKCErrorIfItFails, ir as stringify, it as pRetry, mn as parseCreateNewLocalCommunityUserOptionsSchemaWithPKCErrorIfItFails, nn as parseCommentModerationChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, on as parseCommunityEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, sn as parseCommunityEditOptionsSchemaWithPKCErrorIfItFails, st as require_lib, yn as parseDecryptedChallengeAnswerWithPKCErrorIfItFails } from "../../chunks/rpc-local-community-
|
|
4
|
-
import { t as LocalCommunity } from "../../chunks/local-community-
|
|
1
|
+
import { $n as n, L as hideClassPrivateProps, br as logger_default, st as replaceXWithY, tr as t, vr as PKCError, xt as findStartedCommunity } from "../../chunks/schema-Iavj-cRD.js";
|
|
2
|
+
import { _ as parseRpcPublishAnchorRecordParam, c as parseRpcAuthorNameParam, d as parseRpcCommentRepliesPageParam, f as parseRpcCommunityIdentifierParam, g as parseRpcExportCommunityParam, h as parseRpcExportCommunityModLogsParam, l as parseRpcCancelExportParam, m as parseRpcEditCommunityParam, p as parseRpcCommunityPageParam, t as PKC, u as parseRpcCidParam, v as parseRpcPublishChallengeAnswersParam, y as parseRpcUnsubscribeParam } from "../../chunks/node-4qAZNuJG.js";
|
|
3
|
+
import { $t as parseCommentEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, Dn as parseVoteChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, En as parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, J as buildPageRuntimeFields, Qt as parseCommentChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, Y as buildPagesRuntimeFields, Zn as t$1, at as pLimit, hn as parseCreatePKCWsServerOptionsSchemaWithPKCErrorIfItFails, ir as stringify, it as pRetry, mn as parseCreateNewLocalCommunityUserOptionsSchemaWithPKCErrorIfItFails, nn as parseCommentModerationChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, on as parseCommunityEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, sn as parseCommunityEditOptionsSchemaWithPKCErrorIfItFails, st as require_lib, yn as parseDecryptedChallengeAnswerWithPKCErrorIfItFails } from "../../chunks/rpc-local-community-Cog5rZLG.js";
|
|
4
|
+
import { t as LocalCommunity } from "../../chunks/local-community-CHzhypCp.js";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
6
|
import path from "path";
|
|
7
7
|
import assert from "assert";
|
|
@@ -52,11 +52,13 @@ export declare class CommunityClientsManager extends PKCClientsManager {
|
|
|
52
52
|
startUpdatingLoop(): Promise<void>;
|
|
53
53
|
stopUpdatingLoop(): Promise<void>;
|
|
54
54
|
private _resolveCommunityNameWithoutUpdatingState;
|
|
55
|
+
private _nonAnchorHopsOfLoadedChain;
|
|
55
56
|
private _resolveNameInBackground;
|
|
56
57
|
_resolvePageAuthorNamesInBackground(): void;
|
|
57
58
|
fetchNewUpdateForCommunity(communityAddress: string): Promise<ResultOfFetchingCommunity>;
|
|
58
59
|
private _fetchCommunityIpnsP2PAndVerify;
|
|
59
60
|
private _fetchCommunityFromGateways;
|
|
60
61
|
private _resolveIpnsChainViaGateway;
|
|
62
|
+
private _proveAnchorClaimIfUnwalked;
|
|
61
63
|
private _findErrorInCommunityRecord;
|
|
62
64
|
}
|