GramJS authentication in a worker

Hi. I’m new to JS and making a telegram user bot, but I can’t get through authorization. I have this code that works in NodeJS, but I can’t get it to work in a worker:

const { TelegramClient } = require(“telegram”);
const { StringSession } = require(“telegram/sessions”);

const apiId = 111111111;
const apiHash = “my_hash”;
const stringSession = new StringSession(“session_string_here”); // fill this later with the value from

(async () => {
console.log(“Loading interactive example…”);
const client = new TelegramClient(stringSession, apiId, apiHash, {
connectionRetries: 5,
await client.connect()
console.log(“You should now be connected.”);
console.log(; // Save this string to avoid logging in again
await client.sendMessage(“me”, { message: “Hello!” });

Any tips on how to make this work or implement Telegram user authorization in a worker in general are appreciated. Thanks in advance.