{"id":15323788,"url":"https://github.com/StudyResearchProjects/patissier","last_synced_at":"2025-08-21T11:32:11.347Z","repository":{"id":57701919,"uuid":"495135895","full_name":"EstebanBorai/patissier","owner":"EstebanBorai","description":"HTTP Cookie builder library following the RFC6265","archived":false,"fork":false,"pushed_at":"2023-05-27T20:36:08.000Z","size":191,"stargazers_count":1,"open_issues_count":2,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-12-12T18:04:08.623Z","etag":null,"topics":["builder","cookies","http","javascript","patissier","typescript","web"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/patissier","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/EstebanBorai.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-05-22T17:55:54.000Z","updated_at":"2023-09-04T08:23:34.000Z","dependencies_parsed_at":"2022-09-26T22:30:28.217Z","dependency_job_id":null,"html_url":"https://github.com/EstebanBorai/patissier","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EstebanBorai%2Fpatissier","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EstebanBorai%2Fpatissier/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EstebanBorai%2Fpatissier/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EstebanBorai%2Fpatissier/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EstebanBorai","download_url":"https://codeload.github.com/EstebanBorai/patissier/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230510483,"owners_count":18237519,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["builder","cookies","http","javascript","patissier","typescript","web"],"created_at":"2024-10-01T09:22:08.363Z","updated_at":"2025-08-21T11:32:05.989Z","avatar_url":"https://github.com/EstebanBorai.png","language":"TypeScript","readme":"\u003cdiv\u003e\n  \u003cdiv align=\"center\" style=\"display: block; text-align: center;\"\u003e\n    \u003cimg src=\"./docs/cookie.png\" height=\"120\" width=\"120\" /\u003e\n  \u003c/div\u003e\n  \u003ch1 align=\"center\"\u003ePâtissier\u003c/h1\u003e\n  \u003ch4 align=\"center\"\u003e\n    HTTP Cookie builder library following the RFC6265\n  \u003c/h4\u003e\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n![Build](https://github.com/EstebanBorai/patissier/workflows/build/badge.svg)\n![Lint](https://github.com/EstebanBorai/patissier/workflows/lint/badge.svg)\n![Tests](https://github.com/EstebanBorai/patissier/workflows/test/badge.svg)\n\n\u003c/div\u003e\n\n## Usage\n\nThe following snippet makes use of the `CookieBuilder` class which implements\nthe [builder pattern][1] on the `Cookie` class exported by this library, to\ncreate a HTTP cookie.\n\n```ts\nimport { CookieBuilder } from 'patissier';\n\nconst cookie = new CookieBuilder()\n  .name('pepperoni')\n  .value('pizza_is_so_good')\n  .sameSite(SameSite.Lax)\n  .maxAge(12 * 24 * 60 * 60)\n  .domain('example.com')\n  .path('/')\n  .secure()\n  .httpOnly()\n  .build();\n\nassert(\n  cookie.toString() ===\n    'pepperoni=pizza_is_so_good; Max-Age=1036800; Domain=example.com; Path=/; Secure; HttpOnly; SameSite=Lax',\n);\n```\n\n## Installation\n\n```bash\nnpm install patissier\n```\n\n## Documentation\n\n### `Cookie`\n\nThe `Cookie` class is responsible of validating and creating HTTP cookies.\nWhenever a new `Cookie` instance is created, all of the attributes will be set\nto `null`.\n\n`Cookie` `class` design is thought with the encapsulation principle in mind.\n\nThis means that you must use the `class` instance _getters_ in order to\nretrieve the current value of one of the `Cookie` attributes values.\n\nSame goes for updating, whenever you want to update one of the instance\nattributes, you must use any of the `set*` like methods exposed by `Cookie`.\n\nThis is intended to protect values set to the `Cookie` instance to warranty\nthat the cookie cant be built with invalid attribute values.\n\n#### `Cookie.setName(name: string): void`\n\nSets the cookie name.\n\n#### `Cookie.setValue(value: string): void`\n\nSets the cookie value.\n\n#### `Cookie.setSameSite(value: SameSite): void`\n\nSets the cookie `SameSite` attribute.\n\nDeclare wether the cookie should be restricted to a first-party or\nsame-site context.\n\n- If Same-Site is not specified, then it defaults to `Lax`.\n\n- If the cookie's `SameSite` attribute's value is `None`, then the `Secure`\n  attribute must be specified.\n\n- If the cookie is sent to the same domain but with a different scheme, then\n  it wont be sent.\n\n\u003e **Warning**: You must provide a variant from the `SameSite` `enum` exported by this library.\n\n[Read more on MDN][2]\n\n#### `Cookie.setExpires(date: Date): void`\n\n    Sets the `Expires` attribute for the cookie.\n\n    The `Expires` attribute specifies the deadline of the cookie. This date\n    instance is relative to the client's system clock and not the server's.\n\n    If this value is not specified, the cookie becomes a session cookie, which\n    means that the cookie wont persist when the client shut down.\n\n#### `Cookie.setMaxAge(seconds: number): void`\n\nSets the `Max-Age` attribute for the cookie.\n\nThe `Max-Age` attribute accepts a number representing the TTL in seconds\nfor the cookie. Whenever a 0 or negative value is provided, the cookie\nwill be considered as expired.\n\nIs important to note, that `Max-Age` has precedence over `Expires`, this\nmeans, that if both attibutes are present, `Max-Age` will defne the final\nbehavior.\n\n#### `Cookie.setDomain(domain: string): void`\n\n    Defines the host to which the cookie will be sent.\n\n\u003e **Warning**: Leading dots in domain names (`.example.com`) are ignored. This is specified in most recent spects. This library WILL NOT remove any leading dots from the input.\n\n#### `Cookie.setPath(path: string): void`\n\nIndicates a URL path that must exist in the requested URL in order to send\nthe Cookie header.\nThe `/` (`%x2F`) character is considered a directory separator,\nand subdirectories match as well.\n\n[Read more on MDN][3]\n\n#### `Cookie.setSecure(isSecure: boolean): void`\n\nSets the `Secure` attribute for the Cookie.\n\nA cookie with the `Secure` attribute is only sent to the server with an\nencrypted request over the HTTPS protocol. It's never sent with unsecured\nHTTP (except on localhost), which means man-in-the-middle attackers can't\naccess it easily.\n\n#### `Cookie.setHttpOnly(isHttpOnly: boolean): void`\n\nA cookie with the `HttpOnly` attribute is inaccessible to the JavaScript\n`Document.cookie` API; it's only sent to the server.\n\n[Read more on MDN][3]\n\n#### `Cookie.toString(): string`\n\nBuilds a HTTP Cookie with the current attributes.\n\n### `CookieBuilder`\n\nThe `CookieBuilder` `class` is built around the `Cookie`\nAPI. Most of the methods exposed by the `CookieBuilder` have the same input\ntypes as those from the `Cookie` `class`.\n\nBut different to `Cookie`, the `CookieBuilder` will return\nit's instance in order to allow access to other methods and\nbuild a `Cookie` instance on a single line.\n\nSimilar to `Cookie`, all attributes remain `null` by default.\n\n#### `CookieBuilder.secure(): CookieBuilder`\n\nSets the `Secure` attribute for the underlying `Cookie`.\n\n#### `CookieBuilder.httpOnly(): CookieBuilder`\n\nSets the `HttpOnly` attribute for the underlying `Cookie`.\n\n## Releasing\n\nWhenever a tag is pushed a new release is created an the package is\npublished to the NPM registry using GitHub Actions.\n\nBump the current version using `npm` as follows:\n\n```sh\n# for versions with breaking changes use `major`\nnpm version major\n\n# for versions with non-breaking changes use `minor`\nnpm version minor\n\n# for patch versions use `patch`\nnpm version patch\n```\n\nThen push the repository including tag metadata as follows\n\n```sh\ngit push origin main --follow-tags\n```\n\n## License\n\nThis project is licensed under the MIT License.\n\n## Contributing\n\nAny contribution to this package is welcome! Don't hesitate on opening a PR or creating an issue!\n\n[1]: https://en.wikipedia.org/wiki/Builder_pattern\n[2]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie/SameSite\n[3]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies\n[4]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FStudyResearchProjects%2Fpatissier","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FStudyResearchProjects%2Fpatissier","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FStudyResearchProjects%2Fpatissier/lists"}