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

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.
@@ -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.3";
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,
@@ -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");
@@ -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.3";
@@ -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,
@@ -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";
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.3",
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.2",
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",