Code Explainers

Code explainers tagged #base64url

typescript
interface JwtPayload {
  exp?: number;
  iat?: number;
  sub?: string;

Decoding a JWT to check expiry

jwt base64url type-guards
Intermediate 8 steps
javascript
function parseJwtPayload(token) {
  const parts = token.split('.');
  if (parts.length !== 3) {
    throw new Error('Invalid JWT: expected 3 segments');

Decoding a JWT payload in JavaScript

jwt base64url encoding
Intermediate 6 steps
php
<?php
 
function verifyJwt(string $token, string $secret): array
{

Verifying an HS256 JWT in PHP

jwt hmac authentication
Intermediate 9 steps