Skip to content

Commit

Permalink
Merge pull request #79 from ubwhole/application_proxy
Browse files Browse the repository at this point in the history
Update is_valid_signature() to support proxied requests from Shopify
  • Loading branch information
nodeit authored Jul 17, 2017
2 parents 44fd5d3 + 92075cd commit 8d7d74e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/shopify.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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) {
Expand Down

0 comments on commit 8d7d74e

Please sign in to comment.