@cedx/cookies
Advanced tools
Comparing version 6.0.0 to 6.0.1
/** | ||
* An event dispatched when the cookie store has been changed. | ||
*/ | ||
export declare class CookieEvent extends Event { | ||
export class CookieEvent extends Event { | ||
/** | ||
* The event type. | ||
* @type {string} | ||
* @readonly | ||
*/ | ||
static readonly type = "cookie:change"; | ||
static readonly type: string; | ||
/** | ||
* Creates a new cookie event. | ||
* @param {string} key The changed key. | ||
* @param {string|null} oldValue The original value. | ||
* @param {string|null} newValue The new value. | ||
*/ | ||
constructor(key: string, oldValue?: string | null, newValue?: string | null); | ||
/** | ||
* The changed key. | ||
* @type {string} | ||
* @readonly | ||
*/ | ||
@@ -15,2 +26,4 @@ readonly key: string; | ||
* The new value. | ||
* @type {string|null} | ||
* @readonly | ||
*/ | ||
@@ -20,12 +33,7 @@ readonly newValue: string | null; | ||
* The original value. | ||
* @type {string|null} | ||
* @readonly | ||
*/ | ||
readonly oldValue: string | null; | ||
/** | ||
* Creates a new cookie event. | ||
* @param key The changed key. | ||
* @param oldValue The original value. | ||
* @param newValue The new value. | ||
*/ | ||
constructor(key: string, oldValue?: string | null, newValue?: string | null); | ||
} | ||
//# sourceMappingURL=cookie_event.d.ts.map |
@@ -1,8 +0,13 @@ | ||
import type { SameSite } from "./same_site.js"; | ||
/** | ||
* Defines the attributes of a HTTP cookie. | ||
*/ | ||
export declare class CookieOptions { | ||
export class CookieOptions { | ||
/** | ||
* Creates new cookie options. | ||
* @param {Partial<CookieOptionsParams>} options An object providing values to initialize this instance. | ||
*/ | ||
constructor(options?: Partial<CookieOptionsParams>); | ||
/** | ||
* The domain for which the cookie is valid. | ||
* @type {string} | ||
*/ | ||
@@ -12,2 +17,3 @@ domain: string; | ||
* The expiration date and time for the cookie. | ||
* @type {Date|null} | ||
*/ | ||
@@ -17,2 +23,3 @@ expires: Date | null; | ||
* The maximum duration, in seconds, until the cookie expires. | ||
* @type {number} | ||
*/ | ||
@@ -22,2 +29,3 @@ maxAge: number; | ||
* The path to which the cookie applies. | ||
* @type {string} | ||
*/ | ||
@@ -27,16 +35,13 @@ path: string; | ||
* The cross-site requests policy. | ||
* @type {import("./same_site.js").SameSite|null} | ||
*/ | ||
sameSite: SameSite | null; | ||
sameSite: import("./same_site.js").SameSite | null; | ||
/** | ||
* Value indicating whether to transmit the cookie over HTTPS only. | ||
* @type {boolean} | ||
*/ | ||
secure: boolean; | ||
/** | ||
* Creates new cookie options. | ||
* @param options An object providing values to initialize this instance. | ||
*/ | ||
constructor(options?: Partial<CookieOptionsParams>); | ||
/** | ||
* Returns a string representation of this object. | ||
* @returns The string representation of this object. | ||
* @returns {string} The string representation of this object. | ||
*/ | ||
@@ -46,5 +51,5 @@ toString(): string; | ||
/** | ||
* Defines the parameters of a {@link CookieOptions} instance. | ||
* Defines the parameters of a {@link CookieOptions } instance. | ||
*/ | ||
export interface CookieOptionsParams { | ||
export type CookieOptionsParams = { | ||
/** | ||
@@ -69,3 +74,3 @@ * The domain for which the cookie is valid. | ||
*/ | ||
sameSite: SameSite | null; | ||
sameSite: import("./same_site.js").SameSite | null; | ||
/** | ||
@@ -75,3 +80,3 @@ * Value indicating whether to transmit the cookie over HTTPS only. | ||
secure: boolean; | ||
} | ||
}; | ||
//# sourceMappingURL=cookie_options.d.ts.map |
@@ -1,23 +0,24 @@ | ||
import { CookieEvent } from "./cookie_event.js"; | ||
import { CookieOptions, type CookieOptionsParams } from "./cookie_options.js"; | ||
/** | ||
* Provides access to the [HTTP Cookies](https://developer.mozilla.org/docs/Web/HTTP/Cookies). | ||
*/ | ||
export declare class CookieStore extends EventTarget { | ||
#private; | ||
export class CookieStore extends EventTarget { | ||
/** | ||
* The default cookie options. | ||
* The map of all cookies. | ||
* @type {Map<string, string>} | ||
*/ | ||
readonly defaults: CookieOptions; | ||
static get all(): Map<string, string>; | ||
/** | ||
* Creates a new cookie store. | ||
* @param options An object providing values to initialize this instance. | ||
* @param {Partial<CookieStoreOptions>} options An object providing values to initialize this instance. | ||
*/ | ||
constructor(options?: Partial<CookieStoreOptions>); | ||
/** | ||
* The map of all cookies. | ||
* The default cookie options. | ||
* @type {CookieOptions} | ||
* @readonly | ||
*/ | ||
static get all(): Map<string, string>; | ||
readonly defaults: CookieOptions; | ||
/** | ||
* The keys of this cookie store. | ||
* @type {string[]} | ||
*/ | ||
@@ -27,25 +28,21 @@ get keys(): string[]; | ||
* The number of entries in this cookie store. | ||
* @type {number} | ||
*/ | ||
get length(): number; | ||
/** | ||
* Returns a new iterator that allows iterating the entries of this cookie store. | ||
* @returns An iterator for the entries of this cookie store. | ||
*/ | ||
[Symbol.iterator](): IterableIterator<[string, string]>; | ||
/** | ||
* Removes all entries from this cookie store. | ||
* @param options The cookie options. | ||
* @param {Partial<import("./cookie_options.js").CookieOptionsParams>} options The cookie options. | ||
*/ | ||
clear(options?: Partial<CookieOptionsParams>): void; | ||
clear(options?: Partial<import("./cookie_options.js").CookieOptionsParams>): void; | ||
/** | ||
* Removes the value associated with the specified key. | ||
* @param key The cookie name. | ||
* @param options The cookie options. | ||
* @returns The value associated with the key before it was removed. | ||
* @param {string} key The cookie name. | ||
* @param {Partial<import("./cookie_options.js").CookieOptionsParams>} options The cookie options. | ||
* @returns {string|null} The value associated with the key before it was removed. | ||
*/ | ||
delete(key: string, options?: Partial<CookieOptionsParams>): string | null; | ||
delete(key: string, options?: Partial<import("./cookie_options.js").CookieOptionsParams>): string | null; | ||
/** | ||
* Gets the value associated to the specified key. | ||
* @param key The cookie name. | ||
* @returns The cookie value, or `null` if the key does not exist. | ||
* @param {string} key The cookie name. | ||
* @returns {string|null} The cookie value, or `null` if the key does not exist. | ||
*/ | ||
@@ -55,4 +52,5 @@ get(key: string): string | null; | ||
* Gets the deserialized value associated with the specified key. | ||
* @param key The cookie name. | ||
* @returns The cookie value, or `null` if the key does not exist or the value cannot be deserialized. | ||
* @template T | ||
* @param {string} key The cookie name. | ||
* @returns {T|null} The cookie value, or `null` if the key does not exist or the value cannot be deserialized. | ||
*/ | ||
@@ -62,4 +60,4 @@ getObject<T>(key: string): T | null; | ||
* Gets a value indicating whether this cookie store contains the specified key. | ||
* @param key The cookie name. | ||
* @returns `true` if this cookie store contains the specified key, otherwise `false`. | ||
* @param {string} key The cookie name. | ||
* @returns {boolean} `true` if this cookie store contains the specified key, otherwise `false`. | ||
*/ | ||
@@ -69,4 +67,4 @@ has(key: string): boolean; | ||
* Registers a function that will be invoked whenever the `change` event is triggered. | ||
* @param listener The event handler to register. | ||
* @returns This instance. | ||
* @param {(event: CookieEvent) => void} listener The event handler to register. | ||
* @returns {this} This instance. | ||
* @event | ||
@@ -77,36 +75,38 @@ */ | ||
* Associates a given value with the specified key. | ||
* @param key The cookie name. | ||
* @param value The cookie value. | ||
* @param options The cookie options. | ||
* @returns This instance. | ||
* @param {string} key The cookie name. | ||
* @param {string} value The cookie value. | ||
* @param {Partial<import("./cookie_options.js").CookieOptionsParams>} options The cookie options. | ||
* @returns {this} This instance. | ||
* @throws `Error` if the cookie name is invalid. | ||
*/ | ||
set(key: string, value: string, options?: Partial<CookieOptionsParams>): this; | ||
set(key: string, value: string, options?: Partial<import("./cookie_options.js").CookieOptionsParams>): this; | ||
/** | ||
* Serializes and associates a given `value` with the specified `key`. | ||
* @param key The cookie name. | ||
* @param value The cookie value. | ||
* @param options The cookie options. | ||
* @returns This instance. | ||
* @template T | ||
* @param {string} key The cookie name. | ||
* @param {T} value The cookie value. | ||
* @param {Partial<import("./cookie_options.js").CookieOptionsParams>} options The cookie options. | ||
* @returns {this} This instance. | ||
*/ | ||
setObject<T>(key: string, value: T, options?: Partial<CookieOptionsParams>): this; | ||
setObject<T_1>(key: string, value: T_1, options?: Partial<import("./cookie_options.js").CookieOptionsParams>): this; | ||
/** | ||
* Returns a JSON representation of this object. | ||
* @returns The JSON representation of this object. | ||
* @returns {[string, string][]} The JSON representation of this object. | ||
*/ | ||
toJSON(): [string, string][]; | ||
/** | ||
* Returns a string representation of this object. | ||
* @returns The string representation of this object. | ||
* Returns a new iterator that allows iterating the entries of this cookie store. | ||
* @returns {IterableIterator<[string, string]>} An iterator for the entries of this cookie store. | ||
*/ | ||
toString(): string; | ||
[Symbol.iterator](): IterableIterator<[string, string]>; | ||
#private; | ||
} | ||
/** | ||
* Defines the options of a {@link CookieStore} instance. | ||
* Defines the options of a {@link CookieStore } instance. | ||
*/ | ||
export interface CookieStoreOptions { | ||
export type CookieStoreOptions = { | ||
/** | ||
* The default cookie options. | ||
*/ | ||
defaults: Partial<CookieOptionsParams>; | ||
defaults: Partial<import("./cookie_options.js").CookieOptionsParams>; | ||
/** | ||
@@ -116,3 +116,5 @@ * A string prefixed to every key so that it is unique globally in the whole cookie store. | ||
keyPrefix: string; | ||
} | ||
}; | ||
import { CookieOptions } from "./cookie_options.js"; | ||
import { CookieEvent } from "./cookie_event.js"; | ||
//# sourceMappingURL=cookie_store.d.ts.map |
/** | ||
* Defines the values of the `SameSite` cookie attribute. | ||
*/ | ||
export declare enum SameSite { | ||
export type SameSite = string; | ||
/** | ||
* Defines the values of the `SameSite` cookie attribute. | ||
* @enum {string} | ||
*/ | ||
export const SameSite: Readonly<{ | ||
/** | ||
* Only send cookies for top level navigation requests. | ||
*/ | ||
lax = "lax", | ||
lax: "lax"; | ||
/** | ||
* No restrictions on cross-site requests. | ||
*/ | ||
none = "none", | ||
none: "none"; | ||
/** | ||
* Prevents the cookie from being sent to the target site in all cross-site browsing context. | ||
*/ | ||
strict = "strict" | ||
} | ||
strict: "strict"; | ||
}>; | ||
//# sourceMappingURL=same_site.d.ts.map |
{ | ||
"bugs": "https://github.com/cedx/cookies.js/issues", | ||
"description": "Service for interacting with the HTTP cookies.", | ||
"homepage": "https://docs.belin.io/cookies.js", | ||
"homepage": "https://github.com/cedx/cookies.js", | ||
"license": "MIT", | ||
@@ -9,3 +9,3 @@ "name": "@cedx/cookies", | ||
"type": "module", | ||
"version": "6.0.0", | ||
"version": "6.0.1", | ||
"author": { | ||
@@ -17,22 +17,24 @@ "email": "cedric@belin.io", | ||
"devDependencies": { | ||
"@types/chai": "^4.3.12", | ||
"@types/eslint__js": "^8.42.3", | ||
"@babel/eslint-parser": "^7.24.7", | ||
"@babel/plugin-syntax-import-attributes": "^7.24.7", | ||
"@types/chai": "^4.3.14", | ||
"@types/gulp": "^4.0.17", | ||
"@types/mocha": "^10.0.6", | ||
"@types/node": "^20.11.28", | ||
"@web/test-runner": "^0.18.1", | ||
"@types/node": "^20.14.2", | ||
"@web/test-runner": "^0.18.2", | ||
"@web/test-runner-playwright": "^0.11.0", | ||
"chai": "^5.1.0", | ||
"chai": "^5.1.1", | ||
"del": "^7.1.0", | ||
"eslint": "^8.57.0", | ||
"execa": "^8.0.1", | ||
"typedoc": "^0.25.12", | ||
"typescript": "^5.4.2", | ||
"typescript-eslint": "^7.2.0" | ||
"eslint": "^9.5.0", | ||
"execa": "^9.2.0", | ||
"globals": "^15.4.0", | ||
"gulp": "^5.0.0", | ||
"typescript": "^5.4.5" | ||
}, | ||
"engines": { | ||
"node": ">=20.0.0" | ||
"node": ">=22.0.0" | ||
}, | ||
"exports": { | ||
"types": "./lib/index.d.ts", | ||
"import": "./lib/index.js" | ||
"default": "./src/index.js" | ||
}, | ||
@@ -53,11 +55,5 @@ "files": [ | ||
"scripts": { | ||
"build": "tsc --project src", | ||
"clean": "node tool/clean.js", | ||
"dist": "npm run clean && npm run build", | ||
"doc": "typedoc --options etc/typedoc.js && node tool/doc.js", | ||
"lint": "npm run build && tsc --project . && eslint --config=etc/eslint.config.js etc example src test tool", | ||
"prepack": "npm run dist", | ||
"release": "node tool/publish.js", | ||
"test": "npm run build && web-test-runner --config=etc/test_runner.js" | ||
"prepack": "gulp", | ||
"test": "web-test-runner --config=etc/test_runner.js" | ||
} | ||
} |
@@ -8,8 +8,7 @@ # Cookies for JS | ||
## Documentation | ||
- [User guide](https://docs.belin.io/cookies.js) | ||
- [API reference](https://docs.belin.io/cookies.js/api) | ||
- [User guide](https://github.com/cedx/cookies.js/wiki) | ||
- [Examples](https://github.com/cedx/cookies.js/tree/main/example) | ||
## Development | ||
- [Git repository](https://github.com/cedx/cookies.js) | ||
- [npm package](https://www.npmjs.com/package/@cedx/cookies) | ||
- [Submit an issue](https://github.com/cedx/cookies.js/issues) | ||
@@ -16,0 +15,0 @@ |
{ | ||
"extends": "../tsconfig", | ||
"include": ["index.ts"], | ||
"extends": "../tsconfig.json", | ||
"include": ["**/*.js"], | ||
"compilerOptions": { | ||
"declaration": true, | ||
"declarationMap": true, | ||
"emitDeclarationOnly": true, | ||
"incremental": true, | ||
"noEmit": false, | ||
"outDir": "../lib" | ||
"outDir": "../lib", | ||
"tsBuildInfoFile": "../var/tsbuildinfo.json" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
0
24540
15
19
589
17
1