agilite-utils
Advanced tools
Comparing version 7.0.5 to 7.0.6
@@ -1,1 +0,45 @@ | ||
module.exports = require('./lib/bcrypt') | ||
const hashValue = async function (value) { | ||
return new Promise((resolve, reject) => { | ||
const BCrypt = require('bcryptjs') | ||
try { | ||
BCrypt.genSalt(10, function (err, salt) { | ||
if (err) { | ||
return reject(err) | ||
} | ||
BCrypt.hash(value, salt, function (err, hash) { | ||
if (err) { | ||
return reject(err) | ||
} | ||
resolve(hash) | ||
}) | ||
}) | ||
} catch (e) { | ||
reject(e) | ||
} | ||
}) | ||
} | ||
const compareValues = async function (valueToCompare, hashedValue) { | ||
return new Promise((resolve, reject) => { | ||
const BCrypt = require('bcryptjs') | ||
try { | ||
BCrypt.compare(valueToCompare, hashedValue, function (err, isMatch) { | ||
if (err) { | ||
reject(err) | ||
} else { | ||
resolve(isMatch) | ||
} | ||
}) | ||
} catch (e) { | ||
reject(e) | ||
} | ||
}) | ||
} | ||
// EXPORTS | ||
exports.hashValue = hashValue | ||
exports.compareValues = compareValues |
@@ -1,1 +0,30 @@ | ||
module.exports = require('./lib/enums-type-detect') | ||
module.exports = { | ||
ARRAY: 'Array', | ||
ARRAY_BUFFER: 'ArrayBuffer', | ||
ARGS: 'Arguments', | ||
DATA_VIEW: 'DataView', | ||
DATE: 'Date', | ||
FUNCTION: 'function', | ||
FLOAT32ARRAY: 'Float32Array', | ||
FLOAT64ARRAY: 'Float64Array', | ||
INT8ARRAY: 'Int8Array', | ||
INT16ARRAY: 'Int16Array', | ||
INT32ARRAY: 'Int32Array', | ||
MAP: 'Map', | ||
NULL: 'null', | ||
NUMBER: 'number', | ||
OBJECT: 'Object', | ||
PROMISE: 'Promise', | ||
REGEX: 'RegExp', | ||
SET: 'Set', | ||
STRING: 'string', | ||
BOOLEAN: 'boolean', | ||
SYMBOL: 'symbol', | ||
UINT8ARRAY: 'Uint8Array', | ||
UINT8CLAMPEDARRAY: 'Uint8ClampedArray', | ||
UINT16ARRAY: 'Uint16Array', | ||
UINT32ARRAY: 'Uint32Array', | ||
UNDEFINED: 'undefined', | ||
WEAK_MAP: 'WeakMap', | ||
WEAK_SET: 'WeakSet' | ||
} |
52
index.js
@@ -1,15 +0,39 @@ | ||
// const Utils = { | ||
// // dotEnv: require('dotenv'), | ||
// // enumsTypeDetect: require('./lib/enums-type-detect'), | ||
// // typeDetect: require('type-detect'), | ||
// // nanoPerformance: require('nano-performance'), | ||
// // dateFNS: require('date-fns'), | ||
// // genericPool: require('generic-pool'), | ||
// // servicePool: require('service-pool'), | ||
// // axios: require('axios').default, | ||
// // bcrypt: require('./lib/bcrypt'), | ||
// // jwtSimple: require('./lib/jwt-simple'), | ||
// // uuid: require('uuid') | ||
// } | ||
const getQueryParams = (qs) => { | ||
qs = qs.split('+').join(' ') | ||
// module.exports = Utils | ||
const params = {} | ||
const re = /[?&]?([^=]+)=([^&]*)/g | ||
let tokens = null | ||
// eslint-disable-next-line | ||
while (tokens = re.exec(qs)) { | ||
params[decodeURIComponent(tokens[1])] = decodeURIComponent(tokens[2]) | ||
} | ||
return params | ||
} | ||
const isNumber = (value) => { | ||
const str = ('' + value).trim() | ||
if (str.length === 0) return false | ||
return !isNaN(+str) | ||
} | ||
const padValue = (n, width, z) => { | ||
z = z || '0' | ||
n = n + '' | ||
return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n | ||
} | ||
const toProperCase = (str) => { | ||
return str.replace(/\w\S*/g, function (txt) { | ||
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase() | ||
}) | ||
} | ||
// EXPORTS | ||
exports.getQueryParams = getQueryParams | ||
exports.isNumber = isNumber | ||
exports.padValue = padValue | ||
exports.toProperCase = toProperCase |
@@ -1,1 +0,41 @@ | ||
module.exports = require('./lib/jwt-simple') | ||
const encode = async function (payload, secret) { | ||
let errMsg = null | ||
let token = null | ||
return new Promise((resolve, reject) => { | ||
try { | ||
if (!payload || !secret) { | ||
errMsg = 'Undefined value(s) passed to function - encode' | ||
reject(errMsg) | ||
} else { | ||
token = require('jwt-simple').encode(payload, secret) | ||
resolve(token) | ||
} | ||
} catch (e) { | ||
reject(e) | ||
} | ||
}) | ||
} | ||
const decode = async function (token, secret) { | ||
let errMsg = null | ||
let result = null | ||
return new Promise((resolve, reject) => { | ||
try { | ||
if (!token || !secret) { | ||
errMsg = 'Undefined value(s) passed to function - decode' | ||
reject(errMsg) | ||
} else { | ||
result = require('jwt-simple').decode(token, secret) | ||
resolve(result) | ||
} | ||
} catch (e) { | ||
reject(e) | ||
} | ||
}) | ||
} | ||
// EXPORTS | ||
exports.encode = encode | ||
exports.decode = decode |
{ | ||
"name": "agilite-utils", | ||
"license": "MIT", | ||
"version": "7.0.5", | ||
"version": "7.0.6", | ||
"description": "Various 3rd party utilities, functions and services that we simplify and use throughout the Agilit-e ecosystem", | ||
@@ -6,0 +6,0 @@ "homepage": "https://agilite.io", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6640
144
15
1