const{ CookieJar, Cookie }=require('tough-cookie');const{ FtpCookieStore }=require('tough-cookie-ftp-store');constftpConfig={host: 'example.com',port: 21,user: 'my-username',password: 'my-secret-password',secure: false};constfilePath='/cookies/my-cookies.json';constmain=async()=>{// create clientconststore=newFtpCookieStore(filePath,{timeout: 30000,// ftp connection timeout, in ms (30 seconds)debug: false});// connect to ftp serverawaitstore.connect(ftpConfig);// create a cookie jarconstcookieJar=newCookieJar(store);// set an example cookieconstcookie=Cookie.parse('foo=bar; Domain=example.com; Path=/');// put cookie to cookie jarawaitcookieJar.setCookie(cookie,'http://example.com',(error,cookie)=>{// handle errorsif(error){console.log(error);}// show cookieconsole.log(cookie);// kill ftp connectionstore.disconnect();});}