src/issuer/issuance/oid4vci/entities/deferred-transaction.entity.ts
Entity for tracking deferred credential issuance transactions.
According to OID4VCI Section 9, when the credential is not immediately available,
the Credential Issuer can return a transaction_id for the wallet to poll later.
Properties |
| createdAt |
Type : Date
|
Decorators :
@CreateDateColumn()
|
|
The timestamp when the deferred transaction was created. |
| Optional credential |
Type : string | null
|
Decorators :
@Column('text', {nullable: true})
|
|
The issued credential, populated when status becomes Ready. |
| credentialConfigurationId |
Type : string
|
Decorators :
@Column('varchar')
|
|
The credential configuration ID being requested. |
| Optional errorMessage |
Type : string | null
|
Decorators :
@Column('text', {nullable: true})
|
|
Error message if the transaction failed. |
| expiresAt |
Type : Date
|
Decorators :
@Column()
|
|
The timestamp when the transaction expires. After this time, the transaction_id is no longer valid. |
| holderCnf |
Type : Record<string | unknown>
|
Decorators :
@Column('json')
|
|
The holder's public key (CNF) for key binding. Stored as JSON. |
| interval |
Type : number
|
Decorators :
@Column('int', {default: 5})
|
|
Recommended polling interval in seconds.
Returned to the wallet as |
| sessionId |
Type : string
|
Decorators :
@Column('uuid')
|
|
Session ID associated with this deferred transaction. |
| status |
Type : DeferredTransactionStatus
|
Decorators :
@Column({type: 'varchar', default: undefined})
|
|
Current status of the deferred transaction. |
| tenant |
Type : TenantEntity
|
Decorators :
@ManyToOne(undefined, {cascade: true, onDelete: 'CASCADE'})
|
|
The tenant that owns this transaction. |
| tenantId |
Type : string
|
Decorators :
@Column('varchar')
|
|
Tenant ID for multi-tenancy support. |
| transactionId |
Type : string
|
Decorators :
@PrimaryColumn('uuid')
|
|
Unique identifier for the deferred transaction.
This is the |
| updatedAt |
Type : Date
|
Decorators :
@UpdateDateColumn()
|
|
The timestamp when the deferred transaction was last updated. |
import {
Column,
CreateDateColumn,
Entity,
ManyToOne,
PrimaryColumn,
UpdateDateColumn,
} from "typeorm";
import { TenantEntity } from "../../../../auth/tenant/entitites/tenant.entity";
/**
* Status of a deferred credential transaction.
*/
export enum DeferredTransactionStatus {
/**
* Credential issuance is pending - external system is processing.
*/
Pending = "pending",
/**
* Credential is ready for retrieval.
*/
Ready = "ready",
/**
* Credential has been retrieved by the wallet.
*/
Retrieved = "retrieved",
/**
* Transaction has expired.
*/
Expired = "expired",
/**
* Credential issuance failed.
*/
Failed = "failed",
}
/**
* Entity for tracking deferred credential issuance transactions.
*
* According to OID4VCI Section 9, when the credential is not immediately available,
* the Credential Issuer can return a `transaction_id` for the wallet to poll later.
*
* @see https://openid.net/specs/openid-4-verifiable-credential-issuance-1_0.html#name-deferred-credential-endpoin
*/
@Entity()
export class DeferredTransactionEntity {
/**
* Unique identifier for the deferred transaction.
* This is the `transaction_id` returned to the wallet.
*/
@PrimaryColumn("uuid")
transactionId!: string;
/**
* Tenant ID for multi-tenancy support.
*/
@Column("varchar")
tenantId!: string;
/**
* The tenant that owns this transaction.
*/
@ManyToOne(() => TenantEntity, { cascade: true, onDelete: "CASCADE" })
tenant!: TenantEntity;
/**
* Session ID associated with this deferred transaction.
*/
@Column("uuid")
sessionId!: string;
/**
* The credential configuration ID being requested.
*/
@Column("varchar")
credentialConfigurationId!: string;
/**
* The holder's public key (CNF) for key binding.
* Stored as JSON.
*/
@Column("json")
holderCnf!: Record<string, unknown>;
/**
* Current status of the deferred transaction.
*/
@Column({
type: "varchar",
default: DeferredTransactionStatus.Pending,
})
status!: DeferredTransactionStatus;
/**
* The issued credential, populated when status becomes Ready.
*/
@Column("text", { nullable: true })
credential?: string | null;
/**
* Recommended polling interval in seconds.
* Returned to the wallet as `interval` in the deferred response.
*/
@Column("int", { default: 5 })
interval!: number;
/**
* Error message if the transaction failed.
*/
@Column("text", { nullable: true })
errorMessage?: string | null;
/**
* The timestamp when the deferred transaction was created.
*/
@CreateDateColumn()
createdAt!: Date;
/**
* The timestamp when the deferred transaction was last updated.
*/
@UpdateDateColumn()
updatedAt!: Date;
/**
* The timestamp when the transaction expires.
* After this time, the transaction_id is no longer valid.
*/
@Column()
expiresAt!: Date;
}