Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrating Application Flow #20

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions api/adminFlow.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import axios from "axios";

const axiosInstance = axios.create({ withCredentials: true });
import axiosInstance from "./axiosInstance";

export async function handleGetIdentitiesFlow() {
try {
const getResponse = await axiosInstance.get(process.env.NEXT_PUBLIC_LIST);
const getResponse = await axiosInstance.get(process.env.NEXT_PUBLIC_NYMERIA + "list-identity");
return getResponse.data.identities;
} catch (error) {
throw error;
Expand All @@ -13,7 +11,7 @@ export async function handleGetIdentitiesFlow() {

export async function handleBanIdentityFlow(identity) {
try {
const res = await axiosInstance.put(process.env.NEXT_PUBLIC_BAN, { identity });
const res = await axiosInstance.put(process.env.NEXT_PUBLIC_NYMERIA + "update-identity/ban", { identity });
return res;
} catch (error) {
throw error;
Expand All @@ -22,7 +20,7 @@ export async function handleBanIdentityFlow(identity) {

export async function handleDeleteIdentityFlow(identity) {
try {
const res = await axiosInstance.post(process.env.NEXT_PUBLIC_DELETE, { identity });
const res = await axiosInstance.post(process.env.NEXT_PUBLIC_NYMERIA + "delete-identity", { identity });
return res;
} catch (error) {
throw error;
Expand All @@ -32,7 +30,7 @@ export async function handleDeleteIdentityFlow(identity) {
export async function handleCreateIdentityFlow(name, phone_number, email, role) {
try {
const objData = { name, email, phone_number, role, password: "" };
const res = await axiosInstance.post(process.env.NEXT_PUBLIC_CREATE, objData);
const res = await axiosInstance.post(process.env.NEXT_PUBLIC_NYMERIA + "create-identity", objData);
return res;
} catch (error) {
throw error;
Expand All @@ -41,7 +39,7 @@ export async function handleCreateIdentityFlow(name, phone_number, email, role)

export async function handleRemoveBanFlow(identity) {
try {
const res = await axiosInstance.put(process.env.NEXT_PUBLIC_REMOVE_BAN, { identity });
const res = await axiosInstance.put(process.env.NEXT_PUBLIC_NYMERIA + "update-identity/remove-ban", { identity });
return res;
} catch (error) {
throw error;
Expand All @@ -50,7 +48,7 @@ export async function handleRemoveBanFlow(identity) {

export async function handleRoleSwitchFlow(identity) {
try {
const res = await axiosInstance.put(process.env.NEXT_PUBLIC_SWITCH_ROLE, { identity });
const res = await axiosInstance.put(process.env.NEXT_PUBLIC_NYMERIA + "update-identity/switch-roles", { identity });
return res;
} catch (error) {
throw error;
Expand Down
38 changes: 38 additions & 0 deletions api/applicationFlow.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import axiosInstance from "./axiosInstance";

export async function handleGetAllApplicationsFlow() {
try {
const getResponse = await axiosInstance.get(process.env.NEXT_PUBLIC_NYMERIA + "applications");
return getResponse.data.identities;
} catch (error) {
throw error;
}
}

export async function handleCreateApplicationsFlow(identity) {
try {
const res = await axiosInstance.put(process.env.NEXT_PUBLIC_NYMERIA + "applications", { identity });
return res;
} catch (error) {
throw error;
}
}

export async function handleUpdateApplicationsFlow(identity) {
try {
const res = await axiosInstance.post(process.env.NEXT_PUBLIC_NYMERIA + "applications", { identity });
return res;
} catch (error) {
throw error;
}
}

export async function handleDeleteApplicationFlow(name, phone_number, email, role) {
try {
const objData = { name, email, phone_number, role, password: "" };
const res = await axiosInstance.post(process.env.NEXT_PUBLIC_NYMERIA + "applications", objData);
return res;
} catch (error) {
throw error;
}
}
5 changes: 5 additions & 0 deletions api/axiosInstance.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import axios from "axios";

const axiosInstance = axios.create({ withCredentials: true });

export default axiosInstance;
8 changes: 3 additions & 5 deletions api/loginFlow.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import axios from "axios";

const axiosInstance = axios.create({ withCredentials: true });
import axiosInstance from "./axiosInstance";

export async function handleGetLoginFlow() {
try {
const getResponse = await axiosInstance.get(process.env.NEXT_PUBLIC_LOGIN);
const getResponse = await axiosInstance.get(process.env.NEXT_PUBLIC_NYMERIA + "login");

const flowID = getResponse.data.flowID;
const csrf_token = getResponse.data.csrf_token;
Expand All @@ -17,7 +15,7 @@ export async function handleGetLoginFlow() {
export async function handlePostLoginFlow(flowID, csrf_token, email, password) {
try {
const objData = { flowID, csrf_token, password, identifier: email };
const res = await axiosInstance.post(process.env.NEXT_PUBLIC_LOGIN, objData);
const res = await axiosInstance.post(process.env.NEXT_PUBLIC_NYMERIA + "login", objData);
return res.data;
} catch (error) {
throw error;
Expand Down
8 changes: 3 additions & 5 deletions api/logoutFlow.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import axios from "axios";

const axiosInstance = axios.create({ withCredentials: true });
import axiosInstance from "./axiosInstance";

export async function handleGetLogoutFlow() {
try {
const getResponse = await axiosInstance.get(process.env.NEXT_PUBLIC_LOGOUT);
const getResponse = await axiosInstance.get(process.env.NEXT_PUBLIC_NYMERIA + "logout");

const logoutToken = getResponse.data.logoutToken;
return logoutToken;
Expand All @@ -15,7 +13,7 @@ export async function handleGetLogoutFlow() {

export async function handlePostLogoutFlow(logoutToken) {
try {
await axiosInstance.post(process.env.NEXT_PUBLIC_LOGOUT, { logoutToken });
await axiosInstance.post(process.env.NEXT_PUBLIC_NYMERIA + "logout", { logoutToken });
} catch (error) {
throw error;
}
Expand Down
8 changes: 3 additions & 5 deletions api/mfaFlow.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import axios from "axios";

const axiosInstance = axios.create({ withCredentials: true });
import axiosInstance from "./axiosInstance";

export async function handleGetMFAFlow() {
try {
const getResponse = await axiosInstance.get(process.env.NEXT_PUBLIC_MFA);
const getResponse = await axiosInstance.get(process.env.NEXT_PUBLIC_NYMERIA + "mfa");

const flowID = getResponse.data.flowID;
const csrf_token = getResponse.data.csrf_token;
Expand All @@ -17,7 +15,7 @@ export async function handleGetMFAFlow() {
export async function handlePostMFAFlow(flowID, csrf_token, totp) {
try {
const objData = { flowID, csrf_token, totp };
const res = await axiosInstance.post(process.env.NEXT_PUBLIC_MFA, objData);
const res = await axiosInstance.post(process.env.NEXT_PUBLIC_NYMERIA + "mfa", objData);
return res.data;
} catch (error) {
throw error;
Expand Down
6 changes: 2 additions & 4 deletions api/profileFlow.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import axios from "axios";

const axiosInstance = axios.create({ withCredentials: true });
import axiosInstance from "./axiosInstance";

export async function handleGetSessionDetailsFlow() {
try {
const getResponse = await axiosInstance.post(process.env.NEXT_PUBLIC_GET_PROFILE);
const getResponse = await axiosInstance.post(process.env.NEXT_PUBLIC_NYMERIA + "get_profile");
return getResponse.data;
} catch (error) {
throw error;
Expand Down
8 changes: 3 additions & 5 deletions api/recoveryFlow.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import axios from "axios";

const axiosInstance = axios.create({ withCredentials: true });
import axiosInstance from "./axiosInstance";

export async function handleGetRecoveryFlow() {
try {
const getResponse = await axiosInstance.get(process.env.NEXT_PUBLIC_RECOVERY);
const getResponse = await axiosInstance.get(process.env.NEXT_PUBLIC_NYMERIA + "recovery");

const flowID = getResponse.data.flowID;
const csrf_token = getResponse.data.csrf_token;
Expand All @@ -17,7 +15,7 @@ export async function handleGetRecoveryFlow() {
export async function handlePostRecoveryFlow(flowID, csrf_token, email) {
try {
const objData = { flowID, csrf_token, email };
const res = await axiosInstance.post(process.env.NEXT_PUBLIC_RECOVERY, objData);
const res = await axiosInstance.post(process.env.NEXT_PUBLIC_NYMERIA + "recovery", objData);
return res.data.message;
} catch (error) {
throw error;
Expand Down
8 changes: 3 additions & 5 deletions api/registerFlow.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import axios from "axios";

const axiosInstance = axios.create({ withCredentials: true });
import axiosInstance from "./axiosInstance";

export async function handleGetRegisterFlow() {
try {
const getResponse = await axiosInstance.get(process.env.NEXT_PUBLIC_SIGNUP);
const getResponse = await axiosInstance.get(process.env.NEXT_PUBLIC_NYMERIA + "register");

const flowID = getResponse.data.flowID;
const csrf_token = getResponse.data.csrf_token;
Expand All @@ -17,7 +15,7 @@ export async function handleGetRegisterFlow() {
export async function handlePostRegisterFlow(flowID, csrf_token, password, email, name, phone_number) {
try {
const objData = { flowID, csrf_token, password, traits: { email, name, phone_number } };
const res = await axiosInstance.post(process.env.NEXT_PUBLIC_SIGNUP, objData);
const res = await axiosInstance.post(process.env.NEXT_PUBLIC_NYMERIA + "register", objData);
return res;
} catch (error) {
throw error;
Expand Down
12 changes: 5 additions & 7 deletions api/settingsFlow.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import axios from "axios";

const axiosInstance = axios.create({ withCredentials: true });
import axiosInstance from "./axiosInstance";

export async function handleGetSettingsFlow() {
try {
const getResponse = await axiosInstance.get(process.env.NEXT_PUBLIC_SETTINGS);
const getResponse = await axiosInstance.get(process.env.NEXT_PUBLIC_NYMERIA + "settings");
const flowID = getResponse.data.flowID;
const csrf_token = getResponse.data.csrf_token;
const qr = getResponse.data.qr;
Expand All @@ -18,7 +16,7 @@ export async function handleGetSettingsFlow() {
export async function handlePostToggleTOTPFlow(flowID, csrf_token, totp_code, totp_unlink) {
try {
const objData = { csrf_token, totp_code, flowID, totp_unlink };
const res = await axiosInstance.post(process.env.NEXT_PUBLIC_TOGGLETOTP, objData);
const res = await axiosInstance.post(process.env.NEXT_PUBLIC_NYMERIA + "toggletotp", objData);
return res.data.status;
} catch (error) {
throw error;
Expand All @@ -28,7 +26,7 @@ export async function handlePostToggleTOTPFlow(flowID, csrf_token, totp_code, to
export async function handlePostChangePasswordFlow(flowID, csrf_token, password) {
try {
const objData = { csrf_token, flowID, password };
const res = await axiosInstance.post(process.env.NEXT_PUBLIC_CHANGE_PASSWORD, objData);
const res = await axiosInstance.post(process.env.NEXT_PUBLIC_NYMERIA + "changepassword", objData);
return res.data.status;
} catch (error) {
throw error;
Expand All @@ -38,7 +36,7 @@ export async function handlePostChangePasswordFlow(flowID, csrf_token, password)
export async function handlePostUpdateProfileFlow(flowID, csrf_token, traits) {
try {
const objData = { csrf_token, flowID, traits };
const res = await axiosInstance.post(process.env.NEXT_PUBLIC_UPDATE_PROFILE, objData);
const res = await axiosInstance.post(process.env.NEXT_PUBLIC_NYMERIA + "updateprofile", objData);
return res.data.status;
} catch (error) {
throw error;
Expand Down
8 changes: 3 additions & 5 deletions api/verificationFlow.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import axios from "axios";

const axiosInstance = axios.create({ withCredentials: true });
import axiosInstance from "./axiosInstance";

export async function handleGetVerifyFlow() {
try {
const getResponse = await axiosInstance.get(process.env.NEXT_PUBLIC_VERIFY);
const getResponse = await axiosInstance.get(process.env.NEXT_PUBLIC_NYMERIA + "verification");

const flowID = getResponse.data.flowID;
const csrf_token = getResponse.data.csrf_token;
Expand All @@ -17,7 +15,7 @@ export async function handleGetVerifyFlow() {
export async function handlePostVerifyFlow(flowID, csrf_token, email) {
try {
const objData = { flowID, csrf_token, email };
const res = await axiosInstance.post(process.env.NEXT_PUBLIC_VERIFY, objData);
const res = await axiosInstance.post(process.env.NEXT_PUBLIC_NYMERIA + "verification", objData);
return res.data.message;
} catch (error) {
throw error;
Expand Down
18 changes: 1 addition & 17 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,7 @@
const nextConfig = {
reactStrictMode: true,
env: {
NEXT_PUBLIC_LOGIN: process.env.NEXT_PUBLIC_LOGIN,
NEXT_PUBLIC_SIGNUP: process.env.NEXT_PUBLIC_SIGNUP,
NEXT_PUBLIC_LOGOUT: process.env.NEXT_PUBLIC_LOGOUT,
NEXT_PUBLIC_RECOVERY: process.env.NEXT_PUBLIC_RECOVERY,
NEXT_PUBLIC_LIST: process.env.NEXT_PUBLIC_LIST,
NEXT_PUBLIC_SETTINGS: process.env.NEXT_PUBLIC_SETTINGS,
NEXT_PUBLIC_MFA: process.env.NEXT_PUBLIC_MFA,
NEXT_PUBLIC_TOGGLETOTP: process.env.NEXT_PUBLIC_TOGGLETOTP,
NEXT_PUBLIC_CHANGE_PASSWORD: process.env.NEXT_PUBLIC_CHANGE_PASSWORD,
NEXT_PUBLIC_BAN: process.env.NEXT_PUBLIC_BAN,
NEXT_PUBLIC_DELETE: process.env.NEXT_PUBLIC_DELETE,
NEXT_PUBLIC_VERIFY: process.env.NEXT_PUBLIC_VERIFY,
NEXT_PUBLIC_GET_PROFILE: process.env.NEXT_PUBLIC_GET_PROFILE,
NEXT_PUBLIC_UPDATE_PROFILE: process.env.NEXT_PUBLIC_UPDATE_PROFILE,
NEXT_PUBLIC_CREATE: process.env.NEXT_PUBLIC_CREATE,
NEXT_PUBLIC_REMOVE_BAN: process.env.NEXT_PUBLIC_REMOVE_BAN,
NEXT_PUBLIC_SWITCH_ROLE: process.env.NEXT_PUBLIC_SWITCH_ROLE,
NEXT_PUBLIC_NYMERIA: process.env.NEXT_PUBLIC_NYMERIA,
},
};

Expand Down
Loading