Code Monkey home page Code Monkey logo

Comments (3)

Vishwa52 avatar Vishwa52 commented on August 23, 2024 1

In addition to the solution @davecoffin mentioned, Here is the function and imports that generate a verifier to create a challenge:

Install crypto-es with the following command:
npm i crypto-es

// crypto-es to use base64 and sha256 encryption.
import CryptoES from 'crypto-es';
const Base64 = CryptoES.enc.Base64;
const sha256 = CryptoES.SHA256;

getRandomValues(size) {
    size = size >= 43 && size <= 128 ? size : 128;

    let benchStr = '';
    const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
    for (let i = 0; i < size; i++) {
      benchStr += possible.charAt(Math.floor(Math.random() * possible.length));
    }

    return benchStr;
}

from nativescript-auth0.

JimLynchCodes avatar JimLynchCodes commented on August 23, 2024

Bump! 🙃

from nativescript-auth0.

davecoffin avatar davecoffin commented on August 23, 2024

I am also having this problem... my esteemed colleague @Vishwa52 has figured a workaround, but its unclear why this isnt working.
Here's his solution:
in safariWebAuth.js, replace the handler with this:

handler(redirectURL) {
        if (this.responseType.indexOf(ResponseType.code) > -1) {
            const authentication = new Auth0Authentication(this.clientId, this.url, this.telemetry);
            authentication.logger = this.logger;
            const verifier = this.getRandomValues(32)
            const challenge = Base64.stringify(sha256(verifier)).replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '');

            return new PKCE(authentication, redirectURL, verifier, challenge, 'S256', this.responseType, this.nonce);
            // return PKCE.init(authentication, redirectURL, this.responseType, this.nonce);
        }
        else {
            return new ImplicitGrant(this.responseType, this.nonce);
        }
    }

It just skips the A0SHA256ChallengeGenerator and generates one manually. @NathanWalker any ideas?

from nativescript-auth0.

Related Issues (20)

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.