var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; import { respostaComuns } from "~respostas"; const urlAutenticacao = (ambiente) => `${ambiente == "producao" ? "https://carro-de-boi.idz.one" : "http://localhost:5030"}/autenticacao`; /** faz a validação do token */ const validarToken = ({ ambiente, post, buscar, }) => __awaiter(void 0, void 0, void 0, function* () { const url = `${urlAutenticacao(ambiente)}/autenticacao/api/validar_token`; try { const resposta = yield buscar(url, post) .then((resposta) => resposta.eCerto ? "valido" : "erro") .catch(() => "erro"); return resposta; } catch (e) { return "erro"; } }); const codigoContaSite = ({ ambiente, post, buscar, }) => __awaiter(void 0, void 0, void 0, function* () { const url = `${urlAutenticacao(ambiente)}/autenticacao/api/codigo_prefeitura_site`; try { const resp = yield buscar(url, post).catch((e) => respostaComuns.erro(`erro ao buscar código do site: ${e}`)); return resp; } catch (e) { return respostaComuns.erro(`erro ao buscar código do site: ${e}`); } }); /** todas as rotas de comunicação com autenticador partem dessa variável */ export const pAutenticacao = { validarToken, urlAutenticacao, codigoContaSite, };