import type { NamespacePrefix, PemLabel } from "./types"; export declare function isArrayHasLength(array: unknown): array is unknown[]; export declare function findAttr(element: Element, localName: string, namespace?: string): Attr | null; export declare function findChildren(node: Node | Document, localName: string, namespace?: string): Element[]; /** * @deprecated Will be removed in 7.0. This is an internal DOM helper with no replacement; use a * DOM API or the `xpath` package. */ export declare function findChilds(node: Node | Document, localName: string, namespace?: string): Element[]; export declare function encodeSpecialCharactersInAttribute(attributeValue: any): any; export declare function encodeSpecialCharactersInText(text: string): string; export declare function renderProcessingInstruction(node: ProcessingInstruction): string; export declare function isCanonicalDocumentChild(node: Node): boolean; export declare function hasDocumentLevelProcessingInstruction(doc: Document): boolean; /** * -----BEGIN [LABEL]----- * base64([DATA]) * -----END [LABEL]----- * * Above is shown what PEM file looks like. As can be seen, base64 data * can be in single line or multiple lines. * * This function normalizes PEM presentation to; * - contain PEM header and footer as they are given * - normalize line endings to '\n' * - split lines longer than 64 characters, leaving shorter ones as they are * - ensure that 'preeb' has line ending '\n' * * @param pem The PEM string to normalize */ export declare function normalizePem(pem: string): string; /** * Returns the base64 data of each `CERTIFICATE` message in a PEM value, and `[]` when the value * holds no certificate: bare base64, or messages of other labels. Explanatory text before, after * or between the messages is passed over, as RFC 7468 section 5.2 allows, but every message the * value does hold is read and checked. * * @param pem The PEM value to read certificates from * @throws Error if the value opens a message it does not close as a well-formed PEM, or if a * certificate's labels disagree or its data is not base64 */ export declare function pemCertificates(pem: string): string[]; /** * Returns the decoded bytes of the one PEM message a value holds, whatever its label. * * @param pem The PEM message to decode * @throws Error if the value is not a single well-formed PEM message, or if its data is not what * a `CERTIFICATE`, `PRIVATE KEY` or `RSA PRIVATE KEY` label says it is */ export declare function pemToDer(pem: string): Buffer; export declare function bareCertificate(value: string): string; /** * Returns a value as canonical PEM: one message per certificate or key, wrapped at 64 characters. * The value may be a PEM message, several of them, base64 data with the label supplied by the * caller, or a Buffer. A Buffer that opens with an encapsulation boundary is read as the bytes of * a PEM file and any other as raw DER, so base64 text is given as a string rather than a Buffer. * * @param value The certificate or key to return as PEM * @param pemLabel The label to give base64 data, which needs one; ignored when the value is PEM * @throws Error if the value is neither a well-formed PEM nor base64, if it is base64 and no * label, or an unusable one, was given, or if the data is not what a `CERTIFICATE`, * `PRIVATE KEY` or `RSA PRIVATE KEY` label says it is */ export declare function toPem(value: string | Buffer, pemLabel?: PemLabel): string; export type InheritedXmlAttribute = { localName: string; value: string; }; export declare function findAncestorXmlAttributes(node: Node): InheritedXmlAttribute[]; export declare function findAncestorNsForElement(node: Element): NamespacePrefix[]; /** * Extract ancestor namespaces in order to import it to root of document subset * which is being canonicalized for non-exclusive c14n. * * @param doc - Usually a product from `new xmldom.DOMParser().parseFromString()` * @param docSubsetXpath - xpath query to get document subset being canonicalized * @param namespaceResolver - xpath namespace resolver * @returns i.e. [{prefix: "saml", namespaceURI: "urn:oasis:names:tc:SAML:2.0:assertion"}] */ export declare function findAncestorNs(doc: Document, docSubsetXpath?: string, namespaceResolver?: XPathNSResolver): NamespacePrefix[]; export declare function isPrefixInScope(prefixesInScope: NamespacePrefix[], prefix: string, namespaceURI: string): boolean; export declare function insideProcess(canonicalization: object, ownMethods: object, run: () => T): T; export declare function warnOutsideProcess(canonicalization: object): void; export declare function validateDigestValue(digest: any, expectedDigest: any): boolean; export declare function isDescendantOf(node: Node, parent: Node): boolean;