ttlSeconds = $ttlSeconds; } public function store(array $loginResult): string { $code = IamSecurity::base64UrlEncode(random_bytes(32)); Cache::set($this->key($code), $loginResult, max(30, $this->ttlSeconds)); return $code; } public function consume(string $code): ?array { if (strlen($code) < 20 || strlen($code) > 200) { return null; } $value = Cache::pull($this->key($code)); return is_array($value) ? $value : null; } private function key(string $code): string { return 'iam_login_exchange_' . hash('sha256', $code); } }