GithubHelp home page GithubHelp logo

dcangulo / react-native-pkce-challenge Goto Github PK

View Code? Open in Web Editor NEW
27.0 3.0 7.0 3.84 MB

Proof Key for Code Exchange (PKCE) challenge generator for React Native.

Home Page: https://www.npmjs.com/package/react-native-pkce-challenge

License: MIT License

JavaScript 11.19% Java 22.67% Objective-C 7.25% Ruby 10.31% TypeScript 10.65% CMake 1.50% C++ 31.63% Objective-C++ 4.39% Swift 0.16% C 0.26%
pkce oauth2 react-native react react-native-web reactjs react-native-macos react-native-windows expo

react-native-pkce-challenge's Introduction

Hi ๐Ÿ‘‹, I'm David Angulo

Software Engineer

dcangulo-profile-views

Stats

dcangulo-streak

dcangulo-stats

Languages

dcangulo-languages

Trophies

dcangulo-trophies

react-native-pkce-challenge's People

Contributors

bill-pairaktaridis avatar cavanierc avatar dcangulo avatar dependabot-preview[bot] avatar dependabot[bot] avatar duell10111 avatar rahulpatel 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

Watchers

 avatar  avatar  avatar

react-native-pkce-challenge's Issues

m1 ready?

Hi,

is this package m1 Mac ready? I'm struggling with required ndk.

Thank you.

Update crypto-js to 4.2.0

Possible to update crypto-js to 4.2.0?

Crypto-js PBKDF2 is 1,000 times weaker than originally specified in 1993, and at least 1,300,000 times weaker than current industry standard. This is because it both (1) defaults to SHA1, a cryptographic hash algorithm considered insecure since at least 2005 and (2) defaults to one single iteration, a 'strength' or 'difficulty' value specified at 1,000 when specified in 1993. PBKDF2 relies on iteration count as a countermeasure to preimage and collision attacks.

See GHSA-xwcq-pm8m-c4vf

Add support for typescript

This package does not support typescript and requires the user to generate a .d.ts

interface IPkce {
  codeChallenge: string;
  codeVerifier: string;
}
export function asyncPkceChallenge(): IPkce;

error: package com.davidangulo.randombytes does not exist

When upgrading to 5.x from 3.2, the following error occurs when building Android.

Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
/app/android/app/build/generated/rncli/src/main/java/com/facebook/react/PackageList.java:49: error: package com.davidangulo.randombytes does not exist
import com.davidangulo.randombytes.RandomBytesPackage;
^
/app/android/app/build/generated/rncli/src/main/java/com/facebook/react/PackageList.java:142: error: cannot find symbol

React Native = 0.67.3
buildToolsVersion = "30.0.2"
minSdkVersion = 21
compileSdkVersion = 31
targetSdkVersion = 30
ndkVersion = "21.4.7075529"

[Windows] Error in Android CMake : NODE_MODULES_DIR contains backslashes

Hello

We have an Android build issue related to this library, on windows.

In the android\build.gradle#L60 file, the NODE_MODULES_DIR variable outputs a path with backslashes (\\) on Windows, which CMake rejects, for example : NODE_MODULES_DIR=D:\\.....\\android/../node_modules"

I've found similar issue on other repositories, where the fix is made by doing os-specific formatting in the build.gradle file. Eg :
Kudo/react-native-v8@5a2107f

Another (maybe dirty) solution could be adding something like this to the CMakeLists.txt#L6 file : string(REPLACE "\\" "/" NODE_MODULES_DIR ${NODE_MODULES_DIR})

I've tried both solutions locally, they work and allow me to build and run my Android app on Windows.

Could you please provide a fix for windows usage of this library ?
Thanks a lot !

Full error log below,

PS D:\.....> yarn android
yarn run v1.22.19
$ react-native run-android
info A dev server is already running for this project on port 8081.
info Installing the app...

> Task :react-native-pkce-challenge:configureCMakeDebug[arm64-v8a] FAILED
C/C++: CMake Error at CMakeLists.txt:7 (add_library):
C/C++:   Syntax error in cmake code when parsing string
C/C++:     D:\.....\android/../node_modules/react-native/ReactCommon/jsi/jsi/jsi.cpp
C/C++:   Invalid character escape '\w'.
337 actionable tasks: 2 executed, 335 up-to-date

