@devlas/dte-sii 2.5.2 → 2.5.4

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/SiiPortalAuth.js CHANGED
@@ -1,5 +1,5 @@
1
- // Copyright (c) 2026 Devlas SpA — https://devlas.cl
2
- // Licencia MIT. Ver archivo LICENSE para mas detalles.
1
+ // Copyright (c) 2026 Devlas SpA — https://devlas.cl
2
+ // Licencia MIT. Ver archivo LICENSE para mas detalles.
3
3
  /**
4
4
  * SiiPortalAuth.js
5
5
  *
@@ -411,7 +411,7 @@ class SiiPortalAuth {
411
411
  static _parsearTablaEmpresa(html) {
412
412
  const datos = {};
413
413
 
414
- for (const row of html.matchAll(/<tr>[\s\S]*?<\/tr>/gi)) {
414
+ for (const row of html.matchAll(/<tr[^>]*>[\s\S]*?<\/tr>/gi)) {
415
415
  const celdas = [...row[0].matchAll(/<td[^>]*>([\s\S]*?)<\/td>/gi)]
416
416
  .map(m => m[1]
417
417
  .replace(/<[^>]+>/g, '')
package/dte-sii.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- /**
1
+ /**
2
2
  * @devlas/dte-sii - Type Definitions
3
- *
3
+ *
4
4
  * TypeScript declarations for @devlas/dte-sii
5
- *
6
- * @version 2.3.0
5
+ *
6
+ * @version 2.5.3
7
7
  */
8
8
 
9
9
  // ============================================
