Skip to content

[msal-common][msal-node][#4] Update UnifiedCacheManager.ts #1771

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 14 commits into from
Jun 18, 2020

Conversation

pkanher617
Copy link
Contributor

This PR does the following:

  • Update UnifiedCacheManager.ts to be a class of static functions, rather than a constructed class
  • Make getAllAccounts a static function
  • Move all code dealing with JSON to in-memory serialization to msal-node

@github-actions github-actions bot added msal-browser Related to msal-browser package msal-common Related to msal-common package labels Jun 11, 2020
@pkanher617 pkanher617 changed the base branch from dev to msal-common-scopeset-update June 11, 2020 00:49
@pkanher617 pkanher617 changed the title [msal-common][msal-node] Update UnifiedCacheManager.ts [msal-common][msal-node][#4] Update UnifiedCacheManager.ts Jun 11, 2020
Copy link
Contributor

@sangonzal sangonzal left a 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 we should:

  • Have getAccounts be an API on BaseClient
  • Make all APIs in UnifiedCacheManager be statics

My understanding is that these changes were made because getAccounts and the unifiedCacheManager APIs were not accessible from node.

I think the proper solution to expose getAllAccounts to Node is to construct UnifiedCacheManager in ClientApplication in Node and in PublicClientApplication in browser, and pass that in as part of the BaseClient configuration.

getAccounts and removeAccount can then be part of cacheManager, where they logically belong, and removes the need to make all APIs in UnifiedCacheManager static.

@github-actions github-actions bot added the msal-node Related to msal-node package label Jun 15, 2020
return this.getAccountsFilteredBy();
getAllAccounts(): IAccount[] {
const currentAccounts: AccountCache = this.getAccountsFilteredBy();
const accountValues: AccountEntity[] = Object.values(currentAccounts);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Object.values won't work in IE11 afaik. I think there's already a lot of incompatibility in 2.0 so this won't be the thing that breaks it, but its more to clean up later if/when we do work on compatibility.

Copy link
Member

Choose a reason for hiding this comment

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

good call. @pkanher617 can you please note this to track when we do a recon on msal-common?

Copy link
Collaborator

@tnorling tnorling left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@jmckennon jmckennon left a comment

Choose a reason for hiding this comment

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

Looks good, agreed with Santiago's comments from a few days ago.

Copy link
Contributor

@sangonzal sangonzal left a comment

Choose a reason for hiding this comment

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

Overall looks good.

}
}

export class DefaultStorageClass extends CacheManager {
Copy link
Contributor

@sangonzal sangonzal Jun 16, 2020

Choose a reason for hiding this comment

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

All default implementation are in ClientConfiguration. Seems like this should also go in there?

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 put this here because if the interface ever changes, you can make all the changes in a single file instead of having to jump between here and ClientConfiguration.ts

@@ -33,17 +28,11 @@ export abstract class BaseClient {
protected cryptoUtils: ICrypto;

// Storage Interface
protected cacheStorage: ICacheStorage;
protected cacheStorage: CacheManager;
Copy link
Contributor

Choose a reason for hiding this comment

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

We should either rename CacheManager to CacheStorage, or rename the variables to match the class name.

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 rename the variable to cacheManager.

@pkanher617 pkanher617 changed the base branch from msal-common-scopeset-update to dev June 18, 2020 18:11
Copy link
Member

@sameerag sameerag left a comment

Choose a reason for hiding this comment

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

lgtm. Agree with changing the name to CacheManager

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.9%) to 77.002% when pulling f15b4df on msal-common-unifiedCache-update into a42591f on dev.

@pkanher617 pkanher617 merged commit 25d53da into dev Jun 18, 2020
@sameerag sameerag mentioned this pull request Jun 24, 2020
1 task
@pkanher617 pkanher617 deleted the msal-common-unifiedCache-update branch August 1, 2020 00:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
msal-browser Related to msal-browser package msal-common Related to msal-common package msal-node Related to msal-node package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants