diff --git a/.env.demo b/.env.demo index 859e6383f..db93d00f0 100644 --- a/.env.demo +++ b/.env.demo @@ -14,11 +14,8 @@ PUBLIC_PLATFORM_NAME=CREDEBL PUBLIC_PLATFORM_LOGO=/images/CREDEBL_ICON.png PUBLIC_POWERED_BY=Blockster Labs Pvt. Ltd. PUBLIC_PLATFORM_WEB_URL=https://credebl.id/ -PUBLIC_POWERED_BY_URL=https://blockster.global PUBLIC_PLATFORM_DOCS_URL=https://docs.credebl.id/en/intro/what-is-credebl/ PUBLIC_PLATFORM_GIT=https://github.com/credebl -PUBLIC_PLATFORM_SUPPORT_EMAIL=support@blockster.global -PUBLIC_PLATFORM_SUPPORT_INVITE= PUBLIC_PLATFORM_TWITTER_URL="https://twitter.com/i/flow/login?redirect_after_login=%2Fcredebl" PUBLIC_PLATFROM_DISCORD_SUPPORT="https://discord.gg/w4hnQT7NJG" PUBLIC_ALLOW_DOMAIN="http://your-ip:5000 http://localhost:5000 http://localhost:5001 http://your-ip:5001 https://cdnjs.cloudflare.com https://tailwindcss.com https://www.blockster.global https://www.ayanworks.com https://qaapi.credebl.id https://devapi.credebl.id https://api.credebl.id https://*.credebl.id https://fonts.googleapis.com https://fonts.gstatic.com https://avatars.githubusercontent.com https://dev-org-logo.s3.ap-south-1.amazonaws.com https://flowbite-admin-dashboard.vercel.app/ wss://devapi.credebl.id wss://qaapi.credebl.id wss://api.credebl.id wss://*.credebl.id https://qa.credebl.id https://dev.credebl.id https://credebl.id http://your-ip:3001 http://localhost:3001 http://localhost:3000/certificates ws://your-ip:5000 ws://localhost:5000 https://rpc-amoy.polygon.technology/" \ No newline at end of file diff --git a/.env.sample b/.env.sample index 66bf1ac28..77a7547d8 100644 --- a/.env.sample +++ b/.env.sample @@ -11,10 +11,8 @@ PUBLIC_PLATFORM_NAME= # Please specify your paltform name PUBLIC_PLATFORM_LOGO= # Please specify your logo file link PUBLIC_POWERED_BY= # Please specify your powered by org name PUBLIC_PLATFORM_WEB_URL= # Please specify your platform web URL -PUBLIC_POWERED_BY_URL= # Please specify your support URL PUBLIC_PLATFORM_DOCS_URL= # Please specify your documentation URL PUBLIC_PLATFORM_GIT= # Please specify your Github URL -PUBLIC_PLATFORM_SUPPORT_EMAIL= # Please specify your support email PUBLIC_PLATFORM_TWITTER_URL= # Please specify your twitter URL PUBLIC_PLATFROM_DISCORD_SUPPORT= # Please specify your discord support url diff --git a/.github/workflows/deploy-dev.yml b/.github/workflows/deploy-dev.yml index f202e9e7a..78c954b05 100644 --- a/.github/workflows/deploy-dev.yml +++ b/.github/workflows/deploy-dev.yml @@ -1,9 +1,9 @@ name: Deploy develop branch to Deno on: push: - branches: develop + branches: develop-fixed-dco pull_request: - branches: develop + branches: develop-fixed-dco jobs: deploy: @@ -22,8 +22,53 @@ jobs: with: node-version: lts/* - - name: remove previous node module - run: rm -rf node_modules + - name: Create .env file + + run: | + + echo "PUBLIC_MODE=DEV" > .env + + echo "PUBLIC_BASE_URL=${{ secrets.DEV_PUBLIC_BASE_URL }}" >> .env + + echo "PUBLIC_SHOW_NAME_AS_LOGO=true" >> .env + + echo "PUBLIC_PLATFORM_NAME=CREDEBL" >> .env + + echo "PUBLIC_PLATFORM_LOGO=/images/CREDEBL_ICON.png" >> .env + + echo "PUBLIC_POWERED_BY=Blockster Labs Pvt. Ltd" >> .env + + echo "PUBLIC_PLATFORM_DOCS_URL=https://docs.credebl.id/docs" >> .env + + echo "PUBLIC_PLATFORM_GIT=https://github.com/credebl" >> .env + + echo "PUBLIC_PLATFORM_TWITTER_URL=https://twitter.com/i/flow/login?redirect_after_login=%2Fcredebl" >> .env + + echo "PUBLIC_PLATFROM_DISCORD_SUPPORT=https://discord.gg/w4hnQT7NJG" >> .env + + echo "PUBLIC_ALLOW_DOMAIN=${{ secrets.DEV_PUBLIC_ALLOW_DOMAIN }}" >> .env + + echo "PUBLIC_POLYGON_MAINNET_URL=https://polygon-rpc.com/" >> .env + + echo "PUBLIC_POLYGON_TESTNET_URL=https://rpc-amoy.polygon.technology" >> .env + + echo "PUBLIC_ECOSYSTEM_FRONT_END_URL=https://dev-ecosystem.credebl.id" >> .env + + echo "PUBLIC_CREDEBL_FRONT_END_URL=https://dev.credebl.id" >> .env + + echo "PUBLIC_ECOSYSTEM_BASE_URL=${{ secrets.DEV_PUBLIC_ECOSYSTEM_BASE_URL }}" >> .env + + echo "PUBLIC_PLATFORM_DISCORD_URL=https://discord.gg/w4hnQT7NJG" >> .env + + echo "PUBLIC_REDIRECTION_TARGET_URL=https://social-share.credebl.id" >> .env + + echo "PUBLIC_CRYPTO_PRIVATE_KEY=${{ secrets.DEV_PUBLIC_CRYPTO_PRIVATE_KEY }}" >> .env + + echo "PUBLIC_KEYCLOAK_MANAGEMENT_CLIENT_ID=${{ secrets.DEV_PUBLIC_KEYCLOAK_MANAGEMENT_CLIENT_ID }}" >> .env + + echo "PUBLIC_KEYCLOAK_MANAGEMENT_CLIENT_SECRET=${{ secrets.DEV_PUBLIC_KEYCLOAK_MANAGEMENT_CLIENT_SECRET }}" >> .env + + echo "PUBLIC_REDIRECT_FROM_URL=https://dev.credebl.id" >> .env - name: Build step run: npm install && npm run build # 📝 Update the build command(s) diff --git a/.github/workflows/deploy-qa.yml b/.github/workflows/deploy-qa.yml index 7fc5c3f9e..a9ca4a4d7 100644 --- a/.github/workflows/deploy-qa.yml +++ b/.github/workflows/deploy-qa.yml @@ -1,9 +1,9 @@ name: Deploy develop branch to Deno on: push: - branches: qa + branches: qa-fixed-dco pull_request: - branches: qa + branches: qa-fixed-dco jobs: deploy: @@ -17,18 +17,59 @@ jobs: - name: Clone repository uses: actions/checkout@v3 - - - name: Install Deno - uses: denoland/setup-deno@v1 - with: - deno-version: v1.x - - - name: Install Node.js uses: actions/setup-node@v3 with: node-version: lts/* + - name: Create .env file + + run: | + + echo "PUBLIC_MODE=DEV" > .env + + echo "PUBLIC_BASE_URL=${{ secrets.QA_PUBLIC_BASE_URL }}" >> .env + + echo "PUBLIC_SHOW_NAME_AS_LOGO=true" >> .env + + echo "PUBLIC_PLATFORM_NAME=CREDEBL" >> .env + + echo "PUBLIC_PLATFORM_LOGO=/images/CREDEBL_ICON.png" >> .env + + echo "PUBLIC_POWERED_BY=Blockster Labs Pvt. Ltd" >> .env + + echo "PUBLIC_PLATFORM_DOCS_URL=https://docs.credebl.id/docs" >> .env + + echo "PUBLIC_PLATFORM_GIT=https://github.com/credebl" >> .env + + echo "PUBLIC_PLATFORM_TWITTER_URL=https://twitter.com/i/flow/login?redirect_after_login=%2Fcredebl" >> .env + + echo "PUBLIC_PLATFROM_DISCORD_SUPPORT=https://discord.gg/w4hnQT7NJG" >> .env + + echo "PUBLIC_ALLOW_DOMAIN=${{ secrets.QA_PUBLIC_ALLOW_DOMAIN }}" >> .env + + echo "PUBLIC_POLYGON_MAINNET_URL=https://polygon-rpc.com/" >> .env + + echo "PUBLIC_POLYGON_TESTNET_URL=https://rpc-amoy.polygon.technology" >> .env + + echo "PUBLIC_ECOSYSTEM_FRONT_END_URL=https://qa-ecosystem.credebl.id" >> .env + + echo "PUBLIC_CREDEBL_FRONT_END_URL=https://qa.credebl.id" >> .env + + echo "PUBLIC_ECOSYSTEM_BASE_URL=${{ secrets.QA_PUBLIC_ECOSYSTEM_BASE_URL }}" >> .env + + echo "PUBLIC_PLATFORM_DISCORD_URL=https://discord.gg/w4hnQT7NJG" >> .env + + echo "PUBLIC_REDIRECTION_TARGET_URL=https://social-share.credebl.id" >> .env + + echo "PUBLIC_CRYPTO_PRIVATE_KEY=${{ secrets.QA_PUBLIC_CRYPTO_PRIVATE_KEY }}" >> .env + + echo "PUBLIC_KEYCLOAK_MANAGEMENT_CLIENT_ID=${{ secrets.QA_PUBLIC_KEYCLOAK_MANAGEMENT_CLIENT_ID }}" >> .env + + echo "PUBLIC_KEYCLOAK_MANAGEMENT_CLIENT_SECRET=${{ secrets.QA_PUBLIC_KEYCLOAK_MANAGEMENT_CLIENT_SECRET }}" >> .env + + echo "PUBLIC_REDIRECT_FROM_URL=https://qa.credebl.id" >> .env + - name: Build step run: npm install && npm run build # 📝 Update the build command(s) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index b9f6f1f0f..573e62be1 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,9 +1,9 @@ name: Deploy on: push: - branches: qa-fixed-dco + branches: main pull_request: - branches: qa-fixed-dco + branches: main jobs: deploy: @@ -41,4 +41,4 @@ jobs: entrypoint: "server/entry.mjs" root: "dist" - + \ No newline at end of file diff --git a/src/api/Auth.ts b/src/api/Auth.ts index 45e158e80..f6ca57632 100644 --- a/src/api/Auth.ts +++ b/src/api/Auth.ts @@ -221,15 +221,15 @@ export const addPasskeyUserDetails = async(payload: AddPassword, email:string) = } export const passwordEncryption = (password: string): string => { - const CRYPTO_PRIVATE_KEY: string = `${envConfig.PUBLIC_CRYPTO_PRIVATE_KEY}` + const CRYPTO_PRIVATE_KEY: string = import.meta.env.PUBLIC_CRYPTO_PRIVATE_KEY; const encryptedPassword: string = CryptoJS.AES.encrypt(JSON.stringify(password), CRYPTO_PRIVATE_KEY).toString() return encryptedPassword } export const encryptData = (value: any): string => { - const CRYPTO_PRIVATE_KEY: string = `${envConfig.PUBLIC_CRYPTO_PRIVATE_KEY}` - + const CRYPTO_PRIVATE_KEY: string = import.meta.env.PUBLIC_CRYPTO_PRIVATE_KEY; + try { if (typeof (value) !== 'string') { value = JSON.stringify(value) @@ -243,7 +243,7 @@ export const encryptData = (value: any): string => { } export const decryptData = (value: any): string => { - const CRYPTO_PRIVATE_KEY: string = `${envConfig.PUBLIC_CRYPTO_PRIVATE_KEY}` + const CRYPTO_PRIVATE_KEY: string = import.meta.env.PUBLIC_CRYPTO_PRIVATE_KEY; try { let bytes = CryptoJS.AES.decrypt(value, CRYPTO_PRIVATE_KEY); diff --git a/src/api/verification.ts b/src/api/verification.ts index 05c2b4816..4d77fed61 100644 --- a/src/api/verification.ts +++ b/src/api/verification.ts @@ -1,4 +1,4 @@ -import type { IssueCredential, RequestType } from '../common/enums'; +import { APIVersion, type IssueCredential, type RequestType } from '../common/enums'; import { apiRoutes } from '../config/apiRoutes'; import { storageKeys } from '../config/CommonConstant'; import { getHeaderConfigs } from '../config/GetHeaderConfigs'; @@ -23,6 +23,24 @@ export const verifyCredential = async (payload: object, requestType:RequestType) } }; + +export const verifyCredentialV2 = async (payload: object, requestType:RequestType) => { + const orgId = await getFromLocalStorage(storageKeys.ORG_ID); + const url = `${APIVersion.version_v2}${apiRoutes.organizations.root}/${orgId}${apiRoutes.Verification.verifyCredential}?requestType=${requestType}`; + const axiosPayload = { + url, + payload, + config: await getHeaderConfigs(), + }; + + try { + return await axiosPost(axiosPayload); + } catch (error) { + const err = error as Error; + return err?.message; + } +}; + export const createOobProofRequest = async (payload: object, requestType: RequestType) => { const orgId = await getFromLocalStorage(storageKeys.ORG_ID); const url = `${apiRoutes.organizations.root}/${orgId}${apiRoutes.Verification.oobProofRequest}?requestType=${requestType}`; diff --git a/src/app/LayoutCommon.astro b/src/app/LayoutCommon.astro index d3f99555e..c385e6cc4 100644 --- a/src/app/LayoutCommon.astro +++ b/src/app/LayoutCommon.astro @@ -1,20 +1,10 @@ --- import pkg from '../../package.json' assert { type: 'json' }; -import { getFromCookies } from '../api/Auth'; import { SITE_TITLE } from './constants.js'; import { envConfig } from '../config/envConfig'; const { class: clazz, metaData } = Astro.props; -const initData: any = {}; - -const envKeys = [...Object.keys(process.env), ...Object.keys(import.meta.env)]; -envKeys.forEach((item) => { - initData[item] = process.env[item] || import.meta.env[item]; -}); - -const sessionToken = getFromCookies(Astro.cookies, 'session'); -const refreshToken = getFromCookies(Astro.cookies, 'refresh'); --- @@ -34,12 +24,8 @@ const refreshToken = getFromCookies(Astro.cookies, 'refresh'); - - + - - - + \ No newline at end of file diff --git a/src/common/enums.ts b/src/common/enums.ts index adb652b17..fa59a664a 100644 --- a/src/common/enums.ts +++ b/src/common/enums.ts @@ -156,4 +156,8 @@ export enum Environment { PROD = 'PROD', DEV = 'DEV', QA = 'QA' +} + +export enum APIVersion { + version_v2 = '/v2' } \ No newline at end of file diff --git a/src/commonComponents/CustomCheckbox.tsx b/src/commonComponents/CustomCheckbox.tsx index 09a94ac03..6aac6979e 100644 --- a/src/commonComponents/CustomCheckbox.tsx +++ b/src/commonComponents/CustomCheckbox.tsx @@ -5,39 +5,10 @@ import type { ICustomCheckboxProps, ISchemaData } from './interface'; const CustomCheckbox: React.FC = ({ showCheckbox, isVerificationUsingEmail, onChange, schemaData }) => { const [checked, setChecked] = useState(false); - - useEffect(() => { - if (schemaData) { - try { - const selectedSchemas = JSON.parse(localStorage.getItem('selectedSchemas') ?? '[]'); - const isChecked = selectedSchemas.some((schema: ISchemaData) => schema.schemaId === schemaData.schemaId); - setChecked(isChecked); - } catch (error) { - console.error('Error parsing JSON from localStorage:', error); - } - } - }, [schemaData]); - const handleCheckboxChange = async () => { const newChecked = !checked; setChecked(newChecked); onChange(newChecked, schemaData); - - try { - const selectedSchemas = JSON.parse(localStorage.getItem('selectedSchemas') ?? '[]'); - - if (newChecked) { - selectedSchemas.push(schemaData); - } else { - const index = selectedSchemas.findIndex((schema: ISchemaData) => schema.schemaId === schemaData?.schemaId); - if (index > -1) { - selectedSchemas.splice(index, 1); - } - } - await setToLocalStorage(storageKeys.SELECTED_SCHEMAS, JSON.stringify(selectedSchemas)); - } catch (error) { - console.error('Error updating localStorage:', error); - } }; return ( diff --git a/src/commonComponents/QRcode.tsx b/src/commonComponents/QRcode.tsx index 4d51e1099..3bf1864d4 100644 --- a/src/commonComponents/QRcode.tsx +++ b/src/commonComponents/QRcode.tsx @@ -4,7 +4,8 @@ import domtoimage from 'dom-to-image'; const CustomQRCode = ({ value, size }: { value: string, size: number }) => { - const inputRef = useRef(null); + const node = document.createTextNode(''); + const inputRef = useRef(node); const [isCopied, setIsCopied] = useState(false); function copyTextVal(e: React.MouseEvent) { @@ -24,7 +25,7 @@ const CustomQRCode = ({ value, size }: { value: string, size: number }) => { } const drawHtmlToCanvas = () => { - domtoimage.toJpeg(inputRef.current, { quality: 0.95 }) + domtoimage.toJpeg(inputRef.current, { quality: 0.95 }) .then(function (dataUrl) { var link = document.createElement('a'); link.download = 'my-image-name.jpeg'; diff --git a/src/commonComponents/SchemaCard.tsx b/src/commonComponents/SchemaCard.tsx index 92a420024..fcea3a8b5 100644 --- a/src/commonComponents/SchemaCard.tsx +++ b/src/commonComponents/SchemaCard.tsx @@ -11,6 +11,7 @@ import { limitedAttributesLength, storageKeys } from '../config/CommonConstant'; import type { IAttribute, ISchemaCardProps, ISchemaData } from './interface'; import CustomCheckbox from './CustomCheckbox'; import { Ledgers, Network, PolygonNetworks } from '../common/enums'; +import React from 'react'; const SchemaCard = (props: ISchemaCardProps) => { const orgDidDetails = async () => { @@ -65,16 +66,14 @@ const handleCheckboxChange = (checked: boolean, schemaData?: ISchemaData) => { } }; +const SchemaData = { + schemaId: props.schemaId, + attributes: props.attributes, + issuerDid: props.issuerDid, + created: props.created, +}; - return ( - { - - if (!props.w3cSchema) { - props.onClickCallback(props.schemaId, props.attributes, props.issuerDid, props.created) - } - - if (props.w3cSchema) { - const W3CSchemaData = { + const W3CSchemaData = { schemaId: props.schemaId, schemaName: props.schemaName, version: props.version, @@ -83,6 +82,12 @@ const handleCheckboxChange = (checked: boolean, schemaData?: ISchemaData) => { created: props.created, }; + return ( + { + if (!props.w3cSchema && props.onClickCallback) { + props.onClickCallback(SchemaData); + } + if (props.w3cSchema && props.onClickW3CCallback) { props.onClickW3CCallback(W3CSchemaData); } }} diff --git a/src/commonComponents/datatable/index.tsx b/src/commonComponents/datatable/index.tsx index 3726e40eb..a1548d900 100644 --- a/src/commonComponents/datatable/index.tsx +++ b/src/commonComponents/datatable/index.tsx @@ -1,9 +1,9 @@ -import type { TableData, TableHeader } from './interface'; +import type { ITableData, TableHeader } from './interface'; import CustomSpinner from '../../components/CustomSpinner'; interface DataTableProps { header: TableHeader[]; - data: TableData[]; + data: ITableData[]; loading: boolean; callback?: (clickId: string | null | undefined) => void; displaySelect?: boolean; diff --git a/src/commonComponents/datatable/interface.ts b/src/commonComponents/datatable/interface.ts index 86ae114bf..7cd5870e6 100644 --- a/src/commonComponents/datatable/interface.ts +++ b/src/commonComponents/datatable/interface.ts @@ -6,7 +6,7 @@ export interface TableHeader { width?: string; } -export interface TableData { +export interface ITableData { clickId?: string | null; data: Data[]; } @@ -20,7 +20,7 @@ export interface Data { export interface IDataTable { header: TableHeader[]; - data: TableData[]; + data: ITableData[]; loading: boolean; onInputChange: (e: ChangeEvent) => void; refresh: () => void; diff --git a/src/commonComponents/interface.ts b/src/commonComponents/interface.ts index 272af59f9..ebcc55aa1 100644 --- a/src/commonComponents/interface.ts +++ b/src/commonComponents/interface.ts @@ -40,7 +40,11 @@ export interface ISchemaCardProps { created: string; isClickable?: boolean; showCheckbox?: boolean; - onClickCallback: (schemaId: string, attributes: string[], issuerDid: string, created: string) => void; + onClickCallback: (SchemaData:{ + schemaId: string; + attributes: string[]; + issuerDid: string; + created: string}) => void; onClickW3CCallback: (W3CSchemaData: { schemaId: string; diff --git a/src/components/AddOrganizationInEcosystem.tsx b/src/components/AddOrganizationInEcosystem.tsx deleted file mode 100644 index ebfb9b1f1..000000000 --- a/src/components/AddOrganizationInEcosystem.tsx +++ /dev/null @@ -1,434 +0,0 @@ - -import type { AxiosResponse } from 'axios'; -import { useEffect, useState } from 'react'; -import type { ChangeEvent } from 'react'; -import type { TableData } from '../commonComponents/datatable/interface'; -import { apiStatusCodes, storageKeys } from '../config/CommonConstant'; -import { AlertComponent } from './AlertComponent'; -import BreadCrumbs from './BreadCrumbs'; -import { getFromLocalStorage, removeFromLocalStorage, setToLocalStorage } from '../api/Auth'; -import SortDataTable from '../commonComponents/datatable/SortDataTable'; -import { getOrganizations } from '../api/organization'; -import CustomAvatar from '../components/Avatar'; - -import type { Organisation } from '../components/organization/interfaces'; -import { Roles } from '../utils/enums/roles'; -import { Button } from 'flowbite-react'; -import { addOrganizationInEcosystem } from '../api/ecosystem'; -import { pathRoutes } from '../config/pathRoutes'; - - -const initialPageState = { - page: 1, - search: '', - sortingOrder: 'desc', - pageSize: 10, - role: Roles.OWNER -}; - -interface IErrorOrg { - id: string; - error: string; -} - -interface IErrorResponse { - statusCode: number; - message: string; - data?: { - orgId: string; - } - error?: string; -} - -interface ICurrentPage { - page: number; - pageSize: number; - search: string; - role: string; -} - -const AddOrganizationInEcosystem = () => { - const [listAPIParameter, setListAPIParameter] = useState(initialPageState); - const [errorList, setErrorList] = useState([]); - const [loading, setLoading] = useState(true); - const [error, setError] = useState(null); - const [success, setSuccess] = useState(null); - const [localOrgs, setLocalOrgs] = useState([]); - const [pageInfo, setPageInfo] = useState({ - totalItem: 0, - nextPage: 0, - lastPage: 0, - }); - const [totalPages, setTotalPages] = useState(0); - const [loader, setLoader] = useState(false); - const [organizationsList, setOrganizationsList] = useState | null>(null); - const [tableData, setTableData] = useState([]) - - const selectOrganization = async (item: Organisation, checked: boolean) => { - try { - const index = localOrgs?.length > 0 ? localOrgs.findIndex(ele => ele === item.id) : -1 - - if (index === -1) { - setLocalOrgs((prev: string[]) => [...prev, item.id]) - } else { - const updateLocalOrgs = [...localOrgs] - if (!checked) { - updateLocalOrgs.splice(index, 1); - } - setLocalOrgs(updateLocalOrgs) - } - } catch (error) { - throw new Error(`SELECTED ORGANIZATION:::${error}`); - } - } - - const generateTable = async (organizationsList: Organisation[] | null) => { - const id = await getFromLocalStorage(storageKeys.ECOSYSTEM_ID); - const connections = organizationsList && organizationsList?.length > 0 && organizationsList?.map((ele: Organisation) => { - const isChecked = localOrgs.includes(ele.id) - const alreadyAdded = ele.ecosystemOrgs?.some(item => item.ecosystemId === id) - const title = alreadyAdded ? "Already exists in the ecosystem" : "" - const error = errorList.find(item => item.id === ele.id)?.error || ele.error; - - return { - data: [ - { - data: ( -
- ) => { - const inputElement = event.target as HTMLInputElement; - - const updateOrgList: Organisation[] = organizationsList?.map(item => { - if (item.id === ele.id) { - selectOrganization(item, inputElement.checked) - return { - ...item, - checked: inputElement.checked - } - } - return item - }) - setOrganizationsList(updateOrgList) - }} - disabled={alreadyAdded} - defaultChecked={(ele.checked || isChecked) && !alreadyAdded} - className={`w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded-lg dark:ring-offset-gray-800 dark:bg-gray-700 dark:border-gray-600 disabled:opacity-100 ${alreadyAdded ? "cursor-not-allowed" : "cursor-pointer"}`} - /> -
- ), - }, - { - data: ( -
-
- {(ele?.logoUrl) ? - : - } -
-
- {ele.name} -
-
- ) - }, - { data: (
{ele.id}
) }, - { - data: ( -
- { - ele?.roles?.length > 0 && ele?.roles?.map(item => ( - - {item} - - )) - } -
- ), - }, - { - data: ( -
- { -
{error || "-"}
- } -
- ), - } - ], - }; - }); - setTableData(connections); - } - - useEffect(() => { - generateTable(organizationsList); - }, [organizationsList, localOrgs]) - - const getOwnerOrganizations = async (currentPage: ICurrentPage) => { - setLoading(true); - const response = await getOrganizations( - currentPage.page, - currentPage.pageSize, - currentPage.search, - currentPage.role - ); - const { data } = response as AxiosResponse; - - if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) { - const totalPages = data?.data?.totalPages; - const orgList = data?.data?.organizations.map((userOrg: Organisation) => { - const roles: string[] = userOrg.userOrgRoles.map( - (role) => role.orgRole.name, - ); - userOrg.roles = roles; - return userOrg; - }); - setPageInfo({ - ...pageInfo, - totalItem: data?.data?.totalCount, - lastPage: data?.data?.totalPages, - nextPage: listAPIParameter?.page + 1 - }) - setOrganizationsList(orgList); - setTotalPages(totalPages); - } else { - setError(response as string); - } - setLoading(false); - }; - - const header = [ - { columnName: '', width: 'w-0.5' }, - { columnName: 'Organization' }, - { columnName: 'Id' }, - { columnName: 'Role(s)' }, - { columnName: 'Error' }, - ]; - - //onChange of Search input text - const searchInputChange = (e: ChangeEvent) => { - setListAPIParameter({ - ...listAPIParameter, - search: e.target.value, - page: 1, - }); - }; - - const refreshPage = () => { - setLocalOrgs([]); - getOwnerOrganizations(listAPIParameter); - }; - - const updateLocalOrgs = async () => { - const res = await getFromLocalStorage(storageKeys.SELECT_ORG_IN_ECOSYSTEM) - const selectedOrg = res ? JSON.parse(res) : [] - setLocalOrgs(selectedOrg); - - const err = await getFromLocalStorage(storageKeys.ERROR_ORG_IN_ECOSYSTEM) - const errOrgs = err ? JSON.parse(err) : [] - setErrorList(errOrgs); - } - - const handleAddOrganization = async () => { - const orgId = (await getFromLocalStorage(storageKeys.ORG_ID)) || ''; - const ecosystemId = - (await getFromLocalStorage(storageKeys.ECOSYSTEM_ID)) || ''; - setLoader(true); - try { - const response = await addOrganizationInEcosystem( - localOrgs, - ecosystemId, - orgId, - ); - const { data } = response as AxiosResponse; - setLoader(false); - setLocalOrgs([]); - setErrorList([]); - setOrganizationsList( - (prevState) => - prevState?.map((org) => ({ ...org, checked: false, error: '' })) || - [], - ); - - switch (data?.statusCode) { - case apiStatusCodes.API_STATUS_CREATED: - await removeFromLocalStorage(storageKeys.SELECT_ORG_IN_ECOSYSTEM); - setSuccess(data.message); - setTimeout(() => { - window.location.href = pathRoutes.ecosystem.dashboard; - }, 1000); - break; - - case apiStatusCodes.API_STATUS_PARTIALLY_COMPLETED: - await removeFromLocalStorage(storageKeys.SELECT_ORG_IN_ECOSYSTEM); - const errors = data?.data?.filter( - (item: IErrorResponse) => - item.statusCode !== apiStatusCodes.API_STATUS_CREATED, - ); - const errorData = errors.map((item: IErrorResponse) => ({ - id: item?.data?.orgId || '', - error: item.message, - })); - await setToLocalStorage( - storageKeys.ERROR_ORG_IN_ECOSYSTEM, - JSON.stringify(errorData), - ); - setErrorList(errorData); - setLocalOrgs([]); - - const updateWithError = - organizationsList && organizationsList?.length > 0 - ? organizationsList?.map((item) => ({ - ...item, - error: - errors?.find( - (ele: IErrorResponse) => ele?.data?.orgId === item.id, - )?.message || '', - checked: false - })) - : []; - setSuccess(data?.message); - setOrganizationsList(updateWithError); - setErrorList([]); - break; - default: - setError((response as string) || data?.message); - setErrorList([]); - setLocalOrgs([]); - setOrganizationsList( - (prevState) => - prevState?.map((org) => ({ - ...org, - checked: false, - error: '', - })) || [], - ); - - break; - } - } catch (error) { - setError(error.message as string); - setLoader(false); - setLocalOrgs([]); - setErrorList([]); - setOrganizationsList( - (prevState) => - prevState?.map((org) => ({ ...org, checked: false, error: '' })) || - [], - ); - } - }; - - useEffect(() => { - const clearLocalStorage = async () => { - await removeFromLocalStorage(storageKeys.SELECT_ORG_IN_ECOSYSTEM); - await removeFromLocalStorage(storageKeys.ERROR_ORG_IN_ECOSYSTEM); - }; - clearLocalStorage(); - refreshPage(); - - }, []); - - useEffect(() => { - getOwnerOrganizations(listAPIParameter); - updateLocalOrgs() - }, [listAPIParameter]); - - useEffect(() => { - updateLocalOrgs(); - (async () => { - await removeFromLocalStorage(storageKeys.SELECT_ORG_IN_ECOSYSTEM); - await removeFromLocalStorage(storageKeys.ERROR_ORG_IN_ECOSYSTEM); - })() - }, []) - - useEffect(() => { - (async () => { - await setToLocalStorage(storageKeys.SELECT_ORG_IN_ECOSYSTEM, JSON.stringify(localOrgs)) - })() - }, [localOrgs]) - - return ( -
- -
-

