diff options
author | Minteck <contact@minteck.org> | 2023-02-23 19:34:56 +0100 |
---|---|---|
committer | Minteck <contact@minteck.org> | 2023-02-23 19:34:56 +0100 |
commit | 3d1cd02f27518f1a04374c7c8320cd5d82ede6e9 (patch) | |
tree | 75be5fba4368472fb11c8015aee026b2b9a71888 /school/node_modules/pronote-api/src/cas/generics/aten.js | |
parent | 8cc1f13c17fa2fb5a4410542d39e650e02945634 (diff) | |
download | pluralconnect-3d1cd02f27518f1a04374c7c8320cd5d82ede6e9.tar.gz pluralconnect-3d1cd02f27518f1a04374c7c8320cd5d82ede6e9.tar.bz2 pluralconnect-3d1cd02f27518f1a04374c7c8320cd5d82ede6e9.zip |
Updated 40 files, added 37 files, deleted 1103 files and renamed 3905 files (automated)
Diffstat (limited to 'school/node_modules/pronote-api/src/cas/generics/aten.js')
-rw-r--r-- | school/node_modules/pronote-api/src/cas/generics/aten.js | 76 |
1 files changed, 0 insertions, 76 deletions
diff --git a/school/node_modules/pronote-api/src/cas/generics/aten.js b/school/node_modules/pronote-api/src/cas/generics/aten.js deleted file mode 100644 index 44cfa83..0000000 --- a/school/node_modules/pronote-api/src/cas/generics/aten.js +++ /dev/null @@ -1,76 +0,0 @@ -const fs = require('fs'); -const path = require('path'); - -const jsdom = require('jsdom'); - -const errors = require('../../errors'); -const { getDOM, submitForm, extractStart } = require('../api'); - -// eslint-disable-next-line no-sync -const jsEncrypt = fs.readFileSync(path.join(__dirname, 'jsencrypt.min.js')); - -async function login({ url, account, username, password, startURL, atenURL, postSubmit }) -{ - if (!startURL.startsWith('http')) { - if (startURL.startsWith('/')) { - startURL = startURL.substring(1); - } - - startURL = `https://${atenURL}/${startURL}`; - } - - const jar = new jsdom.CookieJar(); - const dom = await getDOM({ - url: startURL, - jar, - runScripts: true, - hook - }); - - await submit({ dom, jar, username, password, atenURL }); - - if (postSubmit) { - await postSubmit({ dom, jar }); - } - - return extractStart(await getDOM({ - url: url + account.value + '.html', - jar, - asIs: true - })); -} - -async function submit({ dom, jar, username, password, atenURL }) -{ - dom.window.document.getElementById('user').value = username; - dom.window.document.getElementById('password').value = password; - - dom.window.eval('creerCookie(document.getElementById(\'user\'), document.getElementById(\'password\'));'); - - const result = await submitForm({ - dom, - jar, - actionRoot: `https://${atenURL}/login/` - }); - - if (result.window.document.getElementById('aten-auth')) { - throw errors.WRONG_CREDENTIALS.drop(); - } - - return submitForm({ - dom: result, - jar, - asIs: true - }); -} - -function hook(window) -{ - window.eval(jsEncrypt + '; window.JSEncrypt = JSEncrypt;'); -} - -module.exports = { - login, - submit, - hook -}; |