Skip to content

Commit

Permalink
Merge 24b3817 into f296874
Browse files Browse the repository at this point in the history
  • Loading branch information
huangjoyce3 committed Oct 28, 2019
2 parents f296874 + 24b3817 commit 4ddd6f1
Show file tree
Hide file tree
Showing 5 changed files with 689 additions and 103 deletions.
385 changes: 335 additions & 50 deletions dist/appid.min.js

Large diffs are not rendered by default.

395 changes: 345 additions & 50 deletions dist/appid.umd.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/TokenValidator.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class TokenValidator {
throw new TokenError(constants.INVALID_AUDIENCE);
}

if ((nonce && !decoded.payloadObj.nonce) || (decoded.payloadObj.nonce !== nonce)) {
if (nonce && (!decoded.payloadObj.nonce || decoded.payloadObj.nonce !== nonce)) {
throw new TokenError(constants.INVALID_NONCE);
}

Expand Down
3 changes: 1 addition & 2 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,7 @@ class Utils {
token: tokens.access_token,
publicKeys,
issuer,
clientId,
nonce
clientId
});

const idTokenPayload = this.tokenValidator.decodeAndValidate({
Expand Down
7 changes: 7 additions & 0 deletions test/tokenValidatorTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ describe("TokenValidator", () => {
assert.equal(res.toString(), validPayload);
});

it('should return decoded payload - without nonce', async function () {
let token = generateToken({header, payload: validPayload});
let res = await tokenValidator.decodeAndValidate(
{token, publicKeys, issuer: validIssuer, clientId});
assert.equal(res.toString(), validPayload);
});

it('should return invalid token - malformed token', async function () {
try {
let res = await tokenValidator.decodeAndValidate(
Expand Down

0 comments on commit 4ddd6f1

Please sign in to comment.