@adobe/alloy 2.14.0-alpha.2 → 2.14.0-alpha.21

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.
Files changed (31) hide show
  1. package/libEs5/components/Context/injectDevice.js +25 -12
  2. package/libEs5/components/Context/injectEnvironment.js +10 -3
  3. package/libEs5/components/Context/injectHighEntropyUserAgentHints.js +26 -15
  4. package/libEs5/components/Context/injectPlaceContext.js +6 -3
  5. package/libEs5/components/Identity/visitorService/injectGetEcidFromVisitor.js +2 -1
  6. package/libEs5/components/Personalization/dom-actions/executeActions.js +13 -1
  7. package/libEs5/components/Personalization/dom-actions/remapCustomCodeOffers.js +43 -0
  8. package/libEs5/constants/highEntropyUserAgentClientHints.js +1 -1
  9. package/libEs5/constants/libraryVersion.js +1 -1
  10. package/libEs5/core/edgeNetwork/injectSendEdgeNetworkRequest.js +3 -2
  11. package/libEs5/core/index.js +6 -1
  12. package/libEs5/core/network/requestMethods/injectSendFetchRequest.js +1 -1
  13. package/libEs5/utils/request/createGetAssuranceValidationTokenParams.js +54 -0
  14. package/libEs5/utils/request/index.js +9 -1
  15. package/libEs5/utils/toInteger.js +14 -2
  16. package/libEs6/components/Context/injectDevice.js +26 -13
  17. package/libEs6/components/Context/injectEnvironment.js +11 -4
  18. package/libEs6/components/Context/injectHighEntropyUserAgentHints.js +6 -4
  19. package/libEs6/components/Context/injectPlaceContext.js +6 -3
  20. package/libEs6/components/Identity/visitorService/injectGetEcidFromVisitor.js +2 -1
  21. package/libEs6/components/Personalization/dom-actions/executeActions.js +7 -1
  22. package/libEs6/components/Personalization/dom-actions/remapCustomCodeOffers.js +37 -0
  23. package/libEs6/constants/highEntropyUserAgentClientHints.js +1 -1
  24. package/libEs6/constants/libraryVersion.js +1 -1
  25. package/libEs6/core/edgeNetwork/injectSendEdgeNetworkRequest.js +3 -2
  26. package/libEs6/core/index.js +7 -2
  27. package/libEs6/core/network/requestMethods/injectSendFetchRequest.js +1 -1
  28. package/libEs6/utils/request/createGetAssuranceValidationTokenParams.js +47 -0
  29. package/libEs6/utils/request/index.js +2 -1
  30. package/libEs6/utils/toInteger.js +13 -3
  31. package/package.json +6 -5
@@ -36,12 +36,14 @@ var getScreenOrientationViaProperty = function getScreenOrientationViaProperty(w
36
36
  };
37
37
 
