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-node][#2] Merge cache logic in msal-common
for node
and browser
platforms
#1762
Conversation
msal-common
for node
and browser
platforms msal-common
for node
and browser
platforms
const itemCookie = this.getItemCookie(msalKey); | ||
if (this.cacheConfig.storeAuthStateInCookie && itemCookie) { | ||
return itemCookie; | ||
getItem(key: string, type: string): string | object { |
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.
Per discussion with @pkanher617, instead of baking this business logic into these functions, you should instead create an abstract class with functions for each of the case
statements, and then have BrowserStorage
implement ICacheStorage
and extend the abstract class.
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.
That way consumers can use a use-case specific function instead of passing a magic string, and that way if applications provide their own storage implementations, they don't have to know about this logic.
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 will revisit this when we add the feature for consumer driven storage.
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 already have consumer driven storage for Node that we want to support (the extensions library).
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.
@sameerag @pkanher617 Let's talk about this next design meeting.
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 also have other storage scenarios for the web such as VS code extensions that we will want to support, which would fall under "user-provided storage"
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.
The abstract class is now implemented in the follow up PR #1771. Regarding abstracting getItem
implementation, I agree we can improve it for custom storage
, however I would like to track it separately and as an enhancement.
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 prioritize if we can arrive at a design soon but considering the timelines to get a working branch earlier, I would like to close this PR.
…built on this)
This PR merges the cache operations for
node
andbrowser
platforms. It:browser
andSPA Client
cc @pkanher617