{"action":"created","comment":{"url":"https://api.github.com/repos/Avaq/node-server-skeleton/pulls/comments/88266742","pull_request_review_id":8842870,"id":88266742,"diff_hunk":"@@ -0,0 +1,196 @@\n+'use strict';\n+\n+const error = require('http-errors');\n+const Future = require('fluture');\n+const {eitherToFuture} = require('../../util/future');\n+const {randomString} = require('../../util/hash');\n+const config = require('config');\n+const {K, pipe, at, get, Left, Right, maybeToEither, or} = require('sanctuary-env');\n+const {chain, ifElse, test, split, trim, curry, difference, isEmpty, map} = require('ramda');\n+\n+//data TokenType = Authorization | Refresh\n+const Authorization = 1;\n+const Refresh = 2;\n+\n+//    tokenLife :: Number\n+const tokenLife = config.get('security.tokenLife');\n+\n+//    refreshLife :: Number\n+const refreshLife = config.get('security.refreshLife');\n+\n+//    tokenClaimKeys :: Array String\n+const tokenClaimKeys = ['_', 't', '$', 'iat', 'exp'];\n+\n+//    refreshClaimKeys :: Array String\n+const refreshClaimKeys = ['_', 't', 'exp'];\n+\n+//    invalidTokenClaims :: InvalidRequestError\n+const invalidTokenClaims = error(400, {\n+  name: 'InvalidTokenClaimsError',\n+  message: 'Given token does not contain exactly the expected claims'\n+});\n+\n+//    invalidRefreshClaims :: InvalidRequestError\n+const invalidRefreshClaims = error(400, {\n+  name: 'InvalidRefreshClaimsError',\n+  message: 'Given refresh token does not contain exactly the expected claims'\n+});\n+\n+//    invalidTokenType :: InvalidRequestError\n+const invalidTokenType = error(400, {\n+  name: 'InvalidTokenTypeError',\n+  message: 'An invalid type of token was provided where an Authorization token was expected'\n+});\n+\n+//    invalidRefreshType :: InvalidRequestError\n+const invalidRefreshType = error(400, {\n+  name: 'InvalidRefreshTypeError',\n+  message: 'An invalid type of token was provided where a Refresh token was expected'\n+});\n+\n+//    invalidSessionType :: InternalServerError\n+const invalidSessionType = error(500, {\n+  name: 'InvalidSessionTypeError',\n+  message: 'Unexpected session data type'\n+});\n+\n+//    missingAuthorizationHeader :: NotAuthorizedError\n+const missingAuthorizationHeader = error(403, {\n+  name: 'MissingAuthorizationHeaderError',\n+  message: 'Missing Authorization header'\n+});\n+\n+//    missingTokenCookie :: NotAuthorizedError\n+const missingTokenCookie = error(403, {\n+  name: 'MissingTokenCookieError',\n+  message: 'Missing Cookie header'\n+});\n+\n+//    malformedAuthorizationHeader :: InvalidRequestError\n+const malformedAuthorizationHeader = error(400, {\n+  name: 'MalformedAuthorizationHeaderError',\n+  message: 'Malformed Authorization header'\n+});\n+\n+//    malformedAuthorizationHeader :: InvalidRequestError\n+const invalidAuthorizationHeader = error(400, {\n+  name: 'InvalidAuthorizationHeaderError',\n+  message: 'Authorization method must be Bearer'\n+});\n+\n+//    tokenExpired :: NotAuthorizedError\n+const tokenExpired = error(403, {\n+  name: 'TokenExpiredError',\n+  message: 'Token expired'\n+});\n+\n+//    refreshExpired :: NotAuthorizedError\n+const refreshExpired = error(403, {\n+  name: 'RefreshExpiredError',\n+  message: 'Token expired'\n+});\n+\n+//    tokenNotExpired :: NotAuthorizedError\n+const tokenNotExpired = error(400, {\n+  name: 'TokenNotExpiredError',\n+  message: 'Token has not expired yet'\n+});\n+\n+//    pairIdMismatch :: NotAuthorizedError","path":"src/actions/auth/_util.js","position":99,"original_position":99,"commit_id":"2108f315348ac57261d3234480492597861c853e","original_commit_id":"2108f315348ac57261d3234480492597861c853e","user":{"login":"Avaq","id":1217745,"avatar_url":"https://avatars.githubusercontent.com/u/1217745?v=3","gravatar_id":"","url":"https://api.github.com/users/Avaq","html_url":"https://github.com/Avaq","followers_url":"https://api.github.com/users/Avaq/followers","following_url":"https://api.github.com/users/Avaq/following{/other_user}","gists_url":"https://api.github.com/users/Avaq/gists{/gist_id}","starred_url":"https://api.github.com/users/Avaq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Avaq/subscriptions","organizations_url":"https://api.github.com/users/Avaq/orgs","repos_url":"https://api.github.com/users/Avaq/repos","events_url":"https://api.github.com/users/Avaq/events{/privacy}","received_events_url":"https://api.github.com/users/Avaq/received_events","type":"User","site_admin":false},"body":"if it is 'NotAuthorizedError' it should be 403","created_at":"2016-11-16T16:03:44Z","updated_at":"2016-11-16T16:28:47Z","html_url":"https://github.com/Avaq/node-server-skeleton/pull/7#discussion_r88266742","pull_request_url":"https://api.github.com/repos/Avaq/node-server-skeleton/pulls/7","_links":{"self":{"href":"https://api.github.com/repos/Avaq/node-server-skeleton/pulls/comments/88266742"},"html":{"href":"https://github.com/Avaq/node-server-skeleton/pull/7#discussion_r88266742"},"pull_request":{"href":"https://api.github.com/repos/Avaq/node-server-skeleton/pulls/7"}}},"pull_request":{"url":"https://api.github.com/repos/Avaq/node-server-skeleton/pulls/7","id":93796608,"html_url":"https://github.com/Avaq/node-server-skeleton/pull/7","diff_url":"https://github.com/Avaq/node-server-skeleton/pull/7.diff","patch_url":"https://github.com/Avaq/node-server-skeleton/pull/7.patch","issue_url":"https://api.github.com/repos/Avaq/node-server-skeleton/issues/7","number":7,"state":"open","locked":false,"title":"Authorization","user":{"login":"Avaq","id":1217745,"avatar_url":"https://avatars.githubusercontent.com/u/1217745?v=3","gravatar_id":"","url":"https://api.github.com/users/Avaq","html_url":"https://github.com/Avaq","followers_url":"https://api.github.com/users/Avaq/followers","following_url":"https://api.github.com/users/Avaq/following{/other_user}","gists_url":"https://api.github.com/users/Avaq/gists{/gist_id}","starred_url":"https://api.github.com/users/Avaq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Avaq/subscriptions","organizations_url":"https://api.github.com/users/Avaq/orgs","repos_url":"https://api.github.com/users/Avaq/repos","events_url":"https://api.github.com/users/Avaq/events{/privacy}","received_events_url":"https://api.github.com/users/Avaq/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-11-15T16:14:07Z","updated_at":"2016-11-16T16:28:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"83f197ad559797f17b82c2052148c4f4c9ae379c","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/Avaq/node-server-skeleton/pulls/7/commits","review_comments_url":"https://api.github.com/repos/Avaq/node-server-skeleton/pulls/7/comments","review_comment_url":"https://api.github.com/repos/Avaq/node-server-skeleton/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Avaq/node-server-skeleton/issues/7/comments","statuses_url":"https://api.github.com/repos/Avaq/node-server-skeleton/statuses/2108f315348ac57261d3234480492597861c853e","head":{"label":"Avaq:authorization","ref":"authorization","sha":"2108f315348ac57261d3234480492597861c853e","user":{"login":"Avaq","id":1217745,"avatar_url":"https://avatars.githubusercontent.com/u/1217745?v=3","gravatar_id":"","url":"https://api.github.com/users/Avaq","html_url":"https://github.com/Avaq","followers_url":"https://api.github.com/users/Avaq/followers","following_url":"https://api.github.com/users/Avaq/following{/other_user}","gists_url":"https://api.github.com/users/Avaq/gists{/gist_id}","starred_url":"https://api.github.com/users/Avaq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Avaq/subscriptions","organizations_url":"https://api.github.com/users/Avaq/orgs","repos_url":"https://api.github.com/users/Avaq/repos","events_url":"https://api.github.com/users/Avaq/events{/privacy}","received_events_url":"https://api.github.com/users/Avaq/received_events","type":"User","site_admin":false},"repo":{"id":45180467,"name":"node-server-skeleton","full_name":"Avaq/node-server-skeleton","owner":{"login":"Avaq","id":1217745,"avatar_url":"https://avatars.githubusercontent.com/u/1217745?v=3","gravatar_id":"","url":"https://api.github.com/users/Avaq","html_url":"https://github.com/Avaq","followers_url":"https://api.github.com/users/Avaq/followers","following_url":"https://api.github.com/users/Avaq/following{/other_user}","gists_url":"https://api.github.com/users/Avaq/gists{/gist_id}","starred_url":"https://api.github.com/users/Avaq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Avaq/subscriptions","organizations_url":"https://api.github.com/users/Avaq/orgs","repos_url":"https://api.github.com/users/Avaq/repos","events_url":"https://api.github.com/users/Avaq/events{/privacy}","received_events_url":"https://api.github.com/users/Avaq/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Avaq/node-server-skeleton","description":"A starting point for an experimental Node server application","fork":false,"url":"https://api.github.com/repos/Avaq/node-server-skeleton","forks_url":"https://api.github.com/repos/Avaq/node-server-skeleton/forks","keys_url":"https://api.github.com/repos/Avaq/node-server-skeleton/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Avaq/node-server-skeleton/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Avaq/node-server-skeleton/teams","hooks_url":"https://api.github.com/repos/Avaq/node-server-skeleton/hooks","issue_events_url":"https://api.github.com/repos/Avaq/node-server-skeleton/issues/events{/number}","events_url":"https://api.github.com/repos/Avaq/node-server-skeleton/events","assignees_url":"https://api.github.com/repos/Avaq/node-server-skeleton/assignees{/user}","branches_url":"https://api.github.com/repos/Avaq/node-server-skeleton/branches{/branch}","tags_url":"https://api.github.com/repos/Avaq/node-server-skeleton/tags","blobs_url":"https://api.github.com/repos/Avaq/node-server-skeleton/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Avaq/node-server-skeleton/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Avaq/node-server-skeleton/git/refs{/sha}","trees_url":"https://api.github.com/repos/Avaq/node-server-skeleton/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Avaq/node-server-skeleton/statuses/{sha}","languages_url":"https://api.github.com/repos/Avaq/node-server-skeleton/languages","stargazers_url":"https://api.github.com/repos/Avaq/node-server-skeleton/stargazers","contributors_url":"https://api.github.com/repos/Avaq/node-server-skeleton/contributors","subscribers_url":"https://api.github.com/repos/Avaq/node-server-skeleton/subscribers","subscription_url":"https://api.github.com/repos/Avaq/node-server-skeleton/subscription","commits_url":"https://api.github.com/repos/Avaq/node-server-skeleton/commits{/sha}","git_commits_url":"https://api.github.com/repos/Avaq/node-server-skeleton/git/commits{/sha}","comments_url":"https://api.github.com/repos/Avaq/node-server-skeleton/comments{/number}","issue_comment_url":"https://api.github.com/repos/Avaq/node-server-skeleton/issues/comments{/number}","contents_url":"https://api.github.com/repos/Avaq/node-server-skeleton/contents/{+path}","compare_url":"https://api.github.com/repos/Avaq/node-server-skeleton/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Avaq/node-server-skeleton/merges","archive_url":"https://api.github.com/repos/Avaq/node-server-skeleton/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Avaq/node-server-skeleton/downloads","issues_url":"https://api.github.com/repos/Avaq/node-server-skeleton/issues{/number}","pulls_url":"https://api.github.com/repos/Avaq/node-server-skeleton/pulls{/number}","milestones_url":"https://api.github.com/repos/Avaq/node-server-skeleton/milestones{/number}","notifications_url":"https://api.github.com/repos/Avaq/node-server-skeleton/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Avaq/node-server-skeleton/labels{/name}","releases_url":"https://api.github.com/repos/Avaq/node-server-skeleton/releases{/id}","deployments_url":"https://api.github.com/repos/Avaq/node-server-skeleton/deployments","created_at":"2015-10-29T12:03:06Z","updated_at":"2016-10-28T11:39:33Z","pushed_at":"2016-11-16T14:08:08Z","git_url":"git://github.com/Avaq/node-server-skeleton.git","ssh_url":"git@github.com:Avaq/node-server-skeleton.git","clone_url":"https://github.com/Avaq/node-server-skeleton.git","svn_url":"https://github.com/Avaq/node-server-skeleton","homepage":"","size":154,"stargazers_count":10,"watchers_count":10,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":1,"forks":4,"open_issues":1,"watchers":10,"default_branch":"master"}},"base":{"label":"Avaq:master","ref":"master","sha":"8392d4a6aa8ddaf5c1b6544abb3693110c9b3437","user":{"login":"Avaq","id":1217745,"avatar_url":"https://avatars.githubusercontent.com/u/1217745?v=3","gravatar_id":"","url":"https://api.github.com/users/Avaq","html_url":"https://github.com/Avaq","followers_url":"https://api.github.com/users/Avaq/followers","following_url":"https://api.github.com/users/Avaq/following{/other_user}","gists_url":"https://api.github.com/users/Avaq/gists{/gist_id}","starred_url":"https://api.github.com/users/Avaq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Avaq/subscriptions","organizations_url":"https://api.github.com/users/Avaq/orgs","repos_url":"https://api.github.com/users/Avaq/repos","events_url":"https://api.github.com/users/Avaq/events{/privacy}","received_events_url":"https://api.github.com/users/Avaq/received_events","type":"User","site_admin":false},"repo":{"id":45180467,"name":"node-server-skeleton","full_name":"Avaq/node-server-skeleton","owner":{"login":"Avaq","id":1217745,"avatar_url":"https://avatars.githubusercontent.com/u/1217745?v=3","gravatar_id":"","url":"https://api.github.com/users/Avaq","html_url":"https://github.com/Avaq","followers_url":"https://api.github.com/users/Avaq/followers","following_url":"https://api.github.com/users/Avaq/following{/other_user}","gists_url":"https://api.github.com/users/Avaq/gists{/gist_id}","starred_url":"https://api.github.com/users/Avaq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Avaq/subscriptions","organizations_url":"https://api.github.com/users/Avaq/orgs","repos_url":"https://api.github.com/users/Avaq/repos","events_url":"https://api.github.com/users/Avaq/events{/privacy}","received_events_url":"https://api.github.com/users/Avaq/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Avaq/node-server-skeleton","description":"A starting point for an experimental Node server application","fork":false,"url":"https://api.github.com/repos/Avaq/node-server-skeleton","forks_url":"https://api.github.com/repos/Avaq/node-server-skeleton/forks","keys_url":"https://api.github.com/repos/Avaq/node-server-skeleton/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Avaq/node-server-skeleton/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Avaq/node-server-skeleton/teams","hooks_url":"https://api.github.com/repos/Avaq/node-server-skeleton/hooks","issue_events_url":"https://api.github.com/repos/Avaq/node-server-skeleton/issues/events{/number}","events_url":"https://api.github.com/repos/Avaq/node-server-skeleton/events","assignees_url":"https://api.github.com/repos/Avaq/node-server-skeleton/assignees{/user}","branches_url":"https://api.github.com/repos/Avaq/node-server-skeleton/branches{/branch}","tags_url":"https://api.github.com/repos/Avaq/node-server-skeleton/tags","blobs_url":"https://api.github.com/repos/Avaq/node-server-skeleton/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Avaq/node-server-skeleton/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Avaq/node-server-skeleton/git/refs{/sha}","trees_url":"https://api.github.com/repos/Avaq/node-server-skeleton/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Avaq/node-server-skeleton/statuses/{sha}","languages_url":"https://api.github.com/repos/Avaq/node-server-skeleton/languages","stargazers_url":"https://api.github.com/repos/Avaq/node-server-skeleton/stargazers","contributors_url":"https://api.github.com/repos/Avaq/node-server-skeleton/contributors","subscribers_url":"https://api.github.com/repos/Avaq/node-server-skeleton/subscribers","subscription_url":"https://api.github.com/repos/Avaq/node-server-skeleton/subscription","commits_url":"https://api.github.com/repos/Avaq/node-server-skeleton/commits{/sha}","git_commits_url":"https://api.github.com/repos/Avaq/node-server-skeleton/git/commits{/sha}","comments_url":"https://api.github.com/repos/Avaq/node-server-skeleton/comments{/number}","issue_comment_url":"https://api.github.com/repos/Avaq/node-server-skeleton/issues/comments{/number}","contents_url":"https://api.github.com/repos/Avaq/node-server-skeleton/contents/{+path}","compare_url":"https://api.github.com/repos/Avaq/node-server-skeleton/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Avaq/node-server-skeleton/merges","archive_url":"https://api.github.com/repos/Avaq/node-server-skeleton/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Avaq/node-server-skeleton/downloads","issues_url":"https://api.github.com/repos/Avaq/node-server-skeleton/issues{/number}","pulls_url":"https://api.github.com/repos/Avaq/node-server-skeleton/pulls{/number}","milestones_url":"https://api.github.com/repos/Avaq/node-server-skeleton/milestones{/number}","notifications_url":"https://api.github.com/repos/Avaq/node-server-skeleton/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Avaq/node-server-skeleton/labels{/name}","releases_url":"https://api.github.com/repos/Avaq/node-server-skeleton/releases{/id}","deployments_url":"https://api.github.com/repos/Avaq/node-server-skeleton/deployments","created_at":"2015-10-29T12:03:06Z","updated_at":"2016-10-28T11:39:33Z","pushed_at":"2016-11-16T14:08:08Z","git_url":"git://github.com/Avaq/node-server-skeleton.git","ssh_url":"git@github.com:Avaq/node-server-skeleton.git","clone_url":"https://github.com/Avaq/node-server-skeleton.git","svn_url":"https://github.com/Avaq/node-server-skeleton","homepage":"","size":154,"stargazers_count":10,"watchers_count":10,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":1,"forks":4,"open_issues":1,"watchers":10,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Avaq/node-server-skeleton/pulls/7"},"html":{"href":"https://github.com/Avaq/node-server-skeleton/pull/7"},"issue":{"href":"https://api.github.com/repos/Avaq/node-server-skeleton/issues/7"},"comments":{"href":"https://api.github.com/repos/Avaq/node-server-skeleton/issues/7/comments"},"review_comments":{"href":"https://api.github.com/repos/Avaq/node-server-skeleton/pulls/7/comments"},"review_comment":{"href":"https://api.github.com/repos/Avaq/node-server-skeleton/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Avaq/node-server-skeleton/pulls/7/commits"},"statuses":{"href":"https://api.github.com/repos/Avaq/node-server-skeleton/statuses/2108f315348ac57261d3234480492597861c853e"}}}}
{"actor":{"display_login":"Avaq"}}