@guhttps/veu 0.0.0-stage → 0.4.0

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/dist/text.d.ts ADDED
@@ -0,0 +1,24 @@
1
+ /** Letra, número ou sublinhado em qualquer alfabeto: o \w do Python, que no JavaScript só cobre ASCII. */
2
+ export declare const W = "[\\p{L}\\p{N}_]";
3
+ export declare function stripAccents(text: string): string;
4
+ /** Forma de comparação: minúsculas, sem acentos e com espaços simples. */
5
+ export declare function fold(text: string): string;
6
+ export declare function onlyDigits(text: string): string;
7
+ export declare function escapeRegex(text: string): string;
8
+ /** Regex que acha qualquer uma das palavras (já normalizadas com fold) como palavra inteira. */
9
+ export declare function wordsRegex(words: Iterable<string>): RegExp | null;
10
+ export declare function isAlnum(char: string | undefined): boolean;
11
+ export declare function isUpper(text: string): boolean;
12
+ export declare function isLower(text: string): boolean;
13
+ export declare function isAlpha(text: string): boolean;
14
+ /** Até size caracteres antes de start, sem começar no meio de uma palavra. */
15
+ export declare function textBefore(text: string, start: number, size: number): string;
16
+ /** Até size caracteres depois de end, sem terminar no meio de uma palavra. */
17
+ export declare function textAfter(text: string, end: number, size: number): string;
18
+ export declare function contextWindow(text: string, start: number, end: number, before: number, after: number): string;
19
+ /** Torna letras de um trecho de regex insensíveis à caixa ("Rua" -> "[Rr][Uu][Aa]"), sem a flag i. */
20
+ export declare function caseless(source: string): string;
21
+ export declare function counter<T extends string>(items: Iterable<T>): Record<string, number>;
22
+ /** Busca binária: posição onde value entraria em sorted mantendo a ordem (à direita dos iguais). */
23
+ export declare function bisectRight(sorted: readonly number[], value: number): number;
24
+ export declare function bisectLeft(sorted: readonly number[], value: number): number;
package/dist/text.js ADDED
@@ -0,0 +1,121 @@
1
+ // Funções de texto compartilhadas pelos detectores (equivalentes às de veu/_text.py e recognizers/base.py).
2
+ /** Letra, número ou sublinhado em qualquer alfabeto: o \w do Python, que no JavaScript só cobre ASCII. */
3
+ export const W = "[\\p{L}\\p{N}_]";
4
+ const SPACES = /\s+/gu;
5
+ const MARKS = /\p{M}/gu;
6
+ export function stripAccents(text) {
7
+ return text.normalize("NFKD").replace(MARKS, "");
8
+ }
9
+ /** Forma de comparação: minúsculas, sem acentos e com espaços simples. */
10
+ export function fold(text) {
11
+ return stripAccents(text).toLowerCase().replace(/ß/g, "ss").replace(SPACES, " ").trim();
12
+ }
13
+ export function onlyDigits(text) {
14
+ return text.replace(/\D/g, "");
15
+ }
16
+ export function escapeRegex(text) {
17
+ // Sem o "-": com a flag u, "\-" fora de uma classe é erro de sintaxe (e "-" ali não é especial).
18
+ return text.replace(/[.*+?^${}()|[\]\\/]/g, "\\$&");
19
+ }
20
+ /** Regex que acha qualquer uma das palavras (já normalizadas com fold) como palavra inteira. */
21
+ export function wordsRegex(words) {
22
+ const terms = [...new Set([...words].filter(Boolean).map(fold))].sort((a, b) => b.length - a.length);
23
+ if (!terms.length)
24
+ return null;
25
+ return new RegExp(`(?<![\\p{L}\\p{N}_/])(?:${terms.map(escapeRegex).join("|")})(?![\\p{L}\\p{N}_/])`, "u");
26
+ }
27
+ const ALNUM = /[\p{L}\p{N}]/u;
28
+ export function isAlnum(char) {
29
+ return char !== undefined && char !== "" && ALNUM.test(char);
30
+ }
31
+ export function isUpper(text) {
32
+ return text !== text.toLowerCase() && text === text.toUpperCase();
33
+ }
34
+ export function isLower(text) {
35
+ return text !== text.toUpperCase() && text === text.toLowerCase();
36
+ }
37
+ export function isAlpha(text) {
38
+ return text.length > 0 && /^\p{L}+$/u.test(text);
39
+ }
40
+ /** Até size caracteres antes de start, sem começar no meio de uma palavra. */
41
+ export function textBefore(text, start, size) {
42
+ let left = Math.max(0, start - size);
43
+ if (left > 0 && isAlnum(text[left - 1])) {
44
+ while (left < start && isAlnum(text[left]))
45
+ left += 1;
46
+ }
47
+ return text.slice(left, start);
48
+ }
49
+ /** Até size caracteres depois de end, sem terminar no meio de uma palavra. */
50
+ export function textAfter(text, end, size) {
51
+ let right = Math.min(text.length, end + size);
52
+ if (right < text.length && isAlnum(text[right])) {
53
+ while (right > end && isAlnum(text[right - 1]))
54
+ right -= 1;
55
+ }
56
+ return text.slice(end, right);
57
+ }
58
+ export function contextWindow(text, start, end, before, after) {
59
+ return `${fold(textBefore(text, start, before))} │ ${fold(textAfter(text, end, after))}`;
60
+ }
61
+ /** Torna letras de um trecho de regex insensíveis à caixa ("Rua" -> "[Rr][Uu][Aa]"), sem a flag i. */
62
+ export function caseless(source) {
63
+ let output = "";
64
+ let inClass = false;
65
+ for (let i = 0; i < source.length; i += 1) {
66
+ const char = source[i];
67
+ if (char === "\\") {
68
+ output += char + (source[i + 1] ?? "");
69
+ i += 1;
70
+ continue;
71
+ }
72
+ if (inClass) {
73
+ if (char === "]")
74
+ inClass = false;
75
+ const lower = char.toLowerCase();
76
+ const upper = char.toUpperCase();
77
+ output += lower !== upper && char !== "]" ? lower + upper : char;
78
+ continue;
79
+ }
80
+ if (char === "[") {
81
+ inClass = true;
82
+ output += char;
83
+ continue;
84
+ }
85
+ const lower = char.toLowerCase();
86
+ const upper = char.toUpperCase();
87
+ output += lower !== upper ? `[${upper}${lower}]` : char;
88
+ }
89
+ return output;
90
+ }
91
+ export function counter(items) {
92
+ const counts = {};
93
+ for (const item of items)
94
+ counts[item] = (counts[item] ?? 0) + 1;
95
+ return counts;
96
+ }
97
+ /** Busca binária: posição onde value entraria em sorted mantendo a ordem (à direita dos iguais). */
98
+ export function bisectRight(sorted, value) {
99
+ let low = 0;
100
+ let high = sorted.length;
101
+ while (low < high) {
102
+ const middle = (low + high) >> 1;
103
+ if (value < sorted[middle])
104
+ high = middle;
105
+ else
106
+ low = middle + 1;
107
+ }
108
+ return low;
109
+ }
110
+ export function bisectLeft(sorted, value) {
111
+ let low = 0;
112
+ let high = sorted.length;
113
+ while (low < high) {
114
+ const middle = (low + high) >> 1;
115
+ if (sorted[middle] < value)
116
+ low = middle + 1;
117
+ else
118
+ high = middle;
119
+ }
120
+ return low;
121
+ }
@@ -0,0 +1,30 @@
1
+ export declare const VALID_DDDS: ReadonlySet<number>;
2
+ /** Resto da divisão por 97 de um número em texto, sem perder precisão em números grandes. */
3
+ export declare function mod97(digits: string): number;
4
+ export declare function cpfCheckDigits(base: string): string;
5
+ export declare function isValidCpf(value: string): boolean;
6
+ export declare function normalizeCnpj(value: string): string;
7
+ /** CNPJ numérico e alfanumérico: cada caractere vale o código ASCII menos 48. */
8
+ export declare function cnpjCheckDigits(base: string): string;
9
+ export declare function isValidCnpj(value: string): boolean;
10
+ export declare function pisCheckDigit(base: string): string;
11
+ export declare function isValidPis(value: string): boolean;
12
+ export declare function cnhCheckDigits(base: string): string;
13
+ export declare function isValidCnh(value: string): boolean;
14
+ export declare function tituloCheckDigits(base: string): string;
15
+ export declare function isValidTituloEleitor(value: string): boolean;
16
+ export declare function isValidCns(value: string): boolean;
17
+ export declare function renavamCheckDigit(base: string): string;
18
+ export declare function isValidRenavam(value: string): boolean;
19
+ export declare function isValidLuhn(value: string): boolean;
20
+ export declare function isValidCard(value: string): boolean;
21
+ export declare function cnjCheckDigits(number: string, year: string, segment: string, court: string, origin: string): string;
22
+ export declare function isValidProcessoCnj(value: string): boolean;
23
+ export declare function phoneDigits(value: string): string;
24
+ export declare function isValidPhone(value: string): boolean;
25
+ export declare function isValidIntlPhone(value: string): boolean;
26
+ export declare function isValidIban(value: string): boolean;
27
+ export declare function isValidIpv4(value: string): boolean;
28
+ export declare function isValidIpv6(value: string): boolean;
29
+ export declare function parseDate(value: string): Date | null;
30
+ export declare function isPlausibleBirthdate(value: string): boolean;
@@ -0,0 +1,267 @@
1
+ // Validação de documentos brasileiros pelos dígitos verificadores (equivalente a veu/validators.py).
2
+ import { onlyDigits } from "./text.js";
3
+ export const VALID_DDDS = new Set([
4
+ 11, 12, 13, 14, 15, 16, 17, 18, 19, 21, 22, 24, 27, 28, 31, 32, 33, 34, 35, 37, 38,
5
+ 41, 42, 43, 44, 45, 46, 47, 48, 49, 51, 53, 54, 55, 61, 62, 63, 64, 65, 66, 67, 68, 69,
6
+ 71, 73, 74, 75, 77, 79, 81, 82, 83, 84, 85, 86, 87, 88, 89, 91, 92, 93, 94, 95, 96, 97, 98, 99,
7
+ ]);
8
+ const CNPJ_W1 = [5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2];
9
+ const CNPJ_W2 = [6, ...CNPJ_W1];
10
+ function mod11(values, weights) {
11
+ let total = 0;
12
+ for (let i = 0; i < weights.length; i += 1)
13
+ total += values[i] * weights[i];
14
+ const rest = total % 11;
15
+ return rest < 2 ? 0 : 11 - rest;
16
+ }
17
+ function repeated(digits) {
18
+ return digits.length > 0 && new Set(digits).size === 1;
19
+ }
20
+ const range = (from, to, step) => {
21
+ const output = [];
22
+ for (let n = from; step > 0 ? n < to : n > to; n += step)
23
+ output.push(n);
24
+ return output;
25
+ };
26
+ /** Resto da divisão por 97 de um número em texto, sem perder precisão em números grandes. */
27
+ export function mod97(digits) {
28
+ let rest = 0;
29
+ for (const char of digits)
30
+ rest = (rest * 10 + Number(char)) % 97;
31
+ return rest;
32
+ }
33
+ export function cpfCheckDigits(base) {
34
+ const values = [...base].map(Number);
35
+ const first = mod11(values, range(10, 1, -1));
36
+ const second = mod11([...values, first], range(11, 1, -1));
37
+ return `${first}${second}`;
38
+ }
39
+ export function isValidCpf(value) {
40
+ const digits = onlyDigits(value);
41
+ if (digits.length !== 11 || repeated(digits))
42
+ return false;
43
+ return cpfCheckDigits(digits.slice(0, 9)) === digits.slice(9);
44
+ }
45
+ export function normalizeCnpj(value) {
46
+ return value.replace(/[^0-9A-Za-z]/g, "").toUpperCase();
47
+ }
48
+ /** CNPJ numérico e alfanumérico: cada caractere vale o código ASCII menos 48. */
49
+ export function cnpjCheckDigits(base) {
50
+ const values = [...base.toUpperCase()].map((char) => char.charCodeAt(0) - 48);
51
+ const first = mod11(values, CNPJ_W1);
52
+ const second = mod11([...values, first], CNPJ_W2);
53
+ return `${first}${second}`;
54
+ }
55
+ export function isValidCnpj(value) {
56
+ const cnpj = normalizeCnpj(value);
57
+ if (cnpj.length !== 14 || !/^\d{2}$/.test(cnpj.slice(12)))
58
+ return false;
59
+ if (!/^[0-9A-Z]{12}$/.test(cnpj.slice(0, 12)))
60
+ return false;
61
+ if (/^\d+$/.test(cnpj) && repeated(cnpj))
62
+ return false;
63
+ return cnpjCheckDigits(cnpj.slice(0, 12)) === cnpj.slice(12);
64
+ }
65
+ export function pisCheckDigit(base) {
66
+ const weights = [3, 2, 9, 8, 7, 6, 5, 4, 3, 2];
67
+ const rest = [...base].reduce((total, char, i) => total + Number(char) * weights[i], 0) % 11;
68
+ const digit = 11 - rest;
69
+ return digit >= 10 ? "0" : String(digit);
70
+ }
71
+ export function isValidPis(value) {
72
+ const digits = onlyDigits(value);
73
+ if (digits.length !== 11 || repeated(digits))
74
+ return false;
75
+ return pisCheckDigit(digits.slice(0, 10)) === digits[10];
76
+ }
77
+ export function cnhCheckDigits(base) {
78
+ const values = [...base].map(Number);
79
+ let first = values.reduce((total, value, i) => total + value * (9 - i), 0) % 11;
80
+ let discount = 0;
81
+ if (first >= 10) {
82
+ first = 0;
83
+ discount = 2;
84
+ }
85
+ let second = (values.reduce((total, value, i) => total + value * (i + 1), 0) % 11) - discount;
86
+ if (second < 0)
87
+ second += 11;
88
+ if (second >= 10)
89
+ second = 0;
90
+ return `${first}${second}`;
91
+ }
92
+ export function isValidCnh(value) {
93
+ const digits = onlyDigits(value);
94
+ if (digits.length !== 11 || repeated(digits))
95
+ return false;
96
+ return cnhCheckDigits(digits.slice(0, 9)) === digits.slice(9);
97
+ }
98
+ export function tituloCheckDigits(base) {
99
+ const values = [...base].map(Number);
100
+ const uf = values[8] * 10 + values[9];
101
+ let first = values.slice(0, 8).reduce((total, value, i) => total + value * (i + 2), 0) % 11;
102
+ if (first === 10)
103
+ first = 0;
104
+ else if (first === 0 && (uf === 1 || uf === 2))
105
+ first = 1;
106
+ let second = (values[8] * 7 + values[9] * 8 + first * 9) % 11;
107
+ if (second === 10)
108
+ second = 0;
109
+ else if (second === 0 && (uf === 1 || uf === 2))
110
+ second = 1;
111
+ return `${first}${second}`;
112
+ }
113
+ export function isValidTituloEleitor(value) {
114
+ const digits = onlyDigits(value);
115
+ if (digits.length !== 12 || repeated(digits))
116
+ return false;
117
+ const uf = Number(digits.slice(8, 10));
118
+ if (uf < 1 || uf > 28)
119
+ return false;
120
+ return tituloCheckDigits(digits.slice(0, 10)) === digits.slice(10);
121
+ }
122
+ export function isValidCns(value) {
123
+ const digits = onlyDigits(value);
124
+ if (digits.length !== 15 || !"12789".includes(digits[0]))
125
+ return false;
126
+ return [...digits].reduce((total, char, i) => total + Number(char) * (15 - i), 0) % 11 === 0;
127
+ }
128
+ export function renavamCheckDigit(base) {
129
+ const weights = [3, 2, 9, 8, 7, 6, 5, 4, 3, 2];
130
+ const total = [...base].reduce((sum, char, i) => sum + Number(char) * weights[i], 0);
131
+ const digit = (total * 10) % 11;
132
+ return digit === 10 ? "0" : String(digit);
133
+ }
134
+ export function isValidRenavam(value) {
135
+ let digits = onlyDigits(value);
136
+ if (digits.length < 9 || digits.length > 11)
137
+ return false;
138
+ digits = digits.padStart(11, "0");
139
+ if (repeated(digits))
140
+ return false;
141
+ return renavamCheckDigit(digits.slice(0, 10)) === digits[10];
142
+ }
143
+ export function isValidLuhn(value) {
144
+ const digits = onlyDigits(value);
145
+ if (digits.length < 13 || digits.length > 19 || repeated(digits))
146
+ return false;
147
+ let total = 0;
148
+ [...digits].reverse().forEach((char, position) => {
149
+ let number = Number(char);
150
+ if (position % 2) {
151
+ number *= 2;
152
+ if (number > 9)
153
+ number -= 9;
154
+ }
155
+ total += number;
156
+ });
157
+ return total % 10 === 0;
158
+ }
159
+ export function isValidCard(value) {
160
+ const digits = onlyDigits(value);
161
+ if (!isValidLuhn(digits) || !"23456".includes(digits[0]))
162
+ return false;
163
+ return !(digits.length === 14 && isValidCnpj(digits)) && !(digits.length === 15 && isValidCns(digits));
164
+ }
165
+ export function cnjCheckDigits(number, year, segment, court, origin) {
166
+ const rest = mod97(`${number}${year}${segment}${court}${origin}00`);
167
+ return String(98 - rest).padStart(2, "0");
168
+ }
169
+ export function isValidProcessoCnj(value) {
170
+ const d = onlyDigits(value);
171
+ if (d.length !== 20)
172
+ return false;
173
+ return cnjCheckDigits(d.slice(0, 7), d.slice(9, 13), d[13], d.slice(14, 16), d.slice(16)) === d.slice(7, 9);
174
+ }
175
+ export function phoneDigits(value) {
176
+ const digits = onlyDigits(value);
177
+ return (digits.length === 12 || digits.length === 13) && digits.startsWith("55") ? digits.slice(2) : digits;
178
+ }
179
+ export function isValidPhone(value) {
180
+ const digits = phoneDigits(value);
181
+ if (digits.length === 11) {
182
+ return VALID_DDDS.has(Number(digits.slice(0, 2))) && digits[2] === "9" && !repeated(digits.slice(3));
183
+ }
184
+ if (digits.length === 10) {
185
+ return VALID_DDDS.has(Number(digits.slice(0, 2))) && "2345".includes(digits[2]) && !repeated(digits.slice(2));
186
+ }
187
+ return false;
188
+ }
189
+ export function isValidIntlPhone(value) {
190
+ const digits = onlyDigits(value);
191
+ return digits.length >= 8 && digits.length <= 15 && !repeated(digits.slice(-8));
192
+ }
193
+ export function isValidIban(value) {
194
+ const compact = value.replace(/[\s-]/g, "").toUpperCase();
195
+ if (!/^[A-Z]{2}\d{2}[A-Z0-9]{11,30}$/.test(compact))
196
+ return false;
197
+ const rearranged = compact.slice(4) + compact.slice(0, 4);
198
+ const number = [...rearranged].map((char) => parseInt(char, 36).toString()).join("");
199
+ return mod97(number) === 1;
200
+ }
201
+ export function isValidIpv4(value) {
202
+ const parts = value.split(".");
203
+ if (parts.length !== 4)
204
+ return false;
205
+ // Como o ipaddress do Python: sem zeros à esquerda e cada parte de 0 a 255.
206
+ if (!parts.every((part) => /^\d{1,3}$/.test(part) && Number(part) <= 255 && !(part.length > 1 && part[0] === "0"))) {
207
+ return false;
208
+ }
209
+ return !(parts[0] === "127" || value === "0.0.0.0");
210
+ }
211
+ export function isValidIpv6(value) {
212
+ if ((value.match(/:/g) ?? []).length < 2)
213
+ return false;
214
+ const halves = value.split("::");
215
+ if (halves.length > 2)
216
+ return false;
217
+ const groups = (half) => (half === "" ? [] : half.split(":"));
218
+ const head = groups(halves[0]);
219
+ const tail = halves.length === 2 ? groups(halves[1]) : [];
220
+ const all = [...head, ...tail];
221
+ if (!all.every((group) => /^[0-9A-Fa-f]{1,4}$/.test(group)))
222
+ return false;
223
+ if (halves.length === 2 ? all.length > 7 : all.length !== 8)
224
+ return false;
225
+ const expanded = halves.length === 2
226
+ ? [...head, ...Array(8 - all.length).fill("0"), ...tail]
227
+ : all;
228
+ const numbers = expanded.map((group) => parseInt(group, 16));
229
+ const zero = numbers.every((n) => n === 0);
230
+ const loopback = numbers.slice(0, 7).every((n) => n === 0) && numbers[7] === 1;
231
+ return !(zero || loopback);
232
+ }
233
+ const MONTHS = {
234
+ janeiro: 1, fevereiro: 2, marco: 3, "março": 3, abril: 4, maio: 5, junho: 6,
235
+ julho: 7, agosto: 8, setembro: 9, outubro: 10, novembro: 11, dezembro: 12,
236
+ };
237
+ export function parseDate(value) {
238
+ const text = value.trim().toLowerCase();
239
+ let day;
240
+ let month;
241
+ let year;
242
+ let match = /^(\d{1,2})\s+de\s+([a-zç]+)\s+de\s+(\d{4})$/.exec(text);
243
+ if (match) {
244
+ [day, month, year] = [Number(match[1]), MONTHS[match[2]], Number(match[3])];
245
+ }
246
+ else if ((match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(text))) {
247
+ [year, month, day] = [Number(match[1]), Number(match[2]), Number(match[3])];
248
+ }
249
+ else if ((match = /^(\d{1,2})[/.-](\d{1,2})[/.-](\d{2}|\d{4})$/.exec(text))) {
250
+ [day, month, year] = [Number(match[1]), Number(match[2]), Number(match[3])];
251
+ if (year < 100)
252
+ year += year > 30 ? 1900 : 2000;
253
+ }
254
+ else {
255
+ return null;
256
+ }
257
+ if (!month || month < 1 || month > 12 || year < 1)
258
+ return null;
259
+ const date = new Date(Date.UTC(year, month - 1, day));
260
+ if (date.getUTCFullYear() !== year || date.getUTCMonth() !== month - 1 || date.getUTCDate() !== day)
261
+ return null;
262
+ return date;
263
+ }
264
+ export function isPlausibleBirthdate(value) {
265
+ const parsed = parseDate(value);
266
+ return parsed !== null && parsed.getUTCFullYear() >= 1900 && parsed.getUTCFullYear() <= new Date().getFullYear();
267
+ }
@@ -0,0 +1,63 @@
1
+ /** Rótulos comparados só pelos dígitos ("529.982.247-25" e "52998224725" são o mesmo CPF). */
2
+ export declare const DIGIT_LABELS: ReadonlySet<string>;
3
+ export declare const CODE_LABELS: ReadonlySet<string>;
4
+ export declare const MAX_HOLDBACK = 48;
5
+ export declare function normalizeValue(label: string, value: string): string;
6
+ export interface VaultEntry {
7
+ label: string;
8
+ original: string;
9
+ replacement: string;
10
+ kind: "marcador" | "sintetico";
11
+ }
12
+ /** Formato de exportação, igual ao do Véu em Python (veu anonimizar --cofre). */
13
+ export interface VaultData {
14
+ versao: number;
15
+ itens: {
16
+ entidade: string;
17
+ original: string;
18
+ substituto: string;
19
+ tipo?: string;
20
+ }[];
21
+ chaves?: {
22
+ entidade: string;
23
+ valor: string;
24
+ substituto: string;
25
+ }[];
26
+ }
27
+ /** Mapeamento reversível entre dados reais e o que foi enviado ao modelo. Fica só na memória. */
28
+ export declare class Vault {
29
+ private byKey;
30
+ private items;
31
+ private counters;
32
+ private secret;
33
+ constructor(secret?: Uint8Array | string);
34
+ private static key;
35
+ lookup(label: string, value: string): string | undefined;
36
+ placeholder(label: string, value: string, hashed?: boolean): string;
37
+ /** Faz outro valor (por exemplo, só o primeiro nome) usar um marcador já existente. */
38
+ alias(label: string, value: string, replacement: string): void;
39
+ private store;
40
+ get size(): number;
41
+ entries(): VaultEntry[];
42
+ get labels(): Set<string>;
43
+ get hasPlaceholders(): boolean;
44
+ /** Troca os marcadores pelos valores reais. jsonEscape: o texto é um pedaço de JSON. */
45
+ restore(text: string, jsonEscape?: boolean): string;
46
+ restorer(jsonEscape?: boolean): StreamRestorer;
47
+ /** O fim do texto pode ser o começo de um marcador que chega no próximo pedaço? */
48
+ mightContinue(tail: string): boolean;
49
+ /** O arquivo exportado contém os dados reais: guarde com cuidado. */
50
+ toJSON(): VaultData;
51
+ static fromJSON(data: VaultData, secret?: Uint8Array | string): Vault;
52
+ }
53
+ /** Restaura uma resposta que chega em pedaços: um marcador dividido ("[PES" + "SOA_1]") fica retido até completar. */
54
+ export declare class StreamRestorer {
55
+ private buffer;
56
+ readonly vault: Vault;
57
+ readonly jsonEscape: boolean;
58
+ constructor(vault: Vault, jsonEscape?: boolean);
59
+ feed(text: string): string;
60
+ flush(): string;
61
+ get pending(): boolean;
62
+ private safeCut;
63
+ }