altcha-org / altcha-starter-svelte-ts

0 stars 1 forks source link

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'digest') #1

Closed ihr-it-projekt closed 1 month ago

ihr-it-projekt commented 1 month ago

Hi, when i create the captcha. I see on console some error logs and the captcha is not successfully resolved. Never ending circle.

image

My console errors:

8b052acb-350b-412f-8f00-d4580489c73e:1 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'digest')
    at w (8b052acb-350b-412f-8f00-d4580489c73e:1:194)
    at 8b052acb-350b-412f-8f00-d4580489c73e:1:402
    at b (8b052acb-350b-412f-8f00-d4580489c73e:1:463)
    at onmessage (8b052acb-350b-412f-8f00-d4580489c73e:1:1512)

All blob´s throwing this.

I can not find a solution on your docs.

Here is my client code

<script lang="ts">
    import 'altcha';
    import SuperDebug from 'sveltekit-superforms';

    export let data;

    export let value: string = '';
</script>

<SuperDebug data={data} />
<altcha-widget
    style="--altcha-max-width:100%"
    debug
    challengejson={JSON.stringify(data.challengejson)}
   on:statechange={(ev) => {
        console.log('state:', ev.detail.state);
    const { payload, state } = ev.detail
    if (state === 'verified' && payload) {
      value = payload;
    } else {
      value = '';
    }
  }}
></altcha-widget>

Debug Output:

ALTCHA [name=altcha] mounted 1.0.0
altcha.js?v=68285af2:1171 ALTCHA [name=altcha] workers 12
altcha.js?v=68285af2:1171 ALTCHA [name=altcha] plugins none
+page.svelte:40 state: verifying
altcha.js?v=68285af2:1171 ALTCHA [name=altcha] using provided json data
altcha.js?v=68285af2:1171 ALTCHA [name=altcha] challenge {algorithm: 'SHA-256', challenge: '3447df7023daee758a63d51524b14dfda5bd754624d37c38d82f2bf147e155e4', maxnumber: 1000000, salt: 'bca2e522f8ec95b45248a2c6', signature: '5d741fbb2f2dd97e55f8a97401e850280a6fd4a224c995c2e73067a525b8bcfe'}
8b052acb-350b-412f-8f00-d4580489c73e:1 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'digest')
    at w (8b052acb-350b-412f-8f00-d4580489c73e:1:194)
    at 8b052acb-350b-412f-8f00-d4580489c73e:1:402
    at b (8b052acb-350b-412f-8f00-d4580489c73e:1:463)
    at onmessage (8b052acb-350b-412f-8f00-d4580489c73e:1:1512)

Bildschirmfoto 2024-09-26 um 10 19 55

ovx commented 1 month ago

Hi, this is becaase the subtle.crypto is available only in the secure context - you have run the app with https:// or on localhost domain. More info here: https://altcha.org/docs/website-integration/#caveats

ihr-it-projekt commented 1 month ago

Thx a lot. All fine now.