38
38
  var getScreenOrientationViaMediaQuery = function getScreenOrientationViaMediaQuery(window) {
39
- if (window.matchMedia("(orientation: portrait)").matches) {
40
- return "portrait";
41
- }
39
+ if ((0, _utils.isFunction)(window.matchMedia)) {
40
+ if (window.matchMedia("(orientation: portrait)").matches) {
41
+ return "portrait";
42
+ }
42
43
 
43
- if (window.matchMedia("(orientation: landscape)").matches) {
44
- return "landscape";
44
+ if (window.matchMedia("(orientation: landscape)").matches) {
45
+ return "landscape";
46
+ }
45
47
  }
46
48
 
47
49
  return null;
@@ -52,19 +54,30 @@ var _default = function _default(window) {
52
54
  var _window$screen = window.screen,
53
55
  width = _window$screen.width,
54
56
  height = _window$screen.height;
55
- var device = {
56
- screenHeight: height,
57
- screenWidth: width
58
- };
57
+ var device = {};
58
+ var screenHeight = (0, _utils.toInteger)(height);
59
+
60
+ if (screenHeight >= 0) {
61
+ device.screenHeight = screenHeight;
62
+ }
63
+
64
+ var screenWidth = (0, _utils.toInteger)(width);
65
+
66
+ if (screenWidth >= 0) {
67
+ device.screenWidth = screenWidth;
68
+ }
69
+
59
70
  var orientation = getScreenOrientationViaProperty(window) || getScreenOrientationViaMediaQuery(window);
60
71
 
61
72
  if (orientation) {
62
73
  device.screenOrientation = orientation;
63
74
  }
64
75
 
65
- (0, _utils.deepAssign)(xdm, {
66
- device: device
67
- });
76
+ if (Object.keys(device).length > 0) {
77
+ (0, _utils.deepAssign)(xdm, {
78
+ device: device
79
+ });
80
+ }
68
81
  };
69
82
  };
70
83
 
@@ -24,14 +24,21 @@ var _default = function _default(window) {
24
24
  var environment = {
25
25
  type: "browser"
26
26
  };
27
+ var viewportWidth = (0, _utils.toInteger)(clientWidth);
27
28
 
28
- if ((0, _utils.isNumber)(clientWidth) && clientWidth >= 0 && (0, _utils.isNumber)(clientHeight) && clientHeight >= 0) {
29
+ if (viewportWidth >= 0) {
29
30
  environment.browserDetails = {
30
- viewportWidth: Math.round(clientWidth),
31
- viewportHeight: Math.round(clientHeight)
31
+ viewportWidth: viewportWidth
32
32
  };
33
33
  }
34
34
 
35
+ var viewportHeight = (0, _utils.toInteger)(clientHeight);
36
+
37
+ if (viewportHeight >= 0) {
38
+ environment.browserDetails = environment.browserDetails || {};
39
+ environment.browserDetails.viewportHeight = viewportHeight;
40
+ }
41
+
35
42
  (0, _utils.deepAssign)(xdm, {
36
43
  environment: environment
37
44
  });
@@ -6,17 +6,20 @@ var _utils = require("../../utils");
6
6
 
7
7
  var _highEntropyUserAgentClientHints = require("../../constants/highEntropyUserAgentClientHints");
8
8
 
9
- /*
10
- Copyright 2022 Adobe. All rights reserved.
11
- This file is licensed to you under the Apache License, Version 2.0 (the "License");
12
- you may not use this file except in compliance with the License. You may obtain a copy
13
- of the License at http://www.apache.org/licenses/LICENSE-2.0
14
-
15
- Unless required by applicable law or agreed to in writing, software distributed under
16
- the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
17
- OF ANY KIND, either express or implied. See the License for the specific language
18
- governing permissions and limitations under the License.
19
- */
9
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
10
+
11
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
12
+
13
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
14
+
15
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
16
+
17
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
18
+
19
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
20
+
21
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
22
+
20
23
  var browserSupportsUserAgentClientHints = function browserSupportsUserAgentClientHints(navigator) {
21
24
  return typeof navigator.userAgentData !== "undefined";
22
25
  };
@@ -28,12 +31,20 @@ var _default = function _default(navigator) {
28
31
 
29
32
  return function (xdm, logger) {
30
33
  try {
31
- return navigator.userAgentData.getHighEntropyValues(_highEntropyUserAgentClientHints.default).then(function (hints) {
34
+ return navigator.userAgentData.getHighEntropyValues(_highEntropyUserAgentClientHints.default.map(function (hint) {
35
+ return hint[0];
36
+ })).then(function (hints) {
32
37
  var userAgentClientHints = {};
33
38
 
34
- _highEntropyUserAgentClientHints.default.forEach(function (hint) {
35
- if (Object.prototype.hasOwnProperty.call(hints, hint)) {
36
- userAgentClientHints[hint] = hints[hint];
39
+ _highEntropyUserAgentClientHints.default.forEach(function (_ref) {
40
+ var _ref2 = _slicedToArray(_ref, 2),
41
+ hintName = _ref2[0],
42
+ hintType = _ref2[1];
43
+
44
+ if (Object.prototype.hasOwnProperty.call(hints, hintName) &&
45
+ /* eslint-disable-next-line valid-typeof */
46
+ _typeof(hints[hintName]) === hintType) {
47
+ userAgentClientHints[hintName] = hints[hintName];
37
48
  }
38
49
  });
39
50
 
@@ -18,13 +18,16 @@ governing permissions and limitations under the License.
18
18
  var _default = function _default(dateProvider) {
19
19
  return function (xdm) {
20
20
  var date = dateProvider();
21
- var placeContext = {
22
- localTime: (0, _utils.toISOStringLocal)(date)
23
- };
21
+ var placeContext = {};
24
22
  var localTimezoneOffset = (0, _utils.toInteger)(date.getTimezoneOffset());
25
23
 
26
24
  if (localTimezoneOffset !== undefined) {
27
25
  placeContext.localTimezoneOffset = localTimezoneOffset;
26
+ } // make sure the timezone offset only uses two digits
27
+
28
+
29
+ if (localTimezoneOffset === undefined || Math.abs(localTimezoneOffset) < 6000) {
30
+ placeContext.localTime = (0, _utils.toISOStringLocal)(date);
28
31
  }
29
32
 
30
33
  (0, _utils.deepAssign)(xdm, {
@@ -19,8 +19,9 @@ var _default = function _default(_ref) {
19
19
  var logger = _ref.logger,
20
20
  orgId = _ref.orgId,
21
21
  awaitVisitorOptIn = _ref.awaitVisitorOptIn;
22
- var Visitor = (0, _getVisitor.default)(window);
23
22
  return function () {
23
+ var Visitor = (0, _getVisitor.default)(window);
24
+
24
25
  if (Visitor) {
25
26
  // Need to explicitly wait for optIn because visitor will call callback
26
27
  // with invalid values prior to optIn being approved
@@ -4,6 +4,10 @@ exports.default = void 0;
4
4
 
5
5
  var _remapHeadOffers = require("./remapHeadOffers");
6
6
 
7
+ var _utils = require("../../../utils");
8
+
9
+ var _remapCustomCodeOffers = require("./remapCustomCodeOffers");
10
+
7
11
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
8
12
 
9
13
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -45,9 +49,17 @@ var executeAction = function executeAction(logger, modules, type, args) {
45
49
  return execute.apply(void 0, _toConsumableArray(args));
46
50
  };
47
51
 
52
+ var PREPROCESSORS = [_remapHeadOffers.default, _remapCustomCodeOffers.default];
53
+
54
+ var preprocess = function preprocess(action) {
55
+ return PREPROCESSORS.reduce(function (processed, fn) {
56
+ return (0, _utils.assign)(processed, fn(processed));
57
+ }, action);
58
+ };
59
+
48
60
  var _default = function _default(actions, modules, logger) {
49
61
  var actionPromises = actions.map(function (action) {
50
- var processedAction = (0, _remapHeadOffers.default)(action);
62
+ var processedAction = preprocess(action);
51
63
  var type = processedAction.type;
52
64
  return executeAction(logger, modules, type, [processedAction]).then(function (result) {
53
65
  logActionCompleted(logger, processedAction);
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+
3
+ exports.default = void 0;
4
+
5
+ var _utils = require("../../../utils");
6
+
7
+ /*
8
+ Copyright 2021 Adobe. All rights reserved.
9
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
10
+ you may not use this file except in compliance with the License. You may obtain a copy
11
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software distributed under
14
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
15
+ OF ANY KIND, either express or implied. See the License for the specific language
16
+ governing permissions and limitations under the License.
17
+ */
18
+
19
+ /*
20
+ * Preprocess customCode actions before rendering, so that offer selectors are remapped appropriately for
21
+ * target offers, to align with the way it works in at.js.
22
+ */
23
+ var ACTION_CUSTOM_CODE = "customCode";
24
+ var TARGET_BODY_SELECTOR = "BODY > *:eq(0)";
25
+
26
+ var _default = function _default(action) {
27
+ var selector = action.selector,
28
+ type = action.type;
29
+
30
+ if (type !== ACTION_CUSTOM_CODE) {
31
+ return action;
32
+ }
33
+
34
+ if (selector !== TARGET_BODY_SELECTOR) {
35
+ return action;
36
+ }
37
+
38
+ return (0, _utils.assign)({}, action, {
39
+ selector: "BODY"
40
+ });
41
+ };
42
+
43
+ exports.default = _default;
@@ -13,5 +13,5 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
13
13
  OF ANY KIND, either express or implied. See the License for the specific language
14
14
  governing permissions and limitations under the License.
15
15
  */
16
- var _default = ["architecture", "bitness", "model", "platformVersion", "wow64"];
16
+ var _default = [["architecture", "string"], ["bitness", "string"], ["model", "string"], ["platformVersion", "string"], ["wow64", "boolean"]];
17
17
  exports.default = _default;
@@ -15,5 +15,5 @@ governing permissions and limitations under the License.
15
15
  */
16
16
  // The __VERSION__ keyword will be replace at alloy build time with the package.json version.
17
17
  // see babel-plugin-version
18
- var _default = "2.14.0-alpha.2";
18
+ var _default = "2.14.0-alpha.21";
19
19
  exports.default = _default;
@@ -30,7 +30,8 @@ var _default = function _default(_ref) {
30
30
  sendNetworkRequest = _ref.sendNetworkRequest,
31
31
  createResponse = _ref.createResponse,
32
32
  processWarningsAndErrors = _ref.processWarningsAndErrors,
33
- getLocationHint = _ref.getLocationHint;
33
+ getLocationHint = _ref.getLocationHint,
34
+ getAssuranceValidationTokenParams = _ref.getAssuranceValidationTokenParams;
34
35
  var edgeDomain = config.edgeDomain,
35
36
  edgeBasePath = config.edgeBasePath,
36
37
  edgeConfigId = config.edgeConfigId;
@@ -59,7 +60,7 @@ var _default = function _default(_ref) {
59
60
  var endpointDomain = request.getUseIdThirdPartyDomain() ? _domain.ID_THIRD_PARTY : edgeDomain;
60
61
  var locationHint = getLocationHint();
61
62
  var edgeBasePathWithLocationHint = locationHint ? edgeBasePath + "/" + locationHint : edgeBasePath;
62
- var url = "https://" + endpointDomain + "/" + edgeBasePathWithLocationHint + "/" + _apiVersion.default + "/" + request.getAction() + "?configId=" + edgeConfigId + "&requestId=" + request.getId();
63
+ var url = "https://" + endpointDomain + "/" + edgeBasePathWithLocationHint + "/" + _apiVersion.default + "/" + request.getAction() + "?configId=" + edgeConfigId + "&requestId=" + request.getId() + getAssuranceValidationTokenParams();
63
64
  cookieTransfer.cookiesToPayload(request.getPayload(), endpointDomain);
64
65
  return sendNetworkRequest({
65
66
  requestId: request.getId(),
@@ -99,6 +99,10 @@ var sendFetchRequest = (0, _utils.isFunction)(fetch) ? (0, _injectSendFetchReque
99
99
  XMLHttpRequest: XMLHttpRequest
100
100
  });
101
101
  var fireReferrerHideableImage = (0, _utils.injectFireReferrerHideableImage)();
102
+ var getAssuranceValidationTokenParams = (0, _request.createGetAssuranceValidationTokenParams)({
103
+ window: window,
104
+ createNamespacedStorage: createNamespacedStorage
105
+ });
102
106
 
103
107
  var createExecuteCommand = function createExecuteCommand(_ref) {
104
108
  var instanceName = _ref.instanceName,
@@ -177,7 +181,8 @@ var createExecuteCommand = function createExecuteCommand(_ref) {
177
181
  sendNetworkRequest: sendNetworkRequest,
178
182
  createResponse: createResponse,
179
183
  processWarningsAndErrors: processWarningsAndErrors,
180
- getLocationHint: getLocationHint
184
+ getLocationHint: getLocationHint,
185
+ getAssuranceValidationTokenParams: getAssuranceValidationTokenParams
181
186
  });
182
187
  var applyResponse = (0, _injectApplyResponse.default)({
183
188
  lifecycle: lifecycle,
@@ -24,7 +24,7 @@ var _default = function _default(_ref) {
24
24
  headers: {
25
25
  "Content-Type": "text/plain; charset=UTF-8"
26
26
  },
27
- referrer: "client",
27
+ referrerPolicy: "no-referrer-when-downgrade",
28
28
  body: body
29
29
  }).then(function (response) {
30
30
  return response.text().then(function (responseBody) {
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+
3
+ exports.default = void 0;
4
+
5
+ var _index = require("../index");
6
+
7
+ /*
8
+ Copyright 2022 Adobe. All rights reserved.
9
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
10
+ you may not use this file except in compliance with the License. You may obtain a copy
11
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software distributed under
14
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
15
+ OF ANY KIND, either express or implied. See the License for the specific language
16
+ governing permissions and limitations under the License.
17
+ */
18
+ var ASSURANCE_VALIDATION_SESSION_URL_PARAM = "adb_validation_sessionid";
19
+ var ASSURANCE_VALIDATION_NAMESPACE = "validation.";
20
+ var CLIENT_ID = "clientId";
21
+
22
+ var getOrCreateAssuranceClientId = function getOrCreateAssuranceClientId(storage) {
23
+ var clientId = storage.persistent.getItem(CLIENT_ID);
24
+
25
+ if (!clientId) {
26
+ clientId = (0, _index.uuid)();
27
+ storage.persistent.setItem(CLIENT_ID, clientId);
28
+ }
29
+
30
+ return clientId;
31
+ };
32
+
33
+ var _default = function _default(_ref) {
34
+ var window = _ref.window,
35
+ createNamespacedStorage = _ref.createNamespacedStorage;
36
+ var storage = createNamespacedStorage(ASSURANCE_VALIDATION_NAMESPACE);
37
+ return function () {
38
+ var parsedQuery = _index.queryString.parse(window.location.search);
39
+
40
+ var validationSessionId = parsedQuery[ASSURANCE_VALIDATION_SESSION_URL_PARAM];
41
+
42
+ if (!validationSessionId) {
43
+ return "";
44
+ }
45
+
46
+ var clientId = getOrCreateAssuranceClientId(storage);
47
+ var validationToken = validationSessionId + "|" + clientId;
48
+ return "&" + _index.queryString.stringify({
49
+ adobeAepValidationToken: validationToken
50
+ });
51
+ };
52
+ };
53
+
54
+ exports.default = _default;
@@ -18,6 +18,12 @@ Object.defineProperty(exports, "createDataCollectionRequestPayload", {
18
18
  return _createDataCollectionRequestPayload.default;
19
19
  }
20
20
  });
21
+ Object.defineProperty(exports, "createGetAssuranceValidationTokenParams", {
22
+ enumerable: true,
23
+ get: function get() {
24
+ return _createGetAssuranceValidationTokenParams.default;
25
+ }
26
+ });
21
27
  Object.defineProperty(exports, "createHasIdentity", {
22
28
  enumerable: true,
23
29
  get: function get() {
@@ -47,4 +53,6 @@ var _createHasIdentity = require("./createHasIdentity");
47
53
 
48
54
  var _createRequest = require("./createRequest");
49
55
 
50
- var _createRequestPayload = require("./createRequestPayload");
56
+ var _createRequestPayload = require("./createRequestPayload");
57
+
58
+ var _createGetAssuranceValidationTokenParams = require("./createGetAssuranceValidationTokenParams");
@@ -2,6 +2,10 @@
2
2
 
3
3
  exports.default = void 0;
4
4
 
5
+ var _isNumber = require("./isNumber");
6
+
7
+ var _isString = require("./isString");
8
+
5
9
  /*
6
10
  Copyright 2022 Adobe. All rights reserved.
7
11
  This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -16,11 +20,19 @@ governing permissions and limitations under the License.
16
20
 
17
21
  /*
18
22
  * coerce `value` to a number or return `defaultValue` if it cannot be.
23
+ *
24
+ * The coersion is attempted if value is a number or string.
19
25
  */
20
26
  var _default = function _default(value, defaultValue) {
21
- var n = Math.round(Number(value)); // eslint-disable-next-line no-restricted-globals
27
+ if ((0, _isNumber.default)(value) || (0, _isString.default)(value)) {
28
+ var n = Math.round(Number(value)); // eslint-disable-next-line no-restricted-globals
29
+
30
+ if (!isNaN(n)) {
31
+ return n;
32
+ }
33
+ }
22
34
 
23
- return isNaN(n) ? defaultValue : n;
35
+ return defaultValue;
24
36
  };
25
37
 
26
38
  exports.default = _default;
@@ -9,7 +9,7 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
9
9
  OF ANY KIND, either express or implied. See the License for the specific language
10
10
  governing permissions and limitations under the License.
11
11
  */
12
- import { deepAssign } from "../../utils";
12
+ import { deepAssign, isFunction, toInteger } from "../../utils";
13
13
 
14
14
  const getScreenOrientationViaProperty = window => {
15
15
  const {
@@ -36,12 +36,14 @@ const getScreenOrientationViaProperty = window => {
36
36
  };
37
37
 
38
38
  const getScreenOrientationViaMediaQuery = window => {
39
- if (window.matchMedia("(orientation: portrait)").matches) {
40
- return "portrait";
41
- }
39
+ if (isFunction(window.matchMedia)) {
40
+ if (window.matchMedia("(orientation: portrait)").matches) {
41
+ return "portrait";
42
+ }
42
43
 
43
- if (window.matchMedia("(orientation: landscape)").matches) {
44
- return "landscape";
44
+ if (window.matchMedia("(orientation: landscape)").matches) {
45
+ return "landscape";
46
+ }
45
47
  }
46
48
 
47
49
  return null;
@@ -55,18 +57,29 @@ export default (window => {
55
57
  height
56
58
  }
57
59
  } = window;
58
- const device = {
59
- screenHeight: height,
60
- screenWidth: width
61
- };
60
+ const device = {};
61
+ const screenHeight = toInteger(height);
62
+
63
+ if (screenHeight >= 0) {
64
+ device.screenHeight = screenHeight;
65
+ }
66
+
67
+ const screenWidth = toInteger(width);
68
+
69
+ if (screenWidth >= 0) {
70
+ device.screenWidth = screenWidth;
71
+ }
72
+
62
73
  const orientation = getScreenOrientationViaProperty(window) || getScreenOrientationViaMediaQuery(window);
63
74
 
64
75
  if (orientation) {
65
76
  device.screenOrientation = orientation;
66
77
  }
67
78
 
68
- deepAssign(xdm, {
69
- device
70
- });
79
+ if (Object.keys(device).length > 0) {
80
+ deepAssign(xdm, {
81
+ device
82
+ });
83
+ }
71
84
  };
72
85
  });
@@ -9,7 +9,7 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
9
9
  OF ANY KIND, either express or implied. See the License for the specific language
10
10
  governing permissions and limitations under the License.
11
11
  */
12
- import { deepAssign, isNumber } from "../../utils";
12
+ import { deepAssign, toInteger } from "../../utils";
13
13
  export default (window => {
14
14
  return xdm => {
15
15
  const {
@@ -23,14 +23,21 @@ export default (window => {
23
23
  const environment = {
24
24
  type: "browser"
25
25
  };
26
+ const viewportWidth = toInteger(clientWidth);
26
27
 
27
- if (isNumber(clientWidth) && clientWidth >= 0 && isNumber(clientHeight) && clientHeight >= 0) {
28
+ if (viewportWidth >= 0) {
28
29
  environment.browserDetails = {
29
- viewportWidth: Math.round(clientWidth),
30
- viewportHeight: Math.round(clientHeight)
30
+ viewportWidth
31
31
  };
32
32
  }
33
33
 
34
+ const viewportHeight = toInteger(clientHeight);
35
+
36
+ if (viewportHeight >= 0) {
37
+ environment.browserDetails = environment.browserDetails || {};
38
+ environment.browserDetails.viewportHeight = viewportHeight;
39
+ }
40
+
34
41
  deepAssign(xdm, {
35
42
  environment
36
43
  });
@@ -23,11 +23,13 @@ export default (navigator => {
23
23
 
24
24
  return (xdm, logger) => {
25
25
  try {
26
- return navigator.userAgentData.getHighEntropyValues(highEntropyUserAgentHints).then(hints => {
26
+ return navigator.userAgentData.getHighEntropyValues(highEntropyUserAgentHints.map(hint => hint[0])).then(hints => {
27
27
  const userAgentClientHints = {};
28
- highEntropyUserAgentHints.forEach(hint => {
29
- if (Object.prototype.hasOwnProperty.call(hints, hint)) {
30
- userAgentClientHints[hint] = hints[hint];
28
+ highEntropyUserAgentHints.forEach(([hintName, hintType]) => {
29
+ if (Object.prototype.hasOwnProperty.call(hints, hintName) &&
30
+ /* eslint-disable-next-line valid-typeof */
31
+ typeof hints[hintName] === hintType) {
32
+ userAgentClientHints[hintName] = hints[hintName];
31
33
  }
32
34
  });
33
35
  deepAssign(xdm, {
@@ -13,13 +13,16 @@ import { deepAssign, toISOStringLocal, toInteger } from "../../utils";
13
13
  export default (dateProvider => {
14
14
  return xdm => {
15
15
  const date = dateProvider();
16
- const placeContext = {
17
- localTime: toISOStringLocal(date)
18
- };
16
+ const placeContext = {};
19
17
  const localTimezoneOffset = toInteger(date.getTimezoneOffset());
20
18
 
21
19
  if (localTimezoneOffset !== undefined) {
22
20
  placeContext.localTimezoneOffset = localTimezoneOffset;
21
+ } // make sure the timezone offset only uses two digits
22
+
23
+
24
+ if (localTimezoneOffset === undefined || Math.abs(localTimezoneOffset) < 6000) {
25
+ placeContext.localTime = toISOStringLocal(date);
23
26
  }
24
27
 
25
28
  deepAssign(xdm, {
@@ -15,8 +15,9 @@ export default (({
15
15
  orgId,
16
16
  awaitVisitorOptIn
17
17
  }) => {
18
- const Visitor = getVisitor(window);
19
18
  return () => {
19
+ const Visitor = getVisitor(window);
20
+
20
21
  if (Visitor) {
21
22
  // Need to explicitly wait for optIn because visitor will call callback
22
23
  // with invalid values prior to optIn being approved
@@ -9,7 +9,9 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
9
9
  OF ANY KIND, either express or implied. See the License for the specific language
10
10
  governing permissions and limitations under the License.
11
11
  */
12
- import preprocess from "./remapHeadOffers";
12
+ import remapHeadOffers from "./remapHeadOffers";
13
+ import { assign } from "../../../utils";
14
+ import remapCustomCodeOffers from "./remapCustomCodeOffers";
13
15
 
14
16
  const logActionError = (logger, action, error) => {
15
17
  if (logger.enabled) {
@@ -42,6 +44,10 @@ const executeAction = (logger, modules, type, args) => {
42
44
  return execute(...args);
43
45
  };
44
46
 
47
+ const PREPROCESSORS = [remapHeadOffers, remapCustomCodeOffers];
48
+
49
+ const preprocess = action => PREPROCESSORS.reduce((processed, fn) => assign(processed, fn(processed)), action);
50
+
45
51
  export default ((actions, modules, logger) => {
46
52
  const actionPromises = actions.map(action => {
47
53
  const processedAction = preprocess(action);
@@ -0,0 +1,37 @@
1
+ /*
2
+ Copyright 2021 Adobe. All rights reserved.
3
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License. You may obtain a copy
5
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+
7
+ Unless required by applicable law or agreed to in writing, software distributed under
8
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ OF ANY KIND, either express or implied. See the License for the specific language
10
+ governing permissions and limitations under the License.
11
+ */
12
+
13
+ /*
14
+ * Preprocess customCode actions before rendering, so that offer selectors are remapped appropriately for
15
+ * target offers, to align with the way it works in at.js.
16
+ */
17
+ import { assign } from "../../../utils";
18
+ const ACTION_CUSTOM_CODE = "customCode";
19
+ const TARGET_BODY_SELECTOR = "BODY > *:eq(0)";
20
+ export default (action => {
21
+ const {
22
+ selector,
23
+ type
24
+ } = action;
25
+
26
+ if (type !== ACTION_CUSTOM_CODE) {
27
+ return action;
28
+ }
29
+
30
+ if (selector !== TARGET_BODY_SELECTOR) {
31
+ return action;
32
+ }
33
+
34
+ return assign({}, action, {
35
+ selector: "BODY"
36
+ });
37
+ });
@@ -9,4 +9,4 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
9
9
  OF ANY KIND, either express or implied. See the License for the specific language
10
10
  governing permissions and limitations under the License.
11
11
  */
12
- export default ["architecture", "bitness", "model", "platformVersion", "wow64"];
12
+ export default [["architecture", "string"], ["bitness", "string"], ["model", "string"], ["platformVersion", "string"], ["wow64", "boolean"]];
@@ -11,4 +11,4 @@ governing permissions and limitations under the License.
11
11
  */
12
12
  // The __VERSION__ keyword will be replace at alloy build time with the package.json version.
13
13
  // see babel-plugin-version
14
- export default "2.14.0-alpha.2";
14
+ export default "2.14.0-alpha.21";
@@ -21,7 +21,8 @@ export default (({
21
21
  sendNetworkRequest,
22
22
  createResponse,
23
23
  processWarningsAndErrors,
24
- getLocationHint
24
+ getLocationHint,
25
+ getAssuranceValidationTokenParams
25
26
  }) => {
26
27
  const {
27
28
  edgeDomain,
@@ -52,7 +53,7 @@ export default (({
52
53
  const endpointDomain = request.getUseIdThirdPartyDomain() ? ID_THIRD_PARTY_DOMAIN : edgeDomain;
53
54
  const locationHint = getLocationHint();
54
55
  const edgeBasePathWithLocationHint = locationHint ? `${edgeBasePath}/${locationHint}` : edgeBasePath;
55
- const url = `https://${endpointDomain}/${edgeBasePathWithLocationHint}/${apiVersion}/${request.getAction()}?configId=${edgeConfigId}&requestId=${request.getId()}`;
56
+ const url = `https://${endpointDomain}/${edgeBasePathWithLocationHint}/${apiVersion}/${request.getAction()}?configId=${edgeConfigId}&requestId=${request.getId()}${getAssuranceValidationTokenParams()}`;
56
57
  cookieTransfer.cookiesToPayload(request.getPayload(), endpointDomain);
57
58
  return sendNetworkRequest({
58
59
  requestId: request.getId(),
@@ -35,7 +35,7 @@ import createLogger from "./createLogger";
35
35
  import createEventManager from "./createEventManager";
36
36
  import createCookieTransfer from "./createCookieTransfer";
37
37
  import injectShouldTransferCookie from "./injectShouldTransferCookie";
38
- import { createDataCollectionRequest, createDataCollectionRequestPayload } from "../utils/request";
38
+ import { createDataCollectionRequest, createDataCollectionRequestPayload, createGetAssuranceValidationTokenParams } from "../utils/request";
39
39
  import injectSendEdgeNetworkRequest from "./edgeNetwork/injectSendEdgeNetworkRequest";
40
40
  import injectProcessWarningsAndErrors from "./edgeNetwork/injectProcessWarningsAndErrors";
41
41
  import injectGetLocationHint from "./edgeNetwork/injectGetLocationHint";
@@ -61,6 +61,10 @@ const sendFetchRequest = isFunction(fetch) ? injectSendFetchRequest({
61
61
  XMLHttpRequest
62
62
  });
63
63
  const fireReferrerHideableImage = injectFireReferrerHideableImage();
64
+ const getAssuranceValidationTokenParams = createGetAssuranceValidationTokenParams({
65
+ window,
66
+ createNamespacedStorage
67
+ });
64
68
  export const createExecuteCommand = ({
65
69
  instanceName,
66
70
  logController: {
@@ -140,7 +144,8 @@ export const createExecuteCommand = ({
140
144
  sendNetworkRequest,
141
145
  createResponse,
142
146
  processWarningsAndErrors,
143
- getLocationHint
147
+ getLocationHint,
148
+ getAssuranceValidationTokenParams
144
149
  });
145
150
  const applyResponse = injectApplyResponse({
146
151
  lifecycle,
@@ -21,7 +21,7 @@ export default (({
21
21
  headers: {
22
22
  "Content-Type": "text/plain; charset=UTF-8"
23
23
  },
24
- referrer: "client",
24
+ referrerPolicy: "no-referrer-when-downgrade",
25
25
  body
26
26
  }).then(response => {
27
27
  return response.text().then(responseBody => ({
@@ -0,0 +1,47 @@
1
+ /*
2
+ Copyright 2022 Adobe. All rights reserved.
3
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License. You may obtain a copy
5
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+
7
+ Unless required by applicable law or agreed to in writing, software distributed under
8
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ OF ANY KIND, either express or implied. See the License for the specific language
10
+ governing permissions and limitations under the License.
11
+ */
12
+ import { uuid, queryString } from "../index";
13
+ const ASSURANCE_VALIDATION_SESSION_URL_PARAM = "adb_validation_sessionid";
14
+ const ASSURANCE_VALIDATION_NAMESPACE = "validation.";
15
+ const CLIENT_ID = "clientId";
16
+
17
+ const getOrCreateAssuranceClientId = storage => {
18
+ let clientId = storage.persistent.getItem(CLIENT_ID);
19
+
20
+ if (!clientId) {
21
+ clientId = uuid();
22
+ storage.persistent.setItem(CLIENT_ID, clientId);
23
+ }
24
+
25
+ return clientId;
26
+ };
27
+
28
+ export default (({
29
+ window,
30
+ createNamespacedStorage
31
+ }) => {
32
+ const storage = createNamespacedStorage(ASSURANCE_VALIDATION_NAMESPACE);
33
+ return () => {
34
+ const parsedQuery = queryString.parse(window.location.search);
35
+ const validationSessionId = parsedQuery[ASSURANCE_VALIDATION_SESSION_URL_PARAM];
36
+
37
+ if (!validationSessionId) {
38
+ return "";
39
+ }
40
+
41
+ const clientId = getOrCreateAssuranceClientId(storage);
42
+ const validationToken = `${validationSessionId}|${clientId}`;
43
+ return `&${queryString.stringify({
44
+ adobeAepValidationToken: validationToken
45
+ })}`;
46
+ };
47
+ });
@@ -14,4 +14,5 @@ export { default as createDataCollectionRequest } from "./createDataCollectionRe
14
14
  export { default as createDataCollectionRequestPayload } from "./createDataCollectionRequestPayload";
15
15
  export { default as createHasIdentity } from "./createHasIdentity";
16
16
  export { default as createRequest } from "./createRequest";
17
- export { default as createRequestPayload } from "./createRequestPayload";
17
+ export { default as createRequestPayload } from "./createRequestPayload";
18
+ export { default as createGetAssuranceValidationTokenParams } from "./createGetAssuranceValidationTokenParams";
@@ -9,12 +9,22 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
9
9
  OF ANY KIND, either express or implied. See the License for the specific language
10
10
  governing permissions and limitations under the License.
11
11
  */
12
-
12
+ import isNumber from "./isNumber";
13
+ import isString from "./isString";
13
14
  /*
14
15
  * coerce `value` to a number or return `defaultValue` if it cannot be.
16
+ *
17
+ * The coersion is attempted if value is a number or string.
15
18
  */
19
+
16
20
  export default ((value, defaultValue) => {
17
- const n = Math.round(Number(value)); // eslint-disable-next-line no-restricted-globals
21
+ if (isNumber(value) || isString(value)) {
22
+ const n = Math.round(Number(value)); // eslint-disable-next-line no-restricted-globals
23
+
24
+ if (!isNaN(n)) {
25
+ return n;
26
+ }
27
+ }
18
28
 
19
- return isNaN(n) ? defaultValue : n;
29
+ return defaultValue;
20
30
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/alloy",
3
- "version": "2.14.0-alpha.2",
3
+ "version": "2.14.0-alpha.21",
4
4
  "description": "Adobe Experience Platform Web SDK",
5
5
  "main": "libEs5/index.js",
6
6
  "module": "libEs6/index.js",
@@ -64,7 +64,7 @@
64
64
  "uuid": "^3.3.2"
65
65
  },
66
66
  "devDependencies": {
67
- "@adobe/alloy": "^2.14.0-alpha.1",
67
+ "@adobe/alloy": "^2.14.0-alpha.20",
68
68
  "@babel/cli": "^7.12.8",
69
69
  "@babel/core": "^7.2.2",
70
70
  "@babel/plugin-proposal-object-rest-spread": "^7.3.2",
@@ -95,6 +95,7 @@
95
95
  "karma-jasmine": "^2.0.1",
96
96
  "karma-jasmine-html-reporter": "^1.4.2",
97
97
  "karma-jasmine-matchers": "^4.0.1",
98
+ "karma-junit-reporter": "^2.0.1",
98
99
  "karma-rollup-preprocessor": "^7.0.5",
99
100
  "karma-safari-launcher": "^1.0.0",
100
101
  "karma-sauce-launcher": "^4.3.6",
@@ -117,9 +118,9 @@
117
118
  "rollup-plugin-terser": "^7.0.2",
118
119
  "semver": "^7.3.7",
119
120
  "start-server-and-test": "^1.10.6",
120
- "testcafe": "^1.19.0",
121
- "testcafe-browser-provider-saucelabs": "^1.8.3",
122
- "testcafe-reporter-json": "^2.2.0",
121
+ "testcafe": "^2.2.0",
122
+ "testcafe-browser-provider-saucelabs": "^1.9.0",
123
+ "testcafe-reporter-junit": "^3.0.2",
123
124
  "url-exists-nodejs": "^0.1.0",
124
125
  "url-parse": "^1.4.7",
125
126
  "yargs": "^16.2.0"