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

23 lines
717 B
JavaScript
Raw Normal View History

2018-02-12 17:26:06 +00:00
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);
}