@swetrix/captcha 1.0.3 → 2.0.0

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.
@@ -24,6 +24,7 @@
24
24
  display: flex;
25
25
  justify-content: center;
26
26
  align-items: center;
27
+ position: relative;
27
28
 
28
29
  /* 300 - 20px (padding) */
29
30
  width: 280px;
@@ -31,7 +32,7 @@
31
32
  /* bg-gray-100 */
32
33
  background-color: #f9fafb;
33
34
  border: 1px solid #e9e9e9;
34
- height: 65px;
35
+ height: 64px;
35
36
  -webkit-user-select: none;
36
37
  user-select: none;
37
38
  padding-left: 10px;
@@ -49,57 +50,80 @@
49
50
  display: flex;
50
51
  align-items: center;
51
52
  cursor: pointer;
52
-
53
- /* divide the space between #challenge and #branding as a proportion of 5 to 1 using flex */
54
- flex: 5;
53
+ flex: 1;
55
54
  }
56
55
 
57
56
  #action {
58
57
  margin-right: 10px;
58
+ position: relative;
59
+ width: 28px;
60
+ height: 28px;
59
61
  }
60
62
 
61
63
  #checkbox {
62
64
  background-color: #fff;
63
- border: 1px solid #e9e9e9;
65
+ border: 1px solid #c4c4c4;
64
66
  height: 25px;
65
67
  width: 25px;
66
68
  border-radius: 3px;
69
+ position: absolute;
70
+ top: 50%;
71
+ left: 50%;
72
+ transform: translate(-50%, -50%);
73
+ transition: opacity 0.25s ease, transform 0.25s ease;
74
+ }
75
+
76
+ #checkbox:hover {
77
+ border-color: #a0a0a0;
67
78
  }
68
79
 
69
80
  #status {
70
- font-size: 16px;
81
+ font-size: 14px;
71
82
  color: #0f0f0f;
72
83
  }
73
84
 
74
- .hidden {
75
- display: none !important;
85
+ #status span {
86
+ transition: opacity 0.2s ease;
76
87
  }
77
88
 
78
- #branding {
89
+ #status-computing {
79
90
  display: flex;
80
91
  flex-direction: column;
81
- align-items: flex-end;
82
- flex: 1;
83
92
  }
84
93
 
85
- #legal {
86
- font-size: 10px;
94
+ .hidden {
95
+ display: none !important;
87
96
  }
88
97
 
89
- #legal>a {
90
- color: #0f0f0f;
91
- text-decoration: none;
92
- cursor: pointer;
98
+ /* Fade out animation for hiding elements */
99
+ .fade-out {
100
+ opacity: 0 !important;
101
+ transform: translate(-50%, -50%) scale(0.8) !important;
102
+ pointer-events: none;
93
103
  }
94
104
 
95
- #legal>a:hover {
96
- text-decoration: underline;
105
+ /* Fade in animation for showing elements */
106
+ .fade-in {
107
+ opacity: 1;
108
+ transform: translate(-50%, -50%) scale(1);
97
109
  }
98
110
 
99
- #legal>.separator::before {
100
- content: "-";
101
- margin: 0 2px;
102
- color: #0f0f0f;
111
+ #branding {
112
+ position: absolute;
113
+ bottom: 4px;
114
+ right: 10px;
115
+ }
116
+
117
+ #branding a {
118
+ font-size: 9px;
119
+ color: #6b7280;
120
+ text-decoration: none;
121
+ transition: color 0.2s ease;
122
+ }
123
+
124
+ #branding a:hover {
125
+ color: #374151;
126
+ text-decoration: underline;
103
127
  }
104
128
 
105
129
  #action svg {
@@ -107,80 +131,106 @@
107
131
  height: 28px;
108
132
  }
109
133
 
110
- #failure>svg {
134
+ #failure > svg {
111
135
  /* bg-red-500 */
112
136
  color: #d6292a;
113
137
  }
114
138
 
115
- #completed>svg {
139
+ #completed > svg {
116
140
  /* bg-green-600 */
117
141
  color: #16a24c;
118
142
  }
