@adobe/alloy 2.34.2-beta.2 → 2.35.0-beta.4
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.
- package/dist/alloy.js +312 -96
- package/dist/alloy.min.js +1 -1
- package/dist/alloyServiceWorker.js +85 -12
- package/dist/alloyServiceWorker.min.js +1 -1
- package/dist/types/browser/src/components/ActivityCollector/configValidators.d.ts +2 -2
- package/dist/types/browser/src/components/Advertising/configValidators.d.ts +1 -1
- package/dist/types/browser/src/components/Context/index.d.ts +1 -1
- package/dist/types/browser/src/components/Personalization/index.d.ts +1 -1
- package/dist/types/browser/src/components/PushNotifications/helpers/readFromIndexedDb.d.ts +2 -1
- package/dist/types/browser/src/components/PushNotifications/helpers/saveToIndexedDb.d.ts +4 -3
- package/dist/types/browser/src/components/PushNotifications/helpers/serviceWorkerPushListener.d.ts +3 -1
- package/dist/types/browser/src/components/PushNotifications/index.d.ts +1 -1
- package/dist/types/browser/src/components/PushNotifications/request/makeSendPushSubscriptionRequest.d.ts +5 -1
- package/dist/types/browser/src/components/PushNotifications/request/makeSendServiceWorkerTrackingData.d.ts +4 -2
- package/dist/types/browser/src/components/PushNotifications/types.d.ts +28 -0
- package/dist/types/core/src/components/BrandConcierge/configValidators.d.ts +1 -1
- package/dist/types/core/src/components/Consent/configValidators.d.ts +1 -1
- package/dist/types/core/src/components/Consent/validateSetConsentOptions.d.ts +1 -1
- package/dist/types/core/src/components/Identity/configValidators.d.ts +1 -1
- package/dist/types/core/src/components/RulesEngine/index.d.ts +1 -1
- package/dist/types/core/src/components/StreamingMedia/configValidators.d.ts +1 -1
- package/dist/types/core/src/core/config/createCoreConfigs.d.ts +1 -1
- package/dist/types/core/src/utils/bytes.d.ts +1 -1
- package/dist/types/core/src/utils/validateConfigOverride.d.ts +1 -1
- package/dist/types/core/src/utils/validateIdentityMap.d.ts +1 -1
- package/dist/types/core/src/utils/validation/index.d.ts +23 -11
- package/dist/types/core/src/utils/validation/types.d.ts +133 -0
- package/dist/types/core/src/utils/validation/utils.d.ts +4 -3
- package/package.json +2 -2
- package/src/components/PushNotifications/helpers/getPushSubscriptionDetails.js +10 -8
- package/src/components/PushNotifications/helpers/readFromIndexedDb.js +3 -2
- package/src/components/PushNotifications/helpers/saveToIndexedDb.js +7 -2
- package/src/components/PushNotifications/helpers/serviceWorkerPushListener.js +58 -2
- package/src/components/PushNotifications/index.js +7 -6
- package/src/components/PushNotifications/request/makeSendPushSubscriptionRequest.js +20 -5
- package/src/components/PushNotifications/request/makeSendServiceWorkerTrackingData.js +14 -6
- package/src/components/PushNotifications/types.js +15 -0
- package/src/createEventListeners.js +1 -0
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 {
|
|
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 {
|
|
2304
|
-
* @param {
|
|
2305
|
-
* @returns {
|
|
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 {
|
|
2321
|
-
* @param {
|
|
2322
|
-
* @returns {
|
|
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 {
|
|
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 {
|
|
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 {
|
|
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 {
|
|
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 {
|
|
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 {
|
|
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 {
|
|
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 {
|
|
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 {
|
|
2411
|
+
* @param {object} [additionalMethods] - Additional methods to include on the returned
|
|
2399
2412
|
* validator.
|
|
2400
|
-
* @returns {
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
3114
|
-
|
|
3115
|
-
|
|
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
|
|
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
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
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
|
|
3137
|
-
|
|
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
|
|
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
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
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
|
|
3158
|
-
|
|
3159
|
-
|
|
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
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
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
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
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),
|
|
@@ -6667,7 +6859,9 @@
|
|
|
6667
6859
|
// so that sendBeacon requests don't override the edge info from before.
|
|
6668
6860
|
edge = { ...edge, ...response.getEdge() };
|
|
6669
6861
|
|
|
6670
|
-
identity.
|
|
6862
|
+
if (identity.getEcidFromCookie()) {
|
|
6863
|
+
identity.setIdentityAcquired();
|
|
6864
|
+
}
|
|
6671
6865
|
|
|
6672
6866
|
return handleResponseForIdSyncs(response);
|
|
6673
6867
|
},
|
|
@@ -7552,10 +7746,10 @@
|
|
|
7552
7746
|
governing permissions and limitations under the License.
|
|
7553
7747
|
*/
|
|
7554
7748
|
|
|
7555
|
-
// The 2.
|
|
7749
|
+
// The 2.35.0-beta.4 keyword will be replace at alloy build time with the package.json version.
|
|
7556
7750
|
// see babel-plugin-version
|
|
7557
7751
|
|
|
7558
|
-
var libraryVersion = "2.
|
|
7752
|
+
var libraryVersion = "2.35.0-beta.4";
|
|
7559
7753
|
|
|
7560
7754
|
/*
|
|
7561
7755
|
Copyright 2019 Adobe. All rights reserved.
|
|
@@ -20500,8 +20694,7 @@
|
|
|
20500
20694
|
throw new Error("Push notifications are not supported in this browser.");
|
|
20501
20695
|
}
|
|
20502
20696
|
|
|
20503
|
-
/** @type {
|
|
20504
|
-
const notification = window.Notification;
|
|
20697
|
+
const notification = /** @type {typeof Notification} */ (window.Notification);
|
|
20505
20698
|
if (notification.permission !== "granted") {
|
|
20506
20699
|
throw new Error(
|
|
20507
20700
|
"The user has not given permission to send push notifications.",
|
|
@@ -20546,15 +20739,18 @@
|
|
|
20546
20739
|
subscriptionOptions,
|
|
20547
20740
|
);
|
|
20548
20741
|
|
|
20742
|
+
const p256dhKey = subscription.getKey("p256dh");
|
|
20743
|
+
const authKey = subscription.getKey("auth");
|
|
20744
|
+
|
|
20549
20745
|
return {
|
|
20550
20746
|
endpoint: subscription.endpoint,
|
|
20551
20747
|
keys: {
|
|
20552
|
-
p256dh:
|
|
20553
|
-
urlSafe: true
|
|
20554
|
-
|
|
20555
|
-
auth:
|
|
20556
|
-
urlSafe: true
|
|
20557
|
-
|
|
20748
|
+
p256dh: p256dhKey
|
|
20749
|
+
? bytesToBase64(new Uint8Array(p256dhKey), { urlSafe: true })
|
|
20750
|
+
: null,
|
|
20751
|
+
auth: authKey
|
|
20752
|
+
? bytesToBase64(new Uint8Array(authKey), { urlSafe: true })
|
|
20753
|
+
: null,
|
|
20558
20754
|
},
|
|
20559
20755
|
};
|
|
20560
20756
|
} catch (e) {
|
|
@@ -20772,10 +20968,10 @@
|
|
|
20772
20968
|
|
|
20773
20969
|
|
|
20774
20970
|
/**
|
|
20775
|
-
* @param {
|
|
20971
|
+
* @param {Partial<PushServiceWorkerConfig>} data
|
|
20776
20972
|
* @param {Logger} logger
|
|
20777
20973
|
*
|
|
20778
|
-
* @returns {Promise<
|
|
20974
|
+
* @returns {Promise<boolean>} Whether the data was successfully saved.
|
|
20779
20975
|
*/
|
|
20780
20976
|
async function saveToIndexedDB(data, logger) {
|
|
20781
20977
|
try {
|
|
@@ -20809,8 +21005,12 @@
|
|
|
20809
21005
|
"Successfully saved web SDK config to IndexedDB",
|
|
20810
21006
|
updatedConfigData,
|
|
20811
21007
|
);
|
|
21008
|
+
|
|
21009
|
+
return true;
|
|
20812
21010
|
} catch (error) {
|
|
20813
21011
|
logger.error("Failed to save config to IndexedDB", { error });
|
|
21012
|
+
|
|
21013
|
+
return false;
|
|
20814
21014
|
}
|
|
20815
21015
|
}
|
|
20816
21016
|
|
|
@@ -20847,6 +21047,7 @@
|
|
|
20847
21047
|
* @param {EdgeRequestExecutor} options.sendEdgeNetworkRequest
|
|
20848
21048
|
* @param {ConsentManager} options.consent
|
|
20849
21049
|
* @param {Window} options.window
|
|
21050
|
+
* @param {typeof getPushSubscriptionDetailsDefault} [options.getPushSubscriptionDetails]
|
|
20850
21051
|
*
|
|
20851
21052
|
* @returns {Promise<void>}
|
|
20852
21053
|
*/
|
|
@@ -20864,6 +21065,14 @@
|
|
|
20864
21065
|
await identity.awaitIdentity();
|
|
20865
21066
|
const ecid = identity.getEcidFromCookie();
|
|
20866
21067
|
|
|
21068
|
+
if (!ecid) {
|
|
21069
|
+
logger.info(
|
|
21070
|
+
"No ECID is available. Not sending push subscription details to the server.",
|
|
21071
|
+
);
|
|
21072
|
+
|
|
21073
|
+
return;
|
|
21074
|
+
}
|
|
21075
|
+
|
|
20867
21076
|
const pushSubscriptionDetails = await getPushSubscriptionDetails$1({
|
|
20868
21077
|
vapidPublicKey,
|
|
20869
21078
|
window,
|
|
@@ -20876,7 +21085,7 @@
|
|
|
20876
21085
|
const cacheValue = `${ecid}${serializedPushSubscriptionDetails}`;
|
|
20877
21086
|
const storedValue = await storage.getItem(SUBSCRIPTION_DETAILS);
|
|
20878
21087
|
|
|
20879
|
-
if (cacheValue === storedValue) {
|
|
21088
|
+
if (storedValue && cacheValue === storedValue) {
|
|
20880
21089
|
logger.info(
|
|
20881
21090
|
"Subscription details have not changed. Not sending to the server.",
|
|
20882
21091
|
);
|
|
@@ -20884,8 +21093,6 @@
|
|
|
20884
21093
|
return;
|
|
20885
21094
|
}
|
|
20886
21095
|
|
|
20887
|
-
storage.setItem(SUBSCRIPTION_DETAILS, cacheValue);
|
|
20888
|
-
|
|
20889
21096
|
const payload = await createSendPushSubscriptionPayload({
|
|
20890
21097
|
eventManager,
|
|
20891
21098
|
ecid,
|
|
@@ -20900,7 +21107,15 @@
|
|
|
20900
21107
|
await consent.awaitConsent();
|
|
20901
21108
|
await sendEdgeNetworkRequest({ request });
|
|
20902
21109
|
|
|
20903
|
-
await saveToIndexedDB({ ecid }, logger);
|
|
21110
|
+
const savedToIndexedDb = await saveToIndexedDB({ ecid }, logger);
|
|
21111
|
+
|
|
21112
|
+
// Only cache the subscription details once the ECID has been persisted, so
|
|
21113
|
+
// that a failed send or a failed IndexedDB write does not short-circuit the
|
|
21114
|
+
// dedupe check on the next call. This lets a subsequent sendPushSubscription
|
|
21115
|
+
// self-heal instead of getting stuck with a cached subscription but no ECID.
|
|
21116
|
+
if (savedToIndexedDb) {
|
|
21117
|
+
storage.setItem(SUBSCRIPTION_DETAILS, cacheValue);
|
|
21118
|
+
}
|
|
20904
21119
|
};
|
|
20905
21120
|
|
|
20906
21121
|
/*
|
|
@@ -20916,6 +21131,10 @@
|
|
|
20916
21131
|
*/
|
|
20917
21132
|
|
|
20918
21133
|
|
|
21134
|
+
/**
|
|
21135
|
+
* @param {{ orgId?: string, pushNotifications?: { vapidPublicKey?: string, appId?: string, trackingDatasetId?: string } }} config
|
|
21136
|
+
* @returns {boolean}
|
|
21137
|
+
*/
|
|
20919
21138
|
const isComponentConfigured = ({
|
|
20920
21139
|
orgId,
|
|
20921
21140
|
pushNotifications: { vapidPublicKey, appId, trackingDatasetId } = {
|
|
@@ -20923,7 +21142,7 @@
|
|
|
20923
21142
|
appId: undefined,
|
|
20924
21143
|
trackingDatasetId: undefined,
|
|
20925
21144
|
},
|
|
20926
|
-
}) => orgId && vapidPublicKey && appId && trackingDatasetId;
|
|
21145
|
+
}) => Boolean(orgId && vapidPublicKey && appId && trackingDatasetId);
|
|
20927
21146
|
|
|
20928
21147
|
/**
|
|
20929
21148
|
* @function
|
|
@@ -20981,11 +21200,8 @@
|
|
|
20981
21200
|
|
|
20982
21201
|
const {
|
|
20983
21202
|
orgId,
|
|
20984
|
-
pushNotifications: { vapidPublicKey, appId }
|
|
20985
|
-
|
|
20986
|
-
appId: undefined,
|
|
20987
|
-
},
|
|
20988
|
-
} = config || {};
|
|
21203
|
+
pushNotifications: { vapidPublicKey, appId },
|
|
21204
|
+
} = config;
|
|
20989
21205
|
|
|
20990
21206
|
const storage = platformServices.storage.createNamespacedStorage(
|
|
20991
21207
|
`${sanitizeOrgIdForCookieName(orgId)}.pushNotifications.`,
|