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.190 to 1.0.191

5

dist/cancelShopifyOrder.js

@@ -41,4 +41,4 @@ "use strict";

let voidTransactionResults;
let cancelOrderResults;
const { id } = order;
const cancelOrderResults = await cancelUnpaidOrder(shopifyClient, id, email);
const transactions = await getTransactions(shopifyClient, id);

@@ -48,3 +48,3 @@ if (transactions instanceof Error) {

}
const transaction = transactions.find((transaction) => transaction.kind === 'authorization');
const transaction = transactions.find((tx) => tx.kind === 'authorization');
if (transaction) {

@@ -62,3 +62,2 @@ voidTransactionResults = await voidTransaction(shopifyClient, transaction);

}
cancelOrderResults = await cancelUnpaidOrder(shopifyClient, id, email);
if (cancelOrderResults instanceof Error) {

@@ -65,0 +64,0 @@ returnMessage = `${returnMessage} --- ${cancelOrderResults}`;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const getOrder = async (shopifyClient, orderId) => (await shopifyClient.order.get(orderId, { fields: 'financial_status' }).catch((error) => new Error(`Could not fetch order. ${JSON.stringify(error)}`)));
const getOrder = async (shopifyClient, orderId) => (shopifyClient.order.get(orderId, { fields: 'financial_status' }).catch((error) => new Error(`Could not fetch order. ${JSON.stringify(error)}`)));
const createCaptureTransaction = async (shopifyClient, orderId) => {
const paymentCaptureResults = await shopifyClient.transaction.create(orderId, { kind: 'capture' })
const paymentCaptureResults = await shopifyClient
.transaction.create(orderId, { kind: 'capture' })
.catch((error) => new Error(`Could not create capture transaction. ${JSON.stringify(error)}`));

@@ -7,0 +8,0 @@ return paymentCaptureResults instanceof Error ? paymentCaptureResults : 'Payment captured successfully.';

2

dist/flow/getTriggerId.js

@@ -31,3 +31,3 @@ "use strict";

let triggerId = exports.triggerIdMap[triggerName].prod;
if (testPattern.test(process.env['AWS_LAMBDA_FUNCTION_NAME'])) {
if (testPattern.test(process.env.AWS_LAMBDA_FUNCTION_NAME)) {
triggerId = exports.triggerIdMap[triggerName].test;

@@ -34,0 +34,0 @@ }

@@ -23,5 +23,5 @@ "use strict";

}`;
return await shopifyGraphQL_1.default.post(shopifyGraphQL_1.default.getUrl(domain), shopifyGraphQL_1.default.getHeaders(accessToken), query);
return shopifyGraphQL_1.default.post(shopifyGraphQL_1.default.getUrl(domain), shopifyGraphQL_1.default.getHeaders(accessToken), query);
};
exports.default = sendCustomerVerificationTrigger;
//# sourceMappingURL=sendCustomerVerificationTrigger.js.map

@@ -23,5 +23,5 @@ "use strict";

}`;
return await shopifyGraphQL_1.default.post(shopifyGraphQL_1.default.getUrl(domain), shopifyGraphQL_1.default.getHeaders(accessToken), query);
return shopifyGraphQL_1.default.post(shopifyGraphQL_1.default.getUrl(domain), shopifyGraphQL_1.default.getHeaders(accessToken), query);
};
exports.default = sendEQ8ScoreTrigger;
//# sourceMappingURL=sendEQ8ScoreTrigger.js.map

@@ -23,5 +23,5 @@ "use strict";

}`;
return await shopifyGraphQL_1.default.post(shopifyGraphQL_1.default.getUrl(domain), shopifyGraphQL_1.default.getHeaders(accessToken), query);
return shopifyGraphQL_1.default.post(shopifyGraphQL_1.default.getUrl(domain), shopifyGraphQL_1.default.getHeaders(accessToken), query);
};
exports.default = sendOrderRiskTrigger;
//# sourceMappingURL=sendOrderRiskTrigger.js.map

@@ -23,5 +23,5 @@ "use strict";

}`;
return await shopifyGraphQL_1.default.post(shopifyGraphQL_1.default.getUrl(domain), shopifyGraphQL_1.default.getHeaders(accessToken), query);
return shopifyGraphQL_1.default.post(shopifyGraphQL_1.default.getUrl(domain), shopifyGraphQL_1.default.getHeaders(accessToken), query);
};
exports.default = sendOrderStatusTrigger;
//# sourceMappingURL=sendOrderStatusTrigger.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const getAllLocations = async (shopifyClient) => (await shopifyClient.location.list()
const getAllLocations = async (shopifyClient) => (shopifyClient.location.list()
.catch((error) => new Error(`Could not fetch locations. ${JSON.stringify(error)}`)));
const getPhysicalLocations = (locations) => (locations.filter((location) => location.active && !location.legacy));
const getFulfillmentServices = async (shopifyClient) => (await shopifyClient.fulfillmentService.list({ scope: 'all' })
const getFulfillmentServices = async (shopifyClient) => (shopifyClient.fulfillmentService.list({ scope: 'all' })
.catch((error) => new Error(`Could not fetch fulfillment services. ${JSON.stringify(error)}`)));

@@ -8,0 +8,0 @@ const hasCustomFulfillmentService = (allLocations) => (allLocations.some((location) => location.active && location.legacy));

@@ -40,4 +40,3 @@ "use strict";

if (Logger.honeycombWritekey == null || Logger.honeycombDataset == null) {
const honeycombClient = this.intializeHoneycombWithCurrentEnv();
return honeycombClient;
return this.intializeHoneycombWithCurrentEnv();
}

@@ -47,3 +46,3 @@ return new Libhoney({

dataset: Logger.honeycombDataset,
disabled: disabled ? true : false,
disabled: !!disabled,
});

@@ -67,12 +66,12 @@ }

