@n1xyz/nord-ts 0.3.2 → 0.3.3
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/client/Nord.d.ts +9 -3
- package/dist/gen/openapi.d.ts +247 -4
- package/dist/index.browser.js +11442 -11226
- package/dist/index.common.js +222 -1430
- package/dist/types.d.ts +13 -2
- package/dist/websocket/NordWebSocketClient.d.ts +1 -0
- package/dist/websocket/Subscriber.d.ts +7 -1
- package/dist/websocket/events.d.ts +2 -1
- package/dist/websocket/index.d.ts +1 -1
- package/package.json +2 -2
package/dist/index.common.js
CHANGED
|
@@ -360,7 +360,7 @@ var require_fallback = __commonJS((exports, module) => {
|
|
|
360
360
|
|
|
361
361
|
// node_modules/bufferutil/index.js
|
|
362
362
|
var require_bufferutil = __commonJS((exports, module) => {
|
|
363
|
-
var __dirname = "/Users/
|
|
363
|
+
var __dirname = "/Users/dc/Dev/null-studios/proton/nord/ts/node_modules/bufferutil";
|
|
364
364
|
try {
|
|
365
365
|
module.exports = require_node_gyp_build2()(__dirname);
|
|
366
366
|
} catch (e) {
|
|
@@ -772,7 +772,7 @@ var require_fallback2 = __commonJS((exports, module) => {
|
|
|
772
772
|
|
|
773
773
|
// node_modules/utf-8-validate/index.js
|
|
774
774
|
var require_utf_8_validate = __commonJS((exports, module) => {
|
|
775
|
-
var __dirname = "/Users/
|
|
775
|
+
var __dirname = "/Users/dc/Dev/null-studios/proton/nord/ts/node_modules/utf-8-validate";
|
|
776
776
|
try {
|
|
777
777
|
module.exports = require_node_gyp_build2()(__dirname);
|
|
778
778
|
} catch (e) {
|
|
@@ -23452,7 +23452,7 @@ var require_file_uri_to_path2 = __commonJS((exports, module) => {
|
|
|
23452
23452
|
|
|
23453
23453
|
// node_modules/bindings/bindings.js
|
|
23454
23454
|
var require_bindings2 = __commonJS((exports, module) => {
|
|
23455
|
-
var __filename = "/Users/
|
|
23455
|
+
var __filename = "/Users/dc/Dev/null-studios/proton/nord/ts/node_modules/bindings/bindings.js";
|
|
23456
23456
|
var fs = __require("fs");
|
|
23457
23457
|
var path = __require("path");
|
|
23458
23458
|
var fileURLToPath = require_file_uri_to_path2();
|
|
@@ -31621,12 +31621,12 @@ var SpecialAccount;
|
|
|
31621
31621
|
var SpecialAccountSchema = /* @__PURE__ */ enumDesc(file_nord, 5);
|
|
31622
31622
|
|
|
31623
31623
|
// node_modules/decimal.js/decimal.mjs
|
|
31624
|
-
/*!
|
|
31625
|
-
* decimal.js v10.6.0
|
|
31626
|
-
* An arbitrary-precision Decimal type for JavaScript.
|
|
31627
|
-
* https://github.com/MikeMcl/decimal.js
|
|
31628
|
-
* Copyright (c) 2025 Michael Mclaughlin <M8ch88l@gmail.com>
|
|
31629
|
-
* MIT Licence
|
|
31624
|
+
/*!
|
|
31625
|
+
* decimal.js v10.6.0
|
|
31626
|
+
* An arbitrary-precision Decimal type for JavaScript.
|
|
31627
|
+
* https://github.com/MikeMcl/decimal.js
|
|
31628
|
+
* Copyright (c) 2025 Michael Mclaughlin <M8ch88l@gmail.com>
|
|
31629
|
+
* MIT Licence
|
|
31630
31630
|
*/
|
|
31631
31631
|
var EXP_LIMIT = 9000000000000000;
|
|
31632
31632
|
var MAX_DIGITS = 1e9;
|
|
@@ -57308,7 +57308,7 @@ var import_websocket_server2 = __toESM(require_websocket_server2(), 1);
|
|
|
57308
57308
|
var wrapper_default = import_websocket2.default;
|
|
57309
57309
|
|
|
57310
57310
|
// src/websocket/NordWebSocketClient.ts
|
|
57311
|
-
var VALID_STREAM_TYPES = ["trades", "delta", "account"];
|
|
57311
|
+
var VALID_STREAM_TYPES = ["trades", "delta", "deltas", "account", "candle"];
|
|
57312
57312
|
|
|
57313
57313
|
class NordWebSocketClient extends EventEmitter {
|
|
57314
57314
|
ws = null;
|
|
@@ -57478,8 +57478,19 @@ class NordWebSocketClient extends EventEmitter {
|
|
|
57478
57478
|
this.emit("account", message.account);
|
|
57479
57479
|
return;
|
|
57480
57480
|
}
|
|
57481
|
+
if (this.isCandleUpdate(message)) {
|
|
57482
|
+
this.emit("candle", message);
|
|
57483
|
+
return;
|
|
57484
|
+
}
|
|
57481
57485
|
this.emit("error", new Error(`Unexpected message type: ${message}`));
|
|
57482
57486
|
}
|
|
57487
|
+
isCandleUpdate(message) {
|
|
57488
|
+
if (!message || typeof message !== "object") {
|
|
57489
|
+
return false;
|
|
57490
|
+
}
|
|
57491
|
+
const candidate = message;
|
|
57492
|
+
return typeof candidate.res === "string" && typeof candidate.mid === "number" && typeof candidate.t === "number" && typeof candidate.o === "number" && typeof candidate.h === "number" && typeof candidate.l === "number" && typeof candidate.c === "number" && typeof candidate.v === "number";
|
|
57493
|
+
}
|
|
57483
57494
|
reconnect() {
|
|
57484
57495
|
if (this.reconnectAttempts >= this.maxReconnectAttempts) {
|
|
57485
57496
|
this.emit("error", new Error("Max reconnection attempts reached"));
|
|
@@ -57541,14 +57552,20 @@ function initWebSocketClient(webServerUrl, subscriptions) {
|
|
|
57541
57552
|
}
|
|
57542
57553
|
function validateSubscription(subscription) {
|
|
57543
57554
|
const [type, param] = subscription.split("@");
|
|
57544
|
-
if (!type || !param || !["trades", "deltas", "account"].includes(type)) {
|
|
57545
|
-
throw new NordError(`Invalid subscription format: ${subscription}. Expected format: "trades@SYMBOL", "deltas@SYMBOL",
|
|
57555
|
+
if (!type || !param || !["trades", "deltas", "account", "candle"].includes(type)) {
|
|
57556
|
+
throw new NordError(`Invalid subscription format: ${subscription}. Expected format: "trades@SYMBOL", "deltas@SYMBOL", "account@ID", or "candle@SYMBOL:RESOLUTION"`);
|
|
57546
57557
|
}
|
|
57547
57558
|
if (type === "account" && isNaN(Number(param))) {
|
|
57548
57559
|
throw new NordError(`Invalid account ID in subscription: ${subscription}. Account ID must be a number.`);
|
|
57549
57560
|
}
|
|
57561
|
+
if (type === "candle") {
|
|
57562
|
+
const [symbol2, resolution] = param.split(":");
|
|
57563
|
+
if (!symbol2 || !resolution) {
|
|
57564
|
+
throw new NordError(`Invalid candle subscription format: ${subscription}. Expected format: "candle@SYMBOL:RESOLUTION"`);
|
|
57565
|
+
}
|
|
57566
|
+
}
|
|
57550
57567
|
}
|
|
57551
|
-
//
|
|
57568
|
+
// ../../proton-ts/dist/index.common.js
|
|
57552
57569
|
import { createRequire as createRequire2 } from "node:module";
|
|
57553
57570
|
import { Buffer as Buffer22 } from "buffer";
|
|
57554
57571
|
var __create2 = Object.create;
|
|
@@ -63591,141 +63608,6 @@ var require_sha2562 = __commonJS2((exports) => {
|
|
|
63591
63608
|
exports.SHA224 = sha2_ts_1.SHA224;
|
|
63592
63609
|
exports.sha224 = sha2_ts_1.sha224;
|
|
63593
63610
|
});
|
|
63594
|
-
var require_src22 = __commonJS2((exports, module) => {
|
|
63595
|
-
var _Buffer = require_safe_buffer2().Buffer;
|
|
63596
|
-
function base2(ALPHABET2) {
|
|
63597
|
-
if (ALPHABET2.length >= 255) {
|
|
63598
|
-
throw new TypeError("Alphabet too long");
|
|
63599
|
-
}
|
|
63600
|
-
var BASE_MAP = new Uint8Array(256);
|
|
63601
|
-
for (var j = 0;j < BASE_MAP.length; j++) {
|
|
63602
|
-
BASE_MAP[j] = 255;
|
|
63603
|
-
}
|
|
63604
|
-
for (var i = 0;i < ALPHABET2.length; i++) {
|
|
63605
|
-
var x = ALPHABET2.charAt(i);
|
|
63606
|
-
var xc = x.charCodeAt(0);
|
|
63607
|
-
if (BASE_MAP[xc] !== 255) {
|
|
63608
|
-
throw new TypeError(x + " is ambiguous");
|
|
63609
|
-
}
|
|
63610
|
-
BASE_MAP[xc] = i;
|
|
63611
|
-
}
|
|
63612
|
-
var BASE2 = ALPHABET2.length;
|
|
63613
|
-
var LEADER = ALPHABET2.charAt(0);
|
|
63614
|
-
var FACTOR = Math.log(BASE2) / Math.log(256);
|
|
63615
|
-
var iFACTOR = Math.log(256) / Math.log(BASE2);
|
|
63616
|
-
function encode(source) {
|
|
63617
|
-
if (Array.isArray(source) || source instanceof Uint8Array) {
|
|
63618
|
-
source = _Buffer.from(source);
|
|
63619
|
-
}
|
|
63620
|
-
if (!_Buffer.isBuffer(source)) {
|
|
63621
|
-
throw new TypeError("Expected Buffer");
|
|
63622
|
-
}
|
|
63623
|
-
if (source.length === 0) {
|
|
63624
|
-
return "";
|
|
63625
|
-
}
|
|
63626
|
-
var zeroes = 0;
|
|
63627
|
-
var length = 0;
|
|
63628
|
-
var pbegin = 0;
|
|
63629
|
-
var pend = source.length;
|
|
63630
|
-
while (pbegin !== pend && source[pbegin] === 0) {
|
|
63631
|
-
pbegin++;
|
|
63632
|
-
zeroes++;
|
|
63633
|
-
}
|
|
63634
|
-
var size = (pend - pbegin) * iFACTOR + 1 >>> 0;
|
|
63635
|
-
var b58 = new Uint8Array(size);
|
|
63636
|
-
while (pbegin !== pend) {
|
|
63637
|
-
var carry = source[pbegin];
|
|
63638
|
-
var i2 = 0;
|
|
63639
|
-
for (var it1 = size - 1;(carry !== 0 || i2 < length) && it1 !== -1; it1--, i2++) {
|
|
63640
|
-
carry += 256 * b58[it1] >>> 0;
|
|
63641
|
-
b58[it1] = carry % BASE2 >>> 0;
|
|
63642
|
-
carry = carry / BASE2 >>> 0;
|
|
63643
|
-
}
|
|
63644
|
-
if (carry !== 0) {
|
|
63645
|
-
throw new Error("Non-zero carry");
|
|
63646
|
-
}
|
|
63647
|
-
length = i2;
|
|
63648
|
-
pbegin++;
|
|
63649
|
-
}
|
|
63650
|
-
var it2 = size - length;
|
|
63651
|
-
while (it2 !== size && b58[it2] === 0) {
|
|
63652
|
-
it2++;
|
|
63653
|
-
}
|
|
63654
|
-
var str = LEADER.repeat(zeroes);
|
|
63655
|
-
for (;it2 < size; ++it2) {
|
|
63656
|
-
str += ALPHABET2.charAt(b58[it2]);
|
|
63657
|
-
}
|
|
63658
|
-
return str;
|
|
63659
|
-
}
|
|
63660
|
-
function decodeUnsafe(source) {
|
|
63661
|
-
if (typeof source !== "string") {
|
|
63662
|
-
throw new TypeError("Expected String");
|
|
63663
|
-
}
|
|
63664
|
-
if (source.length === 0) {
|
|
63665
|
-
return _Buffer.alloc(0);
|
|
63666
|
-
}
|
|
63667
|
-
var psz = 0;
|
|
63668
|
-
var zeroes = 0;
|
|
63669
|
-
var length = 0;
|
|
63670
|
-
while (source[psz] === LEADER) {
|
|
63671
|
-
zeroes++;
|
|
63672
|
-
psz++;
|
|
63673
|
-
}
|
|
63674
|
-
var size = (source.length - psz) * FACTOR + 1 >>> 0;
|
|
63675
|
-
var b256 = new Uint8Array(size);
|
|
63676
|
-
while (psz < source.length) {
|
|
63677
|
-
var charCode = source.charCodeAt(psz);
|
|
63678
|
-
if (charCode > 255) {
|
|
63679
|
-
return;
|
|
63680
|
-
}
|
|
63681
|
-
var carry = BASE_MAP[charCode];
|
|
63682
|
-
if (carry === 255) {
|
|
63683
|
-
return;
|
|
63684
|
-
}
|
|
63685
|
-
var i2 = 0;
|
|
63686
|
-
for (var it3 = size - 1;(carry !== 0 || i2 < length) && it3 !== -1; it3--, i2++) {
|
|
63687
|
-
carry += BASE2 * b256[it3] >>> 0;
|
|
63688
|
-
b256[it3] = carry % 256 >>> 0;
|
|
63689
|
-
carry = carry / 256 >>> 0;
|
|
63690
|
-
}
|
|
63691
|
-
if (carry !== 0) {
|
|
63692
|
-
throw new Error("Non-zero carry");
|
|
63693
|
-
}
|
|
63694
|
-
length = i2;
|
|
63695
|
-
psz++;
|
|
63696
|
-
}
|
|
63697
|
-
var it4 = size - length;
|
|
63698
|
-
while (it4 !== size && b256[it4] === 0) {
|
|
63699
|
-
it4++;
|
|
63700
|
-
}
|
|
63701
|
-
var vch = _Buffer.allocUnsafe(zeroes + (size - it4));
|
|
63702
|
-
vch.fill(0, 0, zeroes);
|
|
63703
|
-
var j2 = zeroes;
|
|
63704
|
-
while (it4 !== size) {
|
|
63705
|
-
vch[j2++] = b256[it4++];
|
|
63706
|
-
}
|
|
63707
|
-
return vch;
|
|
63708
|
-
}
|
|
63709
|
-
function decode2(string) {
|
|
63710
|
-
var buffer2 = decodeUnsafe(string);
|
|
63711
|
-
if (buffer2) {
|
|
63712
|
-
return buffer2;
|
|
63713
|
-
}
|
|
63714
|
-
throw new Error("Non-base" + BASE2 + " character");
|
|
63715
|
-
}
|
|
63716
|
-
return {
|
|
63717
|
-
encode,
|
|
63718
|
-
decodeUnsafe,
|
|
63719
|
-
decode: decode2
|
|
63720
|
-
};
|
|
63721
|
-
}
|
|
63722
|
-
module.exports = base2;
|
|
63723
|
-
});
|
|
63724
|
-
var require_bs5822 = __commonJS2((exports, module) => {
|
|
63725
|
-
var basex = require_src22();
|
|
63726
|
-
var ALPHABET2 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
63727
|
-
module.exports = basex(ALPHABET2);
|
|
63728
|
-
});
|
|
63729
63611
|
var require_encoding_lib2 = __commonJS2((exports) => {
|
|
63730
63612
|
function inRange(a, min2, max2) {
|
|
63731
63613
|
return min2 <= a && a <= max2;
|
|
@@ -64071,7 +63953,7 @@ var require_lib5 = __commonJS2((exports) => {
|
|
|
64071
63953
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
64072
63954
|
exports.deserializeUnchecked = exports.deserialize = exports.serialize = exports.BinaryReader = exports.BinaryWriter = exports.BorshError = exports.baseDecode = exports.baseEncode = undefined;
|
|
64073
63955
|
var bn_js_1 = __importDefault(require_bn2());
|
|
64074
|
-
var bs58_1 = __importDefault(
|
|
63956
|
+
var bs58_1 = __importDefault(require_bs583());
|
|
64075
63957
|
var encoding = __importStar(require_encoding_lib2());
|
|
64076
63958
|
var ResolvedTextDecoder = typeof TextDecoder !== "function" ? encoding.TextDecoder : TextDecoder;
|
|
64077
63959
|
var textDecoder = new ResolvedTextDecoder("utf-8", { fatal: true });
|
|
@@ -71770,7 +71652,7 @@ var require_fallback3 = __commonJS2((exports, module) => {
|
|
|
71770
71652
|
module.exports = { mask: mask2, unmask };
|
|
71771
71653
|
});
|
|
71772
71654
|
var require_bufferutil2 = __commonJS2((exports, module) => {
|
|
71773
|
-
var __dirname2 = "/Users/
|
|
71655
|
+
var __dirname2 = "/Users/dc/Dev/null-studios/proton/proton-ts/node_modules/bufferutil";
|
|
71774
71656
|
try {
|
|
71775
71657
|
module.exports = require_node_gyp_build22()(__dirname2);
|
|
71776
71658
|
} catch (e) {
|
|
@@ -72176,7 +72058,7 @@ var require_fallback22 = __commonJS2((exports, module) => {
|
|
|
72176
72058
|
module.exports = isValidUTF8;
|
|
72177
72059
|
});
|
|
72178
72060
|
var require_utf_8_validate2 = __commonJS2((exports, module) => {
|
|
72179
|
-
var __dirname2 = "/Users/
|
|
72061
|
+
var __dirname2 = "/Users/dc/Dev/null-studios/proton/proton-ts/node_modules/utf-8-validate";
|
|
72180
72062
|
try {
|
|
72181
72063
|
module.exports = require_node_gyp_build22()(__dirname2);
|
|
72182
72064
|
} catch (e) {
|
|
@@ -84904,14 +84786,14 @@ var require_utf8 = __commonJS2((exports) => {
|
|
|
84904
84786
|
return encoder.encode(input);
|
|
84905
84787
|
}
|
|
84906
84788
|
});
|
|
84907
|
-
var
|
|
84789
|
+
var require_bs5822 = __commonJS2((exports) => {
|
|
84908
84790
|
var __importDefault = exports && exports.__importDefault || function(mod3) {
|
|
84909
84791
|
return mod3 && mod3.__esModule ? mod3 : { default: mod3 };
|
|
84910
84792
|
};
|
|
84911
84793
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
84912
84794
|
exports.encode = encode;
|
|
84913
84795
|
exports.decode = decode2;
|
|
84914
|
-
var bs58_1 = __importDefault(
|
|
84796
|
+
var bs58_1 = __importDefault(require_bs583());
|
|
84915
84797
|
function encode(data4) {
|
|
84916
84798
|
return bs58_1.default.encode(data4);
|
|
84917
84799
|
}
|
|
@@ -84968,7 +84850,7 @@ var require_bytes = __commonJS2((exports) => {
|
|
|
84968
84850
|
exports.base64 = exports.bs58 = exports.utf8 = exports.hex = undefined;
|
|
84969
84851
|
exports.hex = __importStar(require_hex());
|
|
84970
84852
|
exports.utf8 = __importStar(require_utf8());
|
|
84971
|
-
exports.bs58 = __importStar(
|
|
84853
|
+
exports.bs58 = __importStar(require_bs5822());
|
|
84972
84854
|
exports.base64 = __importStar(require_base64());
|
|
84973
84855
|
});
|
|
84974
84856
|
var require_camelcase = __commonJS2((exports, module) => {
|
|
@@ -89001,7 +88883,7 @@ var require_instruction = __commonJS2((exports) => {
|
|
|
89001
88883
|
};
|
|
89002
88884
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
89003
88885
|
exports.BorshInstructionCoder = undefined;
|
|
89004
|
-
var bs58_1 = __importDefault(
|
|
88886
|
+
var bs58_1 = __importDefault(require_bs583());
|
|
89005
88887
|
var buffer_1 = __require2("buffer");
|
|
89006
88888
|
var borsh2 = __importStar(require_dist42());
|
|
89007
88889
|
var idl_js_1 = require_idl();
|
|
@@ -89211,7 +89093,7 @@ var require_accounts = __commonJS2((exports) => {
|
|
|
89211
89093
|
};
|
|
89212
89094
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
89213
89095
|
exports.BorshAccountsCoder = undefined;
|
|
89214
|
-
var bs58_1 = __importDefault(
|
|
89096
|
+
var bs58_1 = __importDefault(require_bs583());
|
|
89215
89097
|
var buffer_1 = __require2("buffer");
|
|
89216
89098
|
var idl_js_1 = require_idl2();
|
|
89217
89099
|
|
|
@@ -89923,1289 +89805,159 @@ var require_token = __commonJS2((exports) => {
|
|
|
89923
89805
|
return web3_js_1.PublicKey.findProgramAddressSync([owner.toBuffer(), exports.TOKEN_PROGRAM_ID.toBuffer(), mint.toBuffer()], exports.ASSOCIATED_PROGRAM_ID)[0];
|
|
89924
89806
|
}
|
|
89925
89807
|
});
|
|
89926
|
-
var
|
|
89927
|
-
|
|
89928
|
-
|
|
89929
|
-
|
|
89930
|
-
|
|
89931
|
-
|
|
89932
|
-
var http2 = _interopDefault(__require2("http"));
|
|
89933
|
-
var Url = _interopDefault(__require2("url"));
|
|
89934
|
-
var whatwgUrl = _interopDefault(require_public_api2());
|
|
89935
|
-
var https2 = _interopDefault(__require2("https"));
|
|
89936
|
-
var zlib = _interopDefault(__require2("zlib"));
|
|
89937
|
-
var Readable = Stream.Readable;
|
|
89938
|
-
var BUFFER = Symbol("buffer");
|
|
89939
|
-
var TYPE = Symbol("type");
|
|
89940
|
-
|
|
89941
|
-
class Blob2 {
|
|
89942
|
-
constructor() {
|
|
89943
|
-
this[TYPE] = "";
|
|
89944
|
-
const blobParts = arguments[0];
|
|
89945
|
-
const options = arguments[1];
|
|
89946
|
-
const buffers = [];
|
|
89947
|
-
let size = 0;
|
|
89948
|
-
if (blobParts) {
|
|
89949
|
-
const a = blobParts;
|
|
89950
|
-
const length = Number(a.length);
|
|
89951
|
-
for (let i = 0;i < length; i++) {
|
|
89952
|
-
const element = a[i];
|
|
89953
|
-
let buffer2;
|
|
89954
|
-
if (element instanceof Buffer) {
|
|
89955
|
-
buffer2 = element;
|
|
89956
|
-
} else if (ArrayBuffer.isView(element)) {
|
|
89957
|
-
buffer2 = Buffer.from(element.buffer, element.byteOffset, element.byteLength);
|
|
89958
|
-
} else if (element instanceof ArrayBuffer) {
|
|
89959
|
-
buffer2 = Buffer.from(element);
|
|
89960
|
-
} else if (element instanceof Blob2) {
|
|
89961
|
-
buffer2 = element[BUFFER];
|
|
89962
|
-
} else {
|
|
89963
|
-
buffer2 = Buffer.from(typeof element === "string" ? element : String(element));
|
|
89964
|
-
}
|
|
89965
|
-
size += buffer2.length;
|
|
89966
|
-
buffers.push(buffer2);
|
|
89967
|
-
}
|
|
89968
|
-
}
|
|
89969
|
-
this[BUFFER] = Buffer.concat(buffers);
|
|
89970
|
-
let type = options && options.type !== undefined && String(options.type).toLowerCase();
|
|
89971
|
-
if (type && !/[^\u0020-\u007E]/.test(type)) {
|
|
89972
|
-
this[TYPE] = type;
|
|
89973
|
-
}
|
|
89974
|
-
}
|
|
89975
|
-
get size() {
|
|
89976
|
-
return this[BUFFER].length;
|
|
89977
|
-
}
|
|
89978
|
-
get type() {
|
|
89979
|
-
return this[TYPE];
|
|
89980
|
-
}
|
|
89981
|
-
text() {
|
|
89982
|
-
return Promise.resolve(this[BUFFER].toString());
|
|
89983
|
-
}
|
|
89984
|
-
arrayBuffer() {
|
|
89985
|
-
const buf = this[BUFFER];
|
|
89986
|
-
const ab = buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
|
|
89987
|
-
return Promise.resolve(ab);
|
|
89988
|
-
}
|
|
89989
|
-
stream() {
|
|
89990
|
-
const readable = new Readable;
|
|
89991
|
-
readable._read = function() {};
|
|
89992
|
-
readable.push(this[BUFFER]);
|
|
89993
|
-
readable.push(null);
|
|
89994
|
-
return readable;
|
|
89995
|
-
}
|
|
89996
|
-
toString() {
|
|
89997
|
-
return "[object Blob]";
|
|
89808
|
+
var require_node_ponyfill = __commonJS2((exports, module) => {
|
|
89809
|
+
var nodeFetch2 = require_lib32();
|
|
89810
|
+
var realFetch = nodeFetch2.default || nodeFetch2;
|
|
89811
|
+
var fetch2 = function(url, options) {
|
|
89812
|
+
if (/^\/\//.test(url)) {
|
|
89813
|
+
url = "https:" + url;
|
|
89998
89814
|
}
|
|
89999
|
-
|
|
90000
|
-
|
|
90001
|
-
|
|
90002
|
-
|
|
90003
|
-
|
|
90004
|
-
|
|
90005
|
-
|
|
90006
|
-
|
|
90007
|
-
|
|
90008
|
-
|
|
90009
|
-
|
|
90010
|
-
|
|
90011
|
-
|
|
90012
|
-
|
|
90013
|
-
|
|
90014
|
-
|
|
90015
|
-
|
|
90016
|
-
|
|
90017
|
-
}
|
|
90018
|
-
const span = Math.max(relativeEnd - relativeStart, 0);
|
|
90019
|
-
const buffer2 = this[BUFFER];
|
|
90020
|
-
const slicedBuffer = buffer2.slice(relativeStart, relativeStart + span);
|
|
90021
|
-
const blob = new Blob2([], { type: arguments[2] });
|
|
90022
|
-
blob[BUFFER] = slicedBuffer;
|
|
90023
|
-
return blob;
|
|
89815
|
+
return realFetch.call(this, url, options);
|
|
89816
|
+
};
|
|
89817
|
+
fetch2.ponyfill = true;
|
|
89818
|
+
module.exports = exports = fetch2;
|
|
89819
|
+
exports.fetch = fetch2;
|
|
89820
|
+
exports.Headers = nodeFetch2.Headers;
|
|
89821
|
+
exports.Request = nodeFetch2.Request;
|
|
89822
|
+
exports.Response = nodeFetch2.Response;
|
|
89823
|
+
exports.default = fetch2;
|
|
89824
|
+
});
|
|
89825
|
+
var require_registry = __commonJS2((exports) => {
|
|
89826
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
89827
|
+
if (k2 === undefined)
|
|
89828
|
+
k2 = k;
|
|
89829
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
89830
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
89831
|
+
desc = { enumerable: true, get: function() {
|
|
89832
|
+
return m[k];
|
|
89833
|
+
} };
|
|
90024
89834
|
}
|
|
90025
|
-
|
|
90026
|
-
|
|
90027
|
-
|
|
90028
|
-
|
|
90029
|
-
|
|
89835
|
+
Object.defineProperty(o, k2, desc);
|
|
89836
|
+
} : function(o, m, k, k2) {
|
|
89837
|
+
if (k2 === undefined)
|
|
89838
|
+
k2 = k;
|
|
89839
|
+
o[k2] = m[k];
|
|
90030
89840
|
});
|
|
90031
|
-
|
|
90032
|
-
|
|
90033
|
-
|
|
90034
|
-
|
|
90035
|
-
configurable: true
|
|
89841
|
+
var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
|
|
89842
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
89843
|
+
} : function(o, v) {
|
|
89844
|
+
o["default"] = v;
|
|
90036
89845
|
});
|
|
90037
|
-
|
|
90038
|
-
|
|
90039
|
-
|
|
90040
|
-
|
|
90041
|
-
if (
|
|
90042
|
-
|
|
89846
|
+
var __importStar = exports && exports.__importStar || function(mod3) {
|
|
89847
|
+
if (mod3 && mod3.__esModule)
|
|
89848
|
+
return mod3;
|
|
89849
|
+
var result = {};
|
|
89850
|
+
if (mod3 != null) {
|
|
89851
|
+
for (var k in mod3)
|
|
89852
|
+
if (k !== "default" && Object.prototype.hasOwnProperty.call(mod3, k))
|
|
89853
|
+
__createBinding(result, mod3, k);
|
|
90043
89854
|
}
|
|
90044
|
-
|
|
89855
|
+
__setModuleDefault(result, mod3);
|
|
89856
|
+
return result;
|
|
89857
|
+
};
|
|
89858
|
+
var __importDefault = exports && exports.__importDefault || function(mod3) {
|
|
89859
|
+
return mod3 && mod3.__esModule ? mod3 : { default: mod3 };
|
|
89860
|
+
};
|
|
89861
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
89862
|
+
exports.verifiedBuild = verifiedBuild;
|
|
89863
|
+
exports.fetchData = fetchData;
|
|
89864
|
+
exports.decodeUpgradeableLoaderState = decodeUpgradeableLoaderState;
|
|
89865
|
+
var cross_fetch_1 = __importDefault(require_node_ponyfill());
|
|
89866
|
+
var borsh2 = __importStar(require_dist42());
|
|
89867
|
+
async function verifiedBuild(connection, programId, limit = 5) {
|
|
89868
|
+
const url = `https://api.apr.dev/api/v0/program/${programId.toString()}/latest?limit=${limit}`;
|
|
89869
|
+
const [programData, latestBuildsResp] = await Promise.all([
|
|
89870
|
+
fetchData(connection, programId),
|
|
89871
|
+
(0, cross_fetch_1.default)(url)
|
|
89872
|
+
]);
|
|
89873
|
+
const latestBuilds = (await latestBuildsResp.json()).filter((b2) => !b2.aborted && b2.state === "Built" && b2.verified === "Verified");
|
|
89874
|
+
if (latestBuilds.length === 0) {
|
|
89875
|
+
return null;
|
|
89876
|
+
}
|
|
89877
|
+
const build = latestBuilds[0];
|
|
89878
|
+
if (programData.slot.toNumber() !== build.verified_slot) {
|
|
89879
|
+
return null;
|
|
89880
|
+
}
|
|
89881
|
+
return build;
|
|
90045
89882
|
}
|
|
90046
|
-
|
|
90047
|
-
|
|
90048
|
-
|
|
90049
|
-
|
|
90050
|
-
try {
|
|
90051
|
-
convert = (() => {
|
|
90052
|
-
throw new Error("Cannot require module " + "encoding");
|
|
90053
|
-
})().convert;
|
|
90054
|
-
} catch (e) {}
|
|
90055
|
-
var INTERNALS = Symbol("Body internals");
|
|
90056
|
-
var PassThrough = Stream.PassThrough;
|
|
90057
|
-
function Body(body) {
|
|
90058
|
-
var _this = this;
|
|
90059
|
-
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, _ref$size = _ref.size;
|
|
90060
|
-
let size = _ref$size === undefined ? 0 : _ref$size;
|
|
90061
|
-
var _ref$timeout = _ref.timeout;
|
|
90062
|
-
let timeout = _ref$timeout === undefined ? 0 : _ref$timeout;
|
|
90063
|
-
if (body == null) {
|
|
90064
|
-
body = null;
|
|
90065
|
-
} else if (isURLSearchParams(body)) {
|
|
90066
|
-
body = Buffer.from(body.toString());
|
|
90067
|
-
} else if (isBlob(body))
|
|
90068
|
-
;
|
|
90069
|
-
else if (Buffer.isBuffer(body))
|
|
90070
|
-
;
|
|
90071
|
-
else if (Object.prototype.toString.call(body) === "[object ArrayBuffer]") {
|
|
90072
|
-
body = Buffer.from(body);
|
|
90073
|
-
} else if (ArrayBuffer.isView(body)) {
|
|
90074
|
-
body = Buffer.from(body.buffer, body.byteOffset, body.byteLength);
|
|
90075
|
-
} else if (body instanceof Stream)
|
|
90076
|
-
;
|
|
90077
|
-
else {
|
|
90078
|
-
body = Buffer.from(String(body));
|
|
89883
|
+
async function fetchData(connection, programId) {
|
|
89884
|
+
const accountInfo = await connection.getAccountInfo(programId);
|
|
89885
|
+
if (accountInfo === null) {
|
|
89886
|
+
throw new Error("program account not found");
|
|
90079
89887
|
}
|
|
90080
|
-
|
|
90081
|
-
|
|
90082
|
-
|
|
90083
|
-
|
|
90084
|
-
};
|
|
90085
|
-
this.size = size;
|
|
90086
|
-
this.timeout = timeout;
|
|
90087
|
-
if (body instanceof Stream) {
|
|
90088
|
-
body.on("error", function(err) {
|
|
90089
|
-
const error = err.name === "AbortError" ? err : new FetchError(`Invalid response body while trying to fetch ${_this.url}: ${err.message}`, "system", err);
|
|
90090
|
-
_this[INTERNALS].error = error;
|
|
90091
|
-
});
|
|
89888
|
+
const { program } = decodeUpgradeableLoaderState(accountInfo.data);
|
|
89889
|
+
const programdataAccountInfo = await connection.getAccountInfo(program.programdataAddress);
|
|
89890
|
+
if (programdataAccountInfo === null) {
|
|
89891
|
+
throw new Error("program data account not found");
|
|
90092
89892
|
}
|
|
89893
|
+
const { programData } = decodeUpgradeableLoaderState(programdataAccountInfo.data);
|
|
89894
|
+
return programData;
|
|
90093
89895
|
}
|
|
90094
|
-
|
|
90095
|
-
|
|
90096
|
-
|
|
90097
|
-
|
|
90098
|
-
|
|
90099
|
-
|
|
90100
|
-
|
|
90101
|
-
|
|
90102
|
-
|
|
90103
|
-
|
|
90104
|
-
|
|
90105
|
-
|
|
90106
|
-
|
|
90107
|
-
|
|
90108
|
-
|
|
90109
|
-
|
|
90110
|
-
|
|
90111
|
-
|
|
90112
|
-
|
|
90113
|
-
|
|
90114
|
-
|
|
90115
|
-
|
|
90116
|
-
json() {
|
|
90117
|
-
var _this2 = this;
|
|
90118
|
-
return consumeBody.call(this).then(function(buffer2) {
|
|
90119
|
-
try {
|
|
90120
|
-
return JSON.parse(buffer2.toString());
|
|
90121
|
-
} catch (err) {
|
|
90122
|
-
return Body.Promise.reject(new FetchError(`invalid json response body at ${_this2.url} reason: ${err.message}`, "invalid-json"));
|
|
90123
|
-
}
|
|
90124
|
-
});
|
|
90125
|
-
},
|
|
90126
|
-
text() {
|
|
90127
|
-
return consumeBody.call(this).then(function(buffer2) {
|
|
90128
|
-
return buffer2.toString();
|
|
90129
|
-
});
|
|
90130
|
-
},
|
|
90131
|
-
buffer() {
|
|
90132
|
-
return consumeBody.call(this);
|
|
90133
|
-
},
|
|
90134
|
-
textConverted() {
|
|
90135
|
-
var _this3 = this;
|
|
90136
|
-
return consumeBody.call(this).then(function(buffer2) {
|
|
90137
|
-
return convertBody(buffer2, _this3.headers);
|
|
90138
|
-
});
|
|
89896
|
+
var UPGRADEABLE_LOADER_STATE_LAYOUT = borsh2.rustEnum([
|
|
89897
|
+
borsh2.struct([], "uninitialized"),
|
|
89898
|
+
borsh2.struct([borsh2.option(borsh2.publicKey(), "authorityAddress")], "buffer"),
|
|
89899
|
+
borsh2.struct([borsh2.publicKey("programdataAddress")], "program"),
|
|
89900
|
+
borsh2.struct([
|
|
89901
|
+
borsh2.u64("slot"),
|
|
89902
|
+
borsh2.option(borsh2.publicKey(), "upgradeAuthorityAddress")
|
|
89903
|
+
], "programData")
|
|
89904
|
+
], undefined, borsh2.u32());
|
|
89905
|
+
function decodeUpgradeableLoaderState(data4) {
|
|
89906
|
+
return UPGRADEABLE_LOADER_STATE_LAYOUT.decode(data4);
|
|
89907
|
+
}
|
|
89908
|
+
});
|
|
89909
|
+
var require_utils42 = __commonJS2((exports) => {
|
|
89910
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
89911
|
+
if (k2 === undefined)
|
|
89912
|
+
k2 = k;
|
|
89913
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
89914
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
89915
|
+
desc = { enumerable: true, get: function() {
|
|
89916
|
+
return m[k];
|
|
89917
|
+
} };
|
|
90139
89918
|
}
|
|
90140
|
-
|
|
90141
|
-
|
|
90142
|
-
|
|
90143
|
-
|
|
90144
|
-
|
|
90145
|
-
blob: { enumerable: true },
|
|
90146
|
-
json: { enumerable: true },
|
|
90147
|
-
text: { enumerable: true }
|
|
89919
|
+
Object.defineProperty(o, k2, desc);
|
|
89920
|
+
} : function(o, m, k, k2) {
|
|
89921
|
+
if (k2 === undefined)
|
|
89922
|
+
k2 = k;
|
|
89923
|
+
o[k2] = m[k];
|
|
90148
89924
|
});
|
|
90149
|
-
|
|
90150
|
-
|
|
90151
|
-
|
|
90152
|
-
|
|
90153
|
-
|
|
90154
|
-
|
|
89925
|
+
var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
|
|
89926
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
89927
|
+
} : function(o, v) {
|
|
89928
|
+
o["default"] = v;
|
|
89929
|
+
});
|
|
89930
|
+
var __importStar = exports && exports.__importStar || function(mod3) {
|
|
89931
|
+
if (mod3 && mod3.__esModule)
|
|
89932
|
+
return mod3;
|
|
89933
|
+
var result = {};
|
|
89934
|
+
if (mod3 != null) {
|
|
89935
|
+
for (var k in mod3)
|
|
89936
|
+
if (k !== "default" && Object.prototype.hasOwnProperty.call(mod3, k))
|
|
89937
|
+
__createBinding(result, mod3, k);
|
|
90155
89938
|
}
|
|
89939
|
+
__setModuleDefault(result, mod3);
|
|
89940
|
+
return result;
|
|
90156
89941
|
};
|
|
90157
|
-
|
|
90158
|
-
|
|
90159
|
-
|
|
90160
|
-
|
|
90161
|
-
|
|
90162
|
-
|
|
90163
|
-
|
|
90164
|
-
|
|
90165
|
-
|
|
90166
|
-
|
|
90167
|
-
|
|
90168
|
-
|
|
90169
|
-
|
|
90170
|
-
|
|
90171
|
-
|
|
90172
|
-
|
|
90173
|
-
|
|
90174
|
-
|
|
90175
|
-
|
|
90176
|
-
if (!(body instanceof Stream)) {
|
|
90177
|
-
return Body.Promise.resolve(Buffer.alloc(0));
|
|
90178
|
-
}
|
|
90179
|
-
let accum = [];
|
|
90180
|
-
let accumBytes = 0;
|
|
90181
|
-
let abort = false;
|
|
90182
|
-
return new Body.Promise(function(resolve, reject) {
|
|
90183
|
-
let resTimeout;
|
|
90184
|
-
if (_this4.timeout) {
|
|
90185
|
-
resTimeout = setTimeout(function() {
|
|
90186
|
-
abort = true;
|
|
90187
|
-
reject(new FetchError(`Response timeout while trying to fetch ${_this4.url} (over ${_this4.timeout}ms)`, "body-timeout"));
|
|
90188
|
-
}, _this4.timeout);
|
|
90189
|
-
}
|
|
90190
|
-
body.on("error", function(err) {
|
|
90191
|
-
if (err.name === "AbortError") {
|
|
90192
|
-
abort = true;
|
|
90193
|
-
reject(err);
|
|
90194
|
-
} else {
|
|
90195
|
-
reject(new FetchError(`Invalid response body while trying to fetch ${_this4.url}: ${err.message}`, "system", err));
|
|
90196
|
-
}
|
|
90197
|
-
});
|
|
90198
|
-
body.on("data", function(chunk) {
|
|
90199
|
-
if (abort || chunk === null) {
|
|
90200
|
-
return;
|
|
90201
|
-
}
|
|
90202
|
-
if (_this4.size && accumBytes + chunk.length > _this4.size) {
|
|
90203
|
-
abort = true;
|
|
90204
|
-
reject(new FetchError(`content size at ${_this4.url} over limit: ${_this4.size}`, "max-size"));
|
|
90205
|
-
return;
|
|
90206
|
-
}
|
|
90207
|
-
accumBytes += chunk.length;
|
|
90208
|
-
accum.push(chunk);
|
|
90209
|
-
});
|
|
90210
|
-
body.on("end", function() {
|
|
90211
|
-
if (abort) {
|
|
90212
|
-
return;
|
|
90213
|
-
}
|
|
90214
|
-
clearTimeout(resTimeout);
|
|
90215
|
-
try {
|
|
90216
|
-
resolve(Buffer.concat(accum, accumBytes));
|
|
90217
|
-
} catch (err) {
|
|
90218
|
-
reject(new FetchError(`Could not create Buffer from response body for ${_this4.url}: ${err.message}`, "system", err));
|
|
90219
|
-
}
|
|
90220
|
-
});
|
|
90221
|
-
});
|
|
90222
|
-
}
|
|
90223
|
-
function convertBody(buffer2, headers) {
|
|
90224
|
-
if (typeof convert !== "function") {
|
|
90225
|
-
throw new Error("The package `encoding` must be installed to use the textConverted() function");
|
|
90226
|
-
}
|
|
90227
|
-
const ct = headers.get("content-type");
|
|
90228
|
-
let charset = "utf-8";
|
|
90229
|
-
let res, str;
|
|
90230
|
-
if (ct) {
|
|
90231
|
-
res = /charset=([^;]*)/i.exec(ct);
|
|
90232
|
-
}
|
|
90233
|
-
str = buffer2.slice(0, 1024).toString();
|
|
90234
|
-
if (!res && str) {
|
|
90235
|
-
res = /<meta.+?charset=(['"])(.+?)\1/i.exec(str);
|
|
90236
|
-
}
|
|
90237
|
-
if (!res && str) {
|
|
90238
|
-
res = /<meta[\s]+?http-equiv=(['"])content-type\1[\s]+?content=(['"])(.+?)\2/i.exec(str);
|
|
90239
|
-
if (!res) {
|
|
90240
|
-
res = /<meta[\s]+?content=(['"])(.+?)\1[\s]+?http-equiv=(['"])content-type\3/i.exec(str);
|
|
90241
|
-
if (res) {
|
|
90242
|
-
res.pop();
|
|
90243
|
-
}
|
|
90244
|
-
}
|
|
90245
|
-
if (res) {
|
|
90246
|
-
res = /charset=(.*)/i.exec(res.pop());
|
|
90247
|
-
}
|
|
90248
|
-
}
|
|
90249
|
-
if (!res && str) {
|
|
90250
|
-
res = /<\?xml.+?encoding=(['"])(.+?)\1/i.exec(str);
|
|
90251
|
-
}
|
|
90252
|
-
if (res) {
|
|
90253
|
-
charset = res.pop();
|
|
90254
|
-
if (charset === "gb2312" || charset === "gbk") {
|
|
90255
|
-
charset = "gb18030";
|
|
90256
|
-
}
|
|
90257
|
-
}
|
|
90258
|
-
return convert(buffer2, "UTF-8", charset).toString();
|
|
90259
|
-
}
|
|
90260
|
-
function isURLSearchParams(obj) {
|
|
90261
|
-
if (typeof obj !== "object" || typeof obj.append !== "function" || typeof obj.delete !== "function" || typeof obj.get !== "function" || typeof obj.getAll !== "function" || typeof obj.has !== "function" || typeof obj.set !== "function") {
|
|
90262
|
-
return false;
|
|
90263
|
-
}
|
|
90264
|
-
return obj.constructor.name === "URLSearchParams" || Object.prototype.toString.call(obj) === "[object URLSearchParams]" || typeof obj.sort === "function";
|
|
90265
|
-
}
|
|
90266
|
-
function isBlob(obj) {
|
|
90267
|
-
return typeof obj === "object" && typeof obj.arrayBuffer === "function" && typeof obj.type === "string" && typeof obj.stream === "function" && typeof obj.constructor === "function" && typeof obj.constructor.name === "string" && /^(Blob|File)$/.test(obj.constructor.name) && /^(Blob|File)$/.test(obj[Symbol.toStringTag]);
|
|
90268
|
-
}
|
|
90269
|
-
function clone3(instance) {
|
|
90270
|
-
let p1, p2;
|
|
90271
|
-
let body = instance.body;
|
|
90272
|
-
if (instance.bodyUsed) {
|
|
90273
|
-
throw new Error("cannot clone body after it is used");
|
|
90274
|
-
}
|
|
90275
|
-
if (body instanceof Stream && typeof body.getBoundary !== "function") {
|
|
90276
|
-
p1 = new PassThrough;
|
|
90277
|
-
p2 = new PassThrough;
|
|
90278
|
-
body.pipe(p1);
|
|
90279
|
-
body.pipe(p2);
|
|
90280
|
-
instance[INTERNALS].body = p1;
|
|
90281
|
-
body = p2;
|
|
90282
|
-
}
|
|
90283
|
-
return body;
|
|
90284
|
-
}
|
|
90285
|
-
function extractContentType(body) {
|
|
90286
|
-
if (body === null) {
|
|
90287
|
-
return null;
|
|
90288
|
-
} else if (typeof body === "string") {
|
|
90289
|
-
return "text/plain;charset=UTF-8";
|
|
90290
|
-
} else if (isURLSearchParams(body)) {
|
|
90291
|
-
return "application/x-www-form-urlencoded;charset=UTF-8";
|
|
90292
|
-
} else if (isBlob(body)) {
|
|
90293
|
-
return body.type || null;
|
|
90294
|
-
} else if (Buffer.isBuffer(body)) {
|
|
90295
|
-
return null;
|
|
90296
|
-
} else if (Object.prototype.toString.call(body) === "[object ArrayBuffer]") {
|
|
90297
|
-
return null;
|
|
90298
|
-
} else if (ArrayBuffer.isView(body)) {
|
|
90299
|
-
return null;
|
|
90300
|
-
} else if (typeof body.getBoundary === "function") {
|
|
90301
|
-
return `multipart/form-data;boundary=${body.getBoundary()}`;
|
|
90302
|
-
} else if (body instanceof Stream) {
|
|
90303
|
-
return null;
|
|
90304
|
-
} else {
|
|
90305
|
-
return "text/plain;charset=UTF-8";
|
|
90306
|
-
}
|
|
90307
|
-
}
|
|
90308
|
-
function getTotalBytes(instance) {
|
|
90309
|
-
const body = instance.body;
|
|
90310
|
-
if (body === null) {
|
|
90311
|
-
return 0;
|
|
90312
|
-
} else if (isBlob(body)) {
|
|
90313
|
-
return body.size;
|
|
90314
|
-
} else if (Buffer.isBuffer(body)) {
|
|
90315
|
-
return body.length;
|
|
90316
|
-
} else if (body && typeof body.getLengthSync === "function") {
|
|
90317
|
-
if (body._lengthRetrievers && body._lengthRetrievers.length == 0 || body.hasKnownLength && body.hasKnownLength()) {
|
|
90318
|
-
return body.getLengthSync();
|
|
90319
|
-
}
|
|
90320
|
-
return null;
|
|
90321
|
-
} else {
|
|
90322
|
-
return null;
|
|
90323
|
-
}
|
|
90324
|
-
}
|
|
90325
|
-
function writeToStream(dest, instance) {
|
|
90326
|
-
const body = instance.body;
|
|
90327
|
-
if (body === null) {
|
|
90328
|
-
dest.end();
|
|
90329
|
-
} else if (isBlob(body)) {
|
|
90330
|
-
body.stream().pipe(dest);
|
|
90331
|
-
} else if (Buffer.isBuffer(body)) {
|
|
90332
|
-
dest.write(body);
|
|
90333
|
-
dest.end();
|
|
90334
|
-
} else {
|
|
90335
|
-
body.pipe(dest);
|
|
90336
|
-
}
|
|
90337
|
-
}
|
|
90338
|
-
Body.Promise = global.Promise;
|
|
90339
|
-
var invalidTokenRegex = /[^\^_`a-zA-Z\-0-9!#$%&'*+.|~]/;
|
|
90340
|
-
var invalidHeaderCharRegex = /[^\t\x20-\x7e\x80-\xff]/;
|
|
90341
|
-
function validateName(name) {
|
|
90342
|
-
name = `${name}`;
|
|
90343
|
-
if (invalidTokenRegex.test(name) || name === "") {
|
|
90344
|
-
throw new TypeError(`${name} is not a legal HTTP header name`);
|
|
90345
|
-
}
|
|
90346
|
-
}
|
|
90347
|
-
function validateValue(value) {
|
|
90348
|
-
value = `${value}`;
|
|
90349
|
-
if (invalidHeaderCharRegex.test(value)) {
|
|
90350
|
-
throw new TypeError(`${value} is not a legal HTTP header value`);
|
|
90351
|
-
}
|
|
90352
|
-
}
|
|
90353
|
-
function find(map, name) {
|
|
90354
|
-
name = name.toLowerCase();
|
|
90355
|
-
for (const key in map) {
|
|
90356
|
-
if (key.toLowerCase() === name) {
|
|
90357
|
-
return key;
|
|
90358
|
-
}
|
|
90359
|
-
}
|
|
90360
|
-
return;
|
|
90361
|
-
}
|
|
90362
|
-
var MAP = Symbol("map");
|
|
90363
|
-
|
|
90364
|
-
class Headers2 {
|
|
90365
|
-
constructor() {
|
|
90366
|
-
let init2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : undefined;
|
|
90367
|
-
this[MAP] = Object.create(null);
|
|
90368
|
-
if (init2 instanceof Headers2) {
|
|
90369
|
-
const rawHeaders = init2.raw();
|
|
90370
|
-
const headerNames = Object.keys(rawHeaders);
|
|
90371
|
-
for (const headerName of headerNames) {
|
|
90372
|
-
for (const value of rawHeaders[headerName]) {
|
|
90373
|
-
this.append(headerName, value);
|
|
90374
|
-
}
|
|
90375
|
-
}
|
|
90376
|
-
return;
|
|
90377
|
-
}
|
|
90378
|
-
if (init2 == null)
|
|
90379
|
-
;
|
|
90380
|
-
else if (typeof init2 === "object") {
|
|
90381
|
-
const method = init2[Symbol.iterator];
|
|
90382
|
-
if (method != null) {
|
|
90383
|
-
if (typeof method !== "function") {
|
|
90384
|
-
throw new TypeError("Header pairs must be iterable");
|
|
90385
|
-
}
|
|
90386
|
-
const pairs = [];
|
|
90387
|
-
for (const pair of init2) {
|
|
90388
|
-
if (typeof pair !== "object" || typeof pair[Symbol.iterator] !== "function") {
|
|
90389
|
-
throw new TypeError("Each header pair must be iterable");
|
|
90390
|
-
}
|
|
90391
|
-
pairs.push(Array.from(pair));
|
|
90392
|
-
}
|
|
90393
|
-
for (const pair of pairs) {
|
|
90394
|
-
if (pair.length !== 2) {
|
|
90395
|
-
throw new TypeError("Each header pair must be a name/value tuple");
|
|
90396
|
-
}
|
|
90397
|
-
this.append(pair[0], pair[1]);
|
|
90398
|
-
}
|
|
90399
|
-
} else {
|
|
90400
|
-
for (const key of Object.keys(init2)) {
|
|
90401
|
-
const value = init2[key];
|
|
90402
|
-
this.append(key, value);
|
|
90403
|
-
}
|
|
90404
|
-
}
|
|
90405
|
-
} else {
|
|
90406
|
-
throw new TypeError("Provided initializer must be an object");
|
|
90407
|
-
}
|
|
90408
|
-
}
|
|
90409
|
-
get(name) {
|
|
90410
|
-
name = `${name}`;
|
|
90411
|
-
validateName(name);
|
|
90412
|
-
const key = find(this[MAP], name);
|
|
90413
|
-
if (key === undefined) {
|
|
90414
|
-
return null;
|
|
90415
|
-
}
|
|
90416
|
-
return this[MAP][key].join(", ");
|
|
90417
|
-
}
|
|
90418
|
-
forEach(callback) {
|
|
90419
|
-
let thisArg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
|
|
90420
|
-
let pairs = getHeaders(this);
|
|
90421
|
-
let i = 0;
|
|
90422
|
-
while (i < pairs.length) {
|
|
90423
|
-
var _pairs$i = pairs[i];
|
|
90424
|
-
const name = _pairs$i[0], value = _pairs$i[1];
|
|
90425
|
-
callback.call(thisArg, value, name, this);
|
|
90426
|
-
pairs = getHeaders(this);
|
|
90427
|
-
i++;
|
|
90428
|
-
}
|
|
90429
|
-
}
|
|
90430
|
-
set(name, value) {
|
|
90431
|
-
name = `${name}`;
|
|
90432
|
-
value = `${value}`;
|
|
90433
|
-
validateName(name);
|
|
90434
|
-
validateValue(value);
|
|
90435
|
-
const key = find(this[MAP], name);
|
|
90436
|
-
this[MAP][key !== undefined ? key : name] = [value];
|
|
90437
|
-
}
|
|
90438
|
-
append(name, value) {
|
|
90439
|
-
name = `${name}`;
|
|
90440
|
-
value = `${value}`;
|
|
90441
|
-
validateName(name);
|
|
90442
|
-
validateValue(value);
|
|
90443
|
-
const key = find(this[MAP], name);
|
|
90444
|
-
if (key !== undefined) {
|
|
90445
|
-
this[MAP][key].push(value);
|
|
90446
|
-
} else {
|
|
90447
|
-
this[MAP][name] = [value];
|
|
90448
|
-
}
|
|
90449
|
-
}
|
|
90450
|
-
has(name) {
|
|
90451
|
-
name = `${name}`;
|
|
90452
|
-
validateName(name);
|
|
90453
|
-
return find(this[MAP], name) !== undefined;
|
|
90454
|
-
}
|
|
90455
|
-
delete(name) {
|
|
90456
|
-
name = `${name}`;
|
|
90457
|
-
validateName(name);
|
|
90458
|
-
const key = find(this[MAP], name);
|
|
90459
|
-
if (key !== undefined) {
|
|
90460
|
-
delete this[MAP][key];
|
|
90461
|
-
}
|
|
90462
|
-
}
|
|
90463
|
-
raw() {
|
|
90464
|
-
return this[MAP];
|
|
90465
|
-
}
|
|
90466
|
-
keys() {
|
|
90467
|
-
return createHeadersIterator(this, "key");
|
|
90468
|
-
}
|
|
90469
|
-
values() {
|
|
90470
|
-
return createHeadersIterator(this, "value");
|
|
90471
|
-
}
|
|
90472
|
-
[Symbol.iterator]() {
|
|
90473
|
-
return createHeadersIterator(this, "key+value");
|
|
90474
|
-
}
|
|
90475
|
-
}
|
|
90476
|
-
Headers2.prototype.entries = Headers2.prototype[Symbol.iterator];
|
|
90477
|
-
Object.defineProperty(Headers2.prototype, Symbol.toStringTag, {
|
|
90478
|
-
value: "Headers",
|
|
90479
|
-
writable: false,
|
|
90480
|
-
enumerable: false,
|
|
90481
|
-
configurable: true
|
|
90482
|
-
});
|
|
90483
|
-
Object.defineProperties(Headers2.prototype, {
|
|
90484
|
-
get: { enumerable: true },
|
|
90485
|
-
forEach: { enumerable: true },
|
|
90486
|
-
set: { enumerable: true },
|
|
90487
|
-
append: { enumerable: true },
|
|
90488
|
-
has: { enumerable: true },
|
|
90489
|
-
delete: { enumerable: true },
|
|
90490
|
-
keys: { enumerable: true },
|
|
90491
|
-
values: { enumerable: true },
|
|
90492
|
-
entries: { enumerable: true }
|
|
90493
|
-
});
|
|
90494
|
-
function getHeaders(headers) {
|
|
90495
|
-
let kind = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "key+value";
|
|
90496
|
-
const keys = Object.keys(headers[MAP]).sort();
|
|
90497
|
-
return keys.map(kind === "key" ? function(k) {
|
|
90498
|
-
return k.toLowerCase();
|
|
90499
|
-
} : kind === "value" ? function(k) {
|
|
90500
|
-
return headers[MAP][k].join(", ");
|
|
90501
|
-
} : function(k) {
|
|
90502
|
-
return [k.toLowerCase(), headers[MAP][k].join(", ")];
|
|
90503
|
-
});
|
|
90504
|
-
}
|
|
90505
|
-
var INTERNAL = Symbol("internal");
|
|
90506
|
-
function createHeadersIterator(target, kind) {
|
|
90507
|
-
const iterator = Object.create(HeadersIteratorPrototype);
|
|
90508
|
-
iterator[INTERNAL] = {
|
|
90509
|
-
target,
|
|
90510
|
-
kind,
|
|
90511
|
-
index: 0
|
|
90512
|
-
};
|
|
90513
|
-
return iterator;
|
|
90514
|
-
}
|
|
90515
|
-
var HeadersIteratorPrototype = Object.setPrototypeOf({
|
|
90516
|
-
next() {
|
|
90517
|
-
if (!this || Object.getPrototypeOf(this) !== HeadersIteratorPrototype) {
|
|
90518
|
-
throw new TypeError("Value of `this` is not a HeadersIterator");
|
|
90519
|
-
}
|
|
90520
|
-
var _INTERNAL = this[INTERNAL];
|
|
90521
|
-
const { target, kind, index } = _INTERNAL;
|
|
90522
|
-
const values = getHeaders(target, kind);
|
|
90523
|
-
const len = values.length;
|
|
90524
|
-
if (index >= len) {
|
|
90525
|
-
return {
|
|
90526
|
-
value: undefined,
|
|
90527
|
-
done: true
|
|
90528
|
-
};
|
|
90529
|
-
}
|
|
90530
|
-
this[INTERNAL].index = index + 1;
|
|
90531
|
-
return {
|
|
90532
|
-
value: values[index],
|
|
90533
|
-
done: false
|
|
90534
|
-
};
|
|
90535
|
-
}
|
|
90536
|
-
}, Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]())));
|
|
90537
|
-
Object.defineProperty(HeadersIteratorPrototype, Symbol.toStringTag, {
|
|
90538
|
-
value: "HeadersIterator",
|
|
90539
|
-
writable: false,
|
|
90540
|
-
enumerable: false,
|
|
90541
|
-
configurable: true
|
|
90542
|
-
});
|
|
90543
|
-
function exportNodeCompatibleHeaders(headers) {
|
|
90544
|
-
const obj = Object.assign({ __proto__: null }, headers[MAP]);
|
|
90545
|
-
const hostHeaderKey = find(headers[MAP], "Host");
|
|
90546
|
-
if (hostHeaderKey !== undefined) {
|
|
90547
|
-
obj[hostHeaderKey] = obj[hostHeaderKey][0];
|
|
90548
|
-
}
|
|
90549
|
-
return obj;
|
|
90550
|
-
}
|
|
90551
|
-
function createHeadersLenient(obj) {
|
|
90552
|
-
const headers = new Headers2;
|
|
90553
|
-
for (const name of Object.keys(obj)) {
|
|
90554
|
-
if (invalidTokenRegex.test(name)) {
|
|
90555
|
-
continue;
|
|
90556
|
-
}
|
|
90557
|
-
if (Array.isArray(obj[name])) {
|
|
90558
|
-
for (const val of obj[name]) {
|
|
90559
|
-
if (invalidHeaderCharRegex.test(val)) {
|
|
90560
|
-
continue;
|
|
90561
|
-
}
|
|
90562
|
-
if (headers[MAP][name] === undefined) {
|
|
90563
|
-
headers[MAP][name] = [val];
|
|
90564
|
-
} else {
|
|
90565
|
-
headers[MAP][name].push(val);
|
|
90566
|
-
}
|
|
90567
|
-
}
|
|
90568
|
-
} else if (!invalidHeaderCharRegex.test(obj[name])) {
|
|
90569
|
-
headers[MAP][name] = [obj[name]];
|
|
90570
|
-
}
|
|
90571
|
-
}
|
|
90572
|
-
return headers;
|
|
90573
|
-
}
|
|
90574
|
-
var INTERNALS$1 = Symbol("Response internals");
|
|
90575
|
-
var STATUS_CODES = http2.STATUS_CODES;
|
|
90576
|
-
|
|
90577
|
-
class Response2 {
|
|
90578
|
-
constructor() {
|
|
90579
|
-
let body = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
90580
|
-
let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
90581
|
-
Body.call(this, body, opts);
|
|
90582
|
-
const status = opts.status || 200;
|
|
90583
|
-
const headers = new Headers2(opts.headers);
|
|
90584
|
-
if (body != null && !headers.has("Content-Type")) {
|
|
90585
|
-
const contentType = extractContentType(body);
|
|
90586
|
-
if (contentType) {
|
|
90587
|
-
headers.append("Content-Type", contentType);
|
|
90588
|
-
}
|
|
90589
|
-
}
|
|
90590
|
-
this[INTERNALS$1] = {
|
|
90591
|
-
url: opts.url,
|
|
90592
|
-
status,
|
|
90593
|
-
statusText: opts.statusText || STATUS_CODES[status],
|
|
90594
|
-
headers,
|
|
90595
|
-
counter: opts.counter
|
|
90596
|
-
};
|
|
90597
|
-
}
|
|
90598
|
-
get url() {
|
|
90599
|
-
return this[INTERNALS$1].url || "";
|
|
90600
|
-
}
|
|
90601
|
-
get status() {
|
|
90602
|
-
return this[INTERNALS$1].status;
|
|
90603
|
-
}
|
|
90604
|
-
get ok() {
|
|
90605
|
-
return this[INTERNALS$1].status >= 200 && this[INTERNALS$1].status < 300;
|
|
90606
|
-
}
|
|
90607
|
-
get redirected() {
|
|
90608
|
-
return this[INTERNALS$1].counter > 0;
|
|
90609
|
-
}
|
|
90610
|
-
get statusText() {
|
|
90611
|
-
return this[INTERNALS$1].statusText;
|
|
90612
|
-
}
|
|
90613
|
-
get headers() {
|
|
90614
|
-
return this[INTERNALS$1].headers;
|
|
90615
|
-
}
|
|
90616
|
-
clone() {
|
|
90617
|
-
return new Response2(clone3(this), {
|
|
90618
|
-
url: this.url,
|
|
90619
|
-
status: this.status,
|
|
90620
|
-
statusText: this.statusText,
|
|
90621
|
-
headers: this.headers,
|
|
90622
|
-
ok: this.ok,
|
|
90623
|
-
redirected: this.redirected
|
|
90624
|
-
});
|
|
90625
|
-
}
|
|
90626
|
-
}
|
|
90627
|
-
Body.mixIn(Response2.prototype);
|
|
90628
|
-
Object.defineProperties(Response2.prototype, {
|
|
90629
|
-
url: { enumerable: true },
|
|
90630
|
-
status: { enumerable: true },
|
|
90631
|
-
ok: { enumerable: true },
|
|
90632
|
-
redirected: { enumerable: true },
|
|
90633
|
-
statusText: { enumerable: true },
|
|
90634
|
-
headers: { enumerable: true },
|
|
90635
|
-
clone: { enumerable: true }
|
|
90636
|
-
});
|
|
90637
|
-
Object.defineProperty(Response2.prototype, Symbol.toStringTag, {
|
|
90638
|
-
value: "Response",
|
|
90639
|
-
writable: false,
|
|
90640
|
-
enumerable: false,
|
|
90641
|
-
configurable: true
|
|
90642
|
-
});
|
|
90643
|
-
var INTERNALS$2 = Symbol("Request internals");
|
|
90644
|
-
var URL2 = Url.URL || whatwgUrl.URL;
|
|
90645
|
-
var parse_url = Url.parse;
|
|
90646
|
-
var format_url = Url.format;
|
|
90647
|
-
function parseURL(urlStr) {
|
|
90648
|
-
if (/^[a-zA-Z][a-zA-Z\d+\-.]*:/.exec(urlStr)) {
|
|
90649
|
-
urlStr = new URL2(urlStr).toString();
|
|
90650
|
-
}
|
|
90651
|
-
return parse_url(urlStr);
|
|
90652
|
-
}
|
|
90653
|
-
var streamDestructionSupported = "destroy" in Stream.Readable.prototype;
|
|
90654
|
-
function isRequest(input) {
|
|
90655
|
-
return typeof input === "object" && typeof input[INTERNALS$2] === "object";
|
|
90656
|
-
}
|
|
90657
|
-
function isAbortSignal(signal) {
|
|
90658
|
-
const proto = signal && typeof signal === "object" && Object.getPrototypeOf(signal);
|
|
90659
|
-
return !!(proto && proto.constructor.name === "AbortSignal");
|
|
90660
|
-
}
|
|
90661
|
-
|
|
90662
|
-
class Request {
|
|
90663
|
-
constructor(input) {
|
|
90664
|
-
let init2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
90665
|
-
let parsedURL;
|
|
90666
|
-
if (!isRequest(input)) {
|
|
90667
|
-
if (input && input.href) {
|
|
90668
|
-
parsedURL = parseURL(input.href);
|
|
90669
|
-
} else {
|
|
90670
|
-
parsedURL = parseURL(`${input}`);
|
|
90671
|
-
}
|
|
90672
|
-
input = {};
|
|
90673
|
-
} else {
|
|
90674
|
-
parsedURL = parseURL(input.url);
|
|
90675
|
-
}
|
|
90676
|
-
let method = init2.method || input.method || "GET";
|
|
90677
|
-
method = method.toUpperCase();
|
|
90678
|
-
if ((init2.body != null || isRequest(input) && input.body !== null) && (method === "GET" || method === "HEAD")) {
|
|
90679
|
-
throw new TypeError("Request with GET/HEAD method cannot have body");
|
|
90680
|
-
}
|
|
90681
|
-
let inputBody = init2.body != null ? init2.body : isRequest(input) && input.body !== null ? clone3(input) : null;
|
|
90682
|
-
Body.call(this, inputBody, {
|
|
90683
|
-
timeout: init2.timeout || input.timeout || 0,
|
|
90684
|
-
size: init2.size || input.size || 0
|
|
90685
|
-
});
|
|
90686
|
-
const headers = new Headers2(init2.headers || input.headers || {});
|
|
90687
|
-
if (inputBody != null && !headers.has("Content-Type")) {
|
|
90688
|
-
const contentType = extractContentType(inputBody);
|
|
90689
|
-
if (contentType) {
|
|
90690
|
-
headers.append("Content-Type", contentType);
|
|
90691
|
-
}
|
|
90692
|
-
}
|
|
90693
|
-
let signal = isRequest(input) ? input.signal : null;
|
|
90694
|
-
if ("signal" in init2)
|
|
90695
|
-
signal = init2.signal;
|
|
90696
|
-
if (signal != null && !isAbortSignal(signal)) {
|
|
90697
|
-
throw new TypeError("Expected signal to be an instanceof AbortSignal");
|
|
90698
|
-
}
|
|
90699
|
-
this[INTERNALS$2] = {
|
|
90700
|
-
method,
|
|
90701
|
-
redirect: init2.redirect || input.redirect || "follow",
|
|
90702
|
-
headers,
|
|
90703
|
-
parsedURL,
|
|
90704
|
-
signal
|
|
90705
|
-
};
|
|
90706
|
-
this.follow = init2.follow !== undefined ? init2.follow : input.follow !== undefined ? input.follow : 20;
|
|
90707
|
-
this.compress = init2.compress !== undefined ? init2.compress : input.compress !== undefined ? input.compress : true;
|
|
90708
|
-
this.counter = init2.counter || input.counter || 0;
|
|
90709
|
-
this.agent = init2.agent || input.agent;
|
|
90710
|
-
}
|
|
90711
|
-
get method() {
|
|
90712
|
-
return this[INTERNALS$2].method;
|
|
90713
|
-
}
|
|
90714
|
-
get url() {
|
|
90715
|
-
return format_url(this[INTERNALS$2].parsedURL);
|
|
90716
|
-
}
|
|
90717
|
-
get headers() {
|
|
90718
|
-
return this[INTERNALS$2].headers;
|
|
90719
|
-
}
|
|
90720
|
-
get redirect() {
|
|
90721
|
-
return this[INTERNALS$2].redirect;
|
|
90722
|
-
}
|
|
90723
|
-
get signal() {
|
|
90724
|
-
return this[INTERNALS$2].signal;
|
|
90725
|
-
}
|
|
90726
|
-
clone() {
|
|
90727
|
-
return new Request(this);
|
|
90728
|
-
}
|
|
90729
|
-
}
|
|
90730
|
-
Body.mixIn(Request.prototype);
|
|
90731
|
-
Object.defineProperty(Request.prototype, Symbol.toStringTag, {
|
|
90732
|
-
value: "Request",
|
|
90733
|
-
writable: false,
|
|
90734
|
-
enumerable: false,
|
|
90735
|
-
configurable: true
|
|
90736
|
-
});
|
|
90737
|
-
Object.defineProperties(Request.prototype, {
|
|
90738
|
-
method: { enumerable: true },
|
|
90739
|
-
url: { enumerable: true },
|
|
90740
|
-
headers: { enumerable: true },
|
|
90741
|
-
redirect: { enumerable: true },
|
|
90742
|
-
clone: { enumerable: true },
|
|
90743
|
-
signal: { enumerable: true }
|
|
90744
|
-
});
|
|
90745
|
-
function getNodeRequestOptions(request) {
|
|
90746
|
-
const parsedURL = request[INTERNALS$2].parsedURL;
|
|
90747
|
-
const headers = new Headers2(request[INTERNALS$2].headers);
|
|
90748
|
-
if (!headers.has("Accept")) {
|
|
90749
|
-
headers.set("Accept", "*/*");
|
|
90750
|
-
}
|
|
90751
|
-
if (!parsedURL.protocol || !parsedURL.hostname) {
|
|
90752
|
-
throw new TypeError("Only absolute URLs are supported");
|
|
90753
|
-
}
|
|
90754
|
-
if (!/^https?:$/.test(parsedURL.protocol)) {
|
|
90755
|
-
throw new TypeError("Only HTTP(S) protocols are supported");
|
|
90756
|
-
}
|
|
90757
|
-
if (request.signal && request.body instanceof Stream.Readable && !streamDestructionSupported) {
|
|
90758
|
-
throw new Error("Cancellation of streamed requests with AbortSignal is not supported in node < 8");
|
|
90759
|
-
}
|
|
90760
|
-
let contentLengthValue = null;
|
|
90761
|
-
if (request.body == null && /^(POST|PUT)$/i.test(request.method)) {
|
|
90762
|
-
contentLengthValue = "0";
|
|
90763
|
-
}
|
|
90764
|
-
if (request.body != null) {
|
|
90765
|
-
const totalBytes = getTotalBytes(request);
|
|
90766
|
-
if (typeof totalBytes === "number") {
|
|
90767
|
-
contentLengthValue = String(totalBytes);
|
|
90768
|
-
}
|
|
90769
|
-
}
|
|
90770
|
-
if (contentLengthValue) {
|
|
90771
|
-
headers.set("Content-Length", contentLengthValue);
|
|
90772
|
-
}
|
|
90773
|
-
if (!headers.has("User-Agent")) {
|
|
90774
|
-
headers.set("User-Agent", "node-fetch/1.0 (+https://github.com/bitinn/node-fetch)");
|
|
90775
|
-
}
|
|
90776
|
-
if (request.compress && !headers.has("Accept-Encoding")) {
|
|
90777
|
-
headers.set("Accept-Encoding", "gzip,deflate");
|
|
90778
|
-
}
|
|
90779
|
-
let agent = request.agent;
|
|
90780
|
-
if (typeof agent === "function") {
|
|
90781
|
-
agent = agent(parsedURL);
|
|
90782
|
-
}
|
|
90783
|
-
return Object.assign({}, parsedURL, {
|
|
90784
|
-
method: request.method,
|
|
90785
|
-
headers: exportNodeCompatibleHeaders(headers),
|
|
90786
|
-
agent
|
|
90787
|
-
});
|
|
90788
|
-
}
|
|
90789
|
-
function AbortError(message) {
|
|
90790
|
-
Error.call(this, message);
|
|
90791
|
-
this.type = "aborted";
|
|
90792
|
-
this.message = message;
|
|
90793
|
-
Error.captureStackTrace(this, this.constructor);
|
|
90794
|
-
}
|
|
90795
|
-
AbortError.prototype = Object.create(Error.prototype);
|
|
90796
|
-
AbortError.prototype.constructor = AbortError;
|
|
90797
|
-
AbortError.prototype.name = "AbortError";
|
|
90798
|
-
var URL$1 = Url.URL || whatwgUrl.URL;
|
|
90799
|
-
var PassThrough$1 = Stream.PassThrough;
|
|
90800
|
-
var isDomainOrSubdomain = function isDomainOrSubdomain(destination, original) {
|
|
90801
|
-
const orig = new URL$1(original).hostname;
|
|
90802
|
-
const dest = new URL$1(destination).hostname;
|
|
90803
|
-
return orig === dest || orig[orig.length - dest.length - 1] === "." && orig.endsWith(dest);
|
|
90804
|
-
};
|
|
90805
|
-
var isSameProtocol = function isSameProtocol(destination, original) {
|
|
90806
|
-
const orig = new URL$1(original).protocol;
|
|
90807
|
-
const dest = new URL$1(destination).protocol;
|
|
90808
|
-
return orig === dest;
|
|
90809
|
-
};
|
|
90810
|
-
function fetch2(url, opts) {
|
|
90811
|
-
if (!fetch2.Promise) {
|
|
90812
|
-
throw new Error("native promise missing, set fetch.Promise to your favorite alternative");
|
|
90813
|
-
}
|
|
90814
|
-
Body.Promise = fetch2.Promise;
|
|
90815
|
-
return new fetch2.Promise(function(resolve, reject) {
|
|
90816
|
-
const request = new Request(url, opts);
|
|
90817
|
-
const options = getNodeRequestOptions(request);
|
|
90818
|
-
const send = (options.protocol === "https:" ? https2 : http2).request;
|
|
90819
|
-
const signal = request.signal;
|
|
90820
|
-
let response = null;
|
|
90821
|
-
const abort = function abort() {
|
|
90822
|
-
let error = new AbortError("The user aborted a request.");
|
|
90823
|
-
reject(error);
|
|
90824
|
-
if (request.body && request.body instanceof Stream.Readable) {
|
|
90825
|
-
destroyStream(request.body, error);
|
|
90826
|
-
}
|
|
90827
|
-
if (!response || !response.body)
|
|
90828
|
-
return;
|
|
90829
|
-
response.body.emit("error", error);
|
|
90830
|
-
};
|
|
90831
|
-
if (signal && signal.aborted) {
|
|
90832
|
-
abort();
|
|
90833
|
-
return;
|
|
90834
|
-
}
|
|
90835
|
-
const abortAndFinalize = function abortAndFinalize() {
|
|
90836
|
-
abort();
|
|
90837
|
-
finalize();
|
|
90838
|
-
};
|
|
90839
|
-
const req = send(options);
|
|
90840
|
-
let reqTimeout;
|
|
90841
|
-
if (signal) {
|
|
90842
|
-
signal.addEventListener("abort", abortAndFinalize);
|
|
90843
|
-
}
|
|
90844
|
-
function finalize() {
|
|
90845
|
-
req.abort();
|
|
90846
|
-
if (signal)
|
|
90847
|
-
signal.removeEventListener("abort", abortAndFinalize);
|
|
90848
|
-
clearTimeout(reqTimeout);
|
|
90849
|
-
}
|
|
90850
|
-
if (request.timeout) {
|
|
90851
|
-
req.once("socket", function(socket) {
|
|
90852
|
-
reqTimeout = setTimeout(function() {
|
|
90853
|
-
reject(new FetchError(`network timeout at: ${request.url}`, "request-timeout"));
|
|
90854
|
-
finalize();
|
|
90855
|
-
}, request.timeout);
|
|
90856
|
-
});
|
|
90857
|
-
}
|
|
90858
|
-
req.on("error", function(err) {
|
|
90859
|
-
reject(new FetchError(`request to ${request.url} failed, reason: ${err.message}`, "system", err));
|
|
90860
|
-
if (response && response.body) {
|
|
90861
|
-
destroyStream(response.body, err);
|
|
90862
|
-
}
|
|
90863
|
-
finalize();
|
|
90864
|
-
});
|
|
90865
|
-
fixResponseChunkedTransferBadEnding(req, function(err) {
|
|
90866
|
-
if (signal && signal.aborted) {
|
|
90867
|
-
return;
|
|
90868
|
-
}
|
|
90869
|
-
if (response && response.body) {
|
|
90870
|
-
destroyStream(response.body, err);
|
|
90871
|
-
}
|
|
90872
|
-
});
|
|
90873
|
-
if (parseInt(process.version.substring(1)) < 14) {
|
|
90874
|
-
req.on("socket", function(s) {
|
|
90875
|
-
s.addListener("close", function(hadError) {
|
|
90876
|
-
const hasDataListener = s.listenerCount("data") > 0;
|
|
90877
|
-
if (response && hasDataListener && !hadError && !(signal && signal.aborted)) {
|
|
90878
|
-
const err = new Error("Premature close");
|
|
90879
|
-
err.code = "ERR_STREAM_PREMATURE_CLOSE";
|
|
90880
|
-
response.body.emit("error", err);
|
|
90881
|
-
}
|
|
90882
|
-
});
|
|
90883
|
-
});
|
|
90884
|
-
}
|
|
90885
|
-
req.on("response", function(res) {
|
|
90886
|
-
clearTimeout(reqTimeout);
|
|
90887
|
-
const headers = createHeadersLenient(res.headers);
|
|
90888
|
-
if (fetch2.isRedirect(res.statusCode)) {
|
|
90889
|
-
const location = headers.get("Location");
|
|
90890
|
-
let locationURL = null;
|
|
90891
|
-
try {
|
|
90892
|
-
locationURL = location === null ? null : new URL$1(location, request.url).toString();
|
|
90893
|
-
} catch (err) {
|
|
90894
|
-
if (request.redirect !== "manual") {
|
|
90895
|
-
reject(new FetchError(`uri requested responds with an invalid redirect URL: ${location}`, "invalid-redirect"));
|
|
90896
|
-
finalize();
|
|
90897
|
-
return;
|
|
90898
|
-
}
|
|
90899
|
-
}
|
|
90900
|
-
switch (request.redirect) {
|
|
90901
|
-
case "error":
|
|
90902
|
-
reject(new FetchError(`uri requested responds with a redirect, redirect mode is set to error: ${request.url}`, "no-redirect"));
|
|
90903
|
-
finalize();
|
|
90904
|
-
return;
|
|
90905
|
-
case "manual":
|
|
90906
|
-
if (locationURL !== null) {
|
|
90907
|
-
try {
|
|
90908
|
-
headers.set("Location", locationURL);
|
|
90909
|
-
} catch (err) {
|
|
90910
|
-
reject(err);
|
|
90911
|
-
}
|
|
90912
|
-
}
|
|
90913
|
-
break;
|
|
90914
|
-
case "follow":
|
|
90915
|
-
if (locationURL === null) {
|
|
90916
|
-
break;
|
|
90917
|
-
}
|
|
90918
|
-
if (request.counter >= request.follow) {
|
|
90919
|
-
reject(new FetchError(`maximum redirect reached at: ${request.url}`, "max-redirect"));
|
|
90920
|
-
finalize();
|
|
90921
|
-
return;
|
|
90922
|
-
}
|
|
90923
|
-
const requestOpts = {
|
|
90924
|
-
headers: new Headers2(request.headers),
|
|
90925
|
-
follow: request.follow,
|
|
90926
|
-
counter: request.counter + 1,
|
|
90927
|
-
agent: request.agent,
|
|
90928
|
-
compress: request.compress,
|
|
90929
|
-
method: request.method,
|
|
90930
|
-
body: request.body,
|
|
90931
|
-
signal: request.signal,
|
|
90932
|
-
timeout: request.timeout,
|
|
90933
|
-
size: request.size
|
|
90934
|
-
};
|
|
90935
|
-
if (!isDomainOrSubdomain(request.url, locationURL) || !isSameProtocol(request.url, locationURL)) {
|
|
90936
|
-
for (const name of ["authorization", "www-authenticate", "cookie", "cookie2"]) {
|
|
90937
|
-
requestOpts.headers.delete(name);
|
|
90938
|
-
}
|
|
90939
|
-
}
|
|
90940
|
-
if (res.statusCode !== 303 && request.body && getTotalBytes(request) === null) {
|
|
90941
|
-
reject(new FetchError("Cannot follow redirect with body being a readable stream", "unsupported-redirect"));
|
|
90942
|
-
finalize();
|
|
90943
|
-
return;
|
|
90944
|
-
}
|
|
90945
|
-
if (res.statusCode === 303 || (res.statusCode === 301 || res.statusCode === 302) && request.method === "POST") {
|
|
90946
|
-
requestOpts.method = "GET";
|
|
90947
|
-
requestOpts.body = undefined;
|
|
90948
|
-
requestOpts.headers.delete("content-length");
|
|
90949
|
-
}
|
|
90950
|
-
resolve(fetch2(new Request(locationURL, requestOpts)));
|
|
90951
|
-
finalize();
|
|
90952
|
-
return;
|
|
90953
|
-
}
|
|
90954
|
-
}
|
|
90955
|
-
res.once("end", function() {
|
|
90956
|
-
if (signal)
|
|
90957
|
-
signal.removeEventListener("abort", abortAndFinalize);
|
|
90958
|
-
});
|
|
90959
|
-
let body = res.pipe(new PassThrough$1);
|
|
90960
|
-
const response_options = {
|
|
90961
|
-
url: request.url,
|
|
90962
|
-
status: res.statusCode,
|
|
90963
|
-
statusText: res.statusMessage,
|
|
90964
|
-
headers,
|
|
90965
|
-
size: request.size,
|
|
90966
|
-
timeout: request.timeout,
|
|
90967
|
-
counter: request.counter
|
|
90968
|
-
};
|
|
90969
|
-
const codings = headers.get("Content-Encoding");
|
|
90970
|
-
if (!request.compress || request.method === "HEAD" || codings === null || res.statusCode === 204 || res.statusCode === 304) {
|
|
90971
|
-
response = new Response2(body, response_options);
|
|
90972
|
-
resolve(response);
|
|
90973
|
-
return;
|
|
90974
|
-
}
|
|
90975
|
-
const zlibOptions = {
|
|
90976
|
-
flush: zlib.Z_SYNC_FLUSH,
|
|
90977
|
-
finishFlush: zlib.Z_SYNC_FLUSH
|
|
90978
|
-
};
|
|
90979
|
-
if (codings == "gzip" || codings == "x-gzip") {
|
|
90980
|
-
body = body.pipe(zlib.createGunzip(zlibOptions));
|
|
90981
|
-
response = new Response2(body, response_options);
|
|
90982
|
-
resolve(response);
|
|
90983
|
-
return;
|
|
90984
|
-
}
|
|
90985
|
-
if (codings == "deflate" || codings == "x-deflate") {
|
|
90986
|
-
const raw = res.pipe(new PassThrough$1);
|
|
90987
|
-
raw.once("data", function(chunk) {
|
|
90988
|
-
if ((chunk[0] & 15) === 8) {
|
|
90989
|
-
body = body.pipe(zlib.createInflate());
|
|
90990
|
-
} else {
|
|
90991
|
-
body = body.pipe(zlib.createInflateRaw());
|
|
90992
|
-
}
|
|
90993
|
-
response = new Response2(body, response_options);
|
|
90994
|
-
resolve(response);
|
|
90995
|
-
});
|
|
90996
|
-
raw.on("end", function() {
|
|
90997
|
-
if (!response) {
|
|
90998
|
-
response = new Response2(body, response_options);
|
|
90999
|
-
resolve(response);
|
|
91000
|
-
}
|
|
91001
|
-
});
|
|
91002
|
-
return;
|
|
91003
|
-
}
|
|
91004
|
-
if (codings == "br" && typeof zlib.createBrotliDecompress === "function") {
|
|
91005
|
-
body = body.pipe(zlib.createBrotliDecompress());
|
|
91006
|
-
response = new Response2(body, response_options);
|
|
91007
|
-
resolve(response);
|
|
91008
|
-
return;
|
|
91009
|
-
}
|
|
91010
|
-
response = new Response2(body, response_options);
|
|
91011
|
-
resolve(response);
|
|
91012
|
-
});
|
|
91013
|
-
writeToStream(req, request);
|
|
91014
|
-
});
|
|
91015
|
-
}
|
|
91016
|
-
function fixResponseChunkedTransferBadEnding(request, errorCallback) {
|
|
91017
|
-
let socket;
|
|
91018
|
-
request.on("socket", function(s) {
|
|
91019
|
-
socket = s;
|
|
91020
|
-
});
|
|
91021
|
-
request.on("response", function(response) {
|
|
91022
|
-
const headers = response.headers;
|
|
91023
|
-
if (headers["transfer-encoding"] === "chunked" && !headers["content-length"]) {
|
|
91024
|
-
response.once("close", function(hadError) {
|
|
91025
|
-
const hasDataListener = socket && socket.listenerCount("data") > 0;
|
|
91026
|
-
if (hasDataListener && !hadError) {
|
|
91027
|
-
const err = new Error("Premature close");
|
|
91028
|
-
err.code = "ERR_STREAM_PREMATURE_CLOSE";
|
|
91029
|
-
errorCallback(err);
|
|
91030
|
-
}
|
|
91031
|
-
});
|
|
91032
|
-
}
|
|
91033
|
-
});
|
|
91034
|
-
}
|
|
91035
|
-
function destroyStream(stream, err) {
|
|
91036
|
-
if (stream.destroy) {
|
|
91037
|
-
stream.destroy(err);
|
|
91038
|
-
} else {
|
|
91039
|
-
stream.emit("error", err);
|
|
91040
|
-
stream.end();
|
|
91041
|
-
}
|
|
91042
|
-
}
|
|
91043
|
-
fetch2.isRedirect = function(code) {
|
|
91044
|
-
return code === 301 || code === 302 || code === 303 || code === 307 || code === 308;
|
|
91045
|
-
};
|
|
91046
|
-
fetch2.Promise = global.Promise;
|
|
91047
|
-
module.exports = exports = fetch2;
|
|
91048
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
91049
|
-
exports.default = exports;
|
|
91050
|
-
exports.Headers = Headers2;
|
|
91051
|
-
exports.Request = Request;
|
|
91052
|
-
exports.Response = Response2;
|
|
91053
|
-
exports.FetchError = FetchError;
|
|
91054
|
-
exports.AbortError = AbortError;
|
|
91055
|
-
});
|
|
91056
|
-
var require_node_ponyfill = __commonJS2((exports, module) => {
|
|
91057
|
-
var nodeFetch2 = require_lib52();
|
|
91058
|
-
var realFetch = nodeFetch2.default || nodeFetch2;
|
|
91059
|
-
var fetch2 = function(url, options) {
|
|
91060
|
-
if (/^\/\//.test(url)) {
|
|
91061
|
-
url = "https:" + url;
|
|
91062
|
-
}
|
|
91063
|
-
return realFetch.call(this, url, options);
|
|
91064
|
-
};
|
|
91065
|
-
fetch2.ponyfill = true;
|
|
91066
|
-
module.exports = exports = fetch2;
|
|
91067
|
-
exports.fetch = fetch2;
|
|
91068
|
-
exports.Headers = nodeFetch2.Headers;
|
|
91069
|
-
exports.Request = nodeFetch2.Request;
|
|
91070
|
-
exports.Response = nodeFetch2.Response;
|
|
91071
|
-
exports.default = fetch2;
|
|
91072
|
-
});
|
|
91073
|
-
var require_registry = __commonJS2((exports) => {
|
|
91074
|
-
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
91075
|
-
if (k2 === undefined)
|
|
91076
|
-
k2 = k;
|
|
91077
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
91078
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
91079
|
-
desc = { enumerable: true, get: function() {
|
|
91080
|
-
return m[k];
|
|
91081
|
-
} };
|
|
91082
|
-
}
|
|
91083
|
-
Object.defineProperty(o, k2, desc);
|
|
91084
|
-
} : function(o, m, k, k2) {
|
|
91085
|
-
if (k2 === undefined)
|
|
91086
|
-
k2 = k;
|
|
91087
|
-
o[k2] = m[k];
|
|
91088
|
-
});
|
|
91089
|
-
var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
|
|
91090
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
91091
|
-
} : function(o, v) {
|
|
91092
|
-
o["default"] = v;
|
|
91093
|
-
});
|
|
91094
|
-
var __importStar = exports && exports.__importStar || function(mod3) {
|
|
91095
|
-
if (mod3 && mod3.__esModule)
|
|
91096
|
-
return mod3;
|
|
91097
|
-
var result = {};
|
|
91098
|
-
if (mod3 != null) {
|
|
91099
|
-
for (var k in mod3)
|
|
91100
|
-
if (k !== "default" && Object.prototype.hasOwnProperty.call(mod3, k))
|
|
91101
|
-
__createBinding(result, mod3, k);
|
|
91102
|
-
}
|
|
91103
|
-
__setModuleDefault(result, mod3);
|
|
91104
|
-
return result;
|
|
91105
|
-
};
|
|
91106
|
-
var __importDefault = exports && exports.__importDefault || function(mod3) {
|
|
91107
|
-
return mod3 && mod3.__esModule ? mod3 : { default: mod3 };
|
|
91108
|
-
};
|
|
91109
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
91110
|
-
exports.verifiedBuild = verifiedBuild;
|
|
91111
|
-
exports.fetchData = fetchData;
|
|
91112
|
-
exports.decodeUpgradeableLoaderState = decodeUpgradeableLoaderState;
|
|
91113
|
-
var cross_fetch_1 = __importDefault(require_node_ponyfill());
|
|
91114
|
-
var borsh2 = __importStar(require_dist42());
|
|
91115
|
-
async function verifiedBuild(connection, programId, limit = 5) {
|
|
91116
|
-
const url = `https://api.apr.dev/api/v0/program/${programId.toString()}/latest?limit=${limit}`;
|
|
91117
|
-
const [programData, latestBuildsResp] = await Promise.all([
|
|
91118
|
-
fetchData(connection, programId),
|
|
91119
|
-
(0, cross_fetch_1.default)(url)
|
|
91120
|
-
]);
|
|
91121
|
-
const latestBuilds = (await latestBuildsResp.json()).filter((b2) => !b2.aborted && b2.state === "Built" && b2.verified === "Verified");
|
|
91122
|
-
if (latestBuilds.length === 0) {
|
|
91123
|
-
return null;
|
|
91124
|
-
}
|
|
91125
|
-
const build = latestBuilds[0];
|
|
91126
|
-
if (programData.slot.toNumber() !== build.verified_slot) {
|
|
91127
|
-
return null;
|
|
91128
|
-
}
|
|
91129
|
-
return build;
|
|
91130
|
-
}
|
|
91131
|
-
async function fetchData(connection, programId) {
|
|
91132
|
-
const accountInfo = await connection.getAccountInfo(programId);
|
|
91133
|
-
if (accountInfo === null) {
|
|
91134
|
-
throw new Error("program account not found");
|
|
91135
|
-
}
|
|
91136
|
-
const { program } = decodeUpgradeableLoaderState(accountInfo.data);
|
|
91137
|
-
const programdataAccountInfo = await connection.getAccountInfo(program.programdataAddress);
|
|
91138
|
-
if (programdataAccountInfo === null) {
|
|
91139
|
-
throw new Error("program data account not found");
|
|
91140
|
-
}
|
|
91141
|
-
const { programData } = decodeUpgradeableLoaderState(programdataAccountInfo.data);
|
|
91142
|
-
return programData;
|
|
91143
|
-
}
|
|
91144
|
-
var UPGRADEABLE_LOADER_STATE_LAYOUT = borsh2.rustEnum([
|
|
91145
|
-
borsh2.struct([], "uninitialized"),
|
|
91146
|
-
borsh2.struct([borsh2.option(borsh2.publicKey(), "authorityAddress")], "buffer"),
|
|
91147
|
-
borsh2.struct([borsh2.publicKey("programdataAddress")], "program"),
|
|
91148
|
-
borsh2.struct([
|
|
91149
|
-
borsh2.u64("slot"),
|
|
91150
|
-
borsh2.option(borsh2.publicKey(), "upgradeAuthorityAddress")
|
|
91151
|
-
], "programData")
|
|
91152
|
-
], undefined, borsh2.u32());
|
|
91153
|
-
function decodeUpgradeableLoaderState(data4) {
|
|
91154
|
-
return UPGRADEABLE_LOADER_STATE_LAYOUT.decode(data4);
|
|
91155
|
-
}
|
|
91156
|
-
});
|
|
91157
|
-
var require_utils42 = __commonJS2((exports) => {
|
|
91158
|
-
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
91159
|
-
if (k2 === undefined)
|
|
91160
|
-
k2 = k;
|
|
91161
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
91162
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
91163
|
-
desc = { enumerable: true, get: function() {
|
|
91164
|
-
return m[k];
|
|
91165
|
-
} };
|
|
91166
|
-
}
|
|
91167
|
-
Object.defineProperty(o, k2, desc);
|
|
91168
|
-
} : function(o, m, k, k2) {
|
|
91169
|
-
if (k2 === undefined)
|
|
91170
|
-
k2 = k;
|
|
91171
|
-
o[k2] = m[k];
|
|
91172
|
-
});
|
|
91173
|
-
var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
|
|
91174
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
91175
|
-
} : function(o, v) {
|
|
91176
|
-
o["default"] = v;
|
|
91177
|
-
});
|
|
91178
|
-
var __importStar = exports && exports.__importStar || function(mod3) {
|
|
91179
|
-
if (mod3 && mod3.__esModule)
|
|
91180
|
-
return mod3;
|
|
91181
|
-
var result = {};
|
|
91182
|
-
if (mod3 != null) {
|
|
91183
|
-
for (var k in mod3)
|
|
91184
|
-
if (k !== "default" && Object.prototype.hasOwnProperty.call(mod3, k))
|
|
91185
|
-
__createBinding(result, mod3, k);
|
|
91186
|
-
}
|
|
91187
|
-
__setModuleDefault(result, mod3);
|
|
91188
|
-
return result;
|
|
91189
|
-
};
|
|
91190
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
91191
|
-
exports.registry = exports.features = exports.token = exports.bytes = exports.publicKey = exports.rpc = exports.sha256 = undefined;
|
|
91192
|
-
exports.sha256 = __importStar(require_sha25622());
|
|
91193
|
-
exports.rpc = __importStar(require_rpc());
|
|
91194
|
-
exports.publicKey = __importStar(require_pubkey());
|
|
91195
|
-
exports.bytes = __importStar(require_bytes());
|
|
91196
|
-
exports.token = __importStar(require_token());
|
|
91197
|
-
exports.features = __importStar(require_features());
|
|
91198
|
-
exports.registry = __importStar(require_registry());
|
|
91199
|
-
});
|
|
91200
|
-
var require_trees = __commonJS2((exports, module) => {
|
|
91201
|
-
var Z_FIXED = 4;
|
|
91202
|
-
var Z_BINARY = 0;
|
|
91203
|
-
var Z_TEXT = 1;
|
|
91204
|
-
var Z_UNKNOWN = 2;
|
|
91205
|
-
function zero(buf) {
|
|
91206
|
-
let len = buf.length;
|
|
91207
|
-
while (--len >= 0) {
|
|
91208
|
-
buf[len] = 0;
|
|
89942
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
89943
|
+
exports.registry = exports.features = exports.token = exports.bytes = exports.publicKey = exports.rpc = exports.sha256 = undefined;
|
|
89944
|
+
exports.sha256 = __importStar(require_sha25622());
|
|
89945
|
+
exports.rpc = __importStar(require_rpc());
|
|
89946
|
+
exports.publicKey = __importStar(require_pubkey());
|
|
89947
|
+
exports.bytes = __importStar(require_bytes());
|
|
89948
|
+
exports.token = __importStar(require_token());
|
|
89949
|
+
exports.features = __importStar(require_features());
|
|
89950
|
+
exports.registry = __importStar(require_registry());
|
|
89951
|
+
});
|
|
89952
|
+
var require_trees = __commonJS2((exports, module) => {
|
|
89953
|
+
var Z_FIXED = 4;
|
|
89954
|
+
var Z_BINARY = 0;
|
|
89955
|
+
var Z_TEXT = 1;
|
|
89956
|
+
var Z_UNKNOWN = 2;
|
|
89957
|
+
function zero(buf) {
|
|
89958
|
+
let len = buf.length;
|
|
89959
|
+
while (--len >= 0) {
|
|
89960
|
+
buf[len] = 0;
|
|
91209
89961
|
}
|
|
91210
89962
|
}
|
|
91211
89963
|
var STORED_BLOCK = 0;
|
|
@@ -101198,7 +99950,7 @@ var require_file_uri_to_path = __commonJS2((exports, module) => {
|
|
|
101198
99950
|
}
|
|
101199
99951
|
});
|
|
101200
99952
|
var require_bindings = __commonJS2((exports, module) => {
|
|
101201
|
-
var __filename2 = "/Users/
|
|
99953
|
+
var __filename2 = "/Users/dc/Dev/null-studios/proton/proton-ts/node_modules/bindings/bindings.js";
|
|
101202
99954
|
var fs = __require2("fs");
|
|
101203
99955
|
var path = __require2("path");
|
|
101204
99956
|
var fileURLToPath = require_file_uri_to_path();
|
|
@@ -106120,7 +104872,7 @@ var import_buffer_layout3 = __toESM2(require_Layout2(), 1);
|
|
|
106120
104872
|
var buffer2 = __require2("buffer");
|
|
106121
104873
|
var ed255192 = require_ed255192();
|
|
106122
104874
|
var BN2 = require_bn2();
|
|
106123
|
-
var bs582 =
|
|
104875
|
+
var bs582 = require_bs583();
|
|
106124
104876
|
var sha2564 = require_sha2562();
|
|
106125
104877
|
var borsh2 = require_lib5();
|
|
106126
104878
|
var BufferLayout2 = require_Layout2();
|
|
@@ -106130,7 +104882,7 @@ var require$$0$12 = __require2("http");
|
|
|
106130
104882
|
var require$$0$22 = __require2("https");
|
|
106131
104883
|
var superstruct2 = require_dist6();
|
|
106132
104884
|
var RpcClient2 = require_browser2();
|
|
106133
|
-
var nodeFetch2 =
|
|
104885
|
+
var nodeFetch2 = require_lib32();
|
|
106134
104886
|
var rpcWebsockets2 = require_dist32();
|
|
106135
104887
|
var sha32 = require_sha32();
|
|
106136
104888
|
var secp256k13 = require_secp256k12();
|
|
@@ -110618,7 +109370,8 @@ class Nord {
|
|
|
110618
109370
|
createWebSocketClient({
|
|
110619
109371
|
trades,
|
|
110620
109372
|
deltas,
|
|
110621
|
-
accounts
|
|
109373
|
+
accounts,
|
|
109374
|
+
candles
|
|
110622
109375
|
}) {
|
|
110623
109376
|
const subscriptions = [];
|
|
110624
109377
|
if (trades && trades.length > 0) {
|
|
@@ -110639,6 +109392,27 @@ class Nord {
|
|
|
110639
109392
|
subscriptions.push(`account@${accountId}`);
|
|
110640
109393
|
});
|
|
110641
109394
|
}
|
|
109395
|
+
if (candles && candles.length > 0) {
|
|
109396
|
+
candles.forEach(({ symbol: symbol2, resolution }) => {
|
|
109397
|
+
if (!symbol2 || typeof symbol2 !== "string") {
|
|
109398
|
+
throw new NordError("Invalid market symbol");
|
|
109399
|
+
}
|
|
109400
|
+
const allowedResolutions = [
|
|
109401
|
+
"1",
|
|
109402
|
+
"5",
|
|
109403
|
+
"15",
|
|
109404
|
+
"30",
|
|
109405
|
+
"60",
|
|
109406
|
+
"1D",
|
|
109407
|
+
"1W",
|
|
109408
|
+
"1M"
|
|
109409
|
+
];
|
|
109410
|
+
if (!allowedResolutions.includes(resolution)) {
|
|
109411
|
+
throw new NordError("Invalid candle resolution");
|
|
109412
|
+
}
|
|
109413
|
+
subscriptions.push(`candle@${symbol2}:${resolution}`);
|
|
109414
|
+
});
|
|
109415
|
+
}
|
|
110642
109416
|
if (subscriptions.length === 0) {
|
|
110643
109417
|
throw new NordError("At least one subscription must be provided");
|
|
110644
109418
|
}
|
|
@@ -110765,6 +109539,24 @@ class Nord {
|
|
|
110765
109539
|
};
|
|
110766
109540
|
return subscription;
|
|
110767
109541
|
}
|
|
109542
|
+
subscribeBars(symbol2, resolution) {
|
|
109543
|
+
if (!symbol2 || typeof symbol2 !== "string") {
|
|
109544
|
+
throw new NordError("Invalid market symbol");
|
|
109545
|
+
}
|
|
109546
|
+
const subscription = new EventEmitter2;
|
|
109547
|
+
const wsClient = this.createWebSocketClient({
|
|
109548
|
+
candles: [{ symbol: symbol2, resolution }]
|
|
109549
|
+
});
|
|
109550
|
+
const handleCandle = (update) => {
|
|
109551
|
+
subscription.emit("message", update);
|
|
109552
|
+
};
|
|
109553
|
+
wsClient.on("candle", handleCandle);
|
|
109554
|
+
subscription.close = () => {
|
|
109555
|
+
wsClient.removeListener("candle", handleCandle);
|
|
109556
|
+
subscription.removeAllListeners();
|
|
109557
|
+
};
|
|
109558
|
+
return subscription;
|
|
109559
|
+
}
|
|
110768
109560
|
subscribeTrades(symbol2) {
|
|
110769
109561
|
if (!symbol2 || typeof symbol2 !== "string") {
|
|
110770
109562
|
throw new NordError("Invalid market symbol");
|