@pkcprotocol/pkc-js 0.0.75 → 0.0.76
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 +10 -0
- package/dist/browser/clients/rpc-client/pkc-rpc-client.d.ts +3 -1
- package/dist/browser/clients/rpc-client/pkc-rpc-client.js +12 -1
- package/dist/browser/clients/rpc-client/pkc-rpc-client.js.map +1 -1
- package/dist/browser/clients/rpc-client/rpc-schema-util.d.ts +18 -0
- package/dist/browser/clients/rpc-client/rpc-schema-util.js +5 -1
- package/dist/browser/clients/rpc-client/rpc-schema-util.js.map +1 -1
- package/dist/browser/clients/rpc-client/schema.d.ts +15 -0
- package/dist/browser/clients/rpc-client/schema.js +20 -0
- package/dist/browser/clients/rpc-client/schema.js.map +1 -1
- package/dist/browser/clients/rpc-client/types.d.ts +3 -2
- package/dist/browser/community/community-client-manager.js +9 -9
- package/dist/browser/community/community-client-manager.js.map +1 -1
- package/dist/browser/community/rpc-local-community.d.ts +6 -1
- package/dist/browser/community/rpc-local-community.js +32 -0
- package/dist/browser/community/rpc-local-community.js.map +1 -1
- package/dist/browser/community/schema.d.ts +15 -0
- package/dist/browser/community/schema.js +16 -1
- package/dist/browser/community/schema.js.map +1 -1
- package/dist/browser/community/types.d.ts +14 -1
- package/dist/browser/constants.d.ts +3 -1
- package/dist/browser/constants.js +9 -1
- package/dist/browser/constants.js.map +1 -1
- package/dist/browser/errors.d.ts +10 -0
- package/dist/browser/errors.js +10 -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/index-with-compile-cache.d.ts +2 -0
- package/dist/browser/index-with-compile-cache.js +1 -0
- package/dist/browser/index-with-compile-cache.js.map +1 -1
- package/dist/browser/index.d.ts +3 -0
- package/dist/browser/index.js +8 -0
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/pkc/pkc.js +37 -3
- package/dist/browser/pkc/pkc.js.map +1 -1
- package/dist/browser/pkc-error.d.ts +1 -1
- package/dist/browser/rpc/src/index.d.ts +4 -1
- package/dist/browser/rpc/src/index.js +29 -1
- package/dist/browser/rpc/src/index.js.map +1 -1
- package/dist/browser/rpc/src/lib/pkc-js/index.d.ts +1 -0
- package/dist/browser/runtime/node/community/local-community/anchor-publishing.d.ts +9 -0
- package/dist/browser/runtime/node/community/local-community/anchor-publishing.js +197 -0
- package/dist/browser/runtime/node/community/local-community/anchor-publishing.js.map +1 -0
- package/dist/browser/runtime/node/community/local-community/db-state.js +22 -4
- package/dist/browser/runtime/node/community/local-community/db-state.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/identity.d.ts +2 -0
- package/dist/browser/runtime/node/community/local-community/identity.js +13 -0
- package/dist/browser/runtime/node/community/local-community/identity.js.map +1 -0
- package/dist/browser/runtime/node/community/local-community/lifecycle.js +24 -0
- package/dist/browser/runtime/node/community/local-community/lifecycle.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/publication-store.js +7 -3
- package/dist/browser/runtime/node/community/local-community/publication-store.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/publication-validation.js +6 -2
- package/dist/browser/runtime/node/community/local-community/publication-validation.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community.d.ts +5 -1
- package/dist/browser/runtime/node/community/local-community.js +47 -6
- package/dist/browser/runtime/node/community/local-community.js.map +1 -1
- package/dist/browser/schema/schema-util.d.ts +6 -0
- package/dist/browser/schema/schema.d.ts +1 -0
- package/dist/browser/schema/schema.js +11 -0
- package/dist/browser/schema/schema.js.map +1 -1
- package/dist/browser/signer/index.d.ts +1 -0
- package/dist/browser/signer/index.js +1 -0
- package/dist/browser/signer/index.js.map +1 -1
- package/dist/browser/signer/ipns-record.d.ts +7 -0
- package/dist/browser/signer/ipns-record.js +34 -0
- package/dist/browser/signer/ipns-record.js.map +1 -0
- package/dist/browser/signer/signatures.d.ts +2 -2
- package/dist/browser/signer/signatures.js +18 -6
- package/dist/browser/signer/signatures.js.map +1 -1
- package/dist/browser/test/test-util.d.ts +4 -0
- package/dist/bundled/bundle-manifest.json +43 -38
- package/dist/bundled/chunks/{helia-for-pkc-BPj1zAUb.js → helia-for-pkc-cKp6JSwA.js} +34 -34
- package/dist/bundled/chunks/{local-community-D4efR9XJ.js → local-community-B3Fhrtiy.js} +205 -38
- package/dist/bundled/chunks/{local-community-ChTkd8lH.js → local-community-DerKPzJm.js} +1 -1
- package/dist/bundled/chunks/{node-BK6GBM0d.js → node-DffqRPit.js} +41 -8
- package/dist/bundled/chunks/{rpc-local-community-O94vseOA.js → rpc-local-community-BdNiruAf.js} +90 -32
- package/dist/bundled/chunks/{schema-wNdSno5O.js → schema-BvBJX6m7.js} +23 -3
- package/dist/bundled/chunks/{util-iNnH2bP5.js → util-BRxHPb9G.js} +1 -1
- package/dist/bundled/index-with-compile-cache.js +2 -1
- package/dist/bundled/index.js +2 -2
- package/dist/bundled/rpc/src/index.js +27 -4
- package/dist/node/clients/rpc-client/pkc-rpc-client.d.ts +3 -1
- package/dist/node/clients/rpc-client/pkc-rpc-client.js +12 -1
- package/dist/node/clients/rpc-client/pkc-rpc-client.js.map +1 -1
- package/dist/node/clients/rpc-client/rpc-schema-util.d.ts +18 -0
- package/dist/node/clients/rpc-client/rpc-schema-util.js +5 -1
- package/dist/node/clients/rpc-client/rpc-schema-util.js.map +1 -1
- package/dist/node/clients/rpc-client/schema.d.ts +15 -0
- package/dist/node/clients/rpc-client/schema.js +20 -0
- package/dist/node/clients/rpc-client/schema.js.map +1 -1
- package/dist/node/clients/rpc-client/types.d.ts +3 -2
- package/dist/node/community/community-client-manager.js +9 -9
- package/dist/node/community/community-client-manager.js.map +1 -1
- package/dist/node/community/rpc-local-community.d.ts +6 -1
- package/dist/node/community/rpc-local-community.js +32 -0
- package/dist/node/community/rpc-local-community.js.map +1 -1
- package/dist/node/community/schema.d.ts +15 -0
- package/dist/node/community/schema.js +16 -1
- package/dist/node/community/schema.js.map +1 -1
- package/dist/node/community/types.d.ts +14 -1
- package/dist/node/constants.d.ts +3 -1
- package/dist/node/constants.js +9 -1
- package/dist/node/constants.js.map +1 -1
- package/dist/node/errors.d.ts +10 -0
- package/dist/node/errors.js +10 -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/index-with-compile-cache.d.ts +2 -0
- package/dist/node/index-with-compile-cache.js +1 -0
- package/dist/node/index-with-compile-cache.js.map +1 -1
- package/dist/node/index.d.ts +3 -0
- package/dist/node/index.js +8 -0
- package/dist/node/index.js.map +1 -1
- package/dist/node/pkc/pkc.js +37 -3
- package/dist/node/pkc/pkc.js.map +1 -1
- package/dist/node/pkc-error.d.ts +1 -1
- package/dist/node/rpc/src/index.d.ts +4 -1
- package/dist/node/rpc/src/index.js +29 -1
- package/dist/node/rpc/src/index.js.map +1 -1
- package/dist/node/rpc/src/lib/pkc-js/index.d.ts +1 -0
- package/dist/node/runtime/node/community/local-community/anchor-publishing.d.ts +9 -0
- package/dist/node/runtime/node/community/local-community/anchor-publishing.js +197 -0
- package/dist/node/runtime/node/community/local-community/anchor-publishing.js.map +1 -0
- package/dist/node/runtime/node/community/local-community/db-state.js +22 -4
- package/dist/node/runtime/node/community/local-community/db-state.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/identity.d.ts +2 -0
- package/dist/node/runtime/node/community/local-community/identity.js +13 -0
- package/dist/node/runtime/node/community/local-community/identity.js.map +1 -0
- package/dist/node/runtime/node/community/local-community/lifecycle.js +24 -0
- package/dist/node/runtime/node/community/local-community/lifecycle.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/publication-store.js +7 -3
- package/dist/node/runtime/node/community/local-community/publication-store.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/publication-validation.js +6 -2
- package/dist/node/runtime/node/community/local-community/publication-validation.js.map +1 -1
- package/dist/node/runtime/node/community/local-community.d.ts +5 -1
- package/dist/node/runtime/node/community/local-community.js +47 -6
- package/dist/node/runtime/node/community/local-community.js.map +1 -1
- package/dist/node/schema/schema-util.d.ts +6 -0
- package/dist/node/schema/schema.d.ts +1 -0
- package/dist/node/schema/schema.js +11 -0
- package/dist/node/schema/schema.js.map +1 -1
- package/dist/node/signer/index.d.ts +1 -0
- package/dist/node/signer/index.js +1 -0
- package/dist/node/signer/index.js.map +1 -1
- package/dist/node/signer/ipns-record.d.ts +7 -0
- package/dist/node/signer/ipns-record.js +34 -0
- package/dist/node/signer/ipns-record.js.map +1 -0
- package/dist/node/signer/signatures.d.ts +2 -2
- package/dist/node/signer/signatures.js +18 -6
- package/dist/node/signer/signatures.js.map +1 -1
- package/dist/node/test/test-util.d.ts +4 -0
- package/package.json +1 -1
- package/dist/bundled/chunks/{src-BKg5Lhod.js → src-BEjAH2gY.js} +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { i as __toESM, r as __require, t as __commonJSMin } from "./chunk-2rV9d50f.js";
|
|
2
|
-
import { B as isIpfsCid,
|
|
3
|
-
import { $ as
|
|
4
|
-
import { o as getHeliaDebugContext } from "./util-
|
|
2
|
+
import { $n as n$1, B as isIpfsCid, Cr as setErrorMap, Ct as findUpdatingCommunity, D as deepMergeRuntimeFields, Dn as CommentUpdateSchema, Dt as refreshTrackedCommentAliases, E as createAbortError, Et as listUpdatingCommunities, Fr as parsedType, H as isIpns, Ir as stringifyPrimitive, It as require_sha256, L as hideClassPrivateProps, Lt as TimeoutError, Pr as joinValues, Pt as untrackUpdatingComment, Q as isStringDomain, Qt as CommunityAnchorSchema, R as ipnsNameToIpnsOverPubsubTopic, Rt as pTimeout, St as findUpdatingComment, Tt as listUpdatingComments, Zn as n$2, _t as timestamp, a as ChallengeRequestMessageSchema, ar as r, b as areEquivalentCommunityAddresses, br as logger_default, ct as resolveWhenPredicateIsTrue, fr as require_retry, ft as shortifyAddress, jt as trackUpdatingComment, k as doesDomainAddressHaveCapitalLetter, ln as PubsubTopicSchema, mt as sleepUntilTimeoutOrAbort, nr as e, ot as removeUndefinedValuesRecursively, pr as FailedToFetchCommentIpfsFromGatewaysError, pt as shortifyCid, r as ChallengeMessageSchema, rn as CommunityIpfsSchema, rr as e$1, s as ChallengeVerificationMessageSchema, st as replaceXWithY, t as ChallengeAnswerMessageSchema, tr as t$1, ut as retryKuboIpfsAdd, vr as PKCError, vt as waitForUpdateInCommunityInstanceWithErrorAndTimeout, wn as CommentUpdateForChallengeVerificationSchema, wt as listStartedCommunities, xr as require_supports_color, xt as findStartedCommunity, y as version_default, yn as CommentIpfsSchema, yr as messages, z as isAbortError } from "./schema-BvBJX6m7.js";
|
|
3
|
+
import { $ as parseRawPages, $n as t$3, An as RpcAuthorNameParamSchema, Bn as RpcExportCommunityResultSchema, Bt as getCommunityNameFromWire, Cn as parsePKCUserOptionsSchemaWithPKCErrorIfItFails, Dt as verifyCommentModeration, En as parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, Et as verifyCommentIpfs, Fn as RpcCommunityPageParamSchema, Ft as getAuthorNameFromRuntime, Gn as RpcPublishedAnchorRecordResultSchema, Gt as getBufferedPKCAddressFromPublicKey, H as tryToDeleteCommunitiesThatFailedToBeDeletedBefore, Hn as RpcFetchCidResultSchema, Ht as normalizeCommunityInputFromCommunity, In as RpcEditCommunityParamSchema, Jn as RpcSuccessResultSchema, Jt as getPKCAddressFromPublicKeySync, Kn as RpcResolveAuthorNameResultSchema, L as listCommunitiesSync, Ln as RpcExportCommunityModLogsParamSchema, Lt as normalizeCreatePublicationAuthor, Mn as RpcCidParamSchema, Mt as verifyVote, Nn as RpcCommentRepliesPageParamSchema, Nt as buildRuntimeAuthor, O as createKuboRpcClient, On as parseVotePubsubMessagePublicationSchemaWithPKCErrorIfItFails, Ot as verifyCommentPubsubMessage, P as getDefaultDataPath, Pn as RpcCommunityIdentifierParamSchema, Pt as cleanWireAuthor, R as monitorCommunitiesDirectory, Rn as RpcExportCommunityModLogsResultSchema, Rt as buildRuntimeCommunityFields, S as encryptEd25519AesGcm, Sn as parseJsonWithPKCErrorIfFails, St as verifyChallengeMessage, Tn as parseRpcCommentUpdateEventWithPKCErrorIfItFails, Tt as verifyCommentEdit, U as CommentClientsManager, Un as RpcPublishAnchorRecordParamSchema, Ut as decode, V as setNativeFunctions$1, Vn as RpcFetchCidParamSchema, Vt as getCommunityPublicKeyFromWire, Wn as RpcPublishChallengeAnswersParamSchema, X as extractCommunityRuntimeFieldsFromParsedPages, Xn as t$4, Yn as RpcUnsubscribeParamSchema, Z as findCommentInPageInstanceRecursively, Zt as parseCidStringSchemaWithPKCErrorIfItFails, _n as parseCreateRpcCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, a as pkcJsChallenges, an as parseCommunityAddressWithPKCErrorIfItFails, b as decryptEd25519AesGcm, bn as parseDecryptedChallengeVerification, bt as signVote, c as AddressesRewriterProxyServer, cn as parseCommunityEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, cr as require_undici, ct as cleanUpBeforePublishing, dn as parseCreateCommentModerationOptionsSchemaWithPKCErrorIfItFails, dt as signChallengeRequest, en as parseCommentEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, er as n$3, et as RepliesPages, f as KeyvBetterSqlite3, fn as parseCreateCommentOptionsSchemaWithPKCErrorIfItFails, g as decodeRpcChallengeVerificationPubsubMsg, gn as parseCreateRemoteCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, h as decodeRpcChallengeRequestPubsubMsg, ht as signCommentModeration, in as parseCommentPubsubMessagePublicationWithPKCErrorIfItFails, jn as RpcCancelExportParamSchema, jt as verifyCommunityEdit, kn as RpcAnchorPublishPreparationResultSchema, kt as verifyCommentUpdate, lt as signChallengeAnswer, m as decodeRpcChallengePubsubMsg, mt as signCommentEdit, n as RpcRemoteCommunity, nr as t$2, nt as PKCClientsManager, o as TrackedInstanceRegistry, ot as PKCTypedEmitter, p as decodeRpcChallengeAnswerPubsubMsg, pn as parseCreateCommunityEditPublicationOptionsSchemaWithPKCErrorIfItFails, pt as signComment, qn as RpcSubscriptionIdResultSchema, rn as parseCommentModerationPubsubMessagePublicationSchemaWithPKCErrorIfItFails, rr as t$5, rt as InflightFetchManager, s as LRUCache, sr as nativeFunctions$2, st as require_lib$1, t as RpcLocalCommunity, tn as parseCommentIpfsSchemaWithPKCErrorIfItFails, tt as PublicationClientsManager, u as RemoteCommunity, un as parseCreateCommentEditOptionsSchemaWithPKCErrorIfItFails, v as createSigner, vn as parseCreateVoteOptionsSchemaWithPKCErrorIfItFails, wn as parseRpcCommentEventWithPKCErrorIfItFails, wt as verifyChallengeVerification, xn as parseDecryptedChallengeWithPKCErrorIfItFails, y as createAnchorIpnsRecord$1, yn as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, yt as signCommunityEdit, zn as RpcExportCommunityParamSchema, zt as getCommunityAddressFromRecord } from "./rpc-local-community-BdNiruAf.js";
|
|
4
|
+
import { o as getHeliaDebugContext } from "./util-BRxHPb9G.js";
|
|
5
5
|
import path from "path";
|
|
6
6
|
import assert from "assert";
|
|
7
7
|
import fs from "fs";
|
|
@@ -2118,6 +2118,9 @@ const parseRpcResolveAuthorNameResult = (result) => RpcResolveAuthorNameResultSc
|
|
|
2118
2118
|
const parseRpcFetchCidResult = (result) => RpcFetchCidResultSchema.loose().parse(result);
|
|
2119
2119
|
const parseRpcSuccessResult = (result) => RpcSuccessResultSchema.loose().parse(result);
|
|
2120
2120
|
const parseRpcSubscriptionIdResult = (result) => RpcSubscriptionIdResultSchema.loose().parse(result);
|
|
2121
|
+
const parseRpcPublishAnchorRecordParam = (params) => RpcPublishAnchorRecordParamSchema.loose().parse(params);
|
|
2122
|
+
const parseRpcAnchorPublishPreparationResult = (result) => RpcAnchorPublishPreparationResultSchema.loose().parse(result);
|
|
2123
|
+
const parseRpcPublishedAnchorRecordResult = (result) => RpcPublishedAnchorRecordResultSchema.loose().parse(result);
|
|
2121
2124
|
const parseRpcExportCommunityParam = (params) => RpcExportCommunityParamSchema.loose().parse(params);
|
|
2122
2125
|
const parseRpcCancelExportParam = (params) => RpcCancelExportParamSchema.loose().parse(params);
|
|
2123
2126
|
const parseRpcExportCommunityResult = (result) => RpcExportCommunityResultSchema.loose().parse(result);
|
|
@@ -2363,6 +2366,14 @@ var PKCRpcClient = class extends import_lib.TypedEmitter {
|
|
|
2363
2366
|
const parsedStopCommunityArgs = parseRpcCommunityIdentifierParam(communityIdentifier);
|
|
2364
2367
|
return parseRpcSuccessResult(await this._webSocketClient.call("stopCommunity", [parsedStopCommunityArgs]));
|
|
2365
2368
|
}
|
|
2369
|
+
async prepareAnchorPublish(communityIdentifier) {
|
|
2370
|
+
const parsedArgs = parseRpcCommunityIdentifierParam(communityIdentifier);
|
|
2371
|
+
return parseRpcAnchorPublishPreparationResult(await this._webSocketClient.call("prepareAnchorPublish", [parsedArgs]));
|
|
2372
|
+
}
|
|
2373
|
+
async publishAnchorRecord(args) {
|
|
2374
|
+
const parsedArgs = parseRpcPublishAnchorRecordParam(args);
|
|
2375
|
+
return parseRpcPublishedAnchorRecordResult(await this._webSocketClient.call("publishAnchorRecord", [parsedArgs]));
|
|
2376
|
+
}
|
|
2366
2377
|
async editCommunity(args) {
|
|
2367
2378
|
parseRpcEditCommunityParam(args);
|
|
2368
2379
|
const wireArgs = {
|
|
@@ -8901,7 +8912,7 @@ var PKC$1 = class extends PKCTypedEmitter {
|
|
|
8901
8912
|
this.clients.libp2pJsClients = {};
|
|
8902
8913
|
if (!this.libp2pJsClientsOptions) return;
|
|
8903
8914
|
if (!this.httpRoutersOptions) throw Error("httpRoutersOptions is required for libp2pJsClient");
|
|
8904
|
-
const { createLibp2pJsClientOrUseExistingOne } = await import("./helia-for-pkc-
|
|
8915
|
+
const { createLibp2pJsClientOrUseExistingOne } = await import("./helia-for-pkc-cKp6JSwA.js");
|
|
8905
8916
|
for (const clientOptions of this.libp2pJsClientsOptions) {
|
|
8906
8917
|
const heliaNode = await createLibp2pJsClientOrUseExistingOne({
|
|
8907
8918
|
...clientOptions,
|
|
@@ -9150,7 +9161,7 @@ var PKC$1 = class extends PKCTypedEmitter {
|
|
|
9150
9161
|
const log = logger_default("pkc-js:pkc:createLocalCommunity");
|
|
9151
9162
|
log.trace("Received community options to create a local community instance:", options);
|
|
9152
9163
|
if (!this._canCreateNewLocalCommunity()) throw new PKCError("ERR_CAN_NOT_CREATE_A_LOCAL_COMMUNITY", { pkcOptions: this._userPKCOptions });
|
|
9153
|
-
const { LocalCommunity, createNewLocalCommunityDb, updateInstancePropsWithStartedCommunityOrDb } = await import("./local-community-
|
|
9164
|
+
const { LocalCommunity, createNewLocalCommunityDb, updateInstancePropsWithStartedCommunityOrDb } = await import("./local-community-DerKPzJm.js");
|
|
9154
9165
|
const isLocalCommunity = (await listCommunitiesSync(this)).includes(options.address);
|
|
9155
9166
|
const community = new LocalCommunity(this);
|
|
9156
9167
|
if (isLocalCommunity) {
|
|
@@ -9182,11 +9193,22 @@ var PKC$1 = class extends PKCTypedEmitter {
|
|
|
9182
9193
|
const hasName = "name" in parsedOptions && typeof parsedOptions.name === "string";
|
|
9183
9194
|
const hasPublicKey = "publicKey" in parsedOptions && typeof parsedOptions.publicKey === "string";
|
|
9184
9195
|
const hasSigner = "signer" in parsedOptions && parsedOptions.signer !== void 0;
|
|
9196
|
+
const anchor = parsedOptions.anchor ?? void 0;
|
|
9197
|
+
const hasAnchor = anchor !== void 0;
|
|
9198
|
+
if (hasAnchor) {
|
|
9199
|
+
const parsedAnchor = CommunityAnchorSchema.safeParse(anchor);
|
|
9200
|
+
if (!parsedAnchor.success) throw new PKCError("ERR_ANCHOR_PUBLIC_KEY_IS_INVALID", {
|
|
9201
|
+
anchor,
|
|
9202
|
+
zodError: parsedAnchor.error
|
|
9203
|
+
});
|
|
9204
|
+
}
|
|
9205
|
+
if (hasAnchor && hasSigner) throw new PKCError("ERR_CAN_NOT_CREATE_A_COMMUNITY_WITH_BOTH_SIGNER_AND_ANCHOR", { ...parsedOptions });
|
|
9185
9206
|
const hasIdentifier = hasAddress || hasName || hasPublicKey;
|
|
9207
|
+
if (hasAnchor && hasIdentifier) throw new PKCError("ERR_CAN_NOT_CREATE_A_COMMUNITY_WITH_BOTH_ANCHOR_AND_IDENTIFIER", { ...parsedOptions });
|
|
9186
9208
|
const effectiveAddress = parsedOptions.address || parsedOptions.name || parsedOptions.publicKey;
|
|
9187
9209
|
if (effectiveAddress && doesDomainAddressHaveCapitalLetter(effectiveAddress)) throw new PKCError("ERR_COMMUNITY_NAME_HAS_CAPITAL_LETTER", { ...parsedOptions });
|
|
9188
9210
|
const canCreateLocalCommunity = this._canCreateNewLocalCommunity();
|
|
9189
|
-
if (hasSigner && !canCreateLocalCommunity) throw new PKCError("ERR_CAN_NOT_CREATE_A_LOCAL_COMMUNITY", {
|
|
9211
|
+
if ((hasSigner || hasAnchor) && !canCreateLocalCommunity) throw new PKCError("ERR_CAN_NOT_CREATE_A_LOCAL_COMMUNITY", {
|
|
9190
9212
|
pkcOptions: this._userPKCOptions,
|
|
9191
9213
|
isEnvNode: Boolean(process),
|
|
9192
9214
|
hasDataPath: Boolean(this.dataPath)
|
|
@@ -9195,7 +9217,16 @@ var PKC$1 = class extends PKCTypedEmitter {
|
|
|
9195
9217
|
const parsedRemoteOptions = parseCreateRemoteCommunityFunctionArgumentSchemaWithPKCErrorIfItFails(options);
|
|
9196
9218
|
return this._createRemoteCommunityInstance(parsedRemoteOptions);
|
|
9197
9219
|
}
|
|
9198
|
-
if (
|
|
9220
|
+
if (hasAnchor) {
|
|
9221
|
+
const minterSigner = await this.createSigner();
|
|
9222
|
+
const localOptions = {
|
|
9223
|
+
...parsedOptions,
|
|
9224
|
+
signer: minterSigner,
|
|
9225
|
+
address: anchor.publicKey
|
|
9226
|
+
};
|
|
9227
|
+
log(`Creating a delegated local community with anchor (${anchor.publicKey}) and minter (${minterSigner.address})`);
|
|
9228
|
+
return this._createLocalCommunity(localOptions);
|
|
9229
|
+
} else if (hasIdentifier && !hasSigner) {
|
|
9199
9230
|
const localCommunityAddress = (await listCommunitiesSync(this)).find((localAddr) => areEquivalentCommunityAddresses(localAddr, effectiveAddress));
|
|
9200
9231
|
if (localCommunityAddress) return this._createLocalCommunity({ address: localCommunityAddress });
|
|
9201
9232
|
else {
|
|
@@ -9668,10 +9699,12 @@ PKC.nativeFunctions = {
|
|
|
9668
9699
|
PKC.getShortCid = getShortCidValue;
|
|
9669
9700
|
PKC.getShortAddress = getShortAddressValue;
|
|
9670
9701
|
PKC.challenges = pkcJsChallenges;
|
|
9702
|
+
PKC.createAnchorIpnsRecord = createAnchorIpnsRecord$1;
|
|
9671
9703
|
const setNativeFunctions = PKC.setNativeFunctions;
|
|
9672
9704
|
const nativeFunctions = PKC.nativeFunctions;
|
|
9673
9705
|
const getShortCid = PKC.getShortCid;
|
|
9674
9706
|
const getShortAddress = PKC.getShortAddress;
|
|
9675
9707
|
const challenges = PKC.challenges;
|
|
9708
|
+
const createAnchorIpnsRecord = PKC.createAnchorIpnsRecord;
|
|
9676
9709
|
//#endregion
|
|
9677
|
-
export {
|
|
9710
|
+
export { parseRpcPublishAnchorRecordParam as _, getShortCid as a, parseRpcAuthorNameParam as c, parseRpcCommentRepliesPageParam as d, parseRpcCommunityIdentifierParam as f, parseRpcExportCommunityParam as g, parseRpcExportCommunityModLogsParam as h, getShortAddress as i, parseRpcCancelExportParam as l, parseRpcEditCommunityParam as m, challenges as n, nativeFunctions as o, parseRpcCommunityPageParam as p, createAnchorIpnsRecord as r, setNativeFunctions as s, PKC as t, parseRpcCidParam as u, parseRpcPublishChallengeAnswersParam as v, parseRpcUnsubscribeParam as y };
|
package/dist/bundled/chunks/{rpc-local-community-O94vseOA.js → rpc-local-community-BdNiruAf.js}
RENAMED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import { i as __toESM, n as __exportAll, r as __require, t as __commonJSMin } from "./chunk-2rV9d50f.js";
|
|
2
|
-
import { $ as pubsubTopicToDhtKey, $
|
|
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-BvBJX6m7.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
7
|
import fsp from "node:fs/promises";
|
|
8
|
-
import
|
|
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
|
|
12
|
+
import path from "path";
|
|
13
13
|
import assert from "assert";
|
|
14
14
|
import { Agent } from "https";
|
|
15
15
|
import { Agent as Agent$1 } from "http";
|
|
16
16
|
import Database from "better-sqlite3";
|
|
17
17
|
import { CID } from "multiformats/cid";
|
|
18
|
+
import { peerIdFromMultihash, peerIdFromPrivateKey, peerIdFromPublicKey, peerIdFromString } from "@libp2p/peer-id";
|
|
18
19
|
import * as Digest from "multiformats/hashes/digest";
|
|
19
20
|
import { of } from "typestub-ipfs-only-hash";
|
|
20
21
|
import { toString } from "uint8arrays/to-string";
|
|
21
|
-
import { peerIdFromMultihash, peerIdFromPrivateKey, peerIdFromPublicKey, peerIdFromString } from "@libp2p/peer-id";
|
|
22
22
|
import { privateKeyFromProtobuf, privateKeyFromRaw, privateKeyToProtobuf, publicKeyFromRaw, publicKeyToProtobuf } from "@libp2p/crypto/keys";
|
|
23
23
|
import { fromString } from "uint8arrays/from-string";
|
|
24
24
|
import { bases } from "multiformats/basics";
|
|
@@ -91003,6 +91003,8 @@ var STORAGE_KEYS;
|
|
|
91003
91003
|
STORAGE_KEYS[STORAGE_KEYS["LAST_IPNS_RECORD"] = 2] = "LAST_IPNS_RECORD";
|
|
91004
91004
|
STORAGE_KEYS[STORAGE_KEYS["COMBINED_HASH_OF_PENDING_COMMENTS"] = 3] = "COMBINED_HASH_OF_PENDING_COMMENTS";
|
|
91005
91005
|
STORAGE_KEYS[STORAGE_KEYS["EXPORTS"] = 4] = "EXPORTS";
|
|
91006
|
+
STORAGE_KEYS[STORAGE_KEYS["ANCHOR_IPNS_RECORD"] = 5] = "ANCHOR_IPNS_RECORD";
|
|
91007
|
+
STORAGE_KEYS[STORAGE_KEYS["HIGHEST_ACCEPTED_ANCHOR_SEQUENCE"] = 6] = "HIGHEST_ACCEPTED_ANCHOR_SEQUENCE";
|
|
91006
91008
|
})(STORAGE_KEYS || (STORAGE_KEYS = {}));
|
|
91007
91009
|
//#endregion
|
|
91008
91010
|
//#region node_modules/safe-stable-stringify/index.js
|
|
@@ -91692,6 +91694,21 @@ const RpcCommunitiesChangeEventResultSchema = object({ communities: array(string
|
|
|
91692
91694
|
const RpcFetchCidResultSchema = object({ content: string() });
|
|
91693
91695
|
const RpcResolveAuthorNameResultSchema = object({ resolvedAuthorName: string().nullable() });
|
|
91694
91696
|
const RpcSuccessResultSchema = object({ success: literal(true) });
|
|
91697
|
+
const RpcPublishAnchorRecordParamSchema = object({
|
|
91698
|
+
name: string().min(1).optional(),
|
|
91699
|
+
publicKey: string().min(1).optional(),
|
|
91700
|
+
recordBase64: string().min(1)
|
|
91701
|
+
}).refine((args) => args.name || args.publicKey, "At least one of name or publicKey must be provided");
|
|
91702
|
+
const RpcAnchorPublishPreparationResultSchema = object({
|
|
91703
|
+
nextSequence: string().min(1),
|
|
91704
|
+
currentAnchorRecordSequence: string().min(1),
|
|
91705
|
+
hasPersistedAnchorRecord: boolean()
|
|
91706
|
+
});
|
|
91707
|
+
const RpcPublishedAnchorRecordResultSchema = object({
|
|
91708
|
+
sequence: string().min(1),
|
|
91709
|
+
value: string().min(1),
|
|
91710
|
+
anchorPublicKey: string().min(1)
|
|
91711
|
+
});
|
|
91695
91712
|
const RpcSubscriptionIdResultSchema = object({ subscriptionId: SubscriptionIdSchema });
|
|
91696
91713
|
const RpcExportCommunityParamSchema = object({
|
|
91697
91714
|
name: string().min(1).optional(),
|
|
@@ -97797,8 +97814,11 @@ function _allFieldsOfRecordInSignedPropertyNames(record) {
|
|
|
97797
97814
|
for (const field of fieldsOfRecord) if (!record.signature.signedPropertyNames.includes(field)) return false;
|
|
97798
97815
|
return true;
|
|
97799
97816
|
}
|
|
97800
|
-
async function verifyCommunity({ community,
|
|
97817
|
+
async function verifyCommunity({ community, communityIpnsHops, resolveAuthorNames, clientsManager, validatePages, cacheIfValid, abortSignal }) {
|
|
97801
97818
|
const log = logger_default("pkc-js:signatures:verifyCommunity");
|
|
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];
|
|
97821
|
+
const terminalIpnsName = communityIpnsHops[communityIpnsHops.length - 1];
|
|
97802
97822
|
if (!_allFieldsOfRecordInSignedPropertyNames(community)) return {
|
|
97803
97823
|
valid: false,
|
|
97804
97824
|
reason: messages.ERR_COMMUNITY_RECORD_INCLUDES_FIELD_NOT_IN_SIGNED_PROPERTY_NAMES
|
|
@@ -97812,11 +97832,11 @@ async function verifyCommunity({ community, communityIpnsName, resolveAuthorName
|
|
|
97812
97832
|
reason: messages.ERR_COMMUNITY_SIGNATURE_IS_INVALID
|
|
97813
97833
|
};
|
|
97814
97834
|
const cacheIfValidWithDefault = typeof cacheIfValid === "boolean" ? cacheIfValid : true;
|
|
97815
|
-
const cacheKey = (0, import_sha256.sha256)(community.signature.signature + validatePages +
|
|
97835
|
+
const cacheKey = (0, import_sha256.sha256)(community.signature.signature + validatePages + communityIpnsHops.join(","));
|
|
97816
97836
|
if (cacheIfValidWithDefault && clientsManager._pkc._memCaches.communityVerificationCache.get(cacheKey)) return { valid: true };
|
|
97817
|
-
const communityAddress = community.name ||
|
|
97837
|
+
const communityAddress = community.name || communityIdentityIpnsName;
|
|
97818
97838
|
const communityForPages = {
|
|
97819
|
-
publicKey:
|
|
97839
|
+
publicKey: communityIdentityIpnsName,
|
|
97820
97840
|
name: community.name,
|
|
97821
97841
|
signature: community.signature
|
|
97822
97842
|
};
|
|
@@ -97848,7 +97868,7 @@ async function verifyCommunity({ community, communityIpnsName, resolveAuthorName
|
|
|
97848
97868
|
};
|
|
97849
97869
|
}
|
|
97850
97870
|
}
|
|
97851
|
-
const communityPeerId = peerIdFromString(
|
|
97871
|
+
const communityPeerId = peerIdFromString(terminalIpnsName);
|
|
97852
97872
|
const signaturePeerId = getPeerIdFromPublicKey(community.signature.publicKey);
|
|
97853
97873
|
if (!communityPeerId.equals(signaturePeerId)) return {
|
|
97854
97874
|
valid: false,
|
|
@@ -101600,14 +101620,14 @@ var CommentClientsManager = class extends PublicationClientsManager {
|
|
|
101600
101620
|
};
|
|
101601
101621
|
//#endregion
|
|
101602
101622
|
//#region dist/node/runtime/node/util.js
|
|
101603
|
-
const getDefaultDataPath = () => path
|
|
101623
|
+
const getDefaultDataPath = () => path.join(process.cwd(), ".pkc");
|
|
101604
101624
|
const getDefaultCommunityDbConfig = async (communityAddress, pkc) => {
|
|
101605
101625
|
let filename;
|
|
101606
101626
|
if (pkc.noData) filename = ":memory:";
|
|
101607
101627
|
else {
|
|
101608
101628
|
assert(typeof pkc.dataPath === "string", "pkc.dataPath need to be defined to get default community db config");
|
|
101609
|
-
filename = path
|
|
101610
|
-
await promises.mkdir(path
|
|
101629
|
+
filename = path.join(pkc.dataPath, "communities", communityAddress);
|
|
101630
|
+
await promises.mkdir(path.dirname(filename), { recursive: true });
|
|
101611
101631
|
}
|
|
101612
101632
|
return {
|
|
101613
101633
|
filename,
|
|
@@ -101706,7 +101726,7 @@ const setNativeFunctions = (newNativeFunctions) => {
|
|
|
101706
101726
|
};
|
|
101707
101727
|
const deleteOldCommunityInWindows = async (subPath, pkc) => {
|
|
101708
101728
|
const log = logger_default("pkc-js:community:deleteStaleCommunityInWindows");
|
|
101709
|
-
const communityAddress = path
|
|
101729
|
+
const communityAddress = path.basename(subPath);
|
|
101710
101730
|
await new Promise((resolve) => setTimeout(resolve, 1e4));
|
|
101711
101731
|
try {
|
|
101712
101732
|
await promises.rm(subPath, { force: true });
|
|
@@ -101730,7 +101750,7 @@ async function tryToDeleteCommunitiesThatFailedToBeDeletedBefore(pkc, log) {
|
|
|
101730
101750
|
}
|
|
101731
101751
|
const communitiesThatWereDeletedSuccessfully = [];
|
|
101732
101752
|
for (const communityAddress of deletedPersistentCommunities) {
|
|
101733
|
-
const communityPath = path
|
|
101753
|
+
const communityPath = path.join(pkc.dataPath, "communities", communityAddress);
|
|
101734
101754
|
try {
|
|
101735
101755
|
await promises.rm(communityPath, { force: true });
|
|
101736
101756
|
log(`Succeeded in deleting old db path (${communityAddress})`);
|
|
@@ -101754,7 +101774,7 @@ async function tryToDeleteCommunitiesThatFailedToBeDeletedBefore(pkc, log) {
|
|
|
101754
101774
|
function listCommunitiesSync(pkc) {
|
|
101755
101775
|
logger_default("pkc-js:listCommunitiesSync");
|
|
101756
101776
|
if (typeof pkc.dataPath !== "string") throw Error("pkc.dataPath needs to be defined to listCommunities");
|
|
101757
|
-
const communitiesPath = path
|
|
101777
|
+
const communitiesPath = path.join(pkc.dataPath, "communities");
|
|
101758
101778
|
const files = readdirSync(communitiesPath, {
|
|
101759
101779
|
recursive: false,
|
|
101760
101780
|
withFileTypes: false
|
|
@@ -101762,7 +101782,7 @@ function listCommunitiesSync(pkc) {
|
|
|
101762
101782
|
const communityFilesWeDontNeedToCheck = pkc.communities ? files.filter((address) => pkc.communities.includes(address)) : [];
|
|
101763
101783
|
const sqliteFiles = files.filter((address) => !communityFilesWeDontNeedToCheck.includes(address)).filter((address) => {
|
|
101764
101784
|
try {
|
|
101765
|
-
const filePath = path
|
|
101785
|
+
const filePath = path.join(communitiesPath, address);
|
|
101766
101786
|
if (!existsSync(filePath)) return false;
|
|
101767
101787
|
const fd = openSync(filePath, "r");
|
|
101768
101788
|
const buffer = Buffer.alloc(16);
|
|
@@ -101843,7 +101863,7 @@ var BackupAbortError = class extends Error {
|
|
|
101843
101863
|
async function backupCommunityDb(opts) {
|
|
101844
101864
|
const { sourcePath, destPath, includePrivateKey, onProgress, signal } = opts;
|
|
101845
101865
|
if (signal?.aborted) throw new BackupAbortError();
|
|
101846
|
-
await promises.mkdir(path
|
|
101866
|
+
await promises.mkdir(path.dirname(destPath), { recursive: true });
|
|
101847
101867
|
const partialPath = destPath + ".partial";
|
|
101848
101868
|
try {
|
|
101849
101869
|
await promises.unlink(partialPath);
|
|
@@ -101927,9 +101947,9 @@ async function statAndHashFile(filePath) {
|
|
|
101927
101947
|
}
|
|
101928
101948
|
async function moveCommunityDbToDeletedDirectory(communityAddress, pkc) {
|
|
101929
101949
|
if (typeof pkc.dataPath !== "string") throw Error("pkc.dataPath is not defined");
|
|
101930
|
-
const oldPath = path
|
|
101931
|
-
const newPath = path
|
|
101932
|
-
await promises.mkdir(path
|
|
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 });
|
|
101933
101953
|
if (!existsSync(oldPath)) throw Error(`Source database ${oldPath} does not exist`);
|
|
101934
101954
|
try {
|
|
101935
101955
|
const sourceDb = new Database(oldPath, { fileMustExist: true });
|
|
@@ -101950,7 +101970,7 @@ async function moveCommunityDbToDeletedDirectory(communityAddress, pkc) {
|
|
|
101950
101970
|
}
|
|
101951
101971
|
async function createKuboRpcClient(kuboRpcClientOptions) {
|
|
101952
101972
|
logger_default("pkc-js:pkc:createKuboRpcClient").trace("Creating a new kubo client on node with options", kuboRpcClientOptions);
|
|
101953
|
-
const { create: CreateKuboRpcClient } = await import("./src-
|
|
101973
|
+
const { create: CreateKuboRpcClient } = await import("./src-BEjAH2gY.js");
|
|
101954
101974
|
const Agent$2 = typeof kuboRpcClientOptions.url === "string" && kuboRpcClientOptions.url.startsWith("https") || kuboRpcClientOptions?.protocol === "https" || kuboRpcClientOptions.url instanceof URL && kuboRpcClientOptions?.url?.protocol === "https:" || kuboRpcClientOptions.url?.toString()?.includes("https") ? Agent : Agent$1;
|
|
101955
101975
|
const onehourMs = 1e3 * 60 * 60;
|
|
101956
101976
|
return CreateKuboRpcClient({
|
|
@@ -101965,7 +101985,7 @@ async function createKuboRpcClient(kuboRpcClientOptions) {
|
|
|
101965
101985
|
}
|
|
101966
101986
|
async function monitorCommunitiesDirectory(pkc) {
|
|
101967
101987
|
const watchAbortController = new AbortController();
|
|
101968
|
-
const communitiesPath = path
|
|
101988
|
+
const communitiesPath = path.join(pkc.dataPath, "communities");
|
|
101969
101989
|
await promises.mkdir(communitiesPath, { recursive: true });
|
|
101970
101990
|
const extensionsToIgnore = [
|
|
101971
101991
|
".lock",
|
|
@@ -124316,6 +124336,18 @@ const decryptEd25519AesGcmPublicKeyBuffer = async (encrypted, privateKeyBase64,
|
|
|
124316
124336
|
return decrypted;
|
|
124317
124337
|
};
|
|
124318
124338
|
//#endregion
|
|
124339
|
+
//#region dist/node/signer/ipns-record.js
|
|
124340
|
+
const ANCHOR_IPNS_RECORD_LIFETIME_MS = 100 * 365 * 24 * 60 * 60 * 1e3;
|
|
124341
|
+
async function createAnchorIpnsRecord({ anchorSigner, minterIpnsName, sequence }) {
|
|
124342
|
+
const { createIPNSRecord, marshalIPNSRecord } = await import("ipns");
|
|
124343
|
+
if (typeof minterIpnsName !== "string" || !minterIpnsName) throw Error("minterIpnsName must be a non-empty IPNS name");
|
|
124344
|
+
peerIdFromString(minterIpnsName);
|
|
124345
|
+
const seq = BigInt(sequence);
|
|
124346
|
+
if (seq < 0n) throw Error("sequence of an anchor IPNS record can not be negative");
|
|
124347
|
+
const ipfsKey = await getIpfsKeyFromPrivateKey(anchorSigner.privateKey);
|
|
124348
|
+
return marshalIPNSRecord(await createIPNSRecord(privateKeyFromProtobuf(new Uint8Array(ipfsKey)), `/ipns/${minterIpnsName}`, seq, ANCHOR_IPNS_RECORD_LIFETIME_MS));
|
|
124349
|
+
}
|
|
124350
|
+
//#endregion
|
|
124319
124351
|
//#region dist/node/signer/index.js
|
|
124320
124352
|
var Signer = class {
|
|
124321
124353
|
constructor(props) {
|
|
@@ -125017,7 +125049,7 @@ var CommunityClientsManager = class extends PKCClientsManager {
|
|
|
125017
125049
|
abortSignal: this._community._getStopAbortSignal()
|
|
125018
125050
|
});
|
|
125019
125051
|
this._community.ipnsHops = ipnsHops;
|
|
125020
|
-
|
|
125052
|
+
ipnsHops[ipnsHops.length - 1];
|
|
125021
125053
|
log.trace(`Resolved community IPNS`, ipnsName, `to CID`, latestCommunityCid, `via hops`, ipnsHops);
|
|
125022
125054
|
if (this._updateCidsAlreadyLoaded.has(latestCommunityCid)) {
|
|
125023
125055
|
log.trace("Resolved community IPNS", ipnsName, "to a cid that we already loaded before. No need to fetch its ipfs", latestCommunityCid);
|
|
@@ -125050,8 +125082,7 @@ var CommunityClientsManager = class extends PKCClientsManager {
|
|
|
125050
125082
|
const communityIpfs = parseCommunityIpfsSchemaPassthroughWithPKCErrorIfItFails(parseJsonWithPKCErrorIfFails(rawCommunityJsonString));
|
|
125051
125083
|
const errInRecord = await this._findErrorInCommunityRecord({
|
|
125052
125084
|
communityJson: communityIpfs,
|
|
125053
|
-
|
|
125054
|
-
terminalIpnsName,
|
|
125085
|
+
communityIpnsHops: ipnsHops,
|
|
125055
125086
|
cidOfCommunityIpns: latestCommunityCid
|
|
125056
125087
|
});
|
|
125057
125088
|
if (errInRecord) throw errInRecord;
|
|
@@ -125129,8 +125160,7 @@ var CommunityClientsManager = class extends PKCClientsManager {
|
|
|
125129
125160
|
gatewayFetches[gatewayUrl].ipnsHops = ipnsHops;
|
|
125130
125161
|
const errorWithinRecord = await this._findErrorInCommunityRecord({
|
|
125131
125162
|
communityJson: communityIpfs,
|
|
125132
|
-
|
|
125133
|
-
terminalIpnsName,
|
|
125163
|
+
communityIpnsHops: ipnsHops,
|
|
125134
125164
|
cidOfCommunityIpns: calculatedCommunityCidFromBody
|
|
125135
125165
|
});
|
|
125136
125166
|
if (errorWithinRecord) {
|
|
@@ -125300,7 +125330,9 @@ var CommunityClientsManager = class extends PKCClientsManager {
|
|
|
125300
125330
|
});
|
|
125301
125331
|
}
|
|
125302
125332
|
}
|
|
125303
|
-
async _findErrorInCommunityRecord({ communityJson,
|
|
125333
|
+
async _findErrorInCommunityRecord({ communityJson, communityIpnsHops, cidOfCommunityIpns }) {
|
|
125334
|
+
const anchorIpnsName = communityIpnsHops[0];
|
|
125335
|
+
const terminalIpnsName = communityIpnsHops[communityIpnsHops.length - 1];
|
|
125304
125336
|
const communityInstanceAddress = this._getCommunityAddressFromInstance();
|
|
125305
125337
|
const recordAddress = this._deriveAddressFromWireRecord(communityJson);
|
|
125306
125338
|
const addressMatchesInstance = this._areEquivalentCommunityAddresses(recordAddress, communityInstanceAddress);
|
|
@@ -125329,7 +125361,7 @@ var CommunityClientsManager = class extends PKCClientsManager {
|
|
|
125329
125361
|
});
|
|
125330
125362
|
const verificationOpts = {
|
|
125331
125363
|
community: communityJson,
|
|
125332
|
-
|
|
125364
|
+
communityIpnsHops,
|
|
125333
125365
|
resolveAuthorNames: this._pkc.resolveAuthorNames,
|
|
125334
125366
|
clientsManager: this,
|
|
125335
125367
|
validatePages: this._pkc.validatePages,
|
|
@@ -125868,11 +125900,11 @@ var AddressRewriterDatabase = class {
|
|
|
125868
125900
|
if (kuboConfig && typeof kuboConfig === "object" && "host" in kuboConfig && "port" in kuboConfig) kuboIdentifier = `${kuboConfig.host}_${kuboConfig.port}`;
|
|
125869
125901
|
const proxyIdentifier = `${proxyTarget.hostname}_${proxyTarget.port || (proxyTarget.protocol === "https:" ? "443" : "80")}`;
|
|
125870
125902
|
const fileName = `address_rewriter_${kuboIdentifier}_${proxyIdentifier}.db`;
|
|
125871
|
-
return
|
|
125903
|
+
return Path.join(dataPath, ".address-rewriter", fileName);
|
|
125872
125904
|
}
|
|
125873
125905
|
async initialize() {
|
|
125874
125906
|
try {
|
|
125875
|
-
const dbDir =
|
|
125907
|
+
const dbDir = Path.dirname(this._dbPath);
|
|
125876
125908
|
await fsp.mkdir(dbDir, { recursive: true });
|
|
125877
125909
|
this._db = new Database(this._dbPath);
|
|
125878
125910
|
this._db.exec(`
|
|
@@ -129421,6 +129453,8 @@ var RpcLocalCommunity = class extends RpcRemoteCommunity {
|
|
|
129421
129453
|
community: this.raw.communityIpfs,
|
|
129422
129454
|
localCommunity: {
|
|
129423
129455
|
signer: this.signer,
|
|
129456
|
+
anchor: this.anchor,
|
|
129457
|
+
anchorRecordSequence: this.anchorRecordSequence,
|
|
129424
129458
|
settings: this.settings,
|
|
129425
129459
|
_usingDefaultChallenge: this._usingDefaultChallenge,
|
|
129426
129460
|
address: this.address,
|
|
@@ -129440,13 +129474,21 @@ var RpcLocalCommunity = class extends RpcRemoteCommunity {
|
|
|
129440
129474
|
...this._toJSONIpfsBaseNoPosts(),
|
|
129441
129475
|
address: this.address,
|
|
129442
129476
|
signer: this.signer,
|
|
129477
|
+
anchor: this.anchor,
|
|
129478
|
+
anchorRecordSequence: this.anchorRecordSequence,
|
|
129443
129479
|
settings: this.settings,
|
|
129444
129480
|
_usingDefaultChallenge: this._usingDefaultChallenge,
|
|
129445
129481
|
started: this.started,
|
|
129446
129482
|
startedState: this.startedState
|
|
129447
129483
|
} };
|
|
129448
129484
|
}
|
|
129485
|
+
_replayAnchorIntoIpnsHops(localProps) {
|
|
129486
|
+
this.anchor = localProps.anchor;
|
|
129487
|
+
this.anchorRecordSequence = localProps.anchorRecordSequence;
|
|
129488
|
+
if (localProps.anchor) this.ipnsHops = [localProps.anchor.publicKey, localProps.signer.address];
|
|
129489
|
+
}
|
|
129449
129490
|
initRpcInternalCommunityBeforeFirstUpdateNoMerge(newProps) {
|
|
129491
|
+
this._replayAnchorIntoIpnsHops(newProps.localCommunity);
|
|
129450
129492
|
this.initRemoteCommunityPropsNoMerge(newProps.localCommunity);
|
|
129451
129493
|
if (newProps.localCommunity.address) this.setAddress(newProps.localCommunity.address);
|
|
129452
129494
|
this.signer = newProps.localCommunity.signer;
|
|
@@ -129456,6 +129498,7 @@ var RpcLocalCommunity = class extends RpcRemoteCommunity {
|
|
|
129456
129498
|
this.raw.localCommunity = newProps;
|
|
129457
129499
|
}
|
|
129458
129500
|
initRpcInternalCommunityAfterFirstUpdateNoMerge(newProps) {
|
|
129501
|
+
this._replayAnchorIntoIpnsHops(newProps.localCommunity);
|
|
129459
129502
|
super.initCommunityIpfsPropsNoMerge(newProps.community);
|
|
129460
129503
|
if (newProps.localCommunity.address) this.setAddress(newProps.localCommunity.address);
|
|
129461
129504
|
this.signer = newProps.localCommunity.signer;
|
|
@@ -129583,6 +129626,21 @@ var RpcLocalCommunity = class extends RpcRemoteCommunity {
|
|
|
129583
129626
|
this.started = false;
|
|
129584
129627
|
untrackStartedCommunity(this._pkc, this);
|
|
129585
129628
|
}
|
|
129629
|
+
async prepareAnchorPublish() {
|
|
129630
|
+
return this._pkc._pkcRpcClient.prepareAnchorPublish({
|
|
129631
|
+
name: this.name,
|
|
129632
|
+
publicKey: this.publicKey
|
|
129633
|
+
});
|
|
129634
|
+
}
|
|
129635
|
+
async publishAnchorRecord(recordBytes) {
|
|
129636
|
+
const result = await this._pkc._pkcRpcClient.publishAnchorRecord({
|
|
129637
|
+
name: this.name,
|
|
129638
|
+
publicKey: this.publicKey,
|
|
129639
|
+
recordBase64: toString(recordBytes, "base64")
|
|
129640
|
+
});
|
|
129641
|
+
this.anchorRecordSequence = result.sequence;
|
|
129642
|
+
return result;
|
|
129643
|
+
}
|
|
129586
129644
|
async stop() {
|
|
129587
129645
|
this.posts._stop();
|
|
129588
129646
|
if (this.state === "updating") return super.stop();
|
|
@@ -129728,4 +129786,4 @@ var RpcLocalCommunity = class extends RpcRemoteCommunity {
|
|
|
129728
129786
|
}
|
|
129729
129787
|
};
|
|
129730
129788
|
//#endregion
|
|
129731
|
-
export {
|
|
129789
|
+
export { parseRawPages as $, t$5 as $n, parseCommentEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails as $t, deriveCommentIpfsFromCommentTableRow as A, RpcAuthorNameParamSchema as An, verifyCommunity as At, resolveDbPostsCidRefs as B, RpcExportCommunityResultSchema as Bn, getCommunityNameFromWire$1 as Bt, encryptEd25519AesGcmPublicKeyBuffer as C, parsePKCUserOptionsSchemaWithPKCErrorIfItFails as Cn, verifyChallengeRequest as Ct, calculateInlineRepliesBudget as D, parseVoteChallengeRequestToEncryptSchemaWithPKCErrorIfItFails as Dn, verifyCommentModeration as Dt, calculateExpectedSignatureSize as E, parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails as En, verifyCommentIpfs as Et, getThumbnailPropsOfLink as F, RpcCommunityPageParamSchema as Fn, getAuthorNameFromRuntime as Ft, POST_REPLIES_SORT_TYPES as G, RpcPublishedAnchorRecordResultSchema as Gn, getBufferedPKCAddressFromPublicKey as Gt, tryToDeleteCommunitiesThatFailedToBeDeletedBefore as H, RpcFetchCidResultSchema as Hn, normalizeCommunityInputFromCommunity as Ht, importSignerIntoKuboNode as I, RpcEditCommunityParamSchema as In, getAuthorNameFromWire as It, buildPageRuntimeFields as J, RpcSuccessResultSchema as Jn, getPKCAddressFromPublicKeySync as Jt, REPLY_REPLIES_SORT_TYPES as K, RpcResolveAuthorNameResultSchema as Kn, getIpfsKeyFromPrivateKey as Kt, listCommunitiesSync as L, RpcExportCommunityModLogsParamSchema as Ln, normalizeCreatePublicationAuthor as Lt, deriveDbReplies as M, RpcCidParamSchema as Mn, verifyVote as Mt, getDefaultCommunityDbConfig as N, RpcCommentRepliesPageParamSchema as Nn, buildRuntimeAuthor as Nt, createKuboRpcClient as O, parseVotePubsubMessagePublicationSchemaWithPKCErrorIfItFails as On, verifyCommentPubsubMessage as Ot, getDefaultDataPath as P, RpcCommunityIdentifierParamSchema as Pn, cleanWireAuthor as Pt, iterateOverPageCidsToFindAllCids as Q, r as Qn, parseCommentChallengeRequestToEncryptSchemaWithPKCErrorIfItFails as Qt, monitorCommunitiesDirectory as R, RpcExportCommunityModLogsResultSchema as Rn, buildRuntimeCommunityFields as Rt, encryptEd25519AesGcm as S, parseJsonWithPKCErrorIfFails as Sn, verifyChallengeMessage as St, backupCommunityDb as T, parseRpcCommentUpdateEventWithPKCErrorIfItFails as Tn, verifyCommentEdit as Tt, CommentClientsManager as U, RpcPublishAnchorRecordParamSchema as Un, decode as Ut, setNativeFunctions as V, RpcFetchCidParamSchema as Vn, getCommunityPublicKeyFromWire as Vt, POSTS_SORT_TYPES as W, RpcPublishChallengeAnswersParamSchema as Wn, encode as Wt, extractCommunityRuntimeFieldsFromParsedPages as X, t$2 as Xn, createSchemaRowParser as Xt, buildPagesRuntimeFields as Y, RpcUnsubscribeParamSchema as Yn, getPublicKeyFromPrivateKey as Yt, findCommentInPageInstanceRecursively as Z, t$4 as Zn, parseCidStringSchemaWithPKCErrorIfItFails as Zt, SignerWithPublicKeyAddress as _, parseCreateRpcCommunityFunctionArgumentSchemaWithPKCErrorIfItFails as _n, signCommentUpdateForChallengeVerification as _t, pkcJsChallenges as a, parseCommunityAddressWithPKCErrorIfItFails as an, STORAGE_KEYS as ar, pLimit as at, decryptEd25519AesGcm as b, parseDecryptedChallengeVerification as bn, signVote as bt, AddressesRewriterProxyServer as c, parseCommunityEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails as cn, require_undici as cr, cleanUpBeforePublishing as ct, MAX_FILE_SIZE_BYTES_FOR_COMMUNITY_IPFS as d, parseCreateCommentModerationOptionsSchemaWithPKCErrorIfItFails as dn, signChallengeRequest as dt, parseCommentEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails as en, n$5 as er, RepliesPages as et, KeyvBetterSqlite3 as f, parseCreateCommentOptionsSchemaWithPKCErrorIfItFails as fn, signChallengeVerification as ft, decodeRpcChallengeVerificationPubsubMsg as g, parseCreateRemoteCommunityFunctionArgumentSchemaWithPKCErrorIfItFails as gn, signCommentUpdate as gt, decodeRpcChallengeRequestPubsubMsg as h, parseCreatePKCWsServerOptionsSchemaWithPKCErrorIfItFails as hn, signCommentModeration as ht, getCommunityChallengeFromCommunityChallengeSettings as i, parseCommentPubsubMessagePublicationWithPKCErrorIfItFails as in, stringify as ir, pRetry as it, deriveDbPosts as j, RpcCancelExportParamSchema as jn, verifyCommunityEdit as jt, deleteOldCommunityInWindows as k, RpcAnchorPublishPreparationResultSchema as kn, verifyCommentUpdate as kt, normalizeSelfAddrsForProvider as l, parseCommunityIpfsSchemaPassthroughWithPKCErrorIfItFails as ln, signChallengeAnswer as lt, decodeRpcChallengePubsubMsg as m, parseCreateNewLocalCommunityUserOptionsSchemaWithPKCErrorIfItFails as mn, signCommentEdit as mt, RpcRemoteCommunity as n, parseCommentModerationChallengeRequestToEncryptSchemaWithPKCErrorIfItFails as nn, t$7 as nr, PKCClientsManager as nt, TrackedInstanceRegistry as o, parseCommunityEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails as on, require_lodash_merge as or, PKCTypedEmitter as ot, decodeRpcChallengeAnswerPubsubMsg as p, parseCreateCommunityEditPublicationOptionsSchemaWithPKCErrorIfItFails as pn, signComment as pt, TIMEFRAMES_TO_SECONDS as q, RpcSubscriptionIdResultSchema as qn, getPKCAddressFromPublicKey as qt, getChallengeVerification as r, parseCommentModerationPubsubMessagePublicationSchemaWithPKCErrorIfItFails as rn, t$8 as rr, InflightFetchManager as rt, LRUCache as s, parseCommunityEditOptionsSchemaWithPKCErrorIfItFails as sn, nativeFunctions$1 as sr, require_lib$1 as st, RpcLocalCommunity as t, parseCommentIpfsSchemaWithPKCErrorIfItFails as tn, n$6 as tr, PublicationClientsManager as tt, RemoteCommunity as u, parseCreateCommentEditOptionsSchemaWithPKCErrorIfItFails as un, signChallengeMessage as ut, createSigner as v, parseCreateVoteOptionsSchemaWithPKCErrorIfItFails as vn, signCommunity as vt, BackupAbortError as w, parseRpcCommentEventWithPKCErrorIfItFails as wn, verifyChallengeVerification as wt, decryptEd25519AesGcmPublicKeyBuffer as x, parseDecryptedChallengeWithPKCErrorIfItFails as xn, verifyChallengeAnswer as xt, createAnchorIpnsRecord as y, parseDecryptedChallengeAnswerWithPKCErrorIfItFails as yn, signCommunityEdit as yt, moveCommunityDbToDeletedDirectory as z, RpcExportCommunityParamSchema as zn, getCommunityAddressFromRecord as zt };
|