factuplan 0.2.1 → 0.2.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.
package/README.md CHANGED
@@ -129,6 +129,29 @@ const { url } = await factuplan.invoices.downloadXml('invoice-id');
129
129
  const { url } = await factuplan.invoices.downloadPdf('invoice-id');
130
130
  ```
131
131
 
132
+ ### Firmar y autorizar XML (Modo B)
133
+
134
+ Si ya tienes tu XML generado (sin firmar), puedes enviarlo para que Factuplan lo firme con tu certificado y lo autorice ante el SRI:
135
+
136
+ ```typescript
137
+ import { readFileSync } from 'fs';
138
+
139
+ // Leer XML sin firmar
140
+ const xml = readFileSync('./factura.xml', 'utf-8');
141
+
142
+ // Firmar y autorizar
143
+ const result = await factuplan.invoices.signAndAuthorize({ xml });
144
+
145
+ console.log(result.accessKey); // Clave de acceso SRI
146
+ console.log(result.status); // Estado del comprobante
147
+
148
+ // Consultar estado de autorizacion
149
+ const status = await factuplan.invoices.getStatus(result.id);
150
+
151
+ // Descargar XML autorizado
152
+ const { url } = await factuplan.invoices.downloadXml(result.id);
153
+ ```
154
+
132
155
  ### Uso y certificado
133
156
 
134
157
  ```typescript
package/dist/index.d.mts CHANGED
@@ -133,6 +133,15 @@ interface DownloadUrlResponse {
133
133
  url: string;
134
134
  s3Key?: string;
135
135
  }
136
+ interface SignAndAuthorizeInput {
137
+ /** Unsigned XML string */
138
+ xml: string;
139
+ }
140
+ interface SignAndAuthorizeResponse {
141
+ id: string;
142
+ accessKey: string;
143
+ status: string;
144
+ }
136
145
  interface UsageResponse {
137
146
  apiKeyId: string;
138
147
  month: string;
@@ -172,6 +181,7 @@ declare class InvoicesResource {
172
181
  private request;
173
182
  constructor(request: Requester$1);
174
183
  create(input: CreateInvoiceInput): Promise<Invoice>;
184
+ signAndAuthorize(input: SignAndAuthorizeInput): Promise<SignAndAuthorizeResponse>;
175
185
  get(id: string): Promise<Record<string, unknown>>;
176
186
  getStatus(id: string): Promise<InvoiceStatus>;
177
187
  downloadXml(id: string): Promise<DownloadUrlResponse>;
@@ -215,4 +225,4 @@ declare class RateLimitError extends FactuplanError {
215
225
  constructor(message?: string);
216
226
  }
217
227
 
218
- export { AuthenticationError, type CertificateStatus, type CreateCustomerInput, type CreateInvoiceInput, type CreateProductInput, type Customer, type CustomerListParams, type DownloadUrlResponse, Factuplan, FactuplanError, type FactuplanOptions, type Invoice, type InvoiceCustomer, type InvoiceItem, type InvoiceStatus, type PaginatedResponse, type Product, type ProductListParams, RateLimitError, type UpdateCustomerInput, type UpdateProductInput, type UsageResponse };
228
+ export { AuthenticationError, type CertificateStatus, type CreateCustomerInput, type CreateInvoiceInput, type CreateProductInput, type Customer, type CustomerListParams, type DownloadUrlResponse, Factuplan, FactuplanError, type FactuplanOptions, type Invoice, type InvoiceCustomer, type InvoiceItem, type InvoiceStatus, type PaginatedResponse, type Product, type ProductListParams, RateLimitError, type SignAndAuthorizeInput, type SignAndAuthorizeResponse, type UpdateCustomerInput, type UpdateProductInput, type UsageResponse };
package/dist/index.d.ts CHANGED
@@ -133,6 +133,15 @@ interface DownloadUrlResponse {
133
133
  url: string;
134
134
  s3Key?: string;
135
135
  }
136
+ interface SignAndAuthorizeInput {
137
+ /** Unsigned XML string */
138
+ xml: string;
139
+ }
140
+ interface SignAndAuthorizeResponse {
141
+ id: string;
142
+ accessKey: string;
143
+ status: string;
144
+ }
136
145
  interface UsageResponse {
137
146
  apiKeyId: string;
138
147
  month: string;
@@ -172,6 +181,7 @@ declare class InvoicesResource {
172
181
  private request;
173
182
  constructor(request: Requester$1);
174
183
  create(input: CreateInvoiceInput): Promise<Invoice>;
184
+ signAndAuthorize(input: SignAndAuthorizeInput): Promise<SignAndAuthorizeResponse>;
175
185
  get(id: string): Promise<Record<string, unknown>>;
176
186
  getStatus(id: string): Promise<InvoiceStatus>;
177
187
  downloadXml(id: string): Promise<DownloadUrlResponse>;
@@ -215,4 +225,4 @@ declare class RateLimitError extends FactuplanError {
215
225
  constructor(message?: string);
216
226
  }
217
227
 
218
- export { AuthenticationError, type CertificateStatus, type CreateCustomerInput, type CreateInvoiceInput, type CreateProductInput, type Customer, type CustomerListParams, type DownloadUrlResponse, Factuplan, FactuplanError, type FactuplanOptions, type Invoice, type InvoiceCustomer, type InvoiceItem, type InvoiceStatus, type PaginatedResponse, type Product, type ProductListParams, RateLimitError, type UpdateCustomerInput, type UpdateProductInput, type UsageResponse };
228
+ export { AuthenticationError, type CertificateStatus, type CreateCustomerInput, type CreateInvoiceInput, type CreateProductInput, type Customer, type CustomerListParams, type DownloadUrlResponse, Factuplan, FactuplanError, type FactuplanOptions, type Invoice, type InvoiceCustomer, type InvoiceItem, type InvoiceStatus, type PaginatedResponse, type Product, type ProductListParams, RateLimitError, type SignAndAuthorizeInput, type SignAndAuthorizeResponse, type UpdateCustomerInput, type UpdateProductInput, type UsageResponse };
package/dist/index.js CHANGED
@@ -80,6 +80,9 @@ var InvoicesResource = class {
80
80
  async create(input) {
81
81
  return this.request("POST", "/developer/invoices", input);
82
82
  }
83
+ async signAndAuthorize(input) {
84
+ return this.request("POST", "/developer/sign-and-authorize", input);
85
+ }
83
86
  async get(id) {
84
87
  return this.request("GET", `/developer/receipts/${id}`);
85
88
  }
package/dist/index.mjs CHANGED
@@ -51,6 +51,9 @@ var InvoicesResource = class {
51
51
  async create(input) {
52
52
  return this.request("POST", "/developer/invoices", input);
53
53
  }
54
+ async signAndAuthorize(input) {
55
+ return this.request("POST", "/developer/sign-and-authorize", input);
56
+ }
54
57
  async get(id) {
55
58
  return this.request("GET", `/developer/receipts/${id}`);
56
59
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "factuplan",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Official Factuplan SDK for JavaScript & TypeScript — Create electronic invoices for Ecuador (SRI)",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",