UNPKG

xmldsigjs-hotfix

Version:

XMLDSIGjs provides an implementation of XMLDSIG in Typescript/Javascript based on WebCrypto

114 lines (113 loc) 3.84 kB
import * as XmlCore from "xml-core"; import { Reference, Signature, Transform as XmlTransform, Transforms as XmlTransforms } from "./xml"; export declare type OptionsSignTransform = "enveloped" | "c14n" | "exc-c14n" | "c14n-com" | "exc-c14n-com" | "base64"; export interface OptionsSignReference { /** * Id of Reference * * @type {string} * @memberOf OptionsSignReference */ id?: string; uri?: string; type?: string; /** * Hash algorithm * * @type {AlgorithmIdentifier} * @memberOf OptionsSignReference */ hash: AlgorithmIdentifier; /** * List of transforms * * @type {OptionsSignTransform[]} * @memberOf OptionsSignReference */ transforms?: OptionsSignTransform[]; } export interface OptionsSign { /** * Id of Signature */ id?: string; /** * Public key for KeyInfo block * * @type {boolean} * @memberOf OptionsSign */ keyValue?: CryptoKey; /** * List of X509 Certificates * * @type {string[]} * @memberOf OptionsSign */ x509?: string[]; /** * List of Reference * Default is Reference with hash alg SHA-256 and exc-c14n transform * * @type {OptionsSignReference[]} * @memberOf OptionsSign */ references?: OptionsSignReference[]; } /** * Provides a wrapper on a core XML signature object to facilitate creating XML signatures. */ export declare class SignedXml implements XmlCore.IXmlSerializable { get XmlSignature(): Signature; Parent?: Element | XmlCore.XmlObject; Key?: CryptoKey; Algorithm?: Algorithm | RsaPssParams | EcdsaParams; get Signature(): Uint8Array | null; protected signature: Signature; protected document?: Document; /** * Creates an instance of SignedXml. * * @param {(Document | Element)} [node] * * @memberOf SignedXml */ constructor(node?: Document | Element); Sign(algorithm: Algorithm | EcdsaParams | RsaPssParams, key: CryptoKey, data: Document, options?: OptionsSign): Promise<Signature>; Verify(key?: CryptoKey): Promise<boolean>; GetXml(): Element | null; /** * Loads a SignedXml state from an XML element. * @param {Element | string} value The XML to load the SignedXml state from. * @returns void */ LoadXml(value: Element | string): void; toString(): string; /** * Returns the public key of a signature. */ protected GetPublicKeys(): Promise<CryptoKey[]>; /** * Returns dictionary of namespaces used in signature */ protected GetSignatureNamespaces(): XmlCore.AssocArray<string>; /** * Copies namespaces from source element and its parents into destination element */ protected CopyNamespaces(src: Element, dst: Element, ignoreDefault: boolean): void; /** * Injects namespaces from dictionary to the target element */ protected InjectNamespaces(namespaces: { [index: string]: string; }, target: Element, ignoreDefault: boolean): void; protected DigestReference(doc: Element, reference: Reference, checkHmac: boolean): Promise<Uint8Array>; protected DigestReferences(data: Element): Promise<void>; protected TransformSignedInfo(data?: Element | Document): string; protected ResolveTransform(transform: string): XmlTransform; protected ApplyTransforms(transforms: XmlTransforms, input: Element): any; protected ApplySignOptions(signature: Signature, algorithm: Algorithm, key: CryptoKey, options?: OptionsSign): Promise<void>; protected ValidateReferences(doc: Element): Promise<boolean>; protected ValidateSignatureValue(keys: CryptoKey[]): Promise<boolean>; } export declare function SelectRootNamespaces(node: Element): XmlCore.AssocArray<string>;