File

src/session/entities/session.entity.ts

Description

Entity representing a user session in the application. It includes various properties such as credentials, authorization code, request URI, authorization queries, and more.

Index

Properties

Properties

Optional auth_queries
Type : AuthorizeQueries
Decorators :
@Column('json', {nullable: true})

Authorization queries associated with the session.

Optional authorization_code
Type : string
Decorators :
@Column('varchar', {nullable: true})

Authorization code for the session.

Optional claimsWebhook
Type : WebhookConfig
Decorators :
@Column('json', {nullable: true})

Webhook configuration to send result and may receive further information.

createdAt
Type : Date
Decorators :
@CreateDateColumn()

The timestamp when the request was created.

Optional credentialPayload
Type : OfferRequestDto
Decorators :
@Column('json', {nullable: true})

Credential payload containing the offer request details.

Optional credentials
Type : VerificationResult[]
Decorators :
@Column('json', {nullable: true})

Verified credentials from the presentation process.

Optional expiresAt
Type : Date
Decorators :
@Column('date', {nullable: true})

The timestamp when the request is set to expire.

id
Type : string
Decorators :
@PrimaryColumn('uuid')

Unique identifier for the session.

Optional issuanceId
Type : string
Decorators :
@Column('varchar', {nullable: true})
Optional nonce
Type : string
Decorators :
@Column('varchar', {nullable: true})

Nonce used for the OID4VCI flow.

notifications
Type : Notification[]
Decorators :
@Column('json', {default: undefined})

Notifications associated with the session.

Optional notifyWebhook
Type : WebhookConfig
Decorators :
@Column('json', {nullable: true})

Webhook configuration to send the result of the notification response.

Optional offer
Type : CredentialOfferObject
Decorators :
@Column('json', {nullable: true})

Credential offer object containing details about the credential offer or presentation request.

Optional offerUrl
Type : string
Decorators :
@Column('varchar', {nullable: true})

Offer URL for the credential offer.

Optional request_uri
Type : string
Decorators :
@Column('varchar', {nullable: true})

Request URI from the authorization request.

Optional requestId
Type : string
Decorators :
@Column('varchar', {nullable: true})

The ID of the presentation configuration associated with the session.

Optional requestObject
Type : string
Decorators :
@Column('varchar', {nullable: true})

Signed presentation auth request.

Optional requestUrl
Type : string
Decorators :
@Column('varchar', {nullable: true})

The URL of the presentation auth request.

status
Type : SessionStatus
Decorators :
@ApiProperty({enum: SessionStatus})
@Column('varchar', {nullable: true, default: 'active'})

Status of the session.

tenant
Type : TenantEntity
Decorators :
@ManyToOne(undefined, {cascade: true, onDelete: 'CASCADE', eager: true})

The tenant that owns this object.

tenantId
Type : string
Decorators :
@Column('varchar')

Tenant ID for multi-tenancy support.

updatedAt
Type : Date
Decorators :
@UpdateDateColumn()

The timestamp when the request was last updated.

useDcApi
Type : boolean
Decorators :
@Column('boolean', {nullable: true})

Flag indicating whether to use the DC API for the presentation request.

Optional vp_nonce
Type : string
Decorators :
@Column('varchar', {nullable: true})

Noncce from the Verifiable Presentation request.

import { ApiProperty } from "@nestjs/swagger";
import {
    CredentialOfferObject,
    NotificationEvent,
} from "@openid4vc/openid4vci";
import { VerificationResult } from "@sd-jwt/sd-jwt-vc";
import {
    Column,
    CreateDateColumn,
    Entity,
    ManyToOne,
    PrimaryColumn,
    UpdateDateColumn,
} from "typeorm";
import { TenantEntity } from "../../auth/tenant/entitites/tenant.entity";
import { AuthorizeQueries } from "../../issuer/authorize/dto/authorize-request.dto";
import { OfferRequestDto } from "../../issuer/oid4vci/dto/offer-request.dto";
import { WebhookConfig } from "../../utils/webhook/webhook.dto";

