@adobe/alloy 2.30.1-beta.11 → 2.30.1-beta.13

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 (108) hide show
  1. package/libEs5/components/BrandConcierge/constants.js +15 -0
  2. package/libEs5/components/BrandConcierge/createBuildEndpointUrl.js +33 -0
  3. package/libEs5/components/BrandConcierge/createConversationServiceRequest.js +35 -0
  4. package/libEs5/components/BrandConcierge/createSendConversationEvent.js +132 -0
  5. package/libEs5/components/BrandConcierge/createSendConversationServiceRequest.js +85 -0
  6. package/libEs5/components/BrandConcierge/createStreamParser.js +96 -0
  7. package/libEs5/components/BrandConcierge/index.js +104 -0
  8. package/libEs5/components/BrandConcierge/utils.js +33 -0
  9. package/libEs5/components/BrandConcierge/validateMessage.js +41 -0
  10. package/libEs5/components/Context/createComponent.js +1 -2
  11. package/libEs5/components/Context/implementationDetails.js +7 -9
  12. package/libEs5/components/Context/index.js +4 -1
  13. package/libEs5/components/Context/injectDevice.js +2 -2
  14. package/libEs5/components/Context/injectEnvironment.js +2 -2
  15. package/libEs5/components/Context/injectHighEntropyUserAgentHints.js +2 -2
  16. package/libEs5/components/Context/injectOneTimeAnalyticsReferrer.js +49 -0
  17. package/libEs5/components/Context/injectPlaceContext.js +2 -2
  18. package/libEs5/components/Context/injectTimestamp.js +2 -3
  19. package/libEs5/components/Context/injectWeb.js +9 -11
  20. package/libEs5/components/Personalization/createPersonalizationDetails.js +1 -1
  21. package/libEs5/components/Personalization/index.js +1 -1
  22. package/libEs5/constants/libraryVersion.js +1 -1
  23. package/libEs5/constants/surface.js +19 -0
  24. package/libEs5/core/componentCreators.js +8 -1
  25. package/libEs5/core/index.js +5 -1
  26. package/libEs5/utils/dom/createGetPageLocation.js +20 -0
  27. package/libEs5/utils/index.js +8 -1
  28. package/libEs5/utils/request/createRequest.js +5 -1
  29. package/libEs5/utils/surfaceUtils.js +82 -0
  30. package/libEs6/components/BrandConcierge/constants.js +12 -0
  31. package/libEs6/components/BrandConcierge/createBuildEndpointUrl.js +30 -0
  32. package/libEs6/components/BrandConcierge/createConversationServiceRequest.js +31 -0
  33. package/libEs6/components/BrandConcierge/createSendConversationEvent.js +128 -0
  34. package/libEs6/components/BrandConcierge/createSendConversationServiceRequest.js +81 -0
  35. package/libEs6/components/BrandConcierge/createStreamParser.js +92 -0
  36. package/libEs6/components/BrandConcierge/index.js +100 -0
  37. package/libEs6/components/BrandConcierge/utils.js +27 -0
  38. package/libEs6/components/BrandConcierge/validateMessage.js +37 -0
  39. package/libEs6/components/Context/createComponent.js +1 -2
  40. package/libEs6/components/Context/implementationDetails.js +7 -9
  41. package/libEs6/components/Context/index.js +4 -1
  42. package/libEs6/components/Context/injectDevice.js +3 -3
  43. package/libEs6/components/Context/injectEnvironment.js +3 -3
  44. package/libEs6/components/Context/injectHighEntropyUserAgentHints.js +3 -3
  45. package/libEs6/components/Context/injectOneTimeAnalyticsReferrer.js +46 -0
  46. package/libEs6/components/Context/injectPlaceContext.js +3 -3
  47. package/libEs6/components/Context/injectTimestamp.js +2 -3
  48. package/libEs6/components/Context/injectWeb.js +9 -11
  49. package/libEs6/components/Personalization/createPersonalizationDetails.js +1 -1
  50. package/libEs6/components/Personalization/index.js +1 -1
  51. package/libEs6/constants/libraryVersion.js +1 -1
  52. package/libEs6/constants/surface.js +16 -0
  53. package/libEs6/core/componentCreators.js +2 -1
  54. package/libEs6/core/index.js +5 -1
  55. package/libEs6/utils/dom/createGetPageLocation.js +17 -0
  56. package/libEs6/utils/index.js +2 -1
  57. package/libEs6/utils/request/createRequest.js +5 -1
  58. package/libEs6/utils/surfaceUtils.js +76 -0
  59. package/package.json +1 -1
  60. package/types/components/BrandConcierge/constants.d.ts +2 -0
  61. package/types/components/BrandConcierge/constants.d.ts.map +1 -0
  62. package/types/components/BrandConcierge/createBuildEndpointUrl.d.ts +9 -0
  63. package/types/components/BrandConcierge/createBuildEndpointUrl.d.ts.map +1 -0
  64. package/types/components/BrandConcierge/createConversationServiceRequest.d.ts +7 -0
  65. package/types/components/BrandConcierge/createConversationServiceRequest.d.ts.map +1 -0
  66. package/types/components/BrandConcierge/createSendConversationEvent.d.ts +14 -0
  67. package/types/components/BrandConcierge/createSendConversationEvent.d.ts.map +1 -0
  68. package/types/components/BrandConcierge/createSendConversationServiceRequest.d.ts +11 -0
  69. package/types/components/BrandConcierge/createSendConversationServiceRequest.d.ts.map +1 -0
  70. package/types/components/BrandConcierge/createStreamParser.d.ts +3 -0
  71. package/types/components/BrandConcierge/createStreamParser.d.ts.map +1 -0
  72. package/types/components/BrandConcierge/index.d.ts +31 -0
  73. package/types/components/BrandConcierge/index.d.ts.map +1 -0
  74. package/types/components/BrandConcierge/utils.d.ts +6 -0
  75. package/types/components/BrandConcierge/utils.d.ts.map +1 -0
  76. package/types/components/BrandConcierge/validateMessage.d.ts +5 -0
  77. package/types/components/BrandConcierge/validateMessage.d.ts.map +1 -0
  78. package/types/components/Context/createComponent.d.ts +1 -1
  79. package/types/components/Context/createComponent.d.ts.map +1 -1
  80. package/types/components/Context/implementationDetails.d.ts +1 -1
  81. package/types/components/Context/implementationDetails.d.ts.map +1 -1
  82. package/types/components/Context/index.d.ts +1 -1
  83. package/types/components/Context/index.d.ts.map +1 -1
  84. package/types/components/Context/injectDevice.d.ts +1 -1
  85. package/types/components/Context/injectDevice.d.ts.map +1 -1
  86. package/types/components/Context/injectEnvironment.d.ts +1 -1
  87. package/types/components/Context/injectEnvironment.d.ts.map +1 -1
  88. package/types/components/Context/injectHighEntropyUserAgentHints.d.ts +1 -1
  89. package/types/components/Context/injectHighEntropyUserAgentHints.d.ts.map +1 -1
  90. package/types/components/Context/injectOneTimeAnalyticsReferrer.d.ts +3 -0
  91. package/types/components/Context/injectOneTimeAnalyticsReferrer.d.ts.map +1 -0
  92. package/types/components/Context/injectPlaceContext.d.ts +1 -1
  93. package/types/components/Context/injectPlaceContext.d.ts.map +1 -1
  94. package/types/components/Context/injectTimestamp.d.ts +1 -1
  95. package/types/components/Context/injectTimestamp.d.ts.map +1 -1
  96. package/types/components/Context/injectWeb.d.ts +1 -1
  97. package/types/components/Context/injectWeb.d.ts.map +1 -1
  98. package/types/components/Personalization/createPersonalizationDetails.d.ts.map +1 -1
  99. package/types/constants/surface.d.ts +5 -0
  100. package/types/constants/surface.d.ts.map +1 -0
  101. package/types/core/componentCreators.d.ts +1 -0
  102. package/types/core/index.d.ts.map +1 -1
  103. package/types/utils/dom/createGetPageLocation.d.ts +5 -0
  104. package/types/utils/dom/createGetPageLocation.d.ts.map +1 -0
  105. package/types/utils/index.d.ts +1 -0
  106. package/types/utils/request/createRequest.d.ts.map +1 -1
  107. package/types/utils/surfaceUtils.d.ts +4 -0
  108. package/types/utils/surfaceUtils.d.ts.map +1 -0
