@usercentrics/cmp-browser-sdk
Version:
Usercentrics CMP Browser SDK
84 lines (83 loc) • 4.56 kB
TypeScript
import { DataTransferSettings } from '../../modules/helpers';
import { InteractionType, StorageCcpa, StorageConsentsBuffer, StorageConsentsV2Buffer, StorageGcm, StorageService as StorageServiceInterface, StorageSettings, StorageTCF, StorageTCFVendorsDisclosed } from './interfaces';
import { ConsentDTOV2 } from '../DataFacade/interfaces';
import { Consents } from '../Api/interfaces/interfaces';
import { IntMap } from '../../interfaces';
import { LegacyStorageData } from './interfaces/interfaces.migration.legacy';
import { Service } from '../SettingsV2/interfaces/interfaces';
import { ServiceBasic } from '../SettingsV2/Data/interfaces';
import { UserCountryResponse } from '../Location/interfaces';
export type Maybe<T> = T | null | undefined;
export default class StorageService {
localStorage: null | Storage;
sessionStorage: null | Storage;
private static instance;
private storeServiceIdToNameMapping;
private constructor();
static getInstance(): StorageService;
static resetInstance(): void;
setStoreServiceIdToNameMapping(value: boolean): void;
getStoreServiceIdToNameMapping(): boolean;
init(): void;
static appendToConsentsBuffer(consents: Consents): void;
static appendToConsentsV2Buffer(consents: ConsentDTOV2): void;
static clearOnNewSettingsId(settingsId: string): void;
static findBufferItem(consents: Consents): StorageConsentsBuffer | undefined;
static findV2BufferItem(consents: ConsentDTOV2): StorageConsentsV2Buffer | undefined;
static removeConsentsBufferItem(storageConsentsBuffer: StorageConsentsBuffer): void;
static removeConsentsV2BufferItem(storageConsentsBuffer: StorageConsentsV2Buffer): void;
static getCcpaString(): string;
static getCcpaData(): StorageCcpa | null;
static fetchConsentsBuffer(): StorageConsentsBuffer[];
static fetchConsentsV2Buffer(): StorageConsentsV2Buffer[];
static fetchControllerId(): string;
static fetchLanguage(): string;
static fetchServices(): StorageServiceInterface[];
static fetchLegacySettings(): LegacyStorageData;
static fetchSettings(): StorageSettings;
static fetchSettingsId(): string;
static fetchSettingsVersion(): string;
static fetchTCFData(): StorageTCF;
static fetchTCFVendorsDisclosedObject(gvlVendors?: IntMap<{
id: number;
legIntPurposes: number[];
purposes: number[];
specialPurposes: number[];
}>): StorageTCFVendorsDisclosed;
static fetchTCString(): string;
static fetchACString(): string;
static fetchUserActionPerformed(): boolean;
static fetchActionTypePerformed(): InteractionType;
static fetchUserCountryResponse(): UserCountryResponse | null;
static setUserCountryResponse(userCountryResponse: UserCountryResponse): void;
static setActionTypePerformed(actionType: InteractionType): void;
static mapServices(services: Pick<Service, 'consent' | 'id' | 'processorId'>[]): StorageServiceInterface[];
static mapSettings(dataTransferSettings: DataTransferSettings, services: Pick<ServiceBasic, 'consent' | 'id' | 'processorId'>[]): StorageSettings;
/**
* Migrating the Legacy Settings (from Vanilla app) to the Browser SDK as part of the EUD-47
* If the settings exists, meaning a consent has been given prior to that, the whole migration is skipped.
* If not, before try to migrate any data it's checked if there is anything to be migrated.
* If so, the migration starts and maps all the old data into the new format
* If successful, the migrated data is saved into the local storage.
* Lastly, in any case the legacy data is removed.
*/
static migrateLegacySettings(settingsId: string): void;
static saveSettings(settings: StorageSettings, services?: Pick<ServiceBasic, 'id' | 'name'>[]): void;
static saveTCFData(tcfData: StorageTCF): void;
static fetchGcmData(): StorageGcm | null;
static saveGcmData(gcmData: StorageGcm): void;
static saveTCString(tcString: string): void;
static setCcpaTimeStamp(data?: StorageCcpa): void;
static getCcpaTimeStamp(): number;
static setCcpaString(ccpaString: string): void;
static settingsExist(): boolean;
static setUserActionPerformed(isActionPerformed: boolean): void;
static clearCcpa(): void;
static clearCcpaData(): void;
static clearTcf(): void;
static clearGcm(): void;
private static clear;
static clearAll(): Promise<void>;
static fetchAbTestVariant(variantKeys: string[]): string;
private static clearLegacySettings;
}