Skip to content

Commit

Permalink
Fix bug with certain PEM keys
Browse files Browse the repository at this point in the history
  • Loading branch information
awlayton committed Apr 2, 2022
1 parent b4c24fc commit ad5ac9c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"certs": "./dist/cli.mjs",
"oada-certs": "./dist/cli.mjs"
},
"version": "4.1.0",
"version": "4.1.1",
"description": "Generate and verify JWT signatures (OAuth dynamic client registration certificates and Trellis document integrity signatures) in the Open Ag Data Alliance (OADA) and Trellis ecosystems",
"main": "dist/index.js",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion src/jwks-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const warn = debug('oada-certs:jwks-utils:warn');
/**
* @todo Better discriminated union of JWK types?
*/
export type JWK = BaseJWK | JWKpem | JWKrsa;
export type JWK = JWKpem | JWKrsa;
export interface BaseJWK extends Partial<jose_JWK.RawKey> {
/**
* Must have "kty" to be a JWK
Expand Down
2 changes: 2 additions & 0 deletions src/sign.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ export async function sign(
// AsKey needs the key to be just the pem string if it's a pem
let privatejwk = await (typeof key === 'string'
? jose_JWK.asKey(key, 'pem')
: key.kty === 'PEM'
? jose_JWK.asKey(key.pem, 'pem')
: jose_JWK.asKey(key));
// If (key.kid) privatejwk.kid = key.kid; // maintain kid from original if passed
// options.header.kid can override the one in the private key:
Expand Down

0 comments on commit ad5ac9c

Please # to comment.