@azure/msal-node
Advanced tools
Comparing version 2.1.0 to 2.2.0-alpha.0
@@ -0,0 +0,0 @@ import { ICachePlugin, TokenCacheContext } from "@azure/msal-common"; |
@@ -0,0 +0,0 @@ export interface ICacheClient { |
@@ -0,0 +0,0 @@ import { AccountEntity } from "@azure/msal-common"; |
@@ -0,0 +0,0 @@ import { AccountInfo } from "@azure/msal-common"; |
@@ -0,0 +0,0 @@ import { TokenKeys, AccountEntity, IdTokenEntity, AccessTokenEntity, RefreshTokenEntity, AppMetadataEntity, ServerTelemetryEntity, ThrottlingEntity, CacheManager, Logger, ValidCacheType, ICrypto, AuthorityMetadataEntity, ValidCredentialType } from "@azure/msal-common"; |
@@ -0,0 +0,0 @@ import { AccountCache, IdTokenCache, AccessTokenCache, RefreshTokenCache, AppMetadataCache } from "@azure/msal-common"; |
@@ -0,0 +0,0 @@ import { AccountCache, IdTokenCache, AccessTokenCache, RefreshTokenCache, AppMetadataCache } from "@azure/msal-common"; |
@@ -0,0 +0,0 @@ import { AccountCache, IdTokenCache, AccessTokenCache, RefreshTokenCache, AppMetadataCache, ValidCacheType } from "@azure/msal-common"; |
@@ -0,0 +0,0 @@ import { NodeStorage } from "./NodeStorage.js"; |
@@ -0,0 +0,0 @@ import { ClientConfiguration, AuthenticationResult, BaseAuthRequest, Logger, ServerTelemetryManager, AzureRegionConfiguration, AzureCloudOptions, AuthorizationCodePayload } from "@azure/msal-common"; |
@@ -0,0 +0,0 @@ import { CryptoProvider } from "../crypto/CryptoProvider.js"; |
@@ -8,3 +8,2 @@ import { AuthenticationResult, BaseClient, ClientConfiguration, CommonClientCredentialRequest, IAppTokenProvider } from "@azure/msal-common"; | ||
private readonly appTokenProvider?; | ||
private lastCacheOutcome; | ||
constructor(configuration: ClientConfiguration, appTokenProvider?: IAppTokenProvider); | ||
@@ -11,0 +10,0 @@ /** |
@@ -0,0 +0,0 @@ import { ClientApplication } from "./ClientApplication.js"; |
@@ -0,0 +0,0 @@ import { AuthenticationResult, BaseClient, ClientConfiguration, CommonDeviceCodeRequest } from "@azure/msal-common"; |
@@ -0,0 +0,0 @@ import { AuthenticationResult, IAppTokenProvider, Logger } from "@azure/msal-common"; |
@@ -0,0 +0,0 @@ import { AccountInfo, AuthenticationResult, Logger } from "@azure/msal-common"; |
@@ -0,0 +0,0 @@ import { AuthenticationResult, BaseClient, ClientConfiguration, CommonOnBehalfOfRequest } from "@azure/msal-common"; |
@@ -65,3 +65,9 @@ import { AuthenticationResult, AccountInfo } from "@azure/msal-common"; | ||
getAllAccounts(): Promise<AccountInfo[]>; | ||
/** | ||
* Attempts to retrieve the redirectUri from the loopback server. If the loopback server does not start listening for requests within the timeout this will throw. | ||
* @param loopbackClient | ||
* @returns | ||
*/ | ||
private waitForRedirectUri; | ||
} | ||
//# sourceMappingURL=PublicClientApplication.d.ts.map |
@@ -0,0 +0,0 @@ import { AuthenticationResult, BaseClient, ClientConfiguration, CommonUsernamePasswordRequest } from "@azure/msal-common"; |
@@ -0,0 +0,0 @@ /// <reference types="node" /> |
@@ -0,0 +0,0 @@ import { ICrypto, PkceCodes } from "@azure/msal-common"; |
@@ -0,0 +0,0 @@ import { IGuidGenerator } from "@azure/msal-common"; |
@@ -0,0 +0,0 @@ /// <reference types="node" /> |
@@ -0,0 +0,0 @@ import { PkceCodes } from "@azure/msal-common"; |
@@ -0,0 +0,0 @@ import { AuthError } from "@azure/msal-common"; |
@@ -41,4 +41,4 @@ /** | ||
export type { SignOutRequest } from "./request/SignOutRequest.js"; | ||
export { PromptValue, ResponseMode, AuthorizationCodePayload, AuthenticationResult, ServerAuthorizationCodeResponse, IdTokenClaims, AccountInfo, ValidCacheType, AuthError, AuthErrorMessage, ClientAuthError, ClientAuthErrorMessage, ClientConfigurationError, ClientConfigurationErrorMessage, InteractionRequiredAuthError, InteractionRequiredAuthErrorMessage, ServerError, INetworkModule, NetworkRequestOptions, NetworkResponse, Logger, LogLevel, ProtocolMode, ICachePlugin, TokenCacheContext, ISerializableTokenCache, AzureCloudInstance, AzureCloudOptions, IAppTokenProvider, AppTokenProviderParameters, AppTokenProviderResult, } from "@azure/msal-common"; | ||
export { PromptValue, ResponseMode, AuthorizationCodePayload, AuthenticationResult, ServerAuthorizationCodeResponse, IdTokenClaims, AccountInfo, ValidCacheType, AuthError, AuthErrorMessage, AuthErrorCodes, ClientAuthError, ClientAuthErrorCodes, ClientAuthErrorMessage, ClientConfigurationError, ClientConfigurationErrorCodes, ClientConfigurationErrorMessage, InteractionRequiredAuthError, InteractionRequiredAuthErrorCodes, InteractionRequiredAuthErrorMessage, ServerError, INetworkModule, NetworkRequestOptions, NetworkResponse, Logger, LogLevel, ProtocolMode, ICachePlugin, TokenCacheContext, ISerializableTokenCache, AzureCloudInstance, AzureCloudOptions, IAppTokenProvider, AppTokenProviderParameters, AppTokenProviderResult, } from "@azure/msal-common"; | ||
export { version } from "./packageMetadata.js"; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /// <reference types="node" /> |
@@ -0,0 +0,0 @@ import { ServerAuthorizationCodeResponse } from "@azure/msal-common"; |
@@ -0,0 +0,0 @@ import { ServerAuthorizationCodeResponse } from "@azure/msal-common"; |
export declare const name = "@azure/msal-node"; | ||
export declare const version = "2.1.0"; | ||
//# sourceMappingURL=packageMetadata.d.ts.map |
@@ -0,0 +0,0 @@ import { CommonAuthorizationCodeRequest } from "@azure/msal-common"; |
@@ -0,0 +0,0 @@ import { CommonAuthorizationUrlRequest } from "@azure/msal-common"; |
@@ -0,0 +0,0 @@ import { CommonClientCredentialRequest } from "@azure/msal-common"; |
@@ -0,0 +0,0 @@ import { CommonDeviceCodeRequest, DeviceCodeResponse } from "@azure/msal-common"; |
@@ -0,0 +0,0 @@ /// <reference types="node" /> |
@@ -0,0 +0,0 @@ import { CommonOnBehalfOfRequest } from "@azure/msal-common"; |
@@ -0,0 +0,0 @@ import { CommonRefreshTokenRequest } from "@azure/msal-common"; |
@@ -0,0 +0,0 @@ import { AccountInfo } from "@azure/msal-common"; |
@@ -0,0 +0,0 @@ import { AccountInfo, CommonSilentFlowRequest } from "@azure/msal-common"; |
@@ -0,0 +0,0 @@ import { CommonUsernamePasswordRequest } from "@azure/msal-common"; |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /// <reference types="node" /> |
@@ -0,0 +0,0 @@ import { NetworkResponse, UrlToHttpRequestOptions } from "@azure/msal-common"; |
{ | ||
"$schema": "https://json.schemastore.org/package.json", | ||
"name": "@azure/msal-node", | ||
"version": "2.1.0", | ||
"version": "2.2.0-alpha.0", | ||
"author": { | ||
@@ -80,3 +80,3 @@ "name": "Microsoft", | ||
"dependencies": { | ||
"@azure/msal-common": "14.0.3", | ||
"@azure/msal-common": "14.1.0-alpha.0", | ||
"jsonwebtoken": "^9.0.0", | ||
@@ -83,0 +83,0 @@ "uuid": "^8.3.0" |
@@ -31,5 +31,6 @@ /* | ||
AuthorizationCodePayload, | ||
ClientAuthError, | ||
Constants, | ||
StringUtils, | ||
createClientAuthError, | ||
ClientAuthErrorCodes, | ||
} from "@azure/msal-common"; | ||
@@ -371,3 +372,3 @@ import { | ||
if (state !== cachedState) { | ||
throw ClientAuthError.createStateMismatchError(); | ||
throw createClientAuthError(ClientAuthErrorCodes.stateMismatch); | ||
} | ||
@@ -374,0 +375,0 @@ } |
@@ -7,3 +7,8 @@ /* | ||
import jwt from "jsonwebtoken"; | ||
import { TimeUtils, ClientAuthError, Constants } from "@azure/msal-common"; | ||
import { | ||
TimeUtils, | ||
Constants, | ||
createClientAuthError, | ||
ClientAuthErrorCodes, | ||
} from "@azure/msal-common"; | ||
import { CryptoProvider } from "../crypto/CryptoProvider.js"; | ||
@@ -90,3 +95,3 @@ import { EncodingUtils } from "../utils/EncodingUtils.js"; | ||
throw ClientAuthError.createInvalidAssertionError(); | ||
throw createClientAuthError(ClientAuthErrorCodes.invalidAssertion); | ||
} | ||
@@ -93,0 +98,0 @@ |
@@ -13,3 +13,3 @@ /* | ||
CacheOutcome, | ||
ClientAuthError, | ||
ClientAuthErrorCodes, | ||
ClientConfiguration, | ||
@@ -31,2 +31,3 @@ CommonClientCredentialRequest, | ||
UrlString, | ||
createClientAuthError, | ||
} from "@azure/msal-common"; | ||
@@ -40,3 +41,2 @@ | ||
private readonly appTokenProvider?: IAppTokenProvider; | ||
private lastCacheOutcome: CacheOutcome; | ||
@@ -64,3 +64,3 @@ constructor( | ||
const cachedAuthenticationResult = | ||
const [cachedAuthenticationResult, lastCacheOutcome] = | ||
await this.getCachedAuthenticationResult(request); | ||
@@ -70,6 +70,3 @@ | ||
// if the token is not expired but must be refreshed; get a new one in the background | ||
if ( | ||
this.lastCacheOutcome === | ||
CacheOutcome.REFRESH_CACHED_ACCESS_TOKEN | ||
) { | ||
if (lastCacheOutcome === CacheOutcome.PROACTIVELY_REFRESHED) { | ||
this.logger.info( | ||
@@ -79,3 +76,3 @@ "ClientCredentialClient:getCachedAuthenticationResult - Cached access token's refreshOn property has been exceeded'. It's not expired, but must be refreshed." | ||
// return the cached token, don't wait for the result of this request | ||
// refresh the access token in the background | ||
const refreshAccessToken = true; | ||
@@ -89,6 +86,3 @@ await this.executeTokenRequest( | ||
// reset the last cache outcome | ||
this.lastCacheOutcome = CacheOutcome.NO_CACHE_HIT; | ||
// otherwise, the token is not expired and does not need to be refreshed | ||
// return the cached token | ||
return cachedAuthenticationResult; | ||
@@ -105,3 +99,5 @@ } else { | ||
request: CommonClientCredentialRequest | ||
): Promise<AuthenticationResult | null> { | ||
): Promise<[AuthenticationResult | null, CacheOutcome]> { | ||
let lastCacheOutcome: CacheOutcome = CacheOutcome.NOT_APPLICABLE; | ||
// read the user-supplied cache into memory, if applicable | ||
@@ -129,7 +125,6 @@ let cacheContext; | ||
if (!cachedAccessToken) { | ||
this.lastCacheOutcome = CacheOutcome.NO_CACHED_ACCESS_TOKEN; | ||
this.serverTelemetryManager?.setCacheOutcome( | ||
CacheOutcome.NO_CACHED_ACCESS_TOKEN | ||
); | ||
return null; | ||
return [null, CacheOutcome.NO_CACHED_ACCESS_TOKEN]; | ||
} | ||
@@ -144,8 +139,6 @@ | ||
) { | ||
this.lastCacheOutcome = CacheOutcome.CACHED_ACCESS_TOKEN_EXPIRED; | ||
this.serverTelemetryManager?.setCacheOutcome( | ||
CacheOutcome.CACHED_ACCESS_TOKEN_EXPIRED | ||
); | ||
return null; | ||
return [null, CacheOutcome.CACHED_ACCESS_TOKEN_EXPIRED]; | ||
} | ||
@@ -158,21 +151,24 @@ | ||
) { | ||
this.lastCacheOutcome = CacheOutcome.REFRESH_CACHED_ACCESS_TOKEN; | ||
lastCacheOutcome = CacheOutcome.PROACTIVELY_REFRESHED; | ||
this.serverTelemetryManager?.setCacheOutcome( | ||
CacheOutcome.REFRESH_CACHED_ACCESS_TOKEN | ||
CacheOutcome.PROACTIVELY_REFRESHED | ||
); | ||
} | ||
return await ResponseHandler.generateAuthenticationResult( | ||
this.cryptoUtils, | ||
this.authority, | ||
{ | ||
account: null, | ||
idToken: null, | ||
accessToken: cachedAccessToken, | ||
refreshToken: null, | ||
appMetadata: null, | ||
}, | ||
true, | ||
request | ||
); | ||
return [ | ||
await ResponseHandler.generateAuthenticationResult( | ||
this.cryptoUtils, | ||
this.authority, | ||
{ | ||
account: null, | ||
idToken: null, | ||
accessToken: cachedAccessToken, | ||
refreshToken: null, | ||
appMetadata: null, | ||
}, | ||
true, | ||
request | ||
), | ||
lastCacheOutcome, | ||
]; | ||
} | ||
@@ -199,3 +195,5 @@ | ||
} else if (accessTokens.length > 1) { | ||
throw ClientAuthError.createMultipleMatchingTokensInCacheError(); | ||
throw createClientAuthError( | ||
ClientAuthErrorCodes.multipleMatchingTokens | ||
); | ||
} | ||
@@ -202,0 +200,0 @@ return accessTokens[0] as AccessTokenEntity; |
@@ -20,3 +20,2 @@ /* | ||
AuthenticationResult, | ||
ClientAuthError, | ||
AzureRegionConfiguration, | ||
@@ -29,2 +28,4 @@ AuthError, | ||
AADAuthorityConstants, | ||
createClientAuthError, | ||
ClientAuthErrorCodes, | ||
} from "@azure/msal-common"; | ||
@@ -130,3 +131,5 @@ import { IConfidentialClientApplication } from "./IConfidentialClientApplication.js"; | ||
) { | ||
throw ClientAuthError.createMissingTenantIdError(); | ||
throw createClientAuthError( | ||
ClientAuthErrorCodes.missingTenantIdError | ||
); | ||
} | ||
@@ -239,3 +242,5 @@ | ||
) { | ||
throw ClientAuthError.createInvalidCredentialError(); | ||
throw createClientAuthError( | ||
ClientAuthErrorCodes.invalidClientCredential | ||
); | ||
} | ||
@@ -256,3 +261,5 @@ | ||
if (!certificateNotEmpty) { | ||
throw ClientAuthError.createInvalidCredentialError(); | ||
throw createClientAuthError( | ||
ClientAuthErrorCodes.invalidClientCredential | ||
); | ||
} else { | ||
@@ -259,0 +266,0 @@ this.clientAssertion = ClientAssertion.fromCertificate( |
@@ -7,5 +7,6 @@ /* | ||
import { | ||
AuthErrorCodes, | ||
AuthenticationResult, | ||
BaseClient, | ||
ClientAuthError, | ||
ClientAuthErrorCodes, | ||
ClientConfiguration, | ||
@@ -21,6 +22,7 @@ CommonDeviceCodeRequest, | ||
ServerDeviceCodeResponse, | ||
ServerError, | ||
StringUtils, | ||
TimeUtils, | ||
UrlString, | ||
createAuthError, | ||
createClientAuthError, | ||
} from "@azure/msal-common"; | ||
@@ -205,3 +207,5 @@ | ||
); | ||
throw ClientAuthError.createDeviceCodeCancelledError(); | ||
throw createClientAuthError( | ||
ClientAuthErrorCodes.deviceCodePollingCancelled | ||
); | ||
} else if ( | ||
@@ -215,3 +219,5 @@ userSpecifiedTimeout && | ||
); | ||
throw ClientAuthError.createUserTimeoutReachedError(); | ||
throw createClientAuthError( | ||
ClientAuthErrorCodes.userTimeoutReached | ||
); | ||
} else if (TimeUtils.nowSeconds() > deviceCodeExpirationTime) { | ||
@@ -226,3 +232,3 @@ if (userSpecifiedTimeout) { | ||
); | ||
throw ClientAuthError.createDeviceCodeExpiredError(); | ||
throw createClientAuthError(ClientAuthErrorCodes.deviceCodeExpired); | ||
} | ||
@@ -303,3 +309,4 @@ return true; | ||
); | ||
throw ServerError.createPostRequestFailed( | ||
throw createAuthError( | ||
AuthErrorCodes.postRequestFailed, | ||
response.body.error | ||
@@ -321,3 +328,5 @@ ); | ||
this.logger.error("Polling stopped for unknown reasons."); | ||
throw ClientAuthError.createDeviceCodeUnknownError(); | ||
throw createClientAuthError( | ||
ClientAuthErrorCodes.deviceCodeUnknownError | ||
); | ||
} | ||
@@ -324,0 +333,0 @@ |
@@ -17,6 +17,7 @@ /* | ||
CacheOutcome, | ||
ClientAuthError, | ||
ClientAuthErrorCodes, | ||
ClientConfiguration, | ||
CommonOnBehalfOfRequest, | ||
Constants, | ||
createClientAuthError, | ||
CredentialFilter, | ||
@@ -105,3 +106,5 @@ CredentialType, | ||
); | ||
throw ClientAuthError.createRefreshRequiredError(); | ||
throw createClientAuthError( | ||
ClientAuthErrorCodes.tokenRefreshRequired | ||
); | ||
} else if ( | ||
@@ -120,3 +123,5 @@ TimeUtils.isTokenExpired( | ||
); | ||
throw ClientAuthError.createRefreshRequiredError(); | ||
throw createClientAuthError( | ||
ClientAuthErrorCodes.tokenRefreshRequired | ||
); | ||
} | ||
@@ -235,3 +240,5 @@ | ||
} else if (numAccessTokens > 1) { | ||
throw ClientAuthError.createMultipleMatchingTokensInCacheError(); | ||
throw createClientAuthError( | ||
ClientAuthErrorCodes.multipleMatchingTokens | ||
); | ||
} | ||
@@ -238,0 +245,0 @@ |
@@ -6,4 +6,8 @@ /* | ||
import { ApiId, Constants } from "../utils/Constants.js"; | ||
import { | ||
ApiId, | ||
Constants, | ||
LOOPBACK_SERVER_CONSTANTS, | ||
} from "../utils/Constants.js"; | ||
import { | ||
AuthenticationResult, | ||
@@ -30,3 +34,3 @@ CommonDeviceCodeRequest, | ||
import { InteractiveRequest } from "../request/InteractiveRequest.js"; | ||
import { NodeAuthError } from "../error/NodeAuthError.js"; | ||
import { NodeAuthError, NodeAuthErrorMessage } from "../error/NodeAuthError.js"; | ||
import { LoopbackClient } from "../network/LoopbackClient.js"; | ||
@@ -172,10 +176,18 @@ import { SilentFlowRequest } from "../request/SilentFlowRequest.js"; | ||
let authCodeListener: Promise<ServerAuthorizationCodeResponse>; | ||
let authCodeResponse: ServerAuthorizationCodeResponse = {}; | ||
let authCodeListenerError: AuthError | null = null; | ||
try { | ||
authCodeListener = loopbackClient.listenForAuthCode( | ||
successTemplate, | ||
errorTemplate | ||
); | ||
const redirectUri = loopbackClient.getRedirectUri(); | ||
const authCodeListener = loopbackClient | ||
.listenForAuthCode(successTemplate, errorTemplate) | ||
.then((response) => { | ||
authCodeResponse = response; | ||
}) | ||
.catch((e) => { | ||
// Store the promise instead of throwing so we can control when its thrown | ||
authCodeListenerError = e; | ||
}); | ||
// Wait for server to be listening | ||
const redirectUri = await this.waitForRedirectUri(loopbackClient); | ||
const validRequest: AuthorizationUrlRequest = { | ||
@@ -193,5 +205,6 @@ ...remainingProperties, | ||
await openBrowser(authCodeUrl); | ||
const authCodeResponse = await authCodeListener.finally(() => { | ||
loopbackClient.closeServer(); | ||
}); | ||
await authCodeListener; | ||
if (authCodeListenerError) { | ||
throw authCodeListenerError; | ||
} | ||
@@ -216,5 +229,4 @@ if (authCodeResponse.error) { | ||
return this.acquireTokenByCode(tokenRequest); | ||
} catch (e) { | ||
} finally { | ||
loopbackClient.closeServer(); | ||
throw e; | ||
} | ||
@@ -288,2 +300,46 @@ } | ||
} | ||
/** | ||
* Attempts to retrieve the redirectUri from the loopback server. If the loopback server does not start listening for requests within the timeout this will throw. | ||
* @param loopbackClient | ||
* @returns | ||
*/ | ||
private async waitForRedirectUri( | ||
loopbackClient: ILoopbackClient | ||
): Promise<string> { | ||
return new Promise<string>((resolve, reject) => { | ||
let ticks = 0; | ||
const id = setInterval(() => { | ||
if ( | ||
LOOPBACK_SERVER_CONSTANTS.TIMEOUT_MS / | ||
LOOPBACK_SERVER_CONSTANTS.INTERVAL_MS < | ||
ticks | ||
) { | ||
clearInterval(id); | ||
reject(NodeAuthError.createLoopbackServerTimeoutError()); | ||
return; | ||
} | ||
try { | ||
const r = loopbackClient.getRedirectUri(); | ||
clearInterval(id); | ||
resolve(r); | ||
return; | ||
} catch (e) { | ||
if ( | ||
e instanceof AuthError && | ||
e.errorCode === | ||
NodeAuthErrorMessage.noLoopbackServerExists.code | ||
) { | ||
// Loopback server is not listening yet | ||
ticks++; | ||
return; | ||
} | ||
clearInterval(id); | ||
reject(e); | ||
return; | ||
} | ||
}, LOOPBACK_SERVER_CONSTANTS.INTERVAL_MS); | ||
}); | ||
} | ||
} |
@@ -93,7 +93,11 @@ /* | ||
AuthErrorMessage, | ||
AuthErrorCodes, | ||
ClientAuthError, | ||
ClientAuthErrorCodes, | ||
ClientAuthErrorMessage, | ||
ClientConfigurationError, | ||
ClientConfigurationErrorCodes, | ||
ClientConfigurationErrorMessage, | ||
InteractionRequiredAuthError, | ||
InteractionRequiredAuthErrorCodes, | ||
InteractionRequiredAuthErrorMessage, | ||
@@ -100,0 +104,0 @@ ServerError, |
@@ -14,7 +14,7 @@ /* | ||
import { NodeAuthError } from "../error/NodeAuthError.js"; | ||
import { Constants, LOOPBACK_SERVER_CONSTANTS } from "../utils/Constants.js"; | ||
import { Constants } from "../utils/Constants.js"; | ||
import { ILoopbackClient } from "./ILoopbackClient.js"; | ||
export class LoopbackClient implements ILoopbackClient { | ||
private server: http.Server; | ||
private server: http.Server | undefined; | ||
@@ -31,13 +31,10 @@ /** | ||
): Promise<ServerAuthorizationCodeResponse> { | ||
if (!!this.server) { | ||
if (this.server) { | ||
throw NodeAuthError.createLoopbackServerAlreadyExistsError(); | ||
} | ||
const authCodeListener = new Promise<ServerAuthorizationCodeResponse>( | ||
return new Promise<ServerAuthorizationCodeResponse>( | ||
(resolve, reject) => { | ||
this.server = http.createServer( | ||
async ( | ||
req: http.IncomingMessage, | ||
res: http.ServerResponse | ||
) => { | ||
(req: http.IncomingMessage, res: http.ServerResponse) => { | ||
const url = req.url; | ||
@@ -64,3 +61,3 @@ if (!url) { | ||
if (authCodeResponse.code) { | ||
const redirectUri = await this.getRedirectUri(); | ||
const redirectUri = this.getRedirectUri(); | ||
res.writeHead(HttpStatus.REDIRECT, { | ||
@@ -77,24 +74,2 @@ location: redirectUri, | ||
); | ||
// Wait for server to be listening | ||
await new Promise<void>((resolve) => { | ||
let ticks = 0; | ||
const id = setInterval(() => { | ||
if ( | ||
LOOPBACK_SERVER_CONSTANTS.TIMEOUT_MS / | ||
LOOPBACK_SERVER_CONSTANTS.INTERVAL_MS < | ||
ticks | ||
) { | ||
throw NodeAuthError.createLoopbackServerTimeoutError(); | ||
} | ||
if (this.server.listening) { | ||
clearInterval(id); | ||
resolve(); | ||
} | ||
ticks++; | ||
}, LOOPBACK_SERVER_CONSTANTS.INTERVAL_MS); | ||
}); | ||
return authCodeListener; | ||
} | ||
@@ -107,3 +82,3 @@ | ||
getRedirectUri(): string { | ||
if (!this.server) { | ||
if (!this.server || !this.server.listening) { | ||
throw NodeAuthError.createNoLoopbackServerExistsError(); | ||
@@ -127,6 +102,15 @@ } | ||
closeServer(): void { | ||
if (!!this.server) { | ||
if (this.server) { | ||
// Only stops accepting new connections, server will close once open/idle connections are closed. | ||
this.server.close(); | ||
if (typeof this.server.closeAllConnections === "function") { | ||
/* | ||
* Close open/idle connections. This API is available in Node versions 18.2 and higher | ||
*/ | ||
this.server.closeAllConnections(); | ||
} | ||
this.server = undefined; | ||
} | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
711837
14544
2
+ Added@azure/msal-common@14.1.0-alpha.0(transitive)
- Removed@azure/msal-common@14.0.3(transitive)