Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…tion-library-for-js into lalimas/browsercachingupdates
  • Loading branch information
lalimasharda committed Jan 9, 2023
2 parents 6eefe24 + 95220b9 commit eb8174d
Show file tree
Hide file tree
Showing 25 changed files with 1,844 additions and 1,122 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix typos #5531",
"packageName": "@azure/msal-browser",
"email": "bmahal@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "Log number of accounts in trace mode. #5529",
"packageName": "@azure/msal-browser",
"email": "kshabelko@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix typos #5531",
"packageName": "@azure/msal-common",
"email": "bmahal@microsoft.com",
"dependentChangeType": "patch"
}
44 changes: 19 additions & 25 deletions extensions/msal-node-extensions/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"lerna": "3.16.4",
"command": {
"run": {
"scope": [
Expand Down
48 changes: 30 additions & 18 deletions lib/msal-angular/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions lib/msal-browser/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions lib/msal-browser/src/app/PublicClientApplication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export class PublicClientApplication extends ClientApplication implements IPubli
*/
protected async acquireTokenSilentAsync(request: SilentRequest, account: AccountInfo): Promise<AuthenticationResult>{
this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_START, InteractionType.Silent, request);
const astsAsyncMeasurement = this.performanceClient.startMeasurement(PerformanceEvents.AcquireTokenSilentAsync, request.correlationId);
const atsAsyncMeasurement = this.performanceClient.startMeasurement(PerformanceEvents.AcquireTokenSilentAsync, request.correlationId);

let result: Promise<AuthenticationResult>;
if (NativeMessageHandler.isNativeAvailable(this.config, this.logger, this.nativeExtensionProvider, request.authenticationScheme) && account.nativeAccountId) {
Expand Down Expand Up @@ -242,7 +242,7 @@ export class PublicClientApplication extends ClientApplication implements IPubli

return result.then((response) => {
this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_SUCCESS, InteractionType.Silent, response);
astsAsyncMeasurement.endMeasurement({
atsAsyncMeasurement.endMeasurement({
success: true,
fromCache: response.fromCache,
isNativeBroker: response.fromNativeBroker,
Expand All @@ -251,7 +251,7 @@ export class PublicClientApplication extends ClientApplication implements IPubli
return response;
}).catch((tokenRenewalError: AuthError) => {
this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_FAILURE, InteractionType.Silent, null, tokenRenewalError);
astsAsyncMeasurement.endMeasurement({
atsAsyncMeasurement.endMeasurement({
errorCode: tokenRenewalError.errorCode,
subErrorCode: tokenRenewalError.subError,
success: false
Expand Down
20 changes: 11 additions & 9 deletions lib/msal-browser/src/cache/BrowserCacheManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -403,33 +403,33 @@ export class BrowserCacheManager extends CacheManager {
getActiveAccount(): AccountInfo | null {
const activeAccountKeyFilters = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT_FILTERS);
const activeAccountValueFilters = this.getItem(activeAccountKeyFilters);
if (!activeAccountValueFilters) {
if (!activeAccountValueFilters) {
// if new active account cache type isn't found, it's an old version, so look for that instead
this.logger.trace("No active account filters cache schema found, looking for legacy schema");
this.logger.trace("BrowserCacheManager.getActiveAccount: No active account filters cache schema found, looking for legacy schema");
const activeAccountKeyLocal = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT);
const activeAccountValueLocal = this.getItem(activeAccountKeyLocal);
if(!activeAccountValueLocal) {
this.logger.trace("No active account found");
this.logger.trace("BrowserCacheManager.getActiveAccount: No active account found");
return null;
}
const activeAccount = this.getAccountInfoByFilter({localAccountId: activeAccountValueLocal})[0] || null;
if(activeAccount) {
this.logger.trace("Legacy active account cache schema found");
this.logger.trace("Adding active account filters cache schema");
this.logger.trace("BrowserCacheManager.getActiveAccount: Legacy active account cache schema found");
this.logger.trace("BrowserCacheManager.getActiveAccount: Adding active account filters cache schema");
this.setActiveAccount(activeAccount);
return activeAccount;
}
return null;
}
const activeAccountValueObj = this.validateAndParseJson(activeAccountValueFilters) as AccountInfo;
if(activeAccountValueObj) {
this.logger.trace("Active account filters schema found");
this.logger.trace("BrowserCacheManager.getActiveAccount: Active account filters schema found");
return this.getAccountInfoByFilter({
homeAccountId: activeAccountValueObj.homeAccountId,
localAccountId: activeAccountValueObj.localAccountId
})[0] || null;
}
this.logger.trace("No active account found");
this.logger.trace("BrowserCacheManager.getActiveAccount: No active account found");
return null;
}

Expand Down Expand Up @@ -461,6 +461,8 @@ export class BrowserCacheManager extends CacheManager {
*/
getAccountInfoByFilter(accountFilter: Partial<Omit<AccountInfo, "idTokenClaims"|"name">>): AccountInfo[] {
const allAccounts = this.getAllAccounts();
this.logger.trace(`BrowserCacheManager.getAccountInfoByFilter: total ${allAccounts.length} accounts found`);

return allAccounts.filter((accountObj) => {
if (accountFilter.username && accountFilter.username.toLowerCase() !== accountObj.username.toLowerCase()) {
return false;
Expand Down Expand Up @@ -1069,10 +1071,10 @@ export class BrowserCacheManager extends CacheManager {
getRedirectRequestContext(): string | null {
return this.getTemporaryCache(TemporaryCacheKeys.REDIRECT_CONTEXT, true);
}

/**
* Sets application id as the redirect context during AcquireTokenRedirect flow.
* @param value
* @param value
*/
setRedirectRequestContext(value: string): void {
this.setTemporaryCache(TemporaryCacheKeys.REDIRECT_CONTEXT, value, true);
Expand Down
2 changes: 1 addition & 1 deletion lib/msal-browser/src/telemetry/BrowserPerformanceClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class BrowserPerformanceClient extends PerformanceClient implements IPerf
this.guidGenerator = new GuidGenerator(this.browserCrypto);
}

startPerformanceMeasuremeant(measureName: string, correlationId: string): IPerformanceMeasurement {
startPerformanceMeasurement(measureName: string, correlationId: string): IPerformanceMeasurement {
return new BrowserPerformanceMeasurement(measureName, correlationId);
}

Expand Down
Loading

0 comments on commit eb8174d

Please sign in to comment.