@keploy/capture-sdk 3.1.0-rc.1 → 3.1.0-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/README.md +398 -58
  2. package/body-redact/package.json +6 -0
  3. package/body-worker-start/package.json +6 -0
  4. package/dist/body-jobs.d.ts +134 -0
  5. package/dist/body-redact.d.ts +23 -0
  6. package/dist/body-redact.js +1 -0
  7. package/dist/body-redact.js.map +1 -0
  8. package/dist/body-redact.mjs +1 -0
  9. package/dist/body-redact.mjs.map +1 -0
  10. package/dist/body-worker-none.d.ts +3 -0
  11. package/dist/body-worker-none.js +1 -0
  12. package/dist/body-worker-none.js.map +1 -0
  13. package/dist/body-worker-none.mjs +1 -0
  14. package/dist/body-worker-none.mjs.map +1 -0
  15. package/dist/body-worker-start.d.ts +3 -0
  16. package/dist/body-worker-start.js +1 -0
  17. package/dist/body-worker-start.js.map +1 -0
  18. package/dist/body-worker-start.mjs +1 -0
  19. package/dist/body-worker-start.mjs.map +1 -0
  20. package/dist/body-worker-unbundled.d.ts +1 -0
  21. package/dist/body-worker-unbundled.mjs +1 -0
  22. package/dist/body-worker-unbundled.mjs.map +1 -0
  23. package/dist/body-worker.d.ts +1 -0
  24. package/dist/body-worker.js +1 -0
  25. package/dist/body-worker.js.map +1 -0
  26. package/dist/errors.d.ts +38 -6
  27. package/dist/index.bundler.mjs +1 -0
  28. package/dist/index.bundler.mjs.map +1 -0
  29. package/dist/index.d.ts +1 -1
  30. package/dist/index.js +1 -11
  31. package/dist/index.js.map +1 -1
  32. package/dist/index.mjs +1 -11
  33. package/dist/index.mjs.map +1 -1
  34. package/dist/leave.d.ts +67 -0
  35. package/dist/module-of.d.ts +45 -0
  36. package/dist/network.d.ts +52 -37
  37. package/dist/privacy.d.ts +23 -2
  38. package/dist/recorder.d.ts +30 -6
  39. package/dist/request-term.d.ts +2 -0
  40. package/dist/request-term.js +1 -2
  41. package/dist/request-term.js.map +1 -1
  42. package/dist/request-term.mjs +1 -2
  43. package/dist/request-term.mjs.map +1 -1
  44. package/dist/strict-attributes.d.ts +9 -0
  45. package/dist/strict-attributes.js +1 -0
  46. package/dist/strict-attributes.js.map +1 -0
  47. package/dist/strict-attributes.mjs +1 -0
  48. package/dist/strict-attributes.mjs.map +1 -0
  49. package/dist/transport.d.ts +35 -3
  50. package/dist/types.d.ts +21 -5
  51. package/package.json +31 -4
  52. package/strict-attributes/package.json +6 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/term-candidate.ts","../src/request-term.ts"],"sourcesContent":["/* ------------------------------------------------------------------ */\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/* @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\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"],"mappings":"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","names":["OBJECT_START","couldBeGraphql","text","OBJECT_START","termBeforeLoad","body","NAME","STARTS","MEMBERS","LEXEME","normalise","doc","out","name","m","open","k","t","at","own","o","prepare","body","v","keys","key","query","n","hash","text","hashed","subtle","digest","hex","requestTerm","p","recordTermFor","known","termBeforeLoad"]}
1
+ {"version":3,"sources":["../src/term-candidate.ts","../package.json","../src/request-term.ts"],"names":["OBJECT_START","version","NAME","STARTS","MEMBERS","LEXEME","own","o","k","Array","isArray","Object","prototype","hasOwnProperty","call","prepare","body","v","JSON","parse","keys","length","some","key","includes","name","query","test","n","hash","text","doc","out","lastIndex","m","exec","push","open","t","at","indexOf","pop","join","normalise","async","hashed","subtle","digest","Uint8Array","TextEncoder","encode","hex","toString","padStart","requestTerm","p","recordTermFor","known","couldBeGraphql","URLSearchParams","FormData","termBeforeLoad","S","A"],"mappings":"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","sourcesContent":["/* ------------------------------------------------------------------ */\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-rc.2\",\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\"\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","/* ------------------------------------------------------------------ */\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"]}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Whether strict keeps attribute `name`'s value on a `tag` element (an SVG
3
+ * one when `svg`), by name alone; a meta's `content` by the meta's own
4
+ * `attributes`. privacy.ts asks this for every attribute but those with
5
+ * their own rule, and blanks what it answers false for.
6
+ */
7
+ export declare function kept(name: string, tag: string, svg: boolean, attributes?: Record<string, unknown>): boolean;
8
+ /** The version this chunk was built as: the SDK refuses one of another (module-of.ts ownChunk). */
9
+ export { version } from "../package.json";
@@ -0,0 +1 @@
1
+ var e,t=Object.defineProperty,r=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,a={};((e,r)=>{for(var o in r)t(e,o,{get:r[o],enumerable:!0})})(a,{kept:()=>c,version:()=>n}),module.exports=(e=a,((e,a,n,l)=>{if(a&&"object"==typeof a||"function"==typeof a)for(let n of o(a))!i.call(e,n)&&void 0!==n&&t(e,n,{get:()=>a[n],enumerable:!(l=r(a,n))||l.enumerable});return e})(t({},"__esModule",{value:!0}),e));var n="3.1.0-rc.2",l=/^(?: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+)$/,s=/^(?: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)$/,p=/^(?: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)$/,d=/^(viewport|color-scheme|theme-color|referrer|robots|format-detection)$/i;function c(e,t,r,o){return"content"===e?"meta"===t&&void 0!==o&&("string"==typeof o["http-equiv"]||d.test(String(o.name))):l.test(e)||!0===(r?p:t.includes("-")?null:s)?.test(e)}//# sourceMappingURL=strict-attributes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/strict-attributes.ts","../package.json"],"names":["strict_attributes_exports","__export","kept","version","module","exports","STRICT_KEPT","HTML_KEPT","SVG_KEPT","PAGE_METAS","name","tag","svg","attributes","test","String","includes"],"mappings":"+HAAAA,EAAA,G,yDAAAC,CAAAD,EAAA,CAAAE,KAAA,IAAAA,EAAAC,QAAA,IAAAA,IAAAC,OAAAC,S,EAAAL,E,gNCEE,IAAAG,EAAW,aD+CPG,EACJ,icAEIC,EACJ,4nBAEIC,EACJ,46BAEIC,EACJ,0EAQK,SAASP,EACdQ,EACAC,EACAC,EACAC,GAEA,MAAgB,YAATH,EACK,SAARC,QACiB,IAAfE,IACqC,iBAA7BA,EAAW,eACjBJ,EAAWK,KAAKC,OAAOF,EAAWH,QACtCJ,EAAYQ,KAAKJ,KAEb,KADDE,EAAMJ,EAAWG,EAAIK,SAAS,KAAO,KAAOT,IAAYO,KAAKJ,EAEtE","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-rc.2\",\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\"\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"]}
@@ -0,0 +1 @@
1
+ var e="3.1.0-rc.2",t=/^(?: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+)$/,o=/^(?: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)$/,r=/^(?: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)$/,i=/^(viewport|color-scheme|theme-color|referrer|robots|format-detection)$/i;function a(e,a,n,l){return"content"===e?"meta"===a&&void 0!==l&&("string"==typeof l["http-equiv"]||i.test(String(l.name))):t.test(e)||!0===(n?r:a.includes("-")?null:o)?.test(e)}export{a as kept,e as version};//# sourceMappingURL=strict-attributes.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../package.json","../src/strict-attributes.ts"],"names":["version","STRICT_KEPT","HTML_KEPT","SVG_KEPT","PAGE_METAS","kept","name","tag","svg","attributes","test","String","includes","c","o"],"mappings":"AAEE,IAAAA,EAAW,aC+CPC,EACJ,icAEIC,EACJ,4nBAEIC,EACJ,46BAEIC,EACJ,0EAQK,SAASC,EACdC,EACAC,EACAC,EACAC,GAEA,MAAgB,YAATH,EACK,SAARC,QACiB,IAAfE,IACqC,iBAA7BA,EAAW,eACjBL,EAAWM,KAAKC,OAAOF,EAAWH,QACtCL,EAAYS,KAAKJ,KAEb,KADDE,EAAML,EAAWI,EAAIK,SAAS,KAAO,KAAOV,IAAYQ,KAAKJ,EAEtE,QAAAO,UAAAC","sourcesContent":["{\n \"name\": \"@keploy/capture-sdk\",\n \"version\": \"3.1.0-rc.2\",\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\"\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","/* ------------------------------------------------------------------ */\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"]}
@@ -82,11 +82,23 @@ export interface TransportConfig {
82
82
  * Called synchronously when the tab is hidden, before the drain that
83
83
  * may be the page's last chance to send (a mobile browser can discard a
84
84
  * hidden page with no pagehide), so the owner can queue what it has
