@@ -5,6 +5,7 @@ import chai from 'chai';
5
5
import jsonld from 'jsonld' ;
6
6
7
7
const should = chai . should ( ) ;
8
+ const { expect} = chai ;
8
9
// RegExp with bs58 characters in it
9
10
const bs58 =
10
11
/ ^ [ 1 2 3 4 5 6 7 8 9 A B C D E F G H J K L M N P Q R S T U V W X Y Z a b c d e f g h i j k m n o p q r s t u v w x y z ] + $ / ;
@@ -298,3 +299,35 @@ export function shouldHaveProofValue({proof, expectedPrefix, encodingName}) {
298
299
true ,
299
300
`Expected "proof.proofValue" to be a valid ${ encodingName } value` ) ;
300
301
}
302
+
303
+ export async function shouldBeProofValue ( { credentials, verifier} ) {
304
+ expect ( credentials , 'Expected test data to be generated.' ) . to . exist ;
305
+ expect ( credentials . clone ( 'issuedVc' ) , 'Expected a valid Vc to be issued.' ) .
306
+ to . exist ;
307
+ // proofValue is added after signing so we can
308
+ // safely delete it for this test
309
+ const noProofValue = credentials . clone ( 'issuedVc' ) ;
310
+ delete noProofValue . proof . proofValue ;
311
+ await verificationFail ( {
312
+ credential : noProofValue ,
313
+ verifier,
314
+ reason : 'MUST not verify VC with no "proofValue".'
315
+ } ) ;
316
+ // null should be an invalid proofValue for almost any proof
317
+ const nullProofValue = credentials . clone ( 'issuedVc' ) ;
318
+ nullProofValue . proof . proofValue = null ;
319
+ await verificationFail ( {
320
+ credential : nullProofValue ,
321
+ verifier,
322
+ reason : 'MUST not verify VC with "proofValue" null.'
323
+ } ) ;
324
+ const noProofValueHeader = credentials . clone ( 'issuedVc' ) ;
325
+ // Remove the multibase header to cause validation error
326
+ noProofValueHeader . proof . proofValue = noProofValueHeader . proof . proofValue .
327
+ slice ( 1 ) ;
328
+ await verificationFail ( {
329
+ credential : noProofValueHeader ,
330
+ verifier,
331
+ reason : 'MUST not verify VC with invalid multibase header on "proofValue"'
332
+ } ) ;
333
+ }
0 commit comments