Skip to content

Commit

Permalink
Rename claims to payload.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredhanson committed Jan 26, 2016
1 parent 9febdf5 commit 0cf7fb9
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions lib/encode/sat.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,29 @@ module.exports = function(options) {


return function sat(info, cb) {
var claims = {}
var payload = {}
, header, token, val;
claims.jti = info.id;
claims.iss = issuer;
claims.sub = info.subject;
claims.aud = info.audience;
claims.azp = info.authorizedPresenter;
claims.iat = Math.floor(Date.now() / 1000);
payload.jti = info.id;
payload.iss = issuer;
payload.sub = info.subject;
payload.aud = info.audience;
payload.azp = info.authorizedPresenter;
payload.iat = Math.floor(Date.now() / 1000);

// see note in ../decode/sat.js about use of scope
if(Array.isArray(info.scope)) { info.scope = info.scope.join(' '); }
if(typeof info.scope == 'string') { claims.scope = info.scope; }
if(typeof info.scope == 'string') { payload.scope = info.scope; }

val = info.expiresAt;
if (val instanceof Date) {
claims.exp = Math.floor(val.getTime() / 1000);
payload.exp = Math.floor(val.getTime() / 1000);
} else {
return cb(new NotValidError('Structured access token requires an expiration time claim'));
}
val = info.notBefore;
if (val instanceof Date) {
// FIXME: This should be nbf
claims.exp = Math.floor(val.getTime() / 1000);
payload.exp = Math.floor(val.getTime() / 1000);
}

if (typeof key == 'function') {
Expand All @@ -56,7 +56,7 @@ module.exports = function(options) {
var header = { typ: 'JWT', alg: algorithm, kid: kid }
, token;
try {
token = jws.sign({ header: header, payload: claims, secret: key });
token = jws.sign({ header: header, payload: payload, secret: key });
} catch (ex) {
return cb(ex);
}
Expand All @@ -66,7 +66,7 @@ module.exports = function(options) {
} else {
header = { typ: 'JWT', alg: algorithm, kid: kid };
try {
token = jws.sign({ header: header, payload: claims, secret: key });
token = jws.sign({ header: header, payload: payload, secret: key });
} catch (ex) {
return cb(ex);
}
Expand Down

0 comments on commit 0cf7fb9

Please sign in to comment.