Socket
Socket
Sign inDemoInstall

@mparticle/web-sdk

Package Overview
Dependencies
Maintainers
8
Versions
108
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mparticle/web-sdk - npm Package Compare versions

Comparing version 2.11.3 to 2.11.5

12

CHANGELOG.md

@@ -5,2 +5,14 @@ ## Releases

#### 2.11.5 - 2020-02-12
- Update node version for Travis
- Api docs update
- Bugfix - Enable configuration of v1 endpoints
#### 2.11.4 - 2020-02-06
- Feat - Modify reset API for public consumption
- Feat - Import @mparticle/event-models to replace eventApiModels
- Bugfix - Typo & keep persistence checking consistent
#### 2.11.3 - 2020-02-04

@@ -7,0 +19,0 @@

5

package.json
{
"name": "@mparticle/web-sdk",
"version": "2.11.3",
"version": "2.11.5",
"description": "mParticle core SDK for web applications",

@@ -67,2 +67,3 @@ "license": "Apache-2.0",

"@babel/preset-typescript": "^7.6.0",
"@mparticle/event-models": "^1.0.3",
"@types/chai": "^4.2.3",

@@ -113,2 +114,2 @@ "@types/mocha": "^5.2.7",

}
}
}

2

src/batchUploader.ts

@@ -1,2 +0,2 @@

