rewindlog 0.0.0-stage → 2.0.1

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.
@@ -0,0 +1,368 @@
1
+ import type { eventWithTime } from '@rrweb/types';
2
+ import { type SecurityAuditMetadata } from './BankingSecurity';
3
+ import { type ExecutiveIncidentSummary, type ClipboardFormat } from './ReportTranslator';
4
+ export interface NetworkLogEntry {
5
+ id: string;
6
+ type: 'fetch' | 'xhr';
7
+ method: string;
8
+ url: string;
9
+ status: number;
10
+ ok: boolean;
11
+ requestHeaders?: Record<string, string>;
12
+ responseHeaders?: Record<string, string>;
13
+ requestBody: string | null;
14
+ responseBody: string | null;
15
+ durationMs: number;
16
+ timestamp: number;
17
+ error?: string;
18
+ }
19
+ export interface ConsoleLogEntry {
20
+ id: string;
21
+ level: 'log' | 'info' | 'warn' | 'error';
22
+ message: string;
23
+ args: string[];
24
+ timestamp: number;
25
+ }
26
+ export interface ErrorLogEntry {
27
+ id: string;
28
+ type: 'uncaught-error' | 'unhandled-rejection' | 'manual';
29
+ message: string;
30
+ stack?: string;
31
+ source?: string;
32
+ lineno?: number;
33
+ colno?: number;
34
+ timestamp: number;
35
+ }
36
+ export interface BreadcrumbEntry {
37
+ id: string;
38
+ category: 'navigation' | 'ui' | 'custom' | 'lifecycle' | 'security';
39
+ message: string;
40
+ data?: Record<string, unknown>;
41
+ timestamp: number;
42
+ }
43
+ export interface RewindLogUser {
44
+ id: string;
45
+ email?: string;
46
+ name?: string;
47
+ role?: string;
48
+ branchCode?: string;
49
+ tenant?: string;
50
+ }
51
+ export interface IssueAnnotation {
52
+ title?: string;
53
+ description?: string;
54
+ severity?: 'low' | 'medium' | 'high' | 'critical';
55
+ stepsToReproduce?: string;
56
+ reportedBy?: RewindLogUser;
57
+ }
58
+ export interface SessionMetadata {
59
+ reportId: string;
60
+ sdkVersion: string;
61
+ environment: string;
62
+ release: string;
63
+ exportedAt: string;
64
+ exportedTimestamp: number;
65
+ sessionStartedAt: number;
66
+ sessionDurationMs: number;
67
+ url: string;
68
+ userAgent: string;
69
+ language: string;
70
+ timezone: string;
71
+ viewport: {
72
+ width: number;
73
+ height: number;
74
+ devicePixelRatio: number;
75
+ };
76
+ user: RewindLogUser | null;
77
+ tags: Record<string, string>;
78
+ securityAudit: SecurityAuditMetadata;
79
+ ringBufferStats: {
80
+ activeDomBlocks: number;
81
+ maxDomBlocks: number;
82
+ checkoutIntervalMs: number;
83
+ totalDomEvents: number;
84
+ networkLogsCount: number;
85
+ maxNetworkLogs: number;
86
+ consoleLogsCount: number;
87
+ errorLogsCount: number;
88
+ estimatedPayloadKB: number;
89
+ };
90
+ }
91
+ export interface BugReportPayload {
92
+ executiveSummary?: ExecutiveIncidentSummary;
93
+ issue?: IssueAnnotation;
94
+ metadata: SessionMetadata;
95
+ networkLogs: NetworkLogEntry[];
96
+ consoleLogs: ConsoleLogEntry[];
97
+ errorLogs: ErrorLogEntry[];
98
+ breadcrumbs: BreadcrumbEntry[];
99
+ domEvents: eventWithTime[];
100
+ }
101
+ export interface RewindLogStats {
102
+ /** Current operating edition ('lite' or 'enterprise') */
103
+ mode: 'lite' | 'enterprise';
104
+ /** True if running completely in browser memory without persistent backend storage requirements */
105
+ isEphemeralRamOnly: boolean;
106
+ /** True if an ingestion webhook endpoint is connected */
107
+ hasEndpointConfigured: boolean;
108
+ /** Active default ticket format */
109
+ ticketFormat: ClipboardFormat;
110
+ isRecording: boolean;
111
+ bankingComplianceMode: boolean;
112
+ maskAllInputs: boolean;
113
+ activeDomBlocks: number;
114
+ maxDomBlocks: number;
115
+ domBlockSizes: number[];
116
+ totalDomEvents: number;
117
+ networkLogsCount: number;
118
+ maxNetworkLogs: number;
119
+ consoleLogsCount: number;
120
+ errorLogsCount: number;
121
+ breadcrumbsCount: number;
122
+ totalRedactionsCount: number;
123
+ estimatedMemoryKB: number;
124
+ sessionStartedAt: number;
125
+ lastCheckoutAt: number;
126
+ }
127
+ export interface RewindLogConfig {
128
+ /**
129
+ * Deployment edition mode:
130
+ * - 'lite': Client-only zero-infra mode. Telemetry stays ephemeral in browser RAM. Zero storage, 1-click clipboard ticket export & standalone HTML download.
131
+ * - 'enterprise': Infra-ready mode. Includes direct ingestion endpoint synchronization, SHA-256 tamper verification, AES-256-GCM encryption, and full OJK/PCI-DSS compliance.
132
+ * Default: 'enterprise'
133
+ */
134
+ mode?: 'lite' | 'enterprise';
135
+ /** Default clipboard ticket format ('whatsapp' | 'slack' | 'teams' | 'jira' | 'markdown' | 'compact'). Default: 'whatsapp' */
136
+ ticketFormat?: ClipboardFormat;
137
+ /** Interval in ms between full DOM checkouts. Default: 60000 (1 minute) */
138
+ checkoutEveryNms?: number;
139
+ /** Maximum number of 1-minute DOM blocks retained in Ring Buffer. Default: 6 (~5 minutes) */
140
+ maxDomBlocks?: number;
141
+ /** Maximum number of network requests retained in Ring Buffer. Default: 50 */
142
+ maxNetworkLogs?: number;
143
+ /** Maximum number of console entries retained in Ring Buffer. Default: 100 */
144
+ maxConsoleLogs?: number;
145
+ /** Maximum number of runtime errors retained in Ring Buffer. Default: 50 */
146
+ maxErrorLogs?: number;
147
+ /** Maximum number of breadcrumbs retained in Ring Buffer. Default: 100 */
148
+ maxBreadcrumbs?: number;
149
+ /** Maximum characters stored per request/response body. Default: 65536 (64KB) */
150
+ maxBodyLength?: number;
151
+ /** Enable strict Banking PCI-DSS / OJK / UU-PDP PII scrubbing across DOM text, URLs, and bodies. Default: true */
152
+ bankingComplianceMode?: boolean;
153
+ /** Mask all text inputs in DOM recording. Default: false (in banking mode, sensitive patterns are still scrubbed) */
154
+ maskAllInputs?: boolean;
155
+ /** CSS class name to completely block sensitive DOM elements from recording. Default: 'rewindlog-block' */
156
+ blockClass?: string;
157
+ /** CSS class name to mask text content in DOM elements. Default: 'rewindlog-mask' */
158
+ maskTextClass?: string;
159
+ /** Capture console.log/info/warn/error automatically. Default: true */
160
+ captureConsole?: boolean;
161
+ /** Capture window uncaught errors and unhandled promise rejections. Default: true */
162
+ captureExceptions?: boolean;
163
+ /** Automatically wipe all in-memory buffers on window unload/pagehide. Default: true */
164
+ wipeMemoryOnUnload?: boolean;
165
+ /** URL substrings or RegExp patterns to ignore in network interceptor */
166
+ ignoreUrls?: Array<string | RegExp>;
167
+ /** Additional header names to strip (Authorization & Cookie are always stripped) */
168
+ additionalRedactedHeaders?: string[];
169
+ /** Additional JSON field keys to scrub in request/response bodies */
170
+ additionalRedactedBodyKeys?: string[];
171
+ /** Environment name (e.g., 'production', 'staging'). Default: 'production' */
172
+ environment?: string;
173
+ /** Application release version. Default: '1.0.0' */
174
+ release?: string;
175
+ /** Optional initial user context */
176
+ user?: RewindLogUser;
177
+ /** Optional webhook endpoint for direct server uploads */
178
+ endpointUrl?: string;
179
+ }
180
+ export interface ExportBugReportOptions extends IssueAnnotation {
181
+ /** Whether to trigger a browser file download (`rewindlog-[timestamp].json`). Default: true */
182
+ download?: boolean;
183
+ }
184
+ export interface EncryptedExportOptions extends IssueAnnotation {
185
+ /** Passphrase used to derive the 256-bit AES-GCM key via PBKDF2-SHA256 */
186
+ passphrase?: string;
187
+ /** Whether to trigger browser download. Default: true */
188
+ download?: boolean;
189
+ }
190
+ export declare class RewindLogSDK {
191
+ private mode;
192
+ private domEvents;
193
+ private networkLogs;
194
+ private consoleLogs;
195
+ private errorLogs;
196
+ private breadcrumbs;
197
+ private config;
198
+ private redactedHeaders;
199
+ private redactedBodyKeys;
200
+ private user;
201
+ private tags;
202
+ private totalRedactionsCount;
203
+ private stopRrwebRecorder;
204
+ private originalFetch;
205
+ private originalXHROpen;
206
+ private originalXHRSend;
207
+ private originalXHRSetRequestHeader;
208
+ private originalConsole;
209
+ private boundErrorHandler;
210
+ private boundRejectionHandler;
211
+ private boundUnloadHandler;
212
+ private isStarted;
213
+ private sessionStartedAt;
214
+ private lastCheckoutAt;
215
+ private listeners;
216
+ constructor(config?: RewindLogConfig);
217
+ /**
218
+ * Starts the rrweb DOM ring-buffer recorder, network interceptor, console recorder, and error listener.
219
+ * Safe to call multiple times (idempotent).
220
+ */
221
+ start(): void;
222
+ /**
223
+ * Stops recording and restores all monkey-patched browser APIs.
224
+ */
225
+ stop(): void;
226
+ /**
227
+ * Dynamically toggles strict full-input masking (`maskAllInputs`) and restarts the DOM recorder cleanly.
228
+ */
229
+ setMaskAllInputs(enabled: boolean): void;
230
+ /**
231
+ * Zeroes out all in-memory Ring Buffers immediately (e.g., upon Teller/Customer Logout or Session Timeout).
232
+ */
233
+ purgeMemory(takeFreshSnapshot?: boolean): void;
234
+ /**
235
+ * Associates user identity metadata with the current session (automatically masks email if in banking mode).
236
+ */
237
+ setUser(user: RewindLogUser | null): void;
238
+ private sanitizeUserObject;
239
+ /**
240
+ * Sets a custom key-value tag on the session metadata.
241
+ */
242
+ setTag(key: string, value: string): void;
243
+ /**
244
+ * Records a custom application breadcrumb into the ring buffer.
245
+ */
246
+ addBreadcrumb(entry: Omit<BreadcrumbEntry, 'id' | 'timestamp'>): void;
247
+ /**
248
+ * Manually records a handled error or exception into the error ring buffer.
249
+ */
250
+ captureException(error: unknown, contextMessage?: string): void;
251
+ /**
252
+ * Subscribes to real-time SDK ring-buffer telemetry updates.
253
+ */
254
+ subscribe(listener: (stats: RewindLogStats) => void): () => void;
255
+ /**
256
+ * Returns current ring-buffer statistics, memory estimates, and deployment edition.
257
+ */
258
+ getStats(): RewindLogStats;
259
+ /**
260
+ * Returns current active edition ('lite' or 'enterprise').
261
+ */
262
+ getMode(): 'lite' | 'enterprise';
263
+ /**
264
+ * Returns default clipboard ticket format.
265
+ */
266
+ getTicketFormat(): ClipboardFormat;
267
+ /**
268
+ * Sets default clipboard ticket format (e.g. 'teams', 'slack', 'whatsapp', 'jira').
269
+ */
270
+ setTicketFormat(format: ClipboardFormat): void;
271
+ /**
272
+ * Switches SDK mode dynamically between 'lite' and 'enterprise'.
273
+ */
274
+ setMode(mode: 'lite' | 'enterprise'): void;
275
+ /**
276
+ * Generates a ready-to-paste Incident Summary for Jira, Slack, WhatsApp, or Markdown.
277
+ * Ideal for Lite mode zero-infra quick triage.
278
+ */
279
+ getQuickShareTicket(format?: ClipboardFormat, issue?: IssueAnnotation): string;
280
+ /**
281
+ * Generates and downloads a self-contained, standalone interactive HTML incident report.
282
+ * Works 100% offline with zero server requirements.
283
+ */
284
+ exportStandaloneHtmlReport(issue?: IssueAnnotation): void;
285
+ /**
286
+ * Forces an immediate rrweb full DOM snapshot checkout (starts a new ring buffer block).
287
+ */
288
+ forceCheckout(): void;
289
+ /**
290
+ * Initializes rrweb recording with a 1-minute checkout interval, 6-block ring buffer,
291
+ * and Banking-Grade DOM Input & Text Node PII Masking.
292
+ */
293
+ private initDomRecorder;
294
+ /**
295
+ * Monkey-patches window.fetch and window.XMLHttpRequest without degrading host app behavior.
296
+ */
297
+ private initNetworkInterceptor;
298
+ private shouldIgnoreUrl;
299
+ private patchFetch;
300
+ private patchXHR;
301
+ /**
302
+ * Intercepts console.log, console.info, console.warn, and console.error into a ring buffer.
303
+ */
304
+ private initConsoleInterceptor;
305
+ private restoreConsole;
306
+ /**
307
+ * Listens for uncaught window errors and unhandled Promise rejections.
308
+ */
309
+ private initExceptionInterceptor;
310
+ private restoreExceptionInterceptor;
311
+ /**
312
+ * Strips sensitive headers (Authorization, Cookie, Set-Cookie, X-Pin-Token, etc.) before storing.
313
+ */
314
+ private sanitizeHeaders;
315
+ private parseRawXHRHeaders;
316
+ /**
317
+ * Scrubs sensitive keys (password, pin, otp, pan, rekening, saldo, nik, etc.) and free-text PII from bodies.
318
+ */
319
+ private sanitizeBodyText;
320
+ private scrubJsonValue;
321
+ /**
322
+ * Converts request body payloads into a safe string representation.
323
+ */
324
+ private serializeBody;
325
+ private formatConsoleArg;
326
+ private truncateString;
327
+ private incrementRedactions;
328
+ /**
329
+ * Pushes a network log entry into the ring buffer, maintaining max 50 items.
330
+ */
331
+ private recordNetworkLog;
332
+ private recordErrorLog;
333
+ private buildMetadata;
334
+ /**
335
+ * Returns a full snapshot of the current telemetry state without triggering a browser download.
336
+ */
337
+ getSnapshot(issue?: IssueAnnotation, integrityHashSha256?: string, encryptedAtRest?: boolean): BugReportPayload;
338
+ /**
339
+ * Flattens the 2D rrweb DOM event buffer and exports it along with the last 50 network logs
340
+ * as a downloadable JSON file (`rewindlog-[timestamp].json`).
341
+ * Also computes and embeds a SHA-256 tamper-evident integrity digest asynchronously.
342
+ */
343
+ exportBugReport(options?: ExportBugReportOptions): BugReportPayload;
344
+ /**
345
+ * Exports the bug report with a SHA-256 integrity signature and optional AES-256-GCM encryption
346
+ * (PBKDF2 100,000 iterations) for strict Banking DLP compliance.
347
+ */
348
+ exportSecureBankingReport(options: EncryptedExportOptions): Promise<{
349
+ payload: BugReportPayload;
350
+ sha256Hex: string;
351
+ encrypted: boolean;
352
+ }>;
353
+ private triggerFileDownload;
354
+ /**
355
+ * Uploads the bug report JSON directly to a backend ingestion webhook/server.
356
+ */
357
+ sendBugReport(endpointUrl?: string, issue?: IssueAnnotation): Promise<{
358
+ ok: boolean;
359
+ status: number;
360
+ payload: BugReportPayload;
361
+ fileName?: string;
362
+ reportId?: string;
363
+ sha256?: string;
364
+ }>;
365
+ private notifyListeners;
366
+ private safeConsoleError;
367
+ private generateId;
368
+ }
@@ -0,0 +1,22 @@
1
+ import React from 'react';
2
+ import type { RewindLogSDK, RewindLogStats, BugReportPayload } from './RewindLog';
3
+ import { type ClipboardFormat } from './ReportTranslator';
4
+ interface RewindLogFloatingWidgetProps {
5
+ sdk: RewindLogSDK | null;
6
+ stats: RewindLogStats | null;
7
+ onExportSuccess: (payload: BugReportPayload) => void;
8
+ onOpenReplayStudio: () => void;
9
+ /** Target ticket format preset ('whatsapp' | 'teams' | 'slack' | 'jira' | 'markdown' | 'compact') */
10
+ ticketFormat?: ClipboardFormat;
11
+ }
12
+ /**
13
+ * Turnkey, production-ready Floating Bug Reporter Widget meant to be dropped into
14
+ * any client web application. Marked with `rewindlog-block` so the widget itself
15
+ * is excluded from DOM recordings.
16
+ *
17
+ * Supports dual-mode operation:
18
+ * 1. Mode Lite: 100% Ephemeral browser RAM, zero infra, instant multi-format clipboard copy & portable HTML.
19
+ * 2. Mode Enterprise: Full infra integration, direct webhook ingest, SHA-256 tamper verification, & Replay Studio.
20
+ */
21
+ export declare const RewindLogFloatingWidget: React.FC<RewindLogFloatingWidgetProps>;
22
+ export {};
@@ -0,0 +1,8 @@
1
+ import { RewindLogSDK, type RewindLogConfig, type RewindLogStats, type BugReportPayload } from './RewindLog';
2
+ import { computeTelemetrySha256, encryptPayloadWithAesGcm, decryptPayloadWithAesGcm, scrubBankingFreeText, sanitizeBankingUrl } from './BankingSecurity';
3
+ import { ReplayStudio } from './ReplayStudio';
4
+ import { RewindLogFloatingWidget } from './RewindLogFloatingWidget';
5
+ import { formatTicketClipboardSummary, exportReadableHtmlReport } from './ReportTranslator';
6
+ export declare function initEnterprise(config?: RewindLogConfig): RewindLogSDK;
7
+ export { RewindLogSDK, ReplayStudio, RewindLogFloatingWidget, computeTelemetrySha256, encryptPayloadWithAesGcm, decryptPayloadWithAesGcm, scrubBankingFreeText, sanitizeBankingUrl, formatTicketClipboardSummary, exportReadableHtmlReport, };
8
+ export type { RewindLogConfig, RewindLogStats, BugReportPayload };
@@ -0,0 +1,42 @@
1
+ import { RewindLogSDK, type RewindLogConfig, type RewindLogStats, type BugReportPayload, type IssueAnnotation, type NetworkLogEntry, type ConsoleLogEntry, type ErrorLogEntry, type BreadcrumbEntry } from './RewindLog';
2
+ import { generateExecutiveSummary, exportReadableHtmlReport, formatTicketClipboardSummary, formatTeamsTicket, formatSlackTicket, formatWhatsAppTicket, formatJiraTicket, formatMarkdownTicket, formatCompactOneLiner, type ClipboardFormat, type ExecutiveIncidentSummary } from './ReportTranslator';
3
+ import { computeTelemetrySha256, encryptPayloadWithAesGcm, decryptPayloadWithAesGcm, scrubBankingFreeText, sanitizeBankingUrl, passesLuhnCheck } from './BankingSecurity';
4
+ import { RewindLogFloatingWidget } from './RewindLogFloatingWidget';
5
+ import { ReplayStudio } from './ReplayStudio';
6
+ import { injectVanillaWidget } from './vanilla-widget';
7
+ export interface InitRewindLogOptions extends RewindLogConfig {
8
+ /**
9
+ * Whether to automatically inject the floating bug reporter button into document.body.
10
+ * Default: true (for script tag / non-React setups). Set to false when rendering <RewindLogFloatingWidget /> in React.
11
+ */
12
+ autoInjectWidget?: boolean;
13
+ }
14
+ /**
15
+ * Initializes and starts the RewindLog SDK with 1 single call.
16
+ * Automatically injects the floating widget if `autoInjectWidget !== false`.
17
+ */
18
+ export declare function init(options?: InitRewindLogOptions): RewindLogSDK;
19
+ /**
20
+ * Returns the current active global instance of RewindLogSDK (if initialized).
21
+ */
22
+ export declare function getInstance(): RewindLogSDK | null;
23
+ /**
24
+ * Destroys active SDK recorder and removes injected DOM widgets.
25
+ */
26
+ export declare function destroy(): void;
27
+ export { RewindLogSDK, RewindLogFloatingWidget, ReplayStudio, injectVanillaWidget, generateExecutiveSummary, exportReadableHtmlReport, formatTicketClipboardSummary, formatTeamsTicket, formatSlackTicket, formatWhatsAppTicket, formatJiraTicket, formatMarkdownTicket, formatCompactOneLiner, computeTelemetrySha256, encryptPayloadWithAesGcm, decryptPayloadWithAesGcm, scrubBankingFreeText, sanitizeBankingUrl, passesLuhnCheck, };
28
+ export type { RewindLogConfig, RewindLogStats, BugReportPayload, IssueAnnotation, NetworkLogEntry, ConsoleLogEntry, ErrorLogEntry, BreadcrumbEntry, ClipboardFormat, ExecutiveIncidentSummary, };
29
+ declare const RewindLog: {
30
+ init: typeof init;
31
+ getInstance: typeof getInstance;
32
+ destroy: typeof destroy;
33
+ RewindLogSDK: typeof RewindLogSDK;
34
+ injectVanillaWidget: typeof injectVanillaWidget;
35
+ generateExecutiveSummary: typeof generateExecutiveSummary;
36
+ exportReadableHtmlReport: typeof exportReadableHtmlReport;
37
+ formatTicketClipboardSummary: typeof formatTicketClipboardSummary;
38
+ computeTelemetrySha256: typeof computeTelemetrySha256;
39
+ encryptPayloadWithAesGcm: typeof encryptPayloadWithAesGcm;
40
+ decryptPayloadWithAesGcm: typeof decryptPayloadWithAesGcm;
41
+ };
42
+ export default RewindLog;
package/dist/lite.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ import { RewindLogSDK, type RewindLogConfig, type RewindLogStats, type BugReportPayload } from './RewindLog';
2
+ import { formatTicketClipboardSummary, exportReadableHtmlReport, formatTeamsTicket, formatSlackTicket, formatWhatsAppTicket, formatJiraTicket, type ClipboardFormat } from './ReportTranslator';
3
+ import { injectVanillaWidget } from './vanilla-widget';
4
+ export interface InitLiteOptions extends Omit<RewindLogConfig, 'mode'> {
5
+ autoInjectWidget?: boolean;
6
+ }
7
+ export declare function initLite(options?: InitLiteOptions): RewindLogSDK;
8
+ export { RewindLogSDK, formatTicketClipboardSummary, exportReadableHtmlReport, formatTeamsTicket, formatSlackTicket, formatWhatsAppTicket, formatJiraTicket, injectVanillaWidget, };
9
+ export type { RewindLogConfig, RewindLogStats, BugReportPayload, ClipboardFormat };