xades-bes-signer 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -138,7 +138,7 @@ function getPCK12CertInfo(certificate, certKey) {
|
|
|
138
138
|
const certificateANS1 = certX509ToASN1(cert);
|
|
139
139
|
const certificateDER = forge.asn1.toDer(certificateANS1).getBytes();
|
|
140
140
|
const hashCErtificateX509DER = (0, security_1.sha1ToBase64)(certificateDER, "utf-8");
|
|
141
|
-
const certificateX509SN = parseInt(
|
|
141
|
+
const certificateX509SN = parseInt(cert === null || cert === void 0 ? void 0 : cert.serialNumber, 16);
|
|
142
142
|
const exponent = (0, security_1.hexToBase64)(key.e.data[0].toString(16));
|
|
143
143
|
const modulus = (0, security_1.bigintToBase64)(BigInt(key.n.toString()));
|
|
144
144
|
const certificateNumber = (0, security_1.getRandomValues)();
|
package/dist/src/libs/signer.js
CHANGED
|
@@ -73,9 +73,10 @@ function getKeyInfoNode(params) {
|
|
|
73
73
|
}
|
|
74
74
|
function getSignedInfoNode(params) {
|
|
75
75
|
return (`<ds:SignedInfo Id="Signature-SignedInfo${params.signedInfoNumber}">` +
|
|
76
|
-
`\n<ds:CanonicalizationMethod
|
|
76
|
+
`\n<ds:CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n20010315"></ds:CanonicalizationMethod>` +
|
|
77
77
|
`\n<ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"></ds:SignatureMethod>` +
|
|
78
|
-
`\n<ds:Reference Id="
|
|
78
|
+
`\n<ds:Reference Id="SignedPropertiesID${params.signedPropertiesIdNumber}" `
|
|
79
|
+
+ `Type="http://uri.etsi.org/01903#SignedProperties" URI="#Signature${params.signatureNumber}-SignedProperties${params.signedPropertiesNumber}">` +
|
|
79
80
|
`\n<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></ds:DigestMethod>` +
|
|
80
81
|
`\n<ds:DigestValue>${params.sha1SignedProperties}</ds:DigestValue>` +
|
|
81
82
|
`\n</ds:Reference>` +
|
|
@@ -90,12 +91,12 @@ function getSignedInfoNode(params) {
|
|
|
90
91
|
`\n<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></ds:DigestMethod>` +
|
|
91
92
|
`\n<ds:DigestValue>${params.sha1Xml}</ds:DigestValue>` +
|
|
92
93
|
`\n</ds:Reference>` +
|
|
93
|
-
`</ds:SignedInfo
|
|
94
|
+
`</ds:SignedInfo>`);
|
|
94
95
|
}
|
|
95
96
|
function getSignatureObject(params) {
|
|
96
97
|
const objectSignature = `<ds:Object Id="Signature${params.signatureNumber}-Object${params.objectNumber}">` +
|
|
97
98
|
`<etsi:QualifyingProperties Target="#Signature${params.signatureNumber}">` +
|
|
98
|
-
`${params.
|
|
99
|
+
`${params.signedProperties}` +
|
|
99
100
|
`</etsi:QualifyingProperties></ds:Object>`;
|
|
100
101
|
return objectSignature;
|
|
101
102
|
}
|
|
@@ -135,7 +136,7 @@ function sign(params) {
|
|
|
135
136
|
const arayuint8 = new Uint8Array(p12Buffer === null || p12Buffer === void 0 ? void 0 : p12Buffer.buffer);
|
|
136
137
|
let certInfo = (0, credentials_1.getPCK12CertInfo)(arayuint8, p12Password);
|
|
137
138
|
const sha1Xml = (0, security_1.sha1ToBase64)(xmlData.replace(`<?xml version="1.0" encoding="UTF-8"?>`, ""), "utf8");
|
|
138
|
-
const namespaces = 'xmlns:ds="http://www.w3.org/2000/09/xmldsig#
|
|
139
|
+
const namespaces = 'xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:estsi="http://uri.etsi.org/01903/v1.3.2#"';
|
|
139
140
|
let signedProperties = getSignedPropertiesNode({
|
|
140
141
|
signatureNumber: certInfo.radomValues.signatureNumber,
|
|
141
142
|
signedPropertiesNumber: certInfo.radomValues.signedPropertiesNumber,
|
|
@@ -187,7 +188,7 @@ function sign(params) {
|
|
|
187
188
|
const objectSignature = getSignatureObject({
|
|
188
189
|
signatureNumber: certInfo.radomValues.signatureNumber,
|
|
189
190
|
objectNumber: certInfo.radomValues.objectNumber,
|
|
190
|
-
|
|
191
|
+
signedProperties,
|
|
191
192
|
});
|
|
192
193
|
const signatureNode = getSignatureNode({
|
|
193
194
|
namespaces,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xades-bes-signer",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "XAdES-BES signer utilities for Node.js (TypeScript) — certificate handling and XAdES-BES signature helpers.",
|
|
5
5
|
"main": "/dist/src/main.js",
|
|
6
6
|
"types": "/dist/src/main.d.ts",
|