Nitt Webmail Auth
1.0.0
用於 NIT-T Webmail 驗證的 JavaScript 套件
npm i nitt-webmail-auth
(async() =>{
/*
Arguments for Authenticator object:
{
publicUrl = "<>", // if you have an external endpoint for login
useWebmailDirectly = false, // If webmail servers are reachable, set this to true
imapPort = 993 // the port for imap
}
Returns:
true/false that indicates if the credentials are right or wrong, if useWebmailDirectly is set to true
(OR)
The response of the external endpoint, if useWebmailDirectly is set to false and PublicUrl is provided
*/
const authenticator = new Authenticator({ useWebmailDirectly: true });
const response = await authenticator.login({
username: "<>", // rollno/username, wihtout @nitt.edu
password: "<>",
pingBeforeLogin: true, // checks if the server is reachable
});
console.log(response);
})();
註:ES6 模組。確保你的 package.json 中有"type" : "module"