ionic-appauth icon indicating copy to clipboard operation
ionic-appauth copied to clipboard

Add ability to pass a custom crypto instance

Open stewones opened this issue 1 year ago • 4 comments

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

stewones avatar May 08 '24 14:05 stewones

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

mraible avatar May 29 '24 18:05 mraible

@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 avatar May 29 '24 22:05 stewones

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

stewones avatar Jun 12 '24 19:06 stewones

Please add this!

jsonhero avatar Sep 27 '24 06:09 jsonhero