UNPKG

rocketfuel-node-sdk

Version:

JS SDK for RocketFuel Payment Method

16 lines (14 loc) 416 B
import CryptoJS from 'crypto-js'; import CustomError from '../../CustomError'; export default function encrypt() { return async (text, clientSecret) => { try { if (typeof text === 'object') { text = JSON.stringify(text); } return await CryptoJS.AES.encrypt(text, clientSecret).toString(); } catch (err) { throw new CustomError(err.message, err.response.data); } }; }