Skip to content

Commit

Permalink
Merge pull request #497 from credebl/merge-dev-to-main
Browse files Browse the repository at this point in the history
merge: develop to main
  • Loading branch information
nishad-ayanworks authored Dec 20, 2023
2 parents 852a390 + 0abc86f commit 5278ad1
Show file tree
Hide file tree
Showing 108 changed files with 5,327 additions and 3,250 deletions.
44 changes: 28 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"flowbite": "^1.7.0",
"flowbite-react": "^0.4.10",
"flowbite-typography": "^1.0.3",
"formik": "^2.4.2",
"formik": "^2.4.5",
"html2canvas": "^1.4.1",
"i": "^0.3.7",
"moment": "^2.29.4",
Expand All @@ -60,7 +60,7 @@
"react-helmet": "^6.1.0",
"react-icons": "^4.10.1",
"react-qr-code": "^2.0.11",
"react-select": "^5.7.7",
"react-select": "^5.8.0",
"react-toastify": "^9.1.3",
"secure-random-password": "^0.2.3",
"shiki": "^0.14.1",
Expand Down
22 changes: 22 additions & 0 deletions src/api/Agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,28 @@ export const getLedgers = async () => {
},
};

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

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

try {
const response = await axiosGet(details)
return response
Expand Down
23 changes: 20 additions & 3 deletions src/api/Auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,16 @@ export const decryptData = (value: any): string => {
}

export const setToLocalStorage = async (key: string, value: any) =>{
// If passed value is object then checked empty object
if (typeof value === 'object' && Boolean(Object.keys(value).length <= 0)) {
return;
}

// If passed value is string then checked if value is falsy
if (typeof value === 'string' && !value?.trim()) {
return;
}

const convertedValue = await encryptData(value)
const setValue = await localStorage.setItem(key, convertedValue as string)
return true
Expand All @@ -200,9 +210,16 @@ export const getFromLocalStorage = async (key: string) =>{
}

export const setToCookies = (cookies: AstroCookies, key: string, value: any, option: {[key: string]: any }) =>{
if(!value.trim()){
return
}
// If passed value is object then checked empty object
if (typeof value === 'object' && Boolean(Object.keys(value).length <= 0)) {
return;
}

// If passed value is string then checked if value is falsy
if (typeof value === 'string' && !value?.trim()) {
return;
}

const convertedValue = encryptData(value)
// Set HttpOnly, Secure, and SameSite attributes in the options
const updatedOption: { [key: string]: any }= {
Expand Down
6 changes: 4 additions & 2 deletions src/api/Schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import { storageKeys } from "../config/CommonConstant";

export const getAllSchemas = async ({itemPerPage, page, allSearch }: GetAllSchemaListParameter) => {
const token = await getFromLocalStorage(storageKeys.TOKEN)
const ledgerId = await getFromLocalStorage(storageKeys.LEDGER_ID)

const details = {
url: `${apiRoutes.Platform.getAllSchemaFromPlatform}?pageSize=${itemPerPage}&searchByText=${allSearch}&pageNumber=${page}`,
url: `${apiRoutes.Platform.getAllSchemaFromPlatform}?pageSize=${itemPerPage}&searchByText=${allSearch}&pageNumber=${page}&ledgerId=${ledgerId}`,
config: {
headers: {
'Content-type': 'application/json',
Expand Down Expand Up @@ -49,7 +51,7 @@ export const getAllSchemasByOrgId = async ({ search, itemPerPage, page }: GetAll
}
}

export const addSchema = async (payload: createSchema, orgId: string) => {
export const createSchemas = async (payload: createSchema, orgId: string) => {
const token = await getFromLocalStorage(storageKeys.TOKEN)
const details = {
url: `${apiRoutes.organizations.root}/${orgId}${apiRoutes.schema.create}`,
Expand Down
18 changes: 16 additions & 2 deletions src/api/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,24 @@ import { storageKeys } from '../config/CommonConstant';
import { getHeaderConfigs } from '../config/GetHeaderConfigs';
import { axiosGet } from '../services/apiRequests';
import { getFromLocalStorage } from './Auth';
export interface IConnectionListAPIParameter {
itemPerPage: number,
page: number,
search: string,
sortBy: string,
sortingOrder: string,
}

export const getConnectionsByOrg = async () => {
export const getConnectionsByOrg = async ({
page,
itemPerPage,
search,
sortBy,
sortingOrder
}: IConnectionListAPIParameter) => {
const orgId = await getFromLocalStorage(storageKeys.ORG_ID);
const url = `${apiRoutes.organizations.root}/${orgId}${apiRoutes.Issuance.getAllConnections}`;
const url = `${apiRoutes.organizations.root}/${orgId}${apiRoutes.Issuance.getAllConnections}?pageSize=${itemPerPage}&pageNumber=${page}&searchByText=${search}&sortByValue=${sortingOrder}&sorting=${sortBy}`;

const axiosPayload = {
url,
config: await getHeaderConfigs(),
Expand Down
6 changes: 2 additions & 4 deletions src/api/invitations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,14 +233,12 @@ export const getEcosystemInvitations = async (pageNumber: number, pageSize: numb
}

// Accept/ Reject Invitations
export const acceptRejectEcosystemInvitations = async (invitationId: string, orgId: string, status: string, orgName: string, orgDid: string) => {
export const acceptRejectEcosystemInvitations = async (invitationId: string, orgId: string, status: string) => {

const url = `${apiRoutes.Ecosystem.root}/${orgId}${apiRoutes.Ecosystem.invitations}/${invitationId}`

const payload = {
status,
orgName,
orgDid
status
}
const token = await getFromLocalStorage(storageKeys.TOKEN)

Expand Down
31 changes: 27 additions & 4 deletions src/api/issuance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@ import axios from 'axios';
import { apiRoutes } from '../config/apiRoutes';
import { storageKeys } from '../config/CommonConstant';
import {
getHeaderConfigs,
getHeaderConfigsForFormData,
getHeaderConfigs
} from '../config/GetHeaderConfigs';
import { axiosGet, axiosPost } from '../services/apiRequests';
import { getFromLocalStorage } from './Auth';
import type { IConnectionListAPIParameter } from './connection';

export const getIssuedCredentials = async () => {
export const getIssuedCredentials = async ({page,
itemPerPage,
search,
sortBy,
sortingOrder}: IConnectionListAPIParameter) => {
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}?pageSize=${itemPerPage}&pageNumber=${page}&searchByText=${search}&sortByValue=${sortingOrder}&sorting=${sortBy}`;

const axiosPayload = {
url,
Expand Down Expand Up @@ -60,3 +64,22 @@ export const issueCredential = async (data: object) => {
return err?.message;
}
};

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

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

try {
return await axiosPost(axiosPayload);
} catch (error) {
const err = error as Error;
return err?.message;
}
};
19 changes: 13 additions & 6 deletions src/api/verification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import { storageKeys } from '../config/CommonConstant';
import { getHeaderConfigs } from '../config/GetHeaderConfigs';
import { axiosGet, axiosPost } from '../services/apiRequests';
import { getFromLocalStorage } from './Auth';
import type { IConnectionListAPIParameter } from './connection';

export const verifyCredential = async (payload: any) => {
const orgId = await getFromLocalStorage(storageKeys.ORG_ID);
const url = `${apiRoutes.organizations.root}/${orgId}${apiRoutes.Verification.verifyCredential}`; const axiosPayload = {
const url = `${apiRoutes.organizations.root}/${orgId}${apiRoutes.Verification.verifyCredential}`;
const axiosPayload = {
url,
payload,
config: await getHeaderConfigs(),
Expand Down Expand Up @@ -37,10 +39,16 @@ export const getVerificationCredential = async (state: IssueCredential) => {
}
};

export const getVerificationList = async () => {
export const getVerificationList = async ({
page,
itemPerPage,
search,
sortBy,
sortingOrder,
}: IConnectionListAPIParameter) => {
const orgId = await getFromLocalStorage(storageKeys.ORG_ID);
const url = `${apiRoutes.organizations.root}/${orgId}${apiRoutes.Verification.verifyCredential}`
const url = `${apiRoutes.organizations.root}/${orgId}${apiRoutes.Verification.verifyCredential}?pageSize=${itemPerPage}&pageNumber=${page}&searchByText=${search}&sortByValue=${sortingOrder}&sorting=${sortBy}`;

const axiosPayload = {
url,
config: await getHeaderConfigs(),
Expand Down Expand Up @@ -71,8 +79,7 @@ export const verifyPresentation = async (proofId:string) => {
};


export const getProofAttributes=async (proofId:string)=>{
const orgId = await getFromLocalStorage(storageKeys.ORG_ID);
export const getProofAttributes=async (proofId:string, orgId: string)=>{
const url = `${apiRoutes.organizations.root}/${orgId}${apiRoutes.Verification.proofRequestAttributesVerification}/${proofId}/form`;
const axiosPayload = {
url,
Expand Down
Loading

0 comments on commit 5278ad1

Please sign in to comment.