{"id":17218446,"url":"https://github.com/perliedman/utoken","last_synced_at":"2025-03-25T14:25:29.717Z","repository":{"id":143798130,"uuid":"120911386","full_name":"perliedman/utoken","owner":"perliedman","description":"Access token validation middleware for Zeit's Micro","archived":false,"fork":false,"pushed_at":"2018-02-09T15:25:57.000Z","size":35,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-18T15:48:31.554Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/perliedman.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2018-02-09T13:51:34.000Z","updated_at":"2018-02-09T13:54:22.000Z","dependencies_parsed_at":"2023-07-10T03:46:27.037Z","dependency_job_id":null,"html_url":"https://github.com/perliedman/utoken","commit_stats":{"total_commits":3,"total_committers":1,"mean_commits":3.0,"dds":0.0,"last_synced_commit":"05cfaccff7dd359962d44f3a9f3416698b7b5678"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/perliedman%2Futoken","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/perliedman%2Futoken/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/perliedman%2Futoken/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/perliedman%2Futoken/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/perliedman","download_url":"https://codeload.github.com/perliedman/utoken/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245478661,"owners_count":20622017,"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-10-15T03:46:50.718Z","updated_at":"2025-03-25T14:25:29.673Z","avatar_url":"https://github.com/perliedman.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# µ-token (utoken)\n\nA access token validation middleware for [micro](https://github.com/zeit/micro).\n\nExample:\n\n```js\n  const accessTokenMiddleWare = require('utoken')\n  const app = require('my-micro-app')\n\n  micro(accessTokenMiddleWare(app))\n```\n\nThis will create a middleware that will read access tokens from the request's `access_token` query parameter.\nBy default, all tokens will be rejected, so we will need to specify a function that tests for valid access tokens:\n\n```js\n  micro(accessTokenMiddleWare(app, {\n    tokenValidatorFn: token =\u003e token == '12345'\n  }))\n```\n\nThis will allow the single access token `12345`. For real world use, you might want to look up the token in a database\nor something like that.\n\n## Options\n\nThere are a couple of options that can be passed to customize the middleware's functionality:\n\n### tokenAccessFn\n\nThis function specifies how the access token is extracted from a request; it is a function that will\nbe passed the HTTP request and should return the token (or `undefined` if not present).\n\nBy default, this function will extract the query parameter `access_token` from the request's URL.\n\n### tokenValidatorFn\n\nThis function validates an access token and returns `true` if it is a valid token and `false` otherwise.\n\nThe default is a function that _always_ returns `false` (rejects all tokens).\n\n### failFn\n\nCalled when access token validation fails: returns a HTTP 401 by default with the error message\n`\"Missing or invalid access token\"`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fperliedman%2Futoken","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fperliedman%2Futoken","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fperliedman%2Futoken/lists"}