@devly-cl/sii-client 0.5.0 → 0.7.1

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.
Files changed (50) hide show
  1. package/README.md +96 -219
  2. package/dist/application/document-status.d.ts +13 -0
  3. package/dist/application/document-status.js +50 -0
  4. package/dist/application/invoice-queries.d.ts +23 -0
  5. package/dist/application/invoice-queries.js +55 -0
  6. package/dist/application/issuance.d.ts +40 -0
  7. package/dist/application/issuance.js +79 -0
  8. package/dist/contracts.d.ts +66 -0
  9. package/dist/contracts.js +2 -0
  10. package/dist/domain/company-info.d.ts +13 -0
  11. package/dist/domain/company-info.js +2 -0
  12. package/dist/domain/document-status.d.ts +93 -0
  13. package/dist/domain/document-status.js +69 -0
  14. package/dist/domain/document.d.ts +51 -0
  15. package/dist/domain/document.js +71 -0
  16. package/dist/domain/invoice-xml.d.ts +34 -11
  17. package/dist/domain/invoice-xml.js +0 -170
  18. package/dist/domain/invoicing.d.ts +78 -5
  19. package/dist/domain/invoicing.js +143 -26
  20. package/dist/domain/issued-invoice.d.ts +1 -2
  21. package/dist/domain/issued-invoice.js +4 -43
  22. package/dist/domain/rcv-document.d.ts +17 -0
  23. package/dist/domain/rcv-document.js +2 -0
  24. package/dist/domain/received-invoice.d.ts +1 -3
  25. package/dist/domain/received-invoice.js +0 -10
  26. package/dist/index.d.ts +12 -7
  27. package/dist/index.js +6 -4
  28. package/dist/infrastructure/document-status-gateway.d.ts +13 -0
  29. package/dist/infrastructure/document-status-gateway.js +127 -0
  30. package/dist/infrastructure/document-status-parser.d.ts +12 -0
  31. package/dist/infrastructure/document-status-parser.js +258 -0
  32. package/dist/infrastructure/dte-xml.d.ts +11 -0
  33. package/dist/infrastructure/dte-xml.js +248 -0
  34. package/dist/infrastructure/facturador-gateway.d.ts +31 -0
  35. package/dist/infrastructure/facturador-gateway.js +509 -0
  36. package/dist/infrastructure/facturador.d.ts +13 -3
  37. package/dist/infrastructure/facturador.js +34 -3
  38. package/dist/infrastructure/invoice-pdf.d.ts +9 -0
  39. package/dist/infrastructure/invoice-pdf.js +171 -0
  40. package/dist/infrastructure/rcv-gateway.d.ts +20 -0
  41. package/dist/infrastructure/rcv-gateway.js +109 -0
  42. package/dist/infrastructure/rcv-normalization.d.ts +13 -0
  43. package/dist/infrastructure/rcv-normalization.js +63 -0
  44. package/dist/infrastructure/sii-client.d.ts +31 -121
  45. package/dist/infrastructure/sii-client.js +69 -772
  46. package/dist/infrastructure/sii-http-session.d.ts +29 -0
  47. package/dist/infrastructure/sii-http-session.js +359 -0
  48. package/dist/{domain/sii-error.d.ts → sii-error.d.ts} +3 -3
  49. package/dist/{domain/sii-error.js → sii-error.js} +14 -4
  50. package/package.json +45 -45
@@ -0,0 +1,29 @@
1
+ import { parseRut } from '../domain/rut';
2
+ import { SiiError, type SiiDiagnostics } from '../sii-error';
3
+ import type { SiiClientOptions, SiiCredentials, SiiSession, InvoicePdfResult } from '../contracts';
4
+ export declare const RCV = "https://www4.sii.cl/consdcvinternetui/";
5
+ export declare const FACTURADOR = "https://www1.sii.cl/cgi-bin/Portal001/";
6
+ export declare const DOCUMENT_STATUS_FORM = "https://palena.sii.cl/cgi_dte/UPL/DTEauth?6";
7
+ export declare const DOCUMENT_STATUS_URL = "https://palena.sii.cl/cgi_dte/UPL/QEstadoDTE";
8
+ export declare const RECIPIENT_EVENTS_PORTAL = "https://www4.sii.cl/registrorechazodtej6ui/";
9
+ export declare const RECIPIENT_EVENTS_URL = "https://www4.sii.cl/registrorechazodtej6ui/services/data/facadeService/validarAccesoReceptor";
10
+ export declare function isRecord(value: unknown): value is Record<string, unknown>;
11
+ /** Owns one personal HTTP session; body consumption belongs to the tracked request. */
12
+ export declare class SiiHttpSession {
13
+ #private;
14
+ readonly company: ReturnType<typeof parseRut>;
15
+ constructor({ empresaRut, timeoutMs, retries, fetchImpl }: SiiClientOptions);
16
+ login({ rut, clave }: SiiCredentials, authorize: (identity: ReturnType<typeof parseRut>) => Promise<boolean>): Promise<SiiSession>;
17
+ assertReady(): ReturnType<typeof parseRut>;
18
+ cookies(url: string): Promise<import("tough-cookie").Cookie[]>;
19
+ failure(code: string, endpoint: SiiDiagnostics['endpoint'], reason: SiiDiagnostics['reason'], response?: Response, extra?: Partial<SiiDiagnostics>): SiiError;
20
+ abortFailure(signal: AbortSignal, endpoint: SiiDiagnostics['endpoint']): SiiError;
21
+ /** Track the whole PDF operation, including an unconsumed stream, until its resources close. */
22
+ pdfOperation(endpoint: SiiDiagnostics['endpoint'], operation: (signal: AbortSignal, trackStream: (stream: InvoicePdfResult['stream']) => void) => Promise<InvoicePdfResult>, signal?: AbortSignal): Promise<InvoicePdfResult>;
23
+ request<T>(url: string, consume: (response: Response) => Promise<T>, options?: RequestInit, canRetry?: boolean, allowRedirect?: boolean): Promise<T>;
24
+ json(response: Response, endpoint: SiiDiagnostics['endpoint'], signal?: AbortSignal): Promise<unknown>;
25
+ readBounded(response: Response, endpoint: SiiDiagnostics['endpoint'], limit?: number, oversizedCode?: string, signal?: AbortSignal): Promise<Uint8Array>;
26
+ dispose(pendingWrite?: Promise<unknown>): Promise<void>;
27
+ }
28
+ export declare function endpointFor(url: string): SiiDiagnostics['endpoint'];
29
+ export declare function responseFormat(response: Response, bytes?: Uint8Array): Pick<SiiDiagnostics, 'contentType' | 'responseType'>;
@@ -0,0 +1,359 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SiiHttpSession = exports.RECIPIENT_EVENTS_URL = exports.RECIPIENT_EVENTS_PORTAL = exports.DOCUMENT_STATUS_URL = exports.DOCUMENT_STATUS_FORM = exports.FACTURADOR = exports.RCV = void 0;
4
+ exports.isRecord = isRecord;
5
+ exports.endpointFor = endpointFor;
6
+ exports.responseFormat = responseFormat;
7
+ const node_crypto_1 = require("node:crypto");
8
+ const promises_1 = require("node:timers/promises");
9
+ const promises_2 = require("node:stream/promises");
10
+ const tough_cookie_1 = require("tough-cookie");
11
+ const rut_1 = require("../domain/rut");
12
+ const invoice_xml_1 = require("../domain/invoice-xml");
13
+ const sii_error_1 = require("../sii-error");
14
+ exports.RCV = 'https://www4.sii.cl/consdcvinternetui/';
15
+ exports.FACTURADOR = 'https://www1.sii.cl/cgi-bin/Portal001/';
16
+ exports.DOCUMENT_STATUS_FORM = 'https://palena.sii.cl/cgi_dte/UPL/DTEauth?6';
17
+ exports.DOCUMENT_STATUS_URL = 'https://palena.sii.cl/cgi_dte/UPL/QEstadoDTE';
18
+ exports.RECIPIENT_EVENTS_PORTAL = 'https://www4.sii.cl/registrorechazodtej6ui/';
19
+ exports.RECIPIENT_EVENTS_URL = `${exports.RECIPIENT_EVENTS_PORTAL}services/data/facadeService/validarAccesoReceptor`;
20
+ const AUTH = 'https://zeusr.sii.cl/cgi_AUT2000/CAutInicio.cgi';
21
+ const LOGOUT = 'https://zeusr.sii.cl/cgi_AUT2000/autTermino.cgi';
22
+ const SESSION = 'https://www4.sii.cl/common-1.0/services/aaSessionService/load';
23
+ const RETRYABLE = new Set([429, 502, 503, 504]);
24
+ const MAX_JSON_BYTES = 16 * 1024 * 1024;
25
+ function isRecord(value) {
26
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
27
+ }
28
+ /** Owns one personal HTTP session; body consumption belongs to the tracked request. */
29
+ class SiiHttpSession {
30
+ company;
31
+ #jar = new tough_cookie_1.CookieJar();
32
+ #fetch;
33
+ #timeoutMs;
34
+ #retries;
35
+ #identity;
36
+ #ready = false;
37
+ #used = false;
38
+ #closed = false;
39
+ #requests = new Set();
40
+ #pdfDownloads = new Map();
41
+ #disposal;
42
+ #traceId = (0, node_crypto_1.randomUUID)();
43
+ constructor({ empresaRut, timeoutMs = 15000, retries = 1, fetchImpl = globalThis.fetch }) {
44
+ this.company = (0, rut_1.parseRut)(empresaRut);
45
+ if (!Number.isInteger(timeoutMs) || timeoutMs < 1000 || timeoutMs > 30000)
46
+ throw new TypeError('timeoutMs inválido');
47
+ if (!Number.isInteger(retries) || retries < 0 || retries > 2)
48
+ throw new TypeError('retries inválido');
49
+ if (typeof fetchImpl !== 'function')
50
+ throw new TypeError('fetchImpl inválido');
51
+ this.#fetch = fetchImpl;
52
+ this.#timeoutMs = timeoutMs;
53
+ this.#retries = retries;
54
+ }
55
+ async login({ rut, clave }, authorize) {
56
+ if (this.#used || this.#closed)
57
+ throw new sii_error_1.SiiError('NEW_INSTANCE_REQUIRED');
58
+ const identity = (0, rut_1.parseRut)(rut);
59
+ if (typeof clave !== 'string' || !clave || clave.length > 256)
60
+ throw new TypeError('Clave inválida');
61
+ this.#used = true;
62
+ try {
63
+ const body = new URLSearchParams({ rut: identity.rut, dv: identity.dv, referencia: exports.RCV, '411': '', rutcntr: identity.formatted, clave });
64
+ await this.request(AUTH, async (response) => {
65
+ await response.body?.cancel();
66
+ const cookies = await this.cookies(exports.RCV);
67
+ if (!cookies.some(c => c.key === 'TOKEN' && c.value))
68
+ throw this.failure('LOGIN_NOT_CONFIRMED', 'CAutInicio.cgi', 'LOGIN_NOT_CONFIRMED', response);
69
+ }, { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded', Origin: 'https://zeusr.sii.cl', Referer: `https://zeusr.sii.cl/AUT2000/InicioAutenticacion/IngresoRutClave.html?${exports.RCV}` }, body: body.toString() });
70
+ await this.request(SESSION, async (response) => {
71
+ const sessionEnvelope = await this.json(response, 'aaSessionService/load');
72
+ const session = isRecord(sessionEnvelope) && isRecord(sessionEnvelope.data) ? sessionEnvelope.data : undefined;
73
+ if (session?.hayRepresentacion !== false)
74
+ throw this.failure('PERSONAL_SESSION_REQUIRED', 'aaSessionService/load', 'PERSONAL_SESSION_REQUIRED', response);
75
+ if (`${session?.rut}-${session?.dv}`.toUpperCase() !== identity.formatted)
76
+ throw this.failure('SESSION_IDENTITY_MISMATCH', 'aaSessionService/load', 'SESSION_IDENTITY_MISMATCH', response);
77
+ }, {}, true);
78
+ this.#identity = identity;
79
+ if (!await authorize(identity))
80
+ throw this.failure('COMPANY_NOT_AUTHORIZED', 'getDcvEmpresasAutorizadas', 'COMPANY_NOT_AUTHORIZED');
81
+ if (this.#closed)
82
+ throw new sii_error_1.SiiError('CLIENT_CLOSED');
83
+ this.#ready = true;
84
+ return { usuarioRut: identity.formatted, empresaRut: this.company.formatted, representacion: false };
85
+ }
86
+ catch (error) {
87
+ await this.dispose();
88
+ throw error;
89
+ }
90
+ }
91
+ assertReady() {
92
+ if (!this.#ready || this.#closed || !this.#identity)
93
+ throw new sii_error_1.SiiError('SESSION_REQUIRED');
94
+ return this.#identity;
95
+ }
96
+ cookies(url) { return this.#jar.getCookies(url); }
97
+ failure(code, endpoint, reason, response, extra = {}) {
98
+ return new sii_error_1.SiiError(code, response?.status, { traceId: this.#traceId, stage: ENDPOINT_STAGES[endpoint], endpoint, reason,
99
+ ...(response ? { httpStatus: response.status, ...responseFormat(response) } : {}), ...extra });
100
+ }
101
+ abortFailure(signal, endpoint) {
102
+ return signal.reason instanceof sii_error_1.SiiError ? signal.reason : this.failure('SII_OPERATION_ABORTED', endpoint, 'OPERATION_ABORTED');
103
+ }
104
+ /** Track the whole PDF operation, including an unconsumed stream, until its resources close. */
105
+ async pdfOperation(endpoint, operation, signal) {
106
+ this.assertReady();
107
+ if (signal !== undefined && !(signal instanceof AbortSignal))
108
+ throw new TypeError('signal inválida');
109
+ const controller = new AbortController();
110
+ const onAbort = () => controller.abort(this.failure('SII_OPERATION_ABORTED', endpoint, 'OPERATION_ABORTED'));
111
+ const timer = setTimeout(() => controller.abort(this.failure('SII_TRANSPORT_ERROR', endpoint, 'TIMEOUT')), this.#timeoutMs);
112
+ let downloadStream;
113
+ let streamCompletion;
114
+ let release;
115
+ const closing = new Promise(resolve => {
116
+ release = () => {
117
+ clearTimeout(timer);
118
+ signal?.removeEventListener('abort', onAbort);
119
+ this.#pdfDownloads.delete(controller);
120
+ downloadStream = undefined;
121
+ resolve();
122
+ };
123
+ });
124
+ this.#pdfDownloads.set(controller, closing);
125
+ signal?.addEventListener('abort', onAbort, { once: true });
126
+ if (signal?.aborted)
127
+ onAbort();
128
+ try {
129
+ if (controller.signal.aborted)
130
+ throw this.abortFailure(controller.signal, endpoint);
131
+ const result = await operation(controller.signal, stream => {
132
+ downloadStream = stream;
133
+ streamCompletion = (0, promises_2.finished)(stream, { cleanup: true }).then(release, release);
134
+ });
135
+ if (controller.signal.aborted) {
136
+ result.stream.destroy(this.abortFailure(controller.signal, endpoint));
137
+ throw this.abortFailure(controller.signal, endpoint);
138
+ }
139
+ return result;
140
+ }
141
+ catch (error) {
142
+ if (downloadStream) {
143
+ downloadStream.destroy(error instanceof sii_error_1.SiiError ? error : this.failure('SII_TRANSPORT_ERROR', endpoint, 'TRANSPORT_ERROR'));
144
+ await streamCompletion;
145
+ }
146
+ else
147
+ release();
148
+ throw controller.signal.aborted ? this.abortFailure(controller.signal, endpoint) : error;
149
+ }
150
+ }
151
+ request(url, consume, options = {}, canRetry = false, allowRedirect = false) {
152
+ const request = this.#sendRequest(url, options, canRetry, allowRedirect).then(async (response) => {
153
+ try {
154
+ const result = await consume(response);
155
+ if (this.#closed)
156
+ throw new sii_error_1.SiiError('CLIENT_CLOSED');
157
+ if (options.signal?.aborted)
158
+ throw this.abortFailure(options.signal, endpointFor(url));
159
+ return result;
160
+ }
161
+ catch (error) {
162
+ await response.body?.cancel().catch(() => { });
163
+ throw error;
164
+ }
165
+ }).catch(error => {
166
+ if (this.#closed)
167
+ throw new sii_error_1.SiiError('CLIENT_CLOSED');
168
+ if (options.signal?.aborted)
169
+ throw this.abortFailure(options.signal, endpointFor(url));
170
+ throw error;
171
+ });
172
+ this.#requests.add(request);
173
+ void request.then(() => this.#requests.delete(request), () => this.#requests.delete(request));
174
+ return request;
175
+ }
176
+ async json(response, endpoint, signal) {
177
+ if (!response.headers.get('content-type')?.toLowerCase().includes('json')) {
178
+ await response.body?.cancel();
179
+ throw this.failure('SESSION_OR_INTERACTIVE_AUTH_REQUIRED', endpoint, 'SESSION_REQUIRED', response);
180
+ }
181
+ const bytes = response.body ? await this.readBounded(response, endpoint, MAX_JSON_BYTES, 'SII_PROTOCOL_CHANGED', signal) : new Uint8Array();
182
+ try {
183
+ return JSON.parse(new TextDecoder().decode(bytes));
184
+ }
185
+ catch {
186
+ throw this.failure('SII_PROTOCOL_CHANGED', endpoint, 'INVALID_RESPONSE', response);
187
+ }
188
+ }
189
+ async readBounded(response, endpoint, limit = invoice_xml_1.MAX_DTE_XML_BYTES, oversizedCode = 'SII_XML_INVALID', signal) {
190
+ const reader = response.body?.getReader();
191
+ if (!reader)
192
+ throw this.failure('SII_XML_UNAVAILABLE', endpoint, 'EMPTY_RESPONSE', response, { responseType: 'EMPTY' });
193
+ let size = 0;
194
+ const chunks = [];
195
+ let cancellation;
196
+ const cancelSource = () => cancellation ??= reader.cancel().catch(() => { });
197
+ const onAbort = () => { void cancelSource(); };
198
+ signal?.addEventListener('abort', onAbort, { once: true });
199
+ try {
200
+ for (;;) {
201
+ if (signal?.aborted)
202
+ throw this.abortFailure(signal, endpoint);
203
+ const { done, value } = await reader.read();
204
+ if (signal?.aborted)
205
+ throw this.abortFailure(signal, endpoint);
206
+ if (done)
207
+ break;
208
+ size += value.byteLength;
209
+ if (size > limit) {
210
+ await cancelSource();
211
+ throw this.failure(oversizedCode, endpoint, 'RESPONSE_TOO_LARGE', response);
212
+ }
213
+ chunks.push(value);
214
+ }
215
+ return Buffer.concat(chunks, size);
216
+ }
217
+ catch (error) {
218
+ throw signal?.aborted ? this.abortFailure(signal, endpoint) : error instanceof sii_error_1.SiiError ? error : this.failure('SII_TRANSPORT_ERROR', endpoint, error instanceof Error && error.name === 'TimeoutError' ? 'TIMEOUT' : 'TRANSPORT_ERROR', response);
219
+ }
220
+ finally {
221
+ signal?.removeEventListener('abort', onAbort);
222
+ await cancellation;
223
+ reader.releaseLock();
224
+ }
225
+ }
226
+ dispose(pendingWrite) {
227
+ if (this.#disposal)
228
+ return this.#disposal;
229
+ this.#closed = true;
230
+ this.#ready = false;
231
+ this.#identity = undefined;
232
+ const downloads = [...this.#pdfDownloads.values()];
233
+ for (const controller of this.#pdfDownloads.keys())
234
+ controller.abort(new sii_error_1.SiiError('CLIENT_CLOSED'));
235
+ this.#disposal = (async () => {
236
+ try {
237
+ // Cleanup is never included in the requests or write it waits for.
238
+ await Promise.allSettled([...this.#requests, ...downloads, ...(pendingWrite ? [pendingWrite] : [])]);
239
+ const cookies = await this.cookies(LOGOUT);
240
+ if (!cookies.some(c => c.value && ['TOKEN', 'NETSCAPE_LIVEWIRE.mac'].includes(c.key)))
241
+ return;
242
+ const headers = new Headers({ Referer: exports.RCV, Cookie: cookies.map(c => c.cookieString()).join('; ') });
243
+ const response = await this.#fetch(LOGOUT, { method: 'GET', headers, redirect: 'manual', signal: AbortSignal.timeout(this.#timeoutMs) });
244
+ if (!response.ok) {
245
+ await response.body?.cancel();
246
+ if (!(response.status >= 300 && response.status < 400 && response.headers.get('location') === 'https://homer.sii.cl/'))
247
+ throw new sii_error_1.SiiError('SII_LOGOUT_FAILED');
248
+ }
249
+ else {
250
+ const page = Buffer.from(await this.readBounded(response, 'autTermino.cgi')).toString('latin1');
251
+ const codes = page.match(/\b\d{2}\.\d{2}\.\d{3}\.\d{3}\.\d{3}\.\d{2}\b/g);
252
+ if (codes?.some(code => code !== '01.01.205.529.269.28'))
253
+ throw new sii_error_1.SiiError('SII_LOGOUT_FAILED');
254
+ }
255
+ }
256
+ catch {
257
+ process.emitWarning('SII_LOGOUT_FAILED', { code: 'SII_LOGOUT_FAILED' });
258
+ }
259
+ finally {
260
+ await this.#jar.removeAllCookies();
261
+ }
262
+ })();
263
+ return this.#disposal;
264
+ }
265
+ async #sendRequest(url, options, canRetry, allowRedirect) {
266
+ const endpoint = endpointFor(url);
267
+ for (let attempt = 0;; attempt++) {
268
+ if (this.#closed)
269
+ throw new sii_error_1.SiiError('CLIENT_CLOSED');
270
+ if (options.signal?.aborted)
271
+ throw this.abortFailure(options.signal, endpoint);
272
+ const headers = new Headers(options.headers);
273
+ const cookie = await this.#jar.getCookieString(url);
274
+ if (this.#closed)
275
+ throw new sii_error_1.SiiError('CLIENT_CLOSED');
276
+ if (cookie)
277
+ headers.set('Cookie', cookie);
278
+ let response;
279
+ try {
280
+ const timeout = AbortSignal.timeout(this.#timeoutMs);
281
+ response = await this.#fetch(url, { ...options, headers, redirect: 'manual', signal: options.signal ? AbortSignal.any([options.signal, timeout]) : timeout });
282
+ }
283
+ catch (error) {
284
+ if (options.signal?.aborted)
285
+ throw this.abortFailure(options.signal, endpoint);
286
+ if (!canRetry || attempt >= this.#retries)
287
+ throw this.failure('SII_TRANSPORT_ERROR', endpoint, error instanceof Error && error.name === 'TimeoutError' ? 'TIMEOUT' : 'TRANSPORT_ERROR', undefined, { attempts: attempt + 1 });
288
+ await (0, promises_1.setTimeout)(250 * (attempt + 1), undefined, { signal: options.signal ?? undefined });
289
+ continue;
290
+ }
291
+ for (const setCookie of response.headers.getSetCookie())
292
+ await this.#jar.setCookie(setCookie, url, { ignoreError: true });
293
+ if (this.#closed) {
294
+ await response.body?.cancel();
295
+ throw new sii_error_1.SiiError('CLIENT_CLOSED');
296
+ }
297
+ if (options.signal?.aborted) {
298
+ await response.body?.cancel();
299
+ throw this.abortFailure(options.signal, endpoint);
300
+ }
301
+ if (canRetry && RETRYABLE.has(response.status) && attempt < this.#retries) {
302
+ const retryAfter = response.headers.get('retry-after');
303
+ const seconds = retryAfter === null ? NaN : Number(retryAfter);
304
+ const waitMs = Number.isFinite(seconds) && seconds >= 0 ? seconds * 1000 : Date.parse(retryAfter ?? '') - Date.now();
305
+ await response.body?.cancel();
306
+ if (Number.isFinite(waitMs) && waitMs > 5000)
307
+ throw this.failure('SII_RETRY_LATER', endpoint, 'RETRY_LATER', response, { attempts: attempt + 1 });
308
+ await (0, promises_1.setTimeout)(Number.isFinite(waitMs) ? Math.max(0, waitMs) : 250 * (attempt + 1), undefined, { signal: options.signal ?? undefined });
309
+ continue;
310
+ }
311
+ if (!response.ok && !(allowRedirect && response.status >= 300 && response.status < 400)) {
312
+ await response.body?.cancel();
313
+ const redirect = response.status >= 300 && response.status < 400;
314
+ throw this.failure(redirect ? 'SESSION_OR_INTERACTIVE_AUTH_REQUIRED' : 'SII_HTTP_ERROR', endpoint, redirect ? 'SESSION_REQUIRED' : 'HTTP_ERROR', response, { attempts: attempt + 1 });
315
+ }
316
+ return response;
317
+ }
318
+ }
319
+ }
320
+ exports.SiiHttpSession = SiiHttpSession;
321
+ const ENDPOINT_STAGES = {
322
+ 'CAutInicio.cgi': 'AUTHENTICATION', 'aaSessionService/load': 'SESSION_CHECK', getDcvEmpresasAutorizadas: 'COMPANY_AUTHORIZATION',
323
+ getDatosInicio: 'RCV_INITIALIZATION', getResumen: 'RCV_SUMMARY', getDetalleCompra: 'RCV_DETAIL', getDetalleVenta: 'RCV_DETAIL',
324
+ 'mipeSelEmpresa.cgi': 'XML_COMPANY_SELECTION', 'mipeLaunchPage.cgi': 'XML_COMPANY_SELECTION', 'mipeDownLoad.cgi': 'XML_DOWNLOAD', 'autTermino.cgi': 'LOGOUT',
325
+ 'mipeGenFacEx.cgi': 'DOCUMENT_PREPARATION', 'mipeDisplayPreView.cgi': 'DOCUMENT_REVIEW', 'mipeGenXMLFirma.cgi': 'DOCUMENT_SIGNING', 'getCertDigital.cgi': 'DOCUMENT_SIGNING', 'postFirmaDigital.cgi': 'DOCUMENT_SIGNING', 'mipeSendXML.cgi': 'DOCUMENT_SEND', 'mipeAdminDocsEmi.cgi': 'DOCUMENT_RECOVERY', 'mipeGesDocEmi.cgi': 'DOCUMENT_RECOVERY', 'mipeDisplayPDF.cgi': 'PDF_DOWNLOAD', 'mipeAdminDocsRcp.cgi': 'PDF_HISTORY', 'mipeShowPdf.cgi': 'PDF_DOWNLOAD',
326
+ DTEauth: 'DOCUMENT_STATUS', QEstadoDTE: 'DOCUMENT_STATUS', registrorechazodtej6ui: 'RECIPIENT_EVENTS', validarAccesoReceptor: 'RECIPIENT_EVENTS',
327
+ };
328
+ const DOCUMENT_ENDPOINTS = new Map([
329
+ [exports.DOCUMENT_STATUS_FORM, 'DTEauth'], [exports.DOCUMENT_STATUS_URL, 'QEstadoDTE'],
330
+ [exports.RECIPIENT_EVENTS_PORTAL, 'registrorechazodtej6ui'], [exports.RECIPIENT_EVENTS_URL, 'validarAccesoReceptor'],
331
+ ]);
332
+ function endpointFor(url) {
333
+ const parsed = new URL(url);
334
+ const documentEndpoint = DOCUMENT_ENDPOINTS.get(parsed.href);
335
+ if (documentEndpoint)
336
+ return documentEndpoint;
337
+ const path = parsed.pathname;
338
+ const endpoint = path.endsWith('/aaSessionService/load') ? 'aaSessionService/load' : path.slice(path.lastIndexOf('/') + 1);
339
+ if (['DTEauth', 'QEstadoDTE', 'registrorechazodtej6ui', 'validarAccesoReceptor'].includes(endpoint))
340
+ throw new TypeError('Endpoint SII desconocido');
341
+ if (!Object.hasOwn(ENDPOINT_STAGES, endpoint))
342
+ throw new TypeError('Endpoint SII desconocido');
343
+ return endpoint;
344
+ }
345
+ function responseFormat(response, bytes) {
346
+ const contentType = response.headers.get('content-type')?.split(';')[0]?.trim().toLowerCase();
347
+ const prefix = bytes ? Buffer.from(bytes.subarray(0, 512)).toString('latin1').trimStart() : '';
348
+ const responseType = bytes?.length === 0 ? 'EMPTY'
349
+ : prefix.startsWith('%PDF-') ? 'PDF'
350
+ : bytes && bytes[0] === 0x50 && bytes[1] === 0x4b && [0x03, 0x05, 0x07].includes(bytes[2] ?? -1) ? 'ZIP'
351
+ : /^(?:<!doctype\s+html|<html|<head|<body|<script|<div)\b/i.test(prefix) ? 'HTML'
352
+ : contentType === 'text/html' ? 'HTML'
353
+ : contentType === 'application/pdf' ? 'PDF'
354
+ : contentType === 'application/zip' ? 'ZIP'
355
+ : contentType?.includes('json') ? 'JSON'
356
+ : /^(?:application|text)\/xml$/.test(contentType ?? '') || /^<(?:\?xml|DTE|EnvioDTE|SetDTE)\b/i.test(prefix) ? 'XML' : 'UNKNOWN';
357
+ // The sanitizer copies only known MIME values.
358
+ return { responseType, ...(contentType ? { contentType: contentType } : {}) };
359
+ }
@@ -1,6 +1,6 @@
1
- declare const STAGES: readonly ["AUTHENTICATION", "SESSION_CHECK", "COMPANY_AUTHORIZATION", "RCV_INITIALIZATION", "RCV_SUMMARY", "RCV_DETAIL", "XML_COMPANY_SELECTION", "XML_DOWNLOAD", "XML_PARSE", "LOGOUT", "DOCUMENT_PREPARATION", "DOCUMENT_REVIEW", "DOCUMENT_SIGNING", "DOCUMENT_SEND", "DOCUMENT_RECOVERY"];
2
- declare const ENDPOINTS: readonly ["CAutInicio.cgi", "aaSessionService/load", "getDcvEmpresasAutorizadas", "getDatosInicio", "getResumen", "getDetalleCompra", "getDetalleVenta", "mipeSelEmpresa.cgi", "mipeLaunchPage.cgi", "mipeDownLoad.cgi", "autTermino.cgi", "mipeGenFacEx.cgi", "mipeDisplayPreView.cgi", "mipeGenXMLFirma.cgi", "getCertDigital.cgi", "postFirmaDigital.cgi", "mipeSendXML.cgi", "mipeAdminDocsEmi.cgi", "mipeGesDocEmi.cgi", "mipeDisplayPDF.cgi"];
3
- declare const REASONS: readonly ["DOCUMENT_LIMIT_EXCEEDED", "DOCUMENT_NOT_FOUND", "EMPTY_RESPONSE", "HTML_RESPONSE", "PROVIDER_ERROR_PAGE", "UNEXPECTED_PDF", "UNEXPECTED_ARCHIVE", "UNEXPECTED_FORMAT", "INVALID_XML", "XML_IDENTITY_MISMATCH", "RESPONSE_TOO_LARGE", "HTTP_ERROR", "TIMEOUT", "TRANSPORT_ERROR", "RETRY_LATER", "CAPTCHA_REQUIRED", "SESSION_REQUIRED", "LOGIN_NOT_CONFIRMED", "PERSONAL_SESSION_REQUIRED", "SESSION_IDENTITY_MISMATCH", "COMPANY_NOT_AUTHORIZED", "COMPANY_SELECTION_REQUIRED", "PROVIDER_REJECTED", "INVALID_RESPONSE", "DOCUMENT_CONTENT_MISMATCH", "CERTIFICATE_UNAVAILABLE", "CERTIFICATE_PASSWORD_INVALID", "CERTIFICATE_EXPIRED", "CERTIFICATE_REVOKED", "SIGNATURE_INVALID", "ISSUANCE_OUTCOME_UNKNOWN"];
1
+ declare const STAGES: readonly ["AUTHENTICATION", "SESSION_CHECK", "COMPANY_AUTHORIZATION", "RCV_INITIALIZATION", "RCV_SUMMARY", "RCV_DETAIL", "XML_COMPANY_SELECTION", "XML_DOWNLOAD", "XML_PARSE", "LOGOUT", "DOCUMENT_PREPARATION", "DOCUMENT_REVIEW", "DOCUMENT_SIGNING", "DOCUMENT_SEND", "DOCUMENT_RECOVERY", "PDF_HISTORY", "PDF_DOWNLOAD", "DOCUMENT_STATUS", "RECIPIENT_EVENTS", "COMPANY_LOOKUP"];
2
+ declare const ENDPOINTS: readonly ["CAutInicio.cgi", "aaSessionService/load", "getDcvEmpresasAutorizadas", "getDatosInicio", "getResumen", "getDetalleCompra", "getDetalleVenta", "mipeSelEmpresa.cgi", "mipeLaunchPage.cgi", "mipeDownLoad.cgi", "autTermino.cgi", "mipeGenFacEx.cgi", "mipeDisplayPreView.cgi", "mipeGenXMLFirma.cgi", "getCertDigital.cgi", "postFirmaDigital.cgi", "mipeSendXML.cgi", "mipeAdminDocsEmi.cgi", "mipeGesDocEmi.cgi", "mipeDisplayPDF.cgi", "mipeAdminDocsRcp.cgi", "mipeShowPdf.cgi", "DTEauth", "QEstadoDTE", "registrorechazodtej6ui", "validarAccesoReceptor"];
3
+ declare const REASONS: readonly ["DOCUMENT_LIMIT_EXCEEDED", "DOCUMENT_NOT_FOUND", "EMPTY_RESPONSE", "HTML_RESPONSE", "PROVIDER_ERROR_PAGE", "UNEXPECTED_PDF", "UNEXPECTED_ARCHIVE", "UNEXPECTED_FORMAT", "INVALID_XML", "XML_IDENTITY_MISMATCH", "RESPONSE_TOO_LARGE", "HTTP_ERROR", "TIMEOUT", "TRANSPORT_ERROR", "RETRY_LATER", "CAPTCHA_REQUIRED", "SESSION_REQUIRED", "LOGIN_NOT_CONFIRMED", "PERSONAL_SESSION_REQUIRED", "SESSION_IDENTITY_MISMATCH", "COMPANY_NOT_AUTHORIZED", "COMPANY_SELECTION_REQUIRED", "PROVIDER_REJECTED", "INVALID_RESPONSE", "DOCUMENT_CONTENT_MISMATCH", "CERTIFICATE_UNAVAILABLE", "CERTIFICATE_PASSWORD_INVALID", "CERTIFICATE_EXPIRED", "CERTIFICATE_REVOKED", "SIGNATURE_INVALID", "ISSUANCE_OUTCOME_UNKNOWN", "INVALID_PDF", "PDF_IDENTITY_MISMATCH", "OPERATION_ABORTED", "DOCUMENT_IDENTITY_MISMATCH", "DOCUMENT_ACCESS_DENIED", "COMPANY_IDENTITY_MISMATCH", "COMPANY_INFO_UNAVAILABLE"];
4
4
  declare const RESPONSE_TYPES: readonly ["XML", "HTML", "PDF", "ZIP", "JSON", "EMPTY", "UNKNOWN"];
5
5
  declare const CONTENT_TYPES: readonly ["application/xml", "text/xml", "application/octet-stream", "text/html", "application/pdf", "application/zip", "application/json", "text/plain"];
6
6
  export interface SiiDiagnostics {
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SiiError = void 0;
4
4
  exports.sanitizeSiiDiagnostics = sanitizeSiiDiagnostics;
5
- const STAGES = ['AUTHENTICATION', 'SESSION_CHECK', 'COMPANY_AUTHORIZATION', 'RCV_INITIALIZATION', 'RCV_SUMMARY', 'RCV_DETAIL', 'XML_COMPANY_SELECTION', 'XML_DOWNLOAD', 'XML_PARSE', 'LOGOUT', 'DOCUMENT_PREPARATION', 'DOCUMENT_REVIEW', 'DOCUMENT_SIGNING', 'DOCUMENT_SEND', 'DOCUMENT_RECOVERY'];
6
- const ENDPOINTS = ['CAutInicio.cgi', 'aaSessionService/load', 'getDcvEmpresasAutorizadas', 'getDatosInicio', 'getResumen', 'getDetalleCompra', 'getDetalleVenta', 'mipeSelEmpresa.cgi', 'mipeLaunchPage.cgi', 'mipeDownLoad.cgi', 'autTermino.cgi', 'mipeGenFacEx.cgi', 'mipeDisplayPreView.cgi', 'mipeGenXMLFirma.cgi', 'getCertDigital.cgi', 'postFirmaDigital.cgi', 'mipeSendXML.cgi', 'mipeAdminDocsEmi.cgi', 'mipeGesDocEmi.cgi', 'mipeDisplayPDF.cgi'];
7
- const REASONS = ['DOCUMENT_LIMIT_EXCEEDED', 'DOCUMENT_NOT_FOUND', 'EMPTY_RESPONSE', 'HTML_RESPONSE', 'PROVIDER_ERROR_PAGE', 'UNEXPECTED_PDF', 'UNEXPECTED_ARCHIVE', 'UNEXPECTED_FORMAT', 'INVALID_XML', 'XML_IDENTITY_MISMATCH', 'RESPONSE_TOO_LARGE', 'HTTP_ERROR', 'TIMEOUT', 'TRANSPORT_ERROR', 'RETRY_LATER', 'CAPTCHA_REQUIRED', 'SESSION_REQUIRED', 'LOGIN_NOT_CONFIRMED', 'PERSONAL_SESSION_REQUIRED', 'SESSION_IDENTITY_MISMATCH', 'COMPANY_NOT_AUTHORIZED', 'COMPANY_SELECTION_REQUIRED', 'PROVIDER_REJECTED', 'INVALID_RESPONSE', 'DOCUMENT_CONTENT_MISMATCH', 'CERTIFICATE_UNAVAILABLE', 'CERTIFICATE_PASSWORD_INVALID', 'CERTIFICATE_EXPIRED', 'CERTIFICATE_REVOKED', 'SIGNATURE_INVALID', 'ISSUANCE_OUTCOME_UNKNOWN'];
5
+ const STAGES = ['AUTHENTICATION', 'SESSION_CHECK', 'COMPANY_AUTHORIZATION', 'RCV_INITIALIZATION', 'RCV_SUMMARY', 'RCV_DETAIL', 'XML_COMPANY_SELECTION', 'XML_DOWNLOAD', 'XML_PARSE', 'LOGOUT', 'DOCUMENT_PREPARATION', 'DOCUMENT_REVIEW', 'DOCUMENT_SIGNING', 'DOCUMENT_SEND', 'DOCUMENT_RECOVERY', 'PDF_HISTORY', 'PDF_DOWNLOAD', 'DOCUMENT_STATUS', 'RECIPIENT_EVENTS', 'COMPANY_LOOKUP'];
6
+ const ENDPOINTS = ['CAutInicio.cgi', 'aaSessionService/load', 'getDcvEmpresasAutorizadas', 'getDatosInicio', 'getResumen', 'getDetalleCompra', 'getDetalleVenta', 'mipeSelEmpresa.cgi', 'mipeLaunchPage.cgi', 'mipeDownLoad.cgi', 'autTermino.cgi', 'mipeGenFacEx.cgi', 'mipeDisplayPreView.cgi', 'mipeGenXMLFirma.cgi', 'getCertDigital.cgi', 'postFirmaDigital.cgi', 'mipeSendXML.cgi', 'mipeAdminDocsEmi.cgi', 'mipeGesDocEmi.cgi', 'mipeDisplayPDF.cgi', 'mipeAdminDocsRcp.cgi', 'mipeShowPdf.cgi', 'DTEauth', 'QEstadoDTE', 'registrorechazodtej6ui', 'validarAccesoReceptor'];
7
+ const REASONS = ['DOCUMENT_LIMIT_EXCEEDED', 'DOCUMENT_NOT_FOUND', 'EMPTY_RESPONSE', 'HTML_RESPONSE', 'PROVIDER_ERROR_PAGE', 'UNEXPECTED_PDF', 'UNEXPECTED_ARCHIVE', 'UNEXPECTED_FORMAT', 'INVALID_XML', 'XML_IDENTITY_MISMATCH', 'RESPONSE_TOO_LARGE', 'HTTP_ERROR', 'TIMEOUT', 'TRANSPORT_ERROR', 'RETRY_LATER', 'CAPTCHA_REQUIRED', 'SESSION_REQUIRED', 'LOGIN_NOT_CONFIRMED', 'PERSONAL_SESSION_REQUIRED', 'SESSION_IDENTITY_MISMATCH', 'COMPANY_NOT_AUTHORIZED', 'COMPANY_SELECTION_REQUIRED', 'PROVIDER_REJECTED', 'INVALID_RESPONSE', 'DOCUMENT_CONTENT_MISMATCH', 'CERTIFICATE_UNAVAILABLE', 'CERTIFICATE_PASSWORD_INVALID', 'CERTIFICATE_EXPIRED', 'CERTIFICATE_REVOKED', 'SIGNATURE_INVALID', 'ISSUANCE_OUTCOME_UNKNOWN', 'INVALID_PDF', 'PDF_IDENTITY_MISMATCH', 'OPERATION_ABORTED', 'DOCUMENT_IDENTITY_MISMATCH', 'DOCUMENT_ACCESS_DENIED', 'COMPANY_IDENTITY_MISMATCH', 'COMPANY_INFO_UNAVAILABLE'];
8
8
  const RESPONSE_TYPES = ['XML', 'HTML', 'PDF', 'ZIP', 'JSON', 'EMPTY', 'UNKNOWN'];
9
9
  const CONTENT_TYPES = ['application/xml', 'text/xml', 'application/octet-stream', 'text/html', 'application/pdf', 'application/zip', 'application/json', 'text/plain'];
10
10
  function member(values, value) {
@@ -33,6 +33,9 @@ const STAGE_LABELS = {
33
33
  RCV_INITIALIZATION: 'inicio del RCV', RCV_SUMMARY: 'resumen del RCV', RCV_DETAIL: 'detalle del RCV',
34
34
  XML_COMPANY_SELECTION: 'selección de empresa en el facturador', XML_DOWNLOAD: 'descarga del XML', XML_PARSE: 'validación del XML', LOGOUT: 'cierre de sesión',
35
35
  DOCUMENT_PREPARATION: 'preparación del documento', DOCUMENT_REVIEW: 'revisión del documento', DOCUMENT_SIGNING: 'firma del documento', DOCUMENT_SEND: 'envío del documento', DOCUMENT_RECOVERY: 'recuperación del documento emitido',
36
+ PDF_HISTORY: 'búsqueda de factura en el historial', PDF_DOWNLOAD: 'descarga del PDF',
37
+ DOCUMENT_STATUS: 'consulta de recepción y contenido del DTE', RECIPIENT_EVENTS: 'consulta de eventos del DTE',
38
+ COMPANY_LOOKUP: 'consulta de datos de empresa por RUT',
36
39
  };
37
40
  const REASON_LABELS = {
38
41
  DOCUMENT_LIMIT_EXCEEDED: 'SII rechazó la consulta porque devuelve demasiados documentos. No confirmó si el XML individual está disponible.',
@@ -45,7 +48,14 @@ const REASON_LABELS = {
45
48
  UNEXPECTED_FORMAT: 'SII devolvió un formato diferente al XML solicitado.',
46
49
  INVALID_XML: 'El XML recibido no contiene un DTE individual válido y no se guardó.',
47
50
  XML_IDENTITY_MISMATCH: 'El XML recibido corresponde a otro documento y no se guardó.',
48
- RESPONSE_TOO_LARGE: 'La respuesta de SII supera el límite permitido de 1 MiB y no se procesó.',
51
+ INVALID_PDF: 'SII no entregó una respuesta PDF válida para esta solicitud.',
52
+ PDF_IDENTITY_MISMATCH: 'El historial no identifica de forma única la factura solicitada. No se descargó el PDF.',
53
+ OPERATION_ABORTED: 'El consumidor canceló la operación.',
54
+ DOCUMENT_IDENTITY_MISMATCH: 'SII devolvió otra identidad documental; no se entregaron sus datos.',
55
+ DOCUMENT_ACCESS_DENIED: 'SII no confirmó el acceso al documento en el rol solicitado.',
56
+ COMPANY_IDENTITY_MISMATCH: 'SII devolvió datos de otro RUT; no se entregaron.',
57
+ COMPANY_INFO_UNAVAILABLE: 'SII no entregó datos utilizables para este RUT. No confirma inexistencia del contribuyente.',
58
+ RESPONSE_TOO_LARGE: 'La respuesta de SII supera el límite permitido para este tipo de respuesta y no se procesó.',
49
59
  HTTP_ERROR: 'SII respondió con un error HTTP.', TIMEOUT: 'SII no respondió dentro del tiempo permitido.',
50
60
  TRANSPORT_ERROR: 'No se pudo completar la comunicación con SII.', RETRY_LATER: 'SII pidió esperar antes de volver a consultar.',
51
61
  CAPTCHA_REQUIRED: 'SII requiere resolver un CAPTCHA en su sitio.', SESSION_REQUIRED: 'SII requiere autenticación interactiva o una sesión válida.',
package/package.json CHANGED
@@ -1,45 +1,45 @@
1
- {
2
- "name": "@devly-cl/sii-client",
3
- "version": "0.5.0",
4
- "description": "Cliente HTTP del SII para acceso personal, RCV, XML y emisión de facturas y notas de crédito, independiente de framework.",
5
- "license": "UNLICENSED",
6
- "type": "commonjs",
7
- "engines": {
8
- "node": ">=22.13.0"
9
- },
10
- "main": "./dist/index.js",
11
- "types": "./dist/index.d.ts",
12
- "exports": {
13
- ".": {
14
- "types": "./dist/index.d.ts",
15
- "require": "./dist/index.js",
16
- "import": "./dist/index.js"
17
- }
18
- },
19
- "files": [
20
- "dist",
21
- "README.md"
22
- ],
23
- "publishConfig": {
24
- "access": "public",
25
- "registry": "https://registry.npmjs.org"
26
- },
27
- "scripts": {
28
- "build": "tsc -p tsconfig.json",
29
- "typecheck": "tsc --noEmit -p tsconfig.json",
30
- "test": "npm run build && node test/check.mjs && node test/invoices.mjs && node test/xml.mjs && node test/logout.mjs && node test/credit-note-xml.mjs && node test/facturador.mjs && node test/invoicing.mjs && node test/issuance.mjs && node test/issuance-edges.mjs && node test/api-naming.mjs",
31
- "check:example": "tsc --strict --noEmit --target ES2022 --module Node16 --moduleResolution Node16 --types node examples/consulta-rcv.ts examples/facturacion.ts",
32
- "check": "npm run typecheck && npm test && npm run check:example",
33
- "test:live": "npm run build && node scripts/live-check.mjs",
34
- "prepack": "npm run check"
35
- },
36
- "dependencies": {
37
- "parse5": "7.3.0",
38
- "saxes": "^6.0.0",
39
- "tough-cookie": "6.0.2"
40
- },
41
- "devDependencies": {
42
- "@types/node": "22.20.2",
43
- "typescript": "5.9.3"
44
- }
45
- }
1
+ {
2
+ "name": "@devly-cl/sii-client",
3
+ "version": "0.7.1",
4
+ "description": "Cliente HTTP del SII para acceso personal, RCV, XML, PDF por streaming y emisión de facturas y notas de crédito, independiente de framework.",
5
+ "license": "UNLICENSED",
6
+ "type": "commonjs",
7
+ "engines": {
8
+ "node": ">=22.13.0"
9
+ },
10
+ "main": "./dist/index.js",
11
+ "types": "./dist/index.d.ts",
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/index.d.ts",
15
+ "require": "./dist/index.js",
16
+ "import": "./dist/index.js"
17
+ }
18
+ },
19
+ "files": [
20
+ "dist",
21
+ "README.md"
22
+ ],
23
+ "publishConfig": {
24
+ "access": "public",
25
+ "registry": "https://registry.npmjs.org"
26
+ },
27
+ "scripts": {
28
+ "build": "tsc -p tsconfig.json",
29
+ "typecheck": "tsc --noEmit -p tsconfig.json",
30
+ "test": "npm run build && node test/check.mjs && node test/invoices.mjs && node test/rcv-documents.mjs && node test/xml.mjs && node test/logout.mjs && node test/credit-note-xml.mjs && node test/facturador.mjs && node test/invoicing.mjs && node test/invoice-optionals.mjs && node test/invoice-optionals-http.mjs && node test/issuance.mjs && node test/issuance-edges.mjs && node test/api-naming.mjs && node test/company-selection.mjs && node test/company-info.mjs && node test/transport-lifecycle.mjs && node test/application.mjs && node test/architecture.mjs && node test/pdf.mjs && node test/pdf-http.mjs && node test/document-status.mjs",
31
+ "check:example": "tsc --strict --noEmit --target ES2022 --module Node16 --moduleResolution Node16 --types node examples/consulta-rcv.ts examples/facturacion.ts examples/factura-opcionales.ts examples/consulta-pdf.ts examples/consulta-estado-documento.ts examples/consulta-empresa.ts",
32
+ "check": "npm run typecheck && npm test && npm run check:example",
33
+ "test:live": "npm run build && node scripts/live-check.mjs",
34
+ "prepack": "npm run check"
35
+ },
36
+ "dependencies": {
37
+ "parse5": "7.3.0",
38
+ "saxes": "^6.0.0",
39
+ "tough-cookie": "6.0.2"
40
+ },
41
+ "devDependencies": {
42
+ "@types/node": "22.20.2",
43
+ "typescript": "5.9.3"
44
+ }
45
+ }