@mparticle/web-sdk 2.51.0 → 2.53.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.
package/dist/mparticle.js CHANGED
@@ -203,7 +203,7 @@ var mParticle = (function () {
203
203
  Base64: Base64$1
204
204
  };
205
205
 
206
- var version = "2.51.0";
206
+ var version = "2.53.0";
207
207
 
208
208
  var Constants = {
209
209
  sdkVersion: version,
@@ -667,12 +667,17 @@ var mParticle = (function () {
667
667
  var replaceAmpWithAmpersand = function replaceAmpWithAmpersand(value) {
668
668
  return value.replace(/&/g, '&');
669
669
  };
670
- var createCookieSyncUrl = function createCookieSyncUrl(mpid, pixelUrl, redirectUrl) {
670
+ var createCookieSyncUrl = function createCookieSyncUrl(mpid, pixelUrl, redirectUrl, domain) {
671
671
  var modifiedPixelUrl = replaceAmpWithAmpersand(pixelUrl);
672
672
  var modifiedDirectUrl = redirectUrl ? replaceAmpWithAmpersand(redirectUrl) : null;
673
673
  var url = replaceMPID(modifiedPixelUrl, mpid);
674
674
  var redirect = modifiedDirectUrl ? replaceMPID(modifiedDirectUrl, mpid) : '';
675
- return url + encodeURIComponent(redirect);
675
+ var fullUrl = url + encodeURIComponent(redirect);
676
+ if (domain) {
677
+ var separator = fullUrl.includes('?') ? '&' : '?';
678
+ fullUrl += "".concat(separator, "domain=").concat(domain);
679
+ }
680
+ return fullUrl;
676
681
  };
677
682
  // FIXME: REFACTOR for V3
678
683
  // only used in store.js to sanitize server-side formatting of
@@ -1246,6 +1251,12 @@ var mParticle = (function () {
1246
1251
  SDKProductActionType[SDKProductActionType["AddToWishlist"] = 9] = "AddToWishlist";
1247
1252
  SDKProductActionType[SDKProductActionType["RemoveFromWishlist"] = 10] = "RemoveFromWishlist";
1248
1253
  })(SDKProductActionType || (SDKProductActionType = {}));
1254
+ var LogLevelType = {
1255
+ None: 'none',
1256
+ Verbose: 'verbose',
1257
+ Warning: 'warning',
1258
+ Error: 'error'
1259
+ };
1249
1260
 
1250
1261
  function getDefaultExportFromCjs (x) {
1251
1262
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
@@ -2524,13 +2535,13 @@ var mParticle = (function () {
2524
2535
  if (isEmpty(event)) {
2525
2536
  return;
2526
2537
  }
2527
- var verbose = this.mpInstance.Logger.verbose;
2538
+ var Logger = this.mpInstance.Logger;
2528
2539
  this.eventsQueuedForProcessing.push(event);
2529
2540
  if (this.offlineStorageEnabled && this.eventVault) {
2530
2541
  this.eventVault.store(this.eventsQueuedForProcessing);
2531
2542
  }
2532
- verbose("Queuing event: ".concat(JSON.stringify(event)));
2533
- verbose("Queued event count: ".concat(this.eventsQueuedForProcessing.length));
2543
+ Logger.verbose("Queuing event: ".concat(JSON.stringify(event)));
2544
+ Logger.verbose("Queued event count: ".concat(this.eventsQueuedForProcessing.length));
2534
2545
  if (this.shouldTriggerImmediateUpload(event.EventDataType)) {
2535
2546
  this.prepareAndUpload(false, false);
2536
2547
  }
@@ -3474,6 +3485,16 @@ var mParticle = (function () {
3474
3485
  var Messages$7 = Constants.Messages;
3475
3486
  var InformationMessages = Messages$7.InformationMessages;
3476
3487
  var DAYS_IN_MILLISECONDS = 1000 * 60 * 60 * 24;
3488
+ // Partner module IDs for cookie sync configurations
3489
+ var PARTNER_MODULE_IDS = {
3490
+ AdobeEventForwarder: 11,
3491
+ DoubleclickDFP: 41,
3492
+ AppNexus: 50,
3493
+ Lotame: 58,
3494
+ TradeDesk: 103,
3495
+ VerizonMedia: 155,
3496
+ Rokt: 1277
3497
+ };
3477
3498
  function CookieSyncManager(mpInstance) {
3478
3499
  var self = this;
3479
3500
  // Public
@@ -3513,6 +3534,10 @@ var mParticle = (function () {
3513
3534
  if (requiresConsent && mpidIsNotInCookies) {
3514
3535
  return;
3515
3536
  }
3537
+ // For Rokt, block cookie sync when noTargeting privacy flag is true
3538
+ if (moduleId === PARTNER_MODULE_IDS.Rokt && mpInstance._CookieConsentManager.getNoTargeting()) {
3539
+ return;
3540
+ }
3516
3541
  var isEnabledForUserConsent = mpInstance._Consent.isEnabledForUserConsent;
3517
3542
  if (!isEnabledForUserConsent(filteringConsentRuleValues, mpInstance.Identity.getCurrentUser())) {
3518
3543
  return;
@@ -3522,8 +3547,12 @@ var mParticle = (function () {
3522
3547
  if (!isLastSyncDateExpired(frequencyCap, lastSyncDateForModule)) {
3523
3548
  return;
3524
3549
  }
3525
- // Url for cookie sync pixel
3526
- var fullUrl = createCookieSyncUrl(mpid, pixelUrl, redirectUrl);
3550
+ // The Trade Desk requires a URL parameter for GDPR enabled users.
3551
+ // It is optional but to simplify the code, we add it for all Trade
3552
+ // // Desk cookie syncs.
3553
+ var domain = moduleId === PARTNER_MODULE_IDS.TradeDesk ? window.location.hostname : undefined;
3554
+ // Add domain parameter for Trade Desk
3555
+ var fullUrl = createCookieSyncUrl(mpid, pixelUrl, redirectUrl, domain);
3527
3556
  self.performCookieSync(fullUrl, moduleId.toString(), mpid, cookieSyncDates);
3528
3557
  });
3529
3558
  };
@@ -3710,17 +3739,20 @@ var mParticle = (function () {
3710
3739
  var self = this;
3711
3740
  this.initialize = function () {
3712
3741
  if (mpInstance._Store.sessionId) {
3713
- var sessionTimeoutInMilliseconds = mpInstance._Store.SDKConfig.sessionTimeout * 60000;
3714
- if (new Date() > new Date(mpInstance._Store.dateLastEventSent.getTime() + sessionTimeoutInMilliseconds)) {
3742
+ var _a = mpInstance._Store,
3743
+ dateLastEventSent = _a.dateLastEventSent,
3744
+ SDKConfig = _a.SDKConfig;
3745
+ var sessionTimeout = SDKConfig.sessionTimeout;
3746
+ if (hasSessionTimedOut(dateLastEventSent === null || dateLastEventSent === void 0 ? void 0 : dateLastEventSent.getTime(), sessionTimeout)) {
3715
3747
  self.endSession();
3716
3748
  self.startNewSession();
3717
3749
  } else {
3718
3750
  // https://go.mparticle.com/work/SQDSDKS-6045
3719
3751
  // https://go.mparticle.com/work/SQDSDKS-6323
3720
3752
  var currentUser = mpInstance.Identity.getCurrentUser();
3721
- var sdkIdentityRequest = mpInstance._Store.SDKConfig.identifyRequest;
3753
+ var sdkIdentityRequest = SDKConfig.identifyRequest;
3722
3754
  if (hasIdentityRequestChanged(currentUser, sdkIdentityRequest)) {
3723
- mpInstance.Identity.identify(mpInstance._Store.SDKConfig.identifyRequest, mpInstance._Store.SDKConfig.identityCallback);
3755
+ mpInstance.Identity.identify(sdkIdentityRequest, SDKConfig.identityCallback);
3724
3756
  mpInstance._Store.identifyCalled = true;
3725
3757
  mpInstance._Store.SDKConfig.identityCallback = null;
3726
3758
  }
@@ -3764,14 +3796,10 @@ var mParticle = (function () {
3764
3796
  }
3765
3797
  };
3766
3798
  this.endSession = function (override) {
3767
- var _a, _b, _c, _d, _e;
3799
+ var _a, _b, _c, _d;
3768
3800
  mpInstance.Logger.verbose(Messages$6.InformationMessages.StartingEndSession);
3769
3801
  if (override) {
3770
- mpInstance._Events.logEvent({
3771
- messageType: Types.MessageType.SessionEnd
3772
- });
3773
- mpInstance._Store.nullifySession();
3774
- (_a = mpInstance._timeOnSiteTimer) === null || _a === void 0 ? void 0 : _a.resetTimer();
3802
+ performSessionEnd();
3775
3803
  return;
3776
3804
  }
3777
3805
  if (!mpInstance._Helpers.canLog()) {
@@ -3780,36 +3808,28 @@ var mParticle = (function () {
3780
3808
  // - the devToken is undefined
3781
3809
  // - webviewBridgeEnabled is set to false
3782
3810
  mpInstance.Logger.verbose(Messages$6.InformationMessages.AbandonEndSession);
3783
- (_b = mpInstance._timeOnSiteTimer) === null || _b === void 0 ? void 0 : _b.resetTimer();
3811
+ (_a = mpInstance._timeOnSiteTimer) === null || _a === void 0 ? void 0 : _a.resetTimer();
3784
3812
  return;
3785
3813
  }
3786
- var sessionTimeoutInMilliseconds;
3787
- var timeSinceLastEventSent;
3788
3814
  var cookies = mpInstance._Persistence.getPersistence();
3789
3815
  if (!cookies || cookies.gs && !cookies.gs.sid) {
3790
3816
  mpInstance.Logger.verbose(Messages$6.InformationMessages.NoSessionToEnd);
3791
- (_c = mpInstance._timeOnSiteTimer) === null || _c === void 0 ? void 0 : _c.resetTimer();
3817
+ (_b = mpInstance._timeOnSiteTimer) === null || _b === void 0 ? void 0 : _b.resetTimer();
3792
3818
  return;
3793
3819
  }
3794
3820
  // sessionId is not equal to cookies.sid if cookies.sid is changed in another tab
3795
3821
  if (cookies.gs.sid && mpInstance._Store.sessionId !== cookies.gs.sid) {
3796
3822
  mpInstance._Store.sessionId = cookies.gs.sid;
3797
3823
  }
3798
- if ((_d = cookies === null || cookies === void 0 ? void 0 : cookies.gs) === null || _d === void 0 ? void 0 : _d.les) {
3799
- sessionTimeoutInMilliseconds = mpInstance._Store.SDKConfig.sessionTimeout * 60000;
3800
- var newDate = new Date().getTime();
3801
- timeSinceLastEventSent = newDate - cookies.gs.les;
3802
- if (timeSinceLastEventSent < sessionTimeoutInMilliseconds) {
3803
- self.setSessionTimer();
3824
+ if ((_c = cookies === null || cookies === void 0 ? void 0 : cookies.gs) === null || _c === void 0 ? void 0 : _c.les) {
3825
+ var sessionTimeout = mpInstance._Store.SDKConfig.sessionTimeout;
3826
+ if (hasSessionTimedOut(cookies.gs.les, sessionTimeout)) {
3827
+ performSessionEnd();
3804
3828
  } else {
3805
- mpInstance._Events.logEvent({
3806
- messageType: Types.MessageType.SessionEnd
3807
- });
3808
- mpInstance._Store.sessionStartDate = null;
3809
- mpInstance._Store.nullifySession();
3829
+ self.setSessionTimer();
3830
+ (_d = mpInstance._timeOnSiteTimer) === null || _d === void 0 ? void 0 : _d.resetTimer();
3810
3831
  }
3811
3832
  }
3812
- (_e = mpInstance._timeOnSiteTimer) === null || _e === void 0 ? void 0 : _e.resetTimer();
3813
3833
  };
3814
3834
  this.setSessionTimer = function () {
3815
3835
  var sessionTimeoutInMilliseconds = mpInstance._Store.SDKConfig.sessionTimeout * 60000;
@@ -3842,6 +3862,34 @@ var mParticle = (function () {
3842
3862
  }
3843
3863
  }
3844
3864
  };
3865
+ /**
3866
+ * Checks if the session has expired based on the last event timestamp
3867
+ * @param lastEventTimestamp - Unix timestamp in milliseconds of the last event
3868
+ * @param sessionTimeout - Session timeout in minutes
3869
+ * @returns true if the session has expired, false otherwise
3870
+ */
3871
+ function hasSessionTimedOut(lastEventTimestamp, sessionTimeout) {
3872
+ if (!lastEventTimestamp || !sessionTimeout || sessionTimeout <= 0) {
3873
+ return false;
3874
+ }
3875
+ var sessionTimeoutInMilliseconds = sessionTimeout * 60000;
3876
+ var timeSinceLastEvent = Date.now() - lastEventTimestamp;
3877
+ return timeSinceLastEvent >= sessionTimeoutInMilliseconds;
3878
+ }
3879
+ /**
3880
+ * Performs session end operations:
3881
+ * - Logs a SessionEnd event
3882
+ * - Nullifies the session ID and related data
3883
+ * - Resets the time-on-site timer
3884
+ */
3885
+ function performSessionEnd() {
3886
+ var _a;
3887
+ mpInstance._Events.logEvent({
3888
+ messageType: Types.MessageType.SessionEnd
3889
+ });
3890
+ mpInstance._Store.nullifySession();
3891
+ (_a = mpInstance._timeOnSiteTimer) === null || _a === void 0 ? void 0 : _a.resetTimer();
3892
+ }
3845
3893
  }
3846
3894
 
3847
3895
  var Messages$5 = Constants.Messages;
@@ -4702,6 +4750,7 @@ var mParticle = (function () {
4702
4750
  this.nullifySession = function () {
4703
4751
  _this.sessionId = null;
4704
4752
  _this.dateLastEventSent = null;
4753
+ _this.sessionStartDate = null;
4705
4754
  _this.sessionAttributes = {};
4706
4755
  _this.localSessionAttributes = {};
4707
4756
  mpInstance._Persistence.update();
@@ -4826,56 +4875,54 @@ var mParticle = (function () {
4826
4875
  return directBaseUrls;
4827
4876
  }
4828
4877
 
4829
- function Logger(config) {
4830
- var self = this;
4831
- var logLevel = config.logLevel || 'warning';
4832
- if (config.hasOwnProperty('logger')) {
4833
- this.logger = config.logger;
4834
- } else {
4835
- this.logger = new ConsoleLogger();
4878
+ var Logger = /** @class */function () {
4879
+ function Logger(config) {
4880
+ var _a, _b;
4881
+ this.logLevel = (_a = config.logLevel) !== null && _a !== void 0 ? _a : LogLevelType.Warning;
4882
+ this.logger = (_b = config.logger) !== null && _b !== void 0 ? _b : new ConsoleLogger();
4836
4883
  }
4837
- this.verbose = function (msg) {
4838
- if (logLevel !== 'none') {
4839
- if (self.logger.verbose && logLevel === 'verbose') {
4840
- self.logger.verbose(msg);
4841
- }
4884
+ Logger.prototype.verbose = function (msg) {
4885
+ if (this.logLevel === LogLevelType.None) return;
4886
+ if (this.logger.verbose && this.logLevel === LogLevelType.Verbose) {
4887
+ this.logger.verbose(msg);
4842
4888
  }
4843
4889
  };
4844
- this.warning = function (msg) {
4845
- if (logLevel !== 'none') {
4846
- if (self.logger.warning && (logLevel === 'verbose' || logLevel === 'warning')) {
4847
- self.logger.warning(msg);
4848
- }
4890
+ Logger.prototype.warning = function (msg) {
4891
+ if (this.logLevel === LogLevelType.None) return;
4892
+ if (this.logger.warning && (this.logLevel === LogLevelType.Verbose || this.logLevel === LogLevelType.Warning)) {
4893
+ this.logger.warning(msg);
4849
4894
  }
4850
4895
  };
4851
- this.error = function (msg) {
4852
- if (logLevel !== 'none') {
4853
- if (self.logger.error) {
4854
- self.logger.error(msg);
4855
- }
4896
+ Logger.prototype.error = function (msg) {
4897
+ if (this.logLevel === LogLevelType.None) return;
4898
+ if (this.logger.error) {
4899
+ this.logger.error(msg);
4856
4900
  }
4857
4901
  };
4858
- this.setLogLevel = function (newLogLevel) {
4859
- logLevel = newLogLevel;
4902
+ Logger.prototype.setLogLevel = function (newLogLevel) {
4903
+ this.logLevel = newLogLevel;
4860
4904
  };
4861
- }
4862
- function ConsoleLogger() {
4863
- this.verbose = function (msg) {
4905
+ return Logger;
4906
+ }();
4907
+ var ConsoleLogger = /** @class */function () {
4908
+ function ConsoleLogger() {}
4909
+ ConsoleLogger.prototype.verbose = function (msg) {
4864
4910
  if (console && console.info) {
4865
4911
  console.info(msg);
4866
4912
  }
4867
4913
  };
4868
- this.error = function (msg) {
4914
+ ConsoleLogger.prototype.error = function (msg) {
4869
4915
  if (console && console.error) {
4870
4916
  console.error(msg);
4871
4917
  }
4872
4918
  };
4873
- this.warning = function (msg) {
4919
+ ConsoleLogger.prototype.warning = function (msg) {
4874
4920
  if (console && console.warn) {
4875
4921
  console.warn(msg);
4876
4922
  }
4877
4923
  };
4878
- }
4924
+ return ConsoleLogger;
4925
+ }();
4879
4926
 
4880
4927
  var Base64 = Polyfill.Base64,
4881
4928
  Messages$4 = Constants.Messages,
@@ -7362,7 +7409,8 @@ var mParticle = (function () {
7362
7409
  DestinationMpid: aliasRequest.destinationMpid,
7363
7410
  SourceMpid: aliasRequest.sourceMpid,
7364
7411
  StartUnixtimeMs: aliasRequest.startTime,
7365
- EndUnixtimeMs: aliasRequest.endTime
7412
+ EndUnixtimeMs: aliasRequest.endTime,
7413
+ Scope: aliasRequest.scope
7366
7414
  };
7367
7415
  },
7368
7416
  convertToNative: function convertToNative(identityApiData) {
@@ -7662,7 +7710,7 @@ var mParticle = (function () {
7662
7710
  after applying this adjustment it will be impossible to create an aliasRequest passes the aliasUsers()
7663
7711
  validation that the startTime must be less than the endTime
7664
7712
  */
7665
- createAliasRequest: function createAliasRequest(sourceUser, destinationUser) {
7713
+ createAliasRequest: function createAliasRequest(sourceUser, destinationUser, scope) {
7666
7714
  try {
7667
7715
  if (!destinationUser || !sourceUser) {
7668
7716
  mpInstance.Logger.error("'destinationUser' and 'sourceUser' must both be present");
@@ -7689,7 +7737,8 @@ var mParticle = (function () {
7689
7737
  destinationMpid: destinationUser.getMPID(),
7690
7738
  sourceMpid: sourceUser.getMPID(),
7691
7739
  startTime: startTime,
7692
- endTime: endTime
7740
+ endTime: endTime,
7741
+ scope: scope || 'device'
7693
7742
  };
7694
7743
  } catch (e) {
7695
7744
  mpInstance.Logger.error('There was a problem with creating an alias request: ' + e);
@@ -9116,15 +9165,15 @@ var mParticle = (function () {
9116
9165
  function IdentityAPIClient(mpInstance) {
9117
9166
  this.sendAliasRequest = function (aliasRequest, aliasCallback) {
9118
9167
  return __awaiter(this, void 0, void 0, function () {
9119
- var _a, verbose, error, invokeAliasCallback, aliasUrl, apiKey, uploadUrl, uploader, uploadPayload, response, aliasResponseBody, message, errorMessage, _b, xhrResponse, errorResponse, e_2, errorMessage;
9120
- return __generator(this, function (_c) {
9121
- switch (_c.label) {
9168
+ var Logger, invokeAliasCallback, aliasUrl, apiKey, uploadUrl, uploader, uploadPayload, response, aliasResponseBody, message, errorMessage, _a, xhrResponse, errorResponse, e_2, errorMessage;
9169
+ return __generator(this, function (_b) {
9170
+ switch (_b.label) {
9122
9171
  case 0:
9123
- _a = mpInstance.Logger, verbose = _a.verbose, error = _a.error;
9172
+ Logger = mpInstance.Logger;
9124
9173
  invokeAliasCallback = mpInstance._Helpers.invokeAliasCallback;
9125
9174
  aliasUrl = mpInstance._Store.SDKConfig.aliasUrl;
9126
9175
  apiKey = mpInstance._Store.devToken;
9127
- verbose(Messages$1.InformationMessages.SendAliasHttp);
9176
+ Logger.verbose(Messages$1.InformationMessages.SendAliasHttp);
9128
9177
  uploadUrl = "https://".concat(aliasUrl).concat(apiKey, "/Alias");
9129
9178
  uploader = window.fetch ? new FetchUploader(uploadUrl) : new XHRUploader(uploadUrl);
9130
9179
  uploadPayload = {
@@ -9135,17 +9184,17 @@ var mParticle = (function () {
9135
9184
  },
9136
9185
  body: JSON.stringify(aliasRequest)
9137
9186
  };
9138
- _c.label = 1;
9187
+ _b.label = 1;
9139
9188
  case 1:
9140
- _c.trys.push([1, 13,, 14]);
9189
+ _b.trys.push([1, 13,, 14]);
9141
9190
  return [4 /*yield*/, uploader.upload(uploadPayload)];
9142
9191
  case 2:
9143
- response = _c.sent();
9192
+ response = _b.sent();
9144
9193
  aliasResponseBody = void 0;
9145
9194
  message = void 0;
9146
9195
  errorMessage = void 0;
9147
- _b = response.status;
9148
- switch (_b) {
9196
+ _a = response.status;
9197
+ switch (_a) {
9149
9198
  case HTTP_ACCEPTED:
9150
9199
  return [3 /*break*/, 3];
9151
9200
  case HTTP_OK:
@@ -9160,23 +9209,23 @@ var mParticle = (function () {
9160
9209
  return [3 /*break*/, 12];
9161
9210
  case 4:
9162
9211
  if (!response.json) return [3 /*break*/, 9];
9163
- _c.label = 5;
9212
+ _b.label = 5;
9164
9213
  case 5:
9165
- _c.trys.push([5, 7,, 8]);
9214
+ _b.trys.push([5, 7,, 8]);
9166
9215
  return [4 /*yield*/, response.json()];
9167
9216
  case 6:
9168
- aliasResponseBody = _c.sent();
9217
+ aliasResponseBody = _b.sent();
9169
9218
  return [3 /*break*/, 8];
9170
9219
  case 7:
9171
- _c.sent();
9172
- verbose('The request has no response body');
9220
+ _b.sent();
9221
+ Logger.verbose('The request has no response body');
9173
9222
  return [3 /*break*/, 8];
9174
9223
  case 8:
9175
9224
  return [3 /*break*/, 10];
9176
9225
  case 9:
9177
9226
  xhrResponse = response;
9178
9227
  aliasResponseBody = xhrResponse.responseText ? JSON.parse(xhrResponse.responseText) : '';
9179
- _c.label = 10;
9228
+ _b.label = 10;
9180
9229
  case 10:
9181
9230
  errorResponse = aliasResponseBody;
9182
9231
  if (errorResponse === null || errorResponse === void 0 ? void 0 : errorResponse.message) {
@@ -9192,13 +9241,13 @@ var mParticle = (function () {
9192
9241
  throw new Error('Received HTTP Code of ' + response.status);
9193
9242
  }
9194
9243
  case 12:
9195
- verbose(message);
9244
+ Logger.verbose(message);
9196
9245
  invokeAliasCallback(aliasCallback, response.status, errorMessage);
9197
9246
  return [3 /*break*/, 14];
9198
9247
  case 13:
9199
- e_2 = _c.sent();
9248
+ e_2 = _b.sent();
9200
9249
  errorMessage = e_2.message || e_2.toString();
9201
- error('Error sending alias request to mParticle servers. ' + errorMessage);
9250
+ Logger.error('Error sending alias request to mParticle servers. ' + errorMessage);
9202
9251
  invokeAliasCallback(aliasCallback, HTTPCodes$1.noHttpCoverage, errorMessage);
9203
9252
  return [3 /*break*/, 14];
9204
9253
  case 14:
@@ -9210,19 +9259,19 @@ var mParticle = (function () {
9210
9259
 
9211
9260
  this.sendIdentityRequest = function (identityApiRequest, method, callback, originalIdentityApiData, parseIdentityResponse, mpid, knownIdentities) {
9212
9261
  return __awaiter(this, void 0, void 0, function () {
9213
- var _a, verbose, error, invokeCallback, previousMPID, uploadUrl, uploader, fetchPayload, response, identityResponse, message, _b, responseBody, errorResponse, errorMessage, err_1, errorMessage;
9214
- return __generator(this, function (_c) {
9215
- switch (_c.label) {
9262
+ var invokeCallback, Logger, previousMPID, uploadUrl, uploader, fetchPayload, response, identityResponse, message, _a, responseBody, errorResponse, errorMessage, err_1, errorMessage;
9263
+ return __generator(this, function (_b) {
9264
+ switch (_b.label) {
9216
9265
  case 0:
9217
- _a = mpInstance.Logger, verbose = _a.verbose, error = _a.error;
9218
9266
  invokeCallback = mpInstance._Helpers.invokeCallback;
9219
- verbose(Messages$1.InformationMessages.SendIdentityBegin);
9267
+ Logger = mpInstance.Logger;
9268
+ Logger.verbose(Messages$1.InformationMessages.SendIdentityBegin);
9220
9269
  if (!identityApiRequest) {
9221
- error(Messages$1.ErrorMessages.APIRequestEmpty);
9270
+ Logger.error(Messages$1.ErrorMessages.APIRequestEmpty);
9222
9271
  return [2 /*return*/];
9223
9272
  }
9224
9273
 
9225
- verbose(Messages$1.InformationMessages.SendIdentityHttp);
9274
+ Logger.verbose(Messages$1.InformationMessages.SendIdentityHttp);
9226
9275
  if (mpInstance._Store.identityCallInFlight) {
9227
9276
  invokeCallback(callback, HTTPCodes$1.activeIdentityRequest, 'There is currently an Identity request processing. Please wait for this to return before requesting again');
9228
9277
  return [2 /*return*/];
@@ -9241,16 +9290,16 @@ var mParticle = (function () {
9241
9290
  body: JSON.stringify(identityApiRequest)
9242
9291
  };
9243
9292
  mpInstance._Store.identityCallInFlight = true;
9244
- _c.label = 1;
9293
+ _b.label = 1;
9245
9294
  case 1:
9246
- _c.trys.push([1, 9,, 10]);
9295
+ _b.trys.push([1, 9,, 10]);
9247
9296
  return [4 /*yield*/, uploader.upload(fetchPayload)];
9248
9297
  case 2:
9249
- response = _c.sent();
9298
+ response = _b.sent();
9250
9299
  identityResponse = void 0;
9251
9300
  message = void 0;
9252
- _b = response.status;
9253
- switch (_b) {
9301
+ _a = response.status;
9302
+ switch (_a) {
9254
9303
  case HTTP_ACCEPTED:
9255
9304
  return [3 /*break*/, 3];
9256
9305
  case HTTP_OK:
@@ -9263,12 +9312,12 @@ var mParticle = (function () {
9263
9312
  if (!response.json) return [3 /*break*/, 5];
9264
9313
  return [4 /*yield*/, response.json()];
9265
9314
  case 4:
9266
- responseBody = _c.sent();
9315
+ responseBody = _b.sent();
9267
9316
  identityResponse = this.getIdentityResponseFromFetch(response, responseBody);
9268
9317
  return [3 /*break*/, 6];
9269
9318
  case 5:
9270
9319
  identityResponse = this.getIdentityResponseFromXHR(response);
9271
- _c.label = 6;
9320
+ _b.label = 6;
9272
9321
  case 6:
9273
9322
  if (identityResponse.status === HTTP_BAD_REQUEST) {
9274
9323
  errorResponse = identityResponse.responseText;
@@ -9290,14 +9339,14 @@ var mParticle = (function () {
9290
9339
  }
9291
9340
  case 8:
9292
9341
  mpInstance._Store.identityCallInFlight = false;
9293
- verbose(message);
9342
+ Logger.verbose(message);
9294
9343
  parseIdentityResponse(identityResponse, previousMPID, callback, originalIdentityApiData, method, knownIdentities, false);
9295
9344
  return [3 /*break*/, 10];
9296
9345
  case 9:
9297
- err_1 = _c.sent();
9346
+ err_1 = _b.sent();
9298
9347
  mpInstance._Store.identityCallInFlight = false;
9299
9348
  errorMessage = err_1.message || err_1.toString();
9300
- error('Error sending identity request to servers' + ' - ' + errorMessage);
9349
+ Logger.error('Error sending identity request to servers' + ' - ' + errorMessage);
9301
9350
  invokeCallback(callback, HTTPCodes$1.noHttpCoverage, errorMessage);
9302
9351
  return [3 /*break*/, 10];
9303
9352
  case 10:
@@ -9790,17 +9839,73 @@ var mParticle = (function () {
9790
9839
  });
9791
9840
  });
9792
9841
  };
9793
-
9842
+ /**
9843
+ * Hashes attributes and returns both original and hashed versions
9844
+ * with Rokt-compatible key names (like emailsha256, mobilesha256)
9845
+ *
9846
+ *
9847
+ * @param {IRoktPartnerAttributes} attributes - Attributes to hash
9848
+ * @returns {Promise<IRoktPartnerAttributes>} Object with both original and hashed attributes
9849
+ *
9850
+ */
9794
9851
  RoktManager.prototype.hashAttributes = function (attributes) {
9795
- if (!this.isReady()) {
9796
- return this.deferredCall('hashAttributes', attributes);
9797
- }
9798
- try {
9799
- return this.kit.hashAttributes(attributes);
9800
- } catch (error) {
9801
- return Promise.reject(error instanceof Error ? error : new Error('Unknown error occurred'));
9802
- }
9852
+ return __awaiter(this, void 0, void 0, function () {
9853
+ var keys, hashPromises, results, hashedAttributes, _i, results_1, _a, key, attributeValue, hashedValue, error_3, errorMessage;
9854
+ var _this = this;
9855
+ return __generator(this, function (_b) {
9856
+ switch (_b.label) {
9857
+ case 0:
9858
+ _b.trys.push([0, 2,, 3]);
9859
+ if (!attributes || _typeof$1(attributes) !== 'object') {
9860
+ return [2 /*return*/, {}];
9861
+ }
9862
+ keys = Object.keys(attributes);
9863
+ if (keys.length === 0) {
9864
+ return [2 /*return*/, {}];
9865
+ }
9866
+ hashPromises = keys.map(function (key) {
9867
+ return __awaiter(_this, void 0, void 0, function () {
9868
+ var attributeValue, hashedValue;
9869
+ return __generator(this, function (_a) {
9870
+ switch (_a.label) {
9871
+ case 0:
9872
+ attributeValue = attributes[key];
9873
+ return [4 /*yield*/, this.hashSha256(attributeValue)];
9874
+ case 1:
9875
+ hashedValue = _a.sent();
9876
+ return [2 /*return*/, {
9877
+ key: key,
9878
+ attributeValue: attributeValue,
9879
+ hashedValue: hashedValue
9880
+ }];
9881
+ }
9882
+ });
9883
+ });
9884
+ });
9885
+ return [4 /*yield*/, Promise.all(hashPromises)];
9886
+ case 1:
9887
+ results = _b.sent();
9888
+ hashedAttributes = {};
9889
+ for (_i = 0, results_1 = results; _i < results_1.length; _i++) {
9890
+ _a = results_1[_i], key = _a.key, attributeValue = _a.attributeValue, hashedValue = _a.hashedValue;
9891
+ hashedAttributes[key] = attributeValue;
9892
+ if (hashedValue) {
9893
+ hashedAttributes["".concat(key, "sha256")] = hashedValue;
9894
+ }
9895
+ }
9896
+ return [2 /*return*/, hashedAttributes];
9897
+ case 2:
9898
+ error_3 = _b.sent();
9899
+ errorMessage = error_3 instanceof Error ? error_3.message : String(error_3);
9900
+ this.logger.error("Failed to hashAttributes, returning an empty object: ".concat(errorMessage));
9901
+ return [2 /*return*/, {}];
9902
+ case 3:
9903
+ return [2 /*return*/];
9904
+ }
9905
+ });
9906
+ });
9803
9907
  };
9908
+
9804
9909
  RoktManager.prototype.setExtensionData = function (extensionData) {
9805
9910
  if (!this.isReady()) {
9806
9911
  this.deferredCall('setExtensionData', extensionData);
@@ -9823,6 +9928,42 @@ var mParticle = (function () {
9823
9928
  return Promise.reject(error instanceof Error ? error : new Error('Error using extension: ' + name));
9824
9929
  }
9825
9930
  };
9931
+ /**
9932
+ * Hashes an attribute using SHA-256
9933
+ *
9934
+ * @param {string | number | boolean | undefined | null} attribute - The value to hash
9935
+ * @returns {Promise<string | undefined | null>} SHA-256 hashed value or undefined/null
9936
+ *
9937
+ */
9938
+ RoktManager.prototype.hashSha256 = function (attribute) {
9939
+ return __awaiter(this, void 0, void 0, function () {
9940
+ var normalizedValue, error_4, errorMessage;
9941
+ return __generator(this, function (_a) {
9942
+ switch (_a.label) {
9943
+ case 0:
9944
+ if (attribute === null || attribute === undefined) {
9945
+ this.logger.warning("hashSha256 received null/undefined as input");
9946
+ return [2 /*return*/, attribute];
9947
+ }
9948
+ _a.label = 1;
9949
+ case 1:
9950
+ _a.trys.push([1, 3,, 4]);
9951
+ normalizedValue = String(attribute).trim().toLocaleLowerCase();
9952
+ return [4 /*yield*/, this.sha256Hex(normalizedValue)];
9953
+ case 2:
9954
+ return [2 /*return*/, _a.sent()];
9955
+ case 3:
9956
+ error_4 = _a.sent();
9957
+ errorMessage = error_4 instanceof Error ? error_4.message : String(error_4);
9958
+ this.logger.error("Failed to hashSha256, returning undefined: ".concat(errorMessage));
9959
+ return [2 /*return*/, undefined];
9960
+ case 4:
9961
+ return [2 /*return*/];
9962
+ }
9963
+ });
9964
+ });
9965
+ };
9966
+
9826
9967
  RoktManager.prototype.getLocalSessionAttributes = function () {
9827
9968
  return this.store.getLocalSessionAttributes();
9828
9969
  };
@@ -9918,6 +10059,45 @@ var mParticle = (function () {
9918
10059
  }
9919
10060
  this.messageQueue["delete"](messageId);
9920
10061
  };
10062
+ /**
10063
+ * Hashes a string input using SHA-256 and returns the hex digest
10064
+ * Uses the Web Crypto API for secure hashing
10065
+ *
10066
+ * @param {string} input - The string to hash
10067
+ * @returns {Promise<string>} The SHA-256 hash as a hexadecimal string
10068
+ */
10069
+ RoktManager.prototype.sha256Hex = function (input) {
10070
+ return __awaiter(this, void 0, void 0, function () {
10071
+ var encoder, encodedInput, digest;
10072
+ return __generator(this, function (_a) {
10073
+ switch (_a.label) {
10074
+ case 0:
10075
+ encoder = new TextEncoder();
10076
+ encodedInput = encoder.encode(input);
10077
+ return [4 /*yield*/, crypto.subtle.digest('SHA-256', encodedInput)];
10078
+ case 1:
10079
+ digest = _a.sent();
10080
+ return [2 /*return*/, this.arrayBufferToHex(digest)];
10081
+ }
10082
+ });
10083
+ });
10084
+ };
10085
+ /**
10086
+ * Converts an ArrayBuffer to a hexadecimal string representation
10087
+ * Each byte is converted to a 2-character hex string with leading zeros
10088
+ *
10089
+ * @param {ArrayBuffer} buffer - The buffer to convert
10090
+ * @returns {string} The hexadecimal string representation
10091
+ */
10092
+ RoktManager.prototype.arrayBufferToHex = function (buffer) {
10093
+ var bytes = new Uint8Array(buffer);
10094
+ var hexString = '';
10095
+ for (var i = 0; i < bytes.length; i++) {
10096
+ var hexByte = bytes[i].toString(16).padStart(2, '0');
10097
+ hexString += hexByte;
10098
+ }
10099
+ return hexString;
10100
+ };
9921
10101
  /**
9922
10102
  * Checks if an identity value has changed by comparing current and new values
9923
10103
  *
@@ -9943,6 +10123,40 @@ var mParticle = (function () {
9943
10123
  return RoktManager;
9944
10124
  }();
9945
10125
 
10126
+ /**
10127
+ * CookieConsentManager handles storage and access of consent flags (noFunctional, noTargeting)
10128
+ * that are passed via launcherOptions during SDK initialization.
10129
+ *
10130
+ * These flags allow Rokt integration to respect user privacy choices.
10131
+ *
10132
+ * Default behavior: Both flags default to false, meaning all features are allowed
10133
+ * unless explicitly opted out by the user.
10134
+ */
10135
+ var CookieConsentManager = /** @class */function () {
10136
+ function CookieConsentManager(flags) {
10137
+ this.flags = flags;
10138
+ this.flags = {
10139
+ noFunctional: flags.noFunctional === true,
10140
+ noTargeting: flags.noTargeting === true
10141
+ };
10142
+ }
10143
+ /**
10144
+ * Returns true if third-party targeting is disabled.
10145
+ * Targeting is allowed when noTargeting is false (default).
10146
+ */
10147
+ CookieConsentManager.prototype.getNoTargeting = function () {
10148
+ return this.flags.noTargeting;
10149
+ };
10150
+ /**
10151
+ * Returns true if functional tracking is disabled.
10152
+ * Functional tracking is allowed when noFunctional is false (default).
10153
+ */
10154
+ CookieConsentManager.prototype.getNoFunctional = function () {
10155
+ return this.flags.noFunctional;
10156
+ };
10157
+ return CookieConsentManager;
10158
+ }();
10159
+
9946
10160
  var Messages = Constants.Messages,
9947
10161
  HTTPCodes = Constants.HTTPCodes,
9948
10162
  FeatureFlags = Constants.FeatureFlags,
@@ -10055,6 +10269,7 @@ var mParticle = (function () {
10055
10269
  if (instance._Store) {
10056
10270
  delete instance._Store;
10057
10271
  }
10272
+ instance.Logger = new Logger(config);
10058
10273
  instance._Store = new Store(config, instance);
10059
10274
  instance._Store.isLocalStorageAvailable = instance._Persistence.determineLocalStorageAvailability(window.localStorage);
10060
10275
  instance._Events.stopTracking();
@@ -11019,10 +11234,19 @@ var mParticle = (function () {
11019
11234
  });
11020
11235
  }
11021
11236
  function runPreConfigFetchInitialization(mpInstance, apiKey, config) {
11237
+ var _a;
11022
11238
  mpInstance.Logger = new Logger(config);
11023
11239
  mpInstance._Store = new Store(config, mpInstance, apiKey);
11024
11240
  window.mParticle.Store = mpInstance._Store;
11025
11241
  mpInstance.Logger.verbose(StartingInitialization);
11242
+ // Initialize CookieConsentManager with privacy flags from launcherOptions
11243
+ var _b = (_a = config === null || config === void 0 ? void 0 : config.launcherOptions) !== null && _a !== void 0 ? _a : {},
11244
+ noFunctional = _b.noFunctional,
11245
+ noTargeting = _b.noTargeting;
11246
+ mpInstance._CookieConsentManager = new CookieConsentManager({
11247
+ noFunctional: noFunctional,
11248
+ noTargeting: noTargeting
11249
+ });
11026
11250
  // Check to see if localStorage is available before main configuration runs
11027
11251
  // since we will need this for the current implementation of user persistence
11028
11252
  // TODO: Refactor this when we refactor User Identity Persistence
@@ -11467,8 +11691,8 @@ var mParticle = (function () {
11467
11691
  aliasUsers: function aliasUsers(aliasRequest, callback) {
11468
11692
  self.getInstance().Identity.aliasUsers(aliasRequest, callback);
11469
11693
  },
11470
- createAliasRequest: function createAliasRequest(sourceUser, destinationUser) {
11471
- return self.getInstance().Identity.createAliasRequest(sourceUser, destinationUser);
11694
+ createAliasRequest: function createAliasRequest(sourceUser, destinationUser, scope) {
11695
+ return self.getInstance().Identity.createAliasRequest(sourceUser, destinationUser, scope);
11472
11696
  },
11473
11697
  getCurrentUser: function getCurrentUser() {
11474
11698
  return self.getInstance().Identity.getCurrentUser();