nfets 0.0.2 → 0.0.10
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/LICENSE +21 -0
- package/build/Release/xml_validator.node +0 -0
- package/dist/chunk-Z2TLKKAE.mjs +2 -0
- package/dist/index.cjs +261 -0
- package/dist/index.d.cts +681 -0
- package/dist/index.d.ts +681 -0
- package/dist/index.mjs +259 -0
- package/dist/src-QBEIGHGM.mjs +8 -0
- package/package.json +61 -18
- package/README.md +0 -0
- package/dist/core/src/index.js +0 -28
- package/dist/nfe/src/index.js +0 -9
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,681 @@
|
|
|
1
|
+
import { KeyObject, X509Certificate } from 'node:crypto';
|
|
2
|
+
import * as _nfets_core_shared_either from '@nfets/core/shared/either';
|
|
3
|
+
import { Either as Either$1 } from '@nfets/core/shared/either';
|
|
4
|
+
import { NFeTsError as NFeTsError$1 } from '@nfets/core/domain/errors/nfets-error';
|
|
5
|
+
import { ReadCertificateResponse as ReadCertificateResponse$1 } from '@nfets/core/domain/entities/certificate/certificate';
|
|
6
|
+
import { SignatureAlgorithm as SignatureAlgorithm$1 } from '@nfets/core/domain/entities/signer/algo';
|
|
7
|
+
import * as _nfets_core_domain from '@nfets/core/domain';
|
|
8
|
+
import { SignerOptions as SignerOptions$1, SignedEntity as SignedEntity$1, StrategyPattern as StrategyPattern$1, XmlToolkit as XmlToolkit$1, NFeTsError as NFeTsError$2 } from '@nfets/core/domain';
|
|
9
|
+
import { ValidationError as ValidationError$1, ValidationOptions } from 'class-validator';
|
|
10
|
+
import { Decimal as Decimal$1 } from 'decimal.js';
|
|
11
|
+
import { Decimal as Decimal$2, DecimalValue as DecimalValue$1 } from '@nfets/core/domain/entities/calculator/decimal';
|
|
12
|
+
import { CacheAdapter as CacheAdapter$1 } from '@nfets/core/domain/repositories/cache-adapter';
|
|
13
|
+
import { CertificateRepository as CertificateRepository$1 } from '@nfets/core/domain/repositories/certificate-repository';
|
|
14
|
+
import { HttpClient as HttpClient$1 } from '@nfets/core/domain/repositories/http-client';
|
|
15
|
+
import { Agent } from 'node:https';
|
|
16
|
+
import { RemoteTransmissionRepository as RemoteTransmissionRepository$1 } from '@nfets/core/domain/repositories/remote-transmission-repository';
|
|
17
|
+
import { Client as Client$1, SendTransmissionPayload as SendTransmissionPayload$1, ExtractReturnType as ExtractReturnType$1 } from '@nfets/core/domain/entities/transmission/payload';
|
|
18
|
+
import * as Xml2js from 'xml2js';
|
|
19
|
+
import * as _nfets_core from '@nfets/core';
|
|
20
|
+
import * as _nfets_nfe_domain_entities_xml_builder_nfe_det_xml_builder from '@nfets/nfe/domain/entities/xml-builder/nfe-det-xml-builder';
|
|
21
|
+
import { ProdBuilder, AssembleDetXmlBuilder } from '@nfets/nfe/domain/entities/xml-builder/nfe-det-xml-builder';
|
|
22
|
+
import { DeepPartial as DeepPartial$1 } from '@nfets/core/shared';
|
|
23
|
+
import { InfNFeAttributes, InfNFe as InfNFe$1 } from '@nfets/nfe/domain/entities/nfe/inf-nfe';
|
|
24
|
+
import { Ide } from '@nfets/nfe/domain/entities/nfe/inf-nfe/ide';
|
|
25
|
+
import { Cobr } from '@nfets/nfe/domain/entities/nfe/inf-nfe/cobr';
|
|
26
|
+
import { Emit } from '@nfets/nfe/domain/entities/nfe/inf-nfe/emit';
|
|
27
|
+
import { Pag } from '@nfets/nfe/domain/entities/nfe/inf-nfe/pag';
|
|
28
|
+
import { Transp } from '@nfets/nfe/domain/entities/nfe/inf-nfe/transp';
|
|
29
|
+
import { Total } from '@nfets/nfe/domain/entities/nfe/inf-nfe/total';
|
|
30
|
+
import { InfIntermed } from '@nfets/nfe/domain/entities/nfe/inf-nfe/infintermed';
|
|
31
|
+
import { Exporta } from '@nfets/nfe/domain/entities/nfe/inf-nfe/exporta';
|
|
32
|
+
import { Compra } from '@nfets/nfe/domain/entities/nfe/inf-nfe/compra';
|
|
33
|
+
import { Cana } from '@nfets/nfe/domain/entities/nfe/inf-nfe/cana';
|
|
34
|
+
import { InfRespTec } from '@nfets/nfe/domain/entities/nfe/inf-nfe/infresptec';
|
|
35
|
+
import { InfSolicNFF } from '@nfets/nfe/domain/entities/nfe/inf-nfe/inf-solic-nff';
|
|
36
|
+
import { InfAdic } from '@nfets/nfe/domain/entities/nfe/inf-nfe/infadic';
|
|
37
|
+
import { Avulsa } from '@nfets/nfe/domain/entities/nfe/inf-nfe/avulsa';
|
|
38
|
+
import { AutXML } from '@nfets/nfe/domain/entities/nfe/inf-nfe/autxml';
|
|
39
|
+
import { Local } from '@nfets/nfe/domain/entities/nfe/inf-nfe/local';
|
|
40
|
+
import { Dest } from '@nfets/nfe/domain/entities/nfe/inf-nfe/dest';
|
|
41
|
+
import { INfeXmlBuilder, InfNFeBuilder, IdeBuilder } from '@nfets/nfe/domain/entities/xml-builder/nfe-xml-builder';
|
|
42
|
+
import { NFe as NFe$1 } from '@nfets/nfe/infrastructure/dto/nfe/nfe';
|
|
43
|
+
import { DetBuilderAggregator } from '@nfets/nfe/application/aggregator/det-builder-aggregator';
|
|
44
|
+
import { TotalBuilderAggregator } from '@nfets/nfe/application/aggregator/total-builder-aggregator';
|
|
45
|
+
import { AccessKey, VerifiedAccessKey } from '@nfets/nfe/domain/entities/acess-keys/access-key';
|
|
46
|
+
import { NFe as NFe$2, NFeAttributes } from '@nfets/nfe/domain/entities/nfe/nfe';
|
|
47
|
+
import { Det } from '@nfets/nfe/domain/entities/nfe/inf-nfe/det';
|
|
48
|
+
import { InfNFeSupl as InfNFeSupl$1 } from '@nfets/nfe/domain/entities/nfe/inf-nfe-supl';
|
|
49
|
+
|
|
50
|
+
declare const SignatureNamespace: "http://www.w3.org/2000/09/xmldsig#";
|
|
51
|
+
declare const CanonicalizationMethod$1: "http://www.w3.org/TR/2001/REC-xml-c14n-20010315";
|
|
52
|
+
declare enum SignatureMethod$1 {
|
|
53
|
+
RSA_SHA1 = "http://www.w3.org/2000/09/xmldsig#rsa-sha1",
|
|
54
|
+
RSA_SHA256 = "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"
|
|
55
|
+
}
|
|
56
|
+
declare enum SignatureAlgorithm {
|
|
57
|
+
SHA1 = "sha1",
|
|
58
|
+
SHA256 = "sha256"
|
|
59
|
+
}
|
|
60
|
+
declare enum DigestAlgorithm {
|
|
61
|
+
SHA1 = "http://www.w3.org/2000/09/xmldsig#sha1",
|
|
62
|
+
SHA256 = "http://www.w3.org/2001/04/xmlenc#sha256"
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
interface SignedInfo {
|
|
66
|
+
CanonicalizationMethod: CanonicalizationMethod;
|
|
67
|
+
SignatureMethod: SignatureMethod;
|
|
68
|
+
Reference: Reference;
|
|
69
|
+
}
|
|
70
|
+
interface CanonicalizationMethod {
|
|
71
|
+
$: {
|
|
72
|
+
Algorithm: 'http://www.w3.org/TR/2001/REC-xml-c14n-20010315';
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
interface SignatureMethod {
|
|
76
|
+
$: {
|
|
77
|
+
Algorithm: `${SignatureMethod$1}`;
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
interface Reference {
|
|
81
|
+
Transforms: Transforms;
|
|
82
|
+
DigestMethod: DigestMethod;
|
|
83
|
+
DigestValue: string;
|
|
84
|
+
$: {
|
|
85
|
+
URI: string;
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
interface Transforms {
|
|
89
|
+
Transform: [
|
|
90
|
+
Transform<'http://www.w3.org/2000/09/xmldsig#enveloped-signature'>,
|
|
91
|
+
Transform<'http://www.w3.org/TR/2001/REC-xml-c14n-20010315'>
|
|
92
|
+
];
|
|
93
|
+
}
|
|
94
|
+
interface Transform<T extends string> {
|
|
95
|
+
$: {
|
|
96
|
+
Algorithm: T;
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
interface DigestMethod {
|
|
100
|
+
$: {
|
|
101
|
+
Algorithm: `${DigestAlgorithm}`;
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
interface KeyInfo {
|
|
105
|
+
X509Data: X509Data;
|
|
106
|
+
}
|
|
107
|
+
interface X509Data {
|
|
108
|
+
X509Certificate: string;
|
|
109
|
+
}
|
|
110
|
+
interface Signature {
|
|
111
|
+
$: {
|
|
112
|
+
xmlns: typeof SignatureNamespace;
|
|
113
|
+
};
|
|
114
|
+
SignedInfo: SignedInfo;
|
|
115
|
+
SignatureValue: string;
|
|
116
|
+
KeyInfo: KeyInfo;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
declare class NFeTsError extends Error {
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
declare const defaultBuilderOptions: BuilderOptions;
|
|
123
|
+
interface XmlDeclarationAttributes {
|
|
124
|
+
version: string;
|
|
125
|
+
encoding?: string | undefined;
|
|
126
|
+
standalone?: boolean | undefined;
|
|
127
|
+
}
|
|
128
|
+
interface RenderOptions {
|
|
129
|
+
pretty?: boolean | undefined;
|
|
130
|
+
indent?: string | undefined;
|
|
131
|
+
newline?: string | undefined;
|
|
132
|
+
}
|
|
133
|
+
interface BuilderOptions {
|
|
134
|
+
attrkey?: string | undefined;
|
|
135
|
+
charkey?: string | undefined;
|
|
136
|
+
rootName?: string | undefined;
|
|
137
|
+
renderOpts?: RenderOptions | undefined;
|
|
138
|
+
xmldec?: XmlDeclarationAttributes | undefined;
|
|
139
|
+
doctype?: 'xml';
|
|
140
|
+
headless?: boolean | undefined;
|
|
141
|
+
allowSurrogateChars?: boolean | undefined;
|
|
142
|
+
cdata?: boolean | undefined;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
declare const defaultParserOptions: ParserOptions;
|
|
146
|
+
interface ParserOptions {
|
|
147
|
+
trim?: boolean;
|
|
148
|
+
normalizeTags?: boolean;
|
|
149
|
+
normalize?: boolean;
|
|
150
|
+
explicitRoot?: boolean;
|
|
151
|
+
xmlns?: boolean;
|
|
152
|
+
explicitArray?: boolean;
|
|
153
|
+
preserveChildrenOrder?: boolean;
|
|
154
|
+
strict?: boolean;
|
|
155
|
+
chunkSize?: number;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
type Either<L, R> = Left<L> | Right<R>;
|
|
159
|
+
declare class Left<L> {
|
|
160
|
+
readonly value: L;
|
|
161
|
+
constructor(value: L);
|
|
162
|
+
isLeft(): this is Left<L>;
|
|
163
|
+
isRight(): this is never;
|
|
164
|
+
}
|
|
165
|
+
declare class Right<R> {
|
|
166
|
+
readonly value: R;
|
|
167
|
+
constructor(value: R);
|
|
168
|
+
isLeft(): this is never;
|
|
169
|
+
isRight(): this is Right<R>;
|
|
170
|
+
}
|
|
171
|
+
declare const left: <L = never>(l: L) => Left<L>;
|
|
172
|
+
declare const right: <R = never>(a?: R) => Right<R>;
|
|
173
|
+
|
|
174
|
+
declare const defaultCanonicalizeOptions: CanonicalizeOptions;
|
|
175
|
+
interface CanonicalizeOptions {
|
|
176
|
+
includeComments: boolean;
|
|
177
|
+
exclusive: boolean;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
interface XmlToolkit {
|
|
181
|
+
parse<T>(xml: string, options?: ParserOptions): Promise<T>;
|
|
182
|
+
build(object: object, options?: BuilderOptions): Promise<string>;
|
|
183
|
+
validate(xml: string, xsdPathReference: string, xsdFilename: string): Promise<Either<NFeTsError, void>>;
|
|
184
|
+
canonicalize(xml: string, options?: CanonicalizeOptions): string;
|
|
185
|
+
digest(xml: string, algorithm: SignatureAlgorithm, options?: CanonicalizeOptions): string;
|
|
186
|
+
getNode(xml: string, tag: string): string | null;
|
|
187
|
+
getAttribute(xml: string, tag: string): string | null;
|
|
188
|
+
appendNode(xml: string, node: string): string;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
interface CertificateRepository {
|
|
192
|
+
read(pfxPathOrBase64: string, password: string): Promise<Either$1<NFeTsError$1, ReadCertificateResponse$1>>;
|
|
193
|
+
sign(content: string, privateKey: KeyObject, algorithm: SignatureAlgorithm$1): Promise<Either$1<NFeTsError$1, string>>;
|
|
194
|
+
getStringPublicKey(certificate: KeyObject): string;
|
|
195
|
+
getStringPrivateKey(privateKey: KeyObject): string;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
declare abstract class Signer {
|
|
199
|
+
protected readonly toolkit: XmlToolkit;
|
|
200
|
+
protected readonly certificateRepository: CertificateRepository;
|
|
201
|
+
protected readonly algorithm: SignatureAlgorithm;
|
|
202
|
+
protected readonly canonical: CanonicalizeOptions;
|
|
203
|
+
constructor(toolkit: XmlToolkit, certificateRepository: CertificateRepository, algorithm?: SignatureAlgorithm, canonical?: CanonicalizeOptions);
|
|
204
|
+
protected assemble(SignedInfo: SignedInfo, SignatureValue: string, certificate: KeyObject): {
|
|
205
|
+
$: {
|
|
206
|
+
xmlns: "http://www.w3.org/2000/09/xmldsig#";
|
|
207
|
+
};
|
|
208
|
+
SignedInfo: SignedInfo;
|
|
209
|
+
SignatureValue: string;
|
|
210
|
+
KeyInfo: {
|
|
211
|
+
X509Data: {
|
|
212
|
+
X509Certificate: string;
|
|
213
|
+
};
|
|
214
|
+
};
|
|
215
|
+
};
|
|
216
|
+
protected signedInfo(node: string, mark: string): {
|
|
217
|
+
CanonicalizationMethod: {
|
|
218
|
+
$: {
|
|
219
|
+
Algorithm: "http://www.w3.org/TR/2001/REC-xml-c14n-20010315";
|
|
220
|
+
};
|
|
221
|
+
};
|
|
222
|
+
SignatureMethod: {
|
|
223
|
+
$: {
|
|
224
|
+
Algorithm: SignatureMethod$1;
|
|
225
|
+
};
|
|
226
|
+
};
|
|
227
|
+
Reference: {
|
|
228
|
+
$: {
|
|
229
|
+
URI: string;
|
|
230
|
+
};
|
|
231
|
+
Transforms: {
|
|
232
|
+
Transform: [{
|
|
233
|
+
$: {
|
|
234
|
+
Algorithm: "http://www.w3.org/2000/09/xmldsig#enveloped-signature";
|
|
235
|
+
};
|
|
236
|
+
}, {
|
|
237
|
+
$: {
|
|
238
|
+
Algorithm: "http://www.w3.org/TR/2001/REC-xml-c14n-20010315";
|
|
239
|
+
};
|
|
240
|
+
}];
|
|
241
|
+
};
|
|
242
|
+
DigestMethod: {
|
|
243
|
+
$: {
|
|
244
|
+
Algorithm: DigestAlgorithm;
|
|
245
|
+
};
|
|
246
|
+
};
|
|
247
|
+
DigestValue: string;
|
|
248
|
+
};
|
|
249
|
+
};
|
|
250
|
+
private digest;
|
|
251
|
+
protected signOrLeft(signedInfo: SignedInfo, privateKey: KeyObject): Promise<Either<NFeTsError, string>>;
|
|
252
|
+
private get transforms();
|
|
253
|
+
private get digestAlgorithm();
|
|
254
|
+
private get signatureMethod();
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
interface ReadCertificateResponse {
|
|
258
|
+
password: string;
|
|
259
|
+
ca: X509Certificate[];
|
|
260
|
+
certificate: X509Certificate;
|
|
261
|
+
privateKey: KeyObject;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
interface Namespaced {
|
|
265
|
+
$: {
|
|
266
|
+
xmlns: string;
|
|
267
|
+
};
|
|
268
|
+
[key: string]: unknown;
|
|
269
|
+
}
|
|
270
|
+
declare class EntitySigner extends Signer {
|
|
271
|
+
sign<T extends Namespaced, K extends keyof T = keyof T>(content: T, options: SignerOptions$1<K>, cert: ReadCertificateResponse): Promise<Either<NFeTsError, SignedEntity$1<T>>>;
|
|
272
|
+
private ns;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
interface SignerOptions<T = string> {
|
|
276
|
+
tag: T;
|
|
277
|
+
mark: string;
|
|
278
|
+
}
|
|
279
|
+
type SignedEntity<T extends object> = T & {
|
|
280
|
+
Signature: Signature;
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
declare class XmlSigner extends Signer {
|
|
284
|
+
sign(xml: string, options: SignerOptions, cert: ReadCertificateResponse): Promise<Left<NFeTsError> | Right<string>>;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
declare const ValidateErrorsMetadata = "__ValidateErrors__";
|
|
288
|
+
declare const mapConstraintsToErrors: (errors: ValidationError$1[], parent?: string) => string[];
|
|
289
|
+
declare const Validates: <T extends object>(klass: new () => T) => (_target: object, property: string | symbol, descriptor: TypedPropertyDescriptor<(payload: T, ...args: object[]) => any>) => void;
|
|
290
|
+
|
|
291
|
+
declare const SkipValidationMetadata = "__SkipValidation__";
|
|
292
|
+
declare const SkipValidation: () => MethodDecorator;
|
|
293
|
+
declare const SkipAllValidations: () => ClassDecorator;
|
|
294
|
+
|
|
295
|
+
declare const IsDecimal: (validationOptions?: ValidationOptions) => PropertyDecorator;
|
|
296
|
+
|
|
297
|
+
interface ChoiceGroup {
|
|
298
|
+
properties: [string, ...string[]];
|
|
299
|
+
required?: boolean;
|
|
300
|
+
}
|
|
301
|
+
interface ChoiceOptions extends ValidationOptions, ChoiceGroup {
|
|
302
|
+
}
|
|
303
|
+
declare const Choice: (options: ChoiceOptions) => ClassDecorator;
|
|
304
|
+
|
|
305
|
+
declare const plainToInstance: <T extends object>(payload: object, klass: new () => T) => T;
|
|
306
|
+
|
|
307
|
+
interface TransformDecimalArgs extends ValidationOptions {
|
|
308
|
+
fixed?: number;
|
|
309
|
+
}
|
|
310
|
+
declare const TransformDecimal: ({ fixed, ...args }?: TransformDecimalArgs) => PropertyDecorator;
|
|
311
|
+
|
|
312
|
+
interface TransformToDateStringArgs extends ValidationOptions {
|
|
313
|
+
format?: string;
|
|
314
|
+
}
|
|
315
|
+
declare const TransformDateString: (args?: TransformToDateStringArgs) => (target: object, propertyKey: string | symbol) => void;
|
|
316
|
+
|
|
317
|
+
interface StateCodeValidatorStrategy extends StrategyPattern$1<string, boolean> {
|
|
318
|
+
execute(stateCode: string): boolean;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
declare class StateCodeAcValidator implements StateCodeValidatorStrategy {
|
|
322
|
+
execute(stateCode: string): boolean;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
declare class StateCodeAlValidator implements StateCodeValidatorStrategy {
|
|
326
|
+
execute(stateCode: string): boolean;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
declare class StateCodeAmValidator implements StateCodeValidatorStrategy {
|
|
330
|
+
execute(stateCode: string): boolean;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
declare class StateCodeApValidator implements StateCodeValidatorStrategy {
|
|
334
|
+
execute(stateCode: string): boolean;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
declare class StateCodeBaValidator implements StateCodeValidatorStrategy {
|
|
338
|
+
execute(stateCode: string): boolean;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
declare class StateCodeCeValidator implements StateCodeValidatorStrategy {
|
|
342
|
+
execute(stateCode: string): boolean;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
declare class StateCodeDfValidator implements StateCodeValidatorStrategy {
|
|
346
|
+
execute(stateCode: string): boolean;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
declare class StateCodeEsValidator implements StateCodeValidatorStrategy {
|
|
350
|
+
execute(stateCode: string): boolean;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
declare class StateCodeGoValidator implements StateCodeValidatorStrategy {
|
|
354
|
+
execute(stateCode: string): boolean;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
declare class StateCodeMaValidator implements StateCodeValidatorStrategy {
|
|
358
|
+
execute(stateCode: string): boolean;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
declare class StateCodeMgValidator implements StateCodeValidatorStrategy {
|
|
362
|
+
execute(stateCode: string): boolean;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
declare class StateCodeMsValidator implements StateCodeValidatorStrategy {
|
|
366
|
+
execute(stateCode: string): boolean;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
declare class StateCodeMtValidator implements StateCodeValidatorStrategy {
|
|
370
|
+
execute(stateCode: string): boolean;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
declare class StateCodePaValidator implements StateCodeValidatorStrategy {
|
|
374
|
+
execute(stateCode: string): boolean;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
declare class StateCodePbValidator implements StateCodeValidatorStrategy {
|
|
378
|
+
execute(stateCode: string): boolean;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
declare class StateCodePeValidator implements StateCodeValidatorStrategy {
|
|
382
|
+
execute(stateCode: string): boolean;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
declare class StateCodePiValidator implements StateCodeValidatorStrategy {
|
|
386
|
+
execute(stateCode: string): boolean;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
declare class StateCodePrValidator implements StateCodeValidatorStrategy {
|
|
390
|
+
execute(stateCode: string): boolean;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
declare class StateCodeRjValidator implements StateCodeValidatorStrategy {
|
|
394
|
+
execute(stateCode: string): boolean;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
declare class StateCodeRnValidator implements StateCodeValidatorStrategy {
|
|
398
|
+
execute(stateCode: string): boolean;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
declare class StateCodeRoValidator implements StateCodeValidatorStrategy {
|
|
402
|
+
execute(stateCode: string): boolean;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
declare class StateCodeRrValidator implements StateCodeValidatorStrategy {
|
|
406
|
+
execute(stateCode: string): boolean;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
declare class StateCodeRsValidator implements StateCodeValidatorStrategy {
|
|
410
|
+
execute(stateCode: string): boolean;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
declare class StateCodeScValidator implements StateCodeValidatorStrategy {
|
|
414
|
+
execute(stateCode: string): boolean;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
declare class StateCodeSeValidator implements StateCodeValidatorStrategy {
|
|
418
|
+
execute(stateCode: string): boolean;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
declare class StateCodeSpValidator implements StateCodeValidatorStrategy {
|
|
422
|
+
execute(stateCode: string): boolean;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
declare class StateCodeToValidator implements StateCodeValidatorStrategy {
|
|
426
|
+
execute(stateCode: string): boolean;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
type DecimalValue = string | number | bigint;
|
|
430
|
+
|
|
431
|
+
declare const UF: {
|
|
432
|
+
readonly AC: "12";
|
|
433
|
+
readonly AL: "27";
|
|
434
|
+
readonly AM: "13";
|
|
435
|
+
readonly AP: "16";
|
|
436
|
+
readonly BA: "29";
|
|
437
|
+
readonly CE: "23";
|
|
438
|
+
readonly DF: "53";
|
|
439
|
+
readonly ES: "32";
|
|
440
|
+
readonly GO: "52";
|
|
441
|
+
readonly MA: "21";
|
|
442
|
+
readonly MG: "31";
|
|
443
|
+
readonly MS: "50";
|
|
444
|
+
readonly MT: "51";
|
|
445
|
+
readonly PA: "15";
|
|
446
|
+
readonly PB: "25";
|
|
447
|
+
readonly PE: "26";
|
|
448
|
+
readonly PI: "22";
|
|
449
|
+
readonly PR: "41";
|
|
450
|
+
readonly RJ: "33";
|
|
451
|
+
readonly RN: "24";
|
|
452
|
+
readonly RO: "11";
|
|
453
|
+
readonly RR: "14";
|
|
454
|
+
readonly RS: "43";
|
|
455
|
+
readonly SC: "42";
|
|
456
|
+
readonly SE: "28";
|
|
457
|
+
readonly SP: "35";
|
|
458
|
+
readonly TO: "17";
|
|
459
|
+
};
|
|
460
|
+
type StateCode = (typeof UF)[keyof typeof UF];
|
|
461
|
+
type StateAcronym = keyof typeof UF;
|
|
462
|
+
|
|
463
|
+
declare const Environment: {
|
|
464
|
+
readonly Production: "1";
|
|
465
|
+
readonly Homolog: "2";
|
|
466
|
+
};
|
|
467
|
+
type EnvironmentCode = (typeof Environment)[keyof typeof Environment];
|
|
468
|
+
|
|
469
|
+
interface StrategyPattern<T, R> {
|
|
470
|
+
execute(...args: T[]): R;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
type HeaderValue = string | string[] | number | boolean | null;
|
|
474
|
+
type HttpClientHeaders = Record<string, HeaderValue>;
|
|
475
|
+
type ResponseType = 'arraybuffer' | 'json';
|
|
476
|
+
interface RequestConfig {
|
|
477
|
+
headers?: HttpClientHeaders;
|
|
478
|
+
responseType?: ResponseType;
|
|
479
|
+
}
|
|
480
|
+
interface HttpResponse<T = unknown> {
|
|
481
|
+
data: T;
|
|
482
|
+
status: number;
|
|
483
|
+
statusText: string;
|
|
484
|
+
headers: HttpClientHeaders;
|
|
485
|
+
}
|
|
486
|
+
interface HttpClient {
|
|
487
|
+
get<T = unknown, R = HttpResponse<T>>(url: string, config?: RequestConfig): Promise<R>;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
type Client = Record<string, (args: any, opt?: RequestConfig) => Promise<any>>;
|
|
491
|
+
type KnownKeys<T> = keyof {
|
|
492
|
+
[K in keyof T as {} extends Record<K, 1> ? never : K]: T[K];
|
|
493
|
+
};
|
|
494
|
+
type SendTransmissionPayload<C extends Client> = {
|
|
495
|
+
[M in KnownKeys<C> & string]: {
|
|
496
|
+
url: string;
|
|
497
|
+
method: M;
|
|
498
|
+
root: string;
|
|
499
|
+
payload: Parameters<C[M]>[0];
|
|
500
|
+
};
|
|
501
|
+
}[KnownKeys<C> & string];
|
|
502
|
+
type ExtractReturnType<C extends Client, P extends SendTransmissionPayload<C>> = P extends {
|
|
503
|
+
method: infer M extends keyof C;
|
|
504
|
+
} ? Awaited<ReturnType<C[M]>> : never;
|
|
505
|
+
|
|
506
|
+
interface TransmitterOptions {
|
|
507
|
+
certificate?: ReadCertificateResponse;
|
|
508
|
+
contingency?: boolean;
|
|
509
|
+
}
|
|
510
|
+
interface Transmitter<C extends Client> {
|
|
511
|
+
configure(options: TransmitterOptions): Transmitter<C>;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
declare class ValidationError extends NFeTsError {
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
interface CacheAdapter {
|
|
518
|
+
get<T>(key: string): Promise<T | null>;
|
|
519
|
+
has(key: string): Promise<boolean>;
|
|
520
|
+
set(key: string, value: unknown): Promise<boolean>;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
interface RemoteTransmissionRepository<C extends Client> {
|
|
524
|
+
setCertificate(certificate: ReadCertificateResponse): RemoteTransmissionRepository<C>;
|
|
525
|
+
send<P extends SendTransmissionPayload<C>>(params: P): Promise<Either<NFeTsError, ExtractReturnType<C, P>>>;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
declare class Decimal extends Decimal$1 implements Decimal$2 {
|
|
529
|
+
static from(value: DecimalValue$1 | Decimal): Decimal$2;
|
|
530
|
+
static newOrZero(value?: DecimalValue$1 | Decimal): Decimal$2;
|
|
531
|
+
static newOrUndefined(value?: DecimalValue$1 | Decimal): Decimal$2 | undefined;
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
declare class MemoryCacheAdapter implements CacheAdapter$1 {
|
|
535
|
+
private cache;
|
|
536
|
+
get<T>(key: string): Promise<T | null>;
|
|
537
|
+
has(key: string): Promise<boolean>;
|
|
538
|
+
set(key: string, value: unknown): Promise<boolean>;
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
declare class NativeCertificateRepository implements CertificateRepository$1 {
|
|
542
|
+
private readonly httpClient;
|
|
543
|
+
private readonly cache;
|
|
544
|
+
constructor(httpClient: HttpClient$1, cache?: CacheAdapter$1);
|
|
545
|
+
read(pfxPathOrBase64: string, password: string): Promise<Either$1<NFeTsError$1, ReadCertificateResponse$1>>;
|
|
546
|
+
sign(content: string, privateKey: KeyObject, algorithm?: SignatureAlgorithm$1): Promise<_nfets_core_shared_either.Left<NFeTsError$1> | _nfets_core_shared_either.Right<string>>;
|
|
547
|
+
getStringPublicKey(certificate: KeyObject): string;
|
|
548
|
+
getStringPrivateKey(privateKey: KeyObject): string;
|
|
549
|
+
private getPfxBuffer;
|
|
550
|
+
private getCacheKey;
|
|
551
|
+
private hitBufferOnCache;
|
|
552
|
+
private isValidRemoteUrl;
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
declare class NullCacheAdapter implements CacheAdapter$1 {
|
|
556
|
+
get<T>(_: string): Promise<T | null>;
|
|
557
|
+
has(_: string): Promise<boolean>;
|
|
558
|
+
set(_: string, __: unknown): Promise<boolean>;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
declare class SoapRemoteTransmissionRepository<C extends Client$1> implements RemoteTransmissionRepository$1<C> {
|
|
562
|
+
private readonly toolkit;
|
|
563
|
+
private readonly certificateRepository;
|
|
564
|
+
private certificate?;
|
|
565
|
+
constructor(toolkit: XmlToolkit$1, certificateRepository: CertificateRepository$1);
|
|
566
|
+
setCertificate(certificate: ReadCertificateResponse$1): this;
|
|
567
|
+
protected get httpsAgent(): Agent;
|
|
568
|
+
protected get defaultSoapHeaders(): {
|
|
569
|
+
'Content-Type': string;
|
|
570
|
+
};
|
|
571
|
+
send<P extends SendTransmissionPayload$1<C>>(params: P): Promise<_nfets_core_shared_either.Left<_nfets_core_domain.NFeTsError> | _nfets_core_shared_either.Right<ExtractReturnType$1<C, P>>>;
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
declare class Xml2JsToolkit implements XmlToolkit {
|
|
575
|
+
private readonly xml2js;
|
|
576
|
+
constructor(xml2js?: typeof Xml2js);
|
|
577
|
+
validate(xml: string, xsdPathReference: string, xsdFilename: string): Promise<Left<NFeTsError> | Right<never>>;
|
|
578
|
+
parse<T>(xml: string, options?: ParserOptions): Promise<T>;
|
|
579
|
+
build(object: object, options?: BuilderOptions): Promise<string>;
|
|
580
|
+
digest(xml: string, algorithm: SignatureAlgorithm, options?: CanonicalizeOptions): string;
|
|
581
|
+
canonicalize(xml: string, options?: CanonicalizeOptions): string;
|
|
582
|
+
getNode(xml: string, tag: string): string | null;
|
|
583
|
+
getAttribute(xml: string, tag: string): string | null;
|
|
584
|
+
appendNode(xml: string, node: string): string;
|
|
585
|
+
private hash;
|
|
586
|
+
private clear;
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
declare const leftFromError: (error: unknown) => Left<NFeTsError>;
|
|
590
|
+
|
|
591
|
+
type DeepPartial<T> = {
|
|
592
|
+
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
|
|
593
|
+
};
|
|
594
|
+
|
|
595
|
+
declare const unreachable: (_: never) => never;
|
|
596
|
+
|
|
597
|
+
declare class NfeXmlBuilder implements INfeXmlBuilder {
|
|
598
|
+
private readonly builder;
|
|
599
|
+
private readonly data;
|
|
600
|
+
protected readonly root = "NFe";
|
|
601
|
+
protected readonly $det: DetBuilderAggregator | undefined;
|
|
602
|
+
protected readonly $total: TotalBuilderAggregator | undefined;
|
|
603
|
+
protected readonly nfeDetXmlBuilder: _nfets_nfe_domain_entities_xml_builder_nfe_det_xml_builder.DetBuilder & ProdBuilder;
|
|
604
|
+
static create(builder: XmlToolkit$1): InfNFeBuilder & IdeBuilder;
|
|
605
|
+
protected constructor(builder: XmlToolkit$1);
|
|
606
|
+
infNFe($: InfNFeAttributes): this;
|
|
607
|
+
ide(payload: Ide): this;
|
|
608
|
+
emit(payload: Emit): this;
|
|
609
|
+
avulsa(payload: Avulsa): this;
|
|
610
|
+
dest(payload: Dest): this;
|
|
611
|
+
retirada(payload: Local): this;
|
|
612
|
+
entrega(payload: Local): this;
|
|
613
|
+
autXML(payload: AutXML): this;
|
|
614
|
+
det<T>(items: [T, ...T[]], build: (ctx: ProdBuilder, item: T) => AssembleDetXmlBuilder): this;
|
|
615
|
+
total(payload: Total): this;
|
|
616
|
+
increment(callback: (context: DeepPartial$1<Total>) => DeepPartial$1<Total>): this;
|
|
617
|
+
transp(payload: Transp): this;
|
|
618
|
+
cobr(payload: Cobr): this;
|
|
619
|
+
pag(payload: Pag): this;
|
|
620
|
+
infIntermed(payload: InfIntermed): this;
|
|
621
|
+
infAdic(payload: InfAdic): this;
|
|
622
|
+
exporta(payload: Exporta): this;
|
|
623
|
+
compra(payload: Compra): this;
|
|
624
|
+
cana(payload: Cana): this;
|
|
625
|
+
infRespTec(payload: InfRespTec): this;
|
|
626
|
+
infSolicNFF(payload: InfSolicNFF): this;
|
|
627
|
+
quiet(): this;
|
|
628
|
+
toObject(): _nfets_core.Left<NFeTsError$2> | _nfets_core.Right<NFe$1>;
|
|
629
|
+
assemble(): Promise<_nfets_core.Left<NFeTsError$2> | _nfets_core.Right<string>>;
|
|
630
|
+
private errors;
|
|
631
|
+
private collect;
|
|
632
|
+
private fillAccessKeyIfEmpty;
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
declare class AccessKeyBuilder {
|
|
636
|
+
compile(payload: AccessKey): string;
|
|
637
|
+
decompile(accessKey: string): VerifiedAccessKey | undefined;
|
|
638
|
+
private code;
|
|
639
|
+
private isCodeValid;
|
|
640
|
+
private verifyingDigit;
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
declare class NFe implements NFe$2 {
|
|
644
|
+
$: NFeAttributes;
|
|
645
|
+
infNFe: InfNFe$1;
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
declare class InfNFe implements InfNFe$1 {
|
|
649
|
+
$: InfNFeAttributes;
|
|
650
|
+
ide: Ide;
|
|
651
|
+
emit: Emit;
|
|
652
|
+
avulsa?: Avulsa;
|
|
653
|
+
dest?: Dest;
|
|
654
|
+
retirada?: Local;
|
|
655
|
+
entrega?: Local;
|
|
656
|
+
autXML?: AutXML[];
|
|
657
|
+
det: [Det, ...Det[]];
|
|
658
|
+
total: Total;
|
|
659
|
+
transp: Transp;
|
|
660
|
+
cobr?: Cobr;
|
|
661
|
+
pag: Pag;
|
|
662
|
+
infIntermed?: InfIntermed;
|
|
663
|
+
infAdic?: InfAdic;
|
|
664
|
+
exporta?: Exporta;
|
|
665
|
+
compra?: Compra;
|
|
666
|
+
cana?: Cana;
|
|
667
|
+
infRespTec?: InfRespTec;
|
|
668
|
+
infSolicNFF?: InfSolicNFF;
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
declare class InfNFeSupl implements InfNFeSupl$1 {
|
|
672
|
+
qrCode: string;
|
|
673
|
+
urlChave: string;
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
declare class NFCe {
|
|
677
|
+
infNFe: InfNFe;
|
|
678
|
+
infNFeSupl: InfNFeSupl;
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
export { AccessKeyBuilder, type BuilderOptions, type CacheAdapter, CanonicalizationMethod$1 as CanonicalizationMethod, type CanonicalizeOptions, type CertificateRepository, Choice, type ChoiceOptions, type Client, Decimal, type DecimalValue, type DeepPartial, DigestAlgorithm, type Either, EntitySigner, Environment, type EnvironmentCode, type ExtractReturnType, type HeaderValue, type HttpClient, type HttpClientHeaders, type HttpResponse, IsDecimal, type KnownKeys, Left, MemoryCacheAdapter, NFCe, NFe, NFeTsError, NativeCertificateRepository, NfeXmlBuilder, NullCacheAdapter, type ParserOptions, type ReadCertificateResponse, type RemoteTransmissionRepository, type RenderOptions, type RequestConfig, type ResponseType, Right, type SendTransmissionPayload, type Signature, SignatureAlgorithm, SignatureMethod$1 as SignatureMethod, SignatureNamespace, type SignedEntity, type SignedInfo, Signer, type SignerOptions, SkipAllValidations, SkipValidation, SkipValidationMetadata, SoapRemoteTransmissionRepository, type StateAcronym, type StateCode, StateCodeAcValidator, StateCodeAlValidator, StateCodeAmValidator, StateCodeApValidator, StateCodeBaValidator, StateCodeCeValidator, StateCodeDfValidator, StateCodeEsValidator, StateCodeGoValidator, StateCodeMaValidator, StateCodeMgValidator, StateCodeMsValidator, StateCodeMtValidator, StateCodePaValidator, StateCodePbValidator, StateCodePeValidator, StateCodePiValidator, StateCodePrValidator, StateCodeRjValidator, StateCodeRnValidator, StateCodeRoValidator, StateCodeRrValidator, StateCodeRsValidator, StateCodeScValidator, StateCodeSeValidator, StateCodeSpValidator, StateCodeToValidator, type StrategyPattern, TransformDateString, TransformDecimal, type TransformDecimalArgs, type TransformToDateStringArgs, type Transforms, type Transmitter, type TransmitterOptions, UF, ValidateErrorsMetadata, Validates, ValidationError, Xml2JsToolkit, type XmlDeclarationAttributes, XmlSigner, type XmlToolkit, defaultBuilderOptions, defaultCanonicalizeOptions, defaultParserOptions, left, leftFromError, mapConstraintsToErrors, plainToInstance, right, unreachable };
|