@solongate/proxy 0.44.0 → 0.45.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/index.js +32 -13
- package/dist/login.js +31 -12
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7473,6 +7473,27 @@ var init_init = __esm({
|
|
|
7473
7473
|
// src/login.ts
|
|
7474
7474
|
var login_exports = {};
|
|
7475
7475
|
import { spawn } from "child_process";
|
|
7476
|
+
function startSpinner2(text) {
|
|
7477
|
+
if (!process.stderr.isTTY) {
|
|
7478
|
+
process.stderr.write(` ${text}
|
|
7479
|
+
`);
|
|
7480
|
+
return (finalLine) => {
|
|
7481
|
+
if (finalLine) process.stderr.write(finalLine + "\n");
|
|
7482
|
+
};
|
|
7483
|
+
}
|
|
7484
|
+
let i = 0;
|
|
7485
|
+
const draw = () => {
|
|
7486
|
+
const frame = SPINNER_FRAMES2[i = (i + 1) % SPINNER_FRAMES2.length];
|
|
7487
|
+
process.stderr.write(`\r ${c.cyan}${frame}${c.reset} ${c.dim}${text}${c.reset}\x1B[K`);
|
|
7488
|
+
};
|
|
7489
|
+
draw();
|
|
7490
|
+
const timer = setInterval(draw, 80);
|
|
7491
|
+
return (finalLine) => {
|
|
7492
|
+
clearInterval(timer);
|
|
7493
|
+
process.stderr.write("\r\x1B[K");
|
|
7494
|
+
if (finalLine) process.stderr.write(finalLine + "\n");
|
|
7495
|
+
};
|
|
7496
|
+
}
|
|
7476
7497
|
function parseArgs2(argv) {
|
|
7477
7498
|
const args = argv.slice(3);
|
|
7478
7499
|
let apiUrl = process.env["SOLONGATE_API_URL"] || "https://api.solongate.com";
|
|
@@ -7494,7 +7515,7 @@ function openBrowser(url) {
|
|
|
7494
7515
|
async function main2() {
|
|
7495
7516
|
const { apiUrl, install } = parseArgs2(process.argv);
|
|
7496
7517
|
console.log("");
|
|
7497
|
-
console.log(` ${c.bold}SolonGate \u2014 Login${c.reset}`);
|
|
7518
|
+
console.log(` ${c.bold}${c.blue4}SolonGate${c.reset} ${c.dim}\u2014 Login${c.reset}`);
|
|
7498
7519
|
console.log("");
|
|
7499
7520
|
let start;
|
|
7500
7521
|
try {
|
|
@@ -7508,20 +7529,19 @@ async function main2() {
|
|
|
7508
7529
|
}
|
|
7509
7530
|
const { device_code, user_code, verification_uri_complete, verification_uri, interval, expires_in } = start;
|
|
7510
7531
|
const verifyUrl = verification_uri_complete || verification_uri;
|
|
7511
|
-
console.log(` Opening your browser to authorize this device\u2026`);
|
|
7532
|
+
console.log(` ${c.blue5}\u2192${c.reset} Opening your browser to authorize this device\u2026`);
|
|
7512
7533
|
console.log("");
|
|
7513
7534
|
console.log(` ${c.dim}If it doesn't open, visit this link:${c.reset}`);
|
|
7514
|
-
console.log(` ${c.
|
|
7535
|
+
console.log(` ${c.cyan}${verifyUrl}${c.reset}`);
|
|
7515
7536
|
console.log("");
|
|
7516
7537
|
void user_code;
|
|
7517
7538
|
openBrowser(verifyUrl);
|
|
7518
7539
|
const pollMs = Math.max(2, Number(interval) || 3) * 1e3;
|
|
7519
7540
|
const deadline = Date.now() + (Number(expires_in) || 600) * 1e3;
|
|
7520
7541
|
let apiKey = "";
|
|
7521
|
-
|
|
7542
|
+
const stopSpinner2 = startSpinner2("Waiting for authorization\u2026");
|
|
7522
7543
|
while (Date.now() < deadline) {
|
|
7523
7544
|
await sleep2(pollMs);
|
|
7524
|
-
process.stderr.write(".");
|
|
7525
7545
|
try {
|
|
7526
7546
|
const res = await fetch(`${apiUrl}/api/v1/auth/device/poll`, {
|
|
7527
7547
|
method: "POST",
|
|
@@ -7531,32 +7551,30 @@ async function main2() {
|
|
|
7531
7551
|
const data = await res.json().catch(() => ({}));
|
|
7532
7552
|
if (data?.status === "approved" && data?.api_key) {
|
|
7533
7553
|
apiKey = data.api_key;
|
|
7534
|
-
|
|
7554
|
+
stopSpinner2();
|
|
7535
7555
|
console.log("");
|
|
7536
7556
|
const who = data?.user?.name || data?.user?.email;
|
|
7537
7557
|
const mail = data?.user?.email;
|
|
7538
7558
|
if (who) {
|
|
7539
7559
|
const suffix = mail && mail !== who ? ` ${c.dim}(${mail})${c.reset}` : "";
|
|
7540
|
-
console.log(` ${c.green}\u2713${c.reset} ${c.bold}Logged in as ${who}${c.reset}${suffix}`);
|
|
7560
|
+
console.log(` ${c.green}\u2713${c.reset} ${c.bold}Logged in as ${c.white}${who}${c.reset}${suffix}`);
|
|
7541
7561
|
} else {
|
|
7542
7562
|
console.log(` ${c.green}\u2713${c.reset} ${c.bold}Logged in${c.reset}`);
|
|
7543
7563
|
}
|
|
7544
7564
|
if (data?.project?.name) {
|
|
7545
|
-
console.log(` ${c.dim}Project:${c.reset} ${data.project.name}`);
|
|
7565
|
+
console.log(` ${c.dim}Project:${c.reset} ${c.cyan}${data.project.name}${c.reset}`);
|
|
7546
7566
|
}
|
|
7547
7567
|
break;
|
|
7548
7568
|
}
|
|
7549
7569
|
if (data?.status === "expired" || data?.status === "not_found") {
|
|
7550
|
-
|
|
7551
|
-
console.log(" Code expired. Run `login` again.");
|
|
7570
|
+
stopSpinner2(` ${c.red}\u2717${c.reset} Code expired. Run \`login\` again.`);
|
|
7552
7571
|
process.exit(1);
|
|
7553
7572
|
}
|
|
7554
7573
|
} catch {
|
|
7555
7574
|
}
|
|
7556
7575
|
}
|
|
7557
7576
|
if (!apiKey) {
|
|
7558
|
-
|
|
7559
|
-
console.log(" Timed out waiting for authorization. Run `login` again.");
|
|
7577
|
+
stopSpinner2(` ${c.red}\u2717${c.reset} Timed out waiting for authorization. Run \`login\` again.`);
|
|
7560
7578
|
process.exit(1);
|
|
7561
7579
|
}
|
|
7562
7580
|
if (!install) {
|
|
@@ -7579,13 +7597,14 @@ async function main2() {
|
|
|
7579
7597
|
console.log(" \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518");
|
|
7580
7598
|
console.log("");
|
|
7581
7599
|
}
|
|
7582
|
-
var sleep2;
|
|
7600
|
+
var sleep2, SPINNER_FRAMES2;
|
|
7583
7601
|
var init_login = __esm({
|
|
7584
7602
|
"src/login.ts"() {
|
|
7585
7603
|
"use strict";
|
|
7586
7604
|
init_cli_utils();
|
|
7587
7605
|
init_global_install();
|
|
7588
7606
|
sleep2 = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
7607
|
+
SPINNER_FRAMES2 = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
|
|
7589
7608
|
main2().catch((err) => {
|
|
7590
7609
|
console.log(`Fatal: ${err instanceof Error ? err.message : String(err)}`);
|
|
7591
7610
|
process.exit(1);
|
package/dist/login.js
CHANGED
|
@@ -196,6 +196,28 @@ async function runGlobalInstall(opts = {}) {
|
|
|
196
196
|
|
|
197
197
|
// src/login.ts
|
|
198
198
|
var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
199
|
+
var SPINNER_FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
|
|
200
|
+
function startSpinner(text) {
|
|
201
|
+
if (!process.stderr.isTTY) {
|
|
202
|
+
process.stderr.write(` ${text}
|
|
203
|
+
`);
|
|
204
|
+
return (finalLine) => {
|
|
205
|
+
if (finalLine) process.stderr.write(finalLine + "\n");
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
let i = 0;
|
|
209
|
+
const draw = () => {
|
|
210
|
+
const frame = SPINNER_FRAMES[i = (i + 1) % SPINNER_FRAMES.length];
|
|
211
|
+
process.stderr.write(`\r ${c.cyan}${frame}${c.reset} ${c.dim}${text}${c.reset}\x1B[K`);
|
|
212
|
+
};
|
|
213
|
+
draw();
|
|
214
|
+
const timer = setInterval(draw, 80);
|
|
215
|
+
return (finalLine) => {
|
|
216
|
+
clearInterval(timer);
|
|
217
|
+
process.stderr.write("\r\x1B[K");
|
|
218
|
+
if (finalLine) process.stderr.write(finalLine + "\n");
|
|
219
|
+
};
|
|
220
|
+
}
|
|
199
221
|
function parseArgs(argv) {
|
|
200
222
|
const args = argv.slice(3);
|
|
201
223
|
let apiUrl = process.env["SOLONGATE_API_URL"] || "https://api.solongate.com";
|
|
@@ -217,7 +239,7 @@ function openBrowser(url) {
|
|
|
217
239
|
async function main() {
|
|
218
240
|
const { apiUrl, install } = parseArgs(process.argv);
|
|
219
241
|
console.log("");
|
|
220
|
-
console.log(` ${c.bold}SolonGate \u2014 Login${c.reset}`);
|
|
242
|
+
console.log(` ${c.bold}${c.blue4}SolonGate${c.reset} ${c.dim}\u2014 Login${c.reset}`);
|
|
221
243
|
console.log("");
|
|
222
244
|
let start;
|
|
223
245
|
try {
|
|
@@ -231,20 +253,19 @@ async function main() {
|
|
|
231
253
|
}
|
|
232
254
|
const { device_code, user_code, verification_uri_complete, verification_uri, interval, expires_in } = start;
|
|
233
255
|
const verifyUrl = verification_uri_complete || verification_uri;
|
|
234
|
-
console.log(` Opening your browser to authorize this device\u2026`);
|
|
256
|
+
console.log(` ${c.blue5}\u2192${c.reset} Opening your browser to authorize this device\u2026`);
|
|
235
257
|
console.log("");
|
|
236
258
|
console.log(` ${c.dim}If it doesn't open, visit this link:${c.reset}`);
|
|
237
|
-
console.log(` ${c.
|
|
259
|
+
console.log(` ${c.cyan}${verifyUrl}${c.reset}`);
|
|
238
260
|
console.log("");
|
|
239
261
|
void user_code;
|
|
240
262
|
openBrowser(verifyUrl);
|
|
241
263
|
const pollMs = Math.max(2, Number(interval) || 3) * 1e3;
|
|
242
264
|
const deadline = Date.now() + (Number(expires_in) || 600) * 1e3;
|
|
243
265
|
let apiKey = "";
|
|
244
|
-
|
|
266
|
+
const stopSpinner = startSpinner("Waiting for authorization\u2026");
|
|
245
267
|
while (Date.now() < deadline) {
|
|
246
268
|
await sleep(pollMs);
|
|
247
|
-
process.stderr.write(".");
|
|
248
269
|
try {
|
|
249
270
|
const res = await fetch(`${apiUrl}/api/v1/auth/device/poll`, {
|
|
250
271
|
method: "POST",
|
|
@@ -254,32 +275,30 @@ async function main() {
|
|
|
254
275
|
const data = await res.json().catch(() => ({}));
|
|
255
276
|
if (data?.status === "approved" && data?.api_key) {
|
|
256
277
|
apiKey = data.api_key;
|
|
257
|
-
|
|
278
|
+
stopSpinner();
|
|
258
279
|
console.log("");
|
|
259
280
|
const who = data?.user?.name || data?.user?.email;
|
|
260
281
|
const mail = data?.user?.email;
|
|
261
282
|
if (who) {
|
|
262
283
|
const suffix = mail && mail !== who ? ` ${c.dim}(${mail})${c.reset}` : "";
|
|
263
|
-
console.log(` ${c.green}\u2713${c.reset} ${c.bold}Logged in as ${who}${c.reset}${suffix}`);
|
|
284
|
+
console.log(` ${c.green}\u2713${c.reset} ${c.bold}Logged in as ${c.white}${who}${c.reset}${suffix}`);
|
|
264
285
|
} else {
|
|
265
286
|
console.log(` ${c.green}\u2713${c.reset} ${c.bold}Logged in${c.reset}`);
|
|
266
287
|
}
|
|
267
288
|
if (data?.project?.name) {
|
|
268
|
-
console.log(` ${c.dim}Project:${c.reset} ${data.project.name}`);
|
|
289
|
+
console.log(` ${c.dim}Project:${c.reset} ${c.cyan}${data.project.name}${c.reset}`);
|
|
269
290
|
}
|
|
270
291
|
break;
|
|
271
292
|
}
|
|
272
293
|
if (data?.status === "expired" || data?.status === "not_found") {
|
|
273
|
-
|
|
274
|
-
console.log(" Code expired. Run `login` again.");
|
|
294
|
+
stopSpinner(` ${c.red}\u2717${c.reset} Code expired. Run \`login\` again.`);
|
|
275
295
|
process.exit(1);
|
|
276
296
|
}
|
|
277
297
|
} catch {
|
|
278
298
|
}
|
|
279
299
|
}
|
|
280
300
|
if (!apiKey) {
|
|
281
|
-
|
|
282
|
-
console.log(" Timed out waiting for authorization. Run `login` again.");
|
|
301
|
+
stopSpinner(` ${c.red}\u2717${c.reset} Timed out waiting for authorization. Run \`login\` again.`);
|
|
283
302
|
process.exit(1);
|
|
284
303
|
}
|
|
285
304
|
if (!install) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solongate/proxy",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.45.0",
|
|
4
4
|
"description": "AI tool security proxy — protect any AI tool server with customizable policies, path/command constraints, rate limiting, and audit logging. Zero code changes required.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|