@prosopo/client-bundle-example 2.11.2 → 2.11.4

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 (52) hide show
  1. package/.turbo/turbo-build$colon$cjs.log +4 -7
  2. package/.turbo/turbo-build$colon$tsc.log +11 -14
  3. package/.turbo/turbo-build.log +4 -10
  4. package/CHANGELOG.md +32 -0
  5. package/LICENSE +201 -0
  6. package/README.md +6 -6
  7. package/dist/cjs/plugins/pages.cjs +7 -0
  8. package/dist/plugins/pages.js +7 -0
  9. package/env.staging +5 -4
  10. package/package.json +52 -53
  11. package/vite.config.ts +50 -1
  12. package/env.development +0 -7
  13. package/env.production +0 -6
  14. package/src/assets/dummy.txt +0 -0
  15. package/src/frictionless-explicit-web3.html +0 -236
  16. package/src/frictionless-explicit.html +0 -204
  17. package/src/frictionless-implicit.html +0 -192
  18. package/src/frictionless-manual-start.html +0 -204
  19. package/src/image-explicit-web3.html +0 -182
  20. package/src/image-explicit.html +0 -151
  21. package/src/image-implicit.html +0 -192
  22. package/src/index.html +0 -192
  23. package/src/index.ts +0 -15
  24. package/src/invisible-frictionless-explicit.html +0 -123
  25. package/src/invisible-frictionless-implicit.html +0 -187
  26. package/src/invisible-image-explicit.html +0 -146
  27. package/src/invisible-image-implicit.html +0 -187
  28. package/src/invisible-pow-explicit.html +0 -146
  29. package/src/invisible-pow-implicit.html +0 -94
  30. package/src/invisible-puzzle-explicit.html +0 -145
  31. package/src/invisible-puzzle-implicit.html +0 -94
  32. package/src/plugins/code-snippet-injector.ts +0 -179
  33. package/src/plugins/form-filler-injector.ts +0 -148
  34. package/src/plugins/layout-injector.ts +0 -256
  35. package/src/plugins/logo.ts +0 -15
  36. package/src/plugins/pages.ts +0 -219
  37. package/src/plugins/placement-injector.ts +0 -114
  38. package/src/plugins/slots.ts +0 -32
  39. package/src/plugins/status-log-injector.ts +0 -143
  40. package/src/pow-explicit-web3.html +0 -179
  41. package/src/pow-explicit.html +0 -143
  42. package/src/pow-implicit-sessionid.html +0 -209
  43. package/src/pow-implicit.html +0 -192
  44. package/src/puzzle-bind-explicit.html +0 -83
  45. package/src/puzzle-explicit.html +0 -151
  46. package/src/puzzle-implicit.html +0 -192
  47. package/src/styles/demo.css +0 -803
  48. package/src/tests/plugins.unit.test.ts +0 -490
  49. package/tsconfig.cjs.json +0 -25
  50. package/tsconfig.json +0 -31
  51. package/tsconfig.tsbuildinfo +0 -1
  52. package/tsconfig.types.json +0 -9
