- Added JsonWebToken encoder

This commit is contained in:
Dave Mc Nicoll committed 2024-05-31 19:00:04 +00:00
1 parent c4e4db7a45
commit e63ea439d6
3 files changed
+43 -5

No files matched your search

+3 -4
View File
@@ -8,10 +8,9 @@ class JsonWebTokenDecoder
protected array $payload;
protected JsonWebTokenAlgorithmEnum $algrithm;
public function __construct(
public string $encoded
public string $encoded,
public string $secretKey,
) {}
protected function parse() : bool
@@ -42,7 +41,7 @@ class JsonWebTokenDecoder
}
}
JsonWebTokenValidate::validateSignature($this->header['alg'], getenv('LEAN_RANDOM'), $encodedHeader, $encodedPayload, $signature);
JsonWebTokenValidate::validateSignature($this->header['alg'], $this->secretKey, $encodedHeader, $encodedPayload, $signature);
}
catch(\Throwable $t) {
throw new JsonWebTokenDecodingError($t->getMessage(), $t->getCode(), $t);