altcha 3.0.8 → 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.8");
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 {