119
143
 
120
- #completed, #failure {
144
+ #completed,
145
+ #failure {
121
146
  display: flex;
122
147
  align-items: center;
123
148
  justify-content: center;
149
+ position: absolute;
150
+ top: 50%;
151
+ left: 50%;
152
+ transform: translate(-50%, -50%) scale(0.8);
153
+ opacity: 0;
154
+ transition: opacity 0.3s ease, transform 0.3s ease;
124
155
  }
125
156
 
126
- /* Loading indicator */
127
- @keyframes spin {
128
- 0% {
129
- transform: rotate(0deg);
130
- }
157
+ #completed.show,
158
+ #failure.show {
159
+ opacity: 1;
160
+ transform: translate(-50%, -50%) scale(1);
161
+ }
131
162
 
132
- 100% {
133
- transform: rotate(360deg);
163
+ /* Checkmark draw animation */
164
+ #completed.show svg path {
165
+ stroke-dasharray: 24;
166
+ stroke-dashoffset: 24;
167
+ animation: drawCheck 0.4s ease forwards 0.1s;
168
+ }
169
+
170
+ @keyframes drawCheck {
171
+ to {
172
+ stroke-dashoffset: 0;
134
173
  }
135
174
  }
136
175
 
176
+ /* Failure shake animation */
177
+ #failure.show {
178
+ animation: shake 0.4s ease;
179
+ }
180
+
181
+ @keyframes shake {
182
+ 0%, 100% { transform: translate(-50%, -50%) scale(1) rotate(0deg); }
183
+ 25% { transform: translate(-50%, -50%) scale(1) rotate(-5deg); }
184
+ 75% { transform: translate(-50%, -50%) scale(1) rotate(5deg); }
185
+ }
186
+
187
+ /* Loading indicator - Material Design style spinner */
137
188
  #loading {
138
- border-radius: 50%;
139
- width: 17px;
140
- height: 17px;
141
- border: 4px solid #b4b4b4;
142
- border-top-color: #fff;
143
- animation: spin 2s infinite linear;
189
+ position: absolute;
190
+ top: 50%;
191
+ left: 50%;
192
+ transform: translate(-50%, -50%);
193
+ width: 24px;
194
+ height: 24px;
195
+ opacity: 0;
196
+ transition: opacity 0.25s ease;
144
197
  }
145
198
 
146
- #manual-challenge {
147
- display: flex;
148
- justify-content: center;
149
- align-items: center;
150
- flex-direction: row;
151
- border: 1px solid #e9e9e9;
152
- border-top: none;
153
- height: 130px;
154
- width: 280px;
155
- padding-left: 10px;
156
- padding-right: 10px;
157
- gap: 10px;
199
+ #loading.show {
200
+ opacity: 1;
158
201
  }
159
202
 
160
- #input-n-captcha {
161
- display: flex;
162
- flex-direction: column;
163
- align-items: center;
164
- cursor: pointer;
165
- flex: 5;
203
+ #loading svg {
204
+ width: 24px;
205
+ height: 24px;
206
+ animation: rotate 1.4s linear infinite;
166
207
  }
167
208
 
168
- #input-n-captcha > input {
169
- width: 100%;
209
+ #loading svg circle {
210
+ stroke: #3b82f6;
211
+ stroke-linecap: round;
212
+ animation: dash 1.4s ease-in-out infinite;
170
213
  }
171
214
 
172
- #manual-submit-btn {
173
- background-color: #fff;
174
- border: 1px solid #e9e9e9;
175
- padding-left: 5px;
176
- padding-right: 5px;
177
- border-radius: 3px;
178
- height: 75px;
179
- display: flex;
180
- align-items: center;
181
- justify-content: center;
182
- cursor: pointer;
183
- flex: 1;
215
+ @keyframes rotate {
216
+ 100% {
217
+ transform: rotate(360deg);
218
+ }
219
+ }
220
+
221
+ @keyframes dash {
222
+ 0% {
223
+ stroke-dasharray: 1, 150;
224
+ stroke-dashoffset: 0;
225
+ }
226
+ 50% {
227
+ stroke-dasharray: 90, 150;
228
+ stroke-dashoffset: -35;
229
+ }
230
+ 100% {
231
+ stroke-dasharray: 90, 150;
232
+ stroke-dashoffset: -124;
233
+ }
184
234
  }
