Add MediaWiki authentication to node
Created by: slifty
This PR sets the stage for moving MediaWiki authentication logic out of shell and into the mw2pdf
code base. Specifically, it introduces a new MediaWikiSession
module which will allow us to separate the auth + rendering of a given page from the collation logic.
This also begins to refactor the code base a bit, moving us to node modules and starting to add some directory structure for code organization.
The new code is not integrated / run by a calling agent, but I confirmed it works by running the following in a sandbox.js
file (node sandbox.js
) against an instance of torque-devenv.
import { MediaWikiSession } from './classes/MediaWikiSession.js'
async function x() {
const session = new MediaWikiSession()
const apiUrl = 'http://127.0.0.1/LLIIA2020/api.php'
await session.authenticate('admin', 'admin_password', apiUrl)
await session.generatePdf('http://127.0.0.1/LLIIA2020/index.php')
}
x()