claude-codex-proxy 1.0.5-beta.9 → 1.0.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/README.md +6 -55
- package/bin/cli.js +0 -71
- package/docs/API.md +0 -22
- package/package.json +2 -3
- package/public/css/style.css +9 -210
- package/public/index.html +811 -32
- package/public/js/app.js +617 -104
- package/src/account-rotation/rate-limits.js +26 -0
- package/src/claude-config.js +18 -0
- package/src/direct-api.js +13 -12
- package/src/index.js +8 -26
- package/src/response-streamer.js +5 -5
- package/src/routes/api-routes.js +9 -44
- package/src/routes/chat-route.js +4 -25
- package/src/routes/claude-config-route.js +10 -54
- package/src/routes/logs-route.js +2 -21
- package/src/routes/messages-route.js +6 -30
- package/src/routes/settings-route.js +2 -131
- package/src/server-settings.js +3 -20
- package/src/server.js +6 -10
- package/src/utils/logger.js +0 -18
- package/public/login.html +0 -32
- package/public/views/accounts-modals.html +0 -159
- package/public/views/accounts.html +0 -183
- package/public/views/client-api-keys-modals.html +0 -55
- package/public/views/client-api-keys.html +0 -69
- package/public/views/dashboard.html +0 -90
- package/public/views/empty.html +0 -0
- package/public/views/logs.html +0 -99
- package/public/views/settings.html +0 -123
- package/src/client-key-usage.js +0 -125
- package/src/deployment.js +0 -49
- package/src/middleware/auth.js +0 -115
- package/src/model-pricing.js +0 -96
- package/src/routes/client-quota-route.js +0 -25
- package/src/utils/proxy-logging.js +0 -5
|
@@ -9,37 +9,10 @@
|
|
|
9
9
|
* POST /settings/raw-proxy-logs
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
import
|
|
13
|
-
import {
|
|
14
|
-
getServerSettings,
|
|
15
|
-
setServerSettings,
|
|
16
|
-
DEFAULT_MODEL_MAP,
|
|
17
|
-
DEFAULT_CLIENT_KEY_WEEKLY_LIMIT_USD
|
|
18
|
-
} from '../server-settings.js';
|
|
19
|
-
import { deleteClientKeyUsage, getClientKeyQuota } from '../client-key-usage.js';
|
|
12
|
+
import { getServerSettings, setServerSettings, DEFAULT_MODEL_MAP } from '../server-settings.js';
|
|
20
13
|
|
|
21
14
|
const VALID_STRATEGIES = ['sticky', 'round-robin'];
|
|
22
15
|
|
|
23
|
-
function getSafeClientApiKey(clientApiKey) {
|
|
24
|
-
const { key, ...safeClientApiKey } = clientApiKey;
|
|
25
|
-
return {
|
|
26
|
-
...safeClientApiKey,
|
|
27
|
-
quota: getClientKeyQuota(clientApiKey.id, clientApiKey.weeklyLimitUsd)
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function validateWeeklyLimitUsd(weeklyLimitUsd) {
|
|
32
|
-
if (typeof weeklyLimitUsd !== 'number' || !Number.isFinite(weeklyLimitUsd) || weeklyLimitUsd < 0) {
|
|
33
|
-
return 'weeklyLimitUsd must be a non-negative number';
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function createClientApiKeyValue() {
|
|
40
|
-
return `ccp_${crypto.randomBytes(24).toString('base64url')}`;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
16
|
/**
|
|
44
17
|
* GET /settings/account-strategy
|
|
45
18
|
* Returns the current account selection strategy.
|
|
@@ -171,113 +144,11 @@ export function handleSetRawProxyLogs(req, res) {
|
|
|
171
144
|
res.json({ success: true, logRawProxyPayloads: settings.logRawProxyPayloads === true });
|
|
172
145
|
}
|
|
173
146
|
|
|
174
|
-
/**
|
|
175
|
-
* GET /settings/client-api-keys
|
|
176
|
-
* Returns metadata only; client API key values are never returned after creation.
|
|
177
|
-
*/
|
|
178
|
-
export function handleListClientApiKeys(req, res) {
|
|
179
|
-
const { clientApiKeys } = getServerSettings();
|
|
180
|
-
res.json({ success: true, clientApiKeys: clientApiKeys.map(getSafeClientApiKey) });
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* POST /settings/client-api-keys
|
|
185
|
-
* Creates a Claude Code client API key.
|
|
186
|
-
*/
|
|
187
|
-
export function handleCreateClientApiKey(req, res) {
|
|
188
|
-
const { name = '', remark = '', weeklyLimitUsd = DEFAULT_CLIENT_KEY_WEEKLY_LIMIT_USD } = req.body || {};
|
|
189
|
-
|
|
190
|
-
if (typeof name !== 'string' || typeof remark !== 'string') {
|
|
191
|
-
return res.status(400).json({ success: false, error: 'name and remark must be strings' });
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
const weeklyLimitError = validateWeeklyLimitUsd(weeklyLimitUsd);
|
|
195
|
-
if (weeklyLimitError) {
|
|
196
|
-
return res.status(400).json({ success: false, error: weeklyLimitError });
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
const clientApiKey = {
|
|
200
|
-
id: crypto.randomUUID(),
|
|
201
|
-
key: createClientApiKeyValue(),
|
|
202
|
-
name: name.trim(),
|
|
203
|
-
remark: remark.trim(),
|
|
204
|
-
weeklyLimitUsd,
|
|
205
|
-
createdAt: new Date().toISOString()
|
|
206
|
-
};
|
|
207
|
-
const settings = getServerSettings();
|
|
208
|
-
setServerSettings({ clientApiKeys: [...settings.clientApiKeys, clientApiKey] });
|
|
209
|
-
|
|
210
|
-
res.status(201).json({ success: true, clientApiKey });
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
* PUT /settings/client-api-keys/:id
|
|
215
|
-
* Updates a client API key's name or remark without exposing its value.
|
|
216
|
-
*/
|
|
217
|
-
export function handleUpdateClientApiKey(req, res) {
|
|
218
|
-
const { id } = req.params;
|
|
219
|
-
const { name, remark, weeklyLimitUsd } = req.body || {};
|
|
220
|
-
|
|
221
|
-
if (name !== undefined && typeof name !== 'string') {
|
|
222
|
-
return res.status(400).json({ success: false, error: 'name must be a string' });
|
|
223
|
-
}
|
|
224
|
-
if (remark !== undefined && typeof remark !== 'string') {
|
|
225
|
-
return res.status(400).json({ success: false, error: 'remark must be a string' });
|
|
226
|
-
}
|
|
227
|
-
if (weeklyLimitUsd !== undefined) {
|
|
228
|
-
const weeklyLimitError = validateWeeklyLimitUsd(weeklyLimitUsd);
|
|
229
|
-
if (weeklyLimitError) {
|
|
230
|
-
return res.status(400).json({ success: false, error: weeklyLimitError });
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
const settings = getServerSettings();
|
|
235
|
-
const index = settings.clientApiKeys.findIndex((clientApiKey) => clientApiKey.id === id);
|
|
236
|
-
if (index < 0) {
|
|
237
|
-
return res.status(404).json({ success: false, error: 'Client API key not found' });
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
const current = settings.clientApiKeys[index];
|
|
241
|
-
const clientApiKey = {
|
|
242
|
-
...current,
|
|
243
|
-
...(name === undefined ? {} : { name: name.trim() }),
|
|
244
|
-
...(remark === undefined ? {} : { remark: remark.trim() }),
|
|
245
|
-
...(weeklyLimitUsd === undefined ? {} : { weeklyLimitUsd })
|
|
246
|
-
};
|
|
247
|
-
const clientApiKeys = [...settings.clientApiKeys];
|
|
248
|
-
clientApiKeys[index] = clientApiKey;
|
|
249
|
-
setServerSettings({ clientApiKeys });
|
|
250
|
-
|
|
251
|
-
res.json({ success: true, clientApiKey: getSafeClientApiKey(clientApiKey) });
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
/**
|
|
255
|
-
* DELETE /settings/client-api-keys/:id
|
|
256
|
-
* Removes a Claude Code client API key immediately.
|
|
257
|
-
*/
|
|
258
|
-
export function handleDeleteClientApiKey(req, res) {
|
|
259
|
-
const { id } = req.params;
|
|
260
|
-
const settings = getServerSettings();
|
|
261
|
-
const clientApiKeys = settings.clientApiKeys.filter((clientApiKey) => clientApiKey.id !== id);
|
|
262
|
-
|
|
263
|
-
if (clientApiKeys.length === settings.clientApiKeys.length) {
|
|
264
|
-
return res.status(404).json({ success: false, error: 'Client API key not found' });
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
setServerSettings({ clientApiKeys });
|
|
268
|
-
deleteClientKeyUsage(id);
|
|
269
|
-
res.json({ success: true });
|
|
270
|
-
}
|
|
271
|
-
|
|
272
147
|
export default {
|
|
273
148
|
handleGetAccountStrategy,
|
|
274
149
|
handleSetAccountStrategy,
|
|
275
150
|
handleGetModelMap,
|
|
276
151
|
handleSetModelMap,
|
|
277
152
|
handleGetRawProxyLogs,
|
|
278
|
-
handleSetRawProxyLogs
|
|
279
|
-
handleListClientApiKeys,
|
|
280
|
-
handleCreateClientApiKey,
|
|
281
|
-
handleUpdateClientApiKey,
|
|
282
|
-
handleDeleteClientApiKey
|
|
153
|
+
handleSetRawProxyLogs
|
|
283
154
|
};
|
package/src/server-settings.js
CHANGED
|
@@ -10,14 +10,11 @@ export const DEFAULT_MODEL_MAP = {
|
|
|
10
10
|
haiku: 'gpt-5.4-mini'
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
export const DEFAULT_CLIENT_KEY_WEEKLY_LIMIT_USD = 50;
|
|
14
|
-
|
|
15
13
|
export const DEFAULT_SETTINGS = {
|
|
16
14
|
accountStrategy: 'sticky',
|
|
17
15
|
defaultCodexModel: 'gpt-5.5',
|
|
18
16
|
logRawProxyPayloads: false,
|
|
19
|
-
modelMap: DEFAULT_MODEL_MAP
|
|
20
|
-
clientApiKeys: []
|
|
17
|
+
modelMap: DEFAULT_MODEL_MAP
|
|
21
18
|
};
|
|
22
19
|
|
|
23
20
|
function ensureConfigDir() {
|
|
@@ -26,16 +23,6 @@ function ensureConfigDir() {
|
|
|
26
23
|
}
|
|
27
24
|
}
|
|
28
25
|
|
|
29
|
-
function normalizeClientApiKey(clientApiKey) {
|
|
30
|
-
const weeklyLimitUsd = Number(clientApiKey?.weeklyLimitUsd);
|
|
31
|
-
return {
|
|
32
|
-
...clientApiKey,
|
|
33
|
-
weeklyLimitUsd: Number.isFinite(weeklyLimitUsd) && weeklyLimitUsd >= 0
|
|
34
|
-
? weeklyLimitUsd
|
|
35
|
-
: DEFAULT_CLIENT_KEY_WEEKLY_LIMIT_USD
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
|
|
39
26
|
function mergeSettings(data = {}) {
|
|
40
27
|
return {
|
|
41
28
|
...DEFAULT_SETTINGS,
|
|
@@ -43,10 +30,7 @@ function mergeSettings(data = {}) {
|
|
|
43
30
|
modelMap: {
|
|
44
31
|
...DEFAULT_MODEL_MAP,
|
|
45
32
|
...(data.modelMap || {})
|
|
46
|
-
}
|
|
47
|
-
clientApiKeys: Array.isArray(data.clientApiKeys)
|
|
48
|
-
? data.clientApiKeys.map(normalizeClientApiKey)
|
|
49
|
-
: []
|
|
33
|
+
}
|
|
50
34
|
};
|
|
51
35
|
}
|
|
52
36
|
|
|
@@ -80,6 +64,5 @@ export default {
|
|
|
80
64
|
setServerSettings,
|
|
81
65
|
SETTINGS_FILE,
|
|
82
66
|
DEFAULT_SETTINGS,
|
|
83
|
-
DEFAULT_MODEL_MAP
|
|
84
|
-
DEFAULT_CLIENT_KEY_WEEKLY_LIMIT_USD
|
|
67
|
+
DEFAULT_MODEL_MAP
|
|
85
68
|
};
|
package/src/server.js
CHANGED
|
@@ -7,14 +7,11 @@ import express from 'express';
|
|
|
7
7
|
import cors from 'cors';
|
|
8
8
|
|
|
9
9
|
import { ensureAccountsPersist, startAutoRefresh } from './account-manager.js';
|
|
10
|
-
import { getServerHost } from './deployment.js';
|
|
11
10
|
import { registerApiRoutes } from './routes/api-routes.js';
|
|
12
11
|
|
|
13
|
-
export function createServer({ port, testMode = false
|
|
14
|
-
if (!testMode
|
|
12
|
+
export function createServer({ port, testMode = false }) {
|
|
13
|
+
if (!testMode) {
|
|
15
14
|
ensureAccountsPersist();
|
|
16
|
-
}
|
|
17
|
-
if (!testMode && startBackgroundJobs) {
|
|
18
15
|
startAutoRefresh();
|
|
19
16
|
}
|
|
20
17
|
|
|
@@ -26,8 +23,7 @@ export function createServer({ port, testMode = false, startBackgroundJobs = tru
|
|
|
26
23
|
const start = Date.now();
|
|
27
24
|
res.on('finish', () => {
|
|
28
25
|
const duration = Date.now() - start;
|
|
29
|
-
const
|
|
30
|
-
const msg = `[${req.method}] ${safeUrl} ${res.statusCode} (${duration}ms)`;
|
|
26
|
+
const msg = `[${req.method}] ${req.originalUrl} ${res.statusCode} (${duration}ms)`;
|
|
31
27
|
if (res.statusCode >= 400) {
|
|
32
28
|
console.log(`\x1b[31m${msg}\x1b[0m`); // Red for error
|
|
33
29
|
} else if (req.originalUrl !== '/health') { // Skip health check logs to reduce noise
|
|
@@ -45,7 +41,7 @@ export function createServer({ port, testMode = false, startBackgroundJobs = tru
|
|
|
45
41
|
'http://127.0.0.1'
|
|
46
42
|
],
|
|
47
43
|
methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'],
|
|
48
|
-
allowedHeaders: ['Content-Type', 'Authorization'
|
|
44
|
+
allowedHeaders: ['Content-Type', 'Authorization'],
|
|
49
45
|
credentials: false
|
|
50
46
|
}));
|
|
51
47
|
app.use(express.json({ limit: process.env.JSON_BODY_LIMIT || '50mb' }));
|
|
@@ -55,9 +51,9 @@ export function createServer({ port, testMode = false, startBackgroundJobs = tru
|
|
|
55
51
|
return app;
|
|
56
52
|
}
|
|
57
53
|
|
|
58
|
-
export function startServer({ port
|
|
54
|
+
export function startServer({ port }) {
|
|
59
55
|
const app = createServer({ port });
|
|
60
|
-
return app.listen(port
|
|
56
|
+
return app.listen(port);
|
|
61
57
|
}
|
|
62
58
|
|
|
63
59
|
export default { createServer, startServer };
|
package/src/utils/logger.js
CHANGED
|
@@ -40,24 +40,6 @@ class Logger extends EventEmitter {
|
|
|
40
40
|
return [...this.history];
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
/**
|
|
44
|
-
* Returns a newest-first page of in-memory log entries.
|
|
45
|
-
*
|
|
46
|
-
* @param {number} page - One-based page number.
|
|
47
|
-
* @param {number} pageSize - Maximum number of entries per page.
|
|
48
|
-
* @returns {{ logs: object[], total: number }} Requested page and total entry count.
|
|
49
|
-
*/
|
|
50
|
-
getHistoryPage(page, pageSize) {
|
|
51
|
-
const total = this.history.length;
|
|
52
|
-
const end = Math.max(0, total - (page - 1) * pageSize);
|
|
53
|
-
const start = Math.max(0, end - pageSize);
|
|
54
|
-
|
|
55
|
-
return {
|
|
56
|
-
logs: this.history.slice(start, end).reverse(),
|
|
57
|
-
total
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
|
|
61
43
|
clear() {
|
|
62
44
|
this.history = [];
|
|
63
45
|
}
|
package/public/login.html
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en" data-theme="codex" class="dark">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8">
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
-
<title>Sign in · Claude Codex Proxy</title>
|
|
7
|
-
<script src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js" defer></script>
|
|
8
|
-
<link rel="stylesheet" href="/css/style.css">
|
|
9
|
-
</head>
|
|
10
|
-
<body class="bg-space-950 text-gray-300 font-sans antialiased min-h-screen" x-data="app" x-init="init()">
|
|
11
|
-
<main x-cloak x-show="authChecked" class="min-h-screen flex items-center justify-center px-4">
|
|
12
|
-
<div class="w-full max-w-md bg-space-900/70 border border-space-border rounded-2xl p-6 shadow-2xl backdrop-blur-md">
|
|
13
|
-
<div class="flex items-center gap-3 mb-6">
|
|
14
|
-
<div class="w-10 h-10 rounded bg-gradient-to-br from-neon-purple to-blue-600 flex items-center justify-center text-white font-bold">CX</div>
|
|
15
|
-
<div>
|
|
16
|
-
<h1 class="text-xl font-bold text-white">Access Required</h1>
|
|
17
|
-
<p class="text-sm text-gray-500">Enter the server access key to open the management UI.</p>
|
|
18
|
-
</div>
|
|
19
|
-
</div>
|
|
20
|
-
<form @submit.prevent="login" class="space-y-4">
|
|
21
|
-
<label class="form-control w-full">
|
|
22
|
-
<span class="label-text text-gray-400 mb-1">Access Key</span>
|
|
23
|
-
<input type="password" x-model="loginApiKey" class="input input-bordered w-full bg-space-950 border-space-border text-white" placeholder="Enter access key" autocomplete="current-password" autofocus>
|
|
24
|
-
</label>
|
|
25
|
-
<p x-show="loginError" x-text="loginError" class="text-sm text-red-400"></p>
|
|
26
|
-
<button type="submit" class="btn w-full bg-neon-purple hover:bg-purple-600 border-0 text-white">Unlock UI</button>
|
|
27
|
-
</form>
|
|
28
|
-
</div>
|
|
29
|
-
</main>
|
|
30
|
-
<script src="/js/app.js"></script>
|
|
31
|
-
</body>
|
|
32
|
-
</html>
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
<div x-show="showAddModal" x-transition class="fixed inset-0 z-50 flex items-center justify-center p-4" style="display: none;">
|
|
2
|
-
<div class="absolute inset-0 bg-black/70 backdrop-blur-sm" @click="showAddModal = false"></div>
|
|
3
|
-
<div class="relative bg-space-900 border border-space-border rounded-xl shadow-2xl max-w-md w-full p-6">
|
|
4
|
-
<h3 class="font-bold text-lg text-white mb-4">Add New Account</h3>
|
|
5
|
-
|
|
6
|
-
<template x-if="!oauthManualMode">
|
|
7
|
-
<div>
|
|
8
|
-
<p class="text-sm text-gray-400 mb-6">Connect a ChatGPT account to use with the proxy. The account will be used for API calls.</p>
|
|
9
|
-
|
|
10
|
-
<div class="flex flex-col gap-3">
|
|
11
|
-
<button class="btn bg-neon-purple hover:bg-purple-600 border-none text-white btn-sm gap-3 h-11"
|
|
12
|
-
@click="startOAuth()">
|
|
13
|
-
<svg class="w-5 h-5" viewBox="0 0 24 24" fill="currentColor">
|
|
14
|
-
<path d="M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"></path>
|
|
15
|
-
<path d="M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"></path>
|
|
16
|
-
<path d="M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"></path>
|
|
17
|
-
<path d="M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"></path>
|
|
18
|
-
</svg>
|
|
19
|
-
<span>Connect via OAuth</span>
|
|
20
|
-
</button>
|
|
21
|
-
|
|
22
|
-
<div class="text-center">
|
|
23
|
-
<span class="text-xs text-gray-500">or</span>
|
|
24
|
-
</div>
|
|
25
|
-
|
|
26
|
-
<button class="btn btn-outline btn-sm text-gray-400 hover:text-white gap-2"
|
|
27
|
-
@click="startManualOAuth()">
|
|
28
|
-
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
29
|
-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14" />
|
|
30
|
-
</svg>
|
|
31
|
-
<span>Manual Authorization (Headless)</span>
|
|
32
|
-
</button>
|
|
33
|
-
|
|
34
|
-
<div class="text-center">
|
|
35
|
-
<span class="text-xs text-gray-500">or</span>
|
|
36
|
-
</div>
|
|
37
|
-
|
|
38
|
-
<button class="btn btn-outline btn-sm text-gray-400 hover:text-white gap-2"
|
|
39
|
-
@click="importFromCodex()">
|
|
40
|
-
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
41
|
-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12" />
|
|
42
|
-
</svg>
|
|
43
|
-
<span>Import from Codex App</span>
|
|
44
|
-
</button>
|
|
45
|
-
</div>
|
|
46
|
-
|
|
47
|
-
<div class="mt-6 flex justify-end">
|
|
48
|
-
<button class="btn btn-outline btn-sm text-gray-400" @click="showAddModal = false">Cancel</button>
|
|
49
|
-
</div>
|
|
50
|
-
</div>
|
|
51
|
-
</template>
|
|
52
|
-
|
|
53
|
-
<template x-if="oauthManualMode">
|
|
54
|
-
<div>
|
|
55
|
-
<p class="text-sm text-gray-400 mb-4">For headless servers without a browser:</p>
|
|
56
|
-
|
|
57
|
-
<div class="bg-space-800/50 border border-space-border/30 rounded-lg p-3 mb-4">
|
|
58
|
-
<p class="text-xs text-gray-500 mb-2">1. Open this URL on another device:</p>
|
|
59
|
-
<div class="flex items-center gap-2">
|
|
60
|
-
<input type="text" readonly :value="oauthManualUrl"
|
|
61
|
-
class="input flex-1 bg-space-700 border-space-border text-xs font-mono text-gray-300">
|
|
62
|
-
<button class="btn btn-xs btn-ghost text-gray-400" @click="copyToClipboard(oauthManualUrl)">
|
|
63
|
-
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
64
|
-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z" />
|
|
65
|
-
</svg>
|
|
66
|
-
</button>
|
|
67
|
-
</div>
|
|
68
|
-
</div>
|
|
69
|
-
|
|
70
|
-
<div class="mb-4">
|
|
71
|
-
<p class="text-xs text-gray-500 mb-2">2. After authorizing, paste the callback URL or code:</p>
|
|
72
|
-
<input type="text" x-model="oauthManualCode"
|
|
73
|
-
placeholder="http://localhost:1455/auth/callback?code=... or just the code"
|
|
74
|
-
class="input w-full bg-space-800 border-space-border text-white font-mono text-sm">
|
|
75
|
-
</div>
|
|
76
|
-
|
|
77
|
-
<div class="flex justify-end gap-2">
|
|
78
|
-
<button class="btn btn-outline btn-sm text-gray-400" @click="oauthManualMode = false">Back</button>
|
|
79
|
-
<button class="btn bg-neon-purple hover:bg-purple-600 border-none text-white btn-sm"
|
|
80
|
-
@click="submitManualOAuth()" :disabled="!oauthManualCode">
|
|
81
|
-
Add Account
|
|
82
|
-
</button>
|
|
83
|
-
</div>
|
|
84
|
-
</div>
|
|
85
|
-
</template>
|
|
86
|
-
</div>
|
|
87
|
-
</div>
|
|
88
|
-
|
|
89
|
-
<div x-show="showDeleteModal" x-transition class="fixed inset-0 z-50 flex items-center justify-center p-4" style="display: none;">
|
|
90
|
-
<div class="absolute inset-0 bg-black/70 backdrop-blur-sm" @click="showDeleteModal = false"></div>
|
|
91
|
-
<div class="relative bg-space-900 border-2 border-red-500/50 rounded-xl shadow-2xl max-w-md w-full p-6">
|
|
92
|
-
<h3 class="font-bold text-lg text-red-400 flex items-center gap-2 mb-4">
|
|
93
|
-
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
94
|
-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" />
|
|
95
|
-
</svg>
|
|
96
|
-
<span>Delete Account</span>
|
|
97
|
-
</h3>
|
|
98
|
-
<p class="text-gray-300 mb-4">Are you sure you want to delete <strong class="text-white font-mono" x-text="deleteTarget"></strong>?</p>
|
|
99
|
-
<div class="bg-red-500/10 border border-red-500/30 rounded p-3 mb-4">
|
|
100
|
-
<p class="text-sm text-red-300">This action cannot be undone. All configuration will be permanently deleted.</p>
|
|
101
|
-
</div>
|
|
102
|
-
<div class="flex justify-end gap-2">
|
|
103
|
-
<button class="btn btn-outline btn-sm text-gray-400" @click="showDeleteModal = false">Cancel</button>
|
|
104
|
-
<button class="btn bg-red-500 hover:bg-red-600 border-none text-white btn-sm" @click="executeDelete()">
|
|
105
|
-
Delete
|
|
106
|
-
</button>
|
|
107
|
-
</div>
|
|
108
|
-
</div>
|
|
109
|
-
</div>
|
|
110
|
-
|
|
111
|
-
<div x-show="showQuotaModalView" x-transition class="fixed inset-0 z-50 flex items-center justify-center p-4" style="display: none;">
|
|
112
|
-
<div class="absolute inset-0 bg-black/70 backdrop-blur-sm" @click="showQuotaModalView = false"></div>
|
|
113
|
-
<div class="relative bg-space-900 border border-space-border rounded-xl shadow-2xl max-w-lg w-full p-6">
|
|
114
|
-
<h3 class="font-bold text-lg text-white mb-2 flex items-center gap-2">
|
|
115
|
-
<svg class="w-6 h-6 text-neon-cyan" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
116
|
-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z" />
|
|
117
|
-
</svg>
|
|
118
|
-
<span>Quota Distribution</span>
|
|
119
|
-
</h3>
|
|
120
|
-
<p class="text-sm text-gray-500 font-mono mb-4" x-text="selectedAccount?.email"></p>
|
|
121
|
-
|
|
122
|
-
<div class="space-y-3 max-h-[60vh] overflow-y-auto" x-show="getRemainingPercentage(selectedAccount) !== null">
|
|
123
|
-
<div class="p-3 bg-space-800/50 border border-space-border/30 rounded-lg">
|
|
124
|
-
<div class="flex justify-between items-center mb-2">
|
|
125
|
-
<span class="text-sm font-semibold text-gray-200">Usage</span>
|
|
126
|
-
<template x-if="!isQuotaExhausted(selectedAccount)">
|
|
127
|
-
<span class="text-xs font-mono"
|
|
128
|
-
:class="quotaTextClass(selectedAccount)"
|
|
129
|
-
x-text="quotaLabel(selectedAccount) + ' remaining'"></span>
|
|
130
|
-
</template>
|
|
131
|
-
<template x-if="isQuotaExhausted(selectedAccount)">
|
|
132
|
-
<span class="text-[10px] font-bold uppercase text-red-400 bg-red-500/10 px-2 py-0.5 rounded border border-red-500/30">QUOTA EXHAUSTED</span>
|
|
133
|
-
</template>
|
|
134
|
-
</div>
|
|
135
|
-
<div class="w-full bg-gray-700 rounded-full h-3 overflow-hidden">
|
|
136
|
-
<div class="h-full rounded-full transition-all"
|
|
137
|
-
:class="quotaBarClass(selectedAccount)"
|
|
138
|
-
:style="`width: ${getRemainingPercentage(selectedAccount)}%`"></div>
|
|
139
|
-
</div>
|
|
140
|
-
<div class="mt-3 pt-3 border-t border-space-border/30 space-y-1">
|
|
141
|
-
<div class="flex items-center justify-between text-xs">
|
|
142
|
-
<span class="text-gray-500">Reset window</span>
|
|
143
|
-
<span class="font-mono text-gray-300" x-text="quotaResetSummary(selectedAccount) || '-'"></span>
|
|
144
|
-
</div>
|
|
145
|
-
<template x-if="quotaResetAtLabel(selectedAccount)">
|
|
146
|
-
<div class="flex items-center justify-between text-xs">
|
|
147
|
-
<span class="text-gray-500">Resets at</span>
|
|
148
|
-
<span class="font-mono text-gray-300" x-text="quotaResetAtLabel(selectedAccount)"></span>
|
|
149
|
-
</div>
|
|
150
|
-
</template>
|
|
151
|
-
</div>
|
|
152
|
-
</div>
|
|
153
|
-
</div>
|
|
154
|
-
|
|
155
|
-
<div class="mt-6 flex justify-end">
|
|
156
|
-
<button class="btn btn-outline btn-sm text-gray-400" @click="showQuotaModalView = false">Close</button>
|
|
157
|
-
</div>
|
|
158
|
-
</div>
|
|
159
|
-
</div>
|