#include common.js
#include utility.js

const MamiMisuzuAuth = (() => {
    let userId = null;
    let authMethod = 'Misuzu';
    let authToken = null;

    return {
        getUserId: () => userId,
        getAuthToken: () => authToken,
        getLine: () => `${authMethod} ${authToken}`,
        getInfo: () => {
            return {
                method: authMethod,
                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;
        },
    };
})();
