visio_salle === null) { throw new RuntimeException('Visio non configurée ou salle non ouverte.'); } $maintenant = time(); $charge = [ 'iss' => config('visio.jwt.app_id'), 'aud' => config('visio.jwt.audience'), 'sub' => '*', 'room' => $seance->visio_salle, 'iat' => $maintenant, 'nbf' => $maintenant - 10, 'exp' => $maintenant + 60 * (int) config('visio.jwt.duree_minutes'), 'context' => [ 'user' => [ 'id' => $identifiant, 'name' => $nom, 'moderator' => $moderateur, ], ], ]; $entete = $this->base64Url(json_encode(['alg' => 'HS256', 'typ' => 'JWT'])); $corps = $this->base64Url(json_encode($charge, JSON_UNESCAPED_UNICODE)); $signature = $this->base64Url(hash_hmac('sha256', "{$entete}.{$corps}", $secret, true)); return "{$entete}.{$corps}.{$signature}"; } private function base64Url(string $donnees): string { return rtrim(strtr(base64_encode($donnees), '+/', '-_'), '='); } }