#include common.js
#include utility.js

const MamiMisuzuAuth = (function() {
    let userId = null,
        authToken = null;

    return {
        getUserId: function() { return userId; },
        getAuthToken: function() { return authToken; },
        getInfo: function() {
            return {
                method: 'Misuzu',
                token: authToken,
            };
        },
        update: async () => {
            const resp = await $x.get(futami.get('token'), { authed: true, type: 'json' });

            const body = resp.body();
            if(body.ok) {
                userId = body.usr.toString();
                authToken = body.tkn;
            }

            return body;
        },
    };
})();
