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

shopify-api-node

Package Overview
Dependencies
Maintainers
3
Versions
108
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

shopify-api-node - npm Package Compare versions

Comparing version 1.2.0 to 2.0.0

README.md

45

index.js
'use strict';
const camelCase = require('lodash/camelCase');
const defaults = require('lodash/defaults');
const assign = require('lodash/assign');

@@ -14,24 +15,25 @@ const path = require('path');

*
* @param {String} shop The name of the shop
* @param {String} key The API Key
* @param {String} password The password
* @param {Object} options Configuration options
* @param {String} options.shopName The name of the shop
* @param {String} options.apiKey The API Key
* @param {String} options.password The private app password
* @param {String} options.accessToken The persistent OAuth public app token
* @param {Number} [options.timeout] The request timeout
* @constructor
* @public
*/
function Shopify(shop, key, password) {
if (!(this instanceof Shopify)) return new Shopify(shop, key, password);
if (!shop || !key) throw new Error('Missing required arguments');
function Shopify(options) {
if (!(this instanceof Shopify)) return new Shopify(options);
if (
!options
|| !options.shopName
|| !options.accessToken && (!options.apiKey || !options.password)
|| options.accessToken && (options.apiKey || options.password)
) {
throw new Error('Missing or invalid options');
}
let auth;
this.options = defaults(options, { timeout: 60000 });
//
// If we have only 2 arguments, `key` is a persistent OAuth2 token.
//
if (password) {
auth = `${key}:${password}`;
} else {
this.token = key;
}
//
// API call limits, updated with each request.

@@ -46,5 +48,5 @@ //

this.baseUrl = {
hostname: `${shop}.myshopify.com`,
protocol: 'https:',
auth
auth: !options.accessToken && `${options.apiKey}:${options.password}`,
hostname: `${options.shopName}.myshopify.com`,
protocol: 'https:'
};

@@ -83,2 +85,3 @@ }

headers: { 'User-Agent': `${pkg.name}/${pkg.version}` },
timeout: this.options.timeout,
json: true,

@@ -89,3 +92,5 @@ retries: 0,

if (this.token) options.headers['X-Shopify-Access-Token'] = this.token;
if (this.options.accessToken) {
options.headers['X-Shopify-Access-Token'] = this.options.accessToken;
}

@@ -92,0 +97,0 @@ if (params) {

{
"name": "shopify-api-node",
"version": "1.2.0",
"version": "2.0.0",
"description": "Shopify API bindings for Node.js",

@@ -24,5 +24,5 @@ "main": "index.js",

"chai": "^3.5.0",
"eslint": "^2.2.0",
"eslint": "^3.0.1",
"istanbul": "^0.4.2",
"mocha": "^2.4.5",
"mocha": "^3.0.1",
"nock": "^8.0.0",

@@ -29,0 +29,0 @@ "pre-commit": "^1.1.2"

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