apiblaze 0.3.4 → 0.3.5
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/index.js +27 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -28,7 +28,7 @@ var import_commander = require("commander");
|
|
|
28
28
|
var import_chalk15 = __toESM(require("chalk"));
|
|
29
29
|
|
|
30
30
|
// package.json
|
|
31
|
-
var version = "0.3.
|
|
31
|
+
var version = "0.3.5";
|
|
32
32
|
|
|
33
33
|
// src/types.ts
|
|
34
34
|
var ApiError = class extends Error {
|
|
@@ -821,9 +821,6 @@ async function offerAutoCreate(teamId, port) {
|
|
|
821
821
|
spinner.fail("Failed to create the dev proxy.");
|
|
822
822
|
throw err;
|
|
823
823
|
}
|
|
824
|
-
const version2 = result.api_version || "1.0.0";
|
|
825
|
-
const endpoint = `https://${name}.apiblaze.com/${version2}/dev`;
|
|
826
|
-
console.log(` ${import_chalk4.default.dim("Endpoint:")} ${import_chalk4.default.bold(endpoint)}`);
|
|
827
824
|
if (auth === "api_key") {
|
|
828
825
|
const key = result.api_keys?.dev ?? Object.values(result.api_keys ?? {})[0];
|
|
829
826
|
if (key) {
|
|
@@ -839,6 +836,31 @@ async function offerAutoCreate(teamId, port) {
|
|
|
839
836
|
}
|
|
840
837
|
return created;
|
|
841
838
|
}
|
|
839
|
+
function isInternalTarget(url) {
|
|
840
|
+
if (!url) return false;
|
|
841
|
+
try {
|
|
842
|
+
const h = new URL(url).hostname.toLowerCase();
|
|
843
|
+
return h === "localhost" || h.endsWith(".localhost") || h.endsWith(".local") || h === "0.0.0.0" || /^127\./.test(h) || /^10\./.test(h) || /^192\.168\./.test(h) || /^169\.254\./.test(h) || /^172\.(1[6-9]|2\d|3[01])\./.test(h);
|
|
844
|
+
} catch {
|
|
845
|
+
return false;
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
function printTunnelEndpoints(restore, targets) {
|
|
849
|
+
if (restore.length === 0) return;
|
|
850
|
+
console.log(import_chalk4.default.bold("\nYour proxy is live at:"));
|
|
851
|
+
for (const r of restore) {
|
|
852
|
+
const label = targets.find((t) => t.projectId === r.projectId)?.projectName ?? r.projectId;
|
|
853
|
+
console.log(`
|
|
854
|
+
${import_chalk4.default.bold(label)}`);
|
|
855
|
+
const envs = Object.keys(r.environments ?? {}).filter((e) => isInternalTarget(r.environments[e]?.target));
|
|
856
|
+
for (const env of envs.length ? envs : ["dev"]) {
|
|
857
|
+
console.log(` ${import_chalk4.default.dim("API: ")} ${import_chalk4.default.cyan(`https://${r.projectId}.apiblaze.com/${r.apiVersion}/${env}`)}`);
|
|
858
|
+
}
|
|
859
|
+
if (r.tenant) {
|
|
860
|
+
console.log(` ${import_chalk4.default.dim("Portal:")} ${import_chalk4.default.cyan(`https://${r.tenant}.portal.apiblaze.com/${r.apiVersion}`)}`);
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
}
|
|
842
864
|
async function probeLocalServer(port) {
|
|
843
865
|
const controller = new AbortController();
|
|
844
866
|
const timer = setTimeout(() => controller.abort(), 1500);
|
|
@@ -944,6 +966,7 @@ Tunneling ${selectedTargets.length} project(s) to localhost:${options.port}
|
|
|
944
966
|
throw err;
|
|
945
967
|
}
|
|
946
968
|
}
|
|
969
|
+
printTunnelEndpoints(restore, selectedTargets);
|
|
947
970
|
const clients = connect.projects.map(
|
|
948
971
|
(projectId) => startTunnelClient({
|
|
949
972
|
connectUrl: connect.url,
|