Skip to content

Commit

Permalink
refactor(any): fix implicit any errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerald Baulig committed May 6, 2024
1 parent 15c1093 commit f731f1c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/accessControlService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class AccessControlService implements AccessControlServiceImplementation

try {
return this.accessController.isAllowed(acsRequest);
} catch (err) { // deny if any error occurs
} catch (err: any) { // deny if any error occurs
this.logger.error('Error evaluating isAllowed request', { code: err.code, message: err.message, stack: err.stack });
return {
decision: Response_Decision.DENY,
Expand All @@ -88,7 +88,7 @@ export class AccessControlService implements AccessControlServiceImplementation
let whatisAllowedResponse: ReverseQuery;
try {
whatisAllowedResponse = await this.accessController.whatIsAllowed(acsRequest);
} catch (err) {
} catch (err: any) {
this.logger.error('Error evaluating whatIsAllowed request', { code: err.code, message: err.message, stack: err.stack });
return {
operation_status: {
Expand Down Expand Up @@ -118,7 +118,7 @@ export class AccessControlService implements AccessControlServiceImplementation

try {
return JSON.parse(object.value.toString());
} catch (err) {
} catch (err: any) {
this.logger.error('Error unmarshalling object', { code: err.code, message: err.message, stack: err.stack });
throw err;
}
Expand Down
9 changes: 5 additions & 4 deletions src/core/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
import { PolicySetWithCombinables, PolicyWithCombinables } from './interfaces.js';
import { RoleAssociation } from '@restorecommerce/rc-grpc-clients/dist/generated-server/io/restorecommerce/auth.js';
import { Topic } from '@restorecommerce/kafka-client';
import { Attribute } from '@restorecommerce/rc-grpc-clients/dist/generated-server/io/restorecommerce/attribute.js';


export const formatTarget = (target: any): Target => {
Expand Down Expand Up @@ -184,7 +185,7 @@ const getUserServiceClient = async () => {
// identity-srv client to resolve subject ID by token
const grpcIDSConfig = cfg.get('client:user');
const loggerCfg = cfg.get('logger');
loggerCfg.esTransformer = (msg) => {
loggerCfg.esTransformer = (msg: any) => {
msg.fields = JSON.stringify(msg.fields);
return msg;
};
Expand Down Expand Up @@ -230,7 +231,7 @@ export async function checkAccessRequest(ctx: ACSClientContext, resource: Resour
let result: DecisionResponse | PolicySetRQResponse;
try {
result = await accessRequest(subject, resource, action, ctx, { operation, roleScopingEntityURN: cfg?.get('authorization:urns:roleScopingEntityURN') });
} catch (err) {
} catch (err: any) {
return {
decision: Response_Decision.DENY,
obligations: [],
Expand Down Expand Up @@ -344,12 +345,12 @@ export const getAllValues = (obj: any, pushedValues: any): any => {
}
};

const nestedAttributesEqual = (redisAttributes, userAttributes) => {
const nestedAttributesEqual = (redisAttributes: Attribute[], userAttributes: Attribute[]) => {
if (!userAttributes) {
return true;
}
if (redisAttributes?.length > 0 && userAttributes?.length > 0) {
return userAttributes.every((obj) => redisAttributes.some((dbObj => dbObj.value === obj.value)));
return userAttributes.every((obj) => redisAttributes.some((dbObj) => dbObj.value === obj.value));
} else if (redisAttributes?.length != userAttributes?.length) {
return false;
}
Expand Down

0 comments on commit f731f1c

Please sign in to comment.