@devlas/dte-sii 2.12.16 → 2.12.17
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.
- package/package.json +1 -1
- package/utils/pfx.js +11 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devlas/dte-sii",
|
|
3
|
-
"version": "2.12.
|
|
3
|
+
"version": "2.12.17",
|
|
4
4
|
"description": "Facturación y boletas electrónicas para el SII de Chile. Genera, timbra, firma y envía DTEs, libros electrónicos y automatiza la certificación.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "dte-sii.d.ts",
|
package/utils/pfx.js
CHANGED
|
@@ -179,7 +179,7 @@ function extractSubjectFields(cert) {
|
|
|
179
179
|
}
|
|
180
180
|
|
|
181
181
|
/**
|
|
182
|
-
* Extraer RUT del certificado (desde serialNumber o CN)
|
|
182
|
+
* Extraer RUT del certificado (desde serialNumber, OU o CN)
|
|
183
183
|
* @param {forge.pki.Certificate} cert - Certificado
|
|
184
184
|
* @returns {string|null} RUT o null
|
|
185
185
|
*/
|
|
@@ -194,6 +194,16 @@ function extractRutFromCertificate(cert) {
|
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
196
|
|
|
197
|
+
// Intentar desde OU — algunas CAs (ej. Signapis) codifican el RUN de la
|
|
198
|
+
// persona natural acá en vez de serialNumber, y el CN es solo el nombre
|
|
199
|
+
// sin dígitos (ninguna de las dos otras estrategias lo detecta).
|
|
200
|
+
if (subject.OU) {
|
|
201
|
+
const clean = subject.OU.replace(/\./g, '').toUpperCase();
|
|
202
|
+
if (/^\d{7,8}-[\dK]$/.test(clean)) {
|
|
203
|
+
return clean;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
197
207
|
// Intentar desde CN
|
|
198
208
|
if (subject.CN) {
|
|
199
209
|
const match = subject.CN.match(/(\d{7,8}-[\dK])/i);
|