@@ -1,192 +0,0 @@
1
- <!doctype html>
2
- <html lang="en">
3
- <head>
4
-
5
- <title>Procaptcha demo: Image, implicit rendering</title>
6
- <script type="module">
7
-
8
- window.addEventListener('load', () => {
9
-
10
- window.setIsError = (isError) => {
11
- const messageContainer = document.getElementById('messageContainer');
12
- messageContainer.style.color = isError ? 'red' : 'black';
13
- messageContainer.style.display = 'block';
14
- };
15
-
16
- window.setMessage = (message) => {
17
- document.getElementById('message').innerText = message;
18
- };
19
-
20
- window.onLoggedIn = (token) => {
21
- updateCaptchaStatus('Logged in, fetching private resource', 'info');
22
- const url = new URL("/private", config.serverUrl).href;
23
- console.log("getting private resource with token ", token, "at", url);
24
- fetch(url, {
25
- method: "GET",
26
- headers: {
27
- Origin: "http://localhost:9232", // TODO: change this to env var
28
- "Content-Type": "application/json",
29
- Authorization: `Bearer ${token}`,
30
- },
31
- })
32
- .then(async (res) => {
33
- try {
34
- const jsonRes = await res.json();
35
- if (res.status === 200) {
36
- updateCaptchaStatus(`Successfully accessed private resource`, 'success');
37
- setMessage(jsonRes.message);
38
- } else {
39
- updateCaptchaStatus(`Failed to access private resource: ${res.status}`, 'error');
40
- }
41
- } catch (err) {
42
- console.log(err);
43
- updateCaptchaStatus(`Error parsing response: ${err}`, 'error');
44
- }
45
- })
46
- .catch((err) => {
47
- console.log(err);
48
- updateCaptchaStatus(`Fetch error: ${err}`, 'error');
49
- });
50
- };
51
-
52
- window.onActionHandler = () => {
53
- updateCaptchaStatus('Form submission initiated', 'info');
54
-
55
- const procaptchaElements = document.getElementsByName('procaptcha-response');
56
-
57
- if (!procaptchaElements.length) {
58
- updateCaptchaStatus('Error: No CAPTCHA response found', 'error');
59
- alert("Must complete captcha");
60
- return
61
- }
62
-
63
- const procaptchaToken = procaptchaElements[0].value;
64
- updateCaptchaStatus(`Token received: ${procaptchaToken.substring(0, 15)}...`, 'success');
65
-
66
- const payload = {
67
- email: document.getElementById('email').value,
68
- name: document.getElementById('name').value,
69
- password: document.getElementById('password').value,
70
- siteKey: import.meta.env.PROSOPO_SITE_KEY_IMAGE,
71
- "procaptcha-response": procaptchaToken,
72
- };
73
- const url = new URL('signup', import.meta.env.PROSOPO_SERVER_URL).href;
74
- console.log("posting to", url, "with payload", payload);
75
- fetch(url, {
76
- method: "POST",
77
- headers: {
78
- "Content-Type": "application/json",
79
- },
80
- body: JSON.stringify(payload),
81
- contentType: "application/json",
82
- }).then((response) => {
83
- return new Promise((resolve) => response.json()
84
- .then((json) => resolve({
85
- status: response.status,
86
- ok: response.ok,
87
- json,
88
- })))
89
- })
90
- .then(async ({status, json, ok}) => {
91
- console.log("status", status, "json", json.message, "ok", ok);
92
- console.log("json", json)
93
- try {
94
- if (status !== 200) {
95
- updateCaptchaStatus(`API Error: ${json.message}`, 'error');
96
- setIsError(true);
97
- setMessage(json.message);
98
- } else {
99
- updateCaptchaStatus(`API Success: ${json.message}`, 'success');
100
- setIsError(false);
101
- setMessage(json.message);
102
- }
103
- } catch (err) {
104
- console.log(err);
105
- updateCaptchaStatus(`Error processing response: ${err}`, 'error');
106
- }
107
- })
108
- .catch((err) => {
109
- console.log(err);
110
- updateCaptchaStatus(`Fetch error: ${err}`, 'error');
111
- setIsError(true);
112
- setMessage("Error: " + err);
113
- });
114
- };
115
-
116
- updateCaptchaStatus('Page loaded - Initializing CAPTCHA system', 'info');
117
-
118
- // Monitor DOM for CAPTCHA initialization
119
- const observer = new MutationObserver((mutations) => {
120
- mutations.forEach((mutation) => {
121
- if (mutation.addedNodes.length) {
122
- for (let i = 0; i < mutation.addedNodes.length; i++) {
123
- const node = mutation.addedNodes[i];
124
- if (node.classList && (node.classList.contains('procaptcha') ||
125
- node.querySelector && node.querySelector('.procaptcha'))) {
126
- updateCaptchaStatus('CAPTCHA DOM elements initialized', 'info');
127
- observer.disconnect();
128
- break;
129
- }
130
- }
131
- }
132
- });
133
- });
134
-
135
- observer.observe(document.body, { childList: true, subtree: true });
136
- });
137
-
138
- window.onCaptchaFailed = function () {
139
- console.log('Challenge failed');
140
- updateCaptchaStatus('Challenge failed - CAPTCHA verification could not be completed', 'error');
141
- }
142
-
143
- window.onCaptchaVerified = (output) => {
144
- console.log('Challenge passed');
145
- updateCaptchaStatus('Challenge passed successfully!', 'success');
146
- updateCaptchaStatus(`Token generated: ${output.substring(0, 15)}...`, 'success');
147
- }
148
-
149
- // Add custom event listener for CAPTCHA verification stages
150
- document.addEventListener('DOMContentLoaded', function() {
151
- setTimeout(() => {
152
- updateCaptchaStatus('CAPTCHA script loaded and initialized', 'info');
153
- updateCaptchaStatus('Waiting for user interaction...', 'info');
154
- }, 500);
155
- });
156
- </script>
157
- <script id="procaptchaScript" type="module" src="%VITE_BUNDLE_URL%" async defer></script>
158
- </head>
159
- <body>
160
-
161
- <div class="demo-card">
162
-
163
- <form action="%PROSOPO_SERVER_URL%/signup" method="POST" class="demo-form">
164
- <h2>Create an account</h2>
165
- <div class="demo-field">
166
- <label for="name">Name</label>
167
- <input id="name" type="text" name="name" required/>
168
- </div>
169
- <div class="demo-field">
170
- <label for="email">Email Address</label>
171
- <input id="email" type="email" name="email" required/>
172
- </div>
173
- <div class="demo-field">
174
- <label for="password">Password</label>
175
- <input id="password" type="password" name="password" required/>
176
- </div>
177
- <div class="demo-field">
178
- <div
179
- class="procaptcha"
180
- data-theme="light"
181
- data-sitekey="%PROSOPO_SITE_KEY_IMAGE%"
182
- data-failed-callback="onCaptchaFailed"
183
- data-callback="onCaptchaVerified"
184
- ></div>
185
- </div>
186
- <div id="messageContainer" style="display: none; color: black;"><span id="message"></span></div>
187
- <button type="button" class="demo-button" onclick="onActionHandler()" data-cy="submit-button">Submit</button>
188
- </form>
189
-
190
- </div>
191
- </body>
192
- </html>
package/src/index.html DELETED
@@ -1,192 +0,0 @@
1
- <!doctype html>
2
- <html lang="en">
3
- <head>
4
-
5
- <title>Procaptcha demo: Frictionless, implicit rendering</title>
6
- <script type="module">
7
-
8
- window.addEventListener('load', () => {
9
-
10
- window.setIsError = (isError) => {
11
- const messageContainer = document.getElementById('messageContainer');
12
- messageContainer.style.color = isError ? 'red' : 'black';
13
- messageContainer.style.display = 'block';
14
- };
15
-
16
- window.setMessage = (message) => {
17
- document.getElementById('message').innerText = message;
18
- };
19
-
20
- window.onLoggedIn = (token) => {
21
- updateCaptchaStatus('Logged in, fetching private resource', 'info');
22
- const url = new URL("/private", config.serverUrl).href;
23
- console.log("getting private resource with token ", token, "at", url);
24
- fetch(url, {
25
- method: "GET",
26
- headers: {
27
- Origin: "http://localhost:9232", // TODO: change this to env var
28
- "Content-Type": "application/json",
29
- Authorization: `Bearer ${token}`,
30
- },
31
- })
32
- .then(async (res) => {
33
- try {
34
- const jsonRes = await res.json();
35
- if (res.status === 200) {
36
- updateCaptchaStatus(`Successfully accessed private resource`, 'success');
37
- setMessage(jsonRes.message);
38
- } else {
39
- updateCaptchaStatus(`Failed to access private resource: ${res.status}`, 'error');
40
- }
41
- } catch (err) {
42
- console.log(err);
43
- updateCaptchaStatus(`Error parsing response: ${err}`, 'error');
44
- }
45
- })
46
- .catch((err) => {
47
- console.log(err);
48
- updateCaptchaStatus(`Fetch error: ${err}`, 'error');
49
- });
50
- };
51
-
52
- window.onActionHandler = () => {
53
- updateCaptchaStatus('Form submission initiated', 'info');
54
-
55
- const procaptchaElements = document.getElementsByName('procaptcha-response');
56
-
57
- if (!procaptchaElements.length) {
58
- updateCaptchaStatus('Error: No CAPTCHA response found', 'error');
59
- alert("Must complete captcha");
60
- return
61
- }
62
-
63
- const procaptchaToken = procaptchaElements[0].value;
64
- updateCaptchaStatus(`Token received: ${procaptchaToken.substring(0, 15)}...`, 'success');
65
-
66
- const payload = {
67
- email: document.getElementById('email').value,
68
- name: document.getElementById('name').value,
69
- password: document.getElementById('password').value,
70
- siteKey: import.meta.env.PROSOPO_SITE_KEY_FRICTIONLESS,
71
- "procaptcha-response": procaptchaToken,
72
- };
73
- const url = new URL('signup', import.meta.env.PROSOPO_SERVER_URL).href;
74
- console.log("posting to", url, "with payload", payload);
75
- fetch(url, {
76
- method: "POST",
77
- headers: {
78
- "Content-Type": "application/json",
79
- },
80
- body: JSON.stringify(payload),
81
- contentType: "application/json",
82
- }).then((response) => {
83
- return new Promise((resolve) => response.json()
84
- .then((json) => resolve({
85
- status: response.status,
86
- ok: response.ok,
87
- json,
88
- })))
89
- })
90
- .then(async ({status, json, ok}) => {
91
- console.log("status", status, "json", json.message, "ok", ok);
92
- console.log("json", json)
93
- try {
94
- if (status !== 200) {
95
- updateCaptchaStatus(`API Error: ${json.message}`, 'error');
96
- setIsError(true);
97
- setMessage(json.message);
98
- } else {
99
- updateCaptchaStatus(`API Success: ${json.message}`, 'success');
100
- setIsError(false);
101
- setMessage(json.message);
102
- }
103
- } catch (err) {
104
- console.log(err);
105
- updateCaptchaStatus(`Error processing response: ${err}`, 'error');
106
- }
107
- })
108
- .catch((err) => {
109
- console.log(err);
110
- updateCaptchaStatus(`Fetch error: ${err}`, 'error');
111
- setIsError(true);
112
- setMessage("Error: " + err);
113
- });
114
- };
115
-
116
- updateCaptchaStatus('Page loaded - Initializing CAPTCHA system', 'info');
117
-
118
- // Monitor DOM for CAPTCHA initialization
119
- const observer = new MutationObserver((mutations) => {
120
- mutations.forEach((mutation) => {
121
- if (mutation.addedNodes.length) {
122
- for (let i = 0; i < mutation.addedNodes.length; i++) {
123
- const node = mutation.addedNodes[i];
124
- if (node.classList && (node.classList.contains('procaptcha') ||
125
- node.querySelector && node.querySelector('.procaptcha'))) {
126
- updateCaptchaStatus('CAPTCHA DOM elements initialized', 'info');
127
- observer.disconnect();
128
- break;
129
- }
130
- }
131
- }
132
- });
133
- });
134
-
135
- observer.observe(document.body, { childList: true, subtree: true });
136
- });
137
-
138
- window.onCaptchaFailed = function () {
139
- console.log('Challenge failed');
140
- updateCaptchaStatus('Challenge failed - CAPTCHA verification could not be completed', 'error');
141
- }
142
-
143
- window.onCaptchaVerified = (output) => {
144
- console.log('Challenge passed');
145
- updateCaptchaStatus('Challenge passed successfully!', 'success');
146
- updateCaptchaStatus(`Token generated: ${output.substring(0, 15)}...`, 'success');
147
- }
148
-
149
- // Add custom event listener for CAPTCHA verification stages
150
- document.addEventListener('DOMContentLoaded', function() {
151
- setTimeout(() => {
152
- updateCaptchaStatus('CAPTCHA script loaded and initialized', 'info');
153
- updateCaptchaStatus('Waiting for user interaction...', 'info');
154
- }, 500);
155
- });
156
- </script>
157
- <script id="procaptchaScript" type="module" src="%VITE_BUNDLE_URL%" async defer></script>
158
- </head>
159
- <body>
160
-
161
- <div class="demo-card">
162
-
163
- <form action="%PROSOPO_SERVER_URL%/signup" method="POST" class="demo-form">
164
- <h2>Create an account</h2>
165
- <div class="demo-field">
166
- <label for="name">Name</label>
167
- <input id="name" type="text" name="name" required/>
168
- </div>
169
- <div class="demo-field">
170
- <label for="email">Email Address</label>
171
- <input id="email" type="email" name="email" required/>
172
- </div>
173
- <div class="demo-field">
174
- <label for="password">Password</label>
175
- <input id="password" type="password" name="password" required/>
176
- </div>
177
- <div class="demo-field">
178
- <div
179
- class="procaptcha"
180
- data-theme="light"
181
- data-sitekey="%PROSOPO_SITE_KEY_FRICTIONLESS%"
182
- data-failed-callback="onCaptchaFailed"
183
- data-callback="onCaptchaVerified"
184
- ></div>
185
- </div>
186
- <div id="messageContainer" style="display: none; color: black;"><span id="message"></span></div>
187
- <button type="button" class="demo-button" onclick="onActionHandler()" data-cy="submit-button">Submit</button>
188
- </form>
189
-
190
- </div>
191
- </body>
192
- </html>
package/src/index.ts DELETED
@@ -1,15 +0,0 @@
1
- // Copyright 2021-2026 Prosopo (UK) Ltd.
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
-
15
- export * from "./plugins/pages.js";
@@ -1,123 +0,0 @@
1
- <!doctype html>
2
- <html lang="en">
3
- <head>
4
-
5
- <title>Procaptcha demo: Frictionless, invisible, explicit rendering</title>
6
- <!-- Status log will be injected by the status-log-injector plugin -->
7
- </head>
8
- <body>
9
- <div class="demo-card">
10
-
11
- <!-- Status log will be injected by the status-log-injector plugin -->
12
-
13
- <form id="demo-form" class="demo-form">
14
- <h2>Create an account</h2>
15
-
16
- <div class="demo-field">
17
- <label for="name">Name</label>
18
- <input type="text" id="name" name="name" required />
19
- </div>
20
-
21
- <div class="demo-field">
22
- <label for="email">Email</label>
23
- <input type="email" id="email" name="email" required />
24
- </div>
25
-
26
- <div id="procaptcha-container"></div>
27
-
28
- <button type="submit" class="demo-button" data-cy="submit-button">Submit</button>
29
-
30
- <div id="error"></div>
31
- </form>
32
-
33
- <div id="result" class="demo-result" style="display: none;"></div>
34
-
35
- </div>
36
-
37
- <script type="module">
38
- import { render, execute } from "%VITE_BUNDLE_URL%"
39
-
40
- // Form validation function
41
- function validateForm() {
42
- const nameInput = document.getElementById('name');
43
- const emailInput = document.getElementById('email');
44
- const errorDisplay = document.getElementById('error');
45
-
46
- if (!nameInput.value || !emailInput.value) {
47
- errorDisplay.textContent = 'Please fill out all fields';
48
- errorDisplay.style.display = 'block';
49
- window.updateCaptchaStatus('Form validation failed: Empty fields', 'error');
50
- return false;
51
- }
52
-
53
- // Basic email validation
54
- const emailPattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
55
- if (!emailPattern.test(emailInput.value)) {
56
- errorDisplay.textContent = 'Please enter a valid email address';
57
- errorDisplay.style.display = 'block';
58
- window.updateCaptchaStatus('Form validation failed: Invalid email format', 'error');
59
- return false;
60
- }
61
-
62
- errorDisplay.style.display = 'none';
63
- window.updateCaptchaStatus('Form validation passed', 'info');
64
- return true;
65
- }
66
-
67
- // Callback for successful CAPTCHA verification
68
- function handleCaptchaResponse(token) {
69
- console.log('Procaptcha verified, token:', token);
70
- window.updateCaptchaStatus('Challenge passed successfully!', 'success');
71
- window.updateCaptchaStatus(`Token generated: ${token.substring(0, 15)}...`, 'success');
72
-
73
- const name = document.getElementById('name').value;
74
- const email = document.getElementById('email').value;
75
-
76
- // Display result
77
- const resultElement = document.getElementById('result');
78
- resultElement.innerHTML = `<strong>Form submitted with:</strong><br>
79
- - Name: ${name}<br>
80
- - Email: ${email}<br>
81
- - Procaptcha verified: Yes`;
82
- resultElement.style.display = 'block';
83
-
84
- window.updateCaptchaStatus('Form submission completed', 'success');
85
- }
86
-
87
- // Callback for failed CAPTCHA verification
88
- function handleCaptchaFailed() {
89
- console.log('Captcha verification failed');
90
- window.updateCaptchaStatus('Challenge failed - CAPTCHA verification could not be completed', 'error');
91
- document.getElementById('error').textContent = 'CAPTCHA verification failed. Please try again.';
92
- document.getElementById('error').style.display = 'block';
93
- }
94
-
95
- // Wait for DOM content to be loaded
96
- document.addEventListener('DOMContentLoaded', function() {
97
- window.updateCaptchaStatus('Initializing CAPTCHA with explicit render call', 'info');
98
-
99
- // Render the CAPTCHA
100
- const widgetId = render(document.getElementById('procaptcha-container'), {
101
- siteKey: import.meta.env.PROSOPO_SITE_KEY_FRICTIONLESS,
102
- callback: handleCaptchaResponse,
103
- "failed-callback": handleCaptchaFailed,
104
- size: "invisible"
105
- });
106
-
107
- window.updateCaptchaStatus('CAPTCHA render function called with widget ID: ' + widgetId, 'info');
108
-
109
- // Add form submit handler
110
- document.getElementById('demo-form').addEventListener('submit', function(e) {
111
- e.preventDefault();
112
- window.updateCaptchaStatus('Form submission attempted', 'info');
113
-
114
- if (validateForm()) {
115
- // Form is valid, CAPTCHA verification will be handled by the callback
116
- window.updateCaptchaStatus('Waiting for CAPTCHA verification', 'info');
117
- execute();
118
- }
119
- });
120
- });
121
- </script>
122
- </body>
123
- </html>