class BaseMandate

Abstract base class for all mandate types Implements common functionality following SOLID principles

Constructors

new
BaseMandate(
data: T,
options?: { id?: string; createdAt?: Date; status?: MandateStatus; signature?: string; },
)

Type Parameters

T extends Mandate

Properties

protected
_createdAt: Date
protected
_data: T
protected
_id: string
protected
optional
_signature: string

Methods

private
generateUniqueId(): string

Generate a unique ID using SHA-256 hash of mandate data + timestamp This ensures integrity and prevents collisions without affecting the standard AP2 signature

Get creation timestamp

Get mandate data

getId(): string

Get mandate ID

getSignature(): string | undefined

Get signature if present

Get mandate status

isSigned(): boolean

Check if mandate is signed (IntentMandate never gets signed)

setStatus(status: MandateStatus): void

Set mandate status

private
sha256Hash(data: string): string

Generate SHA-256 hash using @noble/hashes

optional
sign(
privateKey: string,
...args: any[],
): Promise<void>

Optional method for signing the mandate (not applicable to all mandate types) IntentMandates don't implement this, only CartMandates do

toJSON(): { id: string; createdAt: string; status: MandateStatus; data: T; signature?: string; }

Convert mandate to JSON

abstract
toString(): string

Abstract method for human-readable string representation

protected
abstract
validate(): Promise<void>

Abstract method for validation

optional
verify(
publicKey: string,
...args: any[],
): Promise<boolean>

Optional method for verifying the mandate signature (not applicable to all mandate types) IntentMandates don't implement this, only CartMandates do