- Модуль: pull
- Путь к файлу: ~/bitrix/modules/pull/lib/auth/jwt.php
- Класс: BitrixPullAuthJwt
- Вызов: Jwt::create
static function create(array $channels = [], int $userId = 0): string
{
if (empty($channels) && $userId === 0)
{
throw new MainArgumentException("Either channel list or user id must be specified");
}
$time = time();
$data = [
'iss' => (string)Config::getHostId(),
'iat' => $time,
'exp' => $time + self::TTL,
];
if ($userId > 0)
{
$data['sub'] = (string)$userId;
}
if (!empty($channels))
{
$data['chan'] = implode(',', $channels);
}
$secret = Config::getSignatureKey();
return MainWebJWT::encode($data, $secret);
}