Giter Club home page Giter Club logo

react-native-pure-jwt's Introduction

react-native-pure-jwt

A React Native library that uses native modules to work with JWTs!

react-native-pure-jwt is a library that implements the power of JWTs inside React Native! It's goal is to sign, verify and decode JSON web tokens in order to provide a secure way to transmit authentic messages between two parties.

The difference to another libraries is that react-native-pure-jwt relies on the native realm in order to do JWT-related operations instead of the Javascript realm, so it's more stable (and works without hacks!).

Supported algorithms: HS256, HS384, HS512

React Native version required: >= 0.46.0

What's a JSON Web Token?

Don't know what a JSON Web Token is? Read on. Otherwise, jump down to the Installation section.

JWT is a means of transmitting information between two parties in a compact, verifiable form.

The bits of information encoded in the body of a JWT are called claims. The expanded form of the JWT is in a JSON format, so each claim is a key in the JSON object.

The compacted representation of a signed JWT is a string that has three parts, each separated by a .:

eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJKb2UifQ.ipevRNuRP6HflG8cFKnmUPtypruRC4fb1DWtoLL62SY

Each section is base 64 encoded. The first section is the header, which at a minimum needs to specify the algorithm used to sign the JWT. The second section is the body. This section has all the claims of this JWT encoded in it. The final section is the signature. It's computed by passing a combination of the header and body through the algorithm specified in the header.

If you pass the first two sections through a base 64 decoder, you'll get the following (formatting added for clarity):

header

{
  "alg": "HS256"
}

body

{
  "sub": "Joe"
}

In this case, the information we have is that the HMAC using SHA-256 algorithm was used to sign the JWT. And, the body has a single claim, sub with value Joe.

There are a number of standard claims, called Registered Claims, in the specification and sub (for subject) is one of them.

To compute the signature, you must know the secret that was used to sign it. In this case, it was the word secret. You can see the signature creation is action here (Note: Trailing = are lopped off the signature for the JWT).

Now you know (just about) all you need to know about JWTs. (Credits: jwtk/jjwt)

Installation

Install the package with: yarn add react-native-pure-jwt

If your React Native version supports autolinking, you should only run pod install on ios folder and you'll be good to go.

If not...

react-native link react-native-pure-jwt

The linking process on the iOS version works with Cocoapods

Manual Android linking

  • in android/app/build.gradle:
dependencies {
    ...
    compile "com.facebook.react:react-native:+"  // From node_modules
+   compile project(':react-native-pure-jwt')
}
  • in android/settings.gradle:
...
include ':app'
+ include ':react-native-pure-jwt'
+ project(':react-native-pure-jwt').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-pure-jwt/android')
  • in MainApplication.java:
+ import com.zaguiini.RNPureJwt.RNPureJwtPackage;

  public class MainApplication extends Application implements ReactApplication {
    //......

    @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
+         new RNPureJwtPackage(),
          new MainReactPackage()
      );
    }

    ......
  }

Manual iOS linking

You need to use Cocoapods at the moment. Open your Podfile and insert the following line in your main target:

pod 'react-native-pure-jwt', :podspec => '../node_modules/react-native-pure-jwt/react-native-pure-jwt.podspec'

Then run pod install and open your .xcworkspace

Usage

  • sign:
import { sign } from "react-native-pure-jwt";

sign(
  {
    iss: "[email protected]",
    exp: new Date().getTime() + 3600 * 1000, // expiration date, required, in ms, absolute to 1/1/1970
    additional: "payload"
  }, // body
  "my-secret", // secret
  {
    alg: "HS256"
  }
)
  .then(console.log) // token as the only argument
  .catch(console.error); // possible errors
  • decode:
import { decode } from "react-native-pure-jwt";

decode(
  token, // the token
  secret, // the secret
  {
    skipValidation: true // to skip signature and exp verification
  }
)
  .then(console.log) // already an object. read below, exp key note
  .catch(console.error);

/*
  response example:
  {
    headers: {
      alg: 'HS256'
    },
    payload: {
      iss: '[email protected]',
      exp: 'some date', // IN SECONDS
    }
  }
*/

Troubleshooting

haste collision. react-native/package.json collides with Pods/React/package.json

Add this to your Podfile:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    if target.name == "React"
      target.remove_from_project
    end
  end
end

Feel free to colaborate with the project!

react-native-pure-jwt's People

Contributors

aksonov avatar hansdesmedt avatar jrobber avatar lucasgmagalhaes avatar rhdeck avatar stanlee12 avatar zaguiini avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

react-native-pure-jwt's Issues

Custom Header

Is your feature request related to a problem? Please describe.
I'm curious if you have it on your roadmap to support a custom header?

Describe the solution you'd like
Certain 3rd Party vendors (i.e. Twilio) require adding custom keys to the header:

{
  "typ": "JWT",
  "alg": "HS256",
  "cty": "twilio-fpa;v=1" 
}

Describe alternatives you've considered
I've looked into going with a pure JS implementation, but those have their issues as well. They'll work in a Node.js environment, but not with the React Native or Hermes JS runtime.

