mami/src/mami.js/mszauth.js

30 lines
726 B
JavaScript

#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;
},
};
})();