185
235
  </style>
186
236
  <script>
@@ -201,41 +251,34 @@
201
251
  <div id="action">
202
252
  <!-- Can contain a checkbox itself / a red cross (with a retry action) / a green check mark -->
203
253
  <div id="checkbox"></div>
204
- <div id="failure" class="hidden">
205
- <svg fill="transparent" fill-opacity="0" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
206
- <path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12" />
254
+ <div id="failure">
255
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
256
+ <path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"/>
257
+ <path d="M12 9v4"/>
258
+ <path d="M12 17h.01"/>
259
+ </svg>
260
+ </div>
261
+ <div id="completed">
262
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
263
+ <path d="M20 6 9 17l-5-5"/>
207
264
  </svg>
208
265
  </div>
209
- <div id="completed" class="hidden">
210
- <svg fill="transparent" fill-opacity="0" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor">
211
- <path stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5" />
266
+ <div id="loading">
267
+ <svg viewBox="0 0 50 50">
268
+ <circle cx="25" cy="25" r="20" fill="none" stroke-width="4"></circle>
212
269
  </svg>
213
270
  </div>
214
- <div id="loading" class="hidden"></div>
215
271
  </div>
216
272
  <div id="status">
217
273
  <span id="status-default">I am human</span>
218
274
  <span id="status-failure" class="hidden">Failure, please retry</span>
275
+ <span id="status-computing" class="hidden">
276
+ <span>Verifying...</span>
277
+ </span>
219
278
  </div>
220
279
  </div>
221
280
  <div id="branding">
222
- <a href="https://swetrix.com" target="_blank" rel="noopener noreferrer">
223
- <img src="../assets/logo_blue.png" alt="Swetrix" width="81" height="18" />
224
- </a>
225
- <div id="legal">
226
- <a href="https://swetrix.com/privacy" target="_blank" rel="noopener noreferrer">Privacy</a>
227
- <span class="separator"></span>
228
- <a href="https://swetrix.com/terms" target="_blank" rel="noopener noreferrer">Terms</a>
229
- </div>
230
- </div>
231
- </div>
232
- <div id="manual-challenge" class="hidden">
233
- <div id="input-n-captcha">
234
- <div id="svg-captcha"></div>
235
- <input aria-label="Enter the code from image" type="text" id="svg-captcha-input" autocomplete="off" />
236
- </div>
237
- <div id="manual-submit-btn">
238
- Submit
281
+ <a href="https://swetrix.com/captcha" target="_blank" rel="noopener noreferrer">Swetrix Captcha</a>
239
282
  </div>
240
283
  </div>
241
284
  </body>
@@ -17,7 +17,7 @@
17
17
  }
18
18
  </style>
19
19
 
20
- <script src="../captcha-loader.js" defer></script>
20
+ <script src="../../dist/captcha-loader.js" defer></script>
21
21
  </head>
22
22
 
23
23
  <body>
@@ -25,7 +25,7 @@
25
25
  <input type="text" name="name" value="name">
26
26
  <input type="text" name="email" value="email">
27
27
  <input type="number" name="number" value="number">
28
- <div class="swecaptcha" data-project-id="MP00000000000" data-theme="dark"></div>
28
+ <div class="swecaptcha" data-project-id="AP00000000000" data-theme="light"></div>
29
29
  <input type="submit" value="Submit">
30
30
  </form>
31
31
  </body>
