unofficial-klap-sdk
Version:
Código fuente no oficial de Klap SDK en NodeJs
27 lines (26 loc) • 1.19 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var crypto_1 = __importDefault(require("crypto"));
/**
* Class containing needed authenticaction and configuration to interact with the API.
* Environment correspond to the environment to use, it can be Integration or Production, each has
* a unique URL.
*/
var Utils = {
/**
* @param headerApikey value of apiKey parameter received in request
* @param ecommerceApiKey the secret used to authenticate against the API
* @param order value of order received in request
*/
validateHeaderApikey: function (headerApikey, ecommerceApiKey, order) {
var compositeKey = order.reference_id + order.order_id + ecommerceApiKey;
// este hash es el que debes comparar con el que te llegará en el header "Apikey"
// mediante el request a tus webhooks
var hashApiKey = crypto_1.default.createHash('sha256').update(compositeKey).digest('hex');
return hashApiKey === headerApikey;
},
};
exports.default = Utils;