doescap 1.0.0__py3-none-any.whl

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.
doescap/templates.py ADDED
@@ -0,0 +1,651 @@
1
+ """Modern, self-contained HTML/CSS/JS frontend for DoesCap."""
2
+
3
+ from __future__ import annotations
4
+
5
+
6
+ def render_html_page(title: str = "DoesCap Relay", theme: str = "dark") -> str:
7
+ """Generate the full responsive HTML template for client interactions."""
8
+ bg_color = "#0a0a0c" if theme == "dark" else "#f8f9fa"
9
+ card_bg = "#121316" if theme == "dark" else "#ffffff"
10
+ card_border = "#26282e" if theme == "dark" else "#e2e8f0"
11
+ text_color = "#f3f4f6" if theme == "dark" else "#0f172a"
12
+ subtext_color = "#9ca3af" if theme == "dark" else "#64748b"
13
+ accent_color = "#3b82f6" if theme == "dark" else "#2563eb"
14
+
15
+ return f"""<!doctype html>
16
+ <html lang="en">
17
+ <head>
18
+ <meta charset="utf-8">
19
+ <title>{title}</title>
20
+ <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, viewport-fit=cover">
21
+ <meta name="theme-color" content="{bg_color}">
22
+ <style>
23
+ *, *::before, *::after {{
24
+ box-sizing: border-box;
25
+ margin: 0;
26
+ padding: 0;
27
+ }}
28
+ :root {{
29
+ --bg-color: {bg_color};
30
+ --card-bg: {card_bg};
31
+ --card-border: {card_border};
32
+ --text-color: {text_color};
33
+ --subtext-color: {subtext_color};
34
+ --accent: {accent_color};
35
+ --success: #10b981;
36
+ }}
37
+ html, body {{
38
+ width: 100%;
39
+ min-height: 100vh;
40
+ background-color: var(--bg-color);
41
+ color: var(--text-color);
42
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
43
+ overflow-x: hidden;
44
+ -webkit-font-smoothing: antialiased;
45
+ }}
46
+ .container {{
47
+ display: flex;
48
+ flex-direction: column;
49
+ align-items: center;
50
+ justify-content: center;
51
+ min-height: 100vh;
52
+ padding: 16px;
53
+ width: 100%;
54
+ }}
55
+ .card {{
56
+ width: 100%;
57
+ max-width: 490px;
58
+ background: var(--card-bg);
59
+ border: 1px solid var(--card-border);
60
+ border-radius: 12px;
61
+ padding: 24px;
62
+ box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
63
+ position: relative;
64
+ }}
65
+ .header {{
66
+ display: flex;
67
+ justify-content: space-between;
68
+ align-items: center;
69
+ margin-bottom: 20px;
70
+ padding-bottom: 14px;
71
+ border-bottom: 1px solid var(--card-border);
72
+ }}
73
+ .title-group {{
74
+ display: flex;
75
+ align-items: center;
76
+ gap: 10px;
77
+ }}
78
+ .icon {{
79
+ width: 20px;
80
+ height: 20px;
81
+ fill: none;
82
+ stroke: var(--accent);
83
+ stroke-width: 2;
84
+ stroke-linecap: round;
85
+ stroke-linejoin: round;
86
+ }}
87
+ .title-text {{
88
+ font-size: 15px;
89
+ font-weight: 700;
90
+ letter-spacing: 0.5px;
91
+ }}
92
+ .task-label {{
93
+ font-size: 11px;
94
+ font-weight: 500;
95
+ color: var(--subtext-color);
96
+ margin-top: 2px;
97
+ }}
98
+ .badge {{
99
+ font-size: 11px;
100
+ font-weight: 600;
101
+ padding: 4px 10px;
102
+ border-radius: 9999px;
103
+ display: inline-flex;
104
+ align-items: center;
105
+ gap: 6px;
106
+ background: rgba(156, 163, 175, 0.1);
107
+ color: var(--subtext-color);
108
+ border: 1px solid var(--card-border);
109
+ }}
110
+ .badge.active {{
111
+ background: rgba(59, 130, 246, 0.15);
112
+ color: #60a5fa;
113
+ border-color: rgba(59, 130, 246, 0.3);
114
+ }}
115
+ .badge.solved {{
116
+ background: rgba(16, 185, 129, 0.15);
117
+ color: #34d399;
118
+ border-color: rgba(16, 185, 129, 0.3);
119
+ }}
120
+ .pulse-dot {{
121
+ width: 7px;
122
+ height: 7px;
123
+ border-radius: 50%;
124
+ background: currentColor;
125
+ }}
126
+ .badge.active .pulse-dot {{
127
+ animation: pulse 1.5s cubic-bezier(0.4, 0, 0.6, 1) infinite;
128
+ }}
129
+ @keyframes pulse {{
130
+ 0%, 100% {{ opacity: 1; }}
131
+ 50% {{ opacity: 0.3; }}
132
+ }}
133
+ .stage-wrapper {{
134
+ width: 100%;
135
+ min-height: 200px;
136
+ background: rgba(0, 0, 0, 0.2);
137
+ border: 1px dashed var(--card-border);
138
+ border-radius: 8px;
139
+ display: flex;
140
+ flex-direction: column;
141
+ align-items: center;
142
+ justify-content: center;
143
+ position: relative;
144
+ overflow: hidden;
145
+ margin-bottom: 18px;
146
+ }}
147
+ #f {{
148
+ display: none;
149
+ max-width: 100%;
150
+ height: auto;
151
+ cursor: crosshair;
152
+ user-select: none;
153
+ -webkit-user-drag: none;
154
+ touch-action: none;
155
+ }}
156
+ #direct-container {{
157
+ display: none;
158
+ z-index: 10;
159
+ margin: 16px auto;
160
+ min-height: 80px;
161
+ align-items: center;
162
+ justify-content: center;
163
+ }}
164
+ .loader-box {{
165
+ display: flex;
166
+ flex-direction: column;
167
+ align-items: center;
168
+ gap: 12px;
169
+ color: var(--subtext-color);
170
+ font-size: 13px;
171
+ }}
172
+ .spinner {{
173
+ width: 32px;
174
+ height: 32px;
175
+ border: 3px solid rgba(156, 163, 175, 0.2);
176
+ border-top-color: var(--accent);
177
+ border-radius: 50%;
178
+ animation: spin 0.8s linear infinite;
179
+ }}
180
+ @keyframes spin {{
181
+ to {{ transform: rotate(360deg); }}
182
+ }}
183
+ .tap-effect {{
184
+ position: absolute;
185
+ width: 24px;
186
+ height: 24px;
187
+ border: 2px solid var(--accent);
188
+ border-radius: 50%;
189
+ transform: translate(-50%, -50%) scale(0.5);
190
+ pointer-events: none;
191
+ z-index: 100;
192
+ animation: ripple 0.35s ease-out forwards;
193
+ }}
194
+ @keyframes ripple {{
195
+ to {{
196
+ transform: translate(-50%, -50%) scale(1.6);
197
+ opacity: 0;
198
+ }}
199
+ }}
200
+ .footer-bar {{
201
+ display: flex;
202
+ justify-content: space-between;
203
+ align-items: center;
204
+ background: rgba(0, 0, 0, 0.15);
205
+ border: 1px solid var(--card-border);
206
+ border-radius: 8px;
207
+ padding: 10px 14px;
208
+ font-size: 12px;
209
+ color: var(--subtext-color);
210
+ }}
211
+ .btn {{
212
+ background: var(--card-bg);
213
+ color: var(--text-color);
214
+ border: 1px solid var(--card-border);
215
+ border-radius: 6px;
216
+ padding: 6px 14px;
217
+ font-size: 12px;
218
+ font-weight: 600;
219
+ cursor: pointer;
220
+ transition: all 0.2s ease;
221
+ }}
222
+ .btn:hover {{
223
+ border-color: var(--subtext-color);
224
+ }}
225
+ .btn-primary {{
226
+ background: var(--text-color);
227
+ color: var(--bg-color);
228
+ border-color: var(--text-color);
229
+ }}
230
+ .btn-primary:hover {{
231
+ opacity: 0.9;
232
+ }}
233
+ .hint {{
234
+ margin-top: 14px;
235
+ font-size: 12px;
236
+ color: var(--subtext-color);
237
+ text-align: center;
238
+ line-height: 1.5;
239
+ }}
240
+ #success-screen {{
241
+ display: none;
242
+ flex-direction: column;
243
+ align-items: center;
244
+ text-align: center;
245
+ padding: 16px 8px;
246
+ animation: fadeIn 0.3s ease;
247
+ }}
248
+ @keyframes fadeIn {{
249
+ from {{ opacity: 0; transform: translateY(8px); }}
250
+ to {{ opacity: 1; transform: translateY(0); }}
251
+ }}
252
+ .success-icon-box {{
253
+ width: 52px;
254
+ height: 52px;
255
+ border-radius: 50%;
256
+ background: rgba(16, 185, 129, 0.15);
257
+ border: 2px solid var(--success);
258
+ display: flex;
259
+ align-items: center;
260
+ justify-content: center;
261
+ margin-bottom: 16px;
262
+ }}
263
+ .success-icon-box svg {{
264
+ width: 28px;
265
+ height: 28px;
266
+ stroke: var(--success);
267
+ stroke-width: 2.5;
268
+ fill: none;
269
+ }}
270
+ .success-title {{
271
+ font-size: 18px;
272
+ font-weight: 700;
273
+ color: var(--text-color);
274
+ margin-bottom: 6px;
275
+ }}
276
+ .success-task-name {{
277
+ font-size: 13px;
278
+ color: var(--subtext-color);
279
+ margin-bottom: 14px;
280
+ font-weight: 500;
281
+ }}
282
+ .code-card {{
283
+ width: 100%;
284
+ background: rgba(0, 0, 0, 0.25);
285
+ border: 1px solid var(--card-border);
286
+ border-radius: 8px;
287
+ padding: 14px;
288
+ margin-bottom: 16px;
289
+ text-align: center;
290
+ }}
291
+ .code-title {{
292
+ font-size: 11px;
293
+ color: var(--subtext-color);
294
+ letter-spacing: 1px;
295
+ text-transform: uppercase;
296
+ margin-bottom: 6px;
297
+ }}
298
+ .code-text {{
299
+ font-size: 17px;
300
+ font-weight: 700;
301
+ letter-spacing: 1.5px;
302
+ color: var(--text-color);
303
+ user-select: all;
304
+ cursor: pointer;
305
+ margin-bottom: 10px;
306
+ word-break: break-all;
307
+ }}
308
+ .success-desc {{
309
+ font-size: 12px;
310
+ color: var(--subtext-color);
311
+ line-height: 1.6;
312
+ }}
313
+ @media (max-width: 480px) {{
314
+ .card {{
315
+ padding: 18px 14px;
316
+ }}
317
+ .btn {{
318
+ min-height: 40px;
319
+ }}
320
+ }}
321
+ </style>
322
+ </head>
323
+ <body>
324
+ <div class="container">
325
+ <div class="card">
326
+ <div class="header">
327
+ <div class="title-group">
328
+ <svg class="icon" viewBox="0 0 24 24">
329
+ <path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/>
330
+ </svg>
331
+ <div>
332
+ <div class="title-text">{title}</div>
333
+ <div id="task-label-text" class="task-label" style="display:none;"></div>
334
+ </div>
335
+ </div>
336
+ <div id="status-badge" class="badge">
337
+ <span class="pulse-dot"></span>
338
+ <span id="status-text">INITIALIZING</span>
339
+ </div>
340
+ </div>
341
+
342
+ <div id="main-panel">
343
+ <div id="stage" class="stage-wrapper">
344
+ <div id="loader" class="loader-box">
345
+ <div class="spinner"></div>
346
+ <span>Waiting for captcha widget...</span>
347
+ </div>
348
+ <img id="f" alt="Screencast Stream">
349
+ <div id="direct-container"></div>
350
+ </div>
351
+
352
+ <div class="footer-bar">
353
+ <div>Relay: <strong id="endpoint-label">...</strong></div>
354
+ <button id="copy-btn" class="btn" onclick="copyCurrentUrl()">Copy Link</button>
355
+ </div>
356
+
357
+ <div class="hint">
358
+ Solve the puzzle challenge in this window.<br>
359
+ Verification completes automatically.
360
+ </div>
361
+ </div>
362
+
363
+ <div id="success-screen">
364
+ <div class="success-icon-box">
365
+ <svg viewBox="0 0 24 24">
366
+ <polyline points="20 6 9 17 4 12"></polyline>
367
+ </svg>
368
+ </div>
369
+ <h2 id="success-heading" class="success-title">Verification Complete</h2>
370
+ <div id="claimed-task-name" class="success-task-name" style="display:none;"></div>
371
+
372
+ <div id="promo-code-card" class="code-card" style="display:none;">
373
+ <div class="code-title">Redeemable Code</div>
374
+ <div id="promo-code-value" class="code-text" onclick="copyCode()" title="Click to copy code"></div>
375
+ <button id="copy-code-btn" class="btn btn-primary" onclick="copyCode()">Copy Code</button>
376
+ </div>
377
+
378
+ <p id="success-subtext" class="success-desc">
379
+ Captcha token has been verified and returned to the application.<br>
380
+ You may safely close this tab.
381
+ </p>
382
+ </div>
383
+ </div>
384
+ </div>
385
+
386
+ <script>
387
+ const statusBadge = document.getElementById('status-badge');
388
+ const statusText = document.getElementById('status-text');
389
+ const endpointLabel = document.getElementById('endpoint-label');
390
+ const loader = document.getElementById('loader');
391
+ const imgFrame = document.getElementById('f');
392
+ const directContainer = document.getElementById('direct-container');
393
+ const mainPanel = document.getElementById('main-panel');
394
+ const successScreen = document.getElementById('success-screen');
395
+ const taskLabelEl = document.getElementById('task-label-text');
396
+ const claimedTaskEl = document.getElementById('claimed-task-name');
397
+ const promoCard = document.getElementById('promo-code-card');
398
+ const promoValue = document.getElementById('promo-code-value');
399
+
400
+ endpointLabel.textContent = window.location.host;
401
+
402
+ let directInitialized = false;
403
+ let lastBlobUrl = null;
404
+
405
+ function pullFrame() {{
406
+ fetch('/frame.jpg?' + Date.now())
407
+ .then(res => {{
408
+ if (res.status !== 200) throw 0;
409
+ return res.blob();
410
+ }})
411
+ .then(blob => {{
412
+ const url = URL.createObjectURL(blob);
413
+ imgFrame.src = url;
414
+ if (imgFrame.style.display !== 'block') {{
415
+ imgFrame.style.display = 'block';
416
+ loader.style.display = 'none';
417
+ }}
418
+ if (lastBlobUrl) URL.revokeObjectURL(lastBlobUrl);
419
+ lastBlobUrl = url;
420
+ }})
421
+ .catch(() => {{}});
422
+ }}
423
+
424
+ function calculateCoords(e) {{
425
+ const rect = imgFrame.getBoundingClientRect();
426
+ const scaleX = imgFrame.naturalWidth ? (imgFrame.naturalWidth / rect.width) : 1;
427
+ const scaleY = imgFrame.naturalHeight ? (imgFrame.naturalHeight / rect.height) : 1;
428
+ return {{
429
+ x: (e.clientX - rect.left) * scaleX,
430
+ y: (e.clientY - rect.top) * scaleY
431
+ }};
432
+ }}
433
+
434
+ function showTapMarker(clientX, clientY) {{
435
+ const stage = document.getElementById('stage');
436
+ const r = stage.getBoundingClientRect();
437
+ const dot = document.createElement('div');
438
+ dot.className = 'tap-effect';
439
+ dot.style.left = (clientX - r.left) + 'px';
440
+ dot.style.top = (clientY - r.top) + 'px';
441
+ stage.appendChild(dot);
442
+ setTimeout(() => dot.remove(), 400);
443
+ }}
444
+
445
+ function sendInputEvent(kind, x, y) {{
446
+ fetch('/input', {{
447
+ method: 'POST',
448
+ headers: {{ 'Content-Type': 'application/json' }},
449
+ body: JSON.stringify({{ t: kind, x: x, y: y }})
450
+ }}).catch(() => {{}});
451
+ }}
452
+
453
+ let lastMoveTime = 0;
454
+ imgFrame.addEventListener('mousemove', e => {{
455
+ const now = Date.now();
456
+ if (now - lastMoveTime < 35) return;
457
+ lastMoveTime = now;
458
+ const p = calculateCoords(e);
459
+ sendInputEvent('move', p.x, p.y);
460
+ }});
461
+
462
+ imgFrame.addEventListener('mousedown', e => {{
463
+ e.preventDefault();
464
+ showTapMarker(e.clientX, e.clientY);
465
+ const p = calculateCoords(e);
466
+ sendInputEvent('press', p.x, p.y);
467
+ }});
468
+
469
+ window.addEventListener('mouseup', e => {{
470
+ const p = calculateCoords(e);
471
+ sendInputEvent('release', p.x, p.y);
472
+ }});
473
+
474
+ imgFrame.addEventListener('touchstart', e => {{
475
+ e.preventDefault();
476
+ if (!e.touches.length) return;
477
+ const t = e.touches[0];
478
+ showTapMarker(t.clientX, t.clientY);
479
+ const p = calculateCoords(t);
480
+ sendInputEvent('press', p.x, p.y);
481
+ }}, {{ passive: false }});
482
+
483
+ imgFrame.addEventListener('touchmove', e => {{
484
+ e.preventDefault();
485
+ if (!e.touches.length) return;
486
+ const p = calculateCoords(e.touches[0]);
487
+ sendInputEvent('move', p.x, p.y);
488
+ }}, {{ passive: false }});
489
+
490
+ imgFrame.addEventListener('touchend', e => {{
491
+ e.preventDefault();
492
+ if (!e.changedTouches.length) return;
493
+ const p = calculateCoords(e.changedTouches[0]);
494
+ sendInputEvent('release', p.x, p.y);
495
+ }}, {{ passive: false }});
496
+
497
+ function initDirectSolver(sitekey, rqdata) {{
498
+ if (directInitialized) return;
499
+ directInitialized = true;
500
+
501
+ loader.style.display = 'none';
502
+ imgFrame.style.display = 'none';
503
+ directContainer.style.display = 'flex';
504
+
505
+ window.__onHCaptchaReady = function() {{
506
+ if (!window.hcaptcha || !window.hcaptcha.render) {{
507
+ setTimeout(window.__onHCaptchaReady, 100);
508
+ return;
509
+ }}
510
+ try {{
511
+ const options = {{
512
+ sitekey: sitekey,
513
+ theme: '{theme}',
514
+ callback: function(token) {{
515
+ statusText.textContent = 'VERIFIED';
516
+ statusBadge.className = 'badge solved';
517
+ fetch('/solve', {{
518
+ method: 'POST',
519
+ headers: {{ 'Content-Type': 'application/json' }},
520
+ body: JSON.stringify({{ token: token }})
521
+ }}).catch(() => {{}});
522
+ }},
523
+ 'expired-callback': function() {{
524
+ statusText.textContent = 'EXPIRED';
525
+ statusBadge.className = 'badge';
526
+ }},
527
+ 'error-callback': function(err) {{
528
+ console.error('hCaptcha error:', err);
529
+ }}
530
+ }};
531
+ if (rqdata) options.rqdata = rqdata;
532
+
533
+ const widgetId = hcaptcha.render('direct-container', options);
534
+ if (rqdata && window.hcaptcha.setData) {{
535
+ try {{ window.hcaptcha.setData(widgetId, {{ rqdata: rqdata }}); }} catch(e) {{}}
536
+ }}
537
+ statusText.textContent = 'READY TO SOLVE';
538
+ statusBadge.className = 'badge active';
539
+ }} catch(e) {{
540
+ console.error('Failed to render hCaptcha:', e);
541
+ }}
542
+ }};
543
+
544
+ if (window.hcaptcha && window.hcaptcha.render) {{
545
+ window.__onHCaptchaReady();
546
+ }} else {{
547
+ const script = document.createElement('script');
548
+ script.src = 'https://js.hcaptcha.com/1/api.js?onload=__onHCaptchaReady&render=explicit';
549
+ script.async = true;
550
+ script.defer = true;
551
+ document.head.appendChild(script);
552
+ }}
553
+ }}
554
+
555
+ let screencastInterval = null;
556
+ let isSolved = false;
557
+
558
+ function pollStatus() {{
559
+ fetch('/status')
560
+ .then(r => r.json())
561
+ .then(st => {{
562
+ if (st.task_name && taskLabelEl) {{
563
+ taskLabelEl.textContent = st.task_name;
564
+ taskLabelEl.style.display = 'block';
565
+ }}
566
+
567
+ if (st.mode === 'direct' && st.sitekey) {{
568
+ initDirectSolver(st.sitekey, st.rqdata);
569
+ }} else if (st.mode === 'screencast' && !screencastInterval) {{
570
+ screencastInterval = setInterval(pullFrame, 200);
571
+ pullFrame();
572
+ }}
573
+
574
+ if (st.solved) {{
575
+ if (!isSolved) {{
576
+ isSolved = true;
577
+ statusText.textContent = 'SUCCESS';
578
+ statusBadge.className = 'badge solved';
579
+ mainPanel.style.display = 'none';
580
+ successScreen.style.display = 'flex';
581
+
582
+ if (st.task_name) {{
583
+ claimedTaskEl.textContent = st.task_name;
584
+ claimedTaskEl.style.display = 'block';
585
+ }}
586
+ if (st.promo_code) {{
587
+ promoValue.textContent = st.promo_code;
588
+ promoCard.style.display = 'block';
589
+ }}
590
+ if (st.success_message) {{
591
+ document.getElementById('success-subtext').textContent = st.success_message;
592
+ }}
593
+ }}
594
+ }} else if (st.mode === 'direct' || st.rect) {{
595
+ statusText.textContent = 'ACTIVE';
596
+ statusBadge.className = 'badge active';
597
+ }}
598
+ }})
599
+ .catch(() => {{}});
600
+ }}
601
+
602
+ setInterval(pollStatus, 300);
603
+ pollStatus();
604
+
605
+ function copyCurrentUrl() {{
606
+ const btn = document.getElementById('copy-btn');
607
+ const url = window.location.href;
608
+ copyHelper(url, btn, 'Copied!', 'Copy Link');
609
+ }}
610
+
611
+ function copyCode() {{
612
+ const btn = document.getElementById('copy-code-btn');
613
+ const text = (promoValue ? promoValue.textContent : '').trim();
614
+ copyHelper(text, btn, 'Copied!', 'Copy Code');
615
+ }}
616
+
617
+ function copyHelper(text, btnElement, successText, originalText) {{
618
+ if (!text) return;
619
+ if (navigator.clipboard && window.isSecureContext) {{
620
+ navigator.clipboard.writeText(text).then(showCopied).catch(fallbackCopy);
621
+ }} else {{
622
+ fallbackCopy();
623
+ }}
624
+
625
+ function showCopied() {{
626
+ if (btnElement) {{
627
+ btnElement.textContent = successText;
628
+ setTimeout(() => {{ btnElement.textContent = originalText; }}, 2000);
629
+ }}
630
+ }}
631
+
632
+ function fallbackCopy() {{
633
+ const ta = document.createElement('textarea');
634
+ ta.value = text;
635
+ ta.style.position = 'fixed';
636
+ ta.style.left = '-9999px';
637
+ document.body.appendChild(ta);
638
+ ta.select();
639
+ try {{
640
+ document.execCommand('copy');
641
+ showCopied();
642
+ }} catch(e) {{
643
+ window.prompt('Copy to clipboard:', text);
644
+ }}
645
+ document.body.removeChild(ta);
646
+ }}
647
+ }}
648
+ </script>
649
+ </body>
650
+ </html>
651
+ """