@adobe/alloy 2.29.0-beta.13 → 2.29.0-beta.15

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.
@@ -7,6 +7,7 @@ var _collectRampId = require("../identities/collectRampId.js");
7
7
  var _helpers = require("../utils/helpers.js");
8
8
  var _index = require("../constants/index.js");
9
9
  var _consentStatus = require("../../../constants/consentStatus.js");
10
+ var _browser = require("../../../constants/browser.js");
10
11
  /*
11
12
  Copyright 2023 Adobe. All rights reserved.
12
13
  Licensed under the Apache License, Version 2.0.
@@ -14,10 +15,10 @@ http://www.apache.org/licenses/LICENSE-2.0
14
15
  */
15
16
 
16
17
  const isAdvertisingDisabled = advertising => {
17
- return ![_consentStatus.AUTO, _consentStatus.WAIT].includes(advertising?.handleAdvertisingData);
18
+ return ![_consentStatus.AUTO, _consentStatus.WAIT].includes(advertising?.handleAdvertisingData?.toLowerCase());
18
19
  };
19
20
  const waitForAdvertisingId = advertising => {
20
- return advertising?.handleAdvertisingData === _consentStatus.WAIT;
21
+ return advertising?.handleAdvertisingData?.toLowerCase() === _consentStatus.WAIT;
21
22
  };
22
23
 
23
24
  /**
@@ -47,7 +48,11 @@ async function handleOnBeforeSendEvent({
47
48
  if (isAdvertisingDisabled(advertising) || isClickThru || (0, _helpers.isThrottled)(_index.SURFER_ID, cookieManager) && (0, _helpers.isThrottled)(_index.ID5_ID, cookieManager) && (0, _helpers.isThrottled)(_index.RAMP_ID, cookieManager)) return;
48
49
  try {
49
50
  const useShortTimeout = waitForAdvertisingId(advertising);
50
- const [surferIdResult, id5IdResult, rampIdResult] = await Promise.allSettled([(0, _collectSurferId.default)(cookieManager, getBrowser, useShortTimeout), (0, _collectID5Id.getID5Id)(logger, componentConfig.id5PartnerId, useShortTimeout, useShortTimeout), (0, _collectRampId.getRampId)(logger, componentConfig.rampIdJSPath, cookieManager, useShortTimeout, useShortTimeout)]);
51
+ let rampIdPromise = null;
52
+ if (!getBrowser || getBrowser() !== _browser.CHROME) {
53
+ rampIdPromise = (0, _collectRampId.getRampId)(logger, componentConfig.rampIdJSPath, cookieManager, useShortTimeout, useShortTimeout);
54
+ }
55
+ const [surferIdResult, id5IdResult, rampIdResult] = await Promise.allSettled([(0, _collectSurferId.default)(cookieManager, getBrowser, useShortTimeout), (0, _collectID5Id.getID5Id)(logger, componentConfig.id5PartnerId, useShortTimeout, useShortTimeout), rampIdPromise]);
51
56
  const availableIds = {};
52
57
  if (surferIdResult.status === "fulfilled" && surferIdResult.value && !(0, _helpers.isThrottled)(_index.SURFER_ID, cookieManager)) {
53
58
  availableIds.surferId = surferIdResult.value;
@@ -17,7 +17,7 @@ governing permissions and limitations under the License.
17
17
 
18
18
  let id5Id = "";
19
19
  let inProgressId5Promise = null;
20
- const SHORT_TIMEOUT_MS = 5000;
20
+ const SHORT_TIMEOUT_MS = 2000;
21
21
  const DEFAULT_TIMEOUT_MS = 30000;
22
22
  const initiateID5Call = (partnerId, useShortTimeout, logger) => {
23
23
  partnerId = Math.floor(Number(partnerId));
@@ -20,7 +20,7 @@ const RETRY_CONFIG = {
20
20
  MAX_TIME_MS: 30000,
21
21
  DELAY_BASE_MS: 500,
22
22
  MAX_DELAY_MS: 5000,
23
- SHORT_TIMEOUT_MS: 5000
23
+ SHORT_TIMEOUT_MS: 2000
24
24
  };
25
25
  const state = {
26
26
  rampIdEnv: undefined,
@@ -90,8 +90,12 @@ const getPushSubscriptionDetails = async ({
90
90
  return {
91
91
  endpoint: subscription.endpoint,
92
92
  keys: {
93
- p256dh: (0, _index.bytesToBase64)(new Uint8Array(subscription.getKey("p256dh"))),
94
- auth: (0, _index.bytesToBase64)(new Uint8Array(subscription.getKey("auth")))
93
+ p256dh: (0, _index.bytesToBase64)(new Uint8Array(subscription.getKey("p256dh")), {
94
+ urlSafe: true
95
+ }),
96
+ auth: (0, _index.bytesToBase64)(new Uint8Array(subscription.getKey("auth")), {
97
+ urlSafe: true
98
+ })
95
99
  }
96
100
  };
97
101
  } catch (e) {
@@ -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.29.0-beta.13";
17
+ var _default = exports.default = "2.29.0-beta.15";
@@ -31,8 +31,19 @@ const base64ToBytes = base64String => {
31
31
  /**
32
32
  * Takes a Uint8Array and returns a base64 string.
33
33
  * @param {Uint8Array} bytes
34
+ * @param {Object} [options={}] - Options for encoding
35
+ * @param {boolean} [options.urlSafe=false] - Whether to return URL-safe base64 (no padding, + becomes -, / becomes _)
34
36
  * @returns {string}
35
37
  */
