@qilin-agent/client-ui-primitives 3.1.5 → 3.1.7

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.
@@ -0,0 +1,146 @@
1
+ import { type FormatTables } from './format-tables.ts';
2
+ /** One recognized credential range, with the display form that masks it. */
3
+ export interface SecretRange {
4
+ readonly start: number;
5
+ readonly end: number;
6
+ /** Display form of the original range; line breaks stay in place. */
7
+ readonly masked: string;
8
+ }
9
+ /**
10
+ * One scanner's state: the tables, its own patterns, and a memo of the last
11
+ * queried text, which it keeps until a query for another text. Queries are
12
+ * synchronous and never re-enter, so the patterns' cursors are never shared.
13
+ */
14
+ export declare class CredentialScanner {
15
+ private readonly classes;
16
+ private readonly literals;
17
+ private readonly literalLength;
18
+ private readonly literalKind;
19
+ private readonly literalCheck;
20
+ private readonly literalMin;
21
+ private readonly literalMax;
22
+ private readonly literalOverlap;
23
+ private readonly ending;
24
+ private readonly sharedEndings;
25
+ /** Memo slot of each prefixed format's run class; 0 for `[A-Za-z0-9_-]`, which has four. */
26
+ private readonly literalSlot;
27
+ private readonly literalPattern;
28
+ private readonly prefixes;
29
+ private readonly keyRun;
30
+ private readonly userRun;
31
+ private readonly passwordRun;
32
+ private readonly nonDigits;
33
+ private readonly masks;
34
+ private readonly memo;
35
+ private text;
36
+ /**
37
+ * Build one scanner over shared tables.
38
+ * @param tables - the tables every scanner shares.
39
+ */
40
+ constructor(tables: FormatTables);
41
+ /**
42
+ * The nearest credential at or after `from`. Overlapping candidates of any format join the earliest
43
+ * one and take its mask, so no credential is drawn half masked. Candidates arrive in start order;
44
+ * an address password waits until the scan passes its start, and no other `://` can occur before
45
+ * then, because a user name and a password exclude `/`. A password that starts inside a range also
46
+ * ends inside it: the range holds the `:` before the password, so it is a key block, whose `END`
47
+ * line has spaces, or one that runs to the end of the text.
48
+ * @param text - the complete original text.
49
+ * @param from - the query offset.
50
+ * @returns the nearest credential range, or undefined when none starts at or after `from`.
51
+ */
52
+ match(text: string, from: number): SecretRange | undefined;
53
+ /**
54
+ * Memo entry at `index`; the layout keeps every index inside the array.
55
+ * @param index - the memo index.
56
+ * @returns the stored offset.
57
+ */
58
+ private slot;
59
+ /**
60
+ * `\w` at one offset; out of range is not a word character.
61
+ * @param index - the offset to read.
62
+ * @returns whether the code unit is a word character.
63
+ */
64
+ private isWordAt;
65
+ /**
66
+ * `[^\s/:@?#]` for one UTF-16 code unit; NaN, read out of range, is not one.
67
+ * @param code - the code unit.
68
+ * @returns whether the code unit may appear in an address user name.
69
+ */
70
+ private isUserCode;
71
+ /**
72
+ * Index of the literal the prefix scan matched ending at `end`; one literal sharing the ending matches, so the last needs no check.
73
+ * @param end - the offset after the matched literal.
74
+ * @returns the literal's index.
75
+ */
76
+ private literalEndingAt;
77
+ /**
78
+ * End of the `[A-Za-z0-9_-]*` run at `start`, through four memo pairs replaced in turn.
79
+ * @param start - the run's first offset.
80
+ * @returns the offset after the run.
81
+ */
82
+ private keyRunEnd;
83
+ /**
84
+ * End of the run `pattern` matches at `start`, through the memo pair at `slot`.
85
+ * @param pattern - the sticky run pattern.
86
+ * @param start - the run's first offset.
87
+ * @param slot - the memo pair to fill.
88
+ * @returns the offset after the run.
89
+ */
90
+ private memoRunEnd;
91
+ /**
92
+ * Offset of the first digit at or after `start`, or the text length.
93
+ * @param start - the offset to search from.
94
+ * @returns the digit's offset.
95
+ */
96
+ private nextDigit;
97
+ /**
98
+ * Offset after `[A-Z0-9 ]{0,40}PRIVATE KEY-----` at `start`, or -1; reads at most 52 characters.
99
+ * @param start - the offset the label starts at.
100
+ * @returns the offset after the header label, or -1.
101
+ */
102
+ private labelEnd;
103
+ /**
104
+ * End of the `-----BEGIN [A-Z0-9 ]{0,40}PRIVATE KEY-----` block at `at`: after its first complete
105
+ * `END` line, or the end of the text; -1 for an invalid header.
106
+ * @param at - the offset of the `-----BEGIN ` literal.
107
+ * @returns the offset after the block, or -1.
108
+ */
109
+ private keyBlockEnd;
110
+ /**
111
+ * Whether `\b[a-z][a-z0-9+.-]{1,15}` ends at `at`; reads at most 17 characters back.
112
+ * @param at - the offset after the scheme.
113
+ * @returns whether a scheme ends there.
114
+ */
115
+ private schemeBefore;
116
+ /**
117
+ * The password in `\b[a-z][a-z0-9+.-]{1,15}://[^\s/:@?#]{0,256}:[^\s/@?#]+@` for the `://` at
118
+ * `at`; neither part crosses `?` or `#`, where the authority ends. Callers pass a `://` at or after
119
+ * the query offset, or one whose user name reaches it, so the password never starts before it.
120
+ * @param at - the offset of the `://` literal.
121
+ * @returns the password end with its start in the memo, or -1.
122
+ */
123
+ private addressPassword;
124
+ /**
125
+ * The address password at or after `from` whose `://` starts before `from`, as `addressPassword`
126
+ * returns it. The walk back over the user name runs only when a `:`, a password, and `@` follow.
127
+ * @param from - the query offset.
128
+ * @returns the password end with its start in the memo, or -1.
129
+ */
130
+ private addressBefore;
131
+ /**
132
+ * End of the prefixed credential whose literal starts at `at`, or -1.
133
+ * @param literal - the literal's index.
134
+ * @param at - the offset of the literal.
135
+ * @returns the offset after the credential, or -1.
136
+ */
137
+ private prefixedEnd;
138
+ }
139
+ /**
140
+ * Every credential in `text`, in start order, each with the display form that
141
+ * masks it.
142
+ * @param text - the original user text.
143
+ * @returns the masked ranges; empty when the text holds no recognized credential.
144
+ */
145
+ export declare function scanSecrets(text: string): readonly SecretRange[];
146
+ //# sourceMappingURL=credential-scanner.d.ts.map
@@ -0,0 +1,29 @@
1
+ /** Tables indexed by format position in `CREDENTIAL_FORMATS`, by ASCII code unit, or by a literal's last two code units. */
2
+ export interface FormatTables {
3
+ /** Class bits per ASCII code unit. */
4
+ readonly classes: Uint16Array;
5
+ readonly literals: readonly string[];
6
+ readonly literalLength: Uint8Array;
7
+ readonly literalKind: Uint8Array;
8
+ readonly literalCheck: Uint8Array;
9
+ readonly literalRun: Uint16Array;
10
+ readonly literalMin: Int32Array;
11
+ readonly literalMax: Int32Array;
12
+ /**
13
+ * Length of the longest proper suffix of each literal that begins a literal.
14
+ * The scan resumes there, so a key block whose first dash ends `sk-` is still seen.
15
+ */
16
+ readonly literalOverlap: Uint8Array;
17
+ /** Literal-only alternation of every literal, grouped by shared leading characters; no quantifier. */
18
+ readonly prefixSource: string;
19
+ /** Per key `code[-2] * 128 + code[-1]`: the literal with that ending plus one, or -1 where several share it. */
20
+ readonly ending: Int8Array;
21
+ /** Literals sharing an ending, by the same key. */
22
+ readonly sharedEndings: readonly (readonly number[] | undefined)[];
23
+ }
24
+ /**
25
+ * The tables for `CREDENTIAL_FORMATS`; the first call builds them.
26
+ * @returns the shared, read-only tables.
27
+ */
28
+ export declare function formatTables(): FormatTables;
29
+ //# sourceMappingURL=format-tables.d.ts.map