Additional context
You can read more about Twilio's custom header requirement here: https://www.twilio.com/docs/iam/access-tokens#jwt-format

does it work with Expo?

I use expo and I installed it through Yarn, but it didn't work, the error appears,
TypeError: null is not an object (evaluating 'RNPureJwt.sign')

Any solution?
Thanks

Error 'npm i react-native-pure-jwt'

I try install the npm dependency but occurs an error.

** Command

npm i react-native-pure-jwt

** Error reported
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/react-native
npm ERR! react-native@"0.66.4" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react-native@"^0.41.2" from [email protected]
npm ERR! node_modules/react-native-pure-jwt
npm ERR! react-native-pure-jwt@"*" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution

**My environment

  • OS: Windows 10
  • My package.json
    "dependencies": {
    "@react-native-async-storage/async-storage": "1.15.14",
    "@react-native-community/geolocation": "2.0.2",
    "@react-native-community/masked-view": "0.1.11",
    "@react-navigation/bottom-tabs": "6.0.9",
    "@react-navigation/native": "6.0.6",
    "@react-navigation/stack": "6.0.11",
    "axios": "0.24.0",
    "react": "17.0.2",
    "react-native": "0.66.4",
    "react-native-base64": "^0.2.1",
    "react-native-gesture-handler": "2.1.0",
    "react-native-global-font": "1.0.3",
    "react-native-permissions": "3.2.0",
    "react-native-reanimated": "2.3.1",
    "react-native-safe-area-context": "3.3.2",
    "react-native-screens": "3.10.1",
    "react-native-svg": "12.1.1",
    "react-native-svg-transformer": "0.20.0",
    "react-native-swiper": "1.6.0",
    "styled-components": "5.3.3"
    },

cannot read property 'decode' of null : react-native-pure-jwt

In my react native project the example from github does not works

`
import {decode} from "react-native-pure-jwt";

decode(
"eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJKb2UifQ.ipevRNuRP6HflG8cFKnmUPtypruRC4fb1DWtoLL62SY", // the token
"secret", // the secret
{
skipValidation: true // to skip signature and exp verification
}
)
.then(console.log) // already an object. read below, exp key note
.catch(console.error);

`
I got the following error : "cannot read property 'decode' of null"

Execution failed for task ':app:checkDebugDuplicateClasses'

