altcha 2.2.2 → 2.2.4
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 +3 -2
- package/dist/altcha.d.ts +39 -19
- package/dist/altcha.i18n.d.ts +39 -19
- package/dist/altcha.i18n.js +1688 -1729
- package/dist/altcha.i18n.umd.js +4 -4
- package/dist/altcha.js +1625 -1666
- package/dist/altcha.umd.cjs +4 -4
- package/dist_external/altcha.css +1 -1
- package/dist_external/altcha.d.ts +39 -19
- package/dist_external/altcha.js +1685 -1724
- package/dist_external/altcha.umd.cjs +3 -3
- package/dist_external/worker.js +1 -1
- package/dist_plugins/analytics.js +68 -82
- package/dist_plugins/analytics.umd.cjs +1 -1
- package/dist_plugins/obfuscation.js +70 -79
- package/dist_plugins/obfuscation.umd.cjs +1 -1
- package/dist_plugins/upload.js +360 -332
- package/dist_plugins/upload.umd.cjs +4 -4
- package/package.json +7 -4
|
@@ -1,28 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
var B = (t) => {
|
|
3
|
-
throw TypeError(t);
|
|
4
|
-
};
|
|
5
|
-
var O = (t, e, i) => e in t ? N(t, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : t[e] = i;
|
|
6
|
-
var f = (t, e, i) => O(t, typeof e != "symbol" ? e + "" : e, i), b = (t, e, i) => e.has(t) || B("Cannot " + i);
|
|
7
|
-
var p = (t, e, i) => (b(t, e, "read from private field"), i ? i.call(t) : e.get(t)), g = (t, e, i) => e.has(t) ? B("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, i);
|
|
8
|
-
var E = (t, e, i) => (b(t, e, "access private method"), i);
|
|
9
|
-
class y {
|
|
1
|
+
class h {
|
|
10
2
|
/**
|
|
11
3
|
* Constructs a new instance of the Plugin.
|
|
12
4
|
*
|
|
13
5
|
* @param {PluginContext} context - The context provided to the plugin, containing necessary configurations and dependencies.
|
|
14
6
|
*/
|
|
15
|
-
constructor(
|
|
16
|
-
this.context =
|
|
7
|
+
constructor(t) {
|
|
8
|
+
this.context = t;
|
|
17
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* A distinct name of the plugin. Every plugin must have it's own name.
|
|
12
|
+
*/
|
|
13
|
+
static pluginName;
|
|
18
14
|
/**
|
|
19
15
|
* Registers a plugin class in the global `altchaPlugins` array.
|
|
20
16
|
* Ensures the plugin is added only once.
|
|
21
17
|
*
|
|
22
18
|
* @param {new(context: PluginContext) => Plugin} cls - The plugin class to register.
|
|
23
19
|
*/
|
|
24
|
-
static register(
|
|
25
|
-
typeof globalThis.altchaPlugins != "object" && (globalThis.altchaPlugins = []), globalThis.altchaPlugins.includes(
|
|
20
|
+
static register(t) {
|
|
21
|
+
typeof globalThis.altchaPlugins != "object" && (globalThis.altchaPlugins = []), globalThis.altchaPlugins.includes(t) || globalThis.altchaPlugins.push(t);
|
|
26
22
|
}
|
|
27
23
|
/**
|
|
28
24
|
* Clean up resources when the plugin is destroyed.
|
|
@@ -36,7 +32,7 @@ class y {
|
|
|
36
32
|
*
|
|
37
33
|
* @param {string | null} err - The error message or `null` if there's no error.
|
|
38
34
|
*/
|
|
39
|
-
onErrorChange(
|
|
35
|
+
onErrorChange(t) {
|
|
40
36
|
}
|
|
41
37
|
/**
|
|
42
38
|
* Callback triggered when the plugin state changes.
|
|
@@ -44,95 +40,90 @@ class y {
|
|
|
44
40
|
*
|
|
45
41
|
* @param {State} state - The new state of the plugin.
|
|
46
42
|
*/
|
|
47
|
-
onStateChange(
|
|
43
|
+
onStateChange(t) {
|
|
48
44
|
}
|
|
49
45
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
46
|
+
var s = /* @__PURE__ */ ((e) => (e.CODE = "code", e.ERROR = "error", e.VERIFIED = "verified", e.VERIFYING = "verifying", e.UNVERIFIED = "unverified", e.EXPIRED = "expired", e))(s || {});
|
|
47
|
+
class R extends h {
|
|
48
|
+
static pluginName = "obfuscation";
|
|
49
|
+
// The button element associated with revealing the obfuscated data
|
|
50
|
+
elButton;
|
|
51
|
+
// Bound method for handling button click events
|
|
52
|
+
#t = this.#e.bind(this);
|
|
56
53
|
/**
|
|
57
54
|
* Creates an instance of PluginObfuscation.
|
|
58
55
|
*
|
|
59
56
|
* @param {PluginContext} context - The context object containing plugin configurations.
|
|
60
57
|
*/
|
|
61
|
-
constructor(
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
// The button element associated with revealing the obfuscated data
|
|
66
|
-
f(this, "elButton");
|
|
67
|
-
// Bound method for handling button click events
|
|
68
|
-
g(this, r, E(this, a, I).bind(this));
|
|
69
|
-
const s = i.el;
|
|
70
|
-
this.elButton = ((n = s.parentElement) == null ? void 0 : n.querySelector("[data-clarify-button]")) || ((o = s.parentElement) == null ? void 0 : o.querySelector("button, a")), this.elButton && this.elButton.addEventListener("click", p(this, r));
|
|
58
|
+
constructor(t) {
|
|
59
|
+
super(t);
|
|
60
|
+
const i = t.el;
|
|
61
|
+
this.elButton = i.parentElement?.querySelector("[data-clarify-button]") || i.parentElement?.querySelector("button, a"), this.elButton && this.elButton.addEventListener("click", this.#t);
|
|
71
62
|
}
|
|
72
63
|
/**
|
|
73
64
|
* Destroys the plugin instance, removing event listeners.
|
|
74
65
|
*/
|
|
75
66
|
destroy() {
|
|
76
|
-
this.elButton && this.elButton.removeEventListener("click",
|
|
67
|
+
this.elButton && this.elButton.removeEventListener("click", this.#t);
|
|
77
68
|
}
|
|
78
69
|
/**
|
|
79
70
|
* Handles the clarification process by decrypting the obfuscated data and rendering the clear text.
|
|
80
71
|
*/
|
|
81
72
|
async clarify() {
|
|
82
73
|
const {
|
|
83
|
-
el:
|
|
84
|
-
getConfiguration:
|
|
74
|
+
el: t,
|
|
75
|
+
getConfiguration: i,
|
|
85
76
|
getFloatingAnchor: n,
|
|
86
|
-
setFloatingAnchor:
|
|
87
|
-
reset:
|
|
88
|
-
solve:
|
|
89
|
-
setState:
|
|
90
|
-
} = this.context, { delay:
|
|
91
|
-
if (this.elButton && !n() &&
|
|
92
|
-
|
|
77
|
+
setFloatingAnchor: r,
|
|
78
|
+
reset: f,
|
|
79
|
+
solve: d,
|
|
80
|
+
setState: c
|
|
81
|
+
} = this.context, { delay: g, floating: m, maxnumber: p, obfuscated: u } = i();
|
|
82
|
+
if (this.elButton && !n() && r(this.elButton), !u) {
|
|
83
|
+
c(s.ERROR);
|
|
93
84
|
return;
|
|
94
85
|
}
|
|
95
|
-
|
|
96
|
-
const [
|
|
97
|
-
let
|
|
98
|
-
if (
|
|
99
|
-
const
|
|
100
|
-
|
|
86
|
+
f(s.VERIFYING), await new Promise((l) => setTimeout(l, g || 0));
|
|
87
|
+
const [E, y] = u.split("?");
|
|
88
|
+
let o = new URLSearchParams(y || "").get("key") || void 0;
|
|
89
|
+
if (o) {
|
|
90
|
+
const l = o.match(/^\(prompt:?(.*)\)$/);
|
|
91
|
+
l && (o = prompt(l[1] || "Enter Key:") || void 0);
|
|
101
92
|
}
|
|
102
|
-
const { solution:
|
|
103
|
-
obfuscated:
|
|
104
|
-
key:
|
|
105
|
-
maxnumber:
|
|
93
|
+
const { solution: a } = await d({
|
|
94
|
+
obfuscated: E,
|
|
95
|
+
key: o,
|
|
96
|
+
maxnumber: p
|
|
106
97
|
});
|
|
107
|
-
|
|
98
|
+
a && "clearText" in a ? (this.#i(a.clearText), c(s.VERIFIED), this.context.dispatch("cleartext", a.clearText), m && t && (t.style.display = "none")) : c(s.ERROR, "Unable to decrypt data.");
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Handles the button click event, triggering the clarification process.
|
|
102
|
+
*
|
|
103
|
+
* @param {Event} ev - The click event.
|
|
104
|
+
*/
|
|
105
|
+
#e(t) {
|
|
106
|
+
t.preventDefault();
|
|
107
|
+
const { auto: i } = this.context.getConfiguration();
|
|
108
|
+
i === "off" || this.clarify();
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Renders the clear text data by creating an appropriate element (e.g., a link or text node).
|
|
112
|
+
*
|
|
113
|
+
* @param {string} clearText - The decrypted clear text data to render.
|
|
114
|
+
*/
|
|
115
|
+
#i(t) {
|
|
116
|
+
const i = t.match(/^(mailto|tel|sms|https?):/);
|
|
117
|
+
let n;
|
|
118
|
+
if (i) {
|
|
119
|
+
const [r] = t.slice(t.indexOf(":") + 1).replace(/^\/\//, "").split("?");
|
|
120
|
+
n = document.createElement("a"), n.href = t, n.innerHTML = r;
|
|
121
|
+
} else
|
|
122
|
+
n = document.createTextNode(t);
|
|
123
|
+
this.elButton && n && (this.elButton.after(n), this.elButton.parentElement?.removeChild(this.elButton));
|
|
108
124
|
}
|
|
109
125
|
}
|
|
110
|
-
|
|
111
|
-
* Handles the button click event, triggering the clarification process.
|
|
112
|
-
*
|
|
113
|
-
* @param {Event} ev - The click event.
|
|
114
|
-
*/
|
|
115
|
-
I = function(i) {
|
|
116
|
-
i.preventDefault();
|
|
117
|
-
const { auto: s } = this.context.getConfiguration();
|
|
118
|
-
s === "off" || this.clarify();
|
|
119
|
-
}, /**
|
|
120
|
-
* Renders the clear text data by creating an appropriate element (e.g., a link or text node).
|
|
121
|
-
*
|
|
122
|
-
* @param {string} clearText - The decrypted clear text data to render.
|
|
123
|
-
*/
|
|
124
|
-
x = function(i) {
|
|
125
|
-
var o;
|
|
126
|
-
const s = i.match(/^(mailto|tel|sms|https?):/);
|
|
127
|
-
let n;
|
|
128
|
-
if (s) {
|
|
129
|
-
const [d] = i.slice(i.indexOf(":") + 1).replace(/^\/\//, "").split("?");
|
|
130
|
-
n = document.createElement("a"), n.href = i, n.innerHTML = d;
|
|
131
|
-
} else
|
|
132
|
-
n = document.createTextNode(i);
|
|
133
|
-
this.elButton && n && (this.elButton.after(n), (o = this.elButton.parentElement) == null || o.removeChild(this.elButton));
|
|
134
|
-
}, f(v, "pluginName", "obfuscation");
|
|
135
|
-
y.register(v);
|
|
126
|
+
h.register(R);
|
|
136
127
|
export {
|
|
137
|
-
|
|
128
|
+
R as PluginObfuscation
|
|
138
129
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(o,s){typeof exports=="object"&&typeof module<"u"?s(exports):typeof define=="function"&&define.amd?define(["exports"],s):(o=typeof globalThis<"u"?globalThis:o||self,s(o["[name]"]={}))})(this,function(o){"use strict";class s{constructor(t){this.context=t}static pluginName;static register(t){typeof globalThis.altchaPlugins!="object"&&(globalThis.altchaPlugins=[]),globalThis.altchaPlugins.includes(t)||globalThis.altchaPlugins.push(t)}destroy(){}onErrorChange(t){}onStateChange(t){}}var a=(e=>(e.CODE="code",e.ERROR="error",e.VERIFIED="verified",e.VERIFYING="verifying",e.UNVERIFIED="unverified",e.EXPIRED="expired",e))(a||{});class h extends s{static pluginName="obfuscation";elButton;#t=this.#e.bind(this);constructor(t){super(t);const i=t.el;this.elButton=i.parentElement?.querySelector("[data-clarify-button]")||i.parentElement?.querySelector("button, a"),this.elButton&&this.elButton.addEventListener("click",this.#t)}destroy(){this.elButton&&this.elButton.removeEventListener("click",this.#t)}async clarify(){const{el:t,getConfiguration:i,getFloatingAnchor:n,setFloatingAnchor:u,reset:p,solve:m,setState:f}=this.context,{delay:g,floating:E,maxnumber:y,obfuscated:d}=i();if(this.elButton&&!n()&&u(this.elButton),!d){f(a.ERROR);return}p(a.VERIFYING),await new Promise(c=>setTimeout(c,g||0));const[b,R]=d.split("?");let l=new URLSearchParams(R||"").get("key")||void 0;if(l){const c=l.match(/^\(prompt:?(.*)\)$/);c&&(l=prompt(c[1]||"Enter Key:")||void 0)}const{solution:r}=await m({obfuscated:b,key:l,maxnumber:y});r&&"clearText"in r?(this.#i(r.clearText),f(a.VERIFIED),this.context.dispatch("cleartext",r.clearText),E&&t&&(t.style.display="none")):f(a.ERROR,"Unable to decrypt data.")}#e(t){t.preventDefault();const{auto:i}=this.context.getConfiguration();i==="off"||this.clarify()}#i(t){const i=t.match(/^(mailto|tel|sms|https?):/);let n;if(i){const[u]=t.slice(t.indexOf(":")+1).replace(/^\/\//,"").split("?");n=document.createElement("a"),n.href=t,n.innerHTML=u}else n=document.createTextNode(t);this.elButton&&n&&(this.elButton.after(n),this.elButton.parentElement?.removeChild(this.elButton))}}s.register(h),o.PluginObfuscation=h,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
|