@@ -0,0 +1,2 @@
1
+ !function(){"use strict";async function e(e){const t=(new TextEncoder).encode(e),s=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(s)).map(e=>e.toString(16).padStart(2,"0")).join("")}function t(e,t){for(let s=0;s<t;s++)if("0"!==e[s])return!1;return!0}self.onmessage=async s=>{if(!s.data){const e={type:"error",message:"Invalid message: event.data is missing or empty"};return void self.postMessage(e)}const{challenge:n,difficulty:a,maxIterations:r}=s.data;if("string"!=typeof n||0===n.length){const e={type:"error",message:"Invalid message: challenge must be a non-empty string"};return void self.postMessage(e)}if("number"!=typeof a||!Number.isInteger(a)){const e={type:"error",message:"Invalid message: difficulty must be an integer"};return void self.postMessage(e)}if(a<1||a>32){const e={type:"error",message:"Invalid message: difficulty must be between 1 and 32"};return void self.postMessage(e)}const o=null!=r?r:1e8;if("number"!=typeof o||!Number.isInteger(o)){const e={type:"error",message:"Invalid message: maxIterations must be an integer"};return void self.postMessage(e)}if(o<1){const e={type:"error",message:"Invalid message: maxIterations must be at least 1"};return void self.postMessage(e)}await async function(s,n,a){let r=0;const o=Date.now();for(;r<a;){const a=`${s}:${r}`,i=await e(a);if(t(i,n)){const e={type:"result",nonce:r,solution:i};return void self.postMessage(e)}if(r++,r%1e4==0){const e=(Date.now()-o)/1e3,t={type:"progress",attempts:r,hashRate:Math.round(r/e)};self.postMessage(t)}}const i=Date.now()-o,g=i/1e3,f=g>0?Math.round(r/g):0,m={type:"timeout",reason:`Maximum iterations reached (${a.toLocaleString()})`,attempts:r,elapsedMs:i,hashRate:f};self.postMessage(m)}(n,a,o)}}();
2
+ //# sourceMappingURL=pow-worker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pow-worker.js","sources":["../src/pow-worker.ts"],"sourcesContent":[null],"names":["async","sha256","message","data","TextEncoder","encode","hashBuffer","crypto","subtle","digest","Array","from","Uint8Array","map","b","toString","padStart","join","hasValidPrefix","hash","difficulty","i","self","onmessage","event","error","type","postMessage","challenge","maxIterations","length","Number","isInteger","effectiveMaxIterations","nonce","startTime","Date","now","input","result","solution","elapsed","progress","attempts","hashRate","Math","round","elapsedMs","timeout","reason","toLocaleString","solveChallenge"],"mappings":"yBA4CAA,eAAeC,EAAOC,GACpB,MACMC,GADU,IAAIC,aACCC,OAAOH,GACtBI,QAAmBC,OAAOC,OAAOC,OAAO,UAAWN,GAEzD,OADkBO,MAAMC,KAAK,IAAIC,WAAWN,IAC3BO,IAAKC,GAAMA,EAAEC,SAAS,IAAIC,SAAS,EAAG,MAAMC,KAAK,GACpE,CAGA,SAASC,EAAeC,EAAcC,GACpC,IAAK,IAAIC,EAAI,EAAGA,EAAID,EAAYC,IAC9B,GAAgB,MAAZF,EAAKE,GACP,OAAO,EAGX,OAAO,CACT,CAsDAC,KAAKC,UAAYvB,MAAOwB,IAEtB,IAAKA,EAAMrB,KAAM,CACf,MAAMsB,EAAkB,CACtBC,KAAM,QACNxB,QAAS,mDAGX,YADAoB,KAAKK,YAAYF,EAEnB,CAEA,MAAMG,UAAEA,EAASR,WAAEA,EAAUS,cAAEA,GAAkBL,EAAMrB,KAGvD,GAAyB,iBAAdyB,GAA+C,IAArBA,EAAUE,OAAc,CAC3D,MAAML,EAAkB,CACtBC,KAAM,QACNxB,QAAS,yDAGX,YADAoB,KAAKK,YAAYF,EAEnB,CAGA,GAA0B,iBAAfL,IAA4BW,OAAOC,UAAUZ,GAAa,CACnE,MAAMK,EAAkB,CACtBC,KAAM,QACNxB,QAAS,kDAGX,YADAoB,KAAKK,YAAYF,EAEnB,CAEA,GAAIL,EAAa,GAAKA,EA9ID,GA8I8B,CACjD,MAAMK,EAAkB,CACtBC,KAAM,QACNxB,QAAS,wDAGX,YADAoB,KAAKK,YAAYF,EAEnB,CAGA,MAAMQ,EAAyBJ,QAAAA,EArJF,IAsJ7B,GAAsC,iBAA3BI,IAAwCF,OAAOC,UAAUC,GAAyB,CAC3F,MAAMR,EAAkB,CACtBC,KAAM,QACNxB,QAAS,qDAGX,YADAoB,KAAKK,YAAYF,EAEnB,CAEA,GAAIQ,EAAyB,EAAG,CAC9B,MAAMR,EAAkB,CACtBC,KAAM,QACNxB,QAAS,qDAGX,YADAoB,KAAKK,YAAYF,EAEnB,OA/GFzB,eAA8B4B,EAAmBR,EAAoBS,GACnE,IAAIK,EAAQ,EACZ,MAAMC,EAAYC,KAAKC,MAGvB,KAAOH,EAAQL,GAAe,CAC5B,MAAMS,EAAQ,GAAGV,KAAaM,IACxBf,QAAalB,EAAOqC,GAE1B,GAAIpB,EAAeC,EAAMC,GAAa,CAEpC,MAAMmB,EAAoB,CACxBb,KAAM,SACNQ,QACAM,SAAUrB,GAGZ,YADAG,KAAKK,YAAYY,EAEnB,CAKA,GAHAL,IAGIA,EApBmB,KAoBU,EAAG,CAClC,MACMO,GADYL,KAAKC,MAAQF,GACH,IAEtBO,EAAwB,CAC5BhB,KAAM,WACNiB,SAAUT,EACVU,SAJeC,KAAKC,MAAMZ,EAAQO,IAMpCnB,KAAKK,YAAYe,EACnB,CACF,CAGA,MAAMK,EAAYX,KAAKC,MAAQF,EACzBM,EAAUM,EAAY,IACtBH,EAAWH,EAAU,EAAII,KAAKC,MAAMZ,EAAQO,GAAW,EACvDO,EAAsB,CAC1BtB,KAAM,UACNuB,OAAQ,+BAA+BpB,EAAcqB,oBACrDP,SAAUT,EACVa,YACAH,YAEFtB,KAAKK,YAAYqB,EACnB,CAiEQG,CAAevB,EAAWR,EAAYa"}
package/package.json CHANGED
@@ -1,11 +1,27 @@
1
1
  {
2
2
  "name": "@swetrix/captcha",
3
- "version": "1.0.3",
3
+ "version": "2.0.0",
4
4
  "description": "Swetrix CAPTCHA",
5
+ "type": "module",
5
6
  "captchaloader": "dist/captcha-loader.js",
6
7
  "captcha": "dist/captcha.js",
7
8
  "esnext": "dist/esnext/index.js",
8
9
  "typings": "dist/esnext/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "import": "./dist/esnext/index.js",
13
+ "require": "./dist/captcha.cjs.js",
14
+ "types": "./dist/esnext/index.d.ts",
15
+ "default": "./dist/captcha.js"
16
+ }
17
+ },
18
+ "scripts": {
19
+ "prebuild": "rimraf dist",
20
+ "prepublish": "npm run build",
21
+ "build": "rollup -c",
22
+ "start": "rollup -c -w",
23
+ "tsc": "tsc -p tsconfig.esnext.json"
24
+ },
9
25
  "keywords": [
10
26
  "swetrix",
11
27
  "analytics",
@@ -15,33 +31,23 @@
15
31
  ],
