chore: sync with verdaccio master

This commit is contained in:
Juan Picado @jotadeveloper
2019-04-04 21:23:40 +02:00
parent 133a5f0171
commit 3506f32ad8
241 changed files with 57691 additions and 1932 deletions

View File

@@ -0,0 +1,26 @@
/**
* Token Utility
*/
import { Base64 } from 'js-base64';
import addHours from 'date-fns/add_hours';
export function generateTokenWithTimeRange (limit = 0) {
const payload = {
username: 'verdaccio',
exp: Number.parseInt(addHours(new Date(), limit).getTime() / 1000, 10)
};
return `xxxxxx.${Base64.encode(JSON.stringify(payload))}.xxxxxx`;
}
export function generateTokenWithExpirationAsString () {
const payload = { username: 'verdaccio', exp: 'I am not a number' };
return `xxxxxx.${Base64.encode(payload)}.xxxxxx`;
}
export function generateTokenWithOutExpiration (){
const payload = {
username: 'verdaccio'
};
return `xxxxxx.${Base64.encode(JSON.stringify(payload))}.xxxxxx`;
}