-
Notifications
You must be signed in to change notification settings - Fork 26
feat: implement presentation verification and request handling #1367
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
Merged
iFergal
merged 7 commits into
feat/birth-fishing-cred
from
feature/VT20-2173-credential-verifier-improvement-partB
Oct 1, 2025
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
cf79b3b
feat: implement presentation verification and request handling
Sotatek-DucPhung 4c4c423
fix: optimize exchange retrieval and verification logic
Sotatek-DucPhung 698ac89
refactor: streamline presentation request handling and introduce poll…
Sotatek-DucPhung f37584e
refactor: simplify polling logic in usePresentationPolling hook
Sotatek-DucPhung 8615da5
chore: update RequestPresentationModal to streamline presentation req…
Sotatek-DucPhung fe8ac93
chore: avoid dublicate call api
Sotatek-DucPhung 76be6f2
fix(cred-ui): cleanup, and correct design for status
iFergal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
81 changes: 81 additions & 0 deletions
81
services/credential-server-ui/src/hooks/usePresentationPolling.ts
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| import { useEffect, useRef, useCallback } from "react"; | ||
| import { useAppSelector, useAppDispatch } from "../store/hooks"; | ||
| import { updatePresentationStatus } from "../store/reducers/connectionsSlice"; | ||
| import { PresentationRequestStatus } from "../store/reducers/connectionsSlice.types"; | ||
| import { CredentialService } from "../services"; | ||
|
|
||
| export const usePresentationPolling = () => { | ||
| const dispatch = useAppDispatch(); | ||
| const presentationRequests = useAppSelector( | ||
| (state) => state.connections.presentationRequests | ||
| ); | ||
| const intervalRef = useRef<NodeJS.Timeout | null>(null); | ||
| const errorCountRef = useRef(0); | ||
| const maxErrors = 5; | ||
|
|
||
| const requestedPresentations = presentationRequests.filter( | ||
| (request) => request.status === PresentationRequestStatus.Requested | ||
| ); | ||
|
|
||
| const pollAllRequested = useCallback(async () => { | ||
| if (requestedPresentations.length === 0) { | ||
| return; | ||
| } | ||
|
|
||
| for (const request of requestedPresentations) { | ||
| try { | ||
| const response = await CredentialService.verifyPresentation( | ||
| request.ipexApplySaid, | ||
| request.discloserIdentifier | ||
| ); | ||
|
|
||
| if (response.data.success && response.data.data.verified) { | ||
| dispatch( | ||
| updatePresentationStatus({ | ||
| id: request.id, | ||
| status: PresentationRequestStatus.Presented, | ||
| }) | ||
| ); | ||
| } | ||
| } catch (error) { | ||
| errorCountRef.current += 1; | ||
|
|
||
| if (errorCountRef.current >= maxErrors) { | ||
| if (intervalRef.current) { | ||
| clearInterval(intervalRef.current); | ||
| intervalRef.current = null; | ||
| } | ||
| return; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| if (requestedPresentations.length > 0) { | ||
| errorCountRef.current = 0; | ||
| } | ||
| }, [requestedPresentations, dispatch]); | ||
|
|
||
| useEffect(() => { | ||
| if (intervalRef.current) { | ||
| clearInterval(intervalRef.current); | ||
| } | ||
|
|
||
| intervalRef.current = setInterval(pollAllRequested, 750); | ||
|
|
||
| return () => { | ||
| if (intervalRef.current) { | ||
| clearInterval(intervalRef.current); | ||
| intervalRef.current = null; | ||
| } | ||
| }; | ||
| }, [pollAllRequested]); | ||
|
|
||
| useEffect(() => { | ||
| return () => { | ||
| if (intervalRef.current) { | ||
| clearInterval(intervalRef.current); | ||
| intervalRef.current = null; | ||
| } | ||
| }; | ||
| }, []); | ||
| }; |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did we change to fetching all again?