Skip to content
This repository has been archived by the owner on Aug 18, 2023. It is now read-only.

Commit

Permalink
Merge pull request #10 from XSPGMike/fix/email-subject-changed
Browse files Browse the repository at this point in the history
fix: email subject changed
  • Loading branch information
muharamdani authored Mar 30, 2023
2 parents f3af40c + 9e3b4e5 commit 33a5dc6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
11 changes: 7 additions & 4 deletions dist/mail.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,13 @@ const getLatestEmail = async (sid_token) => {
}
return emailList.list[0];
};
const getEmailContent = async (sid_token, id) => {
const response = await fetch(`${BASEURL}?f=fetch_email&email_id=${id}&sid_token=${sid_token}`);
const content = await response.json();
return (/\b(?<!#)\d{6}\b/g.exec(content.mail_body))?.[0];
};
const getPoeOTPCode = async (sid_token) => {
const emailData = await getLatestEmail(sid_token);
// Example email subject: "Your verification code 123456"
console.log("OTP CODE: " + emailData.mail_subject.split(' ')[3]);
return emailData.mail_subject.split(' ')[3];
return (await getEmailContent(sid_token, emailData.mail_id));
};
export { createNewEmail, getEmailList, getLatestEmail, getPoeOTPCode };
export { createNewEmail, getEmailList, getLatestEmail, getEmailContent, getPoeOTPCode };
13 changes: 10 additions & 3 deletions src/mail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,23 @@ const getLatestEmail = async (sid_token) => {
return emailList.list[0];
}

const getEmailContent = async (sid_token, id) => {
const response = await fetch(`${BASEURL}?f=fetch_email&email_id=${id}&sid_token=${sid_token}`)
const content = await response.json();
return (/\b(?<!#)\d{6}\b/g.exec(content.mail_body))?.[0]
}

const getPoeOTPCode = async (sid_token) => {
const emailData = await getLatestEmail(sid_token)
// Example email subject: "Your verification code 123456"
console.log("OTP CODE: " + emailData.mail_subject.split(' ')[3]);
return emailData.mail_subject.split(' ')[3];
return (
await getEmailContent(sid_token, emailData.mail_id)
)
}

export {
createNewEmail,
getEmailList,
getLatestEmail,
getEmailContent,
getPoeOTPCode
}

0 comments on commit 33a5dc6

Please sign in to comment.