36
38
  exports.base64ToBytes = base64ToBytes;
37
- const bytesToBase64 = bytes => btoa(String.fromCharCode(...bytes));
39
+ const bytesToBase64 = (bytes, options = {}) => {
40
+ const {
41
+ urlSafe = false
42
+ } = options || {};
43
+ const base64 = btoa(String.fromCharCode(...bytes));
44
+ if (urlSafe) {
45
+ return base64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
46
+ }
47
+ return base64;
48
+ };
38
49
  exports.bytesToBase64 = bytesToBase64;
@@ -10,11 +10,12 @@ import { getRampId } from "../identities/collectRampId.js";
10
10
  import { appendAdvertisingIdQueryToEvent, getUrlParams, isThrottled } from "../utils/helpers.js";
11
11
  import { SURFER_ID, ID5_ID, RAMP_ID } from "../constants/index.js";
12
12
  import { AUTO, WAIT } from "../../../constants/consentStatus.js";
13
+ import { CHROME } from "../../../constants/browser.js";
13
14
  const isAdvertisingDisabled = advertising => {
14
- return ![AUTO, WAIT].includes(advertising?.handleAdvertisingData);
15
+ return ![AUTO, WAIT].includes(advertising?.handleAdvertisingData?.toLowerCase());
15
16
  };
16
17
  const waitForAdvertisingId = advertising => {
17
- return advertising?.handleAdvertisingData === WAIT;
18
+ return advertising?.handleAdvertisingData?.toLowerCase() === WAIT;
18
19
  };
19
20
 