- Add Organizations -

-
- {(error || success) && ( - { - setError(null); - setSuccess(null); - }} - /> - )} - { - setListAPIParameter((prevState) => ({ - ...prevState, - page, - })); - }} - totalPages={totalPages} - pageInfo={pageInfo} - isHeader={true} - isSearch={true} - isRefresh={true} - isSort={false} - message={'No Organizations'} - discription={"You don't have any Organization to add"} - itemPerPage={listAPIParameter.pageSize} - > -
- -
-
- ); -}; - -export default AddOrganizationInEcosystem; diff --git a/src/components/Authentication/SignUpUser.tsx b/src/components/Authentication/SignUpUser.tsx index 41df2bcfc..6f5201038 100644 --- a/src/components/Authentication/SignUpUser.tsx +++ b/src/components/Authentication/SignUpUser.tsx @@ -69,24 +69,33 @@ const SignUpUser = () => { }; const ValidateEmail = async (values: emailValue) => { + setVerificationSuccess('') setLoading(true) const userRsp = await checkUserExist(values?.email) const { data } = userRsp as AxiosResponse setLoading(false) + const { isEmailVerified, isRegistrationCompleted } = data?.data || {}; if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) { - if (data?.data?.isRegistrationCompleted === false && data.data.isEmailVerified === false) { - setEmail(values?.email) - await VerifyMail(values?.email) + + if (isEmailVerified){ + if(isRegistrationCompleted){ + setErrMsg(data?.data?.message) + } + else { + setEmail(values?.email) + await setToLocalStorage(storageKeys.USER_EMAIL, values?.email) + setNextFlag(true) + setEnableName(true) + } } - else if (data.data.isEmailVerified === true && data?.data?.isRegistrationCompleted !== true) { - setEmail(values?.email) - await setToLocalStorage(storageKeys.USER_EMAIL, values?.email) - setNextFlag(true) - setEnableName(true) + else { + setEmail(values?.email) + await VerifyMail(values?.email) } - } else { - setErrMsg(userRsp as string) - } + } + else { + setErrMsg(data?.data?.message) + } } const redirectLandingPage = () => { diff --git a/src/components/Avatar/index.tsx b/src/components/Avatar/index.tsx index e350d5815..56769e866 100644 --- a/src/components/Avatar/index.tsx +++ b/src/components/Avatar/index.tsx @@ -1,6 +1,6 @@ -import React, { useState } from 'react' import * as Avatar from '@radix-ui/react-avatar'; +import { avatarColorPairs } from '../../config/CommonConstant'; type Props = { name?: string, @@ -16,36 +16,18 @@ interface ColorPair { background: string } +const getColorPair = (name: string): ColorPair => { + if (!name) return avatarColorPairs[0]; + const index = name + .split('') + .reduce((acc, char) => acc + char.charCodeAt(0), 0) % avatarColorPairs.length; + return avatarColorPairs[index]; +}; + +const CustomAvatar = ({ name, src, className, textSizeRatio = 2.5, round = false, size = '45px' }: Props): JSX.Element => { + const colorPair = name ? getColorPair(name) : avatarColorPairs[0]; + const fontSize = `calc(${size} / ${textSizeRatio})`; -const CustomAvatar = ({ name, src, className,textSizeRatio = 2.5, round=false, size}: Props): JSX.Element => { - const avatarColorPairs: ColorPair[] = [ - { - text: '#ea5455', - background: '#fceaea' - }, - { - text: '#b8b2f7', - background: '#eeecfe' - }, - { - text: '#c1c2c5', - background: '#f0f0f1' - }, - { - text: '#82ddaa', - background: '#e5f8ed' - }, - { - text: '#f4a651', - background: '#fdf3e8' - }, - { - text: '#76ddef', - background: '#e0f9fd' - } - ] - const [randomColor] = useState(avatarColorPairs[Math.floor(Math.random() * avatarColorPairs.length)]) - const fontSize = `calc(${size} / ${textSizeRatio})`; return ( {src ? ( -
- -
- ) : ( - {name?.split(' ').map(part => part[0]).join('').toUpperCase().slice(0,2)} + {name?.split(' ').map(part => part[0]).join('').toUpperCase().slice(0, 2)} )}
); -} +}; export default CustomAvatar; diff --git a/src/components/ConnectionsList/index.tsx b/src/components/ConnectionsList/index.tsx index eadaaf2c3..dc6505e5d 100644 --- a/src/components/ConnectionsList/index.tsx +++ b/src/components/ConnectionsList/index.tsx @@ -6,7 +6,7 @@ import { getConnectionsByOrg, } from '../../api/connection'; import type { IConnectionListAPIParameter } from '../../api/connection'; -import type { TableData } from '../../commonComponents/datatable/interface'; +import type { ITableData } from '../../commonComponents/datatable/interface'; import { apiStatusCodes, storageKeys } from '../../config/CommonConstant'; import { AlertComponent } from '../AlertComponent'; import { dateConversion } from '../../utils/DateConversion'; @@ -16,6 +16,7 @@ import { getFromLocalStorage } from '../../api/Auth'; import { getOrgDetails } from '../../config/ecosystem'; import type { IConnectionList } from '../../components/Issuance/interface'; import SortDataTable from '../../commonComponents/datatable/SortDataTable'; +import React from 'react'; const initialPageState = { itemPerPage: 10, @@ -27,7 +28,7 @@ const initialPageState = { }; const ConnectionList = () => { const [listAPIParameter, setListAPIParameter] = useState(initialPageState); - const [connectionList, setConnectionList] = useState([]); + const [connectionList, setConnectionList] = useState([]); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); const [totalItem, setTotalItem] = useState(0); diff --git a/src/components/Issuance/ConnectionList.tsx b/src/components/Issuance/ConnectionList.tsx index a0d60ee9c..dbb5d05b2 100644 --- a/src/components/Issuance/ConnectionList.tsx +++ b/src/components/Issuance/ConnectionList.tsx @@ -5,7 +5,7 @@ import type { ChangeEvent } from 'react'; import {getConnectionsByOrg, } from '../../api/connection'; import type {IConnectionListAPIParameter} from '../../api/connection' -import type { TableData } from '../../commonComponents/datatable/interface'; +import type { ITableData } from '../../commonComponents/datatable/interface'; import { apiStatusCodes, storageKeys } from '../../config/CommonConstant'; import { AlertComponent } from '../AlertComponent'; import { dateConversion } from '../../utils/DateConversion'; @@ -37,7 +37,7 @@ const ConnectionList = (props: { selectConnection: (connections: IConnectionList[]) => void; }) => { const [listAPIParameter, setListAPIParameter] = useState(initialPageState); - const [tableData, setTableData] = useState([]); + const [tableData, setTableData] = useState([]); const [connectionList, setConnectionList] = useState([]); const [localOrgs, setLocalOrgs] = useState([]); diff --git a/src/components/Issuance/Connections.tsx b/src/components/Issuance/Connections.tsx index 66604f93c..722e7abc1 100644 --- a/src/components/Issuance/Connections.tsx +++ b/src/components/Issuance/Connections.tsx @@ -3,7 +3,7 @@ import { Button } from 'flowbite-react'; import { useEffect, useState } from 'react'; import { getFromLocalStorage, setToLocalStorage } from '../../api/Auth'; import DataTable from '../../commonComponents/datatable'; -import type { TableData } from '../../commonComponents/datatable/interface'; +import type { ITableData } from '../../commonComponents/datatable/interface'; import { storageKeys } from '../../config/CommonConstant'; import { pathRoutes } from '../../config/pathRoutes'; import BreadCrumbs from '../BreadCrumbs'; @@ -17,7 +17,7 @@ import { DidMethod } from '../../common/enums'; const Connections = () => { const [selectedConnections, setSelectedConnections] = useState< - TableData[] + ITableData[] >([]); const selectedConnectionHeader = [ @@ -170,4 +170,4 @@ useEffect(() => { ); }; -export default Connections; +export default Connections; \ No newline at end of file diff --git a/src/components/Issuance/CredDefSelection.tsx b/src/components/Issuance/CredDefSelection.tsx index 9b531130c..2a2137482 100644 --- a/src/components/Issuance/CredDefSelection.tsx +++ b/src/components/Issuance/CredDefSelection.tsx @@ -11,7 +11,7 @@ import { Button } from 'flowbite-react'; import CustomSpinner from '../CustomSpinner'; import DataTable from '../../commonComponents/datatable'; import SchemaCard from '../../commonComponents/SchemaCard'; -import type { TableData } from '../../commonComponents/datatable/interface'; +import type { ITableData } from '../../commonComponents/datatable/interface'; import { dateConversion } from '../../utils/DateConversion'; import { getCredentialDefinitions } from '../../api/issuance'; import { pathRoutes } from '../../config/pathRoutes'; @@ -26,7 +26,7 @@ const CredDefSelection = () => { const [loading, setLoading] = useState(true); const [schemaLoader, setSchemaLoader] = useState(true); const [error, setError] = useState(null); - const [credDefList, setCredDefList] = useState([]); + const [credDefList, setCredDefList] = useState([]); const [schemaDetailsState, setSchemaDetailsState] = useState({ schemaId: '', issuerDid: '', diff --git a/src/components/Issuance/History.tsx b/src/components/Issuance/History.tsx index 8dff2b4e3..82557c3c0 100644 --- a/src/components/Issuance/History.tsx +++ b/src/components/Issuance/History.tsx @@ -2,7 +2,7 @@ import 'react-toastify/dist/ReactToastify.css'; import type { AxiosResponse } from 'axios'; import { useEffect, useState } from 'react'; import type { ChangeEvent } from 'react'; -import type { TableData } from '../../commonComponents/datatable/interface'; +import type { ITableData } from '../../commonComponents/datatable/interface'; import { apiStatusCodes } from '../../config/CommonConstant'; import { AlertComponent } from '../AlertComponent'; import { dateConversion } from '../../utils/DateConversion'; @@ -30,7 +30,7 @@ const HistoryBulkIssuance = () => { sortingOrder: 'desc', }; const [listAPIParameter, setListAPIParameter] = useState(initialPageState); - const [connectionList, setConnectionList] = useState([]); + const [connectionList, setConnectionList] = useState([]); const [loading, setLoading] = useState(true); const [failure, setFailure] = useState(null); const [success, setSuccess] = useState(null); diff --git a/src/components/Issuance/HistoryDetails.tsx b/src/components/Issuance/HistoryDetails.tsx index 08409f0b3..6e7cbba64 100644 --- a/src/components/Issuance/HistoryDetails.tsx +++ b/src/components/Issuance/HistoryDetails.tsx @@ -1,7 +1,7 @@ import { useEffect, useState } from 'react'; import type { ChangeEvent } from 'react'; -import type { TableData } from '../../commonComponents/datatable/interface'; +import type { ITableData } from '../../commonComponents/datatable/interface'; import { apiStatusCodes } from '../../config/CommonConstant'; import { AlertComponent } from '../AlertComponent'; import BreadCrumbs from '../BreadCrumbs'; @@ -27,7 +27,7 @@ const HistoryDetails = ({ requestId }: IProps) => { }; const [listAPIParameter, setListAPIParameter] = useState(initialPageState); - const [historyList, setHistoryList] = useState([]); + const [historyList, setHistoryList] = useState([]); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); const [totalItem, setTotalItem] = useState(0); diff --git a/src/components/Issuance/IssuedCrdentials.tsx b/src/components/Issuance/IssuedCrdentials.tsx index 95ebd77c0..cf2fde20e 100644 --- a/src/components/Issuance/IssuedCrdentials.tsx +++ b/src/components/Issuance/IssuedCrdentials.tsx @@ -9,7 +9,7 @@ import BreadCrumbs from '../BreadCrumbs'; import { Button, Pagination } from 'flowbite-react'; import DateTooltip from '../Tooltip'; import { EmptyListMessage } from '../EmptyListComponent'; -import type { TableData } from '../../commonComponents/datatable/interface'; +import type { ITableData } from '../../commonComponents/datatable/interface'; import { apiStatusCodes, storageKeys } from '../../config/CommonConstant'; import { dateConversion } from '../../utils/DateConversion'; import { getIssuedCredentials } from '../../api/issuance'; @@ -35,7 +35,7 @@ const initialPageState = { const CredentialList = () => { const [loading, setLoading] = useState(true); const [error, setError] = useState(null); - const [issuedCredList, setIssuedCredList] = useState([]); + const [issuedCredList, setIssuedCredList] = useState([]); const [walletCreated, setWalletCreated] = useState(false); const [listAPIParameter, setListAPIParameter] = useState(initialPageState); @@ -170,14 +170,15 @@ const CredentialList = () => { const response = await getOrganizationById(orgId); const { data } = response as AxiosResponse; if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) { - const did = data?.data?.org_agents?.[0]?.orgDid; - - await setToLocalStorage(storageKeys.ORG_DID, did) - if (did.includes(DidMethod.POLYGON) || did.includes(DidMethod.KEY) || did.includes(DidMethod.WEB)) { - setW3CSchema(true); - } - if (did.includes(DidMethod.INDY)) { - setW3CSchema(false); + const did = data?.data?.org_agents[0]?.orgDid; + if (did) { + await setToLocalStorage(storageKeys.ORG_DID, did) + if (did.includes(DidMethod.POLYGON) || did.includes(DidMethod.KEY) || did.includes(DidMethod.WEB)) { + setW3CSchema(true); + } + if (did.includes(DidMethod.INDY)) { + setW3CSchema(false); + } } } setLoading(false); diff --git a/src/components/Profile/DisplayProfileImg.tsx b/src/components/Profile/DisplayProfileImg.tsx index bebfd4d53..36e80fef8 100644 --- a/src/components/Profile/DisplayProfileImg.tsx +++ b/src/components/Profile/DisplayProfileImg.tsx @@ -11,8 +11,11 @@ const DisplayProfileImg = () => { const userProfile = await getFromLocalStorage(storageKeys.USER_PROFILE) const orgRoles = await getFromLocalStorage(storageKeys.ORG_ROLES) const parsedUser = userProfile ? JSON.parse(userProfile) : null; - parsedUser.roles = orgRoles - setUserObj(parsedUser) + + if (parsedUser) { + parsedUser.roles = orgRoles; + setUserObj(parsedUser); + } } useEffect(() => { diff --git a/src/components/Profile/DisplayUser.tsx b/src/components/Profile/DisplayUser.tsx index 83a704006..fbc238f09 100644 --- a/src/components/Profile/DisplayUser.tsx +++ b/src/components/Profile/DisplayUser.tsx @@ -13,8 +13,11 @@ const DisplayUser = () => { const userProfile = await getFromLocalStorage(storageKeys.USER_PROFILE) const orgRoles = await getFromLocalStorage(storageKeys.ORG_ROLES) const parsedUser = userProfile ? JSON.parse(userProfile) : null - parsedUser.roles = orgRoles - setUserObj(parsedUser) + + if (parsedUser) { + parsedUser.roles = orgRoles; + setUserObj(parsedUser); + } } useEffect(() => { const fetchData = async () => { @@ -39,10 +42,10 @@ const DisplayUser = () => { className="text-xl font-medium text-gray-900 truncate dark:text-gray-300 mb-1" role="none" > - {userObj['firstName']} + {userObj?.['firstName']}

- {userObj['email']} + {userObj?.['email']}

{ + { + schemaId, + attributes, + issuerDid, + created, + }: { + schemaId: string; + attributes: string[]; + issuerDid: string; + created: string; + }) => { const schemaDetails = { attribute: attributes, - issuerDid: issuerId, + issuerDid, createdDate: created, }; props.schemaSelectionCallback(schemaId, schemaDetails); diff --git a/src/components/SearchInput/index.tsx b/src/components/SearchInput/index.tsx index d2e48da5a..23a406ea9 100644 --- a/src/components/SearchInput/index.tsx +++ b/src/components/SearchInput/index.tsx @@ -1,4 +1,4 @@ -const SearchInput = ({ onInputChange, value }: any) => { +const SearchInput = ({ onInputChange, value = '' }: { onInputChange?: (e: React.ChangeEvent) => void; value?: string }) => { return (

diff --git a/src/components/User/UserDashBoard.tsx b/src/components/User/UserDashBoard.tsx index 5c6f5b547..ee3b53c97 100644 --- a/src/components/User/UserDashBoard.tsx +++ b/src/components/User/UserDashBoard.tsx @@ -273,15 +273,17 @@ const UserDashBoard = () => { const response = await getOrganizationById(orgId); const { data } = response as AxiosResponse; if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) { - const orgDid = data?.data?.org_agents[0].orgDid - if (data?.data?.org_agents) { + const orgAgentsList = data?.data?.org_agents; + if (orgAgentsList && orgAgentsList.length > 0) { + const orgDid = orgAgentsList[0].orgDid; setWalletData(data?.data?.org_agents); + + if(orgDid?.includes(DidMethod.INDY)){ + setIsW3C(false); + } } else { setWalletData([]); } - if(orgDid.includes(DidMethod.INDY)){ - setIsW3C(false); - } } setWalletLoading(false); }; diff --git a/src/components/Verification/ConnectionList.tsx b/src/components/Verification/ConnectionList.tsx index e40c1cb22..8fe68811d 100644 --- a/src/components/Verification/ConnectionList.tsx +++ b/src/components/Verification/ConnectionList.tsx @@ -6,13 +6,14 @@ import { getConnectionsByOrg, } from '../../api/connection'; import type { IConnectionListAPIParameter } from '../../api/connection'; -import type { TableData } from '../../commonComponents/datatable/interface'; -import { apiStatusCodes } from '../../config/CommonConstant'; +import type { ITableData } from '../../commonComponents/datatable/interface'; +import { apiStatusCodes, storageKeys } from '../../config/CommonConstant'; import { AlertComponent } from '../AlertComponent'; import { dateConversion } from '../../utils/DateConversion'; import DateTooltip from '../Tooltip'; import type { IConnectionList } from './interface'; import SortDataTable from '../../commonComponents/datatable/SortDataTable'; +import { getFromLocalStorage, removeFromLocalStorage, setToLocalStorage } from '../../api/Auth'; const initialPageState = { itemPerPage: 10, @@ -23,12 +24,21 @@ const initialPageState = { allSearch: '', }; +type LocalOrgs = { + connectionId: string; + theirLabel: string; + createDateTime: string; +}; + const ConnectionList = (props: { - selectConnection: (connections: TableData[]) => void; + selectConnection: (connections: IConnectionList[]) => void; }) => { - const [connectionList, setConnectionList] = useState([]); + const [connectionList, setConnectionList] = useState([]); + const [connectionsTableData, setConnectionsTableData] = useState([]); + const [localOrgs, setLocalOrgs] = useState([]); + const [selectedConnectionList, setSelectedConnectionList] = useState< - TableData[] + ITableData[] >([]); const [loading, setLoading] = useState(false); const [listAPIParameter, setListAPIParameter] = @@ -42,17 +52,17 @@ const ConnectionList = (props: { }); useEffect(() => { - let getData: NodeJS.Timeout; + let getConnectionsData: NodeJS.Timeout; if (listAPIParameter?.search?.length >= 1) { - getData = setTimeout(() => { + getConnectionsData = setTimeout(() => { getConnectionsVerification(listAPIParameter); }, 1000); - return () => clearTimeout(getData); + return () => clearTimeout(getConnectionsData); } else { getConnectionsVerification(listAPIParameter); } - return () => clearTimeout(getData); + return () => clearTimeout(getConnectionsData); }, [listAPIParameter]); const searchInputChange = (e: ChangeEvent) => { @@ -63,6 +73,154 @@ const ConnectionList = (props: { }); }; + const renderCheckbox = ( + ele: IConnectionList, + isChecked: boolean, + connections: IConnectionList[], + ) => { + return ( +
+ ) => { + const inputElement = event.target as HTMLInputElement; + + const updateConnectionList = connections.map((item) => { + if (item.connectionId === ele.connectionId) { + selectOrganization(item, inputElement.checked); + return { + ...item, + checked: inputElement.checked, + }; + } + return item; + }); + setConnectionList(updateConnectionList); + }} + className="w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded-lg dark:ring-offset-gray-800 dark:bg-gray-700 dark:border-gray-600 cursor-pointer" + /> +
+ ); + }; + +const extractConnectionFields = (item: IConnectionList) => { + const connectionId = item?.connectionId || 'Not available'; + const theirLabel = item?.theirLabel || 'Not available'; + const createDateTime = item?.createDateTime || 'Not available'; + return { connectionId, theirLabel, createDateTime }; + }; + + const isConnectionChecked = (connectionId: string) => + localOrgs.map((item) => item.connectionId).includes(connectionId); + + + const selectOrganization = async (item: IConnectionList, checked: boolean) => { + try { + const { connectionId, theirLabel, createDateTime } = extractConnectionFields(item); + const index = localOrgs?.findIndex((ele) => ele.connectionId === connectionId) ?? -1; + + if (index === -1) { + setLocalOrgs((prev: LocalOrgs[]) => [ + ...prev, + { connectionId, theirLabel, createDateTime }, + ]); + } else if (!checked) { + const updateLocalOrgs = [...localOrgs]; + updateLocalOrgs.splice(index, 1); + setLocalOrgs(updateLocalOrgs); + } + } catch (error) { + console.error('SELECTED ORGANIZATION:::', error); + } + }; + + + const generateTable = async (connections: IConnectionList[]) => { + try { + const connectionsData = + connections?.length > 0 && + connections.map((ele: IConnectionList) => { + const { connectionId, theirLabel, createDateTime } = extractConnectionFields(ele); + const isChecked = isConnectionChecked(connectionId); + + return { + data: [ + { data: renderCheckbox(ele, isChecked, connections) }, + { data: theirLabel }, + { data: connectionId }, + { + data: ( + + {dateConversion(createDateTime)} + + ), + }, + ], + }; + }); + + setConnectionsTableData(connectionsData); + } catch (err) { + console.error('Error generating table:', err); + } + }; + + useEffect(() => { + props.selectConnection(localOrgs); + }, [localOrgs]); + + + useEffect(() => { + generateTable(connectionList); + }, [connectionList, localOrgs]); + + const updateLocalOrgs = async () => { + const res = await getFromLocalStorage(storageKeys.SELECTED_CONNECTIONS); + const selectedOrg = res ? JSON.parse(res) : []; + setLocalOrgs(selectedOrg); + }; + + useEffect(() => { + const clearStorageAndRefresh = async () => { + refreshPage(); + await removeFromLocalStorage(storageKeys.SELECTED_CONNECTIONS); + await removeFromLocalStorage(storageKeys.SELECTED_USER); + }; + + clearStorageAndRefresh(); + }, []); + + useEffect(() => { + (async () => { + await setToLocalStorage( + storageKeys.SELECTED_CONNECTIONS, + JSON.stringify(localOrgs), + ); + })(); + }, [localOrgs]); + + + useEffect(() => { + let getConnectionsData: NodeJS.Timeout; + updateLocalOrgs(); + if (listAPIParameter?.search?.length >= 1) { + getConnectionsData = setTimeout(() => { + getConnectionsVerification(listAPIParameter); + }, 1000); + return () => clearTimeout(getConnectionsData); + } else { + getConnectionsVerification(listAPIParameter); + } + return () => clearTimeout(getConnectionsData); + }, [listAPIParameter]); + + useEffect(() => { + updateLocalOrgs(); + }, []); + const getConnectionsVerification = async ( apiParameter: IConnectionListAPIParameter, ) => { @@ -79,61 +237,8 @@ const ConnectionList = (props: { nextPage: nextPage, lastPage: lastPage, }); - const connections = data?.data?.data?.map( - (ele: IConnectionList) => { - const userName = ele?.theirLabel - ? ele?.theirLabel - : 'Not available'; - const connectionId = ele?.connectionId - ? ele?.connectionId - : 'Not available'; - const createdOn = ele?.createDateTime - ? ele?.createDateTime - : 'Not available'; - return { - data: [ - { - data: ( -
- , - ) => { - const inputElement = event.target as HTMLInputElement; - selectConnection( - userName, - connectionId, - inputElement.checked, - ); - }} - value="" - className="w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded-lg dark:ring-offset-gray-800 dark:bg-gray-700 dark:border-gray-600 cursor-pointer" - /> -
- ), - }, - { data: userName }, - { data: connectionId }, - { - data: ( - - {' '} - {dateConversion(createdOn)}{' '} - - ), - }, - ], - }; - }, - ); - - setConnectionList(connections); + const connectionsDataByOrgId = data?.data?.data + setConnectionList(connectionsDataByOrgId); setError(null); } else { setConnectionList([]); @@ -153,33 +258,6 @@ const ConnectionList = (props: { { columnName: 'Created on' }, ]; - const selectConnection = ( - user: string, - connectionId: string, - checked: boolean, - ) => { - if (checked) { - setSelectedConnectionList([ - { - data: [ - { - data: user, - }, - { - data: connectionId, - }, - ], - }, - ]); - } else { - setSelectedConnectionList((prevList) => - prevList.filter( - (connection) => connection?.data[1]?.data !== connectionId, - ), - ); - } - }; - const searchSortByValue = (value: any) => { setListAPIParameter({ ...listAPIParameter, @@ -199,10 +277,10 @@ const ConnectionList = (props: { props.selectConnection(selectedConnectionList); }, [selectedConnectionList]); + return (
{ @@ -243,6 +321,7 @@ const ConnectionList = (props: { message={'No Connections'} discription={"You don't have any connections yet"} > +
); }; diff --git a/src/components/Verification/Connections.tsx b/src/components/Verification/Connections.tsx index caba0be32..1c9a7a65f 100644 --- a/src/components/Verification/Connections.tsx +++ b/src/components/Verification/Connections.tsx @@ -1,48 +1,263 @@ -import { Button } from "flowbite-react"; +import { Alert, Button } from "flowbite-react"; import { useEffect, useState } from "react"; -import { getFromLocalStorage, setToLocalStorage } from "../../api/Auth"; +import { getFromLocalStorage, removeFromLocalStorage, setToLocalStorage } from "../../api/Auth"; import DataTable from "../../commonComponents/datatable"; -import type { TableData } from "../../commonComponents/datatable/interface"; -import { storageKeys } from "../../config/CommonConstant"; +import type { ITableData } from "../../commonComponents/datatable/interface"; +import { apiStatusCodes, storageKeys } from "../../config/CommonConstant"; import { pathRoutes } from "../../config/pathRoutes"; import BreadCrumbs from "../BreadCrumbs"; import ConnectionList from "./ConnectionList"; import EmailList from "./EmailList"; import BackButton from '../../commonComponents/backbutton' -import { DidMethod } from "../../common/enums"; +import { DidMethod, RequestType } from "../../common/enums"; +import React from "react"; +import type { IConnectionList } from "./interface"; +import DateTooltip from "../Tooltip"; +import { dateConversion } from "../../utils/DateConversion"; +import { verifyCredential, verifyCredentialV2 } from '../../api/verification'; +import type { AxiosResponse } from "axios"; +import { v4 as uuidv4 } from 'uuid'; +import { getOrganizationById } from "../../api/organization"; const Connections = () => { const [isW3cDid, setIsW3cDid] = useState(false); - const [selectedConnectionList, setSelectedConnectionList] = useState([]) + const [selectedConnectionList, setSelectedConnectionList] = useState([]) + const [proofReqSuccess, setProofReqSuccess] = useState(null); + const [errMsg, setErrMsg] = useState(null); + const [requestLoader, setRequestLoader] = useState(false); + + + const selectedConnectionHeader = [ { columnName: 'User' }, { columnName: 'Connection ID' }, + { columnName: 'Created on' } ] - const selectConnection = (connections: TableData[]) => { - setSelectedConnectionList(connections) - } - const fetchOrgData = async () => { - const orgDid = await getFromLocalStorage(storageKeys.ORG_DID); + const selectConnection = (connections: IConnectionList[]) => { - if (orgDid.includes(DidMethod.POLYGON) || orgDid.includes(DidMethod.KEY) || orgDid.includes(DidMethod.WEB)) { - setIsW3cDid(true); - } else { - setIsW3cDid(false); + try { + const connectionsData = connections?.length > 0 && connections?.map((ele: IConnectionList) => { + const createdOn = ele?.createDateTime + ? ele?.createDateTime + : 'Not available'; + const connectionId = ele.connectionId + ? ele.connectionId + : 'Not available'; + const userName = ele?.theirLabel ? ele.theirLabel : 'Not available'; + + return { + data: [ + { data: userName }, + { data: connectionId }, + { + data: ( + + {' '} + {dateConversion(createdOn)}{' '} + + ), + }, + ], + }; + }) + setSelectedConnectionList(connectionsData); + } catch (error) { + console.log("ERROR IN TABLE GENERATION::", error); } - }; - useEffect(() => { - fetchOrgData(); - }, []); - - const continueToVerify = async () => { - const selectedConnections = selectedConnectionList.map(ele =>{ - return {userName: ele.data[0].data, connectionId:ele.data[1].data} - }) - await setToLocalStorage(storageKeys.SELECTED_USER, selectedConnections) - window.location.href = isW3cDid ? `${pathRoutes.organizations.verification.W3CVerification}` : `${pathRoutes.organizations.verification.verify}` + }; + + const fetchOrganizationDetails = async () => { + try{ + const orgId = await getFromLocalStorage(storageKeys.ORG_ID); + if (!orgId) return; + const response = await getOrganizationById(orgId); + const { data } = response as AxiosResponse; + if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) { + const did = data?.data?.org_agents?.[0]?.orgDid; + + if (did?.includes(DidMethod.POLYGON)) { + setIsW3cDid(true); + + } + if (did?.includes(DidMethod.KEY) || did?.includes(DidMethod.WEB)) { + setIsW3cDid(true); + + + } + if (did?.includes(DidMethod.INDY)) { + setIsW3cDid(false); + + } + } + } catch(error){ + console.error('Error in getSchemaAndUsers:', error); + } + + }; + useEffect(() => { + fetchOrganizationDetails(); + return () => { + setRequestLoader(false); + }; + }, []); + + const handleSubmit = async () => { + setRequestLoader(true); + try { + + const selectedConnections = selectedConnectionList.map((ele) => ({ + userName: ele.data[0].data, + connectionId: ele.data[1].data, + })); + + await setToLocalStorage(storageKeys.SELECTED_USER, selectedConnections); + + const [attributeData, userData, orgId, attributes] = await Promise.all([ + getFromLocalStorage(storageKeys.ATTRIBUTE_DATA), + getFromLocalStorage(storageKeys.SELECTED_USER), + getFromLocalStorage(storageKeys.ORG_ID), + getFromLocalStorage(storageKeys.SCHEMA_ATTRIBUTES), + ]); + + const attr= JSON.parse(attributeData) + + const checkedAttributes = attr + .filter((attribute: any) => attribute.isChecked) + .map((attribute: any) => { + const basePayload = { + attributeName: attribute.attributeName, + credDefId: attribute.credDefId, + schemaId: attribute.schemaId, + }; + + if (attribute.dataType === "number" && attribute.selectedOption !== "Select") { + return { + ...basePayload, + condition: attribute.selectedOption, + value: attribute.value, + }; + } + if (attribute.dataType === "string") { + return basePayload; + } + + return basePayload; + }) + .filter((attr: any) => attr !== null); + + const checkedW3CAttributes = attr + .filter((w3cSchemaAttributes: any) => w3cSchemaAttributes.isChecked) + .map((attribute: any) => { + return { + attributeName: attribute.attributeName, + schemaId: attribute.schemaId, + schemaName:attribute.schemaName + + }; + }); + let verifyCredentialPayload; + + if (!isW3cDid) { + const parsedUserData = JSON.parse(userData); + const connectionIds = parsedUserData.map((connection: { connectionId: string | string[]; }) => connection.connectionId); + + verifyCredentialPayload = { + + connectionId: connectionIds.length === 1 ? connectionIds[0] : connectionIds, + orgId, + proofFormats: { + indy: { + attributes: checkedAttributes, + }, + }, + comment: "string" + }; + } + + + if (isW3cDid) { + const parsedUserData = JSON.parse(userData); + const connectionIds = parsedUserData.map((connection: { connectionId: string | string[] }) => connection.connectionId); + + const schemas = checkedW3CAttributes.map((attr: { schemaId: any; schemaName: any }) => ({ + schemaId: attr.schemaId, + schemaName: attr.schemaName, + })); + + const groupedAttributes = checkedW3CAttributes.reduce((acc: any, curr: any) => { + const schemaName = curr.schemaName; + if (!acc[schemaName]) { + acc[schemaName] = []; + } + acc[schemaName].push(curr); + return acc; + }, {}); + + + verifyCredentialPayload = { + + connectionId: connectionIds.length === 1 ? connectionIds[0] : connectionIds, + comment: 'proof request', + presentationDefinition: { + id: uuidv4(), + input_descriptors: Object.keys(groupedAttributes).map((schemaName) => { + const attributesForSchema = groupedAttributes[schemaName]; + + const attributePathsForSchema = attributesForSchema.map( + (attr: { attributeName: string }) => `$.credentialSubject['${attr.attributeName}']` + ); + + return { + id: uuidv4(), + name: schemaName, + schema: [ + { + uri: schemas.find((schema: { schemaName: string }) => schema.schemaName === schemaName)?.schemaId, + }, + ], + constraints: { + fields: [ + { + path: attributePathsForSchema, + }, + ], + }, + purpose: 'Verify proof', + }; + }), + }, + + } } + + if (attributes && verifyCredentialPayload ) { + const requestType = isW3cDid ? RequestType.PRESENTATION_EXCHANGE : RequestType.INDY; + let response; + if (typeof verifyCredentialPayload.connectionId === 'string') { + response = await verifyCredential(verifyCredentialPayload, requestType); + } else if (Array.isArray(verifyCredentialPayload.connectionId)) { + response = await verifyCredentialV2(verifyCredentialPayload, requestType); + } + + const { data } = response as AxiosResponse; + if (data?.statusCode === apiStatusCodes.API_STATUS_CREATED) { + await removeFromLocalStorage(storageKeys.ATTRIBUTE_DATA); + setProofReqSuccess(data?.message); + window.location.href = pathRoutes.organizations.credentials; + } else { + setErrMsg(response as string); + setRequestLoader(false); + } + } + } catch (error) { + setErrMsg('An error occurred. Please try again.'); + setRequestLoader(false); + } + + }; + return (
@@ -61,6 +276,19 @@ const Connections = () => {
+ {(proofReqSuccess || errMsg) && ( +
+ { + setProofReqSuccess(null); + setErrMsg(null); + }} + > + {proofReqSuccess || errMsg} + +
+ )}
@@ -72,19 +300,34 @@ const Connections = () => {
- + + + {selectedConnectionList.length ?
: ''} diff --git a/src/components/Verification/CredDefSelection.tsx b/src/components/Verification/CredDefSelection.tsx index 9fca2c9b3..c9b8960b8 100644 --- a/src/components/Verification/CredDefSelection.tsx +++ b/src/components/Verification/CredDefSelection.tsx @@ -9,18 +9,19 @@ import { pathRoutes } from "../../config/pathRoutes"; import BreadCrumbs from "../BreadCrumbs"; import { AlertComponent } from "../AlertComponent"; import type { SchemaState, CredDefData } from "./interface"; -import type { TableData } from "../../commonComponents/datatable/interface"; +import type { ITableData } from "../../commonComponents/datatable/interface"; import DataTable from "../../commonComponents/datatable"; import { getCredentialDefinitionsForVerification } from "../../api/verification"; import CustomSpinner from "../CustomSpinner"; import BackButton from '../../commonComponents/backbutton' +import React from "react"; const CredDefSelection = () => { const [schemaState, setSchemaState] = useState({ schemaName: '', version: '' }) const [loading, setLoading] = useState(true) const [schemaLoader, setSchemaLoader] = useState(true) const [error, setError] = useState(null) - const [credDefList, setCredDefList] = useState([]) + const [credDefList, setCredDefList] = useState([]) const [schemaDetailsState, setSchemaDetailsState] = useState({ schemaId: '', issuerDid: '', attributes: [], createdDateTime: '' }) useEffect(() => { diff --git a/src/components/Verification/EmailAttributesSelection.tsx b/src/components/Verification/EmailAttributesSelection.tsx index 070397062..f88eb9063 100644 --- a/src/components/Verification/EmailAttributesSelection.tsx +++ b/src/components/Verification/EmailAttributesSelection.tsx @@ -5,7 +5,7 @@ import { getFromLocalStorage, setToLocalStorage } from '../../api/Auth'; import { apiStatusCodes, predicatesConditions, storageKeys } from '../../config/CommonConstant'; import BreadCrumbs from '../BreadCrumbs'; import DataTable from '../../commonComponents/datatable'; -import type { TableData } from '../../commonComponents/datatable/interface'; +import type { ITableData } from '../../commonComponents/datatable/interface'; import { pathRoutes } from '../../config/pathRoutes'; import BackButton from '../../commonComponents/backbutton'; import type { @@ -15,9 +15,10 @@ import CustomCheckbox from '../../commonComponents/CustomCheckbox'; import { getOrganizationById } from '../../api/organization'; import type { AxiosResponse } from 'axios'; import { DidMethod } from '../../common/enums'; +import React from 'react'; const EmailAttributesSelection = () => { - const [attributeList, setAttributeList] = useState([]); + const [attributeList, setAttributeList] = useState([]); const [proofReqSuccess, setProofReqSuccess] = useState(null); const [errMsg, setErrMsg] = useState(null); const [display, setDisplay] = useState(false); @@ -26,6 +27,20 @@ const EmailAttributesSelection = () => { null, ); const [w3cSchema, setW3cSchema] = useState(false); + const [isConnectionProof, setIsConnectionProof] = useState(false); + + const ConnectionVerification = async () => { + const conn = await getFromLocalStorage(storageKeys.VERIFICATION_ROUTE_TYPE) + if(conn === 'Connection'){ + setIsConnectionProof(true) + }else{ + setIsConnectionProof(false) + } + } + useEffect(() => { + ConnectionVerification(); + }, []); + const handleAttributeChange = async ( attributeName: string, @@ -73,6 +88,7 @@ const EmailAttributesSelection = () => { const getOrgDetails = async () => { setLoading(true); + const orgId = await getFromLocalStorage(storageKeys.ORG_ID); const response = await getOrganizationById(orgId); const { data } = response as AxiosResponse; @@ -94,20 +110,25 @@ const EmailAttributesSelection = () => { }, []); - const handleSubmit = () => { - setErrMsg(null); - - if (w3cSchema) { + const handleSubmit = () => { + setErrMsg(null); + + if(isConnectionProof){ + redirectToConnections(); + return; + } + + if (w3cSchema ) { + redirectToAppropriatePage(); + return; + } + + if (hasInvalidNumberAttributes()) { + return; + } + redirectToAppropriatePage(); - return; - } - - if (hasInvalidNumberAttributes()) { - return; - } - - redirectToAppropriatePage(); - }; + }; const hasInvalidNumberAttributes = (): boolean => { const numberAttributes = attributeData?.filter( @@ -143,6 +164,12 @@ const EmailAttributesSelection = () => { ? `${pathRoutes.organizations.verification.w3cEmailVerification}` : `${pathRoutes.organizations.verification.emailVerification}`; }; + + const redirectToConnections = () => { + window.location.href = w3cSchema + ? `${pathRoutes.organizations.verification.W3CConnections}` + : `${pathRoutes.organizations.verification.connections}`; + } const loadAttributesData = async () => { diff --git a/src/components/Verification/EmailCredDefSelection.tsx b/src/components/Verification/EmailCredDefSelection.tsx index 9652e06fe..2412db48c 100644 --- a/src/components/Verification/EmailCredDefSelection.tsx +++ b/src/components/Verification/EmailCredDefSelection.tsx @@ -6,7 +6,7 @@ import { pathRoutes } from "../../config/pathRoutes"; import BreadCrumbs from "../BreadCrumbs"; import { AlertComponent } from "../AlertComponent"; import type { CredDefData } from "./interface"; -import type { TableData } from "../../commonComponents/datatable/interface"; +import type { ITableData } from "../../commonComponents/datatable/interface"; import DataTable from "../../commonComponents/datatable"; import { getCredentialDefinitionsForVerification } from "../../api/verification"; import BackButton from '../../commonComponents/backbutton'; @@ -18,7 +18,7 @@ import CustomCheckbox from "../../commonComponents/CustomCheckbox"; const EmailCredDefSelection = () => { const [loading, setLoading] = useState(true); const [error, setError] = useState(null); - const [credDefList, setCredDefList] = useState([]); + const [credDefList, setCredDefList] = useState([]); const [searchValue, setSearchValue] = useState(''); const [selectedCredDefs, setSelectedCredDefs] = useState([]); @@ -51,7 +51,7 @@ const EmailCredDefSelection = () => { const getCredDefs = async (schemaIds: string[]) => { setLoading(true); const orgId = await getFromLocalStorage(storageKeys.ORG_ID); - let allCredDefs: TableData[] = []; + let allCredDefs: ITableData[] = []; let rawCredDefs: CredDefData[] = []; for (const schemaId of schemaIds) { @@ -157,7 +157,7 @@ const EmailCredDefSelection = () => {

Credential-definition

- ) => setSearchValue(e.target.value)} /> + ) => setSearchValue(e.target.value)} />
diff --git a/src/components/Verification/EmailSchemaSelection.tsx b/src/components/Verification/EmailSchemaSelection.tsx index 4b78a4404..fb9569a19 100644 --- a/src/components/Verification/EmailSchemaSelection.tsx +++ b/src/components/Verification/EmailSchemaSelection.tsx @@ -1,9 +1,9 @@ +import React from "react"; import VerificationSchemasList from "./VerificationSchemasList"; -const EmailSchemaSelection = () => { - +const EmailSchemaSelection = ({ routeType }: { routeType: string }) => { return ( - + ) } diff --git a/src/components/Verification/Verification.tsx b/src/components/Verification/Verification.tsx index 0c4c420d7..bf5be947c 100644 --- a/src/components/Verification/Verification.tsx +++ b/src/components/Verification/Verification.tsx @@ -6,7 +6,7 @@ import { getFromLocalStorage } from '../../api/Auth'; import { apiStatusCodes, storageKeys } from '../../config/CommonConstant'; import BreadCrumbs from '../BreadCrumbs'; import DataTable from '../../commonComponents/datatable'; -import type { TableData } from '../../commonComponents/datatable/interface'; +import type { ITableData } from '../../commonComponents/datatable/interface'; import { verifyCredential } from '../../api/verification'; import { pathRoutes } from '../../config/pathRoutes'; import CustomSpinner from '../CustomSpinner'; @@ -25,7 +25,7 @@ import { getOrganizationById } from '../../api/organization'; import { DidMethod, RequestType } from '../../common/enums'; const VerificationCred = () => { - const [attributeList, setAttributeList] = useState([]); + const [attributeList, setAttributeList] = useState([]); const [proofReqSuccess, setProofReqSuccess] = useState(null); const [errMsg, setErrMsg] = useState(null); const [display, setDisplay] = useState(false); diff --git a/src/components/Verification/VerificationCredentialList.tsx b/src/components/Verification/VerificationCredentialList.tsx index 145d79c4c..53eb93276 100644 --- a/src/components/Verification/VerificationCredentialList.tsx +++ b/src/components/Verification/VerificationCredentialList.tsx @@ -21,7 +21,7 @@ import { Features } from '../../utils/enums/features'; import ProofRequest from './ProofRequestPopup'; import type { RequestProof } from './interface'; import RoleViewButton from '../RoleViewButton'; -import type { TableData } from '../../commonComponents/datatable/interface'; +import type { ITableData } from '../../commonComponents/datatable/interface'; import { dateConversion } from '../../utils/DateConversion'; import { pathRoutes } from '../../config/pathRoutes'; import { getFromLocalStorage } from '../../api/Auth'; @@ -40,7 +40,7 @@ const initialPageState = { const VerificationCredentialList = () => { const [loading, setLoading] = useState(true); - const [verificationList, setVerificationList] = useState([]); + const [verificationList, setVerificationList] = useState([]); const [openModal, setOpenModal] = useState(false); const [requestId, setRequestId] = useState(''); const [errMsg, setErrMsg] = useState(null); diff --git a/src/components/Verification/VerificationSchemasList.tsx b/src/components/Verification/VerificationSchemasList.tsx index 35a3d25cc..276814e5c 100644 --- a/src/components/Verification/VerificationSchemasList.tsx +++ b/src/components/Verification/VerificationSchemasList.tsx @@ -20,8 +20,8 @@ import { EmptyListMessage } from '../EmptyListComponent'; import SchemaCard from '../../commonComponents/SchemaCard'; import type { IAttributesDetails, ISchema, ISchemaData } from './interface'; -const VerificationSchemasList = () => { - const [schemasList, setSchemasList] = useState([]); +const VerificationSchemasList = ({ routeType }: { routeType: string }) => { +const [schemasList, setSchemasList] = useState([]); const [schemasDetailsErr, setSchemasDetailsErr] = useState(''); const [loading, setLoading] = useState(true); const [allSchemasFlag, setAllSchemasFlag] = useState(false); @@ -89,6 +89,13 @@ const VerificationSchemasList = () => { setLoading(false); } }; + const handleFlag = async () => { + try { + await setToLocalStorage(storageKeys.VERIFICATION_ROUTE_TYPE, routeType); + } catch (error) { + console.error('Error updating localStorage:', error); + } + }; useEffect(() => { getSchemaListDetails(); @@ -236,6 +243,7 @@ const VerificationSchemasList = () => { }; useEffect(() => { + handleFlag(); fetchOrganizationDetails(); (async () => { try { diff --git a/src/components/Verification/interface.ts b/src/components/Verification/interface.ts index 93561594d..174c6852f 100644 --- a/src/components/Verification/interface.ts +++ b/src/components/Verification/interface.ts @@ -50,13 +50,13 @@ export interface IProofRrquestDetails { view: boolean; userRoles?: string[]; } - export interface IConnectionList { theirLabel: string; connectionId: string; createDateTime: string; -} + checked?: boolean; +} export interface SchemaDetail { schemaName: string; version: string; diff --git a/src/config/CommonConstant.ts b/src/config/CommonConstant.ts index 9921c11d7..15b294275 100644 --- a/src/config/CommonConstant.ts +++ b/src/config/CommonConstant.ts @@ -54,6 +54,7 @@ export const storageKeys = { ALL_SCHEMAS:'allSchemaFlag', ECOSYSTEM_ID: "ecosystem_id", ECOSYSTEM_ROLE: "ecosystem_role", + VERIFICATION_ROUTE_TYPE:"routeType" } @@ -70,4 +71,31 @@ export const predicatesConditions = [ { value: '<', label: 'Less than' }, { value: '>=', label: 'Greater than or equal to' }, { value: '<=', label: 'Less than or equal to' } +] + +export const avatarColorPairs = [ + { + text: '#ea5455', + background: '#fceaea' + }, + { + text: '#b8b2f7', + background: '#eeecfe' + }, + { + text: '#c1c2c5', + background: '#f0f0f1' + }, + { + text: '#82ddaa', + background: '#e5f8ed' + }, + { + text: '#f4a651', + background: '#fdf3e8' + }, + { + text: '#76ddef', + background: '#e0f9fd' + } ] \ No newline at end of file diff --git a/src/config/GetHeaderConfigs.ts b/src/config/GetHeaderConfigs.ts index 0ec795542..0705732d2 100644 --- a/src/config/GetHeaderConfigs.ts +++ b/src/config/GetHeaderConfigs.ts @@ -1,8 +1,8 @@ import { getFromLocalStorage } from '../api/Auth'; import { storageKeys } from './CommonConstant'; -import { envConfig } from './envConfig'; -const allowedDomains = envConfig.PUBLIC_ALLOW_DOMAIN; +const allowedDomains = import.meta.env.PUBLIC_ALLOW_DOMAIN; + const commonHeaders = { 'Content-Security-Policy': `default-src 'self'; script-src 'unsafe-inline' ${allowedDomains}; style-src 'unsafe-inline' ${allowedDomains}; font-src ${allowedDomains}; img-src 'self' ${allowedDomains}; frame-src 'self' ${allowedDomains}; object-src 'none'; media-src 'self'; connect-src 'self' ${allowedDomains}; form-action 'self'; frame-ancestors 'self'; `, 'X-Frame-Options': "DENY", diff --git a/src/config/SocketConfig.ts b/src/config/SocketConfig.ts index 2a5eef880..e83269398 100644 --- a/src/config/SocketConfig.ts +++ b/src/config/SocketConfig.ts @@ -1,7 +1,7 @@ import { envConfig } from "./envConfig" import io from "socket.io-client" -const SOCKET = io(`${envConfig.PUBLIC_BASE_URL}`, { +const SOCKET = io(`${import.meta.env.PUBLIC_BASE_URL}`, { reconnection: true, reconnectionDelay: 500, reconnectionAttempts: Infinity, diff --git a/src/config/envConfig.ts b/src/config/envConfig.ts index a1e35d950..ce63bc549 100644 --- a/src/config/envConfig.ts +++ b/src/config/envConfig.ts @@ -17,7 +17,7 @@ if (import.meta.env) { } } -const { PUBLIC_BASE_URL, PUBLIC_ECOSYSTEM_FRONT_END_URL, PUBLIC_POLYGON_TESTNET_URL, PUBLIC_POLYGON_MAINNET_URL, PUBLIC_CRYPTO_PRIVATE_KEY,PUBLIC_SHOW_NAME_AS_LOGO, PUBLIC_PLATFORM_NAME, PUBLIC_PLATFORM_LOGO, PUBLIC_POWERED_BY, PUBLIC_PLATFORM_WEB_URL, PUBLIC_POWERED_BY_URL, PUBLIC_PLATFORM_DOCS_URL, PUBLIC_PLATFORM_GIT, PUBLIC_PLATFORM_SUPPORT_EMAIL, PUBLIC_PLATFORM_TWITTER_URL, PUBLIC_KEYCLOAK_MANAGEMENT_CLIENT_ID, PUBLIC_KEYCLOAK_MANAGEMENT_CLIENT_SECRET, PUBLIC_PLATFORM_SUPPORT_INVITE, PUBLIC_PLATFORM_DISCORD_URL, PUBLIC_ALLOW_DOMAIN, PUBLIC_ECOSYSTEM_BASE_URL, PUBLIC_MODE, PUBLIC_REDIRECT_FROM_URL, PUBLIC_REDIRECTION_TARGET_URL }: any = envVariables; +const { PUBLIC_BASE_URL, PUBLIC_ECOSYSTEM_FRONT_END_URL, PUBLIC_POLYGON_TESTNET_URL, PUBLIC_POLYGON_MAINNET_URL, PUBLIC_CRYPTO_PRIVATE_KEY,PUBLIC_SHOW_NAME_AS_LOGO, PUBLIC_PLATFORM_NAME, PUBLIC_PLATFORM_LOGO, PUBLIC_POWERED_BY, PUBLIC_PLATFORM_WEB_URL, PUBLIC_PLATFORM_DOCS_URL, PUBLIC_PLATFORM_GIT, PUBLIC_PLATFORM_TWITTER_URL, PUBLIC_KEYCLOAK_MANAGEMENT_CLIENT_ID, PUBLIC_KEYCLOAK_MANAGEMENT_CLIENT_SECRET, PUBLIC_PLATFROM_DISCORD_SUPPORT, PUBLIC_PLATFORM_DISCORD_URL, PUBLIC_ALLOW_DOMAIN, PUBLIC_ECOSYSTEM_BASE_URL, PUBLIC_MODE, PUBLIC_REDIRECT_FROM_URL, PUBLIC_REDIRECTION_TARGET_URL }: any = envVariables; export const envConfig = { PUBLIC_BASE_URL: @@ -48,18 +48,12 @@ export const envConfig = { webUrl: PUBLIC_PLATFORM_WEB_URL || import.meta.env.PUBLIC_PLATFORM_WEB_URL, - orgUrl: - PUBLIC_POWERED_BY_URL || - import.meta.env.PUBLIC_POWERED_BY_URL, docs: PUBLIC_PLATFORM_DOCS_URL || import.meta.env.PUBLIC_PLATFORM_DOCS_URL, git: PUBLIC_PLATFORM_GIT || import.meta.env.PUBLIC_PLATFORM_GIT, - support: - PUBLIC_PLATFORM_SUPPORT_EMAIL || - import.meta.env.PUBLIC_PLATFORM_SUPPORT_EMAIL, twitter: PUBLIC_PLATFORM_TWITTER_URL || import.meta.env.PUBLIC_PLATFORM_TWITTER_URL, @@ -74,7 +68,8 @@ export const envConfig = { import.meta.env.PUBLIC_KEYCLOAK_MANAGEMENT_CLIENT_SECRET, }, PUBLIC_ALLOW_DOMAIN: PUBLIC_ALLOW_DOMAIN || import.meta.env.PUBLIC_ALLOW_DOMAIN, - MODE: PUBLIC_MODE, + PUBLIC_PLATFROM_DISCORD_SUPPORT: PUBLIC_PLATFROM_DISCORD_SUPPORT || import.meta.env.PUBLIC_PLATFROM_DISCORD_SUPPORT, + MODE: PUBLIC_MODE || import.meta.env.PUBLIC_MODE, PUBLIC_REDIRECT_FROM_URL: PUBLIC_REDIRECT_FROM_URL || import.meta.env.PUBLIC_REDIRECT_FROM_URL, PUBLIC_REDIRECTION_TARGET_URL: PUBLIC_REDIRECTION_TARGET_URL || import.meta.env.PUBLIC_REDIRECTION_TARGET_URL } \ No newline at end of file diff --git a/src/config/ssrApiConfig.ts b/src/config/ssrApiConfig.ts index fba1e96a0..41563b67e 100644 --- a/src/config/ssrApiConfig.ts +++ b/src/config/ssrApiConfig.ts @@ -20,7 +20,7 @@ const API = async ({ token, url, method, payload }: IProps) => { method, body: JSON.stringify(payload), }; - const baseURL = globalThis.baseUrl || envConfig.PUBLIC_BASE_URL || process.env.PUBLIC_BASE_URL; + const baseURL = globalThis.baseUrl || import.meta.env.PUBLIC_BASE_URL || process.env.PUBLIC_BASE_URL; const apiURL = baseURL + url; const res = await fetch(apiURL, { ...config, diff --git a/src/env.d.ts b/src/env.d.ts index 0b6428c56..71169650d 100644 --- a/src/env.d.ts +++ b/src/env.d.ts @@ -5,6 +5,27 @@ interface ImportMetaEnv { readonly SITE: string; readonly PUBLIC_BASE_URL:string; + readonly PUBLIC_CRYPTO_PRIVATE_KEY: string; + readonly PUBLIC_REDIRECT_FROM_URL: string; + readonly PUBLIC_POLYGON_TESTNET_URL: string; + readonly PUBLIC_POLYGON_MAINNET_URL: string; + readonly PUBLIC_SHOW_NAME_AS_LOGO: string; + readonly PUBLIC_PLATFORM_NAME: string, + readonly PUBLIC_PLATFORM_LOGO: string, + readonly PUBLIC_POWERED_BY: string, + readonly PUBLIC_PLATFROM_DISCORD_SUPPORT: string, + readonly PUBLIC_PLATFORM_WEB_URL: string, + readonly PUBLIC_PLATFORM_DOCS_URL: string, + readonly PUBLIC_PLATFORM_GIT: string, + readonly PUBLIC_PLATFORM_TWITTER_URL: string, + readonly PUBLIC_KEYCLOAK_MANAGEMENT_CLIENT_ID: string, + readonly PUBLIC_KEYCLOAK_MANAGEMENT_CLIENT_SECRET: string, + readonly PUBLIC_PLATFORM_DISCORD_URL: string, + readonly PUBLIC_ALLOW_DOMAIN: string, + readonly PUBLIC_ECOSYSTEM_BASE_URL: string, + readonly PUBLIC_MODE: string, + readonly PUBLIC_REDIRECT_FROM_URL: string, + readonly PUBLIC_REDIRECTION_TARGET_URL: string } interface ImportMeta { diff --git a/src/middleware.ts b/src/middleware.ts index c73dc4a46..912c2929b 100644 --- a/src/middleware.ts +++ b/src/middleware.ts @@ -5,8 +5,8 @@ export const onRequest = async (context: any, next: any) => { const response = await next(); const html = await response.text(); - const domains = envConfig.PUBLIC_ALLOW_DOMAIN; - + const domains = import.meta.env.PUBLIC_ALLOW_DOMAIN; + const allowedDomain = `${context.url.origin} ${domains}` const nonce = "dynamicNONCE" + new Date().getTime().toString(); diff --git a/src/pages/index.astro b/src/pages/index.astro index ffd4f34d3..c3c67f72c 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -788,7 +788,10 @@ const env = import.meta.env || process.env; class="h-10 w-10 rounded-full bg-gray-100 text-gray-600 dark:bg-gray-600 dark:text-gray-300 sm:h-12 sm:w-12 lg:h-16 lg:w-16" /> -
+ class="dark:text:white hover:opacity-50" +1149 +  +
- + class="dark:text:white hover:opacity-50" +1149 +  +
- + - + \ No newline at end of file diff --git a/src/pages/organizations/verification/verify-credentials/schemas/index.astro b/src/pages/organizations/verification/verify-credentials/schemas/index.astro index efe0df627..9bfde5f4f 100644 --- a/src/pages/organizations/verification/verify-credentials/schemas/index.astro +++ b/src/pages/organizations/verification/verify-credentials/schemas/index.astro @@ -1,6 +1,6 @@ --- import LayoutSidebar from "../../../../../app/LayoutSidebar.astro"; -import SchemaSelection from "../../../../../components/Verification/SchemaSelection"; +import EmailSchemaSelection from "../../../../../components/Verification/EmailSchemaSelection"; import { pathRoutes } from "../../../../../config/pathRoutes"; import { checkUserSession } from "../../../../../utils/check-session"; @@ -13,5 +13,6 @@ if (!response.authorized) { --- - + + \ No newline at end of file diff --git a/src/pages/user/[user].astro b/src/pages/user/[user].astro index 09108b37d..8a4ac9738 100644 --- a/src/pages/user/[user].astro +++ b/src/pages/user/[user].astro @@ -1,6 +1,7 @@ --- import LogoFile from '../../commonComponents/LogoFile'; import CustomAvatar from '../../components/Avatar'; +import { envConfig } from '../../config/envConfig'; import { pathRoutes } from '../../config/pathRoutes'; const { user } = Astro.params; diff --git a/src/services/axiosIntercepter.ts b/src/services/axiosIntercepter.ts index 32b5a58ba..2708f2f30 100644 --- a/src/services/axiosIntercepter.ts +++ b/src/services/axiosIntercepter.ts @@ -6,17 +6,17 @@ import { getFromLocalStorage, setToLocalStorage } from '../api/Auth'; import { apiStatusCodes, storageKeys } from '../config/CommonConstant'; const instance = axios.create({ - baseURL: envConfig.PUBLIC_BASE_URL, + baseURL: import.meta.env.PUBLIC_BASE_URL, }); const EcosystemInstance = axios.create({ - baseURL: envConfig.PUBLIC_ECOSYSTEM_BASE_URL, + baseURL: import.meta.env.PUBLIC_ECOSYSTEM_BASE_URL, }); const checkAuthentication = async (sessionCookie: string, request: AxiosRequestConfig) => { const isAuthPage = window.location.href.includes('/authentication/sign-in') || window.location.href.includes('/authentication/sign-up') try { - const baseURL = envConfig.PUBLIC_BASE_URL || process.env.PUBLIC_BASE_URL; + const baseURL = import.meta.env.PUBLIC_BASE_URL || process.env.PUBLIC_BASE_URL; const config = { headers: { 'Content-Type': 'application/json', @@ -48,7 +48,7 @@ const checkAuthentication = async (sessionCookie: string, request: AxiosRequestC } } catch (error) { } }; -const { PUBLIC_BASE_URL, PUBLIC_ECOSYSTEM_BASE_URL }: any = globalThis +const { PUBLIC_BASE_URL, PUBLIC_ECOSYSTEM_BASE_URL }: any = import.meta.env instance.interceptors.request.use(async config => { config.baseURL = PUBLIC_BASE_URL; diff --git a/src/utils/check-session.ts b/src/utils/check-session.ts index 1a1a8537a..41a9f4bbc 100755 --- a/src/utils/check-session.ts +++ b/src/utils/check-session.ts @@ -33,7 +33,7 @@ export const checkUserSession = async ({ try { const baseURL = - envConfig.PUBLIC_BASE_URL || + import.meta.env.PUBLIC_BASE_URL || process.env.PUBLIC_BASE_URL; const config = { headers: {