Skip to content

Commit

Permalink
refactor: API refactor in user, organization, auth and agent module (#82
Browse files Browse the repository at this point in the history
)

* docs: add CONTRIBUTING guidelines

Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>

* docs: add company name in LICESE file

Signed-off-by: Ajay Jadhav <jadhavajay@gmail.com>
Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>

* merge dev branch to main (#77)

* fix: Changed the passkey approch

Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>

* feat/fix: Implemented Add passkey for existing users

Signed-off-by: tipusinghaw <tipu.singh@ayanworks.com>

* feat:implemented add passke

Signed-off-by: tipusinghaw <tipu.singh@ayanworks.com>

* fix: login error message

Signed-off-by: tipusinghaw <tipu.singh@ayanworks.com>

---------

Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>
Signed-off-by: tipusinghaw <tipu.singh@ayanworks.com>
Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>

* worked on the master table json file and .env sample refractoring

Signed-off-by: @nishad.shirsat <nishad.shirsat@ayanworks.com>
Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>

* Included credebl-master-table json file in the .gitignore

Signed-off-by: @nishad.shirsat <nishad.shirsat@ayanworks.com>
Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>

* fix: API refactor in user, organization, auth and agent module

Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>

* fix: Changed the passkey approch

Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>

* feat/fix: Implemented Add passkey for existing users

Signed-off-by: tipusinghaw <tipu.singh@ayanworks.com>
Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>

* feat:implemented add passke

Signed-off-by: tipusinghaw <tipu.singh@ayanworks.com>
Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>

* fix: login error message

Signed-off-by: tipusinghaw <tipu.singh@ayanworks.com>
Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>

* Set Validation for the user login

Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>

* Removed unnecessarily conditions in user dto

Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>

* added the role matrix in the organization, user and agent module

Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>

* Added the error handling in the API-gateway

Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>

* Added role guard in user and organization

Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>

* Error handling in the user signin functionality

Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>

* Function name changes in the singin functionality

Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>

* Added activity log success in user

Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>

* Solved the bug regarding in organization update functionality

Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>

* added role guard in user invitation

Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>

* Error handling on api-gateway dto

Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>

* Added veriable for the seed in agent-service

Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>

* Added veriable for the seed on globaly in agent-service

Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>

---------

Signed-off-by: KulkarniShashank <shashank.kulkarni@ayanworks.com>
Signed-off-by: Ajay Jadhav <jadhavajay@gmail.com>
Signed-off-by: tipusinghaw <tipu.singh@ayanworks.com>
Signed-off-by: @nishad.shirsat <nishad.shirsat@ayanworks.com>
Co-authored-by: Ajay Jadhav <ajay@ayanworks.com>
Co-authored-by: Ajay Jadhav <jadhavajay@gmail.com>
Co-authored-by: Nishad Shirsat <103021375+nishad-ayanworks@users.noreply.github.com>
Co-authored-by: @nishad.shirsat <nishad.shirsat@ayanworks.com>
Co-authored-by: tipusinghaw <tipu.singh@ayanworks.com>
  • Loading branch information
6 people authored Sep 20, 2023
1 parent 9f5ca31 commit 32654c6
Show file tree
Hide file tree
Showing 30 changed files with 816 additions and 703 deletions.
58 changes: 7 additions & 51 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
MODE=DEV


SUPABASE_URL= // Please specify your Supabase Url
SUPABASE_KEY= // Please specify your Supabase Anon key
SUPABASE_JWT_SECRET= // Please specify your Supabase jwt secret

API_GATEWAY_PROTOCOL=http
API_GATEWAY_HOST='0.0.0.0'
API_GATEWAY_PORT=5000
Expand All @@ -10,7 +15,6 @@ AGENT_HOST=username@0.0.0.0 // Please specify your agent host VM and IP addres
AWS_ACCOUNT_ID=xxxxx // Please provide your AWS account Id
S3_BUCKET_ARN=arn:aws:s3:::xxxxx // Please provide your AWS bucket arn

TENANT_EMAIL_LOGO=credebl.jpg
API_ENDPOINT=localhost:5000 #Use your local machine IP Address & PORT
API_ENDPOINT_PORT=5000

Expand All @@ -20,68 +24,20 @@ NATS_HOST='0.0.0.0'
NATS_PORT=4222
NATS_URL=nats://0.0.0.0:4222

REDIS_HOST='localhost' # Use IP Address
REDIS_PORT=6379

POSTGRES_HOST=localhost # Use IP Address
POSTGRES_PORT=5432
POSTGRES_USER=postgres
POSTGRES_PASSWORD=xxxxxxxx
POSTGRES_DATABASE=postgres

POSTGRES_MEDIATOR_DATABASE='mediator_agent'
POSTGRES_MEDIATOR_PORT=5431

MEDIATOR_AGENT_LABEL=MediatorAgent
MEDIATOR_AGENT_ENDPOINT=''

SENDGRID_API_KEY=xxxxxxxxxxxxxx // Please provide your sendgrid API key

FRONT_END_URL=http://localhost:3000

FILE_SERVER=credebl-dev-mediator-indypool
FILE_SERVER_PORT=8081
FILE_SERVER_USER=credebl
FILE_SERVER_HOST=0.0.0.0

REMOTE_FILE_DIR='/opt/cb-tails-file-server/tails/tails-files/'
ACCESSIBLE_FILE_LOCATION='tails-files'

LOCAL_FILE_SERVER=/opt/credebl-platform/tails-files/
GCLOUD_ENGINE_PATH=/home/credebl/.ssh/google_compute_engine

AFJ_AGENT_SPIN_UP=/apps/agent-provisioning/AFJ/scripts/start_agent.sh

AGENT_SPIN_UP_FILE=/agent-spinup/scripts/start_agent.sh
LIBINDY_KEY=CE7709D068DB5E88

AGENT_RESTART_SCRIPT=/agent-spinup/scripts/manage_agent.sh
AGENT_STATUS_SCRIPT=/agent-spinup/scripts/status_agent.sh

WALLET_PROVISION_SCRIPT=/agent-spinup/scripts/wallet_provision.sh
WALLET_STORAGE_HOST=localhost # Use IP Address
WALLET_STORAGE_PORT=5432
WALLET_STORAGE_USER=postgres
WALLET_STORAGE_PASSWORD=xxxxxx

KEYCLOAK_DOMAIN=http://localhost:8089/auth/
KEYCLOAK_ADMIN_URL=http://localhost:8089
KEYCLOAK_MASTER_REALM=master
KEYCLOAK_CREDEBL_REALM=credebl-platform
KEYCLOAK_MANAGEMENT_CLIENT_ID=adminClient
KEYCLOAK_MANAGEMENT_CLIENT_SECRET=xxxxxx-xxxx-xxxx-xxxx-xxxxxx #Refer from ADMIN CONSOLE of your Keycloak
KEYCLOAK_MANAGEMENT_ADEYA_CLIENT_ID=adeyaClient
KEYCLOAK_MANAGEMENT_ADEYA_CLIENT_SECRET=xxxxxx-xxxx-xxxx-xxxx-xxxxxx #Refer from ADMIN CONSOLE of your Keycloak

FILE_UPLOAD_PATH_TENANT= /uploadedFiles/tenant-logo/

CRYPTO_PRIVATE_KEY=xxxxx-xxxxx-xxxxx-xxxxx
PLATFORM_URL=https://dev.credebl.com
KEYCLOAK_URL=http://localhost:8089
PLATFORM_PROFILE_MODE=DEV
CRYPTO_PRIVATE_KEY=xxxxx-xxxxx-xxxxx-xxxxx #It should be same as studio UI

AFJ_VERSION=afj-0.4.0:latest
INVOICE_PDF_URL=./invoice-pdf

FIDO_API_ENDPOINT=http://localhost:8000 # Host:port of your FIDO (WebAuthn) Server

Expand All @@ -91,6 +47,7 @@ PLATFORM_SEED= // The seed should consist of 32 characters.
PLATFORM_ID=

AFJ_AGENT_ENDPOINT_PATH=/apps/agent-provisioning/AFJ/endpoints/
DATABASE_URL="postgresql://postgres:xxxxxx@localhost:5432/postgres?schema=public" #Provide supabase postgres url and Use the correct user/pwd, IP Address

# This was inserted by prisma init:
# Environment variables declared in this file are automatically made available to Prisma.
Expand All @@ -99,7 +56,6 @@ AFJ_AGENT_ENDPOINT_PATH=/apps/agent-provisioning/AFJ/endpoints/
# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB (Preview).
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings

DATABASE_URL="postgresql://postgres:xxxxxx@localhost:5432/postgres?schema=public" #Use the correct user/pwd, IP Address

# enable only prisma:engine-level debugging output
export DEBUG="prisma:engine"
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ uploadedFiles
sonar-project.properties
.scannerwork/*
coverage
libs/prisma-service/prisma/data/credebl-master-table.json
libs/prisma-service/prisma/data/credebl-master-table.json
20 changes: 10 additions & 10 deletions apps/agent-service/src/agent-service.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export class AgentServiceService {
return internalIp;
} catch (error) {
this.logger.error(`error in valid internal ip : ${JSON.stringify(error)}`);
throw new RpcException(error.response);
throw new RpcException(error.response ? error.response : error);
}
}

Expand Down Expand Up @@ -573,7 +573,7 @@ export class AgentServiceService {
});
socket.emit('error-in-wallet-creation-process', { clientId: payload.clientSocketId, error });
}
throw new RpcException(error.response);
throw new RpcException(error.response ? error.response : error);
}
}

Expand Down Expand Up @@ -739,7 +739,7 @@ export class AgentServiceService {
return data;
} catch (error) {
this.logger.error(`Error in connection Invitation in agent service : ${JSON.stringify(error)}`);
throw new RpcException(error);
throw new RpcException(error.response ? error.response : error);
}
}

Expand All @@ -761,7 +761,7 @@ export class AgentServiceService {
return getProofPresentationsData;
} catch (error) {
this.logger.error(`Error in proof presentations in agent service : ${JSON.stringify(error)}`);
throw new RpcException(error);
throw new RpcException(error.response ? error.response : error);
}
}

Expand All @@ -783,7 +783,7 @@ export class AgentServiceService {
return getProofPresentationById;
} catch (error) {
this.logger.error(`Error in proof presentation by id in agent service : ${JSON.stringify(error)}`);
throw new RpcException(error);
throw new RpcException(error.response ? error.response : error);
}
}

Expand All @@ -805,7 +805,7 @@ export class AgentServiceService {
return sendProofRequest;
} catch (error) {
this.logger.error(`Error in send proof request in agent service : ${JSON.stringify(error)}`);
throw new RpcException(error);
throw new RpcException(error.response ? error.response : error);
}
}

Expand All @@ -817,7 +817,7 @@ export class AgentServiceService {
return verifyPresentation;
} catch (error) {
this.logger.error(`Error in verify proof presentation in agent service : ${JSON.stringify(error)}`);
throw new RpcException(error);
throw new RpcException(error.response ? error.response : error);
}
}

Expand Down Expand Up @@ -860,7 +860,7 @@ export class AgentServiceService {

} catch (error) {
this.logger.error(`Agent health details : ${JSON.stringify(error)}`);
throw new RpcException(error);
throw new RpcException(error.response ? error.response : error);
}
}

Expand All @@ -872,7 +872,7 @@ export class AgentServiceService {
return sendProofRequest;
} catch (error) {
this.logger.error(`Error in send out of band proof request in agent service : ${JSON.stringify(error)}`);
throw new RpcException(error);
throw new RpcException(error.response ? error.response : error);
}
}

Expand All @@ -884,7 +884,7 @@ export class AgentServiceService {
return getProofFormData;
} catch (error) {
this.logger.error(`Error in get proof form data in agent service : ${JSON.stringify(error)}`);
throw new RpcException(error);
throw new RpcException(error.response ? error.response : error);
}
}
}
Expand Down
48 changes: 42 additions & 6 deletions apps/api-gateway/common/exception-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,48 @@ export class CustomExceptionFilter extends BaseExceptionFilter {
exception.message = 'Oops! Something went wrong. Please try again';
}

const errorResponse = {
statusCode: status,
message: exception.message || 'Internal server error',
error: exception.message
};
let errorResponse;
if (exception && exception["statusCode"] === HttpStatus.INTERNAL_SERVER_ERROR) {
errorResponse = {
statusCode: status,
message: 'Oops! Something went wrong. Please try again',
error: 'Oops! Something went wrong. Please try again'
};
} else if (exception && exception["statusCode"] === undefined && status === HttpStatus.INTERNAL_SERVER_ERROR) {
errorResponse = {
statusCode: status,
message: 'Oops! Something went wrong. Please try again',
error: 'Oops! Something went wrong. Please try again'
};
} else {
if (exception && exception["response"] && exception.message) {

response.status(status).json(errorResponse);
if (Array.isArray(exception["response"].message)) {
exception["response"].message.forEach((msg) => {
errorResponse = {
statusCode: exception["statusCode"] ? exception["statusCode"] : status,
message: msg || 'Internal server error',
error: msg || 'Internal server error'
};
});
} else {
errorResponse = {
statusCode: exception["statusCode"] ? exception["statusCode"] : status,
message: exception["response"].message ? exception["response"].message : exception["response"] ? exception["response"] : 'Internal server error',
error: exception["response"].message ? exception["response"].message : exception["response"] ? exception["response"] : 'Internal server error'
};
}
} else if (exception && exception.message) {

errorResponse = {
statusCode: exception["statusCode"] ? exception["statusCode"] : status,
message: exception.message || 'Internal server error',
error: exception.message || 'Internal server error'
};

}
}

response.status(errorResponse.statusCode).json(errorResponse);
}
}
Loading

0 comments on commit 32654c6

Please sign in to comment.