diff --git a/src/connectors/indy/indy.controller.ts b/src/connectors/indy/indy.controller.ts index d9c8f11..e0649bf 100644 --- a/src/connectors/indy/indy.controller.ts +++ b/src/connectors/indy/indy.controller.ts @@ -34,30 +34,4 @@ export class IndyController { createInvitation() { return this.indyService.createInvitation(); } - - // @Post('verify') - // verify( - // @Query('verifyRequestId', GetVerifyRequestPipe) - // verifyRequest: CredentialVerifyRequest, - // @Body() - // { identifier }: { identifier: string }, - // ) { - // this.indyService.handleVerifyCredentialRequestForConnection( - // verifyRequest, - // identifier, - // ); - // } - - // @Post('issue') - // issue( - // @Query('issueRequestId', GetIssueRequestPipe) - // issueRequest: CredentialIssueRequest, - // @Body() - // { identifier }: { identifier: string }, - // ) { - // this.indyService.handleIssueCredentialRequestForConnection( - // issueRequest, - // identifier, - // ); - // } } diff --git a/src/issue/issue.controller.ts b/src/issue/issue.controller.ts index 6c08cdb..8bcc976 100644 --- a/src/issue/issue.controller.ts +++ b/src/issue/issue.controller.ts @@ -8,6 +8,7 @@ import { ClassSerializerInterceptor, UseInterceptors, } from '@nestjs/common'; +import { classToPlain } from 'class-transformer'; import { DecodeIssueRequestPipe, @@ -19,7 +20,7 @@ import { GetConnectorPipe } from '../connectors/get-connector.pipe'; import { ConnectorService } from '../connectors/connector-service.interface'; import { JolocomService } from 'src/connectors/jolocom/jolocom.service'; import { IdaService } from 'src/connectors/ida/ida.service'; -import { classToPlain } from 'class-transformer'; +import { IndyService } from 'src/connectors/indy/indy.service'; @UseInterceptors(ClassSerializerInterceptor) @Controller('api/issue') @@ -27,6 +28,7 @@ export class IssueController { constructor( private connectorsService: ConnectorsService, private jolocomService: JolocomService, + private indyService: IndyService, private idaService: IdaService, ) {} @@ -39,7 +41,7 @@ export class IssueController { issueRequest: classToPlain(issueRequest), availableConnectors: await this.connectorsService .availableIssueConnectors(issueRequest) - .then(cs => cs.map(c => c.name)), + .then((cs) => cs.map((c) => c.name)), }; } @@ -61,4 +63,17 @@ export class IssueController { ) { return this.jolocomService.handleIssueCredential(issueRequest, token); } + + @Post('indy/issue') + issue( + @Query('issueRequestId', GetIssueRequestPipe) + issueRequest: CredentialIssueRequest, + @Body() + { identifier }: { identifier: string }, + ) { + this.indyService.handleIssueCredentialRequestForConnection( + issueRequest, + identifier, + ); + } } diff --git a/src/migrations/1628757331513-AddIDACredential.ts b/src/migrations/1628757331513-AddIDACredential.ts new file mode 100644 index 0000000..9dca7c0 --- /dev/null +++ b/src/migrations/1628757331513-AddIDACredential.ts @@ -0,0 +1,28 @@ +import {MigrationInterface, QueryRunner} from "typeorm"; + +export class AddIDACredential1628757331513 implements MigrationInterface { + name = 'AddIDACredential1628757331513' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`CREATE TABLE "ida_credential_type" ("id" SERIAL NOT NULL, "name" character varying NOT NULL, "context" character varying NOT NULL, "attributes" jsonb, CONSTRAINT "UQ_8d0b1682d17450d32b86f9bd36c" UNIQUE ("context"), CONSTRAINT "PK_b4a99b166fe7a5fd530e9c74a15" PRIMARY KEY ("id"))`); + await queryRunner.query(`CREATE TABLE "ida_credential_request_token" ("id" SERIAL NOT NULL, "transactionId" character varying NOT NULL, "verifyRequestId" integer, CONSTRAINT "PK_9d8b93a9730c9aa666a167e83e6" PRIMARY KEY ("id"))`); + await queryRunner.query(`CREATE UNIQUE INDEX "IDX_da4479a58ebc55e96368259779" ON "ida_credential_request_token" ("transactionId", "verifyRequestId") `); + await queryRunner.query(`ALTER TABLE "credential_type" ADD "idaTypeId" integer`); + await queryRunner.query(`ALTER TABLE "master_keys" DROP COLUMN "timestamp"`); + await queryRunner.query(`ALTER TABLE "master_keys" ADD "timestamp" integer NOT NULL`); + await queryRunner.query(`ALTER TABLE "credential_type" ADD CONSTRAINT "FK_d225565823d407624be76d1204d" FOREIGN KEY ("idaTypeId") REFERENCES "ida_credential_type"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "ida_credential_request_token" ADD CONSTRAINT "FK_2e0e677c64a1c40b7a20157f72d" FOREIGN KEY ("verifyRequestId") REFERENCES "credential_verify_request"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "ida_credential_request_token" DROP CONSTRAINT "FK_2e0e677c64a1c40b7a20157f72d"`); + await queryRunner.query(`ALTER TABLE "credential_type" DROP CONSTRAINT "FK_d225565823d407624be76d1204d"`); + await queryRunner.query(`ALTER TABLE "master_keys" DROP COLUMN "timestamp"`); + await queryRunner.query(`ALTER TABLE "master_keys" ADD "timestamp" bigint NOT NULL`); + await queryRunner.query(`ALTER TABLE "credential_type" DROP COLUMN "idaTypeId"`); + await queryRunner.query(`DROP INDEX "IDX_da4479a58ebc55e96368259779"`); + await queryRunner.query(`DROP TABLE "ida_credential_request_token"`); + await queryRunner.query(`DROP TABLE "ida_credential_type"`); + } + +} diff --git a/src/verify/verify.controller.ts b/src/verify/verify.controller.ts index cb97f7f..e9810e6 100644 --- a/src/verify/verify.controller.ts +++ b/src/verify/verify.controller.ts @@ -22,6 +22,7 @@ import { RequestsGateway } from '../requests/requests.gateway'; import { RequestsService } from 'src/requests/requests.service'; import { ResponseStatus } from 'src/connectors/response-status.enum'; import { classToPlain } from 'class-transformer'; +import { IndyService } from 'src/connectors/indy/indy.service'; @UseInterceptors(ClassSerializerInterceptor) @Controller('api/verify') @@ -30,6 +31,7 @@ export class VerifyController { private gateway: RequestsGateway, private connectorsService: ConnectorsService, private requestsService: RequestsService, + private indyService: IndyService, ) {} @Get() @@ -41,7 +43,7 @@ export class VerifyController { verifyRequest: classToPlain(verifyRequest), availableConnectors: await this.connectorsService .availableVerifyConnectors(verifyRequest) - .then(cs => cs.map(c => c.name)), + .then((cs) => cs.map((c) => c.name)), }; } @@ -80,4 +82,17 @@ export class VerifyController { `${verifyRequest.callbackUrl}${responseToken}`, ); } + + @Post('indy/verify') + verify( + @Query('verifyRequestId', GetVerifyRequestPipe) + verifyRequest: CredentialVerifyRequest, + @Body() + { identifier }: { identifier: string }, + ) { + this.indyService.handleVerifyCredentialRequestForConnection( + verifyRequest, + identifier, + ); + } } diff --git a/src/webhooks/webhooks/webhooks.controller.ts b/src/webhooks/webhooks/webhooks.controller.ts index bcf09e4..fb0e0e0 100644 --- a/src/webhooks/webhooks/webhooks.controller.ts +++ b/src/webhooks/webhooks/webhooks.controller.ts @@ -9,7 +9,7 @@ import { ResponseStatus } from 'src/connectors/response-status.enum'; import { RequestsGateway } from 'src/requests/requests.gateway'; import { RequestsService } from 'src/requests/requests.service'; -@Controller('webhooks') +@Controller('api/webhooks') export class WebhooksController { logger: Logger; @@ -21,7 +21,7 @@ export class WebhooksController { this.logger = new Logger(WebhooksController.name); } - @Post('webhook/topic/present_proof') + @Post('indy/topic/present_proof') async webhookPresentProof(@Body() body: IndyPresentProofResponse) { this.debugWebhook('present_proof', body); @@ -52,7 +52,7 @@ export class WebhooksController { ); } - @Post('webhook/topic/issue_credential') + @Post('indy/topic/issue_credential') async webhookIssueCredential(@Body() body: IndyIssueCredentialResponse) { this.debugWebhook('issue_credential', body); @@ -82,7 +82,7 @@ export class WebhooksController { ); } - @Post('webhook/topic/:topic/') + @Post('indy/topic/:topic') webhook(@Param('topic') topic: string, @Body() body: any) { this.debugWebhook(topic, body); }