wi3land / ionic-appauth

Intergration for OpenId/AppAuth-JS into Ionic V3/4/5
MIT License
95 stars 74 forks source link

Add ability to pass a custom crypto instance #348

Open stewones opened 3 months ago

stewones commented 3 months ago

This is useful for testing PKCE in local environments.

example:

    class CustomCrypto {
      generateRandom(size: number): string {
        // implement with your own crypto method. eg: using the sha256 lib
        return 'random_' + size;
      }
      deriveChallenge(code: string) {
        // implement with your own crypto method. eg: using the sha256 lib
        return Promise.resolve('challenge_' + code);
      }
    }

  const authService = new AuthService(browser, storage, requestor, new CustomCrypto());

also added a test for this new behavior, check the auth-service.spec.ts

fixes https://github.com/wi3land/ionic-appauth/issues/73

mraible commented 2 months ago

@wi3land Can you please review this? It seems to change a lot of code that's not related to the feature.

stewones commented 2 months ago

@wi3land Can you please review this? It seems to change a lot of code that's not related to the feature.

I'm proposing to ignore build files from git.

stewones commented 2 months ago

yo! any updates? so to make it clear, I'm just proposing to:

  1. remove the final build files from git. this is a terrible idea, but I understand if the author disagrees and I can happily revert to its original setup. just let me know. https://github.com/wi3land/ionic-appauth/pull/348/commits/61bab14f3f4491b79dbc27124fad348ddaac471b

  2. allow the AuthService to accept a custom crypto implementation so it's easier for us to test PKCE challenges in non-secure environments https://github.com/wi3land/ionic-appauth/pull/348/commits/3f544b652b9d13f82e15506ba2318eb145e3e0e1