{"id":16756781,"url":"https://github.com/charmander/session","last_synced_at":"2025-07-13T03:32:20.487Z","repository":{"id":57101269,"uuid":"136781122","full_name":"charmander/session","owner":"charmander","description":"User and guest session tokens","archived":false,"fork":false,"pushed_at":"2019-02-22T01:18:15.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-10T18:16:38.105Z","etag":null,"topics":["nodejs"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@charmander/session","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/charmander.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":"2018-06-10T05:12:59.000Z","updated_at":"2019-02-22T01:18:16.000Z","dependencies_parsed_at":"2022-08-20T21:10:43.434Z","dependency_job_id":null,"html_url":"https://github.com/charmander/session","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charmander%2Fsession","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charmander%2Fsession/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charmander%2Fsession/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charmander%2Fsession/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/charmander","download_url":"https://codeload.github.com/charmander/session/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225853027,"owners_count":17534644,"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":["nodejs"],"created_at":"2024-10-13T03:42:04.317Z","updated_at":"2024-11-22T06:26:16.876Z","avatar_url":"https://github.com/charmander.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build status][ci image]][ci]\n\n\n## API\n\n**Session tokens** are secret strings consisting of 32 ASCII characters in the range `a` through `p`.\n\n**CSRF tokens** are secret strings constisting of 30 ASCII characters in the range `a` through `p`.\n\n**Storage keys** are 16-byte `Buffer` values that don’t need to be treated as secret.\n\n**User ids** are non-`null`/`undefined` values otherwise free to be defined by the user of the `SessionBox`.\n\n\n- `new SessionBox(storage)`\n\n- `SessionBox#get(token, callback)`\n\n  Gets a session based on a token. The session token can change after this operation, indicated by a non-null `newToken` property. Pass `null` if no token was provided.\n\n- `SessionBox#update(session, newUserId, callback)`\n\n  Updates a session obtained from `SessionBox#get` with a new user id. The session token will always change after this operation, and the old session will be invalidated if it’s not a guest session. Pass `null` to update to a guest session.\n\n\n### Sessions\n\nSessions have the following public properties:\n\n- `newToken`\n\n  A new session token to return to the client, or `null` if the existing session token remains valid.\n\n- `userId`\n\n  The user id associated with the session. `null` represents a guest session.\n\n- `csrf`\n\n  The CSRF token associated with the session.\n\n\n### Storage\n\nA storage implementation should provide these methods:\n\n- `get(key, callback)`\n\n  Retrieves a user id based on a key. The callback has two parameters: `error, userId`.\n\n  If the key does not exist, the retrieved value should be `null` (but `undefined` is also accepted).\n\n- `set(key, userId, callback)`\n\n  Associates a user id with a key. The callback has one parameter: `error`.\n\n  The key will not already exist.\n\n- `delete(key, userId, callback)`\n\n  Disassociates a user id from a key. The id is provided in case the storage maintains a set of keys for each user (e.g. for the purposes of invalidating all of a user’s sessions). The callback has one parameter: `error`.\n\n  If the key does not exist, no error should be produced.\n\n\n  [ci]: https://travis-ci.com/charmander/session\n  [ci image]: https://api.travis-ci.com/charmander/session.svg?branch=master\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcharmander%2Fsession","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcharmander%2Fsession","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcharmander%2Fsession/lists"}