ccwebtty 1.0.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/LICENSE +15 -0
- package/README.md +61 -0
- package/dist/index.js +454 -0
- package/dist/index.js.map +1 -0
- package/dist/public/index.html +1038 -0
- package/dist/public/login.html +106 -0
- package/package.json +57 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>ccweb - Login</title>
|
|
7
|
+
<style>
|
|
8
|
+
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
9
|
+
html, body { height: 100%; background: #1a1b26; color: #a9b1d6; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; }
|
|
10
|
+
body { display: flex; align-items: center; justify-content: center; }
|
|
11
|
+
.login-box {
|
|
12
|
+
width: 320px;
|
|
13
|
+
padding: 32px 28px;
|
|
14
|
+
background: #16161e;
|
|
15
|
+
border: 1px solid #292e42;
|
|
16
|
+
border-radius: 12px;
|
|
17
|
+
}
|
|
18
|
+
.login-box h1 {
|
|
19
|
+
font-size: 20px;
|
|
20
|
+
color: #c0caf5;
|
|
21
|
+
margin-bottom: 4px;
|
|
22
|
+
}
|
|
23
|
+
.login-box p {
|
|
24
|
+
font-size: 13px;
|
|
25
|
+
color: #565f89;
|
|
26
|
+
margin-bottom: 24px;
|
|
27
|
+
}
|
|
28
|
+
label {
|
|
29
|
+
display: block;
|
|
30
|
+
font-size: 12px;
|
|
31
|
+
color: #565f89;
|
|
32
|
+
margin-bottom: 6px;
|
|
33
|
+
}
|
|
34
|
+
input {
|
|
35
|
+
width: 100%;
|
|
36
|
+
padding: 10px 12px;
|
|
37
|
+
background: #1a1b26;
|
|
38
|
+
border: 1px solid #292e42;
|
|
39
|
+
border-radius: 6px;
|
|
40
|
+
color: #c0caf5;
|
|
41
|
+
font-size: 14px;
|
|
42
|
+
outline: none;
|
|
43
|
+
transition: border-color 0.15s;
|
|
44
|
+
margin-bottom: 16px;
|
|
45
|
+
}
|
|
46
|
+
input:focus { border-color: #7aa2f7; }
|
|
47
|
+
button {
|
|
48
|
+
width: 100%;
|
|
49
|
+
padding: 10px;
|
|
50
|
+
background: #7aa2f7;
|
|
51
|
+
color: #1a1b26;
|
|
52
|
+
border: none;
|
|
53
|
+
border-radius: 6px;
|
|
54
|
+
font-size: 14px;
|
|
55
|
+
font-weight: 600;
|
|
56
|
+
cursor: pointer;
|
|
57
|
+
transition: background 0.15s;
|
|
58
|
+
}
|
|
59
|
+
button:hover { background: #89b4fa; }
|
|
60
|
+
button:active { background: #6a8edb; }
|
|
61
|
+
.error {
|
|
62
|
+
display: none;
|
|
63
|
+
font-size: 13px;
|
|
64
|
+
color: #f7768e;
|
|
65
|
+
margin-bottom: 12px;
|
|
66
|
+
}
|
|
67
|
+
</style>
|
|
68
|
+
</head>
|
|
69
|
+
<body>
|
|
70
|
+
<form class="login-box" method="POST" action="/login" id="login-form">
|
|
71
|
+
<h1>ccweb</h1>
|
|
72
|
+
<p>Web Terminal</p>
|
|
73
|
+
<div class="error" id="error-msg">Invalid username or password</div>
|
|
74
|
+
<label for="username">Username</label>
|
|
75
|
+
<input type="text" id="username" name="username" autocomplete="username" required autofocus />
|
|
76
|
+
<label for="password">Password</label>
|
|
77
|
+
<input type="password" id="password" name="password" autocomplete="current-password" required />
|
|
78
|
+
<button type="submit">Login</button>
|
|
79
|
+
</form>
|
|
80
|
+
<script>
|
|
81
|
+
var form = document.getElementById('login-form');
|
|
82
|
+
var errorMsg = document.getElementById('error-msg');
|
|
83
|
+
form.addEventListener('submit', function (e) {
|
|
84
|
+
e.preventDefault();
|
|
85
|
+
var fd = new FormData(form);
|
|
86
|
+
var body = new URLSearchParams();
|
|
87
|
+
body.append('username', fd.get('username'));
|
|
88
|
+
body.append('password', fd.get('password'));
|
|
89
|
+
fetch('/login', {
|
|
90
|
+
method: 'POST',
|
|
91
|
+
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
92
|
+
body: body.toString(),
|
|
93
|
+
redirect: 'manual',
|
|
94
|
+
}).then(function (res) {
|
|
95
|
+
if (res.status === 200 || res.type === 'opaqueredirect') {
|
|
96
|
+
window.location.href = '/';
|
|
97
|
+
} else {
|
|
98
|
+
errorMsg.style.display = 'block';
|
|
99
|
+
}
|
|
100
|
+
}).catch(function () {
|
|
101
|
+
errorMsg.style.display = 'block';
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
</script>
|
|
105
|
+
</body>
|
|
106
|
+
</html>
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ccwebtty",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A CLI tool that exposes an interactive web terminal, similar to ttyd",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"ccweb": "dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist/",
|
|
11
|
+
"README.md",
|
|
12
|
+
"LICENSE"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"postinstall": "node -e \"const fs=require('fs'),p=require('path'),d=p.join('node_modules','node-pty','prebuilds');if(fs.existsSync(d))for(const s of fs.readdirSync(d)){const h=p.join(d,s,'spawn-helper');if(fs.existsSync(h))fs.chmodSync(h,0o755)}\"",
|
|
16
|
+
"build": "tsup",
|
|
17
|
+
"dev": "tsup --watch",
|
|
18
|
+
"prestart": "npm run build",
|
|
19
|
+
"start": "node dist/index.js",
|
|
20
|
+
"prepublishOnly": "npm run build"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"terminal",
|
|
24
|
+
"web",
|
|
25
|
+
"cli",
|
|
26
|
+
"pty",
|
|
27
|
+
"ttyd"
|
|
28
|
+
],
|
|
29
|
+
"author": "",
|
|
30
|
+
"license": "ISC",
|
|
31
|
+
"type": "commonjs",
|
|
32
|
+
"engines": {
|
|
33
|
+
"node": ">=18"
|
|
34
|
+
},
|
|
35
|
+
"repository": {
|
|
36
|
+
"type": "git",
|
|
37
|
+
"url": "https://github.com/nickcao/ccweb.git"
|
|
38
|
+
},
|
|
39
|
+
"homepage": "https://github.com/nickcao/ccweb#readme",
|
|
40
|
+
"bugs": {
|
|
41
|
+
"url": "https://github.com/nickcao/ccweb/issues"
|
|
42
|
+
},
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"cloudflared": "^0.7.1",
|
|
45
|
+
"commander": "^14.0.3",
|
|
46
|
+
"express": "^5.2.1",
|
|
47
|
+
"node-pty": "^1.1.0",
|
|
48
|
+
"ws": "^8.19.0"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@types/express": "^5.0.6",
|
|
52
|
+
"@types/node": "^25.3.5",
|
|
53
|
+
"@types/ws": "^8.18.1",
|
|
54
|
+
"tsup": "^8.5.1",
|
|
55
|
+
"typescript": "^5.9.3"
|
|
56
|
+
}
|
|
57
|
+
}
|