FAILURE: Build failed with an exception. What went wrong: Execution failed for task ':app:checkDebugDuplicateClasses'. 1 exception was raised by workers: java.lang.RuntimeException: java.lang.RuntimeException: Duplicate class io.jsonwebtoken.ClaimJwtException found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-api-0.10.7.jar (io.jsonwebtoken:jjwt-api:0.10.7) Duplicate class io.jsonwebtoken.Claims found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-api-0.10.7.jar (io.jsonwebtoken:jjwt-api:0.10.7) Duplicate class io.jsonwebtoken.ClaimsMutator found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-api-0.10.7.jar (io.jsonwebtoken:jjwt-api:0.10.7) Duplicate class io.jsonwebtoken.Clock found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-api-0.10.7.jar (io.jsonwebtoken:jjwt-api:0.10.7) Duplicate class io.jsonwebtoken.CompressionCodec found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-api-0.10.7.jar (io.jsonwebtoken:jjwt-api:0.10.7) Duplicate class io.jsonwebtoken.CompressionCodecResolver found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-api-0.10.7.jar (io.jsonwebtoken:jjwt-api:0.10.7) Duplicate class io.jsonwebtoken.CompressionCodecs found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-api-0.10.7.jar (io.jsonwebtoken:jjwt-api:0.10.7) Duplicate class io.jsonwebtoken.CompressionException found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-api-0.10.7.jar (io.jsonwebtoken:jjwt-api:0.10.7) Duplicate class io.jsonwebtoken.ExpiredJwtException found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-api-0.10.7.jar (io.jsonwebtoken:jjwt-api:0.10.7) Duplicate class io.jsonwebtoken.Header found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-api-0.10.7.jar (io.jsonwebtoken:jjwt-api:0.10.7) Duplicate class io.jsonwebtoken.IncorrectClaimException found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-api-0.10.7.jar (io.jsonwebtoken:jjwt-api:0.10.7) Duplicate class io.jsonwebtoken.InvalidClaimException found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-api-0.10.7.jar (io.jsonwebtoken:jjwt-api:0.10.7) Duplicate class io.jsonwebtoken.Jws found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-api-0.10.7.jar (io.jsonwebtoken:jjwt-api:0.10.7) Duplicate class io.jsonwebtoken.JwsHeader found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-api-0.10.7.jar (io.jsonwebtoken:jjwt-api:0.10.7) Duplicate class io.jsonwebtoken.Jwt found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-api-0.10.7.jar (io.jsonwebtoken:jjwt-api:0.10.7) Duplicate class io.jsonwebtoken.JwtBuilder found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-api-0.10.7.jar (io.jsonwebtoken:jjwt-api:0.10.7) Duplicate class io.jsonwebtoken.JwtException found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-api-0.10.7.jar (io.jsonwebtoken:jjwt-api:0.10.7) Duplicate class io.jsonwebtoken.JwtHandler found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-api-0.10.7.jar (io.jsonwebtoken:jjwt-api:0.10.7) Duplicate class io.jsonwebtoken.JwtHandlerAdapter found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-api-0.10.7.jar (io.jsonwebtoken:jjwt-api:0.10.7) Duplicate class io.jsonwebtoken.JwtParser found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-api-0.10.7.jar (io.jsonwebtoken:jjwt-api:0.10.7) Duplicate class io.jsonwebtoken.Jwts found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-api-0.10.7.jar (io.jsonwebtoken:jjwt-api:0.10.7) Duplicate class io.jsonwebtoken.MalformedJwtException found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-api-0.10.7.jar (io.jsonwebtoken:jjwt-api:0.10.7) Duplicate class io.jsonwebtoken.MissingClaimException found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-api-0.10.7.jar (io.jsonwebtoken:jjwt-api:0.10.7) Duplicate class io.jsonwebtoken.PrematureJwtException found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-api-0.10.7.jar (io.jsonwebtoken:jjwt-api:0.10.7) Duplicate class io.jsonwebtoken.RequiredTypeException found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-api-0.10.7.jar (io.jsonwebtoken:jjwt-api:0.10.7) Duplicate class io.jsonwebtoken.SignatureAlgorithm found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-api-0.10.7.jar (io.jsonwebtoken:jjwt-api:0.10.7) Duplicate class io.jsonwebtoken.SignatureException found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-api-0.10.7.jar (io.jsonwebtoken:jjwt-api:0.10.7) Duplicate class io.jsonwebtoken.SigningKeyResolver found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-api-0.10.7.jar (io.jsonwebtoken:jjwt-api:0.10.7) Duplicate class io.jsonwebtoken.SigningKeyResolverAdapter found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-api-0.10.7.jar (io.jsonwebtoken:jjwt-api:0.10.7) Duplicate class io.jsonwebtoken.UnsupportedJwtException found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-api-0.10.7.jar (io.jsonwebtoken:jjwt-api:0.10.7) Duplicate class io.jsonwebtoken.impl.AbstractTextCodec found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-impl-0.10.7.jar (io.jsonwebtoken:jjwt-impl:0.10.7) Duplicate class io.jsonwebtoken.impl.AndroidBase64Codec found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-impl-0.10.7.jar (io.jsonwebtoken:jjwt-impl:0.10.7) Duplicate class io.jsonwebtoken.impl.Base64Codec found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-impl-0.10.7.jar (io.jsonwebtoken:jjwt-impl:0.10.7) Duplicate class io.jsonwebtoken.impl.Base64UrlCodec found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-impl-0.10.7.jar (io.jsonwebtoken:jjwt-impl:0.10.7) Duplicate class io.jsonwebtoken.impl.DefaultClaims found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-impl-0.10.7.jar (io.jsonwebtoken:jjwt-impl:0.10.7) Duplicate class io.jsonwebtoken.impl.DefaultClock found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-impl-0.10.7.jar (io.jsonwebtoken:jjwt-impl:0.10.7) Duplicate class io.jsonwebtoken.impl.DefaultHeader found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-impl-0.10.7.jar (io.jsonwebtoken:jjwt-impl:0.10.7) Duplicate class io.jsonwebtoken.impl.DefaultJws found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-impl-0.10.7.jar (io.jsonwebtoken:jjwt-impl:0.10.7) Duplicate class io.jsonwebtoken.impl.DefaultJwsHeader found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-impl-0.10.7.jar (io.jsonwebtoken:jjwt-impl:0.10.7) Duplicate class io.jsonwebtoken.impl.DefaultJwt found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-impl-0.10.7.jar (io.jsonwebtoken:jjwt-impl:0.10.7) Duplicate class io.jsonwebtoken.impl.DefaultJwtBuilder found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-impl-0.10.7.jar (io.jsonwebtoken:jjwt-impl:0.10.7) Duplicate class io.jsonwebtoken.impl.DefaultJwtParser found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-impl-0.10.7.jar (io.jsonwebtoken:jjwt-impl:0.10.7) Duplicate class io.jsonwebtoken.impl.DefaultJwtParser$1 found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-impl-0.10.7.jar (io.jsonwebtoken:jjwt-impl:0.10.7) Duplicate class io.jsonwebtoken.impl.DefaultJwtParser$2 found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-impl-0.10.7.jar (io.jsonwebtoken:jjwt-impl:0.10.7) Duplicate class io.jsonwebtoken.impl.DefaultJwtParser$3 found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-impl-0.10.7.jar (io.jsonwebtoken:jjwt-impl:0.10.7) Duplicate class io.jsonwebtoken.impl.DefaultJwtParser$4 found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-impl-0.10.7.jar (io.jsonwebtoken:jjwt-impl:0.10.7) Duplicate class io.jsonwebtoken.impl.DefaultTextCodecFactory found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-impl-0.10.7.jar (io.jsonwebtoken:jjwt-impl:0.10.7) Duplicate class io.jsonwebtoken.impl.FixedClock found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-impl-0.10.7.jar (io.jsonwebtoken:jjwt-impl:0.10.7) Duplicate class io.jsonwebtoken.impl.JwtMap found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-impl-0.10.7.jar (io.jsonwebtoken:jjwt-impl:0.10.7) Duplicate class io.jsonwebtoken.impl.TextCodec found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-impl-0.10.7.jar (io.jsonwebtoken:jjwt-impl:0.10.7) Duplicate class io.jsonwebtoken.impl.TextCodecFactory found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-impl-0.10.7.jar (io.jsonwebtoken:jjwt-impl:0.10.7) Duplicate class io.jsonwebtoken.impl.compression.AbstractCompressionCodec found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-impl-0.10.7.jar (io.jsonwebtoken:jjwt-impl:0.10.7) Duplicate class io.jsonwebtoken.impl.compression.CompressionCodecs found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-impl-0.10.7.jar (io.jsonwebtoken:jjwt-impl:0.10.7) Duplicate class io.jsonwebtoken.impl.compression.DefaultCompressionCodecResolver found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-impl-0.10.7.jar (io.jsonwebtoken:jjwt-impl:0.10.7) Duplicate class io.jsonwebtoken.impl.compression.DeflateCompressionCodec found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-impl-0.10.7.jar (io.jsonwebtoken:jjwt-impl:0.10.7) Duplicate class io.jsonwebtoken.impl.compression.GzipCompressionCodec found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-impl-0.10.7.jar (io.jsonwebtoken:jjwt-impl:0.10.7) Duplicate class io.jsonwebtoken.impl.crypto.DefaultJwtSignatureValidator found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-impl-0.10.7.jar (io.jsonwebtoken:jjwt-impl:0.10.7) Duplicate class io.jsonwebtoken.impl.crypto.DefaultJwtSigner found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-impl-0.10.7.jar (io.jsonwebtoken:jjwt-impl:0.10.7) Duplicate class io.jsonwebtoken.impl.crypto.DefaultSignatureValidatorFactory found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-impl-0.10.7.jar (io.jsonwebtoken:jjwt-impl:0.10.7) Duplicate class io.jsonwebtoken.impl.crypto.DefaultSignatureValidatorFactory$1 found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-impl-0.10.7.jar (io.jsonwebtoken:jjwt-impl:0.10.7) Duplicate class io.jsonwebtoken.impl.crypto.DefaultSignerFactory found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-impl-0.10.7.jar (io.jsonwebtoken:jjwt-impl:0.10.7) Duplicate class io.jsonwebtoken.impl.crypto.DefaultSignerFactory$1 found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-impl-0.10.7.jar (io.jsonwebtoken:jjwt-impl:0.10.7) Duplicate class io.jsonwebtoken.impl.crypto.EllipticCurveProvider found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-impl-0.10.7.jar (io.jsonwebtoken:jjwt-impl:0.10.7) Duplicate class io.jsonwebtoken.impl.crypto.EllipticCurveProvider$1 found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-impl-0.10.7.jar (io.jsonwebtoken:jjwt-impl:0.10.7) Duplicate class io.jsonwebtoken.impl.crypto.EllipticCurveSignatureValidator found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-impl-0.10.7.jar (io.jsonwebtoken:jjwt-impl:0.10.7) Duplicate class io.jsonwebtoken.impl.crypto.EllipticCurveSigner found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-impl-0.10.7.jar (io.jsonwebtoken:jjwt-impl:0.10.7) Duplicate class io.jsonwebtoken.impl.crypto.JwtSignatureValidator found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-impl-0.10.7.jar (io.jsonwebtoken:jjwt-impl:0.10.7) Duplicate class io.jsonwebtoken.impl.crypto.JwtSigner found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-impl-0.10.7.jar (io.jsonwebtoken:jjwt-impl:0.10.7) Duplicate class io.jsonwebtoken.impl.crypto.MacProvider found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-impl-0.10.7.jar (io.jsonwebtoken:jjwt-impl:0.10.7) Duplicate class io.jsonwebtoken.impl.crypto.MacSigner found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-impl-0.10.7.jar (io.jsonwebtoken:jjwt-impl:0.10.7) Duplicate class io.jsonwebtoken.impl.crypto.MacValidator found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-impl-0.10.7.jar (io.jsonwebtoken:jjwt-impl:0.10.7) Duplicate class io.jsonwebtoken.impl.crypto.RsaProvider found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-impl-0.10.7.jar (io.jsonwebtoken:jjwt-impl:0.10.7) Duplicate class io.jsonwebtoken.impl.crypto.RsaSignatureValidator found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-impl-0.10.7.jar (io.jsonwebtoken:jjwt-impl:0.10.7) Duplicate class io.jsonwebtoken.impl.crypto.RsaSigner found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-impl-0.10.7.jar (io.jsonwebtoken:jjwt-impl:0.10.7) Duplicate class io.jsonwebtoken.impl.crypto.SignatureProvider found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-impl-0.10.7.jar (io.jsonwebtoken:jjwt-impl:0.10.7) Duplicate class io.jsonwebtoken.impl.crypto.SignatureValidator found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-impl-0.10.7.jar (io.jsonwebtoken:jjwt-impl:0.10.7) Duplicate class io.jsonwebtoken.impl.crypto.SignatureValidatorFactory found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-impl-0.10.7.jar (io.jsonwebtoken:jjwt-impl:0.10.7) Duplicate class io.jsonwebtoken.impl.crypto.Signer found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-impl-0.10.7.jar (io.jsonwebtoken:jjwt-impl:0.10.7) Duplicate class io.jsonwebtoken.impl.crypto.SignerFactory found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-impl-0.10.7.jar (io.jsonwebtoken:jjwt-impl:0.10.7) Duplicate class io.jsonwebtoken.lang.Arrays found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-api-0.10.7.jar (io.jsonwebtoken:jjwt-api:0.10.7) Duplicate class io.jsonwebtoken.lang.Assert found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-api-0.10.7.jar (io.jsonwebtoken:jjwt-api:0.10.7) Duplicate class io.jsonwebtoken.lang.Classes found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-api-0.10.7.jar (io.jsonwebtoken:jjwt-api:0.10.7) Duplicate class io.jsonwebtoken.lang.Classes$1 found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-api-0.10.7.jar (io.jsonwebtoken:jjwt-api:0.10.7) Duplicate class io.jsonwebtoken.lang.Classes$2 found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-api-0.10.7.jar (io.jsonwebtoken:jjwt-api:0.10.7) Duplicate class io.jsonwebtoken.lang.Classes$3 found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-api-0.10.7.jar (io.jsonwebtoken:jjwt-api:0.10.7) Duplicate class io.jsonwebtoken.lang.Classes$ClassLoaderAccessor found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-api-0.10.7.jar (io.jsonwebtoken:jjwt-api:0.10.7) Duplicate class io.jsonwebtoken.lang.Classes$ExceptionIgnoringAccessor found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-api-0.10.7.jar (io.jsonwebtoken:jjwt-api:0.10.7) Duplicate class io.jsonwebtoken.lang.Collections found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-api-0.10.7.jar (io.jsonwebtoken:jjwt-api:0.10.7) Duplicate class io.jsonwebtoken.lang.Collections$EnumerationIterator found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-api-0.10.7.jar (io.jsonwebtoken:jjwt-api:0.10.7) Duplicate class io.jsonwebtoken.lang.InstantiationException found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-api-0.10.7.jar (io.jsonwebtoken:jjwt-api:0.10.7) Duplicate class io.jsonwebtoken.lang.Objects found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-api-0.10.7.jar (io.jsonwebtoken:jjwt-api:0.10.7) Duplicate class io.jsonwebtoken.lang.RuntimeEnvironment found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-api-0.10.7.jar (io.jsonwebtoken:jjwt-api:0.10.7) Duplicate class io.jsonwebtoken.lang.Strings found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-api-0.10.7.jar (io.jsonwebtoken:jjwt-api:0.10.7) Duplicate class io.jsonwebtoken.lang.UnknownClassException found in modules jjwt-0.9.0.jar (io.jsonwebtoken:jjwt:0.9.0) and jjwt-api-0.10.7.jar (io.jsonwebtoken:jjwt-api:0.10.7)

