Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: At each authentication also all past codeVerifier are used to get the credential #592

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/routes/[[lang]]/(protected)/credential-offer/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import HeaderWithBackButton from '$lib/components/molecules/HeaderWithBackButton.svelte';
import DebugPopup from '$lib/components/organisms/debug/DebugPopup.svelte';
import { getDebugMode } from '$lib/preferences/debug.js';
import { onDestroy, onMount } from 'svelte';
import ArrayFieldController from '$lib/forms/arrayFieldController.svelte';

export let data;
const { wn, authorizeUrl, parResult, feedbackData } = data;
Expand All @@ -27,7 +29,7 @@
let isCredentialVerified: boolean = false;
let serviceResponse: CredentialResult;

window.addEventListener('message', async function (event) {
const credentialOrFail = async function (event: MessageEvent<string>) {
if (event.origin === window.location.origin) return;
try {
code = JSON.parse(event.data).code;
Expand All @@ -40,7 +42,10 @@
};
content.scrollToTop();
}
});
};

onMount(() => window.addEventListener('message', credentialOrFail));
onDestroy(() => window.removeEventListener('message', credentialOrFail));

const credentialInfo = wn?.credential_requested['display'][0];

Expand All @@ -54,7 +59,7 @@
try {
serviceResponse = await askCredential(code, wn.credential_parameters, codeVerifier);
if (!serviceResponse) return (isModalOpen = false);
isModalOpen = !(await getDebugMode())
isModalOpen = !(await getDebugMode());
isCredentialVerified = true;
log(`serviceResponse: (fine chain): ${JSON.stringify(serviceResponse, null, 2)}`);
} catch (e: unknown) {
Expand Down Expand Up @@ -89,7 +94,6 @@
await goto(`/${id}/credential-detail`);
}, 2000);
};

</script>

<HeaderWithBackButton>
Expand Down
Loading