Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 6x 6x 6x 6x 6x 6x 6x 6x 6x 2x 2x 4x 6x 1x 1x 1x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 1x | import { SDJWTException } from '@hopae/sd-jwt-util'; import { Jwt } from './jwt'; import { Verifier, kbHeader, kbPayload } from '@hopae/sd-jwt-type'; export class KBJwt< Header extends kbHeader = kbHeader, Payload extends kbPayload = kbPayload, > extends Jwt<Header, Payload> { // Checking the validity of the key binding jwt public async verify(verifier: Verifier) { if ( !this.header?.alg || !this.header.typ || !this.payload?.iat || !this.payload?.aud || !this.payload?.nonce || // this is for backward compatibility with version 06 !(this.payload?.sd_hash || (this.payload as any)?._sd_hash) ) { throw new SDJWTException('Invalid Key Binding Jwt'); } return await super.verify(verifier); } // This function is for creating KBJwt object for verify properly public static fromKBEncode< Header extends kbHeader = kbHeader, Payload extends kbPayload = kbPayload, >(encodedJwt: string): KBJwt<Header, Payload> { const { header, payload, signature } = Jwt.decodeJWT<Header, Payload>( encodedJwt, ); const jwt = new KBJwt<Header, Payload>({ header, payload, signature, }); return jwt; } } |