@fixback/sdk 0.3.0 → 0.5.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.
@@ -1,73 +0,0 @@
1
- /**
2
- * Client-side masked screenshot capture (spec MVP §E; ticket #54; ADR-0014).
3
- *
4
- * The capture is **private-by-default**: input values are masked and the SDK's own
5
- * UI is excluded from a *clone* of the view **before** anything is rasterised, so no
6
- * unmasked text and none of Fixback's chrome ever reaches the image.
7
- *
8
- * The rasterisation itself is delegated to `modern-screenshot` (ADR-0014): it clones
9
- * the target, inlines the page's real styles **and** its fonts and images as data
10
- * URIs, then draws the result through an SVG `<foreignObject>` onto a `<canvas>`.
11
- * That closes the fidelity gap a hand-rolled `<foreignObject>` left open — external
12
- * stylesheets, web fonts, and same-origin images now render — so the shot matches
13
- * what the Reporter saw and lines up with the annotation's viewport-space marks.
14
- *
15
- * We keep the privacy guarantee by driving it through two of its hooks: `filter`
16
- * drops Fixback's own host elements, and `onCloneNode` masks the clone's inputs —
17
- * both run on the library's internal clone, before it embeds or serialises anything,
18
- * so the live page is never touched and no real value reaches the raster. The backend
19
- * is injectable so the pipeline (and the masking-before-capture guarantee) is testable
20
- * without a real canvas, and it fails quietly: any problem resolves to `null` and the
21
- * report is simply sent without a screenshot.
22
- */
23
- /** The character private input content is replaced with. */
24
- export declare const MASK_CHAR = "\u2022";
25
- /**
26
- * Mask the private, user-entered content in a subtree: text `input` values,
27
- * `textarea` content, and `contenteditable` text. Developer-authored text
28
- * (placeholders, button labels, non-text controls) is left untouched. Operates in
29
- * place — call it on a *clone* of the view, never the live page.
30
- */
31
- export declare function maskInputs(root: ParentNode): void;
32
- /** A captured screenshot: the image bytes plus its dimensions and content type. */
33
- export interface Capture {
34
- readonly blob: Blob;
35
- readonly width: number;
36
- readonly height: number;
37
- readonly type: string;
38
- }
39
- /** The screenshot filename extension for a {@link Capture}'s content type (defaults to `png`). */
40
- export declare function extensionFor(type: string): string;
41
- /** How the SDK prepares a capture: exclude Fixback's UI, mask the clone's inputs. */
42
- interface CaptureHooks {
43
- /** Keep a node in the shot? Returns `false` for Fixback's own host elements. */
44
- readonly filter: (node: Node) => boolean;
45
- /** Mask private input content on the library's internal clone, pre-raster. */
46
- readonly onCloneNode: (clone: Node) => void;
47
- }
48
- /** Turns a DOM subtree into image bytes at a given size (injectable for tests). */
49
- export type CaptureBackend = (target: Element, meta: {
50
- width: number;
51
- height: number;
52
- type: string;
53
- } & CaptureHooks) => Promise<Blob | null>;
54
- /** Options for {@link captureView}. */
55
- export interface CaptureOptions {
56
- /** The element to capture. Defaults to the document element (the full view). */
57
- readonly target?: Element;
58
- readonly doc?: Document;
59
- readonly win?: Window;
60
- /** Output content type. Defaults to `image/png`. */
61
- readonly type?: string;
62
- /** Override the raster backend (the default is `modern-screenshot`). */
63
- readonly capture?: CaptureBackend;
64
- }
65
- /**
66
- * Capture the current view as a masked screenshot. Delegates the raster to the
67
- * backend ({@link captureViaModernScreenshot} by default), which excludes the SDK's
68
- * own UI and masks input values on its internal clone — **before** it embeds or
69
- * serialises anything — then returns the image bytes, or `null` if capture wasn't
70
- * possible.
71
- */
72
- export declare function captureView(options?: CaptureOptions): Promise<Capture | null>;
73
- export {};
package/dist/scrub.d.ts DELETED
@@ -1,61 +0,0 @@
1
- /**
2
- * The single client-side **scrub choke point** every report passes through
3
- * before transport (spec 0003 §C; research `sentry-error-capture-findings.md`
4
- * §7.4) — the SDK's `beforeSend` equivalent.
5
- *
6
- * Masking is the SDK's job, done in the browser before anything leaves the page.
7
- * The screenshot is masked at capture, and breadcrumbs never record a value or a
8
- * body at the source; `runBeforeSend` is the **last** gate over the assembled
9
- * report. Its default scrubbers are **on**: they strip credentials, query
10
- * strings, and bearer tokens from URLs, and redact obvious PII (emails, long
11
- * digit runs, bearer tokens) from crumb and error text. The result is then handed
12
- * to an optional per-project hook that can mutate it further or drop the whole
13
- * report by returning `null`.
14
- *
15
- * The hook is **synchronous and network-free** by contract, and both manual
16
- * (overlay) and automatic (error-capture) reports run through the very same
17
- * choke point. A project relaxes the defaults with `scrub: false`, or reshapes
18
- * the draft in its own hook — never a silent raw send.
19
- */
20
- import type { ReportContent } from "./report";
21
- /** The per-project client scrub hook. Return `null` to drop the whole report. */
22
- export type BeforeSend = (draft: ReportContent) => ReportContent | null;
23
- /** Options for {@link runBeforeSend}. */
24
- export interface BeforeSendOptions {
25
- /** The per-project hook, run **after** the default scrubbers. */
26
- readonly hook?: BeforeSend | null;
27
- /** Run the built-in default scrubbers first. Defaults to `true`. */
28
- readonly scrub?: boolean;
29
- }
30
- /**
31
- * Redact obvious PII from free text: email addresses, `Bearer <token>` /
32
- * `token <value>` pairs, and long digit runs. Conservative by design — it keeps
33
- * the shape of the message readable while removing the sensitive spans.
34
- */
35
- export declare function redactPii(text: string): string;
36
- /**
37
- * Strip the sensitive parts of a URL: userinfo credentials
38
- * (`scheme://user:pass@host`), the entire query string, a token-bearing
39
- * fragment (one that carries `key=value`), and PII (emails, long digit runs) in
40
- * the **path segments** (#139). Plain hash routes (`#/checkout`) are kept. Works
41
- * on absolute and relative URLs alike, with no dependency and no throw. The host
42
- * (authority) is never redacted — only the path and any surviving fragment route.
43
- */
44
- export declare function scrubUrl(url: string): string;
45
- /**
46
- * Apply the built-in default scrubbers to a report draft: strip the page URL,
47
- * and scrub every crumb's URLs and redact PII from its text. The Reporter's own
48
- * `comment` is intentionally left untouched — it is authored on purpose, not
49
- * scraped. The screenshot and input values are masked elsewhere (at capture and
50
- * at crumb creation); this is the final URL/PII sweep.
51
- */
52
- export declare function applyDefaultScrub(draft: ReportContent): ReportContent;
53
- /**
54
- * Run the report draft through the client scrub choke point: the default
55
- * scrubbers first (unless `scrub` is `false`), then the optional per-project
56
- * hook. Returns the scrubbed (and possibly hook-mutated) draft, or `null` when
57
- * the hook drops the report. A hook that throws is treated as a no-op — the
58
- * already-scrubbed draft is kept, so a buggy hook never breaks the report path
59
- * nor leaks unscrubbed data.
60
- */
61
- export declare function runBeforeSend(draft: ReportContent, options?: BeforeSendOptions): ReportContent | null;