info ๐Ÿ’ก Tip: Make sure that you have set up your development environment correctly, by running npx react-native doctor. To read more about doctor command visit: https://github.com/react-native-community/cli/blob/main/packages/cli-doctor/README.md#doctor 


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-pkce-challenge:configureCMakeDebug[arm64-v8a]'.
> [CXX1429] error when building with cmake using D:\......\node_modules\react-native-pkce-challenge\android\CMakeLists.txt: -- Configuring incomplete, errors occurred!
  See also "D:/......./node_modules/react-native-pkce-challenge/android/.cxx/Debug/493k3528/arm64-v8a/CMakeFiles/CMakeOutput.log".

  C++ build system [configure] failed while executing:
      @echo off
      "C:\\.....\\android-sdk\\cmake\\3.22.1\\bin\\cmake.exe" ^
        "-HD:\\......\\node_modules\\react-native-pkce-challenge\\android" ^
        "-DCMAKE_SYSTEM_NAME=Android" ^
        "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON" ^
        "-DCMAKE_SYSTEM_VERSION=21" ^
        "-DANDROID_PLATFORM=android-21" ^
        "-DANDROID_ABI=arm64-v8a" ^
        "-DCMAKE_ANDROID_ARCH_ABI=arm64-v8a" ^
        "-DANDROID_NDK=C:\\.....\\android-sdk\\ndk\\25.1.8937393" ^
        "-DCMAKE_ANDROID_NDK=C:\\.....\\android-sdk\\ndk\\25.1.8937393" ^
        "-DCMAKE_TOOLCHAIN_FILE=C:\\.....\\android-sdk\\ndk\\25.1.8937393\\build\\cmake\\android.toolchain.cmake" ^
        "-DCMAKE_MAKE_PROGRAM=C:\\.....\\android-sdk\\cmake\\3.22.1\\bin\\ninja.exe" ^
        "-DCMAKE_CXX_FLAGS=-O2 -frtti -fexceptions -Wall -fstack-protector-all" ^
        "-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=D:\\.....\\node_modules\\react-native-pkce-challenge\\android\\build\\intermediates\\cxx\\Debug\\493k3528\\obj\\arm64-v8a" ^
        "-DCMAKE_RUNTIME_OUTPUT_DIRECTORY=D:\\.....\\node_modules\\react-native-pkce-challenge\\android\\build\\intermediates\\cxx\\Debug\\493k3528\\obj\\arm64-v8a" ^
        "-DCMAKE_BUILD_TYPE=Debug" ^
        "-BD:\\.....\\node_modules\\react-native-pkce-challenge\\android\\.cxx\\Debug\\493k3528\\arm64-v8a" ^
        -GNinja ^
>>>>>   "-DNODE_MODULES_DIR=D:\\.....\\android/../node_modules"  <<<<<
    from D:\.....\node_modules\react-native-pkce-challenge\android
  CMake Error at CMakeLists.txt:7 (add_library):
    Syntax error in cmake code when parsing string

      D:\.....\android/../node_modules/react-native/ReactCommon/jsi/jsi/jsi.cpp

    Invalid character escape '\w'.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

ExpoRandom is undifined

Hi! ๐Ÿ‘‹

Firstly, thanks for your work on this project! ๐Ÿ™‚

Today I used patch-package to patch [email protected] for the project I'm working on.

After upgrading this package to 5.1.1, we have a problem with expo. In your upgrade document, you mention that we should remove the ExpoRandom package. But the check in the generate-random-bytes.native.ts expect if the ExpoModules exists, then assumed the ExpoRandom exists too!

Here is the diff that solved my problem:

diff --git a/node_modules/react-native-pkce-challenge/src/generate-random-bytes.native.ts b/node_modules/react-native-pkce-challenge/src/generate-random-bytes.native.ts
index 31db1d6..1f5f1ac 100644
--- a/node_modules/react-native-pkce-challenge/src/generate-random-bytes.native.ts
+++ b/node_modules/react-native-pkce-challenge/src/generate-random-bytes.native.ts
@@ -9,15 +9,16 @@ export default function generateRandomBytes(): string {
 
     return bytes;
   }
+ const globelObj = (global as any)
 
-  if ((global as any).ExpoModules) {
-    const bytes = (global as any).ExpoModules.ExpoRandom.getRandomBase64String(BYTE_LENGTH);
+  if (globelObj?.ExpoModules?.ExpoRandom) {
+    const bytes = globelObj.ExpoRandom.getRandomBase64String(BYTE_LENGTH);
 
     return bytes;
   }
 
-  if ((global as any).RNPkceChallenge) {
-    const bytes = (global as any).RNPkceChallenge.randomBytes(BYTE_LENGTH);
+  if (globelObj?.RNPkceChallenge) {
+    const bytes = globelObj.RNPkceChallenge.randomBytes(BYTE_LENGTH);
 
     return bytes;
   }

This issue body was partially generated by patch-package.

Error in Android app build (c++ version)

Hi! ๐Ÿ‘‹

Firstly, thanks for your work on this project! ๐Ÿ™‚

Today I used patch-package to patch [email protected] for the project I'm working on.

I have an error when building my android app with [email protected].* and [email protected], I think this is because react-native no longer supports c++ 11, using c++ 20 in CMakeLists solves my problem.

Error:

error Failed to install the app. Command failed with exit code 1: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
Execution failed for task ':react-native-pkce-challenge:buildCMakeDebug[arm64-v8a]'.
mobile/android/../node_modules/react-native/ReactCommon/jsi/jsi/jsi.h:1107:23 error: no template named 'enable_if_t' in namespace 'std'; did you mean 'enable_if'? typename = std::enable_if_t< ~~~~~^~~~~~~~~~~ enable_if

Here is the diff that solved my problem:

diff --git a/node_modules/react-native-pkce-challenge/android/CMakeLists.txt b/node_modules/react-native-pkce-challenge/android/CMakeLists.txt
index b6ea016..44f20fa 100644
--- a/node_modules/react-native-pkce-challenge/android/CMakeLists.txt
+++ b/node_modules/react-native-pkce-challenge/android/CMakeLists.txt
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.4.1)
 project(PkceChallenge)
 
 set (CMAKE_VERBOSE_MAKEFILE ON)
-set (CMAKE_CXX_STANDARD 11)
+set (CMAKE_CXX_STANDARD 20)
 
 add_library(cpp
             SHARED

Do you have the same problem?

All works in iOS.

This issue body was partially generated by patch-package.

invalid_grant: PKCE verification failed

Exchange toke request failing with following response.

{"error":"invalid_grant","error_description":"PKCE verification failed"}

React Native: 0.68.5
expo-random: ~12.2.0
react-native-pkce-challenge: ^5.1.1

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.