Skip to content

Commit

Permalink
Human APP backend - 3rd milestone (#1996)
Browse files Browse the repository at this point in the history
* Merge pull request #17 from blockydevs/error_handling

Error handling - exception filters

* Merge pull request #15 from blockydevs/10-jobs-discovery

Endpoint to fetch jobs discovery

* Merge pull request #16 from blockydevs/11-job-assignment

Endpoint to assign a job to user and to retrieve assigned jobs

* Merge pull request #18 from blockydevs/authorization-token-handling

Middleware to pass the auth token

* Merge pull request #21 from blockydevs/unit_tests_fix

fix: unit tests

* Merge pull request #14 from blockydevs/#13-Oracles-discovery

Oracles-discovery

* Merge pull request #20 from blockydevs/#Statistics-Exchange-oracle

# Statistics exchange oracle

* Naming covention alignemnt (#27)

* Alignment of naming convention and endpoint structure

* Alignment of naming convention and endpoint structure

* ExchangeOracleApi->ExchangeOracle

* externalApiGateway-> gateway

* Coverage improvement

* CI/CD workflow

* fix(unit tests): Remove validationSchema from ConfigModule

* Fixes after check

* Removes unnecessary comment

* Fixes SDK limitation

* Removes unnecessary interceptor, changes Body to Query in request for oracle discovery

* Adds statistics related DTO interfaces with api mapping

* Changes in interface naming convention of received data

* Review fixes

* Review fixes

* Review fixes

* Review fixes

* Changes logic of calling exchange oracle: url is obtained based on the address provided in the enpoint. Adds CORS

* Adds test coverage

* Adds test coverage

* Adds kv store to the modules that use it

* minor fixes

* minor fixes

* Alignment of the swagger and interface used in the project

* Alignment after testing with stage exchange oracle (#29)

* Fixes after check

* Removes unnecessary comment

* Fixes SDK limitation

* Removes unnecessary interceptor, changes Body to Query in request for oracle discovery

* Adds statistics related DTO interfaces with api mapping

* Changes in interface naming convention of received data

* Review fixes

* Review fixes

* Review fixes

* Review fixes

* Changes logic of calling exchange oracle: url is obtained based on the address provided in the enpoint. Adds CORS

* Adds test coverage

* Adds test coverage

* Adds kv store to the modules that use it

* minor fixes

* minor fixes

* Alignment of the swagger and interface used in the project

* Minor fixes

* Minor fixes

* Minor fixes

* Minor fixes

* Removes todo

* Review fixes

* Review fixes

* Review fixes

* Review fixes

* Add email verification endpoints and related logic.

* name: human-app -> human-app-server in package.json (#63)

* Implement password reset functionality.

* Add disableOperator and prepareSignature methods.

* A property has been set in the eslint config to avoid enforcing a line break style.

* Implement KYC procedure start.

* Integration with the KYC procedure, password reset and disable operator modules.

* The variable name 'restorePasswordDto' in the sendRestorePassword function has been changed to 'restorePasswordData'.

* Update 'type' field data type in PrepareSignature model.

* Refactor prepareSignature test and update response fixture.

* Refactor service injections in multiple controllers, renamed to a generic 'service' format.

* Refactor services to use 'gateway' instead of 'reputationOracleService'.

* Sets base paths in the controllers and simplify the path of each endpoint.

* Refactor email verification test fixtures.

* Refactor 'h_captcha_token'.

* Enhance test coverage for oracle gateway.

* bug fixed

* Remove hCaptcha token mapping in user-worker and password-reset mappers.

* Refactor code to separate PrepareSignature functionality into its own module. (#71)

* fix: Change naming conventions in password-reset mapper.

* Fixes after code review (2024-05-07) (#75)

* File `global-common.interface.ts` has been renamed to `global-common.ts`.

* Renamed and moved EnvironmentVariableMissingError class.

* Renamed and moved Pageable classes to utils directory.

* Remove unused import in exchange-oracle.gateway.spec.ts

* Remove console.log from fetchAssignedJobs method.

* Update dependencies in package.json.

* Update terminology in README.md

* Remove unused Headers import from job-assignment.controller.ts

* Removed OnModuleInit import from kv-store-gateway.service.ts

* Corrected the data types for REDIS_PORT and REDIS_HOST in .env.example file.

* Remove redundant volume configuration in Docker-compose

* Add RPC_URL environment variable to docker-compose

* Replace hardcoded URL_KEY in KvStoreGateway with imported constant.

* fix: Update KVStoreClient import and test in KvStoreGateway

* Add Reputation Oracle address to .env and refactor Oracle Discovery.

* Add token authentication for Oracle statistics.

* Remove manual environment variable check.

* Refactor address to use escrowAddress in job assignment service.

* Ensure environment variables validation takes place before module loading.

* Revert "Add token authentication for Oracle statistics."

* Update terminology from 'Interfaces' to 'Model' in README

* Refactor PageableClasses to PageableDto and the file renamed from pageable-classes.ts to pageable.model.ts

* Update KV store gateway test to use actual SDK.

* Added REPUTATION_ORACLE_ADDRESS in app configuration and docker compose file.

* Integrate and use EscrowUtils for job assignment processing.

* Added chainId parameter to `getExchangeOracleAddressByEscrowAddress` method.

* Remove redundant code KV-store gateway test

* Update EscrowUtilsGateway tests.

* Add mock ConfigService to oracle-discovery service test.

* Revert "Add mock ConfigService to oracle-discovery service test."

This reverts commit a2134ad.

* Update oracle-discovery.service.spec.ts tests.

* Fixes CR 2024-05-10 (#78)

* The KVStoreKeys.url constant is now directly called.

* Changed Redis data volume path and updated gitignore.

* Refactor oracle discovery and statistics modules.

* Add CHAIN_IDS_ENABLED to .env.example

* Fix typo in oracle-discovery.service file name and references.

* Merge conflict fixes

* Adds Email Confirmation, KYC procedure, Password Reset and Disable Operator modules. (#64)

* Fixes after check

* Removes unnecessary comment

* Fixes SDK limitation

* Removes unnecessary interceptor, changes Body to Query in request for oracle discovery

* Adds statistics related DTO interfaces with api mapping

* Changes in interface naming convention of received data

* Review fixes

* Review fixes

* Review fixes

* Review fixes

* Changes logic of calling exchange oracle: url is obtained based on the address provided in the enpoint. Adds CORS

* Adds test coverage

* Adds test coverage

* Adds kv store to the modules that use it

* minor fixes

* minor fixes

* Alignment of the swagger and interface used in the project

* Add email verification endpoints and related logic.

* Implement password reset functionality.

* Add disableOperator and prepareSignature methods.

* A property has been set in the eslint config to avoid enforcing a line break style.

* Implement KYC procedure start.

* Integration with the KYC procedure, password reset and disable operator modules.

* The variable name 'restorePasswordDto' in the sendRestorePassword function has been changed to 'restorePasswordData'.

* Update 'type' field data type in PrepareSignature model.

* Refactor prepareSignature test and update response fixture.

* Refactor service injections in multiple controllers, renamed to a generic 'service' format.

* Refactor services to use 'gateway' instead of 'reputationOracleService'.

* Sets base paths in the controllers and simplify the path of each endpoint.

* Refactor email verification test fixtures.

* Refactor 'h_captcha_token'.

* Enhance test coverage for oracle gateway.

* bug fixed

* Remove hCaptcha token mapping in user-worker and password-reset mappers.

* Refactor code to separate PrepareSignature functionality into its own module. (#71)

* fix: Change naming conventions in password-reset mapper.

* Merge conflict fixes

---------

Co-authored-by: maciek.nabialek <[email protected]>

* Fixes CR 2024-05-15 (#88)

* Implement token authentication in KYC procedure start.

* Update endpoint in gateway config and add new signature types.

* Fixed tests.

* Remove 'CERTIFICATE_AUTHENTICATION' from global-common enums.

* Fixed reputation-oracle.gateway.spec.ts (#90)

* Removes authorisation from prepare-signature endpoint (#92)

---------

Co-authored-by: MWBlocky <[email protected]>
Co-authored-by: macnablocky <[email protected]>
Co-authored-by: MWBlocky <[email protected]>
Co-authored-by: maciek.nabialek <[email protected]>
  • Loading branch information
5 people authored May 16, 2024
1 parent 4a1e9e9 commit 054c23e
Show file tree
Hide file tree
Showing 67 changed files with 2,195 additions and 114 deletions.
1 change: 1 addition & 0 deletions packages/apps/human-app/server/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ module.exports = {
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'linebreak-style': 0,
},
};
10 changes: 10 additions & 0 deletions packages/apps/human-app/server/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ import { StatisticsModule } from './modules/statistics/statistics.module';
import { StatisticsController } from './modules/statistics/statistics.controller';
import { ExchangeOracleModule } from './integrations/exchange-oracle/exchange-oracle.module';
import { KvStoreModule } from './integrations/kv-store/kv-store.module';
import { EmailConfirmationModule } from './modules/email-confirmation/email-confirmation.module';
import { PasswordResetModule } from './modules/password-reset/password-reset.module';
import { DisableOperatorModule } from './modules/disable-operator/disable-operator.module';
import { KycProcedureModule } from './modules/kyc-procedure/kyc-procedure.module';
import { PrepareSignatureModule } from './modules/prepare-signature/prepare-signature.module';
import { EscrowUtilsModule } from './integrations/escrow/escrow-utils.module';
import Joi from 'joi';
import { ChainId } from '@human-protocol/sdk';
Expand Down Expand Up @@ -69,6 +74,11 @@ import { ChainId } from '@human-protocol/sdk';
OracleDiscoveryModule,
StatisticsModule,
KvStoreModule,
EmailConfirmationModule,
PasswordResetModule,
DisableOperatorModule,
KycProcedureModule,
PrepareSignatureModule,
EscrowUtilsModule,
],
controllers: [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const gatewayConfigServiceMock = {
getConfig: jest.fn().mockReturnValue({
url: 'https://expample.com',
url: 'https://example.com',
endpoints: {
WORKER_SIGNUP: {
endpoint: '/auth/signup',
Expand All @@ -17,6 +17,41 @@ export const gatewayConfigServiceMock = {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
},
EMAIL_VERIFICATION: {
endpoint: '/auth/email-verification',
method: 'POST',
headers: { 'Content-Type': 'application/json' },
},
RESEND_EMAIL_VERIFICATION: {
endpoint: '/auth/resend-email-verification',
method: 'POST',
headers: { 'Content-Type': 'application/json' },
},
FORGOT_PASSWORD: {
endpoint: '/auth/forgot-password',
method: 'POST',
headers: { 'Content-Type': 'application/json' },
},
RESTORE_PASSWORD: {
endpoint: '/auth/restore-password',
method: 'POST',
headers: { 'Content-Type': 'application/json' },
},
PREPARE_SIGNATURE: {
endpoint: '/user/prepare-signature',
method: 'POST',
headers: { 'Content-Type': 'application/json' },
},
DISABLE_OPERATOR: {
endpoint: '/user/disable-operator',
method: 'POST',
headers: { 'Content-Type': 'application/json' },
},
KYC_PROCEDURE_START: {
endpoint: '/kyc/start',
method: 'POST',
headers: { 'Content-Type': 'application/json' },
},
},
}),
};
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Injectable } from '@nestjs/common';
import { ExternalApiName } from '../enums/external-api-name';
import { EndpointName } from '../enums/endpoint-name';
import { GatewayConfig, Gateways } from '../interfaces/endpoint.interface';
import { EnvironmentConfigService } from './environment-config.service';
import { HttpMethod } from '../enums/http-method';
import { ReputationOracleEndpoints } from '../enums/reputation-oracle-endpoints';

@Injectable()
export class GatewayConfigService {
Expand All @@ -18,21 +18,56 @@ export class GatewayConfigService {
[ExternalApiName.REPUTATION_ORACLE]: {
url: this.envConfig.reputationOracleUrl,
endpoints: {
[EndpointName.WORKER_SIGNUP]: {
[ReputationOracleEndpoints.WORKER_SIGNUP]: {
endpoint: '/auth/signup',
method: HttpMethod.POST,
headers: this.JSON_HEADER,
},
[EndpointName.OPERATOR_SIGNUP]: {
[ReputationOracleEndpoints.OPERATOR_SIGNUP]: {
endpoint: '/auth/web3/signup',
method: HttpMethod.POST,
headers: this.JSON_HEADER,
},
[EndpointName.WORKER_SIGNIN]: {
[ReputationOracleEndpoints.WORKER_SIGNIN]: {
endpoint: '/auth/signin',
method: HttpMethod.POST,
headers: this.JSON_HEADER,
},
[ReputationOracleEndpoints.EMAIL_VERIFICATION]: {
endpoint: '/auth/email-verification',
method: HttpMethod.POST,
headers: this.JSON_HEADER,
},
[ReputationOracleEndpoints.RESEND_EMAIL_VERIFICATION]: {
endpoint: '/auth/resend-email-verification',
method: HttpMethod.POST,
headers: this.JSON_HEADER,
},
[ReputationOracleEndpoints.FORGOT_PASSWORD]: {
endpoint: '/auth/forgot-password',
method: HttpMethod.POST,
headers: this.JSON_HEADER,
},
[ReputationOracleEndpoints.RESTORE_PASSWORD]: {
endpoint: '/auth/restore-password',
method: HttpMethod.POST,
headers: this.JSON_HEADER,
},
[ReputationOracleEndpoints.PREPARE_SIGNATURE]: {
endpoint: '/user/prepare-signature',
method: HttpMethod.POST,
headers: this.JSON_HEADER,
},
[ReputationOracleEndpoints.DISABLE_OPERATOR]: {
endpoint: '/user/disable-operator',
method: HttpMethod.POST,
headers: this.JSON_HEADER,
},
[ReputationOracleEndpoints.KYC_PROCEDURE_START]: {
endpoint: '/kyc/start',
method: HttpMethod.POST,
headers: this.JSON_HEADER,
},
},
},
},
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,8 @@ export enum AssignmentSortField {
CREATED_AT = 'created_at',
EXPIRES_AT = 'expires_at',
}
export enum PrepareSignatureType {
SIGNUP = 'SIGNUP',
DISABLE_OPERATOR = 'DISABLE_OPERATOR',
SIGNIN = 'SIGNIN',
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export enum ReputationOracleEndpoints {
WORKER_SIGNUP = 'WORKER_SIGNUP',
WORKER_SIGNIN = 'WORKER_SIGNIN',
OPERATOR_SIGNUP = 'OPERATOR_SIGNUP',
EMAIL_VERIFICATION = 'EMAIL_VERIFICATION',
RESEND_EMAIL_VERIFICATION = 'RESEND_EMAIL_VERIFICATION',
FORGOT_PASSWORD = 'FORGOT_PASSWORD',
RESTORE_PASSWORD = 'RESTORE_PASSWORD',
PREPARE_SIGNATURE = 'PREPARE_SIGNATURE',
DISABLE_OPERATOR = 'DISABLE_OPERATOR',
KYC_PROCEDURE_START = 'KYC_PROCEDURE_START',
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { EndpointName } from '../enums/endpoint-name';
import { ExternalApiName } from '../enums/external-api-name';

export interface GatewayEndpointConfig {
endpoint: string;
method: string;
headers: Record<string, string>;
headers?: Record<string, string>;
params?: Record<string, string | boolean | number>;
}

export interface GatewayConfig {
url: string;
endpoints: Record<EndpointName, GatewayEndpointConfig>;
endpoints: Record<string, GatewayEndpointConfig>;
}

export interface Gateways {
Expand Down
Loading

0 comments on commit 054c23e

Please sign in to comment.