I've already tried clean and rebuild, npm ci, install and uninstall the package but still getting these errors.

Add decode function

Clients should be able to decode a token without verifying it for inspection and extracting information like subject and other claims.

Set compileSdkVersion to 30 or above

"react": "^18.2.0",
"react-native": "^0.72.0",
"react-native-pure-jwt": "^3.0.1",

Error:
Execution failed for task ':tasks'.

Could not create task ':react-native-pure-jwt:compileDebugJavaWithJavac'. > In order to compile Java 9+ source, please set compileSdkVersion to 30 or above *

Create new release and changelog

It would be great if one can just go to Release section and see the API changes.

For example, from 2.2.2 to 3.0.0, named import can now be used.

Decode fails only on IOS

Describe the bug
Utilizing the same secret, and same JWT results in different results when trying to decode on android vs IOS. Decoding is successful on android, but results in "Error: Decoding failed" error on IOS.

To Reproduce
Here is an example that is currently producing this inconsistency on my devices.

import { decode } from 'react-native-pure-jwt'
const test_decode = async () => {
    try {
      let test_token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzZXJpYWxfbnVtYmVyIjoiNWYxMGExNjMtMjk2OC00ZDZkLWIyZDgtOGQxNjQwMDNlMmQ0Iiwic2VxIjo1MTI4MTYsIm5hbWUiOiJOYW1lMSIsImlkIjo2NTQsImRlc2NyaXB0aW9uIjoiVGVzdCBEZWNvZGluZyJ9.ahLaTEhdgonxb8rfLG6NjcIg6rqbGzcHkwwFtvb9KTE";
      let test_key = "SuperSecretKey";
      let test_result = await decode(test_token, test_key);
      console.log(test_result);
      } catch(error) {
        console.warn(error);
    }
  }
  test_decode();

Expected behavior
Decoding should be consistent across platforms when given the same information on both.

Smartphone (please complete the following information):

  • Devices: IPhone XR, Samsung S9+

Please let me know if there is more information needed or if I am utilizing this function incorrectly.

Flaw: A secret should not be required for decode

This is an issue with this project as a lot of client side apps do not encrypt the entire JWT.

You've stated and closed previous post on people talking about this saying look at the README for the { skipValidation: true }.

I've reviewed the code and skipValidation does nothing for allowing tokens to not need a secret. The error is being thrown by dependent libraries. In RNPureJwtModule.java line 99 the error signing key cannot be null or empty is being thrown from the io.jsonwebtoken.Jwts library.

Not working with versions >=0.60

After installing package with npm ,project didn't compile and got the error below.As you now ,React Native CLI uses autolinking.I also tried to unlink and proceed with manual installing as you showed at installation section.But nothing to avail.
Enviroment: Vs Code
Versions:
"react-native": "0.61.1"
"react-native-pure-jwt": "2.1.1"

error React Native CLI uses autolinking for native dependencies, but the following modules are linked manually:

  • react-native-pure-jwt (to unlink run: "react-native unlink react-native-pure-jwt")
    This is likely happening when upgrading React Native from below 0.60 to 0.60 or above. Going forward, you can unlink this dependency via "react-native unlink " and it will be included in your app automatically. If a library isn't compatible with autolinking, disregard this message and notify the library maintainers.