@@ -220,7 +220,7 @@ export class DteSiiError extends Error {
220
220
  code: ErrorCode;
221
221
  details: ErrorDetails;
222
222
  timestamp: string;
223
-
223
+
224
224
  constructor(message: string, code?: ErrorCode, details?: ErrorDetails);
225
225
  toJSON(): object;
226
226
  toString(): string;
@@ -292,11 +292,408 @@ export interface SaveEnvioArtifactsParams {
292
292
  baseDir?: string;
293
293
  }
294
294
 
295
+ // ============================================
296
+ // PFX TYPES
297
+ // ============================================
298
+
299
+ export interface PfxData {
300
+ privateKey: object;
301
+ certificate: object;
302
+ privateKeyPem: string;
303
+ certificatePem: string;
304
+ subject: Record<string, string>;
305
+ rut: string;
306
+ cn: string;
307
+ notBefore: Date;
308
+ notAfter: Date;
309
+ }
310
+
311
+ // ============================================
312
+ // TOKEN CACHE TYPES
313
+ // ============================================
314
+
315
+ export interface TokenCacheEntry {
316
+ key: string;
317
+ ambiente: string;
318
+ tipo: string;
319
+ rutEmisor: string;
320
+ createdAt: string;
321
+ expiresAt: string;
322
+ isExpired: boolean;
323
+ remainingMinutes: number;
324
+ }
325
+
326
+ export interface TokenCacheStats {
327
+ total: number;
328
+ active: number;
329
+ expired: number;
330
+ entries: TokenCacheEntry[];
331
+ }
332
+
333
+ // ============================================
334
+ // CONFIG TYPES (global)
335
+ // ============================================
336
+
337
+ export interface RetryConfig {
338
+ maxRetries?: number;
339
+ initialDelay?: number;
340
+ maxDelay?: number;
341
+ backoffMultiplier?: number;
342
+ retryableStatusCodes?: number[];
343
+ retryableErrors?: string[];
344
+ }
345
+
346
+ export interface TokenCacheConfig {
347
+ enabled?: boolean;
348
+ ttlMinutes?: number;
349
+ }
350
+
351
+ export interface TimeoutConfig {
352
+ soap?: number;
353
+ rest?: number;
354
+ upload?: number;
355
+ }
356
+
357
+ export interface DebugConfig {
358
+ saveArtifacts?: boolean;
359
+ logLevel?: string;
360
+ }
361
+
362
+ export interface GlobalConfig {
363
+ retry?: RetryConfig;
364
+ tokenCache?: TokenCacheConfig;
365
+ timeout?: TimeoutConfig;
366
+ debug?: DebugConfig;
367
+ }
368
+
369
+ export const DEFAULT_CONFIG: Required<GlobalConfig>;
370
+
371
+ // ============================================
372
+ // LOGGER TYPES
373
+ // ============================================
374
+
375
+ export const LOG_LEVELS: {
376
+ SILENT: 0;
377
+ ERROR: 1;
378
+ WARN: 2;
379
+ INFO: 3;
380
+ DEBUG: 4;
381
+ TRACE: 5;
382
+ };
383
+
384
+ export type LogLevel = keyof typeof LOG_LEVELS;
385
+
386
+ export interface LoggerConfig {
387
+ level?: LogLevel | number;
388
+ prefix?: string;
389
+ timestamps?: boolean;
390
+ colors?: boolean;
391
+ }
392
+
393
+ export interface Logger {
394
+ error(...args: any[]): void;
395
+ warn(...args: any[]): void;
396
+ info(...args: any[]): void;
397
+ debug(...args: any[]): void;
398
+ trace(...args: any[]): void;
399
+ log(...args: any[]): void;
400
+ }
401
+
402
+ export interface ScopedLogger extends Logger {
403
+ scope: string;
404
+ }
405
+
406
+ // ============================================
407
+ // ENDPOINTS TYPES
408
+ // ============================================
409
+
410
+ export const HOSTS: {
411
+ certificacion: string;
412
+ produccion: string;
413
+ };
414
+
415
+ export const SOAP_ENDPOINTS: {
416
+ certificacion: { seed: string; token: string; upload: string; estado: string; estadoDte: string };
417
+ produccion: { seed: string; token: string; upload: string; estado: string; estadoDte: string };
418
+ };
419
+
420
+ export const REST_ENDPOINTS: {
421
+ certificacion: { semilla: string; token: string; envio: string; estado: string };
422
+ produccion: { semilla: string; token: string; envio: string; estado: string };
423
+ };
424
+
425
+ export const CERT_ENDPOINTS: Record<string, string>;
426
+
427
+ // ============================================
428
+ // CONSTANTS TYPES
429
+ // ============================================
430
+
431
+ export const TIPOS_DTE: {
432
+ FACTURA: 33;
433
+ FACTURA_ELECTRONICA: 33;
434
+ FACTURA_EXENTA: 34;
435
+ FACTURA_EXENTA_ELECTRONICA: 34;
436
+ BOLETA: 39;
437
+ BOLETA_ELECTRONICA: 39;
438
+ BOLETA_EXENTA: 41;
439
+ BOLETA_EXENTA_ELECTRONICA: 41;
440
+ LIQUIDACION_FACTURA: 43;
441
+ FACTURA_COMPRA: 46;
442
+ FACTURA_COMPRA_ELECTRONICA: 46;
443
+ GUIA_DESPACHO: 52;
444
+ GUIA_DESPACHO_ELECTRONICA: 52;
445
+ NOTA_DEBITO: 56;
446
+ NOTA_DEBITO_ELECTRONICA: 56;
447
+ NOTA_CREDITO: 61;
448
+ NOTA_CREDITO_ELECTRONICA: 61;
449
+ };
450
+
451
+ export const TIPOS_BOLETA: number[];
452
+ export const TIPOS_EXENTOS: number[];
453
+ export const NOMBRES_DTE: Record<number, string>;
454
+ export const TASA_IVA: number;
455
+ export const IDK_CERTIFICACION: number;
456
+
457
+ // ============================================
458
+ // CORE CLASSES
459
+ // ============================================
460
+
461
+ export class Certificado {
462
+ rut: string;
463
+ nombre: string;
464
+ cert: object;
465
+ privateKey: object;
466
+
467
+ constructor(pfxBuffer: Buffer, password: string);
468
+
469
+ getPrivateKeyPem(): string;
470
+ getCertificatePem(): string;
471
+ getPrivateKeyPEM(): string;
472
+ getCertificatePEM(): string;
473
+ getCertificateBase64(): string;
474
+ getModulus(): string;
475
+ getExponent(): string;
476
+ sign(data: string, encoding?: string): string;
477
+ }
478
+
479
+ export class CAF {
480
+ tipo: number;
481
+ folioDesde: number;
482
+ folioHasta: number;
483
+ rutEmisor: string;
484
+ privateKeyPem: string;
485
+ privateKey: object;
486
+ data: object;
487
+
488
+ constructor(xmlContent: string);
489
+
490
+ getRutEmisor(): string;
491
+ getTipoDTE(): number;
492
+ getFolioDesde(): number;
493
+ getFolioHasta(): number;
494
+ getIDK(): number;
495
+ esCertificacion(): boolean;
496
+ getNombreTipoDTE(corto?: boolean): string;
497
+ getCafXml(): string;
498
+ sign(data: string): string;
499
+ isFolioValido(folio: number): boolean;
500
+ validarFolio(folio: number): void;
501
+ getFoliosDisponibles(): number;
502
+ }
503
+
504
+ export interface DteDatos {
505
+ Encabezado: {
506
+ IdDoc: {
507
+ TipoDTE: number;
508
+ Folio: number;
509
+ FchEmis: string;
510
+ [key: string]: any;
511
+ };
512
+ Emisor: Emisor;
513
+ Receptor: Receptor;
514
+ Totales: Totales;
515
+ };
516
+ Detalle?: DetalleItem[];
517
+ DscRcgGlobal?: DscRcgGlobal[];
518
+ Referencia?: Referencia[];
519
+ }
520
+
521
+ export interface DteSimplificado {
522
+ tipo: number;
523
+ folio: number;
524
+ fechaEmision?: string;
525
+ emisor: EmisorConfig;
526
+ receptor?: ReceptorConfig;
527
+ items: ItemSimple[];
528
+ referencias?: Referencia[];
529
+ certificado?: Certificado;
530
+ caf?: CAF;
531
+ [key: string]: any;
532
+ }
533
+
534
+ export class DTE {
535
+ datos: DteDatos;
536
+ montoTotal: number;
537
+ fechaEmision: string | undefined;
538
+ xml: string | null;
539
+ tedXml: string | null;
540
+ tmstFirma: string | null;
541
+
542
+ constructor(datos: DteDatos | DteSimplificado);
543
+
544
+ generarXML(): string;
545
+ timbrar(caf: CAF): string;
546
+ firmar(certificado: Certificado): string;
547
+ getXML(): string;
548
+ getTipoDTE(): number;
549
+ getFolio(): number;
550
+ }
551
+
552
+ export class Signer {
553
+ certificado: Certificado;
554
+
555
+ constructor(certificado: Certificado);
556
+
557
+ firmarSetDTE(xmlSinFirma: string, setId: string, rootTag: string): string;
558
+ firmarDocumento(xmlSinFirma: string, docId: string): string;
559
+ }
560
+
561
+ export interface EnvioConfig {
562
+ certificado: Certificado;
563
+ rutEmisor: string;
564
+ rutEnvia: string;
565
+ fchResol: string;
566
+ nroResol: number;
567
+ ambiente?: 'certificacion' | 'produccion';
568
+ }
569
+
570
+ export class EnvioDTE {
571
+ constructor(config: EnvioConfig);
572
+ agregar(dte: DTE): this;
573
+ generar(): string;
574
+ getXML(): string;
575
+ }
576
+
577
+ export class EnvioBOLETA {
578
+ constructor(config: EnvioConfig);
579
+ agregar(dte: DTE): this;
580
+ generar(): string;
581
+ getXML(): string;
582
+ }
583
+
584
+ // ============================================
585
+ // SERVICES
586
+ // ============================================
587
+
588
+ export class BoletaService {
589
+ constructor(config: object);
590
+ emitir(datos: object): Promise<object>;
591
+ }
592
+
593
+ export interface EnviadorSIIConfig {
594
+ certificado: Certificado;
595
+ rutEmisor: string;
596
+ ambiente?: 'certificacion' | 'produccion';
597
+ }
598
+
599
+ export class EnviadorSII {
600
+ constructor(config: EnviadorSIIConfig);
601
+ enviar(envio: EnvioDTE | EnvioBOLETA): Promise<object>;
602
+ consultarEstado(trackId: string): Promise<object>;
603
+ consultarEstadoDte(params: object): Promise<object>;
604
+ }
605
+
606
+ // ============================================
607
+ // FOLIO MANAGEMENT
608
+ // ============================================
609
+
610
+ export interface FolioServiceConfig {
611
+ baseDir?: string;
612
+ cafDir?: string;
613
+ }
614
+
615
+ export class FolioService {
616
+ constructor(config?: FolioServiceConfig);
617
+ getNextFolio(tipoDte: number, rutEmisor: string, caf: CAF): Promise<number>;
618
+ markFolioUsed(tipoDte: number, folio: number, rutEmisor: string): Promise<void>;
619
+ }
620
+
621
+ export interface FolioRegistryOptions {
622
+ registryPath?: string;
623
+ baseDir?: string;
624
+ }
625
+
626
+ export interface FolioRegistryEntry {
627
+ folio: number;
628
+ tipoDte: number;
629
+ rutEmisor: string;
630
+ cafFingerprint: string;
631
+ estado: string;
632
+ timestamp: string;
633
+ }
634
+
635
+ export class FolioRegistry {
636
+ registryPath: string;
637
+
638
+ constructor(options?: FolioRegistryOptions);
639
+
640
+ load(): { version: number; entries: Record<string, FolioRegistryEntry> };
641
+ save(registry: object): void;
642
+ static createCafFingerprint(cafXml: string): string | undefined;
643
+ static findLatestCaf(dir: string, tipoDte: number): string | null;
644
+ static resolveCafPath(baseDir: string, tipoDte: number): string | null;
645
+ }
646
+
647
+ export function createCafFingerprint(cafXml: string): string | undefined;
648
+ export function findLatestCaf(dir: string, tipoDte: number): string | null;
649
+ export function resolveCafPath(baseDir: string, tipoDte: number): string | null;
650
+
651
+ export class SiiSession {
652
+ constructor(config: object);
653
+ getToken(tipo?: 'soap' | 'rest'): Promise<string>;
654
+ }
655
+
656
+ export class CafSolicitor {
657
+ constructor(config: object);
658
+ solicitar(tipoDte: number, cantidad?: number): Promise<string>;
659
+ }
660
+
661
+ // ============================================
662
+ // BOOKS & REPORTS
663
+ // ============================================
664
+
665
+ export class ConsumoFolio {
666
+ constructor(config: object);
667
+ agregar(dte: object): void;
668
+ generar(): string;
669
+ }
670
+
671
+ export class LibroCompraVenta {
672
+ constructor(config: object);
673
+ agregar(dte: object): void;
674
+ generar(): string;
675
+ }
676
+
677
+ export class LibroGuia {
678
+ constructor(config: object);
679
+ agregar(dte: object): void;
680
+ generar(): string;
681
+ }
682
+
683
+ // ============================================
684
+ // CERT HELPERS
685
+ // ============================================
686
+
687
+ export class CertFolioHelper {
688
+ constructor(config: object);
689
+ prepararFolios(tipoDte: number, cantidad: number): Promise<CAF>;
690
+ }
691
+
295
692
  // ============================================
296
693
  // FUNCTION DECLARATIONS
297
694
  // ============================================
298
695
 
299
- // Sanitización
696
+ // Sanitizacion
300
697
  export function sanitizeSiiText(text: string): string;
301
698
  export function truncateText(text: string, maxLen: number, preserveWords?: boolean): string;
302
699
  export function sanitizeGiroRecep(giro: string): string;
@@ -321,15 +718,21 @@ export function expandSelfClosingTags(xml: string): string;
321
718
  export function normalizeArray<T>(value: T | T[] | null | undefined): T[];
322
719
  export function extractEnvioMetadata(xml: string): EnvioMetadata;
323
720
  export function saveEnvioArtifacts(params: SaveEnvioArtifactsParams): void;
324
-
325
- // Resolución SII
721
+ export function parseXml(xml: string): object;
722
+ export function parseXmlNoNs(xml: string): object;
723
+ export function buildXml(obj: object, pretty?: boolean): string;
724
+ export function decodeXmlEntities(xml: string): string;
725
+ export function extractTagContent(xml: string, tagName: string): string | null;
726
+ export function extractAttribute(xml: string, tagName: string, attrName: string): string | null;
727
+
728
+ // Resolucion SII
326
729
  export function normalizeFechaResolucion(value: string): string;
327
730
  export function createResolucion(fecha: string, numero?: number): Resolucion;
328
731
  export function createResolucionCertificacion(fecha: string): Resolucion;
329
732
  export function createResolucionProduccion(fecha: string, numero: number): Resolucion;
330
733
  export function validarResolucion(resolucion: Resolucion, requireNumero?: boolean): ValidationResult;
331
734
 
332
- // Cálculo
735
+ // Calculo
333
736
  export const TASA_IVA_DEFAULT: number;
334
737
  export function formatDecimal(value: number, decimals?: number): string;
335
738
  export function calcularMontoItem(cantidad: number, precio: number, descuentoPct?: number): MontoItemResult;
@@ -337,6 +740,7 @@ export function calcularTotalesDesdeItems(items: ItemSimple[], options?: Totales
337
740
  export function calcularTotalesDesdeDetalle(detalle: DetalleItem[], options?: TotalesDesdeDetalleOptions): Totales;
338
741
  export function buildDetalle(items: ItemSimple[], options?: BuildDetalleOptions): DetalleItem[];
339
742
  export function buildDetalleGuia(items: ItemSimple[], options?: { sanitize?: (v: string) => string }): DetalleItem[];
743
+ export function buildDetalleCompra(items: ItemSimple[], options?: BuildDetalleOptions): DetalleItem[];
340
744
  export function buildDescuentoGlobal(descuentoPct: number, glosa?: string): DscRcgGlobal[] | null;
341
745
 
342
746
  // Referencia
@@ -363,6 +767,20 @@ export function normalizeReceptor(receptor: Partial<Receptor> | null, esBoleta?:
363
767
  export function validarReceptor(receptor: Partial<Receptor>, options?: { requireGiro?: boolean; allowConsumidorFinal?: boolean }): ValidationResult;
364
768
  export function esConsumidorFinal(receptor: Partial<Receptor>): boolean;
365
769
 
770
+ // Constantes DTE
771
+ export function esBoleta(tipoDte: number): boolean;
772
+ export function esExento(tipoDte: number): boolean;
773
+ export function esNota(tipoDte: number): boolean;
774
+ export function getNombreDte(tipoDte: number, corto?: boolean): string;
775
+ export function esTipoValido(tipoDte: number): boolean;
776
+
777
+ // Endpoints SII
778
+ export function getHost(ambiente: 'certificacion' | 'produccion'): string;
779
+ export function getSoapUrl(ambiente: 'certificacion' | 'produccion', endpoint: string): string;
780
+ export function getRestUrl(ambiente: 'certificacion' | 'produccion', endpoint: string): string;
781
+ export function getCertUrl(endpoint: string): string;
782
+ export function validateAmbiente(ambiente: string): void;
783
+
366
784
  // Errores
367
785
  export function configError(message: string, details?: ErrorDetails): DteSiiError;
368
786
  export function certError(message: string, code?: ErrorCode, details?: ErrorDetails): DteSiiError;
@@ -372,12 +790,53 @@ export function siiError(message: string, code?: ErrorCode, details?: ErrorDetai
372
790
  export function xmlError(message: string, details?: ErrorDetails): DteSiiError;
373
791
  export function wrapError(error: Error, code?: ErrorCode, details?: ErrorDetails): DteSiiError;
374
792
 
793
+ // Logger
794
+ export const logger: Logger;
795
+ export function configureLogger(config: LoggerConfig): void;
796
+ export function silenceLogger(): void;
797
+ export function enableLogger(): void;
798
+ export function getLoggerConfig(): LoggerConfig;
799
+ export function createScopedLogger(scope: string): ScopedLogger;
800
+
801
+ // Configuracion Global
802
+ export function getConfig(): Required<GlobalConfig>;
803
+ export function getConfigSection<K extends keyof GlobalConfig>(section: K): Required<GlobalConfig>[K];
804
+ export function configure(options: GlobalConfig): Required<GlobalConfig>;
805
+ export function configureRetry(options: RetryConfig): RetryConfig;
806
+ export function configureTokenCache(options: TokenCacheConfig): TokenCacheConfig;
807
+ export function configureTimeout(options: TimeoutConfig): TimeoutConfig;
808
+ export function resetConfig(): Required<GlobalConfig>;
809
+ export function configureForProduction(): Required<GlobalConfig>;
810
+ export function configureForDevelopment(): Required<GlobalConfig>;
811
+ export function calculateRetryDelay(attempt: number): number;
812
+ export function isRetryableError(error: Error): boolean;
813
+ export function isRetryableStatus(status: number): boolean;
814
+ export function withRetry<T>(fn: () => Promise<T>, options?: RetryConfig): Promise<T>;
815
+
816
+ // Token Cache
817
+ export function getCachedToken(ambiente: string, tipo: string, rutEmisor: string): string | null;
818
+ export function setCachedToken(ambiente: string, tipo: string, rutEmisor: string, token: string, ttlMinutes?: number): void;
819
+ export function invalidateToken(ambiente: string, tipo: string, rutEmisor: string): void;
820
+ export function invalidateAmbiente(ambiente: string): void;
821
+ export function invalidateEmisor(rutEmisor: string): void;
822
+ export function clearTokenCache(): void;
823
+ export function getTokenCacheStats(): TokenCacheStats;
824
+ export function pruneExpiredTokens(): number;
825
+
826
+ // PFX Utils
827
+ export function loadPfxFromBuffer(pfxBuffer: Buffer, password: string): PfxData;
828
+ export function loadPfxFromFile(filePath: string, password: string): PfxData;
829
+ export function extractSubjectFields(certificate: object): Record<string, string>;
830
+ export function extractRutFromCertificate(certificate: object): string;
831
+ export function isCertificateExpired(notAfter: Date): boolean;
832
+ export function getDaysUntilExpiry(notAfter: Date): number;
833
+ export function createTlsOptions(certificado: Certificado): object;
834
+
375
835
  // ============================================
376
836
  // UTILS NAMESPACE
377
837
  // ============================================
378
838
 
379
839
  export const utils: {
380
- // Sanitización
381
840
  sanitizeSiiText: typeof sanitizeSiiText;
382
841
  truncateText: typeof truncateText;
383
842
  sanitizeGiroRecep: typeof sanitizeGiroRecep;
@@ -385,8 +844,7 @@ export const utils: {
385
844
  sanitizeNombreItem: typeof sanitizeNombreItem;
386
845
  sanitizeDescripcionItem: typeof sanitizeDescripcionItem;
387
846
  safeSegment: typeof safeSegment;
388
-
389
- // RUT
847
+
390
848
  formatRut: typeof formatRut;
391
849
  cleanRut: typeof cleanRut;
392
850
  splitRut: typeof splitRut;
@@ -395,22 +853,25 @@ export const utils: {
395
853
  calcularDV: typeof calcularDV;
396
854
  validarRut: typeof validarRut;
397
855
  validateAndFormatRut: typeof validateAndFormatRut;
398
-
399
- // XML
856
+
400
857
  formatBase64InXml: typeof formatBase64InXml;
401
858
  expandSelfClosingTags: typeof expandSelfClosingTags;
402
859
  normalizeArray: typeof normalizeArray;
403
860
  extractEnvioMetadata: typeof extractEnvioMetadata;
404
861
  saveEnvioArtifacts: typeof saveEnvioArtifacts;
405
-
406
- // Resolución
862
+ parseXml: typeof parseXml;
863
+ parseXmlNoNs: typeof parseXmlNoNs;
864
+ buildXml: typeof buildXml;
865
+ decodeXmlEntities: typeof decodeXmlEntities;
866
+ extractTagContent: typeof extractTagContent;
867
+ extractAttribute: typeof extractAttribute;
868
+
407
869
  normalizeFechaResolucion: typeof normalizeFechaResolucion;
408
870
  createResolucion: typeof createResolucion;
409
871
  createResolucionCertificacion: typeof createResolucionCertificacion;
410
872
  createResolucionProduccion: typeof createResolucionProduccion;
411
873
  validarResolucion: typeof validarResolucion;
412
-
413
- // Cálculo
874
+
414
875
  TASA_IVA_DEFAULT: typeof TASA_IVA_DEFAULT;
415
876
  formatDecimal: typeof formatDecimal;
416
877
  calcularMontoItem: typeof calcularMontoItem;
@@ -418,9 +879,9 @@ export const utils: {
418
879
  calcularTotalesDesdeDetalle: typeof calcularTotalesDesdeDetalle;
419
880
  buildDetalle: typeof buildDetalle;
420
881
  buildDetalleGuia: typeof buildDetalleGuia;
882
+ buildDetalleCompra: typeof buildDetalleCompra;
421
883
  buildDescuentoGlobal: typeof buildDescuentoGlobal;
422
-
423
- // Referencia
884
+
424
885
  buildSetReferencia: typeof buildSetReferencia;
425
886
  buildDocReferencia: typeof buildDocReferencia;
426
887
  buildAnulacionReferencia: typeof buildAnulacionReferencia;
@@ -428,14 +889,12 @@ export const utils: {
428
889
  buildCorreccionMontosReferencia: typeof buildCorreccionMontosReferencia;
429
890
  buildReferenciasNcNd: typeof buildReferenciasNcNd;
430
891
  CODIGOS_REFERENCIA: typeof CODIGOS_REFERENCIA;
431
-
432
- // Emisor
892
+
433
893
  buildEmisor: typeof buildEmisor;
434
894
  buildEmisorBoleta: typeof buildEmisorBoleta;
435
895
  normalizeEmisor: typeof normalizeEmisor;
436
896
  validarEmisor: typeof validarEmisor;
437
-
438
- // Receptor
897
+
439
898
  RUT_CONSUMIDOR_FINAL: typeof RUT_CONSUMIDOR_FINAL;
440
899
  RECEPTOR_CONSUMIDOR_FINAL: typeof RECEPTOR_CONSUMIDOR_FINAL;
441
900
  buildReceptor: typeof buildReceptor;
@@ -444,8 +903,30 @@ export const utils: {
444
903
  normalizeReceptor: typeof normalizeReceptor;
445
904
  validarReceptor: typeof validarReceptor;
446
905
  esConsumidorFinal: typeof esConsumidorFinal;
447
-
448
- // Errores
906
+
907
+ esBoleta: typeof esBoleta;
908
+ esExento: typeof esExento;
909
+ esNota: typeof esNota;
910
+ getNombreDte: typeof getNombreDte;
911
+ esTipoValido: typeof esTipoValido;
912
+
913
+ TIPOS_DTE: typeof TIPOS_DTE;
914
+ TIPOS_BOLETA: typeof TIPOS_BOLETA;
915
+ TIPOS_EXENTOS: typeof TIPOS_EXENTOS;
916
+ NOMBRES_DTE: typeof NOMBRES_DTE;
917
+ TASA_IVA: typeof TASA_IVA;
918
+ IDK_CERTIFICACION: typeof IDK_CERTIFICACION;
919
+
920
+ HOSTS: typeof HOSTS;
921
+ SOAP_ENDPOINTS: typeof SOAP_ENDPOINTS;
922
+ REST_ENDPOINTS: typeof REST_ENDPOINTS;
923
+ CERT_ENDPOINTS: typeof CERT_ENDPOINTS;
924
+ getHost: typeof getHost;
925
+ getSoapUrl: typeof getSoapUrl;
926
+ getRestUrl: typeof getRestUrl;
927
+ getCertUrl: typeof getCertUrl;
928
+ validateAmbiente: typeof validateAmbiente;
929
+
449
930
  DteSiiError: typeof DteSiiError;
450
931
  ERROR_CODES: typeof ERROR_CODES;
451
932
  configError: typeof configError;
@@ -455,4 +936,44 @@ export const utils: {
455
936
  siiError: typeof siiError;
456
937
  xmlError: typeof xmlError;
457
938
  wrapError: typeof wrapError;
458
- };
939
+
940
+ logger: typeof logger;
941
+ LOG_LEVELS: typeof LOG_LEVELS;
942
+ configureLogger: typeof configureLogger;
943
+ silenceLogger: typeof silenceLogger;
944
+ enableLogger: typeof enableLogger;
945
+ getLoggerConfig: typeof getLoggerConfig;
946
+ createScopedLogger: typeof createScopedLogger;
947
+
948
+ getConfig: typeof getConfig;
949
+ getConfigSection: typeof getConfigSection;
950
+ configure: typeof configure;
951
+ configureRetry: typeof configureRetry;
952
+ configureTokenCache: typeof configureTokenCache;
953
+ configureTimeout: typeof configureTimeout;
954
+ resetConfig: typeof resetConfig;
955
+ configureForProduction: typeof configureForProduction;
956
+ configureForDevelopment: typeof configureForDevelopment;
957
+ calculateRetryDelay: typeof calculateRetryDelay;
958
+ isRetryableError: typeof isRetryableError;
959
+ isRetryableStatus: typeof isRetryableStatus;
960
+ withRetry: typeof withRetry;
961
+ DEFAULT_CONFIG: typeof DEFAULT_CONFIG;
962
+
963
+ getCachedToken: typeof getCachedToken;
964
+ setCachedToken: typeof setCachedToken;
965
+ invalidateToken: typeof invalidateToken;
966
+ invalidateAmbiente: typeof invalidateAmbiente;
967
+ invalidateEmisor: typeof invalidateEmisor;
968
+ clearTokenCache: typeof clearTokenCache;
969
+ getTokenCacheStats: typeof getTokenCacheStats;
970
+ pruneExpiredTokens: typeof pruneExpiredTokens;
971
+
972
+ loadPfxFromBuffer: typeof loadPfxFromBuffer;
973
+ loadPfxFromFile: typeof loadPfxFromFile;
974
+ extractSubjectFields: typeof extractSubjectFields;
975
+ extractRutFromCertificate: typeof extractRutFromCertificate;
976
+ isCertificateExpired: typeof isCertificateExpired;
977
+ getDaysUntilExpiry: typeof getDaysUntilExpiry;
978
+ createTlsOptions: typeof createTlsOptions;
979
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devlas/dte-sii",
3
- "version": "2.5.2",
3
+ "version": "2.5.4",
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",
@@ -30,6 +30,7 @@
30
30
  },
31
31
  "dependencies": {
32
32
  "@xmldom/xmldom": "^0.8.11",
33
+ "bwip-js": "^4.8.0",
33
34
  "fast-xml-parser": "^5.3.3",
34
35
  "got": "^11.8.6",
35
36
  "node-forge": "^1.3.3",