@keploy/capture-sdk 3.2.0 → 3.3.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/README.md +36 -27
- package/dist/body-jobs.d.ts +2 -2
- package/dist/body-redact.js +1 -1
- package/dist/body-redact.js.map +1 -1
- package/dist/body-redact.mjs +1 -1
- package/dist/body-redact.mjs.map +1 -1
- package/dist/body-worker-none.js +1 -1
- package/dist/body-worker-none.js.map +1 -1
- package/dist/body-worker-none.mjs +1 -1
- package/dist/body-worker-none.mjs.map +1 -1
- package/dist/body-worker-start.js +1 -1
- package/dist/body-worker-start.js.map +1 -1
- package/dist/body-worker-start.mjs +1 -1
- package/dist/body-worker-start.mjs.map +1 -1
- package/dist/body-worker-unbundled.mjs +1 -1
- package/dist/body-worker-unbundled.mjs.map +1 -1
- package/dist/identity.d.ts +4 -4
- package/dist/index.bundler.mjs +1 -1
- package/dist/index.bundler.mjs.map +1 -1
- package/dist/index.d.ts +4 -5
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/network.d.ts +9 -9
- package/dist/privacy.d.ts +20 -26
- package/dist/recorder.d.ts +29 -25
- package/dist/request-term.js +1 -1
- package/dist/request-term.js.map +1 -1
- package/dist/request-term.mjs +1 -1
- package/dist/request-term.mjs.map +1 -1
- package/dist/strict-attributes.js +1 -1
- package/dist/strict-attributes.js.map +1 -1
- package/dist/strict-attributes.mjs +1 -1
- package/dist/strict-attributes.mjs.map +1 -1
- package/dist/transport.d.ts +16 -16
- package/dist/types.d.ts +8 -1
- package/package.json +2 -2
package/dist/network.d.ts
CHANGED
|
@@ -53,7 +53,7 @@ export declare class NetworkInterceptor {
|
|
|
53
53
|
private bodyCap;
|
|
54
54
|
/** Absolute URLs never observed — the SDK's own ingest endpoint. */
|
|
55
55
|
private ignoredUrls;
|
|
56
|
-
private
|
|
56
|
+
private netActive;
|
|
57
57
|
/**
|
|
58
58
|
* Exchanges answered while recording whose bodies are still being read
|
|
59
59
|
* for the recording, and events reported and still waiting for their
|
|
@@ -72,9 +72,9 @@ export declare class NetworkInterceptor {
|
|
|
72
72
|
* were reported, when the page leaves or the capture stops waiting
|
|
73
73
|
* (cutInflight).
|
|
74
74
|
*/
|
|
75
|
-
private
|
|
75
|
+
private netBodies;
|
|
76
76
|
/** Takes an event's place in the recording when it is reported (see start()). */
|
|
77
|
-
private
|
|
77
|
+
private seqPlace?;
|
|
78
78
|
/**
|
|
79
79
|
* Whether an exchange is recorded at all, asked at the exchange's OWN
|
|
80
80
|
* moments -- when its request leaves, and again when a fetch is
|
|
@@ -87,7 +87,7 @@ export declare class NetworkInterceptor {
|
|
|
87
87
|
*/
|
|
88
88
|
private admitCall;
|
|
89
89
|
/** Which start() an exchange belongs to: one from before a stop() never reports into a later start(). */
|
|
90
|
-
private
|
|
90
|
+
private netRun;
|
|
91
91
|
private originalFetch;
|
|
92
92
|
private originalXhrOpen;
|
|
93
93
|
private originalXhrSend;
|
|
@@ -153,9 +153,9 @@ export declare class NetworkInterceptor {
|
|
|
153
153
|
/** True while an exchange answered while recording is still reading its body for the recording. */
|
|
154
154
|
hasInflight(): boolean;
|
|
155
155
|
/** True when an exchange is recorded: asked when its request leaves and again when it ends. */
|
|
156
|
-
private
|
|
156
|
+
private netAdmits;
|
|
157
157
|
/** Track a pending recording until it has reported. */
|
|
158
|
-
private
|
|
158
|
+
private netTrack;
|
|
159
159
|
/**
|
|
160
160
|
* The Response the page gets for `response` (the network's own), and,
|
|
161
161
|
* through `report`, its body as recorded: as the page reads it, or
|
|
@@ -199,7 +199,7 @@ export declare class NetworkInterceptor {
|
|
|
199
199
|
* called once the cut is in place, so a body known at once (none, or one
|
|
200
200
|
* too large to read) reports into it.
|
|
201
201
|
*/
|
|
202
|
-
private
|
|
202
|
+
private netReport;
|
|
203
203
|
/** Whether this capture has said KUI_E_REQUEST_TERM_FAILED yet. */
|
|
204
204
|
private termWarned;
|
|
205
205
|
/**
|
|
@@ -225,7 +225,7 @@ export declare class NetworkInterceptor {
|
|
|
225
225
|
* of its text, where each one waiting on a load that hung kept it for
|
|
226
226
|
* the page's life.
|
|
227
227
|
*/
|
|
228
|
-
private
|
|
228
|
+
private netTerm;
|
|
229
229
|
private termFailed;
|
|
230
230
|
/**
|
|
231
231
|
* THE PAGE HAS ITS RESPONSE FIRST; IT IS RECORDED AFTER, AND ITS BODIES
|
|
@@ -253,7 +253,7 @@ export declare class NetworkInterceptor {
|
|
|
253
253
|
* record at once what the worker still holds, and a hidden tab and
|
|
254
254
|
* stop() what fits the main thread's budget (reportDue()).
|
|
255
255
|
*/
|
|
256
|
-
private
|
|
256
|
+
private netEmit;
|
|
257
257
|
}
|
|
258
258
|
/** Exposed for tests: the cut and the XHR body shape, without an XHR. */
|
|
259
259
|
export declare const __internals: {
|
package/dist/privacy.d.ts
CHANGED
|
@@ -94,13 +94,6 @@ interface Word {
|
|
|
94
94
|
lengths: Set<number>;
|
|
95
95
|
longest: number;
|
|
96
96
|
}
|
|
97
|
-
/**
|
|
98
|
-
* Every index `v` starts at in `s`, overlapping ones included, in time
|
|
99
|
-
* linear in both (Knuth-Morris-Pratt): an indexOf after each match that
|
|
100
|
-
* was not on a boundary read the same text again once per overlap, and a
|
|
101
|
-
* crafted link under the 64 KiB cap made start() take 789 ms and each
|
|
102
|
-
* replaceState 145 ms (MEASURED in review).
|
|
103
|
-
*/
|
|
104
97
|
export declare function indicesOf(s: string, v: string): number[];
|
|
105
98
|
/**
|
|
106
99
|
* What the scrub did, COUNTED rather than timed: the pieces wordAt decoded,
|
|
@@ -174,8 +167,8 @@ export declare function memoKey(how: string, s: string): string;
|
|
|
174
167
|
* reads every DOM event's JSON copy, in order, before it is scrubbed, and
|
|
175
168
|
* a full snapshot starts it over. rrweb's ids do NOT start over -- its
|
|
176
169
|
* mirror outlives a snapshot, and a node removed and added again keeps
|
|
177
|
-
* its id (MEASURED in review on rrweb 2.1.6
|
|
178
|
-
* afresh what a node is.
|
|
170
|
+
* its id (MEASURED in review on rrweb 2.1.6, still holds on 2.2.2) --
|
|
171
|
+
* which is why an add says afresh what a node is.
|
|
179
172
|
*/
|
|
180
173
|
/**
|
|
181
174
|
* What the page says of rrweb's node ids, for the styles' observer. A node
|
|
@@ -186,9 +179,11 @@ export declare function memoKey(how: string, s: string): string;
|
|
|
186
179
|
* observer of its own, it writes a <style> moved out of the frame into the
|
|
187
180
|
* page as the page's add and THEN the frame's remove, and on that remove
|
|
188
181
|
* deletes the id from its id-to-node map (removeNodeFromMap) although the
|
|
189
|
-
* node is in the page (MEASURED in Chromium with rrweb 2.1.6: the add,
|
|
190
|
-
*
|
|
191
|
-
* under its id
|
|
182
|
+
* node is in the page (MEASURED in Chromium with rrweb 2.1.6: the add, two
|
|
183
|
+
* removes naming the frame's head -- the frame's document observed twice
|
|
184
|
+
* -- then the style's next text added under its id; MEASURED in review on
|
|
185
|
+
* 2.2.2: the add, ONE remove, and the id gone from the map while the node
|
|
186
|
+
* is in the page).
|
|
192
187
|
*/
|
|
193
188
|
export interface NodePresence {
|
|
194
189
|
/** Keep the node `id` names now. */
|
|
@@ -199,11 +194,10 @@ export interface NodePresence {
|
|
|
199
194
|
forget(id: number): void;
|
|
200
195
|
}
|
|
201
196
|
export declare class StyleTexts {
|
|
202
|
-
private readonly page?;
|
|
203
197
|
/** Each style's text nodes, by the style's id. */
|
|
204
|
-
private readonly
|
|
198
|
+
private readonly stStyles;
|
|
205
199
|
/** Each style text node's style, by the text's id. */
|
|
206
|
-
private readonly
|
|
200
|
+
private readonly stTexts;
|
|
207
201
|
/**
|
|
208
202
|
* `present` says whether rrweb's node `id` is still in the page. rrweb
|
|
209
203
|
* writes a remove for the top of a removed subtree alone, so a style
|
|
@@ -219,9 +213,10 @@ export declare class StyleTexts {
|
|
|
219
213
|
* forgotten only when it is no longer in the page; without one -- no
|
|
220
214
|
* DOM to ask -- the remove says so, and nothing is pruned.
|
|
221
215
|
*/
|
|
222
|
-
|
|
216
|
+
private readonly privPage?;
|
|
217
|
+
constructor(privPage?: NodePresence);
|
|
223
218
|
/** `id` has left the page: as `page` says, or, with none, as the remove that names it does. */
|
|
224
|
-
private
|
|
219
|
+
private goneNodes;
|
|
225
220
|
/** How many ids are followed, a style's set of texts included: what a long session's churn must not grow. */
|
|
226
221
|
get size(): number;
|
|
227
222
|
private addText;
|
|
@@ -232,11 +227,11 @@ export declare class StyleTexts {
|
|
|
232
227
|
* and each add and remove of one left its text's id followed for the
|
|
233
228
|
* session (found in review: 2,000 ids after 2,000 cycles).
|
|
234
229
|
*/
|
|
235
|
-
private
|
|
230
|
+
private dropNode;
|
|
236
231
|
observe(event: unknown): void;
|
|
237
232
|
/** Stops following every id `present` says is gone: once per mutation that removes, over the ids followed. */
|
|
238
|
-
private
|
|
239
|
-
private
|
|
233
|
+
private pruneNodes;
|
|
234
|
+
private walkNodes;
|
|
240
235
|
/** The records in an event (one observe() read, or a copy of it) whose `textContent` or `value` is a style's text. */
|
|
241
236
|
recordsIn(event: unknown): Set<unknown>;
|
|
242
237
|
}
|
|
@@ -298,7 +293,7 @@ export declare function keepStrict(kept: typeof strictKept): void;
|
|
|
298
293
|
* A value that is not a string (a style object, a removed attribute's
|
|
299
294
|
* null) is left alone.
|
|
300
295
|
*/
|
|
301
|
-
export declare function scrubDomAttributes(attributes: Record<string, unknown>, strict: boolean, secrets?: readonly string[], tag?: string, svg?: boolean): void;
|
|
296
|
+
export declare function scrubDomAttributes(attributes: Record<string, unknown>, strict: boolean, secrets?: readonly string[], tag?: string, svg?: boolean, mask?: boolean): void;
|
|
302
297
|
/**
|
|
303
298
|
* The page's own text -- a text node in a snapshot or a node added after
|
|
304
299
|
* it, a text change, a value typed under `off` -- with each provider's
|
|
@@ -323,7 +318,7 @@ export declare function scrubDomCss(css: string, strict: boolean, secrets?: read
|
|
|
323
318
|
* batch, so it is read alone.
|
|
324
319
|
*/
|
|
325
320
|
export declare function scrubAddedTextRuns(adds: unknown[]): void;
|
|
326
|
-
export declare function scrubDomTree(root: unknown, strict: boolean, secrets?: readonly string[]): void;
|
|
321
|
+
export declare function scrubDomTree(root: unknown, strict: boolean, secrets?: readonly string[], masked?: (id: unknown) => boolean): void;
|
|
327
322
|
/**
|
|
328
323
|
* A URL as it may be recorded -- the page's own, after the page URL rule
|
|
329
324
|
* (recordedPageUrl), or one in the DOM: query and fragment-pair values
|
|
@@ -350,12 +345,11 @@ export declare const bodyCode: {
|
|
|
350
345
|
/** What a body masked whole is recorded as (maskNetworkData); one that was absent stays null. */
|
|
351
346
|
export declare const MASKED = "[MASKED]";
|
|
352
347
|
export declare class PrivacyEngine {
|
|
353
|
-
private
|
|
354
|
-
private builtinPatterns;
|
|
348
|
+
private privCfg;
|
|
355
349
|
/** The integrator's piiPatterns, compiled global once. */
|
|
356
350
|
private userPatterns;
|
|
357
351
|
/** `privacyMode: "strict"`: no body, and no query value, is recorded. */
|
|
358
|
-
private readonly
|
|
352
|
+
private readonly isStrict;
|
|
359
353
|
/**
|
|
360
354
|
* `privacyMode` is the capture's (CaptureConfig.privacyMode). Only
|
|
361
355
|
* `strict` changes what this engine does: it records no request or
|
|
@@ -368,7 +362,7 @@ export declare class PrivacyEngine {
|
|
|
368
362
|
*/
|
|
369
363
|
constructor(config?: Partial<PrivacyConfig>, privacyMode?: CaptureConfig["privacyMode"]);
|
|
370
364
|
/** The merged config, with what strict mode forces. */
|
|
371
|
-
private
|
|
365
|
+
private privSettle;
|
|
372
366
|
/**
|
|
373
367
|
* Replace every occurrence of known PII patterns in `text` with
|
|
374
368
|
* `[REDACTED]`. Returns the scrubbed string.
|
package/dist/recorder.d.ts
CHANGED
|
@@ -56,10 +56,11 @@ export type OnSessionEndCallback = () => void;
|
|
|
56
56
|
* characters the scrubbed event was certain to reach, and the cap.
|
|
57
57
|
*/
|
|
58
58
|
export type OnScrubOversizedCallback = (eventType: SessionEvent["type"], atLeast: number, cap: number) => void;
|
|
59
|
+
export declare const AUTH_URL: RegExp;
|
|
59
60
|
export declare class KeployCaptureRecorder {
|
|
60
|
-
private
|
|
61
|
+
private recPhase;
|
|
61
62
|
private userPaused;
|
|
62
|
-
private
|
|
63
|
+
private tabHidden;
|
|
63
64
|
private droppedWhileShut;
|
|
64
65
|
/**
|
|
65
66
|
* A DOM event was dropped while the gate was OPEN -- its scrub failed or
|
|
@@ -89,7 +90,7 @@ export declare class KeployCaptureRecorder {
|
|
|
89
90
|
/** How long the next retake after a dropped SNAPSHOT waits; see rebaseline(). */
|
|
90
91
|
private retakeDelay;
|
|
91
92
|
/** Uploads are failing (TransportConfig.onFailing): no snapshot is taken; see failing(). */
|
|
92
|
-
private
|
|
93
|
+
private inOutage;
|
|
93
94
|
/**
|
|
94
95
|
* UPLOADS FAIL, SO NOTHING IS RE-SERIALISED UNTIL ONE IS ACCEPTED AGAIN.
|
|
95
96
|
* Each DOM event the transport drops in an outage is a hole, and each
|
|
@@ -147,19 +148,19 @@ export declare class KeployCaptureRecorder {
|
|
|
147
148
|
*/
|
|
148
149
|
delivered(events: readonly SessionEvent[]): void;
|
|
149
150
|
/** Which of rrweb's text nodes are a <style>'s, so their text is scrubbed as CSS (StyleTexts). */
|
|
150
|
-
private readonly
|
|
151
|
+
private readonly recStyles;
|
|
151
152
|
/** The node of each id the styles' observer follows, kept from when it started (NodePresence). */
|
|
152
153
|
private readonly styleNodes;
|
|
153
|
-
private
|
|
154
|
-
private
|
|
155
|
-
private
|
|
156
|
-
private
|
|
154
|
+
private recSessId;
|
|
155
|
+
private sessionMeta;
|
|
156
|
+
private recCfg;
|
|
157
|
+
private recEmit;
|
|
157
158
|
private sessionEndCb;
|
|
158
159
|
private scrubOversizedCb;
|
|
159
160
|
/** Told how rrweb's import went once the network is back -- null when it landed; see startRRWeb(). */
|
|
160
161
|
private rrwebCb;
|
|
161
162
|
/** Whether rrweb's import, held by the page's leave, is still to land; see startRRWeb(). */
|
|
162
|
-
private
|
|
163
|
+
private rrwebLanding;
|
|
163
164
|
/** The `online` listener that retries rrweb's import; see startRRWeb(). */
|
|
164
165
|
private onlineRetry;
|
|
165
166
|
/** The timer that reads the browser's state while onlineRetry waits; see retryWhenOnline(). */
|
|
@@ -176,13 +177,18 @@ export declare class KeployCaptureRecorder {
|
|
|
176
177
|
* before yielding: a continuation of a superseded session does
|
|
177
178
|
* nothing. See startRRWeb().
|
|
178
179
|
*/
|
|
179
|
-
private
|
|
180
|
+
private recGen;
|
|
180
181
|
private sessionTimer;
|
|
181
182
|
private visibilityHandler;
|
|
182
183
|
private stopNavigation;
|
|
183
184
|
private lastHref;
|
|
184
185
|
/** location.href as the recorder last read it; see noticeUnheardMove(). */
|
|
185
186
|
private seenHref;
|
|
187
|
+
/** 0 = awaiting first Meta, 1 = network arrived before first Meta, 2 = first Meta seen. */
|
|
188
|
+
private bootMeta;
|
|
189
|
+
private recMaskSel;
|
|
190
|
+
/** First interaction timestamp (ms), 0 before any interaction, -1 after auth navigation. */
|
|
191
|
+
actAt: number;
|
|
186
192
|
constructor(config: CaptureConfig);
|
|
187
193
|
/**
|
|
188
194
|
* Start recording. Resolves to the session id, or "" when sampleRate
|
|
@@ -218,7 +224,7 @@ export declare class KeployCaptureRecorder {
|
|
|
218
224
|
stopDom(): void;
|
|
219
225
|
stop(): void;
|
|
220
226
|
/** A same-document navigation, recorded as rrweb records a load: a Meta event. */
|
|
221
|
-
private
|
|
227
|
+
private onNavMove;
|
|
222
228
|
/** rrweb's events on their way to emitEvent, a Meta event's href recorded as the page URL. */
|
|
223
229
|
private recordedRRWebEvent;
|
|
224
230
|
/** Whether pause() closed the gate; a hidden tab does not count. */
|
|
@@ -288,14 +294,8 @@ export declare class KeployCaptureRecorder {
|
|
|
288
294
|
* start this wait over.)
|
|
289
295
|
*/
|
|
290
296
|
private retryWhenOnline;
|
|
291
|
-
/**
|
|
292
|
-
* The ONE reaction on rrweb's held import (by mode): each recorder still
|
|
293
|
-
* landing as it lands is told. Static, so it holds none of them: a
|
|
294
|
-
* recorder stopped meanwhile has left the set.
|
|
295
|
-
*/
|
|
296
|
-
private static whenLanded;
|
|
297
297
|
/** rrweb lands later, its owner told then (awaitingRRWeb): the request is free again. */
|
|
298
|
-
private
|
|
298
|
+
private parkRrweb;
|
|
299
299
|
/** How the import went after start() (back online, or a leave's hold ended): refused, or recorded now or when the DOM gate next opens, its owner told. */
|
|
300
300
|
private loadedLate;
|
|
301
301
|
/** Ends the timer retryWhenOnline() started, if it is still running. */
|
|
@@ -315,7 +315,7 @@ export declare class KeployCaptureRecorder {
|
|
|
315
315
|
*/
|
|
316
316
|
private landedBeforeTheRetry;
|
|
317
317
|
/** Whether what the recorder loads -- rrweb, and under strict its allow-list -- has loaded in this document. */
|
|
318
|
-
private
|
|
318
|
+
private rrwebLoaded;
|
|
319
319
|
/** Whether rrweb's import waits for the network, or for a leave's hold to end: onRRWeb says how it went. */
|
|
320
320
|
awaitingRRWeb(): boolean;
|
|
321
321
|
private rrwebOptions;
|
|
@@ -324,11 +324,15 @@ export declare class KeployCaptureRecorder {
|
|
|
324
324
|
* styles' observer started following it (rrweb's mirror forgets the id
|
|
325
325
|
* of a node moved out of a frame into the page; NodePresence), else the
|
|
326
326
|
* one rrweb's mirror has, connected, and -- in a frame -- in a frame
|
|
327
|
-
* that is itself still in the page, up to the top.
|
|
328
|
-
* host's
|
|
329
|
-
*
|
|
330
|
-
*
|
|
331
|
-
*
|
|
327
|
+
* that is itself still in the page, up to the top. On rrweb 2.2.2 a
|
|
328
|
+
* detached shadow host's shadow root leaves the mirror
|
|
329
|
+
* (Mirror.removeNodeFromMap) and a removed frame's nodes leave the
|
|
330
|
+
* mirror at its pagehide (MEASURED: getNode is null after
|
|
331
|
+
* frame.remove() on 2.2.2, still the node on 2.1.6), while their
|
|
332
|
+
* isConnected stays true; the frame walk is therefore still needed for
|
|
333
|
+
* direct node references held in styleNodes. Asked by the styles'
|
|
334
|
+
* observer after a mutation that removes nodes; with no rrweb, nothing
|
|
335
|
+
* is pruned.
|
|
332
336
|
*/
|
|
333
337
|
private inPage;
|
|
334
338
|
/**
|
|
@@ -359,7 +363,7 @@ export declare class KeployCaptureRecorder {
|
|
|
359
363
|
* ids. Used for the session's URL and referrer and for every Meta
|
|
360
364
|
* event's href, rrweb's and this recorder's.
|
|
361
365
|
*/
|
|
362
|
-
private
|
|
366
|
+
private recScrubUrl;
|
|
363
367
|
/**
|
|
364
368
|
* The URLs in an rrweb event's DOM, scrubbed: every URL-valued
|
|
365
369
|
* attribute in a full snapshot (type 2), and in a mutation (type 3,
|
package/dist/request-term.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";function e(e,t){return null!==e&&"object"==typeof e&&!Array.isArray(e)&&Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0}function t(t){let r;try{r=t?JSON.parse(t):null}catch{return""}if(null===r||"object"!=typeof r||Array.isArray(r))return"";let n=Object.keys(r);if(!n.length||n.some(e=>!g.includes(e)))return"";let l=e(r,"operationName"),u=e(r,"query");if(null!=l&&("string"!=typeof l||!y.test(l))||null!=u&&"string"!=typeof u)return"";let o=l??"",i=e(e(e(r,"extensions"),"persistedQuery"),"sha256Hash");if("string"==typeof i&&/^[0-9A-Fa-f]{64}$/.test(i))return`graphql:${o}#pq`;let s="string"==typeof u?function(e){let t=[],r=[];for(h.lastIndex=0;h.lastIndex<e.length;){let n=h.exec(e);if(!n||n[3])return null;n[1]||(t.push(n[2]||n[4]?'""':n[7]?"0":n[0]),r.push(!!n[6]))}let n=[];for(let e=0;e<t.length;e++){let l=t[e],u="{([".indexOf(l);if(-1!==u){if(n.push("})]"[u]),!u&&!r[e+1]&&"..."!==t[e+1]&&"}"!==t[e+1])return null}else if("})]".includes(l)&&1===l.length&&n.pop()!==l)return null}return d.includes(t[0])&&"}"===t[t.length-1]&&!n.length?t.join(" "):null}(u):null;return null===s?"":[o,s]}async function r([e,t],r){let n=new Uint8Array(await r.digest("SHA-256",(new TextEncoder).encode(t))),l="";for(let e=0;e<8;e++)l+=n[e].toString(16).padStart(2,"0");return`graphql:${e}#${l}`}async function n(e,n){let l=t(e);return"string"==typeof l?l:r(l,n)}function l(e,n){let l=function(e){return null==e||""===e?"":"string"==typeof e?e.length>4194304?"body:*":function(e){return c.test(e)&&(e.includes('"query"')||e.includes("persistedQuery")||e.includes("\\u"))}(e)?null:"":e instanceof URLSearchParams||typeof FormData<"u"&&e instanceof FormData?"":"body:*"}(e);if(null!==l)return l;let u=t(e);return"string"==typeof u?u:n?r(u,n):"body:*"}var u,o=Object.defineProperty,i=Object.getOwnPropertyDescriptor,s=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,f={};((e,t)=>{for(var r in t)o(e,r,{get:t[r],enumerable:!0})})(f,{recordTermFor:()=>l,requestTerm:()=>n,version:()=>p});module.exports=(u=f,((e,t,r,n)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let r of s(t))!a.call(e,r)&&void 0!==r&&o(e,r,{get:()=>t[r],enumerable:!(n=i(t,r))||n.enumerable});return e})(o({},"__esModule",{value:!0}),u));var c=/^[\t\n\r ]*\{/,p="3.
|
|
1
|
+
"use strict";function e(e,t){return null!==e&&"object"==typeof e&&!Array.isArray(e)&&Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0}function t(t){let r;try{r=t?JSON.parse(t):null}catch{return""}if(null===r||"object"!=typeof r||Array.isArray(r))return"";let n=Object.keys(r);if(!n.length||n.some(e=>!g.includes(e)))return"";let l=e(r,"operationName"),u=e(r,"query");if(null!=l&&("string"!=typeof l||!y.test(l))||null!=u&&"string"!=typeof u)return"";let o=l??"",i=e(e(e(r,"extensions"),"persistedQuery"),"sha256Hash");if("string"==typeof i&&/^[0-9A-Fa-f]{64}$/.test(i))return`graphql:${o}#pq`;let s="string"==typeof u?function(e){let t=[],r=[];for(h.lastIndex=0;h.lastIndex<e.length;){let n=h.exec(e);if(!n||n[3])return null;n[1]||(t.push(n[2]||n[4]?'""':n[7]?"0":n[0]),r.push(!!n[6]))}let n=[];for(let e=0;e<t.length;e++){let l=t[e],u="{([".indexOf(l);if(-1!==u){if(n.push("})]"[u]),!u&&!r[e+1]&&"..."!==t[e+1]&&"}"!==t[e+1])return null}else if("})]".includes(l)&&1===l.length&&n.pop()!==l)return null}return d.includes(t[0])&&"}"===t[t.length-1]&&!n.length?t.join(" "):null}(u):null;return null===s?"":[o,s]}async function r([e,t],r){let n=new Uint8Array(await r.digest("SHA-256",(new TextEncoder).encode(t))),l="";for(let e=0;e<8;e++)l+=n[e].toString(16).padStart(2,"0");return`graphql:${e}#${l}`}async function n(e,n){let l=t(e);return"string"==typeof l?l:r(l,n)}function l(e,n){let l=function(e){return null==e||""===e?"":"string"==typeof e?e.length>4194304?"body:*":function(e){return c.test(e)&&(e.includes('"query"')||e.includes("persistedQuery")||e.includes("\\u"))}(e)?null:"":e instanceof URLSearchParams||typeof FormData<"u"&&e instanceof FormData?"":"body:*"}(e);if(null!==l)return l;let u=t(e);return"string"==typeof u?u:n?r(u,n):"body:*"}var u,o=Object.defineProperty,i=Object.getOwnPropertyDescriptor,s=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,f={};((e,t)=>{for(var r in t)o(e,r,{get:t[r],enumerable:!0})})(f,{recordTermFor:()=>l,requestTerm:()=>n,version:()=>p});module.exports=(u=f,((e,t,r,n)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let r of s(t))!a.call(e,r)&&void 0!==r&&o(e,r,{get:()=>t[r],enumerable:!(n=i(t,r))||n.enumerable});return e})(o({},"__esModule",{value:!0}),u));var c=/^[\t\n\r ]*\{/,p="3.3.0",y=/^[_A-Za-z]\w*$/,d=["{","query","mutation","subscription","fragment"],g=["query","operationName","variables","extensions"],h=/([\t\n\r ,\uFEFF]+|#[^\n\r]*)|("""[^"\\]*(?:(?:\\"""|\\(?!""")|"(?!""))[^"\\]*)*""")|(""")|("[^"\\]*(?:\\[^][^"\\]*)*")|(\.\.\.|[!$&()[\]{}:=@|])|([_A-Za-z]\w*)|([0-9-](?:(?!\.\.\.)[^\t\n\r ,\uFEFF!$&()[\]{}:=@|"#])*)|((?:(?!\.\.\.)[^\t\n\r ,\uFEFF!$&()[\]{}:=@|"#\w-])+)/y;//# sourceMappingURL=request-term.js.map
|
package/dist/request-term.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/request-term.ts","../src/term-candidate.ts","../package.json"],"names":["own","o","k","Array","isArray","Object","prototype","hasOwnProperty","call","prepare","body","v","JSON","parse","keys","length","some","key","MEMBERS","includes","name","query","NAME","test","n","hash","text","doc","out","LEXEME","lastIndex","m","exec","push","open","t","at","indexOf","pop","STARTS","join","normalise","async","hashed","subtle","digest","Uint8Array","TextEncoder","encode","hex","toString","padStart","requestTerm","p","recordTermFor","known","OBJECT_START","couldBeGraphql","URLSearchParams","FormData","termBeforeLoad","request_term_exports","__export","version","module","exports"],"mappings":"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","sourcesContent":["/* ------------------------------------------------------------------ */\n/* @keploy/capture-sdk - request term (canonical-key.v2) */\n/* ------------------------------------------------------------------ */\n/*\n * The term spec/canonical-key.v2.json keys a GraphQL request by:\n * \"graphql:<operationName>#<documentId>\", or \"\" when the body is not a\n * GraphQL request. Executed against that file's `term` vectors by\n * __tests__/request-term.test.ts.\n *\n * It is computed HERE, over the RAW body, before redaction, masking or\n * truncation touch it: the stored body may have had a PII pattern\n * redacted inside the document, may be \"[MASKED]\" (strict mode) or may\n * be cut at maxBodySize, and a term derived from it would be wrong or\n * missing. An operation name and a document hash are not user data:\n * every literal (string, block string, number) is blanked before\n * hashing, so input inlined into a document never reaches the hash, and\n * a persisted query's own hash is never recorded.\n *\n * The replay runtime holds a second implementation (packages/replay-\n * runtime/src/canonkey.ts, `graphqlTerm`) held to the same vectors: this\n * package is public and dependency-free, that one is private, and\n * neither may depend on the other. No GraphQL parser: one sticky regex\n * cuts the lexemes, which keeps the code the page downloads small.\n *\n * THIS FILE IS A CHUNK OF ITS OWN (dist/request-term.{mjs,js}, the\n * package's \"./request-term\" export), which network.ts loads the first\n * time a body could be a GraphQL request (term-candidate.ts), and never\n * for a page that sends none. It imports nothing but term-candidate.ts,\n * and nothing in the main bundle imports it but by that name:\n * __tests__/bundle-size.test.ts fails when its lexer is in\n * dist/index.{mjs,js}.\n */\n\nimport { termBeforeLoad } from \"./term-candidate\";\n/** The version this chunk was built as: the SDK refuses one of another (module-of.ts ownChunk). */\nexport { version } from \"../package.json\";\n\nconst NAME = /^[_A-Za-z]\\w*$/;\nconst STARTS = [\"{\", \"query\", \"mutation\", \"subscription\", \"fragment\"];\nconst MEMBERS = [\"query\", \"operationName\", \"variables\", \"extensions\"];\n\n/*\n * One lexeme per match, by the spec's rules.normalisation, in groups:\n * 1 ignored tokens (dropped) 2 a block string 3 an\n * unterminated block string 4 a string 5 a punctuator\n * 6 a NAME run 7 a NUMBER run 8 any other run\n * Anything no alternative matches (an unterminated string) fails the\n * scan. Sticky (y), so a lexeme can only start where the last one ended.\n * Both string alternatives are UNROLLED (a run of plain characters, then\n * one escape or quote at a time), so a long literal is a simple loop and\n * never a backtrack frame per character; and a block string's escaped\n * \\\"\"\" can only be read as the escape -- were its backslash content, the\n * regex would backtrack into it and close a block string the spec says\n * is unterminated.\n */\nconst LEXEME =\n /([\\t\\n\\r ,\\uFEFF]+|#[^\\n\\r]*)|(\"\"\"[^\"\\\\]*(?:(?:\\\\\"\"\"|\\\\(?!\"\"\")|\"(?!\"\"))[^\"\\\\]*)*\"\"\")|(\"\"\")|(\"[^\"\\\\]*(?:\\\\[^][^\"\\\\]*)*\")|(\\.\\.\\.|[!$&()[\\]{}:=@|])|([_A-Za-z]\\w*)|([0-9-](?:(?!\\.\\.\\.)[^\\t\\n\\r ,\\uFEFF!$&()[\\]{}:=@|\"#])*)|((?:(?!\\.\\.\\.)[^\\t\\n\\r ,\\uFEFF!$&()[\\]{}:=@|\"#\\w-])+)/y;\n\n/**\n * The normalised text of a GraphQL document -- lexemes joined by one\n * space, every string blanked to \"\" and every number to 0 -- or null\n * when the text is not a GraphQL document.\n */\nfunction normalise(doc: string): string | null {\n const out: string[] = [];\n const name: boolean[] = [];\n LEXEME.lastIndex = 0;\n while (LEXEME.lastIndex < doc.length) {\n const m = LEXEME.exec(doc);\n if (!m || m[3]) return null;\n if (m[1]) continue;\n out.push(m[2] || m[4] ? '\"\"' : m[7] ? \"0\" : m[0]);\n name.push(!!m[6]);\n }\n // Every opener closes in order; every { opens a selection: a name,\n // '...' or } follows it. A string is \"\" here and a number 0, so no\n // literal can pass for a punctuator or a keyword.\n const open: string[] = [];\n for (let k = 0; k < out.length; k++) {\n const t = out[k] as string;\n const at = \"{([\".indexOf(t);\n if (at !== -1) {\n open.push(\"})]\"[at] as string);\n if (!at && !(name[k + 1] || out[k + 1] === \"...\" || out[k + 1] === \"}\"))\n return null;\n } else if (\"})]\".includes(t) && t.length === 1 && open.pop() !== t)\n return null;\n }\n return STARTS.includes(out[0] as string) &&\n out[out.length - 1] === \"}\" &&\n !open.length\n ? out.join(\" \")\n : null;\n}\n\nfunction own(o: unknown, k: string): unknown {\n return o !== null &&\n typeof o === \"object\" &&\n !Array.isArray(o) &&\n Object.prototype.hasOwnProperty.call(o, k)\n ? (o as Record<string, unknown>)[k]\n : undefined;\n}\n\n/**\n * Everything of the term that needs no hash: \"\" (not a GraphQL request),\n * \"graphql:<name>#pq\" (a persisted query), or [name, normalised text]\n * still to be hashed.\n */\nfunction prepare(body: string | null | undefined): string | [string, string] {\n let v: unknown;\n try {\n v = body ? JSON.parse(body) : null;\n } catch {\n return \"\";\n }\n if (v === null || typeof v !== \"object\" || Array.isArray(v)) return \"\";\n const keys = Object.keys(v);\n if (!keys.length || keys.some((key) => !MEMBERS.includes(key))) return \"\";\n const name = own(v, \"operationName\");\n const query = own(v, \"query\");\n if (name != null && (typeof name !== \"string\" || !NAME.test(name))) return \"\";\n if (query != null && typeof query !== \"string\") return \"\";\n const n = (name as string | null | undefined) ?? \"\";\n const hash = own(own(own(v, \"extensions\"), \"persistedQuery\"), \"sha256Hash\");\n if (typeof hash === \"string\" && /^[0-9A-Fa-f]{64}$/.test(hash))\n return `graphql:${n}#pq`;\n const text = typeof query === \"string\" ? normalise(query) : null;\n return text === null ? \"\" : [n, text];\n}\n\n/** The term of a prepared document: its name and 16 hex of SHA-256. */\nasync function hashed(\n [name, text]: [string, string],\n subtle: SubtleCrypto,\n): Promise<string> {\n const digest = new Uint8Array(\n await subtle.digest(\"SHA-256\", new TextEncoder().encode(text)),\n );\n let hex = \"\";\n for (let k = 0; k < 8; k++)\n hex += (digest[k] as number).toString(16).padStart(2, \"0\");\n return `graphql:${name}#${hex}`;\n}\n\n/**\n * The request term of a raw body: \"\" or \"graphql:<name>#<documentId>\".\n * `subtle` hashes the document (SHA-256).\n */\nexport async function requestTerm(\n body: string | null | undefined,\n subtle: SubtleCrypto,\n): Promise<string> {\n const p = prepare(body);\n return typeof p === \"string\" ? p : hashed(p, subtle);\n}\n\n/**\n * The requestTerm to record for a body AS THE APP HANDED IT to fetch or\n * XHR -- before redaction, masking or truncation touch it. Known at once\n * unless a document has to be hashed; only then a Promise. What needs no\n * term code (no body, a form, a body that is not text or is longer than\n * MAX_TERM_BODY, text that cannot be a GraphQL request) is\n * termBeforeLoad()'s, which the interceptor asks before it loads this\n * chunk. Where the page has no SubtleCrypto (an insecure context) a\n * GraphQL document cannot be hashed and is \"body:*\", and every other term\n * needs no hash: the recording is still a canonical-key.v2 document,\n * whose redacted values match as wildcards (spec/canonical-key.v2.json\n * rules.record). It may throw or reject: the interceptor's termFor() is\n * the one place that turns any failure into \"no term\", so nothing here\n * can reach the page.\n */\nexport function recordTermFor(\n body: unknown,\n subtle: SubtleCrypto | undefined,\n): string | Promise<string> {\n const known = termBeforeLoad(body);\n if (known !== null) return known;\n const p = prepare(body as string);\n if (typeof p === \"string\") return p;\n return subtle ? hashed(p, subtle) : \"body:*\";\n}\n","/* ------------------------------------------------------------------ */\n/* @keploy/capture-sdk - could a body be a GraphQL request? */\n/* ------------------------------------------------------------------ */\n/*\n * The term code (request-term.ts: the lexer, the document check, the\n * hash) is a chunk of its own, loaded only for a body that passes\n * couldBeGraphql(); every other body is recorded here, at once, and the\n * chunk is never fetched. So the check must be a SUPERSET of what the\n * term code gives a term: a GraphQL body it missed would be recorded ''\n * while replay computes its term from postData(), and the keys would\n * differ.\n *\n * DERIVED FROM THE TERM CODE'S OWN ENTRY CONDITIONS (spec/canonical-\n * key.v2.json rules.term and rules.document; request-term.ts prepare()),\n * not from examples. A body has a term only when:\n * 1. it parses as ONE JSON value with nothing but JSON's whitespace\n * (U+0020, U+0009, U+000A, U+000D) before it -- a byte order mark\n * is refused -- and that value is an OBJECT, so the first character\n * that is not JSON whitespace is `{`; and\n * 2. it has a documentId, which needs a member named `query` (a string\n * that is a document) or a member named `persistedQuery` (inside\n * `extensions`). A member name is a JSON string: written with no\n * escape it is exactly `\"query\"`, quotes included, or holds\n * `persistedQuery`; written with any escape it holds `\\u`, the only\n * JSON escape that yields a letter.\n * So a batch (`[...]`), a raw application/graphql document (`{ me { id\n * } }`, `query Q { ... }`), a form and plain text have no term on either\n * side, and a GET has no body to read (the live term is\n * term(request.postData())). __tests__/term-candidate.test.ts runs every\n * term vector and every e2e GraphQL body through the check.\n */\n\n/** Longer bodies (UTF-16 units) are recorded \"body:*\": bounded work, and no literal long enough to strain a regex engine. */\nexport const MAX_TERM_BODY = 4 * 1024 * 1024;\n\n/** Text that starts as a JSON object does: JSON whitespace, then `{` (condition 1 above). */\nexport const OBJECT_START = /^[\\t\\n\\r ]*\\{/;\n\n/** The first character that is not JSON whitespace. */\nexport const NOT_SPACE = /[^\\t\\n\\r ]/;\n\n/** True when `text` could be a body the term code gives a term (see above). */\nexport function couldBeGraphql(text: string): boolean {\n return (\n OBJECT_START.test(text) &&\n (text.includes('\"query\"') ||\n text.includes(\"persistedQuery\") ||\n text.includes(\"\\\\u\"))\n );\n}\n\n/**\n * The requestTerm of a body AS THE APP HANDED IT to fetch or XHR when it\n * needs no term code: '' for no body, a form, or text that cannot be a\n * GraphQL request; \"body:*\" for a body that is not text (a Blob, a\n * buffer, a stream, a Document) or is longer than MAX_TERM_BODY. null\n * when the body could be a GraphQL request: the term code decides it.\n */\nexport function termBeforeLoad(body: unknown): string | null {\n if (body == null || body === \"\") return \"\";\n if (typeof body === \"string\")\n return body.length > MAX_TERM_BODY\n ? \"body:*\"\n : couldBeGraphql(body)\n ? null\n : \"\";\n // Sent as form text, which is never a JSON object.\n if (\n body instanceof URLSearchParams ||\n (typeof FormData !== \"undefined\" && body instanceof FormData)\n )\n return \"\";\n return \"body:*\";\n}\n","{\n \"name\": \"@keploy/capture-sdk\",\n \"version\": \"3.2.0\",\n \"description\": \"Lightweight SDK to capture UI flows from real users - DOM recording, network interception, PII masking\",\n \"homepage\": \"https://keploy.io/docs/running-keploy/ui-capture/\",\n \"main\": \"dist/index.js\",\n \"module\": \"dist/index.bundler.mjs\",\n \"unpkg\": \"dist/index.mjs\",\n \"jsdelivr\": \"dist/index.mjs\",\n \"types\": \"dist/index.d.ts\",\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.mjs\",\n \"require\": \"./dist/index.js\"\n },\n \"./request-term\": {\n \"types\": \"./dist/request-term.d.ts\",\n \"import\": \"./dist/request-term.mjs\",\n \"require\": \"./dist/request-term.js\"\n },\n \"./strict-attributes\": {\n \"types\": \"./dist/strict-attributes.d.ts\",\n \"import\": \"./dist/strict-attributes.mjs\",\n \"require\": \"./dist/strict-attributes.js\"\n },\n \"./body-redact\": {\n \"types\": \"./dist/body-redact.d.ts\",\n \"import\": \"./dist/body-redact.mjs\",\n \"require\": \"./dist/body-redact.js\"\n },\n \"./body-worker-start\": {\n \"types\": \"./dist/body-worker-start.d.ts\",\n \"import\": \"./dist/body-worker-start.mjs\",\n \"require\": \"./dist/body-worker-start.js\"\n },\n \"./package.json\": \"./package.json\"\n },\n \"files\": [\n \"dist\",\n \"request-term/package.json\",\n \"strict-attributes/package.json\",\n \"body-redact/package.json\",\n \"body-worker-start/package.json\",\n \"LICENSE\",\n \"README.md\"\n ],\n \"scripts\": {\n \"build\": \"node scripts/build-main.mjs && node scripts/build-worker.mjs && tsc -p tsconfig.build.json\",\n \"dev\": \"node scripts/build-main.mjs --watch\",\n \"test\": \"vitest run\",\n \"clean\": \"rm -rf dist\",\n \"typecheck\": \"tsc --noEmit\",\n \"prepublishOnly\": \"pnpm run clean && turbo run build --filter=@keploy/capture-sdk --force && node ../../tools/check-release-size.mjs\"\n },\n \"dependencies\": {\n \"rrweb\": \"^2.1.6\"\n },\n \"devDependencies\": {\n \"@keploy/contract\": \"workspace:*\",\n \"@types/node\": \"~24.13.5\",\n \"jsdom\": \"^30.1.0\",\n \"terser\": \"5.51.2\",\n \"tsup\": \"^8.3.0\",\n \"typescript\": \"^7.0.2\",\n \"vitest\": \"^5.0.1\"\n },\n \"peerDependencies\": {},\n \"keywords\": [\n \"keploy\",\n \"ui-testing\",\n \"session-recording\",\n \"e2e\",\n \"capture\"\n ],\n \"browser\": {\n \"./dist/body-worker-unbundled.mjs\": \"./dist/body-worker-none.mjs\"\n },\n \"alias\": {\n \"@keploy/capture-sdk/body-worker-start\": \"./dist/body-worker-start.mjs\"\n },\n \"license\": \"Apache-2.0\",\n \"publishConfig\": {\n \"access\": \"public\"\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/request-term.ts","../src/term-candidate.ts","../package.json"],"names":["own","o","k","Array","isArray","Object","prototype","hasOwnProperty","call","prepare","body","v","JSON","parse","keys","length","some","key","MEMBERS","includes","name","query","NAME","test","n","hash","text","doc","out","LEXEME","lastIndex","m","exec","push","open","t","at","indexOf","pop","STARTS","join","normalise","async","hashed","subtle","digest","Uint8Array","TextEncoder","encode","hex","toString","padStart","requestTerm","p","recordTermFor","known","OBJECT_START","couldBeGraphql","URLSearchParams","FormData","termBeforeLoad","request_term_exports","__export","version","module","exports"],"mappings":"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","sourcesContent":["/* ------------------------------------------------------------------ */\n/* @keploy/capture-sdk - request term (canonical-key.v2) */\n/* ------------------------------------------------------------------ */\n/*\n * The term spec/canonical-key.v2.json keys a GraphQL request by:\n * \"graphql:<operationName>#<documentId>\", or \"\" when the body is not a\n * GraphQL request. Executed against that file's `term` vectors by\n * __tests__/request-term.test.ts.\n *\n * It is computed HERE, over the RAW body, before redaction, masking or\n * truncation touch it: the stored body may have had a PII pattern\n * redacted inside the document, may be \"[MASKED]\" (strict mode) or may\n * be cut at maxBodySize, and a term derived from it would be wrong or\n * missing. An operation name and a document hash are not user data:\n * every literal (string, block string, number) is blanked before\n * hashing, so input inlined into a document never reaches the hash, and\n * a persisted query's own hash is never recorded.\n *\n * The replay runtime holds a second implementation (packages/replay-\n * runtime/src/canonkey.ts, `graphqlTerm`) held to the same vectors: this\n * package is public and dependency-free, that one is private, and\n * neither may depend on the other. No GraphQL parser: one sticky regex\n * cuts the lexemes, which keeps the code the page downloads small.\n *\n * THIS FILE IS A CHUNK OF ITS OWN (dist/request-term.{mjs,js}, the\n * package's \"./request-term\" export), which network.ts loads the first\n * time a body could be a GraphQL request (term-candidate.ts), and never\n * for a page that sends none. It imports nothing but term-candidate.ts,\n * and nothing in the main bundle imports it but by that name:\n * __tests__/bundle-size.test.ts fails when its lexer is in\n * dist/index.{mjs,js}.\n */\n\nimport { termBeforeLoad } from \"./term-candidate\";\n/** The version this chunk was built as: the SDK refuses one of another (module-of.ts ownChunk). */\nexport { version } from \"../package.json\";\n\nconst NAME = /^[_A-Za-z]\\w*$/;\nconst STARTS = [\"{\", \"query\", \"mutation\", \"subscription\", \"fragment\"];\nconst MEMBERS = [\"query\", \"operationName\", \"variables\", \"extensions\"];\n\n/*\n * One lexeme per match, by the spec's rules.normalisation, in groups:\n * 1 ignored tokens (dropped) 2 a block string 3 an\n * unterminated block string 4 a string 5 a punctuator\n * 6 a NAME run 7 a NUMBER run 8 any other run\n * Anything no alternative matches (an unterminated string) fails the\n * scan. Sticky (y), so a lexeme can only start where the last one ended.\n * Both string alternatives are UNROLLED (a run of plain characters, then\n * one escape or quote at a time), so a long literal is a simple loop and\n * never a backtrack frame per character; and a block string's escaped\n * \\\"\"\" can only be read as the escape -- were its backslash content, the\n * regex would backtrack into it and close a block string the spec says\n * is unterminated.\n */\nconst LEXEME =\n /([\\t\\n\\r ,\\uFEFF]+|#[^\\n\\r]*)|(\"\"\"[^\"\\\\]*(?:(?:\\\\\"\"\"|\\\\(?!\"\"\")|\"(?!\"\"))[^\"\\\\]*)*\"\"\")|(\"\"\")|(\"[^\"\\\\]*(?:\\\\[^][^\"\\\\]*)*\")|(\\.\\.\\.|[!$&()[\\]{}:=@|])|([_A-Za-z]\\w*)|([0-9-](?:(?!\\.\\.\\.)[^\\t\\n\\r ,\\uFEFF!$&()[\\]{}:=@|\"#])*)|((?:(?!\\.\\.\\.)[^\\t\\n\\r ,\\uFEFF!$&()[\\]{}:=@|\"#\\w-])+)/y;\n\n/**\n * The normalised text of a GraphQL document -- lexemes joined by one\n * space, every string blanked to \"\" and every number to 0 -- or null\n * when the text is not a GraphQL document.\n */\nfunction normalise(doc: string): string | null {\n const out: string[] = [];\n const name: boolean[] = [];\n LEXEME.lastIndex = 0;\n while (LEXEME.lastIndex < doc.length) {\n const m = LEXEME.exec(doc);\n if (!m || m[3]) return null;\n if (m[1]) continue;\n out.push(m[2] || m[4] ? '\"\"' : m[7] ? \"0\" : m[0]);\n name.push(!!m[6]);\n }\n // Every opener closes in order; every { opens a selection: a name,\n // '...' or } follows it. A string is \"\" here and a number 0, so no\n // literal can pass for a punctuator or a keyword.\n const open: string[] = [];\n for (let k = 0; k < out.length; k++) {\n const t = out[k] as string;\n const at = \"{([\".indexOf(t);\n if (at !== -1) {\n open.push(\"})]\"[at] as string);\n if (!at && !(name[k + 1] || out[k + 1] === \"...\" || out[k + 1] === \"}\"))\n return null;\n } else if (\"})]\".includes(t) && t.length === 1 && open.pop() !== t)\n return null;\n }\n return STARTS.includes(out[0] as string) &&\n out[out.length - 1] === \"}\" &&\n !open.length\n ? out.join(\" \")\n : null;\n}\n\nfunction own(o: unknown, k: string): unknown {\n return o !== null &&\n typeof o === \"object\" &&\n !Array.isArray(o) &&\n Object.prototype.hasOwnProperty.call(o, k)\n ? (o as Record<string, unknown>)[k]\n : undefined;\n}\n\n/**\n * Everything of the term that needs no hash: \"\" (not a GraphQL request),\n * \"graphql:<name>#pq\" (a persisted query), or [name, normalised text]\n * still to be hashed.\n */\nfunction prepare(body: string | null | undefined): string | [string, string] {\n let v: unknown;\n try {\n v = body ? JSON.parse(body) : null;\n } catch {\n return \"\";\n }\n if (v === null || typeof v !== \"object\" || Array.isArray(v)) return \"\";\n const keys = Object.keys(v);\n if (!keys.length || keys.some((key) => !MEMBERS.includes(key))) return \"\";\n const name = own(v, \"operationName\");\n const query = own(v, \"query\");\n if (name != null && (typeof name !== \"string\" || !NAME.test(name))) return \"\";\n if (query != null && typeof query !== \"string\") return \"\";\n const n = (name as string | null | undefined) ?? \"\";\n const hash = own(own(own(v, \"extensions\"), \"persistedQuery\"), \"sha256Hash\");\n if (typeof hash === \"string\" && /^[0-9A-Fa-f]{64}$/.test(hash))\n return `graphql:${n}#pq`;\n const text = typeof query === \"string\" ? normalise(query) : null;\n return text === null ? \"\" : [n, text];\n}\n\n/** The term of a prepared document: its name and 16 hex of SHA-256. */\nasync function hashed(\n [name, text]: [string, string],\n subtle: SubtleCrypto,\n): Promise<string> {\n const digest = new Uint8Array(\n await subtle.digest(\"SHA-256\", new TextEncoder().encode(text)),\n );\n let hex = \"\";\n for (let k = 0; k < 8; k++)\n hex += (digest[k] as number).toString(16).padStart(2, \"0\");\n return `graphql:${name}#${hex}`;\n}\n\n/**\n * The request term of a raw body: \"\" or \"graphql:<name>#<documentId>\".\n * `subtle` hashes the document (SHA-256).\n */\nexport async function requestTerm(\n body: string | null | undefined,\n subtle: SubtleCrypto,\n): Promise<string> {\n const p = prepare(body);\n return typeof p === \"string\" ? p : hashed(p, subtle);\n}\n\n/**\n * The requestTerm to record for a body AS THE APP HANDED IT to fetch or\n * XHR -- before redaction, masking or truncation touch it. Known at once\n * unless a document has to be hashed; only then a Promise. What needs no\n * term code (no body, a form, a body that is not text or is longer than\n * MAX_TERM_BODY, text that cannot be a GraphQL request) is\n * termBeforeLoad()'s, which the interceptor asks before it loads this\n * chunk. Where the page has no SubtleCrypto (an insecure context) a\n * GraphQL document cannot be hashed and is \"body:*\", and every other term\n * needs no hash: the recording is still a canonical-key.v2 document,\n * whose redacted values match as wildcards (spec/canonical-key.v2.json\n * rules.record). It may throw or reject: the interceptor's termFor() is\n * the one place that turns any failure into \"no term\", so nothing here\n * can reach the page.\n */\nexport function recordTermFor(\n body: unknown,\n subtle: SubtleCrypto | undefined,\n): string | Promise<string> {\n const known = termBeforeLoad(body);\n if (known !== null) return known;\n const p = prepare(body as string);\n if (typeof p === \"string\") return p;\n return subtle ? hashed(p, subtle) : \"body:*\";\n}\n","/* ------------------------------------------------------------------ */\n/* @keploy/capture-sdk - could a body be a GraphQL request? */\n/* ------------------------------------------------------------------ */\n/*\n * The term code (request-term.ts: the lexer, the document check, the\n * hash) is a chunk of its own, loaded only for a body that passes\n * couldBeGraphql(); every other body is recorded here, at once, and the\n * chunk is never fetched. So the check must be a SUPERSET of what the\n * term code gives a term: a GraphQL body it missed would be recorded ''\n * while replay computes its term from postData(), and the keys would\n * differ.\n *\n * DERIVED FROM THE TERM CODE'S OWN ENTRY CONDITIONS (spec/canonical-\n * key.v2.json rules.term and rules.document; request-term.ts prepare()),\n * not from examples. A body has a term only when:\n * 1. it parses as ONE JSON value with nothing but JSON's whitespace\n * (U+0020, U+0009, U+000A, U+000D) before it -- a byte order mark\n * is refused -- and that value is an OBJECT, so the first character\n * that is not JSON whitespace is `{`; and\n * 2. it has a documentId, which needs a member named `query` (a string\n * that is a document) or a member named `persistedQuery` (inside\n * `extensions`). A member name is a JSON string: written with no\n * escape it is exactly `\"query\"`, quotes included, or holds\n * `persistedQuery`; written with any escape it holds `\\u`, the only\n * JSON escape that yields a letter.\n * So a batch (`[...]`), a raw application/graphql document (`{ me { id\n * } }`, `query Q { ... }`), a form and plain text have no term on either\n * side, and a GET has no body to read (the live term is\n * term(request.postData())). __tests__/term-candidate.test.ts runs every\n * term vector and every e2e GraphQL body through the check.\n */\n\n/** Longer bodies (UTF-16 units) are recorded \"body:*\": bounded work, and no literal long enough to strain a regex engine. */\nexport const MAX_TERM_BODY = 4 * 1024 * 1024;\n\n/** Text that starts as a JSON object does: JSON whitespace, then `{` (condition 1 above). */\nexport const OBJECT_START = /^[\\t\\n\\r ]*\\{/;\n\n/** The first character that is not JSON whitespace. */\nexport const NOT_SPACE = /[^\\t\\n\\r ]/;\n\n/** True when `text` could be a body the term code gives a term (see above). */\nexport function couldBeGraphql(text: string): boolean {\n return (\n OBJECT_START.test(text) &&\n (text.includes('\"query\"') ||\n text.includes(\"persistedQuery\") ||\n text.includes(\"\\\\u\"))\n );\n}\n\n/**\n * The requestTerm of a body AS THE APP HANDED IT to fetch or XHR when it\n * needs no term code: '' for no body, a form, or text that cannot be a\n * GraphQL request; \"body:*\" for a body that is not text (a Blob, a\n * buffer, a stream, a Document) or is longer than MAX_TERM_BODY. null\n * when the body could be a GraphQL request: the term code decides it.\n */\nexport function termBeforeLoad(body: unknown): string | null {\n if (body == null || body === \"\") return \"\";\n if (typeof body === \"string\")\n return body.length > MAX_TERM_BODY\n ? \"body:*\"\n : couldBeGraphql(body)\n ? null\n : \"\";\n // Sent as form text, which is never a JSON object.\n if (\n body instanceof URLSearchParams ||\n (typeof FormData !== \"undefined\" && body instanceof FormData)\n )\n return \"\";\n return \"body:*\";\n}\n","{\n \"name\": \"@keploy/capture-sdk\",\n \"version\": \"3.3.0\",\n \"description\": \"Lightweight SDK to capture UI flows from real users - DOM recording, network interception, PII masking\",\n \"homepage\": \"https://keploy.io/docs/running-keploy/ui-capture/\",\n \"main\": \"dist/index.js\",\n \"module\": \"dist/index.bundler.mjs\",\n \"unpkg\": \"dist/index.mjs\",\n \"jsdelivr\": \"dist/index.mjs\",\n \"types\": \"dist/index.d.ts\",\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.mjs\",\n \"require\": \"./dist/index.js\"\n },\n \"./request-term\": {\n \"types\": \"./dist/request-term.d.ts\",\n \"import\": \"./dist/request-term.mjs\",\n \"require\": \"./dist/request-term.js\"\n },\n \"./strict-attributes\": {\n \"types\": \"./dist/strict-attributes.d.ts\",\n \"import\": \"./dist/strict-attributes.mjs\",\n \"require\": \"./dist/strict-attributes.js\"\n },\n \"./body-redact\": {\n \"types\": \"./dist/body-redact.d.ts\",\n \"import\": \"./dist/body-redact.mjs\",\n \"require\": \"./dist/body-redact.js\"\n },\n \"./body-worker-start\": {\n \"types\": \"./dist/body-worker-start.d.ts\",\n \"import\": \"./dist/body-worker-start.mjs\",\n \"require\": \"./dist/body-worker-start.js\"\n },\n \"./package.json\": \"./package.json\"\n },\n \"files\": [\n \"dist\",\n \"request-term/package.json\",\n \"strict-attributes/package.json\",\n \"body-redact/package.json\",\n \"body-worker-start/package.json\",\n \"LICENSE\",\n \"README.md\"\n ],\n \"scripts\": {\n \"build\": \"node scripts/build-main.mjs && node scripts/build-worker.mjs && tsc -p tsconfig.build.json\",\n \"dev\": \"node scripts/build-main.mjs --watch\",\n \"test\": \"vitest run\",\n \"clean\": \"rm -rf dist\",\n \"typecheck\": \"tsc --noEmit\",\n \"prepublishOnly\": \"pnpm run clean && turbo run build --filter=@keploy/capture-sdk --force && node ../../tools/check-release-size.mjs\"\n },\n \"dependencies\": {\n \"rrweb\": \"^2.2.2\"\n },\n \"devDependencies\": {\n \"@keploy/contract\": \"workspace:*\",\n \"@types/node\": \"~24.13.5\",\n \"jsdom\": \"^30.1.0\",\n \"terser\": \"5.51.2\",\n \"tsup\": \"^8.3.0\",\n \"typescript\": \"^7.0.2\",\n \"vitest\": \"^5.0.1\"\n },\n \"peerDependencies\": {},\n \"keywords\": [\n \"keploy\",\n \"ui-testing\",\n \"session-recording\",\n \"e2e\",\n \"capture\"\n ],\n \"browser\": {\n \"./dist/body-worker-unbundled.mjs\": \"./dist/body-worker-none.mjs\"\n },\n \"alias\": {\n \"@keploy/capture-sdk/body-worker-start\": \"./dist/body-worker-start.mjs\"\n },\n \"license\": \"Apache-2.0\",\n \"publishConfig\": {\n \"access\": \"public\"\n }\n}\n"]}
|
package/dist/request-term.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function e(e,t){return null!==e&&"object"==typeof e&&!Array.isArray(e)&&Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0}function t(t){let n;try{n=t?JSON.parse(t):null}catch{return""}if(null===n||"object"!=typeof n||Array.isArray(n))return"";let r=Object.keys(n);if(!r.length||r.some(e=>!a.includes(e)))return"";let l=e(n,"operationName"),u=e(n,"query");if(null!=l&&("string"!=typeof l||!o.test(l))||null!=u&&"string"!=typeof u)return"";let i=l??"",c=e(e(e(n,"extensions"),"persistedQuery"),"sha256Hash");if("string"==typeof c&&/^[0-9A-Fa-f]{64}$/.test(c))return`graphql:${i}#pq`;let y="string"==typeof u?function(e){let t=[],n=[];for(f.lastIndex=0;f.lastIndex<e.length;){let r=f.exec(e);if(!r||r[3])return null;r[1]||(t.push(r[2]||r[4]?'""':r[7]?"0":r[0]),n.push(!!r[6]))}let r=[];for(let e=0;e<t.length;e++){let l=t[e],u="{([".indexOf(l);if(-1!==u){if(r.push("})]"[u]),!u&&!n[e+1]&&"..."!==t[e+1]&&"}"!==t[e+1])return null}else if("})]".includes(l)&&1===l.length&&r.pop()!==l)return null}return s.includes(t[0])&&"}"===t[t.length-1]&&!r.length?t.join(" "):null}(u):null;return null===y?"":[i,y]}async function n([e,t],n){let r=new Uint8Array(await n.digest("SHA-256",(new TextEncoder).encode(t))),l="";for(let e=0;e<8;e++)l+=r[e].toString(16).padStart(2,"0");return`graphql:${e}#${l}`}async function r(e,r){let l=t(e);return"string"==typeof l?l:n(l,r)}function l(e,r){let l=function(e){return null==e||""===e?"":"string"==typeof e?e.length>4194304?"body:*":function(e){return u.test(e)&&(e.includes('"query"')||e.includes("persistedQuery")||e.includes("\\u"))}(e)?null:"":e instanceof URLSearchParams||typeof FormData<"u"&&e instanceof FormData?"":"body:*"}(e);if(null!==l)return l;let i=t(e);return"string"==typeof i?i:r?n(i,r):"body:*"}var u=/^[\t\n\r ]*\{/,i="3.
|
|
1
|
+
function e(e,t){return null!==e&&"object"==typeof e&&!Array.isArray(e)&&Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0}function t(t){let n;try{n=t?JSON.parse(t):null}catch{return""}if(null===n||"object"!=typeof n||Array.isArray(n))return"";let r=Object.keys(n);if(!r.length||r.some(e=>!a.includes(e)))return"";let l=e(n,"operationName"),u=e(n,"query");if(null!=l&&("string"!=typeof l||!o.test(l))||null!=u&&"string"!=typeof u)return"";let i=l??"",c=e(e(e(n,"extensions"),"persistedQuery"),"sha256Hash");if("string"==typeof c&&/^[0-9A-Fa-f]{64}$/.test(c))return`graphql:${i}#pq`;let y="string"==typeof u?function(e){let t=[],n=[];for(f.lastIndex=0;f.lastIndex<e.length;){let r=f.exec(e);if(!r||r[3])return null;r[1]||(t.push(r[2]||r[4]?'""':r[7]?"0":r[0]),n.push(!!r[6]))}let r=[];for(let e=0;e<t.length;e++){let l=t[e],u="{([".indexOf(l);if(-1!==u){if(r.push("})]"[u]),!u&&!n[e+1]&&"..."!==t[e+1]&&"}"!==t[e+1])return null}else if("})]".includes(l)&&1===l.length&&r.pop()!==l)return null}return s.includes(t[0])&&"}"===t[t.length-1]&&!r.length?t.join(" "):null}(u):null;return null===y?"":[i,y]}async function n([e,t],n){let r=new Uint8Array(await n.digest("SHA-256",(new TextEncoder).encode(t))),l="";for(let e=0;e<8;e++)l+=r[e].toString(16).padStart(2,"0");return`graphql:${e}#${l}`}async function r(e,r){let l=t(e);return"string"==typeof l?l:n(l,r)}function l(e,r){let l=function(e){return null==e||""===e?"":"string"==typeof e?e.length>4194304?"body:*":function(e){return u.test(e)&&(e.includes('"query"')||e.includes("persistedQuery")||e.includes("\\u"))}(e)?null:"":e instanceof URLSearchParams||typeof FormData<"u"&&e instanceof FormData?"":"body:*"}(e);if(null!==l)return l;let i=t(e);return"string"==typeof i?i:r?n(i,r):"body:*"}var u=/^[\t\n\r ]*\{/,i="3.3.0",o=/^[_A-Za-z]\w*$/,s=["{","query","mutation","subscription","fragment"],a=["query","operationName","variables","extensions"],f=/([\t\n\r ,\uFEFF]+|#[^\n\r]*)|("""[^"\\]*(?:(?:\\"""|\\(?!""")|"(?!""))[^"\\]*)*""")|(""")|("[^"\\]*(?:\\[^][^"\\]*)*")|(\.\.\.|[!$&()[\]{}:=@|])|([_A-Za-z]\w*)|([0-9-](?:(?!\.\.\.)[^\t\n\r ,\uFEFF!$&()[\]{}:=@|"#])*)|((?:(?!\.\.\.)[^\t\n\r ,\uFEFF!$&()[\]{}:=@|"#\w-])+)/y;export{l as recordTermFor,r as requestTerm,i as version};//# sourceMappingURL=request-term.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/request-term.ts","../src/term-candidate.ts","../package.json"],"names":["own","o","k","Array","isArray","Object","prototype","hasOwnProperty","call","prepare","body","v","JSON","parse","keys","length","some","key","MEMBERS","includes","name","query","NAME","test","n","hash","text","doc","out","LEXEME","lastIndex","m","exec","push","open","t","at","indexOf","pop","STARTS","join","normalise","async","hashed","subtle","digest","Uint8Array","TextEncoder","encode","hex","toString","padStart","requestTerm","p","recordTermFor","known","OBJECT_START","couldBeGraphql","URLSearchParams","FormData","termBeforeLoad","version","S","A"],"mappings":"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","sourcesContent":["/* ------------------------------------------------------------------ */\n/* @keploy/capture-sdk - request term (canonical-key.v2) */\n/* ------------------------------------------------------------------ */\n/*\n * The term spec/canonical-key.v2.json keys a GraphQL request by:\n * \"graphql:<operationName>#<documentId>\", or \"\" when the body is not a\n * GraphQL request. Executed against that file's `term` vectors by\n * __tests__/request-term.test.ts.\n *\n * It is computed HERE, over the RAW body, before redaction, masking or\n * truncation touch it: the stored body may have had a PII pattern\n * redacted inside the document, may be \"[MASKED]\" (strict mode) or may\n * be cut at maxBodySize, and a term derived from it would be wrong or\n * missing. An operation name and a document hash are not user data:\n * every literal (string, block string, number) is blanked before\n * hashing, so input inlined into a document never reaches the hash, and\n * a persisted query's own hash is never recorded.\n *\n * The replay runtime holds a second implementation (packages/replay-\n * runtime/src/canonkey.ts, `graphqlTerm`) held to the same vectors: this\n * package is public and dependency-free, that one is private, and\n * neither may depend on the other. No GraphQL parser: one sticky regex\n * cuts the lexemes, which keeps the code the page downloads small.\n *\n * THIS FILE IS A CHUNK OF ITS OWN (dist/request-term.{mjs,js}, the\n * package's \"./request-term\" export), which network.ts loads the first\n * time a body could be a GraphQL request (term-candidate.ts), and never\n * for a page that sends none. It imports nothing but term-candidate.ts,\n * and nothing in the main bundle imports it but by that name:\n * __tests__/bundle-size.test.ts fails when its lexer is in\n * dist/index.{mjs,js}.\n */\n\nimport { termBeforeLoad } from \"./term-candidate\";\n/** The version this chunk was built as: the SDK refuses one of another (module-of.ts ownChunk). */\nexport { version } from \"../package.json\";\n\nconst NAME = /^[_A-Za-z]\\w*$/;\nconst STARTS = [\"{\", \"query\", \"mutation\", \"subscription\", \"fragment\"];\nconst MEMBERS = [\"query\", \"operationName\", \"variables\", \"extensions\"];\n\n/*\n * One lexeme per match, by the spec's rules.normalisation, in groups:\n * 1 ignored tokens (dropped) 2 a block string 3 an\n * unterminated block string 4 a string 5 a punctuator\n * 6 a NAME run 7 a NUMBER run 8 any other run\n * Anything no alternative matches (an unterminated string) fails the\n * scan. Sticky (y), so a lexeme can only start where the last one ended.\n * Both string alternatives are UNROLLED (a run of plain characters, then\n * one escape or quote at a time), so a long literal is a simple loop and\n * never a backtrack frame per character; and a block string's escaped\n * \\\"\"\" can only be read as the escape -- were its backslash content, the\n * regex would backtrack into it and close a block string the spec says\n * is unterminated.\n */\nconst LEXEME =\n /([\\t\\n\\r ,\\uFEFF]+|#[^\\n\\r]*)|(\"\"\"[^\"\\\\]*(?:(?:\\\\\"\"\"|\\\\(?!\"\"\")|\"(?!\"\"))[^\"\\\\]*)*\"\"\")|(\"\"\")|(\"[^\"\\\\]*(?:\\\\[^][^\"\\\\]*)*\")|(\\.\\.\\.|[!$&()[\\]{}:=@|])|([_A-Za-z]\\w*)|([0-9-](?:(?!\\.\\.\\.)[^\\t\\n\\r ,\\uFEFF!$&()[\\]{}:=@|\"#])*)|((?:(?!\\.\\.\\.)[^\\t\\n\\r ,\\uFEFF!$&()[\\]{}:=@|\"#\\w-])+)/y;\n\n/**\n * The normalised text of a GraphQL document -- lexemes joined by one\n * space, every string blanked to \"\" and every number to 0 -- or null\n * when the text is not a GraphQL document.\n */\nfunction normalise(doc: string): string | null {\n const out: string[] = [];\n const name: boolean[] = [];\n LEXEME.lastIndex = 0;\n while (LEXEME.lastIndex < doc.length) {\n const m = LEXEME.exec(doc);\n if (!m || m[3]) return null;\n if (m[1]) continue;\n out.push(m[2] || m[4] ? '\"\"' : m[7] ? \"0\" : m[0]);\n name.push(!!m[6]);\n }\n // Every opener closes in order; every { opens a selection: a name,\n // '...' or } follows it. A string is \"\" here and a number 0, so no\n // literal can pass for a punctuator or a keyword.\n const open: string[] = [];\n for (let k = 0; k < out.length; k++) {\n const t = out[k] as string;\n const at = \"{([\".indexOf(t);\n if (at !== -1) {\n open.push(\"})]\"[at] as string);\n if (!at && !(name[k + 1] || out[k + 1] === \"...\" || out[k + 1] === \"}\"))\n return null;\n } else if (\"})]\".includes(t) && t.length === 1 && open.pop() !== t)\n return null;\n }\n return STARTS.includes(out[0] as string) &&\n out[out.length - 1] === \"}\" &&\n !open.length\n ? out.join(\" \")\n : null;\n}\n\nfunction own(o: unknown, k: string): unknown {\n return o !== null &&\n typeof o === \"object\" &&\n !Array.isArray(o) &&\n Object.prototype.hasOwnProperty.call(o, k)\n ? (o as Record<string, unknown>)[k]\n : undefined;\n}\n\n/**\n * Everything of the term that needs no hash: \"\" (not a GraphQL request),\n * \"graphql:<name>#pq\" (a persisted query), or [name, normalised text]\n * still to be hashed.\n */\nfunction prepare(body: string | null | undefined): string | [string, string] {\n let v: unknown;\n try {\n v = body ? JSON.parse(body) : null;\n } catch {\n return \"\";\n }\n if (v === null || typeof v !== \"object\" || Array.isArray(v)) return \"\";\n const keys = Object.keys(v);\n if (!keys.length || keys.some((key) => !MEMBERS.includes(key))) return \"\";\n const name = own(v, \"operationName\");\n const query = own(v, \"query\");\n if (name != null && (typeof name !== \"string\" || !NAME.test(name))) return \"\";\n if (query != null && typeof query !== \"string\") return \"\";\n const n = (name as string | null | undefined) ?? \"\";\n const hash = own(own(own(v, \"extensions\"), \"persistedQuery\"), \"sha256Hash\");\n if (typeof hash === \"string\" && /^[0-9A-Fa-f]{64}$/.test(hash))\n return `graphql:${n}#pq`;\n const text = typeof query === \"string\" ? normalise(query) : null;\n return text === null ? \"\" : [n, text];\n}\n\n/** The term of a prepared document: its name and 16 hex of SHA-256. */\nasync function hashed(\n [name, text]: [string, string],\n subtle: SubtleCrypto,\n): Promise<string> {\n const digest = new Uint8Array(\n await subtle.digest(\"SHA-256\", new TextEncoder().encode(text)),\n );\n let hex = \"\";\n for (let k = 0; k < 8; k++)\n hex += (digest[k] as number).toString(16).padStart(2, \"0\");\n return `graphql:${name}#${hex}`;\n}\n\n/**\n * The request term of a raw body: \"\" or \"graphql:<name>#<documentId>\".\n * `subtle` hashes the document (SHA-256).\n */\nexport async function requestTerm(\n body: string | null | undefined,\n subtle: SubtleCrypto,\n): Promise<string> {\n const p = prepare(body);\n return typeof p === \"string\" ? p : hashed(p, subtle);\n}\n\n/**\n * The requestTerm to record for a body AS THE APP HANDED IT to fetch or\n * XHR -- before redaction, masking or truncation touch it. Known at once\n * unless a document has to be hashed; only then a Promise. What needs no\n * term code (no body, a form, a body that is not text or is longer than\n * MAX_TERM_BODY, text that cannot be a GraphQL request) is\n * termBeforeLoad()'s, which the interceptor asks before it loads this\n * chunk. Where the page has no SubtleCrypto (an insecure context) a\n * GraphQL document cannot be hashed and is \"body:*\", and every other term\n * needs no hash: the recording is still a canonical-key.v2 document,\n * whose redacted values match as wildcards (spec/canonical-key.v2.json\n * rules.record). It may throw or reject: the interceptor's termFor() is\n * the one place that turns any failure into \"no term\", so nothing here\n * can reach the page.\n */\nexport function recordTermFor(\n body: unknown,\n subtle: SubtleCrypto | undefined,\n): string | Promise<string> {\n const known = termBeforeLoad(body);\n if (known !== null) return known;\n const p = prepare(body as string);\n if (typeof p === \"string\") return p;\n return subtle ? hashed(p, subtle) : \"body:*\";\n}\n","/* ------------------------------------------------------------------ */\n/* @keploy/capture-sdk - could a body be a GraphQL request? */\n/* ------------------------------------------------------------------ */\n/*\n * The term code (request-term.ts: the lexer, the document check, the\n * hash) is a chunk of its own, loaded only for a body that passes\n * couldBeGraphql(); every other body is recorded here, at once, and the\n * chunk is never fetched. So the check must be a SUPERSET of what the\n * term code gives a term: a GraphQL body it missed would be recorded ''\n * while replay computes its term from postData(), and the keys would\n * differ.\n *\n * DERIVED FROM THE TERM CODE'S OWN ENTRY CONDITIONS (spec/canonical-\n * key.v2.json rules.term and rules.document; request-term.ts prepare()),\n * not from examples. A body has a term only when:\n * 1. it parses as ONE JSON value with nothing but JSON's whitespace\n * (U+0020, U+0009, U+000A, U+000D) before it -- a byte order mark\n * is refused -- and that value is an OBJECT, so the first character\n * that is not JSON whitespace is `{`; and\n * 2. it has a documentId, which needs a member named `query` (a string\n * that is a document) or a member named `persistedQuery` (inside\n * `extensions`). A member name is a JSON string: written with no\n * escape it is exactly `\"query\"`, quotes included, or holds\n * `persistedQuery`; written with any escape it holds `\\u`, the only\n * JSON escape that yields a letter.\n * So a batch (`[...]`), a raw application/graphql document (`{ me { id\n * } }`, `query Q { ... }`), a form and plain text have no term on either\n * side, and a GET has no body to read (the live term is\n * term(request.postData())). __tests__/term-candidate.test.ts runs every\n * term vector and every e2e GraphQL body through the check.\n */\n\n/** Longer bodies (UTF-16 units) are recorded \"body:*\": bounded work, and no literal long enough to strain a regex engine. */\nexport const MAX_TERM_BODY = 4 * 1024 * 1024;\n\n/** Text that starts as a JSON object does: JSON whitespace, then `{` (condition 1 above). */\nexport const OBJECT_START = /^[\\t\\n\\r ]*\\{/;\n\n/** The first character that is not JSON whitespace. */\nexport const NOT_SPACE = /[^\\t\\n\\r ]/;\n\n/** True when `text` could be a body the term code gives a term (see above). */\nexport function couldBeGraphql(text: string): boolean {\n return (\n OBJECT_START.test(text) &&\n (text.includes('\"query\"') ||\n text.includes(\"persistedQuery\") ||\n text.includes(\"\\\\u\"))\n );\n}\n\n/**\n * The requestTerm of a body AS THE APP HANDED IT to fetch or XHR when it\n * needs no term code: '' for no body, a form, or text that cannot be a\n * GraphQL request; \"body:*\" for a body that is not text (a Blob, a\n * buffer, a stream, a Document) or is longer than MAX_TERM_BODY. null\n * when the body could be a GraphQL request: the term code decides it.\n */\nexport function termBeforeLoad(body: unknown): string | null {\n if (body == null || body === \"\") return \"\";\n if (typeof body === \"string\")\n return body.length > MAX_TERM_BODY\n ? \"body:*\"\n : couldBeGraphql(body)\n ? null\n : \"\";\n // Sent as form text, which is never a JSON object.\n if (\n body instanceof URLSearchParams ||\n (typeof FormData !== \"undefined\" && body instanceof FormData)\n )\n return \"\";\n return \"body:*\";\n}\n","{\n \"name\": \"@keploy/capture-sdk\",\n \"version\": \"3.2.0\",\n \"description\": \"Lightweight SDK to capture UI flows from real users - DOM recording, network interception, PII masking\",\n \"homepage\": \"https://keploy.io/docs/running-keploy/ui-capture/\",\n \"main\": \"dist/index.js\",\n \"module\": \"dist/index.bundler.mjs\",\n \"unpkg\": \"dist/index.mjs\",\n \"jsdelivr\": \"dist/index.mjs\",\n \"types\": \"dist/index.d.ts\",\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.mjs\",\n \"require\": \"./dist/index.js\"\n },\n \"./request-term\": {\n \"types\": \"./dist/request-term.d.ts\",\n \"import\": \"./dist/request-term.mjs\",\n \"require\": \"./dist/request-term.js\"\n },\n \"./strict-attributes\": {\n \"types\": \"./dist/strict-attributes.d.ts\",\n \"import\": \"./dist/strict-attributes.mjs\",\n \"require\": \"./dist/strict-attributes.js\"\n },\n \"./body-redact\": {\n \"types\": \"./dist/body-redact.d.ts\",\n \"import\": \"./dist/body-redact.mjs\",\n \"require\": \"./dist/body-redact.js\"\n },\n \"./body-worker-start\": {\n \"types\": \"./dist/body-worker-start.d.ts\",\n \"import\": \"./dist/body-worker-start.mjs\",\n \"require\": \"./dist/body-worker-start.js\"\n },\n \"./package.json\": \"./package.json\"\n },\n \"files\": [\n \"dist\",\n \"request-term/package.json\",\n \"strict-attributes/package.json\",\n \"body-redact/package.json\",\n \"body-worker-start/package.json\",\n \"LICENSE\",\n \"README.md\"\n ],\n \"scripts\": {\n \"build\": \"node scripts/build-main.mjs && node scripts/build-worker.mjs && tsc -p tsconfig.build.json\",\n \"dev\": \"node scripts/build-main.mjs --watch\",\n \"test\": \"vitest run\",\n \"clean\": \"rm -rf dist\",\n \"typecheck\": \"tsc --noEmit\",\n \"prepublishOnly\": \"pnpm run clean && turbo run build --filter=@keploy/capture-sdk --force && node ../../tools/check-release-size.mjs\"\n },\n \"dependencies\": {\n \"rrweb\": \"^2.1.6\"\n },\n \"devDependencies\": {\n \"@keploy/contract\": \"workspace:*\",\n \"@types/node\": \"~24.13.5\",\n \"jsdom\": \"^30.1.0\",\n \"terser\": \"5.51.2\",\n \"tsup\": \"^8.3.0\",\n \"typescript\": \"^7.0.2\",\n \"vitest\": \"^5.0.1\"\n },\n \"peerDependencies\": {},\n \"keywords\": [\n \"keploy\",\n \"ui-testing\",\n \"session-recording\",\n \"e2e\",\n \"capture\"\n ],\n \"browser\": {\n \"./dist/body-worker-unbundled.mjs\": \"./dist/body-worker-none.mjs\"\n },\n \"alias\": {\n \"@keploy/capture-sdk/body-worker-start\": \"./dist/body-worker-start.mjs\"\n },\n \"license\": \"Apache-2.0\",\n \"publishConfig\": {\n \"access\": \"public\"\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/request-term.ts","../src/term-candidate.ts","../package.json"],"names":["own","o","k","Array","isArray","Object","prototype","hasOwnProperty","call","prepare","body","v","JSON","parse","keys","length","some","key","MEMBERS","includes","name","query","NAME","test","n","hash","text","doc","out","LEXEME","lastIndex","m","exec","push","open","t","at","indexOf","pop","STARTS","join","normalise","async","hashed","subtle","digest","Uint8Array","TextEncoder","encode","hex","toString","padStart","requestTerm","p","recordTermFor","known","OBJECT_START","couldBeGraphql","URLSearchParams","FormData","termBeforeLoad","version","S","A"],"mappings":"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","sourcesContent":["/* ------------------------------------------------------------------ */\n/* @keploy/capture-sdk - request term (canonical-key.v2) */\n/* ------------------------------------------------------------------ */\n/*\n * The term spec/canonical-key.v2.json keys a GraphQL request by:\n * \"graphql:<operationName>#<documentId>\", or \"\" when the body is not a\n * GraphQL request. Executed against that file's `term` vectors by\n * __tests__/request-term.test.ts.\n *\n * It is computed HERE, over the RAW body, before redaction, masking or\n * truncation touch it: the stored body may have had a PII pattern\n * redacted inside the document, may be \"[MASKED]\" (strict mode) or may\n * be cut at maxBodySize, and a term derived from it would be wrong or\n * missing. An operation name and a document hash are not user data:\n * every literal (string, block string, number) is blanked before\n * hashing, so input inlined into a document never reaches the hash, and\n * a persisted query's own hash is never recorded.\n *\n * The replay runtime holds a second implementation (packages/replay-\n * runtime/src/canonkey.ts, `graphqlTerm`) held to the same vectors: this\n * package is public and dependency-free, that one is private, and\n * neither may depend on the other. No GraphQL parser: one sticky regex\n * cuts the lexemes, which keeps the code the page downloads small.\n *\n * THIS FILE IS A CHUNK OF ITS OWN (dist/request-term.{mjs,js}, the\n * package's \"./request-term\" export), which network.ts loads the first\n * time a body could be a GraphQL request (term-candidate.ts), and never\n * for a page that sends none. It imports nothing but term-candidate.ts,\n * and nothing in the main bundle imports it but by that name:\n * __tests__/bundle-size.test.ts fails when its lexer is in\n * dist/index.{mjs,js}.\n */\n\nimport { termBeforeLoad } from \"./term-candidate\";\n/** The version this chunk was built as: the SDK refuses one of another (module-of.ts ownChunk). */\nexport { version } from \"../package.json\";\n\nconst NAME = /^[_A-Za-z]\\w*$/;\nconst STARTS = [\"{\", \"query\", \"mutation\", \"subscription\", \"fragment\"];\nconst MEMBERS = [\"query\", \"operationName\", \"variables\", \"extensions\"];\n\n/*\n * One lexeme per match, by the spec's rules.normalisation, in groups:\n * 1 ignored tokens (dropped) 2 a block string 3 an\n * unterminated block string 4 a string 5 a punctuator\n * 6 a NAME run 7 a NUMBER run 8 any other run\n * Anything no alternative matches (an unterminated string) fails the\n * scan. Sticky (y), so a lexeme can only start where the last one ended.\n * Both string alternatives are UNROLLED (a run of plain characters, then\n * one escape or quote at a time), so a long literal is a simple loop and\n * never a backtrack frame per character; and a block string's escaped\n * \\\"\"\" can only be read as the escape -- were its backslash content, the\n * regex would backtrack into it and close a block string the spec says\n * is unterminated.\n */\nconst LEXEME =\n /([\\t\\n\\r ,\\uFEFF]+|#[^\\n\\r]*)|(\"\"\"[^\"\\\\]*(?:(?:\\\\\"\"\"|\\\\(?!\"\"\")|\"(?!\"\"))[^\"\\\\]*)*\"\"\")|(\"\"\")|(\"[^\"\\\\]*(?:\\\\[^][^\"\\\\]*)*\")|(\\.\\.\\.|[!$&()[\\]{}:=@|])|([_A-Za-z]\\w*)|([0-9-](?:(?!\\.\\.\\.)[^\\t\\n\\r ,\\uFEFF!$&()[\\]{}:=@|\"#])*)|((?:(?!\\.\\.\\.)[^\\t\\n\\r ,\\uFEFF!$&()[\\]{}:=@|\"#\\w-])+)/y;\n\n/**\n * The normalised text of a GraphQL document -- lexemes joined by one\n * space, every string blanked to \"\" and every number to 0 -- or null\n * when the text is not a GraphQL document.\n */\nfunction normalise(doc: string): string | null {\n const out: string[] = [];\n const name: boolean[] = [];\n LEXEME.lastIndex = 0;\n while (LEXEME.lastIndex < doc.length) {\n const m = LEXEME.exec(doc);\n if (!m || m[3]) return null;\n if (m[1]) continue;\n out.push(m[2] || m[4] ? '\"\"' : m[7] ? \"0\" : m[0]);\n name.push(!!m[6]);\n }\n // Every opener closes in order; every { opens a selection: a name,\n // '...' or } follows it. A string is \"\" here and a number 0, so no\n // literal can pass for a punctuator or a keyword.\n const open: string[] = [];\n for (let k = 0; k < out.length; k++) {\n const t = out[k] as string;\n const at = \"{([\".indexOf(t);\n if (at !== -1) {\n open.push(\"})]\"[at] as string);\n if (!at && !(name[k + 1] || out[k + 1] === \"...\" || out[k + 1] === \"}\"))\n return null;\n } else if (\"})]\".includes(t) && t.length === 1 && open.pop() !== t)\n return null;\n }\n return STARTS.includes(out[0] as string) &&\n out[out.length - 1] === \"}\" &&\n !open.length\n ? out.join(\" \")\n : null;\n}\n\nfunction own(o: unknown, k: string): unknown {\n return o !== null &&\n typeof o === \"object\" &&\n !Array.isArray(o) &&\n Object.prototype.hasOwnProperty.call(o, k)\n ? (o as Record<string, unknown>)[k]\n : undefined;\n}\n\n/**\n * Everything of the term that needs no hash: \"\" (not a GraphQL request),\n * \"graphql:<name>#pq\" (a persisted query), or [name, normalised text]\n * still to be hashed.\n */\nfunction prepare(body: string | null | undefined): string | [string, string] {\n let v: unknown;\n try {\n v = body ? JSON.parse(body) : null;\n } catch {\n return \"\";\n }\n if (v === null || typeof v !== \"object\" || Array.isArray(v)) return \"\";\n const keys = Object.keys(v);\n if (!keys.length || keys.some((key) => !MEMBERS.includes(key))) return \"\";\n const name = own(v, \"operationName\");\n const query = own(v, \"query\");\n if (name != null && (typeof name !== \"string\" || !NAME.test(name))) return \"\";\n if (query != null && typeof query !== \"string\") return \"\";\n const n = (name as string | null | undefined) ?? \"\";\n const hash = own(own(own(v, \"extensions\"), \"persistedQuery\"), \"sha256Hash\");\n if (typeof hash === \"string\" && /^[0-9A-Fa-f]{64}$/.test(hash))\n return `graphql:${n}#pq`;\n const text = typeof query === \"string\" ? normalise(query) : null;\n return text === null ? \"\" : [n, text];\n}\n\n/** The term of a prepared document: its name and 16 hex of SHA-256. */\nasync function hashed(\n [name, text]: [string, string],\n subtle: SubtleCrypto,\n): Promise<string> {\n const digest = new Uint8Array(\n await subtle.digest(\"SHA-256\", new TextEncoder().encode(text)),\n );\n let hex = \"\";\n for (let k = 0; k < 8; k++)\n hex += (digest[k] as number).toString(16).padStart(2, \"0\");\n return `graphql:${name}#${hex}`;\n}\n\n/**\n * The request term of a raw body: \"\" or \"graphql:<name>#<documentId>\".\n * `subtle` hashes the document (SHA-256).\n */\nexport async function requestTerm(\n body: string | null | undefined,\n subtle: SubtleCrypto,\n): Promise<string> {\n const p = prepare(body);\n return typeof p === \"string\" ? p : hashed(p, subtle);\n}\n\n/**\n * The requestTerm to record for a body AS THE APP HANDED IT to fetch or\n * XHR -- before redaction, masking or truncation touch it. Known at once\n * unless a document has to be hashed; only then a Promise. What needs no\n * term code (no body, a form, a body that is not text or is longer than\n * MAX_TERM_BODY, text that cannot be a GraphQL request) is\n * termBeforeLoad()'s, which the interceptor asks before it loads this\n * chunk. Where the page has no SubtleCrypto (an insecure context) a\n * GraphQL document cannot be hashed and is \"body:*\", and every other term\n * needs no hash: the recording is still a canonical-key.v2 document,\n * whose redacted values match as wildcards (spec/canonical-key.v2.json\n * rules.record). It may throw or reject: the interceptor's termFor() is\n * the one place that turns any failure into \"no term\", so nothing here\n * can reach the page.\n */\nexport function recordTermFor(\n body: unknown,\n subtle: SubtleCrypto | undefined,\n): string | Promise<string> {\n const known = termBeforeLoad(body);\n if (known !== null) return known;\n const p = prepare(body as string);\n if (typeof p === \"string\") return p;\n return subtle ? hashed(p, subtle) : \"body:*\";\n}\n","/* ------------------------------------------------------------------ */\n/* @keploy/capture-sdk - could a body be a GraphQL request? */\n/* ------------------------------------------------------------------ */\n/*\n * The term code (request-term.ts: the lexer, the document check, the\n * hash) is a chunk of its own, loaded only for a body that passes\n * couldBeGraphql(); every other body is recorded here, at once, and the\n * chunk is never fetched. So the check must be a SUPERSET of what the\n * term code gives a term: a GraphQL body it missed would be recorded ''\n * while replay computes its term from postData(), and the keys would\n * differ.\n *\n * DERIVED FROM THE TERM CODE'S OWN ENTRY CONDITIONS (spec/canonical-\n * key.v2.json rules.term and rules.document; request-term.ts prepare()),\n * not from examples. A body has a term only when:\n * 1. it parses as ONE JSON value with nothing but JSON's whitespace\n * (U+0020, U+0009, U+000A, U+000D) before it -- a byte order mark\n * is refused -- and that value is an OBJECT, so the first character\n * that is not JSON whitespace is `{`; and\n * 2. it has a documentId, which needs a member named `query` (a string\n * that is a document) or a member named `persistedQuery` (inside\n * `extensions`). A member name is a JSON string: written with no\n * escape it is exactly `\"query\"`, quotes included, or holds\n * `persistedQuery`; written with any escape it holds `\\u`, the only\n * JSON escape that yields a letter.\n * So a batch (`[...]`), a raw application/graphql document (`{ me { id\n * } }`, `query Q { ... }`), a form and plain text have no term on either\n * side, and a GET has no body to read (the live term is\n * term(request.postData())). __tests__/term-candidate.test.ts runs every\n * term vector and every e2e GraphQL body through the check.\n */\n\n/** Longer bodies (UTF-16 units) are recorded \"body:*\": bounded work, and no literal long enough to strain a regex engine. */\nexport const MAX_TERM_BODY = 4 * 1024 * 1024;\n\n/** Text that starts as a JSON object does: JSON whitespace, then `{` (condition 1 above). */\nexport const OBJECT_START = /^[\\t\\n\\r ]*\\{/;\n\n/** The first character that is not JSON whitespace. */\nexport const NOT_SPACE = /[^\\t\\n\\r ]/;\n\n/** True when `text` could be a body the term code gives a term (see above). */\nexport function couldBeGraphql(text: string): boolean {\n return (\n OBJECT_START.test(text) &&\n (text.includes('\"query\"') ||\n text.includes(\"persistedQuery\") ||\n text.includes(\"\\\\u\"))\n );\n}\n\n/**\n * The requestTerm of a body AS THE APP HANDED IT to fetch or XHR when it\n * needs no term code: '' for no body, a form, or text that cannot be a\n * GraphQL request; \"body:*\" for a body that is not text (a Blob, a\n * buffer, a stream, a Document) or is longer than MAX_TERM_BODY. null\n * when the body could be a GraphQL request: the term code decides it.\n */\nexport function termBeforeLoad(body: unknown): string | null {\n if (body == null || body === \"\") return \"\";\n if (typeof body === \"string\")\n return body.length > MAX_TERM_BODY\n ? \"body:*\"\n : couldBeGraphql(body)\n ? null\n : \"\";\n // Sent as form text, which is never a JSON object.\n if (\n body instanceof URLSearchParams ||\n (typeof FormData !== \"undefined\" && body instanceof FormData)\n )\n return \"\";\n return \"body:*\";\n}\n","{\n \"name\": \"@keploy/capture-sdk\",\n \"version\": \"3.3.0\",\n \"description\": \"Lightweight SDK to capture UI flows from real users - DOM recording, network interception, PII masking\",\n \"homepage\": \"https://keploy.io/docs/running-keploy/ui-capture/\",\n \"main\": \"dist/index.js\",\n \"module\": \"dist/index.bundler.mjs\",\n \"unpkg\": \"dist/index.mjs\",\n \"jsdelivr\": \"dist/index.mjs\",\n \"types\": \"dist/index.d.ts\",\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.mjs\",\n \"require\": \"./dist/index.js\"\n },\n \"./request-term\": {\n \"types\": \"./dist/request-term.d.ts\",\n \"import\": \"./dist/request-term.mjs\",\n \"require\": \"./dist/request-term.js\"\n },\n \"./strict-attributes\": {\n \"types\": \"./dist/strict-attributes.d.ts\",\n \"import\": \"./dist/strict-attributes.mjs\",\n \"require\": \"./dist/strict-attributes.js\"\n },\n \"./body-redact\": {\n \"types\": \"./dist/body-redact.d.ts\",\n \"import\": \"./dist/body-redact.mjs\",\n \"require\": \"./dist/body-redact.js\"\n },\n \"./body-worker-start\": {\n \"types\": \"./dist/body-worker-start.d.ts\",\n \"import\": \"./dist/body-worker-start.mjs\",\n \"require\": \"./dist/body-worker-start.js\"\n },\n \"./package.json\": \"./package.json\"\n },\n \"files\": [\n \"dist\",\n \"request-term/package.json\",\n \"strict-attributes/package.json\",\n \"body-redact/package.json\",\n \"body-worker-start/package.json\",\n \"LICENSE\",\n \"README.md\"\n ],\n \"scripts\": {\n \"build\": \"node scripts/build-main.mjs && node scripts/build-worker.mjs && tsc -p tsconfig.build.json\",\n \"dev\": \"node scripts/build-main.mjs --watch\",\n \"test\": \"vitest run\",\n \"clean\": \"rm -rf dist\",\n \"typecheck\": \"tsc --noEmit\",\n \"prepublishOnly\": \"pnpm run clean && turbo run build --filter=@keploy/capture-sdk --force && node ../../tools/check-release-size.mjs\"\n },\n \"dependencies\": {\n \"rrweb\": \"^2.2.2\"\n },\n \"devDependencies\": {\n \"@keploy/contract\": \"workspace:*\",\n \"@types/node\": \"~24.13.5\",\n \"jsdom\": \"^30.1.0\",\n \"terser\": \"5.51.2\",\n \"tsup\": \"^8.3.0\",\n \"typescript\": \"^7.0.2\",\n \"vitest\": \"^5.0.1\"\n },\n \"peerDependencies\": {},\n \"keywords\": [\n \"keploy\",\n \"ui-testing\",\n \"session-recording\",\n \"e2e\",\n \"capture\"\n ],\n \"browser\": {\n \"./dist/body-worker-unbundled.mjs\": \"./dist/body-worker-none.mjs\"\n },\n \"alias\": {\n \"@keploy/capture-sdk/body-worker-start\": \"./dist/body-worker-start.mjs\"\n },\n \"license\": \"Apache-2.0\",\n \"publishConfig\": {\n \"access\": \"public\"\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";function e(e,t,r,o){return"content"===e?"meta"===t&&void 0!==o&&("string"==typeof o["http-equiv"]||c.test(String(o.name))):s.test(e)||!0===(r?d:t.includes("-")?null:p)?.test(e)}var t,r=Object.defineProperty,o=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,n={};((e,t)=>{for(var o in t)r(e,o,{get:t[o],enumerable:!0})})(n,{kept:()=>e,version:()=>l});module.exports=(t=n,((e,t,n,l)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let n of i(t))!a.call(e,n)&&void 0!==n&&r(e,n,{get:()=>t[n],enumerable:!(l=o(t,n))||l.enumerable});return e})(r({},"__esModule",{value:!0}),t));var l="3.
|
|
1
|
+
"use strict";function e(e,t,r,o){return"content"===e?"meta"===t&&void 0!==o&&("string"==typeof o["http-equiv"]||c.test(String(o.name))):s.test(e)||!0===(r?d:t.includes("-")?null:p)?.test(e)}var t,r=Object.defineProperty,o=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,n={};((e,t)=>{for(var o in t)r(e,o,{get:t[o],enumerable:!0})})(n,{kept:()=>e,version:()=>l});module.exports=(t=n,((e,t,n,l)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let n of i(t))!a.call(e,n)&&void 0!==n&&r(e,n,{get:()=>t[n],enumerable:!(l=o(t,n))||l.enumerable});return e})(r({},"__esModule",{value:!0}),t));var l="3.3.0",s=/^(?:id|class|role|slot|part|is|hidden|inert|tabindex|dir|lang|translate|draggable|contenteditable|spellcheck|autofocus|data-testid|xmlns(?::\w+)?|xml:\w+|aria-(?:atomic|autocomplete|busy|colcount|colindex|colspan|controls|describedby|details|disabled|errormessage|expanded|flowto|haspopup|hidden|labelledby|level|live|modal|multiline|multiselectable|orientation|owns|posinset|readonly|relevant|required|rowcount|rowindex|rowspan|setsize)|rr_\w+)$/,p=/^(?:name|type|rel|for|form|list|headers|disabled|readonly|required|multiple|open|autocomplete|inputmode|enterkeyhint|accept|charset|http-equiv|media|sizes|loading|decoding|fetchpriority|crossorigin|referrerpolicy|sandbox|allow|allowfullscreen|target|method|enctype|novalidate|async|defer|nomodule|as|start|reversed|scope|span|colspan|rowspan|cols|rows|size|maxlength|minlength|step|low|high|optimum|width|height|wrap|kind|srclang|default|controls|autoplay|loop|muted|playsinline|preload|shape|coords|usemap|ismap|popover|popovertarget|popovertargetaction|align|valign|border|frameborder|property|itemprop|itemscope|itemtype|itemref)$/,d=/^(?:viewbox|preserveaspectratio|version|d|x|y|z|[xy][12]|c[xy]|r[xy]?|f[xyr]|dx|dy|width|height|points|transform|offset|opacity|display|visibility|overflow|focusable|rotate|refx|refy|orient|pathlength|startoffset|lengthadjust|spreadmethod|in2?|result|stddeviation|operator|mode|k[1-4]|values|radius|scale|type|fill(?:-opacity|-rule)?|stroke(?:-width|-opacity|-linecap|-linejoin|-dasharray|-dashoffset|-miterlimit)?|stop-(?:color|opacity)|font-(?:family|size|weight|style)|text-(?:anchor|decoration|rendering)|textlength|clip-(?:path|rule)|clippathunits|marker(?:-start|-mid|-end|width|height|units)|(?:gradient|pattern|mask|filter|primitive|maskcontent|patterncontent)(?:units|transform)|mask|filter|flood-(?:color|opacity)|lighting-color|vector-effect|(?:dominant|alignment)-baseline|baseline-shift|(?:letter|word)-spacing|writing-mode|paint-order|color(?:-interpolation(?:-filters)?)?|shape-rendering|image-rendering|transform-origin)$/,c=/^(viewport|color-scheme|theme-color|referrer|robots|format-detection)$/i;//# sourceMappingURL=strict-attributes.js.map
|