Interpret any string in options as an API Key instead of using a regex #660
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
r? @ob-stripe
cc @stripe/api-libraries @jlomas-stripe @paulasjes-stripe @remi-stripe
isAuthKey
relies on a regex which assumes a fixed length of a secret key token. This assumption recently broke.Looking at the code, passing a string which does not fit the regex currently noops completely, so I chose to simply check whether it is a non-empty string and if so, assume it is an auth key.
Note that you could maybe interpret this to be a breaking change, because you could have previously written this:
which would have been equivalent to
stripe.customers.retrieve('cus_123')
and worked fine, but with this change would fail with a bad secret key.I think that's fine, but not sure and want to check with others.
Relatedly, I moved
isAuthKey
fromutils
but that didn't seem to be publicly exported so I think that's fine.