@dexto/core 1.16.6 → 1.17.0
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/agent/schemas.d.ts +2 -2
- package/dist/llm/executor/turn-executor.cjs +3 -0
- package/dist/llm/executor/turn-executor.d.ts +5 -5
- package/dist/llm/executor/turn-executor.d.ts.map +1 -1
- package/dist/llm/executor/turn-executor.js +3 -0
- package/dist/llm/index.cjs +6 -0
- package/dist/llm/index.d.ts +2 -0
- package/dist/llm/index.d.ts.map +1 -1
- package/dist/llm/index.js +4 -0
- package/dist/llm/private-address.cjs +88 -0
- package/dist/llm/private-address.d.ts +3 -0
- package/dist/llm/private-address.d.ts.map +1 -0
- package/dist/llm/private-address.js +65 -0
- package/dist/llm/safe-download.cjs +159 -0
- package/dist/llm/safe-download.d.ts +21 -0
- package/dist/llm/safe-download.d.ts.map +1 -0
- package/dist/llm/safe-download.js +126 -0
- package/dist/logger/logger.cjs +8 -9
- package/dist/logger/logger.d.ts.map +1 -1
- package/dist/logger/logger.js +8 -9
- package/dist/logger/v2/dexto-logger.cjs +3 -2
- package/dist/logger/v2/dexto-logger.d.ts.map +1 -1
- package/dist/logger/v2/dexto-logger.js +3 -2
- package/dist/mcp/mcp-client.cjs +17 -8
- package/dist/mcp/mcp-client.d.ts +4 -2
- package/dist/mcp/mcp-client.d.ts.map +1 -1
- package/dist/mcp/mcp-client.js +17 -8
- package/dist/mcp/schemas.cjs +3 -0
- package/dist/mcp/schemas.d.ts +3 -0
- package/dist/mcp/schemas.d.ts.map +1 -1
- package/dist/mcp/schemas.js +3 -0
- package/dist/resources/handlers/filesystem-handler.cjs +7 -6
- package/dist/resources/handlers/filesystem-handler.d.ts.map +1 -1
- package/dist/resources/handlers/filesystem-handler.js +7 -6
- package/dist/systemPrompt/schemas.d.ts +3 -3
- package/dist/telemetry/decorators.cjs +2 -2
- package/dist/telemetry/decorators.js +2 -2
- package/dist/utils/index.cjs +3 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -0
- package/dist/utils/metadata-address.cjs +138 -0
- package/dist/utils/metadata-address.d.ts +24 -0
- package/dist/utils/metadata-address.d.ts.map +1 -0
- package/dist/utils/metadata-address.js +113 -0
- package/dist/utils/path.cjs +0 -15
- package/dist/utils/path.d.ts +0 -6
- package/dist/utils/path.d.ts.map +1 -1
- package/dist/utils/path.js +0 -14
- package/dist/utils/redactor.cjs +242 -34
- package/dist/utils/redactor.d.ts +15 -0
- package/dist/utils/redactor.d.ts.map +1 -1
- package/dist/utils/redactor.js +238 -34
- package/dist/workspace/index.cjs +7 -2
- package/dist/workspace/index.d.ts +1 -0
- package/dist/workspace/index.d.ts.map +1 -1
- package/dist/workspace/index.js +4 -1
- package/dist/workspace/shell-environment.cjs +96 -0
- package/dist/workspace/shell-environment.d.ts +18 -0
- package/dist/workspace/shell-environment.d.ts.map +1 -0
- package/dist/workspace/shell-environment.js +72 -0
- package/dist/workspace/types.d.ts +9 -0
- package/dist/workspace/types.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/utils/index.cjs
CHANGED
|
@@ -29,6 +29,7 @@ __reExport(utils_exports, require("./api-key-resolver.js"), module.exports);
|
|
|
29
29
|
__reExport(utils_exports, require("./defer.js"), module.exports);
|
|
30
30
|
__reExport(utils_exports, require("./async-context.js"), module.exports);
|
|
31
31
|
__reExport(utils_exports, require("./env.js"), module.exports);
|
|
32
|
+
__reExport(utils_exports, require("./metadata-address.js"), module.exports);
|
|
32
33
|
// Annotate the CommonJS export names for ESM import in node:
|
|
33
34
|
0 && (module.exports = {
|
|
34
35
|
...require("./path.js"),
|
|
@@ -44,5 +45,6 @@ __reExport(utils_exports, require("./env.js"), module.exports);
|
|
|
44
45
|
...require("./api-key-resolver.js"),
|
|
45
46
|
...require("./defer.js"),
|
|
46
47
|
...require("./async-context.js"),
|
|
47
|
-
...require("./env.js")
|
|
48
|
+
...require("./env.js"),
|
|
49
|
+
...require("./metadata-address.js")
|
|
48
50
|
});
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAKA,cAAc,WAAW,CAAC;AAC1B,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,UAAU,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAKA,cAAc,WAAW,CAAC;AAC1B,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,UAAU,CAAC;AASzB,cAAc,uBAAuB,CAAC"}
|
package/dist/utils/index.js
CHANGED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var metadata_address_exports = {};
|
|
20
|
+
__export(metadata_address_exports, {
|
|
21
|
+
createMetadataCheckedLookup: () => createMetadataCheckedLookup,
|
|
22
|
+
isMetadataHost: () => isMetadataHost,
|
|
23
|
+
isMetadataTarget: () => isMetadataTarget
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(metadata_address_exports);
|
|
26
|
+
var import_node_dns = require("node:dns");
|
|
27
|
+
var import_node_net = require("node:net");
|
|
28
|
+
const METADATA_HOSTNAMES = /* @__PURE__ */ new Set([
|
|
29
|
+
"metadata.google.internal",
|
|
30
|
+
"metadata.goog",
|
|
31
|
+
"instance-data",
|
|
32
|
+
"instance-data.ec2.internal"
|
|
33
|
+
]);
|
|
34
|
+
async function resolveAllAddresses(hostname) {
|
|
35
|
+
const records = await import_node_dns.promises.lookup(hostname, { all: true, verbatim: true });
|
|
36
|
+
return records.map((record) => record.address);
|
|
37
|
+
}
|
|
38
|
+
const METADATA_IPV4 = ["100.100.100.200", "192.0.0.192", "168.63.129.16"];
|
|
39
|
+
function isMetadataIpv4(a, b, c, d) {
|
|
40
|
+
return a === 169 && b === 254 || METADATA_IPV4.includes(`${a}.${b}.${c}.${d}`);
|
|
41
|
+
}
|
|
42
|
+
function ipv6Groups(address) {
|
|
43
|
+
const [head = "", tail] = address.split("::");
|
|
44
|
+
const headGroups = head === "" ? [] : head.split(":");
|
|
45
|
+
const tailGroups = tail === void 0 || tail === "" ? [] : tail.split(":");
|
|
46
|
+
const missing = tail === void 0 ? 0 : 8 - headGroups.length - tailGroups.length;
|
|
47
|
+
const groups = [...headGroups, ...Array(missing).fill("0"), ...tailGroups];
|
|
48
|
+
return groups.map((group) => Number.parseInt(group, 16));
|
|
49
|
+
}
|
|
50
|
+
function isMetadataIpv6(address) {
|
|
51
|
+
const normalized = new URL(`http://[${address.split("%")[0]}]/`).hostname.slice(1, -1);
|
|
52
|
+
const g = ipv6Groups(normalized);
|
|
53
|
+
const [g0 = 0, g1 = 0, g2 = 0, g3 = 0, g4 = 0, g5 = 0, g6 = 0, g7 = 0] = g;
|
|
54
|
+
if ((g0 & 65472) === 65152) return true;
|
|
55
|
+
const isMetadataUniqueLocal = g0 === 64768 && g1 === 3778 || g0 === 64800 && g1 === 206;
|
|
56
|
+
if (isMetadataUniqueLocal && g2 + g3 + g4 + g5 + g6 === 0 && g7 === 596) {
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
const v4 = (high, low) => isMetadataIpv4(high >> 8, high & 255, low >> 8, low & 255);
|
|
60
|
+
const upperZero = g0 + g1 + g2 + g3 === 0;
|
|
61
|
+
if (upperZero && g4 === 0 && g5 === 65535) return v4(g6, g7);
|
|
62
|
+
if (upperZero && g4 === 65535 && g5 === 0) return v4(g6, g7);
|
|
63
|
+
if (upperZero && g4 === 0 && g5 === 0) return v4(g6, g7);
|
|
64
|
+
if (g0 === 100 && g1 === 65435 && g2 + g3 + g4 + g5 === 0) return v4(g6, g7);
|
|
65
|
+
if (g0 === 8194) return v4(g1, g2);
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
function isMetadataAddress(address) {
|
|
69
|
+
const version = (0, import_node_net.isIP)(address.split("%")[0] ?? address);
|
|
70
|
+
if (version === 4) {
|
|
71
|
+
const [a = 0, b = 0, c = 0, d = 0] = address.split(".").map(Number);
|
|
72
|
+
return isMetadataIpv4(a, b, c, d);
|
|
73
|
+
}
|
|
74
|
+
if (version === 6) return isMetadataIpv6(address);
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
function normalizeHostname(hostname) {
|
|
78
|
+
const bare = hostname.startsWith("[") && hostname.endsWith("]") ? hostname.slice(1, -1) : hostname;
|
|
79
|
+
let host = bare.toLowerCase();
|
|
80
|
+
while (host.endsWith(".")) host = host.slice(0, -1);
|
|
81
|
+
return host;
|
|
82
|
+
}
|
|
83
|
+
function isMetadataHost(hostname) {
|
|
84
|
+
const host = normalizeHostname(hostname);
|
|
85
|
+
return METADATA_HOSTNAMES.has(host) || isMetadataAddress(host);
|
|
86
|
+
}
|
|
87
|
+
async function isMetadataTarget(hostname, resolve = resolveAllAddresses) {
|
|
88
|
+
if (isMetadataHost(hostname)) return true;
|
|
89
|
+
const host = normalizeHostname(hostname);
|
|
90
|
+
if ((0, import_node_net.isIP)(host) !== 0) return false;
|
|
91
|
+
let addresses;
|
|
92
|
+
try {
|
|
93
|
+
addresses = await resolve(host);
|
|
94
|
+
} catch {
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
return addresses.some(isMetadataAddress);
|
|
98
|
+
}
|
|
99
|
+
function createMetadataCheckedLookup(resolve = resolveAllAddresses) {
|
|
100
|
+
return (hostname, options, callback) => {
|
|
101
|
+
const fail = (error) => {
|
|
102
|
+
const errno = Object.assign(error, { code: "EMETADATA" });
|
|
103
|
+
if (options.all) callback(errno, []);
|
|
104
|
+
else callback(errno, "", 0);
|
|
105
|
+
};
|
|
106
|
+
if (isMetadataHost(hostname)) {
|
|
107
|
+
fail(new Error(`Blocked request to metadata host: ${hostname}`));
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
resolve(hostname).then(
|
|
111
|
+
(addresses) => {
|
|
112
|
+
const blocked = addresses.find(isMetadataAddress);
|
|
113
|
+
if (blocked !== void 0) {
|
|
114
|
+
fail(new Error(`${hostname} resolves to metadata address ${blocked}`));
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
const records = addresses.map((address) => ({
|
|
118
|
+
address,
|
|
119
|
+
family: (0, import_node_net.isIP)(address) === 6 ? 6 : 4
|
|
120
|
+
}));
|
|
121
|
+
const [first] = records;
|
|
122
|
+
if (first === void 0) {
|
|
123
|
+
fail(new Error(`Failed to resolve ${hostname}`));
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
if (options.all) callback(null, records);
|
|
127
|
+
else callback(null, first.address, first.family);
|
|
128
|
+
},
|
|
129
|
+
(error) => fail(error instanceof Error ? error : new Error(String(error)))
|
|
130
|
+
);
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
134
|
+
0 && (module.exports = {
|
|
135
|
+
createMetadataCheckedLookup,
|
|
136
|
+
isMetadataHost,
|
|
137
|
+
isMetadataTarget
|
|
138
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type LookupAddress, type LookupOptions } from 'node:dns';
|
|
2
|
+
type Resolve = (hostname: string) => Promise<string[]>;
|
|
3
|
+
/**
|
|
4
|
+
* True when a hostname names a metadata target without any DNS lookup: a metadata host name or
|
|
5
|
+
* an IP literal. Pass `URL.hostname`, which already normalises decimal, octal and hex IPv4.
|
|
6
|
+
*/
|
|
7
|
+
export declare function isMetadataHost(hostname: string): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* True when a hostname is a metadata target, or is a name that resolves to one. Resolves at call
|
|
10
|
+
* time and checks every answer. A name that does not resolve is not a metadata target; the
|
|
11
|
+
* request itself will fail.
|
|
12
|
+
*/
|
|
13
|
+
export declare function isMetadataTarget(hostname: string, resolve?: Resolve): Promise<boolean>;
|
|
14
|
+
type LookupCallback = (error: NodeJS.ErrnoException | null, address: string | LookupAddress[], family?: number) => void;
|
|
15
|
+
/**
|
|
16
|
+
* A `lookup` for a connection (for example an undici `connect.lookup`) that resolves the host
|
|
17
|
+
* itself, refuses metadata answers and hands the connection the addresses it checked. A name
|
|
18
|
+
* that answers differently to a later lookup (DNS rebinding) therefore cannot redirect the
|
|
19
|
+
* connection, because there is no later lookup. IP literals never reach a lookup, so check those
|
|
20
|
+
* with {@link isMetadataHost} first.
|
|
21
|
+
*/
|
|
22
|
+
export declare function createMetadataCheckedLookup(resolve?: Resolve): (hostname: string, options: LookupOptions, callback: LookupCallback) => void;
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=metadata-address.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metadata-address.d.ts","sourceRoot":"","sources":["../../src/utils/metadata-address.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,aAAa,EAAE,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AAmBnF,KAAK,OAAO,GAAG,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;AAkEvD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAGxD;AAED;;;;GAIG;AACH,wBAAsB,gBAAgB,CAClC,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,OAA6B,GACvC,OAAO,CAAC,OAAO,CAAC,CAWlB;AAED,KAAK,cAAc,GAAG,CAClB,KAAK,EAAE,MAAM,CAAC,cAAc,GAAG,IAAI,EACnC,OAAO,EAAE,MAAM,GAAG,aAAa,EAAE,EACjC,MAAM,CAAC,EAAE,MAAM,KACd,IAAI,CAAC;AAEV;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CACvC,OAAO,GAAE,OAA6B,GACvC,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,cAAc,KAAK,IAAI,CAiC9E"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import "../chunk-C6A6W6XS.js";
|
|
2
|
+
import { promises as dns } from "node:dns";
|
|
3
|
+
import { isIP } from "node:net";
|
|
4
|
+
const METADATA_HOSTNAMES = /* @__PURE__ */ new Set([
|
|
5
|
+
"metadata.google.internal",
|
|
6
|
+
"metadata.goog",
|
|
7
|
+
"instance-data",
|
|
8
|
+
"instance-data.ec2.internal"
|
|
9
|
+
]);
|
|
10
|
+
async function resolveAllAddresses(hostname) {
|
|
11
|
+
const records = await dns.lookup(hostname, { all: true, verbatim: true });
|
|
12
|
+
return records.map((record) => record.address);
|
|
13
|
+
}
|
|
14
|
+
const METADATA_IPV4 = ["100.100.100.200", "192.0.0.192", "168.63.129.16"];
|
|
15
|
+
function isMetadataIpv4(a, b, c, d) {
|
|
16
|
+
return a === 169 && b === 254 || METADATA_IPV4.includes(`${a}.${b}.${c}.${d}`);
|
|
17
|
+
}
|
|
18
|
+
function ipv6Groups(address) {
|
|
19
|
+
const [head = "", tail] = address.split("::");
|
|
20
|
+
const headGroups = head === "" ? [] : head.split(":");
|
|
21
|
+
const tailGroups = tail === void 0 || tail === "" ? [] : tail.split(":");
|
|
22
|
+
const missing = tail === void 0 ? 0 : 8 - headGroups.length - tailGroups.length;
|
|
23
|
+
const groups = [...headGroups, ...Array(missing).fill("0"), ...tailGroups];
|
|
24
|
+
return groups.map((group) => Number.parseInt(group, 16));
|
|
25
|
+
}
|
|
26
|
+
function isMetadataIpv6(address) {
|
|
27
|
+
const normalized = new URL(`http://[${address.split("%")[0]}]/`).hostname.slice(1, -1);
|
|
28
|
+
const g = ipv6Groups(normalized);
|
|
29
|
+
const [g0 = 0, g1 = 0, g2 = 0, g3 = 0, g4 = 0, g5 = 0, g6 = 0, g7 = 0] = g;
|
|
30
|
+
if ((g0 & 65472) === 65152) return true;
|
|
31
|
+
const isMetadataUniqueLocal = g0 === 64768 && g1 === 3778 || g0 === 64800 && g1 === 206;
|
|
32
|
+
if (isMetadataUniqueLocal && g2 + g3 + g4 + g5 + g6 === 0 && g7 === 596) {
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
const v4 = (high, low) => isMetadataIpv4(high >> 8, high & 255, low >> 8, low & 255);
|
|
36
|
+
const upperZero = g0 + g1 + g2 + g3 === 0;
|
|
37
|
+
if (upperZero && g4 === 0 && g5 === 65535) return v4(g6, g7);
|
|
38
|
+
if (upperZero && g4 === 65535 && g5 === 0) return v4(g6, g7);
|
|
39
|
+
if (upperZero && g4 === 0 && g5 === 0) return v4(g6, g7);
|
|
40
|
+
if (g0 === 100 && g1 === 65435 && g2 + g3 + g4 + g5 === 0) return v4(g6, g7);
|
|
41
|
+
if (g0 === 8194) return v4(g1, g2);
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
function isMetadataAddress(address) {
|
|
45
|
+
const version = isIP(address.split("%")[0] ?? address);
|
|
46
|
+
if (version === 4) {
|
|
47
|
+
const [a = 0, b = 0, c = 0, d = 0] = address.split(".").map(Number);
|
|
48
|
+
return isMetadataIpv4(a, b, c, d);
|
|
49
|
+
}
|
|
50
|
+
if (version === 6) return isMetadataIpv6(address);
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
function normalizeHostname(hostname) {
|
|
54
|
+
const bare = hostname.startsWith("[") && hostname.endsWith("]") ? hostname.slice(1, -1) : hostname;
|
|
55
|
+
let host = bare.toLowerCase();
|
|
56
|
+
while (host.endsWith(".")) host = host.slice(0, -1);
|
|
57
|
+
return host;
|
|
58
|
+
}
|
|
59
|
+
function isMetadataHost(hostname) {
|
|
60
|
+
const host = normalizeHostname(hostname);
|
|
61
|
+
return METADATA_HOSTNAMES.has(host) || isMetadataAddress(host);
|
|
62
|
+
}
|
|
63
|
+
async function isMetadataTarget(hostname, resolve = resolveAllAddresses) {
|
|
64
|
+
if (isMetadataHost(hostname)) return true;
|
|
65
|
+
const host = normalizeHostname(hostname);
|
|
66
|
+
if (isIP(host) !== 0) return false;
|
|
67
|
+
let addresses;
|
|
68
|
+
try {
|
|
69
|
+
addresses = await resolve(host);
|
|
70
|
+
} catch {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
return addresses.some(isMetadataAddress);
|
|
74
|
+
}
|
|
75
|
+
function createMetadataCheckedLookup(resolve = resolveAllAddresses) {
|
|
76
|
+
return (hostname, options, callback) => {
|
|
77
|
+
const fail = (error) => {
|
|
78
|
+
const errno = Object.assign(error, { code: "EMETADATA" });
|
|
79
|
+
if (options.all) callback(errno, []);
|
|
80
|
+
else callback(errno, "", 0);
|
|
81
|
+
};
|
|
82
|
+
if (isMetadataHost(hostname)) {
|
|
83
|
+
fail(new Error(`Blocked request to metadata host: ${hostname}`));
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
resolve(hostname).then(
|
|
87
|
+
(addresses) => {
|
|
88
|
+
const blocked = addresses.find(isMetadataAddress);
|
|
89
|
+
if (blocked !== void 0) {
|
|
90
|
+
fail(new Error(`${hostname} resolves to metadata address ${blocked}`));
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const records = addresses.map((address) => ({
|
|
94
|
+
address,
|
|
95
|
+
family: isIP(address) === 6 ? 6 : 4
|
|
96
|
+
}));
|
|
97
|
+
const [first] = records;
|
|
98
|
+
if (first === void 0) {
|
|
99
|
+
fail(new Error(`Failed to resolve ${hostname}`));
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
if (options.all) callback(null, records);
|
|
103
|
+
else callback(null, first.address, first.family);
|
|
104
|
+
},
|
|
105
|
+
(error) => fail(error instanceof Error ? error : new Error(String(error)))
|
|
106
|
+
);
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
export {
|
|
110
|
+
createMetadataCheckedLookup,
|
|
111
|
+
isMetadataHost,
|
|
112
|
+
isMetadataTarget
|
|
113
|
+
};
|
package/dist/utils/path.cjs
CHANGED
|
@@ -28,7 +28,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
var path_exports = {};
|
|
30
30
|
__export(path_exports, {
|
|
31
|
-
copyDirectory: () => copyDirectory,
|
|
32
31
|
ensureDextoGlobalDirectory: () => ensureDextoGlobalDirectory,
|
|
33
32
|
findPackageRoot: () => findPackageRoot,
|
|
34
33
|
getDextoEnvPath: () => getDextoEnvPath,
|
|
@@ -91,19 +90,6 @@ function getDextoGlobalPath(type, filename) {
|
|
|
91
90
|
const basePath = path.join((0, import_os.homedir)(), ".dexto", type);
|
|
92
91
|
return filename ? path.join(basePath, filename) : basePath;
|
|
93
92
|
}
|
|
94
|
-
async function copyDirectory(src, dest) {
|
|
95
|
-
await import_fs2.promises.mkdir(dest, { recursive: true });
|
|
96
|
-
const entries = await import_fs2.promises.readdir(src, { withFileTypes: true });
|
|
97
|
-
for (const entry of entries) {
|
|
98
|
-
const srcPath = path.join(src, entry.name);
|
|
99
|
-
const destPath = path.join(dest, entry.name);
|
|
100
|
-
if (entry.isDirectory()) {
|
|
101
|
-
await copyDirectory(srcPath, destPath);
|
|
102
|
-
} else {
|
|
103
|
-
await import_fs2.promises.copyFile(srcPath, destPath);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
93
|
function isPath(str) {
|
|
108
94
|
if (path.isAbsolute(str)) return true;
|
|
109
95
|
if (/[\\/]/.test(str)) return true;
|
|
@@ -161,7 +147,6 @@ function getDextoEnvPath(startPath = process.cwd(), logger) {
|
|
|
161
147
|
}
|
|
162
148
|
// Annotate the CommonJS export names for ESM import in node:
|
|
163
149
|
0 && (module.exports = {
|
|
164
|
-
copyDirectory,
|
|
165
150
|
ensureDextoGlobalDirectory,
|
|
166
151
|
findPackageRoot,
|
|
167
152
|
getDextoEnvPath,
|
package/dist/utils/path.d.ts
CHANGED
|
@@ -23,12 +23,6 @@ export declare function getDextoPath(type: string, filename?: string, startPath?
|
|
|
23
23
|
* @returns Absolute path to the global location (~/.dexto/...)
|
|
24
24
|
*/
|
|
25
25
|
export declare function getDextoGlobalPath(type: string, filename?: string): string;
|
|
26
|
-
/**
|
|
27
|
-
* Copy entire directory recursively
|
|
28
|
-
* @param src Source directory path
|
|
29
|
-
* @param dest Destination directory path
|
|
30
|
-
*/
|
|
31
|
-
export declare function copyDirectory(src: string, dest: string): Promise<void>;
|
|
32
26
|
/**
|
|
33
27
|
* Check if string looks like a file path vs registry name
|
|
34
28
|
* @param str String to check
|
package/dist/utils/path.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../src/utils/path.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAEpD;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAuCxF;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAc1E;AAED;;;;GAIG;AACH,
|
|
1
|
+
{"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../src/utils/path.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAEpD;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAuCxF;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAc1E;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAW3C;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,SAAS,GAAE,MAAsB,GAAG,MAAM,GAAG,IAAI,CAKhF;AAMD;;GAEG;AACH,wBAAsB,0BAA0B,IAAI,OAAO,CAAC,IAAI,CAAC,CAUhE;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,SAAS,GAAE,MAAsB,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAkC1F"}
|
package/dist/utils/path.js
CHANGED
|
@@ -57,19 +57,6 @@ function getDextoGlobalPath(type, filename) {
|
|
|
57
57
|
const basePath = path.join(homedir(), ".dexto", type);
|
|
58
58
|
return filename ? path.join(basePath, filename) : basePath;
|
|
59
59
|
}
|
|
60
|
-
async function copyDirectory(src, dest) {
|
|
61
|
-
await fs.mkdir(dest, { recursive: true });
|
|
62
|
-
const entries = await fs.readdir(src, { withFileTypes: true });
|
|
63
|
-
for (const entry of entries) {
|
|
64
|
-
const srcPath = path.join(src, entry.name);
|
|
65
|
-
const destPath = path.join(dest, entry.name);
|
|
66
|
-
if (entry.isDirectory()) {
|
|
67
|
-
await copyDirectory(srcPath, destPath);
|
|
68
|
-
} else {
|
|
69
|
-
await fs.copyFile(srcPath, destPath);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
60
|
function isPath(str) {
|
|
74
61
|
if (path.isAbsolute(str)) return true;
|
|
75
62
|
if (/[\\/]/.test(str)) return true;
|
|
@@ -126,7 +113,6 @@ function getDextoEnvPath(startPath = process.cwd(), logger) {
|
|
|
126
113
|
return envPath;
|
|
127
114
|
}
|
|
128
115
|
export {
|
|
129
|
-
copyDirectory,
|
|
130
116
|
ensureDextoGlobalDirectory,
|
|
131
117
|
findPackageRoot,
|
|
132
118
|
getDextoEnvPath,
|