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

add vc/vp-jwt envelopes #123

Merged
merged 1 commit into from
Sep 27, 2024
Merged
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
10 changes: 6 additions & 4 deletions tests/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,17 @@ export function extractIfEnveloped(input) {
) {
input.should.have.property('id').that.does
.include('data:', `Missing id field.`);
const extractedCredential = atob(input.id.split(',')[1].split('.')[1]);
return JSON.parse(extractedCredential);
let extractedCredential = atob(input.id.split(',')[1].split('.')[1]);
extractedCredential = JSON.parse(extractedCredential);
return extractedCredential?.vc || extractedCredential;
} else if(input.type == 'EnvelopedVerifiablePresentation' ||
'EnvelopedVerifiablePresentation' in input.type
) {
input.should.have.property('id').that.does
.include('data:', `Missing id field.`);
const extractedPresentation = atob(input.id.split(',')[1].split('.')[1]);
return JSON.parse(extractedPresentation);
let extractedPresentation = atob(input.id.split(',')[1].split('.')[1]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we reuse this piece of code:

atob(input.id.split(',')[1].split('.')[1]);
and also this piece of code (which is similar to what implementations does)

extractedPresentation?.vp || extractedPresentation;

so maybe that should be a helper to the helper function here?

extractedPresentation = JSON.parse(extractedPresentation);
return extractedPresentation?.vp || extractedPresentation;
} else {
return input;
}
Expand Down