16
32
  "repository": {
17
33
  "type": "git",
18
- "url": "git+https://github.com/Swetrix/swetrix-js.git"
34
+ "url": "git+https://github.com/Swetrix/swetrix-captcha.git"
19
35
  },
20
- "author": "Andrii R. <contact@swetrix.com>",
21
- "funding": "https://ko-fi.com/andriir",
36
+ "author": "Swetrix Ltd <contact@swetrix.com>",
22
37
  "license": "MIT",
23
38
  "bugs": {
24
- "url": "https://github.com/Swetrix/swetrix-js/issues"
25
- },
26
- "homepage": "https://swetrix.com/docs",
27
- "dependencies": {
28
- "@types/node": "^18.15.3",
29
- "rollup-plugin-copy": "^3.4.0",
30
- "tslib": "^2.5.0"
39
+ "url": "https://github.com/Swetrix/swetrix-captcha/issues"
31
40
  },
41
+ "homepage": "https://swetrix.com/captcha",
32
42
  "devDependencies": {
33
- "rimraf": "^4.4.0",
34
- "rollup": "^2.79.1",
35
- "rollup-plugin-sourcemaps": "^0.6.3",
36
- "rollup-plugin-typescript2": "^0.34.1",
43
+ "@rollup/plugin-terser": "^0.4.4",
44
+ "@rollup/plugin-typescript": "^12.3.0",
45
+ "@types/node": "^22.15.21",
46
+ "rollup-plugin-copy": "^3.5.0",
47
+ "tslib": "^2.8.1",
37
48
  "@blaumaus/rollup-plugin-uglify": "^7.0.1",
38
- "typescript": "^5.0.2"
39
- },
40
- "scripts": {
41
- "prebuild": "rimraf dist",
42
- "prepublish": "npm run build",
43
- "build": "rollup -c && tsc -p tsconfig.esnext.json",
44
- "start": "rollup -c -w",
45
- "tsc": "tsc -p tsconfig.esnext.json"
49
+ "rimraf": "^5.0.7",
50
+ "rollup": "^4.54.0",
51
+ "typescript": "^5.9.3"
46
52
  }
