hanoman 0.9.3 → 0.9.4
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/build-info.json +3 -3
- package/dist/server.js +28 -3
- package/package.json +1 -1
package/dist/build-info.json
CHANGED
package/dist/server.js
CHANGED
|
@@ -16544,9 +16544,10 @@ var init_ssrf = __esm({
|
|
|
16544
16544
|
});
|
|
16545
16545
|
|
|
16546
16546
|
// src/services/safe-outbound-request.ts
|
|
16547
|
-
import {
|
|
16547
|
+
import { resolve4 as resolve42, resolve6 as resolve62 } from "node:dns/promises";
|
|
16548
16548
|
import { request as httpRequest } from "node:http";
|
|
16549
16549
|
import { request as httpsRequest } from "node:https";
|
|
16550
|
+
import { isIP } from "node:net";
|
|
16550
16551
|
import { createGunzip } from "node:zlib";
|
|
16551
16552
|
async function pinnedRequest(input) {
|
|
16552
16553
|
return new Promise((resolve24, reject2) => {
|
|
@@ -16613,10 +16614,26 @@ async function pinnedRequest(input) {
|
|
|
16613
16614
|
req.end();
|
|
16614
16615
|
});
|
|
16615
16616
|
}
|
|
16617
|
+
function withLookupTimeout(p3, ms) {
|
|
16618
|
+
return new Promise((resolve24, reject2) => {
|
|
16619
|
+
const timer10 = setTimeout(() => reject2(Object.assign(new Error("outbound timeout"), { name: "AbortError" })), ms);
|
|
16620
|
+
timer10.unref?.();
|
|
16621
|
+
p3.then((v) => {
|
|
16622
|
+
clearTimeout(timer10);
|
|
16623
|
+
resolve24(v);
|
|
16624
|
+
}, (e) => {
|
|
16625
|
+
clearTimeout(timer10);
|
|
16626
|
+
reject2(e);
|
|
16627
|
+
});
|
|
16628
|
+
});
|
|
16629
|
+
}
|
|
16616
16630
|
async function safeRequest(options2, deps = {}) {
|
|
16617
16631
|
if (options2.url.protocol !== "http:" && options2.url.protocol !== "https:") throw new Error("outbound scheme ditolak");
|
|
16618
16632
|
if (options2.url.username || options2.url.password) throw new Error("outbound credential URL ditolak");
|
|
16619
|
-
const addresses = await (
|
|
16633
|
+
const addresses = await withLookupTimeout(
|
|
16634
|
+
(deps.lookupAll ?? defaultLookup2)(options2.url.hostname),
|
|
16635
|
+
options2.connectMs
|
|
16636
|
+
);
|
|
16620
16637
|
if (!addresses.length) throw new Error("DNS tak mengembalikan alamat");
|
|
16621
16638
|
if (!options2.allowPrivate) {
|
|
16622
16639
|
const blocked = addresses.find((row) => isBlockedAddress(row.address));
|
|
@@ -16630,7 +16647,15 @@ var init_safe_outbound_request = __esm({
|
|
|
16630
16647
|
"src/services/safe-outbound-request.ts"() {
|
|
16631
16648
|
"use strict";
|
|
16632
16649
|
init_ssrf();
|
|
16633
|
-
defaultLookup2 = async (host2) =>
|
|
16650
|
+
defaultLookup2 = async (host2) => {
|
|
16651
|
+
const literal = isIP(host2);
|
|
16652
|
+
if (literal) return [{ address: host2, family: literal }];
|
|
16653
|
+
const [v4, v6] = await Promise.allSettled([resolve42(host2), resolve62(host2)]);
|
|
16654
|
+
const out4 = [];
|
|
16655
|
+
if (v4.status === "fulfilled") out4.push(...v4.value.map((address) => ({ address, family: 4 })));
|
|
16656
|
+
if (v6.status === "fulfilled") out4.push(...v6.value.map((address) => ({ address, family: 6 })));
|
|
16657
|
+
return out4;
|
|
16658
|
+
};
|
|
16634
16659
|
}
|
|
16635
16660
|
});
|
|
16636
16661
|
|