Skip to content

Commit

Permalink
fix(chore): fixed sonar issue
Browse files Browse the repository at this point in the history
fixed sonar issue

GH-125
  • Loading branch information
Karunesh Mani Tripathi committed Nov 21, 2023
1 parent d8f9254 commit aecef18
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// SONAR-IGNORE-ALL
import { inject, Provider } from '@loopback/core';
import { HttpErrors, Request } from '@loopback/rest';
import {inject, Provider} from '@loopback/core';
import {HttpErrors, Request} from '@loopback/rest';
// eslint-disable-next-line @typescript-eslint/naming-convention
import * as ClientPasswordStrategy from './client-password-strategy';

import { AuthErrorKeys } from '../../../error-keys';
import { IAuthClient } from '../../../types';
import { Strategies } from '../../keys';
import { VerifyFunction } from '../../types';
import {AuthErrorKeys} from '../../../error-keys';
import {IAuthClient} from '../../../types';
import {Strategies} from '../../keys';
import {VerifyFunction} from '../../types';

export interface ClientPasswordStrategyFactory {
(
Expand All @@ -22,7 +22,7 @@ export class ClientPasswordStrategyFactoryProvider
constructor(
@inject(Strategies.Passport.OAUTH2_CLIENT_PASSWORD_VERIFIER)
private readonly verifier: VerifyFunction.OauthClientPasswordFn,
) { }
) {}

value(): ClientPasswordStrategyFactory {
return (options, verifier) =>
Expand Down Expand Up @@ -53,7 +53,8 @@ export class ClientPasswordStrategyFactoryProvider
clientSecret: string | undefined,
cb: (err: Error | null, client?: IAuthClient | null) => void,
req: Request | undefined,
) => {//NOSONAR
) => {
//NOSONAR
try {
const client = await verifyFn(clientId, clientSecret, req);
this.clientPasswordVerifierHelper(client, clientSecret);
Expand All @@ -71,7 +72,8 @@ export class ClientPasswordStrategyFactoryProvider
clientId: string,
clientSecret: string | undefined,
cb: (err: Error | null, client?: IAuthClient | null) => void,
) => {//NOSONAR
) => {
//NOSONAR
try {
const client = await verifyFn(clientId, clientSecret);
this.clientPasswordVerifierHelper(client, clientSecret);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { inject, Provider } from '@loopback/core';
import { HttpErrors, Request } from '@loopback/rest';
/* eslint-disable @typescript-eslint/no-misused-promises */
import {inject, Provider} from '@loopback/core';
import {HttpErrors, Request} from '@loopback/rest';
// eslint-disable-next-line @typescript-eslint/naming-convention
import * as ClientPasswordStrategy from './client-password-strategy';

import { AuthErrorKeys } from '../../../error-keys';
import { ClientType, IAuthSecureClient } from '../../../types';
import { Strategies } from '../../keys';
import { VerifyFunction } from '../../types';
import {AuthErrorKeys} from '../../../error-keys';
import {ClientType, IAuthSecureClient} from '../../../types';
import {Strategies} from '../../keys';
import {VerifyFunction} from '../../types';

export interface SecureClientPasswordStrategyFactory {
(
Expand All @@ -21,7 +22,7 @@ export class SecureClientPasswordStrategyFactoryProvider
constructor(
@inject(Strategies.Passport.OAUTH2_CLIENT_PASSWORD_VERIFIER)
private readonly verifier: VerifyFunction.OauthSecureClientPasswordFn,
) { }
) {}

value(): SecureClientPasswordStrategyFactory {
return (options, verifier) =>
Expand All @@ -42,15 +43,15 @@ export class SecureClientPasswordStrategyFactoryProvider
// do nothing
}
}

//prettier-ignore-start
// prettier-ignore
getSecureClientPasswordVerifier(
options?: ClientPasswordStrategy.StrategyOptionsWithRequestInterface,
verifierPassed?: VerifyFunction.OauthSecureClientPasswordFn,
): ClientPasswordStrategy.Strategy {
const verifyFn = verifierPassed ?? this.verifier;
if (options?.passReqToCallback) {
return new ClientPasswordStrategy.Strategy(
// eslint-disable-next-line @typescript-eslint/no-misused-promises
async (
clientId: string,
clientSecret: string | undefined,
Expand All @@ -70,12 +71,10 @@ export class SecureClientPasswordStrategyFactoryProvider
);
} else {
return new ClientPasswordStrategy.Strategy(
// eslint-disable-next-line @typescript-eslint/no-misused-promises
async (
clientId: string,
clientSecret: string | undefined,
cb: (err: Error | null, client?: IAuthSecureClient | null) => void,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
) => {// NOSONAR
try {
const client = await verifyFn(clientId, clientSecret);
Expand All @@ -90,4 +89,5 @@ export class SecureClientPasswordStrategyFactoryProvider
);
}
}
//prettier-ignore-end
}

0 comments on commit aecef18

Please sign in to comment.