@corbado/observe 1.14.0 → 1.14.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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @corbado/observe
2
2
 
3
+ ## 1.14.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 77ac0d7: Paste observation no longer copies or compares input values: it keeps only the fields' lengths and whether the browser applied the paste. The unused inserted count and the undeclared "Length of the pasted text" reader field are removed. A host-handled paste that replaces text with text of the same length, without an input event, is no longer detected.
8
+
3
9
  ## 1.14.0
4
10
 
5
11
  ### Minor Changes
@@ -18,7 +18,7 @@ var LowEventGroupedInputTracker = class {
18
18
  {
19
19
  key: "dom:input.paste",
20
20
  title: "Paste into tracked input fields",
21
- accessNote: "paste events on the input elements the integration passes to Observe; pasted values never leave the reader",
21
+ accessNote: "paste events on the input elements the integration passes to Observe; only the fields' lengths are compared, values are never copied or compared",
22
22
  group: "Input interaction",
23
23
  origin: "observe-external",
24
24
  fields: [
@@ -28,19 +28,12 @@ var LowEventGroupedInputTracker = class {
28
28
  category: "behavior",
29
29
  exposure: "presence",
30
30
  transform: { note: "trusted paste events only" }
31
- },
32
- {
33
- path: "value",
34
- label: "Length of the pasted text",
35
- category: "behavior",
36
- exposure: "size",
37
- transform: { note: "inserted length only; values are compared in memory and discarded" }
38
31
  }
39
32
  ]
40
33
  },
41
34
  this.inputs,
42
35
  logger,
43
- (ts, _inserted, captureSeq) => {
36
+ (ts, captureSeq) => {
44
37
  this.cancelChange();
45
38
  this.changes.flush();
46
39
  this.changes.markInputObserved();
@@ -40,7 +40,7 @@ var LowEventInputTracker = class {
40
40
  {
41
41
  key: "dom:input.paste",
42
42
  title: "Paste into tracked input fields",
43
- accessNote: "paste events on the input elements the integration passes to Observe; pasted values never leave the reader",
43
+ accessNote: "paste events on the input elements the integration passes to Observe; only the fields' lengths are compared, values are never copied or compared",
44
44
  group: "Input interaction",
45
45
  origin: "observe-external",
46
46
  fields: [
@@ -50,19 +50,12 @@ var LowEventInputTracker = class {
50
50
  category: "behavior",
51
51
  exposure: "presence",
52
52
  transform: { note: "trusted paste events only" }
53
- },
54
- {
55
- path: "value",
56
- label: "Length of the pasted text",
57
- category: "behavior",
58
- exposure: "size",
59
- transform: { note: "inserted length only; values are compared in memory and discarded" }
60
53
  }
61
54
  ]
62
55
  },
63
56
  [inputField],
64
57
  logger,
65
- (ts, _inserted, captureSeq) => {
58
+ (ts, captureSeq) => {
66
59
  this.changes.flush();
67
60
  this.changes.markInputObserved();
68
61
  const oldLength = this.changes.previousLength;
@@ -10,7 +10,9 @@ var InputPasteObserver = class {
10
10
  input.addEventListener("beforeinput", this.onBeforeInput, true);
11
11
  }
12
12
  }
13
- before = null;
13
+ lengthsBefore = null;
14
+ /** An input event of this paste arrived (the browser applied it). */
15
+ applied = false;
14
16
  timestamp = 0;
15
17
  captureSeq;
16
18
  pasteEvent;
@@ -22,21 +24,23 @@ var InputPasteObserver = class {
22
24
  };
23
25
  /** An unrelated input event invalidates pending paste provenance before recording its change. */
24
26
  handlesInput(event) {
25
- if (!this.before) return false;
27
+ if (!this.lengthsBefore) return false;
26
28
  const inPasteDispatch = this.pasteEvent?.type === "paste" && (this.pasteEvent.eventPhase ?? 0) > 0;
27
29
  if (event.inputType === "insertFromPaste" || inPasteDispatch) {
30
+ this.applied = true;
28
31
  return true;
29
32
  }
30
33
  this.clear();
31
34
  return false;
32
35
  }
33
36
  get pending() {
34
- return this.before !== null;
37
+ return this.lengthsBefore !== null;
35
38
  }
36
39
  begin(event) {
37
- if (!event.isTrusted || this.before) return;
40
+ if (!event.isTrusted || this.lengthsBefore) return;
38
41
  try {
39
- this.before = this.inputs.map((input) => input.value);
42
+ this.lengthsBefore = this.inputs.map((input) => input.value.length);
43
+ this.applied = false;
40
44
  this.pasteEvent = event;
41
45
  this.timestamp = Date.now();
42
46
  this.captureSeq = this.reserveCaptureSeq?.();
@@ -47,27 +51,15 @@ var InputPasteObserver = class {
47
51
  }
48
52
  }
49
53
  flush() {
50
- const before = this.before;
51
- if (!before) return;
54
+ const lengthsBefore = this.lengthsBefore;
55
+ if (!lengthsBefore) return;
52
56
  const timestamp = this.timestamp;
53
57
  const captureSeq = this.captureSeq;
58
+ const applied = this.applied;
54
59
  this.clear();
55
60
  try {
56
- let inserted = 0;
57
- let changed = false;
58
- this.inputs.forEach((input, index) => {
59
- const old = before[index];
60
- const value = input.value;
61
- if (old === value) return;
62
- changed = true;
63
- let start = 0;
64
- while (start < old.length && start < value.length && old[start] === value[start]) start++;
65
- let end = 0;
66
- while (end < old.length - start && end < value.length - start && old[old.length - end - 1] === value[value.length - end - 1])
67
- end++;
68
- inserted += value.length - start - end;
69
- });
70
- if (changed) this.changed(timestamp, inserted, captureSeq);
61
+ const changed = applied || this.inputs.some((input, index) => input.value.length !== lengthsBefore[index]);
62
+ if (changed) this.changed(timestamp, captureSeq);
71
63
  } catch (error) {
72
64
  this.logger.error("Failed to finish paste observation", error);
73
65
  }
@@ -75,7 +67,8 @@ var InputPasteObserver = class {
75
67
  clear() {
76
68
  if (this.timer !== null) clearTimeout(this.timer);
77
69
  this.timer = null;
78
- this.before = null;
70
+ this.lengthsBefore = null;
71
+ this.applied = false;
79
72
  this.pasteEvent = void 0;
80
73
  }
81
74
  destroy() {
@@ -1,6 +1,6 @@
1
1
  // src/version.ts
2
2
  var SDK_NAME = "@corbado/observe";
3
- var SDK_VERSION = true ? "1.14.0" : "0.0.0-dev";
3
+ var SDK_VERSION = true ? "1.14.1" : "0.0.0-dev";
4
4
  export {
5
5
  SDK_NAME,
6
6
  SDK_VERSION