Skip to content

Commit

Permalink
Merge pull request #437 from credebl/merge-dev-prod-nov21
Browse files Browse the repository at this point in the history
Merge develop to prod
  • Loading branch information
nishad-ayanworks authored Nov 22, 2023
2 parents 1100702 + f3503b3 commit 4006fab
Show file tree
Hide file tree
Showing 103 changed files with 5,289 additions and 1,932 deletions.
529 changes: 516 additions & 13 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"react-helmet": "^6.1.0",
"react-icons": "^4.10.1",
"react-qr-code": "^2.0.11",
"react-select": "^5.7.7",
"react-toastify": "^9.1.3",
"secure-random-password": "^0.2.3",
"shiki": "^0.14.1",
Expand Down
277 changes: 277 additions & 0 deletions public/images/Black bg.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/bg_banner_image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/credebl-screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions src/api/Agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,28 @@ export const getAgentHealth = async (orgId:number) => {
},
};

try {
const response = await axiosGet(details)
return response
}
catch (error) {
const err = error as Error
return err?.message
}
}

export const getLedgers = async () => {
const token = await getFromLocalStorage(storageKeys.TOKEN)
const details = {
url: `${apiRoutes.Platform.getLedgers}`,
config: {
headers: {
'Content-type': 'application/json',
'Authorization': `Bearer ${token}`,
},
},
};

try {
const response = await axiosGet(details)
return response
Expand Down
24 changes: 24 additions & 0 deletions src/api/Auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { apiRoutes } from '../config/apiRoutes'
import { envConfig } from '../config/envConfig'
import { storageKeys } from '../config/CommonConstant'
import type { AddPassword } from '../components/Profile/interfaces'
import type { AstroCookies } from 'astro'

export interface UserSignUpData {
email: string,
Expand Down Expand Up @@ -198,6 +199,29 @@ export const getFromLocalStorage = async (key: string) =>{
return convertedValue
}

export const setToCookies = (cookies: AstroCookies, key: string, value: any, option: {[key: string]: any }) =>{
if(!value.trim()){
return
}
const convertedValue = encryptData(value)
// Set HttpOnly, Secure, and SameSite attributes in the options
const updatedOption: { [key: string]: any }= {
...option,
httpOnly: true,
secure: true, // Set to true if using HTTPS
sameSite: 'Strict',
};
cookies.set(key, convertedValue as string, updatedOption)

return true
}

export const getFromCookies = (cookies: AstroCookies, key: string) =>{
const value = cookies.get(key).value
const convertedValue = value ? decryptData(value) : ''
return convertedValue
}

export const removeFromLocalStorage = async (key: string) => {
await localStorage.removeItem(key);
return true;
Expand Down
175 changes: 175 additions & 0 deletions src/api/BulkIssuance.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
import type download from 'downloadjs';
import { apiRoutes } from '../config/apiRoutes';
import { storageKeys } from '../config/CommonConstant';
import {
getHeaderConfigs,
getHeaderConfigsForFormData,
} from '../config/GetHeaderConfigs';
import { axiosGet, axiosPost } from '../services/apiRequests';
import { getFromLocalStorage } from './Auth';

export const getSchemaCredDef = async () => {
const orgId = await getFromLocalStorage(storageKeys.ORG_ID);
const url = `${apiRoutes.organizations.root}/${orgId}${apiRoutes.Issuance.bulk.credefList}`;
const axiosPayload = {
url,
config: await getHeaderConfigs(),
};

try {
return await axiosGet(axiosPayload);
} catch (error) {
const err = error as Error;
return err?.message;
}
};

export const DownloadCsvTemplate = async () => {
const orgId = await getFromLocalStorage(storageKeys.ORG_ID);
const credDefId = await getFromLocalStorage(storageKeys.CRED_DEF_ID);
const url = `${apiRoutes.organizations.root}/${orgId}/${credDefId}${apiRoutes.Issuance.download}`;

const axiosPayload = {
url,
config: await getHeaderConfigs(),
};

try {
return await axiosGet(axiosPayload);
} catch (error) {
const err = error as Error;
return err?.message;
}
};

// bulk issuance

// upload file

export const uploadCsvFile = async (payload: any) => {
const orgId = await getFromLocalStorage(storageKeys.ORG_ID);
const credefId = await getFromLocalStorage(storageKeys.CRED_DEF_ID);

const url = `${apiRoutes.organizations.root}/${orgId}${apiRoutes.Issuance.bulk.uploadCsv}?credDefId=${credefId}`;

const axiosPayload = {
url,
payload: payload,
config: await getHeaderConfigsForFormData(),
};

try {
return await axiosPost(axiosPayload);
} catch (error) {
const err = error as Error;
return err?.message;
}
};

//get file data

export const getCsvFileData = async (
requestId: any,
pageNumber: number,
pageSize: number,
search: string,
) => {
const orgId = await getFromLocalStorage(storageKeys.ORG_ID);
const url = `${apiRoutes.organizations.root}/${orgId}/${requestId}${apiRoutes.Issuance.bulk.preview}?pageNumber=${pageNumber}&pageSize=${pageSize}&search=${search}`;

const axiosPayload = {
url,
config: await getHeaderConfigs(),
};

try {
return await axiosGet(axiosPayload);
} catch (error) {
const err = error as Error;
return err?.message;
}
};

export const issueBulkCredential = async (requestId: string, clientId: string) => {
const orgId = await getFromLocalStorage(storageKeys.ORG_ID);
const url = `${apiRoutes.organizations.root}/${orgId}/${requestId}${apiRoutes.Issuance.bulk.bulk}`;

const axiosPayload = {
url,
config: await getHeaderConfigs(),
payload: {
clientId
}
};

try {
return await axiosPost(axiosPayload);
} catch (error) {
const err = error as Error;
return err?.message;
}
};

export const retryBulkIssuance = async (fileId:string) => {
const socketId= await getFromLocalStorage(storageKeys.SOCKET_ID)

const orgId = await getFromLocalStorage(storageKeys.ORG_ID);
const url = `${apiRoutes.organizations.root}/${orgId}/${fileId}${apiRoutes.Issuance.bulk.retry}`;

const axiosPayload = {
url,
payload:{clientId:socketId},
config: await getHeaderConfigs(),
};

try {
return await axiosPost(axiosPayload);
} catch (error) {
const err = error as Error;
return err?.message;
}
};

export const getFilesHistory = async (
pageNumber: number,
pageSize: number,
search: string,
) => {
const orgId = await getFromLocalStorage(storageKeys.ORG_ID);
const url = `${apiRoutes.organizations.root}/${orgId}${apiRoutes.Issuance.bulk.files}?pageNumber=${pageNumber}&pageSize=${pageSize}&search=${search}`;

const axiosPayload = {
url,
config: await getHeaderConfigs(),
};

try {
return await axiosGet(axiosPayload);
} catch (error) {
const err = error as Error;
return err?.message;
}
};

export const getFilesDataHistory = async (
requestId: string,
pageNumber: number,
pageSize: number,
search: string,
sortBy:string
) => {
const orgId = await getFromLocalStorage(storageKeys.ORG_ID);
const url = `${apiRoutes.organizations.root}/${orgId}/${requestId}${apiRoutes.Issuance.bulk.filesData}?pageNumber=${pageNumber}&pageSize=${pageSize}&search=${search}&sortBy=${sortBy}`;

const axiosPayload = {
url,
config: await getHeaderConfigs(),
};

try {
return await axiosGet(axiosPayload);
} catch (error) {
const err = error as Error;
return err?.message;
}
};
16 changes: 9 additions & 7 deletions src/api/issuance.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import axios from 'axios';
import { apiRoutes } from '../config/apiRoutes';
import { storageKeys } from '../config/CommonConstant';
import { getHeaderConfigs } from '../config/GetHeaderConfigs';
import {
getHeaderConfigs,
getHeaderConfigsForFormData,
} from '../config/GetHeaderConfigs';
import { axiosGet, axiosPost } from '../services/apiRequests';
import { getFromLocalStorage } from './Auth';

export const getIssuedCredentials = async () => {
const orgId = await getFromLocalStorage(storageKeys.ORG_ID);
const url= `${apiRoutes.organizations.root}/${orgId}${apiRoutes.Issuance.getIssuedCredentials}`;
const url = `${apiRoutes.organizations.root}/${orgId}${apiRoutes.Issuance.getIssuedCredentials}`;

const axiosPayload = {
url,
Expand All @@ -22,9 +26,8 @@ export const getIssuedCredentials = async () => {
};

export const getCredentialDefinitions = async (schemaId: string) => {

const orgId = await getFromLocalStorage(storageKeys.ORG_ID);
const url= `${apiRoutes.organizations.root}/${orgId}${apiRoutes.schema.getCredDefBySchemaId}/${schemaId}/cred-defs`;
const url = `${apiRoutes.organizations.root}/${orgId}${apiRoutes.schema.getCredDefBySchemaId}/${schemaId}/cred-defs`;

const axiosPayload = {
url,
Expand All @@ -39,12 +42,11 @@ export const getCredentialDefinitions = async (schemaId: string) => {
}
};


export const issueCredential = async (data: object) => {
const orgId = await getFromLocalStorage(storageKeys.ORG_ID);
const url = `${apiRoutes.organizations.root}/${orgId}${apiRoutes.Issuance.issueCredential}`;
const url = `${apiRoutes.organizations.root}/${orgId}${apiRoutes.Issuance.issueCredential}`;
const payload = data;

const axiosPayload = {
url,
payload,
Expand Down
43 changes: 42 additions & 1 deletion src/api/users.ts
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
import { apiRoutes } from '../config/apiRoutes';
import { axiosGet } from '../services/apiRequests';
import { axiosGet, axiosPut } from '../services/apiRequests';
import { getFromLocalStorage } from './Auth';
import { getHeaderConfigs } from '../config/GetHeaderConfigs';
import { storageKeys } from '../config/CommonConstant';

export interface IPlatformSetting {
externalIp: string;
lastInternalId: string;
sgApiKey: string;
emailFrom: string;
apiEndPoint: string;
enableEcosystem: boolean;
multiEcosystemSupport: boolean;
}

export const getUserActivity = async (limit: number) => {
const orgId = await getFromLocalStorage(storageKeys.ORG_ID);
const url = `${apiRoutes.users.recentActivity}?limit=${limit}`;
Expand All @@ -19,3 +29,34 @@ export const getUserActivity = async (limit: number) => {
return err?.message;
}
};

export const getPlatformSettings = async () => {
const url = `${apiRoutes.users.platformSettings}`;
const axiosPayload = {
url,
config: await getHeaderConfigs()
};

try {
return await axiosGet(axiosPayload);
} catch (error) {
const err = error as Error;
return err?.message;
}
};

export const updatePlatformSettings = async (payload: IPlatformSetting) => {
const url = `${apiRoutes.users.platformSettings}`;
const axiosPayload = {
url,
config: await getHeaderConfigs(),
payload
};

try {
return await axiosPut(axiosPayload);
} catch (error) {
const err = error as Error;
return err?.message;
}
};
5 changes: 3 additions & 2 deletions src/app/LayoutCommon.astro
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { url } from '../lib/data.js';
import { SITE_TITLE } from './constants.js';
const { class: clazz } = Astro.props;
const { class: clazz, metaData } = Astro.props;
const baseUrl = process.env.PUBLIC_BASE_URL || import.meta.env.PUBLIC_BASE_URL
const encryptKey = process.env.PUBLIC_CRYPTO_PRIVATE_KEY || import.meta.env.PUBLIC_CRYPTO_PRIVATE_KEY
Expand All @@ -17,6 +17,7 @@ const supabaseKey = process.env.PUBLIC_SUPABASE_KEY || import.meta.env.PUBLIC_SU
<!DOCTYPE html>
<html lang="en">

<head set:html={metaData}/>
<head>
<HelmetHead
siteTitle={SITE_TITLE}
Expand All @@ -27,7 +28,7 @@ const supabaseKey = process.env.PUBLIC_SUPABASE_KEY || import.meta.env.PUBLIC_SU
sitemap={url('sitemap-index.xml')}
client:load
/>

<script is:inline>
if (
localStorage.getItem('color-theme') === 'dark' ||
Expand Down
Loading

0 comments on commit 4006fab

Please sign in to comment.