xmldsigjs
Version:
XML Digital Signature implementation in TypeScript/JavaScript using Web Crypto API
46 lines (45 loc) • 1.82 kB
TypeScript
import { SignatureMethod } from './xml/signature_method.js';
export type BASE64 = string;
export interface IAlgorithm {
algorithm: Algorithm;
namespaceURI: string;
getAlgorithmName(): string;
}
export interface IHashAlgorithm extends IAlgorithm {
Digest(xml: BufferSource | string | Node): Promise<Uint8Array>;
}
export type IHashAlgorithmConstructable = new () => IHashAlgorithm;
export declare abstract class XmlAlgorithm implements IAlgorithm {
algorithm: Algorithm;
namespaceURI: string;
getAlgorithmName(): string;
}
export declare abstract class HashAlgorithm extends XmlAlgorithm implements IHashAlgorithm {
Digest(xml: BufferSource | string | Node): Promise<Uint8Array>;
}
export interface ISignatureAlgorithm extends IAlgorithm {
/**
* Optional method to retrieve parameters from a SignatureMethod.
*/
fromMethod?: (method: SignatureMethod) => void;
/**
* Optional method to set parameters to a SignatureMethod.
*/
toMethod?: (method: SignatureMethod) => void;
Sign(signedInfo: string, signingKey: CryptoKey, algorithm: Algorithm): Promise<ArrayBuffer>;
Verify(signedInfo: string, key: CryptoKey, signatureValue: Uint8Array): Promise<boolean>;
}
export interface ISignatureAlgorithmConstructable {
new (): ISignatureAlgorithm;
fromAlgorithm(alg: Algorithm): ISignatureAlgorithm | null;
}
export declare abstract class SignatureAlgorithm extends XmlAlgorithm implements ISignatureAlgorithm {
/**
* Sign the given string using the given key
*/
Sign(signedInfo: string, signingKey: CryptoKey, algorithm: Algorithm): Promise<ArrayBuffer>;
/**
* Verify the given signature of the given string using key
*/
Verify(signedInfo: string, key: CryptoKey, signatureValue: Uint8Array): Promise<boolean>;
}