src/issuer/issuance/oid4vci/authorization/authorization-servers/authorization-servers.controller.ts

Prefix

issuers/:tenantId/authorization-servers/:authorizationServerId

Relationships

Depends on

No results matching.

Index

Methods

Methods

Async authorize
authorize(tenantId: string, authorizationServerId: string, query: ChainedAsAuthorizeQueryDto, origin: string | undefined, res: Response)
Decorators :
@Public()
@Get('authorize')
@ApiOperation({summary: 'Authorization endpoint'})
@ApiParam({name: 'tenantId', description: 'Tenant identifier'})
@ApiParam({name: 'authorizationServerId', description: 'Authorization server identifier'})
@ApiResponse({status: 302, description: 'Redirect to OID4VP wallet invocation'})
Parameters :
Name Type Optional
tenantId string No
authorizationServerId string No
query ChainedAsAuthorizeQueryDto No
origin string | undefined No
res Response No
Returns : Promise<void>
Async par
par(tenantId: string, authorizationServerId: string, body: any, dpopJwt?: string, clientAttestationJwt?: string, clientAttestationPopJwt?: string)
Decorators :
@Public()
@Post('par')
@HttpCode(HttpStatus.CREATED)
@ApiConsumes('application/x-www-form-urlencoded')
@ApiOperation({summary: 'Pushed Authorization Request'})
@ApiParam({name: 'tenantId', description: 'Tenant identifier'})
@ApiParam({name: 'authorizationServerId', description: 'Authorization server identifier'})
@ApiHeader({name: 'DPoP', required: false, description: 'DPoP proof JWT'})
@ApiHeader({name: 'OAuth-Client-Attestation', required: false, description: 'Wallet attestation JWT'})
@ApiHeader({name: 'OAuth-Client-Attestation-PoP', required: false, description: 'Wallet attestation proof-of-possession JWT'})
@ApiResponse({status: 201, type: ChainedAsParResponseDto})
@ApiResponse({status: 400, type: ChainedAsErrorResponseDto})
Parameters :
Name Type Optional
tenantId string No
authorizationServerId string No
body any No
dpopJwt string Yes
clientAttestationJwt string Yes
clientAttestationPopJwt string Yes
Returns : Promise<ChainedAsParResponseDto>
Async token
token(tenantId: string, authorizationServerId: string, body: ChainedAsTokenRequestDto, dpopJwt?: string)
Decorators :
@Public()
@Post('token')
@HttpCode(HttpStatus.OK)
@ApiOperation({summary: 'Token endpoint'})
@ApiParam({name: 'tenantId', description: 'Tenant identifier'})
@ApiParam({name: 'authorizationServerId', description: 'Authorization server identifier'})
@ApiHeader({name: 'DPoP', required: false, description: 'DPoP proof JWT'})
@ApiResponse({status: 200, type: ChainedAsTokenResponseDto})
@ApiResponse({status: 400, type: ChainedAsErrorResponseDto})
Parameters :
Name Type Optional
tenantId string No
authorizationServerId string No
body ChainedAsTokenRequestDto No
dpopJwt string Yes
Async vpCallback
vpCallback(tenantId: string, authorizationServerId: string, chainedAsSessionId: string, responseCode?: string, error?: string, errorDescription?: string, res?: Response)
Decorators :
@Public()
@Get('vp-callback')
@ApiOperation({summary: 'OID4VP callback'})
@ApiParam({name: 'tenantId', description: 'Tenant identifier'})
@ApiParam({name: 'authorizationServerId', description: 'Authorization server identifier'})
@ApiResponse({status: 302, description: 'Redirect to wallet with authorization code'})
Parameters :
Name Type Optional
tenantId string No
authorizationServerId string No
chainedAsSessionId string No
responseCode string Yes
error string Yes
errorDescription string Yes
res Response Yes
Returns : Promise<void>
import {
    Body,
    Controller,
    Get,
    Headers,
    HttpCode,
    HttpStatus,
    Param,
    Post,
    Query,
    Res,
} from "@nestjs/common";
import {
    ApiConsumes,
    ApiHeader,
    ApiOperation,
    ApiParam,
    ApiResponse,
    ApiTags,
} from "@nestjs/swagger";
import type { Response } from "express";
import { Public } from "../../../../../auth/public.decorator";
import {
    ChainedAsAuthorizeQueryDto,
    ChainedAsErrorResponseDto,
    ChainedAsParResponseDto,
    ChainedAsTokenRequestDto,
    ChainedAsTokenResponseDto,
    extractDpopJkt,
} from "../shared";
import { AuthorizationServersService } from "./authorization-servers.service";

@ApiTags("Authorization Servers")
@Controller("issuers/:tenantId/authorization-servers/:authorizationServerId")
export class AuthorizationServersController {
    constructor(
        private readonly authorizationServersService: AuthorizationServersService,
    ) {}

