1- const { promises : fs } = require ( 'fs' ) ;
2- const {
3- IExecDataProtectorDeserializer,
4- } = require ( '@iexec/dataprotector-deserializer' ) ;
5- const sendTelegram = require ( './telegramService' ) ;
6- const {
7- validateWorkerEnv,
1+ import { IExecDataProtectorDeserializer } from '@iexec/dataprotector-deserializer' ;
2+ import { promises as fs } from 'fs' ;
3+ import { decryptContent , downloadEncryptedContent } from './decryptContent' ;
4+ import sendTelegram from './telegramService' ;
5+ import {
86 validateAppSecret ,
9- validateRequesterSecret,
107 validateProtectedData ,
11- } = require ( './validation' ) ;
12- const {
13- downloadEncryptedContent,
14- decryptContent,
15- } = require ( './decryptContent' ) ;
8+ validateRequesterSecret ,
9+ validateWorkerEnv ,
10+ } from './validation' ;
1611
1712async function writeTaskOutput ( path , message ) {
1813 try {
@@ -30,7 +25,6 @@ async function start() {
3025
3126 // Check worker env
3227 const workerEnv = validateWorkerEnv ( { IEXEC_OUT } ) ;
33-
3428 // Parse the app developer secret environment variable
3529 let appDeveloperSecret ;
3630 try {
@@ -51,7 +45,7 @@ async function start() {
5145 }
5246 requesterSecret = validateRequesterSecret ( requesterSecret ) ;
5347
54- // parse the protected data and get the requester secret (chatId)
48+ // Parse the protected data and get the requester secret (chatId)
5549 let protectedData ;
5650 try {
5751 const deserializer = new IExecDataProtectorDeserializer ( ) ;
@@ -61,7 +55,7 @@ async function start() {
6155 } catch ( e ) {
6256 throw Error ( `Failed to parse ProtectedData: ${ e . message } ` ) ;
6357 }
64- // validate the protected data (chatId)
58+ // Validate the protected data (chatId)
6559 validateProtectedData ( protectedData ) ;
6660
6761 const encryptedTelegramContent = await downloadEncryptedContent (
@@ -79,7 +73,6 @@ async function start() {
7973 botToken : appDeveloperSecret . TELEGRAM_BOT_TOKEN ,
8074 senderName : requesterSecret . senderName ,
8175 } ) ;
82-
8376 await writeTaskOutput (
8477 `${ workerEnv . IEXEC_OUT } /result.txt` ,
8578 JSON . stringify ( response , null , 2 )
@@ -92,4 +85,4 @@ async function start() {
9285 ) ;
9386}
9487
95- module . exports = start ;
88+ export default start ;
0 commit comments