Read payload without secret key

In JWT we can read payload without secret key. I try to use skipValidation option as true and give secret as null. Then it is still giving an [Error: Decoding failed] error.

For quick solution I pick the payload part of the token and decode it with base-64

import {decode} from 'base-64';

const payload = JSON.parse(decode(token.split('.')[1]));

Note: I use base-64 npm package to decode, btoa is not working correctly in React Native.

Possible to use payload as encrypted Token value?

Hello Team,
Is it possible to use the encrypted token payload value and use it, Please suggest some solution for this.

jwt.sign(
            {
                _id: id,
                emailId: email,
                name: name,
                expireAt: expireTime,
                exp: new Date().getTime() + 36000 * 1000, // expiration date, required, in ms, absolute to 1/1/1970
            }, // body
            "secret", // secret
            { alg: "HS256" })
            .then((token) => {
                console.log(" jwt token: ", token);
                jwt
                    .decode(
                        token, // the token
                        "secret", // the secret
                        {
                            skipValidation: true // to skip signature and exp verification
                        }
                    )
                    .then(console.log) // already an object. read below, exp key note
                    .catch(console.error);
            }) // token as the only argument
            .catch(console.error); // possible errors

Here in above code I am encrypting and creating the jwt token to use it
but while encrypting it it comes with below:

{"headers": {"alg": "HS256", "typ": "JWT"}, "payload": {_id: id,
                emailId: email,
                name: name,
                expireAt: expireTime,
                exp: new Date().getTime() + 36000 * 1000}}

Can I only use the Payload data for the encrypted token? please let me know some suggestion/Answer.

Secret should not be required for decode

In the normal node-jsonwebtoken implementation, you can decode without providing a secret and it will still give you the payload. However this module requires the secret, which is something I don't particularly want to hard-code into my RN app.

Is there any way around this?

Thanks!
Matt

iOS build error

info .../node_modules/react-native-pure-jwt/ios/RNPureJwt.m:3:9: fatal error
info
info : 'JWT.h' file not found
info #import "JWT.h"
^~~~~~~
info 1 error generated.

Build on iOS 12
Xcode 10.2.1
RN 0.59.5

iOS install via Cocoapods, branches do not exist

I can't install the library using Cocoapods because it tries to access git branches that don't exist.

[!] Error installing RNPureJwt
[!] /usr/bin/git clone https://github.com/zaguiini/react-native-pure-jwt.git /var/folders/v0/n5lq_ggx5fg4n2lw3xlkqtn00000gn/T/d20190521-40030-nkgbd0 --template= --single-branch --depth 1 --branch 2.0.1

Cloning into '/var/folders/v0/n5lq_ggx5fg4n2lw3xlkqtn00000gn/T/d20190521-40030-nkgbd0'...
warning: Could not find remote branch 2.0.1 to clone.
fatal: Remote branch 2.0.1 not found in upstream origin

RSxxx algorithms doesn't work.

The error object says key bytes can only be specified for HMAC signatures. So, please specify a PublicKey or PrivateKey instance.

Only see decode

When I try to use the sign function I am getting a "undefined is not a function" error. I inspected the contents of the jwt object and I only see the decode function available:

Object { "decode": [Function decode], }

