diff --git a/src/domain/verifier/useCases/validateVerifiableCredential.ts b/src/domain/verifier/useCases/validateVerifiableCredential.ts index 0a4bd28db..f53cb574f 100644 --- a/src/domain/verifier/useCases/validateVerifiableCredential.ts +++ b/src/domain/verifier/useCases/validateVerifiableCredential.ts @@ -54,8 +54,9 @@ function validateContext (context: JsonLDContext, type: string[]): void { function validateIssuer (certificateIssuer: string | Issuer): void { let hasError = false; - - if (typeof certificateIssuer === 'string' && !isValidUrl(certificateIssuer)) { + if (certificateIssuer == null) { + hasError = true; + } else if (typeof certificateIssuer === 'string' && !isValidUrl(certificateIssuer)) { hasError = true; } else if (typeof certificateIssuer === 'object' && !isValidUrl(certificateIssuer.id)) { hasError = true; diff --git a/test/application/certificate/certificate-v3.test.ts b/test/application/certificate/certificate-v3.test.ts index ec86178e8..8f14b6ef6 100644 --- a/test/application/certificate/certificate-v3.test.ts +++ b/test/application/certificate/certificate-v3.test.ts @@ -95,7 +95,7 @@ describe('Certificate entity test suite', function () { const certificate = new Certificate(failingFixture); await expect(certificate.init()) .rejects - .toThrow('Unable to get issuer profile - no issuer address given'); + .toThrow('Document presented is not a valid Verifiable Credential: `issuer` must be a URL string or an object with an `id` URL string'); }); }); @@ -106,7 +106,7 @@ describe('Certificate entity test suite', function () { const certificate = new Certificate(failingFixture); await expect(certificate.init()) .rejects - .toThrow('Unable to get issuer profile - no issuer address given'); + .toThrow('Document presented is not a valid Verifiable Credential: `issuer` must be a URL string or an object with an `id` URL string'); }); }); @@ -117,7 +117,7 @@ describe('Certificate entity test suite', function () { const certificate = new Certificate(failingFixture); await expect(certificate.init()) .rejects - .toThrow('Unable to get issuer profile - no issuer address given'); + .toThrow('Document presented is not a valid Verifiable Credential: `issuer` must be a URL string or an object with an `id` URL string'); }); }); @@ -128,7 +128,7 @@ describe('Certificate entity test suite', function () { const certificate = new Certificate(failingFixture); await expect(certificate.init()) .rejects - .toThrow('Unable to get issuer profile - no issuer address given'); + .toThrow('Document presented is not a valid Verifiable Credential: `issuer` must be a URL string or an object with an `id` URL string'); }); });