Skip to content

Commit

Permalink
fix: 🐛 support for utf8
Browse files Browse the repository at this point in the history
  • Loading branch information
radzom committed Jan 7, 2020
1 parent 87d7309 commit 8d69aa3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 15 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ jwe(key).then(codec => {

## Credits

Made with :heart: by [radzom](https://github.com/radzom) and all these wonderful contributors ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)):
Made with :heart: by [radzom](https://github.com/radzom) and all these wonderful contributors ([emoji key](https://allcontributors.org/docs/en/emoji-key)):

<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore -->
| <img src="https://avatars.githubusercontent.com/u/1225651?v=3" width="100px;"/><br /><sub><b>Francis Pouatcha</b></sub><br />🤔 | | | | | | |
| <img src="https://avatars.githubusercontent.com/u/1225651?v=3" width="100px;"/><br /><sub><b>Francis Pouatcha</b></sub><br />🤔 | <img src="https://avatars.githubusercontent.com/u/1560587?v=3" width="100px;"/><br /><sub><b>jkroepke</b></sub><br />💻🐛 | | | | | |
| :---: | :---: | :---: | :---: | :---: | :---: | :---: |
<!-- ALL-CONTRIBUTORS-LIST:END -->

This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind are welcome!
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind are welcome!
6 changes: 2 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@ const hydra = require('hydration')
function isKey (jwk) {
return (
['oct'].includes(jwk.kty) &&
['A256KW', 'A256GCMKW', 'A256GCM', 'A128CBC-HS256', undefined].includes(
jwk.alg
) &&
['A256KW', 'A256GCMKW', 'A256GCM', 'A128CBC-HS256', undefined].includes(jwk.alg) &&
['enc', undefined].includes(jwk.use) &&
jwk.k.match(/^[A-Za-z0-9_-]{43}$/)
)
}

async function jwe (jwk) {
if (!isKey(jwk)) {
throw new Error(`bad key`)
throw new Error('bad key')
}
const key = await jose.JWK.asKey(jwk)

Expand Down
9 changes: 1 addition & 8 deletions test/jwe.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,7 @@ const testValues = [
date: new Date(42),
regex: /^fortytwo/,
buffer: Buffer.from('fortytwo'),
array: [
null,
42,
'fortytwo',
new Date(42),
/^fortytwo$/,
Buffer.from('fortytwo')
]
array: [null, 42, 'fortytwo', new Date(42), /^fortytwo$/, Buffer.from('fortytwo')]
}
]

Expand Down

0 comments on commit 8d69aa3

Please sign in to comment.