clarity-js 0.6.36 → 0.6.37
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/build/clarity.js +487 -486
- package/build/clarity.min.js +1 -1
- package/build/clarity.module.js +487 -486
- package/package.json +1 -1
- package/src/core/version.ts +1 -1
- package/src/layout/dom.ts +1 -0
- package/test/core.test.ts +27 -18
- package/test/helper.ts +5 -0
- package/test/html/core.html +4 -1
package/package.json
CHANGED
package/src/core/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
let version = "0.6.
|
|
1
|
+
let version = "0.6.37";
|
|
2
2
|
export default version;
|
package/src/layout/dom.ts
CHANGED
|
@@ -97,6 +97,7 @@ export function add(node: Node, parent: Node, data: NodeInfo, source: Source): v
|
|
|
97
97
|
regionId = regionId === null ? parentValue.region : regionId;
|
|
98
98
|
fragmentId = parentValue.fragment;
|
|
99
99
|
fraudId = fraudId === null ? parentValue.metadata.fraud : fraudId;
|
|
100
|
+
privacyId = parentValue.metadata.privacy;
|
|
100
101
|
}
|
|
101
102
|
|
|
102
103
|
// If there's an explicit region attribute set on the element, use it to mark a region on the page
|
package/test/core.test.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { assert } from 'chai';
|
|
2
2
|
import { Browser, Page } from 'playwright';
|
|
3
3
|
import { launch, markup, node, text } from './helper';
|
|
4
4
|
import { Data, decode } from "clarity-decode";
|
|
@@ -33,15 +33,15 @@ describe('Core Tests', () => {
|
|
|
33
33
|
let email = node(decoded, "attributes.id", "eml");
|
|
34
34
|
let password = node(decoded, "attributes.id", "pwd");
|
|
35
35
|
let search = node(decoded, "attributes.id", "search");
|
|
36
|
-
|
|
36
|
+
|
|
37
37
|
// Non-sensitive fields continue to pass through with sensitive bits masked off
|
|
38
|
-
|
|
38
|
+
assert.equal(heading, "Thanks for your order •••••••••");
|
|
39
39
|
|
|
40
40
|
// Sensitive fields, including input fields, are randomized and masked
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
assert.equal(address, "•••••• ••••• ••••• ••••• ••••• •••••");
|
|
42
|
+
assert.equal(email.attributes.value, "••••• •••• •••• ••••");
|
|
43
|
+
assert.equal(password.attributes.value, "••••• ••••");
|
|
44
|
+
assert.equal(search.attributes.value, "hello •••••");
|
|
45
45
|
});
|
|
46
46
|
|
|
47
47
|
it('should mask all text in strict mode', async () => {
|
|
@@ -54,14 +54,14 @@ describe('Core Tests', () => {
|
|
|
54
54
|
let search = node(decoded, "attributes.id", "search");
|
|
55
55
|
|
|
56
56
|
// All fields are randomized and masked
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
57
|
+
assert.equal(heading, "• ••••• ••••• ••••• ••••• •••••");
|
|
58
|
+
assert.equal(address, "•••••• ••••• ••••• ••••• ••••• •••••");
|
|
59
|
+
assert.equal(email.attributes.value, "••••• •••• •••• ••••");
|
|
60
|
+
assert.equal(password.attributes.value, "••••• ••••");
|
|
61
|
+
assert.equal(search.attributes.value, "••••• •••• ••••");
|
|
62
62
|
});
|
|
63
63
|
|
|
64
|
-
it('should
|
|
64
|
+
it('should unmask all text in relaxed mode', async () => {
|
|
65
65
|
let encoded: string[] = await markup(page, "core.html", { unmask: ["body"] });
|
|
66
66
|
let decoded = encoded.map(x => decode(x));
|
|
67
67
|
let heading = text(decoded, "one");
|
|
@@ -71,12 +71,21 @@ describe('Core Tests', () => {
|
|
|
71
71
|
let search = node(decoded, "attributes.id", "search");
|
|
72
72
|
|
|
73
73
|
// Text flows through unmasked for non-sensitive fields, including input fields
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
74
|
+
assert.equal(heading, "Thanks for your order #2AB700GH");
|
|
75
|
+
assert.equal(address, "1 Microsoft Way, Redmond, WA - 98052");
|
|
76
|
+
assert.equal(search.attributes.value, "hello w0rld");
|
|
77
77
|
|
|
78
78
|
// Sensitive fields are still masked
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
assert.equal(email.attributes.value, "••••• •••• •••• ••••");
|
|
80
|
+
assert.equal(password.attributes.value, "••••• ••••");
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it('should respect mask config even in relaxed mode', async () => {
|
|
84
|
+
let encoded: string[] = await markup(page, "core.html", { mask: ["#mask"], unmask: ["body"] });
|
|
85
|
+
let decoded = encoded.map(x => decode(x));
|
|
86
|
+
let subtree = text(decoded, "child");
|
|
87
|
+
|
|
88
|
+
// Masked sub-trees continue to stay masked
|
|
89
|
+
assert.equal(subtree, "••••• •••••");
|
|
81
90
|
});
|
|
82
91
|
});
|
package/test/helper.ts
CHANGED
|
@@ -78,6 +78,10 @@ function config(override: Core.Config): string {
|
|
|
78
78
|
const settings = {
|
|
79
79
|
delay: 100,
|
|
80
80
|
content: true,
|
|
81
|
+
fraud: [],
|
|
82
|
+
regions: [],
|
|
83
|
+
mask: [],
|
|
84
|
+
unmask: [],
|
|
81
85
|
upload: payload => { window["payloads"].push(payload); window["clarity"]("upgrade", "test"); }
|
|
82
86
|
}
|
|
83
87
|
|
|
@@ -100,6 +104,7 @@ function config(override: Core.Config): string {
|
|
|
100
104
|
case "unmask":
|
|
101
105
|
case "regions":
|
|
102
106
|
case "cookies":
|
|
107
|
+
case "fraud":
|
|
103
108
|
output += `${JSON.stringify(key)}: ${JSON.stringify(settings[key])},`;
|
|
104
109
|
break;
|
|
105
110
|
default:
|
package/test/html/core.html
CHANGED
|
@@ -8,10 +8,13 @@
|
|
|
8
8
|
<h1 id="one">Thanks for your order #2AB700GH</h1>
|
|
9
9
|
<p id="two" class="address-details">1 Microsoft Way, Redmond, WA - 98052</p>
|
|
10
10
|
</div>
|
|
11
|
+
<div id="mask">
|
|
12
|
+
<span id="child">Hello World</span>
|
|
13
|
+
</div>
|
|
11
14
|
<form name="login">
|
|
12
15
|
<input type="email" id="eml" title="Email" value="random@email.test">
|
|
13
16
|
<input type="password" id="pwd" title="Password" maxlength="16" value="passw0rd">
|
|
14
|
-
<input type="search" id="search" title="Search" value="hello
|
|
17
|
+
<input type="search" id="search" title="Search" value="hello w0rld">
|
|
15
18
|
</form>
|
|
16
19
|
</body>
|
|
17
20
|
</html>
|