-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for Apple's nonce_supported claim
Apple's authentication identity token can contain a non-standard nonce_supported claim. As specified, when this is set to false skip the nonce check. https://developer.apple.com/documentation/sign_in_with_apple/sign_in_with_apple_rest_api/authenticating_users_with_sign_in_with_apple
- Loading branch information
1 parent
74d5719
commit 6a7b98f
Showing
2 changed files
with
42 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
'use strict'; | ||
|
||
const jwt = require('../'); | ||
const expect = require('chai').expect; | ||
const testUtils = require('./test-utils') | ||
|
||
describe('nonce and nonce_supported option', function () { | ||
|
||
[ | ||
{ | ||
description: 'should succeed without nonce and without nonce support', | ||
signParam: { nonce_supported: false }, | ||
verifyParam: { }, | ||
}, | ||
{ | ||
description: 'should succeed without nonce but with nonce support', | ||
signParam: { nonce_supported: true }, | ||
verifyParam: { }, | ||
}, | ||
{ | ||
description: 'should succeed with nonce but without nonce support', | ||
signParam: { nonce_supported: false }, | ||
verifyParam: { nonce: 'abcde' }, | ||
}, | ||
{ | ||
description: 'should succeed with nonce and nonce support', | ||
signParam: { nonce: 'abcde', nonce_supported: true }, | ||
verifyParam: { nonce: 'abcde' }, | ||
}, | ||
].forEach((testCase) => { | ||
it(testCase.description, function (done) { | ||
var token = jwt.sign(testCase.signParam, undefined, { algorithm: 'none' }); | ||
testUtils.verifyJWTHelper(token, undefined, testCase.verifyParam, (err) => { | ||
testUtils.asyncCheck(done, () => { | ||
expect(err).to.be.null; | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters