@keploy/capture-sdk 3.1.0-rc.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.
Files changed (52) hide show
  1. package/README.md +398 -58
  2. package/body-redact/package.json +6 -0
  3. package/body-worker-start/package.json +6 -0
  4. package/dist/body-jobs.d.ts +134 -0
  5. package/dist/body-redact.d.ts +23 -0
  6. package/dist/body-redact.js +1 -0
  7. package/dist/body-redact.js.map +1 -0
  8. package/dist/body-redact.mjs +1 -0
  9. package/dist/body-redact.mjs.map +1 -0
  10. package/dist/body-worker-none.d.ts +3 -0
  11. package/dist/body-worker-none.js +1 -0
  12. package/dist/body-worker-none.js.map +1 -0
  13. package/dist/body-worker-none.mjs +1 -0
  14. package/dist/body-worker-none.mjs.map +1 -0
  15. package/dist/body-worker-start.d.ts +3 -0
  16. package/dist/body-worker-start.js +1 -0
  17. package/dist/body-worker-start.js.map +1 -0
  18. package/dist/body-worker-start.mjs +1 -0
  19. package/dist/body-worker-start.mjs.map +1 -0
  20. package/dist/body-worker-unbundled.d.ts +1 -0
  21. package/dist/body-worker-unbundled.mjs +1 -0
  22. package/dist/body-worker-unbundled.mjs.map +1 -0
  23. package/dist/body-worker.d.ts +1 -0
  24. package/dist/body-worker.js +1 -0
  25. package/dist/body-worker.js.map +1 -0
  26. package/dist/errors.d.ts +38 -6
  27. package/dist/index.bundler.mjs +1 -0
  28. package/dist/index.bundler.mjs.map +1 -0
  29. package/dist/index.d.ts +1 -1
  30. package/dist/index.js +1 -11
  31. package/dist/index.js.map +1 -1
  32. package/dist/index.mjs +1 -11
  33. package/dist/index.mjs.map +1 -1
  34. package/dist/leave.d.ts +67 -0
  35. package/dist/module-of.d.ts +45 -0
  36. package/dist/network.d.ts +52 -37
  37. package/dist/privacy.d.ts +23 -2
  38. package/dist/recorder.d.ts +30 -6
  39. package/dist/request-term.d.ts +2 -0
  40. package/dist/request-term.js +1 -2
  41. package/dist/request-term.js.map +1 -1
  42. package/dist/request-term.mjs +1 -2
  43. package/dist/request-term.mjs.map +1 -1
  44. package/dist/strict-attributes.d.ts +9 -0
  45. package/dist/strict-attributes.js +1 -0
  46. package/dist/strict-attributes.js.map +1 -0
  47. package/dist/strict-attributes.mjs +1 -0
  48. package/dist/strict-attributes.mjs.map +1 -0
  49. package/dist/transport.d.ts +35 -3
  50. package/dist/types.d.ts +21 -5
  51. package/package.json +31 -4
  52. package/strict-attributes/package.json +6 -0
