@myrasec/eu-captcha 0.0.8 → 0.0.9
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 +40 -2
- package/dist/eu-captcha.js +38 -35
- package/dist/eu-captcha.umd.cjs +2 -2
- package/package.json +1 -1
- package/publish.sh +5 -0
package/README.md
CHANGED
|
@@ -2,6 +2,8 @@ This package provides an easy integration of Myra Security's EU Captcha.
|
|
|
2
2
|
|
|
3
3
|
You can use it with or without react.
|
|
4
4
|
|
|
5
|
+
## with react
|
|
6
|
+
|
|
5
7
|
How to use with react:
|
|
6
8
|
|
|
7
9
|
(0) npm i @myrasec/eu-captcha
|
|
@@ -9,7 +11,7 @@ How to use with react:
|
|
|
9
11
|
(1) In your code add:
|
|
10
12
|
|
|
11
13
|
```
|
|
12
|
-
import { EuCaptcha } from "@myrasec/eu-captcha";
|
|
14
|
+
import { EuCaptcha, isEuCaptchaDone } from "@myrasec/eu-captcha";
|
|
13
15
|
|
|
14
16
|
// use the public sitekey you find in the customer's backend here.
|
|
15
17
|
const captchaSitekey = "YOUR-SITEKEY-HERE";
|
|
@@ -25,6 +27,8 @@ You can test the integration using any fake sitekey. If a sitekey
|
|
|
25
27
|
does not exist, then the captcha runs with default parameters which
|
|
26
28
|
allow traffic to pass.
|
|
27
29
|
|
|
30
|
+
## without react
|
|
31
|
+
|
|
28
32
|
Without react, you can use the library like this:
|
|
29
33
|
|
|
30
34
|
(0) npm i @myrasec/eu-captcha
|
|
@@ -32,7 +36,7 @@ Without react, you can use the library like this:
|
|
|
32
36
|
(1) Load the JS components asynchronously:
|
|
33
37
|
|
|
34
38
|
```
|
|
35
|
-
import { loadEuCaptcha } from "@myrasec/eu-captcha";
|
|
39
|
+
import { loadEuCaptcha, isEuCaptchaDone } from "@myrasec/eu-captcha";
|
|
36
40
|
|
|
37
41
|
loadEuCaptcha();
|
|
38
42
|
```
|
|
@@ -42,3 +46,37 @@ loadEuCaptcha();
|
|
|
42
46
|
```
|
|
43
47
|
<div class="eu-captcha" data-sitekey="YOUR-SITEKEY-HERE"></div>
|
|
44
48
|
```
|
|
49
|
+
|
|
50
|
+
## Querying state
|
|
51
|
+
|
|
52
|
+
Before submitting a form to a server, please ensure that EuCaptcha is done.
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
import { isEuCaptchaDone } from "@myrasec/eu-captcha";
|
|
56
|
+
|
|
57
|
+
function onSubmit(e) {
|
|
58
|
+
e.preventDefault();
|
|
59
|
+
|
|
60
|
+
if (!isEuCaptchaDone()) {
|
|
61
|
+
// computation has not been completed
|
|
62
|
+
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Listening to state change
|
|
69
|
+
|
|
70
|
+
Additionally, a message will be posted to the main window with msg.data.type
|
|
71
|
+
set to 'euCaptchaDone', in case you want to be informed actively to change
|
|
72
|
+
e.g. the state of a button.
|
|
73
|
+
|
|
74
|
+
```
|
|
75
|
+
function listenForCaptchaDone(msg: MessageEvent) {
|
|
76
|
+
if (msg.data.type === 'euCaptchaDone') {
|
|
77
|
+
// change the state of the form, etc.
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
window.addEventListener("message", listenForCaptchaDone, false);
|
|
82
|
+
```
|
package/dist/eu-captcha.js
CHANGED
|
@@ -5,18 +5,18 @@ function te() {
|
|
|
5
5
|
if (I) return E;
|
|
6
6
|
I = 1;
|
|
7
7
|
var t = /* @__PURE__ */ Symbol.for("react.transitional.element"), c = /* @__PURE__ */ Symbol.for("react.fragment");
|
|
8
|
-
function i(
|
|
8
|
+
function i(s, l, u) {
|
|
9
9
|
var d = null;
|
|
10
|
-
if (u !== void 0 && (d = "" + u),
|
|
10
|
+
if (u !== void 0 && (d = "" + u), l.key !== void 0 && (d = "" + l.key), "key" in l) {
|
|
11
11
|
u = {};
|
|
12
|
-
for (var m in
|
|
13
|
-
m !== "key" && (u[m] =
|
|
14
|
-
} else u =
|
|
15
|
-
return
|
|
12
|
+
for (var m in l)
|
|
13
|
+
m !== "key" && (u[m] = l[m]);
|
|
14
|
+
} else u = l;
|
|
15
|
+
return l = u.ref, {
|
|
16
16
|
$$typeof: t,
|
|
17
|
-
type:
|
|
17
|
+
type: s,
|
|
18
18
|
key: d,
|
|
19
|
-
ref:
|
|
19
|
+
ref: l !== void 0 ? l : null,
|
|
20
20
|
props: u
|
|
21
21
|
};
|
|
22
22
|
}
|
|
@@ -89,7 +89,7 @@ function ne() {
|
|
|
89
89
|
), c(e);
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
function
|
|
92
|
+
function s(e) {
|
|
93
93
|
if (e === T) return "<>";
|
|
94
94
|
if (typeof e == "object" && e !== null && e.$$typeof === k)
|
|
95
95
|
return "<...>";
|
|
@@ -100,7 +100,7 @@ function ne() {
|
|
|
100
100
|
return "<...>";
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
|
-
function
|
|
103
|
+
function l() {
|
|
104
104
|
var e = y.A;
|
|
105
105
|
return e === null ? null : e.getOwner();
|
|
106
106
|
}
|
|
@@ -165,19 +165,19 @@ function ne() {
|
|
|
165
165
|
value: h
|
|
166
166
|
}), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
|
|
167
167
|
}
|
|
168
|
-
function
|
|
168
|
+
function S(e, r, n, a, R, h) {
|
|
169
169
|
var o = r.children;
|
|
170
170
|
if (o !== void 0)
|
|
171
171
|
if (a)
|
|
172
172
|
if (K(o)) {
|
|
173
173
|
for (a = 0; a < o.length; a++)
|
|
174
|
-
|
|
174
|
+
g(o[a]);
|
|
175
175
|
Object.freeze && Object.freeze(o);
|
|
176
176
|
} else
|
|
177
177
|
console.error(
|
|
178
178
|
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
179
179
|
);
|
|
180
|
-
else
|
|
180
|
+
else g(o);
|
|
181
181
|
if (x.call(r, "key")) {
|
|
182
182
|
o = t(e);
|
|
183
183
|
var f = Object.keys(r).filter(function(ee) {
|
|
@@ -198,8 +198,8 @@ React keys must be passed directly to JSX without using spread:
|
|
|
198
198
|
}
|
|
199
199
|
if (o = null, n !== void 0 && (i(n), o = "" + n), d(r) && (i(r.key), o = "" + r.key), "key" in r) {
|
|
200
200
|
n = {};
|
|
201
|
-
for (var
|
|
202
|
-
|
|
201
|
+
for (var w in r)
|
|
202
|
+
w !== "key" && (n[w] = r[w]);
|
|
203
203
|
} else n = r;
|
|
204
204
|
return o && m(
|
|
205
205
|
n,
|
|
@@ -208,15 +208,15 @@ React keys must be passed directly to JSX without using spread:
|
|
|
208
208
|
e,
|
|
209
209
|
o,
|
|
210
210
|
n,
|
|
211
|
-
|
|
211
|
+
l(),
|
|
212
212
|
R,
|
|
213
213
|
h
|
|
214
214
|
);
|
|
215
215
|
}
|
|
216
|
-
function A(e) {
|
|
217
|
-
g(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === k && (e._payload.status === "fulfilled" ? g(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
|
|
218
|
-
}
|
|
219
216
|
function g(e) {
|
|
217
|
+
A(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === k && (e._payload.status === "fulfilled" ? A(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
|
|
218
|
+
}
|
|
219
|
+
function A(e) {
|
|
220
220
|
return typeof e == "object" && e !== null && e.$$typeof === j;
|
|
221
221
|
}
|
|
222
222
|
var p = re, j = /* @__PURE__ */ Symbol.for("react.transitional.element"), U = /* @__PURE__ */ Symbol.for("react.portal"), T = /* @__PURE__ */ Symbol.for("react.fragment"), q = /* @__PURE__ */ Symbol.for("react.strict_mode"), J = /* @__PURE__ */ Symbol.for("react.profiler"), V = /* @__PURE__ */ Symbol.for("react.consumer"), z = /* @__PURE__ */ Symbol.for("react.context"), G = /* @__PURE__ */ Symbol.for("react.forward_ref"), X = /* @__PURE__ */ Symbol.for("react.suspense"), B = /* @__PURE__ */ Symbol.for("react.suspense_list"), H = /* @__PURE__ */ Symbol.for("react.memo"), k = /* @__PURE__ */ Symbol.for("react.lazy"), Z = /* @__PURE__ */ Symbol.for("react.activity"), Q = /* @__PURE__ */ Symbol.for("react.client.reference"), y = p.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, x = Object.prototype.hasOwnProperty, K = Array.isArray, O = console.createTask ? console.createTask : function() {
|
|
@@ -230,26 +230,26 @@ React keys must be passed directly to JSX without using spread:
|
|
|
230
230
|
var N, C = {}, Y = p.react_stack_bottom_frame.bind(
|
|
231
231
|
p,
|
|
232
232
|
u
|
|
233
|
-
)(), $ = O(
|
|
233
|
+
)(), $ = O(s(u)), F = {};
|
|
234
234
|
_.Fragment = T, _.jsx = function(e, r, n) {
|
|
235
235
|
var a = 1e4 > y.recentlyCreatedOwnerStacks++;
|
|
236
|
-
return
|
|
236
|
+
return S(
|
|
237
237
|
e,
|
|
238
238
|
r,
|
|
239
239
|
n,
|
|
240
240
|
!1,
|
|
241
241
|
a ? Error("react-stack-top-frame") : Y,
|
|
242
|
-
a ? O(
|
|
242
|
+
a ? O(s(e)) : $
|
|
243
243
|
);
|
|
244
244
|
}, _.jsxs = function(e, r, n) {
|
|
245
245
|
var a = 1e4 > y.recentlyCreatedOwnerStacks++;
|
|
246
|
-
return
|
|
246
|
+
return S(
|
|
247
247
|
e,
|
|
248
248
|
r,
|
|
249
249
|
n,
|
|
250
250
|
!0,
|
|
251
251
|
a ? Error("react-stack-top-frame") : Y,
|
|
252
|
-
a ? O(
|
|
252
|
+
a ? O(s(e)) : $
|
|
253
253
|
);
|
|
254
254
|
};
|
|
255
255
|
})()), _;
|
|
@@ -259,31 +259,34 @@ function ae() {
|
|
|
259
259
|
return L || (L = 1, process.env.NODE_ENV === "production" ? b.exports = te() : b.exports = ne()), b.exports;
|
|
260
260
|
}
|
|
261
261
|
var oe = ae();
|
|
262
|
-
let
|
|
262
|
+
let P = {
|
|
263
263
|
sitekey: "",
|
|
264
264
|
locale: ""
|
|
265
265
|
}, v = null;
|
|
266
|
-
function
|
|
266
|
+
function se(t) {
|
|
267
267
|
return typeof window > "u" ? Promise.reject("Cannot load script on server") : v || (v = new Promise((c, i) => {
|
|
268
268
|
if (document.querySelector(`script[src="${t}"]`)) {
|
|
269
269
|
c();
|
|
270
270
|
return;
|
|
271
271
|
}
|
|
272
|
-
const
|
|
273
|
-
|
|
272
|
+
const s = document.createElement("script");
|
|
273
|
+
s.src = t, s.async = !0, s.onload = () => c(), s.onerror = () => i(new Error(`Failed to load ${t}`)), document.head.appendChild(s);
|
|
274
274
|
}), v);
|
|
275
275
|
}
|
|
276
|
-
function
|
|
277
|
-
t
|
|
278
|
-
|
|
276
|
+
function le(t) {
|
|
277
|
+
t.data.type;
|
|
278
|
+
}
|
|
279
|
+
function ue(t) {
|
|
280
|
+
t = t || {}, typeof t.sitekey == "string" && (P.sitekey = t.sitekey), typeof t.locale == "string" && (P.locale = t.locale), se("https://cdn.eu-captcha.eu/verify.js").then(() => {
|
|
281
|
+
console.log("loaded successfully myra eu captcha library"), window.addEventListener("message", le, !1);
|
|
279
282
|
}, (c) => {
|
|
280
283
|
console.log("error occured: " + c);
|
|
281
284
|
});
|
|
282
285
|
}
|
|
283
|
-
function
|
|
284
|
-
return t && t.sitekey &&
|
|
286
|
+
function ie(t) {
|
|
287
|
+
return t && t.sitekey && ue({ sitekey: t.sitekey }), /* @__PURE__ */ oe.jsx("div", { className: "eu-captcha", "data-sitekey": P.sitekey });
|
|
285
288
|
}
|
|
286
289
|
export {
|
|
287
|
-
|
|
288
|
-
|
|
290
|
+
ie as EuCaptcha,
|
|
291
|
+
ue as loadEuCaptcha
|
|
289
292
|
};
|
package/dist/eu-captcha.umd.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
(function(i,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],m):(i=typeof globalThis<"u"?globalThis:i||self,m(i["@myra/eu-captcha"]={},i.React))})(this,(function(i,m){"use strict";var
|
|
1
|
+
(function(i,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],m):(i=typeof globalThis<"u"?globalThis:i||self,m(i["@myra/eu-captcha"]={},i.React))})(this,(function(i,m){"use strict";var R={exports:{}},E={};var A;function q(){if(A)return E;A=1;var t=Symbol.for("react.transitional.element"),c=Symbol.for("react.fragment");function f(s,l,u){var _=null;if(u!==void 0&&(_=""+u),l.key!==void 0&&(_=""+l.key),"key"in l){u={};for(var b in l)b!=="key"&&(u[b]=l[b])}else u=l;return l=u.ref,{$$typeof:t,type:s,key:_,ref:l!==void 0?l:null,props:u}}return E.Fragment=c,E.jsx=f,E.jsxs=f,E}var p={};var j;function J(){return j||(j=1,process.env.NODE_ENV!=="production"&&(function(){function t(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===ue?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case h:return"Fragment";case ee:return"Profiler";case K:return"StrictMode";case ae:return"Suspense";case oe:return"SuspenseList";case le:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case Q:return"Portal";case te:return e.displayName||"Context";case re:return(e._context.displayName||"Context")+".Consumer";case ne:var r=e.render;return e=e.displayName,e||(e=r.displayName||r.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case se:return r=e.displayName||null,r!==null?r:t(e.type)||"Memo";case O:r=e._payload,e=e._init;try{return t(e(r))}catch{}}return null}function c(e){return""+e}function f(e){try{c(e);var r=!1}catch{r=!0}if(r){r=console;var n=r.error,a=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return n.call(r,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",a),c(e)}}function s(e){if(e===h)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===O)return"<...>";try{var r=t(e);return r?"<"+r+">":"<...>"}catch{return"<...>"}}function l(){var e=S.A;return e===null?null:e.getOwner()}function u(){return Error("react-stack-top-frame")}function _(e){if(I.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function b(e,r){function n(){D||(D=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",r))}n.isReactWarning=!0,Object.defineProperty(e,"key",{get:n,configurable:!0})}function H(){var e=t(this.type);return L[e]||(L[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function Z(e,r,n,a,y,P){var o=n.ref;return e={$$typeof:F,type:e,key:r,props:n,_owner:a},(o!==void 0?o:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:H}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:y}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:P}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function N(e,r,n,a,y,P){var o=r.children;if(o!==void 0)if(a)if(ce(o)){for(a=0;a<o.length;a++)Y(o[a]);Object.freeze&&Object.freeze(o)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Y(o);if(I.call(r,"key")){o=t(e);var d=Object.keys(r).filter(function(ie){return ie!=="key"});a=0<d.length?"{key: someKey, "+d.join(": ..., ")+": ...}":"{key: someKey}",U[o+a]||(d=0<d.length?"{"+d.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
2
2
|
let props = %s;
|
|
3
3
|
<%s {...props} />
|
|
4
4
|
React keys must be passed directly to JSX without using spread:
|
|
5
5
|
let props = %s;
|
|
6
|
-
<%s key={someKey} {...props} />`,a,o,d,o),U[o+a]=!0)}if(o=null,n!==void 0&&(f(n),o=""+n),_(r)&&(f(r.key),o=""+r.key),"key"in r){n={};for(var
|
|
6
|
+
<%s key={someKey} {...props} />`,a,o,d,o),U[o+a]=!0)}if(o=null,n!==void 0&&(f(n),o=""+n),_(r)&&(f(r.key),o=""+r.key),"key"in r){n={};for(var g in r)g!=="key"&&(n[g]=r[g])}else n=r;return o&&b(n,typeof e=="function"?e.displayName||e.name||"Unknown":e),Z(e,o,n,l(),y,P)}function Y(e){$(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===O&&(e._payload.status==="fulfilled"?$(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function $(e){return typeof e=="object"&&e!==null&&e.$$typeof===F}var T=m,F=Symbol.for("react.transitional.element"),Q=Symbol.for("react.portal"),h=Symbol.for("react.fragment"),K=Symbol.for("react.strict_mode"),ee=Symbol.for("react.profiler"),re=Symbol.for("react.consumer"),te=Symbol.for("react.context"),ne=Symbol.for("react.forward_ref"),ae=Symbol.for("react.suspense"),oe=Symbol.for("react.suspense_list"),se=Symbol.for("react.memo"),O=Symbol.for("react.lazy"),le=Symbol.for("react.activity"),ue=Symbol.for("react.client.reference"),S=T.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,I=Object.prototype.hasOwnProperty,ce=Array.isArray,w=console.createTask?console.createTask:function(){return null};T={react_stack_bottom_frame:function(e){return e()}};var D,L={},M=T.react_stack_bottom_frame.bind(T,u)(),W=w(s(u)),U={};p.Fragment=h,p.jsx=function(e,r,n){var a=1e4>S.recentlyCreatedOwnerStacks++;return N(e,r,n,!1,a?Error("react-stack-top-frame"):M,a?w(s(e)):W)},p.jsxs=function(e,r,n){var a=1e4>S.recentlyCreatedOwnerStacks++;return N(e,r,n,!0,a?Error("react-stack-top-frame"):M,a?w(s(e)):W)}})()),p}var x;function V(){return x||(x=1,process.env.NODE_ENV==="production"?R.exports=q():R.exports=J()),R.exports}var z=V();let k={sitekey:"",locale:""},v=null;function G(t){return typeof window>"u"?Promise.reject("Cannot load script on server"):v||(v=new Promise((c,f)=>{if(document.querySelector(`script[src="${t}"]`)){c();return}const s=document.createElement("script");s.src=t,s.async=!0,s.onload=()=>c(),s.onerror=()=>f(new Error(`Failed to load ${t}`)),document.head.appendChild(s)}),v)}function X(t){t.data.type}function C(t){t=t||{},typeof t.sitekey=="string"&&(k.sitekey=t.sitekey),typeof t.locale=="string"&&(k.locale=t.locale),G("https://cdn.eu-captcha.eu/verify.js").then(()=>{console.log("loaded successfully myra eu captcha library"),window.addEventListener("message",X,!1)},c=>{console.log("error occured: "+c)})}function B(t){return t&&t.sitekey&&C({sitekey:t.sitekey}),z.jsx("div",{className:"eu-captcha","data-sitekey":k.sitekey})}i.EuCaptcha=B,i.loadEuCaptcha=C,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})}));
|
package/package.json
CHANGED