altcha 3.0.4 → 3.0.6
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 +68 -0
- package/dist/external/altcha.js +52 -22
- package/dist/external/altcha.min.js +1 -1
- package/dist/external/altcha.umd.cjs +52 -22
- package/dist/external/altcha.umd.min.cjs +1 -1
- package/dist/main/altcha.i18n.js +52 -22
- package/dist/main/altcha.i18n.min.js +1 -1
- package/dist/main/altcha.i18n.umd.cjs +52 -22
- package/dist/main/altcha.i18n.umd.min.cjs +1 -1
- package/dist/main/altcha.js +52 -22
- package/dist/main/altcha.min.js +1 -1
- package/dist/main/altcha.umd.cjs +52 -22
- package/dist/main/altcha.umd.min.cjs +1 -1
- package/package.json +1 -1
package/dist/main/altcha.js
CHANGED
|
@@ -5363,7 +5363,7 @@ function Code($$anchor, $$props) {
|
|
|
5363
5363
|
button.disabled = get(audioState) === AudioState.LOADING || get(audioState) === AudioState.ERROR;
|
|
5364
5364
|
set_attribute(button, "aria-label", get(audioState) === AudioState.LOADING ? strings().loading : strings().getAudioChallenge);
|
|
5365
5365
|
});
|
|
5366
|
-
|
|
5366
|
+
event("click", button, () => onPlayAudio(), true);
|
|
5367
5367
|
append($$anchor2, button);
|
|
5368
5368
|
};
|
|
5369
5369
|
if_block(node_1, ($$render) => {
|
|
@@ -5418,12 +5418,12 @@ function Code($$anchor, $$props) {
|
|
|
5418
5418
|
event("submit", form, onSubmitCapture, true);
|
|
5419
5419
|
delegated("keydown", input, onInputKeyDown);
|
|
5420
5420
|
bind_value(input, () => get(code), ($$value) => set(code, $$value));
|
|
5421
|
-
|
|
5422
|
-
|
|
5421
|
+
event("click", button_1, () => onReload()?.(), true);
|
|
5422
|
+
event("click", button_3, () => onCancel()?.(), true);
|
|
5423
5423
|
append($$anchor, div);
|
|
5424
5424
|
return pop($$exports);
|
|
5425
5425
|
}
|
|
5426
|
-
delegate(["keydown"
|
|
5426
|
+
delegate(["keydown"]);
|
|
5427
5427
|
create_custom_element(
|
|
5428
5428
|
Code,
|
|
5429
5429
|
{
|
|
@@ -5446,7 +5446,7 @@ var root_3$1 = /* @__PURE__ */ from_html(`<div role="button" class="altcha-popov
|
|
|
5446
5446
|
var root$1 = /* @__PURE__ */ from_html(`<!> <div><!> <!> <div class="altcha-popover-content"><!></div></div>`, 1);
|
|
5447
5447
|
function Popover($$anchor, $$props) {
|
|
5448
5448
|
push($$props, true);
|
|
5449
|
-
let anchor = prop($$props, "anchor"), children = prop($$props, "children"), display = prop($$props, "display", 7, "standard"), backdrop = prop($$props, "backdrop", 7, false), onClickOutside = prop($$props, "onClickOutside"), onClickOutsideDelay = prop($$props, "onClickOutsideDelay", 7, 600), onClose = prop($$props, "onClose"), placement = prop($$props, "placement", 7, "auto"), variant = prop($$props, "variant", 7, "neutral"), rest = /* @__PURE__ */ rest_props($$props, [
|
|
5449
|
+
let anchor = prop($$props, "anchor"), children = prop($$props, "children"), display = prop($$props, "display", 7, "standard"), backdrop = prop($$props, "backdrop", 7, false), onClickOutside = prop($$props, "onClickOutside"), onClickOutsideDelay = prop($$props, "onClickOutsideDelay", 7, 600), onClose = prop($$props, "onClose"), placement = prop($$props, "placement", 7, "auto"), updateUISignal = prop($$props, "updateUISignal"), variant = prop($$props, "variant", 7, "neutral"), rest = /* @__PURE__ */ rest_props($$props, [
|
|
5450
5450
|
"$$slots",
|
|
5451
5451
|
"$$events",
|
|
5452
5452
|
"$$legacy",
|
|
@@ -5459,6 +5459,7 @@ function Popover($$anchor, $$props) {
|
|
|
5459
5459
|
"onClickOutsideDelay",
|
|
5460
5460
|
"onClose",
|
|
5461
5461
|
"placement",
|
|
5462
|
+
"updateUISignal",
|
|
5462
5463
|
"variant"
|
|
5463
5464
|
]);
|
|
5464
5465
|
let el = /* @__PURE__ */ state(void 0);
|
|
@@ -5470,6 +5471,11 @@ function Popover($$anchor, $$props) {
|
|
|
5470
5471
|
set(top, placement() === "top");
|
|
5471
5472
|
}
|
|
5472
5473
|
});
|
|
5474
|
+
user_effect(() => {
|
|
5475
|
+
if (updateUISignal()) {
|
|
5476
|
+
reposition();
|
|
5477
|
+
}
|
|
5478
|
+
});
|
|
5473
5479
|
onMount(() => {
|
|
5474
5480
|
const moveToBody = display() === "bottomsheet" || display() === "overlay";
|
|
5475
5481
|
if (moveToBody) {
|
|
@@ -5492,7 +5498,7 @@ function Popover($$anchor, $$props) {
|
|
|
5492
5498
|
}
|
|
5493
5499
|
function onWindowClick(ev) {
|
|
5494
5500
|
const target = ev.target;
|
|
5495
|
-
if (!get(el)?.contains(target) &&
|
|
5501
|
+
if (!get(el)?.contains(target) && (!onClickOutsideDelay() || get(mountedAt) + onClickOutsideDelay() < Date.now())) {
|
|
5496
5502
|
onClickOutside()?.();
|
|
5497
5503
|
}
|
|
5498
5504
|
}
|
|
@@ -5569,6 +5575,13 @@ function Popover($$anchor, $$props) {
|
|
|
5569
5575
|
placement($$value);
|
|
5570
5576
|
flushSync();
|
|
5571
5577
|
},
|
|
5578
|
+
get updateUISignal() {
|
|
5579
|
+
return updateUISignal();
|
|
5580
|
+
},
|
|
5581
|
+
set updateUISignal($$value) {
|
|
5582
|
+
updateUISignal($$value);
|
|
5583
|
+
flushSync();
|
|
5584
|
+
},
|
|
5572
5585
|
get variant() {
|
|
5573
5586
|
return variant();
|
|
5574
5587
|
},
|
|
@@ -5578,7 +5591,7 @@ function Popover($$anchor, $$props) {
|
|
|
5578
5591
|
}
|
|
5579
5592
|
};
|
|
5580
5593
|
var fragment = root$1();
|
|
5581
|
-
event("click", $window, onWindowClick);
|
|
5594
|
+
event("click", $window, onWindowClick, true);
|
|
5582
5595
|
event("resize", $window, onWindowResize);
|
|
5583
5596
|
event("scroll", $window, onWindowScroll);
|
|
5584
5597
|
var node = first_child(fragment);
|
|
@@ -5615,7 +5628,7 @@ function Popover($$anchor, $$props) {
|
|
|
5615
5628
|
{
|
|
5616
5629
|
var consequent_2 = ($$anchor2) => {
|
|
5617
5630
|
var div_3 = root_3$1();
|
|
5618
|
-
|
|
5631
|
+
event("click", div_3, onCloseClick, true);
|
|
5619
5632
|
append($$anchor2, div_3);
|
|
5620
5633
|
};
|
|
5621
5634
|
if_block(node_2, ($$render) => {
|
|
@@ -5631,7 +5644,6 @@ function Popover($$anchor, $$props) {
|
|
|
5631
5644
|
append($$anchor, fragment);
|
|
5632
5645
|
return pop($$exports);
|
|
5633
5646
|
}
|
|
5634
|
-
delegate(["click"]);
|
|
5635
5647
|
create_custom_element(
|
|
5636
5648
|
Popover,
|
|
5637
5649
|
{
|
|
@@ -5643,6 +5655,7 @@ create_custom_element(
|
|
|
5643
5655
|
onClickOutsideDelay: {},
|
|
5644
5656
|
onClose: {},
|
|
5645
5657
|
placement: {},
|
|
5658
|
+
updateUISignal: {},
|
|
5646
5659
|
variant: {}
|
|
5647
5660
|
},
|
|
5648
5661
|
[],
|
|
@@ -5917,6 +5930,7 @@ function Widget($$anchor, $$props) {
|
|
|
5917
5930
|
let checked = /* @__PURE__ */ state(false);
|
|
5918
5931
|
let codeChallenge = /* @__PURE__ */ state(null);
|
|
5919
5932
|
let currentController = /* @__PURE__ */ state(null);
|
|
5933
|
+
let currentDisplay = /* @__PURE__ */ state(null);
|
|
5920
5934
|
let currentState = /* @__PURE__ */ state(proxy(State.UNVERIFIED));
|
|
5921
5935
|
let elAnchorArrow = /* @__PURE__ */ state(void 0);
|
|
5922
5936
|
let elFloatingAnchor = /* @__PURE__ */ state(void 0);
|
|
@@ -5927,6 +5941,7 @@ function Widget($$anchor, $$props) {
|
|
|
5927
5941
|
let expirationTimeout = /* @__PURE__ */ state(null);
|
|
5928
5942
|
let payload = /* @__PURE__ */ state(null);
|
|
5929
5943
|
let plugins = /* @__PURE__ */ state(proxy([]));
|
|
5944
|
+
let updateUISignal = /* @__PURE__ */ state(0);
|
|
5930
5945
|
let userConfig = /* @__PURE__ */ state(proxy({}));
|
|
5931
5946
|
let visible = /* @__PURE__ */ state(true);
|
|
5932
5947
|
const config = /* @__PURE__ */ user_derived(() => ({
|
|
@@ -6006,7 +6021,9 @@ function Widget($$anchor, $$props) {
|
|
|
6006
6021
|
}
|
|
6007
6022
|
});
|
|
6008
6023
|
user_effect(() => {
|
|
6009
|
-
|
|
6024
|
+
if (get(currentDisplay) !== get(config).display) {
|
|
6025
|
+
setDisplay(get(config).display);
|
|
6026
|
+
}
|
|
6010
6027
|
});
|
|
6011
6028
|
user_effect(() => {
|
|
6012
6029
|
if (get(checked) && get(currentState) === State.VERIFYING) {
|
|
@@ -6057,7 +6074,7 @@ function Widget($$anchor, $$props) {
|
|
|
6057
6074
|
}
|
|
6058
6075
|
});
|
|
6059
6076
|
onMount(() => {
|
|
6060
|
-
log("mounted", "3.0.
|
|
6077
|
+
log("mounted", "3.0.6");
|
|
6061
6078
|
if (instance) {
|
|
6062
6079
|
globalThis.$altcha.instances.add(instance);
|
|
6063
6080
|
}
|
|
@@ -6308,9 +6325,6 @@ function Widget($$anchor, $$props) {
|
|
|
6308
6325
|
}
|
|
6309
6326
|
}
|
|
6310
6327
|
function onCloseClick() {
|
|
6311
|
-
if (get(currentController)) {
|
|
6312
|
-
get(currentController).abort();
|
|
6313
|
-
}
|
|
6314
6328
|
setDisplay(get(config).display);
|
|
6315
6329
|
reset$1();
|
|
6316
6330
|
}
|
|
@@ -6329,9 +6343,6 @@ function Widget($$anchor, $$props) {
|
|
|
6329
6343
|
}
|
|
6330
6344
|
}
|
|
6331
6345
|
function onFormReset() {
|
|
6332
|
-
if (get(currentController)) {
|
|
6333
|
-
get(currentController).abort();
|
|
6334
|
-
}
|
|
6335
6346
|
setDisplay(get(config).display);
|
|
6336
6347
|
reset$1();
|
|
6337
6348
|
}
|
|
@@ -6350,8 +6361,11 @@ function Widget($$anchor, $$props) {
|
|
|
6350
6361
|
});
|
|
6351
6362
|
}
|
|
6352
6363
|
}
|
|
6353
|
-
function onWindowPageshow() {
|
|
6354
|
-
|
|
6364
|
+
function onWindowPageshow(ev) {
|
|
6365
|
+
if (ev.persisted) {
|
|
6366
|
+
setDisplay(get(config).display);
|
|
6367
|
+
reset$1();
|
|
6368
|
+
}
|
|
6355
6369
|
}
|
|
6356
6370
|
function onWindowResize() {
|
|
6357
6371
|
updateUI();
|
|
@@ -6471,6 +6485,9 @@ function Widget($$anchor, $$props) {
|
|
|
6471
6485
|
case "standard":
|
|
6472
6486
|
show();
|
|
6473
6487
|
}
|
|
6488
|
+
if (get(currentDisplay) !== value) {
|
|
6489
|
+
set(currentDisplay, value, true);
|
|
6490
|
+
}
|
|
6474
6491
|
}
|
|
6475
6492
|
function setChallengeExpiration(expiresAt) {
|
|
6476
6493
|
if (get(expirationTimeout)) {
|
|
@@ -6569,6 +6586,9 @@ function Widget($$anchor, $$props) {
|
|
|
6569
6586
|
set(checked, false);
|
|
6570
6587
|
set(error, err, true);
|
|
6571
6588
|
set(payload, null);
|
|
6589
|
+
if (get(currentController)) {
|
|
6590
|
+
get(currentController).abort();
|
|
6591
|
+
}
|
|
6572
6592
|
if (get(expirationTimeout)) {
|
|
6573
6593
|
clearTimeout(get(expirationTimeout));
|
|
6574
6594
|
set(expirationTimeout, null);
|
|
@@ -6591,6 +6611,7 @@ function Widget($$anchor, $$props) {
|
|
|
6591
6611
|
case "floating":
|
|
6592
6612
|
return repositionFloating();
|
|
6593
6613
|
}
|
|
6614
|
+
set(updateUISignal, get(updateUISignal) + 1);
|
|
6594
6615
|
}
|
|
6595
6616
|
async function verify(options = {}) {
|
|
6596
6617
|
const {
|
|
@@ -6606,8 +6627,8 @@ function Widget($$anchor, $$props) {
|
|
|
6606
6627
|
if (hook !== void 0) {
|
|
6607
6628
|
return hook;
|
|
6608
6629
|
}
|
|
6609
|
-
set(currentController, controller, true);
|
|
6610
6630
|
reset$1(State.VERIFYING);
|
|
6631
|
+
set(currentController, controller, true);
|
|
6611
6632
|
try {
|
|
6612
6633
|
if (!isSecureContext) {
|
|
6613
6634
|
throw new Error("Secure context (HTTPS) required.");
|
|
@@ -6618,6 +6639,10 @@ function Widget($$anchor, $$props) {
|
|
|
6618
6639
|
if (get(config).test) {
|
|
6619
6640
|
log("running test mode with null challenge");
|
|
6620
6641
|
await delay(Math.max(0, minDuration - (performance.now() - start)));
|
|
6642
|
+
if (get(currentController)?.signal.aborted) {
|
|
6643
|
+
reset$1();
|
|
6644
|
+
return null;
|
|
6645
|
+
}
|
|
6621
6646
|
set(payload, btoa(JSON.stringify({ challenge: null, solution: null, test: true })), true);
|
|
6622
6647
|
log("verified");
|
|
6623
6648
|
setState(State.VERIFIED);
|
|
@@ -6748,7 +6773,7 @@ function Widget($$anchor, $$props) {
|
|
|
6748
6773
|
if (get(config).overlayContent) $$render(consequent_1);
|
|
6749
6774
|
});
|
|
6750
6775
|
}
|
|
6751
|
-
|
|
6776
|
+
event("click", div_2, onCloseClick, true);
|
|
6752
6777
|
append($$anchor2, fragment_1);
|
|
6753
6778
|
};
|
|
6754
6779
|
if_block(node_1, ($$render) => {
|
|
@@ -6893,6 +6918,9 @@ function Widget($$anchor, $$props) {
|
|
|
6893
6918
|
get dir() {
|
|
6894
6919
|
return get(dir);
|
|
6895
6920
|
},
|
|
6921
|
+
get updateUISignal() {
|
|
6922
|
+
return get(updateUISignal);
|
|
6923
|
+
},
|
|
6896
6924
|
children: ($$anchor3, $$slotProps) => {
|
|
6897
6925
|
var fragment_9 = comment();
|
|
6898
6926
|
var node_10 = first_child(fragment_9);
|
|
@@ -6958,6 +6986,9 @@ function Widget($$anchor, $$props) {
|
|
|
6958
6986
|
get dir() {
|
|
6959
6987
|
return get(dir);
|
|
6960
6988
|
},
|
|
6989
|
+
get updateUISignal() {
|
|
6990
|
+
return get(updateUISignal);
|
|
6991
|
+
},
|
|
6961
6992
|
children: ($$anchor4, $$slotProps) => {
|
|
6962
6993
|
var fragment_12 = root_19();
|
|
6963
6994
|
var node_12 = first_child(fragment_12);
|
|
@@ -7029,7 +7060,6 @@ function Widget($$anchor, $$props) {
|
|
|
7029
7060
|
$$cleanup();
|
|
7030
7061
|
return $$pop;
|
|
7031
7062
|
}
|
|
7032
|
-
delegate(["click"]);
|
|
7033
7063
|
if (typeof window !== "undefined" && window.customElements) customElements.define("altcha-widget", create_custom_element(
|
|
7034
7064
|
Widget,
|
|
7035
7065
|
{
|