@pkcprotocol/pkc-js 0.0.68 → 0.0.70
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/generated-version.d.ts +1 -1
- package/dist/browser/generated-version.js +1 -1
- package/dist/browser/helia/helia-for-pkc.js +28 -4
- package/dist/browser/helia/helia-for-pkc.js.map +1 -1
- package/dist/browser/helia/util.d.ts +19 -0
- package/dist/browser/helia/util.js +191 -0
- package/dist/browser/helia/util.js.map +1 -1
- package/dist/browser/rpc/src/schema.d.ts +22 -10
- package/dist/browser/runtime/node/community/local-community/comment-updates.d.ts +5 -1
- package/dist/browser/runtime/node/community/local-community/comment-updates.js +7 -3
- package/dist/browser/runtime/node/community/local-community/comment-updates.js.map +1 -1
- package/dist/browser/schema.d.ts +10 -21
- package/dist/browser/schema.js.map +1 -1
- package/dist/bundled/bundle-manifest.json +92 -90
- package/dist/bundled/chunks/{helia-for-pkc-R4yRqnHx.js → helia-for-pkc-CkFh5nlx.js} +16 -4
- package/dist/bundled/chunks/{local-community-BD1ADX4_.js → local-community-B66sHtZ1.js} +1 -1
- package/dist/bundled/chunks/{local-community-BlGJFwN6.js → local-community-DF2_ny4_.js} +35 -29
- package/dist/bundled/chunks/{node-LHrRDb4V.js → node-C-uEWzwA.js} +5 -5
- package/dist/bundled/chunks/{rpc-local-community-DCOszS5C.js → rpc-local-community-uFGcODiy.js} +17 -17
- package/dist/bundled/chunks/{schema-V4BgFltI.js → schema-CdHApryH.js} +2 -2
- package/dist/bundled/chunks/{util-BOhb3f5T.js → util-D6lhOdvW.js} +101 -2
- package/dist/bundled/index.js +1 -1
- package/dist/bundled/rpc/src/index.js +4 -4
- package/dist/node/generated-version.d.ts +1 -1
- package/dist/node/generated-version.js +1 -1
- package/dist/node/helia/helia-for-pkc.js +28 -4
- package/dist/node/helia/helia-for-pkc.js.map +1 -1
- package/dist/node/helia/util.d.ts +19 -0
- package/dist/node/helia/util.js +191 -0
- package/dist/node/helia/util.js.map +1 -1
- package/dist/node/rpc/src/schema.d.ts +22 -10
- package/dist/node/runtime/node/community/local-community/comment-updates.d.ts +5 -1
- package/dist/node/runtime/node/community/local-community/comment-updates.js +7 -3
- package/dist/node/runtime/node/community/local-community/comment-updates.js.map +1 -1
- package/dist/node/schema.d.ts +10 -21
- package/dist/node/schema.js.map +1 -1
- package/package.json +2 -1
- package/dist/bundled/chunks/{src-0J9-Tmgd.js → src-o_MYSn-E.js} +1 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { i as __toESM, r as __require, t as __commonJSMin } from "./chunk-2rV9d50f.js";
|
|
2
|
-
import { $ as pubsubTopicToDhtKey, $n as t$7, At as trackStartedCommunity, Bt as CommunityEditPublicationPubsubReservedFields, C as contentContainsMarkdownAudio, Ct as findUpdatingCommunity, En as CommentUpdateSchema, F as getIpnsRecordInLocalKuboNode, Fn as CommentEditPubsubMessagePublicationSchema, Ft as untrackUpdatingCommunity, G as isLinkOfAudio, Gt as CommentModerationPubsubMessagePublicationSchema, In as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema, It as require_sha256, J as isLinkOfVideo, Jt as CommentModerationsTableRowSchema, K as isLinkOfImage, Kt as CommentModerationReservedFields, L as hideClassPrivateProps, Ln as CommentEditReservedFields, M as genToArray, Mr as ZodError, Mt as trackUpdatingCommunity, N as getEquivalentCommunityAddresses, Nt as untrackStartedCommunity, O as derivePublicationFromChallengeRequest, On as CommentUpdateTableRowSchema, P as getErrorCodeFromMessage, Q as isStringDomain, Qn as n$3, R as ipnsNameToIpnsOverPubsubTopic, Rt as pTimeout, S as calculateStringSizeSameAsIpfsAddCidV0, T as contentContainsMarkdownVideos, Un as AuthorReservedFields, W as isLinkOfAnimatedImage, Xn as n$4, Y as isLinkValid, Zn as t$8, _r as PKCError, _t as timestamp, a as ChallengeRequestMessageSchema, ar as t$4, at as removeNullUndefinedValues, b as areEquivalentCommunityAddresses, bt as findCommunityInRegistry, cr as t$5, d as DecryptedChallengeRequestSchema, dr as require_retry, dt as retryKuboIpfsAddAndProvide, er as t$6, fn as VotePubsubMessagePublicationSchema, hn as VoteTablesRowSchema, ht as statMfsPathSafely, ir as r$1, k as doesDomainAddressHaveCapitalLetter, kn as CommentsTableRowSchema, kt as syncCommunityRegistryEntry, lr as t$3, lt as retryKuboBlockPutPinAndProvidePubsubTopic, mt as sleepUntilTimeoutOrAbort, nn as CommunityIpfsSchema, nr as e$1, nt as removeBlocksFromKuboNode, pn as VotePubsubReservedFields, q as isLinkOfMedia, r as ChallengeMessageSchema, rn as CommunitySignedPropertyNames, rt as removeMfsFilesSafely, s as ChallengeVerificationMessageSchema, t as ChallengeAnswerMessageSchema, tr as e, u as DecryptedChallengeRequestPublicationSchema, vn as CommentIpfsSchema, vr as messages, w as contentContainsMarkdownImages, x as calculateIpfsCidV0, xt as findStartedCommunity, y as version_default, yn as CommentPubsubMessageReservedFields, yr as logger_default, yt as writeKuboFilesWithTimeout, zn as CommentEditsTableRowSchema } from "./schema-
|
|
3
|
-
import { $n as t$10, A as deriveDbPosts, At as verifyCommunityEdit, Bt as getCommunityPublicKeyFromWire, C as BackupAbortError, Dt as verifyCommentPubsubMessage, E as calculateInlineRepliesBudget, Et as verifyCommentModeration, F as importSignerIntoKuboNode, Ft as getAuthorNameFromWire, G as REPLY_REPLIES_SORT_TYPES, Gt as getIpfsKeyFromPrivateKey, Ht as decode, Jn as r$2, Jt as getPublicKeyFromPrivateKey, K as TIMEFRAMES_TO_SECONDS, Kn as t$9, Kt as getPKCAddressFromPublicKey, M as getDefaultCommunityDbConfig, Mt as buildRuntimeAuthor, Nt as cleanWireAuthor, O as deleteOldCommunityInWindows, Ot as verifyCommentUpdate, P as getThumbnailPropsOfLink, R as moveCommunityDbToDeletedDirectory, S as encryptEd25519AesGcmPublicKeyBuffer, St as verifyChallengeRequest, T as calculateExpectedSignatureSize, Tt as verifyCommentIpfs, U as POSTS_SORT_TYPES, Ut as encode, W as POST_REPLIES_SORT_TYPES, Xn as n$6, Yn as t$11, Yt as createSchemaRowParser, Z as iterateOverPageCidsToFindAllCids, Zn as n$5, _ as SignerWithPublicKeyAddress, _t as signCommunity, a as pkcJsChallenges, b as decryptEd25519AesGcmPublicKeyBuffer, bt as verifyChallengeAnswer, cn as parseCommunityIpfsSchemaPassthroughWithPKCErrorIfItFails, d as MAX_FILE_SIZE_BYTES_FOR_COMMUNITY_IPFS, dt as signChallengeVerification, er as stringify, f as KeyvBetterSqlite3, ft as signComment, gt as signCommentUpdateForChallengeVerification, ht as signCommentUpdate, i as getCommunityChallengeFromCommunityChallengeSettings, it as pLimit, j as deriveDbReplies, jt as verifyVote, k as deriveCommentIpfsFromCommentTableRow, kt as verifyCommunity, l as normalizeSelfAddrsForProvider, lt as signChallengeMessage, nr as require_lodash_merge, o as TrackedInstanceRegistry, on as parseCommunityEditOptionsSchemaWithPKCErrorIfItFails, pt as signCommentEdit, qn as t$12, qt as getPKCAddressFromPublicKeySync, r as getChallengeVerification, s as LRUCache, st as cleanUpBeforePublishing, t as RpcLocalCommunity, tr as STORAGE_KEYS, vn as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, w as backupCommunityDb, wt as verifyCommentEdit, xn as parseJsonWithPKCErrorIfFails, z as resolveDbPostsCidRefs, zt as getCommunityNameFromWire } from "./rpc-local-community-
|
|
2
|
+
import { $ as pubsubTopicToDhtKey, $n as t$7, At as trackStartedCommunity, Bt as CommunityEditPublicationPubsubReservedFields, C as contentContainsMarkdownAudio, Ct as findUpdatingCommunity, En as CommentUpdateSchema, F as getIpnsRecordInLocalKuboNode, Fn as CommentEditPubsubMessagePublicationSchema, Ft as untrackUpdatingCommunity, G as isLinkOfAudio, Gt as CommentModerationPubsubMessagePublicationSchema, In as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema, It as require_sha256, J as isLinkOfVideo, Jt as CommentModerationsTableRowSchema, K as isLinkOfImage, Kt as CommentModerationReservedFields, L as hideClassPrivateProps, Ln as CommentEditReservedFields, M as genToArray, Mr as ZodError, Mt as trackUpdatingCommunity, N as getEquivalentCommunityAddresses, Nt as untrackStartedCommunity, O as derivePublicationFromChallengeRequest, On as CommentUpdateTableRowSchema, P as getErrorCodeFromMessage, Q as isStringDomain, Qn as n$3, R as ipnsNameToIpnsOverPubsubTopic, Rt as pTimeout, S as calculateStringSizeSameAsIpfsAddCidV0, T as contentContainsMarkdownVideos, Un as AuthorReservedFields, W as isLinkOfAnimatedImage, Xn as n$4, Y as isLinkValid, Zn as t$8, _r as PKCError, _t as timestamp, a as ChallengeRequestMessageSchema, ar as t$4, at as removeNullUndefinedValues, b as areEquivalentCommunityAddresses, bt as findCommunityInRegistry, cr as t$5, d as DecryptedChallengeRequestSchema, dr as require_retry, dt as retryKuboIpfsAddAndProvide, er as t$6, fn as VotePubsubMessagePublicationSchema, hn as VoteTablesRowSchema, ht as statMfsPathSafely, ir as r$1, k as doesDomainAddressHaveCapitalLetter, kn as CommentsTableRowSchema, kt as syncCommunityRegistryEntry, lr as t$3, lt as retryKuboBlockPutPinAndProvidePubsubTopic, mt as sleepUntilTimeoutOrAbort, nn as CommunityIpfsSchema, nr as e$1, nt as removeBlocksFromKuboNode, pn as VotePubsubReservedFields, q as isLinkOfMedia, r as ChallengeMessageSchema, rn as CommunitySignedPropertyNames, rt as removeMfsFilesSafely, s as ChallengeVerificationMessageSchema, t as ChallengeAnswerMessageSchema, tr as e, u as DecryptedChallengeRequestPublicationSchema, vn as CommentIpfsSchema, vr as messages, w as contentContainsMarkdownImages, x as calculateIpfsCidV0, xt as findStartedCommunity, y as version_default, yn as CommentPubsubMessageReservedFields, yr as logger_default, yt as writeKuboFilesWithTimeout, zn as CommentEditsTableRowSchema } from "./schema-CdHApryH.js";
|
|
3
|
+
import { $n as t$10, A as deriveDbPosts, At as verifyCommunityEdit, Bt as getCommunityPublicKeyFromWire, C as BackupAbortError, Dt as verifyCommentPubsubMessage, E as calculateInlineRepliesBudget, Et as verifyCommentModeration, F as importSignerIntoKuboNode, Ft as getAuthorNameFromWire, G as REPLY_REPLIES_SORT_TYPES, Gt as getIpfsKeyFromPrivateKey, Ht as decode, Jn as r$2, Jt as getPublicKeyFromPrivateKey, K as TIMEFRAMES_TO_SECONDS, Kn as t$9, Kt as getPKCAddressFromPublicKey, M as getDefaultCommunityDbConfig, Mt as buildRuntimeAuthor, Nt as cleanWireAuthor, O as deleteOldCommunityInWindows, Ot as verifyCommentUpdate, P as getThumbnailPropsOfLink, R as moveCommunityDbToDeletedDirectory, S as encryptEd25519AesGcmPublicKeyBuffer, St as verifyChallengeRequest, T as calculateExpectedSignatureSize, Tt as verifyCommentIpfs, U as POSTS_SORT_TYPES, Ut as encode, W as POST_REPLIES_SORT_TYPES, Xn as n$6, Yn as t$11, Yt as createSchemaRowParser, Z as iterateOverPageCidsToFindAllCids, Zn as n$5, _ as SignerWithPublicKeyAddress, _t as signCommunity, a as pkcJsChallenges, b as decryptEd25519AesGcmPublicKeyBuffer, bt as verifyChallengeAnswer, cn as parseCommunityIpfsSchemaPassthroughWithPKCErrorIfItFails, d as MAX_FILE_SIZE_BYTES_FOR_COMMUNITY_IPFS, dt as signChallengeVerification, er as stringify, f as KeyvBetterSqlite3, ft as signComment, gt as signCommentUpdateForChallengeVerification, ht as signCommentUpdate, i as getCommunityChallengeFromCommunityChallengeSettings, it as pLimit, j as deriveDbReplies, jt as verifyVote, k as deriveCommentIpfsFromCommentTableRow, kt as verifyCommunity, l as normalizeSelfAddrsForProvider, lt as signChallengeMessage, nr as require_lodash_merge, o as TrackedInstanceRegistry, on as parseCommunityEditOptionsSchemaWithPKCErrorIfItFails, pt as signCommentEdit, qn as t$12, qt as getPKCAddressFromPublicKeySync, r as getChallengeVerification, s as LRUCache, st as cleanUpBeforePublishing, t as RpcLocalCommunity, tr as STORAGE_KEYS, vn as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, w as backupCommunityDb, wt as verifyCommentEdit, xn as parseJsonWithPKCErrorIfFails, z as resolveDbPostsCidRefs, zt as getCommunityNameFromWire } from "./rpc-local-community-uFGcODiy.js";
|
|
4
4
|
import { randomFillSync, randomUUID } from "node:crypto";
|
|
5
5
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
6
|
-
import
|
|
6
|
+
import path from "node:path";
|
|
7
7
|
import os from "os";
|
|
8
8
|
import { existsSync, promises } from "node:fs";
|
|
9
|
-
import path from "path";
|
|
9
|
+
import path$1 from "path";
|
|
10
10
|
import assert from "assert";
|
|
11
11
|
import fs from "fs";
|
|
12
12
|
import Database from "better-sqlite3";
|
|
@@ -77,7 +77,8 @@ function calculateLocalMfsPathForCommentUpdate(community, postDbComment, timesta
|
|
|
77
77
|
"update"
|
|
78
78
|
].join("/");
|
|
79
79
|
}
|
|
80
|
-
async function calculateNewCommentUpdate(
|
|
80
|
+
async function calculateNewCommentUpdate(opts) {
|
|
81
|
+
const { community, comment, batchStartTimestamp } = opts;
|
|
81
82
|
const log = logger_default("pkc-js:local-community:_calculateNewCommentUpdate");
|
|
82
83
|
log.trace(`Attempting to calculate new CommentUpdate for comment (${comment.cid}) on community`, community.address);
|
|
83
84
|
const storedCommentUpdate = community._dbHandler.queryCommentUpdateTimestampBucketReplies({ cid: comment.cid });
|
|
@@ -139,7 +140,7 @@ async function calculateNewCommentUpdate(community, comment) {
|
|
|
139
140
|
}),
|
|
140
141
|
postUpdatesBucket: newPostUpdateBucket,
|
|
141
142
|
publishedToPostUpdatesMFS: false,
|
|
142
|
-
insertedAt:
|
|
143
|
+
insertedAt: batchStartTimestamp
|
|
143
144
|
},
|
|
144
145
|
localMfsPath: newLocalMfsPath,
|
|
145
146
|
pendingApproval: comment.pendingApproval
|
|
@@ -166,6 +167,7 @@ async function validateCommentUpdateSignature(community, newCommentUpdate, comme
|
|
|
166
167
|
}
|
|
167
168
|
async function updateCommentsThatNeedToBeUpdated(community) {
|
|
168
169
|
const log = logger_default(`pkc-js:local-community:_updateCommentsThatNeedToBeUpdated`);
|
|
170
|
+
const batchStartTimestamp = timestamp();
|
|
169
171
|
const commentsToUpdate = community._dbHandler.queryCommentsToBeUpdated();
|
|
170
172
|
if (commentsToUpdate.length === 0) return [];
|
|
171
173
|
community._communityUpdateTrigger = true;
|
|
@@ -181,7 +183,11 @@ async function updateCommentsThatNeedToBeUpdated(community) {
|
|
|
181
183
|
for (const depthKey of depthsKeySorted) {
|
|
182
184
|
const commentsAtDepth = commentsByDepth[depthKey];
|
|
183
185
|
const depthLimit = pLimit(50);
|
|
184
|
-
const depthUpdatePromises = commentsAtDepth.map((comment) => depthLimit(async () => await calculateNewCommentUpdate(
|
|
186
|
+
const depthUpdatePromises = commentsAtDepth.map((comment) => depthLimit(async () => await calculateNewCommentUpdate({
|
|
187
|
+
community,
|
|
188
|
+
comment,
|
|
189
|
+
batchStartTimestamp
|
|
190
|
+
})));
|
|
185
191
|
const depthResults = await Promise.all(depthUpdatePromises);
|
|
186
192
|
community._dbHandler.upsertCommentUpdates(depthResults.map((r) => r.newCommentUpdateToWriteToDb));
|
|
187
193
|
postUpdateRows.push(...depthResults);
|
|
@@ -3273,9 +3279,9 @@ var DbHandler = class {
|
|
|
3273
3279
|
if (needToMigrate) {
|
|
3274
3280
|
if (dbExistsAlready && currentDbVersion > 0) {
|
|
3275
3281
|
this.destoryConnection();
|
|
3276
|
-
backupDbPath = path.join(path.dirname(dbPath), ".backup_before_migration", `${path.basename(dbPath)}.${currentDbVersion}.${timestamp()}`);
|
|
3277
|
-
log(`Copying db ${path.basename(dbPath)} to ${backupDbPath} before migration`);
|
|
3278
|
-
if (!fs.existsSync(path.dirname(backupDbPath))) await fs.promises.mkdir(path.dirname(backupDbPath), { recursive: true });
|
|
3282
|
+
backupDbPath = path$1.join(path$1.dirname(dbPath), ".backup_before_migration", `${path$1.basename(dbPath)}.${currentDbVersion}.${timestamp()}`);
|
|
3283
|
+
log(`Copying db ${path$1.basename(dbPath)} to ${backupDbPath} before migration`);
|
|
3284
|
+
if (!fs.existsSync(path$1.dirname(backupDbPath))) await fs.promises.mkdir(path$1.dirname(backupDbPath), { recursive: true });
|
|
3279
3285
|
const sourceDb = new Database(dbPath, { fileMustExist: true });
|
|
3280
3286
|
await sourceDb.backup(backupDbPath);
|
|
3281
3287
|
sourceDb.close();
|
|
@@ -5078,10 +5084,10 @@ var DbHandler = class {
|
|
|
5078
5084
|
if (this._db || this._keyv) await this.destoryConnection();
|
|
5079
5085
|
this._transactionDepth = 0;
|
|
5080
5086
|
const dataPath = this._community._pkc.dataPath;
|
|
5081
|
-
const oldPathString = path.join(dataPath, "communities", oldDbName);
|
|
5082
|
-
const newPathString = path.join(dataPath, "communities", newDbName);
|
|
5083
|
-
await fs.promises.mkdir(path.dirname(oldPathString), { recursive: true });
|
|
5084
|
-
await fs.promises.mkdir(path.dirname(newPathString), { recursive: true });
|
|
5087
|
+
const oldPathString = path$1.join(dataPath, "communities", oldDbName);
|
|
5088
|
+
const newPathString = path$1.join(dataPath, "communities", newDbName);
|
|
5089
|
+
await fs.promises.mkdir(path$1.dirname(oldPathString), { recursive: true });
|
|
5090
|
+
await fs.promises.mkdir(path$1.dirname(newPathString), { recursive: true });
|
|
5085
5091
|
try {
|
|
5086
5092
|
if (!fs.existsSync(oldPathString)) log(`Old DB file ${oldPathString} does not exist. Cannot backup/rename.`);
|
|
5087
5093
|
else {
|
|
@@ -5103,8 +5109,8 @@ var DbHandler = class {
|
|
|
5103
5109
|
}
|
|
5104
5110
|
async lockCommunityStart(communityAddress = this._community.address) {
|
|
5105
5111
|
const log = logger_default("pkc-js:local-community:db-handler:lock:start");
|
|
5106
|
-
const lockfilePath = path.join(this._community._pkc.dataPath, "communities", `${communityAddress}.start.lock`);
|
|
5107
|
-
const communityDbPath = path.join(this._community._pkc.dataPath, "communities", communityAddress);
|
|
5112
|
+
const lockfilePath = path$1.join(this._community._pkc.dataPath, "communities", `${communityAddress}.start.lock`);
|
|
5113
|
+
const communityDbPath = path$1.join(this._community._pkc.dataPath, "communities", communityAddress);
|
|
5108
5114
|
try {
|
|
5109
5115
|
await import_src.default.lock(communityDbPath, {
|
|
5110
5116
|
lockfilePath,
|
|
@@ -5125,8 +5131,8 @@ var DbHandler = class {
|
|
|
5125
5131
|
async unlockCommunityStart(communityAddress = this._community.address) {
|
|
5126
5132
|
const log = logger_default("pkc-js:local-community:db-handler:unlock:start");
|
|
5127
5133
|
log.trace(`Attempting to unlock the start of community (${communityAddress})`);
|
|
5128
|
-
const lockfilePath = path.join(this._community._pkc.dataPath, "communities", `${communityAddress}.start.lock`);
|
|
5129
|
-
const communityDbPath = path.join(this._community._pkc.dataPath, "communities", communityAddress);
|
|
5134
|
+
const lockfilePath = path$1.join(this._community._pkc.dataPath, "communities", `${communityAddress}.start.lock`);
|
|
5135
|
+
const communityDbPath = path$1.join(this._community._pkc.dataPath, "communities", communityAddress);
|
|
5130
5136
|
if (!fs.existsSync(lockfilePath) || !fs.existsSync(communityDbPath)) return;
|
|
5131
5137
|
try {
|
|
5132
5138
|
await import_src.default.unlock(communityDbPath, { lockfilePath });
|
|
@@ -5137,8 +5143,8 @@ var DbHandler = class {
|
|
|
5137
5143
|
}
|
|
5138
5144
|
}
|
|
5139
5145
|
async isCommunityStartLocked(communityAddress = this._community.address) {
|
|
5140
|
-
const lockfilePath = path.join(this._community._pkc.dataPath, "communities", `${communityAddress}.start.lock`);
|
|
5141
|
-
const communityDbPath = path.join(this._community._pkc.dataPath, "communities", communityAddress);
|
|
5146
|
+
const lockfilePath = path$1.join(this._community._pkc.dataPath, "communities", `${communityAddress}.start.lock`);
|
|
5147
|
+
const communityDbPath = path$1.join(this._community._pkc.dataPath, "communities", communityAddress);
|
|
5142
5148
|
return await import_src.default.check(communityDbPath, {
|
|
5143
5149
|
lockfilePath,
|
|
5144
5150
|
realpath: false,
|
|
@@ -5147,8 +5153,8 @@ var DbHandler = class {
|
|
|
5147
5153
|
}
|
|
5148
5154
|
async lockCommunityState() {
|
|
5149
5155
|
const log = logger_default("pkc-js:local-community:db-handler:lock:lockCommunityState");
|
|
5150
|
-
const lockfilePath = path.join(this._community._pkc.dataPath, "communities", `${this._community.address}.state.lock`);
|
|
5151
|
-
const communityDbPath = path.join(this._community._pkc.dataPath, "communities", this._community.address);
|
|
5156
|
+
const lockfilePath = path$1.join(this._community._pkc.dataPath, "communities", `${this._community.address}.state.lock`);
|
|
5157
|
+
const communityDbPath = path$1.join(this._community._pkc.dataPath, "communities", this._community.address);
|
|
5152
5158
|
try {
|
|
5153
5159
|
await import_src.default.lock(communityDbPath, {
|
|
5154
5160
|
lockfilePath,
|
|
@@ -5165,8 +5171,8 @@ var DbHandler = class {
|
|
|
5165
5171
|
}
|
|
5166
5172
|
async unlockCommunityState() {
|
|
5167
5173
|
const log = logger_default("pkc-js:local-community:db-handler:lock:unlockCommunityState");
|
|
5168
|
-
const lockfilePath = path.join(this._community._pkc.dataPath, "communities", `${this._community.address}.state.lock`);
|
|
5169
|
-
const communityDbPath = path.join(this._community._pkc.dataPath, "communities", this._community.address);
|
|
5174
|
+
const lockfilePath = path$1.join(this._community._pkc.dataPath, "communities", `${this._community.address}.state.lock`);
|
|
5175
|
+
const communityDbPath = path$1.join(this._community._pkc.dataPath, "communities", this._community.address);
|
|
5170
5176
|
if (!fs.existsSync(lockfilePath)) return;
|
|
5171
5177
|
try {
|
|
5172
5178
|
await import_src.default.unlock(communityDbPath, { lockfilePath });
|
|
@@ -5176,7 +5182,7 @@ var DbHandler = class {
|
|
|
5176
5182
|
}
|
|
5177
5183
|
}
|
|
5178
5184
|
communityDbExists() {
|
|
5179
|
-
const communityDbPath = path.join(this._community._pkc.dataPath, "communities", this._community.address);
|
|
5185
|
+
const communityDbPath = path$1.join(this._community._pkc.dataPath, "communities", this._community.address);
|
|
5180
5186
|
return fs.existsSync(communityDbPath);
|
|
5181
5187
|
}
|
|
5182
5188
|
markCommentsAsPublishedToPostUpdates(commentCids) {
|
|
@@ -6867,11 +6873,11 @@ async function edit(community, newCommunityOptions) {
|
|
|
6867
6873
|
const EXPORTS_KEY = STORAGE_KEYS[STORAGE_KEYS.EXPORTS];
|
|
6868
6874
|
function defaultExportPathFor(community, exportId) {
|
|
6869
6875
|
if (typeof community._pkc.dataPath !== "string") throw new PKCError("ERR_DATA_PATH_IS_NOT_DEFINED", { communityAddress: community.address });
|
|
6870
|
-
return
|
|
6876
|
+
return path.join(community._pkc.dataPath, "exports", `${exportId}.sqlite`);
|
|
6871
6877
|
}
|
|
6872
6878
|
function sourceDbPathFor(community) {
|
|
6873
6879
|
if (typeof community._pkc.dataPath !== "string") throw new PKCError("ERR_DATA_PATH_IS_NOT_DEFINED", { communityAddress: community.address });
|
|
6874
|
-
return
|
|
6880
|
+
return path.join(community._pkc.dataPath, "communities", community.address);
|
|
6875
6881
|
}
|
|
6876
6882
|
async function persistExports(community) {
|
|
6877
6883
|
if (!community._dbHandler) return;
|
|
@@ -6947,9 +6953,9 @@ async function runExportTask(community, exportId, opts) {
|
|
|
6947
6953
|
async function exportCommunityEmbedded(community, options = {}) {
|
|
6948
6954
|
if (options.signal?.aborted) throw options.signal.reason ?? new DOMException("The operation was aborted.", "AbortError");
|
|
6949
6955
|
const exportId = v4();
|
|
6950
|
-
const destPath = options.exportPath ?
|
|
6956
|
+
const destPath = options.exportPath ? path.resolve(options.exportPath) : defaultExportPathFor(community, exportId);
|
|
6951
6957
|
const includePrivateKey = options.includePrivateKey === true;
|
|
6952
|
-
if (
|
|
6958
|
+
if (path.resolve(destPath) === path.resolve(sourceDbPathFor(community))) throw new PKCError("ERR_EXPORT_PATH_TARGETS_LIVE_DB", {
|
|
6953
6959
|
communityAddress: community.address,
|
|
6954
6960
|
exportPath: destPath
|
|
6955
6961
|
});
|
|
@@ -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, Cn as CommentUpdateForChallengeVerificationSchema, Ct as findUpdatingCommunity, D as deepMergeRuntimeFields, Dt as refreshTrackedCommentAliases, E as createAbortError, En as CommentUpdateSchema, Et as listUpdatingCommunities, Fr as stringifyPrimitive, H as isIpns, It as require_sha256, L as hideClassPrivateProps, Lt as TimeoutError, Nr as joinValues, Pr as parsedType, Pt as untrackUpdatingComment, Q as isStringDomain, Qn as n$1, R as ipnsNameToIpnsOverPubsubTopic, Rt as pTimeout, Sr as setErrorMap, St as findUpdatingComment, Tt as listUpdatingComments, Xn as n$2, _r as PKCError, _t as timestamp, a as ChallengeRequestMessageSchema, b as areEquivalentCommunityAddresses, br as require_supports_color, cn as PubsubTopicSchema, ct as resolveWhenPredicateIsTrue, dr as require_retry, er as t$1, fr as FailedToFetchCommentIpfsFromGatewaysError, ft as shortifyAddress, ir as r, jt as trackUpdatingComment, k as doesDomainAddressHaveCapitalLetter, mt as sleepUntilTimeoutOrAbort, nn as CommunityIpfsSchema, nr as e$1, ot as removeUndefinedValuesRecursively, pt as shortifyCid, r as ChallengeMessageSchema, s as ChallengeVerificationMessageSchema, st as replaceXWithY, t as ChallengeAnswerMessageSchema, tr as e, ut as retryKuboIpfsAdd, vn as CommentIpfsSchema, vr as messages, vt as waitForUpdateInCommunityInstanceWithErrorAndTimeout, wt as listStartedCommunities, xt as findStartedCommunity, y as version_default, yr as logger_default, z as isAbortError } from "./schema-
|
|
3
|
-
import { $ as RepliesPages, $n as t$5, $t as parseCommentEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, An as RpcCidParamSchema, At as verifyCommunityEdit, B as setNativeFunctions$1, Bn as RpcFetchCidResultSchema, Bt as getCommunityPublicKeyFromWire, Cn as parseRpcCommentEventWithPKCErrorIfItFails, Ct as verifyChallengeVerification, D as createKuboRpcClient, Dn as parseVotePubsubMessagePublicationSchemaWithPKCErrorIfItFails, Dt as verifyCommentPubsubMessage, Et as verifyCommentModeration, Fn as RpcExportCommunityModLogsParamSchema, Gn as RpcUnsubscribeParamSchema, H as CommentClientsManager, Hn as RpcResolveAuthorNameResultSchema, Ht as decode, I as listCommunitiesSync, In as RpcExportCommunityModLogsResultSchema, It as normalizeCreatePublicationAuthor, Kn as t$4, L as monitorCommunitiesDirectory, Ln as RpcExportCommunityParamSchema, Lt as buildRuntimeCommunityFields, Mn as RpcCommunityIdentifierParamSchema, Mt as buildRuntimeAuthor, N as getDefaultDataPath, Nn as RpcCommunityPageParamSchema, Nt as cleanWireAuthor, On as RpcAuthorNameParamSchema, Ot as verifyCommentUpdate, Pn as RpcEditCommunityParamSchema, Pt as getAuthorNameFromRuntime, Q as parseRawPages, Qn as t$2, Rn as RpcExportCommunityResultSchema, Rt as getCommunityAddressFromRecord, Sn as parsePKCUserOptionsSchemaWithPKCErrorIfItFails, Tn as parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, Tt as verifyCommentIpfs, Un as RpcSubscriptionIdResultSchema, V as tryToDeleteCommunitiesThatFailedToBeDeletedBefore, Vn as RpcPublishChallengeAnswersParamSchema, Vt as normalizeCommunityInputFromCommunity, Wn as RpcSuccessResultSchema, Wt as getBufferedPKCAddressFromPublicKey, X as findCommentInPageInstanceRecursively, Xn as n$3, Xt as parseCidStringSchemaWithPKCErrorIfItFails, Y as extractCommunityRuntimeFieldsFromParsedPages, Yn as t$3, _n as parseCreateVoteOptionsSchemaWithPKCErrorIfItFails, a as pkcJsChallenges, at as PKCTypedEmitter, bn as parseDecryptedChallengeWithPKCErrorIfItFails, c as AddressesRewriterProxyServer, ct as signChallengeAnswer, dn as parseCreateCommentOptionsSchemaWithPKCErrorIfItFails, en as parseCommentIpfsSchemaWithPKCErrorIfItFails, et as PublicationClientsManager, f as KeyvBetterSqlite3, fn as parseCreateCommunityEditPublicationOptionsSchemaWithPKCErrorIfItFails, ft as signComment, g as decodeRpcChallengeVerificationPubsubMsg, gn as parseCreateRpcCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, h as decodeRpcChallengeRequestPubsubMsg, hn as parseCreateRemoteCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, in as parseCommunityAddressWithPKCErrorIfItFails, ir as require_undici, jn as RpcCommentRepliesPageParamSchema, jt as verifyVote, kn as RpcCancelExportParamSchema, ln as parseCreateCommentEditOptionsSchemaWithPKCErrorIfItFails, m as decodeRpcChallengePubsubMsg, mt as signCommentModeration, n as RpcRemoteCommunity, nn as parseCommentModerationPubsubMessagePublicationSchemaWithPKCErrorIfItFails, nt as InflightFetchManager, o as TrackedInstanceRegistry, ot as require_lib$1, p as decodeRpcChallengeAnswerPubsubMsg, pt as signCommentEdit, rn as parseCommentPubsubMessagePublicationWithPKCErrorIfItFails, rr as nativeFunctions$2, s as LRUCache, sn as parseCommunityEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, st as cleanUpBeforePublishing, t as RpcLocalCommunity, tt as PKCClientsManager, u as RemoteCommunity, un as parseCreateCommentModerationOptionsSchemaWithPKCErrorIfItFails, ut as signChallengeRequest, v as createSigner, vn as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, vt as signCommunityEdit, wn as parseRpcCommentUpdateEventWithPKCErrorIfItFails, wt as verifyCommentEdit, x as encryptEd25519AesGcm, xn as parseJsonWithPKCErrorIfFails, xt as verifyChallengeMessage, y as decryptEd25519AesGcm, yn as parseDecryptedChallengeVerification, yt as signVote, zn as RpcFetchCidParamSchema, zt as getCommunityNameFromWire } from "./rpc-local-community-
|
|
4
|
-
import {
|
|
2
|
+
import { B as isIpfsCid, Cn as CommentUpdateForChallengeVerificationSchema, Ct as findUpdatingCommunity, D as deepMergeRuntimeFields, Dt as refreshTrackedCommentAliases, E as createAbortError, En as CommentUpdateSchema, Et as listUpdatingCommunities, Fr as stringifyPrimitive, H as isIpns, It as require_sha256, L as hideClassPrivateProps, Lt as TimeoutError, Nr as joinValues, Pr as parsedType, Pt as untrackUpdatingComment, Q as isStringDomain, Qn as n$1, R as ipnsNameToIpnsOverPubsubTopic, Rt as pTimeout, Sr as setErrorMap, St as findUpdatingComment, Tt as listUpdatingComments, Xn as n$2, _r as PKCError, _t as timestamp, a as ChallengeRequestMessageSchema, b as areEquivalentCommunityAddresses, br as require_supports_color, cn as PubsubTopicSchema, ct as resolveWhenPredicateIsTrue, dr as require_retry, er as t$1, fr as FailedToFetchCommentIpfsFromGatewaysError, ft as shortifyAddress, ir as r, jt as trackUpdatingComment, k as doesDomainAddressHaveCapitalLetter, mt as sleepUntilTimeoutOrAbort, nn as CommunityIpfsSchema, nr as e$1, ot as removeUndefinedValuesRecursively, pt as shortifyCid, r as ChallengeMessageSchema, s as ChallengeVerificationMessageSchema, st as replaceXWithY, t as ChallengeAnswerMessageSchema, tr as e, ut as retryKuboIpfsAdd, vn as CommentIpfsSchema, vr as messages, vt as waitForUpdateInCommunityInstanceWithErrorAndTimeout, wt as listStartedCommunities, xt as findStartedCommunity, y as version_default, yr as logger_default, z as isAbortError } from "./schema-CdHApryH.js";
|
|
3
|
+
import { $ as RepliesPages, $n as t$5, $t as parseCommentEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, An as RpcCidParamSchema, At as verifyCommunityEdit, B as setNativeFunctions$1, Bn as RpcFetchCidResultSchema, Bt as getCommunityPublicKeyFromWire, Cn as parseRpcCommentEventWithPKCErrorIfItFails, Ct as verifyChallengeVerification, D as createKuboRpcClient, Dn as parseVotePubsubMessagePublicationSchemaWithPKCErrorIfItFails, Dt as verifyCommentPubsubMessage, Et as verifyCommentModeration, Fn as RpcExportCommunityModLogsParamSchema, Gn as RpcUnsubscribeParamSchema, H as CommentClientsManager, Hn as RpcResolveAuthorNameResultSchema, Ht as decode, I as listCommunitiesSync, In as RpcExportCommunityModLogsResultSchema, It as normalizeCreatePublicationAuthor, Kn as t$4, L as monitorCommunitiesDirectory, Ln as RpcExportCommunityParamSchema, Lt as buildRuntimeCommunityFields, Mn as RpcCommunityIdentifierParamSchema, Mt as buildRuntimeAuthor, N as getDefaultDataPath, Nn as RpcCommunityPageParamSchema, Nt as cleanWireAuthor, On as RpcAuthorNameParamSchema, Ot as verifyCommentUpdate, Pn as RpcEditCommunityParamSchema, Pt as getAuthorNameFromRuntime, Q as parseRawPages, Qn as t$2, Rn as RpcExportCommunityResultSchema, Rt as getCommunityAddressFromRecord, Sn as parsePKCUserOptionsSchemaWithPKCErrorIfItFails, Tn as parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, Tt as verifyCommentIpfs, Un as RpcSubscriptionIdResultSchema, V as tryToDeleteCommunitiesThatFailedToBeDeletedBefore, Vn as RpcPublishChallengeAnswersParamSchema, Vt as normalizeCommunityInputFromCommunity, Wn as RpcSuccessResultSchema, Wt as getBufferedPKCAddressFromPublicKey, X as findCommentInPageInstanceRecursively, Xn as n$3, Xt as parseCidStringSchemaWithPKCErrorIfItFails, Y as extractCommunityRuntimeFieldsFromParsedPages, Yn as t$3, _n as parseCreateVoteOptionsSchemaWithPKCErrorIfItFails, a as pkcJsChallenges, at as PKCTypedEmitter, bn as parseDecryptedChallengeWithPKCErrorIfItFails, c as AddressesRewriterProxyServer, ct as signChallengeAnswer, dn as parseCreateCommentOptionsSchemaWithPKCErrorIfItFails, en as parseCommentIpfsSchemaWithPKCErrorIfItFails, et as PublicationClientsManager, f as KeyvBetterSqlite3, fn as parseCreateCommunityEditPublicationOptionsSchemaWithPKCErrorIfItFails, ft as signComment, g as decodeRpcChallengeVerificationPubsubMsg, gn as parseCreateRpcCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, h as decodeRpcChallengeRequestPubsubMsg, hn as parseCreateRemoteCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, in as parseCommunityAddressWithPKCErrorIfItFails, ir as require_undici, jn as RpcCommentRepliesPageParamSchema, jt as verifyVote, kn as RpcCancelExportParamSchema, ln as parseCreateCommentEditOptionsSchemaWithPKCErrorIfItFails, m as decodeRpcChallengePubsubMsg, mt as signCommentModeration, n as RpcRemoteCommunity, nn as parseCommentModerationPubsubMessagePublicationSchemaWithPKCErrorIfItFails, nt as InflightFetchManager, o as TrackedInstanceRegistry, ot as require_lib$1, p as decodeRpcChallengeAnswerPubsubMsg, pt as signCommentEdit, rn as parseCommentPubsubMessagePublicationWithPKCErrorIfItFails, rr as nativeFunctions$2, s as LRUCache, sn as parseCommunityEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, st as cleanUpBeforePublishing, t as RpcLocalCommunity, tt as PKCClientsManager, u as RemoteCommunity, un as parseCreateCommentModerationOptionsSchemaWithPKCErrorIfItFails, ut as signChallengeRequest, v as createSigner, vn as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, vt as signCommunityEdit, wn as parseRpcCommentUpdateEventWithPKCErrorIfItFails, wt as verifyCommentEdit, x as encryptEd25519AesGcm, xn as parseJsonWithPKCErrorIfFails, xt as verifyChallengeMessage, y as decryptEd25519AesGcm, yn as parseDecryptedChallengeVerification, yt as signVote, zn as RpcFetchCidParamSchema, zt as getCommunityNameFromWire } from "./rpc-local-community-uFGcODiy.js";
|
|
4
|
+
import { i as getHeliaDebugContext } from "./util-D6lhOdvW.js";
|
|
5
5
|
import path from "path";
|
|
6
6
|
import assert from "assert";
|
|
7
7
|
import fs from "fs";
|
|
@@ -8875,7 +8875,7 @@ var PKC$1 = class extends PKCTypedEmitter {
|
|
|
8875
8875
|
this.clients.libp2pJsClients = {};
|
|
8876
8876
|
if (!this.libp2pJsClientsOptions) return;
|
|
8877
8877
|
if (!this.httpRoutersOptions) throw Error("httpRoutersOptions is required for libp2pJsClient");
|
|
8878
|
-
const { createLibp2pJsClientOrUseExistingOne } = await import("./helia-for-pkc-
|
|
8878
|
+
const { createLibp2pJsClientOrUseExistingOne } = await import("./helia-for-pkc-CkFh5nlx.js");
|
|
8879
8879
|
for (const clientOptions of this.libp2pJsClientsOptions) {
|
|
8880
8880
|
const heliaNode = await createLibp2pJsClientOrUseExistingOne({
|
|
8881
8881
|
...clientOptions,
|
|
@@ -9123,7 +9123,7 @@ var PKC$1 = class extends PKCTypedEmitter {
|
|
|
9123
9123
|
const log = logger_default("pkc-js:pkc:createLocalCommunity");
|
|
9124
9124
|
log.trace("Received community options to create a local community instance:", options);
|
|
9125
9125
|
if (!this._canCreateNewLocalCommunity()) throw new PKCError("ERR_CAN_NOT_CREATE_A_LOCAL_COMMUNITY", { pkcOptions: this._userPKCOptions });
|
|
9126
|
-
const { LocalCommunity, createNewLocalCommunityDb, updateInstancePropsWithStartedCommunityOrDb } = await import("./local-community-
|
|
9126
|
+
const { LocalCommunity, createNewLocalCommunityDb, updateInstancePropsWithStartedCommunityOrDb } = await import("./local-community-B66sHtZ1.js");
|
|
9127
9127
|
const isLocalCommunity = (await listCommunitiesSync(this)).includes(options.address);
|
|
9128
9128
|
const community = new LocalCommunity(this);
|
|
9129
9129
|
if (isLocalCommunity) {
|
package/dist/bundled/chunks/{rpc-local-community-DCOszS5C.js → rpc-local-community-uFGcODiy.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, $t as CommunityEditOptionsSchema, A as extractNetworkErrorDetails, An as CreateCommentOptionsWithRefinementSchema, Ar as record, At as trackStartedCommunity, B as isIpfsCid, Bn as CreateCommentEditOptionsWithRefinementSchema, Cr as _enum, Ct as findUpdatingCommunity, D as deepMergeRuntimeFields, Dn as CommentUpdateSignedPropertyNames, Dr as literal, E as createAbortError, En as CommentUpdateSchema, Er as custom, Et as listUpdatingCommunities, Ft as untrackUpdatingCommunity, Gn as CidPathSchema, Gt as CommentModerationPubsubMessagePublicationSchema, H as isIpns, Hn as AuthorCommentIpfsReservedFields, Ht as CommunityEditPubsubMessagePublicationSchema, I as getPostUpdateTimestampRange, In as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema, It as require_sha256$1, Jn as CommunityAuthorChallengeReservedFieldNames, Jt as CommentModerationsTableRowSchema, Kn as CidStringSchema, L as hideClassPrivateProps, Mn as ModQueuePageIpfsSchema, Mt as trackUpdatingCommunity, Nn as PageIpfsSchema, Nt as untrackStartedCommunity, O as derivePublicationFromChallengeRequest, Or as number, Ot as refreshTrackedCommunityAliases, Pn as CommentEditChallengeRequestToEncryptSchema, Q as isStringDomain, Qn as n$9, Qt as CommunityChallengeSettingSchema, R as ipnsNameToIpnsOverPubsubTopic, Rn as CommentEditSignedPropertyNames, Rt as pTimeout, Sn as CommentUpdateChallengeReservedFieldNames, St as findUpdatingComment, Tn as CommentUpdateReservedFields, Tr as boolean, U as isIpnsPath, Ut as CreateCommunityEditPublicationOptionsWithRefinementSchema, V as isIpfsPath, Vn as AuthorAddressSchema, Vt as CommunityEditPublicationSignedPropertyNames, Wn as ChallengeAnswersSchema, Wt as CommentModerationChallengeRequestToEncryptSchema, X as isRequestPubsubPublicationOfPost, Xn as n$10, Xt as ChallengeFileFactorySchema, Yn as CreateSignerSchema, Yt as CreateCommentModerationOptionsWithRefinementSchema, Z as isRequestPubsubPublicationOfReply, Zt as ChallengeFileSchema, _ as PKCUserOptionBaseSchema, _n as CommentIpfsReservedFields, _r as PKCError, _t as timestamp, an as CreateRemoteCommunityFunctionArgumentSchema, ar as t$12, b as areEquivalentCommunityAddresses, bn as CommentPubsubMessageWithFlexibleAuthorRefinementSchema, br as require_supports_color, c as ChallengeVerificationMessageSignedPropertyNames, cr as t$10, ct as resolveWhenPredicateIsTrue, dn as VoteChallengeRequestToEncryptSchema, dr as require_retry$1, en as CommunityExportRecordsSchema, er as t$13, f as DecryptedChallengeSchema, fn as VotePubsubMessagePublicationSchema, fr as FailedToFetchCommentIpfsFromGatewaysError, ft as shortifyAddress, g as PKCParsedOptionsSchema, gn as CommentChallengeRequestToEncryptSchema, gr as FailedToFetchPageIpfsFromGatewaysError, gt as throwIfAbortSignalAborted, h as NameResolverSerializedSchema, hr as FailedToFetchGenericIpfsFromGatewaysError, i as ChallengeMessageSignedPropertyNames, in as CreateNewLocalCommunityUserOptionsSchema, ir as r$8, it as removeNullUndefinedEmptyObjectsValuesRecursively, j as fetchAndValidateIpnsRecordFromGateway, jn as GetPageParamSchema, jr as string, k as doesDomainAddressHaveCapitalLetter, kr as object, l as DecryptedChallengeAnswerSchema, ln as RpcRemoteCommunityUpdateEventResultSchema, lr as t$9, m as NameResolveCacheOptionsSchema, mn as VoteSignedPropertyNames, mr as FailedToFetchCommunityFromGatewaysError, mt as sleepUntilTimeoutOrAbort, n as ChallengeAnswerMessageSignedPropertyNames, nn as CommunityIpfsSchema, nr as e$5, o as ChallengeRequestMessageSignedPropertyNames, on as CreateRpcCommunityFunctionArgumentSchema, or as n$8, p as DecryptedChallengeVerificationSchema, pr as FailedToFetchCommentUpdateFromGatewaysError, pt as shortifyCid, qn as CommunityAddressSchema, qt as CommentModerationSignedPropertyNames, rn as CommunitySignedPropertyNames, rr as t$11, sn as ExportCommunityModLogsOptionsSchema, sr as r$7, tn as CommunityIpfsReservedFields, tr as e$6, tt as raceAgainstAbort, un as CreateVoteUserOptionsWithRefinementSchema, ur as e$4, v as PKCUserOptionsSchema, vn as CommentIpfsSchema, vr as messages, vt as waitForUpdateInCommunityInstanceWithErrorAndTimeout, wn as CommentUpdateForChallengeVerificationSignedPropertyNames, wr as array, wt as listStartedCommunities, x as calculateIpfsCidV0, xn as CommentSignedPropertyNames, xr as require_ms$1, xt as findStartedCommunity, yr as logger_default, z as isAbortError, zt as CommunityEditPublicationChallengeRequestToEncryptSchema } from "./schema-
|
|
2
|
+
import { $ as pubsubTopicToDhtKey, $t as CommunityEditOptionsSchema, A as extractNetworkErrorDetails, An as CreateCommentOptionsWithRefinementSchema, Ar as record, At as trackStartedCommunity, B as isIpfsCid, Bn as CreateCommentEditOptionsWithRefinementSchema, Cr as _enum, Ct as findUpdatingCommunity, D as deepMergeRuntimeFields, Dn as CommentUpdateSignedPropertyNames, Dr as literal, E as createAbortError, En as CommentUpdateSchema, Er as custom, Et as listUpdatingCommunities, Ft as untrackUpdatingCommunity, Gn as CidPathSchema, Gt as CommentModerationPubsubMessagePublicationSchema, H as isIpns, Hn as AuthorCommentIpfsReservedFields, Ht as CommunityEditPubsubMessagePublicationSchema, I as getPostUpdateTimestampRange, In as CommentEditPubsubMessagePublicationWithFlexibleAuthorSchema, It as require_sha256$1, Jn as CommunityAuthorChallengeReservedFieldNames, Jt as CommentModerationsTableRowSchema, Kn as CidStringSchema, L as hideClassPrivateProps, Mn as ModQueuePageIpfsSchema, Mt as trackUpdatingCommunity, Nn as PageIpfsSchema, Nt as untrackStartedCommunity, O as derivePublicationFromChallengeRequest, Or as number, Ot as refreshTrackedCommunityAliases, Pn as CommentEditChallengeRequestToEncryptSchema, Q as isStringDomain, Qn as n$9, Qt as CommunityChallengeSettingSchema, R as ipnsNameToIpnsOverPubsubTopic, Rn as CommentEditSignedPropertyNames, Rt as pTimeout, Sn as CommentUpdateChallengeReservedFieldNames, St as findUpdatingComment, Tn as CommentUpdateReservedFields, Tr as boolean, U as isIpnsPath, Ut as CreateCommunityEditPublicationOptionsWithRefinementSchema, V as isIpfsPath, Vn as AuthorAddressSchema, Vt as CommunityEditPublicationSignedPropertyNames, Wn as ChallengeAnswersSchema, Wt as CommentModerationChallengeRequestToEncryptSchema, X as isRequestPubsubPublicationOfPost, Xn as n$10, Xt as ChallengeFileFactorySchema, Yn as CreateSignerSchema, Yt as CreateCommentModerationOptionsWithRefinementSchema, Z as isRequestPubsubPublicationOfReply, Zt as ChallengeFileSchema, _ as PKCUserOptionBaseSchema, _n as CommentIpfsReservedFields, _r as PKCError, _t as timestamp, an as CreateRemoteCommunityFunctionArgumentSchema, ar as t$12, b as areEquivalentCommunityAddresses, bn as CommentPubsubMessageWithFlexibleAuthorRefinementSchema, br as require_supports_color, c as ChallengeVerificationMessageSignedPropertyNames, cr as t$10, ct as resolveWhenPredicateIsTrue, dn as VoteChallengeRequestToEncryptSchema, dr as require_retry$1, en as CommunityExportRecordsSchema, er as t$13, f as DecryptedChallengeSchema, fn as VotePubsubMessagePublicationSchema, fr as FailedToFetchCommentIpfsFromGatewaysError, ft as shortifyAddress, g as PKCParsedOptionsSchema, gn as CommentChallengeRequestToEncryptSchema, gr as FailedToFetchPageIpfsFromGatewaysError, gt as throwIfAbortSignalAborted, h as NameResolverSerializedSchema, hr as FailedToFetchGenericIpfsFromGatewaysError, i as ChallengeMessageSignedPropertyNames, in as CreateNewLocalCommunityUserOptionsSchema, ir as r$8, it as removeNullUndefinedEmptyObjectsValuesRecursively, j as fetchAndValidateIpnsRecordFromGateway, jn as GetPageParamSchema, jr as string, k as doesDomainAddressHaveCapitalLetter, kr as object, l as DecryptedChallengeAnswerSchema, ln as RpcRemoteCommunityUpdateEventResultSchema, lr as t$9, m as NameResolveCacheOptionsSchema, mn as VoteSignedPropertyNames, mr as FailedToFetchCommunityFromGatewaysError, mt as sleepUntilTimeoutOrAbort, n as ChallengeAnswerMessageSignedPropertyNames, nn as CommunityIpfsSchema, nr as e$5, o as ChallengeRequestMessageSignedPropertyNames, on as CreateRpcCommunityFunctionArgumentSchema, or as n$8, p as DecryptedChallengeVerificationSchema, pr as FailedToFetchCommentUpdateFromGatewaysError, pt as shortifyCid, qn as CommunityAddressSchema, qt as CommentModerationSignedPropertyNames, rn as CommunitySignedPropertyNames, rr as t$11, sn as ExportCommunityModLogsOptionsSchema, sr as r$7, tn as CommunityIpfsReservedFields, tr as e$6, tt as raceAgainstAbort, un as CreateVoteUserOptionsWithRefinementSchema, ur as e$4, v as PKCUserOptionsSchema, vn as CommentIpfsSchema, vr as messages, vt as waitForUpdateInCommunityInstanceWithErrorAndTimeout, wn as CommentUpdateForChallengeVerificationSignedPropertyNames, wr as array, wt as listStartedCommunities, x as calculateIpfsCidV0, xn as CommentSignedPropertyNames, xr as require_ms$1, xt as findStartedCommunity, yr as logger_default, z as isAbortError, zt as CommunityEditPublicationChallengeRequestToEncryptSchema } from "./schema-CdHApryH.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 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";
|
|
@@ -101592,14 +101592,14 @@ var CommentClientsManager = class extends PublicationClientsManager {
|
|
|
101592
101592
|
};
|
|
101593
101593
|
//#endregion
|
|
101594
101594
|
//#region dist/node/runtime/node/util.js
|
|
101595
|
-
const getDefaultDataPath = () => path.join(process.cwd(), ".pkc");
|
|
101595
|
+
const getDefaultDataPath = () => path$1.join(process.cwd(), ".pkc");
|
|
101596
101596
|
const getDefaultCommunityDbConfig = async (communityAddress, pkc) => {
|
|
101597
101597
|
let filename;
|
|
101598
101598
|
if (pkc.noData) filename = ":memory:";
|
|
101599
101599
|
else {
|
|
101600
101600
|
assert(typeof pkc.dataPath === "string", "pkc.dataPath need to be defined to get default community db config");
|
|
101601
|
-
filename = path.join(pkc.dataPath, "communities", communityAddress);
|
|
101602
|
-
await promises.mkdir(path.dirname(filename), { recursive: true });
|
|
101601
|
+
filename = path$1.join(pkc.dataPath, "communities", communityAddress);
|
|
101602
|
+
await promises.mkdir(path$1.dirname(filename), { recursive: true });
|
|
101603
101603
|
}
|
|
101604
101604
|
return {
|
|
101605
101605
|
filename,
|
|
@@ -101698,7 +101698,7 @@ const setNativeFunctions = (newNativeFunctions) => {
|
|
|
101698
101698
|
};
|
|
101699
101699
|
const deleteOldCommunityInWindows = async (subPath, pkc) => {
|
|
101700
101700
|
const log = logger_default("pkc-js:community:deleteStaleCommunityInWindows");
|
|
101701
|
-
const communityAddress = path.basename(subPath);
|
|
101701
|
+
const communityAddress = path$1.basename(subPath);
|
|
101702
101702
|
await new Promise((resolve) => setTimeout(resolve, 1e4));
|
|
101703
101703
|
try {
|
|
101704
101704
|
await promises.rm(subPath, { force: true });
|
|
@@ -101722,7 +101722,7 @@ async function tryToDeleteCommunitiesThatFailedToBeDeletedBefore(pkc, log) {
|
|
|
101722
101722
|
}
|
|
101723
101723
|
const communitiesThatWereDeletedSuccessfully = [];
|
|
101724
101724
|
for (const communityAddress of deletedPersistentCommunities) {
|
|
101725
|
-
const communityPath = path.join(pkc.dataPath, "communities", communityAddress);
|
|
101725
|
+
const communityPath = path$1.join(pkc.dataPath, "communities", communityAddress);
|
|
101726
101726
|
try {
|
|
101727
101727
|
await promises.rm(communityPath, { force: true });
|
|
101728
101728
|
log(`Succeeded in deleting old db path (${communityAddress})`);
|
|
@@ -101746,7 +101746,7 @@ async function tryToDeleteCommunitiesThatFailedToBeDeletedBefore(pkc, log) {
|
|
|
101746
101746
|
function listCommunitiesSync(pkc) {
|
|
101747
101747
|
logger_default("pkc-js:listCommunitiesSync");
|
|
101748
101748
|
if (typeof pkc.dataPath !== "string") throw Error("pkc.dataPath needs to be defined to listCommunities");
|
|
101749
|
-
const communitiesPath = path.join(pkc.dataPath, "communities");
|
|
101749
|
+
const communitiesPath = path$1.join(pkc.dataPath, "communities");
|
|
101750
101750
|
const files = readdirSync(communitiesPath, {
|
|
101751
101751
|
recursive: false,
|
|
101752
101752
|
withFileTypes: false
|
|
@@ -101754,7 +101754,7 @@ function listCommunitiesSync(pkc) {
|
|
|
101754
101754
|
const communityFilesWeDontNeedToCheck = pkc.communities ? files.filter((address) => pkc.communities.includes(address)) : [];
|
|
101755
101755
|
const sqliteFiles = files.filter((address) => !communityFilesWeDontNeedToCheck.includes(address)).filter((address) => {
|
|
101756
101756
|
try {
|
|
101757
|
-
const filePath = path.join(communitiesPath, address);
|
|
101757
|
+
const filePath = path$1.join(communitiesPath, address);
|
|
101758
101758
|
if (!existsSync(filePath)) return false;
|
|
101759
101759
|
const fd = openSync(filePath, "r");
|
|
101760
101760
|
const buffer = Buffer.alloc(16);
|
|
@@ -101835,7 +101835,7 @@ var BackupAbortError = class extends Error {
|
|
|
101835
101835
|
async function backupCommunityDb(opts) {
|
|
101836
101836
|
const { sourcePath, destPath, includePrivateKey, onProgress, signal } = opts;
|
|
101837
101837
|
if (signal?.aborted) throw new BackupAbortError();
|
|
101838
|
-
await promises.mkdir(path.dirname(destPath), { recursive: true });
|
|
101838
|
+
await promises.mkdir(path$1.dirname(destPath), { recursive: true });
|
|
101839
101839
|
const partialPath = destPath + ".partial";
|
|
101840
101840
|
try {
|
|
101841
101841
|
await promises.unlink(partialPath);
|
|
@@ -101919,9 +101919,9 @@ async function statAndHashFile(filePath) {
|
|
|
101919
101919
|
}
|
|
101920
101920
|
async function moveCommunityDbToDeletedDirectory(communityAddress, pkc) {
|
|
101921
101921
|
if (typeof pkc.dataPath !== "string") throw Error("pkc.dataPath is not defined");
|
|
101922
|
-
const oldPath = path.join(pkc.dataPath, "communities", communityAddress);
|
|
101923
|
-
const newPath = path.join(pkc.dataPath, "communities", "deleted", communityAddress);
|
|
101924
|
-
await promises.mkdir(path.join(pkc.dataPath, "communities", "deleted"), { recursive: true });
|
|
101922
|
+
const oldPath = path$1.join(pkc.dataPath, "communities", communityAddress);
|
|
101923
|
+
const newPath = path$1.join(pkc.dataPath, "communities", "deleted", communityAddress);
|
|
101924
|
+
await promises.mkdir(path$1.join(pkc.dataPath, "communities", "deleted"), { recursive: true });
|
|
101925
101925
|
if (!existsSync(oldPath)) throw Error(`Source database ${oldPath} does not exist`);
|
|
101926
101926
|
try {
|
|
101927
101927
|
const sourceDb = new Database(oldPath, { fileMustExist: true });
|
|
@@ -101957,7 +101957,7 @@ async function createKuboRpcClient(kuboRpcClientOptions) {
|
|
|
101957
101957
|
}
|
|
101958
101958
|
async function monitorCommunitiesDirectory(pkc) {
|
|
101959
101959
|
const watchAbortController = new AbortController();
|
|
101960
|
-
const communitiesPath = path.join(pkc.dataPath, "communities");
|
|
101960
|
+
const communitiesPath = path$1.join(pkc.dataPath, "communities");
|
|
101961
101961
|
await promises.mkdir(communitiesPath, { recursive: true });
|
|
101962
101962
|
const extensionsToIgnore = [
|
|
101963
101963
|
".lock",
|
|
@@ -125857,11 +125857,11 @@ var AddressRewriterDatabase = class {
|
|
|
125857
125857
|
if (kuboConfig && typeof kuboConfig === "object" && "host" in kuboConfig && "port" in kuboConfig) kuboIdentifier = `${kuboConfig.host}_${kuboConfig.port}`;
|
|
125858
125858
|
const proxyIdentifier = `${proxyTarget.hostname}_${proxyTarget.port || (proxyTarget.protocol === "https:" ? "443" : "80")}`;
|
|
125859
125859
|
const fileName = `address_rewriter_${kuboIdentifier}_${proxyIdentifier}.db`;
|
|
125860
|
-
return
|
|
125860
|
+
return path.join(dataPath, ".address-rewriter", fileName);
|
|
125861
125861
|
}
|
|
125862
125862
|
async initialize() {
|
|
125863
125863
|
try {
|
|
125864
|
-
const dbDir =
|
|
125864
|
+
const dbDir = path.dirname(this._dbPath);
|
|
125865
125865
|
await fsp.mkdir(dbDir, { recursive: true });
|
|
125866
125866
|
this._db = new Database(this._dbPath);
|
|
125867
125867
|
this._db.exec(`
|
|
@@ -15994,7 +15994,7 @@ async function fetchAndValidateIpnsRecordFromGateway(gatewayUrl, ipnsName, opts)
|
|
|
15994
15994
|
const textEncoder = new TextEncoder();
|
|
15995
15995
|
async function calculateStringSizeSameAsIpfsAddCidV0(content) {
|
|
15996
15996
|
const { MemoryBlockstore } = await import("blockstore-core");
|
|
15997
|
-
const { importFile } = await import("./src-
|
|
15997
|
+
const { importFile } = await import("./src-o_MYSn-E.js");
|
|
15998
15998
|
const blockstore = new MemoryBlockstore();
|
|
15999
15999
|
const entry = await importFile({
|
|
16000
16000
|
path: "content.json",
|
|
@@ -16032,7 +16032,7 @@ function extractNetworkErrorDetails(err, depth = 0) {
|
|
|
16032
16032
|
}
|
|
16033
16033
|
//#endregion
|
|
16034
16034
|
//#region dist/node/generated-version.js
|
|
16035
|
-
const version = "0.0.
|
|
16035
|
+
const version = "0.0.70";
|
|
16036
16036
|
//#endregion
|
|
16037
16037
|
//#region dist/node/version.js
|
|
16038
16038
|
const protocolVersion = ProtocolVersionSchema.parse("1.0.0");
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { _r as PKCError, et as pubsubTopicToDhtKeyCid } from "./schema-
|
|
1
|
+
import { _r as PKCError, et as pubsubTopicToDhtKeyCid } from "./schema-CdHApryH.js";
|
|
2
|
+
import { ipnsSelector } from "ipns/selector";
|
|
3
|
+
import { equals } from "uint8arrays/equals";
|
|
2
4
|
//#region dist/node/helia/util.js
|
|
3
5
|
const TOPIC_SUBSCRIBER_WAIT_TIMEOUT_MS = 1e4;
|
|
4
6
|
const MESH_PEER_WAIT_TIMEOUT_MS = 3e3;
|
|
@@ -16,6 +18,48 @@ function getHeliaDebugContext(helia) {
|
|
|
16
18
|
}))
|
|
17
19
|
};
|
|
18
20
|
}
|
|
21
|
+
const DIAL_ERROR_NAMES_RETRYABLE_AFTER_ADDR_MERGE = new Set(["DialDeniedError", "NoValidAddressesError"]);
|
|
22
|
+
function isDialRetryableAfterAddrMerge(error) {
|
|
23
|
+
return DIAL_ERROR_NAMES_RETRYABLE_AFTER_ADDR_MERGE.has(error?.name);
|
|
24
|
+
}
|
|
25
|
+
function multiaddrIsCircuitRelay(addr) {
|
|
26
|
+
return addr.getComponents().some((component) => component.name === "p2p-circuit");
|
|
27
|
+
}
|
|
28
|
+
function createAddrMergeRetryScheduler({ helia, runRetry }) {
|
|
29
|
+
const retryablePeers = /* @__PURE__ */ new Map();
|
|
30
|
+
const inFlightOrDone = /* @__PURE__ */ new Set();
|
|
31
|
+
const retryTasks = [];
|
|
32
|
+
let providerStreamEnded = false;
|
|
33
|
+
let listenerRemoved = false;
|
|
34
|
+
const trigger = (peerId) => {
|
|
35
|
+
const key = peerId.toString();
|
|
36
|
+
if (inFlightOrDone.has(key)) return;
|
|
37
|
+
inFlightOrDone.add(key);
|
|
38
|
+
retryTasks.push(runRetry(peerId).then((outcome) => {
|
|
39
|
+
if (outcome === "not-ready") inFlightOrDone.delete(key);
|
|
40
|
+
}, () => void 0));
|
|
41
|
+
};
|
|
42
|
+
const onPeerUpdate = (evt) => {
|
|
43
|
+
const peerId = evt.detail.peer.id;
|
|
44
|
+
if (retryablePeers.has(peerId.toString())) trigger(peerId);
|
|
45
|
+
};
|
|
46
|
+
helia.libp2p.addEventListener("peer:update", onPeerUpdate);
|
|
47
|
+
return {
|
|
48
|
+
markRetryable(peerId) {
|
|
49
|
+
retryablePeers.set(peerId.toString(), peerId);
|
|
50
|
+
if (providerStreamEnded) trigger(peerId);
|
|
51
|
+
},
|
|
52
|
+
onProviderStreamEnded() {
|
|
53
|
+
providerStreamEnded = true;
|
|
54
|
+
for (const peerId of retryablePeers.values()) trigger(peerId);
|
|
55
|
+
if (!listenerRemoved) {
|
|
56
|
+
listenerRemoved = true;
|
|
57
|
+
helia.libp2p.removeEventListener("peer:update", onPeerUpdate);
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
retryTasks
|
|
61
|
+
};
|
|
62
|
+
}
|
|
19
63
|
function waitForTopicSubscriber({ helia, topic, timeoutMs, abortSignal }) {
|
|
20
64
|
const pubsub = helia.libp2p.services.pubsub;
|
|
21
65
|
if (pubsub.getSubscribers(topic).length > 0) return Promise.resolve();
|
|
@@ -116,6 +160,21 @@ async function connectToPubsubPeers({ helia, pubsubTopic, maxPeers, options, log
|
|
|
116
160
|
const findProvidersStart = Date.now();
|
|
117
161
|
const inflightDialPromises = [];
|
|
118
162
|
const dialOptions = { ...options };
|
|
163
|
+
const retryScheduler = createAddrMergeRetryScheduler({
|
|
164
|
+
helia,
|
|
165
|
+
runRetry: async (peerId) => {
|
|
166
|
+
if (options?.signal?.aborted) return "done";
|
|
167
|
+
try {
|
|
168
|
+
const conn = await helia.libp2p.dial(peerId, dialOptions);
|
|
169
|
+
connectedPeersWithContent.push(conn);
|
|
170
|
+
log.trace("Addr-merge retry dial connected to peer", peerId.toString());
|
|
171
|
+
return "done";
|
|
172
|
+
} catch (e) {
|
|
173
|
+
log.trace("Addr-merge retry dial failed for peer", peerId.toString(), "due to error", e);
|
|
174
|
+
return isDialRetryableAfterAddrMerge(e) ? "not-ready" : "done";
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
});
|
|
119
178
|
try {
|
|
120
179
|
for await (const peer of helia.libp2p.contentRouting.findProviders(contentCid, {
|
|
121
180
|
...options,
|
|
@@ -133,6 +192,7 @@ async function connectToPubsubPeers({ helia, pubsubTopic, maxPeers, options, log
|
|
|
133
192
|
}
|
|
134
193
|
} catch (e) {
|
|
135
194
|
const err = e;
|
|
195
|
+
if (isDialRetryableAfterAddrMerge(err)) retryScheduler.markRetryable(peer.id);
|
|
136
196
|
peerDialToError[peer.id.toString()] = {
|
|
137
197
|
multiaddrs: peer.multiaddrs.map(String),
|
|
138
198
|
errorName: err.name,
|
|
@@ -164,6 +224,8 @@ async function connectToPubsubPeers({ helia, pubsubTopic, maxPeers, options, log
|
|
|
164
224
|
throw e;
|
|
165
225
|
}
|
|
166
226
|
}
|
|
227
|
+
retryScheduler.onProviderStreamEnded();
|
|
228
|
+
inflightDialPromises.push(...retryScheduler.retryTasks);
|
|
167
229
|
let graftError = null;
|
|
168
230
|
try {
|
|
169
231
|
await subscriberAppearedPromise;
|
|
@@ -276,6 +338,26 @@ async function directFetchIpnsRecordFromProviders({ helia, pubsubTopic, routingK
|
|
|
276
338
|
resultController.signal
|
|
277
339
|
]) : AbortSignal.any([findProvidersAbort.signal, resultController.signal]);
|
|
278
340
|
const dialFetchTasks = [];
|
|
341
|
+
const retryScheduler = createAddrMergeRetryScheduler({
|
|
342
|
+
helia,
|
|
343
|
+
runRetry: async (peerId) => {
|
|
344
|
+
if (winner || resultController.signal.aborted || options?.signal?.aborted) return "done";
|
|
345
|
+
const directAddrs = ((await helia.libp2p.peerStore.get(peerId).catch(() => void 0))?.addresses ?? []).map(({ multiaddr }) => multiaddr).filter((addr) => !multiaddrIsCircuitRelay(addr));
|
|
346
|
+
if (directAddrs.length === 0 || !await helia.libp2p.isDialable(directAddrs)) return "not-ready";
|
|
347
|
+
try {
|
|
348
|
+
const dialSignal = options?.signal ? AbortSignal.any([options.signal, resultController.signal]) : resultController.signal;
|
|
349
|
+
const dialTargets = directAddrs.map((addr) => {
|
|
350
|
+
const components = addr.getComponents();
|
|
351
|
+
return components[components.length - 1]?.name === "p2p" ? addr : addr.encapsulate(`/p2p/${peerId.toString()}`);
|
|
352
|
+
});
|
|
353
|
+
await helia.libp2p.dial(dialTargets, { signal: dialSignal });
|
|
354
|
+
await tryFetchFromPeer(peerId, "provider");
|
|
355
|
+
} catch (e) {
|
|
356
|
+
recordErr(peerId, e);
|
|
357
|
+
}
|
|
358
|
+
return "done";
|
|
359
|
+
}
|
|
360
|
+
});
|
|
279
361
|
let attempted = 0;
|
|
280
362
|
try {
|
|
281
363
|
for await (const peer of helia.libp2p.contentRouting.findProviders(contentCid, {
|
|
@@ -284,6 +366,12 @@ async function directFetchIpnsRecordFromProviders({ helia, pubsubTopic, routingK
|
|
|
284
366
|
})) {
|
|
285
367
|
if (resultController.signal.aborted) break;
|
|
286
368
|
const announcedAddrs = peer.multiaddrs ?? [];
|
|
369
|
+
if (announcedAddrs.length > 0 && announcedAddrs.every(multiaddrIsCircuitRelay)) {
|
|
370
|
+
await helia.libp2p.peerStore.merge(peer.id, { multiaddrs: announcedAddrs }).catch(() => void 0);
|
|
371
|
+
log.trace("Skipping dial to circuit-only provider", peer.id.toString(), "for topic", pubsubTopic);
|
|
372
|
+
retryScheduler.markRetryable(peer.id);
|
|
373
|
+
continue;
|
|
374
|
+
}
|
|
287
375
|
const hasDialableAddr = announcedAddrs.length > 0 && await helia.libp2p.isDialable(announcedAddrs);
|
|
288
376
|
dialFetchTasks.push((async () => {
|
|
289
377
|
try {
|
|
@@ -292,6 +380,7 @@ async function directFetchIpnsRecordFromProviders({ helia, pubsubTopic, routingK
|
|
|
292
380
|
await helia.libp2p.dial(peer.id, { signal: dialSignal });
|
|
293
381
|
await tryFetchFromPeer(peer.id, "provider");
|
|
294
382
|
} catch (e) {
|
|
383
|
+
if (isDialRetryableAfterAddrMerge(e)) retryScheduler.markRetryable(peer.id);
|
|
295
384
|
recordErr(peer.id, e);
|
|
296
385
|
}
|
|
297
386
|
})());
|
|
@@ -303,7 +392,9 @@ async function directFetchIpnsRecordFromProviders({ helia, pubsubTopic, routingK
|
|
|
303
392
|
} catch (e) {
|
|
304
393
|
if (!findProvidersSignal.aborted) log.trace("findProviders errored during direct IPNS fetch for topic", pubsubTopic, e);
|
|
305
394
|
}
|
|
395
|
+
retryScheduler.onProviderStreamEnded();
|
|
306
396
|
await Promise.allSettled(dialFetchTasks);
|
|
397
|
+
while (retryScheduler.retryTasks.length > 0) await Promise.allSettled(retryScheduler.retryTasks.splice(0));
|
|
307
398
|
})();
|
|
308
399
|
await Promise.allSettled([...subscriberTasks, providerBranch]);
|
|
309
400
|
if (winner) {
|
|
@@ -316,5 +407,13 @@ async function directFetchIpnsRecordFromProviders({ helia, pubsubTopic, routingK
|
|
|
316
407
|
...getHeliaDebugContext(helia)
|
|
317
408
|
});
|
|
318
409
|
}
|
|
410
|
+
async function cacheIpnsRecordInPubsubLocalStore({ localStore, routingKey, marshalledRecord }) {
|
|
411
|
+
if (await localStore.has(routingKey)) {
|
|
412
|
+
const { record: currentRecord } = await localStore.get(routingKey);
|
|
413
|
+
if (equals(currentRecord, marshalledRecord)) return;
|
|
414
|
+
if (ipnsSelector(routingKey, [currentRecord, marshalledRecord]) === 0) return;
|
|
415
|
+
}
|
|
416
|
+
await localStore.put(routingKey, marshalledRecord);
|
|
417
|
+
}
|
|
319
418
|
//#endregion
|
|
320
|
-
export { selectBitswapSessionSeedPeers as i,
|
|
419
|
+
export { selectBitswapSessionSeedPeers as a, getHeliaDebugContext as i, connectToPubsubPeers as n, directFetchIpnsRecordFromProviders as r, cacheIpnsRecordInPubsubLocalStore as t };
|
package/dist/bundled/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as nativeFunctions, i as getShortCid, n as challenges, o as setNativeFunctions, r as getShortAddress, t as PKC } from "./chunks/node-
|
|
1
|
+
import { a as nativeFunctions, i as getShortCid, n as challenges, o as setNativeFunctions, r as getShortAddress, t as PKC } from "./chunks/node-C-uEWzwA.js";
|
|
2
2
|
export { challenges, PKC as default, getShortAddress, getShortCid, nativeFunctions, setNativeFunctions };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { L as hideClassPrivateProps, Qn as n, _r as PKCError, er as t, st as replaceXWithY, xt as findStartedCommunity, yr as logger_default } from "../../chunks/schema-
|
|
2
|
-
import { _ as parseRpcUnsubscribeParam, c as parseRpcCancelExportParam, d as parseRpcCommunityIdentifierParam, f as parseRpcCommunityPageParam, g as parseRpcPublishChallengeAnswersParam, h as parseRpcExportCommunityParam, l as parseRpcCidParam, m as parseRpcExportCommunityModLogsParam, p as parseRpcEditCommunityParam, s as parseRpcAuthorNameParam, t as PKC, u as parseRpcCommentRepliesPageParam } from "../../chunks/node-
|
|
3
|
-
import { En as parseVoteChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, J as buildPagesRuntimeFields, Qt as parseCommentEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, Tn as parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, Zt as parseCommentChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, an as parseCommunityEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, er as stringify, it as pLimit, mn as parseCreatePKCWsServerOptionsSchemaWithPKCErrorIfItFails, on as parseCommunityEditOptionsSchemaWithPKCErrorIfItFails, ot as require_lib, pn as parseCreateNewLocalCommunityUserOptionsSchemaWithPKCErrorIfItFails, q as buildPageRuntimeFields, qn as t$1, rt as pRetry, tn as parseCommentModerationChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, vn as parseDecryptedChallengeAnswerWithPKCErrorIfItFails } from "../../chunks/rpc-local-community-
|
|
4
|
-
import { t as LocalCommunity } from "../../chunks/local-community-
|
|
1
|
+
import { L as hideClassPrivateProps, Qn as n, _r as PKCError, er as t, st as replaceXWithY, xt as findStartedCommunity, yr as logger_default } from "../../chunks/schema-CdHApryH.js";
|
|
2
|
+
import { _ as parseRpcUnsubscribeParam, c as parseRpcCancelExportParam, d as parseRpcCommunityIdentifierParam, f as parseRpcCommunityPageParam, g as parseRpcPublishChallengeAnswersParam, h as parseRpcExportCommunityParam, l as parseRpcCidParam, m as parseRpcExportCommunityModLogsParam, p as parseRpcEditCommunityParam, s as parseRpcAuthorNameParam, t as PKC, u as parseRpcCommentRepliesPageParam } from "../../chunks/node-C-uEWzwA.js";
|
|
3
|
+
import { En as parseVoteChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, J as buildPagesRuntimeFields, Qt as parseCommentEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, Tn as parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, Zt as parseCommentChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, an as parseCommunityEditChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, er as stringify, it as pLimit, mn as parseCreatePKCWsServerOptionsSchemaWithPKCErrorIfItFails, on as parseCommunityEditOptionsSchemaWithPKCErrorIfItFails, ot as require_lib, pn as parseCreateNewLocalCommunityUserOptionsSchemaWithPKCErrorIfItFails, q as buildPageRuntimeFields, qn as t$1, rt as pRetry, tn as parseCommentModerationChallengeRequestToEncryptSchemaWithPKCErrorIfItFails, vn as parseDecryptedChallengeAnswerWithPKCErrorIfItFails } from "../../chunks/rpc-local-community-uFGcODiy.js";
|
|
4
|
+
import { t as LocalCommunity } from "../../chunks/local-community-DF2_ny4_.js";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
6
|
import path from "path";
|
|
7
7
|
import assert from "assert";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "0.0.
|
|
1
|
+
export declare const version = "0.0.70";
|