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