Skip to content

Commit

Permalink
refactor: unify JOSENotSupported throw on key export
Browse files Browse the repository at this point in the history
  • Loading branch information
panva committed Aug 12, 2022
1 parent caaf2c3 commit fe5d093
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/runtime/node/key_to_jwk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ const keyToJWK: JWKExportFunction = (key: unknown): JWK => {
}

if (jwkExportSupported) {
if (
keyObject.type !== 'secret' &&
!['rsa', 'ec', 'ed25519', 'x25519', 'ed448', 'x448'].includes(keyObject.asymmetricKeyType!)
) {
throw new JOSENotSupported('Unsupported key asymmetricKeyType')
}
return keyObject.export({ format: 'jwk' })
}

Expand Down

0 comments on commit fe5d093

Please sign in to comment.