@keploy/capture-sdk 3.0.1 → 3.1.0-rc.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 +1617 -130
- package/body-redact/package.json +6 -0
- package/body-worker-start/package.json +6 -0
- package/dist/body-jobs.d.ts +134 -0
- package/dist/body-redact.d.ts +23 -0
- package/dist/body-redact.js +1 -0
- package/dist/body-redact.js.map +1 -0
- package/dist/body-redact.mjs +1 -0
- package/dist/body-redact.mjs.map +1 -0
- package/dist/body-worker-none.d.ts +3 -0
- package/dist/body-worker-none.js +1 -0
- package/dist/body-worker-none.js.map +1 -0
- package/dist/body-worker-none.mjs +1 -0
- package/dist/body-worker-none.mjs.map +1 -0
- package/dist/body-worker-start.d.ts +3 -0
- package/dist/body-worker-start.js +1 -0
- package/dist/body-worker-start.js.map +1 -0
- package/dist/body-worker-start.mjs +1 -0
- package/dist/body-worker-start.mjs.map +1 -0
- package/dist/body-worker-unbundled.d.ts +1 -0
- package/dist/body-worker-unbundled.mjs +1 -0
- package/dist/body-worker-unbundled.mjs.map +1 -0
- package/dist/body-worker.d.ts +1 -0
- package/dist/body-worker.js +1 -0
- package/dist/body-worker.js.map +1 -0
- package/dist/errors.d.ts +224 -28
- package/dist/index.bundler.mjs +1 -0
- package/dist/index.bundler.mjs.map +1 -0
- package/dist/index.d.ts +23 -28
- package/dist/index.js +1 -2354
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1 -2297
- package/dist/index.mjs.map +1 -0
- package/dist/leave.d.ts +67 -0
- package/dist/module-of.d.ts +58 -0
- package/dist/network.d.ts +163 -4
- package/dist/privacy.d.ts +387 -12
- package/dist/recorder.d.ts +304 -64
- package/dist/redact.d.ts +48 -6
- package/dist/request-term.d.ts +23 -0
- package/dist/request-term.js +1 -0
- package/dist/request-term.js.map +1 -0
- package/dist/request-term.mjs +1 -0
- package/dist/request-term.mjs.map +1 -0
- package/dist/strict-attributes.d.ts +9 -0
- package/dist/strict-attributes.js +1 -0
- package/dist/strict-attributes.js.map +1 -0
- package/dist/strict-attributes.mjs +1 -0
- package/dist/strict-attributes.mjs.map +1 -0
- package/dist/term-candidate.d.ts +16 -0
- package/dist/transport.d.ts +269 -130
- package/dist/types.d.ts +152 -9
- package/package.json +37 -4
- package/request-term/package.json +6 -0
- package/strict-attributes/package.json +6 -0
package/dist/privacy.d.ts
CHANGED
|
@@ -1,11 +1,371 @@
|
|
|
1
|
-
import type { NetworkEvent, PrivacyConfig } from "./types";
|
|
1
|
+
import type { CaptureConfig, NetworkEvent, PrivacyConfig } from "./types";
|
|
2
|
+
import type { BodyJob, BodyOut } from "./body-redact";
|
|
3
|
+
/**
|
|
4
|
+
* What reading a page URL's `name=value` pairs did, COUNTED rather than
|
|
5
|
+
* timed, as scrubWork is: the units the scan below looked at. Its cost is
|
|
6
|
+
* linear in the text, and the tests hold it by this count -- it was held
|
|
7
|
+
* by a clock (under 2 s for 60 KB), and on a fast machine the scan that
|
|
8
|
+
* reads a run from each of its units, the square of its length, stayed
|
|
9
|
+
* under it (found running the mutation table through the gate).
|
|
10
|
+
*/
|
|
11
|
+
export declare const urlWork: {
|
|
12
|
+
scanned: number;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Every `name=value` of a page URL, as written: each value runs to the
|
|
16
|
+
* next `&`, `;` or `#`, and holds whatever stands before it -- a `/`, a
|
|
17
|
+
* `?`, another `=`.
|
|
18
|
+
*/
|
|
19
|
+
export declare function pagePairs(url: string): Array<[string, string]>;
|
|
20
|
+
/**
|
|
21
|
+
* Every sensitive `name=value` in `text` -- a path's matrix parameters, a
|
|
22
|
+
* route, a query -- with its value redacted up to the next `&`, `;` or `#`
|
|
23
|
+
* (and `?` outside a query): a token can hold `/` (base64). The value of
|
|
24
|
+
* a pair that is not sensitive is read on for names, after its
|
|
25
|
+
* delimiters: `?next=/reset?token=...`.
|
|
26
|
+
*/
|
|
27
|
+
export declare function maskPairs(text: string, inQuery: boolean, linkPage?: boolean): string;
|
|
28
|
+
/** What a declared route must be (PrivacyConfig.secretRoutes): KUI_E_PRIVACY_ROUTE_INVALID quotes it. */
|
|
29
|
+
export declare const ROUTE_RULE = "a route is `/`-separated segments from the path's start, each a literal, `*` (any one segment) or `:name` (the value it names), with no `?` or `#`; a secret route names at least one `:name`, a keep route has at least one literal";
|
|
30
|
+
/**
|
|
31
|
+
* `route`'s segments, empty ones left out as a path's are, or null when it
|
|
32
|
+
* is outside ROUTE_RULE for its list. Kept with a slash at its end, a
|
|
33
|
+
* route matched nothing a path without one held (found in review).
|
|
34
|
+
*/
|
|
35
|
+
export declare function parseRoute(route: unknown, keep?: boolean): string[] | null;
|
|
36
|
+
/** How many times the declared routes have changed. */
|
|
37
|
+
export declare function routesGeneration(): number;
|
|
38
|
+
/** Adds routes already checked by parseRoute. */
|
|
39
|
+
export declare function declareRoutes(secret: string[][], keep: string[][]): void;
|
|
40
|
+
/**
|
|
41
|
+
* A credential a page URL carries, as every event is scrubbed of it
|
|
42
|
+
* (scrubSecrets). Kept as a kind beside its value, never as a marker
|
|
43
|
+
* inside it: a NUL marker was also a value's first character once
|
|
44
|
+
* `%00` decoded, so a token went out and an unrelated string was
|
|
45
|
+
* redacted (found in review).
|
|
46
|
+
*/
|
|
47
|
+
export type PageSecret =
|
|
48
|
+
/** Generated-looking: replaced wherever it appears. */
|
|
49
|
+
{
|
|
50
|
+
kind: 0;
|
|
51
|
+
value: string;
|
|
52
|
+
}
|
|
53
|
+
/** Declared, of at least DECLARED_EVERYWHERE characters: replaced in any case wherever no ASCII letter or digit touches it. */
|
|
54
|
+
| {
|
|
55
|
+
kind: 1;
|
|
56
|
+
value: string;
|
|
57
|
+
}
|
|
58
|
+
/** Declared, and shorter: replaced only as the path segment after `before`, as beforeOf matches it (DECLARED_EVERYWHERE). */
|
|
59
|
+
| {
|
|
60
|
+
kind: 2;
|
|
61
|
+
value: string;
|
|
62
|
+
before: string;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* The credential values in a page URL that every event is scrubbed of
|
|
66
|
+
* (scrubSecrets): each as it appears, decoded and encoded, and cut at each
|
|
67
|
+
* of its last four `/`. EVERY FORM is held to the rule the value is:
|
|
68
|
+
* generated-looking, not a URL, and not part of the page's own origin -- a
|
|
69
|
+
* form that is a word, or a prefix of an origin, scrubbed the page's own
|
|
70
|
+
* text and URLs for the rest of the page (found in review). A declared
|
|
71
|
+
* value is held by DECLARED_EVERYWHERE's rule instead.
|
|
72
|
+
*/
|
|
73
|
+
export declare function pageSecrets(href: string): PageSecret[];
|
|
74
|
+
/** The secrets of a page, each by how it is matched: what scrubSecrets is given. */
|
|
75
|
+
export interface SecretMatcher {
|
|
76
|
+
/** Each generated-looking secret as JSON text spells it inside a string: a quick test of a serialised event. */
|
|
77
|
+
json: string[];
|
|
78
|
+
/** Each declared one, ASCII-lower-cased, as JSON text spells it: a quick test of the event's JSON lower-cased. */
|
|
79
|
+
jsonLower: string[];
|
|
80
|
+
/** Generated-looking secrets, longest first: replaced wherever they appear. */
|
|
81
|
+
plain: string[];
|
|
82
|
+
/** Declared codes, ASCII-lower-cased, longest first: replaced in any case where no ASCII letter or digit touches them. */
|
|
83
|
+
bounded: string[];
|
|
84
|
+
/** Declared short values, ASCII-lower-cased, longest first, each with the segments it is named after (beforeOf): replaced where a URL holds one as the segment after one of them (wordAt). */
|
|
85
|
+
words: Word[];
|
|
86
|
+
}
|
|
87
|
+
/** A declared short value and the segments it is named after, with their lengths: what wordAt reads a text for. */
|
|
88
|
+
interface Word {
|
|
89
|
+
value: string;
|
|
90
|
+
/** The segments, as beforeOf reads them; `""` for a route's first segment, or a segment past MAX_BEFORE. */
|
|
91
|
+
befores: Set<string>;
|
|
92
|
+
/** Their lengths, and the longest of them (`""` aside). */
|
|
93
|
+
lengths: Set<number>;
|
|
94
|
+
longest: number;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Every index `v` starts at in `s`, overlapping ones included, in time
|
|
98
|
+
* linear in both (Knuth-Morris-Pratt): an indexOf after each match that
|
|
99
|
+
* was not on a boundary read the same text again once per overlap, and a
|
|
100
|
+
* crafted link under the 64 KiB cap made start() take 789 ms and each
|
|
101
|
+
* replaceState 145 ms (MEASURED in review).
|
|
102
|
+
*/
|
|
103
|
+
export declare function indicesOf(s: string, v: string): number[];
|
|
104
|
+
/**
|
|
105
|
+
* What the scrub did, COUNTED rather than timed: the pieces wordAt decoded,
|
|
106
|
+
* the strings it scrubbed, the units its scans read and the units it
|
|
107
|
+
* lower-cased. Its cost is held by these counts -- a budget in
|
|
108
|
+
* milliseconds holds nothing on a loaded machine and fails on one
|
|
109
|
+
* (MEASURED: 89 ms locally, 2,068 ms in the CI image, one test).
|
|
110
|
+
*/
|
|
111
|
+
export declare const scrubWork: {
|
|
112
|
+
pieces: number;
|
|
113
|
+
strings: number;
|
|
114
|
+
scanned: number;
|
|
115
|
+
lowered: number;
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* The most the later pass can shorten `[start, end)` places that may
|
|
119
|
+
* overlap, across forms: each run of overlapping places, of total length U,
|
|
120
|
+
* shortens by U less one marker at most, since the replacements made in it
|
|
121
|
+
* are disjoint and each writes one.
|
|
122
|
+
*/
|
|
123
|
+
export declare function unionSlack(spans: number[]): number;
|
|
124
|
+
/**
|
|
125
|
+
* Each place CSS carries data -- a comment (an unclosed one runs to the
|
|
126
|
+
* end), a `url(...)` (its argument unquoted up to the first `)`, or one
|
|
127
|
+
* quoted string, with whitespace around it), a quoted string -- as
|
|
128
|
+
* `at(start, end)`, left to right, leftmost first and in that order of
|
|
129
|
+
* kinds where two start at one place. A string or url() that does not
|
|
130
|
+
* close is no place, and the scan goes on from the unit after its start.
|
|
131
|
+
*
|
|
132
|
+
* IN ONE PASS, counted in scrubWork.scanned. It was a regular expression,
|
|
133
|
+
* and `url(` followed by a run of whitespace with no `)` -- where its
|
|
134
|
+
* three quantifiers all match whitespace -- cost the cube of the run: a
|
|
135
|
+
* crafted inline style froze a page for 13 s at 4 KB (reproduced in
|
|
136
|
+
* review). Where each string body ends, and the next `)`, `"` or `'`
|
|
137
|
+
* after a point, are worked out once and remembered, so a run of
|
|
138
|
+
* unclosed `'a\` or `url(` reads each unit a bounded number of times.
|
|
139
|
+
*/
|
|
140
|
+
export declare function cssData(s: string, at: (start: number, end: number) => void): void;
|
|
141
|
+
/**
|
|
142
|
+
* One matcher for every one of `secrets`, longest first in each rule so a
|
|
143
|
+
* longer form wins over one inside it; null for none.
|
|
144
|
+
*/
|
|
145
|
+
export declare function secretPattern(secrets: readonly PageSecret[]): SecretMatcher | null;
|
|
146
|
+
/** What an event's `data` is: rrweb's event, the SDK's network record, or an integrator's own payload. */
|
|
147
|
+
export type EventShape = "dom" | "network" | "custom";
|
|
148
|
+
/**
|
|
149
|
+
* The longest key V8 hashes by its content: past 16,383 UTF-16 units a
|
|
150
|
+
* string is hashed by its length alone (MEASURED on Node 24: 1,000
|
|
151
|
+
* distinct keys sharing a prefix cost 9 ms in a Map at 8 KB, 645 ms just
|
|
152
|
+
* past this and 3.8 s at 60 KB).
|
|
153
|
+
*/
|
|
154
|
+
export declare const LONGEST_HASHED_KEY = 16383;
|
|
155
|
+
/**
|
|
156
|
+
* The memo key of `s` scrubbed as `how`: the string itself when V8 hashes
|
|
157
|
+
* it, else its length and a hash of its own (FNV-1a), compared whole only
|
|
158
|
+
* on a match. Keyed by the string alone, a page whose crafted URL rrweb
|
|
159
|
+
* writes into 1,000 distinct `href="#..."` made every lookup collide with
|
|
160
|
+
* every earlier one: 3.1 s for one snapshot (found in review).
|
|
161
|
+
*/
|
|
162
|
+
export declare function memoKey(how: string, s: string): string;
|
|
163
|
+
/**
|
|
164
|
+
* The text nodes of the page's `<style>` elements, by rrweb's node id, so
|
|
165
|
+
* the CSS a style's text holds is scrubbed as CSS. rrweb 2 marks none of
|
|
166
|
+
* them -- its serialized text node carries no `isStyle`, which rrweb 1's
|
|
167
|
+
* did -- so text written into a style after the snapshot (a theme switch's
|
|
168
|
+
* `style.textContent = ...`, a CSS-in-JS dev build, HMR) was scrubbed as
|
|
169
|
+
* text, and `/n0/invites/display` made `.b{display:block}` into
|
|
170
|
+
* `.b{[REDACTED]:block}` (found in review). One per capture: observe()
|
|
171
|
+
* reads every DOM event's JSON copy, in order, before it is scrubbed, and
|
|
172
|
+
* a full snapshot starts it over. rrweb's ids do NOT start over -- its
|
|
173
|
+
* mirror outlives a snapshot, and a node removed and added again keeps
|
|
174
|
+
* its id (MEASURED in review on rrweb 2.1.6) -- which is why an add says
|
|
175
|
+
* afresh what a node is.
|
|
176
|
+
*/
|
|
177
|
+
/**
|
|
178
|
+
* What the page says of rrweb's node ids, for the styles' observer. A node
|
|
179
|
+
* is NOTED when the observer starts following its id -- the moment rrweb
|
|
180
|
+
* has just serialised it, so its mirror holds it -- and asked about by
|
|
181
|
+
* that node from then on, not by the id: rrweb's mirror forgets an id
|
|
182
|
+
* that is still in the page. Recording a same-origin frame with an
|
|
183
|
+
* observer of its own, it writes a <style> moved out of the frame into the
|
|
184
|
+
* page as the page's add and THEN the frame's remove, and on that remove
|
|
185
|
+
* deletes the id from its id-to-node map (removeNodeFromMap) although the
|
|
186
|
+
* node is in the page (MEASURED in Chromium with rrweb 2.1.6: the add,
|
|
187
|
+
* two removes naming the frame's head, then the style's next text added
|
|
188
|
+
* under its id).
|
|
189
|
+
*/
|
|
190
|
+
export interface NodePresence {
|
|
191
|
+
/** Keep the node `id` names now. */
|
|
192
|
+
note(id: number): void;
|
|
193
|
+
/** The node kept for `id` is still in the page. */
|
|
194
|
+
present(id: number): boolean;
|
|
195
|
+
/** Stop keeping the node for `id`. */
|
|
196
|
+
forget(id: number): void;
|
|
197
|
+
}
|
|
198
|
+
export declare class StyleTexts {
|
|
199
|
+
private readonly page?;
|
|
200
|
+
/** Each style's text nodes, by the style's id. */
|
|
201
|
+
private readonly styles;
|
|
202
|
+
/** Each style text node's style, by the text's id. */
|
|
203
|
+
private readonly texts;
|
|
204
|
+
/**
|
|
205
|
+
* `present` says whether rrweb's node `id` is still in the page. rrweb
|
|
206
|
+
* writes a remove for the top of a removed subtree alone, so a style
|
|
207
|
+
* inside a removed container, shadow host or frame is named by no
|
|
208
|
+
* remove at all, and each such cycle left its ids followed for the
|
|
209
|
+
* session (found in review: +1,200 ids over 600 container cycles, +400
|
|
210
|
+
* over 200 shadow hosts). And a remove is not always the node leaving:
|
|
211
|
+
* a <style> moved from a frame into the page arrives as the page's add
|
|
212
|
+
* and THEN the frame's remove (NodePresence), and read as "gone" by
|
|
213
|
+
* that remove, a style still in the page was forgotten and its next text
|
|
214
|
+
* scrubbed as text (`.c{display:flex}` posted as `.c{[REDACTED]:flex}`,
|
|
215
|
+
* reproduced in review in Chromium). So with `page`, a removed node is
|
|
216
|
+
* forgotten only when it is no longer in the page; without one -- no
|
|
217
|
+
* DOM to ask -- the remove says so, and nothing is pruned.
|
|
218
|
+
*/
|
|
219
|
+
constructor(page?: NodePresence | undefined);
|
|
220
|
+
/** `id` has left the page: as `page` says, or, with none, as the remove that names it does. */
|
|
221
|
+
private gone;
|
|
222
|
+
/** How many ids are followed, a style's set of texts included: what a long session's churn must not grow. */
|
|
223
|
+
get size(): number;
|
|
224
|
+
private addText;
|
|
225
|
+
private dropText;
|
|
226
|
+
/**
|
|
227
|
+
* A removed node is no style, nor a style's text -- and a removed
|
|
228
|
+
* style's texts go with it: rrweb writes a remove for the style alone,
|
|
229
|
+
* and each add and remove of one left its text's id followed for the
|
|
230
|
+
* session (found in review: 2,000 ids after 2,000 cycles).
|
|
231
|
+
*/
|
|
232
|
+
private drop;
|
|
233
|
+
observe(event: unknown): void;
|
|
234
|
+
/** Stops following every id `present` says is gone: once per mutation that removes, over the ids followed. */
|
|
235
|
+
private prune;
|
|
236
|
+
private walk;
|
|
237
|
+
/** The records in an event (one observe() read, or a copy of it) whose `textContent` or `value` is a style's text. */
|
|
238
|
+
recordsIn(event: unknown): Set<unknown>;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* A scrub that stopped because what it had written passed `cap` units:
|
|
242
|
+
* the event could never be sent (scrubSecrets), and is dropped and said
|
|
243
|
+
* as KUI_E_EVENT_OVERSIZED_SCRUBBING. `atLeast` is a lower bound of the
|
|
244
|
+
* scrubbed event's size: what it had written, less what a later
|
|
245
|
+
* replacement could still take off it (secretRanges' slack).
|
|
246
|
+
*/
|
|
247
|
+
export declare class ScrubOverCap extends Error {
|
|
248
|
+
readonly atLeast: number;
|
|
249
|
+
readonly cap: number;
|
|
250
|
+
constructor(atLeast: number, cap: number);
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* `value` -- an event's `data`, of `shape` -- with every secret in its
|
|
254
|
+
* DATA replaced by `[REDACTED]`: a fresh copy when anything matched,
|
|
255
|
+
* `value` itself when nothing did.
|
|
256
|
+
*
|
|
257
|
+
* DATA, NOT STRUCTURE. What the event's reader parses is left as it is:
|
|
258
|
+
* a member's name is renamed only for a generated-looking secret, and
|
|
259
|
+
* never one rrweb writes for itself (`rr_*`); an attribute whose NAME
|
|
260
|
+
* holds one is dropped, since no name a DOM accepts holds `[REDACTED]`;
|
|
261
|
+
* rrweb's `tagName`, the network record's `method` and `type`, and a
|
|
262
|
+
* style declaration's property are never touched; CSS is scrubbed where
|
|
263
|
+
* it carries data (scrubCss); a request or response body as JSON when it
|
|
264
|
+
* is JSON (scrubBody). Renamed by a declared word, a crafted
|
|
265
|
+
* `#/invites/childNodes` made every node's `childNodes` `[REDACTED]` and
|
|
266
|
+
* the replay threw, `#/invites/button` every `<button>` a tag no DOM
|
|
267
|
+
* accepts, and `#/invites/source` left the flow engine no action -- with
|
|
268
|
+
* no keep route that could stop it, since the link names the word (found
|
|
269
|
+
* in review).
|
|
270
|
+
*
|
|
271
|
+
* NEVER WRITTEN: the value can be an integrator's own object
|
|
272
|
+
* (recorder.emitEvent is public), and an in-place walk hung the tab on a
|
|
273
|
+
* cycle, threw on a frozen object or a throwing getter, and rewrote the
|
|
274
|
+
* app's objects (found in review). Only a DOM event's styles are read in
|
|
275
|
+
* place (StyleTexts.observe: read-only, a cycle walked once, as
|
|
276
|
+
* scrubDomUrls reads the event before this). Its JSON -- what is sent -- is tested,
|
|
277
|
+
* and only when a secret is in it is a fresh copy parsed from that JSON
|
|
278
|
+
* and walked: acyclic, plain, and this function's own. The replacement is
|
|
279
|
+
* in DECODED strings, so it can never land inside an escape sequence and
|
|
280
|
+
* leave the JSON unparseable, and no regular expression runs over the
|
|
281
|
+
* whole serialised text, which overflowed the stack on an 8 MB string
|
|
282
|
+
* (found in review). Two names that become one are both kept, the second
|
|
283
|
+
* suffixed. A value JSON refuses is returned as it is, and the transport
|
|
284
|
+
* drops it unsent (KUI_E_EVENT_UNSERIALISABLE).
|
|
285
|
+
*/
|
|
286
|
+
export declare function scrubSecrets<T>(value: T, matcher: SecretMatcher | null, shape?: EventShape, styles?: StyleTexts, cap?: number): T;
|
|
287
|
+
/** The page's URL as a recording carries it (Meta events and session metadata). */
|
|
288
|
+
export declare function recordedPageUrl(href: string): string;
|
|
289
|
+
declare let strictKept: typeof import("./strict-attributes").kept | undefined;
|
|
290
|
+
/** Installs strict's allow-list, once its chunk has loaded (recorder.ts). */
|
|
291
|
+
export declare function keepStrict(kept: typeof strictKept): void;
|
|
292
|
+
/**
|
|
293
|
+
* An element's attributes as rrweb serialised them, each URL-valued one
|
|
294
|
+
* scrubbed IN PLACE (a value is replaced only when the scrub changed it).
|
|
295
|
+
* A value that is not a string (a style object, a removed attribute's
|
|
296
|
+
* null) is left alone.
|
|
297
|
+
*/
|
|
298
|
+
export declare function scrubDomAttributes(attributes: Record<string, unknown>, strict: boolean, secrets?: readonly string[], tag?: string, svg?: boolean): void;
|
|
299
|
+
/**
|
|
300
|
+
* The page's own text -- a text node in a snapshot or a node added after
|
|
301
|
+
* it, a text change, a value typed under `off` -- with each provider's
|
|
302
|
+
* token and JWT in it replaced, in every mode: the dashboard shows a
|
|
303
|
+
* freshly minted key as text, once. Other text, an email or a phone
|
|
304
|
+
* number among it, is the page's content and is recorded as rrweb masks
|
|
305
|
+
* it.
|
|
306
|
+
*/
|
|
307
|
+
export declare function scrubDomText(text: string): string;
|
|
308
|
+
/**
|
|
309
|
+
* CSS a DOM event carries outside an attribute -- a `<style>`'s text
|
|
310
|
+
* changed after it was added, a rule a script inserted or replaced
|
|
311
|
+
* through the CSSOM, a declaration it set, an adopted stylesheet -- its
|
|
312
|
+
* URLs scrubbed as a style attribute's are, with the page URL's
|
|
313
|
+
* credentials known (`secrets`, as scrubDomTree takes them).
|
|
314
|
+
*/
|
|
315
|
+
export declare function scrubDomCss(css: string, strict: boolean, secrets?: readonly string[]): string;
|
|
316
|
+
/**
|
|
317
|
+
* The same, for the nodes one mutation adds: each is an entry of its own,
|
|
318
|
+
* and `nextId` says which follows which. Linear: each chain is read once,
|
|
319
|
+
* from its head. A text beside a node already on the page is not in the
|
|
320
|
+
* batch, so it is read alone.
|
|
321
|
+
*/
|
|
322
|
+
export declare function scrubAddedTextRuns(adds: unknown[]): void;
|
|
323
|
+
export declare function scrubDomTree(root: unknown, strict: boolean, secrets?: readonly string[]): void;
|
|
324
|
+
/**
|
|
325
|
+
* A URL as it may be recorded -- the page's own, after the page URL rule
|
|
326
|
+
* (recordedPageUrl), or one in the DOM: query and fragment-pair values
|
|
327
|
+
* scrubbed by name (the one rule's, as a `page`) and by shape (a
|
|
328
|
+
* token, a PII pattern), a JWT path segment and a sensitive `;name=`
|
|
329
|
+
* path parameter replaced, a URL inside a value scrubbed one level down,
|
|
330
|
+
* user info dropped. Under
|
|
331
|
+
* `strict` every query and fragment-pair VALUE is replaced and every name
|
|
332
|
+
* kept: the founder's rule for public sites is that no typed text is
|
|
333
|
+
* recorded, and a search box puts what was typed in `?q=`. Not an http(s)
|
|
334
|
+
* URL: returned as it is. A URL with nothing to scrub is returned exactly
|
|
335
|
+
* as it came.
|
|
336
|
+
*/
|
|
337
|
+
export declare function scrubPageUrl(raw: string, strict?: boolean): string;
|
|
2
338
|
export declare function defaultPrivacyConfig(): PrivacyConfig;
|
|
339
|
+
/**
|
|
340
|
+
* The body code (body-redact.ts) on this thread, once the capture has
|
|
341
|
+
* loaded it (body-jobs.ts): what maskNetworkData redacts with when the
|
|
342
|
+
* caller passes no bodies.
|
|
343
|
+
*/
|
|
344
|
+
export declare const bodyCode: {
|
|
345
|
+
redact?: (job: BodyJob) => BodyOut;
|
|
346
|
+
};
|
|
347
|
+
/** What a body masked whole is recorded as (maskNetworkData); one that was absent stays null. */
|
|
348
|
+
export declare const MASKED = "[MASKED]";
|
|
3
349
|
export declare class PrivacyEngine {
|
|
4
350
|
private config;
|
|
5
351
|
private builtinPatterns;
|
|
6
352
|
/** The integrator's piiPatterns, compiled global once. */
|
|
7
353
|
private userPatterns;
|
|
8
|
-
|
|
354
|
+
/** `privacyMode: "strict"`: no body, and no query value, is recorded. */
|
|
355
|
+
private readonly strict;
|
|
356
|
+
/**
|
|
357
|
+
* `privacyMode` is the capture's (CaptureConfig.privacyMode). Only
|
|
358
|
+
* `strict` changes what this engine does: it records no request or
|
|
359
|
+
* response body -- `maskNetworkBodies` is forced on, here and through
|
|
360
|
+
* every updateConfig() -- and replaces every query value of a network
|
|
361
|
+
* URL. KeployCapture refuses an explicit `maskNetworkBodies: false`
|
|
362
|
+
* beside strict (KUI_E_PRIVACY_CONFLICT) before it builds one of these;
|
|
363
|
+
* an engine built directly has no onError to say that to, so strict
|
|
364
|
+
* wins, which is the direction that cannot leak.
|
|
365
|
+
*/
|
|
366
|
+
constructor(config?: Partial<PrivacyConfig>, privacyMode?: CaptureConfig["privacyMode"]);
|
|
367
|
+
/** The merged config, with what strict mode forces. */
|
|
368
|
+
private settle;
|
|
9
369
|
/**
|
|
10
370
|
* Replace every occurrence of known PII patterns in `text` with
|
|
11
371
|
* `[REDACTED]`. Returns the scrubbed string.
|
|
@@ -14,23 +374,38 @@ export declare class PrivacyEngine {
|
|
|
14
374
|
/**
|
|
15
375
|
* Redact a URL without disturbing the parts that carry request identity.
|
|
16
376
|
*
|
|
17
|
-
*
|
|
18
|
-
* computed from, and rewriting it makes the
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
377
|
+
* By the one URL scrubber (maskQueryValues): the path is kept -- it is
|
|
378
|
+
* what the canonical key is computed from, and rewriting it makes the
|
|
379
|
+
* recording unreplayable -- but for a `;name=` parameter that names a
|
|
380
|
+
* credential (`;jsessionid=`), whose value goes.
|
|
381
|
+
* Query values are redacted by parameter NAME (the one rule, read as a
|
|
382
|
+
* `param`), and by nothing else: no regex, built-in or user-supplied,
|
|
383
|
+
* runs over a value. A pair is what follows a `&`, as the key reads one,
|
|
384
|
+
* and its whole value is replaced when anything in it is a credential's
|
|
385
|
+
* -- a `;name=` inside it, a URL nested or encoded in it -- so a redacted
|
|
386
|
+
* value is `[REDACTED]`, which canonical-key.v2's match rule matches any
|
|
387
|
+
* live value against; canonical-key.v1 drops only its own names from a
|
|
388
|
+
* key. The user info is dropped. Every other value and every name is
|
|
389
|
+
* kept, because they are part of identity too -- except under
|
|
390
|
+
* `privacyMode: "strict"`, which replaces every value. An earlier
|
|
391
|
+
* version of this method scanned every value (maskQueryValues records
|
|
392
|
+
* what that did to the key); this comment said so and outlived the fix.
|
|
26
393
|
*/
|
|
27
394
|
maskUrl(rawUrl: string): string;
|
|
28
395
|
/**
|
|
29
396
|
* Returns a deep-copy of the given {@link NetworkEvent} with sensitive
|
|
30
397
|
* headers redacted and (optionally) bodies masked.
|
|
31
398
|
*/
|
|
32
|
-
maskNetworkData(event: NetworkEvent): NetworkEvent;
|
|
399
|
+
maskNetworkData(event: NetworkEvent, bodies?: BodyOut): NetworkEvent;
|
|
400
|
+
/**
|
|
401
|
+
* The bodies of `event` to redact, with what their redaction reads (the
|
|
402
|
+
* content-types and the integrator's piiPatterns, which run on string
|
|
403
|
+
* values inside the structure, so JSON stays valid), or null when the
|
|
404
|
+
* config masks bodies whole and there is nothing to redact.
|
|
405
|
+
*/
|
|
406
|
+
bodyJob(event: NetworkEvent): BodyJob | null;
|
|
33
407
|
getConfig(): Readonly<PrivacyConfig>;
|
|
34
408
|
updateConfig(partial: Partial<PrivacyConfig>): void;
|
|
35
409
|
private maskHeaders;
|
|
36
410
|
}
|
|
411
|
+
export {};
|