-
Notifications
You must be signed in to change notification settings - Fork 9
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
Replace sephereon/PEX presentation definitions with web5 js VCs implementation #112
Changes from 3 commits
752ee43
e6d7784
2a6b134
f8f5765
3bd5cfd
de22b4f
b96056a
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,11 +1,8 @@ | ||||||||||
import type { MessageKind, MessageKindModel, MessageMetadata, ResourceModel } from '../types.js' | ||||||||||
|
||||||||||
import { Offering } from '../resource-kinds/index.js' | ||||||||||
import { VerifiableCredential } from '@web5/credentials' | ||||||||||
import { VerifiableCredential, PresentationExchange } from '@web5/credentials' | ||||||||||
import { Message } from '../message.js' | ||||||||||
import { PEXv2 } from '@sphereon/pex' | ||||||||||
|
||||||||||
const pex = new PEXv2() | ||||||||||
|
||||||||||
/** | ||||||||||
* Options passed to {@link Rfq.create} | ||||||||||
|
@@ -77,9 +74,9 @@ export class Rfq extends Message<'rfq'> { | |||||||||
* @throws if rfq's claims do not fulfill the offering's requirements | ||||||||||
*/ | ||||||||||
async verifyClaims(offering: Offering | ResourceModel<'offering'>) { | ||||||||||
const { areRequiredCredentialsPresent } = pex.evaluateCredentials(offering.data.requiredClaims, this.claims) | ||||||||||
const requiredCredentialsPresent = PresentationExchange.selectCredentials(this.claims, offering.data.requiredClaims) | ||||||||||
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. This is a nit-pick, but variable name is slightly misleading IMO, could do either one of these...
Suggested change
And then update the if (!requiredCredentialsPresent) {
throw new Error(`claims do not fulfill the offering's requirements`)
} Or, could do...
Suggested change
and then keep the 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. yeah good callout, totes agree. |
||||||||||
|
||||||||||
if (areRequiredCredentialsPresent === 'error') { | ||||||||||
if (!requiredCredentialsPresent.length) { | ||||||||||
throw new Error(`claims do not fulfill the offering's requirements`) | ||||||||||
} | ||||||||||
|
||||||||||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
i think this PR necessitates a version bump - would you be able to do that? the readme has a section on how to add a changeset and automatically bump the version.
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.
automagic nice!