@myrasec/eu-captcha-vue 0.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.
@@ -0,0 +1,3 @@
1
+ {
2
+ "recommendations": ["Vue.volar"]
3
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "explorer.fileNesting.enabled": true,
3
+ "explorer.fileNesting.patterns": {
4
+ "tsconfig.json": "tsconfig.*.json, env.d.ts",
5
+ "vite.config.*": "jsconfig*, vitest.config.*, cypress.config.*, playwright.config.*",
6
+ "package.json": "package-lock.json, pnpm*, .yarnrc*, yarn*, .eslint*, eslint*, .oxlint*, oxlint*, .prettier*, prettier*, .editorconfig"
7
+ }
8
+ }
package/LICENSE ADDED
@@ -0,0 +1,9 @@
1
+ Copyright (c) 2026 Myra Security GmbH
2
+
3
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4
+
5
+ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
6
+
7
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8
+
9
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/README.md ADDED
@@ -0,0 +1,60 @@
1
+ This package provides an easy integration of Myra Security's EU Captcha for vuejs 3.
2
+
3
+ Get your sitekey on [EU-Captcha.eu](https://www.eu-captcha.eu/).
4
+
5
+ ## Installation
6
+
7
+ (0) npm i @myrasec/eu-captcha-vue
8
+
9
+ (1) In your code add:
10
+
11
+ ```
12
+ import { EuCaptcha, isEuCaptchaDone } from "@myrasec/eu-captcha-vue";
13
+
14
+ // use the public sitekey you find in the customer's backend here.
15
+ const captchaSitekey = "YOUR-SITEKEY-HERE";
16
+ ```
17
+
18
+ (2) And then render the widget using the following syntax:
19
+
20
+ ```
21
+ <EuCaptcha sitekey={captchaSitekey} />
22
+ ```
23
+
24
+ You can test the integration using any fake sitekey. If a sitekey
25
+ does not exist, then the captcha runs with default parameters which
26
+ allow traffic to pass.
27
+
28
+ ## Querying state
29
+
30
+ Before submitting a form to a server, please ensure that EuCaptcha is done.
31
+
32
+ ```
33
+ import { isEuCaptchaDone } from "@myrasec/eu-captcha-vue";
34
+
35
+ function onSubmit(e) {
36
+ e.preventDefault();
37
+
38
+ if (!isEuCaptchaDone()) {
39
+ // computation has not been completed
40
+
41
+ return;
42
+ }
43
+ }
44
+ ```
45
+
46
+ ## Listening to state change
47
+
48
+ Additionally, a message will be posted to the main window with msg.data.type
49
+ set to 'euCaptchaDone', in case you want to be informed actively to change
50
+ e.g. the state of a button.
51
+
52
+ ```
53
+ function listenForCaptchaDone(msg: MessageEvent) {
54
+ if (msg.data.type === 'euCaptchaDone') {
55
+ // change the state of the form, etc.
56
+ }
57
+ }
58
+
59
+ window.addEventListener("message", listenForCaptchaDone, false);
60
+ ```
@@ -0,0 +1,70 @@
1
+ import { ref as d, createElementBlock as f, openBlock as m } from "vue";
2
+ let o = {
3
+ sitekey: "-",
4
+ locale: "",
5
+ theme: "light"
6
+ }, l = {
7
+ done: !1,
8
+ registered: !1
9
+ }, i = null;
10
+ function h(e) {
11
+ return typeof window > "u" ? Promise.reject("Cannot load script on server") : i || (i = new Promise((t, r) => {
12
+ if (document.querySelector(`script[src="${e}"]`)) {
13
+ t();
14
+ return;
15
+ }
16
+ const n = document.createElement("script");
17
+ n.src = e, n.async = !0, n.onload = () => t(), n.onerror = () => r(new Error(`Failed to load ${e}`)), document.head.appendChild(n);
18
+ }), i);
19
+ }
20
+ function p(e) {
21
+ e.data.type === "euCaptchaCompleted" && (l.done = !0);
22
+ }
23
+ function $() {
24
+ return l.done;
25
+ }
26
+ function y(e, t) {
27
+ 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), h("https://cdn.eu-captcha.eu/verify.js").then(() => {
28
+ l.registered || (l.registered = !0, window.addEventListener("message", p, !1)), t && t();
29
+ }).catch((r) => {
30
+ console.error("error during load of eu captcha library: " + r);
31
+ });
32
+ }
33
+ let c = null, s = null;
34
+ const u = d("");
35
+ function g() {
36
+ u.value = window.getEuCaptchaElement(
37
+ c ?? o.sitekey,
38
+ s ?? o.theme
39
+ );
40
+ }
41
+ const k = {
42
+ props: ["sitekey", "theme"],
43
+ setup(e) {
44
+ e.sitekey && (c = e.sitekey), e.theme && (s = e.theme);
45
+ },
46
+ data() {
47
+ return y(null, g), {
48
+ htmlContent: u
49
+ };
50
+ }
51
+ }, _ = (e, t) => {
52
+ const r = e.__vccOpts || e;
53
+ for (const [n, a] of t)
54
+ r[n] = a;
55
+ return r;
56
+ }, C = ["innerHTML"];
57
+ function E(e, t, r, n, a, v) {
58
+ return m(), f("div", { innerHTML: a.htmlContent }, null, 8, C);
59
+ }
60
+ const w = /* @__PURE__ */ _(k, [["render", E]]), x = {
61
+ install: (e) => {
62
+ e.component("b-upload-files-modal", w);
63
+ }
64
+ };
65
+ export {
66
+ w as EuCaptcha,
67
+ x as default,
68
+ $ as isEuCaptchaDone,
69
+ y as loadEuCaptcha
70
+ };
@@ -0,0 +1 @@
1
+ (function(t,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],o):(t=typeof globalThis<"u"?globalThis:t||self,o(t["@myra/eu-captcha-vue"]={},t.Vue))})(this,(function(t,o){"use strict";let a={sitekey:"-",locale:"",theme:"light"},c={done:!1,registered:!1},l=null;function p(e){return typeof window>"u"?Promise.reject("Cannot load script on server"):l||(l=new Promise((n,r)=>{if(document.querySelector(`script[src="${e}"]`)){n();return}const i=document.createElement("script");i.src=e,i.async=!0,i.onload=()=>n(),i.onerror=()=>r(new Error(`Failed to load ${e}`)),document.head.appendChild(i)}),l)}function y(e){e.data.type==="euCaptchaCompleted"&&(c.done=!0)}function g(){return c.done}function s(e,n){e=e||{},typeof e.sitekey=="string"&&(a.sitekey=e.sitekey),typeof e.locale=="string"&&(a.locale=e.locale),typeof e.theme=="string"&&(a.theme=e.theme),p("https://cdn.eu-captcha.eu/verify.js").then(()=>{c.registered||(c.registered=!0,window.addEventListener("message",y,!1)),n&&n()}).catch(r=>{console.error("error during load of eu captcha library: "+r)})}let d=null,f=null;const h=o.ref("");function _(){h.value=window.getEuCaptchaElement(d??a.sitekey,f??a.theme)}const C={props:["sitekey","theme"],setup(e){e.sitekey&&(d=e.sitekey),e.theme&&(f=e.theme)},data(){return s(null,_),{htmlContent:h}}},E=(e,n)=>{const r=e.__vccOpts||e;for(const[i,u]of n)r[i]=u;return r},k=["innerHTML"];function v(e,n,r,i,u,b){return o.openBlock(),o.createElementBlock("div",{innerHTML:u.htmlContent},null,8,k)}const m=E(C,[["render",v]]),w={install:e=>{e.component("b-upload-files-modal",m)}};t.EuCaptcha=m,t.default=w,t.isEuCaptchaDone=g,t.loadEuCaptcha=s,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
package/env.d.ts ADDED
@@ -0,0 +1 @@
1
+ /// <reference types="vite/client" />
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@myrasec/eu-captcha-vue",
3
+ "version": "0.0.1",
4
+ "private": false,
5
+ "type": "module",
6
+ "main": "./dist/eu-captcha-vue.umd.cjs",
7
+ "module": "./dist/eu-captcha-vue.js",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/eu-captcha-vue.js",
11
+ "require": "./dist/eu-captcha-vue.umd.cjs"
12
+ }
13
+ },
14
+ "scripts": {
15
+ "dev": "vite",
16
+ "build": "run-p type-check \"build-only {@}\" --",
17
+ "preview": "vite preview",
18
+ "build-only": "vite build",
19
+ "type-check": "vue-tsc --build"
20
+ },
21
+ "dependencies": {
22
+ "vue": ">3.0.0"
23
+ },
24
+ "devDependencies": {
25
+ "@tsconfig/node24": "^24.0.3",
26
+ "@types/node": "^24.10.4",
27
+ "@vitejs/plugin-vue": "^6.0.3",
28
+ "@vue/tsconfig": "^0.8.1",
29
+ "npm-run-all2": "^8.0.4",
30
+ "typescript": "~5.9.3",
31
+ "vite": "^7.3.0",
32
+ "vite-plugin-vue-devtools": "^8.0.5",
33
+ "vue-tsc": "^3.2.2"
34
+ }
35
+ }