diff --git a/packages/common/src/web3ProofTypes.ts b/packages/common/src/web3ProofTypes.ts index 4a8b44ec9..649939954 100644 --- a/packages/common/src/web3ProofTypes.ts +++ b/packages/common/src/web3ProofTypes.ts @@ -263,9 +263,16 @@ export type CredentialStatement = { export type RequestStatement = { id: string; statement: AtomicStatementV2[]; + /** The type field is present iff the request is for a verifiable credential */ type?: string[]; }; +export function isVerifiableCredentialRequestStatement( + statement: RequestStatement +): boolean { + return Boolean(statement.type); +} + export type CredentialStatements = CredentialStatement[]; export type CredentialSubject = { diff --git a/packages/common/src/web3Proofs.ts b/packages/common/src/web3Proofs.ts index 8aaaf6302..5d8e71db0 100644 --- a/packages/common/src/web3Proofs.ts +++ b/packages/common/src/web3Proofs.ts @@ -560,14 +560,13 @@ export function createWeb3CommitmentInputWithHdWallet( } /** - * Given an atomic statement and an identity's attributes, determine whether the identity fulfills the statement. + * Given an atomic statement and a prover's attributes, determine whether the statement is fulfilled. */ export function canProveAtomicStatement( statement: AtomicStatementV2, - attributeList: AttributeList + attributes: Record ): boolean { - const attribute = - attributeList.chosenAttributes[statement.attributeTag as AttributeKey]; + const attribute = attributes[statement.attributeTag]; switch (statement.type) { case StatementTypes.AttributeInSet: return statement.set.includes(attribute); @@ -585,14 +584,13 @@ export function canProveAtomicStatement( } /** - * Given a credential statement and an identity's attributes, determine whether the identity fulfills the statement. - * TODO fix this + * Given a credential statement and a prover's attributes, determine whether the statements are fulfilled. */ export function canProveCredentialStatement( credentialStatement: CredentialStatement, - attributeList: AttributeList + attributes: Record ): boolean { return credentialStatement.statement.every((statement) => - canProveAtomicStatement(statement, attributeList) + canProveAtomicStatement(statement, attributes) ); }