GT2/GT2-Android/node_modules/jsonwebtoken/.history/tokenGenerator_201707141208...

23 lines
717 B
JavaScript

const jwt = require('./')
function TokenGenerator (secretOrPrivateKey, secretOrPublicKey, headerOptions) {
this.secretOrPrivateKey = secretOrPrivateKey;
this.secretOrPublicKey = secretOrPublicKey;
this.headerOptions = headerOptions; //algorithm + keyid
}
TokenGenerator.prototype.sign = function(payload, options) {
const signOptions = Object.assign({}, options, this.headerOptions);
return jwt.sign(payload, this.secretOrPrivateKey, options);
}
TokenGenerator.prototype.refresh = function(token, verifyOptions) {
const payload = jwt.verify(payload, this.secretOrPrivateKey, verifyOptions);
delete payload.iat;
delete payload.jti;
return jwt.sign(payload, this.secretOrPrivateKey, options);
}