import { Batch } from './eventsApiModels';
import { Batch } from '@mparticle/event-models';
import {

@@ -3,0 +3,0 @@ SDKEvent,

@@ -171,16 +171,20 @@ export default function Consent(mpInstance) {

function setGDPRConsentState(gdprConsentState) {
if (!gdprConsentState) {
gdpr = {};
} else if (mpInstance._Helpers.isObject(gdprConsentState)) {
gdpr = {};
for (var purpose in gdprConsentState) {
if (gdprConsentState.hasOwnProperty(purpose)) {
addGDPRConsentState(purpose, gdprConsentState[purpose]);
}
}
}
return this;
}
/**
* Invoke these methods on a consent state object.
* <p>
* Usage: var consent = mParticle.Consent.createConsentState()
* <br>
* consent.setGDPRCoonsentState()
*
* @class Consent
*/
/**
* Add a GDPR Consent State to the consent state object
*
* @method addGDPRConsentState
* @param purpose [String] Data processing purpose that describes the type of processing done on the data subject’s data
* @param gdprConsent [Object] A GDPR consent object created via mParticle.Consent.createGDPRConsent(...)
*/
function addGDPRConsentState(purpose, gdprConsent) {

@@ -211,2 +215,23 @@ var normalizedPurpose = canonicalizeForDeduplication(purpose);

function setGDPRConsentState(gdprConsentState) {
if (!gdprConsentState) {
gdpr = {};
} else if (mpInstance._Helpers.isObject(gdprConsentState)) {
gdpr = {};
for (var purpose in gdprConsentState) {
if (gdprConsentState.hasOwnProperty(purpose)) {
addGDPRConsentState(purpose, gdprConsentState[purpose]);
}
}
}
return this;
}
/**
* Remove a GDPR Consent State to the consent state object
*
* @method removeGDPRConsentState
* @param purpose [String] Data processing purpose that describes the type of processing done on the data subject’s data
*/
function removeGDPRConsentState(purpose) {

@@ -221,2 +246,9 @@ var normalizedPurpose = canonicalizeForDeduplication(purpose);

/**
* Gets the GDPR Consent State
*
* @method getGDPRConsentState
* @return {Object} A GDPR Consent State
*/
function getGDPRConsentState() {

@@ -226,2 +258,8 @@ return mpInstance._Helpers.extend({}, gdpr);

/**
* Sets a CCPA Consent state (has a single purpose of 'data_sale_opt_out')
*
* @method setCCPAConsentState
* @param {Object} ccpaConsent CCPA Consent State
*/
function setCCPAConsentState(ccpaConsent) {

@@ -247,2 +285,8 @@ if (!mpInstance._Helpers.isObject(ccpaConsent)) {

/**
* Gets the CCPA Consent State
*
* @method getCCPAConsentStatensent
* @return {Object} A CCPA Consent State
*/
function getCCPAConsentState() {

@@ -252,2 +296,7 @@ return ccpa[CCPAPurpose];

/**
* Removes CCPA from the consent state object
*
* @method removeCCPAState
*/
function removeCCPAState() {

@@ -254,0 +303,0 @@ delete ccpa[CCPAPurpose];

var Constants = {
sdkVersion: '2.11.3',
sdkVersion: '2.11.5',
sdkVendor: 'mparticle',

@@ -4,0 +4,0 @@ platform: 'web',

@@ -27,8 +27,8 @@ import Constants from './constants';

urlWithRedirect = url + encodeURIComponent(redirect);
var cookies = mpInstance._Persistence.getPersistence();
var persistence = mpInstance._Persistence.getPersistence();
if (previousMPID && previousMPID !== mpid) {
if (cookies && cookies[mpid]) {
if (!cookies[mpid].csd) {
cookies[mpid].csd = {};
if (persistence && persistence[mpid]) {
if (!persistence[mpid].csd) {
persistence[mpid].csd = {};
}

@@ -39,3 +39,3 @@ self.performCookieSync(

mpid,
cookies[mpid].csd
persistence[mpid].csd
);

@@ -45,10 +45,12 @@ }

} else {
if (cookies[mpid]) {
if (!cookies[mpid].csd) {
cookies[mpid].csd = {};
if (persistence[mpid]) {
if (!persistence[mpid].csd) {
persistence[mpid].csd = {};
}
lastSyncDateForModule = cookies[mpid].csd[
lastSyncDateForModule = persistence[mpid].csd[
pixelConfig.moduleId.toString()
]
? cookies[mpid].csd[pixelConfig.moduleId.toString()]
? persistence[mpid].csd[
pixelConfig.moduleId.toString()
]
: null;

@@ -71,3 +73,3 @@

mpid,
cookies[mpid].csd
persistence[mpid].csd
);

@@ -80,3 +82,3 @@ }

mpid,
cookies[mpid].csd
persistence[mpid].csd
);

@@ -105,3 +107,3 @@ }

cookieSyncDates[moduleId.toString()] = new Date().getTime();
mpInstance._Persistence.saveUserCookieSyncDatesToCookies(
mpInstance._Persistence.saveUserCookieSyncDatesToPersistence(
mpid,

@@ -108,0 +110,0 @@ cookieSyncDates

@@ -42,6 +42,12 @@ //

/**
* Invoke these methods on the mParticle object.
* Example: mParticle.endSession()
* <p>All of the following methods can be called on the primary mParticle class. In version 2.10.0, we introduced <a href="https://docs.mparticle.com/developers/sdk/web/multiple-instances/">multiple instances</a>. If you are using multiple instances (self hosted environments only), you should call these methods on each instance.</p>
* <p>In current versions of mParticle, if your site has one instance, that instance name is 'default_instance'. Any methods called on mParticle on a site with one instance will be mapped to the `default_instance`.</p>
* <p>This is for simplicity and backwards compatibility. For example, calling mParticle.logPageView() automatically maps to mParticle.getInstance('default_instance').logPageView().</p>
* <p>If you have multiple instances, instances must first be initialized and then a method can be called on that instance. For example:</p>
* <code>
* mParticle.init('apiKey', config, 'another_instance');
* mParticle.getInstance('another_instance').logPageView();
* </code>
*
* @class mParticleInstance
* @class mParticle & mParticleInstance
*/

@@ -90,9 +96,2 @@

/**
* Initializes the mParticle SDK
*
* @method init
* @param {String} apiKey your mParticle assigned API key
* @param {Object} [options] an options object for additional configuration
*/
this.init = function(apiKey, config) {

@@ -131,9 +130,28 @@ if (!config) {

};
/**
* Resets the SDK to an uninitialized state and removes cookies/localStorage. You MUST call mParticle.init(apiKey, window.mParticle.config)
* before any other mParticle methods or the SDK will not function as intended.
* @method setLogLevel
* @param {String} logLevel verbose, warning, or none. By default, `warning` is chosen.
*/
this.setLogLevel = function(newLogLevel) {
self.Logger.setLogLevel(newLogLevel);
};
this.reset = function(config, keepPersistence, instance) {
/**
* Resets the SDK to an uninitialized state and removes cookies/localStorage. You MUST call mParticle.init(apiKey, window.mParticle.config)
* before any other mParticle methods or the SDK will not function as intended.
* @method reset
*/
this.reset = function(instance) {
instance._Persistence.resetPersistence();
if (instance._Store) {
delete instance._Store;
}
};
this._resetForTests = function(config, keepPersistence, instance) {
if (instance._Store) {
delete instance._Store;
}
instance._Store = new Store(config, instance);

@@ -145,3 +163,3 @@ instance._Store.isLocalStorageAvailable = instance._Persistence.determineLocalStorageAvailability(

if (!keepPersistence) {
instance._Persistence.reset_Persistence();
instance._Persistence.resetPersistence();
}

@@ -158,2 +176,7 @@ instance._Persistence.forwardingStatsBatches.uploadsTable = {};

};
/**
* A callback method that is invoked after mParticle is initialized.
* @method ready
* @param {Function} function A function to be called after mParticle is initialized
*/
this.ready = function(f) {

@@ -471,5 +494,40 @@ if (self._Store.isInitialized && typeof f === 'function') {

};
/**
* Invoke these methods on the mParticle.Consent object.
* Example: mParticle.Consent.createConsentState()
*
* @class mParticle.Consent
*/
this.Consent = {
/**
* Creates a CCPA Opt Out Consent State.
*
* @method createCCPAConsent
* @param {Boolean} optOut true represents a "data sale opt-out", false represents the user declining a "data sale opt-out"
* @param {Number} timestamp Unix time (likely to be Date.now())
* @param {String} consentDocument document version or experience that the user may have consented to
* @param {String} location location where the user gave consent
* @param {String} hardwareId hardware ID for the device or browser used to give consent. This property exists only to provide additional context and is not used to identify users
* @return {Object} CCPA Consent State
*/
createCCPAConsent: self._Consent.createPrivacyConsent,
/**
* Creates a GDPR Consent State.
*
* @method createGDPRConsent
* @param {Boolean} consent true represents a "data sale opt-out", false represents the user declining a "data sale opt-out"
* @param {Number} timestamp Unix time (likely to be Date.now())
* @param {String} consentDocument document version or experience that the user may have consented to
* @param {String} location location where the user gave consent
* @param {String} hardwareId hardware ID for the device or browser used to give consent. This property exists only to provide additional context and is not used to identify users
* @return {Object} GDPR Consent State
*/
createGDPRConsent: self._Consent.createPrivacyConsent,
/**
* Creates a Consent State Object, which can then be used to set CCPA states, add multiple GDPR states, as well as get and remove these privacy states.
*
* @method createConsentState
* @return {Object} ConsentState object
*/
createConsentState: self._Consent.createConsentState,

@@ -487,2 +545,3 @@ };

* @class mParticle.eCommerce.Cart
* @deprecated
*/

@@ -851,3 +910,2 @@ Cart: {

* Sets a session attribute
* @for mParticle
* @method setSessionAttribute

@@ -905,3 +963,2 @@ * @param {String} key key for session attribute

* Set opt out of logging
* @for mParticle
* @method setOptOut

@@ -942,3 +999,2 @@ * @param {Boolean} isOptingOut boolean to opt out or not. When set to true, opt out of logging.

* with the necessary integration attributes to be properly forwarded to the given integration.
* @for mParticle
* @method setIntegrationAttribute

@@ -1026,2 +1082,3 @@ * @param {Number} integrationId mParticle integration ID

};
// Used by our forwarders
this.addForwarder = function(forwarder) {

@@ -1248,3 +1305,3 @@ self._preInit.forwarderConstructors.push(forwarder);

} catch (e) {
mpInstance.Loger.warning(
mpInstance.Logger.warning(
'localStorage is not available, using cookies if avaialble'

@@ -1251,0 +1308,0 @@ );

@@ -42,2 +42,11 @@ import Polyfill from './polyfill';

/**
* Initializes the mParticle instance. If no instanceName is provided, an instance name of `default_instance` will be used.
* <p>
* If you'd like to initiate multiple mParticle instances, first review our <a href="https://docs.mparticle.com/developers/sdk/web/multiple-instances/">doc site</a>, and ensure you pass a unique instance name as the third argument as shown below.
* @method init
* @param {String} apiKey your mParticle assigned API key
* @param {Object} [config] an options object for additional configuration
* @param {String} [instanceName] If you are self hosting the JS SDK and working with multiple instances, you would pass an instanceName to `init`. This instance will be selected when invoking other methods. See the above link to the doc site for more info and examples.
*/
this.init = function(apiKey, config, instanceName) {

@@ -387,7 +396,19 @@ if (!config && (window.mParticle && window.mParticle.config)) {

this.reset = function(MPConfig, boolean) {
if (typeof boolean === 'boolean') {
self.getInstance().reset(MPConfig, boolean, self.getInstance());
this.reset = function() {
self.getInstance().reset(self.getInstance());
};
this._resetForTests = function(MPConfig, keepPersistence) {
if (typeof keepPersistence === 'boolean') {
self.getInstance()._resetForTests(
MPConfig,
keepPersistence,
self.getInstance()
);
} else {
self.getInstance().reset(MPConfig, false, self.getInstance());
self.getInstance()._resetForTests(
MPConfig,
false,
self.getInstance()
);
}

@@ -394,0 +415,0 @@ };

@@ -363,3 +363,3 @@ import Constants from './constants';

encodeURIComponent(key),
self.encodeCookies(JSON.stringify(localStorageData))
self.encodePersistence(JSON.stringify(localStorageData))
);

@@ -402,3 +402,3 @@ } catch (e) {

var key = mpInstance._Store.storageName,
localStorageData = self.decodeCookies(
localStorageData = self.decodePersistence(
window.localStorage.getItem(key)

@@ -476,3 +476,3 @@ ),

mpInstance.Logger.verbose(Messages.InformationMessages.CookieFound);
return JSON.parse(self.decodeCookies(result));
return JSON.parse(self.decodePersistence(result));
} else {

@@ -536,3 +536,3 @@ return null;

encodedCookiesWithExpirationAndPath = self.reduceAndEncodeCookies(
encodedCookiesWithExpirationAndPath = self.reduceAndEncodePersistence(
cookies,

@@ -562,4 +562,4 @@ expires,

*/
this.reduceAndEncodeCookies = function(
cookies,
this.reduceAndEncodePersistence = function(
persistence,
expires,

@@ -570,9 +570,9 @@ domain,

var encodedCookiesWithExpirationAndPath,
currentSessionMPIDs = cookies.gs.csm ? cookies.gs.csm : [];
currentSessionMPIDs = persistence.gs.csm ? persistence.gs.csm : [];
// Comment 1 above
if (!currentSessionMPIDs.length) {
for (var key in cookies) {
if (cookies.hasOwnProperty(key)) {
for (var key in persistence) {
if (persistence.hasOwnProperty(key)) {
encodedCookiesWithExpirationAndPath = createFullEncodedCookie(
cookies,
persistence,
expires,

@@ -587,5 +587,5 @@ domain

!SDKv2NonMPIDCookieKeys[key] &&
key !== cookies.cu
key !== persistence.cu
) {
delete cookies[key];
delete persistence[key];
}

@@ -598,7 +598,7 @@ }

var MPIDsOnCookie = {};
for (var potentialMPID in cookies) {
if (cookies.hasOwnProperty(potentialMPID)) {
for (var potentialMPID in persistence) {
if (persistence.hasOwnProperty(potentialMPID)) {
if (
!SDKv2NonMPIDCookieKeys[potentialMPID] &&
potentialMPID !== cookies.cu
potentialMPID !== persistence.cu
) {

@@ -613,3 +613,3 @@ MPIDsOnCookie[potentialMPID] = 1;

encodedCookiesWithExpirationAndPath = createFullEncodedCookie(
cookies,
persistence,
expires,

@@ -624,3 +624,3 @@ domain

if (currentSessionMPIDs.indexOf(mpid) === -1) {
delete cookies[mpid];
delete persistence[mpid];
}

@@ -634,3 +634,3 @@ }

encodedCookiesWithExpirationAndPath = createFullEncodedCookie(
cookies,
persistence,
expires,

@@ -643,3 +643,3 @@ domain

var MPIDtoRemove = currentSessionMPIDs[i];
if (cookies[MPIDtoRemove]) {
if (persistence[MPIDtoRemove]) {
mpInstance.Logger.verbose(

@@ -649,5 +649,5 @@ 'Size of new encoded cookie is larger than maxCookieSize setting of ' +

'. Removing from cookie the earliest logged in MPID containing: ' +
JSON.stringify(cookies[MPIDtoRemove], 0, 2)
JSON.stringify(persistence[MPIDtoRemove], 0, 2)
);
delete cookies[MPIDtoRemove];
delete persistence[MPIDtoRemove];
} else {

@@ -669,5 +669,5 @@ mpInstance.Logger.error(

function createFullEncodedCookie(cookies, expires, domain) {
function createFullEncodedCookie(persistence, expires, domain) {
return (
self.encodeCookies(JSON.stringify(cookies)) +
self.encodePersistence(JSON.stringify(persistence)) +
';expires=' +

@@ -681,3 +681,3 @@ expires +

this.findPrevCookiesBasedOnUI = function(identityApiData) {
var cookies = self.getCookie() || self.getLocalStorage();
var persistence = mpInstance._Persistence.getPersistence();
var matchedUser;

@@ -687,8 +687,8 @@

for (var requestedIdentityType in identityApiData.userIdentities) {
if (cookies && Object.keys(cookies).length) {
for (var key in cookies) {
// any value in cookies that has an MPID key will be an MPID to search through
if (persistence && Object.keys(persistence).length) {
for (var key in persistence) {
// any value in persistence that has an MPID key will be an MPID to search through
// other keys on the cookie are currentSessionMPIDs and currentMPID which should not be searched
if (cookies[key].mpid) {
var cookieUIs = cookies[key].ui;
if (persistence[key].mpid) {
var cookieUIs = persistence[key].ui;
for (var cookieUIType in cookieUIs) {

@@ -712,32 +712,34 @@ if (

if (matchedUser) {
self.storeDataInMemory(cookies, matchedUser);
self.storeDataInMemory(persistence, matchedUser);
}
};
this.encodeCookies = function(cookie) {
cookie = JSON.parse(cookie);
for (var key in cookie.gs) {
if (cookie.gs.hasOwnProperty(key)) {
this.encodePersistence = function(persistence) {
persistence = JSON.parse(persistence);
for (var key in persistence.gs) {
if (persistence.gs.hasOwnProperty(key)) {
if (Base64CookieKeys[key]) {
if (cookie.gs[key]) {
if (persistence.gs[key]) {
// base64 encode any value that is an object or Array in globalSettings
if (
(Array.isArray(cookie.gs[key]) &&
cookie.gs[key].length) ||
(mpInstance._Helpers.isObject(cookie.gs[key]) &&
Object.keys(cookie.gs[key]).length)
(Array.isArray(persistence.gs[key]) &&
persistence.gs[key].length) ||
(mpInstance._Helpers.isObject(
persistence.gs[key]
) &&
Object.keys(persistence.gs[key]).length)
) {
cookie.gs[key] = Base64.encode(
JSON.stringify(cookie.gs[key])
persistence.gs[key] = Base64.encode(
JSON.stringify(persistence.gs[key])
);
} else {
delete cookie.gs[key];
delete persistence.gs[key];
}
} else {
delete cookie.gs[key];
delete persistence.gs[key];
}
} else if (key === 'ie') {
cookie.gs[key] = cookie.gs[key] ? 1 : 0;
} else if (!cookie.gs[key]) {
delete cookie.gs[key];
persistence.gs[key] = persistence.gs[key] ? 1 : 0;
} else if (!persistence.gs[key]) {
delete persistence.gs[key];
}

@@ -747,19 +749,19 @@ }

for (var mpid in cookie) {
if (cookie.hasOwnProperty(mpid)) {
for (var mpid in persistence) {
if (persistence.hasOwnProperty(mpid)) {
if (!SDKv2NonMPIDCookieKeys[mpid]) {
for (key in cookie[mpid]) {
if (cookie[mpid].hasOwnProperty(key)) {
for (key in persistence[mpid]) {
if (persistence[mpid].hasOwnProperty(key)) {
if (Base64CookieKeys[key]) {
if (
mpInstance._Helpers.isObject(
cookie[mpid][key]
persistence[mpid][key]
) &&
Object.keys(cookie[mpid][key]).length
Object.keys(persistence[mpid][key]).length
) {
cookie[mpid][key] = Base64.encode(
JSON.stringify(cookie[mpid][key])
persistence[mpid][key] = Base64.encode(
JSON.stringify(persistence[mpid][key])
);
} else {
delete cookie[mpid][key];
delete persistence[mpid][key];
}

@@ -773,21 +775,23 @@ }

return self.createCookieString(JSON.stringify(cookie));
return self.createCookieString(JSON.stringify(persistence));
};
this.decodeCookies = function(cookie) {
this.decodePersistence = function(persistence) {
try {
if (cookie) {
cookie = JSON.parse(self.revertCookieString(cookie));
if (persistence) {
persistence = JSON.parse(self.revertCookieString(persistence));
if (
mpInstance._Helpers.isObject(cookie) &&
Object.keys(cookie).length
mpInstance._Helpers.isObject(persistence) &&
Object.keys(persistence).length
) {
for (var key in cookie.gs) {
if (cookie.gs.hasOwnProperty(key)) {
for (var key in persistence.gs) {
if (persistence.gs.hasOwnProperty(key)) {
if (Base64CookieKeys[key]) {
cookie.gs[key] = JSON.parse(
Base64.decode(cookie.gs[key])
persistence.gs[key] = JSON.parse(
Base64.decode(persistence.gs[key])
);
} else if (key === 'ie') {
cookie.gs[key] = Boolean(cookie.gs[key]);
persistence.gs[key] = Boolean(
persistence.gs[key]
);
}

@@ -797,12 +801,14 @@ }

for (var mpid in cookie) {
if (cookie.hasOwnProperty(mpid)) {
for (var mpid in persistence) {
if (persistence.hasOwnProperty(mpid)) {
if (!SDKv2NonMPIDCookieKeys[mpid]) {
for (key in cookie[mpid]) {
if (cookie[mpid].hasOwnProperty(key)) {
for (key in persistence[mpid]) {
if (persistence[mpid].hasOwnProperty(key)) {
if (Base64CookieKeys[key]) {
if (cookie[mpid][key].length) {
cookie[mpid][key] = JSON.parse(
if (persistence[mpid][key].length) {
persistence[mpid][
key
] = JSON.parse(
Base64.decode(
cookie[mpid][key]
persistence[mpid][key]
)

@@ -815,3 +821,3 @@ );

} else if (mpid === 'l') {
cookie[mpid] = Boolean(cookie[mpid]);
persistence[mpid] = Boolean(persistence[mpid]);
}

@@ -822,3 +828,3 @@ }

return JSON.stringify(cookie);
return JSON.stringify(persistence);
}

@@ -897,6 +903,6 @@ } catch (e) {

this.getUserIdentities = function(mpid) {
var cookies = self.getPersistence();
var persistence = self.getPersistence();
if (cookies && cookies[mpid] && cookies[mpid].ui) {
return cookies[mpid].ui;
if (persistence && persistence[mpid] && persistence[mpid].ui) {
return persistence[mpid].ui;
} else {

@@ -908,6 +914,6 @@ return {};

this.getAllUserAttributes = function(mpid) {
var cookies = self.getPersistence();
var persistence = self.getPersistence();
if (cookies && cookies[mpid] && cookies[mpid].ua) {
return cookies[mpid].ua;
if (persistence && persistence[mpid] && persistence[mpid].ua) {
return persistence[mpid].ua;
} else {

@@ -953,14 +959,14 @@ return {};

};
this.saveUserIdentitiesToCookies = function(mpid, userIdentities) {
this.saveUserIdentitiesToPersistence = function(mpid, userIdentities) {
if (userIdentities) {
var cookies = self.getPersistence();
if (cookies) {
if (cookies[mpid]) {
cookies[mpid].ui = userIdentities;
var persistence = self.getPersistence();
if (persistence) {
if (persistence[mpid]) {
persistence[mpid].ui = userIdentities;
} else {
cookies[mpid] = {
persistence[mpid] = {
ui: userIdentities,
};
}
self.saveCookies(cookies);
self.savePersistence(persistence);
}

@@ -970,10 +976,10 @@ }

this.saveUserAttributesToCookies = function(mpid, userAttributes) {
var cookies = self.getPersistence();
this.saveUserAttributesToPersistence = function(mpid, userAttributes) {
var persistence = self.getPersistence();
if (userAttributes) {
if (cookies) {
if (cookies[mpid]) {
cookies[mpid].ui = userAttributes;
if (persistence) {
if (persistence[mpid]) {
persistence[mpid].ui = userAttributes;
} else {
cookies[mpid] = {
persistence[mpid] = {
ui: userAttributes,

@@ -983,14 +989,14 @@ };

}
self.saveCookies(cookies);
self.savePersistence(persistence);
}
};
this.saveUserCookieSyncDatesToCookies = function(mpid, csd) {
this.saveUserCookieSyncDatesToPersistence = function(mpid, csd) {
if (csd) {
var cookies = self.getPersistence();
if (cookies) {
if (cookies[mpid]) {
cookies[mpid].csd = csd;
var persistence = self.getPersistence();
if (persistence) {
if (persistence[mpid]) {
persistence[mpid].csd = csd;
} else {
cookies[mpid] = {
persistence[mpid] = {
csd: csd,

@@ -1000,3 +1006,3 @@ };

}
self.saveCookies(cookies);
self.savePersistence(persistence);
}

@@ -1009,6 +1015,6 @@ };

if (consentState || consentState === null) {
var cookies = self.getPersistence();
if (cookies) {
if (cookies[mpid]) {
cookies[
var persistence = self.getPersistence();
if (persistence) {
if (persistence[mpid]) {
persistence[
mpid

@@ -1019,3 +1025,3 @@ ].con = mpInstance._Consent.ConsentSerialization.toMinifiedJsonObject(

} else {
cookies[mpid] = {
persistence[mpid] = {
con: mpInstance._Consent.ConsentSerialization.toMinifiedJsonObject(

@@ -1026,3 +1032,3 @@ consentState

}
self.saveCookies(cookies);
self.savePersistence(persistence);
}

@@ -1032,4 +1038,6 @@ }

this.saveCookies = function(cookies) {
var encodedCookies = self.encodeCookies(JSON.stringify(cookies)),
this.savePersistence = function(persistence) {
var encodedPersistence = self.encodePersistence(
JSON.stringify(persistence)
),
date = new Date(),

@@ -1055,4 +1063,4 @@ key = mpInstance._Store.storageName,

if (mpInstance._Store.SDKConfig.useCookieStorage) {
var encodedCookiesWithExpirationAndPath = self.reduceAndEncodeCookies(
cookies,
var encodedCookiesWithExpirationAndPath = self.reduceAndEncodePersistence(
persistence,
expires,

@@ -1070,3 +1078,3 @@ domain,

mpInstance._Store.storageName,
encodedCookies
encodedPersistence
);

@@ -1078,18 +1086,15 @@ }

this.getPersistence = function() {
var cookies;
if (mpInstance._Store.SDKConfig.useCookieStorage) {
cookies = self.getCookie();
} else {
cookies = self.getLocalStorage();
}
var persistence = this.useLocalStorage()
? this.getLocalStorage()
: this.getCookie();
return cookies;
return persistence;
};
this.getConsentState = function(mpid) {
var cookies = self.getPersistence();
var persistence = self.getPersistence();
if (cookies && cookies[mpid] && cookies[mpid].con) {
if (persistence && persistence[mpid] && persistence[mpid].con) {
return mpInstance._Consent.ConsentSerialization.fromMinifiedJsonObject(
cookies[mpid].con
persistence[mpid].con
);

@@ -1105,5 +1110,5 @@ } else {

}
var cookies = self.getPersistence();
if (cookies && cookies[mpid] && cookies[mpid].fst) {
return cookies[mpid].fst;
var persistence = self.getPersistence();
if (persistence && persistence[mpid] && persistence[mpid].fst) {
return persistence[mpid].fst;
} else {

@@ -1125,10 +1130,10 @@ return null;

}
var cookies = self.getPersistence();
if (cookies) {
if (!cookies[mpid]) {
cookies[mpid] = {};
var persistence = self.getPersistence();
if (persistence) {
if (!persistence[mpid]) {
persistence[mpid] = {};
}
if (!cookies[mpid].fst) {
cookies[mpid].fst = time;
self.saveCookies(cookies);
if (!persistence[mpid].fst) {
persistence[mpid].fst = time;
self.savePersistence(persistence);
}

@@ -1151,5 +1156,5 @@ }

} else {
var cookies = self.getPersistence();
if (cookies && cookies[mpid] && cookies[mpid].lst) {
return cookies[mpid].lst;
var persistence = self.getPersistence();
if (persistence && persistence[mpid] && persistence[mpid].lst) {
return persistence[mpid].lst;
}

@@ -1167,6 +1172,6 @@ return null;

}
var cookies = self.getPersistence();
if (cookies && cookies[mpid]) {
cookies[mpid].lst = time;
self.saveCookies(cookies);
var persistence = self.getPersistence();
if (persistence && persistence[mpid]) {
persistence[mpid].lst = time;
self.savePersistence(persistence);
}

@@ -1179,3 +1184,3 @@ };

this.reset_Persistence = function() {
this.resetPersistence = function() {
removeLocalStorage(StorageNames.localStorageName);

@@ -1185,2 +1190,3 @@ removeLocalStorage(StorageNames.localStorageNameV3);

removeLocalStorage(mpInstance._Store.prodStorageName);
removeLocalStorage(mpInstance._Store.storageName);
removeLocalStorage(StorageNames.localStorageProductsV4);

@@ -1192,2 +1198,5 @@

self.expireCookies(StorageNames.cookieNameV4);
self.expireCookies(mpInstance._Store.prodStorageName);
self.expireCookies(mpInstance._Store.storageName);
if (mParticle._isTestEnv) {

@@ -1194,0 +1203,0 @@ var testWorkspaceToken = 'abcdef';

@@ -1,2 +0,2 @@

import * as EventsApi from './eventsApiModels';
import * as EventsApi from '@mparticle/event-models';

@@ -115,3 +115,3 @@ export interface SDKEvent {

config: SDKConfig;
reset(MPConfig: SDKConfig): void;
_resetForTests(MPConfig: SDKConfig): void;
init(apiKey: string, config: SDKConfig): void;

@@ -118,0 +118,0 @@ getInstance();

@@ -12,3 +12,3 @@ import {

} from './sdkRuntimeModels';
import * as EventsApi from './eventsApiModels';
import * as EventsApi from '@mparticle/event-models';
import Types from './types';

@@ -15,0 +15,0 @@

@@ -23,4 +23,4 @@ import Constants from './constants';

} else {
var cookies = mpInstance._Persistence.getPersistence();
if (cookies && !cookies.cu) {
var persistence = mpInstance._Persistence.getPersistence();
if (persistence && !persistence.cu) {
mpInstance.Identity.identify(

@@ -102,5 +102,3 @@ mpInstance._Store.SDKConfig.identifyRequest,

cookies =
mpInstance._Persistence.getCookie() ||
mpInstance._Persistence.getLocalStorage();
cookies = mpInstance._Persistence.getPersistence();

@@ -179,9 +177,7 @@ if (!cookies) {

if (!mpInstance._Store.webviewBridgeEnabled) {
var cookies =
mpInstance._Persistence.getCookie() ||
mpInstance._Persistence.getLocalStorage();
var persistence = mpInstance._Persistence.getPersistence();
if (!mpInstance._Store.sessionId && cookies) {
if (cookies.sid) {
mpInstance._Store.sessionId = cookies.sid;
if (!mpInstance._Store.sessionId && persistence) {
if (persistence.sid) {
mpInstance._Store.sessionId = persistence.sid;
} else {

@@ -188,0 +184,0 @@ self.startNewSession();

@@ -85,14 +85,6 @@ import Constants from './constants';

if (config.hasOwnProperty('serviceUrl')) {
this.SDKConfig.serviceUrl = config.serviceUrl;
if (config.hasOwnProperty('v1SecureServiceUrl')) {
this.SDKConfig.v1SecureServiceUrl = config.v1SecureServiceUrl;
}
if (config.hasOwnProperty('secureServiceUrl')) {
this.SDKConfig.secureServiceUrl = config.secureServiceUrl;
}
if (config.hasOwnProperty('v2ServiceUrl')) {
this.SDKConfig.v2ServiceUrl = config.v2ServiceUrl;
}
if (config.hasOwnProperty('v2SecureServiceUrl')) {

@@ -99,0 +91,0 @@ this.SDKConfig.v2SecureServiceUrl = config.v2SecureServiceUrl;

@@ -15,2 +15,3 @@ let mParticle = {

reset: voidFunction,
_resetForTests: voidFunction,
setAppName: voidFunction,

@@ -17,0 +18,0 @@ setAppVersion: voidFunction,

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc