-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #91 from xmtp-labs/ar/encrypted-storage-service
refactor: Encrypted Storage
- Loading branch information
Showing
5 changed files
with
37 additions
and
23 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
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,20 +1,31 @@ | ||
import EncryptedStorage from 'react-native-encrypted-storage'; | ||
import RNEncryptedStorage from 'react-native-encrypted-storage'; | ||
|
||
enum StorageKeys { | ||
enum EncryptedStorageKeys { | ||
clientKeys = 'CLIENT_KEYS', | ||
} | ||
|
||
export const saveClientKeys = (address: `0x${string}`, clientKeys: string) => { | ||
return EncryptedStorage.setItem( | ||
`${StorageKeys.clientKeys}_${address}`, | ||
clientKeys, | ||
); | ||
}; | ||
class EncryptedStorage { | ||
//#region Client Keys | ||
private getClientKeysKey = (address: string) => { | ||
return `${EncryptedStorageKeys.clientKeys}_${address}`; | ||
}; | ||
|
||
export const getClientKeys = (address: `0x${string}`) => { | ||
return EncryptedStorage.getItem(`${StorageKeys.clientKeys}_${address}`); | ||
}; | ||
saveClientKeys = (address: string, clientKeys: string) => { | ||
return RNEncryptedStorage.setItem( | ||
this.getClientKeysKey(address), | ||
clientKeys, | ||
); | ||
}; | ||
|
||
export const clearClientKeys = (address: `0x${string}`) => { | ||
return EncryptedStorage.removeItem(`${StorageKeys.clientKeys}_${address}`); | ||
}; | ||
getClientKeys = (address: string) => { | ||
return RNEncryptedStorage.getItem(this.getClientKeysKey(address)); | ||
}; | ||
|
||
clearClientKeys = (address: string) => { | ||
return RNEncryptedStorage.removeItem(this.getClientKeysKey(address)); | ||
}; | ||
|
||
//#endregion Client Keys | ||
} | ||
|
||
export const encryptedStorage = new EncryptedStorage(); |