85
- * recorded and not yet handed over: the exchanges whose events wait for
86
- * a task of their own (NetworkInterceptor.emit). Nothing is cut: the
87
- * page is still there.
85
+ * recorded and not yet handed over: the exchanges whose bodies are still
86
+ * being redacted, as far as they fit the main thread's budget
87
+ * (NetworkInterceptor.reportDue()). Nothing is cut: the page is still
88
+ * there, and the rest is recorded when the worker answers.
88
89
  */
89
90
  beforeHiddenFlush?: () => void;
91
+ /**
92
+ * Called synchronously when the browser is back online, before the
93
+ * flush that ends an outage, so the owner can queue what it recorded
94
+ * offline and has not yet handed over: the exchanges whose bodies are
95
+ * still being redacted, as far as they fit the main thread's budget
96
+ * and its body code had loaded before the outage
97
+ * (NetworkInterceptor.reportDue()): such an exchange made offline is in
98
+ * the upload that ends the outage; the rest follow it, recorded the
99
+ * same, when the code and the worker load and answer.
100
+ */
101
+ beforeOnlineFlush?: () => void;
90
102
  /**
91
103
  * Called once when a terminal rejection has ended this transport, so
92
104
  * the owner can end the CAPTURE.
@@ -188,6 +200,11 @@ export declare class Transport {
188
200
  private drainPending;
189
201
  /** Set by hold(): nothing is sent until release(). */
