@mparticle/web-onetrust-kit 2.0.5 → 3.1.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.
@@ -3,7 +3,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
3
3
  /* eslint-disable no-undef */
4
4
  var CONSENT_REGULATIONS = {
5
5
  GDPR: 'gdpr',
6
- CCPA: 'ccpa'
6
+ CCPA: 'ccpa',
7
7
  };
8
8
  var CCPA_PURPOSE = 'data_sale_opt_out';
9
9
 
@@ -23,14 +23,19 @@ var initialization = {
23
23
  parseConsentMapping: function(rawConsentMapping) {
24
24
  var _consentMapping = {};
25
25
  if (rawConsentMapping) {
26
- var parsedMapping = JSON.parse(rawConsentMapping.replace(/"/g, '\"'));
26
+ var parsedMapping = JSON.parse(
27
+ rawConsentMapping.replace(/"/g, '"')
28
+ );
27
29
 
28
30
  // TODO: [67837] Revise this to use an actual 'regulation' mapping if UI ever returns this
29
31
  parsedMapping.forEach(function(mapping) {
30
32
  var purpose = mapping.map;
31
33
  _consentMapping[mapping.value] = {
32
34
  purpose: purpose,
33
- regulation: purpose === CCPA_PURPOSE ? CONSENT_REGULATIONS.CCPA : CONSENT_REGULATIONS.GDPR
35
+ regulation:
36
+ purpose === CCPA_PURPOSE
37
+ ? CONSENT_REGULATIONS.CCPA
38
+ : CONSENT_REGULATIONS.GDPR,
34
39
  };
35
40
  });
36
41
  }
@@ -57,7 +62,7 @@ var initialization = {
57
62
  // it for something custom so we can hijack
58
63
  var OptanonWrapperCopy = window.OptanonWrapper;
59
64
 
60
- window.OptanonWrapper = function () {
65
+ window.OptanonWrapper = function() {
61
66
  if (window.Optanon && window.Optanon.OnConsentChanged) {
62
67
  window.Optanon.OnConsentChanged(function() {
63
68
  self.createConsentEvents();
@@ -69,7 +74,7 @@ var initialization = {
69
74
  OptanonWrapperCopy();
70
75
  };
71
76
  },
72
- createConsentEvents: function () {
77
+ createConsentEvents: function() {
73
78
  var user = mParticle.Identity.getCurrentUser();
74
79
  if (!window.Optanon || !user) {
75
80
  return;
@@ -129,7 +134,10 @@ var initialization = {
129
134
  consentPurpose,
130
135
  location
131
136
  );
132
- consentState.addGDPRConsentState(consentPurpose, gdprConsent);
137
+ consentState.addGDPRConsentState(
138
+ consentPurpose,
139
+ gdprConsent
140
+ );
133
141
  break;
134
142
 
135
143
  default:
@@ -222,9 +230,11 @@ function setGoogleVendorRequests(
222
230
 
223
231
  if (googleConsentedVendors && googleConsentedVendors.length) {
224
232
  for (var vendorId in googleVendorConsentMapping) {
225
- var consentPurpose = googleVendorConsentMapping[vendorId].purpose;
233
+ var consentPurpose =
234
+ googleVendorConsentMapping[vendorId].purpose;
226
235
  // consent is true if the vendor id is in the array of consented IDs
227
- var consentBoolean = googleConsentedVendors.indexOf(vendorId) > -1;
236
+ var consentBoolean =
237
+ googleConsentedVendors.indexOf(vendorId) > -1;
228
238
  var consent = mParticle.Consent.createGDPRConsent(
229
239
  consentBoolean,
230
240
  Date.now(),
@@ -255,7 +265,8 @@ function setIABVendorRequests(
255
265
  for (var vendorIndex in IABVendorConsentMappings) {
256
266
  var consentPurpose = IABVendorConsentMappings[vendorIndex].purpose;
257
267
  // consent is true if the (vendorIndex - 1) is 1
258
- var consentBoolean = IABConsentedVendors[parseInt(vendorIndex) - 1] === '1';
268
+ var consentBoolean =
269
+ IABConsentedVendors[parseInt(vendorIndex) - 1] === '1';
259
270
  var consent = mParticle.Consent.createGDPRConsent(
260
271
  consentBoolean,
261
272
  Date.now(),
@@ -278,9 +289,11 @@ function setGeneralVendorRequests(
278
289
  try {
279
290
  if (window.Optanon) {
280
291
  for (var vendorId in generalVendorConsentMapping) {
281
- var consentPurpose = generalVendorConsentMapping[vendorId].purpose;
292
+ var consentPurpose =
293
+ generalVendorConsentMapping[vendorId].purpose;
282
294
  // consent is true if the vendorId is in the oneTrustVendorConsent array
283
- var consentBoolean = oneTrustVendorConsent.indexOf(vendorId) > -1;
295
+ var consentBoolean =
296
+ oneTrustVendorConsent.indexOf(vendorId) > -1;
284
297
  var consent = mParticle.Consent.createGDPRConsent(
285
298
  consentBoolean,
286
299
  Date.now(),
@@ -317,12 +330,13 @@ var initialization_1 = {
317
330
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
318
331
  // See the License for the specific language governing permissions and
319
332
  // limitations under the License.
320
- var Initialization = initialization_1.initialization;
333
+ var Initialization = initialization_1
334
+ .initialization;
321
335
 
322
336
  var name = Initialization.name,
323
337
  moduleId = Initialization.moduleId;
324
338
 
325
- var constructor = function () {
339
+ var constructor = function() {
326
340
  var self = this,
327
341
  isInitialized = false,
328
342
  forwarderSettings;
@@ -350,19 +364,26 @@ var constructor = function () {
350
364
  Initialization.createConsentEvents();
351
365
  Initialization.createVendorConsentEvents();
352
366
  } catch (e) {
353
- return {error: 'Error setting user identity on forwarder ' + name + '; ' + e};
367
+ return {
368
+ error:
369
+ 'Error setting user identity on forwarder ' +
370
+ name +
371
+ '; ' +
372
+ e,
373
+ };
354
374
  }
355
- }
356
- else {
357
- return 'Can\'t set new user identities on forwader ' + name + ', not initialized';
375
+ } else {
376
+ return (
377
+ "Can't set new user identities on forwader " +
378
+ name +
379
+ ', not initialized'
380
+ );
358
381
  }
359
382
  }
360
383
 
361
384
  this.init = initForwarder;
362
385
  this.onUserIdentified = onUserIdentified;
363
- this.process = function() {
364
-
365
- };
386
+ this.process = function() {};
366
387
  };
367
388
 
368
389
  function getId() {
@@ -370,31 +391,39 @@ function getId() {
370
391
  }
371
392
 
372
393
  function isObject(val) {
373
- return val != null && typeof val === 'object' && Array.isArray(val) === false;
394
+ return (
395
+ val != null && typeof val === 'object' && Array.isArray(val) === false
396
+ );
374
397
  }
375
398
 
376
399
  function register(config) {
377
400
  if (!config) {
378
- console.log('You must pass a config object to register the kit ' + name);
401
+ console.log(
402
+ 'You must pass a config object to register the kit ' + name
403
+ );
379
404
  return;
380
405
  }
381
406
 
382
407
  if (!isObject(config)) {
383
- console.log('\'config\' must be an object. You passed in a ' + typeof config);
408
+ console.log(
409
+ "'config' must be an object. You passed in a " + typeof config
410
+ );
384
411
  return;
385
412
  }
386
413
 
387
414
  if (isObject(config.kits)) {
388
415
  config.kits[name] = {
389
- constructor: constructor
416
+ constructor: constructor,
390
417
  };
391
418
  } else {
392
419
  config.kits = {};
393
420
  config.kits[name] = {
394
- constructor: constructor
421
+ constructor: constructor,
395
422
  };
396
423
  }
397
- console.log('Successfully registered ' + name + ' to your mParticle configuration');
424
+ console.log(
425
+ 'Successfully registered ' + name + ' to your mParticle configuration'
426
+ );
398
427
  }
399
428
 
400
429
  if (typeof window !== 'undefined') {
@@ -402,13 +431,13 @@ if (typeof window !== 'undefined') {
402
431
  window.mParticle.addForwarder({
403
432
  name: name,
404
433
  constructor: constructor,
405
- getId: getId
434
+ getId: getId,
406
435
  });
407
436
  }
408
437
  }
409
438
 
410
439
  var oneTrustWrapper = {
411
- register: register
440
+ register: register,
412
441
  };
413
442
  var oneTrustWrapper_1 = oneTrustWrapper.register;
414
443
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mparticle/web-onetrust-kit",
3
- "version": "2.0.5",
3
+ "version": "3.1.0",
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",
@@ -8,7 +8,11 @@
8
8
  "files": [
9
9
  "dist/OneTrustKit.common.js"
10
10
  ],
11
- "repository": "https://github.com/mparticle-integrations/mparticle-javascript-integration-onetrust",
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "https://github.com/mParticle/mparticle-web-sdk",
14
+ "directory": "kits/onetrust"
15
+ },
12
16
  "scripts": {
13
17
  "build": "rollup --config rollup.config.js",
14
18
  "watch": "rollup --config rollup.config.js -w",
@@ -31,7 +35,7 @@
31
35
  },
32
36
  "dependencies": {
33
37
  "isobject": "^4.0.0",
34
- "@mparticle/web-sdk": "^2.11.15"
38
+ "@mparticle/web-sdk": "^3.0.0"
35
39
  },
36
40
  "license": "Apache-2.0"
37
41
  }