clarity-js 0.6.39 → 0.6.41
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 +103 -62
- package/build/clarity.min.js +1 -1
- package/build/clarity.module.js +103 -62
- package/package.json +1 -1
- package/src/core/config.ts +2 -1
- package/src/core/version.ts +1 -1
- package/src/data/upload.ts +6 -2
- package/src/index.ts +1 -1
- package/src/layout/dom.ts +14 -13
- package/src/layout/encode.ts +1 -1
- package/src/layout/selector.ts +47 -27
- package/test/core.test.ts +11 -5
- package/test/html/core.html +1 -0
- package/types/core.d.ts +1 -0
- package/types/data.d.ts +3 -2
- package/types/index.d.ts +6 -1
- package/types/layout.d.ts +11 -5
package/test/core.test.ts
CHANGED
|
@@ -33,21 +33,23 @@ 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
|
+
let card = node(decoded, "attributes.id", "cardnum");
|
|
36
37
|
let click = clicks(decoded)[0];
|
|
37
38
|
let input = inputs(decoded)[0];
|
|
38
39
|
|
|
39
40
|
// Non-sensitive fields continue to pass through with sensitive bits masked off
|
|
40
|
-
assert.equal(heading, "Thanks for your order
|
|
41
|
+
assert.equal(heading, "Thanks for your order #▫▪▪▫▫▫▪▪");
|
|
41
42
|
|
|
42
43
|
// Sensitive fields, including input fields, are randomized and masked
|
|
43
44
|
assert.equal(address, "•••••• ••••• ••••• ••••• ••••• •••••");
|
|
44
45
|
assert.equal(email.attributes.value, "••••• •••• •••• ••••");
|
|
45
46
|
assert.equal(password.attributes.value, "••••• ••••");
|
|
46
|
-
assert.equal(search.attributes.value, "hello
|
|
47
|
+
assert.equal(search.attributes.value, "hello ▪▫▪▪▪");
|
|
48
|
+
assert.equal(card.attributes.value, "▫▫▫▫");
|
|
47
49
|
|
|
48
50
|
// Clicked text and input value should be consistent with uber masking configuration
|
|
49
|
-
assert.equal(click.data.text, "Hello
|
|
50
|
-
assert.equal(input.data.value, "query with
|
|
51
|
+
assert.equal(click.data.text, "Hello ▪▪▪▫▪");
|
|
52
|
+
assert.equal(input.data.value, "query with ▪▪▪▪▫▪▪");
|
|
51
53
|
});
|
|
52
54
|
|
|
53
55
|
it('should mask all text in strict mode', async () => {
|
|
@@ -58,6 +60,7 @@ describe('Core Tests', () => {
|
|
|
58
60
|
let email = node(decoded, "attributes.id", "eml");
|
|
59
61
|
let password = node(decoded, "attributes.id", "pwd");
|
|
60
62
|
let search = node(decoded, "attributes.id", "search");
|
|
63
|
+
let card = node(decoded, "attributes.id", "cardnum");
|
|
61
64
|
let click = clicks(decoded)[0];
|
|
62
65
|
let input = inputs(decoded)[0];
|
|
63
66
|
|
|
@@ -67,13 +70,14 @@ describe('Core Tests', () => {
|
|
|
67
70
|
assert.equal(email.attributes.value, "••••• •••• •••• ••••");
|
|
68
71
|
assert.equal(password.attributes.value, "••••• ••••");
|
|
69
72
|
assert.equal(search.attributes.value, "••••• •••• ••••");
|
|
73
|
+
assert.equal(card.attributes.value, "•••••");
|
|
70
74
|
|
|
71
75
|
// Clicked text and input value should also be masked in strict mode
|
|
72
76
|
assert.equal(click.data.text, "••••• •••• ••••");
|
|
73
77
|
assert.equal(input.data.value, "••••• •••• •••• ••••");
|
|
74
78
|
});
|
|
75
79
|
|
|
76
|
-
it('should unmask
|
|
80
|
+
it('should unmask non-sensitive text in relaxed mode', async () => {
|
|
77
81
|
let encoded: string[] = await markup(page, "core.html", { unmask: ["body"] });
|
|
78
82
|
let decoded = encoded.map(x => decode(x));
|
|
79
83
|
let heading = text(decoded, "one");
|
|
@@ -81,6 +85,7 @@ describe('Core Tests', () => {
|
|
|
81
85
|
let email = node(decoded, "attributes.id", "eml");
|
|
82
86
|
let password = node(decoded, "attributes.id", "pwd");
|
|
83
87
|
let search = node(decoded, "attributes.id", "search");
|
|
88
|
+
let card = node(decoded, "attributes.id", "cardnum");
|
|
84
89
|
let click = clicks(decoded)[0];
|
|
85
90
|
let input = inputs(decoded)[0];
|
|
86
91
|
|
|
@@ -92,6 +97,7 @@ describe('Core Tests', () => {
|
|
|
92
97
|
// Sensitive fields are still masked
|
|
93
98
|
assert.equal(email.attributes.value, "••••• •••• •••• ••••");
|
|
94
99
|
assert.equal(password.attributes.value, "••••• ••••");
|
|
100
|
+
assert.equal(card.attributes.value, "•••••");
|
|
95
101
|
|
|
96
102
|
// Clicked text and input value (non-sensitive) both come through without masking in relaxed mode
|
|
97
103
|
assert.equal(click.data.text, "Hello Wor1d");
|
package/test/html/core.html
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
<input type="email" id="eml" title="Email" value="random@email.test">
|
|
16
16
|
<input type="password" id="pwd" title="Password" maxlength="16" value="passw0rd">
|
|
17
17
|
<input type="search" id="search" title="Search" value="hello w0rld">
|
|
18
|
+
<input type="text" id="cardnum" title="CC" value="1234">
|
|
18
19
|
</form>
|
|
19
20
|
</body>
|
|
20
21
|
</html>
|
package/types/core.d.ts
CHANGED
package/types/data.d.ts
CHANGED
|
@@ -244,12 +244,13 @@ export const enum Constant {
|
|
|
244
244
|
Pipe = "|",
|
|
245
245
|
End = "END",
|
|
246
246
|
Upgrade = "UPGRADE",
|
|
247
|
+
Action = "ACTION",
|
|
247
248
|
UserId = "userId",
|
|
248
249
|
SessionId = "sessionId",
|
|
249
250
|
PageId = "pageId",
|
|
250
251
|
Mask = "•", // Placeholder character for explicitly masked content
|
|
251
|
-
Digit = "
|
|
252
|
-
Letter = "
|
|
252
|
+
Digit = "▫", // Placeholder character for digits
|
|
253
|
+
Letter = "▪", // Placeholder character for letters
|
|
253
254
|
SessionStorage = "sessionStorage",
|
|
254
255
|
Cookie = "cookie",
|
|
255
256
|
Navigation = "navigation",
|
package/types/index.d.ts
CHANGED
|
@@ -18,12 +18,17 @@ interface Clarity {
|
|
|
18
18
|
metadata: (callback: Data.MetadataCallback, wait?: boolean) => void;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
interface Selector {
|
|
22
|
+
get: (input: Layout.SelectorInput, type: Layout.Selector) => string;
|
|
23
|
+
reset: () => void;
|
|
24
|
+
}
|
|
25
|
+
|
|
21
26
|
interface Helper {
|
|
22
27
|
get: (node: Node) => Layout.NodeValue;
|
|
23
28
|
getNode: (id: number) => Node;
|
|
24
29
|
hash: (input: string) => string;
|
|
25
30
|
lookup: (hash: string) => number;
|
|
26
|
-
selector:
|
|
31
|
+
selector: Selector;
|
|
27
32
|
}
|
|
28
33
|
|
|
29
34
|
declare const clarity: Clarity;
|
package/types/layout.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Privacy } from "@clarity-types/core";
|
|
2
|
-
import { BooleanFlag } from "@clarity-types/data";
|
|
3
2
|
|
|
4
3
|
/* Enum */
|
|
5
4
|
|
|
@@ -12,8 +11,9 @@ export const enum Source {
|
|
|
12
11
|
}
|
|
13
12
|
|
|
14
13
|
export const enum Selector {
|
|
15
|
-
|
|
16
|
-
Beta = 1
|
|
14
|
+
Alpha = 0,
|
|
15
|
+
Beta = 1,
|
|
16
|
+
Default = 1
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
export const enum InteractionState {
|
|
@@ -45,7 +45,10 @@ export const enum Constant {
|
|
|
45
45
|
Href = "href",
|
|
46
46
|
Src = "src",
|
|
47
47
|
Srcset = "srcset",
|
|
48
|
-
|
|
48
|
+
Hash = "#",
|
|
49
|
+
Dot = ".",
|
|
50
|
+
Separator = ">",
|
|
51
|
+
Tilde = "~",
|
|
49
52
|
Bang = "!",
|
|
50
53
|
Period = ".",
|
|
51
54
|
Comma = ",",
|
|
@@ -91,7 +94,9 @@ export const enum Constant {
|
|
|
91
94
|
Content = "content",
|
|
92
95
|
Generator = "generator",
|
|
93
96
|
ogType = "og:type",
|
|
94
|
-
ogTitle = "og:title"
|
|
97
|
+
ogTitle = "og:title",
|
|
98
|
+
SvgStyle = "svg:style",
|
|
99
|
+
ExcludeClassNames = "load,active,fixed,visible,focus,show,collaps,animat"
|
|
95
100
|
}
|
|
96
101
|
|
|
97
102
|
export const enum JsonLD {
|
|
@@ -139,6 +144,7 @@ export interface Attributes {
|
|
|
139
144
|
}
|
|
140
145
|
|
|
141
146
|
export interface SelectorInput {
|
|
147
|
+
id: number;
|
|
142
148
|
tag: string;
|
|
143
149
|
prefix: [string, string];
|
|
144
150
|
position: number;
|