diff --git a/app/components/ResultLog/ResultLog.tsx b/app/components/ResultLog/ResultLog.tsx
index 933ab70..73230d1 100644
--- a/app/components/ResultLog/ResultLog.tsx
+++ b/app/components/ResultLog/ResultLog.tsx
@@ -18,6 +18,7 @@ export enum LogMessages {
HasExpired = 'has expired',
NoExpirationDate = 'no expiration date set',
HasNotExpired = 'has not expired',
+ NotYetValid = 'is not yet valid',
GeneralError = 'There was an error verifing this credential.',
UnknownError = 'There was an unknown error verifing this credential.',
WellFormed = 'is in a supported credential format',
@@ -130,8 +131,9 @@ export const ResultLog = ({ verificationResult }: ResultLogProps) => {
const isMalformedError =
result?.error?.message ===
'Credential could not be checked for verification and may be malformed.';
+ const isNotYetValidError = result?.error?.message?.includes('will only be valid after');
const { credential } = result;
- if (shouldShowKnownError) {
+ if (shouldShowKnownError && !isNotYetValidError) {
return (
{LogMessages.GeneralError}
@@ -142,6 +144,12 @@ export const ResultLog = ({ verificationResult }: ResultLogProps) => {
)}
)
+ } else if (isNotYetValidError) {
+ return (
+
+ )
} else if (hasSigningError) {
return (
diff --git a/app/lib/validate.ts b/app/lib/validate.ts
index 892bcdc..7b447c9 100644
--- a/app/lib/validate.ts
+++ b/app/lib/validate.ts
@@ -1,6 +1,7 @@
import * as verifierCore from '@digitalcredentials/verifier-core';
import type { VerifiablePresentation } from '@/types/presentation.d';
import type { VerifiableCredential, CredentialError } from '@/types/credential.d';
+import { getIssuanceDate } from './credentialValidityPeriod';
//import { CredentialErrorTypes } from '@/types/credential.d';
//import { KnownDidRegistries } from './../data/knownRegistries'
@@ -10,6 +11,7 @@ enum CredentialErrorTypes {
IsNotVerified = 'Credential is not verified.',
CouldNotBeVerified = 'Credential could not be checked for verification and may be malformed.',
DidNotInRegistry = 'Could not find issuer in registry with given DID.',
+ NotYetValid = 'This credential is not yet valid.',
}
@@ -59,6 +61,21 @@ export async function verifyCredential(credential: VerifiableCredential): Promis
};
*/
+ // Check if credential is not yet valid before verification
+ const issuanceDate = getIssuanceDate(credential);
+ if (issuanceDate) {
+ const validFromDate = new Date(issuanceDate);
+ const now = new Date();
+ if (validFromDate > now) {
+ const formattedDate = validFromDate.toLocaleDateString('en-US', {
+ year: 'numeric',
+ month: 'long',
+ day: 'numeric'
+ });
+ return createNotYetValidResult(credential, `This credential will only be valid after ${formattedDate}.`);
+ }
+ }
+
const response = await fetch("https://digitalcredentials.github.io/dcc-known-registries/known-did-registries.json");
const knownDIDRegistries = await response.json();
@@ -144,6 +161,26 @@ function createFatalErrorResult(credential: VerifiableCredential, message: strin
return result as VerifyResponse
}
+function createNotYetValidResult(credential: VerifiableCredential, message: string): VerifyResponse {
+ const result = {
+ verified: false,
+ results: [
+ {
+ verified: false,
+ credential: credential,
+ log: [
+ { id: 'expiration', valid: false },
+ { id: 'valid_signature', valid: true },
+ { id: 'issuer_did_resolves', valid: true },
+ { id: 'revocation_status', valid: true }
+ ]
+ }
+ ]
+ }
+ addErrorToResult(result, message, false)
+ return result as VerifyResponse
+}
+
function addErrorToResult(result: any, message: string, isFatal: boolean = true) {
result.results[0].error =
{