-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
fix(app-check): getToken returns {token: string}
not string
matching firebase-js-sdk
#5979
Conversation
This pull request is being automatically deployed with Vercel (learn more). react-native-firebase – ./🔍 Inspect: https://vercel.com/invertase/react-native-firebase/CJrkUhv5eJQ136v66EZ1JJ3A4SPF react-native-firebase-next – ./website_modular🔍 Inspect: https://vercel.com/invertase/react-native-firebase-next/7t89qCGUzn1AcpGsqb1YcAxocJpb [Deployment for 31c4498 canceled] |
Codecov Report
@@ Coverage Diff @@
## main #5979 +/- ##
============================================
- Coverage 53.04% 52.95% -0.08%
Complexity 622 622
============================================
Files 208 208
Lines 10171 10189 +18
Branches 1618 1619 +1
============================================
+ Hits 5394 5395 +1
- Misses 4523 4540 +17
Partials 254 254 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mmm - first of all, thanks for noticing this, second 🙋 I made this mistake, sorry about that, but third - I think we need to go other direction and return (or somehow simulate and return) an AppCheckTokenResult for real. https://firebase.google.com/docs/reference/js/app-check.md#gettoken - we're trying to mirror the firebase-js-sdk where ever possible and though the AppCheck APIs diverge a bit I think we can get there with this one. Do you think it's possible to actually return AppCheckTokenResult, and alter the return values to be like that? It won't be a breaking change since AppCheck is in beta but I will make certain the release notes warn people in big bold terms so they're paying attention, if it's possible
It should be simple enough to do! I'll quickly rejig the PR so that it confirms to the firebase-js-sdk. |
I couldn't for the life of me get the android project in |
Ah. sorry - the general development style is to actually load the tests/android directory into gradle. It has all of the modules hooked into it correctly for live editing while using the tests app as the "module host", and allowing quick re-runs in an e2e test harness context --> https://github.com/invertase/react-native-firebase/blob/main/tests/README.md Regardless, I'll look through it - thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks correct - originally on review I was thinking we needed to have expireTimeMillis in there as well but when I examined the firebase-js-sdk reference, it really is just an object with nothing but a token: string property in it, so this seems exactly right. I'll approve the CI runs and we'll see how it goes :-)
getToken
return type (should be a string){token: string}
not string
matching firebase-js-sdk
Description
The return type of the
getToken
method is not of type{ token: string }
, but rather of typestring
.On the Android side, the task result here is the
AppCheckTokenResult
class.https://github.com/invertase/react-native-firebase/blob/master/packages/app-check/android/src/main/java/io/invertase/firebase/appcheck/ReactNativeFirebaseAppCheckModule.java#L85
The
AppCheckTokenResult
class itself has agetToken
method, which returns aString
.https://github.com/firebase/firebase-android-sdk/blob/6da8617afe903126afac46ef71b1d857dcfe7ef9/appcheck/firebase-appcheck/src/main/java/com/google/firebase/appcheck/internal/DefaultAppCheckTokenResult.java#L55
Since the string is what is resolved in the Promise, the return type of the javascript method bound to this native code should also be a string.
On the iOS side, the promise is also passed the
token.token
, which should be a string, instead of thetoken
.https://github.com/invertase/react-native-firebase/blob/master/packages/app-check/ios/RNFBAppCheck/RNFBAppCheckModule.m#L101
In our own app, we found that at runtime the
getToken
call was returning a string, so we had to use typescript assertions to prevent compiler errors due to the incorrect type.Related issues
Release Summary
Checklist
Android
iOS
e2e
tests added or updated inpackages/\*\*/e2e
jest
tests added or updated inpackages/\*\*/__tests__
Test Plan
I added a few tests to assert that
getToken
returns a string. It should have already be returning this type, as in the tests it is passed intojwt.decode
, which accepts a string.Think
react-native-firebase
is great? Please consider supporting the project with any of the below:React Native Firebase
andInvertase
on Twitter