{"id":18262900,"url":"https://github.com/midwayjs/cookies","last_synced_at":"2025-04-09T01:24:56.899Z","repository":{"id":42233049,"uuid":"439536948","full_name":"midwayjs/cookies","owner":"midwayjs","description":"midway cookies adds some new features to koa and serverless.","archived":false,"fork":false,"pushed_at":"2023-12-28T11:40:53.000Z","size":32,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-02-14T19:36:32.194Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/midwayjs.png","metadata":{"files":{"readme":"README.md","changelog":"History.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2021-12-18T05:35:30.000Z","updated_at":"2021-12-19T05:06:58.000Z","dependencies_parsed_at":"2024-01-23T21:20:32.112Z","dependency_job_id":"428c6d21-cefc-4fc0-996c-a4b2cc071450","html_url":"https://github.com/midwayjs/cookies","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/midwayjs%2Fcookies","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/midwayjs%2Fcookies/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/midwayjs%2Fcookies/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/midwayjs%2Fcookies/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/midwayjs","download_url":"https://codeload.github.com/midwayjs/cookies/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247954575,"owners_count":21024244,"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":[],"created_at":"2024-11-05T11:09:14.882Z","updated_at":"2025-04-09T01:24:56.873Z","avatar_url":"https://github.com/midwayjs.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Midway Cookies\n\nExtends [pillarjs/cookies](https://github.com/pillarjs/cookies) and Egg Cookies to adapt koa and serverless with some additional features.\n\nMore encryption than the original version, using a more secure aes-256-gcm algorithm.\n\n## Encrypt\n\n@midwayjs/cookies provide an alternative `encrypt` mode like `signed`. An encrypt cookie's value will be encrypted base on keys. Anyone who don't have the keys are unable to know the original cookie's value.\n\n```ts\nimport * as Cookies from '@midwayjs/cookies');\nctx.cookies = new Cookies(ctx, keys[, defaultCookieOptions]);\nctx.cookies.set('foo', 'bar', { encrypt: true });\nctx.cookies.get('foo', { encrypt: true });\n```\n\n**Note: you should both indicating in get and set in pairs.**\n\n## Set cookie\n\nSet a cookie through `cookies.set(key, value, options)`. The parameters supported by options are:\n\n- path - The valid path of the `String` cookie, the default is `/`.\n- domain - The valid domain name range of `String` cookie, the default is `undefined`.\n- expires - the expiration time of the `Date` cookie.\n- maxAge - the maximum valid time of the `Number` cookie. If maxAge is set, the value of expires will be overwritten.\n- secure - Whether `Boolean` is only transmitted in an encrypted channel. Note that if the request is http, it is not allowed to be set to true. If https is automatically set to true.\n- httpOnly - `Boolean` If set to true, the browser is not allowed to read the value of this cookie.\n- overwrite - `Boolean` If set to true, repeatedly writing the same key on a request will overwrite the previous value written, the default is false.\n- signed - Whether `Boolean` needs to sign the cookie or not, the signed parameter needs to be passed when cooperating with get. At this time, the front-end cannot tamper with the cookie. The default is true.\n- encrypt - Whether `Boolean` needs to encrypt the cookie, you need to pass the encrypt parameter when using get. At this time, the front-end cannot read the real cookie value, and the default is false.\n- partitioned - Whether `Boolean` sets cookies for independent partition state ([CHIPS](https://developers.google.com/privacy-sandbox/3pcd/chips)). Note that this configuration will only take effect if 'secure' is true.\n- removeUnpartitioned - `Boolean` Whether to delete the cookie with the same name in the non-independent partition state. Note that this configuration will only take effect when `partitioned` is true.\n- priority - `String` sets the [priority of the cookie](https://developer.chrome.com/blog/new-in-devtools-81?hl=zh-cn#cookiepriority), the optional value is `Low` , `Medium`, `High`, only valid for Chrome \u003e= 81 version.\n\n## Read cookie\n\nRead a cookie through `cookies.get(key, value, options)`. The parameters supported by options are:\n\n- signed - Whether `Boolean` needs to verify the cookie, and pass the signed parameter when cooperating with the set. At this time, the front-end cannot tamper with the cookie. The default is true.\n- encrypt - Whether `Boolean` needs to decrypt the cookie, and pass the encrypt parameter when cooperating with the set. At this time, the front-end cannot read the real cookie value, and the default is false.\n\n## Delete cookie\n\nUse `cookie.set(key, null)` to delete a cookie. If the `signed` parameter is passed, the signature will also be deleted.\n\n## License\n\n[MIT]((http://github.com/midwayjs/cookies/blob/master/LICENSE))\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmidwayjs%2Fcookies","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmidwayjs%2Fcookies","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmidwayjs%2Fcookies/lists"}