47
- }
53
+ }
@@ -0,0 +1,83 @@
1
+ // import commonjs from '@rollup/plugin-commonjs'
2
+ import copy from 'rollup-plugin-copy'
3
+ import typescript from '@rollup/plugin-typescript'
4
+ import terser from '@rollup/plugin-terser'
5
+ import pkg from './package.json' with { type: 'json' }
6
+ import { createRequire } from 'node:module'
7
+
8
+ const CAPTCHA_PATH = 'src/captcha.ts'
9
+ const CAPTCHA_LOADER_PATH = 'src/captcha-loader.ts'
10
+ const POW_WORKER_PATH = 'src/pow-worker.ts'
11
+
12
+ const require = createRequire(import.meta.url)
13
+
14
+ export default [
15
+ {
16
+ input: CAPTCHA_PATH,
17
+ output: [
18
+ {
19
+ file: pkg.captcha,
20
+ format: 'umd',
21
+ name: 'captcha',
22
+ sourcemap: true,
23
+ },
24
+ ],
25
+ plugins: [
26
+ typescript({
27
+ outDir: './dist',
28
+ sourceMap: true,
29
+ tslib: require.resolve('tslib'),
30
+ }),
31
+
32
+ // copying assets
33
+ copy({
34
+ targets: [
35
+ { src: 'src/assets/*', dest: 'dist/assets' },
36
+ { src: 'src/pages/*', dest: 'dist/pages' },
37
+ ],
38
+ }),
39
+ terser(),
40
+ // commonjs(),
41
+ ],
42
+ },
43
+ {
44
+ input: CAPTCHA_LOADER_PATH,
45
+ output: [
46
+ {
47
+ file: pkg.captchaloader,
48
+ format: 'umd',
49
+ name: 'captcha-loader',
50
+ sourcemap: true,
51
+ },
52
+ ],
53
+ plugins: [
54
+ typescript({
55
+ outDir: './dist',
56
+ sourceMap: true,
57
+ tslib: require.resolve('tslib'),
58
+ }),
59
+ terser(),
60
+ // commonjs(),
61
+ ],
62
+ },
63
+ {
64
+ input: POW_WORKER_PATH,
65
+ output: [
66
+ {
67
+ file: 'dist/pow-worker.js',
68
+ format: 'iife',
69
+ name: 'powWorker',
70
+ sourcemap: true,
71
+ },
72
+ ],
73
+ plugins: [
74
+ typescript({
75
+ outDir: './dist',
76
+ sourceMap: true,
77
+ tslib: require.resolve('tslib'),
78
+ }),
79
+ terser(),
80
+ // commonjs(),
81
+ ],
82
+ },
83
+ ]
@@ -17,16 +17,11 @@ enum LOG_ACTIONS {
17
17
  info = 'info',
18
18
  }
