altcha 0.4.3 → 0.5.0
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 +6 -1
- package/dist/altcha.iife.js +1 -1
- package/dist/altcha.js +473 -462
- package/dist/altcha.umd.cjs +1 -1
- package/dist_external/altcha.d.ts +1 -0
- package/dist_external/altcha.iife.js +1 -0
- package/dist_external/altcha.js +1248 -0
- package/dist_external/altcha.umd.cjs +1 -0
- package/dist_external/worker.js +1 -0
- package/package.json +19 -8
- /package/{dist → dist_external}/altcha.css +0 -0
|
@@ -0,0 +1,1248 @@
|
|
|
1
|
+
var nt = Object.defineProperty;
|
|
2
|
+
var it = (r, e, t) => e in r ? nt(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
|
3
|
+
var D = (r, e, t) => it(r, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
function ee() {
|
|
5
|
+
}
|
|
6
|
+
function Pe(r) {
|
|
7
|
+
return r();
|
|
8
|
+
}
|
|
9
|
+
function Re() {
|
|
10
|
+
return /* @__PURE__ */ Object.create(null);
|
|
11
|
+
}
|
|
12
|
+
function re(r) {
|
|
13
|
+
r.forEach(Pe);
|
|
14
|
+
}
|
|
15
|
+
function He(r) {
|
|
16
|
+
return typeof r == "function";
|
|
17
|
+
}
|
|
18
|
+
function lt(r, e) {
|
|
19
|
+
return r != r ? e == e : r !== e || r && typeof r == "object" || typeof r == "function";
|
|
20
|
+
}
|
|
21
|
+
function ot(r) {
|
|
22
|
+
return Object.keys(r).length === 0;
|
|
23
|
+
}
|
|
24
|
+
function v(r, e) {
|
|
25
|
+
r.appendChild(e);
|
|
26
|
+
}
|
|
27
|
+
function j(r, e, t) {
|
|
28
|
+
r.insertBefore(e, t || null);
|
|
29
|
+
}
|
|
30
|
+
function M(r) {
|
|
31
|
+
r.parentNode && r.parentNode.removeChild(r);
|
|
32
|
+
}
|
|
33
|
+
function I(r) {
|
|
34
|
+
return document.createElement(r);
|
|
35
|
+
}
|
|
36
|
+
function B(r) {
|
|
37
|
+
return document.createElementNS("http://www.w3.org/2000/svg", r);
|
|
38
|
+
}
|
|
39
|
+
function st(r) {
|
|
40
|
+
return document.createTextNode(r);
|
|
41
|
+
}
|
|
42
|
+
function J() {
|
|
43
|
+
return st(" ");
|
|
44
|
+
}
|
|
45
|
+
function ue(r, e, t, i) {
|
|
46
|
+
return r.addEventListener(e, t, i), () => r.removeEventListener(e, t, i);
|
|
47
|
+
}
|
|
48
|
+
function c(r, e, t) {
|
|
49
|
+
t == null ? r.removeAttribute(e) : r.getAttribute(e) !== t && r.setAttribute(e, t);
|
|
50
|
+
}
|
|
51
|
+
function ct(r) {
|
|
52
|
+
return Array.from(r.childNodes);
|
|
53
|
+
}
|
|
54
|
+
function Me(r, e, t) {
|
|
55
|
+
r.classList.toggle(e, !!t);
|
|
56
|
+
}
|
|
57
|
+
function ft(r, e, { bubbles: t = !1, cancelable: i = !1 } = {}) {
|
|
58
|
+
return new CustomEvent(r, { detail: e, bubbles: t, cancelable: i });
|
|
59
|
+
}
|
|
60
|
+
function ut(r) {
|
|
61
|
+
const e = {};
|
|
62
|
+
return r.childNodes.forEach(
|
|
63
|
+
/** @param {Element} node */
|
|
64
|
+
(t) => {
|
|
65
|
+
e[t.slot || "default"] = !0;
|
|
66
|
+
}
|
|
67
|
+
), e;
|
|
68
|
+
}
|
|
69
|
+
let te;
|
|
70
|
+
function Q(r) {
|
|
71
|
+
te = r;
|
|
72
|
+
}
|
|
73
|
+
function me() {
|
|
74
|
+
if (!te) throw new Error("Function called outside component initialization");
|
|
75
|
+
return te;
|
|
76
|
+
}
|
|
77
|
+
function at(r) {
|
|
78
|
+
me().$$.on_mount.push(r);
|
|
79
|
+
}
|
|
80
|
+
function ht(r) {
|
|
81
|
+
me().$$.on_destroy.push(r);
|
|
82
|
+
}
|
|
83
|
+
function dt() {
|
|
84
|
+
const r = me();
|
|
85
|
+
return (e, t, { cancelable: i = !1 } = {}) => {
|
|
86
|
+
const l = r.$$.callbacks[e];
|
|
87
|
+
if (l) {
|
|
88
|
+
const o = ft(
|
|
89
|
+
/** @type {string} */
|
|
90
|
+
e,
|
|
91
|
+
t,
|
|
92
|
+
{ cancelable: i }
|
|
93
|
+
);
|
|
94
|
+
return l.slice().forEach((s) => {
|
|
95
|
+
s.call(r, o);
|
|
96
|
+
}), !o.defaultPrevented;
|
|
97
|
+
}
|
|
98
|
+
return !0;
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
const z = [], he = [];
|
|
102
|
+
let K = [];
|
|
103
|
+
const Te = [], Fe = /* @__PURE__ */ Promise.resolve();
|
|
104
|
+
let de = !1;
|
|
105
|
+
function Ue() {
|
|
106
|
+
de || (de = !0, Fe.then(y));
|
|
107
|
+
}
|
|
108
|
+
function gt() {
|
|
109
|
+
return Ue(), Fe;
|
|
110
|
+
}
|
|
111
|
+
function ge(r) {
|
|
112
|
+
K.push(r);
|
|
113
|
+
}
|
|
114
|
+
const ae = /* @__PURE__ */ new Set();
|
|
115
|
+
let W = 0;
|
|
116
|
+
function y() {
|
|
117
|
+
if (W !== 0)
|
|
118
|
+
return;
|
|
119
|
+
const r = te;
|
|
120
|
+
do {
|
|
121
|
+
try {
|
|
122
|
+
for (; W < z.length; ) {
|
|
123
|
+
const e = z[W];
|
|
124
|
+
W++, Q(e), mt(e.$$);
|
|
125
|
+
}
|
|
126
|
+
} catch (e) {
|
|
127
|
+
throw z.length = 0, W = 0, e;
|
|
128
|
+
}
|
|
129
|
+
for (Q(null), z.length = 0, W = 0; he.length; ) he.pop()();
|
|
130
|
+
for (let e = 0; e < K.length; e += 1) {
|
|
131
|
+
const t = K[e];
|
|
132
|
+
ae.has(t) || (ae.add(t), t());
|
|
133
|
+
}
|
|
134
|
+
K.length = 0;
|
|
135
|
+
} while (z.length);
|
|
136
|
+
for (; Te.length; )
|
|
137
|
+
Te.pop()();
|
|
138
|
+
de = !1, ae.clear(), Q(r);
|
|
139
|
+
}
|
|
140
|
+
function mt(r) {
|
|
141
|
+
if (r.fragment !== null) {
|
|
142
|
+
r.update(), re(r.before_update);
|
|
143
|
+
const e = r.dirty;
|
|
144
|
+
r.dirty = [-1], r.fragment && r.fragment.p(r.ctx, e), r.after_update.forEach(ge);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
function bt(r) {
|
|
148
|
+
const e = [], t = [];
|
|
149
|
+
K.forEach((i) => r.indexOf(i) === -1 ? e.push(i) : t.push(i)), t.forEach((i) => i()), K = e;
|
|
150
|
+
}
|
|
151
|
+
const _t = /* @__PURE__ */ new Set();
|
|
152
|
+
function wt(r, e) {
|
|
153
|
+
r && r.i && (_t.delete(r), r.i(e));
|
|
154
|
+
}
|
|
155
|
+
function yt(r, e, t) {
|
|
156
|
+
const { fragment: i, after_update: l } = r.$$;
|
|
157
|
+
i && i.m(e, t), ge(() => {
|
|
158
|
+
const o = r.$$.on_mount.map(Pe).filter(He);
|
|
159
|
+
r.$$.on_destroy ? r.$$.on_destroy.push(...o) : re(o), r.$$.on_mount = [];
|
|
160
|
+
}), l.forEach(ge);
|
|
161
|
+
}
|
|
162
|
+
function vt(r, e) {
|
|
163
|
+
const t = r.$$;
|
|
164
|
+
t.fragment !== null && (bt(t.after_update), re(t.on_destroy), t.fragment && t.fragment.d(e), t.on_destroy = t.fragment = null, t.ctx = []);
|
|
165
|
+
}
|
|
166
|
+
function kt(r, e) {
|
|
167
|
+
r.$$.dirty[0] === -1 && (z.push(r), Ue(), r.$$.dirty.fill(0)), r.$$.dirty[e / 31 | 0] |= 1 << e % 31;
|
|
168
|
+
}
|
|
169
|
+
function pt(r, e, t, i, l, o, s = null, u = [-1]) {
|
|
170
|
+
const f = te;
|
|
171
|
+
Q(r);
|
|
172
|
+
const a = r.$$ = {
|
|
173
|
+
fragment: null,
|
|
174
|
+
ctx: [],
|
|
175
|
+
// state
|
|
176
|
+
props: o,
|
|
177
|
+
update: ee,
|
|
178
|
+
not_equal: l,
|
|
179
|
+
bound: Re(),
|
|
180
|
+
// lifecycle
|
|
181
|
+
on_mount: [],
|
|
182
|
+
on_destroy: [],
|
|
183
|
+
on_disconnect: [],
|
|
184
|
+
before_update: [],
|
|
185
|
+
after_update: [],
|
|
186
|
+
context: new Map(e.context || (f ? f.$$.context : [])),
|
|
187
|
+
// everything else
|
|
188
|
+
callbacks: Re(),
|
|
189
|
+
dirty: u,
|
|
190
|
+
skip_bound: !1,
|
|
191
|
+
root: e.target || f.$$.root
|
|
192
|
+
};
|
|
193
|
+
s && s(a.root);
|
|
194
|
+
let N = !1;
|
|
195
|
+
if (a.ctx = t ? t(r, e.props || {}, (C, V, ...O) => {
|
|
196
|
+
const F = O.length ? O[0] : V;
|
|
197
|
+
return a.ctx && l(a.ctx[C], a.ctx[C] = F) && (!a.skip_bound && a.bound[C] && a.bound[C](F), N && kt(r, C)), V;
|
|
198
|
+
}) : [], a.update(), N = !0, re(a.before_update), a.fragment = i ? i(a.ctx) : !1, e.target) {
|
|
199
|
+
if (e.hydrate) {
|
|
200
|
+
const C = ct(e.target);
|
|
201
|
+
a.fragment && a.fragment.l(C), C.forEach(M);
|
|
202
|
+
} else
|
|
203
|
+
a.fragment && a.fragment.c();
|
|
204
|
+
e.intro && wt(r.$$.fragment), yt(r, e.target, e.anchor), y();
|
|
205
|
+
}
|
|
206
|
+
Q(f);
|
|
207
|
+
}
|
|
208
|
+
let Be;
|
|
209
|
+
typeof HTMLElement == "function" && (Be = class extends HTMLElement {
|
|
210
|
+
constructor(e, t, i) {
|
|
211
|
+
super();
|
|
212
|
+
/** The Svelte component constructor */
|
|
213
|
+
D(this, "$$ctor");
|
|
214
|
+
/** Slots */
|
|
215
|
+
D(this, "$$s");
|
|
216
|
+
/** The Svelte component instance */
|
|
217
|
+
D(this, "$$c");
|
|
218
|
+
/** Whether or not the custom element is connected */
|
|
219
|
+
D(this, "$$cn", !1);
|
|
220
|
+
/** Component props data */
|
|
221
|
+
D(this, "$$d", {});
|
|
222
|
+
/** `true` if currently in the process of reflecting component props back to attributes */
|
|
223
|
+
D(this, "$$r", !1);
|
|
224
|
+
/** @type {Record<string, CustomElementPropDefinition>} Props definition (name, reflected, type etc) */
|
|
225
|
+
D(this, "$$p_d", {});
|
|
226
|
+
/** @type {Record<string, Function[]>} Event listeners */
|
|
227
|
+
D(this, "$$l", {});
|
|
228
|
+
/** @type {Map<Function, Function>} Event listener unsubscribe functions */
|
|
229
|
+
D(this, "$$l_u", /* @__PURE__ */ new Map());
|
|
230
|
+
this.$$ctor = e, this.$$s = t, i && this.attachShadow({ mode: "open" });
|
|
231
|
+
}
|
|
232
|
+
addEventListener(e, t, i) {
|
|
233
|
+
if (this.$$l[e] = this.$$l[e] || [], this.$$l[e].push(t), this.$$c) {
|
|
234
|
+
const l = this.$$c.$on(e, t);
|
|
235
|
+
this.$$l_u.set(t, l);
|
|
236
|
+
}
|
|
237
|
+
super.addEventListener(e, t, i);
|
|
238
|
+
}
|
|
239
|
+
removeEventListener(e, t, i) {
|
|
240
|
+
if (super.removeEventListener(e, t, i), this.$$c) {
|
|
241
|
+
const l = this.$$l_u.get(t);
|
|
242
|
+
l && (l(), this.$$l_u.delete(t));
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
async connectedCallback() {
|
|
246
|
+
if (this.$$cn = !0, !this.$$c) {
|
|
247
|
+
let e = function(o) {
|
|
248
|
+
return () => {
|
|
249
|
+
let s;
|
|
250
|
+
return {
|
|
251
|
+
c: function() {
|
|
252
|
+
s = I("slot"), o !== "default" && c(s, "name", o);
|
|
253
|
+
},
|
|
254
|
+
/**
|
|
255
|
+
* @param {HTMLElement} target
|
|
256
|
+
* @param {HTMLElement} [anchor]
|
|
257
|
+
*/
|
|
258
|
+
m: function(a, N) {
|
|
259
|
+
j(a, s, N);
|
|
260
|
+
},
|
|
261
|
+
d: function(a) {
|
|
262
|
+
a && M(s);
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
};
|
|
266
|
+
};
|
|
267
|
+
if (await Promise.resolve(), !this.$$cn || this.$$c)
|
|
268
|
+
return;
|
|
269
|
+
const t = {}, i = ut(this);
|
|
270
|
+
for (const o of this.$$s)
|
|
271
|
+
o in i && (t[o] = [e(o)]);
|
|
272
|
+
for (const o of this.attributes) {
|
|
273
|
+
const s = this.$$g_p(o.name);
|
|
274
|
+
s in this.$$d || (this.$$d[s] = se(s, o.value, this.$$p_d, "toProp"));
|
|
275
|
+
}
|
|
276
|
+
for (const o in this.$$p_d)
|
|
277
|
+
!(o in this.$$d) && this[o] !== void 0 && (this.$$d[o] = this[o], delete this[o]);
|
|
278
|
+
this.$$c = new this.$$ctor({
|
|
279
|
+
target: this.shadowRoot || this,
|
|
280
|
+
props: {
|
|
281
|
+
...this.$$d,
|
|
282
|
+
$$slots: t,
|
|
283
|
+
$$scope: {
|
|
284
|
+
ctx: []
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
const l = () => {
|
|
289
|
+
this.$$r = !0;
|
|
290
|
+
for (const o in this.$$p_d)
|
|
291
|
+
if (this.$$d[o] = this.$$c.$$.ctx[this.$$c.$$.props[o]], this.$$p_d[o].reflect) {
|
|
292
|
+
const s = se(
|
|
293
|
+
o,
|
|
294
|
+
this.$$d[o],
|
|
295
|
+
this.$$p_d,
|
|
296
|
+
"toAttribute"
|
|
297
|
+
);
|
|
298
|
+
s == null ? this.removeAttribute(this.$$p_d[o].attribute || o) : this.setAttribute(this.$$p_d[o].attribute || o, s);
|
|
299
|
+
}
|
|
300
|
+
this.$$r = !1;
|
|
301
|
+
};
|
|
302
|
+
this.$$c.$$.after_update.push(l), l();
|
|
303
|
+
for (const o in this.$$l)
|
|
304
|
+
for (const s of this.$$l[o]) {
|
|
305
|
+
const u = this.$$c.$on(o, s);
|
|
306
|
+
this.$$l_u.set(s, u);
|
|
307
|
+
}
|
|
308
|
+
this.$$l = {};
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
// We don't need this when working within Svelte code, but for compatibility of people using this outside of Svelte
|
|
312
|
+
// and setting attributes through setAttribute etc, this is helpful
|
|
313
|
+
attributeChangedCallback(e, t, i) {
|
|
314
|
+
var l;
|
|
315
|
+
this.$$r || (e = this.$$g_p(e), this.$$d[e] = se(e, i, this.$$p_d, "toProp"), (l = this.$$c) == null || l.$set({ [e]: this.$$d[e] }));
|
|
316
|
+
}
|
|
317
|
+
disconnectedCallback() {
|
|
318
|
+
this.$$cn = !1, Promise.resolve().then(() => {
|
|
319
|
+
this.$$cn || (this.$$c.$destroy(), this.$$c = void 0);
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
$$g_p(e) {
|
|
323
|
+
return Object.keys(this.$$p_d).find(
|
|
324
|
+
(t) => this.$$p_d[t].attribute === e || !this.$$p_d[t].attribute && t.toLowerCase() === e
|
|
325
|
+
) || e;
|
|
326
|
+
}
|
|
327
|
+
});
|
|
328
|
+
function se(r, e, t, i) {
|
|
329
|
+
var o;
|
|
330
|
+
const l = (o = t[r]) == null ? void 0 : o.type;
|
|
331
|
+
if (e = l === "Boolean" && typeof e != "boolean" ? e != null : e, !i || !t[r])
|
|
332
|
+
return e;
|
|
333
|
+
if (i === "toAttribute")
|
|
334
|
+
switch (l) {
|
|
335
|
+
case "Object":
|
|
336
|
+
case "Array":
|
|
337
|
+
return e == null ? null : JSON.stringify(e);
|
|
338
|
+
case "Boolean":
|
|
339
|
+
return e ? "" : null;
|
|
340
|
+
case "Number":
|
|
341
|
+
return e ?? null;
|
|
342
|
+
default:
|
|
343
|
+
return e;
|
|
344
|
+
}
|
|
345
|
+
else
|
|
346
|
+
switch (l) {
|
|
347
|
+
case "Object":
|
|
348
|
+
case "Array":
|
|
349
|
+
return e && JSON.parse(e);
|
|
350
|
+
case "Boolean":
|
|
351
|
+
return e;
|
|
352
|
+
case "Number":
|
|
353
|
+
return e != null ? +e : e;
|
|
354
|
+
default:
|
|
355
|
+
return e;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
function Et(r, e, t, i, l, o) {
|
|
359
|
+
let s = class extends Be {
|
|
360
|
+
constructor() {
|
|
361
|
+
super(r, t, l), this.$$p_d = e;
|
|
362
|
+
}
|
|
363
|
+
static get observedAttributes() {
|
|
364
|
+
return Object.keys(e).map(
|
|
365
|
+
(u) => (e[u].attribute || u).toLowerCase()
|
|
366
|
+
);
|
|
367
|
+
}
|
|
368
|
+
};
|
|
369
|
+
return Object.keys(e).forEach((u) => {
|
|
370
|
+
Object.defineProperty(s.prototype, u, {
|
|
371
|
+
get() {
|
|
372
|
+
return this.$$c && u in this.$$c ? this.$$c[u] : this.$$d[u];
|
|
373
|
+
},
|
|
374
|
+
set(f) {
|
|
375
|
+
var a;
|
|
376
|
+
f = se(u, f, e), this.$$d[u] = f, (a = this.$$c) == null || a.$set({ [u]: f });
|
|
377
|
+
}
|
|
378
|
+
});
|
|
379
|
+
}), i.forEach((u) => {
|
|
380
|
+
Object.defineProperty(s.prototype, u, {
|
|
381
|
+
get() {
|
|
382
|
+
var f;
|
|
383
|
+
return (f = this.$$c) == null ? void 0 : f[u];
|
|
384
|
+
}
|
|
385
|
+
});
|
|
386
|
+
}), o && (s = o(s)), r.element = /** @type {any} */
|
|
387
|
+
s, s;
|
|
388
|
+
}
|
|
389
|
+
class $t {
|
|
390
|
+
constructor() {
|
|
391
|
+
/**
|
|
392
|
+
* ### PRIVATE API
|
|
393
|
+
*
|
|
394
|
+
* Do not use, may change at any time
|
|
395
|
+
*
|
|
396
|
+
* @type {any}
|
|
397
|
+
*/
|
|
398
|
+
D(this, "$$");
|
|
399
|
+
/**
|
|
400
|
+
* ### PRIVATE API
|
|
401
|
+
*
|
|
402
|
+
* Do not use, may change at any time
|
|
403
|
+
*
|
|
404
|
+
* @type {any}
|
|
405
|
+
*/
|
|
406
|
+
D(this, "$$set");
|
|
407
|
+
}
|
|
408
|
+
/** @returns {void} */
|
|
409
|
+
$destroy() {
|
|
410
|
+
vt(this, 1), this.$destroy = ee;
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* @template {Extract<keyof Events, string>} K
|
|
414
|
+
* @param {K} type
|
|
415
|
+
* @param {((e: Events[K]) => void) | null | undefined} callback
|
|
416
|
+
* @returns {() => void}
|
|
417
|
+
*/
|
|
418
|
+
$on(e, t) {
|
|
419
|
+
if (!He(t))
|
|
420
|
+
return ee;
|
|
421
|
+
const i = this.$$.callbacks[e] || (this.$$.callbacks[e] = []);
|
|
422
|
+
return i.push(t), () => {
|
|
423
|
+
const l = i.indexOf(t);
|
|
424
|
+
l !== -1 && i.splice(l, 1);
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* @param {Partial<Props>} props
|
|
429
|
+
* @returns {void}
|
|
430
|
+
*/
|
|
431
|
+
$set(e) {
|
|
432
|
+
this.$$set && !ot(e) && (this.$$.skip_bound = !0, this.$$set(e), this.$$.skip_bound = !1);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
const xt = "4";
|
|
436
|
+
typeof window < "u" && (window.__svelte || (window.__svelte = { v: /* @__PURE__ */ new Set() })).v.add(xt);
|
|
437
|
+
const Ct = new TextEncoder();
|
|
438
|
+
function Lt(r) {
|
|
439
|
+
return [...new Uint8Array(r)].map((e) => e.toString(16).padStart(2, "0")).join("");
|
|
440
|
+
}
|
|
441
|
+
async function It(r, e = "SHA-256", t = 1e5) {
|
|
442
|
+
const i = Date.now().toString(16);
|
|
443
|
+
r || (r = Math.round(Math.random() * t));
|
|
444
|
+
const l = await Ze(i, r, e);
|
|
445
|
+
return {
|
|
446
|
+
algorithm: e,
|
|
447
|
+
challenge: l,
|
|
448
|
+
salt: i,
|
|
449
|
+
signature: ""
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
async function Ze(r, e, t) {
|
|
453
|
+
return Lt(
|
|
454
|
+
await crypto.subtle.digest(
|
|
455
|
+
t.toUpperCase(),
|
|
456
|
+
Ct.encode(r + e)
|
|
457
|
+
)
|
|
458
|
+
);
|
|
459
|
+
}
|
|
460
|
+
function At(r, e, t = "SHA-256", i = 1e6, l = 0) {
|
|
461
|
+
const o = new AbortController(), s = Date.now();
|
|
462
|
+
return {
|
|
463
|
+
promise: (async () => {
|
|
464
|
+
for (let f = l; f <= i; f += 1) {
|
|
465
|
+
if (o.signal.aborted)
|
|
466
|
+
return null;
|
|
467
|
+
if (await Ze(e, f, t) === r)
|
|
468
|
+
return {
|
|
469
|
+
number: f,
|
|
470
|
+
took: Date.now() - s
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
return null;
|
|
474
|
+
})(),
|
|
475
|
+
controller: o
|
|
476
|
+
};
|
|
477
|
+
}
|
|
478
|
+
var b = /* @__PURE__ */ ((r) => (r.ERROR = "error", r.VERIFIED = "verified", r.VERIFYING = "verifying", r.UNVERIFIED = "unverified", r.EXPIRED = "expired", r))(b || {});
|
|
479
|
+
function je(r) {
|
|
480
|
+
let e, t, i;
|
|
481
|
+
return {
|
|
482
|
+
c() {
|
|
483
|
+
e = B("svg"), t = B("path"), i = B("path"), c(t, "d", "M12,1A11,11,0,1,0,23,12,11,11,0,0,0,12,1Zm0,19a8,8,0,1,1,8-8A8,8,0,0,1,12,20Z"), c(t, "fill", "currentColor"), c(t, "opacity", ".25"), c(i, "d", "M12,4a8,8,0,0,1,7.89,6.7A1.53,1.53,0,0,0,21.38,12h0a1.5,1.5,0,0,0,1.48-1.75,11,11,0,0,0-21.72,0A1.5,1.5,0,0,0,2.62,12h0a1.53,1.53,0,0,0,1.49-1.3A8,8,0,0,1,12,4Z"), c(i, "fill", "currentColor"), c(i, "class", "altcha-spinner"), c(e, "width", "24"), c(e, "height", "24"), c(e, "viewBox", "0 0 24 24"), c(e, "xmlns", "http://www.w3.org/2000/svg");
|
|
484
|
+
},
|
|
485
|
+
m(l, o) {
|
|
486
|
+
j(l, e, o), v(e, t), v(e, i);
|
|
487
|
+
},
|
|
488
|
+
d(l) {
|
|
489
|
+
l && M(e);
|
|
490
|
+
}
|
|
491
|
+
};
|
|
492
|
+
}
|
|
493
|
+
function Rt(r) {
|
|
494
|
+
let e, t = (
|
|
495
|
+
/*_strings*/
|
|
496
|
+
r[9].label + ""
|
|
497
|
+
), i;
|
|
498
|
+
return {
|
|
499
|
+
c() {
|
|
500
|
+
e = I("label"), c(e, "for", i = /*name*/
|
|
501
|
+
r[3] + "_checkbox");
|
|
502
|
+
},
|
|
503
|
+
m(l, o) {
|
|
504
|
+
j(l, e, o), e.innerHTML = t;
|
|
505
|
+
},
|
|
506
|
+
p(l, o) {
|
|
507
|
+
o[0] & /*_strings*/
|
|
508
|
+
512 && t !== (t = /*_strings*/
|
|
509
|
+
l[9].label + "") && (e.innerHTML = t), o[0] & /*name*/
|
|
510
|
+
8 && i !== (i = /*name*/
|
|
511
|
+
l[3] + "_checkbox") && c(e, "for", i);
|
|
512
|
+
},
|
|
513
|
+
d(l) {
|
|
514
|
+
l && M(e);
|
|
515
|
+
}
|
|
516
|
+
};
|
|
517
|
+
}
|
|
518
|
+
function Mt(r) {
|
|
519
|
+
let e, t = (
|
|
520
|
+
/*_strings*/
|
|
521
|
+
r[9].verifying + ""
|
|
522
|
+
);
|
|
523
|
+
return {
|
|
524
|
+
c() {
|
|
525
|
+
e = I("span");
|
|
526
|
+
},
|
|
527
|
+
m(i, l) {
|
|
528
|
+
j(i, e, l), e.innerHTML = t;
|
|
529
|
+
},
|
|
530
|
+
p(i, l) {
|
|
531
|
+
l[0] & /*_strings*/
|
|
532
|
+
512 && t !== (t = /*_strings*/
|
|
533
|
+
i[9].verifying + "") && (e.innerHTML = t);
|
|
534
|
+
},
|
|
535
|
+
d(i) {
|
|
536
|
+
i && M(e);
|
|
537
|
+
}
|
|
538
|
+
};
|
|
539
|
+
}
|
|
540
|
+
function Tt(r) {
|
|
541
|
+
let e, t = (
|
|
542
|
+
/*_strings*/
|
|
543
|
+
r[9].verified + ""
|
|
544
|
+
), i, l;
|
|
545
|
+
return {
|
|
546
|
+
c() {
|
|
547
|
+
e = I("span"), i = J(), l = I("input"), c(l, "type", "hidden"), c(
|
|
548
|
+
l,
|
|
549
|
+
"name",
|
|
550
|
+
/*name*/
|
|
551
|
+
r[3]
|
|
552
|
+
), l.value = /*payload*/
|
|
553
|
+
r[4];
|
|
554
|
+
},
|
|
555
|
+
m(o, s) {
|
|
556
|
+
j(o, e, s), e.innerHTML = t, j(o, i, s), j(o, l, s);
|
|
557
|
+
},
|
|
558
|
+
p(o, s) {
|
|
559
|
+
s[0] & /*_strings*/
|
|
560
|
+
512 && t !== (t = /*_strings*/
|
|
561
|
+
o[9].verified + "") && (e.innerHTML = t), s[0] & /*name*/
|
|
562
|
+
8 && c(
|
|
563
|
+
l,
|
|
564
|
+
"name",
|
|
565
|
+
/*name*/
|
|
566
|
+
o[3]
|
|
567
|
+
), s[0] & /*payload*/
|
|
568
|
+
16 && (l.value = /*payload*/
|
|
569
|
+
o[4]);
|
|
570
|
+
},
|
|
571
|
+
d(o) {
|
|
572
|
+
o && (M(e), M(i), M(l));
|
|
573
|
+
}
|
|
574
|
+
};
|
|
575
|
+
}
|
|
576
|
+
function Ne(r) {
|
|
577
|
+
let e, t, i, l, o, s, u;
|
|
578
|
+
return {
|
|
579
|
+
c() {
|
|
580
|
+
e = I("div"), t = I("a"), i = B("svg"), l = B("path"), o = B("path"), s = B("path"), c(l, "d", "M2.33955 16.4279C5.88954 20.6586 12.1971 21.2105 16.4279 17.6604C18.4699 15.947 19.6548 13.5911 19.9352 11.1365L17.9886 10.4279C17.8738 12.5624 16.909 14.6459 15.1423 16.1284C11.7577 18.9684 6.71167 18.5269 3.87164 15.1423C1.03163 11.7577 1.4731 6.71166 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577C16.9767 5.86872 17.5322 7.02798 17.804 8.2324L19.9522 9.01429C19.7622 7.07737 19.0059 5.17558 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956C-0.658625 5.88958 -1.21046 12.1971 2.33955 16.4279Z"), c(l, "fill", "currentColor"), c(o, "d", "M3.57212 2.33956C1.65755 3.94607 0.496389 6.11731 0.12782 8.40523L2.04639 9.13961C2.26047 7.15832 3.21057 5.25375 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577L13.8302 6.78606L19.9633 9.13364C19.7929 7.15555 19.0335 5.20847 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956Z"), c(o, "fill", "currentColor"), c(s, "d", "M7 10H5C5 12.7614 7.23858 15 10 15C12.7614 15 15 12.7614 15 10H13C13 11.6569 11.6569 13 10 13C8.3431 13 7 11.6569 7 10Z"), c(s, "fill", "currentColor"), c(i, "width", "22"), c(i, "height", "22"), c(i, "viewBox", "0 0 20 20"), c(i, "fill", "none"), c(i, "xmlns", "http://www.w3.org/2000/svg"), c(t, "href", qe), c(t, "target", "_blank"), c(t, "class", "altcha-logo"), c(t, "aria-label", u = /*_strings*/
|
|
581
|
+
r[9].ariaLinkLabel);
|
|
582
|
+
},
|
|
583
|
+
m(f, a) {
|
|
584
|
+
j(f, e, a), v(e, t), v(t, i), v(i, l), v(i, o), v(i, s);
|
|
585
|
+
},
|
|
586
|
+
p(f, a) {
|
|
587
|
+
a[0] & /*_strings*/
|
|
588
|
+
512 && u !== (u = /*_strings*/
|
|
589
|
+
f[9].ariaLinkLabel) && c(t, "aria-label", u);
|
|
590
|
+
},
|
|
591
|
+
d(f) {
|
|
592
|
+
f && M(e);
|
|
593
|
+
}
|
|
594
|
+
};
|
|
595
|
+
}
|
|
596
|
+
function Se(r) {
|
|
597
|
+
let e, t, i, l;
|
|
598
|
+
function o(f, a) {
|
|
599
|
+
return (
|
|
600
|
+
/*state*/
|
|
601
|
+
f[5] === b.EXPIRED ? Nt : jt
|
|
602
|
+
);
|
|
603
|
+
}
|
|
604
|
+
let s = o(r), u = s(r);
|
|
605
|
+
return {
|
|
606
|
+
c() {
|
|
607
|
+
e = I("div"), t = B("svg"), i = B("path"), l = J(), u.c(), c(i, "stroke-linecap", "round"), c(i, "stroke-linejoin", "round"), c(i, "d", "M6 18L18 6M6 6l12 12"), c(t, "width", "14"), c(t, "height", "14"), c(t, "xmlns", "http://www.w3.org/2000/svg"), c(t, "fill", "none"), c(t, "viewBox", "0 0 24 24"), c(t, "stroke-width", "1.5"), c(t, "stroke", "currentColor"), c(e, "class", "altcha-error");
|
|
608
|
+
},
|
|
609
|
+
m(f, a) {
|
|
610
|
+
j(f, e, a), v(e, t), v(t, i), v(e, l), u.m(e, null);
|
|
611
|
+
},
|
|
612
|
+
p(f, a) {
|
|
613
|
+
s === (s = o(f)) && u ? u.p(f, a) : (u.d(1), u = s(f), u && (u.c(), u.m(e, null)));
|
|
614
|
+
},
|
|
615
|
+
d(f) {
|
|
616
|
+
f && M(e), u.d();
|
|
617
|
+
}
|
|
618
|
+
};
|
|
619
|
+
}
|
|
620
|
+
function jt(r) {
|
|
621
|
+
let e, t = (
|
|
622
|
+
/*_strings*/
|
|
623
|
+
r[9].error + ""
|
|
624
|
+
);
|
|
625
|
+
return {
|
|
626
|
+
c() {
|
|
627
|
+
e = I("div"), c(
|
|
628
|
+
e,
|
|
629
|
+
"title",
|
|
630
|
+
/*error*/
|
|
631
|
+
r[8]
|
|
632
|
+
);
|
|
633
|
+
},
|
|
634
|
+
m(i, l) {
|
|
635
|
+
j(i, e, l), e.innerHTML = t;
|
|
636
|
+
},
|
|
637
|
+
p(i, l) {
|
|
638
|
+
l[0] & /*_strings*/
|
|
639
|
+
512 && t !== (t = /*_strings*/
|
|
640
|
+
i[9].error + "") && (e.innerHTML = t), l[0] & /*error*/
|
|
641
|
+
256 && c(
|
|
642
|
+
e,
|
|
643
|
+
"title",
|
|
644
|
+
/*error*/
|
|
645
|
+
i[8]
|
|
646
|
+
);
|
|
647
|
+
},
|
|
648
|
+
d(i) {
|
|
649
|
+
i && M(e);
|
|
650
|
+
}
|
|
651
|
+
};
|
|
652
|
+
}
|
|
653
|
+
function Nt(r) {
|
|
654
|
+
let e, t = (
|
|
655
|
+
/*_strings*/
|
|
656
|
+
r[9].expired + ""
|
|
657
|
+
);
|
|
658
|
+
return {
|
|
659
|
+
c() {
|
|
660
|
+
e = I("div"), c(
|
|
661
|
+
e,
|
|
662
|
+
"title",
|
|
663
|
+
/*error*/
|
|
664
|
+
r[8]
|
|
665
|
+
);
|
|
666
|
+
},
|
|
667
|
+
m(i, l) {
|
|
668
|
+
j(i, e, l), e.innerHTML = t;
|
|
669
|
+
},
|
|
670
|
+
p(i, l) {
|
|
671
|
+
l[0] & /*_strings*/
|
|
672
|
+
512 && t !== (t = /*_strings*/
|
|
673
|
+
i[9].expired + "") && (e.innerHTML = t), l[0] & /*error*/
|
|
674
|
+
256 && c(
|
|
675
|
+
e,
|
|
676
|
+
"title",
|
|
677
|
+
/*error*/
|
|
678
|
+
i[8]
|
|
679
|
+
);
|
|
680
|
+
},
|
|
681
|
+
d(i) {
|
|
682
|
+
i && M(e);
|
|
683
|
+
}
|
|
684
|
+
};
|
|
685
|
+
}
|
|
686
|
+
function De(r) {
|
|
687
|
+
let e, t, i = (
|
|
688
|
+
/*_strings*/
|
|
689
|
+
r[9].footer + ""
|
|
690
|
+
);
|
|
691
|
+
return {
|
|
692
|
+
c() {
|
|
693
|
+
e = I("div"), t = I("div"), c(e, "class", "altcha-footer");
|
|
694
|
+
},
|
|
695
|
+
m(l, o) {
|
|
696
|
+
j(l, e, o), v(e, t), t.innerHTML = i;
|
|
697
|
+
},
|
|
698
|
+
p(l, o) {
|
|
699
|
+
o[0] & /*_strings*/
|
|
700
|
+
512 && i !== (i = /*_strings*/
|
|
701
|
+
l[9].footer + "") && (t.innerHTML = i);
|
|
702
|
+
},
|
|
703
|
+
d(l) {
|
|
704
|
+
l && M(e);
|
|
705
|
+
}
|
|
706
|
+
};
|
|
707
|
+
}
|
|
708
|
+
function St(r) {
|
|
709
|
+
let e, t, i, l, o, s, u, f, a, N, C, V, O, F, k = (
|
|
710
|
+
/*state*/
|
|
711
|
+
r[5] === b.VERIFYING && je()
|
|
712
|
+
);
|
|
713
|
+
function q(d, A) {
|
|
714
|
+
return (
|
|
715
|
+
/*state*/
|
|
716
|
+
d[5] === b.VERIFIED ? Tt : (
|
|
717
|
+
/*state*/
|
|
718
|
+
d[5] === b.VERIFYING ? Mt : Rt
|
|
719
|
+
)
|
|
720
|
+
);
|
|
721
|
+
}
|
|
722
|
+
let U = q(r), p = U(r), E = (
|
|
723
|
+
/*hidelogo*/
|
|
724
|
+
r[2] !== !0 && Ne(r)
|
|
725
|
+
), g = (
|
|
726
|
+
/*error*/
|
|
727
|
+
(r[8] || /*state*/
|
|
728
|
+
r[5] === b.EXPIRED) && Se(r)
|
|
729
|
+
), _ = (
|
|
730
|
+
/*_strings*/
|
|
731
|
+
r[9].footer && /*hidefooter*/
|
|
732
|
+
r[1] !== !0 && De(r)
|
|
733
|
+
);
|
|
734
|
+
return {
|
|
735
|
+
c() {
|
|
736
|
+
e = I("div"), t = I("div"), k && k.c(), i = J(), l = I("div"), o = I("input"), f = J(), a = I("div"), p.c(), N = J(), E && E.c(), C = J(), g && g.c(), V = J(), _ && _.c(), c(o, "type", "checkbox"), c(o, "id", s = /*name*/
|
|
737
|
+
r[3] + "_checkbox"), o.required = u = /*auto*/
|
|
738
|
+
r[0] !== "onsubmit", c(l, "class", "altcha-checkbox"), Me(
|
|
739
|
+
l,
|
|
740
|
+
"altcha-hidden",
|
|
741
|
+
/*state*/
|
|
742
|
+
r[5] === b.VERIFYING
|
|
743
|
+
), c(a, "class", "altcha-label"), c(t, "class", "altcha-main"), c(e, "class", "altcha"), c(
|
|
744
|
+
e,
|
|
745
|
+
"data-state",
|
|
746
|
+
/*state*/
|
|
747
|
+
r[5]
|
|
748
|
+
);
|
|
749
|
+
},
|
|
750
|
+
m(d, A) {
|
|
751
|
+
j(d, e, A), v(e, t), k && k.m(t, null), v(t, i), v(t, l), v(l, o), o.checked = /*checked*/
|
|
752
|
+
r[6], v(t, f), v(t, a), p.m(a, null), v(t, N), E && E.m(t, null), v(e, C), g && g.m(e, null), v(e, V), _ && _.m(e, null), r[31](e), O || (F = [
|
|
753
|
+
ue(
|
|
754
|
+
o,
|
|
755
|
+
"change",
|
|
756
|
+
/*input_change_handler*/
|
|
757
|
+
r[30]
|
|
758
|
+
),
|
|
759
|
+
ue(
|
|
760
|
+
o,
|
|
761
|
+
"change",
|
|
762
|
+
/*onCheckedChange*/
|
|
763
|
+
r[10]
|
|
764
|
+
),
|
|
765
|
+
ue(
|
|
766
|
+
o,
|
|
767
|
+
"invalid",
|
|
768
|
+
/*onInvalid*/
|
|
769
|
+
r[11]
|
|
770
|
+
)
|
|
771
|
+
], O = !0);
|
|
772
|
+
},
|
|
773
|
+
p(d, A) {
|
|
774
|
+
/*state*/
|
|
775
|
+
d[5] === b.VERIFYING ? k || (k = je(), k.c(), k.m(t, i)) : k && (k.d(1), k = null), A[0] & /*name*/
|
|
776
|
+
8 && s !== (s = /*name*/
|
|
777
|
+
d[3] + "_checkbox") && c(o, "id", s), A[0] & /*auto*/
|
|
778
|
+
1 && u !== (u = /*auto*/
|
|
779
|
+
d[0] !== "onsubmit") && (o.required = u), A[0] & /*checked*/
|
|
780
|
+
64 && (o.checked = /*checked*/
|
|
781
|
+
d[6]), A[0] & /*state*/
|
|
782
|
+
32 && Me(
|
|
783
|
+
l,
|
|
784
|
+
"altcha-hidden",
|
|
785
|
+
/*state*/
|
|
786
|
+
d[5] === b.VERIFYING
|
|
787
|
+
), U === (U = q(d)) && p ? p.p(d, A) : (p.d(1), p = U(d), p && (p.c(), p.m(a, null))), /*hidelogo*/
|
|
788
|
+
d[2] !== !0 ? E ? E.p(d, A) : (E = Ne(d), E.c(), E.m(t, null)) : E && (E.d(1), E = null), /*error*/
|
|
789
|
+
d[8] || /*state*/
|
|
790
|
+
d[5] === b.EXPIRED ? g ? g.p(d, A) : (g = Se(d), g.c(), g.m(e, V)) : g && (g.d(1), g = null), /*_strings*/
|
|
791
|
+
d[9].footer && /*hidefooter*/
|
|
792
|
+
d[1] !== !0 ? _ ? _.p(d, A) : (_ = De(d), _.c(), _.m(e, null)) : _ && (_.d(1), _ = null), A[0] & /*state*/
|
|
793
|
+
32 && c(
|
|
794
|
+
e,
|
|
795
|
+
"data-state",
|
|
796
|
+
/*state*/
|
|
797
|
+
d[5]
|
|
798
|
+
);
|
|
799
|
+
},
|
|
800
|
+
i: ee,
|
|
801
|
+
o: ee,
|
|
802
|
+
d(d) {
|
|
803
|
+
d && M(e), k && k.d(), p.d(), E && E.d(), g && g.d(), _ && _.d(), r[31](null), O = !1, re(F);
|
|
804
|
+
}
|
|
805
|
+
};
|
|
806
|
+
}
|
|
807
|
+
const Ve = "Visit Altcha.org", qe = "https://altcha.org/";
|
|
808
|
+
function Oe(r) {
|
|
809
|
+
return JSON.parse(r);
|
|
810
|
+
}
|
|
811
|
+
function Dt() {
|
|
812
|
+
try {
|
|
813
|
+
return Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
814
|
+
} catch {
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
function Vt(r, e, t) {
|
|
818
|
+
var xe, Ce;
|
|
819
|
+
let i, l, o, { auto: s = void 0 } = e, { blockspam: u = void 0 } = e, { challengeurl: f = void 0 } = e, { challengejson: a = void 0 } = e, { debug: N = !1 } = e, { expire: C = void 0 } = e, { hidefooter: V = !1 } = e, { hidelogo: O = !1 } = e, { name: F = "altcha" } = e, { maxnumber: k = 1e6 } = e, { mockerror: q = !1 } = e, { refetchonexpire: U = !0 } = e, { spamfilter: p = !1 } = e, { strings: E = void 0 } = e, { test: g = !1 } = e, { verifyurl: _ = void 0 } = e, { workers: d = Math.min(16, navigator.hardwareConcurrency || 8) } = e, { workerurl: A = void 0 } = e;
|
|
820
|
+
const ce = dt(), be = ["SHA-256", "SHA-384", "SHA-512"], _e = (Ce = (xe = document.documentElement.lang) == null ? void 0 : xe.split("-")) == null ? void 0 : Ce[0];
|
|
821
|
+
let Z = !1, ne, m = null, fe = null, G = null, P = b.UNVERIFIED, H = null;
|
|
822
|
+
ht(() => {
|
|
823
|
+
m && (m.removeEventListener("submit", ye), m.removeEventListener("reset", ve), m.removeEventListener("focusin", we), m = null), H && (clearTimeout(H), H = null);
|
|
824
|
+
}), at(() => {
|
|
825
|
+
L("mounted", "0.5.0"), L("workers", d), g && L("using test mode"), C && ie(C), s !== void 0 && L("auto", s), m = ne.closest("form"), m && (m.addEventListener("submit", ye), m.addEventListener("reset", ve), s === "onfocus" && m.addEventListener("focusin", we)), s === "onload" && X();
|
|
826
|
+
});
|
|
827
|
+
function L(...n) {
|
|
828
|
+
(N || n.some((h) => h instanceof Error)) && console[n[0] instanceof Error ? "error" : "log"]("ALTCHA", ...n);
|
|
829
|
+
}
|
|
830
|
+
function we(n) {
|
|
831
|
+
P === b.UNVERIFIED && X();
|
|
832
|
+
}
|
|
833
|
+
function ye(n) {
|
|
834
|
+
m && s === "onsubmit" && P === b.UNVERIFIED && (n.preventDefault(), n.stopPropagation(), X().then(() => {
|
|
835
|
+
m == null || m.requestSubmit();
|
|
836
|
+
}));
|
|
837
|
+
}
|
|
838
|
+
function ve() {
|
|
839
|
+
le();
|
|
840
|
+
}
|
|
841
|
+
function ke(n, h) {
|
|
842
|
+
return btoa(JSON.stringify({
|
|
843
|
+
algorithm: n.algorithm,
|
|
844
|
+
challenge: n.challenge,
|
|
845
|
+
number: h.number,
|
|
846
|
+
salt: n.salt,
|
|
847
|
+
signature: n.signature,
|
|
848
|
+
test: g ? !0 : void 0,
|
|
849
|
+
took: h.took
|
|
850
|
+
}));
|
|
851
|
+
}
|
|
852
|
+
function pe(n) {
|
|
853
|
+
if (!n.algorithm)
|
|
854
|
+
throw new Error("Invalid challenge. Property algorithm is missing.");
|
|
855
|
+
if (n.signature === void 0)
|
|
856
|
+
throw new Error("Invalid challenge. Property signature is missing.");
|
|
857
|
+
if (!be.includes(n.algorithm.toUpperCase()))
|
|
858
|
+
throw new Error(`Unknown algorithm value. Allowed values: ${be.join(", ")}`);
|
|
859
|
+
if (!n.challenge || n.challenge.length < 40)
|
|
860
|
+
throw new Error("Challenge is too short. Min. 40 chars.");
|
|
861
|
+
if (!n.salt || n.salt.length < 10)
|
|
862
|
+
throw new Error("Salt is too short. Min. 10 chars.");
|
|
863
|
+
}
|
|
864
|
+
async function Ge() {
|
|
865
|
+
var n;
|
|
866
|
+
if (q)
|
|
867
|
+
throw L("mocking error"), new Error("Mocked error.");
|
|
868
|
+
if (i)
|
|
869
|
+
return L("using provided json data"), i;
|
|
870
|
+
if (g)
|
|
871
|
+
return L("generating test challenge", { test: g }), It(typeof g != "boolean" ? +g : void 0);
|
|
872
|
+
{
|
|
873
|
+
if (!f)
|
|
874
|
+
throw new Error("Attribute challengeurl not set.");
|
|
875
|
+
L("fetching challenge from", f);
|
|
876
|
+
const h = await fetch(f, {
|
|
877
|
+
headers: {
|
|
878
|
+
"x-altcha-spam-filter": p ? "1" : "0"
|
|
879
|
+
}
|
|
880
|
+
});
|
|
881
|
+
if (h.status !== 200)
|
|
882
|
+
throw new Error(`Server responded with ${h.status}.`);
|
|
883
|
+
const w = h.headers.get("Expires"), R = h.headers.get("X-Altcha-Config"), T = await h.json(), S = new URLSearchParams((n = T.salt.split("?")) == null ? void 0 : n[1]), Y = S.get("expires") || S.get("expire");
|
|
884
|
+
if (Y) {
|
|
885
|
+
const $ = new Date(+Y * 1e3), x = isNaN($.getTime()) ? 0 : $.getTime() - Date.now();
|
|
886
|
+
x > 0 && ie(x);
|
|
887
|
+
}
|
|
888
|
+
if (R)
|
|
889
|
+
try {
|
|
890
|
+
const $ = JSON.parse(R);
|
|
891
|
+
$ && typeof $ == "object" && ($.verifyurl && ($.verifyurl = new URL($.verifyurl, new URL(f)).toString()), $e($));
|
|
892
|
+
} catch ($) {
|
|
893
|
+
L("unable to configure from X-Altcha-Config", $);
|
|
894
|
+
}
|
|
895
|
+
if (!C && (w != null && w.length)) {
|
|
896
|
+
const $ = Date.parse(w);
|
|
897
|
+
if ($) {
|
|
898
|
+
const x = $ - Date.now();
|
|
899
|
+
x > 0 && ie(x);
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
return T;
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
function Ee() {
|
|
906
|
+
f && U && P === b.VERIFIED ? X() : le(b.EXPIRED, o.expired);
|
|
907
|
+
}
|
|
908
|
+
async function Xe(n) {
|
|
909
|
+
let h = null;
|
|
910
|
+
if ("Worker" in window) {
|
|
911
|
+
try {
|
|
912
|
+
h = await Ye(n.challenge, n.salt, n.algorithm, n.maxnumber);
|
|
913
|
+
} catch (w) {
|
|
914
|
+
L(w);
|
|
915
|
+
}
|
|
916
|
+
if ((h == null ? void 0 : h.number) !== void 0)
|
|
917
|
+
return { data: n, solution: h };
|
|
918
|
+
}
|
|
919
|
+
return {
|
|
920
|
+
data: n,
|
|
921
|
+
solution: await At(n.challenge, n.salt, n.algorithm, n.maxnumber || k).promise
|
|
922
|
+
};
|
|
923
|
+
}
|
|
924
|
+
async function Ye(n, h, w, R = typeof g == "number" ? g : k, T = Math.ceil(d)) {
|
|
925
|
+
const S = [];
|
|
926
|
+
if (T < 1)
|
|
927
|
+
throw new Error("Wrong number of workers configured.");
|
|
928
|
+
if (T > 16)
|
|
929
|
+
throw new Error("Too many workers. Max. 16 allowed workers.");
|
|
930
|
+
for (let x = 0; x < T; x++)
|
|
931
|
+
S.push(createAltchaWorker(A));
|
|
932
|
+
const Y = Math.ceil(R / T), $ = await Promise.all(S.map((x, oe) => {
|
|
933
|
+
const Le = oe * Y;
|
|
934
|
+
return new Promise((rt) => {
|
|
935
|
+
x.addEventListener("message", (Ie) => {
|
|
936
|
+
if (Ie.data)
|
|
937
|
+
for (const Ae of S)
|
|
938
|
+
Ae !== x && Ae.postMessage({ type: "abort" });
|
|
939
|
+
rt(Ie.data);
|
|
940
|
+
}), x.postMessage({
|
|
941
|
+
payload: {
|
|
942
|
+
alg: w,
|
|
943
|
+
challenge: n,
|
|
944
|
+
max: Le + Y,
|
|
945
|
+
salt: h,
|
|
946
|
+
start: Le
|
|
947
|
+
},
|
|
948
|
+
type: "work"
|
|
949
|
+
});
|
|
950
|
+
});
|
|
951
|
+
}));
|
|
952
|
+
for (const x of S)
|
|
953
|
+
x.terminate();
|
|
954
|
+
return $.find((x) => !!x) || null;
|
|
955
|
+
}
|
|
956
|
+
function Je() {
|
|
957
|
+
[b.UNVERIFIED, b.ERROR, b.EXPIRED].includes(P) ? p && (m == null ? void 0 : m.reportValidity()) === !1 ? t(6, Z = !1) : X() : t(6, Z = !0);
|
|
958
|
+
}
|
|
959
|
+
function We() {
|
|
960
|
+
P === b.VERIFYING && alert(o.waitAlert);
|
|
961
|
+
}
|
|
962
|
+
function ie(n) {
|
|
963
|
+
L("expire", n), H && (clearTimeout(H), H = null), n < 1 ? Ee() : H = setTimeout(Ee, n);
|
|
964
|
+
}
|
|
965
|
+
function ze(n) {
|
|
966
|
+
var w;
|
|
967
|
+
const h = m == null ? void 0 : m.querySelector(typeof n == "string" ? `input[name="${n}"]` : 'input[type="email"]:not([data-no-spamfilter])');
|
|
968
|
+
return ((w = h == null ? void 0 : h.value) == null ? void 0 : w.slice(h.value.indexOf("@"))) || void 0;
|
|
969
|
+
}
|
|
970
|
+
function Ke(n) {
|
|
971
|
+
return [
|
|
972
|
+
...(m == null ? void 0 : m.querySelectorAll(n != null && n.length ? n.map((w) => `input[name="${w}"]`).join(", ") : 'input[type="email"]:not([data-no-spamfilter]), input[type="text"]:not([data-no-spamfilter]), textarea:not([data-no-spamfilter])')) || []
|
|
973
|
+
].reduce(
|
|
974
|
+
(w, R) => {
|
|
975
|
+
const T = R.name, S = R.value.trim();
|
|
976
|
+
return T && S && (w[T] = S), w;
|
|
977
|
+
},
|
|
978
|
+
{}
|
|
979
|
+
);
|
|
980
|
+
}
|
|
981
|
+
async function Qe(n) {
|
|
982
|
+
if (!_)
|
|
983
|
+
throw new Error("Attribute verifyurl not set.");
|
|
984
|
+
L("requesting server verification from", _);
|
|
985
|
+
const h = { payload: n };
|
|
986
|
+
if (p) {
|
|
987
|
+
const { email: T, expectedLanguages: S, expectedCountries: Y, fields: $, ipAddress: x, timeZone: oe } = typeof p == "object" ? p : {
|
|
988
|
+
email: void 0,
|
|
989
|
+
expectedCountries: void 0,
|
|
990
|
+
expectedLanguages: void 0,
|
|
991
|
+
fields: void 0,
|
|
992
|
+
ipAddress: void 0,
|
|
993
|
+
timeZone: void 0
|
|
994
|
+
};
|
|
995
|
+
h.ipAddress = x === !1 ? void 0 : x || "auto", h.email = T === !1 ? void 0 : ze(T), h.fields = $ === !1 ? void 0 : Ke($), h.timeZone = oe === !1 ? void 0 : oe || Dt(), h.expectedCountries = Y, h.expectedLanguages = S || (_e ? [_e] : void 0);
|
|
996
|
+
}
|
|
997
|
+
const w = await fetch(_, {
|
|
998
|
+
body: JSON.stringify(h),
|
|
999
|
+
headers: { "content-type": "application/json" },
|
|
1000
|
+
method: "POST"
|
|
1001
|
+
});
|
|
1002
|
+
if (w.status !== 200)
|
|
1003
|
+
throw new Error(`Server responded with ${w.status}.`);
|
|
1004
|
+
const R = await w.json();
|
|
1005
|
+
if (R != null && R.payload && t(4, G = R.payload), ce("serververification", R), u && R.classification === "BAD")
|
|
1006
|
+
throw new Error("SpamFilter returned negative classification.");
|
|
1007
|
+
}
|
|
1008
|
+
function $e(n) {
|
|
1009
|
+
n.auto !== void 0 && (t(0, s = n.auto), s === "onload" && X()), n.expire !== void 0 && (ie(n.expire), t(14, C = n.expire)), n.challenge && (pe(n.challenge), i = n.challenge), n.challengeurl !== void 0 && t(12, f = n.challengeurl), n.debug !== void 0 && t(13, N = !!n.debug), n.hidefooter !== void 0 && t(1, V = !!n.hidefooter), n.hidelogo !== void 0 && t(2, O = !!n.hidelogo), n.maxnumber !== void 0 && t(15, k = +n.maxnumber), n.mockerror !== void 0 && t(16, q = !!n.mockerror), n.name !== void 0 && t(3, F = n.name), n.refetchonexpire !== void 0 && t(17, U = !!n.refetchonexpire), n.spamfilter !== void 0 && t(18, p = typeof n.spamfilter == "object" ? n.spamfilter : !!n.spamfilter), n.strings && t(29, l = n.strings), n.test !== void 0 && t(19, g = typeof n.test == "number" ? n.test : !!n.test), n.verifyurl !== void 0 && t(20, _ = n.verifyurl), n.workers !== void 0 && t(21, d = +n.workers);
|
|
1010
|
+
}
|
|
1011
|
+
function le(n = b.UNVERIFIED, h = null) {
|
|
1012
|
+
H && (clearTimeout(H), H = null), t(6, Z = !1), t(8, fe = h), t(4, G = null), t(5, P = n);
|
|
1013
|
+
}
|
|
1014
|
+
async function X() {
|
|
1015
|
+
return le(b.VERIFYING), Ge().then((n) => (pe(n), L("challenge", n), Xe(n))).then(({ data: n, solution: h }) => {
|
|
1016
|
+
if (L("solution", h), (h == null ? void 0 : h.number) !== void 0) {
|
|
1017
|
+
if (_)
|
|
1018
|
+
return Qe(ke(n, h));
|
|
1019
|
+
t(4, G = ke(n, h)), L("payload", G);
|
|
1020
|
+
} else
|
|
1021
|
+
throw L("Unable to find a solution. Ensure that the 'maxnumber' attribute is greater than the randomly generated number."), new Error("Unexpected result returned.");
|
|
1022
|
+
}).then(() => {
|
|
1023
|
+
gt().then(() => {
|
|
1024
|
+
t(5, P = b.VERIFIED), t(6, Z = !0), L("verified"), ce("verified", { payload: G });
|
|
1025
|
+
});
|
|
1026
|
+
}).catch((n) => {
|
|
1027
|
+
L(n), t(5, P = b.ERROR), t(6, Z = !1), t(8, fe = n.message);
|
|
1028
|
+
});
|
|
1029
|
+
}
|
|
1030
|
+
function et() {
|
|
1031
|
+
Z = this.checked, t(6, Z);
|
|
1032
|
+
}
|
|
1033
|
+
function tt(n) {
|
|
1034
|
+
he[n ? "unshift" : "push"](() => {
|
|
1035
|
+
ne = n, t(7, ne);
|
|
1036
|
+
});
|
|
1037
|
+
}
|
|
1038
|
+
return r.$$set = (n) => {
|
|
1039
|
+
"auto" in n && t(0, s = n.auto), "blockspam" in n && t(22, u = n.blockspam), "challengeurl" in n && t(12, f = n.challengeurl), "challengejson" in n && t(23, a = n.challengejson), "debug" in n && t(13, N = n.debug), "expire" in n && t(14, C = n.expire), "hidefooter" in n && t(1, V = n.hidefooter), "hidelogo" in n && t(2, O = n.hidelogo), "name" in n && t(3, F = n.name), "maxnumber" in n && t(15, k = n.maxnumber), "mockerror" in n && t(16, q = n.mockerror), "refetchonexpire" in n && t(17, U = n.refetchonexpire), "spamfilter" in n && t(18, p = n.spamfilter), "strings" in n && t(24, E = n.strings), "test" in n && t(19, g = n.test), "verifyurl" in n && t(20, _ = n.verifyurl), "workers" in n && t(21, d = n.workers), "workerurl" in n && t(25, A = n.workerurl);
|
|
1040
|
+
}, r.$$.update = () => {
|
|
1041
|
+
r.$$.dirty[0] & /*challengejson*/
|
|
1042
|
+
8388608 && (i = a ? Oe(a) : void 0), r.$$.dirty[0] & /*strings*/
|
|
1043
|
+
16777216 && t(29, l = E ? Oe(E) : {}), r.$$.dirty[0] & /*parsedStrings*/
|
|
1044
|
+
536870912 && t(9, o = {
|
|
1045
|
+
ariaLinkLabel: Ve,
|
|
1046
|
+
error: "Verification failed. Try again later.",
|
|
1047
|
+
expired: "Verification expired. Try again.",
|
|
1048
|
+
footer: `Protected by <a href="${qe}" target="_blank" aria-label="${l.ariaLinkLabel || Ve}">ALTCHA</a>`,
|
|
1049
|
+
label: "I'm not a robot",
|
|
1050
|
+
verified: "Verified",
|
|
1051
|
+
verifying: "Verifying...",
|
|
1052
|
+
waitAlert: "Verifying... please wait.",
|
|
1053
|
+
...l
|
|
1054
|
+
}), r.$$.dirty[0] & /*payload, state*/
|
|
1055
|
+
48 && ce("statechange", { payload: G, state: P });
|
|
1056
|
+
}, [
|
|
1057
|
+
s,
|
|
1058
|
+
V,
|
|
1059
|
+
O,
|
|
1060
|
+
F,
|
|
1061
|
+
G,
|
|
1062
|
+
P,
|
|
1063
|
+
Z,
|
|
1064
|
+
ne,
|
|
1065
|
+
fe,
|
|
1066
|
+
o,
|
|
1067
|
+
Je,
|
|
1068
|
+
We,
|
|
1069
|
+
f,
|
|
1070
|
+
N,
|
|
1071
|
+
C,
|
|
1072
|
+
k,
|
|
1073
|
+
q,
|
|
1074
|
+
U,
|
|
1075
|
+
p,
|
|
1076
|
+
g,
|
|
1077
|
+
_,
|
|
1078
|
+
d,
|
|
1079
|
+
u,
|
|
1080
|
+
a,
|
|
1081
|
+
E,
|
|
1082
|
+
A,
|
|
1083
|
+
$e,
|
|
1084
|
+
le,
|
|
1085
|
+
X,
|
|
1086
|
+
l,
|
|
1087
|
+
et,
|
|
1088
|
+
tt
|
|
1089
|
+
];
|
|
1090
|
+
}
|
|
1091
|
+
class Ot extends $t {
|
|
1092
|
+
constructor(e) {
|
|
1093
|
+
super(), pt(
|
|
1094
|
+
this,
|
|
1095
|
+
e,
|
|
1096
|
+
Vt,
|
|
1097
|
+
St,
|
|
1098
|
+
lt,
|
|
1099
|
+
{
|
|
1100
|
+
auto: 0,
|
|
1101
|
+
blockspam: 22,
|
|
1102
|
+
challengeurl: 12,
|
|
1103
|
+
challengejson: 23,
|
|
1104
|
+
debug: 13,
|
|
1105
|
+
expire: 14,
|
|
1106
|
+
hidefooter: 1,
|
|
1107
|
+
hidelogo: 2,
|
|
1108
|
+
name: 3,
|
|
1109
|
+
maxnumber: 15,
|
|
1110
|
+
mockerror: 16,
|
|
1111
|
+
refetchonexpire: 17,
|
|
1112
|
+
spamfilter: 18,
|
|
1113
|
+
strings: 24,
|
|
1114
|
+
test: 19,
|
|
1115
|
+
verifyurl: 20,
|
|
1116
|
+
workers: 21,
|
|
1117
|
+
workerurl: 25,
|
|
1118
|
+
configure: 26,
|
|
1119
|
+
reset: 27,
|
|
1120
|
+
verify: 28
|
|
1121
|
+
},
|
|
1122
|
+
null,
|
|
1123
|
+
[-1, -1]
|
|
1124
|
+
);
|
|
1125
|
+
}
|
|
1126
|
+
get auto() {
|
|
1127
|
+
return this.$$.ctx[0];
|
|
1128
|
+
}
|
|
1129
|
+
set auto(e) {
|
|
1130
|
+
this.$$set({ auto: e }), y();
|
|
1131
|
+
}
|
|
1132
|
+
get blockspam() {
|
|
1133
|
+
return this.$$.ctx[22];
|
|
1134
|
+
}
|
|
1135
|
+
set blockspam(e) {
|
|
1136
|
+
this.$$set({ blockspam: e }), y();
|
|
1137
|
+
}
|
|
1138
|
+
get challengeurl() {
|
|
1139
|
+
return this.$$.ctx[12];
|
|
1140
|
+
}
|
|
1141
|
+
set challengeurl(e) {
|
|
1142
|
+
this.$$set({ challengeurl: e }), y();
|
|
1143
|
+
}
|
|
1144
|
+
get challengejson() {
|
|
1145
|
+
return this.$$.ctx[23];
|
|
1146
|
+
}
|
|
1147
|
+
set challengejson(e) {
|
|
1148
|
+
this.$$set({ challengejson: e }), y();
|
|
1149
|
+
}
|
|
1150
|
+
get debug() {
|
|
1151
|
+
return this.$$.ctx[13];
|
|
1152
|
+
}
|
|
1153
|
+
set debug(e) {
|
|
1154
|
+
this.$$set({ debug: e }), y();
|
|
1155
|
+
}
|
|
1156
|
+
get expire() {
|
|
1157
|
+
return this.$$.ctx[14];
|
|
1158
|
+
}
|
|
1159
|
+
set expire(e) {
|
|
1160
|
+
this.$$set({ expire: e }), y();
|
|
1161
|
+
}
|
|
1162
|
+
get hidefooter() {
|
|
1163
|
+
return this.$$.ctx[1];
|
|
1164
|
+
}
|
|
1165
|
+
set hidefooter(e) {
|
|
1166
|
+
this.$$set({ hidefooter: e }), y();
|
|
1167
|
+
}
|
|
1168
|
+
get hidelogo() {
|
|
1169
|
+
return this.$$.ctx[2];
|
|
1170
|
+
}
|
|
1171
|
+
set hidelogo(e) {
|
|
1172
|
+
this.$$set({ hidelogo: e }), y();
|
|
1173
|
+
}
|
|
1174
|
+
get name() {
|
|
1175
|
+
return this.$$.ctx[3];
|
|
1176
|
+
}
|
|
1177
|
+
set name(e) {
|
|
1178
|
+
this.$$set({ name: e }), y();
|
|
1179
|
+
}
|
|
1180
|
+
get maxnumber() {
|
|
1181
|
+
return this.$$.ctx[15];
|
|
1182
|
+
}
|
|
1183
|
+
set maxnumber(e) {
|
|
1184
|
+
this.$$set({ maxnumber: e }), y();
|
|
1185
|
+
}
|
|
1186
|
+
get mockerror() {
|
|
1187
|
+
return this.$$.ctx[16];
|
|
1188
|
+
}
|
|
1189
|
+
set mockerror(e) {
|
|
1190
|
+
this.$$set({ mockerror: e }), y();
|
|
1191
|
+
}
|
|
1192
|
+
get refetchonexpire() {
|
|
1193
|
+
return this.$$.ctx[17];
|
|
1194
|
+
}
|
|
1195
|
+
set refetchonexpire(e) {
|
|
1196
|
+
this.$$set({ refetchonexpire: e }), y();
|
|
1197
|
+
}
|
|
1198
|
+
get spamfilter() {
|
|
1199
|
+
return this.$$.ctx[18];
|
|
1200
|
+
}
|
|
1201
|
+
set spamfilter(e) {
|
|
1202
|
+
this.$$set({ spamfilter: e }), y();
|
|
1203
|
+
}
|
|
1204
|
+
get strings() {
|
|
1205
|
+
return this.$$.ctx[24];
|
|
1206
|
+
}
|
|
1207
|
+
set strings(e) {
|
|
1208
|
+
this.$$set({ strings: e }), y();
|
|
1209
|
+
}
|
|
1210
|
+
get test() {
|
|
1211
|
+
return this.$$.ctx[19];
|
|
1212
|
+
}
|
|
1213
|
+
set test(e) {
|
|
1214
|
+
this.$$set({ test: e }), y();
|
|
1215
|
+
}
|
|
1216
|
+
get verifyurl() {
|
|
1217
|
+
return this.$$.ctx[20];
|
|
1218
|
+
}
|
|
1219
|
+
set verifyurl(e) {
|
|
1220
|
+
this.$$set({ verifyurl: e }), y();
|
|
1221
|
+
}
|
|
1222
|
+
get workers() {
|
|
1223
|
+
return this.$$.ctx[21];
|
|
1224
|
+
}
|
|
1225
|
+
set workers(e) {
|
|
1226
|
+
this.$$set({ workers: e }), y();
|
|
1227
|
+
}
|
|
1228
|
+
get workerurl() {
|
|
1229
|
+
return this.$$.ctx[25];
|
|
1230
|
+
}
|
|
1231
|
+
set workerurl(e) {
|
|
1232
|
+
this.$$set({ workerurl: e }), y();
|
|
1233
|
+
}
|
|
1234
|
+
get configure() {
|
|
1235
|
+
return this.$$.ctx[26];
|
|
1236
|
+
}
|
|
1237
|
+
get reset() {
|
|
1238
|
+
return this.$$.ctx[27];
|
|
1239
|
+
}
|
|
1240
|
+
get verify() {
|
|
1241
|
+
return this.$$.ctx[28];
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1244
|
+
customElements.define("altcha-widget", Et(Ot, { auto: {}, blockspam: {}, challengeurl: {}, challengejson: {}, debug: { type: "Boolean" }, expire: {}, hidefooter: { type: "Boolean" }, hidelogo: { type: "Boolean" }, name: {}, maxnumber: {}, mockerror: { type: "Boolean" }, refetchonexpire: { type: "Boolean" }, spamfilter: { type: "Boolean" }, strings: {}, test: { type: "Boolean" }, verifyurl: {}, workers: {}, workerurl: {} }, [], ["configure", "reset", "verify"], !1));
|
|
1245
|
+
globalThis.createAltchaWorker = (r) => new Worker(new URL(r || "./worker.js", import.meta.url));
|
|
1246
|
+
export {
|
|
1247
|
+
Ot as Altcha
|
|
1248
|
+
};
|