@valbuild/react 0.60.6 → 0.60.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@valbuild/react",
3
- "version": "0.60.6",
3
+ "version": "0.60.7",
4
4
  "private": false,
5
5
  "description": "Val - React internal helpers",
6
6
  "sideEffects": false,
@@ -9,9 +9,9 @@
9
9
  "test": "jest"
10
10
  },
11
11
  "dependencies": {
12
- "@valbuild/core": "~0.60.6",
13
- "@valbuild/shared": "~0.60.6",
14
- "@valbuild/ui": "~0.60.6",
12
+ "@valbuild/core": "~0.60.7",
13
+ "@valbuild/shared": "~0.60.7",
14
+ "@valbuild/ui": "~0.60.7",
15
15
  "@vercel/stega": "^0.1.0",
16
16
  "base64-arraybuffer": "^1.0.2"
17
17
  },
@@ -24,14 +24,29 @@ var isIntrinsicElement = function isIntrinsicElement(type) {
24
24
  };
25
25
  var addValPathIfFound = function addValPathIfFound(type, props) {
26
26
  var valSources = [];
27
- function add(key, value, props, container) {
27
+
28
+ // skip auto-tagging fragments since we can't add attributes to them
29
+ if (type === Symbol["for"]("react.fragment")) {
30
+ return;
31
+ }
32
+ function updateValSources(key, value, props, container) {
33
+ if (!key) {
34
+ return;
35
+ }
36
+ // Prevent prototype pollution
37
+ if (key === "__proto__" || key === "constructor" || key === "prototype") {
38
+ console.error('Val: Could not auto tag. Reason: key is "__proto__" or "constructor" or "prototype".');
39
+ return;
40
+ }
28
41
  var valPath = stegaDecodeString(value);
29
42
  var attr = "data-val-attr-".concat(key.toString().toLowerCase());
30
43
  if (valPath && !props[attr]) {
31
44
  valSources.push(valPath);
32
45
  var cleanValue = isIntrinsicElement(type) ? vercelStegaSplit(value).cleaned : value;
33
- if (Array.isArray(container) && typeof key === "number") {
34
- container[key] = cleanValue;
46
+ // we do Object.entries earlier over props so props that are arrays have string keys:
47
+ var numberOfKey = Number(key);
48
+ if (Array.isArray(container) && numberOfKey > -1) {
49
+ container[numberOfKey] = cleanValue;
35
50
  } else if (typeof key === "string" && !Array.isArray(container)) {
36
51
  container[key] = cleanValue;
37
52
  } else {
@@ -46,7 +61,7 @@ var addValPathIfFound = function addValPathIfFound(type, props) {
46
61
  key = _Object$entries$_i[0],
47
62
  value = _Object$entries$_i[1];
48
63
  if (typeof value === "string" && value.match(VERCEL_STEGA_REGEX)) {
49
- add(key, value, props, props);
64
+ updateValSources(key, value, props, props);
50
65
  } else if (_typeof(value) === "object" && value !== null) {
51
66
  if (key === "style") {
52
67
  for (var _i2 = 0, _Object$entries2 = Object.entries(value); _i2 < _Object$entries2.length; _i2++) {
@@ -54,7 +69,7 @@ var addValPathIfFound = function addValPathIfFound(type, props) {
54
69
  styleKey = _Object$entries2$_i[0],
55
70
  styleValue = _Object$entries2$_i[1];
56
71
  if (typeof styleValue === "string" && styleValue.match(VERCEL_STEGA_REGEX)) {
57
- add(styleKey, styleValue, props, value);
72
+ updateValSources(styleKey, styleValue, props, value);
58
73
  }
59
74
  }
60
75
  } else if (value instanceof Array) {
@@ -63,7 +78,7 @@ var addValPathIfFound = function addValPathIfFound(type, props) {
63
78
  index = _Object$entries3$_i[0],
64
79
  item = _Object$entries3$_i[1];
65
80
  if (typeof item === "string" && item.match(VERCEL_STEGA_REGEX)) {
66
- add(index, item, props, value);
81
+ updateValSources(index, item, props, value);
67
82
  }
68
83
  }
69
84
  }
@@ -34,14 +34,29 @@ var isIntrinsicElement = function isIntrinsicElement(type) {
34
34
  };
35
35
  var addValPathIfFound = function addValPathIfFound(type, props) {
36
36
  var valSources = [];
37
- function add(key, value, props, container) {
37
+
38
+ // skip auto-tagging fragments since we can't add attributes to them
39
+ if (type === Symbol["for"]("react.fragment")) {
40
+ return;
41
+ }
42
+ function updateValSources(key, value, props, container) {
43
+ if (!key) {
44
+ return;
45
+ }
46
+ // Prevent prototype pollution
47
+ if (key === "__proto__" || key === "constructor" || key === "prototype") {
48
+ console.error('Val: Could not auto tag. Reason: key is "__proto__" or "constructor" or "prototype".');
49
+ return;
50
+ }
38
51
  var valPath = stegaDecodeString(value);
39
52
  var attr = "data-val-attr-".concat(key.toString().toLowerCase());
40
53
  if (valPath && !props[attr]) {
41
54
  valSources.push(valPath);
42
55
  var cleanValue = isIntrinsicElement(type) ? stega.vercelStegaSplit(value).cleaned : value;
43
- if (Array.isArray(container) && typeof key === "number") {
44
- container[key] = cleanValue;
56
+ // we do Object.entries earlier over props so props that are arrays have string keys:
57
+ var numberOfKey = Number(key);
58
+ if (Array.isArray(container) && numberOfKey > -1) {
59
+ container[numberOfKey] = cleanValue;
45
60
  } else if (typeof key === "string" && !Array.isArray(container)) {
46
61
  container[key] = cleanValue;
47
62
  } else {
@@ -56,7 +71,7 @@ var addValPathIfFound = function addValPathIfFound(type, props) {
56
71
  key = _Object$entries$_i[0],
57
72
  value = _Object$entries$_i[1];
58
73
  if (typeof value === "string" && value.match(stega.VERCEL_STEGA_REGEX)) {
59
- add(key, value, props, props);
74
+ updateValSources(key, value, props, props);
60
75
  } else if (slicedToArray._typeof(value) === "object" && value !== null) {
61
76
  if (key === "style") {
62
77
  for (var _i2 = 0, _Object$entries2 = Object.entries(value); _i2 < _Object$entries2.length; _i2++) {
@@ -64,7 +79,7 @@ var addValPathIfFound = function addValPathIfFound(type, props) {
64
79
  styleKey = _Object$entries2$_i[0],
65
80
  styleValue = _Object$entries2$_i[1];
66
81
  if (typeof styleValue === "string" && styleValue.match(stega.VERCEL_STEGA_REGEX)) {
67
- add(styleKey, styleValue, props, value);
82
+ updateValSources(styleKey, styleValue, props, value);
68
83
  }
69
84
  }
70
85
  } else if (value instanceof Array) {
@@ -73,7 +88,7 @@ var addValPathIfFound = function addValPathIfFound(type, props) {
73
88
  index = _Object$entries3$_i[0],
74
89
  item = _Object$entries3$_i[1];
75
90
  if (typeof item === "string" && item.match(stega.VERCEL_STEGA_REGEX)) {
76
- add(index, item, props, value);
91
+ updateValSources(index, item, props, value);
77
92
  }
78
93
  }
79
94
  }
@@ -34,14 +34,29 @@ var isIntrinsicElement = function isIntrinsicElement(type) {
34
34
  };
35
35
  var addValPathIfFound = function addValPathIfFound(type, props) {
36
36
  var valSources = [];
37
- function add(key, value, props, container) {
37
+
38
+ // skip auto-tagging fragments since we can't add attributes to them
39
+ if (type === Symbol["for"]("react.fragment")) {
40
+ return;
41
+ }
42
+ function updateValSources(key, value, props, container) {
43
+ if (!key) {
44
+ return;
45
+ }
46
+ // Prevent prototype pollution
47
+ if (key === "__proto__" || key === "constructor" || key === "prototype") {
48
+ console.error('Val: Could not auto tag. Reason: key is "__proto__" or "constructor" or "prototype".');
49
+ return;
50
+ }
38
51
  var valPath = stegaDecodeString(value);
39
52
  var attr = "data-val-attr-".concat(key.toString().toLowerCase());
40
53
  if (valPath && !props[attr]) {
41
54
  valSources.push(valPath);
42
55
  var cleanValue = isIntrinsicElement(type) ? stega.vercelStegaSplit(value).cleaned : value;
43
- if (Array.isArray(container) && typeof key === "number") {
44
- container[key] = cleanValue;
56
+ // we do Object.entries earlier over props so props that are arrays have string keys:
57
+ var numberOfKey = Number(key);
58
+ if (Array.isArray(container) && numberOfKey > -1) {
59
+ container[numberOfKey] = cleanValue;
45
60
  } else if (typeof key === "string" && !Array.isArray(container)) {
46
61
  container[key] = cleanValue;
47
62
  } else {
@@ -56,7 +71,7 @@ var addValPathIfFound = function addValPathIfFound(type, props) {
56
71
  key = _Object$entries$_i[0],
57
72
  value = _Object$entries$_i[1];
58
73
  if (typeof value === "string" && value.match(stega.VERCEL_STEGA_REGEX)) {
59
- add(key, value, props, props);
74
+ updateValSources(key, value, props, props);
60
75
  } else if (slicedToArray._typeof(value) === "object" && value !== null) {
61
76
  if (key === "style") {
62
77
  for (var _i2 = 0, _Object$entries2 = Object.entries(value); _i2 < _Object$entries2.length; _i2++) {
@@ -64,7 +79,7 @@ var addValPathIfFound = function addValPathIfFound(type, props) {
64
79
  styleKey = _Object$entries2$_i[0],
65
80
  styleValue = _Object$entries2$_i[1];
66
81
  if (typeof styleValue === "string" && styleValue.match(stega.VERCEL_STEGA_REGEX)) {
67
- add(styleKey, styleValue, props, value);
82
+ updateValSources(styleKey, styleValue, props, value);
68
83
  }
69
84
  }
70
85
  } else if (value instanceof Array) {
@@ -73,7 +88,7 @@ var addValPathIfFound = function addValPathIfFound(type, props) {
73
88
  index = _Object$entries3$_i[0],
74
89
  item = _Object$entries3$_i[1];
75
90
  if (typeof item === "string" && item.match(stega.VERCEL_STEGA_REGEX)) {
76
- add(index, item, props, value);
91
+ updateValSources(index, item, props, value);
77
92
  }
78
93
  }
79
94
  }
@@ -24,14 +24,29 @@ var isIntrinsicElement = function isIntrinsicElement(type) {
24
24
  };
25
25
  var addValPathIfFound = function addValPathIfFound(type, props) {
26
26
  var valSources = [];
27
- function add(key, value, props, container) {
27
+
28
+ // skip auto-tagging fragments since we can't add attributes to them
29
+ if (type === Symbol["for"]("react.fragment")) {
30
+ return;
31
+ }
32
+ function updateValSources(key, value, props, container) {
33
+ if (!key) {
34
+ return;
35
+ }
36
+ // Prevent prototype pollution
37
+ if (key === "__proto__" || key === "constructor" || key === "prototype") {
38
+ console.error('Val: Could not auto tag. Reason: key is "__proto__" or "constructor" or "prototype".');
39
+ return;
40
+ }
28
41
  var valPath = stegaDecodeString(value);
29
42
  var attr = "data-val-attr-".concat(key.toString().toLowerCase());
30
43
  if (valPath && !props[attr]) {
31
44
  valSources.push(valPath);
32
45
  var cleanValue = isIntrinsicElement(type) ? vercelStegaSplit(value).cleaned : value;
33
- if (Array.isArray(container) && typeof key === "number") {
34
- container[key] = cleanValue;
46
+ // we do Object.entries earlier over props so props that are arrays have string keys:
47
+ var numberOfKey = Number(key);
48
+ if (Array.isArray(container) && numberOfKey > -1) {
49
+ container[numberOfKey] = cleanValue;
35
50
  } else if (typeof key === "string" && !Array.isArray(container)) {
36
51
  container[key] = cleanValue;
37
52
  } else {
@@ -46,7 +61,7 @@ var addValPathIfFound = function addValPathIfFound(type, props) {
46
61
  key = _Object$entries$_i[0],
47
62
  value = _Object$entries$_i[1];
48
63
  if (typeof value === "string" && value.match(VERCEL_STEGA_REGEX)) {
49
- add(key, value, props, props);
64
+ updateValSources(key, value, props, props);
50
65
  } else if (_typeof(value) === "object" && value !== null) {
51
66
  if (key === "style") {
52
67
  for (var _i2 = 0, _Object$entries2 = Object.entries(value); _i2 < _Object$entries2.length; _i2++) {
@@ -54,7 +69,7 @@ var addValPathIfFound = function addValPathIfFound(type, props) {
54
69
  styleKey = _Object$entries2$_i[0],
55
70
  styleValue = _Object$entries2$_i[1];
56
71
  if (typeof styleValue === "string" && styleValue.match(VERCEL_STEGA_REGEX)) {
57
- add(styleKey, styleValue, props, value);
72
+ updateValSources(styleKey, styleValue, props, value);
58
73
  }
59
74
  }
60
75
  } else if (value instanceof Array) {
@@ -63,7 +78,7 @@ var addValPathIfFound = function addValPathIfFound(type, props) {
63
78
  index = _Object$entries3$_i[0],
64
79
  item = _Object$entries3$_i[1];
65
80
  if (typeof item === "string" && item.match(VERCEL_STEGA_REGEX)) {
66
- add(index, item, props, value);
81
+ updateValSources(index, item, props, value);
67
82
  }
68
83
  }
69
84
  }
@@ -24,14 +24,29 @@ var isIntrinsicElement = function isIntrinsicElement(type) {
24
24
  };
25
25
  var addValPathIfFound = function addValPathIfFound(type, props) {
26
26
  var valSources = [];
27
- function add(key, value, props, container) {
27
+
28
+ // skip auto-tagging fragments since we can't add attributes to them
29
+ if (type === Symbol["for"]("react.fragment")) {
30
+ return;
31
+ }
32
+ function updateValSources(key, value, props, container) {
33
+ if (!key) {
34
+ return;
35
+ }
36
+ // Prevent prototype pollution
37
+ if (key === "__proto__" || key === "constructor" || key === "prototype") {
38
+ console.error('Val: Could not auto tag. Reason: key is "__proto__" or "constructor" or "prototype".');
39
+ return;
40
+ }
28
41
  var valPath = stegaDecodeString(value);
29
42
  var attr = "data-val-attr-".concat(key.toString().toLowerCase());
30
43
  if (valPath && !props[attr]) {
31
44
  valSources.push(valPath);
32
45
  var cleanValue = isIntrinsicElement(type) ? vercelStegaSplit(value).cleaned : value;
33
- if (Array.isArray(container) && typeof key === "number") {
34
- container[key] = cleanValue;
46
+ // we do Object.entries earlier over props so props that are arrays have string keys:
47
+ var numberOfKey = Number(key);
48
+ if (Array.isArray(container) && numberOfKey > -1) {
49
+ container[numberOfKey] = cleanValue;
35
50
  } else if (typeof key === "string" && !Array.isArray(container)) {
36
51
  container[key] = cleanValue;
37
52
  } else {
@@ -46,7 +61,7 @@ var addValPathIfFound = function addValPathIfFound(type, props) {
46
61
  key = _Object$entries$_i[0],
47
62
  value = _Object$entries$_i[1];
48
63
  if (typeof value === "string" && value.match(VERCEL_STEGA_REGEX)) {
49
- add(key, value, props, props);
64
+ updateValSources(key, value, props, props);
50
65
  } else if (_typeof(value) === "object" && value !== null) {
51
66
  if (key === "style") {
52
67
  for (var _i2 = 0, _Object$entries2 = Object.entries(value); _i2 < _Object$entries2.length; _i2++) {
@@ -54,7 +69,7 @@ var addValPathIfFound = function addValPathIfFound(type, props) {
54
69
  styleKey = _Object$entries2$_i[0],
55
70
  styleValue = _Object$entries2$_i[1];
56
71
  if (typeof styleValue === "string" && styleValue.match(VERCEL_STEGA_REGEX)) {
57
- add(styleKey, styleValue, props, value);
72
+ updateValSources(styleKey, styleValue, props, value);
58
73
  }
59
74
  }
60
75
  } else if (value instanceof Array) {
@@ -63,7 +78,7 @@ var addValPathIfFound = function addValPathIfFound(type, props) {
63
78
  index = _Object$entries3$_i[0],
64
79
  item = _Object$entries3$_i[1];
65
80
  if (typeof item === "string" && item.match(VERCEL_STEGA_REGEX)) {
66
- add(index, item, props, value);
81
+ updateValSources(index, item, props, value);
67
82
  }
68
83
  }
69
84
  }