Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
cjbarth committed Oct 12, 2023
1 parent 0defe4a commit 9bced7e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
8 changes: 5 additions & 3 deletions src/signed-xml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export class SignedXml {
this.privateKey = privateKey;
this.publicCert = publicCert;
this.signatureAlgorithm = signatureAlgorithm ?? this.signatureAlgorithm;
this.canonicalizationAlgorithm = canonicalizationAlgorithm ;
this.canonicalizationAlgorithm = canonicalizationAlgorithm;
if (typeof inclusiveNamespacesPrefixList === "string") {
this.inclusiveNamespacesPrefixList = inclusiveNamespacesPrefixList.split(" ");
} else if (utils.isArrayHasLength(inclusiveNamespacesPrefixList)) {
Expand Down Expand Up @@ -314,7 +314,7 @@ export class SignedXml {
const c14nOptions = {
ancestorNamespaces: ancestorNamespaces,
};

return this.getCanonXml([this.canonicalizationAlgorithm], signedInfo[0], c14nOptions);
}

Expand Down Expand Up @@ -1030,7 +1030,9 @@ export class SignedXml {
*/
private createSignedInfo(doc, prefix) {
if (typeof this.canonicalizationAlgorithm !== "string") {
throw new Error("Missing canonicalizationAlgorithm when trying to create signed info for XML");
throw new Error(
"Missing canonicalizationAlgorithm when trying to create signed info for XML",
);
}
const transform = this.findCanonicalizationAlgorithm(this.canonicalizationAlgorithm);
const algo = this.findSignatureAlgorithm(this.signatureAlgorithm);
Expand Down
20 changes: 12 additions & 8 deletions test/signature-integration-tests.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ describe("Signature integration tests", function () {
it("verify signature", function () {
const xml =
'<root><x xmlns="ns"></x><y z_attr="value" a_attr1="foo"></y><z><ns:w ns:attr="value" xmlns:ns="myns"></ns:w></z></root>';
verifySignature(xml, "./test/static/integration/expectedVerify.xml", [
"//*[local-name(.)='x']",
"//*[local-name(.)='y']",
"//*[local-name(.)='w']",
],"http://www.w3.org/2001/10/xml-exc-c14n#");
verifySignature(
xml,
"./test/static/integration/expectedVerify.xml",
["//*[local-name(.)='x']", "//*[local-name(.)='y']", "//*[local-name(.)='w']"],
"http://www.w3.org/2001/10/xml-exc-c14n#",
);
});

it("verify signature of complex element", function () {
Expand All @@ -44,9 +45,12 @@ describe("Signature integration tests", function () {
"</book>" +
"</library>";

verifySignature(xml, "./test/static/integration/expectedVerifyComplex.xml", [
"//*[local-name(.)='book']",
],"http://www.w3.org/2001/10/xml-exc-c14n#");
verifySignature(
xml,
"./test/static/integration/expectedVerifyComplex.xml",
["//*[local-name(.)='book']"],
"http://www.w3.org/2001/10/xml-exc-c14n#",
);
});

it("empty URI reference should consider the whole document", function () {
Expand Down

0 comments on commit 9bced7e

Please sign in to comment.