@mparticle/web-onetrust-kit 2.0.4 → 2.0.5
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/OneTrustKit.common.js +130 -107
- package/package.json +1 -1
|
@@ -70,50 +70,74 @@ var initialization = {
|
|
|
70
70
|
};
|
|
71
71
|
},
|
|
72
72
|
createConsentEvents: function () {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
user = mParticle.Identity.getCurrentUser();
|
|
78
|
-
|
|
79
|
-
if (user) {
|
|
80
|
-
consentState = user.getConsentState();
|
|
73
|
+
var user = mParticle.Identity.getCurrentUser();
|
|
74
|
+
if (!window.Optanon || !user) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
81
77
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
for (var key in this.consentMapping) {
|
|
86
|
-
var consentPurpose = this.consentMapping[key].purpose;
|
|
87
|
-
var regulation = this.consentMapping[key].regulation;
|
|
88
|
-
var consentBoolean = false;
|
|
89
|
-
|
|
90
|
-
// removes all non-digits
|
|
91
|
-
// 1st version of OneTrust required a selection from group1, group2, etc
|
|
92
|
-
if (key.indexOf('group') >= 0) {
|
|
93
|
-
key = key.replace(/\D/g, '');
|
|
94
|
-
}
|
|
78
|
+
var location = window.location.href;
|
|
79
|
+
var consentState =
|
|
80
|
+
user.getConsentState() || mParticle.Consent.createConsentState();
|
|
95
81
|
|
|
96
|
-
|
|
82
|
+
for (var key in this.consentMapping) {
|
|
83
|
+
// removes all non-digits
|
|
84
|
+
// 1st version of OneTrust required a selection from group1, group2, etc
|
|
85
|
+
if (key.indexOf('group') >= 0) {
|
|
86
|
+
key = key.replace(/\D/g, '');
|
|
87
|
+
}
|
|
97
88
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
89
|
+
// Although consent purposes can be inputted into the UI in any casing
|
|
90
|
+
// the SDK will automatically lowercase them to prevent pseudo-duplicate
|
|
91
|
+
// consent purposes, so we call `toLowerCase` on the consentMapping purposes here
|
|
92
|
+
var consentPurpose = this.consentMapping[key].purpose.toLowerCase();
|
|
93
|
+
var regulation = this.consentMapping[key].regulation;
|
|
94
|
+
|
|
95
|
+
var latestOTConsentBoolean =
|
|
96
|
+
this.getConsentGroupIds().indexOf(key) > -1;
|
|
97
|
+
|
|
98
|
+
// At present, only CCPA and GDPR are known regulations
|
|
99
|
+
// Using a switch in case a new regulation is added in the future
|
|
100
|
+
switch (regulation) {
|
|
101
|
+
case CONSENT_REGULATIONS.CCPA:
|
|
102
|
+
var ccpaConsent = mParticle.Consent.createCCPAConsent(
|
|
103
|
+
latestOTConsentBoolean,
|
|
104
|
+
Date.now(),
|
|
105
|
+
consentPurpose,
|
|
106
|
+
location
|
|
107
|
+
);
|
|
108
|
+
consentState.setCCPAConsentState(ccpaConsent);
|
|
109
|
+
break;
|
|
110
|
+
|
|
111
|
+
case CONSENT_REGULATIONS.GDPR:
|
|
112
|
+
var GDPRConsentState =
|
|
113
|
+
consentState.getGDPRConsentState() || {};
|
|
114
|
+
|
|
115
|
+
// if the consent boolean exists, and the current users consent
|
|
116
|
+
// is the same as the latest OT consent (consent hasn't changed)
|
|
117
|
+
// then don't update the consent state
|
|
118
|
+
if (GDPRConsentState[consentPurpose]) {
|
|
119
|
+
var currentConsentBoolean =
|
|
120
|
+
GDPRConsentState[consentPurpose].Consented;
|
|
121
|
+
if (currentConsentBoolean === latestOTConsentBoolean) {
|
|
108
122
|
break;
|
|
109
|
-
|
|
110
|
-
console.error('Unknown Consent Regulation', regulation);
|
|
123
|
+
}
|
|
111
124
|
}
|
|
112
|
-
}
|
|
113
125
|
|
|
114
|
-
|
|
126
|
+
var gdprConsent = mParticle.Consent.createGDPRConsent(
|
|
127
|
+
latestOTConsentBoolean,
|
|
128
|
+
Date.now(),
|
|
129
|
+
consentPurpose,
|
|
130
|
+
location
|
|
131
|
+
);
|
|
132
|
+
consentState.addGDPRConsentState(consentPurpose, gdprConsent);
|
|
133
|
+
break;
|
|
134
|
+
|
|
135
|
+
default:
|
|
136
|
+
console.error('Unknown Consent Regulation', regulation);
|
|
115
137
|
}
|
|
116
138
|
}
|
|
139
|
+
|
|
140
|
+
user.setConsentState(consentState);
|
|
117
141
|
},
|
|
118
142
|
|
|
119
143
|
createVendorConsentEvents: function() {
|
|
@@ -228,7 +252,6 @@ function setIABVendorRequests(
|
|
|
228
252
|
var IABConsentedVendors = oneTrustVendorConsent
|
|
229
253
|
? oneTrustVendorConsent.vendor.consents
|
|
230
254
|
: null;
|
|
231
|
-
|
|
232
255
|
for (var vendorIndex in IABVendorConsentMappings) {
|
|
233
256
|
var consentPurpose = IABVendorConsentMappings[vendorIndex].purpose;
|
|
234
257
|
// consent is true if the (vendorIndex - 1) is 1
|
|
@@ -296,97 +319,97 @@ var initialization_1 = {
|
|
|
296
319
|
// limitations under the License.
|
|
297
320
|
var Initialization = initialization_1.initialization;
|
|
298
321
|
|
|
299
|
-
|
|
300
|
-
|
|
322
|
+
var name = Initialization.name,
|
|
323
|
+
moduleId = Initialization.moduleId;
|
|
301
324
|
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
325
|
+
var constructor = function () {
|
|
326
|
+
var self = this,
|
|
327
|
+
isInitialized = false,
|
|
328
|
+
forwarderSettings;
|
|
306
329
|
|
|
307
|
-
|
|
330
|
+
self.name = Initialization.name;
|
|
308
331
|
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
332
|
+
function initForwarder(settings) {
|
|
333
|
+
forwarderSettings = settings;
|
|
334
|
+
if (!isInitialized) {
|
|
335
|
+
try {
|
|
336
|
+
Initialization.initForwarder(forwarderSettings, isInitialized);
|
|
337
|
+
isInitialized = true;
|
|
338
|
+
} catch (e) {
|
|
339
|
+
console.log('Failed to initialize ' + name + ' - ' + e);
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
Initialization.createConsentEvents();
|
|
343
|
+
Initialization.createVendorConsentEvents();
|
|
344
|
+
}
|
|
345
|
+
}
|
|
318
346
|
|
|
347
|
+
function onUserIdentified() {
|
|
348
|
+
if (isInitialized) {
|
|
349
|
+
try {
|
|
319
350
|
Initialization.createConsentEvents();
|
|
320
351
|
Initialization.createVendorConsentEvents();
|
|
352
|
+
} catch (e) {
|
|
353
|
+
return {error: 'Error setting user identity on forwarder ' + name + '; ' + e};
|
|
321
354
|
}
|
|
322
355
|
}
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
if (isInitialized) {
|
|
326
|
-
try {
|
|
327
|
-
Initialization.createConsentEvents();
|
|
328
|
-
Initialization.createVendorConsentEvents();
|
|
329
|
-
} catch (e) {
|
|
330
|
-
return {error: 'Error setting user identity on forwarder ' + name + '; ' + e};
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
else {
|
|
334
|
-
return 'Can\'t set new user identities on forwader ' + name + ', not initialized';
|
|
335
|
-
}
|
|
356
|
+
else {
|
|
357
|
+
return 'Can\'t set new user identities on forwader ' + name + ', not initialized';
|
|
336
358
|
}
|
|
359
|
+
}
|
|
337
360
|
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
361
|
+
this.init = initForwarder;
|
|
362
|
+
this.onUserIdentified = onUserIdentified;
|
|
363
|
+
this.process = function() {
|
|
341
364
|
|
|
342
|
-
};
|
|
343
365
|
};
|
|
366
|
+
};
|
|
344
367
|
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
368
|
+
function getId() {
|
|
369
|
+
return moduleId;
|
|
370
|
+
}
|
|
348
371
|
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
372
|
+
function isObject(val) {
|
|
373
|
+
return val != null && typeof val === 'object' && Array.isArray(val) === false;
|
|
374
|
+
}
|
|
352
375
|
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
376
|
+
function register(config) {
|
|
377
|
+
if (!config) {
|
|
378
|
+
console.log('You must pass a config object to register the kit ' + name);
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
358
381
|
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
382
|
+
if (!isObject(config)) {
|
|
383
|
+
console.log('\'config\' must be an object. You passed in a ' + typeof config);
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
363
386
|
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
}
|
|
374
|
-
console.log('Successfully registered ' + name + ' to your mParticle configuration');
|
|
387
|
+
if (isObject(config.kits)) {
|
|
388
|
+
config.kits[name] = {
|
|
389
|
+
constructor: constructor
|
|
390
|
+
};
|
|
391
|
+
} else {
|
|
392
|
+
config.kits = {};
|
|
393
|
+
config.kits[name] = {
|
|
394
|
+
constructor: constructor
|
|
395
|
+
};
|
|
375
396
|
}
|
|
397
|
+
console.log('Successfully registered ' + name + ' to your mParticle configuration');
|
|
398
|
+
}
|
|
376
399
|
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
}
|
|
400
|
+
if (typeof window !== 'undefined') {
|
|
401
|
+
if (window && window.mParticle && window.mParticle.addForwarder) {
|
|
402
|
+
window.mParticle.addForwarder({
|
|
403
|
+
name: name,
|
|
404
|
+
constructor: constructor,
|
|
405
|
+
getId: getId
|
|
406
|
+
});
|
|
385
407
|
}
|
|
408
|
+
}
|
|
386
409
|
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
410
|
+
var oneTrustWrapper = {
|
|
411
|
+
register: register
|
|
412
|
+
};
|
|
390
413
|
var oneTrustWrapper_1 = oneTrustWrapper.register;
|
|
391
414
|
|
|
392
415
|
exports.default = oneTrustWrapper;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mparticle/web-onetrust-kit",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.5",
|
|
4
4
|
"author": "mParticle Developers <developers@mparticle.com> (https://www.mparticle.com)",
|
|
5
5
|
"description": "mParticle integration sdk for OneTrust",
|
|
6
6
|
"browser": "dist/OneTrustKit.common.js",
|