UNPKG

@haechi-labs/henesis-cli

Version:

🚀 Command Line Interface tool to Utilize henesis

49 lines • 1.63 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const types_1 = require("../types"); const class_transformer_1 = require("class-transformer"); const url_1 = require("./url"); const wretch_1 = require("./wretch"); class UserRpc { constructor(host, version) { this.server = `${host}/users/${version}`; } async login(email, password) { const payload = new types_1.LoginRequest(email, password); const json = await wretch_1.getWretcher() .url(`${this.server}/login`) .post(payload) .error(403, () => { throw new Error(`login failed`); }) .json(); return class_transformer_1.plainToClass(types_1.LoginResponse, json); } async changePassword(password, newPassword) { const payload = new types_1.ChangePassword(password, newPassword); await wretch_1.getWretcher() .url(`${this.server}/passwd`) .patch(payload) .error(403, () => { throw new Error(`failed to change password`); }) .json() .catch((err) => { throw err; }); } async describe() { const json = await wretch_1.getWretcher() .url(`${this.server}/me`) .get() .json() .catch((err) => { throw err; }); return class_transformer_1.plainToClass(types_1.DescribeResponse, json); } } exports.UserRpc = UserRpc; const url = url_1.baseUrl(); exports.default = new UserRpc(url, url_1.rpcVersion); //# sourceMappingURL=user.js.map