Socket
Socket
Sign inDemoInstall

@ns8/ns8-shopify-switches

Package Overview
Dependencies
158
Maintainers
37
Versions
195
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.189 to 1.0.190

42

dist/ShopifyCreateOrderActionSwitch.js

@@ -7,2 +7,3 @@ "use strict";

const Logger_1 = require("./Logger");
const ns8_protect_api_client_1 = require("@ns8/ns8-protect-api-client");
const formatPhoneNumber = (phoneNumberString, countryCode) => {

@@ -286,7 +287,10 @@ let phoneNumber;

}
exports.processCreateOrderActionContext = processCreateOrderActionContext;
class ShopifyCreateOrderActionSwitch {
async create(switchContext) {
try {
const order = await processCreateOrderActionContext(switchContext);
return order;
const orderExistsInProtect = await CreateOrderActionHelpers.scoredOrderExistsInProtect(switchContext);
return orderExistsInProtect
? undefined
: await CreateOrderActionHelpers.processCreateOrderActionContext(switchContext);
}

@@ -300,2 +304,36 @@ catch (err) {

exports.ShopifyCreateOrderActionSwitch = ShopifyCreateOrderActionSwitch;
class CreateOrderActionHelpers {
static async getExistingOrder(switchContext) {
try {
const accessToken = switchContext.merchant.accessTokens[0].id;
const merchantId = switchContext.merchant.id;
const protectApi = new ns8_protect_api_client_1.ProtectAPIClient(switchContext.apiBaseUrl);
const order = await protectApi.getOrderByPlatformId(switchContext.data.order_id, accessToken, merchantId);
return order;
}
catch (err) {
return undefined;
}
}
static orderHasBeenScored(order) {
if (order && order.fraudAssessments) {
const assessments = order.fraudAssessments;
const eq8Assessment = assessments.find((assessment) => assessment.providerType === ns8_protect_models_1.ProviderType.EQ8);
const minFraudAssessment = assessments.find((assessment) => assessment.providerType === ns8_protect_models_1.ProviderType.MIN_FRAUD);
return eq8Assessment != null && minFraudAssessment != null;
}
return false;
}
static async scoredOrderExistsInProtect(switchContext) {
const existingOrder = await CreateOrderActionHelpers.getExistingOrder(switchContext);
if (existingOrder && CreateOrderActionHelpers.orderHasBeenScored(existingOrder)) {
return true;
}
return false;
}
static async processCreateOrderActionContext(switchContext) {
return processCreateOrderActionContext(switchContext);
}
}
exports.CreateOrderActionHelpers = CreateOrderActionHelpers;
//# sourceMappingURL=ShopifyCreateOrderActionSwitch.js.map

6

package.json
{
"name": "@ns8/ns8-shopify-switches",
"version": "1.0.189",
"version": "1.0.190",
"description": "Custom switches for the shopify integration",

@@ -16,3 +16,4 @@ "main": "dist/index.js",

"lint": "tslint --project .",
"test": "nyc mocha --colors"
"test": "nyc mocha --colors",
"test:only": "mocha --colors"
},

@@ -34,2 +35,3 @@ "devDependencies": {

"dependencies": {
"@ns8/ns8-protect-api-client": "^0.0.8",
"isomorphic-fetch": "^2.2.1",

@@ -36,0 +38,0 @@ "libhoney": "^2.0.1",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc