summaryrefslogtreecommitdiff
path: root/alarm/node_modules/pronote-api/src/cas/generics/wayf.js
blob: cca79c7bc66266adf36ca437ff972a1d983cbed1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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;