prorm API Reference
    Preparing search index...

    Class ConsentVersioning

    ConsentVersioning class for tracking consent history with version control. Provides methods for recording, retrieving, and validating consent records.

    Index
    • Initialize the ConsentVersioning model and sync the table. Call once at application startup.

      Parameters

      • prorm: any

        The Prorm instance

      • tableName: string = 'consent_versions'

        Override the default table name 'consent_versions'

      Returns Promise<void>

    • Record a new consent event with version tracking. Creates a new version record for each consent change.

      Parameters

      • userId: string

        Unique identifier of the data subject

      • consentType: string

        Type of consent (e.g. 'marketing_emails')

      • granted: boolean

        Whether consent is granted (true) or revoked (false)

      • version: string

        Privacy notice version at time of recording

      • options: RecordConsentOptions = {}

        Additional options

      Returns Promise<ConsentVersion>

      The created consent version record

    • Get the full consent history for a user and consent type. Returns all version records in chronological order.

      Parameters

      • userId: string

        Unique identifier of the data subject

      • consentType: string

        Type of consent to query

      • options: ConsentHistoryOptions = {}

        History options (order, limit, date filters)

      Returns Promise<ConsentVersion[]>

      Array of consent version records

    • Get the current consent state for a user and consent type. Returns the most recent consent record (granted or revoked).

      Parameters

      • userId: string

        Unique identifier of the data subject

      • consentType: string

        Type of consent to query

      Returns Promise<ConsentVersion | null>

      The current consent version record or null if none exists

    • Revoke consent for a user and consent type. Creates a new version record with granted = false.

      Parameters

      • userId: string

        Unique identifier of the data subject

      • consentType: string

        Type of consent to revoke

      • options: RecordConsentOptions = {}

        Additional options (metadata, ipAddress, etc.)

      Returns Promise<ConsentVersion>

      The created revocation record

    • Validate whether consent is currently valid (granted and not expired).

      Parameters

      • userId: string

        Unique identifier of the data subject

      • consentType: string

        Type of consent to validate

      Returns Promise<boolean>

      true if consent is currently valid, false otherwise

    • Get all users who have granted consent for a specific consent type. Useful for compliance audits and marketing campaigns.

      Parameters

      • consentType: string

        Type of consent to query

      Returns Promise<string[]>

      Array of user IDs with active consent

    • Get consent by specific version.

      Parameters

      • userId: string

        Unique identifier of the data subject

      • consentType: string

        Type of consent to query

      • version: string

        Specific version to retrieve

      Returns Promise<ConsentVersion | null>

      The consent version record or null if not found

    • Re-grant consent (creates new version after revocation).

      Parameters

      • userId: string

        Unique identifier of the data subject

      • consentType: string

        Type of consent to re-grant

      • version: string

        Current privacy notice version

      • options: RecordConsentOptions = {}

        Additional options

      Returns Promise<ConsentVersion>

      The created consent record