.
This commit is contained in:
parent
aa2892c9fb
commit
fed8453f61
13 changed files with 157 additions and 211 deletions
24
dist-import/autenticacao.d.ts
vendored
24
dist-import/autenticacao.d.ts
vendored
|
|
@ -1,24 +0,0 @@
|
|||
import { type tipoResposta } from "~respostas";
|
||||
type tipoPostValidarTokem = {
|
||||
token: string;
|
||||
};
|
||||
type tipoPostCodigoContaSite = {
|
||||
site: string;
|
||||
};
|
||||
/** todas as rotas de comunicação com autenticador partem dessa variável */
|
||||
export declare const pAutenticacao: {
|
||||
validarToken: ({ ambiente, post, buscar, }: {
|
||||
ambiente: "desenvolvimento" | "producao";
|
||||
post: tipoPostValidarTokem;
|
||||
/** função que conecta com a API */
|
||||
buscar: (url: string, post: tipoPostValidarTokem) => Promise<tipoResposta<any>>;
|
||||
}) => Promise<"valido" | "erro">;
|
||||
urlAutenticacao: (ambiente: "desenvolvimento" | "producao") => string;
|
||||
codigoContaSite: ({ ambiente, post, buscar, }: {
|
||||
ambiente: "desenvolvimento" | "producao";
|
||||
post: tipoPostCodigoContaSite;
|
||||
/** função que conecta com a API */
|
||||
buscar: (url: string, post: tipoPostCodigoContaSite) => Promise<tipoResposta<string>>;
|
||||
}) => Promise<tipoResposta<string>>;
|
||||
};
|
||||
export {};
|
||||
|
|
@ -1,30 +1,39 @@
|
|||
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 = async ({ ambiente, post, buscar, }) => {
|
||||
const validarToken = ({ ambiente, post, buscar, }) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
const url = `${urlAutenticacao(ambiente)}/autenticacao/api/validar_token`;
|
||||
try {
|
||||
const resposta = await buscar(url, post)
|
||||
const resposta = yield buscar(url, post)
|
||||
.then((resposta) => resposta.eCerto ? "valido" : "erro")
|
||||
.catch((e) => "erro");
|
||||
.catch(() => "erro");
|
||||
return resposta;
|
||||
}
|
||||
catch (e) {
|
||||
return "erro";
|
||||
}
|
||||
};
|
||||
const codigoContaSite = async ({ ambiente, post, buscar, }) => {
|
||||
});
|
||||
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 = await buscar(url, post).catch((e) => respostaComuns.erro(`erro ao buscar código do site: ${e}`));
|
||||
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,
|
||||
|
|
|
|||
2
dist-import/index.d.ts
vendored
2
dist-import/index.d.ts
vendored
|
|
@ -1,2 +0,0 @@
|
|||
export * from "./tokenQuipo";
|
||||
export * from "./autenticacao";
|
||||
34
dist-import/tokenQuipo.d.ts
vendored
34
dist-import/tokenQuipo.d.ts
vendored
|
|
@ -1,34 +0,0 @@
|
|||
import { z } from "zod";
|
||||
export declare const ztokenQuipo: z.ZodObject<{
|
||||
provedor: z.ZodString;
|
||||
codigo_usuario: z.ZodString;
|
||||
nome_usuario: z.ZodString;
|
||||
codigo_conta: z.ZodString;
|
||||
nome_conta: z.ZodString;
|
||||
codigo_autenticacao: z.ZodString;
|
||||
codigo_acesso_produto: z.ZodString;
|
||||
tipo_de_acesso: z.ZodEnum<["publico", "governo", "sociedade"]>;
|
||||
exp: z.ZodOptional<z.ZodNumber>;
|
||||
}, "strip", z.ZodTypeAny, {
|
||||
provedor: string;
|
||||
codigo_usuario: string;
|
||||
nome_usuario: string;
|
||||
codigo_conta: string;
|
||||
nome_conta: string;
|
||||
codigo_autenticacao: string;
|
||||
codigo_acesso_produto: string;
|
||||
tipo_de_acesso: "publico" | "governo" | "sociedade";
|
||||
exp?: number | undefined;
|
||||
}, {
|
||||
provedor: string;
|
||||
codigo_usuario: string;
|
||||
nome_usuario: string;
|
||||
codigo_conta: string;
|
||||
nome_conta: string;
|
||||
codigo_autenticacao: string;
|
||||
codigo_acesso_produto: string;
|
||||
tipo_de_acesso: "publico" | "governo" | "sociedade";
|
||||
exp?: number | undefined;
|
||||
}>;
|
||||
export type tipos_de_acesso_quipo = z.infer<typeof ztokenQuipo>["tipo_de_acesso"];
|
||||
export type tipoTokenQuipo = z.infer<typeof ztokenQuipo>;
|
||||
Loading…
Add table
Add a link
Reference in a new issue