File

src/issuer/oid4vci/oid4vci.controller.ts

Prefix

:tenantId/vci

Description

Controller for handling OID4VCI (OpenID for Verifiable Credential Issuance) requests.

Index

Methods

Methods

credential
credential(req: Request, tenantId: string)
Decorators :
@Post('credential')
@SessionLogger('session', 'OID4VCI')
@HttpCode(HttpStatus.OK)

Endpoint to issue credentials

Parameters :
Name Type Optional
req Request No
tenantId string No
Returns : Promise<CredentialResponse>
nonce
nonce(tenantId: string)
Decorators :
@Post('nonce')
@HttpCode(HttpStatus.OK)
@Header('Cache-Control', 'no-store')
Parameters :
Name Type Optional
tenantId string No
Returns : any
notifications
notifications(body: NotificationRequestDto, req: Request, tenantId: string)
Decorators :
@Post('notification')
@SessionLogger('notification_id', 'OID4VCI')

Notification endpoint

Parameters :
Name Type Optional
body NotificationRequestDto No
req Request No
tenantId string No
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,
        }));
    }
}

results matching ""

    No results matching ""