UNPKG

@usercentrics/cmp-browser-sdk

Version:
70 lines (69 loc) 3.55 kB
import { CONSENT_ACTION, CONSENT_TYPE } from './enums'; import { Consent, Language } from '../SettingsV2/interfaces'; import { ConsentHistory, DataTransferObject, UserSessionData } from './interfaces'; import { Data, ServiceBasic, ServiceData } from '../SettingsV2/Data/interfaces'; import { DataTransferSettings } from '../../modules/helpers'; import { GraphQLConsentString } from '../Api/interfaces/interfaces'; import { Maybe, Service as ServiceV2 } from '../SettingsV2/interfaces/interfaces'; import { DpsJsonResponse } from '../Api/interfaces'; import { ServiceLabels } from '../SettingsV2/Labels/interfaces'; import { StorageSettings } from '../Storage/interfaces'; export default class DataFacade { restoreAction: CONSENT_ACTION | null; private static instance; private apiInstance; private controllerIdInstance; private eventDispatcherInstance; private settingsV2; private userSessionData; private botInstance; private constructor(); static getInstance(): DataFacade; static resetInstance(): void; execute(services: ServiceV2[], servicesData: ServiceData[], consentAction: CONSENT_ACTION, consentType: CONSENT_TYPE, consentString?: GraphQLConsentString, enableDeprecatedV1ConsentSaving?: boolean): void; getMergedServicesAndSettingsFromStorage(settingsData: Data): { dataTransferSettings: Maybe<DataTransferSettings>; mergedServices: ServiceBasic[]; mergedServicesData: ServiceData[]; mergedSettingsData: Data; updatedEssentialServices: ServiceBasic[]; }; getLatestConsentType(consentHistory: ConsentHistory[]): CONSENT_TYPE; getLatestConsentAction(consentHistory: ConsentHistory[]): CONSENT_ACTION; setUserSessionData(session: UserSessionData): void; mergeServicesAndSettings(mergedServices: ServiceBasic[], mergedServicesData: ServiceData[], dataTransferSettings: Maybe<DataTransferSettings>, updatedEssentialServices: ServiceBasic[], servicesLabels: ServiceLabels[], enableDeprecatedV1ConsentSaving?: boolean): DataTransferObject[]; /** * This method is responsible to restore the user session based on the following criteria: * 1) Try to restore the session from the controller ID (API) * 2) Try to restore from the session that was given to the browser UI via global variable (in-App SDK/Web View) * 3) Try to restore from the cross domain iFrame * If none of the above is available, then simply returns false */ restoreUserSession(dpsJson: DpsJsonResponse): Promise<boolean>; /** * Restores the Cross Domain session */ getCrossDomainSessionData(): Promise<UserSessionData>; /** * Restores the Cross Device session */ getCrossDeviceSessionData(controllerId: string): Promise<UserSessionData>; /** * Note: Remember that timestamp is retrieved from backend in seconds while we store it in milliseconds in frontend. */ restoreData(userSessionData: UserSessionData, dpsJson: DpsJsonResponse): Promise<boolean>; private getDataFacadeServices; private getMergedAndUpdatedEssentialServices; getMergedNonEssentialServices<T extends { consent: Consent; id: string; processorId: string; language: Language | null; version: string; }>(services: T[], storageSettings: StorageSettings): T[]; private resolveTimestamp; } export declare const appendConsentsToHistory: <T extends { consent: Consent; id: string; }>(services: T[], dataTransferObjects: DataTransferObject[]) => T[];