react-native-jose
Getting started
$ npm install react-native-jose --save
Manual installation
iOS
- Add this to your Podfile inside your target
pod 'react-native-jose', :path => '../node_modules/@egendata/react-native-jose'
- Add (if you haven't already or just edit existing post_install settings) in the Podfile
post_install do |installer|
installer.pods_project.targets.each do |target|
if target.name == 'react-native-jose'
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0'
end
end
end
end
- Run your project (
Cmd+R
)<
Android
- Open up
android/app/src/main/java/[...]/MainApplication.java
- Add
import com.reactlibrary.JosePackage
to the imports at the top of the file - Add
new JosePackage()
to the list returned by thegetPackages()
method
Usage
import * as Jose from '@egendata/react-native-jose'
// TODO: What to do with the module?
console.log(Jose)
sign
import {sign} from '@egendata/react-native-jose'
const payload = {}
const privateKeys = {
jwk: {},
pem: '...'
} // private key containing "jwk" and "der" representations
const header = {}
const token = await sign(payload, privateKeys, header)
verify
import {verify} from '@egendata/react-native-jose'
const token = '...'
const jwk = {} // public key
const payload = await verify(token, jwk)
decode
import {decode} from '@egendata/react-native-jose'
const token = '...'
const options = {} // not used currently
const {claimsSet, header, signature} = await decode(token, options)
addRecipient
import {addRecipient} from '@egendata/react-native-jose'
const jwe = {}
const ownerKeys = {
jwk: {},
pem: ''
} // private key containing "jwk" and "pem" representations
const recipientKeys = {
jwk: {},
pem: ''
} // public key containing "jwk" and "pem" representations
const alg // currently only supports "RSA-OAEP"
const newJwe = await addRecipient(payload, ownerKeys, recipientKeys, alg)