@@ -22,7 +22,7 @@ var _default = navigator => {
22
22
  if (!browserSupportsUserAgentClientHints(navigator)) {
23
23
  return _index.noop;
24
24
  }
25
- return (xdm, logger) => {
25
+ return (event, logger) => {
26
26
  try {
27
27
  // eslint-disable-next-line compat/compat -- userAgentData support is checked before calling
28
28
  return navigator.userAgentData.getHighEntropyValues(_highEntropyUserAgentClientHints.default.map(hint => hint[0])).then(hints => {
@@ -33,7 +33,7 @@ var _default = navigator => {
33
33
  userAgentClientHints[hintName] = hints[hintName];
34
34
  }
35
35
  });
36
- (0, _index.deepAssign)(xdm, {
36
+ event.mergeXdm({
37
37
  environment: {
38
38
  browserDetails: {
39
39
  userAgentClientHints
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+
3
+ exports.default = void 0;
4
+ /*
5
+ Copyright 2025 Adobe. All rights reserved.
6
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
7
+ you may not use this file except in compliance with the License. You may obtain a copy
8
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software distributed under
11
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
12
+ OF ANY KIND, either express or implied. See the License for the specific language
13
+ governing permissions and limitations under the License.
14
+ */
15
+ var _default = window => {
16
+ let lastReferrerSent = null;
17
+ return event => {
18
+ const content = event.getContent();
19
+ const eventType = content.xdm?.eventType;
20
+ if (eventType === "decisioning.propositionFetch") {
21
+ return;
22
+ }
23
+
24
+ // Allow customers to explicitly set the referrer (for SPA view changes)
25
+ // Otherwise, use document.referrer
26
+ // eslint-disable-next-line no-underscore-dangle
27
+ const explicitReferrer = content.data?.__adobe?.analytics?.referrer;
28
+ const currentReferrer = explicitReferrer !== undefined ? explicitReferrer : window.document.referrer;
29
+ if (currentReferrer === lastReferrerSent) {
30
+ event.mergeData({
31
+ __adobe: {
32
+ analytics: {
33
+ referrer: ""
34
+ }
35
+ }
36
+ });
37
+ return;
38
+ }
39
+ event.mergeData({
40
+ __adobe: {
41
+ analytics: {
42
+ referrer: currentReferrer
43
+ }
44
+ }
45
+ });
46
+ lastReferrerSent = currentReferrer;
47
+ };
48
+ };
49
+ exports.default = _default;
@@ -14,7 +14,7 @@ OF ANY KIND, either express or implied. See the License for the specific languag
14
14
  governing permissions and limitations under the License.
15
15
  */
16
16
  var _default = dateProvider => {
17
- return xdm => {
17
+ return event => {
18
18
  const date = dateProvider();
19
19
  const placeContext = {};
20
20
  const localTimezoneOffset = (0, _index.toInteger)(date.getTimezoneOffset());
@@ -25,7 +25,7 @@ var _default = dateProvider => {
25
25
  if (localTimezoneOffset === undefined || Math.abs(localTimezoneOffset) < 6000) {
26
26
  placeContext.localTime = (0, _index.toISOStringLocal)(date);
27
27
  }
28
- (0, _index.deepAssign)(xdm, {
28
+ event.mergeXdm({
29
29
  placeContext
30
30
  });
31
31
  };
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  exports.default = void 0;
4
- var _index = require("../../utils/index.js");
5
4
  /*
6
5
  Copyright 2019 Adobe. All rights reserved.
7
6
  This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -14,9 +13,9 @@ OF ANY KIND, either express or implied. See the License for the specific languag
14
13
  governing permissions and limitations under the License.
15
14
  */
16
15
  var _default = dateProvider => {
17
- return xdm => {
16
+ return event => {
18
17
  const timestamp = dateProvider().toISOString();
19
- (0, _index.deepAssign)(xdm, {
18
+ event.mergeXdm({
20
19
  timestamp
21
20
  });
22
21
  };
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  exports.default = void 0;
4
- var _index = require("../../utils/index.js");
5
4
  /*
6
5
  Copyright 2019 Adobe. All rights reserved.
7
6
  This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -14,17 +13,16 @@ OF ANY KIND, either express or implied. See the License for the specific languag
14
13
  governing permissions and limitations under the License.
15
14
  */
16
15
  var _default = window => {
17
- return xdm => {
18
- const web = {
19
- webPageDetails: {
20
- URL: window.location.href || window.location
21
- },
22
- webReferrer: {
23
- URL: window.document.referrer
16
+ return event => {
17
+ event.mergeXdm({
18
+ web: {
19
+ webPageDetails: {
20
+ URL: window.location.href || window.location
21
+ },
22
+ webReferrer: {
23
+ URL: window.document.referrer
24
+ }
24
25
  }
25
- };
26
- (0, _index.deepAssign)(xdm, {
27
- web
28
26
  });
29
27
  };
30
28
  };
@@ -2,9 +2,9 @@
2
2
 
3
3
  exports.default = void 0;
4
4
  var _index = require("../../utils/index.js");
5
- var _surfaceUtils = require("./utils/surfaceUtils.js");
6
5
  var _pageWideScope = require("../../constants/pageWideScope.js");
7
6
  var _schema = require("../../constants/schema.js");
7
+ var _surfaceUtils = require("../../utils/surfaceUtils.js");
8
8
  /*
9
9
  Copyright 2020 Adobe. All rights reserved.
10
10
  This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -25,7 +25,7 @@ var _injectCreateProposition = require("./handlers/injectCreateProposition.js");
25
25
  var _createAsyncArray = require("./utils/createAsyncArray.js");
26
26
  var schema = require("../../constants/schema.js");
27
27
  var _processDefaultContent = require("./handlers/processDefaultContent.js");
28
- var _surfaceUtils = require("./utils/surfaceUtils.js");
28
+ var _surfaceUtils = require("../../utils/surfaceUtils.js");
29
29
  var _createProcessDomAction = require("./handlers/createProcessDomAction.js");
30
30
  var _createProcessHtmlContent = require("./handlers/createProcessHtmlContent.js");
31
31
  var _createProcessRedirect = require("./handlers/createProcessRedirect.js");
@@ -14,4 +14,4 @@ governing permissions and limitations under the License.
14
14
  */
15
15
  // The __VERSION__ keyword will be replace at alloy build time with the package.json version.
16
16
  // see babel-plugin-version
17
- var _default = exports.default = "2.30.1-beta.11";
17
+ var _default = exports.default = "2.30.1-beta.13";
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ exports.WEBAPP = exports.WEB = exports.SURFACE_TYPE_DELIMITER = exports.FRAGMENT_DELIMITER = void 0;
4
+ /*
5
+ Copyright 2022 Adobe. All rights reserved.
6
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
7
+ you may not use this file except in compliance with the License. You may obtain a copy
8
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software distributed under
11
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
12
+ OF ANY KIND, either express or implied. See the License for the specific language
13
+ governing permissions and limitations under the License.
14
+ */
15
+
16
+ const WEB = exports.WEB = "web";
17
+ const WEBAPP = exports.WEBAPP = "webapp";
18
+ const SURFACE_TYPE_DELIMITER = exports.SURFACE_TYPE_DELIMITER = "://";
19
+ const FRAGMENT_DELIMITER = exports.FRAGMENT_DELIMITER = "#";
@@ -18,6 +18,12 @@ Object.defineProperty(exports, "audiences", {
18
18
  return _index2.default;
19
19
  }
20
20
  });
21
+ Object.defineProperty(exports, "brandConcierge", {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _index1.default;
25
+ }
26
+ });
21
27
  Object.defineProperty(exports, "consent", {
22
28
  enumerable: true,
23
29
  get: function () {
@@ -69,4 +75,5 @@ var _index6 = require("../components/Personalization/index.js");
69
75
  var _index7 = require("../components/RulesEngine/index.js");
70
76
  var _index8 = require("../components/StreamingMedia/index.js");
71
77
  var _index9 = require("../components/Advertising/index.js");
72
- var _index0 = require("../components/PushNotifications/index.js");
78
+ var _index0 = require("../components/PushNotifications/index.js");
79
+ var _index1 = require("../components/BrandConcierge/index.js");
@@ -184,6 +184,8 @@ const createExecuteCommand = ({
184
184
  getImmediatelyAvailableTools(componentName) {
185
185
  const componentLogger = createComponentLogger(componentName);
186
186
  return {
187
+ loggingCookieJar,
188
+ instanceName,
187
189
  config,
188
190
  componentRegistry,
189
191
  consent,
@@ -199,7 +201,9 @@ const createExecuteCommand = ({
199
201
  }),
200
202
  createNamespacedStorage,
201
203
  apexDomain,
202
- getBrowser
204
+ getBrowser,
205
+ cookieTransfer,
206
+ createResponse
203
207
  };
204
208
  }
205
209
  });
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ exports.default = void 0;
4
+ /*
5
+ Copyright 2022 Adobe. All rights reserved.
6
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
7
+ you may not use this file except in compliance with the License. You may obtain a copy
8
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software distributed under
11
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
12
+ OF ANY KIND, either express or implied. See the License for the specific language
13
+ governing permissions and limitations under the License.
14
+ */
15
+ var _default = ({
16
+ window
17
+ }) => () => {
18
+ return window.location;
19
+ };
20
+ exports.default = _default;
@@ -36,6 +36,12 @@ Object.defineProperty(exports, "createCallbackAggregator", {
36
36
  return _createCallbackAggregator.default;
37
37
  }
38
38
  });
39
+ Object.defineProperty(exports, "createGetPageLocation", {
40
+ enumerable: true,
41
+ get: function () {
42
+ return _createGetPageLocation.default;
43
+ }
44
+ });
39
45
  Object.defineProperty(exports, "createLoggingCookieJar", {
40
46
  enumerable: true,
41
47
  get: function () {
@@ -362,4 +368,5 @@ var _toISOStringLocal = require("./toISOStringLocal.js");
362
368
  var _uuid = require("./uuid.js");
363
369
  var _updateErrorMessage = require("./updateErrorMessage.js");
364
370
  var _validateIdentityMap = require("./validateIdentityMap.js");
365
- var _validateConfigOverride = require("./validateConfigOverride.js");
371
+ var _validateConfigOverride = require("./validateConfigOverride.js");
372
+ var _createGetPageLocation = require("./dom/createGetPageLocation.js");
@@ -47,7 +47,8 @@ var _default = options => {
47
47
  getAction,
48
48
  getUseSendBeacon,
49
49
  datastreamIdOverride,
50
- edgeSubPath
50
+ edgeSubPath,
51
+ requestParams = {}
51
52
  } = options;
52
53
  const id = (0, _index.uuid)();
53
54
  let shouldUseThirdPartyDomain = false;
@@ -86,6 +87,9 @@ var _default = options => {
86
87
  },
87
88
  setIsIdentityEstablished() {
88
89
  isIdentityEstablished = true;
90
+ },
91
+ getRequestParams() {
92
+ return requestParams;
89
93
  }
90
94
  };
91
95
  };
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+
3
+ exports.normalizeSurfaces = exports.isPageWideSurface = exports.buildPageSurface = void 0;
4
+ var _surface = require("../constants/surface.js");
5
+ var _index = require("./index.js");
6
+ /*
7
+ Copyright 2022 Adobe. All rights reserved.
8
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
9
+ you may not use this file except in compliance with the License. You may obtain a copy
10
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
11
+
12
+ Unless required by applicable law or agreed to in writing, software distributed under
13
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
14
+ OF ANY KIND, either express or implied. See the License for the specific language
15
+ governing permissions and limitations under the License.
16
+ */
17
+
18
+ const SURFACE_REGEX = /^(\w+):\/\/([^/#]+)(\/[^#]*)?(#.*)?$/;
19
+ const AUTHORITY_REGEX = /^(?:.*@)?(?:[a-z\d\u00a1-\uffff.-]+|\[[a-f\d:]+])(?::\d+)?$/;
20
+ const PATH_REGEX = /^\/(?:[/\w\u00a1-\uffff-.~]|%[a-fA-F\d]{2})*$/;
21
+ const FRAGMENT_REGEX = /^#(?:[/\w\u00a1-\uffff-.~]|%[a-fA-F\d]{2})+$/;
22
+ const normalizePath = (path = "/") => {
23
+ let end = path.length;
24
+ while (end > 0 && "/".indexOf(path.charAt(end - 1)) !== -1) {
25
+ end -= 1;
26
+ }
27
+ return path.substring(0, end) || "/";
28
+ };
29
+ const getSurfaceType = surfaceTypeMatch => (0, _index.isNonEmptyString)(surfaceTypeMatch) ? surfaceTypeMatch.toLowerCase() : "";
30
+ const getAuthority = authorityMatch => (0, _index.isNonEmptyString)(authorityMatch) ? authorityMatch.toLowerCase() : "";
31
+ const getPath = pathMatch => (0, _index.isNonEmptyString)(pathMatch) ? normalizePath(pathMatch) : "/";
32
+ const parseSurface = surfaceString => {
33
+ const matched = surfaceString.match(SURFACE_REGEX);
34
+ return matched ? {
35
+ surfaceType: getSurfaceType(matched[1]),
36
+ authority: getAuthority(matched[2]),
37
+ path: getPath(matched[3]),
38
+ fragment: matched[4]
39
+ } : null;
40
+ };
41
+ const stringifySurface = surface => "" + surface.surfaceType + _surface.SURFACE_TYPE_DELIMITER + surface.authority + (surface.path || "") + (surface.fragment || "");
42
+ const buildPageSurface = getPageLocation => {
43
+ const location = getPageLocation();
44
+ const host = location.host.toLowerCase();
45
+ const path = location.pathname;
46
+ return _surface.WEB + _surface.SURFACE_TYPE_DELIMITER + host + normalizePath(path);
47
+ };
48
+ exports.buildPageSurface = buildPageSurface;
49
+ const expandFragmentSurface = (surface, getPageLocation) => surface.startsWith(_surface.FRAGMENT_DELIMITER) ? buildPageSurface(getPageLocation) + surface : surface;
50
+ const validateSurface = (surface, getPageLocation, logger) => {
51
+ const invalidateSurface = validationError => {
52
+ logger.warn(validationError);
53
+ return null;
54
+ };
55
+ if (!(0, _index.isNonEmptyString)(surface)) {
56
+ return invalidateSurface("Invalid surface: " + surface);
57
+ }
58
+ const expanded = expandFragmentSurface(surface, getPageLocation);
59
+ const parsed = parseSurface(expanded);
60
+ if (parsed === null) {
61
+ return invalidateSurface("Invalid surface: " + surface);
62
+ }
63
+ if (![_surface.WEB, _surface.WEBAPP].includes(parsed.surfaceType)) {
64
+ return invalidateSurface("Unsupported surface type " + parsed.surfaceType + " in surface: " + surface);
65
+ }
66
+ if (!parsed.authority || !AUTHORITY_REGEX.test(parsed.authority)) {
67
+ return invalidateSurface("Invalid authority " + parsed.authority + " in surface: " + surface);
68
+ }
69
+ if (parsed.path && !PATH_REGEX.test(parsed.path)) {
70
+ return invalidateSurface("Invalid path " + parsed.path + " in surface: " + surface);
71
+ }
72
+ if (parsed.fragment && !FRAGMENT_REGEX.test(parsed.fragment)) {
73
+ return invalidateSurface("Invalid fragment " + parsed.fragment + " in surface: " + surface);
74
+ }
75
+ return parsed;
76
+ };
77
+ const isPageWideSurface = scope => !!scope && scope.indexOf(_surface.WEB + _surface.SURFACE_TYPE_DELIMITER) === 0 && scope.indexOf(_surface.FRAGMENT_DELIMITER) === -1;
78
+
79
+ // eslint-disable-next-line default-param-last
80
+ exports.isPageWideSurface = isPageWideSurface;
81
+ const normalizeSurfaces = (surfaces = [], getPageLocation, logger) => surfaces.map(surface => validateSurface(surface, getPageLocation, logger)).filter(surface => !(0, _index.isNil)(surface)).map(stringifySurface);
82
+ exports.normalizeSurfaces = normalizeSurfaces;
@@ -0,0 +1,12 @@
1
+ /*
2
+ Copyright 2025 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
+ export const BC_SESSION_COOKIE_NAME = "bc_session_id";
@@ -0,0 +1,30 @@
1
+ /*
2
+ Copyright 2025 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
+ export default ({
14
+ queryString
15
+ }) => {
16
+ return ({
17
+ edgeDomain,
18
+ request,
19
+ datastreamId
20
+ }) => {
21
+ const params = request.getRequestParams();
22
+ const configId = request.getDatastreamIdOverride() || datastreamId;
23
+ params.requestId = request.getId();
24
+ params.configId = configId;
25
+ const stringifiedRequestParams = queryString.stringify({
26
+ ...params
27
+ });
28
+ return `https://${edgeDomain}${request.getEdgeSubPath()}/${request.getAction()}?${stringifiedRequestParams}`;
29
+ };
30
+ };
@@ -0,0 +1,31 @@
1
+ /*
2
+ Copyright 2023 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 { createRequest } from "../../utils/request/index.js";
13
+ export default ({
14
+ payload,
15
+ action = "conversations",
16
+ sessionId
17
+ }) => {
18
+ return createRequest({
19
+ payload: payload,
20
+ edgeSubPath: "/brand-concierge",
21
+ requestParams: {
22
+ sessionId
23
+ },
24
+ getAction() {
25
+ return action;
26
+ },
27
+ getUseSendBeacon() {
28
+ return false;
29
+ }
30
+ });
31
+ };
@@ -0,0 +1,128 @@
1
+ /*
2
+ Copyright 2025 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 { createDataCollectionRequestPayload } from "../../utils/request/index.js";
13
+ import createConversationServiceRequest from "./createConversationServiceRequest.js";
14
+ import { getConciergeSessionCookie, getPageSurface } from "./utils.js";
15
+ import uuid from "../../utils/uuid.js";
16
+ import createStreamParser from "./createStreamParser.js";
17
+ export default ({
18
+ eventManager,
19
+ loggingCookieJar,
20
+ config,
21
+ logger,
22
+ sendConversationServiceRequest,
23
+ buildEndpointUrl,
24
+ cookieTransfer,
25
+ createResponse,
26
+ decodeKndctrCookie,
27
+ lifecycle
28
+ }) => {
29
+ const {
30
+ edgeDomain,
31
+ edgeBasePath,
32
+ datastreamId,
33
+ onBeforeEventSend
34
+ } = config;
35
+ return options => {
36
+ let streamingEnabled = false;
37
+ const {
38
+ message,
39
+ onStreamResponse,
40
+ xdm,
41
+ data
42
+ } = options;
43
+ const sessionId = getConciergeSessionCookie({
44
+ loggingCookieJar,
45
+ config
46
+ }) || uuid();
47
+ const payload = createDataCollectionRequestPayload();
48
+ const request = createConversationServiceRequest({
49
+ payload,
50
+ sessionId: sessionId
51
+ });
52
+ const event = eventManager.createEvent();
53
+ if (message || data) {
54
+ const pageSurface = getPageSurface();
55
+ event.mergeQuery({
56
+ conversation: {
57
+ surfaces: [pageSurface],
58
+ message,
59
+ data
60
+ }
61
+ });
62
+ }
63
+ const ecid = decodeKndctrCookie();
64
+ event.mergeXdm({
65
+ identityMap: {
66
+ ECID: [{
67
+ id: ecid
68
+ }]
69
+ }
70
+ });
71
+ event.mergeXdm({
72
+ ...xdm
73
+ });
74
+ if (message || data) {
75
+ streamingEnabled = true;
76
+ }
77
+ const url = buildEndpointUrl({
78
+ edgeDomain,
79
+ edgeBasePath,
80
+ datastreamId,
81
+ request
82
+ });
83
+ return lifecycle.onBeforeEvent({
84
+ event
85
+ }).then(() => {
86
+ try {
87
+ // NOTE: this calls onBeforeEventSend callback (if configured)
88
+ event.finalize(onBeforeEventSend);
89
+ } catch (error) {
90
+ onStreamResponse({
91
+ error
92
+ });
93
+ throw error;
94
+ }
95
+ payload.addEvent(event);
96
+ cookieTransfer.cookiesToPayload(payload, edgeDomain);
97
+ return sendConversationServiceRequest({
98
+ requestId: uuid(),
99
+ url,
100
+ request,
101
+ onStreamResponse,
102
+ streamingEnabled
103
+ }).then(response => {
104
+ if (response.status === 204) {
105
+ return;
106
+ }
107
+ const onStreamResponseCallback = event => {
108
+ if (event.error) {
109
+ onStreamResponse({
110
+ error: event.error
111
+ });
112
+ return;
113
+ }
114
+ const substr = event.data.replace("data: ", "");
115
+ const responseJson = JSON.parse(substr);
116
+ const response = createResponse({
117
+ content: responseJson
118
+ });
119
+ cookieTransfer.responseToCookies(response);
120
+ logger.info("onStreamResponse callback called with", response.getPayloadsByType("brand-concierge:conversation"));
121
+ onStreamResponse(response.getPayloadsByType("brand-concierge:conversation"));
122
+ };
123
+ const streamParser = createStreamParser();
124
+ streamParser(response.body, onStreamResponseCallback);
125
+ });
126
+ });
127
+ };
128
+ };
@@ -0,0 +1,81 @@
1
+ /*
2
+ Copyright 2025 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 { stackError } from "../../utils/index.js";
13
+ export default ({
14
+ logger,
15
+ fetch
16
+ }) => {
17
+ return async ({
18
+ requestId,
19
+ url,
20
+ request,
21
+ streamingEnabled = true
22
+ }) => {
23
+ const payload = request.getPayload();
24
+ const stringifiedPayload = JSON.stringify(payload);
25
+ const parsedPayload = JSON.parse(stringifiedPayload);
26
+ const headers = {
27
+ "Content-Type": "text/plain"
28
+ };
29
+ if (streamingEnabled) {
30
+ headers.Accept = "text/event-stream";
31
+ } else {
32
+ headers.Accept = "text/plain";
33
+ }
34
+ logger.logOnBeforeNetworkRequest({
35
+ url,
36
+ requestId,
37
+ payload: parsedPayload
38
+ });
39
+ const fetchWithRetries = async (attemptNumber = 1) => {
40
+ const maxAttempts = 4;
41
+ const retryDelays = [2000, 3000, 5000];
42
+ try {
43
+ const response = await fetch(url, {
44
+ method: "POST",
45
+ headers: headers,
46
+ body: stringifiedPayload
47
+ });
48
+ if (!response.ok) {
49
+ throw new Error(`Request failed with status ${response.status}`);
50
+ }
51
+ return response;
52
+ } catch (error) {
53
+ if (attemptNumber < maxAttempts) {
54
+ const delay = retryDelays[attemptNumber - 1];
55
+ logger.logOnNetworkError({
56
+ requestId,
57
+ url,
58
+ payload: parsedPayload,
59
+ error: new Error(`Attempt ${attemptNumber} failed, retrying in ${delay}ms: ${error.message}`)
60
+ });
61
+ await new Promise(resolve => setTimeout(resolve, delay));
62
+ return fetchWithRetries(attemptNumber + 1);
63
+ }
64
+ logger.logOnNetworkError({
65
+ requestId,
66
+ url,
67
+ payload: parsedPayload,
68
+ error
69
+ });
70
+ throw stackError({
71
+ error,
72
+ message: "Network request failed after all retries."
73
+ });
74
+ }
75
+ };
76
+ const executeRequest = async () => {
77
+ return fetchWithRetries();
78
+ };
79
+ return executeRequest();
80
+ };
81
+ };