Shift to node-native authentication
Created by: slifty
The current node worker does the following in order to load a wiki page:
-
Invoke
get-cookies.sh
which (A) makes an API call to get a token and (B) makes a second API call to log in, storing the resulting cookies into acookies.jar
file -
Invoke puppeteer, passing the
cookies.jar
file so that it maintains the session.
I'm concerned that this might result in a race condition in which two users from the same wiki making calls could potentially overwrite the authentication cookie for a given domain. I also think there is value in trying to keep the curl
logic inside of node (instead of a separate shell file / process).
Node has libraries like superagent and node-fetch which can make curl-like calls and superagent has built in support for cookies. The question is whether I can pass the superagent cookie store to puppeteer or not.
If it's possible to create a common cookie store used by both superagent (or equivalent) and puppeteer, then I would like to replace get-cookies.sh
with pure node.