-
Notifications
You must be signed in to change notification settings - Fork 945
First pass at polyfill #3517
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
First pass at polyfill #3517
Conversation
💥 No ChangesetLatest commit: 43c0c18 Merging this PR will not cause any packages to be released. If these changes should not cause updates to packages in this repo, this is fine 🙂 If these changes should be published to npm, you need to add a changeset. This PR includes no changesetsWhen changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types Click here to learn what changesets are, and how to add one. Click here if you're a maintainer who wants to add a changeset to this PR |
7da9610
to
7e0f292
Compare
ba9b8e7
to
5efdcbc
Compare
packages-exp/auth-exp/src/core/persistence/persistence_user_manager.ts
Outdated
Show resolved
Hide resolved
044fba4
to
2935024
Compare
pendingToken, | ||
nonce | ||
} = _tokenResponse as SignInWithIdpResponse; | ||
switch (providerId) { |
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.
Why not just have all of these in the switch statements call Provider.credentialFromResult() like you do for phone auth
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.
good idea, I guess we didn't have these before and I was just copying the old implementation... we should add one to OAuthProvider for the last bit here
2935024
to
cf40fe0
Compare
ed42bf2
to
43c0c18
Compare
Binary Size ReportAffected SDKsNo changes between base commit (937f335) and head commit (53d294d). Test Logs
|
* First pass at polyfill * PR Feedback
* First pass at polyfill * PR Feedback
* First pass at polyfill * PR Feedback
I had to refactor our AuthImpl a lot to get this to work, TLDR we have:
types:
externs.Auth
(new public types)compat.FirebaseAuth
(old public types)auth-exp/AuthCore
(at mostexterns.Auth | compat.FirebaseAuth
, but in reality it's just pared down to the core fields)auth-exp/Auth extends auth-exp/AuthCore
(auth-exp/AuthCore
+ private methods)implementations:
AuthImplCompat implements auth-exp/Auth
AuthImpl extends AuthImplCompat implements externs.Auth
auth-compat-exp/Auth extends AuthImplCompat implements compat.FirebaseAuth
notes:
auth-exp/Auth
->auth-exp/AuthCore
, since it's now a strict subset ofexterns.Auth
we can drop a ton of castsTestAuth
since it implements bothauth-exp/Auth
andexterns.Auth
and doesn't require casting to eitherauth-exp/Auth
should use the unsafe_castAuth
and ensure they never callsetPersistence
,onAuthStateChanged
andonIdTokenStateChanged
since those methods could have different signatures depending on whether an instance ofAuthImpl
orauth-compat-exp/Auth
was passed in.auth-compat-exp/Auth
->externs.Auth
before calling from the polyfill to the new implementation, this cast is unsafe since the signature on the 3 above mentioned changes, hence we must avoid ever calling those methods directlyAuthImplCompat
is generic socurrentUser
types correctly to the right implementationAuthImplCompat
constructor takes aUserProvider
so it can instantiate users of the right classheuristics to follow:
externs.Auth
auth-exp/AuthCore
(true for 99% cases that only need auth forauth.name
), otherwise useauth-exp/Auth
if you or a dependency call one of the_
methods on authTestAuth
externs.Auth
->auth-exp/AuthCore
is freeexterns.Auth
->auth-exp/Auth
is achieved through an unsafe cast by calling_castAuth()
auth-compat-exp/Auth
->externs.Auth
is achieved through an unsafe cast by callingthis.asExtern()
setPersistence
,onAuthStateChanged
oronIdTokenStateChanged
from our code since you have no idea which implementation you're holding on to, use the equivalent_
prefixed methods if you need to call them. Only the user (or integration tests) get to call these directly.