zalo-agent-cli 1.0.0 → 1.0.1
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/README.md +4 -0
- package/package.json +1 -1
- package/src/utils/qr-http-server.js +44 -12
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -29,28 +29,60 @@ export function startQrServer(qrImagePath, port = 18927, tryPorts = [18927, 8080
|
|
|
29
29
|
}
|
|
30
30
|
const img = readFileSync(qrImagePath);
|
|
31
31
|
const b64 = img.toString("base64");
|
|
32
|
+
// Embed mascot inline (read from assets if available, else skip)
|
|
33
|
+
let mascotB64 = "";
|
|
34
|
+
try {
|
|
35
|
+
const { resolve: resolvePath } = await import("path");
|
|
36
|
+
const { fileURLToPath } = await import("url");
|
|
37
|
+
const { dirname } = await import("path");
|
|
38
|
+
const dir = dirname(fileURLToPath(import.meta.url));
|
|
39
|
+
const mascotPath = resolvePath(dir, "../../assets/mascot.png");
|
|
40
|
+
if (existsSync(mascotPath)) {
|
|
41
|
+
mascotB64 = readFileSync(mascotPath).toString("base64");
|
|
42
|
+
}
|
|
43
|
+
} catch {}
|
|
44
|
+
const mascotImg = mascotB64
|
|
45
|
+
? `<img src="data:image/png;base64,${mascotB64}" class="mascot" alt="zalo-agent"/>`
|
|
46
|
+
: "";
|
|
32
47
|
res.writeHead(200, { "Content-Type": "text/html" });
|
|
33
48
|
res.end(`<!DOCTYPE html>
|
|
34
|
-
<html><head><meta charset="utf-8"><title>Zalo QR Login</title>
|
|
49
|
+
<html><head><meta charset="utf-8"><title>Zalo Agent — QR Login</title>
|
|
35
50
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
36
51
|
<style>
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
52
|
+
*{box-sizing:border-box}
|
|
53
|
+
body{display:flex;justify-content:center;align-items:center;min-height:100vh;margin:0;
|
|
54
|
+
background:linear-gradient(135deg,#0a1628 0%,#111d33 50%,#0d1f3c 100%);font-family:system-ui,-apple-system,sans-serif}
|
|
55
|
+
.card{text-align:center;padding:2.5rem 2rem;background:rgba(17,29,51,0.9);
|
|
56
|
+
border-radius:20px;max-width:420px;width:90%;
|
|
57
|
+
border:1px solid rgba(59,130,246,0.2);backdrop-filter:blur(10px);
|
|
58
|
+
box-shadow:0 20px 60px rgba(0,0,0,0.5),0 0 40px rgba(59,130,246,0.1)}
|
|
59
|
+
.mascot{width:80px;height:80px;border-radius:50%;margin-bottom:0.5rem;
|
|
60
|
+
border:2px solid rgba(59,130,246,0.4);box-shadow:0 0 20px rgba(59,130,246,0.2)}
|
|
61
|
+
h1{color:#e2e8f0;font-size:1.1rem;font-weight:600;margin:0.5rem 0}
|
|
62
|
+
.brand{color:#3b82f6;font-size:0.8rem;margin-bottom:1.5rem;opacity:0.8}
|
|
63
|
+
.qr-img{width:260px;height:260px;border-radius:12px;border:3px solid rgba(59,130,246,0.3);
|
|
64
|
+
box-shadow:0 0 30px rgba(59,130,246,0.15)}
|
|
65
|
+
.hint{color:#94a3b8;font-size:0.85rem;margin-top:1.2rem;line-height:1.5}
|
|
66
|
+
.hint strong{color:#60a5fa}
|
|
67
|
+
.success-text{color:#4ade80;font-size:1.3rem;font-weight:bold}
|
|
42
68
|
.hidden{display:none}
|
|
69
|
+
.footer{color:#475569;font-size:0.7rem;margin-top:1.5rem}
|
|
70
|
+
.footer a{color:#3b82f6;text-decoration:none}
|
|
43
71
|
</style></head>
|
|
44
72
|
<body><div class="card">
|
|
45
73
|
<div id="qr-view">
|
|
46
|
-
|
|
47
|
-
<
|
|
48
|
-
<p
|
|
74
|
+
${mascotImg}
|
|
75
|
+
<h1>Zalo Agent CLI</h1>
|
|
76
|
+
<p class="brand">QR Code Login</p>
|
|
77
|
+
<img src="data:image/png;base64,${b64}" class="qr-img" alt="QR Code"/>
|
|
78
|
+
<p class="hint">Open <strong>Zalo app</strong> > <strong>QR Scanner</strong> to scan</p>
|
|
79
|
+
<p class="footer">Powered by <a href="https://github.com/PhucMPham/zalo-agent-cli">zalo-agent-cli</a></p>
|
|
49
80
|
</div>
|
|
50
81
|
<div id="success-view" class="hidden">
|
|
51
|
-
|
|
52
|
-
<
|
|
53
|
-
<p>
|
|
82
|
+
${mascotImg}
|
|
83
|
+
<h1 style="color:#4ade80;font-size:1.5rem;margin:1rem 0">Login Successful!</h1>
|
|
84
|
+
<p class="success-text">You can close this page now.</p>
|
|
85
|
+
<p class="hint">The CLI is ready to use.</p>
|
|
54
86
|
</div>
|
|
55
87
|
</div>
|
|
56
88
|
<script>
|