19
19
 
20
- const DUMMY_PIDS = [
21
- 'AP00000000000', 'MP00000000000', 'FAIL000000000',
22
- ]
20
+ const DUMMY_PIDS = ['AP00000000000', 'FAIL000000000']
23
21
 
24
22
  const isValidPID = (pid: string) => DUMMY_PIDS.includes(pid) || PID_REGEX.test(pid)
25
23
 
26
- const FRAME_HEIGHT_MAPPING = {
27
- default: '66px',
28
- manual: '200px',
29
- }
24
+ const FRAME_HEIGHT = '66px'
30
25
 
31
26
  const getFrameID = (cid: string) => `${cid}-frame`
32
27
 
@@ -37,9 +32,11 @@ const log = (status: LOG_ACTIONS, text: string) => {
37
32
  }
38
33
 
39
34
  const appendParamsToURL = (url: string, params: any) => {
40
- const queryString = Object.keys(params).map((key) => {
41
- return `${encodeURIComponent(key)}=${encodeURIComponent(params[key])}`
42
- }).join('&')
35
+ const queryString = Object.keys(params)
36
+ .map((key) => {
37
+ return `${encodeURIComponent(key)}=${encodeURIComponent(params[key])}`
38
+ })
39
+ .join('&')
43
40
 
44
41
  return `${url}?${queryString}`
45
42
  }
@@ -79,9 +76,7 @@ const postMessageCallback = (pmEvent: MessageEvent) => {
79
76
  return
80
77
  }
81
78
 
82
- const {
83
- type, cid, event,
84
- } = data
79
+ const { type, cid, event } = data
85
80
 
86
81
  if (type !== MESSAGE_IDENTIFIER) {
87
82
  return
@@ -132,32 +127,6 @@ const postMessageCallback = (pmEvent: MessageEvent) => {
132
127
 
133
128
  break
134
129
  }
135
-
136
- case 'manualStarted': {
137
- const frame = document.getElementById(getFrameID(cid))
138
-
139
- if (!frame) {
140
- log(LOG_ACTIONS.error, '[PM -> manualStarted] Frame does not exist.')
141
- return
142
- }
143
-
144
- frame.style.height = FRAME_HEIGHT_MAPPING.manual
145
-
146
- break
147
- }
148
-
149
- case 'manualFinished': {
150
- const frame = document.getElementById(getFrameID(cid))
151
-
152
- if (!frame) {
153
- log(LOG_ACTIONS.error, '[PM -> manualFinished] Frame does not exist.')
154
- return
155
- }
156
-
157
- frame.style.height = FRAME_HEIGHT_MAPPING.default
158
-
159
- break
160
- }
161
130
  }
162
131
  }
163
132
 
@@ -166,10 +135,11 @@ const generateCaptchaFrame = (params: any) => {
166
135
  const captchaFrame = document.createElement('iframe')
167
136
 
168
137
  captchaFrame.id = getFrameID(params.cid)
169
- captchaFrame.src = theme === 'dark'
170
- ? appendParamsToURL(DARK_CAPTCHA_IFRAME_URL, params)
171
- : appendParamsToURL(LIGHT_CAPTCHA_IFRAME_URL, params)
172
- captchaFrame.style.height = FRAME_HEIGHT_MAPPING.default
138
+ captchaFrame.src =
139
+ theme === 'dark'
140
+ ? appendParamsToURL(DARK_CAPTCHA_IFRAME_URL, params)
141
+ : appendParamsToURL(LIGHT_CAPTCHA_IFRAME_URL, params)
142
+ captchaFrame.style.height = FRAME_HEIGHT
173
143
  captchaFrame.title = 'Swetrix Captcha'
174
144
  captchaFrame.style.border = 'none'
175
145
  captchaFrame.style.width = '302px'