Skip to content

Commit

Permalink
Merge pull request #4 from tno-ssi-lab/indy-fix
Browse files Browse the repository at this point in the history
Indy fix
  • Loading branch information
peterlangenkamp authored Aug 12, 2021
2 parents 73361dc + 42f87e9 commit f46259b
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 33 deletions.
26 changes: 0 additions & 26 deletions src/connectors/indy/indy.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
// );
// }
}
19 changes: 17 additions & 2 deletions src/issue/issue.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
ClassSerializerInterceptor,
UseInterceptors,
} from '@nestjs/common';
import { classToPlain } from 'class-transformer';

import {
DecodeIssueRequestPipe,
Expand All @@ -19,14 +20,15 @@ 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')
export class IssueController {
constructor(
private connectorsService: ConnectorsService,
private jolocomService: JolocomService,
private indyService: IndyService,
private idaService: IdaService,
) {}

Expand All @@ -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)),
};
}

Expand All @@ -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,
);
}
}
28 changes: 28 additions & 0 deletions src/migrations/1628757331513-AddIDACredential.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import {MigrationInterface, QueryRunner} from "typeorm";

export class AddIDACredential1628757331513 implements MigrationInterface {
name = 'AddIDACredential1628757331513'

public async up(queryRunner: QueryRunner): Promise<void> {
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<void> {
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"`);
}

}
17 changes: 16 additions & 1 deletion src/verify/verify.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -30,6 +31,7 @@ export class VerifyController {
private gateway: RequestsGateway,
private connectorsService: ConnectorsService,
private requestsService: RequestsService,
private indyService: IndyService,
) {}

@Get()
Expand All @@ -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)),
};
}

Expand Down Expand Up @@ -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,
);
}
}
8 changes: 4 additions & 4 deletions src/webhooks/webhooks/webhooks.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit f46259b

Please sign in to comment.