PocketMine-MP Virion (v3.1) wrapper for the firebase/php-jwt library.
It uses Composer natively to pull the library during the Poggit-CI build process, meaning security updates to the underlying library are not frozen.
To use this in your PocketMine-MP plugin via Poggit-CI, add the following to your .poggit.yml:
projects:
YourPluginName:
path: ""
libs:
- src: xauth-ecosystem/php-jwt-virion/php-jwt-virion
version: ^0.1And in your composer.json, you do not need to require firebase/php-jwt directly if you are relying on the virion injection.
You can use the provided JwtHelper class to encode and decode tokens easily within your plugin:
use ChernegaSergiy\PhpJwtVirion\JwtHelper;
use ChernegaSergiy\PhpJwtVirion\Exception\JwtException;
$secretKey = "your-256-bit-secret";
$helper = new JwtHelper($secretKey);
// Encode a payload
$payload = [
"iss" => "your-plugin",
"aud" => "your-server",
"exp" => time() + 3600
];
$jwt = $helper->encode($payload);
// Decode a token
try {
$decoded = $helper->decode($jwt);
var_dump($decoded);
} catch (JwtException $e) {
echo "Failed to decode JWT: " . $e->getMessage();
}Contributions are welcome and appreciated! Here's how you can contribute:
- Fork the project
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Please make sure to update tests as appropriate and adhere to the existing coding style.
This library is licensed under the CSSM Unlimited License v2.0 (CSSM-ULv2). See the LICENSE file for details. The underlying firebase/php-jwt library is licensed under the 3-Clause BSD License.