Skip to content

Commit

Permalink
Merge branch 'main' into feat/ai-overasking
Browse files Browse the repository at this point in the history
  • Loading branch information
janrtvld committed Nov 26, 2024
2 parents d1f4ec2 + 03cecfb commit 04a26cf
Show file tree
Hide file tree
Showing 35 changed files with 676 additions and 567 deletions.
3 changes: 2 additions & 1 deletion apps/easypid/eas.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"autoIncrement": true,
"distribution": "store",
"android": {
"buildType": "app-bundle"
"buildType": "app-bundle",
"resourceClass": "large"
}
}
},
Expand Down
1 change: 1 addition & 0 deletions apps/easypid/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
import 'fast-text-encoding'
import 'expo-router/entry'
3 changes: 2 additions & 1 deletion apps/easypid/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"@animo-id/expo-ausweis-sdk": "catalog:",
"@animo-id/expo-mdoc-data-transfer": "catalog:",
"@animo-id/expo-secure-environment": "catalog:",
"@animo-id/mdoc": "catalog:",
"@credo-ts/core": "catalog:",
"@expo-google-fonts/open-sans": "^0.2.3",
"@expo-google-fonts/raleway": "^0.2.3",
Expand All @@ -26,7 +27,6 @@
"@package/secure-store": "workspace:*",
"@package/ui": "workspace:*",
"@package/utils": "workspace:*",
"@animo-id/mdoc": "catalog:",
"@react-native-community/blur": "^4.3.2",
"@react-native-community/netinfo": "11.3.1",
"@react-native-masked-view/masked-view": "0.3.1",
Expand All @@ -51,6 +51,7 @@
"expo-system-ui": "~3.0.6",
"expo-updates": "~0.25.16",
"expo-web-browser": "~13.0.3",
"fast-text-encoding": "^1.0.6",
"react": "catalog:",
"react-native": "catalog:",
"react-native-argon2": "^2.0.1",
Expand Down
99 changes: 49 additions & 50 deletions apps/easypid/src/app/(app)/_layout.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Redirect, Stack, useGlobalSearchParams, useLocalSearchParams, usePathname, useRouter } from 'expo-router'
import { Redirect, Stack, useGlobalSearchParams, usePathname, useRouter } from 'expo-router'

import { TypedArrayEncoder } from '@credo-ts/core'
import { useSecureUnlock } from '@easypid/agent'
Expand All @@ -10,7 +10,6 @@ import { type CredentialDataHandlerOptions, DeeplinkHandler, useHaptics } from '
import { HeroIcons, IconContainer } from '@package/ui'
import { useEffect, useState } from 'react'
import { useTheme } from 'tamagui'
import { WithBackgroundPidRefresh } from '../../features/pid/WithBackPidRefresh'

const jsonRecordIds = [activityStorage.recordId]

Expand All @@ -32,17 +31,19 @@ export default function AppLayout() {
// It could be that the onboarding is cut of mid-process, and e.g. the user closes the app
// if this is the case we will redo the onboarding
const [hasFinishedOnboarding] = useHasFinishedOnboarding()
const [resetWalletState, setResetWalletState] = useState<'resetting' | 'reset'>()
const [hasResetWallet, setHasResetWallet] = useState(false)
const shouldResetWallet =
secureUnlock.state !== 'not-configured' && secureUnlock.state !== 'initializing' && !hasFinishedOnboarding
const isWalletLocked = secureUnlock.state === 'locked' || secureUnlock.state === 'acquired-wallet-key'

useEffect(() => {
if (resetWalletState || !shouldResetWallet) return
// Reset state
if (hasResetWallet && !shouldResetWallet) setHasResetWallet(false)
if (!shouldResetWallet || hasResetWallet) return

setResetWalletState('resetting')
resetWallet(secureUnlock).then(() => setResetWalletState('reset'))
}, [secureUnlock, resetWalletState, shouldResetWallet])
setHasResetWallet(true)
resetWallet(secureUnlock)
}, [secureUnlock, hasResetWallet, shouldResetWallet])