    @Public()
    @Post("par")
    @HttpCode(HttpStatus.CREATED)
    @ApiConsumes("application/x-www-form-urlencoded")
    @ApiOperation({ summary: "Pushed Authorization Request" })
    @ApiParam({ name: "tenantId", description: "Tenant identifier" })
    @ApiParam({
        name: "authorizationServerId",
        description: "Authorization server identifier",
    })
    @ApiHeader({ name: "DPoP", required: false, description: "DPoP proof JWT" })
    @ApiHeader({
        name: "OAuth-Client-Attestation",
        required: false,
        description: "Wallet attestation JWT",
    })
    @ApiHeader({
        name: "OAuth-Client-Attestation-PoP",
        required: false,
        description: "Wallet attestation proof-of-possession JWT",
    })
    @ApiResponse({ status: 201, type: ChainedAsParResponseDto })
    @ApiResponse({ status: 400, type: ChainedAsErrorResponseDto })
    async par(
        @Param("tenantId") tenantId: string,
        @Param("authorizationServerId") authorizationServerId: string,
        @Body() body: any,
        @Headers("dpop") dpopJwt?: string,
        @Headers("oauth-client-attestation") clientAttestationJwt?: string,
        @Headers("oauth-client-attestation-pop")
        clientAttestationPopJwt?: string,
    ): Promise<ChainedAsParResponseDto> {
        const dpopJkt = dpopJwt ? extractDpopJkt(dpopJwt) : undefined;
        const clientAttestation =
            clientAttestationJwt && clientAttestationPopJwt
                ? { clientAttestationJwt, clientAttestationPopJwt }
                : undefined;

        return this.authorizationServersService.handlePar(
            tenantId,
            authorizationServerId,
            body,
            dpopJkt,
            clientAttestation,
        );
    }

    @Public()
    @Get("authorize")
    @ApiOperation({ summary: "Authorization endpoint" })
    @ApiParam({ name: "tenantId", description: "Tenant identifier" })
    @ApiParam({
        name: "authorizationServerId",
        description: "Authorization server identifier",
    })
    @ApiResponse({
        status: 302,
        description: "Redirect to OID4VP wallet invocation",
    })
    async authorize(
        @Param("tenantId") tenantId: string,
        @Param("authorizationServerId") authorizationServerId: string,
        @Query() query: ChainedAsAuthorizeQueryDto,
        @Headers("origin") origin: string | undefined,
        @Res() res: Response,
    ): Promise<void> {
        const redirectUrl =
            await this.authorizationServersService.handleAuthorize(
                tenantId,
                authorizationServerId,
                query.client_id,
                query.request_uri,
                origin,
            );
        res.redirect(redirectUrl);
    }

    @Public()
    @Get("vp-callback")
    @ApiOperation({ summary: "OID4VP callback" })
    @ApiParam({ name: "tenantId", description: "Tenant identifier" })
    @ApiParam({
        name: "authorizationServerId",
        description: "Authorization server identifier",
    })
    @ApiResponse({
        status: 302,
        description: "Redirect to wallet with authorization code",
    })
    async vpCallback(
        @Param("tenantId") tenantId: string,
        @Param("authorizationServerId") authorizationServerId: string,
        @Query("cas") chainedAsSessionId: string,
        @Query("response_code") responseCode?: string,
        @Query("error") error?: string,
        @Query("error_description") errorDescription?: string,
        @Res() res?: Response,
    ): Promise<void> {
        const redirectUrl =
            await this.authorizationServersService.handleVerifierCallback(
                tenantId,
                authorizationServerId,
                chainedAsSessionId,
                responseCode,
                error,
                errorDescription,
            );
        res!.redirect(redirectUrl);
    }

    @Public()
    @Post("token")
    @HttpCode(HttpStatus.OK)
    @ApiOperation({ summary: "Token endpoint" })
    @ApiParam({ name: "tenantId", description: "Tenant identifier" })
    @ApiParam({
        name: "authorizationServerId",
        description: "Authorization server identifier",
    })
    @ApiHeader({ name: "DPoP", required: false, description: "DPoP proof JWT" })
    @ApiResponse({ status: 200, type: ChainedAsTokenResponseDto })
    @ApiResponse({ status: 400, type: ChainedAsErrorResponseDto })
    async token(
        @Param("tenantId") tenantId: string,
        @Param("authorizationServerId") authorizationServerId: string,
        @Body() body: ChainedAsTokenRequestDto,
        @Headers("dpop") dpopJwt?: string,
    ): Promise<ChainedAsTokenResponseDto> {
        return this.authorizationServersService.handleToken(
            tenantId,
            authorizationServerId,
            body,
            dpopJwt,
        );
    }
}

results matching ""

    No results matching ""