Laravel AT Protocol Client (alpha & unstable)
1<?php
2
3namespace SocialDept\AtpClient\Console;
4
5use Illuminate\Console\Command;
6use SocialDept\AtpClient\Auth\OAuthKey;
7
8class GenerateOAuthKeyCommand extends Command
9{
10 protected $signature = 'atp-client:generate-key';
11
12 protected $description = 'Generate a new ES256 private key for OAuth';
13
14 public function handle(): int
15 {
16 $this->info('Generating new ES256 private key...');
17 $this->newLine();
18
19 $key = OAuthKey::create();
20 $private = $key->privateB64();
21
22 $this->components->twoColumnDetail('Private Key', '<fg=yellow>'.$private.'</>');
23 $this->newLine();
24
25 $this->components->info('Add this to your .env file:');
26 $this->line('ATP_OAUTH_PRIVATE_KEY="'.$private.'"');
27 $this->newLine();
28
29 $this->components->warn('Keep this key secret! Do not commit it to version control.');
30
31 return self::SUCCESS;
32 }
33}