virgil-sdk
Version:
Virgil Security Services SDK
97 lines (96 loc) • 3.14 kB
TypeScript
import { ICard } from './ICard';
import { IPublicKey, ICardCrypto } from '../types';
/**
* Interface to be implemented by an object capable of verifying the validity
* of Virgil Cards.
*/
export interface ICardVerifier {
/**
* Verifies the validity of the given `card`.
* @param {ICard} card
* @returns {boolean}
*/
verifyCard(card: ICard): boolean;
}
/**
* Signature identifier and the public key to be used to verify additional
* signatures of the cards, if any.
*/
export interface IVerifierCredentials {
/**
* String identifying the signature to be verified with `publicKeyBase64`.
*/
signer: string;
/**
* Public key to be used to verify the signature identified by `signer`.
*/
publicKeyBase64: string;
}
/**
* The {@link VirgilCardVerifier} constructor options.
*/
export interface IVirgilCardVerifierParams {
/**
* Indicates whether the "self" signature of the cards should be verified.
* Self signature is a signature generated with the card's corresponding
* private key.
*/
verifySelfSignature?: boolean;
/**
* Indicates whether the "virgil" signature of the cards should be
* verified. Virgil signature is appended to the list of card's signatures
* when the card is published.
*/
verifyVirgilSignature?: boolean;
/**
* Array of arrays of {@link IVerifierCredentials} objects to be used to
* verify additional signatures of the cards, if any.
*
* If whitelists are provided, the card must have at least one signature
* from each whitelist.
*/
whitelists?: IWhitelist[];
}
export declare type IWhitelist = IVerifierCredentials[];
/**
* Class responsible for validating cards by verifying their digital
* signatures.
*/
export declare class VirgilCardVerifier implements ICardVerifier {
private readonly crypto;
/**
* @see {@link IVirgilCardVerifierParams}
*/
whitelists: IWhitelist[];
/**
* @see {@link IVirgilCardVerifierParams}
*/
verifySelfSignature: boolean;
/**
* @see {@link IVirgilCardVerifierParams}
*/
verifyVirgilSignature: boolean;
/**
* Public key of the Virgil Cards service used for "virgil" signature
* verification.
*/
readonly virgilCardsPublicKey: IPublicKey;
/**
* Initializes a new instance of `VirgilCardVerifier`.
* @param {ICardCrypto} crypto - Object implementing the
* {@link ICardCrypto} interface.
* @param {IVirgilCardVerifierParams} options - Initialization options.
*/
constructor(crypto: ICardCrypto, options?: IVirgilCardVerifierParams);
/**
* Verifies the signatures of the `card`.
* @param {ICard} card
* @returns {boolean} `true` if the signatures to be verified are present
* and valid, otherwise `false`.
*/
verifyCard(card: ICard): boolean;
private selfValidationFailed;
private virgilValidationFailed;
private getPublicKey;
private validateSignerSignature;
}