Skip to content

Commit

Permalink
Basic xades support
Browse files Browse the repository at this point in the history
  • Loading branch information
GauriSpears committed Jan 17, 2024
1 parent 5a0d317 commit 17c628c
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions src/signed-xml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -802,6 +802,9 @@ export class SignedXml {

signatureXml += this.createSignedInfo(doc, prefix);
signatureXml += this.getKeyInfo(prefix);
if (this.xadesQualifyingProperties != null) {

Check failure on line 805 in src/signed-xml.ts

View workflow job for this annotation

GitHub Actions / Lint Code

Property 'xadesQualifyingProperties' does not exist on type 'SignedXml'.

Check failure on line 805 in src/signed-xml.ts

View workflow job for this annotation

GitHub Actions / Test Code (ubuntu-latest, 16, false)

Property 'xadesQualifyingProperties' does not exist on type 'SignedXml'.

Check failure on line 805 in src/signed-xml.ts

View workflow job for this annotation

GitHub Actions / Test Code (ubuntu-latest, 18, false)

Property 'xadesQualifyingProperties' does not exist on type 'SignedXml'.

Check failure on line 805 in src/signed-xml.ts

View workflow job for this annotation

GitHub Actions / Test Code (ubuntu-latest, 20, false)

Property 'xadesQualifyingProperties' does not exist on type 'SignedXml'.

Check failure on line 805 in src/signed-xml.ts

View workflow job for this annotation

GitHub Actions / Test Code (ubuntu-latest, latest, true)

Property 'xadesQualifyingProperties' does not exist on type 'SignedXml'.
signatureXml += `<${currentPrefix}Object>${this.xadesQualifyingProperties()}</${currentPrefix}Object>`;

Check failure on line 806 in src/signed-xml.ts

View workflow job for this annotation

GitHub Actions / Lint Code

Property 'xadesQualifyingProperties' does not exist on type 'SignedXml'.

Check failure on line 806 in src/signed-xml.ts

View workflow job for this annotation

GitHub Actions / Test Code (ubuntu-latest, 16, false)

Property 'xadesQualifyingProperties' does not exist on type 'SignedXml'.

Check failure on line 806 in src/signed-xml.ts

View workflow job for this annotation

GitHub Actions / Test Code (ubuntu-latest, 18, false)

Property 'xadesQualifyingProperties' does not exist on type 'SignedXml'.

Check failure on line 806 in src/signed-xml.ts

View workflow job for this annotation

GitHub Actions / Test Code (ubuntu-latest, 20, false)

Property 'xadesQualifyingProperties' does not exist on type 'SignedXml'.

Check failure on line 806 in src/signed-xml.ts

View workflow job for this annotation

GitHub Actions / Test Code (ubuntu-latest, latest, true)

Property 'xadesQualifyingProperties' does not exist on type 'SignedXml'.
}
signatureXml += `</${currentPrefix}Signature>`;

this.originalXmlWithIds = doc.toString();
Expand Down Expand Up @@ -918,21 +921,29 @@ export class SignedXml {
prefix = prefix ? `${prefix}:` : prefix;

for (const ref of this.getReferences()) {
const nodes = xpath.selectWithResolver(ref.xpath ?? "", doc, this.namespaceResolver);
let nodes = xpath.selectWithResolver(ref.xpath ?? "", doc, this.namespaceResolver);

if (!utils.isArrayHasLength(nodes)) {
throw new Error(
`the following xpath cannot be signed because it was not found: ${ref.xpath}`,
);
if (this.xadesQualifyingProperties != null){

Check failure on line 927 in src/signed-xml.ts

View workflow job for this annotation

GitHub Actions / Lint Code

Property 'xadesQualifyingProperties' does not exist on type 'SignedXml'.

Check failure on line 927 in src/signed-xml.ts

View workflow job for this annotation

GitHub Actions / Test Code (ubuntu-latest, 16, false)

Property 'xadesQualifyingProperties' does not exist on type 'SignedXml'.

Check failure on line 927 in src/signed-xml.ts

View workflow job for this annotation

GitHub Actions / Test Code (ubuntu-latest, 18, false)

Property 'xadesQualifyingProperties' does not exist on type 'SignedXml'.

Check failure on line 927 in src/signed-xml.ts

View workflow job for this annotation

GitHub Actions / Test Code (ubuntu-latest, 20, false)

Property 'xadesQualifyingProperties' does not exist on type 'SignedXml'.

Check failure on line 927 in src/signed-xml.ts

View workflow job for this annotation

GitHub Actions / Test Code (ubuntu-latest, latest, true)

Property 'xadesQualifyingProperties' does not exist on type 'SignedXml'.
nodes = xpath.selectWithResolver(ref.xpath ?? "", new xmldom.DOMParser().parseFromString(this.xadesQualifyingProperties()), this.namespaceResolver);

Check failure on line 928 in src/signed-xml.ts

View workflow job for this annotation

GitHub Actions / Lint Code

Property 'xadesQualifyingProperties' does not exist on type 'SignedXml'.

Check failure on line 928 in src/signed-xml.ts

View workflow job for this annotation

GitHub Actions / Test Code (ubuntu-latest, 16, false)

Property 'xadesQualifyingProperties' does not exist on type 'SignedXml'.

Check failure on line 928 in src/signed-xml.ts

View workflow job for this annotation

GitHub Actions / Test Code (ubuntu-latest, 18, false)

Property 'xadesQualifyingProperties' does not exist on type 'SignedXml'.

Check failure on line 928 in src/signed-xml.ts

View workflow job for this annotation

GitHub Actions / Test Code (ubuntu-latest, 20, false)

Property 'xadesQualifyingProperties' does not exist on type 'SignedXml'.

Check failure on line 928 in src/signed-xml.ts

View workflow job for this annotation

GitHub Actions / Test Code (ubuntu-latest, latest, true)

Property 'xadesQualifyingProperties' does not exist on type 'SignedXml'.
}
if (!utils.isArrayHasLength(nodes)) {
throw new Error(
`the following xpath cannot be signed because it was not found: ${ref.xpath}`,
);
}
}

for (const node of nodes) {
let addattr="";
if (node.localName=="SignedProperties") addattr=' Type="http://uri.etsi.org/01903#SignedProperties"';

Check failure on line 939 in src/signed-xml.ts

View workflow job for this annotation

GitHub Actions / Lint Code

Property 'localName' does not exist on type 'Node'.

Check failure on line 939 in src/signed-xml.ts

View workflow job for this annotation

GitHub Actions / Test Code (ubuntu-latest, 16, false)

Property 'localName' does not exist on type 'Node'.

Check failure on line 939 in src/signed-xml.ts

View workflow job for this annotation

GitHub Actions / Test Code (ubuntu-latest, 18, false)

Property 'localName' does not exist on type 'Node'.

Check failure on line 939 in src/signed-xml.ts

View workflow job for this annotation

GitHub Actions / Test Code (ubuntu-latest, 20, false)

Property 'localName' does not exist on type 'Node'.

Check failure on line 939 in src/signed-xml.ts

View workflow job for this annotation

GitHub Actions / Test Code (ubuntu-latest, latest, true)

Property 'localName' does not exist on type 'Node'.
if (ref.isEmptyUri) {
res += `<${prefix}Reference URI="">`;
} else {
const id = this.ensureHasId(node);
ref.uri = id;
res += `<${prefix}Reference URI="#${id}">`;
res += `<${prefix}Reference URI=""${addattr}>`;
}
else {
const id = this.ensureHasId(node);
ref.uri = id;
res += `<${prefix}Reference URI="#${id}"${addattr}>`;
}
res += `<${prefix}Transforms>`;
for (const trans of ref.transforms || []) {
Expand Down

0 comments on commit 17c628c

Please sign in to comment.