export enum SessionStatus {
    Active = "active",
    Fetched = "fetched",
    Completed = "completed",
    Expired = "expired",
    Failed = "failed",
}

/**
 * Represents a session entity for managing user sessions in the application.
 */
export type Notification = {
    /**
     * Unique identifier for the notification.
     */
    id: string;
    /**
     * The type of notification.
     */
    event?: NotificationEvent;

    /**
     * The credential ID associated with the notification.
     */
    credentialConfigurationId: string;
};

/**
 * Entity representing a user session in the application.
 * It includes various properties such as credentials, authorization code,
 * request URI, authorization queries, and more.
 */
@Entity()
export class Session {
    /**
     * Unique identifier for the session.
     */
    @PrimaryColumn("uuid")
    id: string;

    /**
     * The timestamp when the request was created.
     */
    @CreateDateColumn()
    createdAt: Date;

    /**
     * The timestamp when the request was last updated.
     */
    @UpdateDateColumn()
    updatedAt: Date;

    /**
     * The timestamp when the request is set to expire.
     */
    @Column("date", { nullable: true })
    expiresAt?: Date;

    /**
     * Flag indicating whether to use the DC API for the presentation request.
     */
    @Column("boolean", { nullable: true })
    useDcApi: boolean;

    /**
     * Tenant ID for multi-tenancy support.
     */
    @Column("varchar")
    tenantId: string;

    /**
     * The tenant that owns this object.
     */
    @ManyToOne(() => TenantEntity, {
        cascade: true,
        onDelete: "CASCADE",
        eager: true,
    })
    tenant: TenantEntity;

    /**
     * Status of the session.
     */
    @ApiProperty({ enum: SessionStatus })
    @Column("varchar", { nullable: true, default: "active" })
    status: SessionStatus;

    // issuance specific fields

    @Column("varchar", { nullable: true })
    issuanceId?: string;

    /**
     * Authorization code for the session.
     */
    @Column("varchar", { nullable: true })
    authorization_code?: string;
    /**
     * Request URI from the authorization request.
     */
    @Column("varchar", { nullable: true })
    request_uri?: string;
    /**
     * Authorization queries associated with the session.
     */
    @Column("json", { nullable: true })
    auth_queries?: AuthorizeQueries;

    /**
     * Nonce used for the OID4VCI flow.
     */
    @Column("varchar", { nullable: true })
    nonce?: string;

    /**
     * Credential offer object containing details about the credential offer or presentation request.
     */
    @Column("json", { nullable: true })
    offer?: CredentialOfferObject;

    /**
     * Offer URL for the credential offer.
     */
    @Column("varchar", { nullable: true })
    offerUrl?: string;

    /**
     * Credential payload containing the offer request details.
     */
    @Column("json", { nullable: true })
    credentialPayload?: OfferRequestDto;
    /**
     * Webhook configuration to send result and may receive further information.
     */
    @Column("json", { nullable: true })
    claimsWebhook?: WebhookConfig;
    /**
     * Webhook configuration to send the result of the notification response.
     */
    @Column("json", { nullable: true })
    notifyWebhook?: WebhookConfig;
    /**
     * Notifications associated with the session.
     */
    @Column("json", { default: JSON.stringify([]) })
    notifications: Notification[];

    // presentation specific fields

    /**
     * The ID of the presentation configuration associated with the session.
     */
    @Column("varchar", { nullable: true })
    requestId?: string;

    /**
     * The URL of the presentation auth request.
     */
    @Column("varchar", { nullable: true })
    requestUrl?: string;

    /**
     * Signed presentation auth request.
     */
    @Column("varchar", { nullable: true })
    requestObject?: string;

    /**
     * Verified credentials from the presentation process.
     */
    @Column("json", { nullable: true })
    credentials?: VerificationResult[];

    /**
     * Noncce from the Verifiable Presentation request.
     */
    @Column("varchar", { nullable: true })
    vp_nonce?: string;
}

results matching ""

    No results matching ""