-
Notifications
You must be signed in to change notification settings - Fork 0
Wip/verify unime core compat #4
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
base: wip/verify
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,16 +1,21 @@ | ||||||||||||
import { CredentialOfferSchema } from '../schemas/CredentialOfferSchema'; | ||||||||||||
import { CredentialOfferSchema } from "../schemas/CredentialOfferSchema"; | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would just keep single quotes unless double quotes is the preferred formatting. In the latter case, please also update the formatting in other touched files. |
||||||||||||
|
||||||||||||
const PARAM_CREDENTIAL_OFFER = 'credential_offer'; | ||||||||||||
const PARAM_CREDENTIAL_OFFER_URI = 'credential_offer_uri'; | ||||||||||||
const PARAM_CREDENTIAL_OFFER = "credential_offer"; | ||||||||||||
const PARAM_CREDENTIAL_OFFER_URI = "credential_offer_uri"; | ||||||||||||
|
||||||||||||
// @todo: return type | ||||||||||||
export const credentialOfferFromUrl = async (url: string) => { | ||||||||||||
const parsedUrl = new URL(url); | ||||||||||||
if (parsedUrl.searchParams.get(PARAM_CREDENTIAL_OFFER)) { | ||||||||||||
return CredentialOfferSchema.parse(JSON.parse(parsedUrl.searchParams.get(PARAM_CREDENTIAL_OFFER))); | ||||||||||||
return CredentialOfferSchema.parse( | ||||||||||||
JSON.parse(parsedUrl.searchParams.get(PARAM_CREDENTIAL_OFFER)), | ||||||||||||
); | ||||||||||||
} | ||||||||||||
try { | ||||||||||||
const response = await fetch(parsedUrl.searchParams.get(PARAM_CREDENTIAL_OFFER_URI), {}); | ||||||||||||
const offerURI = | ||||||||||||
parsedUrl.searchParams.get(PARAM_CREDENTIAL_OFFER_URI) || ""; | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||||||||
const decodedOfferURI = decodeURIComponent(offerURI); | ||||||||||||
const response = await fetch(decodedOfferURI, {}); | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After fetching the credential offer, check
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||||||||
return await response.json(); | ||||||||||||
} catch (err) { | ||||||||||||
console.error(err); | ||||||||||||
|
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.
[nitpick] This growing chain of
if
statements for credential types may become hard to extend. Consider refactoring into a mapping or switch statement to improve readability and make future additions simpler.Copilot uses AI. Check for mistakes.
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.
This is a temporary solution pending a discussion pertaining to credential card title display logic. There is no need to optimize it right now.