{"id":22491763,"url":"https://github.com/travishorn/session-timeout","last_synced_at":"2025-03-05T14:13:39.919Z","repository":{"id":42814048,"uuid":"172782074","full_name":"travishorn/session-timeout","owner":"travishorn","description":"Warn users when their session is about to expire. Dependency-free.","archived":false,"fork":false,"pushed_at":"2024-08-30T20:32:04.000Z","size":909,"stargazers_count":41,"open_issues_count":4,"forks_count":20,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-02-26T13:09:11.373Z","etag":null,"topics":["front-end","interface","javascript","session","timeout","timer","ui","user","warning"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/travishorn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-02-26T20:06:50.000Z","updated_at":"2025-01-30T09:43:09.000Z","dependencies_parsed_at":"2024-06-21T13:07:52.071Z","dependency_job_id":"e9032760-6d4d-4421-9427-14b716c71af9","html_url":"https://github.com/travishorn/session-timeout","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/travishorn%2Fsession-timeout","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/travishorn%2Fsession-timeout/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/travishorn%2Fsession-timeout/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/travishorn%2Fsession-timeout/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/travishorn","download_url":"https://codeload.github.com/travishorn/session-timeout/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242039721,"owners_count":20061927,"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":["front-end","interface","javascript","session","timeout","timer","ui","user","warning"],"created_at":"2024-12-06T18:10:12.385Z","updated_at":"2025-03-05T14:13:39.886Z","avatar_url":"https://github.com/travishorn.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Session Timeout\n\nWarn users when their session is about to expire. Dependency-free.\n\nWhen this function is called (usually each time a page is loaded), a timer starts in the background.\nWhen the timer goes off, a warning is displayed to the user that their session is about to expire.\nThe user has two options: Log out now or stay connected. If they choose to log out, they are brought\nto your site's log out page. If they choose to stay connected, a keep-alive URL is requested in the\nbackground, the warning is hidden, and the timer resets.\n\nThis project is the successor to\n[jquery-sessionTimeout](https://github.com/travishorn/jquery-sessionTimeout). I built this new\nversion to remove the dependency on jQuery and jQuery UI.\n\n![Animated demonstration](samples/demo.gif)\n\n## Installation\n\n### Method 1: CDN\n\nInclude the script on your page via UNPKG.\n\n```html\n\u003cscript src=\"https://unpkg.com/@travishorn/session-timeout\"\u003e\u003c/script\u003e\n```\n\n### Method 2: Download\n\nDownload [dist/session-timeout.js](dist/session-timeout.js).\n\nInclude it on your page.\n\n```html\n\u003cscript src=\"session-timeout.js\"\u003e\u003c/script\u003e\n```\n\n### Method 3: ES6 Module using npm and webpack (or similar)\n\nInstall via npm.\n\n```\n\u003e npm install @travishorn/session-timeout\n```\n\nInclude it in your scripts.\n\n```javascript\nimport sessionTimeout from '@travishorn/session-timeout';\n```\n\n## Usage\n\nCall it in JavaScript.\n\n```javascript\nsessionTimeout();\n```\n\nProvide options as an object.\n\n```javascript\nsessionTimeout({\n  warnAfter: 60000,\n  message: 'Are you still there?',\n});\n```\n\n## Options\n\n### appendTimestamp\n\nIf `true`, appends the a timestamp parameter to the end of the keep-alive URL with each request.\nThis can prevent caching issues by guaranteeing the URL is unique.\n\nDefault: `false`\n\nExample URL: `/keep-alive?time=1551203965297`\n\n### keepAliveMethod\n\nThe HTTP method to use when making the keep-alive request.\n\nDefault: `POST`\n\n### keepAliveUrl\n\nWhen the user clicks the \"Stay connected\" button, this URL is requested in the background to keep\ntheir session alive.\n\nDefault: `/keep-alive`\n\n### logOutBtnText\n\nThe text on the log out button.\n\nDefault: `Log out now`\n\n### logOutUrl\n\nWhen the user clicks the \"Log out now\" button, their browser is directed to this URL.\n\nDefault: `/log-out`\n\n### titleText\n\nThe text displayed at the top of the dialog.\n\nDefault: `Session Timeout`\n\n### message\n\nThe message to display when warning the user of inactivity.\n\nDefault: `Your session is about to expire.`\n\n### stayConnectedBtnText\n\nThe text on the \"stay connected\" button.\n\nDefault: `Stay connected`\n\n### timeOutAfter\n\nThe amount of time, in milliseconds, to wait until automatically timing out the user and redirecting\ntheir client to the time-out URL. You will usually want to set this to the same amount of time your\nserver keeps sessions alive. This timer gets reset if the users clicks the \"stay connected\" button\non the warning dialog.\n\nDefault: `1200000` (20 minutes)\n\n### timeOutUrl\n\nOnce the time out period has elapsed, the user's browser will be directed to this URL.\n\nDefault: `/timed-out`\n\n### warnAfter\n\nThe amount of time, in milliseconds, to wait until displaying a warning to the user. If the\nuser clicks the \"stay connected\" button, the warning disappears, and the timer is reset. The warning\nwill re-appear after the same amount of time after reset.\n\nDefault: `900000` (15 minutes)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftravishorn%2Fsession-timeout","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftravishorn%2Fsession-timeout","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftravishorn%2Fsession-timeout/lists"}