@myrasec/eu-captcha-vue 0.0.1 → 0.0.2
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/README.md +14 -0
- package/dist/eu-captcha-vue.js +33 -31
- package/dist/eu-captcha-vue.umd.cjs +1 -1
- package/package.json +1 -1
- package/publish.sh +5 -0
package/README.md
CHANGED
|
@@ -25,6 +25,20 @@ You can test the integration using any fake sitekey. If a sitekey
|
|
|
25
25
|
does not exist, then the captcha runs with default parameters which
|
|
26
26
|
allow traffic to pass.
|
|
27
27
|
|
|
28
|
+
You can also set additional properties: theme, width
|
|
29
|
+
|
|
30
|
+
To switch between light/dark theme:
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
<EuCaptcha sitekey={captchaSitekey} theme="dark" />
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
To define the width of the widget (default is 330). Please specify a number.
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
<EuCaptcha sitekey={captchaSitekey} width=280 />
|
|
40
|
+
```
|
|
41
|
+
|
|
28
42
|
## Querying state
|
|
29
43
|
|
|
30
44
|
Before submitting a form to a server, please ensure that EuCaptcha is done.
|
package/dist/eu-captcha-vue.js
CHANGED
|
@@ -1,70 +1,72 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
let
|
|
1
|
+
import { ref as f, createElementBlock as h, openBlock as m } from "vue";
|
|
2
|
+
let r = {
|
|
3
3
|
sitekey: "-",
|
|
4
4
|
locale: "",
|
|
5
|
-
theme: "light"
|
|
5
|
+
theme: "light",
|
|
6
|
+
width: 330
|
|
6
7
|
}, l = {
|
|
7
8
|
done: !1,
|
|
8
9
|
registered: !1
|
|
9
|
-
},
|
|
10
|
-
function
|
|
11
|
-
return typeof window > "u" ? Promise.reject("Cannot load script on server") :
|
|
10
|
+
}, o = null;
|
|
11
|
+
function y(e) {
|
|
12
|
+
return typeof window > "u" ? Promise.reject("Cannot load script on server") : o || (o = new Promise((t, i) => {
|
|
12
13
|
if (document.querySelector(`script[src="${e}"]`)) {
|
|
13
14
|
t();
|
|
14
15
|
return;
|
|
15
16
|
}
|
|
16
17
|
const n = document.createElement("script");
|
|
17
|
-
n.src = e, n.async = !0, n.onload = () => t(), n.onerror = () =>
|
|
18
|
-
}),
|
|
18
|
+
n.src = e, n.async = !0, n.onload = () => t(), n.onerror = () => i(new Error(`Failed to load ${e}`)), document.head.appendChild(n);
|
|
19
|
+
}), o);
|
|
19
20
|
}
|
|
20
21
|
function p(e) {
|
|
21
22
|
e.data.type === "euCaptchaCompleted" && (l.done = !0);
|
|
22
23
|
}
|
|
23
|
-
function
|
|
24
|
+
function x() {
|
|
24
25
|
return l.done;
|
|
25
26
|
}
|
|
26
|
-
function
|
|
27
|
-
e = e || {}, typeof e.sitekey == "string" && (
|
|
27
|
+
function w(e, t) {
|
|
28
|
+
e = e || {}, typeof e.sitekey == "string" && (r.sitekey = e.sitekey), typeof e.locale == "string" && (r.locale = e.locale), typeof e.theme == "string" && (r.theme = e.theme), typeof e.width == "number" && (r.width = e.width), y("https://cdn.eu-captcha.eu/verify.js").then(() => {
|
|
28
29
|
l.registered || (l.registered = !0, window.addEventListener("message", p, !1)), t && t();
|
|
29
|
-
}).catch((
|
|
30
|
-
console.error("error during load of eu captcha library: " +
|
|
30
|
+
}).catch((i) => {
|
|
31
|
+
console.error("error during load of eu captcha library: " + i);
|
|
31
32
|
});
|
|
32
33
|
}
|
|
33
|
-
let c = null, s = null;
|
|
34
|
-
const u =
|
|
34
|
+
let c = null, d = null, s = null;
|
|
35
|
+
const u = f("");
|
|
35
36
|
function g() {
|
|
36
37
|
u.value = window.getEuCaptchaElement(
|
|
37
|
-
c ??
|
|
38
|
-
|
|
38
|
+
c ?? r.sitekey,
|
|
39
|
+
d ?? r.theme,
|
|
40
|
+
s ?? r.width
|
|
39
41
|
);
|
|
40
42
|
}
|
|
41
43
|
const k = {
|
|
42
|
-
props: ["sitekey", "theme"],
|
|
44
|
+
props: ["sitekey", "theme", "width"],
|
|
43
45
|
setup(e) {
|
|
44
|
-
e.sitekey && (c = e.sitekey), e.theme && (
|
|
46
|
+
e.sitekey && (c = e.sitekey), e.theme && (d = e.theme), e.width && (s = e.width);
|
|
45
47
|
},
|
|
46
48
|
data() {
|
|
47
|
-
return
|
|
49
|
+
return w(null, g), {
|
|
48
50
|
htmlContent: u
|
|
49
51
|
};
|
|
50
52
|
}
|
|
51
53
|
}, _ = (e, t) => {
|
|
52
|
-
const
|
|
54
|
+
const i = e.__vccOpts || e;
|
|
53
55
|
for (const [n, a] of t)
|
|
54
|
-
|
|
55
|
-
return
|
|
56
|
+
i[n] = a;
|
|
57
|
+
return i;
|
|
56
58
|
}, C = ["innerHTML"];
|
|
57
|
-
function E(e, t,
|
|
58
|
-
return m(),
|
|
59
|
+
function E(e, t, i, n, a, b) {
|
|
60
|
+
return m(), h("div", { innerHTML: a.htmlContent }, null, 8, C);
|
|
59
61
|
}
|
|
60
|
-
const
|
|
62
|
+
const v = /* @__PURE__ */ _(k, [["render", E]]), L = {
|
|
61
63
|
install: (e) => {
|
|
62
|
-
e.component("b-upload-files-modal",
|
|
64
|
+
e.component("b-upload-files-modal", v);
|
|
63
65
|
}
|
|
64
66
|
};
|
|
65
67
|
export {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
v as EuCaptcha,
|
|
69
|
+
L as default,
|
|
70
|
+
x as isEuCaptchaDone,
|
|
71
|
+
w as loadEuCaptcha
|
|
70
72
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(t,
|
|
1
|
+
(function(t,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],r):(t=typeof globalThis<"u"?globalThis:t||self,r(t["@myra/eu-captcha-vue"]={},t.Vue))})(this,(function(t,r){"use strict";let o={sitekey:"-",locale:"",theme:"light",width:330},a={done:!1,registered:!1},c=null;function y(e){return typeof window>"u"?Promise.reject("Cannot load script on server"):c||(c=new Promise((n,l)=>{if(document.querySelector(`script[src="${e}"]`)){n();return}const i=document.createElement("script");i.src=e,i.async=!0,i.onload=()=>n(),i.onerror=()=>l(new Error(`Failed to load ${e}`)),document.head.appendChild(i)}),c)}function w(e){e.data.type==="euCaptchaCompleted"&&(a.done=!0)}function g(){return a.done}function d(e,n){e=e||{},typeof e.sitekey=="string"&&(o.sitekey=e.sitekey),typeof e.locale=="string"&&(o.locale=e.locale),typeof e.theme=="string"&&(o.theme=e.theme),typeof e.width=="number"&&(o.width=e.width),y("https://cdn.eu-captcha.eu/verify.js").then(()=>{a.registered||(a.registered=!0,window.addEventListener("message",w,!1)),n&&n()}).catch(l=>{console.error("error during load of eu captcha library: "+l)})}let s=null,f=null,h=null;const m=r.ref("");function _(){m.value=window.getEuCaptchaElement(s??o.sitekey,f??o.theme,h??o.width)}const C={props:["sitekey","theme","width"],setup(e){e.sitekey&&(s=e.sitekey),e.theme&&(f=e.theme),e.width&&(h=e.width)},data(){return d(null,_),{htmlContent:m}}},E=(e,n)=>{const l=e.__vccOpts||e;for(const[i,u]of n)l[i]=u;return l},k=["innerHTML"];function v(e,n,l,i,u,M){return r.openBlock(),r.createElementBlock("div",{innerHTML:u.htmlContent},null,8,k)}const p=E(C,[["render",v]]),b={install:e=>{e.component("b-upload-files-modal",p)}};t.EuCaptcha=p,t.default=b,t.isEuCaptchaDone=g,t.loadEuCaptcha=d,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|
package/package.json
CHANGED