mirror of
				https://github.com/elyby/accounts.git
				synced 2025-05-31 14:11:46 +05:30 
			
		
		
		
	Generate keys pair if they aren't exists
This commit is contained in:
		@@ -8,6 +8,7 @@ use Exception;
 | 
			
		||||
use Lcobucci\JWT\Builder;
 | 
			
		||||
use Lcobucci\JWT\Parser;
 | 
			
		||||
use Lcobucci\JWT\Token;
 | 
			
		||||
use Webmozart\Assert\Assert;
 | 
			
		||||
use yii\base\Component as BaseComponent;
 | 
			
		||||
 | 
			
		||||
class Component extends BaseComponent {
 | 
			
		||||
@@ -39,6 +40,13 @@ class Component extends BaseComponent {
 | 
			
		||||
     */
 | 
			
		||||
    private $algorithmManager;
 | 
			
		||||
 | 
			
		||||
    public function init(): void {
 | 
			
		||||
        parent::init();
 | 
			
		||||
        Assert::notEmpty($this->hmacKey, 'hmacKey must be set');
 | 
			
		||||
        Assert::notEmpty($this->privateKeyPath, 'privateKeyPath must be set');
 | 
			
		||||
        Assert::notEmpty($this->publicKeyPath, 'publicKeyPath must be set');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function create(array $payloads = [], array $headers = []): Token {
 | 
			
		||||
        $now = Carbon::now();
 | 
			
		||||
        $builder = (new Builder())
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user