ngx-cookie-ssr
Version:
Ng Cookie Service is a simple cookie service for Angular applications. This is heavily inspired by [ngx-cookie-service](https://github.com/stevermeister/ngx-cookie-service). But only intended to be used with Angular 19 and onwards.
126 lines (123 loc) • 3.97 kB
TypeScript
import * as i0 from '@angular/core';
declare class CookieService {
private document;
private platformId;
private request;
private responseInit;
private readonly documentIsAccessible;
private cookie;
/**
* Get cookie Regular Expression
*
* @param name Cookie name
* @returns property RegExp
*
* @author: Stepan Suvorov
*/
static getCookieRegExp(name: string): RegExp;
/**
* Gets the unencoded version of an encoded component of a Uniform Resource Identifier (URI).
*
* @param encodedURIComponent A value representing an encoded URI component.
*
* @returns The unencoded version of an encoded component of a Uniform Resource Identifier (URI).
*
* @author: Stepan Suvorov
*/
static safeDecodeURIComponent(encodedURIComponent: string): string;
/**
* Return `true` if {@link Document} is accessible, otherwise return `false`
*
* @param name Cookie name
* @returns boolean - whether cookie with specified name exists
*
* @author: Stepan Suvorov
*/
check(name: string): boolean;
/**
* Get cookies by name
*
* @param name Cookie name
* @returns property value
*
* @author: Stepan Suvorov
*/
get(name: string): string;
/**
* Get all cookies in JSON format
*
* @returns all the cookies in json
*
* @author: Stepan Suvorov
*/
getAll(): {
[key: string]: string;
};
/**
* Set cookie based on provided information
*
* @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 same site token `Lax`, `None`, or `Strict`. Defaults to `Lax`
* @param partitioned Partitioned flag
*
* @author: Stepan Suvorov
*/
set(name: string, value: string, expires?: number | Date, path?: string, domain?: string, secure?: boolean, sameSite?: 'Lax' | 'None' | 'Strict', partitioned?: boolean): void;
/**
* Set cookie based on provided information
*
* Cookie's parameters:
* <pre>
* expires Number of days until the cookies expires or an actual `Date`
* path Cookie path
* domain Cookie domain
* secure Cookie secure flag
* sameSite OWASP same site token `Lax`, `None`, or `Strict`. Defaults to `Lax`
* </pre>
*
* @param name Cookie name
* @param value Cookie value
* @param options Body with cookie's params
*
* @author: Stepan Suvorov
*/
set(name: string, value: string, options?: {
expires?: number | Date;
path?: string;
domain?: string;
secure?: boolean;
sameSite?: 'Lax' | 'None' | 'Strict';
partitioned?: boolean;
}): void;
/**
* Delete cookie by name
*
* @param name Cookie name
* @param path Cookie path
* @param domain Cookie domain
* @param secure Cookie secure flag
* @param sameSite Cookie sameSite flag - https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie/SameSite
*
* @author: Stepan Suvorov
*/
delete(name: string, path?: string, domain?: string, secure?: boolean, sameSite?: 'Lax' | 'None' | 'Strict'): void;
/**
* Delete all cookies
*
* @param path Cookie path
* @param domain Cookie domain
* @param secure Is the Cookie secure
* @param sameSite Is the cookie same site
*
* @author: Stepan Suvorov
*/
deleteAll(path?: string, domain?: string, secure?: boolean, sameSite?: 'Lax' | 'None' | 'Strict'): void;
static ɵfac: i0.ɵɵFactoryDeclaration<CookieService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<CookieService>;
}
export { CookieService };