@corbado/observe 1.9.1 → 1.10.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/dist/analysis/client.mjs +183 -14
- package/dist/analysis/config.mjs +5 -5
- package/dist/analysis/cross-origin-session.mjs +422 -0
- package/dist/analysis/device.mjs +0 -79
- package/dist/analysis/low-events/grouped-input-tracker.mjs +2 -3
- package/dist/analysis/low-events/input-change-recorder.mjs +35 -12
- package/dist/analysis/low-events/input-tracker.mjs +0 -58
- package/dist/analysis/queue.mjs +9 -0
- package/dist/analysis/readers/network.mjs +5 -0
- package/dist/analysis/readers/page.mjs +4 -0
- package/dist/analysis/transports/fetch.mjs +16 -1
- package/dist/analysis/utils/operation-full.mjs +0 -1
- package/dist/analysis/version.mjs +1 -1
- package/dist/cdn/script.global.js +4 -4
- package/dist/index.d.mts +130 -30
- package/dist/index.d.ts +130 -30
- package/dist/index.js +4 -4
- package/dist/index.mjs +4 -4
- package/package.json +1 -1
- package/dist/analysis/readers/password-manager-dom.mjs +0 -112
|
@@ -3,9 +3,6 @@ import { InputChangeRecorder } from "./input-change-recorder.mjs";
|
|
|
3
3
|
import { InputPasteObserver } from "../readers/input-paste.mjs";
|
|
4
4
|
import { observeInputField, readFocusedField, readInputContentLength } from "../readers/input.mjs";
|
|
5
5
|
import { listenWindow } from "../readers/page.mjs";
|
|
6
|
-
import { readPasswordManagerDomSignals } from "../readers/password-manager-dom.mjs";
|
|
7
|
-
var MOUNT_PROBE_DELAY_MS = 500;
|
|
8
|
-
var FOCUS_PROBE_DELAY_MS = 250;
|
|
9
6
|
function fieldContentLength(field) {
|
|
10
7
|
return readInputContentLength(
|
|
11
8
|
{
|
|
@@ -85,10 +82,6 @@ var LowEventInputTracker = class {
|
|
|
85
82
|
removePageHide;
|
|
86
83
|
changes;
|
|
87
84
|
pasteObserver;
|
|
88
|
-
emittedSignals = /* @__PURE__ */ new Set();
|
|
89
|
-
firstFocusHandled = false;
|
|
90
|
-
mountProbeTimer = null;
|
|
91
|
-
focusProbeTimer = null;
|
|
92
85
|
destroyed = false;
|
|
93
86
|
destroy() {
|
|
94
87
|
if (this.destroyed) {
|
|
@@ -96,14 +89,6 @@ var LowEventInputTracker = class {
|
|
|
96
89
|
}
|
|
97
90
|
this.destroyed = true;
|
|
98
91
|
try {
|
|
99
|
-
if (this.mountProbeTimer !== null) {
|
|
100
|
-
clearTimeout(this.mountProbeTimer);
|
|
101
|
-
this.mountProbeTimer = null;
|
|
102
|
-
}
|
|
103
|
-
if (this.focusProbeTimer !== null) {
|
|
104
|
-
clearTimeout(this.focusProbeTimer);
|
|
105
|
-
this.focusProbeTimer = null;
|
|
106
|
-
}
|
|
107
92
|
this.changes.flush();
|
|
108
93
|
this.unregisterInputs?.();
|
|
109
94
|
this.pasteObserver.destroy();
|
|
@@ -204,9 +189,6 @@ var LowEventInputTracker = class {
|
|
|
204
189
|
this.handleFocus();
|
|
205
190
|
}
|
|
206
191
|
}
|
|
207
|
-
if (typeof window !== "undefined") {
|
|
208
|
-
this.mountProbeTimer = setTimeout(() => this.runEnvProbe(), MOUNT_PROBE_DELAY_MS);
|
|
209
|
-
}
|
|
210
192
|
}
|
|
211
193
|
detach() {
|
|
212
194
|
this.removeFieldListeners?.();
|
|
@@ -217,45 +199,6 @@ var LowEventInputTracker = class {
|
|
|
217
199
|
pushLow = (low) => {
|
|
218
200
|
this.sink.enqueueLowEvent(low);
|
|
219
201
|
};
|
|
220
|
-
runEnvProbe() {
|
|
221
|
-
try {
|
|
222
|
-
if (typeof __CBO_DATA_PMD__ === "boolean" ? __CBO_DATA_PMD__ : this.sink.passwordManagerDomScan?.() !== false) {
|
|
223
|
-
const matches = readPasswordManagerDomSignals({
|
|
224
|
-
key: "dom:password-managers.dom-signals",
|
|
225
|
-
title: "Password manager traces in the page",
|
|
226
|
-
accessNote: "DOM markers that password manager extensions insert (attributes, elements, styles)",
|
|
227
|
-
group: "Password manager detection",
|
|
228
|
-
origin: "observe-external",
|
|
229
|
-
fields: [
|
|
230
|
-
{
|
|
231
|
-
path: "signals[]",
|
|
232
|
-
label: "Password manager traces found",
|
|
233
|
-
exposure: "enum",
|
|
234
|
-
transform: { values: ["pa-1", "pa-2", "pa-3", "pa-4", "pa-5", "pa-6"] }
|
|
235
|
-
}
|
|
236
|
-
],
|
|
237
|
-
dataConfig: "pmd"
|
|
238
|
-
});
|
|
239
|
-
const now = Date.now();
|
|
240
|
-
for (const eventType of matches) {
|
|
241
|
-
if (this.emittedSignals.has(eventType)) {
|
|
242
|
-
continue;
|
|
243
|
-
}
|
|
244
|
-
this.emittedSignals.add(eventType);
|
|
245
|
-
this.pushLow({ lowType: eventType, ts: now });
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
} catch (error) {
|
|
249
|
-
this.logger.error("Failed to run input env probe", error);
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
scheduleFocusProbe() {
|
|
253
|
-
if (this.firstFocusHandled) {
|
|
254
|
-
return;
|
|
255
|
-
}
|
|
256
|
-
this.firstFocusHandled = true;
|
|
257
|
-
this.focusProbeTimer = setTimeout(() => this.runEnvProbe(), FOCUS_PROBE_DELAY_MS);
|
|
258
|
-
}
|
|
259
202
|
capturePrefill(newCapture = false) {
|
|
260
203
|
if (this.destroyed) return;
|
|
261
204
|
this.flushPending();
|
|
@@ -270,7 +213,6 @@ var LowEventInputTracker = class {
|
|
|
270
213
|
this.pushLow({ lowType: eventType, ts: Date.now() });
|
|
271
214
|
}
|
|
272
215
|
handleFocus() {
|
|
273
|
-
this.scheduleFocusProbe();
|
|
274
216
|
this.enqueueNonInputEvent("focus");
|
|
275
217
|
}
|
|
276
218
|
handleBlur() {
|
package/dist/analysis/queue.mjs
CHANGED
|
@@ -37,6 +37,7 @@ var RequestQueue = class {
|
|
|
37
37
|
this.requestConfig = options.requestConfig ?? true;
|
|
38
38
|
this.onConfigReceived = options.onConfigReceived;
|
|
39
39
|
this.getDataPolicy = options.getDataPolicy;
|
|
40
|
+
this.getCrossOriginSession = options.getCrossOriginSession;
|
|
40
41
|
this.fixedData = options.fixedData === true;
|
|
41
42
|
this.beforeEventBatchSend = options.beforeEventBatchSend;
|
|
42
43
|
this.standaloneDeviceInfo = options.standaloneDeviceInfo;
|
|
@@ -105,6 +106,7 @@ var RequestQueue = class {
|
|
|
105
106
|
requestConfig;
|
|
106
107
|
onConfigReceived;
|
|
107
108
|
getDataPolicy;
|
|
109
|
+
getCrossOriginSession;
|
|
108
110
|
fixedData;
|
|
109
111
|
beforeEventBatchSend;
|
|
110
112
|
standaloneDeviceInfo;
|
|
@@ -487,6 +489,13 @@ var RequestQueue = class {
|
|
|
487
489
|
if (this.fixedData) {
|
|
488
490
|
batch.meta = { ...batch.meta, fixedData: true };
|
|
489
491
|
}
|
|
492
|
+
try {
|
|
493
|
+
const crossOriginSession = this.getCrossOriginSession?.(batch.sessionId);
|
|
494
|
+
if (crossOriginSession) {
|
|
495
|
+
batch.meta = { ...batch.meta, crossOriginSession };
|
|
496
|
+
}
|
|
497
|
+
} catch {
|
|
498
|
+
}
|
|
490
499
|
const retryCount = entries.reduce((max, entry) => Math.max(max, entry.attempts), 0);
|
|
491
500
|
if (retryCount > 0) {
|
|
492
501
|
batch.meta = { ...batch.meta, retryCount };
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
// src/readers/network.ts
|
|
2
|
+
var declaredByBrowser = /* @__PURE__ */ new Set();
|
|
3
|
+
function declareBrowserRequestData(meta) {
|
|
4
|
+
declaredByBrowser.add(meta);
|
|
5
|
+
}
|
|
2
6
|
function sendFetch(_meta, url, init) {
|
|
3
7
|
return fetch(url, init);
|
|
4
8
|
}
|
|
@@ -10,5 +14,6 @@ function beaconSender(_meta) {
|
|
|
10
14
|
}
|
|
11
15
|
export {
|
|
12
16
|
beaconSender,
|
|
17
|
+
declareBrowserRequestData,
|
|
13
18
|
sendFetch
|
|
14
19
|
};
|
|
@@ -21,8 +21,12 @@ function readSourcePath(_meta, mode, allow) {
|
|
|
21
21
|
const search = applySourcePathQuery(window.location.search, mode, allow);
|
|
22
22
|
return `${window.location.pathname}${search}`;
|
|
23
23
|
}
|
|
24
|
+
function readCookieScope(_meta) {
|
|
25
|
+
return { hostname: window.location.hostname, https: window.location.protocol === "https:" };
|
|
26
|
+
}
|
|
24
27
|
export {
|
|
25
28
|
listenWindow,
|
|
29
|
+
readCookieScope,
|
|
26
30
|
readDocumentComplete,
|
|
27
31
|
readDocumentHidden,
|
|
28
32
|
readPageUrl,
|
|
@@ -1,11 +1,26 @@
|
|
|
1
1
|
// src/transports/fetch.ts
|
|
2
2
|
import { parseReliabilityConfig } from "../config.mjs";
|
|
3
|
-
import { beaconSender, sendFetch } from "../readers/network.mjs";
|
|
3
|
+
import { beaconSender, declareBrowserRequestData, sendFetch } from "../readers/network.mjs";
|
|
4
4
|
var MAX_KEEPALIVE_BODY_BYTES = 6e4;
|
|
5
5
|
var FETCH_TIMEOUT_MS = 6e4;
|
|
6
6
|
var FetchTransport = class {
|
|
7
7
|
constructor(options) {
|
|
8
8
|
this.options = options;
|
|
9
|
+
declareBrowserRequestData({
|
|
10
|
+
key: "browser-api:device.user-agent",
|
|
11
|
+
title: "Browser and operating system",
|
|
12
|
+
accessNote: "User-Agent header the browser sends with every request to the Observe ingestion API (the SDK does not read it); Corbado stores it and derives browser and operating system name and version",
|
|
13
|
+
group: "Device information",
|
|
14
|
+
origin: "observe-external",
|
|
15
|
+
fields: [
|
|
16
|
+
{
|
|
17
|
+
path: "request.header.user-agent",
|
|
18
|
+
label: "Browser and operating system identifier",
|
|
19
|
+
exposure: "raw",
|
|
20
|
+
transform: { note: "full User-Agent string, sent by the browser" }
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
});
|
|
9
24
|
}
|
|
10
25
|
/**
|
|
11
26
|
* Error situations:
|
|
@@ -30,7 +30,6 @@ var OperationFull = class {
|
|
|
30
30
|
this.captureSessionId
|
|
31
31
|
),
|
|
32
32
|
flushKeepalive: () => this.tracker.lowEventFlushKeepalive(),
|
|
33
|
-
passwordManagerDomScan: () => this.tracker.isPasswordManagerDomScanEnabled(),
|
|
34
33
|
registerInputs: (fields, flush) => this.tracker.getWindowObserver().registerInputs(
|
|
35
34
|
fields,
|
|
36
35
|
() => ({
|