0.5.0 • Published 4 years ago

@egendata/react-native-jose v0.5.0

Weekly downloads
6
License
MIT
Repository
github
Last release
4 years ago

react-native-jose

Getting started

$ npm install react-native-jose --save

Manual installation

iOS

  1. Add this to your Podfile inside your target
pod 'react-native-jose', :path => '../node_modules/@egendata/react-native-jose'
  1. 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
  1. Run your project (Cmd+R)<

Android

  1. 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 the getPackages() 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)
0.5.0

4 years ago

0.4.0

5 years ago

0.3.0

5 years ago

0.2.0

5 years ago

0.1.0

5 years ago