UNPKG

@metacall/protocol

Version:

Tool for deploying into MetaCall FaaS platform.

28 lines (27 loc) 870 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const url_1 = require("url"); const protocol_1 = require("./protocol"); exports.default = async (email, password, baseURL) => { const request = { email, password }; if (!baseURL.includes('localhost')) { request['g-recaptcha-response'] = 'empty'; // TODO: Review the captcha } const res = await fetch(baseURL + '/login', { method: 'POST', headers: { Accept: 'application/json, text/plain, */*', Host: new url_1.URL(baseURL).host, Origin: baseURL, 'Content-Type': 'application/json' }, body: JSON.stringify(request) }); if (!res.ok) { throw new protocol_1.ProtocolError('Login failed', res.status, await res.text()); } return await res.text(); };