First working version of EVE-PI

This commit is contained in:
Calli
2023-06-23 12:07:45 +03:00
commit 5429ff7969
46 changed files with 28631 additions and 0 deletions

55
src/esi-sso.ts Normal file
View File

@@ -0,0 +1,55 @@
import { AccessToken } from "./types";
export const refreshToken = async (
character: AccessToken
): Promise<AccessToken> => {
return fetch(`api/refresh`, {
method: "POST",
mode: "cors",
cache: "no-cache",
credentials: "same-origin",
headers: {
"Content-Type": "application/json",
},
redirect: "error",
referrerPolicy: "no-referrer",
body: JSON.stringify(character),
}).then((res) => res.json());
};
export const revokeToken = async (
character: AccessToken
): Promise<Response> => {
return fetch(`api/revoke`, {
method: "POST",
mode: "cors",
cache: "no-cache",
credentials: "same-origin",
headers: {
"Content-Type": "application/json",
},
redirect: "error",
referrerPolicy: "no-referrer",
body: JSON.stringify(character),
});
};
export const loginParameters = async (
selectedScopes: string[],
EVE_SSO_CLIENT_ID: string,
EVE_SSO_CALLBACK_URL: string
) => {
return new URLSearchParams({
response_type: "code",
redirect_uri: EVE_SSO_CALLBACK_URL,
client_id: EVE_SSO_CLIENT_ID,
scope: selectedScopes.join(" "),
state: "asfe",
}).toString();
};
export const eveSwagger = async () => {
return fetch("https://esi.evetech.net/latest/swagger.json").then((res) =>
res.json()
);
};