190
202
  private holding;
203
+ /**
204
+ * Full batches enqueue() asked for while a flight was out, which the run
205
+ * under way owes: one batch each, sent as its flight settles (run()).
206
+ */
207
+ private asked;
191
208
  /**
192
209
  * A DRAIN IS OWED: an event over the keepalive quota was queued while
193
210
  * the browser said it was offline. The next thing that sends -- the
@@ -228,6 +245,17 @@ export declare class Transport {
228
245
  * fit() counts again only when it is over the cap.
229
246
  */
230
247
  private held;
248
+ /**
249
+ * The JSON bytes of what `queue` holds, kept exactly at every change of
250
+ * it (each event's size is measured once, at enqueue): what the unload
251
+ * flush would have to carry. O(1) an event; never a walk of the queue.
252
+ */
253
+ private queued;
254
+ /**
255
+ * The next flight is the counter's: the queue went past the share, and
256
+ * no drain was asked. It is capped at the share (formFlight).
257
+ */
258
+ private counted;
231
259
  /** Flights that spent their attempts since one was last accepted; 0 when uploads work. */
232
260
  private failures;
233
261
  /** performance.now() before which no flight starts on the timer's or an enqueue's say; see OUTAGE_FIRST_MS. */
@@ -419,6 +447,10 @@ export declare class Transport {
419
447
  /** The event's JSON bytes: what enqueue() measured, or measured now for one a flight carried and pagehide took back. */
420
448
  private eventBytes;
421
449
  private mintBatchId;
450
+ /** Takes `events` off the queued bytes (`sign` -1: puts them back). */
451
+ private uncount;
452
+ /** The queue is past what the unload request can carry: O(1), from the counters. */
453
+ private pastShare;
422
454
  /** Events waiting to be sent, retry flights included. */
423
455
  private pendingCount;
424
456
  private trimToCapacity;
package/dist/types.d.ts CHANGED
@@ -6,17 +6,18 @@
6
6
  * the document unloads — a navigation, a tab close — whatever is still
7
7
  * queued is sent in one keepalive request, and the browser caps a
8
8
  * document's keepalive bodies at 64 KiB: MEASURED in Chromium 145, a
9
- * 65,536-byte body is accepted and a 65,537-byte body refused. That
9
+ * 65,536-byte body is accepted and a 65,537-byte body refused. The page
10
+ * needs that quota too, so the SDK takes half of it, 32 KiB: its unload
10
11
  * request carries the oldest queued events that fit, uncompressed; the
11
12
  * first event that does not fit holds back everything behind it, and a
12
13
  * document that is gone has no other way to send.
13
14
  *
14
- * So an event whose JSON alone is over 64 KiB — the DOM snapshot of a
15
+ * So an event whose JSON alone is over 32 KiB — the DOM snapshot of a
15
16
  * big page, a network event whose bodies approach `maxBodySize` — does
16
17
  * not wait for the timer: it is posted as soon as it is queued (behind
17
18
  * a batch already on the wire, if there is one; not while the browser
18
19
  * reports itself offline), with keepalive when its gzipped body fits
19
- * the quota. A body that does not fit even gzipped goes without
20
+ * the SDK's 32 KiB share. A body that does not fit even gzipped goes without
20
21
  * keepalive, and a navigation before its upload completes cancels it.
21
22
  * MEASURED in Chromium 145 on a 50 KB/s uplink, navigation once the
22
23
  * request had left the browser and while its body was still uploading,
@@ -238,8 +239,16 @@ export interface CaptureConfig {
238
239
  * could not be read at all. No size: nothing there was read, so
239
240
  * there was nothing to measure.
240
241
  *
241
- * A network event carrying a body over 64 KiB cannot travel in the
242
+ * A network event carrying a body over 32 KiB cannot travel in the
242
243
  * page-unload flush; see the note on {@link CaptureConfig}.
244
+ *
245
+ * WHERE THE PAGE HAS NO BODY WORKER (a CSP that refuses it, webpack 4,
246
+ * esbuild without dist/body-worker.js copied beside the bundle), a body
247
+ * is redacted on the page's main thread and only up to 64 KiB of it:
248
+ * one over that is recorded with its first 64 KiB redacted, under a
249
+ * first line `[Body cut: K of N characters kept, unverified]`, which
250
+ * replay never serves as the whole response. So is a body still in the
251
+ * worker when the page leaves, past the 64 KiB its last moment redacts.
243
252
  */
244
253
  maxBodySize?: number;
245
254
  /** Maximum number of events to queue in memory before dropping oldest. @default 5_000 */
@@ -363,7 +372,14 @@ export interface PrivacyConfig {
363
372
  blockSelectors: string[];
364
373
  /**
365
374
  * Replace network request/response bodies with "[MASKED]" (a body
366
- * that was absent stays null). @default false
375
+ * that was absent stays null), decided from each body's kind and size,
376
+ * never by serialising, decoding or relaying it. Two reads remain, for
377
+ * the requestTerm every mode records: a string body is scanned, and a
378
+ * Request object's own body is read only as far as the term needs. The
379
+ * browser still copies or encodes a buffer, string, URLSearchParams or
380
+ * FormData passed in fetch()'s init once more, into the Request the SDK
381
+ * builds from the call, which the SDK never reads. See the README.
382
+ * @default false
367
383
  *
368
384
  * Forced on under `privacyMode: "strict"`. KeployCapture refuses an
369
385
  * explicit `false` beside strict with KUI_E_PRIVACY_CONFLICT rather
package/package.json CHANGED
@@ -1,9 +1,11 @@
1
1
  {
2
2
  "name": "@keploy/capture-sdk",
3
- "version": "3.1.0-rc.1",
3
+ "version": "3.1.0-rc.2",
4
4
  "description": "Lightweight SDK to capture UI flows from real users - DOM recording, network interception, PII masking",
5
5
  "main": "dist/index.js",
6
- "module": "dist/index.mjs",
6
+ "module": "dist/index.bundler.mjs",
7
+ "unpkg": "dist/index.mjs",
8
+ "jsdelivr": "dist/index.mjs",
7
9
  "types": "dist/index.d.ts",
8
10
  "exports": {
9
11
  ".": {
@@ -16,11 +18,29 @@
16
18
  "import": "./dist/request-term.mjs",
17
19
  "require": "./dist/request-term.js"
18
20
  },
21
+ "./strict-attributes": {
22
+ "types": "./dist/strict-attributes.d.ts",
23
+ "import": "./dist/strict-attributes.mjs",
24
+ "require": "./dist/strict-attributes.js"
25
+ },
26
+ "./body-redact": {
27
+ "types": "./dist/body-redact.d.ts",
28
+ "import": "./dist/body-redact.mjs",
29
+ "require": "./dist/body-redact.js"
30
+ },
31
+ "./body-worker-start": {
32
+ "types": "./dist/body-worker-start.d.ts",
33
+ "import": "./dist/body-worker-start.mjs",
34
+ "require": "./dist/body-worker-start.js"
35
+ },
19
36
  "./package.json": "./package.json"
20
37
  },
21
38
  "files": [
22
39
  "dist",
23
40
  "request-term/package.json",
41
+ "strict-attributes/package.json",
42
+ "body-redact/package.json",
43
+ "body-worker-start/package.json",
24
44
  "LICENSE",
25
45
  "README.md"
26
46
  ],
@@ -31,6 +51,7 @@
31
51
  "@keploy/contract": "0.1.0",
32
52
  "@types/node": "~24.13.5",
33
53
  "jsdom": "^30.1.0",
54
+ "terser": "5.51.2",
34
55
  "tsup": "^8.3.0",
35
56
  "typescript": "^7.0.2",
36
57
  "vitest": "^5.0.1"
@@ -43,13 +64,19 @@
43
64
  "e2e",
44
65
  "capture"
45
66
  ],
67
+ "browser": {
68
+ "./dist/body-worker-unbundled.mjs": "./dist/body-worker-none.mjs"
69
+ },
70
+ "alias": {
71
+ "@keploy/capture-sdk/body-worker-start": "./dist/body-worker-start.mjs"
72
+ },
46
73
  "license": "Apache-2.0",
47
74
  "publishConfig": {
48
75
  "access": "public"
49
76
  },
50
77
  "scripts": {
51
- "build": "tsup src/index.ts src/request-term.ts --format cjs,esm --minify --sourcemap --no-splitting --external @keploy/capture-sdk --platform browser && tsc -p tsconfig.build.json",
52
- "dev": "tsup src/index.ts src/request-term.ts --format cjs,esm --minify --sourcemap --no-splitting --external @keploy/capture-sdk --platform browser --watch --onSuccess \"tsc -p tsconfig.build.json\"",
78
+ "build": "node scripts/build-main.mjs && node scripts/build-worker.mjs && tsc -p tsconfig.build.json",
79
+ "dev": "node scripts/build-main.mjs --watch",
53
80
  "test": "vitest run",
54
81
  "clean": "rm -rf dist",
55
82
  "typecheck": "tsc --noEmit"
@@ -0,0 +1,6 @@
1
+ {
2
+ "private": true,
3
+ "main": "../dist/strict-attributes.js",
4
+ "module": "../dist/strict-attributes.mjs",
5
+ "types": "../dist/strict-attributes.d.ts"
6
+ }