UNPKG

@sphereon/ssi-sdk.credential-validation

Version:

85 lines (80 loc) 3.13 kB
import { IAgentPlugin, IPluginMethodMap, IAgentContext, ICredentialVerifier } from '@veramo/core'; import { OriginalVerifiableCredential, HasherSync, WrappedVerifiableCredential, WrappedVerifiablePresentation } from '@sphereon/ssi-types'; import { ImDLMdoc } from '@sphereon/ssi-sdk.mdl-mdoc'; declare const credentialValidationMethods: Array<string>; /** * {@inheritDoc ICredentialValidation} */ declare class CredentialValidation implements IAgentPlugin { readonly schema: any; readonly methods: ICredentialValidation; private detectSchemas; private cvVerifyCredential; private cvVerifySchema; private validateSchema; private fetchSchema; private verifyCredentialAgainstSchema; private cvVerifyMdoc; private cvVerifyW3CCredential; private cvVerifySDJWTCredential; } interface ICredentialValidation extends IPluginMethodMap { cvVerifyCredential(args: VerifyCredentialArgs, context: RequiredContext): Promise<VerificationResult>; cvVerifySchema(args: ValidateSchemaArgs): Promise<VerificationResult>; cvVerifyMdoc(args: VerifyMdocCredentialArgs, context: RequiredContext): Promise<VerificationResult>; cvVerifySDJWTCredential(args: VerifySDJWTCredentialArgs, context: RequiredContext): Promise<VerificationResult>; cvVerifyW3CCredential(args: VerifyW3CCredentialArgs, context: RequiredContext): Promise<VerificationResult>; } declare enum SchemaValidation { ALWAYS = "ALWAYS", NEVER = "NEVER", WHEN_PRESENT = "WHEN_PRESENT" } type VerifyCredentialArgs = { credential: OriginalVerifiableCredential; hasher?: HasherSync; fetchRemoteContexts: boolean; policies?: VerificationPolicies; }; type VerificationPolicies = { schemaValidation?: SchemaValidation; credentialStatus?: boolean; expirationDate: boolean; issuanceDate: boolean; }; type ValidateSchemaArgs = { credential: OriginalVerifiableCredential; validationPolicy?: SchemaValidation; hasher?: HasherSync; }; type VerifyMdocCredentialArgs = { credential: string; }; type VerifySDJWTCredentialArgs = { credential: string; hasher?: HasherSync; skipStatusCheck?: boolean; }; type VerifyW3CCredentialArgs = {}; type VerificationResult = { result: boolean; source: WrappedVerifiableCredential | WrappedVerifiablePresentation; subResults: Array<VerificationSubResult>; error?: string | undefined; errorDetails?: string; }; type VerificationSubResult = { result: boolean; error?: string; errorDetails?: string; }; type CredentialVerificationError = { error?: string; errorDetails?: string; }; type RequiredContext = IAgentContext<ImDLMdoc & ICredentialVerifier>; /** * @public */ declare const schema: any; export { CredentialValidation, type CredentialVerificationError, type ICredentialValidation, type RequiredContext, SchemaValidation, type ValidateSchemaArgs, type VerificationPolicies, type VerificationResult, type VerificationSubResult, type VerifyCredentialArgs, type VerifyMdocCredentialArgs, type VerifySDJWTCredentialArgs, type VerifyW3CCredentialArgs, credentialValidationMethods, schema };