-
-
Notifications
You must be signed in to change notification settings - Fork 321
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add opt-in support for Unsecured JWS algorithm "none"
- Loading branch information
Showing
11 changed files
with
365 additions
and
127 deletions.
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
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
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
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,14 @@ | ||
const { strict: assert } = require('assert') | ||
|
||
const sign = (key, payload) => Buffer.from('') | ||
const verify = (key, payload, signature) => !signature.length | ||
|
||
module.exports = (JWA, JWK) => { | ||
const jwaAlg = 'none' | ||
|
||
assert(!JWA.sign.has(jwaAlg), `sign alg ${jwaAlg} already registered`) | ||
assert(!JWA.verify.has(jwaAlg), `verify alg ${jwaAlg} already registered`) | ||
|
||
JWA.sign.set(jwaAlg, sign) | ||
JWA.verify.set(jwaAlg, verify) | ||
} |
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
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,33 @@ | ||
const { inspect } = require('util') | ||
|
||
const Key = require('./base') | ||
|
||
class NoneKey extends Key { | ||
constructor () { | ||
super({ type: 'unsecured' }, { alg: 'none' }) | ||
Object.defineProperties(this, { | ||
kid: { value: undefined }, | ||
thumbprint: { value: undefined }, | ||
toJWK: { value: undefined }, | ||
toPEM: { value: undefined } | ||
}) | ||
} | ||
|
||
/* c8 ignore next 3 */ | ||
[inspect.custom] () { | ||
return 'None {}' | ||
} | ||
|
||
algorithms (operation) { | ||
switch (operation) { | ||
case 'sign': | ||
case 'verify': | ||
case undefined: | ||
return new Set(['none']) | ||
default: | ||
return new Set() | ||
} | ||
} | ||
} | ||
|
||
module.exports = new NoneKey({ type: 'unsecured' }, { alg: 'none' }) |
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
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
Oops, something went wrong.