I am using the sample code and running on iOS through expo project. Any ideas?

#import "React/RCTBridgeModule.h" not found

Hi @zaguiini ,

I installed react-native-pure-jwt in my react native project. Everything seems to be working fine on android. However, on IOS, I get 2 error.

  1. #import "React/RCTBridgeModule.h" not found
  2. Failed to emit precompiled header '/Users/apple/Library/Developer/Xcode/DerivedData/

I have already tried many solutions. But they don't seem to work. I have unchecked parallelized build and my react is on top in Target Section. As instructed in library documentation, I have added the JWT swift file in libraries.

React Native - 0.58.5
react-native-pure-jwt- v1.6.0

Still, it's not working. Any help would be great.

Thanks in advance

Different tokens on iOS and Android from same payload.

Hello. Thank you for the library. I am having an issue, though I do not believe it is a bug. I am running into authentication issue when running my app on Android. The request authenticates correctly for iOS. I notice that the token returned from jwt.sign() is different on each platform, even when the payload body, secret key, and Hash Algo are identical.
Is there a way to have the jwt.sign() function return the same token on both platforms?

Let me know if you need any more information.

Thank you!

Property 'claimsSet' not found

Hello!

When I'm trying to build my app for ios, I'm getting this error:

image

I already tried manual linking and it didn't work... any ideas?

Error: JWT must not be accepted before 2019-08-25T15:33:52Z. Current time: 2019-08-25T15:33:49Z, a difference of 2378 milliseconds. Allowed clock skew: 0 milliseconds.

when i want to decode my jwt for the first time, i see this error.
what should i do?!
{ [Error: JWT must not be accepted before 2019-08-25T15:33:52Z. Current time: 2019-08-25T15:33:49Z, a difference of 2378 milliseconds. Allowed clock skew: 0 milliseconds.] framesToPop: 1, nativeStackAndroid: [ { methodName: 'parse', lineNumber: 407, file: 'DefaultJwtParser.java' }, { methodName: 'decode', lineNumber: 121, file: 'RNPureJwtModule.java' }, { methodName: 'invoke', lineNumber: -2, file: 'Method.java' }, { methodName: 'invoke', lineNumber: 372, file: 'JavaMethodWrapper.java' }, { methodName: 'invoke', lineNumber: 158, file: 'JavaModuleWrapper.java' }, { methodName: 'run', lineNumber: -2, file: 'NativeRunnable.java' }, { methodName: 'handleCallback', lineNumber: 808, file: 'Handler.java' }, { methodName: 'dispatchMessage', lineNumber: 101, file: 'Handler.java' }, { methodName: 'dispatchMessage', lineNumber: 29, file: 'MessageQueueThreadHandler.java' }, { methodName: 'loop', lineNumber: 166, file: 'Looper.java' } ], userInfo: null, code: '0', line: 2114, column: 26, sourceURL: 'http://localhost:8081/index.delta?platform=android&dev=true&minify=false' }

Error on Android Device: java.lang.NullPointerException: Attempt to invoke virtual method 'byte[] java.lang.String.getBytes(java.nio.charset.Charset)' on a null object reference

I followed the installation instructions in overview which are:

yarn add react-native-pure-jwt

and

react-native link eact-native-pure-jwt

I also checked for the ff files:

  1. MainApplication.java
  2. android/app/build.gradle
  3. android/settings.gradle

if the necessary changes has been made for android to be linked properly and I still get this error when running on a physical Android Device

Here is the complete thread

com.zaguiini.RNPureJwt.RNPureJwtModule.toBase64 RNPureJwtModule.java:44
com.zaguiini.RNPureJwt.RNPureJwtModule.decode RNPureJwtModule.java:99
java.lang.reflect.Method.invoke Method.java
com.facebook.react.bridge.JavaMethodWrapper.invoke JavaMethodWrapper.java:372
com.facebook.react.bridge.JavaModuleWrapper.invoke JavaModuleWrapper.java:158
com.facebook.react.bridge.queue.NativeRunnable.run NativeRunnable.java
android.os.Handler.handleCallback Handler.java:873
android.os.Handler.dispatchMessage Handler.java:99
com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage MessageQueueThreadHandler.java:29
android.os.Looper.loop Looper.java:214
com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run MessageQueueThreadImpl.java:232
java.lang.Thread.run Thread.java:764

Screen Shot 2019-10-23 at 17 40 42

Packages versions:
react-native: 0.60.5
react-native-pure-jwt: 2.1.1

Issue with building release package in android - react native 0.60.5

When i tried to build the release package in react native 0.60.5, i encounter this error. Any idea on how to fix this and add compatibility for it?

> Task :react-native-pure-jwt:verifyReleaseResources FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-pure-jwt:verifyReleaseResources'.
> 1 exception was raised by workers:
  com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed
  error: resource android:style/TextAppearance.Material.Widget.Button.Borderless.Colored not found.
  error: resource android:style/TextAppearance.Material.Widget.Button.Colored not found.
  D:\confidential-app\node_modules\react-native-pure-jwt\android\build\intermediates\res\merged\release\values-v26\values-v26.xml:7: error: resource android:attr/colorError not found.
  D:\confidential-app\node_modules\react-native-pure-jwt\android\build\intermediates\res\merged\release\values-v26\values-v26.xml:11: error: resource android:attr/colorError not found.
  D:\confidential-app\node_modules\react-native-pure-jwt\android\build\intermediates\res\merged\release\values-v26\values-v26.xml:15: error: style attribute 'android:attr/keyboardNavigationCluster' not found.
  D:\confidential-app\node_modules\react-native-pure-jwt\android\build\intermediates\res\merged\release\values-v28\values-v28.xml:7: error: resource android:attr/dialogCornerRadius not found.
  D:\confidential-app\node_modules\react-native-pure-jwt\android\build\intermediates\res\merged\release\values-v28\values-v28.xml:11: error: resource android:attr/dialogCornerRadius not found.
  D:\confidential-app\node_modules\react-native-pure-jwt\android\build\intermediates\res\merged\release\values\values.xml:2734: error: resource android:attr/fontStyle not found.
  D:\confidential-app\node_modules\react-native-pure-jwt\android\build\intermediates\res\merged\release\values\values.xml:2735: error: resource android:attr/font not found.
  D:\confidential-app\node_modules\react-native-pure-jwt\android\build\intermediates\res\merged\release\values\values.xml:2736: error: resource android:attr/fontWeight not found.
  D:\confidential-app\node_modules\react-native-pure-jwt\android\build\intermediates\res\merged\release\values\values.xml:2737: error: resource android:attr/fontVariationSettings not found.
  D:\confidential-app\node_modules\react-native-pure-jwt\android\build\intermediates\res\merged\release\values\values.xml:2738: error: resource android:attr/ttcIndex not found.
  D:\confidential-app\node_modules\react-native-pure-jwt\android\build\intermediates\res\merged\release\values\values.xml:2902: error: resource android:attr/startX 
not found.
  D:\confidential-app\node_modules\react-native-pure-jwt\android\build\intermediates\res\merged\release\values\values.xml:2905: error: resource android:attr/startY 
not found.
  D:\confidential-app\node_modules\react-native-pure-jwt\android\build\intermediates\res\merged\release\values\values.xml:2908: error: resource android:attr/endX not found.
  D:\confidential-app\node_modules\react-native-pure-jwt\android\build\intermediates\res\merged\release\values\values.xml:2911: error: resource android:attr/endY not found.
  D:\confidential-app\node_modules\react-native-pure-jwt\android\build\intermediates\res\merged\release\values\values.xml:2919: error: resource android:attr/offset 
not found.
  error: failed linking references.

jwt import unrecognized despite usage and cannot use sign() due to TypeError

Describe the bug
I am simply trying to encode a JWT using the sign function, but when I import jwt from 'react-native-pure-jwt' my editor tells me that jwt is declared but never used, even though I am clearly using it as instructed in the usage section. When the code arrives at the line where I sign a token I get the following error:

TypeError: _reactNativePureJwt.default.sign is not a function. (In '_reactNativePureJwt.default.sign(payload, "s3cr3tt", {
              alg: "HS256"
            })', '_reactNativePureJwt.default.sign' is undefined)

To Reproduce
Steps to reproduce the behavior:

  1. Import jwt from "react-native-pure-jwt" at the top of a react native functional component file
  2. Make a button that calls the sign() function when it is pressed
  3. Observe the error when the function is called due to sign()
  4. See error

Expected behavior
the sign() function should return a string corresponding to the JWT.

Screenshots
Code showing that jwt is unused even though I am using it:
Screen Shot 2020-10-30 at 11 59 34 AM
The error given in console:
Screen Shot 2020-10-30 at 11 59 57 AM

Desktop

  • OS: macOS v10.15.7
  • react-native: 0.63.2
  • react-native-cli: 2.0.1

Smartphone (please complete the following information):

  • Device: iPhone8
  • OS: iOS14

Additional context
The application builds fine and I get this same error when trying auto or manual linking as described in the install instructions.

Decoding failed.

Hello, in my RN project, decoding failed and shows errors like this .

Error: Decoding failed
at createErrorFromErrorData (NativeModules.js:155)
at NativeModules.js:104
at MessageQueue.__invokeCallback (MessageQueue.js:414)
at MessageQueue.js:127
at MessageQueue.__guard (MessageQueue.js:314)
at MessageQueue.invokeCallbackAndReturnFlushedQueue (MessageQueue.js:126)
at RNDebuggerWorker.js:2

Codes in project:

decodeJWTTokens = () => {
const token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.e30.t- IDcSemACt8x4iTMCda8Yhe3iZaWbvV5XKSTbuAn0";
const secret = 'kyaw';
jwt
.decode(token, secret, { skipValidation: false })
.then("Decode JWT ===>", console.log) // already an object. read below, exp key note
.catch("Error ===> ", console.log);
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.