13 if (!class_exists(
'\JWT')) {
14 throw new \ErrorException(
'firebase/php-jwt must be installed to use this feature. You can do this by running "composer require firebase/php-jwt"');
18 public function encode($payload, $key, $alg =
'HS256', $keyId =
null)
20 return \JWT::encode($payload, $key, $alg, $keyId);
23 public function decode($jwt, $key =
null, $allowedAlgorithms =
null)
28 if (!$allowedAlgorithms) {
32 return (array)\JWT::decode($jwt, $key, $allowedAlgorithms);
33 }
catch (\Exception $e) {
40 return \JWT::urlsafeB64Encode($data);
45 return \JWT::urlsafeB64Decode($b64);