20
21
  /**
@@ -44,7 +45,11 @@ export default async function handleOnBeforeSendEvent({
44
45
  if (isAdvertisingDisabled(advertising) || isClickThru || isThrottled(SURFER_ID, cookieManager) && isThrottled(ID5_ID, cookieManager) && isThrottled(RAMP_ID, cookieManager)) return;
45
46
  try {
46
47
  const useShortTimeout = waitForAdvertisingId(advertising);
47
- const [surferIdResult, id5IdResult, rampIdResult] = await Promise.allSettled([collectSurferId(cookieManager, getBrowser, useShortTimeout), getID5Id(logger, componentConfig.id5PartnerId, useShortTimeout, useShortTimeout), getRampId(logger, componentConfig.rampIdJSPath, cookieManager, useShortTimeout, useShortTimeout)]);
48
+ let rampIdPromise = null;
49
+ if (!getBrowser || getBrowser() !== CHROME) {
50
+ rampIdPromise = getRampId(logger, componentConfig.rampIdJSPath, cookieManager, useShortTimeout, useShortTimeout);
51
+ }
52
+ const [surferIdResult, id5IdResult, rampIdResult] = await Promise.allSettled([collectSurferId(cookieManager, getBrowser, useShortTimeout), getID5Id(logger, componentConfig.id5PartnerId, useShortTimeout, useShortTimeout), rampIdPromise]);
48
53
  const availableIds = {};
49
54
  if (surferIdResult.status === "fulfilled" && surferIdResult.value && !isThrottled(SURFER_ID, cookieManager)) {
50
55
  availableIds.surferId = surferIdResult.value;
@@ -13,7 +13,7 @@ import { loadScript } from "../../../utils/dom/index.js";
13
13
  import { ID5_SCRIPT_URL } from "../constants/index.js";
14
14
  let id5Id = "";
15
15
  let inProgressId5Promise = null;
16
- const SHORT_TIMEOUT_MS = 5000;
16
+ const SHORT_TIMEOUT_MS = 2000;
17
17
  const DEFAULT_TIMEOUT_MS = 30000;
18
18
  const initiateID5Call = (partnerId, useShortTimeout, logger) => {
19
19
  partnerId = Math.floor(Number(partnerId));
@@ -17,7 +17,7 @@ const RETRY_CONFIG = {
17
17
  MAX_TIME_MS: 30000,
18
18
  DELAY_BASE_MS: 500,
19
19
  MAX_DELAY_MS: 5000,
20
- SHORT_TIMEOUT_MS: 5000
20
+ SHORT_TIMEOUT_MS: 2000
21
21
  };
22
22
  const state = {
23
23
  rampIdEnv: undefined,
@@ -88,8 +88,12 @@ const getPushSubscriptionDetails = async ({
88
88
  return {
89
89
  endpoint: subscription.endpoint,
90
90
  keys: {
91
- p256dh: bytesToBase64(new Uint8Array(subscription.getKey("p256dh"))),
92
- auth: bytesToBase64(new Uint8Array(subscription.getKey("auth")))
91
+ p256dh: bytesToBase64(new Uint8Array(subscription.getKey("p256dh")), {
92
+ urlSafe: true
93
+ }),
94
+ auth: bytesToBase64(new Uint8Array(subscription.getKey("auth")), {
95
+ urlSafe: true
96
+ })
93
97
  }
94
98
  };
95
99
  } catch (e) {
@@ -13,4 +13,4 @@ governing permissions and limitations under the License.
13
13
  // The __VERSION__ keyword will be replace at alloy build time with the package.json version.
14
14
  // see babel-plugin-version
15
15
 
16
- export default "2.29.0-beta.13";
16
+ export default "2.29.0-beta.15";
@@ -28,6 +28,17 @@ export const base64ToBytes = base64String => {
28
28
  /**
29
29
  * Takes a Uint8Array and returns a base64 string.
30
30
  * @param {Uint8Array} bytes
31
+ * @param {Object} [options={}] - Options for encoding
32
+ * @param {boolean} [options.urlSafe=false] - Whether to return URL-safe base64 (no padding, + becomes -, / becomes _)
31
33
  * @returns {string}
32
34
  */
33
- export const bytesToBase64 = bytes => btoa(String.fromCharCode(...bytes));
35
+ export const bytesToBase64 = (bytes, options = {}) => {
36
+ const {
37
+ urlSafe = false
38
+ } = options || {};
39
+ const base64 = btoa(String.fromCharCode(...bytes));
40
+ if (urlSafe) {
41
+ return base64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
42
+ }
43
+ return base64;
44
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/alloy",
3
- "version": "2.29.0-beta.13",
3
+ "version": "2.29.0-beta.15",
4
4
  "description": "Adobe Experience Platform Web SDK",
5
5
  "type": "module",
6
6
  "main": "libEs5/index.js",
@@ -94,7 +94,7 @@
94
94
  "uuid": "^11.1.0"
95
95
  },
96
96
  "devDependencies": {
97
- "@adobe/alloy": "^2.29.0-beta.5",
97
+ "@adobe/alloy": "^2.29.0-beta.14",
98
98
  "@babel/cli": "^7.28.3",
99
99
  "@babel/plugin-transform-modules-commonjs": "^7.27.1",
100
100
  "@babel/plugin-transform-runtime": "^7.28.3",
@@ -1 +1 @@
1
- {"version":3,"file":"onBeforeSendEventHandler.d.ts","sourceRoot":"","sources":["../../../../src/components/Advertising/handlers/onBeforeSendEventHandler.js"],"names":[],"mappings":"AAyBA;;;;;;;;;;GAUG;AACH,6HARG;IAAuB,aAAa;IACb,MAAM;IACN,KAAK;IACL,KAAK;IACL,eAAe;IACf,WAAW;IACT,UAAU;CACrC,iBAiFA"}
1
+ {"version":3,"file":"onBeforeSendEventHandler.d.ts","sourceRoot":"","sources":["../../../../src/components/Advertising/handlers/onBeforeSendEventHandler.js"],"names":[],"mappings":"AA4BA;;;;;;;;;;GAUG;AACH,6HARG;IAAuB,aAAa;IACb,MAAM;IACN,KAAK;IACL,KAAK;IACL,eAAe;IACf,WAAW;IACT,UAAU;CACrC,iBAsFA"}
@@ -1 +1 @@
1
- {"version":3,"file":"getPushSubscriptionDetails.d.ts","sourceRoot":"","sources":["../../../../src/components/PushNotifications/helpers/getPushSubscriptionDetails.js"],"names":[],"mappings":";AAgBA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wEAhBG;IAAwB,cAAc,EAA9B,MAAM;IACU,MAAM,EAAtB,MAAM;CAEd,GAAU,OAAO,CAAC,gBAAgB,CAAC,CAyFrC;sCAvGqC,aAAa"}
1
+ {"version":3,"file":"getPushSubscriptionDetails.d.ts","sourceRoot":"","sources":["../../../../src/components/PushNotifications/helpers/getPushSubscriptionDetails.js"],"names":[],"mappings":";AAgBA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wEAhBG;IAAwB,cAAc,EAA9B,MAAM;IACU,MAAM,EAAtB,MAAM;CAEd,GAAU,OAAO,CAAC,gBAAgB,CAAC,CA6FrC;sCA3GqC,aAAa"}
@@ -1,3 +1,5 @@
1
1
  export function base64ToBytes(base64String: string): Uint8Array;
2
- export function bytesToBase64(bytes: Uint8Array): string;
2
+ export function bytesToBase64(bytes: Uint8Array, options?: {
3
+ urlSafe?: boolean;
4
+ }): string;
3
5
  //# sourceMappingURL=bytes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bytes.d.ts","sourceRoot":"","sources":["../../src/utils/bytes.js"],"names":[],"mappings":"AAiBO,4CAHI,MAAM,GACJ,UAAU,CAWtB;AAOM,qCAHI,UAAU,GACR,MAAM,CAEwD"}
1
+ {"version":3,"file":"bytes.d.ts","sourceRoot":"","sources":["../../src/utils/bytes.js"],"names":[],"mappings":"AAiBO,4CAHI,MAAM,GACJ,UAAU,CAWtB;AASM,qCALI,UAAU,YAElB;IAA0B,OAAO,GAAzB,OAAO;CACf,GAAU,MAAM,CAWlB"}