Skip to content

Commit

Permalink
Rename findChilds() to findChildren() (#363)
Browse files Browse the repository at this point in the history
  • Loading branch information
cjbarth authored Jul 27, 2023
1 parent 6e6a8b0 commit ca13069
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/exclusive-canonicalization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,9 @@ export class ExclusiveCanonicalization implements CanonicalizationOrTransformati
* If the inclusiveNamespacesPrefixList has not been explicitly provided then look it up in CanonicalizationMethod/InclusiveNamespaces
*/
if (!utils.isArrayHasLength(inclusiveNamespacesPrefixList)) {
const CanonicalizationMethod = utils.findChilds(node, "CanonicalizationMethod");
const CanonicalizationMethod = utils.findChildren(node, "CanonicalizationMethod");
if (CanonicalizationMethod.length !== 0) {
const inclusiveNamespaces = utils.findChilds(
const inclusiveNamespaces = utils.findChildren(
CanonicalizationMethod[0],
"InclusiveNamespaces",
);
Expand Down
14 changes: 7 additions & 7 deletions src/signed-xml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ export class SignedXml {
throw new Error("No signature found.");
}

const signedInfo = utils.findChilds(this.signatureNode, "SignedInfo");
const signedInfo = utils.findChildren(this.signatureNode, "SignedInfo");
if (signedInfo.length === 0) {
throw new Error("could not find SignedInfo element in the message");
}
Expand Down Expand Up @@ -516,7 +516,7 @@ export class SignedXml {
*
*/
loadReference(ref) {
let nodes = utils.findChilds(ref, "DigestMethod");
let nodes = utils.findChildren(ref, "DigestMethod");
if (nodes.length === 0) {
throw new Error(`could not find DigestMethod in reference ${ref.toString()}`);
}
Expand All @@ -528,7 +528,7 @@ export class SignedXml {
}
const digestAlgo = attr.value;

nodes = utils.findChilds(ref, "DigestValue");
nodes = utils.findChildren(ref, "DigestValue");
if (nodes.length === 0) {
throw new Error(`could not find DigestValue node in reference ${ref.toString()}`);
}
Expand All @@ -540,10 +540,10 @@ export class SignedXml {

const transforms: string[] = [];
let inclusiveNamespacesPrefixList: string[] = [];
nodes = utils.findChilds(ref, "Transforms");
nodes = utils.findChildren(ref, "Transforms");
if (nodes.length !== 0) {
const transformsNode = nodes[0];
const transformsAll = utils.findChilds(transformsNode, "Transform");
const transformsAll = utils.findChildren(transformsNode, "Transform");
for (const transform of transformsAll) {
const transformAttr = utils.findAttr(transform, "Algorithm");

Expand All @@ -553,7 +553,7 @@ export class SignedXml {
}

// This is a little strange, we are looking for children of the last child of `transformsNode`
const inclusiveNamespaces = utils.findChilds(
const inclusiveNamespaces = utils.findChildren(
transformsAll[transformsAll.length - 1],
"InclusiveNamespaces",
);
Expand Down Expand Up @@ -799,7 +799,7 @@ export class SignedXml {
}

this.signatureNode = signatureDoc;
const signedInfoNodes = utils.findChilds(this.signatureNode, "SignedInfo");
const signedInfoNodes = utils.findChildren(this.signatureNode, "SignedInfo");
if (signedInfoNodes.length === 0) {
const err3 = new Error("could not find SignedInfo element in the message");
if (!callback) {
Expand Down
7 changes: 6 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export function findAttr(element: Element, localName: string, namespace?: string
return null;
}

export function findChilds(node: Node | Document, localName: string, namespace?: string) {
export function findChildren(node: Node | Document, localName: string, namespace?: string) {
const element = (node as Document).documentElement ?? node;
const res: Element[] = [];
for (let i = 0; i < element.childNodes.length; i++) {
Expand All @@ -46,6 +46,11 @@ export function findChilds(node: Node | Document, localName: string, namespace?:
return res;
}

/** @deprecated */
export function findChilds(node: Node | Document, localName: string, namespace?: string) {
return findChildren(node, localName, namespace);
}

const xml_special_to_encoded_attribute = {
"&": "&amp;",
"<": "&lt;",
Expand Down

0 comments on commit ca13069

Please sign in to comment.