react-native-token
Library for managing tokens structured with keychain storage
Feature
- Simple and easy to use(hook style)
- Topic-Token Top-down structure
- Token stored in Keychain storage
- MIT License
Install
npm i react-native-token || yarn add react-native-token
Setup
This library needs react-native-keychain. Please follow the installation instructions here
Usage
//import library // this is not required const example = async { // Create a topic for storing Keys, Tokens ... etc. let topic = await // Set a value await topic // Get all tokens that stored in Topic let tokens = await topic let publicKey = tokenspublicKeytokenValue await topicclear} // IMPORTANT : EXAMPLE FUNCTIONconst validateSessionToken = async { const result = await API return result}
Methods
- useTopic
- setToken
- getToken
- deleteToken
- getAllToken
- getAllTokenTitle
- deleteTopic
- validateToken
- clear
API
functions
useTopic(topicTitle(String, required)) => RNToken objcet
- Create A topic for storing values.
- It only creates a new topic when topic does not exist.
- If already had a topic for 'topicTitle' that you passed, will just return RNToken object
usage
const example = async { let topic = await }
RNToken.setToken(tokenTitle(String, required), tokenValue(String, required), validateFunction(Function, optional))
- Add or Update token in topic
usage
const example = async { let topic = await await topic}
RNToken.getToken(tokenTitle(String, required))
- Get token
usage
const example = async { let topic = await await topic}
RNToken.deleteToken(tokenTitle(String, required))
- Delete token
usage
const example = async { let topic = await await topic}
RNToken.getAllToken()
- Get all token in topic
usage
const example = async { let topic = await await topic}
RNToken.getAllTokenTitle()
- Get all tokenTitle in topic
usage
const example = async { let topic = await await topic}
RNToken.clear()
- Clear Topic
usage
const example = async { let topic = await await topicclear}
RNToken.deleteTopic()
- Delete this topic
usage
const example = async { let topic = await await topic}
RNToken.validateToken(tokenTitle(String, required))
- Run validate function and return result
usage
const example = async { let topic = await await topic}