+
-
更新任务
-
更新期间 PHP 和私有引擎会重启,短暂连接失败会自动重试。请保留本页面,勿重复提交执行请求。若任务进入 blocked,代码或数据库状态尚未确认,页面会保持维护锁并禁用变更操作;请通过 SSH 核查。如果中断发生在数据库迁移期间,仅回退源码不会解除维护锁,必须人工完成并验证迁移与服务兼容性。
-
+
+
+
Progress
+
更新任务
+
PHP 与私有引擎重启期间会自动只读恢复任务,请保留本页面且不要重复提交。
+
+
+
+
- 任务编号
- —
- 任务状态
- —
- 当前阶段
- —
- 结果
- —
+ 若任务进入 blocked,维护锁会保持启用。数据库迁移中断时仅回退源码不会解除锁,必须通过 SSH 完成并验证恢复。
diff --git a/web/resources/views/venix/layout_assets.tpl b/web/resources/views/venix/layout_assets.tpl
index 513dc452..e711cba4 100644
--- a/web/resources/views/venix/layout_assets.tpl
+++ b/web/resources/views/venix/layout_assets.tpl
@@ -1 +1 @@
-{assign var=venix_asset_version value='2026092902' scope='global'}
+{assign var=venix_asset_version value='2026092903' scope='global'}
diff --git a/web/tests/PrunedProjectContractTest.php b/web/tests/PrunedProjectContractTest.php
index e62e76cd..e7fd3955 100644
--- a/web/tests/PrunedProjectContractTest.php
+++ b/web/tests/PrunedProjectContractTest.php
@@ -16,7 +16,7 @@ foreach (['/community', '/paid-registration', '/trafficlog', '/tcplog', '/tcpmon
$assert(!is_dir($root . '/resources/views/material') && !is_dir($root . '/resources/views/codex'), 'Retired templates remain');
$assert(is_file($root . '/resources/views/venix/admin/hosts/index.tpl'), 'Host administration template missing');
$config = file_get_contents($root . '/config/.config.php.example');
-foreach (['user_try', 'reg_method', 'user_class_default', 'enable_class_expire_reset', 'auto_clean_', 'auto_backup_webroot', 'mu_suffix', 'mu_regex', 'checkinMin', 'enable_documents', 'subUrl', 'tgUrl', 'chatgpt_api'] as $key) {
+foreach (['user_try', 'reg_method', 'user_class_default', 'enable_class_expire_reset', 'auto_clean_', 'auto_backup_webroot', 'mu_suffix', 'mu_regex', 'checkinMin', 'enable_documents', 'subUrl', 'tgUrl', 'enable_telegram', 'telegram_token', 'telegram_request_token', 'chatgpt_api'] as $key) {
$assert(!str_contains($config, $key), 'Retired configuration remains: ' . $key);
}
foreach (['db_password', 'smtp_passsword', 'super_admin', 'auto_backup_passwd', 'enable_login_bind_ip', 'notify_limit_mode'] as $key) {
diff --git a/web/tests/TicketTelegramBoundaryTest.php b/web/tests/TicketTelegramBoundaryTest.php
index a7575b61..e163224b 100644
--- a/web/tests/TicketTelegramBoundaryTest.php
+++ b/web/tests/TicketTelegramBoundaryTest.php
@@ -1,6 +1,5 @@
'true', 'telegram_token' => 'test-not-a-real-token', 'telegram_request_token' => ''];
-check(!Notifications::authorizeWebhook(''), 'Empty webhook secret must fail closed');
-$System_Config['telegram_request_token'] = str_repeat('a', 32);
-check(!Notifications::authorizeWebhook(str_repeat('b', 32)), 'Wrong secret accepted');
-check(Notifications::authorizeWebhook(str_repeat('a', 32)), 'Valid configured secret rejected');
-$System_Config['enable_telegram'] = 'false';
-check(!Notifications::authorizeWebhook(str_repeat('a', 32)), 'Disabled integration accepted');
-
$message = ['chat' => ['type' => 'private', 'id' => 123], 'from' => ['id' => 123], 'text' => '/start ' . str_repeat('a', 48)];
check(Notifications::bindingCommand(['message' => $message]) !== null, 'Private one-time code command rejected');
foreach ([['text' => '/reply 1 hello'], ['chat' => ['type' => 'group', 'id' => 123]], ['from' => ['id' => 124]], ['forward_origin' => ['type' => 'user']], ['from' => ['id' => 123, 'is_bot' => true]], ['text' => '/start bad']] as $change) {
check(Notifications::bindingCommand(['message' => array_replace($message, $change)]) === null, 'Unexpected bot capability accepted');
}
-echo "Administrator-only Telegram boundaries passed.\n";
+$config = file_get_contents(dirname(__DIR__) . '/config/.config.php.example');
+foreach (['enable_telegram', 'telegram_token', 'telegram_request_token', 'tgUrl'] as $legacy) {
+ check(!str_contains($config, $legacy), 'Legacy Telegram config.php setting remains: ' . $legacy);
+}
+$service = file_get_contents(dirname(__DIR__) . '/app/Services/TicketTelegramConfig.php');
+check(str_contains($service, 'ticket_telegram_webhook_base_url'), 'Database Telegram communication origin is missing');
+echo "Administrator-only Telegram command and database configuration boundaries passed.\n";
diff --git a/web/tests/TicketTelegramNotifierSecurityTest.php b/web/tests/TicketTelegramNotifierSecurityTest.php
index a7a388f9..0672d182 100644
--- a/web/tests/TicketTelegramNotifierSecurityTest.php
+++ b/web/tests/TicketTelegramNotifierSecurityTest.php
@@ -15,11 +15,20 @@ namespace App\Models {
public static int $transactions = 0;
public static int $locks = 0;
public static int $writes = 0;
+ public static int $queries = 0;
+ public static bool $failQueries = false;
public function __construct(public string $name = '', public string $value = '{}') {}
- public static function where($key, $value) { return new \TelegramTestQuery($value); }
- public static function firstOrCreate($match, $values)
+ public static function where($key, $value)
{
- return self::$rows[$match['name']] ??= new self($match['name'], $values['value']);
+ if (self::$failQueries) { throw new \RuntimeException('SQLSTATE synthetic-internal-detail'); }
+ self::$queries++;
+ return new \TelegramTestQuery($value);
+ }
+ public static function whereIn($key, $values)
+ {
+ if (self::$failQueries) { throw new \RuntimeException('SQLSTATE synthetic-internal-detail'); }
+ self::$queries++;
+ return new \TelegramTestWhereInQuery($values);
}
public function getConnection() { return new \TelegramTestConnection(); }
public function save()
@@ -37,6 +46,31 @@ namespace App\Services {
public static $user;
public static function getUser() { return self::$user; }
}
+
+ final class RedisClient
+ {
+ public static array $store = [];
+ public static array $ttls = [];
+ public static bool $fail = false;
+ public static int $gets = 0;
+ public static int $sets = 0;
+ public static int $deletes = 0;
+ public function __construct()
+ {
+ if (self::$fail) { throw new \RuntimeException('Redis unavailable'); }
+ }
+ public function getClient() { return new \TelegramTestRedisBackend(); }
+ public function setex($key, $ttl, $value) { return $this->getClient()->setex($key, $ttl, $value); }
+ public function del($key) { return $this->getClient()->del($key); }
+ }
+}
+
+namespace App\Services\Cloud {
+ final class CloudSecrets
+ {
+ public static int $calls = 0;
+ public static function key(string $purpose): string { self::$calls++; return str_repeat("\x42", 32); }
+ }
}
namespace App\Controllers {
@@ -65,6 +99,10 @@ namespace {
use App\Models\Configurations;
use App\Models\User;
use App\Services\Auth;
+ use App\Services\Cloud\CloudSecrets;
+ use App\Services\RedisClient;
+ use App\Services\TicketTelegramConfig;
+ use App\Services\TicketTelegramCredentialCipher;
use App\Services\TicketTelegramNotifier;
use App\Controllers\Admin\TelegramController;
use App\Controllers\TelegramWebhookController;
@@ -79,6 +117,30 @@ namespace {
finally { Configurations::$transactions--; }
}
}
+ final class TelegramTestRedisBackend
+ {
+ public function get($key)
+ {
+ if (RedisClient::$fail) { throw new RuntimeException('Redis unavailable'); }
+ RedisClient::$gets++;
+ return RedisClient::$store[$key] ?? null;
+ }
+ public function setex($key, $ttl, $value)
+ {
+ if (RedisClient::$fail) { throw new RuntimeException('Redis unavailable'); }
+ RedisClient::$sets++;
+ RedisClient::$ttls[$key] = (int) $ttl;
+ RedisClient::$store[$key] = (string) $value;
+ return true;
+ }
+ public function del($key)
+ {
+ if (RedisClient::$fail) { throw new RuntimeException('Redis unavailable'); }
+ RedisClient::$deletes++;
+ unset(RedisClient::$store[$key], RedisClient::$ttls[$key]);
+ return 1;
+ }
+ }
final class TelegramTestQuery
{
public function __construct(private string $name) {}
@@ -94,6 +156,17 @@ namespace {
public function firstOrFail() { return $this->first() ?? throw new RuntimeException('Missing fixture.'); }
public function delete() { unset(Configurations::$rows[$this->name]); }
}
+ final class TelegramTestWhereInQuery
+ {
+ public function __construct(private array $names) {}
+ public function get($columns = ['*'])
+ {
+ return array_values(array_filter(
+ Configurations::$rows,
+ fn ($row) => in_array($row->name, $this->names, true)
+ ));
+ }
+ }
final class TelegramTestResponse
{
public int $status = 200;
@@ -117,13 +190,16 @@ namespace {
}
final class TelegramTestRequest
{
- public function __construct(private string $secret, public TelegramTestStream $stream) {}
+ public function __construct(private string $secret, public TelegramTestStream $stream, private array $payload = []) {}
public function getHeaderLine($name) { return $this->secret; }
public function getBody() { return $this->stream; }
+ public function getParsedBody() { return $this->payload; }
}
require dirname(__DIR__) . '/app/Services/Config.php';
require dirname(__DIR__) . '/app/Services/AdminPermission.php';
+ require dirname(__DIR__) . '/app/Services/TicketTelegramCredentialCipher.php';
+ require dirname(__DIR__) . '/app/Services/TicketTelegramConfig.php';
require dirname(__DIR__) . '/app/Services/TicketTelegramNotifier.php';
require dirname(__DIR__) . '/app/Controllers/Admin/TelegramController.php';
require dirname(__DIR__) . '/app/Controllers/TelegramWebhookController.php';
@@ -133,7 +209,7 @@ namespace {
};
$expectRejected = function ($callback, $message) use ($assert) {
$rejected = false;
- try { $callback(); } catch (RuntimeException $exception) { $rejected = true; }
+ try { $callback(); } catch (Throwable $exception) { $rejected = true; }
$assert($rejected, $message);
};
$state = function () {
@@ -142,11 +218,15 @@ namespace {
$setState = function ($value) {
Configurations::$rows['ticket_telegram_binding'] = new Configurations('ticket_telegram_binding', json_encode($value));
};
+ $configCacheKey = 'ticket_telegram_config_snapshot:v1';
+ $clearConfigCache = function () use ($configCacheKey) {
+ unset(RedisClient::$store[$configCacheKey], RedisClient::$ttls[$configCacheKey]);
+ };
$update = function ($code, $chatId = '123456') {
return ['message' => ['chat' => ['id' => $chatId, 'type' => 'private'],
'from' => ['id' => $chatId, 'is_bot' => false], 'text' => '/start ' . $code]];
};
- $System_Config = ['enable_telegram' => true, 'telegram_token' => 'synthetic-bot-token',
+ $System_Config = ['enable_telegram' => true, 'telegram_token' => '123456789:' . str_repeat('A', 35),
'telegram_request_token' => 'synthetic-webhook-secret-123', 'super_admin' => '1,2',
'baseUrl' => 'https://example.invalid'];
User::$users = [1 => new User(1, 1), 2 => new User(2, 0), 3 => new User(3, 1)];
@@ -154,6 +234,36 @@ namespace {
$expectRejected(fn () => TicketTelegramNotifier::createBinding(2), 'Ordinary whitelisted user can issue binding codes.');
$expectRejected(fn () => TicketTelegramNotifier::createBinding(3), 'Non-super administrator can issue binding codes.');
$binding = TicketTelegramNotifier::createBinding(1);
+ $assert((string) Configurations::$rows[TicketTelegramConfig::MIGRATION_MARKER]->value === '1'
+ && !str_contains(Configurations::$rows[TicketTelegramConfig::BOT_TOKEN]->value, $System_Config['telegram_token'])
+ && !str_contains(Configurations::$rows[TicketTelegramConfig::WEBHOOK_SECRET]->value, $System_Config['telegram_request_token']),
+ 'Legacy Telegram settings were not migrated once as encrypted database values.');
+ TicketTelegramConfig::publicValues();
+ $cachedSnapshot = json_decode(RedisClient::$store[$configCacheKey] ?? '', true);
+ $assert(is_array($cachedSnapshot) && (RedisClient::$ttls[$configCacheKey] ?? 0) === 60
+ && str_starts_with($cachedSnapshot[TicketTelegramConfig::BOT_TOKEN] ?? '', 'sbox:telegram:v1:')
+ && str_starts_with($cachedSnapshot[TicketTelegramConfig::WEBHOOK_SECRET] ?? '', 'sbox:telegram:v1:')
+ && !str_contains(RedisClient::$store[$configCacheKey] ?? '', $System_Config['telegram_token'])
+ && !str_contains(RedisClient::$store[$configCacheKey] ?? '', $System_Config['telegram_request_token']),
+ 'Redis snapshot did not contain only encrypted raw Telegram configuration with a 60-second TTL.');
+ $queriesBeforeCacheHit = Configurations::$queries;
+ $redisGetsBeforeCacheHit = RedisClient::$gets;
+ TicketTelegramConfig::publicValues();
+ $assert(Configurations::$queries === $queriesBeforeCacheHit
+ && RedisClient::$gets === $redisGetsBeforeCacheHit + 1,
+ 'Warm Telegram configuration cache queried the database or loaded the snapshot more than once.');
+ $clearConfigCache();
+ RedisClient::$fail = true;
+ $queriesBeforeFallback = Configurations::$queries;
+ $assert(TicketTelegramConfig::publicValues()['configured']
+ && Configurations::$queries > $queriesBeforeFallback,
+ 'Redis failure did not fall back to the Telegram configuration database rows.');
+ RedisClient::$fail = false;
+ TicketTelegramConfig::publicValues();
+ $expectRejected(fn () => TicketTelegramCredentialCipher::decrypt(
+ Configurations::$rows[TicketTelegramConfig::BOT_TOKEN]->value,
+ 'webhook_secret'
+ ), 'Purpose-separated Telegram ciphertext was accepted as another credential type.');
$assert(preg_match('/^[a-f0-9]{48}$/D', $binding['code']) === 1 && $binding['expires_in'] === 300,
'Binding code entropy/TTL changed.');
$assert($state()['pending_hash'] === hash('sha256', $binding['code'])
@@ -214,49 +324,140 @@ namespace {
$assert(count(BotApi::$calls) === $calls, 'Rejected notification still invoked Telegram.');
$controller = new TelegramController();
+ Auth::$user = User::$users[1];
+ $secretBeforeAtomicSave = TicketTelegramConfig::runtime(true)['webhook_secret'];
+ $saveRequest = new TelegramTestRequest('', new TelegramTestStream(''), [
+ 'telegram_enabled' => 'true',
+ 'telegram_webhook_base_url' => 'https://tg.example.invalid/',
+ 'telegram_bot_token' => '',
+ 'telegram_rotate_webhook_secret' => 'true',
+ ]);
+ $deletesBeforeSave = RedisClient::$deletes;
+ $saved = $controller->save($saveRequest, new TelegramTestResponse(), []);
+ $assert($saved->status === 200 && ($saved->payload['ret'] ?? 0) === 1
+ && ($saved->payload['config']['webhook_url'] ?? '') === 'https://tg.example.invalid/telegram_callback'
+ && !str_contains(json_encode($saved->payload), $System_Config['telegram_token'])
+ && !str_contains(json_encode($saved->payload), $System_Config['telegram_request_token'])
+ && RedisClient::$deletes > $deletesBeforeSave
+ && TicketTelegramConfig::runtime(true)['webhook_secret'] !== $secretBeforeAtomicSave,
+ 'Administrator config save failed or returned Telegram secrets.');
+ $validTokenCipher = Configurations::$rows[TicketTelegramConfig::BOT_TOKEN]->value;
+ Configurations::$rows[TicketTelegramConfig::BOT_TOKEN]->value = 'corrupt-ciphertext';
+ $invalidSavedToken = $controller->save(new TelegramTestRequest('', new TelegramTestStream(''), [
+ 'telegram_enabled' => 'true',
+ 'telegram_webhook_base_url' => 'https://tg.example.invalid',
+ 'telegram_bot_token' => '',
+ ]), new TelegramTestResponse(), []);
+ $assert($invalidSavedToken->status === 422 && ($invalidSavedToken->payload['ret'] ?? 1) === 0,
+ 'Enabled configuration accepted an unreadable stored bot token.');
+ Configurations::$rows[TicketTelegramConfig::BOT_TOKEN]->value = $validTokenCipher;
+ $setState(['bound_admin_id' => 1, 'chat_id' => '123456']);
+ $replacementToken = '987654321:' . str_repeat('B', 35);
+ $replaced = $controller->save(new TelegramTestRequest('', new TelegramTestStream(''), [
+ 'telegram_enabled' => 'true',
+ 'telegram_webhook_base_url' => 'https://tg.example.invalid',
+ 'telegram_bot_token' => $replacementToken,
+ ]), new TelegramTestResponse(), []);
+ $assert($replaced->status === 200 && !isset(Configurations::$rows[TicketTelegramConfig::BINDING])
+ && !str_contains(json_encode($replaced->payload), $replacementToken)
+ && !str_contains(RedisClient::$store[$configCacheKey] ?? '', $replacementToken),
+ 'Replacing the bot token retained the old binding or exposed the new token.');
foreach ([User::$users[2], new User(1, 0), new User(1, 1, 0)] as $account) {
Auth::$user = $account;
- foreach (['bind', 'unbind', 'webhook'] as $action) {
+ foreach (['save', 'rotateSecret', 'bind', 'unbind', 'webhook'] as $action) {
$result = $controller->$action(null, new TelegramTestResponse(), []);
$assert($result->status === 403, 'Direct action bypass allows an ordinary/downgraded/disabled account: ' . $action);
}
}
+ Auth::$user = User::$users[1];
+
$webhook = new TelegramWebhookController();
+ $webhookSecret = TicketTelegramConfig::runtime(true)['webhook_secret'];
$unauthorized = new TelegramTestRequest('incorrect-secret', new TelegramTestStream('{}'));
$assert($webhook->handle($unauthorized, new TelegramTestResponse(), [])->status === 403
&& $unauthorized->stream->bytesRequested === 0, 'Webhook secret rejection occurs after processing the body.');
foreach ([true, false] as $knownSize) {
- $oversized = new TelegramTestRequest($System_Config['telegram_request_token'], new TelegramTestStream(str_repeat('x', 65537), $knownSize));
+ $oversized = new TelegramTestRequest($webhookSecret, new TelegramTestStream(str_repeat('x', 65537), $knownSize));
$assert($webhook->handle($oversized, new TelegramTestResponse(), [])->status === 413,
'Oversized webhook body was accepted.');
$assert($oversized->stream->bytesRequested <= 65537, 'Unknown-length webhook body was read without a limit.');
}
- $badJson = new TelegramTestRequest($System_Config['telegram_request_token'], new TelegramTestStream('{broken'));
+ $badJson = new TelegramTestRequest($webhookSecret, new TelegramTestStream('{broken'));
$assert($webhook->handle($badJson, new TelegramTestResponse(), [])->status === 400, 'Malformed webhook JSON accepted.');
- $System_Config['enable_telegram'] = false;
- $disabled = new TelegramTestRequest($System_Config['telegram_request_token'], new TelegramTestStream('{}'));
+ Configurations::$rows[TicketTelegramConfig::ENABLED]->value = 'false';
+ $clearConfigCache();
+ $disabled = new TelegramTestRequest($webhookSecret, new TelegramTestStream('{}'));
$assert($webhook->handle($disabled, new TelegramTestResponse(), [])->status === 403,
'Disabled bot still accepts webhooks.');
- $System_Config['enable_telegram'] = true;
+ Configurations::$rows[TicketTelegramConfig::ENABLED]->value = 'true';
+ $clearConfigCache();
$assert(TicketTelegramNotifier::registerWebhook(), 'Configured HTTPS webhook registration failed.');
$registration = BotApi::$calls[count(BotApi::$calls) - 1];
$assert($registration[0] === 'setWebhook' && $registration[2] === 10
- && $registration[1]['secret_token'] === $System_Config['telegram_request_token']
+ && $registration[1]['url'] === 'https://tg.example.invalid/telegram_callback'
+ && $registration[1]['secret_token'] === $webhookSecret
&& $registration[1]['allowed_updates'] === '["message"]',
'Webhook registration lost its secret, timeout or message-only update boundary.');
- $System_Config['baseUrl'] = 'http://example.invalid';
- $expectRejected(fn () => TicketTelegramNotifier::registerWebhook(), 'Non-HTTPS webhook URL accepted.');
- $System_Config['baseUrl'] = 'https://example.invalid';
+ $expectRejected(fn () => TicketTelegramConfig::save([
+ 'enabled' => true,
+ 'webhook_base_url' => 'http://example.invalid',
+ ]), 'Non-HTTPS webhook URL accepted.');
+ TicketTelegramConfig::publicValues();
+ $preRotationSnapshot = RedisClient::$store[$configCacheKey] ?? '';
+ $oldSecret = $webhookSecret;
+ $deletesBeforeRotate = RedisClient::$deletes;
+ $rotated = $controller->rotateSecret(null, new TelegramTestResponse(), []);
+ $webhookSecret = TicketTelegramConfig::runtime(true)['webhook_secret'];
+ // Simulate a cache-aside race repopulating the pre-rotation encrypted snapshot.
+ RedisClient::$store[$configCacheKey] = $preRotationSnapshot;
+ RedisClient::$ttls[$configCacheKey] = 60;
+ $queriesBeforeAuthoritativeChecks = Configurations::$queries;
+ $assert($rotated->status === 200 && $oldSecret !== $webhookSecret
+ && RedisClient::$deletes > $deletesBeforeRotate
+ && !TicketTelegramNotifier::authorizeWebhook($oldSecret)
+ && TicketTelegramNotifier::authorizeWebhook($webhookSecret)
+ && Configurations::$queries >= $queriesBeforeAuthoritativeChecks + 2,
+ 'Webhook secret rotation or authoritative runtime reads accepted a stale cached secret.');
BotApi::$fail = true;
$failure = '';
try { TicketTelegramNotifier::registerWebhook(); }
catch (RuntimeException $exception) { $failure = $exception->getMessage(); }
- $assert($failure !== '' && !str_contains($failure, $System_Config['telegram_token']),
+ $assert($failure !== '' && !str_contains($failure, TicketTelegramConfig::runtime(true)['bot_token']),
'SDK failure leaked the Telegram bot token.');
BotApi::$fail = false;
+ $clearConfigCache();
+ Configurations::$failQueries = true;
+ $failure = '';
+ try { TicketTelegramNotifier::registerWebhook(); }
+ catch (RuntimeException $exception) { $failure = $exception->getMessage(); }
+ Configurations::$failQueries = false;
+ $assert($failure === 'Telegram 配置读取失败,请检查数据库与服务器日志'
+ && !str_contains($failure, 'SQLSTATE'), 'Database error details leaked through webhook registration.');
+
+ // Bad legacy values must be consumed once without trapping the administrator in a migration loop.
+ Configurations::$rows = [];
+ $clearConfigCache();
+ $System_Config['enable_telegram'] = 'true';
+ $System_Config['telegram_token'] = 'invalid legacy token';
+ $System_Config['telegram_request_token'] = 'short';
+ $System_Config['tgUrl'] = 'http://insecure.example.invalid/path';
+ $legacy = TicketTelegramConfig::publicValues();
+ $assert((string) Configurations::$rows[TicketTelegramConfig::MIGRATION_MARKER]->value === '1'
+ && !$legacy['bot_token_configured'] && $legacy['webhook_base_url'] === '' && !$legacy['configured'],
+ 'Invalid legacy Telegram values blocked or polluted the one-time migration.');
+
+ // A clean installation must not need the payload key until an administrator saves credentials.
+ Configurations::$rows = [];
+ $clearConfigCache();
+ CloudSecrets::$calls = 0;
+ unset($System_Config['enable_telegram'], $System_Config['telegram_token'],
+ $System_Config['telegram_request_token'], $System_Config['tgUrl']);
+ $fresh = TicketTelegramConfig::publicValues();
+ $assert(!$fresh['enabled'] && !$fresh['bot_token_configured'] && !$fresh['webhook_secret_configured']
+ && CloudSecrets::$calls === 0, 'Fresh Telegram configuration unexpectedly required credential decryption.');
$routes = file_get_contents(dirname(__DIR__) . '/config/routes.php');
- foreach (['bind', 'unbind', 'webhook'] as $action) {
+ foreach (['config', 'secret/rotate', 'bind', 'unbind', 'webhook'] as $action) {
$matches = array_filter(explode("\n", $routes), fn ($line) => str_contains($line, "'/telegram/" . $action . "'"));
$assert(count($matches) === 1 && str_contains(reset($matches), 'new SuperAdmin()'),
'Administrator mutation route lost SuperAdmin/CSRF middleware: ' . $action);