-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #55 from wwWallet/verification-polling
replaced automatic form submission with polling for verification status
- Loading branch information
Showing
3 changed files
with
52 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,43 @@ | ||
const form = document.getElementById("PresentationRequestForm"); | ||
|
||
setTimeout(() => { | ||
form.submit(); | ||
}, 6000); | ||
const path = window.location.pathname; | ||
|
||
const pathSegments = path.split('/'); | ||
|
||
const nonEmptySegments = pathSegments.filter(segment => segment !== ''); | ||
const presentationDefinitionId = nonEmptySegments[nonEmptySegments.length - 1]; | ||
|
||
document.addEventListener("DOMContentLoaded", function() { | ||
const img = document.getElementById("qr-image"); | ||
|
||
img.addEventListener("click", function() { | ||
img.classList.toggle("expanded"); | ||
}); | ||
}); | ||
|
||
setInterval(() => { | ||
|
||
const state = form.elements['state'].value; | ||
|
||
fetch('/verifier/public/definitions/presentation-request/' + presentationDefinitionId, { | ||
method: 'POST', | ||
body: JSON.stringify({ state }), | ||
headers: { | ||
'Content-Type': 'application/json' | ||
} | ||
}).then((response) => { | ||
if (!response.ok) { | ||
throw new Error(`HTTP error with status ${response.status}`); | ||
} | ||
return response.json(); | ||
}) | ||
.then((data) => { | ||
const { url } = data; | ||
if (url) { | ||
window.location.href = url; | ||
} | ||
}) | ||
.catch((err) => { | ||
console.error(err); | ||
}); | ||
}, 3000); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters