@prosopo/client-bundle-example 2.9.4 → 2.10.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.
Files changed (37) hide show
  1. package/CHANGELOG.md +151 -0
  2. package/dist/cjs/index.cjs +49 -0
  3. package/dist/index.js +49 -0
  4. package/package.json +8 -13
  5. package/vite.config.ts +2 -1
  6. package/dist/assets/captcha-BaCo3bEP.js +0 -1
  7. package/dist/assets/captcha-DAWM1slf.css +0 -1
  8. package/dist/assets/dummy.txt +0 -0
  9. package/dist/assets/frictionless-explicit-CtnTw8dK.js +0 -1
  10. package/dist/assets/frictionless-implicit-BH7anfOq.js +0 -1
  11. package/dist/assets/image-explicit-Dm_JoW0N.js +0 -4
  12. package/dist/assets/image-implicit-M0Y7U93R.js +0 -1
  13. package/dist/assets/index-Ck5HfpfQ.js +0 -1
  14. package/dist/assets/invisible-frictionless-explicit-CSPYfcNr.js +0 -4
  15. package/dist/assets/invisible-frictionless-implicit-D0saDt4U.js +0 -1
  16. package/dist/assets/invisible-image-explicit-erOMAo-F.js +0 -4
  17. package/dist/assets/invisible-image-implicit-c0sMfk2s.js +0 -1
  18. package/dist/assets/invisible-pow-explicit-BgMt7lhN.js +0 -4
  19. package/dist/assets/invisible-pow-implicit-CnxS8gw2.js +0 -4
  20. package/dist/assets/pow-explicit-BgDWNJK9.js +0 -4
  21. package/dist/assets/pow-implicit-Ck5HfpfQ.js +0 -1
  22. package/dist/frictionless-explicit.html +0 -875
  23. package/dist/frictionless-implicit.html +0 -874
  24. package/dist/image-explicit.html +0 -877
  25. package/dist/index.html +0 -850
  26. package/dist/invisible-frictionless-explicit.html +0 -877
  27. package/dist/invisible-frictionless-implicit.html +0 -884
  28. package/dist/invisible-image-explicit.html +0 -878
  29. package/dist/invisible-image-implicit.html +0 -884
  30. package/dist/invisible-pow-explicit.html +0 -878
  31. package/dist/invisible-pow-implicit.html +0 -878
  32. package/dist/plugins/explanation-injector.ts +0 -250
  33. package/dist/plugins/form-filler-injector.ts +0 -233
  34. package/dist/plugins/navigation-injector.ts +0 -602
  35. package/dist/plugins/status-log-injector.ts +0 -199
  36. package/dist/pow-explicit.html +0 -877
  37. package/dist/pow-implicit.html +0 -881
