UNPKG

@terminus/ngx-tools

Version:

[![CircleCI][circle-badge]][circle-link] [![codecov][codecov-badge]][codecov-project] [![semantic-release][semantic-release-badge]][semantic-release] [![MIT License][license-image]][license-url] <br> [![NPM version][npm-version-image]][npm-url] [![Github

67 lines (66 loc) 1.93 kB
import { InjectionToken } from '@angular/core'; /** * A service to manage browser cookies */ export declare class TsCookieService { private _document; private platformId; private readonly documentIsAccessible; private readonly document; constructor(_document: any, platformId: InjectionToken<Object>); /** * Set a cookie * * @param name - Cookie name * @param value - Cookie value * @param expires - Number of days until the cookies expires or an actual `Date` * @param path - Cookie path * @param domain - Cookie domain * @param secure - Secure flag * @param sameSite - OWASP samesite token `Lax` or `Strict` */ set(name: string, value: string, expires?: number | Date, path?: string, domain?: string, secure?: boolean, sameSite?: 'Lax' | 'Strict'): void; /** * Verify if a cookie exists * * @param name - Cookie name * @returns boolean */ check(name: string): boolean; /** * @param name - Cookie name * @returns any */ get(name: string): string; /** * Get all cookies * * @returns Object containing all cookies */ getAll(): Record<string, any>; /** * Delete a cookie * * NOTE: This clears the value and sets the cookie as expired. The browser will delete the expired cookie the next time a request * is made to the domain. * * @param name - Cookie name * @param path - Cookie path * @param domain - Cookie domain */ delete(name: string, path?: string, domain?: string): void; /** * Delete all cookies * * @param path - Cookie path * @param domain - Cookie domain */ deleteAll(path?: string, domain?: string): void; /** * Get a regular expression based on a cookie name * * @param name - Cookie name * @returns RegExp */ private getCookieRegExp; }