3.0.3 • Published 1 year ago
@neogeek/create-app-utils v3.0.3
@neogeek/create-app-utils
Install
$ npm install @neogeek/create-app-utils
Usage
URL
getQueryParamsFromUrl(url)
import { getQueryParamsFromUrl } from '@neogeek/create-app-utils';
const { key } = getQueryParamsFromUrl('https://domain.com/?key=value');
Cookies
serializeCookie(key, value, maxAge, secure)
import { serializeCookie } from '@neogeek/create-app-utils';
const cookie = serializeCookie('key', 'value', 0, true);
Dates
generateExpireAtDate(daysFromNow)
import { generateExpireAtDate } from '@neogeek/create-app-utils';
const date = generateExpireAtDate(5);
JWT
extractDataFromToken(token)
import { extractDataFromToken } from '@neogeek/create-app-utils';
const { key } = extractDataFromToken(token);
generateAccessToken(privateKey, data, options)
import { generateAccessToken } from '@neogeek/create-app-utils';
const accessToken = generateAccessToken(
privateKey,
{ key: 'value' },
{
algorithm: 'RS512',
expiresIn: '15 minutes',
}
);
generateRefreshToken(privateKey, data, options)
import { generateRefreshToken } from '@neogeek/create-app-utils';
const refreshToken = generateRefreshToken(
privateKey,
{ key: 'value' },
{
algorithm: 'RS512',
expiresIn: '15 minutes',
}
);
verifyAccessToken(publicKey, token)
import { verifyAccessToken } from '@neogeek/create-app-utils';
const isValid = verifyAccessToken(publicKey, token);
verifyRefreshToken(publicKey, token)
import { verifyRefreshToken } from '@neogeek/create-app-utils';
const isValid = verifyRefreshToken(publicKey, token);