Contents
Consent Types
/**
* See https://gdpr.eu/cookies/ for more information about these enum values.
*/
export type ConsentCategory = "necessary" | "preferences" | "analytics" | "marketing";
/**
* `accept`, `decline`, `close` (banner dismissed), `default` (no interaction; the configured default applied).
*/
export type ConsentAction = "accept" | "decline" | "close" | "default";
export type BannerMode = "opt-in" | "opt-out" | "dontshow" | "tcf";
export type BannerSettings = {
mode: BannerMode;
};
export type TcfConsentSignal = { kind: "tcf"; value: string };
export type GppConsentSignal = { kind: "gpp"; value: string };
export type UnknownConsentSignal = { kind: string; value: string | Record<string, unknown> };
/**
* A keyed union of consent signals.
* TCF and GPP are sent as opaque strings.
* Other unknown signals may send either an opaque string or a free-form object.
*/
export type ConsentSignal = TcfConsentSignal
| GppConsentSignal
| UnknownConsentSignal;
export type BannerAbTest = {
bucket: string;
name: string;
};
export type SingleOrMany<T> = T | T[];
export type ConsentMetadata = {
/**
* Opaque end-user identifier.
* In a future API, this can be filtered on to retrieve the latest record for a given user
*/
user?: string;
/**
* Hash/version of the settings bundle shown, a BannerSettings object,
* or base64 of the realized (merged) client-side settings.
*/
settings?: string | BannerSettings;
abTest?: BannerAbTest;
/**
* Either a single consent signal entry or an array of consent signal entries
*/
consentSignal?: SingleOrMany<ConsentSignal>;
custom?: Record<string, unknown>;
};
export type WebConsentSurfaceMetadata = {
scroll?: { x: number; y: number };
screen?: {
actual?: { height: number; width: number };
available?: { height: number; width: number };
colorDepth?: number;
pixelDepth?: number;
orientation?: { type: string; angle: number };
isExtended?: boolean;
isFullscreen?: boolean;
};
doNotSell?: boolean;
doNotTrack?: boolean;
/** Whether the browser GPC signal was active */
globalPrivacyControl?: boolean;
/** The full URL the user was at when the consent occurred */
location?: string;
/** The URL of where the user came from */
referrer?: string;
/** The list of preferred languages of the user */
languages?: string[];
/** The navigator platform string */
platform?: string;
network?: {
downlink?: number;
downlinkMax?: number;
effectiveType?: string;
roundTripTime?: number;
saveData?: boolean;
type?: string;
};
/** document.dir */
textDirection?: string;
/** document.visibilityState */
visibilityState?: string;
/** document.characterSet */
characterSet?: string;
/** document.contentType */
contentType?: string;
/** The title of the webpage */
title?: string;
/** The amount of memory that the device has */
deviceMemory?: number;
custom?: Record<string, unknown>;
};
/**
* "web" is currently the only pre-defined kind.
* Custom kinds with custom metadata are allowed.
*/
export type WebConsentSurface = { kind: "web"; metadata?: WebConsentSurfaceMetadata };
export type UnknownConsentSurface = { kind: string; metadata?: Record<string, unknown> };
export type ConsentSurface = UnknownConsentSurface | WebConsentSurface;
/** Standard 8-4-4-4-12 UUID string. */
export type UUID = string;ConsentState
/** Request body for POST /consent/v1/:ledgerId/state. */
export type ConsentState = {
/** The unique identifier of the ledger this should be written to */
ledgerId: UUID;
/** Where the consent came from. */
surface: ConsentSurface;
/** The data usages consented to. */
categories: ConsentCategory[];
/** How the consent was communicated. */
action: ConsentAction;
/** Extra information, notably what the person was shown. */
metadata?: ConsentMetadata;
};RecordConsentStateResponse
/** Response body for a successful POST /consent/v1/:ledgerId/state (202). */
export type RecordConsentStateResponse = {
apiVersion: "v1";
kind: "RecordConsentStateResponse";
metadata: {
/** The ledger the record was written to. */
ledgerId: UUID;
/** RFC 9557 instant on the wire; the same value the read returns. */
recordedAt: string;
/** The new record's ID; pass it as `recordId` to GET /consent/v1/:ledgerId/state/:recordId. */
id: UUID;
};
};ConsentStateResource
/**
* Response body for a successful GET /consent/v1/:ledgerId/state/:recordId (200).
* Its `kind` is "ConsentState"; the type is named ConsentStateResource here so that
* it is not confused with the ConsentState request body above.
*/
export type ConsentStateResource = {
apiVersion: "v1";
kind: "ConsentState";
/** The record's identity, the submitted `metadata` fields, and the location derived at the edge. */
metadata: ConsentMetadata & {
ledgerId: UUID;
/** The record's ID. */
id: UUID;
/** RFC 9557 instant on the wire with TZ "Z". */
recordedAt: string;
/** ISO-3166-1 alpha-2 code, "T1", or "XX" when unknown. */
country?: string;
/** Province / state within the country. */
region?: string;
};
/** The rest of the submitted record. */
spec: {
surface: ConsentSurface;
categories: ConsentCategory[];
action: ConsentAction;
};
};Ledger Management Types
CreateLedgerRequestBody
/**
* Request body for POST /ledger/v1/:ownerId. The body itself may also be empty.
*/
export type CreateLedgerRequestBody = {
/**
* @maxLength 2048
* @default ""
*/
name?: string;
};UpdateLedgerRequestBody
/**
* Request body for PATCH /ledger/v1/:ownerId/:ledgerId. Omitted fields are left unchanged. */
export type UpdateLedgerRequestBody = {
/**
* @maxLength 2048
*/
name?: string;
};Ledger
/**
* Response body for a successful POST /ledger/v1/:ownerId (201) and
* PATCH /ledger/v1/:ownerId/:ledgerId (200), and each element of `items` in a
* successful GET /ledger/v1/:ownerId (200).
*/
export type Ledger = {
apiVersion: "v1";
kind: "Ledger";
metadata: {
/**
* A descriptive text about what this ledger will be used for in a business sense. Can change.
*/
name: string;
/**
* The ID of this ledger (the `ledgerId` in other paths), generated at creation time. Never changes.
*/
id: UUID;
/**
* The ID of the owner which created this ledger. Never changes.
*/
ownerId: UUID;
/**
* RFC 9557 instant (UTC, "Z") at which the ledger was created. Never changes.
*/
createdAt: string;
};
};LedgerList
/**
* Response body for a successful GET /ledger/v1/:ownerId (200). `items` is in no guaranteed order.
*/
export type LedgerList = {
apiVersion: "v1";
kind: "LedgerList";
items: Ledger[];
/** Currently always empty. */
metadata: Record<string, unknown>;
};