Skip to content

Validating the private key string #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 10, 2017
Merged

Validating the private key string #20

merged 1 commit into from
May 10, 2017

Conversation

hiranya911
Copy link
Contributor

Currently the admin SDK can be initialized with an invalid private key. The error won't be caught until we try to make an API request using the key, at which point the error would manifest as a server side error:

{ Error: An internal error has occurred. Raw server response: "{}"
    at FirebaseAuthError.Error (native)

This fix parses the private key field when the certificate credential is initialized, and presents the user with a more meaningful error:

Error: Failed to parse private key: Error: Invalid PEM formatted message.
    at FirebaseAppError.Error (native)

I had to bring in node-forge as a dependency to parse private key in PEM. Not sure if that's the best thing to do here. Appreciate any feedback on that.

Copy link

@jshcrowthe jshcrowthe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM 👍 In testing this I discovered that this repo doesn't have a test script to test the repo. We will need to get that implemented.

For reference: https://docs.npmjs.com/misc/scripts

@hiranya911 hiranya911 assigned hiranya911 and unassigned jshcrowthe May 10, 2017
@hiranya911 hiranya911 merged commit 13935e2 into master May 10, 2017
@hiranya911 hiranya911 deleted the hkj-validate-pk branch May 10, 2017 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants