Skip to content

Commit

Permalink
fix(typescript): Compact JWS Header Parameters has alg as required
Browse files Browse the repository at this point in the history
  • Loading branch information
panva committed Nov 11, 2021
1 parent 0fa87af commit c7fabd0
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,5 @@ export type {
JWTDecryptResult,
ResolvedKey,
CompactJWEHeaderParameters,
CompactJWSHeaderParameters,
} from './types.d'
4 changes: 2 additions & 2 deletions src/jws/compact/sign.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FlattenedSign } from '../flattened/sign.js'
import type { JWSHeaderParameters, KeyLike, SignOptions } from '../../types.d'
import type { CompactJWSHeaderParameters, KeyLike, SignOptions } from '../../types.d'

/**
* The CompactSign class is a utility for creating Compact JWS strings.
Expand Down Expand Up @@ -32,7 +32,7 @@ export class CompactSign {
*
* @param protectedHeader JWS Protected Header.
*/
setProtectedHeader(protectedHeader: JWSHeaderParameters) {
setProtectedHeader(protectedHeader: CompactJWSHeaderParameters) {
this._flattened.setProtectedHeader(protectedHeader)
return this
}
Expand Down
4 changes: 2 additions & 2 deletions src/jws/compact/verify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type {
CompactVerifyResult,
FlattenedJWSInput,
GetKeyFunction,
JWSHeaderParameters,
CompactJWSHeaderParameters,
KeyLike,
VerifyOptions,
ResolvedKey,
Expand All @@ -19,7 +19,7 @@ import type {
* to verify using a remote JSON Web Key Set.
*/
export interface CompactVerifyGetKey
extends GetKeyFunction<JWSHeaderParameters, FlattenedJWSInput> {}
extends GetKeyFunction<CompactJWSHeaderParameters, FlattenedJWSInput> {}

/**
* Verifies the signature and format of and afterwards decodes the Compact JWS.
Expand Down
8 changes: 8 additions & 0 deletions src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,14 @@ export interface ResolvedKey {
key: KeyLike | Uint8Array
}

/**
* Recognized Compact JWS Header Parameters, any other Header Members
* may also be present.
*/
export interface CompactJWSHeaderParameters extends JWSHeaderParameters {
alg: string
}

/**
* Recognized Compact JWE Header Parameters, any other Header Members
* may also be present.
Expand Down

0 comments on commit c7fabd0

Please sign in to comment.