https://github.com/tsirysndr/react-native-jsontokens
React Native library for signing, decoding, and verifying JSON Web Tokens (JWTs)
https://github.com/tsirysndr/react-native-jsontokens
jwt jwt-token react-native
Last synced: 2 months ago
JSON representation
React Native library for signing, decoding, and verifying JSON Web Tokens (JWTs)
- Host: GitHub
- URL: https://github.com/tsirysndr/react-native-jsontokens
- Owner: tsirysndr
- License: mit
- Created: 2017-11-05T18:01:00.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-03-29T07:38:05.000Z (over 7 years ago)
- Last Synced: 2025-03-05T21:56:28.305Z (over 1 year ago)
- Topics: jwt, jwt-token, react-native
- Language: JavaScript
- Homepage:
- Size: 22.5 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# React Native JSON Tokens JS
React Native library for signing, decoding, and verifying JSON Web Tokens (JWTs)
### NOTE
This library requires [rn-nodeify](https://github.com/tradle/rn-nodeify)
### Installation
```
npm install react-native-jsontokens
```
### Signing Tokens
```js
import { TokenSigner } from 'react-native-jsontokens'
const rawPrivateKey = '278a5de700e29faae8e40e366ec5012b5ec63d36ec77e8a2417154cc1d25383f'
const tokenPayload = {"iat": 1440713414.85}
const token = new TokenSigner('ES256k', rawPrivateKey).sign(tokenPayload)
```
### Creating Unsecured Tokens
```js
import { createUnsecuredToken } from 'react-native-jsontokens'
const createUnsecuredToken(tokenPayload)
```
### Decoding Tokens
```js
import { decodeToken } = from 'react-native-jsontokens'
const tokenData = decodeToken(token)
```
### Verifying Tokens
```js
import { TokenVerifier } from 'react-native-jsontokens'
const rawPublicKey = '03fdd57adec3d438ea237fe46b33ee1e016eda6b585c3e27ea66686c2ea5358479'
const verified = new TokenVerifier('ES256k', rawPublicKey).verify(token)