credo-ts
credo-ts copied to clipboard
Fix W3cCredentialsApi verifyCredential types
I believe the type signature of the W3cCredentialsApi
verifyCredential method is incorrect.
Code as follows has a TS compilation error:
const w3cVerifyCredentialOptions: W3cVerifyCredentialOptions<ClaimFormat.LdpVc> = {
credential: W3cJsonLdVerifiableCredential.fromJson(vc)
};
const verifyCredential: W3cVerifyCredentialResult =
await this.credoService.agent.w3cCredentials.verifyCredential(w3cVerifyCredentialOptions);
Argument of type 'W3cJsonLdVerifyCredentialOptions' is not assignable to parameter of type 'W3cJwtVerifyCredentialOptions'.
Types of property 'credential' are incompatible.
Type 'W3cJsonLdVerifiableCredential' is not assignable to type 'string | W3cJwtVerifiableCredential'.
Type 'W3cJsonLdVerifiableCredential' is missing the following properties from type 'W3cJwtVerifiableCredential': jwt, _credential, credential, serializedJwtts(2345)
I suggest that the type signature of verifyCredential
be changed from
public async verifyCredential(options: W3cVerifyCredentialOptions)
to
public async verifyCredential<Format extends ClaimFormat.JwtVc | ClaimFormat.LdpVc>(options: W3cVerifyCredentialOptions<Format>