@burdenoff/ui-engine 0.0.0-stage → 2026.1127.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.
- package/LICENSE +25 -0
- package/README.md +62 -2
- package/dist/capture.d.ts +118 -0
- package/dist/capture.js +14 -0
- package/dist/index-05zgh18g.js +210 -0
- package/dist/index-3v887c75.js +52 -0
- package/dist/index-c6pmt2rg.js +213 -0
- package/dist/index-phd8yhyg.js +224 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +62 -0
- package/dist/recording.d.ts +214 -0
- package/dist/recording.js +28 -0
- package/dist/redact-credentials.d.ts +39 -0
- package/dist/replay.d.ts +144 -0
- package/dist/replay.js +20 -0
- package/dist/resolve.d.ts +43 -0
- package/dist/resolve.js +10 -0
- package/package.json +94 -4
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
// src/recording.ts
|
|
2
|
+
import { sha256 as nobleSha256 } from "@noble/hashes/sha2.js";
|
|
3
|
+
import { bytesToHex, utf8ToBytes } from "@noble/hashes/utils.js";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
|
|
6
|
+
// src/redact-credentials.ts
|
|
7
|
+
var REDACTED2 = "[REDACTED]";
|
|
8
|
+
var CREDENTIAL_PATTERNS = [
|
|
9
|
+
/\b(?:Bearer|Basic)\s+[^\s"'`,;)\]}]+/gi,
|
|
10
|
+
/\b(?:sk|pk|rk|xai)-[^\s"'`,;)\]}]+/gi,
|
|
11
|
+
/\b(?:gsk|hf|ghp|gho|ghs|ghu|glpat)_[^\s"'`,;)\]}]+/gi,
|
|
12
|
+
/\bAIza[\w-]{10,}/g,
|
|
13
|
+
/\b(?:AKIA|ASIA)[0-9A-Z]{12,}/g
|
|
14
|
+
];
|
|
15
|
+
var SEPARATORS = /([\s"'`,;:=()[\]{}]+)/;
|
|
16
|
+
var SECRET_KEY = /^(?:api[_-]?key|access[_-]?key|secret|secret[_-]?key|client[_-]?secret|token|password)$/i;
|
|
17
|
+
function isMaskedFragment(word) {
|
|
18
|
+
const ellipsis = word.indexOf("…");
|
|
19
|
+
return word.includes("***") || ellipsis !== -1 && ellipsis < word.length - 1;
|
|
20
|
+
}
|
|
21
|
+
function redactWords(text) {
|
|
22
|
+
const parts = text.split(SEPARATORS);
|
|
23
|
+
for (let index = 0;index < parts.length; index += 2) {
|
|
24
|
+
const word = parts[index] ?? "";
|
|
25
|
+
if (word && word !== REDACTED2 && isMaskedFragment(word))
|
|
26
|
+
parts[index] = REDACTED2;
|
|
27
|
+
const separator = parts[index + 1] ?? "";
|
|
28
|
+
const next = parts[index + 2];
|
|
29
|
+
if (next && SECRET_KEY.test(word) && /[:=]/.test(separator))
|
|
30
|
+
parts[index + 2] = REDACTED2;
|
|
31
|
+
}
|
|
32
|
+
return parts.join("");
|
|
33
|
+
}
|
|
34
|
+
function redactCredentials2(text) {
|
|
35
|
+
if (!text)
|
|
36
|
+
return text;
|
|
37
|
+
let redacted = text;
|
|
38
|
+
for (const pattern of CREDENTIAL_PATTERNS) {
|
|
39
|
+
redacted = redacted.replace(pattern, REDACTED2);
|
|
40
|
+
}
|
|
41
|
+
redacted = redactWords(redacted);
|
|
42
|
+
return redacted.replace(/(?:\[REDACTED\]){2,}/g, REDACTED2);
|
|
43
|
+
}
|
|
44
|
+
var MARKER_PROBE = "";
|
|
45
|
+
function containsCredential(text) {
|
|
46
|
+
if (!text)
|
|
47
|
+
return false;
|
|
48
|
+
const probe = text.replaceAll(REDACTED2, MARKER_PROBE);
|
|
49
|
+
return redactCredentials2(probe).replaceAll(MARKER_PROBE, REDACTED2) !== text;
|
|
50
|
+
}
|
|
51
|
+
function decodeUriText(text) {
|
|
52
|
+
try {
|
|
53
|
+
return decodeURIComponent(text.replaceAll("+", " "));
|
|
54
|
+
} catch {
|
|
55
|
+
return text;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function containsCredentialInUrl(text) {
|
|
59
|
+
return containsCredential(decodeUriText(text).replace(/[/?&#]/g, " "));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// src/recording.ts
|
|
63
|
+
function sha256Hex2(text) {
|
|
64
|
+
return bytesToHex(nobleSha256(utf8ToBytes(text)));
|
|
65
|
+
}
|
|
66
|
+
var RECORDING_VERSION2 = 1;
|
|
67
|
+
var MAX_RECORDED_STEPS2 = 200;
|
|
68
|
+
var MAX_LABEL = 512;
|
|
69
|
+
var MAX_TEXT = 4000;
|
|
70
|
+
var MAX_INTENT = 500;
|
|
71
|
+
var SAVED_STEP_AUTHORS2 = ["PERSON", "TEACH_MODE", "IMPORT"];
|
|
72
|
+
var REPLAYABLE_ACTIONS2 = [
|
|
73
|
+
"click",
|
|
74
|
+
"type",
|
|
75
|
+
"secret_fill",
|
|
76
|
+
"key",
|
|
77
|
+
"scroll",
|
|
78
|
+
"navigate",
|
|
79
|
+
"focus_window"
|
|
80
|
+
];
|
|
81
|
+
var label = z.string().trim().min(1).max(MAX_LABEL);
|
|
82
|
+
var recordedTargetSchema2 = z.strictObject({
|
|
83
|
+
app: label.optional(),
|
|
84
|
+
window: label.optional(),
|
|
85
|
+
role: label,
|
|
86
|
+
name: label,
|
|
87
|
+
nth: z.int().min(0).max(50).default(0)
|
|
88
|
+
});
|
|
89
|
+
var stepBase = {
|
|
90
|
+
id: z.string().regex(/^[A-Za-z0-9_-]{1,64}$/),
|
|
91
|
+
intent: z.string().trim().min(1).max(MAX_INTENT),
|
|
92
|
+
screenshotRef: z.string().regex(/^[A-Za-z0-9][A-Za-z0-9:/._-]{0,511}$/).optional(),
|
|
93
|
+
fingerprint: z.string().regex(/^[0-9a-f]{64}$/)
|
|
94
|
+
};
|
|
95
|
+
var targeted = { ...stepBase, target: recordedTargetSchema2 };
|
|
96
|
+
var recordedStepSchema2 = z.discriminatedUnion("action", [
|
|
97
|
+
z.strictObject({
|
|
98
|
+
...targeted,
|
|
99
|
+
action: z.literal("click"),
|
|
100
|
+
button: z.enum(["left", "right"]).default("left"),
|
|
101
|
+
count: z.union([z.literal(1), z.literal(2)]).default(1)
|
|
102
|
+
}),
|
|
103
|
+
z.strictObject({
|
|
104
|
+
...stepBase,
|
|
105
|
+
action: z.literal("type"),
|
|
106
|
+
target: recordedTargetSchema2.optional(),
|
|
107
|
+
text: z.string().max(MAX_TEXT).optional(),
|
|
108
|
+
masked: z.boolean().default(false)
|
|
109
|
+
}),
|
|
110
|
+
z.strictObject({
|
|
111
|
+
...targeted,
|
|
112
|
+
action: z.literal("secret_fill"),
|
|
113
|
+
secretRef: z.string().regex(/^[A-Za-z0-9][A-Za-z0-9:/._-]{0,254}$/),
|
|
114
|
+
expectedOrigin: z.url({ protocol: /^https?$/ })
|
|
115
|
+
}),
|
|
116
|
+
z.strictObject({ ...stepBase, action: z.literal("key"), keys: z.array(z.string().min(1).max(32)).min(1).max(8) }),
|
|
117
|
+
z.strictObject({
|
|
118
|
+
...stepBase,
|
|
119
|
+
action: z.literal("scroll"),
|
|
120
|
+
target: recordedTargetSchema2.optional(),
|
|
121
|
+
dx: z.int().min(-1e4).max(1e4),
|
|
122
|
+
dy: z.int().min(-1e4).max(1e4)
|
|
123
|
+
}),
|
|
124
|
+
z.strictObject({ ...stepBase, action: z.literal("navigate"), url: z.url({ protocol: /^https?$/ }).max(2048) }),
|
|
125
|
+
z.strictObject({
|
|
126
|
+
...stepBase,
|
|
127
|
+
action: z.literal("focus_window"),
|
|
128
|
+
app: label,
|
|
129
|
+
title: label.optional()
|
|
130
|
+
})
|
|
131
|
+
]);
|
|
132
|
+
var recordingSchema2 = z.strictObject({
|
|
133
|
+
version: z.literal(RECORDING_VERSION2),
|
|
134
|
+
steps: z.array(recordedStepSchema2).min(1).max(MAX_RECORDED_STEPS2)
|
|
135
|
+
});
|
|
136
|
+
function targetFingerprint2(step) {
|
|
137
|
+
const target = "target" in step && step.target ? step.target : undefined;
|
|
138
|
+
return sha256Hex2(JSON.stringify([
|
|
139
|
+
step.action,
|
|
140
|
+
target?.app ?? null,
|
|
141
|
+
target?.window ?? null,
|
|
142
|
+
target?.role ?? null,
|
|
143
|
+
target?.name ?? null,
|
|
144
|
+
target?.nth ?? 0,
|
|
145
|
+
"url" in step ? step.url ?? null : null,
|
|
146
|
+
"app" in step ? step.app ?? null : null,
|
|
147
|
+
"title" in step ? step.title ?? null : null
|
|
148
|
+
]));
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
class RecordingError2 extends Error {
|
|
152
|
+
code;
|
|
153
|
+
constructor(code, message) {
|
|
154
|
+
super(message);
|
|
155
|
+
this.code = code;
|
|
156
|
+
this.name = "RecordingError";
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
function parseRecording2(value) {
|
|
160
|
+
const parsed = recordingSchema2.safeParse(value);
|
|
161
|
+
if (!parsed.success) {
|
|
162
|
+
const issue = parsed.error.issues[0];
|
|
163
|
+
const where = issue?.path.map(String).join(".") ?? "";
|
|
164
|
+
throw new RecordingError2("INVALID_RECORDING", `Recording is not valid at ${where || "the top"}: ${issue?.message}`);
|
|
165
|
+
}
|
|
166
|
+
const ids = new Set;
|
|
167
|
+
for (const step of parsed.data.steps) {
|
|
168
|
+
if (ids.has(step.id))
|
|
169
|
+
throw new RecordingError2("DUPLICATE_STEP_ID", `Step id ${step.id} is used twice.`);
|
|
170
|
+
ids.add(step.id);
|
|
171
|
+
if (targetFingerprint2(step) !== step.fingerprint) {
|
|
172
|
+
throw new RecordingError2("FINGERPRINT_MISMATCH", `Step ${step.id} was changed after it was recorded.`);
|
|
173
|
+
}
|
|
174
|
+
const field = credentialField(step);
|
|
175
|
+
if (field) {
|
|
176
|
+
throw new RecordingError2("CREDENTIAL_IN_RECORDING", `Step ${step.id} holds a credential in its ${field}.`);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return parsed.data;
|
|
180
|
+
}
|
|
181
|
+
function storedText(step) {
|
|
182
|
+
const target = "target" in step ? step.target : undefined;
|
|
183
|
+
const fields = [
|
|
184
|
+
["intent", step.intent],
|
|
185
|
+
["target app", target?.app],
|
|
186
|
+
["target window", target?.window],
|
|
187
|
+
["target role", target?.role],
|
|
188
|
+
["target name", target?.name]
|
|
189
|
+
];
|
|
190
|
+
switch (step.action) {
|
|
191
|
+
case "type":
|
|
192
|
+
return [...fields, ["text", step.text]];
|
|
193
|
+
case "navigate":
|
|
194
|
+
return fields;
|
|
195
|
+
case "focus_window":
|
|
196
|
+
return [...fields, ["app", step.app], ["title", step.title]];
|
|
197
|
+
default:
|
|
198
|
+
return fields;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
function credentialField(step) {
|
|
202
|
+
if (step.action === "navigate") {
|
|
203
|
+
const url = new URL(step.url);
|
|
204
|
+
if (url.username || url.password || containsCredentialInUrl(step.url))
|
|
205
|
+
return "url";
|
|
206
|
+
}
|
|
207
|
+
return storedText(step).find(([, value]) => value !== undefined && containsCredential(value))?.[0];
|
|
208
|
+
}
|
|
209
|
+
function isSavedStepAuthor2(value) {
|
|
210
|
+
return typeof value === "string" && SAVED_STEP_AUTHORS2.includes(value);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
export { REDACTED2, redactCredentials2, containsCredential, decodeUriText, containsCredentialInUrl, sha256Hex2, RECORDING_VERSION2, MAX_RECORDED_STEPS2, SAVED_STEP_AUTHORS2, REPLAYABLE_ACTIONS2, recordedTargetSchema2, recordedStepSchema2, recordingSchema2, targetFingerprint2, RecordingError2, parseRecording2, isSavedStepAuthor2 };
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import {
|
|
2
|
+
REDACTED2,
|
|
3
|
+
redactCredentials2,
|
|
4
|
+
containsCredential,
|
|
5
|
+
decodeUriText,
|
|
6
|
+
containsCredentialInUrl,
|
|
7
|
+
RECORDING_VERSION2,
|
|
8
|
+
targetFingerprint2,
|
|
9
|
+
parseRecording2
|
|
10
|
+
} from "./index-c6pmt2rg.js";
|
|
11
|
+
|
|
12
|
+
// src/capture.ts
|
|
13
|
+
var SECRET_FIELD = /password|passcode|passwd|\bpin\b|otp|one[\s-]?time|verification|security code|auth(?:entication)? code|\bcvv\b|\bcvc\b|card number|secret|token|recovery/i;
|
|
14
|
+
var SECRET_AUTOCOMPLETE = /password|one-time-code|^cc-/i;
|
|
15
|
+
var SECRET_PARAM = /token|code|key|secret|sig|signature|auth|password|passwd|otp|session|state|reset|nonce|ticket|hash/i;
|
|
16
|
+
var RESET_PATH = /reset|recover|verify|verification|magic|confirm|activate|invite|unsubscribe/i;
|
|
17
|
+
var SECRET_LABEL = /code|pin|otp|password|passcode|token|verification|one[\s-]?time/i;
|
|
18
|
+
var CODE_LIKE = /^[\d ]{4,10}$/;
|
|
19
|
+
function isSecretField(element) {
|
|
20
|
+
if (!element)
|
|
21
|
+
return false;
|
|
22
|
+
if (element.inputType?.toLowerCase() === "password")
|
|
23
|
+
return true;
|
|
24
|
+
if (element.autocomplete && SECRET_AUTOCOMPLETE.test(element.autocomplete))
|
|
25
|
+
return true;
|
|
26
|
+
return SECRET_FIELD.test(element.name);
|
|
27
|
+
}
|
|
28
|
+
function cleanLabel(text) {
|
|
29
|
+
const cleaned = redactCredentials2(text);
|
|
30
|
+
return (SECRET_LABEL.test(cleaned) ? cleaned.replace(/\d{4,}/g, REDACTED2) : cleaned).trim();
|
|
31
|
+
}
|
|
32
|
+
var MIN_SCRUBBED_SECRET = 4;
|
|
33
|
+
function scrubberFor(secrets) {
|
|
34
|
+
const known = [...new Set(secrets.filter((secret) => secret.length >= MIN_SCRUBBED_SECRET))].sort((a, b) => b.length - a.length);
|
|
35
|
+
const holds = (part) => {
|
|
36
|
+
const decoded = decodeUriText(part);
|
|
37
|
+
return known.some((secret) => part.includes(secret) || decoded.includes(secret));
|
|
38
|
+
};
|
|
39
|
+
const scrub = Object.assign((text) => known.reduce((out, secret) => out.replaceAll(secret, REDACTED2), text), {
|
|
40
|
+
url: (raw) => {
|
|
41
|
+
const url = new URL(raw);
|
|
42
|
+
if (holds(url.search) || holds(url.hash)) {
|
|
43
|
+
url.search = "";
|
|
44
|
+
url.hash = "";
|
|
45
|
+
}
|
|
46
|
+
if (holds(url.pathname))
|
|
47
|
+
url.pathname = "/";
|
|
48
|
+
return url.toString();
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
return scrub;
|
|
52
|
+
}
|
|
53
|
+
function scrubTarget(target, scrub) {
|
|
54
|
+
return {
|
|
55
|
+
...target,
|
|
56
|
+
...target.app ? { app: scrub(target.app) } : {},
|
|
57
|
+
...target.window ? { window: scrub(target.window) } : {},
|
|
58
|
+
role: scrub(target.role),
|
|
59
|
+
name: scrub(target.name)
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function scrubDraft(draft, scrub) {
|
|
63
|
+
const intent = scrub(draft.intent);
|
|
64
|
+
switch (draft.action) {
|
|
65
|
+
case "click":
|
|
66
|
+
case "secret_fill":
|
|
67
|
+
return { ...draft, intent, target: scrubTarget(draft.target, scrub) };
|
|
68
|
+
case "scroll":
|
|
69
|
+
return { ...draft, intent, ...draft.target ? { target: scrubTarget(draft.target, scrub) } : {} };
|
|
70
|
+
case "focus_window":
|
|
71
|
+
return { ...draft, intent, app: scrub(draft.app), ...draft.title ? { title: scrub(draft.title) } : {} };
|
|
72
|
+
case "type": {
|
|
73
|
+
const target = draft.target ? { target: scrubTarget(draft.target, scrub) } : {};
|
|
74
|
+
if (draft.text === undefined || scrub(draft.text) === draft.text) {
|
|
75
|
+
return { ...draft, intent, ...target };
|
|
76
|
+
}
|
|
77
|
+
const screenshotRef = draft.screenshotRef ? { screenshotRef: draft.screenshotRef } : {};
|
|
78
|
+
return { id: draft.id, intent, ...screenshotRef, ...target, action: "type", masked: true };
|
|
79
|
+
}
|
|
80
|
+
case "navigate":
|
|
81
|
+
return { ...draft, intent, url: scrub.url(draft.url) };
|
|
82
|
+
case "key":
|
|
83
|
+
return { ...draft, intent };
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function targetOf(element) {
|
|
87
|
+
return {
|
|
88
|
+
...element.app ? { app: cleanLabel(element.app) } : {},
|
|
89
|
+
...element.window ? { window: cleanLabel(element.window) } : {},
|
|
90
|
+
role: cleanLabel(element.role),
|
|
91
|
+
name: cleanLabel(element.name),
|
|
92
|
+
nth: element.nth ?? 0
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function resetLinkKeep(segments) {
|
|
96
|
+
const index = segments.findIndex((segment) => RESET_PATH.test(decodeUriText(segment)));
|
|
97
|
+
if (index === -1)
|
|
98
|
+
return;
|
|
99
|
+
const segment = decodeUriText(segments[index] ?? "");
|
|
100
|
+
return /\d/.test(segment) || segment.length > 64 ? index : index + 1;
|
|
101
|
+
}
|
|
102
|
+
function sensitiveValues(params, everyValue) {
|
|
103
|
+
return [...params.entries()].filter(([name, value]) => everyValue || SECRET_PARAM.test(name) || containsCredential(value)).map(([, value]) => value);
|
|
104
|
+
}
|
|
105
|
+
function maskUrlParts(raw) {
|
|
106
|
+
const url = new URL(raw);
|
|
107
|
+
const removed = [url.username, url.password].map(decodeUriText);
|
|
108
|
+
url.username = "";
|
|
109
|
+
url.password = "";
|
|
110
|
+
const params = [...url.searchParams.keys()];
|
|
111
|
+
const resetLink = RESET_PATH.test(decodeUriText(url.pathname));
|
|
112
|
+
const credentialInPath = containsCredentialInUrl(url.pathname);
|
|
113
|
+
const carriesSecret = params.some((name) => SECRET_PARAM.test(name)) || resetLink || credentialInPath || SECRET_PARAM.test(url.hash) || containsCredentialInUrl(url.search) || containsCredentialInUrl(url.hash);
|
|
114
|
+
if (!carriesSecret) {
|
|
115
|
+
return { url: url.toString(), masked: raw !== url.toString(), removed: removed.filter(Boolean) };
|
|
116
|
+
}
|
|
117
|
+
removed.push(...sensitiveValues(url.searchParams, resetLink));
|
|
118
|
+
const fragment = url.hash.slice(1);
|
|
119
|
+
if (fragment.includes("="))
|
|
120
|
+
removed.push(...sensitiveValues(new URLSearchParams(fragment), resetLink));
|
|
121
|
+
else if (fragment && (resetLink || SECRET_PARAM.test(fragment)))
|
|
122
|
+
removed.push(decodeUriText(fragment));
|
|
123
|
+
url.search = "";
|
|
124
|
+
url.hash = "";
|
|
125
|
+
const segments = url.pathname.split("/");
|
|
126
|
+
const keep = credentialInPath ? 1 : resetLink ? resetLinkKeep(segments) : undefined;
|
|
127
|
+
if (keep !== undefined) {
|
|
128
|
+
if (!credentialInPath)
|
|
129
|
+
removed.push(...segments.slice(keep).map(decodeUriText));
|
|
130
|
+
url.pathname = segments.slice(0, keep).join("/") || "/";
|
|
131
|
+
}
|
|
132
|
+
return { url: url.toString(), masked: true, removed: removed.filter(Boolean) };
|
|
133
|
+
}
|
|
134
|
+
function maskUrl2(raw) {
|
|
135
|
+
const { url, masked } = maskUrlParts(raw);
|
|
136
|
+
return { url, masked };
|
|
137
|
+
}
|
|
138
|
+
function captureRecording2(events) {
|
|
139
|
+
const drafts = [];
|
|
140
|
+
const capturedSecrets = [];
|
|
141
|
+
events.forEach((event, index) => {
|
|
142
|
+
const id = `s${index + 1}`;
|
|
143
|
+
const intent = redactCredentials2(event.intent?.trim() || `Step ${index + 1}: ${event.type}`).slice(0, 500);
|
|
144
|
+
const screenshotRef = event.screenshot?.masked ? { screenshotRef: event.screenshot.ref } : {};
|
|
145
|
+
const common = { id, intent, ...screenshotRef };
|
|
146
|
+
let draft;
|
|
147
|
+
switch (event.type) {
|
|
148
|
+
case "click":
|
|
149
|
+
draft = {
|
|
150
|
+
...common,
|
|
151
|
+
action: "click",
|
|
152
|
+
target: targetOf(event.element),
|
|
153
|
+
button: event.button ?? "left",
|
|
154
|
+
count: event.count ?? 1
|
|
155
|
+
};
|
|
156
|
+
break;
|
|
157
|
+
case "type": {
|
|
158
|
+
const target = event.element ? { target: targetOf(event.element) } : {};
|
|
159
|
+
const secret = isSecretField(event.element) || CODE_LIKE.test(event.text) || redactCredentials2(event.text) !== event.text;
|
|
160
|
+
if (secret) {
|
|
161
|
+
if (event.text)
|
|
162
|
+
capturedSecrets.push(event.text);
|
|
163
|
+
if (event.secretRef && event.origin && event.element) {
|
|
164
|
+
draft = {
|
|
165
|
+
...common,
|
|
166
|
+
action: "secret_fill",
|
|
167
|
+
target: targetOf(event.element),
|
|
168
|
+
secretRef: event.secretRef,
|
|
169
|
+
expectedOrigin: new URL(event.origin).origin
|
|
170
|
+
};
|
|
171
|
+
} else {
|
|
172
|
+
draft = { ...common, ...target, action: "type", masked: true };
|
|
173
|
+
}
|
|
174
|
+
} else {
|
|
175
|
+
draft = { ...common, ...target, action: "type", text: event.text, masked: false };
|
|
176
|
+
}
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
case "key":
|
|
180
|
+
draft = { ...common, action: "key", keys: [...event.keys] };
|
|
181
|
+
break;
|
|
182
|
+
case "scroll":
|
|
183
|
+
draft = {
|
|
184
|
+
...common,
|
|
185
|
+
...event.element ? { target: targetOf(event.element) } : {},
|
|
186
|
+
action: "scroll",
|
|
187
|
+
dx: Math.trunc(event.dx),
|
|
188
|
+
dy: Math.trunc(event.dy)
|
|
189
|
+
};
|
|
190
|
+
break;
|
|
191
|
+
case "navigate": {
|
|
192
|
+
const masked = maskUrlParts(event.url);
|
|
193
|
+
if (masked.masked)
|
|
194
|
+
capturedSecrets.push(event.url, ...masked.removed);
|
|
195
|
+
draft = { ...common, action: "navigate", url: masked.url };
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
case "focus_window":
|
|
199
|
+
draft = {
|
|
200
|
+
...common,
|
|
201
|
+
action: "focus_window",
|
|
202
|
+
app: cleanLabel(event.app),
|
|
203
|
+
...event.title ? { title: cleanLabel(event.title) } : {}
|
|
204
|
+
};
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
207
|
+
drafts.push(draft);
|
|
208
|
+
});
|
|
209
|
+
const scrub = scrubberFor(capturedSecrets);
|
|
210
|
+
const steps = drafts.map((original) => {
|
|
211
|
+
const draft = scrubDraft(original, scrub);
|
|
212
|
+
return { ...draft, fingerprint: targetFingerprint2(draft) };
|
|
213
|
+
});
|
|
214
|
+
for (const step of steps) {
|
|
215
|
+
if (step.screenshotRef && capturedSecrets.some((secret) => secret && step.screenshotRef?.includes(secret))) {
|
|
216
|
+
delete step.screenshotRef;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
const recording = parseRecording2({ version: RECORDING_VERSION2, steps });
|
|
220
|
+
const maskedStepIds = recording.steps.filter((step) => step.action === "type" && step.masked).map((step) => step.id);
|
|
221
|
+
return { recording, maskedStepIds, capturedSecrets };
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
export { maskUrl2, captureRecording2 };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @burdenoff/ui-engine: the shared, browser-safe UI automation engine.
|
|
3
|
+
*
|
|
4
|
+
* Each module is also published as its own subpath (`@burdenoff/ui-engine/recording`,
|
|
5
|
+
* `/capture`, `/resolve`, `/replay`), so a consumer can load only what it uses.
|
|
6
|
+
*/
|
|
7
|
+
export { MAX_RECORDED_STEPS, RECORDING_VERSION, REPLAYABLE_ACTIONS, type RecordedStep, type RecordedTarget, type Recording, RecordingError, type ReplayableAction, SAVED_STEP_AUTHORS, type SavedStepAuthor, isSavedStepAuthor, parseRecording, recordedStepSchema, recordedTargetSchema, recordingSchema, sha256Hex, targetFingerprint, } from './recording.js';
|
|
8
|
+
export { type CaptureResult, REDACTED, type RecorderElement, type RecorderEvent, type RecorderScreenshot, captureRecording, maskUrl, redactCredentials, } from './capture.js';
|
|
9
|
+
export { MAX_SNAPSHOT_NODES, type ResolveOutcome, type SnapshotNode, readSnapshotNodes, resolveTarget, } from './resolve.js';
|
|
10
|
+
export { type FallbackReason, type ReplayCallKind, type ReplayCallOutcome, type ReplayChatMessage, type ReplayFunctionCall, type ReplayOptions, type ReplayPlan, type ReplaySource, type ReplayState, afterReplayCall, finishFallback, markFallbackAsked, planReplay, readReplayState, replayReasons, replayStateFrom, } from './replay.js';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import {
|
|
2
|
+
REDACTED2,
|
|
3
|
+
redactCredentials2,
|
|
4
|
+
sha256Hex2,
|
|
5
|
+
RECORDING_VERSION2,
|
|
6
|
+
MAX_RECORDED_STEPS2,
|
|
7
|
+
SAVED_STEP_AUTHORS2,
|
|
8
|
+
REPLAYABLE_ACTIONS2,
|
|
9
|
+
recordedTargetSchema2,
|
|
10
|
+
recordedStepSchema2,
|
|
11
|
+
recordingSchema2,
|
|
12
|
+
targetFingerprint2,
|
|
13
|
+
RecordingError2,
|
|
14
|
+
parseRecording2,
|
|
15
|
+
isSavedStepAuthor2
|
|
16
|
+
} from "./index-c6pmt2rg.js";
|
|
17
|
+
import {
|
|
18
|
+
maskUrl2,
|
|
19
|
+
captureRecording2
|
|
20
|
+
} from "./index-phd8yhyg.js";
|
|
21
|
+
import {
|
|
22
|
+
MAX_SNAPSHOT_NODES2,
|
|
23
|
+
readSnapshotNodes2,
|
|
24
|
+
resolveTarget2
|
|
25
|
+
} from "./index-3v887c75.js";
|
|
26
|
+
import {
|
|
27
|
+
replayStateFrom2,
|
|
28
|
+
readReplayState2,
|
|
29
|
+
planReplay2,
|
|
30
|
+
afterReplayCall2,
|
|
31
|
+
finishFallback2,
|
|
32
|
+
markFallbackAsked2,
|
|
33
|
+
replayReasons2
|
|
34
|
+
} from "./index-05zgh18g.js";
|
|
35
|
+
export {
|
|
36
|
+
MAX_RECORDED_STEPS2 as MAX_RECORDED_STEPS,
|
|
37
|
+
MAX_SNAPSHOT_NODES2 as MAX_SNAPSHOT_NODES,
|
|
38
|
+
RECORDING_VERSION2 as RECORDING_VERSION,
|
|
39
|
+
REDACTED2 as REDACTED,
|
|
40
|
+
REPLAYABLE_ACTIONS2 as REPLAYABLE_ACTIONS,
|
|
41
|
+
RecordingError2 as RecordingError,
|
|
42
|
+
SAVED_STEP_AUTHORS2 as SAVED_STEP_AUTHORS,
|
|
43
|
+
afterReplayCall2 as afterReplayCall,
|
|
44
|
+
captureRecording2 as captureRecording,
|
|
45
|
+
finishFallback2 as finishFallback,
|
|
46
|
+
isSavedStepAuthor2 as isSavedStepAuthor,
|
|
47
|
+
markFallbackAsked2 as markFallbackAsked,
|
|
48
|
+
maskUrl2 as maskUrl,
|
|
49
|
+
parseRecording2 as parseRecording,
|
|
50
|
+
planReplay2 as planReplay,
|
|
51
|
+
readReplayState2 as readReplayState,
|
|
52
|
+
readSnapshotNodes2 as readSnapshotNodes,
|
|
53
|
+
recordedStepSchema2 as recordedStepSchema,
|
|
54
|
+
recordedTargetSchema2 as recordedTargetSchema,
|
|
55
|
+
recordingSchema2 as recordingSchema,
|
|
56
|
+
redactCredentials2 as redactCredentials,
|
|
57
|
+
replayReasons2 as replayReasons,
|
|
58
|
+
replayStateFrom2 as replayStateFrom,
|
|
59
|
+
resolveTarget2 as resolveTarget,
|
|
60
|
+
sha256Hex2 as sha256Hex,
|
|
61
|
+
targetFingerprint2 as targetFingerprint
|
|
62
|
+
};
|