@pkcprotocol/pkc-js 0.0.80 → 0.0.81
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/pkc/pkc.d.ts +1 -2
- package/dist/browser/pkc/pkc.js +17 -24
- package/dist/browser/pkc/pkc.js.map +1 -1
- package/dist/browser/rpc/src/index.js +1 -1
- package/dist/browser/rpc/src/index.js.map +1 -1
- package/dist/browser/runtime/browser/setup-kubo-http-routers.d.ts +1 -0
- package/dist/browser/runtime/browser/setup-kubo-http-routers.js +4 -0
- package/dist/browser/runtime/browser/setup-kubo-http-routers.js.map +1 -0
- package/dist/browser/runtime/node/community/local-community/reprovide-on-address-change.d.ts +3 -2
- package/dist/browser/runtime/node/community/local-community/reprovide-on-address-change.js +19 -10
- package/dist/browser/runtime/node/community/local-community/reprovide-on-address-change.js.map +1 -1
- package/dist/browser/runtime/node/setup-kubo-http-routers.d.ts +2 -0
- package/dist/browser/runtime/node/{setup-kubo-address-rewriter-and-http-router.js → setup-kubo-http-routers.js} +54 -112
- package/dist/browser/runtime/node/setup-kubo-http-routers.js.map +1 -0
- package/dist/browser/util.d.ts +3 -4
- package/dist/browser/util.js +7 -3
- package/dist/browser/util.js.map +1 -1
- package/dist/bundled/bundle-manifest.json +76 -93
- package/dist/bundled/chunks/{helia-for-pkc-BsYWQ7qS.js → helia-for-pkc-BcNF-orO.js} +31 -31
- package/dist/bundled/chunks/{local-community-EqWKTLxr.js → local-community-B6-jaMsn.js} +1 -1
- package/dist/bundled/chunks/{local-community-CHzhypCp.js → local-community-CyX1HwD0.js} +8 -4
- package/dist/bundled/chunks/{node-4qAZNuJG.js → node-BCXmIYLQ.js} +265 -2310
- package/dist/bundled/chunks/{rpc-local-community-Cog5rZLG.js → rpc-local-community-BOiy8BX1.js} +47 -570
- package/dist/bundled/chunks/{schema-Iavj-cRD.js → schema-DZyEx0YQ.js} +4 -4
- package/dist/bundled/chunks/{util-CfSUfLkV.js → util-BTPlI1yF.js} +1 -1
- 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/pkc/pkc.d.ts +1 -2
- package/dist/node/pkc/pkc.js +17 -24
- package/dist/node/pkc/pkc.js.map +1 -1
- package/dist/node/rpc/src/index.js +1 -1
- package/dist/node/rpc/src/index.js.map +1 -1
- package/dist/node/runtime/browser/setup-kubo-http-routers.d.ts +1 -0
- package/dist/node/runtime/browser/setup-kubo-http-routers.js +4 -0
- package/dist/node/runtime/browser/setup-kubo-http-routers.js.map +1 -0
- package/dist/node/runtime/node/community/local-community/reprovide-on-address-change.d.ts +3 -2
- package/dist/node/runtime/node/community/local-community/reprovide-on-address-change.js +19 -10
- package/dist/node/runtime/node/community/local-community/reprovide-on-address-change.js.map +1 -1
- package/dist/node/runtime/node/setup-kubo-http-routers.d.ts +2 -0
- package/dist/node/runtime/node/{setup-kubo-address-rewriter-and-http-router.js → setup-kubo-http-routers.js} +54 -112
- package/dist/node/runtime/node/setup-kubo-http-routers.js.map +1 -0
- package/dist/node/util.d.ts +3 -4
- package/dist/node/util.js +7 -3
- package/dist/node/util.js.map +1 -1
- package/package.json +2 -2
- package/dist/browser/runtime/browser/setup-kubo-address-rewriter-and-http-router.d.ts +0 -1
- package/dist/browser/runtime/browser/setup-kubo-address-rewriter-and-http-router.js +0 -4
- package/dist/browser/runtime/browser/setup-kubo-address-rewriter-and-http-router.js.map +0 -1
- package/dist/browser/runtime/node/address-rewriter-db.d.ts +0 -33
- package/dist/browser/runtime/node/address-rewriter-db.js +0 -156
- package/dist/browser/runtime/node/address-rewriter-db.js.map +0 -1
- package/dist/browser/runtime/node/addresses-rewriter-proxy-server.d.ts +0 -47
- package/dist/browser/runtime/node/addresses-rewriter-proxy-server.js +0 -534
- package/dist/browser/runtime/node/addresses-rewriter-proxy-server.js.map +0 -1
- package/dist/browser/runtime/node/setup-kubo-address-rewriter-and-http-router.d.ts +0 -4
- package/dist/browser/runtime/node/setup-kubo-address-rewriter-and-http-router.js.map +0 -1
- package/dist/node/runtime/browser/setup-kubo-address-rewriter-and-http-router.d.ts +0 -1
- package/dist/node/runtime/browser/setup-kubo-address-rewriter-and-http-router.js +0 -4
- package/dist/node/runtime/browser/setup-kubo-address-rewriter-and-http-router.js.map +0 -1
- package/dist/node/runtime/node/address-rewriter-db.d.ts +0 -33
- package/dist/node/runtime/node/address-rewriter-db.js +0 -156
- package/dist/node/runtime/node/address-rewriter-db.js.map +0 -1
- package/dist/node/runtime/node/addresses-rewriter-proxy-server.d.ts +0 -47
- package/dist/node/runtime/node/addresses-rewriter-proxy-server.js +0 -534
- package/dist/node/runtime/node/addresses-rewriter-proxy-server.js.map +0 -1
- package/dist/node/runtime/node/setup-kubo-address-rewriter-and-http-router.d.ts +0 -4
- package/dist/node/runtime/node/setup-kubo-address-rewriter-and-http-router.js.map +0 -1
- package/dist/bundled/chunks/{src-BEjAH2gY.js → src-WLgFbUwZ.js} +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { i as __toESM, r as __require, t as __commonJSMin } from "./chunk-2rV9d50f.js";
|
|
2
|
-
import { $n as n$1, B as isIpfsCid, Cr as setErrorMap, Ct as findUpdatingCommunity, D as deepMergeRuntimeFields, Dn as CommentUpdateSchema, Dt as refreshTrackedCommentAliases, E as createAbortError, Et as listUpdatingCommunities, Fr as parsedType, H as isIpns, Ir as stringifyPrimitive, It as require_sha256, L as hideClassPrivateProps, Lt as TimeoutError, Pr as joinValues, Pt as untrackUpdatingComment, Q as isStringDomain, Qt as CommunityAnchorSchema, R as ipnsNameToIpnsOverPubsubTopic, Rt as pTimeout, St as findUpdatingComment, Tt as listUpdatingComments, Zn as n$2, _t as timestamp, a as ChallengeRequestMessageSchema, ar as r, b as areEquivalentCommunityAddresses, br as logger_default, ct as resolveWhenPredicateIsTrue, fr as require_retry, ft as shortifyAddress, jt as trackUpdatingComment, k as doesDomainAddressHaveCapitalLetter, ln as PubsubTopicSchema, mt as sleepUntilTimeoutOrAbort, nr as e, ot as removeUndefinedValuesRecursively, pr as FailedToFetchCommentIpfsFromGatewaysError, pt as shortifyCid, r as ChallengeMessageSchema, rn as CommunityIpfsSchema, rr as e$1, s as ChallengeVerificationMessageSchema, st as replaceXWithY, t as ChallengeAnswerMessageSchema, tr as t$1, ut as retryKuboIpfsAdd, vr as PKCError, vt as waitForUpdateInCommunityInstanceWithErrorAndTimeout, wn as CommentUpdateForChallengeVerificationSchema, wt as listStartedCommunities,
|
|
3
|
-
import { $ as
|
|
4
|
-
import { o as getHeliaDebugContext } from "./util-
|
|
2
|
+
import { $n as n$1, B as isIpfsCid, Cr as setErrorMap, Ct as findUpdatingCommunity, D as deepMergeRuntimeFields, Dn as CommentUpdateSchema, Dt as refreshTrackedCommentAliases, E as createAbortError, Et as listUpdatingCommunities, Fr as parsedType, H as isIpns, Ir as stringifyPrimitive, It as require_sha256, L as hideClassPrivateProps, Lt as TimeoutError, Pr as joinValues, Pt as untrackUpdatingComment, Q as isStringDomain, Qt as CommunityAnchorSchema, R as ipnsNameToIpnsOverPubsubTopic, Rt as pTimeout, St as findUpdatingComment, Tt as listUpdatingComments, Zn as n$2, _t as timestamp, a as ChallengeRequestMessageSchema, ar as r, b as areEquivalentCommunityAddresses, br as logger_default, ct as resolveWhenPredicateIsTrue, fr as require_retry, ft as shortifyAddress, jt as trackUpdatingComment, k as doesDomainAddressHaveCapitalLetter, ln as PubsubTopicSchema, mt as sleepUntilTimeoutOrAbort, nr as e, ot as removeUndefinedValuesRecursively, pr as FailedToFetchCommentIpfsFromGatewaysError, pt as shortifyCid, r as ChallengeMessageSchema, rn as CommunityIpfsSchema, rr as e$1, s as ChallengeVerificationMessageSchema, st as replaceXWithY, t as ChallengeAnswerMessageSchema, tr as t$1, ut as retryKuboIpfsAdd, vr as PKCError, vt as waitForUpdateInCommunityInstanceWithErrorAndTimeout, wn as CommentUpdateForChallengeVerificationSchema, wt as listStartedCommunities, xt as findStartedCommunity, y as version_default, yn as CommentIpfsSchema, yr as messages, z as isAbortError } from "./schema-DZyEx0YQ.js";
|
|
3
|
+
import { $ as PublicationClientsManager, $t as parseCommentIpfsSchemaWithPKCErrorIfItFails, An as RpcCidParamSchema, At as verifyVote, B as tryToDeleteCommunitiesThatFailedToBeDeletedBefore, Bn as RpcFetchCidResultSchema, Bt as normalizeCommunityInputFromCommunity, Cn as parseRpcCommentUpdateEventWithPKCErrorIfItFails, Ct as verifyCommentEdit, Dn as RpcAnchorPublishPreparationResultSchema, Dt as verifyCommentUpdate, E as createKuboRpcClient, En as parseVotePubsubMessagePublicationSchemaWithPKCErrorIfItFails, Et as verifyCommentPubsubMessage, F as listCommunitiesSync, Fn as RpcExportCommunityModLogsParamSchema, Ft as normalizeCreatePublicationAuthor, Gn as RpcSubscriptionIdResultSchema, Hn as RpcPublishChallengeAnswersParamSchema, I as monitorCommunitiesDirectory, In as RpcExportCommunityModLogsResultSchema, It as buildRuntimeCommunityFields, J as extractCommunityRuntimeFieldsFromParsedPages, Jn as t$4, Kn as RpcSuccessResultSchema, Kt as getPKCAddressFromPublicKeySync, Ln as RpcExportCommunityParamSchema, Lt as getCommunityAddressFromRecord, M as getDefaultDataPath, Mn as RpcCommunityIdentifierParamSchema, Mt as cleanWireAuthor, Nn as RpcCommunityPageParamSchema, Nt as getAuthorNameFromRuntime, On as RpcAuthorNameParamSchema, Pn as RpcEditCommunityParamSchema, Q as RepliesPages, Qn as n$3, Qt as parseCommentEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, Rn as RpcExportCommunityResultSchema, Rt as getCommunityNameFromWire, Sn as parseRpcCommentEventWithPKCErrorIfItFails, St as verifyChallengeVerification, Tt as verifyCommentModeration, Un as RpcPublishedAnchorRecordResultSchema, Ut as getBufferedPKCAddressFromPublicKey, V as CommentClientsManager, Vn as RpcPublishAnchorRecordParamSchema, Vt as decode, Wn as RpcResolveAuthorNameResultSchema, Y as findCommentInPageInstanceRecursively, Yt as parseCidStringSchemaWithPKCErrorIfItFails, Z as parseRawPages, Zn as t$3, _ as createAnchorIpnsRecord$1, _n as parseDecryptedChallengeAnswerWithPKCErrorIfItFails, _t as signCommunityEdit, a as pkcJsChallenges, ar as nativeFunctions$2, at as require_lib$1, b as encryptEd25519AesGcm, bn as parseJsonWithPKCErrorIfFails, bt as verifyChallengeMessage, c as RemoteCommunity, cn as parseCreateCommentEditOptionsSchemaWithPKCErrorIfItFails, d as decodeRpcChallengeAnswerPubsubMsg, dn as parseCreateCommunityEditPublicationOptionsSchemaWithPKCErrorIfItFails, dt as signComment, er as t$2, et as PKCClientsManager, f as decodeRpcChallengePubsubMsg, ft as signCommentEdit, g as createSigner, gn as parseCreateVoteOptionsSchemaWithPKCErrorIfItFails, hn as parseCreateRpcCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, it as PKCTypedEmitter, jn as RpcCommentRepliesPageParamSchema, jt as buildRuntimeAuthor, kn as RpcCancelExportParamSchema, kt as verifyCommunityEdit, ln as parseCreateCommentModerationOptionsSchemaWithPKCErrorIfItFails, lt as signChallengeRequest, m as decodeRpcChallengeVerificationPubsubMsg, mn as parseCreateRemoteCommunityFunctionArgumentSchemaWithPKCErrorIfItFails, n as RpcRemoteCommunity, nn as parseCommentPubsubMessagePublicationWithPKCErrorIfItFails, o as TrackedInstanceRegistry, on as parseCommunityEditPubsubMessagePublicationSchemaWithPKCErrorIfItFails, or as require_undici, ot as cleanUpBeforePublishing, p as decodeRpcChallengeRequestPubsubMsg, pt as signCommentModeration, qn as RpcUnsubscribeParamSchema, rn as parseCommunityAddressWithPKCErrorIfItFails, s as LRUCache, st as signChallengeAnswer, t as RpcLocalCommunity, tn as parseCommentModerationPubsubMessagePublicationSchemaWithPKCErrorIfItFails, tr as t$5, tt as InflightFetchManager, u as KeyvBetterSqlite3, un as parseCreateCommentOptionsSchemaWithPKCErrorIfItFails, v as decryptEd25519AesGcm, vn as parseDecryptedChallengeVerification, vt as signVote, wn as parseSetNewSettingsPKCWsServerSchemaWithPKCErrorIfItFails, wt as verifyCommentIpfs, xn as parsePKCUserOptionsSchemaWithPKCErrorIfItFails, yn as parseDecryptedChallengeWithPKCErrorIfItFails, z as setNativeFunctions$1, zn as RpcFetchCidParamSchema, zt as getCommunityPublicKeyFromWire } from "./rpc-local-community-BOiy8BX1.js";
|
|
4
|
+
import { o as getHeliaDebugContext } from "./util-BTPlI1yF.js";
|
|
5
5
|
import path from "path";
|
|
6
6
|
import assert from "assert";
|
|
7
7
|
import fs from "fs";
|
|
@@ -2493,7 +2493,7 @@ var PKCRpcClient = class extends import_lib.TypedEmitter {
|
|
|
2493
2493
|
//#region node_modules/nofilter/lib/index.js
|
|
2494
2494
|
var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2495
2495
|
const stream$5 = __require("stream");
|
|
2496
|
-
const { Buffer: Buffer$
|
|
2496
|
+
const { Buffer: Buffer$6 } = __require("buffer");
|
|
2497
2497
|
const td = new TextDecoder("utf8", {
|
|
2498
2498
|
fatal: true,
|
|
2499
2499
|
ignoreBOM: true
|
|
@@ -2512,7 +2512,7 @@ var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
2512
2512
|
let inpE = null;
|
|
2513
2513
|
switch (typeof input) {
|
|
2514
2514
|
case "object":
|
|
2515
|
-
if (Buffer$
|
|
2515
|
+
if (Buffer$6.isBuffer(input)) inp = input;
|
|
2516
2516
|
else if (input) options = input;
|
|
2517
2517
|
break;
|
|
2518
2518
|
case "string":
|
|
@@ -2593,7 +2593,7 @@ var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
2593
2593
|
*/
|
|
2594
2594
|
static concat(list, length) {
|
|
2595
2595
|
if (!Array.isArray(list)) throw new TypeError("list argument must be an Array of NoFilters");
|
|
2596
|
-
if (list.length === 0 || length === 0) return Buffer$
|
|
2596
|
+
if (list.length === 0 || length === 0) return Buffer$6.alloc(0);
|
|
2597
2597
|
if (length == null) length = list.reduce((tot, nf) => {
|
|
2598
2598
|
if (!(nf instanceof NoFilter)) throw new TypeError("list argument must be an Array of NoFilters");
|
|
2599
2599
|
return tot + nf.length;
|
|
@@ -2603,11 +2603,11 @@ var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
2603
2603
|
const bufs = list.map((nf) => {
|
|
2604
2604
|
if (!(nf instanceof NoFilter)) throw new TypeError("list argument must be an Array of NoFilters");
|
|
2605
2605
|
const buf = nf.slice();
|
|
2606
|
-
if (Buffer$
|
|
2606
|
+
if (Buffer$6.isBuffer(buf)) allObjs = false;
|
|
2607
2607
|
else allBufs = false;
|
|
2608
2608
|
return buf;
|
|
2609
2609
|
});
|
|
2610
|
-
if (allBufs) return Buffer$
|
|
2610
|
+
if (allBufs) return Buffer$6.concat(bufs, length);
|
|
2611
2611
|
if (allObjs) return [].concat(...bufs).slice(0, length);
|
|
2612
2612
|
throw new Error("Concatenating mixed object and byte streams not supported");
|
|
2613
2613
|
}
|
|
@@ -2615,7 +2615,7 @@ var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
2615
2615
|
* @ignore
|
|
2616
2616
|
*/
|
|
2617
2617
|
_transform(chunk, encoding, callback) {
|
|
2618
|
-
if (!this._readableState.objectMode && !Buffer$
|
|
2618
|
+
if (!this._readableState.objectMode && !Buffer$6.isBuffer(chunk)) chunk = Buffer$6.from(chunk, encoding);
|
|
2619
2619
|
this.push(chunk);
|
|
2620
2620
|
callback();
|
|
2621
2621
|
}
|
|
@@ -2750,7 +2750,7 @@ var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
2750
2750
|
if (this === other) return 0;
|
|
2751
2751
|
const buf1 = this.slice();
|
|
2752
2752
|
const buf2 = other.slice();
|
|
2753
|
-
if (Buffer$
|
|
2753
|
+
if (Buffer$6.isBuffer(buf1) && Buffer$6.isBuffer(buf2)) return buf1.compare(buf2);
|
|
2754
2754
|
throw new Error("Cannot compare streams in object mode");
|
|
2755
2755
|
}
|
|
2756
2756
|
/**
|
|
@@ -2778,9 +2778,9 @@ var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
2778
2778
|
if (this._readableState.objectMode) return this._bufArray().slice(start, end);
|
|
2779
2779
|
const bufs = this._bufArray();
|
|
2780
2780
|
switch (bufs.length) {
|
|
2781
|
-
case 0: return Buffer$
|
|
2781
|
+
case 0: return Buffer$6.alloc(0);
|
|
2782
2782
|
case 1: return bufs[0].slice(start, end);
|
|
2783
|
-
default: return Buffer$
|
|
2783
|
+
default: return Buffer$6.concat(bufs).slice(start, end);
|
|
2784
2784
|
}
|
|
2785
2785
|
}
|
|
2786
2786
|
/**
|
|
@@ -2807,7 +2807,7 @@ var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
2807
2807
|
*/
|
|
2808
2808
|
toJSON() {
|
|
2809
2809
|
const b = this.slice();
|
|
2810
|
-
if (Buffer$
|
|
2810
|
+
if (Buffer$6.isBuffer(b)) return b.toJSON();
|
|
2811
2811
|
return b;
|
|
2812
2812
|
}
|
|
2813
2813
|
/**
|
|
@@ -2823,7 +2823,7 @@ var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
2823
2823
|
*/
|
|
2824
2824
|
toString(encoding, start, end) {
|
|
2825
2825
|
const buf = this.slice(start, end);
|
|
2826
|
-
if (!Buffer$
|
|
2826
|
+
if (!Buffer$6.isBuffer(buf)) return JSON.stringify(buf);
|
|
2827
2827
|
if (!encoding || encoding === "utf8") return td.decode(buf);
|
|
2828
2828
|
return buf.toString(encoding);
|
|
2829
2829
|
}
|
|
@@ -2832,7 +2832,7 @@ var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
2832
2832
|
*/
|
|
2833
2833
|
[Symbol.for("nodejs.util.inspect.custom")](depth, options) {
|
|
2834
2834
|
const hex = this._bufArray().map((b) => {
|
|
2835
|
-
if (Buffer$
|
|
2835
|
+
if (Buffer$6.isBuffer(b)) return options.stylize(b.toString("hex"), "string");
|
|
2836
2836
|
return JSON.stringify(b);
|
|
2837
2837
|
}).join(", ");
|
|
2838
2838
|
return `${this.constructor.name} [${hex}]`;
|
|
@@ -2860,7 +2860,7 @@ var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
2860
2860
|
str = val.toString(16);
|
|
2861
2861
|
}
|
|
2862
2862
|
if (str.length % 2) str = `0${str}`;
|
|
2863
|
-
return this.push(Buffer$
|
|
2863
|
+
return this.push(Buffer$6.from(str, "hex"));
|
|
2864
2864
|
}
|
|
2865
2865
|
/**
|
|
2866
2866
|
* Read a variable-sized JavaScript unsigned BigInt from the stream.
|
|
@@ -2871,7 +2871,7 @@ var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
2871
2871
|
*/
|
|
2872
2872
|
readUBigInt(len) {
|
|
2873
2873
|
const b = this.read(len);
|
|
2874
|
-
if (!Buffer$
|
|
2874
|
+
if (!Buffer$6.isBuffer(b)) return null;
|
|
2875
2875
|
return BigInt(`0x${b.toString("hex")}`);
|
|
2876
2876
|
}
|
|
2877
2877
|
/**
|
|
@@ -2884,7 +2884,7 @@ var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
2884
2884
|
*/
|
|
2885
2885
|
readBigInt(len) {
|
|
2886
2886
|
const b = this.read(len);
|
|
2887
|
-
if (!Buffer$
|
|
2887
|
+
if (!Buffer$6.isBuffer(b)) return null;
|
|
2888
2888
|
let ret = BigInt(`0x${b.toString("hex")}`);
|
|
2889
2889
|
if (b[0] & 128) {
|
|
2890
2890
|
const mask = BigInt(1) << BigInt(b.length) * BigInt(8);
|
|
@@ -2899,7 +2899,7 @@ var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
2899
2899
|
* @returns {boolean} True on success.
|
|
2900
2900
|
*/
|
|
2901
2901
|
writeUInt8(value) {
|
|
2902
|
-
const b = Buffer$
|
|
2902
|
+
const b = Buffer$6.from([value]);
|
|
2903
2903
|
return this.push(b);
|
|
2904
2904
|
}
|
|
2905
2905
|
/**
|
|
@@ -2910,7 +2910,7 @@ var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
2910
2910
|
* @returns {boolean} True on success.
|
|
2911
2911
|
*/
|
|
2912
2912
|
writeUInt16LE(value) {
|
|
2913
|
-
const b = Buffer$
|
|
2913
|
+
const b = Buffer$6.alloc(2);
|
|
2914
2914
|
b.writeUInt16LE(value);
|
|
2915
2915
|
return this.push(b);
|
|
2916
2916
|
}
|
|
@@ -2922,7 +2922,7 @@ var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
2922
2922
|
* @returns {boolean} True on success.
|
|
2923
2923
|
*/
|
|
2924
2924
|
writeUInt16BE(value) {
|
|
2925
|
-
const b = Buffer$
|
|
2925
|
+
const b = Buffer$6.alloc(2);
|
|
2926
2926
|
b.writeUInt16BE(value);
|
|
2927
2927
|
return this.push(b);
|
|
2928
2928
|
}
|
|
@@ -2934,7 +2934,7 @@ var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
2934
2934
|
* @returns {boolean} True on success.
|
|
2935
2935
|
*/
|
|
2936
2936
|
writeUInt32LE(value) {
|
|
2937
|
-
const b = Buffer$
|
|
2937
|
+
const b = Buffer$6.alloc(4);
|
|
2938
2938
|
b.writeUInt32LE(value);
|
|
2939
2939
|
return this.push(b);
|
|
2940
2940
|
}
|
|
@@ -2946,7 +2946,7 @@ var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
2946
2946
|
* @returns {boolean} True on success.
|
|
2947
2947
|
*/
|
|
2948
2948
|
writeUInt32BE(value) {
|
|
2949
|
-
const b = Buffer$
|
|
2949
|
+
const b = Buffer$6.alloc(4);
|
|
2950
2950
|
b.writeUInt32BE(value);
|
|
2951
2951
|
return this.push(b);
|
|
2952
2952
|
}
|
|
@@ -2957,7 +2957,7 @@ var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
2957
2957
|
* @returns {boolean} True on success.
|
|
2958
2958
|
*/
|
|
2959
2959
|
writeInt8(value) {
|
|
2960
|
-
const b = Buffer$
|
|
2960
|
+
const b = Buffer$6.from([value]);
|
|
2961
2961
|
return this.push(b);
|
|
2962
2962
|
}
|
|
2963
2963
|
/**
|
|
@@ -2967,7 +2967,7 @@ var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
2967
2967
|
* @returns {boolean} True on success.
|
|
2968
2968
|
*/
|
|
2969
2969
|
writeInt16LE(value) {
|
|
2970
|
-
const b = Buffer$
|
|
2970
|
+
const b = Buffer$6.alloc(2);
|
|
2971
2971
|
b.writeUInt16LE(value);
|
|
2972
2972
|
return this.push(b);
|
|
2973
2973
|
}
|
|
@@ -2978,7 +2978,7 @@ var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
2978
2978
|
* @returns {boolean} True on success.
|
|
2979
2979
|
*/
|
|
2980
2980
|
writeInt16BE(value) {
|
|
2981
|
-
const b = Buffer$
|
|
2981
|
+
const b = Buffer$6.alloc(2);
|
|
2982
2982
|
b.writeUInt16BE(value);
|
|
2983
2983
|
return this.push(b);
|
|
2984
2984
|
}
|
|
@@ -2989,7 +2989,7 @@ var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
2989
2989
|
* @returns {boolean} True on success.
|
|
2990
2990
|
*/
|
|
2991
2991
|
writeInt32LE(value) {
|
|
2992
|
-
const b = Buffer$
|
|
2992
|
+
const b = Buffer$6.alloc(4);
|
|
2993
2993
|
b.writeUInt32LE(value);
|
|
2994
2994
|
return this.push(b);
|
|
2995
2995
|
}
|
|
@@ -3000,7 +3000,7 @@ var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
3000
3000
|
* @returns {boolean} True on success.
|
|
3001
3001
|
*/
|
|
3002
3002
|
writeInt32BE(value) {
|
|
3003
|
-
const b = Buffer$
|
|
3003
|
+
const b = Buffer$6.alloc(4);
|
|
3004
3004
|
b.writeUInt32BE(value);
|
|
3005
3005
|
return this.push(b);
|
|
3006
3006
|
}
|
|
@@ -3011,7 +3011,7 @@ var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
3011
3011
|
* @returns {boolean} True on success.
|
|
3012
3012
|
*/
|
|
3013
3013
|
writeFloatLE(value) {
|
|
3014
|
-
const b = Buffer$
|
|
3014
|
+
const b = Buffer$6.alloc(4);
|
|
3015
3015
|
b.writeFloatLE(value);
|
|
3016
3016
|
return this.push(b);
|
|
3017
3017
|
}
|
|
@@ -3022,7 +3022,7 @@ var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
3022
3022
|
* @returns {boolean} True on success.
|
|
3023
3023
|
*/
|
|
3024
3024
|
writeFloatBE(value) {
|
|
3025
|
-
const b = Buffer$
|
|
3025
|
+
const b = Buffer$6.alloc(4);
|
|
3026
3026
|
b.writeFloatBE(value);
|
|
3027
3027
|
return this.push(b);
|
|
3028
3028
|
}
|
|
@@ -3033,7 +3033,7 @@ var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
3033
3033
|
* @returns {boolean} True on success.
|
|
3034
3034
|
*/
|
|
3035
3035
|
writeDoubleLE(value) {
|
|
3036
|
-
const b = Buffer$
|
|
3036
|
+
const b = Buffer$6.alloc(8);
|
|
3037
3037
|
b.writeDoubleLE(value);
|
|
3038
3038
|
return this.push(b);
|
|
3039
3039
|
}
|
|
@@ -3044,7 +3044,7 @@ var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
3044
3044
|
* @returns {boolean} True on success.
|
|
3045
3045
|
*/
|
|
3046
3046
|
writeDoubleBE(value) {
|
|
3047
|
-
const b = Buffer$
|
|
3047
|
+
const b = Buffer$6.alloc(8);
|
|
3048
3048
|
b.writeDoubleBE(value);
|
|
3049
3049
|
return this.push(b);
|
|
3050
3050
|
}
|
|
@@ -3055,7 +3055,7 @@ var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
3055
3055
|
* @returns {boolean} True on success.
|
|
3056
3056
|
*/
|
|
3057
3057
|
writeBigInt64LE(value) {
|
|
3058
|
-
const b = Buffer$
|
|
3058
|
+
const b = Buffer$6.alloc(8);
|
|
3059
3059
|
b.writeBigInt64LE(value);
|
|
3060
3060
|
return this.push(b);
|
|
3061
3061
|
}
|
|
@@ -3066,7 +3066,7 @@ var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
3066
3066
|
* @returns {boolean} True on success.
|
|
3067
3067
|
*/
|
|
3068
3068
|
writeBigInt64BE(value) {
|
|
3069
|
-
const b = Buffer$
|
|
3069
|
+
const b = Buffer$6.alloc(8);
|
|
3070
3070
|
b.writeBigInt64BE(value);
|
|
3071
3071
|
return this.push(b);
|
|
3072
3072
|
}
|
|
@@ -3077,7 +3077,7 @@ var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
3077
3077
|
* @returns {boolean} True on success.
|
|
3078
3078
|
*/
|
|
3079
3079
|
writeBigUInt64LE(value) {
|
|
3080
|
-
const b = Buffer$
|
|
3080
|
+
const b = Buffer$6.alloc(8);
|
|
3081
3081
|
b.writeBigUInt64LE(value);
|
|
3082
3082
|
return this.push(b);
|
|
3083
3083
|
}
|
|
@@ -3088,7 +3088,7 @@ var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
3088
3088
|
* @returns {boolean} True on success.
|
|
3089
3089
|
*/
|
|
3090
3090
|
writeBigUInt64BE(value) {
|
|
3091
|
-
const b = Buffer$
|
|
3091
|
+
const b = Buffer$6.alloc(8);
|
|
3092
3092
|
b.writeBigUInt64BE(value);
|
|
3093
3093
|
return this.push(b);
|
|
3094
3094
|
}
|
|
@@ -3099,7 +3099,7 @@ var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
3099
3099
|
*/
|
|
3100
3100
|
readUInt8() {
|
|
3101
3101
|
const b = this.read(1);
|
|
3102
|
-
if (!Buffer$
|
|
3102
|
+
if (!Buffer$6.isBuffer(b)) return null;
|
|
3103
3103
|
return b.readUInt8();
|
|
3104
3104
|
}
|
|
3105
3105
|
/**
|
|
@@ -3110,7 +3110,7 @@ var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
3110
3110
|
*/
|
|
3111
3111
|
readUInt16LE() {
|
|
3112
3112
|
const b = this.read(2);
|
|
3113
|
-
if (!Buffer$
|
|
3113
|
+
if (!Buffer$6.isBuffer(b)) return null;
|
|
3114
3114
|
return b.readUInt16LE();
|
|
3115
3115
|
}
|
|
3116
3116
|
/**
|
|
@@ -3121,7 +3121,7 @@ var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
3121
3121
|
*/
|
|
3122
3122
|
readUInt16BE() {
|
|
3123
3123
|
const b = this.read(2);
|
|
3124
|
-
if (!Buffer$
|
|
3124
|
+
if (!Buffer$6.isBuffer(b)) return null;
|
|
3125
3125
|
return b.readUInt16BE();
|
|
3126
3126
|
}
|
|
3127
3127
|
/**
|
|
@@ -3132,7 +3132,7 @@ var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
3132
3132
|
*/
|
|
3133
3133
|
readUInt32LE() {
|
|
3134
3134
|
const b = this.read(4);
|
|
3135
|
-
if (!Buffer$
|
|
3135
|
+
if (!Buffer$6.isBuffer(b)) return null;
|
|
3136
3136
|
return b.readUInt32LE();
|
|
3137
3137
|
}
|
|
3138
3138
|
/**
|
|
@@ -3143,7 +3143,7 @@ var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
3143
3143
|
*/
|
|
3144
3144
|
readUInt32BE() {
|
|
3145
3145
|
const b = this.read(4);
|
|
3146
|
-
if (!Buffer$
|
|
3146
|
+
if (!Buffer$6.isBuffer(b)) return null;
|
|
3147
3147
|
return b.readUInt32BE();
|
|
3148
3148
|
}
|
|
3149
3149
|
/**
|
|
@@ -3153,7 +3153,7 @@ var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
3153
3153
|
*/
|
|
3154
3154
|
readInt8() {
|
|
3155
3155
|
const b = this.read(1);
|
|
3156
|
-
if (!Buffer$
|
|
3156
|
+
if (!Buffer$6.isBuffer(b)) return null;
|
|
3157
3157
|
return b.readInt8();
|
|
3158
3158
|
}
|
|
3159
3159
|
/**
|
|
@@ -3164,7 +3164,7 @@ var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
3164
3164
|
*/
|
|
3165
3165
|
readInt16LE() {
|
|
3166
3166
|
const b = this.read(2);
|
|
3167
|
-
if (!Buffer$
|
|
3167
|
+
if (!Buffer$6.isBuffer(b)) return null;
|
|
3168
3168
|
return b.readInt16LE();
|
|
3169
3169
|
}
|
|
3170
3170
|
/**
|
|
@@ -3175,7 +3175,7 @@ var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
3175
3175
|
*/
|
|
3176
3176
|
readInt16BE() {
|
|
3177
3177
|
const b = this.read(2);
|
|
3178
|
-
if (!Buffer$
|
|
3178
|
+
if (!Buffer$6.isBuffer(b)) return null;
|
|
3179
3179
|
return b.readInt16BE();
|
|
3180
3180
|
}
|
|
3181
3181
|
/**
|
|
@@ -3186,7 +3186,7 @@ var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
3186
3186
|
*/
|
|
3187
3187
|
readInt32LE() {
|
|
3188
3188
|
const b = this.read(4);
|
|
3189
|
-
if (!Buffer$
|
|
3189
|
+
if (!Buffer$6.isBuffer(b)) return null;
|
|
3190
3190
|
return b.readInt32LE();
|
|
3191
3191
|
}
|
|
3192
3192
|
/**
|
|
@@ -3197,7 +3197,7 @@ var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
3197
3197
|
*/
|
|
3198
3198
|
readInt32BE() {
|
|
3199
3199
|
const b = this.read(4);
|
|
3200
|
-
if (!Buffer$
|
|
3200
|
+
if (!Buffer$6.isBuffer(b)) return null;
|
|
3201
3201
|
return b.readInt32BE();
|
|
3202
3202
|
}
|
|
3203
3203
|
/**
|
|
@@ -3208,7 +3208,7 @@ var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
3208
3208
|
*/
|
|
3209
3209
|
readFloatLE() {
|
|
3210
3210
|
const b = this.read(4);
|
|
3211
|
-
if (!Buffer$
|
|
3211
|
+
if (!Buffer$6.isBuffer(b)) return null;
|
|
3212
3212
|
return b.readFloatLE();
|
|
3213
3213
|
}
|
|
3214
3214
|
/**
|
|
@@ -3219,7 +3219,7 @@ var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
3219
3219
|
*/
|
|
3220
3220
|
readFloatBE() {
|
|
3221
3221
|
const b = this.read(4);
|
|
3222
|
-
if (!Buffer$
|
|
3222
|
+
if (!Buffer$6.isBuffer(b)) return null;
|
|
3223
3223
|
return b.readFloatBE();
|
|
3224
3224
|
}
|
|
3225
3225
|
/**
|
|
@@ -3230,7 +3230,7 @@ var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
3230
3230
|
*/
|
|
3231
3231
|
readDoubleLE() {
|
|
3232
3232
|
const b = this.read(8);
|
|
3233
|
-
if (!Buffer$
|
|
3233
|
+
if (!Buffer$6.isBuffer(b)) return null;
|
|
3234
3234
|
return b.readDoubleLE();
|
|
3235
3235
|
}
|
|
3236
3236
|
/**
|
|
@@ -3241,7 +3241,7 @@ var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
3241
3241
|
*/
|
|
3242
3242
|
readDoubleBE() {
|
|
3243
3243
|
const b = this.read(8);
|
|
3244
|
-
if (!Buffer$
|
|
3244
|
+
if (!Buffer$6.isBuffer(b)) return null;
|
|
3245
3245
|
return b.readDoubleBE();
|
|
3246
3246
|
}
|
|
3247
3247
|
/**
|
|
@@ -3252,7 +3252,7 @@ var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
3252
3252
|
*/
|
|
3253
3253
|
readBigInt64LE() {
|
|
3254
3254
|
const b = this.read(8);
|
|
3255
|
-
if (!Buffer$
|
|
3255
|
+
if (!Buffer$6.isBuffer(b)) return null;
|
|
3256
3256
|
return b.readBigInt64LE();
|
|
3257
3257
|
}
|
|
3258
3258
|
/**
|
|
@@ -3263,7 +3263,7 @@ var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
3263
3263
|
*/
|
|
3264
3264
|
readBigInt64BE() {
|
|
3265
3265
|
const b = this.read(8);
|
|
3266
|
-
if (!Buffer$
|
|
3266
|
+
if (!Buffer$6.isBuffer(b)) return null;
|
|
3267
3267
|
return b.readBigInt64BE();
|
|
3268
3268
|
}
|
|
3269
3269
|
/**
|
|
@@ -3274,7 +3274,7 @@ var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
3274
3274
|
*/
|
|
3275
3275
|
readBigUInt64LE() {
|
|
3276
3276
|
const b = this.read(8);
|
|
3277
|
-
if (!Buffer$
|
|
3277
|
+
if (!Buffer$6.isBuffer(b)) return null;
|
|
3278
3278
|
return b.readBigUInt64LE();
|
|
3279
3279
|
}
|
|
3280
3280
|
/**
|
|
@@ -3285,7 +3285,7 @@ var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
3285
3285
|
*/
|
|
3286
3286
|
readBigUInt64BE() {
|
|
3287
3287
|
const b = this.read(8);
|
|
3288
|
-
if (!Buffer$
|
|
3288
|
+
if (!Buffer$6.isBuffer(b)) return null;
|
|
3289
3289
|
return b.readBigUInt64BE();
|
|
3290
3290
|
}
|
|
3291
3291
|
};
|
|
@@ -3366,7 +3366,7 @@ var require_constants = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
3366
3366
|
//#endregion
|
|
3367
3367
|
//#region node_modules/cbor/lib/utils.js
|
|
3368
3368
|
var require_utils = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
3369
|
-
const { Buffer: Buffer$
|
|
3369
|
+
const { Buffer: Buffer$5 } = __require("buffer");
|
|
3370
3370
|
const NoFilter = require_lib();
|
|
3371
3371
|
const stream$4 = __require("stream");
|
|
3372
3372
|
const { NUMBYTES, SHIFT32, BI, SYMS } = require_constants();
|
|
@@ -3392,12 +3392,12 @@ var require_utils = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
3392
3392
|
].every((f) => typeof s[f] === "function");
|
|
3393
3393
|
}
|
|
3394
3394
|
exports.isBufferish = function isBufferish(b) {
|
|
3395
|
-
return b && typeof b === "object" && (Buffer$
|
|
3395
|
+
return b && typeof b === "object" && (Buffer$5.isBuffer(b) || b instanceof Uint8Array || b instanceof Uint8ClampedArray || b instanceof ArrayBuffer || b instanceof DataView);
|
|
3396
3396
|
};
|
|
3397
3397
|
exports.bufferishToBuffer = function bufferishToBuffer(b) {
|
|
3398
|
-
if (Buffer$
|
|
3399
|
-
else if (ArrayBuffer.isView(b)) return Buffer$
|
|
3400
|
-
else if (b instanceof ArrayBuffer) return Buffer$
|
|
3398
|
+
if (Buffer$5.isBuffer(b)) return b;
|
|
3399
|
+
else if (ArrayBuffer.isView(b)) return Buffer$5.from(b.buffer, b.byteOffset, b.byteLength);
|
|
3400
|
+
else if (b instanceof ArrayBuffer) return Buffer$5.from(b);
|
|
3401
3401
|
return null;
|
|
3402
3402
|
};
|
|
3403
3403
|
exports.parseCBORint = function parseCBORint(ai, buf) {
|
|
@@ -3415,7 +3415,7 @@ var require_utils = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
3415
3415
|
}
|
|
3416
3416
|
};
|
|
3417
3417
|
exports.writeHalf = function writeHalf(buf, half) {
|
|
3418
|
-
const u32 = Buffer$
|
|
3418
|
+
const u32 = Buffer$5.allocUnsafe(4);
|
|
3419
3419
|
u32.writeFloatBE(half, 0);
|
|
3420
3420
|
const u = u32.readUInt32BE(0);
|
|
3421
3421
|
if ((u & 8191) !== 0) return false;
|
|
@@ -3447,7 +3447,7 @@ var require_utils = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
3447
3447
|
}
|
|
3448
3448
|
};
|
|
3449
3449
|
exports.hex = function hex(s) {
|
|
3450
|
-
return Buffer$
|
|
3450
|
+
return Buffer$5.from(s.replace(/^0x/, ""), "hex");
|
|
3451
3451
|
};
|
|
3452
3452
|
exports.bin = function bin(s) {
|
|
3453
3453
|
s = s.replace(/\s/g, "");
|
|
@@ -3459,7 +3459,7 @@ var require_utils = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
3459
3459
|
start = end;
|
|
3460
3460
|
end += 8;
|
|
3461
3461
|
}
|
|
3462
|
-
return Buffer$
|
|
3462
|
+
return Buffer$5.from(chunks);
|
|
3463
3463
|
};
|
|
3464
3464
|
exports.arrayEqual = function arrayEqual(a, b) {
|
|
3465
3465
|
if (a == null && b == null) return true;
|
|
@@ -3951,7 +3951,7 @@ var require_decoder = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
3951
3951
|
const utils = require_utils();
|
|
3952
3952
|
const NoFilter = require_lib();
|
|
3953
3953
|
const { MT, NUMBYTES, SYMS, BI } = require_constants();
|
|
3954
|
-
const { Buffer: Buffer$
|
|
3954
|
+
const { Buffer: Buffer$4 } = __require("buffer");
|
|
3955
3955
|
const COUNT = Symbol("count");
|
|
3956
3956
|
const MAJOR = Symbol("major type");
|
|
3957
3957
|
const ERROR = Symbol("error");
|
|
@@ -4300,7 +4300,7 @@ var require_decoder = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
4300
4300
|
if (this.max_depth >= 0 && depth > this.max_depth) throw new Error(`Maximum depth ${this.max_depth} exceeded`);
|
|
4301
4301
|
const [octet] = yield 1;
|
|
4302
4302
|
if (!this.running) {
|
|
4303
|
-
this.bs.unshift(Buffer$
|
|
4303
|
+
this.bs.unshift(Buffer$4.from([octet]));
|
|
4304
4304
|
throw new UnexpectedDataError(octet);
|
|
4305
4305
|
}
|
|
4306
4306
|
const mt = octet >> 5;
|
|
@@ -4348,7 +4348,7 @@ var require_decoder = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
4348
4348
|
case 0:
|
|
4349
4349
|
this.emit("start-string", mt, val, parent_major, parent_length);
|
|
4350
4350
|
if (mt === MT.UTF8_STRING) val = "";
|
|
4351
|
-
else val = this.preferWeb ? new Uint8Array(0) : Buffer$
|
|
4351
|
+
else val = this.preferWeb ? new Uint8Array(0) : Buffer$4.allocUnsafe(0);
|
|
4352
4352
|
break;
|
|
4353
4353
|
case -1:
|
|
4354
4354
|
this.emit("start", mt, SYMS.STREAM, parent_major, parent_length);
|
|
@@ -4491,7 +4491,7 @@ var require_commented = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
4491
4491
|
const Decoder = require_decoder();
|
|
4492
4492
|
const NoFilter = require_lib();
|
|
4493
4493
|
const { MT, NUMBYTES, SYMS } = require_constants();
|
|
4494
|
-
const { Buffer: Buffer$
|
|
4494
|
+
const { Buffer: Buffer$3 } = __require("buffer");
|
|
4495
4495
|
function plural(c) {
|
|
4496
4496
|
if (c > 1) return "s";
|
|
4497
4497
|
return "";
|
|
@@ -4773,7 +4773,7 @@ var require_commented = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
4773
4773
|
break;
|
|
4774
4774
|
}
|
|
4775
4775
|
const str = utils.cborValueToString(val, -Infinity);
|
|
4776
|
-
if (typeof val === "string" || Buffer$
|
|
4776
|
+
if (typeof val === "string" || Buffer$3.isBuffer(val)) {
|
|
4777
4777
|
if (val.length > 0) {
|
|
4778
4778
|
this.push(str);
|
|
4779
4779
|
this.push("\n");
|
|
@@ -5033,7 +5033,7 @@ var require_encoder = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
5033
5033
|
const NoFilter = require_lib();
|
|
5034
5034
|
const utils = require_utils();
|
|
5035
5035
|
const { MT, NUMBYTES, SHIFT32, SIMPLE, SYMS, TAG, BI } = require_constants();
|
|
5036
|
-
const { Buffer: Buffer$
|
|
5036
|
+
const { Buffer: Buffer$2 } = __require("buffer");
|
|
5037
5037
|
const HALF = MT.SIMPLE_FLOAT << 5 | NUMBYTES.TWO;
|
|
5038
5038
|
const FLOAT = MT.SIMPLE_FLOAT << 5 | NUMBYTES.FOUR;
|
|
5039
5039
|
const DOUBLE = MT.SIMPLE_FLOAT << 5 | NUMBYTES.EIGHT;
|
|
@@ -5041,11 +5041,11 @@ var require_encoder = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
5041
5041
|
const FALSE = MT.SIMPLE_FLOAT << 5 | SIMPLE.FALSE;
|
|
5042
5042
|
const UNDEFINED = MT.SIMPLE_FLOAT << 5 | SIMPLE.UNDEFINED;
|
|
5043
5043
|
const NULL = MT.SIMPLE_FLOAT << 5 | SIMPLE.NULL;
|
|
5044
|
-
const BREAK = Buffer$
|
|
5045
|
-
const BUF_NAN = Buffer$
|
|
5046
|
-
const BUF_INF_NEG = Buffer$
|
|
5047
|
-
const BUF_INF_POS = Buffer$
|
|
5048
|
-
const BUF_NEG_ZERO = Buffer$
|
|
5044
|
+
const BREAK = Buffer$2.from([255]);
|
|
5045
|
+
const BUF_NAN = Buffer$2.from("f97e00", "hex");
|
|
5046
|
+
const BUF_INF_NEG = Buffer$2.from("f9fc00", "hex");
|
|
5047
|
+
const BUF_INF_POS = Buffer$2.from("f97c00", "hex");
|
|
5048
|
+
const BUF_NEG_ZERO = Buffer$2.from("f98000", "hex");
|
|
5049
5049
|
/**
|
|
5050
5050
|
* Generate the CBOR for a value. If you are using this, you'll either need
|
|
5051
5051
|
* to call {@link Encoder.write} with a Buffer, or look into the internals of
|
|
@@ -5195,7 +5195,7 @@ var require_encoder = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
5195
5195
|
* @ignore
|
|
5196
5196
|
*/
|
|
5197
5197
|
_pushUInt8(val) {
|
|
5198
|
-
const b = Buffer$
|
|
5198
|
+
const b = Buffer$2.allocUnsafe(1);
|
|
5199
5199
|
b.writeUInt8(val, 0);
|
|
5200
5200
|
return this.push(b);
|
|
5201
5201
|
}
|
|
@@ -5205,7 +5205,7 @@ var require_encoder = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
5205
5205
|
* @ignore
|
|
5206
5206
|
*/
|
|
5207
5207
|
_pushUInt16BE(val) {
|
|
5208
|
-
const b = Buffer$
|
|
5208
|
+
const b = Buffer$2.allocUnsafe(2);
|
|
5209
5209
|
b.writeUInt16BE(val, 0);
|
|
5210
5210
|
return this.push(b);
|
|
5211
5211
|
}
|
|
@@ -5215,7 +5215,7 @@ var require_encoder = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
5215
5215
|
* @ignore
|
|
5216
5216
|
*/
|
|
5217
5217
|
_pushUInt32BE(val) {
|
|
5218
|
-
const b = Buffer$
|
|
5218
|
+
const b = Buffer$2.allocUnsafe(4);
|
|
5219
5219
|
b.writeUInt32BE(val, 0);
|
|
5220
5220
|
return this.push(b);
|
|
5221
5221
|
}
|
|
@@ -5225,7 +5225,7 @@ var require_encoder = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
5225
5225
|
* @ignore
|
|
5226
5226
|
*/
|
|
5227
5227
|
_pushFloatBE(val) {
|
|
5228
|
-
const b = Buffer$
|
|
5228
|
+
const b = Buffer$2.allocUnsafe(4);
|
|
5229
5229
|
b.writeFloatBE(val, 0);
|
|
5230
5230
|
return this.push(b);
|
|
5231
5231
|
}
|
|
@@ -5235,7 +5235,7 @@ var require_encoder = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
5235
5235
|
* @ignore
|
|
5236
5236
|
*/
|
|
5237
5237
|
_pushDoubleBE(val) {
|
|
5238
|
-
const b = Buffer$
|
|
5238
|
+
const b = Buffer$2.allocUnsafe(8);
|
|
5239
5239
|
b.writeDoubleBE(val, 0);
|
|
5240
5240
|
return this.push(b);
|
|
5241
5241
|
}
|
|
@@ -5265,7 +5265,7 @@ var require_encoder = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
5265
5265
|
*/
|
|
5266
5266
|
_pushFloat(obj) {
|
|
5267
5267
|
if (this.canonical) {
|
|
5268
|
-
const b2 = Buffer$
|
|
5268
|
+
const b2 = Buffer$2.allocUnsafe(2);
|
|
5269
5269
|
if (utils.writeHalf(b2, obj)) return this._pushUInt8(HALF) && this.push(b2);
|
|
5270
5270
|
}
|
|
5271
5271
|
if (Math.fround(obj) === obj) return this._pushUInt8(FLOAT) && this._pushFloatBE(obj);
|
|
@@ -5329,7 +5329,7 @@ var require_encoder = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
5329
5329
|
* @ignore
|
|
5330
5330
|
*/
|
|
5331
5331
|
_pushString(obj) {
|
|
5332
|
-
const len = Buffer$
|
|
5332
|
+
const len = Buffer$2.byteLength(obj, "utf8");
|
|
5333
5333
|
return this._pushInt(len, MT.UTF8_STRING) && this.push(obj, "utf8");
|
|
5334
5334
|
}
|
|
5335
5335
|
/**
|
|
@@ -5391,7 +5391,7 @@ var require_encoder = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
5391
5391
|
}
|
|
5392
5392
|
let str = obj.toString(16);
|
|
5393
5393
|
if (str.length % 2) str = `0${str}`;
|
|
5394
|
-
const buf = Buffer$
|
|
5394
|
+
const buf = Buffer$2.from(str, "hex");
|
|
5395
5395
|
return this._pushTag(tag) && Encoder._pushBuffer(this, buf);
|
|
5396
5396
|
}
|
|
5397
5397
|
/**
|
|
@@ -5675,7 +5675,7 @@ Call removeLoopDetectors before resuming.`);
|
|
|
5675
5675
|
8: 3
|
|
5676
5676
|
}[sz];
|
|
5677
5677
|
if (!gen._pushTag(typ)) return false;
|
|
5678
|
-
return Encoder._pushBuffer(gen, Buffer$
|
|
5678
|
+
return Encoder._pushBuffer(gen, Buffer$2.from(obj.buffer, obj.byteOffset, obj.byteLength));
|
|
5679
5679
|
}
|
|
5680
5680
|
/**
|
|
5681
5681
|
* @param {Encoder} gen Encoder.
|
|
@@ -5684,7 +5684,7 @@ Call removeLoopDetectors before resuming.`);
|
|
|
5684
5684
|
* @ignore
|
|
5685
5685
|
*/
|
|
5686
5686
|
static _pushArrayBuffer(gen, obj) {
|
|
5687
|
-
return Encoder._pushBuffer(gen, Buffer$
|
|
5687
|
+
return Encoder._pushBuffer(gen, Buffer$2.from(obj));
|
|
5688
5688
|
}
|
|
5689
5689
|
/**
|
|
5690
5690
|
* Encode the given object with indefinite length. There are apparently
|
|
@@ -5792,7 +5792,7 @@ Call removeLoopDetectors before resuming.`);
|
|
|
5792
5792
|
const enc = new Encoder(options);
|
|
5793
5793
|
enc.on("data", (buf) => bufs.push(buf));
|
|
5794
5794
|
enc.on("error", reject);
|
|
5795
|
-
enc.on("finish", () => resolve(Buffer$
|
|
5795
|
+
enc.on("finish", () => resolve(Buffer$2.concat(bufs)));
|
|
5796
5796
|
enc.pushAny(obj);
|
|
5797
5797
|
enc.end();
|
|
5798
5798
|
});
|
|
@@ -5820,7 +5820,7 @@ Call removeLoopDetectors before resuming.`);
|
|
|
5820
5820
|
Array: Encoder.pushArray,
|
|
5821
5821
|
Date: Encoder._pushDate,
|
|
5822
5822
|
Buffer: Encoder._pushBuffer,
|
|
5823
|
-
[Buffer$
|
|
5823
|
+
[Buffer$2.name]: Encoder._pushBuffer,
|
|
5824
5824
|
Map: Encoder._pushMap,
|
|
5825
5825
|
NoFilter: Encoder._pushNoFilter,
|
|
5826
5826
|
[NoFilter.name]: Encoder._pushNoFilter,
|
|
@@ -5849,7 +5849,7 @@ Call removeLoopDetectors before resuming.`);
|
|
|
5849
5849
|
//#endregion
|
|
5850
5850
|
//#region node_modules/cbor/lib/map.js
|
|
5851
5851
|
var require_map = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
5852
|
-
const { Buffer: Buffer$
|
|
5852
|
+
const { Buffer: Buffer$1 } = __require("buffer");
|
|
5853
5853
|
const encoder = require_encoder();
|
|
5854
5854
|
const decoder = require_decoder();
|
|
5855
5855
|
const { MT } = require_constants();
|
|
@@ -5979,10 +5979,10 @@ var require_map = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
5979
5979
|
encodeCBOR(gen) {
|
|
5980
5980
|
if (!gen._pushInt(this.size, MT.MAP)) return false;
|
|
5981
5981
|
if (gen.canonical) {
|
|
5982
|
-
const entries = Array.from(super.entries()).map((kv) => [Buffer$
|
|
5982
|
+
const entries = Array.from(super.entries()).map((kv) => [Buffer$1.from(kv[0], "base64"), kv[1]]);
|
|
5983
5983
|
entries.sort((a, b) => a[0].compare(b[0]));
|
|
5984
5984
|
for (const kv of entries) if (!(gen.push(kv[0]) && gen.pushAny(kv[1]))) return false;
|
|
5985
|
-
} else for (const kv of super.entries()) if (!(gen.push(Buffer$
|
|
5985
|
+
} else for (const kv of super.entries()) if (!(gen.push(Buffer$1.from(kv[0], "base64")) && gen.pushAny(kv[1]))) return false;
|
|
5986
5986
|
return true;
|
|
5987
5987
|
}
|
|
5988
5988
|
};
|
|
@@ -6051,7 +6051,7 @@ var require_objectRecorder = /* @__PURE__ */ __commonJSMin(((exports, module) =>
|
|
|
6051
6051
|
var require_sharedValueEncoder = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
6052
6052
|
const Encoder = require_encoder();
|
|
6053
6053
|
const ObjectRecorder = require_objectRecorder();
|
|
6054
|
-
const { Buffer
|
|
6054
|
+
const { Buffer } = __require("buffer");
|
|
6055
6055
|
module.exports = class SharedValueEncoder extends Encoder {
|
|
6056
6056
|
constructor(opts) {
|
|
6057
6057
|
super(opts);
|
|
@@ -6153,7 +6153,7 @@ var require_sharedValueEncoder = /* @__PURE__ */ __commonJSMin(((exports, module
|
|
|
6153
6153
|
const enc = new SharedValueEncoder(options);
|
|
6154
6154
|
enc.on("data", () => {});
|
|
6155
6155
|
enc.on("error", reject);
|
|
6156
|
-
enc.on("finish", () => resolve(Buffer
|
|
6156
|
+
enc.on("finish", () => resolve(Buffer.concat(bufs)));
|
|
6157
6157
|
enc.pushAny(obj);
|
|
6158
6158
|
enc.stopRecording();
|
|
6159
6159
|
enc.removeAllListeners("data");
|
|
@@ -6522,2230 +6522,193 @@ var CommentModeration = class extends Publication {
|
|
|
6522
6522
|
}
|
|
6523
6523
|
};
|
|
6524
6524
|
//#endregion
|
|
6525
|
-
//#region
|
|
6526
|
-
|
|
6527
|
-
|
|
6528
|
-
|
|
6529
|
-
|
|
6530
|
-
|
|
6531
|
-
|
|
6532
|
-
|
|
6533
|
-
|
|
6534
|
-
|
|
6535
|
-
|
|
6536
|
-
|
|
6537
|
-
|
|
6538
|
-
|
|
6539
|
-
|
|
6525
|
+
//#region dist/node/runtime/node/setup-kubo-http-routers.js
|
|
6526
|
+
function _mergeRouterConfigs(existingConfig, newConfig) {
|
|
6527
|
+
if (!existingConfig?.Routers) return newConfig;
|
|
6528
|
+
const existingRoutersByEndpoint = /* @__PURE__ */ new Map();
|
|
6529
|
+
Object.entries(existingConfig.Routers).forEach(([routerName, router]) => {
|
|
6530
|
+
if (router.Parameters?.Endpoint) existingRoutersByEndpoint.set(router.Parameters.Endpoint, {
|
|
6531
|
+
routerName,
|
|
6532
|
+
router
|
|
6533
|
+
});
|
|
6534
|
+
});
|
|
6535
|
+
const mergedRouters = { ...newConfig.Routers };
|
|
6536
|
+
Object.entries(newConfig.Routers).forEach(([newRouterName, newRouter]) => {
|
|
6537
|
+
if (newRouter.Parameters?.Endpoint) {
|
|
6538
|
+
const existing = existingRoutersByEndpoint.get(newRouter.Parameters.Endpoint);
|
|
6539
|
+
if (existing) mergedRouters[newRouterName] = {
|
|
6540
|
+
...existing.router,
|
|
6541
|
+
...newRouter,
|
|
6542
|
+
Parameters: {
|
|
6543
|
+
...existing.router.Parameters,
|
|
6544
|
+
...newRouter.Parameters
|
|
6545
|
+
}
|
|
6546
|
+
};
|
|
6547
|
+
}
|
|
6548
|
+
});
|
|
6549
|
+
return {
|
|
6550
|
+
...newConfig,
|
|
6551
|
+
Routers: mergedRouters
|
|
6540
6552
|
};
|
|
6541
|
-
|
|
6542
|
-
|
|
6543
|
-
|
|
6544
|
-
|
|
6545
|
-
|
|
6553
|
+
}
|
|
6554
|
+
async function _setProvideDhtSweepEnabledOnKuboNode(kuboClient, sweepEnabled, signal) {
|
|
6555
|
+
const log = logger_default("pkc-js:pkc:_init:retrySettingHttpRoutersOnIpfsNodes:setProvideDhtSweepEnabledOnIpfsNode");
|
|
6556
|
+
const configKey = "Provide.DHT.SweepEnabled";
|
|
6557
|
+
const url = `${kuboClient._clientOptions.url}/config?arg=${configKey}&arg=${JSON.stringify(sweepEnabled)}&json=true`;
|
|
6558
|
+
try {
|
|
6559
|
+
await fetch(url, {
|
|
6560
|
+
method: "POST",
|
|
6561
|
+
headers: kuboClient._clientOptions.headers,
|
|
6562
|
+
signal
|
|
6563
|
+
});
|
|
6564
|
+
} catch (e) {
|
|
6565
|
+
const error = new PKCError("ERR_FAILED_TO_SET_CONFIG_ON_KUBO_NODE", {
|
|
6566
|
+
fullUrl: url,
|
|
6567
|
+
actualError: e,
|
|
6568
|
+
kuboEndpoint: kuboClient._clientOptions.url,
|
|
6569
|
+
configKey,
|
|
6570
|
+
configValueToBeSet: sweepEnabled
|
|
6571
|
+
});
|
|
6572
|
+
log.error(e);
|
|
6573
|
+
throw error;
|
|
6546
6574
|
}
|
|
6547
|
-
|
|
6548
|
-
|
|
6575
|
+
log.trace("Succeeded in setting config key", configKey, "on node", kuboClient._clientOptions.url, "to be", sweepEnabled);
|
|
6576
|
+
}
|
|
6577
|
+
async function _setHttpRouterOptionsOnKuboNode(kuboClient, routingValue, signal) {
|
|
6578
|
+
const log = logger_default("pkc-js:pkc:_init:retrySettingHttpRoutersOnIpfsNodes:setHttpRouterOptionsOnIpfsNode");
|
|
6579
|
+
const routingKey = "Routing";
|
|
6580
|
+
let routingConfigBeforeChanging;
|
|
6581
|
+
try {
|
|
6582
|
+
routingConfigBeforeChanging = await kuboClient._client.config.get(routingKey, { signal });
|
|
6583
|
+
} catch (e) {
|
|
6584
|
+
const error = new PKCError("ERR_FAILED_TO_GET_CONFIG_ON_KUBO_NODE", {
|
|
6585
|
+
actualError: e,
|
|
6586
|
+
kuboEndpoint: kuboClient._clientOptions.url,
|
|
6587
|
+
configKey: routingKey
|
|
6588
|
+
});
|
|
6589
|
+
log.error(e);
|
|
6590
|
+
throw error;
|
|
6549
6591
|
}
|
|
6550
|
-
|
|
6551
|
-
|
|
6592
|
+
const mergedRoutingValue = _mergeRouterConfigs(routingConfigBeforeChanging, routingValue);
|
|
6593
|
+
const url = `${kuboClient._clientOptions.url}/config?arg=${routingKey}&arg=${JSON.stringify(mergedRoutingValue)}&json=true`;
|
|
6594
|
+
try {
|
|
6595
|
+
await fetch(url, {
|
|
6596
|
+
method: "POST",
|
|
6597
|
+
headers: kuboClient._clientOptions.headers,
|
|
6598
|
+
signal
|
|
6599
|
+
});
|
|
6600
|
+
} catch (e) {
|
|
6601
|
+
const error = new PKCError("ERR_FAILED_TO_SET_CONFIG_ON_KUBO_NODE", {
|
|
6602
|
+
fullUrl: url,
|
|
6603
|
+
actualError: e,
|
|
6604
|
+
kuboEndpoint: kuboClient._clientOptions.url,
|
|
6605
|
+
configKey: routingKey,
|
|
6606
|
+
configValueToBeSet: mergedRoutingValue
|
|
6607
|
+
});
|
|
6608
|
+
log.error(e);
|
|
6609
|
+
throw error;
|
|
6552
6610
|
}
|
|
6553
|
-
|
|
6554
|
-
|
|
6555
|
-
|
|
6556
|
-
|
|
6557
|
-
|
|
6558
|
-
|
|
6559
|
-
|
|
6560
|
-
return deepEqual(a, b);
|
|
6561
|
-
}
|
|
6611
|
+
log.trace("Succeeded in setting config key", routingKey, "on node", kuboClient._clientOptions.url, "to be", mergedRoutingValue);
|
|
6612
|
+
await _setProvideDhtSweepEnabledOnKuboNode(kuboClient, false, signal);
|
|
6613
|
+
const endpointsBefore = Object.values(routingConfigBeforeChanging?.Routers || {}).map((router) => router.Parameters?.Endpoint).filter((endpoint) => endpoint !== void 0);
|
|
6614
|
+
const endpointsAfter = Object.values(mergedRoutingValue.Routers).map((router) => router.Parameters?.Endpoint).filter((endpoint) => endpoint !== void 0);
|
|
6615
|
+
if (!t$3(endpointsBefore.sort(), endpointsAfter.sort())) {
|
|
6616
|
+
log("Config on kubo node has been changed. PKC-js will send shutdown command to node", kuboClient._clientOptions.url, "Clients of pkc-js should restart ipfs node");
|
|
6617
|
+
const shutdownUrl = `${kuboClient._clientOptions.url}/shutdown`;
|
|
6562
6618
|
try {
|
|
6563
|
-
|
|
6619
|
+
await fetch(shutdownUrl, {
|
|
6620
|
+
method: "POST",
|
|
6621
|
+
headers: kuboClient._clientOptions.headers,
|
|
6622
|
+
signal
|
|
6623
|
+
});
|
|
6564
6624
|
} catch (e) {
|
|
6565
|
-
|
|
6566
|
-
|
|
6567
|
-
|
|
6568
|
-
|
|
6569
|
-
|
|
6570
|
-
|
|
6571
|
-
|
|
6572
|
-
key = ka[i];
|
|
6573
|
-
if (!deepEqual(a[key], b[key])) return false;
|
|
6625
|
+
const error = new PKCError("ERR_FAILED_TO_SHUTDOWN_KUBO_NODE", {
|
|
6626
|
+
actualError: e,
|
|
6627
|
+
kuboEndpoint: kuboClient._clientOptions.url,
|
|
6628
|
+
shutdownUrl
|
|
6629
|
+
});
|
|
6630
|
+
log.error(e);
|
|
6631
|
+
throw error;
|
|
6574
6632
|
}
|
|
6575
|
-
return true;
|
|
6576
6633
|
}
|
|
6577
|
-
}
|
|
6578
|
-
|
|
6579
|
-
|
|
6580
|
-
|
|
6581
|
-
|
|
6582
|
-
const
|
|
6583
|
-
const
|
|
6584
|
-
const
|
|
6585
|
-
const
|
|
6586
|
-
|
|
6587
|
-
|
|
6588
|
-
|
|
6589
|
-
|
|
6590
|
-
(?:${v6seg}:){4}(?:(?::${v6seg}){0,1}:${v4}|(?::${v6seg}){1,3}|:)| // 1:2:3:4:: 1:2:3:4::6:7:8 1:2:3:4::8 1:2:3:4::6:7:1.2.3.4
|
|
6591
|
-
(?:${v6seg}:){3}(?:(?::${v6seg}){0,2}:${v4}|(?::${v6seg}){1,4}|:)| // 1:2:3:: 1:2:3::5:6:7:8 1:2:3::8 1:2:3::5:6:7:1.2.3.4
|
|
6592
|
-
(?:${v6seg}:){2}(?:(?::${v6seg}){0,3}:${v4}|(?::${v6seg}){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4
|
|
6593
|
-
(?:${v6seg}:){1}(?:(?::${v6seg}){0,4}:${v4}|(?::${v6seg}){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4
|
|
6594
|
-
(?::(?:(?::${v6seg}){0,5}:${v4}|(?::${v6seg}){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4
|
|
6595
|
-
)(?:%[0-9a-zA-Z]{1,})? // %eth0 %1
|
|
6596
|
-
`.replace(/\s*\/\/.*$/gm, "").replace(/\n/g, "").trim();
|
|
6597
|
-
const v46Exact = new RegExp(`(?:^${v4}$)|(?:^${v6}$)`);
|
|
6598
|
-
const v4exact = new RegExp(`^${v4}$`);
|
|
6599
|
-
const v6exact = new RegExp(`^${v6}$`);
|
|
6600
|
-
const ip = (options) => options && options.exact ? v46Exact : new RegExp(`(?:${b(options)}${v4}${b(options)})|(?:${b(options)}${v6}${b(options)})`, "g");
|
|
6601
|
-
ip.v4 = (options) => options && options.exact ? v4exact : new RegExp(`${b(options)}${v4}${b(options)}`, "g");
|
|
6602
|
-
ip.v6 = (options) => options && options.exact ? v6exact : new RegExp(`${b(options)}${v6}${b(options)}`, "g");
|
|
6603
|
-
module.exports = ip;
|
|
6604
|
-
}));
|
|
6605
|
-
//#endregion
|
|
6606
|
-
//#region node_modules/is2/package.json
|
|
6607
|
-
var require_package = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
6608
|
-
module.exports = {
|
|
6609
|
-
"name": "is2",
|
|
6610
|
-
"version": "2.0.9",
|
|
6611
|
-
"description": "A type checking library where each exported function returns either true or false and does not throw. Also added tests.",
|
|
6612
|
-
"license": "MIT",
|
|
6613
|
-
"tags": [
|
|
6614
|
-
"type",
|
|
6615
|
-
"check",
|
|
6616
|
-
"checker",
|
|
6617
|
-
"checking",
|
|
6618
|
-
"utilities",
|
|
6619
|
-
"network",
|
|
6620
|
-
"networking",
|
|
6621
|
-
"credit",
|
|
6622
|
-
"card",
|
|
6623
|
-
"validation"
|
|
6624
|
-
],
|
|
6625
|
-
"keywords": [
|
|
6626
|
-
"type",
|
|
6627
|
-
"check",
|
|
6628
|
-
"checker",
|
|
6629
|
-
"checking",
|
|
6630
|
-
"utilities",
|
|
6631
|
-
"network",
|
|
6632
|
-
"networking",
|
|
6633
|
-
"credit",
|
|
6634
|
-
"card",
|
|
6635
|
-
"validation"
|
|
6636
|
-
],
|
|
6637
|
-
"author": "Enrico Marino <enrico.marino@email.com>",
|
|
6638
|
-
"maintainers": "Edmond Meinfelder <edmond@stdarg.com>, Chris Oyler <christopher.oyler@gmail.com>",
|
|
6639
|
-
"homepage": "http://github.com/stdarg/is2",
|
|
6640
|
-
"repository": {
|
|
6641
|
-
"type": "git",
|
|
6642
|
-
"url": "git@github.com:stdarg/is2.git"
|
|
6643
|
-
},
|
|
6644
|
-
"bugs": { "url": "http://github.com/stdarg/is/issues" },
|
|
6645
|
-
"main": "./index.js",
|
|
6646
|
-
"scripts": { "test": "./node_modules/.bin/mocha -C --reporter list tests.js" },
|
|
6647
|
-
"engines": { "node": ">=v0.10.0" },
|
|
6648
|
-
"dependencies": {
|
|
6649
|
-
"deep-is": "^0.1.3",
|
|
6650
|
-
"ip-regex": "^4.1.0",
|
|
6651
|
-
"is-url": "^1.2.4"
|
|
6634
|
+
}
|
|
6635
|
+
async function setupKuboHttpRouters(pkc) {
|
|
6636
|
+
if (pkc.destroyed) return;
|
|
6637
|
+
if (!Array.isArray(pkc.kuboRpcClientsOptions) || pkc.kuboRpcClientsOptions.length <= 0) throw Error("need ipfs http client to be defined");
|
|
6638
|
+
if (!Array.isArray(pkc.httpRoutersOptions) || pkc.httpRoutersOptions.length <= 0) throw Error("Need http router options to defined");
|
|
6639
|
+
const log = logger_default("pkc-js:node:setupKuboHttpRouters");
|
|
6640
|
+
const httpRouterUrls = [...pkc.httpRoutersOptions].sort();
|
|
6641
|
+
const kuboClients = pkc.clients.kuboRpcClients;
|
|
6642
|
+
const parallelRouters = [];
|
|
6643
|
+
const httpRoutersConfig = {
|
|
6644
|
+
HttpRoutersParallel: {
|
|
6645
|
+
Type: "parallel",
|
|
6646
|
+
Parameters: { Routers: parallelRouters }
|
|
6652
6647
|
},
|
|
6653
|
-
|
|
6654
|
-
|
|
6655
|
-
|
|
6648
|
+
HttpRouterNotSupported: {
|
|
6649
|
+
Type: "http",
|
|
6650
|
+
Parameters: { Endpoint: "http://kubohttprouternotsupported" }
|
|
6656
6651
|
}
|
|
6657
6652
|
};
|
|
6658
|
-
|
|
6659
|
-
|
|
6660
|
-
|
|
6661
|
-
|
|
6662
|
-
|
|
6663
|
-
|
|
6664
|
-
|
|
6665
|
-
|
|
6666
|
-
|
|
6667
|
-
|
|
6668
|
-
|
|
6669
|
-
* Use two levels of REs to avoid REDOS.
|
|
6670
|
-
*/
|
|
6671
|
-
var protocolAndDomainRE = /^(?:\w+:)?\/\/(\S+)$/;
|
|
6672
|
-
var localhostDomainRE = /^localhost[\:?\d]*(?:[^\:?\d]\S*)?$/;
|
|
6673
|
-
var nonLocalhostDomainRE = /^[^\s\.]+\.\S{2,}$/;
|
|
6674
|
-
/**
|
|
6675
|
-
* Loosely validate a URL `string`.
|
|
6676
|
-
*
|
|
6677
|
-
* @param {String} string
|
|
6678
|
-
* @return {Boolean}
|
|
6679
|
-
*/
|
|
6680
|
-
function isUrl(string) {
|
|
6681
|
-
if (typeof string !== "string") return false;
|
|
6682
|
-
var match = string.match(protocolAndDomainRE);
|
|
6683
|
-
if (!match) return false;
|
|
6684
|
-
var everythingAfterProtocol = match[1];
|
|
6685
|
-
if (!everythingAfterProtocol) return false;
|
|
6686
|
-
if (localhostDomainRE.test(everythingAfterProtocol) || nonLocalhostDomainRE.test(everythingAfterProtocol)) return true;
|
|
6687
|
-
return false;
|
|
6653
|
+
for (const [i, httpRouterUrl] of httpRouterUrls.entries()) {
|
|
6654
|
+
const RouterName = `HttpRouter${i + 1}`;
|
|
6655
|
+
httpRoutersConfig[RouterName] = {
|
|
6656
|
+
Type: "http",
|
|
6657
|
+
Parameters: { Endpoint: httpRouterUrl }
|
|
6658
|
+
};
|
|
6659
|
+
parallelRouters[i] = {
|
|
6660
|
+
RouterName,
|
|
6661
|
+
IgnoreErrors: true,
|
|
6662
|
+
Timeout: "10s"
|
|
6663
|
+
};
|
|
6688
6664
|
}
|
|
6689
|
-
|
|
6690
|
-
|
|
6691
|
-
|
|
6692
|
-
|
|
6693
|
-
|
|
6694
|
-
|
|
6695
|
-
|
|
6696
|
-
|
|
6697
|
-
|
|
6698
|
-
|
|
6699
|
-
* Copyright(c) 2013,2014 Edmond Meinfelder <edmond@stdarg.com>
|
|
6700
|
-
* Copyright(c) 2011 Enrico Marino <enrico.marino@email.com>
|
|
6701
|
-
* MIT license
|
|
6702
|
-
*/
|
|
6703
|
-
var require_is2 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
6704
|
-
const owns = {}.hasOwnProperty;
|
|
6705
|
-
const toString = {}.toString;
|
|
6706
|
-
const is = exports;
|
|
6707
|
-
const deepIs = require_deep_is();
|
|
6708
|
-
const ipRegEx = require_ip_regex();
|
|
6709
|
-
is.version = require_package().version;
|
|
6710
|
-
/**
|
|
6711
|
-
* Tests if is is running under a browser.
|
|
6712
|
-
* @return {Boolean} true if the environment has process, process.version and process.versions.
|
|
6713
|
-
*/
|
|
6714
|
-
is.browser = function() {
|
|
6715
|
-
return !is.node() && typeof window !== "undefined" && toString.call(window) === "[object global]";
|
|
6716
|
-
};
|
|
6717
|
-
/**
|
|
6718
|
-
* Test if 'value' is defined.
|
|
6719
|
-
* Alias: def
|
|
6720
|
-
* @param {Any} value The value to test.
|
|
6721
|
-
* @return {Boolean} true if 'value' is defined, false otherwise.
|
|
6722
|
-
*/
|
|
6723
|
-
is.defined = function(value) {
|
|
6724
|
-
return typeof value !== "undefined";
|
|
6725
|
-
};
|
|
6726
|
-
is.def = is.defined;
|
|
6727
|
-
/**
|
|
6728
|
-
* Tests if is is running under node.js
|
|
6729
|
-
* @return {Boolean} true if the environment has process, process.version and process.versions.
|
|
6730
|
-
*/
|
|
6731
|
-
is.nodejs = function() {
|
|
6732
|
-
return process && process.hasOwnProperty("version") && process.hasOwnProperty("versions");
|
|
6733
|
-
};
|
|
6734
|
-
is.node = is.nodejs;
|
|
6735
|
-
/**
|
|
6736
|
-
* Test if 'value' is undefined.
|
|
6737
|
-
* Aliases: undef, udef
|
|
6738
|
-
* @param {Any} value value to test.
|
|
6739
|
-
* @return {Boolean} true if 'value' is undefined, false otherwise.
|
|
6740
|
-
*/
|
|
6741
|
-
is.undefined = function(value) {
|
|
6742
|
-
return value === void 0;
|
|
6743
|
-
};
|
|
6744
|
-
is.udef = is.undef = is.undefined;
|
|
6745
|
-
/**
|
|
6746
|
-
* Test if 'value' is an array.
|
|
6747
|
-
* Alias: ary, arry
|
|
6748
|
-
* @param {Any} value value to test.
|
|
6749
|
-
* @return {Boolean} true if 'value' is an array, false otherwise.
|
|
6750
|
-
*/
|
|
6751
|
-
is.array = function(value) {
|
|
6752
|
-
return "[object Array]" === toString.call(value);
|
|
6753
|
-
};
|
|
6754
|
-
is.arr = is.ary = is.arry = is.array;
|
|
6755
|
-
/**
|
|
6756
|
-
* Test if 'value' is an arraylike object (i.e. it has a length property with a valid value)
|
|
6757
|
-
* Aliases: arraylike, arryLike, aryLike
|
|
6758
|
-
* @param {Any} value value to test.
|
|
6759
|
-
* @return {Boolean} true if 'value' is an arguments object, false otherwise.
|
|
6760
|
-
*/
|
|
6761
|
-
is.arrayLike = function(value) {
|
|
6762
|
-
if (is.nullOrUndef(value)) return false;
|
|
6763
|
-
return value !== void 0 && owns.call(value, "length") && isFinite(value.length);
|
|
6764
|
-
};
|
|
6765
|
-
is.arrLike = is.arryLike = is.aryLike = is.arraylike = is.arrayLike;
|
|
6766
|
-
/**
|
|
6767
|
-
* Test if 'value' is an arguments object.
|
|
6768
|
-
* Alias: args
|
|
6769
|
-
* @param {Any} value value to test
|
|
6770
|
-
* @return {Boolean} true if 'value' is an arguments object, false otherwise
|
|
6771
|
-
*/
|
|
6772
|
-
is.arguments = function(value) {
|
|
6773
|
-
return "[object Arguments]" === toString.call(value);
|
|
6774
|
-
};
|
|
6775
|
-
is.args = is.arguments;
|
|
6776
|
-
/**
|
|
6777
|
-
* Test if 'value' is a boolean.
|
|
6778
|
-
* Alias: bool
|
|
6779
|
-
* @param {Any} value value to test.
|
|
6780
|
-
* @return {Boolean} true if 'value' is a boolean, false otherwise.
|
|
6781
|
-
*/
|
|
6782
|
-
is.boolean = function(value) {
|
|
6783
|
-
return "[object Boolean]" === toString.call(value);
|
|
6784
|
-
};
|
|
6785
|
-
is.bool = is.boolean;
|
|
6786
|
-
/**
|
|
6787
|
-
* Test if 'value' is an instance of Buffer.
|
|
6788
|
-
* Aliases: instOf, instanceof
|
|
6789
|
-
* @param {Any} value value to test.
|
|
6790
|
-
* @return {Boolean} true if 'value' is an instance of 'constructor'.
|
|
6791
|
-
*/
|
|
6792
|
-
is.buffer = function(value) {
|
|
6793
|
-
return is.nodejs() && Buffer && Buffer.hasOwnProperty("isBuffer") && Buffer.isBuffer(value);
|
|
6794
|
-
};
|
|
6795
|
-
is.buff = is.buf = is.buffer;
|
|
6796
|
-
/**
|
|
6797
|
-
* Test if 'value' is a date.
|
|
6798
|
-
* @param {Any} value value to test.
|
|
6799
|
-
* @return {Boolean} true if 'value' is a date, false otherwise.
|
|
6800
|
-
*/
|
|
6801
|
-
is.date = function(value) {
|
|
6802
|
-
return "[object Date]" === toString.call(value);
|
|
6803
|
-
};
|
|
6804
|
-
/**
|
|
6805
|
-
* Test if 'value' is an error object.
|
|
6806
|
-
* Alias: err
|
|
6807
|
-
* @param value value to test.
|
|
6808
|
-
* @return {Boolean} true if 'value' is an error object, false otherwise.
|
|
6809
|
-
*/
|
|
6810
|
-
is.error = function(value) {
|
|
6811
|
-
return "[object Error]" === toString.call(value);
|
|
6812
|
-
};
|
|
6813
|
-
is.err = is.error;
|
|
6814
|
-
/**
|
|
6815
|
-
* Test if 'value' is false.
|
|
6816
|
-
* @param {Any} value value to test.
|
|
6817
|
-
* @return {Boolean} true if 'value' is false, false otherwise
|
|
6818
|
-
*/
|
|
6819
|
-
is.false = function(value) {
|
|
6820
|
-
return value === false;
|
|
6821
|
-
};
|
|
6822
|
-
/**
|
|
6823
|
-
* Test if 'value' is a function or async function.
|
|
6824
|
-
* Alias: func
|
|
6825
|
-
* @param {Any} value value to test.
|
|
6826
|
-
* @return {Boolean} true if 'value' is a function, false otherwise.
|
|
6827
|
-
*/
|
|
6828
|
-
is.function = function(value) {
|
|
6829
|
-
return is.syncFunction(value) || is.asyncFunction(value);
|
|
6830
|
-
};
|
|
6831
|
-
is.fun = is.func = is.function;
|
|
6832
|
-
/**
|
|
6833
|
-
* Test if 'value' is an async function using `async () => {}` or `async function () {}`.
|
|
6834
|
-
* Alias: func
|
|
6835
|
-
* @param {Any} value value to test.
|
|
6836
|
-
* @return {Boolean} true if 'value' is a function, false otherwise.
|
|
6837
|
-
*/
|
|
6838
|
-
is.asyncFunction = function(value) {
|
|
6839
|
-
return "[object AsyncFunction]" === toString.call(value);
|
|
6840
|
-
};
|
|
6841
|
-
is.asyncFun = is.asyncFunc = is.asyncFunction;
|
|
6842
|
-
/**
|
|
6843
|
-
* Test if 'value' is a synchronous function.
|
|
6844
|
-
* Alias: syncFunc
|
|
6845
|
-
* @param {Any} value value to test.
|
|
6846
|
-
* @return {Boolean} true if 'value' is a function, false otherwise.
|
|
6847
|
-
*/
|
|
6848
|
-
is.syncFunction = function(value) {
|
|
6849
|
-
return "[object Function]" === toString.call(value);
|
|
6850
|
-
};
|
|
6851
|
-
is.syncFun = is.syncFunc = is.syncFunction;
|
|
6852
|
-
/**
|
|
6853
|
-
* Test if 'value' is null.
|
|
6854
|
-
* @param {Any} value to test.
|
|
6855
|
-
* @return {Boolean} true if 'value' is null, false otherwise.
|
|
6856
|
-
*/
|
|
6857
|
-
is.null = function(value) {
|
|
6858
|
-
return value === null;
|
|
6859
|
-
};
|
|
6860
|
-
/**
|
|
6861
|
-
* Test is 'value' is either null or undefined.
|
|
6862
|
-
* Alias: nullOrUndef
|
|
6863
|
-
* @param {Any} value value to test.
|
|
6864
|
-
* @return {Boolean} True if value is null or undefined, false otherwise.
|
|
6865
|
-
*/
|
|
6866
|
-
is.nullOrUndefined = function(value) {
|
|
6867
|
-
return value === null || typeof value === "undefined";
|
|
6868
|
-
};
|
|
6869
|
-
is.nullOrUndef = is.nullOrUndefined;
|
|
6870
|
-
/**
|
|
6871
|
-
* Test if 'value' is a number.
|
|
6872
|
-
* Alias: num
|
|
6873
|
-
* @param {Any} value to test.
|
|
6874
|
-
* @return {Boolean} true if 'value' is a number, false otherwise.
|
|
6875
|
-
*/
|
|
6876
|
-
is.number = function(value) {
|
|
6877
|
-
return "[object Number]" === toString.call(value);
|
|
6878
|
-
};
|
|
6879
|
-
is.num = is.number;
|
|
6880
|
-
/**
|
|
6881
|
-
* Test if 'value' is an object. Note: Arrays, RegExps, Date, Error, etc all return false.
|
|
6882
|
-
* Alias: obj
|
|
6883
|
-
* @param {Any} value to test.
|
|
6884
|
-
* @return {Boolean} true if 'value' is an object, false otherwise.
|
|
6885
|
-
*/
|
|
6886
|
-
is.object = function(value) {
|
|
6887
|
-
return "[object Object]" === toString.call(value);
|
|
6888
|
-
};
|
|
6889
|
-
is.obj = is.object;
|
|
6890
|
-
/**
|
|
6891
|
-
* Test if 'value' is a regular expression.
|
|
6892
|
-
* Alias: regexp
|
|
6893
|
-
* @param {Any} value to test.
|
|
6894
|
-
* @return {Boolean} true if 'value' is a regexp, false otherwise.
|
|
6895
|
-
*/
|
|
6896
|
-
is.regExp = function(value) {
|
|
6897
|
-
return "[object RegExp]" === toString.call(value);
|
|
6898
|
-
};
|
|
6899
|
-
is.re = is.regexp = is.regExp;
|
|
6900
|
-
/**
|
|
6901
|
-
* Test if 'value' is a string.
|
|
6902
|
-
* Alias: str
|
|
6903
|
-
* @param {Any} value to test.
|
|
6904
|
-
* @return {Boolean} true if 'value' is a string, false otherwise.
|
|
6905
|
-
*/
|
|
6906
|
-
is.string = function(value) {
|
|
6907
|
-
return "[object String]" === toString.call(value);
|
|
6908
|
-
};
|
|
6909
|
-
is.str = is.string;
|
|
6910
|
-
/**
|
|
6911
|
-
* Test if 'value' is true.
|
|
6912
|
-
* @param {Any} value to test.
|
|
6913
|
-
* @return {Boolean} true if 'value' is true, false otherwise.
|
|
6914
|
-
*/
|
|
6915
|
-
is.true = function(value) {
|
|
6916
|
-
return value === true;
|
|
6917
|
-
};
|
|
6918
|
-
/**
|
|
6919
|
-
* Test if 'value' is a uuid (v1-v5)
|
|
6920
|
-
* @param {Any} value to test.
|
|
6921
|
-
* @return {Boolean} true if 'value is a valid RFC4122 UUID. Case non-specific.
|
|
6922
|
-
*/
|
|
6923
|
-
var uuidRegExp = /* @__PURE__ */ new RegExp("[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}", "i");
|
|
6924
|
-
is.uuid = function(value) {
|
|
6925
|
-
return uuidRegExp.test(value);
|
|
6926
|
-
};
|
|
6927
|
-
/**
|
|
6928
|
-
* Test if 'value' is equal to 'other'. Works for objects and arrays and will do deep comparisions,
|
|
6929
|
-
* using recursion.
|
|
6930
|
-
* Alias: eq
|
|
6931
|
-
* @param {Any} value value.
|
|
6932
|
-
* @param {Any} other value to compare with.
|
|
6933
|
-
* @return {Boolean} true if 'value' is equal to 'other', false otherwise
|
|
6934
|
-
*/
|
|
6935
|
-
is.equal = function(value, other) {
|
|
6936
|
-
var type = toString.call(value);
|
|
6937
|
-
if (typeof value !== typeof other) return false;
|
|
6938
|
-
if (type !== toString.call(other)) return false;
|
|
6939
|
-
if ("[object Object]" === type || "[object Array]" === type) return deepIs(value, other);
|
|
6940
|
-
else if ("[object Function]" === type) return value.prototype === other.prototype;
|
|
6941
|
-
else if ("[object Date]" === type) return value.getTime() === other.getTime();
|
|
6942
|
-
return value === other;
|
|
6943
|
-
};
|
|
6944
|
-
is.objEquals = is.eq = is.equal;
|
|
6945
|
-
/**
|
|
6946
|
-
* JS Type definitions which cannot host values.
|
|
6947
|
-
* @api private
|
|
6948
|
-
*/
|
|
6949
|
-
var NON_HOST_TYPES = {
|
|
6950
|
-
"boolean": 1,
|
|
6951
|
-
"number": 1,
|
|
6952
|
-
"string": 1,
|
|
6953
|
-
"undefined": 1
|
|
6954
|
-
};
|
|
6955
|
-
/**
|
|
6956
|
-
* Test if 'key' in host is an object. To be hosted means host[value] is an object.
|
|
6957
|
-
* @param {Any} value The value to test.
|
|
6958
|
-
* @param {Any} host Host that may contain value.
|
|
6959
|
-
* @return {Boolean} true if 'value' is hosted by 'host', false otherwise.
|
|
6960
|
-
*/
|
|
6961
|
-
is.hosted = function(value, host) {
|
|
6962
|
-
if (is.nullOrUndef(value)) return false;
|
|
6963
|
-
var type = typeof host[value];
|
|
6964
|
-
return type === "object" ? !!host[value] : !NON_HOST_TYPES[type];
|
|
6965
|
-
};
|
|
6966
|
-
/**
|
|
6967
|
-
* Test if 'value' is an instance of 'constructor'.
|
|
6968
|
-
* Aliases: instOf, instanceof
|
|
6969
|
-
* @param {Any} value value to test.
|
|
6970
|
-
* @return {Boolean} true if 'value' is an instance of 'constructor'.
|
|
6971
|
-
*/
|
|
6972
|
-
is.instanceOf = function(value, constructor) {
|
|
6973
|
-
if (is.nullOrUndef(value) || is.nullOrUndef(constructor)) return false;
|
|
6974
|
-
return value instanceof constructor;
|
|
6665
|
+
const routingValue = {
|
|
6666
|
+
Type: "custom",
|
|
6667
|
+
Methods: {
|
|
6668
|
+
"find-providers": { RouterName: "HttpRoutersParallel" },
|
|
6669
|
+
provide: { RouterName: "HttpRoutersParallel" },
|
|
6670
|
+
"find-peers": { RouterName: "HttpRouterNotSupported" },
|
|
6671
|
+
"get-ipns": { RouterName: "HttpRouterNotSupported" },
|
|
6672
|
+
"put-ipns": { RouterName: "HttpRouterNotSupported" }
|
|
6673
|
+
},
|
|
6674
|
+
Routers: httpRoutersConfig
|
|
6975
6675
|
};
|
|
6976
|
-
|
|
6977
|
-
|
|
6978
|
-
|
|
6979
|
-
|
|
6980
|
-
|
|
6981
|
-
|
|
6982
|
-
|
|
6983
|
-
|
|
6984
|
-
|
|
6985
|
-
|
|
6986
|
-
|
|
6987
|
-
}
|
|
6988
|
-
|
|
6676
|
+
const settingOptionRetryOption = import_retry.operation({
|
|
6677
|
+
forever: true,
|
|
6678
|
+
factor: 2,
|
|
6679
|
+
maxTimeout: 60 * 1e3
|
|
6680
|
+
});
|
|
6681
|
+
const destroySignal = pkc._getDestroyAbortSignal();
|
|
6682
|
+
let removeDestroyListener;
|
|
6683
|
+
await new Promise((resolve) => {
|
|
6684
|
+
const onDestroy = () => {
|
|
6685
|
+
settingOptionRetryOption.stop();
|
|
6686
|
+
resolve();
|
|
6687
|
+
};
|
|
6688
|
+
if (destroySignal.aborted) {
|
|
6689
|
+
onDestroy();
|
|
6690
|
+
return;
|
|
6989
6691
|
}
|
|
6990
|
-
|
|
6991
|
-
|
|
6992
|
-
|
|
6993
|
-
|
|
6994
|
-
|
|
6995
|
-
|
|
6996
|
-
* @param {String} type The name of the type.
|
|
6997
|
-
* @return {Boolean} true if 'value' is an arguments object, false otherwise.
|
|
6998
|
-
*/
|
|
6999
|
-
is.type = function(value, type) {
|
|
7000
|
-
return typeof value === type;
|
|
7001
|
-
};
|
|
7002
|
-
is.a = is.type;
|
|
7003
|
-
/**
|
|
7004
|
-
* Test if 'value' is empty. To be empty means to be an array, object or string with nothing contained.
|
|
7005
|
-
* @param {Any} value value to test.
|
|
7006
|
-
* @return {Boolean} true if 'value' is empty, false otherwise.
|
|
7007
|
-
*/
|
|
7008
|
-
is.empty = function(value) {
|
|
7009
|
-
var type = toString.call(value);
|
|
7010
|
-
if ("[object Array]" === type || "[object Arguments]" === type) return value.length === 0;
|
|
7011
|
-
if ("[object Object]" === type) {
|
|
7012
|
-
for (var key in value) if (owns.call(value, key)) return false;
|
|
7013
|
-
return true;
|
|
7014
|
-
}
|
|
7015
|
-
if ("[object String]" === type) return value === "";
|
|
7016
|
-
return false;
|
|
7017
|
-
};
|
|
7018
|
-
/**
|
|
7019
|
-
* Test if 'value' is an arguments object that is empty.
|
|
7020
|
-
* Alias: args
|
|
7021
|
-
* @param {Any} value value to test
|
|
7022
|
-
* @return {Boolean} true if 'value' is an arguments object with no args, false otherwise
|
|
7023
|
-
*/
|
|
7024
|
-
is.emptyArguments = function(value) {
|
|
7025
|
-
return "[object Arguments]" === toString.call(value) && value.length === 0;
|
|
7026
|
-
};
|
|
7027
|
-
is.noArgs = is.emptyArgs = is.emptyArguments;
|
|
7028
|
-
/**
|
|
7029
|
-
* Test if 'value' is an array containing no entries.
|
|
7030
|
-
* Aliases: emptyArry, emptyAry
|
|
7031
|
-
* @param {Any} value The value to test.
|
|
7032
|
-
* @return {Boolean} true if 'value' is an array with no elemnets.
|
|
7033
|
-
*/
|
|
7034
|
-
is.emptyArray = function(value) {
|
|
7035
|
-
return "[object Array]" === toString.call(value) && value.length === 0;
|
|
7036
|
-
};
|
|
7037
|
-
is.emptyArry = is.emptyAry = is.emptyArray;
|
|
7038
|
-
/**
|
|
7039
|
-
* Test if 'value' is an empty array(like) object.
|
|
7040
|
-
* Aliases: arguents.empty, args.empty, ary.empty, arry.empty
|
|
7041
|
-
* @param {Any} value value to test.
|
|
7042
|
-
* @return {Boolean} true if 'value' is an empty array(like), false otherwise.
|
|
7043
|
-
*/
|
|
7044
|
-
is.emptyArrayLike = function(value) {
|
|
7045
|
-
return value.length === 0;
|
|
7046
|
-
};
|
|
7047
|
-
is.emptyArrLike = is.emptyArrayLike;
|
|
7048
|
-
/**
|
|
7049
|
-
* Test if 'value' is an empty string.
|
|
7050
|
-
* Alias: emptyStr
|
|
7051
|
-
* @param {Any} value to test.
|
|
7052
|
-
* @return {Boolean} true if 'value' is am empty string, false otherwise.
|
|
7053
|
-
*/
|
|
7054
|
-
is.emptyString = function(value) {
|
|
7055
|
-
return is.string(value) && value.length === 0;
|
|
7056
|
-
};
|
|
7057
|
-
is.emptyStr = is.emptyString;
|
|
7058
|
-
/**
|
|
7059
|
-
* Test if 'value' is an array containing at least 1 entry.
|
|
7060
|
-
* Aliases: nonEmptyArry, nonEmptyAry
|
|
7061
|
-
* @param {Any} value The value to test.
|
|
7062
|
-
* @return {Boolean} true if 'value' is an array with at least 1 value, false otherwise.
|
|
7063
|
-
*/
|
|
7064
|
-
is.nonEmptyArray = function(value) {
|
|
7065
|
-
return "[object Array]" === toString.call(value) && value.length > 0;
|
|
7066
|
-
};
|
|
7067
|
-
is.nonEmptyArr = is.nonEmptyArry = is.nonEmptyAry = is.nonEmptyArray;
|
|
7068
|
-
/**
|
|
7069
|
-
* Test if 'value' is an object with properties. Note: Arrays are objects.
|
|
7070
|
-
* Alias: nonEmptyObj
|
|
7071
|
-
* @param {Any} value to test.
|
|
7072
|
-
* @return {Boolean} true if 'value' is an object, false otherwise.
|
|
7073
|
-
*/
|
|
7074
|
-
is.nonEmptyObject = function(value) {
|
|
7075
|
-
return "[object Object]" === toString.call(value) && Object.keys(value).length > 0;
|
|
7076
|
-
};
|
|
7077
|
-
is.nonEmptyObj = is.nonEmptyObject;
|
|
7078
|
-
/**
|
|
7079
|
-
* Test if 'value' is an object with no properties. Note: Arrays are objects.
|
|
7080
|
-
* Alias: nonEmptyObj
|
|
7081
|
-
* @param {Any} value to test.
|
|
7082
|
-
* @return {Boolean} true if 'value' is an object, false otherwise.
|
|
7083
|
-
*/
|
|
7084
|
-
is.emptyObject = function(value) {
|
|
7085
|
-
return "[object Object]" === toString.call(value) && Object.keys(value).length === 0;
|
|
7086
|
-
};
|
|
7087
|
-
is.emptyObj = is.emptyObject;
|
|
7088
|
-
/**
|
|
7089
|
-
* Test if 'value' is a non-empty string.
|
|
7090
|
-
* Alias: nonEmptyStr
|
|
7091
|
-
* @param {Any} value to test.
|
|
7092
|
-
* @return {Boolean} true if 'value' is a non-empty string, false otherwise.
|
|
7093
|
-
*/
|
|
7094
|
-
is.nonEmptyString = function(value) {
|
|
7095
|
-
return is.string(value) && value.length > 0;
|
|
7096
|
-
};
|
|
7097
|
-
is.nonEmptyStr = is.nonEmptyString;
|
|
7098
|
-
/**
|
|
7099
|
-
* Test if 'value' is an even number.
|
|
7100
|
-
* @param {Number} value to test.
|
|
7101
|
-
* @return {Boolean} true if 'value' is an even number, false otherwise.
|
|
7102
|
-
*/
|
|
7103
|
-
is.even = function(value) {
|
|
7104
|
-
return "[object Number]" === toString.call(value) && value % 2 === 0;
|
|
7105
|
-
};
|
|
7106
|
-
/**
|
|
7107
|
-
* Test if 'value' is a decimal number.
|
|
7108
|
-
* Aliases: decimalNumber, decNum
|
|
7109
|
-
* @param {Any} value value to test.
|
|
7110
|
-
* @return {Boolean} true if 'value' is a decimal number, false otherwise.
|
|
7111
|
-
*/
|
|
7112
|
-
is.decimal = function(value) {
|
|
7113
|
-
return "[object Number]" === toString.call(value) && value % 1 !== 0;
|
|
7114
|
-
};
|
|
7115
|
-
is.dec = is.decNum = is.decimal;
|
|
7116
|
-
/**
|
|
7117
|
-
* Test if 'value' is an integer.
|
|
7118
|
-
* Alias: integer
|
|
7119
|
-
* @param {Any} value to test.
|
|
7120
|
-
* @return {Boolean} true if 'value' is an integer, false otherwise.
|
|
7121
|
-
*/
|
|
7122
|
-
is.integer = function(value) {
|
|
7123
|
-
return "[object Number]" === toString.call(value) && value % 1 === 0;
|
|
7124
|
-
};
|
|
7125
|
-
is.int = is.integer;
|
|
7126
|
-
/**
|
|
7127
|
-
* is.nan
|
|
7128
|
-
* Test if `value` is not a number.
|
|
7129
|
-
*
|
|
7130
|
-
* @param {Mixed} value value to test
|
|
7131
|
-
* @return {Boolean} true if `value` is not a number, false otherwise
|
|
7132
|
-
* @api public
|
|
7133
|
-
*/
|
|
7134
|
-
is.notANumber = function(value) {
|
|
7135
|
-
return !is.num(value) || value !== value;
|
|
7136
|
-
};
|
|
7137
|
-
is.nan = is.notANum = is.notANumber;
|
|
7138
|
-
/**
|
|
7139
|
-
* Test if 'value' is an odd number.
|
|
7140
|
-
* @param {Number} value to test.
|
|
7141
|
-
* @return {Boolean} true if 'value' is an odd number, false otherwise.
|
|
7142
|
-
*/
|
|
7143
|
-
is.odd = function(value) {
|
|
7144
|
-
return !is.decimal(value) && "[object Number]" === toString.call(value) && value % 2 !== 0;
|
|
7145
|
-
};
|
|
7146
|
-
is.oddNumber = is.oddNum = is.odd;
|
|
7147
|
-
/**
|
|
7148
|
-
* Test if 'value' is a positive number.
|
|
7149
|
-
* Alias: positiveNum, posNum
|
|
7150
|
-
* @param {Any} value to test.
|
|
7151
|
-
* @return {Boolean} true if 'value' is a number, false otherwise.
|
|
7152
|
-
*/
|
|
7153
|
-
is.positiveNumber = function(value) {
|
|
7154
|
-
return "[object Number]" === toString.call(value) && value > 0;
|
|
7155
|
-
};
|
|
7156
|
-
is.pos = is.positive = is.posNum = is.positiveNum = is.positiveNumber;
|
|
7157
|
-
/**
|
|
7158
|
-
* Test if 'value' is a negative number.
|
|
7159
|
-
* Aliases: negNum, negativeNum
|
|
7160
|
-
* @param {Any} value to test.
|
|
7161
|
-
* @return {Boolean} true if 'value' is a number, false otherwise.
|
|
7162
|
-
*/
|
|
7163
|
-
is.negativeNumber = function(value) {
|
|
7164
|
-
return "[object Number]" === toString.call(value) && value < 0;
|
|
7165
|
-
};
|
|
7166
|
-
is.neg = is.negNum = is.negativeNum = is.negativeNumber;
|
|
7167
|
-
/**
|
|
7168
|
-
* Test if 'value' is a negative integer.
|
|
7169
|
-
* Aliases: negInt, negativeInteger
|
|
7170
|
-
* @param {Any} value to test.
|
|
7171
|
-
* @return {Boolean} true if 'value' is a negative integer, false otherwise.
|
|
7172
|
-
*/
|
|
7173
|
-
is.negativeInteger = function(value) {
|
|
7174
|
-
return "[object Number]" === toString.call(value) && value % 1 === 0 && value < 0;
|
|
7175
|
-
};
|
|
7176
|
-
is.negativeInt = is.negInt = is.negativeInteger;
|
|
7177
|
-
/**
|
|
7178
|
-
* Test if 'value' is a positive integer.
|
|
7179
|
-
* Alias: posInt
|
|
7180
|
-
* @param {Any} value to test.
|
|
7181
|
-
* @return {Boolean} true if 'value' is a positive integer, false otherwise.
|
|
7182
|
-
*/
|
|
7183
|
-
is.positiveInteger = function(value) {
|
|
7184
|
-
return "[object Number]" === toString.call(value) && value % 1 === 0 && value > 0;
|
|
7185
|
-
};
|
|
7186
|
-
is.posInt = is.positiveInt = is.positiveInteger;
|
|
7187
|
-
/**
|
|
7188
|
-
* Test if 'value' is divisible by 'n'.
|
|
7189
|
-
* Alias: divisBy
|
|
7190
|
-
* @param {Number} value value to test.
|
|
7191
|
-
* @param {Number} n dividend.
|
|
7192
|
-
* @return {Boolean} true if 'value' is divisible by 'n', false otherwise.
|
|
7193
|
-
*/
|
|
7194
|
-
is.divisibleBy = function(value, n) {
|
|
7195
|
-
if (value === 0) return false;
|
|
7196
|
-
return "[object Number]" === toString.call(value) && n !== 0 && value % n === 0;
|
|
7197
|
-
};
|
|
7198
|
-
is.divBy = is.divisBy = is.divisibleBy;
|
|
7199
|
-
/**
|
|
7200
|
-
* Test if 'value' is greater than or equal to 'other'.
|
|
7201
|
-
* Aliases: greaterOrEq, greaterOrEqual
|
|
7202
|
-
* @param {Number} value value to test.
|
|
7203
|
-
* @param {Number} other value to compare with.
|
|
7204
|
-
* @return {Boolean} true, if value is greater than or equal to other, false otherwise.
|
|
7205
|
-
*/
|
|
7206
|
-
is.greaterOrEqualTo = function(value, other) {
|
|
7207
|
-
return value >= other;
|
|
7208
|
-
};
|
|
7209
|
-
is.greaterOrEqual = is.ge = is.greaterOrEqualTo;
|
|
7210
|
-
/**
|
|
7211
|
-
* Test if 'value' is greater than 'other'.
|
|
7212
|
-
* Aliases: greaterThan
|
|
7213
|
-
* @param {Number} value value to test.
|
|
7214
|
-
* @param {Number} other value to compare with.
|
|
7215
|
-
* @return {Boolean} true, if value is greater than other, false otherwise.
|
|
7216
|
-
*/
|
|
7217
|
-
is.greaterThan = function(value, other) {
|
|
7218
|
-
return value > other;
|
|
7219
|
-
};
|
|
7220
|
-
is.gt = is.greaterThan;
|
|
7221
|
-
/**
|
|
7222
|
-
* Test if 'value' is less than or equal to 'other'.
|
|
7223
|
-
* Alias: lessThanOrEq, lessThanOrEqual
|
|
7224
|
-
* @param {Number} value value to test
|
|
7225
|
-
* @param {Number} other value to compare with
|
|
7226
|
-
* @return {Boolean} true, if 'value' is less than or equal to 'other', false otherwise.
|
|
7227
|
-
*/
|
|
7228
|
-
is.lessThanOrEqualTo = function(value, other) {
|
|
7229
|
-
return value <= other;
|
|
7230
|
-
};
|
|
7231
|
-
is.lessThanOrEq = is.lessThanOrEqual = is.le = is.lessThanOrEqualTo;
|
|
7232
|
-
/**
|
|
7233
|
-
* Test if 'value' is less than 'other'.
|
|
7234
|
-
* Alias: lessThan
|
|
7235
|
-
* @param {Number} value value to test
|
|
7236
|
-
* @param {Number} other value to compare with
|
|
7237
|
-
* @return {Boolean} true, if 'value' is less than 'other', false otherwise.
|
|
7238
|
-
*/
|
|
7239
|
-
is.lessThan = function(value, other) {
|
|
7240
|
-
return value < other;
|
|
7241
|
-
};
|
|
7242
|
-
is.lt = is.lessThan;
|
|
7243
|
-
/**
|
|
7244
|
-
* Test if 'value' is greater than 'others' values.
|
|
7245
|
-
* Alias: max
|
|
7246
|
-
* @param {Number} value value to test.
|
|
7247
|
-
* @param {Array} others values to compare with.
|
|
7248
|
-
* @return {Boolean} true if 'value' is greater than 'others' values.
|
|
7249
|
-
*/
|
|
7250
|
-
is.maximum = function(value, others) {
|
|
7251
|
-
if (!is.arrayLike(others) || !is.number(value)) return false;
|
|
7252
|
-
var len = others.length;
|
|
7253
|
-
while (--len > -1) if (value < others[len]) return false;
|
|
7254
|
-
return true;
|
|
7255
|
-
};
|
|
7256
|
-
is.max = is.maximum;
|
|
7257
|
-
/**
|
|
7258
|
-
* Test if 'value' is less than 'others' values.
|
|
7259
|
-
* Alias: min
|
|
7260
|
-
* @param {Number} value value to test.
|
|
7261
|
-
* @param {Array} others values to compare with.
|
|
7262
|
-
* @return {Boolean} true if 'value' is less than 'others' values.
|
|
7263
|
-
*/
|
|
7264
|
-
is.minimum = function(value, others) {
|
|
7265
|
-
if (!is.arrayLike(others) || !is.number(value)) return false;
|
|
7266
|
-
var len = others.length;
|
|
7267
|
-
while (--len > -1) if (value > others[len]) return false;
|
|
7268
|
-
return true;
|
|
7269
|
-
};
|
|
7270
|
-
is.min = is.minimum;
|
|
7271
|
-
/**
|
|
7272
|
-
* Test if 'value' is within 'start' and 'finish'.
|
|
7273
|
-
* Alias: withIn
|
|
7274
|
-
* @param {Number} value value to test.
|
|
7275
|
-
* @param {Number} start lower bound.
|
|
7276
|
-
* @param {Number} finish upper bound.
|
|
7277
|
-
* @return {Boolean} true if 'value' is is within 'start' and 'finish', false otherwise.
|
|
7278
|
-
*/
|
|
7279
|
-
is.within = function(value, start, finish) {
|
|
7280
|
-
return value >= start && value <= finish;
|
|
7281
|
-
};
|
|
7282
|
-
is.withIn = is.within;
|
|
7283
|
-
/**
|
|
7284
|
-
* Test if 'value' is within 'precision' decimal places from 'comparitor'.
|
|
7285
|
-
* Alias: closish, near.
|
|
7286
|
-
* @param {Number} value value to test
|
|
7287
|
-
* @param {Number} comparitor value to test 'value' against
|
|
7288
|
-
* @param {Number} precision number of decimals to compare floating points, defaults to 2
|
|
7289
|
-
* @return {Boolean} true if 'value' is within 'precision' decimal places from 'comparitor', false otherwise.
|
|
7290
|
-
*/
|
|
7291
|
-
is.prettyClose = function(value, comparitor, precision) {
|
|
7292
|
-
if (!is.number(value) || !is.number(comparitor)) return false;
|
|
7293
|
-
if (is.defined(precision) && !is.posInt(precision)) return false;
|
|
7294
|
-
if (is.undefined(precision)) precision = 2;
|
|
7295
|
-
return value.toFixed(precision) === comparitor.toFixed(precision);
|
|
7296
|
-
};
|
|
7297
|
-
is.closish = is.near = is.prettyClose;
|
|
7298
|
-
/**
|
|
7299
|
-
* Test if a value is a valid DNS address. eg www.stdarg.com is true while
|
|
7300
|
-
* 127.0.0.1 is false.
|
|
7301
|
-
* @param {Any} value to test if a DNS address.
|
|
7302
|
-
* @return {Boolean} true if a DNS address, false otherwise.
|
|
7303
|
-
* DNS Address is made up of labels separated by '.'
|
|
7304
|
-
* Each label must be between 1 and 63 characters long
|
|
7305
|
-
* The entire hostname (including the delimiting dots) has a maximum of 255 characters.
|
|
7306
|
-
* Hostname may not contain other characters, such as the underscore character (_)
|
|
7307
|
-
* other DNS names may contain the underscore.
|
|
7308
|
-
*/
|
|
7309
|
-
is.dnsAddress = function(value) {
|
|
7310
|
-
if (!is.nonEmptyStr(value)) return false;
|
|
7311
|
-
if (value.length > 255) return false;
|
|
7312
|
-
if (numbersLabel.test(value)) return false;
|
|
7313
|
-
if (!dnsLabel.test(value)) return false;
|
|
7314
|
-
return true;
|
|
7315
|
-
};
|
|
7316
|
-
is.dnsAddr = is.dns = is.dnsAddress;
|
|
7317
|
-
var dnsLabel = /^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])(\.([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9]))*$/;
|
|
7318
|
-
var numbersLabel = /^([0-9]|[0-9][0-9\-]{0,61}[0-9])(\.([0-9]|[0-9][0-9\-]{0,61}[0-9]))*$/;
|
|
7319
|
-
/**
|
|
7320
|
-
* Test if value is a valid email address.
|
|
7321
|
-
* @param {Any} value to test if an email address.
|
|
7322
|
-
* @return {Boolean} true if an email address, false otherwise.
|
|
7323
|
-
*/
|
|
7324
|
-
is.emailAddress = function(value) {
|
|
7325
|
-
if (!is.nonEmptyStr(value)) return false;
|
|
7326
|
-
return emailRegexp.test(value);
|
|
7327
|
-
};
|
|
7328
|
-
is.email = is.emailAddr = is.emailAddress;
|
|
7329
|
-
var emailRegexp = /^([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x22([^\x0d\x22\x5c\x80-\xff]|\x5c[\x00-\x7f])*\x22)(\x2e([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x22([^\x0d\x22\x5c\x80-\xff]|\x5c[\x00-\x7f])*\x22))*\x40([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x5b([^\x0d\x5b-\x5d\x80-\xff]|\x5c[\x00-\x7f])*\x5d)(\x2e([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x5b([^\x0d\x5b-\x5d\x80-\xff]|\x5c[\x00-\x7f])*\x5d))*$/;
|
|
7330
|
-
/**
|
|
7331
|
-
* Test if a value is either an IPv4 numeric IP address.
|
|
7332
|
-
* The rules are:
|
|
7333
|
-
* must be a string
|
|
7334
|
-
* length must be 15 characters or less
|
|
7335
|
-
* There must be four octets separated by a '.'
|
|
7336
|
-
* No octet can be less than 0 or greater than 255.
|
|
7337
|
-
* @param {Any} value to test if an ip address.
|
|
7338
|
-
* @return {Boolean} true if an ip address, false otherwise.
|
|
7339
|
-
*/
|
|
7340
|
-
is.ipv4Address = function(value) {
|
|
7341
|
-
if (!is.nonEmptyStr(value)) return false;
|
|
7342
|
-
if (value.length > 15) return false;
|
|
7343
|
-
var octets = value.split(".");
|
|
7344
|
-
if (!is.array(octets) || octets.length !== 4) return false;
|
|
7345
|
-
for (var i = 0; i < octets.length; i++) {
|
|
7346
|
-
var val = parseInt(octets[i], 10);
|
|
7347
|
-
if (isNaN(val)) return false;
|
|
7348
|
-
if (val < 0 || val > 255) return false;
|
|
7349
|
-
}
|
|
7350
|
-
return true;
|
|
7351
|
-
};
|
|
7352
|
-
is.ipv4 = is.ipv4Addr = is.ipv4Address;
|
|
7353
|
-
/**
|
|
7354
|
-
* Test if a value is either an IPv6 numeric IP address.
|
|
7355
|
-
* @param {Any} value to test if an ip address.
|
|
7356
|
-
* @return {Boolean} true if an ip address, false otherwise.
|
|
7357
|
-
*/
|
|
7358
|
-
is.ipv6Address = function(value) {
|
|
7359
|
-
if (!is.nonEmptyStr(value)) return false;
|
|
7360
|
-
return ipRegEx.v6({ extract: true }).test(value);
|
|
7361
|
-
};
|
|
7362
|
-
is.ipv6 = is.ipv6Addr = is.ipv6Address;
|
|
7363
|
-
/**
|
|
7364
|
-
* Test if a value is either an IPv4 or IPv6 numeric IP address.
|
|
7365
|
-
* @param {Any} value to test if an ip address.
|
|
7366
|
-
* @return {Boolean} true if an ip address, false otherwise.
|
|
7367
|
-
*/
|
|
7368
|
-
is.ipAddress = function(value) {
|
|
7369
|
-
if (!is.nonEmptyStr(value)) return false;
|
|
7370
|
-
return is.ipv4Address(value) || is.ipv6Address(value);
|
|
7371
|
-
};
|
|
7372
|
-
is.ip = is.ipAddr = is.ipAddress;
|
|
7373
|
-
/**
|
|
7374
|
-
* Test is a value is a valid ipv4, ipv6 or DNS name.
|
|
7375
|
-
* Aliases: host, hostAddr, hostAddress.
|
|
7376
|
-
* @param {Any} value to test if a host address.
|
|
7377
|
-
* @return {Boolean} true if a host address, false otherwise.
|
|
7378
|
-
*/
|
|
7379
|
-
is.hostAddress = function(value) {
|
|
7380
|
-
if (!is.nonEmptyStr(value)) return false;
|
|
7381
|
-
return is.dns(value) || is.ipv4(value) || is.ipv6(value);
|
|
7382
|
-
};
|
|
7383
|
-
is.host = is.hostIp = is.hostAddr = is.hostAddress;
|
|
7384
|
-
/**
|
|
7385
|
-
* Test if a number is a valid TCP port
|
|
7386
|
-
* @param {Any} value to test if its a valid TCP port
|
|
7387
|
-
*/
|
|
7388
|
-
is.port = function(value) {
|
|
7389
|
-
if (!is.num(value) || is.negativeInt(value) || value > 65535) return false;
|
|
7390
|
-
return true;
|
|
7391
|
-
};
|
|
7392
|
-
/**
|
|
7393
|
-
* Test if a number is a valid TCP port in the range 0-1023.
|
|
7394
|
-
* Alias: is.sysPort.
|
|
7395
|
-
* @param {Any} value to test if its a valid TCP port
|
|
7396
|
-
*/
|
|
7397
|
-
is.systemPort = function(value) {
|
|
7398
|
-
if (is.port(value) && value < 1024) return true;
|
|
7399
|
-
return false;
|
|
7400
|
-
};
|
|
7401
|
-
is.sysPort = is.systemPort;
|
|
7402
|
-
/**
|
|
7403
|
-
* Test if a number is a valid TCP port in the range 1024-65535.
|
|
7404
|
-
* @param {Any} value to test if its a valid TCP port
|
|
7405
|
-
*/
|
|
7406
|
-
is.userPort = function(value) {
|
|
7407
|
-
if (is.port(value) && value > 1023) return true;
|
|
7408
|
-
return false;
|
|
7409
|
-
};
|
|
7410
|
-
/**
|
|
7411
|
-
* Test if a string is a credit card.
|
|
7412
|
-
* From http://en.wikipedia.org/wiki/Luhn_algorithm
|
|
7413
|
-
* @param {String} value to test if a credit card.
|
|
7414
|
-
* @return true if the string is the correct format, false otherwise
|
|
7415
|
-
*/
|
|
7416
|
-
is.creditCardNumber = function(str) {
|
|
7417
|
-
if (!is.str(str)) return false;
|
|
7418
|
-
var ary = str.split("");
|
|
7419
|
-
var i, cnt;
|
|
7420
|
-
for (i = ary.length - 1, cnt = 1; i > -1; i--, cnt++) if (cnt % 2 === 0) ary[i] *= 2;
|
|
7421
|
-
str = ary.join("");
|
|
7422
|
-
var sum = 0;
|
|
7423
|
-
for (i = 0; i < str.length; i++) sum += Math.floor(str[i]);
|
|
7424
|
-
return sum % 10 === 0;
|
|
7425
|
-
};
|
|
7426
|
-
is.creditCard = is.creditCardNum = is.creditCardNumber;
|
|
7427
|
-
/**
|
|
7428
|
-
* Test if card number is an American Express card.
|
|
7429
|
-
* @param {String} the credit card number string to test.
|
|
7430
|
-
* @return true if the string is the correct format, false otherwise
|
|
7431
|
-
*/
|
|
7432
|
-
is.americanExpressCardNumber = function(str) {
|
|
7433
|
-
if (!is.str(str) || str.length !== 15) return false;
|
|
7434
|
-
var prefix = Math.floor(str.slice(0, 2));
|
|
7435
|
-
if (prefix !== 34 && prefix !== 37) return false;
|
|
7436
|
-
if (!is.creditCardNumber(str)) return false;
|
|
7437
|
-
return true;
|
|
7438
|
-
};
|
|
7439
|
-
is.amexCard = is.amexCardNum = is.americanExpressCardNumber;
|
|
7440
|
-
/**
|
|
7441
|
-
* Test if card number is a China UnionPay card.
|
|
7442
|
-
* @param {String} the credit card number string to test.
|
|
7443
|
-
* @return true if the string is the correct format, false otherwise
|
|
7444
|
-
*/
|
|
7445
|
-
is.chinaUnionPayCardNumber = function(str) {
|
|
7446
|
-
if (!is.str(str) || str.length < 16 && str.length > 19) return false;
|
|
7447
|
-
var prefix = Math.floor(str.slice(0, 2));
|
|
7448
|
-
if (prefix !== 62 && prefix !== 88) return false;
|
|
7449
|
-
return true;
|
|
7450
|
-
};
|
|
7451
|
-
is.chinaUnion = is.chinaUnionPayCard = is.chinaUnionPayCardNumber;
|
|
7452
|
-
/**
|
|
7453
|
-
* Test if card number is a Diner's Club Carte Blance card.
|
|
7454
|
-
* @param {String} the credit card number string to test.
|
|
7455
|
-
* @return true if the string is the correct format, false otherwise
|
|
7456
|
-
*/
|
|
7457
|
-
is.dinersClubCarteBlancheCardNumber = function(str) {
|
|
7458
|
-
if (!is.str(str) || str.length !== 14) return false;
|
|
7459
|
-
var prefix = Math.floor(str.slice(0, 3));
|
|
7460
|
-
if (prefix < 300 || prefix > 305) return false;
|
|
7461
|
-
if (!is.creditCardNumber(str)) return false;
|
|
7462
|
-
return true;
|
|
7463
|
-
};
|
|
7464
|
-
is.dinersClubCB = is.dinersClubCarteBlancheCard = is.dinersClubCarteBlancheCardNumber;
|
|
7465
|
-
/**
|
|
7466
|
-
* Test if card number is a Diner's Club International card.
|
|
7467
|
-
* @param {String} the credit card number string to test.
|
|
7468
|
-
* @return true if the string is the correct format, false otherwise
|
|
7469
|
-
*/
|
|
7470
|
-
is.dinersClubInternationalCardNumber = function(str) {
|
|
7471
|
-
if (!is.str(str) || str.length !== 14) return false;
|
|
7472
|
-
var prefix = Math.floor(str.slice(0, 3));
|
|
7473
|
-
var prefix2 = Math.floor(str.slice(0, 2));
|
|
7474
|
-
if ((prefix < 300 || prefix > 305) && prefix !== 309 && prefix2 !== 36 && (prefix2 < 38 || prefix2 > 39)) return false;
|
|
7475
|
-
if (!is.creditCardNumber(str)) return false;
|
|
7476
|
-
return true;
|
|
7477
|
-
};
|
|
7478
|
-
is.dinersClubInt = is.dinersClubInternationalCard = is.dinersClubInternationalCardNumber;
|
|
7479
|
-
/**
|
|
7480
|
-
* Test if card number is a Diner's Club USA & CA card.
|
|
7481
|
-
* @param {String} the credit card number string to test.
|
|
7482
|
-
* @return true if the string is the correct format, false otherwise
|
|
7483
|
-
*/
|
|
7484
|
-
is.dinersClubUSACanadaCardNumber = function(str) {
|
|
7485
|
-
if (!is.str(str) || str.length !== 16) return false;
|
|
7486
|
-
var prefix = Math.floor(str.slice(0, 2));
|
|
7487
|
-
if (prefix !== 54 && prefix !== 55) return false;
|
|
7488
|
-
if (!is.creditCardNumber(str)) return false;
|
|
7489
|
-
return true;
|
|
7490
|
-
};
|
|
7491
|
-
is.dinersClub = is.dinersClubUSACanCard = is.dinersClubUSACanadaCardNumber;
|
|
7492
|
-
/**
|
|
7493
|
-
* Test if card number is a Diner's Club USA/CA card.
|
|
7494
|
-
* @param {String} the credit card number string to test.
|
|
7495
|
-
* @return true if the string is the correct format, false otherwise
|
|
7496
|
-
*/
|
|
7497
|
-
is.discoverCardNumber = function(str) {
|
|
7498
|
-
if (!is.str(str) || str.length !== 16) return false;
|
|
7499
|
-
var prefix = Math.floor(str.slice(0, 6));
|
|
7500
|
-
var prefix2 = Math.floor(str.slice(0, 3));
|
|
7501
|
-
if (str.slice(0, 4) !== "6011" && (prefix < 622126 || prefix > 622925) && (prefix2 < 644 || prefix2 > 649) && str.slice(0, 2) !== "65") return false;
|
|
7502
|
-
if (!is.creditCardNumber(str)) return false;
|
|
7503
|
-
return true;
|
|
7504
|
-
};
|
|
7505
|
-
is.discover = is.discoverCard = is.discoverCardNumber;
|
|
7506
|
-
/**
|
|
7507
|
-
* Test if card number is an InstaPayment card number
|
|
7508
|
-
* @param {String} the credit card number string to test.
|
|
7509
|
-
* @return true if the string is the correct format, false otherwise
|
|
7510
|
-
*/
|
|
7511
|
-
is.instaPaymentCardNumber = function(str) {
|
|
7512
|
-
if (!is.str(str) || str.length !== 16) return false;
|
|
7513
|
-
var prefix = Math.floor(str.slice(0, 3));
|
|
7514
|
-
if (prefix < 637 || prefix > 639) return false;
|
|
7515
|
-
if (!is.creditCardNumber(str)) return false;
|
|
7516
|
-
return true;
|
|
7517
|
-
};
|
|
7518
|
-
is.instaPayment = is.instaPaymentCardNumber;
|
|
7519
|
-
/**
|
|
7520
|
-
* Test if card number is a JCB card number
|
|
7521
|
-
* @param {String} the credit card number string to test.
|
|
7522
|
-
* @return true if the string is the correct format, false otherwise
|
|
7523
|
-
*/
|
|
7524
|
-
is.jcbCardNumber = function(str) {
|
|
7525
|
-
if (!is.str(str) || str.length !== 16) return false;
|
|
7526
|
-
var prefix = Math.floor(str.slice(0, 4));
|
|
7527
|
-
if (prefix < 3528 || prefix > 3589) return false;
|
|
7528
|
-
if (!is.creditCardNumber(str)) return false;
|
|
7529
|
-
return true;
|
|
7530
|
-
};
|
|
7531
|
-
is.jcb = is.jcbCard = is.jcbCardNumber;
|
|
7532
|
-
/**
|
|
7533
|
-
* Test if card number is a Laser card number
|
|
7534
|
-
* @param {String} the credit card number string to test.
|
|
7535
|
-
* @return true if the string is the correct format, false otherwise
|
|
7536
|
-
*/
|
|
7537
|
-
is.laserCardNumber = function(str) {
|
|
7538
|
-
if (!is.str(str) || str.length < 16 && str.length > 19) return false;
|
|
7539
|
-
var prefix = Math.floor(str.slice(0, 4));
|
|
7540
|
-
if ([
|
|
7541
|
-
6304,
|
|
7542
|
-
6706,
|
|
7543
|
-
6771,
|
|
7544
|
-
6709
|
|
7545
|
-
].indexOf(prefix) === -1) return false;
|
|
7546
|
-
if (!is.creditCardNumber(str)) return false;
|
|
7547
|
-
return true;
|
|
7548
|
-
};
|
|
7549
|
-
is.laser = is.laserCard = is.laserCardNumber;
|
|
7550
|
-
/**
|
|
7551
|
-
* Test if card number is a Maestro card number
|
|
7552
|
-
* @param {String} the credit card number string to test.
|
|
7553
|
-
* @return true if the string is the correct format, false otherwise
|
|
7554
|
-
*/
|
|
7555
|
-
is.maestroCardNumber = function(str) {
|
|
7556
|
-
if (!is.str(str) || str.length < 12 || str.length > 19) return false;
|
|
7557
|
-
var prefix = str.slice(0, 4);
|
|
7558
|
-
if ([
|
|
7559
|
-
"5018",
|
|
7560
|
-
"5020",
|
|
7561
|
-
"5038",
|
|
7562
|
-
"5612",
|
|
7563
|
-
"5893",
|
|
7564
|
-
"6304",
|
|
7565
|
-
"6759",
|
|
7566
|
-
"6761",
|
|
7567
|
-
"6762",
|
|
7568
|
-
"6763",
|
|
7569
|
-
"0604",
|
|
7570
|
-
"6390"
|
|
7571
|
-
].indexOf(prefix) === -1) return false;
|
|
7572
|
-
if (!is.creditCardNumber(str)) return false;
|
|
7573
|
-
return true;
|
|
7574
|
-
};
|
|
7575
|
-
is.maestro = is.maestroCard = is.maestroCardNumber;
|
|
7576
|
-
/**
|
|
7577
|
-
* Test if card number is a Dankort card number
|
|
7578
|
-
* @param {String} the credit card number string to test.
|
|
7579
|
-
* @return true if the string is the correct format, false otherwise
|
|
7580
|
-
*/
|
|
7581
|
-
is.dankortCardNumber = function(str) {
|
|
7582
|
-
if (!is.str(str) || str.length !== 16) return false;
|
|
7583
|
-
if (str.slice(0, 4) !== "5019") return false;
|
|
7584
|
-
if (!is.creditCardNumber(str)) return false;
|
|
7585
|
-
return true;
|
|
7586
|
-
};
|
|
7587
|
-
is.dankort = is.dankortCard = is.dankortCardNumber;
|
|
7588
|
-
/**
|
|
7589
|
-
* Test if card number is a MasterCard card number
|
|
7590
|
-
* @param {String} the credit card number string to test.
|
|
7591
|
-
* @return true if the string is the correct format, false otherwise
|
|
7592
|
-
*/
|
|
7593
|
-
is.masterCardCardNumber = function(str) {
|
|
7594
|
-
if (!is.str(str) || str.length !== 16) return false;
|
|
7595
|
-
var prefix = Math.floor(str.slice(0, 2));
|
|
7596
|
-
if (prefix < 50 || prefix > 55) return false;
|
|
7597
|
-
if (!is.creditCardNumber(str)) return false;
|
|
7598
|
-
return true;
|
|
7599
|
-
};
|
|
7600
|
-
is.masterCard = is.masterCardCard = is.masterCardCardNumber;
|
|
7601
|
-
/**
|
|
7602
|
-
* Test if card number is a Visa card number
|
|
7603
|
-
* @param {String} the credit card number string to test.
|
|
7604
|
-
* @return true if the string is the correct format, false otherwise
|
|
7605
|
-
*/
|
|
7606
|
-
is.visaCardNumber = function(str) {
|
|
7607
|
-
if (!is.str(str) || str.length !== 13 && str.length !== 16) return false;
|
|
7608
|
-
if ("4" !== str.slice(0, 1)) return false;
|
|
7609
|
-
if (!is.creditCardNumber(str)) return false;
|
|
7610
|
-
return true;
|
|
7611
|
-
};
|
|
7612
|
-
is.visa = is.visaCard = is.visaCardNumber;
|
|
7613
|
-
/**
|
|
7614
|
-
* Test if card number is a Visa card number
|
|
7615
|
-
* @param {String} the credit card number string to test.
|
|
7616
|
-
* @return true if the string is the correct format, false otherwise
|
|
7617
|
-
*/
|
|
7618
|
-
is.visaElectronCardNumber = function(str) {
|
|
7619
|
-
if (!is.str(str) || str.length !== 16) return false;
|
|
7620
|
-
var prefix = Math.floor(str.slice(0, 4));
|
|
7621
|
-
if ("417500" !== str.slice(0, 6) && [
|
|
7622
|
-
4026,
|
|
7623
|
-
4405,
|
|
7624
|
-
4508,
|
|
7625
|
-
4844,
|
|
7626
|
-
4913,
|
|
7627
|
-
4917
|
|
7628
|
-
].indexOf(prefix) === -1) return false;
|
|
7629
|
-
if (!is.creditCardNumber(str)) return false;
|
|
7630
|
-
return false;
|
|
7631
|
-
};
|
|
7632
|
-
is.visaElectron = is.visaElectronCard = is.visaElectronCardNumber;
|
|
7633
|
-
/**
|
|
7634
|
-
* Test if the input is a valid MongoDB id.
|
|
7635
|
-
* @param {String|Object} Either a mongodb object id or a string representation.
|
|
7636
|
-
* @return true if the string is the correct format, false otherwise
|
|
7637
|
-
* Thanks to Jason Denizac (https://github.com/jden) for pointing this out.
|
|
7638
|
-
* https://github.com/jden/objectid/blob/master/index.js#L7-L10
|
|
7639
|
-
*/
|
|
7640
|
-
var objIdPattern = /^[0-9a-fA-F]{24}$/;
|
|
7641
|
-
is.mongoId = is.objectId = is.objId = function(id) {
|
|
7642
|
-
return Boolean(id) && !Array.isArray(id) && objIdPattern.test(String(id));
|
|
7643
|
-
};
|
|
7644
|
-
/**
|
|
7645
|
-
* Test is the first argument is structly equal to any of the subsequent args.
|
|
7646
|
-
* @param Value to test against subsequent arguments.
|
|
7647
|
-
* @return true if the first value matches any of subsequent values.
|
|
7648
|
-
*/
|
|
7649
|
-
is.matching = is.match = is.inArgs = function(val) {
|
|
7650
|
-
if (arguments.length < 2) return false;
|
|
7651
|
-
var result = false;
|
|
7652
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
7653
|
-
var eq = is.equal(val, arguments[i]);
|
|
7654
|
-
result = result || eq;
|
|
7655
|
-
}
|
|
7656
|
-
return result;
|
|
7657
|
-
};
|
|
7658
|
-
/**********************************
|
|
7659
|
-
***Definitely a work in progress***
|
|
7660
|
-
**********************************/
|
|
7661
|
-
/**
|
|
7662
|
-
* Test if a string contains a US street address
|
|
7663
|
-
* @param {String} the string to search
|
|
7664
|
-
* @return true if an address is present, false otherwise
|
|
7665
|
-
*/
|
|
7666
|
-
is.streetAddress = function(str) {
|
|
7667
|
-
if (!is.str(str)) return false;
|
|
7668
|
-
return /\b\d+[\s](?:[A-Za-z0-9.-]+[\s]+)+\b(ALLEY|ALY|AVENUE|AVE|BEND|BND|BLUFFS?|BLFS?|BOULEVARD|BLVD|BRANCH|BR|CENTERS?|CTRS?|CIRCLES?|CIRS?|CLIFFS?|CLFS?|COURTS?|CTS?|COVES?|CVS?|CREEK|CRK|CRESCENT|CRES|CREST|CRST|CROSSING|XING|DRIVES?|DRS?|EXPRESSWAY|EXPY|FREEWAY|FWY|HEIGHTS|HTS|HIGHWAY|HWY|HILLS?|HLS?|LANE|LN|LOOP|MANORS?|MNRS?|MOTORWAY|MTWY|MOUNT|MT|PARKS?|PARKWAYS?|PKWY|PASS|PLACE|PL|PLAZA|PLZ|POINTS?|PTS?|RIDGES?|RDGS?|ROADS?|RDS?|ROUTE|RTE?|SHOALS?|SHLS?|SHORES?|SHRS?|SPRINGS?|SPGS?|SPURS?|STREETS?|STS?|SUMMIT|SMT|TERRACE|TER|THROUGHWAY|TRWY|TRAFFICWAY|TRFY|TRAIL|TRL|TURNPIKE|TPKE|VALLEYS?|VLYS?|WAYS?)+(?:[\.\-\s\,]?)*((APARTMENT|APT|APPT|#|NUMBER|NUM|FLOOR|FL|\s)?(\d)*)\b/gi.test(str);
|
|
7669
|
-
};
|
|
7670
|
-
is.street = is.address = is.streetAddress;
|
|
7671
|
-
/**
|
|
7672
|
-
* Test if a string resembles a US Zip code,
|
|
7673
|
-
* no regular expression will be perfect for this,
|
|
7674
|
-
* as there are many numbers that aren't valid zip codes
|
|
7675
|
-
* @param {String || Number} the string or number literal to test
|
|
7676
|
-
* @return true if zipcode like, false otherwise
|
|
7677
|
-
*/
|
|
7678
|
-
is.zipCode = function(str) {
|
|
7679
|
-
if (is.undefined(str) || !(is.string(str) || is.number(str))) return false;
|
|
7680
|
-
return /^\d{5}(?:-\d{4})?$/.test(str);
|
|
7681
|
-
};
|
|
7682
|
-
is.zip = is.zipCode;
|
|
7683
|
-
/**
|
|
7684
|
-
* Test if a string contains a US phone number
|
|
7685
|
-
* @param {String} the string to search
|
|
7686
|
-
* @return true if str contains a phone number, false otherwise.
|
|
7687
|
-
*/
|
|
7688
|
-
is.phoneNumber = function(str) {
|
|
7689
|
-
if (!is.string(str)) return false;
|
|
7690
|
-
return /(?:(?:\+?1\s*(?:[.-]\s*)?)?(?:(\(?)(?:(\s*([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9])\s*)|([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\)?)\s*(?:[.-]\s*)?)?([2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2})\s*(?:[.-]\s*)?([0-9]{4})/g.test(str);
|
|
7691
|
-
};
|
|
7692
|
-
is.phone = is.phoneNumber;
|
|
7693
|
-
/**
|
|
7694
|
-
* Test is a string is a valid URL
|
|
7695
|
-
* @param {string} val - the possible url to check
|
|
7696
|
-
* @return true if str contains a phone number, false otherwise.
|
|
7697
|
-
*/
|
|
7698
|
-
var isUrl = require_is_url();
|
|
7699
|
-
is.url = function(val) {
|
|
7700
|
-
return isUrl(val);
|
|
7701
|
-
};
|
|
7702
|
-
is.uri = is.url;
|
|
7703
|
-
is.enumerator = function(val, ary) {
|
|
7704
|
-
var value = false;
|
|
7705
|
-
if (!is.defined(val) || !is.defined(ary) || !is.arrayLike(ary)) return value;
|
|
7706
|
-
for (var i = 0, len = ary.length; i < len; i++) if (is.equal(val, ary[i])) {
|
|
7707
|
-
value = true;
|
|
7708
|
-
break;
|
|
7709
|
-
}
|
|
7710
|
-
return value;
|
|
7711
|
-
};
|
|
7712
|
-
is.enum = is.inArray = is.enumerator;
|
|
7713
|
-
}));
|
|
7714
|
-
//#endregion
|
|
7715
|
-
//#region node_modules/tcp-port-used/node_modules/ms/index.js
|
|
7716
|
-
var require_ms = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
7717
|
-
/**
|
|
7718
|
-
* Helpers.
|
|
7719
|
-
*/
|
|
7720
|
-
var s = 1e3;
|
|
7721
|
-
var m = s * 60;
|
|
7722
|
-
var h = m * 60;
|
|
7723
|
-
var d = h * 24;
|
|
7724
|
-
var w = d * 7;
|
|
7725
|
-
var y = d * 365.25;
|
|
7726
|
-
/**
|
|
7727
|
-
* Parse or format the given `val`.
|
|
7728
|
-
*
|
|
7729
|
-
* Options:
|
|
7730
|
-
*
|
|
7731
|
-
* - `long` verbose formatting [false]
|
|
7732
|
-
*
|
|
7733
|
-
* @param {String|Number} val
|
|
7734
|
-
* @param {Object} [options]
|
|
7735
|
-
* @throws {Error} throw an error if val is not a non-empty string or a number
|
|
7736
|
-
* @return {String|Number}
|
|
7737
|
-
* @api public
|
|
7738
|
-
*/
|
|
7739
|
-
module.exports = function(val, options) {
|
|
7740
|
-
options = options || {};
|
|
7741
|
-
var type = typeof val;
|
|
7742
|
-
if (type === "string" && val.length > 0) return parse(val);
|
|
7743
|
-
else if (type === "number" && isFinite(val)) return options.long ? fmtLong(val) : fmtShort(val);
|
|
7744
|
-
throw new Error("val is not a non-empty string or a valid number. val=" + JSON.stringify(val));
|
|
7745
|
-
};
|
|
7746
|
-
/**
|
|
7747
|
-
* Parse the given `str` and return milliseconds.
|
|
7748
|
-
*
|
|
7749
|
-
* @param {String} str
|
|
7750
|
-
* @return {Number}
|
|
7751
|
-
* @api private
|
|
7752
|
-
*/
|
|
7753
|
-
function parse(str) {
|
|
7754
|
-
str = String(str);
|
|
7755
|
-
if (str.length > 100) return;
|
|
7756
|
-
var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(str);
|
|
7757
|
-
if (!match) return;
|
|
7758
|
-
var n = parseFloat(match[1]);
|
|
7759
|
-
switch ((match[2] || "ms").toLowerCase()) {
|
|
7760
|
-
case "years":
|
|
7761
|
-
case "year":
|
|
7762
|
-
case "yrs":
|
|
7763
|
-
case "yr":
|
|
7764
|
-
case "y": return n * y;
|
|
7765
|
-
case "weeks":
|
|
7766
|
-
case "week":
|
|
7767
|
-
case "w": return n * w;
|
|
7768
|
-
case "days":
|
|
7769
|
-
case "day":
|
|
7770
|
-
case "d": return n * d;
|
|
7771
|
-
case "hours":
|
|
7772
|
-
case "hour":
|
|
7773
|
-
case "hrs":
|
|
7774
|
-
case "hr":
|
|
7775
|
-
case "h": return n * h;
|
|
7776
|
-
case "minutes":
|
|
7777
|
-
case "minute":
|
|
7778
|
-
case "mins":
|
|
7779
|
-
case "min":
|
|
7780
|
-
case "m": return n * m;
|
|
7781
|
-
case "seconds":
|
|
7782
|
-
case "second":
|
|
7783
|
-
case "secs":
|
|
7784
|
-
case "sec":
|
|
7785
|
-
case "s": return n * s;
|
|
7786
|
-
case "milliseconds":
|
|
7787
|
-
case "millisecond":
|
|
7788
|
-
case "msecs":
|
|
7789
|
-
case "msec":
|
|
7790
|
-
case "ms": return n;
|
|
7791
|
-
default: return;
|
|
7792
|
-
}
|
|
7793
|
-
}
|
|
7794
|
-
/**
|
|
7795
|
-
* Short format for `ms`.
|
|
7796
|
-
*
|
|
7797
|
-
* @param {Number} ms
|
|
7798
|
-
* @return {String}
|
|
7799
|
-
* @api private
|
|
7800
|
-
*/
|
|
7801
|
-
function fmtShort(ms) {
|
|
7802
|
-
var msAbs = Math.abs(ms);
|
|
7803
|
-
if (msAbs >= d) return Math.round(ms / d) + "d";
|
|
7804
|
-
if (msAbs >= h) return Math.round(ms / h) + "h";
|
|
7805
|
-
if (msAbs >= m) return Math.round(ms / m) + "m";
|
|
7806
|
-
if (msAbs >= s) return Math.round(ms / s) + "s";
|
|
7807
|
-
return ms + "ms";
|
|
7808
|
-
}
|
|
7809
|
-
/**
|
|
7810
|
-
* Long format for `ms`.
|
|
7811
|
-
*
|
|
7812
|
-
* @param {Number} ms
|
|
7813
|
-
* @return {String}
|
|
7814
|
-
* @api private
|
|
7815
|
-
*/
|
|
7816
|
-
function fmtLong(ms) {
|
|
7817
|
-
var msAbs = Math.abs(ms);
|
|
7818
|
-
if (msAbs >= d) return plural(ms, msAbs, d, "day");
|
|
7819
|
-
if (msAbs >= h) return plural(ms, msAbs, h, "hour");
|
|
7820
|
-
if (msAbs >= m) return plural(ms, msAbs, m, "minute");
|
|
7821
|
-
if (msAbs >= s) return plural(ms, msAbs, s, "second");
|
|
7822
|
-
return ms + " ms";
|
|
7823
|
-
}
|
|
7824
|
-
/**
|
|
7825
|
-
* Pluralization helper.
|
|
7826
|
-
*/
|
|
7827
|
-
function plural(ms, msAbs, n, name) {
|
|
7828
|
-
var isPlural = msAbs >= n * 1.5;
|
|
7829
|
-
return Math.round(ms / n) + " " + name + (isPlural ? "s" : "");
|
|
7830
|
-
}
|
|
7831
|
-
}));
|
|
7832
|
-
//#endregion
|
|
7833
|
-
//#region node_modules/tcp-port-used/node_modules/debug/src/common.js
|
|
7834
|
-
var require_common = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
7835
|
-
/**
|
|
7836
|
-
* This is the common logic for both the Node.js and web browser
|
|
7837
|
-
* implementations of `debug()`.
|
|
7838
|
-
*/
|
|
7839
|
-
function setup(env) {
|
|
7840
|
-
createDebug.debug = createDebug;
|
|
7841
|
-
createDebug.default = createDebug;
|
|
7842
|
-
createDebug.coerce = coerce;
|
|
7843
|
-
createDebug.disable = disable;
|
|
7844
|
-
createDebug.enable = enable;
|
|
7845
|
-
createDebug.enabled = enabled;
|
|
7846
|
-
createDebug.humanize = require_ms();
|
|
7847
|
-
createDebug.destroy = destroy;
|
|
7848
|
-
Object.keys(env).forEach((key) => {
|
|
7849
|
-
createDebug[key] = env[key];
|
|
7850
|
-
});
|
|
7851
|
-
/**
|
|
7852
|
-
* The currently active debug mode names, and names to skip.
|
|
7853
|
-
*/
|
|
7854
|
-
createDebug.names = [];
|
|
7855
|
-
createDebug.skips = [];
|
|
7856
|
-
/**
|
|
7857
|
-
* Map of special "%n" handling functions, for the debug "format" argument.
|
|
7858
|
-
*
|
|
7859
|
-
* Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
|
|
7860
|
-
*/
|
|
7861
|
-
createDebug.formatters = {};
|
|
7862
|
-
/**
|
|
7863
|
-
* Selects a color for a debug namespace
|
|
7864
|
-
* @param {String} namespace The namespace string for the for the debug instance to be colored
|
|
7865
|
-
* @return {Number|String} An ANSI color code for the given namespace
|
|
7866
|
-
* @api private
|
|
7867
|
-
*/
|
|
7868
|
-
function selectColor(namespace) {
|
|
7869
|
-
let hash = 0;
|
|
7870
|
-
for (let i = 0; i < namespace.length; i++) {
|
|
7871
|
-
hash = (hash << 5) - hash + namespace.charCodeAt(i);
|
|
7872
|
-
hash |= 0;
|
|
7873
|
-
}
|
|
7874
|
-
return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
|
|
7875
|
-
}
|
|
7876
|
-
createDebug.selectColor = selectColor;
|
|
7877
|
-
/**
|
|
7878
|
-
* Create a debugger with the given `namespace`.
|
|
7879
|
-
*
|
|
7880
|
-
* @param {String} namespace
|
|
7881
|
-
* @return {Function}
|
|
7882
|
-
* @api public
|
|
7883
|
-
*/
|
|
7884
|
-
function createDebug(namespace) {
|
|
7885
|
-
let prevTime;
|
|
7886
|
-
let enableOverride = null;
|
|
7887
|
-
function debug(...args) {
|
|
7888
|
-
if (!debug.enabled) return;
|
|
7889
|
-
const self = debug;
|
|
7890
|
-
const curr = Number(/* @__PURE__ */ new Date());
|
|
7891
|
-
self.diff = curr - (prevTime || curr);
|
|
7892
|
-
self.prev = prevTime;
|
|
7893
|
-
self.curr = curr;
|
|
7894
|
-
prevTime = curr;
|
|
7895
|
-
args[0] = createDebug.coerce(args[0]);
|
|
7896
|
-
if (typeof args[0] !== "string") args.unshift("%O");
|
|
7897
|
-
let index = 0;
|
|
7898
|
-
args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
|
|
7899
|
-
if (match === "%%") return "%";
|
|
7900
|
-
index++;
|
|
7901
|
-
const formatter = createDebug.formatters[format];
|
|
7902
|
-
if (typeof formatter === "function") {
|
|
7903
|
-
const val = args[index];
|
|
7904
|
-
match = formatter.call(self, val);
|
|
7905
|
-
args.splice(index, 1);
|
|
7906
|
-
index--;
|
|
7907
|
-
}
|
|
7908
|
-
return match;
|
|
7909
|
-
});
|
|
7910
|
-
createDebug.formatArgs.call(self, args);
|
|
7911
|
-
(self.log || createDebug.log).apply(self, args);
|
|
7912
|
-
}
|
|
7913
|
-
debug.namespace = namespace;
|
|
7914
|
-
debug.useColors = createDebug.useColors();
|
|
7915
|
-
debug.color = createDebug.selectColor(namespace);
|
|
7916
|
-
debug.extend = extend;
|
|
7917
|
-
debug.destroy = createDebug.destroy;
|
|
7918
|
-
Object.defineProperty(debug, "enabled", {
|
|
7919
|
-
enumerable: true,
|
|
7920
|
-
configurable: false,
|
|
7921
|
-
get: () => enableOverride === null ? createDebug.enabled(namespace) : enableOverride,
|
|
7922
|
-
set: (v) => {
|
|
7923
|
-
enableOverride = v;
|
|
7924
|
-
}
|
|
7925
|
-
});
|
|
7926
|
-
if (typeof createDebug.init === "function") createDebug.init(debug);
|
|
7927
|
-
return debug;
|
|
7928
|
-
}
|
|
7929
|
-
function extend(namespace, delimiter) {
|
|
7930
|
-
const newDebug = createDebug(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) + namespace);
|
|
7931
|
-
newDebug.log = this.log;
|
|
7932
|
-
return newDebug;
|
|
7933
|
-
}
|
|
7934
|
-
/**
|
|
7935
|
-
* Enables a debug mode by namespaces. This can include modes
|
|
7936
|
-
* separated by a colon and wildcards.
|
|
7937
|
-
*
|
|
7938
|
-
* @param {String} namespaces
|
|
7939
|
-
* @api public
|
|
7940
|
-
*/
|
|
7941
|
-
function enable(namespaces) {
|
|
7942
|
-
createDebug.save(namespaces);
|
|
7943
|
-
createDebug.names = [];
|
|
7944
|
-
createDebug.skips = [];
|
|
7945
|
-
let i;
|
|
7946
|
-
const split = (typeof namespaces === "string" ? namespaces : "").split(/[\s,]+/);
|
|
7947
|
-
const len = split.length;
|
|
7948
|
-
for (i = 0; i < len; i++) {
|
|
7949
|
-
if (!split[i]) continue;
|
|
7950
|
-
namespaces = split[i].replace(/\*/g, ".*?");
|
|
7951
|
-
if (namespaces[0] === "-") createDebug.skips.push(new RegExp("^" + namespaces.substr(1) + "$"));
|
|
7952
|
-
else createDebug.names.push(new RegExp("^" + namespaces + "$"));
|
|
7953
|
-
}
|
|
7954
|
-
}
|
|
7955
|
-
/**
|
|
7956
|
-
* Disable debug output.
|
|
7957
|
-
*
|
|
7958
|
-
* @return {String} namespaces
|
|
7959
|
-
* @api public
|
|
7960
|
-
*/
|
|
7961
|
-
function disable() {
|
|
7962
|
-
const namespaces = [...createDebug.names.map(toNamespace), ...createDebug.skips.map(toNamespace).map((namespace) => "-" + namespace)].join(",");
|
|
7963
|
-
createDebug.enable("");
|
|
7964
|
-
return namespaces;
|
|
7965
|
-
}
|
|
7966
|
-
/**
|
|
7967
|
-
* Returns true if the given mode name is enabled, false otherwise.
|
|
7968
|
-
*
|
|
7969
|
-
* @param {String} name
|
|
7970
|
-
* @return {Boolean}
|
|
7971
|
-
* @api public
|
|
7972
|
-
*/
|
|
7973
|
-
function enabled(name) {
|
|
7974
|
-
if (name[name.length - 1] === "*") return true;
|
|
7975
|
-
let i;
|
|
7976
|
-
let len;
|
|
7977
|
-
for (i = 0, len = createDebug.skips.length; i < len; i++) if (createDebug.skips[i].test(name)) return false;
|
|
7978
|
-
for (i = 0, len = createDebug.names.length; i < len; i++) if (createDebug.names[i].test(name)) return true;
|
|
7979
|
-
return false;
|
|
7980
|
-
}
|
|
7981
|
-
/**
|
|
7982
|
-
* Convert regexp to namespace
|
|
7983
|
-
*
|
|
7984
|
-
* @param {RegExp} regxep
|
|
7985
|
-
* @return {String} namespace
|
|
7986
|
-
* @api private
|
|
7987
|
-
*/
|
|
7988
|
-
function toNamespace(regexp) {
|
|
7989
|
-
return regexp.toString().substring(2, regexp.toString().length - 2).replace(/\.\*\?$/, "*");
|
|
7990
|
-
}
|
|
7991
|
-
/**
|
|
7992
|
-
* Coerce `val`.
|
|
7993
|
-
*
|
|
7994
|
-
* @param {Mixed} val
|
|
7995
|
-
* @return {Mixed}
|
|
7996
|
-
* @api private
|
|
7997
|
-
*/
|
|
7998
|
-
function coerce(val) {
|
|
7999
|
-
if (val instanceof Error) return val.stack || val.message;
|
|
8000
|
-
return val;
|
|
8001
|
-
}
|
|
8002
|
-
/**
|
|
8003
|
-
* XXX DO NOT USE. This is a temporary stub function.
|
|
8004
|
-
* XXX It WILL be removed in the next major release.
|
|
8005
|
-
*/
|
|
8006
|
-
function destroy() {
|
|
8007
|
-
console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
|
|
8008
|
-
}
|
|
8009
|
-
createDebug.enable(createDebug.load());
|
|
8010
|
-
return createDebug;
|
|
8011
|
-
}
|
|
8012
|
-
module.exports = setup;
|
|
8013
|
-
}));
|
|
8014
|
-
//#endregion
|
|
8015
|
-
//#region node_modules/tcp-port-used/node_modules/debug/src/browser.js
|
|
8016
|
-
var require_browser = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
8017
|
-
/**
|
|
8018
|
-
* This is the web browser implementation of `debug()`.
|
|
8019
|
-
*/
|
|
8020
|
-
exports.formatArgs = formatArgs;
|
|
8021
|
-
exports.save = save;
|
|
8022
|
-
exports.load = load;
|
|
8023
|
-
exports.useColors = useColors;
|
|
8024
|
-
exports.storage = localstorage();
|
|
8025
|
-
exports.destroy = (() => {
|
|
8026
|
-
let warned = false;
|
|
8027
|
-
return () => {
|
|
8028
|
-
if (!warned) {
|
|
8029
|
-
warned = true;
|
|
8030
|
-
console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
|
|
8031
|
-
}
|
|
8032
|
-
};
|
|
8033
|
-
})();
|
|
8034
|
-
/**
|
|
8035
|
-
* Colors.
|
|
8036
|
-
*/
|
|
8037
|
-
exports.colors = [
|
|
8038
|
-
"#0000CC",
|
|
8039
|
-
"#0000FF",
|
|
8040
|
-
"#0033CC",
|
|
8041
|
-
"#0033FF",
|
|
8042
|
-
"#0066CC",
|
|
8043
|
-
"#0066FF",
|
|
8044
|
-
"#0099CC",
|
|
8045
|
-
"#0099FF",
|
|
8046
|
-
"#00CC00",
|
|
8047
|
-
"#00CC33",
|
|
8048
|
-
"#00CC66",
|
|
8049
|
-
"#00CC99",
|
|
8050
|
-
"#00CCCC",
|
|
8051
|
-
"#00CCFF",
|
|
8052
|
-
"#3300CC",
|
|
8053
|
-
"#3300FF",
|
|
8054
|
-
"#3333CC",
|
|
8055
|
-
"#3333FF",
|
|
8056
|
-
"#3366CC",
|
|
8057
|
-
"#3366FF",
|
|
8058
|
-
"#3399CC",
|
|
8059
|
-
"#3399FF",
|
|
8060
|
-
"#33CC00",
|
|
8061
|
-
"#33CC33",
|
|
8062
|
-
"#33CC66",
|
|
8063
|
-
"#33CC99",
|
|
8064
|
-
"#33CCCC",
|
|
8065
|
-
"#33CCFF",
|
|
8066
|
-
"#6600CC",
|
|
8067
|
-
"#6600FF",
|
|
8068
|
-
"#6633CC",
|
|
8069
|
-
"#6633FF",
|
|
8070
|
-
"#66CC00",
|
|
8071
|
-
"#66CC33",
|
|
8072
|
-
"#9900CC",
|
|
8073
|
-
"#9900FF",
|
|
8074
|
-
"#9933CC",
|
|
8075
|
-
"#9933FF",
|
|
8076
|
-
"#99CC00",
|
|
8077
|
-
"#99CC33",
|
|
8078
|
-
"#CC0000",
|
|
8079
|
-
"#CC0033",
|
|
8080
|
-
"#CC0066",
|
|
8081
|
-
"#CC0099",
|
|
8082
|
-
"#CC00CC",
|
|
8083
|
-
"#CC00FF",
|
|
8084
|
-
"#CC3300",
|
|
8085
|
-
"#CC3333",
|
|
8086
|
-
"#CC3366",
|
|
8087
|
-
"#CC3399",
|
|
8088
|
-
"#CC33CC",
|
|
8089
|
-
"#CC33FF",
|
|
8090
|
-
"#CC6600",
|
|
8091
|
-
"#CC6633",
|
|
8092
|
-
"#CC9900",
|
|
8093
|
-
"#CC9933",
|
|
8094
|
-
"#CCCC00",
|
|
8095
|
-
"#CCCC33",
|
|
8096
|
-
"#FF0000",
|
|
8097
|
-
"#FF0033",
|
|
8098
|
-
"#FF0066",
|
|
8099
|
-
"#FF0099",
|
|
8100
|
-
"#FF00CC",
|
|
8101
|
-
"#FF00FF",
|
|
8102
|
-
"#FF3300",
|
|
8103
|
-
"#FF3333",
|
|
8104
|
-
"#FF3366",
|
|
8105
|
-
"#FF3399",
|
|
8106
|
-
"#FF33CC",
|
|
8107
|
-
"#FF33FF",
|
|
8108
|
-
"#FF6600",
|
|
8109
|
-
"#FF6633",
|
|
8110
|
-
"#FF9900",
|
|
8111
|
-
"#FF9933",
|
|
8112
|
-
"#FFCC00",
|
|
8113
|
-
"#FFCC33"
|
|
8114
|
-
];
|
|
8115
|
-
/**
|
|
8116
|
-
* Currently only WebKit-based Web Inspectors, Firefox >= v31,
|
|
8117
|
-
* and the Firebug extension (any Firefox version) are known
|
|
8118
|
-
* to support "%c" CSS customizations.
|
|
8119
|
-
*
|
|
8120
|
-
* TODO: add a `localStorage` variable to explicitly enable/disable colors
|
|
8121
|
-
*/
|
|
8122
|
-
function useColors() {
|
|
8123
|
-
if (typeof window !== "undefined" && window.process && (window.process.type === "renderer" || window.process.__nwjs)) return true;
|
|
8124
|
-
if (typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) return false;
|
|
8125
|
-
return typeof document !== "undefined" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || typeof window !== "undefined" && window.console && (window.console.firebug || window.console.exception && window.console.table) || typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 || typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
|
|
8126
|
-
}
|
|
8127
|
-
/**
|
|
8128
|
-
* Colorize log arguments if enabled.
|
|
8129
|
-
*
|
|
8130
|
-
* @api public
|
|
8131
|
-
*/
|
|
8132
|
-
function formatArgs(args) {
|
|
8133
|
-
args[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args[0] + (this.useColors ? "%c " : " ") + "+" + module.exports.humanize(this.diff);
|
|
8134
|
-
if (!this.useColors) return;
|
|
8135
|
-
const c = "color: " + this.color;
|
|
8136
|
-
args.splice(1, 0, c, "color: inherit");
|
|
8137
|
-
let index = 0;
|
|
8138
|
-
let lastC = 0;
|
|
8139
|
-
args[0].replace(/%[a-zA-Z%]/g, (match) => {
|
|
8140
|
-
if (match === "%%") return;
|
|
8141
|
-
index++;
|
|
8142
|
-
if (match === "%c") lastC = index;
|
|
8143
|
-
});
|
|
8144
|
-
args.splice(lastC, 0, c);
|
|
8145
|
-
}
|
|
8146
|
-
/**
|
|
8147
|
-
* Invokes `console.debug()` when available.
|
|
8148
|
-
* No-op when `console.debug` is not a "function".
|
|
8149
|
-
* If `console.debug` is not available, falls back
|
|
8150
|
-
* to `console.log`.
|
|
8151
|
-
*
|
|
8152
|
-
* @api public
|
|
8153
|
-
*/
|
|
8154
|
-
exports.log = console.debug || console.log || (() => {});
|
|
8155
|
-
/**
|
|
8156
|
-
* Save `namespaces`.
|
|
8157
|
-
*
|
|
8158
|
-
* @param {String} namespaces
|
|
8159
|
-
* @api private
|
|
8160
|
-
*/
|
|
8161
|
-
function save(namespaces) {
|
|
8162
|
-
try {
|
|
8163
|
-
if (namespaces) exports.storage.setItem("debug", namespaces);
|
|
8164
|
-
else exports.storage.removeItem("debug");
|
|
8165
|
-
} catch (error) {}
|
|
8166
|
-
}
|
|
8167
|
-
/**
|
|
8168
|
-
* Load `namespaces`.
|
|
8169
|
-
*
|
|
8170
|
-
* @return {String} returns the previously persisted debug modes
|
|
8171
|
-
* @api private
|
|
8172
|
-
*/
|
|
8173
|
-
function load() {
|
|
8174
|
-
let r;
|
|
8175
|
-
try {
|
|
8176
|
-
r = exports.storage.getItem("debug");
|
|
8177
|
-
} catch (error) {}
|
|
8178
|
-
if (!r && typeof process !== "undefined" && "env" in process) r = process.env.DEBUG;
|
|
8179
|
-
return r;
|
|
8180
|
-
}
|
|
8181
|
-
/**
|
|
8182
|
-
* Localstorage attempts to return the localstorage.
|
|
8183
|
-
*
|
|
8184
|
-
* This is necessary because safari throws
|
|
8185
|
-
* when a user disables cookies/localstorage
|
|
8186
|
-
* and you attempt to access it.
|
|
8187
|
-
*
|
|
8188
|
-
* @return {LocalStorage}
|
|
8189
|
-
* @api private
|
|
8190
|
-
*/
|
|
8191
|
-
function localstorage() {
|
|
8192
|
-
try {
|
|
8193
|
-
return localStorage;
|
|
8194
|
-
} catch (error) {}
|
|
8195
|
-
}
|
|
8196
|
-
module.exports = require_common()(exports);
|
|
8197
|
-
const { formatters } = module.exports;
|
|
8198
|
-
/**
|
|
8199
|
-
* Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
|
|
8200
|
-
*/
|
|
8201
|
-
formatters.j = function(v) {
|
|
8202
|
-
try {
|
|
8203
|
-
return JSON.stringify(v);
|
|
8204
|
-
} catch (error) {
|
|
8205
|
-
return "[UnexpectedJSONParseError]: " + error.message;
|
|
8206
|
-
}
|
|
8207
|
-
};
|
|
8208
|
-
}));
|
|
8209
|
-
//#endregion
|
|
8210
|
-
//#region node_modules/tcp-port-used/node_modules/debug/src/node.js
|
|
8211
|
-
var require_node = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
8212
|
-
/**
|
|
8213
|
-
* Module dependencies.
|
|
8214
|
-
*/
|
|
8215
|
-
const tty = __require("tty");
|
|
8216
|
-
const util$1 = __require("util");
|
|
8217
|
-
/**
|
|
8218
|
-
* This is the Node.js implementation of `debug()`.
|
|
8219
|
-
*/
|
|
8220
|
-
exports.init = init;
|
|
8221
|
-
exports.log = log;
|
|
8222
|
-
exports.formatArgs = formatArgs;
|
|
8223
|
-
exports.save = save;
|
|
8224
|
-
exports.load = load;
|
|
8225
|
-
exports.useColors = useColors;
|
|
8226
|
-
exports.destroy = util$1.deprecate(() => {}, "Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
|
|
8227
|
-
/**
|
|
8228
|
-
* Colors.
|
|
8229
|
-
*/
|
|
8230
|
-
exports.colors = [
|
|
8231
|
-
6,
|
|
8232
|
-
2,
|
|
8233
|
-
3,
|
|
8234
|
-
4,
|
|
8235
|
-
5,
|
|
8236
|
-
1
|
|
8237
|
-
];
|
|
8238
|
-
try {
|
|
8239
|
-
const supportsColor = require_supports_color();
|
|
8240
|
-
if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) exports.colors = [
|
|
8241
|
-
20,
|
|
8242
|
-
21,
|
|
8243
|
-
26,
|
|
8244
|
-
27,
|
|
8245
|
-
32,
|
|
8246
|
-
33,
|
|
8247
|
-
38,
|
|
8248
|
-
39,
|
|
8249
|
-
40,
|
|
8250
|
-
41,
|
|
8251
|
-
42,
|
|
8252
|
-
43,
|
|
8253
|
-
44,
|
|
8254
|
-
45,
|
|
8255
|
-
56,
|
|
8256
|
-
57,
|
|
8257
|
-
62,
|
|
8258
|
-
63,
|
|
8259
|
-
68,
|
|
8260
|
-
69,
|
|
8261
|
-
74,
|
|
8262
|
-
75,
|
|
8263
|
-
76,
|
|
8264
|
-
77,
|
|
8265
|
-
78,
|
|
8266
|
-
79,
|
|
8267
|
-
80,
|
|
8268
|
-
81,
|
|
8269
|
-
92,
|
|
8270
|
-
93,
|
|
8271
|
-
98,
|
|
8272
|
-
99,
|
|
8273
|
-
112,
|
|
8274
|
-
113,
|
|
8275
|
-
128,
|
|
8276
|
-
129,
|
|
8277
|
-
134,
|
|
8278
|
-
135,
|
|
8279
|
-
148,
|
|
8280
|
-
149,
|
|
8281
|
-
160,
|
|
8282
|
-
161,
|
|
8283
|
-
162,
|
|
8284
|
-
163,
|
|
8285
|
-
164,
|
|
8286
|
-
165,
|
|
8287
|
-
166,
|
|
8288
|
-
167,
|
|
8289
|
-
168,
|
|
8290
|
-
169,
|
|
8291
|
-
170,
|
|
8292
|
-
171,
|
|
8293
|
-
172,
|
|
8294
|
-
173,
|
|
8295
|
-
178,
|
|
8296
|
-
179,
|
|
8297
|
-
184,
|
|
8298
|
-
185,
|
|
8299
|
-
196,
|
|
8300
|
-
197,
|
|
8301
|
-
198,
|
|
8302
|
-
199,
|
|
8303
|
-
200,
|
|
8304
|
-
201,
|
|
8305
|
-
202,
|
|
8306
|
-
203,
|
|
8307
|
-
204,
|
|
8308
|
-
205,
|
|
8309
|
-
206,
|
|
8310
|
-
207,
|
|
8311
|
-
208,
|
|
8312
|
-
209,
|
|
8313
|
-
214,
|
|
8314
|
-
215,
|
|
8315
|
-
220,
|
|
8316
|
-
221
|
|
8317
|
-
];
|
|
8318
|
-
} catch (error) {}
|
|
8319
|
-
/**
|
|
8320
|
-
* Build up the default `inspectOpts` object from the environment variables.
|
|
8321
|
-
*
|
|
8322
|
-
* $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
|
|
8323
|
-
*/
|
|
8324
|
-
exports.inspectOpts = Object.keys(process.env).filter((key) => {
|
|
8325
|
-
return /^debug_/i.test(key);
|
|
8326
|
-
}).reduce((obj, key) => {
|
|
8327
|
-
const prop = key.substring(6).toLowerCase().replace(/_([a-z])/g, (_, k) => {
|
|
8328
|
-
return k.toUpperCase();
|
|
8329
|
-
});
|
|
8330
|
-
let val = process.env[key];
|
|
8331
|
-
if (/^(yes|on|true|enabled)$/i.test(val)) val = true;
|
|
8332
|
-
else if (/^(no|off|false|disabled)$/i.test(val)) val = false;
|
|
8333
|
-
else if (val === "null") val = null;
|
|
8334
|
-
else val = Number(val);
|
|
8335
|
-
obj[prop] = val;
|
|
8336
|
-
return obj;
|
|
8337
|
-
}, {});
|
|
8338
|
-
/**
|
|
8339
|
-
* Is stdout a TTY? Colored output is enabled when `true`.
|
|
8340
|
-
*/
|
|
8341
|
-
function useColors() {
|
|
8342
|
-
return "colors" in exports.inspectOpts ? Boolean(exports.inspectOpts.colors) : tty.isatty(process.stderr.fd);
|
|
8343
|
-
}
|
|
8344
|
-
/**
|
|
8345
|
-
* Adds ANSI color escape codes if enabled.
|
|
8346
|
-
*
|
|
8347
|
-
* @api public
|
|
8348
|
-
*/
|
|
8349
|
-
function formatArgs(args) {
|
|
8350
|
-
const { namespace: name, useColors } = this;
|
|
8351
|
-
if (useColors) {
|
|
8352
|
-
const c = this.color;
|
|
8353
|
-
const colorCode = "\x1B[3" + (c < 8 ? c : "8;5;" + c);
|
|
8354
|
-
const prefix = ` ${colorCode};1m${name} \u001B[0m`;
|
|
8355
|
-
args[0] = prefix + args[0].split("\n").join("\n" + prefix);
|
|
8356
|
-
args.push(colorCode + "m+" + module.exports.humanize(this.diff) + "\x1B[0m");
|
|
8357
|
-
} else args[0] = getDate() + name + " " + args[0];
|
|
8358
|
-
}
|
|
8359
|
-
function getDate() {
|
|
8360
|
-
if (exports.inspectOpts.hideDate) return "";
|
|
8361
|
-
return (/* @__PURE__ */ new Date()).toISOString() + " ";
|
|
8362
|
-
}
|
|
8363
|
-
/**
|
|
8364
|
-
* Invokes `util.format()` with the specified arguments and writes to stderr.
|
|
8365
|
-
*/
|
|
8366
|
-
function log(...args) {
|
|
8367
|
-
return process.stderr.write(util$1.format(...args) + "\n");
|
|
8368
|
-
}
|
|
8369
|
-
/**
|
|
8370
|
-
* Save `namespaces`.
|
|
8371
|
-
*
|
|
8372
|
-
* @param {String} namespaces
|
|
8373
|
-
* @api private
|
|
8374
|
-
*/
|
|
8375
|
-
function save(namespaces) {
|
|
8376
|
-
if (namespaces) process.env.DEBUG = namespaces;
|
|
8377
|
-
else delete process.env.DEBUG;
|
|
8378
|
-
}
|
|
8379
|
-
/**
|
|
8380
|
-
* Load `namespaces`.
|
|
8381
|
-
*
|
|
8382
|
-
* @return {String} returns the previously persisted debug modes
|
|
8383
|
-
* @api private
|
|
8384
|
-
*/
|
|
8385
|
-
function load() {
|
|
8386
|
-
return process.env.DEBUG;
|
|
8387
|
-
}
|
|
8388
|
-
/**
|
|
8389
|
-
* Init logic for `debug` instances.
|
|
8390
|
-
*
|
|
8391
|
-
* Create a new `inspectOpts` object in case `useColors` is set
|
|
8392
|
-
* differently for a particular `debug` instance.
|
|
8393
|
-
*/
|
|
8394
|
-
function init(debug) {
|
|
8395
|
-
debug.inspectOpts = {};
|
|
8396
|
-
const keys = Object.keys(exports.inspectOpts);
|
|
8397
|
-
for (let i = 0; i < keys.length; i++) debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
|
|
8398
|
-
}
|
|
8399
|
-
module.exports = require_common()(exports);
|
|
8400
|
-
const { formatters } = module.exports;
|
|
8401
|
-
/**
|
|
8402
|
-
* Map %o to `util.inspect()`, all on a single line.
|
|
8403
|
-
*/
|
|
8404
|
-
formatters.o = function(v) {
|
|
8405
|
-
this.inspectOpts.colors = this.useColors;
|
|
8406
|
-
return util$1.inspect(v, this.inspectOpts).split("\n").map((str) => str.trim()).join(" ");
|
|
8407
|
-
};
|
|
8408
|
-
/**
|
|
8409
|
-
* Map %O to `util.inspect()`, allowing multiple lines if needed.
|
|
8410
|
-
*/
|
|
8411
|
-
formatters.O = function(v) {
|
|
8412
|
-
this.inspectOpts.colors = this.useColors;
|
|
8413
|
-
return util$1.inspect(v, this.inspectOpts);
|
|
8414
|
-
};
|
|
8415
|
-
}));
|
|
8416
|
-
//#endregion
|
|
8417
|
-
//#region node_modules/tcp-port-used/node_modules/debug/src/index.js
|
|
8418
|
-
var require_src = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
8419
|
-
/**
|
|
8420
|
-
* Detect Electron renderer / nwjs process, which is node, but we should
|
|
8421
|
-
* treat as a browser.
|
|
8422
|
-
*/
|
|
8423
|
-
if (typeof process === "undefined" || process.type === "renderer" || process.browser === true || process.__nwjs) module.exports = require_browser();
|
|
8424
|
-
else module.exports = require_node();
|
|
8425
|
-
}));
|
|
8426
|
-
//#endregion
|
|
8427
|
-
//#region dist/node/runtime/node/setup-kubo-address-rewriter-and-http-router.js
|
|
8428
|
-
var import_tcp_port_used = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports) => {
|
|
8429
|
-
exports.check = check;
|
|
8430
|
-
var is = require_is2();
|
|
8431
|
-
var net = __require("net");
|
|
8432
|
-
var util = __require("util");
|
|
8433
|
-
var debug = require_src()("tcp-port-used");
|
|
8434
|
-
function getDeferred() {
|
|
8435
|
-
var resolve, reject, promise = new Promise(function(res, rej) {
|
|
8436
|
-
resolve = res;
|
|
8437
|
-
reject = rej;
|
|
8438
|
-
});
|
|
8439
|
-
return {
|
|
8440
|
-
resolve,
|
|
8441
|
-
reject,
|
|
8442
|
-
promise
|
|
8443
|
-
};
|
|
8444
|
-
}
|
|
8445
|
-
/**
|
|
8446
|
-
* Creates an options object from all the possible arguments
|
|
8447
|
-
* @private
|
|
8448
|
-
* @param {Number} port a valid TCP port number
|
|
8449
|
-
* @param {String} host The DNS name or IP address.
|
|
8450
|
-
* @param {Boolean} status The desired in use status to wait for: false === not in use, true === in use
|
|
8451
|
-
* @param {Number} retryTimeMs the retry interval in milliseconds - defaultis is 200ms
|
|
8452
|
-
* @param {Number} timeOutMs the amount of time to wait until port is free default is 1000ms
|
|
8453
|
-
* @return {Object} An options object with all the above parameters as properties.
|
|
8454
|
-
*/
|
|
8455
|
-
function makeOptionsObj(port, host, inUse, retryTimeMs, timeOutMs) {
|
|
8456
|
-
var opts = {};
|
|
8457
|
-
opts.port = port;
|
|
8458
|
-
opts.host = host;
|
|
8459
|
-
opts.inUse = inUse;
|
|
8460
|
-
opts.retryTimeMs = retryTimeMs;
|
|
8461
|
-
opts.timeOutMs = timeOutMs;
|
|
8462
|
-
return opts;
|
|
8463
|
-
}
|
|
8464
|
-
/**
|
|
8465
|
-
* Checks if a TCP port is in use by creating the socket and binding it to the
|
|
8466
|
-
* target port. Once bound, successfully, it's assume the port is availble.
|
|
8467
|
-
* After the socket is closed or in error, the promise is resolved.
|
|
8468
|
-
* Note: you have to be super user to correctly test system ports (0-1023).
|
|
8469
|
-
* @param {Number|Object} port The port you are curious to see if available. If an object, must have the parameters as properties.
|
|
8470
|
-
* @param {String} [host] May be a DNS name or IP address. Default '127.0.0.1'
|
|
8471
|
-
* @return {Object} A deferred Q promise.
|
|
8472
|
-
*
|
|
8473
|
-
* Example usage:
|
|
8474
|
-
*
|
|
8475
|
-
* var tcpPortUsed = require('tcp-port-used');
|
|
8476
|
-
* tcpPortUsed.check(22, '127.0.0.1')
|
|
8477
|
-
* .then(function(inUse) {
|
|
8478
|
-
* debug('Port 22 usage: '+inUse);
|
|
8479
|
-
* }, function(err) {
|
|
8480
|
-
* console.error('Error on check: '+util.inspect(err));
|
|
8481
|
-
* });
|
|
8482
|
-
*/
|
|
8483
|
-
function check(port, host) {
|
|
8484
|
-
var deferred = getDeferred();
|
|
8485
|
-
var inUse = true;
|
|
8486
|
-
var client;
|
|
8487
|
-
var opts;
|
|
8488
|
-
if (!is.obj(port)) opts = makeOptionsObj(port, host);
|
|
8489
|
-
else opts = port;
|
|
8490
|
-
if (!is.port(opts.port)) {
|
|
8491
|
-
debug("Error invalid port: " + util.inspect(opts.port));
|
|
8492
|
-
deferred.reject(/* @__PURE__ */ new Error("invalid port: " + util.inspect(opts.port)));
|
|
8493
|
-
return deferred.promise;
|
|
8494
|
-
}
|
|
8495
|
-
if (is.nullOrUndefined(opts.host)) {
|
|
8496
|
-
debug("set host address to default 127.0.0.1");
|
|
8497
|
-
opts.host = "127.0.0.1";
|
|
8498
|
-
}
|
|
8499
|
-
function cleanUp() {
|
|
8500
|
-
if (client) {
|
|
8501
|
-
client.removeAllListeners("connect");
|
|
8502
|
-
client.removeAllListeners("error");
|
|
8503
|
-
client.end();
|
|
8504
|
-
client.destroy();
|
|
8505
|
-
client.unref();
|
|
8506
|
-
}
|
|
8507
|
-
}
|
|
8508
|
-
function onConnectCb() {
|
|
8509
|
-
deferred.resolve(inUse);
|
|
8510
|
-
cleanUp();
|
|
8511
|
-
}
|
|
8512
|
-
function onErrorCb(err) {
|
|
8513
|
-
if (err.code !== "ECONNREFUSED") deferred.reject(err);
|
|
8514
|
-
else {
|
|
8515
|
-
inUse = false;
|
|
8516
|
-
deferred.resolve(inUse);
|
|
6692
|
+
destroySignal.addEventListener("abort", onDestroy, { once: true });
|
|
6693
|
+
removeDestroyListener = () => destroySignal.removeEventListener("abort", onDestroy);
|
|
6694
|
+
settingOptionRetryOption.attempt(async () => {
|
|
6695
|
+
if (pkc.destroyed) {
|
|
6696
|
+
resolve();
|
|
6697
|
+
return;
|
|
8517
6698
|
}
|
|
8518
|
-
cleanUp();
|
|
8519
|
-
}
|
|
8520
|
-
client = new net.Socket();
|
|
8521
|
-
client.once("connect", onConnectCb);
|
|
8522
|
-
client.once("error", onErrorCb);
|
|
8523
|
-
client.connect({
|
|
8524
|
-
port: opts.port,
|
|
8525
|
-
host: opts.host
|
|
8526
|
-
}, function() {});
|
|
8527
|
-
return deferred.promise;
|
|
8528
|
-
}
|
|
8529
|
-
})))(), 1);
|
|
8530
|
-
const MAX_TCP_PORT = 65535;
|
|
8531
|
-
function _mergeRouterConfigs(existingConfig, newConfig) {
|
|
8532
|
-
if (!existingConfig?.Routers) return newConfig;
|
|
8533
|
-
const existingRoutersByEndpoint = /* @__PURE__ */ new Map();
|
|
8534
|
-
Object.entries(existingConfig.Routers).forEach(([routerName, router]) => {
|
|
8535
|
-
if (router.Parameters?.Endpoint) existingRoutersByEndpoint.set(router.Parameters.Endpoint, {
|
|
8536
|
-
routerName,
|
|
8537
|
-
router
|
|
8538
|
-
});
|
|
8539
|
-
});
|
|
8540
|
-
const mergedRouters = { ...newConfig.Routers };
|
|
8541
|
-
Object.entries(newConfig.Routers).forEach(([newRouterName, newRouter]) => {
|
|
8542
|
-
if (newRouter.Parameters?.Endpoint) {
|
|
8543
|
-
const existing = existingRoutersByEndpoint.get(newRouter.Parameters.Endpoint);
|
|
8544
|
-
if (existing) mergedRouters[newRouterName] = {
|
|
8545
|
-
...existing.router,
|
|
8546
|
-
...newRouter,
|
|
8547
|
-
Parameters: {
|
|
8548
|
-
...existing.router.Parameters,
|
|
8549
|
-
...newRouter.Parameters
|
|
8550
|
-
}
|
|
8551
|
-
};
|
|
8552
|
-
}
|
|
8553
|
-
});
|
|
8554
|
-
return {
|
|
8555
|
-
...newConfig,
|
|
8556
|
-
Routers: mergedRouters
|
|
8557
|
-
};
|
|
8558
|
-
}
|
|
8559
|
-
async function _setProvideDhtSweepEnabledOnKuboNode(kuboClient, sweepEnabled) {
|
|
8560
|
-
const log = logger_default("pkc-js:pkc:_init:retrySettingHttpRoutersOnIpfsNodes:setProvideDhtSweepEnabledOnIpfsNode");
|
|
8561
|
-
const configKey = "Provide.DHT.SweepEnabled";
|
|
8562
|
-
const url = `${kuboClient._clientOptions.url}/config?arg=${configKey}&arg=${JSON.stringify(sweepEnabled)}&json=true`;
|
|
8563
|
-
try {
|
|
8564
|
-
await fetch(url, {
|
|
8565
|
-
method: "POST",
|
|
8566
|
-
headers: kuboClient._clientOptions.headers
|
|
8567
|
-
});
|
|
8568
|
-
} catch (e) {
|
|
8569
|
-
const error = new PKCError("ERR_FAILED_TO_SET_CONFIG_ON_KUBO_NODE", {
|
|
8570
|
-
fullUrl: url,
|
|
8571
|
-
actualError: e,
|
|
8572
|
-
kuboEndpoint: kuboClient._clientOptions.url,
|
|
8573
|
-
configKey,
|
|
8574
|
-
configValueToBeSet: sweepEnabled
|
|
8575
|
-
});
|
|
8576
|
-
log.error(e);
|
|
8577
|
-
throw error;
|
|
8578
|
-
}
|
|
8579
|
-
log.trace("Succeeded in setting config key", configKey, "on node", kuboClient._clientOptions.url, "to be", sweepEnabled);
|
|
8580
|
-
}
|
|
8581
|
-
async function _setHttpRouterOptionsOnKuboNode(kuboClient, routingValue) {
|
|
8582
|
-
const log = logger_default("pkc-js:pkc:_init:retrySettingHttpRoutersOnIpfsNodes:setHttpRouterOptionsOnIpfsNode");
|
|
8583
|
-
const routingKey = "Routing";
|
|
8584
|
-
let routingConfigBeforeChanging;
|
|
8585
|
-
try {
|
|
8586
|
-
routingConfigBeforeChanging = await kuboClient._client.config.get(routingKey);
|
|
8587
|
-
} catch (e) {
|
|
8588
|
-
const error = new PKCError("ERR_FAILED_TO_GET_CONFIG_ON_KUBO_NODE", {
|
|
8589
|
-
actualError: e,
|
|
8590
|
-
kuboEndpoint: kuboClient._clientOptions.url,
|
|
8591
|
-
configKey: routingKey
|
|
8592
|
-
});
|
|
8593
|
-
log.error(e);
|
|
8594
|
-
throw error;
|
|
8595
|
-
}
|
|
8596
|
-
const mergedRoutingValue = _mergeRouterConfigs(routingConfigBeforeChanging, routingValue);
|
|
8597
|
-
const url = `${kuboClient._clientOptions.url}/config?arg=${routingKey}&arg=${JSON.stringify(mergedRoutingValue)}&json=true`;
|
|
8598
|
-
try {
|
|
8599
|
-
await fetch(url, {
|
|
8600
|
-
method: "POST",
|
|
8601
|
-
headers: kuboClient._clientOptions.headers
|
|
8602
|
-
});
|
|
8603
|
-
} catch (e) {
|
|
8604
|
-
const error = new PKCError("ERR_FAILED_TO_SET_CONFIG_ON_KUBO_NODE", {
|
|
8605
|
-
fullUrl: url,
|
|
8606
|
-
actualError: e,
|
|
8607
|
-
kuboEndpoint: kuboClient._clientOptions.url,
|
|
8608
|
-
configKey: routingKey,
|
|
8609
|
-
configValueToBeSet: mergedRoutingValue
|
|
8610
|
-
});
|
|
8611
|
-
log.error(e);
|
|
8612
|
-
throw error;
|
|
8613
|
-
}
|
|
8614
|
-
log.trace("Succeeded in setting config key", routingKey, "on node", kuboClient._clientOptions.url, "to be", mergedRoutingValue);
|
|
8615
|
-
await _setProvideDhtSweepEnabledOnKuboNode(kuboClient, false);
|
|
8616
|
-
const endpointsBefore = Object.values(routingConfigBeforeChanging?.Routers || {}).map((router) => router.Parameters?.Endpoint).filter((endpoint) => endpoint !== void 0);
|
|
8617
|
-
const endpointsAfter = Object.values(mergedRoutingValue.Routers).map((router) => router.Parameters?.Endpoint).filter((endpoint) => endpoint !== void 0);
|
|
8618
|
-
if (!t$3(endpointsBefore.sort(), endpointsAfter.sort())) {
|
|
8619
|
-
log("Config on kubo node has been changed. PKC-js will send shutdown command to node", kuboClient._clientOptions.url, "Clients of pkc-js should restart ipfs node");
|
|
8620
|
-
const shutdownUrl = `${kuboClient._clientOptions.url}/shutdown`;
|
|
8621
|
-
try {
|
|
8622
|
-
await fetch(shutdownUrl, {
|
|
8623
|
-
method: "POST",
|
|
8624
|
-
headers: kuboClient._clientOptions.headers
|
|
8625
|
-
});
|
|
8626
|
-
} catch (e) {
|
|
8627
|
-
const error = new PKCError("ERR_FAILED_TO_SHUTDOWN_KUBO_NODE", {
|
|
8628
|
-
actualError: e,
|
|
8629
|
-
kuboEndpoint: kuboClient._clientOptions.url,
|
|
8630
|
-
shutdownUrl
|
|
8631
|
-
});
|
|
8632
|
-
log.error(e);
|
|
8633
|
-
throw error;
|
|
8634
|
-
}
|
|
8635
|
-
}
|
|
8636
|
-
}
|
|
8637
|
-
async function _getStartedProxyUrl(pkc, httpRouterUrl) {
|
|
8638
|
-
if (pkc.destroyed) return void 0;
|
|
8639
|
-
const mappingKeyName = `httprouter_proxy_${httpRouterUrl}`;
|
|
8640
|
-
try {
|
|
8641
|
-
const urlOfProxyOfHttpRouter = await pkc._storage.getItem(mappingKeyName);
|
|
8642
|
-
if (pkc.destroyed) return void 0;
|
|
8643
|
-
if (urlOfProxyOfHttpRouter) {
|
|
8644
|
-
const proxyHttpUrl = new URL(urlOfProxyOfHttpRouter);
|
|
8645
|
-
if (await import_tcp_port_used.check(Number(proxyHttpUrl.port), "127.0.0.1")) return urlOfProxyOfHttpRouter;
|
|
8646
|
-
if (pkc.destroyed) return void 0;
|
|
8647
|
-
await pkc._storage.removeItem(mappingKeyName);
|
|
8648
|
-
}
|
|
8649
|
-
return;
|
|
8650
|
-
} catch (error) {
|
|
8651
|
-
if (pkc.destroyed && error instanceof Error && error.message.includes("database connection is not open")) return;
|
|
8652
|
-
throw error;
|
|
8653
|
-
}
|
|
8654
|
-
}
|
|
8655
|
-
async function setupKuboAddressesRewriterAndHttpRouters(pkc) {
|
|
8656
|
-
if (pkc.destroyed) return { destroy: async () => {} };
|
|
8657
|
-
if (!Array.isArray(pkc.kuboRpcClientsOptions) || pkc.kuboRpcClientsOptions.length <= 0) throw Error("need ipfs http client to be defined");
|
|
8658
|
-
if (!Array.isArray(pkc.httpRoutersOptions) || pkc.httpRoutersOptions.length <= 0) throw Error("Need http router options to defined");
|
|
8659
|
-
logger_default("pkc-js:node:setupKuboAddressesRewriterAndHttpRouters");
|
|
8660
|
-
const httpRouterProxyUrls = [];
|
|
8661
|
-
const proxyServers = [];
|
|
8662
|
-
const parsedStartPortOverride = Number(process.env.PKC_ADDRESSES_REWRITER_START_PORT);
|
|
8663
|
-
let addressesRewriterStartPort = Number.isInteger(parsedStartPortOverride) && parsedStartPortOverride > 0 && parsedStartPortOverride <= MAX_TCP_PORT ? parsedStartPortOverride : 19575;
|
|
8664
|
-
for (const httpRouter of pkc.httpRoutersOptions) {
|
|
8665
|
-
if (pkc.destroyed) break;
|
|
8666
|
-
const startedProxyUrl = await _getStartedProxyUrl(pkc, httpRouter);
|
|
8667
|
-
if (startedProxyUrl) {
|
|
8668
|
-
httpRouterProxyUrls.push(startedProxyUrl);
|
|
8669
|
-
continue;
|
|
8670
|
-
}
|
|
8671
|
-
let port = addressesRewriterStartPort;
|
|
8672
|
-
const hostname = "127.0.0.1";
|
|
8673
|
-
while (await import_tcp_port_used.check(port, hostname)) {
|
|
8674
|
-
port++;
|
|
8675
|
-
if (port > MAX_TCP_PORT) throw Error(`No free loopback port for the addresses rewriter proxy between ${addressesRewriterStartPort} and ${MAX_TCP_PORT}`);
|
|
8676
|
-
}
|
|
8677
|
-
const addressesRewriterProxyServer = new AddressesRewriterProxyServer({
|
|
8678
|
-
kuboClients: Object.values(pkc.clients.kuboRpcClients).map((kubo) => kubo._client),
|
|
8679
|
-
port,
|
|
8680
|
-
hostname,
|
|
8681
|
-
proxyTargetUrl: httpRouter,
|
|
8682
|
-
pkc
|
|
8683
|
-
});
|
|
8684
|
-
await addressesRewriterProxyServer.listen();
|
|
8685
|
-
if (pkc.destroyed) {
|
|
8686
|
-
await addressesRewriterProxyServer.destroy();
|
|
8687
|
-
break;
|
|
8688
|
-
}
|
|
8689
|
-
proxyServers.push(addressesRewriterProxyServer);
|
|
8690
|
-
const httpRouterProxyUrl = `http://${hostname}:${port}`;
|
|
8691
|
-
httpRouterProxyUrls.push(httpRouterProxyUrl);
|
|
8692
|
-
}
|
|
8693
|
-
httpRouterProxyUrls.sort();
|
|
8694
|
-
const kuboClients = pkc.clients.kuboRpcClients;
|
|
8695
|
-
const parallelRouters = [];
|
|
8696
|
-
const httpRoutersConfig = {
|
|
8697
|
-
HttpRoutersParallel: {
|
|
8698
|
-
Type: "parallel",
|
|
8699
|
-
Parameters: { Routers: parallelRouters }
|
|
8700
|
-
},
|
|
8701
|
-
HttpRouterNotSupported: {
|
|
8702
|
-
Type: "http",
|
|
8703
|
-
Parameters: { Endpoint: "http://kubohttprouternotsupported" }
|
|
8704
|
-
}
|
|
8705
|
-
};
|
|
8706
|
-
for (const [i, httpRouterUrl] of httpRouterProxyUrls.entries()) {
|
|
8707
|
-
const RouterName = `HttpRouter${i + 1}`;
|
|
8708
|
-
httpRoutersConfig[RouterName] = {
|
|
8709
|
-
Type: "http",
|
|
8710
|
-
Parameters: { Endpoint: httpRouterUrl }
|
|
8711
|
-
};
|
|
8712
|
-
parallelRouters[i] = {
|
|
8713
|
-
RouterName,
|
|
8714
|
-
IgnoreErrors: true,
|
|
8715
|
-
Timeout: "10s"
|
|
8716
|
-
};
|
|
8717
|
-
}
|
|
8718
|
-
const routingValue = {
|
|
8719
|
-
Type: "custom",
|
|
8720
|
-
Methods: {
|
|
8721
|
-
"find-providers": { RouterName: "HttpRoutersParallel" },
|
|
8722
|
-
provide: { RouterName: "HttpRoutersParallel" },
|
|
8723
|
-
"find-peers": { RouterName: "HttpRouterNotSupported" },
|
|
8724
|
-
"get-ipns": { RouterName: "HttpRouterNotSupported" },
|
|
8725
|
-
"put-ipns": { RouterName: "HttpRouterNotSupported" }
|
|
8726
|
-
},
|
|
8727
|
-
Routers: httpRoutersConfig
|
|
8728
|
-
};
|
|
8729
|
-
const settingOptionRetryOption = import_retry.operation({
|
|
8730
|
-
forever: true,
|
|
8731
|
-
factor: 2,
|
|
8732
|
-
maxTimeout: 60 * 1e3
|
|
8733
|
-
});
|
|
8734
|
-
await new Promise((resolve) => {
|
|
8735
|
-
settingOptionRetryOption.attempt(async (curAttempt) => {
|
|
8736
6699
|
for (const kuboClient of Object.values(kuboClients)) try {
|
|
8737
|
-
await _setHttpRouterOptionsOnKuboNode(kuboClient, routingValue);
|
|
6700
|
+
await _setHttpRouterOptionsOnKuboNode(kuboClient, routingValue, destroySignal);
|
|
8738
6701
|
} catch (e) {
|
|
8739
6702
|
settingOptionRetryOption.retry(e);
|
|
8740
6703
|
return;
|
|
8741
6704
|
}
|
|
8742
|
-
resolve(
|
|
6705
|
+
resolve();
|
|
8743
6706
|
});
|
|
8744
6707
|
});
|
|
6708
|
+
removeDestroyListener?.();
|
|
8745
6709
|
settingOptionRetryOption.stop();
|
|
8746
|
-
|
|
8747
|
-
|
|
8748
|
-
} };
|
|
6710
|
+
if (pkc.destroyed) return;
|
|
6711
|
+
log.trace("Set http router config on all kubo nodes", Object.keys(kuboClients), "to", httpRouterUrls);
|
|
8749
6712
|
}
|
|
8750
6713
|
//#endregion
|
|
8751
6714
|
//#region dist/node/publications/community-edit/community-edit.js
|
|
@@ -8917,7 +6880,7 @@ var PKC$1 = class extends PKCTypedEmitter {
|
|
|
8917
6880
|
this.clients.libp2pJsClients = {};
|
|
8918
6881
|
if (!this.libp2pJsClientsOptions) return;
|
|
8919
6882
|
if (!this.httpRoutersOptions) throw Error("httpRoutersOptions is required for libp2pJsClient");
|
|
8920
|
-
const { createLibp2pJsClientOrUseExistingOne } = await import("./helia-for-pkc-
|
|
6883
|
+
const { createLibp2pJsClientOrUseExistingOne } = await import("./helia-for-pkc-BcNF-orO.js");
|
|
8921
6884
|
for (const clientOptions of this.libp2pJsClientsOptions) {
|
|
8922
6885
|
const heliaNode = await createLibp2pJsClientOrUseExistingOne({
|
|
8923
6886
|
...clientOptions,
|
|
@@ -8941,23 +6904,19 @@ var PKC$1 = class extends PKCTypedEmitter {
|
|
|
8941
6904
|
const log = logger_default("pkc-js:pkc:_initHttpRoutersWithIpfsInBackground");
|
|
8942
6905
|
if (this.destroyed) return;
|
|
8943
6906
|
if (this.httpRoutersOptions?.length && this.kuboRpcClientsOptions?.length && this._canCreateNewLocalCommunity()) {
|
|
8944
|
-
const setupPromise =
|
|
8945
|
-
if (this.destroyed)
|
|
8946
|
-
|
|
8947
|
-
return;
|
|
8948
|
-
}
|
|
8949
|
-
log("Set http router options and their proxies successfully on all connected ipfs", Object.keys(this.clients.kuboRpcClients));
|
|
8950
|
-
this._addressRewriterDestroy = addressesRewriterProxyServer.destroy;
|
|
6907
|
+
const setupPromise = setupKuboHttpRouters(this).then(() => {
|
|
6908
|
+
if (this.destroyed) return;
|
|
6909
|
+
log("Set http router options successfully on all connected ipfs", Object.keys(this.clients.kuboRpcClients));
|
|
8951
6910
|
}).catch((e) => {
|
|
8952
6911
|
if (this.destroyed) return;
|
|
8953
|
-
log.error("Failed to set http router options
|
|
6912
|
+
log.error("Failed to set http router options on ipfs nodes due to error", e);
|
|
8954
6913
|
this.emit("error", e);
|
|
8955
6914
|
});
|
|
8956
|
-
this.
|
|
6915
|
+
this._httpRouterSetupPromise = setupPromise;
|
|
8957
6916
|
}
|
|
8958
6917
|
}
|
|
8959
6918
|
async _waitForHttpRoutersSetupToSettle() {
|
|
8960
|
-
if (this.
|
|
6919
|
+
if (this._httpRouterSetupPromise) await this._httpRouterSetupPromise;
|
|
8961
6920
|
}
|
|
8962
6921
|
async _init() {
|
|
8963
6922
|
const log = logger_default("pkc-js:pkc:_init");
|
|
@@ -9166,7 +7125,7 @@ var PKC$1 = class extends PKCTypedEmitter {
|
|
|
9166
7125
|
const log = logger_default("pkc-js:pkc:createLocalCommunity");
|
|
9167
7126
|
log.trace("Received community options to create a local community instance:", options);
|
|
9168
7127
|
if (!this._canCreateNewLocalCommunity()) throw new PKCError("ERR_CAN_NOT_CREATE_A_LOCAL_COMMUNITY", { pkcOptions: this._userPKCOptions });
|
|
9169
|
-
const { LocalCommunity, createNewLocalCommunityDb, updateInstancePropsWithStartedCommunityOrDb } = await import("./local-community-
|
|
7128
|
+
const { LocalCommunity, createNewLocalCommunityDb, updateInstancePropsWithStartedCommunityOrDb } = await import("./local-community-B6-jaMsn.js");
|
|
9170
7129
|
const isLocalCommunity = (await listCommunitiesSync(this)).includes(options.address);
|
|
9171
7130
|
const community = new LocalCommunity(this);
|
|
9172
7131
|
if (isLocalCommunity) {
|
|
@@ -9544,13 +7503,9 @@ var PKC$1 = class extends PKCTypedEmitter {
|
|
|
9544
7503
|
for (const community of listUpdatingCommunities(this)) await community.stop();
|
|
9545
7504
|
await Promise.all(listStartedCommunities(this).map((community) => community.stop()));
|
|
9546
7505
|
if (this._communityFsWatchAbort) this._communityFsWatchAbort.abort();
|
|
9547
|
-
if (this.
|
|
9548
|
-
await this.
|
|
9549
|
-
this.
|
|
9550
|
-
}
|
|
9551
|
-
if (this._addressRewriterDestroy) {
|
|
9552
|
-
await this._addressRewriterDestroy();
|
|
9553
|
-
this._addressRewriterDestroy = void 0;
|
|
7506
|
+
if (this._httpRouterSetupPromise) {
|
|
7507
|
+
await this._httpRouterSetupPromise;
|
|
7508
|
+
this._httpRouterSetupPromise = void 0;
|
|
9554
7509
|
}
|
|
9555
7510
|
await this._storage.destroy();
|
|
9556
7511
|
for (const storage of Object.values(this._storageLRUs)) await storage.destroy();
|