diff --git a/suites/verify.js b/suites/verify.js index dd2a340..8570b15 100644 --- a/suites/verify.js +++ b/suites/verify.js @@ -165,8 +165,20 @@ export function runDataIntegrityProofVerifyTests({ 'at the end of the value, or with a time zone offset relative ' + 'to UTC.', async function() { this.test.link = 'https://w3c.github.io/vc-data-integrity/#proofs:~:text=MUST%20be%20specified%20as%20an%20%5BXMLSCHEMA11%2D2%5D%20dateTimeStamp%20string%2C%20either%20in%20Universal%20Coordinated%20Time%20(UTC)%2C%20denoted%20by%20a%20Z%20at%20the%20end%20of%20the%20value%2C%20or%20with%20a%20time%20zone%20offset%20relative%20to%20UTC'; - const credential = credentials.clone('invalidCreated'); - await verificationFail({credential, verifier}); + await verificationFail({ + credential: credentials.clone('invalidCreated'), + verifier + }); + }); + it('If present (expires), it MUST be an [XMLSCHEMA11-2] dateTimeStamp ' + + 'string, either in Universal Coordinated Time (UTC), denoted by a Z ' + + 'at the end of the value, or with a time zone offset relative to UTC.', + async function() { + this.test.link = 'https://w3c.github.io/vc-data-integrity/#proofs:~:text=If%20present%2C%20it%20MUST%20be%20an%20%5BXMLSCHEMA11%2D2%5D%20dateTimeStamp%20string%2C%20either%20in%20Universal%20Coordinated%20Time%20(UTC)%2C%20denoted%20by%20a%20Z%20at%20the%20end%20of%20the%20value%2C%20or%20with%20a%20time%20zone%20offset%20relative%20to%20UTC.'; + await verificationFail({ + credential: credentials.clone('invalidExpires'), + verifier + }); }); // we can't tell if its interpreted correctly but we can ensure their // verifier at least takes timestamps without Z or an offset. diff --git a/vc-generator/generators.js b/vc-generator/generators.js index bf9004f..4346c10 100644 --- a/vc-generator/generators.js +++ b/vc-generator/generators.js @@ -17,6 +17,7 @@ export const generators = { noOffsetCreated, noOffsetExpires, invalidCreated, + invalidExpires, createdOneYearAgo }, // creates test vectors for Authentication Purpose tests @@ -173,13 +174,23 @@ function noVerificationMethod({suite, selectiveSuite, credential, ...args}) { return {...args, suite, selectiveSuite, credential}; } -function invalidCreated({suite, selectiveSuite, credential, ...args}) { +function invalidCreated({suite, selectiveSuite, ...args}) { // suite.date will be used as created when signing suite.date = 'invalidDate'; if(selectiveSuite) { selectiveSuite.date = 'invalidDate'; } - return {...args, suite, selectiveSuite, credential}; + return {...args, suite, selectiveSuite}; +} + +function invalidExpires({suite, selectiveSuite, ...args}) { + suite.proof = suite.proof || {}; + suite.proof.expires = 'invalidDate'; + if(selectiveSuite) { + selectiveSuite.proof = selectiveSuite.proof || {}; + selectiveSuite.proof.expires = 'invalidDate'; + } + return {...args, suite, selectiveSuite}; } function createdOneYearAgo({ @@ -214,7 +225,8 @@ function invalidProofType({ suite.type = proofType; if(selectiveSuite) { const proofId = 'urn:uuid:no-proof-type-test'; - suite.proof = {id: proofId}; + suite.proof = suite.proof || {}; + suite.proof.id = proofId; selectiveSuite._cryptosuite.options.proofId = proofId; selectiveSuite.type = proofType; } @@ -252,11 +264,13 @@ function noOffsetCreated({suite, selectiveSuite, ...args}) { } function noOffsetExpires({suite, selectiveSuite, ...args}) { - const expires = new Date().toISOString().replace(/\.\d+Z$/, ''); // lop off ms precision from ISO timestamp - suite.proof = {expires}; + const expires = new Date().toISOString().replace(/\.\d+Z$/, ''); + suite.proof = suite.proof || {}; + suite.proof.expires = expires; if(selectiveSuite) { - selectiveSuite.proof = {...suite.proof, ...selectiveSuite.proof}; + selectiveSuite.proof = selectiveSuite.proof || {}; + selectiveSuite.proof.expires = expires; } return {...args, suite, selectiveSuite}; }