-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into feat/funke-receive-pid
- Loading branch information
Showing
75 changed files
with
4,726 additions
and
3,980 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -100,6 +100,6 @@ android | |
|
||
# build output | ||
dist/ | ||
types/ | ||
packages/ui/types | ||
|
||
storybook-static | ||
storybook-static |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { type FunkeAppAgent, 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 useSecureUnlock = () => _useSecureUnlock<{ agent?: AppAgent }>() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { initializeFunkeAgent } from '@package/agent' | ||
import { trustedCertificates } from '../constants' | ||
|
||
export function initializeAppAgent({ walletKey }: { walletKey: string }) { | ||
return initializeFunkeAgent({ | ||
keyDerivation: 'raw', | ||
walletId: 'funke-wallet', | ||
walletKey: walletKey, | ||
walletLabel: 'Funke Wallet', | ||
trustedX509Certificates: trustedCertificates, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import ExpoConstants from 'expo-constants' | ||
|
||
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' | ||
|
||
const TRUSTED_CERTIFICATES = ExpoConstants.expoConfig?.extra?.trustedCertificates as [string, ...string[]] | undefined | ||
|
||
if (!Array.isArray(TRUSTED_CERTIFICATES)) { | ||
throw new Error('Trusted Certificates provided in the expo config is not an array') | ||
} | ||
|
||
export const trustedCertificates = TRUSTED_CERTIFICATES |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { aes128Gcm } from '@package/agent' | ||
import { FUNKE_WALLET_INSTANCE_LONG_TERM_AES_KEY_ID } from '../constants' | ||
|
||
export const funkeAes128Gcm = aes128Gcm(FUNKE_WALLET_INSTANCE_LONG_TERM_AES_KEY_ID) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
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' | ||
|
||
/** | ||
* | ||
* Derive a key pair based on a numeric pin according to the steps in B' | ||
* | ||
* returns pin_derived_eph_pub + pin_derived_eph_priv | ||
* | ||
* @todo Might be good later to add methods like `signWithPidPin` | ||
* | ||
*/ | ||
export const deriveKeypairFromPin = async (agentContext: AgentContext, pin: Array<number>) => { | ||
if (!(await funkeAes128Gcm.aes128GcmHasKey({ agentContext }))) { | ||
throw new Error('No AES key found in storage. Flow is called in an incorrect way!') | ||
} | ||
|
||
const pinSecret = await funkeAes128Gcm.aes128GcmEncrypt({ | ||
agentContext, | ||
data: new Uint8Array(pin), | ||
}) | ||
|
||
const pinSeed = await kdf.derive( | ||
TypedArrayEncoder.toUtf8String(new Uint8Array(pin)), | ||
TypedArrayEncoder.toUtf8String(pinSecret) | ||
) | ||
|
||
return Key.fromSeed({ | ||
seed: new Uint8Array(TypedArrayEncoder.fromHex(pinSeed)), | ||
method: KeyMethod.None, | ||
algorithm: KeyAlgs.EcSecp256r1, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './seedCredential' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import type { Agent } from '@credo-ts/core' | ||
import { walletJsonStore } from '@package/agent' | ||
import { FUNKE_WALLET_SEED_CREDENTIAL_RECORD_ID } from '../constants' | ||
|
||
export const seedCredentialStorage = { | ||
store: async (agent: Agent, seedCredential: string) => | ||
walletJsonStore.store(agent, FUNKE_WALLET_SEED_CREDENTIAL_RECORD_ID, { | ||
seedCredential, | ||
}), | ||
|
||
update: async (agent: Agent, seedCredential: string) => | ||
walletJsonStore.update(agent, FUNKE_WALLET_SEED_CREDENTIAL_RECORD_ID, { | ||
seedCredential, | ||
}), | ||
|
||
getById: async (agent: Agent) => | ||
walletJsonStore.getById<{ seedCredential: string }>(agent, FUNKE_WALLET_SEED_CREDENTIAL_RECORD_ID), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
{ | ||
"extends": "../../tsconfig.json" | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"rootDir": "./", | ||
"paths": { | ||
"@/*": ["./apps/funke/*"] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.