import { Transform } from "./xml/transform.js"; import { Transforms } from "./xml/transform_collection.js"; import { Reference } from "./xml/reference.js"; import { Signature } from "./xml/signature.js"; import "./xml/index.js"; import { AssocArray, IXmlSerializable, XmlObject } from "xml-core"; export interface OptionsXPathSignTransform { name: "xpath"; selector: string; namespaces?: Record; } export type OptionsSignTransform = "enveloped" | "c14n" | "exc-c14n" | "c14n-com" | "exc-c14n-com" | "base64" | OptionsXPathSignTransform | string; export type OptionsSignCanonicalization = "c14n" | "exc-c14n" | "c14n-com" | "exc-c14n-com" | (string & {}); export type DigestReferenceSource = Element | BufferSource; export interface OptionsVerify { key?: CryptoKey; content?: DigestReferenceSource; } export interface OptionsSignReference { /** * Id of Reference * * @type {string} * @memberOf OptionsSignReference */ id?: string; uri?: string; type?: string; /** * Hash algorithm */ hash: AlgorithmIdentifier; /** * List of transforms */ 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[]; /** * Canonicalization method of SignedInfo: c14n, exc-c14n, c14n-com, exc-c14n-com * or the namespace URI of a canonicalization transform * Default is c14n */ canonicalization?: OptionsSignCanonicalization; } /** * Provides a wrapper on a core XML signature object to facilitate creating XML signatures. */ export declare class SignedXml implements IXmlSerializable { get XmlSignature(): Signature; contentHandler?: (reference: Reference, target: this) => Promise; Parent?: Element | XmlObject; Key?: CryptoKey; Algorithm?: Algorithm | RsaPssParams | EcdsaParams; get Signature(): Uint8Array | null; protected signature: Signature; protected document?: Document; /** * If set to true, transformations with comments will be replaced with transformations * without comments. * This is a non-standard implementation to ensure compatibility with systems that do not support * canonicalization with comments. */ replaceCanonicalization: boolean; /** * Creates an instance of SignedXml. * * @param {(Document | Element)} [node] * * @memberOf SignedXml */ constructor(node?: Document | Element); Sign(algorithm: Algorithm | EcdsaParams | RsaPssParams, key: CryptoKey, data: Document | DigestReferenceSource, options?: OptionsSign): Promise; private reimportKey; Verify(params?: CryptoKey | OptionsVerify): Promise; 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; /** * Returns dictionary of namespaces used in signature */ protected GetSignatureNamespaces(): AssocArray; /** * 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: Record, target: Element, ignoreDefault: boolean): void; protected DigestReference(source: DigestReferenceSource, reference: Reference, _checkHmac: boolean): Promise>; protected DigestReferences(data: DigestReferenceSource): Promise; protected TransformSignedInfo(data?: Element | Document | BufferSource): string; /** * Returns the namespace URI of a canonicalization method. * Other transforms (e.g. base64, enveloped) are not allowed: SignedInfo would not be canonicalized * and the signature would not cover it */ protected ResolveCanonicalization(canonicalization: OptionsSignCanonicalization): string; protected ResolveTransform(transform: OptionsSignTransform): Transform; protected ApplyTransforms(transforms: Transforms, input: Element): any; protected ApplySignOptions(signature: Signature, algorithm: Algorithm, key: CryptoKey, options: OptionsSign): Promise; protected ValidateReferences(doc: DigestReferenceSource): Promise; protected ValidateSignatureValue(keys: CryptoKey[]): Promise; } export declare function SelectRootNamespaces(node: Element): AssocArray;