@adobe/alloy 2.34.2-beta.3 → 2.35.0

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 (40) hide show
  1. package/dist/alloy.js +287 -91
  2. package/dist/alloy.min.js +1 -1
  3. package/dist/alloyServiceWorker.js +85 -14
  4. package/dist/alloyServiceWorker.min.js +1 -1
  5. package/dist/types/browser/src/components/ActivityCollector/configValidators.d.ts +2 -2
  6. package/dist/types/browser/src/components/Advertising/configValidators.d.ts +1 -1
  7. package/dist/types/browser/src/components/Context/index.d.ts +1 -1
  8. package/dist/types/browser/src/components/Personalization/index.d.ts +1 -1
  9. package/dist/types/browser/src/components/PushNotifications/helpers/readFromIndexedDb.d.ts +2 -1
  10. package/dist/types/browser/src/components/PushNotifications/helpers/saveToIndexedDb.d.ts +3 -2
  11. package/dist/types/browser/src/components/PushNotifications/helpers/serviceWorkerPushListener.d.ts +3 -1
  12. package/dist/types/browser/src/components/PushNotifications/index.d.ts +1 -1
  13. package/dist/types/browser/src/components/PushNotifications/request/makeSendPushSubscriptionRequest.d.ts +5 -1
  14. package/dist/types/browser/src/components/PushNotifications/request/makeSendServiceWorkerTrackingData.d.ts +4 -2
  15. package/dist/types/browser/src/components/PushNotifications/types.d.ts +28 -0
  16. package/dist/types/core/src/components/BrandConcierge/configValidators.d.ts +1 -1
  17. package/dist/types/core/src/components/Consent/configValidators.d.ts +1 -1
  18. package/dist/types/core/src/components/Consent/validateSetConsentOptions.d.ts +1 -1
  19. package/dist/types/core/src/components/Identity/configValidators.d.ts +1 -1
  20. package/dist/types/core/src/components/RulesEngine/index.d.ts +1 -1
  21. package/dist/types/core/src/components/StreamingMedia/configValidators.d.ts +1 -1
  22. package/dist/types/core/src/core/config/createCoreConfigs.d.ts +1 -1
  23. package/dist/types/core/src/utils/bytes.d.ts +1 -1
  24. package/dist/types/core/src/utils/validateConfigOverride.d.ts +1 -1
  25. package/dist/types/core/src/utils/validateIdentityMap.d.ts +1 -1
  26. package/dist/types/core/src/utils/validation/index.d.ts +23 -11
  27. package/dist/types/core/src/utils/validation/types.d.ts +133 -0
  28. package/dist/types/core/src/utils/validation/utils.d.ts +4 -3
  29. package/package.json +2 -2
  30. package/src/components/Context/injectOneTimeAnalyticsReferrer.js +1 -1
  31. package/src/components/PushNotifications/helpers/getPushSubscriptionDetails.js +10 -8
  32. package/src/components/PushNotifications/helpers/readFromIndexedDb.js +3 -2
  33. package/src/components/PushNotifications/helpers/saveToIndexedDb.js +2 -1
  34. package/src/components/PushNotifications/helpers/serviceWorkerNotificationClickListener.js +0 -1
  35. package/src/components/PushNotifications/helpers/serviceWorkerPushListener.js +58 -2
  36. package/src/components/PushNotifications/index.js +7 -6
  37. package/src/components/PushNotifications/request/makeSendPushSubscriptionRequest.js +2 -1
  38. package/src/components/PushNotifications/request/makeSendServiceWorkerTrackingData.js +14 -6
  39. package/src/components/PushNotifications/types.js +15 -0
  40. package/src/createEventListeners.js +1 -1
package/dist/alloy.js CHANGED
@@ -104,7 +104,7 @@
104
104
  /**
105
105
  * Takes a base64 string of bytes and returns a Uint8Array.
106
106
  * @param {string} base64String
107
- * @returns {Uint8Array}
107
+ * @returns {Uint8Array<ArrayBuffer>}
108
108
  */
