30 lines
1.4 KiB
JavaScript
30 lines
1.4 KiB
JavaScript
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 { urlAutenticacao } from "./_urlAutenticacao";
|
|
import node_fetch from "cross-fetch";
|
|
/** faz a validação do token */
|
|
export const validarToken = (_a) => __awaiter(void 0, [_a], void 0, function* ({ ambiente, post, }) {
|
|
const url = `${urlAutenticacao(ambiente)}/api/validar_token`;
|
|
try {
|
|
const resposta = yield node_fetch(url, {
|
|
method: "POST",
|
|
body: JSON.stringify(post),
|
|
headers: { "Content-Type": "application/json" },
|
|
})
|
|
.then((r) => r.json())
|
|
.then((r) => r)
|
|
.then((resposta) => resposta.eCerto ? "valido" : "erro")
|
|
.catch(() => "erro");
|
|
return resposta;
|
|
}
|
|
catch (e) {
|
|
return "erro";
|
|
}
|
|
});
|