@@ -1,878 +0,0 @@
1
- <!doctype html>
2
- <html lang="en">
3
- <head>
4
- <link href="https://cdn.muicss.com/mui-0.10.3/css/mui.min.css" rel="stylesheet" type="text/css"/>
5
- <title>Procaptcha Invisible POW Mode - Implicit Rendering</title>
6
- <!-- Load the Procaptcha script -->
7
- <script type="module" src="http://localhost:9269/procaptcha.bundle.js" async defer></script>
8
-
9
- <style>
10
- .nav-topbar {
11
- background-color: #2196F3;
12
- padding: 0;
13
- margin-bottom: 20px;
14
- transition: all 0.3s ease;
15
- overflow: hidden;
16
- max-height: 500px;
17
- box-shadow: 0 2px 5px rgba(0,0,0,0.2);
18
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
19
- }
20
- .nav-topbar.collapsed {
21
- max-height: 60px;
22
- }
23
- .nav-container {
24
- max-width: 1200px;
25
- margin: 0 auto;
26
- padding: 0 20px;
27
- position: relative;
28
- }
29
- .nav-header {
30
- display: flex;
31
- justify-content: space-between;
32
- align-items: center;
33
- padding: 12px 0;
34
- position: relative;
35
- z-index: 20;
36
- }
37
- .nav-title {
38
- color: white;
39
- font-size: 1.25rem;
40
- font-weight: 600;
41
- margin: 0;
42
- display: flex;
43
- align-items: center;
44
- gap: 8px;
45
- }
46
- .nav-title-text {
47
- margin-right: 8px;
48
- }
49
- .nav-title-hint {
50
- font-size: 0.875rem;
51
- font-weight: normal;
52
- opacity: 0;
53
- transition: opacity 0.3s ease;
54
- color: rgba(255,255,255,0.8);
55
- }
56
- .collapsed .nav-title-hint {
57
- opacity: 0.8;
58
- }
59
- .nav-toggle {
60
- background-color: rgba(255,255,255,0.1);
61
- color: white;
62
- border: none;
63
- padding: 8px 12px;
64
- cursor: pointer;
65
- border-radius: 6px;
66
- z-index: 10;
67
- display: flex;
68
- align-items: center;
69
- justify-content: center;
70
- transition: background-color 0.2s ease;
71
- }
72
- .nav-toggle:hover {
73
- background-color: rgba(255,255,255,0.2);
74
- }
75
- .nav-toggle-icon {
76
- width: 24px;
77
- height: 24px;
78
- display: inline-block;
79
- position: relative;
80
- }
81
- .nav-toggle-icon svg {
82
- position: absolute;
83
- top: 0;
84
- left: 0;
85
- transition: opacity 0.3s ease;
86
- }
87
- .nav-toggle-icon .icon-collapse {
88
- opacity: 1;
89
- }
90
- .nav-toggle-icon .icon-expand {
91
- opacity: 0;
92
- }
93
- .collapsed .nav-toggle-icon .icon-collapse {
94
- opacity: 0;
95
- }
96
- .collapsed .nav-toggle-icon .icon-expand {
97
- opacity: 1;
98
- }
99
- .nav-content {
100
- padding: 0 0 20px 0;
101
- transition: opacity 0.3s ease;
102
- }
103
- .collapsed .nav-content {
104
- opacity: 0;
105
- }
106
- .nav-sections {
107
- display: flex;
108
- flex-wrap: wrap;
109
- gap: 20px;
110
- }
111
- .nav-section {
112
- flex: 1;
113
- min-width: 280px;
114
- }
115
- .nav-section h3 {
116
- color: white;
117
- font-size: 1rem;
118
- font-weight: 600;
119
- margin: 0 0 12px 0;
120
- padding-bottom: 8px;
121
- border-bottom: 1px solid rgba(255,255,255,0.2);
122
- }
123
- .nav-group {
124
- background: rgba(255,255,255,0.1);
125
- border-radius: 8px;
126
- padding: 12px;
127
- margin-bottom: 12px;
128
- }
129
- .nav-group-title {
130
- color: rgba(255,255,255,0.9);
131
- font-size: 0.875rem;
132
- font-weight: 500;
133
- margin: 0 0 8px 0;
134
- text-transform: uppercase;
135
- letter-spacing: 0.5px;
136
- }
137
- .nav-group-links {
138
- list-style: none;
139
- margin: 0;
140
- padding: 0;
141
- }
142
- .nav-group-links li {
143
- margin: 6px 0;
144
- }
145
- .nav-group-links a {
146
- color: white;
147
- text-decoration: none;
148
- font-weight: 500;
149
- padding: 6px 8px;
150
- display: inline-block;
151
- border-radius: 4px;
152
- transition: background-color 0.2s ease;
153
- }
154
- .nav-group-links a:hover {
155
- background-color: rgba(255,255,255,0.2);
156
- }
157
- .nav-group-links .active {
158
- background-color: rgba(255,255,255,0.2);
159
- font-weight: 600;
160
- }
161
- .nav-group-links .disabled {
162
- color: rgba(255,255,255,0.5);
163
- cursor: not-allowed;
164
- opacity: 0.7;
165
- }
166
-
167
- @media (max-width: 768px) {
168
- .nav-container {
169
- padding: 0 16px;
170
- }
171
- .nav-title {
172
- font-size: 1.125rem;
173
- }
174
- .nav-title-hint {
175
- display: none;
176
- }
177
- .nav-sections {
178
- flex-direction: column;
179
- gap: 16px;
180
- }
181
- .nav-section {
182
- min-width: 100%;
183
- }
184
- .nav-section h3 {
185
- font-size: 0.875rem;
186
- }
187
- .nav-group {
188
- padding: 10px;
189
- }
190
- .nav-group-title {
191
- font-size: 0.8125rem;
192
- }
193
- .nav-group-links a {
194
- padding: 8px 10px;
195
- width: 100%;
196
- }
197
- }
198
-
199
- @media (max-width: 480px) {
200
- .nav-topbar {
201
- max-height: 60px;
202
- }
203
- .nav-topbar.collapsed {
204
- max-height: 60px;
205
- }
206
- .nav-title {
207
- font-size: 1rem;
208
- }
209
- .nav-toggle {
210
- padding: 6px 10px;
211
- }
212
- }
213
-
214
- .nav-group-dropdown {
215
- position: relative;
216
- display: inline-block;
217
- }
218
-
219
- .nav-group-dropdown-btn {
220
- background: none;
221
- border: none;
222
- color: white;
223
- font-weight: 500;
224
- padding: 6px 8px;
225
- cursor: pointer;
226
- display: flex;
227
- align-items: center;
228
- gap: 4px;
229
- border-radius: 4px;
230
- transition: background-color 0.2s ease;
231
- }
232
-
233
- .nav-group-dropdown-btn:hover {
234
- background-color: rgba(255,255,255,0.2);
235
- }
236
-
237
- .nav-group-dropdown-btn svg {
238
- width: 16px;
239
- height: 16px;
240
- transition: transform 0.2s ease;
241
- }
242
-
243
- .nav-group-dropdown-btn.open svg {
244
- transform: rotate(180deg);
245
- }
246
-
247
- .nav-group-dropdown-content {
248
- display: none;
249
- position: absolute;
250
- background-color: rgba(33, 150, 243, 0.95);
251
- min-width: 160px;
252
- box-shadow: 0 8px 16px rgba(0,0,0,0.2);
253
- z-index: 1;
254
- border-radius: 4px;
255
- padding: 8px 0;
256
- margin-top: 4px;
257
- }
258
-
259
- .nav-group-dropdown-btn.open + .nav-group-dropdown-content {
260
- display: block;
261
- }
262
-
263
- .nav-group-dropdown-content a {
264
- color: white;
265
- padding: 8px 16px;
266
- text-decoration: none;
267
- display: block;
268
- transition: background-color 0.2s ease;
269
- }
270
-
271
- .nav-group-dropdown-content a:hover {
272
- background-color: rgba(255,255,255,0.2);
273
- }
274
-
275
- .nav-group-dropdown-content a.active {
276
- background-color: rgba(255,255,255,0.2);
277
- font-weight: 600;
278
- }
279
-
280
- @media (max-width: 768px) {
281
- .nav-group-dropdown-content {
282
- position: static;
283
- box-shadow: none;
284
- background-color: rgba(255,255,255,0.1);
285
- margin-top: 8px;
286
- }
287
- }
288
- </style>
289
- <script type="module" crossorigin src="/assets/invisible-pow-implicit-CnxS8gw2.js"></script>
290
- <link rel="modulepreload" crossorigin href="/assets/captcha-BaCo3bEP.js">
291
- <link rel="stylesheet" crossorigin href="/assets/captcha-DAWM1slf.css">
292
-
293
- <style>
294
- .form-filler-button {
295
- position: fixed;
296
- bottom: 20px;
297
- right: 20px;
298
- background-color: #2196F3;
299
- color: white;
300
- border: none;
301
- border-radius: 30px;
302
- padding: 12px 20px;
303
- font-size: 14px;
304
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
305
- cursor: pointer;
306
- box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
307
- z-index: 9999;
308
- display: flex;
309
- align-items: center;
310
- gap: 8px;
311
- transition: all 0.2s ease;
312
- outline: none;
313
- }
314
-
315
- .form-filler-button:hover {
316
- background-color: #1976D2;
317
- box-shadow: 0 6px 12px rgba(0, 0, 0, 0.25);
318
- transform: translateY(-2px);
319
- }
320
-
321
- .form-filler-button:active {
322
- transform: translateY(1px);
323
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
324
- }
325
-
326
- .form-filler-button svg {
327
- width: 18px;
328
- height: 18px;
329
- fill: white;
330
- }
331
-
332
- .form-filler-button span {
333
- font-weight: 500;
334
- }
335
-
336
- @media (max-width: 768px) {
337
- .form-filler-button {
338
- bottom: 15px;
339
- right: 15px;
340
- padding: 10px 15px;
341
- font-size: 12px;
342
- }
343
-
344
- .form-filler-button svg {
345
- width: 14px;
346
- height: 14px;
347
- }
348
- }
349
- </style>
350
-
351
- <style>
352
- .captcha-status {
353
- margin-top: 20px;
354
- padding: 15px;
355
- background-color: #f0f8ff;
356
- border: 2px solid #2196F3;
357
- border-radius: 5px;
358
- font-family: monospace;
359
- font-size: 14px;
360
- }
361
- .status-item {
362
- margin: 5px 0;
363
- padding: 5px;
364
- }
365
- .status-success {
366
- color: #4CAF50;
367
- font-weight: bold;
368
- }
369
- .status-error {
370
- color: #F44336;
371
- font-weight: bold;
372
- }
373
- .status-info {
374
- color: #2196F3;
375
- }
376
- .status-warning {
377
- color: #FF9800;
378
- }
379
- .status-title {
380
- font-weight: bold;
381
- margin-bottom: 10px;
382
- border-bottom: 1px solid #2196F3;
383
- padding-bottom: 5px;
384
- }
385
- .console-output {
386
- margin-top: 20px;
387
- padding: 10px;
388
- background-color: #f5f5f5;
389
- border: 1px solid #ddd;
390
- border-radius: 4px;
391
- font-family: monospace;
392
- white-space: pre-wrap;
393
- max-height: 200px;
394
- overflow-y: auto;
395
- }
396
- </style>
397
-
398
- <script type="module">
399
- // Function to update CAPTCHA status display
400
- function updateCaptchaStatus(message, type = 'info') {
401
- const statusContainer = document.getElementById('captcha-status');
402
- if (!statusContainer) return;
403
-
404
- const timestamp = new Date().toLocaleTimeString();
405
- const statusItem = document.createElement('div');
406
- statusItem.className = `status-item status-${type}`;
407
- statusItem.innerHTML = `[${timestamp}] ${message}`;
408
- statusContainer.appendChild(statusItem);
409
-
410
- // Also log to console
411
- console.log(`CAPTCHA Status: ${message}`);
412
- }
413
-
414
- // Make updateCaptchaStatus available globally
415
- window.updateCaptchaStatus = updateCaptchaStatus;
416
-
417
- // Override the original callbacks with enhanced versions that use status logging
418
- const originalOnCaptchaFailed = window.onCaptchaFailed;
419
- window.onCaptchaFailed = function() {
420
- updateCaptchaStatus('Challenge failed - CAPTCHA verification could not be completed', 'error');
421
- if (originalOnCaptchaFailed) originalOnCaptchaFailed();
422
- };
423
-
424
- const originalOnCaptchaVerified = window.onCaptchaVerified;
425
- window.onCaptchaVerified = function(output) {
426
- updateCaptchaStatus('Challenge passed successfully!', 'success');
427
- updateCaptchaStatus(`Token generated: ${output.substring(0, 15)}...`, 'success');
428
- if (originalOnCaptchaVerified) originalOnCaptchaVerified(output);
429
- };
430
-
431
- const originalOnActionHandler = window.onActionHandler;
432
- window.onActionHandler = function() {
433
- const procaptchaElements = document.getElementsByName('procaptcha-response');
434
-
435
- if (!procaptchaElements.length) {
436
- updateCaptchaStatus('Error: No CAPTCHA response token found', 'error');
437
- alert("Must complete captcha");
438
- return;
439
- }
440
-
441
- updateCaptchaStatus('Form submission initiated with valid CAPTCHA token', 'info');
442
- if (originalOnActionHandler) originalOnActionHandler();
443
- };
444
-
445
- document.addEventListener('DOMContentLoaded', function() {
446
- updateCaptchaStatus('Page loaded - Initializing CAPTCHA system', 'info');
447
-
448
- // Monitor DOM for CAPTCHA initialization
449
- const observer = new MutationObserver((mutations) => {
450
- mutations.forEach((mutation) => {
451
- if (mutation.addedNodes.length) {
452
- for (let i = 0; i < mutation.addedNodes.length; i++) {
453
- const node = mutation.addedNodes[i];
454
- if (node.classList && (node.classList.contains('procaptcha') ||
455
- node.querySelector && node.querySelector('.procaptcha'))) {
456
- updateCaptchaStatus('CAPTCHA DOM elements initialized', 'info');
457
- observer.disconnect();
458
- break;
459
- }
460
- }
461
- }
462
- });
463
- });
464
-
465
- observer.observe(document.body, { childList: true, subtree: true });
466
- });
467
-
468
- // Create a method to show CAPTCHA execution events
469
- document.addEventListener('procaptcha:execute', function(e) {
470
- // Determine captcha type from the page URL
471
- const url = window.location.pathname;
472
- const isFrictionless = url.includes('frictionless');
473
- const isImage = url.includes('image');
474
- const isPow = url.includes('pow');
475
-
476
- let captchaType = 'unknown';
477
- if (isFrictionless) captchaType = 'frictionless';
478
- else if (isImage) captchaType = 'image';
479
- else if (isPow) captchaType = 'pow';
480
-
481
- updateCaptchaStatus(`CAPTCHA execution started: type=${captchaType}`, 'info');
482
- updateCaptchaStatus(`Container: ${e.detail.containerId}, timestamp: ${new Date(e.detail.timestamp).toLocaleTimeString()}`, 'info');
483
- });
484
- </script>
485
- </head>
486
- <body>
487
-
488
- <div id="nav-topbar" class="nav-topbar">
489
- <div class="nav-container">
490
- <div id="nav-header" class="nav-header">
491
- <h1 class="nav-title">
492
- <span class="nav-title-text">Procaptcha Demo Playground</span>
493
- <span class="nav-title-hint">(Click anywhere to see more examples)</span>
494
- </h1>
495
- <button id="nav-toggle" class="nav-toggle" aria-label="Toggle navigation">
496
- <span class="nav-toggle-icon">
497
- <svg class="icon-collapse" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
498
- <polyline points="18 15 12 9 6 15"></polyline>
499
- </svg>
500
- <svg class="icon-expand" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
501
- <polyline points="6 9 12 15 18 9"></polyline>
502
- </svg>
503
- </span>
504
- </button>
505
- </div>
506
- <div class="nav-content">
507
- <div class="nav-sections">
508
-
509
- <div class="nav-section">
510
- <h3>Standard Captchas</h3>
511
- <div class="nav-row">
512
-
513
- <div class="nav-group">
514
- <div class="nav-group-title">Image</div>
515
- <div class="nav-group-links">
516
- <a href="index.html">Implicit</a>
517
- <a href="image-explicit.html">Explicit</a>
518
- </div>
519
- </div>
520
-
521
-
522
- <div class="nav-group">
523
- <div class="nav-group-title">Pow</div>
524
- <div class="nav-group-links">
525
- <a href="pow-implicit.html">Implicit</a>
526
- <a href="pow-explicit.html">Explicit</a>
527
- </div>
528
- </div>
529
-
530
-
531
- <div class="nav-group">
532
- <div class="nav-group-title">Frictionless</div>
533
- <div class="nav-group-links">
534
- <a href="frictionless-implicit.html">Implicit</a>
535
- <a href="frictionless-explicit.html">Explicit</a>
536
- </div>
537
- </div>
538
-
539
- </div>
540
- </div>
541
-
542
-
543
- <div class="nav-section">
544
- <h3>Invisible Captchas</h3>
545
- <div class="nav-row">
546
-
547
- <div class="nav-group">
548
- <div class="nav-group-title">Image</div>
549
- <div class="nav-group-links">
550
- <a href="invisible-image-implicit.html">Implicit</a>
551
- <a href="invisible-image-explicit.html">Explicit</a>
552
- </div>
553
- </div>
554
-
555
-
556
- <div class="nav-group">
557
- <div class="nav-group-title">Pow</div>
558
- <div class="nav-group-links">
559
- <a href="invisible-pow-implicit.html" class="active">Implicit</a>
560
- <a href="invisible-pow-explicit.html">Explicit</a>
561
- </div>
562
- </div>
563
-
564
-
565
- <div class="nav-group">
566
- <div class="nav-group-title">Frictionless</div>
567
- <div class="nav-group-links">
568
- <a href="invisible-frictionless-implicit.html">Implicit</a>
569
- <a href="invisible-frictionless-explicit.html">Explicit</a>
570
- </div>
571
- </div>
572
-
573
- </div>
574
- </div>
575
-
576
- </div>
577
- </div>
578
- </div>
579
- </div>
580
-
581
- <div class="mui-container">
582
- <h1>Invisible Proof of Work CAPTCHA - Implicit Rendering</h1>
583
- <p>This example demonstrates how to use Procaptcha in invisible Proof of Work mode with implicit rendering directly on a button.</p>
584
-
585
- <!-- CAPTCHA Status Display will be injected by the status-log-injector plugin -->
586
-
587
- <form id="demo-form" action="javascript:void(0);" method="POST" class="mui-form">
588
- <h2>Example Form</h2>
589
- <div class="mui-textfield mui-textfield--float-label">
590
- <label for="name">Name</label>
591
- <input type="text" id="name" name="name" required />
592
- </div>
593
-
594
- <div class="mui-textfield mui-textfield--float-label">
595
- <label for="email">Email</label>
596
- <input type="email" id="email" name="email" required />
597
- </div>
598
-
599
- <!-- Submit button with Procaptcha attributes -->
600
- <button
601
- class="mui-btn mui-btn--raised procaptcha"
602
- data-sitekey="undefined"
603
- data-callback="onSubmit"
604
- data-captcha-type="pow"
605
- data-size="invisible">
606
- Submit
607
- </button>
608
- </form>
609
- <!-- CAPTCHA Status Display -->
610
- <div id="captcha-status" class="captcha-status">
611
- <div class="status-title">CAPTCHA Status Log</div>
612
- </div>
613
-
614
- <!-- Console output display area -->
615
- <div id="console-output" class="console-output" style="display: none;"></div>
616
-
617
-
618
- <div id="result" class="info-box" style="display: none;"></div>
619
-
620
- <!-- Console output display area -->
621
- <div id="console-output" class="console-output" style="display: none;"></div>
622
-
623
- <!-- Explanation will be injected by the explanation-injector plugin -->
624
- </div>
625
-
626
- <script>
627
- document.addEventListener('DOMContentLoaded', function() {
628
- const toggleBtn = document.getElementById('nav-toggle');
629
- const navBar = document.getElementById('nav-topbar');
630
- const navHeader = document.getElementById('nav-header');
631
- const isMobile = window.innerWidth <= 768;
632
-
633
- // Check if navigation was previously collapsed
634
- const navCollapsed = localStorage.getItem('navCollapsed') === 'true';
635
- if (navCollapsed) {
636
- navBar.classList.add('collapsed');
637
- }
638
-
639
- // Function to expand the navigation
640
- function expandNav() {
641
- if (navBar.classList.contains('collapsed')) {
642
- navBar.classList.remove('collapsed');
643
- localStorage.setItem('navCollapsed', 'false');
644
- }
645
- }
646
-
647
- // Function to collapse the navigation
648
- function collapseNav() {
649
- if (!navBar.classList.contains('collapsed')) {
650
- navBar.classList.add('collapsed');
651
- localStorage.setItem('navCollapsed', 'true');
652
- }
653
- }
654
-
655
- // Function to toggle the navigation
656
- function toggleNav() {
657
- navBar.classList.toggle('collapsed');
658
- localStorage.setItem('navCollapsed', navBar.classList.contains('collapsed'));
659
- }
660
-
661
- // Toggle on button click
662
- toggleBtn.addEventListener('click', function(e) {
663
- e.stopPropagation();
664
- toggleNav();
665
- });
666
-
667
- // Expand on toggle button hover when collapsed (desktop only)
668
- if (!isMobile) {
669
- toggleBtn.addEventListener('mouseenter', function() {
670
- if (navBar.classList.contains('collapsed')) {
671
- expandNav();
672
- }
673
- });
674
- }
675
-
676
- // Toggle on header click
677
- navHeader.addEventListener('click', function(e) {
678
- if (e.target.tagName === 'A') {
679
- return;
680
- }
681
- toggleNav();
682
- });
683
-
684
- // Make the header appear clickable with cursor style
685
- navHeader.style.cursor = 'pointer';
686
-
687
- // Handle window resize
688
- window.addEventListener('resize', function() {
689
- const newIsMobile = window.innerWidth <= 768;
690
- if (newIsMobile !== isMobile) {
691
- if (newIsMobile) {
692
- // On mobile, collapse the nav by default
693
- collapseNav();
694
- } else {
695
- // On desktop, expand the nav by default
696
- expandNav();
697
- }
698
- }
699
- });
700
-
701
- // Handle dropdown toggles
702
- document.querySelectorAll('.nav-group-dropdown-btn').forEach(button => {
703
- button.addEventListener('click', function(e) {
704
- e.stopPropagation();
705
- this.classList.toggle('open');
706
- });
707
- });
708
-
709
- // Close dropdowns when clicking outside
710
- document.addEventListener('click', function(e) {
711
- if (!e.target.closest('.nav-group-dropdown')) {
712
- document.querySelectorAll('.nav-group-dropdown-btn').forEach(button => {
713
- button.classList.remove('open');
714
- });
715
- }
716
- });
717
- });
718
- </script>
719
-
720
-
721
- <button id="form-filler-button" class="form-filler-button" title="Fill all form fields with default values">
722
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
723
- <path d="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z"/>
724
- </svg>
725
- <span>Fill Form</span>
726
- </button>
727
-
728
- <script>
729
- document.addEventListener('DOMContentLoaded', function() {
730
- // Create a function to fill the form with sensible default values
731
- function fillFormWithDefaults() {
732
- // Get all input elements
733
- const inputs = document.querySelectorAll('input, select, textarea');
734
-
735
- // Record which elements were filled for status feedback
736
- const filledElements = [];
737
-
738
- // Process each input
739
- inputs.forEach(input => {
740
- let filled = true;
741
-
742
- // Skip hidden inputs and those with existing values
743
- if (input.type === 'hidden' || (input.value && input.value.trim() !== '')) {
744
- filled = false;
745
- }
746
- // Handle different input types
747
- else if (input.type === 'text') {
748
- if (input.id.toLowerCase().includes('name') || input.name.toLowerCase().includes('name')) {
749
- input.value = 'John Doe';
750
- } else {
751
- input.value = 'Default Text';
752
- }
753
- }
754
- else if (input.type === 'email') {
755
- input.value = 'test@example.com';
756
- }
757
- else if (input.type === 'password') {
758
- input.value = 'Password123!';
759
- }
760
- else if (input.type === 'tel') {
761
- input.value = '+1234567890';
762
- }
763
- else if (input.type === 'number') {
764
- input.value = '42';
765
- }
766
- else if (input.type === 'url') {
767
- input.value = 'https://example.com';
768
- }
769
- else if (input.type === 'date') {
770
- const today = new Date();
771
- const yyyy = today.getFullYear();
772
- const mm = String(today.getMonth() + 1).padStart(2, '0');
773
- const dd = String(today.getDate()).padStart(2, '0');
774
- input.value = `${yyyy}-${mm}-${dd}`;
775
- }
776
- else if (input.type === 'time') {
777
- input.value = '12:00';
778
- }
779
- else if (input.type === 'checkbox' || input.type === 'radio') {
780
- input.checked = true;
781
- }
782
- else if (input.tagName === 'SELECT') {
783
- if (input.options.length > 0) {
784
- input.selectedIndex = 1 >= input.options.length ? 0 : 1; // Select second option if available, first otherwise
785
- }
786
- }
787
- else if (input.tagName === 'TEXTAREA') {
788
- input.value = 'This is a sample text for the textarea field.';
789
- }
790
- else {
791
- // For any other input types
792
- input.value = 'Default Value';
793
- }
794
-
795
- // Add to filled elements if we actually filled it
796
- if (filled) {
797
- filledElements.push(input);
798
-
799
- // Dispatch input event to trigger any listeners
800
- const event = new Event('input', { bubbles: true });
801
- input.dispatchEvent(event);
802
-
803
- // For select elements, also dispatch change event
804
- if (input.tagName === 'SELECT') {
805
- const changeEvent = new Event('change', { bubbles: true });
806
- input.dispatchEvent(changeEvent);
807
- }
808
- }
809
- });
810
-
811
- // Show a notification about what was filled
812
- if (filledElements.length > 0) {
813
- // If an updateCaptchaStatus function exists (from our other demos), use it
814
- if (typeof window.updateCaptchaStatus === 'function') {
815
- window.updateCaptchaStatus(`Filled ${filledElements.length} form fields with default values`, 'info');
816
- } else {
817
- console.log(`Filled ${filledElements.length} form fields with default values`);
818
- }
819
-
820
- // Highlight the filled fields briefly
821
- filledElements.forEach(el => {
822
- const originalBackground = el.style.backgroundColor;
823
- const originalTransition = el.style.transition;
824
-
825
- el.style.transition = 'background-color 1.5s ease';
826
- el.style.backgroundColor = '#e3f2fd';
827
-
828
- setTimeout(() => {
829
- el.style.backgroundColor = originalBackground;
830
- setTimeout(() => {
831
- el.style.transition = originalTransition;
832
- }, 1500);
833
- }, 500);
834
- });
835
- }
836
- }
837
-
838
- // Add the click event listener to the form filler button
839
- const formFillerButton = document.getElementById('form-filler-button');
840
- if (formFillerButton) {
841
- formFillerButton.addEventListener('click', fillFormWithDefaults);
842
- }
843
- });
844
- </script>
845
-
846
- <div class="explanation">
847
- <h2>How Invisible Proof of Work CAPTCHA Works (Implicit Rendering)</h2>
848
-
849
- <h3>Implementation Details</h3>
850
- <p>This example demonstrates how to use Procaptcha in Proof of Work mode with implicit rendering:</p>
851
- <ol>
852
- <li>Import the Procaptcha script</li>
853
- <li>Add a div with the procaptcha class</li>
854
- <li>Set data-* attributes to configure the CAPTCHA</li>
855
- <li>Handle the verification result in the callback function</li>
856
- </ol>
857
-
858
- <h3>Key Code Example</h3>
859
- <pre>&lt;div
860
- class=&quot;procaptcha&quot;
861
- data-theme=&quot;light&quot;
862
- data-sitekey=&quot;%PROSOPO_SITE_KEY_POW%&quot;
863
- data-failed-callback=&quot;onCaptchaFailed&quot;
864
- data-callback=&quot;onCaptchaVerified&quot;
865
- data-captcha-type=&quot;pow&quot;
866
- data-size=&quot;invisible&quot;
867
- &gt;&lt;/div&gt;</pre>
868
-
869
- <h3>Execution Flow</h3>
870
- <ol>
871
- <li>On page load, Procaptcha scans for elements with the procaptcha class</li>
872
- <li>The Proof of Work computation happens in the browser</li>
873
- <li>When the computation is complete, the callback function is called</li>
874
- <li>On successful verification, the form can be submitted with the token</li>
875
- </ol>
876
- </div>
877
- </body>
878
- </html>