-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
60e2859
commit 9587ffe
Showing
9 changed files
with
147 additions
and
46 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
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
4 changes: 4 additions & 0 deletions
4
android/racehorse/src/main/java/org/racehorse/utils/Strings.kt
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 @@ | ||
package org.racehorse.utils | ||
|
||
inline fun String?.ifNullOrBlank(defaultValue: () -> String): String = | ||
if (isNullOrBlank()) defaultValue() else this |
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
78 changes: 78 additions & 0 deletions
78
web/example/src/examples/BiometricEncryptedStorageExample.tsx
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,78 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import { FormattedJSON } from '../components/FormattedJSON'; | ||
import { BiometricAuthenticator, BiometricConfig, biometricEncryptedStorageManager } from 'racehorse'; | ||
|
||
const biometricConfig: BiometricConfig = { | ||
title: 'Authentication required', | ||
authenticators: [BiometricAuthenticator.BIOMETRIC_STRONG], | ||
}; | ||
|
||
export function BiometricEncryptedStorageExample() { | ||
const [key, setKey] = useState('my_key'); | ||
const [value, setValue] = useState('my_value'); | ||
const [persistedValue, setPersistedValue] = useState<string | null>(null); | ||
|
||
useEffect(() => { | ||
biometricEncryptedStorageManager.get(key).then(setPersistedValue); | ||
}, [key, value]); | ||
|
||
return ( | ||
<> | ||
<h2>{'Biometric encrypted storage'}</h2> | ||
|
||
<div style={{ display: 'flex', gap: '10px' }}> | ||
<div> | ||
{'Key:'} | ||
<br /> | ||
<input | ||
type="text" | ||
value={key} | ||
size={10} | ||
onChange={event => { | ||
setKey(event.target.value); | ||
}} | ||
/> | ||
</div> | ||
|
||
<div> | ||
{'Value:'} | ||
<br /> | ||
<input | ||
type="text" | ||
value={value} | ||
size={10} | ||
onChange={event => { | ||
setValue(event.target.value); | ||
}} | ||
/> | ||
</div> | ||
</div> | ||
|
||
<p> | ||
<button | ||
onClick={() => { | ||
biometricEncryptedStorageManager.set(key, value, biometricConfig).then(ok => { | ||
if (ok) { | ||
biometricEncryptedStorageManager.get(key, biometricConfig).then(setPersistedValue); | ||
} | ||
}); | ||
}} | ||
> | ||
{'Set value'} | ||
</button>{' '} | ||
<button | ||
onClick={() => { | ||
if (biometricEncryptedStorageManager.delete(key)) { | ||
biometricEncryptedStorageManager.get(key, biometricConfig).then(setPersistedValue); | ||
} | ||
}} | ||
> | ||
{'Delete value'} | ||
</button> | ||
</p> | ||
|
||
{'Persisted value: '} | ||
<FormattedJSON value={persistedValue} /> | ||
</> | ||
); | ||
} |
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