Abstract base class for all mandate types Implements common functionality following SOLID principles
BaseMandate(data: T,options?: { id?: string; createdAt?: Date; status?: MandateStatus; signature?: string; },)
T extends Mandate
_createdAt: Date
_id: string
_signature: string
_status: MandateStatus
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
getCreatedAt(): Date
Get creation timestamp
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
sha256Hash(data: string): string
Generate SHA-256 hash using @noble/hashes
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
toString(): string
Abstract method for human-readable string representation
validate(): Promise<void>
Abstract method for validation
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