-
Notifications
You must be signed in to change notification settings - Fork 930
Add a resaturation function for auth User instances #4484
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
base: main
Are you sure you want to change the base?
Conversation
|
b86c40d
to
5ac8e3b
Compare
Size Analysis ReportAffected Products
|
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.
Code LGTM, will approve after API proposal is reviewed and finalized
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.
LGTM. Lint will pass once you merge the branch with master.
This is exactly what I need. Any workarounds I can use until this is merged? |
Any movement on this PR? I would really like to keep my client-side node apps running in stateless containers authenticated with a first-party solution |
@sam-gc A feature like this would be extremely useful for MV3 Chrome Extensions, where the background service worker has a short lifespan. In MV3, authentication is crippled, see #5588 If the authentication could be handled on a normal website, and the user data passed to the extension via external messaging, then the extension could authenticate using This way, the authentication use case is greatly simplified, and the Chrome extension code is not concerned with authentication itself. |
@@ -317,3 +318,7 @@ export class UserImpl implements User { | |||
return user; | |||
} | |||
} | |||
|
|||
export function userFromJSON(auth: externs.Auth, json: string): externs.User { | |||
return UserImpl._fromJSON(_castAuth(auth), JSON.parse(json)); |
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.
Would be helpful if this could take a plain object as well (some storage solutions parse the JSON automatically), for example:
const userObj = typeof json === "string" ? JSON.parse(json) : json;
return UserImpl._fromJSON(_castAuth(auth), userObj);
Was this function 'userFromJSON' ever released? I can't seem to find it in any documentation. As mentioned above, Chrome Extension firebase google authentication is very hard to achieve in the main extension context. The only viable option is to do the authentication offscreen and then use 'updateCurrentUser' to populate the Auth of the main context. But that requires creating a new user from the stingified creds passed to the main context via messaging. |
This allows symmetry for the user object:
This also allows more flexibility in environments whose storage we don't always fully support (see #1874, #4468)
Pending API review.