import { decode , encode } from 'base64-url' ; import { SignatureScheme } from '../crypto' ; /**
 * Representation of JWT Header.
 */ export class JwtHeader { param encoded public static deserialize ( encoded ) { const decoded = decode ( encoded ) ; const header = JSON . parse ( decoded ) ; return new JwtHeader ( header . alg , header . kid ) ; } alg ? : string ; kid ? : string ; typ : string ; constructor ( alg ? , kid ? ) { this . alg = alg ; this . kid = kid ; this . typ = 'JWT' ; } /**
     * Serializes the header into JWT format - Base64 encoded string.
     */ public serialize ( algorithm , publicKeyId ) { let header ; if ( algorithm !== undefined ) { header = { alg : algorithm . labelJWS , typ : 'JWT' , kid : publicKeyId } ; } else { header = { typ : 'JWT' } ; } return encode ( JSON . stringify ( header ) , 'utf-8' ) ; } }