chzzk-z
Version:
chzzk-z is naver streaming platform Chzzk Library
42 lines • 1.21 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChzzkUser = void 0;
const apis_1 = require("./apis");
class ChzzkUser {
constructor(cm, opt) {
this.userRepository = new apis_1.ChzzkUserRepository();
this.cm = cm;
this.opt = opt;
}
async login(nidAuth, nidSession) {
this.opt.nidAuth = nidAuth;
this.opt.nidSession = nidSession;
const status = await this.userRepository.status(this.opt);
this.opt.userId = status.userIdHash;
if (!status.loggedIn) {
this.opt.nidAuth = null;
this.opt.nidSession = null;
throw new Error("failed to login.");
}
else {
this._loggedIn = true;
}
}
async logout() {
if (!this._loggedIn) {
throw new Error("not logged in.");
}
this.opt.nidAuth = null;
this.opt.nidSession = null;
this.opt.userId = null;
this._loggedIn = false;
}
async status() {
return this.userRepository.status(this.opt);
}
get loggedIn() {
return this._loggedIn;
}
}
exports.ChzzkUser = ChzzkUser;
//# sourceMappingURL=user.js.map