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
[msal-browser] Add platform-level state object to state string and read interaction type #2045
Conversation
// Deserialize hash fragment response parameters. | ||
const hashUrlString: UrlString = new UrlString(hash); | ||
const serverParams: ServerAuthorizationCodeResponse = hashUrlString.getDeserializedHash<ServerAuthorizationCodeResponse>(); | ||
const requestStateObj: RequestStateObject = ProtocolUtils.parseRequestState(this.browserCrypto, serverParams.state); |
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 it make sense to write a helper function that gets the interactionType
from state
? Is this something we might need to do in other places as well?
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.
We can extract this in the future if we need it, but for now this is only needed for redirect flows.
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.
A couple questions, but nothing blocking. LGTM
export enum InteractionType { | ||
REDIRECT = "redirect", | ||
POPUP = "popup", | ||
SILENT = "silent" |
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.
Throttling I believe also has this concept. @jmckennon
|
||
const stateString = JSON.stringify(stateObj); | ||
|
||
return browserCrypto.base64Encode(stateString); |
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.
I don't think this needs to be encoded here. What about returning the stateObj
and then adding that as is to the library state object? That way we are only encoding/stringifying/decoding/parsing once.
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.
I didn't want common to specify the exact object structure, which is why I made it a string. I felt like adding any
type for platformState was too generic. We can talk about this offline.
handleRedirect fixes
This PR addresses an issue where the handleRedirectPromise() code would be processed inside a popup before monitorWindowForHash can detect the hash value. This may happen if the opening window's execution is paused or suspended.
I have added the following: