Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…tion-library-for-js into fix-sourcemap-errors
  • Loading branch information
lalimasharda committed Aug 28, 2023
2 parents 0310631 + b4924fa commit 5987c09
Show file tree
Hide file tree
Showing 57 changed files with 376 additions and 365 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Remove isEmpty helper API",
"packageName": "@azure/msal-browser",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Remove isEmpty helper API",
"packageName": "@azure/msal-common",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Remove isEmpty helper API",
"packageName": "@azure/msal-node",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "close loopback server on error #6387",
"packageName": "@azure/msal-node",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "minor",
"comment": "feat(msal-node): change all relative imports to .js #6399",
"packageName": "@azure/msal-node",
"email": "[email protected]",
"dependentChangeType": "patch"
}
10 changes: 4 additions & 6 deletions lib/msal-browser/src/cache/BrowserCacheManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1556,7 +1556,7 @@ export class BrowserCacheManager extends CacheManager {
JSON.stringify(ccsCredential),
true
);
} else if (!StringUtils.isEmpty(loginHint)) {
} else if (loginHint) {
const ccsCredential: CcsCredential = {
credential: loginHint,
type: CcsCredentialType.UPN,
Expand All @@ -1576,16 +1576,14 @@ export class BrowserCacheManager extends CacheManager {
resetRequestCache(state: string): void {
this.logger.trace("BrowserCacheManager.resetRequestCache called");
// check state and remove associated cache items
if (!StringUtils.isEmpty(state)) {
if (state) {
this.getKeys().forEach((key) => {
if (key.indexOf(state) !== -1) {
this.removeItem(key);
}
});
}

// delete generic interactive request parameters
if (state) {
// delete generic interactive request parameters
this.removeItem(this.generateStateKey(state));
this.removeItem(this.generateNonceKey(state));
this.removeItem(this.generateAuthorityKey(state));
Expand Down Expand Up @@ -1709,7 +1707,7 @@ export class BrowserCacheManager extends CacheManager {
);

// Get cached authority and use if no authority is cached with request.
if (StringUtils.isEmpty(parsedRequest.authority)) {
if (!parsedRequest.authority) {
const authorityCacheKey: string = this.generateAuthorityKey(state);
const cachedAuthority = this.getTemporaryCache(authorityCacheKey);
if (!cachedAuthority) {
Expand Down
4 changes: 2 additions & 2 deletions lib/msal-browser/src/error/BrowserAuthError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License.
*/

import { AuthError, StringUtils } from "@azure/msal-common";
import { AuthError } from "@azure/msal-common";

/**
* BrowserAuthErrorMessage class containing string constants used by error codes and messages.
Expand Down Expand Up @@ -297,7 +297,7 @@ export class BrowserAuthError extends AuthError {
*/
static createPopupWindowError(errDetail?: string): BrowserAuthError {
let errorMessage = BrowserAuthErrorMessage.popupWindowError.desc;
errorMessage = !StringUtils.isEmpty(errDetail)
errorMessage = errDetail
? `${errorMessage} Details: ${errDetail}`
: errorMessage;
return new BrowserAuthError(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ import {
ServerTelemetryManager,
ServerTelemetryRequest,
ClientConfigurationError,
StringUtils,
Authority,
AuthorityOptions,
AuthorityFactory,
IPerformanceClient,
PerformanceEvents,
StringUtils,
} from "@azure/msal-common";
import { BrowserConfiguration } from "../config/Configuration";
import { BrowserCacheManager } from "../cache/BrowserCacheManager";
Expand Down
7 changes: 3 additions & 4 deletions lib/msal-browser/src/interaction_client/PopupClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
ProtocolUtils,
ServerAuthorizationCodeResponse,
PerformanceEvents,
StringUtils,
IPerformanceClient,
Logger,
ICrypto,
Expand Down Expand Up @@ -542,7 +541,7 @@ export class PopupClient extends StandardInteractionClient {
*/
initiateAuthRequest(requestUrl: string, params: PopupParams): Window {
// Check that request url is not empty.
if (!StringUtils.isEmpty(requestUrl)) {
if (requestUrl) {
this.logger.infoPii(`Navigate to: ${requestUrl}`);
// Open the popup window to requestUrl.
return this.openPopup(requestUrl, params);
Expand Down Expand Up @@ -602,7 +601,7 @@ export class PopupClient extends StandardInteractionClient {
} catch (e) {}

// Don't process blank pages or cross domain
if (StringUtils.isEmpty(href) || href === "about:blank") {
if (!href || href === "about:blank") {
return;
}

Expand Down Expand Up @@ -687,7 +686,7 @@ export class PopupClient extends StandardInteractionClient {
} catch (e) {}

// Don't process blank pages or cross domain
if (StringUtils.isEmpty(href) || href === "about:blank") {
if (!href || href === "about:blank") {
return;
}

Expand Down
7 changes: 3 additions & 4 deletions lib/msal-browser/src/interaction_client/SilentIframeClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import {
ICrypto,
Logger,
StringUtils,
PromptValue,
CommonAuthorizationCodeRequest,
AuthorizationCodeClient,
Expand Down Expand Up @@ -82,9 +81,9 @@ export class SilentIframeClient extends StandardInteractionClient {
);
// Check that we have some SSO data
if (
StringUtils.isEmpty(request.loginHint) &&
StringUtils.isEmpty(request.sid) &&
(!request.account || StringUtils.isEmpty(request.account.username))
!request.loginHint &&
!request.sid &&
(!request.account || !request.account.username)
) {
this.logger.warning(
"No user hint provided. The authorization server may need more information to complete this request."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
CommonEndSessionRequest,
ProtocolUtils,
ResponseMode,
StringUtils,
IdTokenClaims,
AccountInfo,
AzureCloudOptions,
Expand Down Expand Up @@ -463,7 +462,7 @@ export abstract class StandardInteractionClient extends BaseInteractionClient {
}

// Check for ADAL/MSAL v1 SSO
if (StringUtils.isEmpty(validatedRequest.loginHint) && !account) {
if (!validatedRequest.loginHint && !account) {
const legacyLoginHint = this.browserStorage.getLegacyLoginHint();
if (legacyLoginHint) {
validatedRequest.loginHint = legacyLoginHint;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import {
AuthorizationCodePayload,
StringUtils,
CommonAuthorizationCodeRequest,
AuthorizationCodeClient,
AuthorityFactory,
Expand Down Expand Up @@ -69,7 +68,7 @@ export class InteractionHandler {
);
this.logger.verbose("InteractionHandler.handleCodeResponse called");
// Check that location hash isn't empty.
if (StringUtils.isEmpty(locationHash)) {
if (!locationHash) {
throw BrowserAuthError.createEmptyHashError();
}

Expand Down
5 changes: 2 additions & 3 deletions lib/msal-browser/src/interaction_handler/RedirectHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import {
AuthorizationCodeClient,
StringUtils,
CommonAuthorizationCodeRequest,
ICrypto,
Authority,
Expand Down Expand Up @@ -64,7 +63,7 @@ export class RedirectHandler extends InteractionHandler {
): Promise<void> {
this.logger.verbose("RedirectHandler.initiateAuthRequest called");
// Navigate if valid URL
if (!StringUtils.isEmpty(requestUrl)) {
if (requestUrl) {
// Cache start page, returns to this page after redirectUri if navigateToLoginRequestUrl is true
if (params.redirectStartPage) {
this.logger.verbose(
Expand Down Expand Up @@ -152,7 +151,7 @@ export class RedirectHandler extends InteractionHandler {
this.logger.verbose("RedirectHandler.handleCodeResponse called");

// Check that location hash isn't empty.
if (StringUtils.isEmpty(locationHash)) {
if (!locationHash) {
throw BrowserAuthError.createEmptyHashError();
}

Expand Down
5 changes: 2 additions & 3 deletions lib/msal-browser/src/interaction_handler/SilentHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import {
UrlString,
StringUtils,
CommonAuthorizationCodeRequest,
AuthorizationCodeClient,
Constants,
Expand Down Expand Up @@ -60,7 +59,7 @@ export class SilentHandler extends InteractionHandler {
this.authCodeRequest.correlationId
);

if (StringUtils.isEmpty(requestUrl)) {
if (!requestUrl) {
// Throw error if request URL is empty.
this.logger.info("Navigate url is empty");
throw BrowserAuthError.createEmptyNavigationUriError();
Expand Down Expand Up @@ -125,7 +124,7 @@ export class SilentHandler extends InteractionHandler {
: Constants.EMPTY_STRING;
} catch (e) {}

if (StringUtils.isEmpty(href) || href === "about:blank") {
if (!href || href === "about:blank") {
return;
}

Expand Down
3 changes: 1 addition & 2 deletions lib/msal-browser/src/utils/BrowserProtocolUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import { InteractionType } from "./BrowserConstants";
import {
StringUtils,
ClientAuthError,
ICrypto,
RequestStateObject,
Expand All @@ -28,7 +27,7 @@ export class BrowserProtocolUtils {
browserCrypto: ICrypto,
state: string
): BrowserStateObject | null {
if (StringUtils.isEmpty(state)) {
if (!state) {
return null;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/msal-common/src/account/AuthToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class AuthToken {
// Claims inside token
claims: TokenClaims;
constructor(rawToken: string, crypto: ICrypto) {
if (StringUtils.isEmpty(rawToken)) {
if (!rawToken) {
throw ClientAuthError.createTokenNullOrEmptyError(rawToken);
}

Expand Down
5 changes: 2 additions & 3 deletions lib/msal-common/src/account/ClientInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*/

import { ClientAuthError } from "../error/ClientAuthError";
import { StringUtils } from "../utils/StringUtils";
import { ICrypto } from "../crypto/ICrypto";
import { Separators, Constants } from "../utils/Constants";

Expand All @@ -25,7 +24,7 @@ export function buildClientInfo(
rawClientInfo: string,
crypto: ICrypto
): ClientInfo {
if (StringUtils.isEmpty(rawClientInfo)) {
if (!rawClientInfo) {
throw ClientAuthError.createClientInfoEmptyError();
}

Expand All @@ -46,7 +45,7 @@ export function buildClientInfo(
export function buildClientInfoFromHomeAccountId(
homeAccountId: string
): ClientInfo {
if (StringUtils.isEmpty(homeAccountId)) {
if (!homeAccountId) {
throw ClientAuthError.createClientInfoDecodingError(
"Home account ID was empty."
);
Expand Down
3 changes: 1 addition & 2 deletions lib/msal-common/src/authority/AuthorityFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import { Authority } from "./Authority";
import { ClientConfigurationError } from "../error/ClientConfigurationError";
import { INetworkModule } from "../network/INetworkModule";
import { StringUtils } from "../utils/StringUtils";
import { ClientAuthError } from "../error/ClientAuthError";
import { ICacheManager } from "../cache/interface/ICacheManager";
import { AuthorityOptions } from "./AuthorityOptions";
Expand Down Expand Up @@ -90,7 +89,7 @@ export class AuthorityFactory {
correlationId?: string
): Authority {
// Throw error if authority url is empty
if (StringUtils.isEmpty(authorityUrl)) {
if (!authorityUrl) {
throw ClientConfigurationError.createUrlEmptyError();
}

Expand Down
5 changes: 1 addition & 4 deletions lib/msal-common/src/cache/entities/AccessTokenEntity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import { CredentialEntity } from "./CredentialEntity";
import { CredentialType, AuthenticationScheme } from "../../utils/Constants";
import { TimeUtils } from "../../utils/TimeUtils";
import { StringUtils } from "../../utils/StringUtils";
import { ICrypto } from "../../crypto/ICrypto";
import { TokenClaims } from "../../account/TokenClaims";
import { AuthToken } from "../../account/AuthToken";
Expand Down Expand Up @@ -101,9 +100,7 @@ export class AccessTokenEntity extends CredentialEntity {
atEntity.target = scopes;
atEntity.userAssertionHash = userAssertionHash;

atEntity.tokenType = StringUtils.isEmpty(tokenType)
? AuthenticationScheme.BEARER
: tokenType;
atEntity.tokenType = tokenType || AuthenticationScheme.BEARER;

if (requestedClaims) {
atEntity.requestedClaims = requestedClaims;
Expand Down
6 changes: 1 addition & 5 deletions lib/msal-common/src/cache/entities/AccountEntity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { Separators, CacheAccountType, Constants } from "../../utils/Constants";
import { Authority } from "../../authority/Authority";
import { ICrypto } from "../../crypto/ICrypto";
import { buildClientInfo } from "../../account/ClientInfo";
import { StringUtils } from "../../utils/StringUtils";
import { AccountInfo } from "../../account/AccountInfo";
import { ClientAuthError } from "../../error/ClientAuthError";
import { AuthorityType } from "../../authority/AuthorityType";
Expand Down Expand Up @@ -239,10 +238,7 @@ export class AccountEntity {
if (serverClientInfo) {
try {
const clientInfo = buildClientInfo(serverClientInfo, cryptoObj);
if (
!StringUtils.isEmpty(clientInfo.uid) &&
!StringUtils.isEmpty(clientInfo.utid)
) {
if (clientInfo.uid && clientInfo.utid) {
return `${clientInfo.uid}${Separators.CLIENT_INFO_SEPARATOR}${clientInfo.utid}`;
}
} catch (e) {}
Expand Down
2 changes: 1 addition & 1 deletion lib/msal-common/src/client/AuthorizationCodeClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ export class AuthorizationCodeClient extends BaseClient {
}

if (
!StringUtils.isEmpty(request.claims) ||
request.claims ||
(this.config.authOptions.clientCapabilities &&
this.config.authOptions.clientCapabilities.length > 0)
) {
Expand Down
12 changes: 3 additions & 9 deletions lib/msal-common/src/logger/Logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* Licensed under the MIT License.
*/

import { StringUtils } from "../utils/StringUtils";
import { LoggerOptions } from "../config/ClientConfiguration";
import { Constants } from "../utils/Constants";

Expand Down Expand Up @@ -126,14 +125,9 @@ export class Logger {
const timestamp = new Date().toUTCString();

// Add correlationId to logs if set, correlationId provided on log messages take precedence
let logHeader: string;
if (!StringUtils.isEmpty(options.correlationId)) {
logHeader = `[${timestamp}] : [${options.correlationId}]`;
} else if (!StringUtils.isEmpty(this.correlationId)) {
logHeader = `[${timestamp}] : [${this.correlationId}]`;
} else {
logHeader = `[${timestamp}]`;
}
const logHeader = `[${timestamp}] : [${
options.correlationId || this.correlationId || ""
}]`;

const log = `${logHeader} : ${this.packageName}@${
this.packageVersion
Expand Down
Loading

0 comments on commit 5987c09

Please sign in to comment.