@@ -0,0 +1,6 @@
1
+ {
2
+ "private": true,
3
+ "main": "../dist/body-redact.js",
4
+ "module": "../dist/body-redact.mjs",
5
+ "types": "../dist/body-redact.d.ts"
6
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "private": true,
3
+ "main": "../dist/body-worker-none.js",
4
+ "module": "../dist/body-worker-none.mjs",
5
+ "types": "../dist/body-worker-start.d.ts"
6
+ }
@@ -0,0 +1,134 @@
1
+ import type { BodyJob, BodyOut } from "./body-redact";
2
+ type BodyCode = typeof import("./body-redact");
3
+ type WorkerStart = typeof import("./body-worker-start");
4
+ /**
5
+ * UTF-16 units of body the main thread redacts in one go: a body with no
6
+ * worker, and all the bodies a moment that cannot wait redacts together.
7
+ * 64 KiB is about 6-10 ms of redaction at desktop speed (MEASURED: 5.7 ms
8
+ * for a 64 KB JSON in Chromium, 6 in Firefox, 8 in WebKit), and the most
9
+ * a page-unload flush can carry anyway (transport.ts, the keepalive
10
+ * quota). Founder's ruling, 2026-11-11.
11
+ */
12
+ export declare const MAIN_THREAD_BODY_BUDGET = 65536;
13
+ interface Held {
14
+ job: BodyJob | null;
15
+ owner: BodyJobs;
16
+ /** Its bodies as recorded, once known (undefined: not yet). */
17
+ out?: BodyOut | null;
18
+ /** The relay is over (see network.ts): the main thread redacts after it. */
19
+ after?: Promise<void>;
20
+ /** Posted already, at report (a browser with no idle periods; see redact). */
21
+ sent?: boolean;
22
+ /** leave.ts's leaveMark() as its exchange was answered (ofTheLeave). */
23
+ mark: number;
24
+ }
25
+ /**
26
+ * THE CODE AS SOON AS THE CAPTURE STARTS: the main thread's code, asked
27
+ * for now -- in init()'s own task, beside rrweb's import, never in an
28
+ * idle period or after the first exchange -- so the window in which a
29
+ * page that leaves finds a body held without it is the chunk's fetch.
30
+ * The page's network is recorded meanwhile, as it always was; a body
31
+ * that meets a moment that cannot wait before the code has arrived is
32
+ * recorded as notCapturedBodyNote(N, "left") (now()). Offline it
33
+ * is asked for once the browser is back (whenOnline), as before.
34
+ */
35
+ export declare function askForCode(): void;
36
+ /**
37
+ * Start loading the main thread's code and the worker, once per page: at
38
+ * a capture's start, in a task of its own (prepareSoon). For a capture
39
+ * KeployCapture started the code is asked for already (askForCode).
40
+ */
41
+ export declare function prepare(): void;
42
+ /**
43
+ * prepare() in a task of its own, never beside the page's own work: at a
44
+ * capture's start in the page's next idle period (as rrweb loads at
45
+ * start), and at the latest in the task after its first exchange leaves.
46
+ * So the chunk and the worker are there before a burst of the page's
47
+ * requests when an idle period comes first after the capture starts;
48
+ * otherwise they are asked for in the task after its first request
49
+ * leaves, queued behind the requests that task made, while their
50
+ * responses may still be arriving. MEASURED, WebKit 26.6, one
51
+ * box, 9 interleaved reps, 50 x 64 KB with the loads asked for beside the
52
+ * burst's first request: time to headers +1.8 ms and the burst +3.3 ms
53
+ * against main, both past main's spread.
54
+ */
55
+ export declare function prepareSoon(idle?: boolean): void;
56
+ /**
57
+ * Let the page's worker go when a capture stops and nothing is posted to
58
+ * it: an idle thread for the rest of the page's life otherwise. The next
59
+ * capture starts one again from its start (the chunk is the module
60
+ * the page already loaded; the script, the bundler's file, is cached). A
61
+ * page that has no worker (null) keeps having none. And, when no capture
62
+ * is live (`last`), stop waiting for the network: nothing asks then, and
63
+ * the wait's look a second would outlive the capture
64
+ * (dom-recorder-offline-unsaid.test.ts). Never while one is: a capture
65
+ * started during this one's settle() holds its bodies in the same wait.
66
+ * Every body of the capture that ended was recorded by its settle().
67
+ * `wanted`: whether a capture is live or a next session waits for the
68
+ * visitor's input (a continuous capture's), which a running worker is kept
69
+ * for while the page leaves; read again whenever the kept worker may go.
70
+ */
71
+ export declare function releaseWorker(last?: boolean, wanted?: () => boolean): void;
72
+ /**
73
+ * One capture's bodies on their way to the recording. `record` is called
74
+ * once per job, with its bodies as recorded, or null for a job whose
75
+ * redaction threw (the exchange is not recorded, as when redaction threw
76
+ * on the main thread).
77
+ */
78
+ export declare class BodyJobs {
79
+ /** Jobs not yet recorded, in the order they were handed over. */
80
+ private held;
81
+ /**
82
+ * Redact `job`'s bodies, off the main thread, and call `record` with
83
+ * them. A null job has nothing to redact (bodies masked whole), and is
84
+ * recorded in a task of its own.
85
+ */
86
+ redact(job: BodyJob | null, record: (out: BodyOut | null) => void, after?: Promise<void>, mark?: number): void;
87
+ /** True while a job is held. */
88
+ holds(): boolean;
89
+ /** True while `held` is held: not yet recorded. */
90
+ has(held: Held): boolean;
91
+ /**
92
+ * The worker's answer for `held`: kept, and recorded in an idle period
93
+ * of its own (the event's headers, URL and serialisation run on this
94
+ * thread, never beside the page's work); now() records it at once.
95
+ */
96
+ answered(held: Held, out: BodyOut | null): void;
97
+ /** Record `held` with `out`, once. */
98
+ answer(held: Held, out: BodyOut | null): void;
99
+ /**
100
+ * With no worker: redact `held` here, in a task of its own once the relay
101
+ * is over, each body up to the budget (the founder's rule is per body: a
102
+ * body of 64 KiB or less is redacted whole, as it always was).
103
+ */
104
+ alone(held: Held): void;
105
+ /**
106
+ * Record now, on this thread, the jobs still held, within
107
+ * MAIN_THREAD_BODY_BUDGET units in all: those that fit whole first, in
108
+ * the order handed over, then the rest; each keeps its place (seq). `final` is
109
+ * a moment after which nothing more is recorded (pagehide, settle()'s
110
+ * bound): a job past the budget is recorded cut, and one whose code has
111
+ * not loaded as not captured (noted: `left` while the code is on its
112
+ * way, `code-failed` when it failed for good), so the exchange is never
113
+ * lost and no body is recorded in the clear. Other
114
+ * moments (a hidden tab's drain, stop()) record only what fits whole,
115
+ * and leave the rest to the worker.
116
+ */
117
+ now(final: boolean): void;
118
+ }
119
+ /** Exposed for tests: the chunk loaders, and the page's worker forgotten. */
120
+ export declare const __bodyJobs: {
121
+ /** Load the code and the worker's start with these from now on (the page's import() when none), forgetting any worker so far. */
122
+ loaders(codeLoader?: () => Promise<BodyCode>, startLoader?: () => Promise<WorkerStart>): void;
123
+ /** The worker as it stands: undefined (not asked for), null (none), or the worker. */
124
+ worker: () => Worker | null | undefined;
125
+ /** prepare() is due in a task of its own (prepareSoon's idle or next task). */
126
+ soon: () => boolean;
127
+ /** Jobs not yet recorded that wait for the worker's start, in the page-wide wait (starting). */
128
+ starting: () => number;
129
+ /** Every job in the page-wide wait, recorded or not. */
130
+ waiting: () => number;
131
+ /** UTF-16 units of body the page's worker plumbing still holds (the wait, and jobs posted): none once recorded. */
132
+ retained: () => number;
133
+ };
134
+ export {};
@@ -0,0 +1,23 @@
1
+ /** The version this chunk was built as: the SDK refuses one of another (module-of.ts ownChunk). */
2
+ export { version } from "../package.json";
3
+ /** One exchange's bodies, as the main thread hands them over. */
4
+ export interface BodyJob {
5
+ requestBody: string | null;
6
+ responseBody: string | null;
7
+ /** The request's and the response's content-type, if any. */
8
+ requestType?: string;
9
+ responseType?: string;
10
+ /** The integrator's piiPatterns, compiled global (structured-cloned into the worker). */
11
+ patterns: RegExp[];
12
+ }
13
+ /** The two bodies as recorded. */
14
+ export interface BodyOut {
15
+ requestBody: string | null;
16
+ responseBody: string | null;
17
+ }
18
+ /**
19
+ * Both bodies of `job`, redacted. The worker passes no limits and redacts
20
+ * them whole; the main thread passes its budget (body-jobs.ts): `limit`
21
+ * UTF-16 units of the request body, and `responseLimit` of the response's.
22
+ */
23
+ export declare function redactBodies(job: BodyJob, limit?: number, responseLimit?: number): BodyOut;
@@ -0,0 +1 @@
1
+ var e,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,l={};((e,n)=>{for(var r in n)t(e,r,{get:n[r],enumerable:!0})})(l,{redactBodies:()=>at,version:()=>lt}),module.exports=(e=l,((e,l,s,a)=>{if(l&&"object"==typeof l||"function"==typeof l)for(let s of r(l))!i.call(e,s)&&void 0!==s&&t(e,s,{get:()=>l[s],enumerable:!(a=n(l,s))||a.enumerable});return e})(t({},"__esModule",{value:!0}),e));var s=/%[0-7][\da-f]|%(?:c[2-9a-f]|d[\da-f])%[89ab][\da-f]|%e0%[ab][\da-f]%[89ab][\da-f]|%e[1-9a-ce-f](?:%[89ab][\da-f]){2}|%ed%[89][\da-f]%[89ab][\da-f]|%f0%[9ab][\da-f](?:%[89ab][\da-f]){2}|%f[1-3](?:%[89ab][\da-f]){3}|%f4%8[\da-f](?:%[89ab][\da-f]){2}/gi;function a(e){return e.includes("%")?e.replace(s,e=>decodeURIComponent(e)):e}var o=new Set(["password","passwd","pwd","secret","token","accesstoken","refreshtoken","idtoken","authorization","auth","apikey","clientsecret","privatekey","session","sessionid","cookie","ssn","socialsecuritynumber","creditcard","cardnumber","cvv","cvc","pin","passphrase","pass1","pass2","currentpass","rpkey","codeverifier","rawkey","apikeyauth","setcookie","proxyauthorization","samlresponse","confirmkey","tokenhash","clerkticket","nonce","hmac","loginhash","magiclink","phpsessid","oauthverifier","sig","sid","sessid","csrf","xsrf","bearer","authentication","credentials","pass","tokenid","authkey","secretkey","accesskey","clientkey","signingkey","sessionkey","subscriptionkey","functionskey","factorcode","jwtassertion","samlassertion","clientassertion","secretaccesskey","accesskeysecret"]),c=new Set(["invitecode","invitationcode","authcode","authorizationcode","verificationcode","verifycode","confirmationcode","confirmcode","resetcode","mfacode","smscode","otpcode","totpcode","twofactorcode","2facode","logincode","passcode","oobcode","linkcode"]),u=new Set(["cardexpiry","cardexpiration","cardexpirydate","cardexpirationdate","cardexp","cardexpdate","cardexpmonth","cardexpyear","ccexp","ccexpiry","ccexpiration","ccexpdate","ccexpmonth","ccexpyear","creditcardexpiry","creditcardexpiration","expmonth","expyear","expirymonth","expiryyear","expirationmonth","expirationyear"]),f=/(?:password(?:\d|confirm|confirmation|new|old|repeat|again|verify|retype)?|passwd|secret|token|apikey|privatekey|passphrase|signature|sessionid|jwt|otp|credential|curl)$/,d=new Set(["pagetoken","nextpagetoken","prevpagetoken","previouspagetoken","pagingtoken","paginationtoken","nexttoken","prevtoken","previoustoken","continuationtoken","nextcontinuationtoken","cursortoken","synctoken","nextsynctoken","startingtoken","starttoken","skiptoken","deltatoken","resumptiontoken","scrolltoken","aftertoken","beforetoken"]),h=new Set(["auth","session","cookie","pin","sig"]);function p(e,t){return a(e).split("key"===t?/[[\]]+/:/[[\].]+/).map(e=>e.toLowerCase().replace(/[-_$+\s]/g,"")).filter(e=>""!==e)}function g(e,t){return!(d.has(e)||"page"===t&&h.has(e))&&(o.has(e)||c.has(e)||u.has(e)||f.test(e))}function k(e,t){return function(e,t){return e.some(e=>g(e,t))||e.length>1&&g(e.join(""),t)}(p(e,t),t)}var x=/(&|;(?=[^;&=#]+=|end$))/,m=1,b=/^(?:[a-z][a-z0-9+.-]*:\/\/|\/)[^?#]*[?#]./i,y=/[&;?#][^&;=?#]+=/;function v(e,t,n){let r=e.indexOf("#"),i=-1===r?e:e.slice(0,r),l=i.indexOf("?"),s=-1===l?i:i.slice(0,l),a=-1===l?null:i.slice(l+1),o=-1===r?null:e.slice(r+1),c=A(s,t)+(null===a?"":`?${$(a,t,n,s)}`)+(null===o?"":`#${O(o,t,n,s)}`);return c===e?e:c}function w(e,t=!1){if(t){let t=e.search(/\s/);return-1===t?e.length:t}let n=0,r=0,i=0;for(let t=0;t<e.length;t++){let l=e[t];if(/[\s,;"'<>\\`]/.test(l))return t;if("("===l)n++;else if("["===l)r++;else if("{"===l)i++;else{if(")"===l&&0===n--)return t;if("]"===l&&0===r--)return t;if("}"===l&&0===i--)return t}}return e.length}function z(e,t){let n=e;for(let e=0;e<4;e++){let e=a(n);if(e===n)break;n=e}for(let e of n.matchAll(/(?:^|[?&;#])([^?&;#=/\s]+)=/g))if(k(e[1],t))return!0;return!1}function $(e,t,n=0,r=""){let i=e.split(t.whole?/(&)/:x),l=i.filter((e,t)=>t%2==0),s={path:r,pairs:l,depth:n};return l.map(e=>{let r=e.indexOf("=");if(-1===r)return!0===t.bare?.(e)?"[REDACTED]":e;let i=e.slice(0,r),l=e.slice(r+1);if(""===l)return e;let o=function(e){let t=e.replace(/\+/g," ");if(!/%/.test(t))return t;if(/%(?![0-9A-Fa-f]{2})/.test(t))return e;try{return decodeURIComponent(t)}catch{return e}}(l),c=()=>`${i}=[REDACTED]`,u=t.before?.(i,l,s)??null;if(null!==u)return`${i}=${u}`;if(t.strict||(t.whole?function(e){let t=[],n=e.split(x);for(let e=0;e<n.length;e+=2){let r=n[e].indexOf("=");r>0&&t.push(n[e].slice(0,r))}return t}(e):[i]).some(e=>k(e,t.kind))||!0===t.value?.(i,l,o)){if(!0!==t.spaced)return c();let e=w(l,t.form),n=l.slice(e);return`${i}=${0!==e||t.form?"[REDACTED]":""}${t.tail?.(n)??n}`}if(n>=m&&(b.test(o)||y.test(o)))return"page"===t.kind||z(o,t.kind)?c():e;let f=function(e,t,n){return/^[a-z][a-z0-9+.-]*:\/\//i.test(e)?Z(e,t,n+1):e.startsWith("/")?v(e,t,n+1):y.test(e)?/[?#]/.test(e)?v(e,t,n+1):$(e,t,n+1):null}(o,t,n);return null!==f&&f!==o?t.whole?c():!0!==t.raw?`${i}=${encodeURIComponent(f)}`:l===o?`${i}=${f}`:encodeURIComponent(o)===l?`${i}=${encodeURIComponent(f)}`:c():a(o)!==o&&z(o,t.kind)?c():e}).map((e,t)=>(0===t?"":i[2*t-1])+e).join("")}function A(e,t){let n=e.split("/"),r=n.map(e=>e.split(";")[0]);return n.map((n,i)=>{if(!0===t.segment?.(n))return"[REDACTED]";let l=n.indexOf(";"),s=r[i],a=!0===t.head?.(e,s,i,r)?"[REDACTED]":s;return-1===l?a:a+n.slice(l).replace(/;([^;=]+)=([^;]*)/g,(e,n,r)=>{let i=!0===t.spaced?w(r,t.form):r.length;return i>0&&k(n,t.kind)?`;${n}=[REDACTED]${r.slice(i)}`:e})}).join("/")}function O(e,t,n,r=""){let i=e.indexOf("?");if(-1!==i){let l=e.slice(0,i);return`${A(l,t)}?${$(e.slice(i+1),t,n,`${r}/${l}`)}`}let l=e.indexOf("=");if(-1!==l&&!e.slice(0,l).includes("/"))return $(e,t,n,r);let s=-1===l?null:/^([^&;]*)([&;])/.exec(e);return null!==s?`${A(s[1],t)}${s[2]}${$(e.slice(s[0].length),t,n,`${r}/${s[1]}`)}`:A(e,t)}function Z(e,t,n){if(t.whole||!0===t.raw||!_.test(e))return I(e,t,n);let r;try{r=new URL(e)}catch{return I(e,t,n)}let i=r.search.slice(1),l=r.hash.slice(1),s=A(r.pathname,t),a=r.search?$(i,t,n,r.pathname):"",o=r.hash?O(l,t,n,r.pathname):"";return s===r.pathname&&a===i&&o===l&&""===r.username&&""===r.password?e:`${r.protocol}//${r.host}`+s+(r.search?`?${a}`:"")+(r.hash?`#${o}`:"")}var _=/^(?:https?:|[a-z][a-z0-9+.-]*:[/\\]{2})/i;function I(e,t,n){let r=/^([a-z][a-z0-9+.-]*:)([/\\]*)([^/\\?#]*)/i.exec(e),[i,l,s,a]=r,o=""===s?-1:a.lastIndexOf("@"),c=l+s+a.slice(o+1)+v(e.slice(i.length),t,n);return c===e?e:c}function S(e,t){let n,r=e.length-e.trimStart().length,i=e.length-e.trimEnd().length,l=e.slice(r,e.length-i);return/^(?:javascript|vbscript|data|blob):/i.test(l)?e:(n=/^[a-z][a-z0-9+.-]*:/i.test(l)?Z(l,t,0):v(l,t,0),n===l?e:e.slice(0,r)+n+e.slice(e.length-i))}var C=/[a-z][a-z0-9+.-]{0,31}:[/\\]{2}|(?<attr>\bcontent\s*=\s*(?:["']\s*)?\d[\d.]*\s*[;,]\s*url\s*=\s*["']?|\b(?:href|src|action|formaction|poster|cite|data|background|longdesc|content|data-src|data-href|xlink:href)\s*=\s*["']?|(?<![\w:.-])[\w:.-]{1,40}\s*=\s*["'](?=\.{0,2}\/|[?#]|[a-z][a-z0-9+.-]{0,31}:\/|[a-z][a-z0-9-]{0,30}[+.][a-z0-9+.-]{0,30}:|localhost:\d{1,5}[/?#]|(?:mailto|tel|sms|urn|data|javascript|vbscript|blob|about|xmpp|sip|sips|magnet|intent|bitcoin|geo|market|news):)|\burl\(\s*["']?)(?=[^\s"'<>])/gi,j=/[\s"'<>\\^`{|}]/,E=".,;:!?",D=/[a-z][a-z0-9+.-]{0,31}:\/\//iy;function R(e,t,n,r){let i=t,l=0,s=0;for(;i<e.length;i++){let t=e[i];if(j.test(t)||r&&","===t&&(D.lastIndex=i+1,D.test(e)))break;if(n)if("("===t)l++;else if("["===t)s++;else if(")"===t||"]"===t){if(0===(")"===t?l:s))break;")"===t?l--:s--}}return function(e,t,n){let r=0,i=0;for(let l=t;l<n;l++){let t=e[l];"("===t?r++:")"===t?r--:"["===t?i++:"]"===t&&i--}for(;n>t;){let t=e[n-1];if(")"===t){if(r>=0)break;r++}else if("]"===t){if(i>=0)break;i++}else if(!E.includes(t))break;n--}return n}(e,t,i)}var N=/url\(\s*["']?/iy;var B="[REDACTED]",T=new Set(["expiry","expirydate","expiration","expirationdate","expdate","exp"]),W=new Set(["cardnumber","creditcard","creditcardnumber","ccnumber","cardnum","pan","cvv","cvc"]),U="[UNPARSEABLE_BODY_NOT_REDACTED]",F=[/^\[Blob: \d+ bytes, truncated\]$/,/^\[Blob: \d+ bytes\]$/,/^\[Binary: \d+ bytes\]$/,/^\[Response body too large: \d+ bytes\]$/,/^\[ReadableStream\]$/,/^\[Unreadable body\]$/,/^\[(?:arraybuffer|blob|document|json|text|) response\]$/];function L(e){return p(e,"key").join("")}var P=/^[A-Za-z]+(?:[-_][A-Za-z]+)*$/,J=/^[A-Za-z][a-z]+(?:[A-Z][a-z]+)+$/,M=new Set(["authorization_code","urn:ietf:params:oauth:grant-type:device_code"]),q=new Set(["code","devicecode"]),K=new Set([...q,"state"]),Y=new Set(["redirecturi","clientid","verificationuri"]);function G(e){let t=!1,n=!1,r=!1,i=!1;for(let[l,s]of e){if("granttype"===l&&M.has(s.trim().toLowerCase())||"codeverifier"===l)return!0;q.has(l)&&(t=!0,s.length>=10&&(r=!0)),Y.has(l)&&(n=!0),"state"===l&&H(s)&&(i=!0)}return t&&(n||i&&r)}function H(e){return e.length>=16&&/^[A-Za-z0-9_\-.~+/=]+$/.test(e)&&/[A-Za-z]/.test(e)&&(/\d/.test(e)||/[a-z]/.test(e)&&/[A-Z]/.test(e))&&!function(e){return!!P.test(e)&&(e.length<=16||J.test(e)||/^[A-Za-z][a-z]+(?:[-_][A-Za-z][a-z]+)+$/.test(e))}(e)&&!function(e){return/^(?:[A-Z]+|[A-Z]?[a-z]+)\d*(?:[-_](?:(?:[A-Z]+|[A-Z]?[a-z]+)\d*|\d+))+$/.test(e)&&/(?:^|[-_])[A-Za-z]+(?:[-_]|$)/.test(e)}(e)}var Q=new Set(["passcode"]);function V(e){return k(e,"key")}var X=new Set(["credentials","authentication","pass"]),ee=/[a-zA-Z0-9.-]{1,253}\.[a-zA-Z]{2,63}/y;function te(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||46===e||95===e||37===e||43===e||45===e}var ne=/(?<![A-Za-z0-9])(?:kep_[A-Za-z0-9_-]{20,}|gh[pousr]_[A-Za-z0-9]{36,}|github_pat_[A-Za-z0-9_]{22,}|glpat-[A-Za-z0-9_-]{20,}|xox[abprse]-[A-Za-z0-9-]{10,}|[sr]k_(?:live|test)_[A-Za-z0-9]{16,}|sk-(?:proj|ant)-[A-Za-z0-9_-]{20,}|npm_[A-Za-z0-9]{36,}|whsec_[A-Za-z0-9+/=]{24,}|(?:AKIA|ASIA)[0-9A-Z]{16,}|AIza[0-9A-Za-z_-]{35,})/g,re=/\b\d{3}-\d{2}-\d{4}\b/g,ie=/(?:\+\d{1,3}[ .-]?)?(?:\(\d{3}\)[ .-]?|\b\d{3}[ .-])\d{3}[ .-]\d{4}\b/g,le=/(?<![A-Za-z0-9_-])eyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\b/g,se=/(?<![\d.])(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)(?![\d.])/g;function ae(e){if(e.length<13||e.length>19)return!1;let t="4"===e[0]&&(13===e.length||16===e.length||19===e.length),n=/^(5[1-5]|2[2-7])/.test(e)&&16===e.length,r=/^3[47]/.test(e)&&15===e.length,i=/^6(?:011|5)/.test(e)&&16===e.length,l=/^(?:35|3[068])/.test(e)&&e.length>=14&&e.length<=19;return!!(t||n||r||i||l)&&function(e){let t=0,n=!1;for(let r=e.length-1;r>=0;r--){let i=e.charCodeAt(r)-48;if(i<0||i>9)return!1;n&&(i*=2,i>9&&(i-=9)),t+=i,n=!n}return t%10==0}(e)}function oe(e,t,n){for(let r of e.matchAll(t))""!==r[0]&&n.push([r.index,r.index+r[0].length])}function ce(e,t,n){oe(e,le,n),oe(e,ne,n),function(e,t){let n=0,r=e.indexOf("@");for(;-1!==r;){let i=Math.max(n,r-64),l=r;for(;l>i&&te(e.charCodeAt(l-1));)l--;if(l<r){ee.lastIndex=r+1;let i=ee.exec(e);if(i){n=r+1+i[0].length,t.push([l,n]),r=e.indexOf("@",n);continue}}r=e.indexOf("@",r+1)}}(e,n),oe(e,re,n),oe(e,ie,n),oe(e,se,n),function(e,t){for(let n of e.matchAll(/\b(?:\d[ -]?){12,18}\d\b/g))ae(n[0].replace(/[^0-9]/g,""))&&t.push([n.index,n.index+n[0].length])}(e,n);for(let r of t)oe(e,r,n)}function ue(e,t){if(0===t.length)return e;t.sort((e,t)=>e[0]-t[0]||t[1]-e[1]);let n="",r=0,[i,l,s]=t[0];for(let a=1;a<=t.length;a++){let o=t[a];void 0!==o&&o[0]<l?(o[1]>l&&(l=o[1]),s=void 0):(n+=e.slice(r,i)+(s??B),r=l,void 0!==o&&([i,l,s]=o))}return n+e.slice(r)}var fe=64,de={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"};var he=JSON.stringify(B),pe={kind:"param",strict:!1,whole:!1,raw:!0},ge={...pe,spaced:!0,tail:e=>ve(e,xe)},ke={...pe,spaced:!0,form:!0},xe={...pe,spaced:!0,list:!0},me=/^(?=[^={}<>"'\\^`|]*(?:=|$))(?:(?:[a-z][a-z0-9+.-]*:\/|[a-z][a-z0-9-]*[+.][a-z0-9+.-]*:|localhost:\d{1,5}[/?#]|(?:mailto|tel|sms|urn|data|javascript|vbscript|blob|about|xmpp|sip|sips|magnet|intent|bitcoin|geo|market|news):|\.{0,2}\/)[^\s?#]*[?#]|(?:[\w.~%-][\w.~%/-]*)?[?#][^\s=&#]+=|\.{0,2}\/[^\s?#;=]*;)/i,be=/^\S*/,ye=/^[^\r\n]*/gm;function ve(e,t=pe){let n=e.replace(ye,e=>me.test(be.exec(e)[0])?S(e,t):e),r=function(e,t){let n=[];for(let[r,i]of function(e,t=!1){let n=[];C.lastIndex=0;for(let r=C.exec(e);null!==r;r=C.exec(e)){let i=r.index+(r.groups?.attr?.length??0);N.lastIndex=i;let l=void 0!==r.groups?.attr&&N.test(e);l&&(i=N.lastIndex);let s=r.groups?.attr??"",a=R(e,i,!/["']$/.test(s)||/^url\(/i.test(s)||l,t);"{"===e[a]&&a>i&&"$"===e[a-1]&&a--,a>i&&n.push([i,a]),C.lastIndex=Math.max(a,r.index+r[0].length,i+1)}return n}(e,!0===t.list)){let l=e.slice(r,i),s=S(l,t);s!==l&&n.push([r,i,s])}return n}(n,t);if(0===r.length)return ze(n,t);let i="",l=0;for(let[e,t,s]of r)i+=n.slice(l,e)+s,l=t;return ze(i+n.slice(l),t)}var we=/[a-z][a-z0-9+.-]{0,31}:(?:\\\/|\\u002[fF]){2}(?:[^\s"'<>\\^`{|}()[\]/]|\/(?![dgimsuvy]*(?![\w$]))|\\\/|\\u002[fF])*/gi;function ze(e,t){return/:(?:\\\/|\\u002[fF])/.test(e)?e.replace(we,e=>{let n="",r=[];for(let t=0;t<e.length;){r.push(t);let i=$e.exec(e.slice(t,t+6));n+=null===i?e[t]:"/",t+=null===i?1:i[0].length}r.push(e.length);let i=S(n,t);if(i===n)return e;let l=0;for(;l<i.length&&i[l]===n[l];)l++;let s=0;for(;s<i.length-l&&s<n.length-l&&i[i.length-1-s]===n[n.length-1-s];)s++;let a=/\\\/|\\u002[fF]/.exec(e)[0];return e.slice(0,r[l])+i.slice(l,i.length-s).replace(/\//g,a)+e.slice(r[n.length-s])}):e}var $e=/^(?:\\\/|\\u002[fF])/;function Ae(e){if(!/[%+]/.test(e))return!1;let t=Re(e);if(t===e)return!1;if(a(t)!==t&&z(t,"param"))return!0;let n=ve(t);if(n===t)return!1;let r=[];return Ke(t,r),ue(t,r)!==n}function Oe(e,t){return"scalar"===t.kind?/^(?:true|false)$/.test(e.slice(t.start,t.end)):"array"===t.kind&&t.items.every(t=>Oe(e,t))}function Ze(e,t,n,r,i,l){let s=e=>{l.push([t.start,t.end,e])};if("deep"===t.kind)return s(he);if("scalar"===t.kind&&e.startsWith("null",t.start)||Oe(e,t))return;let a=null!==n&&function(e){return p(e,"key").some(e=>Q.has(e)||e.endsWith("otp"))}(n);if(null!==n&&V(n)&&(!a||!function(e){return"object"===e.kind||"array"===e.kind}(t))&&("string"===t.kind||!function(e){return p(e,"key").some(e=>X.has(e))}(n)))return s(he);if("scalar"===t.kind){let n=e.slice(t.start,t.end),r=/^\d+$/.test(n)?n:function(e){if(!/^-?\d/.test(e))return null;let t=Number(e);return Number.isInteger(t)?String(t):null}(n);return void(null!==r&&ae(r)&&s(he))}if("string"===t.kind){let e=Ce(t.value,r,i)??function(e,t){if(!e)return e;let n=[];return Ke(e,n,"string"),ce(e,t,n),ue(e,n)}(ve(t.value),i);return void(e!==t.value&&s(JSON.stringify(e)))}if("array"===t.kind){for(let s of t.items)Ze(e,s,n,r+1,i,l);return}let o=t.entries.some(({key:e,value:t})=>Ie.has(e.toLowerCase())&&"string"===t.kind&&V(t.value)),c=t.entries.some(({key:e})=>W.has(L(e))),u=G(t.entries.map(({key:e,value:t})=>[L(e),"string"===t.kind?t.value:""]));for(let{key:n,value:s}of t.entries)Oe(e,s)||(c&&T.has(L(n))?l.push([s.start,s.end,he]):!(u&&K.has(L(n))||a&&"code"===L(n))||"scalar"===s.kind&&e.startsWith("null",s.start)?o&&Se.has(n.toLowerCase())?l.push([s.start,s.end,he]):Ze(e,s,V(n)?n:null,r+1,i,l):l.push([s.start,s.end,he]))}function _e(e,t,n){let r=[];return Ze(e,function(e,t){let n=0,r=()=>{for(;n<e.length;){let t=e.charCodeAt(n);if(32!==t&&9!==t&&10!==t&&13!==t)break;n++}},i=()=>{n++;let t="",r=n;for(;'"'!==e[n];){if("\\"!==e[n]){n++;continue}t+=e.slice(r,n);let i=e[n+1];"u"===i?(t+=String.fromCharCode(parseInt(e.slice(n+2,n+6),16)),n+=6):(t+=de[i],n+=2),r=n}return t+=e.slice(r,n),n++,t},l=t=>{r();let s=n;if(t>fe)return(()=>{let t=0;do{let r=e[n];if('"'===r){for(n++;'"'!==e[n];)n+="\\"===e[n]?2:1;n++}else if("{"===r||"["===r)t++,n++;else if("}"===r||"]"===r)t--,n++;else{if(0===t&&(","===r||":"===r))break;n++}}while(t>0||n<e.length&&!/[\s,\]}]/.test(e[n]))})(),{kind:"deep",start:s,end:n};let a=e[n];if("{"===a){n++;let a=[];if(r(),"}"===e[n])n++;else for(;;){r();let s=i();if(r(),n++,a.push({key:s,value:l(t+1)}),r(),"}"===e[n++])break}return{kind:"object",start:s,end:n,entries:a}}if("["===a){n++;let i=[];if(r(),"]"===e[n])n++;else for(;i.push(l(t+1)),r(),"]"!==e[n++];);return{kind:"array",start:s,end:n,items:i}}if('"'===a){let e=i();return{kind:"string",start:s,end:n,value:e}}for(;n<e.length&&!/[\s,\]}]/.test(e[n]);)n++;return{kind:"scalar",start:s,end:n}};return l(t)}(e,t),null,t,n,r),function(e,t){if(0===t.length)return e;t.sort((e,t)=>e[0]-t[0]);let n="",r=0;for(let[i,l,s]of t)n+=e.slice(r,i)+s,r=l;return n+e.slice(r)}(e,r)}var Ie=new Set(["key","name","header"]),Se=new Set(["value","values","expected","actual"]);function Ce(e,t,n){if(!/^\s*[[{]/.test(e))return null;try{JSON.parse(e)}catch{return null}return _e(e,t+1,n)}function je(e,t,n=[]){if(null==e||""===e)return e??null;if(function(e){return F.some(t=>t.test(e))}(e))return e;if((t??"").toLowerCase().includes("json")||/^\s*[[{]/.test(e)){try{JSON.parse(e)}catch{return U}return _e(e,0,n)}let r=e.endsWith(Ee),i=r?e.slice(0,-Ee.length):e,l=ve(i,ke),s=function(e,t){if(Ve.test(t))return function(e){return e.split("&").every(Ge)}(e);if(Qe.test(t))return!0;let n=e.endsWith(Ee),r=(n?e.slice(0,-Ee.length):e).split("&"),i=r.length-1;return r.some(e=>e.includes("="))&&r.every((e,t)=>n&&t===i||Ge(e))}(r?l+Ee:l,t??""),a=s||l===i?l:ve(i,ge),o=r?a+Ee:a,c=function(e,t,n){if(!Ve.test(t))return null;let r=e.endsWith(Ee),i=r?e.slice(0,-Ee.length):e,l=Xe.exec(t),s=null!==l?l[1]??l[2]:/^--([^\r\n]{1,200})\r?\n/.exec(i)?.[1]??null;if(null===s)return null;let a="--"+s,o=i.startsWith(a)?0:i.indexOf("\n"+a);if(-1===o)return null;o>0&&(o+=1);let c=[];for(it(i,0,o,n,c);;){let e=o+a.length;if(i.startsWith("--",e)&&-1===i.indexOf("\n"+a,e)){it(i,e+2,i.length,n,c);break}let t=i.indexOf("\n",e);if(-1===t)break;let r=t+1,l=-1;for(;r<i.length;){let e=i.indexOf("\n",r);if(-1===e)break;if(e===r||e===r+1&&"\r"===i[r]){l=e+1;break}r=e+1}let s=-1===l?i.length:l;if(it(i,t+1,s,n,c),-1===l)break;let u=i.indexOf("\n"+a,l),f=-1===u?i.length:u;-1!==u&&f>l&&"\r"===i[f-1]&&f--;let d=i.slice(t+1,s),h=et.exec(d),p=null===h?"":h[1]??h[2],g=tt.test(d)||k(p,"param")?null:Ce(i.slice(l,f),0,n);if(tt.test(d)||k(p,"param")?c.push([l,f]):null!==g&&g!==i.slice(l,f)?c.push([l,f,g]):it(i,l,f,n,c),-1===u)break;o=u+1}return ue(i,c)+(r?Ee:"")}(o,t??"",n);if(null!==c)return c;if(Ve.test(t??"")&&!s)return nt;let u=function(e,t,n,r=!1){let i=e.endsWith(Ee),l=i?e.slice(0,-Ee.length):e,s=l.split("&");if(!n){let e=[];return Ke(l,e,r?"code":"text"),0===e.length?null:(ce(l,t,e),ue(l,e)+(i?Ee:""))}let a=[];ce(l,t,a);let o,c=/[%+]/.test(l),u=Be(c?l.length:0),f=Ye.test(l),d=[],h=G(s.flatMap(e=>{let t=e.indexOf("=");return-1===t?[]:[[L(Re(e.slice(0,t))),Re(e.slice(t+1))]]})),p=[],g=0;for(let e of s){let n=e.indexOf("="),r=-1===n?g+e.length:g+n,i=g+e.length,s=u.length;c&&Ue(l,g,r,u),-1!==n&&c&&(Te(u,"=",r,r+1),Ue(l,r+1,i,u)),-1!==n&&(k(e.slice(0,n),"param")||h&&K.has(L(Re(e.slice(0,n)))))||-1!==n&&Ae(l.slice(r+1,i))?a.push([r+1,i]):-1!==n&&null!==(o=rt(l,r+1,i,t))?3===o.length?p.push(o):a.push(o):f&&(He(l,g,i,a),c&&d.push(s,u.length)),g+=e.length,g<l.length&&(c&&Te(u,"&",g,g+1),g++)}if(c){let e=[],n=u.parts.join("");ce(n,t,e);for(let t=0;t<d.length;t+=2)He(n,d[t],d[t+1],e);for(let[t,n]of e)a.push([u.start[t],u.end[n-1]])}let x=a.filter(([e,t])=>!function(e,t,n){let r=0,i=e.length-1;for(;r<=i;){let l=r+i>>1,[s,a]=e[l];if(t<s)i=l-1;else{if(!(t>=a))return n<=a;r=l+1}}return!1}(p,e,t));return ue(l,[...x,...p])+(i?Ee:"")}(o,n,s,/(?:java|ecma)script/i.test(t??""));return null!==u?u:function(e,t=[]){if(!e)return e;let n=[];return ce(e,t,n),ue(e,n)}(o,n)}var Ee="...[truncated]",De=/^[A-Za-z0-9_.~!*'()%+[\]-]*$/;function Re(e){if(!/[%+]/.test(e))return e;let t=Be(e.length);return Ue(e,0,e.length,t),t.parts.join("")}function Ne(e,t){if(t+2>e.length)return-1;let n=parseInt(e[t],16),r=parseInt(e[t+1],16);return Number.isNaN(n)||Number.isNaN(r)?-1:16*n+r}function Be(e){return{parts:[],start:new Int32Array(e),end:new Int32Array(e),length:0}}function Te(e,t,n,r){e.parts.push(t);for(let i=0;i<t.length;i++)e.start[e.length]=n,e.end[e.length]=r,e.length++}function We(e,t,n,r){if(!(t>=n)){r.parts.push(e.slice(t,n));for(let e=t;e<n;e++)r.start[r.length]=e,r.end[r.length]=e+1,r.length++}}function Ue(e,t,n,r){let i={parts:r.parts.length,length:r.length},l=t,s=t;for(;s<n;){let a=e.charCodeAt(s);if(43!==a&&37!==a){s++;continue}if(We(e,l,s,r),43===a){Te(r," ",s,s+1),l=++s;continue}let o=s+3<=n?Ne(e,s+1):-1,c=-1,u=128,f=191;o>=0&&o<128?c=0:o>=194&&o<=223?c=1:o>=224&&o<=239?(c=2,224===o&&(u=160),237===o&&(f=159)):o>=240&&o<=244&&(c=3,240===o&&(u=144),244===o&&(f=143));let d=c<=0?o:o&63>>c;for(let t=1;t<=c&&d>=0;t++){let r=s+3*t,i=r+3<=n&&"%"===e[r]?Ne(e,r+1):-1;d=i<(1===t?u:128)||i>(1===t?f:191)?-1:d<<6|63&i}if(c<0||d<0)return r.parts.length=i.parts,r.length=i.length,void We(e,t,n,r);let h=s+3*(c+1);Te(r,String.fromCodePoint(d),s,h),l=s=h}We(e,l,n,r)}var Fe=/(^|[?&;\n>#]|(?<!\b(?:var|let|const)|[(){}])[ \t\r\f\v])([\w%-]*(?:\[[\w%-]*\][\w%-]*)*)=/g,Le=/(^|[?&;\n]|(?<=[\w/%~-])(?<!\*\/|(?:^|[^\w$/%~.-])(?:static|accessor))#)([\w%-]*(?:\[[\w%-]*\][\w%-]*)*)=/g,Pe=/(^|[?&]|(?<=[\w/%~-])(?<!\*\/|(?:^|[^\w$/%~.-])(?:static|accessor))#)([\w%-]*(?:\[[\w%-]*\][\w%-]*)*)=/g,Je=/(^|[?&;,\s]|(?<=[\w/%~-])#)([\w%-]*(?:\[[\w%-]*\][\w%-]*)*)=/g,Me=/(?:[^\s&"'`<>\\,;(){}[\]$]|\$(?!\{))+/y,qe=/[^&]+/y;function Ke(e,t,n="text"){let r="code"===n?Le:"string"===n?Pe:"header"===n?Je:Fe,i="text"===n&&/<script/i.test(e)?function(e){let t=[],n=/<script\b/gi,r=/<\/script\s*>/gi;for(let i=n.exec(e);null!==i;i=n.exec(e)){let l=e.indexOf(">",i.index);if(-1===l)break;r.lastIndex=l+1;let s=r.exec(e),a=null===s?e.length:s.index;t.push([l+1,a]),n.lastIndex=a}return t}(e):[],l=0;r.lastIndex=0;for(let s=r.exec(e);null!==s;s=r.exec(e)){if(!k(s[2],"param"))continue;if(i.length>0&&(/^[ \t\r\f\v>]$/.test(s[1])||"#"===s[1]&&(!/[\w/%~-]/.test(e[s.index-1]??"")||e.startsWith("*/",s.index-2)||/(?:^|[^\w$/%~.-])(?:static|accessor)$/.test(e.slice(Math.max(0,s.index-9),s.index))))){for(;l<i.length&&i[l][1]<=s.index;)l++;if(l<i.length&&i[l][0]<=s.index)continue}let a=s.index+s[0].length;Me.lastIndex=a;let o=Me.exec(e);if(null===o)continue;"string"===n&&(qe.lastIndex=a,o=qe.exec(e)??o);let c=a+o[0].length;t.push([a,c]),r.lastIndex=c}}var Ye=/[?;\n]|%(?:3[FfBb]|26|0[Aa])/;function Ge(e){let t=e.indexOf("="),n=(-1===t?e:e.slice(0,t)).trim();return De.test(n)&&(-1===t||!/\s/.test(e.slice(t+1)))}function He(e,t,n,r){let i=!1;for(let r=t;r<n&&!i;r++){let t=e.charCodeAt(r);i=63===t||59===t||38===t||10===t}if(!i)return;let l=[];Ke(e.slice(t,n),l);for(let[e,n]of l)r.push([t+e,t+n])}var Qe=/^\s*(?:application\/x-www-form-urlencoded|multipart\/form-data)\s*(?:;|$)/i,Ve=/^\s*multipart\/form-data\s*(?:;|$)/i,Xe=/;\s*boundary\s*=\s*(?:"([^"\r\n]{1,200})"|([^\s;"]{1,200}))/i,et=/^content-disposition\s*:[^\n]*?;\s*name\s*=\s*(?:"([^"\r\n]*)"|([^\s;]+))/im,tt=/^content-disposition\s*:[^\n]*?;\s*filename\*?\s*=/im,nt="[Unreadable body]";function rt(e,t,n,r){let i=e.slice(t,n);if(!/^(?:%7B|%5B|[[{])/i.test(i))return null;if(/[%+]/.test(i)){let e=Re(i),l=Ce(e,0,r);return null===l||l===e?null:[t,n]}let l=Ce(i,0,r);return null===l||l===i?null:[t,n,l]}function it(e,t,n,r,i){if(t>=n)return;let l=e.slice(t,n),s=[];ce(l,r,s),Ke(l,s);for(let[e,n]of s)i.push([t+e,t+n])}var lt="3.1.0-rc.2";function st(e,t,n,r){return null===e||e.length<=r?je(e,t,n):function(e,t){return`[Body cut: ${e} of ${t} characters kept, unverified]\n`}(r,e.length)+(r>0?je(e.slice(0,r)+Ee,t,n)??"":"")}function at(e,t=1/0,n=t){return{requestBody:st(e.requestBody,e.requestType,e.patterns,t),responseBody:st(e.responseBody,e.responseType,e.patterns,n)}}//# sourceMappingURL=body-redact.js.map