src/issuer/oid4vci/oid4vci.controller.ts
:tenantId/vci
Controller for handling OID4VCI (OpenID for Verifiable Credential Issuance) requests.
Methods |
| credential | |||||||||
credential(req: Request, tenantId: string)
|
|||||||||
Decorators :
@Post('credential')
|
|||||||||
|
Defined in src/issuer/oid4vci/oid4vci.controller.ts:38
|
|||||||||
|
Endpoint to issue credentials
Parameters :
Returns :
Promise<CredentialResponse>
|
| nonce | ||||||
nonce(tenantId: string)
|
||||||
Decorators :
@Post('nonce')
|
||||||
|
Defined in src/issuer/oid4vci/oid4vci.controller.ts:63
|
||||||
|
Parameters :
Returns :
any
|
| notifications | ||||||||||||
notifications(body: NotificationRequestDto, req: Request, tenantId: string)
|
||||||||||||
Decorators :
@Post('notification')
|
||||||||||||
|
Defined in src/issuer/oid4vci/oid4vci.controller.ts:52
|
||||||||||||
|
Notification endpoint
Parameters :
Returns :
any
|
import {
Body,
Controller,
Header,
HttpCode,
HttpStatus,
Param,
Post,
Req,
UseInterceptors,
} from "@nestjs/common";
import { ApiExcludeController, ApiParam } from "@nestjs/swagger";
import type { CredentialResponse } from "@openid4vc/openid4vci";
import type { Request } from "express";
import { Oid4vciService } from "../../issuer/oid4vci/oid4vci.service";
import { SessionLogger } from "../../utils/logger//session-logger.decorator";
import { SessionLoggerInterceptor } from "../../utils/logger/session-logger.interceptor";
import { NotificationRequestDto } from "./dto/notification-request.dto";
/**
* Controller for handling OID4VCI (OpenID for Verifiable Credential Issuance) requests.
*/
@ApiParam({ name: "tenantId", required: true })
@ApiExcludeController(process.env.SWAGGER_ALL !== "true")
@Controller(":tenantId/vci")
@UseInterceptors(SessionLoggerInterceptor)
export class Oid4vciController {
constructor(private readonly oid4vciService: Oid4vciService) {}
/**
* Endpoint to issue credentials
* @param req
* @returns
*/
@Post("credential")
@SessionLogger("session", "OID4VCI")
@HttpCode(HttpStatus.OK)
credential(
@Req() req: Request,
@Param("tenantId") tenantId: string,
): Promise<CredentialResponse> {
return this.oid4vciService.getCredential(req, tenantId);
}
/**
* Notification endpoint
* @param body
* @returns
*/
@Post("notification")
@SessionLogger("notification_id", "OID4VCI")
notifications(
@Body() body: NotificationRequestDto,
@Req() req: Request,
@Param("tenantId") tenantId: string,
) {
return this.oid4vciService.handleNotification(req, body, tenantId);
}
@Post("nonce")
@HttpCode(HttpStatus.OK)
@Header("Cache-Control", "no-store")
nonce(@Param("tenantId") tenantId: string) {
//TODO: maybe also add it into the header, see https://openid.net/specs/openid-4-verifiable-credential-issuance-1_0.html#name-nonce-response
return this.oid4vciService.nonceRequest(tenantId).then((nonce) => ({
c_nonce: nonce,
}));
}
}