// If we are intializing and the wallet was opened using a deeplinkg we will be redirected
// to the authentication screen. We first save the redirection url and use that when navigation
Expand All @@ -66,7 +67,7 @@ export default function AppLayout() {
}

// This should show the splash screen
if (secureUnlock.state === 'initializing' || (shouldResetWallet && resetWalletState !== 'reset')) {
if (secureUnlock.state === 'initializing' || shouldResetWallet) {
return null
}

Expand Down Expand Up @@ -97,48 +98,46 @@ export default function AppLayout() {
return (
<AgentProvider agent={secureUnlock.context.agent}>
<WalletJsonStoreProvider agent={secureUnlock.context.agent} recordIds={jsonRecordIds}>
<WithBackgroundPidRefresh>
<Stack screenOptions={{ headerShown: false }}>
<Stack.Screen
options={{
presentation: 'modal',
}}
name="(home)/scan"
/>
<Stack.Screen
name="notifications/openIdPresentation"
options={{
gestureEnabled: false,
}}
/>
<Stack.Screen
name="notifications/openIdCredential"
options={{
gestureEnabled: false,
}}
/>
<Stack.Screen
name="notifications/offlinePresentation"
options={{
gestureEnabled: false,
}}
/>
<Stack.Screen name="credentials/index" options={headerNormalOptions} />
<Stack.Screen name="credentials/[id]/index" options={headerNormalOptions} />
<Stack.Screen name="credentials/[id]/attributes" options={headerNormalOptions} />
<Stack.Screen name="credentials/requestedAttributes" options={headerNormalOptions} />
<Stack.Screen name="menu/index" options={headerNormalOptions} />
<Stack.Screen name="menu/feedback" options={headerNormalOptions} />
<Stack.Screen name="menu/settings" options={headerNormalOptions} />
<Stack.Screen name="menu/about" options={headerNormalOptions} />
<Stack.Screen name="activity/index" options={headerNormalOptions} />
<Stack.Screen name="activity/[id]" options={headerNormalOptions} />
<Stack.Screen name="pinConfirmation" options={headerNormalOptions} />
<Stack.Screen name="pinLocked" options={headerNormalOptions} />
<Stack.Screen name="issuer" options={headerNormalOptions} />
<Stack.Screen name="pidSetup" />
</Stack>
</WithBackgroundPidRefresh>
<Stack screenOptions={{ headerShown: false }}>
<Stack.Screen
options={{
presentation: 'modal',
}}
name="(home)/scan"
/>
<Stack.Screen
name="notifications/openIdPresentation"
options={{
gestureEnabled: false,
}}
/>
<Stack.Screen
name="notifications/openIdCredential"
options={{
gestureEnabled: false,
}}
/>
<Stack.Screen
name="notifications/offlinePresentation"
options={{
gestureEnabled: false,
}}
/>
<Stack.Screen name="credentials/index" options={headerNormalOptions} />
<Stack.Screen name="credentials/[id]/index" options={headerNormalOptions} />
<Stack.Screen name="credentials/[id]/attributes" options={headerNormalOptions} />
<Stack.Screen name="credentials/requestedAttributes" options={headerNormalOptions} />
<Stack.Screen name="menu/index" options={headerNormalOptions} />
<Stack.Screen name="menu/feedback" options={headerNormalOptions} />
<Stack.Screen name="menu/settings" options={headerNormalOptions} />
<Stack.Screen name="menu/about" options={headerNormalOptions} />
<Stack.Screen name="activity/index" options={headerNormalOptions} />
<Stack.Screen name="activity/[id]" options={headerNormalOptions} />
<Stack.Screen name="pinConfirmation" options={headerNormalOptions} />
<Stack.Screen name="pinLocked" options={headerNormalOptions} />
<Stack.Screen name="federation" options={headerNormalOptions} />
<Stack.Screen name="pidSetup" />
</Stack>
</WalletJsonStoreProvider>
</AgentProvider>
)
Expand Down
18 changes: 18 additions & 0 deletions apps/easypid/src/app/(app)/federation.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { FunkeFederationDetailScreen } from '@easypid/features/wallet/FunkeFederationDetailScreen'
import type { TrustedEntity } from '@package/agent'
import { useLocalSearchParams } from 'expo-router'

export default function Screen() {
const { entityId, trustedEntities, name, logo } = useLocalSearchParams()

const trustedEntitiesArray = JSON.parse(decodeURIComponent(trustedEntities as string)) as Array<TrustedEntity>

return (
<FunkeFederationDetailScreen
entityId={entityId as string}
trustedEntities={trustedEntitiesArray}
name={name as string}
logo={logo as string}
/>
)
}
8 changes: 0 additions & 8 deletions apps/easypid/src/app/(app)/issuer.tsx

This file was deleted.

2 changes: 2 additions & 0 deletions apps/easypid/src/app/+native-intent.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'fast-text-encoding'

import { parseInvitationUrl } from '@package/agent'
import { deeplinkSchemes } from '@package/app'
import * as Haptics from 'expo-haptics'
Expand Down
2 changes: 2 additions & 0 deletions apps/easypid/src/app/_layout.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'fast-text-encoding'

import { BackgroundLockProvider, NoInternetToastProvider, Provider, useTransparentNavigationBar } from '@package/app'
import { SecureUnlockProvider } from '@package/secure-store/secureUnlock'
import { DefaultTheme, ThemeProvider } from '@react-navigation/native'
Expand Down
6 changes: 5 additions & 1 deletion apps/easypid/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@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kwJwYDVQQDDCBpc3N1YW5jZS5nZW1laW5kZS1tdXN0ZXJzdGFkdC5kZTErMCkGCSqGSIb3DQEJARYcdGVzdEBnZW1laW5kZS1tdXN0ZXJzdGFkdC5kZTBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABDYXt8M+5E1ADj5N2Rv/zIwBlvkTlt3gsscrKP4owg6km9Ejv5bHqDWY+nQi29ezNH2tkhGrKe0ZsmeH9ZqUsI+jITAfMB0GA1UdDgQWBBRSW2AGYj1dJ5Nz84/XojDDjH00XzAKBggqhkjOPQQDAgNIADBFAiBJ7ohG3x9iBlbTeSLnJGTFdwfw10mM9sd1J/TpoijcfAIhALgJgE/w3/J7jJMvZq+EiUT8DkhKTTUNhN74uA+bL4v6'

export const trustedX509Certificates = [
ubiqueIssuer,
bdrPidIssuerCertificate,
animoFunkeRelyingPartyCertificate,
ubiqueRootCertificate,
oldAnimoFunkeRelyingPartyCertificate,
'MIIBKDCBzqADAgECAhAyWHL4SEss2wMO1QQybg/fMAoGCCqGSM49BAMCMA0xCzAJBgNVBAYTAk5MMB4XDTcwMDEwMTAwMDAwMFoXDTI1MTEyMjA4MjIxMlowDTELMAkGA1UEBhMCTkwwOTATBgcqhkjOPQIBBggqhkjOPQMBBwMiAALcD1XzKepFxWMAOqV+ln1fybBt7DRO5CV0f9A6mRp2xaMwMC4wLAYDVR0RBCUwI4IhMDRkNy0yMTctMTIzLTE4LTI2Lm5ncm9rLWZyZWUuYXBwMAoGCCqGSM49BAMCA0kAMEYCIQDWjkAm/iLhGWcgKILW48f43vEUByvJd2R4lxdTdK9w+wIhALcZIgrH2h9SoXHjuI9ktOMbfVHxt59iq+lOKsC4yOUQ',
'MIIBJzCBz6ADAgECAhA0WLLsSm0Hf5R2/q7neHUKMAoGCCqGSM49BAMCMA0xCzAJBgNVBAYTAk5MMB4XDTcwMDEwMTAwMDAwMFoXDTI1MTEyMjA4MjIxMlowDTELMAkGA1UEBhMCTkwwOTATBgcqhkjOPQIBBggqhkjOPQMBBwMiAALcD1XzKepFxWMAOqV+ln1fybBt7DRO5CV0f9A6mRp2xaMxMC8wLQYDVR0RBCYwJIIiNGFjNS0xMDktMzctMTUwLTE5OC5uZ3Jvay1mcmVlLmFwcDAKBggqhkjOPQQDAgNHADBEAiAEqDL6WHBelM4YW3L0k2criU+Za/FlDEuAJKuY+LiY/AIgR0qGuW9qu4wUo/kcJ75mv+jAwV25ABmYAnbUX/7u5lI=',
]

// https://gitlab.opencode.de/bmi/eudi-wallet/eidas-2.0-architekturkonzept/-/blob/main/architecture-proposal.md#pid-contents
Expand Down
9 changes: 0 additions & 9 deletions apps/easypid/src/features/pid/WithBackPidRefresh.tsx

This file was deleted.

27 changes: 22 additions & 5 deletions apps/easypid/src/features/proximity/mdocProximity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
import { TypedArrayEncoder } from '@credo-ts/core'
import { getMdocContext } from '@credo-ts/core/build/modules/mdoc/MdocContext'
import type { EasyPIDAppAgent, FormattedSubmission, MdocRecord } from '@package/agent'
import { handleBatchCredential } from '@package/agent/src/batch'
import { type Permission, PermissionsAndroid, Platform } from 'react-native'

const requireMdocDataTransfer = () =>
Expand Down Expand Up @@ -47,6 +48,7 @@ export const checkMdocPermissions = async () => {

export const getMdocQrCode = async () => {
const mdt = requireMdocDataTransfer().mdocDataTransfer.instance()
mdt.enableNfc()
const qrData = await mdt.startQrEngagement()
return qrData
}
Expand Down Expand Up @@ -82,12 +84,22 @@ export const shareDeviceResponse = async (options: ShareDeviceResponseOptions) =
throw new Error('Not all requirements are satisfied')
}

const issuerSignedDocuments = options.submission.entries.map((e) => {
if (!e.isSatisfied) throw new Error(`Requirement for doctype ${e.inputDescriptorId} not satisfied`)
if (options.submission.entries.length > 1) {
throw new Error('Only one mdoc supported at the moment due to only being able to sign with one device key')
}

const issuerSignedDocuments = await Promise.all(
options.submission.entries.map(async (e) => {
if (!e.isSatisfied) throw new Error(`Requirement for doctype ${e.inputDescriptorId} not satisfied`)

const credential = e.credentials[0].credential.record as MdocRecord

const credential = e.credentials[0].credential.record as MdocRecord
return parseIssuerSigned(TypedArrayEncoder.fromBase64(credential.base64Url), credential.getTags().docType)
})
// Optionally handle batch issuance
const credentialRecord = await handleBatchCredential(options.agent, credential)

return parseIssuerSigned(TypedArrayEncoder.fromBase64(credentialRecord.base64Url), credential.getTags().docType)
})
)

const mdoc = new MDoc(issuerSignedDocuments)

Expand Down Expand Up @@ -118,3 +130,8 @@ export const shareDeviceResponse = async (options: ShareDeviceResponseOptions) =

await mdt.sendDeviceResponse(deviceResponse.encode())
}

export const shutdownDataTransfer = () => {
const mdt = requireMdocDataTransfer().mdocDataTransfer.instance()
mdt.shutdown()
}
Loading

0 comments on commit 04a26cf

Please sign in to comment.