Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
4d79910
feat: implement zcap login page
0marSalah Sep 5, 2025
fd7a581
feat: add react-qr-code dependency to package.json
0marSalah Sep 5, 2025
cb4fc01
feat: add @types/uuid dependency to package.json
0marSalah Sep 5, 2025
791e829
feat: add AppDidContext and provider for managing appDidSigner and zc…
0marSalah Sep 3, 2025
08789c6
feat: implement zCap storage utility functions for managing zCap in l…
0marSalah Sep 3, 2025
b569b8c
refactor: remove unused getWASFileUrl function from zcapStorage utility
0marSalah Sep 3, 2025
28e73fb
feat: implement local test for WAS upload functionality
0marSalah Sep 8, 2025
0f30d8b
chore: update testWasUpload.js with new capability details and proof …
0marSalah Sep 8, 2025
99a1921
feat: file upload functionality with WAS support and improve context…
0marSalah Sep 10, 2025
d55041a
refactor: update createZcapClient function to return any type for imp…
0marSalah Sep 10, 2025
6eebf75
refactor: clean up global type declarations and streamline appInstanc…
0marSalah Sep 22, 2025
2bd0ac9
Merge branch 'dev' into 411-store-evidence-filesimages-in-was
0marSalah Sep 22, 2025
253ba56
refactor: rename localStorage keys for zCap to 'delegatedWasZcap'
0marSalah Sep 22, 2025
9f52020
refactor: simplify condition in useHandleUpload by removing redundant…
0marSalah Sep 22, 2025
1405623
refactor: implement unified upload handling and introduce storage bac…
0marSalah Sep 22, 2025
56ee53f
feat: add @cooperation/vc-storage dependency to package.json
0marSalah Sep 22, 2025
1f0bb99
fix: update @digitalcredentials/ezcap version in package.json to remo…
0marSalah Sep 23, 2025
22b8314
chore: update @cooperation/vc-storage dependency version to ^1.0.42 i…
0marSalah Sep 23, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 30 additions & 27 deletions app/ClientLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { usePathname } from 'next/navigation'
import background from './Assets/Images/Background.svg'
import Providers from './components/signing/Providers'
import AppDidInitializer from './components/AppDidInitializer'
import { AppDidProvider } from './contexts/AppDidContext'

export default function ClientLayout({
children
Expand All @@ -28,33 +29,35 @@ export default function ClientLayout({
<ThemeProvider theme={Theme}>
<CssBaseline />
<Providers>
<StepProvider>
<NavBar />
<Box
component='main'
sx={{
flexGrow: 1,
minHeight: `calc(100vh - 315px)`,
backgroundImage: pathname === '/' ? `url(${background.src})` : 'none',
backgroundRepeat: 'no-repeat',
backgroundSize: 'cover',
backgroundPosition: 'center',
pb: '60px',
backgroundBlendMode: pathname === '/' ? 'overlay' : 'normal',
backgroundColor:
pathname === '/'
? {
xs: 'rgba(255, 255, 255, 0.8)',
md: 'rgba(255, 255, 255, 0.85)'
}
: '#F0F4F8'
}}
>
<AppDidInitializer />
{children}
</Box>
<Footer />
</StepProvider>
<AppDidProvider>
<StepProvider>
<NavBar />
<Box
component='main'
sx={{
flexGrow: 1,
minHeight: `calc(100vh - 315px)`,
backgroundImage: pathname === '/' ? `url(${background.src})` : 'none',
backgroundRepeat: 'no-repeat',
backgroundSize: 'cover',
backgroundPosition: 'center',
pb: '60px',
backgroundBlendMode: pathname === '/' ? 'overlay' : 'normal',
backgroundColor:
pathname === '/'
? {
xs: 'rgba(255, 255, 255, 0.8)',
md: 'rgba(255, 255, 255, 0.85)'
}
: '#F0F4F8'
}}
>
<AppDidInitializer />
{children}
</Box>
<Footer />
</StepProvider>
</AppDidProvider>
</Providers>
</ThemeProvider>
</body>
Expand Down
59 changes: 59 additions & 0 deletions app/contexts/AppDidContext.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
'use client'

import React, { createContext, useContext, useState, useEffect, ReactNode } from 'react'

interface AppDidContextType {
appInstanceDid: any
hasZcap: boolean
zcapInfo: any
}

const AppDidContext = createContext<AppDidContextType | undefined>(undefined)

interface AppDidProviderProps {
children: ReactNode
}

export function AppDidProvider({ children }: AppDidProviderProps) {
const [zcapInfo, setZcapInfo] = useState<any>(null)
const [appInstanceDid, setAppInstanceDid] = useState<any>(null)

useEffect(() => {
// Check for stored zCap on mount
const storedZcap = localStorage.getItem('delegatedWasZcap')
const storedAppInstanceDid = localStorage.getItem('AppInstanceDID')
if (storedZcap) {
setZcapInfo(storedZcap)
}
if (storedAppInstanceDid) {
try {
const appInstanceDidObject = JSON.parse(storedAppInstanceDid)
setAppInstanceDid(appInstanceDidObject)
} catch (error) {
console.error('Error parsing stored AppInstanceDID:', error)
}
}
}, [])

const hasZcap = !!zcapInfo

const value: AppDidContextType = {
appInstanceDid,
hasZcap,
zcapInfo,
}

return (
<AppDidContext.Provider value={value}>
{children}
</AppDidContext.Provider>
)
}

export function useAppDid() {
const context = useContext(AppDidContext)
if (context === undefined) {
throw new Error('useAppDid must be used within an AppDidProvider')
}
return context
}
14 changes: 11 additions & 3 deletions app/credentialForm/form/StepContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const StepContext = createContext<StepContextType>({
handleNext: async () => {},
handleBack: () => {},
handleSkip: () => {},
setUploadImageFn: () => () => {}
setUploadImageFn: (_fn: () => Promise<void>) => {}
})

export const StepProvider = ({ children }: { children: React.ReactNode }) => {
Expand Down Expand Up @@ -116,17 +116,25 @@ export const StepProvider = ({ children }: { children: React.ReactNode }) => {
setActiveStep(prevStep => prevStep + 1)
}, [])

// Ensure passing function as value, not as state updater
const setUploadImageFnSafe = useCallback(
(fn: () => Promise<void>) => {
setUploadImageFn(() => fn)
},
[]
)

const contextValue = useMemo(
() => ({
activeStep,
setActiveStep,
handleNext,
handleBack,
setUploadImageFn,
setUploadImageFn: setUploadImageFnSafe,
loading,
handleSkip
}),
[activeStep, handleNext, handleBack, setUploadImageFn, loading, handleSkip]
[activeStep, handleNext, handleBack, setUploadImageFnSafe, loading, handleSkip]
)

return <StepContext.Provider value={contextValue}>{children}</StepContext.Provider>
Expand Down
Loading