dataset: process.env.HONEYCOMB_DATASET,
disabled: disabled ? true : false,
disabled: !!disabled,
});
}
static logToHoneycomb(type, data, context, label) {
if (Logger.honeycombClient == null || Logger.honeycombClient.newEvent == null) {
return undefined;
if (Logger.honeycombClient != null && Logger.honeycombClient.newEvent != null) {
const honeycombEvent = Logger.honeycombClient.newEvent();
honeycombEvent.add(Object.assign({ message: label, messageType: type, functionName: context.functionName, functionVersion: context.functionVersion, requestId: context.awsRequestId, stage: process.env.STAGE, switchContext: context }, data));
honeycombEvent.send();
}
const honeycombEvent = Logger.honeycombClient.newEvent();
honeycombEvent.add(Object.assign({ message: label, messageType: type, functionName: context.functionName, functionVersion: context.functionVersion, requestId: context.awsRequestId, stage: process.env.STAGE, switchContext: context }, data));
honeycombEvent.send();
return undefined;
}

@@ -84,3 +83,3 @@ static getHoneycombConfigDetails(disabled) {

isDatasetNull: Logger.honeycombDataset == null,
isDisabledFlagActive: disabled ? true : false,
isDisabledFlagActive: !!disabled,
dataset: Logger.honeycombDataset,

@@ -105,4 +104,3 @@ nodeEnv: process.env.NODE_ENV,

if (context == null) {
const emptyContext = { context: 'None' };
return emptyContext;
return { context: 'None' };
}

@@ -109,0 +107,0 @@ if (!Array.isArray(context) && typeof context === 'object') {

@@ -33,3 +33,3 @@ "use strict";

await client.orderRisk.create(orderId, primaryOrderRisk);
return await Promise.all(fraudAssessments
return Promise.all(fraudAssessments
.filter((fraudAssessment) => (fraudAssessment.providerType === 'EQ8' || fraudAssessment.providerType === 'MIN_FRAUD')).map((fraudAssessment) => (fraudAssessment.factors

@@ -36,0 +36,0 @@ .map((factor) => (client.orderRisk.create(orderId, {

@@ -5,5 +5,5 @@ "use strict";

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

@@ -42,3 +42,3 @@ let phoneNumber;

lastName: last_name || default_address.last_name,
totalSpent: isNaN(parseFloat(total_spent)) ? undefined : parseFloat(total_spent),
totalSpent: Number.isNaN(parseFloat(total_spent)) ? undefined : parseFloat(total_spent),
platformCreatedAt: new Date(created_at),

@@ -66,20 +66,18 @@ });

};
const mapLineItems = (lineItems) => {
return (lineItems.map((lineItem) => {
const { title, name, quantity, price, sku, variant_id, variant_title, vendor, product_id, gift_card, total_discount, } = lineItem;
return new ns8_protect_models_1.LineItem({
title,
name,
quantity,
sku,
vendor,
price: parseFloat(price),
variantId: variant_id ? variant_id.toString() : '',
variantTitle: variant_title,
platformProductId: product_id ? product_id.toString() : '',
isGiftCard: gift_card,
totalDiscount: parseFloat(total_discount),
});
}));
};
const mapLineItems = (lineItems) => (lineItems.map((lineItem) => {
const { title, name, quantity, price, sku, variant_id, variant_title, vendor, product_id, gift_card, total_discount, } = lineItem;
return new ns8_protect_models_1.LineItem({
title,
name,
quantity,
sku,
vendor,
price: parseFloat(price),
variantId: variant_id ? variant_id.toString() : '',
variantTitle: variant_title,
platformProductId: product_id ? product_id.toString() : '',
isGiftCard: gift_card,
totalDiscount: parseFloat(total_discount),
});
}));
exports.mapLineItems = mapLineItems;

@@ -121,15 +119,13 @@ const hasGiftCard = (lineItems) => (lineItems.some((item) => item.gift_card));

}
else if (gateway === 'Money Order') {
transactionPartial.method = ns8_protect_models_1.TransactionMethod.CHECK;
}
else if (gateway === 'Bank Deposit') {
transactionPartial.method = ns8_protect_models_1.TransactionMethod.BANK_WIRE;
}
else if (gateway === 'Cash on Delivery (COD)') {
transactionPartial.method = ns8_protect_models_1.TransactionMethod.COD;
}
else {
if (gateway === 'Money Order') {
transactionPartial.method = ns8_protect_models_1.TransactionMethod.CHECK;
}
else if (gateway === 'Bank Deposit') {
transactionPartial.method = ns8_protect_models_1.TransactionMethod.BANK_WIRE;
}
else if (gateway === 'Cash on Delivery (COD)') {
transactionPartial.method = ns8_protect_models_1.TransactionMethod.COD;
}
else {
transactionPartial.method = ns8_protect_models_1.TransactionMethod.OTHER;
}
transactionPartial.method = ns8_protect_models_1.TransactionMethod.OTHER;
}

@@ -145,4 +141,4 @@ return new ns8_protect_models_1.Transaction(transactionPartial);

session_hash: null,
user_agent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14) ' +
'AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0 Safari/605.1.15',
user_agent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14) '
+ 'AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0 Safari/605.1.15',
});

@@ -195,3 +191,3 @@ exports.makeTestClientDetails = makeTestClientDetails;

else {
clientDetails = new Error(`Client details cannot be derived from this order.`);
clientDetails = new Error('Client details cannot be derived from this order.');
}

@@ -212,5 +208,5 @@ if (!(clientDetails instanceof Error)) {

let shouldProcessOrder = false;
if (!payment_details &&
kind !== 'void' && kind !== 'refund' && kind !== 'capture' &&
(status === 'pending' || status === 'success')) {
if (!payment_details
&& kind !== 'void' && kind !== 'refund' && kind !== 'capture'
&& (status === 'pending' || status === 'success')) {
shouldProcessOrder = true;

@@ -251,4 +247,4 @@ }

const { id, name, currency, billing_address, shipping_address, customer, total_price, line_items = [], created_at, } = shopifyOrder;
if (switchContext.data.kind === 'capture' &&
shopifyTransactionList.every((transaction) => transaction.kind !== 'authorization')) {
if (switchContext.data.kind === 'capture'
&& shopifyTransactionList.every((transaction) => transaction.kind !== 'authorization')) {
console.log('capture without authorization', JSON.stringify({

@@ -295,17 +291,2 @@ orderId: id,

exports.processCreateOrderActionContext = processCreateOrderActionContext;
class ShopifyCreateOrderActionSwitch {
async create(switchContext) {
try {
const orderExistsInProtect = await CreateOrderActionHelpers.scoredOrderExistsInProtect(switchContext);
return orderExistsInProtect
? undefined
: await CreateOrderActionHelpers.processCreateOrderActionContext(switchContext);
}
catch (err) {
Logger_1.Logger.error(err, switchContext, 'ShopifyCreateOrderActionSwitch');
throw err;
}
}
}
exports.ShopifyCreateOrderActionSwitch = ShopifyCreateOrderActionSwitch;
class CreateOrderActionHelpers {

@@ -327,4 +308,6 @@ static async getExistingOrder(switchContext) {

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);
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;

@@ -346,2 +329,17 @@ }

exports.CreateOrderActionHelpers = CreateOrderActionHelpers;
class ShopifyCreateOrderActionSwitch {
async create(switchContext) {
try {
const orderExistsInProtect = await CreateOrderActionHelpers.scoredOrderExistsInProtect(switchContext);
return orderExistsInProtect
? undefined
: await CreateOrderActionHelpers.processCreateOrderActionContext(switchContext);
}
catch (err) {
Logger_1.Logger.error(err, switchContext, 'ShopifyCreateOrderActionSwitch');
throw err;
}
}
}
exports.ShopifyCreateOrderActionSwitch = ShopifyCreateOrderActionSwitch;
//# sourceMappingURL=ShopifyCreateOrderActionSwitch.js.map

@@ -21,3 +21,3 @@ "use strict";

};
return await fetch(url.toString(), options);
return fetch(url.toString(), options);
},

@@ -24,0 +24,0 @@ };

@@ -57,3 +57,3 @@ "use strict";

}));
return await Promise.all(pendingInstallations);
return Promise.all(pendingInstallations);
};

@@ -60,0 +60,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const ns8_protect_models_1 = require("ns8-protect-models");
const getPlatformOrderDetails_1 = require("./getPlatformOrderDetails");

@@ -8,3 +9,2 @@ const getShopifyClient_1 = require("./getShopifyClient");

const fulfillOrder_1 = require("./fulfillOrder");
const ns8_protect_models_1 = require("ns8-protect-models");
const sendOrderStatusTrigger_1 = require("./flow/sendOrderStatusTrigger");

@@ -11,0 +11,0 @@ class ShopifyUpdateOrderStatusEventSwitch {

{
"name": "@ns8/ns8-shopify-switches",
"version": "1.0.190",
"version": "1.0.191",
"description": "Custom switches for the shopify integration",

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

"build": "rm -rf dist && tsc && rm -rf node_modules && yarn install --production=true",
"lint": "tslint --project .",
"lint": "eslint src/** --ext ts",
"test": "nyc mocha --colors",

@@ -23,11 +23,14 @@ "test:only": "mocha --colors"

"@types/mocha": "^5.2.7",
"@types/node": "^12.12.17",
"@types/node": "^12.12.20",
"@types/sinon": "^7.5.1",
"@typescript-eslint/eslint-plugin": "^2.12.0",
"@typescript-eslint/parser": "^2.12.0",
"chai": "^4.2.0",
"eslint": "^6.7.2",
"eslint-config-airbnb-base": "14.0.0",
"eslint-plugin-import": "^2.19.1",
"mocha": "^6.2.2",
"ns8-tslint": "^2.0.0",
"nyc": "^14.1.1",
"sinon": "^7.5.0",
"ts-node": "^8.5.4",
"tslint": "^5.20.1",
"typescript": "^3.7.3"

@@ -34,0 +37,0 @@ },

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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