109
109
  const base64ToBytes = (base64String) => {
110
110
  // Add padding if needed
@@ -114,7 +114,7 @@
114
114
  const base64 = (base64String + padding).replace(/-/g, "+").replace(/_/g, "/");
115
115
 
116
116
  const binString = atob(base64);
117
- return Uint8Array.from(binString, (m) => m.codePointAt(0));
117
+ return Uint8Array.from(binString, (m) => m.codePointAt(0) ?? 0);
118
118
  };
119
119
 
120
120
  /**
@@ -2284,13 +2284,19 @@
2284
2284
  governing permissions and limitations under the License.
2285
2285
  */
2286
2286
 
2287
+ /** @import { ValidatorFn } from './types.js' */
2288
+
2287
2289
  /**
2288
2290
  * Wraps a validator returning the value if it is null or undefined, otherwise
2289
2291
  * it will call the original validator and return the result.
2290
2292
  *
2291
- * @param {function} validator - the validator to call if the value is not null
2293
+ * @param {ValidatorFn} validator - the validator to call if the value is not null
2294
+ * @returns {ValidatorFn}
2292
2295
  */
2293
2296
  const skipIfNull = (validator) =>
2297
+ /**
2298
+ * @this {any}
2299
+ */
2294
2300
  function skipIfNullValidator(value, path) {
2295
2301
  return value == null ? value : validator.call(this, value, path);
2296
2302
  };
@@ -2300,11 +2306,14 @@
2300
2306
  * validator with the result of the first validator. The result of the second validator
2301
2307
  * is returned.
2302
2308
  *
2303
- * @param {function} firstValidator - validator to call first
2304
- * @param {function} secondValidator - validator to call second
2305
- * @returns {function} - a new validator that calls the first and second validators
2309
+ * @param {ValidatorFn} firstValidator - validator to call first
2310
+ * @param {ValidatorFn} secondValidator - validator to call second
2311
+ * @returns {ValidatorFn} - a new validator that calls the first and second validators
2306
2312
  */
2307
2313
  const callSequentially = (firstValidator, secondValidator) =>
2314
+ /**
2315
+ * @this {any}
2316
+ */
2308
2317
  function callSequentiallyValidator(value, path) {
2309
2318
  return secondValidator.call(
2310
2319
  this,
@@ -2317,12 +2326,16 @@
2317
2326
  * Just like callSequentially, but if either validator throws an error, the errors
2318
2327
  * are collected and thrown at the end.
2319
2328
  *
2320
- * @param {function} firstValidator
2321
- * @param {function} secondValidator
2322
- * @returns {function}
2329
+ * @param {ValidatorFn} firstValidator
2330
+ * @param {ValidatorFn} secondValidator
2331
+ * @returns {ValidatorFn}
2323
2332
  */
2324
2333
  const callSequentiallyJoinErrors = (firstValidator, secondValidator) =>
2334
+ /**
2335
+ * @this {any}
2336
+ */
2325
2337
  function callSequentiallyJoinErrorsValidator(value, path) {
2338
+ /** @type {unknown[]} */
2326
2339
  const errors = [];
2327
2340
  const newValue = [firstValidator, secondValidator].reduce(
2328
2341
  (memo, validator) => {
@@ -2346,12 +2359,12 @@
2346
2359
  * sequence, this will also copy over methods from the base validator to the
2347
2360
  * resulting validator and include any additional methods.
2348
2361
  *
2349
- * @param {function} baseValidator - This validator will be called first, and its
2362
+ * @param {ValidatorFn} baseValidator - This validator will be called first, and its
2350
2363
  * methods will be copied over to the returned validator.
2351
- * @param {function} newValidator - This validator will be called second.
2352
- * @param {object} additionalMethods - Additional methods to include on the returned
2364
+ * @param {ValidatorFn} newValidator - This validator will be called second.
2365
+ * @param {object} [additionalMethods] - Additional methods to include on the returned
2353
2366
  * validator.
2354
- * @returns {function}
2367
+ * @returns {ValidatorFn}
2355
2368
  */
2356
2369
  const chain = (baseValidator, newValidator, additionalMethods) => {
2357
2370
  return Object.assign(
@@ -2367,14 +2380,14 @@
2367
2380
  * copy over methods from the base validator to the resulting validator and
2368
2381
  * include any additional methods.
2369
2382
  *
2370
- * @param {function} baseValidator - This validator will be called first, and its
2383
+ * @param {ValidatorFn} baseValidator - This validator will be called first, and its
2371
2384
  * methods will be copied over to the returned validator.
2372
- * @param {function} newValidator - This validator will be called second. If the value
2385
+ * @param {ValidatorFn} newValidator - This validator will be called second. If the value
2373
2386
  * is null after the first validator is called, this validator will not be
2374
2387
  * called.
2375
- * @param {object} additionalMethods - Additional methods to include on the returned
2388
+ * @param {object} [additionalMethods] - Additional methods to include on the returned
2376
2389
  * validator.
2377
- * @returns {function}
2390
+ * @returns {ValidatorFn}
2378
2391
  */
2379
2392
  const nullSafeChain = (
2380
2393
  baseValidator,
@@ -2391,13 +2404,13 @@
2391
2404
  /**
2392
2405
  * Same as nullSafeChain, but calls the new validator first.
2393
2406
  *
2394
- * @param {function} baseValidator - This validator will be called second, and its
2407
+ * @param {ValidatorFn} baseValidator - This validator will be called second, and its
2395
2408
  * methods will be copied over to the returned validator.
2396
- * @param {function} newValidator - This validator will be called first. If the value
2409
+ * @param {ValidatorFn} newValidator - This validator will be called first. If the value
2397
2410
  * is null, this validator will not be called.
2398
- * @param {function} additionalMethods - Additional methods to include on the returned
2411
+ * @param {object} [additionalMethods] - Additional methods to include on the returned
2399
2412
  * validator.
2400
- * @returns {function}
2413
+ * @returns {ValidatorFn}
2401
2414
  */
2402
2415
  const reverseNullSafeChainJoinErrors = (
2403
2416
  baseValidator,
@@ -3047,135 +3060,310 @@
3047
3060
 
3048
3061
 
3049
3062
  // The base validator does no validation and just returns the value unchanged
3050
- const base = (value) => value;
3063
+ const base = /** @type {AnyValidator} */ ((value) => value);
3051
3064
 
3052
3065
  // The 'default', 'required', and 'deprecated' methods are available after any
3053
3066
  // data-type method. Don't use the nullSafeChain on 'default' or 'required'
3054
3067
  // because they need to handle the null or undefined case
3068
+ /**
3069
+ * @this {AnyValidator}
3070
+ * @param {any} defaultValue
3071
+ * @returns {AnyValidator}
3072
+ */
3055
3073
  base.default = function _default(defaultValue) {
3056
- return chain(this, createDefaultValidator(defaultValue));
3074
+ return /** @type {AnyValidator} */ (
3075
+ chain(this, createDefaultValidator(defaultValue))
3076
+ );
3057
3077
  };
3078
+ /**
3079
+ * @this {AnyValidator}
3080
+ * @returns {AnyValidator}
3081
+ */
3058
3082
  base.required = function required() {
3059
- return chain(this, requiredValidator);
3083
+ return /** @type {AnyValidator} */ (chain(this, requiredValidator));
3060
3084
  };
3085
+ /**
3086
+ * @this {AnyValidator}
3087
+ * @param {string} message
3088
+ * @returns {AnyValidator}
3089
+ */
3061
3090
  base.deprecated = function deprecated(message) {
3062
- return chain(this, createDeprecatedValidator(message));
3091
+ return /** @type {AnyValidator} */ (
3092
+ chain(this, createDeprecatedValidator(message))
3093
+ );
3063
3094
  };
3064
3095
 
3065
3096
  // helper validators
3097
+ /**
3098
+ * @this {StringValidator}
3099
+ * @returns {StringValidator}
3100
+ */
3066
3101
  const domain = function domain() {
3067
- return nullSafeChain(this, domainValidator);
3102
+ return /** @type {StringValidator} */ (nullSafeChain(this, domainValidator));
3068
3103
  };
3104
+ /**
3105
+ * @this {NumberValidator}
3106
+ * @param {number} minValue
3107
+ * @returns {NumberValidator}
3108
+ */
3069
3109
  const minimumInteger = function minimumInteger(minValue) {
3070
- return nullSafeChain(this, createMinimumValidator("an integer", minValue));
3110
+ return /** @type {NumberValidator} */ (
3111
+ nullSafeChain(this, createMinimumValidator("an integer", minValue))
3112
+ );
3071
3113
  };
3114
+ /**
3115
+ * @this {NumberValidator}
3116
+ * @param {number} minValue
3117
+ * @returns {NumberValidator}
3118
+ */
3072
3119
  const minimumNumber = function minimumNumber(minValue) {
3073
- return nullSafeChain(this, createMinimumValidator("a number", minValue));
3120
+ return /** @type {NumberValidator} */ (
3121
+ nullSafeChain(this, createMinimumValidator("a number", minValue))
3122
+ );
3074
3123
  };
3124
+ /**
3125
+ * @this {NumberValidator}
3126
+ * @param {number} maxValue
3127
+ * @returns {NumberValidator}
3128
+ */
3075
3129
  const maximumNumber = function maximumNumber(maxValue) {
3076
- return nullSafeChain(this, createMaximumValidator("a number", maxValue));
3130
+ return /** @type {NumberValidator} */ (
3131
+ nullSafeChain(this, createMaximumValidator("a number", maxValue))
3132
+ );
3077
3133
  };
3134
+ /**
3135
+ * @this {NumberValidator}
3136
+ * @returns {NumberValidator}
3137
+ */
3078
3138
  const integer = function integer() {
3079
- return nullSafeChain(this, integerValidator, { minimum: minimumInteger });
3139
+ return /** @type {NumberValidator} */ (
3140
+ nullSafeChain(this, integerValidator, { minimum: minimumInteger })
3141
+ );
3080
3142
  };
3143
+ /**
3144
+ * @this {StringValidator}
3145
+ * @returns {StringValidator}
3146
+ */
3081
3147
  const nonEmptyString = function nonEmptyString() {
3082
- return nullSafeChain(this, createNonEmptyValidator("a non-empty string"));
3148
+ return /** @type {StringValidator} */ (
3149
+ nullSafeChain(this, createNonEmptyValidator("a non-empty string"))
3150
+ );
3083
3151
  };
3152
+ /**
3153
+ * @this {ArrayValidator}
3154
+ * @returns {ArrayValidator}
3155
+ */
3084
3156
  const nonEmptyArray = function nonEmptyArray() {
3085
- return nullSafeChain(this, createNonEmptyValidator("a non-empty array"));
3157
+ return /** @type {ArrayValidator} */ (
3158
+ nullSafeChain(this, createNonEmptyValidator("a non-empty array"))
3159
+ );
3086
3160
  };
3161
+ /**
3162
+ * @this {MapOfValuesValidator | ObjectValidator}
3163
+ * @returns {MapOfValuesValidator & ObjectValidator}
3164
+ */
3087
3165
  const nonEmptyObject = function nonEmptyObject() {
3088
- return nullSafeChain(this, createNonEmptyValidator("a non-empty object"));
3166
+ return /** @type {MapOfValuesValidator & ObjectValidator} */ (
3167
+ nullSafeChain(this, createNonEmptyValidator("a non-empty object"))
3168
+ );
3089
3169
  };
3170
+ /**
3171
+ * @this {StringValidator}
3172
+ * @returns {StringValidator}
3173
+ */
3090
3174
  const regexp = function regexp() {
3091
- return nullSafeChain(this, regexpValidator);
3175
+ return /** @type {StringValidator} */ (nullSafeChain(this, regexpValidator));
3092
3176
  };
3177
+ /**
3178
+ * @this {StringValidator}
3179
+ * @param {RegExp} regexpPattern
3180
+ * @returns {StringValidator}
3181
+ */
3093
3182
  const matches = function matches(regexpPattern) {
3094
- return nullSafeChain(this, matchesRegexpValidator(regexpPattern));
3183
+ return /** @type {StringValidator} */ (
3184
+ nullSafeChain(this, matchesRegexpValidator(regexpPattern))
3185
+ );
3095
3186
  };
3187
+ /**
3188
+ * @this {NumberValidator | StringValidator}
3189
+ * @returns {NumberValidator & StringValidator}
3190
+ */
3096
3191
  const unique = function createUnique() {
3097
- return nullSafeChain(this, createUniqueValidator());
3192
+ return /** @type {NumberValidator & StringValidator} */ (
3193
+ nullSafeChain(this, createUniqueValidator())
3194
+ );
3098
3195
  };
3196
+ /**
3197
+ * @this {ArrayValidator}
3198
+ * @returns {ArrayValidator}
3199
+ */
3099
3200
  const uniqueItems = function createUniqueItems() {
3100
- return nullSafeChain(this, createUniqueItemsValidator());
3201
+ return /** @type {ArrayValidator} */ (
3202
+ nullSafeChain(this, createUniqueItemsValidator())
3203
+ );
3101
3204
  };
3102
3205
 
3103
3206
  // top-level validators. These are the first functions that are called to create a validator.
3207
+ /**
3208
+ * @this {AnyValidator}
3209
+ * @param {ValidatorFn[]} validators
3210
+ * @param {string} [message]
3211
+ * @returns {AnyValidator}
3212
+ */
3104
3213
  const anyOf = function anyOf(validators, message) {
3105
3214
  // use chain here because we don't want to accept null or undefined unless at least
3106
3215
  // one of the validators accept null or undefined.
3107
- return chain(this, createAnyOfValidator(validators, message));
3216
+ return /** @type {AnyValidator} */ (
3217
+ chain(this, createAnyOfValidator(validators, message))
3218
+ );
3108
3219
  };
3220
+ /**
3221
+ * @this {AnyValidator}
3222
+ * @returns {AnyValidator}
3223
+ */
3109
3224
  const anything = function anything() {
3110
3225
  return this;
3111
3226
  };
3227
+ /**
3228
+ * @this {AnyValidator}
3229
+ * @param {ValidatorFn} elementValidator
3230
+ * @returns {ArrayValidator}
3231
+ */
3112
3232
  const arrayOf = function arrayOf(elementValidator) {
3113
- return nullSafeChain(this, createArrayOfValidator(elementValidator), {
3114
- nonEmpty: nonEmptyArray,
3115
- uniqueItems,
3116
- });
3233
+ return /** @type {ArrayValidator} */ (
3234
+ nullSafeChain(this, createArrayOfValidator(elementValidator), {
3235
+ nonEmpty: nonEmptyArray,
3236
+ uniqueItems,
3237
+ })
3238
+ );
3117
3239
  };
3240
+ /**
3241
+ * @this {AnyValidator}
3242
+ * @returns {AnyValidator}
3243
+ */
3118
3244
  const boolean = function boolean() {
3119
- return nullSafeChain(this, booleanValidator);
3245
+ return /** @type {AnyValidator} */ (nullSafeChain(this, booleanValidator));
3120
3246
  };
3247
+ /**
3248
+ * @this {AnyValidator}
3249
+ * @returns {AnyValidator}
3250
+ */
3121
3251
  const callback = function callback() {
3122
- return nullSafeChain(this, callbackValidator);
3252
+ return /** @type {AnyValidator} */ (nullSafeChain(this, callbackValidator));
3123
3253
  };
3254
+ /**
3255
+ * @this {AnyValidator}
3256
+ * @param {any} literalValue
3257
+ * @returns {AnyValidator}
3258
+ */
3124
3259
  const literal = function literal(literalValue) {
3125
- return nullSafeChain(this, createLiteralValidator(literalValue));
3260
+ return /** @type {AnyValidator} */ (
3261
+ nullSafeChain(this, createLiteralValidator(literalValue))
3262
+ );
3126
3263
  };
3264
+ /**
3265
+ * @this {AnyValidator}
3266
+ * @returns {NumberValidator}
3267
+ */
3127
3268
  const number = function number() {
3128
- return nullSafeChain(this, numberValidator, {
3129
- minimum: minimumNumber,
3130
- maximum: maximumNumber,
3131
- integer,
3132
- unique,
3133
- });
3269
+ return /** @type {NumberValidator} */ (
3270
+ nullSafeChain(this, numberValidator, {
3271
+ minimum: minimumNumber,
3272
+ maximum: maximumNumber,
3273
+ integer,
3274
+ unique,
3275
+ })
3276
+ );
3134
3277
  };
3278
+ /**
3279
+ * @this {AnyValidator}
3280
+ * @param {ValidatorFn} valuesValidator
3281
+ * @returns {MapOfValuesValidator}
3282
+ */
3135
3283
  const mapOfValues = function mapOfValues(valuesValidator) {
3136
- return nullSafeChain(this, createMapOfValuesValidator(valuesValidator), {
3137
- nonEmpty: nonEmptyObject,
3138
- });
3284
+ return /** @type {MapOfValuesValidator} */ (
3285
+ nullSafeChain(this, createMapOfValuesValidator(valuesValidator), {
3286
+ nonEmpty: nonEmptyObject,
3287
+ })
3288
+ );
3139
3289
  };
3290
+ /**
3291
+ * @param {ObjectValidatorSchema} schema
3292
+ */
3140
3293
  const createObjectOfAdditionalProperties = (schema) => ({
3294
+ /**
3295
+ * @this {ObjectValidator}
3296
+ * @returns {ObjectValidator}
3297
+ */
3141
3298
  noUnknownFields: function noUnknownFields() {
3142
- return nullSafeChain(this, createNoUnknownFieldsValidator(schema));
3299
+ return /** @type {ObjectValidator} */ (
3300
+ nullSafeChain(this, createNoUnknownFieldsValidator(schema))
3301
+ );
3143
3302
  },
3144
3303
  nonEmpty: nonEmptyObject,
3304
+ /**
3305
+ * @this {ObjectValidator}
3306
+ * @param {ObjectValidator} otherObjectOfValidator
3307
+ * @returns {ObjectValidator}
3308
+ */
3145
3309
  concat: function concat(otherObjectOfValidator) {
3146
3310
  // combine the schema so that noUnknownFields, and concat have the combined schema
3147
3311
  const newSchema = { ...schema, ...otherObjectOfValidator.schema };
3148
- return nullSafeChain(
3149
- this,
3150
- otherObjectOfValidator,
3151
- createObjectOfAdditionalProperties(newSchema),
3312
+ return /** @type {ObjectValidator} */ (
3313
+ nullSafeChain(
3314
+ this,
3315
+ otherObjectOfValidator,
3316
+ createObjectOfAdditionalProperties(newSchema),
3317
+ )
3152
3318
  );
3153
3319
  },
3320
+ /**
3321
+ * @this {ObjectValidator}
3322
+ * @param {string} oldField
3323
+ * @param {ValidatorFn} oldSchema
3324
+ * @param {string} newField
3325
+ * @returns {ObjectValidator}
3326
+ */
3154
3327
  renamed: function renamed(oldField, oldSchema, newField) {
3155
3328
  // Run the deprecated validator first so that the deprecated field is removed
3156
3329
  // before the objectOf validator runs.
3157
- return reverseNullSafeChainJoinErrors(
3158
- this,
3159
- createRenamedValidator(oldField, oldSchema, newField),
3330
+ return /** @type {ObjectValidator} */ (
3331
+ reverseNullSafeChainJoinErrors(
3332
+ this,
3333
+ createRenamedValidator(oldField, oldSchema, newField),
3334
+ )
3160
3335
  );
3161
3336
  },
3162
3337
  schema,
3163
3338
  });
3339
+ /**
3340
+ * @this {AnyValidator}
3341
+ * @param {ObjectValidatorSchema} schema
3342
+ * @returns {ObjectValidator}
3343
+ */
3164
3344
  const objectOf = function objectOf(schema) {
3165
- return nullSafeChain(
3166
- this,
3167
- createObjectOfValidator(schema),
3168
- createObjectOfAdditionalProperties(schema),
3345
+ return /** @type {ObjectValidator} */ (
3346
+ nullSafeChain(
3347
+ this,
3348
+ createObjectOfValidator(schema),
3349
+ createObjectOfAdditionalProperties(schema),
3350
+ )
3169
3351
  );
3170
3352
  };
3353
+ /**
3354
+ * @this {AnyValidator}
3355
+ * @returns {StringValidator}
3356
+ */
3171
3357
  const string = function string() {
3172
- return nullSafeChain(this, stringValidator, {
3173
- regexp,
3174
- domain,
3175
- nonEmpty: nonEmptyString,
3176
- unique,
3177
- matches,
3178
- });
3358
+ return /** @type {StringValidator} */ (
3359
+ nullSafeChain(this, stringValidator, {
3360
+ regexp,
3361
+ domain,
3362
+ nonEmpty: nonEmptyString,
3363
+ unique,
3364
+ matches,
3365
+ })
3366
+ );
3179
3367
  };
3180
3368
 
3181
3369
  const boundAnyOf = anyOf.bind(base);
@@ -3190,6 +3378,10 @@
3190
3378
  const boundString = string.bind(base);
3191
3379
 
3192
3380
  // compound validators
3381
+ /**
3382
+ * @param {...any} values
3383
+ * @returns {AnyValidator}
3384
+ */
3193
3385
  const boundEnumOf = function boundEnumOf(...values) {
3194
3386
  return boundAnyOf(
3195
3387
  values.map(boundLiteral),
@@ -7554,10 +7746,10 @@
7554
7746
  governing permissions and limitations under the License.
7555
7747
  */
7556
7748
 
7557
- // The 2.34.2-beta.3 keyword will be replace at alloy build time with the package.json version.
7749
+ // The 2.35.0 keyword will be replace at alloy build time with the package.json version.
7558
7750
  // see babel-plugin-version
7559
7751
 
7560
- var libraryVersion = "2.34.2-beta.3";
7752
+ var libraryVersion = "2.35.0";
7561
7753
 
7562
7754
  /*
7563
7755
  Copyright 2019 Adobe. All rights reserved.
@@ -20502,8 +20694,7 @@
20502
20694
  throw new Error("Push notifications are not supported in this browser.");
20503
20695
  }
20504
20696
 
20505
- /** @type {object} */
20506
- const notification = window.Notification;
20697
+ const notification = /** @type {typeof Notification} */ (window.Notification);
20507
20698
  if (notification.permission !== "granted") {
20508
20699
  throw new Error(
20509
20700
  "The user has not given permission to send push notifications.",
@@ -20548,15 +20739,18 @@
20548
20739
  subscriptionOptions,
20549
20740
  );
20550
20741
 
20742
+ const p256dhKey = subscription.getKey("p256dh");
20743
+ const authKey = subscription.getKey("auth");
20744
+
20551
20745
  return {
20552
20746
  endpoint: subscription.endpoint,
20553
20747
  keys: {
20554
- p256dh: bytesToBase64(new Uint8Array(subscription.getKey("p256dh")), {
20555
- urlSafe: true,
20556
- }),
20557
- auth: bytesToBase64(new Uint8Array(subscription.getKey("auth")), {
20558
- urlSafe: true,
20559
- }),
20748
+ p256dh: p256dhKey
20749
+ ? bytesToBase64(new Uint8Array(p256dhKey), { urlSafe: true })
20750
+ : null,
20751
+ auth: authKey
20752
+ ? bytesToBase64(new Uint8Array(authKey), { urlSafe: true })
20753
+ : null,
20560
20754
  },
20561
20755
  };
20562
20756
  } catch (e) {
@@ -20774,7 +20968,7 @@
20774
20968
 
20775
20969
 
20776
20970
  /**
20777
- * @param {Object} data
20971
+ * @param {Partial<PushServiceWorkerConfig>} data
20778
20972
  * @param {Logger} logger
20779
20973
  *
20780
20974
  * @returns {Promise<boolean>} Whether the data was successfully saved.
@@ -20853,6 +21047,7 @@
20853
21047
  * @param {EdgeRequestExecutor} options.sendEdgeNetworkRequest
20854
21048
  * @param {ConsentManager} options.consent
20855
21049
  * @param {Window} options.window
21050
+ * @param {typeof getPushSubscriptionDetailsDefault} [options.getPushSubscriptionDetails]
20856
21051
  *
20857
21052
  * @returns {Promise<void>}
20858
21053
  */
@@ -20936,6 +21131,10 @@
20936
21131
  */
20937
21132
 
20938
21133
 
21134
+ /**
21135
+ * @param {{ orgId?: string, pushNotifications?: { vapidPublicKey?: string, appId?: string, trackingDatasetId?: string } }} config
21136
+ * @returns {boolean}
21137
+ */
20939
21138
  const isComponentConfigured = ({
20940
21139
  orgId,
20941
21140
  pushNotifications: { vapidPublicKey, appId, trackingDatasetId } = {
@@ -20943,7 +21142,7 @@
20943
21142
  appId: undefined,
20944
21143
  trackingDatasetId: undefined,
20945
21144
  },
20946
- }) => orgId && vapidPublicKey && appId && trackingDatasetId;
21145
+ }) => Boolean(orgId && vapidPublicKey && appId && trackingDatasetId);
20947
21146
 
20948
21147
  /**
20949
21148
  * @function
@@ -21001,11 +21200,8 @@
21001
21200
 
21002
21201
  const {
21003
21202
  orgId,
21004
- pushNotifications: { vapidPublicKey, appId } = {
21005
- vapidPublicKey: undefined,
21006
- appId: undefined,
21007
- },
21008
- } = config || {};
21203
+ pushNotifications: { vapidPublicKey, appId },
21204
+ } = config;
21009
21205
 
21010
21206
  const storage = platformServices.storage.createNamespacedStorage(
21011
21207
  `${sanitizeOrgIdForCookieName(orgId)}.pushNotifications.`,
@@ -21425,7 +21621,7 @@
21425
21621
 
21426
21622
  // Allow customers to explicitly set the referrer (for SPA view changes)
21427
21623
  // Otherwise, use document.referrer
21428
- // eslint-disable-next-line no-underscore-dangle
21624
+
21429
21625
  const explicitReferrer = content.data?.__adobe?.analytics?.referrer;
21430
21626
  const currentReferrer =
21431
21627
  explicitReferrer !== undefined