8000 Removed Duplicate HTTP Status enum by Robbie-Microsoft · Pull Request #7767 · AzureAD/microsoft-authentication-library-for-js · GitHub
[go: up one dir, main page]

Skip to content

Removed Duplicate HTTP Status enum #7767

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 3 commits into from
May 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "none",
"comment": "Removed duplicate http status enum #7767",
"packageName": "@azure/msal-common",
"email": "rginsburg@microsoft.com",
"dependentChangeType": "none"
}
15 changes: 5 additions & 10 deletions lib/msal-common/src/authority/RegionDiscovery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { NetworkResponse } from "../network/NetworkResponse.js";
import { IMDSBadResponse } from "../response/IMDSBadResponse.js";
import {
Constants,
HttpStatus,
RegionDiscoverySources,
ResponseCodes,
} from "../utils/Constants.js";
import { RegionDiscoveryMetadata } from "./RegionDiscoveryMetadata.js";
import { ImdsOptions } from "./ImdsOptions.js";
Expand Down Expand Up @@ -75,19 +75,15 @@ export class RegionDiscovery {
this.performanceClient,
this.correlationId
)(Constants.IMDS_VERSION, options);
if (
localIMDSVersionResponse.status ===
ResponseCodes.httpSuccess
) {
if (localIMDSVersionResponse.status === HttpStatus.SUCCESS) {
autodetectedRegionName = localIMDSVersionResponse.body;
regionDiscoveryMetadata.region_source =
RegionDiscoverySources.IMDS;
}

// If the response using the local IMDS version failed, try to fetch the current version of IMDS and retry.
if (
localIMDSVersionResponse.status ===
ResponseCodes.httpBadRequest
localIMDSVersionResponse.status === HttpStatus.BAD_REQUEST
) {
const currentIMDSVersion = await invokeAsync(
this.getCurrentVersion.bind(this),
Expand All @@ -110,8 +106,7 @@ export class RegionDiscovery {
this.correlationId
)(currentIMDSVersion, options);
if (
currentIMDSVersionResponse.status ===
ResponseCodes.httpSuccess
currentIMDSVersionResponse.status === HttpStatus.SUCCESS
) {
autodetectedRegionName =
currentIMDSVersionResponse.body;
Expand Down Expand Up @@ -180,7 +175,7 @@ export class RegionDiscovery {

// When IMDS endpoint is called without the api version query param, bad request response comes back with latest version.
if (
response.status === ResponseCodes.httpBadRequest &&
response.status === HttpStatus.BAD_REQUEST &&
response.body &&
response.body["newest-versions"] &&
response.body["newest-versions"].length > 0
Expand Down
9 changes: 0 additions & 9 deletions lib/msal-common/src/utils/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,15 +326,6 @@ export const PasswordGrantConstants = {
export type PasswordGrantConstants =
(typeof PasswordGrantConstants)[keyof typeof PasswordGrantConstants];

/**
* Response codes
*/
export const ResponseCodes = {
httpSuccess: 200,
httpBadRequest: 400,
} as const;
export type ResponseCodes = (typeof ResponseCodes)[keyof typeof ResponseCodes];

/**
* Region Discovery Sources
*/
Expand Down
0