Skip to content

Commit

Permalink
WIP on decoding.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredhanson committed Feb 24, 2021
1 parent 2fc552a commit 734c03a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions lib/decoder.js
Expand Up @@ -34,21 +34,21 @@ Decoder.prototype.decode = function(claims, options, cb) {
if (!layer) { console.log('no layer'); return cb(new Error('invalid claims')); }
console.log('LAYER?');
console.log(layer);
console.log(layer.length);
//console.log(layer.length);

try {
debug('decode %s', layer.name || 'anonymous');

console.log('TRY DECODE');
console.log(layer);

var arity = layer.length;
var arity = layer.decode.length;
if (arity == 3) { // async with options
layer(claims, {}, next);
layer.decode(claims, {}, next);
} else if (arity == 2) { // async
layer(claims, next);
layer.decode(claims, next);
} else {
var m = layer(claims);
var m = layer.decode(claims);
next(null, m);
}
} catch (ex) {
Expand Down
4 changes: 2 additions & 2 deletions lib/tokens.js
Expand Up @@ -85,7 +85,7 @@ Tokens.prototype.createDecoder = function(type) {
if (!type) {
types = this._dialects.getTypes();
for (i = 0, len = types.length; i < len; ++i) {
stack.push(this._dialects.get(types[i]).decode);
stack.push(this._dialects.get(types[i]));
}
return new Decoder(stack);
}
Expand Down Expand Up @@ -205,7 +205,7 @@ Tokens.prototype.validate = function(token, options, cb) {
console.log(msg);


return cb(null, { claims: claims });
return cb(null, { claims: msg });
});

});
Expand Down
8 changes: 4 additions & 4 deletions test/tokens.validate.test.js
Expand Up @@ -219,14 +219,14 @@ describe('Tokens', function() {

describe('with dialects', function() {

describe.skip('from issuer as object', function() {
describe('from issuer as object', function() {
var keyring = new Object();
keyring.get = sinon.stub().yields(null, { secret: 'keyboardcat' });

var access = {
decode: function(msg) {
decode: function(claims) {
return {
scp: msg.scope
scope: claims.scp
};
}
};
Expand Down Expand Up @@ -300,7 +300,7 @@ describe('Tokens', function() {

it('should yield token', function() {
expect(token.claims).to.deep.equal({
scp: 'profile'
scope: 'profile'
});
});
}); // from issuer as object
Expand Down

0 comments on commit 734c03a

Please sign in to comment.