38 lines
1.1 KiB
JavaScript
38 lines
1.1 KiB
JavaScript
import { fetchRespHandler } from "../utils/http";
|
|
|
|
const AUTH_URL = process.env.REACT_APP_AUTH_SERVICE_URL || "https://gw-dev.fiskerdps.com/compute_auth";
|
|
const CALLBACK_URL = process.env.REACT_APP_AUTH_CALLBACK_URL || "https://dev-ota-admin.fiskerdps.com";
|
|
|
|
const auth = {
|
|
ssoAuthorize: () => `${AUTH_URL}/authorize?redirect=${CALLBACK_URL}`,
|
|
ssoLogout: () => `${AUTH_URL}/logout?redirect=${CALLBACK_URL}`,
|
|
signIn: (code) => fetch(`${AUTH_URL}/token`, {
|
|
method: "POST",
|
|
headers: {
|
|
"Content-Type": "application/json"
|
|
},
|
|
body: JSON.stringify({
|
|
code,
|
|
redirect: CALLBACK_URL,
|
|
})
|
|
}).then(fetchRespHandler),
|
|
|
|
verify: (idToken) => fetch(`${AUTH_URL}/verify`, {
|
|
method: "POST",
|
|
headers: {
|
|
"Content-Type": "application/json"
|
|
},
|
|
body: JSON.stringify({ token: idToken })
|
|
}).then(fetchRespHandler),
|
|
|
|
refresh: (refreshToken) => fetch(`${AUTH_URL}/refresh`, {
|
|
method: "POST",
|
|
headers: {
|
|
"Content-Type": "application/json"
|
|
},
|
|
body: JSON.stringify({ refresh_token: refreshToken })
|
|
}).then(fetchRespHandler),
|
|
};
|
|
|
|
export default auth;
|