From 92075cdc27730a51b81bd6b680e49270e05f8dd7 Mon Sep 17 00:00:00 2001 From: John Lee Date: Thu, 13 Jul 2017 19:39:37 -0500 Subject: [PATCH] Update is_valid_signature() to support proxied requests from Shopify --- lib/shopify.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/shopify.js b/lib/shopify.js index 5ed2dba..2980d2b 100644 --- a/lib/shopify.js +++ b/lib/shopify.js @@ -52,6 +52,7 @@ ShopifyAPI.prototype.is_valid_signature = function(params, non_state) { } var hmac = params['hmac'], + theHash = params['hmac'] || params['signature'], secret = this.config.shopify_shared_secret, parameters = [], digest, @@ -63,14 +64,14 @@ ShopifyAPI.prototype.is_valid_signature = function(params, non_state) { } } - message = parameters.sort().join('&'); + message = parameters.sort().join(hmac ? '&' : ''); digest = crypto .createHmac('SHA256', secret) .update(message) .digest('hex'); - return (digest === hmac); + return ( digest === theHash ); }; ShopifyAPI.prototype.exchange_temporary_token = function(query_params, callback) {