diff options
author | RaindropsSys <contact@minteck.org> | 2023-06-22 23:06:12 +0200 |
---|---|---|
committer | RaindropsSys <contact@minteck.org> | 2023-06-22 23:06:12 +0200 |
commit | 23563c7188e089929b60f9e10721c6fc43a220ff (patch) | |
tree | edfe2b009c82900d4ac27db02222d2f68dcad846 /includes/external/school/node_modules/pronote-api/src | |
parent | 7a7a49332df7c852abbaa33c7e8e87f93d064d61 (diff) | |
download | pluralconnect-23563c7188e089929b60f9e10721c6fc43a220ff.tar.gz pluralconnect-23563c7188e089929b60f9e10721c6fc43a220ff.tar.bz2 pluralconnect-23563c7188e089929b60f9e10721c6fc43a220ff.zip |
Updated 15 files, added includes/maintenance/deleteUnusedAssets.php and deleted 4944 files (automated)
Diffstat (limited to 'includes/external/school/node_modules/pronote-api/src')
99 files changed, 0 insertions, 4231 deletions
diff --git a/includes/external/school/node_modules/pronote-api/src/accounts.js b/includes/external/school/node_modules/pronote-api/src/accounts.js deleted file mode 100644 index 0db0472..0000000 --- a/includes/external/school/node_modules/pronote-api/src/accounts.js +++ /dev/null @@ -1,23 +0,0 @@ -const errors = require('./errors'); - -const ACCOUNTS = [ - { name: 'student', value: 'eleve', id: 3 }, - { name: 'parent', value: 'parent', id: 2 }, - { name: 'teacher', value: 'professeur', id: 1 }, - { name: 'attendant', value: 'accompagnant', id: 25 }, - { name: 'company', value: 'entreprise', id: 4 }, - { name: 'administration', value: 'viescolaire', id: 13 } -]; - -function getAccountType(type) -{ - for (const account of ACCOUNTS) { - if (account.name === type) { - return account; - } - } - - throw errors.UNKNOWN_ACCOUNT.drop(type); -} - -module.exports = getAccountType; diff --git a/includes/external/school/node_modules/pronote-api/src/auth.js b/includes/external/school/node_modules/pronote-api/src/auth.js deleted file mode 100644 index b19b97e..0000000 --- a/includes/external/school/node_modules/pronote-api/src/auth.js +++ /dev/null @@ -1,96 +0,0 @@ -const errors = require('./errors'); -const cas = require('./cas'); -const { decipher, getLoginKey } = require('./cipher'); -const getAccountType = require('./accounts'); -const PronoteSession = require('./session'); - -const getParams = require('./fetch/pronote/params'); -const { getId, getAuthKey } = require('./fetch/pronote/auth'); -const getUser = require('./fetch/pronote/user'); - -function loginFor(type) -{ - return (url, username, password, cas = 'none') => login(url, username, password, cas, getAccountType(type)); -} - -async function login(url, username, password, cas, account) -{ - const server = getServer(url); - const start = await getStart(server, username, password, cas, account); - const session = new PronoteSession({ - serverURL: server, - sessionID: start.h, - - type: account, - - disableAES: !!start.sCrA, - disableCompress: !!start.sCoA, - - keyModulus: start.MR, - keyExponent: start.ER - }) - - session.params = await getParams(session); - if (!session.params) { - throw errors.WRONG_CREDENTIALS.drop(); - } - if (cas === 'none') { - await auth(session, username, password, false); - } else { - await auth(session, start.e, start.f, true); - } - session.user = await getUser(session); - - return session; -} - -function getServer(url) -{ - if (url.endsWith('.html')) { - return url.substring(0, url.lastIndexOf('/') + 1); - } - - if (!url.endsWith('/')) { - url += '/'; - } - - return url; -} - -async function getStart(url, username, password, casName, type) -{ - if (casName === 'names' || casName === 'getCAS' || !cas[casName]) { - throw errors.UNKNOWN_CAS.drop(casName); - } - - const account = typeof type === 'string' ? getAccountType(type) : type; - return await cas[casName](url, account, username, password); -} - -async function auth(session, username, password, fromCas) -{ - const id = await getId(session, username, fromCas); - const key = getLoginKey(username, password, id.scramble, fromCas); - - let challenge; - try { - challenge = decipher(session, id.challenge, { scrambled: true, key }); - } catch (e) { - throw errors.WRONG_CREDENTIALS.drop(); - } - - const userKey = await getAuthKey(session, challenge, key); - if (!userKey) { - throw errors.WRONG_CREDENTIALS.drop(); - } - - session.aesKey = decipher(session, userKey, { key, asBytes: true }); -} - -module.exports = { - loginStudent: loginFor('student'), - loginParent: loginFor('parent'), - - getStart, - auth -}; diff --git a/includes/external/school/node_modules/pronote-api/src/axioRequest.js b/includes/external/school/node_modules/pronote-api/src/axioRequest.js deleted file mode 100644 index 3e625c2..0000000 --- a/includes/external/school/node_modules/pronote-api/src/axioRequest.js +++ /dev/null @@ -1,86 +0,0 @@ -const axios = require('axios'); - -async function axioRequest({ url, body, data, method = 'GET', binary, jar = null }) { - let userAgent = 'Mozilla/5.0 (X11; Linux x86_64; rv:59.0) Gecko/20100101 Firefox/59.0'; - if (url.includes('teleservices.ac-nancy-metz.fr')) { - userAgent = 'FuckTheUselessProtection/1.0'; - } - - const params = encodeParams(data); - const content = { - url, - method: method.toLowerCase(), - headers: { - 'User-Agent': userAgent, - 'Content-Type': body !== undefined - ? 'application/json' - : (params !== '' && method !== 'GET' ? 'application/x-www-form-urlencoded' : ''), - 'Cookie': encodeCookies(jar) - }, - maxRedirects: 0, - validateStatus(status) { - return status === 401 || (status >= 200 && status <= 302) - } - }; - - if (binary) { - content.responseType = 'arraybuffer'; - } - - if (params) { - if (method.toUpperCase() === 'GET') { - content.url += '?' + params; - } else { - content.data = params; - } - } else if (body) { - content.data = body; - } - const response = await axios(content) - - if (response.headers['set-cookie'] && jar !== null) { - await updateCookies(response, jar, url); - } - - return response; -} - -function updateCookies(response, jar, url) { - return new Promise((accept, reject) => { - response.headers['set-cookie'].forEach(cookie => { - jar.setCookie(cookie, url, err => (err ? reject(err) : accept())); - }); - }); -} - -function encodeCookies(jar) { - if (!jar) { - return ''; - } - - let cookies = ''; - jar.toJSON().cookies.forEach(cookie => cookies += cookie.key + '=' + cookie.value + '; '); - - if (cookies.length !== 0) { - cookies = cookies.substring(0, cookies.length - 2); - } - - return cookies; -} - -function encodeParams(data) { - if (!data) { - return ''; - } - - let params = ''; - for (const k of Object.keys(data)) { - const v = data[k]; - params += `${k}=${encodeURIComponent(v)}&` - } - - return params.substring(0, params.length - 1) -} - - -module.exports = axioRequest diff --git a/includes/external/school/node_modules/pronote-api/src/cas/ac-besancon.js b/includes/external/school/node_modules/pronote-api/src/cas/ac-besancon.js deleted file mode 100644 index 9a6fe7d..0000000 --- a/includes/external/school/node_modules/pronote-api/src/cas/ac-besancon.js +++ /dev/null @@ -1,12 +0,0 @@ -const wayf = require('./generics/kdecole-wayf'); - -module.exports = (url, account, username, password) => wayf({ - url, - account, - username, - password, - - casUrl: 'cas.eclat-bfc.fr', - idp: 'BESANC-ATS_parent_eleve_2D', - atenURL: 'teleservices.ac-besancon.fr' -}); diff --git a/includes/external/school/node_modules/pronote-api/src/cas/ac-bordeaux.js b/includes/external/school/node_modules/pronote-api/src/cas/ac-bordeaux.js deleted file mode 100644 index 938ab83..0000000 --- a/includes/external/school/node_modules/pronote-api/src/cas/ac-bordeaux.js +++ /dev/null @@ -1,11 +0,0 @@ -const aten = require('./generics/aten'); - -module.exports = (url, account, username, password) => aten.login({ - url, - account, - username, - password, - - startURL: '/sso/SSO?SPEntityID=https%3A%2F%2Fmon.lyceeconnecte.fr%2Fauth%2Fsaml%2Fmetadata%2Fidp.xml', - atenURL: 'bv.ac-bordeaux.fr' -}); diff --git a/includes/external/school/node_modules/pronote-api/src/cas/ac-bordeaux2.js b/includes/external/school/node_modules/pronote-api/src/cas/ac-bordeaux2.js deleted file mode 100644 index 4fc68c3..0000000 --- a/includes/external/school/node_modules/pronote-api/src/cas/ac-bordeaux2.js +++ /dev/null @@ -1,11 +0,0 @@ -const aten = require('./generics/aten'); - -module.exports = (url, account, username, password) => aten.login({ - url, - account, - username, - password, - - startURL: '/sso/SSO?SPEntityID=https://ent2d.ac-bordeaux.fr/shibboleth', - atenURL: 'idp-fim-ts.ac-bordeaux.fr' -}); diff --git a/includes/external/school/node_modules/pronote-api/src/cas/ac-caen.js b/includes/external/school/node_modules/pronote-api/src/cas/ac-caen.js deleted file mode 100644 index 1565539..0000000 --- a/includes/external/school/node_modules/pronote-api/src/cas/ac-caen.js +++ /dev/null @@ -1,15 +0,0 @@ -const wayf = require('./generics/wayf'); - -module.exports = (url, account, username, password) => wayf({ - url, - username, - password, - - startURL: 'https://fip.itslearning.com/SP/bn/', - wayfURL: 'https://fip.itslearning.com/ds-bn/', - atenURL: 'teleservices.ac-caen.fr', - - extraParams: { - origin: 'urn:fi:ac-caen:ts:1.0' - } -}); diff --git a/includes/external/school/node_modules/pronote-api/src/cas/ac-clermont.js b/includes/external/school/node_modules/pronote-api/src/cas/ac-clermont.js deleted file mode 100644 index 6819637..0000000 --- a/includes/external/school/node_modules/pronote-api/src/cas/ac-clermont.js +++ /dev/null @@ -1,11 +0,0 @@ -const wayf = require('./generics/kdecole-wayf'); - -module.exports = (url, account, username, password) => wayf({ - url, - account, - username, - password, - - casUrl: 'cas.ent.auvergnerhonealpes.fr', - idp: 'CLERMONT-ATS' -}); diff --git a/includes/external/school/node_modules/pronote-api/src/cas/ac-dijon.js b/includes/external/school/node_modules/pronote-api/src/cas/ac-dijon.js deleted file mode 100644 index 4aded11..0000000 --- a/includes/external/school/node_modules/pronote-api/src/cas/ac-dijon.js +++ /dev/null @@ -1,12 +0,0 @@ -const wayf = require('./generics/kdecole-wayf'); - -module.exports = (url, account, username, password) => wayf({ - url, - account, - username, - password, - - casUrl: 'cas.eclat-bfc.fr', - idp: 'DIJON-ATS_parent_eleve_2D', - atenURL: 'teleservices.ac-dijon.fr' -}); diff --git a/includes/external/school/node_modules/pronote-api/src/cas/ac-grenoble.js b/includes/external/school/node_modules/pronote-api/src/cas/ac-grenoble.js deleted file mode 100644 index aaf83c8..0000000 --- a/includes/external/school/node_modules/pronote-api/src/cas/ac-grenoble.js +++ /dev/null @@ -1,11 +0,0 @@ -const wayf = require('./generics/kdecole-wayf'); - -module.exports = (url, account, username, password) => wayf({ - url, - account, - username, - password, - - casUrl: 'cas.ent.auvergnerhonealpes.fr', - idp: 'GRE-ATS' -}); diff --git a/includes/external/school/node_modules/pronote-api/src/cas/ac-lille.js b/includes/external/school/node_modules/pronote-api/src/cas/ac-lille.js deleted file mode 100644 index 8ffb82f..0000000 --- a/includes/external/school/node_modules/pronote-api/src/cas/ac-lille.js +++ /dev/null @@ -1,12 +0,0 @@ -const wayf = require('./generics/kdecole-wayf'); - -module.exports = (url, account, username, password) => wayf({ - url, - account, - username, - password, - - casUrl: 'cas.savoirsnumeriques62.fr', - idp: 'ATS_parent_eleve', - atenURL: 'teleservices.ac-lille.fr' -}); diff --git a/includes/external/school/node_modules/pronote-api/src/cas/ac-lille2.js b/includes/external/school/node_modules/pronote-api/src/cas/ac-lille2.js deleted file mode 100644 index ec3a45d..0000000 --- a/includes/external/school/node_modules/pronote-api/src/cas/ac-lille2.js +++ /dev/null @@ -1,12 +0,0 @@ -const aten = require('./generics/aten'); - -module.exports = (url, account, username, password) => aten.login({ - url, - account, - username, - password, - - // eslint-disable-next-line max-len - startURL: '/login/ct_logon_vk.jsp?CT_ORIG_URL=%2Fsso%2FSSO%3FSPEntityID%3Durn%3Afi%3Aent%3Alille-hdf-ts%3A1.0%26TARGET%3Dhttps%3A%2F%2Fwww.enthdf.fr%2F&ct_orig_uri=%2Fsso%2FSSO%3FSPEntityID%3Durn%3Afi%3Aent%3Alille-hdf-ts%3A1.0%26TARGET%3Dhttps%3A%2F%2Fwww.enthdf.fr%2F', - atenURL: 'teleservices.ac-lille.fr' -}); diff --git a/includes/external/school/node_modules/pronote-api/src/cas/ac-limoges.js b/includes/external/school/node_modules/pronote-api/src/cas/ac-limoges.js deleted file mode 100644 index db6377e..0000000 --- a/includes/external/school/node_modules/pronote-api/src/cas/ac-limoges.js +++ /dev/null @@ -1,11 +0,0 @@ -const aten = require('./generics/aten'); - -module.exports = (url, account, username, password) => aten.login({ - url, - account, - username, - password, - - startURL: '/sso/SSO?SPEntityID=https%3A%2F%2Fmon.lyceeconnecte.fr%2Fauth%2Fsaml%2Fmetadata%2Fidp.xml', - atenURL: 'teleservices.ac-limoges.fr' -}); diff --git a/includes/external/school/node_modules/pronote-api/src/cas/ac-lyon.js b/includes/external/school/node_modules/pronote-api/src/cas/ac-lyon.js deleted file mode 100644 index 3f8abd5..0000000 --- a/includes/external/school/node_modules/pronote-api/src/cas/ac-lyon.js +++ /dev/null @@ -1,11 +0,0 @@ -const wayf = require('./generics/kdecole-wayf'); - -module.exports = (url, account, username, password) => wayf({ - url, - account, - username, - password, - - casUrl: 'cas.ent.auvergnerhonealpes.fr', - idp: 'LYON-ATS' -}); diff --git a/includes/external/school/node_modules/pronote-api/src/cas/ac-montpellier.js b/includes/external/school/node_modules/pronote-api/src/cas/ac-montpellier.js deleted file mode 100644 index d7424ae..0000000 --- a/includes/external/school/node_modules/pronote-api/src/cas/ac-montpellier.js +++ /dev/null @@ -1,12 +0,0 @@ -const wayf = require('./generics/kdecole-wayf'); - -module.exports = (url, account, username, password) => wayf({ - url, - account, - username, - password, - - casUrl: 'cas.mon-ent-occitanie.fr', - idp: 'MONTP-ATS', - atenURL: 'famille.ac-montpellier.fr' -}); diff --git a/includes/external/school/node_modules/pronote-api/src/cas/ac-nancy-metz.js b/includes/external/school/node_modules/pronote-api/src/cas/ac-nancy-metz.js deleted file mode 100644 index e8623a8..0000000 --- a/includes/external/school/node_modules/pronote-api/src/cas/ac-nancy-metz.js +++ /dev/null @@ -1,12 +0,0 @@ -const wayf = require('./generics/kdecole-wayf'); - -module.exports = (url, account, username, password) => wayf({ - url, - account, - username, - password, - - casUrl: 'cas.monbureaunumerique.fr', - idp: 'NAN-ME-ATS', - atenURL: 'teleservices.ac-nancy-metz.fr' -}); diff --git a/includes/external/school/node_modules/pronote-api/src/cas/ac-nantes.js b/includes/external/school/node_modules/pronote-api/src/cas/ac-nantes.js deleted file mode 100644 index c628370..0000000 --- a/includes/external/school/node_modules/pronote-api/src/cas/ac-nantes.js +++ /dev/null @@ -1,16 +0,0 @@ -const wayf = require('./generics/wayf'); - -module.exports = (url, account, username, password) => wayf({ - url, - username, - password, - - startURL: 'https://cas3.e-lyco.fr/access/', - wayfURL: 'https://cas3.e-lyco.fr/discovery/', - atenURL: 'ats-idp.ac-nantes.fr', - - extraParams: { - origin: 'https://ats-idp.ac-nantes.fr/SAML/FIM', - action: 'selection' - } -}); diff --git a/includes/external/school/node_modules/pronote-api/src/cas/ac-orleans-tours.js b/includes/external/school/node_modules/pronote-api/src/cas/ac-orleans-tours.js deleted file mode 100644 index d0c876a..0000000 --- a/includes/external/school/node_modules/pronote-api/src/cas/ac-orleans-tours.js +++ /dev/null @@ -1,22 +0,0 @@ -const jsdom = require('jsdom'); - -const { getDOM } = require('./api'); -const educonnect = require('./generics/educonnect'); - -async function login(url, account, username, password) -{ - const jar = new jsdom.CookieJar(); - let dom = await getDOM({ - url: 'https://lycees.netocentre.fr/portail/f/welcome/normal/render.uP', - jar - }); - - dom = await getDOM({ - url: dom.window.document.getElementById('portalCASLoginLink').href + '&idpId=parentEleveEN-IdP', - jar - }); - - return educonnect({ dom, jar, url, account, username, password }); -} - -module.exports = login; diff --git a/includes/external/school/node_modules/pronote-api/src/cas/ac-poitiers.js b/includes/external/school/node_modules/pronote-api/src/cas/ac-poitiers.js deleted file mode 100644 index d4c02d9..0000000 --- a/includes/external/school/node_modules/pronote-api/src/cas/ac-poitiers.js +++ /dev/null @@ -1,11 +0,0 @@ -const aten = require('./generics/aten'); - -module.exports = (url, account, username, password) => aten.login({ - url, - account, - username, - password, - - startURL: '/sso/SSO?SPEntityID=https%3A%2F%2Fmon.lyceeconnecte.fr%2Fauth%2Fsaml%2Fmetadata%2Fidp.xml', - atenURL: 'teleservices.ac-poitiers.fr' -}); diff --git a/includes/external/school/node_modules/pronote-api/src/cas/ac-reims.js b/includes/external/school/node_modules/pronote-api/src/cas/ac-reims.js deleted file mode 100644 index 87fe262..0000000 --- a/includes/external/school/node_modules/pronote-api/src/cas/ac-reims.js +++ /dev/null @@ -1,12 +0,0 @@ -const wayf = require('./generics/kdecole-wayf'); - -module.exports = (url, account, username, password) => wayf({ - url, - account, - username, - password, - - casUrl: 'cas.monbureaunumerique.fr', - idp: 'REIMS-ATS', - atenURL: 'services-familles.ac-reims.fr' -}); diff --git a/includes/external/school/node_modules/pronote-api/src/cas/ac-rouen.js b/includes/external/school/node_modules/pronote-api/src/cas/ac-rouen.js deleted file mode 100644 index b202810..0000000 --- a/includes/external/school/node_modules/pronote-api/src/cas/ac-rouen.js +++ /dev/null @@ -1,18 +0,0 @@ -const aten = require('./generics/aten'); -const { getDOM } = require('./api'); - -module.exports = (url, account, username, password) => aten.login({ - url, - account, - username, - password, - - // eslint-disable-next-line max-len - startURL: 'https://nero.l-educdenormandie.fr/Shibboleth.sso/Login?entityID=urn:fi:ac-rouen:ts-EDUC-Normandie:1:0&target=', - atenURL: 'sso-ent.ac-rouen.fr', - - postSubmit: ({ jar }) => getDOM({ - url: 'https://nero.l-educdenormandie.fr/c/portal/nero/access', - jar - }) -}); diff --git a/includes/external/school/node_modules/pronote-api/src/cas/ac-strasbourg.js b/includes/external/school/node_modules/pronote-api/src/cas/ac-strasbourg.js deleted file mode 100644 index c064866..0000000 --- a/includes/external/school/node_modules/pronote-api/src/cas/ac-strasbourg.js +++ /dev/null @@ -1,12 +0,0 @@ -const wayf = require('./generics/kdecole-wayf'); - -module.exports = (url, account, username, password) => wayf({ - url, - account, - username, - password, - - casUrl: 'cas.monbureaunumerique.fr', - idp: 'STRAS-ATS', - atenURL: 'teleservices.ac-strasbourg.fr' -}); diff --git a/includes/external/school/node_modules/pronote-api/src/cas/ac-toulouse.js b/includes/external/school/node_modules/pronote-api/src/cas/ac-toulouse.js deleted file mode 100644 index 1c3ea76..0000000 --- a/includes/external/school/node_modules/pronote-api/src/cas/ac-toulouse.js +++ /dev/null @@ -1,11 +0,0 @@ -const wayf = require('./generics/kdecole-wayf'); - -module.exports = (url, account, username, password) => wayf({ - url, - account, - username, - password, - - casUrl: 'cas.mon-ent-occitanie.fr', - idp: 'TOULO-ENT' -}); diff --git a/includes/external/school/node_modules/pronote-api/src/cas/ac-valdoise.js b/includes/external/school/node_modules/pronote-api/src/cas/ac-valdoise.js deleted file mode 100644 index 739379d..0000000 --- a/includes/external/school/node_modules/pronote-api/src/cas/ac-valdoise.js +++ /dev/null @@ -1,10 +0,0 @@ -const wayf = require('./generics/kdecole-wayf'); - -module.exports = (url, account, username, password) => wayf({ - url, - account, - username, - password, - - casUrl: 'cas.moncollege.valdoise.fr' -}); diff --git a/includes/external/school/node_modules/pronote-api/src/cas/agora06.js b/includes/external/school/node_modules/pronote-api/src/cas/agora06.js deleted file mode 100644 index d0f8c64..0000000 --- a/includes/external/school/node_modules/pronote-api/src/cas/agora06.js +++ /dev/null @@ -1,10 +0,0 @@ -const wayf = require('./generics/kdecole-wayf'); - -module.exports = (url, account, username, password) => wayf({ - url, - account, - username, - password, - - casUrl: 'cas.agora06.fr' -}); diff --git a/includes/external/school/node_modules/pronote-api/src/cas/api.js b/includes/external/school/node_modules/pronote-api/src/cas/api.js deleted file mode 100644 index 604faf4..0000000 --- a/includes/external/school/node_modules/pronote-api/src/cas/api.js +++ /dev/null @@ -1,113 +0,0 @@ -const { JSDOM } = require('jsdom'); - -const errors = require('../errors'); -const http = require('../http'); - -// eslint-disable-next-line max-len -function submitForm({ dom, jar, asIs, runScripts, hook, method = 'POST', actionRoot, extraParams, followRedirects = true }) { - let url = dom.window.document.getElementsByTagName('form')[0].action; - - if (url.startsWith('/')) - { - url = url.substring(1); - } - - if (url.indexOf('http') === -1) - { - url = actionRoot + url; - } - - const params = getParams(dom, extraParams); - - const data = { - url, - jar, - asIs, - followRedirects, - runScripts, - hook, - data: params, - method - }; - - return getDOM(data); -} - -function getParams(dom, extra = {}) -{ - const params = {}; - - Array.prototype.forEach.call( - dom.window.document.getElementsByTagName('input'), - input => (input.name !== '' ? params[input.name] = input.value : '') - ); - - return { ...params, ...extra }; -} - -async function getDOM({ url, jar, method = 'GET', data = '', runScripts, hook, followRedirects, asIs }) -{ - let result = await http({ - url, - method, - data, - jar, - followRedirects - }); - - if (asIs) - { - return result; - } - - if (result.indexOf('<script>$(function() { startup() });</script>') !== -1) - { - result = result - .replace('<script>$(function() { startup() });</script>', '') - .replace('console.log(user+" "+pwd);', ''); - } - - return new JSDOM(result, { - runScripts: runScripts ? 'dangerously' : 'outside-only', - beforeParse(window) { - if (hook) { - hook(window) - } - }, - cookieJar: jar - }); -} - - -function extractStart(html) { - if (html.includes('Votre adresse IP est provisoirement suspendue')) { // Top 10 anime betrayals - throw errors.BANNED.drop(); - } - - if (html.includes('Le site n\'est pas disponible')) { - throw errors.CLOSED.drop(); - } - - if (!html.includes('PRONOTE')) { - throw errors.WRONG_CREDENTIALS.drop(); - } - - html = html.replace(/ /ug, '').replace(/\n/ug, ''); - - const from = 'Start('; - const to = ')}catch'; - - const start = html.substring(html.indexOf(from) + from.length, html.indexOf(to)); - const json = start. - replace(/(['"])?([a-z0-9A-Z_]+)(['"])?:/gu, '"$2": '). - replace(/'/gu, '"'); - - return JSON.parse(json); -} - -module.exports = { - submitForm, - getDOM, - getParams, - extractStart -}; diff --git a/includes/external/school/node_modules/pronote-api/src/cas/arsene76.js b/includes/external/school/node_modules/pronote-api/src/cas/arsene76.js deleted file mode 100644 index 862f588..0000000 --- a/includes/external/school/node_modules/pronote-api/src/cas/arsene76.js +++ /dev/null @@ -1,11 +0,0 @@ -const wayf = require('./generics/kdecole-wayf'); - -module.exports = (url, account, username, password) => wayf({ - url, - account, - username, - password, - - casUrl: 'cas.arsene76.fr', - idp: 'ATS_parent_eleve' -}); diff --git a/includes/external/school/node_modules/pronote-api/src/cas/atrium-sud.js b/includes/external/school/node_modules/pronote-api/src/cas/atrium-sud.js deleted file mode 100644 index c508a3d..0000000 --- a/includes/external/school/node_modules/pronote-api/src/cas/atrium-sud.js +++ /dev/null @@ -1,43 +0,0 @@ -const jsdom = require('jsdom'); -const { getDOM, extractStart } = require('./api'); - -async function login(url, account, username, password) -{ - const jar = new jsdom.CookieJar(); - let dom = await getDOM({ - url: 'https://www.atrium-sud.fr/connexion/login?service=' + url, - jar - }); - - let lt = dom.window.document.getElementsByName('lt'); - let execution = dom.window.document.getElementsByName('execution'); - lt = lt[0].value; - execution = execution[0].value; - - dom = await getDOM({ - url: 'https://www.atrium-sud.fr/connexion/login?service=' + url, - jar, - method: 'POST', - data: { - username, - password, - lt, - execution, - _eventId: 'submit', - submit: '' - }, - asIs: true - }) - - dom = await getDOM({ - url, - jar, - method: 'GET', - asIs: true, - followRedirects: true - }); - - return extractStart(dom); -} - -module.exports = login; diff --git a/includes/external/school/node_modules/pronote-api/src/cas/cybercolleges42.js b/includes/external/school/node_modules/pronote-api/src/cas/cybercolleges42.js deleted file mode 100644 index 303c119..0000000 --- a/includes/external/school/node_modules/pronote-api/src/cas/cybercolleges42.js +++ /dev/null @@ -1,11 +0,0 @@ -const wayf = require('./generics/kdecole-wayf'); - -module.exports = (url, account, username, password) => wayf({ - url, - account, - username, - password, - - casUrl: 'cas.cybercolleges42.fr', - idp: 'ATS' -}); diff --git a/includes/external/school/node_modules/pronote-api/src/cas/eure-normandie.js b/includes/external/school/node_modules/pronote-api/src/cas/eure-normandie.js deleted file mode 100644 index 541d41c..0000000 --- a/includes/external/school/node_modules/pronote-api/src/cas/eure-normandie.js +++ /dev/null @@ -1,11 +0,0 @@ -const wayf = require('./generics/kdecole-wayf'); - -module.exports = (url, account, username, password) => wayf({ - url, - account, - username, - password, - - casUrl: 'cas.ent27.fr', - idp: 'ATS' -}); diff --git a/includes/external/school/node_modules/pronote-api/src/cas/find.js b/includes/external/school/node_modules/pronote-api/src/cas/find.js deleted file mode 100644 index 020c8fa..0000000 --- a/includes/external/school/node_modules/pronote-api/src/cas/find.js +++ /dev/null @@ -1,80 +0,0 @@ -const http = require('../http'); - -const URLS = { - 'ac-besancon': 'cas.eclat-bfc.fr', - 'ac-bordeaux': 'mon.lyceeconnecte.fr', - 'ac-bordeaux2': 'ent2d.ac-bordeaux.fr', - 'ac-caen': 'fip.itslearning.com', - 'ac-clermont': 'cas.ent.auvergnerhonealpes.fr', - 'ac-dijon': 'cas.eclat-bfc.fr', - 'ac-grenoble': 'cas.ent.auvergnerhonealpes.fr', - 'ac-lille': 'cas.savoirsnumeriques62.fr', - 'ac-lille2': 'teleservices.ac-lille.fr', - 'ac-limoges': 'mon.lyceeconnecte.fr', - 'ac-lyon': 'cas.ent.auvergnerhonealpes.fr', - 'ac-montpellier': 'cas.mon-ent-occitanie.fr', - 'ac-nancy-metz': 'cas.monbureaunumerique.fr', - 'ac-nantes': 'cas3.e-lyco.fr', - 'ac-orleans-tours': 'ent.netocentre.fr', - 'ac-poitiers': 'mon.lyceeconnecte.fr', - 'ac-reims': 'cas.monbureaunumerique.fr', - 'ac-rouen': 'nero.l-educdenormandie.fr', - 'ac-strasbourg': 'cas.monbureaunumerique.fr', - 'ac-toulouse': 'cas.mon-ent-occitanie.fr', - 'ac-valdoise': 'cas.moncollege.valdoise.fr', - 'agora06': 'cas.agora06.fr', - 'arsene76': 'cas.arsene76.fr', - 'atrium-sud': 'www.atrium-sud.fr', - 'cybercolleges42': 'cas.cybercolleges42.fr', - 'eure-normandie': 'cas.ent27.fr', - 'haute-garonne': 'cas.ecollege.haute-garonne.fr', - 'hdf': 'enthdf.fr', - 'iledefrance': 'ent.iledefrance.fr', - 'moncollege-essonne': 'www.moncollege-ent.essonne.fr', - 'laclasse': 'www.laclasse.com', - 'ljr-munich': 'cas.kosmoseducation.com', - 'lyceeconnecte': 'mon.lyceeconnecte.fr', - 'parisclassenumerique': 'ent.parisclassenumerique.fr', - 'portail-famille': 'seshat.ac-orleans-tours.fr:8443', - 'seine-et-marne': 'ent77.seine-et-marne.fr', - 'somme': 'college.entsomme.fr', - 'toutatice': 'www.toutatice.fr', - 'monbureaunumerique-educonnect': 'cas.monbureaunumerique.fr' -}; - -async function find(url) -{ - if (!url.endsWith('/')) { - url += '/'; - } - - let location = await http({ url: url + 'eleve.html', followRedirects: 'get' }); - if (location.includes('<head>')) { - return 'none'; - } - - if (location.startsWith('http://') || location.startsWith('https://')) { - location = location.substring(location.indexOf('/') + 2); - } - - const host = location.substring(0, location.indexOf('/')); - - const result = []; - for (const [name, casHost] of Object.entries(URLS)) { - if (host === casHost) { - result.push(name); - } - } - - if (result.length === 0) { - return null; - } - - if (result.length === 1) { - return result[0]; - } - - return result; -} - -module.exports = find; diff --git a/includes/external/school/node_modules/pronote-api/src/cas/generics/aten.js b/includes/external/school/node_modules/pronote-api/src/cas/generics/aten.js deleted file mode 100644 index 44cfa83..0000000 --- a/includes/external/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 -}; diff --git a/includes/external/school/node_modules/pronote-api/src/cas/generics/educonnect.js b/includes/external/school/node_modules/pronote-api/src/cas/generics/educonnect.js deleted file mode 100644 index cd8e42e..0000000 --- a/includes/external/school/node_modules/pronote-api/src/cas/generics/educonnect.js +++ /dev/null @@ -1,24 +0,0 @@ -const errors = require('../../errors'); -const { submitForm } = require('../api'); - -async function login({ dom, jar, username, password }) { - dom.window.document.getElementById('username').value = username; - dom.window.document.getElementById('password').value = password; - - dom = await submitForm({ - dom, - jar, - actionRoot: 'https://educonnect.education.gouv.fr/', - extraParams: { - '_eventId_proceed': '' - } - }); - - if (!dom.window.document.querySelector('input[name=SAMLResponse]')) { - throw errors.WRONG_CREDENTIALS.drop(); - } - - return await submitForm({ dom, jar, followRedirects: false }); -} - -module.exports = login; diff --git a/includes/external/school/node_modules/pronote-api/src/cas/generics/jsencrypt.min.js b/includes/external/school/node_modules/pronote-api/src/cas/generics/jsencrypt.min.js deleted file mode 100644 index a7f4b24..0000000 --- a/includes/external/school/node_modules/pronote-api/src/cas/generics/jsencrypt.min.js +++ /dev/null @@ -1,8 +0,0 @@ -/* eslint-disable */ - -var JSEncryptExports = {}; -(function(exports) { - function BigInteger(a,b,c){null!=a&&("number"==typeof a?this.fromNumber(a,b,c):null==b&&"string"!=typeof a?this.fromString(a,256):this.fromString(a,b))}function nbi(){return new BigInteger(null)}function am1(a,b,c,d,e,f){for(;--f>=0;){var g=b*this[a++]+c[d]+e;e=Math.floor(g/67108864),c[d++]=67108863&g}return e}function am2(a,b,c,d,e,f){for(var g=32767&b,h=b>>15;--f>=0;){var i=32767&this[a],j=this[a++]>>15,k=h*i+j*g;i=g*i+((32767&k)<<15)+c[d]+(1073741823&e),e=(i>>>30)+(k>>>15)+h*j+(e>>>30),c[d++]=1073741823&i}return e}function am3(a,b,c,d,e,f){for(var g=16383&b,h=b>>14;--f>=0;){var i=16383&this[a],j=this[a++]>>14,k=h*i+j*g;i=g*i+((16383&k)<<14)+c[d]+e,e=(i>>28)+(k>>14)+h*j,c[d++]=268435455&i}return e}function int2char(a){return BI_RM.charAt(a)}function intAt(a,b){var c=BI_RC[a.charCodeAt(b)];return null==c?-1:c}function bnpCopyTo(a){for(var b=this.t-1;b>=0;--b)a[b]=this[b];a.t=this.t,a.s=this.s}function bnpFromInt(a){this.t=1,this.s=0>a?-1:0,a>0?this[0]=a:-1>a?this[0]=a+DV:this.t=0}function nbv(a){var b=nbi();return b.fromInt(a),b}function bnpFromString(a,b){var c;if(16==b)c=4;else if(8==b)c=3;else if(256==b)c=8;else if(2==b)c=1;else if(32==b)c=5;else{if(4!=b)return void this.fromRadix(a,b);c=2}this.t=0,this.s=0;for(var d=a.length,e=!1,f=0;--d>=0;){var g=8==c?255&a[d]:intAt(a,d);0>g?"-"==a.charAt(d)&&(e=!0):(e=!1,0==f?this[this.t++]=g:f+c>this.DB?(this[this.t-1]|=(g&(1<<this.DB-f)-1)<<f,this[this.t++]=g>>this.DB-f):this[this.t-1]|=g<<f,f+=c,f>=this.DB&&(f-=this.DB))}8==c&&0!=(128&a[0])&&(this.s=-1,f>0&&(this[this.t-1]|=(1<<this.DB-f)-1<<f)),this.clamp(),e&&BigInteger.ZERO.subTo(this,this)}function bnpClamp(){for(var a=this.s&this.DM;this.t>0&&this[this.t-1]==a;)--this.t}function bnToString(a){if(this.s<0)return"-"+this.negate().toString(a);var b;if(16==a)b=4;else if(8==a)b=3;else if(2==a)b=1;else if(32==a)b=5;else{if(4!=a)return this.toRadix(a);b=2}var c,d=(1<<b)-1,e=!1,f="",g=this.t,h=this.DB-g*this.DB%b;if(g-->0)for(h<this.DB&&(c=this[g]>>h)>0&&(e=!0,f=int2char(c));g>=0;)b>h?(c=(this[g]&(1<<h)-1)<<b-h,c|=this[--g]>>(h+=this.DB-b)):(c=this[g]>>(h-=b)&d,0>=h&&(h+=this.DB,--g)),c>0&&(e=!0),e&&(f+=int2char(c));return e?f:"0"}function bnNegate(){var a=nbi();return BigInteger.ZERO.subTo(this,a),a}function bnAbs(){return this.s<0?this.negate():this}function bnCompareTo(a){var b=this.s-a.s;if(0!=b)return b;var c=this.t;if(b=c-a.t,0!=b)return this.s<0?-b:b;for(;--c>=0;)if(0!=(b=this[c]-a[c]))return b;return 0}function nbits(a){var b,c=1;return 0!=(b=a>>>16)&&(a=b,c+=16),0!=(b=a>>8)&&(a=b,c+=8),0!=(b=a>>4)&&(a=b,c+=4),0!=(b=a>>2)&&(a=b,c+=2),0!=(b=a>>1)&&(a=b,c+=1),c}function bnBitLength(){return this.t<=0?0:this.DB*(this.t-1)+nbits(this[this.t-1]^this.s&this.DM)}function bnpDLShiftTo(a,b){var c;for(c=this.t-1;c>=0;--c)b[c+a]=this[c];for(c=a-1;c>=0;--c)b[c]=0;b.t=this.t+a,b.s=this.s}function bnpDRShiftTo(a,b){for(var c=a;c<this.t;++c)b[c-a]=this[c];b.t=Math.max(this.t-a,0),b.s=this.s}function bnpLShiftTo(a,b){var c,d=a%this.DB,e=this.DB-d,f=(1<<e)-1,g=Math.floor(a/this.DB),h=this.s<<d&this.DM;for(c=this.t-1;c>=0;--c)b[c+g+1]=this[c]>>e|h,h=(this[c]&f)<<d;for(c=g-1;c>=0;--c)b[c]=0;b[g]=h,b.t=this.t+g+1,b.s=this.s,b.clamp()}function bnpRShiftTo(a,b){b.s=this.s;var c=Math.floor(a/this.DB);if(c>=this.t)return void(b.t=0);var d=a%this.DB,e=this.DB-d,f=(1<<d)-1;b[0]=this[c]>>d;for(var g=c+1;g<this.t;++g)b[g-c-1]|=(this[g]&f)<<e,b[g-c]=this[g]>>d;d>0&&(b[this.t-c-1]|=(this.s&f)<<e),b.t=this.t-c,b.clamp()}function bnpSubTo(a,b){for(var c=0,d=0,e=Math.min(a.t,this.t);e>c;)d+=this[c]-a[c],b[c++]=d&this.DM,d>>=this.DB;if(a.t<this.t){for(d-=a.s;c<this.t;)d+=this[c],b[c++]=d&this.DM,d>>=this.DB;d+=this.s}else{for(d+=this.s;c<a.t;)d-=a[c],b[c++]=d&this.DM,d>>=this.DB;d-=a.s}b.s=0>d?-1:0,-1>d?b[c++]=this.DV+d:d>0&&(b[c++]=d),b.t=c,b.clamp()}function bnpMultiplyTo(a,b){var c=this.abs(),d=a.abs(),e=c.t;for(b.t=e+d.t;--e>=0;)b[e]=0;for(e=0;e<d.t;++e)b[e+c.t]=c.am(0,d[e],b,e,0,c.t);b.s=0,b.clamp(),this.s!=a.s&&BigInteger.ZERO.subTo(b,b)}function bnpSquareTo(a){for(var b=this.abs(),c=a.t=2*b.t;--c>=0;)a[c]=0;for(c=0;c<b.t-1;++c){var d=b.am(c,b[c],a,2*c,0,1);(a[c+b.t]+=b.am(c+1,2*b[c],a,2*c+1,d,b.t-c-1))>=b.DV&&(a[c+b.t]-=b.DV,a[c+b.t+1]=1)}a.t>0&&(a[a.t-1]+=b.am(c,b[c],a,2*c,0,1)),a.s=0,a.clamp()}function bnpDivRemTo(a,b,c){var d=a.abs();if(!(d.t<=0)){var e=this.abs();if(e.t<d.t)return null!=b&&b.fromInt(0),void(null!=c&&this.copyTo(c));null==c&&(c=nbi());var f=nbi(),g=this.s,h=a.s,i=this.DB-nbits(d[d.t-1]);i>0?(d.lShiftTo(i,f),e.lShiftTo(i,c)):(d.copyTo(f),e.copyTo(c));var j=f.t,k=f[j-1];if(0!=k){var l=k*(1<<this.F1)+(j>1?f[j-2]>>this.F2:0),m=this.FV/l,n=(1<<this.F1)/l,o=1<<this.F2,p=c.t,q=p-j,r=null==b?nbi():b;for(f.dlShiftTo(q,r),c.compareTo(r)>=0&&(c[c.t++]=1,c.subTo(r,c)),BigInteger.ONE.dlShiftTo(j,r),r.subTo(f,f);f.t<j;)f[f.t++]=0;for(;--q>=0;){var s=c[--p]==k?this.DM:Math.floor(c[p]*m+(c[p-1]+o)*n);if((c[p]+=f.am(0,s,c,q,0,j))<s)for(f.dlShiftTo(q,r),c.subTo(r,c);c[p]<--s;)c.subTo(r,c)}null!=b&&(c.drShiftTo(j,b),g!=h&&BigInteger.ZERO.subTo(b,b)),c.t=j,c.clamp(),i>0&&c.rShiftTo(i,c),0>g&&BigInteger.ZERO.subTo(c,c)}}}function bnMod(a){var b=nbi();return this.abs().divRemTo(a,null,b),this.s<0&&b.compareTo(BigInteger.ZERO)>0&&a.subTo(b,b),b}function Classic(a){this.m=a}function cConvert(a){return a.s<0||a.compareTo(this.m)>=0?a.mod(this.m):a}function cRevert(a){return a}function cReduce(a){a.divRemTo(this.m,null,a)}function cMulTo(a,b,c){a.multiplyTo(b,c),this.reduce(c)}function cSqrTo(a,b){a.squareTo(b),this.reduce(b)}function bnpInvDigit(){if(this.t<1)return 0;var a=this[0];if(0==(1&a))return 0;var b=3&a;return b=b*(2-(15&a)*b)&15,b=b*(2-(255&a)*b)&255,b=b*(2-((65535&a)*b&65535))&65535,b=b*(2-a*b%this.DV)%this.DV,b>0?this.DV-b:-b}function Montgomery(a){this.m=a,this.mp=a.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<a.DB-15)-1,this.mt2=2*a.t}function montConvert(a){var b=nbi();return a.abs().dlShiftTo(this.m.t,b),b.divRemTo(this.m,null,b),a.s<0&&b.compareTo(BigInteger.ZERO)>0&&this.m.subTo(b,b),b}function montRevert(a){var b=nbi();return a.copyTo(b),this.reduce(b),b}function montReduce(a){for(;a.t<=this.mt2;)a[a.t++]=0;for(var b=0;b<this.m.t;++b){var c=32767&a[b],d=c*this.mpl+((c*this.mph+(a[b]>>15)*this.mpl&this.um)<<15)&a.DM;for(c=b+this.m.t,a[c]+=this.m.am(0,d,a,b,0,this.m.t);a[c]>=a.DV;)a[c]-=a.DV,a[++c]++}a.clamp(),a.drShiftTo(this.m.t,a),a.compareTo(this.m)>=0&&a.subTo(this.m,a)}function montSqrTo(a,b){a.squareTo(b),this.reduce(b)}function montMulTo(a,b,c){a.multiplyTo(b,c),this.reduce(c)}function bnpIsEven(){return 0==(this.t>0?1&this[0]:this.s)}function bnpExp(a,b){if(a>4294967295||1>a)return BigInteger.ONE;var c=nbi(),d=nbi(),e=b.convert(this),f=nbits(a)-1;for(e.copyTo(c);--f>=0;)if(b.sqrTo(c,d),(a&1<<f)>0)b.mulTo(d,e,c);else{var g=c;c=d,d=g}return b.revert(c)}function bnModPowInt(a,b){var c;return c=256>a||b.isEven()?new Classic(b):new Montgomery(b),this.exp(a,c)}function bnClone(){var a=nbi();return this.copyTo(a),a}function bnIntValue(){if(this.s<0){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]}function bnByteValue(){return 0==this.t?this.s:this[0]<<24>>24}function bnShortValue(){return 0==this.t?this.s:this[0]<<16>>16}function bnpChunkSize(a){return Math.floor(Math.LN2*this.DB/Math.log(a))}function bnSigNum(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1}function bnpToRadix(a){if(null==a&&(a=10),0==this.signum()||2>a||a>36)return"0";var b=this.chunkSize(a),c=Math.pow(a,b),d=nbv(c),e=nbi(),f=nbi(),g="";for(this.divRemTo(d,e,f);e.signum()>0;)g=(c+f.intValue()).toString(a).substr(1)+g,e.divRemTo(d,e,f);return f.intValue().toString(a)+g}function bnpFromRadix(a,b){this.fromInt(0),null==b&&(b=10);for(var c=this.chunkSize(b),d=Math.pow(b,c),e=!1,f=0,g=0,h=0;h<a.length;++h){var i=intAt(a,h);0>i?"-"==a.charAt(h)&&0==this.signum()&&(e=!0):(g=b*g+i,++f>=c&&(this.dMultiply(d),this.dAddOffset(g,0),f=0,g=0))}f>0&&(this.dMultiply(Math.pow(b,f)),this.dAddOffset(g,0)),e&&BigInteger.ZERO.subTo(this,this)}function bnpFromNumber(a,b,c){if("number"==typeof b)if(2>a)this.fromInt(1);else for(this.fromNumber(a,c),this.testBit(a-1)||this.bitwiseTo(BigInteger.ONE.shiftLeft(a-1),op_or,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(b);)this.dAddOffset(2,0),this.bitLength()>a&&this.subTo(BigInteger.ONE.shiftLeft(a-1),this);else{var d=new Array,e=7&a;d.length=(a>>3)+1,b.nextBytes(d),e>0?d[0]&=(1<<e)-1:d[0]=0,this.fromString(d,256)}}function bnToByteArray(){var a=this.t,b=new Array;b[0]=this.s;var c,d=this.DB-a*this.DB%8,e=0;if(a-->0)for(d<this.DB&&(c=this[a]>>d)!=(this.s&this.DM)>>d&&(b[e++]=c|this.s<<this.DB-d);a>=0;)8>d?(c=(this[a]&(1<<d)-1)<<8-d,c|=this[--a]>>(d+=this.DB-8)):(c=this[a]>>(d-=8)&255,0>=d&&(d+=this.DB,--a)),0!=(128&c)&&(c|=-256),0==e&&(128&this.s)!=(128&c)&&++e,(e>0||c!=this.s)&&(b[e++]=c);return b}function bnEquals(a){return 0==this.compareTo(a)}function bnMin(a){return this.compareTo(a)<0?this:a}function bnMax(a){return this.compareTo(a)>0?this:a}function bnpBitwiseTo(a,b,c){var d,e,f=Math.min(a.t,this.t);for(d=0;f>d;++d)c[d]=b(this[d],a[d]);if(a.t<this.t){for(e=a.s&this.DM,d=f;d<this.t;++d)c[d]=b(this[d],e);c.t=this.t}else{for(e=this.s&this.DM,d=f;d<a.t;++d)c[d]=b(e,a[d]);c.t=a.t}c.s=b(this.s,a.s),c.clamp()}function op_and(a,b){return a&b}function bnAnd(a){var b=nbi();return this.bitwiseTo(a,op_and,b),b}function op_or(a,b){return a|b}function bnOr(a){var b=nbi();return this.bitwiseTo(a,op_or,b),b}function op_xor(a,b){return a^b}function bnXor(a){var b=nbi();return this.bitwiseTo(a,op_xor,b),b}function op_andnot(a,b){return a&~b}function bnAndNot(a){var b=nbi();return this.bitwiseTo(a,op_andnot,b),b}function bnNot(){for(var a=nbi(),b=0;b<this.t;++b)a[b]=this.DM&~this[b];return a.t=this.t,a.s=~this.s,a}function bnShiftLeft(a){var b=nbi();return 0>a?this.rShiftTo(-a,b):this.lShiftTo(a,b),b}function bnShiftRight(a){var b=nbi();return 0>a?this.lShiftTo(-a,b):this.rShiftTo(a,b),b}function lbit(a){if(0==a)return-1;var b=0;return 0==(65535&a)&&(a>>=16,b+=16),0==(255&a)&&(a>>=8,b+=8),0==(15&a)&&(a>>=4,b+=4),0==(3&a)&&(a>>=2,b+=2),0==(1&a)&&++b,b}function bnGetLowestSetBit(){for(var a=0;a<this.t;++a)if(0!=this[a])return a*this.DB+lbit(this[a]);return this.s<0?this.t*this.DB:-1}function cbit(a){for(var b=0;0!=a;)a&=a-1,++b;return b}function bnBitCount(){for(var a=0,b=this.s&this.DM,c=0;c<this.t;++c)a+=cbit(this[c]^b);return a}function bnTestBit(a){var b=Math.floor(a/this.DB);return b>=this.t?0!=this.s:0!=(this[b]&1<<a%this.DB)}function bnpChangeBit(a,b){var c=BigInteger.ONE.shiftLeft(a);return this.bitwiseTo(c,b,c),c}function bnSetBit(a){return this.changeBit(a,op_or)}function bnClearBit(a){return this.changeBit(a,op_andnot)}function bnFlipBit(a){return this.changeBit(a,op_xor)}function bnpAddTo(a,b){for(var c=0,d=0,e=Math.min(a.t,this.t);e>c;)d+=this[c]+a[c],b[c++]=d&this.DM,d>>=this.DB;if(a.t<this.t){for(d+=a.s;c<this.t;)d+=this[c],b[c++]=d&this.DM,d>>=this.DB;d+=this.s}else{for(d+=this.s;c<a.t;)d+=a[c],b[c++]=d&this.DM,d>>=this.DB;d+=a.s}b.s=0>d?-1:0,d>0?b[c++]=d:-1>d&&(b[c++]=this.DV+d),b.t=c,b.clamp()}function bnAdd(a){var b=nbi();return this.addTo(a,b),b}function bnSubtract(a){var b=nbi();return this.subTo(a,b),b}function bnMultiply(a){var b=nbi();return this.multiplyTo(a,b),b}function bnSquare(){var a=nbi();return this.squareTo(a),a}function bnDivide(a){var b=nbi();return this.divRemTo(a,b,null),b}function bnRemainder(a){var b=nbi();return this.divRemTo(a,null,b),b}function bnDivideAndRemainder(a){var b=nbi(),c=nbi();return this.divRemTo(a,b,c),new Array(b,c)}function bnpDMultiply(a){this[this.t]=this.am(0,a-1,this,0,0,this.t),++this.t,this.clamp()}function bnpDAddOffset(a,b){if(0!=a){for(;this.t<=b;)this[this.t++]=0;for(this[b]+=a;this[b]>=this.DV;)this[b]-=this.DV,++b>=this.t&&(this[this.t++]=0),++this[b]}}function NullExp(){}function nNop(a){return a}function nMulTo(a,b,c){a.multiplyTo(b,c)}function nSqrTo(a,b){a.squareTo(b)}function bnPow(a){return this.exp(a,new NullExp)}function bnpMultiplyLowerTo(a,b,c){var d=Math.min(this.t+a.t,b);for(c.s=0,c.t=d;d>0;)c[--d]=0;var e;for(e=c.t-this.t;e>d;++d)c[d+this.t]=this.am(0,a[d],c,d,0,this.t);for(e=Math.min(a.t,b);e>d;++d)this.am(0,a[d],c,d,0,b-d);c.clamp()}function bnpMultiplyUpperTo(a,b,c){--b;var d=c.t=this.t+a.t-b;for(c.s=0;--d>=0;)c[d]=0;for(d=Math.max(b-this.t,0);d<a.t;++d)c[this.t+d-b]=this.am(b-d,a[d],c,0,0,this.t+d-b);c.clamp(),c.drShiftTo(1,c)}function Barrett(a){this.r2=nbi(),this.q3=nbi(),BigInteger.ONE.dlShiftTo(2*a.t,this.r2),this.mu=this.r2.divide(a),this.m=a}function barrettConvert(a){if(a.s<0||a.t>2*this.m.t)return a.mod(this.m);if(a.compareTo(this.m)<0)return a;var b=nbi();return a.copyTo(b),this.reduce(b),b}function barrettRevert(a){return a}function barrettReduce(a){for(a.drShiftTo(this.m.t-1,this.r2),a.t>this.m.t+1&&(a.t=this.m.t+1,a.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);a.compareTo(this.r2)<0;)a.dAddOffset(1,this.m.t+1);for(a.subTo(this.r2,a);a.compareTo(this.m)>=0;)a.subTo(this.m,a)}function barrettSqrTo(a,b){a.squareTo(b),this.reduce(b)}function barrettMulTo(a,b,c){a.multiplyTo(b,c),this.reduce(c)}function bnModPow(a,b){var c,d,e=a.bitLength(),f=nbv(1);if(0>=e)return f;c=18>e?1:48>e?3:144>e?4:768>e?5:6,d=8>e?new Classic(b):b.isEven()?new Barrett(b):new Montgomery(b);var g=new Array,h=3,i=c-1,j=(1<<c)-1;if(g[1]=d.convert(this),c>1){var k=nbi();for(d.sqrTo(g[1],k);j>=h;)g[h]=nbi(),d.mulTo(k,g[h-2],g[h]),h+=2}var l,m,n=a.t-1,o=!0,p=nbi();for(e=nbits(a[n])-1;n>=0;){for(e>=i?l=a[n]>>e-i&j:(l=(a[n]&(1<<e+1)-1)<<i-e,n>0&&(l|=a[n-1]>>this.DB+e-i)),h=c;0==(1&l);)l>>=1,--h;if((e-=h)<0&&(e+=this.DB,--n),o)g[l].copyTo(f),o=!1;else{for(;h>1;)d.sqrTo(f,p),d.sqrTo(p,f),h-=2;h>0?d.sqrTo(f,p):(m=f,f=p,p=m),d.mulTo(p,g[l],f)}for(;n>=0&&0==(a[n]&1<<e);)d.sqrTo(f,p),m=f,f=p,p=m,--e<0&&(e=this.DB-1,--n)}return d.revert(f)}function bnGCD(a){var b=this.s<0?this.negate():this.clone(),c=a.s<0?a.negate():a.clone();if(b.compareTo(c)<0){var d=b;b=c,c=d}var e=b.getLowestSetBit(),f=c.getLowestSetBit();if(0>f)return b;for(f>e&&(f=e),f>0&&(b.rShiftTo(f,b),c.rShiftTo(f,c));b.signum()>0;)(e=b.getLowestSetBit())>0&&b.rShiftTo(e,b),(e=c.getLowestSetBit())>0&&c.rShiftTo(e,c),b.compareTo(c)>=0?(b.subTo(c,b),b.rShiftTo(1,b)):(c.subTo(b,c),c.rShiftTo(1,c));return f>0&&c.lShiftTo(f,c),c}function bnpModInt(a){if(0>=a)return 0;var b=this.DV%a,c=this.s<0?a-1:0;if(this.t>0)if(0==b)c=this[0]%a;else for(var d=this.t-1;d>=0;--d)c=(b*c+this[d])%a;return c}function bnModInverse(a){var b=a.isEven();if(this.isEven()&&b||0==a.signum())return BigInteger.ZERO;for(var c=a.clone(),d=this.clone(),e=nbv(1),f=nbv(0),g=nbv(0),h=nbv(1);0!=c.signum();){for(;c.isEven();)c.rShiftTo(1,c),b?(e.isEven()&&f.isEven()||(e.addTo(this,e),f.subTo(a,f)),e.rShiftTo(1,e)):f.isEven()||f.subTo(a,f),f.rShiftTo(1,f);for(;d.isEven();)d.rShiftTo(1,d),b?(g.isEven()&&h.isEven()||(g.addTo(this,g),h.subTo(a,h)),g.rShiftTo(1,g)):h.isEven()||h.subTo(a,h),h.rShiftTo(1,h);c.compareTo(d)>=0?(c.subTo(d,c),b&&e.subTo(g,e),f.subTo(h,f)):(d.subTo(c,d),b&&g.subTo(e,g),h.subTo(f,h))}return 0!=d.compareTo(BigInteger.ONE)?BigInteger.ZERO:h.compareTo(a)>=0?h.subtract(a):h.signum()<0?(h.addTo(a,h),h.signum()<0?h.add(a):h):h}function bnIsProbablePrime(a){var b,c=this.abs();if(1==c.t&&c[0]<=lowprimes[lowprimes.length-1]){for(b=0;b<lowprimes.length;++b)if(c[0]==lowprimes[b])return!0;return!1}if(c.isEven())return!1;for(b=1;b<lowprimes.length;){for(var d=lowprimes[b],e=b+1;e<lowprimes.length&&lplim>d;)d*=lowprimes[e++];for(d=c.modInt(d);e>b;)if(d%lowprimes[b++]==0)return!1}return c.millerRabin(a)}function bnpMillerRabin(a){var b=this.subtract(BigInteger.ONE),c=b.getLowestSetBit();if(0>=c)return!1;var d=b.shiftRight(c);a=a+1>>1,a>lowprimes.length&&(a=lowprimes.length);for(var e=nbi(),f=0;a>f;++f){e.fromInt(lowprimes[Math.floor(Math.random()*lowprimes.length)]);var g=e.modPow(d,this);if(0!=g.compareTo(BigInteger.ONE)&&0!=g.compareTo(b)){for(var h=1;h++<c&&0!=g.compareTo(b);)if(g=g.modPowInt(2,this),0==g.compareTo(BigInteger.ONE))return!1;if(0!=g.compareTo(b))return!1}}return!0}function Arcfour(){this.i=0,this.j=0,this.S=new Array}function ARC4init(a){var b,c,d;for(b=0;256>b;++b)this.S[b]=b;for(c=0,b=0;256>b;++b)c=c+this.S[b]+a[b%a.length]&255,d=this.S[b],this.S[b]=this.S[c],this.S[c]=d;this.i=0,this.j=0}function ARC4next(){var a;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,a=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=a,this.S[a+this.S[this.i]&255]}function prng_newstate(){return new Arcfour}function rng_get_byte(){if(null==rng_state){for(rng_state=prng_newstate();rng_psize>rng_pptr;){var a=Math.floor(65536*Math.random());rng_pool[rng_pptr++]=255&a}for(rng_state.init(rng_pool),rng_pptr=0;rng_pptr<rng_pool.length;++rng_pptr)rng_pool[rng_pptr]=0;rng_pptr=0}return rng_state.next()}function rng_get_bytes(a){var b;for(b=0;b<a.length;++b)a[b]=rng_get_byte()}function SecureRandom(){}function parseBigInt(a,b){return new BigInteger(a,b)}function linebrk(a,b){for(var c="",d=0;d+b<a.length;)c+=a.substring(d,d+b)+"\n",d+=b;return c+a.substring(d,a.length)}function byte2Hex(a){return 16>a?"0"+a.toString(16):a.toString(16)}function pkcs1pad2(a,b){if(b<a.length+11)return console.error("Message too long for RSA"),null;for(var c=new Array,d=a.length-1;d>=0&&b>0;){var e=a.charCodeAt(d--);128>e?c[--b]=e:e>127&&2048>e?(c[--b]=63&e|128,c[--b]=e>>6|192):(c[--b]=63&e|128,c[--b]=e>>6&63|128,c[--b]=e>>12|224)}c[--b]=0;for(var f=new SecureRandom,g=new Array;b>2;){for(g[0]=0;0==g[0];)f.nextBytes(g);c[--b]=g[0]}return c[--b]=2,c[--b]=0,new BigInteger(c)}function RSAKey(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}function RSASetPublic(a,b){null!=a&&null!=b&&a.length>0&&b.length>0?(this.n=parseBigInt(a,16),this.e=parseInt(b,16)):console.error("Invalid RSA public key")}function RSADoPublic(a){return a.modPowInt(this.e,this.n)}function RSAEncrypt(a){var b=pkcs1pad2(a,this.n.bitLength()+7>>3);if(null==b)return null;var c=this.doPublic(b);if(null==c)return null;var d=c.toString(16);return 0==(1&d.length)?d:"0"+d}function pkcs1unpad2(a,b){for(var c=a.toByteArray(),d=0;d<c.length&&0==c[d];)++d;if(c.length-d!=b-1||2!=c[d])return null;for(++d;0!=c[d];)if(++d>=c.length)return null;for(var e="";++d<c.length;){var f=255&c[d];128>f?e+=String.fromCharCode(f):f>191&&224>f?(e+=String.fromCharCode((31&f)<<6|63&c[d+1]),++d):(e+=String.fromCharCode((15&f)<<12|(63&c[d+1])<<6|63&c[d+2]),d+=2)}return e}function RSASetPrivate(a,b,c){null!=a&&null!=b&&a.length>0&&b.length>0?(this.n=parseBigInt(a,16),this.e=parseInt(b,16),this.d=parseBigInt(c,16)):console.error("Invalid RSA private key")}function RSASetPrivateEx(a,b,c,d,e,f,g,h){null!=a&&null!=b&&a.length>0&&b.length>0?(this.n=parseBigInt(a,16),this.e=parseInt(b,16),this.d=parseBigInt(c,16),this.p=parseBigInt(d,16),this.q=parseBigInt(e,16),this.dmp1=parseBigInt(f,16),this.dmq1=parseBigInt(g,16),this.coeff=parseBigInt(h,16)):console.error("Invalid RSA private key")}function RSAGenerate(a,b){var c=new SecureRandom,d=a>>1;this.e=parseInt(b,16);for(var e=new BigInteger(b,16);;){for(;this.p=new BigInteger(a-d,1,c),0!=this.p.subtract(BigInteger.ONE).gcd(e).compareTo(BigInteger.ONE)||!this.p.isProbablePrime(10););for(;this.q=new BigInteger(d,1,c),0!=this.q.subtract(BigInteger.ONE).gcd(e).compareTo(BigInteger.ONE)||!this.q.isProbablePrime(10););if(this.p.compareTo(this.q)<=0){var f=this.p;this.p=this.q,this.q=f}var g=this.p.subtract(BigInteger.ONE),h=this.q.subtract(BigInteger.ONE),i=g.multiply(h);if(0==i.gcd(e).compareTo(BigInteger.ONE)){this.n=this.p.multiply(this.q),this.d=e.modInverse(i),this.dmp1=this.d.mod(g),this.dmq1=this.d.mod(h),this.coeff=this.q.modInverse(this.p);break}}}function RSADoPrivate(a){if(null==this.p||null==this.q)return a.modPow(this.d,this.n);for(var b=a.mod(this.p).modPow(this.dmp1,this.p),c=a.mod(this.q).modPow(this.dmq1,this.q);b.compareTo(c)<0;)b=b.add(this.p);return b.subtract(c).multiply(this.coeff).mod(this.p).multiply(this.q).add(c)}function RSADecrypt(a){var b=parseBigInt(a,16),c=this.doPrivate(b);return null==c?null:pkcs1unpad2(c,this.n.bitLength()+7>>3)}function hex2b64(a){var b,c,d="";for(b=0;b+3<=a.length;b+=3)c=parseInt(a.substring(b,b+3),16),d+=b64map.charAt(c>>6)+b64map.charAt(63&c);for(b+1==a.length?(c=parseInt(a.substring(b,b+1),16),d+=b64map.charAt(c<<2)):b+2==a.length&&(c=parseInt(a.substring(b,b+2),16),d+=b64map.charAt(c>>2)+b64map.charAt((3&c)<<4));(3&d.length)>0;)d+=b64pad;return d}function b64tohex(a){var b,c,d="",e=0;for(b=0;b<a.length&&a.charAt(b)!=b64pad;++b)v=b64map.indexOf(a.charAt(b)),0>v||(0==e?(d+=int2char(v>>2),c=3&v,e=1):1==e?(d+=int2char(c<<2|v>>4),c=15&v,e=2):2==e?(d+=int2char(c),d+=int2char(v>>2),c=3&v,e=3):(d+=int2char(c<<2|v>>4),d+=int2char(15&v),e=0));return 1==e&&(d+=int2char(c<<2)),d}function b64toBA(a){var b,c=b64tohex(a),d=new Array;for(b=0;2*b<c.length;++b)d[b]=parseInt(c.substring(2*b,2*b+2),16);return d}var dbits,canary=0xdeadbeefcafe,j_lm=15715070==(16777215&canary);j_lm&&"Microsoft Internet Explorer"==navigator.appName?(BigInteger.prototype.am=am2,dbits=30):j_lm&&"Netscape"!=navigator.appName?(BigInteger.prototype.am=am1,dbits=26):(BigInteger.prototype.am=am3,dbits=28),BigInteger.prototype.DB=dbits,BigInteger.prototype.DM=(1<<dbits)-1,BigInteger.prototype.DV=1<<dbits;var BI_FP=52;BigInteger.prototype.FV=Math.pow(2,BI_FP),BigInteger.prototype.F1=BI_FP-dbits,BigInteger.prototype.F2=2*dbits-BI_FP;var BI_RM="0123456789abcdefghijklmnopqrstuvwxyz",BI_RC=new Array,rr,vv;for(rr="0".charCodeAt(0),vv=0;9>=vv;++vv)BI_RC[rr++]=vv;for(rr="a".charCodeAt(0),vv=10;36>vv;++vv)BI_RC[rr++]=vv;for(rr="A".charCodeAt(0),vv=10;36>vv;++vv)BI_RC[rr++]=vv;Classic.prototype.convert=cConvert,Classic.prototype.revert=cRevert,Classic.prototype.reduce=cReduce,Classic.prototype.mulTo=cMulTo,Classic.prototype.sqrTo=cSqrTo,Montgomery.prototype.convert=montConvert,Montgomery.prototype.revert=montRevert,Montgomery.prototype.reduce=montReduce,Montgomery.prototype.mulTo=montMulTo,Montgomery.prototype.sqrTo=montSqrTo,BigInteger.prototype.copyTo=bnpCopyTo,BigInteger.prototype.fromInt=bnpFromInt,BigInteger.prototype.fromString=bnpFromString,BigInteger.prototype.clamp=bnpClamp,BigInteger.prototype.dlShiftTo=bnpDLShiftTo,BigInteger.prototype.drShiftTo=bnpDRShiftTo,BigInteger.prototype.lShiftTo=bnpLShiftTo,BigInteger.prototype.rShiftTo=bnpRShiftTo,BigInteger.prototype.subTo=bnpSubTo,BigInteger.prototype.multiplyTo=bnpMultiplyTo,BigInteger.prototype.squareTo=bnpSquareTo,BigInteger.prototype.divRemTo=bnpDivRemTo,BigInteger.prototype.invDigit=bnpInvDigit,BigInteger.prototype.isEven=bnpIsEven,BigInteger.prototype.exp=bnpExp,BigInteger.prototype.toString=bnToString,BigInteger.prototype.negate=bnNegate,BigInteger.prototype.abs=bnAbs,BigInteger.prototype.compareTo=bnCompareTo,BigInteger.prototype.bitLength=bnBitLength,BigInteger.prototype.mod=bnMod,BigInteger.prototype.modPowInt=bnModPowInt,BigInteger.ZERO=nbv(0),BigInteger.ONE=nbv(1),NullExp.prototype.convert=nNop,NullExp.prototype.revert=nNop,NullExp.prototype.mulTo=nMulTo,NullExp.prototype.sqrTo=nSqrTo,Barrett.prototype.convert=barrettConvert,Barrett.prototype.revert=barrettRevert,Barrett.prototype.reduce=barrettReduce,Barrett.prototype.mulTo=barrettMulTo,Barrett.prototype.sqrTo=barrettSqrTo;var lowprimes=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],lplim=(1<<26)/lowprimes[lowprimes.length-1];BigInteger.prototype.chunkSize=bnpChunkSize,BigInteger.prototype.toRadix=bnpToRadix,BigInteger.prototype.fromRadix=bnpFromRadix,BigInteger.prototype.fromNumber=bnpFromNumber,BigInteger.prototype.bitwiseTo=bnpBitwiseTo,BigInteger.prototype.changeBit=bnpChangeBit,BigInteger.prototype.addTo=bnpAddTo,BigInteger.prototype.dMultiply=bnpDMultiply,BigInteger.prototype.dAddOffset=bnpDAddOffset,BigInteger.prototype.multiplyLowerTo=bnpMultiplyLowerTo,BigInteger.prototype.multiplyUpperTo=bnpMultiplyUpperTo,BigInteger.prototype.modInt=bnpModInt,BigInteger.prototype.millerRabin=bnpMillerRabin,BigInteger.prototype.clone=bnClone,BigInteger.prototype.intValue=bnIntValue,BigInteger.prototype.byteValue=bnByteValue,BigInteger.prototype.shortValue=bnShortValue,BigInteger.prototype.signum=bnSigNum,BigInteger.prototype.toByteArray=bnToByteArray,BigInteger.prototype.equals=bnEquals,BigInteger.prototype.min=bnMin,BigInteger.prototype.max=bnMax,BigInteger.prototype.and=bnAnd,BigInteger.prototype.or=bnOr,BigInteger.prototype.xor=bnXor,BigInteger.prototype.andNot=bnAndNot,BigInteger.prototype.not=bnNot,BigInteger.prototype.shiftLeft=bnShiftLeft,BigInteger.prototype.shiftRight=bnShiftRight,BigInteger.prototype.getLowestSetBit=bnGetLowestSetBit,BigInteger.prototype.bitCount=bnBitCount,BigInteger.prototype.testBit=bnTestBit,BigInteger.prototype.setBit=bnSetBit,BigInteger.prototype.clearBit=bnClearBit,BigInteger.prototype.flipBit=bnFlipBit,BigInteger.prototype.add=bnAdd,BigInteger.prototype.subtract=bnSubtract,BigInteger.prototype.multiply=bnMultiply,BigInteger.prototype.divide=bnDivide,BigInteger.prototype.remainder=bnRemainder,BigInteger.prototype.divideAndRemainder=bnDivideAndRemainder,BigInteger.prototype.modPow=bnModPow,BigInteger.prototype.modInverse=bnModInverse,BigInteger.prototype.pow=bnPow,BigInteger.prototype.gcd=bnGCD,BigInteger.prototype.isProbablePrime=bnIsProbablePrime,BigInteger.prototype.square=bnSquare,Arcfour.prototype.init=ARC4init,Arcfour.prototype.next=ARC4next;var rng_psize=256,rng_state,rng_pool,rng_pptr;if(null==rng_pool){rng_pool=new Array,rng_pptr=0;var t;if(window.crypto&&window.crypto.getRandomValues){var z=new Uint32Array(256);for(window.crypto.getRandomValues(z),t=0;t<z.length;++t)rng_pool[rng_pptr++]=255&z[t]}var onMouseMoveListener=function(a){if(this.count=this.count||0,this.count>=256||rng_pptr>=rng_psize)return void(window.removeEventListener?window.removeEventListener("mousemove",onMouseMoveListener):window.detachEvent&&window.detachEvent("onmousemove",onMouseMoveListener));this.count+=1;var b=a.x+a.y;rng_pool[rng_pptr++]=255&b};window.addEventListener?window.addEventListener("mousemove",onMouseMoveListener):window.attachEvent&&window.attachEvent("onmousemove",onMouseMoveListener)}SecureRandom.prototype.nextBytes=rng_get_bytes,RSAKey.prototype.doPublic=RSADoPublic,RSAKey.prototype.setPublic=RSASetPublic,RSAKey.prototype.encrypt=RSAEncrypt,RSAKey.prototype.doPrivate=RSADoPrivate,RSAKey.prototype.setPrivate=RSASetPrivate,RSAKey.prototype.setPrivateEx=RSASetPrivateEx,RSAKey.prototype.generate=RSAGenerate,RSAKey.prototype.decrypt=RSADecrypt,function(){var a=function(a,b,c){var d=new SecureRandom,e=a>>1;this.e=parseInt(b,16);var f=new BigInteger(b,16),g=this,h=function(){var b=function(){if(g.p.compareTo(g.q)<=0){var a=g.p;g.p=g.q,g.q=a}var b=g.p.subtract(BigInteger.ONE),d=g.q.subtract(BigInteger.ONE),e=b.multiply(d);0==e.gcd(f).compareTo(BigInteger.ONE)?(g.n=g.p.multiply(g.q),g.d=f.modInverse(e),g.dmp1=g.d.mod(b),g.dmq1=g.d.mod(d),g.coeff=g.q.modInverse(g.p),setTimeout(function(){c()},0)):setTimeout(h,0)},i=function(){g.q=nbi(),g.q.fromNumberAsync(e,1,d,function(){g.q.subtract(BigInteger.ONE).gcda(f,function(a){0==a.compareTo(BigInteger.ONE)&&g.q.isProbablePrime(10)?setTimeout(b,0):setTimeout(i,0)})})},j=function(){g.p=nbi(),g.p.fromNumberAsync(a-e,1,d,function(){g.p.subtract(BigInteger.ONE).gcda(f,function(a){0==a.compareTo(BigInteger.ONE)&&g.p.isProbablePrime(10)?setTimeout(i,0):setTimeout(j,0)})})};setTimeout(j,0)};setTimeout(h,0)};RSAKey.prototype.generateAsync=a;var b=function(a,b){var c=this.s<0?this.negate():this.clone(),d=a.s<0?a.negate():a.clone();if(c.compareTo(d)<0){var e=c;c=d,d=e}var f=c.getLowestSetBit(),g=d.getLowestSetBit();if(0>g)return void b(c);g>f&&(g=f),g>0&&(c.rShiftTo(g,c),d.rShiftTo(g,d));var h=function(){(f=c.getLowestSetBit())>0&&c.rShiftTo(f,c),(f=d.getLowestSetBit())>0&&d.rShiftTo(f,d),c.compareTo(d)>=0?(c.subTo(d,c),c.rShiftTo(1,c)):(d.subTo(c,d),d.rShiftTo(1,d)),c.signum()>0?setTimeout(h,0):(g>0&&d.lShiftTo(g,d),setTimeout(function(){b(d)},0))};setTimeout(h,10)};BigInteger.prototype.gcda=b;var c=function(a,b,c,d){if("number"==typeof b)if(2>a)this.fromInt(1);else{this.fromNumber(a,c),this.testBit(a-1)||this.bitwiseTo(BigInteger.ONE.shiftLeft(a-1),op_or,this),this.isEven()&&this.dAddOffset(1,0);var e=this,f=function(){e.dAddOffset(2,0),e.bitLength()>a&&e.subTo(BigInteger.ONE.shiftLeft(a-1),e),e.isProbablePrime(b)?setTimeout(function(){d()},0):setTimeout(f,0)};setTimeout(f,0)}else{var g=new Array,h=7&a;g.length=(a>>3)+1,b.nextBytes(g),h>0?g[0]&=(1<<h)-1:g[0]=0,this.fromString(g,256)}};BigInteger.prototype.fromNumberAsync=c}();var b64map="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",b64pad="=",JSX=JSX||{};JSX.env=JSX.env||{};var L=JSX,OP=Object.prototype,FUNCTION_TOSTRING="[object Function]",ADD=["toString","valueOf"];JSX.env.parseUA=function(a){var b,c=function(a){var b=0;return parseFloat(a.replace(/\./g,function(){return 1==b++?"":"."}))},d=navigator,e={ie:0,opera:0,gecko:0,webkit:0,chrome:0,mobile:null,air:0,ipad:0,iphone:0,ipod:0,ios:null,android:0,webos:0,caja:d&&d.cajaVersion,secure:!1,os:null},f=a||navigator&&navigator.userAgent,g=window&&window.location,h=g&&g.href;return e.secure=h&&0===h.toLowerCase().indexOf("https"),f&&(/windows|win32/i.test(f)?e.os="windows":/macintosh/i.test(f)?e.os="macintosh":/rhino/i.test(f)&&(e.os="rhino"),/KHTML/.test(f)&&(e.webkit=1),b=f.match(/AppleWebKit\/([^\s]*)/),b&&b[1]&&(e.webkit=c(b[1]),/ Mobile\//.test(f)?(e.mobile="Apple",b=f.match(/OS ([^\s]*)/),b&&b[1]&&(b=c(b[1].replace("_","."))),e.ios=b,e.ipad=e.ipod=e.iphone=0,b=f.match(/iPad|iPod|iPhone/),b&&b[0]&&(e[b[0].toLowerCase()]=e.ios)):(b=f.match(/NokiaN[^\/]*|Android \d\.\d|webOS\/\d\.\d/),b&&(e.mobile=b[0]),/webOS/.test(f)&&(e.mobile="WebOS",b=f.match(/webOS\/([^\s]*);/),b&&b[1]&&(e.webos=c(b[1]))),/ Android/.test(f)&&(e.mobile="Android",b=f.match(/Android ([^\s]*);/),b&&b[1]&&(e.android=c(b[1])))),b=f.match(/Chrome\/([^\s]*)/),b&&b[1]?e.chrome=c(b[1]):(b=f.match(/AdobeAIR\/([^\s]*)/),b&&(e.air=b[0]))),e.webkit||(b=f.match(/Opera[\s\/]([^\s]*)/),b&&b[1]?(e.opera=c(b[1]),b=f.match(/Version\/([^\s]*)/),b&&b[1]&&(e.opera=c(b[1])),b=f.match(/Opera Mini[^;]*/),b&&(e.mobile=b[0])):(b=f.match(/MSIE\s([^;]*)/),b&&b[1]?e.ie=c(b[1]):(b=f.match(/Gecko\/([^\s]*)/),b&&(e.gecko=1,b=f.match(/rv:([^\s\)]*)/),b&&b[1]&&(e.gecko=c(b[1]))))))),e},JSX.env.ua=JSX.env.parseUA(),JSX.isFunction=function(a){return"function"==typeof a||OP.toString.apply(a)===FUNCTION_TOSTRING},JSX._IEEnumFix=JSX.env.ua.ie?function(a,b){var c,d,e;for(c=0;c<ADD.length;c+=1)d=ADD[c],e=b[d],L.isFunction(e)&&e!=OP[d]&&(a[d]=e)}:function(){},JSX.extend=function(a,b,c){if(!b||!a)throw new Error("extend failed, please check that all dependencies are included.");var d,e=function(){};if(e.prototype=b.prototype,a.prototype=new e,a.prototype.constructor=a,a.superclass=b.prototype,b.prototype.constructor==OP.constructor&&(b.prototype.constructor=b),c){for(d in c)L.hasOwnProperty(c,d)&&(a.prototype[d]=c[d]);L._IEEnumFix(a.prototype,c)}},"undefined"!=typeof KJUR&&KJUR||(KJUR={}),"undefined"!=typeof KJUR.asn1&&KJUR.asn1||(KJUR.asn1={}),KJUR.asn1.ASN1Util=new function(){this.integerToByteHex=function(a){var b=a.toString(16);return b.length%2==1&&(b="0"+b),b},this.bigIntToMinTwosComplementsHex=function(a){var b=a.toString(16);if("-"!=b.substr(0,1))b.length%2==1?b="0"+b:b.match(/^[0-7]/)||(b="00"+b); - else{var c=b.substr(1),d=c.length;d%2==1?d+=1:b.match(/^[0-7]/)||(d+=2);for(var e="",f=0;d>f;f++)e+="f";var g=new BigInteger(e,16),h=g.xor(a).add(BigInteger.ONE);b=h.toString(16).replace(/^-/,"")}return b},this.getPEMStringFromHex=function(a,b){var c=CryptoJS.enc.Hex.parse(a),d=CryptoJS.enc.Base64.stringify(c),e=d.replace(/(.{64})/g,"$1\r\n");return e=e.replace(/\r\n$/,""),"-----BEGIN "+b+"-----\r\n"+e+"\r\n-----END "+b+"-----\r\n"}},KJUR.asn1.ASN1Object=function(){var a="";this.getLengthHexFromValue=function(){if("undefined"==typeof this.hV||null==this.hV)throw"this.hV is null or undefined.";if(this.hV.length%2==1)throw"value hex must be even length: n="+a.length+",v="+this.hV;var b=this.hV.length/2,c=b.toString(16);if(c.length%2==1&&(c="0"+c),128>b)return c;var d=c.length/2;if(d>15)throw"ASN.1 length too long to represent by 8x: n = "+b.toString(16);var e=128+d;return e.toString(16)+c},this.getEncodedHex=function(){return(null==this.hTLV||this.isModified)&&(this.hV=this.getFreshValueHex(),this.hL=this.getLengthHexFromValue(),this.hTLV=this.hT+this.hL+this.hV,this.isModified=!1),this.hTLV},this.getValueHex=function(){return this.getEncodedHex(),this.hV},this.getFreshValueHex=function(){return""}},KJUR.asn1.DERAbstractString=function(a){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);this.getString=function(){return this.s},this.setString=function(a){this.hTLV=null,this.isModified=!0,this.s=a,this.hV=stohex(this.s)},this.setStringHex=function(a){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=a},this.getFreshValueHex=function(){return this.hV},"undefined"!=typeof a&&("undefined"!=typeof a.str?this.setString(a.str):"undefined"!=typeof a.hex&&this.setStringHex(a.hex))},JSX.extend(KJUR.asn1.DERAbstractString,KJUR.asn1.ASN1Object),KJUR.asn1.DERAbstractTime=function(){KJUR.asn1.DERAbstractTime.superclass.constructor.call(this);this.localDateToUTC=function(a){utc=a.getTime()+6e4*a.getTimezoneOffset();var b=new Date(utc);return b},this.formatDate=function(a,b){var c=this.zeroPadding,d=this.localDateToUTC(a),e=String(d.getFullYear());"utc"==b&&(e=e.substr(2,2));var f=c(String(d.getMonth()+1),2),g=c(String(d.getDate()),2),h=c(String(d.getHours()),2),i=c(String(d.getMinutes()),2),j=c(String(d.getSeconds()),2);return e+f+g+h+i+j+"Z"},this.zeroPadding=function(a,b){return a.length>=b?a:new Array(b-a.length+1).join("0")+a},this.getString=function(){return this.s},this.setString=function(a){this.hTLV=null,this.isModified=!0,this.s=a,this.hV=stohex(this.s)},this.setByDateValue=function(a,b,c,d,e,f){var g=new Date(Date.UTC(a,b-1,c,d,e,f,0));this.setByDate(g)},this.getFreshValueHex=function(){return this.hV}},JSX.extend(KJUR.asn1.DERAbstractTime,KJUR.asn1.ASN1Object),KJUR.asn1.DERAbstractStructured=function(a){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);this.setByASN1ObjectArray=function(a){this.hTLV=null,this.isModified=!0,this.asn1Array=a},this.appendASN1Object=function(a){this.hTLV=null,this.isModified=!0,this.asn1Array.push(a)},this.asn1Array=new Array,"undefined"!=typeof a&&"undefined"!=typeof a.array&&(this.asn1Array=a.array)},JSX.extend(KJUR.asn1.DERAbstractStructured,KJUR.asn1.ASN1Object),KJUR.asn1.DERBoolean=function(){KJUR.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV="0101ff"},JSX.extend(KJUR.asn1.DERBoolean,KJUR.asn1.ASN1Object),KJUR.asn1.DERInteger=function(a){KJUR.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(a){this.hTLV=null,this.isModified=!0,this.hV=KJUR.asn1.ASN1Util.bigIntToMinTwosComplementsHex(a)},this.setByInteger=function(a){var b=new BigInteger(String(a),10);this.setByBigInteger(b)},this.setValueHex=function(a){this.hV=a},this.getFreshValueHex=function(){return this.hV},"undefined"!=typeof a&&("undefined"!=typeof a.bigint?this.setByBigInteger(a.bigint):"undefined"!=typeof a["int"]?this.setByInteger(a["int"]):"undefined"!=typeof a.hex&&this.setValueHex(a.hex))},JSX.extend(KJUR.asn1.DERInteger,KJUR.asn1.ASN1Object),KJUR.asn1.DERBitString=function(a){KJUR.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(a){this.hTLV=null,this.isModified=!0,this.hV=a},this.setUnusedBitsAndHexValue=function(a,b){if(0>a||a>7)throw"unused bits shall be from 0 to 7: u = "+a;var c="0"+a;this.hTLV=null,this.isModified=!0,this.hV=c+b},this.setByBinaryString=function(a){a=a.replace(/0+$/,"");var b=8-a.length%8;8==b&&(b=0);for(var c=0;b>=c;c++)a+="0";for(var d="",c=0;c<a.length-1;c+=8){var e=a.substr(c,8),f=parseInt(e,2).toString(16);1==f.length&&(f="0"+f),d+=f}this.hTLV=null,this.isModified=!0,this.hV="0"+b+d},this.setByBooleanArray=function(a){for(var b="",c=0;c<a.length;c++)b+=1==a[c]?"1":"0";this.setByBinaryString(b)},this.newFalseArray=function(a){for(var b=new Array(a),c=0;a>c;c++)b[c]=!1;return b},this.getFreshValueHex=function(){return this.hV},"undefined"!=typeof a&&("undefined"!=typeof a.hex?this.setHexValueIncludingUnusedBits(a.hex):"undefined"!=typeof a.bin?this.setByBinaryString(a.bin):"undefined"!=typeof a.array&&this.setByBooleanArray(a.array))},JSX.extend(KJUR.asn1.DERBitString,KJUR.asn1.ASN1Object),KJUR.asn1.DEROctetString=function(a){KJUR.asn1.DEROctetString.superclass.constructor.call(this,a),this.hT="04"},JSX.extend(KJUR.asn1.DEROctetString,KJUR.asn1.DERAbstractString),KJUR.asn1.DERNull=function(){KJUR.asn1.DERNull.superclass.constructor.call(this),this.hT="05",this.hTLV="0500"},JSX.extend(KJUR.asn1.DERNull,KJUR.asn1.ASN1Object),KJUR.asn1.DERObjectIdentifier=function(a){var b=function(a){var b=a.toString(16);return 1==b.length&&(b="0"+b),b},c=function(a){var c="",d=new BigInteger(a,10),e=d.toString(2),f=7-e.length%7;7==f&&(f=0);for(var g="",h=0;f>h;h++)g+="0";e=g+e;for(var h=0;h<e.length-1;h+=7){var i=e.substr(h,7);h!=e.length-7&&(i="1"+i),c+=b(parseInt(i,2))}return c};KJUR.asn1.DERObjectIdentifier.superclass.constructor.call(this),this.hT="06",this.setValueHex=function(a){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=a},this.setValueOidString=function(a){if(!a.match(/^[0-9.]+$/))throw"malformed oid string: "+a;var d="",e=a.split("."),f=40*parseInt(e[0])+parseInt(e[1]);d+=b(f),e.splice(0,2);for(var g=0;g<e.length;g++)d+=c(e[g]);this.hTLV=null,this.isModified=!0,this.s=null,this.hV=d},this.setValueName=function(a){if("undefined"==typeof KJUR.asn1.x509.OID.name2oidList[a])throw"DERObjectIdentifier oidName undefined: "+a;var b=KJUR.asn1.x509.OID.name2oidList[a];this.setValueOidString(b)},this.getFreshValueHex=function(){return this.hV},"undefined"!=typeof a&&("undefined"!=typeof a.oid?this.setValueOidString(a.oid):"undefined"!=typeof a.hex?this.setValueHex(a.hex):"undefined"!=typeof a.name&&this.setValueName(a.name))},JSX.extend(KJUR.asn1.DERObjectIdentifier,KJUR.asn1.ASN1Object),KJUR.asn1.DERUTF8String=function(a){KJUR.asn1.DERUTF8String.superclass.constructor.call(this,a),this.hT="0c"},JSX.extend(KJUR.asn1.DERUTF8String,KJUR.asn1.DERAbstractString),KJUR.asn1.DERNumericString=function(a){KJUR.asn1.DERNumericString.superclass.constructor.call(this,a),this.hT="12"},JSX.extend(KJUR.asn1.DERNumericString,KJUR.asn1.DERAbstractString),KJUR.asn1.DERPrintableString=function(a){KJUR.asn1.DERPrintableString.superclass.constructor.call(this,a),this.hT="13"},JSX.extend(KJUR.asn1.DERPrintableString,KJUR.asn1.DERAbstractString),KJUR.asn1.DERTeletexString=function(a){KJUR.asn1.DERTeletexString.superclass.constructor.call(this,a),this.hT="14"},JSX.extend(KJUR.asn1.DERTeletexString,KJUR.asn1.DERAbstractString),KJUR.asn1.DERIA5String=function(a){KJUR.asn1.DERIA5String.superclass.constructor.call(this,a),this.hT="16"},JSX.extend(KJUR.asn1.DERIA5String,KJUR.asn1.DERAbstractString),KJUR.asn1.DERUTCTime=function(a){KJUR.asn1.DERUTCTime.superclass.constructor.call(this,a),this.hT="17",this.setByDate=function(a){this.hTLV=null,this.isModified=!0,this.date=a,this.s=this.formatDate(this.date,"utc"),this.hV=stohex(this.s)},"undefined"!=typeof a&&("undefined"!=typeof a.str?this.setString(a.str):"undefined"!=typeof a.hex?this.setStringHex(a.hex):"undefined"!=typeof a.date&&this.setByDate(a.date))},JSX.extend(KJUR.asn1.DERUTCTime,KJUR.asn1.DERAbstractTime),KJUR.asn1.DERGeneralizedTime=function(a){KJUR.asn1.DERGeneralizedTime.superclass.constructor.call(this,a),this.hT="18",this.setByDate=function(a){this.hTLV=null,this.isModified=!0,this.date=a,this.s=this.formatDate(this.date,"gen"),this.hV=stohex(this.s)},"undefined"!=typeof a&&("undefined"!=typeof a.str?this.setString(a.str):"undefined"!=typeof a.hex?this.setStringHex(a.hex):"undefined"!=typeof a.date&&this.setByDate(a.date))},JSX.extend(KJUR.asn1.DERGeneralizedTime,KJUR.asn1.DERAbstractTime),KJUR.asn1.DERSequence=function(a){KJUR.asn1.DERSequence.superclass.constructor.call(this,a),this.hT="30",this.getFreshValueHex=function(){for(var a="",b=0;b<this.asn1Array.length;b++){var c=this.asn1Array[b];a+=c.getEncodedHex()}return this.hV=a,this.hV}},JSX.extend(KJUR.asn1.DERSequence,KJUR.asn1.DERAbstractStructured),KJUR.asn1.DERSet=function(a){KJUR.asn1.DERSet.superclass.constructor.call(this,a),this.hT="31",this.getFreshValueHex=function(){for(var a=new Array,b=0;b<this.asn1Array.length;b++){var c=this.asn1Array[b];a.push(c.getEncodedHex())}return a.sort(),this.hV=a.join(""),this.hV}},JSX.extend(KJUR.asn1.DERSet,KJUR.asn1.DERAbstractStructured),KJUR.asn1.DERTaggedObject=function(a){KJUR.asn1.DERTaggedObject.superclass.constructor.call(this),this.hT="a0",this.hV="",this.isExplicit=!0,this.asn1Object=null,this.setASN1Object=function(a,b,c){this.hT=b,this.isExplicit=a,this.asn1Object=c,this.isExplicit?(this.hV=this.asn1Object.getEncodedHex(),this.hTLV=null,this.isModified=!0):(this.hV=null,this.hTLV=c.getEncodedHex(),this.hTLV=this.hTLV.replace(/^../,b),this.isModified=!1)},this.getFreshValueHex=function(){return this.hV},"undefined"!=typeof a&&("undefined"!=typeof a.tag&&(this.hT=a.tag),"undefined"!=typeof a.explicit&&(this.isExplicit=a.explicit),"undefined"!=typeof a.obj&&(this.asn1Object=a.obj,this.setASN1Object(this.isExplicit,this.hT,this.asn1Object)))},JSX.extend(KJUR.asn1.DERTaggedObject,KJUR.asn1.ASN1Object),function(a){"use strict";var b,c={};c.decode=function(c){var d;if(b===a){var e="0123456789ABCDEF",f=" \f\n\r  \u2028\u2029";for(b=[],d=0;16>d;++d)b[e.charAt(d)]=d;for(e=e.toLowerCase(),d=10;16>d;++d)b[e.charAt(d)]=d;for(d=0;d<f.length;++d)b[f.charAt(d)]=-1}var g=[],h=0,i=0;for(d=0;d<c.length;++d){var j=c.charAt(d);if("="==j)break;if(j=b[j],-1!=j){if(j===a)throw"Illegal character at offset "+d;h|=j,++i>=2?(g[g.length]=h,h=0,i=0):h<<=4}}if(i)throw"Hex encoding incomplete: 4 bits missing";return g},window.Hex=c}(),function(a){"use strict";var b,c={};c.decode=function(c){var d;if(b===a){var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",f="= \f\n\r  \u2028\u2029";for(b=[],d=0;64>d;++d)b[e.charAt(d)]=d;for(d=0;d<f.length;++d)b[f.charAt(d)]=-1}var g=[],h=0,i=0;for(d=0;d<c.length;++d){var j=c.charAt(d);if("="==j)break;if(j=b[j],-1!=j){if(j===a)throw"Illegal character at offset "+d;h|=j,++i>=4?(g[g.length]=h>>16,g[g.length]=h>>8&255,g[g.length]=255&h,h=0,i=0):h<<=6}}switch(i){case 1:throw"Base64 encoding incomplete: at least 2 bits missing";case 2:g[g.length]=h>>10;break;case 3:g[g.length]=h>>16,g[g.length]=h>>8&255}return g},c.re=/-----BEGIN [^-]+-----([A-Za-z0-9+\/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+\/=\s]+)====/,c.unarmor=function(a){var b=c.re.exec(a);if(b)if(b[1])a=b[1];else{if(!b[2])throw"RegExp out of sync";a=b[2]}return c.decode(a)},window.Base64=c}(),function(a){"use strict";function b(a,c){a instanceof b?(this.enc=a.enc,this.pos=a.pos):(this.enc=a,this.pos=c)}function c(a,b,c,d,e){this.stream=a,this.header=b,this.length=c,this.tag=d,this.sub=e}var d=100,e="…",f={tag:function(a,b){var c=document.createElement(a);return c.className=b,c},text:function(a){return document.createTextNode(a)}};b.prototype.get=function(b){if(b===a&&(b=this.pos++),b>=this.enc.length)throw"Requesting byte offset "+b+" on a stream of length "+this.enc.length;return this.enc[b]},b.prototype.hexDigits="0123456789ABCDEF",b.prototype.hexByte=function(a){return this.hexDigits.charAt(a>>4&15)+this.hexDigits.charAt(15&a)},b.prototype.hexDump=function(a,b,c){for(var d="",e=a;b>e;++e)if(d+=this.hexByte(this.get(e)),c!==!0)switch(15&e){case 7:d+=" ";break;case 15:d+="\n";break;default:d+=" "}return d},b.prototype.parseStringISO=function(a,b){for(var c="",d=a;b>d;++d)c+=String.fromCharCode(this.get(d));return c},b.prototype.parseStringUTF=function(a,b){for(var c="",d=a;b>d;){var e=this.get(d++);c+=String.fromCharCode(128>e?e:e>191&&224>e?(31&e)<<6|63&this.get(d++):(15&e)<<12|(63&this.get(d++))<<6|63&this.get(d++))}return c},b.prototype.parseStringBMP=function(a,b){for(var c="",d=a;b>d;d+=2){var e=this.get(d),f=this.get(d+1);c+=String.fromCharCode((e<<8)+f)}return c},b.prototype.reTime=/^((?:1[89]|2\d)?\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/,b.prototype.parseTime=function(a,b){var c=this.parseStringISO(a,b),d=this.reTime.exec(c);return d?(c=d[1]+"-"+d[2]+"-"+d[3]+" "+d[4],d[5]&&(c+=":"+d[5],d[6]&&(c+=":"+d[6],d[7]&&(c+="."+d[7]))),d[8]&&(c+=" UTC","Z"!=d[8]&&(c+=d[8],d[9]&&(c+=":"+d[9]))),c):"Unrecognized time: "+c},b.prototype.parseInteger=function(a,b){var c=b-a;if(c>4){c<<=3;var d=this.get(a);if(0===d)c-=8;else for(;128>d;)d<<=1,--c;return"("+c+" bit)"}for(var e=0,f=a;b>f;++f)e=e<<8|this.get(f);return e},b.prototype.parseBitString=function(a,b){var c=this.get(a),d=(b-a-1<<3)-c,e="("+d+" bit)";if(20>=d){var f=c;e+=" ";for(var g=b-1;g>a;--g){for(var h=this.get(g),i=f;8>i;++i)e+=h>>i&1?"1":"0";f=0}}return e},b.prototype.parseOctetString=function(a,b){var c=b-a,f="("+c+" byte) ";c>d&&(b=a+d);for(var g=a;b>g;++g)f+=this.hexByte(this.get(g));return c>d&&(f+=e),f},b.prototype.parseOID=function(a,b){for(var c="",d=0,e=0,f=a;b>f;++f){var g=this.get(f);if(d=d<<7|127&g,e+=7,!(128&g)){if(""===c){var h=80>d?40>d?0:1:2;c=h+"."+(d-40*h)}else c+="."+(e>=31?"bigint":d);d=e=0}}return c},c.prototype.typeName=function(){if(this.tag===a)return"unknown";var b=this.tag>>6,c=(this.tag>>5&1,31&this.tag);switch(b){case 0:switch(c){case 0:return"EOC";case 1:return"BOOLEAN";case 2:return"INTEGER";case 3:return"BIT_STRING";case 4:return"OCTET_STRING";case 5:return"NULL";case 6:return"OBJECT_IDENTIFIER";case 7:return"ObjectDescriptor";case 8:return"EXTERNAL";case 9:return"REAL";case 10:return"ENUMERATED";case 11:return"EMBEDDED_PDV";case 12:return"UTF8String";case 16:return"SEQUENCE";case 17:return"SET";case 18:return"NumericString";case 19:return"PrintableString";case 20:return"TeletexString";case 21:return"VideotexString";case 22:return"IA5String";case 23:return"UTCTime";case 24:return"GeneralizedTime";case 25:return"GraphicString";case 26:return"VisibleString";case 27:return"GeneralString";case 28:return"UniversalString";case 30:return"BMPString";default:return"Universal_"+c.toString(16)}case 1:return"Application_"+c.toString(16);case 2:return"["+c+"]";case 3:return"Private_"+c.toString(16)}},c.prototype.reSeemsASCII=/^[ -~]+$/,c.prototype.content=function(){if(this.tag===a)return null;var b=this.tag>>6,c=31&this.tag,f=this.posContent(),g=Math.abs(this.length);if(0!==b){if(null!==this.sub)return"("+this.sub.length+" elem)";var h=this.stream.parseStringISO(f,f+Math.min(g,d));return this.reSeemsASCII.test(h)?h.substring(0,2*d)+(h.length>2*d?e:""):this.stream.parseOctetString(f,f+g)}switch(c){case 1:return 0===this.stream.get(f)?"false":"true";case 2:return this.stream.parseInteger(f,f+g);case 3:return this.sub?"("+this.sub.length+" elem)":this.stream.parseBitString(f,f+g);case 4:return this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(f,f+g);case 6:return this.stream.parseOID(f,f+g);case 16:case 17:return"("+this.sub.length+" elem)";case 12:return this.stream.parseStringUTF(f,f+g);case 18:case 19:case 20:case 21:case 22:case 26:return this.stream.parseStringISO(f,f+g);case 30:return this.stream.parseStringBMP(f,f+g);case 23:case 24:return this.stream.parseTime(f,f+g)}return null},c.prototype.toString=function(){return this.typeName()+"@"+this.stream.pos+"[header:"+this.header+",length:"+this.length+",sub:"+(null===this.sub?"null":this.sub.length)+"]"},c.prototype.print=function(b){if(b===a&&(b=""),document.writeln(b+this),null!==this.sub){b+=" ";for(var c=0,d=this.sub.length;d>c;++c)this.sub[c].print(b)}},c.prototype.toPrettyString=function(b){b===a&&(b="");var c=b+this.typeName()+" @"+this.stream.pos;if(this.length>=0&&(c+="+"),c+=this.length,32&this.tag?c+=" (constructed)":3!=this.tag&&4!=this.tag||null===this.sub||(c+=" (encapsulates)"),c+="\n",null!==this.sub){b+=" ";for(var d=0,e=this.sub.length;e>d;++d)c+=this.sub[d].toPrettyString(b)}return c},c.prototype.toDOM=function(){var a=f.tag("div","node");a.asn1=this;var b=f.tag("div","head"),c=this.typeName().replace(/_/g," ");b.innerHTML=c;var d=this.content();if(null!==d){d=String(d).replace(/</g,"<");var e=f.tag("span","preview");e.appendChild(f.text(d)),b.appendChild(e)}a.appendChild(b),this.node=a,this.head=b;var g=f.tag("div","value");if(c="Offset: "+this.stream.pos+"<br/>",c+="Length: "+this.header+"+",c+=this.length>=0?this.length:-this.length+" (undefined)",32&this.tag?c+="<br/>(constructed)":3!=this.tag&&4!=this.tag||null===this.sub||(c+="<br/>(encapsulates)"),null!==d&&(c+="<br/>Value:<br/><b>"+d+"</b>","object"==typeof oids&&6==this.tag)){var h=oids[d];h&&(h.d&&(c+="<br/>"+h.d),h.c&&(c+="<br/>"+h.c),h.w&&(c+="<br/>(warning!)"))}g.innerHTML=c,a.appendChild(g);var i=f.tag("div","sub");if(null!==this.sub)for(var j=0,k=this.sub.length;k>j;++j)i.appendChild(this.sub[j].toDOM());return a.appendChild(i),b.onclick=function(){a.className="node collapsed"==a.className?"node":"node collapsed"},a},c.prototype.posStart=function(){return this.stream.pos},c.prototype.posContent=function(){return this.stream.pos+this.header},c.prototype.posEnd=function(){return this.stream.pos+this.header+Math.abs(this.length)},c.prototype.fakeHover=function(a){this.node.className+=" hover",a&&(this.head.className+=" hover")},c.prototype.fakeOut=function(a){var b=/ ?hover/;this.node.className=this.node.className.replace(b,""),a&&(this.head.className=this.head.className.replace(b,""))},c.prototype.toHexDOM_sub=function(a,b,c,d,e){if(!(d>=e)){var g=f.tag("span",b);g.appendChild(f.text(c.hexDump(d,e))),a.appendChild(g)}},c.prototype.toHexDOM=function(b){var c=f.tag("span","hex");if(b===a&&(b=c),this.head.hexNode=c,this.head.onmouseover=function(){this.hexNode.className="hexCurrent"},this.head.onmouseout=function(){this.hexNode.className="hex"},c.asn1=this,c.onmouseover=function(){var a=!b.selected;a&&(b.selected=this.asn1,this.className="hexCurrent"),this.asn1.fakeHover(a)},c.onmouseout=function(){var a=b.selected==this.asn1;this.asn1.fakeOut(a),a&&(b.selected=null,this.className="hex")},this.toHexDOM_sub(c,"tag",this.stream,this.posStart(),this.posStart()+1),this.toHexDOM_sub(c,this.length>=0?"dlen":"ulen",this.stream,this.posStart()+1,this.posContent()),null===this.sub)c.appendChild(f.text(this.stream.hexDump(this.posContent(),this.posEnd())));else if(this.sub.length>0){var d=this.sub[0],e=this.sub[this.sub.length-1];this.toHexDOM_sub(c,"intro",this.stream,this.posContent(),d.posStart());for(var g=0,h=this.sub.length;h>g;++g)c.appendChild(this.sub[g].toHexDOM(b));this.toHexDOM_sub(c,"outro",this.stream,e.posEnd(),this.posEnd())}return c},c.prototype.toHexString=function(){return this.stream.hexDump(this.posStart(),this.posEnd(),!0)},c.decodeLength=function(a){var b=a.get(),c=127&b;if(c==b)return c;if(c>3)throw"Length over 24 bits not supported at position "+(a.pos-1);if(0===c)return-1;b=0;for(var d=0;c>d;++d)b=b<<8|a.get();return b},c.hasContent=function(a,d,e){if(32&a)return!0;if(3>a||a>4)return!1;var f=new b(e);3==a&&f.get();var g=f.get();if(g>>6&1)return!1;try{var h=c.decodeLength(f);return f.pos-e.pos+h==d}catch(i){return!1}},c.decode=function(a){a instanceof b||(a=new b(a,0));var d=new b(a),e=a.get(),f=c.decodeLength(a),g=a.pos-d.pos,h=null;if(c.hasContent(e,f,a)){var i=a.pos;if(3==e&&a.get(),h=[],f>=0){for(var j=i+f;a.pos<j;)h[h.length]=c.decode(a);if(a.pos!=j)throw"Content size is not correct for container starting at offset "+i}else try{for(;;){var k=c.decode(a);if(0===k.tag)break;h[h.length]=k}f=i-a.pos}catch(l){throw"Exception while decoding undefined length content: "+l}}else a.pos+=f;return new c(d,g,f,e,h)},c.test=function(){for(var a=[{value:[39],expected:39},{value:[129,201],expected:201},{value:[131,254,220,186],expected:16702650}],d=0,e=a.length;e>d;++d){var f=new b(a[d].value,0),g=c.decodeLength(f);g!=a[d].expected&&document.write("In test["+d+"] expected "+a[d].expected+" got "+g+"\n")}},window.ASN1=c}(),ASN1.prototype.getHexStringValue=function(){var a=this.toHexString(),b=2*this.header,c=2*this.length;return a.substr(b,c)},RSAKey.prototype.parseKey=function(a){try{var b=0,c=0,d=/^\s*(?:[0-9A-Fa-f][0-9A-Fa-f]\s*)+$/,e=d.test(a)?Hex.decode(a):Base64.unarmor(a),f=ASN1.decode(e);if(9===f.sub.length){b=f.sub[1].getHexStringValue(),this.n=parseBigInt(b,16),c=f.sub[2].getHexStringValue(),this.e=parseInt(c,16);var g=f.sub[3].getHexStringValue();this.d=parseBigInt(g,16);var h=f.sub[4].getHexStringValue();this.p=parseBigInt(h,16);var i=f.sub[5].getHexStringValue();this.q=parseBigInt(i,16);var j=f.sub[6].getHexStringValue();this.dmp1=parseBigInt(j,16);var k=f.sub[7].getHexStringValue();this.dmq1=parseBigInt(k,16);var l=f.sub[8].getHexStringValue();this.coeff=parseBigInt(l,16)}else{if(2!==f.sub.length)return!1;var m=f.sub[1],n=m.sub[0];b=n.sub[0].getHexStringValue(),this.n=parseBigInt(b,16),c=n.sub[1].getHexStringValue(),this.e=parseInt(c,16)}return!0}catch(o){return!1}},RSAKey.prototype.getPrivateBaseKey=function(){var a={array:[new KJUR.asn1.DERInteger({"int":0}),new KJUR.asn1.DERInteger({bigint:this.n}),new KJUR.asn1.DERInteger({"int":this.e}),new KJUR.asn1.DERInteger({bigint:this.d}),new KJUR.asn1.DERInteger({bigint:this.p}),new KJUR.asn1.DERInteger({bigint:this.q}),new KJUR.asn1.DERInteger({bigint:this.dmp1}),new KJUR.asn1.DERInteger({bigint:this.dmq1}),new KJUR.asn1.DERInteger({bigint:this.coeff})]},b=new KJUR.asn1.DERSequence(a);return b.getEncodedHex()},RSAKey.prototype.getPrivateBaseKeyB64=function(){return hex2b64(this.getPrivateBaseKey())},RSAKey.prototype.getPublicBaseKey=function(){var a={array:[new KJUR.asn1.DERObjectIdentifier({oid:"1.2.840.113549.1.1.1"}),new KJUR.asn1.DERNull]},b=new KJUR.asn1.DERSequence(a);a={array:[new KJUR.asn1.DERInteger({bigint:this.n}),new KJUR.asn1.DERInteger({"int":this.e})]};var c=new KJUR.asn1.DERSequence(a);a={hex:"00"+c.getEncodedHex()};var d=new KJUR.asn1.DERBitString(a);a={array:[b,d]};var e=new KJUR.asn1.DERSequence(a);return e.getEncodedHex()},RSAKey.prototype.getPublicBaseKeyB64=function(){return hex2b64(this.getPublicBaseKey())},RSAKey.prototype.wordwrap=function(a,b){if(b=b||64,!a)return a;var c="(.{1,"+b+"})( +|$\n?)|(.{1,"+b+"})";return a.match(RegExp(c,"g")).join("\n")},RSAKey.prototype.getPrivateKey=function(){var a="-----BEGIN RSA PRIVATE KEY-----\n";return a+=this.wordwrap(this.getPrivateBaseKeyB64())+"\n",a+="-----END RSA PRIVATE KEY-----"},RSAKey.prototype.getPublicKey=function(){var a="-----BEGIN PUBLIC KEY-----\n";return a+=this.wordwrap(this.getPublicBaseKeyB64())+"\n",a+="-----END PUBLIC KEY-----"},RSAKey.prototype.hasPublicKeyProperty=function(a){return a=a||{},a.hasOwnProperty("n")&&a.hasOwnProperty("e")},RSAKey.prototype.hasPrivateKeyProperty=function(a){return a=a||{},a.hasOwnProperty("n")&&a.hasOwnProperty("e")&&a.hasOwnProperty("d")&&a.hasOwnProperty("p")&&a.hasOwnProperty("q")&&a.hasOwnProperty("dmp1")&&a.hasOwnProperty("dmq1")&&a.hasOwnProperty("coeff")},RSAKey.prototype.parsePropertiesFrom=function(a){this.n=a.n,this.e=a.e,a.hasOwnProperty("d")&&(this.d=a.d,this.p=a.p,this.q=a.q,this.dmp1=a.dmp1,this.dmq1=a.dmq1,this.coeff=a.coeff)};var JSEncryptRSAKey=function(a){RSAKey.call(this),a&&("string"==typeof a?this.parseKey(a):(this.hasPrivateKeyProperty(a)||this.hasPublicKeyProperty(a))&&this.parsePropertiesFrom(a))};JSEncryptRSAKey.prototype=new RSAKey,JSEncryptRSAKey.prototype.constructor=JSEncryptRSAKey;var JSEncrypt=function(a){a=a||{},this.default_key_size=parseInt(a.default_key_size)||1024,this.default_public_exponent=a.default_public_exponent||"010001",this.log=a.log||!1,this.key=null};JSEncrypt.prototype.setKey=function(a){this.log&&this.key&&console.warn("A key was already set, overriding existing."),this.key=new JSEncryptRSAKey(a)},JSEncrypt.prototype.setPrivateKey=function(a){this.setKey(a)},JSEncrypt.prototype.setPublicKey=function(a){this.setKey(a)},JSEncrypt.prototype.decrypt=function(a){try{return this.getKey().decrypt(b64tohex(a))}catch(b){return!1}},JSEncrypt.prototype.encrypt=function(a){try{return hex2b64(this.getKey().encrypt(a))}catch(b){return!1}},JSEncrypt.prototype.getKey=function(a){if(!this.key){if(this.key=new JSEncryptRSAKey,a&&"[object Function]"==={}.toString.call(a))return void this.key.generateAsync(this.default_key_size,this.default_public_exponent,a);this.key.generate(this.default_key_size,this.default_public_exponent)}return this.key},JSEncrypt.prototype.getPrivateKey=function(){return this.getKey().getPrivateKey()},JSEncrypt.prototype.getPrivateKeyB64=function(){return this.getKey().getPrivateBaseKeyB64()},JSEncrypt.prototype.getPublicKey=function(){return this.getKey().getPublicKey()},JSEncrypt.prototype.getPublicKeyB64=function(){return this.getKey().getPublicBaseKeyB64()};exports.JSEncrypt = JSEncrypt; -})(JSEncryptExports); -var JSEncrypt = JSEncryptExports.JSEncrypt; diff --git a/includes/external/school/node_modules/pronote-api/src/cas/generics/kdecole-educonnect.js b/includes/external/school/node_modules/pronote-api/src/cas/generics/kdecole-educonnect.js deleted file mode 100644 index 28db408..0000000 --- a/includes/external/school/node_modules/pronote-api/src/cas/generics/kdecole-educonnect.js +++ /dev/null @@ -1,30 +0,0 @@ -const jsdom = require('jsdom'); - -const { getDOM, submitForm, extractStart } = require('../api'); -const edu = require('./educonnect'); - -async function login({ url, account, username, password, casUrl, idp }) -{ - - const jar = new jsdom.CookieJar(); - - // Select EduConnect - let dom = await getDOM({ - url: `https://${casUrl}/login?&selection=${idp}&service=${url}&submit=Valider`, - jar, - followRedirects: true - }); - - - // Send SAML Request to EduConnect - dom = await submitForm({ - dom, - jar - }); - - await edu({ dom, jar, username, password }); - - return extractStart(await getDOM({ url: url + account.value + '.html', jar, asIs: true })); -} - -module.exports = login; diff --git a/includes/external/school/node_modules/pronote-api/src/cas/generics/kdecole-wayf.js b/includes/external/school/node_modules/pronote-api/src/cas/generics/kdecole-wayf.js deleted file mode 100644 index 7d20163..0000000 --- a/includes/external/school/node_modules/pronote-api/src/cas/generics/kdecole-wayf.js +++ /dev/null @@ -1,45 +0,0 @@ -const jsdom = require('jsdom'); - -const { getDOM, submitForm, extractStart } = require('../api'); -const aten = require('./aten'); - -async function login({ url, account, username, password, casUrl, idp, atenURL }) -{ - if (idp && !idp.includes('parent_eleve')) { - idp += '_parent_eleve'; - } - - casUrl = `https://${casUrl}/`; - - const jar = new jsdom.CookieJar(); - let dom = await getDOM({ - url: `${casUrl}login?${idp ? `selection=${idp}&` : ''}service=${encodeURIComponent(url)}`, - jar - }); - - if (atenURL) { - dom = await submitForm({ - dom, - jar, - runScripts: !!atenURL, - hook: atenURL && aten.hook, - actionRoot: casUrl - }); - - await aten.submit({ dom, jar, username, password, atenURL }); - } else { - dom.window.document.getElementById('username').value = username; - dom.window.document.getElementById('password').value = password; - - await submitForm({ - actionRoot: casUrl, - dom, - jar, - asIs: true - }); - } - - return extractStart(await getDOM({ url: url + account.value + '.html', jar, asIs: true })); -} - -module.exports = login; diff --git a/includes/external/school/node_modules/pronote-api/src/cas/generics/openent.js b/includes/external/school/node_modules/pronote-api/src/cas/generics/openent.js deleted file mode 100644 index 7e3fa29..0000000 --- a/includes/external/school/node_modules/pronote-api/src/cas/generics/openent.js +++ /dev/null @@ -1,31 +0,0 @@ -const jsdom = require('jsdom'); - -const http = require('../../http'); -const { getDOM, extractStart } = require('../api'); - -async function login({ url, account, username, password, target }) -{ - const location = await http({ url, followRedirects: 'get' }); - - let service = encodeURIComponent(url); - if (location.startsWith('http') && location.includes('service=')) { - service = location.substring(location.indexOf('=') + 1); - } - - const jar = new jsdom.CookieJar(); - - await getDOM({ - url: `https://${target}/auth/login`, - jar, - method: 'POST', - data: { - email: username, - password, - callback: `/cas/login?service=${service}` - } - }); - - return extractStart(await getDOM({ url: url + account.value + '.html', jar, asIs: true })); -} - -module.exports = login; diff --git a/includes/external/school/node_modules/pronote-api/src/cas/generics/wayf.js b/includes/external/school/node_modules/pronote-api/src/cas/generics/wayf.js deleted file mode 100644 index cca79c7..0000000 --- a/includes/external/school/node_modules/pronote-api/src/cas/generics/wayf.js +++ /dev/null @@ -1,34 +0,0 @@ -const jsdom = require('jsdom'); - -const { getParams, getDOM, extractStart } = require('../api'); -const aten = require('./aten'); - -async function login({ url, username, password, startURL, wayfURL, atenURL, extraParams }) -{ - const jar = new jsdom.CookieJar(); - - let dom = await getDOM({ - url: `${startURL}login?service=${encodeURIComponent(url)}`, - jar - }); - - dom = await getDOM({ - url: `${wayfURL}WAYF`, - jar, - data: { ...getParams(dom), ...extraParams }, - runScripts: true, - hook: aten.hook - }); - - dom = await aten.submit({ - dom, - jar, - username, - password, - atenURL - }); - - return extractStart(dom); -} - -module.exports = login; diff --git a/includes/external/school/node_modules/pronote-api/src/cas/haute-garonne.js b/includes/external/school/node_modules/pronote-api/src/cas/haute-garonne.js deleted file mode 100644 index 4db97dc..0000000 --- a/includes/external/school/node_modules/pronote-api/src/cas/haute-garonne.js +++ /dev/null @@ -1,11 +0,0 @@ -const wayf = require('./generics/kdecole-wayf'); - -module.exports = (url, account, username, password) => wayf({ - url, - account, - username, - password, - - casUrl: 'cas.ecollege.haute-garonne.fr', - idp: 'ATS_parent_eleve' -}); diff --git a/includes/external/school/node_modules/pronote-api/src/cas/hdf.js b/includes/external/school/node_modules/pronote-api/src/cas/hdf.js deleted file mode 100644 index 6b03118..0000000 --- a/includes/external/school/node_modules/pronote-api/src/cas/hdf.js +++ /dev/null @@ -1,10 +0,0 @@ -const openent = require('./generics/openent'); - -module.exports = (url, account, username, password) => openent({ - url, - account, - username, - password, - - target: 'enthdf.fr' -}); diff --git a/includes/external/school/node_modules/pronote-api/src/cas/iledefrance.js b/includes/external/school/node_modules/pronote-api/src/cas/iledefrance.js deleted file mode 100644 index e32dfa5..0000000 --- a/includes/external/school/node_modules/pronote-api/src/cas/iledefrance.js +++ /dev/null @@ -1,10 +0,0 @@ -const openent = require('./generics/openent'); - -module.exports = (url, account, username, password) => openent({ - url, - account, - username, - password, - - target: 'ent.iledefrance.fr' -}); diff --git a/includes/external/school/node_modules/pronote-api/src/cas/index.js b/includes/external/school/node_modules/pronote-api/src/cas/index.js deleted file mode 100644 index e893f3a..0000000 --- a/includes/external/school/node_modules/pronote-api/src/cas/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/* eslint-disable array-element-newline */ - -const find = require('./find'); - -const CAS = [ - 'ac-besancon', 'ac-bordeaux', 'ac-bordeaux2', 'ac-caen', 'ac-clermont', 'ac-dijon', - 'ac-grenoble', 'ac-lille', 'ac-limoges', 'ac-lyon', 'ac-montpellier', - 'ac-nancy-metz', 'ac-nantes', 'ac-orleans-tours', 'ac-poitiers', - 'ac-reims', 'ac-rouen', 'ac-strasbourg', 'ac-toulouse', - - 'agora06', 'arsene76', 'atrium-sud', - - 'haute-garonne', 'hdf', 'iledefrance', 'seine-et-marne', 'somme', 'eure-normandie', - 'parisclassenumerique', 'ljr-munich', - - 'toutatice', 'laclasse', 'lyceeconnecte', 'portail-famille', 'cybercolleges42', - 'ac-valdoise', 'ac-lille2', 'moncollege-essonne', 'monbureaunumerique-educonnect', - - 'none' -]; - -module.exports = { - getCAS: find, - list: CAS -}; - -for (const cas of CAS) { - // eslint-disable-next-line node/global-require - module.exports[cas] = require('./' + cas); -} - diff --git a/includes/external/school/node_modules/pronote-api/src/cas/laclasse.js b/includes/external/school/node_modules/pronote-api/src/cas/laclasse.js deleted file mode 100644 index ea1d5d3..0000000 --- a/includes/external/school/node_modules/pronote-api/src/cas/laclasse.js +++ /dev/null @@ -1,22 +0,0 @@ -const { getDOM, getParams, extractStart } = require('./api'); - -const LOGIN_URL = 'https://www.laclasse.com/sso/login'; - -async function login(url, account, username, password) -{ - const service = encodeURIComponent(url); - - return extractStart(await getDOM({ - url: LOGIN_URL, - method: 'POST', - data: { - service, - state: getParams(await getDOM({ url: `${LOGIN_URL}?service=${service}` })).state, - username, - password - }, - asIs: true - })); -} - -module.exports = login; diff --git a/includes/external/school/node_modules/pronote-api/src/cas/ljr-munich.js b/includes/external/school/node_modules/pronote-api/src/cas/ljr-munich.js deleted file mode 100644 index b500139..0000000 --- a/includes/external/school/node_modules/pronote-api/src/cas/ljr-munich.js +++ /dev/null @@ -1,11 +0,0 @@ -const wayf = require('./generics/kdecole-wayf'); - -module.exports = (url, account, username, password) => wayf({ - url, - account, - username, - password, - - casUrl: 'cas.kosmoseducation.com', - idp: 'MUNICH-SKO' -}); diff --git a/includes/external/school/node_modules/pronote-api/src/cas/lyceeconnecte.js b/includes/external/school/node_modules/pronote-api/src/cas/lyceeconnecte.js deleted file mode 100644 index 5cb3cce..0000000 --- a/includes/external/school/node_modules/pronote-api/src/cas/lyceeconnecte.js +++ /dev/null @@ -1,10 +0,0 @@ -const openent = require('./generics/openent'); - -module.exports = (url, account, username, password) => openent({ - url, - account, - username, - password, - - target: 'mon.lyceeconnecte.fr' -}); diff --git a/includes/external/school/node_modules/pronote-api/src/cas/monbureaunumerique-educonnect.js b/includes/external/school/node_modules/pronote-api/src/cas/monbureaunumerique-educonnect.js deleted file mode 100644 index 1b74ef0..0000000 --- a/includes/external/school/node_modules/pronote-api/src/cas/monbureaunumerique-educonnect.js +++ /dev/null @@ -1,11 +0,0 @@ -const educonnect = require('./generics/kdecole-educonnect'); - -module.exports = (url, account, username, password) => educonnect({ - url, - account, - username, - password, - - casUrl: 'cas.monbureaunumerique.fr', - idp: 'EDU' -}); diff --git a/includes/external/school/node_modules/pronote-api/src/cas/moncollege-essonne.js b/includes/external/school/node_modules/pronote-api/src/cas/moncollege-essonne.js deleted file mode 100644 index 800a8ce..0000000 --- a/includes/external/school/node_modules/pronote-api/src/cas/moncollege-essonne.js +++ /dev/null @@ -1,10 +0,0 @@ -const openent = require('./generics/openent'); - -module.exports = (url, account, username, password) => openent({ - url, - account, - username, - password, - - target: 'www.moncollege-ent.essonne.fr' -}); diff --git a/includes/external/school/node_modules/pronote-api/src/cas/none.js b/includes/external/school/node_modules/pronote-api/src/cas/none.js deleted file mode 100644 index 2fa72cf..0000000 --- a/includes/external/school/node_modules/pronote-api/src/cas/none.js +++ /dev/null @@ -1,9 +0,0 @@ -const http = require('../http'); -const { extractStart } = require('./api'); - -async function login(url, account) -{ - return extractStart(await http({ url: url + account.value + '.html?login=true' })); -} - -module.exports = login; diff --git a/includes/external/school/node_modules/pronote-api/src/cas/parisclassenumerique.js b/includes/external/school/node_modules/pronote-api/src/cas/parisclassenumerique.js deleted file mode 100644 index 4512a28..0000000 --- a/includes/external/school/node_modules/pronote-api/src/cas/parisclassenumerique.js +++ /dev/null @@ -1,10 +0,0 @@ -const openent = require('./generics/openent'); - -module.exports = (url, account, username, password) => openent({ - url, - account, - username, - password, - - target: 'ent.parisclassenumerique.fr' -}); diff --git a/includes/external/school/node_modules/pronote-api/src/cas/portail-famille.js b/includes/external/school/node_modules/pronote-api/src/cas/portail-famille.js deleted file mode 100644 index 49fed2a..0000000 --- a/includes/external/school/node_modules/pronote-api/src/cas/portail-famille.js +++ /dev/null @@ -1,11 +0,0 @@ -const aten = require('./generics/aten'); - -module.exports = (url, account, username, password) => aten.login({ - url, - account, - username, - password, - - startURL: 'https://seshat.ac-orleans-tours.fr:8443/identite/discovery?idp_ident=urn:fi:ac-orleans_EXT:ts:1.0', - atenURL: 'portail-famille.ac-orleans-tours.fr' -}); diff --git a/includes/external/school/node_modules/pronote-api/src/cas/seine-et-marne.js b/includes/external/school/node_modules/pronote-api/src/cas/seine-et-marne.js deleted file mode 100644 index 9111fd4..0000000 --- a/includes/external/school/node_modules/pronote-api/src/cas/seine-et-marne.js +++ /dev/null @@ -1,10 +0,0 @@ -const openent = require('./generics/openent'); - -module.exports = (url, account, username, password) => openent({ - url, - account, - username, - password, - - target: 'ent77.seine-et-marne.fr' -}); diff --git a/includes/external/school/node_modules/pronote-api/src/cas/somme.js b/includes/external/school/node_modules/pronote-api/src/cas/somme.js deleted file mode 100644 index 8aca523..0000000 --- a/includes/external/school/node_modules/pronote-api/src/cas/somme.js +++ /dev/null @@ -1,10 +0,0 @@ -const openent = require('./generics/openent'); - -module.exports = (url, account, username, password) => openent({ - url, - account, - username, - password, - - target: 'college.entsomme.fr' -}); diff --git a/includes/external/school/node_modules/pronote-api/src/cas/toutatice.js b/includes/external/school/node_modules/pronote-api/src/cas/toutatice.js deleted file mode 100644 index 84c10b0..0000000 --- a/includes/external/school/node_modules/pronote-api/src/cas/toutatice.js +++ /dev/null @@ -1,74 +0,0 @@ -const jsdom = require('jsdom'); -const axioRequest = require('../axioRequest') - -const { getDOM, submitForm, extractStart } = require('./api'); -const educonnect = require('./generics/educonnect'); -const querystring = require('querystring'); -const http = require('../http'); - -async function login(url, account, username, password) { - const jar = new jsdom.CookieJar(); - let dom = await getDOM({ - url: 'https://www.toutatice.fr/portail/auth/pagemarker/2/MonEspace', - jar - }); - - dom = await submitForm({ - dom, - jar, - actionRoot: 'https://www.toutatice.fr/wayf/', - extraParams: { - // eslint-disable-next-line camelcase - _saml_idp: 'educonnect' - } - }); - dom = await educonnect({ dom, jar, url, account, username, password }); - - let redirectURL = dom.window.document.getElementsByTagName('a')[0].href - - let response = await axioRequest({ - url: redirectURL, - jar - }) - - redirectURL = getOrigin(redirectURL) + response.headers.location - - const parsed = querystring.parse(redirectURL.split('?')[1]) - const conversation = parsed.conversation - const sessionid = parsed.sessionid - - // eslint-disable-next-line max-len - redirectURL = `${getOrigin(redirectURL)}/idp/Authn/RemoteUser?conversation=${conversation}&redirectToLoaderRemoteUser=0&sessionid=${sessionid}` - - response = await axioRequest({ - url: redirectURL, - jar - }) - // eslint-disable-next-line max-len - const remoteUserParsed = response.data.match(/<conversation>(.+)<\/conversation><uidInSession>(.+)<\/uidInSession>/u) - - const remoteUserConversation = remoteUserParsed[1] - const uidInSession = remoteUserParsed[2] - - // eslint-disable-next-line max-len - redirectURL = `${getOrigin(redirectURL)}/idp/Authn/RemoteUser?conversation=${remoteUserConversation}&uidInSession=${uidInSession}&sessionid=${sessionid}` - - response = await http({ - url: redirectURL, - jar, - followRedirects: true - }) - - return extractStart(await getDOM({ - url: `${url}${account.value}.html`, - jar, - asIs: true - })) -} - -function getOrigin(url) { - const noProtocol = url.substring(url.indexOf('/') + 2); - return url.substring(0, url.indexOf('/')) + '//' + noProtocol.substring(0, noProtocol.indexOf('/')); -} - -module.exports = login; diff --git a/includes/external/school/node_modules/pronote-api/src/cipher.js b/includes/external/school/node_modules/pronote-api/src/cipher.js deleted file mode 100644 index 350de5b..0000000 --- a/includes/external/school/node_modules/pronote-api/src/cipher.js +++ /dev/null @@ -1,118 +0,0 @@ -const forge = require('node-forge'); -const pako = require('pako'); - -function initCipher(session, keyModulus, keyExponent) -{ - session.aesIV = generateIV(); - - session.publicKey = forge.pki.rsa.setPublicKey( - new forge.jsbn.BigInteger(keyModulus, 16), - new forge.jsbn.BigInteger(keyExponent, 16) - ); -} - -function cipher(session, data, { key, compress, disableIV } = {}) -{ - data = forge.util.encodeUtf8('' + data); - if (compress && !session.disableCompress) { - data = deflate(data); - } - - const cipher = createCipher(session, key, false, disableIV); - cipher.update(new forge.util.ByteBuffer(data)); - - return cipher.finish() && cipher.output.toHex(); -} - -function decipher(session, data, { compress, scrambled, key, asBytes } = {}) -{ - const cipher = createCipher(session, key, true); - cipher.update(new forge.util.ByteBuffer(forge.util.hexToBytes(data))); - - let result = cipher.finish() && cipher.output.bytes(); - if (compress && !session.disableCompress) { - result = inflate(result); - } - - result = forge.util.decodeUtf8(result); - - if (scrambled) { - const unscrambled = new Array(result.length); - for (let i = 0; i < result.length; i += 1) { - if (i % 2 === 0) { - unscrambled.push(result.charAt(i)); - } - } - - return unscrambled.join(''); - } - - if (asBytes) { - const buffer = new forge.util.ByteBuffer(); - const split = result.split(','); - - for (let i = 0; i < split.length; i++) { - buffer.putInt(parseInt(split[i])); - } - - return buffer; - } - - return result; -} - -function createCipher(session, key, decipher, disableIV = false) -{ - if (!key) { - key = session.aesKey || new forge.util.ByteBuffer(); - } - - const cipher = forge.cipher[decipher ? 'createDecipher' : 'createCipher']('AES-CBC', md5(key)); - const iv = disableIV ? new forge.util.ByteBuffer() : md5(session.aesIV); - - cipher.start({ iv }); - - return cipher; -} - -function md5(buffer) -{ - return forge.md.md5.create().update(buffer.bytes()).digest(); -} - -function deflate(data) -{ - return pako.deflateRaw(new forge.util.ByteBuffer(data).toHex(), { level: 6, to: 'string' }); -} - -function inflate(data) -{ - return pako.inflateRaw(data, { to: 'string' }); -} - -function generateIV() -{ - return new forge.util.ByteBuffer(forge.random.generate(16)); -} - -function getUUID(session, iv) -{ - return forge.util.encode64(session.publicKey.encrypt(iv.bytes()), 64); -} - -function getLoginKey(username, password, scramble, fromCas) -{ - const hash = forge.md.sha256.create().update(scramble || '').update(forge.util.encodeUtf8(password)).digest(); - const key = (fromCas ? '' : username.toLowerCase()) + hash.toHex().toUpperCase(); - - return new forge.util.ByteBuffer(forge.util.encodeUtf8(key)); -} - -module.exports = { - initCipher, - - cipher, - decipher, - getUUID, - getLoginKey -}; diff --git a/includes/external/school/node_modules/pronote-api/src/data/dates.js b/includes/external/school/node_modules/pronote-api/src/data/dates.js deleted file mode 100644 index 52377ba..0000000 --- a/includes/external/school/node_modules/pronote-api/src/data/dates.js +++ /dev/null @@ -1,82 +0,0 @@ -function toPronoteWeek(session, date) -{ - const firstWeek = toUTCWeek(session.params.firstDay); - const week = toUTCWeek(date); - - if (week >= firstWeek) { - return week - firstWeek + 1; - } - - return 52 - (firstWeek - week) + 1; // Trust me this works -} - -function toUTCWeek(date) -{ - const firstDay = new Date((new Date()).getFullYear(), 0, 1); - return Math.ceil((((date - firstDay) / 86400000) + firstDay.getDay() + 1) / 7); -} - -function toPronoteDay(session, date) -{ - return Math.ceil((date - session.params.firstDay) / 86400000); -} - -function fromPronoteDay(session, day) -{ - const date = new Date(session.params.firstDay.getTime()); - date.setDate(date.getDate() + day - 1); - - return date; -} - -function toPronoteDate(date) -{ - return `${date.getDate()}/${date.getMonth() + 1}/${date.getFullYear()} ` + - `${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}`; -} - -function fromPronoteHours(hours) -{ - return ~~hours[0] + ~~hours.substring(2) / 60; -} - -function parseDate(string) -{ - const date = new Date(); - const split = string.split(' '); - - const day = split[0].split('/'); - - date.setFullYear(~~day[2], (~~day[1]) - 1, ~~day[0]); - date.setMilliseconds(0); - - if (split.length > 1) - { - const time = split[1].split(':'); - - date.setHours(~~time[0]); - date.setMinutes(~~time[1]); - date.setSeconds(~~time[2]); - } - else - { - date.setHours(0); - date.setMinutes(0); - date.setSeconds(0); - } - - return date; -} - -module.exports = { - toPronoteWeek, - toUTCWeek, - - toPronoteDay, - fromPronoteDay, - - toPronoteDate, - parseDate, - - fromPronoteHours -}; diff --git a/includes/external/school/node_modules/pronote-api/src/data/files.js b/includes/external/school/node_modules/pronote-api/src/data/files.js deleted file mode 100644 index aea0e8e..0000000 --- a/includes/external/school/node_modules/pronote-api/src/data/files.js +++ /dev/null @@ -1,14 +0,0 @@ -const { toPronote } = require('./objects'); -const { cipher } = require('../cipher'); - -const EXTERNAL_FILES_FOLDER = 'FichiersExternes/'; - -function getFileURL(session, { id, name, type }) -{ - const fileID = cipher(session, JSON.stringify(toPronote({ id, type }))); - const fileName = encodeURIComponent(encodeURIComponent(name)); // *Clown emoji* - - return session.server + EXTERNAL_FILES_FOLDER + fileID + '/' + fileName + '?Session=' + session.id; -} - -module.exports = { getFileURL }; diff --git a/includes/external/school/node_modules/pronote-api/src/data/html.js b/includes/external/school/node_modules/pronote-api/src/data/html.js deleted file mode 100644 index 33a4f0d..0000000 --- a/includes/external/school/node_modules/pronote-api/src/data/html.js +++ /dev/null @@ -1,16 +0,0 @@ -const { stripHtml } = require('string-strip-html'); - -function fromHTML(text) -{ - if (!text) { - if (text === undefined) { - return null; - } - - return text; - } - - return stripHtml(text).result; -} - -module.exports = fromHTML; diff --git a/includes/external/school/node_modules/pronote-api/src/data/id.js b/includes/external/school/node_modules/pronote-api/src/data/id.js deleted file mode 100644 index 2c3c2d3..0000000 --- a/includes/external/school/node_modules/pronote-api/src/data/id.js +++ /dev/null @@ -1,33 +0,0 @@ -const { h64 } = require('xxhashjs'); - -function withId(obj, fields, extraData) -{ - const result = {}; - for (const field of fields) { - result[field] = obj[field]; - } - - if (extraData) { - result.__extraData = extraData; - } - - return { - id: h64(JSON.stringify(result), 0).toString(16), - ...obj - }; -} - -function checkDuplicates(objs) -{ - for (const obj of objs) { - const duplicates = objs.filter(o => o.id === obj.id); - - if (duplicates.length > 1) { - duplicates.forEach((d, i) => d.id = d.id.substring(0, d.id.length - 1) + i); - } - } - - return objs; -} - -module.exports = { withId, checkDuplicates }; diff --git a/includes/external/school/node_modules/pronote-api/src/data/objects.js b/includes/external/school/node_modules/pronote-api/src/data/objects.js deleted file mode 100644 index 5cc985e..0000000 --- a/includes/external/school/node_modules/pronote-api/src/data/objects.js +++ /dev/null @@ -1,44 +0,0 @@ -function fromPronote({ N, L, G, ...obj } = {}, fn = null, gName = 'type') { - const result = {}; - - if (typeof fn === 'string') { - gName = fn; - fn = null; - } - - if (N) { - result.id = N; - } - if (L) { - result.name = L; - } - if (G !== undefined && gName) { - result[gName] = G; - } - - return { - ...result, - ...(fn ? fn(G && gName ? obj : { G, ...obj }) : {}) - }; -} - -function toPronote({ id, name, type } = {}) { - const result = {}; - - if (id) { - result.N = id; - } - if (name) { - result.L = name; - } - if (type) { - result.G = type; - } - - return result; -} - -module.exports = { - fromPronote, - toPronote -}; diff --git a/includes/external/school/node_modules/pronote-api/src/data/periods.js b/includes/external/school/node_modules/pronote-api/src/data/periods.js deleted file mode 100644 index a13039d..0000000 --- a/includes/external/school/node_modules/pronote-api/src/data/periods.js +++ /dev/null @@ -1,24 +0,0 @@ -function getPeriodBy(session, period, type = null) -{ - const Type = ['trimester', 'semester', 'year']; - const periods = session.params.periods; - if (!type || Type.indexOf(type) === -1) { - type = 'trimester' - } - if (!period) { - const now = Date.now(); - return periods.find(p => now >= p.from && now <= p.to && p.kind === type) || periods[5]; - } else if (typeof period === 'string') { - for (const p of periods) { - if (p.name === period) { - return p; - } - } - } - - return period; -} - -module.exports = { - getPeriodBy -}; diff --git a/includes/external/school/node_modules/pronote-api/src/data/types.js b/includes/external/school/node_modules/pronote-api/src/data/types.js deleted file mode 100644 index a77e35f..0000000 --- a/includes/external/school/node_modules/pronote-api/src/data/types.js +++ /dev/null @@ -1,87 +0,0 @@ -const { fromPronote } = require('./objects'); - -function parseDate(str) -{ - const date = new Date(); - const split = str.split(' '); - - const day = split[0].split('/'); - - date.setFullYear(~~day[2], (~~day[1]) - 1, ~~day[0]); - date.setMilliseconds(0); - - if (split.length > 1) { - const time = split[1].split(':'); - - date.setHours(~~time[0]); - date.setMinutes(~~time[1]); - date.setSeconds(~~time[2]); - } else { - date.setHours(0); - date.setMinutes(0); - date.setSeconds(0); - } - - return date; -} - -function parseRange(str) -{ - const content = str.substring(1, str.length - 1).split(','); - const result = []; - - for (const val of content) { - if (val.includes('..')) { - const index = val.indexOf('..'); - for (let i = ~~val.substring(0, index); i <= ~~val.substring(index + 2); i++) { - result.push(i); - } - } else { - result.push(~~val); - } - } - - return result; -} - -function parse({ _T: type, V: value } = {}, f = null, g = 'type') -{ - if (!value) { - if (value === undefined) { - return null; - } - - return value; - } - - switch (type) { - case 7: // Date - return parseDate(value); - case 8: // ? (Range) - case 11: // ? (Range) - case 26: // ? (Range) - return parseRange(value); - case 10: // Mark / Number - value = value.replace('|', '-'); - - if (value.indexOf(',') !== -1) { - return parseFloat(value.replace(',', '.')); - } - - return ~~value; - case 21: // HTML content - case 23: // URL - case 24: // Object (includes Array) - case 25: // Resource - default: - if (f !== false && value.map) { - return value.map(o => fromPronote(o, f, g)); - } else if (f !== false && (value.N || value.L)) { - return fromPronote(value, f, g); - } - - return value; - } -} - -module.exports = parse; diff --git a/includes/external/school/node_modules/pronote-api/src/errors.js b/includes/external/school/node_modules/pronote-api/src/errors.js deleted file mode 100644 index 5bb6e17..0000000 --- a/includes/external/school/node_modules/pronote-api/src/errors.js +++ /dev/null @@ -1,30 +0,0 @@ -const PRONOTE = error(-1, ({ title, message }) => title + (title && message ? ' - ' : '') + message); -const UNKNOWN_CAS = error(1, cas => `Unknown CAS '${cas}' (use 'none' for no CAS)`); -const BANNED = error(2, 'Your IP address is temporarily banned because of too many failed authentication attempts'); -const WRONG_CREDENTIALS = error(3, 'Wrong user credentials'); -const UNKNOWN_ACCOUNT = error(4, typeAccount => `Unknown account type '${typeAccount}'`); -const SESSION_EXPIRED = error(5, 'Session has expired due to inactivity or error'); -const RATE_LIMITED = error(6, 'You are being rate limited because of too many failed requests'); -const CLOSED = error(7, 'The instance is closed, try again later'); - -function error(code, message) -{ - return { - code, - drop: (...args) => ({ - code, - message: typeof message === 'string' ? message : message(...args) - }) - } -} - -module.exports = { - PRONOTE, - UNKNOWN_CAS, - BANNED, - WRONG_CREDENTIALS, - UNKNOWN_ACCOUNT, - SESSION_EXPIRED, - RATE_LIMITED, - CLOSED -}; diff --git a/includes/external/school/node_modules/pronote-api/src/fetch/absences.js b/includes/external/school/node_modules/pronote-api/src/fetch/absences.js deleted file mode 100644 index 9c1ac02..0000000 --- a/includes/external/school/node_modules/pronote-api/src/fetch/absences.js +++ /dev/null @@ -1,114 +0,0 @@ -const { getPeriodBy } = require('../data/periods'); -const { withId, checkDuplicates } = require('../data/id'); - -const getAbsences = require('./pronote/absences'); - -// eslint-disable-next-line complexity -async function absences(session, user, period = null, from = null, to = null, type = null) -{ - const result = { - absences: [], - delays: [], - punishments: [], - other: [], - totals: [] - }; - - const p = getPeriodBy(session, !period && !type && from && to ? 'Trimestre 1' : period, type); - const absences = await getAbsences(session, user, p, from || p.from, to || p.to); - if (!absences) { - return null; - } - - for (const event of absences.events) { - // eslint-disable-next-line default-case - switch (event.type) { - case 'absence': - result.absences.push(withId({ - from: event.from, - to: event.to, - justified: event.justified, - solved: event.solved, - hours: event.hours, - reason: event.reasons.length && event.reasons[0].name || '' - }, ['from', 'to'])); - break; - case 'delay': - result.delays.push(withId({ - date: event.date, - justified: event.justified, - solved: event.solved, - justification: event.justification, - minutesMissed: event.duration, - reason: event.reasons.length && event.reasons[0].name || '' - }, ['data', 'minutesMissed'])); - break; - case 'punishment': - // eslint-disable-next-line no-case-declarations - let detention = null; - if (event.nature.type === 1) { - const schedule = event.schedule[0]; - const hour = session.params.firstHour.getHours() + schedule.position / session.params.ticksPerHour; - - const from = new Date(schedule.date.getTime()); - const to = new Date(schedule.date.getTime()); - - from.setHours(from.getHours() + hour); - to.setHours(to.getHours() + hour); - to.setMinutes(to.getMinutes() + schedule.duration); - - detention = { from, to }; - } - - result.punishments.push(withId({ - date: event.date, - isExclusion: event.isExclusion, - isDuringLesson: !event.isNotDuringLesson, - homework: event.homework, - circumstances: event.circumstances, - giver: event.giver.name, - reason: event.reasons.length && event.reasons[0].name || '', - detention - }, ['data'])); - break; - case 'other': - result.other.push(withId({ - kind: event.name, - date: event.date, - giver: event.giver.name, - comment: event.comment, - subject: event.subject && event.subject.name || null - }, ['kind', 'date'])); - break; - } - } - - Object.values(result).forEach(checkDuplicates); - - if (absences.subjects) { - for (const subject of absences.subjects) { - if (subject.inGroup) { - continue; - } - - const res = parseSubject(subject); - if (subject.group) { - res.subs = absences.subjects.filter(s => s.inGroup === subject.group).map(s => parseSubject(s)); - } - - result.totals.push(res); - } - } - - return result; -} - -function parseSubject(subject) { - return { - subject: subject.name, - hoursAssisted: subject.hoursAssisted, - hoursMissed: subject.hoursMissed - }; -} - -module.exports = absences; diff --git a/includes/external/school/node_modules/pronote-api/src/fetch/contents.js b/includes/external/school/node_modules/pronote-api/src/fetch/contents.js deleted file mode 100644 index 62e85df..0000000 --- a/includes/external/school/node_modules/pronote-api/src/fetch/contents.js +++ /dev/null @@ -1,51 +0,0 @@ -const { toPronoteWeek } = require('../data/dates'); -const { getFileURL } = require('../data/files'); -const fromHTML = require('../data/html'); -const { withId, checkDuplicates } = require('../data/id'); - -const getContents = require('./pronote/contents'); - -async function contents(session, user, from = new Date(), to = null) -{ - if (!to || to < from) { - to = new Date(from.getTime()); - to.setDate(to.getDate() + 1); - } - - const fromWeek = toPronoteWeek(session, from); - const toWeek = toPronoteWeek(session, to); - - const contents = await getContents(session, user, fromWeek, toWeek); - if (!contents) { - return null; - } - - const result = []; - - for (const lesson of contents.lessons) { - if (lesson.from < from || lesson.to > to) { - continue; - } - - const content = lesson.content[0]; // Maybe on some instances there will be multiple entries ? Check this - if (typeof content === 'undefined') { - continue; - } - result.push(withId({ - subject: lesson.subject.name, - teachers: lesson.teachers.map(t => t.name), - from: lesson.from, - to: lesson.to, - color: lesson.color, - title: content.name, - description: fromHTML(content.description), - htmlDescription: content.htmlDescription, - files: content.files.map(f => withId({ name: f.name, url: getFileURL(session, f) }, ['name'])), - category: content.category.name - }, ['subject', 'from', 'to'])); - } - - return checkDuplicates(result).sort((a, b) => a.from - b.from); -} - -module.exports = contents; diff --git a/includes/external/school/node_modules/pronote-api/src/fetch/evaluations.js b/includes/external/school/node_modules/pronote-api/src/fetch/evaluations.js deleted file mode 100644 index dca1b9f..0000000 --- a/includes/external/school/node_modules/pronote-api/src/fetch/evaluations.js +++ /dev/null @@ -1,65 +0,0 @@ -const { getPeriodBy } = require('../data/periods'); -const { withId, checkDuplicates } = require('../data/id'); - -const getEvaluations = require('./pronote/evaluations'); - -async function evaluations(session, user, period = null, type = null) -{ - const evaluations = await getEvaluations(session, user, getPeriodBy(session, period, type)); - if (!evaluations) { - return null; - } - - const result = []; - - if (!evaluations) { - return null; - } - - for (const evaluation of evaluations) { - let subject = result.find(s => s.name === evaluation.subject.name); - if (!subject) { - const { position, name, color } = evaluation.subject; - subject = { - position, - name, - teacher: evaluation.teacher.name, - color, - evaluations: [] - }; - - result.push(subject); - } - - subject.evaluations.push(withId({ - name: evaluation.name, - date: evaluation.date, - coefficient: evaluation.coefficient, - levels: evaluation.acquisitionLevels.map(({ name, position, value, item, domain, pillar }) => ({ - name: item && item.name || domain.name, - position, - value: { - short: value, - long: name - }, - prefixes: !pillar.prefixes[0] ? [] : pillar.prefixes - })) - }, ['name', 'date'], subject.name)); - } - - result.forEach(s => checkDuplicates(s.evaluations)); - - result.sort((a, b) => a.position - b.position); - result.forEach(s => { - s.evaluations.forEach(e => { - e.levels.sort((a, b) => a.position - b.position); - e.levels.forEach(l => delete l.position); - }); - - return delete s.position; - }); - - return result; -} - -module.exports = evaluations; diff --git a/includes/external/school/node_modules/pronote-api/src/fetch/files.js b/includes/external/school/node_modules/pronote-api/src/fetch/files.js deleted file mode 100644 index 7703ee4..0000000 --- a/includes/external/school/node_modules/pronote-api/src/fetch/files.js +++ /dev/null @@ -1,32 +0,0 @@ -const { parseDate } = require('../data/dates'); -const { getFileURL } = require('../data/files'); -const { withId, checkDuplicates } = require('../data/id'); - -const getFiles = require('./pronote/files'); - -async function files(session, user) { - const files = await getFiles(session, user); - if (!files) { - return null; - } - - const result = []; - - const subjects = {}; - for (const subject of files.listeMatieres.V) { - subjects[subject.N] = subject.L; - } - - for (const file of files.listeRessources.V) { - result.push(withId({ - time: parseDate(file.date.V), - subject: subjects[file.matiere.V.N], - name: file.ressource.V.L, - url: getFileURL(session, { id: file.ressource.V.N, name: file.ressource.V.L, type: file.ressource.V.G }) - }, 'subject', 'name')); - } - - return checkDuplicates(result); -} - -module.exports = files; diff --git a/includes/external/school/node_modules/pronote-api/src/fetch/homeworks.js b/includes/external/school/node_modules/pronote-api/src/fetch/homeworks.js deleted file mode 100644 index 7f2146b..0000000 --- a/includes/external/school/node_modules/pronote-api/src/fetch/homeworks.js +++ /dev/null @@ -1,45 +0,0 @@ -const { toPronoteWeek } = require('../data/dates'); -const { getFileURL } = require('../data/files'); -const fromHTML = require('../data/html'); -const { withId, checkDuplicates } = require('../data/id'); - -const getHomeworks = require('./pronote/homeworks'); - -async function homeworks(session, user, from = new Date(), to = null) -{ - if (!to || to < from) { - to = new Date(from.getTime()); - to.setDate(to.getDate() + 1); - } - - const fromWeek = toPronoteWeek(session, from); - const toWeek = toPronoteWeek(session, to); - - const homeworks = await getHomeworks(session, user, fromWeek, toWeek); - if (!homeworks) { - return null; - } - - const result = []; - - for (const homework of homeworks) { - if (homework.for < from || homework.for > to) { - continue; - } - - result.push(withId({ - description: fromHTML(homework.description), - htmlDescription: homework.description, - subject: homework.subject.name, - givenAt: homework.givenAt, - for: homework.for, - done: homework.done, - color: homework.color, - files: homework.files.map(f => withId({ name: f.name, url: getFileURL(session, f) }, ['name'])) - }, 'subject', 'givenAt')); - } - - return checkDuplicates(result).sort((a, b) => a.for - b.for); -} - -module.exports = homeworks; diff --git a/includes/external/school/node_modules/pronote-api/src/fetch/infos.js b/includes/external/school/node_modules/pronote-api/src/fetch/infos.js deleted file mode 100644 index 0ec03a7..0000000 --- a/includes/external/school/node_modules/pronote-api/src/fetch/infos.js +++ /dev/null @@ -1,33 +0,0 @@ -const { getFileURL } = require('../data/files'); -const fromHTML = require('../data/html'); -const { withId, checkDuplicates } = require('../data/id'); - -const getInfos = require('./pronote/infos'); - -async function infos(session, user) -{ - const infos = await getInfos(session, user); - if (!infos) { - return null; - } - - const result = []; - - for (const info of infos.infos) - { - result.push(withId({ - date: info.date, - title: info.name, - author: info.author.name, - content: fromHTML(info.content[0].text), - htmlContent: info.content[0].text, - files: info.content[0].files.map(f => withId({ name: f.name, url: getFileURL(session, f) }, ['name'])) - }, ['date', 'title'])); - } - - checkDuplicates(result).sort((a, b) => a.date - b.date); - - return result; -} - -module.exports = infos; diff --git a/includes/external/school/node_modules/pronote-api/src/fetch/marks.js b/includes/external/school/node_modules/pronote-api/src/fetch/marks.js deleted file mode 100644 index 1e57e85..0000000 --- a/includes/external/school/node_modules/pronote-api/src/fetch/marks.js +++ /dev/null @@ -1,73 +0,0 @@ -const { getPeriodBy } = require('../data/periods'); -const { withId, checkDuplicates } = require('../data/id'); - -const getMarks = require('./pronote/marks'); - -async function marks(session, user, period = null, type = null) -{ - const marks = await getMarks(session, user, getPeriodBy(session, period, type)); - if (!marks) { - return null; - } - - const result = { - subjects: [], - averages: {} - }; - - if (marks.studentAverage) { - result.averages.student = Number((marks.studentAverage / marks.studentAverageScale * 20).toFixed(2)); - } - if (marks.studentClassAverage) { - result.averages.studentClass = Number(marks.studentClassAverage.toFixed(2)); - } - - for (const subject of marks.subjects.sort((a, b) => a.order - b.order)) { - result.subjects.push({ - name: subject.name, - averages: { - student: subject.studentAverage / subject.studentAverageScale * 20, - studentClass: subject.studentClassAverage, - max: subject.maxAverage, - min: subject.minAverage - }, - color: subject.color, - marks: [] - }); - } - - for (const mark of marks.marks) { - const subject = result.subjects.find(s => s.name === mark.subject.name); - if (!subject) { - continue; - } - - const res = { - isAway: mark.value < 0 - }; - - if (!res.isAway) { - res.value = mark.value; - } - - if (mark.average >= 0) { - res.min = mark.min; - res.max = mark.max; - res.average = mark.average; - } - - subject.marks.push(withId({ - title: mark.title, - ...res, - scale: mark.scale, - coefficient: mark.coefficient, - date: mark.date - }, ['title', 'date'], subject.name)); - } - - result.subjects.forEach(s => checkDuplicates(s.marks)); - - return result; -} - -module.exports = marks; diff --git a/includes/external/school/node_modules/pronote-api/src/fetch/menu.js b/includes/external/school/node_modules/pronote-api/src/fetch/menu.js deleted file mode 100644 index 6f2872c..0000000 --- a/includes/external/school/node_modules/pronote-api/src/fetch/menu.js +++ /dev/null @@ -1,41 +0,0 @@ -const getMenu = require('./pronote/menu'); - -async function menu(session, user, from = new Date(), to = null) -{ - if (!to || to < from) { - to = new Date(from.getTime()); - to.setDate(to.getDate() + 1); - to.setHours(to.getHours() - 1); - } - - const result = []; - const date = new Date(from.getTime()); - - // eslint-disable-next-line no-unmodified-loop-condition - while (date < to) { - const menus = await getMenu(session, user, date); - if (!menus) { - return null; - } - - for (const menu of menus.menus) { - if (menu.date < from || menu.date > to) { - continue; - } - - result.push({ - date: menu.date, - meals: menu.meals.map(m => m.content.map(c => c.lines.map(({ name, labels }) => ({ - name, - labels: labels.map(({ name, color }) => ({ name, color })) - })))) - }); - } - - date.setDate(date.getDate() + 7); - } - - return result; -} - -module.exports = menu; diff --git a/includes/external/school/node_modules/pronote-api/src/fetch/pronote/absences.js b/includes/external/school/node_modules/pronote-api/src/fetch/pronote/absences.js deleted file mode 100644 index 19bf2dc..0000000 --- a/includes/external/school/node_modules/pronote-api/src/fetch/pronote/absences.js +++ /dev/null @@ -1,164 +0,0 @@ -const parse = require('../../data/types'); -const { toPronote } = require('../../data/objects'); -const { toPronoteDate } = require('../../data/dates'); -const { fromPronoteHours } = require('../../data/dates'); - -const navigate = require('./navigate'); - -const PAGE_NAME = 'PagePresence'; -const TAB_ID = 19; -const ACCOUNTS = ['student', 'parent']; - -async function getAbsences(session, user, period, from, to) -{ - const absences = await navigate(session, user, PAGE_NAME, TAB_ID, ACCOUNTS, { - DateDebut: { - _T: 7, - V: toPronoteDate(from) - }, - DateFin: { - _T: 7, - V: toPronoteDate(to) - }, - periode: period.name ? toPronote(period) : period - }); - - if (!absences) { - return null; - } - - return { - authorizations: (a => ({ - absences: a.absence, - fillAbsenceReason: a.saisieMotifAbsence, - delays: a.retard, - fillDelayReason: a.saisieMotifRetard, - punishments: a.punition, - exclusions: a.exclusion, - sanctions: a.sanction, - conservatoryMesures: a.mesureConservatoire, - infirmary: a.infirmerie, - mealAbsences: a.absenceRepas, - internshipAbsences: a.absenceInternat, - observations: a.observation, - incidents: a.incident, - totalHoursMissed: a.totalHeuresManquees - }))(absences.autorisations), - events: parse(absences.listeAbsences, a => parseEvent(a), false), - subjects: parse(absences.Matieres, ({ - P, regroupement, dansRegroupement, suivi, absence, excluCours, excluEtab - }) => ({ - position: P, - group: regroupement, - inGroup: dansRegroupement, - hoursAssisted: suivi / 3600, - hoursMissed: absence / 3600, - lessonExclusions: excluCours, - establishmentExclusions: excluEtab - })), - recaps: parse(absences.listeRecapitulatifs, ({ NombreTotal, NbrHeures, NombreNonJustifie }) => ({ - count: NombreTotal, - unjustifiedCount: NombreNonJustifie, - hours: fromPronoteHours(NbrHeures) - })), - sanctions: parse(absences.listeSanctionUtilisateur) // TODO: Check values - }; -} - -function parseEvent(a) -{ - switch (a.page.Absence) { - case 13: - return { - type: 'absence', - ...parseAbsence(a) - }; - case 14: - return { - type: 'delay', - ...parseDelay(a) - }; - case 41: - return { - type: 'punishment', - ...parsePunishment(a) - }; - case 45: - return { - type: 'other', - ...parseOther(a) - }; - default: - return { - type: 'unknown', - ...a - }; - } -} - -function parseAbsence(a) -{ - return { - from: parse(a.dateDebut), - to: parse(a.dateFin), - opened: a.ouverte, - solved: a.reglee, - justified: a.justifie, - hours: fromPronoteHours(a.NbrHeures), - days: a.NbrJours, - reasons: parse(a.listeMotifs) - } -} - -function parseDelay(a) -{ - return { - date: parse(a.date), - solved: a.reglee, - justified: a.justifie, - justification: a.justification, - duration: a.duree, - reasons: parse(a.listeMotifs) - }; -} - -function parsePunishment(a) -{ - return { - date: parse(a.dateDemande), - isExclusion: a.estUneExclusion, - isNotDuringLesson: a.horsCours, - homework: a.travailAFaire, - isBoundToIncident: a.estLieAUnIncident, - circumstances: a.circonstances, - duration: a.duree, - giver: parse(a.demandeur), - isSchedulable: a.estProgrammable, - reasons: parse(a.listeMotifs), - schedule: parse(a.programmation, ({ date, placeExecution, duree }) => ({ - date: parse(date), - position: placeExecution, - duration: duree - })), - nature: a.nature && parse(a.nature, ({ estProgrammable, estAvecARParent }) => ({ - isSchedulable: estProgrammable, - requiresParentsMeeting: estAvecARParent - })) - } -} - -function parseOther(a) -{ - return { - date: parse(a.date), - giver: parse(a.demandeur, ({ estProfPrincipal, mail }) => ({ - isHeadTeacher: estProfPrincipal, - mail - })), - comment: a.commentaire, - read: a.estLue, - subject: parse(a.matiere) - }; -} - -module.exports = getAbsences; diff --git a/includes/external/school/node_modules/pronote-api/src/fetch/pronote/auth.js b/includes/external/school/node_modules/pronote-api/src/fetch/pronote/auth.js deleted file mode 100644 index 9c1d566..0000000 --- a/includes/external/school/node_modules/pronote-api/src/fetch/pronote/auth.js +++ /dev/null @@ -1,43 +0,0 @@ -const request = require('../../request'); -const { cipher } = require('../../cipher'); - -async function getId(session, username, fromCas) -{ - const { donnees: id } = await request(session, 'Identification', { - donnees: { - genreConnexion: 0, - genreEspace: session.type.id, - identifiant: username, - pourENT: fromCas, - enConnexionAuto: false, - demandeConnexionAuto: false, - demandeConnexionAppliMobile: false, - demandeConnexionAppliMobileJeton: false, - uuidAppliMobile: '', - loginTokenSAV: '' - } - }); - - return { - scramble: id.alea, - challenge: id.challenge - }; -} - -async function getAuthKey(session, challenge, key) -{ - const { donnees: auth } = await request(session, 'Authentification', { - donnees: { - connexion: 0, - challenge: cipher(session, challenge, { key }), - espace: session.type.id - } - }); - - return auth.cle; -} - -module.exports = { - getId, - getAuthKey -}; diff --git a/includes/external/school/node_modules/pronote-api/src/fetch/pronote/contents.js b/includes/external/school/node_modules/pronote-api/src/fetch/pronote/contents.js deleted file mode 100644 index 7525e3d..0000000 --- a/includes/external/school/node_modules/pronote-api/src/fetch/pronote/contents.js +++ /dev/null @@ -1,60 +0,0 @@ -const parse = require('../../data/types'); -const { fromPronote } = require('../../data/objects'); - -const navigate = require('./navigate'); - -const PAGE_NAME = 'PageCahierDeTexte'; -const TAB_ID = 89; -const ACCOUNTS = ['student', 'parent']; - -async function getContents(session, user, fromWeek = 1, toWeek = null) -{ - if (!toWeek || toWeek < fromWeek) { - toWeek = fromWeek; - } - - const contents = await navigate(session, user, PAGE_NAME, TAB_ID, ACCOUNTS, { - domaine: { - _T: 8, - V: `[${fromWeek}..${toWeek}]` - } - }); - - if (!contents) { - return null; - } - - return { - lessons: parse(contents.ListeCahierDeTextes, ({ - cours, verrouille, listeGroupes, Matiere, CouleurFond, listeProfesseurs, Date, DateFin, - listeContenus, listeElementsProgrammeCDT - }) => ({ - lesson: parse(cours), - locked: verrouille, - groups: parse(listeGroupes), // TODO: Check values - subject: parse(Matiere), - color: CouleurFond, - teachers: parse(listeProfesseurs), - from: parse(Date), - to: parse(DateFin), - content: parse(listeContenus, ({ - descriptif, categorie, parcoursEducatif, ListePieceJointe, training - }) => ({ - description: parse(descriptif), - category: parse(categorie), - path: parcoursEducatif, - files: parse(ListePieceJointe), - training: parse(training).ListeExecutionsQCM.map(o => fromPronote(o)) // TODO: Check values - })), - skills: parse(listeElementsProgrammeCDT) - })), - resources: (({ listeRessources, listeMatieres }) => ({ - resources: parse(listeRessources), // TODO: Check values - subjects: parse(listeMatieres) // TODO: Check values - }))(parse(contents.ListeRessourcesPedagogiques)), - // TODO: Check values - numericalResources: parse(parse(contents.ListeRessourcesNumeriques).listeRessources) - }; -} - -module.exports = getContents; diff --git a/includes/external/school/node_modules/pronote-api/src/fetch/pronote/evaluations.js b/includes/external/school/node_modules/pronote-api/src/fetch/pronote/evaluations.js deleted file mode 100644 index c9065fd..0000000 --- a/includes/external/school/node_modules/pronote-api/src/fetch/pronote/evaluations.js +++ /dev/null @@ -1,49 +0,0 @@ -const parse = require('../../data/types'); -const { toPronote } = require('../../data/objects'); - -const navigate = require('./navigate'); - -const PAGE_NAME = 'DernieresEvaluations'; -const TAB_ID = 201; -const ACCOUNTS = ['student', 'parent']; - -async function getEvaluations(session, user, period) -{ - const evaluations = await navigate(session, user, PAGE_NAME, TAB_ID, ACCOUNTS, { - periode: period.name ? toPronote(period) : period - }); - - if (!evaluations) { - return null; - } - - return parse(evaluations.listeEvaluations, ({ - listeNiveauxDAcquisitions, listePaliers, matiere, individu, coefficient, descriptif, date, periode - }) => ({ - title: descriptif, - acquisitionLevels: parse(listeNiveauxDAcquisitions, ({ - abbreviation, ordre, pilier, coefficient, domaine, item - }) => ({ - position: ordre, - value: abbreviation, - pillar: parse(pilier, ({ strPrefixes }) => ({ - prefixes: strPrefixes.split(', ') - })), - coefficient, - domain: parse(domaine), - item: item && parse(item) || null - })), - levels: parse(listePaliers), - subject: parse(matiere, ({ couleur, ordre, serviceConcerne }) => ({ - position: ordre, - service: parse(serviceConcerne), - color: couleur - })), - teacher: parse(individu), - coefficient, - date: parse(date), - period: parse(periode) - })); -} - -module.exports = getEvaluations; diff --git a/includes/external/school/node_modules/pronote-api/src/fetch/pronote/files.js b/includes/external/school/node_modules/pronote-api/src/fetch/pronote/files.js deleted file mode 100644 index 2871fbe..0000000 --- a/includes/external/school/node_modules/pronote-api/src/fetch/pronote/files.js +++ /dev/null @@ -1,16 +0,0 @@ -const navigate = require('./navigate'); - -const PAGE_NAME = 'RessourcePedagogique'; -const TAB_ID = 99; -const ACCOUNTS = ['student']; - -async function getFiles(session, user) -{ - return await navigate(session, user, PAGE_NAME, TAB_ID, ACCOUNTS, { - avecRessourcesPronote: true, - avecRessourcesEditeur: false - }); -} - - -module.exports = getFiles; diff --git a/includes/external/school/node_modules/pronote-api/src/fetch/pronote/homeworks.js b/includes/external/school/node_modules/pronote-api/src/fetch/pronote/homeworks.js deleted file mode 100644 index 7d13c48..0000000 --- a/includes/external/school/node_modules/pronote-api/src/fetch/pronote/homeworks.js +++ /dev/null @@ -1,43 +0,0 @@ -const parse = require('../../data/types'); - -const navigate = require('./navigate'); - -const PAGE_NAME = 'PageCahierDeTexte'; -const TAB_ID = 88; -const ACCOUNTS = ['student', 'parent']; - -async function getHomeworks(session, user, fromWeek = 1, toWeek = null) -{ - if (!toWeek || toWeek < fromWeek) { - toWeek = fromWeek; - } - - const homeworks = await navigate(session, user, PAGE_NAME, TAB_ID, ACCOUNTS, { - domaine: { - _T: 8, - V: `[${fromWeek}..${toWeek}]` - } - }); - - if (!homeworks) { - return null; - } - - return parse(homeworks.ListeTravauxAFaire, ({ - descriptif, PourLe, TAFFait, niveauDifficulte, duree, cours, DonneLe, - Matiere, CouleurFond, ListePieceJointe - }) => ({ - description: parse(descriptif), - lesson: parse(cours), - subject: parse(Matiere), - givenAt: parse(DonneLe), - for: parse(PourLe), - done: TAFFait, - difficultyLevel: niveauDifficulte, - duration: duree, - color: CouleurFond, - files: parse(ListePieceJointe) - })); -} - -module.exports = getHomeworks; diff --git a/includes/external/school/node_modules/pronote-api/src/fetch/pronote/infos.js b/includes/external/school/node_modules/pronote-api/src/fetch/pronote/infos.js deleted file mode 100644 index 6e05ce1..0000000 --- a/includes/external/school/node_modules/pronote-api/src/fetch/pronote/infos.js +++ /dev/null @@ -1,33 +0,0 @@ -const parse = require('../../data/types'); -const navigate = require('./navigate'); - -const PAGE_NAME = 'PageActualites'; -const TAB_ID = 8; -const ACCOUNTS = ['student', 'parent']; - -async function getInfos(session, user) -{ - const infos = await navigate(session, user, PAGE_NAME, TAB_ID, ACCOUNTS, { - estAuteur: false - }); - - if (!infos) { - return null; - } - - return { - categories: parse(infos.listeCategories, ({ estDefaut }) => ({ - isDefault: estDefaut - })), - infos: parse(infos.listeActualites, ({ dateDebut, elmauteur, listeQuestions }) => ({ - date: parse(dateDebut), - author: parse(elmauteur), - content: parse(listeQuestions, ({ texte, listePiecesJointes }) => ({ - text: parse(texte), - files: parse(listePiecesJointes) - })) - })) - }; -} - -module.exports = getInfos; diff --git a/includes/external/school/node_modules/pronote-api/src/fetch/pronote/keepAlive.js b/includes/external/school/node_modules/pronote-api/src/fetch/pronote/keepAlive.js deleted file mode 100644 index 89705ec..0000000 --- a/includes/external/school/node_modules/pronote-api/src/fetch/pronote/keepAlive.js +++ /dev/null @@ -1,8 +0,0 @@ -const request = require('../../request'); - -async function keepAlive(session) -{ - await request(session, 'Presence'); -} - -module.exports = keepAlive; diff --git a/includes/external/school/node_modules/pronote-api/src/fetch/pronote/logout.js b/includes/external/school/node_modules/pronote-api/src/fetch/pronote/logout.js deleted file mode 100644 index ede23e7..0000000 --- a/includes/external/school/node_modules/pronote-api/src/fetch/pronote/logout.js +++ /dev/null @@ -1,8 +0,0 @@ -const request = require('../../request'); - -async function logout(session) -{ - await request(session, 'SaisieDeconnexion'); -} - -module.exports = logout; diff --git a/includes/external/school/node_modules/pronote-api/src/fetch/pronote/marks.js b/includes/external/school/node_modules/pronote-api/src/fetch/pronote/marks.js deleted file mode 100644 index dcb7644..0000000 --- a/includes/external/school/node_modules/pronote-api/src/fetch/pronote/marks.js +++ /dev/null @@ -1,71 +0,0 @@ -const parse = require('../../data/types'); -const { toPronote } = require('../../data/objects'); - -const navigate = require('./navigate'); - -const PAGE_NAME = 'DernieresNotes'; -const TAB_ID = 198; -const ACCOUNTS = ['student', 'parent']; - -async function getMarks(session, user, period) -{ - const marks = await navigate(session, user, PAGE_NAME, TAB_ID, ACCOUNTS, { - Periode: period.name ? toPronote(period) : period - }); - - if (!marks) { - return null; - } - - const result = {}; - - if (marks.moyGenerale) { - result.studentAverage = parse(marks.moyGenerale); - result.studentAverageScale = parse(marks.baremeMoyGenerale); - result.defaultStudentAverageScale = parse(marks.baremeMoyGeneraleParDefaut); - } - - if (marks.moyGeneraleClasse) { - result.studentClassAverage = parse(marks.moyGeneraleClasse); - } - - return { - ...result, - subjects: marks.avecDetailService && parse(marks.listeServices, ({ - ordre, estServiceEnGroupe, - moyEleve, baremeMoyEleve, baremeMoyEleveParDefaut, moyClasse, moyMax, moyMin, - couleur - }) => ({ - position: ordre, - isGroupSubject: estServiceEnGroupe, - studentAverage: parse(moyEleve), - studentAverageScale: parse(baremeMoyEleve), - defaultStudentAverageScale: parse(baremeMoyEleveParDefaut), - studentClassAverage: parse(moyClasse), - maxAverage: parse(moyMax), - minAverage: parse(moyMin), - color: couleur - })) || [], - marks: marks.avecDetailDevoir && parse(marks.listeDevoirs, ({ - note, bareme, baremeParDefaut, date, service, periode, moyenne, estEnGroupe, noteMax, noteMin, - commentaire, coefficient - }) => ({ - subject: parse(service, ({ couleur }) => ({ - color: couleur - })), - title: commentaire, - value: parse(note), - scale: parse(bareme), - average: parse(moyenne), - defaultScale: parse(baremeParDefaut), - coefficient, - min: parse(noteMin) || -1, - max: parse(noteMax) || -1, - date: parse(date), - period: parse(periode), - isGroupMark: estEnGroupe - })) || [] - }; -} - -module.exports = getMarks; diff --git a/includes/external/school/node_modules/pronote-api/src/fetch/pronote/menu.js b/includes/external/school/node_modules/pronote-api/src/fetch/pronote/menu.js deleted file mode 100644 index 988c168..0000000 --- a/includes/external/school/node_modules/pronote-api/src/fetch/pronote/menu.js +++ /dev/null @@ -1,42 +0,0 @@ -const { toPronoteDate } = require('../../data/dates'); -const parse = require('../../data/types'); - -const navigate = require('./navigate'); - -const PAGE_NAME = 'PageMenus'; -const TAB_ID = 10; -const ACCOUNTS = ['student', 'parent']; - -async function getMenu(session, user, day = new Date()) -{ - const menu = await navigate(session, user, PAGE_NAME, TAB_ID, ACCOUNTS, { - date: { - _T: 7, - V: toPronoteDate(day) - } - }); - - if (!menu) { - return null; - } - - return { - hasLunch: menu.AvecRepasMidi, - hasDiner: menu.AvecRepasSoir, - filledWeeks: parse(menu.DomaineDePresence), - menus: parse(menu.ListeJours, false).map(({ Date, ListeRepas }) => ({ - date: parse(Date), - meals: parse(ListeRepas, ({ ListePlats }) => ({ - content: parse(ListePlats, ({ ListeAliments }) => ({ - lines: parse(ListeAliments, ({ listeLabelsAlimentaires }) => ({ - labels: parse(listeLabelsAlimentaires, ({ couleur }) => ({ - color: couleur - })) - })) - })) - })) - })) - }; -} - -module.exports = getMenu; diff --git a/includes/external/school/node_modules/pronote-api/src/fetch/pronote/navigate.js b/includes/external/school/node_modules/pronote-api/src/fetch/pronote/navigate.js deleted file mode 100644 index edaa3d4..0000000 --- a/includes/external/school/node_modules/pronote-api/src/fetch/pronote/navigate.js +++ /dev/null @@ -1,23 +0,0 @@ -const { toPronote } = require('../../data/objects'); -const request = require('../../request'); - -async function navigate(session, user, page, tab, accounts, data) -{ - if (session.user.hiddenTabs.includes(tab) || !accounts.includes(session.type.name)) { - return null; - } - - const content = { - _Signature_: { - membre: toPronote(user), - onglet: tab - } - }; - if (data) { - content.donnees = data; - } - - return (await request(session, page, content)).donnees; -} - -module.exports = navigate; diff --git a/includes/external/school/node_modules/pronote-api/src/fetch/pronote/params.js b/includes/external/school/node_modules/pronote-api/src/fetch/pronote/params.js deleted file mode 100644 index 12fc2e9..0000000 --- a/includes/external/school/node_modules/pronote-api/src/fetch/pronote/params.js +++ /dev/null @@ -1,141 +0,0 @@ -const parse = require('../../data/types'); -const { fromPronote } = require('../../data/objects'); - -const request = require('../../request'); - -const { getUUID } = require('../../cipher'); - -async function getParams(session) -{ - const { donnees: params } = await request(session, 'FonctionParametres', { - donnees: { Uuid: getUUID(session, session.aesIV) } - }); - - const general = params.General; - if (!general) { - return; - } - return { - navigatorId: params.identifiantNav, - fonts: parse(params.listePolices, false).map(o => o.L), - withMember: params.avecMembre, - forNewCaledonia: params.pourNouvelleCaledonie, - loginImageId: params.genreImageConnexion, - loginImageUrl: params.urlImageConnexion, - cssLogo: params.logoProduitCss, - theme: params.Theme, - serverTime: parse(params.DateServeurHttp), - mobileURL: params.URLMobile, - mobileSupport: params.AvecEspaceMobile, - title: params.Nom, - indexEducationWebsite: parse(general.urlSiteIndexEducation), - version: general.versionPN, - versionFull: general.version, - year: ~~general.millesime, - language: { id: general.langID, name: general.langue }, - supportedLanguages: parse(general.listeLangues, false).map(({ langID, description }) => ({ - id: langID, - name: description - })), - infoPage: general.lienMentions, - hasForum: general.avecForum, - helpURL: parse(general.UrlAide), - videosURL: parse(general.urlAccesVideos), - twitterURL: parse(general.urlAccesTwitter), - withLoginOptions: general.AvecChoixConnexion, - establishment: general.NomEtablissement, - displayWeeks: general.afficherSemainesCalendaires, - schoolYear: general.AnneeScolaire, - firstCycle: parse(general.dateDebutPremierCycle), - firstDay: parse(general.PremiereDate), - firstMonday: parse(general.PremierLundi), - lastDay: parse(general.DerniereDate), - ticksPerDay: general.PlacesParJour, - ticksPerHour: general.PlacesParHeure, - sequenceDuration: general.DureeSequence, - ticksForHalfDayAbsence: general.PlaceDemiJourneeAbsence, - hasLunch: general.activationDemiPension, - lunchStart: general.debutDemiPension, - lunchEnd: general.finDemiPension, - withPlainAfternoonHours: general.AvecHeuresPleinesApresMidi, - firstOrLastWorkingDay: parse(general.JourOuvre), - workingDays: parse(general.JoursOuvres), - lunchDays: parse(general.JoursDemiPension), - parentsChat: general.ActivationMessagerieEntreParents, - workingDaysPerCycle: general.joursOuvresParCycle, - firstDayOfWeek: general.premierJourSemaine, - timetableGridsInCycle: general.grillesEDTEnCycle, - workingDaysCycle: parse(general.setOfJoursCycleOuvre), - halfWorkingDays: general.DemiJourneesOuvrees.map(parse), - frequenciesRanges: general.DomainesFrequences.map(parse), - frequenciesLabels: general.LibellesFrequences, - defaultMarkMax: parse(general.BaremeNotation), - allowedAnnotations: parse(general.listeAnnotationsAutorisees), - acquisitionLevels: parse(general.ListeNiveauxDAcquisitions, ({ - listePositionnements, positionJauge, actifPour, abbreviation, raccourci, - couleur, ponderation, nombrePointsBrevet, estAcqui, estNotantPourTxReussite - }) => ({ - positions: parse(listePositionnements, ({ abbreviation, abbreviationAvecPrefixe }) => ({ - shortName: abbreviation, - shortNameWithPrefix: abbreviationAvecPrefixe - }), 'count'), - triggerPosition: positionJauge, - activeFor: parse(actifPour), - shortName: abbreviation, - shortPath: raccourci, - color: couleur, - weighting: parse(ponderation), - brevetPoints: parse(nombrePointsBrevet), - acquired: estAcqui, - countsForSuccess: estNotantPourTxReussite - }), 'count'), - displayAcquisitionShortLabel: general.AfficherAbbreviationNiveauDAcquisition, - withEvaluationHistory: general.AvecEvaluationHistorique, - withoutIntermediaryLevelAutoValidation: general.SansValidationNivIntermediairesDsValidAuto, - onlySchoolYearEvaluationsInAutoValidation: general.NeComptabiliserQueEvalsAnneeScoDsValidAuto, - CECRLLevelsSupport: general.AvecGestionNiveauxCECRL, - langActivityColor: general.couleurActiviteLangagiere, - minMarkMCQ: general.minBaremeQuestionQCM, - maxMarkMCQ: general.maxBaremeQuestionQCM, - maxPointsMCQ: general.maxNbPointQCM, - skillsGridLabelSize: general.tailleLibelleElementGrilleCompetence, - homeworkCommentSize: general.tailleCommentaireDevoir, - officeEnabled: general.O365_Actif, - officeFederatedMode: general.O365_ModeFederated, - officeTutorial: parse(general.O365_UrlTuto_Office), - oneDriveTutorial: parse(general.O365_UrlTuto_OneDrive), - connexionInfoRetrieval: general.AvecRecuperationInfosConnexion, - font: general.Police, - fontSize: general.TaillePolice, - attachedStudents: general.AvecElevesRattaches, - phoneMask: general.maskTelephone, - maxECTS: general.maxECTS, - maxAppreciationSizes: general.TailleMaxAppreciation, - publicHolidays: parse(general.listeJoursFeries, ({ dateDebut, dateFin }) => ({ - from: parse(dateDebut), - to: parse(dateFin) - })), - displaySequences: general.afficherSequences, - firstHour: parse(general.PremiereHeure), - hours: parse(general.ListeHeures, ({ A }) => ({ - round: A === undefined - }), 'count'), - endHours: parse(general.ListeHeuresFin, ({ A }) => ({ - round: A === undefined - }), 'count'), - sequences: general.sequences, - periods: general.ListePeriodes.map(p => fromPronote(p, ({ G, periodeNotation, dateDebut, dateFin }) => ({ - kind: G === 1 ? 'trimester' : (G === 2 ? 'semester' : (G === 3 ? 'year' : 'other')), - notationPeriod: periodeNotation, - from: parse(dateDebut), - to: parse(dateFin) - }), false)), - logo: parse(general.logo), - breaks: parse(general.recreations, ({ place }) => ({ - position: place - })), - appCookieName: general.nomCookieAppli - }; -} - -module.exports = getParams; diff --git a/includes/external/school/node_modules/pronote-api/src/fetch/pronote/timetable.js b/includes/external/school/node_modules/pronote-api/src/fetch/pronote/timetable.js deleted file mode 100644 index a98b9ce..0000000 --- a/includes/external/school/node_modules/pronote-api/src/fetch/pronote/timetable.js +++ /dev/null @@ -1,81 +0,0 @@ -const parse = require('../../data/types'); -const { toPronote, fromPronote } = require('../../data/objects'); - -const navigate = require('./navigate'); - -const PAGE_NAME = 'PageEmploiDuTemps'; -const TAB_ID = 16; -const ACCOUNTS = ['student', 'parent']; - -async function getTimetable(session, user, week) -{ - const student = toPronote(session.user); - const timetable = await navigate(session, user, PAGE_NAME, TAB_ID, ACCOUNTS, { - avecAbsencesEleve: false, // TODO: Test what those parameters do - avecAbsencesRessource: true, - avecConseilDeClasse: true, - avecDisponibilites: true, - avecInfosPrefsGrille: true, - avecRessourceLibrePiedHoraire: false, - estEDTPermanence: false, - numeroSemaine: week, // *Clown emoji* - NumeroSemaine: week, - ressource: student, - Ressource: student - }); - - if (!timetable || !timetable.ListeCours) { - return null; - } - - let iCalURL = null; - if (timetable.avecExportICal) { - const id = timetable.ParametreExportiCal; - iCalURL = `${session.server}ical/Edt.ics?icalsecurise=${id}&version=${session.params.version}`; - } - - return { - hasCancelledLessons: timetable.avecCoursAnnule, - iCalURL, - lessons: timetable.ListeCours.map(o => fromPronote(o, ({ - place, duree, DateDuCours, CouleurFond, ListeContenus, AvecTafPublie, Statut, estAnnule, estRetenue, - dispenseEleve - }) => ({ - position: place, - duration: duree, - date: parse(DateDuCours), - status: Statut, - color: CouleurFond, - content: parse(ListeContenus), - hasHomework: AvecTafPublie, - isCancelled: !!estAnnule, - isDetention: !!estRetenue, - remoteLesson: !!dispenseEleve && dispenseEleve.V.maison - }))), - // I was unable to witness a filled "absences.joursCycle", so didn't include it - breaks: parse(timetable.recreations, ({ place }) => ({ - position: place - })) - }; -} - -async function getFilledDaysAndWeeks(session, user) -{ - const daysData = await navigate(session, user, PAGE_NAME + '_DomainePresence', TAB_ID, ACCOUNTS, { - Ressource: toPronote(session.user) - }); - - if (!daysData) { - return null; - } - - return { - filledWeeks: parse(daysData.Domaine), - filledDays: parse(daysData.joursPresence) - } -} - -module.exports = { - getTimetable, - getFilledDaysAndWeeks -}; diff --git a/includes/external/school/node_modules/pronote-api/src/fetch/pronote/user.js b/includes/external/school/node_modules/pronote-api/src/fetch/pronote/user.js deleted file mode 100644 index 54f62be..0000000 --- a/includes/external/school/node_modules/pronote-api/src/fetch/pronote/user.js +++ /dev/null @@ -1,183 +0,0 @@ -const request = require('../../request'); - -const parse = require('../../data/types'); -const { getFileURL } = require('../../data/files'); -const { fromPronote } = require('../../data/objects'); - -async function getUser(session) -{ - const { donnees: user } = await request(session, 'ParametresUtilisateur'); - const { data, authorizations } = getSpecificData(session, user); - - const res = user.ressource; - const aut = user.autorisations; - - return { - ...fromPronote(res), - ...data, - establishmentsInfo: parse(user.listeInformationsEtablissements, ({ Logo, Coordonnees }) => ({ - logoID: parse(Logo), - address: [Coordonnees.Adresse1, Coordonnees.Adresse2], - postalCode: Coordonnees.CodePostal, - postalLabel: Coordonnees.LibellePostal, - city: Coordonnees.LibelleVille, - province: Coordonnees.Province, - country: Coordonnees.Pays, - website: Coordonnees.SiteInternet - })), - userSettings: (({ version, EDT, theme, Communication }) => ({ - version, - timetable: { - displayCanceledLessons: EDT.afficherCoursAnnules, - invertAxis: EDT.axeInverseEDT, - invertWeeklyPlanAxis: EDT.axeInversePlanningHebdo, - invertDayPlanAxis: EDT.axeInversePlanningJour, - invertDay2PlanAxis: EDT.axeInversePlanningJour2, - dayCount: EDT.nbJours, - resourceCount: EDT.nbRessources, - daysInTimetable: EDT.nbJoursEDT, - sequenceCount: EDT.nbSequences - }, - theme: theme.theme, - unreadDiscussions: Communication.DiscussionNonLues - }))(user.parametresUtilisateur), - sessionAuthorizations: { - twitterManagement: user.autorisationsSession.fonctionnalites.gestionTwitter, - expandedAttestation: user.autorisationsSession.fonctionnalites.attestationEtendue - }, - authorizations: { - discussions: aut.AvecDiscussion, - teachersDiscussions: aut.AvecDiscussionProfesseurs, - timetableVisibleWeeks: parse(aut.cours.domaineConsultationEDT), - canEditLessons: parse(aut.cours.domaineModificationCours), - hideClassParts: aut.cours.masquerPartiesDeClasse, - maxEstablishmentFileSize: aut.tailleMaxDocJointEtablissement, - editPassword: aut.compte.avecSaisieMotDePasse, - editPersonalInfo: aut.compte.avecInformationsPersonnelles, - canPrint: aut.autoriserImpression, - ...authorizations - }, - minPasswordSize: user.reglesSaisieMDP.min, - maxPasswordSize: user.reglesSaisieMDP.max, - passwordRules: parse(user.reglesSaisieMDP.regles), - kioskAccess: user.autorisationKiosque, - tabs: user.listeOnglets.map(parseTab), - hiddenTabs: user.listeOngletsInvisibles, - notifiedTabs: user.listeOngletsNotification - }; -} - -function parseTab({ G: id, Onglet: subs }) -{ - return { id, subs: (subs || []).map(parseTab) }; -} - -function getSpecificData(session, data) -{ - switch (session.type.name) - { - case 'student': - return getStudentData(session, data); - case 'parent': - return getParentData(session, data); - case 'teacher': - - break; - case 'administration': - - break; - default: - return {}; - } -} - -function getStudentData(session, data) -{ - return { - data: getStudent(session, data.ressource), - authorizations: { - maxUserWorkFileSize: data.autorisations.tailleMaxRenduTafEleve - } - }; -} - -function getStudent(session, res) -{ - const avatar = {}; - if (res.avecPhoto) { - avatar.avatar = getFileURL(session, { - id: res.N, - name: 'photo.jpg' - }); - } - - return { - ...fromPronote(res), - establishment: parse(res.Etablissement), - ...avatar, - studentClass: fromPronote(res.classeDEleve), - classHistory: parse(res.listeClassesHistoriques, ({ AvecNote, AvecFiliere }) => ({ - hadMarks: AvecNote, - hadOptions: AvecFiliere - })), - groups: parse(res.listeGroupes), - tabsPillars: parse(res.listeOngletsPourPiliers, ({ listePaliers }) => ({ - levels: parse(listePaliers, ({ listePiliers }) => ({ - pillars: parse(listePiliers, ({ estPilierLVE, estSocleCommun, Service }) => ({ - isForeignLanguage: estPilierLVE, - isCoreSkill: estSocleCommun, - subject: Service && parse(Service) - })) - })) - }), 'tab'), - tabsPeriods: parse(res.listeOngletsPourPeriodes, ({ listePeriodes, periodeParDefaut }) => ({ - periods: parse(listePeriodes, ({ GenreNotation }) => ({ - isCorePeriod: GenreNotation === 1 - })), - defaultPeriod: parse(periodeParDefaut) - }), 'tab') - }; -} - -function getParentData(session, data) -{ - const res = data.ressource; - const aut = data.autorisations; - - return { - data: { - isDelegate: res.estDelegue, - isBDMember: res.estMembreCA, - canDiscussWithManagers: res.avecDiscussionResponsables, - absencesReasons: parse(data.listeMotifsAbsences), - delaysReasons: parse(data.listeMotifsRetards), - classDelegates: parse(res.listeClassesDelegue), - students: res.listeRessources.map(r => fromPronote(r, ({ listeSessions }) => ({ - ...getStudent(session, r), - sessions: parse(listeSessions, ({ date, strHeureDebut, strHeureFin }) => ({ - from: getDateWithHours(parse(date), strHeureDebut), - to: getDateWithHours(parse(date), strHeureFin) - })) - }))) - }, - authorizations: { - staffDiscussion: aut.AvecDiscussionPersonnels, - parentsDiscussion: aut.AvecDiscussionParents, - editStudentPassword: aut.compte.avecSaisieMotDePasseEleve, - editCoordinates: aut.compte.avecSaisieInfosPersoCoordonnees, - editAuthorizations: aut.compte.avecSaisieInfosPersoAutorisations - } - }; -} - -function getDateWithHours(date, hours) -{ - const h = hours.indexOf('h'); - - date.setHours(date.getHours() + ~~hours.substring(0, h)); - date.setMinutes(date.getMinutes() + ~~hours.substring(h)); - - return date; -} - -module.exports = getUser; diff --git a/includes/external/school/node_modules/pronote-api/src/fetch/timetable.js b/includes/external/school/node_modules/pronote-api/src/fetch/timetable.js deleted file mode 100644 index 059b849..0000000 --- a/includes/external/school/node_modules/pronote-api/src/fetch/timetable.js +++ /dev/null @@ -1,95 +0,0 @@ -const { toPronoteWeek } = require('../data/dates'); -const { withId, checkDuplicates } = require('../data/id'); - -const { getFilledDaysAndWeeks, getTimetable } = require('./pronote/timetable'); - -async function timetable(session, user, from = new Date(), to = null) -{ - if (!to || to < from) { - to = new Date(from.getTime()); - to.setDate(to.getDate() + 1); - } - - const filled = await getFilledDaysAndWeeks(session, user); - if (!filled) { - return null; - } - - const fromWeek = toPronoteWeek(session, from); - const toWeek = toPronoteWeek(session, to); - - const weeks = []; - for (let i = fromWeek; i <= toWeek; i++) { - weeks.push(i); - } - - const result = []; - for (const week of weeks) { - const timetable = await getTimetable(session, user, week); - const lessons = getTimetableWeek(session, timetable); - - if (lessons) { - lessons.filter(l => l.from >= from && l.from <= to).forEach(lesson => { - if (!filled.filledWeeks.includes(week)) { - lesson.isCancelled = true; - } - - result.push(lesson); - }); - } - } - - return result.sort((a, b) => a.from - b.from); -} - -function getTimetableWeek(session, table) { - const result = []; - if (!table || !table.lessons) { - return - } - - for (const lesson of table.lessons) { - const from = lesson.date; - const to = new Date(from.getTime() + (lesson.duration / session.params.ticksPerHour * 3600000)); - - const res = { - from, - to, - isDetention: lesson.isDetention, - remoteLesson: lesson.remoteLesson, - status: lesson.status, - hasDuplicate: !!table.lessons.find(l => l.date.getTime() === from.getTime() && l !== lesson) - }; - - let room, subject, teacher; - if (lesson.isDetention) { - subject = lesson.content[0]; - teacher = lesson.content[1]; - room = lesson.content[2]; - } else { - if (lesson.content) { - subject = lesson.content.find(o => o.type === 16); - teacher = lesson.content.find(o => o.type === 3); - room = lesson.content.find(o => o.type === 17); - } else { - subject = 'Non défini'; - room = 'Non défini'; - teacher = 'Non défini'; - } - - res.isAway = (lesson.status || false) && !!lesson.status.match(/(.+)?prof(.+)?absent(.+)?/giu); - res.isCancelled = !res.isAway && lesson.isCancelled; - res.color = lesson.color; - } - - res.subject = subject && subject.name || null; - res.teacher = teacher && teacher.name || null; - res.room = room && room.name || null; - - result.push(withId(res, ['from', 'to', 'subject'])); - } - - return checkDuplicates(result); -} - -module.exports = timetable; diff --git a/includes/external/school/node_modules/pronote-api/src/geo.js b/includes/external/school/node_modules/pronote-api/src/geo.js deleted file mode 100644 index 6b2909c..0000000 --- a/includes/external/school/node_modules/pronote-api/src/geo.js +++ /dev/null @@ -1,41 +0,0 @@ -const https = require('https'); - -function geo(lat, long) { - return new Promise((resolve, reject) => { - - const data = `data={"nomFonction": "geoLoc","lat": ${lat.toString()},"long": ${long.toString()}}`; - - const options = { - hostname: 'www.index-education.com', - port: 443, - path: '/swie/geoloc.php', - method: 'POST', - headers: { - 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8', - // eslint-disable-next-line max-len - 'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/10.0 Mobile/14E304 Safari/602.1', - 'Content-Length': data.length - } - } - - let incomingData = ''; - const request = https.request(options, res => { - res.on('data', data => { - incomingData += data; - }); - res.on('end', () => { - const data = JSON.parse(incomingData); - resolve(Array.isArray(data) ? data : []); - }); - }); - - request.write(data); - request.end(); - - request.on('error', error => { - reject(error); - }); - }) -} - -module.exports = geo; diff --git a/includes/external/school/node_modules/pronote-api/src/http.js b/includes/external/school/node_modules/pronote-api/src/http.js deleted file mode 100644 index e83abf5..0000000 --- a/includes/external/school/node_modules/pronote-api/src/http.js +++ /dev/null @@ -1,36 +0,0 @@ -const axioRequest = require('./axioRequest') - -async function http({ url, body, data, method = 'GET', binary, jar = null, followRedirects = true }) { - const response = await axioRequest({ - url, - body, - data, - method, - binary, - jar - }) - - if (response.headers.location && followRedirects) { - let location = response.headers.location; - if (!location.startsWith('http')) { - location = getOrigin(url) + location; - } - - if (followRedirects === 'get') { - return location; - } - - return await http({ - url: location, - jar - }); - } - return response.data; -} - -function getOrigin(url) { - const noProtocol = url.substring(url.indexOf('/') + 2); - return url.substring(0, url.indexOf('/')) + '//' + noProtocol.substring(0, noProtocol.indexOf('/')); -} - -module.exports = http; diff --git a/includes/external/school/node_modules/pronote-api/src/request.js b/includes/external/school/node_modules/pronote-api/src/request.js deleted file mode 100644 index 06ec411..0000000 --- a/includes/external/school/node_modules/pronote-api/src/request.js +++ /dev/null @@ -1,50 +0,0 @@ -const { cipher, decipher } = require('./cipher'); -const errors = require('./errors'); -const http = require('./http'); - -async function request(session, name, content = {}) -{ - session.request += 2; - - const disableIV = session.request === 1; - - const order = cipher(session, session.request, { disableIV }); - const url = `${session.server}appelfonction/${session.type.id}/${session.id}/${order}`; - - let data = content; - if (!session.disableAES) { - data = cipher(session, JSON.stringify(content), { compress: true, disableIV }); - } - - const result = await http({ - url, - method: 'POST', - body: { - nom: name, - numeroOrdre: order, - session: session.id, - donneesSec: data - } - }); - - if (result.Erreur) { - const { Titre, Message } = result.Erreur; - - if (Titre.startsWith('La page a expiré !')) { - throw errors.SESSION_EXPIRED.drop(); - } - if (Message.startsWith('Vous avez dépassé le nombre')) { - throw errors.RATE_LIMITED.drop(); - } - - throw errors.PRONOTE.drop({ title: Titre, message: Message }); - } - - if (!session.disableAES) { - return JSON.parse(decipher(session, result.donneesSec, { compress: true })); - } - - return result.donneesSec; -} - -module.exports = request; diff --git a/includes/external/school/node_modules/pronote-api/src/server/auth.js b/includes/external/school/node_modules/pronote-api/src/server/auth.js deleted file mode 100644 index 54962a2..0000000 --- a/includes/external/school/node_modules/pronote-api/src/server/auth.js +++ /dev/null @@ -1,49 +0,0 @@ -const { v4: uuid } = require('uuid'); - -const { loginStudent, loginParent } = require('../auth'); - -const sessions = {}; - -async function login({ url, username, password, cas, account = 'student' }) -{ - if (!url || !username || !password) { - throw { - http: 400, - message: 'Missing \'url\', or \'username\', or \'password\', or header \'Content-Type: application/json\'' - }; - } - - let func; - switch (account) { - case 'student': - func = loginStudent; - break; - case 'parent': - func = loginParent; - break; - default: - throw { - http: 400, - message: `Unknown account type '${account}'` - }; - } - - const token = uuid(); - sessions[token] = await func(url, username, password, cas); - - return { token }; -} - -// eslint-disable-next-line no-unused-vars -async function logout(_, token) -{ - delete sessions[token]; - return { success: true }; -} - -function getSession(token) -{ - return sessions[token]; -} - -module.exports = { login, logout, getSession }; diff --git a/includes/external/school/node_modules/pronote-api/src/server/context.js b/includes/external/school/node_modules/pronote-api/src/server/context.js deleted file mode 100644 index 9f34442..0000000 --- a/includes/external/school/node_modules/pronote-api/src/server/context.js +++ /dev/null @@ -1,73 +0,0 @@ -function common(session) { - return { - params: () => session.params, - user: () => session.user, - - keepAlive: async () => { - await session.keepAlive(); - return true; - }, - logout: async () => { - await session.logout(); - return true; - }, - - setKeepAlive: async ({ enabled }) => { - await session.setKeepAlive(enabled); - return enabled; - } - }; -} - -function student(session) { - return { - timetable: ({ from, to }) => session.timetable(from, to), - marks: ({ period }) => session.marks(period), - evaluations: ({ period }) => session.evaluations(period), - absences: ({ period, from, to }) => session.absences(period, from, to), - infos: () => session.infos(), - contents: ({ from, to }) => session.contents(from, to), - homeworks: ({ from, to }) => session.homeworks(from, to), - menu: ({ from, to }) => session.menu(from, to), - files: () => session.files() - }; -} - -function parent(session) { - function getStudent(student) { - for (const s of session.user.students) { - if (s.id === student || s.name === student) { - return s; - } - } - - return null; - } - - return { - timetable: ({ student, from, to }) => session.timetable(getStudent(student), from, to), - marks: ({ student, period }) => session.marks(getStudent(student), period), - evaluations: ({ student, period }) => session.evaluations(getStudent(student), period), - absences: ({ student, period, from, to }) => session.absences(getStudent(student), period, from, to), - infos: ({ student }) => session.infos(getStudent(student)), - contents: ({ student, from, to }) => session.contents(getStudent(student), from, to), - homeworks: ({ student, from, to }) => session.homeworks(getStudent(student), from, to), - menu: ({ student, from, to }) => session.menu(getStudent(student), from, to), - files: ({ student }) => session.files(getStudent(student)) - }; -} - -function getContext(session) { - const result = common(session); - - switch (session.type.name) { - case 'student': - return { ...result, ...student(session) }; - case 'parent': - return { ...result, ...parent(session) }; - default: - return result; - } -} - -module.exports = getContext; diff --git a/includes/external/school/node_modules/pronote-api/src/server/date.js b/includes/external/school/node_modules/pronote-api/src/server/date.js deleted file mode 100644 index a35cd5a..0000000 --- a/includes/external/school/node_modules/pronote-api/src/server/date.js +++ /dev/null @@ -1,20 +0,0 @@ -const { GraphQLScalarType, Kind } = require('graphql'); - -module.exports = new GraphQLScalarType({ - name: 'Date', - description: 'Equivalent of the JS Date type', - - parseValue(value) { - return new Date(value); - }, - serialize(value) { - return value.getTime(); - }, - parseLiteral(ast) { - if (ast.kind === Kind.INT) { - return new Date(parseInt(ast.value)); - } - - return new Date(ast.value); - } -}); diff --git a/includes/external/school/node_modules/pronote-api/src/server/http.js b/includes/external/school/node_modules/pronote-api/src/server/http.js deleted file mode 100644 index 66b07a5..0000000 --- a/includes/external/school/node_modules/pronote-api/src/server/http.js +++ /dev/null @@ -1,57 +0,0 @@ -/* eslint no-console: off */ - -const polka = require('polka'); -const body = require('body-parser'); - -function start(host, port, handlers) -{ - const server = polka(); - server.use(body.json()); - - server.post('/auth/login', (req, res) => handle(req, res, handlers.login)); - server.post('/auth/logout', (req, res) => handle(req, res, handlers.logout)); - server.post('/graphql', (req, res) => handle(req, res, handlers.graphql)); - - return new Promise((resolve, reject) => { - server.listen(port, host, err => { - if (err) { - return reject(err); - } - - return resolve(); - }) - }); -} - -function handle(req, res, handler) -{ - handler(req.body, req.headers.token) - .then(result => respond(res, 200, result)) - .catch(err => { - console.error('Error during request handling :'); - console.error(err); - - if (err.message) { - delete err.http; - respond(res, err.http || 500, err); - } else { - respond(res, 500, { - message: 'Internal error : ' + err - }); - } - }); -} - -function respond(res, code, obj) -{ - const data = JSON.stringify(obj); - const headers = { - 'Content-Type': 'application/json; charset=utf-8', - 'Content-Length': Buffer.byteLength(data) - }; - - res.writeHead(code, headers); - res.end(data); -} - -module.exports = start; diff --git a/includes/external/school/node_modules/pronote-api/src/server/index.js b/includes/external/school/node_modules/pronote-api/src/server/index.js deleted file mode 100644 index 1693e1c..0000000 --- a/includes/external/school/node_modules/pronote-api/src/server/index.js +++ /dev/null @@ -1,47 +0,0 @@ -const { graphql } = require('graphql'); - -const http = require('./http'); -const context = require('./context'); -const getSchemas = require('./schemas'); -const { login, logout, getSession } = require('./auth'); - -async function start(host, port) -{ - const schemas = await getSchemas(); - - await http(host, port, { - graphql: ({ query, variables }, token) => handle(token, schemas, query, context, variables), - login: params => login(params), - logout: (_, token) => logout(token) - }); -} - -async function handle(token, schemas, query, context, variables) -{ - if (!token) { - throw { - http: 401, - message: 'Missing \'Token\' header' - }; - } - - if (!query) { - throw { - http: 400, - message: 'Missing \'query\' field or \'Content-Type: application/json\' header' - }; - } - - const session = getSession(token); - if (!session) { - throw { - http: 401, - message: 'Unknown session token' - }; - } - - const schema = schemas[session.type.name]; - return await graphql(schema, query, context(session), null, variables); -} - -module.exports = start; diff --git a/includes/external/school/node_modules/pronote-api/src/server/schemas/common.graphql b/includes/external/school/node_modules/pronote-api/src/server/schemas/common.graphql deleted file mode 100644 index 0d821ff..0000000 --- a/includes/external/school/node_modules/pronote-api/src/server/schemas/common.graphql +++ /dev/null @@ -1,464 +0,0 @@ -scalar Date - -type Query { - params: PronoteParams! - user: PronoteUser! -} - -type Mutation { - # Please remember to disable this when you don't need it, or else sessions will last forever ! - setKeepAlive(enabled: Boolean!): Boolean! - - # This is in a mutation, because this is a request that send a keep alive to Pronote, not a value - # It will always returns True - keepAlive: Boolean! - - # This is in a mutation, because this is a request that send a keep alive to Pronote, not a value - # It will always returns True - logout: Boolean! -} - -type Lesson { - id: String! - from: Date! - to: Date! - isDetention: Boolean! - hasDuplicate: Boolean! - subject: String - teacher: String - room: String - status: String - isAway: Boolean - isCancelled: Boolean - color: String - remoteLesson: Boolean -} - -type Marks { - subjects: [MarksSubject]! - averages: MarksAverages! -} - -type MarksSubject { - name: String! - averages: MarksSubjectAverages! - color: String! - marks: [Mark!]! -} - -type MarksAverages { - student: Float - studentClass: Float -} - -type MarksSubjectAverages { - student: Float! - studentClass: Float! - min: Float! - max: Float! -} - -type Mark { - id: String!, - title: String!, - value: Float, - scale: Float!, - average: Float, - coefficient: Float! - min: Float - max: Float - date: Date! - isAway: Boolean! -} - -type EvaluationSubject { - name: String! - teacher: String! - color: String! - evaluations: [Evaluation!]! -} - -type Evaluation { - id: String! - name: String! - date: Date! - coefficient: Float! - levels: [EvaluationLevel!]! -} - -type EvaluationLevel { - name: String! - value: EvaluationLevelValue! - prefixes: [String!]! -} - -type EvaluationLevelValue { - short: String! - long: String! -} - -type Absences { - absences: [Absence!]! - delays: [Delay!]! - punishments: [Punishment!]! - other: [OtherEvent!]! - totals: [SubjectAbsences!]! -} - -type Absence { - id: String! - from: Date! - to: Date! - justified: Boolean! - solved: Boolean! - hours: Float! - reason: String -} - -type Delay { - id: String! - date: Date! - justified: Boolean! - solved: Boolean! - justification: String! - minutesMissed: Int! - reason: String -} - -type Punishment { - id: String! - date: Date! - isExclusion: Boolean! - isDuringLesson: Boolean! - homework: String! - circumstances: String! - giver: String! - reason: String - detention: Detention -} - -type Detention { - id: String! - from: Date! - to: Date! -} - -type OtherEvent { - id: String! - kind: String! - date: Date! - giver: String! - comment: String! - subject: String -} - -type SubjectAbsences { - subject: String! - hoursAssisted: Float! - hoursMissed: Float! - subs: [SubjectAbsences!] -} - -type Info { - id: String! - date: Date! - title: String - author: String! - content: String! - htmlContent: String! - files: [File!]! -} - -type LessonContent { - id: String! - subject: String! - teachers: [String!]! - from: Date! - to: Date! - color: String! - title: String - description: String! - htmlDescription: String! - files: [File!]! - category: String! -} - -type Homework { - id: String! - description: String! - htmlDescription: String! - subject: String! - givenAt: Date! - for: Date! - done: Boolean! - color: String! - files: [File!]! -} - -type File { - id: String! - time: String! - subject: String! - name: String! - url: String! -} - -type MenuDay { - date: Date! - meals: [[[MenuMealEntry!]!]!]! -} - -type MenuMealEntry { - name: String! - labels: [MenuMealLabel!]! -} - -type MenuMealLabel { - name: String! - color: String! -} - -type PronoteParams { - navigatorId: String - fonts: [String!]! - withMember: Boolean! - forNewCaledonia: Boolean! - loginImageId: Float! - loginImageUrl: String! - cssLogo: String! - theme: Float! - serverTime: Date! - mobileURL: String! - mobileSupport: Boolean! - title: String! - indexEducationWebsite: String! - version: String! - versionFull: String! - year: Float! - language: PronoteLanguage - supportedLanguages: [PronoteLanguage]! - infoPage: String! - hasForum: Boolean! - helpURL: String! - videosURL: String! - twitterURL: String! - withLoginOptions: Boolean! - establishment: String! - displayWeeks: String! - schoolYear: String! - firstCycle: Date! - firstDay: Date! - firstMonday: Date! - lastDay: Date! - ticksPerDay: Float! - ticksPerHour: Float! - sequenceDuration: Float! - ticksForHalfDayAbsence: Float! - hasLunch: Boolean! - lunchStart: Float! - lunchEnd: Float! - withPlainAfternoonHours: Boolean! - firstOrLastWorkingDay: Date! - workingDays: [Float!]! - lunchDays: [Float!]! - parentsChat: Boolean! - workingDaysPerCycle: Float! - firstDayOfWeek: Float! - timetableGridsInCycle: Float! - workingDaysCycle: [Float!]! - halfWorkingDays: [[Float!]!]! - frequenciesRanges: [[Float!]!]! - frequenciesLabels: [String!]! - defaultMarkMax: Float! - allowedAnnotations: [Float!]! - acquisitionLevels: [PronoteAcquisitionLevel]! - displayAcquisitionShortLabel: Boolean! - withEvaluationHistory: Boolean! - withoutIntermediaryLevelAutoValidation: Boolean! - onlySchoolYearEvaluationsInAutoValidation: Boolean! - CECRLLevelsSupport: Boolean - langActivityColor: String - minMarkMCQ: Float! - maxMarkMCQ: Float! - maxPointsMCQ: Float! - skillsGridLabelSize: Float! - homeworkCommentSize: Float! - officeEnabled: Boolean! - officeFederatedMode: Boolean! - officeTutorial: String! - oneDriveTutorial: String! - connexionInfoRetrieval: Boolean! - font: String! - fontSize: Float! - attachedStudents: Boolean! - phoneMask: String! - maxECTS: Float! - maxAppreciationSizes: [Float!]! - publicHolidays: [PronoteHoliday]! - displaySequences: Boolean! - firstHour: Date! - hours: [PronoteHour]! - endHours: [PronoteHour]! - sequences: [String!]! - periods: [PronotePeriod]! - logo: Float! - breaks: [PronoteBreak]! - appCookieName: String! -} - -type PronoteUser { - name: String! - establishmentsInfo: [PronoteEstablishmentInfo!]! - userSettings: PronoteUserSettings! - sessionAuthorizations: PronoteSessionAuthorizations! - authorizations: PronoteUserAuthorizations - minPasswordSize: Int! - maxPasswordSize: Int! - passwordRules: [Int!]! - kioskAccess: Boolean! - tabs: [PronoteTab!]! - hiddenTabs: [Int!]! - notifiedTabs: [Int!]! -} - -type PronoteLanguage { - id: Int! - name: String! -} - -type PronoteAcquisitionLevel { - count: Int! - positions: [PronoteAcquisitionLevelPositions!]! - triggerPosition: Float! - activeFor: [Int!]! - shortName: String! - shortPath: String! - color: String - weighting: Float - brevetPoints: Float - acquired: Boolean - countsForSuccess: Boolean -} - -type PronoteAcquisitionLevelPositions { - name: String! - count: Int! - shortName: String! - shortNameWithPrefix: String -} - -type PronoteHoliday { - name: String! - from: Date! - to: Date! -} - -type PronoteHour { - name: String! - count: Int! - round: Boolean! -} - -type PronotePeriod { - name: String! - notationPeriod: Int! - from: Date! - to: Date! -} - -type PronoteBreak { - name: String! - position: Int! -} - -type PronoteNamedObject { - name: String! -} - -type PronoteClassHistoryElement { - name: String! - hadMarks: Boolean! - hadOptions: Boolean! -} - -type PronoteTabPillars { - tab: Int! - levels: [PronotePillarLevel!]! -} - -type PronotePillarLevel { - name: String! - pillars: [PronotePillar!]! -} - -type PronotePillar { - name: String! - isForeignLanguage: Boolean! - isCoreSkill: Boolean! - subject: PronoteNamedObject! -} - -type PronoteTabPeriods { - tab: Int! - periods: [PronoteTabPeriod!]! - defaultPeriod: PronoteNamedObject -} - -type PronoteTabPeriod { - name: String! - isCorePeriod: Boolean! -} - -type PronoteEstablishmentInfo { - name: String! - logoID: Int! - address: [String!]! - postalCode: String! - postalLabel: String! - city: String! - province: String! - country: String! - website: String! -} - -type PronoteUserSettings { - version: Float! - timetable: PronoteUserTimetableSettings! - theme: Int! - unreadDiscussions: Boolean! -} - -type PronoteUserTimetableSettings { - displayCanceledLessons: Boolean! - invertAxis: Boolean! - invertWeeklyPlanAxis: Boolean! - invertDayPlanAxis: Boolean! - invertDay2PlanAxis: Boolean! - dayCount: Int! - resourceCount: Int! - daysInTimetable: Int! - sequenceCount: Int! -} - -type PronoteUserAuthorizations { - discussions: Boolean! - teachersDiscussions: Boolean! - timetableVisibleWeeks: [Int!]! - canEditLessons: [Int!]! - hideClassParts: Boolean! - maxEstablishmentFileSize: Int! - maxUserWorkFileSize: Int! - hasPassword: Boolean! - hasPersonalInfo: Boolean! - canPrint: Boolean! -} - -type PronoteSessionAuthorizations { - twitterManagement: Boolean! - expandedAttestation: Boolean! -} - -type PronoteTab { - id: Int! - subs: [PronoteTab!]! -} diff --git a/includes/external/school/node_modules/pronote-api/src/server/schemas/index.js b/includes/external/school/node_modules/pronote-api/src/server/schemas/index.js deleted file mode 100644 index 099d358..0000000 --- a/includes/external/school/node_modules/pronote-api/src/server/schemas/index.js +++ /dev/null @@ -1,40 +0,0 @@ -const path = require('path'); -const fs = require('fs').promises; - -const { buildSchema } = require('graphql'); - -const date = require('../date'); - -const SCHEMAS = ['student', 'parent']; - -async function readFile(name) -{ - const file = path.join(__dirname, name); - const content = await fs.readFile(file); - - return content.toString(); -} - -async function readSchema(common, name) -{ - const content = await readFile(name + '.graphql'); - const schema = buildSchema(common + '\n' + content); - - Object.assign(schema._typeMap.Date, date); - - return schema; -} - -async function getSchemas() -{ - const common = await readFile('common.graphql'); - const result = {}; - - for (const schema of SCHEMAS) { - result[schema] = await readSchema(common, schema); - } - - return result; -} - -module.exports = getSchemas; diff --git a/includes/external/school/node_modules/pronote-api/src/server/schemas/parent.graphql b/includes/external/school/node_modules/pronote-api/src/server/schemas/parent.graphql deleted file mode 100644 index 0f6bf86..0000000 --- a/includes/external/school/node_modules/pronote-api/src/server/schemas/parent.graphql +++ /dev/null @@ -1,40 +0,0 @@ -extend type Query { - timetable(student: String!, from: Date, to: Date): [Lesson!] - marks(student: String!, period: String): Marks - evaluations(student: String!, period: String): [EvaluationSubject!] - absences(student: String!, period: String, from: Date, to: Date): Absences - infos(student: String!): [Info!] - contents(student: String!, from: Date, to: Date): [LessonContent!] - homeworks(student: String!, from: Date, to: Date): [Homework!] - menu(student: String!, from: Date, to: Date): [MenuDay!] - files(student: String!): [File!] -} - -extend type PronoteUser { - isDelegate: Boolean! - isBDMember: Boolean! - canDiscussWithManagers: Boolean! - absencesReasons: [PronoteNamedObject!]! - delaysReasons: [PronoteNamedObject!]! - classDelegates: [PronoteNamedObject!]! - students: [PronoteStudent!]! -} - -extend type PronoteUserAuthorizations { - staffDiscussion: Boolean! - parentsDiscussion: Boolean! - editStudentPassword: Boolean! - editCoordinates: Boolean! - editAuthorizations: Boolean! -} - -type PronoteStudent { - name: String! - establishment: PronoteNamedObject! - avatar: String - studentClass: PronoteNamedObject! - classHistory: [PronoteClassHistoryElement!]! - groups: [PronoteNamedObject!]! - tabsPillars: [PronoteTabPillars!]! - tabsPeriods: [PronoteTabPeriods!]! -} diff --git a/includes/external/school/node_modules/pronote-api/src/server/schemas/student.graphql b/includes/external/school/node_modules/pronote-api/src/server/schemas/student.graphql deleted file mode 100644 index 99dd73f..0000000 --- a/includes/external/school/node_modules/pronote-api/src/server/schemas/student.graphql +++ /dev/null @@ -1,21 +0,0 @@ -extend type Query { - timetable(from: Date, to: Date): [Lesson!] - marks(period: String): Marks - evaluations(period: String): [EvaluationSubject!] - absences(period: String, from: Date, to: Date): Absences - infos: [Info] - contents(from: Date, to: Date): [LessonContent!] - homeworks(from: Date, to: Date): [Homework!] - menu(from: Date, to: Date): [MenuDay!] - files: [File!] -} - -extend type PronoteUser { - establishment: PronoteNamedObject! - avatar: String - studentClass: PronoteNamedObject! - classHistory: [PronoteClassHistoryElement!]! - groups: [PronoteNamedObject!]! - tabsPillars: [PronoteTabPillars!]! - tabsPeriods: [PronoteTabPeriods!]! -} diff --git a/includes/external/school/node_modules/pronote-api/src/session.js b/includes/external/school/node_modules/pronote-api/src/session.js deleted file mode 100644 index 6804d17..0000000 --- a/includes/external/school/node_modules/pronote-api/src/session.js +++ /dev/null @@ -1,84 +0,0 @@ -const { initCipher } = require('./cipher'); -const getAccountType = require('./accounts'); - -const timetable = require('./fetch/timetable'); -const marks = require('./fetch/marks'); -const evaluations = require('./fetch/evaluations'); -const absences = require('./fetch/absences'); -const infos = require('./fetch/infos'); -const contents = require('./fetch/contents'); -const homeworks = require('./fetch/homeworks'); -const menu = require('./fetch/menu'); -const files = require('./fetch/files'); - -const keepAlive = require('./fetch/pronote/keepAlive'); -const logout = require('./fetch/pronote/logout'); - -const DEFAULT_KEEP_ALIVE_RATE = 120; // In seconds. 120 is the Pronote default 'Presence' request rate. -const GENERAL_REQUESTS = { - keepAlive, logout -}; -const REQUESTS = { - timetable, marks, evaluations, absences, contents, - infos, homeworks, menu, files -}; - -class PronoteSession -{ - constructor({ serverURL, sessionID, type, disableAES, disableCompress, keyModulus, keyExponent }) - { - this.id = ~~sessionID; - this.server = serverURL; - this.type = typeof type === 'string' ? getAccountType(type) : type; - - this.disableAES = disableAES; - this.disableCompress = disableCompress; - - initCipher(this, keyModulus, keyExponent); - - this.request = -1; - this.isKeptAlive = false; - - for (const [req, method] of Object.entries(GENERAL_REQUESTS)) { - this[req] = () => method(this); - } - for (const [req, method] of Object.entries(REQUESTS)) { - this[req] = (...args) => callRequest(method, this, args); - } - } - - setKeepAlive(enabled, onError, rate = DEFAULT_KEEP_ALIVE_RATE) - { - if (enabled === this.isKeptAlive) { - return; - } - - if (enabled) { - this.interval = setInterval(() => { - this.keepAlive().catch(err => { - this.setKeepAlive(false); - if (onError) { - onError(err); - } - }); - }, rate * 1000); - } else { - clearInterval(this.interval); - } - - this.isKeptAlive = enabled; - } -} - -function callRequest(method, session, args) -{ - switch (session.type.name) - { - case 'student': - return method(session, session.user, ...args); - default: - return method(session, ...args); - } -} - -module.exports = PronoteSession; |