Skip to content

Commit 09bc2fc

Browse files
refactor(auth)!: align Google auth provider helpers
1 parent 29056da commit 09bc2fc

4 files changed

Lines changed: 36 additions & 6 deletions

File tree

.github/scripts/compare-types/configs/auth.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,6 @@ const config: PackageConfig = {
165165
reason:
166166
'Native provider flows resolve immediately with a UserCredential instead of following the browser redirect contract used by the firebase-js-sdk.',
167167
},
168-
{
169-
name: 'GoogleAuthProvider',
170-
reason:
171-
'RN Firebase now exposes the firebase-js-sdk static fields and OAuthCredential return type, but its native helper class still omits credentialFromResult/credentialFromError helpers because native provider results do not expose web credential extraction.',
172-
},
173168
{
174169
name: 'OAuthProvider',
175170
reason:

packages/auth/e2e/provider.e2e.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,13 @@ describe('auth() -> Providers', function () {
178178
firebase.auth.GoogleAuthProvider.PROVIDER_ID.should.equal('google.com');
179179
});
180180
});
181+
182+
describe('credential extraction helpers', function () {
183+
it('should return null for native provider results and errors', function () {
184+
should.equal(firebase.auth.GoogleAuthProvider.credentialFromResult({}), null);
185+
should.equal(firebase.auth.GoogleAuthProvider.credentialFromError({}), null);
186+
});
187+
});
181188
});
182189

183190
describe('OAuthProvider', function () {
@@ -626,6 +633,15 @@ describe('auth() -> Providers', function () {
626633
GoogleAuthProvider.PROVIDER_ID.should.equal('google.com');
627634
});
628635
});
636+
637+
describe('credential extraction helpers', function () {
638+
it('should return null for native provider results and errors', function () {
639+
const { GoogleAuthProvider } = authModular;
640+
641+
should.equal(GoogleAuthProvider.credentialFromResult({}), null);
642+
should.equal(GoogleAuthProvider.credentialFromError({}), null);
643+
});
644+
});
629645
});
630646

631647
describe('OAuthProvider', function () {

packages/auth/lib/providers/GoogleAuthProvider.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@
1515
*
1616
*/
1717

18-
import type { OAuthCredential } from '../types/auth';
18+
import type { AuthError, OAuthCredential, UserCredential } from '../types/auth';
19+
20+
// Keep the SDK helper signature name while mapping to RNFB's native auth error type.
21+
type FirebaseError = AuthError;
1922

2023
const providerId = 'google.com' as const;
2124

@@ -54,4 +57,12 @@ export default class GoogleAuthProvider {
5457
},
5558
};
5659
}
60+
61+
static credentialFromResult(_userCredential: UserCredential): OAuthCredential | null {
62+
return null;
63+
}
64+
65+
static credentialFromError(_error: FirebaseError): OAuthCredential | null {
66+
return null;
67+
}
5768
}

packages/auth/type-test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,12 @@ const githubCredentialFromError: OAuthCredential | null = GithubAuthProvider.cre
168168
{} as AuthError,
169169
);
170170
const googleCredential: OAuthCredential = GoogleAuthProvider.credential('google-id-token', null);
171+
const googleCredentialFromResult: OAuthCredential | null = GoogleAuthProvider.credentialFromResult(
172+
{} as UserCredential,
173+
);
174+
const googleCredentialFromError: OAuthCredential | null = GoogleAuthProvider.credentialFromError(
175+
{} as AuthError,
176+
);
171177
const twitterCredential: OAuthCredential = TwitterAuthProvider.credential(
172178
'twitter-token',
173179
'twitter-secret',
@@ -191,6 +197,8 @@ console.log(githubCredential.accessToken);
191197
console.log(githubCredentialFromResult?.accessToken);
192198
console.log(githubCredentialFromError?.accessToken);
193199
console.log(googleCredential.idToken);
200+
console.log(googleCredentialFromResult?.idToken);
201+
console.log(googleCredentialFromError?.idToken);
194202
console.log(twitterCredential.accessToken);
195203
console.log(
196204
ActionCodeOperation.VERIFY_EMAIL,

0 commit comments

Comments
 (0)