@pkcprotocol/pkc-js 0.0.56 → 0.0.58
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/errors.d.ts +1 -1
- package/dist/browser/errors.js +1 -1
- 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/runtime/node/community/local-community/lifecycle.js +10 -0
- package/dist/browser/runtime/node/community/local-community/lifecycle.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/publication-validation.js +8 -2
- package/dist/browser/runtime/node/community/local-community/publication-validation.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/pubsub.js +1 -1
- package/dist/browser/runtime/node/community/local-community/pubsub.js.map +1 -1
- package/dist/browser/runtime/node/community/local-community/reprovide-on-address-change.d.ts +60 -0
- package/dist/browser/runtime/node/community/local-community/reprovide-on-address-change.js +95 -0
- package/dist/browser/runtime/node/community/local-community/reprovide-on-address-change.js.map +1 -0
- package/dist/browser/runtime/node/community/local-community.d.ts +2 -0
- package/dist/browser/runtime/node/community/local-community.js +5 -0
- package/dist/browser/runtime/node/community/local-community.js.map +1 -1
- package/dist/bundled/bundle-manifest.json +39 -37
- package/dist/bundled/chunks/{helia-for-pkc-CcmiATPg.js → helia-for-pkc-Dy66yFBq.js} +2 -2
- package/dist/bundled/chunks/{local-community-DzFaedmf.js → local-community-CpqhUYOZ.js} +1 -1
- package/dist/bundled/chunks/{local-community-DdB4oPEw.js → local-community-D1BZqTaY.js} +92 -4
- package/dist/bundled/chunks/{node-DNJqRHLq.js → node-OomQx4kQ.js} +10 -533
- package/dist/bundled/chunks/{rpc-local-community-OVRYzYQ3.js → rpc-local-community-XVq4w0ZG.js} +563 -40
- package/dist/bundled/chunks/{schema-lNZ3-tdE.js → schema-C03N0i5R.js} +2 -2
- package/dist/bundled/chunks/{util-MtD9fpa8.js → util-DFDVE6vH.js} +1 -1
- package/dist/bundled/index.js +1 -1
- package/dist/bundled/rpc/src/index.js +4 -4
- package/dist/node/errors.d.ts +1 -1
- package/dist/node/errors.js +1 -1
- 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/runtime/node/community/local-community/lifecycle.js +10 -0
- package/dist/node/runtime/node/community/local-community/lifecycle.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/publication-validation.js +8 -2
- package/dist/node/runtime/node/community/local-community/publication-validation.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/pubsub.js +1 -1
- package/dist/node/runtime/node/community/local-community/pubsub.js.map +1 -1
- package/dist/node/runtime/node/community/local-community/reprovide-on-address-change.d.ts +60 -0
- package/dist/node/runtime/node/community/local-community/reprovide-on-address-change.js +95 -0
- package/dist/node/runtime/node/community/local-community/reprovide-on-address-change.js.map +1 -0
- package/dist/node/runtime/node/community/local-community.d.ts +2 -0
- package/dist/node/runtime/node/community/local-community.js +5 -0
- package/dist/node/runtime/node/community/local-community.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import { B as isIpfsCid, Cn as CommentUpdateForChallengeVerificationSchema, Cr as parsedType, Ct as findUpdatingCommunity, D as deepMergeRuntimeFields, Dr as __require, Dt as refreshTrackedCommentAliases, E as createAbortError, En as CommentUpdateSchema, Et as listUpdatingCommunities, It as require_sha256, L as hideClassPrivateProps, Lt as TimeoutError, Or as __toESM, Pt as untrackUpdatingComment, Q as isStringDomain, Qn as CID, Rt as pTimeout, Sr as joinValues, St as findUpdatingComment, Tr as __commonJSMin, Tt as listUpdatingComments, Xn as require_commonjs, Zn as require_retry, _t as timestamp, a as ChallengeRequestMessageSchema, b as areEquivalentCommunityAddresses, cn as PubsubTopicSchema, cr as logger_default, ct as resolveWhenPredicateIsTrue, dr as setErrorMap, ft as shortifyAddress, jt as trackUpdatingComment, k as doesDomainAddressHaveCapitalLetter, lr as require_supports_color, mt as sleepUntilTimeoutOrAbort, nn as CommunityIpfsSchema, or as PKCError, ot as removeUndefinedValuesRecursively, pt as shortifyCid, r as ChallengeMessageSchema, s as ChallengeVerificationMessageSchema, sr as messages, st as replaceXWithY, t as ChallengeAnswerMessageSchema, tr as FailedToFetchCommentIpfsFromGatewaysError, ut as retryKuboIpfsAdd, vn as CommentIpfsSchema, vt as waitForUpdateInCommunityInstanceWithErrorAndTimeout, wr as stringifyPrimitive, wt as listStartedCommunities, xt as findStartedCommunity, y as version_default, z as isAbortError } from "./schema-
|
|
2
|
-
import { $ as
|
|
3
|
-
import { n as getHeliaDebugContext } from "./util-
|
|
4
|
-
import
|
|
5
|
-
import fs from "node:fs/promises";
|
|
6
|
-
import path from "node:path";
|
|
7
|
-
import path$1 from "path";
|
|
1
|
+
import { B as isIpfsCid, Cn as CommentUpdateForChallengeVerificationSchema, Cr as parsedType, Ct as findUpdatingCommunity, D as deepMergeRuntimeFields, Dr as __require, Dt as refreshTrackedCommentAliases, E as createAbortError, En as CommentUpdateSchema, Et as listUpdatingCommunities, It as require_sha256, L as hideClassPrivateProps, Lt as TimeoutError, Or as __toESM, Pt as untrackUpdatingComment, Q as isStringDomain, Qn as CID, Rt as pTimeout, Sr as joinValues, St as findUpdatingComment, Tr as __commonJSMin, Tt as listUpdatingComments, Xn as require_commonjs, Zn as require_retry, _t as timestamp, a as ChallengeRequestMessageSchema, b as areEquivalentCommunityAddresses, cn as PubsubTopicSchema, cr as logger_default, ct as resolveWhenPredicateIsTrue, dr as setErrorMap, ft as shortifyAddress, jt as trackUpdatingComment, k as doesDomainAddressHaveCapitalLetter, lr as require_supports_color, mt as sleepUntilTimeoutOrAbort, nn as CommunityIpfsSchema, or as PKCError, ot as removeUndefinedValuesRecursively, pt as shortifyCid, r as ChallengeMessageSchema, s as ChallengeVerificationMessageSchema, sr as messages, st as replaceXWithY, t as ChallengeAnswerMessageSchema, tr as FailedToFetchCommentIpfsFromGatewaysError, ut as retryKuboIpfsAdd, vn as CommentIpfsSchema, vt as waitForUpdateInCommunityInstanceWithErrorAndTimeout, wr as stringifyPrimitive, wt as listStartedCommunities, xt as findStartedCommunity, y as version_default, z as isAbortError } from "./schema-C03N0i5R.js";
|
|
2
|
+
import { $ as RepliesPages, $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, 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, 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 require_undici, Xt as parseCidStringSchemaWithPKCErrorIfItFails, Y as extractCommunityRuntimeFieldsFromParsedPages, Yn as nativeFunctions$2, _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, 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, 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-XVq4w0ZG.js";
|
|
3
|
+
import { n as getHeliaDebugContext } from "./util-DFDVE6vH.js";
|
|
4
|
+
import path from "path";
|
|
8
5
|
import assert from "assert";
|
|
9
|
-
import fs
|
|
10
|
-
import https from "node:https";
|
|
6
|
+
import fs from "fs";
|
|
11
7
|
import Database from "better-sqlite3";
|
|
12
8
|
import { of } from "typestub-ipfs-only-hash";
|
|
13
9
|
import EventEmitter from "events";
|
|
@@ -2033,8 +2029,8 @@ var Storage = class {
|
|
|
2033
2029
|
let dbFilePath;
|
|
2034
2030
|
if (this._pkc.noData || !this._pkc.dataPath) dbFilePath = ":memory:";
|
|
2035
2031
|
else {
|
|
2036
|
-
fs
|
|
2037
|
-
dbFilePath = path
|
|
2032
|
+
fs.mkdirSync(this._pkc.dataPath, { recursive: true });
|
|
2033
|
+
dbFilePath = path.join(this._pkc.dataPath, "storage.db");
|
|
2038
2034
|
}
|
|
2039
2035
|
this._db = new Database(dbFilePath);
|
|
2040
2036
|
this._keyv = new KeyvBetterSqlite3(this._db);
|
|
@@ -6394,7 +6390,7 @@ var LRUStorage = class {
|
|
|
6394
6390
|
}
|
|
6395
6391
|
toJSON() {}
|
|
6396
6392
|
async init() {
|
|
6397
|
-
const dbPath = this._opts.pkc.noData || !this._opts.pkc.dataPath ? `:memory:` : path
|
|
6393
|
+
const dbPath = this._opts.pkc.noData || !this._opts.pkc.dataPath ? `:memory:` : path.join(this._opts.pkc.dataPath, "lru-storage");
|
|
6398
6394
|
this._cache = new SqliteCache({
|
|
6399
6395
|
database: dbPath,
|
|
6400
6396
|
cacheTableName: this._opts.cacheName,
|
|
@@ -6470,525 +6466,6 @@ var CommentModeration = class extends Publication {
|
|
|
6470
6466
|
}
|
|
6471
6467
|
};
|
|
6472
6468
|
//#endregion
|
|
6473
|
-
//#region dist/node/runtime/node/address-rewriter-db.js
|
|
6474
|
-
const debug$1 = logger_default("pkc-js:address-rewriter-db");
|
|
6475
|
-
var AddressRewriterDatabase = class {
|
|
6476
|
-
constructor(dataPath, kuboConfig, proxyTarget) {
|
|
6477
|
-
this._db = null;
|
|
6478
|
-
this._dbPath = this._initializeDbPath(dataPath, kuboConfig, proxyTarget);
|
|
6479
|
-
}
|
|
6480
|
-
_initializeDbPath(dataPath, kuboConfig, proxyTarget) {
|
|
6481
|
-
if (!dataPath) throw new Error("dataPath must be defined for request logging");
|
|
6482
|
-
let kuboIdentifier = "unknown";
|
|
6483
|
-
if (kuboConfig && typeof kuboConfig === "object" && "host" in kuboConfig && "port" in kuboConfig) kuboIdentifier = `${kuboConfig.host}_${kuboConfig.port}`;
|
|
6484
|
-
const proxyIdentifier = `${proxyTarget.hostname}_${proxyTarget.port || (proxyTarget.protocol === "https:" ? "443" : "80")}`;
|
|
6485
|
-
const fileName = `address_rewriter_${kuboIdentifier}_${proxyIdentifier}.db`;
|
|
6486
|
-
return path.join(dataPath, ".address-rewriter", fileName);
|
|
6487
|
-
}
|
|
6488
|
-
async initialize() {
|
|
6489
|
-
try {
|
|
6490
|
-
const dbDir = path.dirname(this._dbPath);
|
|
6491
|
-
await fs.mkdir(dbDir, { recursive: true });
|
|
6492
|
-
this._db = new Database(this._dbPath);
|
|
6493
|
-
this._db.exec(`
|
|
6494
|
-
CREATE TABLE IF NOT EXISTS request_logs (
|
|
6495
|
-
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
6496
|
-
keys TEXT NOT NULL,
|
|
6497
|
-
received_at INTEGER NOT NULL,
|
|
6498
|
-
transmitted_at INTEGER,
|
|
6499
|
-
success INTEGER NOT NULL,
|
|
6500
|
-
status_code INTEGER,
|
|
6501
|
-
method TEXT NOT NULL,
|
|
6502
|
-
url TEXT NOT NULL,
|
|
6503
|
-
error TEXT,
|
|
6504
|
-
retry_count INTEGER DEFAULT 0,
|
|
6505
|
-
body_preview TEXT,
|
|
6506
|
-
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
6507
|
-
)
|
|
6508
|
-
`);
|
|
6509
|
-
this._db.exec(`
|
|
6510
|
-
CREATE TABLE IF NOT EXISTS reprovide_logs (
|
|
6511
|
-
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
6512
|
-
key TEXT NOT NULL,
|
|
6513
|
-
timestamp INTEGER NOT NULL,
|
|
6514
|
-
success INTEGER NOT NULL,
|
|
6515
|
-
error TEXT,
|
|
6516
|
-
block_not_local INTEGER DEFAULT 0,
|
|
6517
|
-
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
6518
|
-
)
|
|
6519
|
-
`);
|
|
6520
|
-
this._db.exec(`
|
|
6521
|
-
CREATE TABLE IF NOT EXISTS failed_keys (
|
|
6522
|
-
key TEXT PRIMARY KEY,
|
|
6523
|
-
added_at INTEGER NOT NULL,
|
|
6524
|
-
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
6525
|
-
)
|
|
6526
|
-
`);
|
|
6527
|
-
this._db.exec(`
|
|
6528
|
-
CREATE INDEX IF NOT EXISTS idx_request_logs_received_at ON request_logs(received_at);
|
|
6529
|
-
CREATE INDEX IF NOT EXISTS idx_reprovide_logs_timestamp ON reprovide_logs(timestamp);
|
|
6530
|
-
CREATE INDEX IF NOT EXISTS idx_reprovide_logs_key ON reprovide_logs(key);
|
|
6531
|
-
`);
|
|
6532
|
-
try {
|
|
6533
|
-
this._db.exec("ALTER TABLE request_logs ADD COLUMN body_preview TEXT");
|
|
6534
|
-
} catch (error) {
|
|
6535
|
-
if (!(error instanceof Error ? error.message : String(error)).toLowerCase().includes("duplicate column name")) throw error;
|
|
6536
|
-
}
|
|
6537
|
-
debug$1(`Initialized SQLite database at ${this._dbPath}`);
|
|
6538
|
-
} catch (error) {
|
|
6539
|
-
debug$1.error(`Failed to initialize database at ${this._dbPath}:`, error);
|
|
6540
|
-
throw error;
|
|
6541
|
-
}
|
|
6542
|
-
}
|
|
6543
|
-
close() {
|
|
6544
|
-
if (this._db) {
|
|
6545
|
-
this._db.close();
|
|
6546
|
-
this._db = null;
|
|
6547
|
-
}
|
|
6548
|
-
}
|
|
6549
|
-
insertRequestLogs(logs) {
|
|
6550
|
-
if (!this._db) throw new Error("Database not initialized");
|
|
6551
|
-
const insertStmt = this._db.prepare(`
|
|
6552
|
-
INSERT INTO request_logs (
|
|
6553
|
-
keys, received_at, transmitted_at, success, status_code,
|
|
6554
|
-
method, url, error, retry_count, body_preview
|
|
6555
|
-
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
6556
|
-
`);
|
|
6557
|
-
this._db.transaction(() => {
|
|
6558
|
-
for (const log of logs) insertStmt.run(JSON.stringify(log.keys), log.receivedAt, log.transmittedAt || null, log.success ? 1 : 0, log.statusCode || null, log.method, log.url, log.error || null, log.retryCount || 0, log.bodyPreview || null);
|
|
6559
|
-
})();
|
|
6560
|
-
}
|
|
6561
|
-
insertReprovideLog(key, success, error, blockNotLocal) {
|
|
6562
|
-
if (!this._db) throw new Error("Database not initialized");
|
|
6563
|
-
this._db.prepare(`
|
|
6564
|
-
INSERT INTO reprovide_logs (key, timestamp, success, error, block_not_local)
|
|
6565
|
-
VALUES (?, ?, ?, ?, ?)
|
|
6566
|
-
`).run(key, Date.now(), success ? 1 : 0, error || null, blockNotLocal ? 1 : 0);
|
|
6567
|
-
}
|
|
6568
|
-
loadFailedKeys() {
|
|
6569
|
-
if (!this._db) return [];
|
|
6570
|
-
try {
|
|
6571
|
-
return this._db.prepare("SELECT key FROM failed_keys").all().map((row) => row.key);
|
|
6572
|
-
} catch (error) {
|
|
6573
|
-
debug$1.error("Failed to load failed keys from database:", error);
|
|
6574
|
-
return [];
|
|
6575
|
-
}
|
|
6576
|
-
}
|
|
6577
|
-
saveFailedKeys(keys) {
|
|
6578
|
-
if (!this._db) throw new Error("Database not initialized");
|
|
6579
|
-
this._db.transaction(() => {
|
|
6580
|
-
this._db.exec("DELETE FROM failed_keys");
|
|
6581
|
-
if (keys.length > 0) {
|
|
6582
|
-
const insertStmt = this._db.prepare("INSERT INTO failed_keys (key, added_at) VALUES (?, ?)");
|
|
6583
|
-
const now = Date.now();
|
|
6584
|
-
for (const key of keys) insertStmt.run(key, now);
|
|
6585
|
-
}
|
|
6586
|
-
})();
|
|
6587
|
-
}
|
|
6588
|
-
};
|
|
6589
|
-
//#endregion
|
|
6590
|
-
//#region dist/node/runtime/node/addresses-rewriter-proxy-server.js
|
|
6591
|
-
const debug = logger_default("pkc-js:addresses-rewriter");
|
|
6592
|
-
const MAX_BODY_PREVIEW_BYTES = 4096;
|
|
6593
|
-
function normalizeSelfAddrsForProvider(addrs, peerId) {
|
|
6594
|
-
const suffix = `/p2p/${peerId}`;
|
|
6595
|
-
return import_commonjs.unique(addrs.map((addr) => addr.endsWith(suffix) ? addr.slice(0, -suffix.length) : addr));
|
|
6596
|
-
}
|
|
6597
|
-
var AddressesRewriterProxyServer = class {
|
|
6598
|
-
constructor({ kuboClients: kuboClient, port, hostname, proxyTargetUrl, pkc }) {
|
|
6599
|
-
this._requestLogBuffer = [];
|
|
6600
|
-
this._isWritingLogs = false;
|
|
6601
|
-
this._failedKeys = /* @__PURE__ */ new Set();
|
|
6602
|
-
this._isRetrying = false;
|
|
6603
|
-
this.addresses = {};
|
|
6604
|
-
this.kuboClients = kuboClient;
|
|
6605
|
-
this.port = port;
|
|
6606
|
-
this.hostname = hostname || "127.0.0.1";
|
|
6607
|
-
this.proxyTarget = new URL(proxyTargetUrl);
|
|
6608
|
-
this.server = http.createServer((req, res) => this._proxyRequestRewrite(req, res));
|
|
6609
|
-
this._storageKeyName = `httprouter_proxy_${proxyTargetUrl}`;
|
|
6610
|
-
this._pkc = pkc;
|
|
6611
|
-
const envValue = process.env.ENABLE_LOGGING_OF_ADDRESS_REWRITER_PROXY;
|
|
6612
|
-
this._loggingEnabled = envValue === "1" || envValue?.toLowerCase() === "true";
|
|
6613
|
-
if (this._loggingEnabled) {
|
|
6614
|
-
const kuboConfig = this.kuboClients?.[0]?.getEndpointConfig();
|
|
6615
|
-
this._db = new AddressRewriterDatabase(this._pkc.dataPath, kuboConfig, this.proxyTarget);
|
|
6616
|
-
} else this._db = null;
|
|
6617
|
-
this._httpAgent = new http.Agent({
|
|
6618
|
-
keepAlive: true,
|
|
6619
|
-
keepAliveMsecs: 3e4,
|
|
6620
|
-
maxSockets: 50,
|
|
6621
|
-
timeout: 1e4
|
|
6622
|
-
});
|
|
6623
|
-
this._httpsAgent = new https.Agent({
|
|
6624
|
-
keepAlive: true,
|
|
6625
|
-
keepAliveMsecs: 3e4,
|
|
6626
|
-
maxSockets: 50,
|
|
6627
|
-
timeout: 1e4
|
|
6628
|
-
});
|
|
6629
|
-
hideClassPrivateProps(this);
|
|
6630
|
-
}
|
|
6631
|
-
async listen(callback) {
|
|
6632
|
-
if (this._loggingEnabled && this._db) {
|
|
6633
|
-
await this._db.initialize();
|
|
6634
|
-
debug("Request logging enabled for addresses rewriter proxy");
|
|
6635
|
-
} else debug("Request logging disabled for addresses rewriter proxy");
|
|
6636
|
-
await this._startUpdateAddressesLoop();
|
|
6637
|
-
if (this._loggingEnabled) this._startRequestLogging();
|
|
6638
|
-
await this._startFailedKeysRetry();
|
|
6639
|
-
this.server.on("error", (err) => debug.error("Error with address rewriter proxy", this.server.address(), "Proxy target", this.proxyTarget, err));
|
|
6640
|
-
this.server.listen(this.port, this.hostname, callback);
|
|
6641
|
-
debug("Addresses rewriter proxy at", this.hostname + ":" + this.port, "started listening to forward requests to", this.proxyTarget.host, `- request logging ${this._loggingEnabled ? "enabled" : "disabled"}`);
|
|
6642
|
-
await this._pkc._storage.setItem(this._storageKeyName, `http://${this.hostname}:${this.port}`);
|
|
6643
|
-
}
|
|
6644
|
-
async destroy() {
|
|
6645
|
-
this.server.close();
|
|
6646
|
-
if (this._updateAddressesInterval) clearInterval(this._updateAddressesInterval);
|
|
6647
|
-
if (this._logWriteInterval) clearInterval(this._logWriteInterval);
|
|
6648
|
-
if (this._retryInterval) clearInterval(this._retryInterval);
|
|
6649
|
-
await this._writeRequestLogs();
|
|
6650
|
-
this._db?.close();
|
|
6651
|
-
this._httpAgent.destroy();
|
|
6652
|
-
this._httpsAgent.destroy();
|
|
6653
|
-
await this._pkc._storage.removeItem(this._storageKeyName);
|
|
6654
|
-
}
|
|
6655
|
-
_proxyRequestRewrite(req, res) {
|
|
6656
|
-
let reqBody = "";
|
|
6657
|
-
req.on("data", (chunk) => {
|
|
6658
|
-
reqBody += chunk.toString();
|
|
6659
|
-
});
|
|
6660
|
-
req.on("end", () => {
|
|
6661
|
-
const shouldRewrite = req.method === "PUT" || req.method === "POST";
|
|
6662
|
-
let requestLogEntry = null;
|
|
6663
|
-
if (shouldRewrite) {
|
|
6664
|
-
const keys = this._extractKeysFromRequestBody(reqBody);
|
|
6665
|
-
const shouldLogRequest = this._loggingEnabled;
|
|
6666
|
-
if (keys.length > 0 || shouldLogRequest) {
|
|
6667
|
-
requestLogEntry = {
|
|
6668
|
-
keys,
|
|
6669
|
-
receivedAt: Date.now(),
|
|
6670
|
-
success: false,
|
|
6671
|
-
method: req.method || "UNKNOWN",
|
|
6672
|
-
url: req.url || "/",
|
|
6673
|
-
retryCount: 0,
|
|
6674
|
-
bodyPreview: shouldLogRequest ? this._createBodyPreview(reqBody) : void 0
|
|
6675
|
-
};
|
|
6676
|
-
if (shouldLogRequest) this._requestLogBuffer.push(requestLogEntry);
|
|
6677
|
-
}
|
|
6678
|
-
}
|
|
6679
|
-
let rewrittenBody = reqBody;
|
|
6680
|
-
if (shouldRewrite && rewrittenBody) try {
|
|
6681
|
-
const json = JSON.parse(rewrittenBody);
|
|
6682
|
-
if (json.Providers && Array.isArray(json.Providers)) {
|
|
6683
|
-
for (const provider of json.Providers) {
|
|
6684
|
-
const peerId = provider?.Payload?.ID;
|
|
6685
|
-
if (peerId && this.addresses[peerId]) provider.Payload.Addrs = this.addresses[peerId];
|
|
6686
|
-
}
|
|
6687
|
-
rewrittenBody = JSON.stringify(json);
|
|
6688
|
-
}
|
|
6689
|
-
} catch (e) {
|
|
6690
|
-
debug("proxy body rewrite error:", e, "body", rewrittenBody, req.url, req.method);
|
|
6691
|
-
}
|
|
6692
|
-
this._proxyRequest(req, res, rewrittenBody, requestLogEntry);
|
|
6693
|
-
});
|
|
6694
|
-
req.on("error", (err) => {
|
|
6695
|
-
debug.trace("Request error:", req.url, req.method, req.headers, reqBody, err);
|
|
6696
|
-
if (!res.headersSent) {
|
|
6697
|
-
debug.trace("Request error:", req.url, req.method, req.headers, reqBody, err);
|
|
6698
|
-
res.writeHead(500);
|
|
6699
|
-
res.end("Internal Server Error");
|
|
6700
|
-
}
|
|
6701
|
-
});
|
|
6702
|
-
}
|
|
6703
|
-
_proxyRequest(req, res, rewrittenBody, requestLogEntry) {
|
|
6704
|
-
if (requestLogEntry) {
|
|
6705
|
-
requestLogEntry.retryCount = 0;
|
|
6706
|
-
requestLogEntry.transmittedAt = Date.now();
|
|
6707
|
-
}
|
|
6708
|
-
const { request: httpRequest } = this.proxyTarget.protocol === "https:" ? https : http;
|
|
6709
|
-
const agent = this.proxyTarget.protocol === "https:" ? this._httpsAgent : this._httpAgent;
|
|
6710
|
-
const requestOptions = {
|
|
6711
|
-
hostname: this.proxyTarget.hostname,
|
|
6712
|
-
protocol: this.proxyTarget.protocol,
|
|
6713
|
-
path: req.url,
|
|
6714
|
-
method: req.method,
|
|
6715
|
-
headers: {
|
|
6716
|
-
...req.headers,
|
|
6717
|
-
"content-length": Buffer.byteLength(rewrittenBody),
|
|
6718
|
-
host: this.proxyTarget.host
|
|
6719
|
-
},
|
|
6720
|
-
agent,
|
|
6721
|
-
timeout: 1e4
|
|
6722
|
-
};
|
|
6723
|
-
if (this.proxyTarget.port) requestOptions.port = this.proxyTarget.port;
|
|
6724
|
-
const proxyReq = httpRequest(requestOptions);
|
|
6725
|
-
proxyReq.setTimeout(1e4, () => {
|
|
6726
|
-
debug.trace("Proxy request timed out", requestOptions);
|
|
6727
|
-
if (requestLogEntry) {
|
|
6728
|
-
requestLogEntry.success = false;
|
|
6729
|
-
requestLogEntry.statusCode = 504;
|
|
6730
|
-
requestLogEntry.error = "Request timeout";
|
|
6731
|
-
requestLogEntry.completed = true;
|
|
6732
|
-
if (requestLogEntry.keys) {
|
|
6733
|
-
const sizeBefore = this._failedKeys.size;
|
|
6734
|
-
requestLogEntry.keys.forEach((key) => this._failedKeys.add(key));
|
|
6735
|
-
if (this._failedKeys.size > sizeBefore) this._saveFailedKeysToDatabase();
|
|
6736
|
-
}
|
|
6737
|
-
}
|
|
6738
|
-
proxyReq.destroy();
|
|
6739
|
-
if (!res.headersSent) {
|
|
6740
|
-
res.writeHead(504);
|
|
6741
|
-
res.end("Gateway Timeout");
|
|
6742
|
-
}
|
|
6743
|
-
});
|
|
6744
|
-
proxyReq.on("error", (e) => {
|
|
6745
|
-
proxyReq.destroy();
|
|
6746
|
-
if (requestLogEntry) {
|
|
6747
|
-
requestLogEntry.success = false;
|
|
6748
|
-
requestLogEntry.statusCode = 500;
|
|
6749
|
-
requestLogEntry.error = `Proxy error: ${e.message}`;
|
|
6750
|
-
requestLogEntry.completed = true;
|
|
6751
|
-
debug.trace(`Updated log entry with error for keys: ${requestLogEntry.keys.join(", ")}`);
|
|
6752
|
-
if (requestLogEntry.keys) {
|
|
6753
|
-
const sizeBefore = this._failedKeys.size;
|
|
6754
|
-
requestLogEntry.keys.forEach((key) => this._failedKeys.add(key));
|
|
6755
|
-
if (this._failedKeys.size > sizeBefore) this._saveFailedKeysToDatabase();
|
|
6756
|
-
}
|
|
6757
|
-
}
|
|
6758
|
-
if (!res.headersSent) {
|
|
6759
|
-
debug.trace("address rewriter proxy error:", e, "Request options", requestOptions);
|
|
6760
|
-
res.writeHead(500);
|
|
6761
|
-
res.end("Internal Server Error");
|
|
6762
|
-
}
|
|
6763
|
-
});
|
|
6764
|
-
proxyReq.on("response", (proxyRes) => {
|
|
6765
|
-
const statusCode = proxyRes.statusCode || 500;
|
|
6766
|
-
const isSuccess = statusCode >= 200 && statusCode < 300;
|
|
6767
|
-
if (requestLogEntry) {
|
|
6768
|
-
requestLogEntry.success = isSuccess;
|
|
6769
|
-
requestLogEntry.statusCode = statusCode;
|
|
6770
|
-
requestLogEntry.completed = true;
|
|
6771
|
-
if (!isSuccess) {
|
|
6772
|
-
requestLogEntry.error = `HTTP ${statusCode}`;
|
|
6773
|
-
if (requestLogEntry.keys) {
|
|
6774
|
-
const sizeBefore = this._failedKeys.size;
|
|
6775
|
-
requestLogEntry.keys.forEach((key) => this._failedKeys.add(key));
|
|
6776
|
-
if (this._failedKeys.size > sizeBefore) this._saveFailedKeysToDatabase();
|
|
6777
|
-
}
|
|
6778
|
-
}
|
|
6779
|
-
}
|
|
6780
|
-
proxyRes.on("error", (err) => {
|
|
6781
|
-
debug.trace("Proxy response error:", err);
|
|
6782
|
-
if (!res.headersSent) {
|
|
6783
|
-
res.writeHead(500);
|
|
6784
|
-
res.end("Proxy Response Error");
|
|
6785
|
-
}
|
|
6786
|
-
if (requestLogEntry) {
|
|
6787
|
-
requestLogEntry.success = false;
|
|
6788
|
-
requestLogEntry.statusCode = 500;
|
|
6789
|
-
requestLogEntry.error = `Proxy response error: ${err.message}`;
|
|
6790
|
-
requestLogEntry.completed = true;
|
|
6791
|
-
}
|
|
6792
|
-
proxyRes.destroy(err);
|
|
6793
|
-
});
|
|
6794
|
-
if (!res.headersSent) {
|
|
6795
|
-
res.writeHead(statusCode, proxyRes.headers);
|
|
6796
|
-
proxyRes.pipe(res);
|
|
6797
|
-
}
|
|
6798
|
-
res.on("finish", () => {
|
|
6799
|
-
proxyRes.resume();
|
|
6800
|
-
});
|
|
6801
|
-
});
|
|
6802
|
-
proxyReq.write(rewrittenBody);
|
|
6803
|
-
proxyReq.end();
|
|
6804
|
-
}
|
|
6805
|
-
async _startUpdateAddressesLoop() {
|
|
6806
|
-
if (!this.kuboClients?.length) throw Error("should have a defined kubo rpc client option to start the address rewriter");
|
|
6807
|
-
const isRetriableError = (error) => {
|
|
6808
|
-
if (typeof error !== "object" || error === null) return false;
|
|
6809
|
-
const err = error;
|
|
6810
|
-
return err.response?.status === 500 || err.status === 500 || err.statusCode === 500;
|
|
6811
|
-
};
|
|
6812
|
-
const tryUpdateAddressesForClient = async (kuboClient) => {
|
|
6813
|
-
return new Promise((resolve) => {
|
|
6814
|
-
const operation = import_retry.operation({
|
|
6815
|
-
retries: 3,
|
|
6816
|
-
factor: 2,
|
|
6817
|
-
minTimeout: 1e3,
|
|
6818
|
-
maxTimeout: 8e3
|
|
6819
|
-
});
|
|
6820
|
-
operation.attempt(async (currentAttempt) => {
|
|
6821
|
-
try {
|
|
6822
|
-
const idRes = await kuboClient.id();
|
|
6823
|
-
const swarmAddrsRes = await kuboClient.swarm.addrs();
|
|
6824
|
-
const peerId = idRes.id.toString();
|
|
6825
|
-
if (typeof peerId !== "string") throw Error("Failed to get Peer ID of kubo node");
|
|
6826
|
-
const swarmListeningAddresses = swarmAddrsRes.filter((swarmAddr) => swarmAddr.id.toString() === peerId);
|
|
6827
|
-
const addresses = normalizeSelfAddrsForProvider([...idRes.addresses.map((addr) => addr.toString()), ...import_commonjs.flatten(swarmListeningAddresses.map((swarmAddr) => swarmAddr.addrs.map((addr) => addr.toString())))], peerId);
|
|
6828
|
-
if (addresses.length === 0) throw Error(`Failed to get any addresses for peer ${peerId}`);
|
|
6829
|
-
this.addresses[peerId] = addresses;
|
|
6830
|
-
resolve();
|
|
6831
|
-
} catch (e) {
|
|
6832
|
-
const error = e;
|
|
6833
|
-
if (isRetriableError(error)) {
|
|
6834
|
-
debug(`tryUpdateAddresses attempt ${currentAttempt}/4 failed with 500 error:`, error.message, { kuboConfig: kuboClient.getEndpointConfig() });
|
|
6835
|
-
if (operation.retry(error)) return;
|
|
6836
|
-
}
|
|
6837
|
-
debug("tryUpdateAddresses error:", error.message, { kuboConfig: kuboClient.getEndpointConfig() });
|
|
6838
|
-
resolve();
|
|
6839
|
-
}
|
|
6840
|
-
});
|
|
6841
|
-
});
|
|
6842
|
-
};
|
|
6843
|
-
const tryUpdateAddresses = async () => {
|
|
6844
|
-
const promises = this.kuboClients.map(tryUpdateAddressesForClient);
|
|
6845
|
-
await Promise.allSettled(promises);
|
|
6846
|
-
};
|
|
6847
|
-
await tryUpdateAddresses();
|
|
6848
|
-
this._updateAddressesInterval = setInterval(tryUpdateAddresses, 1e3 * 60);
|
|
6849
|
-
}
|
|
6850
|
-
_extractKeysFromRequestBody(body) {
|
|
6851
|
-
try {
|
|
6852
|
-
const json = JSON.parse(body);
|
|
6853
|
-
const keys = [];
|
|
6854
|
-
if (json.Providers && Array.isArray(json.Providers)) {
|
|
6855
|
-
for (const provider of json.Providers) if (provider?.Payload?.Keys) keys.push(...provider.Payload.Keys);
|
|
6856
|
-
}
|
|
6857
|
-
return keys;
|
|
6858
|
-
} catch {
|
|
6859
|
-
return [];
|
|
6860
|
-
}
|
|
6861
|
-
}
|
|
6862
|
-
_createBodyPreview(body) {
|
|
6863
|
-
const buffer = Buffer.from(body, "utf8");
|
|
6864
|
-
if (buffer.length <= MAX_BODY_PREVIEW_BYTES) return body;
|
|
6865
|
-
return `${buffer.subarray(0, MAX_BODY_PREVIEW_BYTES).toString("utf8")}...[truncated ${buffer.length - MAX_BODY_PREVIEW_BYTES} bytes]`;
|
|
6866
|
-
}
|
|
6867
|
-
async _writeRequestLogs() {
|
|
6868
|
-
if (!this._loggingEnabled || !this._db) return;
|
|
6869
|
-
if (this._requestLogBuffer.length === 0 || this._isWritingLogs) return;
|
|
6870
|
-
this._isWritingLogs = true;
|
|
6871
|
-
const logsToWrite = this._requestLogBuffer.filter((entry) => entry.completed);
|
|
6872
|
-
if (logsToWrite.length === 0) {
|
|
6873
|
-
this._isWritingLogs = false;
|
|
6874
|
-
return;
|
|
6875
|
-
}
|
|
6876
|
-
const inFlightLogs = this._requestLogBuffer.filter((entry) => !entry.completed);
|
|
6877
|
-
this._requestLogBuffer = inFlightLogs;
|
|
6878
|
-
try {
|
|
6879
|
-
this._db.insertRequestLogs(logsToWrite);
|
|
6880
|
-
debug.trace(`Wrote ${logsToWrite.length} new request log entries to SQLite database`);
|
|
6881
|
-
} catch (error) {
|
|
6882
|
-
debug.error(`Failed to write request logs to SQLite database:`, error);
|
|
6883
|
-
this._requestLogBuffer.unshift(...logsToWrite);
|
|
6884
|
-
} finally {
|
|
6885
|
-
this._isWritingLogs = false;
|
|
6886
|
-
}
|
|
6887
|
-
}
|
|
6888
|
-
_startRequestLogging() {
|
|
6889
|
-
if (!this._loggingEnabled || !this._db) return;
|
|
6890
|
-
const writeInterval = 5 * 1e3;
|
|
6891
|
-
this._logWriteInterval = setInterval(async () => {
|
|
6892
|
-
await this._writeRequestLogs();
|
|
6893
|
-
}, writeInterval);
|
|
6894
|
-
}
|
|
6895
|
-
async _startFailedKeysRetry() {
|
|
6896
|
-
this._loadFailedKeysFromDatabase();
|
|
6897
|
-
const retryInterval = 120 * 1e3;
|
|
6898
|
-
this._retryInterval = setInterval(async () => {
|
|
6899
|
-
if (this._isRetrying) {
|
|
6900
|
-
debug.trace("Previous failed-keys retry still running, skipping this tick");
|
|
6901
|
-
return;
|
|
6902
|
-
}
|
|
6903
|
-
this._isRetrying = true;
|
|
6904
|
-
try {
|
|
6905
|
-
await this._retryFailedKeys();
|
|
6906
|
-
} finally {
|
|
6907
|
-
this._isRetrying = false;
|
|
6908
|
-
}
|
|
6909
|
-
}, retryInterval);
|
|
6910
|
-
debug(`Started failed keys retry with ${this._failedKeys.size} keys from previous sessions`);
|
|
6911
|
-
}
|
|
6912
|
-
_loadFailedKeysFromDatabase() {
|
|
6913
|
-
if (!this._loggingEnabled || !this._db) return;
|
|
6914
|
-
try {
|
|
6915
|
-
const keys = this._db.loadFailedKeys();
|
|
6916
|
-
keys.forEach((key) => this._failedKeys.add(key));
|
|
6917
|
-
debug(`Loaded ${keys.length} failed keys from database`);
|
|
6918
|
-
} catch (error) {
|
|
6919
|
-
debug.error("Failed to load failed keys from database:", error);
|
|
6920
|
-
throw error;
|
|
6921
|
-
}
|
|
6922
|
-
}
|
|
6923
|
-
_saveFailedKeysToDatabase() {
|
|
6924
|
-
if (!this._loggingEnabled || !this._db) return;
|
|
6925
|
-
try {
|
|
6926
|
-
const keys = Array.from(this._failedKeys);
|
|
6927
|
-
this._db.saveFailedKeys(keys);
|
|
6928
|
-
if (keys.length === 0) debug.trace(`All keys successfully provided - no failed keys to save`);
|
|
6929
|
-
else debug.trace(`Saved ${keys.length} failed keys to database`);
|
|
6930
|
-
} catch (error) {
|
|
6931
|
-
debug.error("Failed to save failed keys to database:", error);
|
|
6932
|
-
throw error;
|
|
6933
|
-
}
|
|
6934
|
-
}
|
|
6935
|
-
async _retryFailedKeys() {
|
|
6936
|
-
if (this._failedKeys.size === 0) {
|
|
6937
|
-
debug.trace(`No failed keys to retry - all keys successfully provided`);
|
|
6938
|
-
return;
|
|
6939
|
-
}
|
|
6940
|
-
debug(`Retrying ${this._failedKeys.size} failed keys`);
|
|
6941
|
-
const keysToRetry = Array.from(this._failedKeys);
|
|
6942
|
-
const kuboClient = this.kuboClients?.[0];
|
|
6943
|
-
if (!kuboClient) {
|
|
6944
|
-
debug.error("No kubo client available for retry");
|
|
6945
|
-
return;
|
|
6946
|
-
}
|
|
6947
|
-
const successfulKeys = [];
|
|
6948
|
-
const stillFailedKeys = [];
|
|
6949
|
-
const keysToDiscard = [];
|
|
6950
|
-
for (const key of keysToRetry) try {
|
|
6951
|
-
debug.trace(`Providing key to HTTP routers: ${key}`);
|
|
6952
|
-
const events = [];
|
|
6953
|
-
for await (const event of kuboClient.routing.provide(key, {
|
|
6954
|
-
recursive: true,
|
|
6955
|
-
verbose: true
|
|
6956
|
-
})) {
|
|
6957
|
-
events.push(event);
|
|
6958
|
-
debug(`Routing provide event for ${key}:`, event);
|
|
6959
|
-
}
|
|
6960
|
-
successfulKeys.push(key);
|
|
6961
|
-
debug.trace(`Successfully provided key: ${key}`);
|
|
6962
|
-
this._logReprovideAttempt(key, true, void 0, false);
|
|
6963
|
-
} catch (error) {
|
|
6964
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
6965
|
-
const isBlockNotLocal = errorMessage.includes("block") && errorMessage.includes("not found locally");
|
|
6966
|
-
this._logReprovideAttempt(key, false, errorMessage, isBlockNotLocal);
|
|
6967
|
-
if (isBlockNotLocal) {
|
|
6968
|
-
keysToDiscard.push(key);
|
|
6969
|
-
debug.trace(`Discarding key ${key} - block not found locally, will not retry`);
|
|
6970
|
-
} else {
|
|
6971
|
-
stillFailedKeys.push(key);
|
|
6972
|
-
debug.trace(`Failed to provide key ${key}:`, error);
|
|
6973
|
-
}
|
|
6974
|
-
}
|
|
6975
|
-
successfulKeys.forEach((key) => this._failedKeys.delete(key));
|
|
6976
|
-
keysToDiscard.forEach((key) => this._failedKeys.delete(key));
|
|
6977
|
-
this._saveFailedKeysToDatabase();
|
|
6978
|
-
debug.trace(`Retry completed: ${successfulKeys.length} successful, ${stillFailedKeys.length} still failed, ${keysToDiscard.length} discarded`);
|
|
6979
|
-
}
|
|
6980
|
-
_logReprovideAttempt(key, success, error, blockNotLocal) {
|
|
6981
|
-
if (!this._loggingEnabled || !this._db) return;
|
|
6982
|
-
try {
|
|
6983
|
-
this._db.insertReprovideLog(key, success, error, blockNotLocal);
|
|
6984
|
-
debug.trace(`Logged reprovide attempt for key ${key}: success=${success}, blockNotLocal=${blockNotLocal}`);
|
|
6985
|
-
} catch (error) {
|
|
6986
|
-
debug.error(`Failed to log reprovide attempt for key ${key}:`, error);
|
|
6987
|
-
throw error;
|
|
6988
|
-
}
|
|
6989
|
-
}
|
|
6990
|
-
};
|
|
6991
|
-
//#endregion
|
|
6992
6469
|
//#region node_modules/deep-is/index.js
|
|
6993
6470
|
var require_deep_is = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
6994
6471
|
var pSlice = Array.prototype.slice;
|
|
@@ -9380,7 +8857,7 @@ var PKC$1 = class extends PKCTypedEmitter {
|
|
|
9380
8857
|
this.clients.libp2pJsClients = {};
|
|
9381
8858
|
if (!this.libp2pJsClientsOptions) return;
|
|
9382
8859
|
if (!this.httpRoutersOptions) throw Error("httpRoutersOptions is required for libp2pJsClient");
|
|
9383
|
-
const { createLibp2pJsClientOrUseExistingOne } = await import("./helia-for-pkc-
|
|
8860
|
+
const { createLibp2pJsClientOrUseExistingOne } = await import("./helia-for-pkc-Dy66yFBq.js");
|
|
9384
8861
|
for (const clientOptions of this.libp2pJsClientsOptions) {
|
|
9385
8862
|
const heliaNode = await createLibp2pJsClientOrUseExistingOne({
|
|
9386
8863
|
...clientOptions,
|
|
@@ -9626,7 +9103,7 @@ var PKC$1 = class extends PKCTypedEmitter {
|
|
|
9626
9103
|
const log = logger_default("pkc-js:pkc:createLocalCommunity");
|
|
9627
9104
|
log.trace("Received community options to create a local community instance:", options);
|
|
9628
9105
|
if (!this._canCreateNewLocalCommunity()) throw new PKCError("ERR_CAN_NOT_CREATE_A_LOCAL_COMMUNITY", { pkcOptions: this._userPKCOptions });
|
|
9629
|
-
const { LocalCommunity, createNewLocalCommunityDb, updateInstancePropsWithStartedCommunityOrDb } = await import("./local-community-
|
|
9106
|
+
const { LocalCommunity, createNewLocalCommunityDb, updateInstancePropsWithStartedCommunityOrDb } = await import("./local-community-CpqhUYOZ.js");
|
|
9630
9107
|
const isLocalCommunity = (await listCommunitiesSync(this)).includes(options.address);
|
|
9631
9108
|
const community = new LocalCommunity(this);
|
|
9632
9109
|
if (isLocalCommunity) {
|