feat: source tokens and client events API

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BCrwHHnGCB5XH968Nxokqw
This commit is contained in:
nikita.hohlov
2026-09-04 06:58:03 -03:00
parent 245ca88af6
commit 5ea5c045a7
9 changed files with 387 additions and 2 deletions

View File

@@ -0,0 +1,31 @@
<?php
namespace App\Console\Commands;
use App\Models\Source;
use Illuminate\Console\Command;
class SourceCreate extends Command
{
protected $signature = 'hado:source:create {name : Имя источника, напр. docs}';
protected $description = 'Регистрирует сервис-клиент и печатает его токен (один раз)';
public function handle(): int
{
$name = (string) $this->argument('name');
if (Source::where('name', $name)->exists()) {
$this->error("Источник «{$name}» уже существует");
return self::FAILURE;
}
$token = 'hado_'.bin2hex(random_bytes(32));
Source::create(['name' => $name, 'token_hash' => hash('sha256', $token)]);
$this->info("Источник «{$name}» создан. Токен показывается один раз, в базе только хэш.");
$this->line("Token: {$token}");
return self::SUCCESS;
}
}