Skip to content
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

Merged
merged 8 commits into from
Dec 31, 2021
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ public void getToken(String appName, boolean forceRefresh, Promise promise) {
getExecutor(),
(task) -> {
if (task.isSuccessful()) {
promise.resolve(task.getResult().getToken());
WritableMap tokenResultMap = Arguments.createMap();
tokenResultMap.putString("token", task.getResult().getToken());
promise.resolve(tokenResultMap);
} else {
Log.e(
TAG,
Expand Down
4 changes: 2 additions & 2 deletions packages/app-check/e2e/appcheck.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('appCheck()', function () {
describe('getToken())', function () {
it('token fetch attempt should work', async function () {
// Our tests configure a debug provider with shared secret so we should get a valid token
const token = await firebase.appCheck().getToken();
const { token } = await firebase.appCheck().getToken();
token.should.not.equal('');
const decodedToken = jwt.decode(token);
decodedToken.aud[1].should.equal('projects/react-native-firebase-testing');
Expand All @@ -53,7 +53,7 @@ describe('appCheck()', function () {

// Force refresh should get a different token?
// TODO sometimes fails on android https://github.com/firebase/firebase-android-sdk/issues/2954
const token2 = await firebase.appCheck().getToken(true);
const { token: token2 } = await firebase.appCheck().getToken(true);
token2.should.not.equal('');
const decodedToken2 = jwt.decode(token2);
decodedToken2.aud[1].should.equal('projects/react-native-firebase-testing');
Expand Down
4 changes: 3 additions & 1 deletion packages/app-check/ios/RNFBAppCheck/RNFBAppCheckModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ - (dispatch_queue_t)methodQueue {
return;
}

resolve(token.token);
NSMutableDictionary *tokenResultDictionary = [NSMutableDictionary new];
tokenResultDictionary[@"token"] = token.token;
resolve(tokenResultDictionary);
}];
}

Expand Down