1 import type { IStorageProvider } from '@unleash/proxy-client-react';
3 import { FLAGS_WITH_VARIANT } from '../UnleashFeatureFlagsVariants';
4 import { type FeatureFlagToggle } from '../interface';
5 import saveWhitelistedFlagInCookies from './UnleashCookiesProvider';
7 export default class ProtonUnleashStorageProvider implements IStorageProvider {
8 private prefix = 'unleash:repository';
10 public async save(name: string, data: FeatureFlagToggle[]) {
11 const repo = JSON.stringify(data);
13 const key = `${this.prefix}:${name}`;
15 window.localStorage.setItem(key, repo);
16 saveWhitelistedFlagInCookies(data, FLAGS_WITH_VARIANT);
20 public get(name: string) {
22 const key = `${this.prefix}:${name}`;
23 const data = window.localStorage.getItem(key);
24 return data ? JSON.parse(data) : undefined;