UNPKG

sibs-payments

Version:

A payment system module for SIBS payments integration with card tokenization support

27 lines 1.15 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Decrypt = Decrypt; const crypto_1 = __importDefault(require("crypto")); function Decrypt(body, iv, tag, key) { // Encryption algorithm : AES // Block mode : GCM // Padding : None // Initialization Vector : In HTTP header (X-Initialization-Vector) // Authentication Tag : In HTTP header (X-Authentication-Tag) // Format of body: Base64 // Format of Initialization Vector: Base64 const b64 = (s) => Buffer.from(s, "base64"); const _body = b64(body); const _iv = b64(iv); // Buffer length 12 const _tag = b64(tag); // Buffer length 16 const _key = b64(key); // Buffer length 32 // Append authentication const decipher = crypto_1.default.createDecipheriv("aes-256-gcm", _key, _iv); decipher.setAuthTag(_tag); // Decrypt the payload return Buffer.concat([decipher.update(_body), decipher.final()]).toString("utf8"); } //# sourceMappingURL=purchase-decrypt.js.map