Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@mparticle/web-sdk

Package Overview
Dependencies
Maintainers
0
Versions
115
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.28.2 to 2.28.3

src/aliasRequestApiClient.ts

2

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

@@ -5,0 +5,0 @@ "license": "Apache-2.0",

@@ -192,2 +192,8 @@ import { version } from '../package.json';

export const ONE_DAY_IN_SECONDS = 60 * 60 * 24;
export const MILLIS_IN_ONE_SEC = 1000;
export const MILLIS_IN_ONE_SEC = 1000;
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Status
export const HTTP_OK = 200 as const;
export const HTTP_ACCEPTED = 202 as const;
export const HTTP_BAD_REQUEST = 400 as const;
export const HTTP_FORBIDDEN = 403 as const;

@@ -118,2 +118,11 @@ import { IdentityApiData, MPID, UserIdentities } from '@mparticle/web-sdk';

export interface IAliasCallback {
(result: IAliasResult): void;
}
export interface IAliasResult {
httpCode: number;
message: string;
}
export interface SDKIdentityApi {

@@ -120,0 +129,0 @@ HTTPCodes: typeof HTTPCodes;

import Constants from './constants';
import { xhrIdentityResponseAdapter } from './identity-utils';
import { sendAliasRequest } from './aliasRequestApiClient';

@@ -10,55 +11,4 @@ var HTTPCodes = Constants.HTTPCodes,

export default function IdentityAPIClient(mpInstance) {
this.sendAliasRequest = function(aliasRequest, callback) {
var xhr,
xhrCallback = function() {
if (xhr.readyState === 4) {
// https://go.mparticle.com/work/SQDSDKS-6368
mpInstance.Logger.verbose(
'Received ' + xhr.statusText + ' from server'
);
//only parse error messages from failing requests
if (xhr.status !== 200 && xhr.status !== 202) {
if (xhr.responseText) {
var response = JSON.parse(xhr.responseText);
if (response.hasOwnProperty('message')) {
var errorMessage = response.message;
mpInstance._Helpers.invokeAliasCallback(
callback,
xhr.status,
errorMessage
);
return;
}
}
}
mpInstance._Helpers.invokeAliasCallback(
callback,
xhr.status
);
}
};
mpInstance.Logger.verbose(Messages.InformationMessages.SendAliasHttp);
xhr = mpInstance._Helpers.createXHR(xhrCallback);
if (xhr) {
try {
xhr.open(
'post',
mpInstance._Helpers.createServiceUrl(
mpInstance._Store.SDKConfig.aliasUrl,
mpInstance._Store.devToken
) + '/Alias'
);
xhr.send(JSON.stringify(aliasRequest));
} catch (e) {
mpInstance._Helpers.invokeAliasCallback(
callback,
HTTPCodes.noHttpCoverage,
e
);
mpInstance.Logger.error(
'Error sending alias request to mParticle servers. ' + e
);
}
}
this.sendAliasRequest = async function(aliasRequest, callback) {
await sendAliasRequest(mpInstance, aliasRequest, callback);
};

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

@@ -19,4 +19,8 @@ import * as EventsApi from '@mparticle/event-models';

import { Kit, MPForwarder } from './forwarders.interfaces';
import { IIdentity, SDKIdentityApi } from './identity.interfaces';
import {
IIdentity,
SDKIdentityApi,
IAliasCallback,
} from './identity.interfaces';
import {
ISDKUserAttributeChangeData,

@@ -269,2 +273,7 @@ ISDKUserIdentityChanges,

getFeatureFlag?(feature: string): boolean | string; // TODO: Feature Constants should be converted to enum
invokeAliasCallback(
aliasCallback: IAliasCallback,
number: number,
errorMessage: string
): void;
isDelayedByIntegration?(

@@ -271,0 +280,0 @@ delayedIntegrations: Dictionary<boolean>,

@@ -50,2 +50,3 @@ export interface fetchPayload {

// https://go.mparticle.com/work/SQDSDKS-6736
private async makeRequest(

@@ -62,9 +63,13 @@ url: string,

// Process the response
if (xhr.status >= 200 && xhr.status < 300) {
resolve(xhr as unknown as Response);
} else {
reject(xhr);
}
// We resolve all xhr responses whose ready state is 4 regardless of HTTP codes that may be errors (400+)
// because these are valid HTTP responses.
resolve((xhr as unknown) as Response);
};
// Reject a promise only when there is an xhr error
xhr.onerror = () => {
reject((xhr as unknown) as Response);
};
xhr.open(method, url);

@@ -71,0 +76,0 @@ xhr.send(data);

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

export const HTTP_SUCCESS = 200 as const;
const createCookieString = (value: string): string =>

@@ -16,0 +14,0 @@ replaceCommasWithPipes(replaceQuotesWithApostrophes(value));

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