nfets 0.0.45 → 0.0.46

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.
@@ -1,4 +1,4 @@
1
- import { h as StateCode, j as EnvironmentCode, D as DecimalValue, i as StateAcronym, l as Signature, f as StateCodes, p as TransmitterOptions, q as Transmitter, m as Client, G as RequestConfig, O as SignedEntity, Y as Either, x as NFeTsError, a as ReadCertificateResponse, R as ReadCertificateRequest, J as HttpClient, w as XmlToolkit, y as CacheAdapter, z as CertificateRepository, L as RemoteTransmissionRepository, U as EntitySigner, V as XmlSigner, Z as Left, _ as Right, N as Namespaced } from '../xml-signer-BmpwXTKY.cjs';
1
+ import { h as StateCode, j as EnvironmentCode, D as DecimalValue, i as StateAcronym, l as Signature, f as StateCodes, p as TransmitterOptions, q as Transmitter, m as Client, G as RequestConfig, O as SignedEntity, Z as Either, x as NFeTsError, a as ReadCertificateResponse, Q as SignerRepository, d as SignatureAlgorithm, _ as Left, $ as Right, R as ReadCertificateRequest, J as HttpClient, w as XmlToolkit, y as CacheAdapter, z as CertificateRepository, L as RemoteTransmissionRepository, V as EntitySigner, W as XmlSigner, N as Namespaced } from '../xml-signer-Cu3OlWV1.cjs';
2
2
  import 'node:crypto';
3
3
 
4
4
  type DeepPartial<T> = {
@@ -1623,12 +1623,17 @@ declare class NFe implements NFe$1 {
1623
1623
  Signature?: Signature;
1624
1624
  }
1625
1625
 
1626
+ declare class CryptoSignerRepository implements SignerRepository {
1627
+ sign(content: string, cert: ReadCertificateResponse, algorithm: SignatureAlgorithm): Promise<Left<NFeTsError> | Right<string>>;
1628
+ }
1629
+
1626
1630
  declare abstract class Pipeline {
1627
1631
  protected readonly certificate?: ReadCertificateRequest | undefined;
1628
1632
  protected readonly xmlns = "http://www.portalfiscal.inf.br/nfe";
1629
1633
  protected readonly http: HttpClient;
1630
1634
  protected readonly toolkit: XmlToolkit;
1631
1635
  protected readonly caching: CacheAdapter;
1636
+ protected readonly signerRepository: CryptoSignerRepository;
1632
1637
  protected readonly certificates: CertificateRepository;
1633
1638
  protected readonly soap: RemoteTransmissionRepository<NfeRemoteClient>;
1634
1639
  protected readonly signer: EntitySigner;
@@ -1,4 +1,4 @@
1
- import { h as StateCode, j as EnvironmentCode, D as DecimalValue, i as StateAcronym, l as Signature, f as StateCodes, p as TransmitterOptions, q as Transmitter, m as Client, G as RequestConfig, O as SignedEntity, Y as Either, x as NFeTsError, a as ReadCertificateResponse, R as ReadCertificateRequest, J as HttpClient, w as XmlToolkit, y as CacheAdapter, z as CertificateRepository, L as RemoteTransmissionRepository, U as EntitySigner, V as XmlSigner, Z as Left, _ as Right, N as Namespaced } from '../xml-signer-BmpwXTKY.js';
1
+ import { h as StateCode, j as EnvironmentCode, D as DecimalValue, i as StateAcronym, l as Signature, f as StateCodes, p as TransmitterOptions, q as Transmitter, m as Client, G as RequestConfig, O as SignedEntity, Z as Either, x as NFeTsError, a as ReadCertificateResponse, Q as SignerRepository, d as SignatureAlgorithm, _ as Left, $ as Right, R as ReadCertificateRequest, J as HttpClient, w as XmlToolkit, y as CacheAdapter, z as CertificateRepository, L as RemoteTransmissionRepository, V as EntitySigner, W as XmlSigner, N as Namespaced } from '../xml-signer-Cu3OlWV1.js';
2
2
  import 'node:crypto';
3
3
 
4
4
  type DeepPartial<T> = {
@@ -1623,12 +1623,17 @@ declare class NFe implements NFe$1 {
1623
1623
  Signature?: Signature;
1624
1624
  }
1625
1625
 
1626
+ declare class CryptoSignerRepository implements SignerRepository {
1627
+ sign(content: string, cert: ReadCertificateResponse, algorithm: SignatureAlgorithm): Promise<Left<NFeTsError> | Right<string>>;
1628
+ }
1629
+
1626
1630
  declare abstract class Pipeline {
1627
1631
  protected readonly certificate?: ReadCertificateRequest | undefined;
1628
1632
  protected readonly xmlns = "http://www.portalfiscal.inf.br/nfe";
1629
1633
  protected readonly http: HttpClient;
1630
1634
  protected readonly toolkit: XmlToolkit;
1631
1635
  protected readonly caching: CacheAdapter;
1636
+ protected readonly signerRepository: CryptoSignerRepository;
1632
1637
  protected readonly certificates: CertificateRepository;
1633
1638
  protected readonly soap: RemoteTransmissionRepository<NfeRemoteClient>;
1634
1639
  protected readonly signer: EntitySigner;
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w}from"../chunk-ZRYCG7PM.mjs";import"../chunk-XGHTJXFZ.mjs";import"../chunk-W6MRGYXP.mjs";export{d as AccessKeyBuilder,e as DefaultDetBuilderAggregator,f as DefaultTotalBuilderAggregator,u as NFCeDto,q as NFeDto,k as NfceAuthorizerPipeline,m as NfceConsultStatusPipeline,j as NfceQrcode,i as NfceRemoteTransmitter,v as NfceXmlBuilder,w as NfceXmlBuilderPipeline,n as NfeAuthorizationResponsePipeline,h as NfeAuthorizerPipeline,l as NfeConsultStatusPipeline,r as NfeDetXmlBuilder,o as NfeNfceCancelPipeline,p as NfeNfceVoidRangePipeline,g as NfeRemoteTransmitter,s as NfeXmlBuilder,t as NfeXmlBuilderPipeline,a as TpEmis,b as TpEvent,c as schemas};
2
+ import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w}from"../chunk-LP4JOWRA.mjs";import"../chunk-EG7US67K.mjs";import"../chunk-W6MRGYXP.mjs";export{d as AccessKeyBuilder,e as DefaultDetBuilderAggregator,f as DefaultTotalBuilderAggregator,u as NFCeDto,q as NFeDto,k as NfceAuthorizerPipeline,m as NfceConsultStatusPipeline,j as NfceQrcode,i as NfceRemoteTransmitter,v as NfceXmlBuilder,w as NfceXmlBuilderPipeline,n as NfeAuthorizationResponsePipeline,h as NfeAuthorizerPipeline,l as NfeConsultStatusPipeline,r as NfeDetXmlBuilder,o as NfeNfceCancelPipeline,p as NfeNfceVoidRangePipeline,g as NfeRemoteTransmitter,s as NfeXmlBuilder,t as NfeXmlBuilderPipeline,a as TpEmis,b as TpEvent,c as schemas};
@@ -67,7 +67,7 @@ interface ReadCertificateResponse {
67
67
  password: string;
68
68
  ca: X509Certificate[];
69
69
  certificate: X509Certificate;
70
- privateKey: KeyObject;
70
+ privateKey?: KeyObject;
71
71
  }
72
72
  interface CertificateInfo {
73
73
  CNPJ?: string;
@@ -313,7 +313,7 @@ interface CacheAdapter {
313
313
 
314
314
  interface CertificateRepository {
315
315
  read(request: ReadCertificateRequest): Promise<Either<NFeTsError, ReadCertificateResponse>>;
316
- sign(content: string, privateKey: KeyObject, algorithm: SignatureAlgorithm): Promise<Either<NFeTsError, string>>;
316
+ sign(content: string, cert: ReadCertificateResponse, algorithm: SignatureAlgorithm): Promise<Either<NFeTsError, string>>;
317
317
  getStringCertificate(certificate: X509Certificate): string;
318
318
  getStringPrivateKey(privateKey: KeyObject): string;
319
319
  getCertificateInfo(certificate: X509Certificate): CertificateInfo;
@@ -331,6 +331,9 @@ interface SignerOptions<T = string> {
331
331
  type SignedEntity<T extends object> = T & {
332
332
  Signature: Signature;
333
333
  };
334
+ interface SignerRepository {
335
+ sign(content: string, cert: ReadCertificateResponse, algorithm: SignatureAlgorithm): Promise<Either<NFeTsError, string>>;
336
+ }
334
337
 
335
338
  declare abstract class Signer {
336
339
  protected readonly toolkit: XmlToolkit;
@@ -385,7 +388,7 @@ declare abstract class Signer {
385
388
  };
386
389
  };
387
390
  private digest;
388
- protected signOrLeft(signedInfo: SignedInfo, privateKey: KeyObject): Promise<Either<NFeTsError, string>>;
391
+ protected signOrLeft(signedInfo: SignedInfo, cert: ReadCertificateResponse): Promise<Either<NFeTsError, string>>;
389
392
  private get transforms();
390
393
  private get digestAlgorithm();
391
394
  private get signatureMethod();
@@ -400,4 +403,4 @@ declare class XmlSigner extends Signer {
400
403
  sign(xml: string, options: SignerOptions, cert: ReadCertificateResponse): Promise<Left<NFeTsError> | Right<string>>;
401
404
  }
402
405
 
403
- export { type HttpClientHeaders as A, type BuilderOptions as B, type CertificateInfo as C, type DecimalValue as D, Environment as E, type ResponseType as F, type RequestConfig as G, type HeaderValue as H, type HttpResponse as I, type HttpClient as J, type KnownKeys as K, type RemoteTransmissionRepository as L, type SignerOptions as M, type Namespaced as N, type SignedEntity as O, type ParserOptions as P, Signer as Q, type ReadCertificateRequest as R, SignatureNamespace as S, type Transforms as T, EntitySigner as U, XmlSigner as V, type Decimal as W, type XmlDeclarationAttributes as X, type Either as Y, Left as Z, Right as _, type ReadCertificateResponse as a, CanonicalizationMethod$1 as b, SignatureMethod$1 as c, SignatureAlgorithm as d, DigestAlgorithm as e, StateCodes as f, StateAcronyms as g, type StateCode as h, type StateAcronym as i, type EnvironmentCode as j, type SignedInfo as k, type Signature as l, type Client as m, type SendTransmissionPayload as n, type ExtractReturnType as o, type TransmitterOptions as p, type Transmitter as q, defaultCanonicalizeOptions as r, type CanonicalizeOptions as s, defaultBuilderOptions as t, type RenderOptions as u, defaultParserOptions as v, type XmlToolkit as w, NFeTsError as x, type CacheAdapter as y, type CertificateRepository as z };
406
+ export { Right as $, type HttpClientHeaders as A, type BuilderOptions as B, type CertificateInfo as C, type DecimalValue as D, Environment as E, type ResponseType as F, type RequestConfig as G, type HeaderValue as H, type HttpResponse as I, type HttpClient as J, type KnownKeys as K, type RemoteTransmissionRepository as L, type SignerOptions as M, type Namespaced as N, type SignedEntity as O, type ParserOptions as P, type SignerRepository as Q, type ReadCertificateRequest as R, SignatureNamespace as S, type Transforms as T, Signer as U, EntitySigner as V, XmlSigner as W, type XmlDeclarationAttributes as X, type Decimal as Y, type Either as Z, Left as _, type ReadCertificateResponse as a, CanonicalizationMethod$1 as b, SignatureMethod$1 as c, SignatureAlgorithm as d, DigestAlgorithm as e, StateCodes as f, StateAcronyms as g, type StateCode as h, type StateAcronym as i, type EnvironmentCode as j, type SignedInfo as k, type Signature as l, type Client as m, type SendTransmissionPayload as n, type ExtractReturnType as o, type TransmitterOptions as p, type Transmitter as q, defaultCanonicalizeOptions as r, type CanonicalizeOptions as s, defaultBuilderOptions as t, type RenderOptions as u, defaultParserOptions as v, type XmlToolkit as w, NFeTsError as x, type CacheAdapter as y, type CertificateRepository as z };
@@ -67,7 +67,7 @@ interface ReadCertificateResponse {
67
67
  password: string;
68
68
  ca: X509Certificate[];
69
69
  certificate: X509Certificate;
70
- privateKey: KeyObject;
70
+ privateKey?: KeyObject;
71
71
  }
72
72
  interface CertificateInfo {
73
73
  CNPJ?: string;
@@ -313,7 +313,7 @@ interface CacheAdapter {
313
313
 
314
314
  interface CertificateRepository {
315
315
  read(request: ReadCertificateRequest): Promise<Either<NFeTsError, ReadCertificateResponse>>;
316
- sign(content: string, privateKey: KeyObject, algorithm: SignatureAlgorithm): Promise<Either<NFeTsError, string>>;
316
+ sign(content: string, cert: ReadCertificateResponse, algorithm: SignatureAlgorithm): Promise<Either<NFeTsError, string>>;
317
317
  getStringCertificate(certificate: X509Certificate): string;
318
318
  getStringPrivateKey(privateKey: KeyObject): string;
319
319
  getCertificateInfo(certificate: X509Certificate): CertificateInfo;
@@ -331,6 +331,9 @@ interface SignerOptions<T = string> {
331
331
  type SignedEntity<T extends object> = T & {
332
332
  Signature: Signature;
333
333
  };
334
+ interface SignerRepository {
335
+ sign(content: string, cert: ReadCertificateResponse, algorithm: SignatureAlgorithm): Promise<Either<NFeTsError, string>>;
336
+ }
334
337
 
335
338
  declare abstract class Signer {
336
339
  protected readonly toolkit: XmlToolkit;
@@ -385,7 +388,7 @@ declare abstract class Signer {
385
388
  };
386
389
  };
387
390
  private digest;
388
- protected signOrLeft(signedInfo: SignedInfo, privateKey: KeyObject): Promise<Either<NFeTsError, string>>;
391
+ protected signOrLeft(signedInfo: SignedInfo, cert: ReadCertificateResponse): Promise<Either<NFeTsError, string>>;
389
392
  private get transforms();
390
393
  private get digestAlgorithm();
391
394
  private get signatureMethod();
@@ -400,4 +403,4 @@ declare class XmlSigner extends Signer {
400
403
  sign(xml: string, options: SignerOptions, cert: ReadCertificateResponse): Promise<Left<NFeTsError> | Right<string>>;
401
404
  }
402
405
 
403
- export { type HttpClientHeaders as A, type BuilderOptions as B, type CertificateInfo as C, type DecimalValue as D, Environment as E, type ResponseType as F, type RequestConfig as G, type HeaderValue as H, type HttpResponse as I, type HttpClient as J, type KnownKeys as K, type RemoteTransmissionRepository as L, type SignerOptions as M, type Namespaced as N, type SignedEntity as O, type ParserOptions as P, Signer as Q, type ReadCertificateRequest as R, SignatureNamespace as S, type Transforms as T, EntitySigner as U, XmlSigner as V, type Decimal as W, type XmlDeclarationAttributes as X, type Either as Y, Left as Z, Right as _, type ReadCertificateResponse as a, CanonicalizationMethod$1 as b, SignatureMethod$1 as c, SignatureAlgorithm as d, DigestAlgorithm as e, StateCodes as f, StateAcronyms as g, type StateCode as h, type StateAcronym as i, type EnvironmentCode as j, type SignedInfo as k, type Signature as l, type Client as m, type SendTransmissionPayload as n, type ExtractReturnType as o, type TransmitterOptions as p, type Transmitter as q, defaultCanonicalizeOptions as r, type CanonicalizeOptions as s, defaultBuilderOptions as t, type RenderOptions as u, defaultParserOptions as v, type XmlToolkit as w, NFeTsError as x, type CacheAdapter as y, type CertificateRepository as z };
406
+ export { Right as $, type HttpClientHeaders as A, type BuilderOptions as B, type CertificateInfo as C, type DecimalValue as D, Environment as E, type ResponseType as F, type RequestConfig as G, type HeaderValue as H, type HttpResponse as I, type HttpClient as J, type KnownKeys as K, type RemoteTransmissionRepository as L, type SignerOptions as M, type Namespaced as N, type SignedEntity as O, type ParserOptions as P, type SignerRepository as Q, type ReadCertificateRequest as R, SignatureNamespace as S, type Transforms as T, Signer as U, EntitySigner as V, XmlSigner as W, type XmlDeclarationAttributes as X, type Decimal as Y, type Either as Z, Left as _, type ReadCertificateResponse as a, CanonicalizationMethod$1 as b, SignatureMethod$1 as c, SignatureAlgorithm as d, DigestAlgorithm as e, StateCodes as f, StateAcronyms as g, type StateCode as h, type StateAcronym as i, type EnvironmentCode as j, type SignedInfo as k, type Signature as l, type Client as m, type SendTransmissionPayload as n, type ExtractReturnType as o, type TransmitterOptions as p, type Transmitter as q, defaultCanonicalizeOptions as r, type CanonicalizeOptions as s, defaultBuilderOptions as t, type RenderOptions as u, defaultParserOptions as v, type XmlToolkit as w, NFeTsError as x, type CacheAdapter as y, type CertificateRepository as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nfets",
3
- "version": "0.0.45",
3
+ "version": "0.0.46",
4
4
  "description": "typescript libraries for Brazilian's SEFAZ standards",
5
5
  "type": "module",
6
6
  "main": "./dist/index.mjs",
@@ -68,6 +68,7 @@
68
68
  "@types/pdfkit": "^0.17.3",
69
69
  "@typescript-eslint/parser": "^8.21.0",
70
70
  "axios": "^1.7.9",
71
+ "cross-env": "^10.1.0",
71
72
  "eslint": "^9.19.0",
72
73
  "eslint-plugin-prettier": "^5.2.3",
73
74
  "fs-extra": "^11.3.0",