vue-mtcaptcha 1.0.1

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 ng-mtcaptcha
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,304 @@
1
+ # vue-mtcaptcha
2
+
3
+ Vue 3 MTCaptcha component library with TypeScript support. [MTCaptcha](https://www.mtcaptcha.com) is an efficient security solution to protect your Vue application against spam and automated abuse. It can be integrated with login, registration, forgot password, comments, contact forms, and any custom forms.
4
+
5
+ ## Top Highlights of MTCaptcha
6
+
7
+ - GDPR compliance
8
+ - Enterprise friendly
9
+ - Accessibility compliance
10
+ - Adaptive risk engine
11
+ - High availability around the world
12
+
13
+ ## Summary of Features
14
+
15
+ - Easy to configure custom skin for captcha that suits your app theme.
16
+ - Flexible localization support via built-in language options and `customLangText`.
17
+ - Supports explicit widget control through ref methods.
18
+
19
+ ## Supported Languages
20
+
21
+ MTCaptcha supports localization for 60+ languages.
22
+
23
+ Use `lang` to select the active language code (for example: `en`, `fr`, `ta`).
24
+
25
+ Use `customLangText` to override labels for one or more language codes.
26
+
27
+ ## Forms You Can Protect
28
+
29
+ - Login form protection
30
+ - Registration form protection
31
+ - Comments form protection
32
+ - Forgot password form protection
33
+ - Contact form protection
34
+ - Any custom form you want to secure
35
+
36
+ ## Installation
37
+
38
+ ### Prerequisites
39
+
40
+ - Vue 3.0.0 or higher
41
+ - MTCaptcha account and sitekey
42
+
43
+ Install with npm:
44
+
45
+ ```bash
46
+ npm install vue-mtcaptcha
47
+ ```
48
+
49
+ ## Basic Usage (Vue 3)
50
+
51
+ Use the [MTCaptcha demo site](https://service-origin.mtc4ptch4.com/mtcv1/demo/) to build a custom configuration tailored to your specific needs
52
+
53
+ ```vue
54
+ <template>
55
+ <MTCaptcha
56
+ ref="captchaRef"
57
+ sitekey="YOUR_SITE_KEY"
58
+ :verified-callback="onVerified"
59
+ />
60
+ </template>
61
+
62
+ <script setup lang="ts">
63
+ import { ref } from 'vue';
64
+ import MTCaptcha, { type MTCaptchaState } from 'vue-mtcaptcha';
65
+
66
+ const captchaRef = ref<InstanceType<typeof MTCaptcha> | null>(null);
67
+
68
+ function onVerified(state: MTCaptchaState) {
69
+ console.log('Verified token:', state.verifiedToken);
70
+ }
71
+
72
+ function readToken() {
73
+ const token = captchaRef.value?.getVerifiedToken();
74
+ console.log('Token via ref:', token);
75
+ }
76
+ </script>
77
+ ```
78
+
79
+ The component automatically injects the MTCaptcha client scripts and renders a `div.mtcaptcha`.
80
+
81
+ ## Optional Plugin Usage
82
+
83
+ If you prefer plugin-style setup:
84
+
85
+ ```ts
86
+ import { createApp } from 'vue';
87
+ import App from './App.vue';
88
+ import { MTCaptchaPlugin } from 'vue-mtcaptcha';
89
+
90
+ const app = createApp(App);
91
+ app.use(MTCaptchaPlugin, {
92
+ siteKey: 'YOUR_SITE_KEY',
93
+ action: 'login.submit',
94
+ });
95
+ app.mount('#app');
96
+ ```
97
+
98
+ ## Props
99
+
100
+
101
+ | Name | Type | Required | Default | Description |
102
+ | ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | ------------ | --------------------------------------------------------------------------------------------------------------------------------------------- |
103
+ | `sitekey` | `string` | Yes | `-` | Your MTCaptcha site key. |
104
+ | `enableTestMode` | `string` | No | `-` | Test key from MTCaptcha Admin Console (next to PrivateKey). |
105
+ | `lang` | `string` | No | `-` | Active language code used by the widget (for example: `en`, `fr`, `ta`). |
106
+ | `customLangText` | `MTCaptchaCustomLangText` | No | `-` | Custom language text JSON. |
107
+ | `customStyle` | `MTCaptchaCustomStyle` | No | `-` | Custom style JSON for widget look-and-feel. |
108
+ | `theme` | `'basic' \| 'overcast' \| 'neowhite' \| 'goldbezel' \| 'blackmoon' \| 'darkruby' \| 'touchoforange' \| 'caribbean' \| 'woodyallen' \| 'chrome' \| 'highcontrast'` | No | `basic` | Widget theme preset. |
109
+ | `challengeType` | `'imageonly' \| 'standard'` | No | `standard` | Challenge mode. Use `imageonly` to force image-only challenges. |
110
+ | `action` | `string` | No | `-` | Action tag. Must match `^[a-zA-Z0-9\\-_. ,]{1,30}$`. |
111
+ | `widgetSize` | `'mini' \| 'standard'` | No | `standard` | Widget size mode. |
112
+ | `miniFormWidth` | `number` | No | `responsive` | Width for mini widget. Range: `265` to `600`. |
113
+ | `miniFormHeight` | `number` | No | `45` | Height for mini widget. Range: `42` to `55`. |
114
+ | `loadAnimation` | `boolean` | No | `true` | Set to `false` to disable loading animation. |
115
+ | `autoFadeOuterText` | `boolean` | No | `-` | When `true`, outer text fades automatically; when `false`, it does not. |
116
+ | `lowFrictionInvisible` | `'force-visible' \| 'force-invisible'` | No | `-` | Controls visibility behavior when low-friction invisible mode is enabled. |
117
+ | `autoFormValidate` | `boolean` | No | `-` | Enables auto form validation behavior in MTCaptcha. |
118
+ | `jsloadedCallback` | `(state: MTCaptchaState) => void` | No | `-` | Called when the MTCaptcha JavaScript library has loaded. |
119
+ | `renderedCallback` | `(state: MTCaptchaState) => void` | No | `-` | Called when the widget is rendered (made visible). It may not fire if captcha remains invisible due to low-friction or IP whitelist settings. |
120
+ | `verifiedCallback` | `(state: MTCaptchaState) => void` | No | `-` | Called when the user is verified. a `verifiedToken` is available on callback. |
121
+ | `verifyexpiredCallback` | `(state: MTCaptchaState) => void` | No | `-` | Called when the last `verifiedToken` has expired. |
122
+ | `errorCallback` | `(state: MTCaptchaState) => void` | No | `-` | Called when an error occurs (for example bad sitekey or connection issues). |
123
+
124
+ For complete documentation, please visit our official [docs site](https://docs.mtcaptcha.com/dev-guide-quickstart)
125
+
126
+ ## Ref Methods
127
+
128
+ You can call these through a component ref:
129
+
130
+
131
+ | Method | Description |
132
+ | ----------------------------- | ------------------------------------------------------------------------------------------------------------- |
133
+ | `setEnableTestMode(testKey?)` | Enables automated test mode with a test key. |
134
+ | `getConfiguration()` | Returns a copy of the captcha configuration object for debugging; mutating the returned object has no effect. |
135
+ | `getStatus()` | Returns the current captcha state object. |
136
+ | `getVerifiedToken()` | Returns the current `verifiedToken` string, or `null` when not verified. |
137
+ | `renderUI()` | Explicitly renders/re-renders the widget (useful for explicit or async-safe render flows). |
138
+ | `resetUI()` | Resets the widget and its state. |
139
+ | `remove()` | Completely removes the widget from the DOM; it can be re-instantiated with `renderUI()`. |
140
+ | `showMandatory()` | Forces mandatory validation styling/message, useful with custom form validation flows. |
141
+
142
+
143
+ ## Callback State Type
144
+
145
+ ```ts
146
+ interface MTCaptchaState {
147
+ element: HTMLElement | null;
148
+ domID: string;
149
+ statusCode: number;
150
+ verifiedToken: string | null;
151
+ isVerified: boolean;
152
+ isVisible: boolean;
153
+ statusDesc: string;
154
+ }
155
+ ```
156
+
157
+ ## customLangText Interface
158
+
159
+ Use `customLangText` to override widget text by language code. Pair it with `lang` to choose which entry is used at runtime.
160
+
161
+ ```ts
162
+ interface MTCaptchaCustomLangEntry {
163
+ inputPrompt?: string;
164
+ captchaRefresh?: string;
165
+ loading?: string;
166
+ reload?: string;
167
+ verifying?: string;
168
+ verifyFail?: string;
169
+ verifySuccess?: string;
170
+ captchaExpired?: string;
171
+ verifyExpired?: string;
172
+ emptyCaptcha?: string;
173
+ incompleteCaptcha?: string;
174
+ audioPlay?: string;
175
+ audioPlaying?: string;
176
+ continueAudio?: string;
177
+ downloadAudio?: string;
178
+ audioDownloading?: string;
179
+ connectionError?: string;
180
+ }
181
+
182
+ type MTCaptchaCustomLangText = Record<string, MTCaptchaCustomLangEntry>;
183
+ ```
184
+
185
+ Example:
186
+
187
+ ```ts
188
+ const customLangText = {
189
+ en: {
190
+ inputPrompt: 'Enter captcha text',
191
+ verifyFail: 'Verification failed',
192
+ verifySuccess: 'Verified',
193
+ },
194
+ zh: {
195
+ inputPrompt: '[input|☺|☺|<html>]',
196
+ captchaRefresh:
197
+ '!!this is a very very long <refresh> msg intended to be <silly> ☺ and no <script> ☺ to see how it would react to multiline message and if the widget adjusts height correctly!!',
198
+ loading: '!!loading!!',
199
+ reload: '!!reloading!!',
200
+ verifying: '!!verifying...!!',
201
+ verifyFail: '!!verification failed!!',
202
+ verifySuccess: '!!✓success✓!!',
203
+ captchaExpired: '!!token expired!!',
204
+ verifyExpired: '!!captcha expired!!',
205
+ emptyCaptcha: '!!please complete captcha!!',
206
+ incompleteCaptcha: '!!please complete captcha!!',
207
+ audioPlay: '!!play audio!!',
208
+ audioPlaying: '!!audio playing...!!',
209
+ continueAudio: '!!continue play!!',
210
+ downloadAudio: '!!download audio!!',
211
+ audioDownloading: '!!audio downloading!!',
212
+ connectionError:
213
+ '!!Failed to reach MTCaptcha Service <br>, Please check your internet connection and try again!!',
214
+ },
215
+ };
216
+ ```
217
+
218
+ Usage:
219
+
220
+ ```vue
221
+ <MTCaptcha
222
+ sitekey="YOUR_SITE_KEY"
223
+ lang="zh"
224
+ :custom-lang-text="customLangText"
225
+ />
226
+ ```
227
+
228
+ ## customStyle Interface
229
+
230
+ Use `customStyle` to override widget colors, fonts, and borders.
231
+
232
+ ```ts
233
+ interface MTCaptchaInputBorderColor {
234
+ byDefault?: string;
235
+ hover?: string;
236
+ active?: string;
237
+ }
238
+
239
+ interface MTCaptchaButtonIconColor {
240
+ refresh?: string;
241
+ verify?: string;
242
+ success?: string;
243
+ fail?: string;
244
+ audio?: string;
245
+ audiofocus?: string;
246
+ }
247
+
248
+ interface MTCaptchaCustomStyle {
249
+ cardColor?: string;
250
+ cardShadowColor?: string;
251
+ cardBorder?: string;
252
+ placeHolderColor?: string;
253
+ inputTextColor?: string;
254
+ inputTextFont?: string;
255
+ msgTextColor?: string;
256
+ invalidMsgTextColor?: string;
257
+ msgTextFont?: string;
258
+ inputBackgroundColor?: string;
259
+ inputBorderColor?: MTCaptchaInputBorderColor;
260
+ buttonIconColor?: MTCaptchaButtonIconColor;
261
+ loadAnimationDotColor?: string;
262
+ loadAnimationBorderColor?: string;
263
+ }
264
+ ```
265
+
266
+ Example:
267
+
268
+ ```ts
269
+ const customStyle = {
270
+ cardColor: '#32FF2F',
271
+ cardShadowColor: 'rgba(197,255,73,1)',
272
+ cardBorder: '10px #DEDEDE',
273
+ placeHolderColor: '#46FFB9',
274
+ inputTextColor: '#DAFFEC',
275
+ inputTextFont: 'San serif',
276
+ msgTextColor: '#63FF8B',
277
+ invalidMsgTextColor: '#61FFCE',
278
+ msgTextFont: 'Arial',
279
+ inputBackgroundColor: '#2EF3FF',
280
+ inputBorderColor: {
281
+ byDefault: '#4AFF97',
282
+ hover: '#60FF6E',
283
+ active: '#70FFFE',
284
+ },
285
+ buttonIconColor: {
286
+ refresh: '#DDFF80',
287
+ verify: '#93FF66',
288
+ success: '#AFE9FF',
289
+ fail: '#3D84FF',
290
+ audio: '#FF7E32',
291
+ audiofocus: '#FF500F',
292
+ },
293
+ loadAnimationDotColor: '#F122FF',
294
+ loadAnimationBorderColor: '#DFFF78',
295
+ };
296
+ ```
297
+
298
+ ## License
299
+
300
+ MIT License - see [LICENSE](https://github.com/mtcaptcha-public/vue-mtcaptcha/blob/main/LICENSE) file for details.
301
+
302
+ ## Support
303
+
304
+ For issues and feature requests, please use the [GitHub issue tracker](https://github.com/mtcaptcha-public/vue-mtcaptcha/issues).
@@ -0,0 +1,247 @@
1
+ import { type App, type Plugin } from 'vue';
2
+ declare global {
3
+ interface Window {
4
+ mtcaptchaConfig?: Record<string, unknown>;
5
+ mtcaptcha?: {
6
+ enableTestMode: (testKey?: string) => void;
7
+ getConfiguration: () => unknown;
8
+ getStatus: () => unknown;
9
+ getVerifiedToken: () => string | undefined;
10
+ resetUI: () => void;
11
+ renderUI: () => void;
12
+ remove: () => void;
13
+ showMandatory: () => void;
14
+ };
15
+ }
16
+ }
17
+ export interface MTCaptchaState {
18
+ element: HTMLElement | null;
19
+ domID: string;
20
+ statusCode: number;
21
+ verifiedToken: string | null;
22
+ isVerified: boolean;
23
+ isVisible: boolean;
24
+ statusDesc: string;
25
+ }
26
+ export type MTCaptchaCustomLangText = Record<string, Record<string, string>>;
27
+ export interface MTCaptchaInputBorderColor {
28
+ byDefault?: string;
29
+ hover?: string;
30
+ active?: string;
31
+ }
32
+ export interface MTCaptchaButtonIconColor {
33
+ refresh?: string;
34
+ verify?: string;
35
+ success?: string;
36
+ fail?: string;
37
+ audio?: string;
38
+ audiofocus?: string;
39
+ }
40
+ export interface MTCaptchaCustomStyle {
41
+ cardColor?: string;
42
+ cardShadowColor?: string;
43
+ cardBorder?: string;
44
+ placeHolderColor?: string;
45
+ inputTextColor?: string;
46
+ inputTextFont?: string;
47
+ msgTextColor?: string;
48
+ invalidMsgTextColor?: string;
49
+ msgTextFont?: string;
50
+ inputBackgroundColor?: string;
51
+ inputBorderColor?: MTCaptchaInputBorderColor;
52
+ buttonIconColor?: MTCaptchaButtonIconColor;
53
+ loadAnimationDotColor?: string;
54
+ loadAnimationBorderColor?: string;
55
+ }
56
+ export interface MTCaptchaOptions {
57
+ siteKey: string;
58
+ enableTestMode?: string;
59
+ lang?: string;
60
+ challengeType?: 'imageonly' | 'standard';
61
+ customLangText?: MTCaptchaCustomLangText;
62
+ customStyle?: MTCaptchaCustomStyle;
63
+ theme?: 'basic' | 'overcast' | 'neowhite' | 'goldbezel' | 'blackmoon' | 'darkruby' | 'touchoforange' | 'caribbean' | 'woodyallen' | 'chrome' | 'highcontrast';
64
+ action?: string;
65
+ widgetSize?: 'mini' | 'standard';
66
+ miniFormWidth?: number;
67
+ miniFormHeight?: number;
68
+ loadAnimation?: boolean;
69
+ lowFrictionInvisible?: 'force-visible' | 'force-invisible';
70
+ jsloadedCallback?: (state: MTCaptchaState) => void;
71
+ renderedCallback?: (state: MTCaptchaState) => void;
72
+ verifiedCallback?: (state: MTCaptchaState) => void;
73
+ verifyexpiredCallback?: (state: MTCaptchaState) => void;
74
+ errorCallback?: (state: MTCaptchaState) => void;
75
+ autoFormValidate?: boolean;
76
+ autoFadeOuterText?: boolean;
77
+ }
78
+ export type MTCaptchaPlugin = Plugin & {
79
+ install(app: App, options?: MTCaptchaOptions): void;
80
+ };
81
+ declare const MTCaptchaPluginImpl: MTCaptchaPlugin;
82
+ export declare const MTCaptchaComponent: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
83
+ sitekey: {
84
+ type: StringConstructor;
85
+ required: true;
86
+ };
87
+ action: {
88
+ type: StringConstructor;
89
+ required: false;
90
+ validator: (value: string) => boolean;
91
+ };
92
+ enableTestMode: {
93
+ type: StringConstructor;
94
+ required: false;
95
+ };
96
+ lang: {
97
+ type: StringConstructor;
98
+ required: false;
99
+ };
100
+ customLangText: {
101
+ type: ObjectConstructor;
102
+ required: false;
103
+ };
104
+ customStyle: {
105
+ type: ObjectConstructor;
106
+ required: false;
107
+ };
108
+ theme: {
109
+ type: StringConstructor;
110
+ required: false;
111
+ default: string;
112
+ validator: (value: string) => boolean;
113
+ };
114
+ widgetSize: {
115
+ type: StringConstructor;
116
+ required: false;
117
+ validator: (value: string) => boolean;
118
+ };
119
+ miniFormWidth: {
120
+ type: NumberConstructor;
121
+ required: false;
122
+ validator: (value: number) => boolean;
123
+ };
124
+ miniFormHeight: {
125
+ type: NumberConstructor;
126
+ required: false;
127
+ validator: (value: number) => boolean;
128
+ };
129
+ loadAnimation: {
130
+ type: BooleanConstructor;
131
+ required: false;
132
+ default: boolean;
133
+ };
134
+ lowFrictionInvisible: {
135
+ type: StringConstructor;
136
+ required: false;
137
+ validator: (value: string) => boolean;
138
+ };
139
+ challengeType: {
140
+ type: StringConstructor;
141
+ required: false;
142
+ validator: (value: string) => boolean;
143
+ };
144
+ jsloadedCallback: FunctionConstructor;
145
+ renderedCallback: FunctionConstructor;
146
+ verifiedCallback: FunctionConstructor;
147
+ verifyexpiredCallback: FunctionConstructor;
148
+ errorCallback: FunctionConstructor;
149
+ autoFormValidate: {
150
+ type: BooleanConstructor;
151
+ required: false;
152
+ };
153
+ autoFadeOuterText: {
154
+ type: BooleanConstructor;
155
+ required: false;
156
+ };
157
+ }>, {}, {}, {}, {
158
+ setEnableTestMode(testKey?: string): void;
159
+ getConfiguration(): unknown;
160
+ getStatus(): unknown;
161
+ getVerifiedToken(): string | undefined;
162
+ resetUI(): void;
163
+ renderUI(): void;
164
+ remove(): void;
165
+ showMandatory(): void;
166
+ }, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
167
+ sitekey: {
168
+ type: StringConstructor;
169
+ required: true;
170
+ };
171
+ action: {
172
+ type: StringConstructor;
173
+ required: false;
174
+ validator: (value: string) => boolean;
175
+ };
176
+ enableTestMode: {
177
+ type: StringConstructor;
178
+ required: false;
179
+ };
180
+ lang: {
181
+ type: StringConstructor;
182
+ required: false;
183
+ };
184
+ customLangText: {
185
+ type: ObjectConstructor;
186
+ required: false;
187
+ };
188
+ customStyle: {
189
+ type: ObjectConstructor;
190
+ required: false;
191
+ };
192
+ theme: {
193
+ type: StringConstructor;
194
+ required: false;
195
+ default: string;
196
+ validator: (value: string) => boolean;
197
+ };
198
+ widgetSize: {
199
+ type: StringConstructor;
200
+ required: false;
201
+ validator: (value: string) => boolean;
202
+ };
203
+ miniFormWidth: {
204
+ type: NumberConstructor;
205
+ required: false;
206
+ validator: (value: number) => boolean;
207
+ };
208
+ miniFormHeight: {
209
+ type: NumberConstructor;
210
+ required: false;
211
+ validator: (value: number) => boolean;
212
+ };
213
+ loadAnimation: {
214
+ type: BooleanConstructor;
215
+ required: false;
216
+ default: boolean;
217
+ };
218
+ lowFrictionInvisible: {
219
+ type: StringConstructor;
220
+ required: false;
221
+ validator: (value: string) => boolean;
222
+ };
223
+ challengeType: {
224
+ type: StringConstructor;
225
+ required: false;
226
+ validator: (value: string) => boolean;
227
+ };
228
+ jsloadedCallback: FunctionConstructor;
229
+ renderedCallback: FunctionConstructor;
230
+ verifiedCallback: FunctionConstructor;
231
+ verifyexpiredCallback: FunctionConstructor;
232
+ errorCallback: FunctionConstructor;
233
+ autoFormValidate: {
234
+ type: BooleanConstructor;
235
+ required: false;
236
+ };
237
+ autoFadeOuterText: {
238
+ type: BooleanConstructor;
239
+ required: false;
240
+ };
241
+ }>> & Readonly<{}>, {
242
+ theme: string;
243
+ loadAnimation: boolean;
244
+ autoFormValidate: boolean;
245
+ autoFadeOuterText: boolean;
246
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
247
+ export default MTCaptchaPluginImpl;
@@ -0,0 +1,6 @@
1
+ import type { App } from 'vue';
2
+ import MTCaptchaPluginImpl, { type MTCaptchaOptions, MTCaptchaComponent } from './MTCaptcha';
3
+ export * from './MTCaptcha';
4
+ export default MTCaptchaComponent;
5
+ export declare function install(app: App, options?: MTCaptchaOptions): void;
6
+ export { MTCaptchaComponent as MTCaptcha, MTCaptchaPluginImpl as MTCaptchaPlugin };
@@ -0,0 +1,215 @@
1
+ import { defineComponent as e, h as t } from "vue";
2
+ //#region src/MTCaptcha.ts
3
+ var n = !1, r = /^[a-zA-Z0-9\-_. ,]{1,30}$/;
4
+ function i(e) {
5
+ return e == null || e === "" ? !0 : r.test(e);
6
+ }
7
+ function a(e) {
8
+ return e == null || e === "" ? !0 : e === "mini" || e === "standard";
9
+ }
10
+ function o(e) {
11
+ return e == null ? !0 : Number.isFinite(e) && e >= 265 && e <= 600;
12
+ }
13
+ function s(e) {
14
+ return e == null ? !0 : Number.isFinite(e) && e >= 42 && e <= 55;
15
+ }
16
+ function c(e) {
17
+ return e == null || e === "" ? !0 : e === "force-visible" || e === "force-invisible";
18
+ }
19
+ function l(e) {
20
+ return e == null || e === "" ? !0 : e === "imageonly" || e === "standard";
21
+ }
22
+ function u(e) {
23
+ return e == null || e === "" ? !0 : [
24
+ "basic",
25
+ "overcast",
26
+ "neowhite",
27
+ "goldbezel",
28
+ "blackmoon",
29
+ "darkruby",
30
+ "touchoforange",
31
+ "caribbean",
32
+ "woodyallen",
33
+ "chrome",
34
+ "highcontrast"
35
+ ].includes(e);
36
+ }
37
+ function d() {
38
+ if (n) return;
39
+ n = !0;
40
+ let e = document.getElementsByTagName("head")[0] || document.getElementsByTagName("body")[0], t = document.createElement("script");
41
+ t.async = !0, t.src = "https://qa-service.sadtron.com/mtcv1/client/mtcaptcha.min.js", e.appendChild(t);
42
+ let r = document.createElement("script");
43
+ r.async = !0, r.src = "https://qa-service2.sadtron.com/mtcv1/client/mtcaptcha2.min.js", e.appendChild(r);
44
+ }
45
+ var f = { install(e, t) {
46
+ if (!t?.siteKey) throw Error("MTCaptcha: \"siteKey\" is required");
47
+ if (!i(t.action)) throw Error("MTCaptcha: \"action\" is invalid. Use 1-30 chars [a-zA-Z0-9-_. ,]");
48
+ if (!a(t.widgetSize)) throw Error("MTCaptcha: \"widgetSize\" must be \"mini\" or \"standard\"");
49
+ if (!o(t.miniFormWidth)) throw Error("MTCaptcha: \"miniFormWidth\" must be between 265 and 600");
50
+ if (!s(t.miniFormHeight)) throw Error("MTCaptcha: \"miniFormHeight\" must be between 42 and 55");
51
+ if (!c(t.lowFrictionInvisible)) throw Error("MTCaptcha: \"lowFrictionInvisible\" must be \"force-visible\" or \"force-invisible\"");
52
+ if (!l(t.challengeType)) throw Error("MTCaptcha: \"challengeType\" must be \"imageonly\" or \"standard\"");
53
+ if (!u(t.theme)) throw Error("MTCaptcha: \"theme\" must be one of basic, overcast, neowhite, goldbezel, blackmoon, darkruby, touchoforange, caribbean, woodyallen, chrome, highcontrast");
54
+ t && (window.mtcaptchaConfig = {
55
+ ...window.mtcaptchaConfig ?? {},
56
+ sitekey: t.siteKey,
57
+ render: "explicit",
58
+ enableTestMode: t.enableTestMode ?? window.mtcaptchaConfig?.enableTestMode,
59
+ lang: t.lang ?? window.mtcaptchaConfig?.lang,
60
+ customLangText: t.customLangText ?? window.mtcaptchaConfig?.customLangText,
61
+ customStyle: t.customStyle ?? window.mtcaptchaConfig?.customStyle,
62
+ theme: t.theme ?? window.mtcaptchaConfig?.theme ?? "basic",
63
+ action: t.action ?? window.mtcaptchaConfig?.action,
64
+ widgetSize: t.widgetSize ?? window.mtcaptchaConfig?.widgetSize,
65
+ miniFormWidth: t.miniFormWidth ?? window.mtcaptchaConfig?.miniFormWidth,
66
+ miniFormHeight: t.miniFormHeight ?? window.mtcaptchaConfig?.miniFormHeight,
67
+ loadAnimation: t.loadAnimation ?? window.mtcaptchaConfig?.loadAnimation ?? !0,
68
+ lowFrictionInvisible: t.lowFrictionInvisible ?? window.mtcaptchaConfig?.lowFrictionInvisible,
69
+ challengeType: t.challengeType ?? window.mtcaptchaConfig?.challengeType,
70
+ "jsloaded-callback": t.jsloadedCallback ?? window.mtcaptchaConfig?.["jsloaded-callback"],
71
+ "rendered-callback": t.renderedCallback ?? window.mtcaptchaConfig?.["rendered-callback"],
72
+ "verified-callback": t.verifiedCallback ?? window.mtcaptchaConfig?.["verified-callback"],
73
+ "verifyexpired-callback": t.verifyexpiredCallback ?? window.mtcaptchaConfig?.["verifyexpired-callback"],
74
+ "error-callback": t.errorCallback ?? window.mtcaptchaConfig?.["error-callback"],
75
+ autoFormValidate: t.autoFormValidate ?? window.mtcaptchaConfig?.autoFormValidate,
76
+ autoFadeOuterText: t.autoFadeOuterText ?? window.mtcaptchaConfig?.autoFadeOuterText
77
+ }), d();
78
+ } }, p = e({
79
+ name: "MTCaptcha",
80
+ props: {
81
+ sitekey: {
82
+ type: String,
83
+ required: !0
84
+ },
85
+ action: {
86
+ type: String,
87
+ required: !1,
88
+ validator: (e) => i(e)
89
+ },
90
+ enableTestMode: {
91
+ type: String,
92
+ required: !1
93
+ },
94
+ lang: {
95
+ type: String,
96
+ required: !1
97
+ },
98
+ customLangText: {
99
+ type: Object,
100
+ required: !1
101
+ },
102
+ customStyle: {
103
+ type: Object,
104
+ required: !1
105
+ },
106
+ theme: {
107
+ type: String,
108
+ required: !1,
109
+ default: "basic",
110
+ validator: (e) => u(e)
111
+ },
112
+ widgetSize: {
113
+ type: String,
114
+ required: !1,
115
+ validator: (e) => a(e)
116
+ },
117
+ miniFormWidth: {
118
+ type: Number,
119
+ required: !1,
120
+ validator: (e) => o(e)
121
+ },
122
+ miniFormHeight: {
123
+ type: Number,
124
+ required: !1,
125
+ validator: (e) => s(e)
126
+ },
127
+ loadAnimation: {
128
+ type: Boolean,
129
+ required: !1,
130
+ default: !0
131
+ },
132
+ lowFrictionInvisible: {
133
+ type: String,
134
+ required: !1,
135
+ validator: (e) => c(e)
136
+ },
137
+ challengeType: {
138
+ type: String,
139
+ required: !1,
140
+ validator: (e) => l(e)
141
+ },
142
+ jsloadedCallback: Function,
143
+ renderedCallback: Function,
144
+ verifiedCallback: Function,
145
+ verifyexpiredCallback: Function,
146
+ errorCallback: Function,
147
+ autoFormValidate: {
148
+ type: Boolean,
149
+ required: !1
150
+ },
151
+ autoFadeOuterText: {
152
+ type: Boolean,
153
+ required: !1
154
+ }
155
+ },
156
+ methods: {
157
+ setEnableTestMode(e) {
158
+ window.mtcaptcha?.enableTestMode(e);
159
+ },
160
+ getConfiguration() {
161
+ return window.mtcaptcha?.getConfiguration();
162
+ },
163
+ getStatus() {
164
+ return window.mtcaptcha?.getStatus();
165
+ },
166
+ getVerifiedToken() {
167
+ return window.mtcaptcha?.getVerifiedToken();
168
+ },
169
+ resetUI() {
170
+ window.mtcaptcha?.resetUI();
171
+ },
172
+ renderUI() {
173
+ window.mtcaptcha?.renderUI();
174
+ },
175
+ remove() {
176
+ window.mtcaptcha?.remove();
177
+ },
178
+ showMandatory() {
179
+ window.mtcaptcha?.showMandatory();
180
+ }
181
+ },
182
+ mounted() {
183
+ d(), window.mtcaptchaConfig = {
184
+ ...window.mtcaptchaConfig ?? {},
185
+ sitekey: this.sitekey,
186
+ enableTestMode: this.enableTestMode ?? window.mtcaptchaConfig?.enableTestMode,
187
+ lang: this.lang ?? window.mtcaptchaConfig?.lang,
188
+ customLangText: this.customLangText ?? window.mtcaptchaConfig?.customLangText,
189
+ customStyle: this.customStyle ?? window.mtcaptchaConfig?.customStyle,
190
+ theme: this.theme ?? window.mtcaptchaConfig?.theme ?? "basic",
191
+ action: this.action ?? window.mtcaptchaConfig?.action,
192
+ widgetSize: this.widgetSize ?? window.mtcaptchaConfig?.widgetSize,
193
+ miniFormWidth: this.miniFormWidth ?? window.mtcaptchaConfig?.miniFormWidth,
194
+ miniFormHeight: this.miniFormHeight ?? window.mtcaptchaConfig?.miniFormHeight,
195
+ loadAnimation: this.loadAnimation ?? window.mtcaptchaConfig?.loadAnimation ?? !0,
196
+ lowFrictionInvisible: this.lowFrictionInvisible ?? window.mtcaptchaConfig?.lowFrictionInvisible,
197
+ challengeType: this.challengeType ?? window.mtcaptchaConfig?.challengeType,
198
+ "jsloaded-callback": this.jsloadedCallback ?? window.mtcaptchaConfig?.["jsloaded-callback"],
199
+ "rendered-callback": this.renderedCallback ?? window.mtcaptchaConfig?.["rendered-callback"],
200
+ "verified-callback": this.verifiedCallback ?? window.mtcaptchaConfig?.["verified-callback"],
201
+ "verifyexpired-callback": this.verifyexpiredCallback ?? window.mtcaptchaConfig?.["verifyexpired-callback"],
202
+ "error-callback": this.errorCallback ?? window.mtcaptchaConfig?.["error-callback"],
203
+ autoFormValidate: this.autoFormValidate ?? window.mtcaptchaConfig?.autoFormValidate,
204
+ autoFadeOuterText: this.autoFadeOuterText ?? window.mtcaptchaConfig?.autoFadeOuterText
205
+ };
206
+ },
207
+ render() {
208
+ return t("div", { class: "mtcaptcha" });
209
+ }
210
+ }), m = p;
211
+ function h(e, t) {
212
+ e.use(f, t);
213
+ }
214
+ //#endregion
215
+ export { p as MTCaptcha, p as MTCaptchaComponent, f as MTCaptchaPlugin, m as default, h as install };
@@ -0,0 +1 @@
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`vue`)):typeof define==`function`&&define.amd?define([`exports`,`vue`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.MTCaptchaVue={},e.Vue))})(this,function(e,t){Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});var n=!1,r=/^[a-zA-Z0-9\-_. ,]{1,30}$/;function i(e){return e==null||e===``?!0:r.test(e)}function a(e){return e==null||e===``?!0:e===`mini`||e===`standard`}function o(e){return e==null?!0:Number.isFinite(e)&&e>=265&&e<=600}function s(e){return e==null?!0:Number.isFinite(e)&&e>=42&&e<=55}function c(e){return e==null||e===``?!0:e===`force-visible`||e===`force-invisible`}function l(e){return e==null||e===``?!0:e===`imageonly`||e===`standard`}function u(e){return e==null||e===``?!0:[`basic`,`overcast`,`neowhite`,`goldbezel`,`blackmoon`,`darkruby`,`touchoforange`,`caribbean`,`woodyallen`,`chrome`,`highcontrast`].includes(e)}function d(){if(n)return;n=!0;let e=document.getElementsByTagName(`head`)[0]||document.getElementsByTagName(`body`)[0],t=document.createElement(`script`);t.async=!0,t.src=`https://qa-service.sadtron.com/mtcv1/client/mtcaptcha.min.js`,e.appendChild(t);let r=document.createElement(`script`);r.async=!0,r.src=`https://qa-service2.sadtron.com/mtcv1/client/mtcaptcha2.min.js`,e.appendChild(r)}var f={install(e,t){if(!t?.siteKey)throw Error(`MTCaptcha: "siteKey" is required`);if(!i(t.action))throw Error(`MTCaptcha: "action" is invalid. Use 1-30 chars [a-zA-Z0-9-_. ,]`);if(!a(t.widgetSize))throw Error(`MTCaptcha: "widgetSize" must be "mini" or "standard"`);if(!o(t.miniFormWidth))throw Error(`MTCaptcha: "miniFormWidth" must be between 265 and 600`);if(!s(t.miniFormHeight))throw Error(`MTCaptcha: "miniFormHeight" must be between 42 and 55`);if(!c(t.lowFrictionInvisible))throw Error(`MTCaptcha: "lowFrictionInvisible" must be "force-visible" or "force-invisible"`);if(!l(t.challengeType))throw Error(`MTCaptcha: "challengeType" must be "imageonly" or "standard"`);if(!u(t.theme))throw Error(`MTCaptcha: "theme" must be one of basic, overcast, neowhite, goldbezel, blackmoon, darkruby, touchoforange, caribbean, woodyallen, chrome, highcontrast`);t&&(window.mtcaptchaConfig={...window.mtcaptchaConfig??{},sitekey:t.siteKey,render:`explicit`,enableTestMode:t.enableTestMode??window.mtcaptchaConfig?.enableTestMode,lang:t.lang??window.mtcaptchaConfig?.lang,customLangText:t.customLangText??window.mtcaptchaConfig?.customLangText,customStyle:t.customStyle??window.mtcaptchaConfig?.customStyle,theme:t.theme??window.mtcaptchaConfig?.theme??`basic`,action:t.action??window.mtcaptchaConfig?.action,widgetSize:t.widgetSize??window.mtcaptchaConfig?.widgetSize,miniFormWidth:t.miniFormWidth??window.mtcaptchaConfig?.miniFormWidth,miniFormHeight:t.miniFormHeight??window.mtcaptchaConfig?.miniFormHeight,loadAnimation:t.loadAnimation??window.mtcaptchaConfig?.loadAnimation??!0,lowFrictionInvisible:t.lowFrictionInvisible??window.mtcaptchaConfig?.lowFrictionInvisible,challengeType:t.challengeType??window.mtcaptchaConfig?.challengeType,"jsloaded-callback":t.jsloadedCallback??window.mtcaptchaConfig?.[`jsloaded-callback`],"rendered-callback":t.renderedCallback??window.mtcaptchaConfig?.[`rendered-callback`],"verified-callback":t.verifiedCallback??window.mtcaptchaConfig?.[`verified-callback`],"verifyexpired-callback":t.verifyexpiredCallback??window.mtcaptchaConfig?.[`verifyexpired-callback`],"error-callback":t.errorCallback??window.mtcaptchaConfig?.[`error-callback`],autoFormValidate:t.autoFormValidate??window.mtcaptchaConfig?.autoFormValidate,autoFadeOuterText:t.autoFadeOuterText??window.mtcaptchaConfig?.autoFadeOuterText}),d()}},p=(0,t.defineComponent)({name:`MTCaptcha`,props:{sitekey:{type:String,required:!0},action:{type:String,required:!1,validator:e=>i(e)},enableTestMode:{type:String,required:!1},lang:{type:String,required:!1},customLangText:{type:Object,required:!1},customStyle:{type:Object,required:!1},theme:{type:String,required:!1,default:`basic`,validator:e=>u(e)},widgetSize:{type:String,required:!1,validator:e=>a(e)},miniFormWidth:{type:Number,required:!1,validator:e=>o(e)},miniFormHeight:{type:Number,required:!1,validator:e=>s(e)},loadAnimation:{type:Boolean,required:!1,default:!0},lowFrictionInvisible:{type:String,required:!1,validator:e=>c(e)},challengeType:{type:String,required:!1,validator:e=>l(e)},jsloadedCallback:Function,renderedCallback:Function,verifiedCallback:Function,verifyexpiredCallback:Function,errorCallback:Function,autoFormValidate:{type:Boolean,required:!1},autoFadeOuterText:{type:Boolean,required:!1}},methods:{setEnableTestMode(e){window.mtcaptcha?.enableTestMode(e)},getConfiguration(){return window.mtcaptcha?.getConfiguration()},getStatus(){return window.mtcaptcha?.getStatus()},getVerifiedToken(){return window.mtcaptcha?.getVerifiedToken()},resetUI(){window.mtcaptcha?.resetUI()},renderUI(){window.mtcaptcha?.renderUI()},remove(){window.mtcaptcha?.remove()},showMandatory(){window.mtcaptcha?.showMandatory()}},mounted(){d(),window.mtcaptchaConfig={...window.mtcaptchaConfig??{},sitekey:this.sitekey,enableTestMode:this.enableTestMode??window.mtcaptchaConfig?.enableTestMode,lang:this.lang??window.mtcaptchaConfig?.lang,customLangText:this.customLangText??window.mtcaptchaConfig?.customLangText,customStyle:this.customStyle??window.mtcaptchaConfig?.customStyle,theme:this.theme??window.mtcaptchaConfig?.theme??`basic`,action:this.action??window.mtcaptchaConfig?.action,widgetSize:this.widgetSize??window.mtcaptchaConfig?.widgetSize,miniFormWidth:this.miniFormWidth??window.mtcaptchaConfig?.miniFormWidth,miniFormHeight:this.miniFormHeight??window.mtcaptchaConfig?.miniFormHeight,loadAnimation:this.loadAnimation??window.mtcaptchaConfig?.loadAnimation??!0,lowFrictionInvisible:this.lowFrictionInvisible??window.mtcaptchaConfig?.lowFrictionInvisible,challengeType:this.challengeType??window.mtcaptchaConfig?.challengeType,"jsloaded-callback":this.jsloadedCallback??window.mtcaptchaConfig?.[`jsloaded-callback`],"rendered-callback":this.renderedCallback??window.mtcaptchaConfig?.[`rendered-callback`],"verified-callback":this.verifiedCallback??window.mtcaptchaConfig?.[`verified-callback`],"verifyexpired-callback":this.verifyexpiredCallback??window.mtcaptchaConfig?.[`verifyexpired-callback`],"error-callback":this.errorCallback??window.mtcaptchaConfig?.[`error-callback`],autoFormValidate:this.autoFormValidate??window.mtcaptchaConfig?.autoFormValidate,autoFadeOuterText:this.autoFadeOuterText??window.mtcaptchaConfig?.autoFadeOuterText}},render(){return(0,t.h)(`div`,{class:`mtcaptcha`})}}),m=p;function h(e,t){e.use(f,t)}e.MTCaptcha=p,e.MTCaptchaComponent=p,e.MTCaptchaPlugin=f,e.default=m,e.install=h});
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "vue-mtcaptcha",
3
+ "version": "1.0.1",
4
+ "description": "A Vue 3 plugin for MTCaptcha integration.",
5
+ "author": "MTCaptcha Public",
6
+ "organization": "MTcaptcha",
7
+ "homepage": "https://github.com/mtcaptcha-public/vue-mtcaptcha",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/mtcaptcha-public/vue-mtcaptcha.git",
11
+ "web": "https://github.com/mtcaptcha-public/vue-mtcaptcha"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/mtcaptcha-public/vue-mtcaptcha/issues"
15
+ },
16
+ "license": "MIT",
17
+ "main": "dist/vue-mtcaptcha.umd.js",
18
+ "module": "dist/vue-mtcaptcha.es.js",
19
+ "types": "dist/index.d.ts",
20
+ "files": [
21
+ "dist"
22
+ ],
23
+ "scripts": {
24
+ "build": "vite build && npm run build:types",
25
+ "build:types": "tsc -p tsconfig.types.json",
26
+ "dev": "vite dev",
27
+ "preview": "vite preview"
28
+ },
29
+ "keywords": [
30
+ "vue",
31
+ "mtcaptcha",
32
+ "captcha",
33
+ "vue-library",
34
+ "vue-component",
35
+ "security",
36
+ "mtcaptcha-vue"
37
+ ],
38
+ "peerDependencies": {
39
+ "vue": "^3.5.30"
40
+ },
41
+ "devDependencies": {
42
+ "@types/node": "^25.5.0",
43
+ "@vitejs/plugin-vue": "^6.0.5",
44
+ "typescript": "^5.9.3",
45
+ "vite": "^8.0.0"
46
+ }
47
+ }