@keploy/capture-sdk 3.1.0 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/network.d.ts CHANGED
@@ -48,11 +48,11 @@ declare function serializeXhrBody(body: Document | XMLHttpRequestBodyInit | null
48
48
  */
49
49
  export declare function recordedUrl(raw: string): string;
50
50
  export declare class NetworkInterceptor {
51
- private callback;
51
+ private onNetwork;
52
52
  private privacyEngine;
53
- private maxBodySize;
53
+ private bodyCap;
54
54
  /** Absolute URLs never observed — the SDK's own ingest endpoint. */
55
- private ignored;
55
+ private ignoredUrls;
56
56
  private active;
57
57
  /**
58
58
  * Exchanges answered while recording whose bodies are still being read
@@ -85,7 +85,7 @@ export declare class NetworkInterceptor {
85
85
  * fetch(x); pause()` lost x. Every event the callback gets has been
86
86
  * admitted.
87
87
  */
88
- private admit;
88
+ private admitCall;
89
89
  /** Which start() an exchange belongs to: one from before a stop() never reports into a later start(). */
90
90
  private run;
91
91
  private originalFetch;
@@ -96,20 +96,25 @@ export declare class NetworkInterceptor {
96
96
  /** The capture's privacyMode: `strict` records no body and no query value. */
97
97
  privacyMode?: CaptureConfig["privacyMode"]);
98
98
  /** True for a request the interceptor must pass through untouched. */
99
- private ignores;
99
+ private ignoresUrl;
100
100
  /**
101
101
  * `place`, when given, is asked for an exchange's place in the
102
102
  * recording at the moment it is reported -- where it was recorded
103
103
  * before its masking moved to a task of its own (see emit) -- and the
104
104
  * answer is handed to `callback` beside the event.
105
105
  */
106
- start(callback: NetworkEventCallback, admit?: () => boolean, place?: () => number): void;
106
+ start(callback: NetworkEventCallback, admit?: () => boolean, place?: () => number, deferPrepare?: boolean): void;
107
+ /**
108
+ * Schedule the idle body-worker prepare for an active capture (used when
109
+ * start() deferred it while rrweb loaded).
110
+ */
111
+ prepare(): void;
107
112
  /**
108
113
  * Ask for the body code now (body-jobs.ts, askForCode), for a capture
109
114
  * that will redact bodies with it: none for one that masks them whole.
110
115
  */
111
116
  askForCode(): void;
112
- stop(): void;
117
+ stop(discard?: boolean): void;
113
118
  /**
114
119
  * Wait at most `timeoutMs` for the exchanges answered before stop() to
115
120
  * report, then report nothing more. An endless stream never ends; the
@@ -154,10 +154,10 @@ export declare class KeployCaptureRecorder {
154
154
  private metadata;
155
155
  private config;
156
156
  private onEvent;
157
- private onSessionEnd;
158
- private onScrubOversized;
157
+ private sessionEndCb;
158
+ private scrubOversizedCb;
159
159
  /** Told how rrweb's import went once the network is back -- null when it landed; see startRRWeb(). */
160
- private onRRWeb;
160
+ private rrwebCb;
161
161
  /** Whether rrweb's import, held by the page's leave, is still to land; see startRRWeb(). */
162
162
  private landing;
163
163
  /** The `online` listener that retries rrweb's import; see startRRWeb(). */
@@ -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.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
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.2.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
@@ -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.1.0\",\n \"description\": \"Lightweight SDK to capture UI flows from real users - DOM recording, network interception, PII masking\",\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.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 +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.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
+ 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.2.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.1.0\",\n \"description\": \"Lightweight SDK to capture UI flows from real users - DOM recording, network interception, PII masking\",\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.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 +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.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
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.2.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
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/strict-attributes.ts","../package.json"],"names":["kept","name","tag","svg","attributes","PAGE_METAS","test","String","STRICT_KEPT","SVG_KEPT","includes","HTML_KEPT","strict_attributes_exports","__export","version","module","exports"],"mappings":"aAmEO,SAASA,EACdC,EACAC,EACAC,EACAC,GAEA,MAAgB,YAATH,EACK,SAARC,QACiB,IAAfE,IACqC,iBAA7BA,EAAW,eACjBC,EAAWC,KAAKC,OAAOH,EAAWH,QACtCO,EAAYF,KAAKL,KAEb,KADDE,EAAMM,EAAWP,EAAIQ,SAAS,KAAO,KAAOC,IAAYL,KAAKL,EAEtE,C,+HAjFAW,EAAA,G,yDAAAC,CAAAD,EAAA,CAAAZ,KAAA,IAAAA,EAAAc,QAAA,IAAAA,IAAAC,OAAAC,S,EAAAJ,E,gNCEE,IAAAE,EAAW,QD+CPN,EACJ,icAEIG,EACJ,4nBAEIF,EACJ,46BAEIJ,EACJ","sourcesContent":["/* ------------------------------------------------------------------ */\n/* @keploy/capture-sdk - strict's attribute allow-list */\n/* ------------------------------------------------------------------ */\n/*\n * THIS FILE IS A CHUNK OF ITS OWN (dist/strict-attributes.{mjs,js}, the\n * package's \"./strict-attributes\" export). The recorder loads it under\n * `privacyMode: \"strict\"` alone, beside rrweb's import and in parallel\n * with it, and starts no recording until both have loaded\n * (recorder.ts loadRecorder), so no snapshot is ever taken without it; a\n * load that fails ends the capture with\n * KUI_E_STRICT_ATTRIBUTES_UNAVAILABLE and records nothing. balanced and\n * off never load it. It imports nothing but the version it exports (a\n * string the build inlines), and the main builds import it\n * only by that name (dist/index.mjs also by its file beside it, for a page\n * with no bundler): __tests__/bundle-size.test.ts fails when\n * one of its names is in dist/index.mjs, dist/index.bundler.mjs or\n * dist/index.js. Why a chunk: the three lists are about 954 B gzipped\n * of distinct names, and with them in the base bundle every build was\n * over its budget (founder's ruling, 2026-11-13: never slow the page).\n *\n * STRICT RECORDS NO PAGE TEXT (README, Privacy): what a text node holds,\n * rrweb masks; what an attribute holds, privacy.ts blanks unless this\n * file keeps it, by an ALLOW-LIST. A list of the attributes that hold\n * text missed every one it did not name -- Livewire's wire:snapshot,\n * Alpine's x-data, an Astro island's props, a custom element's message\n * -- so strict keeps only the names whose value is the page's\n * structure: an id, a class, a token, a number, an id reference, SVG\n * geometry, ARIA state, a test id, rrweb's own. A URL, CSS, a srcset and\n * a srcdoc go through their own rules (privacy.ts OWN_RULE, the URL\n * rule). Every other value is blanked, a field's value rrweb already\n * masked kept as it is, and a meta's `content` kept only where the meta\n * configures the page. Blank, not asterisks: the flow engine reads an\n * empty aria-label as none, so a strict recording never names an\n * element by a label it cannot have.\n *\n * ARIA under strict: kept, the attributes that describe the widget -- its\n * structure (level, posinset, setsize, row/col counts and indexes), its\n * relationships (id references: controls, describedby, labelledby, owns,\n * details, errormessage, flowto), its configuration (autocomplete,\n * haspopup, multiline, multiselectable, orientation, readonly, required,\n * disabled, modal, live, atomic, busy, relevant) and whether it is open or\n * hidden (expanded, hidden). Blanked, every one that reflects what the\n * visitor chose or entered: value now/min/max/text (a two-thumb slider's\n * min and max are the other thumb's chosen value), checked, selected,\n * pressed, current, sort, invalid (a verdict on what they typed) and\n * activedescendant (the id of the option they are on). And on HTML\n * elements `checked` and `selected` for the same reason (privacy.ts drops\n * them).\n */\nconst STRICT_KEPT =\n /^(?: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+)$/;\n/** Kept on an HTML element (not a custom one, whose attributes are its own): a token, a number, an id reference. */\nconst HTML_KEPT =\n /^(?: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)$/;\n/** Kept on an SVG element only: its geometry and paint, by exact name. */\nconst SVG_KEPT =\n /^(?: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)$/;\n/** A meta whose `content` configures the page, not one that describes it. */\nconst PAGE_METAS =\n /^(viewport|color-scheme|theme-color|referrer|robots|format-detection)$/i;\n\n/**\n * Whether strict keeps attribute `name`'s value on a `tag` element (an SVG\n * one when `svg`), by name alone; a meta's `content` by the meta's own\n * `attributes`. privacy.ts asks this for every attribute but those with\n * their own rule, and blanks what it answers false for.\n */\nexport function kept(\n name: string,\n tag: string,\n svg: boolean,\n attributes?: Record<string, unknown>,\n): boolean {\n return name === \"content\"\n ? tag === \"meta\" &&\n attributes !== undefined &&\n (typeof attributes[\"http-equiv\"] === \"string\" ||\n PAGE_METAS.test(String(attributes.name)))\n : STRICT_KEPT.test(name) ||\n (svg ? SVG_KEPT : tag.includes(\"-\") ? null : HTML_KEPT)?.test(name) ===\n true;\n}\n\n/** The version this chunk was built as: the SDK refuses one of another (module-of.ts ownChunk). */\nexport { version } from \"../package.json\";\n","{\n \"name\": \"@keploy/capture-sdk\",\n \"version\": \"3.1.0\",\n \"description\": \"Lightweight SDK to capture UI flows from real users - DOM recording, network interception, PII masking\",\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/strict-attributes.ts","../package.json"],"names":["kept","name","tag","svg","attributes","PAGE_METAS","test","String","STRICT_KEPT","SVG_KEPT","includes","HTML_KEPT","strict_attributes_exports","__export","version","module","exports"],"mappings":"aAmEO,SAASA,EACdC,EACAC,EACAC,EACAC,GAEA,MAAgB,YAATH,EACK,SAARC,QACiB,IAAfE,IACqC,iBAA7BA,EAAW,eACjBC,EAAWC,KAAKC,OAAOH,EAAWH,QACtCO,EAAYF,KAAKL,KAEb,KADDE,EAAMM,EAAWP,EAAIQ,SAAS,KAAO,KAAOC,IAAYL,KAAKL,EAEtE,C,+HAjFAW,EAAA,G,yDAAAC,CAAAD,EAAA,CAAAZ,KAAA,IAAAA,EAAAc,QAAA,IAAAA,IAAAC,OAAAC,S,EAAAJ,E,gNCEE,IAAAE,EAAW,QD+CPN,EACJ,icAEIG,EACJ,4nBAEIF,EACJ,46BAEIJ,EACJ","sourcesContent":["/* ------------------------------------------------------------------ */\n/* @keploy/capture-sdk - strict's attribute allow-list */\n/* ------------------------------------------------------------------ */\n/*\n * THIS FILE IS A CHUNK OF ITS OWN (dist/strict-attributes.{mjs,js}, the\n * package's \"./strict-attributes\" export). The recorder loads it under\n * `privacyMode: \"strict\"` alone, beside rrweb's import and in parallel\n * with it, and starts no recording until both have loaded\n * (recorder.ts loadRecorder), so no snapshot is ever taken without it; a\n * load that fails ends the capture with\n * KUI_E_STRICT_ATTRIBUTES_UNAVAILABLE and records nothing. balanced and\n * off never load it. It imports nothing but the version it exports (a\n * string the build inlines), and the main builds import it\n * only by that name (dist/index.mjs also by its file beside it, for a page\n * with no bundler): __tests__/bundle-size.test.ts fails when\n * one of its names is in dist/index.mjs, dist/index.bundler.mjs or\n * dist/index.js. Why a chunk: the three lists are about 954 B gzipped\n * of distinct names, and with them in the base bundle every build was\n * over its budget (founder's ruling, 2026-11-13: never slow the page).\n *\n * STRICT RECORDS NO PAGE TEXT (README, Privacy): what a text node holds,\n * rrweb masks; what an attribute holds, privacy.ts blanks unless this\n * file keeps it, by an ALLOW-LIST. A list of the attributes that hold\n * text missed every one it did not name -- Livewire's wire:snapshot,\n * Alpine's x-data, an Astro island's props, a custom element's message\n * -- so strict keeps only the names whose value is the page's\n * structure: an id, a class, a token, a number, an id reference, SVG\n * geometry, ARIA state, a test id, rrweb's own. A URL, CSS, a srcset and\n * a srcdoc go through their own rules (privacy.ts OWN_RULE, the URL\n * rule). Every other value is blanked, a field's value rrweb already\n * masked kept as it is, and a meta's `content` kept only where the meta\n * configures the page. Blank, not asterisks: the flow engine reads an\n * empty aria-label as none, so a strict recording never names an\n * element by a label it cannot have.\n *\n * ARIA under strict: kept, the attributes that describe the widget -- its\n * structure (level, posinset, setsize, row/col counts and indexes), its\n * relationships (id references: controls, describedby, labelledby, owns,\n * details, errormessage, flowto), its configuration (autocomplete,\n * haspopup, multiline, multiselectable, orientation, readonly, required,\n * disabled, modal, live, atomic, busy, relevant) and whether it is open or\n * hidden (expanded, hidden). Blanked, every one that reflects what the\n * visitor chose or entered: value now/min/max/text (a two-thumb slider's\n * min and max are the other thumb's chosen value), checked, selected,\n * pressed, current, sort, invalid (a verdict on what they typed) and\n * activedescendant (the id of the option they are on). And on HTML\n * elements `checked` and `selected` for the same reason (privacy.ts drops\n * them).\n */\nconst STRICT_KEPT =\n /^(?: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+)$/;\n/** Kept on an HTML element (not a custom one, whose attributes are its own): a token, a number, an id reference. */\nconst HTML_KEPT =\n /^(?: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)$/;\n/** Kept on an SVG element only: its geometry and paint, by exact name. */\nconst SVG_KEPT =\n /^(?: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)$/;\n/** A meta whose `content` configures the page, not one that describes it. */\nconst PAGE_METAS =\n /^(viewport|color-scheme|theme-color|referrer|robots|format-detection)$/i;\n\n/**\n * Whether strict keeps attribute `name`'s value on a `tag` element (an SVG\n * one when `svg`), by name alone; a meta's `content` by the meta's own\n * `attributes`. privacy.ts asks this for every attribute but those with\n * their own rule, and blanks what it answers false for.\n */\nexport function kept(\n name: string,\n tag: string,\n svg: boolean,\n attributes?: Record<string, unknown>,\n): boolean {\n return name === \"content\"\n ? tag === \"meta\" &&\n attributes !== undefined &&\n (typeof attributes[\"http-equiv\"] === \"string\" ||\n PAGE_METAS.test(String(attributes.name)))\n : STRICT_KEPT.test(name) ||\n (svg ? SVG_KEPT : tag.includes(\"-\") ? null : HTML_KEPT)?.test(name) ===\n true;\n}\n\n/** The version this chunk was built as: the SDK refuses one of another (module-of.ts ownChunk). */\nexport { version } from \"../package.json\";\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 +1 @@
1
- function e(e,t,n,l){return"content"===e?"meta"===t&&void 0!==l&&("string"==typeof l["http-equiv"]||a.test(String(l.name))):o.test(e)||!0===(n?i:t.includes("-")?null:r)?.test(e)}var t="3.1.0",o=/^(?: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+)$/,r=/^(?: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)$/,i=/^(?: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)$/,a=/^(viewport|color-scheme|theme-color|referrer|robots|format-detection)$/i;export{e as kept,t as version};//# sourceMappingURL=strict-attributes.mjs.map
1
+ function e(e,t,n,l){return"content"===e?"meta"===t&&void 0!==l&&("string"==typeof l["http-equiv"]||a.test(String(l.name))):o.test(e)||!0===(n?i:t.includes("-")?null:r)?.test(e)}var t="3.2.0",o=/^(?: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+)$/,r=/^(?: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)$/,i=/^(?: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)$/,a=/^(viewport|color-scheme|theme-color|referrer|robots|format-detection)$/i;export{e as kept,t as version};//# sourceMappingURL=strict-attributes.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/strict-attributes.ts","../package.json"],"names":["kept","name","tag","svg","attributes","PAGE_METAS","test","String","STRICT_KEPT","SVG_KEPT","includes","HTML_KEPT","version","c","o"],"mappings":"AAmEO,SAASA,EACdC,EACAC,EACAC,EACAC,GAEA,MAAgB,YAATH,EACK,SAARC,QACiB,IAAfE,IACqC,iBAA7BA,EAAW,eACjBC,EAAWC,KAAKC,OAAOH,EAAWH,QACtCO,EAAYF,KAAKL,KAEb,KADDE,EAAMM,EAAWP,EAAIQ,SAAS,KAAO,KAAOC,IAAYL,KAAKL,EAEtE,CC/EE,IAAAW,EAAW,QD+CPJ,EACJ,icAEIG,EACJ,4nBAEIF,EACJ,46BAEIJ,EACJ,iFAsBFQ,UAAAC","sourcesContent":["/* ------------------------------------------------------------------ */\n/* @keploy/capture-sdk - strict's attribute allow-list */\n/* ------------------------------------------------------------------ */\n/*\n * THIS FILE IS A CHUNK OF ITS OWN (dist/strict-attributes.{mjs,js}, the\n * package's \"./strict-attributes\" export). The recorder loads it under\n * `privacyMode: \"strict\"` alone, beside rrweb's import and in parallel\n * with it, and starts no recording until both have loaded\n * (recorder.ts loadRecorder), so no snapshot is ever taken without it; a\n * load that fails ends the capture with\n * KUI_E_STRICT_ATTRIBUTES_UNAVAILABLE and records nothing. balanced and\n * off never load it. It imports nothing but the version it exports (a\n * string the build inlines), and the main builds import it\n * only by that name (dist/index.mjs also by its file beside it, for a page\n * with no bundler): __tests__/bundle-size.test.ts fails when\n * one of its names is in dist/index.mjs, dist/index.bundler.mjs or\n * dist/index.js. Why a chunk: the three lists are about 954 B gzipped\n * of distinct names, and with them in the base bundle every build was\n * over its budget (founder's ruling, 2026-11-13: never slow the page).\n *\n * STRICT RECORDS NO PAGE TEXT (README, Privacy): what a text node holds,\n * rrweb masks; what an attribute holds, privacy.ts blanks unless this\n * file keeps it, by an ALLOW-LIST. A list of the attributes that hold\n * text missed every one it did not name -- Livewire's wire:snapshot,\n * Alpine's x-data, an Astro island's props, a custom element's message\n * -- so strict keeps only the names whose value is the page's\n * structure: an id, a class, a token, a number, an id reference, SVG\n * geometry, ARIA state, a test id, rrweb's own. A URL, CSS, a srcset and\n * a srcdoc go through their own rules (privacy.ts OWN_RULE, the URL\n * rule). Every other value is blanked, a field's value rrweb already\n * masked kept as it is, and a meta's `content` kept only where the meta\n * configures the page. Blank, not asterisks: the flow engine reads an\n * empty aria-label as none, so a strict recording never names an\n * element by a label it cannot have.\n *\n * ARIA under strict: kept, the attributes that describe the widget -- its\n * structure (level, posinset, setsize, row/col counts and indexes), its\n * relationships (id references: controls, describedby, labelledby, owns,\n * details, errormessage, flowto), its configuration (autocomplete,\n * haspopup, multiline, multiselectable, orientation, readonly, required,\n * disabled, modal, live, atomic, busy, relevant) and whether it is open or\n * hidden (expanded, hidden). Blanked, every one that reflects what the\n * visitor chose or entered: value now/min/max/text (a two-thumb slider's\n * min and max are the other thumb's chosen value), checked, selected,\n * pressed, current, sort, invalid (a verdict on what they typed) and\n * activedescendant (the id of the option they are on). And on HTML\n * elements `checked` and `selected` for the same reason (privacy.ts drops\n * them).\n */\nconst STRICT_KEPT =\n /^(?: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+)$/;\n/** Kept on an HTML element (not a custom one, whose attributes are its own): a token, a number, an id reference. */\nconst HTML_KEPT =\n /^(?: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)$/;\n/** Kept on an SVG element only: its geometry and paint, by exact name. */\nconst SVG_KEPT =\n /^(?: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)$/;\n/** A meta whose `content` configures the page, not one that describes it. */\nconst PAGE_METAS =\n /^(viewport|color-scheme|theme-color|referrer|robots|format-detection)$/i;\n\n/**\n * Whether strict keeps attribute `name`'s value on a `tag` element (an SVG\n * one when `svg`), by name alone; a meta's `content` by the meta's own\n * `attributes`. privacy.ts asks this for every attribute but those with\n * their own rule, and blanks what it answers false for.\n */\nexport function kept(\n name: string,\n tag: string,\n svg: boolean,\n attributes?: Record<string, unknown>,\n): boolean {\n return name === \"content\"\n ? tag === \"meta\" &&\n attributes !== undefined &&\n (typeof attributes[\"http-equiv\"] === \"string\" ||\n PAGE_METAS.test(String(attributes.name)))\n : STRICT_KEPT.test(name) ||\n (svg ? SVG_KEPT : tag.includes(\"-\") ? null : HTML_KEPT)?.test(name) ===\n true;\n}\n\n/** The version this chunk was built as: the SDK refuses one of another (module-of.ts ownChunk). */\nexport { version } from \"../package.json\";\n","{\n \"name\": \"@keploy/capture-sdk\",\n \"version\": \"3.1.0\",\n \"description\": \"Lightweight SDK to capture UI flows from real users - DOM recording, network interception, PII masking\",\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/strict-attributes.ts","../package.json"],"names":["kept","name","tag","svg","attributes","PAGE_METAS","test","String","STRICT_KEPT","SVG_KEPT","includes","HTML_KEPT","version","c","o"],"mappings":"AAmEO,SAASA,EACdC,EACAC,EACAC,EACAC,GAEA,MAAgB,YAATH,EACK,SAARC,QACiB,IAAfE,IACqC,iBAA7BA,EAAW,eACjBC,EAAWC,KAAKC,OAAOH,EAAWH,QACtCO,EAAYF,KAAKL,KAEb,KADDE,EAAMM,EAAWP,EAAIQ,SAAS,KAAO,KAAOC,IAAYL,KAAKL,EAEtE,CC/EE,IAAAW,EAAW,QD+CPJ,EACJ,icAEIG,EACJ,4nBAEIF,EACJ,46BAEIJ,EACJ,iFAsBFQ,UAAAC","sourcesContent":["/* ------------------------------------------------------------------ */\n/* @keploy/capture-sdk - strict's attribute allow-list */\n/* ------------------------------------------------------------------ */\n/*\n * THIS FILE IS A CHUNK OF ITS OWN (dist/strict-attributes.{mjs,js}, the\n * package's \"./strict-attributes\" export). The recorder loads it under\n * `privacyMode: \"strict\"` alone, beside rrweb's import and in parallel\n * with it, and starts no recording until both have loaded\n * (recorder.ts loadRecorder), so no snapshot is ever taken without it; a\n * load that fails ends the capture with\n * KUI_E_STRICT_ATTRIBUTES_UNAVAILABLE and records nothing. balanced and\n * off never load it. It imports nothing but the version it exports (a\n * string the build inlines), and the main builds import it\n * only by that name (dist/index.mjs also by its file beside it, for a page\n * with no bundler): __tests__/bundle-size.test.ts fails when\n * one of its names is in dist/index.mjs, dist/index.bundler.mjs or\n * dist/index.js. Why a chunk: the three lists are about 954 B gzipped\n * of distinct names, and with them in the base bundle every build was\n * over its budget (founder's ruling, 2026-11-13: never slow the page).\n *\n * STRICT RECORDS NO PAGE TEXT (README, Privacy): what a text node holds,\n * rrweb masks; what an attribute holds, privacy.ts blanks unless this\n * file keeps it, by an ALLOW-LIST. A list of the attributes that hold\n * text missed every one it did not name -- Livewire's wire:snapshot,\n * Alpine's x-data, an Astro island's props, a custom element's message\n * -- so strict keeps only the names whose value is the page's\n * structure: an id, a class, a token, a number, an id reference, SVG\n * geometry, ARIA state, a test id, rrweb's own. A URL, CSS, a srcset and\n * a srcdoc go through their own rules (privacy.ts OWN_RULE, the URL\n * rule). Every other value is blanked, a field's value rrweb already\n * masked kept as it is, and a meta's `content` kept only where the meta\n * configures the page. Blank, not asterisks: the flow engine reads an\n * empty aria-label as none, so a strict recording never names an\n * element by a label it cannot have.\n *\n * ARIA under strict: kept, the attributes that describe the widget -- its\n * structure (level, posinset, setsize, row/col counts and indexes), its\n * relationships (id references: controls, describedby, labelledby, owns,\n * details, errormessage, flowto), its configuration (autocomplete,\n * haspopup, multiline, multiselectable, orientation, readonly, required,\n * disabled, modal, live, atomic, busy, relevant) and whether it is open or\n * hidden (expanded, hidden). Blanked, every one that reflects what the\n * visitor chose or entered: value now/min/max/text (a two-thumb slider's\n * min and max are the other thumb's chosen value), checked, selected,\n * pressed, current, sort, invalid (a verdict on what they typed) and\n * activedescendant (the id of the option they are on). And on HTML\n * elements `checked` and `selected` for the same reason (privacy.ts drops\n * them).\n */\nconst STRICT_KEPT =\n /^(?: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+)$/;\n/** Kept on an HTML element (not a custom one, whose attributes are its own): a token, a number, an id reference. */\nconst HTML_KEPT =\n /^(?: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)$/;\n/** Kept on an SVG element only: its geometry and paint, by exact name. */\nconst SVG_KEPT =\n /^(?: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)$/;\n/** A meta whose `content` configures the page, not one that describes it. */\nconst PAGE_METAS =\n /^(viewport|color-scheme|theme-color|referrer|robots|format-detection)$/i;\n\n/**\n * Whether strict keeps attribute `name`'s value on a `tag` element (an SVG\n * one when `svg`), by name alone; a meta's `content` by the meta's own\n * `attributes`. privacy.ts asks this for every attribute but those with\n * their own rule, and blanks what it answers false for.\n */\nexport function kept(\n name: string,\n tag: string,\n svg: boolean,\n attributes?: Record<string, unknown>,\n): boolean {\n return name === \"content\"\n ? tag === \"meta\" &&\n attributes !== undefined &&\n (typeof attributes[\"http-equiv\"] === \"string\" ||\n PAGE_METAS.test(String(attributes.name)))\n : STRICT_KEPT.test(name) ||\n (svg ? SVG_KEPT : tag.includes(\"-\") ? null : HTML_KEPT)?.test(name) ===\n true;\n}\n\n/** The version this chunk was built as: the SDK refuses one of another (module-of.ts ownChunk). */\nexport { version } from \"../package.json\";\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"]}
@@ -199,7 +199,7 @@ export declare class Transport {
199
199
  /** Set by a drain request that arrived while a flush was running. */
200
200
  private drainPending;
201
201
  /** Set by hold(): nothing is sent until release(). */
202
- private holding;
202
+ private holdOpen;
203
203
  /**
204
204
  * Full batches enqueue() asked for while a flight was out, which the run
205
205
  * under way owes: one batch each, sent as its flight settles (run()).
@@ -255,9 +255,9 @@ export declare class Transport {
255
255
  * The next flight is the counter's: the queue went past the share, and
256
256
  * no drain was asked. It is capped at the share (formFlight).
257
257
  */
258
- private counted;
258
+ private shareFlight;
259
259
  /** Flights that spent their attempts since one was last accepted; 0 when uploads work. */
260
- private failures;
260
+ private failCount;
261
261
  /** performance.now() before which no flight starts on the timer's or an enqueue's say; see OUTAGE_FIRST_MS. */
262
262
  private notBefore;
263
263
  constructor(config: TransportConfig);
@@ -293,7 +293,7 @@ export declare class Transport {
293
293
  * after start() answers the import with the network still down, and
294
294
  * what comes after waits for the network there as it did.
295
295
  */
296
- release(): void;
296
+ release(drain?: boolean): void;
297
297
  /** Drops what is queued and what waits to be re-sent, unsent. */
298
298
  discard(): void;
299
299
  /**
@@ -315,7 +315,7 @@ export declare class Transport {
315
315
  */
316
316
  place(): number;
317
317
  /** Uploads are failing and the wait before the next flight is not over. */
318
- private get paced();
318
+ private get outagePaced();
319
319
  /**
320
320
  * Holds what is unsent at MAX_QUEUE_BYTES, dropping the oldest first:
321
321
  * waiting flights whole, then queued events. fit() never drops the
@@ -358,7 +358,7 @@ export declare class Transport {
358
358
  /** One console line; each caller says its code once per capture. */
359
359
  private warn;
360
360
  /** The request body for `events`, with everything a batch carries. */
361
- private payload;
361
+ private makeBatch;
362
362
  /**
363
363
  * Send queued events.
364
364
  *
@@ -382,8 +382,8 @@ export declare class Transport {
382
382
  * leaving (found in review #29). One sender runs at a time, so one
383
383
  * wait is pending at most.
384
384
  */
385
- private backoff;
386
- private sendWithRetry;
385
+ private retryWait;
386
+ private postFlight;
387
387
  /**
388
388
  * The last flush, issued while the document is being torn down.
389
389
  *
@@ -431,11 +431,11 @@ export declare class Transport {
431
431
  * leaving. Which is why an event that can never fit is not left to
432
432
  * wait here: enqueue() sends it as soon as it is queued.
433
433
  */
434
- private reclaimInFlight;
434
+ private reclaimFlight;
435
435
  private reviveNext;
436
436
  private formFlight;
437
437
  /**
438
- * The POST body for `events`: JSON.stringify(this.payload(events,
438
+ * The POST body for `events`: JSON.stringify(this.makeBatch(events,
439
439
  * batchId)), the same text, with each event's JSON as enqueue() wrote
440
440
  * it, joined. The envelope is written with no events; its
441
441
  * `"events":[]` is the first, since only the session and batch ids,
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@keploy/capture-sdk",
3
- "version": "3.1.0",
3
+ "version": "3.2.0",
4
4
  "description": "Lightweight SDK to capture UI flows from real users - DOM recording, network interception, PII masking",
5
+ "homepage": "https://keploy.io/docs/running-keploy/ui-capture/",
5
6
  "main": "dist/index.js",
6
7
  "module": "dist/index.bundler.mjs",
7
8
  "unpkg": "dist/index.mjs",