Skip to content

Commit

Permalink
chore: rename funke to ausweis (#138)
Browse files Browse the repository at this point in the history
Signed-off-by: Berend Sliedrecht <[email protected]>
  • Loading branch information
berendsliedrecht authored Aug 14, 2024
1 parent d7d8db1 commit 66ee65d
Show file tree
Hide file tree
Showing 52 changed files with 97 additions and 66 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ The folder structure is as follows

- `apps` top level applications
- `paradym` Paradym Wallet - react native app for iOS & Android
- `funke` Funke Wallet - react native app for iOS & Android
- `ausweis` Ausweis Wallet - react native app for iOS & Android
- `packages` shared packages
- `ui` includes our custom UI kit that will be optimized by Tamagui
- `agent` includes the Aries Framework JavaScript (AFJ) agent and SSI capabilities
Expand Down
14 changes: 7 additions & 7 deletions apps/funke/app.config.js → apps/ausweis/app.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ const invitationSchemes = ['openid', 'openid-initiate-issuance', 'openid-credent
* @type {import('@expo/config-types').ExpoConfig}
*/
const config = {
name: `Funke Wallet${variant.name}`,
scheme: 'funke',
slug: 'funke-wallet',
name: `Ausweis Wallet ${variant.name}`,
scheme: 'ausweis-wallet',
slug: 'ausweis-wallet',
owner: 'animo-id',
version,
orientation: 'portrait',
Expand Down Expand Up @@ -74,10 +74,10 @@ const config = {
assetBundlePatterns: ['**/*'],
ios: {
supportsTablet: false,
bundleIdentifier: `id.animo.funke.wallet${variant.bundle}`,
bundleIdentifier: `id.animo.ausweis${variant.bundle}`,
infoPlist: {
NSCameraUsageDescription: 'Funke Wallet uses the camera to initiate receiving and sharing of credentials.',
NSFaceIDUsageDescription: 'Funke Wallet uses FaceID to securely unlock the wallet and share credentials.',
NSCameraUsageDescription: 'Ausweis Wallet uses the camera to initiate receiving and sharing of credentials.',
NSFaceIDUsageDescription: 'Ausweis Wallet uses FaceID to securely unlock the wallet and share credentials.',
ITSAppUsesNonExemptEncryption: false,
// Add schemes for deep linking
CFBundleURLTypes: [
Expand All @@ -92,7 +92,7 @@ const config = {
foregroundImage: './assets/adaptive-icon.png',
backgroundColor: '#FFFFFF',
},
package: `id.animo.funke.wallet${variant.bundle}`,
package: `id.animo.ausweis${variant.bundle}`,
intentFilters: [
...invitationSchemes.map((scheme) => ({
action: 'VIEW',
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion apps/funke/package.json → apps/ausweis/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "funke-wallet",
"name": "ausweis-wallet",
"version": "1.5.1",
"main": "expo-router/entry",
"private": true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { type FunkeAppAgent, useAgent } from '@package/agent'
import { type AusweisAppAgent, useAgent } from '@package/agent'
import { useSecureUnlock as _useSecureUnlock } from '@package/secure-store/secureUnlock'

export { initializeAppAgent } from './initialize'

export const useAppAgent = useAgent<FunkeAppAgent>
export type AppAgent = FunkeAppAgent
export const useAppAgent = useAgent<AusweisAppAgent>
export type AppAgent = AusweisAppAgent
export type SecureUnlockContext = { agent: AppAgent }

export const useSecureUnlock = () => _useSecureUnlock<SecureUnlockContext>()
12 changes: 12 additions & 0 deletions apps/ausweis/src/agent/initialize.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { trustedX509Certificates } from '@ausweis/constants'
import { initializeAusweisAgent } from '@package/agent'

export function initializeAppAgent({ walletKey }: { walletKey: string }) {
return initializeAusweisAgent({
keyDerivation: 'raw',
walletId: 'ausweis-wallet',
walletKey,
walletLabel: 'Ausweis Wallet',
trustedX509Certificates,
})
}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Redirect, Stack } from 'expo-router'

import { useSecureUnlock } from '@funke/agent'
import { useSecureUnlock } from '@ausweis/agent'
import { AgentProvider } from '@package/agent'
import { useResetWalletDevMenu } from '../../utils/resetWallet'

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Redirect } from 'expo-router'

import { initializeAppAgent, useSecureUnlock } from '@ausweis/agent'
import { WalletInvalidKeyError } from '@credo-ts/core'
import { initializeAppAgent, useSecureUnlock } from '@funke/agent'
import { FlexPage, HeroIcons, Paragraph, PinDotsInput, type PinDotsInputRef, Stack, YStack } from '@package/ui'
import * as SplashScreen from 'expo-splash-screen'
import { useEffect, useRef } from 'react'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { OnboardingContextProvider } from '@funke/features/onboarding'
import { OnboardingContextProvider } from '@ausweis/features/onboarding'
import { Slot } from 'expo-router'
import * as SplashScreen from 'expo-splash-screen'
import { useResetWalletDevMenu } from '../../utils/resetWallet'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useOnboardingContext } from '@funke/features/onboarding'
import { useOnboardingContext } from '@ausweis/features/onboarding'
import { FlexPage, OnboardingScreensHeader } from '@package/ui'
import Animated, { FadeInRight, FadeOutLeft } from 'react-native-reanimated'

Expand Down
4 changes: 2 additions & 2 deletions apps/funke/src/constants.ts → apps/ausweis/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const FUNKE_WALLET_SEED_CREDENTIAL_RECORD_ID = 'FUNKE_WALLET_SEED_CREDENTIAL_RECORD_ID '
export const FUNKE_WALLET_INSTANCE_LONG_TERM_AES_KEY_ID = 'FUNKE_WALLET_INSTANCE_LONG_TERM_AES_KEY_ID'
export const AUSWEIS_WALLET_SEED_CREDENTIAL_RECORD_ID = 'AUSWEIS_WALLET_SEED_CREDENTIAL_RECORD_ID'
export const AUSWEIS_WALLET_INSTANCE_LONG_TERM_AES_KEY_ID = 'AUSWEIS_WALLET_INSTANCE_LONG_TERM_AES_KEY_ID'

// https://demo.pid-issuer.bundesdruckerei.de
const bdrPidIssuerCertificate = `-----BEGIN CERTIFICATE-----
Expand Down
4 changes: 4 additions & 0 deletions apps/ausweis/src/crypto/aes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { AUSWEIS_WALLET_INSTANCE_LONG_TERM_AES_KEY_ID } from '@ausweis/constants'
import { aes128Gcm } from '@package/agent'

export const ausweisAes128Gcm = aes128Gcm(AUSWEIS_WALLET_INSTANCE_LONG_TERM_AES_KEY_ID)
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { type AgentContext, TypedArrayEncoder } from '@credo-ts/core'
import { Key, KeyAlgs, KeyMethod } from '@hyperledger/aries-askar-react-native'
import { kdf } from '@package/secure-store/kdf'
import { funkeAes128Gcm } from './aes'
import { ausweisAes128Gcm } from './aes'

/**
*
Expand All @@ -13,11 +13,11 @@ import { funkeAes128Gcm } from './aes'
*
*/
export const deriveKeypairFromPin = async (agentContext: AgentContext, pin: Array<number>) => {
if (!(await funkeAes128Gcm.aes128GcmHasKey({ agentContext }))) {
if (!(await ausweisAes128Gcm.aes128GcmHasKey({ agentContext }))) {
throw new Error('No AES key found in storage. Flow is called in an incorrect way!')
}

const pinSecret = await funkeAes128Gcm.aes128GcmEncrypt({
const pinSecret = await ausweisAes128Gcm.aes128GcmEncrypt({
agentContext,
data: new Uint8Array(pin),
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { sendCommand } from '@animo-id/expo-ausweis-sdk'
import type { SdJwtVcHeader } from '@credo-ts/core'
import { initializeAppAgent, useSecureUnlock } from '@funke/agent'
import { type AppAgent, initializeAppAgent, useSecureUnlock } from '@ausweis/agent'
import {
ReceivePidUseCase,
type ReceivePidUseCaseOptions,
type ReceivePidUseCaseState,
} from '@funke/use-cases/ReceivePidUseCase'
import { type FunkeAppAgent, storeCredential } from '@package/agent'
} from '@ausweis/use-cases/ReceivePidUseCase'
import type { SdJwtVcHeader } from '@credo-ts/core'
import { storeCredential } from '@package/agent'
import { useToastController } from '@package/ui'
import { capitalizeFirstLetter } from '@package/utils'
import { useRouter } from 'expo-router'
Expand All @@ -21,7 +21,14 @@ import { OnboardingIntroductionSteps } from './screens/introduction-steps'
import OnboardingPinEnter from './screens/pin'
import OnboardingWelcome from './screens/welcome'

type Page = { type: 'fullscreen' } | { type: 'content'; title: string; subtitle?: string; animationKey?: string }
type Page =
| { type: 'fullscreen' }
| {
type: 'content'
title: string
subtitle?: string
animationKey?: string
}

// Same animation key means the content won't fade out and then in again. So if the two screens have most content in common
// this looks nicer.
Expand Down Expand Up @@ -149,7 +156,10 @@ export const OnboardingContext = createContext<OnboardingContext>({} as Onboardi
export function OnboardingContextProvider({
initialStep,
children,
}: PropsWithChildren<{ initialStep?: OnboardingStep['step']; flow?: 'c' | 'bprime' }>) {
}: PropsWithChildren<{
initialStep?: OnboardingStep['step']
flow?: 'c' | 'bprime'
}>) {
const toast = useToastController()
const secureUnlock = useSecureUnlock()
const [currentStepName, setCurrentStepName] = useState<OnboardingStep['step']>(initialStep ?? 'welcome')
Expand All @@ -160,7 +170,7 @@ export function OnboardingContextProvider({
const [walletPin, setWalletPin] = useState<string>()
const [idCardPin, setIdCardPin] = useState<string>()
const [userName, setUserName] = useState<string>()
const [agent, setAgent] = useState<FunkeAppAgent>()
const [agent, setAgent] = useState<AppAgent>()

const currentStep = onboardingStepsCFlow.find((step) => step.step === currentStepName)
if (!currentStep) throw new Error(`Invalid step ${currentStepName}`)
Expand Down Expand Up @@ -209,7 +219,9 @@ export function OnboardingContextProvider({

const onPinReEnter = async (pin: string) => {
if (walletPin !== pin) {
toast.show('Pin entries do not match', { customData: { preset: 'danger' } })
toast.show('Pin entries do not match', {
customData: { preset: 'danger' },
})
setWalletPin(undefined)
goToPreviousStep()
throw new Error('Pin entries do not match')
Expand Down Expand Up @@ -251,7 +263,9 @@ export function OnboardingContextProvider({
})
// If we don't wait for a bit, it will render the keyboard and the nfc modal at the same time...
setTimeout(() => {
toast.show('Invalid PIN entered for eID Card. Please try again', { customData: { preset: 'danger' } })
toast.show('Invalid PIN entered for eID Card. Please try again', {
customData: { preset: 'danger' },
})
setCurrentStepName('id-card-pin')
}, 3000)
})
Expand All @@ -274,7 +288,10 @@ export function OnboardingContextProvider({
setIdCardPin(pin)

if (secureUnlock.state !== 'unlocked') {
reset({ error: 'onIdCardPinEnter: Secure unlock state is not unlocked', resetToStep: 'welcome' })
reset({
error: 'onIdCardPinEnter: Secure unlock state is not unlocked',
resetToStep: 'welcome',
})
throw new Error('onIdCardPinEnter: Secure unlock state is not unlocked')
}

Expand All @@ -298,7 +315,13 @@ export function OnboardingContextProvider({
return
}

const reset = ({ resetToStep = 'welcome', error }: { error?: unknown; resetToStep: OnboardingStep['step'] }) => {
const reset = ({
resetToStep = 'welcome',
error,
}: {
error?: unknown
resetToStep: OnboardingStep['step']
}) => {
if (error) console.error(error)

const stepsToCompleteAfterReset = onboardingStepsCFlow
Expand Down Expand Up @@ -339,13 +362,19 @@ export function OnboardingContextProvider({

const onStartScanning = async () => {
if (receivePidUseCase?.state !== 'id-card-auth') {
reset({ resetToStep: 'id-card-pin', error: 'onStartScanning: receivePidUseCaseState is not id-card-auth' })
reset({
resetToStep: 'id-card-pin',
error: 'onStartScanning: receivePidUseCaseState is not id-card-auth',
})
return
}

// FIXME: we should probably remove the database here.
if (secureUnlock.state !== 'unlocked') {
reset({ resetToStep: 'welcome', error: 'onStartScanning: secureUnlock.state is not unlocked' })
reset({
resetToStep: 'welcome',
error: 'onStartScanning: secureUnlock.state is not unlocked',
})
return
}

Expand All @@ -371,7 +400,9 @@ export function OnboardingContextProvider({
{ given_name: string; family_name: string }
>(credential.compactSdJwtVc)
setUserName(
`${capitalizeFirstLetter(parsed.prettyClaims.given_name.toLowerCase())} ${capitalizeFirstLetter(parsed.prettyClaims.family_name.toLowerCase())}`
`${capitalizeFirstLetter(parsed.prettyClaims.given_name.toLowerCase())} ${capitalizeFirstLetter(
parsed.prettyClaims.family_name.toLowerCase()
)}`
)
setCurrentStepName('id-card-complete')
} catch (error) {
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { AUSWEIS_WALLET_SEED_CREDENTIAL_RECORD_ID } from '@ausweis/constants'
import type { Agent } from '@credo-ts/core'
import { FUNKE_WALLET_SEED_CREDENTIAL_RECORD_ID } from '@funke/constants'
import { walletJsonStore } from '@package/agent'

export const seedCredentialStorage = {
store: async (agent: Agent, seedCredential: string) =>
walletJsonStore.store(agent, FUNKE_WALLET_SEED_CREDENTIAL_RECORD_ID, {
walletJsonStore.store(agent, AUSWEIS_WALLET_SEED_CREDENTIAL_RECORD_ID, {
seedCredential,
}),

update: async (agent: Agent, seedCredential: string) =>
walletJsonStore.update(agent, FUNKE_WALLET_SEED_CREDENTIAL_RECORD_ID, {
walletJsonStore.update(agent, AUSWEIS_WALLET_SEED_CREDENTIAL_RECORD_ID, {
seedCredential,
}),

getById: async (agent: Agent) =>
walletJsonStore.getById<{ seedCredential: string }>(agent, FUNKE_WALLET_SEED_CREDENTIAL_RECORD_ID),
walletJsonStore.getById<{ seedCredential: string }>(agent, AUSWEIS_WALLET_SEED_CREDENTIAL_RECORD_ID),
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AusweisAuthFlow, type AusweisAuthFlowOptions } from '@animo-id/expo-ausweis-sdk'
import type { AppAgent } from '@funke/agent'
import { pidSchemes } from '@funke/constants'
import type { AppAgent } from '@ausweis/agent'
import { pidSchemes } from '@ausweis/constants'
import {
type OpenId4VciRequestTokenResponse,
type OpenId4VciResolvedAuthorizationRequest,
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion apps/funke/tsconfig.json → apps/ausweis/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"compilerOptions": {
"rootDir": "./",
"paths": {
"@funke/*": ["./apps/funke/src/*"]
"@ausweis/*": ["./apps/ausweis/src/*"]
}
},
"include": ["./src/**/*.ts", "./src/**/*.tsx", "tamagui.config.ts"]
Expand Down
12 changes: 0 additions & 12 deletions apps/funke/src/agent/initialize.ts

This file was deleted.

4 changes: 0 additions & 4 deletions apps/funke/src/crypto/aes.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { OnboardingScreensHeader } from '@package/ui/src/components/OnboardingSc
import { useArgs } from '@storybook/addons'
import { IdCard } from './IdCard'

const germanIssuerImage = require('../../../funke/assets/german-issuer-image.png')
const germanIssuerImage = require('../../../ausweis/assets/german-issuer-image.png')

interface IdCardPinScreenProps {
pinLength: number
Expand Down
6 changes: 3 additions & 3 deletions packages/agent/src/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const askarModule = new AskarModule({
ariesAskar: ariesAskar,
})

export const initializeFunkeAgent = async ({
export const initializeAusweisAgent = async ({
walletLabel,
walletId,
walletKey,
Expand Down Expand Up @@ -200,8 +200,8 @@ export const initializeFullAgent = async ({
}

export type FullAppAgent = Awaited<ReturnType<typeof initializeFullAgent>>
export type FunkeAppAgent = Awaited<ReturnType<typeof initializeFunkeAgent>>
export type EitherAgent = FullAppAgent | FunkeAppAgent
export type AusweisAppAgent = Awaited<ReturnType<typeof initializeAusweisAgent>>
export type EitherAgent = FullAppAgent | AusweisAppAgent

// biome-ignore lint/suspicious/noExplicitAny: it just needs to extend any, it won't actually be used
export const useAgent = <A extends Agent<any> = FullAppAgent>(): {
Expand Down
4 changes: 2 additions & 2 deletions packages/agent/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ global.Buffer = Buffer

export {
initializeFullAgent,
initializeFunkeAgent,
initializeAusweisAgent,
useAgent,
FullAppAgent,
FunkeAppAgent,
AusweisAppAgent,
} from './agent'
export * from './providers'
export * from './invitation'
Expand Down
2 changes: 1 addition & 1 deletion pnpm-lock.yaml

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

2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"typeRoots": ["./types"],
"paths": {
"@package/*": ["./packages/*"],
"@funke/*": ["./apps/funke/src/*"],
"@ausweis/*": ["./apps/ausweis/src/*"],
"@paradym/*": ["./apps/paradym/*"]
}
},
Expand Down

0 comments on commit 66ee65d

Please sign in to comment.