Skip to content

Add the internal auth interface including proactive refresh #3655

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

Merged
merged 6 commits into from
Aug 24, 2020

Conversation

sam-gc
Copy link
Contributor

@sam-gc sam-gc commented Aug 18, 2020

No description provided.

@changeset-bot
Copy link

changeset-bot bot commented Aug 18, 2020

💥 No Changeset

Latest commit: 207e25a

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 changesets

When 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

@sam-gc sam-gc marked this pull request as ready for review August 18, 2020 20:49
@sam-gc sam-gc requested a review from avolkovi August 18, 2020 20:49
@google-oss-bot
Copy link
Contributor

google-oss-bot commented Aug 18, 2020

Binary Size Report

Affected SDKs

No changes between base commit (c7ef26f) and head commit (03e95cd).

Test Logs

@@ -271,6 +275,20 @@ export class AuthImplCompat<T extends User> implements Auth, _FirebaseService {
return `${this.config.authDomain}:${this.config.apiKey}:${this.name}`;
}

_startProactiveRefresh(): void {
this.isProactiveRefreshEnabled = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need this on the auth object? or should it just live exclusively on the user?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auth needs to know about it because start/stop are tightly coupled with the current user lifecycle.

);
sinon
.stub(user, '_startProactiveRefresh')
.callsFake(() => (isProactiveRefresh = true));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can these just be sinon.spy()'s and you check to make sure they were called?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this better since I'm testing as it gets toggled back and forth. I suppose you could do it by counting the number of times start was called and how many stop was called, but that seems more complicated


export const _AUTH_COMPONENT_NAME = 'auth-exp';
export const _AUTH_INTERNAL_COMPONENT_NAME = 'auth-internal-exp';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this right? or should it be auth-interop?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Feiyang1 for guidance. I believe internal is correct since that's what we do now, but maybe we're changing our language?
https://github.com/firebase/firebase-js-sdk/search?q=%27auth-internal%27&unscoped_q=%27auth-internal%27

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

auth-interna is correct

export class ProactiveRefresh {
private isRunning = false;

// Node timers and browser timers return fundamentally different types.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i have a similar issue in my PR, do you think it's worth extracting the setInterval logic into a common util?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eh that would mean adding more code that is compiled deadweight just to circumvent the type system.

}

private updateProactiveRefresh(): void {
if (this.internalListeners.size > 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we actively refresh for external listeners as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've definitely had feature requests for it. I think it should still be an optional thing you turn on, exposed through a method on user or something

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we going to do it, or this is something for the future?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can add it to the new API proposal and see what kind of feedback we get


export const _AUTH_COMPONENT_NAME = 'auth-exp';
export const _AUTH_INTERNAL_COMPONENT_NAME = 'auth-internal-exp';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

auth-interna is correct

@Feiyang1
Copy link
Member

The registration part for auth-internal looks good to me.

@sam-gc sam-gc force-pushed the samgho/internal-methods branch from dc168e7 to 8a7c658 Compare August 18, 2020 23:10
Base automatically changed from samgho/register-internal to auth-next August 24, 2020 18:26
@sam-gc sam-gc force-pushed the samgho/internal-methods branch from 8a7c658 to 207e25a Compare August 24, 2020 22:54
@sam-gc sam-gc merged commit c1e9229 into auth-next Aug 24, 2020
@sam-gc sam-gc deleted the samgho/internal-methods branch August 24, 2020 22:54
sam-gc added a commit that referenced this pull request Sep 1, 2020
* Proactive refresh and internal SDK

* Fix tests for node

* Formatting

* Remove unused file

* PR feedback

* Formatting
@firebase firebase locked and limited conversation to collaborators Sep 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants