Skip to content
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

Remove retries for popup and redirect #7270

Merged
merged 14 commits into from
Aug 28, 2024
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "minor",
"comment": "Remove retry for popup and redirect #7270",
"packageName": "@azure/msal-browser",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "Remove PerformanceEvent for PopupTokenHelper #7270",
"packageName": "@azure/msal-common",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "none",
"comment": "Format fix #7270",
"packageName": "@azure/msal-node",
"email": "[email protected]",
"dependentChangeType": "none"
}
10 changes: 2 additions & 8 deletions lib/msal-browser/apiReview/msal-browser.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,7 @@ declare namespace BrowserAuthErrorCodes {
uninitializedPublicClientApplication,
nativePromptNotSupported,
invalidBase64String,
invalidPopTokenRequest,
failedToRetry
invalidPopTokenRequest
}
}
export { BrowserAuthErrorCodes }
Expand Down Expand Up @@ -840,11 +839,6 @@ export { ExternalTokenResponse }
// @public (undocumented)
const failedToParseResponse = "failed_to_parse_response";

// Warning: (ae-missing-release-tag) "failedToRetry" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
const failedToRetry = "failed_to_retry";

// Warning: (ae-missing-release-tag) "getCurrentUri" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public
Expand Down Expand Up @@ -1679,7 +1673,7 @@ const userCancelled = "user_cancelled";
// Warning: (ae-missing-release-tag) "version" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const version = "3.20.0";
export const version = "3.21.0";

// Warning: (ae-missing-release-tag) "WrapperSKU" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
// Warning: (ae-missing-release-tag) "WrapperSKU" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
Expand Down
95 changes: 0 additions & 95 deletions lib/msal-browser/src/cache/BrowserCacheManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1552,9 +1552,6 @@ export class BrowserCacheManager extends CacheManager {
this.removeTemporaryItem(
this.generateCacheKey(TemporaryCacheKeys.NATIVE_REQUEST)
);
this.removeTemporaryItem(
this.generateCacheKey(TemporaryCacheKeys.REDIRECT_REQUEST)
);
this.setInteractionInProgress(false);
}

Expand Down Expand Up @@ -1616,98 +1613,6 @@ export class BrowserCacheManager extends CacheManager {
this.setInteractionInProgress(false);
}

/**
* Create request retry key to cache retry status
*/
generateRequestRetriedKey(): string {
return `${Constants.CACHE_PREFIX}.${TemporaryCacheKeys.REQUEST_RETRY}.${this.clientId}`;
}

/**
* Gets the request retry value from the cache
*/
getRequestRetried(): number | null {
const requestRetriedKey = this.generateRequestRetriedKey();
const cachedRetryNumber = this.getTemporaryCache(requestRetriedKey);
if (!cachedRetryNumber) {
return null;
}
return parseInt(cachedRetryNumber);
}

/**
* Sets the request retry value to "retried" in the cache
*/
setRequestRetried(): void {
this.logger.trace("BrowserCacheManager.setRequestRetried called");
const requestRetriedKey = this.generateRequestRetriedKey();
this.setTemporaryCache(requestRetriedKey, "1", false);
}

/**
* Removes all request retry values in the cache
*/
removeRequestRetried(): void {
const requestRetriedKey = this.generateRequestRetriedKey();
this.removeTemporaryItem(requestRetriedKey);
}

/**
* Caches the redirectRequest in the cache
* @param redirectRequest
*/
cacheRedirectRequest(redirectRequest: RedirectRequest): void {
this.logger.trace("BrowserCacheManager.cacheRedirectRequest called");
const { ...restParams } = redirectRequest;
delete restParams.onRedirectNavigate;
const encodedValue = JSON.stringify(restParams);

this.setTemporaryCache(
TemporaryCacheKeys.REDIRECT_REQUEST,
encodedValue,
true
);
}

/**
* Gets redirect request from the cache. Logs an error and returns undefined if nothing is found.
*/
getCachedRedirectRequest(): RedirectRequest | undefined {
this.logger.trace(
"BrowserCacheManager.getCachedRedirectRequest called"
);
const cachedRedirectRequest = this.getTemporaryCache(
TemporaryCacheKeys.REDIRECT_REQUEST,
true
);
if (!cachedRedirectRequest) {
this.logger.error(`No cached redirect request found.`);
} else {
this.removeTemporaryItem(
this.generateCacheKey(TemporaryCacheKeys.REDIRECT_REQUEST)
);
let parsedRequest: RedirectRequest;
try {
parsedRequest = JSON.parse(
cachedRedirectRequest
) as RedirectRequest;
} catch (e) {
this.logger.errorPii(
`Attempted to parse: ${cachedRedirectRequest}`
);
this.logger.error(
`Parsing cached redirect request threw with error: ${e}`
);
return;
}

if (parsedRequest) {
return parsedRequest;
}
}
return;
}

cacheCodeRequest(authCodeRequest: CommonAuthorizationCodeRequest): void {
this.logger.trace("BrowserCacheManager.cacheCodeRequest called");

Expand Down
2 changes: 0 additions & 2 deletions lib/msal-browser/src/error/BrowserAuthError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ export const BrowserAuthErrorMessages = {
"Invalid base64 encoded string.",
[BrowserAuthErrorCodes.invalidPopTokenRequest]:
"Invalid PoP token request. The request should not have both a popKid value and signPopToken set to true.",
[BrowserAuthErrorCodes.failedToRetry]:
"Unable to retry failed auth code redemption due to usage of the onRedirectNavigate request parameter. Please set onRedirectNavigate on the PublicClientApplication configuration instead or call loginRedirect again.",
};

/**
Expand Down
1 change: 0 additions & 1 deletion lib/msal-browser/src/error/BrowserAuthErrorCodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,3 @@ export const uninitializedPublicClientApplication =
export const nativePromptNotSupported = "native_prompt_not_supported";
export const invalidBase64String = "invalid_base64_string";
export const invalidPopTokenRequest = "invalid_pop_token_request";
export const failedToRetry = "failed_to_retry";
Loading
Loading