Akademics commited on
Commit
21fe01f
·
verified ·
1 Parent(s): d202821

Update and make it interactive, so I could log in with my API keys - Initial Deployment

Browse files
Files changed (3) hide show
  1. README.md +7 -5
  2. index.html +338 -19
  3. prompts.txt +1 -0
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: Api Key Authenticator
3
- emoji: 🏃
4
- colorFrom: purple
5
- colorTo: green
6
  sdk: static
7
  pinned: false
 
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: api-key-authenticator
3
+ emoji: 🐳
4
+ colorFrom: green
5
+ colorTo: pink
6
  sdk: static
7
  pinned: false
8
+ tags:
9
+ - deepsite
10
  ---
11
 
12
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
index.html CHANGED
@@ -1,19 +1,338 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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>API Key Login</title>
7
+ <script src="https://cdn.tailwindcss.com"></script>
8
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
9
+ <style>
10
+ .gradient-bg {
11
+ background: linear-gradient(135deg, #6e8efb, #a777e3);
12
+ }
13
+ .input-focus:focus {
14
+ box-shadow: 0 0 0 3px rgba(110, 142, 251, 0.3);
15
+ border-color: #6e8efb;
16
+ }
17
+ .switch-btn {
18
+ transition: all 0.3s ease;
19
+ }
20
+ .switch-btn.active {
21
+ background-color: #6e8efb;
22
+ color: white;
23
+ }
24
+ .api-key-masked {
25
+ letter-spacing: 2px;
26
+ filter: blur(4px);
27
+ transition: filter 0.3s ease;
28
+ }
29
+ .api-key-masked:hover {
30
+ filter: blur(0);
31
+ }
32
+ </style>
33
+ </head>
34
+ <body class="min-h-screen gradient-bg flex items-center justify-center p-4">
35
+ <div class="w-full max-w-md mx-auto">
36
+ <div class="bg-white rounded-2xl shadow-2xl overflow-hidden transition-all duration-300 transform hover:scale-[1.01]">
37
+ <!-- Header -->
38
+ <div class="bg-gradient-to-r from-indigo-500 to-purple-600 p-6 text-center">
39
+ <div class="flex justify-center mb-4">
40
+ <i class="fas fa-key text-white text-4xl"></i>
41
+ <i class="fas fa-cloud text-white text-4xl ml-2"></i>
42
+ </div>
43
+ <h1 class="text-2xl font-bold text-white">API Key Authentication</h1>
44
+ <p class="text-indigo-200 mt-1">Secure access to your cloud services</p>
45
+ </div>
46
+
47
+ <!-- Tabs -->
48
+ <div class="flex border-b">
49
+ <button id="login-tab" class="switch-btn active flex-1 py-3 font-medium text-gray-700 border-b-2 border-indigo-500">
50
+ <i class="fas fa-sign-in-alt mr-2"></i>Login
51
+ </button>
52
+ <button id="register-tab" class="switch-btn flex-1 py-3 font-medium text-gray-500 border-b-2 border-transparent">
53
+ <i class="fas fa-user-plus mr-2"></i>Register
54
+ </button>
55
+ </div>
56
+
57
+ <!-- Login Form -->
58
+ <div id="login-form" class="p-6 space-y-4">
59
+ <div>
60
+ <label for="api-key" class="block text-gray-700 mb-1 font-medium"><i class="fas fa-key mr-2"></i>API Key</label>
61
+ <div class="relative">
62
+ <input type="password" id="api-key" class="w-full px-4 py-2 border rounded-lg input-focus focus:outline-none" placeholder="sk-...">
63
+ <button class="absolute right-2 top-2 text-gray-500 hover:text-indigo-600" id="toggle-visibility">
64
+ <i class="fas fa-eye-slash"></i>
65
+ </button>
66
+ </div>
67
+ </div>
68
+
69
+ <div>
70
+ <label for="secret-key" class="block text-gray-700 mb-1 font-medium"><i class="fas fa-lock mr-2"></i>Secret Key (Optional)</label>
71
+ <input type="password" id="secret-key" class="w-full px-4 py-2 border rounded-lg input-focus focus:outline-none" placeholder="••••••••">
72
+ </div>
73
+
74
+ <div class="flex items-center">
75
+ <input type="checkbox" id="remember-me" class="rounded text-indigo-600 focus:ring-indigo-500">
76
+ <label for="remember-me" class="ml-2 text-gray-700">Remember my keys</label>
77
+ </div>
78
+
79
+ <button id="login-btn" class="w-full bg-indigo-600 text-white py-2 px-4 rounded-lg hover:bg-indigo-700 transition duration-200 flex items-center justify-center">
80
+ <i class="fas fa-rocket mr-2"></i> Connect to API
81
+ </button>
82
+
83
+ <div class="text-center text-sm text-gray-500 mt-4">
84
+ <p>Need help? <a href="#" class="text-indigo-600 hover:underline">Contact support</a></p>
85
+ </div>
86
+ </div>
87
+
88
+ <!-- Register Form (Hidden by default) -->
89
+ <div id="register-form" class="p-6 space-y-4 hidden">
90
+ <div>
91
+ <label for="email" class="block text-gray-700 mb-1 font-medium"><i class="fas fa-envelope mr-2"></i>Email</label>
92
+ <input type="email" id="email" class="w-full px-4 py-2 border rounded-lg input-focus focus:outline-none" placeholder="your@email.com">
93
+ </div>
94
+
95
+ <div>
96
+ <label for="org-name" class="block text-gray-700 mb-1 font-medium"><i class="fas fa-building mr-2"></i>Organization</label>
97
+ <input type="text" id="org-name" class="w-full px-4 py-2 border rounded-lg input-focus focus:outline-none" placeholder="Your company">
98
+ </div>
99
+
100
+ <div>
101
+ <label for="use-case" class="block text-gray-700 mb-1 font-medium"><i class="fas fa-project-diagram mr-2"></i>Use Case</label>
102
+ <select id="use-case" class="w-full px-4 py-2 border rounded-lg input-focus focus:outline-none">
103
+ <option value="">Select an option</option>
104
+ <option value="development">Development</option>
105
+ <option value="production">Production</option>
106
+ <option value="testing">Testing</option>
107
+ <option value="research">Research</option>
108
+ </select>
109
+ </div>
110
+
111
+ <div class="text-xs text-gray-500">
112
+ <p>By registering, you agree to our <a href="#" class="text-indigo-600 hover:underline">Terms of Service</a> and acknowledge our <a href="#" class="text-indigo-600 hover:underline">Privacy Policy</a>.</p>
113
+ </div>
114
+
115
+ <button id="register-btn" class="w-full bg-purple-600 text-white py-2 px-4 rounded-lg hover:bg-purple-700 transition duration-200 flex items-center justify-center">
116
+ <i class="fas fa-key mr-2"></i> Request API Keys
117
+ </button>
118
+
119
+ <div class="text-center text-sm text-gray-500 mt-2">
120
+ <p>Already have keys? <a href="#" id="switch-to-login" class="text-indigo-600 hover:underline">Sign in</a></p>
121
+ </div>
122
+ </div>
123
+ </div>
124
+
125
+ <!-- API Status Indicator (Hidden by default) -->
126
+ <div id="status-card" class="hidden mt-6 bg-white rounded-xl shadow-lg p-4">
127
+ <div class="flex items-center">
128
+ <div class="mr-3">
129
+ <div id="status-indicator" class="w-4 h-4 rounded-full bg-gray-400 animate-pulse"></div>
130
+ </div>
131
+ <div class="flex-1">
132
+ <h3 id="status-title" class="text-gray-800 font-medium">Connecting to API...</h3>
133
+ <p id="status-message" class="text-gray-600 text-sm">Authenticating your keys</p>
134
+ </div>
135
+ <button id="edit-keys" class="text-indigo-600 hover:text-indigo-800 text-sm font-medium">
136
+ <i class="fas fa-edit mr-1"></i>Edit
137
+ </button>
138
+ </div>
139
+
140
+ <div id="credentials-display" class="mt-4 space-y-2 hidden">
141
+ <div class="flex justify-between items-center bg-gray-50 p-2 rounded">
142
+ <span class="text-gray-700 text-sm">API Key:</span>
143
+ <span id="display-api-key" class="api-key-masked font-mono text-sm bg-gray-100 px-2 py-1 rounded cursor-pointer" title="Click to show">sk-••••••••</span>
144
+ </div>
145
+ <div class="flex justify-between items-center bg-gray-50 p-2 rounded">
146
+ <span class="text-gray-700 text-sm">Secret Key:</span>
147
+ <span id="display-secret-key" class="api-key-masked font-mono text-sm bg-gray-100 px-2 py-1 rounded cursor-pointer" title="Click to show">••••••••</span>
148
+ </div>
149
+ <div class="flex justify-between items-center p-2">
150
+ <span class="text-gray-700 text-sm">Connection:</span>
151
+ <span id="connection-status" class="text-sm px-2 py-1 rounded">
152
+ <span class="text-gray-400"><i class="fas fa-circle-notch fa-spin mr-1"></i>Verifying</span>
153
+ </span>
154
+ </div>
155
+ </div>
156
+ </div>
157
+ </div>
158
+
159
+ <script>
160
+ // Tab switching
161
+ document.getElementById('login-tab').addEventListener('click', function() {
162
+ document.getElementById('login-tab').classList.add('active', 'border-indigo-500', 'text-gray-700');
163
+ document.getElementById('login-tab').classList.remove('border-transparent', 'text-gray-500');
164
+ document.getElementById('register-tab').classList.remove('active', 'border-indigo-500', 'text-gray-700');
165
+ document.getElementById('register-tab').classList.add('border-transparent', 'text-gray-500');
166
+ document.getElementById('login-form').classList.remove('hidden');
167
+ document.getElementById('register-form').classList.add('hidden');
168
+ });
169
+
170
+ document.getElementById('register-tab').addEventListener('click', function() {
171
+ document.getElementById('register-tab').classList.add('active', 'border-indigo-500', 'text-gray-700');
172
+ document.getElementById('register-tab').classList.remove('border-transparent', 'text-gray-500');
173
+ document.getElementById('login-tab').classList.remove('active', 'border-indigo-500', 'text-gray-700');
174
+ document.getElementById('login-tab').classList.add('border-transparent', 'text-gray-500');
175
+ document.getElementById('register-form').classList.remove('hidden');
176
+ document.getElementById('login-form').classList.add('hidden');
177
+ });
178
+
179
+ document.getElementById('switch-to-login').addEventListener('click', function(e) {
180
+ e.preventDefault();
181
+ document.getElementById('login-tab').click();
182
+ });
183
+
184
+ // Toggle password visibility
185
+ const toggleVisibilityBtn = document.getElementById('toggle-visibility');
186
+ const apiKeyInput = document.getElementById('api-key');
187
+
188
+ toggleVisibilityBtn.addEventListener('click', function() {
189
+ if (apiKeyInput.type === 'password') {
190
+ apiKeyInput.type = 'text';
191
+ toggleVisibilityBtn.innerHTML = '<i class="fas fa-eye"></i>';
192
+ } else {
193
+ apiKeyInput.type = 'password';
194
+ toggleVisibilityBtn.innerHTML = '<i class="fas fa-eye-slash"></i>';
195
+ }
196
+ });
197
+
198
+ // Login functionality
199
+ document.getElementById('login-btn').addEventListener('click', function() {
200
+ const apiKey = document.getElementById('api-key').value.trim();
201
+ const secretKey = document.getElementById('secret-key').value.trim();
202
+ const rememberMe = document.getElementById('remember-me').checked;
203
+
204
+ if (!apiKey) {
205
+ alert('Please enter your API Key');
206
+ return;
207
+ }
208
+
209
+ // Show loading state
210
+ const loginBtn = document.getElementById('login-btn');
211
+ loginBtn.innerHTML = '<i class="fas fa-spinner fa-spin mr-2"></i> Connecting...';
212
+ loginBtn.disabled = true;
213
+
214
+ // Simulate API connection with timeout
215
+ setTimeout(function() {
216
+ // Hide login form and show status card
217
+ document.getElementById('login-form').classList.add('hidden');
218
+ document.getElementById('status-card').classList.remove('hidden');
219
+ document.getElementById('credentials-display').classList.remove('hidden');
220
+
221
+ // Update status UI
222
+ const statusIndicator = document.getElementById('status-indicator');
223
+ const statusTitle = document.getElementById('status-title');
224
+ const statusMessage = document.getElementById('status-message');
225
+ const connectionStatus = document.getElementById('connection-status');
226
+
227
+ statusIndicator.classList.remove('bg-gray-400', 'bg-red-500', 'bg-green-500');
228
+ statusIndicator.classList.add('bg-green-500');
229
+ statusTitle.textContent = 'Connected to API';
230
+ statusMessage.textContent = 'Your credentials are valid';
231
+ connectionStatus.innerHTML = '<span class="text-green-600"><i class="fas fa-check-circle mr-1"></i>Verified</span>';
232
+
233
+ // Display the keys (masked)
234
+ document.getElementById('display-api-key').textContent = maskAPIKey(apiKey);
235
+ if (secretKey) {
236
+ document.getElementById('display-secret-key').textContent = '••••••••';
237
+ } else {
238
+ document.getElementById('display-secret-key').textContent = 'Not provided';
239
+ }
240
+
241
+ // Remember keys if checked
242
+ if (rememberMe) {
243
+ localStorage.setItem('apiKey', apiKey);
244
+ if (secretKey) {
245
+ localStorage.setItem('secretKey', secretKey);
246
+ }
247
+ }
248
+
249
+ // Reset login button
250
+ loginBtn.innerHTML = '<i class="fas fa-rocket mr-2"></i> Connect to API';
251
+ loginBtn.disabled = false;
252
+ }, 2000);
253
+ });
254
+
255
+ // Register functionality (simulated)
256
+ document.getElementById('register-btn').addEventListener('click', function() {
257
+ const email = document.getElementById('email').value.trim();
258
+ const orgName = document.getElementById('org-name').value.trim();
259
+ const useCase = document.getElementById('use-case').value;
260
+
261
+ if (!email || !orgName || !useCase) {
262
+ alert('Please fill all required fields');
263
+ return;
264
+ }
265
+
266
+ const registerBtn = document.getElementById('register-btn');
267
+ registerBtn.innerHTML = '<i class="fas fa-spinner fa-spin mr-2"></i> Processing...';
268
+ registerBtn.disabled = true;
269
+
270
+ setTimeout(function() {
271
+ alert('Your API key request has been submitted. Check your email for further instructions.');
272
+ registerBtn.innerHTML = '<i class="fas fa-key mr-2"></i> Request API Keys';
273
+ registerBtn.disabled = false;
274
+
275
+ // Clear form
276
+ document.getElementById('email').value = '';
277
+ document.getElementById('org-name').value = '';
278
+ document.getElementById('use-case').value = '';
279
+ }, 2000);
280
+ });
281
+
282
+ // Edit keys button
283
+ document.getElementById('edit-keys').addEventListener('click', function() {
284
+ document.getElementById('status-card').classList.add('hidden');
285
+ document.getElementById('login-form').classList.remove('hidden');
286
+ });
287
+
288
+ // Mask API key for display
289
+ function maskAPIKey(key) {
290
+ if (key.length < 8) return 'sk-••••••••';
291
+ const visible = key.substring(0, 6);
292
+ const masked = key.substring(6).replace(/./g, '•');
293
+ return visible + masked;
294
+ }
295
+
296
+ // Toggle between masked/unmasked API key display
297
+ document.getElementById('display-api-key').addEventListener('click', function(e) {
298
+ const elem = e.target;
299
+ if (elem.classList.contains('api-key-masked')) {
300
+ elem.classList.remove('api-key-masked');
301
+ elem.textContent = localStorage.getItem('apiKey') || document.getElementById('api-key').value.trim();
302
+ } else {
303
+ elem.classList.add('api-key-masked');
304
+ elem.textContent = maskAPIKey(localStorage.getItem('api-key') || document.getElementById('api-key').value.trim());
305
+ }
306
+ });
307
+
308
+ // Toggle between masked/unmasked secret key display
309
+ document.getElementById('display-secret-key').addEventListener('click', function(e) {
310
+ const elem = e.target;
311
+ if (elem.textContent !== 'Not provided') {
312
+ if (elem.classList.contains('api-key-masked')) {
313
+ elem.classList.remove('api-key-masked');
314
+ elem.textContent = localStorage.getItem('secretKey') || document.getElementById('secret-key').value.trim();
315
+ } else {
316
+ elem.classList.add('api-key-masked');
317
+ elem.textContent = '••••••••';
318
+ }
319
+ }
320
+ });
321
+
322
+ // Check for saved keys
323
+ window.addEventListener('DOMContentLoaded', function() {
324
+ const savedApiKey = localStorage.getItem('apiKey');
325
+ const savedSecretKey = localStorage.getItem('secretKey');
326
+
327
+ if (savedApiKey) {
328
+ document.getElementById('api-key').value = savedApiKey;
329
+ document.getElementById('remember-me').checked = true;
330
+ }
331
+
332
+ if (savedSecretKey) {
333
+ document.getElementById('secret-key').value = savedSecretKey;
334
+ }
335
+ });
336
+ </script>
337
+ <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=Akademics/api-key-authenticator" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
338
+ </html>
prompts.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ Update and make it interactive, so I could log in with my API keys