UNPKG

@m10s/cmp

Version:

Package containing scripts used by Schibsteds' sites to integrate with Sourcepoint CMP

203 lines (185 loc) 8.16 kB
declare module '@m10s/cmp' { type RequiredProperties = { /** * - Maps the message to a specific property (website, app, OTT) as set up in the Sourcepoint account dashboard. */ baseEndpoint: string; /** * - Consent message language. Available: `en`, `no`, `sv`, `fi`, `dk`. */ consentLanguage: string; /** * - Maps the message to a specific property (website, app, OTT) as set up in the Sourcepoint account dashboard. */ propertyId: number; }; type ExtendedRequiredProperties = { /** * - Allows to use the Privacy Manager ID for the property group use of a property group's Privacy Manager ID. */ groupPmId: number; }; type OptionalProperties = Partial<{ /** * - (**Optional**) Used to override organization's Sourcepoint account. Default value: 1960. */ accountId: number; /** * - (**Optional**) Used to display a message from one property, e.g. production url, on another domain, e.g. staging/test site. */ propertyHref: string; /** * - (**Optional**) Array with key value pairs passed to Sourcepoint – could be used as conditions in scenarios. */ targetingParams: string[]; /** * - (**Optional**) Schibsted account user identifier for logged-in users, e.g. 123456. It's not a full SDRN. Send it only if a user is logged-in. */ userId: number; /** * - (**Optional**) Schibsted account realm of the logged in user. E.g. schibsted.com, spid.no, schibsted.fi. */ realm: string; /** * - (**Optional**) Provide in order to redirect users to Privacy Settings UI page with a `client_id` parameter passed. It's a unique identifier generated for an individual service client. */ clientId: string; /** * - (**Optional**) Pulse Event Tracker object. */ pulseTracker: object; /** * - (**Optional**) Used to allow users to return to a specific page from Privacy Settings UI. Its default value is the current URL. */ referrer: string; /** * - (**Optional**) It should be a base64-encoded string. Enables passing any query parameters as a part of a specific redirect URL. */ state: string; /** * - (**Optional**) Provide when you assign Pulse to different variable than `window.pulse`. Used in the server-side integration type. */ pulseObjectName: string; /** * - (**Optional**) Provide if you want to enable displaying modal in a mobile app webview. `all` – all modals will be enabled; `scc` – only SCC modal will be enabled; `tcf` – only TCF modal will be enabled; `psi` – only PSI modal will be enabled. */ showInWebview: 'all' | 'scc' | 'tcf' | 'psi'; /** * - (**Optional**) Schibsted account browser SDK Identity object. */ identityObject: object; /** * - (**Optional**) Provide in case you assigned the `Identity` object to a different global variable than `window.Identity`. */ identityObjectName: string; /** * - (**Optional**) When using the consent identifier, Sourcepoint will persist the consent preferences for the end-user in other properties in the configuration. */ authId: string; }>; type BaseConfig = RequiredProperties & OptionalProperties; type ExtendedConfig = BaseConfig & ExtendedRequiredProperties; export type PSIConfig = BaseConfig; export type SCCConfig = ExtendedConfig; export type TCFConfig = ExtendedConfig; // client-side solution types /** * @description Configures the PSI pop-up on the client-side (in the browser). * @param {Window} window - `window` object. * @param {Document} document - `document` object. * @param {Navigator} navigator - `navigator` object. * @param {PSIConfig} config - The configuration object required to establish a connection with the Sourcepoint service. */ export function psi( window: Window, document: Document, navigator: Navigator, config: PSIConfig ): void; /** * @description Configures the SCC pop-up on the client-side (in the browser). * @param {Window} window - `window` object. * @param {Document} document - `document` object. * @param {Navigator} navigator - `navigator` object. * @param {SCCConfig} config - The configuration object required to establish a connection with the Sourcepoint service. */ export function scc( window: Window, document: Document, navigator: Navigator, config: SCCConfig ): void; /** * @description Configures the TCF pop-up on the client-side (in the browser). * @param {Window} window - `window` object. * @param {Document} document - `document` object. * @param {Navigator} navigator - `navigator` object. * @param {TCFConfig} config - The configuration object required to establish a connection with the Sourcepoint service. */ export function tcf( window: Window, document: Document, navigator: Navigator, config: TCFConfig ): void; // server-side solution types /** * @description Configures the SCC pop-up on the server-side (in a node.js app). * @param {SCCConfig} config - The configuration object required to establish a connection with the Sourcepoint service. * @param {boolean} [asHTML=true] - (`true` **by default**) - Decides if the code snippet should be returned in a `script` HTML tag or as pure code string. * @return string */ export function psi(config: PSIConfig, asHtml: boolean): string; /** * @description Configures the SCC pop-up on the server-side (in a node.js app). * @param {SCCConfig} config - The configuration object required to establish a connection with the Sourcepoint service. * @param {boolean} [asHTML=true] - (`true` **by default**) - Decides if the code snippet should be returned in a `script` HTML tag or as pure code string. * @return string */ export function scc(config: SCCConfig, asHtml: boolean): string; /** * @description Configures the TCF pop-up on the server-side (in a node.js app). * @param {TCFConfig} config - The configuration object required to establish a connection with the Sourcepoint service. * @param {boolean} [asHTML=true] - (`true` **by default**) - Decides if the code snippet should be returned in a `script` HTML tag or as pure code string. * @return string */ export function tcf(config: TCFConfig, asHtml: boolean): string; } export {}; /** * Represents the categories for which consent can be given. */ export type ConsentCategory = | "CMP:advertising" | "CMP:analytics" | "CMP:marketing" | "CMP:personalisation" | "CMP:performance_marketing"; /** * Represents the value of a consent. * `1` means granted, `0` means denied, and `null` means user has not made a choice yet. */ export type ConsentState = "1" | "0" | null; declare global { interface Window { psi?: { openPrivacySettings: (url: string) => void; setUserId: (id?: number) => void; }; _tcf_?: { getConsentedToAllSync: () => boolean | null; isConsentedToAll: (callback: (value: boolean) => void) => void; getCachedOrDefaultConsentsForPulse: () => object; subscribe: ( consentCategory: ConsentCategory, callback: (value: ConsentState) => void ) => void; getPermissionSync: (consentCategory: ConsentCategory) => ConsentState; getPermission: ( consentCategory: ConsentCategory, callback: (value: ConsentState) => void ) => void; showPrivacyManager: () => void; }; } }