@zougui/common.furaffinity
Version:
39 lines • 2.3 kB
JavaScript
;
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _Account_cookieA, _Account_cookieB, _Account_loggedIn;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Account = void 0;
const furaffinity_api_1 = require("furaffinity-api");
class Account {
constructor(options) {
_Account_cookieA.set(this, void 0);
_Account_cookieB.set(this, void 0);
_Account_loggedIn.set(this, false);
__classPrivateFieldSet(this, _Account_cookieA, options.cookieA, "f");
__classPrivateFieldSet(this, _Account_cookieB, options.cookieB, "f");
}
async login() {
if (__classPrivateFieldGet(this, _Account_loggedIn, "f")) {
return;
}
(0, furaffinity_api_1.login)(__classPrivateFieldGet(this, _Account_cookieA, "f"), __classPrivateFieldGet(this, _Account_cookieB, "f"));
const user = await (0, furaffinity_api_1.user)();
if (!user || user.id === 'guest') {
throw new Error('Could not log you in');
}
__classPrivateFieldSet(this, _Account_loggedIn, true, "f");
}
}
exports.Account = Account;
_Account_cookieA = new WeakMap(), _Account_cookieB = new WeakMap(), _Account_loggedIn = new WeakMap();
//# sourceMappingURL=Account.js.map