UNPKG

ggez-banking-sdk

Version:

A Node.js package to handle GGEZ Banking API endpoints, Simplify the process of managing CRUD operations with this efficient and easy-to-use package.

41 lines (40 loc) 1.89 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.generatekeyAndIvCode = exports.generatekeyAndIvUsingUserID = exports.generatekeyAndIv = void 0; exports.paddingLeft = paddingLeft; function paddingLeft(value, length, paddingChar) { if (value.length >= length) { return value; } const paddingLength = length - value.length; const padding = paddingChar.repeat(paddingLength); const paddedValue = padding + value; return paddedValue; } const generatekeyAndIv = (program_id, user_id, installation_id) => { const paddedLeft10ProgramId = paddingLeft(program_id.toString(), 10, "0"); const paddedLeft10UserId = paddingLeft(user_id.toString(), 10, "0"); const paddedLeft8ProgramId = paddingLeft(program_id.toString(), 8, "0"); const paddedLeft8UserId = paddingLeft(user_id.toString(), 8, "0"); const paddedLeft10Fingerprint = paddingLeft(installation_id || "", 10, "0"); let key = `${paddedLeft10ProgramId}.${paddedLeft10UserId}.${paddedLeft10Fingerprint}`; let iv = `${paddedLeft8ProgramId}${paddedLeft8UserId}`; return { key: key, iv: iv }; }; exports.generatekeyAndIv = generatekeyAndIv; const generatekeyAndIvUsingUserID = (user_id) => { const paddedLeft32UserId = paddingLeft(user_id.toString(), 32, "0"); const paddedLeft16UserId = paddingLeft(user_id.toString(), 16, "0"); let key = paddedLeft32UserId; let iv = paddedLeft16UserId; return { key: key, iv: iv }; }; exports.generatekeyAndIvUsingUserID = generatekeyAndIvUsingUserID; const generatekeyAndIvCode = (code) => { const paddedLeft32UserId = paddingLeft(code.toString(), 32, "0"); const paddedLeft16UserId = paddingLeft(code.toString(), 16, "0"); let key = paddedLeft32UserId; let iv = paddedLeft16UserId; return { key: key, iv: iv }; }; exports.generatekeyAndIvCode = generatekeyAndIvCode;