{"version":3,"file":"bravobit-bb-foundation-storage.mjs","sources":["../../../projects/bb-foundation/storage/src/lib/interfaces/strategy.interface.ts","../../../projects/bb-foundation/storage/src/lib/strategies/polyfill-storage.strategy.ts","../../../projects/bb-foundation/storage/src/lib/strategies/cookie-storage.strategy.ts","../../../projects/bb-foundation/storage/src/lib/strategies/memory-storage.strategy.ts","../../../projects/bb-foundation/storage/src/lib/storage.service.ts","../../../projects/bb-foundation/storage/src/bravobit-bb-foundation-storage.ts"],"sourcesContent":["import {StorageAttributes} from './attributes.interface';\n\nexport interface StorageStrategy {\n\n    get<T = any>(token: string): T | undefined;\n\n    set<T = any>(token: string, value: T): void;\n\n    set<T = any>(token: string, value: T, attributes?: StorageAttributes): void;\n\n    remove(token: string): void;\n\n    remove(token: string, attributes?: StorageAttributes): void;\n\n    clear(): void;\n\n    clear(attributes?: StorageAttributes): void;\n\n    isSupported(): boolean;\n\n}\n\nexport enum StorageOption {\n    Local = 'local',\n    Cookie = 'cookie',\n    Session = 'session',\n    Memory = 'memory'\n}\n","import {PolyfillStorageAttributes} from '../interfaces/attributes.interface';\nimport {StorageStrategy} from '../interfaces/strategy.interface';\n\nexport class PolyfillStorage implements StorageStrategy {\n\n    // State.\n    private readonly _isSupported: boolean = false;\n\n    constructor(private _storage?: Storage) {\n        // Check if the storage is supported.\n        this._isSupported = this.testIfSupported();\n    }\n\n    get<T = any>(token: string) {\n        // Validate that the storage is supported.\n        if (!this._isSupported) {\n            return undefined;\n        }\n\n        return this.decode<T>(token);\n    }\n\n    set<T = any>(token: string, value: T, attributes?: PolyfillStorageAttributes) {\n        // Validate that the storage is supported.\n        if (!this._isSupported) {\n            return;\n        }\n\n        // Stringify the data.\n        const rawData = this.encode<T>(value, {...attributes});\n\n        // Set the raw data in the storage.\n        this._storage.setItem(token, rawData);\n    }\n\n    remove(token: string) {\n        // Validate that the storage is supported.\n        if (!this._isSupported) {\n            return;\n        }\n\n        // Remove the item in the storage.\n        this._storage.removeItem(token);\n    }\n\n    clear() {\n        // Validate that the storage is supported.\n        if (!this._isSupported) {\n            return;\n        }\n\n        // Clear the storage.\n        this._storage.clear();\n    }\n\n    isSupported() {\n        return this._isSupported;\n    }\n\n    private decode<T>(token: string) {\n        // Retrieve the raw data from the storage.\n        const rawData = this._storage.getItem(token);\n\n        // Try to parse the data.\n        let parsedData: T | undefined = undefined;\n\n        // Only parse the data when it is not null.\n        if (rawData !== null) {\n            try {\n                const {value, expires} = JSON.parse(rawData);\n\n                if (expires !== undefined) {\n                    const now = Date.now();\n                    const expireDate = new Date(expires).getTime();\n\n                    if (expireDate <= now) {\n                        this.remove(token);\n                        return undefined;\n                    }\n                }\n\n                parsedData = value;\n            } catch {\n                // We dont do anything with failed parsing.\n            }\n        }\n\n        // Return the parsed data.\n        return parsedData;\n    }\n\n    private encode = <T>(value: T, attributes: PolyfillStorageAttributes) => {\n        // Make sure the expires attribute is a date and not a number.\n        const data = {value};\n\n        if (typeof attributes.expires === 'number') {\n            attributes.expires = new Date(attributes.expires);\n        }\n\n        if (attributes.expires) {\n            data['expires'] = attributes.expires;\n        }\n\n        return JSON.stringify(data);\n    };\n\n    private testIfSupported = () => {\n        if (typeof this._storage === 'undefined') {\n            return false;\n        }\n\n        try {\n            const x = '__storage_test__';\n            this._storage.setItem(x, x);\n            this._storage.removeItem(x);\n            return true;\n        } catch (error) {\n            return error instanceof DOMException\n                && (error.name === 'QuotaExceededError' || error.name === 'NS_ERROR_DOM_QUOTA_REACHED')\n                && (this._storage && this._storage.length !== 0);\n        }\n    };\n\n}\n","import {CookieStorageAttributes} from '../interfaces/attributes.interface';\nimport {StorageStrategy} from '../interfaces/strategy.interface';\n\nexport class CookieStorage implements StorageStrategy {\n\n    // State.\n    private readonly _isSupported: boolean = false;\n\n    constructor(private _isBrowser: boolean,\n                private _cookieString?: string) {\n        // Check if the storage is supported.\n        this._isSupported = this.testIfSupported();\n    }\n\n    get<T = any>(token: string) {\n        // Get all values and pick one out.\n        const values = this.all();\n        return values?.[token] as T;\n    }\n\n    set<T = any>(token: string, value: T, attributes?: CookieStorageAttributes) {\n        // Validate that the storage is supported.\n        if (!this._isSupported) {\n            return;\n        }\n\n        // Write a new cookie.\n        document.cookie = this.encode(token, value, {path: '/', sameSite: 'Lax', ...attributes});\n    }\n\n    remove(token: string, attributes?: CookieStorageAttributes) {\n        // Validate that the storage is supported.\n        if (!this._isSupported) {\n            return;\n        }\n\n        this.set(token, '', {...attributes, expires: -1});\n    }\n\n    clear(attributes?: CookieStorageAttributes) {\n        // Validate that the storage is supported.\n        if (!this._isSupported) {\n            return;\n        }\n\n        const items = this.all();\n\n        for (const token in items) {\n            this.remove(token, attributes);\n        }\n    }\n\n    isSupported() {\n        return this._isSupported;\n    }\n\n    private all() {\n        const cookieString = this._isBrowser\n            ? document?.cookie\n            : this._cookieString;\n\n        return this.decode(cookieString);\n    }\n\n    private encode(token: string, value: any, attributes: CookieStorageAttributes) {\n        // Encode the token.\n        const encodedToken = encodeURIComponent(token)\n            .replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent)\n            .replace(/\\(/g, '%28').replace(/\\)/g, '%29');\n\n        const rawValue = JSON.stringify(value);\n\n        // Encode the value.\n        const encodedValue = encodeURIComponent(rawValue)\n            .replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent);\n\n        // Return the completed encoded string.\n        return [encodedToken, '=', encodedValue, this.stringifyCookie(attributes)].join('');\n    }\n\n    private decode = (cookieString: string) => {\n        const result: { [token: string]: any } = {};\n        const cookies = cookieString ? cookieString.split('; ') : [];\n        const rdecode = /(%[0-9A-Z]{2})+/g;\n\n        for (let index = 0; index < cookies.length; index++) {\n            const parts = cookies[index].split('=');\n            let cookie = parts.slice(1).join('=');\n\n            if (cookie.charAt(0) === '\"') {\n                cookie = cookie.slice(1, -1);\n            }\n\n            try {\n                const name = parts[0].replace(rdecode, decodeURIComponent);\n                const value = cookie.replace(rdecode, decodeURIComponent);\n                result[name] = this.jsonParse(value);\n            } catch {\n                // Ignore cookies with an invalid name/value encoding.\n            }\n        }\n\n        return result;\n    };\n\n    private jsonParse = <T = any>(rawValue: string) => {\n        // Try to parse the data.\n        let parsedValue: T | undefined = undefined;\n\n        // Only parse the value when it is not null.\n        if (rawValue !== undefined) {\n            try {\n                parsedValue = JSON.parse(rawValue);\n            } catch {\n                // The string could not be parsed to JSON.\n            }\n        }\n\n        // Return the parsed value.\n        return parsedValue;\n    };\n\n    private stringifyCookie(attributes: CookieStorageAttributes) {\n        // Make sure the expires attribute is a date and not a number.\n        if (typeof attributes.expires === 'number') {\n            const expires = new Date();\n            expires.setMilliseconds(expires.getMilliseconds() + attributes.expires * 864e+5);\n            attributes.expires = expires;\n        }\n\n        // Force secure when sameSite=None.\n        if (attributes.sameSite === 'None') {\n            attributes.secure = true;\n            console?.warn?.('Cooke was forced with secure flag because sameSite=None');\n        }\n\n        // Stringify all attributes.\n        return this.stringifyAttribute('Expires', attributes.expires ? attributes.expires.toUTCString() : '')\n            + this.stringifyAttribute('Domain', attributes.domain)\n            + this.stringifyAttribute('Path', attributes.path)\n            + this.stringifyAttribute('Secure', attributes.secure)\n            + this.stringifyAttribute('SameSite', attributes.sameSite);\n    }\n\n    private stringifyAttribute = (token: string, value: string | boolean | undefined) => {\n        if (!value) {\n            return '';\n        }\n\n        const stringified = `; ${token}`;\n\n        // Boolean attributes should not have a value.\n        if (value === true) {\n            return stringified;\n        }\n\n        return stringified + `= ${value}`;\n    };\n\n    private testIfSupported = () => {\n        // We are using an aggressive test here, because we cannot rely on navigator.cookieEnabled\n        // it does not return the correct value at all times.\n        const testCookieString = `bbcookietest`;\n        try {\n            document.cookie = `${testCookieString}=1`;\n            const result = document.cookie.indexOf(`${testCookieString}=`) !== -1;\n            document.cookie = `${testCookieString}=1; expires=Thu, 01-Jan-1970 00:00:01 GMT`;\n            return result;\n        } catch {\n            return false;\n        }\n    };\n\n}\n","import {MemoryStorageAttributes} from '../interfaces/attributes.interface';\nimport {MemoryStorageData} from '../interfaces/memory.interface';\nimport {StorageStrategy} from '../interfaces/strategy.interface';\n\nexport class MemoryStorage implements StorageStrategy {\n\n    // State.\n    private _storage: MemoryStorageData = {};\n\n    get<T = any>(token: string): T {\n        // Grab the data from the memory storage.\n        const result = this._storage[token];\n\n        // Validate the data exists.\n        if (result === undefined) {\n            return undefined;\n        }\n\n        // Extract the value and expire date.\n        const {value, expires} = result;\n\n        // Validate the value is still valid.\n        if (expires !== undefined) {\n            const now = Date.now();\n            const expireDate = new Date(expires).getTime();\n\n            // Remove the value if it is expired.\n            if (expireDate <= now) {\n                this.remove(token);\n                return undefined;\n            }\n        }\n\n        // Return the value.\n        return value;\n    }\n\n    set<T = any>(token: string, value: T, attributes?: MemoryStorageAttributes) {\n        // Save the encoded value with the attributes.\n        this._storage[token] = this.encode<T>(value, {...attributes});\n    }\n\n    remove(token: string) {\n        delete this._storage[token];\n    }\n\n    clear() {\n        this._storage = {};\n    }\n\n    isSupported() {\n        // The memory storage is always supported.\n        return true;\n    }\n\n    private encode = <T>(value: T, attributes: MemoryStorageAttributes) => {\n        const data = {value};\n\n        // Make sure the expires is a date object.\n        if (typeof attributes.expires === 'number') {\n            attributes.expires = new Date(attributes.expires);\n        }\n\n        // Add the expire date if it was set.\n        if (attributes.expires) {\n            data['expires'] = attributes.expires;\n        }\n\n        // Return the encoded data.\n        return data;\n    };\n\n}\n","import {StorageOption, StorageStrategy} from './interfaces/strategy.interface';\nimport {PolyfillStorage} from './strategies/polyfill-storage.strategy';\nimport {StorageAttributes} from './interfaces/attributes.interface';\nimport {CookieStorage} from './strategies/cookie-storage.strategy';\nimport {MemoryStorage} from './strategies/memory-storage.strategy';\nimport {inject, Injectable} from '@angular/core';\nimport {Platform} from '@angular/cdk/platform';\nimport {COOKIE} from '@bravobit/bb-foundation';\n\ndeclare let ngDevMode;\n\n@Injectable({\n    providedIn: 'root'\n})\nexport class Storage implements StorageStrategy {\n\n    // Dependencies.\n    private readonly _platform: Platform = inject(Platform);\n    private readonly _cookieString?: string = inject(COOKIE, {optional: true});\n\n    // All available strategies (sorted best to last).\n    private readonly _strategies: { [key in `${StorageOption}`]: StorageStrategy };\n\n    // Current selected storage strategy.\n    private readonly _current: StorageStrategy | null = null;\n\n    constructor() {\n        this._strategies = {\n            [StorageOption.Local]: new PolyfillStorage(this.getLocalStorage()),\n            [StorageOption.Cookie]: new CookieStorage(this._platform.isBrowser, this._cookieString),\n            [StorageOption.Session]: new PolyfillStorage(this.getSessionStorage()),\n            [StorageOption.Memory]: new MemoryStorage()\n        };\n\n        this._current = this.findBestStorageStrategy();\n    }\n\n    select(option: StorageOption | StorageOption[]) {\n        const items = Array.isArray(option) ? option : [option];\n        for (const item of items) {\n            const strategy = this._strategies?.[item] ?? null;\n            if (strategy && strategy.isSupported()) {\n                return strategy;\n            }\n        }\n\n        if (this._platform.isBrowser && (typeof ngDevMode === 'undefined' || ngDevMode)) {\n            console?.warn?.('[Storage]: Could not select proper storage option, using memory fallback.');\n        }\n\n        // Always return as a fallback the memory storage since it should be always available.\n        return this._strategies.memory;\n    }\n\n    get local() {\n        return this._strategies.local;\n    }\n\n    get cookie() {\n        return this._strategies.cookie;\n    }\n\n    get session() {\n        return this._strategies.session;\n    }\n\n    get memory() {\n        return this._strategies.memory;\n    }\n\n    get<T = any>(token: string): T {\n        return this._current.get(token);\n    }\n\n    set<T = any>(token: string, value: T, attributes?: StorageAttributes) {\n        this._current.set<T>(token, value, attributes);\n    }\n\n    remove(token: string, attributes?: StorageAttributes) {\n        this._current.remove(token, attributes);\n    }\n\n    clear(attributes?: StorageAttributes) {\n        this._current.clear(attributes);\n    }\n\n    isSupported() {\n        return !!this._current;\n    }\n\n    private findBestStorageStrategy() {\n        // Loop through all available strategies to find the best.\n        for (const type in this._strategies) {\n            const strategy = this._strategies?.[type];\n\n            // The first supported strategy is the best.\n            if (strategy?.isSupported()) {\n                return strategy;\n            }\n        }\n\n        // If no strategy was returned we fallback to memory\n        // storage since it should be available always.\n        if (this._platform.isBrowser && (typeof ngDevMode === 'undefined' || ngDevMode)) {\n            console?.warn?.('[Storage]: Could not select proper storage option, using memory fallback.');\n        }\n\n        return this._strategies.memory;\n    }\n\n    private getLocalStorage = () => {\n        try {\n            return (typeof window !== 'undefined') ? window?.localStorage : null;\n        } catch {\n            return null;\n        }\n    };\n\n    private getSessionStorage = () => {\n        try {\n            return (typeof window !== 'undefined') ? window?.sessionStorage : null;\n        } catch {\n            return null;\n        }\n    };\n\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;;IAsBY;AAAZ,CAAA,UAAY,aAAa,EAAA;AACrB,IAAA,aAAA,CAAA,OAAA,CAAA,GAAA,OAAe;AACf,IAAA,aAAA,CAAA,QAAA,CAAA,GAAA,QAAiB;AACjB,IAAA,aAAA,CAAA,SAAA,CAAA,GAAA,SAAmB;AACnB,IAAA,aAAA,CAAA,QAAA,CAAA,GAAA,QAAiB;AACrB,CAAC,EALW,aAAa,KAAb,aAAa,GAAA,EAAA,CAAA,CAAA;;MCnBZ,eAAe,CAAA;AAKJ,IAAA,QAAA;;IAFH,YAAY,GAAY,KAAK;AAE9C,IAAA,WAAA,CAAoB,QAAkB,EAAA;QAAlB,IAAA,CAAA,QAAQ,GAAR,QAAQ;;AAExB,QAAA,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,eAAe,EAAE;IAC9C;AAEA,IAAA,GAAG,CAAU,KAAa,EAAA;;AAEtB,QAAA,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE;AACpB,YAAA,OAAO,SAAS;QACpB;AAEA,QAAA,OAAO,IAAI,CAAC,MAAM,CAAI,KAAK,CAAC;IAChC;AAEA,IAAA,GAAG,CAAU,KAAa,EAAE,KAAQ,EAAE,UAAsC,EAAA;;AAExE,QAAA,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE;YACpB;QACJ;;AAGA,QAAA,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAI,K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