Entities references
Action
/** Supported action types.
*/
enum ActionType {
Accept = 'ACCEPT',
Reject = 'REJECT',
Unselected = 'UNSELECTED',
}
/** A consent Action represents a single input from a Subject.
*
* In the Cookie Consent flow, it might be opt-in/opt-out actions on a specific cookie.
*
*/
type Action = {
/** Privacy Protocol ID associated with this action. */
target: string
/** UC Configuration ID associated with this action. */
vendor: string
/** Type of action performed on the target object. */
action: ActionType
/** Optional jurisdiction of the action. */
jurisdiction?: string
}
Action values
Action values are uppercase: 'ACCEPT', 'REJECT' and 'UNSELECTED'. The API also accepts lowercase values and stores them as uppercase.
Older SDK versions used lowercase ActionType values, so a cookie written by one of them can still hold 'accept'. Compare case-insensitively when you read actions from the cookie:
const accepted = action.action.toUpperCase() === ActionType.Accept
ActionWithConsent
import { ActionType } from './Action'
/**
* Represents a consent and its included actions.
*/
type ActionWithConsent = {
/** Target object of this Action. */
target: string
/** Vendor that owns the target object. */
vendor: string
/** Type of action performed on the target object. */
action: ActionType
/** Consent Id. */
consentId: string
/** Channel Id. */
channelId: string
/** Creation Date of this consent.*/
createdAt: Date
}
AuthorizationConfig
/** This type defines the configuration required by the function [getToken] of [UnifiedConsentByOsanoSDK] to work.
*/
type AuthorizationConfig = {
/** URL of authorization services provider */
issuer: string
/** The config Id */
configId: string
/** The Client Id */
customerId: string
}
ClientConfig
/**
* This type defines the configuration required by a UnifiedConsentByOsanoClient to work.
*/
type ClientConfig = {
/** Token with authorization to execute call to the Core API */
token: string
/** Osano's Unified Consent API URL, including /v2 */
apiUrl: string
/** API Key issued by Osano through the Webapp. Optional, but necessary for calling subject related routes in the Core API */
osanoApiKey?: string
/** Set a country code for the client instance */
overrideCountryCode?: string
/** Set a region code for the client instance */
overrideRegionCode?: string
/** Overrides the default configuration of the cookies*/
cookieConfig?: CookieConfig
}
ChildEmbeddedConfig
type ChildEmbeddedConfig = {
/** Overrides the default configuration of the cookies */
cookieConfig?: CookieConfig
}
EmbeddedConfig
/** Defines the configuration to initialize the embedded rendering mode.
*/
type EmbeddedConfig = {
/* A DOM iframe where the target child is rendered */
targetIframe: HTMLIFrameElement
/** Overrides the default configuration of the cookies*/
cookieConfig?: CookieConfig
}
CombinedConfig
type CombinedConfig = {
/** URL of authorization services provider */
issuer?: string
/** The config ID to use when generating a token*/
configId?: string
/** The customer ID to use when generating a token*/
customerId?: string
/** Token with authorization to execute call to the Core API */
token?: string
/** Osano's Unified Consent API URL, including /v2 */
apiUrl?: string
/** Set a country code for the client instance */
overrideCountryCode?: string
/** Set a region code for the client instance */
overrideRegionCode?: string
/** Overrides the default configuration of the cookies*/
cookieConfig?: CookieConfig
/** Gpc attributes*/
attributes?: Record<string, any>
/** The target iframe for initializing the embedded experience*/
targetIframe?: HTMLIFrameElement
}
Collection
getCollection returns the GET /v2/collections response as is, so the field names are the API's.
type CollectionType = 'draft' | 'published'
type Collection = {
collectionId: string
name: string
frameworks: string[]
consents: CollectionPrivacyProtocol[]
preferences: CollectionPrivacyProtocol[]
configIds: string[]
jurisdiction: string | null
/** ISO 8601 timestamp */
created: string
/** ISO 8601 timestamp */
updated: string
type: CollectionType
customerId: string
}
CollectionPrivacyProtocol
A consent or preference in a Collection.
type CollectionPrivacyProtocol = {
/** Send it as the target of a consent action */
privacyProtocolId: string
name: string
trigger: string
type: 'consent' | 'preference'
title: string
description: string
defaultAction: 'ACCEPT' | 'REJECT' | 'UNSELECTED'
acceptWording: string
rejectWording: string
enabled: boolean
collectionId: string
frameworks: string[]
/** gpc: whether GPC resolves this protocol to ACCEPT */
frameworkDefaults: { gpc?: boolean }
integrations: Integration[]
}
type IntegrationLabelValue = {
label: string
value: string
}
type Integration = {
connection: IntegrationLabelValue
operation: IntegrationLabelValue
additionalFields: boolean
fields: object
protocolValue?: string[]
}
CollectionResponse
type CollectionResponse = {
collection: Collection
jurisdictions: string[]
}
Conflict
/** A Conflict represents a collision between Actions within a configuration.
*/
import { ActionWithConsent } from './ActionWithConsent'
type Conflict = {
/** Type represents the classification why there exists some conflict with the consents */
type: string
/** Resolution represents the action taken to resolve the conflict */
resolution: string
/** List of actions in conflict */
actionsInConflict: ActionWithConsent[]
}
ConsentType
type ConsentType = 'implicit' | 'explicit'
CreateConsentPayload
type CreateConsentPayload = {
subject: Subject
actions: Action[]
/** Defaults to {} */
attributes?: Record<string, any>
tags?: string[]
compliance?: {
privacyPolicy?: {
version?: string
url: string
},
gpc?: 1
}
// A country two letter ISO code. Defaults to the resolved country via IP if not provided
overrideCountryCode?: string
// A two letter ISO code for the state/division
overrideRegionCode?: string
}
CreateGpcConsentPayload
type CreateGpcConsentPayload = {
subject: Subject
compliance: {
gpc: 1
}
/** Defaults to {} */
attributes?: Record<string, any>
/** An optional jurisdiction override. If not passed, the user's jurisdiction will be determined by IP geolocation. */
jurisdiction?: string
}
GetUnifiedConsentResponse
type GetUnifiedConsentResponse = {
/** Unified Consent contains all the information about consent of a Subject */
unifiedConsent: UnifiedConsent
/** List of Conflicts if exists with all the details of resolution */
conflicts: Conflict[]
}
HasConsentsPayload
type HasConsentsPayload = {
/** The subjectId to check for having previous consents */
subjectId?: string
}
SaveProfilePayload
type SaveProfilePayload = {
email: string
profile?: any
}
VerifySubjectProfilePayload
type VerifySubjectProfilePayload = {
email: string
verificationCode: string
}
CookieConfig
type CookieConfig = {
/** Amount of days in the future when the cookie expiration will be set */
expirationInDays?: number
/** Whether the expiration date should be refreshed on a new visit */
refreshOnVisit?: boolean
/** An optional array of default actions. Used as a fallback if subject has no consent matching the target.
* Note: Default actions only affect tag manager integrations (GTM & Tealium).
*/
defaultActions?: { target: string; vendor: string; action: ActionType }[]
}
PrivacyProtocolsConfig
/**
* This type defines the configuration required to register the privacy protocols.
*/
type PrivacyProtocolsConfig = {
/** Osano's Unified Consent API URL, including /v2 */
apiUrl: string
/** Token generated by getToken */
token: string
/** Gpc attributes */
attributes?: Record<string, any>
/** Cookie-related config */
cookieConfig?: CookieConfig
}
Session
type Session = {
subject: {
verifiedId: string
}
profile: {
email: string
firstName?: string
lastName?: string
}
}
Subject
A subject in the system. It has either an anonymousId or a verifiedId. Subject.verified(id) sets verifiedId, and Subject.anonymous(id?) sets anonymousId.
class Subject {
static verified(id: string): Subject
static anonymous(id?: string): Subject
readonly verifiedId?: string
readonly anonymousId?: string
/** verifiedId if set, otherwise anonymousId */
get id(): string | undefined
}
UnifiedConsent
type UnifiedConsent = {
/** Subject Id. */
subjectId: string
/** Brand Id. */
brandId: string
/** List of Actions of consent. */
actions: Action[]
/** Attributes of consent. */
attributes: { [key: string]: any }
}
MessageType
Supported event types. Import it from the package, or use window.unifiedConsentJsSdk.MessageType in the browser.
enum MessageType {
LOGIN = 'login',
LOGOUT = 'logout',
CONSENT_WRITE = 'consent:write',
CONSENT_WRITE_GPC = 'consent:write:gpc',
CHILD_INIT = 'child:init',
CHILD_LOADED = 'child:loaded',
}
MessageListener
Callback to execute when an event is received
type MessageListener = (message: Message) => void
Message
type Message = {
type: MessageType
data: any
}