altcha 3.0.7 → 3.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.
@@ -6076,7 +6076,7 @@
6076
6076
  }
6077
6077
  });
6078
6078
  onMount(() => {
6079
- log("mounted", "3.0.7");
6079
+ log("mounted", "3.0.9");
6080
6080
  if (instance) {
6081
6081
  globalThis.$altcha.instances.add(instance);
6082
6082
  }
@@ -6175,7 +6175,14 @@
6175
6175
  return hook;
6176
6176
  }
6177
6177
  if (typeof source2 === "string") {
6178
- if (source2.match(/^(https?:)?\//)) {
6178
+ if (source2.startsWith("{")) {
6179
+ log("parsing JSON challenge");
6180
+ try {
6181
+ challenge = JSON.parse(source2);
6182
+ } catch {
6183
+ throw new Error(`Unable to parse JSON challenge.`);
6184
+ }
6185
+ } else {
6179
6186
  log("fetching challenge from", requestOptions?.method || "GET", source2);
6180
6187
  set(baseUrl, new URL(source2, location.origin), true);
6181
6188
  const resp = await get(config).fetch(source2, {
@@ -6203,13 +6210,6 @@
6203
6210
  log("HIS result", json.hisResult);
6204
6211
  }
6205
6212
  challenge = json;
6206
- } else {
6207
- log("parsing JSON challenge");
6208
- try {
6209
- challenge = JSON.parse(source2);
6210
- } catch {
6211
- throw new Error(`Unable to parse JSON challenge.`);
6212
- }
6213
6213
  }
6214
6214
  } else if (source2 && typeof source2 === "object") {
6215
6215
  try {
@@ -6349,10 +6349,14 @@
6349
6349
  reset$1();
6350
6350
  }
6351
6351
  function onFormSubmit(ev) {
6352
- set(elSubmitter, ev.submitter, true);
6352
+ const target = ev.target;
6353
+ if (target?.getAttribute("data-code-challenge") === "true") {
6354
+ return;
6355
+ }
6353
6356
  if (get(auto) === "onsubmit" && get(currentState) === State.UNVERIFIED) {
6354
6357
  ev.preventDefault();
6355
6358
  ev.stopPropagation();
6359
+ set(elSubmitter, ev.submitter, true);
6356
6360
  show();
6357
6361
  verify().then((result) => {
6358
6362
  if (result && !get(codeChallenge)) {